@aglyn/aglyn 1.0.0-beta.270 → 1.0.0-beta.271
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/package.json +11 -11
- package/src/lib/app-utils/activity-labels.js +2 -0
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +13 -0
- package/src/lib/app-utils/analytics-events.js +2 -0
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/append-only-history.d.ts +94 -0
- package/src/lib/app-utils/append-only-history.js +73 -0
- package/src/lib/app-utils/append-only-history.js.map +1 -0
- package/src/lib/app-utils/bundle-intent.d.ts +186 -0
- package/src/lib/app-utils/bundle-intent.js +386 -0
- package/src/lib/app-utils/bundle-intent.js.map +1 -0
- package/src/lib/app-utils/client-build.d.ts +204 -0
- package/src/lib/app-utils/client-build.js +237 -0
- package/src/lib/app-utils/client-build.js.map +1 -0
- package/src/lib/app-utils/console-routes.d.ts +4 -0
- package/src/lib/app-utils/console-routes.js +2 -0
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +7 -5
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +5 -5
- package/src/lib/app-utils/docs-help.generated.js +9 -2
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +101 -31
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/margin-utilization.js +6 -4
- package/src/lib/app-utils/margin-utilization.js.map +1 -1
- package/src/lib/app-utils/media-filter.d.ts +26 -0
- package/src/lib/app-utils/media-filter.js +32 -0
- package/src/lib/app-utils/media-filter.js.map +1 -1
- package/src/lib/app-utils/onboarding-deep-link.d.ts +36 -2
- package/src/lib/app-utils/onboarding-deep-link.js +48 -5
- package/src/lib/app-utils/onboarding-deep-link.js.map +1 -1
- package/src/lib/app-utils/operator-alerts.js +21 -0
- package/src/lib/app-utils/operator-alerts.js.map +1 -1
- package/src/lib/app-utils/owner-approval-record.d.ts +102 -0
- package/src/lib/app-utils/owner-approval-record.js +148 -0
- package/src/lib/app-utils/owner-approval-record.js.map +1 -0
- package/src/lib/app-utils/plan-entitlements.d.ts +183 -67
- package/src/lib/app-utils/plan-entitlements.js +213 -58
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +10 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +4 -0
- package/src/lib/app-utils/server.js +7 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-care-project.d.ts +227 -0
- package/src/lib/app-utils/site-care-project.js +423 -0
- package/src/lib/app-utils/site-care-project.js.map +1 -0
- package/src/lib/app-utils/site-care.d.ts +268 -0
- package/src/lib/app-utils/site-care.js +283 -0
- package/src/lib/app-utils/site-care.js.map +1 -0
- package/src/lib/app-utils/upgrade-proposal.d.ts +29 -4
- package/src/lib/app-utils/upgrade-proposal.js +60 -9
- package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
- package/src/lib/foundation/definitions/org-billing.types.d.ts +40 -10
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +3 -1
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +48 -0
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/plugin-ai-capabilities.d.ts +19 -0
- package/src/lib/plugin-manager/plugin-ai-capabilities.js.map +1 -1
- package/src/lib/plugin-manager/plugin-domain-search.d.ts +81 -0
- package/src/lib/plugin-manager/plugin-domain-search.js +63 -0
- package/src/lib/plugin-manager/plugin-domain-search.js.map +1 -0
- package/src/lib/plugin-manager/plugin-entitlements.d.ts +23 -5
- package/src/lib/plugin-manager/plugin-entitlements.js +10 -0
- package/src/lib/plugin-manager/plugin-entitlements.js.map +1 -1
- package/src/lib/plugin-manager/purchase-gate-preclearance.d.ts +61 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.js +102 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.js.map +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* APPEND-ONLY HISTORY (AGL-3959).
|
|
19
|
+
*
|
|
20
|
+
* Work that bills — Site Care minutes and extra time, and the flat-quoted
|
|
21
|
+
* project invoice after it (AGL-3970) — keeps one dated row per thing that
|
|
22
|
+
* happened: a minute entry, a timer start, an approval, a charge, an email,
|
|
23
|
+
* a correction. Nothing is overwritten. A fix is a new row that says what it
|
|
24
|
+
* was before, what it is now, who changed it and why, so the record a person
|
|
25
|
+
* can be shown is the whole record.
|
|
26
|
+
*
|
|
27
|
+
* Each row carries two tellings of the same fact: `summary`, written for the
|
|
28
|
+
* owner in plain words (it is what their statement lists), and the
|
|
29
|
+
* structured `before` / `after` / `stripe` a staff member or the
|
|
30
|
+
* reconciliation reads. This module is the row's shape and its rules; the
|
|
31
|
+
* write — always a `create`, in the same batch as the change it records — is
|
|
32
|
+
* `@aglyn/tenant-data-admin/server/append-only-history-write`.
|
|
33
|
+
*/
|
|
34
|
+
/** The longest reason or summary a row keeps. */
|
|
35
|
+
export declare const HISTORY_TEXT_MAX = 500;
|
|
36
|
+
/** The Stripe object a row's money movement names. */
|
|
37
|
+
export interface HistoryStripeRef {
|
|
38
|
+
/** `invoiceitem`, `credit_note`, `refund`, `invoice`. */
|
|
39
|
+
object: string;
|
|
40
|
+
id: string;
|
|
41
|
+
/** Whole cents the object moved, when it moved money. */
|
|
42
|
+
amountCents?: number;
|
|
43
|
+
}
|
|
44
|
+
/** One row. */
|
|
45
|
+
export interface AppendOnlyHistoryRow {
|
|
46
|
+
/** When it happened, epoch ms. */
|
|
47
|
+
atMs: number;
|
|
48
|
+
/** Who did it; null when nobody did (a scheduled check). */
|
|
49
|
+
byUid: string | null;
|
|
50
|
+
byEmail: string | null;
|
|
51
|
+
/** What kind of thing happened, `noun.verb`: `minutes.corrected`. */
|
|
52
|
+
kind: string;
|
|
53
|
+
/** What happened, in plain words an owner can read. */
|
|
54
|
+
summary: string;
|
|
55
|
+
/** Why; required on every correction. */
|
|
56
|
+
reason: string | null;
|
|
57
|
+
before: Readonly<Record<string, unknown>> | null;
|
|
58
|
+
after: Readonly<Record<string, unknown>> | null;
|
|
59
|
+
stripe: HistoryStripeRef | null;
|
|
60
|
+
/** The record the row belongs to, when the history is shared by many. */
|
|
61
|
+
subjectId: string | null;
|
|
62
|
+
}
|
|
63
|
+
export interface HistoryRowInput {
|
|
64
|
+
atMs: number;
|
|
65
|
+
by: {
|
|
66
|
+
uid: string | null;
|
|
67
|
+
email: string | null;
|
|
68
|
+
};
|
|
69
|
+
kind: string;
|
|
70
|
+
summary: string;
|
|
71
|
+
reason?: string | null;
|
|
72
|
+
before?: Readonly<Record<string, unknown>> | null;
|
|
73
|
+
after?: Readonly<Record<string, unknown>> | null;
|
|
74
|
+
stripe?: HistoryStripeRef | null;
|
|
75
|
+
subjectId?: string | null;
|
|
76
|
+
}
|
|
77
|
+
/** A trimmed, bounded reason, or null when blank. */
|
|
78
|
+
export declare function cleanHistoryReason(reason: unknown): string | null;
|
|
79
|
+
/**
|
|
80
|
+
* The reason a correction must carry, or an error to show. Every change to
|
|
81
|
+
* something already recorded goes through this, so "why" is never optional
|
|
82
|
+
* where it matters.
|
|
83
|
+
*/
|
|
84
|
+
export declare function requireHistoryReason(reason: unknown): {
|
|
85
|
+
ok: true;
|
|
86
|
+
reason: string;
|
|
87
|
+
} | {
|
|
88
|
+
ok: false;
|
|
89
|
+
error: string;
|
|
90
|
+
};
|
|
91
|
+
/** A row from its parts, every field present so a reader never guesses. */
|
|
92
|
+
export declare function historyRow(input: HistoryRowInput): AppendOnlyHistoryRow;
|
|
93
|
+
/** Rows oldest first, ties kept in the order they were read. */
|
|
94
|
+
export declare function sortHistoryRows<Row extends Pick<AppendOnlyHistoryRow, 'atMs'>>(rows: readonly Row[]): Row[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* APPEND-ONLY HISTORY (AGL-3959).
|
|
18
|
+
*
|
|
19
|
+
* Work that bills — Site Care minutes and extra time, and the flat-quoted
|
|
20
|
+
* project invoice after it (AGL-3970) — keeps one dated row per thing that
|
|
21
|
+
* happened: a minute entry, a timer start, an approval, a charge, an email,
|
|
22
|
+
* a correction. Nothing is overwritten. A fix is a new row that says what it
|
|
23
|
+
* was before, what it is now, who changed it and why, so the record a person
|
|
24
|
+
* can be shown is the whole record.
|
|
25
|
+
*
|
|
26
|
+
* Each row carries two tellings of the same fact: `summary`, written for the
|
|
27
|
+
* owner in plain words (it is what their statement lists), and the
|
|
28
|
+
* structured `before` / `after` / `stripe` a staff member or the
|
|
29
|
+
* reconciliation reads. This module is the row's shape and its rules; the
|
|
30
|
+
* write — always a `create`, in the same batch as the change it records — is
|
|
31
|
+
* `@aglyn/tenant-data-admin/server/append-only-history-write`.
|
|
32
|
+
*/ /** The longest reason or summary a row keeps. */ export const HISTORY_TEXT_MAX = 500;
|
|
33
|
+
/** A trimmed, bounded reason, or null when blank. */ export function cleanHistoryReason(reason) {
|
|
34
|
+
const text = typeof reason === 'string' ? reason.trim().slice(0, HISTORY_TEXT_MAX) : '';
|
|
35
|
+
return text ? text : null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The reason a correction must carry, or an error to show. Every change to
|
|
39
|
+
* something already recorded goes through this, so "why" is never optional
|
|
40
|
+
* where it matters.
|
|
41
|
+
*/ export function requireHistoryReason(reason) {
|
|
42
|
+
const cleaned = cleanHistoryReason(reason);
|
|
43
|
+
return cleaned ? {
|
|
44
|
+
ok: true,
|
|
45
|
+
reason: cleaned
|
|
46
|
+
} : {
|
|
47
|
+
ok: false,
|
|
48
|
+
error: 'Say why — a reason is required.'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** A row from its parts, every field present so a reader never guesses. */ export function historyRow(input) {
|
|
52
|
+
var _input_by_uid, _input_by_email, _input_summary, _input_reason, _input_before, _input_after, _input_stripe, _input_subjectId;
|
|
53
|
+
return {
|
|
54
|
+
atMs: Math.floor(input.atMs),
|
|
55
|
+
byUid: (_input_by_uid = input.by.uid) != null ? _input_by_uid : null,
|
|
56
|
+
byEmail: (_input_by_email = input.by.email) != null ? _input_by_email : null,
|
|
57
|
+
kind: input.kind,
|
|
58
|
+
summary: String((_input_summary = input.summary) != null ? _input_summary : '').trim().slice(0, HISTORY_TEXT_MAX),
|
|
59
|
+
reason: cleanHistoryReason((_input_reason = input.reason) != null ? _input_reason : null),
|
|
60
|
+
before: (_input_before = input.before) != null ? _input_before : null,
|
|
61
|
+
after: (_input_after = input.after) != null ? _input_after : null,
|
|
62
|
+
stripe: (_input_stripe = input.stripe) != null ? _input_stripe : null,
|
|
63
|
+
subjectId: (_input_subjectId = input.subjectId) != null ? _input_subjectId : null
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Rows oldest first, ties kept in the order they were read. */ export function sortHistoryRows(rows) {
|
|
67
|
+
return rows.map((row, index)=>({
|
|
68
|
+
row,
|
|
69
|
+
index
|
|
70
|
+
})).sort((a, b)=>a.row.atMs - b.row.atMs || a.index - b.index).map(({ row })=>row);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=append-only-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/append-only-history.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * APPEND-ONLY HISTORY (AGL-3959).\n *\n * Work that bills — Site Care minutes and extra time, and the flat-quoted\n * project invoice after it (AGL-3970) — keeps one dated row per thing that\n * happened: a minute entry, a timer start, an approval, a charge, an email,\n * a correction. Nothing is overwritten. A fix is a new row that says what it\n * was before, what it is now, who changed it and why, so the record a person\n * can be shown is the whole record.\n *\n * Each row carries two tellings of the same fact: `summary`, written for the\n * owner in plain words (it is what their statement lists), and the\n * structured `before` / `after` / `stripe` a staff member or the\n * reconciliation reads. This module is the row's shape and its rules; the\n * write — always a `create`, in the same batch as the change it records — is\n * `@aglyn/tenant-data-admin/server/append-only-history-write`.\n */\n\n/** The longest reason or summary a row keeps. */\nexport const HISTORY_TEXT_MAX = 500\n\n/** The Stripe object a row's money movement names. */\nexport interface HistoryStripeRef {\n /** `invoiceitem`, `credit_note`, `refund`, `invoice`. */\n object: string\n id: string\n /** Whole cents the object moved, when it moved money. */\n amountCents?: number\n}\n\n/** One row. */\nexport interface AppendOnlyHistoryRow {\n /** When it happened, epoch ms. */\n atMs: number\n /** Who did it; null when nobody did (a scheduled check). */\n byUid: string | null\n byEmail: string | null\n /** What kind of thing happened, `noun.verb`: `minutes.corrected`. */\n kind: string\n /** What happened, in plain words an owner can read. */\n summary: string\n /** Why; required on every correction. */\n reason: string | null\n before: Readonly<Record<string, unknown>> | null\n after: Readonly<Record<string, unknown>> | null\n stripe: HistoryStripeRef | null\n /** The record the row belongs to, when the history is shared by many. */\n subjectId: string | null\n}\n\nexport interface HistoryRowInput {\n atMs: number\n by: { uid: string | null; email: string | null }\n kind: string\n summary: string\n reason?: string | null\n before?: Readonly<Record<string, unknown>> | null\n after?: Readonly<Record<string, unknown>> | null\n stripe?: HistoryStripeRef | null\n subjectId?: string | null\n}\n\n/** A trimmed, bounded reason, or null when blank. */\nexport function cleanHistoryReason(reason: unknown): string | null {\n const text = typeof reason === 'string' ? reason.trim().slice(0, HISTORY_TEXT_MAX) : ''\n return text ? text : null\n}\n\n/**\n * The reason a correction must carry, or an error to show. Every change to\n * something already recorded goes through this, so \"why\" is never optional\n * where it matters.\n */\nexport function requireHistoryReason(\n reason: unknown,\n): { ok: true; reason: string } | { ok: false; error: string } {\n const cleaned = cleanHistoryReason(reason)\n return cleaned ? { ok: true, reason: cleaned } : { ok: false, error: 'Say why — a reason is required.' }\n}\n\n/** A row from its parts, every field present so a reader never guesses. */\nexport function historyRow(input: HistoryRowInput): AppendOnlyHistoryRow {\n return {\n atMs: Math.floor(input.atMs),\n byUid: input.by.uid ?? null,\n byEmail: input.by.email ?? null,\n kind: input.kind,\n summary: String(input.summary ?? '').trim().slice(0, HISTORY_TEXT_MAX),\n reason: cleanHistoryReason(input.reason ?? null),\n before: input.before ?? null,\n after: input.after ?? null,\n stripe: input.stripe ?? null,\n subjectId: input.subjectId ?? null,\n }\n}\n\n/** Rows oldest first, ties kept in the order they were read. */\nexport function sortHistoryRows<Row extends Pick<AppendOnlyHistoryRow, 'atMs'>>(\n rows: readonly Row[],\n): Row[] {\n return rows\n .map((row, index) => ({ row, index }))\n .sort((a, b) => a.row.atMs - b.row.atMs || a.index - b.index)\n .map(({ row }) => row)\n}\n"],"names":["HISTORY_TEXT_MAX","cleanHistoryReason","reason","text","trim","slice","requireHistoryReason","cleaned","ok","error","historyRow","input","atMs","Math","floor","byUid","by","uid","byEmail","email","kind","summary","String","before","after","stripe","subjectId","sortHistoryRows","rows","map","row","index","sort","a","b"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;CAgBC,GAED,+CAA+C,GAC/C,OAAO,MAAMA,mBAAmB,IAAG;AA2CnC,mDAAmD,GACnD,OAAO,SAASC,mBAAmBC,MAAe;IAChD,MAAMC,OAAO,OAAOD,WAAW,WAAWA,OAAOE,IAAI,GAAGC,KAAK,CAAC,GAAGL,oBAAoB;IACrF,OAAOG,OAAOA,OAAO;AACvB;AAEA;;;;CAIC,GACD,OAAO,SAASG,qBACdJ,MAAe;IAEf,MAAMK,UAAUN,mBAAmBC;IACnC,OAAOK,UAAU;QAAEC,IAAI;QAAMN,QAAQK;IAAQ,IAAI;QAAEC,IAAI;QAAOC,OAAO;IAAkC;AACzG;AAEA,yEAAyE,GACzE,OAAO,SAASC,WAAWC,KAAsB;QAGtCA,eACEA,iBAEOA,gBACWA,eACnBA,eACDA,cACCA,eACGA;IAVb,OAAO;QACLC,MAAMC,KAAKC,KAAK,CAACH,MAAMC,IAAI;QAC3BG,KAAK,GAAEJ,gBAAAA,MAAMK,EAAE,CAACC,GAAG,YAAZN,gBAAgB;QACvBO,OAAO,GAAEP,kBAAAA,MAAMK,EAAE,CAACG,KAAK,YAAdR,kBAAkB;QAC3BS,MAAMT,MAAMS,IAAI;QAChBC,SAASC,QAAOX,iBAAAA,MAAMU,OAAO,YAAbV,iBAAiB,IAAIP,IAAI,GAAGC,KAAK,CAAC,GAAGL;QACrDE,QAAQD,oBAAmBU,gBAAAA,MAAMT,MAAM,YAAZS,gBAAgB;QAC3CY,MAAM,GAAEZ,gBAAAA,MAAMY,MAAM,YAAZZ,gBAAgB;QACxBa,KAAK,GAAEb,eAAAA,MAAMa,KAAK,YAAXb,eAAe;QACtBc,MAAM,GAAEd,gBAAAA,MAAMc,MAAM,YAAZd,gBAAgB;QACxBe,SAAS,GAAEf,mBAAAA,MAAMe,SAAS,YAAff,mBAAmB;IAChC;AACF;AAEA,8DAA8D,GAC9D,OAAO,SAASgB,gBACdC,IAAoB;IAEpB,OAAOA,KACJC,GAAG,CAAC,CAACC,KAAKC,QAAW,CAAA;YAAED;YAAKC;QAAM,CAAA,GAClCC,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEH,GAAG,CAAClB,IAAI,GAAGsB,EAAEJ,GAAG,CAAClB,IAAI,IAAIqB,EAAEF,KAAK,GAAGG,EAAEH,KAAK,EAC3DF,GAAG,CAAC,CAAC,EAAEC,GAAG,EAAE,GAAKA;AACtB"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* THE ADD-ONS A PLAN SELLS, AND THE BUNDLE A LINK ASKS FOR (AGL-3955).
|
|
19
|
+
*
|
|
20
|
+
* One list of add-on kinds and one parser for the add-ons a link, an upgrade
|
|
21
|
+
* proposal or a staff dialog names, so the Billing card, the bundle checkout
|
|
22
|
+
* link, the hand-off proposal (AGL-3956) and `/api/billing/checkout` agree on
|
|
23
|
+
* what `addons=siteCare,ai,extraHost:2` means.
|
|
24
|
+
*
|
|
25
|
+
* The kinds are `OrgSeatAddons`' keys: what `resolvePurchasedAddons` counts,
|
|
26
|
+
* what the webhook mirrors from Stripe, and what `/api/billing/addons` sells.
|
|
27
|
+
* The prices and ceilings here are the ones `billing-addons.ts` (server)
|
|
28
|
+
* re-exports, so a kind the link can preselect is always a kind the
|
|
29
|
+
* checkout can price.
|
|
30
|
+
*
|
|
31
|
+
* A link is typed by a person and passed through hops nobody controls, so
|
|
32
|
+
* the parser never throws and never guesses: an unknown token is dropped and
|
|
33
|
+
* reported, so the page can say so in one line instead of failing.
|
|
34
|
+
*/
|
|
35
|
+
import type { AiTierId, OrgPlan, OrgSeatAddons } from '../foundation/definitions/org-billing.types';
|
|
36
|
+
import { resolveOrgEntitlements } from './plan-entitlements';
|
|
37
|
+
/** An add-on kind: a key of `org.seatAddons`. */
|
|
38
|
+
export type AddonKind = keyof Required<OrgSeatAddons>;
|
|
39
|
+
/**
|
|
40
|
+
* Every add-on kind Billing sells, in the order the Billing card lists them.
|
|
41
|
+
* `/api/billing/addons`, the webhook's price map and the native add-ons
|
|
42
|
+
* screen all read this list.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ADDON_KINDS: readonly AddonKind[];
|
|
45
|
+
/** The org-wide 0/1 kinds: one purchase covers the workspace. */
|
|
46
|
+
export declare const TOGGLE_ADDON_KIND_LIST: readonly AddonKind[];
|
|
47
|
+
export declare function isAddonKind(value: unknown): value is AddonKind;
|
|
48
|
+
/**
|
|
49
|
+
* Monthly USD per unit for an add-on on a plan (yearly prices are ×12 of
|
|
50
|
+
* this); null when the plan doesn't sell the kind. Single pricing source
|
|
51
|
+
* of truth: `PLAN_PRICING`, the three flat add-on constants and `AI_TIERS`
|
|
52
|
+
* (`tier` as `addonPriceId` reads it; absent, the tier a plan-named purchase
|
|
53
|
+
* means, `defaultAiTierForPlan`, AGL-3965).
|
|
54
|
+
*/
|
|
55
|
+
export declare function addonUnitUsd(kind: AddonKind, plan: OrgPlan, tier?: AiTierId | null): number | null;
|
|
56
|
+
/**
|
|
57
|
+
* Max purchasable quantity per kind, from a purchases-free entitlement
|
|
58
|
+
* resolution (plan defaults + staff overrides only) so the ceiling does not
|
|
59
|
+
* drift as the org buys: seat/dataset kinds stop at the plan's hard max,
|
|
60
|
+
* hosts/registers use flat ceilings, the Event Calendar, Aglyn AI and Site
|
|
61
|
+
* Care are 0/1 toggles. POS registers additionally require the `pos`
|
|
62
|
+
* feature, and Site Care a plan that sells it (`planSellsSiteCare`), which is
|
|
63
|
+
* why the plan travels with the baseline.
|
|
64
|
+
*
|
|
65
|
+
* One definition for every reader: `/api/billing/addons` asks how many the
|
|
66
|
+
* org may buy on its plan, a plan change asks how many of what it bought the
|
|
67
|
+
* new plan can deliver, and a bundle link asks how many it may preselect.
|
|
68
|
+
*/
|
|
69
|
+
export declare function addonMaxForBaseline(kind: AddonKind, baseline: ReturnType<typeof resolveOrgEntitlements>, plan: OrgPlan): number;
|
|
70
|
+
/** The ceiling a PLAN would impose on an add-on kind, purchases excluded. */
|
|
71
|
+
export declare function addonMaxForPlan(kind: AddonKind, plan: OrgPlan): number;
|
|
72
|
+
/** Whether a plan sells an add-on at all: priced, with a ceiling above zero. */
|
|
73
|
+
export declare function planSellsAddon(kind: AddonKind, plan: OrgPlan): boolean;
|
|
74
|
+
/** Quantities by kind, absent kinds meaning none. */
|
|
75
|
+
export type BundleAddons = Partial<Record<AddonKind, number>>;
|
|
76
|
+
/**
|
|
77
|
+
* What a link writes for each kind. `ai` and `extraHost` are the words the
|
|
78
|
+
* account owner chose (AGL-3955); the rest follow the same shape.
|
|
79
|
+
*/
|
|
80
|
+
export declare const BUNDLE_ADDON_TOKENS: Record<AddonKind, string>;
|
|
81
|
+
/** One add-on a token names, with the Aglyn AI tier when it names one. */
|
|
82
|
+
interface ParsedToken {
|
|
83
|
+
kind: AddonKind;
|
|
84
|
+
quantity: number;
|
|
85
|
+
tier?: AiTierId;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* THE `ai:<tier>` TOKENS (AGL-3965).
|
|
89
|
+
*
|
|
90
|
+
* Aglyn AI is a tier chosen on its own, on any paid plan: `ai:boost` adds
|
|
91
|
+
* Aglyn AI Boost. The words are the tier ids, lower-cased as every token is,
|
|
92
|
+
* and resolve through `parseAiTierAddonKey`, the one spelling of the
|
|
93
|
+
* `ai:<tier>` key. A bare `ai` (or `ai:1`) still means "add it" and sells
|
|
94
|
+
* the plan's default tier (`defaultAiTierForPlan`). An unknown tier is
|
|
95
|
+
* dropped with the notice like any other unknown add-on, never read as
|
|
96
|
+
* "add whichever tier": that would sell a tier nobody chose.
|
|
97
|
+
*/
|
|
98
|
+
export declare const AI_ADDON_TIER_TOKENS: Readonly<Record<string, AiTierId>>;
|
|
99
|
+
export declare function resolveAiAddonTier(tier: string): ParsedToken | null;
|
|
100
|
+
export interface ParsedBundleAddons {
|
|
101
|
+
addons: BundleAddons;
|
|
102
|
+
/** The tokens nothing understood, as they were written. */
|
|
103
|
+
dropped: string[];
|
|
104
|
+
/** The Aglyn AI tier an `ai:<tier>` token named (AGL-3965), if any. */
|
|
105
|
+
aiTier?: AiTierId;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Read the add-ons a link, a proposal or a request names.
|
|
109
|
+
*
|
|
110
|
+
* Accepts the link form (`"siteCare,ai,extraHost:2"`), a list of tokens, or a
|
|
111
|
+
* map of kind → quantity or flag (`{ siteCare: true, hosts: 2 }`, the shape
|
|
112
|
+
* the native staff screens post from their toggles). Never throws: anything
|
|
113
|
+
* it cannot read is reported in `dropped` and left out.
|
|
114
|
+
*/
|
|
115
|
+
export declare function parseBundleAddons(input: unknown): ParsedBundleAddons;
|
|
116
|
+
export interface FittedBundleAddons {
|
|
117
|
+
addons: BundleAddons;
|
|
118
|
+
/** Kinds the plan does not sell, dropped. */
|
|
119
|
+
notSold: AddonKind[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The add-ons a plan can actually carry: kinds it does not sell are dropped,
|
|
123
|
+
* quantities are held to its ceiling. What a link preselects on one plan is
|
|
124
|
+
* re-fitted when the owner picks another, so the checkout is never asked for
|
|
125
|
+
* something it would refuse.
|
|
126
|
+
*/
|
|
127
|
+
export declare function fitBundleAddonsToPlan(addons: BundleAddons | null | undefined, plan: OrgPlan): FittedBundleAddons;
|
|
128
|
+
/**
|
|
129
|
+
* The add-ons as the link writes them: `siteCare,ai:boost,extraHost:2`.
|
|
130
|
+
* Aglyn AI is written with its tier when one is named (AGL-3965), as bare
|
|
131
|
+
* `ai` otherwise.
|
|
132
|
+
*/
|
|
133
|
+
export declare function bundleAddonsParam(addons: BundleAddons | null | undefined, aiTier?: AiTierId | null): string;
|
|
134
|
+
/** Whether any add-on is asked for. */
|
|
135
|
+
export declare function hasBundleAddons(addons: BundleAddons | null | undefined): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* How each kind is named to a customer, singular. Aglyn AI carries its tier
|
|
138
|
+
* when one is named: "Aglyn AI Boost" (AGL-3965).
|
|
139
|
+
*/
|
|
140
|
+
export declare function bundleAddonLabel(kind: AddonKind, brand?: string, aiTier?: AiTierId | null): string;
|
|
141
|
+
/** "Site Care", "2 × Extra site", "Aglyn AI Boost". */
|
|
142
|
+
export declare function describeBundleAddon(kind: AddonKind, quantity: number, brand?: string, aiTier?: AiTierId | null): string;
|
|
143
|
+
/** The longest coupon code a link carries. Stripe codes are far shorter. */
|
|
144
|
+
export declare const BUNDLE_COUPON_MAX = 64;
|
|
145
|
+
/**
|
|
146
|
+
* A promotion code as a link carries it, or undefined. Only the characters
|
|
147
|
+
* Stripe allows in a customer-facing code; anything else is not a code
|
|
148
|
+
* somebody was handed, and is dropped rather than sent to Stripe.
|
|
149
|
+
*
|
|
150
|
+
* The code is only APPLIED here. Codes are minted on the staff Coupons page,
|
|
151
|
+
* which audits them; nothing on this path creates one.
|
|
152
|
+
*/
|
|
153
|
+
export declare function normalizeBundleCoupon(raw: unknown): string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* A domain name as a bundle carries it — lower-cased, no scheme, no path —
|
|
156
|
+
* or undefined. Whether it is for sale and at what price is the registrar's
|
|
157
|
+
* answer, re-checked at purchase; this only refuses what cannot be a name.
|
|
158
|
+
*/
|
|
159
|
+
export declare function normalizeBundleDomain(raw: unknown): string | undefined;
|
|
160
|
+
/** "$15.99". */
|
|
161
|
+
export declare function formatBundleCents(cents: number): string;
|
|
162
|
+
/**
|
|
163
|
+
* The domain line a bundle shows (AGL-3955): "example.com — $15.99 first
|
|
164
|
+
* year, renews yearly at $15.99". The price is the registrar's at the moment
|
|
165
|
+
* the link was minted; the purchase re-checks it.
|
|
166
|
+
*/
|
|
167
|
+
export declare function bundleDomainLine(domain: {
|
|
168
|
+
name: string;
|
|
169
|
+
firstYearCents: number;
|
|
170
|
+
renewalCents: number;
|
|
171
|
+
}): string;
|
|
172
|
+
/**
|
|
173
|
+
* The bundle in one line, for an email, a dialog or a snackbar:
|
|
174
|
+
* "Starter with Site Care and Aglyn AI, billed yearly, code BOOTH25".
|
|
175
|
+
*/
|
|
176
|
+
export declare function describeBundle(bundle: {
|
|
177
|
+
plan: OrgPlan;
|
|
178
|
+
addons?: BundleAddons | null;
|
|
179
|
+
interval?: 'month' | 'year' | null;
|
|
180
|
+
coupon?: string | null;
|
|
181
|
+
/** The Aglyn AI tier, named with the AI add-on (AGL-3965). */
|
|
182
|
+
aiTier?: AiTierId | null;
|
|
183
|
+
}, options?: {
|
|
184
|
+
brand?: string;
|
|
185
|
+
}): string;
|
|
186
|
+
export {};
|