@octap/contracts 0.3.0 → 0.3.4
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 +57 -0
- package/dist/announcements.d.ts +58 -0
- package/dist/announcements.js +12 -0
- package/dist/announcements.js.map +1 -0
- package/dist/exports.d.ts +54 -0
- package/dist/exports.js +9 -1
- package/dist/exports.js.map +1 -1
- package/dist/governance.d.ts +31 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +49 -0
- package/dist/ledger.js +7 -0
- package/dist/ledger.js.map +1 -0
- package/dist/licensing.d.ts +146 -1
- package/dist/licensing.js +2 -0
- package/dist/licensing.js.map +1 -1
- package/dist/loyalty.d.ts +18 -0
- package/dist/members.d.ts +5 -0
- package/dist/membership.d.ts +160 -0
- package/dist/membership.js +4 -0
- package/dist/membership.js.map +1 -0
- package/dist/notifications.js +13 -1
- package/dist/notifications.js.map +1 -1
- package/dist/organization-events.d.ts +21 -1
- 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 +6 -1
- package/dist/rewards.d.ts +45 -6
- package/dist/rewards.js.map +1 -1
- package/dist/webhooks.d.ts +8 -2
- package/package.json +3 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/** `OFF`: no levels (the default). `OCTAP`: OctaP runs them. `OWN_CODE`: your server sends them, OctaP shows them. */
|
|
2
|
+
export type MembershipMode = 'OFF' | 'OCTAP' | 'OWN_CODE';
|
|
3
|
+
/** What moves a customer up. `MANUAL`: nothing does, levels are set by hand. */
|
|
4
|
+
export type MembershipRule = 'POINTS_EARNED' | 'MONEY_SPENT' | 'PURCHASE_COUNT' | 'MANUAL';
|
|
5
|
+
/**
|
|
6
|
+
* `NEVER`: every purchase counts, and no one moves down. `YEARLY`: purchases of the last 12 months
|
|
7
|
+
* count, and a customer may move down 12 months after reaching their level.
|
|
8
|
+
*/
|
|
9
|
+
export type MembershipDowngrade = 'NEVER' | 'YEARLY';
|
|
10
|
+
/** Who decided a customer's level. `MANUAL` survives every automatic check until the Owner removes it. */
|
|
11
|
+
export type MembershipLevelSource = 'AUTOMATIC' | 'MANUAL' | 'OWN_CODE';
|
|
12
|
+
export type MembershipChangeCause = 'MOVED_UP' | 'MOVED_DOWN' | 'SET_BY_OWNER' | 'SET_BY_SERVER' | 'MANUAL_REMOVED' | 'LEVEL_REMOVED';
|
|
13
|
+
export declare const MEMBERSHIP_MAX_LEVELS = 20;
|
|
14
|
+
export declare const MEMBERSHIP_MAX_LEVEL_NAME_LENGTH = 60;
|
|
15
|
+
export declare const MEMBERSHIP_MAX_REASON_LENGTH = 500;
|
|
16
|
+
export interface MembershipLevelDto {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* What a customer must reach, in the rule's own unit: points, money in the program currency's smallest
|
|
21
|
+
* unit (as `purchaseAmount`), or purchases. `null` while levels are set by hand.
|
|
22
|
+
* @TJS-type ["integer", "null"]
|
|
23
|
+
*/
|
|
24
|
+
target: number | null;
|
|
25
|
+
/** Customers who hold it now. */
|
|
26
|
+
customers: number;
|
|
27
|
+
}
|
|
28
|
+
export interface MembershipSettingsDto {
|
|
29
|
+
mode: MembershipMode;
|
|
30
|
+
/** `null` until a rule is picked. */
|
|
31
|
+
rule: MembershipRule | null;
|
|
32
|
+
downgrade: MembershipDowngrade;
|
|
33
|
+
/** Lowest first. Kept while the mode is `OFF`. */
|
|
34
|
+
levels: MembershipLevelDto[];
|
|
35
|
+
}
|
|
36
|
+
/** A starting point. Picking one only fills the form: what is saved is yours and never follows the template. */
|
|
37
|
+
export interface MembershipTemplateDto {
|
|
38
|
+
rule: MembershipRule;
|
|
39
|
+
downgrade: MembershipDowngrade;
|
|
40
|
+
levels: {
|
|
41
|
+
name: string;
|
|
42
|
+
target: number | null;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
export interface MembershipLevelInput {
|
|
46
|
+
/** An existing level's id; leave out for a new level. */
|
|
47
|
+
id?: string;
|
|
48
|
+
name: string;
|
|
49
|
+
/** @TJS-type ["integer", "null"] */
|
|
50
|
+
target?: number | null;
|
|
51
|
+
}
|
|
52
|
+
/** The whole settings, replaced at once. The order of `levels` is their order, lowest first. */
|
|
53
|
+
export interface MembershipSettingsInput {
|
|
54
|
+
mode: MembershipMode;
|
|
55
|
+
rule: MembershipRule | null;
|
|
56
|
+
downgrade: MembershipDowngrade;
|
|
57
|
+
levels: MembershipLevelInput[];
|
|
58
|
+
/**
|
|
59
|
+
* Every existing level left out of `levels`. One that customers hold needs `moveToLevelId`: the
|
|
60
|
+
* existing level they get, or `null` for none.
|
|
61
|
+
*/
|
|
62
|
+
removed?: {
|
|
63
|
+
levelId: string;
|
|
64
|
+
/** @TJS-type ["string", "null"] */
|
|
65
|
+
moveToLevelId?: string | null;
|
|
66
|
+
}[];
|
|
67
|
+
}
|
|
68
|
+
/** How many customers each level would have once these settings are on and everyone is checked. */
|
|
69
|
+
export interface MembershipPreviewDto {
|
|
70
|
+
/** In the order of the request's `levels`. */
|
|
71
|
+
levels: {
|
|
72
|
+
name: string;
|
|
73
|
+
customers: number;
|
|
74
|
+
}[];
|
|
75
|
+
withoutLevel: number;
|
|
76
|
+
}
|
|
77
|
+
/** A customer's level as a read shows it. */
|
|
78
|
+
export interface MembershipCustomerLevel {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
source: MembershipLevelSource;
|
|
82
|
+
reachedAt: string | null;
|
|
83
|
+
}
|
|
84
|
+
export interface MembershipProgressDto {
|
|
85
|
+
mode: MembershipMode;
|
|
86
|
+
/** `null`: no level, or the feature is off. */
|
|
87
|
+
level: MembershipCustomerLevel | null;
|
|
88
|
+
/** `null` unless OctaP runs the levels by a rule that counts something. */
|
|
89
|
+
progress: {
|
|
90
|
+
rule: MembershipRule;
|
|
91
|
+
/** What counts so far. */
|
|
92
|
+
total: number;
|
|
93
|
+
/** Only purchases from this moment on count; `null` for all of them. */
|
|
94
|
+
countedSince: string | null;
|
|
95
|
+
/** The next level up, or `null` at the highest. */
|
|
96
|
+
next: {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
target: number;
|
|
100
|
+
remaining: number;
|
|
101
|
+
} | null;
|
|
102
|
+
/** When this customer may move down, or `null` if never. */
|
|
103
|
+
nextDownCheckAt: string | null;
|
|
104
|
+
} | null;
|
|
105
|
+
}
|
|
106
|
+
export interface SetMembershipLevelInput {
|
|
107
|
+
/**
|
|
108
|
+
* `null` for no level.
|
|
109
|
+
* @TJS-type ["string", "null"]
|
|
110
|
+
*/
|
|
111
|
+
levelId: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* Why, kept in the history. No personal data. Required when the Owner sets a level in the console;
|
|
114
|
+
* optional with an API key.
|
|
115
|
+
*/
|
|
116
|
+
reason?: string;
|
|
117
|
+
}
|
|
118
|
+
/** A customer reading their own level: the token `getIdToken()` of `@octap/browser-sdk` returns. */
|
|
119
|
+
export interface MyMembershipInput {
|
|
120
|
+
organizationId: string;
|
|
121
|
+
idToken: string;
|
|
122
|
+
}
|
|
123
|
+
export interface MembershipLevelChangeDto {
|
|
124
|
+
id: string;
|
|
125
|
+
from: {
|
|
126
|
+
id: string;
|
|
127
|
+
name: string;
|
|
128
|
+
} | null;
|
|
129
|
+
to: {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
} | null;
|
|
133
|
+
cause: MembershipChangeCause;
|
|
134
|
+
actorType: 'USER' | 'CREDENTIAL' | 'SYSTEM';
|
|
135
|
+
actorId: string | null;
|
|
136
|
+
reason: string | null;
|
|
137
|
+
/**
|
|
138
|
+
* For an automatic move: what was counted, and the target it was compared with. After a refund,
|
|
139
|
+
* `reversedTransactionId` names the reversed earn that lowered the level.
|
|
140
|
+
*/
|
|
141
|
+
rule: {
|
|
142
|
+
rule: MembershipRule;
|
|
143
|
+
total: number;
|
|
144
|
+
target: number | null;
|
|
145
|
+
countedSince: string | null;
|
|
146
|
+
reversedTransactionId?: string;
|
|
147
|
+
} | null;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
}
|
|
150
|
+
export interface MembershipHistoryQuery {
|
|
151
|
+
/** 1–100, 25 by default. */
|
|
152
|
+
limit?: number;
|
|
153
|
+
/** The last row's id from the previous page. */
|
|
154
|
+
cursor?: string;
|
|
155
|
+
}
|
|
156
|
+
/** Newest first. */
|
|
157
|
+
export interface MembershipHistoryPage {
|
|
158
|
+
items: MembershipLevelChangeDto[];
|
|
159
|
+
nextCursor: string | null;
|
|
160
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership.js","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC"}
|
package/dist/notifications.js
CHANGED
|
@@ -41,7 +41,11 @@ export const NOTIFICATION_RULES = {
|
|
|
41
41
|
'voucher.expired': { console: { audience: 'MEMBER', severity: always('INFO') } },
|
|
42
42
|
'voucher.member_expired': null,
|
|
43
43
|
'budget.low': { console: { audience: 'OWNER', severity: always('WARNING') } },
|
|
44
|
-
'license.usage_threshold': {
|
|
44
|
+
'license.usage_threshold': {
|
|
45
|
+
console: { audience: 'OWNER', severity: always('WARNING') },
|
|
46
|
+
// The System Admin hears of 100% only: 80% is the Owner's early warning.
|
|
47
|
+
platform: { severity: (data) => (data.threshold === 100 ? 'WARNING' : null) },
|
|
48
|
+
},
|
|
45
49
|
'license.expiry_notice': {
|
|
46
50
|
console: {
|
|
47
51
|
audience: 'OWNER',
|
|
@@ -93,6 +97,14 @@ export const NOTIFICATION_RULES = {
|
|
|
93
97
|
'organization.change_request.decided': {
|
|
94
98
|
console: { audience: 'OWNER', severity: (data) => (data.outcome === 'REJECTED' ? 'WARNING' : 'INFO') },
|
|
95
99
|
},
|
|
100
|
+
// A System Admin's announcement (OCT-396): for every member, as urgent as the admin marked it.
|
|
101
|
+
'platform.announcement': { console: { audience: 'MEMBER', severity: (data) => data.severity } },
|
|
102
|
+
// The first transaction of a license month refused (OCT-346): the business is turning customers away.
|
|
103
|
+
'license.limit_refused': {
|
|
104
|
+
console: { audience: 'OWNER', severity: always('ACTION') },
|
|
105
|
+
platform: { severity: always('WARNING') },
|
|
106
|
+
resolves: ['licenseRenewal'],
|
|
107
|
+
},
|
|
96
108
|
};
|
|
97
109
|
/** The rule for `type`, or `null` for a type this build does not know or that never notifies. */
|
|
98
110
|
export function notificationRuleOf(type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../src/notifications.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,uBAAuB,GAAoC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAoBtG,8FAA8F;AAC9F,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAkBpD,MAAM,MAAM,GAAG,CAAC,QAA8B,EAAE,EAAE,CAAC,GAAyB,EAAE,CAAC,QAAQ,CAAC;AAExF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiE;IAC9F,gBAAgB,EAAE,IAAI;IACtB,wBAAwB,EAAE,IAAI;IAC9B,qBAAqB,EAAE;QACrB,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;QAC5D,OAAO,EAAE,aAAa;KACvB;IACD,8BAA8B,EAAE,IAAI;IACpC,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EA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C/F,sGAAsG;IACtG,uBAAuB,EAAE;QACvB,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC1D,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;QACzC,QAAQ,EAAE,CAAC,gBAAgB,CAAC;KAC7B;CACF,CAAC;AAEF,iGAAiG;AACjG,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,IAAI,GAAI,kBAAiG,CAAC,IAAI,CAAC,CAAC;IACtH,OAAO,IAAI,IAAI,IAAI,CAAC;AACtB,CAAC;AAyKD,4CAA4C;AAC5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { AnnouncementSeverity } from './announcements.js';
|
|
1
2
|
import type { GovernanceRequestType } from './governance.js';
|
|
3
|
+
import type { LicenseLimitRefusedEventData } from './licensing.js';
|
|
2
4
|
import type { WebhookEventData, WebhookEventType } from './webhooks.js';
|
|
3
5
|
/**
|
|
4
6
|
* Organization events that are never delivered as webhooks (OCT-30): they reach the console stream and
|
|
5
7
|
* in-app notifications only. One becomes a webhook by moving it into `WebhookEventType`.
|
|
6
8
|
*/
|
|
7
|
-
export type InternalEventType = 'organization.change_request.decided';
|
|
9
|
+
export type InternalEventType = 'organization.change_request.decided' | 'license.limit_refused' | 'platform.announcement';
|
|
8
10
|
/**
|
|
9
11
|
* `organization.change_request.decided`: a System Admin approved or rejected one of the organization's
|
|
10
12
|
* change requests. An approved program change is still on its way: its `program.*` or `budget.*`
|
|
@@ -17,8 +19,23 @@ export interface ChangeRequestDecidedEventData {
|
|
|
17
19
|
/** The System Admin's reason; always given for a rejection. */
|
|
18
20
|
reason: string | null;
|
|
19
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* `platform.announcement`: a System Admin posted an announcement to the organization (OCT-396), such as
|
|
24
|
+
* planned maintenance or new prices. One event per organization it was sent to, with the same
|
|
25
|
+
* `announcementId`. Every active member sees it.
|
|
26
|
+
*/
|
|
27
|
+
export interface PlatformAnnouncementEventData {
|
|
28
|
+
announcementId: string;
|
|
29
|
+
title: string;
|
|
30
|
+
body: string | null;
|
|
31
|
+
/** An https link for more, or `null`. */
|
|
32
|
+
link: string | null;
|
|
33
|
+
severity: AnnouncementSeverity;
|
|
34
|
+
}
|
|
20
35
|
interface InternalEventDataOf {
|
|
21
36
|
'organization.change_request.decided': ChangeRequestDecidedEventData;
|
|
37
|
+
'license.limit_refused': LicenseLimitRefusedEventData;
|
|
38
|
+
'platform.announcement': PlatformAnnouncementEventData;
|
|
22
39
|
}
|
|
23
40
|
/** Every type recorded in an organization's event log: webhook events and internal ones. */
|
|
24
41
|
export type OrganizationEventType = WebhookEventType | InternalEventType;
|
|
@@ -53,6 +70,9 @@ export type OrganizationEventSubject = {
|
|
|
53
70
|
} | {
|
|
54
71
|
kind: 'changeRequest';
|
|
55
72
|
id: string;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'announcement';
|
|
75
|
+
id: string;
|
|
56
76
|
};
|
|
57
77
|
/**
|
|
58
78
|
* One message of the console event stream (`GET /v1/console/organizations/:id/events`, OCT-326):
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-events.js","sourceRoot":"","sources":["../src/organization-events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"organization-events.js","sourceRoot":"","sources":["../src/organization-events.ts"],"names":[],"mappings":"AAqFA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,cAAc;IACrB,YAAY,EAAE,sBAAsB;IACpC,aAAa,EAAE,uBAAuB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization slugs (OCT-367): an organization's address (`/orgs/:slug` today, a subdomain later).
|
|
3
|
+
* One set of rules for the application, the public resolve route, the availability check and a
|
|
4
|
+
* rename, so a slug that passes one passes all.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SLUG_MIN_LENGTH = 3;
|
|
7
|
+
export declare const SLUG_MAX_LENGTH = 48;
|
|
8
|
+
/** How long a renamed organization's old slug keeps redirecting, and stays taken. */
|
|
9
|
+
export declare const SLUG_REDIRECT_DAYS = 90;
|
|
10
|
+
/**
|
|
11
|
+
* Names Core or the web route, or might: never an organization's slug. One list, so a new route
|
|
12
|
+
* name is reserved everywhere at once.
|
|
13
|
+
*/
|
|
14
|
+
export declare const RESERVED_SLUGS: readonly string[];
|
|
15
|
+
export type SlugProblem = 'INVALID' | 'RESERVED';
|
|
16
|
+
/** Trimmed and lowercased: `' My-Shop '` is `my-shop`. */
|
|
17
|
+
export declare const normalizeSlug: (value: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* What's wrong with an already normalized slug, or `null`. Valid: 3–48 characters of `a-z`, `0-9`
|
|
20
|
+
* and single hyphens, not starting or ending with a hyphen, and not reserved.
|
|
21
|
+
*/
|
|
22
|
+
export declare function slugProblem(slug: string): SlugProblem | null;
|
|
23
|
+
/** Explains a problem to the person choosing a slug. */
|
|
24
|
+
export declare function slugProblemMessage(problem: SlugProblem): string;
|
|
25
|
+
/**
|
|
26
|
+
* The plain slug a business name suggests: diacritics stripped (`đ` becomes `d`, which Unicode
|
|
27
|
+
* doesn't decompose), anything else that isn't a letter or digit turned into single hyphens, cut to
|
|
28
|
+
* fit. `Cà Phê Sữa Đá` gives `ca-phe-sua-da`. `null` when nothing usable is left.
|
|
29
|
+
*/
|
|
30
|
+
export declare function slugFromName(name: string): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Slugs to offer for a business name, best first: the plain one, then variants with a short
|
|
33
|
+
* suffix, each valid and short enough. The caller keeps the available ones.
|
|
34
|
+
*/
|
|
35
|
+
export declare function slugCandidates(name: string, suffixes: readonly string[]): string[];
|
|
36
|
+
/** `GET /v1/console/organization-slugs/check?slug=&name=`. */
|
|
37
|
+
export interface OrganizationSlugCheckQuery {
|
|
38
|
+
/** The slug to check; normalized first. */
|
|
39
|
+
slug?: string;
|
|
40
|
+
/** A business name to suggest slugs from. */
|
|
41
|
+
name?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface OrganizationSlugCheck {
|
|
44
|
+
/** The normalized slug checked, or `null` when only `name` was given. */
|
|
45
|
+
slug: string | null;
|
|
46
|
+
available: boolean;
|
|
47
|
+
/** Why it isn't available, or `null` when it is (or nothing was checked). */
|
|
48
|
+
reason: 'TAKEN' | 'RESERVED' | 'INVALID' | null;
|
|
49
|
+
/** Up to 3 available slugs from `name`, best first. Empty without `name`. */
|
|
50
|
+
suggestions: string[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `GET /v1/organizations/resolve/:slug`. A slug an organization was renamed away from in the last
|
|
54
|
+
* `SLUG_REDIRECT_DAYS` days resolves too, with `redirectTo`: its current slug.
|
|
55
|
+
*/
|
|
56
|
+
export interface ResolvedOrganization {
|
|
57
|
+
organizationId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
/** The organization's current slug. */
|
|
60
|
+
slug: string;
|
|
61
|
+
/** Set when the slug asked for is an old one: send the visitor here. */
|
|
62
|
+
redirectTo?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* How often an organization may change its slug: at most `SLUG_CHANGES_PER_WINDOW` changes in
|
|
66
|
+
* `SLUG_CHANGE_WINDOW_DAYS` days. Each change keeps the old slug taken for `SLUG_REDIRECT_DAYS` days,
|
|
67
|
+
* so without a limit one organization could hold many slugs; a few changes still allow fixing a typo.
|
|
68
|
+
*/
|
|
69
|
+
export declare const SLUG_CHANGES_PER_WINDOW = 3;
|
|
70
|
+
export declare const SLUG_CHANGE_WINDOW_DAYS = 30;
|
|
71
|
+
/**
|
|
72
|
+
* `PUT /v1/console/organizations/:organizationId/slug`: the Owner changes the slug, applied at once
|
|
73
|
+
* with no review. Normalized and checked like an application's.
|
|
74
|
+
*/
|
|
75
|
+
export interface ChangeOrganizationSlugInput {
|
|
76
|
+
slug: string;
|
|
77
|
+
}
|
|
78
|
+
export interface OrganizationSlugChange {
|
|
79
|
+
/** The new, normalized slug. */
|
|
80
|
+
slug: string;
|
|
81
|
+
/** The old slug, which redirects to the new one until `redirectUntil`. */
|
|
82
|
+
previousSlug: string;
|
|
83
|
+
redirectUntil: string;
|
|
84
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization slugs (OCT-367): an organization's address (`/orgs/:slug` today, a subdomain later).
|
|
3
|
+
* One set of rules for the application, the public resolve route, the availability check and a
|
|
4
|
+
* rename, so a slug that passes one passes all.
|
|
5
|
+
*/
|
|
6
|
+
export const SLUG_MIN_LENGTH = 3;
|
|
7
|
+
export const SLUG_MAX_LENGTH = 48;
|
|
8
|
+
/** How long a renamed organization's old slug keeps redirecting, and stays taken. */
|
|
9
|
+
export const SLUG_REDIRECT_DAYS = 90;
|
|
10
|
+
/**
|
|
11
|
+
* Names Core or the web route, or might: never an organization's slug. One list, so a new route
|
|
12
|
+
* name is reserved everywhere at once.
|
|
13
|
+
*/
|
|
14
|
+
export const RESERVED_SLUGS = [
|
|
15
|
+
'about',
|
|
16
|
+
'account',
|
|
17
|
+
'admin',
|
|
18
|
+
'api',
|
|
19
|
+
'app',
|
|
20
|
+
'assets',
|
|
21
|
+
'auth',
|
|
22
|
+
'billing',
|
|
23
|
+
'blog',
|
|
24
|
+
'callback',
|
|
25
|
+
'console',
|
|
26
|
+
'dashboard',
|
|
27
|
+
'dev',
|
|
28
|
+
'developer',
|
|
29
|
+
'developers',
|
|
30
|
+
'docs',
|
|
31
|
+
'help',
|
|
32
|
+
'login',
|
|
33
|
+
'logout',
|
|
34
|
+
'mail',
|
|
35
|
+
'mcp',
|
|
36
|
+
'merchant',
|
|
37
|
+
'new',
|
|
38
|
+
'oauth',
|
|
39
|
+
'octap',
|
|
40
|
+
'onboarding',
|
|
41
|
+
'org',
|
|
42
|
+
'organizations',
|
|
43
|
+
'orgs',
|
|
44
|
+
'partner',
|
|
45
|
+
'partners',
|
|
46
|
+
'platform',
|
|
47
|
+
'pricing',
|
|
48
|
+
'root',
|
|
49
|
+
'settings',
|
|
50
|
+
'signin',
|
|
51
|
+
'signup',
|
|
52
|
+
'staging',
|
|
53
|
+
'static',
|
|
54
|
+
'status',
|
|
55
|
+
'support',
|
|
56
|
+
'system',
|
|
57
|
+
'test',
|
|
58
|
+
'v1',
|
|
59
|
+
'www',
|
|
60
|
+
];
|
|
61
|
+
/** Trimmed and lowercased: `' My-Shop '` is `my-shop`. */
|
|
62
|
+
export const normalizeSlug = (value) => value.trim().toLowerCase();
|
|
63
|
+
/**
|
|
64
|
+
* What's wrong with an already normalized slug, or `null`. Valid: 3–48 characters of `a-z`, `0-9`
|
|
65
|
+
* and single hyphens, not starting or ending with a hyphen, and not reserved.
|
|
66
|
+
*/
|
|
67
|
+
export function slugProblem(slug) {
|
|
68
|
+
if (slug.length < SLUG_MIN_LENGTH || slug.length > SLUG_MAX_LENGTH || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug))
|
|
69
|
+
return 'INVALID';
|
|
70
|
+
return RESERVED_SLUGS.includes(slug) ? 'RESERVED' : null;
|
|
71
|
+
}
|
|
72
|
+
/** Explains a problem to the person choosing a slug. */
|
|
73
|
+
export function slugProblemMessage(problem) {
|
|
74
|
+
return problem === 'RESERVED'
|
|
75
|
+
? 'That address is reserved by OctaP; choose another'
|
|
76
|
+
: `Use ${SLUG_MIN_LENGTH}–${SLUG_MAX_LENGTH} lowercase letters, numbers or single hyphens, not starting or ending with a hyphen`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The plain slug a business name suggests: diacritics stripped (`đ` becomes `d`, which Unicode
|
|
80
|
+
* doesn't decompose), anything else that isn't a letter or digit turned into single hyphens, cut to
|
|
81
|
+
* fit. `Cà Phê Sữa Đá` gives `ca-phe-sua-da`. `null` when nothing usable is left.
|
|
82
|
+
*/
|
|
83
|
+
export function slugFromName(name) {
|
|
84
|
+
const plain = name
|
|
85
|
+
.replace(/[đĐ]/g, 'd')
|
|
86
|
+
.normalize('NFD')
|
|
87
|
+
.replace(/\p{Diacritic}/gu, '')
|
|
88
|
+
.toLowerCase()
|
|
89
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
90
|
+
.replace(/^-+|-+$/g, '');
|
|
91
|
+
const cut = plain.slice(0, SLUG_MAX_LENGTH).replace(/-+$/, '');
|
|
92
|
+
return cut.length >= SLUG_MIN_LENGTH ? cut : null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Slugs to offer for a business name, best first: the plain one, then variants with a short
|
|
96
|
+
* suffix, each valid and short enough. The caller keeps the available ones.
|
|
97
|
+
*/
|
|
98
|
+
export function slugCandidates(name, suffixes) {
|
|
99
|
+
const base = slugFromName(name);
|
|
100
|
+
if (!base)
|
|
101
|
+
return [];
|
|
102
|
+
const variants = suffixes.map((suffix) => {
|
|
103
|
+
const room = SLUG_MAX_LENGTH - suffix.length - 1;
|
|
104
|
+
return `${base.slice(0, room).replace(/-+$/, '')}-${suffix}`;
|
|
105
|
+
});
|
|
106
|
+
return [base, ...variants].filter((slug, i, all) => slugProblem(slug) === null && all.indexOf(slug) === i);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* How often an organization may change its slug: at most `SLUG_CHANGES_PER_WINDOW` changes in
|
|
110
|
+
* `SLUG_CHANGE_WINDOW_DAYS` days. Each change keeps the old slug taken for `SLUG_REDIRECT_DAYS` days,
|
|
111
|
+
* so without a limit one organization could hold many slugs; a few changes still allow fixing a typo.
|
|
112
|
+
*/
|
|
113
|
+
export const SLUG_CHANGES_PER_WINDOW = 3;
|
|
114
|
+
export const SLUG_CHANGE_WINDOW_DAYS = 30;
|
|
115
|
+
//# sourceMappingURL=organization-slugs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-slugs.js","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AC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7G,CAAC;AAiCD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
|
package/dist/organizations.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OrganizationApplicationInput } from './console.js';
|
|
2
2
|
/**
|
|
3
3
|
* An organization's loyalty program terms, as approved through `PROVISION_PROGRAM` and later
|
|
4
|
-
* `UPDATE_EARN_RATE` requests. `status` is `PROVISIONING` while the chain calls run, then `ACTIVE`.
|
|
4
|
+
* `UPDATE_EARN_RATE` and `PROGRAM_CAP_CHANGE` requests. `status` is `PROVISIONING` while the chain calls run, then `ACTIVE`.
|
|
5
5
|
*/
|
|
6
6
|
export interface ProgramTerms {
|
|
7
7
|
status: string;
|
|
@@ -11,6 +11,11 @@ export interface ProgramTerms {
|
|
|
11
11
|
expiryDays: number;
|
|
12
12
|
/** The issuance budget set at provisioning, before any top-up (see the budget read for the live figure). */
|
|
13
13
|
initialBudget: number;
|
|
14
|
+
/**
|
|
15
|
+
* The most the program may ever be funded with, top-ups included. Top-ups up to it apply without
|
|
16
|
+
* review; raising or lowering it is a `PROGRAM_CAP_CHANGE` request a System Admin decides.
|
|
17
|
+
*/
|
|
18
|
+
budgetCap: number;
|
|
14
19
|
/** 1 at provisioning; each applied earn-rate change adds one. */
|
|
15
20
|
policyVersion: number;
|
|
16
21
|
}
|
package/dist/rewards.d.ts
CHANGED
|
@@ -211,29 +211,58 @@ export interface GrantVoucherRequest {
|
|
|
211
211
|
idempotencyKey: string;
|
|
212
212
|
}
|
|
213
213
|
/** Asks the customer to use a voucher. Only their signature marks it used. */
|
|
214
|
+
/**
|
|
215
|
+
* One voucher, by `serialCode`. To use several of one customer's vouchers with one signature, send
|
|
216
|
+
* `PrepareVoucherUsesRequest` instead. How vouchers combine, and the discount, stay with you.
|
|
217
|
+
*/
|
|
214
218
|
export interface PrepareVoucherUseRequest {
|
|
215
219
|
serialCode: string;
|
|
216
220
|
/** Persist the same key across retries. */
|
|
217
221
|
idempotencyKey: string;
|
|
222
|
+
/** Your order, echoed on the response and on each `voucher.redeemed`. 1–100 characters, no personal data. */
|
|
223
|
+
orderReference?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Several vouchers of one customer, used in one transaction they sign once: the chain marks all of
|
|
227
|
+
* them used, or none. 1–5 serials, no duplicates. If any one can't be used, nothing is prepared and
|
|
228
|
+
* the error names its serial. The same key with another set or `orderReference` is a 409.
|
|
229
|
+
*/
|
|
230
|
+
export interface PrepareVoucherUsesRequest {
|
|
231
|
+
serialCodes: string[];
|
|
232
|
+
/** Persist the same key across retries. */
|
|
233
|
+
idempotencyKey: string;
|
|
234
|
+
/** Your order, echoed on the response and on each `voucher.redeemed`. 1–100 characters, no personal data. */
|
|
235
|
+
orderReference?: string;
|
|
218
236
|
}
|
|
219
|
-
|
|
237
|
+
/** One voucher of a use, as prepared. */
|
|
238
|
+
export interface VoucherUseItem {
|
|
220
239
|
voucherOwnershipId: string;
|
|
221
240
|
voucherId: string;
|
|
222
241
|
serialCode: string;
|
|
223
242
|
/** AVAILABLE until the chain confirms the use. */
|
|
224
243
|
status: VoucherOwnershipStatus;
|
|
225
|
-
/** For the customer's device to sign. Null once the use has settled. */
|
|
226
|
-
digest: string | null;
|
|
227
|
-
transactionBytes: string | null;
|
|
228
244
|
voucherTitle: string;
|
|
229
245
|
discountType?: string | null;
|
|
230
246
|
discountValue?: string | null;
|
|
231
247
|
}
|
|
248
|
+
/** What `POST /v1/rewards/vouchers/use` answers to `serialCodes`. */
|
|
249
|
+
export interface PrepareVoucherUsesResponse {
|
|
250
|
+
/** Every voucher of the use, in `serialCode` order. */
|
|
251
|
+
vouchers: VoucherUseItem[];
|
|
252
|
+
/** For the customer's device to sign, once for all of them. Null once the use has settled. */
|
|
253
|
+
digest: string | null;
|
|
254
|
+
transactionBytes: string | null;
|
|
255
|
+
orderReference: string | null;
|
|
256
|
+
}
|
|
257
|
+
/** What `POST /v1/rewards/vouchers/use` answers to one `serialCode`: the voucher's fields at the top level too. */
|
|
258
|
+
export interface PrepareVoucherUseResponse extends VoucherUseItem, PrepareVoucherUsesResponse {
|
|
259
|
+
}
|
|
232
260
|
export interface FinalizeVoucherUseRequest {
|
|
233
261
|
digest: string;
|
|
234
262
|
signature: string;
|
|
235
263
|
}
|
|
236
|
-
|
|
264
|
+
/** One voucher the chain marked used. */
|
|
265
|
+
export interface RedeemedVoucher {
|
|
237
266
|
voucherOwnershipId: string;
|
|
238
267
|
voucherId: string;
|
|
239
268
|
serialCode: string;
|
|
@@ -242,8 +271,18 @@ export interface RedeemVoucherResponse {
|
|
|
242
271
|
voucherTitle: string;
|
|
243
272
|
discountType?: string | null;
|
|
244
273
|
discountValue?: string | null;
|
|
245
|
-
/** The customer-signed transaction that marked it used. */
|
|
274
|
+
/** The customer-signed transaction that marked it used, shared by every voucher of the use. */
|
|
275
|
+
blockchainDigest: string;
|
|
276
|
+
}
|
|
277
|
+
/** What finalize answers for a use of several vouchers. */
|
|
278
|
+
export interface RedeemVouchersResponse {
|
|
279
|
+
/** Every voucher of the use, in `serialCode` order. */
|
|
280
|
+
vouchers: RedeemedVoucher[];
|
|
246
281
|
blockchainDigest: string;
|
|
282
|
+
orderReference: string | null;
|
|
283
|
+
}
|
|
284
|
+
/** What finalize answers for a use of one voucher: its fields at the top level too. */
|
|
285
|
+
export interface RedeemVoucherResponse extends RedeemedVoucher, RedeemVouchersResponse {
|
|
247
286
|
}
|
|
248
287
|
export interface VoucherOwnershipDto {
|
|
249
288
|
refundPolicy?: VoucherRefundPolicySnapshot;
|
package/dist/rewards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewards.js","sourceRoot":"","sources":["../src/rewards.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,OAAO,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiE,EACjE,QAAc;IAEd,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC;
|
|
1
|
+
{"version":3,"file":"rewards.js","sourceRoot":"","sources":["../src/rewards.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,OAAO,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiE,EACjE,QAAc;IAEd,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC;AA0OD,sGAAsG;AACtG,qGAAqG;AACrG,sCAAsC;AACtC,sGAAsG;AAEtG,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,gDAAgD;AAChD,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC"}
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LicenseExpiryNoticeEventData, LicensePaymentNeedsAttentionEventData, LicensePurchasedEventData, LicenseUsageThresholdEventData } from './licensing.js';
|
|
2
2
|
import type { BudgetWarningThreshold } from './loyalty.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RedeemedVoucher, VoucherActorRef, VoucherOwnershipStatus, VoucherPublishStatus, VoucherStatus } from './rewards.js';
|
|
4
4
|
export type WebhookEndpointStatus = 'ACTIVE' | 'DISABLED';
|
|
5
5
|
export type WebhookDeliveryStatus = 'PENDING' | 'DELIVERED' | 'DEAD_LETTER';
|
|
6
6
|
export interface WebhookEndpointDto {
|
|
@@ -204,8 +204,14 @@ export interface VoucherMemberExpiredEventData {
|
|
|
204
204
|
* `voucher.redeemed`: the customer signed and the chain marked their voucher used. Deliver the benefit
|
|
205
205
|
* on this event. No points move here; a paid claim already sent `credits.redemption.confirmed`.
|
|
206
206
|
*/
|
|
207
|
-
|
|
207
|
+
/**
|
|
208
|
+
* One per voucher, also when several were used with one signature: those share `blockchainDigest`
|
|
209
|
+
* and `orderReference`, so wait for each voucher of the order before delivering its benefit.
|
|
210
|
+
*/
|
|
211
|
+
export interface VoucherRedeemedEventData extends RedeemedVoucher {
|
|
208
212
|
organizationEndUserId: string;
|
|
213
|
+
/** The `orderReference` sent when preparing the use; null without one, or when no prepared use is behind it. */
|
|
214
|
+
orderReference: string | null;
|
|
209
215
|
}
|
|
210
216
|
/**
|
|
211
217
|
* The voucher as it is right after the change. Every voucher lifecycle event carries it: fetch the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octap/contracts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Typed request/response contracts for the Octap Core REST API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"dependencies": {},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
-
"README.md"
|
|
26
|
+
"README.md",
|
|
27
|
+
"CHANGELOG.md"
|
|
27
28
|
],
|
|
28
29
|
"publishConfig": {
|
|
29
30
|
"access": "public"
|