@unchainedshop/core 4.1.0 → 4.1.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/factory/index.d.ts +9 -1
- package/lib/factory/index.d.ts.map +1 -1
- package/lib/factory/index.js +9 -1
- package/lib/factory/index.js.map +1 -1
- package/lib/factory/registerAssortmentSearchFilter.d.ts +9 -0
- package/lib/factory/registerAssortmentSearchFilter.d.ts.map +1 -0
- package/lib/factory/registerAssortmentSearchFilter.js +24 -0
- package/lib/factory/registerAssortmentSearchFilter.js.map +1 -0
- package/lib/factory/registerInvoicePayment.d.ts +9 -0
- package/lib/factory/registerInvoicePayment.d.ts.map +1 -0
- package/lib/factory/registerInvoicePayment.js +32 -0
- package/lib/factory/registerInvoicePayment.js.map +1 -0
- package/lib/factory/registerPhysicalWarehouse copy.d.ts +10 -0
- package/lib/factory/registerPhysicalWarehouse copy.d.ts.map +1 -0
- package/lib/factory/registerPhysicalWarehouse copy.js +54 -0
- package/lib/factory/registerPhysicalWarehouse copy.js.map +1 -0
- package/lib/factory/registerPhysicalWarehouse.d.ts +10 -0
- package/lib/factory/registerPhysicalWarehouse.d.ts.map +1 -0
- package/lib/factory/registerPhysicalWarehouse.js +54 -0
- package/lib/factory/registerPhysicalWarehouse.js.map +1 -0
- package/lib/factory/registerPhysicalWarehousing.d.ts +10 -0
- package/lib/factory/registerPhysicalWarehousing.d.ts.map +1 -0
- package/lib/factory/registerPhysicalWarehousing.js +54 -0
- package/lib/factory/registerPhysicalWarehousing.js.map +1 -0
- package/lib/factory/registerPickUpDelivery.d.ts +12 -0
- package/lib/factory/registerPickUpDelivery.d.ts.map +1 -0
- package/lib/factory/registerPickUpDelivery.js +46 -0
- package/lib/factory/registerPickUpDelivery.js.map +1 -0
- package/lib/factory/registerProductDiscoverabilityFilter.js +1 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js.map +1 -1
- package/lib/factory/registerProductSearchFilter.d.ts +9 -0
- package/lib/factory/registerProductSearchFilter.d.ts.map +1 -0
- package/lib/factory/registerProductSearchFilter.js +24 -0
- package/lib/factory/registerProductSearchFilter.js.map +1 -0
- package/lib/factory/registerShippingDelivery.d.ts +11 -0
- package/lib/factory/registerShippingDelivery.d.ts.map +1 -0
- package/lib/factory/registerShippingDelivery.js +38 -0
- package/lib/factory/registerShippingDelivery.js.map +1 -0
- package/lib/factory/registerVirtualWarehouse.d.ts +11 -0
- package/lib/factory/registerVirtualWarehouse.d.ts.map +1 -0
- package/lib/factory/registerVirtualWarehouse.js +51 -0
- package/lib/factory/registerVirtualWarehouse.js.map +1 -0
- package/lib/factory/registerVirtualWarehousing.d.ts +11 -0
- package/lib/factory/registerVirtualWarehousing.d.ts.map +1 -0
- package/lib/factory/registerVirtualWarehousing.js +51 -0
- package/lib/factory/registerVirtualWarehousing.js.map +1 -0
- package/lib/factory/registerWarehouse.d.ts +7 -0
- package/lib/factory/registerWarehouse.d.ts.map +1 -0
- package/lib/factory/registerWarehouse.js +35 -0
- package/lib/factory/registerWarehouse.js.map +1 -0
- package/lib/factory/registerWorker copy.d.ts +7 -0
- package/lib/factory/registerWorker copy.d.ts.map +1 -0
- package/lib/factory/registerWorker copy.js +35 -0
- package/lib/factory/registerWorker copy.js.map +1 -0
- package/lib/factory/registerWorker.d.ts +7 -0
- package/lib/factory/registerWorker.d.ts.map +1 -0
- package/lib/factory/registerWorker.js +35 -0
- package/lib/factory/registerWorker.js.map +1 -0
- package/lib/services/removeProduct.d.ts.map +1 -1
- package/lib/services/removeProduct.js +3 -0
- package/lib/services/removeProduct.js.map +1 -1
- package/package.json +1 -1
- package/src/factory/index.ts +19 -1
- package/src/factory/registerAssortmentSearchFilter.ts +36 -0
- package/src/factory/registerInvoicePayment.ts +61 -0
- package/src/factory/registerPhysicalWarehousing.ts +92 -0
- package/src/factory/registerPickUpDelivery.ts +81 -0
- package/src/factory/registerProductDiscoverabilityFilter.ts +1 -1
- package/src/factory/registerProductSearchFilter.ts +36 -0
- package/src/factory/registerShippingDelivery.ts +65 -0
- package/src/factory/registerVirtualWarehousing.ts +100 -0
- package/src/factory/registerWorker.ts +46 -0
- package/src/services/removeProduct.ts +3 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SearchQuery } from '@unchainedshop/core-filters';
|
|
2
|
+
import { FilterAdapter, FilterDirector } from '../core-index.js';
|
|
3
|
+
|
|
4
|
+
export default function registerProductSearchFilter({
|
|
5
|
+
orderIndex = 0,
|
|
6
|
+
search,
|
|
7
|
+
}: {
|
|
8
|
+
orderIndex?: number;
|
|
9
|
+
search: (params: SearchQuery & { queryString: string; locale: Intl.Locale }) => Promise<string[]>;
|
|
10
|
+
}) {
|
|
11
|
+
FilterDirector.registerAdapter({
|
|
12
|
+
...FilterAdapter,
|
|
13
|
+
|
|
14
|
+
key: `shop.unchained.filters.product-search-${crypto.randomUUID()}`,
|
|
15
|
+
label: 'Product Search Filter (auto-generated)',
|
|
16
|
+
version: '1.0.0',
|
|
17
|
+
orderIndex,
|
|
18
|
+
|
|
19
|
+
actions: (params) => {
|
|
20
|
+
return {
|
|
21
|
+
...FilterAdapter.actions(params),
|
|
22
|
+
|
|
23
|
+
async searchProducts({ productIds }, { locale }) {
|
|
24
|
+
const { queryString, ...rest } = params.searchQuery;
|
|
25
|
+
if (!queryString) return productIds;
|
|
26
|
+
|
|
27
|
+
const restrictedProductIds = new Set(productIds || []);
|
|
28
|
+
const foundProductIds = await search({ ...rest, queryString, locale });
|
|
29
|
+
return foundProductIds.filter(
|
|
30
|
+
restrictedProductIds.size === 0 ? Boolean : (id) => restrictedProductIds.has(id),
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { DeliveryConfiguration, DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
2
|
+
import { DeliveryAdapter, DeliveryContext, DeliveryDirector } from '../core-index.js';
|
|
3
|
+
import { Work } from '@unchainedshop/core-worker';
|
|
4
|
+
|
|
5
|
+
export default function registerShippingDelivery({
|
|
6
|
+
adapterId,
|
|
7
|
+
active,
|
|
8
|
+
autoReleaseAllowed,
|
|
9
|
+
estimatedDeliveryThroughput,
|
|
10
|
+
send,
|
|
11
|
+
}: {
|
|
12
|
+
adapterId: string;
|
|
13
|
+
active?: boolean;
|
|
14
|
+
autoReleaseAllowed?: boolean;
|
|
15
|
+
estimatedDeliveryThroughput?: (
|
|
16
|
+
warehousingThroughputTime: number,
|
|
17
|
+
context: DeliveryContext,
|
|
18
|
+
) => Promise<number | null>;
|
|
19
|
+
send:
|
|
20
|
+
| boolean
|
|
21
|
+
| ((configuration: DeliveryConfiguration, context: DeliveryContext) => Promise<boolean | Work>);
|
|
22
|
+
}) {
|
|
23
|
+
DeliveryDirector.registerAdapter({
|
|
24
|
+
...DeliveryAdapter,
|
|
25
|
+
|
|
26
|
+
key: `shop.unchained.delivery.shipping-${adapterId}`,
|
|
27
|
+
label: 'Shipping Delivery: ' + adapterId,
|
|
28
|
+
version: '1.0.0',
|
|
29
|
+
|
|
30
|
+
initialConfiguration: [],
|
|
31
|
+
|
|
32
|
+
typeSupported: (type) => {
|
|
33
|
+
return type === DeliveryProviderType.SHIPPING;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
actions: (config, context) => {
|
|
37
|
+
return {
|
|
38
|
+
...DeliveryAdapter.actions(config, context),
|
|
39
|
+
|
|
40
|
+
isActive: () => {
|
|
41
|
+
return active ?? true;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
isAutoReleaseAllowed: () => {
|
|
45
|
+
return autoReleaseAllowed ?? true;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
configurationError: () => {
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
estimatedDeliveryThroughput: async (warehousingThroughputTime) => {
|
|
53
|
+
if (estimatedDeliveryThroughput) {
|
|
54
|
+
return estimatedDeliveryThroughput(warehousingThroughputTime, context);
|
|
55
|
+
}
|
|
56
|
+
return 0;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
send: async () => {
|
|
60
|
+
return typeof send === 'function' ? await send(config, context) : send;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TokenSurrogate,
|
|
3
|
+
WarehousingConfiguration,
|
|
4
|
+
WarehousingProviderType,
|
|
5
|
+
} from '@unchainedshop/core-warehousing';
|
|
6
|
+
import { WarehousingAdapter, WarehousingContext, WarehousingDirector } from '../core-index.js';
|
|
7
|
+
|
|
8
|
+
export default function registerVirtualWarehousing<Metadata = Record<string, any>>({
|
|
9
|
+
adapterId,
|
|
10
|
+
orderIndex = 0,
|
|
11
|
+
stock,
|
|
12
|
+
tokenize,
|
|
13
|
+
tokenMetadata,
|
|
14
|
+
isInvalidateable,
|
|
15
|
+
}: {
|
|
16
|
+
adapterId: string;
|
|
17
|
+
orderIndex?: number;
|
|
18
|
+
stock?:
|
|
19
|
+
| number
|
|
20
|
+
| ((
|
|
21
|
+
referenceDate: Date,
|
|
22
|
+
configuration: WarehousingConfiguration,
|
|
23
|
+
context: WarehousingContext,
|
|
24
|
+
) => Promise<number>);
|
|
25
|
+
|
|
26
|
+
tokenize: (
|
|
27
|
+
configuration: WarehousingConfiguration,
|
|
28
|
+
context: WarehousingContext,
|
|
29
|
+
) => Promise<Omit<TokenSurrogate, 'userId' | 'productId' | 'orderPositionId'>[]>;
|
|
30
|
+
|
|
31
|
+
tokenMetadata?: (
|
|
32
|
+
serialNumber: string,
|
|
33
|
+
referenceDate: Date,
|
|
34
|
+
configuration: WarehousingConfiguration,
|
|
35
|
+
context: WarehousingContext,
|
|
36
|
+
) => Promise<Metadata>;
|
|
37
|
+
|
|
38
|
+
isInvalidateable?: (
|
|
39
|
+
serialNumber: string,
|
|
40
|
+
referenceDate: Date,
|
|
41
|
+
configuration: WarehousingConfiguration,
|
|
42
|
+
context: WarehousingContext,
|
|
43
|
+
) => Promise<boolean>;
|
|
44
|
+
}) {
|
|
45
|
+
WarehousingDirector.registerAdapter({
|
|
46
|
+
...WarehousingAdapter,
|
|
47
|
+
|
|
48
|
+
key: 'shop.unchained.warehousing.virtual.' + adapterId,
|
|
49
|
+
label: 'Virtual Wareshousing: ' + adapterId,
|
|
50
|
+
version: '1.0.0',
|
|
51
|
+
orderIndex,
|
|
52
|
+
|
|
53
|
+
initialConfiguration: [{ key: 'shipping-hub', value: 'Shipping Hub' }],
|
|
54
|
+
|
|
55
|
+
typeSupported: (type) => {
|
|
56
|
+
return type === WarehousingProviderType.VIRTUAL;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
actions: (configuration, context) => {
|
|
60
|
+
return {
|
|
61
|
+
...WarehousingAdapter.actions(configuration, context),
|
|
62
|
+
|
|
63
|
+
isActive() {
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
configurationError() {
|
|
68
|
+
return null;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
stock: async (referenceDate) => {
|
|
72
|
+
if (typeof stock === 'number') {
|
|
73
|
+
return stock;
|
|
74
|
+
} else if (typeof stock === 'function') {
|
|
75
|
+
return stock(referenceDate, configuration, context);
|
|
76
|
+
}
|
|
77
|
+
return 99999;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
async tokenize() {
|
|
81
|
+
return tokenize(configuration, context);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async tokenMetadata(serialNumber, referenceDate) {
|
|
85
|
+
if (tokenMetadata) {
|
|
86
|
+
return tokenMetadata(serialNumber, referenceDate, configuration, context);
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
async isInvalidateable(serialNumber, referenceDate) {
|
|
92
|
+
if (isInvalidateable) {
|
|
93
|
+
return isInvalidateable(serialNumber, referenceDate, configuration, context);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { WorkerAdapter, WorkerDirector } from '../core-index.js';
|
|
2
|
+
|
|
3
|
+
export default function registerWorker<Input = any, Result = any>({
|
|
4
|
+
type,
|
|
5
|
+
external,
|
|
6
|
+
maxParallelAllocations,
|
|
7
|
+
process,
|
|
8
|
+
}: {
|
|
9
|
+
type: string;
|
|
10
|
+
external?: boolean;
|
|
11
|
+
maxParallelAllocations?: number;
|
|
12
|
+
process?: (input: Input, workId: string) => Promise<Result>;
|
|
13
|
+
}) {
|
|
14
|
+
WorkerDirector.registerAdapter({
|
|
15
|
+
...WorkerAdapter,
|
|
16
|
+
|
|
17
|
+
key: 'shop.unchained.worker.' + type.toLowerCase(),
|
|
18
|
+
label: 'Worker: ' + type,
|
|
19
|
+
version: '1.0',
|
|
20
|
+
external: external ?? false,
|
|
21
|
+
maxParallelAllocations,
|
|
22
|
+
type,
|
|
23
|
+
|
|
24
|
+
async doWork(input, _, workId) {
|
|
25
|
+
if (!process) {
|
|
26
|
+
return { success: false };
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const result = await process(input, workId);
|
|
30
|
+
return {
|
|
31
|
+
success: true,
|
|
32
|
+
result,
|
|
33
|
+
};
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: {
|
|
38
|
+
name: err.name,
|
|
39
|
+
message: err.message,
|
|
40
|
+
cause: err.cause,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|