@cosmicdrift/kumiko-bundled-features 0.411.0 → 0.413.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-shell/feature.d.ts +1 -1
- package/dist/agent-tools/agent-doc-lint.d.ts +9 -0
- package/dist/agent-tools/agent-doc-lint.js +42 -5
- package/dist/agent-tools/agent-manifest.d.ts +0 -1
- package/dist/agent-tools/agent-manifest.js +9 -99
- package/dist/agent-tools/api-docs/anchors.d.ts +14 -0
- package/dist/agent-tools/api-docs/anchors.js +49 -0
- package/dist/agent-tools/api-docs/check.d.ts +7 -0
- package/dist/agent-tools/api-docs/check.js +15 -0
- package/dist/agent-tools/api-docs/collect-events.d.ts +10 -0
- package/dist/agent-tools/api-docs/collect-events.js +90 -0
- package/dist/agent-tools/api-docs/collect.d.ts +15 -0
- package/dist/agent-tools/api-docs/collect.js +108 -0
- package/dist/agent-tools/api-docs/curl.d.ts +5 -0
- package/dist/agent-tools/api-docs/curl.js +24 -0
- package/dist/agent-tools/api-docs/error-table.d.ts +9 -0
- package/dist/agent-tools/api-docs/error-table.js +31 -0
- package/dist/agent-tools/api-docs/examples.d.ts +16 -0
- package/dist/agent-tools/api-docs/examples.js +25 -0
- package/dist/agent-tools/api-docs/generate.d.ts +19 -0
- package/dist/agent-tools/api-docs/generate.js +104 -0
- package/dist/agent-tools/api-docs/index-json.d.ts +15 -0
- package/dist/agent-tools/api-docs/index-json.js +6 -0
- package/dist/agent-tools/api-docs/index.d.ts +9 -0
- package/dist/agent-tools/api-docs/index.js +6 -0
- package/dist/agent-tools/api-docs/list-parameters.d.ts +61 -0
- package/dist/agent-tools/api-docs/list-parameters.js +28 -0
- package/dist/agent-tools/api-docs/markdown.d.ts +29 -0
- package/dist/agent-tools/api-docs/markdown.js +48 -0
- package/dist/agent-tools/api-docs/menu-path.d.ts +8 -0
- package/dist/agent-tools/api-docs/menu-path.js +60 -0
- package/dist/agent-tools/api-docs/model.d.ts +76 -0
- package/dist/agent-tools/api-docs/problems.d.ts +32 -0
- package/dist/agent-tools/api-docs/problems.js +28 -0
- package/dist/agent-tools/api-docs/render-events.d.ts +12 -0
- package/dist/agent-tools/api-docs/render-events.js +55 -0
- package/dist/agent-tools/api-docs/render-openapi.d.ts +10 -0
- package/dist/agent-tools/api-docs/render-openapi.js +170 -0
- package/dist/agent-tools/api-docs/render-overview.d.ts +11 -0
- package/dist/agent-tools/api-docs/render-overview.js +60 -0
- package/dist/agent-tools/api-docs/render-reference.d.ts +14 -0
- package/dist/agent-tools/api-docs/render-reference.js +50 -0
- package/dist/agent-tools/api-docs/render-tokens.d.ts +12 -0
- package/dist/agent-tools/api-docs/render-tokens.js +101 -0
- package/dist/agent-tools/api-docs/schema-fields.d.ts +16 -0
- package/dist/agent-tools/api-docs/schema-fields.js +141 -0
- package/dist/agent-tools/api-docs/section-ids.d.ts +25 -0
- package/dist/agent-tools/api-docs/section-ids.js +26 -0
- package/dist/agent-tools/api-docs/system-only.d.ts +5 -0
- package/dist/agent-tools/api-docs/system-only.js +7 -0
- package/dist/agent-tools/api-docs/texts/de.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/de.js +123 -0
- package/dist/agent-tools/api-docs/texts/en.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/en.js +123 -0
- package/dist/agent-tools/api-docs/texts/es.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/es.js +123 -0
- package/dist/agent-tools/api-docs/texts/fr.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/fr.js +123 -0
- package/dist/agent-tools/api-docs/texts/index.d.ts +14 -0
- package/dist/agent-tools/api-docs/texts/index.js +55 -0
- package/dist/agent-tools/api-docs/texts/it.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/it.js +123 -0
- package/dist/agent-tools/api-docs/texts/types.d.ts +18 -0
- package/dist/agent-tools/api-docs/texts/types.js +104 -0
- package/dist/agent-tools/api-docs/ui-writes.d.ts +12 -0
- package/dist/agent-tools/api-docs/ui-writes.js +73 -0
- package/dist/agent-tools/handler-schema.d.ts +5 -0
- package/dist/agent-tools/handler-schema.js +37 -0
- package/dist/agent-tools/index.d.ts +2 -1
- package/dist/agent-tools/index.js +2 -1
- package/dist/agent-tools/labels.d.ts +26 -0
- package/dist/agent-tools/labels.js +131 -0
- package/dist/auth-email-password/boot-rules.d.ts +7 -0
- package/dist/auth-email-password/boot-rules.js +7 -0
- package/dist/auth-email-password/feature.js +6 -13
- package/dist/auth-email-password/validate-options.d.ts +5 -0
- package/dist/auth-email-password/validate-options.js +15 -0
- package/dist/billing-foundation/boot-rules.d.ts +22 -0
- package/dist/billing-foundation/boot-rules.js +22 -0
- package/dist/billing-foundation/validate-options.js +56 -18
- package/dist/cap-overview/boot-rules.d.ts +12 -0
- package/dist/cap-overview/boot-rules.js +12 -0
- package/dist/cap-overview/feature.js +8 -3
- package/dist/documents/boot-rules.d.ts +12 -0
- package/dist/documents/boot-rules.js +12 -0
- package/dist/documents/feature.js +8 -3
- package/dist/file-derivatives/boot-rules.d.ts +7 -0
- package/dist/file-derivatives/boot-rules.js +7 -0
- package/dist/file-derivatives/feature.js +5 -2
- package/dist/folders/boot-rules.d.ts +7 -0
- package/dist/folders/boot-rules.js +7 -0
- package/dist/folders/feature.js +8 -5
- package/dist/helpdesk/boot-rules.d.ts +7 -0
- package/dist/helpdesk/boot-rules.js +7 -0
- package/dist/{contact → helpdesk}/challenge.js +2 -2
- package/dist/helpdesk/client/helpdesk-client-source.d.ts +1 -0
- package/dist/{contact/client/contact-client-source.js → helpdesk/client/helpdesk-client-source.js} +4 -4
- package/dist/helpdesk/client/helpdesk-website-client.d.ts +26 -0
- package/dist/helpdesk/client/helpdesk-website-client.js +1 -0
- package/dist/helpdesk/client/index.d.ts +2 -0
- package/dist/helpdesk/client/index.js +1 -0
- package/dist/{contact → helpdesk}/entity.d.ts +6 -6
- package/dist/{contact → helpdesk}/entity.js +31 -27
- package/dist/helpdesk/feature.d.ts +3 -0
- package/dist/{contact → helpdesk}/feature.js +43 -39
- package/dist/{contact → helpdesk}/handlers/attempts.d.ts +2 -2
- package/dist/helpdesk/handlers/challenge.query.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/challenge.query.js +5 -5
- package/dist/helpdesk/handlers/forward-request.write.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/forward-request.write.js +17 -15
- package/dist/{contact → helpdesk}/handlers/mark-done.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/mark-done.write.js +8 -8
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.js +11 -11
- package/dist/{contact → helpdesk}/handlers/open-count.js +2 -2
- package/dist/{contact → helpdesk}/handlers/open-count.query.js +4 -4
- package/dist/{contact → helpdesk}/handlers/replies.query.js +6 -6
- package/dist/{contact → helpdesk}/handlers/reply.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/reply.write.js +16 -16
- package/dist/helpdesk/handlers/report.write.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/report.write.js +17 -17
- package/dist/helpdesk/handlers/request-delivery.query.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/request-delivery.query.js +24 -24
- package/dist/{contact → helpdesk}/handlers/request-detail.query.d.ts +3 -3
- package/dist/{contact → helpdesk}/handlers/request-detail.query.js +10 -10
- package/dist/{contact → helpdesk}/handlers/request-list.query.js +2 -2
- package/dist/helpdesk/handlers/send-reply-mail.write.d.ts +8 -0
- package/dist/{contact → helpdesk}/handlers/send-reply-mail.write.js +15 -15
- package/dist/helpdesk/handlers/send-test.write.d.ts +5 -0
- package/dist/{contact → helpdesk}/handlers/send-test.write.js +10 -10
- package/dist/{contact → helpdesk}/handlers/submit.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/submit.write.js +17 -17
- package/dist/{contact → helpdesk}/handlers/take-over-uploads.js +5 -5
- package/dist/{contact → helpdesk}/i18n.d.ts +1 -1
- package/dist/{contact → helpdesk}/i18n.js +78 -75
- package/dist/helpdesk/index.d.ts +5 -0
- package/dist/helpdesk/index.js +4 -0
- package/dist/{contact → helpdesk}/lib.d.ts +5 -5
- package/dist/{contact → helpdesk}/lib.js +16 -16
- package/dist/{contact → helpdesk}/mail.d.ts +20 -20
- package/dist/{contact → helpdesk}/mail.js +47 -47
- package/dist/{contact → helpdesk}/options.d.ts +6 -6
- package/dist/helpdesk/options.js +36 -0
- package/dist/helpdesk/panels.d.ts +2 -0
- package/dist/helpdesk/panels.js +21 -0
- package/dist/{contact → helpdesk}/payloads.d.ts +11 -11
- package/dist/{contact → helpdesk}/payloads.js +28 -28
- package/dist/helpdesk/screens.d.ts +5 -0
- package/dist/{contact → helpdesk}/screens.js +87 -87
- package/dist/{contact → helpdesk}/subject.js +3 -3
- package/dist/helpdesk/user-data-hooks.d.ts +3 -0
- package/dist/{contact → helpdesk}/user-data-hooks.js +15 -15
- package/dist/helpdesk/web/constants.d.ts +127 -0
- package/dist/helpdesk/web/constants.js +126 -0
- package/dist/helpdesk/web/index.d.ts +1 -0
- package/dist/helpdesk/web/index.js +1 -0
- package/dist/host-routing/boot-rules.d.ts +22 -0
- package/dist/host-routing/boot-rules.js +22 -0
- package/dist/host-routing/validate-options.js +35 -11
- package/dist/inbound-mail-foundation/entities.d.ts +84 -0
- package/dist/inbound-mail-foundation/entities.js +96 -71
- package/dist/inbound-mail-foundation/feature.js +2 -2
- package/dist/jobs/boot-rules.d.ts +7 -0
- package/dist/jobs/boot-rules.js +7 -0
- package/dist/jobs/feature.js +5 -2
- package/dist/legal-pages/boot-rules.d.ts +17 -0
- package/dist/legal-pages/boot-rules.js +17 -0
- package/dist/legal-pages/feature.js +5 -2
- package/dist/legal-pages/lib/validate-routes.js +11 -3
- package/dist/metrics/boot-rules.d.ts +12 -0
- package/dist/metrics/boot-rules.js +12 -0
- package/dist/metrics/validate.js +8 -2
- package/dist/notes-history/boot-rules.d.ts +7 -0
- package/dist/notes-history/boot-rules.js +7 -0
- package/dist/notes-history/feature.js +7 -4
- package/dist/personal-access-tokens/boot-rules.d.ts +7 -0
- package/dist/personal-access-tokens/boot-rules.js +7 -0
- package/dist/personal-access-tokens/feature.d.ts +1 -0
- package/dist/personal-access-tokens/feature.js +4 -2
- package/dist/personal-access-tokens/handlers/create.write.js +2 -2
- package/dist/personal-access-tokens/i18n.js +5 -1
- package/dist/personal-access-tokens/index.d.ts +4 -2
- package/dist/personal-access-tokens/index.js +29 -2
- package/dist/personal-access-tokens/scope-events-check.d.ts +3 -0
- package/dist/personal-access-tokens/scope-events-check.js +21 -0
- package/dist/personal-access-tokens/screens.js +8 -2
- package/dist/personal-access-tokens/web/constants.d.ts +1 -0
- package/dist/personal-access-tokens/web/constants.js +1 -0
- package/dist/personal-access-tokens/web/scopes.d.ts +2 -0
- package/dist/personal-access-tokens/web/scopes.js +12 -0
- package/dist/presence/boot-rules.d.ts +7 -0
- package/dist/presence/boot-rules.js +7 -0
- package/dist/presence/options.js +5 -1
- package/dist/readiness/boot-rules.d.ts +12 -0
- package/dist/readiness/boot-rules.js +12 -0
- package/dist/readiness/probe-boot-check.js +8 -3
- package/dist/shared/assert-no-where-rule-in-ownership-write.d.ts +1 -1
- package/dist/shared/assert-no-where-rule-in-ownership-write.js +11 -7
- package/dist/shared/boot-rules.d.ts +7 -0
- package/dist/shared/boot-rules.js +7 -0
- package/dist/subscription-mollie/boot-rules.d.ts +17 -0
- package/dist/subscription-mollie/boot-rules.js +17 -0
- package/dist/subscription-mollie/feature.js +13 -6
- package/dist/tags/boot-rules.d.ts +7 -0
- package/dist/tags/boot-rules.js +7 -0
- package/dist/tags/feature.js +8 -5
- package/dist/template-resolver/boot-rules.d.ts +17 -0
- package/dist/template-resolver/boot-rules.js +17 -0
- package/dist/template-resolver/feature.js +14 -5
- package/dist/tenant/boot-rules.d.ts +7 -0
- package/dist/tenant/boot-rules.js +7 -0
- package/dist/tenant/feature.js +5 -2
- package/kumiko-es-tables.json +4 -4
- package/package.json +29 -29
- package/src/agent-tools/changes.json +24 -0
- package/src/{contact → helpdesk}/changes.json +6 -0
- package/src/inbound-mail-foundation/changes.json +6 -0
- package/src/personal-access-tokens/changes.json +6 -0
- package/dist/contact/client/contact-client-source.d.ts +0 -1
- package/dist/contact/client/contact-website-client.d.ts +0 -26
- package/dist/contact/client/index.d.ts +0 -2
- package/dist/contact/client/index.js +0 -1
- package/dist/contact/feature.d.ts +0 -3
- package/dist/contact/handlers/challenge.query.d.ts +0 -9
- package/dist/contact/handlers/forward-request.write.d.ts +0 -9
- package/dist/contact/handlers/report.write.d.ts +0 -16
- package/dist/contact/handlers/request-delivery.query.d.ts +0 -16
- package/dist/contact/handlers/send-reply-mail.write.d.ts +0 -8
- package/dist/contact/handlers/send-test.write.d.ts +0 -5
- package/dist/contact/index.d.ts +0 -5
- package/dist/contact/index.js +0 -4
- package/dist/contact/options.js +0 -32
- package/dist/contact/panels.d.ts +0 -2
- package/dist/contact/panels.js +0 -21
- package/dist/contact/screens.d.ts +0 -5
- package/dist/contact/user-data-hooks.d.ts +0 -3
- package/dist/contact/web/constants.d.ts +0 -127
- package/dist/contact/web/constants.js +0 -126
- package/dist/contact/web/index.d.ts +0 -1
- package/dist/contact/web/index.js +0 -1
- /package/dist/{contact/client/contact-website-client.js → agent-tools/api-docs/model.js} +0 -0
- /package/dist/{contact → helpdesk}/challenge.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/attempts.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/replies.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/request-list.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/take-over-uploads.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.js +0 -0
- /package/dist/{contact → helpdesk}/subject.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.js +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { translationValueOtherText } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
const FALLBACK_LOCALE = "en";
|
|
3
|
+
// localeCompare depends on the runtime locale and ICU punctuation rules; qualified
|
|
4
|
+
// names contain `:`, so compare by code point instead for deterministic ordering.
|
|
5
|
+
export function compareIds(a, b) {
|
|
6
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
7
|
+
}
|
|
8
|
+
/** Requested locale, then English, then the first remaining locale in code-point
|
|
9
|
+
* order; `undefined` when the entry has no text at all (the key is then omitted). */
|
|
10
|
+
export function pickLabel(labels, locale) {
|
|
11
|
+
const nonEmpty = (value) => value !== undefined && value !== "" ? value : undefined;
|
|
12
|
+
const firstLocale = Object.keys(labels)
|
|
13
|
+
.sort(compareIds)
|
|
14
|
+
.find((key) => nonEmpty(labels[key]));
|
|
15
|
+
return (nonEmpty(labels[locale]) ??
|
|
16
|
+
nonEmpty(labels[FALLBACK_LOCALE]) ??
|
|
17
|
+
(firstLocale !== undefined ? labels[firstLocale] : undefined));
|
|
18
|
+
}
|
|
19
|
+
/** The manifest surfaces one string per locale — a plural entry reads as its
|
|
20
|
+
* CLDR `other` form since the manifest has no `count` to select a category. */
|
|
21
|
+
export function entryAsLabels(entry) {
|
|
22
|
+
return Object.fromEntries(Object.entries(entry).map(([locale, value]) => [locale, translationValueOtherText(value)]));
|
|
23
|
+
}
|
|
24
|
+
const labelsIndexByTranslations = new WeakMap();
|
|
25
|
+
/** Every tail starting at a key boundary (`:` or `.`, with and without the
|
|
26
|
+
* separator) maps to the first key that ends with it. */
|
|
27
|
+
function buildSuffixIndex(translations) {
|
|
28
|
+
const index = new Map();
|
|
29
|
+
for (const [key, entry] of Object.entries(translations)) {
|
|
30
|
+
const match = { key, labels: entryAsLabels(entry) };
|
|
31
|
+
const addTail = (start) => {
|
|
32
|
+
const tail = key.slice(start);
|
|
33
|
+
if (!index.has(tail))
|
|
34
|
+
index.set(tail, match);
|
|
35
|
+
};
|
|
36
|
+
addTail(0);
|
|
37
|
+
for (let position = 0; position < key.length; position++) {
|
|
38
|
+
if (key[position] === ":" || key[position] === ".") {
|
|
39
|
+
addTail(position);
|
|
40
|
+
addTail(position + 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return index;
|
|
45
|
+
}
|
|
46
|
+
/** Translation keys carry a feature prefix the manifest can't reconstruct
|
|
47
|
+
* (`showcase:entity:item:field:title`), so match on the suffix instead. The
|
|
48
|
+
* suffix must start at a `:` or `.` boundary of the key. */
|
|
49
|
+
export function labelsForSuffix(translations, suffix) {
|
|
50
|
+
return suffixMatch(translations, suffix)?.labels ?? {};
|
|
51
|
+
}
|
|
52
|
+
function suffixMatch(translations, suffix) {
|
|
53
|
+
let index = labelsIndexByTranslations.get(translations);
|
|
54
|
+
if (index === undefined) {
|
|
55
|
+
index = buildSuffixIndex(translations);
|
|
56
|
+
labelsIndexByTranslations.set(translations, index);
|
|
57
|
+
}
|
|
58
|
+
return index.get(suffix);
|
|
59
|
+
}
|
|
60
|
+
const LOCALE_PACKAGE_PREFIX = "locale-";
|
|
61
|
+
const localePackageKeysByTranslations = new WeakMap();
|
|
62
|
+
/** Locale packages register their entries as `locale-<xx>:<key>`; map each `<key>` to
|
|
63
|
+
* the registered keys that carry it, in code-point order. */
|
|
64
|
+
function localePackageKeys(translations) {
|
|
65
|
+
let index = localePackageKeysByTranslations.get(translations);
|
|
66
|
+
if (index === undefined) {
|
|
67
|
+
index = new Map();
|
|
68
|
+
for (const key of Object.keys(translations).sort(compareIds)) {
|
|
69
|
+
if (!key.startsWith(LOCALE_PACKAGE_PREFIX))
|
|
70
|
+
continue;
|
|
71
|
+
const name = key.slice(key.indexOf(":") + 1);
|
|
72
|
+
index.set(name, [...(index.get(name) ?? []), key]);
|
|
73
|
+
}
|
|
74
|
+
localePackageKeysByTranslations.set(translations, index);
|
|
75
|
+
}
|
|
76
|
+
return index;
|
|
77
|
+
}
|
|
78
|
+
/** The labels of `fullKey` per locale, completed by locale packages that translate it
|
|
79
|
+
* under `locale-<xx>:<fullKey>` or, for `<feature>:<key>`, under `locale-<xx>:<key>`.
|
|
80
|
+
* The owner's text wins, then the locale packages in code-point order. */
|
|
81
|
+
export function localizedLabels(translations, fullKey) {
|
|
82
|
+
const plainKey = fullKey.includes(":") ? fullKey.slice(fullKey.indexOf(":") + 1) : undefined;
|
|
83
|
+
const packages = localePackageKeys(translations);
|
|
84
|
+
const keys = [
|
|
85
|
+
...(translations[fullKey] === undefined ? [] : [fullKey]),
|
|
86
|
+
...[
|
|
87
|
+
...new Set([
|
|
88
|
+
...(packages.get(fullKey) ?? []),
|
|
89
|
+
...(plainKey ? (packages.get(plainKey) ?? []) : []),
|
|
90
|
+
]),
|
|
91
|
+
].sort(compareIds),
|
|
92
|
+
];
|
|
93
|
+
const merged = {};
|
|
94
|
+
for (const key of keys) {
|
|
95
|
+
for (const [locale, label] of Object.entries(entryAsLabels(translations[key] ?? {}))) {
|
|
96
|
+
if (merged[locale] === undefined)
|
|
97
|
+
merged[locale] = label;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return merged;
|
|
101
|
+
}
|
|
102
|
+
/** `labelsForSuffix` with the locale-package completion of `localizedLabels`: the owner
|
|
103
|
+
* key behind the suffix is preferred over a locale package key that ends the same way. */
|
|
104
|
+
export function localizedLabelsForSuffix(translations, suffix) {
|
|
105
|
+
const match = suffixMatch(translations, suffix);
|
|
106
|
+
if (match === undefined)
|
|
107
|
+
return {};
|
|
108
|
+
const owner = Object.keys(translations).find((key) => !key.startsWith(LOCALE_PACKAGE_PREFIX) && key.endsWith(suffix));
|
|
109
|
+
return localizedLabels(translations, owner ?? match.key);
|
|
110
|
+
}
|
|
111
|
+
/** Entity field label per locale; `field` may be a dotted path, only its last segment names the field. */
|
|
112
|
+
export function entityFieldLabels(translations, entity, field) {
|
|
113
|
+
return localizedLabelsForSuffix(translations, `:entity:${entity}:field:${field.slice(field.lastIndexOf(".") + 1)}`);
|
|
114
|
+
}
|
|
115
|
+
function lastSegmentOf(qualifiedId) {
|
|
116
|
+
return qualifiedId.slice(qualifiedId.lastIndexOf(":") + 1);
|
|
117
|
+
}
|
|
118
|
+
/** Screen titles live under the qualified id or, for feature-local screens, under
|
|
119
|
+
* `screen:<shortId>.title`. */
|
|
120
|
+
export function screenTitleLabels(translations, screenId) {
|
|
121
|
+
return entryAsLabels(translations[`${screenId}.title`] ??
|
|
122
|
+
translations[`screen:${lastSegmentOf(screenId)}.title`] ??
|
|
123
|
+
{});
|
|
124
|
+
}
|
|
125
|
+
/** `screenTitleLabels` completed by locale packages (see `localizedLabels`). */
|
|
126
|
+
export function localizedScreenTitleLabels(translations, screenId) {
|
|
127
|
+
const own = localizedLabels(translations, `${screenId}.title`);
|
|
128
|
+
return Object.keys(own).length > 0
|
|
129
|
+
? own
|
|
130
|
+
: localizedLabels(translations, `screen:${lastSegmentOf(screenId)}.title`);
|
|
131
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const AUTH_EMAIL_PASSWORD_BOOT_RULES: {
|
|
2
|
+
readonly hmacSecretTooShort: {
|
|
3
|
+
readonly id: "auth-email-password/hmac-secret-too-short";
|
|
4
|
+
readonly summary: "Each configured token hmacSecret is at least the minimum length.";
|
|
5
|
+
readonly fix: "Pass an hmacSecret of at least the minimum length.";
|
|
6
|
+
};
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const AUTH_EMAIL_PASSWORD_BOOT_RULES = {
|
|
2
|
+
hmacSecretTooShort: {
|
|
3
|
+
id: "auth-email-password/hmac-secret-too-short",
|
|
4
|
+
summary: "Each configured token hmacSecret is at least the minimum length.",
|
|
5
|
+
fix: "Pass an hmacSecret of at least the minimum length.",
|
|
6
|
+
},
|
|
7
|
+
};
|
|
@@ -21,7 +21,7 @@ import { createSignupRequestHandler, } from "./handlers/signup-request.write.js"
|
|
|
21
21
|
import { createSwitchTenantMfaGateHandler } from "./handlers/switch-tenant-mfa-gate.write.js";
|
|
22
22
|
import { createVerifyEmailHandler } from "./handlers/verify-email.write.js";
|
|
23
23
|
import { AUTH_MAIL_VARIABLES, authMailLocalizedTemplate, INVITE_MAIL_VARIABLES, sendsMagicLinkMail, } from "./mail-notifications.js";
|
|
24
|
-
import {
|
|
24
|
+
import { assertSignedTokenSecretsLongEnough } from "./validate-options.js";
|
|
25
25
|
import { AUTH_EMAIL_PASSWORD_MAIL_I18N } from "./web/mail-i18n.js";
|
|
26
26
|
/**
|
|
27
27
|
* Env-vars contract for the `auth-email-password` feature.
|
|
@@ -51,18 +51,11 @@ export const authEmailPasswordEnvSchema = z.object({
|
|
|
51
51
|
// identity lookups (via ctx.dispatch.queryAs) and on the tenant feature for
|
|
52
52
|
// membership resolution. No direct imports of foreign tables.
|
|
53
53
|
export function createAuthEmailPasswordFeature(opts = {}) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (opts.emailVerification && opts.emailVerification.hmacSecret.length < MIN_HMAC_SECRET_LENGTH) {
|
|
61
|
-
throw new Error(`[auth-email-password] emailVerification.hmacSecret must be ≥${MIN_HMAC_SECRET_LENGTH} chars (HMAC-SHA256 token signing)`);
|
|
62
|
-
}
|
|
63
|
-
if (opts.accountUnlock && opts.accountUnlock.hmacSecret.length < MIN_HMAC_SECRET_LENGTH) {
|
|
64
|
-
throw new Error(`[auth-email-password] accountUnlock.hmacSecret must be ≥${MIN_HMAC_SECRET_LENGTH} chars (HMAC-SHA256 token signing)`);
|
|
65
|
-
}
|
|
54
|
+
assertSignedTokenSecretsLongEnough({
|
|
55
|
+
passwordReset: opts.passwordReset,
|
|
56
|
+
emailVerification: opts.emailVerification,
|
|
57
|
+
accountUnlock: opts.accountUnlock,
|
|
58
|
+
});
|
|
66
59
|
const strictVerification = opts.emailVerification !== undefined && (opts.emailVerification.mode ?? "strict") === "strict";
|
|
67
60
|
const feature = defineFeature("auth-email-password", (r) => {
|
|
68
61
|
r.describe("Provides email+password authentication: the always-on handlers are `login`, `changePassword`, and `logout`; optional flows — password reset, email verification, magic-link self-signup, tenant invite, and account-unlock — are registered only when you pass their respective option objects (`passwordReset`, `emailVerification`, `signup`, `invite`, `accountUnlock`) to `createAuthEmailPasswordFeature(opts)`. All five magic-link flows dispatch their mail through the `delivery` feature via `ctx.notify`, so mounting any of them additionally requires `delivery`. Tokens are HMAC-signed (reset/verify/unlock) or opaque-random in Redis (signup/invite). `accountUnlock` is the self-service escape hatch for `accountLockout`'s monotonic failure-counter (#1266): confirming the mailed token clears the Redis lockout state without touching the user entity. Requires the `user` and `tenant` features, and declares `JWT_SECRET` (≥ 32 chars) in `authEmailPasswordEnvSchema` so a missing secret surfaces at boot validation rather than on the first login attempt.");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { AUTH_EMAIL_PASSWORD_BOOT_RULES } from "./boot-rules.js";
|
|
3
|
+
import { MIN_HMAC_SECRET_LENGTH } from "./web/constants.js";
|
|
4
|
+
// ≥32 chars, symmetric to the JWT_SECRET env check: a short HMAC secret
|
|
5
|
+
// makes reset/verify tokens forgeable — that's account takeover, so the
|
|
6
|
+
// factory fails fast instead of trusting the caller.
|
|
7
|
+
export function assertSignedTokenSecretsLongEnough(signedTokenFlows) {
|
|
8
|
+
for (const [optionName, flow] of Object.entries(signedTokenFlows)) {
|
|
9
|
+
if (flow && flow.hmacSecret.length < MIN_HMAC_SECRET_LENGTH) {
|
|
10
|
+
throw bootRuleError(AUTH_EMAIL_PASSWORD_BOOT_RULES.hmacSecretTooShort, {
|
|
11
|
+
message: `[auth-email-password] ${optionName}.hmacSecret must be ≥${MIN_HMAC_SECRET_LENGTH} chars (HMAC-SHA256 token signing)`,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const BILLING_FOUNDATION_BOOT_RULES: {
|
|
2
|
+
readonly consumerProtectionInvalid: {
|
|
3
|
+
readonly id: "billing-foundation/consumer-protection-invalid";
|
|
4
|
+
readonly summary: "consumerProtection options carry non-empty texts, a valid operator email, a valid termination scope and valid legal links.";
|
|
5
|
+
readonly fix: "Fix the consumerProtection option named in the error message.";
|
|
6
|
+
};
|
|
7
|
+
readonly baseUrlInvalid: {
|
|
8
|
+
readonly id: "billing-foundation/base-url-invalid";
|
|
9
|
+
readonly summary: "baseUrl is a parseable absolute http or https URL.";
|
|
10
|
+
readonly fix: "Pass an absolute http(s) URL as baseUrl.";
|
|
11
|
+
};
|
|
12
|
+
readonly baseUrlRequired: {
|
|
13
|
+
readonly id: "billing-foundation/base-url-required";
|
|
14
|
+
readonly summary: "baseUrl is set whenever consumerProtection or a catalog is configured.";
|
|
15
|
+
readonly fix: "Pass baseUrl, checkout redirect URLs are built from it.";
|
|
16
|
+
};
|
|
17
|
+
readonly catalogInvalid: {
|
|
18
|
+
readonly id: "billing-foundation/catalog-invalid";
|
|
19
|
+
readonly summary: "The catalog declares unique plans, root-relative paths, view roles and a valid contact card.";
|
|
20
|
+
readonly fix: "Fix the catalog option named in the error message.";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const BILLING_FOUNDATION_BOOT_RULES = {
|
|
2
|
+
consumerProtectionInvalid: {
|
|
3
|
+
id: "billing-foundation/consumer-protection-invalid",
|
|
4
|
+
summary: "consumerProtection options carry non-empty texts, a valid operator email, a valid termination scope and valid legal links.",
|
|
5
|
+
fix: "Fix the consumerProtection option named in the error message.",
|
|
6
|
+
},
|
|
7
|
+
baseUrlInvalid: {
|
|
8
|
+
id: "billing-foundation/base-url-invalid",
|
|
9
|
+
summary: "baseUrl is a parseable absolute http or https URL.",
|
|
10
|
+
fix: "Pass an absolute http(s) URL as baseUrl.",
|
|
11
|
+
},
|
|
12
|
+
baseUrlRequired: {
|
|
13
|
+
id: "billing-foundation/base-url-required",
|
|
14
|
+
summary: "baseUrl is set whenever consumerProtection or a catalog is configured.",
|
|
15
|
+
fix: "Pass baseUrl, checkout redirect URLs are built from it.",
|
|
16
|
+
},
|
|
17
|
+
catalogInvalid: {
|
|
18
|
+
id: "billing-foundation/catalog-invalid",
|
|
19
|
+
summary: "The catalog declares unique plans, root-relative paths, view roles and a valid contact card.",
|
|
20
|
+
fix: "Fix the catalog option named in the error message.",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { BILLING_FOUNDATION_BOOT_RULES } from "./boot-rules.js";
|
|
1
3
|
// Feature-definition-time validation for createBillingFoundationFeature's
|
|
2
4
|
// options — split out of feature.ts to keep that file at registration-only
|
|
3
5
|
// concerns (app-feature-structure guard's 300-line budget). Internal — not
|
|
@@ -30,7 +32,9 @@ function validateProviderTexts(cp) {
|
|
|
30
32
|
continue;
|
|
31
33
|
for (const locale of ["de", "en"]) {
|
|
32
34
|
if (!text[locale]?.trim()) {
|
|
33
|
-
throw
|
|
35
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
36
|
+
message: `createBillingFoundationFeature: consumerProtection.providerTexts.${providerName}.${textName} needs a non-empty "${locale}" entry.`,
|
|
37
|
+
});
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -38,22 +42,32 @@ function validateProviderTexts(cp) {
|
|
|
38
42
|
}
|
|
39
43
|
function validateConsumerProtection(cp) {
|
|
40
44
|
if (cp.termsTextBlock.trim() === "") {
|
|
41
|
-
throw
|
|
45
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
46
|
+
message: "createBillingFoundationFeature: consumerProtection.termsTextBlock is empty.",
|
|
47
|
+
});
|
|
42
48
|
}
|
|
43
49
|
for (const locale of ["de", "en"]) {
|
|
44
50
|
if (!cp.vatNote[locale]?.trim()) {
|
|
45
|
-
throw
|
|
51
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
52
|
+
message: `createBillingFoundationFeature: consumerProtection.vatNote needs a non-empty "${locale}" entry.`,
|
|
53
|
+
});
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
validateProviderTexts(cp);
|
|
49
57
|
if (!z.email().safeParse(cp.operatorEmail).success) {
|
|
50
|
-
throw
|
|
58
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
59
|
+
message: `createBillingFoundationFeature: consumerProtection.operatorEmail "${cp.operatorEmail}" is not a valid email address.`,
|
|
60
|
+
});
|
|
51
61
|
}
|
|
52
62
|
if (cp.oneOffItemLabel !== undefined && typeof cp.oneOffItemLabel !== "function") {
|
|
53
|
-
throw
|
|
63
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
64
|
+
message: "createBillingFoundationFeature: consumerProtection.oneOffItemLabel must be a function.",
|
|
65
|
+
});
|
|
54
66
|
}
|
|
55
67
|
if (cp.terminationScope !== undefined && !isTerminationScope(cp.terminationScope)) {
|
|
56
|
-
throw
|
|
68
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
69
|
+
message: `createBillingFoundationFeature: consumerProtection.terminationScope "${String(cp.terminationScope)}" must be one of ${TERMINATION_SCOPES.map((scope) => `"${scope}"`).join(", ")}.`,
|
|
70
|
+
});
|
|
57
71
|
}
|
|
58
72
|
if (isLegalLinkSet(cp.legalLinks)) {
|
|
59
73
|
validateLegalLinkSet(cp.legalLinks, "legalLinks");
|
|
@@ -66,7 +80,9 @@ function validatePerLocaleLegalLinks(legalLinks) {
|
|
|
66
80
|
for (const locale of CONSENT_LOCALES) {
|
|
67
81
|
const set = legalLinks[locale];
|
|
68
82
|
if (!set) {
|
|
69
|
-
throw
|
|
83
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
84
|
+
message: `createBillingFoundationFeature: consumerProtection.legalLinks needs a "${locale}" entry when given per locale.`,
|
|
85
|
+
});
|
|
70
86
|
}
|
|
71
87
|
validateLegalLinkSet(set, `legalLinks.${locale}`);
|
|
72
88
|
}
|
|
@@ -77,18 +93,24 @@ function validateLegalLinkSet(set, path) {
|
|
|
77
93
|
if (key === "refund" && link === undefined)
|
|
78
94
|
continue;
|
|
79
95
|
if (typeof link !== "string" || !isRootRelativeOrHttpsUrl(link)) {
|
|
80
|
-
throw
|
|
96
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
97
|
+
message: `createBillingFoundationFeature: consumerProtection.${path}.${key} "${link}" must be a root-relative path ("/..." not "//") or an absolute https URL.`,
|
|
98
|
+
});
|
|
81
99
|
}
|
|
82
100
|
}
|
|
83
101
|
}
|
|
84
102
|
function validateContactCard(contact) {
|
|
85
103
|
for (const key of ["labelKey", "actionLabelKey"]) {
|
|
86
104
|
if (contact[key].trim() === "") {
|
|
87
|
-
throw
|
|
105
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.catalogInvalid, {
|
|
106
|
+
message: `createBillingFoundationFeature: catalog.contact.${key} must not be empty.`,
|
|
107
|
+
});
|
|
88
108
|
}
|
|
89
109
|
}
|
|
90
110
|
if (!isContactCardHref(contact.href)) {
|
|
91
|
-
throw
|
|
111
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.catalogInvalid, {
|
|
112
|
+
message: `createBillingFoundationFeature: catalog.contact.href "${contact.href}" must be an absolute https: or mailto: URL.`,
|
|
113
|
+
});
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
116
|
function validateBaseUrl(baseUrl) {
|
|
@@ -97,10 +119,14 @@ function validateBaseUrl(baseUrl) {
|
|
|
97
119
|
parsed = new URL(baseUrl);
|
|
98
120
|
}
|
|
99
121
|
catch {
|
|
100
|
-
throw
|
|
122
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.baseUrlInvalid, {
|
|
123
|
+
message: `createBillingFoundationFeature: baseUrl "${baseUrl}" is not a parseable absolute URL.`,
|
|
124
|
+
});
|
|
101
125
|
}
|
|
102
126
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
103
|
-
throw
|
|
127
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.baseUrlInvalid, {
|
|
128
|
+
message: `createBillingFoundationFeature: baseUrl "${baseUrl}" must use http or https (parsed protocol "${parsed.protocol}").`,
|
|
129
|
+
});
|
|
104
130
|
}
|
|
105
131
|
}
|
|
106
132
|
/** Validates `options` and throws a plain `Error` with a clear message at
|
|
@@ -112,7 +138,9 @@ export function validateOptions(options) {
|
|
|
112
138
|
validateBaseUrl(options.baseUrl);
|
|
113
139
|
if (options.consumerProtection) {
|
|
114
140
|
if (options.baseUrl === undefined) {
|
|
115
|
-
throw
|
|
141
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.baseUrlRequired, {
|
|
142
|
+
message: "createBillingFoundationFeature: consumerProtection requires baseUrl (checkout redirect URLs are built from it).",
|
|
143
|
+
});
|
|
116
144
|
}
|
|
117
145
|
validateConsumerProtection(options.consumerProtection);
|
|
118
146
|
}
|
|
@@ -121,15 +149,21 @@ export function validateOptions(options) {
|
|
|
121
149
|
if (!catalog)
|
|
122
150
|
return;
|
|
123
151
|
if (options.baseUrl === undefined) {
|
|
124
|
-
throw
|
|
152
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.baseUrlRequired, {
|
|
153
|
+
message: "createBillingFoundationFeature: catalog requires baseUrl (plan checkouts need it to build success/cancel/return URLs).",
|
|
154
|
+
});
|
|
125
155
|
}
|
|
126
156
|
if (catalog.plans.length === 0) {
|
|
127
|
-
throw
|
|
157
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.catalogInvalid, {
|
|
158
|
+
message: "createBillingFoundationFeature: catalog.plans must not be empty.",
|
|
159
|
+
});
|
|
128
160
|
}
|
|
129
161
|
const seen = new Set();
|
|
130
162
|
for (const tier of catalog.plans) {
|
|
131
163
|
if (seen.has(tier)) {
|
|
132
|
-
throw
|
|
164
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.catalogInvalid, {
|
|
165
|
+
message: `createBillingFoundationFeature: catalog.plans has a duplicate tier "${tier}".`,
|
|
166
|
+
});
|
|
133
167
|
}
|
|
134
168
|
seen.add(tier);
|
|
135
169
|
}
|
|
@@ -139,11 +173,15 @@ export function validateOptions(options) {
|
|
|
139
173
|
["returnPath", catalog.returnPath],
|
|
140
174
|
]) {
|
|
141
175
|
if (path !== undefined && !isRootRelativePath(path)) {
|
|
142
|
-
throw
|
|
176
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.catalogInvalid, {
|
|
177
|
+
message: `createBillingFoundationFeature: catalog.${key} "${path}" must start with "/" and not "//".`,
|
|
178
|
+
});
|
|
143
179
|
}
|
|
144
180
|
}
|
|
145
181
|
if (catalog.viewRoles.length === 0) {
|
|
146
|
-
throw
|
|
182
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.catalogInvalid, {
|
|
183
|
+
message: "createBillingFoundationFeature: catalog.viewRoles must not be empty.",
|
|
184
|
+
});
|
|
147
185
|
}
|
|
148
186
|
if (catalog.contact !== undefined)
|
|
149
187
|
validateContactCard(catalog.contact);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const CAP_OVERVIEW_BOOT_RULES: {
|
|
2
|
+
readonly emptyCaps: {
|
|
3
|
+
readonly id: "cap-overview/empty-caps";
|
|
4
|
+
readonly summary: "createCapOverviewFeature receives at least one cap.";
|
|
5
|
+
readonly fix: "Pass a non-empty caps list.";
|
|
6
|
+
};
|
|
7
|
+
readonly unknownListCap: {
|
|
8
|
+
readonly id: "cap-overview/unknown-list-cap";
|
|
9
|
+
readonly summary: "listCaps only references cap ids declared in caps.";
|
|
10
|
+
readonly fix: "Use ids from caps in listCaps.";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const CAP_OVERVIEW_BOOT_RULES = {
|
|
2
|
+
emptyCaps: {
|
|
3
|
+
id: "cap-overview/empty-caps",
|
|
4
|
+
summary: "createCapOverviewFeature receives at least one cap.",
|
|
5
|
+
fix: "Pass a non-empty caps list.",
|
|
6
|
+
},
|
|
7
|
+
unknownListCap: {
|
|
8
|
+
id: "cap-overview/unknown-list-cap",
|
|
9
|
+
summary: "listCaps only references cap ids declared in caps.",
|
|
10
|
+
fix: "Use ids from caps in listCaps.",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
// - No nav wiring — a separate cut adds `r.nav(...)` entries.
|
|
16
16
|
//
|
|
17
17
|
// **Boot-Dependencies:** tenant, tier-engine, billing-foundation.
|
|
18
|
-
import { defineFeature } from "@cosmicdrift/kumiko-framework/engine";
|
|
18
|
+
import { bootRuleError, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
19
19
|
import { resolveCapUsageRoles } from "./access.js";
|
|
20
|
+
import { CAP_OVERVIEW_BOOT_RULES } from "./boot-rules.js";
|
|
20
21
|
import { createCapsUsageQuery } from "./handlers/caps-usage.query.js";
|
|
21
22
|
import { createTenantCapsListQuery } from "./handlers/tenant-caps-list.query.js";
|
|
22
23
|
import { tenantOptionsQuery } from "./handlers/tenant-options.query.js";
|
|
@@ -25,14 +26,18 @@ import { createMyCapsScreen, createTenantCapListScreen, platformTenantCapsScreen
|
|
|
25
26
|
import { CAP_OVERVIEW_FEATURE } from "./web/constants.js";
|
|
26
27
|
export function createCapOverviewFeature(opts) {
|
|
27
28
|
if (opts.caps.length === 0) {
|
|
28
|
-
throw
|
|
29
|
+
throw bootRuleError(CAP_OVERVIEW_BOOT_RULES.emptyCaps, {
|
|
30
|
+
message: "createCapOverviewFeature: `caps` must not be empty.",
|
|
31
|
+
});
|
|
29
32
|
}
|
|
30
33
|
const usageRoles = resolveCapUsageRoles(opts.usageVisibleTo);
|
|
31
34
|
const capIds = new Set(opts.caps.map((cap) => cap.id));
|
|
32
35
|
const listCaps = opts.listCaps ?? opts.caps.slice(0, 3).map((cap) => cap.id);
|
|
33
36
|
for (const id of listCaps) {
|
|
34
37
|
if (!capIds.has(id)) {
|
|
35
|
-
throw
|
|
38
|
+
throw bootRuleError(CAP_OVERVIEW_BOOT_RULES.unknownListCap, {
|
|
39
|
+
message: `createCapOverviewFeature: listCaps references unknown cap id "${id}" — known ids: ${[...capIds].join(", ")}`,
|
|
40
|
+
});
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
return defineFeature(CAP_OVERVIEW_FEATURE, (r) => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DOCUMENTS_BOOT_RULES: {
|
|
2
|
+
readonly negativeExpiringWithinDays: {
|
|
3
|
+
readonly id: "documents/negative-expiring-within-days";
|
|
4
|
+
readonly summary: "expiringWithinDays is not negative.";
|
|
5
|
+
readonly fix: "Pass zero or a positive number.";
|
|
6
|
+
};
|
|
7
|
+
readonly categoryLabelUnknownCategory: {
|
|
8
|
+
readonly id: "documents/category-label-unknown-category";
|
|
9
|
+
readonly summary: "categoryLabels only names categories listed in categories.";
|
|
10
|
+
readonly fix: "Add the category to categories or drop its label.";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const DOCUMENTS_BOOT_RULES = {
|
|
2
|
+
negativeExpiringWithinDays: {
|
|
3
|
+
id: "documents/negative-expiring-within-days",
|
|
4
|
+
summary: "expiringWithinDays is not negative.",
|
|
5
|
+
fix: "Pass zero or a positive number.",
|
|
6
|
+
},
|
|
7
|
+
categoryLabelUnknownCategory: {
|
|
8
|
+
id: "documents/category-label-unknown-category",
|
|
9
|
+
summary: "categoryLabels only names categories listed in categories.",
|
|
10
|
+
fix: "Add the category to categories or drop its label.",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// records through link rows. A document is readable only through a record the viewer can read,
|
|
3
3
|
// and only while the owner of its file is readable too (EntityDefinition.readGate). Documents
|
|
4
4
|
// come from capture rules (a file saved into a configured field) or from the system-only import.
|
|
5
|
-
import { defineEntityCreateHandler, defineEntityDeleteHandler, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
5
|
+
import { bootRuleError, defineEntityCreateHandler, defineEntityDeleteHandler, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import { DOCUMENTS_BOOT_RULES } from "./boot-rules.js";
|
|
6
7
|
import { registerCapture, validateCaptureRules } from "./capture.js";
|
|
7
8
|
import { DEFAULT_ADMIN_ROLES, DEFAULT_DOCUMENT_ACCESS, DEFAULT_EXPIRING_WITHIN_DAYS, DOCUMENT_ENTITY, DOCUMENT_LINK_ENTITY, DOCUMENTS_FEATURE_NAME, } from "./constants.js";
|
|
8
9
|
import { createDocumentEntity, createDocumentLinkEntity, } from "./entity.js";
|
|
@@ -111,11 +112,15 @@ function registerDocuments(r, opts) {
|
|
|
111
112
|
}
|
|
112
113
|
export function createDocumentsFeature(opts) {
|
|
113
114
|
if (opts.expiringWithinDays !== undefined && opts.expiringWithinDays < 0) {
|
|
114
|
-
throw
|
|
115
|
+
throw bootRuleError(DOCUMENTS_BOOT_RULES.negativeExpiringWithinDays, {
|
|
116
|
+
message: "createDocumentsFeature({ expiringWithinDays }) must not be negative.",
|
|
117
|
+
});
|
|
115
118
|
}
|
|
116
119
|
for (const category of Object.keys(opts.categoryLabels ?? {})) {
|
|
117
120
|
if (!opts.categories.includes(category)) {
|
|
118
|
-
throw
|
|
121
|
+
throw bootRuleError(DOCUMENTS_BOOT_RULES.categoryLabelUnknownCategory, {
|
|
122
|
+
message: `createDocumentsFeature({ categoryLabels }) names "${category}", which is not in categories.`,
|
|
123
|
+
});
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
return defineFeature(DOCUMENTS_FEATURE_NAME, (r) => registerDocuments(r, opts));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const FILE_DERIVATIVES_BOOT_RULES: {
|
|
2
|
+
readonly publicTenantResolutionWithoutApexResolver: {
|
|
3
|
+
readonly id: "file-derivatives/public-tenant-resolution-without-apex-resolver";
|
|
4
|
+
readonly summary: "publicTenantResolution is only set together with resolveApexTenant.";
|
|
5
|
+
readonly fix: "Pass resolveApexTenant or drop publicTenantResolution.";
|
|
6
|
+
};
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const FILE_DERIVATIVES_BOOT_RULES = {
|
|
2
|
+
publicTenantResolutionWithoutApexResolver: {
|
|
3
|
+
id: "file-derivatives/public-tenant-resolution-without-apex-resolver",
|
|
4
|
+
summary: "publicTenantResolution is only set together with resolveApexTenant.",
|
|
5
|
+
fix: "Pass resolveApexTenant or drop publicTenantResolution.",
|
|
6
|
+
},
|
|
7
|
+
};
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
// configurable, so this feature has no `r.config` and no
|
|
7
7
|
// `r.extensionSelector`.
|
|
8
8
|
import { cachedResponse, computeRevisionEtag } from "@cosmicdrift/kumiko-framework/api";
|
|
9
|
-
import { defineFeature, EXT_DERIVATIVE_OVERLAY_RESOLVER, EXT_DERIVATIVE_PUBLIC_PREDICATE, EXT_DERIVATIVE_RENDERER, isUuid, } from "@cosmicdrift/kumiko-framework/engine";
|
|
9
|
+
import { bootRuleError, defineFeature, EXT_DERIVATIVE_OVERLAY_RESOLVER, EXT_DERIVATIVE_PUBLIC_PREDICATE, EXT_DERIVATIVE_RENDERER, isUuid, } from "@cosmicdrift/kumiko-framework/engine";
|
|
10
10
|
import { RateLimitError } from "@cosmicdrift/kumiko-framework/errors";
|
|
11
|
+
import { FILE_DERIVATIVES_BOOT_RULES } from "./boot-rules.js";
|
|
11
12
|
import { PUBLIC_VARIANT_QN, publicVariantQuery } from "./handlers/public-variant.query.js";
|
|
12
13
|
import { PUBLIC_VARIANT_BY_FILE_REF_QN, publicVariantByFileRefQuery, } from "./handlers/public-variant-by-file-ref.query.js";
|
|
13
14
|
const FEATURE_NAME = "file-derivatives";
|
|
@@ -42,7 +43,9 @@ const VARIANT_NAME_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
|
42
43
|
export function createFileDerivativesFeature(opts = {}) {
|
|
43
44
|
const basePath = opts.basePath ?? "/media";
|
|
44
45
|
if (opts.publicTenantResolution !== undefined && !opts.resolveApexTenant) {
|
|
45
|
-
throw
|
|
46
|
+
throw bootRuleError(FILE_DERIVATIVES_BOOT_RULES.publicTenantResolutionWithoutApexResolver, {
|
|
47
|
+
message: "createFileDerivativesFeature: publicTenantResolution requires resolveApexTenant — it only changes which tenant a variant is read from, resolveApexTenant still gates the host.",
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
50
|
return defineFeature(FEATURE_NAME, (r) => {
|
|
48
51
|
r.describe("Declares the `derivativeRenderer` extension point. `ctx.services.derivatives.variant(fileRefId, spec, name)` derives a variant of a tracked FileRef the first time it's requested and reuses the stored result afterwards (derive-on-first-use, keyed by a hash of the spec). Mount at least one `derivatives-*` renderer feature alongside this one — without a registered renderer for the FileRef's MIME type, every `variant(...)` call throws. Also declares the `derivativePublicPredicate` extension point (`r.useExtension(EXT_DERIVATIVE_PUBLIC_PREDICATE, '<entityType>', { isPublic })`) and, when `createFileDerivativesFeature({resolveApexTenant})` is passed a host-resolver, mounts an anonymous `GET {basePath}/:fileRefId/:variant` route that serves any variant name the FileRef's field declared in its `variants` for a FileRef whose entityType has a registered predicate returning true — default-deny (404) otherwise, same as an unknown FileRef or an undeclared variant name. The route's only rate-limit (`per: \"ip\"`) depends on the server's `trustedProxyHops` matching the deployment's actual reverse-proxy count — at the default 0 it ignores `x-forwarded-for` entirely, so every caller shares one bucket until that's configured. `publicTenantResolution: \"fileRef\"` keeps resolveApexTenant as the host gate but reads the variant from the FileRef row's own tenant instead of the host's, so one shared platform host serves every tenant's public variants — each FileRef-tenant's own `isPublic` predicate still default-denies. Also declares the `derivativeOverlayResolver` extension point (`r.useExtension(EXT_DERIVATIVE_OVERLAY_RESOLVER, '<entityType>', { resolve })`), used to turn a variant's `overlays[].dataToken` into the actual QR payload for that FileRef's entityType before the variant is rendered — a variant declaring a `qr` overlay throws at request-time if no resolver is registered for the FileRef's entityType.");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const FOLDERS_BOOT_RULES: {
|
|
2
|
+
readonly emptyParentsAllowlist: {
|
|
3
|
+
readonly id: "folders/empty-parents-allowlist";
|
|
4
|
+
readonly summary: "The parents allowlist is omitted or non-empty.";
|
|
5
|
+
readonly fix: "Omit parents or list at least one entity.";
|
|
6
|
+
};
|
|
7
|
+
};
|
package/dist/folders/feature.js
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
// generic entity handlers), set-folder (put/move), clear-folder (unfile).
|
|
15
15
|
// Deferred: reparenting with cycle-check (folder:update CAN change parentId, but
|
|
16
16
|
// no UI exposes it in v1 — folders-view guards cycles defensively).
|
|
17
|
-
import { defineEntityCreateHandler, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
17
|
+
import { bootRuleError, defineEntityCreateHandler, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
18
18
|
import { assertNoWhereRuleInOwnershipWrite, resolveFeatureAccess } from "../shared/index.js";
|
|
19
|
+
import { FOLDERS_BOOT_RULES } from "./boot-rules.js";
|
|
19
20
|
import { createFolderAssignmentEntity, folderEntity } from "./entity.js";
|
|
20
21
|
import { createClearFolderHandler } from "./handlers/clear-folder.write.js";
|
|
21
22
|
import { createDeleteFolderHandler } from "./handlers/delete-folder.write.js";
|
|
@@ -75,10 +76,12 @@ export function createFoldersFeature(opts = {}) {
|
|
|
75
76
|
}
|
|
76
77
|
assertNoWhereRuleInOwnershipWrite("createFoldersFeature", opts.ownership?.write);
|
|
77
78
|
if (opts.parents !== undefined && opts.parents.length === 0) {
|
|
78
|
-
throw
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
throw bootRuleError(FOLDERS_BOOT_RULES.emptyParentsAllowlist, {
|
|
80
|
+
message: "createFoldersFeature({ parents }): parents must not be an empty array — " +
|
|
81
|
+
"an empty allowlist rejects every set-folder call and hides every " +
|
|
82
|
+
"assignment row. Omit `parents` to keep every registered entity " +
|
|
83
|
+
"admissible as a host instead.",
|
|
84
|
+
});
|
|
82
85
|
}
|
|
83
86
|
const access = resolveFeatureAccess(opts, DEFAULT_FOLDER_ACCESS);
|
|
84
87
|
return defineFeature(FOLDERS_FEATURE_NAME, (r) => registerFolders(r, access, opts.toggleable, opts.ownership, opts.parents));
|