@octap/contracts 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +6 -3
- package/dist/analytics.d.ts +56 -0
- package/dist/analytics.js +2 -0
- package/dist/analytics.js.map +1 -0
- package/dist/assistant.d.ts +62 -0
- package/dist/assistant.js +6 -0
- package/dist/assistant.js.map +1 -0
- package/dist/audit.d.ts +49 -0
- package/dist/audit.js +7 -0
- package/dist/audit.js.map +1 -0
- package/dist/console.d.ts +172 -0
- package/dist/console.js +2 -0
- package/dist/console.js.map +1 -0
- package/dist/evidence.d.ts +122 -0
- package/dist/evidence.js +9 -0
- package/dist/evidence.js.map +1 -0
- package/dist/governance.d.ts +51 -0
- package/dist/governance.js +2 -0
- package/dist/governance.js.map +1 -0
- package/dist/identity.d.ts +30 -0
- package/dist/identity.js +2 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/loyalty.d.ts +227 -0
- package/dist/loyalty.js +2 -0
- package/dist/loyalty.js.map +1 -0
- package/dist/mcp-auth.d.ts +20 -0
- package/dist/mcp-auth.js +2 -0
- package/dist/mcp-auth.js.map +1 -0
- package/dist/members.d.ts +36 -0
- package/dist/members.js +2 -0
- package/dist/members.js.map +1 -0
- package/dist/organization-events.d.ts +52 -0
- package/dist/organization-events.js +15 -0
- package/dist/organization-events.js.map +1 -0
- package/dist/organizations.d.ts +44 -0
- package/dist/organizations.js +2 -0
- package/dist/organizations.js.map +1 -0
- package/dist/request-logs.d.ts +149 -0
- package/dist/request-logs.js +17 -0
- package/dist/request-logs.js.map +1 -0
- package/dist/rewards.d.ts +430 -0
- package/dist/rewards.js +36 -0
- package/dist/rewards.js.map +1 -0
- package/dist/system-users.d.ts +26 -0
- package/dist/system-users.js +3 -0
- package/dist/system-users.js.map +1 -0
- package/dist/voucher-refunds.d.ts +36 -0
- package/dist/voucher-refunds.js +9 -0
- package/dist/voucher-refunds.js.map +1 -0
- package/dist/webhooks.d.ts +217 -0
- package/dist/webhooks.js +2 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OctaPointees
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
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.
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.js","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/audit.d.ts
ADDED
|
@@ -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"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { CreateVoucherRequest, UpdateVoucherRequest } from './rewards.js';
|
|
2
|
+
import type { OrganizationPersona } from './system-users.js';
|
|
3
|
+
export type OrganizationType = 'INDIVIDUAL_HOUSEHOLD' | 'COMPANY';
|
|
4
|
+
/**
|
|
5
|
+
* `PATCH /v1/console/organizations/:id/profile`: display details, applied immediately. Send at least
|
|
6
|
+
* one field. Legal details (legal name, tax ID, representative, CCCD, type) change only through an
|
|
7
|
+
* `UPDATE_IDENTITY` change request; a legal field sent here must equal the stored value, else 400.
|
|
8
|
+
*/
|
|
9
|
+
export interface OrganizationProfileInput {
|
|
10
|
+
/** 2–160 characters. */
|
|
11
|
+
name?: string;
|
|
12
|
+
/** An `https:` URL of up to 2048 characters, or `null` to remove the logo. */
|
|
13
|
+
logoUrl?: string | null;
|
|
14
|
+
}
|
|
15
|
+
/** The legal details an organization is registered with. */
|
|
16
|
+
export interface OrganizationIdentityInput {
|
|
17
|
+
legalName?: string;
|
|
18
|
+
taxId?: string;
|
|
19
|
+
representativeName?: string;
|
|
20
|
+
/** CCCD, 12 digits, write-only: responses only ever return its last four digits. */
|
|
21
|
+
nationalId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface OrganizationApplicationInput extends OrganizationIdentityInput {
|
|
24
|
+
name: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
organizationType: OrganizationType;
|
|
27
|
+
}
|
|
28
|
+
export interface OrganizationApplication {
|
|
29
|
+
id: string;
|
|
30
|
+
organizationId: string;
|
|
31
|
+
name: string;
|
|
32
|
+
slug: string;
|
|
33
|
+
status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED';
|
|
34
|
+
reason: string | null;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
applicantEmail: string;
|
|
37
|
+
initialOwnerName?: string | null;
|
|
38
|
+
initialOwnerEmail?: string | null;
|
|
39
|
+
organizationType: OrganizationType | null;
|
|
40
|
+
legalName: string | null;
|
|
41
|
+
taxId: string | null;
|
|
42
|
+
representativeName: string | null;
|
|
43
|
+
nationalIdLast4: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface ConsoleOrganization {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
slug: string;
|
|
49
|
+
legalName: string | null;
|
|
50
|
+
taxId: string | null;
|
|
51
|
+
status: string;
|
|
52
|
+
persona: OrganizationPersona;
|
|
53
|
+
organizationType: OrganizationType | null;
|
|
54
|
+
representativeName: string | null;
|
|
55
|
+
logoUrl: string | null;
|
|
56
|
+
/** Business Developers' vouchers need an Owner's approval before they go live. */
|
|
57
|
+
voucherApprovalRequired: boolean;
|
|
58
|
+
/** Returned only to Business Owners. Never the full CCCD. */
|
|
59
|
+
nationalIdLast4?: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface ConsoleStaff {
|
|
62
|
+
id: string;
|
|
63
|
+
fullName: string;
|
|
64
|
+
email: string;
|
|
65
|
+
persona: OrganizationPersona;
|
|
66
|
+
status: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ConsoleInvitation {
|
|
69
|
+
id: string;
|
|
70
|
+
email: string;
|
|
71
|
+
persona: 'BUSINESS_DEVELOPER';
|
|
72
|
+
status: 'PENDING' | 'ACCEPTED' | 'REVOKED' | 'EXPIRED';
|
|
73
|
+
expiresAt: string;
|
|
74
|
+
}
|
|
75
|
+
export interface CreatedConsoleInvitation extends ConsoleInvitation {
|
|
76
|
+
token: string;
|
|
77
|
+
}
|
|
78
|
+
/** An organization's API key as the console lists it: never the raw key or its hash. */
|
|
79
|
+
export interface ConsoleCredential {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
keyPrefix: string;
|
|
83
|
+
scopes: string[];
|
|
84
|
+
status: string;
|
|
85
|
+
/** `SANDBOX` keys never touch real points or the chain (OCT-297). Fixed at issue. */
|
|
86
|
+
environment: ApiCredentialEnvironment;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
/** Approximate: recorded after each authenticated request, not inside it. */
|
|
89
|
+
lastUsedAt: string | null;
|
|
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';
|
|
98
|
+
/** Returned once, when the key is created: store `rawKey` now, it cannot be read again. */
|
|
99
|
+
export interface CreatedConsoleCredential extends ConsoleCredential {
|
|
100
|
+
rawKey: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ConsoleCredentialInput {
|
|
103
|
+
/** 1–100 characters. */
|
|
104
|
+
name: string;
|
|
105
|
+
/**
|
|
106
|
+
* `read` (the default) grants `['read']`; `write` grants `['read', 'write']` and only the Owner may
|
|
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.
|
|
110
|
+
*/
|
|
111
|
+
scope?: 'read' | 'write';
|
|
112
|
+
/** `LIVE` by default. */
|
|
113
|
+
environment?: ApiCredentialEnvironment;
|
|
114
|
+
}
|
|
115
|
+
export interface ConsoleCredentialPatch {
|
|
116
|
+
/** 1–100 characters. */
|
|
117
|
+
name: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ConsoleGoogleLoginInput {
|
|
120
|
+
/** Google ID token from the console sign-in. */
|
|
121
|
+
idToken: string;
|
|
122
|
+
}
|
|
123
|
+
export interface ConsoleStaffAccessPatch {
|
|
124
|
+
status: 'ACTIVE' | 'SUSPENDED';
|
|
125
|
+
}
|
|
126
|
+
export interface ConsoleInvitationInput {
|
|
127
|
+
/** @format email */
|
|
128
|
+
email: string;
|
|
129
|
+
persona?: 'BUSINESS_DEVELOPER';
|
|
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
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creating a voucher from the console session, which is stricter than `CreateVoucherRequest`: it is
|
|
165
|
+
* always a `DRAFT`, activated afterwards with `PATCH { status: 'ACTIVE' }`, and `pointsCost` must be
|
|
166
|
+
* sent (0 for a free reward). The Owner and a Business Developer may create one.
|
|
167
|
+
*/
|
|
168
|
+
export interface ConsoleVoucherInput extends Omit<CreateVoucherRequest, 'status'> {
|
|
169
|
+
pointsCost: number;
|
|
170
|
+
/** Only `DRAFT`, which is also the default; any other status is a 400. */
|
|
171
|
+
status?: 'DRAFT';
|
|
172
|
+
}
|
package/dist/console.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
+
}
|
package/dist/evidence.js
ADDED
|
@@ -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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { OrganizationIdentityInput, OrganizationType } from './console.js';
|
|
2
|
+
export type GovernanceRequestType = 'UPDATE_PROFILE' | 'TRANSFER_OWNERSHIP' | 'DEACTIVATE' | 'BUDGET_TOP_UP' | 'SUSPEND' | 'REINSTATE' | 'UPDATE_IDENTITY';
|
|
3
|
+
/**
|
|
4
|
+
* `UPDATE_IDENTITY` replaces an organization's legal details once a System Admin approves it. Send
|
|
5
|
+
* at least one field; `organizationType` only classifies an organization that has none yet. The
|
|
6
|
+
* stored request keeps only the CCCD's last four digits, never the number.
|
|
7
|
+
*/
|
|
8
|
+
export interface IdentityChangePayload extends OrganizationIdentityInput {
|
|
9
|
+
organizationType?: OrganizationType;
|
|
10
|
+
}
|
|
11
|
+
export interface GovernanceProposal {
|
|
12
|
+
requestType: GovernanceRequestType;
|
|
13
|
+
reason: string;
|
|
14
|
+
payload: {
|
|
15
|
+
name?: string;
|
|
16
|
+
targetUserId?: string;
|
|
17
|
+
amount?: number;
|
|
18
|
+
} & IdentityChangePayload;
|
|
19
|
+
}
|
|
20
|
+
export interface GovernanceRequest {
|
|
21
|
+
id: string;
|
|
22
|
+
organizationId: string | null;
|
|
23
|
+
requestedById: string;
|
|
24
|
+
reviewedById: string | null;
|
|
25
|
+
requesterEmail?: string;
|
|
26
|
+
reviewerEmail?: string | null;
|
|
27
|
+
initialOwnerName?: string | null;
|
|
28
|
+
initialOwnerEmail?: string | null;
|
|
29
|
+
requestType: GovernanceRequestType | 'CREATE_ORGANIZATION';
|
|
30
|
+
status: string;
|
|
31
|
+
payload: unknown;
|
|
32
|
+
reason: string | null;
|
|
33
|
+
reviewedAt: string | null;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
}
|
|
36
|
+
export type GovernanceRequestStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED';
|
|
37
|
+
/** `GET /v1/platform/change-requests` query. */
|
|
38
|
+
export interface GovernanceRequestListQuery {
|
|
39
|
+
/** 1–100, default 25. */
|
|
40
|
+
limit?: number;
|
|
41
|
+
/** @format uuid */
|
|
42
|
+
cursor?: string;
|
|
43
|
+
status?: GovernanceRequestStatus;
|
|
44
|
+
/** @format uuid */
|
|
45
|
+
organizationId?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Body of an approve or reject decision. */
|
|
48
|
+
export interface ReviewDecisionInput {
|
|
49
|
+
/** 1–1000 characters. */
|
|
50
|
+
reason: string;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface GoogleLoginRequest {
|
|
2
|
+
idToken: string;
|
|
3
|
+
}
|
|
4
|
+
export interface GoogleLoginResponse {
|
|
5
|
+
endUserId: string;
|
|
6
|
+
suiAddress: string;
|
|
7
|
+
isNewUser: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface EnrollMemberRequest {
|
|
10
|
+
/** Proves which customer is enrolling; the end user is derived from it, never supplied. */
|
|
11
|
+
idToken: string;
|
|
12
|
+
}
|
|
13
|
+
export interface EnrollMemberResponse {
|
|
14
|
+
organizationEndUserId: string;
|
|
15
|
+
/** The end user the id_token proved, so a caller can check it against the customer it expected. */
|
|
16
|
+
endUserId: string;
|
|
17
|
+
isNewEnrollment: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface VerifyCustomerRequest {
|
|
20
|
+
idToken: string;
|
|
21
|
+
}
|
|
22
|
+
export interface VerifyCustomerResponse {
|
|
23
|
+
/** Null when this Google account has never signed in to OctaP. */
|
|
24
|
+
endUserId: string | null;
|
|
25
|
+
suiAddress: string;
|
|
26
|
+
/** The `organizationEndUserId` in the calling organization; null until the customer enrolls. */
|
|
27
|
+
memberId: string | null;
|
|
28
|
+
/** True only when reward operations will accept this member: enrolled and not blocked. */
|
|
29
|
+
active: boolean;
|
|
30
|
+
}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './loyalty.js';
|
|
2
|
+
export * from './rewards.js';
|
|
3
|
+
export * from './voucher-refunds.js';
|
|
4
|
+
export * from './webhooks.js';
|
|
5
|
+
export * from './organization-events.js';
|
|
6
|
+
export * from './identity.js';
|
|
7
|
+
export * from './system-users.js';
|
|
8
|
+
export * from './console.js';
|
|
9
|
+
export * from './members.js';
|
|
10
|
+
export * from './governance.js';
|
|
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';
|