@merkaly/api 0.28.2 → 0.28.4
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/README.md +55 -0
- package/dist/abstract.validator.d.ts +6 -2
- package/dist/abstract.validator.js +47 -5
- package/dist/finance/payment/payment.entity.d.ts +4 -4
- package/dist/integration/payment/payment.account.entity.d.ts +4 -4
- package/dist/integration/supplier/supplier.connection.entity.d.ts +1 -1
- package/dist/inventory/catalog/brand/brand.entity.d.ts +3 -0
- package/dist/inventory/catalog/brand/request.validator.d.ts +1 -0
- package/dist/inventory/catalog/brand/request.validator.js +7 -0
- package/dist/inventory/catalog/category/category.entity.d.ts +3 -0
- package/dist/inventory/catalog/category/request.validator.d.ts +1 -0
- package/dist/inventory/catalog/category/request.validator.js +7 -0
- package/dist/inventory/catalog/product/product.entity.d.ts +1 -1
- package/dist/inventory/catalog/variant/variant.option.entity.d.ts +1 -1
- package/dist/logistics/shipment/shipment.entity.d.ts +1 -1
- package/dist/order/purchase/purchase.entity.d.ts +1 -1
- package/dist/order/sale/sale.entity.d.ts +5 -5
- package/dist/order/sale/search.request.validator.d.ts +1 -2
- package/dist/order/sale/search.request.validator.js +0 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @merkaly/api
|
|
2
|
+
|
|
3
|
+
Shared contracts (types, enums, validators and transitions) of the Merkaly API, published to npm
|
|
4
|
+
and used by the frontends (admin, store, dashboard). The source of truth is
|
|
5
|
+
`apps/api.merkaly.io`: nothing here is written by hand except `manifest.json`.
|
|
6
|
+
|
|
7
|
+
## How it is built
|
|
8
|
+
|
|
9
|
+
1. `pnpm build` in `apps/api.merkaly.io` produces its `dist/`.
|
|
10
|
+
2. `pnpm sync` here copies the `.d.ts`/`.js` files listed in `manifest.json` from that `dist/` into
|
|
11
|
+
`src/`, rewriting imports between them.
|
|
12
|
+
3. `pnpm build` here (`build.ts`) generates `dist/` with one barrel per entry point.
|
|
13
|
+
|
|
14
|
+
### `manifest.json`
|
|
15
|
+
|
|
16
|
+
- `paths` maps each public entry point to the api files it exports (relative to `api/dist/src`).
|
|
17
|
+
- **A leaf that is an array becomes an entry point with a barrel**: `"@/order": { "sale": [...] }`
|
|
18
|
+
is importable as `@merkaly/api/order/sale`. Intermediate maps do not generate one, so
|
|
19
|
+
`@merkaly/api/order` alone does not resolve: add a leaf (`type`, `home`...) instead.
|
|
20
|
+
- New domains need their group here (e.g. `"@/dashboard": { "home": [...] }`) or their types
|
|
21
|
+
never reach the package.
|
|
22
|
+
|
|
23
|
+
### After `pnpm sync`
|
|
24
|
+
|
|
25
|
+
TypeScript emits `from "x"` with double quotes; the committed files use single quotes. Normalize
|
|
26
|
+
only the `from` clauses (inline `import("mongoose")` types keep double quotes):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
find src -name '*.d.ts' -exec perl -pi -e 's/(\bfrom )"([^"]+)"/$1\x27$2\x27/g' {} +
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If `git status` then shows files you did not mean to change, the api has unsynced changes: review
|
|
33
|
+
them before committing.
|
|
34
|
+
|
|
35
|
+
## Testing in a frontend before publishing
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
rm node_modules/@merkaly/api
|
|
39
|
+
ln -s ../../../../packages/api node_modules/@merkaly/api # from the app folder
|
|
40
|
+
rm -rf node_modules/.cache/vite # then restart its dev server
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Restore with `pnpm add @merkaly/api@<version>` once published. Frontends always use the
|
|
44
|
+
published package, never local types.
|
|
45
|
+
|
|
46
|
+
## Release
|
|
47
|
+
|
|
48
|
+
1. Merge the contracts PR (after the api PR it depends on).
|
|
49
|
+
2. On `master`: bump `version` in `package.json` and commit `chore: release @merkaly/api vX.Y.Z`.
|
|
50
|
+
3. Push the tag `vX.Y.Z`: `release.yml` typechecks, lints, builds and publishes to npm. The tag
|
|
51
|
+
must match `package.json`.
|
|
52
|
+
4. Bump the dependency in each frontend (`chore(deps): bump @merkaly/api to X.Y.Z`).
|
|
53
|
+
|
|
54
|
+
**Versioning**: patch by default (new contracts, fields or fixes); minor only when something a
|
|
55
|
+
frontend uses is removed or changes shape.
|
|
@@ -7,13 +7,17 @@ declare class PaginationValidator {
|
|
|
7
7
|
export type AbstractEntityValidator = Record<string, any>;
|
|
8
8
|
export declare abstract class AbstractRequestValidator {
|
|
9
9
|
}
|
|
10
|
+
export interface ReadRules {
|
|
11
|
+
join: readonly string[];
|
|
12
|
+
}
|
|
10
13
|
export declare class ReadValidator extends AbstractRequestValidator {
|
|
14
|
+
static readonly rules: ReadRules;
|
|
11
15
|
join?: PopulateOptions[];
|
|
12
16
|
select?: string;
|
|
13
17
|
}
|
|
14
|
-
export interface SearchRules {
|
|
18
|
+
export interface SearchRules extends ReadRules {
|
|
15
19
|
filters: readonly string[];
|
|
16
|
-
sort
|
|
20
|
+
sort?: readonly string[];
|
|
17
21
|
}
|
|
18
22
|
export declare class SearchValidator<E = AbstractEntity> extends ReadValidator {
|
|
19
23
|
static readonly rules: SearchRules;
|
|
@@ -29,12 +29,14 @@ __decorate([
|
|
|
29
29
|
export class AbstractRequestValidator {
|
|
30
30
|
}
|
|
31
31
|
export class ReadValidator extends AbstractRequestValidator {
|
|
32
|
+
static rules = { join: [] };
|
|
32
33
|
join = [];
|
|
33
34
|
select;
|
|
34
35
|
}
|
|
35
36
|
__decorate([
|
|
36
37
|
(0, class_validator_1.IsOptional)(),
|
|
37
38
|
(0, class_transformer_1.Transform)(({ value }) => transformJoinsIntoPopulate(value)),
|
|
39
|
+
AllowedBy('join', joinViolation),
|
|
38
40
|
__metadata("design:type", Array)
|
|
39
41
|
], ReadValidator.prototype, "join", void 0);
|
|
40
42
|
__decorate([
|
|
@@ -42,7 +44,7 @@ __decorate([
|
|
|
42
44
|
__metadata("design:type", String)
|
|
43
45
|
], ReadValidator.prototype, "select", void 0);
|
|
44
46
|
export class SearchValidator extends ReadValidator {
|
|
45
|
-
static rules = { filters: [],
|
|
47
|
+
static rules = { filters: [], join: [] };
|
|
46
48
|
pagination = new PaginationValidator();
|
|
47
49
|
sort = {};
|
|
48
50
|
filters = {};
|
|
@@ -67,7 +69,7 @@ __decorate([
|
|
|
67
69
|
__metadata("design:type", Object)
|
|
68
70
|
], SearchValidator.prototype, "sort", void 0);
|
|
69
71
|
__decorate([
|
|
70
|
-
(0, class_transformer_1.Transform)(({ key, value }) => transformStructuredValue(key, value)),
|
|
72
|
+
(0, class_transformer_1.Transform)(({ key, value }) => escapeRegexOperands(key, transformStructuredValue(key, value))),
|
|
71
73
|
AllowedBy('filters', filterViolation),
|
|
72
74
|
(0, class_validator_1.IsOptional)(),
|
|
73
75
|
__metadata("design:type", Object)
|
|
@@ -90,7 +92,11 @@ const FIELD_OPERATORS = new Set([
|
|
|
90
92
|
'$exists',
|
|
91
93
|
]);
|
|
92
94
|
const LOGICAL_OPERATORS = new Set(['$and', '$or']);
|
|
93
|
-
const
|
|
95
|
+
const REGEX_MAX_LENGTH = 100;
|
|
96
|
+
const REGEX_OPTIONS = /^[ims]*$/;
|
|
97
|
+
const REGEX_SPECIALS = /[\\^$.*+?()[\]{}|]/g;
|
|
98
|
+
const REGEX_ESCAPED = /\\([\\^$.*+?()[\]{}|])/g;
|
|
99
|
+
const rulesOf = (object) => object.constructor.rules ?? ReadValidator.rules;
|
|
94
100
|
function AllowedBy(name, violation) {
|
|
95
101
|
return (0, class_validator_1.ValidateBy)({
|
|
96
102
|
name: `${name}Allowed`,
|
|
@@ -118,7 +124,7 @@ function filterViolation(value, rules, path = 'filters') {
|
|
|
118
124
|
return nested;
|
|
119
125
|
continue;
|
|
120
126
|
}
|
|
121
|
-
if (!rules.filters.includes(field))
|
|
127
|
+
if (!(rules.filters ?? []).includes(field))
|
|
122
128
|
return `${path}.${field} is not filterable`;
|
|
123
129
|
if (isPlainValue(condition))
|
|
124
130
|
continue;
|
|
@@ -129,6 +135,10 @@ function filterViolation(value, rules, path = 'filters') {
|
|
|
129
135
|
return `${path}.${field} must not use ${operator}`;
|
|
130
136
|
if (!isPlainValue(operand))
|
|
131
137
|
return `${path}.${field}.${operator} must be a plain value`;
|
|
138
|
+
if (operator === '$regex' && !(0, class_validator_1.isString)(operand))
|
|
139
|
+
return `${path}.${field}.$regex must be a string`;
|
|
140
|
+
if (operator === '$options' && !((0, class_validator_1.isString)(operand) && REGEX_OPTIONS.test(operand)))
|
|
141
|
+
return `${path}.${field}.$options must only use i, m or s`;
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
return undefined;
|
|
@@ -136,9 +146,41 @@ function filterViolation(value, rules, path = 'filters') {
|
|
|
136
146
|
function sortViolation(value, rules) {
|
|
137
147
|
if (!(0, class_validator_1.isObject)(value))
|
|
138
148
|
return undefined;
|
|
139
|
-
const field = Object.keys(value).find((key) => !rules.sort.includes(key));
|
|
149
|
+
const field = Object.keys(value).find((key) => !(rules.sort ?? rules.filters ?? []).includes(key));
|
|
140
150
|
return field ? `sort.${field} is not sortable` : undefined;
|
|
141
151
|
}
|
|
152
|
+
function joinViolation(value, rules, prefix = '') {
|
|
153
|
+
if (value === undefined || value === null)
|
|
154
|
+
return undefined;
|
|
155
|
+
if (!(0, class_validator_1.isArray)(value))
|
|
156
|
+
return 'join must be a list';
|
|
157
|
+
for (const entry of value) {
|
|
158
|
+
if (!(0, class_validator_1.isString)(entry?.path))
|
|
159
|
+
return 'join entries must have a path';
|
|
160
|
+
const path = prefix ? `${prefix}.${entry.path}` : entry.path;
|
|
161
|
+
if (!(rules.join ?? []).includes(path))
|
|
162
|
+
return `join.${path} is not allowed`;
|
|
163
|
+
const nested = joinViolation(entry.populate, rules, path);
|
|
164
|
+
if (nested)
|
|
165
|
+
return nested;
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
const escapeRegex = (term) => term.replace(REGEX_ESCAPED, '$1').replace(REGEX_SPECIALS, '\\$&');
|
|
170
|
+
function escapeRegexOperands(key, value) {
|
|
171
|
+
if ((0, class_validator_1.isArray)(value))
|
|
172
|
+
return value.map((item) => escapeRegexOperands(key, item));
|
|
173
|
+
if (!(0, class_validator_1.isObject)(value))
|
|
174
|
+
return value;
|
|
175
|
+
const entries = Object.entries(value).map(([field, nested]) => {
|
|
176
|
+
if (field !== '$regex' || !(0, class_validator_1.isString)(nested))
|
|
177
|
+
return [field, escapeRegexOperands(key, nested)];
|
|
178
|
+
if (nested.length > REGEX_MAX_LENGTH)
|
|
179
|
+
throw new QueryValidationError(`${key} $regex must be at most ${REGEX_MAX_LENGTH} characters`);
|
|
180
|
+
return [field, escapeRegex(nested)];
|
|
181
|
+
});
|
|
182
|
+
return Object.fromEntries(entries);
|
|
183
|
+
}
|
|
142
184
|
const SORT_ORDERS = new Set([1, -1, 'asc', 'desc', 'ascending', 'descending']);
|
|
143
185
|
function assertSortOrder(sort) {
|
|
144
186
|
if (!sort)
|
|
@@ -16,7 +16,7 @@ export declare const FinancePaymentGatewayPixSchema: MongoSchema<FinancePaymentG
|
|
|
16
16
|
_id: import("mongoose").Types.ObjectId;
|
|
17
17
|
} & {
|
|
18
18
|
__v: number;
|
|
19
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity>, {}, import("mongoose").
|
|
19
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity> & {
|
|
20
20
|
_id: import("mongoose").Types.ObjectId;
|
|
21
21
|
} & {
|
|
22
22
|
__v: number;
|
|
@@ -29,7 +29,7 @@ export declare const FinancePaymentGatewayCardSchema: MongoSchema<FinancePayment
|
|
|
29
29
|
_id: import("mongoose").Types.ObjectId;
|
|
30
30
|
} & {
|
|
31
31
|
__v: number;
|
|
32
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayCardEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity>, {}, import("mongoose").
|
|
32
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayCardEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity> & {
|
|
33
33
|
_id: import("mongoose").Types.ObjectId;
|
|
34
34
|
} & {
|
|
35
35
|
__v: number;
|
|
@@ -53,7 +53,7 @@ export declare const FinancePaymentGatewaySchema: MongoSchema<FinancePaymentGate
|
|
|
53
53
|
_id: import("mongoose").Types.ObjectId;
|
|
54
54
|
} & {
|
|
55
55
|
__v: number;
|
|
56
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayEntity>, {}, import("mongoose").
|
|
56
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<FinancePaymentGatewayEntity> & {
|
|
57
57
|
_id: import("mongoose").Types.ObjectId;
|
|
58
58
|
} & {
|
|
59
59
|
__v: number;
|
|
@@ -75,7 +75,7 @@ export declare const FinancePaymentAttemptSchema: MongoSchema<FinancePaymentAtte
|
|
|
75
75
|
_id: import("mongoose").Types.ObjectId;
|
|
76
76
|
} & {
|
|
77
77
|
__v: number;
|
|
78
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentAttemptEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentAttemptEntity>, {}, import("mongoose").
|
|
78
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentAttemptEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentAttemptEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<FinancePaymentAttemptEntity> & {
|
|
79
79
|
_id: import("mongoose").Types.ObjectId;
|
|
80
80
|
} & {
|
|
81
81
|
__v: number;
|
|
@@ -10,7 +10,7 @@ export declare const IntegrationPaymentAccountApprovalSchema: MongoSchema<Integr
|
|
|
10
10
|
_id: import("mongoose").Types.ObjectId;
|
|
11
11
|
} & {
|
|
12
12
|
__v: number;
|
|
13
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountApprovalEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountApprovalEntity>, {}, import("mongoose").
|
|
13
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountApprovalEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountApprovalEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<IntegrationPaymentAccountApprovalEntity> & {
|
|
14
14
|
_id: import("mongoose").Types.ObjectId;
|
|
15
15
|
} & {
|
|
16
16
|
__v: number;
|
|
@@ -23,7 +23,7 @@ export declare const IntegrationPaymentAccountWithdrawalSchema: MongoSchema<Inte
|
|
|
23
23
|
_id: import("mongoose").Types.ObjectId;
|
|
24
24
|
} & {
|
|
25
25
|
__v: number;
|
|
26
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountWithdrawalEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountWithdrawalEntity>, {}, import("mongoose").
|
|
26
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountWithdrawalEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountWithdrawalEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<IntegrationPaymentAccountWithdrawalEntity> & {
|
|
27
27
|
_id: import("mongoose").Types.ObjectId;
|
|
28
28
|
} & {
|
|
29
29
|
__v: number;
|
|
@@ -37,7 +37,7 @@ export declare const IntegrationPaymentAccountPixSchema: MongoSchema<Integration
|
|
|
37
37
|
_id: import("mongoose").Types.ObjectId;
|
|
38
38
|
} & {
|
|
39
39
|
__v: number;
|
|
40
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountPixEntity>, {}, import("mongoose").
|
|
40
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountPixEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<IntegrationPaymentAccountPixEntity> & {
|
|
41
41
|
_id: import("mongoose").Types.ObjectId;
|
|
42
42
|
} & {
|
|
43
43
|
__v: number;
|
|
@@ -60,7 +60,7 @@ export declare const IntegrationPaymentAccountSchema: MongoSchema<IntegrationPay
|
|
|
60
60
|
_id: import("mongoose").Types.ObjectId;
|
|
61
61
|
} & {
|
|
62
62
|
__v: number;
|
|
63
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountEntity>, {}, import("mongoose").
|
|
63
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<IntegrationPaymentAccountEntity> & {
|
|
64
64
|
_id: import("mongoose").Types.ObjectId;
|
|
65
65
|
} & {
|
|
66
66
|
__v: number;
|
|
@@ -11,7 +11,7 @@ export declare const IntegrationSupplierConnectionSchema: MongoSchema<Integratio
|
|
|
11
11
|
_id: import("mongoose").Types.ObjectId;
|
|
12
12
|
} & {
|
|
13
13
|
__v: number;
|
|
14
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationSupplierConnectionEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationSupplierConnectionEntity>, {}, import("mongoose").
|
|
14
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationSupplierConnectionEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationSupplierConnectionEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<IntegrationSupplierConnectionEntity> & {
|
|
15
15
|
_id: import("mongoose").Types.ObjectId;
|
|
16
16
|
} & {
|
|
17
17
|
__v: number;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { AbstractEntity } from '../../../abstract.entity.js';
|
|
2
2
|
import { CatalogRelationStatusEnum } from '../../../relation.status.enum.js';
|
|
3
3
|
import { CatalogProductEntity } from '../product';
|
|
4
|
+
import type { AssetEntity } from '../../../assets/asset';
|
|
4
5
|
export declare class CatalogBrandEntity extends AbstractEntity {
|
|
5
6
|
name: string;
|
|
6
7
|
description: string;
|
|
8
|
+
posterId?: string | null;
|
|
9
|
+
readonly poster?: AssetEntity | null;
|
|
7
10
|
readonly products?: CatalogProductEntity[];
|
|
8
11
|
readonly status: CatalogRelationStatusEnum;
|
|
9
12
|
}
|
|
@@ -3,6 +3,7 @@ import type { CatalogBrandEntity } from './brand.entity.js';
|
|
|
3
3
|
export declare class CreateBrandRequestValidator extends AbstractRequestValidator {
|
|
4
4
|
name: string;
|
|
5
5
|
description?: string;
|
|
6
|
+
posterId?: string | null;
|
|
6
7
|
constructor(brand?: CatalogBrandEntity);
|
|
7
8
|
}
|
|
8
9
|
export declare class UpdateBrandRequestValidator extends CreateBrandRequestValidator {
|
|
@@ -13,6 +13,7 @@ import * as abstract_validator_1 from '../../../abstract.validator.js';
|
|
|
13
13
|
export class CreateBrandRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
14
14
|
name;
|
|
15
15
|
description;
|
|
16
|
+
posterId;
|
|
16
17
|
constructor(brand) {
|
|
17
18
|
super();
|
|
18
19
|
if (!brand) {
|
|
@@ -20,6 +21,7 @@ export class CreateBrandRequestValidator extends abstract_validator_1.AbstractRe
|
|
|
20
21
|
}
|
|
21
22
|
this.name = brand.name;
|
|
22
23
|
this.description = brand.description;
|
|
24
|
+
this.posterId = brand.posterId ? String(brand.posterId) : null;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
__decorate([
|
|
@@ -34,6 +36,11 @@ __decorate([
|
|
|
34
36
|
(0, class_validator_1.IsOptional)(),
|
|
35
37
|
__metadata("design:type", String)
|
|
36
38
|
], CreateBrandRequestValidator.prototype, "description", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, class_validator_1.IsMongoId)(),
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], CreateBrandRequestValidator.prototype, "posterId", void 0);
|
|
37
44
|
export class UpdateBrandRequestValidator extends CreateBrandRequestValidator {
|
|
38
45
|
}
|
|
39
46
|
__decorate([
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AbstractEntity } from '../../../abstract.entity.js';
|
|
2
2
|
import { CatalogRelationStatusEnum } from '../../../relation.status.enum.js';
|
|
3
3
|
import { CatalogProductEntity } from '../product';
|
|
4
|
+
import type { AssetEntity } from '../../../assets/asset';
|
|
4
5
|
export declare class CatalogCategoryEntity extends AbstractEntity {
|
|
5
6
|
name: string;
|
|
6
7
|
description?: string;
|
|
7
8
|
icon?: string | null;
|
|
8
9
|
parent?: CatalogCategoryEntity;
|
|
10
|
+
posterId?: string | null;
|
|
11
|
+
readonly poster?: AssetEntity | null;
|
|
9
12
|
readonly children?: CatalogCategoryEntity[];
|
|
10
13
|
readonly products?: CatalogProductEntity[];
|
|
11
14
|
readonly status: CatalogRelationStatusEnum;
|
|
@@ -5,6 +5,7 @@ export declare class CreateCategoryRequestValidator extends AbstractRequestValid
|
|
|
5
5
|
description?: string;
|
|
6
6
|
icon?: string | null;
|
|
7
7
|
parent?: string | null;
|
|
8
|
+
posterId?: string | null;
|
|
8
9
|
constructor(category?: CatalogCategoryEntity);
|
|
9
10
|
}
|
|
10
11
|
export declare class UpdateCategoryRequestValidator extends CreateCategoryRequestValidator {
|
|
@@ -15,6 +15,7 @@ export class CreateCategoryRequestValidator extends abstract_validator_1.Abstrac
|
|
|
15
15
|
description;
|
|
16
16
|
icon;
|
|
17
17
|
parent;
|
|
18
|
+
posterId;
|
|
18
19
|
constructor(category) {
|
|
19
20
|
super();
|
|
20
21
|
if (!category) {
|
|
@@ -24,6 +25,7 @@ export class CreateCategoryRequestValidator extends abstract_validator_1.Abstrac
|
|
|
24
25
|
this.description = category.description;
|
|
25
26
|
this.icon = category.icon;
|
|
26
27
|
this.parent = category.parent ? String(category.parent._id ?? category.parent) : null;
|
|
28
|
+
this.posterId = category.posterId ? String(category.posterId) : null;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
__decorate([
|
|
@@ -50,6 +52,11 @@ __decorate([
|
|
|
50
52
|
(0, class_validator_1.IsOptional)(),
|
|
51
53
|
__metadata("design:type", String)
|
|
52
54
|
], CreateCategoryRequestValidator.prototype, "parent", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, class_validator_1.IsMongoId)(),
|
|
57
|
+
(0, class_validator_1.IsOptional)(),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], CreateCategoryRequestValidator.prototype, "posterId", void 0);
|
|
53
60
|
export class UpdateCategoryRequestValidator extends CreateCategoryRequestValidator {
|
|
54
61
|
}
|
|
55
62
|
__decorate([
|
|
@@ -14,7 +14,7 @@ export declare const CatalogProductPropertySchema: MongoSchema<CatalogProductPro
|
|
|
14
14
|
_id: Types.ObjectId;
|
|
15
15
|
} & {
|
|
16
16
|
__v: number;
|
|
17
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CatalogProductPropertyEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CatalogProductPropertyEntity>, {}, import("mongoose").
|
|
17
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CatalogProductPropertyEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CatalogProductPropertyEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<CatalogProductPropertyEntity> & {
|
|
18
18
|
_id: Types.ObjectId;
|
|
19
19
|
} & {
|
|
20
20
|
__v: number;
|
|
@@ -9,7 +9,7 @@ export declare const CatalogVariantOptionSchema: import("mongoose").Schema<Catal
|
|
|
9
9
|
_id: import("mongoose").Types.ObjectId;
|
|
10
10
|
} & {
|
|
11
11
|
__v: number;
|
|
12
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CatalogVariantOptionEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CatalogVariantOptionEntity>, {}, import("mongoose").
|
|
12
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CatalogVariantOptionEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CatalogVariantOptionEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<CatalogVariantOptionEntity> & {
|
|
13
13
|
_id: import("mongoose").Types.ObjectId;
|
|
14
14
|
} & {
|
|
15
15
|
__v: number;
|
|
@@ -14,7 +14,7 @@ export declare const LogisticsShipmentEventSchema: MongoSchema<LogisticsShipment
|
|
|
14
14
|
_id: import("mongoose").Types.ObjectId;
|
|
15
15
|
} & {
|
|
16
16
|
__v: number;
|
|
17
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LogisticsShipmentEventEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<LogisticsShipmentEventEntity>, {}, import("mongoose").
|
|
17
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LogisticsShipmentEventEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<LogisticsShipmentEventEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<LogisticsShipmentEventEntity> & {
|
|
18
18
|
_id: import("mongoose").Types.ObjectId;
|
|
19
19
|
} & {
|
|
20
20
|
__v: number;
|
|
@@ -18,7 +18,7 @@ export declare const OrderPurchaseSupplierOrderSchema: MongoSchema<OrderPurchase
|
|
|
18
18
|
_id: import("mongoose").Types.ObjectId;
|
|
19
19
|
} & {
|
|
20
20
|
__v: number;
|
|
21
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderPurchaseSupplierOrderEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderPurchaseSupplierOrderEntity>, {}, import("mongoose").
|
|
21
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderPurchaseSupplierOrderEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderPurchaseSupplierOrderEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<OrderPurchaseSupplierOrderEntity> & {
|
|
22
22
|
_id: import("mongoose").Types.ObjectId;
|
|
23
23
|
} & {
|
|
24
24
|
__v: number;
|
|
@@ -15,7 +15,7 @@ export declare const OrderSaleDeliveryRecipientSchema: MongoSchema<OrderSaleDeli
|
|
|
15
15
|
_id: import("mongoose").Types.ObjectId;
|
|
16
16
|
} & {
|
|
17
17
|
__v: number;
|
|
18
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryRecipientEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryRecipientEntity>, {}, import("mongoose").
|
|
18
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryRecipientEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryRecipientEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<OrderSaleDeliveryRecipientEntity> & {
|
|
19
19
|
_id: import("mongoose").Types.ObjectId;
|
|
20
20
|
} & {
|
|
21
21
|
__v: number;
|
|
@@ -34,7 +34,7 @@ export declare const OrderSaleDeliveryAddressSchema: MongoSchema<OrderSaleDelive
|
|
|
34
34
|
_id: import("mongoose").Types.ObjectId;
|
|
35
35
|
} & {
|
|
36
36
|
__v: number;
|
|
37
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryAddressEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryAddressEntity>, {}, import("mongoose").
|
|
37
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryAddressEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryAddressEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<OrderSaleDeliveryAddressEntity> & {
|
|
38
38
|
_id: import("mongoose").Types.ObjectId;
|
|
39
39
|
} & {
|
|
40
40
|
__v: number;
|
|
@@ -47,7 +47,7 @@ export declare const OrderSaleDeliveryDaysSchema: MongoSchema<OrderSaleDeliveryD
|
|
|
47
47
|
_id: import("mongoose").Types.ObjectId;
|
|
48
48
|
} & {
|
|
49
49
|
__v: number;
|
|
50
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryDaysEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryDaysEntity>, {}, import("mongoose").
|
|
50
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryDaysEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryDaysEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<OrderSaleDeliveryDaysEntity> & {
|
|
51
51
|
_id: import("mongoose").Types.ObjectId;
|
|
52
52
|
} & {
|
|
53
53
|
__v: number;
|
|
@@ -62,7 +62,7 @@ export declare const OrderSaleDeliveryLineSchema: MongoSchema<OrderSaleDeliveryL
|
|
|
62
62
|
_id: import("mongoose").Types.ObjectId;
|
|
63
63
|
} & {
|
|
64
64
|
__v: number;
|
|
65
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryLineEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryLineEntity>, {}, import("mongoose").
|
|
65
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryLineEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryLineEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<OrderSaleDeliveryLineEntity> & {
|
|
66
66
|
_id: import("mongoose").Types.ObjectId;
|
|
67
67
|
} & {
|
|
68
68
|
__v: number;
|
|
@@ -78,7 +78,7 @@ export declare const OrderSaleDeliverySchema: MongoSchema<OrderSaleDeliveryEntit
|
|
|
78
78
|
_id: import("mongoose").Types.ObjectId;
|
|
79
79
|
} & {
|
|
80
80
|
__v: number;
|
|
81
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryEntity>, {}, import("mongoose").
|
|
81
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderSaleDeliveryEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderSaleDeliveryEntity>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<OrderSaleDeliveryEntity> & {
|
|
82
82
|
_id: import("mongoose").Types.ObjectId;
|
|
83
83
|
} & {
|
|
84
84
|
__v: number;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { OrderBuyerStageEnum } from './fulfillment.enum.js';
|
|
2
|
-
import { SearchValidator
|
|
2
|
+
import { SearchValidator } from '../../abstract.validator.js';
|
|
3
3
|
import type { OrderSaleEntity } from './sale.entity.js';
|
|
4
4
|
export declare class SearchBuyerOrdersRequestValidator extends SearchValidator<OrderSaleEntity> {
|
|
5
|
-
static readonly rules: SearchRules;
|
|
6
5
|
stage?: OrderBuyerStageEnum;
|
|
7
6
|
}
|
|
@@ -12,7 +12,6 @@ import * as class_validator_1 from "class-validator";
|
|
|
12
12
|
import * as fulfillment_enum_1 from './fulfillment.enum.js';
|
|
13
13
|
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
14
14
|
export class SearchBuyerOrdersRequestValidator extends abstract_validator_1.SearchValidator {
|
|
15
|
-
static rules = { filters: ['number'], sort: [] };
|
|
16
15
|
stage;
|
|
17
16
|
}
|
|
18
17
|
__decorate([
|