@octap/contracts 0.3.1 → 0.3.4
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 +42 -0
- package/dist/governance.d.ts +18 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +49 -0
- package/dist/ledger.js +7 -0
- package/dist/ledger.js.map +1 -0
- package/dist/licensing.d.ts +1 -1
- package/dist/licensing.js +1 -0
- package/dist/licensing.js.map +1 -1
- package/dist/loyalty.d.ts +10 -0
- package/dist/members.d.ts +5 -0
- package/dist/membership.d.ts +160 -0
- package/dist/membership.js +4 -0
- package/dist/membership.js.map +1 -0
- package/dist/rewards.d.ts +45 -6
- package/dist/rewards.js.map +1 -1
- package/dist/webhooks.d.ts +8 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.4
|
|
4
|
+
|
|
5
|
+
Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up as is.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Several vouchers with one signature (OCT-218): `PrepareVoucherUsesRequest` (`serialCodes`, 1–5)
|
|
10
|
+
and `PrepareVoucherUsesResponse`; `VoucherUseItem`, `RedeemedVoucher` and `RedeemVouchersResponse`.
|
|
11
|
+
`PrepareVoucherUseRequest` takes an optional `orderReference`. `PrepareVoucherUseResponse` and
|
|
12
|
+
`RedeemVoucherResponse` gain `vouchers` and `orderReference`, and keep every field they had.
|
|
13
|
+
`VoucherRedeemedEventData` gains `orderReference`.
|
|
14
|
+
|
|
15
|
+
## 0.3.3
|
|
16
|
+
|
|
17
|
+
Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up as is.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- `GovernanceProposal.confirmation` (OCT-407): the organization's slug, typed by the Owner. An
|
|
22
|
+
`UPDATE_EARN_RATE` and a `PROGRAM_CAP_CHANGE` that lowers the cap now need it, and then apply
|
|
23
|
+
without review (created `APPROVED`); without it they are a 400. A cap increase still waits for a
|
|
24
|
+
System Admin. Clients that change the earn rate must send it.
|
|
25
|
+
- `ConsoleChangeRequest.appliedWithoutReview`: true for a request approved on submission (a top-up
|
|
26
|
+
within the cap, or one the Owner confirmed), so clients need not match `reviewReason`.
|
|
27
|
+
|
|
28
|
+
## 0.3.2
|
|
29
|
+
|
|
30
|
+
Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up as is.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- Ledger records (OCT-328): `LedgerRecord` (`status` `PENDING`/`CONFIRMED`/`FAILED`, `digest`,
|
|
35
|
+
`confirmedAt`), decided by OctaP rather than read off a row's own status. `LoyaltyTransactionDto`
|
|
36
|
+
and `IssuanceBudgetTopUp` gain a `ledger` field.
|
|
37
|
+
- `VoucherTermsEvidence` (the publish that froze a voucher's terms, and the object holding them) and
|
|
38
|
+
`VoucherOwnershipEvidence` (a member's voucher: issued, used, refunded, each a `LedgerRecord`).
|
|
39
|
+
- Membership levels (OCT-408). The 0.3.1 notes listed these, but the published 0.3.1 package doesn't
|
|
40
|
+
contain them; 0.3.2 is the first that does.
|
|
41
|
+
|
|
3
42
|
## 0.3.1
|
|
4
43
|
|
|
5
44
|
Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up as is.
|
|
@@ -13,3 +52,6 @@ Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up
|
|
|
13
52
|
- Platform announcements (OCT-396).
|
|
14
53
|
- Organization slug rules and availability check (OCT-367).
|
|
15
54
|
- Background CSV export types (OCT-402).
|
|
55
|
+
- Membership levels (OCT-408): settings, templates, preview, a customer's level and progress, and the
|
|
56
|
+
history of changes (`rule.reversedTransactionId` after a refund). `LicenseFeature` gains
|
|
57
|
+
`membership.levels`.
|
package/dist/governance.d.ts
CHANGED
|
@@ -24,9 +24,13 @@ export interface GovernanceProposal {
|
|
|
24
24
|
* refused with 409 otherwise (raise the cap first). One runs at a time: while the last is still
|
|
25
25
|
* being applied, or ended UNKNOWN, another is a 409. A repeat sent after the first has finished
|
|
26
26
|
* is a new top-up, still bounded by `budgetCap`.
|
|
27
|
-
* - `UPDATE_EARN_RATE`: `{ earnBps }`, 0–10000, which replaces the base earn rate
|
|
27
|
+
* - `UPDATE_EARN_RATE`: `{ earnBps }`, 0–10000, which replaces the base earn rate. Needs no review
|
|
28
|
+
* once `confirmation` holds the organization's slug: it is created `APPROVED` and queued at once.
|
|
29
|
+
* One runs at a time: while the last is still being applied, or ended UNKNOWN, another is a 409.
|
|
28
30
|
* - `PROGRAM_CAP_CHANGE`: `{ budgetCap }`, a positive whole number of points, up or down, but never
|
|
29
|
-
* below what the program is already funded with.
|
|
31
|
+
* below what the program is already funded with. No chain call. A decrease needs no review once
|
|
32
|
+
* `confirmation` holds the organization's slug, and applies at once; an increase waits for a
|
|
33
|
+
* System Admin, since the cap is what lets top-ups skip review.
|
|
30
34
|
*/
|
|
31
35
|
payload: {
|
|
32
36
|
name?: string;
|
|
@@ -37,6 +41,13 @@ export interface GovernanceProposal {
|
|
|
37
41
|
totalBudget?: number;
|
|
38
42
|
budgetCap?: number;
|
|
39
43
|
} & IdentityChangePayload;
|
|
44
|
+
/**
|
|
45
|
+
* The organization's slug, typed exactly by the Owner, for a change that applies without review: an
|
|
46
|
+
* `UPDATE_EARN_RATE` or a `PROGRAM_CAP_CHANGE` that lowers the cap. Without it such a change is a
|
|
47
|
+
* 400. It guards against a slip, not a taken-over session, so a cap increase and an ownership
|
|
48
|
+
* transfer still wait for a System Admin. Only those two request types accept it.
|
|
49
|
+
*/
|
|
50
|
+
confirmation?: string;
|
|
40
51
|
}
|
|
41
52
|
export interface GovernanceRequest {
|
|
42
53
|
id: string;
|
|
@@ -98,6 +109,11 @@ export interface ConsoleChangeRequest {
|
|
|
98
109
|
/** The System Admin's reason; null while `PENDING`. */
|
|
99
110
|
reviewReason: string | null;
|
|
100
111
|
reviewedAt: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* True for a request approved on submission, with no System Admin: a top-up within the cap, or an
|
|
114
|
+
* earn-rate change or cap decrease the Owner confirmed (OCT-407). `reviewReason` then says which.
|
|
115
|
+
*/
|
|
116
|
+
appliedWithoutReview: boolean;
|
|
101
117
|
createdAt: string;
|
|
102
118
|
/** Null for a request that queues no command, or one not approved. */
|
|
103
119
|
command: ChangeRequestCommand | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './identity.js';
|
|
|
8
8
|
export * from './system-users.js';
|
|
9
9
|
export * from './console.js';
|
|
10
10
|
export * from './members.js';
|
|
11
|
+
export * from './membership.js';
|
|
11
12
|
export * from './governance.js';
|
|
12
13
|
export * from './organizations.js';
|
|
13
14
|
export * from './organization-slugs.js';
|
|
@@ -18,6 +19,7 @@ export * from './request-logs.js';
|
|
|
18
19
|
export * from './licensing.js';
|
|
19
20
|
export * from './audit.js';
|
|
20
21
|
export * from './evidence.js';
|
|
22
|
+
export * from './ledger.js';
|
|
21
23
|
export * from './analytics.js';
|
|
22
24
|
export * from './exports.js';
|
|
23
25
|
export * from './member-insights.js';
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from './identity.js';
|
|
|
8
8
|
export * from './system-users.js';
|
|
9
9
|
export * from './console.js';
|
|
10
10
|
export * from './members.js';
|
|
11
|
+
export * from './membership.js';
|
|
11
12
|
export * from './governance.js';
|
|
12
13
|
export * from './organizations.js';
|
|
13
14
|
export * from './organization-slugs.js';
|
|
@@ -18,6 +19,7 @@ export * from './request-logs.js';
|
|
|
18
19
|
export * from './licensing.js';
|
|
19
20
|
export * from './audit.js';
|
|
20
21
|
export * from './evidence.js';
|
|
22
|
+
export * from './ledger.js';
|
|
21
23
|
export * from './analytics.js';
|
|
22
24
|
export * from './exports.js';
|
|
23
25
|
export * from './member-insights.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
package/dist/ledger.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ledger records: what OctaP wrote to the chain for one business fact, and how far that write got.
|
|
3
|
+
* The console's evidence views (OCT-328) show these instead of guessing from business statuses,
|
|
4
|
+
* which can run ahead of the chain (a refund is CONFIRMED in OctaP before its mirror lands).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* - `PENDING`: queued, sent, or being checked; the chain has not confirmed it yet.
|
|
8
|
+
* - `CONFIRMED`: the chain executed it. Only this state proves anything.
|
|
9
|
+
* - `FAILED`: it never took effect on the chain.
|
|
10
|
+
*/
|
|
11
|
+
export type LedgerRecordStatus = 'PENDING' | 'CONFIRMED' | 'FAILED';
|
|
12
|
+
/** One write to the chain. */
|
|
13
|
+
export interface LedgerRecord {
|
|
14
|
+
status: LedgerRecordStatus;
|
|
15
|
+
/**
|
|
16
|
+
* The Sui transaction digest. Set once a transaction was built for it, so a `PENDING` or `FAILED`
|
|
17
|
+
* write may carry one too; a `CONFIRMED` write recorded before digests were kept may not.
|
|
18
|
+
*/
|
|
19
|
+
digest: string | null;
|
|
20
|
+
/** When OctaP saw the chain confirm it; null unless `CONFIRMED`. */
|
|
21
|
+
confirmedAt: string | null;
|
|
22
|
+
}
|
|
23
|
+
/** The ledger behind a voucher's terms: frozen on the chain when the voucher goes live. */
|
|
24
|
+
export interface VoucherTermsEvidence {
|
|
25
|
+
voucherId: string;
|
|
26
|
+
/** The `VoucherTerms` object holding the frozen terms; null until a publish succeeds. */
|
|
27
|
+
termsObjectId: string | null;
|
|
28
|
+
/** The latest attempt to publish the terms; null for a voucher that was never taken live. */
|
|
29
|
+
published: LedgerRecord | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The ledger behind one member's voucher. The chain keeps it inside the member's `CreditAccount`,
|
|
33
|
+
* under the voucher's `VoucherTerms`. Each step is null when it never happened or never reaches the
|
|
34
|
+
* chain (a used voucher can't be refunded unused, a free voucher has no points to give back).
|
|
35
|
+
*/
|
|
36
|
+
export interface VoucherOwnershipEvidence {
|
|
37
|
+
voucherOwnershipId: string;
|
|
38
|
+
voucherId: string;
|
|
39
|
+
organizationEndUserId: string;
|
|
40
|
+
/** The member's `CreditAccount`; null before the account exists. */
|
|
41
|
+
creditAccountId: string | null;
|
|
42
|
+
termsObjectId: string | null;
|
|
43
|
+
/** Claimed with points, or granted for free. */
|
|
44
|
+
issued: LedgerRecord | null;
|
|
45
|
+
/** The latest use. */
|
|
46
|
+
used: LedgerRecord | null;
|
|
47
|
+
/** The refund of a voucher claimed with points. */
|
|
48
|
+
refunded: LedgerRecord | null;
|
|
49
|
+
}
|
package/dist/ledger.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ledger records: what OctaP wrote to the chain for one business fact, and how far that write got.
|
|
3
|
+
* The console's evidence views (OCT-328) show these instead of guessing from business statuses,
|
|
4
|
+
* which can run ahead of the chain (a refund is CONFIRMED in OctaP before its mirror lands).
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/licensing.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const LICENSE_TIERS: readonly LicenseTier[];
|
|
|
9
9
|
* Features a plan switches on. `core` (earn, redeem, vouchers, members, console) is never listed:
|
|
10
10
|
* every license has it.
|
|
11
11
|
*/
|
|
12
|
-
export type LicenseFeature = 'voucher.batches' | 'voucher.approval' | 'webhooks' | 'mcp' | 'assistant' | 'sandbox';
|
|
12
|
+
export type LicenseFeature = 'voucher.batches' | 'voucher.approval' | 'webhooks' | 'mcp' | 'assistant' | 'sandbox' | 'membership.levels';
|
|
13
13
|
export declare const LICENSE_FEATURES: readonly LicenseFeature[];
|
|
14
14
|
/** Caps a plan sets. `null` is no limit. */
|
|
15
15
|
export interface LicenseLimits {
|
package/dist/licensing.js
CHANGED
package/dist/licensing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"licensing.js","sourceRoot":"","sources":["../src/licensing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"licensing.js","sourceRoot":"","sources":["../src/licensing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAQlG,MAAM,CAAC,MAAM,gBAAgB,GAA8B;IACzD,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,KAAK;IACL,WAAW;IACX,SAAS;IACT,mBAAmB;CACpB,CAAC;AAaF,MAAM,CAAC,MAAM,kBAAkB,GAAqC;IAClE,qBAAqB;IACrB,SAAS;IACT,SAAS;IACT,aAAa;CACd,CAAC;AAQF,qGAAqG;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AA6HpC,MAAM,CAAC,MAAM,uBAAuB,GAAoC,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAoI/G;;;GAGG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,CAAC;AAI1D,MAAM,CAAC,MAAM,wBAAwB,GAAqC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAiCpF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAOhE,MAAM,CAAC,MAAM,qBAAqB,GAAkC,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAoCxH,qCAAqC;AACrC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,kGAAkG;AAClG,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC"}
|
package/dist/loyalty.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LedgerRecord } from './ledger.js';
|
|
1
2
|
/** Draft boundary types from the knowledge base; wire schemas remain to be designed. */
|
|
2
3
|
export type Points = string;
|
|
3
4
|
export interface BalanceSnapshot {
|
|
@@ -131,6 +132,13 @@ export interface LoyaltyTransactionDto {
|
|
|
131
132
|
idempotencyKey: string;
|
|
132
133
|
receiptReference?: string | null;
|
|
133
134
|
status: LoyaltyTxStatus;
|
|
135
|
+
/**
|
|
136
|
+
* Where its write to the chain stands, decided by OctaP rather than read off `status`: a reversal
|
|
137
|
+
* is CONFIRMED here before its mirror reaches the chain. Null when nothing goes to the chain for
|
|
138
|
+
* it (an expiry, which the chain applies by its own clock; a reversal of something never on the
|
|
139
|
+
* chain; anything from a sandbox key).
|
|
140
|
+
*/
|
|
141
|
+
ledger: LedgerRecord | null;
|
|
134
142
|
metadata?: Record<string, unknown> | null;
|
|
135
143
|
createdAt: string;
|
|
136
144
|
updatedAt: string;
|
|
@@ -150,6 +158,8 @@ export interface IssuanceBudgetTopUp {
|
|
|
150
158
|
amount: number;
|
|
151
159
|
/** PENDING or PROCESSING until the chain answers; UNKNOWN needs an operator and is never retried. */
|
|
152
160
|
status: string;
|
|
161
|
+
/** Its write to the chain. */
|
|
162
|
+
ledger: LedgerRecord;
|
|
153
163
|
createdAt: string;
|
|
154
164
|
}
|
|
155
165
|
/** How many more points a program may issue. Points, not money: no payment is involved. */
|
package/dist/members.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { CreditBalanceSnapshot } from './loyalty.js';
|
|
2
|
+
import type { MembershipCustomerLevel } from './membership.js';
|
|
2
3
|
export interface MemberDirectoryQuery {
|
|
3
4
|
limit?: number;
|
|
4
5
|
cursor?: string;
|
|
5
6
|
q?: string;
|
|
6
7
|
status?: 'ACTIVE' | 'BLOCKED';
|
|
7
8
|
externalMemberId?: string;
|
|
9
|
+
/** Only customers with this membership level. Empty while the organization's levels are off. */
|
|
10
|
+
levelId?: string;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
13
|
* `GET …/members/{memberId}/transactions`: `limit` 1–100 (default 25), `cursor` from the last page,
|
|
@@ -28,6 +31,8 @@ export interface MemberProfile {
|
|
|
28
31
|
externalMemberId: string | null;
|
|
29
32
|
metadata: unknown;
|
|
30
33
|
joinedAt: string;
|
|
34
|
+
/** `null`: no level, or the organization's levels are off. */
|
|
35
|
+
level: MembershipCustomerLevel | null;
|
|
31
36
|
}
|
|
32
37
|
export interface MemberProfilePatch {
|
|
33
38
|
status?: 'ACTIVE' | 'BLOCKED';
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/** `OFF`: no levels (the default). `OCTAP`: OctaP runs them. `OWN_CODE`: your server sends them, OctaP shows them. */
|
|
2
|
+
export type MembershipMode = 'OFF' | 'OCTAP' | 'OWN_CODE';
|
|
3
|
+
/** What moves a customer up. `MANUAL`: nothing does, levels are set by hand. */
|
|
4
|
+
export type MembershipRule = 'POINTS_EARNED' | 'MONEY_SPENT' | 'PURCHASE_COUNT' | 'MANUAL';
|
|
5
|
+
/**
|
|
6
|
+
* `NEVER`: every purchase counts, and no one moves down. `YEARLY`: purchases of the last 12 months
|
|
7
|
+
* count, and a customer may move down 12 months after reaching their level.
|
|
8
|
+
*/
|
|
9
|
+
export type MembershipDowngrade = 'NEVER' | 'YEARLY';
|
|
10
|
+
/** Who decided a customer's level. `MANUAL` survives every automatic check until the Owner removes it. */
|
|
11
|
+
export type MembershipLevelSource = 'AUTOMATIC' | 'MANUAL' | 'OWN_CODE';
|
|
12
|
+
export type MembershipChangeCause = 'MOVED_UP' | 'MOVED_DOWN' | 'SET_BY_OWNER' | 'SET_BY_SERVER' | 'MANUAL_REMOVED' | 'LEVEL_REMOVED';
|
|
13
|
+
export declare const MEMBERSHIP_MAX_LEVELS = 20;
|
|
14
|
+
export declare const MEMBERSHIP_MAX_LEVEL_NAME_LENGTH = 60;
|
|
15
|
+
export declare const MEMBERSHIP_MAX_REASON_LENGTH = 500;
|
|
16
|
+
export interface MembershipLevelDto {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* What a customer must reach, in the rule's own unit: points, money in the program currency's smallest
|
|
21
|
+
* unit (as `purchaseAmount`), or purchases. `null` while levels are set by hand.
|
|
22
|
+
* @TJS-type ["integer", "null"]
|
|
23
|
+
*/
|
|
24
|
+
target: number | null;
|
|
25
|
+
/** Customers who hold it now. */
|
|
26
|
+
customers: number;
|
|
27
|
+
}
|
|
28
|
+
export interface MembershipSettingsDto {
|
|
29
|
+
mode: MembershipMode;
|
|
30
|
+
/** `null` until a rule is picked. */
|
|
31
|
+
rule: MembershipRule | null;
|
|
32
|
+
downgrade: MembershipDowngrade;
|
|
33
|
+
/** Lowest first. Kept while the mode is `OFF`. */
|
|
34
|
+
levels: MembershipLevelDto[];
|
|
35
|
+
}
|
|
36
|
+
/** A starting point. Picking one only fills the form: what is saved is yours and never follows the template. */
|
|
37
|
+
export interface MembershipTemplateDto {
|
|
38
|
+
rule: MembershipRule;
|
|
39
|
+
downgrade: MembershipDowngrade;
|
|
40
|
+
levels: {
|
|
41
|
+
name: string;
|
|
42
|
+
target: number | null;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
export interface MembershipLevelInput {
|
|
46
|
+
/** An existing level's id; leave out for a new level. */
|
|
47
|
+
id?: string;
|
|
48
|
+
name: string;
|
|
49
|
+
/** @TJS-type ["integer", "null"] */
|
|
50
|
+
target?: number | null;
|
|
51
|
+
}
|
|
52
|
+
/** The whole settings, replaced at once. The order of `levels` is their order, lowest first. */
|
|
53
|
+
export interface MembershipSettingsInput {
|
|
54
|
+
mode: MembershipMode;
|
|
55
|
+
rule: MembershipRule | null;
|
|
56
|
+
downgrade: MembershipDowngrade;
|
|
57
|
+
levels: MembershipLevelInput[];
|
|
58
|
+
/**
|
|
59
|
+
* Every existing level left out of `levels`. One that customers hold needs `moveToLevelId`: the
|
|
60
|
+
* existing level they get, or `null` for none.
|
|
61
|
+
*/
|
|
62
|
+
removed?: {
|
|
63
|
+
levelId: string;
|
|
64
|
+
/** @TJS-type ["string", "null"] */
|
|
65
|
+
moveToLevelId?: string | null;
|
|
66
|
+
}[];
|
|
67
|
+
}
|
|
68
|
+
/** How many customers each level would have once these settings are on and everyone is checked. */
|
|
69
|
+
export interface MembershipPreviewDto {
|
|
70
|
+
/** In the order of the request's `levels`. */
|
|
71
|
+
levels: {
|
|
72
|
+
name: string;
|
|
73
|
+
customers: number;
|
|
74
|
+
}[];
|
|
75
|
+
withoutLevel: number;
|
|
76
|
+
}
|
|
77
|
+
/** A customer's level as a read shows it. */
|
|
78
|
+
export interface MembershipCustomerLevel {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
source: MembershipLevelSource;
|
|
82
|
+
reachedAt: string | null;
|
|
83
|
+
}
|
|
84
|
+
export interface MembershipProgressDto {
|
|
85
|
+
mode: MembershipMode;
|
|
86
|
+
/** `null`: no level, or the feature is off. */
|
|
87
|
+
level: MembershipCustomerLevel | null;
|
|
88
|
+
/** `null` unless OctaP runs the levels by a rule that counts something. */
|
|
89
|
+
progress: {
|
|
90
|
+
rule: MembershipRule;
|
|
91
|
+
/** What counts so far. */
|
|
92
|
+
total: number;
|
|
93
|
+
/** Only purchases from this moment on count; `null` for all of them. */
|
|
94
|
+
countedSince: string | null;
|
|
95
|
+
/** The next level up, or `null` at the highest. */
|
|
96
|
+
next: {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
target: number;
|
|
100
|
+
remaining: number;
|
|
101
|
+
} | null;
|
|
102
|
+
/** When this customer may move down, or `null` if never. */
|
|
103
|
+
nextDownCheckAt: string | null;
|
|
104
|
+
} | null;
|
|
105
|
+
}
|
|
106
|
+
export interface SetMembershipLevelInput {
|
|
107
|
+
/**
|
|
108
|
+
* `null` for no level.
|
|
109
|
+
* @TJS-type ["string", "null"]
|
|
110
|
+
*/
|
|
111
|
+
levelId: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* Why, kept in the history. No personal data. Required when the Owner sets a level in the console;
|
|
114
|
+
* optional with an API key.
|
|
115
|
+
*/
|
|
116
|
+
reason?: string;
|
|
117
|
+
}
|
|
118
|
+
/** A customer reading their own level: the token `getIdToken()` of `@octap/browser-sdk` returns. */
|
|
119
|
+
export interface MyMembershipInput {
|
|
120
|
+
organizationId: string;
|
|
121
|
+
idToken: string;
|
|
122
|
+
}
|
|
123
|
+
export interface MembershipLevelChangeDto {
|
|
124
|
+
id: string;
|
|
125
|
+
from: {
|
|
126
|
+
id: string;
|
|
127
|
+
name: string;
|
|
128
|
+
} | null;
|
|
129
|
+
to: {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
} | null;
|
|
133
|
+
cause: MembershipChangeCause;
|
|
134
|
+
actorType: 'USER' | 'CREDENTIAL' | 'SYSTEM';
|
|
135
|
+
actorId: string | null;
|
|
136
|
+
reason: string | null;
|
|
137
|
+
/**
|
|
138
|
+
* For an automatic move: what was counted, and the target it was compared with. After a refund,
|
|
139
|
+
* `reversedTransactionId` names the reversed earn that lowered the level.
|
|
140
|
+
*/
|
|
141
|
+
rule: {
|
|
142
|
+
rule: MembershipRule;
|
|
143
|
+
total: number;
|
|
144
|
+
target: number | null;
|
|
145
|
+
countedSince: string | null;
|
|
146
|
+
reversedTransactionId?: string;
|
|
147
|
+
} | null;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
}
|
|
150
|
+
export interface MembershipHistoryQuery {
|
|
151
|
+
/** 1–100, 25 by default. */
|
|
152
|
+
limit?: number;
|
|
153
|
+
/** The last row's id from the previous page. */
|
|
154
|
+
cursor?: string;
|
|
155
|
+
}
|
|
156
|
+
/** Newest first. */
|
|
157
|
+
export interface MembershipHistoryPage {
|
|
158
|
+
items: MembershipLevelChangeDto[];
|
|
159
|
+
nextCursor: string | null;
|
|
160
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership.js","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC"}
|
package/dist/rewards.d.ts
CHANGED
|
@@ -211,29 +211,58 @@ export interface GrantVoucherRequest {
|
|
|
211
211
|
idempotencyKey: string;
|
|
212
212
|
}
|
|
213
213
|
/** Asks the customer to use a voucher. Only their signature marks it used. */
|
|
214
|
+
/**
|
|
215
|
+
* One voucher, by `serialCode`. To use several of one customer's vouchers with one signature, send
|
|
216
|
+
* `PrepareVoucherUsesRequest` instead. How vouchers combine, and the discount, stay with you.
|
|
217
|
+
*/
|
|
214
218
|
export interface PrepareVoucherUseRequest {
|
|
215
219
|
serialCode: string;
|
|
216
220
|
/** Persist the same key across retries. */
|
|
217
221
|
idempotencyKey: string;
|
|
222
|
+
/** Your order, echoed on the response and on each `voucher.redeemed`. 1–100 characters, no personal data. */
|
|
223
|
+
orderReference?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Several vouchers of one customer, used in one transaction they sign once: the chain marks all of
|
|
227
|
+
* them used, or none. 1–5 serials, no duplicates. If any one can't be used, nothing is prepared and
|
|
228
|
+
* the error names its serial. The same key with another set or `orderReference` is a 409.
|
|
229
|
+
*/
|
|
230
|
+
export interface PrepareVoucherUsesRequest {
|
|
231
|
+
serialCodes: string[];
|
|
232
|
+
/** Persist the same key across retries. */
|
|
233
|
+
idempotencyKey: string;
|
|
234
|
+
/** Your order, echoed on the response and on each `voucher.redeemed`. 1–100 characters, no personal data. */
|
|
235
|
+
orderReference?: string;
|
|
218
236
|
}
|
|
219
|
-
|
|
237
|
+
/** One voucher of a use, as prepared. */
|
|
238
|
+
export interface VoucherUseItem {
|
|
220
239
|
voucherOwnershipId: string;
|
|
221
240
|
voucherId: string;
|
|
222
241
|
serialCode: string;
|
|
223
242
|
/** AVAILABLE until the chain confirms the use. */
|
|
224
243
|
status: VoucherOwnershipStatus;
|
|
225
|
-
/** For the customer's device to sign. Null once the use has settled. */
|
|
226
|
-
digest: string | null;
|
|
227
|
-
transactionBytes: string | null;
|
|
228
244
|
voucherTitle: string;
|
|
229
245
|
discountType?: string | null;
|
|
230
246
|
discountValue?: string | null;
|
|
231
247
|
}
|
|
248
|
+
/** What `POST /v1/rewards/vouchers/use` answers to `serialCodes`. */
|
|
249
|
+
export interface PrepareVoucherUsesResponse {
|
|
250
|
+
/** Every voucher of the use, in `serialCode` order. */
|
|
251
|
+
vouchers: VoucherUseItem[];
|
|
252
|
+
/** For the customer's device to sign, once for all of them. Null once the use has settled. */
|
|
253
|
+
digest: string | null;
|
|
254
|
+
transactionBytes: string | null;
|
|
255
|
+
orderReference: string | null;
|
|
256
|
+
}
|
|
257
|
+
/** What `POST /v1/rewards/vouchers/use` answers to one `serialCode`: the voucher's fields at the top level too. */
|
|
258
|
+
export interface PrepareVoucherUseResponse extends VoucherUseItem, PrepareVoucherUsesResponse {
|
|
259
|
+
}
|
|
232
260
|
export interface FinalizeVoucherUseRequest {
|
|
233
261
|
digest: string;
|
|
234
262
|
signature: string;
|
|
235
263
|
}
|
|
236
|
-
|
|
264
|
+
/** One voucher the chain marked used. */
|
|
265
|
+
export interface RedeemedVoucher {
|
|
237
266
|
voucherOwnershipId: string;
|
|
238
267
|
voucherId: string;
|
|
239
268
|
serialCode: string;
|
|
@@ -242,8 +271,18 @@ export interface RedeemVoucherResponse {
|
|
|
242
271
|
voucherTitle: string;
|
|
243
272
|
discountType?: string | null;
|
|
244
273
|
discountValue?: string | null;
|
|
245
|
-
/** The customer-signed transaction that marked it used. */
|
|
274
|
+
/** The customer-signed transaction that marked it used, shared by every voucher of the use. */
|
|
275
|
+
blockchainDigest: string;
|
|
276
|
+
}
|
|
277
|
+
/** What finalize answers for a use of several vouchers. */
|
|
278
|
+
export interface RedeemVouchersResponse {
|
|
279
|
+
/** Every voucher of the use, in `serialCode` order. */
|
|
280
|
+
vouchers: RedeemedVoucher[];
|
|
246
281
|
blockchainDigest: string;
|
|
282
|
+
orderReference: string | null;
|
|
283
|
+
}
|
|
284
|
+
/** What finalize answers for a use of one voucher: its fields at the top level too. */
|
|
285
|
+
export interface RedeemVoucherResponse extends RedeemedVoucher, RedeemVouchersResponse {
|
|
247
286
|
}
|
|
248
287
|
export interface VoucherOwnershipDto {
|
|
249
288
|
refundPolicy?: VoucherRefundPolicySnapshot;
|
package/dist/rewards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewards.js","sourceRoot":"","sources":["../src/rewards.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,OAAO,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiE,EACjE,QAAc;IAEd,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC;
|
|
1
|
+
{"version":3,"file":"rewards.js","sourceRoot":"","sources":["../src/rewards.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,OAAO,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiE,EACjE,QAAc;IAEd,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC;AA0OD,sGAAsG;AACtG,qGAAqG;AACrG,sCAAsC;AACtC,sGAAsG;AAEtG,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,gDAAgD;AAChD,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC"}
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LicenseExpiryNoticeEventData, LicensePaymentNeedsAttentionEventData, LicensePurchasedEventData, LicenseUsageThresholdEventData } from './licensing.js';
|
|
2
2
|
import type { BudgetWarningThreshold } from './loyalty.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RedeemedVoucher, VoucherActorRef, VoucherOwnershipStatus, VoucherPublishStatus, VoucherStatus } from './rewards.js';
|
|
4
4
|
export type WebhookEndpointStatus = 'ACTIVE' | 'DISABLED';
|
|
5
5
|
export type WebhookDeliveryStatus = 'PENDING' | 'DELIVERED' | 'DEAD_LETTER';
|
|
6
6
|
export interface WebhookEndpointDto {
|
|
@@ -204,8 +204,14 @@ export interface VoucherMemberExpiredEventData {
|
|
|
204
204
|
* `voucher.redeemed`: the customer signed and the chain marked their voucher used. Deliver the benefit
|
|
205
205
|
* on this event. No points move here; a paid claim already sent `credits.redemption.confirmed`.
|
|
206
206
|
*/
|
|
207
|
-
|
|
207
|
+
/**
|
|
208
|
+
* One per voucher, also when several were used with one signature: those share `blockchainDigest`
|
|
209
|
+
* and `orderReference`, so wait for each voucher of the order before delivering its benefit.
|
|
210
|
+
*/
|
|
211
|
+
export interface VoucherRedeemedEventData extends RedeemedVoucher {
|
|
208
212
|
organizationEndUserId: string;
|
|
213
|
+
/** The `orderReference` sent when preparing the use; null without one, or when no prepared use is behind it. */
|
|
214
|
+
orderReference: string | null;
|
|
209
215
|
}
|
|
210
216
|
/**
|
|
211
217
|
* The voucher as it is right after the change. Every voucher lifecycle event carries it: fetch the
|