@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/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/** Draft boundary types from the knowledge base; wire schemas remain to be designed. */
|
|
2
|
+
export type Points = string;
|
|
3
|
+
export interface BalanceSnapshot {
|
|
4
|
+
confirmed_balance: Points;
|
|
5
|
+
pending_earn: Points;
|
|
6
|
+
pending_redemption: Points;
|
|
7
|
+
as_of_checkpoint: string;
|
|
8
|
+
observed_at: string;
|
|
9
|
+
stale: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type LoyaltyTxType = 'EARN' | 'REDEEM' | 'REVERSAL' | 'TRANSFER' | 'EXPIRY' | 'ADJUSTMENT';
|
|
12
|
+
export type LoyaltyTxStatus = 'PENDING' | 'CONFIRMED' | 'FAILED' | 'REVERSED';
|
|
13
|
+
export interface EarnPointsRequest {
|
|
14
|
+
organizationEndUserId: string;
|
|
15
|
+
/** Purchase amount in the program currency minor unit; the chain applies earn_bps. */
|
|
16
|
+
purchaseAmount: number;
|
|
17
|
+
idempotencyKey: string;
|
|
18
|
+
receiptReference?: string;
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface EarnPointsResponse {
|
|
22
|
+
/** Present, and true, only on what a sandbox key made or reads (OCT-297). */
|
|
23
|
+
isSandbox?: true;
|
|
24
|
+
transactionId: string;
|
|
25
|
+
organizationEndUserId: string;
|
|
26
|
+
purchaseAmount: number | null;
|
|
27
|
+
/** Estimate at acceptance, never spendable before chain confirmation. */
|
|
28
|
+
estimatedPoints: number | null;
|
|
29
|
+
/** Actual chain-confirmed points, null while pending or failed. */
|
|
30
|
+
pointsEarned: number | null;
|
|
31
|
+
newBalance: number;
|
|
32
|
+
status: LoyaltyTxStatus;
|
|
33
|
+
idempotencyKey: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What the customer gets for the points: a discount on one of your orders. It is hashed into the
|
|
37
|
+
* on-chain redemption the customer signs, so the chain records what each spend paid for.
|
|
38
|
+
*/
|
|
39
|
+
export interface PosRedemptionBenefit {
|
|
40
|
+
/** Your own order id. Must hold no personal data. */
|
|
41
|
+
orderReference: string;
|
|
42
|
+
/** The discount on that order, in `currency`'s major units (e.g. 25000 for 25.000 VND). */
|
|
43
|
+
discountAmount: number;
|
|
44
|
+
/** ISO 4217 code, e.g. `VND`. */
|
|
45
|
+
currency: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ReservePosRedemptionRequest extends PosRedemptionBenefit {
|
|
48
|
+
organizationEndUserId: string;
|
|
49
|
+
pointsAmount: number;
|
|
50
|
+
idempotencyKey: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ReservePosRedemptionResponse {
|
|
53
|
+
/** Present, and true, only on what a sandbox key made or reads (OCT-297). */
|
|
54
|
+
isSandbox?: true;
|
|
55
|
+
transactionId: string;
|
|
56
|
+
/** Null only when `status` isn't PENDING — the command already settled on an earlier call. */
|
|
57
|
+
digest: string | null;
|
|
58
|
+
/** Base64 full transaction bytes for the member's device to sign. Null alongside `digest`. */
|
|
59
|
+
transactionBytes: string | null;
|
|
60
|
+
status: LoyaltyTxStatus;
|
|
61
|
+
idempotencyKey: string;
|
|
62
|
+
}
|
|
63
|
+
export interface FinalizePosRedemptionRequest {
|
|
64
|
+
digest: string;
|
|
65
|
+
signature: string;
|
|
66
|
+
}
|
|
67
|
+
export interface FinalizePosRedemptionResponse {
|
|
68
|
+
/** Present, and true, only on what a sandbox key made or reads (OCT-297). */
|
|
69
|
+
isSandbox?: true;
|
|
70
|
+
transactionId: string;
|
|
71
|
+
organizationEndUserId: string;
|
|
72
|
+
pointsRedeemed: number;
|
|
73
|
+
newBalance: number;
|
|
74
|
+
status: LoyaltyTxStatus;
|
|
75
|
+
blockchainDigest: string;
|
|
76
|
+
}
|
|
77
|
+
export interface CreditBalanceSnapshot {
|
|
78
|
+
/** Present, and true, only on what a sandbox key made or reads (OCT-297). */
|
|
79
|
+
isSandbox?: true;
|
|
80
|
+
organizationEndUserId: string;
|
|
81
|
+
confirmedBalance: number;
|
|
82
|
+
pendingEarn: number;
|
|
83
|
+
pendingRedemption: number;
|
|
84
|
+
lifetimeEarned: number;
|
|
85
|
+
lifetimeRedeemed: number;
|
|
86
|
+
/** Last Sui checkpoint the indexer has projected; null until the indexer has seen any event. */
|
|
87
|
+
asOfCheckpoint: string | null;
|
|
88
|
+
/** When this snapshot was read (ISO 8601). */
|
|
89
|
+
observedAt: string;
|
|
90
|
+
/** True while `pendingEarn`/`pendingRedemption` is nonzero: part of this balance can still change. */
|
|
91
|
+
stale: boolean;
|
|
92
|
+
/** The member's `CreditAccount` object on Sui; null until their first earn opens it. */
|
|
93
|
+
creditAccountId: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface ReverseTransactionRequest {
|
|
96
|
+
transactionId: string;
|
|
97
|
+
idempotencyKey: string;
|
|
98
|
+
reason: string;
|
|
99
|
+
}
|
|
100
|
+
export interface ReverseTransactionResponse {
|
|
101
|
+
reversalTransactionId: string;
|
|
102
|
+
reversedTransactionId: string;
|
|
103
|
+
organizationEndUserId: string;
|
|
104
|
+
pointsAmount: number;
|
|
105
|
+
newBalance: number;
|
|
106
|
+
idempotencyKey: string;
|
|
107
|
+
}
|
|
108
|
+
export interface LoyaltyTransactionDto {
|
|
109
|
+
/** Present, and true, only on what a sandbox key made or reads (OCT-297). */
|
|
110
|
+
isSandbox?: true;
|
|
111
|
+
id: string;
|
|
112
|
+
organizationId: string;
|
|
113
|
+
organizationEndUserId: string;
|
|
114
|
+
createdByMembershipId?: string | null;
|
|
115
|
+
blockchainTransactionId?: string | null;
|
|
116
|
+
/** The Sui transaction digest, once `blockchainTransactionId` resolves on-chain. */
|
|
117
|
+
blockchainDigest?: string | null;
|
|
118
|
+
/** When the chain confirmed it; null until then. */
|
|
119
|
+
confirmedAt?: string | null;
|
|
120
|
+
transactionType: LoyaltyTxType;
|
|
121
|
+
/** Actual points; null for an unconfirmed earn. */
|
|
122
|
+
pointsAmount: number | null;
|
|
123
|
+
purchaseAmount?: number | null;
|
|
124
|
+
estimatedPoints?: number | null;
|
|
125
|
+
idempotencyKey: string;
|
|
126
|
+
receiptReference?: string | null;
|
|
127
|
+
status: LoyaltyTxStatus;
|
|
128
|
+
metadata?: Record<string, unknown> | null;
|
|
129
|
+
createdAt: string;
|
|
130
|
+
updatedAt: string;
|
|
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
|
+
}
|
|
137
|
+
export type BudgetWarningThreshold = 80 | 95;
|
|
138
|
+
export interface IssuanceBudgetShard {
|
|
139
|
+
shardId: string;
|
|
140
|
+
remaining: number;
|
|
141
|
+
}
|
|
142
|
+
export interface IssuanceBudgetTopUp {
|
|
143
|
+
operationId: string;
|
|
144
|
+
amount: number;
|
|
145
|
+
/** PENDING or PROCESSING until the chain answers; UNKNOWN needs an operator and is never retried. */
|
|
146
|
+
status: string;
|
|
147
|
+
createdAt: string;
|
|
148
|
+
}
|
|
149
|
+
/** How many more points a program may issue. Points, not money: no payment is involved. */
|
|
150
|
+
export interface IssuanceBudgetDto {
|
|
151
|
+
organizationId: string;
|
|
152
|
+
/** Live from the chain. Earns still in flight are not subtracted yet. */
|
|
153
|
+
remaining: number;
|
|
154
|
+
/** The figure set at provisioning, before any top-up. */
|
|
155
|
+
initialBudget: number;
|
|
156
|
+
/** `initialBudget` plus every applied top-up. */
|
|
157
|
+
capacity: number;
|
|
158
|
+
/** 80 or 95 once the fullest shard has used that percentage of its share, otherwise null. */
|
|
159
|
+
warningThreshold: BudgetWarningThreshold | null;
|
|
160
|
+
/** A shard never borrows from another, so an earn can fail while the total is above zero. */
|
|
161
|
+
shards: IssuanceBudgetShard[];
|
|
162
|
+
/** Latest first, at most 20. */
|
|
163
|
+
recentTopUps: IssuanceBudgetTopUp[];
|
|
164
|
+
observedAt: string;
|
|
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
|
+
}
|
package/dist/loyalty.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loyalty.js","sourceRoot":"","sources":["../src/loyalty.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OrganizationPersona } from './system-users.js';
|
|
2
|
+
/**
|
|
3
|
+
* `GET /v1/console/mcp/token`: what an MCP access token is bound to, for the MCP server (an OAuth
|
|
4
|
+
* resource server) to check on every request. Answered only for a live token; any other is a 401.
|
|
5
|
+
*/
|
|
6
|
+
export interface McpTokenIntrospection {
|
|
7
|
+
active: true;
|
|
8
|
+
/** The MCP host's OAuth client id from dynamic registration. */
|
|
9
|
+
clientId: string;
|
|
10
|
+
scopes: string[];
|
|
11
|
+
userId: string;
|
|
12
|
+
/** The one organization this token can read. */
|
|
13
|
+
organizationId: string;
|
|
14
|
+
/** The user's persona in that organization when the token was issued; Core rechecks it per request. */
|
|
15
|
+
persona: OrganizationPersona;
|
|
16
|
+
/** The RFC 8707 resource (the MCP server URL) the token was issued for. */
|
|
17
|
+
resource: string;
|
|
18
|
+
/** Expiry in seconds since the epoch. */
|
|
19
|
+
expiresAt: number;
|
|
20
|
+
}
|
package/dist/mcp-auth.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-auth.js","sourceRoot":"","sources":["../src/mcp-auth.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CreditBalanceSnapshot } from './loyalty.js';
|
|
2
|
+
export interface MemberDirectoryQuery {
|
|
3
|
+
limit?: number;
|
|
4
|
+
cursor?: string;
|
|
5
|
+
q?: string;
|
|
6
|
+
status?: 'ACTIVE' | 'BLOCKED';
|
|
7
|
+
externalMemberId?: string;
|
|
8
|
+
}
|
|
9
|
+
/** `GET …/members/{memberId}/transactions`: `limit` 1–100 (default 25), `cursor` from the last page. */
|
|
10
|
+
export interface MemberTransactionQuery {
|
|
11
|
+
limit?: number;
|
|
12
|
+
cursor?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MemberProfile {
|
|
15
|
+
id: string;
|
|
16
|
+
endUserId: string;
|
|
17
|
+
displayName: string | null;
|
|
18
|
+
email: string | null;
|
|
19
|
+
phoneNumber: string | null;
|
|
20
|
+
status: string;
|
|
21
|
+
externalMemberId: string | null;
|
|
22
|
+
metadata: unknown;
|
|
23
|
+
joinedAt: string;
|
|
24
|
+
}
|
|
25
|
+
export interface MemberProfilePatch {
|
|
26
|
+
status?: 'ACTIVE' | 'BLOCKED';
|
|
27
|
+
externalMemberId?: string | null;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export interface MemberDirectoryPage {
|
|
31
|
+
items: MemberProfile[];
|
|
32
|
+
nextCursor: string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface MemberDetail extends MemberProfile {
|
|
35
|
+
balance: CreditBalanceSnapshot;
|
|
36
|
+
}
|
package/dist/members.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"members.js","sourceRoot":"","sources":["../src/members.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { WebhookEventType } from './webhooks.js';
|
|
2
|
+
/**
|
|
3
|
+
* What changed, so a console screen knows what to refetch. Only ids: the stream never carries the
|
|
4
|
+
* data itself, which is read through the REST routes and their access checks.
|
|
5
|
+
*/
|
|
6
|
+
export type OrganizationEventSubject = {
|
|
7
|
+
kind: 'voucher';
|
|
8
|
+
id: string;
|
|
9
|
+
batchId: string | null;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'voucherOwnership';
|
|
12
|
+
id: string;
|
|
13
|
+
voucherId: string;
|
|
14
|
+
memberId: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'loyaltyTransaction';
|
|
17
|
+
id: string;
|
|
18
|
+
memberId: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'issuanceBudget';
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'webhookEndpoint';
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* One message of the console event stream (`GET /v1/console/organizations/:id/events`, OCT-326):
|
|
27
|
+
* the SSE `event` is `type`, the SSE `id` is `sequence`, and `data` is this object as JSON.
|
|
28
|
+
*/
|
|
29
|
+
export interface OrganizationStreamEvent {
|
|
30
|
+
/** The event's id, the same one its webhook carries. */
|
|
31
|
+
id: string;
|
|
32
|
+
/** Orders the organization's events; sent as the SSE `id`, so a reconnect resumes after it. */
|
|
33
|
+
sequence: number;
|
|
34
|
+
type: WebhookEventType;
|
|
35
|
+
subject: OrganizationEventSubject;
|
|
36
|
+
occurredAt: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Stream messages about the stream itself, sent as the SSE `event` with no `id`:
|
|
40
|
+
* - `stream.reset`: events since the `Last-Event-ID` are no longer available (kept 30 days) or the
|
|
41
|
+
* id is unknown. Refetch every screen, then carry on: newer events follow on the same stream.
|
|
42
|
+
* - `stream.token_expired`: the Google ID token the stream was opened with expired, and the stream
|
|
43
|
+
* closes. Reconnect with a fresh token and the last `id` seen; nothing is lost.
|
|
44
|
+
* - `stream.access_revoked`: the caller is no longer an active Owner or Business Developer of an
|
|
45
|
+
* active organization, and the stream closes. Don't reconnect.
|
|
46
|
+
*/
|
|
47
|
+
export declare const ORGANIZATION_STREAM_CONTROL: {
|
|
48
|
+
readonly reset: "stream.reset";
|
|
49
|
+
readonly tokenExpired: "stream.token_expired";
|
|
50
|
+
readonly accessRevoked: "stream.access_revoked";
|
|
51
|
+
};
|
|
52
|
+
export type OrganizationStreamControl = (typeof ORGANIZATION_STREAM_CONTROL)[keyof typeof ORGANIZATION_STREAM_CONTROL];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream messages about the stream itself, sent as the SSE `event` with no `id`:
|
|
3
|
+
* - `stream.reset`: events since the `Last-Event-ID` are no longer available (kept 30 days) or the
|
|
4
|
+
* id is unknown. Refetch every screen, then carry on: newer events follow on the same stream.
|
|
5
|
+
* - `stream.token_expired`: the Google ID token the stream was opened with expired, and the stream
|
|
6
|
+
* closes. Reconnect with a fresh token and the last `id` seen; nothing is lost.
|
|
7
|
+
* - `stream.access_revoked`: the caller is no longer an active Owner or Business Developer of an
|
|
8
|
+
* active organization, and the stream closes. Don't reconnect.
|
|
9
|
+
*/
|
|
10
|
+
export const ORGANIZATION_STREAM_CONTROL = {
|
|
11
|
+
reset: 'stream.reset',
|
|
12
|
+
tokenExpired: 'stream.token_expired',
|
|
13
|
+
accessRevoked: 'stream.access_revoked',
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=organization-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-events.js","sourceRoot":"","sources":["../src/organization-events.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,cAAc;IACrB,YAAY,EAAE,sBAAsB;IACpC,aAAa,EAAE,uBAAuB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { OrganizationApplicationInput } from './console.js';
|
|
2
|
+
export interface ProvisionOrganizationInput {
|
|
3
|
+
earnBps: number;
|
|
4
|
+
expiryDays: number;
|
|
5
|
+
totalBudget: number;
|
|
6
|
+
shardCount: number;
|
|
7
|
+
idempotencyKey: string;
|
|
8
|
+
}
|
|
9
|
+
export interface OrganizationProvisioningStatus {
|
|
10
|
+
operationId: string;
|
|
11
|
+
status: string;
|
|
12
|
+
errorMessage: string | null;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PlatformOrganization {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
status: string;
|
|
20
|
+
organizationType: string | null;
|
|
21
|
+
legalName: string | null;
|
|
22
|
+
taxId: string | null;
|
|
23
|
+
representativeName: string | null;
|
|
24
|
+
logoUrl: string | null;
|
|
25
|
+
programStatus: string | null;
|
|
26
|
+
programControlId: string | null;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
provisioning: OrganizationProvisioningStatus | null;
|
|
29
|
+
}
|
|
30
|
+
/** `GET /v1/platform/organizations` query. */
|
|
31
|
+
export interface PlatformOrganizationListQuery {
|
|
32
|
+
/** 1–100, default 25. */
|
|
33
|
+
limit?: number;
|
|
34
|
+
/** @format uuid */
|
|
35
|
+
cursor?: string;
|
|
36
|
+
status?: 'ACTIVE' | 'SUSPENDED' | 'PENDING_APPROVAL' | 'ARCHIVED';
|
|
37
|
+
/** Name or slug search, up to 160 characters. */
|
|
38
|
+
q?: string;
|
|
39
|
+
}
|
|
40
|
+
/** `POST /v1/platform/organizations`: a System Admin applies on behalf of an existing Google user. */
|
|
41
|
+
export interface PlatformOrganizationInput extends OrganizationApplicationInput {
|
|
42
|
+
/** @format uuid */
|
|
43
|
+
ownerUserId: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.js","sourceRoot":"","sources":["../src/organizations.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request log (OCT-298): every call an organization's API keys made, as the organization's own
|
|
3
|
+
* developers see it in the console. Kept 30 days. Field names follow the OpenTelemetry HTTP
|
|
4
|
+
* semantic conventions where one exists (`route` = `http.route`, `statusCode` =
|
|
5
|
+
* `http.response.status_code`, `latencyMs` = `http.server.request.duration` in milliseconds).
|
|
6
|
+
*/
|
|
7
|
+
/** What part of the API a call belongs to, from its route. */
|
|
8
|
+
export type RequestLogCategory = 'credits' | 'vouchers' | 'refund-policy' | 'webhooks' | 'organizations' | 'other';
|
|
9
|
+
export declare const REQUEST_LOG_CATEGORIES: readonly RequestLogCategory[];
|
|
10
|
+
/** How many days a request log row is kept. */
|
|
11
|
+
export declare const REQUEST_LOG_RETENTION_DAYS = 30;
|
|
12
|
+
/** The API key that made a call, as the console shows it. Never the key itself. */
|
|
13
|
+
export interface RequestLogCredentialRef {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
keyPrefix: string;
|
|
17
|
+
}
|
|
18
|
+
/** One row of the list. */
|
|
19
|
+
export interface RequestLogEntry {
|
|
20
|
+
/** The correlation id (`X-Request-Id` on the response): quote it to OctaP support. */
|
|
21
|
+
requestId: string;
|
|
22
|
+
method: string;
|
|
23
|
+
/** The route template, e.g. `/v1/credits/members/:memberId/balance`: groups calls to the same endpoint. */
|
|
24
|
+
route: string;
|
|
25
|
+
/**
|
|
26
|
+
* The path called, without its query string, with only UUID parameters filled in: any other value
|
|
27
|
+
* stays its placeholder (`:memberId`), so no free text or personal data is kept.
|
|
28
|
+
*/
|
|
29
|
+
path: string;
|
|
30
|
+
statusCode: number;
|
|
31
|
+
latencyMs: number;
|
|
32
|
+
category: RequestLogCategory;
|
|
33
|
+
/** The `code` of a non-2xx response's error body, when it had one. */
|
|
34
|
+
errorCode: string | null;
|
|
35
|
+
/** The `message` of a non-2xx response's error body. */
|
|
36
|
+
errorMessage: string | null;
|
|
37
|
+
credential: RequestLogCredentialRef;
|
|
38
|
+
/** The caller's `User-Agent`, e.g. the SDK and its version. */
|
|
39
|
+
userAgent: string | null;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
}
|
|
42
|
+
/** One row with everything recorded about it, including a non-2xx response's full error body. */
|
|
43
|
+
export interface RequestLogDetail extends RequestLogEntry {
|
|
44
|
+
errorBody: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `succeeded` = 2xx/3xx, `failed` = 4xx/5xx; a class (`4xx`) or an exact code (`404`) narrows it further.
|
|
48
|
+
*/
|
|
49
|
+
export type RequestLogStatusFilter = 'succeeded' | 'failed' | '2xx' | '3xx' | '4xx' | '5xx' | `${number}`;
|
|
50
|
+
/** Filters shared by every request-log read. Times are ISO 8601; the window defaults to the last 24 hours. */
|
|
51
|
+
export interface RequestLogFilters {
|
|
52
|
+
from?: string;
|
|
53
|
+
to?: string;
|
|
54
|
+
credentialId?: string;
|
|
55
|
+
category?: RequestLogCategory;
|
|
56
|
+
method?: string;
|
|
57
|
+
status?: RequestLogStatusFilter;
|
|
58
|
+
/** Exact route template, e.g. from a summary row. */
|
|
59
|
+
route?: string;
|
|
60
|
+
}
|
|
61
|
+
/** `GET …/request-logs`: newest first, `page` from 1, `limit` 1–100 (default 50). */
|
|
62
|
+
export interface RequestLogListQuery extends RequestLogFilters {
|
|
63
|
+
page?: number;
|
|
64
|
+
limit?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface RequestLogPage {
|
|
67
|
+
items: RequestLogEntry[];
|
|
68
|
+
page: number;
|
|
69
|
+
limit: number;
|
|
70
|
+
total: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* `GET …/request-logs/tail`: what arrived after `cursor` (at most 100). Without a cursor nothing is
|
|
74
|
+
* returned, only the cursor to poll from: a tail starts now, like `stripe logs tail`, and only shows
|
|
75
|
+
* calls that arrived after it opened. A call is never skipped, even one whose row committed late; it
|
|
76
|
+
* may arrive a moment after newer ones.
|
|
77
|
+
*/
|
|
78
|
+
export interface RequestLogTailQuery extends Omit<RequestLogFilters, 'from' | 'to'> {
|
|
79
|
+
cursor?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface RequestLogTail {
|
|
82
|
+
items: RequestLogEntry[];
|
|
83
|
+
/** Opaque. Pass it back on the next poll. */
|
|
84
|
+
cursor: string;
|
|
85
|
+
}
|
|
86
|
+
export interface LatencyPercentiles {
|
|
87
|
+
p50: number | null;
|
|
88
|
+
p95: number | null;
|
|
89
|
+
p99: number | null;
|
|
90
|
+
}
|
|
91
|
+
/** Rate, errors, duration for one slice of traffic. `errorRate` is failed / requests, 0–1. */
|
|
92
|
+
export interface RequestLogStats {
|
|
93
|
+
requests: number;
|
|
94
|
+
succeeded: number;
|
|
95
|
+
clientErrors: number;
|
|
96
|
+
serverErrors: number;
|
|
97
|
+
errorRate: number;
|
|
98
|
+
latencyMs: LatencyPercentiles;
|
|
99
|
+
}
|
|
100
|
+
export interface RequestLogSummary {
|
|
101
|
+
from: string;
|
|
102
|
+
to: string;
|
|
103
|
+
totals: RequestLogStats;
|
|
104
|
+
byCategory: (RequestLogStats & {
|
|
105
|
+
category: RequestLogCategory;
|
|
106
|
+
})[];
|
|
107
|
+
/** The 20 busiest endpoints. */
|
|
108
|
+
byRoute: (RequestLogStats & {
|
|
109
|
+
method: string;
|
|
110
|
+
route: string;
|
|
111
|
+
})[];
|
|
112
|
+
byCredential: (RequestLogStats & {
|
|
113
|
+
credential: RequestLogCredentialRef;
|
|
114
|
+
})[];
|
|
115
|
+
}
|
|
116
|
+
export type RequestLogInterval = '1m' | '5m' | '15m' | '1h' | '1d';
|
|
117
|
+
/** `GET …/request-logs/timeseries`: `interval` defaults to one that gives at most ~100 buckets. */
|
|
118
|
+
export interface RequestLogTimeseriesQuery extends RequestLogFilters {
|
|
119
|
+
interval?: RequestLogInterval;
|
|
120
|
+
}
|
|
121
|
+
export interface RequestLogBucket {
|
|
122
|
+
start: string;
|
|
123
|
+
requests: number;
|
|
124
|
+
succeeded: number;
|
|
125
|
+
clientErrors: number;
|
|
126
|
+
serverErrors: number;
|
|
127
|
+
p95LatencyMs: number | null;
|
|
128
|
+
}
|
|
129
|
+
export interface RequestLogTimeseries {
|
|
130
|
+
from: string;
|
|
131
|
+
to: string;
|
|
132
|
+
interval: RequestLogInterval;
|
|
133
|
+
/** Every bucket in the window, empty ones included, oldest first. */
|
|
134
|
+
buckets: RequestLogBucket[];
|
|
135
|
+
}
|
|
136
|
+
/** `GET …/request-logs/errors`: failed calls grouped by endpoint, status and error code, most frequent first. */
|
|
137
|
+
export interface RequestLogErrorGroup {
|
|
138
|
+
method: string;
|
|
139
|
+
route: string;
|
|
140
|
+
statusCode: number;
|
|
141
|
+
errorCode: string | null;
|
|
142
|
+
/** The most recent message in the group. */
|
|
143
|
+
errorMessage: string | null;
|
|
144
|
+
count: number;
|
|
145
|
+
firstSeenAt: string;
|
|
146
|
+
lastSeenAt: string;
|
|
147
|
+
/** The most recent call in the group, to open its detail. */
|
|
148
|
+
lastRequestId: string;
|
|
149
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request log (OCT-298): every call an organization's API keys made, as the organization's own
|
|
3
|
+
* developers see it in the console. Kept 30 days. Field names follow the OpenTelemetry HTTP
|
|
4
|
+
* semantic conventions where one exists (`route` = `http.route`, `statusCode` =
|
|
5
|
+
* `http.response.status_code`, `latencyMs` = `http.server.request.duration` in milliseconds).
|
|
6
|
+
*/
|
|
7
|
+
export const REQUEST_LOG_CATEGORIES = [
|
|
8
|
+
'credits',
|
|
9
|
+
'vouchers',
|
|
10
|
+
'refund-policy',
|
|
11
|
+
'webhooks',
|
|
12
|
+
'organizations',
|
|
13
|
+
'other',
|
|
14
|
+
];
|
|
15
|
+
/** How many days a request log row is kept. */
|
|
16
|
+
export const REQUEST_LOG_RETENTION_DAYS = 30;
|
|
17
|
+
//# sourceMappingURL=request-logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-logs.js","sourceRoot":"","sources":["../src/request-logs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAC,MAAM,sBAAsB,GAAkC;IACnE,SAAS;IACT,UAAU;IACV,eAAe;IACf,UAAU;IACV,eAAe;IACf,OAAO;CACR,CAAC;AAEF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC"}
|