@medusajs/types 1.8.6 → 1.8.7-next-20230528103641
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/common/common.d.ts +3 -0
- package/dist/common/config-module.d.ts +1 -1
- package/dist/dal/index.d.ts +69 -0
- package/dist/dal/index.js +18 -0
- package/dist/dal/index.js.map +1 -0
- package/dist/dal/repository-service.d.ts +10 -0
- package/dist/dal/repository-service.js +3 -0
- package/dist/dal/repository-service.js.map +1 -0
- package/dist/inventory/common.d.ts +1 -1
- package/dist/product/common.d.ts +115 -0
- package/dist/product/common.js +11 -0
- package/dist/product/common.js.map +1 -0
- package/dist/product/index.d.ts +2 -0
- package/dist/product/index.js +19 -0
- package/dist/product/index.js.map +1 -0
- package/dist/product/service.d.ts +10 -0
- package/dist/product/service.js +3 -0
- package/dist/product/service.js.map +1 -0
- package/package.json +1 -1
package/dist/common/common.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export declare type ProjectConfigOptions = {
|
|
|
22
22
|
jwt_secret?: string;
|
|
23
23
|
cookie_secret?: string;
|
|
24
24
|
database_url?: string;
|
|
25
|
-
database_type: string;
|
|
26
25
|
database_database?: string;
|
|
27
26
|
database_schema?: string;
|
|
28
27
|
database_logging: LoggerOptions;
|
|
28
|
+
database_type?: string;
|
|
29
29
|
http_compression?: HttpCompressionOptions;
|
|
30
30
|
database_extra?: Record<string, unknown> & {
|
|
31
31
|
ssl: {
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
};
|
|
56
|
+
export interface OptionsQuery<T, P extends string = never> {
|
|
57
|
+
populate?: string[];
|
|
58
|
+
orderBy?: Order<T> | Order<T>[];
|
|
59
|
+
limit?: number;
|
|
60
|
+
offset?: number;
|
|
61
|
+
fields?: string[];
|
|
62
|
+
groupBy?: string | string[];
|
|
63
|
+
filters?: Dictionary<boolean | Dictionary> | string[] | boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare type FindOptions<T> = {
|
|
66
|
+
where: FilterQuery<T>;
|
|
67
|
+
options?: OptionsQuery<T, any>;
|
|
68
|
+
};
|
|
69
|
+
export * from "./repository-service";
|
|
@@ -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-service"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+IA,uDAAoC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FindOptions } from "./index";
|
|
2
|
+
/**
|
|
3
|
+
* Data access layer (DAL) interface to implements for any repository service.
|
|
4
|
+
* This layer helps to separate the business logic (service layer) from accessing the
|
|
5
|
+
* ORM directly and allows to switch to another ORM without changing the business logic.
|
|
6
|
+
*/
|
|
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]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-service.js","sourceRoot":"","sources":["../../src/dal/repository-service.ts"],"names":[],"mappings":""}
|
|
@@ -197,7 +197,7 @@ export declare type FilterableReservationItemProps = {
|
|
|
197
197
|
line_item_id?: string | string[];
|
|
198
198
|
inventory_item_id?: string | string[];
|
|
199
199
|
location_id?: string | string[];
|
|
200
|
-
description?: string;
|
|
200
|
+
description?: string | StringComparisonOperator;
|
|
201
201
|
created_by?: string | string[];
|
|
202
202
|
quantity?: number | NumericalComparisonOperator;
|
|
203
203
|
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { OperatorMap } from "../dal";
|
|
2
|
+
export declare enum ProductStatus {
|
|
3
|
+
DRAFT = "draft",
|
|
4
|
+
PROPOSED = "proposed",
|
|
5
|
+
PUBLISHED = "published",
|
|
6
|
+
REJECTED = "rejected"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* DTO in and out of the module (module API)
|
|
10
|
+
*/
|
|
11
|
+
export interface ProductDTO {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
handle?: string | null;
|
|
15
|
+
subtitle?: string | null;
|
|
16
|
+
description?: string | null;
|
|
17
|
+
is_giftcard: boolean;
|
|
18
|
+
status: ProductStatus;
|
|
19
|
+
thumbnail?: string | null;
|
|
20
|
+
weight?: number | null;
|
|
21
|
+
length?: number | null;
|
|
22
|
+
height?: number | null;
|
|
23
|
+
origin_country?: string | null;
|
|
24
|
+
hs_code?: string | null;
|
|
25
|
+
mid_code?: string | null;
|
|
26
|
+
material?: string | null;
|
|
27
|
+
collection?: any;
|
|
28
|
+
categories?: any;
|
|
29
|
+
type: any;
|
|
30
|
+
tags: any;
|
|
31
|
+
options: ProductOptionDTO[];
|
|
32
|
+
discountable?: boolean;
|
|
33
|
+
external_id?: string | null;
|
|
34
|
+
created_at?: string | Date;
|
|
35
|
+
updated_at?: string | Date;
|
|
36
|
+
deleted_at?: string | Date;
|
|
37
|
+
}
|
|
38
|
+
export interface ProductVariantDTO {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
sku?: string | null;
|
|
42
|
+
barcode?: string | null;
|
|
43
|
+
ean?: string | null;
|
|
44
|
+
upc?: string | null;
|
|
45
|
+
inventory_quantity: number;
|
|
46
|
+
allow_backorder?: boolean;
|
|
47
|
+
manage_inventory?: boolean;
|
|
48
|
+
hs_code?: string | null;
|
|
49
|
+
origin_country?: string | null;
|
|
50
|
+
mid_code?: string | null;
|
|
51
|
+
material?: string | null;
|
|
52
|
+
weight?: number | null;
|
|
53
|
+
length?: number | null;
|
|
54
|
+
height?: number | null;
|
|
55
|
+
width?: number | null;
|
|
56
|
+
options: ProductOptionValueDTO;
|
|
57
|
+
metadata?: Record<string, unknown> | null;
|
|
58
|
+
product: ProductDTO;
|
|
59
|
+
variant_rank?: number | null;
|
|
60
|
+
created_at: string | Date;
|
|
61
|
+
updated_at: string | Date;
|
|
62
|
+
deleted_at: string | Date;
|
|
63
|
+
}
|
|
64
|
+
export interface ProductTagDTO {
|
|
65
|
+
id: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ProductVariantDTO {
|
|
68
|
+
id: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ProductCollectionDTO {
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ProductOptionDTO {
|
|
74
|
+
id: string;
|
|
75
|
+
title: string;
|
|
76
|
+
product: ProductDTO;
|
|
77
|
+
values: ProductOptionValueDTO;
|
|
78
|
+
metadata?: Record<string, unknown> | null;
|
|
79
|
+
}
|
|
80
|
+
export interface ProductOptionValueDTO {
|
|
81
|
+
id: string;
|
|
82
|
+
value: string;
|
|
83
|
+
option: ProductOptionDTO;
|
|
84
|
+
variant: ProductVariantDTO;
|
|
85
|
+
metadata?: Record<string, unknown> | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Filters/Config (module API input filters and config)
|
|
89
|
+
*/
|
|
90
|
+
export interface FilterableProductProps {
|
|
91
|
+
id?: string | string[];
|
|
92
|
+
tags?: {
|
|
93
|
+
value?: string[];
|
|
94
|
+
};
|
|
95
|
+
categories?: {
|
|
96
|
+
id?: {
|
|
97
|
+
[Operator in keyof OperatorMap<any>]: string[];
|
|
98
|
+
} | string[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface FilterableProductTagProps {
|
|
102
|
+
id?: string | string[];
|
|
103
|
+
value?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface FilterableProductCollectionProps {
|
|
106
|
+
id?: string | string[];
|
|
107
|
+
title?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface FilterableProductVariantProps {
|
|
110
|
+
id?: string | string[];
|
|
111
|
+
sku?: string;
|
|
112
|
+
options?: {
|
|
113
|
+
id?: string[];
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductStatus = void 0;
|
|
4
|
+
var ProductStatus;
|
|
5
|
+
(function (ProductStatus) {
|
|
6
|
+
ProductStatus["DRAFT"] = "draft";
|
|
7
|
+
ProductStatus["PROPOSED"] = "proposed";
|
|
8
|
+
ProductStatus["PUBLISHED"] = "published";
|
|
9
|
+
ProductStatus["REJECTED"] = "rejected";
|
|
10
|
+
})(ProductStatus = exports.ProductStatus || (exports.ProductStatus = {}));
|
|
11
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./service"), exports);
|
|
18
|
+
__exportStar(require("./common"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/product/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,2CAAwB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FilterableProductCollectionProps, FilterableProductProps, FilterableProductTagProps, FilterableProductVariantProps, ProductCollectionDTO, ProductDTO, ProductTagDTO, ProductVariantDTO } from "./common";
|
|
2
|
+
import { FindConfig } from "../common";
|
|
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[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/product/service.ts"],"names":[],"mappings":""}
|