@octap/sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/README.md +7 -6
- package/dist/client.d.ts +53 -11
- package/dist/client.js +68 -22
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/voucher-csv.d.ts +57 -0
- package/dist/voucher-csv.js +343 -0
- package/dist/voucher-csv.js.map +1 -0
- package/package.json +4 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Voucher expiry webhooks (OCT-336): `voucher.expired` (a voucher's claim window closed while it was
|
|
8
|
+
live, paused or sold out; `VoucherLifecycleEventData`) and `voucher.member_expired` (a customer's
|
|
9
|
+
voucher reached its own deadline unused; `VoucherMemberExpiredEventData`). Each arrives once,
|
|
10
|
+
within about a minute of the deadline.
|
|
11
|
+
- Voucher batches (OCT-303): `createVouchers(items, { dryRun, name })` creates up to 100 vouchers
|
|
12
|
+
as one DRAFT batch (`dryRun` previews each item's result and writes nothing), then
|
|
13
|
+
`activateVoucherBatch`, `pauseVoucherBatch`, `resumeVoucherBatch` and `archiveVoucherBatch` act
|
|
14
|
+
on the whole batch and report each voucher's outcome. Read them with `listVoucherBatches` and
|
|
15
|
+
`getVoucherBatch`.
|
|
16
|
+
- `VoucherDto.batchId`: the batch a voucher was created or re-imported in, `null` otherwise.
|
|
17
|
+
- `parseVoucherCsv(text, { utcOffset })` reads a CSV in the Octap voucher template (the file the
|
|
18
|
+
console imports) into items for `createVouchers`, with the console's checks: each bad row is
|
|
19
|
+
reported with its line and column and left out. Also exported: `VOUCHER_CSV_TEMPLATE`,
|
|
20
|
+
`VOUCHER_CSV_TYPES`, `VOUCHER_BENEFIT_SCHEMA` and `suggestVoucherCode`.
|
|
21
|
+
- The reference documents the `octap.benefit.v1` shape of `terms` the console reads.
|
|
22
|
+
- `VoucherDto.createdBy`, `activatedBy` and `activatedAt` (OCT-324): who created a voucher, who took
|
|
23
|
+
it live (whoever activated it, or the Owner who approved it) and when publishing started. Each is
|
|
24
|
+
`{ type: 'USER' | 'API_CREDENTIAL', id }` or `null` when not recorded.
|
|
25
|
+
- `VoucherApprovalDto.id` and `snapshot`: the submission an Owner decides on, and its terms as
|
|
26
|
+
submitted, which is what approving publishes.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- `EXPIRED` is now actually written (OCT-336). A voucher past its claim window is `EXPIRED`, not
|
|
31
|
+
`ACTIVE`, and a customer's voucher past its deadline is `EXPIRED`, not `AVAILABLE`, in every read:
|
|
32
|
+
`listVouchers`, `getVoucher`, `listMemberVouchers`, `getClaim` and voucher batches. Pausing or
|
|
33
|
+
resuming an `EXPIRED` voucher is a 409; its supply and metadata stay editable.
|
|
34
|
+
|
|
35
|
+
- `VoucherStatus` has a new value, `ARCHIVED`: a voucher of an archived batch that never went
|
|
36
|
+
live. `listVouchers` and `getVoucher` can return it. It can't be edited, submitted or claimed;
|
|
37
|
+
importing its code in a new batch brings it back as `DRAFT`. Code that switches on `status`
|
|
38
|
+
should handle it.
|
|
39
|
+
|
|
40
|
+
### Breaking changes
|
|
41
|
+
|
|
42
|
+
The `admin` API key scope is gone. Managing webhooks and the voucher refund policy moved to the
|
|
43
|
+
console, where only the organization's Owner can do it. These methods are removed, because no API
|
|
44
|
+
key can call their routes any more:
|
|
45
|
+
|
|
46
|
+
| Removed | Do it in the console instead |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `registerWebhookEndpoint` | Webhooks → register an endpoint |
|
|
49
|
+
| `disableWebhookEndpoint`, `enableWebhookEndpoint` | Webhooks → disable / enable |
|
|
50
|
+
| `rotateWebhookSecret` | Webhooks → rotate the secret |
|
|
51
|
+
| `replayWebhookDelivery` | Webhooks → deliveries → replay |
|
|
52
|
+
| `setVoucherRefundPolicy` | Refund policy → publish |
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
- `listVoucherRefundPolicyHistory` needs only a `read` key (it needed `admin`).
|
|
57
|
+
- `reverseTransaction` can refund an expired or redeemed voucher with a `write` key when the refund
|
|
58
|
+
policy allows it. It used to need `admin`; now the policy is the only gate.
|
|
59
|
+
- `VoucherRefundPolicyDto` has a new `createdByUserId`, the Owner who published the version from the
|
|
60
|
+
console. `createdByCredentialId` is set only on versions published with an API key before 0.2.0.
|
|
61
|
+
|
|
62
|
+
`listWebhookEndpoints`, `listWebhookDeliveries`, `getVoucherRefundPolicy` and every other method are
|
|
63
|
+
unchanged.
|
|
64
|
+
|
|
65
|
+
## 0.1.0
|
|
66
|
+
|
|
67
|
+
First public release.
|
package/README.md
CHANGED
|
@@ -38,19 +38,20 @@ and `signal`, including both balance overloads.
|
|
|
38
38
|
| `POST /v1/credits/transactions/:id/reverse` | `reverseTransaction` |
|
|
39
39
|
| `GET /v1/credits/members/:id/balance`, `/transactions` | `getBalance`, `listTransactions` |
|
|
40
40
|
| `GET /v1/credits/budget` | `getIssuanceBudget` |
|
|
41
|
-
| `GET
|
|
41
|
+
| `GET /v1/rewards/refund-policy`, `GET .../history` | `getVoucherRefundPolicy`, `listVoucherRefundPolicyHistory` |
|
|
42
42
|
| `POST/GET /v1/rewards/vouchers`, `GET/PATCH .../:id` | `createVoucher`, `listVouchers`, `getVoucher`, `updateVoucher` |
|
|
43
43
|
| `POST .../vouchers/:id/claim`, `GET .../claims/:id` | `claimVoucher`, `getVoucherClaim` |
|
|
44
44
|
| `POST .../vouchers/:id/grant` | `grantVoucher` |
|
|
45
45
|
| `POST .../vouchers/use`, `/use/finalize` | `prepareVoucherUse`, `finalizeVoucherUse` |
|
|
46
46
|
| `GET .../members/:id/vouchers` | `listMemberVouchers` |
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `GET /v1/webhooks/deliveries`, `POST .../:id/replay` | `listWebhookDeliveries`, `replayWebhookDelivery` |
|
|
47
|
+
| `GET /v1/webhooks/endpoints` | `listWebhookEndpoints` |
|
|
48
|
+
| `GET /v1/webhooks/deliveries` | `listWebhookDeliveries` |
|
|
50
49
|
|
|
51
50
|
`finalizeVoucherClaim` is an alias for the shared finalize route. Customer signatures authorize
|
|
52
|
-
finalization; no merchant credential is needed there.
|
|
53
|
-
|
|
51
|
+
finalization; no merchant credential is needed there. A `read` key is enough for every read here; a
|
|
52
|
+
`write` key for the rest. The Owner registers, disables, enables and rotates webhook endpoints, replays
|
|
53
|
+
deliveries and publishes the refund policy in the console, not with a key (removed from the SDK in
|
|
54
|
+
0.2.0, see `CHANGELOG.md`). List responses never include a webhook secret.
|
|
54
55
|
|
|
55
56
|
## Earn
|
|
56
57
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BalanceSnapshot, EarnPointsRequest, EarnPointsResponse, IssuanceBudgetDto, CreditBalanceSnapshot,
|
|
1
|
+
import type { BalanceSnapshot, EarnPointsRequest, EarnPointsResponse, IssuanceBudgetDto, CreditBalanceSnapshot, LoyaltyTransactionPage, CreateVoucherRequest, UpdateVoucherRequest, VoucherDto, ClaimVoucherRequest, ClaimVoucherResponse, FinalizePosRedemptionRequest, FinalizePosRedemptionResponse, GrantVoucherRequest, PrepareVoucherUseRequest, PrepareVoucherUseResponse, FinalizeVoucherUseRequest, RedeemVoucherResponse, VoucherOwnershipDto, ListVoucherRefundPolicyHistoryRequest, VoucherRefundPolicyDto, VerifyCustomerResponse, ReservePosRedemptionRequest, ReservePosRedemptionResponse, ReverseTransactionRequest, ReverseTransactionResponse, WebhookEndpointDto, WebhookDeliveryDto, VoucherBatchActionResponse, CreateVoucherBatchResponse, ListVoucherBatchesRequest, VoucherBatchDetailDto, VoucherBatchDto, VoucherBatchItem } from '@octap/contracts';
|
|
2
2
|
import type { Transport } from './transports/transport.js';
|
|
3
3
|
export interface RequestOptions {
|
|
4
4
|
organizationId?: string;
|
|
@@ -43,16 +43,19 @@ export declare class OctaPointClient {
|
|
|
43
43
|
finalizePosRedemption(request: FinalizePosRedemptionRequest, options?: RequestOptions): Promise<FinalizePosRedemptionResponse>;
|
|
44
44
|
reverseTransaction(request: ReverseTransactionRequest, options?: RequestOptions): Promise<ReverseTransactionResponse>;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* One page of a member's loyalty transactions, newest first. `limit` 1–100 (default 25). Pass the
|
|
47
|
+
* returned `nextCursor` as `cursor` for the next page; it is `null` on the last page.
|
|
47
48
|
*/
|
|
48
49
|
listTransactions(memberId: string, options?: RequestOptions & {
|
|
49
50
|
limit?: number;
|
|
50
|
-
|
|
51
|
+
cursor?: string;
|
|
52
|
+
}): Promise<LoyaltyTransactionPage>;
|
|
51
53
|
/** The policy the next published voucher takes. A published voucher keeps the one it was published with. */
|
|
52
54
|
getVoucherRefundPolicy(options?: RequestOptions): Promise<VoucherRefundPolicyDto>;
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Lists immutable policy versions, newest first. The Owner publishes a new version from the console;
|
|
57
|
+
* no API key can.
|
|
58
|
+
*/
|
|
56
59
|
listVoucherRefundPolicyHistory(query?: ListVoucherRefundPolicyHistoryRequest, options?: RequestOptions): Promise<VoucherRefundPolicyDto[]>;
|
|
57
60
|
/**
|
|
58
61
|
* Create a new voucher definition. A `code` already used in your organization is a 409: if a create
|
|
@@ -70,6 +73,45 @@ export declare class OctaPointClient {
|
|
|
70
73
|
* Get a specific voucher by its ID.
|
|
71
74
|
*/
|
|
72
75
|
getVoucher(voucherId: string, options?: RequestOptions): Promise<VoucherDto>;
|
|
76
|
+
/**
|
|
77
|
+
* Creates up to `VOUCHER_BATCH_MAX_ITEMS` vouchers as one DRAFT batch (OCT-303). Each item is
|
|
78
|
+
* checked and written on its own, and `items[i]` of the response says what happened to `items[i]`:
|
|
79
|
+
* `created`, `unchanged` (already there with the same values, so sending the same list again is
|
|
80
|
+
* safe), `conflict` (that `code` holds other values and is kept), `replaced` (a draft of an archived
|
|
81
|
+
* batch now holds these values) or `error`. With `dryRun`, nothing is written: use it to preview.
|
|
82
|
+
* Nothing goes live until `activateVoucherBatch`. `name` labels the batch (up to 120 characters).
|
|
83
|
+
*/
|
|
84
|
+
createVouchers(items: VoucherBatchItem[], batchOptions?: {
|
|
85
|
+
dryRun?: boolean;
|
|
86
|
+
name?: string;
|
|
87
|
+
}, options?: RequestOptions): Promise<CreateVoucherBatchResponse>;
|
|
88
|
+
/** Batches, newest first; archived ones only with `includeArchived`. */
|
|
89
|
+
listVoucherBatches(query?: ListVoucherBatchesRequest, options?: RequestOptions): Promise<VoucherBatchDto[]>;
|
|
90
|
+
/** A batch with its vouchers. */
|
|
91
|
+
getVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchDetailDto>;
|
|
92
|
+
/**
|
|
93
|
+
* Activates every DRAFT voucher of the batch: each one starts publishing on-chain, or waits for an
|
|
94
|
+
* Owner when the organization requires approval. A voucher that can't go live stays DRAFT, with a
|
|
95
|
+
* `reason`; one already published or waiting is `skipped`, so calling it again is safe. Publishing
|
|
96
|
+
* is done by a worker a few vouchers at a time, so a large batch takes minutes to be fully live.
|
|
97
|
+
*/
|
|
98
|
+
activateVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Pauses every voucher of the batch that is on-chain: members can't claim them any more, and the
|
|
101
|
+
* vouchers they hold stay usable. Drafts and vouchers waiting for approval are `skipped`. Archiving
|
|
102
|
+
* a batch doesn't stop claims; this does.
|
|
103
|
+
*/
|
|
104
|
+
pauseVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
|
|
105
|
+
/** Resumes every paused voucher of the batch that is published. Resuming needs no approval. */
|
|
106
|
+
resumeVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* For a batch you won't use (a wrong file, a cancelled campaign). The batch is hidden and can't be
|
|
109
|
+
* activated again, and each of its vouchers that never went live becomes `ARCHIVED` (one waiting
|
|
110
|
+
* for approval is withdrawn): it can't be edited or go live any more. Live vouchers stay live;
|
|
111
|
+
* pause the batch to stop claims. Importing an archived voucher's code again brings it back as a
|
|
112
|
+
* DRAFT in the new batch. There is no un-archive.
|
|
113
|
+
*/
|
|
114
|
+
archiveVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
|
|
73
115
|
/**
|
|
74
116
|
* Reserve a voucher; paid claims return customer-signable bytes and remain RESERVED until chain confirmation.
|
|
75
117
|
*/
|
|
@@ -94,13 +136,13 @@ export declare class OctaPointClient {
|
|
|
94
136
|
* List all vouchers claimed/owned by a member.
|
|
95
137
|
*/
|
|
96
138
|
listMemberVouchers(memberId: string, options?: RequestOptions): Promise<VoucherOwnershipDto[]>;
|
|
97
|
-
|
|
139
|
+
/**
|
|
140
|
+
* The organization's webhook endpoints, without their secrets. The Owner registers, disables,
|
|
141
|
+
* enables and rotates them from the console; no API key can.
|
|
142
|
+
*/
|
|
98
143
|
listWebhookEndpoints(options?: RequestOptions): Promise<WebhookEndpointDto[]>;
|
|
99
|
-
|
|
100
|
-
enableWebhookEndpoint(id: string, options?: RequestOptions): Promise<WebhookEndpointDto>;
|
|
101
|
-
rotateWebhookSecret(id: string, options?: RequestOptions): Promise<WebhookEndpointWithSecretDto>;
|
|
144
|
+
/** Recent deliveries, newest first. The Owner replays a dead-lettered one from the console. */
|
|
102
145
|
listWebhookDeliveries(options?: RequestOptions): Promise<WebhookDeliveryDto[]>;
|
|
103
|
-
replayWebhookDelivery(id: string, options?: RequestOptions): Promise<WebhookDeliveryDto>;
|
|
104
146
|
}
|
|
105
147
|
/**
|
|
106
148
|
* Convenience factory to instantiate the client.
|
package/dist/client.js
CHANGED
|
@@ -135,10 +135,11 @@ export class OctaPointClient {
|
|
|
135
135
|
return this.request(`/v1/credits/transactions/${encodeURIComponent(transactionId)}/reverse`, 'POST', body, options);
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
138
|
+
* One page of a member's loyalty transactions, newest first. `limit` 1–100 (default 25). Pass the
|
|
139
|
+
* returned `nextCursor` as `cursor` for the next page; it is `null` on the last page.
|
|
139
140
|
*/
|
|
140
141
|
async listTransactions(memberId, options) {
|
|
141
|
-
return this.request(`/v1/credits/members/${encodeURIComponent(memberId)}/transactions`, 'GET', undefined, options, { limit: options?.limit });
|
|
142
|
+
return this.request(`/v1/credits/members/${encodeURIComponent(memberId)}/transactions`, 'GET', undefined, options, { limit: options?.limit, cursor: options?.cursor });
|
|
142
143
|
}
|
|
143
144
|
// ==========================================
|
|
144
145
|
// REWARDS & VOUCHERS API
|
|
@@ -147,11 +148,10 @@ export class OctaPointClient {
|
|
|
147
148
|
async getVoucherRefundPolicy(options) {
|
|
148
149
|
return this.request('/v1/rewards/refund-policy', 'GET', undefined, options);
|
|
149
150
|
}
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
/** Lists immutable policy versions, newest first; requires an admin-scoped credential. */
|
|
151
|
+
/**
|
|
152
|
+
* Lists immutable policy versions, newest first. The Owner publishes a new version from the console;
|
|
153
|
+
* no API key can.
|
|
154
|
+
*/
|
|
155
155
|
async listVoucherRefundPolicyHistory(query = {}, options) {
|
|
156
156
|
return this.request('/v1/rewards/refund-policy/history', 'GET', undefined, options, {
|
|
157
157
|
limit: query.limit,
|
|
@@ -182,6 +182,62 @@ export class OctaPointClient {
|
|
|
182
182
|
async getVoucher(voucherId, options) {
|
|
183
183
|
return this.request(`/v1/rewards/vouchers/${encodeURIComponent(voucherId)}`, 'GET', undefined, options);
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Creates up to `VOUCHER_BATCH_MAX_ITEMS` vouchers as one DRAFT batch (OCT-303). Each item is
|
|
187
|
+
* checked and written on its own, and `items[i]` of the response says what happened to `items[i]`:
|
|
188
|
+
* `created`, `unchanged` (already there with the same values, so sending the same list again is
|
|
189
|
+
* safe), `conflict` (that `code` holds other values and is kept), `replaced` (a draft of an archived
|
|
190
|
+
* batch now holds these values) or `error`. With `dryRun`, nothing is written: use it to preview.
|
|
191
|
+
* Nothing goes live until `activateVoucherBatch`. `name` labels the batch (up to 120 characters).
|
|
192
|
+
*/
|
|
193
|
+
async createVouchers(items, batchOptions = {}, options) {
|
|
194
|
+
return this.request('/v1/rewards/voucher-batches', 'POST', {
|
|
195
|
+
items,
|
|
196
|
+
...(batchOptions.dryRun !== undefined ? { dryRun: batchOptions.dryRun } : {}),
|
|
197
|
+
...(batchOptions.name !== undefined ? { name: batchOptions.name } : {}),
|
|
198
|
+
}, options);
|
|
199
|
+
}
|
|
200
|
+
/** Batches, newest first; archived ones only with `includeArchived`. */
|
|
201
|
+
async listVoucherBatches(query = {}, options) {
|
|
202
|
+
return this.request('/v1/rewards/voucher-batches', 'GET', undefined, options, {
|
|
203
|
+
includeArchived: query.includeArchived === undefined ? undefined : String(query.includeArchived),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/** A batch with its vouchers. */
|
|
207
|
+
async getVoucherBatch(batchId, options) {
|
|
208
|
+
return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}`, 'GET', undefined, options);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Activates every DRAFT voucher of the batch: each one starts publishing on-chain, or waits for an
|
|
212
|
+
* Owner when the organization requires approval. A voucher that can't go live stays DRAFT, with a
|
|
213
|
+
* `reason`; one already published or waiting is `skipped`, so calling it again is safe. Publishing
|
|
214
|
+
* is done by a worker a few vouchers at a time, so a large batch takes minutes to be fully live.
|
|
215
|
+
*/
|
|
216
|
+
async activateVoucherBatch(batchId, options) {
|
|
217
|
+
return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/activate`, 'POST', undefined, options);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Pauses every voucher of the batch that is on-chain: members can't claim them any more, and the
|
|
221
|
+
* vouchers they hold stay usable. Drafts and vouchers waiting for approval are `skipped`. Archiving
|
|
222
|
+
* a batch doesn't stop claims; this does.
|
|
223
|
+
*/
|
|
224
|
+
async pauseVoucherBatch(batchId, options) {
|
|
225
|
+
return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/pause`, 'POST', undefined, options);
|
|
226
|
+
}
|
|
227
|
+
/** Resumes every paused voucher of the batch that is published. Resuming needs no approval. */
|
|
228
|
+
async resumeVoucherBatch(batchId, options) {
|
|
229
|
+
return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/resume`, 'POST', undefined, options);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* For a batch you won't use (a wrong file, a cancelled campaign). The batch is hidden and can't be
|
|
233
|
+
* activated again, and each of its vouchers that never went live becomes `ARCHIVED` (one waiting
|
|
234
|
+
* for approval is withdrawn): it can't be edited or go live any more. Live vouchers stay live;
|
|
235
|
+
* pause the batch to stop claims. Importing an archived voucher's code again brings it back as a
|
|
236
|
+
* DRAFT in the new batch. There is no un-archive.
|
|
237
|
+
*/
|
|
238
|
+
async archiveVoucherBatch(batchId, options) {
|
|
239
|
+
return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/archive`, 'POST', undefined, options);
|
|
240
|
+
}
|
|
185
241
|
/**
|
|
186
242
|
* Reserve a voucher; paid claims return customer-signable bytes and remain RESERVED until chain confirmation.
|
|
187
243
|
*/
|
|
@@ -220,27 +276,17 @@ export class OctaPointClient {
|
|
|
220
276
|
async listMemberVouchers(memberId, options) {
|
|
221
277
|
return this.request(`/v1/rewards/members/${encodeURIComponent(memberId)}/vouchers`, 'GET', undefined, options);
|
|
222
278
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
279
|
+
/**
|
|
280
|
+
* The organization's webhook endpoints, without their secrets. The Owner registers, disables,
|
|
281
|
+
* enables and rotates them from the console; no API key can.
|
|
282
|
+
*/
|
|
226
283
|
async listWebhookEndpoints(options) {
|
|
227
284
|
return this.request('/v1/webhooks/endpoints', 'GET', undefined, options);
|
|
228
285
|
}
|
|
229
|
-
|
|
230
|
-
return this.request(`/v1/webhooks/endpoints/${encodeURIComponent(id)}/disable`, 'POST', undefined, options);
|
|
231
|
-
}
|
|
232
|
-
async enableWebhookEndpoint(id, options) {
|
|
233
|
-
return this.request(`/v1/webhooks/endpoints/${encodeURIComponent(id)}/enable`, 'POST', undefined, options);
|
|
234
|
-
}
|
|
235
|
-
async rotateWebhookSecret(id, options) {
|
|
236
|
-
return this.request(`/v1/webhooks/endpoints/${encodeURIComponent(id)}/rotate-secret`, 'POST', undefined, options);
|
|
237
|
-
}
|
|
286
|
+
/** Recent deliveries, newest first. The Owner replays a dead-lettered one from the console. */
|
|
238
287
|
async listWebhookDeliveries(options) {
|
|
239
288
|
return this.request('/v1/webhooks/deliveries', 'GET', undefined, options);
|
|
240
289
|
}
|
|
241
|
-
async replayWebhookDelivery(id, options) {
|
|
242
|
-
return this.request(`/v1/webhooks/deliveries/${encodeURIComponent(id)}/replay`, 'POST', undefined, options);
|
|
243
|
-
}
|
|
244
290
|
}
|
|
245
291
|
/**
|
|
246
292
|
* Convenience factory to instantiate the client.
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE1G,SAAS,gBAAgB,CAAC,GAAY,EAAE,MAAoB;IAC1D,OAAO,MAAM,EAAE,OAAO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Q,EAC7D,MAAM,EACN,OAAO,EACP,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CACrB,OAAiC,EACjC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAA4B,0BAA0B,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvG,CAAC;IAED,wGAAwG;IACxG,KAAK,CAAC,kBAAkB,CACtB,OAAkC,EAClC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAwB,mCAAmC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5G,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CAAC,QAAgB,EAAE,OAAwB;QACjE,OAAO,IAAI,CAAC,OAAO,CACjB,uBAAuB,kBAAkB,CAAC,QAAQ,CAAC,WAAW,EAC9D,KAAK,EACL,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,oBAAoB,CAAC,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED,+FAA+F;IAC/F,KAAK,CAAC,qBAAqB,CAAC,OAAwB;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkC,EAAE;IACxE,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { OctaPointClient, createOctaPointClient, type OctaPointClientOptions, type RequestOptions } from './client.js';
|
|
2
2
|
export { OctaSdkError, OctaApiError, OctaNetworkError, OctaRequestAbortedError } from './errors/index.js';
|
|
3
3
|
export { verifyWebhookSignature, constructWebhookEvent } from './webhooks.js';
|
|
4
|
+
export { parseVoucherCsv, suggestVoucherCode, VOUCHER_BENEFIT_SCHEMA, VOUCHER_CSV_TEMPLATE, VOUCHER_CSV_TYPES, type ParsedVoucherCsv, type ParseVoucherCsvOptions, type VoucherBenefitKind, type VoucherCsvRow, } from './voucher-csv.js';
|
|
4
5
|
export type { Transport, RestTransport } from './transports/transport.js';
|
|
5
|
-
export type { Points, BalanceSnapshot, LoyaltyTxType, LoyaltyTxStatus, EarnPointsRequest, EarnPointsResponse, IssuanceBudgetDto, IssuanceBudgetShard, IssuanceBudgetTopUp, BudgetWarningThreshold, PosRedemptionBenefit, ReservePosRedemptionRequest, ReservePosRedemptionResponse, FinalizePosRedemptionRequest, FinalizePosRedemptionResponse, ReverseTransactionRequest, ReverseTransactionResponse, CreditBalanceSnapshot, LoyaltyTransactionDto, VoucherRefundPolicy, VoucherRefundPolicySnapshot, SetVoucherRefundPolicyRequest, ListVoucherRefundPolicyHistoryRequest, VoucherRefundPolicyDto, VoucherStatus, VoucherOwnershipStatus, DiscountType, CreateVoucherRequest, UpdateVoucherRequest, VoucherDto, ClaimVoucherRequest, ClaimVoucherResponse, GrantVoucherRequest, PrepareVoucherUseRequest, PrepareVoucherUseResponse, FinalizeVoucherUseRequest, RedeemVoucherResponse, VoucherOwnershipDto, WebhookEndpointStatus, WebhookDeliveryStatus, WebhookEndpointDto, WebhookEndpointWithSecretDto, RegisterWebhookEndpointRequest, WebhookDeliveryDto, WebhookEventType, WebhookEvent, CreditsEarnedEventData, CreditsChainConfirmedEventData, CreditsEarnFailedEventData, EarnFailureCode, BudgetLowEventData, } from '@octap/contracts';
|
|
6
|
+
export type { Points, BalanceSnapshot, LoyaltyTxType, LoyaltyTxStatus, EarnPointsRequest, EarnPointsResponse, IssuanceBudgetDto, IssuanceBudgetShard, IssuanceBudgetTopUp, BudgetWarningThreshold, PosRedemptionBenefit, ReservePosRedemptionRequest, ReservePosRedemptionResponse, FinalizePosRedemptionRequest, FinalizePosRedemptionResponse, ReverseTransactionRequest, ReverseTransactionResponse, CreditBalanceSnapshot, LoyaltyTransactionDto, LoyaltyTransactionPage, VoucherRefundPolicy, VoucherRefundPolicySnapshot, SetVoucherRefundPolicyRequest, ListVoucherRefundPolicyHistoryRequest, VoucherRefundPolicyDto, VoucherStatus, VoucherOwnershipStatus, DiscountType, CreateVoucherRequest, UpdateVoucherRequest, VoucherDto, ClaimVoucherRequest, ClaimVoucherResponse, GrantVoucherRequest, PrepareVoucherUseRequest, PrepareVoucherUseResponse, FinalizeVoucherUseRequest, RedeemVoucherResponse, VoucherOwnershipDto, VoucherBatchSource, VoucherBatchItem, CreateVoucherBatchRequest, CreateVoucherBatchResponse, VoucherBatchItemErrorCode, VoucherBatchItemResult, VoucherFieldDifference, VoucherBatchDto, VoucherBatchStatusCounts, VoucherBatchDetailDto, ListVoucherBatchesRequest, VoucherBatchOutcome, VoucherBatchActivationOutcome, VoucherBatchActionResult, VoucherBatchActionResponse, WebhookEndpointStatus, WebhookDeliveryStatus, WebhookEndpointDto, WebhookEndpointWithSecretDto, RegisterWebhookEndpointRequest, WebhookDeliveryDto, WebhookEventType, WebhookEvent, CreditsEarnedEventData, CreditsChainConfirmedEventData, CreditsEarnFailedEventData, EarnFailureCode, BudgetLowEventData, } from '@octap/contracts';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { OctaPointClient, createOctaPointClient } from './client.js';
|
|
2
2
|
export { OctaSdkError, OctaApiError, OctaNetworkError, OctaRequestAbortedError } from './errors/index.js';
|
|
3
3
|
export { verifyWebhookSignature, constructWebhookEvent } from './webhooks.js';
|
|
4
|
+
export { parseVoucherCsv, suggestVoucherCode, VOUCHER_BENEFIT_SCHEMA, VOUCHER_CSV_TEMPLATE, VOUCHER_CSV_TYPES, } from './voucher-csv.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAoD,MAAM,aAAa,CAAC;AAEvH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAoD,MAAM,aAAa,CAAC;AAEvH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,GAKlB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type VoucherBatchItem } from '@octap/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the Octap voucher CSV template, the same file the console imports, into items for
|
|
4
|
+
* `createVouchers`. It makes the same checks as the console: a row it can't read, that breaks a
|
|
5
|
+
* rule, or that repeats an earlier row's code is reported with a `problem` and left out of `items`.
|
|
6
|
+
* Core still checks every item when it is sent.
|
|
7
|
+
*/
|
|
8
|
+
/** Marks `terms` written in this shape, so the console and any reader know which fields to expect. */
|
|
9
|
+
export declare const VOUCHER_BENEFIT_SCHEMA = "octap.benefit.v1";
|
|
10
|
+
/** The reward kinds of the template, as `terms.kind`. */
|
|
11
|
+
export type VoucherBenefitKind = 'PERCENT_OFF' | 'AMOUNT_OFF' | 'FREE_ITEM' | 'BUY_X_GET_Y' | 'FREE_SHIPPING' | 'FIXED_PRICE' | 'CUSTOM';
|
|
12
|
+
/** The `type` column's values, one per kind. */
|
|
13
|
+
export declare const VOUCHER_CSV_TYPES: readonly ["percent_off", "amount_off", "free_item", "buy_x_get_y", "free_shipping", "fixed_price", "custom"];
|
|
14
|
+
/** The template with one example row per kind, the same as the console's download. */
|
|
15
|
+
export declare const VOUCHER_CSV_TEMPLATE: string;
|
|
16
|
+
/** One row of the file: the item sent to Core, or why it was left out. */
|
|
17
|
+
export interface VoucherCsvRow {
|
|
18
|
+
/** The row's line in the file; the header is line 1. */
|
|
19
|
+
line: number;
|
|
20
|
+
/** The row's code (made from its title when the cell is empty); `null` when it has none. */
|
|
21
|
+
code: string | null;
|
|
22
|
+
/** Set when the row passed every check. */
|
|
23
|
+
item?: VoucherBatchItem;
|
|
24
|
+
/** Why the row was left out, naming the CSV column: `points_cost: Enter a whole number…`. */
|
|
25
|
+
problem?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ParsedVoucherCsv {
|
|
28
|
+
/**
|
|
29
|
+
* The rows that passed, in file order, ready for `createVouchers`. `items[i]` is the item of
|
|
30
|
+
* `rows.filter((row) => row.item)[i]`, so a result's `index` leads back to its line.
|
|
31
|
+
*/
|
|
32
|
+
items: VoucherBatchItem[];
|
|
33
|
+
/** Every row of the file, with its item or its problem. */
|
|
34
|
+
rows: VoucherCsvRow[];
|
|
35
|
+
/** Set when the whole file is refused (empty, a required column missing, too many rows). */
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ParseVoucherCsvOptions {
|
|
39
|
+
/**
|
|
40
|
+
* The UTC offset dates are read in: `claims_open_on` starts at 00:00:00 and `claims_close_on` ends
|
|
41
|
+
* at 23:59:59 of that day there. Defaults to `+07:00` (Vietnam). `Z` is UTC.
|
|
42
|
+
*/
|
|
43
|
+
utcOffset?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reads a CSV in the Octap voucher template into items for `createVouchers`.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* const { items, rows, error } = parseVoucherCsv(await readFile('rewards.csv', 'utf8'));
|
|
50
|
+
* if (error) throw new Error(error);
|
|
51
|
+
* for (const row of rows) if (row.problem) console.warn(`line ${row.line}: ${row.problem}`);
|
|
52
|
+
* const preview = await client.createVouchers(items, { dryRun: true });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseVoucherCsv(text: string, options?: ParseVoucherCsvOptions): ParsedVoucherCsv;
|
|
56
|
+
/** `Trà sữa trân châu!` → `TRA-SUA-TRAN-CHAU`, as the console makes a code from a title. */
|
|
57
|
+
export declare function suggestVoucherCode(title: string): string;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { VOUCHER_BATCH_MAX_ITEMS, VOUCHER_MAX_VALID_FOR_DAYS } from '@octap/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the Octap voucher CSV template, the same file the console imports, into items for
|
|
4
|
+
* `createVouchers`. It makes the same checks as the console: a row it can't read, that breaks a
|
|
5
|
+
* rule, or that repeats an earlier row's code is reported with a `problem` and left out of `items`.
|
|
6
|
+
* Core still checks every item when it is sent.
|
|
7
|
+
*/
|
|
8
|
+
/** Marks `terms` written in this shape, so the console and any reader know which fields to expect. */
|
|
9
|
+
export const VOUCHER_BENEFIT_SCHEMA = 'octap.benefit.v1';
|
|
10
|
+
/** The `type` column's values, one per kind. */
|
|
11
|
+
export const VOUCHER_CSV_TYPES = [
|
|
12
|
+
'percent_off',
|
|
13
|
+
'amount_off',
|
|
14
|
+
'free_item',
|
|
15
|
+
'buy_x_get_y',
|
|
16
|
+
'free_shipping',
|
|
17
|
+
'fixed_price',
|
|
18
|
+
'custom',
|
|
19
|
+
];
|
|
20
|
+
const COLUMNS = [
|
|
21
|
+
'type',
|
|
22
|
+
'title',
|
|
23
|
+
'code',
|
|
24
|
+
'points_cost',
|
|
25
|
+
'value',
|
|
26
|
+
'max_discount_vnd',
|
|
27
|
+
'min_order_vnd',
|
|
28
|
+
'item',
|
|
29
|
+
'buy_quantity',
|
|
30
|
+
'get_quantity',
|
|
31
|
+
'price_vnd',
|
|
32
|
+
'benefit',
|
|
33
|
+
'applies_to',
|
|
34
|
+
'total_supply',
|
|
35
|
+
'per_member_limit',
|
|
36
|
+
'claims_open_on',
|
|
37
|
+
'claims_close_on',
|
|
38
|
+
'valid_for_days',
|
|
39
|
+
'description',
|
|
40
|
+
];
|
|
41
|
+
/** Headers of earlier templates, still read so an old file keeps working. */
|
|
42
|
+
const LEGACY_HEADERS = { starts_on: 'claims_open_on', expires_on: 'claims_close_on' };
|
|
43
|
+
const KIND_ALIASES = {
|
|
44
|
+
percent_off: 'PERCENT_OFF',
|
|
45
|
+
percent: 'PERCENT_OFF',
|
|
46
|
+
amount_off: 'AMOUNT_OFF',
|
|
47
|
+
amount: 'AMOUNT_OFF',
|
|
48
|
+
free_item: 'FREE_ITEM',
|
|
49
|
+
buy_x_get_y: 'BUY_X_GET_Y',
|
|
50
|
+
free_shipping: 'FREE_SHIPPING',
|
|
51
|
+
free_delivery: 'FREE_SHIPPING',
|
|
52
|
+
fixed_price: 'FIXED_PRICE',
|
|
53
|
+
special_price: 'FIXED_PRICE',
|
|
54
|
+
custom: 'CUSTOM',
|
|
55
|
+
};
|
|
56
|
+
/** The template with one example row per kind, the same as the console's download. */
|
|
57
|
+
export const VOUCHER_CSV_TEMPLATE = [
|
|
58
|
+
COLUMNS.join(','),
|
|
59
|
+
'percent_off,20% off drinks,DRINKS-20,300,20,50000,200000,,,,,,Drinks only,100,1,,2027-12-31,14,',
|
|
60
|
+
'amount_off,30000 off,SAVE-30K,400,30000,,150000,,,,,,,,3,,2027-12-31,30,',
|
|
61
|
+
'free_item,A free latte,FREE-LATTE,500,,,,"Latte, size M",,,,,,50,,,2027-12-31,30,',
|
|
62
|
+
'buy_x_get_y,Buy 1 get 1 tea,B1G1-TEA,600,,,,Milk tea,1,1,,,,,1,,2027-12-31,,',
|
|
63
|
+
'free_shipping,Free delivery,FREE-SHIP,200,,20000,100000,,,,,,,,,,2027-12-31,,',
|
|
64
|
+
'fixed_price,Combo 99k,COMBO-99K,350,,,,Burger and drink,,,99000,,,,,,2027-12-31,7,',
|
|
65
|
+
'custom,Spa afternoon,SPA-PASS,2000,,,,,,,,One 60-minute treatment,,10,1,,2027-12-31,,Book 2 days ahead',
|
|
66
|
+
].join('\n');
|
|
67
|
+
/**
|
|
68
|
+
* Reads a CSV in the Octap voucher template into items for `createVouchers`.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const { items, rows, error } = parseVoucherCsv(await readFile('rewards.csv', 'utf8'));
|
|
72
|
+
* if (error) throw new Error(error);
|
|
73
|
+
* for (const row of rows) if (row.problem) console.warn(`line ${row.line}: ${row.problem}`);
|
|
74
|
+
* const preview = await client.createVouchers(items, { dryRun: true });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export function parseVoucherCsv(text, options = {}) {
|
|
78
|
+
const offset = options.utcOffset ?? '+07:00';
|
|
79
|
+
if (!/^(Z|[+-](0\d|1[0-4]):[0-5]\d)$/.test(offset))
|
|
80
|
+
throw new TypeError(`utcOffset must look like +07:00, -05:00 or Z; got "${offset}"`);
|
|
81
|
+
const [header, ...body] = parseCsv(text);
|
|
82
|
+
if (!header)
|
|
83
|
+
return { items: [], rows: [], error: 'The file is empty.' };
|
|
84
|
+
const index = header.map((h) => {
|
|
85
|
+
const name = h.trim().toLowerCase();
|
|
86
|
+
return LEGACY_HEADERS[name] ?? name;
|
|
87
|
+
});
|
|
88
|
+
const missing = ['type', 'title', 'points_cost'].filter((h) => !index.includes(h));
|
|
89
|
+
if (missing.length)
|
|
90
|
+
return { items: [], rows: [], error: `Missing column(s): ${missing.join(', ')}. Use the template.` };
|
|
91
|
+
if (body.length > VOUCHER_BATCH_MAX_ITEMS)
|
|
92
|
+
return {
|
|
93
|
+
items: [],
|
|
94
|
+
rows: [],
|
|
95
|
+
error: `At most ${VOUCHER_BATCH_MAX_ITEMS} vouchers per file; this one has ${body.length}.`,
|
|
96
|
+
};
|
|
97
|
+
const seen = new Map();
|
|
98
|
+
const rows = body.map((cells, i) => {
|
|
99
|
+
const line = i + 2;
|
|
100
|
+
const cell = (column) => {
|
|
101
|
+
const at = index.indexOf(column);
|
|
102
|
+
return at < 0 ? '' : (cells[at] ?? '').trim();
|
|
103
|
+
};
|
|
104
|
+
const row = readRow(cell, offset);
|
|
105
|
+
const code = row.item?.code ?? (row.code || null);
|
|
106
|
+
const problems = [...row.problems];
|
|
107
|
+
const earlier = code ? seen.get(code) : undefined;
|
|
108
|
+
if (code && earlier && !problems.length)
|
|
109
|
+
problems.push(`code: ${code} is already used by line ${earlier}`);
|
|
110
|
+
// Only a row that is sent takes its code: a corrected copy of a bad row is not a repeat.
|
|
111
|
+
if (code && !earlier && !problems.length)
|
|
112
|
+
seen.set(code, line);
|
|
113
|
+
return problems.length || !row.item
|
|
114
|
+
? { line, code, problem: problems.join('; ') || 'This row could not be read' }
|
|
115
|
+
: { line, code, item: row.item };
|
|
116
|
+
});
|
|
117
|
+
return { items: rows.flatMap((row) => (row.item ? [row.item] : [])), rows };
|
|
118
|
+
}
|
|
119
|
+
const CODE_PATTERN = /^[A-Za-z0-9_-]{1,80}$/;
|
|
120
|
+
const whole = (value) => /^\d+$/.test(value);
|
|
121
|
+
const positiveAmount = (value) => /^\d{1,10}(\.\d{1,2})?$/.test(value) && Number(value) > 0;
|
|
122
|
+
/** `Trà sữa trân châu!` → `TRA-SUA-TRAN-CHAU`, as the console makes a code from a title. */
|
|
123
|
+
export function suggestVoucherCode(title) {
|
|
124
|
+
return title
|
|
125
|
+
.normalize('NFD')
|
|
126
|
+
.replace(/[̀-ͯ]/g, '')
|
|
127
|
+
.replace(/[đĐ]/g, 'D')
|
|
128
|
+
.toUpperCase()
|
|
129
|
+
.replace(/[^A-Z0-9]+/g, '-')
|
|
130
|
+
.replace(/^-+|-+$/g, '')
|
|
131
|
+
.slice(0, 40)
|
|
132
|
+
.replace(/-+$/g, '');
|
|
133
|
+
}
|
|
134
|
+
/** One row's checks, and its item when they all pass. Mirrors the console's form. */
|
|
135
|
+
function readRow(cell, offset) {
|
|
136
|
+
const problems = [];
|
|
137
|
+
const fail = (column, message) => problems.push(`${column}: ${message}`);
|
|
138
|
+
const typeCell = cell('type').toLowerCase();
|
|
139
|
+
const kind = KIND_ALIASES[typeCell] ?? KIND_ALIASES[typeCell.replace(/\s+/g, '_')];
|
|
140
|
+
if (!kind)
|
|
141
|
+
problems.push(`Unknown type "${cell('type')}"`);
|
|
142
|
+
const title = cell('title');
|
|
143
|
+
const code = cell('code') || suggestVoucherCode(title);
|
|
144
|
+
if (!title)
|
|
145
|
+
fail('title', 'Enter a title');
|
|
146
|
+
else if (title.length > 200)
|
|
147
|
+
fail('title', 'At most 200 characters');
|
|
148
|
+
if (!CODE_PATTERN.test(code))
|
|
149
|
+
fail('code', 'Letters, numbers, - and _ only (at most 80)');
|
|
150
|
+
const points = cell('points_cost');
|
|
151
|
+
if (!whole(points))
|
|
152
|
+
fail('points_cost', 'Enter a whole number of points (0 for free)');
|
|
153
|
+
const positiveWhole = (column, message) => {
|
|
154
|
+
const value = cell(column);
|
|
155
|
+
if (!value)
|
|
156
|
+
return null;
|
|
157
|
+
if (!(whole(value) && Number(value) > 0))
|
|
158
|
+
fail(column, message);
|
|
159
|
+
return Number(value);
|
|
160
|
+
};
|
|
161
|
+
const totalSupply = positiveWhole('total_supply', 'Enter a positive whole number, or leave empty for unlimited');
|
|
162
|
+
const perMemberLimit = positiveWhole('per_member_limit', 'Enter a positive whole number, or leave empty for no limit');
|
|
163
|
+
const days = cell('valid_for_days');
|
|
164
|
+
if (days && !(whole(days) && Number(days) >= 1 && Number(days) <= VOUCHER_MAX_VALID_FOR_DAYS))
|
|
165
|
+
fail('valid_for_days', `Enter a whole number of days from 1 to ${VOUCHER_MAX_VALID_FOR_DAYS}`);
|
|
166
|
+
const date = (column) => {
|
|
167
|
+
const value = cell(column);
|
|
168
|
+
if (!value)
|
|
169
|
+
return '';
|
|
170
|
+
const read = csvDate(value);
|
|
171
|
+
if ('problem' in read) {
|
|
172
|
+
fail(column, read.problem);
|
|
173
|
+
return '';
|
|
174
|
+
}
|
|
175
|
+
return read.day;
|
|
176
|
+
};
|
|
177
|
+
const opens = date('claims_open_on');
|
|
178
|
+
const closes = date('claims_close_on');
|
|
179
|
+
if (opens && closes && opens > closes)
|
|
180
|
+
fail('claims_close_on', 'Must be on or after the opening date');
|
|
181
|
+
const vnd = (column) => {
|
|
182
|
+
const value = cell(column);
|
|
183
|
+
if (value && !whole(value))
|
|
184
|
+
fail(column, 'Enter an amount in VND');
|
|
185
|
+
return value;
|
|
186
|
+
};
|
|
187
|
+
const minOrder = vnd('min_order_vnd');
|
|
188
|
+
const terms = { schema: VOUCHER_BENEFIT_SCHEMA, kind: kind ?? 'CUSTOM' };
|
|
189
|
+
const setNumber = (key, value) => {
|
|
190
|
+
if (value)
|
|
191
|
+
terms[key] = Number(value);
|
|
192
|
+
};
|
|
193
|
+
setNumber('minOrderVnd', minOrder);
|
|
194
|
+
if (cell('applies_to'))
|
|
195
|
+
terms.appliesTo = cell('applies_to');
|
|
196
|
+
let discountType;
|
|
197
|
+
let discountValue;
|
|
198
|
+
const value = cell('value');
|
|
199
|
+
const item = cell('item');
|
|
200
|
+
switch (kind) {
|
|
201
|
+
case 'PERCENT_OFF':
|
|
202
|
+
if (!positiveAmount(value) || Number(value) > 100)
|
|
203
|
+
fail('value', 'Enter a percentage above 0, at most 100');
|
|
204
|
+
setNumber('maxDiscountVnd', vnd('max_discount_vnd'));
|
|
205
|
+
discountType = 'PERCENTAGE';
|
|
206
|
+
discountValue = value;
|
|
207
|
+
break;
|
|
208
|
+
case 'AMOUNT_OFF':
|
|
209
|
+
if (!positiveAmount(value))
|
|
210
|
+
fail('value', 'Enter an amount in VND');
|
|
211
|
+
discountType = 'FIXED_AMOUNT';
|
|
212
|
+
discountValue = value;
|
|
213
|
+
break;
|
|
214
|
+
case 'FREE_ITEM':
|
|
215
|
+
if (!item)
|
|
216
|
+
fail('item', 'Say which item is free');
|
|
217
|
+
terms.item = item;
|
|
218
|
+
discountType = 'FREE_ITEM';
|
|
219
|
+
break;
|
|
220
|
+
case 'BUY_X_GET_Y': {
|
|
221
|
+
const buy = cell('buy_quantity') || '1';
|
|
222
|
+
const get = cell('get_quantity') || '1';
|
|
223
|
+
if (!(whole(buy) && Number(buy) > 0))
|
|
224
|
+
fail('buy_quantity', 'At least 1');
|
|
225
|
+
if (!(whole(get) && Number(get) > 0))
|
|
226
|
+
fail('get_quantity', 'At least 1');
|
|
227
|
+
if (!item)
|
|
228
|
+
fail('item', 'Say which item it applies to');
|
|
229
|
+
terms.buyQuantity = Number(buy);
|
|
230
|
+
terms.getQuantity = Number(get);
|
|
231
|
+
terms.item = item;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case 'FREE_SHIPPING':
|
|
235
|
+
setNumber('maxDiscountVnd', vnd('max_discount_vnd'));
|
|
236
|
+
break;
|
|
237
|
+
case 'FIXED_PRICE': {
|
|
238
|
+
const price = vnd('price_vnd');
|
|
239
|
+
if (!price)
|
|
240
|
+
fail('price_vnd', 'Enter the special price');
|
|
241
|
+
if (!item)
|
|
242
|
+
fail('item', 'Say what the price is for');
|
|
243
|
+
setNumber('priceVnd', price);
|
|
244
|
+
terms.item = item;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
case 'CUSTOM':
|
|
248
|
+
if (!cell('benefit'))
|
|
249
|
+
fail('benefit', 'Describe what the customer gets');
|
|
250
|
+
terms.benefit = cell('benefit');
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
if (problems.length)
|
|
254
|
+
return { code, problems };
|
|
255
|
+
const description = cell('description');
|
|
256
|
+
return {
|
|
257
|
+
code,
|
|
258
|
+
problems,
|
|
259
|
+
item: {
|
|
260
|
+
code,
|
|
261
|
+
title,
|
|
262
|
+
...(description ? { description } : {}),
|
|
263
|
+
pointsCost: Number(points),
|
|
264
|
+
...(discountType ? { discountType } : {}),
|
|
265
|
+
...(discountValue ? { discountValue } : {}),
|
|
266
|
+
terms,
|
|
267
|
+
totalSupply,
|
|
268
|
+
perMemberLimit,
|
|
269
|
+
startsAt: opens ? new Date(`${opens}T00:00:00${offset}`).toISOString() : null,
|
|
270
|
+
expiresAt: closes ? new Date(`${closes}T23:59:59${offset}`).toISOString() : null,
|
|
271
|
+
validForDays: days ? Number(days) : null,
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* A date cell as `YYYY-MM-DD`. Excel rewrites dates in the computer's own format when it saves a
|
|
277
|
+
* CSV (`12/31/2027` on a US Mac, `31/12/2027` in Vietnam), so `D/M/YYYY` and `M/D/YYYY` are read too
|
|
278
|
+
* when only one of them is a real date. `05/02/2027` could be 5 February or 2 May: refused.
|
|
279
|
+
*/
|
|
280
|
+
function csvDate(cell) {
|
|
281
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
282
|
+
const real = (y, m, d) => {
|
|
283
|
+
const date = new Date(Date.UTC(y, m - 1, d));
|
|
284
|
+
return date.getUTCFullYear() === y && date.getUTCMonth() === m - 1 && date.getUTCDate() === d;
|
|
285
|
+
};
|
|
286
|
+
const ok = (y, m, d) => (real(y, m, d) ? { day: `${y}-${pad(m)}-${pad(d)}` } : undefined);
|
|
287
|
+
const unreadable = { problem: `"${cell}" is not a date; write it as YYYY-MM-DD, e.g. 2027-12-31` };
|
|
288
|
+
const iso = /^(\d{4})[-/.](\d{1,2})[-/.](\d{1,2})$/.exec(cell);
|
|
289
|
+
if (iso)
|
|
290
|
+
return ok(Number(iso[1]), Number(iso[2]), Number(iso[3])) ?? unreadable;
|
|
291
|
+
const local = /^(\d{1,2})[-/.](\d{1,2})[-/.](\d{4})$/.exec(cell);
|
|
292
|
+
if (!local)
|
|
293
|
+
return unreadable;
|
|
294
|
+
const [a, b, year] = [Number(local[1]), Number(local[2]), Number(local[3])];
|
|
295
|
+
const dayFirst = ok(year, b, a);
|
|
296
|
+
const monthFirst = ok(year, a, b);
|
|
297
|
+
if (dayFirst && monthFirst && a !== b)
|
|
298
|
+
return { problem: `"${cell}" could be ${dayFirst.day} or ${monthFirst.day}; write it as YYYY-MM-DD` };
|
|
299
|
+
return dayFirst ?? monthFirst ?? unreadable;
|
|
300
|
+
}
|
|
301
|
+
/** RFC 4180 CSV: quoted fields may hold commas, quotes ("") and line breaks; a UTF-8 BOM is skipped. */
|
|
302
|
+
function parseCsv(text) {
|
|
303
|
+
const rows = [];
|
|
304
|
+
let row = [];
|
|
305
|
+
let field = '';
|
|
306
|
+
let quoted = false;
|
|
307
|
+
const source = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
308
|
+
for (let i = 0; i < source.length; i += 1) {
|
|
309
|
+
const char = source[i];
|
|
310
|
+
if (quoted) {
|
|
311
|
+
if (char === '"' && source[i + 1] === '"') {
|
|
312
|
+
field += '"';
|
|
313
|
+
i += 1;
|
|
314
|
+
}
|
|
315
|
+
else if (char === '"')
|
|
316
|
+
quoted = false;
|
|
317
|
+
else
|
|
318
|
+
field += char;
|
|
319
|
+
}
|
|
320
|
+
else if (char === '"')
|
|
321
|
+
quoted = true;
|
|
322
|
+
else if (char === ',') {
|
|
323
|
+
row.push(field);
|
|
324
|
+
field = '';
|
|
325
|
+
}
|
|
326
|
+
else if (char === '\n' || char === '\r') {
|
|
327
|
+
if (char === '\r' && source[i + 1] === '\n')
|
|
328
|
+
i += 1;
|
|
329
|
+
row.push(field);
|
|
330
|
+
rows.push(row);
|
|
331
|
+
row = [];
|
|
332
|
+
field = '';
|
|
333
|
+
}
|
|
334
|
+
else
|
|
335
|
+
field += char;
|
|
336
|
+
}
|
|
337
|
+
if (field || row.length) {
|
|
338
|
+
row.push(field);
|
|
339
|
+
rows.push(row);
|
|
340
|
+
}
|
|
341
|
+
return rows.filter((r) => r.some((cell) => cell.trim()));
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=voucher-csv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voucher-csv.js","sourceRoot":"","sources":["../src/voucher-csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAyB,MAAM,kBAAkB,CAAC;AAE9G;;;;;GAKG;AAEH,sGAAsG;AACtG,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAMzD,gDAAgD;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,aAAa;IACb,YAAY;IACZ,WAAW;IACX,aAAa;IACb,eAAe;IACf,aAAa;IACb,QAAQ;CACA,CAAC;AAEX,MAAM,OAAO,GAAG;IACd,MAAM;IACN,OAAO;IACP,MAAM;IACN,aAAa;IACb,OAAO;IACP,kBAAkB;IAClB,eAAe;IACf,MAAM;IACN,cAAc;IACd,cAAc;IACd,WAAW;IACX,SAAS;IACT,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,aAAa;CACL,CAAC;AAGX,6EAA6E;AAC7E,MAAM,cAAc,GAAoC,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AAEvH,MAAM,YAAY,GAAuC;IACvD,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,YAAY;IACpB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,aAAa;IAC5B,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;IACjB,iGAA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CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octap/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Server-side Node.js SDK for the Octap Core loyalty API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@octap/contracts": "^0.
|
|
23
|
+
"@octap/contracts": "^0.2.0"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
-
"README.md"
|
|
27
|
+
"README.md",
|
|
28
|
+
"CHANGELOG.md"
|
|
28
29
|
],
|
|
29
30
|
"publishConfig": {
|
|
30
31
|
"access": "public"
|