@cosmicdrift/kumiko-samples 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/package.json +1 -1
- package/packages/bundled-features/package.json +13 -13
- package/packages/bundled-features/src/admin-shell/feature.ts +1 -1
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +64 -3
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +13 -130
- package/packages/bundled-features/src/agent-tools/api-docs/anchors.ts +60 -0
- package/packages/bundled-features/src/agent-tools/api-docs/check.ts +25 -0
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +140 -0
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +175 -0
- package/packages/bundled-features/src/agent-tools/api-docs/curl.ts +28 -0
- package/packages/bundled-features/src/agent-tools/api-docs/error-table.ts +45 -0
- package/packages/bundled-features/src/agent-tools/api-docs/examples.ts +43 -0
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +179 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index-json.ts +29 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +21 -0
- package/packages/bundled-features/src/agent-tools/api-docs/list-parameters.ts +38 -0
- package/packages/bundled-features/src/agent-tools/api-docs/markdown.ts +70 -0
- package/packages/bundled-features/src/agent-tools/api-docs/menu-path.ts +82 -0
- package/packages/bundled-features/src/agent-tools/api-docs/model.ts +83 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +58 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-events.ts +76 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +216 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-overview.ts +86 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-reference.ts +79 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-tokens.ts +136 -0
- package/packages/bundled-features/src/agent-tools/api-docs/schema-fields.ts +167 -0
- package/packages/bundled-features/src/agent-tools/api-docs/section-ids.ts +28 -0
- package/packages/bundled-features/src/agent-tools/api-docs/system-only.ts +11 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/de.ts +166 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/en.ts +159 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/es.ts +162 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/fr.ts +169 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/index.ts +67 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/it.ts +165 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/types.ts +130 -0
- package/packages/bundled-features/src/agent-tools/api-docs/ui-writes.ts +81 -0
- package/packages/bundled-features/src/agent-tools/changes.json +24 -0
- package/packages/bundled-features/src/agent-tools/handler-schema.ts +45 -0
- package/packages/bundled-features/src/agent-tools/index.ts +24 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +181 -0
- package/packages/bundled-features/src/auth-email-password/boot-rules.ts +9 -0
- package/packages/bundled-features/src/auth-email-password/feature.ts +6 -19
- package/packages/bundled-features/src/auth-email-password/validate-options.ts +20 -0
- package/packages/bundled-features/src/billing-foundation/boot-rules.ts +26 -0
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +59 -46
- package/packages/bundled-features/src/cap-overview/boot-rules.ts +14 -0
- package/packages/bundled-features/src/cap-overview/feature.ts +12 -5
- package/packages/bundled-features/src/documents/boot-rules.ts +14 -0
- package/packages/bundled-features/src/documents/feature.ts +8 -4
- package/packages/bundled-features/src/file-derivatives/boot-rules.ts +9 -0
- package/packages/bundled-features/src/file-derivatives/feature.ts +6 -3
- package/packages/bundled-features/src/folders/boot-rules.ts +9 -0
- package/packages/bundled-features/src/folders/feature.ts +6 -3
- package/packages/bundled-features/src/helpdesk/boot-rules.ts +9 -0
- package/packages/bundled-features/src/{contact → helpdesk}/challenge.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/changes.json +6 -0
- package/packages/bundled-features/src/{contact/client/contact-client-source.ts → helpdesk/client/helpdesk-client-source.ts} +4 -4
- package/packages/bundled-features/src/helpdesk/client/helpdesk-website-client.ts +29 -0
- package/packages/bundled-features/src/helpdesk/client/index.ts +9 -0
- package/packages/bundled-features/src/{contact → helpdesk}/entity.ts +35 -31
- package/packages/bundled-features/src/{contact → helpdesk}/feature.ts +56 -52
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/attempts.ts +3 -3
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/challenge.query.ts +10 -10
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/forward-request.write.ts +25 -23
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/mark-done.write.ts +11 -11
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/notify-reporter-in-app.write.ts +14 -14
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.query.ts +4 -4
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/replies.query.ts +6 -6
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/reply.write.ts +30 -30
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/report.write.ts +29 -29
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-delivery.query.ts +40 -40
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-detail.query.ts +15 -15
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-list.query.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-reply-mail.write.ts +24 -24
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-test.write.ts +18 -14
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/submit.write.ts +32 -31
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/take-over-uploads.ts +5 -5
- package/packages/bundled-features/src/{contact → helpdesk}/i18n.ts +78 -75
- package/packages/bundled-features/src/helpdesk/index.ts +29 -0
- package/packages/bundled-features/src/{contact → helpdesk}/lib.ts +32 -28
- package/packages/bundled-features/src/{contact → helpdesk}/mail.ts +56 -56
- package/packages/bundled-features/src/{contact → helpdesk}/options.ts +18 -16
- package/packages/bundled-features/src/helpdesk/panels.ts +28 -0
- package/packages/bundled-features/src/{contact → helpdesk}/payloads.ts +33 -33
- package/packages/bundled-features/src/{contact → helpdesk}/screens.ts +104 -104
- package/packages/bundled-features/src/{contact → helpdesk}/subject.ts +3 -3
- package/packages/bundled-features/src/{contact → helpdesk}/user-data-hooks.ts +17 -17
- package/packages/bundled-features/src/helpdesk/web/constants.ts +160 -0
- package/packages/bundled-features/src/helpdesk/web/index.ts +29 -0
- package/packages/bundled-features/src/host-routing/boot-rules.ts +27 -0
- package/packages/bundled-features/src/host-routing/validate-options.ts +36 -27
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +99 -71
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +2 -2
- package/packages/bundled-features/src/jobs/boot-rules.ts +9 -0
- package/packages/bundled-features/src/jobs/feature.ts +9 -4
- package/packages/bundled-features/src/legal-pages/boot-rules.ts +19 -0
- package/packages/bundled-features/src/legal-pages/feature.ts +6 -3
- package/packages/bundled-features/src/legal-pages/lib/validate-routes.ts +11 -5
- package/packages/bundled-features/src/metrics/boot-rules.ts +15 -0
- package/packages/bundled-features/src/metrics/validate.ts +8 -2
- package/packages/bundled-features/src/notes-history/boot-rules.ts +9 -0
- package/packages/bundled-features/src/notes-history/feature.ts +6 -3
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +9 -0
- package/packages/bundled-features/src/personal-access-tokens/changes.json +6 -0
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -2
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +7 -2
- package/packages/bundled-features/src/personal-access-tokens/i18n.ts +6 -1
- package/packages/bundled-features/src/personal-access-tokens/index.ts +37 -2
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -0
- package/packages/bundled-features/src/personal-access-tokens/screens.ts +9 -1
- package/packages/bundled-features/src/personal-access-tokens/web/constants.ts +1 -0
- package/packages/bundled-features/src/personal-access-tokens/web/scopes.ts +14 -0
- package/packages/bundled-features/src/presence/boot-rules.ts +9 -0
- package/packages/bundled-features/src/presence/options.ts +5 -1
- package/packages/bundled-features/src/readiness/boot-rules.ts +14 -0
- package/packages/bundled-features/src/readiness/probe-boot-check.ts +8 -6
- package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +6 -4
- package/packages/bundled-features/src/shared/boot-rules.ts +9 -0
- package/packages/bundled-features/src/subscription-mollie/boot-rules.ts +19 -0
- package/packages/bundled-features/src/subscription-mollie/feature.ts +18 -10
- package/packages/bundled-features/src/tags/boot-rules.ts +9 -0
- package/packages/bundled-features/src/tags/feature.ts +6 -3
- package/packages/bundled-features/src/template-resolver/boot-rules.ts +19 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +14 -10
- package/packages/bundled-features/src/tenant/boot-rules.ts +9 -0
- package/packages/bundled-features/src/tenant/feature.ts +5 -3
- package/samples/apps/marketing-demo/README.md +1 -1
- package/samples/apps/marketing-demo/playwright.config.ts +1 -1
- package/samples/apps/marketing-demo/src/app/client.tsx +3 -3
- package/samples/apps/marketing-demo/src/app/seed-data.ts +1 -1
- package/samples/apps/marketing-demo/src/app/seed.ts +4 -4
- package/samples/apps/marketing-demo/src/app/server.ts +3 -3
- package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/feature.ts +15 -12
- package/samples/apps/marketing-demo/src/features/ticketing/i18n.ts +100 -0
- package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/ticket.ts +4 -4
- package/samples/apps/marketing-demo/src/features/ticketing/web/index.ts +7 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +67 -67
- package/samples/apps/use-all-bundled/kumiko/migrations/0064_helpdesk-rename.rebuild.json +4 -0
- package/samples/apps/use-all-bundled/package.json +1 -1
- package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
- package/samples/apps/use-all-bundled/src/app/screens-feature.ts +10 -10
- package/samples/apps/use-all-bundled/src/run-config.ts +6 -6
- package/samples/recipes/api-docs/README.md +52 -0
- package/samples/recipes/api-docs/api-docs/de/events.md +62 -0
- package/samples/recipes/api-docs/api-docs/de/overview.md +100 -0
- package/samples/recipes/api-docs/api-docs/de/reference/tickets.md +305 -0
- package/samples/recipes/api-docs/api-docs/de/tokens.md +66 -0
- package/samples/recipes/api-docs/api-docs/en/events.md +62 -0
- package/samples/recipes/api-docs/api-docs/en/overview.md +100 -0
- package/samples/recipes/api-docs/api-docs/en/reference/tickets.md +305 -0
- package/samples/recipes/api-docs/api-docs/en/tokens.md +66 -0
- package/samples/recipes/api-docs/api-docs/index.json +371 -0
- package/samples/recipes/api-docs/api-docs/openapi.json +982 -0
- package/samples/recipes/api-docs/api-examples/ticket-close.json +21 -0
- package/samples/recipes/api-docs/api-examples/ticket-create.json +42 -0
- package/samples/recipes/api-docs/api-examples/ticket-detail.json +28 -0
- package/samples/recipes/api-docs/api-examples/ticket-list.json +31 -0
- package/samples/recipes/api-docs/api-examples/ticket-update.json +54 -0
- package/samples/recipes/api-docs/api-examples/webhooks/ticket-closed.json +8 -0
- package/samples/recipes/api-docs/api-examples/webhooks/ticket-created.json +10 -0
- package/samples/recipes/api-docs/kumiko.config.ts +33 -0
- package/samples/recipes/api-docs/package.json +14 -0
- package/samples/recipes/api-docs/src/feature.ts +218 -0
- package/samples/recipes/api-docs/tsconfig.json +22 -0
- package/samples/recipes/golden-path/src/feature.ts +1 -1
- package/samples/recipes/{contact → helpdesk}/README.md +16 -16
- package/samples/recipes/{contact → helpdesk}/package.json +2 -2
- package/samples/recipes/{contact → helpdesk}/src/feature.ts +6 -6
- package/packages/bundled-features/src/contact/client/contact-website-client.ts +0 -29
- package/packages/bundled-features/src/contact/client/index.ts +0 -9
- package/packages/bundled-features/src/contact/index.ts +0 -29
- package/packages/bundled-features/src/contact/panels.ts +0 -28
- package/packages/bundled-features/src/contact/web/constants.ts +0 -160
- package/packages/bundled-features/src/contact/web/index.ts +0 -29
- package/samples/apps/marketing-demo/src/features/helpdesk/i18n.ts +0 -100
- package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +0 -7
- /package/packages/bundled-features/src/{contact → helpdesk}/handlers/access.ts +0 -0
- /package/packages/bundled-features/src/{contact → helpdesk}/pow.ts +0 -0
- /package/packages/bundled-features/src/{contact → helpdesk}/user-agent.ts +0 -0
- /package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/index.ts +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { LEGAL_PAGES_BOOT_RULES } from "../boot-rules.ts";
|
|
1
3
|
import type { LegalPageRoute } from "../web/constants.ts";
|
|
2
4
|
|
|
3
5
|
// Validated once at feature-build time (not per-request) so a config typo
|
|
@@ -6,15 +8,19 @@ export function validateRoutes(routes: readonly LegalPageRoute[]): void {
|
|
|
6
8
|
const seenPaths = new Set<string>();
|
|
7
9
|
for (const route of routes) {
|
|
8
10
|
if (!route.path || !route.slug || !route.lang) {
|
|
9
|
-
throw
|
|
10
|
-
`legal-pages: route is missing a required field (path/slug/lang): ${JSON.stringify(route)}`,
|
|
11
|
-
);
|
|
11
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.invalidRoute, {
|
|
12
|
+
message: `legal-pages: route is missing a required field (path/slug/lang): ${JSON.stringify(route)}`,
|
|
13
|
+
});
|
|
12
14
|
}
|
|
13
15
|
if (!route.path.startsWith("/")) {
|
|
14
|
-
throw
|
|
16
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.invalidRoute, {
|
|
17
|
+
message: `legal-pages: route path must start with "/", got "${route.path}"`,
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
if (seenPaths.has(route.path)) {
|
|
17
|
-
throw
|
|
21
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.duplicateRoutePath, {
|
|
22
|
+
message: `legal-pages: duplicate route path "${route.path}"`,
|
|
23
|
+
});
|
|
18
24
|
}
|
|
19
25
|
seenPaths.add(route.path);
|
|
20
26
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const METRICS_BOOT_RULES = {
|
|
4
|
+
duplicateMetricId: {
|
|
5
|
+
id: "metrics/duplicate-metric-id",
|
|
6
|
+
summary: "Metric ids passed to the metrics factory are unique.",
|
|
7
|
+
fix: "Rename one of the metrics.",
|
|
8
|
+
},
|
|
9
|
+
invalidMetric: {
|
|
10
|
+
id: "metrics/invalid-metric",
|
|
11
|
+
summary:
|
|
12
|
+
"Each metric passed to the metrics factory has a kebab-case id and a valid definition.",
|
|
13
|
+
fix: "Fix the metric named in the error message.",
|
|
14
|
+
},
|
|
15
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { extractTableInfo, isTimestamptzType } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { METRICS_BOOT_RULES } from "./boot-rules.ts";
|
|
2
4
|
import { filterValueKindOf, metricFilterEntries, RESERVED_PAYLOAD_KEYS } from "./filters.ts";
|
|
3
5
|
import type { MetricDefinition } from "./types.ts";
|
|
4
6
|
import { METRIC_RANGES } from "./web/constants.ts";
|
|
@@ -15,7 +17,9 @@ export function validateMetrics(metrics: readonly MetricDefinition[]): void {
|
|
|
15
17
|
const seen = new Set<string>();
|
|
16
18
|
for (const metric of metrics) {
|
|
17
19
|
if (seen.has(metric.id)) {
|
|
18
|
-
throw
|
|
20
|
+
throw bootRuleError(METRICS_BOOT_RULES.duplicateMetricId, {
|
|
21
|
+
message: `metrics: duplicate metric id "${metric.id}"`,
|
|
22
|
+
});
|
|
19
23
|
}
|
|
20
24
|
seen.add(metric.id);
|
|
21
25
|
validateMetric(metric);
|
|
@@ -27,7 +31,9 @@ type TableInfo = ReturnType<typeof extractTableInfo>;
|
|
|
27
31
|
|
|
28
32
|
function validateMetric(metric: MetricDefinition): void {
|
|
29
33
|
const fail: Fail = (reason) => {
|
|
30
|
-
throw
|
|
34
|
+
throw bootRuleError(METRICS_BOOT_RULES.invalidMetric, {
|
|
35
|
+
message: `metrics: metric "${metric.id}" ${reason}`,
|
|
36
|
+
});
|
|
31
37
|
};
|
|
32
38
|
if (!KEBAB_ID.test(metric.id)) fail("has an id that is not kebab-case");
|
|
33
39
|
if (metric.scopes.length === 0) fail("declares no scopes");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const NOTES_HISTORY_BOOT_RULES = {
|
|
4
|
+
emptyParentsAllowlist: {
|
|
5
|
+
id: "notes-history/empty-parents-allowlist",
|
|
6
|
+
summary: "The parents allowlist is omitted or non-empty.",
|
|
7
|
+
fix: "Omit parents or list at least one entity.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
17
|
type AccessRule,
|
|
18
|
+
bootRuleError,
|
|
18
19
|
defineEntityListHandler,
|
|
19
20
|
defineFeature,
|
|
20
21
|
type EntityDefinition,
|
|
21
22
|
type FeatureRegistrar,
|
|
22
23
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
23
24
|
import { assertNoWhereRuleInOwnershipWrite, resolveFeatureAccess } from "../shared/index.ts";
|
|
25
|
+
import { NOTES_HISTORY_BOOT_RULES } from "./boot-rules.ts";
|
|
24
26
|
import { createNoteEntryEntity, noteMentionEntity } from "./entity.ts";
|
|
25
27
|
import { createNoteEntryExecutor } from "./executor.ts";
|
|
26
28
|
import { createAddNoteHandler } from "./handlers/add-note.write.ts";
|
|
@@ -122,11 +124,12 @@ export function createNotesHistoryFeature(
|
|
|
122
124
|
// that's a config mistake, not a valid allowlist. Omit `parents` instead
|
|
123
125
|
// of passing an empty array.
|
|
124
126
|
if (opts.parents !== undefined && opts.parents.length === 0) {
|
|
125
|
-
throw
|
|
126
|
-
|
|
127
|
+
throw bootRuleError(NOTES_HISTORY_BOOT_RULES.emptyParentsAllowlist, {
|
|
128
|
+
message:
|
|
129
|
+
"createNotesHistoryFeature({ parents }): parents must not be an empty array — " +
|
|
127
130
|
"an empty allowlist rejects every add-note call. Omit `parents` to allow " +
|
|
128
131
|
"any registered entity the caller can read as a note parent.",
|
|
129
|
-
);
|
|
132
|
+
});
|
|
130
133
|
}
|
|
131
134
|
return defineFeature(NOTES_HISTORY_FEATURE_NAME, (r) =>
|
|
132
135
|
registerNotesHistory(
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const PERSONAL_ACCESS_TOKENS_BOOT_RULES = {
|
|
4
|
+
scopeEventWithoutContract: {
|
|
5
|
+
id: "personal-access-tokens/scope-event-without-contract",
|
|
6
|
+
summary: "Events listed in PAT scopes have a public webhook contract.",
|
|
7
|
+
fix: "Declare the event with r.defineWebhookEvent or opt the entity into webhookEvents.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.412.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "token scopes list the webhook events they release",
|
|
6
|
+
"detail": "`PatScopeDef.events` takes exact event names (no globs). Holding the scope at read or write level is enough to subscribe, `expandScopeEvents(config, granted)` returns the union. Boot fails when a scope lists an event without a public contract, for example an internal `r.defineEvent`. Revoking a token now has a title and a field label in every bundle locale."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.385.0",
|
|
4
10
|
"type": "improvement",
|
|
@@ -19,6 +19,7 @@ import { PAT_FEATURE_I18N, patScopeOptionTranslations } from "./i18n.ts";
|
|
|
19
19
|
import { PAT_REVOKED_EVENT_SHORT, patRevokedSchema } from "./pat-revoked-event.ts";
|
|
20
20
|
import { createPatResolver } from "./resolver.ts";
|
|
21
21
|
import { apiTokenEntity } from "./schema/api-token.ts";
|
|
22
|
+
import { validateScopeEventContracts } from "./scope-events-check.ts";
|
|
22
23
|
import { createPatMintScreen, patListScreen } from "./screens.ts";
|
|
23
24
|
import {
|
|
24
25
|
API_TOKEN_ENTITY_NAME,
|
|
@@ -84,6 +85,7 @@ export type PersonalAccessTokensOptions = {
|
|
|
84
85
|
|
|
85
86
|
export type PatFeatureExports = {
|
|
86
87
|
readonly rateLimit: PatRateLimit;
|
|
88
|
+
readonly scopes: PatScopeConfig;
|
|
87
89
|
readonly bindAutoRevokeOnPasswordChange: BindPatAutoRevokeOnPasswordChange;
|
|
88
90
|
};
|
|
89
91
|
|
|
@@ -138,6 +140,7 @@ export function createPersonalAccessTokensFeature(
|
|
|
138
140
|
// different path. No projection: the payload IS the read, consumed
|
|
139
141
|
// directly off the event-store NOTIFY.
|
|
140
142
|
r.defineEvent(PAT_REVOKED_EVENT_SHORT, patRevokedSchema, { piiFields: "none" });
|
|
143
|
+
r.bootCheck(({ features }) => validateScopeEventContracts(scopes, features));
|
|
141
144
|
|
|
142
145
|
// Password-change auto-revoke — mirrors sessions' own
|
|
143
146
|
// autoRevokeOnPasswordChange postSave hook, including WHY it's a
|
|
@@ -195,12 +198,12 @@ export function createPersonalAccessTokensFeature(
|
|
|
195
198
|
|
|
196
199
|
// rateLimit flows into feature.exports so run-prod-app builds the
|
|
197
200
|
// limiter from the same declaration — single source of truth. `scopes`
|
|
198
|
-
// is
|
|
199
|
-
// available-scopes, so it doesn't need to round-trip through exports.
|
|
201
|
+
// is also exported so the API-docs generator can read the catalog.
|
|
200
202
|
return {
|
|
201
203
|
handlers,
|
|
202
204
|
queries,
|
|
203
205
|
bindAutoRevokeOnPasswordChange,
|
|
206
|
+
scopes,
|
|
204
207
|
rateLimit: options.rateLimit ?? PAT_DEFAULT_RATE_LIMIT,
|
|
205
208
|
} satisfies { handlers: unknown; queries: unknown } & PatFeatureExports;
|
|
206
209
|
});
|
|
@@ -12,7 +12,12 @@ import { encryptForDirectWrite, unprocessable, verifyPassword } from "../../shar
|
|
|
12
12
|
import { UserQueries } from "../../user/index.ts";
|
|
13
13
|
import { mintPatToken } from "../hash.ts";
|
|
14
14
|
import { apiTokenEntity, apiTokenTable } from "../schema/api-token.ts";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
API_TOKEN_ENTITY_NAME,
|
|
17
|
+
PAT_DEFAULT_EXPIRES_IN_DAYS,
|
|
18
|
+
PAT_MAX_EXPIRES_IN_DAYS,
|
|
19
|
+
PatErrors,
|
|
20
|
+
} from "../web/constants.ts";
|
|
16
21
|
|
|
17
22
|
export type PatMfaVerifyResult = { readonly enrolled: boolean; readonly ok: boolean };
|
|
18
23
|
|
|
@@ -49,7 +54,7 @@ export function createPatCreateHandler(opts: CreatePatOptions = {}) {
|
|
|
49
54
|
schema: z.object({
|
|
50
55
|
name: z.string().min(1).max(120),
|
|
51
56
|
scopes: z.array(z.string().min(1)).min(1),
|
|
52
|
-
expiresInDays: z.number().int().positive().max(
|
|
57
|
+
expiresInDays: z.number().int().positive().max(PAT_MAX_EXPIRES_IN_DAYS).optional(),
|
|
53
58
|
currentPassword: z.string().min(1),
|
|
54
59
|
mfaCode: z.string().optional(),
|
|
55
60
|
}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ACTION_FORM_ENTITY } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { fieldLabelKey, fieldOptionLabelKey } from "@cosmicdrift/kumiko-renderer/headless";
|
|
3
|
-
import { PAT_FEATURE } from "./web/constants.ts";
|
|
3
|
+
import { PAT_FEATURE, PatHandlers } from "./web/constants.ts";
|
|
4
4
|
import type { PatScopeConfig } from "./web/scopes.ts";
|
|
5
5
|
|
|
6
6
|
const mintFieldKey = (field: string): string =>
|
|
@@ -12,6 +12,9 @@ const scopeOptionKey = (grant: string): string =>
|
|
|
12
12
|
export const patScopeOptionKey = (domain: string, level: "read" | "write"): string =>
|
|
13
13
|
scopeOptionKey(`${domain}:${level}`);
|
|
14
14
|
|
|
15
|
+
// The revoke handler has no entity and no action form, so its title and field label only exist here.
|
|
16
|
+
const patRevokeKey = (suffix: string): string => `${PatHandlers.revoke}:${suffix}`;
|
|
17
|
+
|
|
15
18
|
type LocalizedString = { readonly en: string };
|
|
16
19
|
|
|
17
20
|
export const PAT_FEATURE_I18N: Readonly<Record<string, LocalizedString>> = {
|
|
@@ -29,6 +32,8 @@ export const PAT_FEATURE_I18N: Readonly<Record<string, LocalizedString>> = {
|
|
|
29
32
|
"pat.list.status.expired": { en: "Expired" },
|
|
30
33
|
"pat.list.revoke": { en: "Revoke" },
|
|
31
34
|
"pat.list.revoke.confirm": { en: "Revoke this token? Anything using it will stop working." },
|
|
35
|
+
[patRevokeKey("title")]: { en: "Revoke token" },
|
|
36
|
+
[patRevokeKey("field:id")]: { en: "Token" },
|
|
32
37
|
|
|
33
38
|
"pat.create.title": { en: "Create a new token" },
|
|
34
39
|
"pat.create.submit": { en: "Create token" },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { PAT_DEFAULT_RATE_LIMIT, type PatRateLimit } from "./web/constants.ts";
|
|
3
|
+
import type { PatScopeConfig, PatScopeDef } from "./web/scopes.ts";
|
|
3
4
|
|
|
4
5
|
export type { BindPatAutoRevokeOnPasswordChange, PersonalAccessTokensOptions } from "./feature.ts";
|
|
5
6
|
export {
|
|
@@ -20,9 +21,43 @@ export { createPatResolver } from "./resolver.ts";
|
|
|
20
21
|
export { revokeAllPatTokensForUser } from "./revoke-for-user.ts";
|
|
21
22
|
export { apiTokenEntity, apiTokenTable } from "./schema/api-token.ts";
|
|
22
23
|
export type { PatRateLimit } from "./web/constants.ts";
|
|
23
|
-
export {
|
|
24
|
+
export {
|
|
25
|
+
PAT_DEFAULT_EXPIRES_IN_DAYS,
|
|
26
|
+
PAT_DEFAULT_RATE_LIMIT,
|
|
27
|
+
PAT_FEATURE,
|
|
28
|
+
PAT_MAX_EXPIRES_IN_DAYS,
|
|
29
|
+
PAT_SCREEN_ID,
|
|
30
|
+
PatHandlers,
|
|
31
|
+
PatQueries,
|
|
32
|
+
} from "./web/constants.ts";
|
|
24
33
|
export type { PatScopeConfig, PatScopeDef } from "./web/scopes.ts";
|
|
25
|
-
export { expandScopes } from "./web/scopes.ts";
|
|
34
|
+
export { expandScopeEvents, expandScopes } from "./web/scopes.ts";
|
|
35
|
+
|
|
36
|
+
function isStringArray(value: unknown): value is readonly string[] {
|
|
37
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isPatScopeDef(value: unknown): value is PatScopeDef {
|
|
41
|
+
if (!value || typeof value !== "object") return false;
|
|
42
|
+
if (!("label" in value) || typeof value.label !== "string") return false;
|
|
43
|
+
if (!("read" in value) || !isStringArray(value.read)) return false;
|
|
44
|
+
if ("write" in value && value.write !== undefined && !isStringArray(value.write)) return false;
|
|
45
|
+
return !("events" in value) || value.events === undefined || isStringArray(value.events);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isPatScopeConfig(value: unknown): value is PatScopeConfig {
|
|
49
|
+
return !!value && typeof value === "object" && Object.values(value).every(isPatScopeDef);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Reads the scope catalog off a mounted PAT feature's exports; undefined for any other feature.
|
|
53
|
+
export function patScopesFromFeature(feature: FeatureDefinition): PatScopeConfig | undefined {
|
|
54
|
+
const exports = feature.exports;
|
|
55
|
+
if (exports && typeof exports === "object" && "scopes" in exports) {
|
|
56
|
+
const { scopes } = exports;
|
|
57
|
+
if (isPatScopeConfig(scopes)) return scopes;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
26
61
|
|
|
27
62
|
// Reads the per-token rate-limit config off a mounted PAT feature's exports.
|
|
28
63
|
// Falls back to the default when absent. run-prod-app uses this to build the
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bootRuleError,
|
|
3
|
+
createWebhookContractResolver,
|
|
4
|
+
type FeatureDefinition,
|
|
5
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import { PERSONAL_ACCESS_TOKENS_BOOT_RULES } from "./boot-rules.ts";
|
|
7
|
+
import { PAT_FEATURE } from "./web/constants.ts";
|
|
8
|
+
import type { PatScopeConfig } from "./web/scopes.ts";
|
|
9
|
+
|
|
10
|
+
function entityNameOf(qualifiedName: string): string {
|
|
11
|
+
const dot = qualifiedName.lastIndexOf(".");
|
|
12
|
+
return dot > 0 ? qualifiedName.slice(0, dot) : qualifiedName;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function validateScopeEventContracts(
|
|
16
|
+
scopes: PatScopeConfig,
|
|
17
|
+
features: readonly FeatureDefinition[],
|
|
18
|
+
): void {
|
|
19
|
+
const resolver = createWebhookContractResolver(features);
|
|
20
|
+
for (const [domain, def] of Object.entries(scopes)) {
|
|
21
|
+
for (const qn of def.events ?? []) {
|
|
22
|
+
if (resolver.get(qn)) continue;
|
|
23
|
+
throw bootRuleError(PERSONAL_ACCESS_TOKENS_BOOT_RULES.scopeEventWithoutContract, {
|
|
24
|
+
message:
|
|
25
|
+
`[${PAT_FEATURE}] scope "${domain}" lists event "${qn}" without a public contract. ` +
|
|
26
|
+
"Declare it with r.defineWebhookEvent(...), or set webhookEvents: true on the entity to release its <entity>.created/.updated/.deleted events " +
|
|
27
|
+
`(entity "${entityNameOf(qn)}" has no such opt-in); internal r.defineEvent events are never released.`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
import { ACTION_FORM_ENTITY } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
8
8
|
import { fieldOptionLabelKeyPrefix } from "@cosmicdrift/kumiko-renderer/headless";
|
|
9
9
|
import {
|
|
10
|
+
PAT_DEFAULT_EXPIRES_IN_DAYS,
|
|
10
11
|
PAT_FEATURE,
|
|
12
|
+
PAT_MAX_EXPIRES_IN_DAYS,
|
|
11
13
|
PAT_MINT_SCREEN_ID,
|
|
12
14
|
PAT_SCREEN_ID,
|
|
13
15
|
PatHandlers,
|
|
@@ -136,7 +138,13 @@ export function createPatMintScreen(scopes: PatScopeConfig): SecretMintScreenDef
|
|
|
136
138
|
display: "checkboxes",
|
|
137
139
|
options: patGrantOptions(scopes),
|
|
138
140
|
},
|
|
139
|
-
expiresInDays: {
|
|
141
|
+
expiresInDays: {
|
|
142
|
+
type: "number",
|
|
143
|
+
integer: true,
|
|
144
|
+
min: 1,
|
|
145
|
+
max: PAT_MAX_EXPIRES_IN_DAYS,
|
|
146
|
+
default: PAT_DEFAULT_EXPIRES_IN_DAYS,
|
|
147
|
+
},
|
|
140
148
|
currentPassword: { type: "text", required: true, format: "password", sensitive: true },
|
|
141
149
|
mfaCode: { type: "text" },
|
|
142
150
|
},
|
|
@@ -15,6 +15,7 @@ export const PatErrors = {
|
|
|
15
15
|
// default is a standing-credential risk; the existing 3650-day cap still
|
|
16
16
|
// lets callers who genuinely want a long-lived token pass it explicitly.
|
|
17
17
|
export const PAT_DEFAULT_EXPIRES_IN_DAYS = 90;
|
|
18
|
+
export const PAT_MAX_EXPIRES_IN_DAYS = 3650;
|
|
18
19
|
|
|
19
20
|
// Declarative projectionList screen id — the caller's own tokens, revoke as a
|
|
20
21
|
// row action. The app places it via r.nav.
|
|
@@ -10,6 +10,9 @@ export type PatScopeDef = {
|
|
|
10
10
|
readonly read: readonly string[];
|
|
11
11
|
// Omit for a read-only domain — the UI then offers only "no access" / "read".
|
|
12
12
|
readonly write?: readonly string[];
|
|
13
|
+
// Exact webhook event QNs (no globs): a subscriber must know exactly what it gets. Every entry
|
|
14
|
+
// needs a public contract (r.defineWebhookEvent or an entity event); the boot check enforces it.
|
|
15
|
+
readonly events?: readonly string[];
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
export type PatScopeConfig = Readonly<Record<string, PatScopeDef>>;
|
|
@@ -24,6 +27,17 @@ export function parseGrant(grant: string): { domain: string; level: string } | n
|
|
|
24
27
|
return { domain: grant.slice(0, idx), level: grant.slice(idx + 1) };
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
// Union of the webhook events of every granted domain; read level already suffices to subscribe.
|
|
31
|
+
export function expandScopeEvents(config: PatScopeConfig, granted: readonly string[]): string[] {
|
|
32
|
+
const out = new Set<string>();
|
|
33
|
+
for (const grant of granted) {
|
|
34
|
+
const parsed = parseGrant(grant);
|
|
35
|
+
if (!parsed) continue;
|
|
36
|
+
for (const qn of config[parsed.domain]?.events ?? []) out.add(qn);
|
|
37
|
+
}
|
|
38
|
+
return [...out];
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
// Expand granted "<domain>:<level>" entries into the union of QN globs: read
|
|
28
42
|
// always grants the read QNs; write additionally grants the write QNs. Unknown
|
|
29
43
|
// domains contribute nothing (fail-closed — a scope dropped from config after a
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const PRESENCE_BOOT_RULES = {
|
|
4
|
+
invalidTtlSeconds: {
|
|
5
|
+
id: "presence/invalid-ttl-seconds",
|
|
6
|
+
summary: "The presence ttlSeconds option is a positive number.",
|
|
7
|
+
fix: "Pass a positive ttlSeconds.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { PRESENCE_BOOT_RULES } from "./boot-rules.ts";
|
|
1
3
|
export const PRESENCE_DEFAULT_ROLES: readonly string[] = ["TenantAdmin", "TenantMember"];
|
|
2
4
|
export const PRESENCE_DEFAULT_TTL_SECONDS = 45;
|
|
3
5
|
|
|
@@ -20,7 +22,9 @@ export type PresenceSettings = {
|
|
|
20
22
|
export function resolvePresenceSettings(options: PresenceOptions): PresenceSettings {
|
|
21
23
|
const ttlSeconds = options.ttlSeconds ?? PRESENCE_DEFAULT_TTL_SECONDS;
|
|
22
24
|
if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
|
|
23
|
-
throw
|
|
25
|
+
throw bootRuleError(PRESENCE_BOOT_RULES.invalidTtlSeconds, {
|
|
26
|
+
message: `presence: ttlSeconds must be a positive number, got ${ttlSeconds}`,
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
29
|
return {
|
|
26
30
|
entities: new Set(options.entities ?? []),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const READINESS_BOOT_RULES = {
|
|
4
|
+
probeTranslationMissing: {
|
|
5
|
+
id: "readiness/probe-translation-missing",
|
|
6
|
+
summary: "Probe area and label keys are defined by a mounted feature.",
|
|
7
|
+
fix: "Add the key via r.translations(...).",
|
|
8
|
+
},
|
|
9
|
+
probeFixScreenUnknown: {
|
|
10
|
+
id: "readiness/probe-fix-screen-unknown",
|
|
11
|
+
summary: "A probe fixScreen names a screen of a mounted feature.",
|
|
12
|
+
fix: "Use a <feature>:screen:<id> qualified name of a mounted screen.",
|
|
13
|
+
},
|
|
14
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bootRuleError,
|
|
2
3
|
buildConfigFeatureSchema,
|
|
3
4
|
createRegistry,
|
|
4
5
|
type FeatureDefinition,
|
|
5
6
|
SETTINGS_HUB_FEATURE,
|
|
6
7
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
8
|
+
import { READINESS_BOOT_RULES } from "./boot-rules.ts";
|
|
7
9
|
|
|
8
10
|
// Settings screens come from config keys at schema build, not from r.screen, yet a probe may
|
|
9
11
|
// link a failed row to one (mail sending lives on config:screen:mail-foundation-tenant).
|
|
@@ -38,15 +40,15 @@ export function validateProbeTranslations(features: readonly FeatureDefinition[]
|
|
|
38
40
|
["label", probe.label],
|
|
39
41
|
] as const) {
|
|
40
42
|
if (!defined.has(key)) {
|
|
41
|
-
throw
|
|
42
|
-
`Probe "${probe.qualifiedName}": ${field} translation key "${key}" is not defined by any mounted feature. Add it via r.translations(...).`,
|
|
43
|
-
);
|
|
43
|
+
throw bootRuleError(READINESS_BOOT_RULES.probeTranslationMissing, {
|
|
44
|
+
message: `Probe "${probe.qualifiedName}": ${field} translation key "${key}" is not defined by any mounted feature. Add it via r.translations(...).`,
|
|
45
|
+
});
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
if (probe.fixScreen !== undefined && !screenQns.has(probe.fixScreen)) {
|
|
47
|
-
throw
|
|
48
|
-
`Probe "${probe.qualifiedName}": fixScreen "${probe.fixScreen}" is not a screen of any mounted feature. Use a "<feature>:screen:<id>" QN.`,
|
|
49
|
-
);
|
|
49
|
+
throw bootRuleError(READINESS_BOOT_RULES.probeFixScreenUnknown, {
|
|
50
|
+
message: `Probe "${probe.qualifiedName}": fixScreen "${probe.fixScreen}" is not a screen of any mounted feature. Use a "<feature>:screen:<id>" QN.`,
|
|
51
|
+
});
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { bootRuleError, type OwnershipMap } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { SHARED_BOOT_RULES } from "./boot-rules.ts";
|
|
2
3
|
|
|
3
4
|
// Boot validation rejects `{ kind: "where" }` in access.write too;
|
|
4
5
|
// failing at factory time names the option instead of an entity scope.
|
|
@@ -13,13 +14,14 @@ export function assertNoWhereRuleInOwnershipWrite(
|
|
|
13
14
|
);
|
|
14
15
|
// skip: no where-rule present, the option is valid
|
|
15
16
|
if (!hasWhereRule) return;
|
|
16
|
-
throw
|
|
17
|
-
|
|
17
|
+
throw bootRuleError(SHARED_BOOT_RULES.whereRuleInOwnershipWrite, {
|
|
18
|
+
message:
|
|
19
|
+
`${factoryName}({ ownership }): ownership.write must not contain a ` +
|
|
18
20
|
'`{ kind: "where" }` rule — where-rules are evaluated only at the SQL ' +
|
|
19
21
|
"layer (the read path, via buildOwnershipClause). Write paths that " +
|
|
20
22
|
"consult access.write (userCanCreateFieldRow/userCanWriteFieldRow) can't " +
|
|
21
23
|
"evaluate them, so such a rule can only ever deny — boot validation " +
|
|
22
24
|
"rejects it too (fw#2626). Use a `from()` rule for ownership.write, or " +
|
|
23
25
|
"leave it unset.",
|
|
24
|
-
);
|
|
26
|
+
});
|
|
25
27
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const SHARED_BOOT_RULES = {
|
|
4
|
+
whereRuleInOwnershipWrite: {
|
|
5
|
+
id: "shared/where-rule-in-ownership-write",
|
|
6
|
+
summary: "ownership.write of a bundled-feature factory contains no where rule.",
|
|
7
|
+
fix: "Drop the where rule from ownership.write; it only applies on the read path.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const SUBSCRIPTION_MOLLIE_BOOT_RULES = {
|
|
4
|
+
emptyApiKey: {
|
|
5
|
+
id: "subscription-mollie/empty-api-key",
|
|
6
|
+
summary: "The Mollie provider receives a non-empty apiKey.",
|
|
7
|
+
fix: "Set MOLLIE_API_KEY before mounting.",
|
|
8
|
+
},
|
|
9
|
+
emptyWebhookUrl: {
|
|
10
|
+
id: "subscription-mollie/empty-webhook-url",
|
|
11
|
+
summary: "The Mollie provider receives a non-empty webhookUrl.",
|
|
12
|
+
fix: "Pass the foundation webhook URL Mollie sends events to.",
|
|
13
|
+
},
|
|
14
|
+
priceMapDrift: {
|
|
15
|
+
id: "subscription-mollie/price-map-drift",
|
|
16
|
+
summary: "priceToTier and priceToConfig declare the same price ids.",
|
|
17
|
+
fix: "Make both maps list the same price ids.",
|
|
18
|
+
},
|
|
19
|
+
} as const satisfies BootRuleTable;
|
|
@@ -40,9 +40,14 @@
|
|
|
40
40
|
// ];
|
|
41
41
|
|
|
42
42
|
import type { SubscriptionProviderPlugin } from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
bootRuleError,
|
|
45
|
+
defineFeature,
|
|
46
|
+
type FeatureDefinition,
|
|
47
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
44
48
|
import { createMollieClient } from "@mollie/api-client";
|
|
45
49
|
import * as z from "zod";
|
|
50
|
+
import { SUBSCRIPTION_MOLLIE_BOOT_RULES } from "./boot-rules.ts";
|
|
46
51
|
import { MOLLIE_PROVIDER_NAME, SUBSCRIPTION_MOLLIE_FEATURE } from "./constants.ts";
|
|
47
52
|
import { createMollieCheckoutSession, type MolliePriceConfig } from "./plugin-methods.ts";
|
|
48
53
|
import { type MollieClientShape, verifyAndParseMollieWebhook } from "./verify-webhook.ts";
|
|
@@ -91,14 +96,16 @@ export function createSubscriptionMollieFeature(
|
|
|
91
96
|
options: SubscriptionMollieOptions,
|
|
92
97
|
): FeatureDefinition {
|
|
93
98
|
if (options.apiKey.length === 0) {
|
|
94
|
-
throw
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
throw bootRuleError(SUBSCRIPTION_MOLLIE_BOOT_RULES.emptyApiKey, {
|
|
100
|
+
message:
|
|
101
|
+
"subscription-mollie: apiKey is empty. Set MOLLIE_API_KEY (or system-config) before mounting.",
|
|
102
|
+
});
|
|
97
103
|
}
|
|
98
104
|
if (options.webhookUrl.length === 0) {
|
|
99
|
-
throw
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
throw bootRuleError(SUBSCRIPTION_MOLLIE_BOOT_RULES.emptyWebhookUrl, {
|
|
106
|
+
message:
|
|
107
|
+
"subscription-mollie: webhookUrl is empty. Set the foundation-webhook-URL where Mollie sends events.",
|
|
108
|
+
});
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
// Drift guard: priceToTier and priceToConfig must have identical keys;
|
|
@@ -108,11 +115,12 @@ export function createSubscriptionMollieFeature(
|
|
|
108
115
|
const missingInConfig = [...tierKeys].filter((k) => !configKeys.has(k));
|
|
109
116
|
const missingInTier = [...configKeys].filter((k) => !tierKeys.has(k));
|
|
110
117
|
if (missingInConfig.length > 0 || missingInTier.length > 0) {
|
|
111
|
-
throw
|
|
112
|
-
|
|
118
|
+
throw bootRuleError(SUBSCRIPTION_MOLLIE_BOOT_RULES.priceMapDrift, {
|
|
119
|
+
message:
|
|
120
|
+
`subscription-mollie: priceToTier ↔ priceToConfig drift — ` +
|
|
113
121
|
`priceIds in tier but missing config: [${missingInConfig.join(", ")}]; ` +
|
|
114
122
|
`priceIds in config but missing tier: [${missingInTier.join(", ")}]`,
|
|
115
|
-
);
|
|
123
|
+
});
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
const client = createMollieClient({ apiKey: options.apiKey });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const TAGS_BOOT_RULES = {
|
|
4
|
+
emptyParentsAllowlist: {
|
|
5
|
+
id: "tags/empty-parents-allowlist",
|
|
6
|
+
summary: "The parents allowlist is omitted or non-empty.",
|
|
7
|
+
fix: "Omit parents or list at least one entity.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
22
|
type AccessRule,
|
|
23
|
+
bootRuleError,
|
|
23
24
|
defineEntityDetailHandler,
|
|
24
25
|
defineEntityListHandler,
|
|
25
26
|
defineEntityUpdateHandler,
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
28
29
|
type FeatureRegistrar,
|
|
29
30
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
30
31
|
import { assertNoWhereRuleInOwnershipWrite, resolveFeatureAccess } from "../shared/index.ts";
|
|
32
|
+
import { TAGS_BOOT_RULES } from "./boot-rules.ts";
|
|
31
33
|
import { createTagAssignmentEntity, tagEntity } from "./entity.ts";
|
|
32
34
|
import { createTagAssignmentExecutor } from "./executor.ts";
|
|
33
35
|
import { createAssignTagHandler } from "./handlers/assign-tag.write.ts";
|
|
@@ -189,12 +191,13 @@ export function createTagsFeature(opts: TagsFeatureOptions = {}): typeof default
|
|
|
189
191
|
return defaultTagsFeature;
|
|
190
192
|
}
|
|
191
193
|
if (opts.parents !== undefined && opts.parents.length === 0) {
|
|
192
|
-
throw
|
|
193
|
-
|
|
194
|
+
throw bootRuleError(TAGS_BOOT_RULES.emptyParentsAllowlist, {
|
|
195
|
+
message:
|
|
196
|
+
"createTagsFeature({ parents }): parents must not be an empty array — " +
|
|
194
197
|
"an empty allowlist rejects every assign-tag call and hides every " +
|
|
195
198
|
"assignment row. Omit `parents` to keep every registered entity " +
|
|
196
199
|
"admissible as a host instead.",
|
|
197
|
-
);
|
|
200
|
+
});
|
|
198
201
|
}
|
|
199
202
|
assertNoWhereRuleInOwnershipWrite("createTagsFeature", opts.ownership?.write);
|
|
200
203
|
const access = resolveFeatureAccess(opts, DEFAULT_TAG_ACCESS);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const TEMPLATE_RESOLVER_BOOT_RULES = {
|
|
4
|
+
collectionRefusedKind: {
|
|
5
|
+
id: "template-resolver/collection-refused-kind",
|
|
6
|
+
summary: "Collections only use kinds that collections may write.",
|
|
7
|
+
fix: "Pick an allowed collection kind.",
|
|
8
|
+
},
|
|
9
|
+
tenantEditableDuplicate: {
|
|
10
|
+
id: "template-resolver/tenant-editable-duplicate",
|
|
11
|
+
summary: "tenantEditable lists each kind and slug once.",
|
|
12
|
+
fix: "Remove the duplicate entry.",
|
|
13
|
+
},
|
|
14
|
+
tenantEditableInvalidEntry: {
|
|
15
|
+
id: "template-resolver/tenant-editable-invalid-entry",
|
|
16
|
+
summary: "Each tenantEditable entry has a non-empty slug and at least one access role.",
|
|
17
|
+
fix: "Give the entry a slug and roles.",
|
|
18
|
+
},
|
|
19
|
+
} as const satisfies BootRuleTable;
|