@octap/contracts 0.1.0 → 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/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 +50 -3
- package/dist/evidence.d.ts +122 -0
- package/dist/evidence.js +9 -0
- package/dist/evidence.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/loyalty.d.ts +81 -2
- 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 +5 -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/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 +241 -1
- package/dist/rewards.js +8 -0
- package/dist/rewards.js.map +1 -1
- package/dist/system-users.d.ts +5 -0
- package/dist/system-users.js.map +1 -1
- package/dist/voucher-refunds.d.ts +8 -2
- package/dist/voucher-refunds.js.map +1 -1
- package/dist/webhooks.d.ts +84 -5
- package/package.json +1 -1
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BudgetWarningThreshold } from './loyalty.js';
|
|
2
|
-
import type { RedeemVoucherResponse, VoucherOwnershipStatus } from './rewards.js';
|
|
2
|
+
import type { RedeemVoucherResponse, VoucherActorRef, VoucherOwnershipStatus, VoucherPublishStatus, VoucherStatus } from './rewards.js';
|
|
3
3
|
export type WebhookEndpointStatus = 'ACTIVE' | 'DISABLED';
|
|
4
4
|
export type WebhookDeliveryStatus = 'PENDING' | 'DELIVERED' | 'DEAD_LETTER';
|
|
5
5
|
export interface WebhookEndpointDto {
|
|
@@ -20,7 +20,10 @@ export interface RegisterWebhookEndpointRequest {
|
|
|
20
20
|
description?: string;
|
|
21
21
|
}
|
|
22
22
|
export interface WebhookDeliveryDto {
|
|
23
|
+
/** This delivery (to replay it). Not the event's id: one event goes to every endpoint. */
|
|
23
24
|
id: string;
|
|
25
|
+
/** The event delivered, sent as the body's `id` and `x-octap-event-id`. */
|
|
26
|
+
eventId: string;
|
|
24
27
|
endpointId: string;
|
|
25
28
|
eventType: string;
|
|
26
29
|
status: WebhookDeliveryStatus;
|
|
@@ -32,7 +35,7 @@ export interface WebhookDeliveryDto {
|
|
|
32
35
|
updatedAt: string;
|
|
33
36
|
}
|
|
34
37
|
/** Every event OctaP delivers; sent as `x-octap-event-type` and as the body's `type`. */
|
|
35
|
-
export type WebhookEventType = 'credits.earned' | 'credits.earn.confirmed' | 'credits.earn.failed' | 'credits.redemption.confirmed' | 'credits.reversed' | 'voucher.granted' | 'voucher.redeemed' | 'budget.low';
|
|
38
|
+
export type WebhookEventType = 'credits.earned' | 'credits.earn.confirmed' | 'credits.earn.failed' | 'credits.redemption.confirmed' | 'credits.reversed' | 'voucher.granted' | 'voucher.redeemed' | 'voucher.created' | 'voucher.submitted' | 'voucher.returned' | 'voucher.activated' | 'voucher.publish.failed' | 'voucher.paused' | 'voucher.archived' | 'voucher.expired' | 'voucher.member_expired' | 'budget.low' | 'webhook.test';
|
|
36
39
|
/**
|
|
37
40
|
* `credits.earned`: an earn was *accepted* and is on its way to the chain (status PENDING).
|
|
38
41
|
* `newBalance` is the confirmed balance, which does not include it yet; wait for
|
|
@@ -89,6 +92,15 @@ export interface BudgetLowEventData {
|
|
|
89
92
|
remaining: number;
|
|
90
93
|
capacity: number;
|
|
91
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* `webhook.test`: sent on request from the console to one endpoint only, to check that it receives
|
|
97
|
+
* and verifies OctaP's deliveries. Signed and retried like any other event. Nothing happened in
|
|
98
|
+
* the organization: ignore it beyond acknowledging it.
|
|
99
|
+
*/
|
|
100
|
+
export interface WebhookTestEventData {
|
|
101
|
+
endpointId: string;
|
|
102
|
+
message: string;
|
|
103
|
+
}
|
|
92
104
|
/**
|
|
93
105
|
* `credits.reversed`: a CONFIRMED earn or redemption was reversed in the ledger. Settled
|
|
94
106
|
* immediately; a chain-confirmed original is also mirrored on-chain afterwards, which sends no
|
|
@@ -100,8 +112,6 @@ export interface ReversalEventData {
|
|
|
100
112
|
organizationEndUserId: string;
|
|
101
113
|
pointsAmount: number;
|
|
102
114
|
newBalance: number;
|
|
103
|
-
/** True when reversing an already-spent earn left a clawback debt. */
|
|
104
|
-
balanceWentNegative: boolean;
|
|
105
115
|
}
|
|
106
116
|
/**
|
|
107
117
|
* `voucher.granted`: the chain recorded a voucher given without spending points, through a grant or
|
|
@@ -120,6 +130,19 @@ export interface VoucherGrantedEventData {
|
|
|
120
130
|
expiresAt: string | null;
|
|
121
131
|
blockchainDigest: string;
|
|
122
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* `voucher.member_expired`: a customer's voucher reached its own deadline (`expiresAt`) unused, so it
|
|
135
|
+
* is `EXPIRED` and can no longer be used. Sent once, within about a minute of the deadline (the
|
|
136
|
+
* expiry sweep), or sooner when the voucher is read first.
|
|
137
|
+
*/
|
|
138
|
+
export interface VoucherMemberExpiredEventData {
|
|
139
|
+
voucherOwnershipId: string;
|
|
140
|
+
voucherId: string;
|
|
141
|
+
organizationEndUserId: string;
|
|
142
|
+
serialCode: string;
|
|
143
|
+
status: VoucherOwnershipStatus;
|
|
144
|
+
expiresAt: string | null;
|
|
145
|
+
}
|
|
123
146
|
/**
|
|
124
147
|
* `voucher.redeemed`: the customer signed and the chain marked their voucher used. Deliver the benefit
|
|
125
148
|
* on this event. No points move here; a paid claim already sent `credits.redemption.confirmed`.
|
|
@@ -127,6 +150,58 @@ export interface VoucherGrantedEventData {
|
|
|
127
150
|
export interface VoucherRedeemedEventData extends RedeemVoucherResponse {
|
|
128
151
|
organizationEndUserId: string;
|
|
129
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* The voucher as it is right after the change. Every voucher lifecycle event carries it: fetch the
|
|
155
|
+
* voucher for anything else. `updatedAt` is the value an Owner's activation or review sends back.
|
|
156
|
+
*
|
|
157
|
+
* - `voucher.created`: created on its own or by a batch, or an archived code imported again (back as
|
|
158
|
+
* `DRAFT` in the new batch). Created with `status: 'ACTIVE'` it is followed by `voucher.submitted`,
|
|
159
|
+
* or by `voucher.activated` once the chain holds its terms.
|
|
160
|
+
* - `voucher.activated`: it is `ACTIVE` and claimable: the chain confirmed its terms, or a paused one
|
|
161
|
+
* was resumed. Not sent while publishing; one paused while publishing waits until it is resumed.
|
|
162
|
+
* - `voucher.publish.failed`: its terms never reached the chain (`publishStatus: 'FAILED'`). Fix it and
|
|
163
|
+
* activate it again.
|
|
164
|
+
* - `voucher.paused`: an Owner or an API key paused it; claims stop.
|
|
165
|
+
* - `voucher.archived`: its batch was archived before it went live; it can no longer be used.
|
|
166
|
+
* - `voucher.expired`: its claim window (`expiresAt`) closed while it was live, paused or sold out, so
|
|
167
|
+
* it is `EXPIRED` and nobody can claim it any more. Vouchers customers already hold keep their own
|
|
168
|
+
* deadline (`voucher.member_expired`).
|
|
169
|
+
*/
|
|
170
|
+
export interface VoucherLifecycleEventData {
|
|
171
|
+
voucherId: string;
|
|
172
|
+
code: string;
|
|
173
|
+
title: string;
|
|
174
|
+
batchId: string | null;
|
|
175
|
+
status: VoucherStatus;
|
|
176
|
+
publishStatus: VoucherPublishStatus;
|
|
177
|
+
/** The on-chain `VoucherTerms`, once published. */
|
|
178
|
+
suiTermsId: string | null;
|
|
179
|
+
createdBy: VoucherActorRef;
|
|
180
|
+
activatedBy: VoucherActorRef;
|
|
181
|
+
activatedAt: string | null;
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* `voucher.submitted`: a Business Developer's (or an API key's) activation is waiting for an Owner,
|
|
186
|
+
* because the organization requires approval. Status `PENDING_APPROVAL`.
|
|
187
|
+
*/
|
|
188
|
+
export interface VoucherSubmittedEventData extends VoucherLifecycleEventData {
|
|
189
|
+
/** The submission an Owner approves or rejects. */
|
|
190
|
+
approvalRequestId: string;
|
|
191
|
+
submittedBy: VoucherActorRef;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* `voucher.returned`: a submission left the approval queue without going live: an Owner rejected it
|
|
195
|
+
* (`reason` says why) or it was withdrawn. The voucher is back to `DRAFT`. An approval sends no
|
|
196
|
+
* `voucher.returned`; it starts publishing, and `voucher.activated` follows.
|
|
197
|
+
*/
|
|
198
|
+
export interface VoucherReturnedEventData extends VoucherLifecycleEventData {
|
|
199
|
+
approvalRequestId: string;
|
|
200
|
+
outcome: 'REJECTED' | 'WITHDRAWN';
|
|
201
|
+
reason: string | null;
|
|
202
|
+
/** The user who rejected or withdrew it. */
|
|
203
|
+
reviewedById: string | null;
|
|
204
|
+
}
|
|
130
205
|
interface WebhookEventOf<T extends WebhookEventType, D> {
|
|
131
206
|
/** Stable across retries and replays (`x-octap-event-id`): dedupe on it. */
|
|
132
207
|
id: string;
|
|
@@ -134,5 +209,9 @@ interface WebhookEventOf<T extends WebhookEventType, D> {
|
|
|
134
209
|
data: D;
|
|
135
210
|
}
|
|
136
211
|
/** A delivered webhook body, discriminated on `type`. */
|
|
137
|
-
export type WebhookEvent = WebhookEventOf<'credits.earned', CreditsEarnedEventData> | WebhookEventOf<'credits.earn.confirmed', CreditsChainConfirmedEventData> | WebhookEventOf<'credits.earn.failed', CreditsEarnFailedEventData> | WebhookEventOf<'credits.redemption.confirmed', CreditsChainConfirmedEventData> | WebhookEventOf<'credits.reversed', ReversalEventData> | WebhookEventOf<'voucher.granted', VoucherGrantedEventData> | WebhookEventOf<'voucher.redeemed', VoucherRedeemedEventData> | WebhookEventOf<'budget.low', BudgetLowEventData>;
|
|
212
|
+
export type WebhookEvent = WebhookEventOf<'credits.earned', CreditsEarnedEventData> | WebhookEventOf<'credits.earn.confirmed', CreditsChainConfirmedEventData> | WebhookEventOf<'credits.earn.failed', CreditsEarnFailedEventData> | WebhookEventOf<'credits.redemption.confirmed', CreditsChainConfirmedEventData> | WebhookEventOf<'credits.reversed', ReversalEventData> | WebhookEventOf<'voucher.granted', VoucherGrantedEventData> | WebhookEventOf<'voucher.redeemed', VoucherRedeemedEventData> | WebhookEventOf<'voucher.created', VoucherLifecycleEventData> | WebhookEventOf<'voucher.submitted', VoucherSubmittedEventData> | WebhookEventOf<'voucher.returned', VoucherReturnedEventData> | WebhookEventOf<'voucher.activated', VoucherLifecycleEventData> | WebhookEventOf<'voucher.publish.failed', VoucherLifecycleEventData> | WebhookEventOf<'voucher.paused', VoucherLifecycleEventData> | WebhookEventOf<'voucher.archived', VoucherLifecycleEventData> | WebhookEventOf<'voucher.expired', VoucherLifecycleEventData> | WebhookEventOf<'voucher.member_expired', VoucherMemberExpiredEventData> | WebhookEventOf<'budget.low', BudgetLowEventData> | WebhookEventOf<'webhook.test', WebhookTestEventData>;
|
|
213
|
+
/** The `data` of each event type. */
|
|
214
|
+
export type WebhookEventData<T extends WebhookEventType> = Extract<WebhookEvent, {
|
|
215
|
+
type: T;
|
|
216
|
+
}>['data'];
|
|
138
217
|
export {};
|