@medusajs/loyalty-plugin 2.22.5 → 2.22.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +47460 -0
- package/.medusa/server/src/admin/index.mjs +47442 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.d.ts +2 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.js +28 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.js +41 -0
- package/.medusa/server/src/api/admin/gift-cards/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/admin/gift-cards/middlewares.js +82 -0
- package/.medusa/server/src/api/admin/gift-cards/query-config.d.ts +14 -0
- package/.medusa/server/src/api/admin/gift-cards/query-config.js +32 -0
- package/.medusa/server/src/api/admin/gift-cards/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/gift-cards/route.js +42 -0
- package/.medusa/server/src/api/admin/gift-cards/validators.d.ts +139 -0
- package/.medusa/server/src/api/admin/gift-cards/validators.js +56 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.js +30 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/debit/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/debit/route.js +30 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.js +19 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.js +23 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.js +92 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.d.ts +18 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.js +44 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/route.js +52 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.d.ts +147 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.js +49 -0
- package/.medusa/server/src/api/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/middlewares.js +25 -0
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.d.ts +5 -0
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.js +43 -0
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.d.ts +4 -0
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +25 -0
- package/.medusa/server/src/api/store/carts/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +35 -0
- package/.medusa/server/src/api/store/carts/query-config.d.ts +5 -0
- package/.medusa/server/src/api/store/carts/query-config.js +14 -0
- package/.medusa/server/src/api/store/carts/validators.d.ts +13 -0
- package/.medusa/server/src/api/store/carts/validators.js +14 -0
- package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.d.ts +3 -0
- package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.js +24 -0
- package/.medusa/server/src/api/store/gift-cards/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/gift-cards/middlewares.js +16 -0
- package/.medusa/server/src/api/store/gift-cards/query-config.d.ts +14 -0
- package/.medusa/server/src/api/store/gift-cards/query-config.js +73 -0
- package/.medusa/server/src/api/store/gift-cards/validators.d.ts +7 -0
- package/.medusa/server/src/api/store/gift-cards/validators.js +8 -0
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.d.ts +3 -0
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.js +31 -0
- package/.medusa/server/src/api/store/store-credit-accounts/claim/route.d.ts +3 -0
- package/.medusa/server/src/api/store/store-credit-accounts/claim/route.js +25 -0
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.js +36 -0
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.d.ts +14 -0
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.js +51 -0
- package/.medusa/server/src/api/store/store-credit-accounts/route.d.ts +3 -0
- package/.medusa/server/src/api/store/store-credit-accounts/route.js +40 -0
- package/.medusa/server/src/api/store/store-credit-accounts/validators.d.ts +44 -0
- package/.medusa/server/src/api/store/store-credit-accounts/validators.js +19 -0
- package/.medusa/server/src/links/cart-gift-cards-link.d.ts +2 -0
- package/.medusa/server/src/links/cart-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/customer-store-credit-account-link.d.ts +1 -0
- package/.medusa/server/src/links/customer-store-credit-account-link.js +13 -0
- package/.medusa/server/src/links/gift-card-store-credit.d.ts +2 -0
- package/.medusa/server/src/links/gift-card-store-credit.js +10 -0
- package/.medusa/server/src/links/order-gift-cards-link.d.ts +2 -0
- package/.medusa/server/src/links/order-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/order-line-item-gift-card-link.d.ts +1 -0
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +19 -0
- package/.medusa/server/src/migration-scripts/create-loyalty-rbac-policies.d.ts +6 -0
- package/.medusa/server/src/migration-scripts/create-loyalty-rbac-policies.js +30 -0
- package/.medusa/server/src/modules/loyalty/index.d.ts +21 -0
- package/.medusa/server/src/modules/loyalty/index.js +12 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.js +17 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.js +14 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.js +14 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.js +16 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.js +20 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card.d.ts +18 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card.js +18 -0
- package/.medusa/server/src/modules/loyalty/models/index.d.ts +1 -0
- package/.medusa/server/src/modules/loyalty/models/index.js +9 -0
- package/.medusa/server/src/modules/loyalty/service.d.ts +25 -0
- package/.medusa/server/src/modules/loyalty/service.js +20 -0
- package/.medusa/server/src/modules/store-credit/index.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/index.js +12 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.js +16 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.js +18 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.js +19 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.js +14 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.js +16 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.js +16 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.js +27 -0
- package/.medusa/server/src/modules/store-credit/models/account-transaction.d.ts +28 -0
- package/.medusa/server/src/modules/store-credit/models/account-transaction.js +21 -0
- package/.medusa/server/src/modules/store-credit/models/index.d.ts +2 -0
- package/.medusa/server/src/modules/store-credit/models/index.js +11 -0
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.d.ts +27 -0
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.js +27 -0
- package/.medusa/server/src/modules/store-credit/service.d.ts +56 -0
- package/.medusa/server/src/modules/store-credit/service.js +322 -0
- package/.medusa/server/src/subscribers/create-gift-card.d.ts +5 -0
- package/.medusa/server/src/subscribers/create-gift-card.js +53 -0
- package/.medusa/server/src/types/cart/index.d.ts +12 -0
- package/.medusa/server/src/types/cart/index.js +3 -0
- package/.medusa/server/src/types/http/gift-card.d.ts +42 -0
- package/.medusa/server/src/types/http/gift-card.js +3 -0
- package/.medusa/server/src/types/http/index.d.ts +3 -0
- package/.medusa/server/src/types/http/index.js +20 -0
- package/.medusa/server/src/types/http/store-credit-account.d.ts +71 -0
- package/.medusa/server/src/types/http/store-credit-account.js +3 -0
- package/.medusa/server/src/types/http/transaction.d.ts +19 -0
- package/.medusa/server/src/types/http/transaction.js +3 -0
- package/.medusa/server/src/types/index.d.ts +5 -0
- package/.medusa/server/src/types/index.js +22 -0
- package/.medusa/server/src/types/loyalty/index.d.ts +3 -0
- package/.medusa/server/src/types/loyalty/index.js +20 -0
- package/.medusa/server/src/types/loyalty/module.d.ts +166 -0
- package/.medusa/server/src/types/loyalty/module.js +12 -0
- package/.medusa/server/src/types/loyalty/service.d.ts +169 -0
- package/.medusa/server/src/types/loyalty/service.js +3 -0
- package/.medusa/server/src/types/loyalty/workflows.d.ts +3 -0
- package/.medusa/server/src/types/loyalty/workflows.js +3 -0
- package/.medusa/server/src/types/modules.d.ts +6 -0
- package/.medusa/server/src/types/modules.js +12 -0
- package/.medusa/server/src/types/rbac.d.ts +7 -0
- package/.medusa/server/src/types/rbac.js +8 -0
- package/.medusa/server/src/types/store-credit/index.d.ts +2 -0
- package/.medusa/server/src/types/store-credit/index.js +19 -0
- package/.medusa/server/src/types/store-credit/module.d.ts +315 -0
- package/.medusa/server/src/types/store-credit/module.js +13 -0
- package/.medusa/server/src/types/store-credit/service.d.ts +325 -0
- package/.medusa/server/src/types/store-credit/service.js +3 -0
- package/.medusa/server/src/utils/__tests__/code-generator.spec.d.ts +1 -0
- package/.medusa/server/src/utils/__tests__/code-generator.spec.js +30 -0
- package/.medusa/server/src/utils/__tests__/gift-card.spec.d.ts +1 -0
- package/.medusa/server/src/utils/__tests__/gift-card.spec.js +23 -0
- package/.medusa/server/src/utils/code-generator.d.ts +1 -0
- package/.medusa/server/src/utils/code-generator.js +30 -0
- package/.medusa/server/src/utils/gift-card.d.ts +17 -0
- package/.medusa/server/src/utils/gift-card.js +25 -0
- package/.medusa/server/src/workflows/carts/index.d.ts +5 -0
- package/.medusa/server/src/workflows/carts/index.js +22 -0
- package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.d.ts +37 -0
- package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.js +36 -0
- package/.medusa/server/src/workflows/carts/workflows/__tests__/validate-gift-card-expiry.spec.d.ts +1 -0
- package/.medusa/server/src/workflows/carts/workflows/__tests__/validate-gift-card-expiry.spec.js +94 -0
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.d.ts +136 -0
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.js +204 -0
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.d.ts +136 -0
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +161 -0
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.d.ts +94 -0
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.js +139 -0
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.d.ts +30 -0
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.js +158 -0
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.d.ts +103 -0
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.js +124 -0
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.d.ts +29 -0
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.js +22 -0
- package/.medusa/server/src/workflows/gift-cards/index.d.ts +9 -0
- package/.medusa/server/src/workflows/gift-cards/index.js +26 -0
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.d.ts +20 -0
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.js +39 -0
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.d.ts +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.js +24 -0
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.d.ts +32 -0
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.js +34 -0
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.d.ts +19 -0
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.js +41 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.d.ts +65 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.js +101 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.d.ts +36 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.js +88 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.d.ts +28 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.js +34 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.d.ts +60 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.js +129 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.d.ts +28 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.js +31 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +30 -0
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +26 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +27 -0
- package/.medusa/server/src/workflows/index.d.ts +3 -0
- package/.medusa/server/src/workflows/index.js +20 -0
- package/.medusa/server/src/workflows/orders/index.d.ts +2 -0
- package/.medusa/server/src/workflows/orders/index.js +19 -0
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.d.ts +34 -0
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.js +75 -0
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.d.ts +88 -0
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +131 -0
- package/.medusa/server/src/workflows/store-credit/index.d.ts +9 -0
- package/.medusa/server/src/workflows/store-credit/index.js +26 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.d.ts +19 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.js +37 -0
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.d.ts +20 -0
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.js +31 -0
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.d.ts +20 -0
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.js +31 -0
- package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.d.ts +91 -0
- package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.js +170 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.d.ts +50 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.js +50 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.d.ts +29 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.js +32 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.d.ts +29 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.js +55 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.d.ts +29 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.js +32 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-store-credit-account.d.ts +30 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-store-credit-account.js +56 -0
- package/.medusa/server/tailwind.config.d.ts +3 -0
- package/.medusa/server/tailwind.config.js +12 -0
- package/package.json +21 -21
- package/CHANGELOG.md +0 -432
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { BigNumberValue } from "@medusajs/framework/types";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a store credit account in the Store Credit Module.
|
|
4
|
+
*/
|
|
5
|
+
export type ModuleStoreCreditAccount = {
|
|
6
|
+
/**
|
|
7
|
+
* The store credit account's ID.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The ID of the customer who owns this account, if any.
|
|
12
|
+
*/
|
|
13
|
+
customer_id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The unique code that identifies this account, used for anonymous or gift card accounts.
|
|
16
|
+
*/
|
|
17
|
+
code?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The three-letter ISO currency code of the account's balance.
|
|
20
|
+
*
|
|
21
|
+
* @example usd
|
|
22
|
+
*/
|
|
23
|
+
currency_code: string;
|
|
24
|
+
/**
|
|
25
|
+
* The total amount credited to this account.
|
|
26
|
+
*/
|
|
27
|
+
credits: BigNumberValue;
|
|
28
|
+
/**
|
|
29
|
+
* The total amount debited from this account.
|
|
30
|
+
*/
|
|
31
|
+
debits: BigNumberValue;
|
|
32
|
+
/**
|
|
33
|
+
* The current balance of this account (credits minus debits).
|
|
34
|
+
*/
|
|
35
|
+
balance: BigNumberValue;
|
|
36
|
+
/**
|
|
37
|
+
* Custom key-value pairs attached to this account.
|
|
38
|
+
*/
|
|
39
|
+
metadata: Record<string, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* The date the account was created.
|
|
42
|
+
*/
|
|
43
|
+
created_at: string;
|
|
44
|
+
/**
|
|
45
|
+
* The date the account was last updated.
|
|
46
|
+
*/
|
|
47
|
+
updated_at: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The data required to create a store credit account.
|
|
51
|
+
*/
|
|
52
|
+
export type ModuleCreateStoreCreditAccount = {
|
|
53
|
+
/**
|
|
54
|
+
* The unique code for the account. If not provided, one is auto-generated.
|
|
55
|
+
*/
|
|
56
|
+
code?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The ID of the customer to associate with the account.
|
|
59
|
+
*/
|
|
60
|
+
customer_id?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The three-letter ISO currency code for the account.
|
|
63
|
+
*
|
|
64
|
+
* @example usd
|
|
65
|
+
*/
|
|
66
|
+
currency_code: string;
|
|
67
|
+
/**
|
|
68
|
+
* Custom key-value pairs to attach to the account.
|
|
69
|
+
*/
|
|
70
|
+
metadata?: Record<string, unknown>;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The data required to credit a store credit account with an amount.
|
|
74
|
+
*/
|
|
75
|
+
export type ModuleCreditStoreCreditAccount = {
|
|
76
|
+
/**
|
|
77
|
+
* The ID of the store credit account to credit.
|
|
78
|
+
*/
|
|
79
|
+
account_id: string;
|
|
80
|
+
/**
|
|
81
|
+
* The amount to credit to the account.
|
|
82
|
+
*/
|
|
83
|
+
amount: number;
|
|
84
|
+
/**
|
|
85
|
+
* An optional note describing the credit transaction.
|
|
86
|
+
*/
|
|
87
|
+
note?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The resource type this credit references (for example, "order", "gift_card").
|
|
90
|
+
*/
|
|
91
|
+
reference?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The ID of the referenced resource.
|
|
94
|
+
*/
|
|
95
|
+
reference_id?: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The data required to debit a store credit account by an amount.
|
|
99
|
+
*/
|
|
100
|
+
export type ModuleDebitStoreCreditAccount = {
|
|
101
|
+
/**
|
|
102
|
+
* The ID of the store credit account to debit.
|
|
103
|
+
*/
|
|
104
|
+
account_id: string;
|
|
105
|
+
/**
|
|
106
|
+
* The amount to debit from the account.
|
|
107
|
+
*/
|
|
108
|
+
amount: number;
|
|
109
|
+
/**
|
|
110
|
+
* An optional note describing the debit transaction.
|
|
111
|
+
*/
|
|
112
|
+
note?: string;
|
|
113
|
+
/**
|
|
114
|
+
* The resource type this debit references (for example, "user", "order").
|
|
115
|
+
*/
|
|
116
|
+
reference?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The ID of the referenced resource.
|
|
119
|
+
*/
|
|
120
|
+
reference_id?: string;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The data required to update a store credit account.
|
|
124
|
+
*/
|
|
125
|
+
export type ModuleUpdateStoreCreditAccount = {
|
|
126
|
+
/**
|
|
127
|
+
* The ID of the store credit account to update.
|
|
128
|
+
*/
|
|
129
|
+
id: string;
|
|
130
|
+
/**
|
|
131
|
+
* The ID of the customer to associate with the account.
|
|
132
|
+
*/
|
|
133
|
+
customer_id?: string;
|
|
134
|
+
/**
|
|
135
|
+
* The three-letter ISO currency code to update.
|
|
136
|
+
*/
|
|
137
|
+
currency_code?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Custom key-value pairs to update on the account.
|
|
140
|
+
*/
|
|
141
|
+
metadata?: Record<string, unknown>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The type of an account transaction.
|
|
145
|
+
*/
|
|
146
|
+
export declare enum TransactionType {
|
|
147
|
+
CREDIT = "credit",
|
|
148
|
+
DEBIT = "debit"
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A union of the possible transaction type string values.
|
|
152
|
+
*/
|
|
153
|
+
export type TransactionTypeValues = TransactionType.CREDIT | TransactionType.DEBIT;
|
|
154
|
+
/**
|
|
155
|
+
* Represents a transaction on a store credit account.
|
|
156
|
+
*/
|
|
157
|
+
export type ModuleAccountTransaction = {
|
|
158
|
+
/**
|
|
159
|
+
* The transaction's ID.
|
|
160
|
+
*/
|
|
161
|
+
id: string;
|
|
162
|
+
/**
|
|
163
|
+
* The ID of the store credit account this transaction belongs to.
|
|
164
|
+
*/
|
|
165
|
+
account_id: string;
|
|
166
|
+
/**
|
|
167
|
+
* Whether this is a credit or debit transaction.
|
|
168
|
+
*/
|
|
169
|
+
type: TransactionTypeValues;
|
|
170
|
+
/**
|
|
171
|
+
* The transaction amount.
|
|
172
|
+
*/
|
|
173
|
+
amount: BigNumberValue;
|
|
174
|
+
/**
|
|
175
|
+
* The store credit account this transaction belongs to.
|
|
176
|
+
*/
|
|
177
|
+
account: ModuleStoreCreditAccount;
|
|
178
|
+
/**
|
|
179
|
+
* An optional note describing the transaction.
|
|
180
|
+
*/
|
|
181
|
+
note?: string;
|
|
182
|
+
/**
|
|
183
|
+
* The resource type this transaction references (for example, "order", "cart").
|
|
184
|
+
*/
|
|
185
|
+
reference?: string;
|
|
186
|
+
/**
|
|
187
|
+
* The ID of the referenced resource.
|
|
188
|
+
*/
|
|
189
|
+
reference_id?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Custom key-value pairs attached to this transaction.
|
|
192
|
+
*/
|
|
193
|
+
metadata: Record<string, unknown>;
|
|
194
|
+
/**
|
|
195
|
+
* The date the transaction was created.
|
|
196
|
+
*/
|
|
197
|
+
created_at: string;
|
|
198
|
+
/**
|
|
199
|
+
* The date the transaction was last updated.
|
|
200
|
+
*/
|
|
201
|
+
updated_at: string;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The data required to create an account transaction.
|
|
205
|
+
*/
|
|
206
|
+
export type ModuleCreateAccountTransaction = {
|
|
207
|
+
/**
|
|
208
|
+
* The ID of the store credit account to transact on.
|
|
209
|
+
*/
|
|
210
|
+
account_id: string;
|
|
211
|
+
/**
|
|
212
|
+
* The transaction amount.
|
|
213
|
+
*/
|
|
214
|
+
amount: BigNumberValue;
|
|
215
|
+
/**
|
|
216
|
+
* Whether this is a credit or debit transaction.
|
|
217
|
+
*/
|
|
218
|
+
type: TransactionTypeValues;
|
|
219
|
+
/**
|
|
220
|
+
* An optional note describing the transaction.
|
|
221
|
+
*/
|
|
222
|
+
note?: string;
|
|
223
|
+
/**
|
|
224
|
+
* The resource type this transaction references.
|
|
225
|
+
*/
|
|
226
|
+
reference?: string;
|
|
227
|
+
/**
|
|
228
|
+
* The ID of the referenced resource.
|
|
229
|
+
*/
|
|
230
|
+
reference_id?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Custom key-value pairs to attach to the transaction.
|
|
233
|
+
*/
|
|
234
|
+
metadata?: Record<string, unknown>;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* The data required to credit a store credit account.
|
|
238
|
+
*/
|
|
239
|
+
export type ModuleCreditAccount = {
|
|
240
|
+
/**
|
|
241
|
+
* The ID of the store credit account to credit.
|
|
242
|
+
*/
|
|
243
|
+
account_id: string;
|
|
244
|
+
/**
|
|
245
|
+
* The amount to credit.
|
|
246
|
+
*/
|
|
247
|
+
amount: BigNumberValue;
|
|
248
|
+
/**
|
|
249
|
+
* An optional note describing the credit.
|
|
250
|
+
*/
|
|
251
|
+
note?: string;
|
|
252
|
+
/**
|
|
253
|
+
* The resource type this credit references (for example, "cart", "order").
|
|
254
|
+
*/
|
|
255
|
+
reference: string;
|
|
256
|
+
/**
|
|
257
|
+
* The ID of the referenced resource.
|
|
258
|
+
*/
|
|
259
|
+
reference_id: string;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* The data required to debit a store credit account.
|
|
263
|
+
*/
|
|
264
|
+
export type ModuleDebitAccount = {
|
|
265
|
+
/**
|
|
266
|
+
* The ID of the store credit account to debit.
|
|
267
|
+
*/
|
|
268
|
+
account_id: string;
|
|
269
|
+
/**
|
|
270
|
+
* The amount to debit.
|
|
271
|
+
*/
|
|
272
|
+
amount: BigNumberValue;
|
|
273
|
+
/**
|
|
274
|
+
* An optional note describing the debit.
|
|
275
|
+
*/
|
|
276
|
+
note?: string;
|
|
277
|
+
/**
|
|
278
|
+
* The resource type this debit references (for example, "cart", "order").
|
|
279
|
+
*/
|
|
280
|
+
reference: string;
|
|
281
|
+
/**
|
|
282
|
+
* The ID of the referenced resource.
|
|
283
|
+
*/
|
|
284
|
+
reference_id: string;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* The data required to retrieve statistics for a store credit account.
|
|
288
|
+
*/
|
|
289
|
+
export type ModuleRetrieveAccountStats = {
|
|
290
|
+
/**
|
|
291
|
+
* The ID of the store credit account to retrieve stats for.
|
|
292
|
+
*/
|
|
293
|
+
account_id: string;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Aggregated balance statistics for a store credit account.
|
|
297
|
+
*/
|
|
298
|
+
export type ModuleAccountStats = {
|
|
299
|
+
/**
|
|
300
|
+
* The store credit account's ID.
|
|
301
|
+
*/
|
|
302
|
+
id: string;
|
|
303
|
+
/**
|
|
304
|
+
* The current balance of the account (credits minus debits).
|
|
305
|
+
*/
|
|
306
|
+
balance: BigNumberValue;
|
|
307
|
+
/**
|
|
308
|
+
* The total amount credited to the account.
|
|
309
|
+
*/
|
|
310
|
+
credits: BigNumberValue;
|
|
311
|
+
/**
|
|
312
|
+
* The total amount debited from the account.
|
|
313
|
+
*/
|
|
314
|
+
debits: BigNumberValue;
|
|
315
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionType = void 0;
|
|
4
|
+
/* Entity: AccountTransaction */
|
|
5
|
+
/**
|
|
6
|
+
* The type of an account transaction.
|
|
7
|
+
*/
|
|
8
|
+
var TransactionType;
|
|
9
|
+
(function (TransactionType) {
|
|
10
|
+
TransactionType["CREDIT"] = "credit";
|
|
11
|
+
TransactionType["DEBIT"] = "debit";
|
|
12
|
+
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL3R5cGVzL3N0b3JlLWNyZWRpdC9tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBc0pBLGdDQUFnQztBQUVoQzs7R0FFRztBQUNILElBQVksZUFHWDtBQUhELFdBQVksZUFBZTtJQUN6QixvQ0FBaUIsQ0FBQTtJQUNqQixrQ0FBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxlQUFlLCtCQUFmLGVBQWUsUUFHMUIifQ==
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { RestoreReturn } from "@medusajs/framework/types";
|
|
2
|
+
import { BaseFilterable, Context, FindConfig, IModuleService } from "@medusajs/types";
|
|
3
|
+
import { ModuleAccountStats, ModuleAccountTransaction, ModuleCreateStoreCreditAccount, ModuleCreditAccount, ModuleDebitAccount, ModuleRetrieveAccountStats, ModuleStoreCreditAccount, ModuleUpdateStoreCreditAccount } from "./module";
|
|
4
|
+
/**
|
|
5
|
+
* The filters to apply when retrieving store credit accounts.
|
|
6
|
+
*/
|
|
7
|
+
export interface ModuleStoreCreditAccountFilters extends BaseFilterable<ModuleStoreCreditAccountFilters> {
|
|
8
|
+
/**
|
|
9
|
+
* A search term to filter store credit accounts by.
|
|
10
|
+
*/
|
|
11
|
+
q?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Filter by store credit account ID(s).
|
|
14
|
+
*/
|
|
15
|
+
id?: string | string[];
|
|
16
|
+
/**
|
|
17
|
+
* Filter by currency code(s).
|
|
18
|
+
*/
|
|
19
|
+
currency_code?: string | string[];
|
|
20
|
+
/**
|
|
21
|
+
* Filter by customer ID(s).
|
|
22
|
+
*/
|
|
23
|
+
customer_id?: string | string[];
|
|
24
|
+
/**
|
|
25
|
+
* The field to order results by.
|
|
26
|
+
*/
|
|
27
|
+
order?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The filters to apply when listing account transactions.
|
|
31
|
+
*/
|
|
32
|
+
export interface ModuleListAccountTransactions extends BaseFilterable<ModuleListAccountTransactions> {
|
|
33
|
+
/**
|
|
34
|
+
* Filter by transaction ID(s).
|
|
35
|
+
*/
|
|
36
|
+
id?: string | string[];
|
|
37
|
+
/**
|
|
38
|
+
* Filter by store credit account ID(s).
|
|
39
|
+
*/
|
|
40
|
+
account_id?: string | string[];
|
|
41
|
+
/**
|
|
42
|
+
* The field to order results by.
|
|
43
|
+
*/
|
|
44
|
+
order?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The main service interface for the StoreCredit Module.
|
|
48
|
+
*/
|
|
49
|
+
export interface IStoreCreditModuleService extends IModuleService {
|
|
50
|
+
/**
|
|
51
|
+
* This method creates a store credit account.
|
|
52
|
+
*
|
|
53
|
+
* @param {ModuleCreateStoreCreditAccount} data - The store credit account to create.
|
|
54
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
55
|
+
* @returns {Promise<ModuleStoreCreditAccount>} The created store credit account.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const account = await storeCreditModuleService.createStoreCreditAccounts({
|
|
59
|
+
* currency_code: "usd",
|
|
60
|
+
* customer_id: "cust_123",
|
|
61
|
+
* })
|
|
62
|
+
*/
|
|
63
|
+
createStoreCreditAccounts(data: ModuleCreateStoreCreditAccount, sharedContext?: Context): Promise<ModuleStoreCreditAccount>;
|
|
64
|
+
/**
|
|
65
|
+
* This method creates store credit accounts.
|
|
66
|
+
*
|
|
67
|
+
* @param {ModuleCreateStoreCreditAccount[]} data - The store credit accounts to create.
|
|
68
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
69
|
+
* @returns {Promise<ModuleStoreCreditAccount[]>} The created store credit accounts.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const accounts = await storeCreditModuleService.createStoreCreditAccounts([
|
|
73
|
+
* {
|
|
74
|
+
* currency_code: "usd",
|
|
75
|
+
* customer_id: "cust_123",
|
|
76
|
+
* },
|
|
77
|
+
* ])
|
|
78
|
+
*/
|
|
79
|
+
createStoreCreditAccounts(data: ModuleCreateStoreCreditAccount[], sharedContext?: Context): Promise<ModuleStoreCreditAccount[]>;
|
|
80
|
+
/**
|
|
81
|
+
* This method updates a store credit account.
|
|
82
|
+
*
|
|
83
|
+
* @param {ModuleUpdateStoreCreditAccount} data - The attributes to update in the store credit account.
|
|
84
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
85
|
+
* @returns {Promise<ModuleStoreCreditAccount>} The updated store credit account.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const account = await storeCreditModuleService.updateStoreCreditAccounts({
|
|
89
|
+
* id: "sca_123",
|
|
90
|
+
* customer_id: "cust_456",
|
|
91
|
+
* })
|
|
92
|
+
*/
|
|
93
|
+
updateStoreCreditAccounts(data: ModuleUpdateStoreCreditAccount, sharedContext?: Context): Promise<ModuleStoreCreditAccount>;
|
|
94
|
+
/**
|
|
95
|
+
* This method updates store credit accounts.
|
|
96
|
+
*
|
|
97
|
+
* @param {ModuleUpdateStoreCreditAccount[]} data - The attributes to update in the store credit accounts.
|
|
98
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
99
|
+
* @returns {Promise<ModuleStoreCreditAccount[]>} The updated store credit accounts.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const accounts = await storeCreditModuleService.updateStoreCreditAccounts([
|
|
103
|
+
* {
|
|
104
|
+
* id: "sca_123",
|
|
105
|
+
* customer_id: "cust_456",
|
|
106
|
+
* },
|
|
107
|
+
* ])
|
|
108
|
+
*/
|
|
109
|
+
updateStoreCreditAccounts(data: ModuleUpdateStoreCreditAccount[], sharedContext?: Context): Promise<ModuleStoreCreditAccount[]>;
|
|
110
|
+
/**
|
|
111
|
+
* This method retrieves a paginated list of store credit accounts based on optional filters and configuration.
|
|
112
|
+
*
|
|
113
|
+
* @param {ModuleStoreCreditAccountFilters} filters - The filters to apply on the retrieved store credit accounts.
|
|
114
|
+
* @param {FindConfig<ModuleStoreCreditAccount>} config - The configurations determining how the store credit accounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a store credit account.
|
|
115
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
116
|
+
* @returns {Promise<ModuleStoreCreditAccount[]>} The list of store credit accounts.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* To retrieve a list of store credit accounts by customer:
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* const accounts = await storeCreditModuleService.listStoreCreditAccounts({
|
|
123
|
+
* id: ["sca_123", "sca_321"],
|
|
124
|
+
* })
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* To specify relations that should be retrieved within the store credit accounts:
|
|
128
|
+
*
|
|
129
|
+
* :::note
|
|
130
|
+
*
|
|
131
|
+
* You can only retrieve data models defined in the same module. To retrieve linked data models
|
|
132
|
+
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
|
|
133
|
+
*
|
|
134
|
+
* :::
|
|
135
|
+
*
|
|
136
|
+
* ```ts
|
|
137
|
+
* const accounts = await storeCreditModuleService.listStoreCreditAccounts(
|
|
138
|
+
* {
|
|
139
|
+
* id: ["sca_123", "sca_321"],
|
|
140
|
+
* },
|
|
141
|
+
* {
|
|
142
|
+
* relations: ["transactions"],
|
|
143
|
+
* }
|
|
144
|
+
* )
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* const accounts = await storeCreditModuleService.listStoreCreditAccounts(
|
|
151
|
+
* { id: ["sca_123", "sca_321"] },
|
|
152
|
+
* { take: 20, skip: 2 }
|
|
153
|
+
* )
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
listStoreCreditAccounts(filters?: ModuleStoreCreditAccountFilters, config?: FindConfig<ModuleStoreCreditAccount>, sharedContext?: Context): Promise<ModuleStoreCreditAccount[]>;
|
|
157
|
+
/**
|
|
158
|
+
* This method retrieves a store credit account by its ID.
|
|
159
|
+
*
|
|
160
|
+
* @param {string} id - The ID of the store credit account to retrieve.
|
|
161
|
+
* @param {FindConfig<ModuleStoreCreditAccount>} config - The configurations determining how the store credit account is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a store credit account.
|
|
162
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
163
|
+
* @returns {Promise<ModuleStoreCreditAccount>} The retrieved store credit account.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* A simple example that retrieves a store credit account by its ID:
|
|
167
|
+
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* const account = await storeCreditModuleService.retrieveStoreCreditAccount("sca_123")
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* To specify relations that should be retrieved:
|
|
173
|
+
*
|
|
174
|
+
* :::note
|
|
175
|
+
*
|
|
176
|
+
* You can only retrieve data models defined in the same module. To retrieve linked data models
|
|
177
|
+
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
|
|
178
|
+
*
|
|
179
|
+
* :::
|
|
180
|
+
*
|
|
181
|
+
* ```ts
|
|
182
|
+
* const account = await storeCreditModuleService.retrieveStoreCreditAccount("sca_123", {
|
|
183
|
+
* relations: ["transactions"],
|
|
184
|
+
* })
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
retrieveStoreCreditAccount(id: string, config?: FindConfig<ModuleStoreCreditAccount>, sharedContext?: Context): Promise<ModuleStoreCreditAccount>;
|
|
188
|
+
/**
|
|
189
|
+
* This method deletes store credit accounts by their IDs.
|
|
190
|
+
*
|
|
191
|
+
* @param {string[]} ids - The IDs of the store credit accounts to delete.
|
|
192
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
193
|
+
* @returns {Promise<void>} Resolves when the store credit accounts are deleted successfully.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* await storeCreditModuleService.deleteStoreCreditAccounts(["sca_123", "sca_456"])
|
|
197
|
+
*/
|
|
198
|
+
deleteStoreCreditAccounts(ids: string[], sharedContext?: Context): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* This method soft deletes store credit accounts by their IDs. Soft-deleted accounts can be restored using the {@link restoreStoreCreditAccounts} method.
|
|
201
|
+
*
|
|
202
|
+
* @param {string[]} ids - The IDs of the store credit accounts to soft delete.
|
|
203
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
204
|
+
* @returns {Promise<void>} Resolves when the store credit accounts are soft deleted successfully.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* await storeCreditModuleService.softDeleteStoreCreditAccounts(["sca_123"])
|
|
208
|
+
*/
|
|
209
|
+
softDeleteStoreCreditAccounts(ids: string[], sharedContext?: Context): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* This method restores soft-deleted store credit accounts by their IDs.
|
|
212
|
+
*
|
|
213
|
+
* @param {string[]} ids - The IDs of the store credit accounts to restore.
|
|
214
|
+
* @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore and return.
|
|
215
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
216
|
+
* @returns {Promise<Record<TReturnableLinkableKeys, string[]> | void>} The IDs of restored linked records, or void if no linkable keys are requested.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* await storeCreditModuleService.restoreStoreCreditAccounts(["sca_123"])
|
|
220
|
+
*/
|
|
221
|
+
restoreStoreCreditAccounts<TReturnableLinkableKeys extends string = string>(ids: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<TReturnableLinkableKeys, string[]> | void>;
|
|
222
|
+
/**
|
|
223
|
+
* This method retrieves a list of account transactions based on the provided filters.
|
|
224
|
+
*
|
|
225
|
+
* @param {ModuleListAccountTransactions} filters - The filters to apply on the retrieved transactions.
|
|
226
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
227
|
+
* @returns {Promise<ModuleAccountTransaction[]>} The list of account transactions.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* To retrieve a list of account transactions by ID:
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* const transactions = await storeCreditModuleService.listAccountTransactions({
|
|
234
|
+
* id: ["txn_123", "txn_321"],
|
|
235
|
+
* })
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* To specify relations that should be retrieved within the account transactions:
|
|
239
|
+
*
|
|
240
|
+
* :::note
|
|
241
|
+
*
|
|
242
|
+
* You can only retrieve data models defined in the same module. To retrieve linked data models
|
|
243
|
+
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
|
|
244
|
+
*
|
|
245
|
+
* :::
|
|
246
|
+
*
|
|
247
|
+
* ```ts
|
|
248
|
+
* const transactions = await storeCreditModuleService.listAccountTransactions({
|
|
249
|
+
* id: ["txn_123", "txn_321"],
|
|
250
|
+
* }, {
|
|
251
|
+
* relations: ["account"],
|
|
252
|
+
* })
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
|
256
|
+
*
|
|
257
|
+
* ```ts
|
|
258
|
+
* const transactions = await storeCreditModuleService.listAccountTransactions(
|
|
259
|
+
* { id: ["txn_123", "txn_321"] },
|
|
260
|
+
* { take: 20, skip: 2 }
|
|
261
|
+
* )
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
listAccountTransactions(filters: ModuleListAccountTransactions, sharedContext?: Context): Promise<ModuleAccountTransaction[]>;
|
|
265
|
+
/**
|
|
266
|
+
* This method retrieves the balance statistics for a store credit account.
|
|
267
|
+
*
|
|
268
|
+
* @param {ModuleRetrieveAccountStats} filters - The filters to identify the account to retrieve stats for.
|
|
269
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
270
|
+
* @returns {Promise<ModuleAccountStats>} The account statistics including balance, credits, and debits.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* const stats = await storeCreditModuleService.retrieveAccountStats({
|
|
274
|
+
* account_id: "sca_123",
|
|
275
|
+
* })
|
|
276
|
+
*/
|
|
277
|
+
retrieveAccountStats(filters: ModuleRetrieveAccountStats, sharedContext?: Context): Promise<ModuleAccountStats>;
|
|
278
|
+
/**
|
|
279
|
+
* This method credits one or more store credit accounts by creating credit transactions.
|
|
280
|
+
*
|
|
281
|
+
* @param {ModuleCreditAccount[]} data - The credit transactions to create.
|
|
282
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
283
|
+
* @returns {Promise<ModuleAccountTransaction[]>} The created credit transactions.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* const transactions = await storeCreditModuleService.creditAccounts([
|
|
287
|
+
* {
|
|
288
|
+
* account_id: "sca_123",
|
|
289
|
+
* amount: 100,
|
|
290
|
+
* reference: "order",
|
|
291
|
+
* reference_id: "order_123",
|
|
292
|
+
* },
|
|
293
|
+
* ])
|
|
294
|
+
*/
|
|
295
|
+
creditAccounts(data: ModuleCreditAccount[], sharedContext?: Context): Promise<ModuleAccountTransaction[]>;
|
|
296
|
+
/**
|
|
297
|
+
* This method debits one or more store credit accounts by creating debit transactions.
|
|
298
|
+
*
|
|
299
|
+
* @param {ModuleDebitAccount[]} data - The debit transactions to create.
|
|
300
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
301
|
+
* @returns {Promise<ModuleAccountTransaction[]>} The created debit transactions.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* const transactions = await storeCreditModuleService.debitAccounts([
|
|
305
|
+
* {
|
|
306
|
+
* account_id: "sca_123",
|
|
307
|
+
* amount: 50,
|
|
308
|
+
* reference: "cart",
|
|
309
|
+
* reference_id: "cart_123",
|
|
310
|
+
* },
|
|
311
|
+
* ])
|
|
312
|
+
*/
|
|
313
|
+
debitAccounts(data: ModuleDebitAccount[], sharedContext?: Context): Promise<ModuleAccountTransaction[]>;
|
|
314
|
+
/**
|
|
315
|
+
* This method deletes account transactions by their IDs.
|
|
316
|
+
*
|
|
317
|
+
* @param {string[]} ids - The IDs of the transactions to delete.
|
|
318
|
+
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
|
319
|
+
* @returns {Promise<void>} Resolves when the transactions are deleted successfully.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* await storeCreditModuleService.deleteTransactions(["txn_123", "txn_456"])
|
|
323
|
+
*/
|
|
324
|
+
deleteTransactions(ids: string[], sharedContext?: Context): Promise<void>;
|
|
325
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy90eXBlcy9zdG9yZS1jcmVkaXQvc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const code_generator_1 = require("../code-generator");
|
|
4
|
+
const CODE_CHARACTERS = "[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]";
|
|
5
|
+
const stripCode = (code, prefix) => code.slice(prefix.length + 1).replace(/-/g, "");
|
|
6
|
+
describe("generateCode", () => {
|
|
7
|
+
it("formats the code as the prefix followed by sections of 4 characters", () => {
|
|
8
|
+
const code = (0, code_generator_1.generateCode)("GIFT", 4);
|
|
9
|
+
expect(code).toMatch(new RegExp(`^GIFT(-${CODE_CHARACTERS}{4}){4}$`));
|
|
10
|
+
});
|
|
11
|
+
it("omits the prefix when an empty prefix is given", () => {
|
|
12
|
+
const code = (0, code_generator_1.generateCode)("", 2);
|
|
13
|
+
expect(code).toMatch(new RegExp(`^${CODE_CHARACTERS}{4}-${CODE_CHARACTERS}{4}$`));
|
|
14
|
+
});
|
|
15
|
+
it.each([
|
|
16
|
+
{ prefix: "GIFT", sections: 4 },
|
|
17
|
+
{ prefix: "SC", sections: 4 },
|
|
18
|
+
{ prefix: "GIFT", sections: 8 },
|
|
19
|
+
])("doesn't repeat the leading characters at the end of a $sections-section code", ({ prefix, sections }) => {
|
|
20
|
+
const length = sections * 4;
|
|
21
|
+
const usedBytes = Math.ceil((length * 5) / 8);
|
|
22
|
+
const repeatedLength = length - usedBytes;
|
|
23
|
+
for (let i = 0; i < 100; i++) {
|
|
24
|
+
const characters = stripCode((0, code_generator_1.generateCode)(prefix, sections), prefix);
|
|
25
|
+
expect(characters).toHaveLength(length);
|
|
26
|
+
expect(characters.slice(usedBytes)).not.toEqual(characters.slice(0, repeatedLength));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29kZS1nZW5lcmF0b3Iuc3BlYy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy91dGlscy9fX3Rlc3RzX18vY29kZS1nZW5lcmF0b3Iuc3BlYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHNEQUFpRDtBQUVqRCxNQUFNLGVBQWUsR0FBRyxvQ0FBb0MsQ0FBQztBQUU3RCxNQUFNLFNBQVMsR0FBRyxDQUFDLElBQVksRUFBRSxNQUFjLEVBQUUsRUFBRSxDQUNqRCxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksRUFBRSxFQUFFLENBQUMsQ0FBQztBQUVsRCxRQUFRLENBQUMsY0FBYyxFQUFFLEdBQUcsRUFBRTtJQUM1QixFQUFFLENBQUMscUVBQXFFLEVBQUUsR0FBRyxFQUFFO1FBQzdFLE1BQU0sSUFBSSxHQUFHLElBQUEsNkJBQVksRUFBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFFckMsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDLE9BQU8sQ0FBQyxJQUFJLE1BQU0sQ0FBQyxVQUFVLGVBQWUsVUFBVSxDQUFDLENBQUMsQ0FBQztJQUN4RSxDQUFDLENBQUMsQ0FBQztJQUVILEVBQUUsQ0FBQyxnREFBZ0QsRUFBRSxHQUFHLEVBQUU7UUFDeEQsTUFBTSxJQUFJLEdBQUcsSUFBQSw2QkFBWSxFQUFDLEVBQUUsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUVqQyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUMsT0FBTyxDQUNsQixJQUFJLE1BQU0sQ0FBQyxJQUFJLGVBQWUsT0FBTyxlQUFlLE1BQU0sQ0FBQyxDQUM1RCxDQUFDO0lBQ0osQ0FBQyxDQUFDLENBQUM7SUFFSCxFQUFFLENBQUMsSUFBSSxDQUFDO1FBQ04sRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxDQUFDLEVBQUU7UUFDL0IsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLFFBQVEsRUFBRSxDQUFDLEVBQUU7UUFDN0IsRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxDQUFDLEVBQUU7S0FDaEMsQ0FBQyxDQUNBLDhFQUE4RSxFQUM5RSxDQUFDLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxFQUFFLEVBQUU7UUFDdkIsTUFBTSxNQUFNLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztRQUM1QixNQUFNLFNBQVMsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO1FBQzlDLE1BQU0sY0FBYyxHQUFHLE1BQU0sR0FBRyxTQUFTLENBQUM7UUFFMUMsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxDQUFDLEVBQUUsRUFBRSxDQUFDO1lBQzdCLE1BQU0sVUFBVSxHQUFHLFNBQVMsQ0FBQyxJQUFBLDZCQUFZLEVBQUMsTUFBTSxFQUFFLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDO1lBRXJFLE1BQU0sQ0FBQyxVQUFVLENBQUMsQ0FBQyxZQUFZLENBQUMsTUFBTSxDQUFDLENBQUM7WUFDeEMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUM3QyxVQUFVLENBQUMsS0FBSyxDQUFDLENBQUMsRUFBRSxjQUFjLENBQUMsQ0FDcEMsQ0FBQztRQUNKLENBQUM7SUFDSCxDQUFDLENBQ0YsQ0FBQztBQUNKLENBQUMsQ0FBQyxDQUFDIn0=
|