@octap/contracts 0.2.1 → 0.3.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 +162 -0
- package/dist/assistant.d.ts +24 -0
- package/dist/campaigns.d.ts +64 -0
- package/dist/campaigns.js +5 -0
- package/dist/campaigns.js.map +1 -0
- package/dist/console.d.ts +13 -2
- package/dist/exports.d.ts +36 -0
- package/dist/exports.js +2 -0
- package/dist/exports.js.map +1 -0
- package/dist/governance.d.ts +55 -1
- package/dist/identity.d.ts +44 -17
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/licensing.d.ts +366 -0
- package/dist/licensing.js +36 -0
- package/dist/licensing.js.map +1 -0
- package/dist/loyalty.d.ts +11 -1
- package/dist/mcp-auth.d.ts +62 -1
- package/dist/mcp-tool-calls.d.ts +71 -0
- package/dist/mcp-tool-calls.js +16 -0
- package/dist/mcp-tool-calls.js.map +1 -0
- package/dist/member-insights.d.ts +73 -0
- package/dist/member-insights.js +11 -0
- package/dist/member-insights.js.map +1 -0
- package/dist/members.d.ts +8 -1
- package/dist/notifications.d.ts +234 -0
- package/dist/notifications.js +104 -0
- package/dist/notifications.js.map +1 -0
- package/dist/organization-events.d.ts +36 -2
- package/dist/organization-events.js.map +1 -1
- package/dist/organizations.d.ts +14 -4
- package/dist/platform-observability.d.ts +103 -0
- package/dist/platform-observability.js +2 -0
- package/dist/platform-observability.js.map +1 -0
- package/dist/rewards.d.ts +13 -1
- package/dist/rewards.js.map +1 -1
- package/dist/webhooks.d.ts +61 -4
- package/package.json +2 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licenses (OCT-329): what an organization may use, and until when. A license plan is a tier in the
|
|
3
|
+
* catalogue the System Admin manages; a license is one organization's copy of a plan's
|
|
4
|
+
* entitlements for a period. Billing never touches customers' points or vouchers.
|
|
5
|
+
*/
|
|
6
|
+
export type LicenseTier = 'TRIAL' | 'STARTER' | 'GROWTH' | 'ENTERPRISE';
|
|
7
|
+
export declare const LICENSE_TIERS: readonly LicenseTier[];
|
|
8
|
+
/**
|
|
9
|
+
* Features a plan switches on. `core` (earn, redeem, vouchers, members, console) is never listed:
|
|
10
|
+
* every license has it.
|
|
11
|
+
*/
|
|
12
|
+
export type LicenseFeature = 'voucher.batches' | 'voucher.approval' | 'webhooks' | 'mcp' | 'assistant' | 'sandbox';
|
|
13
|
+
export declare const LICENSE_FEATURES: readonly LicenseFeature[];
|
|
14
|
+
/** Caps a plan sets. `null` is no limit. */
|
|
15
|
+
export interface LicenseLimits {
|
|
16
|
+
/** Confirmed earns and redeems per license month. */
|
|
17
|
+
transactionsMonthly: number | null;
|
|
18
|
+
/** The organization's members (customers). */
|
|
19
|
+
members: number | null;
|
|
20
|
+
/** ACTIVE API keys. Core's own cap of 25 still applies. */
|
|
21
|
+
apiKeys: number | null;
|
|
22
|
+
/** ACTIVE Owners and Business Developers. */
|
|
23
|
+
teamMembers: number | null;
|
|
24
|
+
}
|
|
25
|
+
export declare const LICENSE_LIMIT_KEYS: readonly (keyof LicenseLimits)[];
|
|
26
|
+
/** What a plan grants, copied onto each license when it is created. */
|
|
27
|
+
export interface LicenseEntitlements {
|
|
28
|
+
features: LicenseFeature[];
|
|
29
|
+
limits: LicenseLimits;
|
|
30
|
+
}
|
|
31
|
+
/** After `endsAt`, new transactions keep working for this many days, then the license is EXPIRED. */
|
|
32
|
+
export declare const LICENSE_GRACE_DAYS = 7;
|
|
33
|
+
/**
|
|
34
|
+
* Worked out from the dates, never stored: ACTIVE before `endsAt`, GRACE for
|
|
35
|
+
* `LICENSE_GRACE_DAYS` after it, EXPIRED from then on.
|
|
36
|
+
*/
|
|
37
|
+
export type LicenseState = 'ACTIVE' | 'GRACE' | 'EXPIRED';
|
|
38
|
+
/** How a license came about. */
|
|
39
|
+
export type LicenseSource = 'TRIAL' | 'MIGRATION' | 'PURCHASE' | 'ADMIN';
|
|
40
|
+
export interface LicensePlanDto {
|
|
41
|
+
id: string;
|
|
42
|
+
tier: LicenseTier;
|
|
43
|
+
name: string;
|
|
44
|
+
/** Price of one month, an integer in VND. An order costs this times the months bought. */
|
|
45
|
+
monthlyPriceVnd: number;
|
|
46
|
+
/** The terms, in months, it can be bought for; empty when it isn't bought by the month. */
|
|
47
|
+
termMonthsAllowed: number[];
|
|
48
|
+
/** A fixed length in days instead of months (the trial). */
|
|
49
|
+
durationDays: number | null;
|
|
50
|
+
entitlements: LicenseEntitlements;
|
|
51
|
+
/** Offered to Owners to buy. A plan that isn't (the trial, a contract) is still granted. */
|
|
52
|
+
purchasable: boolean;
|
|
53
|
+
/** Inactive plans are kept for the licenses already on them but are no longer offered. */
|
|
54
|
+
active: boolean;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
updatedAt: string;
|
|
57
|
+
}
|
|
58
|
+
export interface LicenseDto {
|
|
59
|
+
id: string;
|
|
60
|
+
organizationId: string;
|
|
61
|
+
planId: string;
|
|
62
|
+
tier: LicenseTier;
|
|
63
|
+
planName: string;
|
|
64
|
+
/** The plan's entitlements as they were when this license was created. */
|
|
65
|
+
entitlements: LicenseEntitlements;
|
|
66
|
+
source: LicenseSource;
|
|
67
|
+
startsAt: string;
|
|
68
|
+
endsAt: string;
|
|
69
|
+
graceEndsAt: string;
|
|
70
|
+
state: LicenseState;
|
|
71
|
+
/** Whole days until `endsAt`, 0 once it has passed. */
|
|
72
|
+
daysLeft: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* How much of each limit is in use. `transactionsMonthly` counts the current license month, which
|
|
76
|
+
* runs from `periodStart` to `periodEnd`; the last month ends at the license's `endsAt`, and once that
|
|
77
|
+
* has passed it stays the last month.
|
|
78
|
+
*/
|
|
79
|
+
export interface LicenseUsage {
|
|
80
|
+
periodStart: string;
|
|
81
|
+
periodEnd: string;
|
|
82
|
+
transactionsMonthly: number;
|
|
83
|
+
/** ACTIVE members who aren't blocked or unverified. */
|
|
84
|
+
members: number;
|
|
85
|
+
/** ACTIVE API keys, sandbox ones included. */
|
|
86
|
+
apiKeys: number;
|
|
87
|
+
/** ACTIVE Owners and Business Developers. */
|
|
88
|
+
teamMembers: number;
|
|
89
|
+
}
|
|
90
|
+
/** `GET …/license`: the organization's current license and usage; `null` when it has none. */
|
|
91
|
+
export interface OrganizationLicenseDto {
|
|
92
|
+
organizationId: string;
|
|
93
|
+
license: LicenseDto | null;
|
|
94
|
+
usage: LicenseUsage | null;
|
|
95
|
+
}
|
|
96
|
+
/** `POST /v1/platform/license-plans`. */
|
|
97
|
+
export interface CreateLicensePlanRequest {
|
|
98
|
+
tier: LicenseTier;
|
|
99
|
+
name: string;
|
|
100
|
+
monthlyPriceVnd: number;
|
|
101
|
+
termMonthsAllowed?: number[];
|
|
102
|
+
durationDays?: number | null;
|
|
103
|
+
entitlements: LicenseEntitlements;
|
|
104
|
+
purchasable?: boolean;
|
|
105
|
+
active?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* `PATCH /v1/platform/license-plans/:id`. Licenses already granted keep their own copy. A named
|
|
109
|
+
* interface, not `Partial<Omit<…>>`: the OpenAPI generator names an inline generic after the file's
|
|
110
|
+
* absolute path.
|
|
111
|
+
*/
|
|
112
|
+
export interface UpdateLicensePlanRequest {
|
|
113
|
+
name?: string;
|
|
114
|
+
monthlyPriceVnd?: number;
|
|
115
|
+
termMonthsAllowed?: number[];
|
|
116
|
+
durationDays?: number | null;
|
|
117
|
+
entitlements?: LicenseEntitlements;
|
|
118
|
+
purchasable?: boolean;
|
|
119
|
+
active?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Why a request was refused with 402 (OCT-329): the license doesn't include the feature, or the
|
|
123
|
+
* organization has used up a limit. 403 stays for "not allowed whatever the plan".
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Why a 402 refused the request. `LICENSE_EXPIRED`: the license is past its grace period, so new
|
|
127
|
+
* transactions (earn, POS reserve, paid voucher claims) are refused until it is renewed.
|
|
128
|
+
*/
|
|
129
|
+
export type LicenseErrorCode = 'LICENSE_FEATURE_NOT_INCLUDED' | 'LICENSE_LIMIT_REACHED' | 'LICENSE_EXPIRED';
|
|
130
|
+
/** The body of a 402. `feature` or `limit` says which; `used` and `allowed` come with a limit. */
|
|
131
|
+
export interface LicenseErrorBody {
|
|
132
|
+
statusCode: 402;
|
|
133
|
+
code: LicenseErrorCode;
|
|
134
|
+
message: string;
|
|
135
|
+
feature?: LicenseFeature;
|
|
136
|
+
limit?: keyof LicenseLimits;
|
|
137
|
+
used?: number;
|
|
138
|
+
/** The plan's limit. For transactions, `used` can be past it by the extra 10% a month may go over. */
|
|
139
|
+
allowed?: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* New transactions are refused once a license month's count reaches this share of
|
|
143
|
+
* `transactionsMonthly`: the 10% above the limit gives the partner time to upgrade or renew.
|
|
144
|
+
*/
|
|
145
|
+
export declare const LICENSE_TRANSACTION_HARD_LIMIT_PERCENT = 110;
|
|
146
|
+
/** The shares of `transactionsMonthly` that send a warning, once each per license month. */
|
|
147
|
+
export type LicenseUsageThreshold = 80 | 100;
|
|
148
|
+
export declare const LICENSE_USAGE_THRESHOLDS: readonly LicenseUsageThreshold[];
|
|
149
|
+
/** `license.usage_threshold`: this license month's transactions reached 80% or 100% of the limit. */
|
|
150
|
+
export interface LicenseUsageThresholdEventData {
|
|
151
|
+
limit: 'transactionsMonthly';
|
|
152
|
+
threshold: LicenseUsageThreshold;
|
|
153
|
+
used: number;
|
|
154
|
+
/** The plan's `transactionsMonthly`. New transactions stop at 110% of it. */
|
|
155
|
+
allowed: number;
|
|
156
|
+
periodStart: string;
|
|
157
|
+
periodEnd: string;
|
|
158
|
+
}
|
|
159
|
+
/** Days before `endsAt` that send a reminder, latest first. */
|
|
160
|
+
export declare const LICENSE_EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
|
|
161
|
+
/**
|
|
162
|
+
* A step of a license's end, in order: reminders before `endsAt`, then `GRACE` once it has passed
|
|
163
|
+
* (still working), then `EXPIRED` once the grace period is over (new transactions refused).
|
|
164
|
+
*/
|
|
165
|
+
export type LicenseExpiryStage = 'DAYS_30' | 'DAYS_7' | 'DAYS_1' | 'GRACE' | 'EXPIRED';
|
|
166
|
+
export declare const LICENSE_EXPIRY_STAGES: readonly LicenseExpiryStage[];
|
|
167
|
+
/**
|
|
168
|
+
* `license.expiry_notice`: the organization's license reached a step of its end. Sent once per step,
|
|
169
|
+
* and only for the latest license, so a license already renewed sends nothing more. When several
|
|
170
|
+
* steps passed unseen (no worker ran), only the current one is sent.
|
|
171
|
+
*/
|
|
172
|
+
export interface LicenseExpiryNoticeEventData {
|
|
173
|
+
licenseId: string;
|
|
174
|
+
stage: LicenseExpiryStage;
|
|
175
|
+
tier: LicenseTier;
|
|
176
|
+
planName: string;
|
|
177
|
+
endsAt: string;
|
|
178
|
+
graceEndsAt: string;
|
|
179
|
+
/** Whole days until `endsAt`, 0 once it has passed. */
|
|
180
|
+
daysLeft: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* `POST /v1/platform/organizations/:organizationId/license`, System Admin: grants `months` of
|
|
184
|
+
* `planId`. It follows the current license (from its `endsAt`) while that is active or in grace,
|
|
185
|
+
* and starts now once it has expired or when there is none.
|
|
186
|
+
*/
|
|
187
|
+
export interface RenewLicenseRequest {
|
|
188
|
+
planId: string;
|
|
189
|
+
months: number;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* An order to buy or renew a license (OCT-330), paid by bank transfer. `PAID` once the money
|
|
193
|
+
* arrived, `CANCELED` when the Owner dropped it or chose another plan. `EXPIRED` is never stored:
|
|
194
|
+
* it is a `PENDING` order past `expiresAt`, and a transfer for it is no longer accepted.
|
|
195
|
+
*/
|
|
196
|
+
export type LicenseOrderStatus = 'PENDING' | 'PAID' | 'CANCELED';
|
|
197
|
+
export type LicenseOrderState = LicenseOrderStatus | 'EXPIRED';
|
|
198
|
+
/** How long an order can be paid. */
|
|
199
|
+
export declare const LICENSE_ORDER_TTL_HOURS = 24;
|
|
200
|
+
/** Every payment code starts with this, then 8 digits; SePay finds it in the transfer content. */
|
|
201
|
+
export declare const LICENSE_PAYMENT_CODE_PREFIX = "OCTAP";
|
|
202
|
+
/** `POST /v1/console/organizations/:organizationId/license/orders`, Owner only. */
|
|
203
|
+
export interface CreateLicenseOrderRequest {
|
|
204
|
+
planId: string;
|
|
205
|
+
/** One of the plan's `termMonthsAllowed`. */
|
|
206
|
+
termMonths: number;
|
|
207
|
+
}
|
|
208
|
+
/** An order and how to pay it. The amount is always the plan's monthly price times the term. */
|
|
209
|
+
export interface LicenseOrderDto {
|
|
210
|
+
id: string;
|
|
211
|
+
organizationId: string;
|
|
212
|
+
planId: string;
|
|
213
|
+
tier: LicenseTier;
|
|
214
|
+
planName: string;
|
|
215
|
+
termMonths: number;
|
|
216
|
+
amountVnd: number;
|
|
217
|
+
/** Put it in the transfer content as is: that is how the payment is matched to this order. */
|
|
218
|
+
paymentCode: string;
|
|
219
|
+
state: LicenseOrderState;
|
|
220
|
+
/** VietQR image for exactly `amountVnd`, with `paymentCode` as the transfer content. */
|
|
221
|
+
qrUrl: string;
|
|
222
|
+
bankAccount: string;
|
|
223
|
+
bankCode: string;
|
|
224
|
+
expiresAt: string;
|
|
225
|
+
paidAt: string | null;
|
|
226
|
+
createdAt: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A bank transfer SePay reported (OCT-330): `RECEIVED` until the worker processes it, then `MATCHED`
|
|
230
|
+
* (it paid an order, by itself or by a System Admin's `pay`), `UNMATCHED` (a System Admin decides),
|
|
231
|
+
* `IGNORED` (money going out, or set aside by a System Admin) or `REFUNDED` (sent back in full).
|
|
232
|
+
*/
|
|
233
|
+
export type PaymentTransferStatus = 'RECEIVED' | 'MATCHED' | 'UNMATCHED' | 'IGNORED' | 'REFUNDED';
|
|
234
|
+
/** How Core learned of a transfer: SePay's webhook, or the daily reconciliation with SePay's API. */
|
|
235
|
+
export type PaymentTransferSource = 'WEBHOOK' | 'RECONCILE';
|
|
236
|
+
/** Why a transfer was not matched to an order. */
|
|
237
|
+
export type PaymentUnmatchedReason = 'NO_CODE' | 'UNKNOWN_CODE' | 'UNDERPAID' | 'ORDER_EXPIRED' | 'ORDER_CANCELED' | 'ORDER_ALREADY_PAID'
|
|
238
|
+
/** Processing failed unexpectedly; the transfer waits for a System Admin. */
|
|
239
|
+
| 'PROCESSING_ERROR';
|
|
240
|
+
/**
|
|
241
|
+
* A transfer paid an order: `license.activated` (bought while none was in force, or after one
|
|
242
|
+
* expired), `license.renewed` (the same or a lower tier: it follows the license still active or in
|
|
243
|
+
* grace) or `license.upgraded` (a higher tier: it starts now, and replaces the license in force and
|
|
244
|
+
* any queued after it, whose days left are added as `bonusDays`).
|
|
245
|
+
*/
|
|
246
|
+
export interface LicensePurchasedEventData {
|
|
247
|
+
licenseId: string;
|
|
248
|
+
orderId: string;
|
|
249
|
+
paymentCode: string;
|
|
250
|
+
tier: LicenseTier;
|
|
251
|
+
planName: string;
|
|
252
|
+
termMonths: number;
|
|
253
|
+
amountVnd: number;
|
|
254
|
+
/** What came in above the order's amount, to refund; 0 when exact. */
|
|
255
|
+
overpaidVnd: number;
|
|
256
|
+
startsAt: string;
|
|
257
|
+
/** On an upgrade, `bonusDays` past the term. */
|
|
258
|
+
endsAt: string;
|
|
259
|
+
/**
|
|
260
|
+
* `license.upgraded` only: the days the replaced licenses had left, added at the new plan's price
|
|
261
|
+
* (whole days, rounded down). 0 otherwise.
|
|
262
|
+
*/
|
|
263
|
+
bonusDays: number;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* `license.payment_needs_attention`: a transfer for one of the organization's orders couldn't pay it
|
|
267
|
+
* (too little, or the order had expired, was canceled or was already paid). OctaP reviews it.
|
|
268
|
+
*/
|
|
269
|
+
export interface LicensePaymentNeedsAttentionEventData {
|
|
270
|
+
transferId: string;
|
|
271
|
+
orderId: string;
|
|
272
|
+
paymentCode: string;
|
|
273
|
+
reason: Exclude<PaymentUnmatchedReason, 'NO_CODE' | 'UNKNOWN_CODE' | 'PROCESSING_ERROR'>;
|
|
274
|
+
receivedVnd: number;
|
|
275
|
+
expectedVnd: number;
|
|
276
|
+
}
|
|
277
|
+
/** What a System Admin did to a transfer (OCT-330 part 3). */
|
|
278
|
+
export type PaymentTransferAction = 'PAY' | 'REFUND' | 'IGNORE';
|
|
279
|
+
/** One System Admin action on a transfer, as recorded: never edited or removed. */
|
|
280
|
+
export interface PaymentTransferActionDto {
|
|
281
|
+
id: string;
|
|
282
|
+
action: PaymentTransferAction;
|
|
283
|
+
reason: string;
|
|
284
|
+
/** `REFUND`: the amount sent back. */
|
|
285
|
+
amountVnd: number | null;
|
|
286
|
+
/** `PAY`: the order it paid. */
|
|
287
|
+
orderId: string | null;
|
|
288
|
+
/** `REFUND`: the bank's reference of the transfer back, when given. */
|
|
289
|
+
bankReference: string | null;
|
|
290
|
+
/** The System Admin, a console user id. */
|
|
291
|
+
actorId: string | null;
|
|
292
|
+
createdAt: string;
|
|
293
|
+
}
|
|
294
|
+
/** A transfer, for the System Admin (`GET /v1/platform/payment-transfers`). */
|
|
295
|
+
export interface PaymentTransferDto {
|
|
296
|
+
id: string;
|
|
297
|
+
source: PaymentTransferSource;
|
|
298
|
+
/** SePay's id from the webhook; null for one found by reconciliation only. */
|
|
299
|
+
sepayId: number | null;
|
|
300
|
+
/** SePay's API id (a UUID), for one found by reconciliation. */
|
|
301
|
+
sepayTransactionId: string | null;
|
|
302
|
+
gateway: string;
|
|
303
|
+
accountNumber: string;
|
|
304
|
+
transferType: 'in' | 'out';
|
|
305
|
+
amountVnd: number;
|
|
306
|
+
/** The `OCTAP` payment code found, or null. */
|
|
307
|
+
code: string | null;
|
|
308
|
+
content: string;
|
|
309
|
+
/** The bank's reference of the transfer. */
|
|
310
|
+
referenceCode: string | null;
|
|
311
|
+
/** When the money moved. */
|
|
312
|
+
transactionAt: string;
|
|
313
|
+
status: PaymentTransferStatus;
|
|
314
|
+
/** Why it was not matched (`PaymentUnmatchedReason`), or `OUTGOING`. Kept after a System Admin pays it. */
|
|
315
|
+
reason: string | null;
|
|
316
|
+
organizationId: string | null;
|
|
317
|
+
orderId: string | null;
|
|
318
|
+
/** What came in above the order's amount. */
|
|
319
|
+
overpaidVnd: number;
|
|
320
|
+
/** What was sent back, recorded by `refund`. */
|
|
321
|
+
refundedVnd: number;
|
|
322
|
+
receivedAt: string;
|
|
323
|
+
processedAt: string | null;
|
|
324
|
+
}
|
|
325
|
+
/** One transfer with SePay's payload as sent and every System Admin action on it. */
|
|
326
|
+
export interface PaymentTransferDetailDto extends PaymentTransferDto {
|
|
327
|
+
raw: Record<string, unknown>;
|
|
328
|
+
actions: PaymentTransferActionDto[];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* `GET /v1/platform/payment-transfers`: `status` defaults to `UNMATCHED`, the ones waiting for a
|
|
332
|
+
* System Admin; `ALL` lists every status. `limit` is 1 to 100, 50 by default.
|
|
333
|
+
*/
|
|
334
|
+
export interface PaymentTransferListQuery {
|
|
335
|
+
status?: PaymentTransferStatus | 'ALL';
|
|
336
|
+
cursor?: string;
|
|
337
|
+
limit?: number;
|
|
338
|
+
}
|
|
339
|
+
/** Newest first; pass `nextCursor` back as `cursor` for the next page. */
|
|
340
|
+
export interface PaymentTransferPage {
|
|
341
|
+
items: PaymentTransferDto[];
|
|
342
|
+
nextCursor: string | null;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* `POST /v1/platform/payment-transfers/:id/pay`: pays an order with an `UNMATCHED` transfer, as if
|
|
346
|
+
* it had matched. `orderId` names another order (a wrong code in the content); without it, the
|
|
347
|
+
* order the transfer was matched to (past its 24 hours, or short and accepted anyway).
|
|
348
|
+
*/
|
|
349
|
+
export interface PayPaymentTransferRequest {
|
|
350
|
+
orderId?: string;
|
|
351
|
+
reason: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* `POST /v1/platform/payment-transfers/:id/refund`: records money sent back outside OctaP (SePay
|
|
355
|
+
* can't refund a bank transfer). At most what is left of an `UNMATCHED` transfer, or of what a
|
|
356
|
+
* `MATCHED` one paid above its order.
|
|
357
|
+
*/
|
|
358
|
+
export interface RefundPaymentTransferRequest {
|
|
359
|
+
amountVnd: number;
|
|
360
|
+
reason: string;
|
|
361
|
+
bankReference?: string;
|
|
362
|
+
}
|
|
363
|
+
/** `POST /v1/platform/payment-transfers/:id/ignore`: sets an `UNMATCHED` transfer aside as not OctaP's. */
|
|
364
|
+
export interface IgnorePaymentTransferRequest {
|
|
365
|
+
reason: string;
|
|
366
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licenses (OCT-329): what an organization may use, and until when. A license plan is a tier in the
|
|
3
|
+
* catalogue the System Admin manages; a license is one organization's copy of a plan's
|
|
4
|
+
* entitlements for a period. Billing never touches customers' points or vouchers.
|
|
5
|
+
*/
|
|
6
|
+
export const LICENSE_TIERS = ['TRIAL', 'STARTER', 'GROWTH', 'ENTERPRISE'];
|
|
7
|
+
export const LICENSE_FEATURES = [
|
|
8
|
+
'voucher.batches',
|
|
9
|
+
'voucher.approval',
|
|
10
|
+
'webhooks',
|
|
11
|
+
'mcp',
|
|
12
|
+
'assistant',
|
|
13
|
+
'sandbox',
|
|
14
|
+
];
|
|
15
|
+
export const LICENSE_LIMIT_KEYS = [
|
|
16
|
+
'transactionsMonthly',
|
|
17
|
+
'members',
|
|
18
|
+
'apiKeys',
|
|
19
|
+
'teamMembers',
|
|
20
|
+
];
|
|
21
|
+
/** After `endsAt`, new transactions keep working for this many days, then the license is EXPIRED. */
|
|
22
|
+
export const LICENSE_GRACE_DAYS = 7;
|
|
23
|
+
/**
|
|
24
|
+
* New transactions are refused once a license month's count reaches this share of
|
|
25
|
+
* `transactionsMonthly`: the 10% above the limit gives the partner time to upgrade or renew.
|
|
26
|
+
*/
|
|
27
|
+
export const LICENSE_TRANSACTION_HARD_LIMIT_PERCENT = 110;
|
|
28
|
+
export const LICENSE_USAGE_THRESHOLDS = [80, 100];
|
|
29
|
+
/** Days before `endsAt` that send a reminder, latest first. */
|
|
30
|
+
export const LICENSE_EXPIRY_REMINDER_DAYS = [30, 7, 1];
|
|
31
|
+
export const LICENSE_EXPIRY_STAGES = ['DAYS_30', 'DAYS_7', 'DAYS_1', 'GRACE', 'EXPIRED'];
|
|
32
|
+
/** How long an order can be paid. */
|
|
33
|
+
export const LICENSE_ORDER_TTL_HOURS = 24;
|
|
34
|
+
/** Every payment code starts with this, then 8 digits; SePay finds it in the transfer content. */
|
|
35
|
+
export const LICENSE_PAYMENT_CODE_PREFIX = 'OCTAP';
|
|
36
|
+
//# sourceMappingURL=licensing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"licensing.js","sourceRoot":"","sources":["../src/licensing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAOlG,MAAM,CAAC,MAAM,gBAAgB,GAA8B;IACzD,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,KAAK;IACL,WAAW;IACX,SAAS;CACV,CAAC;AAaF,MAAM,CAAC,MAAM,kBAAkB,GAAqC;IAClE,qBAAqB;IACrB,SAAS;IACT,SAAS;IACT,aAAa;CACd,CAAC;AAQF,qGAAqG;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAwHpC;;;GAGG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,CAAC;AAI1D,MAAM,CAAC,MAAM,wBAAwB,GAAqC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAapF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAOhE,MAAM,CAAC,MAAM,qBAAqB,GAAkC,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAoCxH,qCAAqC;AACrC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,kGAAkG;AAClG,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC"}
|
package/dist/loyalty.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export interface EarnPointsRequest {
|
|
|
17
17
|
idempotencyKey: string;
|
|
18
18
|
receiptReference?: string;
|
|
19
19
|
metadata?: Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* A campaign of this organization whose earn boost applies to this purchase (OCT-340). It must be
|
|
22
|
+
* ACTIVE, within its window and have a multiplier, or the earn is refused (422): it is never earned
|
|
23
|
+
* at the base rate instead. Omit for an ordinary earn. One campaign per earn.
|
|
24
|
+
*/
|
|
25
|
+
campaignId?: string;
|
|
20
26
|
}
|
|
21
27
|
export interface EarnPointsResponse {
|
|
22
28
|
/** Present, and true, only on what a sandbox key made or reads (OCT-297). */
|
|
@@ -166,7 +172,7 @@ export interface IssuanceBudgetDto {
|
|
|
166
172
|
/**
|
|
167
173
|
* `GET /v1/credits/transactions` and `GET /v1/console/organizations/{organizationId}/transactions`:
|
|
168
174
|
* the organization's points history, newest first. `limit` 1–100 (default 25), `cursor` from the
|
|
169
|
-
* last page's `nextCursor`; `type`, `status` and `
|
|
175
|
+
* last page's `nextCursor`; `type`, `status`, `memberId` and the `from`/`to` window narrow it.
|
|
170
176
|
*/
|
|
171
177
|
export interface OrganizationTransactionQuery {
|
|
172
178
|
limit?: number;
|
|
@@ -174,6 +180,10 @@ export interface OrganizationTransactionQuery {
|
|
|
174
180
|
type?: LoyaltyTxType;
|
|
175
181
|
status?: LoyaltyTxStatus;
|
|
176
182
|
memberId?: string;
|
|
183
|
+
/** Only transactions created at or after this moment. ISO 8601 date-time with an offset or Z. */
|
|
184
|
+
from?: string;
|
|
185
|
+
/** Only transactions created before this moment (excluded), after `from`. ISO 8601 date-time with an offset or Z. */
|
|
186
|
+
to?: string;
|
|
177
187
|
}
|
|
178
188
|
/**
|
|
179
189
|
* How a member's recorded balance compares with their `CreditAccount` on Sui, read live from the
|
package/dist/mcp-auth.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ export interface McpTokenIntrospection {
|
|
|
7
7
|
active: true;
|
|
8
8
|
/** The MCP host's OAuth client id from dynamic registration. */
|
|
9
9
|
clientId: string;
|
|
10
|
+
/** `mcp` (read), plus `mcp:write` when the user allowed changes at sign-in (OCT-314). */
|
|
10
11
|
scopes: string[];
|
|
11
12
|
userId: string;
|
|
12
|
-
/** The one organization this token can
|
|
13
|
+
/** The one organization this token can reach. */
|
|
13
14
|
organizationId: string;
|
|
14
15
|
/** The user's persona in that organization when the token was issued; Core rechecks it per request. */
|
|
15
16
|
persona: OrganizationPersona;
|
|
@@ -18,3 +19,63 @@ export interface McpTokenIntrospection {
|
|
|
18
19
|
/** Expiry in seconds since the epoch. */
|
|
19
20
|
expiresAt: number;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* `POST /v1/console/organizations/:organizationId/mcp/confirmations` (OCT-314), with an MCP token that
|
|
24
|
+
* has `mcp:write`: a change to show the user before making it. Nothing changes yet.
|
|
25
|
+
*/
|
|
26
|
+
export interface McpConfirmationInput {
|
|
27
|
+
method: 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
28
|
+
/** A console route of the token's organization, e.g. `/v1/console/organizations/<id>/vouchers`. */
|
|
29
|
+
path: string;
|
|
30
|
+
/** The JSON body to send; `{}` when the route takes none. */
|
|
31
|
+
body?: Record<string, unknown>;
|
|
32
|
+
/** What the change does, in words the user confirms (1-1000 characters). */
|
|
33
|
+
summary: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A prepared change. The host shows `summary`, and only once the user agrees sends `method path` with
|
|
37
|
+
* exactly `body` and the header `X-Mcp-Confirmation: <confirmationId>`. The id works once, for that
|
|
38
|
+
* request only, until `expiresAt` (5 minutes). A retry of the same request with the same id returns
|
|
39
|
+
* the first answer instead of making the change again.
|
|
40
|
+
*/
|
|
41
|
+
export interface McpConfirmation {
|
|
42
|
+
confirmationId: string;
|
|
43
|
+
method: McpConfirmationInput['method'];
|
|
44
|
+
path: string;
|
|
45
|
+
body: Record<string, unknown>;
|
|
46
|
+
summary: string;
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One MCP host signed in as the current user (OCT-305): `GET /v1/console/mcp/connections`. Never the
|
|
51
|
+
* token or its hash. Connections from before OCT-305 aren't listed until they expire (within an hour).
|
|
52
|
+
*/
|
|
53
|
+
export interface McpConnection {
|
|
54
|
+
/** Opaque; pass it to `DELETE /v1/console/mcp/connections/{connectionId}` to sign the host out. */
|
|
55
|
+
id: string;
|
|
56
|
+
/** The name the host registered with, e.g. "Claude Code". Chosen by the host, so shown as given. */
|
|
57
|
+
clientName: string;
|
|
58
|
+
organization: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
};
|
|
62
|
+
persona: OrganizationPersona;
|
|
63
|
+
/** Whether the connection may make changes (`mcp:write`), not only read. */
|
|
64
|
+
canMakeChanges: boolean;
|
|
65
|
+
/** ISO 8601. */
|
|
66
|
+
signedInAt: string;
|
|
67
|
+
/** ISO 8601. The host has to sign in again after this. */
|
|
68
|
+
expiresAt: string;
|
|
69
|
+
}
|
|
70
|
+
/** Newest sign-in first. `?organizationId=` lists only one organization's connections. */
|
|
71
|
+
export interface McpConnectionList {
|
|
72
|
+
items: McpConnection[];
|
|
73
|
+
}
|
|
74
|
+
/** `DELETE /v1/console/mcp/connections` (all of the user's) or `…/{connectionId}` (one): how many were signed out. */
|
|
75
|
+
export interface McpConnectionsSignedOut {
|
|
76
|
+
signedOut: number;
|
|
77
|
+
}
|
|
78
|
+
export interface McpConnectionListQuery {
|
|
79
|
+
/** Only this organization's connections. */
|
|
80
|
+
organizationId?: string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { OrganizationPersona } from './system-users.js';
|
|
2
|
+
/**
|
|
3
|
+
* MCP tool calls (OCT-296): who used which MCP tool, for which organization, and with what result.
|
|
4
|
+
* Core writes one record per tool call from the requests the MCP server makes with the user's MCP
|
|
5
|
+
* access token, so the MCP process cannot leave a call out.
|
|
6
|
+
* `GET /v1/console/organizations/{organizationId}/mcp-tool-calls`, Owner only.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Every Core request made with an MCP access token names the tool call it serves: the tool, and an
|
|
10
|
+
* id the MCP server draws once per call. A tool that makes several requests (`get_member`) sends the
|
|
11
|
+
* same id on each, so the call is one record. Core refuses an MCP request without them.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MCP_TOOL_HEADER = "x-octap-mcp-tool";
|
|
14
|
+
export declare const MCP_CALL_HEADER = "x-octap-mcp-call";
|
|
15
|
+
/** Kept for a year, then deleted by the worker. */
|
|
16
|
+
export declare const MCP_TOOL_CALL_RETENTION_DAYS = 365;
|
|
17
|
+
/**
|
|
18
|
+
* `DENIED`: Core refused the caller (401 or 403). `ERROR`: any other failure, including a 404.
|
|
19
|
+
* When a call's requests end differently, the record keeps the first failure.
|
|
20
|
+
*/
|
|
21
|
+
export type McpToolCallOutcome = 'SUCCESS' | 'DENIED' | 'ERROR';
|
|
22
|
+
export interface McpToolCallEntry {
|
|
23
|
+
/** The id the MCP server gave the call. */
|
|
24
|
+
callId: string;
|
|
25
|
+
/** When the call's first request reached Core. */
|
|
26
|
+
occurredAt: string;
|
|
27
|
+
user: {
|
|
28
|
+
id: string;
|
|
29
|
+
/** The user's name or email as it is now; null once the user is removed. */
|
|
30
|
+
label: string | null;
|
|
31
|
+
};
|
|
32
|
+
/** The MCP host's OAuth client id, or `octap-dashboard-assistant` for the dashboard assistant. */
|
|
33
|
+
clientId: string;
|
|
34
|
+
/** The persona the token was issued for. */
|
|
35
|
+
persona: OrganizationPersona;
|
|
36
|
+
tool: string;
|
|
37
|
+
outcome: McpToolCallOutcome;
|
|
38
|
+
/** Core's HTTP status for the request the outcome comes from. */
|
|
39
|
+
httpStatus: number;
|
|
40
|
+
/** That request's `X-Request-Id`, to match OctaP's own logs. */
|
|
41
|
+
requestId: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Core's own time on the call, summed over its requests, in ms. A slow conversation with small
|
|
44
|
+
* values here is the host and the model, not Core.
|
|
45
|
+
*/
|
|
46
|
+
durationMs: number;
|
|
47
|
+
/**
|
|
48
|
+
* Set by write tools only: what the call changed and how it was confirmed. Null on reads. The
|
|
49
|
+
* change itself is in the audit log, under the same request id.
|
|
50
|
+
*/
|
|
51
|
+
write: {
|
|
52
|
+
targetType: string | null;
|
|
53
|
+
targetId: string | null;
|
|
54
|
+
confirmationId: string | null;
|
|
55
|
+
idempotencyKey: string | null;
|
|
56
|
+
} | null;
|
|
57
|
+
}
|
|
58
|
+
/** Newest first. `limit` 1–100 (default 50), `cursor` from the last page's `nextCursor`. Times are ISO 8601. */
|
|
59
|
+
export interface McpToolCallQuery {
|
|
60
|
+
limit?: number;
|
|
61
|
+
cursor?: string;
|
|
62
|
+
from?: string;
|
|
63
|
+
to?: string;
|
|
64
|
+
userId?: string;
|
|
65
|
+
tool?: string;
|
|
66
|
+
outcome?: McpToolCallOutcome;
|
|
67
|
+
}
|
|
68
|
+
export interface McpToolCallPage {
|
|
69
|
+
items: McpToolCallEntry[];
|
|
70
|
+
nextCursor: string | null;
|
|
71
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool calls (OCT-296): who used which MCP tool, for which organization, and with what result.
|
|
3
|
+
* Core writes one record per tool call from the requests the MCP server makes with the user's MCP
|
|
4
|
+
* access token, so the MCP process cannot leave a call out.
|
|
5
|
+
* `GET /v1/console/organizations/{organizationId}/mcp-tool-calls`, Owner only.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Every Core request made with an MCP access token names the tool call it serves: the tool, and an
|
|
9
|
+
* id the MCP server draws once per call. A tool that makes several requests (`get_member`) sends the
|
|
10
|
+
* same id on each, so the call is one record. Core refuses an MCP request without them.
|
|
11
|
+
*/
|
|
12
|
+
export const MCP_TOOL_HEADER = 'x-octap-mcp-tool';
|
|
13
|
+
export const MCP_CALL_HEADER = 'x-octap-mcp-call';
|
|
14
|
+
/** Kept for a year, then deleted by the worker. */
|
|
15
|
+
export const MCP_TOOL_CALL_RETENTION_DAYS = 365;
|
|
16
|
+
//# sourceMappingURL=mcp-tool-calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-calls.js","sourceRoot":"","sources":["../src/mcp-tool-calls.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD,mDAAmD;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which members (OCT-376), for a program's Owner and Business Developers, so a question such as "who
|
|
3
|
+
* earned the most this month?" is one read instead of a walk through the ledger:
|
|
4
|
+
* `GET /v1/console/organizations/{organizationId}/analytics/top-members` and `…/member-segments`.
|
|
5
|
+
* `MemberSegments` (`…/analytics/members`) counts members by activity; these name them.
|
|
6
|
+
*
|
|
7
|
+
* Every figure means what it means in `ProgramAnalyticsSummary`: CONFIRMED transactions only, in
|
|
8
|
+
* `[from, to)`, the last 30 days by default and at most 366 days.
|
|
9
|
+
*/
|
|
10
|
+
/** A member as a ranking or a segment lists it. No contact details: those are on the member's own page. */
|
|
11
|
+
export interface InsightMember {
|
|
12
|
+
memberId: string;
|
|
13
|
+
/** The customer's display name, when they have one. */
|
|
14
|
+
name: string | null;
|
|
15
|
+
/** The merchant's own id for this member, when it has one. */
|
|
16
|
+
externalMemberId: string | null;
|
|
17
|
+
status: string;
|
|
18
|
+
/** Confirmed points they can spend now, whatever the window. */
|
|
19
|
+
balance: number;
|
|
20
|
+
joinedAt: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* - `earned`, `redeemed`: points in the window.
|
|
24
|
+
* - `transactions`: how many earns and redemptions in the window, the most active first.
|
|
25
|
+
* - `balance`: points held now; the window does not change it.
|
|
26
|
+
*/
|
|
27
|
+
export type TopMembersMetric = 'earned' | 'redeemed' | 'transactions' | 'balance';
|
|
28
|
+
export interface TopMembersQuery {
|
|
29
|
+
/** Defaults to `transactions`. */
|
|
30
|
+
metric?: TopMembersMetric;
|
|
31
|
+
from?: string;
|
|
32
|
+
to?: string;
|
|
33
|
+
/** 1-50, default 10. */
|
|
34
|
+
limit?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TopMember extends InsightMember {
|
|
37
|
+
earned: number;
|
|
38
|
+
redeemed: number;
|
|
39
|
+
transactions: number;
|
|
40
|
+
}
|
|
41
|
+
export interface TopMembers {
|
|
42
|
+
from: string;
|
|
43
|
+
to: string;
|
|
44
|
+
metric: TopMembersMetric;
|
|
45
|
+
/** Highest first. Members with none of the metric are left out. */
|
|
46
|
+
items: TopMember[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* - `never_redeemed`: holds points now and never had a confirmed redemption, ever.
|
|
50
|
+
* - `inactive`: enrolled before the window and neither earned nor redeemed in it.
|
|
51
|
+
* - `new`: enrolled in the window.
|
|
52
|
+
*/
|
|
53
|
+
export type MemberSegment = 'never_redeemed' | 'inactive' | 'new';
|
|
54
|
+
export interface MemberSegmentQuery {
|
|
55
|
+
segment: MemberSegment;
|
|
56
|
+
from?: string;
|
|
57
|
+
to?: string;
|
|
58
|
+
/** From 1. */
|
|
59
|
+
page?: string;
|
|
60
|
+
/** 1-50, default 20. */
|
|
61
|
+
limit?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface MemberSegmentPage {
|
|
64
|
+
from: string;
|
|
65
|
+
to: string;
|
|
66
|
+
segment: MemberSegment;
|
|
67
|
+
/** Largest balance first, except `new`: the newest first. */
|
|
68
|
+
items: InsightMember[];
|
|
69
|
+
page: number;
|
|
70
|
+
limit: number;
|
|
71
|
+
/** Everyone in the segment, not only this page. */
|
|
72
|
+
total: number;
|
|
73
|
+
}
|