@octap/contracts 0.3.0 → 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 ADDED
@@ -0,0 +1,57 @@
1
+ # Changelog
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
+
42
+ ## 0.3.1
43
+
44
+ Additive only: no type was removed or narrowed, so `^0.3.0` consumers pick it up as is.
45
+
46
+ ### Added
47
+
48
+ - Program budget cap: `ProgramTerms.budgetCap`; `IssuanceBudgetDto.budgetCap` and `topUpHeadroom`;
49
+ `GovernanceRequestType` gains `PROGRAM_CAP_CHANGE` (`{ budgetCap }`); `PROVISION_PROGRAM` accepts
50
+ an optional `budgetCap`. A `BUDGET_TOP_UP` within the cap is approved without review.
51
+ - System Admin license overview types (OCT-346).
52
+ - Platform announcements (OCT-396).
53
+ - Organization slug rules and availability check (OCT-367).
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`.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Platform announcements (OCT-396): a System Admin tells organizations something themselves, such as
3
+ * planned maintenance or new prices. Each one reaches every active member of the organizations it was
4
+ * sent to as a `platform.announcement` notification (in-app only, never a webhook). A sent
5
+ * announcement is never edited or deleted: a correction is a new one.
6
+ */
7
+ /** How urgent an announcement is. */
8
+ export type AnnouncementSeverity = 'INFO' | 'WARNING';
9
+ export declare const ANNOUNCEMENT_SEVERITIES: readonly AnnouncementSeverity[];
10
+ export declare const ANNOUNCEMENT_TITLE_MAX = 120;
11
+ export declare const ANNOUNCEMENT_BODY_MAX = 1000;
12
+ /** Organizations one announcement may name; to reach more, send it to all. */
13
+ export declare const ANNOUNCEMENT_TARGETS_MAX = 500;
14
+ /**
15
+ * `POST /v1/platform/announcements`. Exactly one target: `organizationIds` (one or more) or
16
+ * `allOrganizations: true`, which means every organization that is active when it's sent.
17
+ */
18
+ export interface CreateAnnouncementInput {
19
+ /** 1–120 characters. */
20
+ title: string;
21
+ /** At most 1000 characters. */
22
+ body?: string | null;
23
+ /** An https URL. */
24
+ link?: string | null;
25
+ /** Default `INFO`. */
26
+ severity?: AnnouncementSeverity;
27
+ organizationIds?: string[];
28
+ allOrganizations?: boolean;
29
+ }
30
+ /** A sent announcement, as the platform's list shows it. */
31
+ export interface Announcement {
32
+ id: string;
33
+ title: string;
34
+ body: string | null;
35
+ link: string | null;
36
+ severity: AnnouncementSeverity;
37
+ /** Whether it went to every active organization. */
38
+ allOrganizations: boolean;
39
+ /** How many organizations it reached. */
40
+ targetCount: number;
41
+ /** The System Admin who sent it. */
42
+ sentBy: {
43
+ id: string;
44
+ name: string | null;
45
+ };
46
+ sentAt: string;
47
+ }
48
+ /** `GET /v1/platform/announcements`: newest first. `limit` 1–100, default 30. */
49
+ export interface AnnouncementListQuery {
50
+ /** The `nextCursor` of the previous page. */
51
+ cursor?: string;
52
+ limit?: number;
53
+ }
54
+ export interface AnnouncementPage {
55
+ items: Announcement[];
56
+ /** Pass as `cursor` for the next, older page; `null` once there is no more. */
57
+ nextCursor: string | null;
58
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Platform announcements (OCT-396): a System Admin tells organizations something themselves, such as
3
+ * planned maintenance or new prices. Each one reaches every active member of the organizations it was
4
+ * sent to as a `platform.announcement` notification (in-app only, never a webhook). A sent
5
+ * announcement is never edited or deleted: a correction is a new one.
6
+ */
7
+ export const ANNOUNCEMENT_SEVERITIES = ['INFO', 'WARNING'];
8
+ export const ANNOUNCEMENT_TITLE_MAX = 120;
9
+ export const ANNOUNCEMENT_BODY_MAX = 1000;
10
+ /** Organizations one announcement may name; to reach more, send it to all. */
11
+ export const ANNOUNCEMENT_TARGETS_MAX = 500;
12
+ //# sourceMappingURL=announcements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announcements.js","sourceRoot":"","sources":["../src/announcements.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,uBAAuB,GAAoC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE5F,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC"}
package/dist/exports.d.ts CHANGED
@@ -34,3 +34,57 @@ export interface ExportLink {
34
34
  /** Rows the file holds, counted when the link was made. */
35
35
  rows: number;
36
36
  }
37
+ /**
38
+ * A file over the streaming limit (100,000 rows) is refused with a 400 whose `error` is this code; send
39
+ * the same request as a background export job instead (`POST …/export-jobs`, OCT-402).
40
+ */
41
+ export declare const EXPORT_TOO_LARGE = "EXPORT_TOO_LARGE";
42
+ /** The most rows a background export job may hold. */
43
+ export declare const EXPORT_JOB_MAX_ROWS = 2000000;
44
+ /** How long a finished job's file is kept, in hours; afterwards the job is `EXPIRED`. */
45
+ export declare const EXPORT_JOB_RETENTION_HOURS = 24;
46
+ /**
47
+ * `QUEUED` until a worker picks it up, `RUNNING` while it writes the file, then `READY` (download it
48
+ * until `expiresAt`), `FAILED` (`error` says why; nothing is kept) or `EXPIRED` (the file is gone).
49
+ */
50
+ export type ExportJobStatus = 'QUEUED' | 'RUNNING' | 'READY' | 'FAILED' | 'EXPIRED';
51
+ /** `POST /v1/console/organizations/{organizationId}/export-jobs`: the same body as an export link. */
52
+ export type ExportJobInput = ExportLinkInput;
53
+ /** A background export (OCT-402): a file over the streaming limit, kept for a day once written. */
54
+ export interface ExportJob {
55
+ id: string;
56
+ dataset: ExportDataset;
57
+ /** The filters it was asked with, checked: `from` and `to` filled in. */
58
+ filters: Record<string, string>;
59
+ status: ExportJobStatus;
60
+ /** Rows counted when it was asked for; the exact count once `READY`. */
61
+ rows: number;
62
+ /** Bytes, once `READY`. */
63
+ sizeBytes: number | null;
64
+ /** SHA-256 of the file, hex, once `READY`. */
65
+ sha256: string | null;
66
+ /** The download file name, e.g. `octap-transactions-2026-12-02.csv`. */
67
+ filename: string;
68
+ /** Why it failed, when `FAILED`. */
69
+ error: string | null;
70
+ requestedBy: {
71
+ id: string;
72
+ name: string | null;
73
+ } | null;
74
+ createdAt: string;
75
+ finishedAt: string | null;
76
+ /** When the file is deleted, once `READY`. */
77
+ expiresAt: string | null;
78
+ }
79
+ export interface ExportJobPage {
80
+ items: ExportJob[];
81
+ }
82
+ /**
83
+ * A one-time link to a `READY` job's file, for 5 minutes, for the MCP assistant: opening it checks the
84
+ * user's access again and redirects to the file. Never a storage URL.
85
+ */
86
+ export interface ExportJobLink {
87
+ jobId: string;
88
+ url: string;
89
+ expiresAt: string;
90
+ }
package/dist/exports.js CHANGED
@@ -1,2 +1,10 @@
1
- export {};
1
+ /**
2
+ * A file over the streaming limit (100,000 rows) is refused with a 400 whose `error` is this code; send
3
+ * the same request as a background export job instead (`POST …/export-jobs`, OCT-402).
4
+ */
5
+ export const EXPORT_TOO_LARGE = 'EXPORT_TOO_LARGE';
6
+ /** The most rows a background export job may hold. */
7
+ export const EXPORT_JOB_MAX_ROWS = 2_000_000;
8
+ /** How long a finished job's file is kept, in hours; afterwards the job is `EXPIRED`. */
9
+ export const EXPORT_JOB_RETENTION_HOURS = 24;
2
10
  //# sourceMappingURL=exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,sDAAsD;AACtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAC7C,yFAAyF;AACzF,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { OrganizationIdentityInput, OrganizationType } from './console.js';
2
- export type GovernanceRequestType = 'UPDATE_PROFILE' | 'TRANSFER_OWNERSHIP' | 'DEACTIVATE' | 'BUDGET_TOP_UP' | 'SUSPEND' | 'REINSTATE' | 'UPDATE_IDENTITY' | 'UPDATE_EARN_RATE' | 'PROVISION_PROGRAM';
2
+ export type GovernanceRequestType = 'UPDATE_PROFILE' | 'TRANSFER_OWNERSHIP' | 'DEACTIVATE' | 'BUDGET_TOP_UP' | 'SUSPEND' | 'REINSTATE' | 'UPDATE_IDENTITY' | 'UPDATE_EARN_RATE' | 'PROVISION_PROGRAM' | 'PROGRAM_CAP_CHANGE';
3
3
  /**
4
4
  * `UPDATE_IDENTITY` replaces an organization's legal details once a System Admin approves it. Send
5
5
  * at least one field; `organizationType` only classifies an organization that has none yet. The
@@ -14,12 +14,23 @@ export interface GovernanceProposal {
14
14
  /**
15
15
  * The program terms are the merchant's to choose and are proposed by the organization's Owner
16
16
  * only; a System Admin approves or rejects them with a reason, and never proposes them:
17
- * - `PROVISION_PROGRAM`: `{ earnBps, expiryDays, totalBudget }` sets up the organization's loyalty
18
- * program. `earnBps` 0–10000 (points per 10,000 units of purchase), `expiryDays` 1–3650 (how
19
- * long earned points last; never changes afterwards), `totalBudget` a positive whole number of
20
- * points it may issue.
21
- * - `BUDGET_TOP_UP`: `{ amount }`, a positive whole number of points. The budget only grows.
22
- * - `UPDATE_EARN_RATE`: `{ earnBps }`, 0–10000, which replaces the base earn rate once approved.
17
+ * - `PROVISION_PROGRAM`: `{ earnBps, expiryDays, totalBudget, budgetCap? }` sets up the
18
+ * organization's loyalty program. `earnBps` 0–10000 (points per 10,000 units of purchase),
19
+ * `expiryDays` 1–3650 (how long earned points last; never changes afterwards), `totalBudget` a
20
+ * positive whole number of points it may issue, `budgetCap` the most it may ever be funded with,
21
+ * top-ups included: at least `totalBudget`, which it defaults to.
22
+ * - `BUDGET_TOP_UP`: `{ amount }`, a positive whole number of points. The budget only grows. Needs
23
+ * no review: it is created `APPROVED` and applied at once when it fits within `budgetCap`, and
24
+ * refused with 409 otherwise (raise the cap first). One runs at a time: while the last is still
25
+ * being applied, or ended UNKNOWN, another is a 409. A repeat sent after the first has finished
26
+ * is a new top-up, still bounded by `budgetCap`.
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.
30
+ * - `PROGRAM_CAP_CHANGE`: `{ budgetCap }`, a positive whole number of points, up or down, but never
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.
23
34
  */
24
35
  payload: {
25
36
  name?: string;
@@ -28,7 +39,15 @@ export interface GovernanceProposal {
28
39
  earnBps?: number;
29
40
  expiryDays?: number;
30
41
  totalBudget?: number;
42
+ budgetCap?: number;
31
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;
32
51
  }
33
52
  export interface GovernanceRequest {
34
53
  id: string;
@@ -90,6 +109,11 @@ export interface ConsoleChangeRequest {
90
109
  /** The System Admin's reason; null while `PENDING`. */
91
110
  reviewReason: string | null;
92
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;
93
117
  createdAt: string;
94
118
  /** Null for a request that queues no command, or one not approved. */
95
119
  command: ChangeRequestCommand | null;
package/dist/index.d.ts CHANGED
@@ -8,8 +8,10 @@ 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';
14
+ export * from './organization-slugs.js';
13
15
  export * from './mcp-auth.js';
14
16
  export * from './mcp-tool-calls.js';
15
17
  export * from './assistant.js';
@@ -17,8 +19,10 @@ export * from './request-logs.js';
17
19
  export * from './licensing.js';
18
20
  export * from './audit.js';
19
21
  export * from './evidence.js';
22
+ export * from './ledger.js';
20
23
  export * from './analytics.js';
21
24
  export * from './exports.js';
22
25
  export * from './member-insights.js';
23
26
  export * from './platform-observability.js';
24
27
  export * from './notifications.js';
28
+ export * from './announcements.js';
package/dist/index.js CHANGED
@@ -8,8 +8,10 @@ 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';
14
+ export * from './organization-slugs.js';
13
15
  export * from './mcp-auth.js';
14
16
  export * from './mcp-tool-calls.js';
15
17
  export * from './assistant.js';
@@ -17,9 +19,11 @@ export * from './request-logs.js';
17
19
  export * from './licensing.js';
18
20
  export * from './audit.js';
19
21
  export * from './evidence.js';
22
+ export * from './ledger.js';
20
23
  export * from './analytics.js';
21
24
  export * from './exports.js';
22
25
  export * from './member-insights.js';
23
26
  export * from './platform-observability.js';
24
27
  export * from './notifications.js';
28
+ export * from './announcements.js';
25
29
  //# 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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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"}
@@ -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 {
@@ -93,6 +93,132 @@ export interface OrganizationLicenseDto {
93
93
  license: LicenseDto | null;
94
94
  usage: LicenseUsage | null;
95
95
  }
96
+ /** One license month's counted transactions, from `license_usage`. */
97
+ export interface LicenseHistoryMonth {
98
+ periodStart: string;
99
+ periodEnd: string;
100
+ /** Accepted, less the ones that failed after: the same count the limit uses. */
101
+ transactions: number;
102
+ /** When the 80% and 100% warnings went out that month, if they did. */
103
+ warned80At: string | null;
104
+ warned100At: string | null;
105
+ /** Requests refused with 402 that month (OCT-346). */
106
+ refused: LicenseRefusalCounts;
107
+ lastRefusedAt: string | null;
108
+ }
109
+ /**
110
+ * Requests refused with 402 in one license month (OCT-346), by what they stopped. A missing feature
111
+ * isn't a used-up quota and isn't counted.
112
+ */
113
+ export interface LicenseRefusalCounts {
114
+ /** Transactions turned away: earns, POS redeems or paid claims at 110% of the limit, or past an expired license's grace. */
115
+ transactions: number;
116
+ /** One more member, API key or team member refused at 100% of its limit. */
117
+ resources: number;
118
+ }
119
+ /** One license an organization had, newest first, with the months it counted transactions in. */
120
+ export interface LicenseHistoryEntry {
121
+ id: string;
122
+ planId: string;
123
+ tier: LicenseTier;
124
+ planName: string;
125
+ source: LicenseSource;
126
+ entitlements: LicenseEntitlements;
127
+ startsAt: string;
128
+ endsAt: string;
129
+ state: LicenseState;
130
+ /** The license that replaced this one on an upgrade; it stopped counting then. */
131
+ replacedByLicenseId: string | null;
132
+ /**
133
+ * Newest first. A month appears once a transaction was counted or a request refused in it, so a
134
+ * quiet month has none.
135
+ * Members, API keys and team members are counted live, so they have no history.
136
+ */
137
+ months: LicenseHistoryMonth[];
138
+ }
139
+ /** `GET /v1/platform/organizations/:organizationId/license/history` (OCT-346). */
140
+ export interface OrganizationLicenseHistoryDto {
141
+ organizationId: string;
142
+ licenses: LicenseHistoryEntry[];
143
+ }
144
+ /** A license's state for the System Admin's list; `NONE` is an organization that never had one. */
145
+ export type PlatformLicenseState = LicenseState | 'NONE';
146
+ export declare const PLATFORM_LICENSE_STATES: readonly PlatformLicenseState[];
147
+ /**
148
+ * One limit's use. `percent` is `floor(used × 100 / allowed)`: rounded down, so 80 is reached exactly
149
+ * when the 80% warning goes out. Transactions can reach 110 (a month may go 10% over); the others
150
+ * stop at 100. `allowed` and `percent` are `null` for no limit, or for an organization without a
151
+ * license (it is never limited).
152
+ */
153
+ export interface LicenseLimitUsage {
154
+ used: number;
155
+ allowed: number | null;
156
+ percent: number | null;
157
+ }
158
+ /** The license in force, as `GET /v1/platform/licenses` shows it: `LicenseDto` without the entitlements. */
159
+ export interface PlatformLicenseSummary {
160
+ id: string;
161
+ planId: string;
162
+ tier: LicenseTier;
163
+ planName: string;
164
+ source: LicenseSource;
165
+ startsAt: string;
166
+ endsAt: string;
167
+ graceEndsAt: string;
168
+ /** Whole days until `endsAt`, 0 once it has passed. */
169
+ daysLeft: number;
170
+ }
171
+ /** Each limit's use, by limit. */
172
+ export interface PlatformLicenseUsage {
173
+ transactionsMonthly: LicenseLimitUsage;
174
+ members: LicenseLimitUsage;
175
+ apiKeys: LicenseLimitUsage;
176
+ teamMembers: LicenseLimitUsage;
177
+ }
178
+ /** One organization in `GET /v1/platform/licenses` (OCT-346). */
179
+ export interface PlatformLicenseListItem {
180
+ organizationId: string;
181
+ organizationName: string;
182
+ /** The license in force, or `null` when the organization never had one. */
183
+ license: PlatformLicenseSummary | null;
184
+ state: PlatformLicenseState;
185
+ /** The license month `usage.transactionsMonthly` counts; `null` without a license. */
186
+ periodStart: string | null;
187
+ periodEnd: string | null;
188
+ /**
189
+ * Transactions are this license month's counted ones: accepted, less those that failed after.
190
+ * Members, API keys and team members are counted as they stand.
191
+ */
192
+ usage: PlatformLicenseUsage;
193
+ /** The highest `percent` of the four limits; `null` when none has one. */
194
+ usagePercent: number | null;
195
+ /**
196
+ * Requests refused with 402 in this license month, by what they stopped. An expired license keeps
197
+ * counting on its last month.
198
+ */
199
+ refusedThisMonth: LicenseRefusalCounts;
200
+ }
201
+ /** `GET /v1/platform/licenses`. Archived organizations are left out. */
202
+ export interface PlatformLicenseListQuery {
203
+ state?: PlatformLicenseState;
204
+ tier?: LicenseTier;
205
+ /** ACTIVE licenses that end within this many days (`daysLeft` at most this). */
206
+ expiresWithinDays?: number;
207
+ /** At least one limit at or above this percentage. */
208
+ minUsagePercent?: number;
209
+ /** `daysLeft` (soonest end first, the default) or `usage` (highest `usagePercent` first). */
210
+ sort?: 'daysLeft' | 'usage';
211
+ /** 1 to 100, 50 by default. */
212
+ limit?: number;
213
+ offset?: number;
214
+ }
215
+ export interface PlatformLicensePage {
216
+ items: PlatformLicenseListItem[];
217
+ /** Organizations matching the filters, across all pages. */
218
+ total: number;
219
+ limit: number;
220
+ offset: number;
221
+ }
96
222
  /** `POST /v1/platform/license-plans`. */
97
223
  export interface CreateLicensePlanRequest {
98
224
  tier: LicenseTier;
@@ -156,6 +282,25 @@ export interface LicenseUsageThresholdEventData {
156
282
  periodStart: string;
157
283
  periodEnd: string;
158
284
  }
285
+ /**
286
+ * `license.limit_refused` (internal, OCT-346): the first transaction of a license month refused with
287
+ * 402, at 110% of the limit (`LICENSE_LIMIT_REACHED`) or past an expired license's grace
288
+ * (`LICENSE_EXPIRED`): the business is turning customers away. Later ones that month only add to
289
+ * `license_usage.refused_transactions`, so the feed isn't flooded. A refused member, API key or team
290
+ * member is only counted (`refused_resources`): whoever tried got the 402 in the console already.
291
+ */
292
+ export interface LicenseLimitRefusedEventData {
293
+ licenseId: string;
294
+ tier: LicenseTier;
295
+ planName: string;
296
+ code: 'LICENSE_LIMIT_REACHED' | 'LICENSE_EXPIRED';
297
+ /** `transactionsMonthly` when it was full; `null` for an expired license. */
298
+ limit: 'transactionsMonthly' | null;
299
+ used: number | null;
300
+ allowed: number | null;
301
+ periodStart: string;
302
+ periodEnd: string;
303
+ }
159
304
  /** Days before `endsAt` that send a reminder, latest first. */
160
305
  export declare const LICENSE_EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
161
306
  /**
package/dist/licensing.js CHANGED
@@ -11,6 +11,7 @@ export const LICENSE_FEATURES = [
11
11
  'mcp',
12
12
  'assistant',
13
13
  'sandbox',
14
+ 'membership.levels',
14
15
  ];
15
16
  export const LICENSE_LIMIT_KEYS = [
16
17
  'transactionsMonthly',
@@ -20,6 +21,7 @@ export const LICENSE_LIMIT_KEYS = [
20
21
  ];
21
22
  /** After `endsAt`, new transactions keep working for this many days, then the license is EXPIRED. */
22
23
  export const LICENSE_GRACE_DAYS = 7;
24
+ export const PLATFORM_LICENSE_STATES = ['ACTIVE', 'GRACE', 'EXPIRED', 'NONE'];
23
25
  /**
24
26
  * New transactions are refused once a license month's count reaches this share of
25
27
  * `transactionsMonthly`: the 10% above the limit gives the partner time to upgrade or renew.
@@ -1 +1 @@
1
- {"version":3,"file":"licensing.js","sourceRoot":"","sources":["../src/licensing.ts"],"names":[],"mappings":"AAAA;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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. */
@@ -161,6 +171,14 @@ export interface IssuanceBudgetDto {
161
171
  initialBudget: number;
162
172
  /** `initialBudget` plus every applied top-up. */
163
173
  capacity: number;
174
+ /** The most the program may ever be funded with, top-ups included (see `ProgramTerms.budgetCap`). */
175
+ budgetCap: number;
176
+ /**
177
+ * How many points a top-up may add right now without review: `budgetCap` minus `initialBudget` and
178
+ * every top-up not known to have failed (queued and unsettled ones count). A larger top-up is
179
+ * refused until a `PROGRAM_CAP_CHANGE` raises the cap.
180
+ */
181
+ topUpHeadroom: number;
164
182
  /** 80 or 95 once the fullest shard has used that percentage of its share, otherwise null. */
165
183
  warningThreshold: BudgetWarningThreshold | null;
166
184
  /** A shard never borrows from another, so an earn can fail while the total is above zero. */
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';