@unchainedshop/plugins 4.7.2 → 4.8.0

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 +2 -0
  2. package/lib/delivery/post.d.ts +1 -0
  3. package/lib/delivery/post.js +23 -0
  4. package/lib/delivery/send-message.d.ts +1 -0
  5. package/lib/delivery/send-message.js +40 -0
  6. package/lib/delivery/stores.d.ts +1 -0
  7. package/lib/delivery/stores.js +43 -0
  8. package/lib/enrollments/licensed.d.ts +4 -0
  9. package/lib/enrollments/licensed.js +52 -0
  10. package/lib/events/node-event-emitter.d.ts +1 -3
  11. package/lib/events/node-event-emitter.js +3 -3
  12. package/lib/files/gridfs/adapter.d.ts +2 -2
  13. package/lib/files/gridfs/adapter.js +5 -2
  14. package/lib/files/gridfs/handler-express.d.ts +9 -0
  15. package/lib/files/gridfs/handler-express.js +110 -0
  16. package/lib/files/gridfs/handler-fastify.d.ts +3 -0
  17. package/lib/files/gridfs/handler-fastify.js +138 -0
  18. package/lib/files/gridfs/index.d.ts +4 -5
  19. package/lib/files/gridfs/index.js +3 -30
  20. package/lib/files/minio/handler-express.d.ts +2 -0
  21. package/lib/files/minio/handler-express.js +36 -0
  22. package/lib/files/minio/handler-fastify.d.ts +3 -0
  23. package/lib/files/minio/handler-fastify.js +40 -0
  24. package/lib/files/minio/index.d.ts +5 -4
  25. package/lib/files/minio/index.js +157 -18
  26. package/lib/filters/local-search.d.ts +3 -0
  27. package/lib/filters/local-search.js +66 -0
  28. package/lib/filters/strict-equal.d.ts +1 -0
  29. package/lib/filters/strict-equal.js +24 -0
  30. package/lib/payment/apple-iap/adapter.d.ts +1 -2
  31. package/lib/payment/apple-iap/adapter.js +3 -2
  32. package/lib/payment/apple-iap/handler-express.d.ts +2 -0
  33. package/lib/payment/apple-iap/handler-express.js +103 -0
  34. package/lib/payment/apple-iap/handler-fastify.d.ts +3 -0
  35. package/lib/payment/apple-iap/handler-fastify.js +102 -0
  36. package/lib/payment/apple-iap/index.d.ts +4 -6
  37. package/lib/payment/apple-iap/index.js +3 -28
  38. package/lib/payment/braintree.d.ts +1 -0
  39. package/lib/payment/braintree.js +138 -0
  40. package/lib/payment/cryptopay/handler-express.d.ts +2 -0
  41. package/lib/payment/cryptopay/handler-express.js +19 -0
  42. package/lib/payment/cryptopay/handler-fastify.d.ts +3 -0
  43. package/lib/payment/cryptopay/handler-fastify.js +17 -0
  44. package/lib/payment/cryptopay/index.d.ts +4 -5
  45. package/lib/payment/cryptopay/index.js +3 -31
  46. package/lib/payment/cryptopay/plugin.d.ts +3 -0
  47. package/lib/payment/cryptopay/plugin.js +159 -0
  48. package/lib/payment/datatrans-v2/handler-express.d.ts +1 -0
  49. package/lib/payment/datatrans-v2/handler-express.js +71 -0
  50. package/lib/payment/datatrans-v2/handler-fastify.d.ts +2 -0
  51. package/lib/payment/datatrans-v2/handler-fastify.js +71 -0
  52. package/lib/payment/datatrans-v2/index.d.ts +1 -4
  53. package/lib/payment/datatrans-v2/index.js +400 -17
  54. package/lib/payment/invoice-prepaid.d.ts +1 -0
  55. package/lib/payment/invoice-prepaid.js +30 -0
  56. package/lib/payment/invoice.d.ts +1 -0
  57. package/lib/payment/invoice.js +27 -0
  58. package/lib/payment/paypal-checkout.d.ts +1 -0
  59. package/lib/payment/paypal-checkout.js +87 -0
  60. package/lib/payment/payrexx/handler-express.d.ts +1 -0
  61. package/lib/payment/payrexx/handler-express.js +85 -0
  62. package/lib/payment/payrexx/handler-fastify.d.ts +2 -0
  63. package/lib/payment/payrexx/handler-fastify.js +91 -0
  64. package/lib/payment/payrexx/index.d.ts +1 -4
  65. package/lib/payment/payrexx/index.js +158 -19
  66. package/lib/payment/postfinance-checkout/handler-express.d.ts +1 -0
  67. package/lib/payment/postfinance-checkout/handler-express.js +37 -0
  68. package/lib/payment/postfinance-checkout/handler-fastify.d.ts +2 -0
  69. package/lib/payment/postfinance-checkout/handler-fastify.js +40 -0
  70. package/lib/payment/postfinance-checkout/index.d.ts +0 -5
  71. package/lib/payment/postfinance-checkout/index.js +186 -25
  72. package/lib/payment/saferpay/adapter.js +2 -1
  73. package/lib/payment/saferpay/handler-express.d.ts +1 -0
  74. package/lib/payment/saferpay/handler-express.js +59 -0
  75. package/lib/payment/saferpay/handler-fastify.d.ts +2 -0
  76. package/lib/payment/saferpay/handler-fastify.js +62 -0
  77. package/lib/payment/saferpay/index.d.ts +4 -5
  78. package/lib/payment/saferpay/index.js +3 -29
  79. package/lib/payment/stripe/handler-express.d.ts +5 -0
  80. package/lib/payment/stripe/handler-express.js +121 -0
  81. package/lib/payment/stripe/handler-fastify.d.ts +6 -0
  82. package/lib/payment/stripe/handler-fastify.js +131 -0
  83. package/lib/payment/stripe/index.d.ts +1 -4
  84. package/lib/payment/stripe/index.js +116 -22
  85. package/lib/payment/stripe/stripe.js +4 -1
  86. package/lib/presets/all-express.d.ts +6 -0
  87. package/lib/presets/all-express.js +26 -0
  88. package/lib/presets/all-fastify.d.ts +6 -0
  89. package/lib/presets/all-fastify.js +49 -0
  90. package/lib/presets/all.d.ts +70 -1
  91. package/lib/presets/all.js +27 -41
  92. package/lib/presets/base-express.d.ts +2 -0
  93. package/lib/presets/base-express.js +5 -0
  94. package/lib/presets/base-fastify.d.ts +3 -0
  95. package/lib/presets/base-fastify.js +16 -0
  96. package/lib/presets/base.d.ts +25 -1
  97. package/lib/presets/base.js +25 -56
  98. package/lib/presets/countries/ch.d.ts +2 -1
  99. package/lib/presets/countries/ch.js +2 -7
  100. package/lib/presets/crypto-express.d.ts +3 -0
  101. package/lib/presets/crypto-express.js +8 -0
  102. package/lib/presets/crypto-fastify.d.ts +3 -0
  103. package/lib/presets/crypto-fastify.js +11 -0
  104. package/lib/presets/crypto.d.ts +7 -3
  105. package/lib/presets/crypto.js +7 -18
  106. package/lib/pricing/delivery-swiss-tax.d.ts +2 -0
  107. package/lib/pricing/delivery-swiss-tax.js +62 -0
  108. package/lib/pricing/discount-100-off.d.ts +2 -0
  109. package/lib/pricing/discount-100-off.js +30 -0
  110. package/lib/pricing/discount-half-price-manual.d.ts +2 -0
  111. package/lib/pricing/discount-half-price-manual.js +30 -0
  112. package/lib/pricing/discount-half-price.d.ts +2 -0
  113. package/lib/pricing/discount-half-price.js +33 -0
  114. package/lib/pricing/free-delivery.d.ts +2 -0
  115. package/lib/pricing/free-delivery.js +27 -0
  116. package/lib/pricing/free-payment.d.ts +2 -0
  117. package/lib/pricing/free-payment.js +27 -0
  118. package/lib/pricing/order-delivery.d.ts +2 -0
  119. package/lib/pricing/order-delivery.js +33 -0
  120. package/lib/pricing/order-discount.d.ts +2 -0
  121. package/lib/pricing/order-discount.js +74 -0
  122. package/lib/pricing/order-items-discount.d.ts +2 -0
  123. package/lib/pricing/order-items-discount.js +50 -0
  124. package/lib/pricing/order-items.d.ts +2 -0
  125. package/lib/pricing/order-items.js +43 -0
  126. package/lib/pricing/order-payment.d.ts +2 -0
  127. package/lib/pricing/order-payment.js +33 -0
  128. package/lib/pricing/order-round.d.ts +10 -0
  129. package/lib/pricing/order-round.js +135 -0
  130. package/lib/pricing/product-catalog-price-options.d.ts +2 -0
  131. package/lib/pricing/product-catalog-price-options.js +51 -0
  132. package/lib/pricing/product-catalog-price.d.ts +2 -0
  133. package/lib/pricing/product-catalog-price.js +60 -0
  134. package/lib/pricing/product-discount.d.ts +2 -0
  135. package/lib/pricing/product-discount.js +69 -0
  136. package/lib/pricing/product-price-rateconversion.d.ts +2 -0
  137. package/lib/pricing/product-price-rateconversion.js +53 -0
  138. package/lib/pricing/product-round.d.ts +10 -0
  139. package/lib/pricing/product-round.js +44 -0
  140. package/lib/pricing/product-swiss-tax.d.ts +2 -0
  141. package/lib/pricing/product-swiss-tax.js +76 -0
  142. package/lib/quotations/manual.d.ts +1 -0
  143. package/lib/quotations/manual.js +20 -0
  144. package/lib/warehousing/eth-minter.d.ts +1 -0
  145. package/lib/warehousing/eth-minter.js +120 -0
  146. package/lib/warehousing/store.d.ts +1 -0
  147. package/lib/warehousing/store.js +34 -0
  148. package/lib/worker/budgetsms.d.ts +9 -0
  149. package/lib/worker/budgetsms.js +169 -0
  150. package/lib/worker/bulk-export.d.ts +2 -0
  151. package/lib/worker/bulk-export.js +64 -0
  152. package/lib/worker/bulk-import.d.ts +2 -0
  153. package/lib/worker/bulk-import.js +65 -0
  154. package/lib/worker/bulkgate.d.ts +1 -0
  155. package/lib/worker/bulkgate.js +91 -0
  156. package/lib/worker/email.d.ts +1 -0
  157. package/lib/worker/email.js +136 -0
  158. package/lib/worker/enrollment-order-generator.d.ts +1 -0
  159. package/lib/worker/enrollment-order-generator.js +77 -0
  160. package/lib/worker/error-notifications.d.ts +9 -0
  161. package/lib/worker/error-notifications.js +61 -0
  162. package/lib/worker/export-token.d.ts +4 -0
  163. package/lib/worker/export-token.js +26 -0
  164. package/lib/worker/external.d.ts +2 -0
  165. package/lib/worker/external.js +13 -0
  166. package/lib/worker/heartbeat.d.ts +1 -0
  167. package/lib/worker/heartbeat.js +26 -0
  168. package/lib/worker/http-request.d.ts +8 -0
  169. package/lib/worker/http-request.js +56 -0
  170. package/lib/worker/message.d.ts +10 -0
  171. package/lib/worker/message.js +42 -0
  172. package/lib/worker/push-notification.d.ts +1 -0
  173. package/lib/worker/push-notification.js +87 -0
  174. package/lib/worker/twilio.d.ts +1 -0
  175. package/lib/worker/twilio.js +59 -0
  176. package/lib/worker/update-coinbase-rates.d.ts +1 -0
  177. package/lib/worker/update-coinbase-rates.js +59 -0
  178. package/lib/worker/update-ecb-rates.d.ts +1 -0
  179. package/lib/worker/update-ecb-rates.js +92 -0
  180. package/lib/worker/update-token-ownership.d.ts +3 -0
  181. package/lib/worker/update-token-ownership.js +57 -0
  182. package/lib/worker/zombie-killer.d.ts +13 -0
  183. package/lib/worker/zombie-killer.js +91 -0
  184. package/package.json +10 -15
@@ -0,0 +1,49 @@
1
+ import connectCryptoToFastify from "./crypto-fastify.js";
2
+ import connectBaseToFastify from "./base-fastify.js";
3
+ import { stripeHandler } from "../payment/stripe/handler-fastify.js";
4
+ import { postfinanceCheckoutHandler } from "../payment/postfinance-checkout/handler-fastify.js";
5
+ import { datatransHandler } from "../payment/datatrans-v2/handler-fastify.js";
6
+ import { appleIAPHandler } from "../payment/apple-iap/handler-fastify.js";
7
+ import { payrexxHandler } from "../payment/payrexx/handler-fastify.js";
8
+ import { saferpayHandler } from "../payment/saferpay/handler-fastify.js";
9
+ import { configureGenerateOrderAutoscheduling } from "../worker/enrollment-order-generator.js";
10
+ const { STRIPE_WEBHOOK_PATH = '/payment/stripe', PAYREXX_WEBHOOK_PATH = '/payment/payrexx', PFCHECKOUT_WEBHOOK_PATH = '/payment/postfinance-checkout', DATATRANS_WEBHOOK_PATH = '/payment/datatrans/webhook', APPLE_IAP_WEBHOOK_PATH = '/payment/apple-iap', SAFERPAY_WEBHOOK_PATH = '/payment/saferpay/webhook', } = process.env;
11
+ export default (fastify, { unchainedAPI }) => {
12
+ connectBaseToFastify(fastify);
13
+ connectCryptoToFastify(fastify, unchainedAPI);
14
+ fastify.register((s, opts, registered) => {
15
+ s.addContentTypeParser('application/json', { parseAs: 'string', bodyLimit: 1024 * 1024 }, s.defaultTextParser);
16
+ s.route({
17
+ url: STRIPE_WEBHOOK_PATH,
18
+ method: 'POST',
19
+ handler: stripeHandler,
20
+ });
21
+ s.route({
22
+ url: DATATRANS_WEBHOOK_PATH,
23
+ method: 'POST',
24
+ handler: datatransHandler,
25
+ });
26
+ registered();
27
+ });
28
+ fastify.route({
29
+ url: PFCHECKOUT_WEBHOOK_PATH,
30
+ method: 'POST',
31
+ handler: postfinanceCheckoutHandler,
32
+ });
33
+ fastify.route({
34
+ url: APPLE_IAP_WEBHOOK_PATH,
35
+ method: 'POST',
36
+ handler: appleIAPHandler,
37
+ });
38
+ fastify.route({
39
+ url: PAYREXX_WEBHOOK_PATH,
40
+ method: 'POST',
41
+ handler: payrexxHandler,
42
+ });
43
+ fastify.route({
44
+ url: SAFERPAY_WEBHOOK_PATH,
45
+ method: 'GET',
46
+ handler: saferpayHandler,
47
+ });
48
+ configureGenerateOrderAutoscheduling();
49
+ };
@@ -1 +1,70 @@
1
- export declare function registerAllPlugins(): void;
1
+ import './countries/ch.ts';
2
+ import '../delivery/send-message.ts';
3
+ import '../delivery/stores.ts';
4
+ import '../payment/invoice-prepaid.ts';
5
+ import '../payment/paypal-checkout.ts';
6
+ import '../payment/stripe/index.ts';
7
+ import '../payment/postfinance-checkout/index.ts';
8
+ import '../payment/datatrans-v2/index.ts';
9
+ import '../payment/payrexx/index.ts';
10
+ import '../filters/strict-equal.ts';
11
+ import '../filters/local-search.ts';
12
+ import '../worker/twilio.ts';
13
+ import '../worker/bulkgate.ts';
14
+ import '../worker/budgetsms.ts';
15
+ import '../worker/push-notification.ts';
16
+ import '../worker/enrollment-order-generator.ts';
17
+ declare const modules: {
18
+ saferpayTransactions: {
19
+ configure: ({ db }: {
20
+ db: import("mongodb").Db;
21
+ }) => Promise<{
22
+ findTransactionById: (_id: import("bson").ObjectId) => Promise<import("mongodb").WithId<import("../payment/saferpay/db/SaferpayTransactionsCollection.ts").SaferpayTransaction> | null>;
23
+ createTransaction: (orderPaymentId: any) => Promise<import("bson").ObjectId>;
24
+ setToken: (_id: import("bson").ObjectId, token: string) => Promise<void>;
25
+ }>;
26
+ };
27
+ appleTransactions: {
28
+ configure: ({ db }: {
29
+ db: any;
30
+ }) => Promise<{
31
+ findTransactionById: (transactionIdentifier: string) => Promise<import("../payment/apple-iap/db/AppleTransactionsCollection.ts").AppleTransaction | null>;
32
+ createTransaction: (doc: Omit<import("../payment/apple-iap/db/AppleTransactionsCollection.ts").AppleTransaction, "_id" | "created"> & Pick<Partial<import("../payment/apple-iap/db/AppleTransactionsCollection.ts").AppleTransaction>, "_id" | "created">) => Promise<string>;
33
+ }>;
34
+ };
35
+ cryptopay: {
36
+ configure: ({ db }: {
37
+ db: any;
38
+ }) => {
39
+ getWalletAddress: (address: string, contract?: string) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction | null>;
40
+ updateMostRecentBlock: (currencyCode: string, blockHeight: number) => Promise<void>;
41
+ updateWalletAddress: ({ address, blockHeight, amount, contract, currencyCode, decimals, }: {
42
+ address: string;
43
+ blockHeight: number;
44
+ amount: string | number;
45
+ contract?: string;
46
+ currencyCode: string;
47
+ decimals: number;
48
+ }) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction>;
49
+ mapOrderPaymentToWalletAddress: ({ address, contract, currencyCode, orderPaymentId, }: {
50
+ address: string;
51
+ contract?: string;
52
+ currencyCode: string;
53
+ orderPaymentId: string;
54
+ }) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction>;
55
+ getNextDerivationNumber: (currencyCode: string) => Promise<number>;
56
+ getWalletAddressesByOrderPaymentId: (orderPaymentId: string) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction[]>;
57
+ };
58
+ };
59
+ gridfsFileUploads: {
60
+ configure: ({ db }: {
61
+ db: any;
62
+ }) => {
63
+ createWriteStream: (directoryName: any, fileId: any, fileName: any, uploadOptions: import("mongodb").GridFSBucketWriteStream["options"]) => Promise<import("mongodb").GridFSBucketWriteStream>;
64
+ getFileInfo: (directoryName: any, fileId: any) => Promise<import("mongodb").GridFSFile | null>;
65
+ createReadStream: (directoryName: any, fileId: any) => Promise<import("mongodb").GridFSBucketReadStream>;
66
+ removeFileFromBucket: (directoryName: any, fileId: any) => Promise<void>;
67
+ };
68
+ };
69
+ };
70
+ export default modules;
@@ -1,41 +1,27 @@
1
- import { registerBasePlugins } from "./base.js";
2
- import { registerCryptoPlugins } from "./crypto.js";
3
- import { registerSwissTaxPlugins } from "./countries/ch.js";
4
- import { pluginRegistry } from '@unchainedshop/core';
5
- import { DatatransPlugin } from "../payment/datatrans-v2/index.js";
6
- import { StripePlugin } from "../payment/stripe/index.js";
7
- import { InvoicePrepaidPlugin } from "../payment/invoice-prepaid/index.js";
8
- import { SendMessagePlugin } from "../delivery/send-message/index.js";
9
- import { PickMupPlugin } from "../delivery/stores/index.js";
10
- import { AppleIAPPlugin } from "../payment/apple-iap/index.js";
11
- import { PayrexxPlugin } from "../payment/payrexx/index.js";
12
- import { PostfinanceCheckoutPlugin } from "../payment/postfinance-checkout/index.js";
13
- import { SaferpayPlugin } from "../payment/saferpay/index.js";
14
- import { StrictQualFilterPlugin } from "../filters/strict-equal/index.js";
15
- import { LocalSearchPlugin } from "../filters/local-search/index.js";
16
- import { TwilioPlugin } from "../worker/twilio/index.js";
17
- import { BulkGatePlugin } from "../worker/bulkgate/index.js";
18
- import { BudgetSMSPlugin } from "../worker/budgetsms/index.js";
19
- import { PushNotificationPlugin } from "../worker/push-notification/index.js";
20
- import { EnrollmentOrderGeneratorPlugin } from "../worker/enrollment-order-generator/index.js";
21
- export function registerAllPlugins() {
22
- registerBasePlugins();
23
- registerCryptoPlugins();
24
- registerSwissTaxPlugins();
25
- pluginRegistry.register(DatatransPlugin);
26
- pluginRegistry.register(StripePlugin);
27
- pluginRegistry.register(AppleIAPPlugin);
28
- pluginRegistry.register(PayrexxPlugin);
29
- pluginRegistry.register(PostfinanceCheckoutPlugin);
30
- pluginRegistry.register(SaferpayPlugin);
31
- pluginRegistry.register(InvoicePrepaidPlugin);
32
- pluginRegistry.register(SendMessagePlugin);
33
- pluginRegistry.register(PickMupPlugin);
34
- pluginRegistry.register(StrictQualFilterPlugin);
35
- pluginRegistry.register(LocalSearchPlugin);
36
- pluginRegistry.register(TwilioPlugin);
37
- pluginRegistry.register(BulkGatePlugin);
38
- pluginRegistry.register(BudgetSMSPlugin);
39
- pluginRegistry.register(PushNotificationPlugin);
40
- pluginRegistry.register(EnrollmentOrderGeneratorPlugin);
41
- }
1
+ import baseModules from "./base.js";
2
+ import "./countries/ch.js";
3
+ import cryptoModules from "./crypto.js";
4
+ import "../delivery/send-message.js";
5
+ import "../delivery/stores.js";
6
+ import "../payment/invoice-prepaid.js";
7
+ import "../payment/paypal-checkout.js";
8
+ import appleTransactionsModules from "../payment/apple-iap/index.js";
9
+ import saferpayTransactionsModules from "../payment/saferpay/index.js";
10
+ import "../payment/stripe/index.js";
11
+ import "../payment/postfinance-checkout/index.js";
12
+ import "../payment/datatrans-v2/index.js";
13
+ import "../payment/payrexx/index.js";
14
+ import "../filters/strict-equal.js";
15
+ import "../filters/local-search.js";
16
+ import "../worker/twilio.js";
17
+ import "../worker/bulkgate.js";
18
+ import "../worker/budgetsms.js";
19
+ import "../worker/push-notification.js";
20
+ import "../worker/enrollment-order-generator.js";
21
+ const modules = {
22
+ ...baseModules,
23
+ ...cryptoModules,
24
+ ...appleTransactionsModules,
25
+ ...saferpayTransactionsModules,
26
+ };
27
+ export default modules;
@@ -0,0 +1,2 @@
1
+ declare const _default: (app: any) => void;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import handler from "../files/gridfs/handler-express.js";
2
+ const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
3
+ export default (app) => {
4
+ app.use(GRIDFS_PUT_SERVER_PATH, handler);
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ declare const _default: (fastify: FastifyInstance) => void;
3
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import handler from "../files/gridfs/handler-fastify.js";
2
+ const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
3
+ export default (fastify) => {
4
+ fastify.register((s, opts, registered) => {
5
+ s.removeAllContentTypeParsers();
6
+ s.addContentTypeParser('*', function (req, payload, done) {
7
+ done(null);
8
+ });
9
+ s.route({
10
+ url: GRIDFS_PUT_SERVER_PATH + '/:directoryName/:fileName',
11
+ method: ['GET', 'PUT', 'OPTIONS'],
12
+ handler,
13
+ });
14
+ registered();
15
+ });
16
+ };
@@ -1 +1,25 @@
1
- export declare function registerBasePlugins(): void;
1
+ import '../delivery/post.ts';
2
+ import '../payment/invoice.ts';
3
+ import '../warehousing/store.ts';
4
+ import '../pricing/free-payment.ts';
5
+ import '../pricing/free-delivery.ts';
6
+ import '../pricing/order-items.ts';
7
+ import '../pricing/order-discount.ts';
8
+ import '../pricing/order-delivery.ts';
9
+ import '../pricing/order-payment.ts';
10
+ import '../pricing/product-catalog-price.ts';
11
+ import '../pricing/product-discount.ts';
12
+ import '../quotations/manual.ts';
13
+ import '../enrollments/licensed.ts';
14
+ import '../events/node-event-emitter.ts';
15
+ import '../worker/bulk-import.ts';
16
+ import '../worker/zombie-killer.ts';
17
+ import '../worker/message.ts';
18
+ import '../worker/external.ts';
19
+ import '../worker/http-request.ts';
20
+ import '../worker/heartbeat.ts';
21
+ import '../worker/email.ts';
22
+ import '../worker/error-notifications.ts';
23
+ import '../worker/bulk-export.ts';
24
+ import gridfsModules from '../files/gridfs/index.ts';
25
+ export default gridfsModules;
@@ -1,56 +1,25 @@
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
+ 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 +1,2 @@
1
- export declare function registerSwissTaxPlugins(): void;
1
+ import '../../pricing/product-swiss-tax.ts';
2
+ import '../../pricing/delivery-swiss-tax.ts';
@@ -1,7 +1,2 @@
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
+ import "../../pricing/product-swiss-tax.js";
2
+ import "../../pricing/delivery-swiss-tax.js";
@@ -0,0 +1,3 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ declare const _default: (app: any, unchainedAPI: UnchainedCore) => void;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import express from 'express';
2
+ import handler from "../payment/cryptopay/handler-express.js";
3
+ import { configureExportToken } from "../worker/export-token.js";
4
+ const { CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay' } = process.env;
5
+ export default (app, unchainedAPI) => {
6
+ app.use(CRYPTOPAY_WEBHOOK_PATH, express.json(), handler);
7
+ configureExportToken(unchainedAPI);
8
+ };
@@ -0,0 +1,3 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ declare const _default: (fastify: any, unchainedAPI: UnchainedCore) => void;
3
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import handler from "../payment/cryptopay/handler-fastify.js";
2
+ import { configureExportToken } from "../worker/export-token.js";
3
+ const { CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay' } = process.env;
4
+ export default (fastify, unchainedAPI) => {
5
+ fastify.route({
6
+ url: CRYPTOPAY_WEBHOOK_PATH,
7
+ method: 'POST',
8
+ handler,
9
+ });
10
+ configureExportToken(unchainedAPI);
11
+ };
@@ -1,3 +1,7 @@
1
- declare const _default: {};
2
- export default _default;
3
- export declare function registerCryptoPlugins(): void;
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,18 +1,7 @@
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
- }
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;
@@ -0,0 +1,2 @@
1
+ import { type IDeliveryPricingAdapter } from '@unchainedshop/core';
2
+ export declare const DeliverySwissTax: IDeliveryPricingAdapter;
@@ -0,0 +1,62 @@
1
+ import { DeliveryPricingRowCategory, DeliveryPricingAdapter, DeliveryPricingDirector, } from '@unchainedshop/core';
2
+ import { resolveTaxCategoryFromDeliveryProvider, SwissTaxCategories } from "./tax/ch.js";
3
+ import isDeliveryAddressInCountry from "./utils/isDeliveryAddressInCountry.js";
4
+ export const DeliverySwissTax = {
5
+ ...DeliveryPricingAdapter,
6
+ key: 'shop.unchained.pricing.delivery-swiss-tax',
7
+ version: '1.0.0',
8
+ label: 'Apply Swiss Tax on Delivery Fees',
9
+ orderIndex: 80,
10
+ isActivatedFor: (context) => {
11
+ if (!context.order)
12
+ return false;
13
+ if (!context.orderDelivery)
14
+ return false;
15
+ return isDeliveryAddressInCountry({
16
+ order: context.order,
17
+ orderDelivery: context.orderDelivery,
18
+ countryCode: context.countryCode,
19
+ }, ['CH', 'LI']);
20
+ },
21
+ actions: (params) => {
22
+ const pricingAdapter = DeliveryPricingAdapter.actions(params);
23
+ const { context } = params;
24
+ return {
25
+ ...pricingAdapter,
26
+ calculate: async () => {
27
+ const taxCategory = resolveTaxCategoryFromDeliveryProvider(context.provider) || SwissTaxCategories.DEFAULT;
28
+ const taxRate = taxCategory.rate(context.order?.ordered);
29
+ DeliveryPricingAdapter.log(`DeliverySwissTax -> Tax Multiplicator: ${taxRate}`);
30
+ params.calculationSheet.filterBy({ isTaxable: true }).forEach(({ isNetPrice, ...row }) => {
31
+ if (!isNetPrice) {
32
+ const taxAmount = row.amount - row.amount / (1 + taxRate);
33
+ pricingAdapter.resultSheet().calculation.push({
34
+ ...row,
35
+ amount: -taxAmount,
36
+ isTaxable: false,
37
+ isNetPrice: false,
38
+ meta: { adapter: DeliverySwissTax.key },
39
+ });
40
+ pricingAdapter.resultSheet().addTax({
41
+ amount: taxAmount,
42
+ rate: taxRate,
43
+ baseCategory: DeliveryPricingRowCategory.Delivery,
44
+ meta: { adapter: DeliverySwissTax.key },
45
+ });
46
+ }
47
+ else {
48
+ const taxAmount = row.amount * taxRate;
49
+ pricingAdapter.resultSheet().addTax({
50
+ amount: taxAmount,
51
+ rate: taxRate,
52
+ baseCategory: DeliveryPricingRowCategory.Delivery,
53
+ meta: { adapter: DeliverySwissTax.key },
54
+ });
55
+ }
56
+ });
57
+ return pricingAdapter.calculate();
58
+ },
59
+ };
60
+ },
61
+ };
62
+ DeliveryPricingDirector.registerAdapter(DeliverySwissTax);
@@ -0,0 +1,2 @@
1
+ import { type OrderDiscountConfiguration, type IDiscountAdapter } from '@unchainedshop/core';
2
+ export declare const HundredOff: IDiscountAdapter<OrderDiscountConfiguration>;
@@ -0,0 +1,30 @@
1
+ import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
2
+ export const HundredOff = {
3
+ ...OrderDiscountAdapter,
4
+ key: 'shop.unchained.discount.100-off',
5
+ label: '100 Off',
6
+ version: '1.0.0',
7
+ orderIndex: 10,
8
+ isManualAdditionAllowed: async () => {
9
+ return true;
10
+ },
11
+ isManualRemovalAllowed: async () => {
12
+ return true;
13
+ },
14
+ actions: async ({ context }) => ({
15
+ ...(await OrderDiscountAdapter.actions({ context })),
16
+ isValidForSystemTriggering: async () => {
17
+ return false;
18
+ },
19
+ isValidForCodeTriggering: async ({ code }) => {
20
+ return code.toUpperCase() === '100OFF';
21
+ },
22
+ discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
23
+ if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
24
+ return { fixedRate: 10000 };
25
+ }
26
+ return null;
27
+ },
28
+ }),
29
+ };
30
+ OrderDiscountDirector.registerAdapter(HundredOff);
@@ -0,0 +1,2 @@
1
+ import { type ProductDiscountConfiguration, type IDiscountAdapter } from '@unchainedshop/core';
2
+ export declare const HalfPriceManual: IDiscountAdapter<ProductDiscountConfiguration>;
@@ -0,0 +1,30 @@
1
+ import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
2
+ export const HalfPriceManual = {
3
+ ...OrderDiscountAdapter,
4
+ key: 'shop.unchained.discount.half-price-manual',
5
+ label: 'Half Price Manual',
6
+ version: '1.0.0',
7
+ orderIndex: 10,
8
+ isManualAdditionAllowed: async () => {
9
+ return true;
10
+ },
11
+ isManualRemovalAllowed: async () => {
12
+ return true;
13
+ },
14
+ actions: async ({ context }) => ({
15
+ ...(await OrderDiscountAdapter.actions({ context })),
16
+ isValidForSystemTriggering: async () => {
17
+ return false;
18
+ },
19
+ isValidForCodeTriggering: async ({ code }) => {
20
+ return code === 'HALFPRICE';
21
+ },
22
+ discountForPricingAdapterKey({ pricingAdapterKey }) {
23
+ if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
24
+ return { rate: 0.5 };
25
+ }
26
+ return null;
27
+ },
28
+ }),
29
+ };
30
+ OrderDiscountDirector.registerAdapter(HalfPriceManual);
@@ -0,0 +1,2 @@
1
+ import { type ProductDiscountConfiguration, type IDiscountAdapter } from '@unchainedshop/core';
2
+ export declare const HalfPrice: IDiscountAdapter<ProductDiscountConfiguration>;
@@ -0,0 +1,33 @@
1
+ import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
2
+ export const HalfPrice = {
3
+ ...OrderDiscountAdapter,
4
+ key: 'shop.unchained.discount.half-price',
5
+ label: 'Half Price',
6
+ version: '1.0.0',
7
+ orderIndex: 10,
8
+ isManualAdditionAllowed: async () => {
9
+ return false;
10
+ },
11
+ isManualRemovalAllowed: async () => {
12
+ return false;
13
+ },
14
+ actions: async ({ context }) => ({
15
+ ...(await OrderDiscountAdapter.actions({ context })),
16
+ isValidForSystemTriggering: async () => {
17
+ const { order } = context;
18
+ const user = await context.modules.users.findUserById(order.userId);
19
+ const isUserEligibleForHalfPrice = user?.tags && user.tags.indexOf('half-price') !== -1;
20
+ return !!isUserEligibleForHalfPrice;
21
+ },
22
+ isValidForCodeTriggering: async () => {
23
+ return false;
24
+ },
25
+ discountForPricingAdapterKey({ pricingAdapterKey }) {
26
+ if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
27
+ return { rate: 0.5 };
28
+ }
29
+ return null;
30
+ },
31
+ }),
32
+ };
33
+ OrderDiscountDirector.registerAdapter(HalfPrice);
@@ -0,0 +1,2 @@
1
+ import { type IDeliveryPricingAdapter } from '@unchainedshop/core';
2
+ export declare const DeliveryFreePrice: IDeliveryPricingAdapter;
@@ -0,0 +1,27 @@
1
+ import { DeliveryPricingAdapter, DeliveryPricingDirector, } from '@unchainedshop/core';
2
+ export const DeliveryFreePrice = {
3
+ ...DeliveryPricingAdapter,
4
+ key: 'shop.unchained.pricing.delivery-free',
5
+ label: 'Free Delivery',
6
+ version: '1.0.0',
7
+ orderIndex: 0,
8
+ isActivatedFor: () => {
9
+ return true;
10
+ },
11
+ actions: (params) => {
12
+ const pricingAdapter = DeliveryPricingAdapter.actions(params);
13
+ return {
14
+ ...pricingAdapter,
15
+ calculate: async () => {
16
+ pricingAdapter.resultSheet().addFee({
17
+ amount: 0,
18
+ isTaxable: false,
19
+ isNetPrice: false,
20
+ meta: { adapter: DeliveryFreePrice.key },
21
+ });
22
+ return pricingAdapter.calculate();
23
+ },
24
+ };
25
+ },
26
+ };
27
+ DeliveryPricingDirector.registerAdapter(DeliveryFreePrice);
@@ -0,0 +1,2 @@
1
+ import { type IPaymentPricingAdapter } from '@unchainedshop/core';
2
+ export declare const PaymentFreePrice: IPaymentPricingAdapter;