@medusajs/types 1.11.0 → 1.11.1-next-20230913180203

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export type EntityDateColumns = "created_at" | "updated_at";
2
+ export type SoftDeletableEntityDateColumns = "deleted_at" | EntityDateColumns;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/dal/entity.ts"],"names":[],"mappings":""}
@@ -1,8 +1,8 @@
1
1
  import { Dictionary, FilterQuery, Order } from "./utils";
2
2
  export { FilterQuery } from "./utils";
3
3
  export interface BaseFilterable<T> {
4
- $and?: T;
5
- $or?: T;
4
+ $and?: (T | BaseFilterable<T>)[];
5
+ $or?: (T | BaseFilterable<T>)[];
6
6
  }
7
7
  export interface OptionsQuery<T, P extends string = never> {
8
8
  populate?: string[];
@@ -14,7 +14,8 @@ export interface OptionsQuery<T, P extends string = never> {
14
14
  filters?: Dictionary<boolean | Dictionary> | string[] | boolean;
15
15
  }
16
16
  export type FindOptions<T = any> = {
17
- where: FilterQuery<T>;
17
+ where: FilterQuery<T> & BaseFilterable<FilterQuery<T>>;
18
18
  options?: OptionsQuery<T, any>;
19
19
  };
20
20
  export * from "./repository-service";
21
+ export * from "./entity";
package/dist/dal/index.js CHANGED
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./repository-service"), exports);
18
+ __exportStar(require("./entity"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBA,uDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBA,uDAAoC;AACpC,2CAAwB"}
@@ -3,23 +3,53 @@ export type JoinerRelationship = {
3
3
  foreignKey: string;
4
4
  primaryKey: string;
5
5
  serviceName: string;
6
+ /**
7
+ * If true, the relationship is an internal service from the medusa core
8
+ * TODO: Remove when there are no more "internal" services
9
+ */
10
+ isInternalService?: boolean;
11
+ /**
12
+ * In an inverted relationship the foreign key is on the other service and the primary key is on the current service
13
+ */
6
14
  inverse?: boolean;
15
+ /**
16
+ * Force the relationship to return a list
17
+ */
7
18
  isList?: boolean;
19
+ /**
20
+ * Extra arguments to pass to the remoteFetchData callback
21
+ */
8
22
  args?: Record<string, any>;
9
23
  };
10
24
  export interface JoinerServiceConfigAlias {
11
25
  name: string;
26
+ /**
27
+ * Extra arguments to pass to the remoteFetchData callback
28
+ */
12
29
  args?: Record<string, any>;
13
30
  }
14
31
  export interface JoinerServiceConfig {
15
32
  serviceName: string;
33
+ /**
34
+ * Property name to use as entrypoint to the service
35
+ */
16
36
  alias?: JoinerServiceConfigAlias | JoinerServiceConfigAlias[];
37
+ /**
38
+ * alias for deeper nested relationships (e.g. { 'price': 'prices.calculated_price_set.amount' })
39
+ */
40
+ fieldAlias?: Record<string, string | {
41
+ path: string;
42
+ forwardArgumentsOnPath: string[];
43
+ }>;
17
44
  primaryKeys: string[];
18
45
  relationships?: JoinerRelationship[];
19
46
  extends?: {
20
47
  serviceName: string;
21
48
  relationship: JoinerRelationship;
22
49
  }[];
50
+ /**
51
+ * Extra arguments to pass to the remoteFetchData callback
52
+ */
23
53
  args?: Record<string, any>;
24
54
  }
25
55
  export interface JoinerArgument {
@@ -18,23 +18,34 @@ export type InternalModuleDeclaration = {
18
18
  scope: MODULE_SCOPE.INTERNAL;
19
19
  resources: MODULE_RESOURCE_TYPE;
20
20
  dependencies?: string[];
21
- /**
22
- * @deprecated The property should not be used.
23
- */
21
+ definition?: ModuleDefinition;
24
22
  resolve?: string;
25
23
  options?: Record<string, unknown>;
24
+ /**
25
+ * If multiple modules are registered with the same key, the alias can be used to differentiate them
26
+ */
26
27
  alias?: string;
28
+ /**
29
+ * If the module is the main module for the key when multiple ones are registered
30
+ */
27
31
  main?: boolean;
28
32
  };
29
33
  export type ExternalModuleDeclaration = {
30
34
  scope: MODULE_SCOPE.EXTERNAL;
35
+ definition?: ModuleDefinition;
31
36
  server?: {
32
37
  type: "http";
33
38
  url: string;
34
39
  keepAlive: boolean;
35
40
  };
36
41
  options?: Record<string, unknown>;
42
+ /**
43
+ * If multiple modules are registered with the same key, the alias can be used to differentiate them
44
+ */
37
45
  alias?: string;
46
+ /**
47
+ * If the module is the main module for the key when multiple ones are registered
48
+ */
38
49
  main?: boolean;
39
50
  };
40
51
  export type ModuleResolution = {
@@ -59,6 +70,7 @@ export type ModuleDefinition = {
59
70
  */
60
71
  isRequired?: boolean;
61
72
  isQueryable?: boolean;
73
+ isLegacy?: boolean;
62
74
  dependencies?: string[];
63
75
  defaultModuleDeclaration: InternalModuleDeclaration | ExternalModuleDeclaration;
64
76
  };
@@ -93,25 +105,54 @@ export type ModuleJoinerConfig = Omit<JoinerServiceConfig, "serviceName" | "prim
93
105
  relationships?: ModuleJoinerRelationship[];
94
106
  extends?: {
95
107
  serviceName: string;
108
+ fieldAlias?: Record<string, string | {
109
+ path: string;
110
+ forwardArgumentsOnPath: string[];
111
+ }>;
96
112
  relationship: ModuleJoinerRelationship;
97
113
  }[];
98
114
  serviceName?: string;
99
115
  primaryKeys?: string[];
116
+ /**
117
+ * If the module is a link module
118
+ */
100
119
  isLink?: boolean;
120
+ /**
121
+ * Keys that can be used to link to other modules
122
+ */
101
123
  linkableKeys?: string[];
124
+ /**
125
+ * If true it expands a RemoteQuery property but doesn't create a pivot table
126
+ */
102
127
  isReadOnlyLink?: boolean;
103
128
  databaseConfig?: {
129
+ /**
130
+ * Name of the pivot table. If not provided it is auto generated
131
+ */
104
132
  tableName?: string;
133
+ /**
134
+ * Prefix for the id column. If not provided it is "link"
135
+ */
105
136
  idPrefix?: string;
106
137
  extraFields?: Record<string, {
107
138
  type: "date" | "time" | "datetime" | "bigint" | "blob" | "uint8array" | "array" | "enumArray" | "enum" | "json" | "integer" | "smallint" | "tinyint" | "mediumint" | "float" | "double" | "boolean" | "decimal" | "string" | "uuid" | "text";
108
139
  defaultValue?: string;
109
140
  nullable?: boolean;
141
+ /**
142
+ * Mikro-orm options for the column
143
+ */
110
144
  options?: Record<string, unknown>;
111
145
  }>;
112
146
  };
113
147
  };
114
148
  export declare type ModuleJoinerRelationship = JoinerRelationship & {
149
+ /**
150
+ * If true, the relationship is an internal service from the medusa core TODO: Remove when there are no more "internal" services
151
+ */
152
+ isInternalService?: boolean;
153
+ /**
154
+ * If true, the link joiner will cascade deleting the relationship
155
+ */
115
156
  deleteCascade?: boolean;
116
157
  };
117
158
  export type ModuleExports = {
@@ -137,6 +178,7 @@ export interface ModuleServiceInitializeOptions {
137
178
  database?: string;
138
179
  driverOptions?: Record<string, unknown>;
139
180
  debug?: boolean;
181
+ pool?: Record<string, unknown>;
140
182
  };
141
183
  }
142
184
  export type ModuleServiceInitializeCustomDataLayerOptions = {
@@ -1,2 +1,3 @@
1
1
  export * from "./currency";
2
2
  export * from "./money-amount";
3
+ export * from "./price-set";
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./currency"), exports);
18
18
  __exportStar(require("./money-amount"), exports);
19
+ __exportStar(require("./price-set"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pricing/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,iDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pricing/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,iDAA8B;AAC9B,8CAA2B"}
@@ -0,0 +1,31 @@
1
+ import { BaseFilterable } from "../../dal";
2
+ import { FilterableMoneyAmountProps, MoneyAmountDTO } from "./money-amount";
3
+ export interface PricingContext {
4
+ context?: {
5
+ currency_code?: string;
6
+ };
7
+ }
8
+ export interface PricingFilters {
9
+ id: string[];
10
+ }
11
+ export interface PriceSetDTO {
12
+ id: string;
13
+ money_amounts?: MoneyAmountDTO[];
14
+ }
15
+ export interface CalculatedPriceSetDTO {
16
+ id: string;
17
+ amount: number | null;
18
+ currency_code: string | null;
19
+ min_quantity: number | null;
20
+ max_quantity: number | null;
21
+ }
22
+ export interface CreatePriceSetDTO {
23
+ money_amounts?: MoneyAmountDTO[];
24
+ }
25
+ export interface UpdatePriceSetDTO {
26
+ id: string;
27
+ }
28
+ export interface FilterablePriceSetProps extends BaseFilterable<FilterablePriceSetProps> {
29
+ id?: string[];
30
+ money_amounts?: FilterableMoneyAmountProps;
31
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=price-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-set.js","sourceRoot":"","sources":["../../../src/pricing/common/price-set.ts"],"names":[],"mappings":""}
@@ -1,15 +1,22 @@
1
1
  import { FindConfig } from "../common";
2
2
  import { ModuleJoinerConfig } from "../modules-sdk";
3
3
  import { Context } from "../shared-context";
4
- import { CreateCurrencyDTO, CreateMoneyAmountDTO, CurrencyDTO, FilterableCurrencyProps, FilterableMoneyAmountProps, MoneyAmountDTO, UpdateCurrencyDTO, UpdateMoneyAmountDTO } from "./common";
4
+ import { CalculatedPriceSetDTO, CreateCurrencyDTO, CreateMoneyAmountDTO, CreatePriceSetDTO, CurrencyDTO, FilterableCurrencyProps, FilterableMoneyAmountProps, FilterablePriceSetProps, MoneyAmountDTO, PriceSetDTO, PricingContext, PricingFilters, UpdateCurrencyDTO, UpdateMoneyAmountDTO, UpdatePriceSetDTO } from "./common";
5
5
  export interface IPricingModuleService {
6
6
  __joinerConfig(): ModuleJoinerConfig;
7
- retrieve(id: string, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context): Promise<MoneyAmountDTO>;
8
- list(filters?: FilterableMoneyAmountProps, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context): Promise<MoneyAmountDTO[]>;
9
- listAndCount(filters?: FilterableMoneyAmountProps, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context): Promise<[MoneyAmountDTO[], number]>;
10
- create(data: CreateMoneyAmountDTO[], sharedContext?: Context): Promise<MoneyAmountDTO[]>;
11
- update(data: UpdateMoneyAmountDTO[], sharedContext?: Context): Promise<MoneyAmountDTO[]>;
7
+ calculatePrices(filters: PricingFilters, context?: PricingContext, sharedContext?: Context): Promise<CalculatedPriceSetDTO>;
8
+ retrieve(id: string, config?: FindConfig<PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO>;
9
+ list(filters?: FilterablePriceSetProps, config?: FindConfig<PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO[]>;
10
+ listAndCount(filters?: FilterablePriceSetProps, config?: FindConfig<PriceSetDTO>, sharedContext?: Context): Promise<[PriceSetDTO[], number]>;
11
+ create(data: CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
12
+ update(data: UpdatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
12
13
  delete(ids: string[], sharedContext?: Context): Promise<void>;
14
+ retrieveMoneyAmount(id: string, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context): Promise<MoneyAmountDTO>;
15
+ listMoneyAmounts(filters?: FilterableMoneyAmountProps, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context): Promise<MoneyAmountDTO[]>;
16
+ listAndCountMoneyAmounts(filters?: FilterableMoneyAmountProps, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context): Promise<[MoneyAmountDTO[], number]>;
17
+ createMoneyAmounts(data: CreateMoneyAmountDTO[], sharedContext?: Context): Promise<MoneyAmountDTO[]>;
18
+ updateMoneyAmounts(data: UpdateMoneyAmountDTO[], sharedContext?: Context): Promise<MoneyAmountDTO[]>;
19
+ deleteMoneyAmounts(ids: string[], sharedContext?: Context): Promise<void>;
13
20
  retrieveCurrency(code: string, config?: FindConfig<CurrencyDTO>, sharedContext?: Context): Promise<CurrencyDTO>;
14
21
  listCurrencies(filters?: FilterableCurrencyProps, config?: FindConfig<CurrencyDTO>, sharedContext?: Context): Promise<CurrencyDTO[]>;
15
22
  listAndCountCurrencies(filters?: FilterableCurrencyProps, config?: FindConfig<CurrencyDTO>, sharedContext?: Context): Promise<[CurrencyDTO[], number]>;
@@ -142,6 +142,7 @@ export interface ProductOptionValueDTO {
142
142
  * Filters/Config (module API input filters and config)
143
143
  */
144
144
  export interface FilterableProductProps extends BaseFilterable<FilterableProductProps> {
145
+ q?: string;
145
146
  handle?: string | string[];
146
147
  id?: string | string[];
147
148
  tags?: {
@@ -149,6 +150,8 @@ export interface FilterableProductProps extends BaseFilterable<FilterableProduct
149
150
  };
150
151
  categories?: {
151
152
  id?: string | string[] | OperatorMap<string>;
153
+ is_internal?: boolean;
154
+ is_active?: boolean;
152
155
  };
153
156
  category_id?: string | string[] | OperatorMap<string>;
154
157
  collection_id?: string | string[] | OperatorMap<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/types",
3
- "version": "1.11.0",
3
+ "version": "1.11.1-next-20230913180203",
4
4
  "description": "Medusa Types definition",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",