@octap/contracts 0.2.1 → 0.3.1

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/analytics.d.ts +162 -0
  3. package/dist/announcements.d.ts +58 -0
  4. package/dist/announcements.js +12 -0
  5. package/dist/announcements.js.map +1 -0
  6. package/dist/assistant.d.ts +24 -0
  7. package/dist/campaigns.d.ts +64 -0
  8. package/dist/campaigns.js +5 -0
  9. package/dist/campaigns.js.map +1 -0
  10. package/dist/console.d.ts +13 -2
  11. package/dist/exports.d.ts +90 -0
  12. package/dist/exports.js +10 -0
  13. package/dist/exports.js.map +1 -0
  14. package/dist/governance.d.ts +63 -1
  15. package/dist/identity.d.ts +44 -17
  16. package/dist/index.d.ts +9 -0
  17. package/dist/index.js +9 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/licensing.d.ts +511 -0
  20. package/dist/licensing.js +37 -0
  21. package/dist/licensing.js.map +1 -0
  22. package/dist/loyalty.d.ts +19 -1
  23. package/dist/mcp-auth.d.ts +62 -1
  24. package/dist/mcp-tool-calls.d.ts +71 -0
  25. package/dist/mcp-tool-calls.js +16 -0
  26. package/dist/mcp-tool-calls.js.map +1 -0
  27. package/dist/member-insights.d.ts +73 -0
  28. package/dist/member-insights.js +11 -0
  29. package/dist/member-insights.js.map +1 -0
  30. package/dist/members.d.ts +8 -1
  31. package/dist/notifications.d.ts +234 -0
  32. package/dist/notifications.js +116 -0
  33. package/dist/notifications.js.map +1 -0
  34. package/dist/organization-events.d.ts +56 -2
  35. package/dist/organization-events.js.map +1 -1
  36. package/dist/organization-slugs.d.ts +84 -0
  37. package/dist/organization-slugs.js +115 -0
  38. package/dist/organization-slugs.js.map +1 -0
  39. package/dist/organizations.d.ts +19 -4
  40. package/dist/platform-observability.d.ts +103 -0
  41. package/dist/platform-observability.js +2 -0
  42. package/dist/platform-observability.js.map +1 -0
  43. package/dist/rewards.d.ts +13 -1
  44. package/dist/rewards.js.map +1 -1
  45. package/dist/webhooks.d.ts +61 -4
  46. package/package.json +4 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1
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
+ - Program budget cap: `ProgramTerms.budgetCap`; `IssuanceBudgetDto.budgetCap` and `topUpHeadroom`;
10
+ `GovernanceRequestType` gains `PROGRAM_CAP_CHANGE` (`{ budgetCap }`); `PROVISION_PROGRAM` accepts
11
+ an optional `budgetCap`. A `BUDGET_TOP_UP` within the cap is approved without review.
12
+ - System Admin license overview types (OCT-346).
13
+ - Platform announcements (OCT-396).
14
+ - Organization slug rules and availability check (OCT-367).
15
+ - Background CSV export types (OCT-402).
@@ -54,3 +54,165 @@ export interface ProgramAnalyticsSummary {
54
54
  vouchers: VoucherPerformance;
55
55
  dailyTrend: ProgramAnalyticsDay[];
56
56
  }
57
+ /**
58
+ * `GET /v1/console/organizations/{organizationId}/analytics/vouchers`: how each voucher did in the
59
+ * window, for its Owner and Business Developers. Same counting as `VoucherPerformance`, per voucher.
60
+ */
61
+ export interface VoucherPerformanceQuery extends ProgramAnalyticsQuery {
62
+ /** Only this campaign's vouchers. */
63
+ campaignId?: string;
64
+ /** 1–100, default 50. */
65
+ limit?: number;
66
+ }
67
+ export interface VoucherPerformanceRow {
68
+ voucherId: string;
69
+ code: string;
70
+ title: string;
71
+ status: string;
72
+ campaignId: string | null;
73
+ /** Claimed by a customer in the window. */
74
+ claimed: number;
75
+ /** Used at the merchant in the window. */
76
+ redeemed: number;
77
+ /** Claimed copies whose deadline passed unused in the window (up to now). */
78
+ expiredUnused: number;
79
+ }
80
+ /** Vouchers with any activity in the window, most claimed first. */
81
+ export interface VoucherPerformanceList {
82
+ from: string;
83
+ to: string;
84
+ items: VoucherPerformanceRow[];
85
+ }
86
+ /**
87
+ * `GET /v1/console/organizations/{organizationId}/analytics/campaigns`: what each campaign running
88
+ * during the window did in it.
89
+ */
90
+ export interface CampaignPerformanceRow {
91
+ campaignId: string;
92
+ name: string;
93
+ status: string;
94
+ startsAt: string;
95
+ endsAt: string;
96
+ /** CONFIRMED earns its multiplier boosted, in the window. */
97
+ boostedEarns: number;
98
+ /** Points those earns credited, boost included. */
99
+ boostedPoints: number;
100
+ /** Its vouchers claimed in the window. */
101
+ vouchersClaimed: number;
102
+ /** Its vouchers used in the window. */
103
+ vouchersRedeemed: number;
104
+ }
105
+ /** Campaigns whose dates overlap the window, newest start first. */
106
+ export interface CampaignPerformanceList {
107
+ from: string;
108
+ to: string;
109
+ items: CampaignPerformanceRow[];
110
+ }
111
+ /**
112
+ * `GET /v1/console/organizations/{organizationId}/analytics/members`: where the organization's members
113
+ * are now, by their last CONFIRMED earn or redemption. Every enrolled member is in exactly one segment.
114
+ */
115
+ export interface MemberSegments {
116
+ asOf: string;
117
+ /** Last earn or redemption within `activeDays` (30) days. */
118
+ active: number;
119
+ /** Last one between `activeDays` and `dormantDays` (90) days ago: worth a nudge. */
120
+ lapsing: number;
121
+ /** Last one more than `dormantDays` days ago. */
122
+ dormant: number;
123
+ /** Enrolled, never earned or redeemed. */
124
+ neverTransacted: number;
125
+ enrolled: number;
126
+ activeDays: number;
127
+ dormantDays: number;
128
+ }
129
+ /** What Core noticed, for an assistant to explain. Each comes with the numbers behind it. */
130
+ export type ProgramSignalCode =
131
+ /** Points earned fell by 20% or more against the previous period. */
132
+ 'EARN_DOWN'
133
+ /** Points earned rose by 20% or more against the previous period. */
134
+ | 'EARN_UP'
135
+ /** At the current pace, the issuance budget runs out within 14 days. */
136
+ | 'BUDGET_LOW'
137
+ /** Claimed vouchers will expire unused in the next 7 days. */
138
+ | 'VOUCHERS_EXPIRING'
139
+ /** More members are lapsing (30–90 days quiet) than are active. */
140
+ | 'MEMBERS_LAPSING'
141
+ /** Reversed points are 10% or more of points earned. */
142
+ | 'REVERSALS_HIGH';
143
+ export interface ProgramSignal {
144
+ code: ProgramSignalCode;
145
+ /** The figure behind it: a percentage change, days left, a count or a share. */
146
+ value: number;
147
+ }
148
+ /**
149
+ * `GET /v1/console/organizations/{organizationId}/analytics/insights`: one answer to "how are we
150
+ * doing?", for the console and the MCP assistant. The window (default 30 days) against the window of
151
+ * the same length right before it, plus where things are heading.
152
+ */
153
+ export interface ProgramInsights {
154
+ from: string;
155
+ to: string;
156
+ previous: {
157
+ from: string;
158
+ to: string;
159
+ };
160
+ circulation: {
161
+ current: ProgramCirculation;
162
+ previous: ProgramCirculation;
163
+ };
164
+ activeMembers: {
165
+ current: number;
166
+ previous: number;
167
+ };
168
+ vouchers: {
169
+ current: VoucherPerformance;
170
+ previous: VoucherPerformance;
171
+ };
172
+ /** Null when the chain can't be read right now; the rest still answers. */
173
+ budget: {
174
+ remaining: number;
175
+ capacity: number;
176
+ /** Points earned per day in the window, on average. */
177
+ earnedPerDay: number;
178
+ /** `remaining / earnedPerDay`, rounded down; null when nothing was earned. */
179
+ daysLeft: number | null;
180
+ } | null;
181
+ /** Claimed, unused vouchers whose deadline falls in the next `days` days. */
182
+ expiringSoon: {
183
+ days: number;
184
+ vouchers: number;
185
+ };
186
+ segments: MemberSegments;
187
+ /** The three most claimed vouchers in the window. */
188
+ topVouchers: VoucherPerformanceRow[];
189
+ signals: ProgramSignal[];
190
+ }
191
+ /**
192
+ * `GET /v1/console/organizations/{organizationId}/analytics/members/{memberId}`: one member's activity
193
+ * in the window (default 30 days) and over all time, in one read, so nobody pages through their
194
+ * transactions to add them up. CONFIRMED transactions only, counted as the program summary counts: a
195
+ * PENDING earn shows in their transaction list but not here until the chain confirms it.
196
+ */
197
+ export interface MemberActivitySummary {
198
+ memberId: string;
199
+ from: string;
200
+ to: string;
201
+ /** In the window. */
202
+ points: ProgramCirculation;
203
+ /** The same over all time, since they joined. */
204
+ lifetime: ProgramCirculation;
205
+ /** CONFIRMED earns and redemptions in the window. */
206
+ transactions: {
207
+ earns: number;
208
+ redemptions: number;
209
+ };
210
+ /** Over all time: their first and last CONFIRMED earn or redemption; null if none. */
211
+ firstActivityAt: string | null;
212
+ lastActivityAt: string | null;
213
+ /** Unused vouchers they hold now, and vouchers they used in the window. */
214
+ vouchers: {
215
+ held: number;
216
+ usedInWindow: number;
217
+ };
218
+ }
@@ -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"}
@@ -8,6 +8,14 @@ export interface AssistantTurn {
8
8
  /** Plain text of that turn. */
9
9
  text: string;
10
10
  }
11
+ /** The console pages a question can be asked beside. */
12
+ export type AssistantPageName = 'dashboard' | 'insights' | 'vouchers' | 'campaigns' | 'members' | 'transactions' | 'api-keys' | 'webhooks' | 'team' | 'settings';
13
+ /** The page the user has open, for what their question leaves out, such as its period. */
14
+ export interface AssistantPage {
15
+ name: AssistantPageName;
16
+ /** What it shows, such as its period or filters, in one line. At most 300 characters. */
17
+ showing?: string;
18
+ }
11
19
  /** `POST /v1/console/organizations/:organizationId/assistant/messages` */
12
20
  export interface AssistantMessageBody {
13
21
  /** The new question. 1–4000 characters. */
@@ -17,6 +25,14 @@ export interface AssistantMessageBody {
17
25
  * characters together with the new message.
18
26
  */
19
27
  history?: AssistantTurn[];
28
+ /** The user's IANA time zone, such as `Asia/Ho_Chi_Minh`, for "today" and "last week". UTC without it. */
29
+ timeZone?: string;
30
+ /**
31
+ * The browser's id for this chat (a UUID). With it, Core keeps what the tools returned for a short
32
+ * while, so a follow-up need not read it again. It names the chat only among this user's own.
33
+ */
34
+ chatId?: string;
35
+ page?: AssistantPage;
20
36
  }
21
37
  /**
22
38
  * One event of the answer stream (`text/event-stream`; each `data:` line is one JSON event, and the
@@ -32,11 +48,19 @@ export type AssistantStreamEvent =
32
48
  | {
33
49
  type: 'tool';
34
50
  name: string;
51
+ id?: string;
35
52
  }
36
53
  /** That tool failed or was refused, e.g. because the user's access changed. */
37
54
  | {
38
55
  type: 'tool_error';
39
56
  name: string;
57
+ id?: string;
58
+ }
59
+ /** The tool call with this id returned. */
60
+ | {
61
+ type: 'tool_done';
62
+ name: string;
63
+ id: string;
40
64
  }
41
65
  /** The model declined to answer. `category` is the provider's refusal category, when there is one. */
42
66
  | {
@@ -0,0 +1,64 @@
1
+ import type { VoucherBatchActionResult, VoucherDto } from './rewards.js';
2
+ /**
3
+ * DRAFT until an Owner activates it, which approves it. ACTIVE and PAUSED move back and forth;
4
+ * ENDED (by the Owner, or automatically once `endsAt` has passed) and ARCHIVED are final.
5
+ */
6
+ export type CampaignStatus = 'DRAFT' | 'ACTIVE' | 'PAUSED' | 'ENDED' | 'ARCHIVED';
7
+ /** The most an earn may be boosted: 10x, enforced on-chain too. */
8
+ export declare const CAMPAIGN_MAX_MULTIPLIER_BPS = 100000;
9
+ export declare const CAMPAIGN_MAX_NAME_LENGTH = 160;
10
+ export declare const CAMPAIGN_MAX_DESCRIPTION_LENGTH = 2000;
11
+ /**
12
+ * A named, time-boxed promotion (OCT-340). It may boost earn, group vouchers, or both:
13
+ * - Earn: an earn that sends this campaign's id as `campaignId` gets `multiplierBps` on top of the
14
+ * program's rate, while the campaign is ACTIVE and `startsAt <= now <= endsAt`. Otherwise the earn is
15
+ * refused (422), never earned at the base rate instead.
16
+ * - Vouchers: a voucher created with `campaignId`, alone or in a batch, belongs to it.
17
+ */
18
+ export interface CampaignDto {
19
+ id: string;
20
+ organizationId: string;
21
+ name: string;
22
+ description: string | null;
23
+ status: CampaignStatus;
24
+ startsAt: string;
25
+ endsAt: string;
26
+ /** 20000 is 2x. `null`: the campaign boosts no earn, it only groups vouchers. */
27
+ multiplierBps: number | null;
28
+ /** Whether an earn naming it is boosted right now: ACTIVE, within its window, with a multiplier. */
29
+ earnBoostLive: boolean;
30
+ createdByUserId: string | null;
31
+ /** The Owner whose first activation approved it. */
32
+ approvedByUserId: string | null;
33
+ approvedAt: string | null;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ }
37
+ export interface ListCampaignsRequest {
38
+ /** Only campaigns that boost an earn right now (`earnBoostLive`). Defaults to `false`. */
39
+ live?: boolean;
40
+ }
41
+ /** A campaign with its vouchers, in `code` order. */
42
+ export interface CampaignDetailDto extends CampaignDto {
43
+ vouchers: VoucherDto[];
44
+ }
45
+ /** Created as a DRAFT; nothing is boosted until an Owner activates it. */
46
+ export interface CreateCampaignRequest {
47
+ name: string;
48
+ description?: string | null;
49
+ /** ISO 8601. */
50
+ startsAt: string;
51
+ /** ISO 8601, after `startsAt`. */
52
+ endsAt: string;
53
+ /**
54
+ * The earn boost, above 10000 (1x) and at most `CAMPAIGN_MAX_MULTIPLIER_BPS` (10x). Omit or `null` for
55
+ * a campaign that only groups vouchers.
56
+ * @TJS-type ["integer", "null"]
57
+ */
58
+ multiplierBps?: number | null;
59
+ }
60
+ /** `activate`, `pause`, `resume` or `archive` on every voucher of a campaign, with each voucher's outcome. */
61
+ export interface CampaignVoucherActionResponse {
62
+ campaign: CampaignDto;
63
+ vouchers: VoucherBatchActionResult[];
64
+ }
@@ -0,0 +1,5 @@
1
+ /** The most an earn may be boosted: 10x, enforced on-chain too. */
2
+ export const CAMPAIGN_MAX_MULTIPLIER_BPS = 100_000;
3
+ export const CAMPAIGN_MAX_NAME_LENGTH = 160;
4
+ export const CAMPAIGN_MAX_DESCRIPTION_LENGTH = 2000;
5
+ //# sourceMappingURL=campaigns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"campaigns.js","sourceRoot":"","sources":["../src/campaigns.ts"],"names":[],"mappings":"AAQA,mEAAmE;AACnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,CAAC"}
package/dist/console.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ProgramTerms } from './organizations.js';
1
2
  import type { CreateVoucherRequest, UpdateVoucherRequest } from './rewards.js';
2
3
  import type { OrganizationPersona } from './system-users.js';
3
4
  export type OrganizationType = 'INDIVIDUAL_HOUSEHOLD' | 'COMPANY';
@@ -55,8 +56,14 @@ export interface ConsoleOrganization {
55
56
  logoUrl: string | null;
56
57
  /** Business Developers' vouchers need an Owner's approval before they go live. */
57
58
  voucherApprovalRequired: boolean;
59
+ /** IANA time zone its days start in, e.g. `Asia/Ho_Chi_Minh`. */
60
+ timeZone: string;
61
+ /** ISO 4217 code of its purchase amounts, e.g. `VND`. */
62
+ currency: string;
58
63
  /** Returned only to Business Owners. Never the full CCCD. */
59
64
  nationalIdLast4?: string | null;
65
+ /** The loyalty program's current terms; null until a `PROVISION_PROGRAM` request is approved and run. */
66
+ program: ProgramTerms | null;
60
67
  }
61
68
  export interface ConsoleStaff {
62
69
  id: string;
@@ -128,14 +135,18 @@ export interface ConsoleInvitationInput {
128
135
  email: string;
129
136
  persona?: 'BUSINESS_DEVELOPER';
130
137
  }
131
- /** `PATCH /v1/console/organizations/:id/settings`, Owner only. */
138
+ /** `PATCH /v1/console/organizations/:id/settings`, Owner only. Send one field or more. */
132
139
  export interface OrganizationSettingsInput {
133
140
  /**
134
141
  * When on, a Business Developer submits a voucher for approval instead of activating it, and an
135
142
  * API key asking for `ACTIVE` puts it in `PENDING_APPROVAL`. Owners never need approval. Turning
136
143
  * it off leaves vouchers already waiting as they are.
137
144
  */
138
- voucherApprovalRequired: boolean;
145
+ voucherApprovalRequired?: boolean;
146
+ /** An IANA time zone, e.g. `Asia/Ho_Chi_Minh`. */
147
+ timeZone?: string;
148
+ /** An ISO 4217 currency code, e.g. `VND`. */
149
+ currency?: string;
139
150
  }
140
151
  /**
141
152
  * `PATCH /v1/console/organizations/:id/vouchers/:voucherId`. `expectedUpdatedAt` is the voucher's
@@ -0,0 +1,90 @@
1
+ /**
2
+ * CSV exports: the organization's data as a file, for the console and, through a download link, the
3
+ * MCP assistant. `GET /v1/console/organizations/{organizationId}/exports/{dataset}.csv` streams the file
4
+ * to a signed-in user; `POST …/exports` returns a link to it, for 5 minutes, used once.
5
+ *
6
+ * Every file is UTF-8 with a byte order mark (so Excel reads Vietnamese names), comma-separated with
7
+ * RFC 4180 quoting, dates as ISO 8601 in the organization's time zone, and text cells that start
8
+ * with `=`, `+`, `-`, `@` or a control character prefixed with `'` so a spreadsheet never runs them as a
9
+ * formula. Every export is recorded in the organization's audit log (`export.<dataset>`).
10
+ */
11
+ export type ExportDataset = 'transactions' | 'members' | 'vouchers' | 'program-report' | 'audit-log';
12
+ /**
13
+ * Filters, by dataset. `from`/`to` (ISO 8601 with an offset; default the last 30 days, at most 366)
14
+ * apply to every dataset except `members`. `transactions` also takes `type`, `status` and `memberId`;
15
+ * `audit-log` takes `action` (exact, or a prefix ending in `.`).
16
+ */
17
+ export interface ExportQuery {
18
+ from?: string;
19
+ to?: string;
20
+ type?: string;
21
+ status?: string;
22
+ memberId?: string;
23
+ action?: string;
24
+ }
25
+ /** `POST /v1/console/organizations/{organizationId}/exports`. */
26
+ export interface ExportLinkInput extends ExportQuery {
27
+ dataset: ExportDataset;
28
+ }
29
+ /** A download link: anyone holding it downloads the file once, within 5 minutes, as the user who asked. */
30
+ export interface ExportLink {
31
+ dataset: ExportDataset;
32
+ url: string;
33
+ expiresAt: string;
34
+ /** Rows the file holds, counted when the link was made. */
35
+ rows: number;
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
+ }
@@ -0,0 +1,10 @@
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;
10
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
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';
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
@@ -11,10 +11,31 @@ export interface IdentityChangePayload extends OrganizationIdentityInput {
11
11
  export interface GovernanceProposal {
12
12
  requestType: GovernanceRequestType;
13
13
  reason: string;
14
+ /**
15
+ * The program terms are the merchant's to choose and are proposed by the organization's Owner
16
+ * only; a System Admin approves or rejects them with a reason, and never proposes them:
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 once approved.
28
+ * - `PROGRAM_CAP_CHANGE`: `{ budgetCap }`, a positive whole number of points, up or down, but never
29
+ * below what the program is already funded with. Applies on approval, with no chain call.
30
+ */
14
31
  payload: {
15
32
  name?: string;
16
33
  targetUserId?: string;
17
34
  amount?: number;
35
+ earnBps?: number;
36
+ expiryDays?: number;
37
+ totalBudget?: number;
38
+ budgetCap?: number;
18
39
  } & IdentityChangePayload;
19
40
  }
20
41
  export interface GovernanceRequest {
@@ -44,6 +65,47 @@ export interface GovernanceRequestListQuery {
44
65
  /** @format uuid */
45
66
  organizationId?: string;
46
67
  }
68
+ /** `GET /v1/console/organizations/:id/change-requests` query: the organization's own requests. */
69
+ export interface ConsoleChangeRequestListQuery {
70
+ /** 1–100, default 25. */
71
+ limit?: number;
72
+ /** The last page's `nextCursor`. @format uuid */
73
+ cursor?: string;
74
+ status?: GovernanceRequestStatus;
75
+ requestType?: GovernanceRequestType;
76
+ }
77
+ /**
78
+ * The worker command an approved program request queued (`PROVISION_PROGRAM`, `BUDGET_TOP_UP`,
79
+ * `UPDATE_EARN_RATE`). `PENDING`/`PROCESSING`: being applied. `SUBMITTED`: applied. `FAILED`: not
80
+ * applied, nothing reached the chain. `UNKNOWN`: may have reached the chain; OctaP is checking it.
81
+ */
82
+ export interface ChangeRequestCommand {
83
+ operationId: string;
84
+ status: 'PENDING' | 'PROCESSING' | 'SUBMITTED' | 'FAILED' | 'UNKNOWN';
85
+ errorMessage: string | null;
86
+ updatedAt: string;
87
+ }
88
+ /** One of the organization's change requests, as its Owner and Business Developers see it. */
89
+ export interface ConsoleChangeRequest {
90
+ id: string;
91
+ requestType: GovernanceRequestType | 'CREATE_ORGANIZATION';
92
+ status: GovernanceRequestStatus;
93
+ /** What was asked for. Never a CCCD: `UPDATE_IDENTITY` keeps only `nationalIdLast4`. */
94
+ payload: unknown;
95
+ requestedById: string;
96
+ /** The proposer's reason. */
97
+ requestReason: string | null;
98
+ /** The System Admin's reason; null while `PENDING`. */
99
+ reviewReason: string | null;
100
+ reviewedAt: string | null;
101
+ createdAt: string;
102
+ /** Null for a request that queues no command, or one not approved. */
103
+ command: ChangeRequestCommand | null;
104
+ }
105
+ export interface ConsoleChangeRequestPage {
106
+ items: ConsoleChangeRequest[];
107
+ nextCursor: string | null;
108
+ }
47
109
  /** Body of an approve or reject decision. */
48
110
  export interface ReviewDecisionInput {
49
111
  /** 1–1000 characters. */