Ver código fonte

refactor(core): Rework ConfigurableOperation args implementation

Relates to #135
Michael Bromley 6 anos atrás
pai
commit
adbd616325
32 arquivos alterados com 218 adições e 274 exclusões
  1. 2 20
      packages/common/src/generated-shop-types.ts
  2. 2 20
      packages/common/src/generated-types.ts
  3. 19 1
      packages/common/src/shared-types.ts
  4. 4 4
      packages/core/e2e/__snapshots__/collection.e2e-spec.ts.snap
  5. 8 8
      packages/core/e2e/__snapshots__/promotion.e2e-spec.ts.snap
  6. 14 15
      packages/core/e2e/collection.e2e-spec.ts
  7. 4 5
      packages/core/e2e/default-search-plugin.e2e-spec.ts
  8. 2 20
      packages/core/e2e/graphql/generated-e2e-admin-types.ts
  9. 2 20
      packages/core/e2e/graphql/generated-e2e-shop-types.ts
  10. 10 8
      packages/core/e2e/promotion.e2e-spec.ts
  11. 2 3
      packages/core/e2e/shop-catalog.e2e-spec.ts
  12. 3 8
      packages/core/src/api/common/id-codec.service.ts
  13. 2 22
      packages/core/src/api/schema/common/common-types.graphql
  14. 22 18
      packages/core/src/common/configurable-operation.ts
  15. 5 2
      packages/core/src/config/collection/collection-filter.ts
  16. 10 7
      packages/core/src/config/collection/default-collection-filters.ts
  17. 2 4
      packages/core/src/config/payment-method/example-payment-method-config.ts
  18. 3 2
      packages/core/src/config/payment-method/payment-method-handler.ts
  19. 18 5
      packages/core/src/config/promotion/default-promotion-actions.ts
  20. 17 10
      packages/core/src/config/promotion/default-promotion-conditions.ts
  21. 3 6
      packages/core/src/config/promotion/promotion-action.ts
  22. 6 10
      packages/core/src/config/promotion/promotion-condition.ts
  23. 2 4
      packages/core/src/config/shipping-method/default-shipping-calculator.ts
  24. 1 3
      packages/core/src/config/shipping-method/default-shipping-eligibility-checker.ts
  25. 9 9
      packages/core/src/config/shipping-method/shipping-calculator.ts
  26. 3 6
      packages/core/src/config/shipping-method/shipping-eligibility-checker.ts
  27. 10 7
      packages/core/src/data-import/providers/populator/populator.ts
  28. 8 9
      packages/core/src/service/helpers/order-calculator/order-calculator.spec.ts
  29. 18 6
      packages/core/src/service/services/collection.service.ts
  30. 7 12
      packages/core/src/service/services/payment-method.service.ts
  31. 0 0
      schema-admin.json
  32. 0 0
      schema-shop.json

+ 2 - 20
packages/common/src/generated-shop-types.ts

@@ -215,34 +215,16 @@ export type CollectionTranslation = {
 export type ConfigArg = {
     __typename?: 'ConfigArg';
     name: Scalars['String'];
-    type: ConfigArgType;
+    type: Scalars['String'];
     value?: Maybe<Scalars['String']>;
 };
 
 export type ConfigArgInput = {
     name: Scalars['String'];
-    type: ConfigArgType;
+    type: Scalars['String'];
     value?: Maybe<Scalars['String']>;
 };
 
-/** Certain entities allow arbitrary configuration arguments to be specified which can then
- * be set in the admin-ui and used in the business logic of the app. These are the valid
- * data types of such arguments. The data type influences:
- *
- * 1. How the argument form field is rendered in the admin-ui
- * 2. The JavaScript type into which the value is coerced before being passed to the business logic.
- */
-export enum ConfigArgType {
-    PERCENTAGE = 'PERCENTAGE',
-    MONEY = 'MONEY',
-    INT = 'INT',
-    STRING = 'STRING',
-    DATETIME = 'DATETIME',
-    BOOLEAN = 'BOOLEAN',
-    FACET_VALUE_IDS = 'FACET_VALUE_IDS',
-    STRING_OPERATOR = 'STRING_OPERATOR',
-}
-
 export type ConfigurableOperation = {
     __typename?: 'ConfigurableOperation';
     code: Scalars['String'];

+ 2 - 20
packages/common/src/generated-types.ts

@@ -291,34 +291,16 @@ export type CollectionTranslationInput = {
 export type ConfigArg = {
   __typename?: 'ConfigArg',
   name: Scalars['String'],
-  type: ConfigArgType,
+  type: Scalars['String'],
   value?: Maybe<Scalars['String']>,
 };
 
 export type ConfigArgInput = {
   name: Scalars['String'],
-  type: ConfigArgType,
+  type: Scalars['String'],
   value?: Maybe<Scalars['String']>,
 };
 
-/** Certain entities allow arbitrary configuration arguments to be specified which can then
- * be set in the admin-ui and used in the business logic of the app. These are the valid
- * data types of such arguments. The data type influences:
- * 
- * 1. How the argument form field is rendered in the admin-ui
- * 2. The JavaScript type into which the value is coerced before being passed to the business logic.
- */
-export enum ConfigArgType {
-  PERCENTAGE = 'PERCENTAGE',
-  MONEY = 'MONEY',
-  INT = 'INT',
-  STRING = 'STRING',
-  DATETIME = 'DATETIME',
-  BOOLEAN = 'BOOLEAN',
-  FACET_VALUE_IDS = 'FACET_VALUE_IDS',
-  STRING_OPERATOR = 'STRING_OPERATOR'
-}
-
 export type ConfigurableOperation = {
   __typename?: 'ConfigurableOperation',
   code: Scalars['String'],

+ 19 - 1
packages/common/src/shared-types.ts

@@ -47,7 +47,25 @@ export type ID = string | number;
  */
 export type CustomFieldType = 'string' | 'localeString' | 'int' | 'float' | 'boolean' | 'datetime';
 
-export type CustomFieldsObject = { [key: string]: any; };
+/**
+ * Certain entities allow arbitrary configuration arguments to be specified which can then
+ * be set in the admin-ui and used in the business logic of the app. These are the valid
+ * data types of such arguments. The data type influences:
+ *
+ * 1. How the argument form field is rendered in the admin-ui
+ * 2. The JavaScript type into which the value is coerced before being passed to the business logic.
+ */
+export type ConfigArgType =
+    | 'string'
+    | 'int'
+    | 'float'
+    | 'boolean'
+    | 'datetime'
+    | 'facetValueIds'
+    | 'stringOperator';
+export type ConfigArgSubset<T extends ConfigArgType> = T;
+
+export type CustomFieldsObject = { [key: string]: any };
 
 /**
  * This interface describes the shape of the JSON config file used by the Admin UI.

+ 4 - 4
packages/core/e2e/__snapshots__/collection.e2e-spec.ts.snap

@@ -38,12 +38,12 @@ Object {
       "args": Array [
         Object {
           "name": "facetValueIds",
-          "type": "FACET_VALUE_IDS",
+          "type": "facetValueIds",
           "value": "[\\"T_1\\"]",
         },
         Object {
           "name": "containsAny",
-          "type": "BOOLEAN",
+          "type": "boolean",
           "value": "false",
         },
       ],
@@ -99,12 +99,12 @@ Object {
       "args": Array [
         Object {
           "name": "facetValueIds",
-          "type": "FACET_VALUE_IDS",
+          "type": "facetValueIds",
           "value": "[\\"T_3\\"]",
         },
         Object {
           "name": "containsAny",
-          "type": "BOOLEAN",
+          "type": "boolean",
           "value": "false",
         },
       ],

+ 8 - 8
packages/core/e2e/__snapshots__/promotion.e2e-spec.ts.snap

@@ -7,7 +7,7 @@ Object {
       "args": Array [
         Object {
           "name": "facetValueIds",
-          "type": "FACET_VALUE_IDS",
+          "type": "facetValueIds",
           "value": null,
         },
       ],
@@ -20,7 +20,7 @@ Object {
       "args": Array [
         Object {
           "name": "arg",
-          "type": "MONEY",
+          "type": "int",
           "value": null,
         },
       ],
@@ -31,7 +31,7 @@ Object {
       "args": Array [
         Object {
           "name": "arg",
-          "type": "MONEY",
+          "type": "int",
           "value": null,
         },
       ],
@@ -49,7 +49,7 @@ Object {
       "args": Array [
         Object {
           "name": "facetValueIds",
-          "type": "FACET_VALUE_IDS",
+          "type": "facetValueIds",
           "value": "[\\"T_1\\"]",
         },
       ],
@@ -62,7 +62,7 @@ Object {
       "args": Array [
         Object {
           "name": "arg",
-          "type": "MONEY",
+          "type": "int",
           "value": "500",
         },
       ],
@@ -82,7 +82,7 @@ Object {
       "args": Array [
         Object {
           "name": "facetValueIds",
-          "type": "FACET_VALUE_IDS",
+          "type": "facetValueIds",
           "value": "[\\"T_1\\"]",
         },
       ],
@@ -95,7 +95,7 @@ Object {
       "args": Array [
         Object {
           "name": "arg",
-          "type": "MONEY",
+          "type": "int",
           "value": "90",
         },
       ],
@@ -106,7 +106,7 @@ Object {
       "args": Array [
         Object {
           "name": "arg",
-          "type": "MONEY",
+          "type": "int",
           "value": "10",
         },
       ],

+ 14 - 15
packages/core/e2e/collection.e2e-spec.ts

@@ -14,7 +14,6 @@ import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { COLLECTION_FRAGMENT, FACET_VALUE_FRAGMENT } from './graphql/fragments';
 import {
     Collection,
-    ConfigArgType,
     CreateCollection,
     CreateCollectionInput,
     CreateCollectionSelectVariants,
@@ -109,12 +108,12 @@ describe('Collection resolver', () => {
                                     {
                                         name: 'facetValueIds',
                                         value: `["${getFacetValueId('electronics')}"]`,
-                                        type: ConfigArgType.FACET_VALUE_IDS,
+                                        type: 'facetValueIds',
                                     },
                                     {
                                         name: 'containsAny',
                                         value: `false`,
-                                        type: ConfigArgType.BOOLEAN,
+                                        type: 'boolean',
                                     },
                                 ],
                             },
@@ -145,12 +144,12 @@ describe('Collection resolver', () => {
                                     {
                                         name: 'facetValueIds',
                                         value: `["${getFacetValueId('computers')}"]`,
-                                        type: ConfigArgType.FACET_VALUE_IDS,
+                                        type: 'facetValueIds',
                                     },
                                     {
                                         name: 'containsAny',
                                         value: `false`,
-                                        type: ConfigArgType.BOOLEAN,
+                                        type: 'boolean',
                                     },
                                 ],
                             },
@@ -176,12 +175,12 @@ describe('Collection resolver', () => {
                                     {
                                         name: 'facetValueIds',
                                         value: `["${getFacetValueId('pear')}"]`,
-                                        type: ConfigArgType.FACET_VALUE_IDS,
+                                        type: 'facetValueIds',
                                     },
                                     {
                                         name: 'containsAny',
                                         value: `false`,
-                                        type: ConfigArgType.BOOLEAN,
+                                        type: 'boolean',
                                     },
                                 ],
                             },
@@ -415,12 +414,12 @@ describe('Collection resolver', () => {
                                 {
                                     name: 'operator',
                                     value: 'contains',
-                                    type: ConfigArgType.STRING_OPERATOR,
+                                    type: 'stringOperator',
                                 },
                                 {
                                     name: 'term',
                                     value: 'laptop',
-                                    type: ConfigArgType.STRING,
+                                    type: 'string',
                                 },
                             ],
                         },
@@ -601,12 +600,12 @@ describe('Collection resolver', () => {
                                         value: `["${getFacetValueId('pear')}", "${getFacetValueId(
                                             'photo',
                                         )}"]`,
-                                        type: ConfigArgType.FACET_VALUE_IDS,
+                                        type: 'facetValueIds',
                                     },
                                     {
                                         name: 'containsAny',
                                         value: `false`,
-                                        type: ConfigArgType.BOOLEAN,
+                                        type: 'boolean',
                                     },
                                 ],
                             },
@@ -636,12 +635,12 @@ describe('Collection resolver', () => {
                                         value: `["${getFacetValueId('pear')}", "${getFacetValueId(
                                             'photo',
                                         )}"]`,
-                                        type: ConfigArgType.FACET_VALUE_IDS,
+                                        type: 'facetValueIds',
                                     },
                                     {
                                         name: 'containsAny',
                                         value: `true`,
-                                        type: ConfigArgType.BOOLEAN,
+                                        type: 'boolean',
                                     },
                                 ],
                             },
@@ -681,12 +680,12 @@ describe('Collection resolver', () => {
                                     {
                                         name: 'operator',
                                         value: operator,
-                                        type: ConfigArgType.STRING_OPERATOR,
+                                        type: 'stringOperator',
                                     },
                                     {
                                         name: 'term',
                                         value: term,
-                                        type: ConfigArgType.STRING,
+                                        type: 'string',
                                     },
                                 ],
                             },

+ 4 - 5
packages/core/e2e/default-search-plugin.e2e-spec.ts

@@ -8,7 +8,6 @@ import { DefaultSearchPlugin } from '../src/plugin/default-search-plugin/default
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import {
-    ConfigArgType,
     CreateCollection,
     CreateFacet,
     GetRunningJobs,
@@ -390,12 +389,12 @@ describe('Default search plugin', () => {
                                     {
                                         name: 'facetValueIds',
                                         value: `["T_4"]`,
-                                        type: ConfigArgType.FACET_VALUE_IDS,
+                                        type: 'facetValueIds',
                                     },
                                     {
                                         name: 'containsAny',
                                         value: `false`,
-                                        type: ConfigArgType.BOOLEAN,
+                                        type: 'boolean',
                                     },
                                 ],
                             },
@@ -444,12 +443,12 @@ describe('Default search plugin', () => {
                                 {
                                     name: 'facetValueIds',
                                     value: `["T_3"]`,
-                                    type: ConfigArgType.FACET_VALUE_IDS,
+                                    type: 'facetValueIds',
                                 },
                                 {
                                     name: 'containsAny',
                                     value: `false`,
-                                    type: ConfigArgType.BOOLEAN,
+                                    type: 'boolean',
                                 },
                             ],
                         },

+ 2 - 20
packages/core/e2e/graphql/generated-e2e-admin-types.ts

@@ -291,34 +291,16 @@ export type CollectionTranslationInput = {
 export type ConfigArg = {
     __typename?: 'ConfigArg';
     name: Scalars['String'];
-    type: ConfigArgType;
+    type: Scalars['String'];
     value?: Maybe<Scalars['String']>;
 };
 
 export type ConfigArgInput = {
     name: Scalars['String'];
-    type: ConfigArgType;
+    type: Scalars['String'];
     value?: Maybe<Scalars['String']>;
 };
 
-/** Certain entities allow arbitrary configuration arguments to be specified which can then
- * be set in the admin-ui and used in the business logic of the app. These are the valid
- * data types of such arguments. The data type influences:
- *
- * 1. How the argument form field is rendered in the admin-ui
- * 2. The JavaScript type into which the value is coerced before being passed to the business logic.
- */
-export enum ConfigArgType {
-    PERCENTAGE = 'PERCENTAGE',
-    MONEY = 'MONEY',
-    INT = 'INT',
-    STRING = 'STRING',
-    DATETIME = 'DATETIME',
-    BOOLEAN = 'BOOLEAN',
-    FACET_VALUE_IDS = 'FACET_VALUE_IDS',
-    STRING_OPERATOR = 'STRING_OPERATOR',
-}
-
 export type ConfigurableOperation = {
     __typename?: 'ConfigurableOperation';
     code: Scalars['String'];

+ 2 - 20
packages/core/e2e/graphql/generated-e2e-shop-types.ts

@@ -215,34 +215,16 @@ export type CollectionTranslation = {
 export type ConfigArg = {
     __typename?: 'ConfigArg';
     name: Scalars['String'];
-    type: ConfigArgType;
+    type: Scalars['String'];
     value?: Maybe<Scalars['String']>;
 };
 
 export type ConfigArgInput = {
     name: Scalars['String'];
-    type: ConfigArgType;
+    type: Scalars['String'];
     value?: Maybe<Scalars['String']>;
 };
 
-/** Certain entities allow arbitrary configuration arguments to be specified which can then
- * be set in the admin-ui and used in the business logic of the app. These are the valid
- * data types of such arguments. The data type influences:
- *
- * 1. How the argument form field is rendered in the admin-ui
- * 2. The JavaScript type into which the value is coerced before being passed to the business logic.
- */
-export enum ConfigArgType {
-    PERCENTAGE = 'PERCENTAGE',
-    MONEY = 'MONEY',
-    INT = 'INT',
-    STRING = 'STRING',
-    DATETIME = 'DATETIME',
-    BOOLEAN = 'BOOLEAN',
-    FACET_VALUE_IDS = 'FACET_VALUE_IDS',
-    STRING_OPERATOR = 'STRING_OPERATOR',
-}
-
 export type ConfigurableOperation = {
     __typename?: 'ConfigurableOperation';
     code: Scalars['String'];

+ 10 - 8
packages/core/e2e/promotion.e2e-spec.ts

@@ -8,7 +8,6 @@ import { PromotionCondition } from '../src/config/promotion/promotion-condition'
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { CONFIGURABLE_FRAGMENT, PROMOTION_FRAGMENT } from './graphql/fragments';
 import {
-    ConfigArgType,
     CreatePromotion,
     DeletePromotion,
     DeletionResult,
@@ -68,7 +67,7 @@ describe('Promotion resolver', () => {
                     conditions: [
                         {
                             code: promoCondition.code,
-                            arguments: [{ name: 'arg', value: '500', type: ConfigArgType.MONEY }],
+                            arguments: [{ name: 'arg', value: '500', type: 'int' }],
                         },
                     ],
                     actions: [
@@ -78,7 +77,7 @@ describe('Promotion resolver', () => {
                                 {
                                     name: 'facetValueIds',
                                     value: '["T_1"]',
-                                    type: ConfigArgType.FACET_VALUE_IDS,
+                                    type: 'facetValueIds',
                                 },
                             ],
                         },
@@ -99,11 +98,11 @@ describe('Promotion resolver', () => {
                     conditions: [
                         {
                             code: promoCondition.code,
-                            arguments: [{ name: 'arg', value: '90', type: ConfigArgType.MONEY }],
+                            arguments: [{ name: 'arg', value: '90', type: 'int' }],
                         },
                         {
                             code: promoCondition2.code,
-                            arguments: [{ name: 'arg', value: '10', type: ConfigArgType.MONEY }],
+                            arguments: [{ name: 'arg', value: '10', type: 'int' }],
                         },
                     ],
                 },
@@ -149,7 +148,10 @@ describe('Promotion resolver', () => {
 
         it('deletes a promotion', async () => {
             promotionToDelete = allPromotions[0];
-            const result = await client.query<DeletePromotion.Mutation, DeletePromotion.Variables>(DELETE_PROMOTION, { id: promotionToDelete.id });
+            const result = await client.query<DeletePromotion.Mutation, DeletePromotion.Variables>(
+                DELETE_PROMOTION,
+                { id: promotionToDelete.id },
+            );
 
             expect(result.deletePromotion).toEqual({ result: DeletionResult.DELETED });
         });
@@ -189,7 +191,7 @@ function generateTestCondition(code: string): PromotionCondition<any> {
     return new PromotionCondition({
         code,
         description: `description for ${code}`,
-        args: { arg: ConfigArgType.MONEY },
+        args: { arg: { type: 'int' } },
         check: (order, args) => true,
     });
 }
@@ -198,7 +200,7 @@ function generateTestAction(code: string): PromotionAction<any> {
     return new PromotionOrderAction({
         code,
         description: `description for ${code}`,
-        args: { facetValueIds: ConfigArgType.FACET_VALUE_IDS },
+        args: { facetValueIds: { type: 'facetValueIds' } },
         execute: (order, args) => {
             return 42;
         },

+ 2 - 3
packages/core/e2e/shop-catalog.e2e-spec.ts

@@ -6,7 +6,6 @@ import { facetValueCollectionFilter } from '../src/config/collection/default-col
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import {
-    ConfigArgType,
     CreateCollection,
     CreateFacet,
     DisableProduct,
@@ -249,12 +248,12 @@ describe('Shop catalog', () => {
                                 {
                                     name: 'facetValueIds',
                                     value: `["${category.values[3].id}"]`,
-                                    type: ConfigArgType.FACET_VALUE_IDS,
+                                    type: 'facetValueIds',
                                 },
                                 {
                                     name: 'containsAny',
                                     value: `false`,
-                                    type: ConfigArgType.BOOLEAN,
+                                    type: 'boolean',
                                 },
                             ],
                         },

+ 3 - 8
packages/core/src/api/common/id-codec.service.ts

@@ -1,10 +1,5 @@
 import { Injectable } from '@nestjs/common';
-import {
-    ConfigArgType,
-    ConfigurableOperation,
-    ConfigurableOperationInput,
-} from '@vendure/common/lib/generated-types';
-import { ID } from '@vendure/common/lib/shared-types';
+import { ConfigurableOperation, ConfigurableOperationInput } from '@vendure/common/lib/generated-types';
 
 import { ConfigService } from '../../config/config.service';
 
@@ -37,7 +32,7 @@ export class IdCodecService {
         const inputArray = Array.isArray(input) ? input : [input];
         for (const operationInput of inputArray) {
             for (const arg of operationInput.arguments) {
-                if (arg.type === ConfigArgType.FACET_VALUE_IDS && arg.value) {
+                if (arg.type === 'facetValueIds' && arg.value) {
                     const ids = JSON.parse(arg.value) as string[];
                     const decodedIds = ids.map(id => this.decode(id));
                     arg.value = JSON.stringify(decodedIds);
@@ -59,7 +54,7 @@ export class IdCodecService {
         const inputArray = Array.isArray(input) ? input : [input];
         for (const operation of inputArray) {
             for (const arg of operation.args) {
-                if (arg.type === ConfigArgType.FACET_VALUE_IDS && arg.value) {
+                if (arg.type === 'facetValueIds' && arg.value) {
                     const ids = JSON.parse(arg.value) as string[];
                     const encoded = ids.map(id => this.encode(id));
                     arg.value = JSON.stringify(encoded);

+ 2 - 22
packages/core/src/api/schema/common/common-types.graphql

@@ -20,29 +20,9 @@ type Adjustment {
     amount: Int!
 }
 
-"""
-Certain entities allow arbitrary configuration arguments to be specified which can then
-be set in the admin-ui and used in the business logic of the app. These are the valid
-data types of such arguments. The data type influences:
-
-1. How the argument form field is rendered in the admin-ui
-2. The JavaScript type into which the value is coerced before being passed to the business logic.
-
-"""
-enum ConfigArgType {
-    PERCENTAGE
-    MONEY
-    INT
-    STRING
-    DATETIME
-    BOOLEAN
-    FACET_VALUE_IDS
-    STRING_OPERATOR
-}
-
 type ConfigArg {
     name: String!
-    type: ConfigArgType!
+    type: String!
     value: String
 }
 
@@ -66,7 +46,7 @@ type DeletionResponse {
 
 input ConfigArgInput {
     name: String!
-    type: ConfigArgType!
+    type: String!
     value: String
 }
 

+ 22 - 18
packages/core/src/common/configurable-operation.ts

@@ -1,12 +1,18 @@
 // prettier-ignore
-import { ConfigArg, ConfigArgType, ConfigurableOperation } from '@vendure/common/lib/generated-types';
+import { ConfigArg, ConfigurableOperation } from '@vendure/common/lib/generated-types';
+import { ConfigArgType } from '@vendure/common/lib/shared-types';
 
 import { InternalServerError } from './error/errors';
 
+export type ConfigArgDef<T extends ConfigArgType> = {
+    type: T;
+};
+
 export type ConfigArgs<T extends ConfigArgType> = {
-    [name: string]: T;
+    [name: string]: ConfigArgDef<T>;
 };
 
+// TODO: replace with string options
 export type StringOperator = 'startsWith' | 'endsWith' | 'contains' | 'doesNotContain';
 
 // prettier-ignore
@@ -15,15 +21,15 @@ export type StringOperator = 'startsWith' | 'endsWith' | 'contains' | 'doesNotCo
  * in business logic.
  */
 export type ConfigArgValues<T extends ConfigArgs<any>> = {
-    [K in keyof T]: T[K] extends ConfigArgType.INT | ConfigArgType.MONEY | ConfigArgType.PERCENTAGE
+    [K in keyof T]: T[K] extends ConfigArgDef<'int' | 'float'>
         ? number
-        : T[K] extends ConfigArgType.DATETIME
+        : T[K] extends ConfigArgDef<'datetime'>
             ? Date
-            : T[K] extends ConfigArgType.BOOLEAN
+            : T[K] extends ConfigArgDef<'boolean'>
                 ? boolean
-                : T[K] extends ConfigArgType.FACET_VALUE_IDS
+                : T[K] extends ConfigArgDef<'facetValueIds'>
                     ? string[]
-                    : T[K] extends ConfigArgType.STRING_OPERATOR
+                    : T[K] extends ConfigArgDef<'stringOperator'>
                         ? StringOperator
                         : string
 };
@@ -46,7 +52,7 @@ export function configurableDefToOperation(def: ConfigurableOperationDef): Confi
     return {
         code: def.code,
         description: def.description,
-        args: Object.entries(def.args).map(([name, type]) => ({ name, type })),
+        args: Object.entries(def.args).map(([name, arg]) => ({ name, type: arg.type })),
     };
 }
 
@@ -59,7 +65,7 @@ export function configurableDefToOperation(def: ConfigurableOperationDef): Confi
  * to:
  * { foo: 'bar' }
  **/
-export function argsArrayToHash<T>(args: ConfigArg[]): ConfigArgValues<T> {
+export function argsArrayToHash<T extends ConfigArgs<any>>(args: ConfigArg[]): ConfigArgValues<T> {
     const output: ConfigArgValues<T> = {} as any;
     for (const arg of args) {
         if (arg && arg.value != null) {
@@ -69,20 +75,18 @@ export function argsArrayToHash<T>(args: ConfigArg[]): ConfigArgValues<T> {
     return output;
 }
 
-function coerceValueToType<T>(arg: ConfigArg): ConfigArgValues<T>[keyof T] {
+function coerceValueToType<T extends ConfigArgs<any>>(arg: ConfigArg): ConfigArgValues<T>[keyof T] {
     switch (arg.type as ConfigArgType) {
-        case ConfigArgType.STRING:
-        case ConfigArgType.STRING_OPERATOR:
+        case 'string':
+        case 'stringOperator':
             return arg.value as any;
-        case ConfigArgType.INT:
-        case ConfigArgType.MONEY:
-        case ConfigArgType.PERCENTAGE:
+        case 'int':
             return Number.parseInt(arg.value || '', 10) as any;
-        case ConfigArgType.DATETIME:
+        case 'datetime':
             return Date.parse(arg.value || '') as any;
-        case ConfigArgType.BOOLEAN:
+        case 'boolean':
             return !!(arg.value && (arg.value.toLowerCase() === 'true' || arg.value === '1')) as any;
-        case ConfigArgType.FACET_VALUE_IDS:
+        case 'facetValueIds':
             try {
                 return JSON.parse(arg.value as any);
             } catch (err) {

+ 5 - 2
packages/core/src/config/collection/collection-filter.ts

@@ -1,4 +1,5 @@
-import { ConfigArg, ConfigArgType } from '@vendure/common/lib/generated-types';
+import { ConfigArg } from '@vendure/common/lib/generated-types';
+import { ConfigArgSubset, ConfigArgType } from '@vendure/common/lib/shared-types';
 import { SelectQueryBuilder } from 'typeorm';
 
 import {
@@ -9,7 +10,9 @@ import {
 } from '../../common/configurable-operation';
 import { ProductVariant } from '../../entity/product-variant/product-variant.entity';
 
-export type CollectionFilterArgType = ConfigArgType.FACET_VALUE_IDS | ConfigArgType.STRING | ConfigArgType.STRING_OPERATOR | ConfigArgType.BOOLEAN;
+export type CollectionFilterArgType = ConfigArgSubset<
+    'facetValueIds' | 'string' | 'stringOperator' | 'boolean'
+>;
 export type CollectionFilterArgs = ConfigArgs<CollectionFilterArgType>;
 
 export type ApplyCollectionFilterFn<T extends CollectionFilterArgs> = (

+ 10 - 7
packages/core/src/config/collection/default-collection-filters.ts

@@ -1,6 +1,7 @@
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
 import { Brackets } from 'typeorm';
 
+import { UserInputError } from '../../common/error/errors';
+
 import { CollectionFilter } from './collection-filter';
 
 /**
@@ -8,8 +9,8 @@ import { CollectionFilter } from './collection-filter';
  */
 export const facetValueCollectionFilter = new CollectionFilter({
     args: {
-        facetValueIds: ConfigArgType.FACET_VALUE_IDS,
-        containsAny: ConfigArgType.BOOLEAN,
+        facetValueIds: { type: 'facetValueIds' },
+        containsAny: { type: 'boolean' },
     },
     code: 'facet-value-filter',
     description: 'Filter by FacetValues',
@@ -22,8 +23,8 @@ export const facetValueCollectionFilter = new CollectionFilter({
                     new Brackets(qb1 => {
                         const ids = args.facetValueIds;
                         return qb1
-                            .where(`productFacetValues.id IN (:...ids)`, {ids})
-                            .orWhere(`variantFacetValues.id IN (:...ids)`, {ids});
+                            .where(`productFacetValues.id IN (:...ids)`, { ids })
+                            .orWhere(`variantFacetValues.id IN (:...ids)`, { ids });
                     }),
                 )
                 .groupBy('productVariant.id')
@@ -38,8 +39,8 @@ export const facetValueCollectionFilter = new CollectionFilter({
 
 export const variantNameCollectionFilter = new CollectionFilter({
     args: {
-        operator: ConfigArgType.STRING_OPERATOR,
-        term: ConfigArgType.STRING,
+        operator: { type: 'string' },
+        term: { type: 'string' },
     },
     code: 'variant-name-filter',
     description: 'Filter by ProductVariant name',
@@ -54,6 +55,8 @@ export const variantNameCollectionFilter = new CollectionFilter({
                 return qb.andWhere('translation.name LIKE :term', { term: `${args.term}%` });
             case 'endsWith':
                 return qb.andWhere('translation.name LIKE :term', { term: `%${args.term}` });
+            default:
+                throw new UserInputError(`${args.operator} is not a valid operator`);
         }
     },
 });

+ 2 - 4
packages/core/src/config/payment-method/example-payment-method-config.ts

@@ -1,5 +1,3 @@
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
-
 import { CreatePaymentResult, PaymentMethodHandler } from './payment-method-handler';
 
 /**
@@ -28,8 +26,8 @@ export const examplePaymentHandler = new PaymentMethodHandler({
     code: 'example-payment-provider',
     description: 'Example Payment Provider',
     args: {
-        automaticCapture: ConfigArgType.BOOLEAN,
-        apiKey: ConfigArgType.STRING,
+        automaticCapture: { type: 'boolean' },
+        apiKey: { type: 'string' },
     },
     createPayment: async (order, args, metadata): Promise<CreatePaymentResult> => {
         try {

+ 3 - 2
packages/core/src/config/payment-method/payment-method-handler.ts

@@ -1,4 +1,5 @@
-import { ConfigArg, ConfigArgType, RefundOrderInput } from '@vendure/common/lib/generated-types';
+import { ConfigArg, RefundOrderInput } from '@vendure/common/lib/generated-types';
+import { ConfigArgSubset } from '@vendure/common/lib/shared-types';
 
 import {
     argsArrayToHash,
@@ -15,7 +16,7 @@ import {
 } from '../../service/helpers/payment-state-machine/payment-state';
 import { RefundState } from '../../service/helpers/refund-state-machine/refund-state';
 
-export type PaymentMethodArgType = ConfigArgType.INT | ConfigArgType.STRING | ConfigArgType.BOOLEAN;
+export type PaymentMethodArgType = ConfigArgSubset<'int' | 'string' | 'boolean'>;
 export type PaymentMethodArgs = ConfigArgs<PaymentMethodArgType>;
 export type OnTransitionStartReturnType = ReturnType<Required<StateMachineConfig<any>>['onTransitionStart']>;
 

+ 18 - 5
packages/core/src/config/promotion/default-promotion-actions.ts

@@ -1,10 +1,12 @@
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
-
 import { PromotionItemAction, PromotionOrderAction } from './promotion-action';
 
 export const orderPercentageDiscount = new PromotionOrderAction({
     code: 'order_percentage_discount',
-    args: { discount: ConfigArgType.PERCENTAGE },
+    args: {
+        discount: {
+            type: 'int',
+        },
+    },
     execute(order, args) {
         return -order.subTotal * (args.discount / 100);
     },
@@ -13,7 +15,11 @@ export const orderPercentageDiscount = new PromotionOrderAction({
 
 export const itemPercentageDiscount = new PromotionItemAction({
     code: 'item_percentage_discount',
-    args: { discount: ConfigArgType.PERCENTAGE },
+    args: {
+        discount: {
+            type: 'int',
+        },
+    },
     execute(orderItem, orderLine, args) {
         return -orderLine.unitPrice * (args.discount / 100);
     },
@@ -37,7 +43,14 @@ export const buy1Get1Free = new PromotionItemAction({
 
 export const discountOnItemWithFacets = new PromotionItemAction({
     code: 'facet_based_discount',
-    args: { discount: ConfigArgType.PERCENTAGE, facets: ConfigArgType.FACET_VALUE_IDS },
+    args: {
+        discount: {
+            type: 'int',
+        },
+        facets: {
+            type: 'facetValueIds',
+        },
+    },
     async execute(orderItem, orderLine, args, { hasFacetValues }) {
         if (await hasFacetValues(orderLine, args.facets)) {
             return -orderLine.unitPrice * (args.discount / 100);

+ 17 - 10
packages/core/src/config/promotion/default-promotion-conditions.ts

@@ -1,5 +1,3 @@
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
-
 import { Order } from '../../entity/order/order.entity';
 
 import { PromotionCondition } from './promotion-condition';
@@ -8,8 +6,8 @@ export const minimumOrderAmount = new PromotionCondition({
     description: 'If order total is greater than { amount }',
     code: 'minimum_order_amount',
     args: {
-        amount: ConfigArgType.MONEY,
-        taxInclusive: ConfigArgType.BOOLEAN,
+        amount: { type: 'int' },
+        taxInclusive: { type: 'boolean' },
     },
     check(order, args) {
         if (args.taxInclusive) {
@@ -24,7 +22,10 @@ export const minimumOrderAmount = new PromotionCondition({
 export const dateRange = new PromotionCondition({
     code: 'date_range',
     description: 'If Order placed between { start } and { end }',
-    args: { start: ConfigArgType.DATETIME, end: ConfigArgType.DATETIME },
+    args: {
+        start: { type: 'datetime' },
+        end: { type: 'datetime' },
+    },
     check(order: Order, args) {
         const now = new Date();
         return args.start < now && now < args.end;
@@ -34,18 +35,24 @@ export const dateRange = new PromotionCondition({
 export const atLeastNOfProduct = new PromotionCondition({
     code: 'at_least_n_of_product',
     description: 'Buy at least { minimum } of any product',
-    args: { minimum: ConfigArgType.INT },
+    args: { minimum: { type: 'int' } },
     check(order: Order, args) {
-        return order.lines.reduce((result, item) => {
-            return result || item.quantity >= args.minimum;
-        }, false as boolean);
+        return order.lines.reduce(
+            (result, item) => {
+                return result || item.quantity >= args.minimum;
+            },
+            false as boolean,
+        );
     },
 });
 
 export const atLeastNWithFacets = new PromotionCondition({
     code: 'at_least_n_with_facets',
     description: 'Buy at least { minimum } products with the given facets',
-    args: { minimum: ConfigArgType.INT, facets: ConfigArgType.FACET_VALUE_IDS },
+    args: {
+        minimum: { type: 'int' },
+        facets: { type: 'facetValueIds' },
+    },
     async check(order: Order, args, { hasFacetValues }) {
         let matches = 0;
         for (const line of order.lines) {

+ 3 - 6
packages/core/src/config/promotion/promotion-action.ts

@@ -1,4 +1,5 @@
-import { ConfigArg, ConfigArgType } from '@vendure/common/lib/generated-types';
+import { ConfigArg } from '@vendure/common/lib/generated-types';
+import { ConfigArgSubset } from '@vendure/common/lib/shared-types';
 
 import {
     argsArrayToHash,
@@ -12,11 +13,7 @@ import { Order } from '../../entity/order/order.entity';
 
 import { PromotionUtils } from './promotion-condition';
 
-export type PromotionActionArgType =
-    | ConfigArgType.PERCENTAGE
-    | ConfigArgType.MONEY
-    | ConfigArgType.INT
-    | ConfigArgType.FACET_VALUE_IDS;
+export type PromotionActionArgType = ConfigArgSubset<'int' | 'facetValueIds'>;
 export type PromotionActionArgs = ConfigArgs<PromotionActionArgType>;
 
 export type ExecutePromotionItemActionFn<T extends PromotionActionArgs> = (

+ 6 - 10
packages/core/src/config/promotion/promotion-condition.ts

@@ -1,5 +1,5 @@
-import { ConfigArg, ConfigArgType } from '@vendure/common/lib/generated-types';
-import { ID } from '@vendure/common/lib/shared-types';
+import { ConfigArg } from '@vendure/common/lib/generated-types';
+import { ConfigArgSubset, ID } from '@vendure/common/lib/shared-types';
 
 import {
     argsArrayToHash,
@@ -10,13 +10,9 @@ import {
 import { OrderLine } from '../../entity';
 import { Order } from '../../entity/order/order.entity';
 
-export type PromotionConditionArgType =
-    | ConfigArgType.INT
-    | ConfigArgType.MONEY
-    | ConfigArgType.STRING
-    | ConfigArgType.DATETIME
-    | ConfigArgType.BOOLEAN
-    | ConfigArgType.FACET_VALUE_IDS;
+export type PromotionConditionArgType = ConfigArgSubset<
+    'int' | 'string' | 'datetime' | 'boolean' | 'facetValueIds'
+>;
 export type PromotionConditionArgs = ConfigArgs<PromotionConditionArgType>;
 
 /**
@@ -78,6 +74,6 @@ export class PromotionCondition<T extends PromotionConditionArgs = {}> implement
     }
 
     async check(order: Order, args: ConfigArg[], utils: PromotionUtils): Promise<boolean> {
-        return await this.checkFn(order, argsArrayToHash<T>(args), utils);
+        return this.checkFn(order, argsArrayToHash<T>(args), utils);
     }
 }

+ 2 - 4
packages/core/src/config/shipping-method/default-shipping-calculator.ts

@@ -1,13 +1,11 @@
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
-
 import { ShippingCalculator } from './shipping-calculator';
 
 export const defaultShippingCalculator = new ShippingCalculator({
     code: 'default-shipping-calculator',
     description: 'Default Flat-Rate Shipping Calculator',
     args: {
-        rate: ConfigArgType.MONEY,
-        taxRate: ConfigArgType.PERCENTAGE,
+        rate: { type: 'int' },
+        taxRate: { type: 'int' },
     },
     calculate: (order, args) => {
         return { price: args.rate, priceWithTax: args.rate * ((100 + args.taxRate) / 100) };

+ 1 - 3
packages/core/src/config/shipping-method/default-shipping-eligibility-checker.ts

@@ -1,12 +1,10 @@
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
-
 import { ShippingEligibilityChecker } from './shipping-eligibility-checker';
 
 export const defaultShippingEligibilityChecker = new ShippingEligibilityChecker({
     code: 'default-shipping-eligibility-checker',
     description: 'Default Shipping Eligibility Checker',
     args: {
-        orderMinimum: ConfigArgType.MONEY,
+        orderMinimum: { type: 'int' },
     },
     check: (order, args) => {
         return order.total >= args.orderMinimum;

+ 9 - 9
packages/core/src/config/shipping-method/shipping-calculator.ts

@@ -1,15 +1,15 @@
-import { ConfigArg, ConfigArgType } from '@vendure/common/lib/generated-types';
+import { ConfigArg } from '@vendure/common/lib/generated-types';
+import { ConfigArgSubset } from '@vendure/common/lib/shared-types';
 
-import { ConfigArgs, ConfigurableOperationDef } from '../../common/configurable-operation';
-import { argsArrayToHash, ConfigArgValues } from '../../common/configurable-operation';
+import {
+    argsArrayToHash,
+    ConfigArgs,
+    ConfigArgValues,
+    ConfigurableOperationDef,
+} from '../../common/configurable-operation';
 import { Order } from '../../entity/order/order.entity';
 
-export type ShippingCalculatorArgType =
-    | ConfigArgType.INT
-    | ConfigArgType.MONEY
-    | ConfigArgType.STRING
-    | ConfigArgType.PERCENTAGE
-    | ConfigArgType.BOOLEAN;
+export type ShippingCalculatorArgType = ConfigArgSubset<'int' | 'string' | 'boolean'>;
 export type ShippingCalculatorArgs = ConfigArgs<ShippingCalculatorArgType>;
 
 export type ShippingPrice = {

+ 3 - 6
packages/core/src/config/shipping-method/shipping-eligibility-checker.ts

@@ -1,14 +1,11 @@
-import { ConfigArg, ConfigArgType } from '@vendure/common/lib/generated-types';
+import { ConfigArg } from '@vendure/common/lib/generated-types';
+import { ConfigArgSubset } from '@vendure/common/lib/shared-types';
 
 import { ConfigArgs, ConfigurableOperationDef } from '../../common/configurable-operation';
 import { argsArrayToHash, ConfigArgValues } from '../../common/configurable-operation';
 import { Order } from '../../entity/order/order.entity';
 
-export type ShippingEligibilityCheckerArgType =
-    | ConfigArgType.INT
-    | ConfigArgType.MONEY
-    | ConfigArgType.STRING
-    | ConfigArgType.BOOLEAN;
+export type ShippingEligibilityCheckerArgType = ConfigArgSubset<'int' | 'string' | 'boolean'>;
 export type ShippingEligibilityCheckerArgs = ConfigArgs<ShippingEligibilityCheckerArgType>;
 
 /**

+ 10 - 7
packages/core/src/data-import/providers/populator/populator.ts

@@ -1,5 +1,5 @@
 import { Injectable } from '@nestjs/common';
-import { ConfigArgType, LanguageCode } from '@vendure/common/lib/generated-types';
+import { LanguageCode } from '@vendure/common/lib/generated-types';
 import { normalizeString } from '@vendure/common/lib/normalize-string';
 import { ID } from '@vendure/common/lib/shared-types';
 import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
@@ -91,7 +91,10 @@ export class Populator {
 
             let featuredAssetId: string | null = null;
             if (collectionDef.featuredAssetFilename) {
-                const asset = await this.assetService.findByFileName(collectionDef.featuredAssetFilename, false);
+                const asset = await this.assetService.findByFileName(
+                    collectionDef.featuredAssetFilename,
+                    false,
+                );
                 if (asset) {
                     featuredAssetId = asset.id as string;
                 }
@@ -114,13 +117,13 @@ export class Populator {
                         arguments: [
                             {
                                 name: 'facetValueIds',
-                                type: ConfigArgType.FACET_VALUE_IDS,
+                                type: 'facetValueIds',
                                 value: JSON.stringify(facetValueIds),
                             },
                             {
                                 name: 'containsAny',
                                 value: `false`,
-                                type: ConfigArgType.BOOLEAN,
+                                type: 'boolean',
                             },
                         ],
                     },
@@ -219,13 +222,13 @@ export class Populator {
             await this.shippingMethodService.create({
                 checker: {
                     code: defaultShippingEligibilityChecker.code,
-                    arguments: [{ name: 'orderMinimum', value: '0', type: ConfigArgType.MONEY }],
+                    arguments: [{ name: 'orderMinimum', value: '0', type: 'int' /* TODO: money */ }],
                 },
                 calculator: {
                     code: defaultShippingCalculator.code,
                     arguments: [
-                        { name: 'rate', value: method.price.toString(), type: ConfigArgType.MONEY },
-                        { name: 'taxRate', value: '0', type: ConfigArgType.PERCENTAGE },
+                        { name: 'rate', value: method.price.toString(), type: 'int' /* TODO: money */ },
+                        { name: 'taxRate', value: '0', type: 'int' /* TODO: percentage */ },
                     ],
                 },
                 description: method.name,

+ 8 - 9
packages/core/src/service/helpers/order-calculator/order-calculator.spec.ts

@@ -1,5 +1,4 @@
 import { Test } from '@nestjs/testing';
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
 import { Omit } from '@vendure/common/lib/omit';
 import { Connection } from 'typeorm';
 
@@ -138,7 +137,7 @@ describe('OrderCalculator', () => {
         });
 
         const orderTotalCondition = new PromotionCondition({
-            args: { minimum: ConfigArgType.MONEY },
+            args: { minimum: { type: 'int' } },
             code: 'order_total_condition',
             description: '',
             check(order, args) {
@@ -190,7 +189,7 @@ describe('OrderCalculator', () => {
                 conditions: [
                     {
                         code: orderTotalCondition.code,
-                        args: [{ name: 'minimum', type: ConfigArgType.MONEY, value: '100' }],
+                        args: [{ name: 'minimum', type: 'int', value: '100' }],
                     },
                 ],
                 promotionConditions: [orderTotalCondition],
@@ -222,7 +221,7 @@ describe('OrderCalculator', () => {
 
         it('interaction between promotions', async () => {
             const orderQuantityCondition = new PromotionCondition({
-                args: { minimum: ConfigArgType.INT },
+                args: { minimum: { type: 'int' } },
                 code: 'order_quantity_condition',
                 description: 'Passes if any order line has at least the minimum quantity',
                 check(_order, args) {
@@ -237,7 +236,7 @@ describe('OrderCalculator', () => {
 
             const orderPercentageDiscount = new PromotionOrderAction({
                 code: 'order_percentage_discount',
-                args: { discount: ConfigArgType.PERCENTAGE },
+                args: { discount: { type: 'int' } },
                 execute(_order, args) {
                     return -_order.subTotal * (args.discount / 100);
                 },
@@ -250,14 +249,14 @@ describe('OrderCalculator', () => {
                 conditions: [
                     {
                         code: orderQuantityCondition.code,
-                        args: [{ name: 'minimum', type: ConfigArgType.INT, value: '3' }],
+                        args: [{ name: 'minimum', type: 'int', value: '3' }],
                     },
                 ],
                 promotionConditions: [orderQuantityCondition],
                 actions: [
                     {
                         code: orderPercentageDiscount.code,
-                        args: [{ name: 'discount', type: ConfigArgType.PERCENTAGE, value: '50' }],
+                        args: [{ name: 'discount', type: 'int', value: '50' }],
                     },
                 ],
                 promotionActions: [orderPercentageDiscount],
@@ -269,14 +268,14 @@ describe('OrderCalculator', () => {
                 conditions: [
                     {
                         code: orderTotalCondition.code,
-                        args: [{ name: 'minimum', type: ConfigArgType.MONEY, value: '100' }],
+                        args: [{ name: 'minimum', type: 'int', value: '100' }],
                     },
                 ],
                 promotionConditions: [orderTotalCondition],
                 actions: [
                     {
                         code: orderPercentageDiscount.code,
-                        args: [{ name: 'discount', type: ConfigArgType.PERCENTAGE, value: '10' }],
+                        args: [{ name: 'discount', type: 'int', value: '10' }],
                     },
                 ],
                 promotionActions: [orderPercentageDiscount],

+ 18 - 6
packages/core/src/service/services/collection.service.ts

@@ -6,7 +6,7 @@ import {
     DeletionResponse,
     DeletionResult,
     MoveCollectionInput,
-    UpdateCollectionInput
+    UpdateCollectionInput,
 } from '@vendure/common/lib/generated-types';
 import { pick } from '@vendure/common/lib/pick';
 import { ROOT_COLLECTION_NAME } from '@vendure/common/lib/shared-constants';
@@ -22,7 +22,10 @@ import { ListQueryOptions } from '../../common/types/common-types';
 import { Translated } from '../../common/types/locale-types';
 import { assertFound, idsAreEqual } from '../../common/utils';
 import { CollectionFilter } from '../../config/collection/collection-filter';
-import { facetValueCollectionFilter, variantNameCollectionFilter } from '../../config/collection/default-collection-filters';
+import {
+    facetValueCollectionFilter,
+    variantNameCollectionFilter,
+} from '../../config/collection/default-collection-filters';
 import { CollectionTranslation } from '../../entity/collection/collection-translation.entity';
 import { Collection } from '../../entity/collection/collection.entity';
 import { ProductVariant } from '../../entity/product-variant/product-variant.entity';
@@ -40,7 +43,10 @@ import { FacetValueService } from './facet-value.service';
 
 export class CollectionService implements OnModuleInit {
     private rootCategories: { [channelCode: string]: Collection } = {};
-    private availableFilters: Array<CollectionFilter<any>> = [facetValueCollectionFilter, variantNameCollectionFilter];
+    private availableFilters: Array<CollectionFilter<any>> = [
+        facetValueCollectionFilter,
+        variantNameCollectionFilter,
+    ];
 
     constructor(
         @InjectConnection() private connection: Connection,
@@ -170,7 +176,11 @@ export class CollectionService implements OnModuleInit {
      * Returns the descendants of a Collection as a flat array. The depth of the traversal can be limited
      * with the maxDepth argument. So to get only the immediate children, set maxDepth = 1.
      */
-    async getDescendants(ctx: RequestContext, rootId: ID, maxDepth: number = Number.MAX_SAFE_INTEGER): Promise<Array<Translated<Collection>>> {
+    async getDescendants(
+        ctx: RequestContext,
+        rootId: ID,
+        maxDepth: number = Number.MAX_SAFE_INTEGER,
+    ): Promise<Array<Translated<Collection>>> {
         const getChildren = async (id: ID, _descendants: Collection[] = [], depth = 1) => {
             const children = await this.connection
                 .getRepository(Collection)
@@ -336,7 +346,7 @@ export class CollectionService implements OnModuleInit {
                     args: filter.arguments.map((inputArg, i) => {
                         return {
                             name: inputArg.name,
-                            type: match.args[inputArg.name],
+                            type: match.args[inputArg.name].type,
                             value: inputArg.value,
                         };
                     }),
@@ -363,7 +373,9 @@ export class CollectionService implements OnModuleInit {
             ...(collection.filters || []),
         ]);
         const postIds = collection.productVariants.map(v => v.id);
-        await this.connection.getRepository(Collection).save(collection, { chunk: Math.ceil(collection.productVariants.length / 500) });
+        await this.connection
+            .getRepository(Collection)
+            .save(collection, { chunk: Math.ceil(collection.productVariants.length / 500) });
 
         const preIdsSet = new Set(preIds);
         const postIdsSet = new Set(postIds);

+ 7 - 12
packages/core/src/service/services/payment-method.service.ts

@@ -1,11 +1,6 @@
 import { Injectable } from '@nestjs/common';
 import { InjectConnection } from '@nestjs/typeorm';
-import {
-    ConfigArg,
-    ConfigArgType,
-    RefundOrderInput,
-    UpdatePaymentMethodInput,
-} from '@vendure/common/lib/generated-types';
+import { ConfigArg, RefundOrderInput, UpdatePaymentMethodInput } from '@vendure/common/lib/generated-types';
 import { omit } from '@vendure/common/lib/omit';
 import { ID, PaginatedList } from '@vendure/common/lib/shared-types';
 import { assertNever } from '@vendure/common/lib/shared-utils';
@@ -201,12 +196,12 @@ export class PaymentMethodService {
         existingConfigArgs: ConfigArg[],
     ): ConfigArg[] {
         let configArgs: ConfigArg[] = [];
-        for (const [name, type] of Object.entries(handler.args)) {
+        for (const [name, def] of Object.entries(handler.args)) {
             if (!existingConfigArgs.find(ca => ca.name === name)) {
                 configArgs.push({
                     name,
-                    type,
-                    value: this.getDefaultValue(type),
+                    type: def.type,
+                    value: this.getDefaultValue(def.type),
                 });
             }
         }
@@ -216,11 +211,11 @@ export class PaymentMethodService {
 
     private getDefaultValue(type: PaymentMethodArgType): string {
         switch (type) {
-            case ConfigArgType.STRING:
+            case 'string':
                 return '';
-            case ConfigArgType.BOOLEAN:
+            case 'boolean':
                 return 'false';
-            case ConfigArgType.INT:
+            case 'int':
                 return '0';
             default:
                 assertNever(type);

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
schema-admin.json


Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
schema-shop.json


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff