@medusajs/loyalty-plugin 2.22.4 → 2.22.5
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/CHANGELOG.md +432 -0
- package/package.json +20 -20
- package/.medusa/server/src/admin/index.js +0 -47854
- package/.medusa/server/src/admin/index.mjs +0 -47836
- package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.d.ts +0 -2
- package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.js +0 -28
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.d.ts +0 -4
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.js +0 -41
- package/.medusa/server/src/api/admin/gift-cards/middlewares.d.ts +0 -2
- package/.medusa/server/src/api/admin/gift-cards/middlewares.js +0 -82
- package/.medusa/server/src/api/admin/gift-cards/query-config.d.ts +0 -14
- package/.medusa/server/src/api/admin/gift-cards/query-config.js +0 -32
- package/.medusa/server/src/api/admin/gift-cards/route.d.ts +0 -4
- package/.medusa/server/src/api/admin/gift-cards/route.js +0 -42
- package/.medusa/server/src/api/admin/gift-cards/validators.d.ts +0 -139
- package/.medusa/server/src/api/admin/gift-cards/validators.js +0 -56
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.js +0 -30
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/debit/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/debit/route.js +0 -30
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.js +0 -19
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.js +0 -23
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.d.ts +0 -2
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.js +0 -92
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.d.ts +0 -18
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.js +0 -44
- package/.medusa/server/src/api/admin/store-credit-accounts/route.d.ts +0 -4
- package/.medusa/server/src/api/admin/store-credit-accounts/route.js +0 -52
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.d.ts +0 -147
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.js +0 -49
- package/.medusa/server/src/api/middlewares.d.ts +0 -2
- package/.medusa/server/src/api/middlewares.js +0 -25
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.d.ts +0 -5
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.js +0 -43
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.d.ts +0 -4
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +0 -25
- package/.medusa/server/src/api/store/carts/middlewares.d.ts +0 -2
- package/.medusa/server/src/api/store/carts/middlewares.js +0 -35
- package/.medusa/server/src/api/store/carts/query-config.d.ts +0 -5
- package/.medusa/server/src/api/store/carts/query-config.js +0 -14
- package/.medusa/server/src/api/store/carts/validators.d.ts +0 -13
- package/.medusa/server/src/api/store/carts/validators.js +0 -14
- package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.d.ts +0 -3
- package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.js +0 -24
- package/.medusa/server/src/api/store/gift-cards/middlewares.d.ts +0 -2
- package/.medusa/server/src/api/store/gift-cards/middlewares.js +0 -16
- package/.medusa/server/src/api/store/gift-cards/query-config.d.ts +0 -14
- package/.medusa/server/src/api/store/gift-cards/query-config.js +0 -73
- package/.medusa/server/src/api/store/gift-cards/validators.d.ts +0 -7
- package/.medusa/server/src/api/store/gift-cards/validators.js +0 -8
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.d.ts +0 -3
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.js +0 -31
- package/.medusa/server/src/api/store/store-credit-accounts/claim/route.d.ts +0 -3
- package/.medusa/server/src/api/store/store-credit-accounts/claim/route.js +0 -25
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.d.ts +0 -2
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.js +0 -36
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.d.ts +0 -14
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.js +0 -51
- package/.medusa/server/src/api/store/store-credit-accounts/route.d.ts +0 -3
- package/.medusa/server/src/api/store/store-credit-accounts/route.js +0 -40
- package/.medusa/server/src/api/store/store-credit-accounts/validators.d.ts +0 -44
- package/.medusa/server/src/api/store/store-credit-accounts/validators.js +0 -19
- package/.medusa/server/src/links/cart-gift-cards-link.d.ts +0 -2
- package/.medusa/server/src/links/cart-gift-cards-link.js +0 -13
- package/.medusa/server/src/links/customer-store-credit-account-link.d.ts +0 -1
- package/.medusa/server/src/links/customer-store-credit-account-link.js +0 -13
- package/.medusa/server/src/links/gift-card-store-credit.d.ts +0 -2
- package/.medusa/server/src/links/gift-card-store-credit.js +0 -10
- package/.medusa/server/src/links/order-gift-cards-link.d.ts +0 -2
- package/.medusa/server/src/links/order-gift-cards-link.js +0 -13
- package/.medusa/server/src/links/order-line-item-gift-card-link.d.ts +0 -1
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +0 -19
- package/.medusa/server/src/migration-scripts/create-loyalty-rbac-policies.d.ts +0 -6
- package/.medusa/server/src/migration-scripts/create-loyalty-rbac-policies.js +0 -30
- package/.medusa/server/src/modules/loyalty/index.d.ts +0 -21
- package/.medusa/server/src/modules/loyalty/index.js +0 -12
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.js +0 -17
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.js +0 -19
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.js +0 -19
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.js +0 -14
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.js +0 -14
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.js +0 -16
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.d.ts +0 -5
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.js +0 -20
- package/.medusa/server/src/modules/loyalty/models/gift-card.d.ts +0 -18
- package/.medusa/server/src/modules/loyalty/models/gift-card.js +0 -18
- package/.medusa/server/src/modules/loyalty/models/index.d.ts +0 -1
- package/.medusa/server/src/modules/loyalty/models/index.js +0 -9
- package/.medusa/server/src/modules/loyalty/service.d.ts +0 -25
- package/.medusa/server/src/modules/loyalty/service.js +0 -20
- package/.medusa/server/src/modules/store-credit/index.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/index.js +0 -12
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.js +0 -16
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.js +0 -18
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.js +0 -19
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.js +0 -14
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.js +0 -16
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.js +0 -16
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.d.ts +0 -5
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.js +0 -27
- package/.medusa/server/src/modules/store-credit/models/account-transaction.d.ts +0 -28
- package/.medusa/server/src/modules/store-credit/models/account-transaction.js +0 -21
- package/.medusa/server/src/modules/store-credit/models/index.d.ts +0 -2
- package/.medusa/server/src/modules/store-credit/models/index.js +0 -11
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.d.ts +0 -27
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.js +0 -27
- package/.medusa/server/src/modules/store-credit/service.d.ts +0 -56
- package/.medusa/server/src/modules/store-credit/service.js +0 -322
- package/.medusa/server/src/subscribers/create-gift-card.d.ts +0 -5
- package/.medusa/server/src/subscribers/create-gift-card.js +0 -53
- package/.medusa/server/src/types/cart/index.d.ts +0 -12
- package/.medusa/server/src/types/cart/index.js +0 -3
- package/.medusa/server/src/types/http/gift-card.d.ts +0 -42
- package/.medusa/server/src/types/http/gift-card.js +0 -3
- package/.medusa/server/src/types/http/index.d.ts +0 -3
- package/.medusa/server/src/types/http/index.js +0 -20
- package/.medusa/server/src/types/http/store-credit-account.d.ts +0 -71
- package/.medusa/server/src/types/http/store-credit-account.js +0 -3
- package/.medusa/server/src/types/http/transaction.d.ts +0 -19
- package/.medusa/server/src/types/http/transaction.js +0 -3
- package/.medusa/server/src/types/index.d.ts +0 -5
- package/.medusa/server/src/types/index.js +0 -22
- package/.medusa/server/src/types/loyalty/index.d.ts +0 -3
- package/.medusa/server/src/types/loyalty/index.js +0 -20
- package/.medusa/server/src/types/loyalty/module.d.ts +0 -166
- package/.medusa/server/src/types/loyalty/module.js +0 -12
- package/.medusa/server/src/types/loyalty/service.d.ts +0 -169
- package/.medusa/server/src/types/loyalty/service.js +0 -3
- package/.medusa/server/src/types/loyalty/workflows.d.ts +0 -3
- package/.medusa/server/src/types/loyalty/workflows.js +0 -3
- package/.medusa/server/src/types/modules.d.ts +0 -6
- package/.medusa/server/src/types/modules.js +0 -12
- package/.medusa/server/src/types/rbac.d.ts +0 -7
- package/.medusa/server/src/types/rbac.js +0 -8
- package/.medusa/server/src/types/store-credit/index.d.ts +0 -2
- package/.medusa/server/src/types/store-credit/index.js +0 -19
- package/.medusa/server/src/types/store-credit/module.d.ts +0 -315
- package/.medusa/server/src/types/store-credit/module.js +0 -13
- package/.medusa/server/src/types/store-credit/service.d.ts +0 -325
- package/.medusa/server/src/types/store-credit/service.js +0 -3
- package/.medusa/server/src/utils/__tests__/code-generator.spec.d.ts +0 -1
- package/.medusa/server/src/utils/__tests__/code-generator.spec.js +0 -30
- package/.medusa/server/src/utils/__tests__/gift-card.spec.d.ts +0 -1
- package/.medusa/server/src/utils/__tests__/gift-card.spec.js +0 -23
- package/.medusa/server/src/utils/code-generator.d.ts +0 -1
- package/.medusa/server/src/utils/code-generator.js +0 -30
- package/.medusa/server/src/utils/gift-card.d.ts +0 -17
- package/.medusa/server/src/utils/gift-card.js +0 -25
- package/.medusa/server/src/workflows/carts/index.d.ts +0 -5
- package/.medusa/server/src/workflows/carts/index.js +0 -22
- package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.d.ts +0 -37
- package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.js +0 -36
- package/.medusa/server/src/workflows/carts/workflows/__tests__/validate-gift-card-expiry.spec.d.ts +0 -1
- package/.medusa/server/src/workflows/carts/workflows/__tests__/validate-gift-card-expiry.spec.js +0 -94
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.d.ts +0 -136
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.js +0 -204
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.d.ts +0 -136
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +0 -161
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.d.ts +0 -94
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.js +0 -139
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.d.ts +0 -30
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.js +0 -158
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.d.ts +0 -103
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.js +0 -124
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.d.ts +0 -29
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.js +0 -22
- package/.medusa/server/src/workflows/gift-cards/index.d.ts +0 -9
- package/.medusa/server/src/workflows/gift-cards/index.js +0 -26
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.d.ts +0 -20
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.js +0 -39
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.d.ts +0 -17
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.js +0 -24
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.d.ts +0 -32
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.js +0 -34
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.d.ts +0 -19
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.js +0 -41
- package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.d.ts +0 -65
- package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.js +0 -101
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.d.ts +0 -36
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.js +0 -88
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.d.ts +0 -28
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.js +0 -34
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.d.ts +0 -60
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.js +0 -129
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.d.ts +0 -28
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.js +0 -31
- package/.medusa/server/src/workflows/hooks/after-order-created.d.ts +0 -1
- package/.medusa/server/src/workflows/hooks/after-order-created.js +0 -30
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.d.ts +0 -1
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +0 -31
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.d.ts +0 -1
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +0 -26
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.d.ts +0 -1
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +0 -27
- package/.medusa/server/src/workflows/index.d.ts +0 -3
- package/.medusa/server/src/workflows/index.js +0 -20
- package/.medusa/server/src/workflows/orders/index.d.ts +0 -2
- package/.medusa/server/src/workflows/orders/index.js +0 -19
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.d.ts +0 -34
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.js +0 -75
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.d.ts +0 -88
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +0 -131
- package/.medusa/server/src/workflows/store-credit/index.d.ts +0 -9
- package/.medusa/server/src/workflows/store-credit/index.js +0 -26
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.d.ts +0 -19
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.js +0 -37
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.d.ts +0 -20
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.js +0 -31
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.d.ts +0 -20
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.js +0 -31
- package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.d.ts +0 -91
- package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.js +0 -170
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.d.ts +0 -50
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.js +0 -50
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.d.ts +0 -29
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.js +0 -32
- package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.d.ts +0 -29
- package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.js +0 -55
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.d.ts +0 -29
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.js +0 -32
- package/.medusa/server/src/workflows/store-credit/workflows/debit-store-credit-account.d.ts +0 -30
- package/.medusa/server/src/workflows/store-credit/workflows/debit-store-credit-account.js +0 -56
- package/.medusa/server/tailwind.config.d.ts +0 -3
- package/.medusa/server/tailwind.config.js +0 -12
package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ModuleCreateStoreCreditAccount } from "../../../types/store-credit";
|
|
2
|
-
/**
|
|
3
|
-
* This step validates the input for creating store credit accounts. It throws an
|
|
4
|
-
* error if no input is provided or if any entry is missing a currency code.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* const data = validateStoreCreditAccountInputStep([
|
|
8
|
-
* { customer_id: "cust_123", currency_code: "usd" },
|
|
9
|
-
* ])
|
|
10
|
-
*/
|
|
11
|
-
export declare const validateStoreCreditAccountInputStep: import("@medusajs/framework/workflows-sdk").StepFunction<ModuleCreateStoreCreditAccount[], unknown>;
|
|
12
|
-
/**
|
|
13
|
-
* Data for creating a store credit account for a customer.
|
|
14
|
-
*/
|
|
15
|
-
export type CreateStoreCreditAccountsWorkflowInput = {
|
|
16
|
-
/**
|
|
17
|
-
* An optional code for the store credit account. If not provided, one is auto-generated.
|
|
18
|
-
*/
|
|
19
|
-
code?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The ID of the customer who owns the store credit account.
|
|
22
|
-
*/
|
|
23
|
-
customer_id: string;
|
|
24
|
-
/**
|
|
25
|
-
* The currency of the store credit account.
|
|
26
|
-
*/
|
|
27
|
-
currency_code: string;
|
|
28
|
-
}[];
|
|
29
|
-
/**
|
|
30
|
-
* This workflow creates one or more store credit accounts after validating the input.
|
|
31
|
-
*
|
|
32
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
33
|
-
* allowing you to wrap custom logic around store credit account creation.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* const { result } = await createStoreCreditAccountsWorkflow(container)
|
|
37
|
-
* .run({
|
|
38
|
-
* input: [
|
|
39
|
-
* {
|
|
40
|
-
* customer_id: "cust_123",
|
|
41
|
-
* currency_code: "usd",
|
|
42
|
-
* },
|
|
43
|
-
* ],
|
|
44
|
-
* })
|
|
45
|
-
*
|
|
46
|
-
* @summary
|
|
47
|
-
*
|
|
48
|
-
* Create store credit accounts.
|
|
49
|
-
*/
|
|
50
|
-
export declare const createStoreCreditAccountsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<CreateStoreCreditAccountsWorkflowInput, import("../../../types/store-credit").ModuleStoreCreditAccount[], []>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStoreCreditAccountsWorkflow = exports.validateStoreCreditAccountInputStep = void 0;
|
|
4
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
-
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
6
|
-
const create_store_credit_accounts_1 = require("../steps/create-store-credit-accounts");
|
|
7
|
-
/**
|
|
8
|
-
* This step validates the input for creating store credit accounts. It throws an
|
|
9
|
-
* error if no input is provided or if any entry is missing a currency code.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const data = validateStoreCreditAccountInputStep([
|
|
13
|
-
* { customer_id: "cust_123", currency_code: "usd" },
|
|
14
|
-
* ])
|
|
15
|
-
*/
|
|
16
|
-
exports.validateStoreCreditAccountInputStep = (0, workflows_sdk_1.createStep)("validate-store-credit-account-input", async function (input) {
|
|
17
|
-
if (input.length === 0) {
|
|
18
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "No input provided");
|
|
19
|
-
}
|
|
20
|
-
if (input.some((i) => !(0, utils_1.isPresent)(i.currency_code))) {
|
|
21
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Currency code is required to create a store credit account");
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
/**
|
|
25
|
-
* This workflow creates one or more store credit accounts after validating the input.
|
|
26
|
-
*
|
|
27
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
28
|
-
* allowing you to wrap custom logic around store credit account creation.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* const { result } = await createStoreCreditAccountsWorkflow(container)
|
|
32
|
-
* .run({
|
|
33
|
-
* input: [
|
|
34
|
-
* {
|
|
35
|
-
* customer_id: "cust_123",
|
|
36
|
-
* currency_code: "usd",
|
|
37
|
-
* },
|
|
38
|
-
* ],
|
|
39
|
-
* })
|
|
40
|
-
*
|
|
41
|
-
* @summary
|
|
42
|
-
*
|
|
43
|
-
* Create store credit accounts.
|
|
44
|
-
*/
|
|
45
|
-
exports.createStoreCreditAccountsWorkflow = (0, workflows_sdk_1.createWorkflow)("create-store-credit-accounts", function (input) {
|
|
46
|
-
(0, exports.validateStoreCreditAccountInputStep)(input);
|
|
47
|
-
const createdStoreCreditAccounts = (0, create_store_credit_accounts_1.createStoreCreditAccountsStep)(input);
|
|
48
|
-
return new workflows_sdk_1.WorkflowResponse(createdStoreCreditAccounts);
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLXN0b3JlLWNyZWRpdC1hY2NvdW50cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3Mvc3RvcmUtY3JlZGl0L3dvcmtmbG93cy9jcmVhdGUtc3RvcmUtY3JlZGl0LWFjY291bnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHFEQUFtRTtBQUNuRSxxRUFJMkM7QUFFM0Msd0ZBQXNGO0FBRXRGOzs7Ozs7OztHQVFHO0FBQ1UsUUFBQSxtQ0FBbUMsR0FBRyxJQUFBLDBCQUFVLEVBQzNELHFDQUFxQyxFQUNyQyxLQUFLLFdBQVcsS0FBdUM7SUFDckQsSUFBSSxLQUFLLENBQUMsTUFBTSxLQUFLLENBQUMsRUFBRSxDQUFDO1FBQ3ZCLE1BQU0sSUFBSSxtQkFBVyxDQUNuQixtQkFBVyxDQUFDLEtBQUssQ0FBQyxZQUFZLEVBQzlCLG1CQUFtQixDQUNwQixDQUFDO0lBQ0osQ0FBQztJQUVELElBQUksS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxJQUFBLGlCQUFTLEVBQUMsQ0FBQyxDQUFDLGFBQWEsQ0FBQyxDQUFDLEVBQUUsQ0FBQztRQUNuRCxNQUFNLElBQUksbUJBQVcsQ0FDbkIsbUJBQVcsQ0FBQyxLQUFLLENBQUMsWUFBWSxFQUM5Qiw0REFBNEQsQ0FDN0QsQ0FBQztJQUNKLENBQUM7QUFDSCxDQUFDLENBQ0YsQ0FBQztBQW9CRjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FvQkc7QUFDVSxRQUFBLGlDQUFpQyxHQUFHLElBQUEsOEJBQWMsRUFDN0QsOEJBQThCLEVBQzlCLFVBQVUsS0FBNkM7SUFDckQsSUFBQSwyQ0FBbUMsRUFBQyxLQUFLLENBQUMsQ0FBQztJQUUzQyxNQUFNLDBCQUEwQixHQUFHLElBQUEsNERBQTZCLEVBQUMsS0FBSyxDQUFDLENBQUM7SUFDeEUsT0FBTyxJQUFJLGdDQUFnQixDQUFDLDBCQUEwQixDQUFDLENBQUM7QUFDMUQsQ0FBQyxDQUNGLENBQUMifQ==
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ModuleCreditAccount } from "../../../types/store-credit";
|
|
2
|
-
/**
|
|
3
|
-
* Data for crediting one or more store credit accounts.
|
|
4
|
-
*/
|
|
5
|
-
export type CreditAccountsWorkflowInput = ModuleCreditAccount[];
|
|
6
|
-
/**
|
|
7
|
-
* This workflow credits one or more store credit accounts with transactions.
|
|
8
|
-
*
|
|
9
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
10
|
-
* allowing you to wrap custom logic around crediting store credit accounts.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const { result } = await creditAccountsWorkflow(container)
|
|
14
|
-
* .run({
|
|
15
|
-
* input: [
|
|
16
|
-
* {
|
|
17
|
-
* account_id: "sca_123",
|
|
18
|
-
* amount: 100,
|
|
19
|
-
* reference: "gift_card",
|
|
20
|
-
* reference_id: "gc_123",
|
|
21
|
-
* },
|
|
22
|
-
* ],
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* @summary
|
|
26
|
-
*
|
|
27
|
-
* Credit one or more store credit accounts.
|
|
28
|
-
*/
|
|
29
|
-
export declare const creditAccountsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<CreditAccountsWorkflowInput, import("../../../types/store-credit").ModuleAccountTransaction[], []>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.creditAccountsWorkflow = void 0;
|
|
4
|
-
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
5
|
-
const credit_account_1 = require("../steps/credit-account");
|
|
6
|
-
/**
|
|
7
|
-
* This workflow credits one or more store credit accounts with transactions.
|
|
8
|
-
*
|
|
9
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
10
|
-
* allowing you to wrap custom logic around crediting store credit accounts.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const { result } = await creditAccountsWorkflow(container)
|
|
14
|
-
* .run({
|
|
15
|
-
* input: [
|
|
16
|
-
* {
|
|
17
|
-
* account_id: "sca_123",
|
|
18
|
-
* amount: 100,
|
|
19
|
-
* reference: "gift_card",
|
|
20
|
-
* reference_id: "gc_123",
|
|
21
|
-
* },
|
|
22
|
-
* ],
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* @summary
|
|
26
|
-
*
|
|
27
|
-
* Credit one or more store credit accounts.
|
|
28
|
-
*/
|
|
29
|
-
exports.creditAccountsWorkflow = (0, workflows_sdk_1.createWorkflow)("credit-accounts", function (input) {
|
|
30
|
-
return new workflows_sdk_1.WorkflowResponse((0, credit_account_1.creditAccountStep)(input));
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlZGl0LWFjY291bnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL3dvcmtmbG93cy9zdG9yZS1jcmVkaXQvd29ya2Zsb3dzL2NyZWRpdC1hY2NvdW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxRUFBcUY7QUFFckYsNERBQTREO0FBTzVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBc0JHO0FBQ1UsUUFBQSxzQkFBc0IsR0FBRyxJQUFBLDhCQUFjLEVBQ2xELGlCQUFpQixFQUNqQixVQUFVLEtBQWtDO0lBQzFDLE9BQU8sSUFBSSxnQ0FBZ0IsQ0FBQyxJQUFBLGtDQUFpQixFQUFDLEtBQUssQ0FBQyxDQUFDLENBQUM7QUFDeEQsQ0FBQyxDQUNGLENBQUMifQ==
|
package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ModuleCreditStoreCreditAccount } from "../../../types/store-credit";
|
|
2
|
-
/**
|
|
3
|
-
* Input to credit a specific store credit account with an amount.
|
|
4
|
-
*/
|
|
5
|
-
export type CreditStoreCreditAccountWorkflowInput = ModuleCreditStoreCreditAccount;
|
|
6
|
-
/**
|
|
7
|
-
* This workflow credits a specific store credit account with an amount. It validates
|
|
8
|
-
* that the amount is greater than zero and that the account exists before crediting.
|
|
9
|
-
*
|
|
10
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
11
|
-
* allowing you to wrap custom logic around crediting a store credit account.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* await creditStoreCreditAccountWorkflow(container)
|
|
15
|
-
* .run({
|
|
16
|
-
* input: {
|
|
17
|
-
* account_id: "sca_123",
|
|
18
|
-
* amount: 100,
|
|
19
|
-
* note: "Loyalty reward",
|
|
20
|
-
* reference: "order",
|
|
21
|
-
* reference_id: "order_123",
|
|
22
|
-
* },
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* @summary
|
|
26
|
-
*
|
|
27
|
-
* Credit a store credit account.
|
|
28
|
-
*/
|
|
29
|
-
export declare const creditStoreCreditAccountWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<ModuleCreditStoreCreditAccount, unknown, any[]>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.creditStoreCreditAccountWorkflow = void 0;
|
|
4
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
-
const core_flows_1 = require("@medusajs/medusa/core-flows");
|
|
6
|
-
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
7
|
-
const credit_account_1 = require("../steps/credit-account");
|
|
8
|
-
const validateStoreCreditAccountInputStep = (0, workflows_sdk_1.createStep)("validate-store-credit-account-input", async function (input) {
|
|
9
|
-
if (input.amount <= 0) {
|
|
10
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Amount must be greater than 0");
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
/**
|
|
14
|
-
* This workflow credits a specific store credit account with an amount. It validates
|
|
15
|
-
* that the amount is greater than zero and that the account exists before crediting.
|
|
16
|
-
*
|
|
17
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
18
|
-
* allowing you to wrap custom logic around crediting a store credit account.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* await creditStoreCreditAccountWorkflow(container)
|
|
22
|
-
* .run({
|
|
23
|
-
* input: {
|
|
24
|
-
* account_id: "sca_123",
|
|
25
|
-
* amount: 100,
|
|
26
|
-
* note: "Loyalty reward",
|
|
27
|
-
* reference: "order",
|
|
28
|
-
* reference_id: "order_123",
|
|
29
|
-
* },
|
|
30
|
-
* })
|
|
31
|
-
*
|
|
32
|
-
* @summary
|
|
33
|
-
*
|
|
34
|
-
* Credit a store credit account.
|
|
35
|
-
*/
|
|
36
|
-
exports.creditStoreCreditAccountWorkflow = (0, workflows_sdk_1.createWorkflow)("credit-store-credit-account", function (input) {
|
|
37
|
-
validateStoreCreditAccountInputStep(input);
|
|
38
|
-
const storeCreditAccountData = (0, core_flows_1.useQueryGraphStep)({
|
|
39
|
-
entity: "store_credit_account",
|
|
40
|
-
fields: ["id", "code", "customer_id", "currency_code", "balance"],
|
|
41
|
-
filters: { id: input.account_id },
|
|
42
|
-
options: { throwIfKeyNotFound: true },
|
|
43
|
-
});
|
|
44
|
-
const creditData = (0, workflows_sdk_1.transform)({ storeCreditAccountData, input }, ({ storeCreditAccountData, input }) => {
|
|
45
|
-
return {
|
|
46
|
-
account_id: storeCreditAccountData.data[0].id,
|
|
47
|
-
amount: utils_1.MathBN.convert(input.amount),
|
|
48
|
-
note: input.note || "",
|
|
49
|
-
reference: input.reference || "",
|
|
50
|
-
reference_id: input.reference_id || "",
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
(0, credit_account_1.creditAccountStep)([creditData]);
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlZGl0LXN0b3JlLWNyZWRpdC1hY2NvdW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL3dvcmtmbG93cy9zdG9yZS1jcmVkaXQvd29ya2Zsb3dzL2NyZWRpdC1zdG9yZS1jcmVkaXQtYWNjb3VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxREFBZ0U7QUFDaEUsNERBQWdFO0FBQ2hFLHFFQUEwRjtBQUcxRiw0REFBNEQ7QUFPNUQsTUFBTSxtQ0FBbUMsR0FBRyxJQUFBLDBCQUFVLEVBQ3BELHFDQUFxQyxFQUNyQyxLQUFLLFdBQVcsS0FBcUM7SUFDbkQsSUFBSSxLQUFLLENBQUMsTUFBTSxJQUFJLENBQUMsRUFBRSxDQUFDO1FBQ3RCLE1BQU0sSUFBSSxtQkFBVyxDQUNuQixtQkFBVyxDQUFDLEtBQUssQ0FBQyxZQUFZLEVBQzlCLCtCQUErQixDQUNoQyxDQUFDO0lBQ0osQ0FBQztBQUNILENBQUMsQ0FDRixDQUFDO0FBRUY7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FzQkc7QUFDVSxRQUFBLGdDQUFnQyxHQUFHLElBQUEsOEJBQWMsRUFDNUQsNkJBQTZCLEVBQzdCLFVBQVUsS0FBNEM7SUFDcEQsbUNBQW1DLENBQUMsS0FBSyxDQUFDLENBQUM7SUFFM0MsTUFBTSxzQkFBc0IsR0FBRyxJQUFBLDhCQUFpQixFQUFDO1FBQy9DLE1BQU0sRUFBRSxzQkFBc0I7UUFDOUIsTUFBTSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxhQUFhLEVBQUUsZUFBZSxFQUFFLFNBQVMsQ0FBQztRQUNqRSxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsS0FBSyxDQUFDLFVBQVUsRUFBRTtRQUNqQyxPQUFPLEVBQUUsRUFBRSxrQkFBa0IsRUFBRSxJQUFJLEVBQUU7S0FDdEMsQ0FBQyxDQUFDO0lBRUgsTUFBTSxVQUFVLEdBQUcsSUFBQSx5QkFBUyxFQUMxQixFQUFFLHNCQUFzQixFQUFFLEtBQUssRUFBRSxFQUNqQyxDQUFDLEVBQUUsc0JBQXNCLEVBQUUsS0FBSyxFQUFFLEVBQUUsRUFBRTtRQUNwQyxPQUFPO1lBQ0wsVUFBVSxFQUFFLHNCQUFzQixDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFO1lBQzdDLE1BQU0sRUFBRSxjQUFNLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUM7WUFDcEMsSUFBSSxFQUFFLEtBQUssQ0FBQyxJQUFJLElBQUksRUFBRTtZQUN0QixTQUFTLEVBQUUsS0FBSyxDQUFDLFNBQVMsSUFBSSxFQUFFO1lBQ2hDLFlBQVksRUFBRSxLQUFLLENBQUMsWUFBWSxJQUFJLEVBQUU7U0FDdkMsQ0FBQztJQUNKLENBQUMsQ0FDRixDQUFDO0lBRUYsSUFBQSxrQ0FBaUIsRUFBQyxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUM7QUFDbEMsQ0FBQyxDQUNGLENBQUMifQ==
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ModuleDebitAccount } from "../../../types/store-credit";
|
|
2
|
-
/**
|
|
3
|
-
* Data for debiting one or more store credit accounts.
|
|
4
|
-
*/
|
|
5
|
-
export type DebitAccountsWorkflowInput = ModuleDebitAccount[];
|
|
6
|
-
/**
|
|
7
|
-
* This workflow debits one or more store credit accounts by creating debit transactions.
|
|
8
|
-
*
|
|
9
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
10
|
-
* allowing you to wrap custom logic around debiting store credit accounts.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const { result } = await debitAccountsWorkflow(container)
|
|
14
|
-
* .run({
|
|
15
|
-
* input: [
|
|
16
|
-
* {
|
|
17
|
-
* account_id: "sca_123",
|
|
18
|
-
* amount: 50,
|
|
19
|
-
* reference: "cart",
|
|
20
|
-
* reference_id: "cart_123",
|
|
21
|
-
* },
|
|
22
|
-
* ],
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* @summary
|
|
26
|
-
*
|
|
27
|
-
* Debit one or more store credit accounts.
|
|
28
|
-
*/
|
|
29
|
-
export declare const debitAccountsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<DebitAccountsWorkflowInput, import("../../../types/store-credit").ModuleAccountTransaction[], []>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debitAccountsWorkflow = void 0;
|
|
4
|
-
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
5
|
-
const debit_account_1 = require("../steps/debit-account");
|
|
6
|
-
/**
|
|
7
|
-
* This workflow debits one or more store credit accounts by creating debit transactions.
|
|
8
|
-
*
|
|
9
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
10
|
-
* allowing you to wrap custom logic around debiting store credit accounts.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const { result } = await debitAccountsWorkflow(container)
|
|
14
|
-
* .run({
|
|
15
|
-
* input: [
|
|
16
|
-
* {
|
|
17
|
-
* account_id: "sca_123",
|
|
18
|
-
* amount: 50,
|
|
19
|
-
* reference: "cart",
|
|
20
|
-
* reference_id: "cart_123",
|
|
21
|
-
* },
|
|
22
|
-
* ],
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* @summary
|
|
26
|
-
*
|
|
27
|
-
* Debit one or more store credit accounts.
|
|
28
|
-
*/
|
|
29
|
-
exports.debitAccountsWorkflow = (0, workflows_sdk_1.createWorkflow)("debit-accounts", function (input) {
|
|
30
|
-
return new workflows_sdk_1.WorkflowResponse((0, debit_account_1.debitAccountStep)(input));
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGViaXQtYWNjb3VudHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL3N0b3JlLWNyZWRpdC93b3JrZmxvd3MvZGViaXQtYWNjb3VudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEscUVBQXFGO0FBRXJGLDBEQUEwRDtBQU8xRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQXNCRztBQUNVLFFBQUEscUJBQXFCLEdBQUcsSUFBQSw4QkFBYyxFQUNqRCxnQkFBZ0IsRUFDaEIsVUFBVSxLQUFpQztJQUN6QyxPQUFPLElBQUksZ0NBQWdCLENBQUMsSUFBQSxnQ0FBZ0IsRUFBQyxLQUFLLENBQUMsQ0FBQyxDQUFDO0FBQ3ZELENBQUMsQ0FDRixDQUFDIn0=
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ModuleDebitStoreCreditAccount } from "../../../types/store-credit";
|
|
2
|
-
/**
|
|
3
|
-
* Input to debit a specific store credit account by an amount.
|
|
4
|
-
*/
|
|
5
|
-
export type DebitStoreCreditAccountWorkflowInput = ModuleDebitStoreCreditAccount;
|
|
6
|
-
/**
|
|
7
|
-
* This workflow debits a specific store credit account by an amount. It validates
|
|
8
|
-
* that the amount is greater than zero and that the account exists before debiting.
|
|
9
|
-
* The debit is rejected if the account's balance doesn't cover the amount.
|
|
10
|
-
*
|
|
11
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
12
|
-
* allowing you to wrap custom logic around debiting a store credit account.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* await debitStoreCreditAccountWorkflow(container)
|
|
16
|
-
* .run({
|
|
17
|
-
* input: {
|
|
18
|
-
* account_id: "sca_123",
|
|
19
|
-
* amount: 100,
|
|
20
|
-
* note: "Credit issued by mistake",
|
|
21
|
-
* reference: "user",
|
|
22
|
-
* reference_id: "user_123",
|
|
23
|
-
* },
|
|
24
|
-
* })
|
|
25
|
-
*
|
|
26
|
-
* @summary
|
|
27
|
-
*
|
|
28
|
-
* Debit a store credit account.
|
|
29
|
-
*/
|
|
30
|
-
export declare const debitStoreCreditAccountWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<ModuleDebitStoreCreditAccount, unknown, any[]>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debitStoreCreditAccountWorkflow = void 0;
|
|
4
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
-
const core_flows_1 = require("@medusajs/medusa/core-flows");
|
|
6
|
-
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
7
|
-
const debit_account_1 = require("../steps/debit-account");
|
|
8
|
-
const validateDebitStoreCreditAccountInputStep = (0, workflows_sdk_1.createStep)("validate-debit-store-credit-account-input", async function (input) {
|
|
9
|
-
if (input.amount <= 0) {
|
|
10
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Amount must be greater than 0");
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
/**
|
|
14
|
-
* This workflow debits a specific store credit account by an amount. It validates
|
|
15
|
-
* that the amount is greater than zero and that the account exists before debiting.
|
|
16
|
-
* The debit is rejected if the account's balance doesn't cover the amount.
|
|
17
|
-
*
|
|
18
|
-
* You can use this workflow within your own customizations or custom workflows,
|
|
19
|
-
* allowing you to wrap custom logic around debiting a store credit account.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* await debitStoreCreditAccountWorkflow(container)
|
|
23
|
-
* .run({
|
|
24
|
-
* input: {
|
|
25
|
-
* account_id: "sca_123",
|
|
26
|
-
* amount: 100,
|
|
27
|
-
* note: "Credit issued by mistake",
|
|
28
|
-
* reference: "user",
|
|
29
|
-
* reference_id: "user_123",
|
|
30
|
-
* },
|
|
31
|
-
* })
|
|
32
|
-
*
|
|
33
|
-
* @summary
|
|
34
|
-
*
|
|
35
|
-
* Debit a store credit account.
|
|
36
|
-
*/
|
|
37
|
-
exports.debitStoreCreditAccountWorkflow = (0, workflows_sdk_1.createWorkflow)("debit-store-credit-account", function (input) {
|
|
38
|
-
validateDebitStoreCreditAccountInputStep(input);
|
|
39
|
-
const storeCreditAccountData = (0, core_flows_1.useQueryGraphStep)({
|
|
40
|
-
entity: "store_credit_account",
|
|
41
|
-
fields: ["id", "code", "customer_id", "currency_code", "balance"],
|
|
42
|
-
filters: { id: input.account_id },
|
|
43
|
-
options: { throwIfKeyNotFound: true },
|
|
44
|
-
});
|
|
45
|
-
const debitData = (0, workflows_sdk_1.transform)({ storeCreditAccountData, input }, ({ storeCreditAccountData, input }) => {
|
|
46
|
-
return {
|
|
47
|
-
account_id: storeCreditAccountData.data[0].id,
|
|
48
|
-
amount: utils_1.MathBN.convert(input.amount),
|
|
49
|
-
note: input.note || "",
|
|
50
|
-
reference: input.reference || "",
|
|
51
|
-
reference_id: input.reference_id || "",
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
(0, debit_account_1.debitAccountStep)([debitData]);
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGViaXQtc3RvcmUtY3JlZGl0LWFjY291bnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL3N0b3JlLWNyZWRpdC93b3JrZmxvd3MvZGViaXQtc3RvcmUtY3JlZGl0LWFjY291bnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEscURBQWdFO0FBQ2hFLDREQUFnRTtBQUNoRSxxRUFBMEY7QUFHMUYsMERBQTBEO0FBTzFELE1BQU0sd0NBQXdDLEdBQUcsSUFBQSwwQkFBVSxFQUN6RCwyQ0FBMkMsRUFDM0MsS0FBSyxXQUFXLEtBQW9DO0lBQ2xELElBQUksS0FBSyxDQUFDLE1BQU0sSUFBSSxDQUFDLEVBQUUsQ0FBQztRQUN0QixNQUFNLElBQUksbUJBQVcsQ0FDbkIsbUJBQVcsQ0FBQyxLQUFLLENBQUMsWUFBWSxFQUM5QiwrQkFBK0IsQ0FDaEMsQ0FBQztJQUNKLENBQUM7QUFDSCxDQUFDLENBQ0YsQ0FBQztBQUVGOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQXVCRztBQUNVLFFBQUEsK0JBQStCLEdBQUcsSUFBQSw4QkFBYyxFQUMzRCw0QkFBNEIsRUFDNUIsVUFBVSxLQUEyQztJQUNuRCx3Q0FBd0MsQ0FBQyxLQUFLLENBQUMsQ0FBQztJQUVoRCxNQUFNLHNCQUFzQixHQUFHLElBQUEsOEJBQWlCLEVBQUM7UUFDL0MsTUFBTSxFQUFFLHNCQUFzQjtRQUM5QixNQUFNLEVBQUUsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLGFBQWEsRUFBRSxlQUFlLEVBQUUsU0FBUyxDQUFDO1FBQ2pFLE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxLQUFLLENBQUMsVUFBVSxFQUFFO1FBQ2pDLE9BQU8sRUFBRSxFQUFFLGtCQUFrQixFQUFFLElBQUksRUFBRTtLQUN0QyxDQUFDLENBQUM7SUFFSCxNQUFNLFNBQVMsR0FBRyxJQUFBLHlCQUFTLEVBQ3pCLEVBQUUsc0JBQXNCLEVBQUUsS0FBSyxFQUFFLEVBQ2pDLENBQUMsRUFBRSxzQkFBc0IsRUFBRSxLQUFLLEVBQUUsRUFBRSxFQUFFO1FBQ3BDLE9BQU87WUFDTCxVQUFVLEVBQUUsc0JBQXNCLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUU7WUFDN0MsTUFBTSxFQUFFLGNBQU0sQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQztZQUNwQyxJQUFJLEVBQUUsS0FBSyxDQUFDLElBQUksSUFBSSxFQUFFO1lBQ3RCLFNBQVMsRUFBRSxLQUFLLENBQUMsU0FBUyxJQUFJLEVBQUU7WUFDaEMsWUFBWSxFQUFFLEtBQUssQ0FBQyxZQUFZLElBQUksRUFBRTtTQUN2QyxDQUFDO0lBQ0osQ0FBQyxDQUNGLENBQUM7SUFFRixJQUFBLGdDQUFnQixFQUFDLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQztBQUNoQyxDQUFDLENBQ0YsQ0FBQyJ9
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ui_preset_1 = __importDefault(require("@medusajs/ui-preset"));
|
|
7
|
-
const config = {
|
|
8
|
-
content: ["./src/admin/**/*.{ts,tsx}"],
|
|
9
|
-
presets: [ui_preset_1.default],
|
|
10
|
-
};
|
|
11
|
-
exports.default = config;
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFpbHdpbmQuY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdGFpbHdpbmQuY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsb0VBQXdDO0FBR3hDLE1BQU0sTUFBTSxHQUFXO0lBQ3JCLE9BQU8sRUFBRSxDQUFDLDJCQUEyQixDQUFDO0lBQ3RDLE9BQU8sRUFBRSxDQUFDLG1CQUFNLENBQUM7Q0FDbEIsQ0FBQTtBQUVELGtCQUFlLE1BQU0sQ0FBQSJ9
|