@octap/contracts 0.3.4 → 0.3.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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.5
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
+ - Extra points by level (OCT-411): `multiplierBps` on membership levels, templates, level inputs and a
10
+ customer's level and next level, with `MEMBERSHIP_BASE_MULTIPLIER_BPS` and
11
+ `MEMBERSHIP_MAX_MULTIPLIER_BPS`. `EarnPointsResponse`, `LoyaltyTransactionDto` and `credits.earned`
12
+ gain the whole `multiplierBps` and the `level` behind the extra points (`LoyaltyTransactionLevel`).
13
+ - `LicenseExpiryNoticeEventData` gains `featuresLost` (the features the next license lacks, `[]` without
14
+ one) and `nextPlanName`. A renewed license now still sends the 30, 7 and 1 days reminders when the next
15
+ license drops a feature, never `GRACE` or `EXPIRED`.
16
+ - `AssistantStreamEvent` gains `{ type: 'confirmation'; confirmation: McpConfirmation }` (OCT-422): a
17
+ change the dashboard assistant prepared, for the user to confirm or cancel. A consumer that switches
18
+ on `type` should ignore types it doesn't know.
19
+ - `VoucherPlanPreviewRequest`, `VoucherPlanPreview` and their parts (OCT-420).
20
+ - Reissuing a used voucher (OCT-263): `ReissueVoucherRequest` and `VOUCHER_REISSUE_MAX_REASON_LENGTH`.
21
+ `ClaimVoucherResponse` and `VoucherOwnershipDto` gain `reissuedFromOwnershipId` (`null` unless the
22
+ voucher was reissued for a used one), and `VoucherGrantedEventData` gains it when set.
23
+ - One-time codes (OCT-423): `OneTimeCodeChannel`, `OneTimeCodePurpose`, their limits
24
+ (`ONE_TIME_CODE_TTL_MS`, `ONE_TIME_CODE_MAX_ATTEMPTS`, `ONE_TIME_CODE_RESEND_MS`,
25
+ `ONE_TIME_CODES_PER_HOUR`) and the System Admin test-message types (`TestMessage`, `TestMessagePage`,
26
+ `SendTestCodeRequest`, `VerifyTestCodeRequest` and their answers).
27
+ - Phone number at sign-in (OCT-280): `CustomerSignInPhoneRequired`, `SendSignInPhoneCodeRequest`,
28
+ `VerifySignInPhoneRequest`, `SendCustomerPhoneCodeRequest`, `ConfirmCustomerPhoneRequest`,
29
+ `SentPhoneCode` and `CustomerPhone`. `MemberProfile` gains `phoneVerifiedAt`.
30
+ - Phone consent per business (OCT-424): `CustomerSignInPhoneShare` (`{ phoneShareRequired, phoneNumberEnding }`)
31
+ and `ShareSignInPhoneRequest`. `MemberProfile.phoneNumber` and `phoneVerifiedAt` are null unless the customer
32
+ shared their number with that business.
33
+
3
34
  ## 0.3.4
4
35
 
5
36
  Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up as is.
@@ -1,3 +1,4 @@
1
+ import type { McpConfirmation } from './mcp-auth.js';
1
2
  /**
2
3
  * The dashboard assistant (OCT-308): a chat in the console backed by an OpenAI model, which
3
4
  * reads the organization through the OctaP MCP server with the signed-in user's persona.
@@ -72,6 +73,17 @@ export type AssistantStreamEvent =
72
73
  type: 'done';
73
74
  reason: AssistantStopReason;
74
75
  }
76
+ /**
77
+ * The assistant prepared a change (OCT-422). Nothing is made until the user presses Confirm: the
78
+ * console then sends `confirmation.method` to `confirmation.path` with `confirmation.body` and the
79
+ * header `X-Assistant-Confirmation: <confirmationId>`, signed in as the user. It works once, before
80
+ * `expiresAt`. Cancel is `DELETE .../assistant/confirmations/{confirmationId}`. The summary comes from
81
+ * Core's stored change, not from the model.
82
+ */
83
+ | {
84
+ type: 'confirmation';
85
+ confirmation: McpConfirmation;
86
+ }
75
87
  /** The turn failed after the stream started. The message is safe to show. */
76
88
  | {
77
89
  type: 'error';
@@ -84,3 +96,11 @@ export type AssistantStreamEvent =
84
96
  * - `refused`: see the `refusal` event.
85
97
  */
86
98
  export type AssistantStopReason = 'complete' | 'tool_limit' | 'length' | 'refused';
99
+ /**
100
+ * `DELETE /v1/console/organizations/{organizationId}/assistant/confirmations/{confirmationId}` (OCT-422):
101
+ * the user pressed Cancel, and the change the assistant prepared can't be made any more.
102
+ */
103
+ export interface AssistantConfirmationCancelled {
104
+ confirmationId: string;
105
+ cancelled: true;
106
+ }
package/dist/assistant.js CHANGED
@@ -1,6 +1,2 @@
1
- /**
2
- * The dashboard assistant (OCT-308): a chat in the console backed by an OpenAI model, which
3
- * reads the organization through the OctaP MCP server with the signed-in user's persona.
4
- */
5
1
  export {};
6
2
  //# sourceMappingURL=assistant.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistant.js","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
1
+ {"version":3,"file":"assistant.js","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":""}
@@ -32,6 +32,70 @@ export interface CustomerSignInResult {
32
32
  expiresAt: number;
33
33
  };
34
34
  }
35
+ /**
36
+ * `POST /v1/identity/sign-in/complete` for a new customer (OCT-280): Google is done, but sign-in
37
+ * finishes only once they verify a phone number on the same page. Nothing is enrolled or returned
38
+ * until then.
39
+ */
40
+ export interface CustomerSignInPhoneRequired {
41
+ phoneRequired: true;
42
+ }
43
+ /**
44
+ * `POST /v1/identity/sign-in/complete` for a customer who has a verified number and joins this business
45
+ * for the first time (OCT-424): the page asks once whether to share the number with it, with no new
46
+ * code, then posts `…/sign-in/phone/share`. Nothing is enrolled or returned until then.
47
+ */
48
+ export interface CustomerSignInPhoneShare {
49
+ phoneShareRequired: true;
50
+ /** The last 4 digits of the customer's number, so they know which one they share. */
51
+ phoneNumberEnding: string;
52
+ }
53
+ /** `POST /v1/identity/sign-in/phone/share`: whether the customer shares their number with this business. */
54
+ export interface ShareSignInPhoneRequest {
55
+ requestId: string;
56
+ /** `true` to share it; `false` joins the business without it. */
57
+ share: boolean;
58
+ }
59
+ /** `POST /v1/identity/sign-in/phone`: the number the code goes to, and the customer's consent. */
60
+ export interface SendSignInPhoneCodeRequest {
61
+ requestId: string;
62
+ /** A Vietnamese mobile number: `0912 345 678` or `+84 912 345 678`. */
63
+ phoneNumber: string;
64
+ /** The customer agrees to share the number with the business. Must be `true`. */
65
+ consent: boolean;
66
+ }
67
+ /** A phone code was sent: to this number, kept as `+84…`. */
68
+ export interface SentPhoneCode {
69
+ phoneNumber: string;
70
+ expiresAt: string;
71
+ /** When another code can be asked for. */
72
+ resendAfter: string;
73
+ }
74
+ /** `POST /v1/identity/sign-in/phone/verify`: the code sent by the last `…/sign-in/phone`. */
75
+ export interface VerifySignInPhoneRequest {
76
+ requestId: string;
77
+ code: string;
78
+ }
79
+ /**
80
+ * `POST /v1/identity/phone/send` (OCT-280): a signed-in customer adds or changes their number, with
81
+ * the customer token from `@octap/browser-sdk`'s sign-in.
82
+ */
83
+ export interface SendCustomerPhoneCodeRequest {
84
+ customerToken: string;
85
+ phoneNumber: string;
86
+ consent: boolean;
87
+ }
88
+ /** `POST /v1/identity/phone/confirm`: the number and the code sent to it. */
89
+ export interface ConfirmCustomerPhoneRequest {
90
+ customerToken: string;
91
+ phoneNumber: string;
92
+ code: string;
93
+ }
94
+ /** The customer's verified number, after `…/phone/confirm`. */
95
+ export interface CustomerPhone {
96
+ phoneNumber: string;
97
+ phoneVerifiedAt: string;
98
+ }
35
99
  export interface CompleteCustomerSignInRequest {
36
100
  requestId: string;
37
101
  /** Google's credential, posted by Core's own sign-in page. */
package/dist/index.d.ts CHANGED
@@ -23,6 +23,8 @@ export * from './ledger.js';
23
23
  export * from './analytics.js';
24
24
  export * from './exports.js';
25
25
  export * from './member-insights.js';
26
+ export * from './voucher-plans.js';
26
27
  export * from './platform-observability.js';
27
28
  export * from './notifications.js';
28
29
  export * from './announcements.js';
30
+ export * from './one-time-codes.js';
package/dist/index.js CHANGED
@@ -23,7 +23,9 @@ export * from './ledger.js';
23
23
  export * from './analytics.js';
24
24
  export * from './exports.js';
25
25
  export * from './member-insights.js';
26
+ export * from './voucher-plans.js';
26
27
  export * from './platform-observability.js';
27
28
  export * from './notifications.js';
28
29
  export * from './announcements.js';
30
+ export * from './one-time-codes.js';
29
31
  //# 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,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"}
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,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
@@ -310,9 +310,11 @@ export declare const LICENSE_EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
310
310
  export type LicenseExpiryStage = 'DAYS_30' | 'DAYS_7' | 'DAYS_1' | 'GRACE' | 'EXPIRED';
311
311
  export declare const LICENSE_EXPIRY_STAGES: readonly LicenseExpiryStage[];
312
312
  /**
313
- * `license.expiry_notice`: the organization's license reached a step of its end. Sent once per step,
314
- * and only for the latest license, so a license already renewed sends nothing more. When several
315
- * steps passed unseen (no worker ran), only the current one is sent.
313
+ * `license.expiry_notice`: the organization's license reached a step of its end. Sent once per step.
314
+ * A license already renewed sends nothing more, unless the next license lacks some of its features:
315
+ * then it still sends the 30, 7 and 1 days reminders, with `featuresLost`, but never `GRACE` or
316
+ * `EXPIRED`, since the next license starts on time. When several steps passed unseen (no worker ran),
317
+ * only the current one is sent.
316
318
  */
317
319
  export interface LicenseExpiryNoticeEventData {
318
320
  licenseId: string;
@@ -323,6 +325,10 @@ export interface LicenseExpiryNoticeEventData {
323
325
  graceEndsAt: string;
324
326
  /** Whole days until `endsAt`, 0 once it has passed. */
325
327
  daysLeft: number;
328
+ /** The features of this license that the next one lacks: they stop when it starts. `[]` without a next one. */
329
+ featuresLost: LicenseFeature[];
330
+ /** The plan of the license that follows this one, or `null` when none does yet. */
331
+ nextPlanName: string | null;
326
332
  }
327
333
  /**
328
334
  * `POST /v1/platform/organizations/:organizationId/license`, System Admin: grants `months` of
@@ -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;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"}
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;AA0CxH,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
@@ -38,6 +38,20 @@ export interface EarnPointsResponse {
38
38
  newBalance: number;
39
39
  status: LoyaltyTxStatus;
40
40
  idempotencyKey: string;
41
+ /**
42
+ * The whole boost this earn got, in basis points: `10000` (1x) for none. A campaign's and the
43
+ * customer's membership level's extras are added, capped at 10x (`100000`).
44
+ */
45
+ multiplierBps?: number;
46
+ /** The membership level whose extra points boosted this earn (OCT-411); `null` when none did. */
47
+ level?: LoyaltyTransactionLevel | null;
48
+ }
49
+ /** The level behind an earn's extra points, as it was when the earn was accepted. */
50
+ export interface LoyaltyTransactionLevel {
51
+ id: string;
52
+ name: string;
53
+ /** The level's own boost, in basis points (above `10000`). */
54
+ multiplierBps: number;
41
55
  }
42
56
  /**
43
57
  * What the customer gets for the points: a discount on one of your orders. It is hashed into the
@@ -140,6 +154,12 @@ export interface LoyaltyTransactionDto {
140
154
  */
141
155
  ledger: LedgerRecord | null;
142
156
  metadata?: Record<string, unknown> | null;
157
+ /** On an EARN: the campaign whose boost applied (OCT-340), or `null`. */
158
+ campaignId?: string | null;
159
+ /** On an EARN: the whole boost, in basis points; `10000` (1x) for none and for other types. */
160
+ multiplierBps?: number;
161
+ /** On an EARN: the membership level whose extra points boosted it (OCT-411), or `null`. */
162
+ level?: LoyaltyTransactionLevel | null;
143
163
  createdAt: string;
144
164
  updatedAt: string;
145
165
  }
@@ -33,9 +33,11 @@ export interface McpConfirmationInput {
33
33
  summary: string;
34
34
  }
35
35
  /**
36
- * A prepared change. The host shows `summary`, and only once the user agrees sends `method path` with
37
- * exactly `body` and the header `X-Mcp-Confirmation: <confirmationId>`. The id works once, for that
38
- * request only, until `expiresAt` (5 minutes). A retry of the same request with the same id returns
36
+ * A prepared change. It is shown with `summary`, and only once the user agrees, `method path` is sent with
37
+ * exactly `body` and the confirmation header: `X-Mcp-Confirmation: <confirmationId>` from the MCP host that
38
+ * prepared it, or `X-Assistant-Confirmation: <confirmationId>` from the console, signed in with Google, when
39
+ * the user pressed Confirm on a change the dashboard assistant prepared (OCT-422). The id works once, for that
40
+ * request and user only, until `expiresAt` (5 minutes). A retry of the same request with the same id returns
39
41
  * the first answer instead of making the change again.
40
42
  */
41
43
  export interface McpConfirmation {
package/dist/members.d.ts CHANGED
@@ -26,7 +26,10 @@ export interface MemberProfile {
26
26
  endUserId: string;
27
27
  displayName: string | null;
28
28
  email: string | null;
29
+ /** The full number, `+84…`. The console shows only its last 4 digits. */
29
30
  phoneNumber: string | null;
31
+ /** When the customer verified `phoneNumber` with a code (OCT-280); null without one. */
32
+ phoneVerifiedAt: string | null;
30
33
  status: string;
31
34
  externalMemberId: string | null;
32
35
  metadata: unknown;
@@ -13,6 +13,10 @@ export type MembershipChangeCause = 'MOVED_UP' | 'MOVED_DOWN' | 'SET_BY_OWNER' |
13
13
  export declare const MEMBERSHIP_MAX_LEVELS = 20;
14
14
  export declare const MEMBERSHIP_MAX_LEVEL_NAME_LENGTH = 60;
15
15
  export declare const MEMBERSHIP_MAX_REASON_LENGTH = 500;
16
+ /** A level's `multiplierBps` when it gives no extra points (1x). */
17
+ export declare const MEMBERSHIP_BASE_MULTIPLIER_BPS = 10000;
18
+ /** The most a level's `multiplierBps` may be (10x). A level's and a campaign's boosts together are also capped at 10x. */
19
+ export declare const MEMBERSHIP_MAX_MULTIPLIER_BPS = 100000;
16
20
  export interface MembershipLevelDto {
17
21
  id: string;
18
22
  name: string;
@@ -22,6 +26,12 @@ export interface MembershipLevelDto {
22
26
  * @TJS-type ["integer", "null"]
23
27
  */
24
28
  target: number | null;
29
+ /**
30
+ * Extra points (OCT-411): the boost on every earn of a customer at this level, in basis points.
31
+ * `10000` (1x) gives none, `15000` gives 1.5x, at most `100000` (10x). It applies while the mode is
32
+ * `OCTAP` or `OWN_CODE`. With a campaign, the two extras are added: 1.5x and 2x give 2.5x, capped at 10x.
33
+ */
34
+ multiplierBps: number;
25
35
  /** Customers who hold it now. */
26
36
  customers: number;
27
37
  }
@@ -40,6 +50,7 @@ export interface MembershipTemplateDto {
40
50
  levels: {
41
51
  name: string;
42
52
  target: number | null;
53
+ multiplierBps: number;
43
54
  }[];
44
55
  }
45
56
  export interface MembershipLevelInput {
@@ -48,6 +59,8 @@ export interface MembershipLevelInput {
48
59
  name: string;
49
60
  /** @TJS-type ["integer", "null"] */
50
61
  target?: number | null;
62
+ /** Extra points, 10000–100000; leave out for none (10000, 1x). */
63
+ multiplierBps?: number;
51
64
  }
52
65
  /** The whole settings, replaced at once. The order of `levels` is their order, lowest first. */
53
66
  export interface MembershipSettingsInput {
@@ -80,6 +93,8 @@ export interface MembershipCustomerLevel {
80
93
  name: string;
81
94
  source: MembershipLevelSource;
82
95
  reachedAt: string | null;
96
+ /** The level's extra points: `10000` (1x) for none. */
97
+ multiplierBps: number;
83
98
  }
84
99
  export interface MembershipProgressDto {
85
100
  mode: MembershipMode;
@@ -98,6 +113,7 @@ export interface MembershipProgressDto {
98
113
  name: string;
99
114
  target: number;
100
115
  remaining: number;
116
+ multiplierBps: number;
101
117
  } | null;
102
118
  /** When this customer may move down, or `null` if never. */
103
119
  nextDownCheckAt: string | null;
@@ -1,4 +1,8 @@
1
1
  export const MEMBERSHIP_MAX_LEVELS = 20;
2
2
  export const MEMBERSHIP_MAX_LEVEL_NAME_LENGTH = 60;
3
3
  export const MEMBERSHIP_MAX_REASON_LENGTH = 500;
4
+ /** A level's `multiplierBps` when it gives no extra points (1x). */
5
+ export const MEMBERSHIP_BASE_MULTIPLIER_BPS = 10_000;
6
+ /** The most a level's `multiplierBps` may be (10x). A level's and a campaign's boosts together are also capped at 10x. */
7
+ export const MEMBERSHIP_MAX_MULTIPLIER_BPS = 100_000;
4
8
  //# sourceMappingURL=membership.js.map
@@ -1 +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"}
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;AAChD,oEAAoE;AACpE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC;AACrD,0HAA0H;AAC1H,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * One-time codes (OCT-423): a 6-digit code sent to a phone number by SMS or to an email address,
3
+ * valid 5 minutes and usable once. Core keeps only a hash of the code. Until a real provider is set
4
+ * up, delivery is mocked: each message is kept as a test message, which a System Admin reads on dev
5
+ * and staging (`GET /v1/platform/test-messages`). Mock delivery is refused on mainnet.
6
+ */
7
+ export type OneTimeCodeChannel = 'SMS' | 'EMAIL';
8
+ /** What a code is for. `TEST` is a code a System Admin sends from the test-message page. */
9
+ export type OneTimeCodePurpose = 'TEST' | 'PHONE_VERIFY';
10
+ /** How long a code is valid. */
11
+ export declare const ONE_TIME_CODE_TTL_MS: number;
12
+ /** Wrong tries a code takes before it stops working. */
13
+ export declare const ONE_TIME_CODE_MAX_ATTEMPTS = 5;
14
+ /** The wait before another code can be sent to the same destination, for the same purpose. */
15
+ export declare const ONE_TIME_CODE_RESEND_MS: number;
16
+ /** Codes one destination can be sent in an hour. */
17
+ export declare const ONE_TIME_CODES_PER_HOUR = 5;
18
+ /** How long a test message is kept. */
19
+ export declare const TEST_MESSAGE_RETENTION_MS: number;
20
+ /**
21
+ * Where a test message's code stands: `WAITING` (can still be used), `USED`, `EXPIRED`, `REPLACED`
22
+ * (a newer code was sent to the same destination) or `LOCKED` (too many wrong tries).
23
+ */
24
+ export type TestMessageStatus = 'WAITING' | 'USED' | 'EXPIRED' | 'REPLACED' | 'LOCKED';
25
+ /** One message mock delivery kept instead of sending it. */
26
+ export interface TestMessage {
27
+ id: string;
28
+ channel: OneTimeCodeChannel;
29
+ /** The phone number (`+84…`) or email address it was for. */
30
+ destination: string;
31
+ purpose: OneTimeCodePurpose;
32
+ /** The text a real SMS or email would carry. */
33
+ body: string;
34
+ code: string;
35
+ status: TestMessageStatus;
36
+ /** Wrong tries so far. */
37
+ attempts: number;
38
+ createdAt: string;
39
+ expiresAt: string;
40
+ usedAt: string | null;
41
+ }
42
+ export interface TestMessagePage {
43
+ items: TestMessage[];
44
+ nextCursor: string | null;
45
+ }
46
+ /** `GET /v1/platform/test-messages`. */
47
+ export interface TestMessageQuery {
48
+ channel?: OneTimeCodeChannel;
49
+ /** Exact match, after the same normalization as when sending (`0912…` finds `+84912…`). */
50
+ destination?: string;
51
+ /** 1–100, default 50. */
52
+ limit?: number;
53
+ cursor?: string;
54
+ }
55
+ /** `POST /v1/platform/test-messages`: send a `TEST` code, to try the flow end to end. */
56
+ export interface SendTestCodeRequest {
57
+ channel: OneTimeCodeChannel;
58
+ destination: string;
59
+ }
60
+ /** A `TEST` code sent: read it on the test-message page. */
61
+ export interface SentTestCode {
62
+ id: string;
63
+ channel: OneTimeCodeChannel;
64
+ /** As codes are kept under: `+84…`, or the email lowercased. */
65
+ destination: string;
66
+ expiresAt: string;
67
+ /** When another code can be sent to this destination. */
68
+ resendAfter: string;
69
+ }
70
+ /** `POST /v1/platform/test-messages/verify`: check a `TEST` code, as a sign-up form would. */
71
+ export interface VerifyTestCodeRequest {
72
+ channel: OneTimeCodeChannel;
73
+ destination: string;
74
+ code: string;
75
+ }
76
+ export interface VerifyTestCodeResult {
77
+ /** Right, and now used. Wrong, expired, replaced or locked all read `false`, never which. */
78
+ valid: boolean;
79
+ }
80
+ /** Whether codes are mock-delivered here, so the test-message page has anything to show. */
81
+ export interface TestMessagesStatus {
82
+ delivery: 'mock' | 'off';
83
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * One-time codes (OCT-423): a 6-digit code sent to a phone number by SMS or to an email address,
3
+ * valid 5 minutes and usable once. Core keeps only a hash of the code. Until a real provider is set
4
+ * up, delivery is mocked: each message is kept as a test message, which a System Admin reads on dev
5
+ * and staging (`GET /v1/platform/test-messages`). Mock delivery is refused on mainnet.
6
+ */
7
+ /** How long a code is valid. */
8
+ export const ONE_TIME_CODE_TTL_MS = 5 * 60 * 1000;
9
+ /** Wrong tries a code takes before it stops working. */
10
+ export const ONE_TIME_CODE_MAX_ATTEMPTS = 5;
11
+ /** The wait before another code can be sent to the same destination, for the same purpose. */
12
+ export const ONE_TIME_CODE_RESEND_MS = 60 * 1000;
13
+ /** Codes one destination can be sent in an hour. */
14
+ export const ONE_TIME_CODES_PER_HOUR = 5;
15
+ /** How long a test message is kept. */
16
+ export const TEST_MESSAGE_RETENTION_MS = 24 * 60 * 60 * 1000;
17
+ //# sourceMappingURL=one-time-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one-time-codes.js","sourceRoot":"","sources":["../src/one-time-codes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,gCAAgC;AAChC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAClD,wDAAwD;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AACjD,oDAAoD;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,uCAAuC;AACvC,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
package/dist/rewards.d.ts CHANGED
@@ -203,6 +203,11 @@ export interface ClaimVoucherResponse {
203
203
  * final value arrives on `voucher.granted` or `credits.redemption.confirmed`.
204
204
  */
205
205
  expiresAt?: string | null;
206
+ /**
207
+ * The used voucher this one was reissued for (OCT-263, `reissueVoucher`); `null` for any other claim
208
+ * or grant.
209
+ */
210
+ reissuedFromOwnershipId?: string | null;
206
211
  }
207
212
  /** Gives a customer a voucher without spending their points. */
208
213
  export interface GrantVoucherRequest {
@@ -210,6 +215,21 @@ export interface GrantVoucherRequest {
210
215
  /** Persist the same key across retries. */
211
216
  idempotencyKey: string;
212
217
  }
218
+ /** The longest `reason` a reissue takes, after trimming. */
219
+ export declare const VOUCHER_REISSUE_MAX_REASON_LENGTH = 500;
220
+ /**
221
+ * Gives a customer a used voucher's benefit back as a new voucher of the same kind (OCT-263), for
222
+ * example when the booking it paid for was cancelled in time. The used voucher stays used.
223
+ */
224
+ export interface ReissueVoucherRequest {
225
+ /** Persist the same key across retries. */
226
+ idempotencyKey: string;
227
+ /**
228
+ * Why, in 1–500 characters, such as your booking reference. Kept with the new voucher. No personal
229
+ * data.
230
+ */
231
+ reason: string;
232
+ }
213
233
  /** Asks the customer to use a voucher. Only their signature marks it used. */
214
234
  /**
215
235
  * One voucher, by `serialCode`. To use several of one customer's vouchers with one signature, send
@@ -299,6 +319,11 @@ export interface VoucherOwnershipDto {
299
319
  * final value arrives on `voucher.granted` or `credits.redemption.confirmed`.
300
320
  */
301
321
  expiresAt?: string | null;
322
+ /**
323
+ * The used voucher this one was reissued for (OCT-263, `reissueVoucher`); `null` for any other claim
324
+ * or grant.
325
+ */
326
+ reissuedFromOwnershipId?: string | null;
302
327
  voucher?: VoucherDto;
303
328
  }
304
329
  /** The most items one `createVoucherBatch` call takes; more is a 400 for the whole request. */
package/dist/rewards.js CHANGED
@@ -25,6 +25,8 @@ export function voucherUseDeadline(voucher, issuedAt) {
25
25
  const own = issuedAt.getTime() + duration;
26
26
  return new Date(voucher.expiresAt === null ? own : Math.min(own, voucher.expiresAt.getTime()));
27
27
  }
28
+ /** The longest `reason` a reissue takes, after trimming. */
29
+ export const VOUCHER_REISSUE_MAX_REASON_LENGTH = 500;
28
30
  // ---------------------------------------------------------------------------------------------------
29
31
  // Voucher batches (OCT-303): create many vouchers as one DRAFT batch, review them, then activate the
30
32
  // whole batch at once, or archive it.
@@ -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;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"}
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;AA4ID,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AAwHrD,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"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * A voucher plan checked before anything is created:
3
+ * `POST /v1/console/organizations/{organizationId}/analytics/voucher-plan`. The dashboard assistant
4
+ * drafts a plan ("lapsed members back in December, 10 million VND"), and Core says whether it would
5
+ * accept the voucher, the most it can cost, and what the organization's own history suggests. It
6
+ * reads only, so a read-only MCP connection may ask.
7
+ */
8
+ /**
9
+ * Who the plan is meant for, by each member's last CONFIRMED earn or redemption, as
10
+ * `MemberSegments` counts them: `active` within `activeDays`, `lapsing` before that but within
11
+ * `dormantDays`, `dormant` earlier, `never_transacted` none. A voucher itself cannot be limited to a
12
+ * group: any active member can claim it. The audience sizes the estimate and says whom to tell.
13
+ */
14
+ export type VoucherPlanAudience = 'all' | 'active' | 'lapsing' | 'dormant' | 'never_transacted';
15
+ /** The voucher the plan would create, in the fields `POST .../vouchers` takes. */
16
+ export interface VoucherPlanVoucher {
17
+ /** Optional while planning; creating the voucher needs one, unique in the organization. */
18
+ code?: string;
19
+ title: string;
20
+ description?: string;
21
+ /** Points a member pays to claim it; 0 for a free reward. */
22
+ pointsCost: number;
23
+ discountType: 'PERCENTAGE' | 'FIXED_AMOUNT' | 'FREE_ITEM';
24
+ /** A positive decimal string: the amount off in the organization's currency, or the percentage. */
25
+ discountValue?: string;
26
+ /** How many vouchers exist; omitted or `null` is unlimited, which has no cost cap. */
27
+ totalSupply?: number | null;
28
+ perMemberLimit?: number | null;
29
+ /** ISO 8601 date-time with an offset. When members can start claiming; omitted is now. */
30
+ startsAt?: string | null;
31
+ /** ISO 8601 date-time with an offset. When claims close; it must leave at least 24 hours to activate. */
32
+ expiresAt?: string | null;
33
+ validForDays?: number | null;
34
+ campaignId?: string;
35
+ }
36
+ export interface VoucherPlanPreviewRequest {
37
+ voucher: VoucherPlanVoucher;
38
+ /** Defaults to `all`. */
39
+ audience?: VoucherPlanAudience;
40
+ /**
41
+ * The most the organization will give away in discounts, in its currency, as a decimal string
42
+ * ("10000000"). A plan whose cost cap is above it is not valid.
43
+ */
44
+ budget?: string;
45
+ }
46
+ /** One finding about the plan: the field it is about (`null` for the whole plan) and what to do. */
47
+ export interface VoucherPlanIssue {
48
+ field: string | null;
49
+ message: string;
50
+ }
51
+ export interface VoucherPlanPreview {
52
+ /** No errors: Core would create the voucher as planned, and it fits the budget if one was given. */
53
+ valid: boolean;
54
+ /** What Core would refuse, or what breaks the budget. Fix each and preview again. */
55
+ errors: VoucherPlanIssue[];
56
+ /** Accepted, but worth knowing before creating: no cost cap, little history, an approval step. */
57
+ warnings: VoucherPlanIssue[];
58
+ /** Money the organization gives away in discounts. Certain, not estimated. */
59
+ cost: {
60
+ currency: string;
61
+ /**
62
+ * The most the plan can cost: `discountValue × totalSupply` for a FIXED_AMOUNT voucher with a
63
+ * supply. `null` when nothing caps it (a percentage, a free item, or unlimited supply).
64
+ */
65
+ maxCost: string | null;
66
+ budget: string | null;
67
+ /** `null` without a budget or without a cap. */
68
+ fitsBudget: boolean | null;
69
+ /** For a FIXED_AMOUNT voucher and a budget: the most vouchers the budget covers. */
70
+ maxSupplyForBudget: number | null;
71
+ };
72
+ /** How many members the plan is for, now. */
73
+ audience: {
74
+ segment: VoucherPlanAudience;
75
+ members: number;
76
+ /** Of those, members whose confirmed balance already covers `pointsCost`. */
77
+ canAffordPointsCost: number;
78
+ activeDays: number;
79
+ dormantDays: number;
80
+ };
81
+ /** The organization's own vouchers claimed in the last `days` days, and how many of those were used. */
82
+ history: {
83
+ days: number;
84
+ claimed: number;
85
+ /** Of the vouchers claimed in the window, how many were used: never more than `claimed`. */
86
+ redeemed: number;
87
+ /** `redeemed / claimed`, or `null` with fewer than `minClaims` claims to go on. */
88
+ redeemRate: number | null;
89
+ minClaims: number;
90
+ /** What these figures count, and that recent claims make the rate read a little low. */
91
+ note: string;
92
+ };
93
+ /** Estimates from `history`, never promises. `null` when there is nothing to base them on. */
94
+ estimate: {
95
+ /** If every voucher is claimed, how many would be used at the historical rate. */
96
+ usesIfAllClaimed: number | null;
97
+ /** What those uses would cost, for a FIXED_AMOUNT voucher. */
98
+ costIfAllClaimed: string | null;
99
+ };
100
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A voucher plan checked before anything is created:
3
+ * `POST /v1/console/organizations/{organizationId}/analytics/voucher-plan`. The dashboard assistant
4
+ * drafts a plan ("lapsed members back in December, 10 million VND"), and Core says whether it would
5
+ * accept the voucher, the most it can cost, and what the organization's own history suggests. It
6
+ * reads only, so a read-only MCP connection may ask.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=voucher-plans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voucher-plans.js","sourceRoot":"","sources":["../src/voucher-plans.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -54,6 +54,17 @@ export interface CreditsEarnedEventData {
54
54
  newBalance: number;
55
55
  /** The campaign whose multiplier boosted it (OCT-340); absent for an ordinary earn. */
56
56
  campaignId?: string;
57
+ /**
58
+ * The whole boost, in basis points: `10000` (1x) for none. A campaign's and the customer's level's
59
+ * extras are added, capped at 10x.
60
+ */
61
+ multiplierBps: number;
62
+ /** The membership level whose extra points boosted it (OCT-411); absent when none did. */
63
+ level?: {
64
+ id: string;
65
+ name: string;
66
+ multiplierBps: number;
67
+ };
57
68
  }
58
69
  /**
59
70
  * `credits.earn.confirmed` / `credits.redemption.confirmed`: the chain confirmed the transaction.
@@ -171,8 +182,8 @@ export interface ReversalEventData {
171
182
  newBalance: number;
172
183
  }
173
184
  /**
174
- * `voucher.granted`: the chain recorded a voucher given without spending points, through a grant or
175
- * a free claim. A paid claim reports through `credits.redemption.confirmed` instead.
185
+ * `voucher.granted`: the chain recorded a voucher given without spending points, through a grant,
186
+ * a free claim or a reissue. A paid claim reports through `credits.redemption.confirmed` instead.
176
187
  */
177
188
  export interface VoucherGrantedEventData {
178
189
  voucherOwnershipId: string;
@@ -186,6 +197,8 @@ export interface VoucherGrantedEventData {
186
197
  */
187
198
  expiresAt: string | null;
188
199
  blockchainDigest: string;
200
+ /** Set when this voucher was reissued for a used one (OCT-263): that voucher's id. */
201
+ reissuedFromOwnershipId?: string;
189
202
  }
190
203
  /**
191
204
  * `voucher.member_expired`: a customer's voucher reached its own deadline (`expiresAt`) unused, so it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octap/contracts",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Typed request/response contracts for the Octap Core REST API.",
5
5
  "license": "MIT",
6
6
  "repository": {