@octap/contracts 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -1,6 +1,42 @@
1
- # Shared API contracts
2
- Framework-free TypeScript wire types used by the API and both SDKs: `src/loyalty.ts` (points)
3
- and `src/rewards.ts` (vouchers). This package is separate from on-chain Move contracts.
4
- These types also drive the OpenAPI document's request and response schemas (`npm run openapi:schemas`,
5
- see `api/README.md`): a JSDoc comment on a field becomes its description there, and `@format uuid`
6
- becomes its format. Runtime validation and protobuf generation do not exist yet.
1
+ # @octap/contracts
2
+
3
+ TypeScript types for the Octap Core REST API: every request and response body, the webhook events,
4
+ and the status values. `@octap/sdk`, `@octap/browser-sdk`, `@octap/mcp` and `@octap/verify` all use
5
+ them, and so does Core itself.
6
+
7
+ It is types only: nothing here runs, and nothing validates a value at runtime.
8
+
9
+ ```bash
10
+ npm install @octap/contracts
11
+ ```
12
+
13
+ ```ts
14
+ import type { WebhookEvent } from '@octap/contracts';
15
+
16
+ function onEvent(event: WebhookEvent) {
17
+ if (event.type === 'credits.earn.confirmed') {
18
+ // event.data is CreditsChainConfirmedEventData
19
+ }
20
+ }
21
+ ```
22
+
23
+ You don't need this package if you use `@octap/sdk`: it re-exports the types its methods take and
24
+ return. Install it on its own for code that only handles the data, such as a webhook receiver in
25
+ another service or a typed frontend.
26
+
27
+ ## What's in it
28
+
29
+ | Area | Examples |
30
+ | --- | --- |
31
+ | Points | `EarnPointsRequest`, `CreditBalanceSnapshot`, `LoyaltyTransactionDto`, `ReservePosRedemptionResponse` |
32
+ | Vouchers | `VoucherDto`, `VoucherStatus`, `VoucherOwnershipDto`, `VoucherOwnershipStatus`, `ClaimVoucherResponse` |
33
+ | Voucher batches and refunds | `VoucherBatchDto`, `VoucherBatchItem`, `VoucherRefundPolicyDto` |
34
+ | Webhooks | `WebhookEvent` (discriminated on `type`), `WebhookEventType`, `WebhookEventData<T>` |
35
+ | Members and identity | `VerifyCustomerResponse`, `MemberProfile` |
36
+ | Evidence, audit and analytics | `EvidenceBundle`, `AuditLogEntry`, `ProgramAnalyticsSummary` |
37
+
38
+ Each type's JSDoc says what its fields mean. The same comments describe the fields in Core's OpenAPI
39
+ document.
40
+
41
+ This package is not the on-chain Move contracts: those are in `contracts/` in the
42
+ [octap-core repository](https://github.com/OctaPointees/octap-core).
@@ -0,0 +1,56 @@
1
+ /**
2
+ * How an organization's points and vouchers actually moved, for its Owner and Business
3
+ * Developers: `GET /v1/console/organizations/{organizationId}/analytics/summary`. Every figure
4
+ * here is CONFIRMED-only and answers one operating question; nothing is shown just because the
5
+ * data exists. Cross-organization figures (how many merchants OctaP has, platform revenue) are
6
+ * out of scope here — revenue specifically has nothing real behind it yet, since billing is not a
7
+ * live payment flow.
8
+ */
9
+ export interface ProgramAnalyticsQuery {
10
+ /** ISO 8601 date-time with an offset or Z. Defaults to 30 days before `to`; at most 366 days before it. */
11
+ from?: string;
12
+ /** ISO 8601 date-time with an offset or Z. Defaults to now. */
13
+ to?: string;
14
+ }
15
+ /** The program's point economy in the window. `earned`/`redeemed`/`reversed` are unsigned magnitudes. */
16
+ export interface ProgramCirculation {
17
+ /** Points actually granted (CONFIRMED EARN). The liability side: what the organization now owes its customers. */
18
+ earned: number;
19
+ /** Points actually spent (CONFIRMED REDEEM). The proof side: evidence the points are used, not just handed out. */
20
+ redeemed: number;
21
+ /** Points undone because a merchant corrected a mistake (CONFIRMED REVERSAL of an earn or of a redemption). High relative to `earned` flags an issuance quality problem, not a healthy program. */
22
+ reversed: number;
23
+ /** How much the outstanding balance grew this window: `earned - redeemed`, minus reversed earns, plus reversed redemptions (their points go back to the customer). A number that only ever grows means the program is a one-way liability with no redemption behind it. */
24
+ net: number;
25
+ }
26
+ /** Whether enrollment is converting into actual use, not just sign-ups. */
27
+ export interface ProgramEngagement {
28
+ /** Distinct customers with at least one CONFIRMED earn or redeem in the window — people actually using the program now. */
29
+ activeMembers: number;
30
+ /** Everyone ever enrolled in this organization, regardless of the window. Compare to `activeMembers`: a wide gap means enrollment isn't converting to use. */
31
+ enrolledMembers: number;
32
+ }
33
+ /** Whether issued vouchers get used, not just claimed and forgotten. */
34
+ export interface VoucherPerformance {
35
+ /** Vouchers a customer claimed in the window (points spent or a free one taken). */
36
+ claimed: number;
37
+ /** Of all vouchers redeemed at the merchant in the window — the only number here that proves the voucher did its job. */
38
+ redeemed: number;
39
+ /** Claimed vouchers whose `expiresAt` passed unused in the window (up to now): lost value for the customer and wasted issuance budget for the merchant. */
40
+ expiredUnused: number;
41
+ }
42
+ /** One day's earn/redeem totals — the trend behind `circulation`, for a chart. */
43
+ export interface ProgramAnalyticsDay {
44
+ /** Start of the day (UTC midnight), ISO 8601. The first and last day count only what falls inside the window. */
45
+ start: string;
46
+ earned: number;
47
+ redeemed: number;
48
+ }
49
+ export interface ProgramAnalyticsSummary {
50
+ from: string;
51
+ to: string;
52
+ circulation: ProgramCirculation;
53
+ engagement: ProgramEngagement;
54
+ vouchers: VoucherPerformance;
55
+ dailyTrend: ProgramAnalyticsDay[];
56
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":""}
@@ -0,0 +1,62 @@
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
+ /** One earlier turn of the conversation. The browser keeps the history; Core stores none. */
6
+ export interface AssistantTurn {
7
+ role: 'user' | 'assistant';
8
+ /** Plain text of that turn. */
9
+ text: string;
10
+ }
11
+ /** `POST /v1/console/organizations/:organizationId/assistant/messages` */
12
+ export interface AssistantMessageBody {
13
+ /** The new question. 1–4000 characters. */
14
+ message: string;
15
+ /**
16
+ * The conversation so far, oldest first, starting with a user turn. At most 40 turns and 60000
17
+ * characters together with the new message.
18
+ */
19
+ history?: AssistantTurn[];
20
+ }
21
+ /**
22
+ * One event of the answer stream (`text/event-stream`; each `data:` line is one JSON event, and the
23
+ * SSE `event:` name equals `type`). The stream always ends with `done` or `error`.
24
+ */
25
+ export type AssistantStreamEvent =
26
+ /** The next piece of the answer. */
27
+ {
28
+ type: 'text';
29
+ text: string;
30
+ }
31
+ /** The assistant started reading data with this tool, e.g. `find_member`. */
32
+ | {
33
+ type: 'tool';
34
+ name: string;
35
+ }
36
+ /** That tool failed or was refused, e.g. because the user's access changed. */
37
+ | {
38
+ type: 'tool_error';
39
+ name: string;
40
+ }
41
+ /** The model declined to answer. `category` is the provider's refusal category, when there is one. */
42
+ | {
43
+ type: 'refusal';
44
+ category: string | null;
45
+ }
46
+ /** The turn ended. `reason` says why the answer may be incomplete. */
47
+ | {
48
+ type: 'done';
49
+ reason: AssistantStopReason;
50
+ }
51
+ /** The turn failed after the stream started. The message is safe to show. */
52
+ | {
53
+ type: 'error';
54
+ message: string;
55
+ };
56
+ /**
57
+ * - `complete`: the answer is finished.
58
+ * - `tool_limit`: the assistant needed more tool calls than one turn allows; ask a narrower question.
59
+ * - `length`: the answer hit the length limit.
60
+ * - `refused`: see the `refusal` event.
61
+ */
62
+ export type AssistantStopReason = 'complete' | 'tool_limit' | 'length' | 'refused';
@@ -0,0 +1,6 @@
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
+ export {};
6
+ //# sourceMappingURL=assistant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistant.js","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The organization's audit log (OCT-333): who did what, and when. Durable and append-only, written
3
+ * in the transaction of each change. `GET /v1/console/organizations/{organizationId}/audit-log`,
4
+ * Owner only.
5
+ */
6
+ /** A console user, an API key, or OctaP itself (a worker, the chain indexer). */
7
+ export type AuditActorType = 'USER' | 'CREDENTIAL' | 'SYSTEM';
8
+ export interface AuditActorRef {
9
+ type: AuditActorType;
10
+ /** A user id or an API key id; null for SYSTEM. */
11
+ id: string | null;
12
+ /** The user's name, or the key's name and prefix, as they are now. Null for SYSTEM or a removed record. */
13
+ label: string | null;
14
+ }
15
+ export interface AuditLogEntry {
16
+ id: string;
17
+ occurredAt: string;
18
+ actor: AuditActorRef;
19
+ /** `<target>.<verb>` (e.g. `api_key.revoked`, `member.blocked`) or an event type (`credits.earned`). */
20
+ action: string;
21
+ target: {
22
+ type: string;
23
+ id: string | null;
24
+ };
25
+ /** The request's `X-Request-Id`, to match the request log and OctaP's own logs. */
26
+ requestId: string | null;
27
+ /** Field names and non-personal values only, e.g. `{ status: { from: 'ACTIVE', to: 'BLOCKED' } }`. */
28
+ changes: Record<string, unknown> | null;
29
+ }
30
+ /**
31
+ * Newest first. `limit` 1–100 (default 50), `cursor` from the last page's `nextCursor`. `action`
32
+ * matches exactly, or every action under a prefix when it ends with `.` (`api_key.`). Times are
33
+ * ISO 8601.
34
+ */
35
+ export interface AuditLogQuery {
36
+ limit?: number;
37
+ cursor?: string;
38
+ from?: string;
39
+ to?: string;
40
+ actorType?: AuditActorType;
41
+ actorId?: string;
42
+ action?: string;
43
+ targetType?: string;
44
+ targetId?: string;
45
+ }
46
+ export interface AuditLogPage {
47
+ items: AuditLogEntry[];
48
+ nextCursor: string | null;
49
+ }
package/dist/audit.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The organization's audit log (OCT-333): who did what, and when. Durable and append-only, written
3
+ * in the transaction of each change. `GET /v1/console/organizations/{organizationId}/audit-log`,
4
+ * Owner only.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/dist/console.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CreateVoucherRequest } from './rewards.js';
1
+ import type { CreateVoucherRequest, UpdateVoucherRequest } from './rewards.js';
2
2
  import type { OrganizationPersona } from './system-users.js';
3
3
  export type OrganizationType = 'INDIVIDUAL_HOUSEHOLD' | 'COMPANY';
4
4
  /**
@@ -53,6 +53,8 @@ export interface ConsoleOrganization {
53
53
  organizationType: OrganizationType | null;
54
54
  representativeName: string | null;
55
55
  logoUrl: string | null;
56
+ /** Business Developers' vouchers need an Owner's approval before they go live. */
57
+ voucherApprovalRequired: boolean;
56
58
  /** Returned only to Business Owners. Never the full CCCD. */
57
59
  nationalIdLast4?: string | null;
58
60
  }
@@ -80,10 +82,19 @@ export interface ConsoleCredential {
80
82
  keyPrefix: string;
81
83
  scopes: string[];
82
84
  status: string;
85
+ /** `SANDBOX` keys never touch real points or the chain (OCT-297). Fixed at issue. */
86
+ environment: ApiCredentialEnvironment;
83
87
  createdAt: string;
84
88
  /** Approximate: recorded after each authenticated request, not inside it. */
85
89
  lastUsedAt: string | null;
86
90
  }
91
+ /**
92
+ * `LIVE` keys (`octap_live_…`) move real points on-chain. `SANDBOX` keys (`octap_test_…`) earn and
93
+ * redeem against a separate sandbox ledger: same validation and response shapes, no chain, no real
94
+ * balance, no webhooks. A sandbox key may only call the routes that support sandbox; any other
95
+ * write is a 403 with `code: "SANDBOX_NOT_SUPPORTED"`.
96
+ */
97
+ export type ApiCredentialEnvironment = 'LIVE' | 'SANDBOX';
87
98
  /** Returned once, when the key is created: store `rawKey` now, it cannot be read again. */
88
99
  export interface CreatedConsoleCredential extends ConsoleCredential {
89
100
  rawKey: string;
@@ -93,9 +104,13 @@ export interface ConsoleCredentialInput {
93
104
  name: string;
94
105
  /**
95
106
  * `read` (the default) grants `['read']`; `write` grants `['read', 'write']` and only the Owner may
96
- * ask for it. A Business Developer revokes and renames read keys only.
107
+ * ask for it. A Business Developer revokes and renames read keys only. Sandbox keys are the
108
+ * exception: they cannot change anything real, so a Business Developer may create and manage a
109
+ * sandbox `write` key.
97
110
  */
98
111
  scope?: 'read' | 'write';
112
+ /** `LIVE` by default. */
113
+ environment?: ApiCredentialEnvironment;
99
114
  }
100
115
  export interface ConsoleCredentialPatch {
101
116
  /** 1–100 characters. */
@@ -113,10 +128,42 @@ export interface ConsoleInvitationInput {
113
128
  email: string;
114
129
  persona?: 'BUSINESS_DEVELOPER';
115
130
  }
131
+ /** `PATCH /v1/console/organizations/:id/settings`, Owner only. */
132
+ export interface OrganizationSettingsInput {
133
+ /**
134
+ * When on, a Business Developer submits a voucher for approval instead of activating it, and an
135
+ * API key asking for `ACTIVE` puts it in `PENDING_APPROVAL`. Owners never need approval. Turning
136
+ * it off leaves vouchers already waiting as they are.
137
+ */
138
+ voucherApprovalRequired: boolean;
139
+ }
140
+ /**
141
+ * `PATCH /v1/console/organizations/:id/vouchers/:voucherId`. `expectedUpdatedAt` is the voucher's
142
+ * `updatedAt` as the Owner reviewed it. Required when an Owner activates (`status: 'ACTIVE'`) while the
143
+ * organization requires approval: a draft changed since is a 409, so nobody's edit goes live unseen
144
+ * (OCT-324). Ignored otherwise.
145
+ */
146
+ export type ConsoleVoucherPatch = UpdateVoucherRequest & {
147
+ expectedUpdatedAt?: string;
148
+ };
149
+ /**
150
+ * `POST /v1/console/organizations/:id/vouchers/:voucherId/approve`. `approvalRequestId` is the
151
+ * submission the Owner reviewed (`approval.id`): a voucher withdrawn and submitted again since is a 409.
152
+ */
153
+ export interface VoucherApproveInput {
154
+ approvalRequestId: string;
155
+ }
156
+ /** `POST /v1/console/organizations/:id/vouchers/:voucherId/reject`. */
157
+ export interface VoucherRejectInput {
158
+ /** The submission the Owner reviewed (`approval.id`), as for approving. */
159
+ approvalRequestId: string;
160
+ /** 1–500 characters, shown to whoever submitted it. */
161
+ reason: string;
162
+ }
116
163
  /**
117
164
  * Creating a voucher from the console session, which is stricter than `CreateVoucherRequest`: it is
118
165
  * always a `DRAFT`, activated afterwards with `PATCH { status: 'ACTIVE' }`, and `pointsCost` must be
119
- * sent (0 for a free reward). Only the Owner may create one.
166
+ * sent (0 for a free reward). The Owner and a Business Developer may create one.
120
167
  */
121
168
  export interface ConsoleVoucherInput extends Omit<CreateVoucherRequest, 'status'> {
122
169
  pointsCost: number;
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Audit evidence (OCT-77). At the end of each period, Core seals each organization's activity on
3
+ * Sui: its confirmed ledger facts and its audit log rows, hashed into a manifest. Anyone holding a
4
+ * period's bundle can check it against that seal without trusting OctaP (`@octap/verify`).
5
+ *
6
+ * `GET /v1/console/organizations/{organizationId}/evidence…`, Owner only.
7
+ */
8
+ /** `SEALING` while the seal is on its way to the chain, then `SEALED` for good. */
9
+ export type EvidencePeriodStatus = 'SEALING' | 'SEALED';
10
+ /** The encrypted copy on Walrus. `DISABLED` when this deployment keeps no copy, `SKIPPED` for an empty period. */
11
+ export type EvidenceArchiveStatus = 'PENDING' | 'ARCHIVED' | 'DISABLED' | 'SKIPPED';
12
+ /**
13
+ * One loyalty transaction confirmed on-chain during the period. Only facts that never change once
14
+ * confirmed: no status (a reversal is its own fact, in the period it happened) and no checkpoint
15
+ * (filled in later by the indexer).
16
+ */
17
+ export interface EvidenceLedgerFact {
18
+ id: string;
19
+ type: string;
20
+ pointsAmount: number;
21
+ purchaseAmount: number | null;
22
+ /** The member's id in the organization. */
23
+ memberId: string;
24
+ receiptReference: string | null;
25
+ /** On a REVERSAL, the transaction it reverses. */
26
+ reversesTransactionId: string | null;
27
+ /** The Sui transaction that carried it. */
28
+ digest: string;
29
+ confirmedAt: string;
30
+ }
31
+ /** One audit log row of the period (OCT-333). Append-only, so it never changes. */
32
+ export interface EvidenceAuditFact {
33
+ id: string;
34
+ occurredAt: string;
35
+ actorType: string;
36
+ actorId: string | null;
37
+ action: string;
38
+ targetType: string;
39
+ targetId: string | null;
40
+ requestId: string | null;
41
+ changes: Record<string, unknown> | null;
42
+ }
43
+ export interface EvidenceSection {
44
+ count: number;
45
+ /** sha256 (hex) of the section's facts, one canonical JSON line each. */
46
+ sha256: string;
47
+ }
48
+ /** What is sealed: its sha256 is the seal's `manifest_hash`. */
49
+ export interface EvidenceManifest {
50
+ format: 'octap.evidence.manifest/v1';
51
+ organizationId: string;
52
+ periodStart: string;
53
+ periodEnd: string;
54
+ ledger: EvidenceSection;
55
+ audit: EvidenceSection;
56
+ /** The organization's previous sealed manifest, null on its first. */
57
+ previousManifestHash: string | null;
58
+ }
59
+ /** Where a period's seal is on Sui. */
60
+ export interface EvidenceSealReference {
61
+ network: string;
62
+ packageId: string;
63
+ sealObjectId: string;
64
+ transactionDigest: string;
65
+ sealedAt: string;
66
+ }
67
+ /** The file an Owner downloads and hands to an auditor. The same period always gives the same file. */
68
+ export interface EvidenceBundle {
69
+ format: 'octap.evidence/v1';
70
+ manifest: EvidenceManifest;
71
+ manifestHash: string;
72
+ seal: EvidenceSealReference;
73
+ ledger: EvidenceLedgerFact[];
74
+ audit: EvidenceAuditFact[];
75
+ }
76
+ export interface EvidencePeriodSummary {
77
+ id: string;
78
+ periodStart: string;
79
+ periodEnd: string;
80
+ ledgerCount: number;
81
+ auditCount: number;
82
+ status: EvidencePeriodStatus;
83
+ archiveStatus: EvidenceArchiveStatus;
84
+ }
85
+ export interface EvidencePeriodPage {
86
+ /** The end of the organization's latest sealed period, null before its first. */
87
+ sealedThrough: string | null;
88
+ /** How many periods are sealed. */
89
+ periodCount: number;
90
+ /** Newest first. */
91
+ items: EvidencePeriodSummary[];
92
+ nextCursor: string | null;
93
+ }
94
+ export interface EvidencePeriodDetail extends EvidencePeriodSummary {
95
+ manifestHash: string;
96
+ previousManifestHash: string | null;
97
+ /** Null while SEALING. */
98
+ seal: EvidenceSealReference | null;
99
+ archive: {
100
+ status: EvidenceArchiveStatus;
101
+ walrusBlobId: string | null;
102
+ archivedAt: string | null;
103
+ };
104
+ }
105
+ /**
106
+ * For the Console's Verify button: the manifest as sealed, and the same period recomputed from the
107
+ * database now. The browser checks both against the seal read straight from Sui
108
+ * (`verifyRecomputation` in `@octap/verify`), so the verdict never rests on OctaP's word.
109
+ */
110
+ export interface EvidenceRecomputation {
111
+ periodId: string;
112
+ sealedManifest: EvidenceManifest;
113
+ recomputedManifest: EvidenceManifest;
114
+ /** Null while SEALING: there is nothing on-chain to check against yet. */
115
+ seal: EvidenceSealReference | null;
116
+ computedAt: string;
117
+ }
118
+ /** Newest first. `limit` 1–100 (default 30), `cursor` from the last page's `nextCursor`. */
119
+ export interface EvidencePeriodQuery {
120
+ limit?: number;
121
+ cursor?: string;
122
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Audit evidence (OCT-77). At the end of each period, Core seals each organization's activity on
3
+ * Sui: its confirmed ledger facts and its audit log rows, hashed into a manifest. Anyone holding a
4
+ * period's bundle can check it against that seal without trusting OctaP (`@octap/verify`).
5
+ *
6
+ * `GET /v1/console/organizations/{organizationId}/evidence…`, Owner only.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/dist/index.d.ts CHANGED
@@ -2,9 +2,16 @@ export * from './loyalty.js';
2
2
  export * from './rewards.js';
3
3
  export * from './voucher-refunds.js';
4
4
  export * from './webhooks.js';
5
+ export * from './organization-events.js';
5
6
  export * from './identity.js';
6
7
  export * from './system-users.js';
7
8
  export * from './console.js';
8
9
  export * from './members.js';
9
10
  export * from './governance.js';
10
11
  export * from './organizations.js';
12
+ export * from './mcp-auth.js';
13
+ export * from './assistant.js';
14
+ export * from './request-logs.js';
15
+ export * from './audit.js';
16
+ export * from './evidence.js';
17
+ export * from './analytics.js';
package/dist/index.js CHANGED
@@ -2,10 +2,17 @@ export * from './loyalty.js';
2
2
  export * from './rewards.js';
3
3
  export * from './voucher-refunds.js';
4
4
  export * from './webhooks.js';
5
+ export * from './organization-events.js';
5
6
  export * from './identity.js';
6
7
  export * from './system-users.js';
7
8
  export * from './console.js';
8
9
  export * from './members.js';
9
10
  export * from './governance.js';
10
11
  export * from './organizations.js';
12
+ export * from './mcp-auth.js';
13
+ export * from './assistant.js';
14
+ export * from './request-logs.js';
15
+ export * from './audit.js';
16
+ export * from './evidence.js';
17
+ export * from './analytics.js';
11
18
  //# 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,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,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,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
package/dist/loyalty.d.ts CHANGED
@@ -19,6 +19,8 @@ export interface EarnPointsRequest {
19
19
  metadata?: Record<string, unknown>;
20
20
  }
21
21
  export interface EarnPointsResponse {
22
+ /** Present, and true, only on what a sandbox key made or reads (OCT-297). */
23
+ isSandbox?: true;
22
24
  transactionId: string;
23
25
  organizationEndUserId: string;
24
26
  purchaseAmount: number | null;
@@ -48,6 +50,8 @@ export interface ReservePosRedemptionRequest extends PosRedemptionBenefit {
48
50
  idempotencyKey: string;
49
51
  }
50
52
  export interface ReservePosRedemptionResponse {
53
+ /** Present, and true, only on what a sandbox key made or reads (OCT-297). */
54
+ isSandbox?: true;
51
55
  transactionId: string;
52
56
  /** Null only when `status` isn't PENDING — the command already settled on an earlier call. */
53
57
  digest: string | null;
@@ -61,6 +65,8 @@ export interface FinalizePosRedemptionRequest {
61
65
  signature: string;
62
66
  }
63
67
  export interface FinalizePosRedemptionResponse {
68
+ /** Present, and true, only on what a sandbox key made or reads (OCT-297). */
69
+ isSandbox?: true;
64
70
  transactionId: string;
65
71
  organizationEndUserId: string;
66
72
  pointsRedeemed: number;
@@ -69,6 +75,8 @@ export interface FinalizePosRedemptionResponse {
69
75
  blockchainDigest: string;
70
76
  }
71
77
  export interface CreditBalanceSnapshot {
78
+ /** Present, and true, only on what a sandbox key made or reads (OCT-297). */
79
+ isSandbox?: true;
72
80
  organizationEndUserId: string;
73
81
  confirmedBalance: number;
74
82
  pendingEarn: number;
@@ -81,6 +89,8 @@ export interface CreditBalanceSnapshot {
81
89
  observedAt: string;
82
90
  /** True while `pendingEarn`/`pendingRedemption` is nonzero: part of this balance can still change. */
83
91
  stale: boolean;
92
+ /** The member's `CreditAccount` object on Sui; null until their first earn opens it. */
93
+ creditAccountId: string | null;
84
94
  }
85
95
  export interface ReverseTransactionRequest {
86
96
  transactionId: string;
@@ -93,11 +103,11 @@ export interface ReverseTransactionResponse {
93
103
  organizationEndUserId: string;
94
104
  pointsAmount: number;
95
105
  newBalance: number;
96
- /** True when `newBalance` went negative — the member owes points back (clawback debt). */
97
- balanceWentNegative: boolean;
98
106
  idempotencyKey: string;
99
107
  }
100
108
  export interface LoyaltyTransactionDto {
109
+ /** Present, and true, only on what a sandbox key made or reads (OCT-297). */
110
+ isSandbox?: true;
101
111
  id: string;
102
112
  organizationId: string;
103
113
  organizationEndUserId: string;
@@ -105,6 +115,8 @@ export interface LoyaltyTransactionDto {
105
115
  blockchainTransactionId?: string | null;
106
116
  /** The Sui transaction digest, once `blockchainTransactionId` resolves on-chain. */
107
117
  blockchainDigest?: string | null;
118
+ /** When the chain confirmed it; null until then. */
119
+ confirmedAt?: string | null;
108
120
  transactionType: LoyaltyTxType;
109
121
  /** Actual points; null for an unconfirmed earn. */
110
122
  pointsAmount: number | null;
@@ -117,6 +129,11 @@ export interface LoyaltyTransactionDto {
117
129
  createdAt: string;
118
130
  updatedAt: string;
119
131
  }
132
+ /** A page of a member's history, newest first. Pass `nextCursor` back as `cursor` for the next page. */
133
+ export interface LoyaltyTransactionPage {
134
+ items: LoyaltyTransactionDto[];
135
+ nextCursor: string | null;
136
+ }
120
137
  export type BudgetWarningThreshold = 80 | 95;
121
138
  export interface IssuanceBudgetShard {
122
139
  shardId: string;
@@ -146,3 +163,65 @@ export interface IssuanceBudgetDto {
146
163
  recentTopUps: IssuanceBudgetTopUp[];
147
164
  observedAt: string;
148
165
  }
166
+ /**
167
+ * `GET /v1/credits/transactions` and `GET /v1/console/organizations/{organizationId}/transactions`:
168
+ * 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.
170
+ */
171
+ export interface OrganizationTransactionQuery {
172
+ limit?: number;
173
+ cursor?: string;
174
+ type?: LoyaltyTxType;
175
+ status?: LoyaltyTxStatus;
176
+ memberId?: string;
177
+ }
178
+ /**
179
+ * How a member's recorded balance compares with their `CreditAccount` on Sui, read live from the
180
+ * chain's own `credit_account::spendable`:
181
+ * - `MATCH`: the two are equal.
182
+ * - `PENDING`: something for this member is still on its way to the chain (a pending earn or
183
+ * redemption, or a reversal not yet mirrored), so they cannot be compared yet. Ask again shortly.
184
+ * - `MISMATCH`: nothing is in flight and they differ.
185
+ * - `UNAVAILABLE`: the chain could not be read just now.
186
+ */
187
+ export type BalanceReconciliationStatus = 'MATCH' | 'PENDING' | 'MISMATCH' | 'UNAVAILABLE';
188
+ /** `GET …/members/{memberId}/reconciliation`. Cached for up to 30 seconds. */
189
+ export interface BalanceReconciliation {
190
+ organizationEndUserId: string;
191
+ status: BalanceReconciliationStatus;
192
+ /** The member's `CreditAccount` object; null before their first earn (the ledger then holds 0). */
193
+ creditAccountId: string | null;
194
+ /** OctaP's `confirmedBalance`. */
195
+ recordedBalance: number;
196
+ /** What the chain says is spendable now; null when `UNAVAILABLE`. */
197
+ ledgerBalance: number | null;
198
+ /** `ledgerBalance - recordedBalance`; null when `UNAVAILABLE`. */
199
+ difference: number | null;
200
+ checkedAt: string;
201
+ }
202
+ /** The program's published rules as the chain holds them, beside what OctaP applies. */
203
+ export interface ProgramPolicyEvidence {
204
+ policyVersionId: string;
205
+ version: number;
206
+ earnBps: number;
207
+ expiryMs: number;
208
+ /** The transaction that published the policy; null if the chain did not report one. */
209
+ publishedDigest: string | null;
210
+ publishedAt: string | null;
211
+ }
212
+ /**
213
+ * `GET /v1/credits/program` and `GET /v1/console/organizations/{organizationId}/program`: the
214
+ * loyalty program and the on-chain policy behind it. `policyStatus` is `MATCH` when the chain's
215
+ * rules are the ones OctaP applies, `MISMATCH` otherwise, `UNAVAILABLE` when the chain could not be
216
+ * read (then `policy` is null).
217
+ */
218
+ export interface ProgramEvidence {
219
+ programId: string;
220
+ status: string;
221
+ programControlId: string;
222
+ earnBps: number;
223
+ expiryMs: number;
224
+ provisionedAt: string;
225
+ policyStatus: 'MATCH' | 'MISMATCH' | 'UNAVAILABLE';
226
+ policy: ProgramPolicyEvidence | null;
227
+ }