@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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export const NOTIFICATION_SEVERITIES = ['ACTION', 'WARNING', 'INFO'];
|
|
2
|
+
/** How long a grouped notification's bucket lasts, aligned to the clock (14:00, 14:15, …). */
|
|
3
|
+
export const NOTIFICATION_GROUP_WINDOW_MINUTES = 15;
|
|
4
|
+
const always = (severity) => () => severity;
|
|
5
|
+
/**
|
|
6
|
+
* Every organization event type's rule, or `null` when it never notifies: a routine success the
|
|
7
|
+
* person who caused it already knows about. Typed over every `OrganizationEventType`, so a new event
|
|
8
|
+
* type does not compile until it says whether it notifies.
|
|
9
|
+
*/
|
|
10
|
+
export const NOTIFICATION_RULES = {
|
|
11
|
+
'credits.earned': null,
|
|
12
|
+
'credits.earn.confirmed': null,
|
|
13
|
+
'credits.earn.failed': {
|
|
14
|
+
console: { audience: 'MEMBER', severity: always('WARNING') },
|
|
15
|
+
groupBy: 'failureCode',
|
|
16
|
+
},
|
|
17
|
+
'credits.redemption.confirmed': null,
|
|
18
|
+
'credits.reversed': null,
|
|
19
|
+
'voucher.granted': null,
|
|
20
|
+
'voucher.redeemed': null,
|
|
21
|
+
'voucher.created': null,
|
|
22
|
+
'voucher.submitted': {
|
|
23
|
+
console: { audience: 'OWNER', severity: always('ACTION') },
|
|
24
|
+
resolves: ['voucherApproval'],
|
|
25
|
+
},
|
|
26
|
+
'voucher.returned': {
|
|
27
|
+
console: { audience: 'MEMBER', severity: always('ACTION') },
|
|
28
|
+
resolves: ['voucherApproval'],
|
|
29
|
+
},
|
|
30
|
+
'voucher.activated': {
|
|
31
|
+
console: { audience: 'MEMBER', severity: always('INFO') },
|
|
32
|
+
resolves: ['voucherApproval', 'voucherPublishFailed'],
|
|
33
|
+
},
|
|
34
|
+
'voucher.publish.failed': {
|
|
35
|
+
console: { audience: 'MEMBER', severity: always('ACTION') },
|
|
36
|
+
platform: { severity: always('WARNING') },
|
|
37
|
+
resolves: ['voucherPublishFailed'],
|
|
38
|
+
},
|
|
39
|
+
'voucher.paused': null,
|
|
40
|
+
'voucher.archived': { resolves: ['voucherPublishFailed'] },
|
|
41
|
+
'voucher.expired': { console: { audience: 'MEMBER', severity: always('INFO') } },
|
|
42
|
+
'voucher.member_expired': null,
|
|
43
|
+
'budget.low': { console: { audience: 'OWNER', severity: always('WARNING') } },
|
|
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
|
+
},
|
|
49
|
+
'license.expiry_notice': {
|
|
50
|
+
console: {
|
|
51
|
+
audience: 'OWNER',
|
|
52
|
+
severity: (data) => (data.stage === 'GRACE' || data.stage === 'EXPIRED' ? 'ACTION' : 'WARNING'),
|
|
53
|
+
},
|
|
54
|
+
platform: { severity: (data) => (data.stage === 'GRACE' || data.stage === 'EXPIRED' ? 'WARNING' : null) },
|
|
55
|
+
resolves: ['licenseRenewal'],
|
|
56
|
+
},
|
|
57
|
+
'budget.topped_up': { console: { audience: 'OWNER', severity: always('INFO') } },
|
|
58
|
+
'budget.top_up.failed': {
|
|
59
|
+
console: { audience: 'OWNER', severity: always('WARNING') },
|
|
60
|
+
platform: { severity: always('WARNING') },
|
|
61
|
+
},
|
|
62
|
+
'program.provisioned': {
|
|
63
|
+
console: { audience: 'OWNER', severity: always('INFO') },
|
|
64
|
+
platform: { severity: always('INFO') },
|
|
65
|
+
},
|
|
66
|
+
'program.provision.failed': {
|
|
67
|
+
console: { audience: 'OWNER', severity: always('WARNING') },
|
|
68
|
+
platform: { severity: always('WARNING') },
|
|
69
|
+
},
|
|
70
|
+
'program.earn_rate.changed': { console: { audience: 'OWNER', severity: always('INFO') } },
|
|
71
|
+
'program.earn_rate.failed': {
|
|
72
|
+
console: { audience: 'OWNER', severity: always('WARNING') },
|
|
73
|
+
platform: { severity: always('WARNING') },
|
|
74
|
+
},
|
|
75
|
+
'license.activated': {
|
|
76
|
+
console: { audience: 'OWNER', severity: always('INFO') },
|
|
77
|
+
platform: { severity: always('INFO') },
|
|
78
|
+
resolves: ['licenseRenewal', 'paymentUnderpaid'],
|
|
79
|
+
},
|
|
80
|
+
'license.renewed': {
|
|
81
|
+
console: { audience: 'OWNER', severity: always('INFO') },
|
|
82
|
+
platform: { severity: always('INFO') },
|
|
83
|
+
resolves: ['licenseRenewal', 'paymentUnderpaid'],
|
|
84
|
+
},
|
|
85
|
+
'license.upgraded': {
|
|
86
|
+
console: { audience: 'OWNER', severity: always('INFO') },
|
|
87
|
+
platform: { severity: always('INFO') },
|
|
88
|
+
resolves: ['licenseRenewal', 'paymentUnderpaid'],
|
|
89
|
+
},
|
|
90
|
+
'license.payment_needs_attention': {
|
|
91
|
+
// Short: the Owner can send the rest. Otherwise OctaP settles it (refund), so it is for information.
|
|
92
|
+
console: { audience: 'OWNER', severity: (data) => (data.reason === 'UNDERPAID' ? 'ACTION' : 'WARNING') },
|
|
93
|
+
platform: { severity: always('WARNING') },
|
|
94
|
+
resolves: ['paymentUnderpaid'],
|
|
95
|
+
},
|
|
96
|
+
'webhook.test': null,
|
|
97
|
+
'organization.change_request.decided': {
|
|
98
|
+
console: { audience: 'OWNER', severity: (data) => (data.outcome === 'REJECTED' ? 'WARNING' : 'INFO') },
|
|
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
|
+
},
|
|
108
|
+
};
|
|
109
|
+
/** The rule for `type`, or `null` for a type this build does not know or that never notifies. */
|
|
110
|
+
export function notificationRuleOf(type) {
|
|
111
|
+
const rule = NOTIFICATION_RULES[type];
|
|
112
|
+
return rule ?? null;
|
|
113
|
+
}
|
|
114
|
+
/** The unread count stops counting here. */
|
|
115
|
+
export const NOTIFICATION_UNREAD_CAP = 100;
|
|
116
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +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,EAAE,IAAI;IACvB,mBAAmB,EAAE;QACnB,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC1D,QAAQ,EAAE,CAAC,iBAAiB,CAAC;KAC9B;IACD,kBAAkB,EAAE;QAClB,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC3D,QAAQ,EAAE,CAAC,iBAAiB,CAAC;KAC9B;IACD,mBAAmB,EAAE;QACnB,OAAO,EAAE,EA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E,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;KACvG;IACD,+FAA+F;IAC/F,uBAAuB,EAAE,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;IAC/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,4 +1,46 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnouncementSeverity } from './announcements.js';
|
|
2
|
+
import type { GovernanceRequestType } from './governance.js';
|
|
3
|
+
import type { LicenseLimitRefusedEventData } from './licensing.js';
|
|
4
|
+
import type { WebhookEventData, WebhookEventType } from './webhooks.js';
|
|
5
|
+
/**
|
|
6
|
+
* Organization events that are never delivered as webhooks (OCT-30): they reach the console stream and
|
|
7
|
+
* in-app notifications only. One becomes a webhook by moving it into `WebhookEventType`.
|
|
8
|
+
*/
|
|
9
|
+
export type InternalEventType = 'organization.change_request.decided' | 'license.limit_refused' | 'platform.announcement';
|
|
10
|
+
/**
|
|
11
|
+
* `organization.change_request.decided`: a System Admin approved or rejected one of the organization's
|
|
12
|
+
* change requests. An approved program change is still on its way: its `program.*` or `budget.*`
|
|
13
|
+
* result follows. Not sent for an organization application (`CREATE_ORGANIZATION`).
|
|
14
|
+
*/
|
|
15
|
+
export interface ChangeRequestDecidedEventData {
|
|
16
|
+
changeRequestId: string;
|
|
17
|
+
requestType: GovernanceRequestType;
|
|
18
|
+
outcome: 'APPROVED' | 'REJECTED';
|
|
19
|
+
/** The System Admin's reason; always given for a rejection. */
|
|
20
|
+
reason: string | null;
|
|
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
|
+
}
|
|
35
|
+
interface InternalEventDataOf {
|
|
36
|
+
'organization.change_request.decided': ChangeRequestDecidedEventData;
|
|
37
|
+
'license.limit_refused': LicenseLimitRefusedEventData;
|
|
38
|
+
'platform.announcement': PlatformAnnouncementEventData;
|
|
39
|
+
}
|
|
40
|
+
/** Every type recorded in an organization's event log: webhook events and internal ones. */
|
|
41
|
+
export type OrganizationEventType = WebhookEventType | InternalEventType;
|
|
42
|
+
/** The payload of each organization event type. */
|
|
43
|
+
export type OrganizationEventData<T extends OrganizationEventType> = T extends WebhookEventType ? WebhookEventData<T> : T extends InternalEventType ? InternalEventDataOf[T] : never;
|
|
2
44
|
/**
|
|
3
45
|
* What changed, so a console screen knows what to refetch. Only ids: the stream never carries the
|
|
4
46
|
* data itself, which is read through the REST routes and their access checks.
|
|
@@ -18,9 +60,19 @@ export type OrganizationEventSubject = {
|
|
|
18
60
|
memberId: string;
|
|
19
61
|
} | {
|
|
20
62
|
kind: 'issuanceBudget';
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'license';
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'program';
|
|
21
67
|
} | {
|
|
22
68
|
kind: 'webhookEndpoint';
|
|
23
69
|
id: string;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'changeRequest';
|
|
72
|
+
id: string;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'announcement';
|
|
75
|
+
id: string;
|
|
24
76
|
};
|
|
25
77
|
/**
|
|
26
78
|
* One message of the console event stream (`GET /v1/console/organizations/:id/events`, OCT-326):
|
|
@@ -31,7 +83,8 @@ export interface OrganizationStreamEvent {
|
|
|
31
83
|
id: string;
|
|
32
84
|
/** Orders the organization's events; sent as the SSE `id`, so a reconnect resumes after it. */
|
|
33
85
|
sequence: number;
|
|
34
|
-
type
|
|
86
|
+
/** A webhook event type, or an internal one (`InternalEventType`) that no webhook carries. */
|
|
87
|
+
type: OrganizationEventType;
|
|
35
88
|
subject: OrganizationEventSubject;
|
|
36
89
|
occurredAt: string;
|
|
37
90
|
}
|
|
@@ -50,3 +103,4 @@ export declare const ORGANIZATION_STREAM_CONTROL: {
|
|
|
50
103
|
readonly accessRevoked: "stream.access_revoked";
|
|
51
104
|
};
|
|
52
105
|
export type OrganizationStreamControl = (typeof ORGANIZATION_STREAM_CONTROL)[keyof typeof ORGANIZATION_STREAM_CONTROL];
|
|
106
|
+
export {};
|
|
@@ -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","sourceRoot":"","sources":["../src/organization-slugs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,qFAAqF;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,OAAO;IACP,SAAS;IACT,OAAO;IACP,KAAK;IACL,KAAK;IACL,QAAQ;IACR,MAAM;IACN,SAAS;IACT,MAAM;IACN,UAAU;IACV,SAAS;IACT,WAAW;IACX,KAAK;IACL,WAAW;IACX,YAAY;IACZ,MAAM;IACN,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,KAAK;IACL,UAAU;IACV,KAAK;IACL,OAAO;IACP,OAAO;IACP,YAAY;IACZ,KAAK;IACL,eAAe;IACf,MAAM;IACN,SAAS;IACT,UAAU;IACV,UAAU;IACV,SAAS;IACT,MAAM;IACN,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,KAAK;CACN,CAAC;AAIF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAE3E;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,CAAC,MAAM,GAAG,eAAe,IAAI,IAAI,CAAC,MAAM,GAAG,eAAe,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5G,OAAO,SA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AC,KAAK,EAAE,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,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,10 +1,23 @@
|
|
|
1
1
|
import type { OrganizationApplicationInput } from './console.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* An organization's loyalty program terms, as approved through `PROVISION_PROGRAM` and later
|
|
4
|
+
* `UPDATE_EARN_RATE` and `PROGRAM_CAP_CHANGE` requests. `status` is `PROVISIONING` while the chain calls run, then `ACTIVE`.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProgramTerms {
|
|
7
|
+
status: string;
|
|
8
|
+
/** Points per 10,000 units of purchase. */
|
|
3
9
|
earnBps: number;
|
|
10
|
+
/** How long earned points last. Set once, at provisioning; never changes. */
|
|
4
11
|
expiryDays: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
/** The issuance budget set at provisioning, before any top-up (see the budget read for the live figure). */
|
|
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;
|
|
19
|
+
/** 1 at provisioning; each applied earn-rate change adds one. */
|
|
20
|
+
policyVersion: number;
|
|
8
21
|
}
|
|
9
22
|
export interface OrganizationProvisioningStatus {
|
|
10
23
|
operationId: string;
|
|
@@ -24,6 +37,8 @@ export interface PlatformOrganization {
|
|
|
24
37
|
logoUrl: string | null;
|
|
25
38
|
programStatus: string | null;
|
|
26
39
|
programControlId: string | null;
|
|
40
|
+
/** The program's current terms; null before a `PROVISION_PROGRAM` request is approved and run. */
|
|
41
|
+
program: ProgramTerms | null;
|
|
27
42
|
createdAt: string;
|
|
28
43
|
provisioning: OrganizationProvisioningStatus | null;
|
|
29
44
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ProgramAnalyticsQuery, ProgramAnalyticsSummary } from './analytics.js';
|
|
2
|
+
import type { RequestLogCredentialRef, RequestLogTailQuery, RequestLogDetail, RequestLogEntry, RequestLogErrorGroup, RequestLogFilters, RequestLogListQuery, RequestLogStats, RequestLogSummary, RequestLogTimeseriesQuery } from './request-logs.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a System Admin reads about the platform (OCT-352), under `/v1/platform`. Figures across
|
|
5
|
+
* organizations are for the platform only: no console route ever shows one merchant another's data.
|
|
6
|
+
* A System Admin's read of one organization's audit log or request log is recorded in that
|
|
7
|
+
* organization's own audit log (`platform.audit_log.read`, `platform.request_log.read`).
|
|
8
|
+
*/
|
|
9
|
+
/** `GET /v1/platform/analytics/summary`: the console summary's figures, summed over every organization. */
|
|
10
|
+
export interface PlatformAnalyticsSummary extends ProgramAnalyticsSummary {
|
|
11
|
+
/** Organizations currently ACTIVE. */
|
|
12
|
+
activeOrganizations: number;
|
|
13
|
+
}
|
|
14
|
+
export type PlatformOrganizationAnalyticsSort = 'earned' | 'redeemed' | 'activeMembers' | 'enrolledMembers' | 'name';
|
|
15
|
+
/** `GET /v1/platform/analytics/organizations`: one row per organization, paged. */
|
|
16
|
+
export interface PlatformOrganizationAnalyticsQuery extends ProgramAnalyticsQuery {
|
|
17
|
+
/** From 1. */
|
|
18
|
+
page?: number;
|
|
19
|
+
/** 1–100, default 25. */
|
|
20
|
+
limit?: number;
|
|
21
|
+
/** Default `earned`. Figures sort largest first, `name` A to Z. */
|
|
22
|
+
sort?: PlatformOrganizationAnalyticsSort;
|
|
23
|
+
}
|
|
24
|
+
/** One organization's figures in the window. An organization with no activity shows zeros. */
|
|
25
|
+
export interface PlatformOrganizationAnalytics {
|
|
26
|
+
organizationId: string;
|
|
27
|
+
name: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
status: string;
|
|
30
|
+
/** CONFIRMED earns in the window. */
|
|
31
|
+
earned: number;
|
|
32
|
+
/** CONFIRMED redemptions in the window. */
|
|
33
|
+
redeemed: number;
|
|
34
|
+
/** Distinct members with a CONFIRMED earn or redeem in the window. */
|
|
35
|
+
activeMembers: number;
|
|
36
|
+
/** Everyone ever enrolled, regardless of the window. */
|
|
37
|
+
enrolledMembers: number;
|
|
38
|
+
}
|
|
39
|
+
export interface PlatformOrganizationAnalyticsPage {
|
|
40
|
+
from: string;
|
|
41
|
+
to: string;
|
|
42
|
+
items: PlatformOrganizationAnalytics[];
|
|
43
|
+
page: number;
|
|
44
|
+
limit: number;
|
|
45
|
+
/** Organizations listed: every approved one (ACTIVE, SUSPENDED or ARCHIVED), never a pending or rejected application. */
|
|
46
|
+
total: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Request-log filters across organizations. With `organizationId`, or a `credentialId` (a key
|
|
50
|
+
* belongs to one organization), the read covers that organization only and is recorded in its
|
|
51
|
+
* audit log.
|
|
52
|
+
*/
|
|
53
|
+
export interface PlatformRequestLogFilters extends RequestLogFilters {
|
|
54
|
+
/** @format uuid */
|
|
55
|
+
organizationId?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PlatformRequestLogListQuery extends RequestLogListQuery {
|
|
58
|
+
/** @format uuid */
|
|
59
|
+
organizationId?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface PlatformRequestLogTimeseriesQuery extends RequestLogTimeseriesQuery {
|
|
62
|
+
/** @format uuid */
|
|
63
|
+
organizationId?: string;
|
|
64
|
+
}
|
|
65
|
+
/** The organization a logged call belongs to. */
|
|
66
|
+
export interface PlatformOrganizationRef {
|
|
67
|
+
organizationId: string;
|
|
68
|
+
organizationName: string;
|
|
69
|
+
}
|
|
70
|
+
export type PlatformRequestLogEntry = RequestLogEntry & PlatformOrganizationRef;
|
|
71
|
+
export interface PlatformRequestLogPage {
|
|
72
|
+
items: PlatformRequestLogEntry[];
|
|
73
|
+
page: number;
|
|
74
|
+
limit: number;
|
|
75
|
+
total: number;
|
|
76
|
+
}
|
|
77
|
+
export type PlatformRequestLogDetail = RequestLogDetail & PlatformOrganizationRef;
|
|
78
|
+
/**
|
|
79
|
+
* `GET /v1/platform/request-logs/tail`: the console's live tail across organizations, or one with
|
|
80
|
+
* `organizationId` (or a key's). Narrowed, it is recorded in that organization's audit log once,
|
|
81
|
+
* when the tail opens (the call without a cursor), not on every poll.
|
|
82
|
+
*/
|
|
83
|
+
export interface PlatformRequestLogTailQuery extends RequestLogTailQuery {
|
|
84
|
+
/** @format uuid */
|
|
85
|
+
organizationId?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface PlatformRequestLogTail {
|
|
88
|
+
items: PlatformRequestLogEntry[];
|
|
89
|
+
/** Opaque. Pass it back on the next poll, with the same filters. */
|
|
90
|
+
cursor: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The console summary, plus the 20 busiest organizations (empty when narrowed to one). Each key names
|
|
94
|
+
* its organization; across organizations only the 20 busiest keys are listed.
|
|
95
|
+
*/
|
|
96
|
+
export interface PlatformRequestLogSummary extends Omit<RequestLogSummary, 'byCredential'> {
|
|
97
|
+
byCredential: (RequestLogStats & {
|
|
98
|
+
credential: RequestLogCredentialRef;
|
|
99
|
+
} & PlatformOrganizationRef)[];
|
|
100
|
+
byOrganization: (RequestLogStats & PlatformOrganizationRef)[];
|
|
101
|
+
}
|
|
102
|
+
/** Failed calls grouped by organization, endpoint, status and error code. */
|
|
103
|
+
export type PlatformRequestLogErrorGroup = RequestLogErrorGroup & PlatformOrganizationRef;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-observability.js","sourceRoot":"","sources":["../src/platform-observability.ts"],"names":[],"mappings":""}
|
package/dist/rewards.d.ts
CHANGED
|
@@ -128,8 +128,13 @@ export interface CreateVoucherRequest {
|
|
|
128
128
|
validForDays?: number | null;
|
|
129
129
|
metadata?: Record<string, unknown>;
|
|
130
130
|
status?: 'DRAFT' | 'ACTIVE' | 'PAUSED';
|
|
131
|
+
/**
|
|
132
|
+
* The campaign it belongs to (OCT-340): one of this organization's that is not ENDED or ARCHIVED.
|
|
133
|
+
* Set only on create; it never changes afterwards.
|
|
134
|
+
*/
|
|
135
|
+
campaignId?: string;
|
|
131
136
|
}
|
|
132
|
-
export type UpdateVoucherRequest = Partial<CreateVoucherRequest
|
|
137
|
+
export type UpdateVoucherRequest = Partial<Omit<CreateVoucherRequest, 'campaignId'>>;
|
|
133
138
|
export interface VoucherDto {
|
|
134
139
|
id: string;
|
|
135
140
|
organizationId: string;
|
|
@@ -159,6 +164,8 @@ export interface VoucherDto {
|
|
|
159
164
|
approval?: VoucherApprovalDto | null;
|
|
160
165
|
/** The batch it was created or last imported in (`createVoucherBatch`), `null` if created on its own. */
|
|
161
166
|
batchId?: string | null;
|
|
167
|
+
/** The campaign it belongs to (OCT-340), `null` if none. */
|
|
168
|
+
campaignId?: string | null;
|
|
162
169
|
/** Who created it (or last replaced it by importing its code again); `null` if not recorded. */
|
|
163
170
|
createdBy: VoucherActorRef;
|
|
164
171
|
/**
|
|
@@ -276,6 +283,11 @@ export interface CreateVoucherBatchRequest {
|
|
|
276
283
|
items: VoucherBatchItem[];
|
|
277
284
|
/** Run every check and report each item's result, but write nothing. */
|
|
278
285
|
dryRun?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* A campaign (OCT-340), not ENDED or ARCHIVED, that every voucher this batch creates (or brings back
|
|
288
|
+
* from ARCHIVED) joins. A voucher the batch leaves as it is keeps its own campaign.
|
|
289
|
+
*/
|
|
290
|
+
campaignId?: string;
|
|
279
291
|
}
|
|
280
292
|
/** Machine-readable reason an item was not written. */
|
|
281
293
|
export type VoucherBatchItemErrorCode =
|
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,M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