diff --git a/.changeset/blue-mangos-speak.md b/.changeset/blue-mangos-speak.md new file mode 100644 index 000000000..30dfdbcf9 --- /dev/null +++ b/.changeset/blue-mangos-speak.md @@ -0,0 +1,20 @@ +--- +'@commercetools-test-data/custom-view': minor +--- + +Allow to generate test data for Custom Views Installations. + +```ts +import { + CustomViewInstallation, + RestrictedCustomViewInstallationForOrganization, + type TCustomViewInstallationGraphql, + type TRestrictedCustomViewInstallationForOrganizationGraphql, +} from '@commercetools-test-data/custom-view'; + +const customViewInstallation = + CustomViewInstallation.random().buildGraphql(); + +const restrictedCustomViewInstallationForOrganization = + RestrictedCustomViewInstallationForOrganization.random().buildGraphql(); +``` diff --git a/models/custom-view/src/custom-view-installation-permission/builder.spec.ts b/models/custom-view/src/custom-view-installation-permission/builder.spec.ts new file mode 100644 index 000000000..0a9d7dbce --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/builder.spec.ts @@ -0,0 +1,56 @@ +/* eslint-disable jest/no-disabled-tests */ +/* eslint-disable jest/valid-title */ +import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; +import type { + TCustomViewInstallationPermission, + TCustomViewInstallationPermissionGraphql, +} from './types'; +import * as CustomViewInstallationPermissionModel from './index'; + +describe('CustomViewInstallationPermission model builder', () => { + it( + ...createBuilderSpec< + TCustomViewInstallationPermission, + TCustomViewInstallationPermission + >( + 'default', + CustomViewInstallationPermissionModel.random(), + expect.objectContaining({ + name: 'view', + oAuthScopes: expect.arrayContaining([expect.stringMatching(/^view_/)]), + }) + ) + ); + + it( + ...createBuilderSpec< + TCustomViewInstallationPermission, + TCustomViewInstallationPermissionGraphql + >( + 'graphql', + CustomViewInstallationPermissionModel.presets.ViewOnlyPermissions(), + expect.objectContaining({ + __typename: 'CustomViewInstallationPermission', + name: 'view', + oAuthScopes: expect.arrayContaining([expect.stringMatching(/^view_/)]), + }) + ) + ); + + it( + ...createBuilderSpec< + TCustomViewInstallationPermission, + TCustomViewInstallationPermissionGraphql + >( + 'graphql', + CustomViewInstallationPermissionModel.presets.ManageOnlyPermissions(), + expect.objectContaining({ + __typename: 'CustomViewInstallationPermission', + name: 'manage', + oAuthScopes: expect.arrayContaining([ + expect.stringMatching(/^manage_/), + ]), + }) + ) + ); +}); diff --git a/models/custom-view/src/custom-view-installation-permission/builder.ts b/models/custom-view/src/custom-view-installation-permission/builder.ts new file mode 100644 index 000000000..cbdfb6507 --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/builder.ts @@ -0,0 +1,15 @@ +import { Builder } from '@commercetools-test-data/core'; +import generator from './generator'; +import transformers from './transformers'; +import type { + TCustomViewInstallationPermission, + TCreateCustomViewInstallationPermissionBuilder, +} from './types'; + +const Model: TCreateCustomViewInstallationPermissionBuilder = () => + Builder({ + generator, + transformers, + }); + +export default Model; diff --git a/models/custom-view/src/custom-view-installation-permission/generator.ts b/models/custom-view/src/custom-view-installation-permission/generator.ts new file mode 100644 index 000000000..a7d18e5cd --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/generator.ts @@ -0,0 +1,19 @@ +import { Generator, fake } from '@commercetools-test-data/core'; +import { createRelatedDates } from '@commercetools-test-data/utils'; +import sampleSize from 'lodash/sampleSize'; +import { supportedViewOAuthScopes } from '../custom-view-permission/constants'; +import type { TCustomViewInstallationPermission } from './types'; + +const [getOlderDate, getNewerDate] = createRelatedDates(); + +const generator = Generator({ + fields: { + id: fake((f) => f.string.uuid()), + createdAt: fake(getOlderDate), + updatedAt: fake(getNewerDate), + name: 'view', + oAuthScopes: sampleSize(supportedViewOAuthScopes, 2), + }, +}); + +export default generator; diff --git a/models/custom-view/src/custom-view-installation-permission/index.ts b/models/custom-view/src/custom-view-installation-permission/index.ts new file mode 100644 index 000000000..153b04270 --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/index.ts @@ -0,0 +1,3 @@ +export { default as random } from './builder'; +export * as presets from './presets'; +export * from './types'; diff --git a/models/custom-view/src/custom-view-installation-permission/presets/index.ts b/models/custom-view/src/custom-view-installation-permission/presets/index.ts new file mode 100644 index 000000000..55569c31c --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/presets/index.ts @@ -0,0 +1,4 @@ +import ManageOnlyPermissions from './manage-only-permissions'; +import ViewOnlyPermissions from './view-only-permissions'; + +export { ViewOnlyPermissions, ManageOnlyPermissions }; diff --git a/models/custom-view/src/custom-view-installation-permission/presets/manage-only-permissions.ts b/models/custom-view/src/custom-view-installation-permission/presets/manage-only-permissions.ts new file mode 100644 index 000000000..f05dee6e4 --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/presets/manage-only-permissions.ts @@ -0,0 +1,26 @@ +import { entryPointUriPathToResourceAccesses } from '@commercetools-frontend/application-config/ssr'; +import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants'; +import camelCase from 'lodash/camelCase'; +import sampleSize from 'lodash/sampleSize'; +import upperFirst from 'lodash/upperFirst'; +import { supportedManageOAuthScopes } from '../../custom-view-permission/constants'; +import CustomViewInstallationPermission from '../builder'; + +const preset = (additionalPermission = '') => { + const resourceAccesses = entryPointUriPathToResourceAccesses( + CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, + [additionalPermission] + ); + return CustomViewInstallationPermission() + .name( + !additionalPermission + ? resourceAccesses.manage + : // @ts-ignore + resourceAccesses[ + `manage${upperFirst(camelCase(additionalPermission))}` + ] + ) + .oAuthScopes(sampleSize(supportedManageOAuthScopes, 1)); +}; + +export default preset; diff --git a/models/custom-view/src/custom-view-installation-permission/presets/presets.spec.ts b/models/custom-view/src/custom-view-installation-permission/presets/presets.spec.ts new file mode 100644 index 000000000..7ce659952 --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/presets/presets.spec.ts @@ -0,0 +1,26 @@ +import { ViewOnlyPermissions, ManageOnlyPermissions } from '.'; + +describe('view only permissions', () => { + it('should build important properties', () => { + const built = ViewOnlyPermissions().buildGraphql(); + + expect(built).toEqual( + expect.objectContaining({ + name: 'view', + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }) + ); + }); +}); +describe('with manage only permissions', () => { + it('should build important properties', () => { + const built = ManageOnlyPermissions().buildGraphql(); + + expect(built).toEqual( + expect.objectContaining({ + name: 'manage', + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }) + ); + }); +}); diff --git a/models/custom-view/src/custom-view-installation-permission/presets/view-only-permissions.ts b/models/custom-view/src/custom-view-installation-permission/presets/view-only-permissions.ts new file mode 100644 index 000000000..3badf3d13 --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/presets/view-only-permissions.ts @@ -0,0 +1,24 @@ +import { entryPointUriPathToResourceAccesses } from '@commercetools-frontend/application-config/ssr'; +import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants'; +import camelCase from 'lodash/camelCase'; +import sampleSize from 'lodash/sampleSize'; +import upperFirst from 'lodash/upperFirst'; +import { supportedViewOAuthScopes } from '../../custom-view-permission/constants'; +import CustomViewInstallationPermission from '../builder'; + +const preset = (additionalPermission = '') => { + const resourceAccesses = entryPointUriPathToResourceAccesses( + CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, + [additionalPermission] + ); + return CustomViewInstallationPermission() + .name( + !additionalPermission + ? resourceAccesses.view + : // @ts-ignore + resourceAccesses[`view${upperFirst(camelCase(additionalPermission))}`] + ) + .oAuthScopes(sampleSize(supportedViewOAuthScopes, 1)); +}; + +export default preset; diff --git a/models/custom-view/src/custom-view-installation-permission/transformers.ts b/models/custom-view/src/custom-view-installation-permission/transformers.ts new file mode 100644 index 000000000..2dff50c0e --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/transformers.ts @@ -0,0 +1,22 @@ +import { Transformer } from '@commercetools-test-data/core'; +import type { + TCustomViewInstallationPermission, + TCustomViewInstallationPermissionGraphql, +} from './types'; + +const transformers = { + default: Transformer< + TCustomViewInstallationPermission, + TCustomViewInstallationPermission + >('default', {}), + graphql: Transformer< + TCustomViewInstallationPermission, + TCustomViewInstallationPermissionGraphql + >('graphql', { + addFields: () => ({ + __typename: 'CustomViewInstallationPermission', + }), + }), +}; + +export default transformers; diff --git a/models/custom-view/src/custom-view-installation-permission/types.ts b/models/custom-view/src/custom-view-installation-permission/types.ts new file mode 100644 index 000000000..617f82058 --- /dev/null +++ b/models/custom-view/src/custom-view-installation-permission/types.ts @@ -0,0 +1,15 @@ +import type { TBuilder } from '@commercetools-test-data/core'; +import type { TMcSettingsCustomViewInstallationPermission } from '@commercetools-test-data/graphql-types'; + +export type TCustomViewInstallationPermissionGraphql = + TMcSettingsCustomViewInstallationPermission; + +export type TCustomViewInstallationPermission = Omit< + TCustomViewInstallationPermissionGraphql, + '__typename' +>; + +export type TCustomViewInstallationPermissionBuilder = + TBuilder; +export type TCreateCustomViewInstallationPermissionBuilder = + () => TCustomViewInstallationPermissionBuilder; diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/builder.spec.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/builder.spec.ts new file mode 100644 index 000000000..9a306b5fa --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/builder.spec.ts @@ -0,0 +1,57 @@ +/* eslint-disable jest/no-disabled-tests */ +/* eslint-disable jest/valid-title */ +import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; +import type { + TCustomViewInstallation, + TCustomViewInstallationGraphql, +} from './types'; +import * as CustomViewInstallationModel from './index'; + +describe('builder', () => { + it( + ...createBuilderSpec( + 'default', + CustomViewInstallationModel.random(), + expect.objectContaining({ + id: expect.any(String), + createdAt: expect.any(String), + updatedAt: expect.any(String), + acceptedPermissions: expect.arrayContaining([ + expect.objectContaining({ + name: expect.stringMatching(/^(view|manage)$/), + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }), + ]), + installInAllProjects: expect.any(Boolean), + projects: expect.any(Array), + ownerId: expect.any(String), + owner: expect.any(Object), + }) + ) + ); + it( + ...createBuilderSpec< + TCustomViewInstallation, + TCustomViewInstallationGraphql + >( + 'graphql', + CustomViewInstallationModel.random(), + expect.objectContaining({ + __typename: 'CustomViewInstallation', + id: expect.any(String), + createdAt: expect.any(String), + updatedAt: expect.any(String), + acceptedPermissions: expect.arrayContaining([ + expect.objectContaining({ + name: expect.stringMatching(/^(view|manage)$/), + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }), + ]), + installInAllProjects: expect.any(Boolean), + projects: expect.any(Array), + ownerId: expect.any(String), + owner: expect.any(Object), + }) + ) + ); +}); diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/builder.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/builder.ts new file mode 100644 index 000000000..903afaab4 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/builder.ts @@ -0,0 +1,15 @@ +import { Builder } from '@commercetools-test-data/core'; +import generator from './generator'; +import transformers from './transformers'; +import type { + TCustomViewInstallation, + TCreateCustomViewInstallationBuilder, +} from './types'; + +const Model: TCreateCustomViewInstallationBuilder = () => + Builder({ + generator, + transformers, + }); + +export default Model; diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/generator.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/generator.ts new file mode 100644 index 000000000..8fba71278 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/generator.ts @@ -0,0 +1,24 @@ +import { fake, Generator } from '@commercetools-test-data/core'; +import { createRelatedDates } from '@commercetools-test-data/utils'; +import * as CustomViewInstallationPermission from '../../custom-view-installation-permission'; +import type { TCustomViewInstallation } from './types'; + +const [getOlderDate, getNewerDate] = createRelatedDates(); + +const generator = Generator({ + fields: { + id: fake((f) => f.string.uuid()), + createdAt: fake(getOlderDate), + updatedAt: fake(getNewerDate), + acceptedPermissions: fake(() => [ + CustomViewInstallationPermission.presets.ViewOnlyPermissions(), + CustomViewInstallationPermission.presets.ManageOnlyPermissions(), + ]), + projects: fake(() => []), + installInAllProjects: fake((f) => f.datatype.boolean()), + owner: fake(() => ({})), + ownerId: fake((f) => f.string.uuid()), + }, +}); + +export default generator; diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/index.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/index.ts new file mode 100644 index 000000000..153b04270 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/index.ts @@ -0,0 +1,3 @@ +export { default as random } from './builder'; +export * as presets from './presets'; +export * from './types'; diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/presets/index.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/presets/index.ts new file mode 100644 index 000000000..763e57fe0 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/presets/index.ts @@ -0,0 +1,3 @@ +const presets = {}; + +export default presets; diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/transformers.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/transformers.ts new file mode 100644 index 000000000..e2ebd4c36 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/transformers.ts @@ -0,0 +1,25 @@ +import { Transformer } from '@commercetools-test-data/core'; +import type { + TCustomViewInstallation, + TCustomViewInstallationGraphql, +} from './types'; + +const transformers = { + default: Transformer( + 'default', + { + buildFields: ['acceptedPermissions', 'projects'], + } + ), + graphql: Transformer( + 'graphql', + { + buildFields: ['acceptedPermissions', 'projects'], + addFields: () => ({ + __typename: 'CustomViewInstallation', + }), + } + ), +}; + +export default transformers; diff --git a/models/custom-view/src/custom-view-installation/custom-view-installation/types.ts b/models/custom-view/src/custom-view-installation/custom-view-installation/types.ts new file mode 100644 index 000000000..641ff1cb3 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/custom-view-installation/types.ts @@ -0,0 +1,13 @@ +import type { TBuilder } from '@commercetools-test-data/core'; +import type { TMcSettingsCustomViewInstallation } from '@commercetools-test-data/graphql-types'; + +export type TCustomViewInstallationGraphql = TMcSettingsCustomViewInstallation; + +export type TCustomViewInstallation = Omit< + TCustomViewInstallationGraphql, + '__typename' +>; + +export type TCustomViewInstallationBuilder = TBuilder; +export type TCreateCustomViewInstallationBuilder = + () => TCustomViewInstallationBuilder; diff --git a/models/custom-view/src/custom-view-installation/index.ts b/models/custom-view/src/custom-view-installation/index.ts new file mode 100644 index 000000000..42d3b3863 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/index.ts @@ -0,0 +1,3 @@ +// Export models +export * as CustomViewInstallation from './custom-view-installation'; +export * as RestrictedCustomViewInstallationForOrganization from './restricted-custom-view-installation-for-organization'; diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/builder.spec.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/builder.spec.ts new file mode 100644 index 000000000..4bf519eb2 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/builder.spec.ts @@ -0,0 +1,109 @@ +/* eslint-disable jest/no-disabled-tests */ +/* eslint-disable jest/valid-title */ +import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; +import type { + TRestrictedCustomViewInstallationForOrganization, + TRestrictedCustomViewInstallationForOrganizationGraphql, +} from './types'; +import * as RestrictedCustomViewInstallationForOrganizationModel from './index'; + +describe('builder', () => { + it( + ...createBuilderSpec< + TRestrictedCustomViewInstallationForOrganization, + TRestrictedCustomViewInstallationForOrganization + >( + 'default', + RestrictedCustomViewInstallationForOrganizationModel.random(), + expect.objectContaining({ + id: expect.any(String), + createdAt: expect.any(String), + updatedAt: expect.any(String), + acceptedPermissions: expect.arrayContaining([ + expect.objectContaining({ + name: expect.stringMatching(/^(view|manage)$/), + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }), + ]), + customView: expect.objectContaining({ + id: expect.any(String), + createdAt: expect.any(String), + updatedAt: expect.any(String), + defaultLabel: expect.any(String), + labelAllLocales: expect.arrayContaining([ + expect.objectContaining({ + locale: expect.stringMatching(/^(de|en|es)$/), + value: expect.any(String), + }), + ]), + locators: expect.arrayContaining([expect.any(String)]), + ownerId: expect.any(String), + permissions: expect.arrayContaining([ + expect.objectContaining({ + name: expect.stringMatching(/^(view|manage)$/), + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }), + ]), + status: expect.stringMatching(/^(DRAFT|PRIVATE_USAGE)$/), + type: 'CustomPanel', + typeSettings: expect.objectContaining({ + size: expect.stringMatching(/^(SMALL|LARGE)$/), + }), + url: expect.any(String), + }), + installInAllProjects: expect.any(Boolean), + projects: expect.any(Array), + }) + ) + ); + it( + ...createBuilderSpec< + TRestrictedCustomViewInstallationForOrganization, + TRestrictedCustomViewInstallationForOrganizationGraphql + >( + 'graphql', + RestrictedCustomViewInstallationForOrganizationModel.random(), + expect.objectContaining({ + __typename: 'RestrictedCustomViewInstallationForOrganization', + id: expect.any(String), + createdAt: expect.any(String), + updatedAt: expect.any(String), + acceptedPermissions: expect.arrayContaining([ + expect.objectContaining({ + name: expect.stringMatching(/^(view|manage)$/), + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }), + ]), + customView: expect.objectContaining({ + __typename: 'CustomView', + id: expect.any(String), + createdAt: expect.any(String), + updatedAt: expect.any(String), + defaultLabel: expect.any(String), + labelAllLocales: expect.arrayContaining([ + expect.objectContaining({ + locale: expect.stringMatching(/^(de|en|es)$/), + value: expect.any(String), + }), + ]), + locators: expect.arrayContaining([expect.any(String)]), + ownerId: expect.any(String), + permissions: expect.arrayContaining([ + expect.objectContaining({ + name: expect.stringMatching(/^(view|manage)$/), + oAuthScopes: expect.arrayContaining([expect.any(String)]), + }), + ]), + status: expect.stringMatching(/^(DRAFT|PRIVATE_USAGE)$/), + type: 'CustomPanel', + typeSettings: expect.objectContaining({ + size: expect.stringMatching(/^(SMALL|LARGE)$/), + }), + url: expect.any(String), + }), + installInAllProjects: expect.any(Boolean), + projects: expect.any(Array), + }) + ) + ); +}); diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/builder.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/builder.ts new file mode 100644 index 000000000..2c86d4483 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/builder.ts @@ -0,0 +1,16 @@ +import { Builder } from '@commercetools-test-data/core'; +import generator from './generator'; +import transformers from './transformers'; +import type { + TRestrictedCustomViewInstallationForOrganization, + TCreateRestrictedCustomViewInstallationForOrganizationBuilder, +} from './types'; + +const Model: TCreateRestrictedCustomViewInstallationForOrganizationBuilder = + () => + Builder({ + generator, + transformers, + }); + +export default Model; diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/generator.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/generator.ts new file mode 100644 index 000000000..8645292c1 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/generator.ts @@ -0,0 +1,24 @@ +import { fake, Generator } from '@commercetools-test-data/core'; +import { createRelatedDates } from '@commercetools-test-data/utils'; +import * as CustomView from '../../custom-view'; +import * as CustomViewInstallationPermission from '../../custom-view-installation-permission'; +import type { TRestrictedCustomViewInstallationForOrganization } from './types'; + +const [getOlderDate, getNewerDate] = createRelatedDates(); + +const generator = Generator({ + fields: { + id: fake((f) => f.string.uuid()), + createdAt: fake(getOlderDate), + updatedAt: fake(getNewerDate), + customView: fake(() => CustomView.random()), + acceptedPermissions: fake(() => [ + CustomViewInstallationPermission.presets.ViewOnlyPermissions(), + CustomViewInstallationPermission.presets.ManageOnlyPermissions(), + ]), + projects: fake(() => []), + installInAllProjects: fake((f) => f.datatype.boolean()), + }, +}); + +export default generator; diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/index.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/index.ts new file mode 100644 index 000000000..153b04270 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/index.ts @@ -0,0 +1,3 @@ +export { default as random } from './builder'; +export * as presets from './presets'; +export * from './types'; diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/presets/index.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/presets/index.ts new file mode 100644 index 000000000..763e57fe0 --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/presets/index.ts @@ -0,0 +1,3 @@ +const presets = {}; + +export default presets; diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/transformers.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/transformers.ts new file mode 100644 index 000000000..2da40622e --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/transformers.ts @@ -0,0 +1,25 @@ +import { Transformer } from '@commercetools-test-data/core'; +import type { + TRestrictedCustomViewInstallationForOrganization, + TRestrictedCustomViewInstallationForOrganizationGraphql, +} from './types'; + +const transformers = { + default: Transformer< + TRestrictedCustomViewInstallationForOrganization, + TRestrictedCustomViewInstallationForOrganization + >('default', { + buildFields: ['customView', 'acceptedPermissions', 'projects'], + }), + graphql: Transformer< + TRestrictedCustomViewInstallationForOrganization, + TRestrictedCustomViewInstallationForOrganizationGraphql + >('graphql', { + buildFields: ['customView', 'acceptedPermissions', 'projects'], + addFields: () => ({ + __typename: 'RestrictedCustomViewInstallationForOrganization', + }), + }), +}; + +export default transformers; diff --git a/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/types.ts b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/types.ts new file mode 100644 index 000000000..f4a593b1b --- /dev/null +++ b/models/custom-view/src/custom-view-installation/restricted-custom-view-installation-for-organization/types.ts @@ -0,0 +1,15 @@ +import type { TBuilder } from '@commercetools-test-data/core'; +import type { TMcSettingsRestrictedCustomViewInstallationForOrganization } from '@commercetools-test-data/graphql-types'; + +export type TRestrictedCustomViewInstallationForOrganizationGraphql = + TMcSettingsRestrictedCustomViewInstallationForOrganization; + +export type TRestrictedCustomViewInstallationForOrganization = Omit< + TMcSettingsRestrictedCustomViewInstallationForOrganization, + '__typename' +>; + +export type TRestrictedCustomViewInstallationForOrganizationBuilder = + TBuilder; +export type TCreateRestrictedCustomViewInstallationForOrganizationBuilder = + () => TRestrictedCustomViewInstallationForOrganizationBuilder; diff --git a/models/custom-view/src/custom-view-installation/types.ts b/models/custom-view/src/custom-view-installation/types.ts new file mode 100644 index 000000000..0ad0feb2e --- /dev/null +++ b/models/custom-view/src/custom-view-installation/types.ts @@ -0,0 +1,3 @@ +// Export types +export * from './custom-view-installation/types'; +export * from './restricted-custom-view-installation-for-organization/types'; diff --git a/models/custom-view/src/custom-view/types.ts b/models/custom-view/src/custom-view/types.ts index 26af9d266..985aa8618 100644 --- a/models/custom-view/src/custom-view/types.ts +++ b/models/custom-view/src/custom-view/types.ts @@ -23,25 +23,6 @@ type CustomViewPermission = { oAuthScopes: string[]; }; -export type CustomViewInstallationPermission = { - createdAt: string; - id: string; - name: string; - oAuthScopes: string[]; - updatedAt: string; -}; - -export type CustomViewInstallation = { - acceptedPermissions: CustomViewInstallationPermission[]; - createdAt: string; - id: string; - installInAllProjects: boolean; - // owner: OrganizationExtension; - ownerId: string; - // projects: ProjectExtension[]; - updatedAt: string; -}; - export type TCustomView = { id: string; // owner: OrganizationExtension; diff --git a/models/custom-view/src/index.ts b/models/custom-view/src/index.ts index f447e92b7..68415577a 100644 --- a/models/custom-view/src/index.ts +++ b/models/custom-view/src/index.ts @@ -2,6 +2,12 @@ export * from './custom-view/types'; export * from './custom-view-permission/types'; export * from './custom-view-type-settings-for-custom-panel/types'; +export * from './custom-view-installation/types'; +export * from './custom-view-installation-permission/types'; + +// Export constants +export * from './custom-view/constants'; +export * from './custom-view-permission/constants'; // Export models export * as CustomView from './custom-view'; @@ -11,3 +17,8 @@ export * as CustomViewPermission from './custom-view-permission'; export * as CustomViewPermissionDraft from './custom-view-permission-draft'; export * as CustomViewTypeSettingsForCustomPanel from './custom-view-type-settings-for-custom-panel'; +export { + RestrictedCustomViewInstallationForOrganization, + CustomViewInstallation, +} from './custom-view-installation'; +export * as CustomViewInstallationPermission from './custom-view-installation-permission';