@medusajs/types 1.9.0-next-20230727065752 → 1.9.0
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.
|
@@ -6,13 +6,17 @@ import { Context } from "../shared-context";
|
|
|
6
6
|
* This layer helps to separate the business logic (service layer) from accessing the
|
|
7
7
|
* ORM directly and allows to switch to another ORM without changing the business logic.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
transaction(task: (transactionManager:
|
|
9
|
+
interface BaseRepositoryService<T = any> {
|
|
10
|
+
transaction<TManager = unknown>(task: (transactionManager: TManager) => Promise<any>, context?: {
|
|
11
11
|
isolationLevel?: string;
|
|
12
|
-
transaction?:
|
|
12
|
+
transaction?: TManager;
|
|
13
13
|
enableNestedTransactions?: boolean;
|
|
14
14
|
}): Promise<any>;
|
|
15
|
+
getFreshManager<TManager = unknown>(): TManager;
|
|
16
|
+
getActiveManager<TManager = unknown>(): TManager;
|
|
15
17
|
serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>;
|
|
18
|
+
}
|
|
19
|
+
export interface RepositoryService<T = any> extends BaseRepositoryService<T> {
|
|
16
20
|
find(options?: FindOptions<T>, context?: Context): Promise<T[]>;
|
|
17
21
|
findAndCount(options?: FindOptions<T>, context?: Context): Promise<[T[], number]>;
|
|
18
22
|
upsert?(data: any, context?: Context): Promise<T[]>;
|
|
@@ -22,7 +26,10 @@ export interface RepositoryService<T = any> {
|
|
|
22
26
|
softDelete(ids: string[], context?: Context): Promise<T[]>;
|
|
23
27
|
restore(ids: string[], context?: Context): Promise<T[]>;
|
|
24
28
|
}
|
|
25
|
-
export interface TreeRepositoryService<T = any> extends
|
|
29
|
+
export interface TreeRepositoryService<T = any> extends BaseRepositoryService<T> {
|
|
26
30
|
find(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions, context?: Context): Promise<T[]>;
|
|
27
31
|
findAndCount(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions, context?: Context): Promise<[T[], number]>;
|
|
32
|
+
create(data: unknown, context?: Context): Promise<T>;
|
|
33
|
+
delete(id: string, context?: Context): Promise<void>;
|
|
28
34
|
}
|
|
35
|
+
export {};
|
package/dist/product/common.d.ts
CHANGED
|
@@ -78,6 +78,24 @@ export interface ProductCategoryDTO {
|
|
|
78
78
|
created_at: string | Date;
|
|
79
79
|
updated_at: string | Date;
|
|
80
80
|
}
|
|
81
|
+
export interface CreateProductCategoryDTO {
|
|
82
|
+
name: string;
|
|
83
|
+
handle?: string;
|
|
84
|
+
is_active?: boolean;
|
|
85
|
+
is_internal?: boolean;
|
|
86
|
+
rank?: number;
|
|
87
|
+
parent_category_id: string | null;
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
export interface UpdateProductCategoryDTO {
|
|
91
|
+
name?: string;
|
|
92
|
+
handle?: string;
|
|
93
|
+
is_active?: boolean;
|
|
94
|
+
is_internal?: boolean;
|
|
95
|
+
rank?: number;
|
|
96
|
+
parent_category_id?: string | null;
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
}
|
|
81
99
|
export interface ProductTagDTO {
|
|
82
100
|
id: string;
|
|
83
101
|
value: string;
|
|
@@ -138,6 +156,15 @@ export interface FilterableProductTagProps extends BaseFilterable<FilterableProd
|
|
|
138
156
|
id?: string | string[];
|
|
139
157
|
value?: string;
|
|
140
158
|
}
|
|
159
|
+
export interface FilterableProductTypeProps extends BaseFilterable<FilterableProductTypeProps> {
|
|
160
|
+
id?: string | string[];
|
|
161
|
+
value?: string;
|
|
162
|
+
}
|
|
163
|
+
export interface FilterableProductOptionProps extends BaseFilterable<FilterableProductOptionProps> {
|
|
164
|
+
id?: string | string[];
|
|
165
|
+
title?: string;
|
|
166
|
+
product_id?: string | string[];
|
|
167
|
+
}
|
|
141
168
|
export interface FilterableProductCollectionProps extends BaseFilterable<FilterableProductCollectionProps> {
|
|
142
169
|
id?: string | string[];
|
|
143
170
|
title?: string;
|
|
@@ -152,6 +179,7 @@ export interface FilterableProductVariantProps extends BaseFilterable<Filterable
|
|
|
152
179
|
}
|
|
153
180
|
export interface FilterableProductCategoryProps extends BaseFilterable<FilterableProductCategoryProps> {
|
|
154
181
|
id?: string | string[];
|
|
182
|
+
name?: string | string[];
|
|
155
183
|
parent_category_id?: string | string[] | null;
|
|
156
184
|
handle?: string | string[];
|
|
157
185
|
is_active?: boolean;
|
|
@@ -161,16 +189,54 @@ export interface FilterableProductCategoryProps extends BaseFilterable<Filterabl
|
|
|
161
189
|
/**
|
|
162
190
|
* Write DTO (module API input)
|
|
163
191
|
*/
|
|
192
|
+
export interface CreateProductCollectionDTO {
|
|
193
|
+
title: string;
|
|
194
|
+
handle?: string;
|
|
195
|
+
products?: ProductDTO[];
|
|
196
|
+
metadata?: Record<string, unknown>;
|
|
197
|
+
}
|
|
198
|
+
export interface UpdateProductCollectionDTO {
|
|
199
|
+
id: string;
|
|
200
|
+
value?: string;
|
|
201
|
+
title?: string;
|
|
202
|
+
handle?: string;
|
|
203
|
+
products?: ProductDTO[];
|
|
204
|
+
metadata?: Record<string, unknown>;
|
|
205
|
+
}
|
|
164
206
|
export interface CreateProductTypeDTO {
|
|
165
207
|
id?: string;
|
|
166
208
|
value: string;
|
|
209
|
+
metadata?: Record<string, unknown>;
|
|
210
|
+
}
|
|
211
|
+
export interface UpsertProductTypeDTO {
|
|
212
|
+
id?: string;
|
|
213
|
+
value: string;
|
|
214
|
+
}
|
|
215
|
+
export interface UpdateProductTypeDTO {
|
|
216
|
+
id: string;
|
|
217
|
+
value?: string;
|
|
218
|
+
metadata?: Record<string, unknown>;
|
|
167
219
|
}
|
|
168
220
|
export interface CreateProductTagDTO {
|
|
221
|
+
value: string;
|
|
222
|
+
}
|
|
223
|
+
export interface UpsertProductTagDTO {
|
|
169
224
|
id?: string;
|
|
170
225
|
value: string;
|
|
171
226
|
}
|
|
227
|
+
export interface UpdateProductTagDTO {
|
|
228
|
+
id: string;
|
|
229
|
+
value?: string;
|
|
230
|
+
}
|
|
172
231
|
export interface CreateProductOptionDTO {
|
|
173
232
|
title: string;
|
|
233
|
+
product_id?: string;
|
|
234
|
+
product?: Record<any, any>;
|
|
235
|
+
}
|
|
236
|
+
export interface UpdateProductOptionDTO {
|
|
237
|
+
id: string;
|
|
238
|
+
title?: string;
|
|
239
|
+
product_id?: string;
|
|
174
240
|
}
|
|
175
241
|
export interface CreateProductVariantOptionDTO {
|
|
176
242
|
value: string;
|
|
@@ -358,8 +424,7 @@ export interface UpdateProductVariantOnlyDTO {
|
|
|
358
424
|
metadata?: Record<string, unknown>;
|
|
359
425
|
}
|
|
360
426
|
export interface CreateProductOptionOnlyDTO {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
};
|
|
427
|
+
product_id?: string;
|
|
428
|
+
product?: Record<any, any>;
|
|
364
429
|
title: string;
|
|
365
430
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateProductDTO, UpdateProductDTO, FilterableProductCategoryProps, FilterableProductCollectionProps, FilterableProductProps, FilterableProductTagProps, FilterableProductVariantProps, ProductCategoryDTO, ProductCollectionDTO, ProductDTO, ProductTagDTO, ProductVariantDTO } from "./common";
|
|
1
|
+
import { CreateProductDTO, CreateProductTagDTO, CreateProductTypeDTO, CreateProductOptionDTO, CreateProductCategoryDTO, UpdateProductTagDTO, UpdateProductTypeDTO, UpdateProductOptionDTO, UpdateProductCategoryDTO, UpdateProductDTO, FilterableProductCategoryProps, FilterableProductCollectionProps, FilterableProductProps, FilterableProductTagProps, FilterableProductTypeProps, FilterableProductOptionProps, FilterableProductVariantProps, ProductCategoryDTO, ProductCollectionDTO, ProductDTO, ProductTagDTO, ProductTypeDTO, ProductOptionDTO, ProductVariantDTO, CreateProductCollectionDTO, UpdateProductCollectionDTO } from "./common";
|
|
2
2
|
import { Context } from "../shared-context";
|
|
3
3
|
import { FindConfig } from "../common";
|
|
4
4
|
import { JoinerServiceConfig } from "../joiner";
|
|
@@ -7,16 +7,39 @@ export interface IProductModuleService {
|
|
|
7
7
|
retrieve(productId: string, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<ProductDTO>;
|
|
8
8
|
list(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<ProductDTO[]>;
|
|
9
9
|
listAndCount(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<[ProductDTO[], number]>;
|
|
10
|
+
retrieveTag(tagId: string, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<ProductTagDTO>;
|
|
10
11
|
listTags(filters?: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<ProductTagDTO[]>;
|
|
12
|
+
listAndCountTags(filters?: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<[ProductTagDTO[], number]>;
|
|
13
|
+
createTags(data: CreateProductTagDTO[], sharedContext?: Context): Promise<ProductTagDTO[]>;
|
|
14
|
+
updateTags(data: UpdateProductTagDTO[], sharedContext?: Context): Promise<ProductTagDTO[]>;
|
|
15
|
+
deleteTags(productTagIds: string[], sharedContext?: Context): Promise<void>;
|
|
16
|
+
retrieveType(typeId: string, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<ProductTypeDTO>;
|
|
17
|
+
listTypes(filters?: FilterableProductTypeProps, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
|
18
|
+
listAndCountTypes(filters?: FilterableProductTypeProps, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<[ProductTypeDTO[], number]>;
|
|
19
|
+
createTypes(data: CreateProductTypeDTO[], sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
|
20
|
+
updateTypes(data: UpdateProductTypeDTO[], sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
|
21
|
+
deleteTypes(productTypeIds: string[], sharedContext?: Context): Promise<void>;
|
|
22
|
+
retrieveOption(optionId: string, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<ProductOptionDTO>;
|
|
23
|
+
listOptions(filters?: FilterableProductOptionProps, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
|
24
|
+
listAndCountOptions(filters?: FilterableProductOptionProps, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<[ProductOptionDTO[], number]>;
|
|
25
|
+
createOptions(data: CreateProductOptionDTO[], sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
|
26
|
+
updateOptions(data: UpdateProductOptionDTO[], sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
|
27
|
+
deleteOptions(productOptionIds: string[], sharedContext?: Context): Promise<void>;
|
|
11
28
|
retrieveVariant(productVariantId: string, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<ProductVariantDTO>;
|
|
12
29
|
listVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<ProductVariantDTO[]>;
|
|
13
30
|
listAndCountVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<[ProductVariantDTO[], number]>;
|
|
14
31
|
retrieveCollection(productCollectionId: string, config?: FindConfig<ProductCollectionDTO>, sharedContext?: Context): Promise<ProductCollectionDTO>;
|
|
15
32
|
listCollections(filters?: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
|
16
33
|
listAndCountCollections(filters?: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, sharedContext?: Context): Promise<[ProductCollectionDTO[], number]>;
|
|
34
|
+
createCollections(data: CreateProductCollectionDTO[], sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
|
35
|
+
updateCollections(data: UpdateProductCollectionDTO[], sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
|
36
|
+
deleteCollections(productCollectionIds: string[], sharedContext?: Context): Promise<void>;
|
|
17
37
|
retrieveCategory(productCategoryId: string, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<ProductCategoryDTO>;
|
|
18
38
|
listCategories(filters?: FilterableProductCategoryProps, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<ProductCategoryDTO[]>;
|
|
19
39
|
listAndCountCategories(filters?: FilterableProductCategoryProps, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<[ProductCategoryDTO[], number]>;
|
|
40
|
+
createCategory(data: CreateProductCategoryDTO, sharedContext?: Context): Promise<ProductCategoryDTO>;
|
|
41
|
+
updateCategory(categoryId: string, data: UpdateProductCategoryDTO, sharedContext?: Context): Promise<ProductCategoryDTO>;
|
|
42
|
+
deleteCategory(categoryId: string, sharedContext?: Context): Promise<void>;
|
|
20
43
|
create(data: CreateProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
|
|
21
44
|
update(data: UpdateProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
|
|
22
45
|
delete(productIds: string[], sharedContext?: Context): Promise<void>;
|
package/dist/shared-context.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EntityManager } from "typeorm";
|
|
2
2
|
export declare type SharedContext = {
|
|
3
3
|
transactionManager?: EntityManager;
|
|
4
|
+
manager?: EntityManager;
|
|
4
5
|
};
|
|
5
6
|
export declare type Context<TManager = unknown> = {
|
|
6
7
|
transactionManager?: TManager;
|
|
8
|
+
manager?: TManager;
|
|
7
9
|
isolationLevel?: string;
|
|
8
10
|
enableNestedTransactions?: boolean;
|
|
9
11
|
transactionId?: string;
|