diff --git a/.changeset/olive-shoes-kiss.md b/.changeset/olive-shoes-kiss.md new file mode 100644 index 000000000..c676a3abb --- /dev/null +++ b/.changeset/olive-shoes-kiss.md @@ -0,0 +1,6 @@ +--- +'@commercetools-test-data/commons': minor +'@commercetools-test-data/associate-role': minor +--- + +Add Associate Role package diff --git a/models/associate-role/LICENSE b/models/associate-role/LICENSE new file mode 100644 index 000000000..e113013cb --- /dev/null +++ b/models/associate-role/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) commercetools GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/models/associate-role/README.md b/models/associate-role/README.md new file mode 100644 index 000000000..0aade4c59 --- /dev/null +++ b/models/associate-role/README.md @@ -0,0 +1,31 @@ +# @commercetools-test-data/associate-role + +This package provides the data model for the commercetools platform `AssociateRole` representations + +https://docs.commercetools.com/api/projects/associate-roles#representations + +# Install + +```bash +$ pnpm add -D @commercetools-test-data/associate-role +``` + +# Usage + +```ts +import { + AssociateRole, + AssociateRoleDraft, + type TAssociateRole, + type TAssociateRoleDraft, +} from '@commercetools-test-data/associate-role'; + +const associateRole = AssociateRole.random().build(); +const AssociateRoleDraft = + AssociateRoleDraft.random().build(); + +// Presets +const emptyCustomerDraft = AssociateRole.presets + .withAllBusinessUnitPermissions() + .build(); +``` diff --git a/models/associate-role/package.json b/models/associate-role/package.json new file mode 100644 index 000000000..f87600c12 --- /dev/null +++ b/models/associate-role/package.json @@ -0,0 +1,28 @@ +{ + "name": "@commercetools-test-data/associate-role", + "version": "6.5.0", + "description": "Data model for commercetools API AssociateRole", + "bugs": "https://github.com/commercetools/test-data/issues", + "repository": { + "type": "git", + "url": "https://github.com/commercetools/test-data.git", + "directory": "models/associate-role" + }, + "keywords": ["javascript", "typescript", "test-data"], + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "main": "dist/commercetools-test-data-associate-role.cjs.js", + "module": "dist/commercetools-test-data-associate-role.esm.js", + "files": ["dist", "package.json", "LICENSE", "README.md"], + "dependencies": { + "@babel/runtime": "^7.17.9", + "@babel/runtime-corejs3": "^7.17.9", + "@commercetools-test-data/commons": "6.4.2", + "@commercetools-test-data/core": "6.4.2", + "@commercetools-test-data/utils": "6.4.2", + "@commercetools/platform-sdk": "^6.0.0", + "@faker-js/faker": "^8.0.0" + } +} diff --git a/models/associate-role/src/associate-role-draft/builder.spec.ts b/models/associate-role/src/associate-role-draft/builder.spec.ts new file mode 100644 index 000000000..691e70b0e --- /dev/null +++ b/models/associate-role/src/associate-role-draft/builder.spec.ts @@ -0,0 +1,49 @@ +/* eslint-disable jest/no-disabled-tests */ +/* eslint-disable jest/valid-title */ +import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; +import type { TAssociateRoleDraft } from '../types'; +import * as AssociateRoleDraft from './index'; + +describe('builder', () => { + it( + ...createBuilderSpec( + 'default', + AssociateRoleDraft.random(), + expect.objectContaining({ + key: expect.any(String), + name: expect.any(String), + buyerAssignable: expect.any(Boolean), + permissions: expect.any(Array), + custom: null, + }) + ) + ); + + it( + ...createBuilderSpec( + 'rest', + AssociateRoleDraft.random(), + expect.objectContaining({ + key: expect.any(String), + name: expect.any(String), + buyerAssignable: expect.any(Boolean), + permissions: expect.any(Array), + custom: null, + }) + ) + ); + + it( + ...createBuilderSpec( + 'graphql', + AssociateRoleDraft.random(), + expect.objectContaining({ + key: expect.any(String), + name: expect.any(String), + buyerAssignable: expect.any(Boolean), + permissions: expect.any(Array), + custom: null, + }) + ) + ); +}); diff --git a/models/associate-role/src/associate-role-draft/builder.ts b/models/associate-role/src/associate-role-draft/builder.ts new file mode 100644 index 000000000..7eeef90d7 --- /dev/null +++ b/models/associate-role/src/associate-role-draft/builder.ts @@ -0,0 +1,13 @@ +import { Builder } from '@commercetools-test-data/core'; +import { + TAssociateRoleDraft, + TCreateAssociateRoleDraftBuilder, +} from '../types'; +import generator from './generator'; + +const AssociateRoleDraft: TCreateAssociateRoleDraftBuilder = () => + Builder({ + generator, + }); + +export default AssociateRoleDraft; diff --git a/models/associate-role/src/associate-role-draft/generator.ts b/models/associate-role/src/associate-role-draft/generator.ts new file mode 100644 index 000000000..d7e80451a --- /dev/null +++ b/models/associate-role/src/associate-role-draft/generator.ts @@ -0,0 +1,14 @@ +import { fake, Generator } from '@commercetools-test-data/core'; +import { TAssociateRoleDraft } from '../types'; + +const generator = Generator({ + fields: { + key: fake((f) => f.string.alphanumeric(10)), + name: fake((f) => f.string.alphanumeric(15)), + buyerAssignable: fake((f) => f.datatype.boolean()), + permissions: [], + custom: null, + }, +}); + +export default generator; diff --git a/models/associate-role/src/associate-role-draft/index.ts b/models/associate-role/src/associate-role-draft/index.ts new file mode 100644 index 000000000..96e2519e1 --- /dev/null +++ b/models/associate-role/src/associate-role-draft/index.ts @@ -0,0 +1,2 @@ +export { default as random } from './builder'; +export { default as presets } from './presets'; diff --git a/models/associate-role/src/associate-role-draft/presets/index.ts b/models/associate-role/src/associate-role-draft/presets/index.ts new file mode 100644 index 000000000..763e57fe0 --- /dev/null +++ b/models/associate-role/src/associate-role-draft/presets/index.ts @@ -0,0 +1,3 @@ +const presets = {}; + +export default presets; diff --git a/models/associate-role/src/builder.spec.ts b/models/associate-role/src/builder.spec.ts new file mode 100644 index 000000000..6fa4cc439 --- /dev/null +++ b/models/associate-role/src/builder.spec.ts @@ -0,0 +1,80 @@ +/* eslint-disable jest/no-disabled-tests */ +/* eslint-disable jest/valid-title */ +import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; +import type { TAssociateRole, TAssociateRoleGraphql } from './types'; +import * as AssociateRole from './index'; + +describe('builder', () => { + it( + ...createBuilderSpec( + 'default', + AssociateRole.random(), + expect.objectContaining({ + id: expect.any(String), + version: expect.any(Number), + createdAt: expect.any(String), + createdBy: expect.objectContaining({ + customer: expect.objectContaining({ typeId: 'customer' }), + }), + lastModifiedAt: expect.any(String), + lastModifiedBy: expect.objectContaining({ + customer: expect.objectContaining({ typeId: 'customer' }), + }), + key: expect.any(String), + name: expect.any(String), + buyerAssignable: expect.any(Boolean), + permissions: expect.any(Array), + custom: null, + }) + ) + ); + + it( + ...createBuilderSpec( + 'rest', + AssociateRole.random(), + expect.objectContaining({ + id: expect.any(String), + version: expect.any(Number), + createdAt: expect.any(String), + createdBy: expect.objectContaining({ + customer: expect.objectContaining({ typeId: 'customer' }), + }), + lastModifiedAt: expect.any(String), + lastModifiedBy: expect.objectContaining({ + customer: expect.objectContaining({ typeId: 'customer' }), + }), + key: expect.any(String), + name: expect.any(String), + buyerAssignable: expect.any(Boolean), + permissions: expect.any(Array), + custom: null, + }) + ) + ); + + it( + ...createBuilderSpec( + 'graphql', + AssociateRole.random(), + expect.objectContaining({ + __typename: 'AssociateRole', + id: expect.any(String), + version: expect.any(Number), + createdAt: expect.any(String), + createdBy: expect.objectContaining({ + customerRef: expect.objectContaining({ typeId: 'customer' }), + }), + lastModifiedAt: expect.any(String), + lastModifiedBy: expect.objectContaining({ + customerRef: expect.objectContaining({ typeId: 'customer' }), + }), + key: expect.any(String), + name: expect.any(String), + buyerAssignable: expect.any(Boolean), + permissions: expect.any(Array), + custom: null, + }) + ) + ); +}); diff --git a/models/associate-role/src/builder.ts b/models/associate-role/src/builder.ts new file mode 100644 index 000000000..1be850fe9 --- /dev/null +++ b/models/associate-role/src/builder.ts @@ -0,0 +1,12 @@ +import { Builder } from '@commercetools-test-data/core'; +import generator from './generator'; +import transformers from './transformers'; +import { TAssociateRole, TCreateAssociateRoleBuilder } from './types'; + +const Model: TCreateAssociateRoleBuilder = () => + Builder({ + generator, + transformers, + }); + +export default Model; diff --git a/models/associate-role/src/constants.ts b/models/associate-role/src/constants.ts new file mode 100644 index 000000000..9aaf030af --- /dev/null +++ b/models/associate-role/src/constants.ts @@ -0,0 +1,56 @@ +const BUSINESS_UNIT_PERMISSIONS = { + ADD_CHILD_UNITS: 'AddChildUnits', + UPDATE_ASSOCIATES: 'UpdateAssociates', + UPDATE_BUSINESS_UNIT_DETAILS: 'UpdateBusinessUnitDetails', + UPDATE_PARENT_UNIT: 'UpdateParentUnit', +}; + +const CART_PERMISSIONS = { + VIEW_MY_CARTS: 'ViewMyCarts', + CREATE_MY_CARTS: 'CreateMyCarts', + UPDATE_MY_CARTS: 'UpdateMyCarts', + DELETE_MY_CARTS: 'DeleteMyCarts', + VIEW_OTHERS_CARTS: 'ViewOthersCarts', + CREATE_OTHERS_CARTS: 'CreateOthersCarts', + UPDATE_OTHERS_CARTS: 'UpdateOthersCarts', + DELETE_OTHERS_CARTS: 'DeleteOthersCarts', +}; + +const ORDER_PERMISSIONS = { + CREATE_MY_ORDERS_FROM_MY_CARTS: 'CreateMyOrdersFromMyCarts', + CREATE_MY_ORDERS_FROM_MY_QUOTES: 'CreateMyOrdersFromMyQuotes', + UPDATE_MY_ORDERS: 'UpdateMyOrders', + VIEW_MY_ORDERS: 'ViewMyOrders', + CREATE_ORDERS_FROM_OTHERS_CARTS: 'CreateOrdersFromOthersCarts', + CREATE_ORDERS_FROM_OTHERS_QUOTES: 'CreateOrdersFromOthersQuotes', + VIEW_OTHERS_ORDERS: 'ViewOthersOrders', + UPDATE_OTHERS_ORDERS: 'UpdateOthersOrders', +}; + +const QUOTE_PERMISSIONS = { + VIEW_MY_QUOTES: 'ViewMyQuotes', + ACCEPT_MY_QUOTES: 'AcceptMyQuotes', + DECLINE_MY_QUOTES: 'DeclineMyQuotes', + RENEGOTIATE_MY_QUOTES: 'RenegotiateMyQuotes', + VIEW_OTHERS_QUOTES: 'ViewOthersQuotes', + ACCEPT_OTHERS_QUOTES: 'AcceptOthersQuotes', + DECLINE_OTHERS_QUOTES: 'DeclineOthersQuotes', + RENEGOTIATE_OTHERS_QUOTES: 'RenegotiateOthersQuotes', +}; + +const QUOTE_REQUEST_PERMISSIONS = { + CREATE_MY_QUOTE_REQUESTS_FROM_MY_CARTS: 'CreateMyQuoteRequestsFromMyCarts', + VIEW_MY_QUOTE_REQUESTS: 'ViewMyQuoteRequests', + UPDATE_MY_QUOTE_REQUESTS: 'UpdateMyQuoteRequests', + CREATE_QUOTE_REQUESTS_FROM_OTHERS_CARTS: 'CreateQuoteRequestsFromOthersCarts', + VIEW_OTHERS_QUOTE_REQUESTS: 'ViewOthersQuoteRequests', + UPDATE_OTHERS_QUOTE_REQUESTS: 'UpdateOthersQuoteRequests', +}; + +export { + BUSINESS_UNIT_PERMISSIONS, + CART_PERMISSIONS, + ORDER_PERMISSIONS, + QUOTE_PERMISSIONS, + QUOTE_REQUEST_PERMISSIONS, +}; diff --git a/models/associate-role/src/generator.ts b/models/associate-role/src/generator.ts new file mode 100644 index 000000000..9091c9a3e --- /dev/null +++ b/models/associate-role/src/generator.ts @@ -0,0 +1,24 @@ +import { ClientLogging } from '@commercetools-test-data/commons'; +import { fake, Generator, sequence } from '@commercetools-test-data/core'; +import { createRelatedDates } from '@commercetools-test-data/utils'; +import { TAssociateRole } from './types'; + +const [getOlderDate, getNewerDate] = createRelatedDates(); + +const generator = Generator({ + fields: { + id: fake((f) => f.string.uuid()), + version: sequence(), + key: fake((f) => f.string.alphanumeric(10)), + buyerAssignable: fake((f) => f.datatype.boolean()), + name: fake((f) => f.string.alphanumeric(15)), + permissions: [], + custom: null, + createdAt: fake(getOlderDate), + createdBy: fake(() => ClientLogging.random()), + lastModifiedAt: fake(getNewerDate), + lastModifiedBy: fake(() => ClientLogging.random()), + }, +}); + +export default generator; diff --git a/models/associate-role/src/index.ts b/models/associate-role/src/index.ts new file mode 100644 index 000000000..64748e497 --- /dev/null +++ b/models/associate-role/src/index.ts @@ -0,0 +1,7 @@ +export * as AssociateRoleDraft from './associate-role-draft'; +export * as AssociateRole from '.'; + +export { default as random } from './builder'; +export * as presets from './presets'; +export * as constants from './constants'; +export * from './types'; diff --git a/models/associate-role/src/presets/index.ts b/models/associate-role/src/presets/index.ts new file mode 100644 index 000000000..38228b845 --- /dev/null +++ b/models/associate-role/src/presets/index.ts @@ -0,0 +1,21 @@ +import { default as withAllBusinessUnitPermissions } from './with-all-business-unit-permissions'; +import { default as withAllCartPermissions } from './with-all-cart-permissions'; +import { default as withAllOrderPermissions } from './with-all-order-permissions'; +import { default as withAllQuotePermissions } from './with-all-quote-permissions'; +import { default as withAllQuoteRequestPermissions } from './with-all-quote-request-permissions'; +import { default as withMyCartPermissions } from './with-my-cart-permissions'; +import { default as withMyOrderPermissions } from './with-my-order-permissions'; +import { default as withMyQuotePermissions } from './with-my-quote-permissions'; +import { default as withMyQuoteRequestPermissions } from './with-my-quote-request-permissions'; + +export { + withAllBusinessUnitPermissions, + withAllCartPermissions, + withAllOrderPermissions, + withAllQuotePermissions, + withAllQuoteRequestPermissions, + withMyCartPermissions, + withMyOrderPermissions, + withMyQuotePermissions, + withMyQuoteRequestPermissions, +}; diff --git a/models/associate-role/src/presets/with-all-business-unit-permissions.ts b/models/associate-role/src/presets/with-all-business-unit-permissions.ts new file mode 100644 index 000000000..f93d73d53 --- /dev/null +++ b/models/associate-role/src/presets/with-all-business-unit-permissions.ts @@ -0,0 +1,12 @@ +import AssociateRole from '../builder'; +import { BUSINESS_UNIT_PERMISSIONS } from '../constants'; + +const withAllBusinessUnitPermissions = () => + AssociateRole().permissions([ + BUSINESS_UNIT_PERMISSIONS.ADD_CHILD_UNITS, + BUSINESS_UNIT_PERMISSIONS.UPDATE_ASSOCIATES, + BUSINESS_UNIT_PERMISSIONS.UPDATE_BUSINESS_UNIT_DETAILS, + BUSINESS_UNIT_PERMISSIONS.UPDATE_PARENT_UNIT, + ]); + +export default withAllBusinessUnitPermissions; diff --git a/models/associate-role/src/presets/with-all-cart-permissions.ts b/models/associate-role/src/presets/with-all-cart-permissions.ts new file mode 100644 index 000000000..e864d4a69 --- /dev/null +++ b/models/associate-role/src/presets/with-all-cart-permissions.ts @@ -0,0 +1,16 @@ +import AssociateRole from '../builder'; +import { CART_PERMISSIONS } from '../constants'; + +const withAllCartPermissions = () => + AssociateRole().permissions([ + CART_PERMISSIONS.CREATE_MY_CARTS, + CART_PERMISSIONS.CREATE_OTHERS_CARTS, + CART_PERMISSIONS.DELETE_MY_CARTS, + CART_PERMISSIONS.DELETE_OTHERS_CARTS, + CART_PERMISSIONS.UPDATE_MY_CARTS, + CART_PERMISSIONS.UPDATE_OTHERS_CARTS, + CART_PERMISSIONS.VIEW_MY_CARTS, + CART_PERMISSIONS.VIEW_OTHERS_CARTS, + ]); + +export default withAllCartPermissions; diff --git a/models/associate-role/src/presets/with-all-order-permissions.ts b/models/associate-role/src/presets/with-all-order-permissions.ts new file mode 100644 index 000000000..1c50e6c23 --- /dev/null +++ b/models/associate-role/src/presets/with-all-order-permissions.ts @@ -0,0 +1,16 @@ +import AssociateRole from '../builder'; +import { ORDER_PERMISSIONS } from '../constants'; + +const withAllOrderPermissions = () => + AssociateRole().permissions([ + ORDER_PERMISSIONS.CREATE_MY_ORDERS_FROM_MY_CARTS, + ORDER_PERMISSIONS.CREATE_ORDERS_FROM_OTHERS_CARTS, + ORDER_PERMISSIONS.CREATE_MY_ORDERS_FROM_MY_QUOTES, + ORDER_PERMISSIONS.CREATE_ORDERS_FROM_OTHERS_QUOTES, + ORDER_PERMISSIONS.UPDATE_MY_ORDERS, + ORDER_PERMISSIONS.UPDATE_OTHERS_ORDERS, + ORDER_PERMISSIONS.VIEW_MY_ORDERS, + ORDER_PERMISSIONS.VIEW_OTHERS_ORDERS, + ]); + +export default withAllOrderPermissions; diff --git a/models/associate-role/src/presets/with-all-quote-permissions.ts b/models/associate-role/src/presets/with-all-quote-permissions.ts new file mode 100644 index 000000000..973404592 --- /dev/null +++ b/models/associate-role/src/presets/with-all-quote-permissions.ts @@ -0,0 +1,16 @@ +import AssociateRole from '../builder'; +import { QUOTE_PERMISSIONS } from '../constants'; + +const withAllQuotePermissions = () => + AssociateRole().permissions([ + QUOTE_PERMISSIONS.VIEW_MY_QUOTES, + QUOTE_PERMISSIONS.VIEW_OTHERS_QUOTES, + QUOTE_PERMISSIONS.ACCEPT_MY_QUOTES, + QUOTE_PERMISSIONS.ACCEPT_OTHERS_QUOTES, + QUOTE_PERMISSIONS.DECLINE_MY_QUOTES, + QUOTE_PERMISSIONS.DECLINE_OTHERS_QUOTES, + QUOTE_PERMISSIONS.RENEGOTIATE_MY_QUOTES, + QUOTE_PERMISSIONS.RENEGOTIATE_OTHERS_QUOTES, + ]); + +export default withAllQuotePermissions; diff --git a/models/associate-role/src/presets/with-all-quote-request-permissions.ts b/models/associate-role/src/presets/with-all-quote-request-permissions.ts new file mode 100644 index 000000000..db422e1b6 --- /dev/null +++ b/models/associate-role/src/presets/with-all-quote-request-permissions.ts @@ -0,0 +1,14 @@ +import AssociateRole from '../builder'; +import { QUOTE_REQUEST_PERMISSIONS } from '../constants'; + +const withAllQuoteRequestPermissions = () => + AssociateRole().permissions([ + QUOTE_REQUEST_PERMISSIONS.CREATE_MY_QUOTE_REQUESTS_FROM_MY_CARTS, + QUOTE_REQUEST_PERMISSIONS.CREATE_QUOTE_REQUESTS_FROM_OTHERS_CARTS, + QUOTE_REQUEST_PERMISSIONS.UPDATE_MY_QUOTE_REQUESTS, + QUOTE_REQUEST_PERMISSIONS.UPDATE_OTHERS_QUOTE_REQUESTS, + QUOTE_REQUEST_PERMISSIONS.VIEW_MY_QUOTE_REQUESTS, + QUOTE_REQUEST_PERMISSIONS.VIEW_OTHERS_QUOTE_REQUESTS, + ]); + +export default withAllQuoteRequestPermissions; diff --git a/models/associate-role/src/presets/with-my-cart-permissions.ts b/models/associate-role/src/presets/with-my-cart-permissions.ts new file mode 100644 index 000000000..495fd40be --- /dev/null +++ b/models/associate-role/src/presets/with-my-cart-permissions.ts @@ -0,0 +1,12 @@ +import AssociateRole from '../builder'; +import { CART_PERMISSIONS } from '../constants'; + +const withMyCartPermissions = () => + AssociateRole().permissions([ + CART_PERMISSIONS.CREATE_MY_CARTS, + CART_PERMISSIONS.DELETE_MY_CARTS, + CART_PERMISSIONS.UPDATE_MY_CARTS, + CART_PERMISSIONS.VIEW_MY_CARTS, + ]); + +export default withMyCartPermissions; diff --git a/models/associate-role/src/presets/with-my-order-permissions.ts b/models/associate-role/src/presets/with-my-order-permissions.ts new file mode 100644 index 000000000..cf8f67599 --- /dev/null +++ b/models/associate-role/src/presets/with-my-order-permissions.ts @@ -0,0 +1,12 @@ +import AssociateRole from '../builder'; +import { ORDER_PERMISSIONS } from '../constants'; + +const withMyOrderPermissions = () => + AssociateRole().permissions([ + ORDER_PERMISSIONS.CREATE_MY_ORDERS_FROM_MY_CARTS, + ORDER_PERMISSIONS.CREATE_MY_ORDERS_FROM_MY_QUOTES, + ORDER_PERMISSIONS.UPDATE_MY_ORDERS, + ORDER_PERMISSIONS.VIEW_MY_ORDERS, + ]); + +export default withMyOrderPermissions; diff --git a/models/associate-role/src/presets/with-my-quote-permissions.ts b/models/associate-role/src/presets/with-my-quote-permissions.ts new file mode 100644 index 000000000..d5565ba69 --- /dev/null +++ b/models/associate-role/src/presets/with-my-quote-permissions.ts @@ -0,0 +1,12 @@ +import AssociateRole from '../builder'; +import { QUOTE_PERMISSIONS } from '../constants'; + +const withMyQuotePermissions = () => + AssociateRole().permissions([ + QUOTE_PERMISSIONS.VIEW_MY_QUOTES, + QUOTE_PERMISSIONS.ACCEPT_MY_QUOTES, + QUOTE_PERMISSIONS.DECLINE_MY_QUOTES, + QUOTE_PERMISSIONS.RENEGOTIATE_MY_QUOTES, + ]); + +export default withMyQuotePermissions; diff --git a/models/associate-role/src/presets/with-my-quote-request-permissions.ts b/models/associate-role/src/presets/with-my-quote-request-permissions.ts new file mode 100644 index 000000000..ca8f6accc --- /dev/null +++ b/models/associate-role/src/presets/with-my-quote-request-permissions.ts @@ -0,0 +1,11 @@ +import AssociateRole from '../builder'; +import { QUOTE_REQUEST_PERMISSIONS } from '../constants'; + +const withAllQuoteRequestPermissions = () => + AssociateRole().permissions([ + QUOTE_REQUEST_PERMISSIONS.CREATE_MY_QUOTE_REQUESTS_FROM_MY_CARTS, + QUOTE_REQUEST_PERMISSIONS.UPDATE_MY_QUOTE_REQUESTS, + QUOTE_REQUEST_PERMISSIONS.VIEW_MY_QUOTE_REQUESTS, + ]); + +export default withAllQuoteRequestPermissions; diff --git a/models/associate-role/src/transformers.ts b/models/associate-role/src/transformers.ts new file mode 100644 index 000000000..972f6a1e9 --- /dev/null +++ b/models/associate-role/src/transformers.ts @@ -0,0 +1,19 @@ +import { Transformer } from '@commercetools-test-data/core'; +import type { TAssociateRole, TAssociateRoleGraphql } from './types'; + +const transformers = { + default: Transformer('default', { + buildFields: ['createdBy', 'lastModifiedBy'], + }), + rest: Transformer('rest', { + buildFields: ['createdBy', 'lastModifiedBy'], + }), + graphql: Transformer('graphql', { + buildFields: ['createdBy', 'lastModifiedBy'], + addFields: () => ({ + __typename: 'AssociateRole', + }), + }), +}; + +export default transformers; diff --git a/models/associate-role/src/types.ts b/models/associate-role/src/types.ts new file mode 100644 index 000000000..79c440efc --- /dev/null +++ b/models/associate-role/src/types.ts @@ -0,0 +1,21 @@ +import type { + AssociateRole, + AssociateRoleDraft, +} from '@commercetools/platform-sdk'; +import type { TBuilder } from '@commercetools-test-data/core'; + +//AssociateRoleDraft +export type TAssociateRoleDraft = AssociateRoleDraft; +export type TAssociateRoleDraftBuilder = TBuilder; +export type TCreateAssociateRoleDraftBuilder = () => TAssociateRoleDraftBuilder; +export type TAssociateRoleDraftGraphql = TAssociateRoleDraft & { + __typename: 'AssociateRoleDraft'; +}; + +//AssociateRole +export type TAssociateRole = AssociateRole; +export type TAssociateRoleBuilder = TBuilder; +export type TCreateAssociateRoleBuilder = () => TAssociateRoleBuilder; +export type TAssociateRoleGraphql = TAssociateRole & { + __typename: 'AssociateRole'; +}; diff --git a/models/commons/src/key-reference/presets/associate-role-reference.spec.ts b/models/commons/src/key-reference/presets/associate-role-reference.spec.ts new file mode 100644 index 000000000..242acfb4a --- /dev/null +++ b/models/commons/src/key-reference/presets/associate-role-reference.spec.ts @@ -0,0 +1,10 @@ +import type { TKeyReference } from '../types'; +import associateRoleReference from './associate-role-reference'; + +it('should build an associateRole reference', () => { + const built = associateRoleReference().build(); + expect(built).toEqual({ + key: expect.any(String), + typeId: 'associate-role', + }); +}); diff --git a/models/commons/src/key-reference/presets/associate-role-reference.ts b/models/commons/src/key-reference/presets/associate-role-reference.ts new file mode 100644 index 000000000..577ed0148 --- /dev/null +++ b/models/commons/src/key-reference/presets/associate-role-reference.ts @@ -0,0 +1,7 @@ +import KeyReference from '../builder'; +import type { TKeyReferenceBuilder } from '../types'; + +const associateRole = (): TKeyReferenceBuilder => + KeyReference().typeId('associate-role'); + +export default associateRole; diff --git a/models/commons/src/key-reference/presets/index.ts b/models/commons/src/key-reference/presets/index.ts index abef07363..400f3afcf 100644 --- a/models/commons/src/key-reference/presets/index.ts +++ b/models/commons/src/key-reference/presets/index.ts @@ -1,3 +1,4 @@ +import associateRole from './associate-role-reference'; import businessUnit from './business-unit-reference'; import category from './category-reference'; import customerGroup from './customer-group-reference'; @@ -9,6 +10,7 @@ import taxCategory from './tax-category-reference'; import zone from './zone-reference'; const presets = { + associateRole, businessUnit, category, customer, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b98e746b7..648e7f7b2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true @@ -131,6 +131,30 @@ importers: graphql-types: {} + models/associate-role: + dependencies: + '@babel/runtime': + specifier: ^7.17.9 + version: 7.19.4 + '@babel/runtime-corejs3': + specifier: ^7.17.9 + version: 7.19.4 + '@commercetools-test-data/commons': + specifier: 6.4.2 + version: 6.4.2 + '@commercetools-test-data/core': + specifier: 6.4.2 + version: 6.4.2 + '@commercetools-test-data/utils': + specifier: 6.4.2 + version: 6.4.2 + '@commercetools/platform-sdk': + specifier: ^6.0.0 + version: 6.0.0 + '@faker-js/faker': + specifier: ^8.0.0 + version: 8.0.0 + models/business-unit: dependencies: '@babel/runtime': @@ -2617,7 +2641,7 @@ packages: /@changesets/apply-release-plan@6.1.4: resolution: {integrity: sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/config': 2.3.1 '@changesets/get-version-range-type': 0.3.2 '@changesets/git': 2.0.0 @@ -2635,7 +2659,7 @@ packages: /@changesets/assemble-release-plan@5.2.4: resolution: {integrity: sha512-xJkWX+1/CUaOUWTguXEbCDTyWJFECEhmdtbkjhn5GVBGxdP/JwaHBIU9sW3FR6gD07UwZ7ovpiPclQZs+j+mvg==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/errors': 0.1.4 '@changesets/get-dependents-graph': 1.3.6 '@changesets/types': 5.2.1 @@ -2738,7 +2762,7 @@ packages: /@changesets/get-release-plan@3.0.17: resolution: {integrity: sha512-6IwKTubNEgoOZwDontYc2x2cWXfr6IKxP3IhKeK+WjyD6y3M4Gl/jdQvBw+m/5zWILSOCAaGLu2ZF6Q+WiPniw==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/assemble-release-plan': 5.2.4 '@changesets/config': 2.3.1 '@changesets/pre': 1.0.14 @@ -2754,7 +2778,7 @@ packages: /@changesets/git@2.0.0: resolution: {integrity: sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/errors': 0.1.4 '@changesets/types': 5.2.1 '@manypkg/get-packages': 1.1.3 @@ -2779,7 +2803,7 @@ packages: /@changesets/pre@1.0.14: resolution: {integrity: sha512-dTsHmxQWEQekHYHbg+M1mDVYFvegDh9j/kySNuDKdylwfMEevTeDouR7IfHNyVodxZXu17sXoJuf2D0vi55FHQ==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/errors': 0.1.4 '@changesets/types': 5.2.1 '@manypkg/get-packages': 1.1.3 @@ -2789,7 +2813,7 @@ packages: /@changesets/read@0.5.9: resolution: {integrity: sha512-T8BJ6JS6j1gfO1HFq50kU3qawYxa4NTbI/ASNVVCBTsKquy2HYwM9r7ZnzkiMe8IEObAJtUVGSrePCOxAK2haQ==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/git': 2.0.0 '@changesets/logger': 0.0.5 '@changesets/parse': 0.3.16 @@ -2810,7 +2834,7 @@ packages: /@changesets/write@0.2.3: resolution: {integrity: sha512-Dbamr7AIMvslKnNYsLFafaVORx4H0pvCA2MHqgtNCySMe1blImEyAEOzDmcgKAkgz4+uwoLz7demIrX+JBr/Xw==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/types': 5.2.1 fs-extra: 7.0.1 human-id: 1.0.2 @@ -2823,7 +2847,7 @@ packages: dependencies: '@babel/core': 7.23.0 '@babel/register': 7.22.15(@babel/core@7.23.0) - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@babel/runtime-corejs3': 7.23.1 '@commercetools-frontend/babel-preset-mc-app': 22.10.0 '@commercetools-frontend/constants': 22.10.0 @@ -2863,7 +2887,7 @@ packages: '@babel/preset-env': 7.22.20(@babel/core@7.23.0) '@babel/preset-react': 7.22.15(@babel/core@7.23.0) '@babel/preset-typescript': 7.23.0(@babel/core@7.23.0) - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@babel/runtime-corejs3': 7.23.1 '@emotion/babel-plugin': 11.11.0 '@emotion/babel-preset-css-prop': 11.11.0(@babel/core@7.23.0) @@ -2913,7 +2937,7 @@ packages: /@commercetools-frontend/constants@22.10.0: resolution: {integrity: sha512-ty15pNpX+ThJAR+GnYHgDBHEDyc9GeXia72VBFR/gnu1XbH7JkPPBxMjU6csOUSHiC27o82N7xxtzUMtLeZaXQ==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@babel/runtime-corejs3': 7.23.1 dev: false @@ -2955,7 +2979,7 @@ packages: resolution: {integrity: sha512-uL5nP2+FJqUROv5gxdaYDp9xbuig45gxwEf3oBIOambnZjSO28dwh86mt5SeL5f29hhiN9ApswgjKIVjNbbgAw==} deprecated: Use the @commercetools-test-data/product-type package instead dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@babel/runtime-corejs3': 7.23.1 '@commercetools-test-data/attribute-type': 5.11.2 '@commercetools-test-data/commons': 5.11.2 @@ -2971,8 +2995,8 @@ packages: resolution: {integrity: sha512-JecOqJ3jdc/1+mnNcYKRzQBzNlJSwzuuxOKWKWyAZzXW2sH3z4K+rECaQY3Y+HMFqIMgVboa9ebd6YIgDlFFNA==} deprecated: Use the @commercetools-test-data/product-type package instead dependencies: - '@babel/runtime': 7.21.0 - '@babel/runtime-corejs3': 7.19.4 + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 '@commercetools-test-data/commons': 5.11.2 '@commercetools-test-data/core': 5.11.2 '@commercetools-test-data/utils': 5.11.2 @@ -2985,8 +3009,8 @@ packages: /@commercetools-test-data/commons@5.11.2: resolution: {integrity: sha512-AxcUby9NOEmil3kJKrNVa7Lz94UHOeW+nFgsmn5I3CLKrt/Q5VI0et+6Ls1UJh57buxbTQRK15O/Gd/hRMYwSA==} dependencies: - '@babel/runtime': 7.21.0 - '@babel/runtime-corejs3': 7.19.4 + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 '@commercetools-test-data/core': 5.11.2 '@commercetools-test-data/utils': 5.11.2 '@commercetools/platform-sdk': 4.11.0 @@ -2997,11 +3021,36 @@ packages: - encoding dev: false + /@commercetools-test-data/commons@6.4.2: + resolution: {integrity: sha512-j8YRChlU17Tjmt6dtk+4UuVQeAq/VMBu+HmvBHITjzRMvQcwm6q293KF575tkL6Y26qoxnbGKgDM2BDz+UruPA==} + dependencies: + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 + '@commercetools-test-data/core': 6.4.2 + '@commercetools-test-data/utils': 6.4.2 + '@commercetools/platform-sdk': 6.0.0 + '@faker-js/faker': 8.0.0 + '@types/lodash': 4.14.201 + lodash: 4.17.21 + transitivePeerDependencies: + - encoding + dev: false + /@commercetools-test-data/core@5.11.2: resolution: {integrity: sha512-iz++zEBengERwg3REm51RsEFmiUeNPQz1K9K2kZjH1sAkFxOf1ydmpM0Tt4Awmi/OHQ+G2tGKKdJewm8AQyHNg==} dependencies: - '@babel/runtime': 7.21.0 - '@babel/runtime-corejs3': 7.19.4 + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 + '@faker-js/faker': 8.0.0 + '@types/lodash': 4.14.201 + lodash: 4.17.21 + dev: false + + /@commercetools-test-data/core@6.4.2: + resolution: {integrity: sha512-cb0G9zQJGLaS16/3LiFigEHVIefsgADaZoc53zDbq/J+FHXy1CpCbh+qJS3z/WL22owT60hkuJPYb81A7+mRAA==} + dependencies: + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 '@faker-js/faker': 8.0.0 '@types/lodash': 4.14.201 lodash: 4.17.21 @@ -3010,7 +3059,7 @@ packages: /@commercetools-test-data/product-variant@5.11.2: resolution: {integrity: sha512-7VT0Iez2bi8fhpqJOzVx/WfmLV+mAXlc5SOxZoTeP1JyUyY07GiujI0ctKAh8Q3/0qzVyJ08RFV1BLtYxLWeKA==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@babel/runtime-corejs3': 7.23.1 '@commercetools-test-data/attribute-definition': 5.11.2 '@commercetools-test-data/commons': 5.11.2 @@ -3025,8 +3074,16 @@ packages: /@commercetools-test-data/utils@5.11.2: resolution: {integrity: sha512-7CU08wvYiQJ+tltvnEDunX/QtVgHimnMtNmwXBicL6/7OsiN/QHtW3pIuN8Sb/OQva6zUPLgOQe/6UbVHB+WpA==} dependencies: - '@babel/runtime': 7.21.0 - '@babel/runtime-corejs3': 7.19.4 + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 + '@faker-js/faker': 8.0.0 + dev: false + + /@commercetools-test-data/utils@6.4.2: + resolution: {integrity: sha512-3FrW30V5iS8IX5ZfGKEQT/kIeA6+DW/H2vTaiVGh/YdaZZ7sbitym4KVeiGQKQ8tbrNJK8WI5qZAF3YUHhUj+Q==} + dependencies: + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 '@faker-js/faker': 8.0.0 dev: false @@ -3275,7 +3332,7 @@ packages: resolution: {integrity: sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==} dependencies: '@babel/helper-module-imports': 7.22.15 - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@emotion/hash': 0.9.1 '@emotion/memoize': 0.8.1 '@emotion/serialize': 1.1.2 @@ -3294,7 +3351,7 @@ packages: dependencies: '@babel/core': 7.23.0 '@babel/plugin-transform-react-jsx': 7.22.15(@babel/core@7.23.0) - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@emotion/babel-plugin': 11.11.0 '@emotion/babel-plugin-jsx-pragmatic': 0.2.1(@babel/core@7.23.0) dev: false @@ -4342,7 +4399,7 @@ packages: /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@types/node': 12.20.55 find-up: 4.1.0 fs-extra: 8.1.0 @@ -4360,7 +4417,7 @@ packages: /@manypkg/get-packages@1.1.3: resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 @@ -4613,7 +4670,7 @@ packages: engines: {node: '>=12'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@types/aria-query': 4.2.2 aria-query: 5.1.3 chalk: 4.1.2 @@ -5438,7 +5495,7 @@ packages: resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==} engines: {node: '>=10', npm: '>=6'} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 cosmiconfig: 7.1.0 resolve: 1.22.1 dev: false @@ -5483,7 +5540,7 @@ packages: resolution: {integrity: sha512-G5R+xmo5LS41A4UyZjOjV0mp9AvkuCyUOAJ6TOv/jTZS+VKh7L7HUDRcCSOb0YCM/u0fFarh7Diz0wjY8rFNFg==} engines: {node: '>=10', npm: '>=6'} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@types/babel__core': 7.1.19 babel-plugin-macros: 3.1.0 require-from-string: 2.0.2 @@ -6163,7 +6220,7 @@ packages: /cross-fetch@3.1.8: resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==} dependencies: - node-fetch: 2.6.12 + node-fetch: 2.7.0 transitivePeerDependencies: - encoding dev: false @@ -6801,7 +6858,7 @@ packages: peerDependencies: eslint: ^6.8.0 || ^7.0.0 || ^8.0.0 dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 '@testing-library/dom': 8.19.0 eslint: 8.52.0 requireindex: 1.2.0 @@ -6835,7 +6892,7 @@ packages: peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 aria-query: 5.1.3 array-includes: 3.1.6 array.prototype.flatmap: 1.3.1 @@ -9729,8 +9786,8 @@ packages: /omit-empty-es@1.1.3: resolution: {integrity: sha512-rqEprmXZ0CaOcY7vtCdRLm7QPrmyst30GN4WWsUwcbvosHF55cszEZ6Gg9SNnVIiXC91luURcSp+xChg2ymjkA==} dependencies: - '@babel/runtime': 7.21.0 - '@babel/runtime-corejs3': 7.21.0 + '@babel/runtime': 7.23.4 + '@babel/runtime-corejs3': 7.23.1 dev: false /once@1.4.0: @@ -10284,7 +10341,7 @@ packages: /regenerator-transform@0.15.2: resolution: {integrity: sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg==} dependencies: - '@babel/runtime': 7.23.1 + '@babel/runtime': 7.23.4 dev: false /regexp.prototype.flags@1.5.1: