oneentry 1.0.136 → 1.0.137
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 +15 -3
- package/configure.js +27 -3
- package/dist/admins/adminsApi.js +4 -1
- package/dist/admins/adminsInterfaces.d.ts +1 -1
- package/dist/admins/adminsSchemas.d.ts +30 -0
- package/dist/admins/adminsSchemas.js +27 -0
- package/dist/attribute-sets/attributeSetsApi.js +13 -4
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
- package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
- package/dist/auth-provider/authProviderApi.d.ts +11 -8
- package/dist/auth-provider/authProviderApi.js +25 -15
- package/dist/auth-provider/authProviderSchemas.d.ts +137 -0
- package/dist/auth-provider/authProviderSchemas.js +85 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +6 -6
- package/dist/base/asyncModules.d.ts +25 -15
- package/dist/base/asyncModules.js +91 -24
- package/dist/base/stateModule.d.ts +7 -0
- package/dist/base/stateModule.js +26 -11
- package/dist/base/syncModules.d.ts +12 -0
- package/dist/base/syncModules.js +45 -94
- package/dist/base/utils.d.ts +41 -2
- package/dist/base/validation.d.ts +118 -0
- package/dist/base/validation.js +132 -0
- package/dist/blocks/blocksApi.js +16 -11
- package/dist/blocks/blocksInterfaces.d.ts +1 -1
- package/dist/blocks/blocksSchemas.d.ts +187 -0
- package/dist/blocks/blocksSchemas.js +43 -0
- package/dist/config.d.ts +10 -2
- package/dist/config.js +20 -4
- package/dist/file-uploading/fileUploadingApi.js +4 -1
- package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
- package/dist/file-uploading/fileUploadingSchemas.js +21 -0
- package/dist/forms/formsApi.js +7 -2
- package/dist/forms/formsInterfaces.d.ts +20 -8
- package/dist/forms/formsSchemas.d.ts +65 -0
- package/dist/forms/formsSchemas.js +36 -0
- package/dist/forms-data/formsDataApi.js +10 -3
- package/dist/forms-data/formsDataInterfaces.d.ts +2 -2
- package/dist/forms-data/formsDataSchemas.d.ts +107 -0
- package/dist/forms-data/formsDataSchemas.js +83 -0
- package/dist/general-types/generalTypesApi.js +4 -1
- package/dist/general-types/generalTypesSchemas.d.ts +50 -0
- package/dist/general-types/generalTypesSchemas.js +35 -0
- package/dist/integration-collections/integrationCollectionsApi.js +25 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
- package/dist/integration-collections/integrationCollectionsSchemas.js +63 -0
- package/dist/locales/localesApi.js +4 -1
- package/dist/locales/localesSchemas.d.ts +32 -0
- package/dist/locales/localesSchemas.js +26 -0
- package/dist/menus/menusApi.js +4 -1
- package/dist/menus/menusSchemas.d.ts +16 -0
- package/dist/menus/menusSchemas.js +28 -0
- package/dist/orders/ordersApi.js +13 -4
- package/dist/orders/ordersInterfaces.d.ts +3 -3
- package/dist/orders/ordersSchemas.d.ts +158 -0
- package/dist/orders/ordersSchemas.js +120 -0
- package/dist/pages/pagesApi.d.ts +2 -1
- package/dist/pages/pagesApi.js +87 -34
- package/dist/pages/pagesInterfaces.d.ts +6 -5
- package/dist/pages/pagesSchemas.d.ts +85 -0
- package/dist/pages/pagesSchemas.js +46 -0
- package/dist/payments/paymentsApi.js +13 -4
- package/dist/payments/paymentsInterfaces.d.ts +3 -3
- package/dist/payments/paymentsSchemas.d.ts +121 -0
- package/dist/payments/paymentsSchemas.js +75 -0
- package/dist/product-statuses/productStatusesApi.js +13 -3
- package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/dist/product-statuses/productStatusesSchemas.js +30 -0
- package/dist/products/productsApi.js +19 -6
- package/dist/products/productsInterfaces.d.ts +4 -4
- package/dist/products/productsSchemas.d.ts +212 -0
- package/dist/products/productsSchemas.js +85 -0
- package/dist/templates/templatesApi.js +11 -4
- package/dist/templates/templatesSchemas.d.ts +48 -0
- package/dist/templates/templatesSchemas.js +31 -0
- package/dist/templates-preview/templatesPreviewApi.js +7 -2
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
- package/dist/users/usersApi.js +8 -5
- package/dist/users/usersInterfaces.d.ts +2 -1
- package/dist/users/usersSchemas.d.ts +38 -0
- package/dist/users/usersSchemas.js +28 -0
- package/package.json +5 -4
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation schemas for Pages module
|
|
3
|
+
* @description Zod schemas for validating pages-related API responses
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Page entity schema
|
|
8
|
+
* Includes all fields returned by the API
|
|
9
|
+
*/
|
|
10
|
+
export declare const PageEntitySchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodNumber;
|
|
12
|
+
parentId: z.ZodNullable<z.ZodNumber>;
|
|
13
|
+
pageUrl: z.ZodString;
|
|
14
|
+
depth: z.ZodNumber;
|
|
15
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
16
|
+
isVisible: z.ZodBoolean;
|
|
17
|
+
type: z.ZodString;
|
|
18
|
+
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
19
|
+
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
20
|
+
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
21
|
+
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
22
|
+
isSync: z.ZodBoolean;
|
|
23
|
+
template: z.ZodOptional<z.ZodAny>;
|
|
24
|
+
blocks: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodArray<z.ZodString>]>>;
|
|
25
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
27
|
+
products: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
childrenCount: z.ZodOptional<z.ZodString>;
|
|
29
|
+
total: z.ZodOptional<z.ZodString>;
|
|
30
|
+
categoryPath: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* Pages response schema (array of pages)
|
|
34
|
+
*/
|
|
35
|
+
export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
36
|
+
id: z.ZodNumber;
|
|
37
|
+
parentId: z.ZodNullable<z.ZodNumber>;
|
|
38
|
+
pageUrl: z.ZodString;
|
|
39
|
+
depth: z.ZodNumber;
|
|
40
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
41
|
+
isVisible: z.ZodBoolean;
|
|
42
|
+
type: z.ZodString;
|
|
43
|
+
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
44
|
+
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
45
|
+
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
46
|
+
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
47
|
+
isSync: z.ZodBoolean;
|
|
48
|
+
template: z.ZodOptional<z.ZodAny>;
|
|
49
|
+
blocks: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodArray<z.ZodString>]>>;
|
|
50
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
52
|
+
products: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
childrenCount: z.ZodOptional<z.ZodString>;
|
|
54
|
+
total: z.ZodOptional<z.ZodString>;
|
|
55
|
+
categoryPath: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
/**
|
|
58
|
+
* Single page response schema
|
|
59
|
+
*/
|
|
60
|
+
export declare const SinglePageSchema: z.ZodObject<{
|
|
61
|
+
id: z.ZodNumber;
|
|
62
|
+
parentId: z.ZodNullable<z.ZodNumber>;
|
|
63
|
+
pageUrl: z.ZodString;
|
|
64
|
+
depth: z.ZodNumber;
|
|
65
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
66
|
+
isVisible: z.ZodBoolean;
|
|
67
|
+
type: z.ZodString;
|
|
68
|
+
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
69
|
+
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
70
|
+
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
71
|
+
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
72
|
+
isSync: z.ZodBoolean;
|
|
73
|
+
template: z.ZodOptional<z.ZodAny>;
|
|
74
|
+
blocks: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodArray<z.ZodString>]>>;
|
|
75
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
77
|
+
products: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
childrenCount: z.ZodOptional<z.ZodString>;
|
|
79
|
+
total: z.ZodOptional<z.ZodString>;
|
|
80
|
+
categoryPath: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
/**
|
|
83
|
+
* Page config schema
|
|
84
|
+
*/
|
|
85
|
+
export declare const PageConfigSchema: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageConfigSchema = exports.SinglePageSchema = exports.PagesResponseSchema = exports.PageEntitySchema = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validation schemas for Pages module
|
|
6
|
+
* @description Zod schemas for validating pages-related API responses
|
|
7
|
+
*/
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
/**
|
|
10
|
+
* Page entity schema
|
|
11
|
+
* Includes all fields returned by the API
|
|
12
|
+
*/
|
|
13
|
+
exports.PageEntitySchema = zod_1.z.object({
|
|
14
|
+
id: zod_1.z.number(),
|
|
15
|
+
parentId: zod_1.z.number().nullable(),
|
|
16
|
+
pageUrl: zod_1.z.string(),
|
|
17
|
+
depth: zod_1.z.number(),
|
|
18
|
+
localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
19
|
+
isVisible: zod_1.z.boolean(),
|
|
20
|
+
type: zod_1.z.string(),
|
|
21
|
+
templateIdentifier: zod_1.z.string().nullable(),
|
|
22
|
+
attributeSetIdentifier: zod_1.z.string().nullable(),
|
|
23
|
+
attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
24
|
+
moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
|
|
25
|
+
isSync: zod_1.z.boolean(),
|
|
26
|
+
template: zod_1.z.any().optional(),
|
|
27
|
+
blocks: zod_1.z.union([zod_1.z.array(zod_1.z.any()), zod_1.z.array(zod_1.z.string())]).optional(),
|
|
28
|
+
position: zod_1.z.number().optional(),
|
|
29
|
+
config: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
|
|
30
|
+
products: zod_1.z.number().optional(),
|
|
31
|
+
childrenCount: zod_1.z.string().optional(),
|
|
32
|
+
total: zod_1.z.string().optional(),
|
|
33
|
+
categoryPath: zod_1.z.string().optional(),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Pages response schema (array of pages)
|
|
37
|
+
*/
|
|
38
|
+
exports.PagesResponseSchema = zod_1.z.array(exports.PageEntitySchema);
|
|
39
|
+
/**
|
|
40
|
+
* Single page response schema
|
|
41
|
+
*/
|
|
42
|
+
exports.SinglePageSchema = exports.PageEntitySchema;
|
|
43
|
+
/**
|
|
44
|
+
* Page config schema
|
|
45
|
+
*/
|
|
46
|
+
exports.PageConfigSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.any());
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
|
+
const paymentsSchemas_1 = require("./paymentsSchemas");
|
|
7
8
|
/**
|
|
8
9
|
* Controllers for working with payments
|
|
9
10
|
* @handle /api/content/payments
|
|
@@ -35,7 +36,9 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
35
36
|
limit,
|
|
36
37
|
};
|
|
37
38
|
const result = await this._fetchGet('/sessions/?' + this._queryParamsToString(query));
|
|
38
|
-
|
|
39
|
+
// Validate response if validation is enabled
|
|
40
|
+
const validated = this._validateResponse(result, paymentsSchemas_1.PaymentSessionsResponseSchema);
|
|
41
|
+
return validated;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
44
|
* Get a single payment session object by its identifier.
|
|
@@ -61,7 +64,9 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
61
64
|
*/
|
|
62
65
|
async getSessionByOrderId(id) {
|
|
63
66
|
const result = await this._fetchGet(`/sessions/order/${id}`);
|
|
64
|
-
|
|
67
|
+
// Validate response if validation is enabled
|
|
68
|
+
const validated = this._validateResponse(result, paymentsSchemas_1.SinglePaymentSessionSchema);
|
|
69
|
+
return validated;
|
|
65
70
|
}
|
|
66
71
|
/**
|
|
67
72
|
* Creation of payment session.
|
|
@@ -80,7 +85,9 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
80
85
|
type,
|
|
81
86
|
automaticTaxEnabled,
|
|
82
87
|
});
|
|
83
|
-
|
|
88
|
+
// Validate response if validation is enabled
|
|
89
|
+
const validated = this._validateResponse(result, paymentsSchemas_1.CreateSessionResponseSchema);
|
|
90
|
+
return validated;
|
|
84
91
|
}
|
|
85
92
|
/**
|
|
86
93
|
* Get all payment accounts as an array.
|
|
@@ -92,7 +99,9 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
92
99
|
*/
|
|
93
100
|
async getAccounts() {
|
|
94
101
|
const result = await this._fetchGet('/accounts');
|
|
95
|
-
|
|
102
|
+
// Validate response if validation is enabled
|
|
103
|
+
const validated = this._validateResponse(result, paymentsSchemas_1.PaymentAccountsResponseSchema);
|
|
104
|
+
return this._normalizeData(validated);
|
|
96
105
|
}
|
|
97
106
|
/**
|
|
98
107
|
* Get a single payment account object by its identifier.
|
|
@@ -20,7 +20,7 @@ interface IPaymentsApi {
|
|
|
20
20
|
* @description This method gets list of payment sessions. This method requires user authorization.
|
|
21
21
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
22
22
|
*/
|
|
23
|
-
getSessions(offset
|
|
23
|
+
getSessions(offset?: number, limit?: number): Promise<ISessionsEntity | IError>;
|
|
24
24
|
/**
|
|
25
25
|
* Get a single payment session object by its identifier.
|
|
26
26
|
* @handleName getSessionById
|
|
@@ -76,7 +76,7 @@ interface IPaymentsApi {
|
|
|
76
76
|
/**
|
|
77
77
|
* @interface ISessionsEntity
|
|
78
78
|
* @property {number} total - Total number of found records. Example: 100.
|
|
79
|
-
* @property {ISessionEntity} items - Array of session objects.
|
|
79
|
+
* @property {ISessionEntity[]} items - Array of session objects.
|
|
80
80
|
* @example
|
|
81
81
|
[
|
|
82
82
|
{
|
|
@@ -94,7 +94,7 @@ interface IPaymentsApi {
|
|
|
94
94
|
*/
|
|
95
95
|
interface ISessionsEntity {
|
|
96
96
|
total: number;
|
|
97
|
-
items: ISessionEntity;
|
|
97
|
+
items: ISessionEntity[];
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* @interface ISessionEntity
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Payment session schema
|
|
4
|
+
* @description Zod schema for validating payment session responses
|
|
5
|
+
*/
|
|
6
|
+
export declare const PaymentSessionSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
8
|
+
orderId: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
orderIdentifier: z.ZodOptional<z.ZodString>;
|
|
10
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
12
|
+
status: z.ZodString;
|
|
13
|
+
paymentMethod: z.ZodOptional<z.ZodString>;
|
|
14
|
+
createdDate: z.ZodOptional<z.ZodString>;
|
|
15
|
+
updatedDate: z.ZodOptional<z.ZodString>;
|
|
16
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
17
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
18
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
19
|
+
type: z.ZodOptional<z.ZodString>;
|
|
20
|
+
paymentAccountId: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
paymentUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* Payment sessions response schema
|
|
25
|
+
* @description Paginated response schema for payment sessions
|
|
26
|
+
*/
|
|
27
|
+
export declare const PaymentSessionsResponseSchema: z.ZodObject<{
|
|
28
|
+
items: z.ZodArray<z.ZodObject<{
|
|
29
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
30
|
+
orderId: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
orderIdentifier: z.ZodOptional<z.ZodString>;
|
|
32
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
34
|
+
status: z.ZodString;
|
|
35
|
+
paymentMethod: z.ZodOptional<z.ZodString>;
|
|
36
|
+
createdDate: z.ZodOptional<z.ZodString>;
|
|
37
|
+
updatedDate: z.ZodOptional<z.ZodString>;
|
|
38
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
39
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
40
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
41
|
+
type: z.ZodOptional<z.ZodString>;
|
|
42
|
+
paymentAccountId: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
paymentUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
total: z.ZodNumber;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
/**
|
|
48
|
+
* Single payment session response schema
|
|
49
|
+
* @description Schema for a single payment session
|
|
50
|
+
*/
|
|
51
|
+
export declare const SinglePaymentSessionSchema: z.ZodObject<{
|
|
52
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
53
|
+
orderId: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
orderIdentifier: z.ZodOptional<z.ZodString>;
|
|
55
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
57
|
+
status: z.ZodString;
|
|
58
|
+
paymentMethod: z.ZodOptional<z.ZodString>;
|
|
59
|
+
createdDate: z.ZodOptional<z.ZodString>;
|
|
60
|
+
updatedDate: z.ZodOptional<z.ZodString>;
|
|
61
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
62
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
63
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
64
|
+
type: z.ZodOptional<z.ZodString>;
|
|
65
|
+
paymentAccountId: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
paymentUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/**
|
|
69
|
+
* Payment account schema
|
|
70
|
+
* @description Schema for a payment account
|
|
71
|
+
*/
|
|
72
|
+
export declare const PaymentAccountSchema: z.ZodObject<{
|
|
73
|
+
id: z.ZodNumber;
|
|
74
|
+
identifier: z.ZodOptional<z.ZodString>;
|
|
75
|
+
marker: z.ZodOptional<z.ZodString>;
|
|
76
|
+
name: z.ZodOptional<z.ZodString>;
|
|
77
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
isVisible: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
isUsed: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
testMode: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
82
|
+
type: z.ZodOptional<z.ZodString>;
|
|
83
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
84
|
+
settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
85
|
+
testSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
86
|
+
localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
87
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
updatedDate: z.ZodOptional<z.ZodString>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
/**
|
|
91
|
+
* Payment accounts response schema
|
|
92
|
+
*/
|
|
93
|
+
export declare const PaymentAccountsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
94
|
+
id: z.ZodNumber;
|
|
95
|
+
identifier: z.ZodOptional<z.ZodString>;
|
|
96
|
+
marker: z.ZodOptional<z.ZodString>;
|
|
97
|
+
name: z.ZodOptional<z.ZodString>;
|
|
98
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
isVisible: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
isUsed: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
testMode: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
103
|
+
type: z.ZodOptional<z.ZodString>;
|
|
104
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
105
|
+
settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
106
|
+
testSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
107
|
+
localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
108
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
updatedDate: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
/**
|
|
112
|
+
* Create session response schema
|
|
113
|
+
*/
|
|
114
|
+
export declare const CreateSessionResponseSchema: z.ZodObject<{
|
|
115
|
+
id: z.ZodString;
|
|
116
|
+
url: z.ZodOptional<z.ZodString>;
|
|
117
|
+
status: z.ZodString;
|
|
118
|
+
amount: z.ZodNumber;
|
|
119
|
+
currency: z.ZodString;
|
|
120
|
+
createdAt: z.ZodString;
|
|
121
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateSessionResponseSchema = exports.PaymentAccountsResponseSchema = exports.PaymentAccountSchema = exports.SinglePaymentSessionSchema = exports.PaymentSessionsResponseSchema = exports.PaymentSessionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Payment session schema
|
|
7
|
+
* @description Zod schema for validating payment session responses
|
|
8
|
+
*/
|
|
9
|
+
exports.PaymentSessionSchema = zod_1.z.object({
|
|
10
|
+
id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]),
|
|
11
|
+
orderId: zod_1.z.number().optional(),
|
|
12
|
+
orderIdentifier: zod_1.z.string().optional(),
|
|
13
|
+
amount: zod_1.z.number().optional(),
|
|
14
|
+
currency: zod_1.z.string().optional(),
|
|
15
|
+
status: zod_1.z.string(),
|
|
16
|
+
paymentMethod: zod_1.z.string().optional(),
|
|
17
|
+
createdDate: zod_1.z.string().optional(),
|
|
18
|
+
updatedDate: zod_1.z.string().optional(),
|
|
19
|
+
createdAt: zod_1.z.string().optional(),
|
|
20
|
+
expiresAt: zod_1.z.string().optional(),
|
|
21
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
22
|
+
type: zod_1.z.string().optional(),
|
|
23
|
+
paymentAccountId: zod_1.z.number().optional(),
|
|
24
|
+
paymentUrl: zod_1.z.string().nullable().optional(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Payment sessions response schema
|
|
28
|
+
* @description Paginated response schema for payment sessions
|
|
29
|
+
*/
|
|
30
|
+
exports.PaymentSessionsResponseSchema = zod_1.z.object({
|
|
31
|
+
items: zod_1.z.array(exports.PaymentSessionSchema),
|
|
32
|
+
total: zod_1.z.number(),
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Single payment session response schema
|
|
36
|
+
* @description Schema for a single payment session
|
|
37
|
+
*/
|
|
38
|
+
exports.SinglePaymentSessionSchema = exports.PaymentSessionSchema;
|
|
39
|
+
/**
|
|
40
|
+
* Payment account schema
|
|
41
|
+
* @description Schema for a payment account
|
|
42
|
+
*/
|
|
43
|
+
exports.PaymentAccountSchema = zod_1.z.object({
|
|
44
|
+
id: zod_1.z.number(),
|
|
45
|
+
identifier: zod_1.z.string().optional(),
|
|
46
|
+
marker: zod_1.z.string().optional(),
|
|
47
|
+
name: zod_1.z.string().optional(),
|
|
48
|
+
isActive: zod_1.z.boolean().optional(),
|
|
49
|
+
isVisible: zod_1.z.boolean().optional(),
|
|
50
|
+
isUsed: zod_1.z.boolean().optional(),
|
|
51
|
+
testMode: zod_1.z.boolean().optional(),
|
|
52
|
+
provider: zod_1.z.string().optional(),
|
|
53
|
+
type: zod_1.z.string().optional(),
|
|
54
|
+
config: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
55
|
+
settings: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
56
|
+
testSettings: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
57
|
+
localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
58
|
+
position: zod_1.z.number().optional(),
|
|
59
|
+
updatedDate: zod_1.z.string().optional(),
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Payment accounts response schema
|
|
63
|
+
*/
|
|
64
|
+
exports.PaymentAccountsResponseSchema = zod_1.z.array(exports.PaymentAccountSchema);
|
|
65
|
+
/**
|
|
66
|
+
* Create session response schema
|
|
67
|
+
*/
|
|
68
|
+
exports.CreateSessionResponseSchema = zod_1.z.object({
|
|
69
|
+
id: zod_1.z.string(),
|
|
70
|
+
url: zod_1.z.string().optional(),
|
|
71
|
+
status: zod_1.z.string(),
|
|
72
|
+
amount: zod_1.z.number(),
|
|
73
|
+
currency: zod_1.z.string(),
|
|
74
|
+
createdAt: zod_1.z.string(),
|
|
75
|
+
});
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
|
+
const productStatusesSchemas_1 = require("./productStatusesSchemas");
|
|
7
8
|
/**
|
|
8
9
|
* Controllers for working with product statuses
|
|
9
10
|
* @handle /api/content/product-statuses
|
|
@@ -29,7 +30,9 @@ class ProductStatusesApi extends asyncModules_1.default {
|
|
|
29
30
|
*/
|
|
30
31
|
async getProductStatuses(langCode = this.state.lang) {
|
|
31
32
|
const result = await this._fetchGet('');
|
|
32
|
-
|
|
33
|
+
// Validate response if validation is enabled
|
|
34
|
+
const validated = this._validateResponse(result, productStatusesSchemas_1.ProductStatusesResponseSchema);
|
|
35
|
+
return this._normalizeData(validated, langCode);
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
38
|
* Search for a product status object by its textual identifier (marker).
|
|
@@ -42,7 +45,9 @@ class ProductStatusesApi extends asyncModules_1.default {
|
|
|
42
45
|
*/
|
|
43
46
|
async getProductsByStatusMarker(marker, langCode = this.state.lang) {
|
|
44
47
|
const result = await this._fetchGet(`/marker/${marker}`);
|
|
45
|
-
|
|
48
|
+
// Validate response if validation is enabled
|
|
49
|
+
const validated = this._validateResponse(result, productStatusesSchemas_1.ProductStatusEntitySchema);
|
|
50
|
+
return this._normalizeData(validated, langCode);
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* Check the existence of a textual identifier.
|
|
@@ -54,7 +59,12 @@ class ProductStatusesApi extends asyncModules_1.default {
|
|
|
54
59
|
*/
|
|
55
60
|
async validateMarker(marker) {
|
|
56
61
|
const result = await this._fetchGet(`/marker-validation/${marker}`);
|
|
57
|
-
|
|
62
|
+
// Validate response if validation is enabled
|
|
63
|
+
const validated = this._validateResponse(result, productStatusesSchemas_1.ValidateMarkerResponseSchema);
|
|
64
|
+
// Extract the 'valid' boolean value from the response object
|
|
65
|
+
return typeof validated === 'object' && 'valid' in validated
|
|
66
|
+
? validated.valid
|
|
67
|
+
: validated;
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
exports.default = ProductStatusesApi;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation schemas for ProductStatuses module
|
|
3
|
+
* @description Zod schemas for validating product statuses-related API responses
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Product status entity schema
|
|
8
|
+
* Includes all fields returned by the API
|
|
9
|
+
*/
|
|
10
|
+
export declare const ProductStatusEntitySchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodNumber;
|
|
12
|
+
identifier: z.ZodString;
|
|
13
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
14
|
+
isDefault: z.ZodBoolean;
|
|
15
|
+
version: z.ZodNumber;
|
|
16
|
+
position: z.ZodNumber;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
/**
|
|
19
|
+
* Product statuses response schema (array of product statuses)
|
|
20
|
+
*/
|
|
21
|
+
export declare const ProductStatusesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
22
|
+
id: z.ZodNumber;
|
|
23
|
+
identifier: z.ZodString;
|
|
24
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
25
|
+
isDefault: z.ZodBoolean;
|
|
26
|
+
version: z.ZodNumber;
|
|
27
|
+
position: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
/**
|
|
30
|
+
* Validate marker response schema (object with valid property)
|
|
31
|
+
*/
|
|
32
|
+
export declare const ValidateMarkerResponseSchema: z.ZodObject<{
|
|
33
|
+
valid: z.ZodBoolean;
|
|
34
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateMarkerResponseSchema = exports.ProductStatusesResponseSchema = exports.ProductStatusEntitySchema = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validation schemas for ProductStatuses module
|
|
6
|
+
* @description Zod schemas for validating product statuses-related API responses
|
|
7
|
+
*/
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
/**
|
|
10
|
+
* Product status entity schema
|
|
11
|
+
* Includes all fields returned by the API
|
|
12
|
+
*/
|
|
13
|
+
exports.ProductStatusEntitySchema = zod_1.z.object({
|
|
14
|
+
id: zod_1.z.number(),
|
|
15
|
+
identifier: zod_1.z.string(),
|
|
16
|
+
localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
17
|
+
isDefault: zod_1.z.boolean(),
|
|
18
|
+
version: zod_1.z.number(),
|
|
19
|
+
position: zod_1.z.number(),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Product statuses response schema (array of product statuses)
|
|
23
|
+
*/
|
|
24
|
+
exports.ProductStatusesResponseSchema = zod_1.z.array(exports.ProductStatusEntitySchema);
|
|
25
|
+
/**
|
|
26
|
+
* Validate marker response schema (object with valid property)
|
|
27
|
+
*/
|
|
28
|
+
exports.ValidateMarkerResponseSchema = zod_1.z.object({
|
|
29
|
+
valid: zod_1.z.boolean(),
|
|
30
|
+
});
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/* eslint-disable jsdoc/reject-any-type */
|
|
7
7
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
8
|
+
const productsSchemas_1 = require("./productsSchemas");
|
|
8
9
|
/**
|
|
9
10
|
* Controllers for working with product pages
|
|
10
11
|
* @handle /api/content/products
|
|
@@ -79,7 +80,9 @@ class ProductApi extends asyncModules_1.default {
|
|
|
79
80
|
langCode,
|
|
80
81
|
};
|
|
81
82
|
const result = await this._fetchPost(`/all?` + this._queryParamsToString(query), body);
|
|
82
|
-
|
|
83
|
+
// Validate response if validation is enabled
|
|
84
|
+
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
85
|
+
return this._dataPostProcess(validated, langCode);
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
88
|
* Search for all product page objects with pagination that do not have a category.
|
|
@@ -105,7 +108,9 @@ class ProductApi extends asyncModules_1.default {
|
|
|
105
108
|
async getProductsEmptyPage(langCode = this.state.lang, userQuery) {
|
|
106
109
|
const query = { ...this._defaultQuery, ...userQuery };
|
|
107
110
|
const result = await this._fetchGet(`/empty-page?langCode=${langCode}&` + this._queryParamsToString(query));
|
|
108
|
-
|
|
111
|
+
// Validate response if validation is enabled
|
|
112
|
+
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
113
|
+
return this._dataPostProcess(validated, langCode);
|
|
109
114
|
}
|
|
110
115
|
/**
|
|
111
116
|
* Search for all products with pagination for the selected category.
|
|
@@ -157,7 +162,9 @@ class ProductApi extends asyncModules_1.default {
|
|
|
157
162
|
async getProductsByPageId(id, body = [], langCode = this.state.lang, userQuery) {
|
|
158
163
|
const query = { ...this._defaultQuery, ...userQuery };
|
|
159
164
|
const result = await this._fetchPost(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query), body);
|
|
160
|
-
|
|
165
|
+
// Validate response if validation is enabled
|
|
166
|
+
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
167
|
+
return this._dataPostProcess(validated, langCode);
|
|
161
168
|
}
|
|
162
169
|
/**
|
|
163
170
|
* Search for information about products and prices for the selected category.
|
|
@@ -241,7 +248,9 @@ class ProductApi extends asyncModules_1.default {
|
|
|
241
248
|
const query = { ...this._defaultQuery, ...userQuery };
|
|
242
249
|
const result = await this._fetchPost(`/page/url/${url}?langCode=${langCode}&` +
|
|
243
250
|
this._queryParamsToString(query), body);
|
|
244
|
-
|
|
251
|
+
// Validate response if validation is enabled
|
|
252
|
+
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
253
|
+
return this._dataPostProcess(validated, langCode);
|
|
245
254
|
}
|
|
246
255
|
/**
|
|
247
256
|
* Find all related product page objects.
|
|
@@ -272,7 +281,9 @@ class ProductApi extends asyncModules_1.default {
|
|
|
272
281
|
async getRelatedProductsById(id, langCode = this.state.lang, userQuery) {
|
|
273
282
|
const query = { ...this._defaultQuery, ...userQuery };
|
|
274
283
|
const result = await this._fetchGet(`/${id}/related?langCode=${langCode}&` + this._queryParamsToString(query));
|
|
275
|
-
|
|
284
|
+
// Validate response if validation is enabled
|
|
285
|
+
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
286
|
+
return this._dataPostProcess(validated, langCode);
|
|
276
287
|
}
|
|
277
288
|
/**
|
|
278
289
|
* Find products by its ids.
|
|
@@ -326,7 +337,9 @@ class ProductApi extends asyncModules_1.default {
|
|
|
326
337
|
*/
|
|
327
338
|
async getProductById(id, langCode = this.state.lang) {
|
|
328
339
|
const result = await this._fetchGet(`/${id}?langCode=${langCode}`);
|
|
329
|
-
|
|
340
|
+
// Validate response if validation is enabled
|
|
341
|
+
const validated = this._validateResponse(result, productsSchemas_1.ProductEntitySchema);
|
|
342
|
+
return this._dataPostProcess(validated, langCode);
|
|
330
343
|
}
|
|
331
344
|
/**
|
|
332
345
|
* Getting a product block object by product id.
|
|
@@ -231,7 +231,7 @@ interface IProductApi {
|
|
|
231
231
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
232
232
|
* @description This method performs a quick search for product page objects with limited output.
|
|
233
233
|
*/
|
|
234
|
-
searchProduct(name: string, langCode
|
|
234
|
+
searchProduct(name: string, langCode?: string): Promise<IProductsEntity[] | IError>;
|
|
235
235
|
/**
|
|
236
236
|
* Getting the number of products for the entire catalog.
|
|
237
237
|
* @handleName getProductsCount
|
|
@@ -263,7 +263,7 @@ interface IProductApi {
|
|
|
263
263
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
264
264
|
* @description This method calculates and returns the total number of products present across the entire catalog, optionally applying specified filters.
|
|
265
265
|
*/
|
|
266
|
-
getProductsCount(body
|
|
266
|
+
getProductsCount(body?: any): Promise<IProductsCount | IError>;
|
|
267
267
|
/**
|
|
268
268
|
* Getting the number of products on a catalog page by page ID.
|
|
269
269
|
* @handleName getProductsCountByPageId
|
|
@@ -296,7 +296,7 @@ interface IProductApi {
|
|
|
296
296
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
297
297
|
* @description This method calculates and returns the number of products available on a given catalog page, identified by its page ID, with optional filtering.
|
|
298
298
|
*/
|
|
299
|
-
getProductsCountByPageId(id: string, body
|
|
299
|
+
getProductsCountByPageId(id: string, body?: any): Promise<IProductsCount | IError>;
|
|
300
300
|
/**
|
|
301
301
|
* Getting the number of products on a catalog page by page URL.
|
|
302
302
|
* @handleName getProductsCountByPageUrl
|
|
@@ -329,7 +329,7 @@ interface IProductApi {
|
|
|
329
329
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
330
330
|
* @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
|
|
331
331
|
*/
|
|
332
|
-
getProductsCountByPageUrl(url: string, body
|
|
332
|
+
getProductsCountByPageUrl(url: string, body?: any): Promise<IProductsCount | IError>;
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
335
335
|
* @interface IProductsQuery
|