@unchainedshop/core 4.6.2 → 4.7.2
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/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/lib/utils/schedule.js +164 -28
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
-
import { QuotationError, } from "./QuotationAdapter.js";
|
|
2
|
+
import { QuotationError, QuotationAdapter, } from "./QuotationAdapter.js";
|
|
3
3
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
5
|
const logger = createLogger('unchained:core');
|
|
5
6
|
const baseDirector = BaseDirector('QuotationDirector', {
|
|
6
7
|
adapterSortKey: 'orderIndex',
|
|
7
8
|
});
|
|
8
|
-
const findAppropriateAdapters = (quotationContext, unchainedAPI) =>
|
|
9
|
+
const findAppropriateAdapters = (quotationContext, unchainedAPI) => QuotationDirector.getAdapters({
|
|
9
10
|
adapterFilter: (Adapter) => {
|
|
10
11
|
const activated = Adapter.isActivatedFor(quotationContext, unchainedAPI);
|
|
11
12
|
if (!activated) {
|
|
@@ -16,6 +17,14 @@ const findAppropriateAdapters = (quotationContext, unchainedAPI) => baseDirector
|
|
|
16
17
|
});
|
|
17
18
|
export const QuotationDirector = {
|
|
18
19
|
...baseDirector,
|
|
20
|
+
getAdapter: (key) => {
|
|
21
|
+
const adapters = pluginRegistry.getAdapters(QuotationAdapter.adapterType);
|
|
22
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
23
|
+
},
|
|
24
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
25
|
+
const adapters = pluginRegistry.getAdapters(QuotationAdapter.adapterType);
|
|
26
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
27
|
+
},
|
|
19
28
|
actions: async (quotationContext, unchainedAPI) => {
|
|
20
29
|
const context = { ...quotationContext, ...unchainedAPI };
|
|
21
30
|
const Adapter = findAppropriateAdapters(quotationContext, unchainedAPI)?.shift();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IBaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import type { WarehousingProvider, TokenSurrogate } from '@unchainedshop/core-warehousing';
|
|
3
|
-
import { type IWarehousingAdapter, type WarehousingContext, WarehousingError } from '
|
|
3
|
+
import { type IWarehousingAdapter, type WarehousingContext, WarehousingError } from './WarehousingAdapter.ts';
|
|
4
4
|
import type { Modules } from '../modules.ts';
|
|
5
5
|
export interface EstimatedDispatch {
|
|
6
6
|
shipping?: Date;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
3
|
const logger = createLogger('unchained:core');
|
|
4
|
-
import { DeliveryDirector
|
|
4
|
+
import { DeliveryDirector } from "./DeliveryDirector.js";
|
|
5
|
+
import { WarehousingError, WarehousingAdapter, } from "./WarehousingAdapter.js";
|
|
6
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
5
7
|
const getReferenceDate = (context) => {
|
|
6
8
|
return context && context.referenceDate ? context.referenceDate : new Date();
|
|
7
9
|
};
|
|
@@ -10,8 +12,16 @@ const baseDirector = BaseDirector('WarehousingDirector', {
|
|
|
10
12
|
});
|
|
11
13
|
export const WarehousingDirector = {
|
|
12
14
|
...baseDirector,
|
|
15
|
+
getAdapter: (key) => {
|
|
16
|
+
const adapters = pluginRegistry.getAdapters(WarehousingAdapter.adapterType);
|
|
17
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
18
|
+
},
|
|
19
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
20
|
+
const adapters = pluginRegistry.getAdapters(WarehousingAdapter.adapterType);
|
|
21
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
22
|
+
},
|
|
13
23
|
actions: async (warehousingProvider, warehousingContext, unchainedAPI) => {
|
|
14
|
-
const Adapter =
|
|
24
|
+
const Adapter = WarehousingDirector.getAdapter(warehousingProvider.adapterKey);
|
|
15
25
|
if (!Adapter) {
|
|
16
26
|
throw new Error(`Warehousing Plugin ${warehousingProvider.adapterKey} not available`);
|
|
17
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Work, WorkData, WorkResult } from '@unchainedshop/core-worker';
|
|
2
2
|
import { type IBaseDirector } from '@unchainedshop/utils';
|
|
3
3
|
import type { ScheduleData } from '../utils/schedule.ts';
|
|
4
|
-
import type
|
|
4
|
+
import { type IWorkerAdapter } from './WorkerAdapter.ts';
|
|
5
5
|
import type { Modules } from '../modules.ts';
|
|
6
6
|
export type WorkScheduleConfiguration = Pick<WorkData, 'timeout' | 'retries' | 'priority' | 'worker' | 'scheduleId'> & {
|
|
7
7
|
type: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import { WorkerAdapter } from "./WorkerAdapter.js";
|
|
2
3
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
5
|
const logger = createLogger('unchained:core');
|
|
4
6
|
const AutoScheduleMap = new Map();
|
|
5
7
|
const baseDirector = BaseDirector('WorkerDirector', {
|
|
@@ -7,6 +9,14 @@ const baseDirector = BaseDirector('WorkerDirector', {
|
|
|
7
9
|
});
|
|
8
10
|
export const WorkerDirector = {
|
|
9
11
|
...baseDirector,
|
|
12
|
+
getAdapter: (key) => {
|
|
13
|
+
const adapters = pluginRegistry.getAdapters(WorkerAdapter.adapterType);
|
|
14
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
15
|
+
},
|
|
16
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
17
|
+
const adapters = pluginRegistry.getAdapters(WorkerAdapter.adapterType);
|
|
18
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
19
|
+
},
|
|
10
20
|
getActivePluginTypes: ({ external } = {}) => {
|
|
11
21
|
return WorkerDirector.getAdapters()
|
|
12
22
|
.filter((adapter) => {
|
|
@@ -16,26 +26,9 @@ export const WorkerDirector = {
|
|
|
16
26
|
})
|
|
17
27
|
.map((adapter) => adapter.type);
|
|
18
28
|
},
|
|
19
|
-
registerAdapter: (Adapter) => {
|
|
20
|
-
if (WorkerDirector.getAdapterByType(Adapter.type))
|
|
21
|
-
throw new Error(`WorkerDirector: There is already a adapter registered with type: ${Adapter.type}`);
|
|
22
|
-
baseDirector.registerAdapter(Adapter);
|
|
23
|
-
},
|
|
24
29
|
disableAutoscheduling: (type) => {
|
|
25
30
|
AutoScheduleMap.delete(type);
|
|
26
31
|
},
|
|
27
|
-
unregisterAdapter: (key) => {
|
|
28
|
-
const adapter = WorkerDirector.getAdapter(key);
|
|
29
|
-
const result = baseDirector.unregisterAdapter(key);
|
|
30
|
-
if (adapter) {
|
|
31
|
-
AutoScheduleMap.forEach((workItemConfiguration, scheduleId) => {
|
|
32
|
-
if (workItemConfiguration.type === adapter.type) {
|
|
33
|
-
AutoScheduleMap.delete(scheduleId);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
},
|
|
39
32
|
configureAutoscheduling: (workItemConfiguration) => {
|
|
40
33
|
AutoScheduleMap.set(workItemConfiguration.scheduleId || workItemConfiguration.type, workItemConfiguration);
|
|
41
34
|
},
|
package/lib/directors/index.d.ts
CHANGED
|
@@ -39,4 +39,6 @@ export * from './FailedRescheduler.ts';
|
|
|
39
39
|
export * from './BaseWorker.ts';
|
|
40
40
|
export * from './QuotationAdapter.ts';
|
|
41
41
|
export * from './QuotationDirector.ts';
|
|
42
|
+
export * from './FileDirector.ts';
|
|
43
|
+
export { type IFileAdapter, FileAdapter } from '@unchainedshop/core-files';
|
|
42
44
|
export * from './MessagingDirector.ts';
|
package/lib/directors/index.js
CHANGED
|
@@ -39,4 +39,6 @@ export * from "./FailedRescheduler.js";
|
|
|
39
39
|
export * from "./BaseWorker.js";
|
|
40
40
|
export * from "./QuotationAdapter.js";
|
|
41
41
|
export * from "./QuotationDirector.js";
|
|
42
|
+
export * from "./FileDirector.js";
|
|
43
|
+
export { FileAdapter } from '@unchainedshop/core-files';
|
|
42
44
|
export * from "./MessagingDirector.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { SearchQuery } from '@unchainedshop/core-filters';
|
|
2
|
+
import { type IPlugin } from '../core-index.ts';
|
|
2
3
|
export default function registerAssortmentSearchFilter({ orderIndex, search, }: {
|
|
3
4
|
orderIndex?: number;
|
|
4
5
|
search: (params: SearchQuery & {
|
|
5
6
|
queryString: string;
|
|
6
7
|
locale: Intl.Locale;
|
|
7
8
|
}) => Promise<string[]>;
|
|
8
|
-
}):
|
|
9
|
+
}): IPlugin;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FilterAdapter
|
|
1
|
+
import { FilterAdapter } from "../core-index.js";
|
|
2
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
3
|
export default function registerAssortmentSearchFilter({ orderIndex = 0, search, }) {
|
|
3
|
-
|
|
4
|
+
const adapter = {
|
|
4
5
|
...FilterAdapter,
|
|
5
6
|
key: `shop.unchained.filters.assortment-search-${crypto.randomUUID()}`,
|
|
6
7
|
label: 'Assortment Search Filter (auto-generated)',
|
|
@@ -19,5 +20,13 @@ export default function registerAssortmentSearchFilter({ orderIndex = 0, search,
|
|
|
19
20
|
},
|
|
20
21
|
};
|
|
21
22
|
},
|
|
22
|
-
}
|
|
23
|
+
};
|
|
24
|
+
const plugin = {
|
|
25
|
+
key: adapter.key,
|
|
26
|
+
label: adapter.label,
|
|
27
|
+
version: adapter.version,
|
|
28
|
+
adapters: [adapter],
|
|
29
|
+
};
|
|
30
|
+
pluginRegistry.register(plugin);
|
|
31
|
+
return plugin;
|
|
23
32
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PaymentConfiguration } from '@unchainedshop/core-payment';
|
|
2
|
-
import { type PaymentContext, type PaymentChargeActionResult } from '../core-index.ts';
|
|
2
|
+
import { type PaymentContext, type PaymentChargeActionResult, type IPlugin } from '../core-index.ts';
|
|
3
3
|
export default function registerInvoicePayment({ adapterId, active, payLaterAllowed, charge, }: {
|
|
4
4
|
adapterId: string;
|
|
5
5
|
active?: boolean;
|
|
6
6
|
payLaterAllowed?: boolean;
|
|
7
7
|
charge: false | ((configuration: PaymentConfiguration, context: PaymentContext) => Promise<PaymentChargeActionResult | false>);
|
|
8
|
-
}):
|
|
8
|
+
}): IPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { PaymentAdapter,
|
|
1
|
+
import { PaymentAdapter, } from "../core-index.js";
|
|
2
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
3
|
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
4
|
export default function registerInvoicePayment({ adapterId, active, payLaterAllowed, charge, }) {
|
|
4
|
-
|
|
5
|
+
const adapter = {
|
|
5
6
|
...PaymentAdapter,
|
|
6
7
|
key: `shop.unchained.payment.invoice-${adapterId}`,
|
|
7
8
|
label: 'Invoice Payment: ' + adapterId,
|
|
@@ -27,5 +28,13 @@ export default function registerInvoicePayment({ adapterId, active, payLaterAllo
|
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
30
|
},
|
|
30
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const plugin = {
|
|
33
|
+
key: adapter.key,
|
|
34
|
+
label: adapter.label,
|
|
35
|
+
version: adapter.version,
|
|
36
|
+
adapters: [adapter],
|
|
37
|
+
};
|
|
38
|
+
pluginRegistry.register(plugin);
|
|
39
|
+
return plugin;
|
|
31
40
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { WarehousingConfiguration } from '@unchainedshop/core-warehousing';
|
|
2
|
-
import { type WarehousingContext } from '../core-index.ts';
|
|
2
|
+
import { type WarehousingContext, type IPlugin } from '../core-index.ts';
|
|
3
3
|
export default function registerPhysicalWarehousing({ adapterId, orderIndex, stock, productionTime, commissioningTime, }: {
|
|
4
4
|
adapterId: string;
|
|
5
5
|
orderIndex?: number;
|
|
6
6
|
stock?: number | ((referenceDate: Date, configuration: WarehousingConfiguration, context: WarehousingContext) => Promise<number>);
|
|
7
7
|
productionTime?: number | ((quantityToProduct: number, configuration: WarehousingConfiguration, context: WarehousingContext) => Promise<number>);
|
|
8
8
|
commissioningTime?: number | ((quantity: number, configuration: WarehousingConfiguration, context: WarehousingContext) => Promise<number>);
|
|
9
|
-
}):
|
|
9
|
+
}): IPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
|
|
2
|
-
import { WarehousingAdapter,
|
|
2
|
+
import { WarehousingAdapter, } from "../core-index.js";
|
|
3
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
4
|
export default function registerPhysicalWarehousing({ adapterId, orderIndex = 0, stock, productionTime, commissioningTime, }) {
|
|
4
|
-
|
|
5
|
+
const adapter = {
|
|
5
6
|
...WarehousingAdapter,
|
|
6
7
|
key: 'shop.unchained.warehousing.physical.' + adapterId,
|
|
7
8
|
label: 'Physical Warehousing: ' + adapterId,
|
|
@@ -49,5 +50,13 @@ export default function registerPhysicalWarehousing({ adapterId, orderIndex = 0,
|
|
|
49
50
|
},
|
|
50
51
|
};
|
|
51
52
|
},
|
|
52
|
-
}
|
|
53
|
+
};
|
|
54
|
+
const plugin = {
|
|
55
|
+
key: adapter.key,
|
|
56
|
+
label: adapter.label,
|
|
57
|
+
version: adapter.version,
|
|
58
|
+
adapters: [adapter],
|
|
59
|
+
};
|
|
60
|
+
pluginRegistry.register(plugin);
|
|
61
|
+
return plugin;
|
|
53
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeliveryConfiguration, type DeliveryLocation } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { type DeliveryContext } from '../core-index.ts';
|
|
2
|
+
import { type DeliveryContext, type IPlugin } from '../core-index.ts';
|
|
3
3
|
import type { Work } from '@unchainedshop/core-worker';
|
|
4
4
|
export default function registerPickUpDelivery({ adapterId, locations, active, autoReleaseAllowed, estimatedDeliveryThroughput, send, }: {
|
|
5
5
|
adapterId: string;
|
|
@@ -8,4 +8,4 @@ export default function registerPickUpDelivery({ adapterId, locations, active, a
|
|
|
8
8
|
estimatedDeliveryThroughput?: (warehousingThroughputTime: number, context: DeliveryContext) => Promise<number | null>;
|
|
9
9
|
send: boolean | ((configuration: DeliveryConfiguration, context: DeliveryContext) => Promise<boolean | Work>);
|
|
10
10
|
locations: DeliveryLocation[] | ((context: DeliveryContext) => Promise<DeliveryLocation[]>);
|
|
11
|
-
}):
|
|
11
|
+
}): IPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DeliveryProviderType, } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { DeliveryAdapter,
|
|
2
|
+
import { DeliveryAdapter, } from "../core-index.js";
|
|
3
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
4
|
export default function registerPickUpDelivery({ adapterId, locations, active, autoReleaseAllowed, estimatedDeliveryThroughput, send, }) {
|
|
4
|
-
|
|
5
|
+
const adapter = {
|
|
5
6
|
...DeliveryAdapter,
|
|
6
7
|
key: `shop.unchained.delivery.pickup-${adapterId}`,
|
|
7
8
|
label: 'PickUp Delivery: ' + adapterId,
|
|
@@ -41,5 +42,13 @@ export default function registerPickUpDelivery({ adapterId, locations, active, a
|
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
44
|
},
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
const plugin = {
|
|
47
|
+
key: adapter.key,
|
|
48
|
+
label: adapter.label,
|
|
49
|
+
version: adapter.version,
|
|
50
|
+
adapters: [adapter],
|
|
51
|
+
};
|
|
52
|
+
pluginRegistry.register(plugin);
|
|
53
|
+
return plugin;
|
|
45
54
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FilterAdapter
|
|
1
|
+
import { FilterAdapter } from "../core-index.js";
|
|
2
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
3
|
export default function registerProductDiscoverabilityFilter({ orderIndex = 0, hiddenTagValue = 'hidden', }) {
|
|
3
|
-
|
|
4
|
+
const adapter = {
|
|
4
5
|
...FilterAdapter,
|
|
5
6
|
key: `shop.unchained.filters.product-discoverability-${crypto.randomUUID()}`,
|
|
6
7
|
label: 'Product Discoverability Filter (auto-generated)',
|
|
@@ -22,5 +23,13 @@ export default function registerProductDiscoverabilityFilter({ orderIndex = 0, h
|
|
|
22
23
|
},
|
|
23
24
|
};
|
|
24
25
|
},
|
|
25
|
-
}
|
|
26
|
+
};
|
|
27
|
+
const plugin = {
|
|
28
|
+
key: adapter.key,
|
|
29
|
+
label: adapter.label,
|
|
30
|
+
version: adapter.version,
|
|
31
|
+
adapters: [adapter],
|
|
32
|
+
};
|
|
33
|
+
pluginRegistry.register(plugin);
|
|
34
|
+
return plugin;
|
|
26
35
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { SearchQuery } from '@unchainedshop/core-filters';
|
|
2
|
+
import { type IPlugin } from '../core-index.ts';
|
|
2
3
|
export default function registerProductSearchFilter({ orderIndex, search, }: {
|
|
3
4
|
orderIndex?: number;
|
|
4
5
|
search: (params: SearchQuery & {
|
|
5
6
|
queryString: string;
|
|
6
7
|
locale: Intl.Locale;
|
|
7
8
|
}) => Promise<string[]>;
|
|
8
|
-
}):
|
|
9
|
+
}): IPlugin;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FilterAdapter
|
|
1
|
+
import { FilterAdapter } from "../core-index.js";
|
|
2
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
3
|
export default function registerProductSearchFilter({ orderIndex = 0, search, }) {
|
|
3
|
-
|
|
4
|
+
const adapter = {
|
|
4
5
|
...FilterAdapter,
|
|
5
6
|
key: `shop.unchained.filters.product-search-${crypto.randomUUID()}`,
|
|
6
7
|
label: 'Product Search Filter (auto-generated)',
|
|
@@ -19,5 +20,13 @@ export default function registerProductSearchFilter({ orderIndex = 0, search, })
|
|
|
19
20
|
},
|
|
20
21
|
};
|
|
21
22
|
},
|
|
22
|
-
}
|
|
23
|
+
};
|
|
24
|
+
const plugin = {
|
|
25
|
+
key: adapter.key,
|
|
26
|
+
label: adapter.label,
|
|
27
|
+
version: adapter.version,
|
|
28
|
+
adapters: [adapter],
|
|
29
|
+
};
|
|
30
|
+
pluginRegistry.register(plugin);
|
|
31
|
+
return plugin;
|
|
23
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeliveryConfiguration } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { type DeliveryContext } from '../core-index.ts';
|
|
2
|
+
import { type DeliveryContext, type IPlugin } from '../core-index.ts';
|
|
3
3
|
import type { Work } from '@unchainedshop/core-worker';
|
|
4
4
|
export default function registerShippingDelivery({ adapterId, active, autoReleaseAllowed, estimatedDeliveryThroughput, send, }: {
|
|
5
5
|
adapterId: string;
|
|
@@ -7,4 +7,4 @@ export default function registerShippingDelivery({ adapterId, active, autoReleas
|
|
|
7
7
|
autoReleaseAllowed?: boolean;
|
|
8
8
|
estimatedDeliveryThroughput?: (warehousingThroughputTime: number, context: DeliveryContext) => Promise<number | null>;
|
|
9
9
|
send: boolean | ((configuration: DeliveryConfiguration, context: DeliveryContext) => Promise<boolean | Work>);
|
|
10
|
-
}):
|
|
10
|
+
}): IPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { DeliveryAdapter,
|
|
2
|
+
import { DeliveryAdapter, } from "../core-index.js";
|
|
3
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
4
|
export default function registerShippingDelivery({ adapterId, active, autoReleaseAllowed, estimatedDeliveryThroughput, send, }) {
|
|
4
|
-
|
|
5
|
+
const adapter = {
|
|
5
6
|
...DeliveryAdapter,
|
|
6
7
|
key: `shop.unchained.delivery.shipping-${adapterId}`,
|
|
7
8
|
label: 'Shipping Delivery: ' + adapterId,
|
|
@@ -33,5 +34,13 @@ export default function registerShippingDelivery({ adapterId, active, autoReleas
|
|
|
33
34
|
},
|
|
34
35
|
};
|
|
35
36
|
},
|
|
36
|
-
}
|
|
37
|
+
};
|
|
38
|
+
const plugin = {
|
|
39
|
+
key: adapter.key,
|
|
40
|
+
label: adapter.label,
|
|
41
|
+
version: adapter.version,
|
|
42
|
+
adapters: [adapter],
|
|
43
|
+
};
|
|
44
|
+
pluginRegistry.register(plugin);
|
|
45
|
+
return plugin;
|
|
37
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TokenSurrogate, type WarehousingConfiguration } from '@unchainedshop/core-warehousing';
|
|
2
|
-
import { type WarehousingContext } from '../core-index.ts';
|
|
2
|
+
import { type WarehousingContext, type IPlugin } from '../core-index.ts';
|
|
3
3
|
export default function registerVirtualWarehousing<Metadata = Record<string, any>>({ adapterId, orderIndex, stock, tokenize, tokenMetadata, isInvalidateable, }: {
|
|
4
4
|
adapterId: string;
|
|
5
5
|
orderIndex?: number;
|
|
@@ -7,4 +7,4 @@ export default function registerVirtualWarehousing<Metadata = Record<string, any
|
|
|
7
7
|
tokenize: (configuration: WarehousingConfiguration, context: WarehousingContext) => Promise<Omit<TokenSurrogate, 'userId' | 'productId' | 'orderPositionId'>[]>;
|
|
8
8
|
tokenMetadata?: (serialNumber: string, referenceDate: Date, configuration: WarehousingConfiguration, context: WarehousingContext) => Promise<Metadata>;
|
|
9
9
|
isInvalidateable?: (serialNumber: string, referenceDate: Date, configuration: WarehousingConfiguration, context: WarehousingContext) => Promise<boolean>;
|
|
10
|
-
}):
|
|
10
|
+
}): IPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { WarehousingProviderType, } from '@unchainedshop/core-warehousing';
|
|
2
|
-
import { WarehousingAdapter,
|
|
2
|
+
import { WarehousingAdapter, } from "../core-index.js";
|
|
3
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
4
|
export default function registerVirtualWarehousing({ adapterId, orderIndex = 0, stock, tokenize, tokenMetadata, isInvalidateable, }) {
|
|
4
|
-
|
|
5
|
+
const adapter = {
|
|
5
6
|
...WarehousingAdapter,
|
|
6
7
|
key: 'shop.unchained.warehousing.virtual.' + adapterId,
|
|
7
8
|
label: 'Virtual Wareshousing: ' + adapterId,
|
|
@@ -46,5 +47,13 @@ export default function registerVirtualWarehousing({ adapterId, orderIndex = 0,
|
|
|
46
47
|
},
|
|
47
48
|
};
|
|
48
49
|
},
|
|
49
|
-
}
|
|
50
|
+
};
|
|
51
|
+
const plugin = {
|
|
52
|
+
key: adapter.key,
|
|
53
|
+
label: adapter.label,
|
|
54
|
+
version: adapter.version,
|
|
55
|
+
adapters: [adapter],
|
|
56
|
+
};
|
|
57
|
+
pluginRegistry.register(plugin);
|
|
58
|
+
return plugin;
|
|
50
59
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type IPlugin } from '../core-index.ts';
|
|
1
2
|
export default function registerWorker<Input = any, Result = any>({ type, external, maxParallelAllocations, process, }: {
|
|
2
3
|
type: string;
|
|
3
4
|
external?: boolean;
|
|
4
5
|
maxParallelAllocations?: number;
|
|
5
6
|
process?: (input: Input, workId: string) => Promise<Result>;
|
|
6
|
-
}):
|
|
7
|
+
}): IPlugin;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { WorkerAdapter
|
|
1
|
+
import { WorkerAdapter } from "../core-index.js";
|
|
2
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
3
|
export default function registerWorker({ type, external, maxParallelAllocations, process, }) {
|
|
3
|
-
|
|
4
|
+
const adapter = {
|
|
4
5
|
...WorkerAdapter,
|
|
5
6
|
key: 'shop.unchained.worker.' + type.toLowerCase(),
|
|
6
7
|
label: 'Worker: ' + type,
|
|
@@ -30,5 +31,13 @@ export default function registerWorker({ type, external, maxParallelAllocations,
|
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
|
-
}
|
|
34
|
+
};
|
|
35
|
+
const plugin = {
|
|
36
|
+
key: adapter.key,
|
|
37
|
+
label: adapter.label,
|
|
38
|
+
version: adapter.version,
|
|
39
|
+
adapters: [adapter],
|
|
40
|
+
};
|
|
41
|
+
pluginRegistry.register(plugin);
|
|
42
|
+
return plugin;
|
|
34
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileAdapter } from
|
|
1
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
2
|
export async function createDownloadStreamService({ fileId, }) {
|
|
3
3
|
const fileAdapter = getFileAdapter();
|
|
4
4
|
const file = await this.files.findFile({ fileId });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function createFileDownloadURLService({ file, expires, params = {}, }) {
|
|
3
4
|
if (!file)
|
|
4
5
|
return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function createSignedURLService({ directoryName, fileName, meta }) {
|
|
3
4
|
const fileUploadAdapter = getFileAdapter();
|
|
4
5
|
const preparedFileData = await fileUploadAdapter.createSignedURL(directoryName, fileName, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileAdapter } from
|
|
1
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
2
|
export async function removeFilesService({ fileIds }) {
|
|
3
3
|
if (fileIds && typeof fileIds !== 'string' && !Array.isArray(fileIds))
|
|
4
4
|
throw Error('Media id/s to be removed not provided as a string or array');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function uploadFileFromStreamService({ directoryName, rawFile, meta, ...options }) {
|
|
3
4
|
const fileUploadAdapter = getFileAdapter();
|
|
4
5
|
const uploadFileData = await fileUploadAdapter.uploadFileFromStream(directoryName, rawFile, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function uploadFileFromURLService({ directoryName, fileInput, meta, }) {
|
|
3
4
|
const fileUploadAdapter = getFileAdapter();
|
|
4
5
|
const uploadFileData = await fileUploadAdapter.uploadFileFromURL(directoryName, fileInput, {
|