@octap/contracts 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/analytics.d.ts +162 -0
- package/dist/announcements.d.ts +58 -0
- package/dist/announcements.js +12 -0
- package/dist/announcements.js.map +1 -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 +90 -0
- package/dist/exports.js +10 -0
- package/dist/exports.js.map +1 -0
- package/dist/governance.d.ts +63 -1
- package/dist/identity.d.ts +44 -17
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/licensing.d.ts +511 -0
- package/dist/licensing.js +37 -0
- package/dist/licensing.js.map +1 -0
- package/dist/loyalty.d.ts +19 -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 +116 -0
- package/dist/notifications.js.map +1 -0
- package/dist/organization-events.d.ts +56 -2
- package/dist/organization-events.js.map +1 -1
- package/dist/organization-slugs.d.ts +84 -0
- package/dist/organization-slugs.js +115 -0
- package/dist/organization-slugs.js.map +1 -0
- package/dist/organizations.d.ts +19 -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 +4 -2
package/dist/identity.d.ts
CHANGED
|
@@ -1,30 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** The zkLogin proof for the merchant page's own ephemeral key, as `@mysten/sui/zklogin` reads it. */
|
|
2
|
+
export interface ZkLoginProofInputs {
|
|
3
|
+
proofPoints: {
|
|
4
|
+
a: string[];
|
|
5
|
+
b: string[][];
|
|
6
|
+
c: string[];
|
|
7
|
+
};
|
|
8
|
+
issBase64Details: {
|
|
9
|
+
value: string;
|
|
10
|
+
indexMod4: number;
|
|
11
|
+
};
|
|
12
|
+
headerBase64: string;
|
|
13
|
+
addressSeed: string;
|
|
3
14
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
/**
|
|
16
|
+
* What Core's hosted sign-in page posts to the merchant page that opened it (OCT-394), and the
|
|
17
|
+
* response of `POST /v1/identity/sign-in/complete`. Google's id_token is not in it.
|
|
18
|
+
*/
|
|
19
|
+
export interface CustomerSignInResult {
|
|
20
|
+
/** For the merchant's backend to check with `verifyCustomer`. Valid for this organization only. */
|
|
21
|
+
customerToken: string;
|
|
22
|
+
user: {
|
|
23
|
+
endUserId: string;
|
|
24
|
+
/** The customer's `organizationEndUserId` in this organization. */
|
|
25
|
+
memberId: string;
|
|
26
|
+
suiAddress: string;
|
|
27
|
+
};
|
|
28
|
+
/** Lets the page sign with its ephemeral key until `expiresAt` (ms since the epoch). */
|
|
29
|
+
signer: {
|
|
30
|
+
proof: ZkLoginProofInputs;
|
|
31
|
+
maxEpoch: number;
|
|
32
|
+
expiresAt: number;
|
|
33
|
+
};
|
|
8
34
|
}
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
35
|
+
export interface CompleteCustomerSignInRequest {
|
|
36
|
+
requestId: string;
|
|
37
|
+
/** Google's credential, posted by Core's own sign-in page. */
|
|
38
|
+
credential: string;
|
|
18
39
|
}
|
|
19
40
|
export interface VerifyCustomerRequest {
|
|
41
|
+
/** The customer token from `@octap/browser-sdk`'s `getIdToken()`. */
|
|
20
42
|
idToken: string;
|
|
21
43
|
}
|
|
22
44
|
export interface VerifyCustomerResponse {
|
|
23
|
-
/** Null when
|
|
45
|
+
/** Null only when the customer's account was removed after they signed in. */
|
|
24
46
|
endUserId: string | null;
|
|
25
47
|
suiAddress: string;
|
|
26
|
-
/** The `organizationEndUserId` in the calling organization; null
|
|
48
|
+
/** The `organizationEndUserId` in the calling organization; null if the membership was removed. */
|
|
27
49
|
memberId: string | null;
|
|
28
50
|
/** True only when reward operations will accept this member: enrolled and not blocked. */
|
|
29
51
|
active: boolean;
|
|
30
52
|
}
|
|
53
|
+
/** The web origins whose pages may receive a customer's sign-in for one organization (OCT-394). */
|
|
54
|
+
export interface SignInOriginsDto {
|
|
55
|
+
/** e.g. `https://shop.example`; `http://localhost:3000` for development. Empty refuses every page. */
|
|
56
|
+
origins: string[];
|
|
57
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './loyalty.js';
|
|
2
2
|
export * from './rewards.js';
|
|
3
|
+
export * from './campaigns.js';
|
|
3
4
|
export * from './voucher-refunds.js';
|
|
4
5
|
export * from './webhooks.js';
|
|
5
6
|
export * from './organization-events.js';
|
|
@@ -9,9 +10,17 @@ export * from './console.js';
|
|
|
9
10
|
export * from './members.js';
|
|
10
11
|
export * from './governance.js';
|
|
11
12
|
export * from './organizations.js';
|
|
13
|
+
export * from './organization-slugs.js';
|
|
12
14
|
export * from './mcp-auth.js';
|
|
15
|
+
export * from './mcp-tool-calls.js';
|
|
13
16
|
export * from './assistant.js';
|
|
14
17
|
export * from './request-logs.js';
|
|
18
|
+
export * from './licensing.js';
|
|
15
19
|
export * from './audit.js';
|
|
16
20
|
export * from './evidence.js';
|
|
17
21
|
export * from './analytics.js';
|
|
22
|
+
export * from './exports.js';
|
|
23
|
+
export * from './member-insights.js';
|
|
24
|
+
export * from './platform-observability.js';
|
|
25
|
+
export * from './notifications.js';
|
|
26
|
+
export * from './announcements.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './loyalty.js';
|
|
2
2
|
export * from './rewards.js';
|
|
3
|
+
export * from './campaigns.js';
|
|
3
4
|
export * from './voucher-refunds.js';
|
|
4
5
|
export * from './webhooks.js';
|
|
5
6
|
export * from './organization-events.js';
|
|
@@ -9,10 +10,18 @@ export * from './console.js';
|
|
|
9
10
|
export * from './members.js';
|
|
10
11
|
export * from './governance.js';
|
|
11
12
|
export * from './organizations.js';
|
|
13
|
+
export * from './organization-slugs.js';
|
|
12
14
|
export * from './mcp-auth.js';
|
|
15
|
+
export * from './mcp-tool-calls.js';
|
|
13
16
|
export * from './assistant.js';
|
|
14
17
|
export * from './request-logs.js';
|
|
18
|
+
export * from './licensing.js';
|
|
15
19
|
export * from './audit.js';
|
|
16
20
|
export * from './evidence.js';
|
|
17
21
|
export * from './analytics.js';
|
|
22
|
+
export * from './exports.js';
|
|
23
|
+
export * from './member-insights.js';
|
|
24
|
+
export * from './platform-observability.js';
|
|
25
|
+
export * from './notifications.js';
|
|
26
|
+
export * from './announcements.js';
|
|
18
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,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"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,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,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,511 @@
|
|
|
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
|
+
/** One license month's counted transactions, from `license_usage`. */
|
|
97
|
+
export interface LicenseHistoryMonth {
|
|
98
|
+
periodStart: string;
|
|
99
|
+
periodEnd: string;
|
|
100
|
+
/** Accepted, less the ones that failed after: the same count the limit uses. */
|
|
101
|
+
transactions: number;
|
|
102
|
+
/** When the 80% and 100% warnings went out that month, if they did. */
|
|
103
|
+
warned80At: string | null;
|
|
104
|
+
warned100At: string | null;
|
|
105
|
+
/** Requests refused with 402 that month (OCT-346). */
|
|
106
|
+
refused: LicenseRefusalCounts;
|
|
107
|
+
lastRefusedAt: string | null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Requests refused with 402 in one license month (OCT-346), by what they stopped. A missing feature
|
|
111
|
+
* isn't a used-up quota and isn't counted.
|
|
112
|
+
*/
|
|
113
|
+
export interface LicenseRefusalCounts {
|
|
114
|
+
/** Transactions turned away: earns, POS redeems or paid claims at 110% of the limit, or past an expired license's grace. */
|
|
115
|
+
transactions: number;
|
|
116
|
+
/** One more member, API key or team member refused at 100% of its limit. */
|
|
117
|
+
resources: number;
|
|
118
|
+
}
|
|
119
|
+
/** One license an organization had, newest first, with the months it counted transactions in. */
|
|
120
|
+
export interface LicenseHistoryEntry {
|
|
121
|
+
id: string;
|
|
122
|
+
planId: string;
|
|
123
|
+
tier: LicenseTier;
|
|
124
|
+
planName: string;
|
|
125
|
+
source: LicenseSource;
|
|
126
|
+
entitlements: LicenseEntitlements;
|
|
127
|
+
startsAt: string;
|
|
128
|
+
endsAt: string;
|
|
129
|
+
state: LicenseState;
|
|
130
|
+
/** The license that replaced this one on an upgrade; it stopped counting then. */
|
|
131
|
+
replacedByLicenseId: string | null;
|
|
132
|
+
/**
|
|
133
|
+
* Newest first. A month appears once a transaction was counted or a request refused in it, so a
|
|
134
|
+
* quiet month has none.
|
|
135
|
+
* Members, API keys and team members are counted live, so they have no history.
|
|
136
|
+
*/
|
|
137
|
+
months: LicenseHistoryMonth[];
|
|
138
|
+
}
|
|
139
|
+
/** `GET /v1/platform/organizations/:organizationId/license/history` (OCT-346). */
|
|
140
|
+
export interface OrganizationLicenseHistoryDto {
|
|
141
|
+
organizationId: string;
|
|
142
|
+
licenses: LicenseHistoryEntry[];
|
|
143
|
+
}
|
|
144
|
+
/** A license's state for the System Admin's list; `NONE` is an organization that never had one. */
|
|
145
|
+
export type PlatformLicenseState = LicenseState | 'NONE';
|
|
146
|
+
export declare const PLATFORM_LICENSE_STATES: readonly PlatformLicenseState[];
|
|
147
|
+
/**
|
|
148
|
+
* One limit's use. `percent` is `floor(used × 100 / allowed)`: rounded down, so 80 is reached exactly
|
|
149
|
+
* when the 80% warning goes out. Transactions can reach 110 (a month may go 10% over); the others
|
|
150
|
+
* stop at 100. `allowed` and `percent` are `null` for no limit, or for an organization without a
|
|
151
|
+
* license (it is never limited).
|
|
152
|
+
*/
|
|
153
|
+
export interface LicenseLimitUsage {
|
|
154
|
+
used: number;
|
|
155
|
+
allowed: number | null;
|
|
156
|
+
percent: number | null;
|
|
157
|
+
}
|
|
158
|
+
/** The license in force, as `GET /v1/platform/licenses` shows it: `LicenseDto` without the entitlements. */
|
|
159
|
+
export interface PlatformLicenseSummary {
|
|
160
|
+
id: string;
|
|
161
|
+
planId: string;
|
|
162
|
+
tier: LicenseTier;
|
|
163
|
+
planName: string;
|
|
164
|
+
source: LicenseSource;
|
|
165
|
+
startsAt: string;
|
|
166
|
+
endsAt: string;
|
|
167
|
+
graceEndsAt: string;
|
|
168
|
+
/** Whole days until `endsAt`, 0 once it has passed. */
|
|
169
|
+
daysLeft: number;
|
|
170
|
+
}
|
|
171
|
+
/** Each limit's use, by limit. */
|
|
172
|
+
export interface PlatformLicenseUsage {
|
|
173
|
+
transactionsMonthly: LicenseLimitUsage;
|
|
174
|
+
members: LicenseLimitUsage;
|
|
175
|
+
apiKeys: LicenseLimitUsage;
|
|
176
|
+
teamMembers: LicenseLimitUsage;
|
|
177
|
+
}
|
|
178
|
+
/** One organization in `GET /v1/platform/licenses` (OCT-346). */
|
|
179
|
+
export interface PlatformLicenseListItem {
|
|
180
|
+
organizationId: string;
|
|
181
|
+
organizationName: string;
|
|
182
|
+
/** The license in force, or `null` when the organization never had one. */
|
|
183
|
+
license: PlatformLicenseSummary | null;
|
|
184
|
+
state: PlatformLicenseState;
|
|
185
|
+
/** The license month `usage.transactionsMonthly` counts; `null` without a license. */
|
|
186
|
+
periodStart: string | null;
|
|
187
|
+
periodEnd: string | null;
|
|
188
|
+
/**
|
|
189
|
+
* Transactions are this license month's counted ones: accepted, less those that failed after.
|
|
190
|
+
* Members, API keys and team members are counted as they stand.
|
|
191
|
+
*/
|
|
192
|
+
usage: PlatformLicenseUsage;
|
|
193
|
+
/** The highest `percent` of the four limits; `null` when none has one. */
|
|
194
|
+
usagePercent: number | null;
|
|
195
|
+
/**
|
|
196
|
+
* Requests refused with 402 in this license month, by what they stopped. An expired license keeps
|
|
197
|
+
* counting on its last month.
|
|
198
|
+
*/
|
|
199
|
+
refusedThisMonth: LicenseRefusalCounts;
|
|
200
|
+
}
|
|
201
|
+
/** `GET /v1/platform/licenses`. Archived organizations are left out. */
|
|
202
|
+
export interface PlatformLicenseListQuery {
|
|
203
|
+
state?: PlatformLicenseState;
|
|
204
|
+
tier?: LicenseTier;
|
|
205
|
+
/** ACTIVE licenses that end within this many days (`daysLeft` at most this). */
|
|
206
|
+
expiresWithinDays?: number;
|
|
207
|
+
/** At least one limit at or above this percentage. */
|
|
208
|
+
minUsagePercent?: number;
|
|
209
|
+
/** `daysLeft` (soonest end first, the default) or `usage` (highest `usagePercent` first). */
|
|
210
|
+
sort?: 'daysLeft' | 'usage';
|
|
211
|
+
/** 1 to 100, 50 by default. */
|
|
212
|
+
limit?: number;
|
|
213
|
+
offset?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface PlatformLicensePage {
|
|
216
|
+
items: PlatformLicenseListItem[];
|
|
217
|
+
/** Organizations matching the filters, across all pages. */
|
|
218
|
+
total: number;
|
|
219
|
+
limit: number;
|
|
220
|
+
offset: number;
|
|
221
|
+
}
|
|
222
|
+
/** `POST /v1/platform/license-plans`. */
|
|
223
|
+
export interface CreateLicensePlanRequest {
|
|
224
|
+
tier: LicenseTier;
|
|
225
|
+
name: string;
|
|
226
|
+
monthlyPriceVnd: number;
|
|
227
|
+
termMonthsAllowed?: number[];
|
|
228
|
+
durationDays?: number | null;
|
|
229
|
+
entitlements: LicenseEntitlements;
|
|
230
|
+
purchasable?: boolean;
|
|
231
|
+
active?: boolean;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* `PATCH /v1/platform/license-plans/:id`. Licenses already granted keep their own copy. A named
|
|
235
|
+
* interface, not `Partial<Omit<…>>`: the OpenAPI generator names an inline generic after the file's
|
|
236
|
+
* absolute path.
|
|
237
|
+
*/
|
|
238
|
+
export interface UpdateLicensePlanRequest {
|
|
239
|
+
name?: string;
|
|
240
|
+
monthlyPriceVnd?: number;
|
|
241
|
+
termMonthsAllowed?: number[];
|
|
242
|
+
durationDays?: number | null;
|
|
243
|
+
entitlements?: LicenseEntitlements;
|
|
244
|
+
purchasable?: boolean;
|
|
245
|
+
active?: boolean;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Why a request was refused with 402 (OCT-329): the license doesn't include the feature, or the
|
|
249
|
+
* organization has used up a limit. 403 stays for "not allowed whatever the plan".
|
|
250
|
+
*/
|
|
251
|
+
/**
|
|
252
|
+
* Why a 402 refused the request. `LICENSE_EXPIRED`: the license is past its grace period, so new
|
|
253
|
+
* transactions (earn, POS reserve, paid voucher claims) are refused until it is renewed.
|
|
254
|
+
*/
|
|
255
|
+
export type LicenseErrorCode = 'LICENSE_FEATURE_NOT_INCLUDED' | 'LICENSE_LIMIT_REACHED' | 'LICENSE_EXPIRED';
|
|
256
|
+
/** The body of a 402. `feature` or `limit` says which; `used` and `allowed` come with a limit. */
|
|
257
|
+
export interface LicenseErrorBody {
|
|
258
|
+
statusCode: 402;
|
|
259
|
+
code: LicenseErrorCode;
|
|
260
|
+
message: string;
|
|
261
|
+
feature?: LicenseFeature;
|
|
262
|
+
limit?: keyof LicenseLimits;
|
|
263
|
+
used?: number;
|
|
264
|
+
/** The plan's limit. For transactions, `used` can be past it by the extra 10% a month may go over. */
|
|
265
|
+
allowed?: number;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* New transactions are refused once a license month's count reaches this share of
|
|
269
|
+
* `transactionsMonthly`: the 10% above the limit gives the partner time to upgrade or renew.
|
|
270
|
+
*/
|
|
271
|
+
export declare const LICENSE_TRANSACTION_HARD_LIMIT_PERCENT = 110;
|
|
272
|
+
/** The shares of `transactionsMonthly` that send a warning, once each per license month. */
|
|
273
|
+
export type LicenseUsageThreshold = 80 | 100;
|
|
274
|
+
export declare const LICENSE_USAGE_THRESHOLDS: readonly LicenseUsageThreshold[];
|
|
275
|
+
/** `license.usage_threshold`: this license month's transactions reached 80% or 100% of the limit. */
|
|
276
|
+
export interface LicenseUsageThresholdEventData {
|
|
277
|
+
limit: 'transactionsMonthly';
|
|
278
|
+
threshold: LicenseUsageThreshold;
|
|
279
|
+
used: number;
|
|
280
|
+
/** The plan's `transactionsMonthly`. New transactions stop at 110% of it. */
|
|
281
|
+
allowed: number;
|
|
282
|
+
periodStart: string;
|
|
283
|
+
periodEnd: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* `license.limit_refused` (internal, OCT-346): the first transaction of a license month refused with
|
|
287
|
+
* 402, at 110% of the limit (`LICENSE_LIMIT_REACHED`) or past an expired license's grace
|
|
288
|
+
* (`LICENSE_EXPIRED`): the business is turning customers away. Later ones that month only add to
|
|
289
|
+
* `license_usage.refused_transactions`, so the feed isn't flooded. A refused member, API key or team
|
|
290
|
+
* member is only counted (`refused_resources`): whoever tried got the 402 in the console already.
|
|
291
|
+
*/
|
|
292
|
+
export interface LicenseLimitRefusedEventData {
|
|
293
|
+
licenseId: string;
|
|
294
|
+
tier: LicenseTier;
|
|
295
|
+
planName: string;
|
|
296
|
+
code: 'LICENSE_LIMIT_REACHED' | 'LICENSE_EXPIRED';
|
|
297
|
+
/** `transactionsMonthly` when it was full; `null` for an expired license. */
|
|
298
|
+
limit: 'transactionsMonthly' | null;
|
|
299
|
+
used: number | null;
|
|
300
|
+
allowed: number | null;
|
|
301
|
+
periodStart: string;
|
|
302
|
+
periodEnd: string;
|
|
303
|
+
}
|
|
304
|
+
/** Days before `endsAt` that send a reminder, latest first. */
|
|
305
|
+
export declare const LICENSE_EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
|
|
306
|
+
/**
|
|
307
|
+
* A step of a license's end, in order: reminders before `endsAt`, then `GRACE` once it has passed
|
|
308
|
+
* (still working), then `EXPIRED` once the grace period is over (new transactions refused).
|
|
309
|
+
*/
|
|
310
|
+
export type LicenseExpiryStage = 'DAYS_30' | 'DAYS_7' | 'DAYS_1' | 'GRACE' | 'EXPIRED';
|
|
311
|
+
export declare const LICENSE_EXPIRY_STAGES: readonly LicenseExpiryStage[];
|
|
312
|
+
/**
|
|
313
|
+
* `license.expiry_notice`: the organization's license reached a step of its end. Sent once per step,
|
|
314
|
+
* and only for the latest license, so a license already renewed sends nothing more. When several
|
|
315
|
+
* steps passed unseen (no worker ran), only the current one is sent.
|
|
316
|
+
*/
|
|
317
|
+
export interface LicenseExpiryNoticeEventData {
|
|
318
|
+
licenseId: string;
|
|
319
|
+
stage: LicenseExpiryStage;
|
|
320
|
+
tier: LicenseTier;
|
|
321
|
+
planName: string;
|
|
322
|
+
endsAt: string;
|
|
323
|
+
graceEndsAt: string;
|
|
324
|
+
/** Whole days until `endsAt`, 0 once it has passed. */
|
|
325
|
+
daysLeft: number;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* `POST /v1/platform/organizations/:organizationId/license`, System Admin: grants `months` of
|
|
329
|
+
* `planId`. It follows the current license (from its `endsAt`) while that is active or in grace,
|
|
330
|
+
* and starts now once it has expired or when there is none.
|
|
331
|
+
*/
|
|
332
|
+
export interface RenewLicenseRequest {
|
|
333
|
+
planId: string;
|
|
334
|
+
months: number;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* An order to buy or renew a license (OCT-330), paid by bank transfer. `PAID` once the money
|
|
338
|
+
* arrived, `CANCELED` when the Owner dropped it or chose another plan. `EXPIRED` is never stored:
|
|
339
|
+
* it is a `PENDING` order past `expiresAt`, and a transfer for it is no longer accepted.
|
|
340
|
+
*/
|
|
341
|
+
export type LicenseOrderStatus = 'PENDING' | 'PAID' | 'CANCELED';
|
|
342
|
+
export type LicenseOrderState = LicenseOrderStatus | 'EXPIRED';
|
|
343
|
+
/** How long an order can be paid. */
|
|
344
|
+
export declare const LICENSE_ORDER_TTL_HOURS = 24;
|
|
345
|
+
/** Every payment code starts with this, then 8 digits; SePay finds it in the transfer content. */
|
|
346
|
+
export declare const LICENSE_PAYMENT_CODE_PREFIX = "OCTAP";
|
|
347
|
+
/** `POST /v1/console/organizations/:organizationId/license/orders`, Owner only. */
|
|
348
|
+
export interface CreateLicenseOrderRequest {
|
|
349
|
+
planId: string;
|
|
350
|
+
/** One of the plan's `termMonthsAllowed`. */
|
|
351
|
+
termMonths: number;
|
|
352
|
+
}
|
|
353
|
+
/** An order and how to pay it. The amount is always the plan's monthly price times the term. */
|
|
354
|
+
export interface LicenseOrderDto {
|
|
355
|
+
id: string;
|
|
356
|
+
organizationId: string;
|
|
357
|
+
planId: string;
|
|
358
|
+
tier: LicenseTier;
|
|
359
|
+
planName: string;
|
|
360
|
+
termMonths: number;
|
|
361
|
+
amountVnd: number;
|
|
362
|
+
/** Put it in the transfer content as is: that is how the payment is matched to this order. */
|
|
363
|
+
paymentCode: string;
|
|
364
|
+
state: LicenseOrderState;
|
|
365
|
+
/** VietQR image for exactly `amountVnd`, with `paymentCode` as the transfer content. */
|
|
366
|
+
qrUrl: string;
|
|
367
|
+
bankAccount: string;
|
|
368
|
+
bankCode: string;
|
|
369
|
+
expiresAt: string;
|
|
370
|
+
paidAt: string | null;
|
|
371
|
+
createdAt: string;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* A bank transfer SePay reported (OCT-330): `RECEIVED` until the worker processes it, then `MATCHED`
|
|
375
|
+
* (it paid an order, by itself or by a System Admin's `pay`), `UNMATCHED` (a System Admin decides),
|
|
376
|
+
* `IGNORED` (money going out, or set aside by a System Admin) or `REFUNDED` (sent back in full).
|
|
377
|
+
*/
|
|
378
|
+
export type PaymentTransferStatus = 'RECEIVED' | 'MATCHED' | 'UNMATCHED' | 'IGNORED' | 'REFUNDED';
|
|
379
|
+
/** How Core learned of a transfer: SePay's webhook, or the daily reconciliation with SePay's API. */
|
|
380
|
+
export type PaymentTransferSource = 'WEBHOOK' | 'RECONCILE';
|
|
381
|
+
/** Why a transfer was not matched to an order. */
|
|
382
|
+
export type PaymentUnmatchedReason = 'NO_CODE' | 'UNKNOWN_CODE' | 'UNDERPAID' | 'ORDER_EXPIRED' | 'ORDER_CANCELED' | 'ORDER_ALREADY_PAID'
|
|
383
|
+
/** Processing failed unexpectedly; the transfer waits for a System Admin. */
|
|
384
|
+
| 'PROCESSING_ERROR';
|
|
385
|
+
/**
|
|
386
|
+
* A transfer paid an order: `license.activated` (bought while none was in force, or after one
|
|
387
|
+
* expired), `license.renewed` (the same or a lower tier: it follows the license still active or in
|
|
388
|
+
* grace) or `license.upgraded` (a higher tier: it starts now, and replaces the license in force and
|
|
389
|
+
* any queued after it, whose days left are added as `bonusDays`).
|
|
390
|
+
*/
|
|
391
|
+
export interface LicensePurchasedEventData {
|
|
392
|
+
licenseId: string;
|
|
393
|
+
orderId: string;
|
|
394
|
+
paymentCode: string;
|
|
395
|
+
tier: LicenseTier;
|
|
396
|
+
planName: string;
|
|
397
|
+
termMonths: number;
|
|
398
|
+
amountVnd: number;
|
|
399
|
+
/** What came in above the order's amount, to refund; 0 when exact. */
|
|
400
|
+
overpaidVnd: number;
|
|
401
|
+
startsAt: string;
|
|
402
|
+
/** On an upgrade, `bonusDays` past the term. */
|
|
403
|
+
endsAt: string;
|
|
404
|
+
/**
|
|
405
|
+
* `license.upgraded` only: the days the replaced licenses had left, added at the new plan's price
|
|
406
|
+
* (whole days, rounded down). 0 otherwise.
|
|
407
|
+
*/
|
|
408
|
+
bonusDays: number;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* `license.payment_needs_attention`: a transfer for one of the organization's orders couldn't pay it
|
|
412
|
+
* (too little, or the order had expired, was canceled or was already paid). OctaP reviews it.
|
|
413
|
+
*/
|
|
414
|
+
export interface LicensePaymentNeedsAttentionEventData {
|
|
415
|
+
transferId: string;
|
|
416
|
+
orderId: string;
|
|
417
|
+
paymentCode: string;
|
|
418
|
+
reason: Exclude<PaymentUnmatchedReason, 'NO_CODE' | 'UNKNOWN_CODE' | 'PROCESSING_ERROR'>;
|
|
419
|
+
receivedVnd: number;
|
|
420
|
+
expectedVnd: number;
|
|
421
|
+
}
|
|
422
|
+
/** What a System Admin did to a transfer (OCT-330 part 3). */
|
|
423
|
+
export type PaymentTransferAction = 'PAY' | 'REFUND' | 'IGNORE';
|
|
424
|
+
/** One System Admin action on a transfer, as recorded: never edited or removed. */
|
|
425
|
+
export interface PaymentTransferActionDto {
|
|
426
|
+
id: string;
|
|
427
|
+
action: PaymentTransferAction;
|
|
428
|
+
reason: string;
|
|
429
|
+
/** `REFUND`: the amount sent back. */
|
|
430
|
+
amountVnd: number | null;
|
|
431
|
+
/** `PAY`: the order it paid. */
|
|
432
|
+
orderId: string | null;
|
|
433
|
+
/** `REFUND`: the bank's reference of the transfer back, when given. */
|
|
434
|
+
bankReference: string | null;
|
|
435
|
+
/** The System Admin, a console user id. */
|
|
436
|
+
actorId: string | null;
|
|
437
|
+
createdAt: string;
|
|
438
|
+
}
|
|
439
|
+
/** A transfer, for the System Admin (`GET /v1/platform/payment-transfers`). */
|
|
440
|
+
export interface PaymentTransferDto {
|
|
441
|
+
id: string;
|
|
442
|
+
source: PaymentTransferSource;
|
|
443
|
+
/** SePay's id from the webhook; null for one found by reconciliation only. */
|
|
444
|
+
sepayId: number | null;
|
|
445
|
+
/** SePay's API id (a UUID), for one found by reconciliation. */
|
|
446
|
+
sepayTransactionId: string | null;
|
|
447
|
+
gateway: string;
|
|
448
|
+
accountNumber: string;
|
|
449
|
+
transferType: 'in' | 'out';
|
|
450
|
+
amountVnd: number;
|
|
451
|
+
/** The `OCTAP` payment code found, or null. */
|
|
452
|
+
code: string | null;
|
|
453
|
+
content: string;
|
|
454
|
+
/** The bank's reference of the transfer. */
|
|
455
|
+
referenceCode: string | null;
|
|
456
|
+
/** When the money moved. */
|
|
457
|
+
transactionAt: string;
|
|
458
|
+
status: PaymentTransferStatus;
|
|
459
|
+
/** Why it was not matched (`PaymentUnmatchedReason`), or `OUTGOING`. Kept after a System Admin pays it. */
|
|
460
|
+
reason: string | null;
|
|
461
|
+
organizationId: string | null;
|
|
462
|
+
orderId: string | null;
|
|
463
|
+
/** What came in above the order's amount. */
|
|
464
|
+
overpaidVnd: number;
|
|
465
|
+
/** What was sent back, recorded by `refund`. */
|
|
466
|
+
refundedVnd: number;
|
|
467
|
+
receivedAt: string;
|
|
468
|
+
processedAt: string | null;
|
|
469
|
+
}
|
|
470
|
+
/** One transfer with SePay's payload as sent and every System Admin action on it. */
|
|
471
|
+
export interface PaymentTransferDetailDto extends PaymentTransferDto {
|
|
472
|
+
raw: Record<string, unknown>;
|
|
473
|
+
actions: PaymentTransferActionDto[];
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* `GET /v1/platform/payment-transfers`: `status` defaults to `UNMATCHED`, the ones waiting for a
|
|
477
|
+
* System Admin; `ALL` lists every status. `limit` is 1 to 100, 50 by default.
|
|
478
|
+
*/
|
|
479
|
+
export interface PaymentTransferListQuery {
|
|
480
|
+
status?: PaymentTransferStatus | 'ALL';
|
|
481
|
+
cursor?: string;
|
|
482
|
+
limit?: number;
|
|
483
|
+
}
|
|
484
|
+
/** Newest first; pass `nextCursor` back as `cursor` for the next page. */
|
|
485
|
+
export interface PaymentTransferPage {
|
|
486
|
+
items: PaymentTransferDto[];
|
|
487
|
+
nextCursor: string | null;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* `POST /v1/platform/payment-transfers/:id/pay`: pays an order with an `UNMATCHED` transfer, as if
|
|
491
|
+
* it had matched. `orderId` names another order (a wrong code in the content); without it, the
|
|
492
|
+
* order the transfer was matched to (past its 24 hours, or short and accepted anyway).
|
|
493
|
+
*/
|
|
494
|
+
export interface PayPaymentTransferRequest {
|
|
495
|
+
orderId?: string;
|
|
496
|
+
reason: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* `POST /v1/platform/payment-transfers/:id/refund`: records money sent back outside OctaP (SePay
|
|
500
|
+
* can't refund a bank transfer). At most what is left of an `UNMATCHED` transfer, or of what a
|
|
501
|
+
* `MATCHED` one paid above its order.
|
|
502
|
+
*/
|
|
503
|
+
export interface RefundPaymentTransferRequest {
|
|
504
|
+
amountVnd: number;
|
|
505
|
+
reason: string;
|
|
506
|
+
bankReference?: string;
|
|
507
|
+
}
|
|
508
|
+
/** `POST /v1/platform/payment-transfers/:id/ignore`: sets an `UNMATCHED` transfer aside as not OctaP's. */
|
|
509
|
+
export interface IgnorePaymentTransferRequest {
|
|
510
|
+
reason: string;
|
|
511
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
export const PLATFORM_LICENSE_STATES = ['ACTIVE', 'GRACE', 'EXPIRED', 'NONE'];
|
|
24
|
+
/**
|
|
25
|
+
* New transactions are refused once a license month's count reaches this share of
|
|
26
|
+
* `transactionsMonthly`: the 10% above the limit gives the partner time to upgrade or renew.
|
|
27
|
+
*/
|
|
28
|
+
export const LICENSE_TRANSACTION_HARD_LIMIT_PERCENT = 110;
|
|
29
|
+
export const LICENSE_USAGE_THRESHOLDS = [80, 100];
|
|
30
|
+
/** Days before `endsAt` that send a reminder, latest first. */
|
|
31
|
+
export const LICENSE_EXPIRY_REMINDER_DAYS = [30, 7, 1];
|
|
32
|
+
export const LICENSE_EXPIRY_STAGES = ['DAYS_30', 'DAYS_7', 'DAYS_1', 'GRACE', 'EXPIRED'];
|
|
33
|
+
/** How long an order can be paid. */
|
|
34
|
+
export const LICENSE_ORDER_TTL_HOURS = 24;
|
|
35
|
+
/** Every payment code starts with this, then 8 digits; SePay finds it in the transfer content. */
|
|
36
|
+
export const LICENSE_PAYMENT_CODE_PREFIX = 'OCTAP';
|
|
37
|
+
//# sourceMappingURL=licensing.js.map
|