@unchainedshop/plugins 4.8.25 → 4.8.26

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 (251) hide show
  1. package/lib/pricing/tax/ch-tax-rates.json +1 -1
  2. package/lib/pricing/tax/eraRates.d.ts +3 -2
  3. package/lib/pricing/tax/eraRates.js +34 -8
  4. package/lib/pricing/tax/eu-tax-rates.json +33 -1
  5. package/lib/pricing/tax/eu.js +1 -1
  6. package/lib/pricing/tax/uk-tax-rates.json +1 -1
  7. package/lib/pricing/tax/us-tax-rates.json +63 -3
  8. package/lib/pricing/tax/us.js +1 -1
  9. package/package.json +1 -1
  10. package/lib/delivery/post/adapter.d.ts +0 -2
  11. package/lib/delivery/post/adapter.js +0 -22
  12. package/lib/delivery/post/index.d.ts +0 -4
  13. package/lib/delivery/post/index.js +0 -10
  14. package/lib/delivery/send-message/adapter.d.ts +0 -2
  15. package/lib/delivery/send-message/adapter.js +0 -39
  16. package/lib/delivery/send-message/index.d.ts +0 -4
  17. package/lib/delivery/send-message/index.js +0 -10
  18. package/lib/delivery/stores/adapter.d.ts +0 -2
  19. package/lib/delivery/stores/adapter.js +0 -42
  20. package/lib/delivery/stores/index.d.ts +0 -4
  21. package/lib/delivery/stores/index.js +0 -10
  22. package/lib/enrollments/licensed/adapter.d.ts +0 -6
  23. package/lib/enrollments/licensed/adapter.js +0 -51
  24. package/lib/enrollments/licensed/index.d.ts +0 -4
  25. package/lib/enrollments/licensed/index.js +0 -10
  26. package/lib/files/gridfs/api.d.ts +0 -7
  27. package/lib/files/gridfs/api.js +0 -163
  28. package/lib/files/minio/adapter.d.ts +0 -4
  29. package/lib/files/minio/adapter.js +0 -160
  30. package/lib/files/minio/api.d.ts +0 -2
  31. package/lib/files/minio/api.js +0 -40
  32. package/lib/files/temp-upload/api.d.ts +0 -8
  33. package/lib/files/temp-upload/api.js +0 -48
  34. package/lib/files/temp-upload/index.d.ts +0 -3
  35. package/lib/files/temp-upload/index.js +0 -15
  36. package/lib/filters/local-search/adapter.d.ts +0 -2
  37. package/lib/filters/local-search/adapter.js +0 -56
  38. package/lib/filters/local-search/index.d.ts +0 -4
  39. package/lib/filters/local-search/index.js +0 -10
  40. package/lib/filters/strict-equal/adapter.d.ts +0 -2
  41. package/lib/filters/strict-equal/adapter.js +0 -23
  42. package/lib/filters/strict-equal/index.d.ts +0 -4
  43. package/lib/filters/strict-equal/index.js +0 -10
  44. package/lib/payment/apple-iap/api.d.ts +0 -2
  45. package/lib/payment/apple-iap/api.js +0 -119
  46. package/lib/payment/cryptopay/adapter.d.ts +0 -2
  47. package/lib/payment/cryptopay/adapter.js +0 -157
  48. package/lib/payment/cryptopay/api.d.ts +0 -2
  49. package/lib/payment/cryptopay/api.js +0 -23
  50. package/lib/payment/datatrans-v2/adapter.d.ts +0 -2
  51. package/lib/payment/datatrans-v2/adapter.js +0 -417
  52. package/lib/payment/datatrans-v2/api.d.ts +0 -2
  53. package/lib/payment/datatrans-v2/api.js +0 -108
  54. package/lib/payment/invoice/adapter.d.ts +0 -2
  55. package/lib/payment/invoice/adapter.js +0 -26
  56. package/lib/payment/invoice/index.d.ts +0 -4
  57. package/lib/payment/invoice/index.js +0 -10
  58. package/lib/payment/invoice-prepaid/adapter.d.ts +0 -2
  59. package/lib/payment/invoice-prepaid/adapter.js +0 -29
  60. package/lib/payment/invoice-prepaid/index.d.ts +0 -4
  61. package/lib/payment/invoice-prepaid/index.js +0 -10
  62. package/lib/payment/payrexx/adapter.d.ts +0 -2
  63. package/lib/payment/payrexx/adapter.js +0 -161
  64. package/lib/payment/payrexx/api.d.ts +0 -2
  65. package/lib/payment/payrexx/api.js +0 -97
  66. package/lib/payment/postfinance-checkout/adapter.d.ts +0 -2
  67. package/lib/payment/postfinance-checkout/adapter.js +0 -189
  68. package/lib/payment/postfinance-checkout/webhook.d.ts +0 -2
  69. package/lib/payment/postfinance-checkout/webhook.js +0 -48
  70. package/lib/payment/saferpay/webhook.d.ts +0 -2
  71. package/lib/payment/saferpay/webhook.js +0 -64
  72. package/lib/payment/stripe/adapter.d.ts +0 -2
  73. package/lib/payment/stripe/adapter.js +0 -121
  74. package/lib/payment/stripe/api.d.ts +0 -6
  75. package/lib/payment/stripe/api.js +0 -165
  76. package/lib/pricing/delivery-eu-tax/adapter.d.ts +0 -3
  77. package/lib/pricing/delivery-eu-tax/adapter.js +0 -55
  78. package/lib/pricing/delivery-eu-tax/index.d.ts +0 -4
  79. package/lib/pricing/delivery-eu-tax/index.js +0 -10
  80. package/lib/pricing/delivery-swiss-tax/adapter.d.ts +0 -3
  81. package/lib/pricing/delivery-swiss-tax/adapter.js +0 -43
  82. package/lib/pricing/delivery-swiss-tax/index.d.ts +0 -4
  83. package/lib/pricing/delivery-swiss-tax/index.js +0 -10
  84. package/lib/pricing/delivery-uk-tax/adapter.d.ts +0 -3
  85. package/lib/pricing/delivery-uk-tax/adapter.js +0 -43
  86. package/lib/pricing/delivery-uk-tax/index.d.ts +0 -4
  87. package/lib/pricing/delivery-uk-tax/index.js +0 -10
  88. package/lib/pricing/delivery-us-sales-tax/adapter.d.ts +0 -3
  89. package/lib/pricing/delivery-us-sales-tax/adapter.js +0 -58
  90. package/lib/pricing/delivery-us-sales-tax/index.d.ts +0 -4
  91. package/lib/pricing/delivery-us-sales-tax/index.js +0 -10
  92. package/lib/pricing/discount-100-off/adapter.d.ts +0 -3
  93. package/lib/pricing/discount-100-off/adapter.js +0 -30
  94. package/lib/pricing/discount-100-off/index.d.ts +0 -4
  95. package/lib/pricing/discount-100-off/index.js +0 -10
  96. package/lib/pricing/discount-half-price-manual/adapter.d.ts +0 -3
  97. package/lib/pricing/discount-half-price-manual/adapter.js +0 -30
  98. package/lib/pricing/discount-half-price-manual/index.d.ts +0 -4
  99. package/lib/pricing/discount-half-price-manual/index.js +0 -10
  100. package/lib/pricing/free-delivery/adapter.d.ts +0 -3
  101. package/lib/pricing/free-delivery/adapter.js +0 -27
  102. package/lib/pricing/free-delivery/index.d.ts +0 -4
  103. package/lib/pricing/free-delivery/index.js +0 -10
  104. package/lib/pricing/free-payment/adapter.d.ts +0 -3
  105. package/lib/pricing/free-payment/adapter.js +0 -27
  106. package/lib/pricing/free-payment/index.d.ts +0 -4
  107. package/lib/pricing/free-payment/index.js +0 -10
  108. package/lib/pricing/order-delivery/adapter.d.ts +0 -3
  109. package/lib/pricing/order-delivery/adapter.js +0 -33
  110. package/lib/pricing/order-delivery/index.d.ts +0 -4
  111. package/lib/pricing/order-delivery/index.js +0 -10
  112. package/lib/pricing/order-discount/adapter.d.ts +0 -3
  113. package/lib/pricing/order-discount/adapter.js +0 -74
  114. package/lib/pricing/order-discount/index.d.ts +0 -4
  115. package/lib/pricing/order-discount/index.js +0 -10
  116. package/lib/pricing/order-items/adapter.d.ts +0 -3
  117. package/lib/pricing/order-items/adapter.js +0 -43
  118. package/lib/pricing/order-items/index.d.ts +0 -4
  119. package/lib/pricing/order-items/index.js +0 -10
  120. package/lib/pricing/order-payment/adapter.d.ts +0 -3
  121. package/lib/pricing/order-payment/adapter.js +0 -33
  122. package/lib/pricing/order-payment/index.d.ts +0 -4
  123. package/lib/pricing/order-payment/index.js +0 -10
  124. package/lib/pricing/product-catalog-price/adapter.d.ts +0 -3
  125. package/lib/pricing/product-catalog-price/adapter.js +0 -60
  126. package/lib/pricing/product-catalog-price/index.d.ts +0 -4
  127. package/lib/pricing/product-catalog-price/index.js +0 -10
  128. package/lib/pricing/product-discount/adapter.d.ts +0 -3
  129. package/lib/pricing/product-discount/adapter.js +0 -69
  130. package/lib/pricing/product-discount/index.d.ts +0 -4
  131. package/lib/pricing/product-discount/index.js +0 -10
  132. package/lib/pricing/product-eu-tax/adapter.d.ts +0 -3
  133. package/lib/pricing/product-eu-tax/adapter.js +0 -56
  134. package/lib/pricing/product-eu-tax/index.d.ts +0 -4
  135. package/lib/pricing/product-eu-tax/index.js +0 -10
  136. package/lib/pricing/product-price-rateconversion/adapter.d.ts +0 -3
  137. package/lib/pricing/product-price-rateconversion/adapter.js +0 -53
  138. package/lib/pricing/product-price-rateconversion/index.d.ts +0 -4
  139. package/lib/pricing/product-price-rateconversion/index.js +0 -10
  140. package/lib/pricing/product-quotation-price.d.ts +0 -2
  141. package/lib/pricing/product-quotation-price.js +0 -40
  142. package/lib/pricing/product-swiss-tax/adapter.d.ts +0 -3
  143. package/lib/pricing/product-swiss-tax/adapter.js +0 -57
  144. package/lib/pricing/product-swiss-tax/index.d.ts +0 -4
  145. package/lib/pricing/product-swiss-tax/index.js +0 -10
  146. package/lib/pricing/product-uk-tax/adapter.d.ts +0 -3
  147. package/lib/pricing/product-uk-tax/adapter.js +0 -57
  148. package/lib/pricing/product-uk-tax/index.d.ts +0 -4
  149. package/lib/pricing/product-uk-tax/index.js +0 -10
  150. package/lib/pricing/product-us-sales-tax/adapter.d.ts +0 -3
  151. package/lib/pricing/product-us-sales-tax/adapter.js +0 -52
  152. package/lib/pricing/product-us-sales-tax/index.d.ts +0 -4
  153. package/lib/pricing/product-us-sales-tax/index.js +0 -10
  154. package/lib/quotations/manual/adapter.d.ts +0 -2
  155. package/lib/quotations/manual/adapter.js +0 -24
  156. package/lib/quotations/manual/index.d.ts +0 -4
  157. package/lib/quotations/manual/index.js +0 -10
  158. package/lib/warehousing/erc-metadata/api.d.ts +0 -12
  159. package/lib/warehousing/erc-metadata/api.js +0 -43
  160. package/lib/warehousing/erc-metadata/index.d.ts +0 -3
  161. package/lib/warehousing/erc-metadata/index.js +0 -15
  162. package/lib/warehousing/eth-minter/adapter.d.ts +0 -2
  163. package/lib/warehousing/eth-minter/adapter.js +0 -119
  164. package/lib/warehousing/eth-minter/index.d.ts +0 -4
  165. package/lib/warehousing/eth-minter/index.js +0 -10
  166. package/lib/warehousing/store/adapter.d.ts +0 -2
  167. package/lib/warehousing/store/adapter.js +0 -33
  168. package/lib/warehousing/store/index.d.ts +0 -4
  169. package/lib/warehousing/store/index.js +0 -10
  170. package/lib/worker/budgetsms/adapter.d.ts +0 -22
  171. package/lib/worker/budgetsms/adapter.js +0 -169
  172. package/lib/worker/budgetsms/index.d.ts +0 -4
  173. package/lib/worker/budgetsms/index.js +0 -10
  174. package/lib/worker/bulk-export/adapter.d.ts +0 -3
  175. package/lib/worker/bulk-export/adapter.js +0 -64
  176. package/lib/worker/bulk-export/index.d.ts +0 -4
  177. package/lib/worker/bulk-export/index.js +0 -10
  178. package/lib/worker/bulk-import/adapter.d.ts +0 -3
  179. package/lib/worker/bulk-import/adapter.js +0 -65
  180. package/lib/worker/bulk-import/api.d.ts +0 -9
  181. package/lib/worker/bulk-import/api.js +0 -52
  182. package/lib/worker/bulk-import/index.d.ts +0 -4
  183. package/lib/worker/bulk-import/index.js +0 -18
  184. package/lib/worker/bulkgate/adapter.d.ts +0 -12
  185. package/lib/worker/bulkgate/adapter.js +0 -91
  186. package/lib/worker/bulkgate/index.d.ts +0 -4
  187. package/lib/worker/bulkgate/index.js +0 -10
  188. package/lib/worker/email/adapter.d.ts +0 -9
  189. package/lib/worker/email/adapter.js +0 -150
  190. package/lib/worker/email/index.d.ts +0 -4
  191. package/lib/worker/email/index.js +0 -10
  192. package/lib/worker/enrollment-order-generator/adapter.d.ts +0 -4
  193. package/lib/worker/enrollment-order-generator/adapter.js +0 -77
  194. package/lib/worker/enrollment-order-generator/index.d.ts +0 -4
  195. package/lib/worker/enrollment-order-generator/index.js +0 -13
  196. package/lib/worker/error-notifications/adapter.d.ts +0 -10
  197. package/lib/worker/error-notifications/adapter.js +0 -62
  198. package/lib/worker/error-notifications/index.d.ts +0 -4
  199. package/lib/worker/error-notifications/index.js +0 -13
  200. package/lib/worker/export-token/adapter.d.ts +0 -4
  201. package/lib/worker/export-token/adapter.js +0 -25
  202. package/lib/worker/export-token/index.d.ts +0 -4
  203. package/lib/worker/export-token/index.js +0 -13
  204. package/lib/worker/external/adapter.d.ts +0 -3
  205. package/lib/worker/external/adapter.js +0 -13
  206. package/lib/worker/external/index.d.ts +0 -4
  207. package/lib/worker/external/index.js +0 -10
  208. package/lib/worker/gc-guests/adapter.d.ts +0 -9
  209. package/lib/worker/gc-guests/adapter.js +0 -56
  210. package/lib/worker/gc-guests/index.d.ts +0 -4
  211. package/lib/worker/gc-guests/index.js +0 -13
  212. package/lib/worker/heartbeat/adapter.d.ts +0 -8
  213. package/lib/worker/heartbeat/adapter.js +0 -26
  214. package/lib/worker/heartbeat/index.d.ts +0 -4
  215. package/lib/worker/heartbeat/index.js +0 -10
  216. package/lib/worker/http-request/adapter.d.ts +0 -8
  217. package/lib/worker/http-request/adapter.js +0 -55
  218. package/lib/worker/http-request/index.d.ts +0 -4
  219. package/lib/worker/http-request/index.js +0 -10
  220. package/lib/worker/invalidate-carts/adapter.d.ts +0 -9
  221. package/lib/worker/invalidate-carts/adapter.js +0 -52
  222. package/lib/worker/invalidate-carts/index.d.ts +0 -4
  223. package/lib/worker/invalidate-carts/index.js +0 -13
  224. package/lib/worker/message/adapter.d.ts +0 -11
  225. package/lib/worker/message/adapter.js +0 -42
  226. package/lib/worker/message/index.d.ts +0 -4
  227. package/lib/worker/message/index.js +0 -10
  228. package/lib/worker/push-notification/adapter.d.ts +0 -9
  229. package/lib/worker/push-notification/adapter.js +0 -87
  230. package/lib/worker/push-notification/index.d.ts +0 -4
  231. package/lib/worker/push-notification/index.js +0 -10
  232. package/lib/worker/twilio/adapter.d.ts +0 -8
  233. package/lib/worker/twilio/adapter.js +0 -59
  234. package/lib/worker/twilio/index.d.ts +0 -4
  235. package/lib/worker/twilio/index.js +0 -10
  236. package/lib/worker/update-coinbase-rates/adapter.d.ts +0 -4
  237. package/lib/worker/update-coinbase-rates/adapter.js +0 -59
  238. package/lib/worker/update-coinbase-rates/index.d.ts +0 -4
  239. package/lib/worker/update-coinbase-rates/index.js +0 -13
  240. package/lib/worker/update-ecb-rates/adapter.d.ts +0 -4
  241. package/lib/worker/update-ecb-rates/adapter.js +0 -94
  242. package/lib/worker/update-ecb-rates/index.d.ts +0 -4
  243. package/lib/worker/update-ecb-rates/index.js +0 -13
  244. package/lib/worker/update-token-ownership/adapter.d.ts +0 -5
  245. package/lib/worker/update-token-ownership/adapter.js +0 -58
  246. package/lib/worker/update-token-ownership/index.d.ts +0 -4
  247. package/lib/worker/update-token-ownership/index.js +0 -13
  248. package/lib/worker/zombie-killer/adapter.d.ts +0 -15
  249. package/lib/worker/zombie-killer/adapter.js +0 -113
  250. package/lib/worker/zombie-killer/index.d.ts +0 -4
  251. package/lib/worker/zombie-killer/index.js +0 -13
@@ -1,8 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- interface Arg {
3
- wait?: number;
4
- fails?: boolean;
5
- }
6
- type Result = Arg;
7
- export declare const Heartbeat: IWorkerAdapter<Arg, Result>;
8
- export default Heartbeat;
@@ -1,26 +0,0 @@
1
- import { WorkerAdapter } from '@unchainedshop/core';
2
- import { setTimeout } from 'node:timers/promises';
3
- export const Heartbeat = {
4
- ...WorkerAdapter,
5
- key: 'shop.unchained.worker-plugin.heartbeat',
6
- label: 'Heartbeat plugin to check if workers are working',
7
- version: '1.0.0',
8
- type: 'HEARTBEAT',
9
- maxParallelAllocations: 1,
10
- doWork: async (input) => {
11
- if (input?.wait) {
12
- await setTimeout(input.wait);
13
- }
14
- if (input?.fails) {
15
- return {
16
- success: false,
17
- result: input,
18
- };
19
- }
20
- return {
21
- success: true,
22
- result: input,
23
- };
24
- },
25
- };
26
- export default Heartbeat;
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const HeartbeatPlugin: IPlugin;
3
- export default HeartbeatPlugin;
4
- export { Heartbeat } from './adapter.ts';
@@ -1,10 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { Heartbeat } from "./adapter.js";
3
- export const HeartbeatPlugin = {
4
- key: 'shop.unchained.worker-plugin.heartbeat',
5
- label: 'Heartbeat Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [Heartbeat],
8
- };
9
- export default HeartbeatPlugin;
10
- export { Heartbeat } from "./adapter.js";
@@ -1,8 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- export declare const HttpRequestWorkerPlugin: IWorkerAdapter<{
3
- url?: string;
4
- data?: any;
5
- headers?: any;
6
- method: 'POST' | 'GET';
7
- }, any>;
8
- export default HttpRequestWorkerPlugin;
@@ -1,55 +0,0 @@
1
- import { WorkerAdapter } from '@unchainedshop/core';
2
- const postFetch = async (url, { data, headers }) => {
3
- return fetch(url, {
4
- method: 'POST',
5
- body: JSON.stringify(data),
6
- duplex: 'half',
7
- headers: { 'Content-Type': 'application/json', ...headers },
8
- });
9
- };
10
- const nonPostFetch = async (url, { headers, method = 'GET' }) => {
11
- return fetch(url, {
12
- method,
13
- headers,
14
- });
15
- };
16
- export const HttpRequestWorkerPlugin = {
17
- ...WorkerAdapter,
18
- key: 'shop.unchained.worker-plugin.http-request',
19
- label: 'Request a resource via http request. 200 = success',
20
- version: '1.0.0',
21
- type: 'HTTP_REQUEST',
22
- async doWork({ url, data = {}, headers, method = 'POST' } = { method: 'POST' }) {
23
- if (!url) {
24
- return {
25
- success: false,
26
- error: {
27
- name: 'URL_REQUIRED',
28
- message: 'HTTP_REQUEST requires an url',
29
- },
30
- };
31
- }
32
- try {
33
- const normalizedFetch = method.toUpperCase() === 'POST' ? postFetch : nonPostFetch;
34
- const res = await normalizedFetch(url, { data, headers, method });
35
- const contentType = res.headers.get('content-type');
36
- const isJson = contentType && contentType.includes('application/json');
37
- const result = isJson ? await res.json() : { text: await res.text() };
38
- if (res.status === 200 && res.ok) {
39
- return { success: true, result };
40
- }
41
- return { success: false, result };
42
- }
43
- catch (err) {
44
- return {
45
- success: false,
46
- error: {
47
- name: err.name,
48
- message: err.message,
49
- stack: err.stack,
50
- },
51
- };
52
- }
53
- },
54
- };
55
- export default HttpRequestWorkerPlugin;
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const HttpRequestPlugin: IPlugin;
3
- export default HttpRequestPlugin;
4
- export { HttpRequestWorkerPlugin } from './adapter.ts';
@@ -1,10 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { HttpRequestWorkerPlugin as HttpRequestWorker } from "./adapter.js";
3
- export const HttpRequestPlugin = {
4
- key: 'shop.unchained.worker-plugin.http-request',
5
- label: 'HTTP Request Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [HttpRequestWorker],
8
- };
9
- export default HttpRequestPlugin;
10
- export { HttpRequestWorkerPlugin } from "./adapter.js";
@@ -1,9 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- export declare const InvalidateCartsWorker: IWorkerAdapter<{
3
- maxAgeDays?: number;
4
- }, {
5
- scannedCartCount: number;
6
- recalculatedCartCount: number;
7
- }>;
8
- export default InvalidateCartsWorker;
9
- export declare const configureInvalidateCartsAutoscheduling: () => void;
@@ -1,52 +0,0 @@
1
- import { WorkerAdapter, WorkerDirector, schedule } from '@unchainedshop/core';
2
- import { createLogger } from '@unchainedshop/logger';
3
- const logger = createLogger('unchained:worker:invalidate-carts');
4
- const firstOfMonthAtLocalMidnight = schedule.parse.cron('0 0 1 * *');
5
- export const InvalidateCartsWorker = {
6
- ...WorkerAdapter,
7
- key: 'shop.unchained.worker-plugin.invalidate-carts',
8
- label: 'Invalidate Carts',
9
- version: '1.0.0',
10
- type: 'INVALIDATE_CARTS',
11
- doWork: async ({ maxAgeDays } = {}, unchainedAPI) => {
12
- const { modules, services } = unchainedAPI;
13
- try {
14
- const orderIds = await modules.orders.findCartIdsToInvalidate(maxAgeDays);
15
- let recalculatedCartCount = 0;
16
- for (const orderId of orderIds) {
17
- try {
18
- await services.orders.updateCalculation(orderId);
19
- recalculatedCartCount += 1;
20
- }
21
- catch (err) {
22
- logger.warn(`Failed to recalculate cart ${orderId}: ${err.message}`);
23
- }
24
- }
25
- return {
26
- success: true,
27
- result: {
28
- scannedCartCount: orderIds.length,
29
- recalculatedCartCount,
30
- },
31
- };
32
- }
33
- catch (err) {
34
- return {
35
- success: false,
36
- error: {
37
- name: err.name,
38
- message: err.message,
39
- stack: err.stack,
40
- },
41
- };
42
- }
43
- },
44
- };
45
- export default InvalidateCartsWorker;
46
- export const configureInvalidateCartsAutoscheduling = () => {
47
- WorkerDirector.configureAutoscheduling({
48
- type: InvalidateCartsWorker.type,
49
- schedule: firstOfMonthAtLocalMidnight,
50
- retries: 0,
51
- });
52
- };
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const InvalidateCartsPlugin: IPlugin;
3
- export default InvalidateCartsPlugin;
4
- export * from './adapter.ts';
@@ -1,13 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { InvalidateCartsWorker, configureInvalidateCartsAutoscheduling } from "./adapter.js";
3
- export const InvalidateCartsPlugin = {
4
- key: 'shop.unchained.worker-plugin.invalidate-carts',
5
- label: 'Invalidate Carts Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [InvalidateCartsWorker],
8
- onRegister: () => {
9
- configureInvalidateCartsAutoscheduling();
10
- },
11
- };
12
- export default InvalidateCartsPlugin;
13
- export * from "./adapter.js";
@@ -1,11 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- import type { Work } from '@unchainedshop/core-worker';
3
- export declare const MessageWorker: IWorkerAdapter<{
4
- template: string;
5
- _id: string;
6
- [x: string]: any;
7
- }, {
8
- info?: string;
9
- forked?: Work[];
10
- }>;
11
- export default MessageWorker;
@@ -1,42 +0,0 @@
1
- import { MessagingDirector, WorkerAdapter } from '@unchainedshop/core';
2
- export const MessageWorker = {
3
- ...WorkerAdapter,
4
- key: 'shop.unchained.worker-plugin.message',
5
- label: 'Send Message by combining payload with a template and start concrete jobs',
6
- version: '1.0.0',
7
- type: 'MESSAGE',
8
- doWork: async ({ template, ...payload }, unchainedAPI, workId) => {
9
- try {
10
- const templateResolver = MessagingDirector.getTemplate(template);
11
- if (!templateResolver)
12
- throw new Error(`No template resolver found for template ${template}`);
13
- const workConfigurations = await templateResolver({
14
- template,
15
- ...payload,
16
- }, unchainedAPI);
17
- if (workConfigurations.length > 0) {
18
- const forked = await Promise.all(workConfigurations.map(async (workConfiguration) => {
19
- const work = await unchainedAPI.modules.worker.addWork({
20
- ...workConfiguration,
21
- originalWorkId: workId,
22
- });
23
- delete work.input;
24
- return work;
25
- }));
26
- return { success: true, result: { forked } };
27
- }
28
- return { success: true, result: { forked: [] } };
29
- }
30
- catch (err) {
31
- return {
32
- success: false,
33
- error: {
34
- name: err.name,
35
- message: err.message,
36
- stack: err.stack,
37
- },
38
- };
39
- }
40
- },
41
- };
42
- export default MessageWorker;
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const MessagePlugin: IPlugin;
3
- export default MessagePlugin;
4
- export * from './adapter.ts';
@@ -1,10 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { MessageWorker } from "./adapter.js";
3
- export const MessagePlugin = {
4
- key: 'shop.unchained.worker-plugin.message',
5
- label: 'Message Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [MessageWorker],
8
- };
9
- export default MessagePlugin;
10
- export * from "./adapter.js";
@@ -1,9 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- export declare const PushNotificationWorkerPlugin: IWorkerAdapter<{
3
- subscription: any;
4
- payload: string;
5
- subject: string;
6
- urgency?: 'very-low' | 'low' | 'normal' | 'high';
7
- topic?: string;
8
- }, any>;
9
- export default PushNotificationWorkerPlugin;
@@ -1,87 +0,0 @@
1
- import { WorkerAdapter } from '@unchainedshop/core';
2
- import { createLogger } from '@unchainedshop/logger';
3
- const logger = createLogger('unchained:worker:push-notification');
4
- let webPush;
5
- try {
6
- const module = await import('web-push');
7
- webPush = module.default;
8
- }
9
- catch {
10
- logger.warn(`optional peer npm package 'web-push' not installed, push notifications will not work`);
11
- }
12
- const { PUSH_NOTIFICATION_PUBLIC_KEY, PUSH_NOTIFICATION_PRIVATE_KEY } = process.env;
13
- export const PushNotificationWorkerPlugin = {
14
- ...WorkerAdapter,
15
- key: 'shop.unchained.worker-plugin.push-notification',
16
- label: 'Push Notification',
17
- version: '1.0',
18
- type: 'PUSH',
19
- doWork: async ({ subscription, subject, payload, urgency = null, topic = null }) => {
20
- if (!webPush) {
21
- return {
22
- success: false,
23
- error: {
24
- name: 'WEB_PUSH_NOT_INSTALLED',
25
- message: 'npm dependency web-push is not installed, please install it to use this worker',
26
- },
27
- };
28
- }
29
- if (!PUSH_NOTIFICATION_PUBLIC_KEY)
30
- return {
31
- success: false,
32
- error: {
33
- name: 'VAPID_PUBLIC_KEY_REQUIRED',
34
- message: 'vapidPublicKey key required to send push notifications',
35
- },
36
- };
37
- if (!PUSH_NOTIFICATION_PRIVATE_KEY)
38
- return {
39
- success: false,
40
- error: {
41
- name: 'VAPID_PRIVATE_KEY_REQUIRED',
42
- message: 'vapidPrivateKey key are required to send push notifications',
43
- },
44
- };
45
- if (!subscription) {
46
- return {
47
- success: false,
48
- error: {
49
- name: 'USER_SUBSCRIPTION_OBJECT_REQUIRED',
50
- message: 'PUSH service subscription required',
51
- },
52
- };
53
- }
54
- const options = {
55
- vapidDetails: {
56
- subject,
57
- publicKey: PUSH_NOTIFICATION_PUBLIC_KEY,
58
- privateKey: PUSH_NOTIFICATION_PRIVATE_KEY,
59
- },
60
- TTL: 60,
61
- };
62
- if (urgency) {
63
- options.urgency = urgency;
64
- }
65
- if (topic) {
66
- options.topic = topic;
67
- }
68
- try {
69
- await webPush.sendNotification(subscription, payload, options);
70
- return {
71
- success: true,
72
- error: null,
73
- };
74
- }
75
- catch (err) {
76
- return {
77
- success: false,
78
- error: {
79
- name: err.name,
80
- message: err.message,
81
- stack: err.stack,
82
- },
83
- };
84
- }
85
- },
86
- };
87
- export default PushNotificationWorkerPlugin;
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const PushNotificationPlugin: IPlugin;
3
- export default PushNotificationPlugin;
4
- export { PushNotificationWorkerPlugin } from './adapter.ts';
@@ -1,10 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { PushNotificationWorkerPlugin as PushNotificationWorker } from "./adapter.js";
3
- export const PushNotificationPlugin = {
4
- key: 'shop.unchained.worker-plugin.push-notification',
5
- label: 'Push Notification Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [PushNotificationWorker],
8
- };
9
- export default PushNotificationPlugin;
10
- export { PushNotificationWorkerPlugin } from "./adapter.js";
@@ -1,8 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- export declare const SmsWorkerPlugin: IWorkerAdapter<{
3
- from?: string;
4
- to: string;
5
- text: string;
6
- [key: string]: any;
7
- }, any>;
8
- export default SmsWorkerPlugin;
@@ -1,59 +0,0 @@
1
- import { WorkerAdapter } from '@unchainedshop/core';
2
- const { TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_SMS_FROM } = process.env;
3
- export const SmsWorkerPlugin = {
4
- ...WorkerAdapter,
5
- key: 'shop.unchained.worker-plugin.twilio',
6
- label: 'Send Messages through Twilio',
7
- version: '1.0.0',
8
- type: 'TWILIO',
9
- doWork: async ({ from, to, text, ...params }) => {
10
- try {
11
- if (!TWILIO_SMS_FROM && !from)
12
- throw new Error('Missing Twilio "from" number. Set TWILIO_SMS_FROM env var or provide "from" in input');
13
- if (!to)
14
- throw new Error('Missing "to" in input');
15
- const url = `https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Messages.json`;
16
- const response = await fetch(url, {
17
- method: 'POST',
18
- headers: {
19
- Authorization: `Basic ${Buffer.from(`${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}`).toString('base64')}`,
20
- 'Content-Type': 'application/x-www-form-urlencoded',
21
- },
22
- body: new URLSearchParams({
23
- Body: text || '',
24
- From: from || TWILIO_SMS_FROM,
25
- To: to,
26
- ...params,
27
- }),
28
- });
29
- const data = (await response.json());
30
- if (!response.ok) {
31
- return {
32
- success: false,
33
- error: {
34
- name: 'TWILIO_ERROR',
35
- message: data.message || 'Failed to send SMS',
36
- },
37
- };
38
- }
39
- return {
40
- success: true,
41
- result: {
42
- sid: data.sid,
43
- },
44
- error: null,
45
- };
46
- }
47
- catch (err) {
48
- return {
49
- success: false,
50
- error: {
51
- name: err.name,
52
- message: err.message,
53
- stack: err.stack,
54
- },
55
- };
56
- }
57
- },
58
- };
59
- export default SmsWorkerPlugin;
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const TwilioPlugin: IPlugin;
3
- export default TwilioPlugin;
4
- export { SmsWorkerPlugin } from './adapter.ts';
@@ -1,10 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { SmsWorkerPlugin as TwilioWorker } from "./adapter.js";
3
- export const TwilioPlugin = {
4
- key: 'shop.unchained.worker-plugin.twilio',
5
- label: 'Twilio SMS Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [TwilioWorker],
8
- };
9
- export default TwilioPlugin;
10
- export { SmsWorkerPlugin } from "./adapter.js";
@@ -1,4 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- export declare const UpdateCoinbaseRates: IWorkerAdapter<any, any>;
3
- export default UpdateCoinbaseRates;
4
- export declare const configureUpdateCoinbaseRatesAutoscheduling: () => void;
@@ -1,59 +0,0 @@
1
- import { WorkerAdapter, WorkerDirector, schedule } from '@unchainedshop/core';
2
- import { resolveBestCurrency } from '@unchainedshop/utils';
3
- const getExchangeRates = async (base) => {
4
- const res = await fetch(`https://api.coinbase.com/v2/exchange-rates?currency=${base}`);
5
- const { data } = (await res.json());
6
- return data;
7
- };
8
- const everyMinute = schedule.parse.cron('* * * * *');
9
- export const UpdateCoinbaseRates = {
10
- ...WorkerAdapter,
11
- key: 'shop.unchained.worker.update-coinbase-rates',
12
- label: 'Update Coinbase Rates',
13
- version: '1.0.0',
14
- type: 'UPDATE_COINBASE_RATES',
15
- doWork: async (input, unchainedAPI) => {
16
- try {
17
- const currencies = await unchainedAPI.modules.currencies.findCurrencies({ includeInactive: true });
18
- const currencyCode = resolveBestCurrency(null, currencies);
19
- const currencyCodes = currencies.map((currency) => currency.isoCode);
20
- const { currency: baseCurrency, rates: pairs } = await getExchangeRates(currencyCode);
21
- const timestamp = new Date();
22
- const expiresAt = new Date(new Date().getTime() + 5 * 60 * 1000);
23
- const rates = Object.entries(pairs)
24
- .map(([quoteCurrency, rate]) => {
25
- return {
26
- baseCurrency,
27
- quoteCurrency,
28
- rate: parseFloat(rate),
29
- timestamp,
30
- expiresAt,
31
- };
32
- })
33
- .filter((rate) => currencyCodes.includes(rate.quoteCurrency) && rate.quoteCurrency !== rate.baseCurrency);
34
- const success = await unchainedAPI.modules.products.prices.rates.updateRates(rates);
35
- return {
36
- success,
37
- result: {
38
- ratesUpdated: rates.length,
39
- },
40
- };
41
- }
42
- catch {
43
- return {
44
- success: false,
45
- error: {
46
- name: 'UPDATE_COINBASE_RATES_FAILED',
47
- message: 'Updating Coinbase Rates failed',
48
- },
49
- };
50
- }
51
- },
52
- };
53
- export default UpdateCoinbaseRates;
54
- export const configureUpdateCoinbaseRatesAutoscheduling = () => {
55
- WorkerDirector.configureAutoscheduling({
56
- type: UpdateCoinbaseRates.type,
57
- schedule: everyMinute,
58
- });
59
- };
@@ -1,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const UpdateCoinbaseRatesPlugin: IPlugin;
3
- export default UpdateCoinbaseRatesPlugin;
4
- export { UpdateCoinbaseRates, configureUpdateCoinbaseRatesAutoscheduling } from './adapter.ts';
@@ -1,13 +0,0 @@
1
- import {} from '@unchainedshop/core';
2
- import { UpdateCoinbaseRates, configureUpdateCoinbaseRatesAutoscheduling } from "./adapter.js";
3
- export const UpdateCoinbaseRatesPlugin = {
4
- key: 'shop.unchained.worker.update-coinbase-rates',
5
- label: 'Update Coinbase Rates Worker Plugin',
6
- version: '1.0.0',
7
- adapters: [UpdateCoinbaseRates],
8
- onRegister: () => {
9
- configureUpdateCoinbaseRatesAutoscheduling();
10
- },
11
- };
12
- export default UpdateCoinbaseRatesPlugin;
13
- export { UpdateCoinbaseRates, configureUpdateCoinbaseRatesAutoscheduling } from "./adapter.js";
@@ -1,4 +0,0 @@
1
- import { type IWorkerAdapter } from '@unchainedshop/core';
2
- export declare const UpdateECBRates: IWorkerAdapter<any, any>;
3
- export default UpdateECBRates;
4
- export declare const configureUpdateECBRatesAutoscheduling: () => void;