@unchainedshop/core 4.8.4 → 5.0.0-alpha.1
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/lib/bulk-exporter/createBulkExporter.d.ts +2 -2
- package/lib/bulk-exporter/createBulkExporter.js +2 -2
- package/lib/bulk-exporter/handlers/exportAssortmentsHandler.d.ts +19 -19
- package/lib/bulk-exporter/handlers/exportAssortmentsHandler.js +9 -9
- package/lib/bulk-exporter/handlers/exportFiltersHandler.d.ts +11 -11
- package/lib/bulk-exporter/handlers/exportFiltersHandler.js +5 -5
- package/lib/bulk-exporter/handlers/exportProductsHandler.d.ts +19 -19
- package/lib/bulk-exporter/handlers/exportProductsHandler.js +9 -9
- package/lib/bulk-exporter/handlers/exportUsersHandler.d.ts +17 -17
- package/lib/bulk-exporter/handlers/exportUsersHandler.js +8 -8
- package/lib/bulk-importer/createBulkImporter.js +6 -6
- package/lib/bulk-importer/handlers/product/create.d.ts +3 -3
- package/lib/bulk-importer/handlers/product/create.js +2 -2
- package/lib/bulk-importer/handlers/product/update.d.ts +3 -3
- package/lib/bulk-importer/handlers/product/update.js +1 -1
- package/lib/core-index.d.ts +3 -0
- package/lib/core-index.js +6 -2
- package/lib/directors/BaseDiscountDirector.js +6 -6
- package/lib/directors/BasePricingDirector.js +1 -1
- package/lib/directors/DeliveryAdapter.js +1 -0
- package/lib/directors/DeliveryDirector.js +11 -2
- package/lib/directors/DeliveryPricingAdapter.d.ts +2 -1
- package/lib/directors/DeliveryPricingAdapter.js +2 -1
- package/lib/directors/DeliveryPricingDirector.d.ts +1 -1
- package/lib/directors/DeliveryPricingDirector.js +12 -2
- package/lib/directors/DeliveryPricingSheet.d.ts +1 -1
- package/lib/directors/DeliveryPricingSheet.js +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -0
- package/lib/directors/EnrollmentDirector.js +11 -1
- package/lib/directors/FilterAdapter.js +1 -0
- package/lib/directors/FilterDirector.js +11 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +3 -2
- package/lib/directors/OrderDiscountAdapter.js +5 -2
- package/lib/directors/OrderDiscountDirector.d.ts +15 -1
- package/lib/directors/OrderDiscountDirector.js +14 -1
- package/lib/directors/OrderPricingAdapter.d.ts +2 -1
- package/lib/directors/OrderPricingAdapter.js +3 -1
- package/lib/directors/OrderPricingDirector.d.ts +4 -1
- package/lib/directors/OrderPricingDirector.js +12 -1
- package/lib/directors/OrderPricingSheet.d.ts +1 -1
- package/lib/directors/OrderPricingSheet.js +1 -1
- package/lib/directors/PaymentAdapter.js +1 -0
- package/lib/directors/PaymentDirector.js +11 -2
- package/lib/directors/PaymentPricingAdapter.d.ts +2 -1
- package/lib/directors/PaymentPricingAdapter.js +2 -1
- package/lib/directors/PaymentPricingDirector.d.ts +2 -1
- package/lib/directors/PaymentPricingDirector.js +11 -1
- package/lib/directors/PaymentPricingSheet.d.ts +2 -1
- package/lib/directors/PaymentPricingSheet.js +2 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +3 -2
- package/lib/directors/ProductDiscountAdapter.js +5 -2
- package/lib/directors/ProductDiscountDirector.d.ts +16 -2
- package/lib/directors/ProductDiscountDirector.js +15 -2
- package/lib/directors/ProductPricingAdapter.d.ts +2 -1
- package/lib/directors/ProductPricingAdapter.js +3 -1
- package/lib/directors/ProductPricingDirector.d.ts +3 -1
- package/lib/directors/ProductPricingDirector.js +12 -1
- package/lib/directors/ProductPricingSheet.d.ts +1 -1
- package/lib/directors/ProductPricingSheet.js +1 -1
- package/lib/directors/QuotationAdapter.js +1 -0
- package/lib/directors/QuotationDirector.js +11 -2
- package/lib/directors/WarehousingAdapter.js +1 -0
- package/lib/directors/WarehousingDirector.d.ts +1 -1
- package/lib/directors/WarehousingDirector.js +12 -2
- package/lib/directors/WorkerAdapter.js +1 -0
- package/lib/directors/WorkerDirector.d.ts +1 -1
- package/lib/directors/WorkerDirector.js +10 -17
- package/lib/directors/index.d.ts +2 -0
- package/lib/directors/index.js +2 -0
- package/lib/factory/registerAssortmentSearchFilter.d.ts +2 -1
- package/lib/factory/registerAssortmentSearchFilter.js +12 -3
- package/lib/factory/registerInvoicePayment.d.ts +2 -2
- package/lib/factory/registerInvoicePayment.js +12 -3
- package/lib/factory/registerPhysicalWarehousing.d.ts +2 -2
- package/lib/factory/registerPhysicalWarehousing.js +12 -3
- package/lib/factory/registerPickUpDelivery.d.ts +2 -2
- package/lib/factory/registerPickUpDelivery.js +12 -3
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts +2 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js +12 -3
- package/lib/factory/registerProductSearchFilter.d.ts +2 -1
- package/lib/factory/registerProductSearchFilter.js +12 -3
- package/lib/factory/registerShippingDelivery.d.ts +2 -2
- package/lib/factory/registerShippingDelivery.js +12 -3
- package/lib/factory/registerVirtualWarehousing.d.ts +2 -2
- package/lib/factory/registerVirtualWarehousing.js +12 -3
- package/lib/factory/registerWorker.d.ts +2 -1
- package/lib/factory/registerWorker.js +12 -3
- package/lib/services/createDownloadStream.js +1 -1
- package/lib/services/createFileDownloadURL.js +2 -1
- package/lib/services/createSignedURL.js +2 -1
- package/lib/services/linkFileService.js +1 -1
- package/lib/services/removeFiles.js +1 -1
- package/lib/services/uploadFileFromStream.js +2 -1
- package/lib/services/uploadFileFromURL.js +2 -1
- package/package.json +20 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import exportProductsHandler from './handlers/exportProductsHandler.ts';
|
|
2
2
|
import exportAssortmentsHandler from './handlers/exportAssortmentsHandler.ts';
|
|
3
3
|
import exportFiltersHandler from './handlers/exportFiltersHandler.ts';
|
|
4
|
-
import { z } from 'zod
|
|
4
|
+
import { z } from 'zod';
|
|
5
5
|
import type { CSVFileResult } from './handlers/generateCSVFileAndUrl.ts';
|
|
6
6
|
export declare const EXPORTS_DIRECTORY = "exports";
|
|
7
7
|
export type ExportFiles = Record<string, CSVFileResult | null>;
|
|
@@ -11,7 +11,7 @@ export interface BulkExportOperationResult {
|
|
|
11
11
|
files: ExportFiles;
|
|
12
12
|
}
|
|
13
13
|
export interface BulkExportHandler<T = unknown> {
|
|
14
|
-
payloadSchema?: z.
|
|
14
|
+
payloadSchema?: z.ZodObject<z.ZodRawShape>;
|
|
15
15
|
(params: Record<string, unknown>, locales: string[], unchainedAPI: T): Promise<ExportFiles>;
|
|
16
16
|
}
|
|
17
17
|
export interface BulkExporterOptions {
|
|
@@ -2,7 +2,7 @@ import exportProductsHandler from "./handlers/exportProductsHandler.js";
|
|
|
2
2
|
import exportAssortmentsHandler from "./handlers/exportAssortmentsHandler.js";
|
|
3
3
|
import exportFiltersHandler from "./handlers/exportFiltersHandler.js";
|
|
4
4
|
import { createLogger } from '@unchainedshop/logger';
|
|
5
|
-
import { z } from 'zod
|
|
5
|
+
import { z } from 'zod';
|
|
6
6
|
import exportUsersHandler from "./handlers/exportUsersHandler.js";
|
|
7
7
|
const logger = createLogger('unchained:bulk-export');
|
|
8
8
|
export const EXPORTS_DIRECTORY = 'exports';
|
|
@@ -30,7 +30,7 @@ export default function createBulkExporterFactory(bulkExporterOptions) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
catch (e) {
|
|
33
|
-
throw new Error(`${type}: ${e.message}
|
|
33
|
+
throw new Error(`${type}: ${e.message}`);
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
execute: async (payload, locales, unchainedApi) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { UnchainedCore } from '../../core-index.ts';
|
|
2
|
-
import { z } from 'zod
|
|
3
|
-
export declare const AssortmentExportPayloadSchema: z.
|
|
4
|
-
exportAssortments: z.
|
|
5
|
-
exportLinks: z.
|
|
6
|
-
exportProducts: z.
|
|
7
|
-
exportFilters: z.
|
|
8
|
-
queryString: z.
|
|
9
|
-
includeInactive: z.
|
|
10
|
-
includeLeaves: z.
|
|
11
|
-
tags: z.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const AssortmentExportPayloadSchema: z.ZodObject<{
|
|
4
|
+
exportAssortments: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
exportLinks: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
exportProducts: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
exportFilters: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
9
|
+
includeInactive: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
includeLeaves: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
12
|
}, z.core.$strip>;
|
|
13
13
|
export interface AssortmentExportParams {
|
|
14
14
|
exportAssortments?: boolean;
|
|
@@ -24,15 +24,15 @@ declare const exportAssortmentsHandler: {
|
|
|
24
24
|
products: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
25
25
|
children: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
26
26
|
}>;
|
|
27
|
-
payloadSchema: z.
|
|
28
|
-
exportAssortments: z.
|
|
29
|
-
exportLinks: z.
|
|
30
|
-
exportProducts: z.
|
|
31
|
-
exportFilters: z.
|
|
32
|
-
queryString: z.
|
|
33
|
-
includeInactive: z.
|
|
34
|
-
includeLeaves: z.
|
|
35
|
-
tags: z.
|
|
27
|
+
payloadSchema: z.ZodObject<{
|
|
28
|
+
exportAssortments: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
exportLinks: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
exportProducts: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
exportFilters: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
33
|
+
includeInactive: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
includeLeaves: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
36
|
}, z.core.$strip>;
|
|
37
37
|
};
|
|
38
38
|
export default exportAssortmentsHandler;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import generateCSVFileAndURL from "./generateCSVFileAndUrl.js";
|
|
2
|
-
import { z } from 'zod
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { EXPORTS_DIRECTORY } from "../createBulkExporter.js";
|
|
4
4
|
export const AssortmentExportPayloadSchema = z.object({
|
|
5
|
-
exportAssortments: z.
|
|
6
|
-
exportLinks: z.
|
|
7
|
-
exportProducts: z.
|
|
8
|
-
exportFilters: z.
|
|
9
|
-
queryString: z.
|
|
10
|
-
includeInactive: z.
|
|
11
|
-
includeLeaves: z.
|
|
12
|
-
tags: z.
|
|
5
|
+
exportAssortments: z.boolean().optional(),
|
|
6
|
+
exportLinks: z.boolean().optional(),
|
|
7
|
+
exportProducts: z.boolean().optional(),
|
|
8
|
+
exportFilters: z.boolean().optional(),
|
|
9
|
+
queryString: z.string().optional(),
|
|
10
|
+
includeInactive: z.boolean().optional(),
|
|
11
|
+
includeLeaves: z.boolean().optional(),
|
|
12
|
+
tags: z.array(z.string()).optional(),
|
|
13
13
|
});
|
|
14
14
|
const ASSORTMENT_CSV_SCHEMA = {
|
|
15
15
|
base: ['_id', 'isActive', 'isBase', 'isRoot', 'sequence', 'tags'],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { UnchainedCore } from '../../core-index.ts';
|
|
2
|
-
import { z } from 'zod
|
|
3
|
-
export declare const FilterExportPayloadSchema: z.
|
|
4
|
-
exportFilters: z.
|
|
5
|
-
exportFilterOptions: z.
|
|
6
|
-
queryString: z.
|
|
7
|
-
includeInactive: z.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const FilterExportPayloadSchema: z.ZodObject<{
|
|
4
|
+
exportFilters: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
exportFilterOptions: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
7
|
+
includeInactive: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
}, z.core.$strip>;
|
|
9
9
|
export interface FilterExportParams {
|
|
10
10
|
exportFilters?: boolean;
|
|
@@ -16,11 +16,11 @@ declare const exportFiltersHandler: {
|
|
|
16
16
|
filters: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
17
17
|
filterOptions: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
18
18
|
}>;
|
|
19
|
-
payloadSchema: z.
|
|
20
|
-
exportFilters: z.
|
|
21
|
-
exportFilterOptions: z.
|
|
22
|
-
queryString: z.
|
|
23
|
-
includeInactive: z.
|
|
19
|
+
payloadSchema: z.ZodObject<{
|
|
20
|
+
exportFilters: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
exportFilterOptions: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
23
|
+
includeInactive: z.ZodOptional<z.ZodBoolean>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
};
|
|
26
26
|
export default exportFiltersHandler;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import generateCSVFileAndURL from "./generateCSVFileAndUrl.js";
|
|
2
|
-
import { z } from 'zod
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { EXPORTS_DIRECTORY } from "../createBulkExporter.js";
|
|
4
4
|
export const FilterExportPayloadSchema = z.object({
|
|
5
|
-
exportFilters: z.
|
|
6
|
-
exportFilterOptions: z.
|
|
7
|
-
queryString: z.
|
|
8
|
-
includeInactive: z.
|
|
5
|
+
exportFilters: z.boolean().optional(),
|
|
6
|
+
exportFilterOptions: z.boolean().optional(),
|
|
7
|
+
queryString: z.string().optional(),
|
|
8
|
+
includeInactive: z.boolean().optional(),
|
|
9
9
|
});
|
|
10
10
|
const FILTER_CSV_SCHEMA = {
|
|
11
11
|
filterFields: ['_id', 'key', 'type', 'isActive'],
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { UnchainedCore } from '../../core-index.ts';
|
|
2
|
-
import { z } from 'zod
|
|
3
|
-
export declare const ProductExportPayloadSchema: z.
|
|
4
|
-
exportProducts: z.
|
|
5
|
-
exportBundleItems: z.
|
|
6
|
-
exportPrices: z.
|
|
7
|
-
exportVariations: z.
|
|
8
|
-
exportVariationOptions: z.
|
|
9
|
-
queryString: z.
|
|
10
|
-
includeDrafts: z.
|
|
11
|
-
tags: z.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const ProductExportPayloadSchema: z.ZodObject<{
|
|
4
|
+
exportProducts: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
exportBundleItems: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
exportPrices: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
exportVariations: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
exportVariationOptions: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
10
|
+
includeDrafts: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
12
|
}, z.core.$strip>;
|
|
13
13
|
export interface ProductExportParams {
|
|
14
14
|
exportProducts?: boolean;
|
|
@@ -26,15 +26,15 @@ declare const exportProductsHandler: {
|
|
|
26
26
|
variations: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
27
27
|
variationOptions: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
28
28
|
}>;
|
|
29
|
-
payloadSchema: z.
|
|
30
|
-
exportProducts: z.
|
|
31
|
-
exportBundleItems: z.
|
|
32
|
-
exportPrices: z.
|
|
33
|
-
exportVariations: z.
|
|
34
|
-
exportVariationOptions: z.
|
|
35
|
-
queryString: z.
|
|
36
|
-
includeDrafts: z.
|
|
37
|
-
tags: z.
|
|
29
|
+
payloadSchema: z.ZodObject<{
|
|
30
|
+
exportProducts: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
exportBundleItems: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
exportPrices: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
exportVariations: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
exportVariationOptions: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
36
|
+
includeDrafts: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
38
|
}, z.core.$strip>;
|
|
39
39
|
};
|
|
40
40
|
export default exportProductsHandler;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import generateCSVFileAndURL from "./generateCSVFileAndUrl.js";
|
|
2
|
-
import { z } from 'zod
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { EXPORTS_DIRECTORY } from "../createBulkExporter.js";
|
|
4
4
|
export const ProductExportPayloadSchema = z.object({
|
|
5
|
-
exportProducts: z.
|
|
6
|
-
exportBundleItems: z.
|
|
7
|
-
exportPrices: z.
|
|
8
|
-
exportVariations: z.
|
|
9
|
-
exportVariationOptions: z.
|
|
10
|
-
queryString: z.
|
|
11
|
-
includeDrafts: z.
|
|
12
|
-
tags: z.
|
|
5
|
+
exportProducts: z.boolean().optional(),
|
|
6
|
+
exportBundleItems: z.boolean().optional(),
|
|
7
|
+
exportPrices: z.boolean().optional(),
|
|
8
|
+
exportVariations: z.boolean().optional(),
|
|
9
|
+
exportVariationOptions: z.boolean().optional(),
|
|
10
|
+
queryString: z.string().optional(),
|
|
11
|
+
includeDrafts: z.boolean().optional(),
|
|
12
|
+
tags: z.array(z.string()).optional(),
|
|
13
13
|
});
|
|
14
14
|
const PRODUCT_CSV_SCHEMA = {
|
|
15
15
|
base: ['_id', 'sku', 'baseUnit', 'sequence', 'status', 'tags', 'updated', 'published', 'type'],
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { UnchainedCore } from '../../core-index.ts';
|
|
2
|
-
import { z } from 'zod
|
|
3
|
-
export declare const UserExportPayloadSchema: z.
|
|
4
|
-
exportReviews: z.
|
|
5
|
-
exportOrders: z.
|
|
6
|
-
exportBookmarks: z.
|
|
7
|
-
exportEvents: z.
|
|
8
|
-
exportQuotations: z.
|
|
9
|
-
exportEnrollments: z.
|
|
10
|
-
userId: z.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const UserExportPayloadSchema: z.ZodObject<{
|
|
4
|
+
exportReviews: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
exportOrders: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
exportBookmarks: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
exportEvents: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
exportQuotations: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
exportEnrollments: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
export interface UserExportParams {
|
|
13
13
|
exportReviews?: boolean;
|
|
@@ -27,14 +27,14 @@ declare const exportUsersHandler: {
|
|
|
27
27
|
quotations: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
28
28
|
enrollments: import("./generateCSVFileAndUrl.ts").CSVFileResult | null;
|
|
29
29
|
}>;
|
|
30
|
-
payloadSchema: z.
|
|
31
|
-
exportReviews: z.
|
|
32
|
-
exportOrders: z.
|
|
33
|
-
exportBookmarks: z.
|
|
34
|
-
exportEvents: z.
|
|
35
|
-
exportQuotations: z.
|
|
36
|
-
exportEnrollments: z.
|
|
37
|
-
userId: z.
|
|
30
|
+
payloadSchema: z.ZodObject<{
|
|
31
|
+
exportReviews: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
exportOrders: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
exportBookmarks: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
exportEvents: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
exportQuotations: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
exportEnrollments: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
38
38
|
}, z.core.$strip>;
|
|
39
39
|
};
|
|
40
40
|
export default exportUsersHandler;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import generateCSVFileAndURL from "./generateCSVFileAndUrl.js";
|
|
2
|
-
import { z } from 'zod
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { EXPORTS_DIRECTORY } from "../createBulkExporter.js";
|
|
4
4
|
export const UserExportPayloadSchema = z.object({
|
|
5
|
-
exportReviews: z.
|
|
6
|
-
exportOrders: z.
|
|
7
|
-
exportBookmarks: z.
|
|
8
|
-
exportEvents: z.
|
|
9
|
-
exportQuotations: z.
|
|
10
|
-
exportEnrollments: z.
|
|
11
|
-
userId: z.
|
|
5
|
+
exportReviews: z.boolean().optional(),
|
|
6
|
+
exportOrders: z.boolean().optional(),
|
|
7
|
+
exportBookmarks: z.boolean().optional(),
|
|
8
|
+
exportEvents: z.boolean().optional(),
|
|
9
|
+
exportQuotations: z.boolean().optional(),
|
|
10
|
+
exportEnrollments: z.boolean().optional(),
|
|
11
|
+
userId: z.string().optional(),
|
|
12
12
|
});
|
|
13
13
|
const USER_CSV_SCHEMA = {
|
|
14
14
|
userFields: [
|
|
@@ -59,12 +59,12 @@ export default function createBulkImporterFactory(db, bulkImporterOptions) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
catch (e) {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const issues = e?.issues
|
|
63
|
+
? e.issues.map((i) => `${i.path?.join('.')}: ${i.message}`).join(', ')
|
|
64
|
+
: e.message;
|
|
65
|
+
throw new Error(`🤧 ${entity}.${operation}.${event.payload?._id || '*'} (${issues})`, {
|
|
66
|
+
cause: e,
|
|
67
|
+
});
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
prepare: async (event, unchainedAPI) => {
|
|
@@ -10,7 +10,7 @@ export declare const ProductCreateSpecificationSchema: z.ZodMiniObject<{
|
|
|
10
10
|
readonly TOKENIZED_PRODUCT: "TOKENIZED_PRODUCT";
|
|
11
11
|
}>;
|
|
12
12
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
13
|
-
status: z.
|
|
13
|
+
status: z.ZodMiniNullable<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
14
14
|
published: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
15
15
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
16
16
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -67,7 +67,7 @@ export declare const ProductCreatePayloadSchema: z.ZodMiniObject<{
|
|
|
67
67
|
readonly TOKENIZED_PRODUCT: "TOKENIZED_PRODUCT";
|
|
68
68
|
}>;
|
|
69
69
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
70
|
-
status: z.
|
|
70
|
+
status: z.ZodMiniNullable<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
71
71
|
published: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
72
72
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
73
73
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -170,7 +170,7 @@ declare namespace createProduct {
|
|
|
170
170
|
readonly TOKENIZED_PRODUCT: "TOKENIZED_PRODUCT";
|
|
171
171
|
}>;
|
|
172
172
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
173
|
-
status: z.
|
|
173
|
+
status: z.ZodMiniNullable<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
174
174
|
published: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
175
175
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
176
176
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -7,7 +7,7 @@ import { ProductType } from '@unchainedshop/core-products';
|
|
|
7
7
|
export const ProductCreateSpecificationSchema = z.object({
|
|
8
8
|
type: z.enum(ProductType),
|
|
9
9
|
sequence: z.optional(z.number()),
|
|
10
|
-
status: z.
|
|
10
|
+
status: z.nullable(z.optional(z.string())),
|
|
11
11
|
published: z.nullish(z.iso.datetime()),
|
|
12
12
|
tags: z.optional(z.array(z.string())),
|
|
13
13
|
commerce: z.optional(z.object({
|
|
@@ -65,12 +65,12 @@ const transformSpecification = (specification) => {
|
|
|
65
65
|
const proxy = assignments ? { assignments } : undefined;
|
|
66
66
|
return {
|
|
67
67
|
...productData,
|
|
68
|
+
...(sequence != null && { sequence }),
|
|
68
69
|
published: productData.published ? new Date(productData.published) : undefined,
|
|
69
70
|
tags,
|
|
70
71
|
warehousing,
|
|
71
72
|
supply,
|
|
72
73
|
proxy,
|
|
73
|
-
...(sequence != null && { sequence }),
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
76
|
export default async function createProduct(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI) {
|
|
@@ -4,7 +4,7 @@ import type { Services } from '../../../services/index.ts';
|
|
|
4
4
|
export declare const ProductUpdateSpecificationSchema: z.ZodMiniObject<{
|
|
5
5
|
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
6
6
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
7
|
-
status: z.
|
|
7
|
+
status: z.ZodMiniNullable<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
8
8
|
published: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
9
9
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
10
10
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -55,7 +55,7 @@ export declare const ProductUpdatePayloadSchema: z.ZodMiniObject<{
|
|
|
55
55
|
specification: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
56
56
|
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
57
57
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
58
|
-
status: z.
|
|
58
|
+
status: z.ZodMiniNullable<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
59
59
|
published: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
60
60
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
61
61
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -152,7 +152,7 @@ declare namespace updateProduct {
|
|
|
152
152
|
specification: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
153
153
|
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
154
154
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
155
|
-
status: z.
|
|
155
|
+
status: z.ZodMiniNullable<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
156
156
|
published: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
157
157
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
158
158
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -6,7 +6,7 @@ import convertTagsToLowerCase from "../utils/convertTagsToLowerCase.js";
|
|
|
6
6
|
export const ProductUpdateSpecificationSchema = z.object({
|
|
7
7
|
type: z.optional(z.string()),
|
|
8
8
|
sequence: z.optional(z.number()),
|
|
9
|
-
status: z.
|
|
9
|
+
status: z.nullable(z.optional(z.string())),
|
|
10
10
|
published: z.nullish(z.iso.datetime()),
|
|
11
11
|
tags: z.optional(z.array(z.string())),
|
|
12
12
|
commerce: z.optional(z.object({
|
package/lib/core-index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export * from './services/index.ts';
|
|
|
9
9
|
export * from './directors/index.ts';
|
|
10
10
|
export * from './factory/index.ts';
|
|
11
11
|
export * from './bulk-exporter/index.ts';
|
|
12
|
+
export * from './plugins/PluginRegistry.ts';
|
|
13
|
+
export * from './utils/getFileAdapter.ts';
|
|
14
|
+
export { filesSettings } from '@unchainedshop/core-files';
|
|
12
15
|
export { default as schedule, type ScheduleData } from './utils/schedule.ts';
|
|
13
16
|
export interface UnchainedCoreOptions {
|
|
14
17
|
db: mongodb.Db;
|
package/lib/core-index.js
CHANGED
|
@@ -2,13 +2,16 @@ import {} from '@unchainedshop/mongodb';
|
|
|
2
2
|
import initServices, {} from "./services/index.js";
|
|
3
3
|
import initModules, {} from "./modules.js";
|
|
4
4
|
import createBulkImporterFactory, {} from "./bulk-importer/index.js";
|
|
5
|
-
import { WorkerDirector, DeliveryDirector, DeliveryPricingDirector, EnrollmentDirector, FilterDirector, OrderDiscountDirector, OrderPricingDirector, PaymentDirector, PaymentPricingDirector, ProductDiscountDirector, ProductPricingDirector, QuotationDirector, WarehousingDirector, } from "./directors/index.js";
|
|
5
|
+
import { WorkerDirector, DeliveryDirector, DeliveryPricingDirector, EnrollmentDirector, FileDirector, FilterDirector, OrderDiscountDirector, OrderPricingDirector, PaymentDirector, PaymentPricingDirector, ProductDiscountDirector, ProductPricingDirector, QuotationDirector, WarehousingDirector, } from "./directors/index.js";
|
|
6
6
|
import createBulkExporterFactory, {} from "./bulk-exporter/index.js";
|
|
7
7
|
export * from "./bulk-importer/index.js";
|
|
8
8
|
export * from "./services/index.js";
|
|
9
9
|
export * from "./directors/index.js";
|
|
10
10
|
export * from "./factory/index.js";
|
|
11
11
|
export * from "./bulk-exporter/index.js";
|
|
12
|
+
export * from "./plugins/PluginRegistry.js";
|
|
13
|
+
export * from "./utils/getFileAdapter.js";
|
|
14
|
+
export { filesSettings } from '@unchainedshop/core-files';
|
|
12
15
|
export { default as schedule } from "./utils/schedule.js";
|
|
13
16
|
export const initCore = async ({ db, migrationRepository, bulkImporter: bulkImporterOptions = {}, modules: customModules = {}, services: customServices = {}, options = {}, bulkExporter: bulkExporterOptions = {}, }) => {
|
|
14
17
|
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions);
|
|
@@ -28,6 +31,7 @@ export const getAllAdapters = () => {
|
|
|
28
31
|
const delivery = DeliveryDirector.getAdapters();
|
|
29
32
|
const deliveryPricing = DeliveryPricingDirector.getAdapters();
|
|
30
33
|
const enrollment = EnrollmentDirector.getAdapters();
|
|
34
|
+
const file = FileDirector.getAdapters();
|
|
31
35
|
const filter = FilterDirector.getAdapters();
|
|
32
36
|
const orderDiscount = OrderDiscountDirector.getAdapters();
|
|
33
37
|
const orderPricing = OrderPricingDirector.getAdapters();
|
|
@@ -37,5 +41,5 @@ export const getAllAdapters = () => {
|
|
|
37
41
|
const productPricing = ProductPricingDirector.getAdapters();
|
|
38
42
|
const quotation = QuotationDirector.getAdapters();
|
|
39
43
|
const warehousing = WarehousingDirector.getAdapters();
|
|
40
|
-
return [].concat(worker, delivery, deliveryPricing, enrollment, filter, orderDiscount, orderPricing, payment, paymentPricing, productDiscount, productPricing, quotation, warehousing);
|
|
44
|
+
return [].concat(worker, delivery, deliveryPricing, enrollment, file, filter, orderDiscount, orderPricing, payment, paymentPricing, productDiscount, productPricing, quotation, warehousing);
|
|
41
45
|
};
|
|
@@ -3,16 +3,15 @@ export const BaseDiscountDirector = (directorName) => {
|
|
|
3
3
|
const baseDirector = BaseDirector(directorName, {
|
|
4
4
|
adapterSortKey: 'orderIndex',
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
const director = {
|
|
7
7
|
...baseDirector,
|
|
8
|
-
actions: async (discountContext, unchainedAPI)
|
|
8
|
+
actions: async function (discountContext, unchainedAPI) {
|
|
9
9
|
const context = { ...discountContext, ...unchainedAPI };
|
|
10
10
|
return {
|
|
11
11
|
resolveDiscountAdapterFromStaticCode: async (options) => {
|
|
12
12
|
if (!context.order)
|
|
13
13
|
return null;
|
|
14
|
-
const discounts = await Promise.all(
|
|
15
|
-
.getAdapters()
|
|
14
|
+
const discounts = await Promise.all(this.getAdapters()
|
|
16
15
|
.filter((Adapter) => Adapter.isManualAdditionAllowed(options?.code))
|
|
17
16
|
.map(async (Adapter) => {
|
|
18
17
|
const adapter = await Adapter.actions({ context });
|
|
@@ -23,10 +22,10 @@ export const BaseDiscountDirector = (directorName) => {
|
|
|
23
22
|
}));
|
|
24
23
|
return discounts.find(({ isValid }) => isValid === true)?.Adapter || null;
|
|
25
24
|
},
|
|
26
|
-
async
|
|
25
|
+
findSystemDiscounts: async () => {
|
|
27
26
|
if (!context.order)
|
|
28
27
|
return [];
|
|
29
|
-
const discounts = await Promise.all(
|
|
28
|
+
const discounts = await Promise.all(this.getAdapters().map(async (Adapter) => {
|
|
30
29
|
const adapter = await Adapter.actions({ context });
|
|
31
30
|
return {
|
|
32
31
|
key: Adapter.key,
|
|
@@ -41,4 +40,5 @@ export const BaseDiscountDirector = (directorName) => {
|
|
|
41
40
|
};
|
|
42
41
|
},
|
|
43
42
|
};
|
|
43
|
+
return director;
|
|
44
44
|
};
|
|
@@ -17,7 +17,7 @@ export const BasePricingDirector = (directorName) => {
|
|
|
17
17
|
async rebuildCalculation(pricingContext, unchainedAPI) {
|
|
18
18
|
const context = await this.buildPricingContext(pricingContext, unchainedAPI);
|
|
19
19
|
let calculation = [];
|
|
20
|
-
const Adapters =
|
|
20
|
+
const Adapters = this.getAdapters({
|
|
21
21
|
adapterFilter: (Adapter) => {
|
|
22
22
|
return Adapter.isActivatedFor(context);
|
|
23
23
|
},
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
-
import { DeliveryError, } from "./DeliveryAdapter.js";
|
|
2
|
+
import { DeliveryError, DeliveryAdapter, } from "./DeliveryAdapter.js";
|
|
3
3
|
import { OrderDeliveryStatus } from '@unchainedshop/core-orders';
|
|
4
4
|
import { createLogger } from '@unchainedshop/logger';
|
|
5
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
5
6
|
const logger = createLogger('unchained:core');
|
|
6
7
|
const baseDirector = BaseDirector('DeliveryDirector');
|
|
7
8
|
export const DeliveryDirector = {
|
|
8
9
|
...baseDirector,
|
|
10
|
+
getAdapter: (key) => {
|
|
11
|
+
const adapters = pluginRegistry.getAdapters(DeliveryAdapter.adapterType);
|
|
12
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
13
|
+
},
|
|
14
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
15
|
+
const adapters = pluginRegistry.getAdapters(DeliveryAdapter.adapterType);
|
|
16
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
17
|
+
},
|
|
9
18
|
actions: async (deliveryProvider, deliveryContext, unchainedAPI) => {
|
|
10
|
-
const Adapter =
|
|
19
|
+
const Adapter = DeliveryDirector.getAdapter(deliveryProvider.adapterKey);
|
|
11
20
|
if (!Adapter) {
|
|
12
21
|
throw new Error(`Delivery Plugin ${deliveryProvider.adapterKey} not available`);
|
|
13
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type BasePricingAdapterContext, type IPricingAdapter
|
|
1
|
+
import { type BasePricingAdapterContext, type IPricingAdapter } from './BasePricingAdapter.ts';
|
|
2
|
+
import type { IPricingSheet } from './BasePricingSheet.ts';
|
|
2
3
|
import type { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
3
4
|
import type { PricingCalculation } from '@unchainedshop/utils';
|
|
4
5
|
import type { OrderDelivery, OrderDiscount, Order } from '@unchainedshop/core-orders';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DeliveryPricingSheet } from "./DeliveryPricingSheet.js";
|
|
2
|
-
import { BasePricingAdapter, } from "
|
|
2
|
+
import { BasePricingAdapter, } from "./BasePricingAdapter.js";
|
|
3
3
|
const basePricingAdapter = BasePricingAdapter();
|
|
4
4
|
export const DeliveryPricingAdapter = {
|
|
5
5
|
...basePricingAdapter,
|
|
6
|
+
adapterType: Symbol.for('unchained:adapter:pricing:delivery'),
|
|
6
7
|
isActivatedFor: () => {
|
|
7
8
|
return false;
|
|
8
9
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IPricingDirector } from '
|
|
1
|
+
import { type IPricingDirector } from './BasePricingDirector.ts';
|
|
2
2
|
import { type DeliveryPricingAdapterContext, type DeliveryPricingCalculation, type IDeliveryPricingAdapter, type IDeliveryPricingSheet } from './DeliveryPricingAdapter.ts';
|
|
3
3
|
import type { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
4
4
|
import type { Order } from '@unchainedshop/core-orders';
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { DeliveryPricingSheet
|
|
2
|
-
import {} from "./
|
|
1
|
+
import { DeliveryPricingSheet } from "./DeliveryPricingSheet.js";
|
|
2
|
+
import { BasePricingDirector } from "./BasePricingDirector.js";
|
|
3
|
+
import { DeliveryPricingAdapter, } from "./DeliveryPricingAdapter.js";
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
5
|
const baseDirector = BasePricingDirector('DeliveryPricingDirector');
|
|
4
6
|
export const DeliveryPricingDirector = {
|
|
5
7
|
...baseDirector,
|
|
8
|
+
getAdapter: (key) => {
|
|
9
|
+
const adapters = pluginRegistry.getAdapters(DeliveryPricingAdapter.adapterType);
|
|
10
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
11
|
+
},
|
|
12
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
13
|
+
const adapters = pluginRegistry.getAdapters(DeliveryPricingAdapter.adapterType);
|
|
14
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
15
|
+
},
|
|
6
16
|
async buildPricingContext(context, unchainedAPI) {
|
|
7
17
|
const { modules } = unchainedAPI;
|
|
8
18
|
if ('item' in context) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PricingSheetParams } from '
|
|
1
|
+
import { type PricingSheetParams } from './BasePricingSheet.ts';
|
|
2
2
|
import type { DeliveryPricingCalculation, IDeliveryPricingSheet } from './DeliveryPricingAdapter.ts';
|
|
3
3
|
export declare const DeliveryPricingRowCategory: {
|
|
4
4
|
readonly Delivery: "DELIVERY";
|