@unchainedshop/plugins 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.
Files changed (184) hide show
  1. package/README.md +0 -2
  2. package/lib/events/node-event-emitter.d.ts +3 -1
  3. package/lib/events/node-event-emitter.js +3 -3
  4. package/lib/files/gridfs/adapter.d.ts +2 -2
  5. package/lib/files/gridfs/adapter.js +2 -5
  6. package/lib/files/gridfs/index.d.ts +5 -4
  7. package/lib/files/gridfs/index.js +30 -3
  8. package/lib/files/minio/index.d.ts +4 -5
  9. package/lib/files/minio/index.js +18 -157
  10. package/lib/payment/apple-iap/adapter.d.ts +2 -1
  11. package/lib/payment/apple-iap/adapter.js +2 -3
  12. package/lib/payment/apple-iap/index.d.ts +6 -4
  13. package/lib/payment/apple-iap/index.js +28 -3
  14. package/lib/payment/cryptopay/index.d.ts +5 -4
  15. package/lib/payment/cryptopay/index.js +31 -3
  16. package/lib/payment/datatrans-v2/index.d.ts +4 -1
  17. package/lib/payment/datatrans-v2/index.js +17 -400
  18. package/lib/payment/payrexx/index.d.ts +4 -1
  19. package/lib/payment/payrexx/index.js +19 -158
  20. package/lib/payment/postfinance-checkout/index.d.ts +5 -0
  21. package/lib/payment/postfinance-checkout/index.js +25 -186
  22. package/lib/payment/saferpay/adapter.js +1 -2
  23. package/lib/payment/saferpay/index.d.ts +5 -4
  24. package/lib/payment/saferpay/index.js +29 -3
  25. package/lib/payment/stripe/index.d.ts +4 -1
  26. package/lib/payment/stripe/index.js +22 -116
  27. package/lib/payment/stripe/stripe.js +2 -5
  28. package/lib/presets/all.d.ts +1 -70
  29. package/lib/presets/all.js +41 -27
  30. package/lib/presets/base.d.ts +1 -25
  31. package/lib/presets/base.js +56 -25
  32. package/lib/presets/countries/ch.d.ts +1 -2
  33. package/lib/presets/countries/ch.js +7 -2
  34. package/lib/presets/crypto.d.ts +3 -7
  35. package/lib/presets/crypto.js +18 -7
  36. package/package.json +15 -10
  37. package/lib/delivery/post.d.ts +0 -1
  38. package/lib/delivery/post.js +0 -23
  39. package/lib/delivery/send-message.d.ts +0 -1
  40. package/lib/delivery/send-message.js +0 -40
  41. package/lib/delivery/stores.d.ts +0 -1
  42. package/lib/delivery/stores.js +0 -43
  43. package/lib/enrollments/licensed.d.ts +0 -4
  44. package/lib/enrollments/licensed.js +0 -52
  45. package/lib/files/gridfs/handler-express.d.ts +0 -9
  46. package/lib/files/gridfs/handler-express.js +0 -110
  47. package/lib/files/gridfs/handler-fastify.d.ts +0 -3
  48. package/lib/files/gridfs/handler-fastify.js +0 -138
  49. package/lib/files/minio/handler-express.d.ts +0 -2
  50. package/lib/files/minio/handler-express.js +0 -36
  51. package/lib/files/minio/handler-fastify.d.ts +0 -3
  52. package/lib/files/minio/handler-fastify.js +0 -40
  53. package/lib/filters/local-search.d.ts +0 -3
  54. package/lib/filters/local-search.js +0 -66
  55. package/lib/filters/strict-equal.d.ts +0 -1
  56. package/lib/filters/strict-equal.js +0 -24
  57. package/lib/payment/apple-iap/handler-express.d.ts +0 -2
  58. package/lib/payment/apple-iap/handler-express.js +0 -103
  59. package/lib/payment/apple-iap/handler-fastify.d.ts +0 -3
  60. package/lib/payment/apple-iap/handler-fastify.js +0 -102
  61. package/lib/payment/braintree.d.ts +0 -1
  62. package/lib/payment/braintree.js +0 -138
  63. package/lib/payment/cryptopay/handler-express.d.ts +0 -2
  64. package/lib/payment/cryptopay/handler-express.js +0 -19
  65. package/lib/payment/cryptopay/handler-fastify.d.ts +0 -3
  66. package/lib/payment/cryptopay/handler-fastify.js +0 -17
  67. package/lib/payment/cryptopay/plugin.d.ts +0 -3
  68. package/lib/payment/cryptopay/plugin.js +0 -159
  69. package/lib/payment/datatrans-v2/handler-express.d.ts +0 -1
  70. package/lib/payment/datatrans-v2/handler-express.js +0 -71
  71. package/lib/payment/datatrans-v2/handler-fastify.d.ts +0 -2
  72. package/lib/payment/datatrans-v2/handler-fastify.js +0 -71
  73. package/lib/payment/invoice-prepaid.d.ts +0 -1
  74. package/lib/payment/invoice-prepaid.js +0 -30
  75. package/lib/payment/invoice.d.ts +0 -1
  76. package/lib/payment/invoice.js +0 -27
  77. package/lib/payment/paypal-checkout.d.ts +0 -1
  78. package/lib/payment/paypal-checkout.js +0 -87
  79. package/lib/payment/payrexx/handler-express.d.ts +0 -1
  80. package/lib/payment/payrexx/handler-express.js +0 -85
  81. package/lib/payment/payrexx/handler-fastify.d.ts +0 -2
  82. package/lib/payment/payrexx/handler-fastify.js +0 -91
  83. package/lib/payment/postfinance-checkout/handler-express.d.ts +0 -1
  84. package/lib/payment/postfinance-checkout/handler-express.js +0 -37
  85. package/lib/payment/postfinance-checkout/handler-fastify.d.ts +0 -2
  86. package/lib/payment/postfinance-checkout/handler-fastify.js +0 -40
  87. package/lib/payment/saferpay/handler-express.d.ts +0 -1
  88. package/lib/payment/saferpay/handler-express.js +0 -59
  89. package/lib/payment/saferpay/handler-fastify.d.ts +0 -2
  90. package/lib/payment/saferpay/handler-fastify.js +0 -62
  91. package/lib/payment/stripe/handler-express.d.ts +0 -5
  92. package/lib/payment/stripe/handler-express.js +0 -121
  93. package/lib/payment/stripe/handler-fastify.d.ts +0 -6
  94. package/lib/payment/stripe/handler-fastify.js +0 -131
  95. package/lib/presets/all-express.d.ts +0 -6
  96. package/lib/presets/all-express.js +0 -26
  97. package/lib/presets/all-fastify.d.ts +0 -6
  98. package/lib/presets/all-fastify.js +0 -49
  99. package/lib/presets/base-express.d.ts +0 -2
  100. package/lib/presets/base-express.js +0 -5
  101. package/lib/presets/base-fastify.d.ts +0 -3
  102. package/lib/presets/base-fastify.js +0 -16
  103. package/lib/presets/crypto-express.d.ts +0 -3
  104. package/lib/presets/crypto-express.js +0 -8
  105. package/lib/presets/crypto-fastify.d.ts +0 -3
  106. package/lib/presets/crypto-fastify.js +0 -11
  107. package/lib/pricing/delivery-swiss-tax.d.ts +0 -2
  108. package/lib/pricing/delivery-swiss-tax.js +0 -62
  109. package/lib/pricing/discount-100-off.d.ts +0 -2
  110. package/lib/pricing/discount-100-off.js +0 -30
  111. package/lib/pricing/discount-half-price-manual.d.ts +0 -2
  112. package/lib/pricing/discount-half-price-manual.js +0 -30
  113. package/lib/pricing/discount-half-price.d.ts +0 -2
  114. package/lib/pricing/discount-half-price.js +0 -33
  115. package/lib/pricing/free-delivery.d.ts +0 -2
  116. package/lib/pricing/free-delivery.js +0 -27
  117. package/lib/pricing/free-payment.d.ts +0 -2
  118. package/lib/pricing/free-payment.js +0 -27
  119. package/lib/pricing/order-delivery.d.ts +0 -2
  120. package/lib/pricing/order-delivery.js +0 -33
  121. package/lib/pricing/order-discount.d.ts +0 -2
  122. package/lib/pricing/order-discount.js +0 -74
  123. package/lib/pricing/order-items-discount.d.ts +0 -2
  124. package/lib/pricing/order-items-discount.js +0 -50
  125. package/lib/pricing/order-items.d.ts +0 -2
  126. package/lib/pricing/order-items.js +0 -43
  127. package/lib/pricing/order-payment.d.ts +0 -2
  128. package/lib/pricing/order-payment.js +0 -33
  129. package/lib/pricing/order-round.d.ts +0 -10
  130. package/lib/pricing/order-round.js +0 -135
  131. package/lib/pricing/product-catalog-price-options.d.ts +0 -2
  132. package/lib/pricing/product-catalog-price-options.js +0 -51
  133. package/lib/pricing/product-catalog-price.d.ts +0 -2
  134. package/lib/pricing/product-catalog-price.js +0 -60
  135. package/lib/pricing/product-discount.d.ts +0 -2
  136. package/lib/pricing/product-discount.js +0 -69
  137. package/lib/pricing/product-price-rateconversion.d.ts +0 -2
  138. package/lib/pricing/product-price-rateconversion.js +0 -53
  139. package/lib/pricing/product-round.d.ts +0 -10
  140. package/lib/pricing/product-round.js +0 -44
  141. package/lib/pricing/product-swiss-tax.d.ts +0 -2
  142. package/lib/pricing/product-swiss-tax.js +0 -76
  143. package/lib/quotations/manual.d.ts +0 -1
  144. package/lib/quotations/manual.js +0 -20
  145. package/lib/warehousing/eth-minter.d.ts +0 -1
  146. package/lib/warehousing/eth-minter.js +0 -120
  147. package/lib/warehousing/store.d.ts +0 -1
  148. package/lib/warehousing/store.js +0 -34
  149. package/lib/worker/budgetsms.d.ts +0 -9
  150. package/lib/worker/budgetsms.js +0 -169
  151. package/lib/worker/bulk-export.d.ts +0 -2
  152. package/lib/worker/bulk-export.js +0 -64
  153. package/lib/worker/bulk-import.d.ts +0 -2
  154. package/lib/worker/bulk-import.js +0 -65
  155. package/lib/worker/bulkgate.d.ts +0 -1
  156. package/lib/worker/bulkgate.js +0 -91
  157. package/lib/worker/email.d.ts +0 -1
  158. package/lib/worker/email.js +0 -136
  159. package/lib/worker/enrollment-order-generator.d.ts +0 -1
  160. package/lib/worker/enrollment-order-generator.js +0 -77
  161. package/lib/worker/error-notifications.d.ts +0 -9
  162. package/lib/worker/error-notifications.js +0 -61
  163. package/lib/worker/export-token.d.ts +0 -4
  164. package/lib/worker/export-token.js +0 -26
  165. package/lib/worker/external.d.ts +0 -2
  166. package/lib/worker/external.js +0 -13
  167. package/lib/worker/heartbeat.d.ts +0 -1
  168. package/lib/worker/heartbeat.js +0 -26
  169. package/lib/worker/http-request.d.ts +0 -8
  170. package/lib/worker/http-request.js +0 -56
  171. package/lib/worker/message.d.ts +0 -10
  172. package/lib/worker/message.js +0 -42
  173. package/lib/worker/push-notification.d.ts +0 -1
  174. package/lib/worker/push-notification.js +0 -87
  175. package/lib/worker/twilio.d.ts +0 -1
  176. package/lib/worker/twilio.js +0 -59
  177. package/lib/worker/update-coinbase-rates.d.ts +0 -1
  178. package/lib/worker/update-coinbase-rates.js +0 -59
  179. package/lib/worker/update-ecb-rates.d.ts +0 -1
  180. package/lib/worker/update-ecb-rates.js +0 -92
  181. package/lib/worker/update-token-ownership.d.ts +0 -3
  182. package/lib/worker/update-token-ownership.js +0 -57
  183. package/lib/worker/zombie-killer.d.ts +0 -13
  184. package/lib/worker/zombie-killer.js +0 -91
@@ -1,25 +1,56 @@
1
- import "../delivery/post.js";
2
- import "../payment/invoice.js";
3
- import "../warehousing/store.js";
4
- import "../pricing/free-payment.js";
5
- import "../pricing/free-delivery.js";
6
- import "../pricing/order-items.js";
7
- import "../pricing/order-discount.js";
8
- import "../pricing/order-delivery.js";
9
- import "../pricing/order-payment.js";
10
- import "../pricing/product-catalog-price.js";
11
- import "../pricing/product-discount.js";
12
- import "../quotations/manual.js";
13
- import "../enrollments/licensed.js";
14
- import "../events/node-event-emitter.js";
15
- import "../worker/bulk-import.js";
16
- import "../worker/zombie-killer.js";
17
- import "../worker/message.js";
18
- import "../worker/external.js";
19
- import "../worker/http-request.js";
20
- import "../worker/heartbeat.js";
21
- import "../worker/email.js";
22
- import "../worker/error-notifications.js";
23
- import "../worker/bulk-export.js";
24
- import gridfsModules from "../files/gridfs/index.js";
25
- export default gridfsModules;
1
+ import { pluginRegistry } from '@unchainedshop/core';
2
+ import { setEmitAdapter } from '@unchainedshop/events';
3
+ import { GridFSPlugin } from "../files/gridfs/index.js";
4
+ import { TempUploadPlugin } from "../files/temp-upload/index.js";
5
+ import { InvoicePlugin } from "../payment/invoice/index.js";
6
+ import { PostPlugin } from "../delivery/post/index.js";
7
+ import { StorePlugin } from "../warehousing/store/index.js";
8
+ import { ERCMetadataPlugin } from "../warehousing/erc-metadata/index.js";
9
+ import { PaymentFreePricePlugin } from "../pricing/free-payment/index.js";
10
+ import { DeliveryFreePricePlugin } from "../pricing/free-delivery/index.js";
11
+ import { OrderItemsPlugin } from "../pricing/order-items/index.js";
12
+ import { OrderDiscountPlugin } from "../pricing/order-discount/index.js";
13
+ import { OrderDeliveryPlugin } from "../pricing/order-delivery/index.js";
14
+ import { OrderPaymentPlugin } from "../pricing/order-payment/index.js";
15
+ import { ProductPricePlugin } from "../pricing/product-catalog-price/index.js";
16
+ import { ProductDiscountPlugin } from "../pricing/product-discount/index.js";
17
+ import { ManualOfferingPlugin } from "../quotations/manual/index.js";
18
+ import { LicensedEnrollmentsPlugin } from "../enrollments/licensed/index.js";
19
+ import { NodeEventEmitter } from "../events/node-event-emitter.js";
20
+ import { BulkImportPlugin } from "../worker/bulk-import/index.js";
21
+ import { ZombieKillerPlugin } from "../worker/zombie-killer/index.js";
22
+ import { MessagePlugin } from "../worker/message/index.js";
23
+ import { ExternalPlugin } from "../worker/external/index.js";
24
+ import { HttpRequestPlugin } from "../worker/http-request/index.js";
25
+ import { HeartbeatPlugin } from "../worker/heartbeat/index.js";
26
+ import { EmailPlugin } from "../worker/email/index.js";
27
+ import { ErrorNotificationsPlugin } from "../worker/error-notifications/index.js";
28
+ import { BulkExportPlugin } from "../worker/bulk-export/index.js";
29
+ export function registerBasePlugins() {
30
+ pluginRegistry.register(GridFSPlugin);
31
+ pluginRegistry.register(TempUploadPlugin);
32
+ pluginRegistry.register(InvoicePlugin);
33
+ pluginRegistry.register(PostPlugin);
34
+ pluginRegistry.register(StorePlugin);
35
+ pluginRegistry.register(ERCMetadataPlugin);
36
+ pluginRegistry.register(PaymentFreePricePlugin);
37
+ pluginRegistry.register(DeliveryFreePricePlugin);
38
+ pluginRegistry.register(OrderItemsPlugin);
39
+ pluginRegistry.register(OrderDiscountPlugin);
40
+ pluginRegistry.register(OrderDeliveryPlugin);
41
+ pluginRegistry.register(OrderPaymentPlugin);
42
+ pluginRegistry.register(ProductPricePlugin);
43
+ pluginRegistry.register(ProductDiscountPlugin);
44
+ pluginRegistry.register(ManualOfferingPlugin);
45
+ pluginRegistry.register(LicensedEnrollmentsPlugin);
46
+ setEmitAdapter(NodeEventEmitter());
47
+ pluginRegistry.register(BulkImportPlugin);
48
+ pluginRegistry.register(ZombieKillerPlugin);
49
+ pluginRegistry.register(MessagePlugin);
50
+ pluginRegistry.register(ExternalPlugin);
51
+ pluginRegistry.register(HttpRequestPlugin);
52
+ pluginRegistry.register(HeartbeatPlugin);
53
+ pluginRegistry.register(EmailPlugin);
54
+ pluginRegistry.register(ErrorNotificationsPlugin);
55
+ pluginRegistry.register(BulkExportPlugin);
56
+ }
@@ -1,2 +1 @@
1
- import '../../pricing/product-swiss-tax.ts';
2
- import '../../pricing/delivery-swiss-tax.ts';
1
+ export declare function registerSwissTaxPlugins(): void;
@@ -1,2 +1,7 @@
1
- import "../../pricing/product-swiss-tax.js";
2
- import "../../pricing/delivery-swiss-tax.js";
1
+ import { ProductSwissTaxPlugin } from "../../pricing/product-swiss-tax/index.js";
2
+ import { DeliverySwissTaxPlugin } from "../../pricing/delivery-swiss-tax/index.js";
3
+ import { pluginRegistry } from '@unchainedshop/core';
4
+ export function registerSwissTaxPlugins() {
5
+ pluginRegistry.register(ProductSwissTaxPlugin);
6
+ pluginRegistry.register(DeliverySwissTaxPlugin);
7
+ }
@@ -1,7 +1,3 @@
1
- import cryptopayModules from '../payment/cryptopay/index.ts';
2
- import '../warehousing/eth-minter.ts';
3
- import '../pricing/product-price-rateconversion.ts';
4
- import '../worker/update-ecb-rates.ts';
5
- import '../worker/update-coinbase-rates.ts';
6
- import '../worker/export-token.ts';
7
- export default cryptopayModules;
1
+ declare const _default: {};
2
+ export default _default;
3
+ export declare function registerCryptoPlugins(): void;
@@ -1,7 +1,18 @@
1
- import cryptopayModules from "../payment/cryptopay/index.js";
2
- import "../warehousing/eth-minter.js";
3
- import "../pricing/product-price-rateconversion.js";
4
- import "../worker/update-ecb-rates.js";
5
- import "../worker/update-coinbase-rates.js";
6
- import "../worker/export-token.js";
7
- export default cryptopayModules;
1
+ import { pluginRegistry } from '@unchainedshop/core';
2
+ import { CryptopayPlugin } from "../payment/cryptopay/index.js";
3
+ import { ETHMinterPlugin } from "../warehousing/eth-minter/index.js";
4
+ import { ProductPriceRateConversionPlugin } from "../pricing/product-price-rateconversion/index.js";
5
+ import { ExportTokenPlugin } from "../worker/export-token/index.js";
6
+ import { UpdateECBRatesPlugin } from "../worker/update-ecb-rates/index.js";
7
+ import { UpdateCoinbaseRatesPlugin } from "../worker/update-coinbase-rates/index.js";
8
+ import { UpdateTokenOwnershipPlugin } from "../worker/update-token-ownership/index.js";
9
+ export default {};
10
+ export function registerCryptoPlugins() {
11
+ pluginRegistry.register(CryptopayPlugin);
12
+ pluginRegistry.register(ETHMinterPlugin);
13
+ pluginRegistry.register(ProductPriceRateConversionPlugin);
14
+ pluginRegistry.register(ExportTokenPlugin);
15
+ pluginRegistry.register(UpdateECBRatesPlugin);
16
+ pluginRegistry.register(UpdateCoinbaseRatesPlugin);
17
+ pluginRegistry.register(UpdateTokenOwnershipPlugin);
18
+ }
package/package.json CHANGED
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
3
  "description": "Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters",
4
- "version": "4.6.2",
4
+ "version": "4.7.2",
5
5
  "main": "lib/plugins-index.js",
6
6
  "types": "lib/plugins-index.d.ts",
7
7
  "exports": {
8
- "./*": "./lib/*"
8
+ "./presets/*": "./lib/presets/*.js",
9
+ "./presets/countries/*": "./lib/presets/countries/*.js",
10
+ "./events/*": "./lib/events/*.js",
11
+ "./enrollments/*": "./lib/enrollments/*/index.js",
12
+ "./quotations/*": "./lib/quotations/*/index.js",
13
+ "./filters/*": "./lib/filters/*/index.js",
14
+ "./delivery/*": "./lib/delivery/*/index.js",
15
+ "./warehousing/*": "./lib/warehousing/*/index.js",
16
+ "./payment/*": "./lib/payment/*/index.js",
17
+ "./files/*": "./lib/files/*/index.js",
18
+ "./pricing/*": "./lib/pricing/*/index.js",
19
+ "./worker/*": "./lib/worker/*/index.js"
9
20
  },
10
21
  "type": "module",
11
22
  "scripts": {
@@ -46,13 +57,11 @@
46
57
  "@unchainedshop/core-warehousing": "^4.6.0",
47
58
  "@unchainedshop/core-worker": "^4.6.0",
48
59
  "@unchainedshop/events": "^4.6.0",
49
- "@unchainedshop/file-upload": "^4.6.0",
50
60
  "@unchainedshop/logger": "^4.6.0",
51
61
  "@unchainedshop/utils": "^4.6.0"
52
62
  },
53
63
  "peerDependencies": {
54
64
  "@aws-sdk/client-eventbridge": ">= 3.714 < 4",
55
- "@paypal/checkout-server-sdk": "1.x",
56
65
  "@redis/client": ">= 1 < 6",
57
66
  "@scure/bip32": ">= 2",
58
67
  "@scure/btc-signer": ">= 2",
@@ -61,7 +70,7 @@
61
70
  "express": ">= 5 < 6",
62
71
  "fastify": ">= 5.2 < 6",
63
72
  "minio": "8.x",
64
- "nodemailer": ">= 6.9 < 8",
73
+ "nodemailer": ">= 6.9 < 9",
65
74
  "p-memoize": "8.x",
66
75
  "stripe": ">= 19 < 21",
67
76
  "web-push": ">= 3.6 <4",
@@ -71,9 +80,6 @@
71
80
  "@aws-sdk/client-eventbridge": {
72
81
  "optional": true
73
82
  },
74
- "@paypal/checkout-server-sdk": {
75
- "optional": true
76
- },
77
83
  "@redis/client": {
78
84
  "optional": true
79
85
  },
@@ -112,7 +118,6 @@
112
118
  }
113
119
  },
114
120
  "devDependencies": {
115
- "@paypal/checkout-server-sdk": "^1.0.3",
116
121
  "@redis/client": "^5.6.0",
117
122
  "@scure/bip32": "^2.0.0",
118
123
  "@scure/btc-signer": "^2.0.0",
@@ -122,7 +127,7 @@
122
127
  "express": "^5.1.0",
123
128
  "fastify": "^5.4.0",
124
129
  "minio": "^8.0.5",
125
- "nodemailer": "^7.0.5",
130
+ "nodemailer": "^8.0.1",
126
131
  "p-memoize": "^8.0.0",
127
132
  "stripe": "^20.0.0",
128
133
  "typescript": "^5.8.3",
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { DeliveryAdapter, DeliveryDirector } from '@unchainedshop/core';
2
- import { DeliveryProviderType } from '@unchainedshop/core-delivery';
3
- const Post = {
4
- ...DeliveryAdapter,
5
- key: 'shop.unchained.post',
6
- label: 'Manual',
7
- version: '1.0.0',
8
- typeSupported: (type) => {
9
- return type === DeliveryProviderType.SHIPPING;
10
- },
11
- actions: (config, context) => {
12
- return {
13
- ...DeliveryAdapter.actions(config, context),
14
- isActive: () => {
15
- return true;
16
- },
17
- configurationError: () => {
18
- return null;
19
- },
20
- };
21
- },
22
- };
23
- DeliveryDirector.registerAdapter(Post);
@@ -1 +0,0 @@
1
- export {};
@@ -1,40 +0,0 @@
1
- import { DeliveryAdapter, DeliveryDirector } from '@unchainedshop/core';
2
- import { DeliveryProviderType } from '@unchainedshop/core-delivery';
3
- const SendMessage = {
4
- ...DeliveryAdapter,
5
- key: 'shop.unchained.delivery.send-message',
6
- label: 'Forward via Messaging',
7
- version: '1.0.0',
8
- initialConfiguration: [
9
- { key: 'from', value: '' },
10
- { key: 'to', value: '' },
11
- { key: 'cc', value: '' },
12
- ],
13
- typeSupported: (type) => {
14
- return type === DeliveryProviderType.SHIPPING;
15
- },
16
- actions: (config, context) => {
17
- return {
18
- ...DeliveryAdapter.actions(config, context),
19
- isActive: () => {
20
- return true;
21
- },
22
- configurationError: () => {
23
- return null;
24
- },
25
- send: async () => {
26
- const { modules, order } = context;
27
- return modules.worker.addWork({
28
- type: 'MESSAGE',
29
- retries: 0,
30
- input: {
31
- template: 'DELIVERY',
32
- orderId: order._id,
33
- config,
34
- },
35
- });
36
- },
37
- };
38
- },
39
- };
40
- DeliveryDirector.registerAdapter(SendMessage);
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- import { DeliveryAdapter, DeliveryDirector } from '@unchainedshop/core';
2
- import { DeliveryProviderType } from '@unchainedshop/core-delivery';
3
- const PickMup = {
4
- ...DeliveryAdapter,
5
- key: 'shop.unchained.stores',
6
- label: 'Pre-configured Stores',
7
- version: '1.0.0',
8
- typeSupported: (type) => {
9
- return type === DeliveryProviderType.PICKUP;
10
- },
11
- actions: (config, context) => {
12
- const getStores = () => {
13
- const storesItem = config.find((item) => item.key === 'stores');
14
- if (!storesItem)
15
- return [];
16
- try {
17
- return typeof storesItem.value === 'string' ? JSON.parse(storesItem.value) : storesItem.value;
18
- }
19
- catch {
20
- return storesItem?.value ?? [];
21
- }
22
- };
23
- return {
24
- ...DeliveryAdapter.actions(config, context),
25
- isActive() {
26
- return true;
27
- },
28
- isAutoReleaseAllowed() {
29
- return false;
30
- },
31
- configurationError() {
32
- return null;
33
- },
34
- pickUpLocationById: async (id) => {
35
- return getStores().find((store) => store._id === id);
36
- },
37
- pickUpLocations: async () => {
38
- return getStores();
39
- },
40
- };
41
- },
42
- };
43
- DeliveryDirector.registerAdapter(PickMup);
@@ -1,4 +0,0 @@
1
- export declare const rangeMatcher: (date?: Date) => ({ start, end }: {
2
- start: any;
3
- end: any;
4
- }) => boolean;
@@ -1,52 +0,0 @@
1
- import { EnrollmentDirector, EnrollmentAdapter } from '@unchainedshop/core';
2
- export const rangeMatcher = (date = new Date()) => {
3
- const timestamp = date.getTime();
4
- return ({ start, end }) => {
5
- const startTimestamp = new Date(start).getTime();
6
- const endTimestamp = new Date(end).getTime();
7
- return startTimestamp <= timestamp && endTimestamp >= timestamp;
8
- };
9
- };
10
- const LicensedEnrollments = {
11
- ...EnrollmentAdapter,
12
- key: 'shop.unchained.enrollments.licensed',
13
- version: '1.0.0',
14
- label: 'Simple Licensed Enrollments',
15
- isActivatedFor: (productPlan) => {
16
- return productPlan?.usageCalculationType === 'LICENSED';
17
- },
18
- actions: (params) => {
19
- const { enrollment } = params;
20
- return {
21
- ...EnrollmentAdapter.actions(params),
22
- isValidForActivation: async () => {
23
- const periods = enrollment?.periods || [];
24
- return periods.findIndex(rangeMatcher()) !== -1;
25
- },
26
- isOverdue: async () => {
27
- return false;
28
- },
29
- configurationForOrder: async (context) => {
30
- const { period } = context;
31
- const beginningOfPeriod = period.start.getTime() <= new Date().getTime();
32
- if (!enrollment)
33
- throw new Error('Enrollment missing in context');
34
- if (beginningOfPeriod) {
35
- return {
36
- period,
37
- orderContext: {},
38
- orderPositionTemplates: [
39
- {
40
- quantity: 1,
41
- productId: enrollment.productId,
42
- originalProductId: enrollment.productId,
43
- },
44
- ],
45
- };
46
- }
47
- return null;
48
- },
49
- };
50
- },
51
- };
52
- EnrollmentDirector.registerAdapter(LicensedEnrollments);
@@ -1,9 +0,0 @@
1
- import express from 'express';
2
- import { type GridFSFileUploadsModule } from './module.ts';
3
- import { type Context } from '@unchainedshop/api';
4
- declare const gridfsHandler: (req: express.Request & {
5
- unchainedContext: Context & {
6
- modules: GridFSFileUploadsModule;
7
- };
8
- }, res: express.Response) => Promise<void>;
9
- export default gridfsHandler;
@@ -1,110 +0,0 @@
1
- import { pipeline, finished } from 'node:stream/promises';
2
- import { PassThrough } from 'node:stream';
3
- import { buildHashedFilename } from '@unchainedshop/file-upload';
4
- import express from 'express';
5
- import sign from "./sign.js";
6
- import {} from "./module.js";
7
- import {} from '@unchainedshop/api';
8
- import { createLogger } from '@unchainedshop/logger';
9
- import { getFileAdapter } from '@unchainedshop/core-files';
10
- import { timingSafeStringEqual } from '@unchainedshop/utils';
11
- const { ROOT_URL, GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
12
- const logger = createLogger('unchained:gridfs');
13
- const gridfsHandler = async (req, res) => {
14
- try {
15
- const { services, modules } = req.unchainedContext;
16
- const url = new URL(req.url, ROOT_URL);
17
- const [, directoryNameRaw, fileNameRaw] = url.pathname.split('/');
18
- const directoryName = decodeURIComponent(directoryNameRaw);
19
- const fileName = decodeURIComponent(fileNameRaw);
20
- res.setHeader('Access-Control-Allow-Methods', 'GET, PUT');
21
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
22
- res.setHeader('Access-Control-Allow-Origin', '*');
23
- if (req.method === 'OPTIONS') {
24
- res.status(200).end();
25
- return;
26
- }
27
- if (req.method === 'PUT') {
28
- const { s: signature, e: expiryTimestamp } = req.query;
29
- const expiryDate = new Date(parseInt(expiryTimestamp, 10));
30
- const fileId = await buildHashedFilename(directoryName, fileName, expiryDate);
31
- const expectedSignature = await sign(directoryName, fileId, expiryDate.getTime());
32
- if (await timingSafeStringEqual(expectedSignature, signature)) {
33
- const file = await modules.files.findFile({ fileId });
34
- if (!file) {
35
- res.status(404).send('File not found');
36
- return;
37
- }
38
- if (file.expires === null) {
39
- res.status(400).send('File already linked');
40
- return;
41
- }
42
- const type = req.header('Content-Type') === 'application/octet-stream'
43
- ? file.type || req.header('Content-Type')
44
- : req.header('Content-Type') || file.type;
45
- const writeStream = await modules.gridfsFileUploads.createWriteStream(directoryName, fileId, fileName, {
46
- chunkSizeBytes: 1024 * 1024,
47
- metadata: { 'content-type': type },
48
- });
49
- await pipeline(req, new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), writeStream);
50
- await finished(writeStream, { readable: false });
51
- const { length } = writeStream;
52
- await services.files.linkFile({ fileId, size: length, type });
53
- res.status(200).end();
54
- return;
55
- }
56
- res.status(403).end();
57
- return;
58
- }
59
- if (req.method === 'GET') {
60
- const { s: signature, e: expiryTimestamp } = req.query;
61
- const fileDocument = await modules.files.findFile({
62
- url: `${GRIDFS_PUT_SERVER_PATH}/${directoryName}/${fileName}`,
63
- });
64
- if (fileDocument?.meta?.isPrivate) {
65
- const expiry = parseInt(expiryTimestamp, 10);
66
- if (expiry <= Date.now()) {
67
- res.status(403).send('Access restricted: Expired.');
68
- return;
69
- }
70
- const fileUploadAdapter = getFileAdapter();
71
- const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
72
- const expectedSignature = signedUrl ? new URL(signedUrl, 'file://').searchParams.get('s') : null;
73
- if (!signedUrl ||
74
- !expectedSignature ||
75
- !(await timingSafeStringEqual(expectedSignature, signature))) {
76
- res.status(403).send('Access restricted: Invalid signature.');
77
- return;
78
- }
79
- }
80
- else if (!fileDocument) {
81
- res.status(404).end();
82
- return;
83
- }
84
- const file = await modules.gridfsFileUploads.getFileInfo(directoryName, fileDocument._id);
85
- if (file?.metadata?.['content-type']) {
86
- res.setHeader('Content-Type', file.metadata['content-type']);
87
- }
88
- if (file?.length) {
89
- res.setHeader('Content-Length', file?.length.toString());
90
- }
91
- const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileDocument._id);
92
- readStream.pipe(res, { end: false });
93
- await finished(readStream);
94
- res.status(200).end();
95
- return;
96
- }
97
- res.status(404).end();
98
- }
99
- catch (e) {
100
- if (e.code === 'ENOENT') {
101
- logger.warn(e);
102
- res.status(404).send();
103
- }
104
- else {
105
- logger.warn(e);
106
- res.status(503).send({ name: e.name, code: e.code, message: e.message });
107
- }
108
- }
109
- };
110
- export default gridfsHandler;
@@ -1,3 +0,0 @@
1
- import { type RouteHandlerMethod } from 'fastify';
2
- declare const gridfsHandler: RouteHandlerMethod;
3
- export default gridfsHandler;
@@ -1,138 +0,0 @@
1
- import { finished, pipeline } from 'node:stream/promises';
2
- import { PassThrough } from 'node:stream';
3
- import {} from 'fastify';
4
- import { buildHashedFilename } from '@unchainedshop/file-upload';
5
- import sign from "./sign.js";
6
- import {} from "./module.js";
7
- import {} from '@unchainedshop/api';
8
- import { createLogger } from '@unchainedshop/logger';
9
- import { getFileAdapter } from '@unchainedshop/core-files';
10
- import { timingSafeStringEqual } from '@unchainedshop/utils';
11
- const logger = createLogger('unchained:gridfs');
12
- const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
13
- const gridfsHandler = async (req, reply) => {
14
- try {
15
- const { services, modules } = req.unchainedContext;
16
- const { directoryName, fileName } = req.params;
17
- reply.header('Access-Control-Allow-Methods', 'GET, PUT');
18
- reply.header('Access-Control-Allow-Headers', 'content-type');
19
- reply.header('Access-Control-Allow-Origin', '*');
20
- if (req.method === 'OPTIONS') {
21
- reply.status(200);
22
- return reply.send();
23
- }
24
- if (req.method === 'PUT') {
25
- const { s: signature, e: expiryTimestamp } = req.query;
26
- const expiryDate = new Date(parseInt(expiryTimestamp, 10));
27
- const fileId = await buildHashedFilename(directoryName, fileName, expiryDate);
28
- const expectedSignature = await sign(directoryName, fileId, expiryDate.getTime());
29
- if (await timingSafeStringEqual(expectedSignature, signature)) {
30
- const file = await modules.files.findFile({ fileId });
31
- if (!file) {
32
- reply.status(404);
33
- logger.error('File not found', { fileId });
34
- return reply.send({
35
- success: false,
36
- message: 'File not found',
37
- name: 'FILE_NOT_FOUND',
38
- });
39
- }
40
- if (file.expires === null) {
41
- reply.status(400);
42
- logger.error('File already linked', { fileId });
43
- return reply.send({
44
- success: false,
45
- message: 'File already linked',
46
- name: 'FILE_ALREADY_LINKED',
47
- });
48
- }
49
- const type = req.headers['content-type'] === 'application/octet-stream'
50
- ? file.type || req.headers['content-type']
51
- : req.headers['content-type'] || file.type;
52
- const writeStream = await modules.gridfsFileUploads.createWriteStream(directoryName, fileId, fileName, {
53
- chunkSizeBytes: 1024 * 1024,
54
- metadata: { 'content-type': type },
55
- });
56
- await pipeline(req.raw, new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), writeStream);
57
- await finished(writeStream, { readable: false });
58
- const { length } = writeStream;
59
- await services.files.linkFile({ fileId, size: length, type });
60
- reply.status(200);
61
- return reply.send({
62
- success: true,
63
- fileId,
64
- size: length,
65
- type,
66
- });
67
- }
68
- logger.error('Invalid signature', { fileId, expiryDate });
69
- reply.status(403);
70
- return reply.send({
71
- success: false,
72
- message: 'Access restricted: Invalid signature.',
73
- name: 'INVALID_SIGNATURE',
74
- });
75
- }
76
- if (req.method === 'GET') {
77
- const { s: signature, e: expiryTimestamp } = req.query;
78
- const fileDocument = await modules.files.findFile({
79
- url: `${GRIDFS_PUT_SERVER_PATH}/${directoryName}/${fileName}`,
80
- });
81
- if (fileDocument?.meta?.isPrivate) {
82
- const expiry = parseInt(expiryTimestamp, 10);
83
- if (expiry <= Date.now()) {
84
- logger.error('URL Expired', { fileName, expiry });
85
- reply.status(403);
86
- return reply.send({
87
- success: false,
88
- message: 'Access restricted: URL expired.',
89
- name: 'URL_EXPIRED',
90
- });
91
- }
92
- const fileUploadAdapter = getFileAdapter();
93
- const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
94
- const expectedSignature = signedUrl ? new URL(signedUrl, 'file://').searchParams.get('s') : null;
95
- if (!signedUrl ||
96
- !expectedSignature ||
97
- !(await timingSafeStringEqual(expectedSignature, signature))) {
98
- reply.status(403);
99
- logger.error('Invalid signature', { fileName, expiry });
100
- return reply.send({
101
- success: false,
102
- message: 'Access restricted: Invalid signature.',
103
- name: 'INVALID_SIGNATURE',
104
- });
105
- }
106
- }
107
- else if (!fileDocument) {
108
- logger.error('File not found', { fileName });
109
- reply.status(404);
110
- return reply.send();
111
- }
112
- const file = await modules.gridfsFileUploads.getFileInfo(directoryName, fileDocument._id);
113
- if (file?.metadata?.['content-type']) {
114
- reply.header('content-type', file.metadata['content-type']);
115
- }
116
- if (file?.length) {
117
- reply.header('content-length', file?.length.toString());
118
- }
119
- const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileDocument._id);
120
- reply.status(200);
121
- return reply.send(readStream);
122
- }
123
- reply.status(404);
124
- return reply.send();
125
- }
126
- catch (e) {
127
- logger.error(e);
128
- if (e.code === 'ENOENT') {
129
- reply.status(404);
130
- return reply.send();
131
- }
132
- else {
133
- reply.status(504);
134
- return reply.send({ success: false, name: e.name, code: e.code, message: e.message });
135
- }
136
- }
137
- };
138
- export default gridfsHandler;
@@ -1,2 +0,0 @@
1
- declare const minioHandler: (req: any, res: any) => Promise<void>;
2
- export default minioHandler;