@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
@@ -0,0 +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;AAOlG,MAAM,CAAC,MAAM,gBAAgB,GAA8B;IACzD,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,KAAK;IACL,WAAW;IACX,SAAS;CACV,CAAC;AAaF,MAAM,CAAC,MAAM,kBAAkB,GAAqC;IAClE,qBAAqB;IACrB,SAAS;IACT,SAAS;IACT,aAAa;CACd,CAAC;AAQF,qGAAqG;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AA6HpC,MAAM,CAAC,MAAM,uBAAuB,GAAoC,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAoI/G;;;GAGG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,CAAC;AAI1D,MAAM,CAAC,MAAM,wBAAwB,GAAqC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAiCpF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAOhE,MAAM,CAAC,MAAM,qBAAqB,GAAkC,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAoCxH,qCAAqC;AACrC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,kGAAkG;AAClG,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC"}
package/dist/loyalty.d.ts CHANGED
@@ -17,6 +17,12 @@ export interface EarnPointsRequest {
17
17
  idempotencyKey: string;
18
18
  receiptReference?: string;
19
19
  metadata?: Record<string, unknown>;
20
+ /**
21
+ * A campaign of this organization whose earn boost applies to this purchase (OCT-340). It must be
22
+ * ACTIVE, within its window and have a multiplier, or the earn is refused (422): it is never earned
23
+ * at the base rate instead. Omit for an ordinary earn. One campaign per earn.
24
+ */
25
+ campaignId?: string;
20
26
  }
21
27
  export interface EarnPointsResponse {
22
28
  /** Present, and true, only on what a sandbox key made or reads (OCT-297). */
@@ -155,6 +161,14 @@ export interface IssuanceBudgetDto {
155
161
  initialBudget: number;
156
162
  /** `initialBudget` plus every applied top-up. */
157
163
  capacity: number;
164
+ /** The most the program may ever be funded with, top-ups included (see `ProgramTerms.budgetCap`). */
165
+ budgetCap: number;
166
+ /**
167
+ * How many points a top-up may add right now without review: `budgetCap` minus `initialBudget` and
168
+ * every top-up not known to have failed (queued and unsettled ones count). A larger top-up is
169
+ * refused until a `PROGRAM_CAP_CHANGE` raises the cap.
170
+ */
171
+ topUpHeadroom: number;
158
172
  /** 80 or 95 once the fullest shard has used that percentage of its share, otherwise null. */
159
173
  warningThreshold: BudgetWarningThreshold | null;
160
174
  /** A shard never borrows from another, so an earn can fail while the total is above zero. */
@@ -166,7 +180,7 @@ export interface IssuanceBudgetDto {
166
180
  /**
167
181
  * `GET /v1/credits/transactions` and `GET /v1/console/organizations/{organizationId}/transactions`:
168
182
  * the organization's points history, newest first. `limit` 1–100 (default 25), `cursor` from the
169
- * last page's `nextCursor`; `type`, `status` and `memberId` narrow it.
183
+ * last page's `nextCursor`; `type`, `status`, `memberId` and the `from`/`to` window narrow it.
170
184
  */
171
185
  export interface OrganizationTransactionQuery {
172
186
  limit?: number;
@@ -174,6 +188,10 @@ export interface OrganizationTransactionQuery {
174
188
  type?: LoyaltyTxType;
175
189
  status?: LoyaltyTxStatus;
176
190
  memberId?: string;
191
+ /** Only transactions created at or after this moment. ISO 8601 date-time with an offset or Z. */
192
+ from?: string;
193
+ /** Only transactions created before this moment (excluded), after `from`. ISO 8601 date-time with an offset or Z. */
194
+ to?: string;
177
195
  }
178
196
  /**
179
197
  * How a member's recorded balance compares with their `CreditAccount` on Sui, read live from the
@@ -7,9 +7,10 @@ export interface McpTokenIntrospection {
7
7
  active: true;
8
8
  /** The MCP host's OAuth client id from dynamic registration. */
9
9
  clientId: string;
10
+ /** `mcp` (read), plus `mcp:write` when the user allowed changes at sign-in (OCT-314). */
10
11
  scopes: string[];
11
12
  userId: string;
12
- /** The one organization this token can read. */
13
+ /** The one organization this token can reach. */
13
14
  organizationId: string;
14
15
  /** The user's persona in that organization when the token was issued; Core rechecks it per request. */
15
16
  persona: OrganizationPersona;
@@ -18,3 +19,63 @@ export interface McpTokenIntrospection {
18
19
  /** Expiry in seconds since the epoch. */
19
20
  expiresAt: number;
20
21
  }
22
+ /**
23
+ * `POST /v1/console/organizations/:organizationId/mcp/confirmations` (OCT-314), with an MCP token that
24
+ * has `mcp:write`: a change to show the user before making it. Nothing changes yet.
25
+ */
26
+ export interface McpConfirmationInput {
27
+ method: 'POST' | 'PATCH' | 'PUT' | 'DELETE';
28
+ /** A console route of the token's organization, e.g. `/v1/console/organizations/<id>/vouchers`. */
29
+ path: string;
30
+ /** The JSON body to send; `{}` when the route takes none. */
31
+ body?: Record<string, unknown>;
32
+ /** What the change does, in words the user confirms (1-1000 characters). */
33
+ summary: string;
34
+ }
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
39
+ * the first answer instead of making the change again.
40
+ */
41
+ export interface McpConfirmation {
42
+ confirmationId: string;
43
+ method: McpConfirmationInput['method'];
44
+ path: string;
45
+ body: Record<string, unknown>;
46
+ summary: string;
47
+ expiresAt: string;
48
+ }
49
+ /**
50
+ * One MCP host signed in as the current user (OCT-305): `GET /v1/console/mcp/connections`. Never the
51
+ * token or its hash. Connections from before OCT-305 aren't listed until they expire (within an hour).
52
+ */
53
+ export interface McpConnection {
54
+ /** Opaque; pass it to `DELETE /v1/console/mcp/connections/{connectionId}` to sign the host out. */
55
+ id: string;
56
+ /** The name the host registered with, e.g. "Claude Code". Chosen by the host, so shown as given. */
57
+ clientName: string;
58
+ organization: {
59
+ id: string;
60
+ name: string;
61
+ };
62
+ persona: OrganizationPersona;
63
+ /** Whether the connection may make changes (`mcp:write`), not only read. */
64
+ canMakeChanges: boolean;
65
+ /** ISO 8601. */
66
+ signedInAt: string;
67
+ /** ISO 8601. The host has to sign in again after this. */
68
+ expiresAt: string;
69
+ }
70
+ /** Newest sign-in first. `?organizationId=` lists only one organization's connections. */
71
+ export interface McpConnectionList {
72
+ items: McpConnection[];
73
+ }
74
+ /** `DELETE /v1/console/mcp/connections` (all of the user's) or `…/{connectionId}` (one): how many were signed out. */
75
+ export interface McpConnectionsSignedOut {
76
+ signedOut: number;
77
+ }
78
+ export interface McpConnectionListQuery {
79
+ /** Only this organization's connections. */
80
+ organizationId?: string;
81
+ }
@@ -0,0 +1,71 @@
1
+ import type { OrganizationPersona } from './system-users.js';
2
+ /**
3
+ * MCP tool calls (OCT-296): who used which MCP tool, for which organization, and with what result.
4
+ * Core writes one record per tool call from the requests the MCP server makes with the user's MCP
5
+ * access token, so the MCP process cannot leave a call out.
6
+ * `GET /v1/console/organizations/{organizationId}/mcp-tool-calls`, Owner only.
7
+ */
8
+ /**
9
+ * Every Core request made with an MCP access token names the tool call it serves: the tool, and an
10
+ * id the MCP server draws once per call. A tool that makes several requests (`get_member`) sends the
11
+ * same id on each, so the call is one record. Core refuses an MCP request without them.
12
+ */
13
+ export declare const MCP_TOOL_HEADER = "x-octap-mcp-tool";
14
+ export declare const MCP_CALL_HEADER = "x-octap-mcp-call";
15
+ /** Kept for a year, then deleted by the worker. */
16
+ export declare const MCP_TOOL_CALL_RETENTION_DAYS = 365;
17
+ /**
18
+ * `DENIED`: Core refused the caller (401 or 403). `ERROR`: any other failure, including a 404.
19
+ * When a call's requests end differently, the record keeps the first failure.
20
+ */
21
+ export type McpToolCallOutcome = 'SUCCESS' | 'DENIED' | 'ERROR';
22
+ export interface McpToolCallEntry {
23
+ /** The id the MCP server gave the call. */
24
+ callId: string;
25
+ /** When the call's first request reached Core. */
26
+ occurredAt: string;
27
+ user: {
28
+ id: string;
29
+ /** The user's name or email as it is now; null once the user is removed. */
30
+ label: string | null;
31
+ };
32
+ /** The MCP host's OAuth client id, or `octap-dashboard-assistant` for the dashboard assistant. */
33
+ clientId: string;
34
+ /** The persona the token was issued for. */
35
+ persona: OrganizationPersona;
36
+ tool: string;
37
+ outcome: McpToolCallOutcome;
38
+ /** Core's HTTP status for the request the outcome comes from. */
39
+ httpStatus: number;
40
+ /** That request's `X-Request-Id`, to match OctaP's own logs. */
41
+ requestId: string | null;
42
+ /**
43
+ * Core's own time on the call, summed over its requests, in ms. A slow conversation with small
44
+ * values here is the host and the model, not Core.
45
+ */
46
+ durationMs: number;
47
+ /**
48
+ * Set by write tools only: what the call changed and how it was confirmed. Null on reads. The
49
+ * change itself is in the audit log, under the same request id.
50
+ */
51
+ write: {
52
+ targetType: string | null;
53
+ targetId: string | null;
54
+ confirmationId: string | null;
55
+ idempotencyKey: string | null;
56
+ } | null;
57
+ }
58
+ /** Newest first. `limit` 1–100 (default 50), `cursor` from the last page's `nextCursor`. Times are ISO 8601. */
59
+ export interface McpToolCallQuery {
60
+ limit?: number;
61
+ cursor?: string;
62
+ from?: string;
63
+ to?: string;
64
+ userId?: string;
65
+ tool?: string;
66
+ outcome?: McpToolCallOutcome;
67
+ }
68
+ export interface McpToolCallPage {
69
+ items: McpToolCallEntry[];
70
+ nextCursor: string | null;
71
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * MCP tool calls (OCT-296): who used which MCP tool, for which organization, and with what result.
3
+ * Core writes one record per tool call from the requests the MCP server makes with the user's MCP
4
+ * access token, so the MCP process cannot leave a call out.
5
+ * `GET /v1/console/organizations/{organizationId}/mcp-tool-calls`, Owner only.
6
+ */
7
+ /**
8
+ * Every Core request made with an MCP access token names the tool call it serves: the tool, and an
9
+ * id the MCP server draws once per call. A tool that makes several requests (`get_member`) sends the
10
+ * same id on each, so the call is one record. Core refuses an MCP request without them.
11
+ */
12
+ export const MCP_TOOL_HEADER = 'x-octap-mcp-tool';
13
+ export const MCP_CALL_HEADER = 'x-octap-mcp-call';
14
+ /** Kept for a year, then deleted by the worker. */
15
+ export const MCP_TOOL_CALL_RETENTION_DAYS = 365;
16
+ //# sourceMappingURL=mcp-tool-calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-tool-calls.js","sourceRoot":"","sources":["../src/mcp-tool-calls.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD,mDAAmD;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Which members (OCT-376), for a program's Owner and Business Developers, so a question such as "who
3
+ * earned the most this month?" is one read instead of a walk through the ledger:
4
+ * `GET /v1/console/organizations/{organizationId}/analytics/top-members` and `…/member-segments`.
5
+ * `MemberSegments` (`…/analytics/members`) counts members by activity; these name them.
6
+ *
7
+ * Every figure means what it means in `ProgramAnalyticsSummary`: CONFIRMED transactions only, in
8
+ * `[from, to)`, the last 30 days by default and at most 366 days.
9
+ */
10
+ /** A member as a ranking or a segment lists it. No contact details: those are on the member's own page. */
11
+ export interface InsightMember {
12
+ memberId: string;
13
+ /** The customer's display name, when they have one. */
14
+ name: string | null;
15
+ /** The merchant's own id for this member, when it has one. */
16
+ externalMemberId: string | null;
17
+ status: string;
18
+ /** Confirmed points they can spend now, whatever the window. */
19
+ balance: number;
20
+ joinedAt: string;
21
+ }
22
+ /**
23
+ * - `earned`, `redeemed`: points in the window.
24
+ * - `transactions`: how many earns and redemptions in the window, the most active first.
25
+ * - `balance`: points held now; the window does not change it.
26
+ */
27
+ export type TopMembersMetric = 'earned' | 'redeemed' | 'transactions' | 'balance';
28
+ export interface TopMembersQuery {
29
+ /** Defaults to `transactions`. */
30
+ metric?: TopMembersMetric;
31
+ from?: string;
32
+ to?: string;
33
+ /** 1-50, default 10. */
34
+ limit?: string;
35
+ }
36
+ export interface TopMember extends InsightMember {
37
+ earned: number;
38
+ redeemed: number;
39
+ transactions: number;
40
+ }
41
+ export interface TopMembers {
42
+ from: string;
43
+ to: string;
44
+ metric: TopMembersMetric;
45
+ /** Highest first. Members with none of the metric are left out. */
46
+ items: TopMember[];
47
+ }
48
+ /**
49
+ * - `never_redeemed`: holds points now and never had a confirmed redemption, ever.
50
+ * - `inactive`: enrolled before the window and neither earned nor redeemed in it.
51
+ * - `new`: enrolled in the window.
52
+ */
53
+ export type MemberSegment = 'never_redeemed' | 'inactive' | 'new';
54
+ export interface MemberSegmentQuery {
55
+ segment: MemberSegment;
56
+ from?: string;
57
+ to?: string;
58
+ /** From 1. */
59
+ page?: string;
60
+ /** 1-50, default 20. */
61
+ limit?: string;
62
+ }
63
+ export interface MemberSegmentPage {
64
+ from: string;
65
+ to: string;
66
+ segment: MemberSegment;
67
+ /** Largest balance first, except `new`: the newest first. */
68
+ items: InsightMember[];
69
+ page: number;
70
+ limit: number;
71
+ /** Everyone in the segment, not only this page. */
72
+ total: number;
73
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Which members (OCT-376), for a program's Owner and Business Developers, so a question such as "who
3
+ * earned the most this month?" is one read instead of a walk through the ledger:
4
+ * `GET /v1/console/organizations/{organizationId}/analytics/top-members` and `…/member-segments`.
5
+ * `MemberSegments` (`…/analytics/members`) counts members by activity; these name them.
6
+ *
7
+ * Every figure means what it means in `ProgramAnalyticsSummary`: CONFIRMED transactions only, in
8
+ * `[from, to)`, the last 30 days by default and at most 366 days.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=member-insights.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member-insights.js","sourceRoot":"","sources":["../src/member-insights.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
package/dist/members.d.ts CHANGED
@@ -6,10 +6,17 @@ export interface MemberDirectoryQuery {
6
6
  status?: 'ACTIVE' | 'BLOCKED';
7
7
  externalMemberId?: string;
8
8
  }
9
- /** `GET …/members/{memberId}/transactions`: `limit` 1–100 (default 25), `cursor` from the last page. */
9
+ /**
10
+ * `GET …/members/{memberId}/transactions`: `limit` 1–100 (default 25), `cursor` from the last page,
11
+ * and an optional `from`/`to` window.
12
+ */
10
13
  export interface MemberTransactionQuery {
11
14
  limit?: number;
12
15
  cursor?: string;
16
+ /** Only transactions created at or after this moment. ISO 8601 date-time with an offset or Z. */
17
+ from?: string;
18
+ /** Only transactions created before this moment (excluded), after `from`. ISO 8601 date-time with an offset or Z. */
19
+ to?: string;
13
20
  }
14
21
  export interface MemberProfile {
15
22
  id: string;
@@ -0,0 +1,234 @@
1
+ import type { GovernanceRequestType } from './governance.js';
2
+ import type { LicenseState, LicenseTier, PaymentTransferStatus } from './licensing.js';
3
+ import type { OrganizationEventData, OrganizationEventType } from './organization-events.js';
4
+ /**
5
+ * In-app notifications (OCT-30), for the business console and the platform portal. Two layers that
6
+ * never mix:
7
+ *
8
+ * - **Feed**: organization events (the outbox) that need a person, newest first, with an unread count
9
+ * kept by a per-user read mark. Reading clears the count and nothing else.
10
+ * - **Open items**: things still waiting for someone (a voucher to approve, a license to renew, a
11
+ * transfer to settle), read live from their own records. One leaves the list only when it is
12
+ * resolved, never because it was read.
13
+ */
14
+ /** How urgent a notification is, most urgent first. */
15
+ export type NotificationSeverity = 'ACTION' | 'WARNING' | 'INFO';
16
+ export declare const NOTIFICATION_SEVERITIES: readonly NotificationSeverity[];
17
+ /**
18
+ * Who in the organization a console notification is for. `OWNER`: the Owner only, for what only an
19
+ * Owner can resolve (billing, budget, program terms). `MEMBER`: the Owner and Business Developers.
20
+ */
21
+ export type NotificationAudience = 'OWNER' | 'MEMBER';
22
+ /** What an open item is waiting for. Add a kind to `OpenItemCountsByKind` too. */
23
+ export type OpenItemKind = 'voucherApproval' | 'voucherPublishFailed' | 'licenseRenewal' | 'paymentUnderpaid' | 'organizationApplication' | 'changeRequest' | 'paymentTransfer';
24
+ /** How long a grouped notification's bucket lasts, aligned to the clock (14:00, 14:15, …). */
25
+ export declare const NOTIFICATION_GROUP_WINDOW_MINUTES = 15;
26
+ /** Whether and how an event type notifies. */
27
+ export interface NotificationRule<T extends OrganizationEventType> {
28
+ /** In the organization's console. */
29
+ console?: {
30
+ audience: NotificationAudience;
31
+ severity: (data: OrganizationEventData<T>) => NotificationSeverity;
32
+ };
33
+ /** In the platform portal. `null` from `severity`: this one does not notify the platform. */
34
+ platform?: {
35
+ severity: (data: OrganizationEventData<T>) => NotificationSeverity | null;
36
+ };
37
+ /**
38
+ * Events of this type with the same value of this payload field, in the same
39
+ * `NOTIFICATION_GROUP_WINDOW_MINUTES` bucket, show as one notification with a count. Each event is
40
+ * still recorded on its own; grouping happens only when the feed is read.
41
+ */
42
+ groupBy?: string;
43
+ /** Open items this event may have changed: a client refetches them when it arrives. */
44
+ resolves?: readonly OpenItemKind[];
45
+ }
46
+ /**
47
+ * Every organization event type's rule, or `null` when it never notifies: a routine success the
48
+ * person who caused it already knows about. Typed over every `OrganizationEventType`, so a new event
49
+ * type does not compile until it says whether it notifies.
50
+ */
51
+ export declare const NOTIFICATION_RULES: {
52
+ [T in OrganizationEventType]: NotificationRule<T> | null;
53
+ };
54
+ /** The rule for `type`, or `null` for a type this build does not know or that never notifies. */
55
+ export declare function notificationRuleOf(type: string): NotificationRule<OrganizationEventType> | null;
56
+ /**
57
+ * One notification in a feed: one event, or a group of events of the same kind in one bucket (see
58
+ * `NotificationRule.groupBy`). `id` and `data` are the latest event's; `sequence` is its sequence and
59
+ * the feed's cursor. A group whose newest event is past the read mark is unread again.
60
+ */
61
+ export interface Notification {
62
+ id: string;
63
+ sequence: number;
64
+ type: OrganizationEventType;
65
+ severity: NotificationSeverity;
66
+ organizationId: string;
67
+ /** How many events it stands for: 1, or more for a group. */
68
+ count: number;
69
+ /** When its first and latest events happened. */
70
+ firstAt: string;
71
+ lastAt: string;
72
+ /** The latest event's payload, as its webhook carries it (`OrganizationEventData`). */
73
+ data: Record<string, unknown>;
74
+ unread: boolean;
75
+ }
76
+ export interface NotificationPage {
77
+ items: Notification[];
78
+ /**
79
+ * Pass as `beforeSequence` for the next, older page; `null` once there is no more. A page can
80
+ * hold fewer than `limit` items and still have a next one.
81
+ */
82
+ nextBeforeSequence: number | null;
83
+ /**
84
+ * In the main view: whether there are notifications from before the user's first look at this
85
+ * feed, shown only when asked for with `earlier` (a "show earlier" control). Always `false` in
86
+ * the `earlier` view.
87
+ */
88
+ hasEarlier: boolean;
89
+ }
90
+ /**
91
+ * `GET …/notifications`. `limit` 1–100, default 30. The main view starts at the user's first look at
92
+ * the feed: a newcomer does not see what happened before they arrived. `earlier: true` reads those
93
+ * older notifications instead, newest first, with the same paging.
94
+ */
95
+ export interface NotificationListQuery {
96
+ beforeSequence?: number;
97
+ limit?: number;
98
+ earlier?: boolean;
99
+ }
100
+ /** `GET /v1/platform/notifications`: also narrowed to one organization, or to one severity. */
101
+ export interface PlatformNotificationListQuery extends NotificationListQuery {
102
+ organizationId?: string;
103
+ severity?: NotificationSeverity;
104
+ }
105
+ /**
106
+ * `POST …/notifications/read`: marks everything up to `upToSequence` (the newest `sequence` the
107
+ * client has shown) read. The mark only moves forward.
108
+ */
109
+ export interface MarkNotificationsReadInput {
110
+ upToSequence: number;
111
+ }
112
+ export interface NotificationReadMark {
113
+ lastReadSequence: number;
114
+ }
115
+ /** An open item, by what it is waiting for. Every one is waiting for an action, so it has no severity. */
116
+ export type OpenItem = {
117
+ kind: 'voucherApproval';
118
+ /** The approval request. */
119
+ id: string;
120
+ organizationId: string;
121
+ createdAt: string;
122
+ voucherId: string;
123
+ voucherCode: string;
124
+ voucherTitle: string;
125
+ } | {
126
+ kind: 'voucherPublishFailed';
127
+ /** The voucher. */
128
+ id: string;
129
+ organizationId: string;
130
+ createdAt: string;
131
+ voucherCode: string;
132
+ voucherTitle: string;
133
+ } | {
134
+ kind: 'licenseRenewal';
135
+ /** The license. */
136
+ id: string;
137
+ organizationId: string;
138
+ createdAt: string;
139
+ state: Exclude<LicenseState, 'ACTIVE'>;
140
+ tier: LicenseTier;
141
+ planName: string;
142
+ endsAt: string;
143
+ graceEndsAt: string;
144
+ } | {
145
+ kind: 'paymentUnderpaid';
146
+ /** The order. */
147
+ id: string;
148
+ organizationId: string;
149
+ createdAt: string;
150
+ paymentCode: string;
151
+ expectedVnd: number;
152
+ /** What the short transfers for it added up to so far. */
153
+ receivedVnd: number;
154
+ orderExpiresAt: string;
155
+ } | {
156
+ kind: 'organizationApplication';
157
+ /** The change request. */
158
+ id: string;
159
+ organizationId: string;
160
+ createdAt: string;
161
+ organizationName: string;
162
+ } | {
163
+ kind: 'changeRequest';
164
+ /** The change request. */
165
+ id: string;
166
+ organizationId: string;
167
+ createdAt: string;
168
+ requestType: GovernanceRequestType;
169
+ } | {
170
+ kind: 'paymentTransfer';
171
+ /** The transfer. */
172
+ id: string;
173
+ /** `null`: the transfer named no organization (no code, or an unknown one). */
174
+ organizationId: string | null;
175
+ createdAt: string;
176
+ status: Extract<PaymentTransferStatus, 'UNMATCHED' | 'MATCHED'>;
177
+ reason: string | null;
178
+ amountVnd: number;
179
+ /** For a MATCHED transfer: what was paid above the order and not yet sent back. */
180
+ owedRefundVnd: number;
181
+ };
182
+ /**
183
+ * How many open items of each kind; a kind with none is left out. Spelled out rather than
184
+ * `Partial<Record<OpenItemKind, number>>`, whose generated schema name would carry a file path.
185
+ */
186
+ export interface OpenItemCountsByKind {
187
+ voucherApproval?: number;
188
+ voucherPublishFailed?: number;
189
+ licenseRenewal?: number;
190
+ paymentUnderpaid?: number;
191
+ organizationApplication?: number;
192
+ changeRequest?: number;
193
+ paymentTransfer?: number;
194
+ }
195
+ export interface OpenItemCounts {
196
+ total: number;
197
+ byKind: OpenItemCountsByKind;
198
+ }
199
+ /** `GET /v1/console/organizations/:id/notifications/summary`. */
200
+ export interface NotificationSummary {
201
+ /** Unread notifications, counted up to `NOTIFICATION_UNREAD_CAP` (show "99+" past it). */
202
+ unread: number;
203
+ openItems: OpenItemCounts;
204
+ lastReadSequence: number;
205
+ }
206
+ /** The unread count stops counting here. */
207
+ export declare const NOTIFICATION_UNREAD_CAP = 100;
208
+ /** `GET …/notifications/open-items` in the console: oldest first. */
209
+ export interface OpenItemList {
210
+ items: OpenItem[];
211
+ }
212
+ /** One organization's share of the platform's open items. `organizationId` null: no organization. */
213
+ export interface PlatformOpenItemGroup {
214
+ organizationId: string | null;
215
+ organizationName: string | null;
216
+ items: OpenItem[];
217
+ }
218
+ /** `GET /v1/platform/notifications/open-items`: grouped by organization, the busiest first. */
219
+ export interface PlatformOpenItemList {
220
+ groups: PlatformOpenItemGroup[];
221
+ }
222
+ /** `GET /v1/platform/notifications/open-items`: `organizationId` narrows it to one organization. */
223
+ export interface PlatformOpenItemQuery {
224
+ organizationId?: string;
225
+ }
226
+ /** `GET /v1/platform/notifications/summary`, polled by the portal. */
227
+ export interface PlatformNotificationSummary extends NotificationSummary {
228
+ /** Organizations with open items, the busiest first (at most 20). */
229
+ organizations: {
230
+ organizationId: string | null;
231
+ organizationName: string | null;
232
+ openItems: number;
233
+ }[];
234
+ }