@medusajs/types 1.8.7 → 1.8.8-beta-20230619170349

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.
package/dist/bundles.d.ts CHANGED
@@ -2,7 +2,9 @@ export * as CacheTypes from "./cache";
2
2
  export * as CommonTypes from "./common";
3
3
  export * as EventBusTypes from "./event-bus";
4
4
  export * as InventoryTypes from "./inventory";
5
+ export * as ProductTypes from "./product";
5
6
  export * as ModulesSdkTypes from "./modules-sdk";
6
7
  export * as SearchTypes from "./search";
7
8
  export * as StockLocationTypes from "./stock-location";
8
9
  export * as TransactionBaseTypes from "./transaction-base";
10
+ export * as DAL from "./dal";
package/dist/bundles.js CHANGED
@@ -23,13 +23,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.TransactionBaseTypes = exports.StockLocationTypes = exports.SearchTypes = exports.ModulesSdkTypes = exports.InventoryTypes = exports.EventBusTypes = exports.CommonTypes = exports.CacheTypes = void 0;
26
+ exports.DAL = exports.TransactionBaseTypes = exports.StockLocationTypes = exports.SearchTypes = exports.ModulesSdkTypes = exports.ProductTypes = exports.InventoryTypes = exports.EventBusTypes = exports.CommonTypes = exports.CacheTypes = void 0;
27
27
  exports.CacheTypes = __importStar(require("./cache"));
28
28
  exports.CommonTypes = __importStar(require("./common"));
29
29
  exports.EventBusTypes = __importStar(require("./event-bus"));
30
30
  exports.InventoryTypes = __importStar(require("./inventory"));
31
+ exports.ProductTypes = __importStar(require("./product"));
31
32
  exports.ModulesSdkTypes = __importStar(require("./modules-sdk"));
32
33
  exports.SearchTypes = __importStar(require("./search"));
33
34
  exports.StockLocationTypes = __importStar(require("./stock-location"));
34
35
  exports.TransactionBaseTypes = __importStar(require("./transaction-base"));
36
+ exports.DAL = __importStar(require("./dal"));
35
37
  //# sourceMappingURL=bundles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundles.js","sourceRoot":"","sources":["../src/bundles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAqC;AACrC,wDAAuC;AACvC,6DAA4C;AAC5C,8DAA6C;AAC7C,iEAAgD;AAChD,wDAAuC;AACvC,uEAAsD;AACtD,2EAA0D"}
1
+ {"version":3,"file":"bundles.js","sourceRoot":"","sources":["../src/bundles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAqC;AACrC,wDAAuC;AACvC,6DAA4C;AAC5C,8DAA6C;AAC7C,0DAAyC;AACzC,iEAAgD;AAChD,wDAAuC;AACvC,uEAAsD;AACtD,2EAA0D;AAC1D,6CAA4B"}
@@ -4,10 +4,10 @@ import { FindOptionsRelations } from "typeorm/find-options/FindOptionsRelations"
4
4
  /**
5
5
  * Utility type used to remove some optional attributes (coming from K) from a type T
6
6
  */
7
- export declare type WithRequiredProperty<T, K extends keyof T> = T & {
7
+ export type WithRequiredProperty<T, K extends keyof T> = T & {
8
8
  [Property in K]-?: T[Property];
9
9
  };
10
- export declare type PartialPick<T, K extends keyof T> = {
10
+ export type PartialPick<T, K extends keyof T> = {
11
11
  [P in K]?: T[P];
12
12
  };
13
13
  export interface BaseEntity {
@@ -18,7 +18,7 @@ export interface BaseEntity {
18
18
  export interface SoftDeletableEntity extends BaseEntity {
19
19
  deleted_at: Date | null;
20
20
  }
21
- export declare type Writable<T> = {
21
+ export type Writable<T> = {
22
22
  -readonly [key in keyof T]: T[key] | FindOperator<T[key]> | FindOperator<T[key][]> | FindOperator<string[]>;
23
23
  };
24
24
  export interface FindConfig<Entity> {
@@ -30,7 +30,7 @@ export interface FindConfig<Entity> {
30
30
  [K: string]: "ASC" | "DESC";
31
31
  };
32
32
  }
33
- export declare type ExtendedFindConfig<TEntity> = (Omit<FindOneOptions<TEntity>, "where" | "relations" | "select"> | Omit<FindManyOptions<TEntity>, "where" | "relations" | "select">) & {
33
+ export type ExtendedFindConfig<TEntity> = (Omit<FindOneOptions<TEntity>, "where" | "relations" | "select"> | Omit<FindManyOptions<TEntity>, "where" | "relations" | "select">) & {
34
34
  select?: FindOptionsSelect<TEntity>;
35
35
  relations?: FindOptionsRelations<TEntity>;
36
36
  where: FindOptionsWhere<TEntity> | FindOptionsWhere<TEntity>[];
@@ -38,16 +38,16 @@ export declare type ExtendedFindConfig<TEntity> = (Omit<FindOneOptions<TEntity>,
38
38
  skip?: number;
39
39
  take?: number;
40
40
  };
41
- export declare type QuerySelector<TEntity> = Selector<TEntity> & {
41
+ export type QuerySelector<TEntity> = Selector<TEntity> & {
42
42
  q?: string;
43
43
  };
44
- export declare type TreeQuerySelector<TEntity> = QuerySelector<TEntity> & {
44
+ export type TreeQuerySelector<TEntity> = QuerySelector<TEntity> & {
45
45
  include_descendants_tree?: boolean;
46
46
  };
47
- export declare type Selector<TEntity> = {
47
+ export type Selector<TEntity> = {
48
48
  [key in keyof TEntity]?: TEntity[key] | TEntity[key][] | DateComparisonOperator | StringComparisonOperator | NumericalComparisonOperator | FindOperator<TEntity[key][] | string | string[]>;
49
49
  };
50
- export declare type TotalField = "shipping_total" | "discount_total" | "tax_total" | "refunded_total" | "total" | "subtotal" | "refundable_amount" | "gift_card_total" | "gift_card_tax_total";
50
+ export type TotalField = "shipping_total" | "discount_total" | "tax_total" | "refunded_total" | "total" | "subtotal" | "refundable_amount" | "gift_card_total" | "gift_card_tax_total";
51
51
  export interface CustomFindOptions<TModel, InKeys extends keyof TModel> {
52
52
  select?: FindManyOptions<TModel>["select"];
53
53
  where?: FindManyOptions<TModel>["where"] & {
@@ -57,7 +57,7 @@ export interface CustomFindOptions<TModel, InKeys extends keyof TModel> {
57
57
  skip?: number;
58
58
  take?: number;
59
59
  }
60
- export declare type QueryConfig<TEntity extends BaseEntity> = {
60
+ export type QueryConfig<TEntity extends BaseEntity> = {
61
61
  defaultFields?: (keyof TEntity | string)[];
62
62
  defaultRelations?: string[];
63
63
  allowedFields?: string[];
@@ -65,25 +65,27 @@ export declare type QueryConfig<TEntity extends BaseEntity> = {
65
65
  defaultLimit?: number;
66
66
  isList?: boolean;
67
67
  };
68
- export declare type RequestQueryFields = {
68
+ export type RequestQueryFields = {
69
69
  expand?: string;
70
70
  fields?: string;
71
71
  offset?: number;
72
72
  limit?: number;
73
73
  order?: string;
74
74
  };
75
- export declare type PaginatedResponse = {
75
+ export type PaginatedResponse = {
76
76
  limit: number;
77
77
  offset: number;
78
78
  count: number;
79
79
  };
80
- export declare type DeleteResponse = {
80
+ export type DeleteResponse = {
81
81
  id: string;
82
82
  object: string;
83
83
  deleted: boolean;
84
84
  };
85
85
  export interface EmptyQueryParams {
86
86
  }
87
+ export interface RepositoryTransformOptions {
88
+ }
87
89
  export interface DateComparisonOperator {
88
90
  lt?: Date;
89
91
  gt?: Date;
@@ -1,7 +1,7 @@
1
1
  import { RedisOptions } from "ioredis";
2
2
  import { LoggerOptions } from "typeorm";
3
3
  import { ExternalModuleDeclaration, InternalModuleDeclaration } from "../modules-sdk";
4
- declare type SessionOptions = {
4
+ type SessionOptions = {
5
5
  name?: string;
6
6
  resave?: boolean;
7
7
  rolling?: boolean;
@@ -9,14 +9,15 @@ declare type SessionOptions = {
9
9
  secret?: string;
10
10
  ttl?: number;
11
11
  };
12
- export declare type HttpCompressionOptions = {
12
+ export type HttpCompressionOptions = {
13
13
  enabled?: boolean;
14
14
  level?: number;
15
15
  memLevel?: number;
16
16
  threshold?: number | string;
17
17
  };
18
- export declare type ProjectConfigOptions = {
18
+ export type ProjectConfigOptions = {
19
19
  redis_url?: string;
20
+ redis_prefix?: string;
20
21
  redis_options?: RedisOptions;
21
22
  session_options?: SessionOptions;
22
23
  jwt_secret?: string;
@@ -35,7 +36,7 @@ export declare type ProjectConfigOptions = {
35
36
  store_cors?: string;
36
37
  admin_cors?: string;
37
38
  };
38
- export declare type ConfigModule = {
39
+ export type ConfigModule = {
39
40
  projectConfig: ProjectConfigOptions;
40
41
  featureFlags: Record<string, boolean | string>;
41
42
  modules?: Record<string, false | string | Partial<InternalModuleDeclaration | ExternalModuleDeclaration>>;
@@ -1,5 +1,5 @@
1
1
  import { AwilixContainer } from "awilix";
2
- export declare type MedusaContainer = AwilixContainer & {
2
+ export type MedusaContainer = AwilixContainer & {
3
3
  registerAdd: <T>(name: string, registration: T) => MedusaContainer;
4
4
  createScope: () => MedusaContainer;
5
5
  };
@@ -1,58 +1,9 @@
1
- /// <reference types="node" />
2
- declare type Dictionary<T = any> = {
3
- [k: string]: T;
4
- };
5
- declare type Query<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>;
6
- declare type EntityProps<T> = {
7
- -readonly [K in keyof T as ExcludeFunctions<T, K>]?: T[K];
8
- };
9
- declare type ExpandScalar<T> = null | (T extends string ? string | RegExp : T extends Date ? Date | string : T);
10
- declare type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Buffer | {
11
- toHexString(): string;
12
- };
13
- declare type ExcludeFunctions<T, K extends keyof T> = T[K] extends Function ? never : K extends symbol ? never : K;
14
- declare type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T;
15
- declare const PrimaryKeyType: unique symbol;
16
- declare type Primary<T> = T extends {
17
- [PrimaryKeyType]?: infer PK;
18
- } ? ReadonlyPrimary<PK> : T extends {
19
- _id?: infer PK;
20
- } ? ReadonlyPrimary<PK> | string : T extends {
21
- uuid?: infer PK;
22
- } ? ReadonlyPrimary<PK> : T extends {
23
- id?: infer PK;
24
- } ? ReadonlyPrimary<PK> : never;
25
- export declare type OperatorMap<T> = {
26
- $and?: Query<T>[];
27
- $or?: Query<T>[];
28
- $eq?: ExpandScalar<T> | ExpandScalar<T>[];
29
- $ne?: ExpandScalar<T>;
30
- $in?: ExpandScalar<T>[];
31
- $nin?: ExpandScalar<T>[];
32
- $not?: Query<T>;
33
- $gt?: ExpandScalar<T>;
34
- $gte?: ExpandScalar<T>;
35
- $lt?: ExpandScalar<T>;
36
- $lte?: ExpandScalar<T>;
37
- $like?: string;
38
- $re?: string;
39
- $ilike?: string;
40
- $fulltext?: string;
41
- $overlap?: string[];
42
- $contains?: string[];
43
- $contained?: string[];
44
- $exists?: boolean;
45
- };
46
- declare type FilterValue2<T> = T | ExpandScalar<T> | Primary<T>;
47
- declare type FilterValue<T> = OperatorMap<FilterValue2<T>> | FilterValue2<T> | FilterValue2<T>[] | null;
48
- declare type ExpandObject<T> = T extends object ? T extends Scalar ? never : {
49
- -readonly [K in keyof T as ExcludeFunctions<T, K>]?: Query<any> | FilterValue<any> | null;
50
- } : never;
51
- declare type ObjectQuery<T> = ExpandObject<T> & OperatorMap<T>;
52
- export declare type FilterQuery<T> = ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T>>> | NonNullable<EntityProps<T> & OperatorMap<T>> | FilterQuery<T>[];
53
- declare type Order<T> = {
54
- [key in keyof T]?: "ASC" | "DESC" | Order<T[key] extends Array<any> ? T[key][0] : T[key]>;
55
- };
1
+ import { Dictionary, FilterQuery, Order } from "./utils";
2
+ export { FilterQuery } from "./utils";
3
+ export interface BaseFilterable<T> {
4
+ $and?: T;
5
+ $or?: T;
6
+ }
56
7
  export interface OptionsQuery<T, P extends string = never> {
57
8
  populate?: string[];
58
9
  orderBy?: Order<T> | Order<T>[];
@@ -62,7 +13,7 @@ export interface OptionsQuery<T, P extends string = never> {
62
13
  groupBy?: string | string[];
63
14
  filters?: Dictionary<boolean | Dictionary> | string[] | boolean;
64
15
  }
65
- export declare type FindOptions<T> = {
16
+ export type FindOptions<T = any> = {
66
17
  where: FilterQuery<T>;
67
18
  options?: OptionsQuery<T, any>;
68
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+IA,uDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBA,uDAAoC"}
@@ -1,10 +1,11 @@
1
1
  import { FindOptions } from "./index";
2
+ import { RepositoryTransformOptions } from "../common";
2
3
  /**
3
4
  * Data access layer (DAL) interface to implements for any repository service.
4
5
  * This layer helps to separate the business logic (service layer) from accessing the
5
6
  * ORM directly and allows to switch to another ORM without changing the business logic.
6
7
  */
7
- export interface RepositoryService<S = any> {
8
- find<T = S>(options?: FindOptions<T>): Promise<T[]>;
9
- findAndCount<T = S>(options?: FindOptions<T>): Promise<[T[], number]>;
8
+ export interface RepositoryService<T = any> {
9
+ find(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions): Promise<T[]>;
10
+ findAndCount(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions): Promise<[T[], number]>;
10
11
  }
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ export type Dictionary<T = any> = {
3
+ [k: string]: T;
4
+ };
5
+ type Query<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>;
6
+ type ExpandScalar<T> = null | (T extends string ? string | RegExp : T extends Date ? Date | string : T);
7
+ type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Buffer | {
8
+ toHexString(): string;
9
+ };
10
+ type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T;
11
+ declare const PrimaryKeyType: unique symbol;
12
+ type Primary<T> = T extends {
13
+ [PrimaryKeyType]?: infer PK;
14
+ } ? ReadonlyPrimary<PK> : T extends {
15
+ _id?: infer PK;
16
+ } ? ReadonlyPrimary<PK> | string : T extends {
17
+ uuid?: infer PK;
18
+ } ? ReadonlyPrimary<PK> : T extends {
19
+ id?: infer PK;
20
+ } ? ReadonlyPrimary<PK> : never;
21
+ export type OperatorMap<T> = {
22
+ $and?: Query<T>[];
23
+ $or?: Query<T>[];
24
+ $eq?: ExpandScalar<T> | ExpandScalar<T>[];
25
+ $ne?: ExpandScalar<T>;
26
+ $in?: ExpandScalar<T>[];
27
+ $nin?: ExpandScalar<T>[];
28
+ $not?: Query<T>;
29
+ $gt?: ExpandScalar<T>;
30
+ $gte?: ExpandScalar<T>;
31
+ $lt?: ExpandScalar<T>;
32
+ $lte?: ExpandScalar<T>;
33
+ $like?: string;
34
+ $re?: string;
35
+ $ilike?: string;
36
+ $fulltext?: string;
37
+ $overlap?: string[];
38
+ $contains?: string[];
39
+ $contained?: string[];
40
+ $exists?: boolean;
41
+ };
42
+ type FilterValue2<T> = T | ExpandScalar<T> | Primary<T>;
43
+ type FilterValue<T> = OperatorMap<FilterValue2<T>> | FilterValue2<T> | FilterValue2<T>[] | null;
44
+ type PrevLimit = [never, 1, 2, 3];
45
+ export type FilterQuery<T = any, Prev extends number = 3> = Prev extends never ? never : {
46
+ [Key in keyof T]?: T[Key] extends boolean | number | string | bigint | symbol | Date ? T[Key] | OperatorMap<T[Key]> : T[Key] extends infer U ? U extends {
47
+ [x: number]: infer V;
48
+ } ? V extends object ? FilterQuery<Partial<V>, PrevLimit[Prev]> : never : never : never;
49
+ };
50
+ export type Order<T> = {
51
+ [key in keyof T]?: "ASC" | "DESC" | Order<T[key] extends Array<any> ? T[key][0] : T[key]>;
52
+ };
53
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/dal/utils.ts"],"names":[],"mappings":""}
@@ -1,13 +1,13 @@
1
- export declare type Subscriber<T = unknown> = (data: T, eventName: string) => Promise<void>;
2
- export declare type SubscriberContext = {
1
+ export type Subscriber<T = unknown> = (data: T, eventName: string) => Promise<void>;
2
+ export type SubscriberContext = {
3
3
  subscriberId: string;
4
4
  };
5
- export declare type SubscriberDescriptor = {
5
+ export type SubscriberDescriptor = {
6
6
  id: string;
7
7
  subscriber: Subscriber;
8
8
  };
9
- export declare type EventHandler<T = unknown> = (data: T, eventName: string) => Promise<void>;
10
- export declare type EmitData<T = unknown> = {
9
+ export type EventHandler<T = unknown> = (data: T, eventName: string) => Promise<void>;
10
+ export type EmitData<T = unknown> = {
11
11
  eventName: string;
12
12
  data: T;
13
13
  options?: Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,10 @@ export * from "./common";
4
4
  export * from "./event-bus";
5
5
  export * from "./inventory";
6
6
  export * from "./modules-sdk";
7
+ export * from "./product";
8
+ export * from "./product-category";
7
9
  export * from "./search";
8
10
  export * from "./shared-context";
9
11
  export * from "./stock-location";
10
12
  export * from "./transaction-base";
13
+ export * from "./dal";
package/dist/index.js CHANGED
@@ -20,8 +20,11 @@ __exportStar(require("./common"), exports);
20
20
  __exportStar(require("./event-bus"), exports);
21
21
  __exportStar(require("./inventory"), exports);
22
22
  __exportStar(require("./modules-sdk"), exports);
23
+ __exportStar(require("./product"), exports);
24
+ __exportStar(require("./product-category"), exports);
23
25
  __exportStar(require("./search"), exports);
24
26
  __exportStar(require("./shared-context"), exports);
25
27
  __exportStar(require("./stock-location"), exports);
26
28
  __exportStar(require("./transaction-base"), exports);
29
+ __exportStar(require("./dal"), exports);
27
30
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,0CAAuB;AACvB,2CAAwB;AACxB,8CAA2B;AAC3B,8CAA2B;AAC3B,gDAA6B;AAC7B,2CAAwB;AACxB,mDAAgC;AAChC,mDAAgC;AAChC,qDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,0CAAuB;AACvB,2CAAwB;AACxB,8CAA2B;AAC3B,8CAA2B;AAC3B,gDAA6B;AAC7B,4CAAyB;AACzB,qDAAkC;AAClC,2CAAwB;AACxB,mDAAgC;AAChC,mDAAgC;AAChC,qDAAkC;AAClC,wCAAqB"}
@@ -61,7 +61,7 @@ import { NumericalComparisonOperator, StringComparisonOperator } from "../common
61
61
  * description: "The date with timezone at which the resource was deleted."
62
62
  * format: date-time
63
63
  */
64
- export declare type InventoryItemDTO = {
64
+ export type InventoryItemDTO = {
65
65
  id: string;
66
66
  sku?: string | null;
67
67
  origin_country?: string | null;
@@ -127,7 +127,7 @@ export declare type InventoryItemDTO = {
127
127
  * description: "The date with timezone at which the resource was deleted."
128
128
  * format: date-time
129
129
  */
130
- export declare type ReservationItemDTO = {
130
+ export type ReservationItemDTO = {
131
131
  id: string;
132
132
  location_id: string;
133
133
  inventory_item_id: string;
@@ -179,7 +179,7 @@ export declare type ReservationItemDTO = {
179
179
  * description: "The date with timezone at which the resource was deleted."
180
180
  * format: date-time
181
181
  */
182
- export declare type InventoryLevelDTO = {
182
+ export type InventoryLevelDTO = {
183
183
  id: string;
184
184
  inventory_item_id: string;
185
185
  location_id: string;
@@ -191,7 +191,7 @@ export declare type InventoryLevelDTO = {
191
191
  updated_at: string | Date;
192
192
  deleted_at: string | Date | null;
193
193
  };
194
- export declare type FilterableReservationItemProps = {
194
+ export type FilterableReservationItemProps = {
195
195
  id?: string | string[];
196
196
  type?: string | string[];
197
197
  line_item_id?: string | string[];
@@ -201,7 +201,7 @@ export declare type FilterableReservationItemProps = {
201
201
  created_by?: string | string[];
202
202
  quantity?: number | NumericalComparisonOperator;
203
203
  };
204
- export declare type FilterableInventoryItemProps = {
204
+ export type FilterableInventoryItemProps = {
205
205
  id?: string | string[];
206
206
  location_id?: string | string[];
207
207
  q?: string;
@@ -210,7 +210,7 @@ export declare type FilterableInventoryItemProps = {
210
210
  hs_code?: string | string[] | StringComparisonOperator;
211
211
  requires_shipping?: boolean;
212
212
  };
213
- export declare type CreateInventoryItemInput = {
213
+ export type CreateInventoryItemInput = {
214
214
  sku?: string;
215
215
  origin_country?: string;
216
216
  mid_code?: string;
@@ -226,7 +226,7 @@ export declare type CreateInventoryItemInput = {
226
226
  hs_code?: string;
227
227
  requires_shipping?: boolean;
228
228
  };
229
- export declare type CreateReservationItemInput = {
229
+ export type CreateReservationItemInput = {
230
230
  line_item_id?: string;
231
231
  inventory_item_id: string;
232
232
  location_id: string;
@@ -236,31 +236,31 @@ export declare type CreateReservationItemInput = {
236
236
  external_id?: string;
237
237
  metadata?: Record<string, unknown> | null;
238
238
  };
239
- export declare type FilterableInventoryLevelProps = {
239
+ export type FilterableInventoryLevelProps = {
240
240
  inventory_item_id?: string | string[];
241
241
  location_id?: string | string[];
242
242
  stocked_quantity?: number | NumericalComparisonOperator;
243
243
  reserved_quantity?: number | NumericalComparisonOperator;
244
244
  incoming_quantity?: number | NumericalComparisonOperator;
245
245
  };
246
- export declare type CreateInventoryLevelInput = {
246
+ export type CreateInventoryLevelInput = {
247
247
  inventory_item_id: string;
248
248
  location_id: string;
249
249
  stocked_quantity: number;
250
250
  reserved_quantity?: number;
251
251
  incoming_quantity?: number;
252
252
  };
253
- export declare type UpdateInventoryLevelInput = {
253
+ export type UpdateInventoryLevelInput = {
254
254
  stocked_quantity?: number;
255
255
  incoming_quantity?: number;
256
256
  };
257
- export declare type UpdateReservationItemInput = {
257
+ export type UpdateReservationItemInput = {
258
258
  quantity?: number;
259
259
  location_id?: string;
260
260
  description?: string;
261
261
  metadata?: Record<string, unknown> | null;
262
262
  };
263
- export declare type ReserveQuantityContext = {
263
+ export type ReserveQuantityContext = {
264
264
  locationId?: string;
265
265
  lineItemId?: string;
266
266
  salesChannelId?: string | null;
@@ -14,7 +14,7 @@ export interface IInventoryService {
14
14
  updateInventoryLevel(inventoryItemId: string, locationId: string, update: UpdateInventoryLevelInput, context?: SharedContext): Promise<InventoryLevelDTO>;
15
15
  updateInventoryItem(inventoryItemId: string, input: CreateInventoryItemInput, context?: SharedContext): Promise<InventoryItemDTO>;
16
16
  updateReservationItem(reservationItemId: string, input: UpdateReservationItemInput, context?: SharedContext): Promise<ReservationItemDTO>;
17
- deleteReservationItemsByLineItem(lineItemId: string, context?: SharedContext): Promise<void>;
17
+ deleteReservationItemsByLineItem(lineItemId: string | string[], context?: SharedContext): Promise<void>;
18
18
  deleteReservationItem(reservationItemId: string | string[], context?: SharedContext): Promise<void>;
19
19
  deleteInventoryItem(inventoryItemId: string, context?: SharedContext): Promise<void>;
20
20
  deleteInventoryItemLevelByLocationId(locationId: string, context?: SharedContext): Promise<void>;
@@ -1,10 +1,10 @@
1
1
  import { Logger as _Logger } from "winston";
2
2
  import { MedusaContainer } from "../common/medusa-container";
3
- export declare type Constructor<T> = new (...args: any[]) => T;
3
+ export type Constructor<T> = new (...args: any[]) => T;
4
4
  export * from "../common/medusa-container";
5
- export declare type LogLevel = "query" | "schema" | "error" | "warn" | "info" | "log" | "migration";
6
- export declare type LoggerOptions = boolean | "all" | LogLevel[];
7
- export declare type Logger = _Logger & {
5
+ export type LogLevel = "query" | "schema" | "error" | "warn" | "info" | "log" | "migration";
6
+ export type LoggerOptions = boolean | "all" | LogLevel[];
7
+ export type Logger = _Logger & {
8
8
  progress: (activityId: string, msg: string) => void;
9
9
  info: (msg: string) => void;
10
10
  warn: (msg: string) => void;
@@ -17,29 +17,30 @@ export declare enum MODULE_RESOURCE_TYPE {
17
17
  SHARED = "shared",
18
18
  ISOLATED = "isolated"
19
19
  }
20
- export declare type InternalModuleDeclaration = {
20
+ export type InternalModuleDeclaration = {
21
21
  scope: MODULE_SCOPE.INTERNAL;
22
22
  resources: MODULE_RESOURCE_TYPE;
23
23
  dependencies?: string[];
24
24
  resolve?: string;
25
25
  options?: Record<string, unknown>;
26
26
  };
27
- export declare type ExternalModuleDeclaration = {
27
+ export type ExternalModuleDeclaration = {
28
28
  scope: MODULE_SCOPE.EXTERNAL;
29
- server: {
29
+ server?: {
30
30
  type: "http";
31
31
  url: string;
32
32
  keepAlive: boolean;
33
33
  };
34
34
  };
35
- export declare type ModuleResolution = {
35
+ export type ModuleResolution = {
36
36
  resolutionPath: string | false;
37
37
  definition: ModuleDefinition;
38
38
  options?: Record<string, unknown>;
39
39
  dependencies?: string[];
40
40
  moduleDeclaration?: InternalModuleDeclaration | ExternalModuleDeclaration;
41
+ moduleExports?: ModuleExports;
41
42
  };
42
- export declare type ModuleDefinition = {
43
+ export type ModuleDefinition = {
43
44
  key: string;
44
45
  registrationName: string;
45
46
  defaultPackage: string | false;
@@ -49,17 +50,17 @@ export declare type ModuleDefinition = {
49
50
  dependencies?: string[];
50
51
  defaultModuleDeclaration: InternalModuleDeclaration | ExternalModuleDeclaration;
51
52
  };
52
- export declare type LoaderOptions<TOptions = Record<string, unknown>> = {
53
+ export type LoaderOptions<TOptions = Record<string, unknown>> = {
53
54
  container: MedusaContainer;
54
55
  options?: TOptions;
55
56
  logger?: Logger;
56
57
  };
57
- export declare type ModuleLoaderFunction = (options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
58
- export declare type ModulesResponse = {
58
+ export type ModuleLoaderFunction = (options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
59
+ export type ModulesResponse = {
59
60
  module: string;
60
61
  resolution: string | false;
61
62
  }[];
62
- export declare type ModuleExports = {
63
+ export type ModuleExports = {
63
64
  service: Constructor<any>;
64
65
  loaders?: ModuleLoaderFunction[];
65
66
  migrations?: any[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules-sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,6DAA0C;AAkB1C,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;AACvB,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAED,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,6CAAqB,CAAA;AACvB,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules-sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,6DAA0C;AAkB1C,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;AACvB,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAED,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,6CAAqB,CAAA;AACvB,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B"}
@@ -1,4 +1,5 @@
1
- import { OperatorMap } from "../dal";
1
+ import { BaseFilterable } from "../dal";
2
+ import { OperatorMap } from "../dal/utils";
2
3
  export declare enum ProductStatus {
3
4
  DRAFT = "draft",
4
5
  PROPOSED = "proposed",
@@ -24,10 +25,11 @@ export interface ProductDTO {
24
25
  hs_code?: string | null;
25
26
  mid_code?: string | null;
26
27
  material?: string | null;
27
- collection?: any;
28
- categories?: any;
29
- type: any;
30
- tags: any;
28
+ collection: ProductCollectionDTO;
29
+ categories?: ProductCategoryDTO[] | null;
30
+ type: ProductTypeDTO[];
31
+ tags: ProductTagDTO[];
32
+ variants: ProductVariantDTO[];
31
33
  options: ProductOptionDTO[];
32
34
  discountable?: boolean;
33
35
  external_id?: string | null;
@@ -61,21 +63,45 @@ export interface ProductVariantDTO {
61
63
  updated_at: string | Date;
62
64
  deleted_at: string | Date;
63
65
  }
64
- export interface ProductTagDTO {
66
+ export interface ProductCategoryDTO {
65
67
  id: string;
68
+ name: string;
69
+ description?: string;
70
+ handle?: string;
71
+ is_active?: boolean;
72
+ is_internal?: boolean;
73
+ rank?: number;
74
+ parent_category?: ProductCategoryDTO;
75
+ category_children: ProductCategoryDTO[];
76
+ created_at: string | Date;
77
+ updated_at: string | Date;
66
78
  }
67
- export interface ProductVariantDTO {
79
+ export interface ProductTagDTO {
68
80
  id: string;
81
+ value: string;
82
+ metadata?: Record<string, unknown> | null;
83
+ products: ProductDTO[];
69
84
  }
70
85
  export interface ProductCollectionDTO {
71
86
  id: string;
87
+ title: string;
88
+ handle: string;
89
+ metadata?: Record<string, unknown> | null;
90
+ deleted_at?: string | Date;
91
+ }
92
+ export interface ProductTypeDTO {
93
+ id: string;
94
+ value: string;
95
+ metadata?: Record<string, unknown> | null;
96
+ deleted_at?: string | Date;
72
97
  }
73
98
  export interface ProductOptionDTO {
74
99
  id: string;
75
100
  title: string;
76
101
  product: ProductDTO;
77
- values: ProductOptionValueDTO;
102
+ values: ProductOptionValueDTO[];
78
103
  metadata?: Record<string, unknown> | null;
104
+ deleted_at?: string | Date;
79
105
  }
80
106
  export interface ProductOptionValueDTO {
81
107
  id: string;
@@ -83,33 +109,42 @@ export interface ProductOptionValueDTO {
83
109
  option: ProductOptionDTO;
84
110
  variant: ProductVariantDTO;
85
111
  metadata?: Record<string, unknown> | null;
112
+ deleted_at?: string | Date;
86
113
  }
87
114
  /**
88
115
  * Filters/Config (module API input filters and config)
89
116
  */
90
- export interface FilterableProductProps {
117
+ export interface FilterableProductProps extends BaseFilterable<FilterableProductProps> {
118
+ handle?: string | string[];
91
119
  id?: string | string[];
92
120
  tags?: {
93
121
  value?: string[];
94
122
  };
95
123
  categories?: {
96
- id?: {
97
- [Operator in keyof OperatorMap<any>]: string[];
98
- } | string[];
124
+ id?: string | string[] | OperatorMap<string>;
99
125
  };
126
+ category_ids?: string | string[] | OperatorMap<string>;
100
127
  }
101
- export interface FilterableProductTagProps {
128
+ export interface FilterableProductTagProps extends BaseFilterable<FilterableProductTagProps> {
102
129
  id?: string | string[];
103
130
  value?: string;
104
131
  }
105
- export interface FilterableProductCollectionProps {
132
+ export interface FilterableProductCollectionProps extends BaseFilterable<FilterableProductCollectionProps> {
106
133
  id?: string | string[];
107
134
  title?: string;
108
135
  }
109
- export interface FilterableProductVariantProps {
136
+ export interface FilterableProductVariantProps extends BaseFilterable<FilterableProductVariantProps> {
110
137
  id?: string | string[];
111
- sku?: string;
138
+ sku?: string | string[];
112
139
  options?: {
113
140
  id?: string[];
114
141
  };
115
142
  }
143
+ export interface FilterableProductCategoryProps extends BaseFilterable<FilterableProductCategoryProps> {
144
+ id?: string | string[];
145
+ parent_category_id?: string | string[] | null;
146
+ handle?: string | string[];
147
+ is_active?: boolean;
148
+ is_internal?: boolean;
149
+ include_descendants_tree?: boolean;
150
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/product/common.ts"],"names":[],"mappings":";;;AAEA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,sCAAqB,CAAA;IACrB,wCAAuB,CAAA;IACvB,sCAAqB,CAAA;AACvB,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB"}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/product/common.ts"],"names":[],"mappings":";;;AAGA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,sCAAqB,CAAA;IACrB,wCAAuB,CAAA;IACvB,sCAAqB,CAAA;AACvB,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB"}
@@ -1,10 +1,11 @@
1
- import { FilterableProductCollectionProps, FilterableProductProps, FilterableProductTagProps, FilterableProductVariantProps, ProductCollectionDTO, ProductDTO, ProductTagDTO, ProductVariantDTO } from "./common";
1
+ import { FilterableProductCategoryProps, FilterableProductCollectionProps, FilterableProductProps, FilterableProductTagProps, FilterableProductVariantProps, ProductCategoryDTO, ProductCollectionDTO, ProductDTO, ProductTagDTO, ProductVariantDTO } from "./common";
2
2
  import { FindConfig } from "../common";
3
3
  import { SharedContext } from "../shared-context";
4
- export interface IProductService {
5
- list<T = unknown>(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<T[]>;
6
- listAndCount<T = unknown>(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<[T[], number]>;
7
- listTags<T = unknown>(filter: FilterableProductTagProps, config?: FindConfig<ProductVariantDTO>, context?: SharedContext): Promise<T[]>;
8
- listVariants<T = unknown>(filter: FilterableProductVariantProps, config?: FindConfig<ProductTagDTO>, context?: SharedContext): Promise<T[]>;
9
- listCollections<T = unknown>(filter: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, context?: SharedContext): Promise<T[]>;
4
+ export interface IProductModuleService<TProduct = any, TProductVariant = any, TProductTag = any, TProductCollection = any, TProductCategory = any> {
5
+ list(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<ProductDTO[]>;
6
+ listAndCount(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<[ProductDTO[], number]>;
7
+ listTags(filter: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, context?: SharedContext): Promise<ProductTagDTO[]>;
8
+ listVariants(filter: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, context?: SharedContext): Promise<ProductVariantDTO[]>;
9
+ listCollections(filter: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, context?: SharedContext): Promise<ProductCollectionDTO[]>;
10
+ listCategories(filters: FilterableProductCategoryProps, config?: FindConfig<ProductCategoryDTO>, sharedContext?: SharedContext): Promise<ProductCategoryDTO[]>;
10
11
  }
@@ -0,0 +1 @@
1
+ export * from "./repository";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./repository"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/product-category/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
@@ -0,0 +1,4 @@
1
+ import { RepositoryTransformOptions } from '../common';
2
+ export interface ProductCategoryTransformOptions extends RepositoryTransformOptions {
3
+ includeDescendantsTree?: boolean;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/product-category/repository.ts"],"names":[],"mappings":""}
@@ -2,7 +2,7 @@ export * from "./index-types";
2
2
  export * from "./interface";
3
3
  export * from "./settings";
4
4
  export * from "./variant-keys";
5
- export declare type IndexSettings = {
5
+ export type IndexSettings = {
6
6
  /**
7
7
  * Settings specific to the provider. E.g. `searchableAttributes`.
8
8
  */
@@ -1,4 +1,4 @@
1
- export declare type IndexSettings = {
1
+ export type IndexSettings = {
2
2
  /**
3
3
  * Settings specific to the provider. E.g. `searchableAttributes`.
4
4
  */
@@ -1,4 +1,4 @@
1
1
  import { EntityManager } from "typeorm";
2
- export declare type SharedContext = {
2
+ export type SharedContext = {
3
3
  transactionManager?: EntityManager;
4
4
  };
@@ -63,7 +63,7 @@ import { StringComparisonOperator } from "../common/common";
63
63
  * description: An optional key-value map with additional details
64
64
  * example: {car: "white"}
65
65
  */
66
- export declare type StockLocationAddressDTO = {
66
+ export type StockLocationAddressDTO = {
67
67
  id?: string;
68
68
  address_1: string;
69
69
  address_2?: string | null;
@@ -124,7 +124,7 @@ export declare type StockLocationAddressDTO = {
124
124
  * description: "The date with timezone at which the resource was deleted."
125
125
  * format: date-time
126
126
  */
127
- export declare type StockLocationDTO = {
127
+ export type StockLocationDTO = {
128
128
  id: string;
129
129
  name: string;
130
130
  metadata: Record<string, unknown> | null;
@@ -143,10 +143,10 @@ export declare type StockLocationDTO = {
143
143
  * sales_channels:
144
144
  * $ref: "#/components/schemas/SalesChannel"
145
145
  */
146
- export declare type StockLocationExpandedDTO = StockLocationDTO & {
146
+ export type StockLocationExpandedDTO = StockLocationDTO & {
147
147
  sales_channels?: any[];
148
148
  };
149
- export declare type FilterableStockLocationProps = {
149
+ export type FilterableStockLocationProps = {
150
150
  id?: string | string[];
151
151
  name?: string | string[] | StringComparisonOperator;
152
152
  };
@@ -192,7 +192,7 @@ export declare type FilterableStockLocationProps = {
192
192
  * description: An optional key-value map with additional details
193
193
  * example: {car: "white"}
194
194
  */
195
- export declare type StockLocationAddressInput = {
195
+ export type StockLocationAddressInput = {
196
196
  address_1: string;
197
197
  address_2?: string;
198
198
  country_code: string;
@@ -226,7 +226,7 @@ export declare type StockLocationAddressInput = {
226
226
  * description: An optional key-value map with additional details
227
227
  * example: {car: "white"}
228
228
  */
229
- export declare type CreateStockLocationInput = {
229
+ export type CreateStockLocationInput = {
230
230
  name: string;
231
231
  address_id?: string;
232
232
  address?: string | StockLocationAddressInput;
@@ -254,7 +254,7 @@ export declare type CreateStockLocationInput = {
254
254
  * description: An optional key-value map with additional details
255
255
  * example: {car: "white"}
256
256
  */
257
- export declare type UpdateStockLocationInput = {
257
+ export type UpdateStockLocationInput = {
258
258
  name?: string;
259
259
  address_id?: string;
260
260
  address?: StockLocationAddressInput;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@medusajs/types",
3
- "version": "1.8.7",
3
+ "version": "1.8.8-beta-20230619170349",
4
4
  "description": "Medusa Types definition",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "https://github.com/medusajs/medusa",
@@ -19,6 +20,7 @@
19
20
  "devDependencies": {
20
21
  "awilix": "^8.0.0",
21
22
  "cross-env": "^5.2.1",
23
+ "ioredis": "^5.2.5",
22
24
  "typeorm": "^0.3.16",
23
25
  "typescript": "^4.4.4",
24
26
  "winston": "^3.8.2"