@cosmicdrift/kumiko-samples 0.410.0 → 0.412.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 +31 -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/changes.json +24 -0
- package/packages/bundled-features/src/auth-email-password/seeding.ts +84 -6
- package/packages/bundled-features/src/auth-email-password/web/i18n.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +48 -3
- package/packages/bundled-features/src/auth-email-password/web/static-account.ts +190 -0
- package/packages/bundled-features/src/auth-email-password/web/static-client.ts +226 -0
- package/packages/bundled-features/src/foundation-shared/demo-admin-env.ts +11 -0
- package/packages/bundled-features/src/foundation-shared/index.ts +5 -1
- 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/inbound-provider-imap/changes.json +6 -0
- package/packages/bundled-features/src/inbound-provider-imap/imap-client.ts +3 -1
- 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 +28 -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/changes.json +8 -0
- package/packages/bundled-features/src/presence/feature.ts +25 -0
- package/packages/bundled-features/src/presence/handlers/heartbeat.write.ts +52 -0
- package/packages/bundled-features/src/presence/handlers/leave.write.ts +41 -0
- package/packages/bundled-features/src/presence/handlers/list.query.ts +39 -0
- package/packages/bundled-features/src/presence/index.ts +7 -0
- package/packages/bundled-features/src/presence/options.ts +30 -0
- package/packages/bundled-features/src/presence/payloads.ts +26 -0
- package/packages/bundled-features/src/presence/room.ts +65 -0
- package/packages/bundled-features/src/presence/store.ts +185 -0
- package/packages/bundled-features/src/sessions/feature.ts +6 -2
- package/packages/bundled-features/src/sessions/handlers/last-activity-probe.route.ts +19 -0
- package/packages/bundled-features/src/tenant-inactivity/changes.json +12 -0
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +14 -6
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +4 -1
- package/packages/bundled-features/src/tenant-inactivity/handlers/inactivity-state.query.ts +2 -1
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +2 -1
- package/packages/bundled-features/src/tenant-inactivity/options.ts +1 -0
- package/packages/bundled-features/src/tenant-inactivity/remote-activity.ts +6 -1
- package/packages/bundled-features/src/tenant-inactivity/static-keep-account.ts +37 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +2 -0
- package/packages/bundled-features/src/tenant-lifecycle/handlers/cancel-destruction.write.ts +6 -2
- package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +2 -1
- package/packages/bundled-features/src/tenant-lifecycle/index.ts +1 -0
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/static-submit.ts +56 -0
- package/samples/apps/styleguide/src/features/widgets/i18n.ts +143 -0
- package/samples/apps/styleguide/src/features/widgets/web/VariantsDemo.tsx +276 -0
- package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +3 -0
- package/samples/apps/styleguide/src/features/workboard/feature.ts +1 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +23 -1
- package/samples/apps/use-all-bundled/src/run-config.ts +3 -0
- 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/realtime-sse/README.md +1 -0
- package/samples/recipes/realtime-sse/package.json +1 -0
- package/samples/recipes/realtime-sse/src/feature.ts +9 -0
- package/samples/recipes/record-detail-layout/README.md +1 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +10 -0
- package/samples/recipes/wizard-form/README.md +9 -0
- package/samples/recipes/wizard-form/src/feature.ts +13 -2
|
@@ -7,6 +7,25 @@ import {
|
|
|
7
7
|
// The route is reachable anonymously, so a short secret would be guessable within the rate limit.
|
|
8
8
|
const MIN_PROBE_SECRET_LENGTH = 32;
|
|
9
9
|
|
|
10
|
+
export const LAST_ACTIVITY_PROBE_SECRET_ENV = "SESSIONS_LAST_ACTIVITY_PROBE_SECRET";
|
|
11
|
+
|
|
12
|
+
// Env is the fallback for apps that mount sessions without options; the value is never echoed.
|
|
13
|
+
// The feature definition also runs in client bundles, where `process` may not exist.
|
|
14
|
+
export function readProbeSecretFromEnv(
|
|
15
|
+
env: Readonly<Record<string, string | undefined>> | undefined = typeof process === "undefined"
|
|
16
|
+
? undefined
|
|
17
|
+
: process.env,
|
|
18
|
+
): string | undefined {
|
|
19
|
+
const secret = env?.[LAST_ACTIVITY_PROBE_SECRET_ENV];
|
|
20
|
+
if (secret === undefined) return undefined;
|
|
21
|
+
if (secret.length < MIN_PROBE_SECRET_LENGTH) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`sessions: ${LAST_ACTIVITY_PROBE_SECRET_ENV} must be at least ${MIN_PROBE_SECRET_LENGTH} characters`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return secret;
|
|
27
|
+
}
|
|
28
|
+
|
|
10
29
|
export function registerLastActivityProbe(r: FeatureRegistrar, secret: string): void {
|
|
11
30
|
if (secret.length < MIN_PROBE_SECRET_LENGTH) {
|
|
12
31
|
throw new Error(
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.411.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "Warning mails reach Admins, activity sources get the tenant db, sessions probe secret from env",
|
|
6
|
+
"detail": "The inactivity warning mail goes to every member with the `TenantOwner`, `TenantAdmin` or `Admin` role (`TENANT_KEEP_ACCOUNT_ROLES`, also the roles of the keep-account and state handlers), once per user. An activity source that reports a time in the future is capped at the current time. `TenantActivitySource` now receives `{ tenantId, now, db }` with `db: TenantDb`, so a source can read the tenant's own data; existing sources that ignore the extra field keep working. The sessions feature falls back to the `SESSIONS_LAST_ACTIVITY_PROBE_SECRET` environment variable when `lastActivityProbeSecret` is not set, so apps that mount sessions without options can serve the last-activity probe. A value shorter than 32 characters fails the boot with a message that names the variable but not its value; an unset variable keeps the probe off. Client code can import the handler names from `@cosmicdrift/kumiko-bundled-features/tenant-inactivity/constants` (`TenantInactivityHandlers`, `TenantInactivityJobs`) without pulling the server barrel (ioredis, `tls`) into the browser bundle."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.411.0",
|
|
10
|
+
"type": "improvement",
|
|
11
|
+
"title": "tenant-inactivity/static-keep-account, a DOM-free keep-account client",
|
|
12
|
+
"detail": "`@cosmicdrift/kumiko-bundled-features/tenant-inactivity/static-keep-account` exports `keepAccount(token)`, which posts `tenant-inactivity:write:keep-account`, and `takeKeepAccountToken()`, which reads the `#token=` fragment of the mail link and removes it from the address bar. Results use the same `kind: \"success\" | \"failure\"` union as the other static clients; an expired or replaced link is a failure."
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"version": "0.407.0",
|
|
4
16
|
"type": "improvement",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
1
|
+
import { fetchOne, type TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import type { JobContext, TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { hasMailTranslations, mailT } from "@cosmicdrift/kumiko-framework/i18n";
|
|
4
4
|
import { parseRoles } from "@cosmicdrift/kumiko-framework/utils";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../tenant/index.ts";
|
|
12
12
|
import { requestTenantDestruction } from "../tenant-lifecycle/index.ts";
|
|
13
13
|
import { userTable } from "../user/index.ts";
|
|
14
|
-
import {
|
|
14
|
+
import { TENANT_KEEP_ACCOUNT_ROLES } from "./constants.ts";
|
|
15
15
|
import { formatInactivityMailDate } from "./email-templates.ts";
|
|
16
16
|
import {
|
|
17
17
|
activityBase,
|
|
@@ -67,11 +67,15 @@ async function newestExternalActivity(
|
|
|
67
67
|
options: TenantInactivityOptions,
|
|
68
68
|
tenantId: TenantId,
|
|
69
69
|
now: Temporal.Instant,
|
|
70
|
+
db: TenantDb,
|
|
70
71
|
): Promise<Temporal.Instant | null> {
|
|
71
72
|
const found = await Promise.all(
|
|
72
|
-
(options.activitySources ?? []).map((source) => source({ tenantId, now })),
|
|
73
|
+
(options.activitySources ?? []).map((source) => source({ tenantId, now, db })),
|
|
74
|
+
);
|
|
75
|
+
// A source reporting the future would postpone the deletion indefinitely.
|
|
76
|
+
return latestOf(
|
|
77
|
+
found.map((at) => (at !== null && Temporal.Instant.compare(at, now) > 0 ? now : at)),
|
|
73
78
|
);
|
|
74
|
-
return latestOf(found);
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
function isNewerThanBase(
|
|
@@ -89,8 +93,12 @@ async function loadOwners(ctx: JobContext): Promise<readonly OwnerRecipient[]> {
|
|
|
89
93
|
{},
|
|
90
94
|
);
|
|
91
95
|
const owners: OwnerRecipient[] = [];
|
|
96
|
+
const seen = new Set<string>();
|
|
92
97
|
for (const membership of memberships) {
|
|
93
|
-
if (
|
|
98
|
+
if (seen.has(membership.userId)) continue;
|
|
99
|
+
const roles = parseRoles(membership.roles);
|
|
100
|
+
if (!TENANT_KEEP_ACCOUNT_ROLES.some((role) => roles.includes(role))) continue;
|
|
101
|
+
seen.add(membership.userId);
|
|
94
102
|
const user = await ctx.db
|
|
95
103
|
.global(userTable)
|
|
96
104
|
.fetchOne<{ locale: string | null }>({ id: membership.userId });
|
|
@@ -187,7 +195,7 @@ async function evaluate(
|
|
|
187
195
|
if (decision.kind === "none") return state;
|
|
188
196
|
|
|
189
197
|
// Steps with consequences ask other apps first: activity there counts too.
|
|
190
|
-
const external = await newestExternalActivity(options, tenantId, now);
|
|
198
|
+
const external = await newestExternalActivity(options, tenantId, now, ctx.db);
|
|
191
199
|
if (isNewerThanBase(external, state)) {
|
|
192
200
|
return startNewCycle({ ...state, lastActivityAt: external });
|
|
193
201
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export const TENANT_INACTIVITY_FEATURE = "tenant-inactivity";
|
|
2
2
|
export const TENANT_INACTIVITY_STATE_ENTITY = "tenant-inactivity-state";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// Everyone who may react to the warning: the account-close roles plus TenantAdmin, so the mail
|
|
5
|
+
// reaches exactly the people who can open the keep-account link and read the state.
|
|
6
|
+
export const TENANT_KEEP_ACCOUNT_ROLES = ["TenantOwner", "TenantAdmin", "Admin"] as const;
|
|
4
7
|
|
|
5
8
|
export const TenantInactivityJobs = {
|
|
6
9
|
check: `${TENANT_INACTIVITY_FEATURE}:job:check-inactive-tenants`,
|
|
@@ -2,6 +2,7 @@ import { createTenantDb, type TenantDb } from "@cosmicdrift/kumiko-framework/db"
|
|
|
2
2
|
import { defineQueryHandler, parseTenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { AccessDeniedError, UnprocessableError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
+
import { TENANT_KEEP_ACCOUNT_ROLES } from "../constants.ts";
|
|
5
6
|
import { describeOutlook, foldActivity } from "../inactivity-plan.ts";
|
|
6
7
|
import { resolveInactivityRule, type TenantInactivityOptions } from "../options.ts";
|
|
7
8
|
import { loadInactivityState, loadNewestSessionActivity } from "../state-store.ts";
|
|
@@ -17,7 +18,7 @@ export function createInactivityStateQuery<TTier extends string>(
|
|
|
17
18
|
return defineQueryHandler({
|
|
18
19
|
name: "state",
|
|
19
20
|
schema: z.object({ tenantIdOverride: z.string().min(1).max(36).optional() }),
|
|
20
|
-
access: { roles: [
|
|
21
|
+
access: { roles: [...TENANT_KEEP_ACCOUNT_ROLES, "SystemAdmin"] },
|
|
21
22
|
escapeHatch: { grants: ["unsafeRaw"], reason: STATE_QUERY_ESCAPE_HATCH_REASON },
|
|
22
23
|
description:
|
|
23
24
|
"Returns whether the tenant is exempt from inactivity deletion, its last activity, the warnings already sent and the next step with its date; owners and admins see their own tenant, a SystemAdmin any tenant.",
|
|
@@ -2,6 +2,7 @@ import { fetchOne, updateMany } from "@cosmicdrift/kumiko-framework/db";
|
|
|
2
2
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
+
import { TENANT_KEEP_ACCOUNT_ROLES } from "../constants.ts";
|
|
5
6
|
import { redeemKeepAccountToken } from "../keep-token.ts";
|
|
6
7
|
import { tenantInactivityStateTable } from "../state-table.ts";
|
|
7
8
|
|
|
@@ -13,7 +14,7 @@ export function createKeepAccountHandler(opts: { readonly keepAccountTokenSecret
|
|
|
13
14
|
name: "keep-account",
|
|
14
15
|
schema: z.object({ token: z.string().min(1) }),
|
|
15
16
|
access: {
|
|
16
|
-
roles: ["anonymous", "Member", "User",
|
|
17
|
+
roles: ["anonymous", "Member", "User", ...TENANT_KEEP_ACCOUNT_ROLES, "SystemAdmin"],
|
|
17
18
|
anySignedIn: true,
|
|
18
19
|
},
|
|
19
20
|
escapeHatch: { grants: ["unsafeRaw"], reason: KEEP_ACCOUNT_ESCAPE_HATCH_REASON },
|
|
@@ -7,6 +7,7 @@ import type { InactivityRule } from "./inactivity-plan.ts";
|
|
|
7
7
|
export type TenantActivitySource = (args: {
|
|
8
8
|
readonly tenantId: TenantId;
|
|
9
9
|
readonly now: Temporal.Instant;
|
|
10
|
+
readonly db: TenantDb;
|
|
10
11
|
}) => Promise<Temporal.Instant | null>;
|
|
11
12
|
|
|
12
13
|
type SharedOptions = {
|
|
@@ -4,12 +4,15 @@ import * as z from "zod";
|
|
|
4
4
|
|
|
5
5
|
const probeResponseSchema = z.object({ lastActivityAt: z.string().nullable() });
|
|
6
6
|
|
|
7
|
+
// A sleeping app (scale-to-zero) needs 23-24 s to wake and up to 45 s on its first start.
|
|
8
|
+
export const REMOTE_ACTIVITY_TIMEOUT_MS = 60_000;
|
|
9
|
+
|
|
7
10
|
type SendRequest = (url: string, init: RequestInit) => Promise<Response>;
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Asks a sibling app for its newest session activity (the sessions `lastActivityProbeSecret`
|
|
11
14
|
* route). Use it inside a `TenantActivitySource` so a user active in the other app keeps the
|
|
12
|
-
* account alive. Fails closed: any error throws, and the job then sends no mail and files no
|
|
15
|
+
* account alive. Fails closed: any error or timeout throws, and the job then sends no mail and files no
|
|
13
16
|
* deletion request for that run. `send` exists for tests; production uses the internal egress
|
|
14
17
|
* pinned to the origin of `url`.
|
|
15
18
|
*/
|
|
@@ -17,12 +20,14 @@ export async function fetchRemoteAppLastActivity(args: {
|
|
|
17
20
|
readonly url: string;
|
|
18
21
|
readonly secret: string;
|
|
19
22
|
readonly send?: SendRequest;
|
|
23
|
+
readonly timeoutMs?: number;
|
|
20
24
|
}): Promise<Temporal.Instant | null> {
|
|
21
25
|
// Sibling apps sit in the same cluster on private addresses, which the external policy blocks.
|
|
22
26
|
const send = args.send ?? egress({ kind: "internal", allowOrigins: [new URL(args.url).origin] });
|
|
23
27
|
const response = await send(args.url, {
|
|
24
28
|
method: "GET",
|
|
25
29
|
headers: { authorization: `Bearer ${args.secret}` },
|
|
30
|
+
signal: AbortSignal.timeout(args.timeoutMs ?? REMOTE_ACTIVITY_TIMEOUT_MS),
|
|
26
31
|
});
|
|
27
32
|
if (!response.ok) {
|
|
28
33
|
throw new Error(`remote activity probe answered ${response.status}`);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// DOM-free "keep my account" page for static sites: fetch plus pure logic only.
|
|
2
|
+
// The link in the warning mail carries the token in the URL fragment (`#token=`), which browsers
|
|
3
|
+
// never send to a server or in a Referer.
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
dispatchWrite,
|
|
7
|
+
type StaticRequestOptions,
|
|
8
|
+
type StaticResult,
|
|
9
|
+
staticSuccess,
|
|
10
|
+
takeUrlToken,
|
|
11
|
+
} from "@cosmicdrift/kumiko-bundled-features/auth-email-password/static-client";
|
|
12
|
+
import { TenantInactivityHandlers } from "./constants.ts";
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
hrefWithoutUrlToken,
|
|
16
|
+
readUrlToken,
|
|
17
|
+
STATIC_NETWORK_REASON,
|
|
18
|
+
STATIC_RATE_LIMITED_REASON,
|
|
19
|
+
type StaticFailure,
|
|
20
|
+
type StaticRequestOptions,
|
|
21
|
+
type StaticResult,
|
|
22
|
+
type StaticSuccess,
|
|
23
|
+
} from "@cosmicdrift/kumiko-bundled-features/auth-email-password/static-client";
|
|
24
|
+
|
|
25
|
+
/** Reads `#token=` from the current page and removes it from the address bar. Browser only. */
|
|
26
|
+
export function takeKeepAccountToken(): string {
|
|
27
|
+
return takeUrlToken("fragment");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A used, replaced or expired link fails with reason `invalid_or_expired_token`. */
|
|
31
|
+
export async function keepAccount(
|
|
32
|
+
token: string,
|
|
33
|
+
options?: StaticRequestOptions,
|
|
34
|
+
): Promise<StaticResult<undefined>> {
|
|
35
|
+
const result = await dispatchWrite(TenantInactivityHandlers.keepAccount, { token }, options);
|
|
36
|
+
return result.kind === "success" ? staticSuccess(undefined) : result;
|
|
37
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const TENANT_LIFECYCLE_FEATURE = "tenant-lifecycle" as const;
|
|
2
2
|
|
|
3
|
+
export const TENANT_ACCOUNT_CLOSE_ROLES = ["TenantOwner", "Admin"] as const;
|
|
4
|
+
|
|
3
5
|
export const TENANT_AGGREGATE_TYPE = "tenant" as const;
|
|
4
6
|
|
|
5
7
|
const EVENT_PREFIX = `${TENANT_LIFECYCLE_FEATURE}:event:` as const;
|
|
@@ -5,7 +5,11 @@ import { appendDomainEventCore } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { isWithinGracePeriod } from "../../shared/index.ts";
|
|
7
7
|
import { type TenantLifecycleStatus, tenantEntity, tenantTable } from "../../tenant/index.ts";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
DESTRUCTION_CANCELLED_EVENT_QN,
|
|
10
|
+
TENANT_ACCOUNT_CLOSE_ROLES,
|
|
11
|
+
TENANT_LIFECYCLE_FEATURE,
|
|
12
|
+
} from "../constants.ts";
|
|
9
13
|
import { invalidateTenantLifecycleGate } from "../lifecycle-gate.ts";
|
|
10
14
|
|
|
11
15
|
const crud = createEventStoreExecutor(tenantTable, tenantEntity, { entityName: "tenant" });
|
|
@@ -21,7 +25,7 @@ const CANCEL_DESTRUCTION_TENANT_ROW_REASON =
|
|
|
21
25
|
export const cancelDestructionWrite = defineWriteHandler({
|
|
22
26
|
name: "cancel-destruction",
|
|
23
27
|
schema: z.object({}),
|
|
24
|
-
access: { roles:
|
|
28
|
+
access: { roles: TENANT_ACCOUNT_CLOSE_ROLES },
|
|
25
29
|
description:
|
|
26
30
|
"Returns a tenant whose destruction was requested back to active and clears the grace period; use it to undo a close-account request while the grace period is still running.",
|
|
27
31
|
escapeHatch: {
|
package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
+
import { TENANT_ACCOUNT_CLOSE_ROLES } from "../constants.ts";
|
|
3
4
|
import { requestTenantDestruction } from "../request-tenant-destruction.ts";
|
|
4
5
|
|
|
5
6
|
const REQUEST_DESTRUCTION_TENANT_ROW_REASON =
|
|
@@ -8,7 +9,7 @@ const REQUEST_DESTRUCTION_TENANT_ROW_REASON =
|
|
|
8
9
|
export const requestDestructionWrite = defineWriteHandler({
|
|
9
10
|
name: "request-destruction",
|
|
10
11
|
schema: z.object({}),
|
|
11
|
-
access: { roles:
|
|
12
|
+
access: { roles: TENANT_ACCOUNT_CLOSE_ROLES },
|
|
12
13
|
description:
|
|
13
14
|
"Puts the caller's own tenant into destroyRequested, starts the compliance-profile grace period after which its data is erased, and revokes every session in the tenant; use it when an account owner asks to close their account.",
|
|
14
15
|
agent: { risk: "high" },
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.411.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "waitlist/static-submit, a DOM-free waitlist sign-up client",
|
|
6
|
+
"detail": "`@cosmicdrift/kumiko-bundled-features/waitlist/static-submit` exports `submitToWaitlist(submission)` for plain Astro scripts: fetch plus pure logic, no renderer, React or `window` at import time. It posts `waitlist:write:submit` same-origin with name, email, optional company, portfolio and message, the page locale (also sent as `X-Locale`) and the honeypot field `website`. Blank optional fields are dropped. The result is a discriminated union `{ kind: \"success\"; data } | { kind: \"failure\"; reason; message?; retryAfterSeconds? }`; a network error is the reason `network`, a 429 is `rate_limited`."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.410.0",
|
|
4
10
|
"type": "fix",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// DOM-free waitlist sign-up for static sites: fetch plus pure logic only.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
dispatchWrite,
|
|
5
|
+
type StaticResult,
|
|
6
|
+
staticSuccess,
|
|
7
|
+
} from "@cosmicdrift/kumiko-bundled-features/auth-email-password/static-client";
|
|
8
|
+
import { WaitlistHandlers } from "./web/constants.ts";
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
STATIC_NETWORK_REASON,
|
|
12
|
+
STATIC_RATE_LIMITED_REASON,
|
|
13
|
+
type StaticFailure,
|
|
14
|
+
type StaticResult,
|
|
15
|
+
type StaticSuccess,
|
|
16
|
+
} from "@cosmicdrift/kumiko-bundled-features/auth-email-password/static-client";
|
|
17
|
+
|
|
18
|
+
export type WaitlistSubmission = {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly email: string;
|
|
21
|
+
readonly company?: string;
|
|
22
|
+
readonly portfolio?: string;
|
|
23
|
+
readonly message?: string;
|
|
24
|
+
/** BCP 47 tag of the page language; also picks the language of the confirmation mail. */
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
/** Honeypot: render it as a hidden field named `website` and pass its value through unchanged. */
|
|
27
|
+
readonly website?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function nonBlank(value: string | undefined): string | undefined {
|
|
31
|
+
return value === undefined || value.trim() === "" ? undefined : value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Success reads the same for a new and an already listed address. */
|
|
35
|
+
export async function submitToWaitlist(
|
|
36
|
+
submission: WaitlistSubmission,
|
|
37
|
+
): Promise<StaticResult<undefined>> {
|
|
38
|
+
const { name, email, locale, website } = submission;
|
|
39
|
+
const company = nonBlank(submission.company);
|
|
40
|
+
const portfolio = nonBlank(submission.portfolio);
|
|
41
|
+
const message = nonBlank(submission.message);
|
|
42
|
+
const result = await dispatchWrite(
|
|
43
|
+
WaitlistHandlers.submit,
|
|
44
|
+
{
|
|
45
|
+
name,
|
|
46
|
+
email,
|
|
47
|
+
locale,
|
|
48
|
+
...(company !== undefined && { company }),
|
|
49
|
+
...(portfolio !== undefined && { portfolio }),
|
|
50
|
+
...(message !== undefined && { message }),
|
|
51
|
+
...(website !== undefined && { website }),
|
|
52
|
+
},
|
|
53
|
+
{ locale },
|
|
54
|
+
);
|
|
55
|
+
return result.kind === "success" ? staticSuccess(undefined) : result;
|
|
56
|
+
}
|
|
@@ -275,4 +275,147 @@ export const WIDGETS_I18N = {
|
|
|
275
275
|
"widgets:catalog:plan-contact-sales": { de: "Vertrieb kontaktieren", en: "Contact sales" },
|
|
276
276
|
"widgets:catalog:plan-credits": { de: "Credit-Paket", en: "Credit pack" },
|
|
277
277
|
"widgets:catalog:plan-buy": { de: "Kaufen", en: "Buy" },
|
|
278
|
+
"widgets:catalog:variants-title": { de: "Neue Varianten", en: "New variants" },
|
|
279
|
+
"widgets:catalog:variants-heading-group": { de: "Gruppen-Überschrift", en: "Group heading" },
|
|
280
|
+
"widgets:catalog:variants-heading-section": {
|
|
281
|
+
de: "Abschnitts-Überschrift",
|
|
282
|
+
en: "Section heading",
|
|
283
|
+
},
|
|
284
|
+
"widgets:catalog:variants-detail-normal": {
|
|
285
|
+
de: "Details mit normalen Werten",
|
|
286
|
+
en: "Details with normal-weight values",
|
|
287
|
+
},
|
|
288
|
+
"widgets:catalog:variants-detail-sidebar": {
|
|
289
|
+
de: "Details in der Seitenspalte",
|
|
290
|
+
en: "Details in a side column",
|
|
291
|
+
},
|
|
292
|
+
"widgets:catalog:variants-label-owner": { de: "Inhaber", en: "Owner" },
|
|
293
|
+
"widgets:catalog:variants-value-owner": { de: "Jamie Rivera", en: "Jamie Rivera" },
|
|
294
|
+
"widgets:catalog:variants-label-region": { de: "Region", en: "Region" },
|
|
295
|
+
"widgets:catalog:variants-value-region": { de: "Frankfurt", en: "Frankfurt" },
|
|
296
|
+
"widgets:catalog:variants-label-plan": { de: "Tarif", en: "Plan" },
|
|
297
|
+
"widgets:catalog:variants-value-plan": { de: "Team", en: "Team" },
|
|
298
|
+
"widgets:catalog:variants-composer": { de: "Chat-Eingabe", en: "Chat composer" },
|
|
299
|
+
"widgets:catalog:variants-composer-placeholder": {
|
|
300
|
+
de: "Nachricht schreiben",
|
|
301
|
+
en: "Write a message",
|
|
302
|
+
},
|
|
303
|
+
"widgets:catalog:variants-composer-send": { de: "Senden", en: "Send" },
|
|
304
|
+
"widgets:catalog:variants-textarea-placeholder": {
|
|
305
|
+
de: "Notiz mit Platzhalter",
|
|
306
|
+
en: "Note with placeholder",
|
|
307
|
+
},
|
|
308
|
+
"widgets:catalog:variants-textarea-hint": {
|
|
309
|
+
de: "Beschreibe kurz, was zu tun ist",
|
|
310
|
+
en: "Describe briefly what needs doing",
|
|
311
|
+
},
|
|
312
|
+
"widgets:catalog:variants-mode-switch": {
|
|
313
|
+
de: "Modus mit gesperrter und markierter Option",
|
|
314
|
+
en: "Mode switch with disabled and flagged option",
|
|
315
|
+
},
|
|
316
|
+
"widgets:catalog:variants-mode-a": { de: "Automatisch", en: "Automatic" },
|
|
317
|
+
"widgets:catalog:variants-mode-b": { de: "Manuell", en: "Manual" },
|
|
318
|
+
"widgets:catalog:variants-mode-c": { de: "Offene Fragen", en: "Open questions" },
|
|
319
|
+
"widgets:catalog:variants-mode-d": { de: "Gesperrt", en: "Locked" },
|
|
320
|
+
"widgets:catalog:variants-section-nav": {
|
|
321
|
+
de: "Abschnittsnavigation für eigene Screens",
|
|
322
|
+
en: "Section navigation for custom screens",
|
|
323
|
+
},
|
|
324
|
+
"widgets:catalog:variants-nav-profile": { de: "Profil", en: "Profile" },
|
|
325
|
+
"widgets:catalog:variants-nav-billing": { de: "Abrechnung", en: "Billing" },
|
|
326
|
+
"widgets:catalog:variants-nav-security": { de: "Sicherheit", en: "Security" },
|
|
327
|
+
"widgets:catalog:variants-nav-body": {
|
|
328
|
+
de: "Die Liste rechts springt zum Abschnitt und folgt dem Scrollen.",
|
|
329
|
+
en: "The list on the right jumps to the section and follows the scroll position.",
|
|
330
|
+
},
|
|
331
|
+
"widgets:catalog:variants-banner": {
|
|
332
|
+
de: "Hinweis mit Symbol und Hervorhebung",
|
|
333
|
+
en: "Banner with icon and emphasis",
|
|
334
|
+
},
|
|
335
|
+
"widgets:catalog:variants-banner-lead": {
|
|
336
|
+
de: "Vor dem Löschen bitte ",
|
|
337
|
+
en: "Before deleting, please ",
|
|
338
|
+
},
|
|
339
|
+
"widgets:catalog:variants-banner-strong": { de: "ein Backup anlegen", en: "create a backup" },
|
|
340
|
+
"widgets:catalog:variants-banner-tail": {
|
|
341
|
+
de: ". Das Löschen ist endgültig.",
|
|
342
|
+
en: ". Deleting is permanent.",
|
|
343
|
+
},
|
|
344
|
+
"widgets:catalog:variants-round2-title": {
|
|
345
|
+
de: "Studio-Varianten, zweite Runde",
|
|
346
|
+
en: "Studio variants, round two",
|
|
347
|
+
},
|
|
348
|
+
"widgets:catalog:variants-choice": {
|
|
349
|
+
de: "Auswahlkarten, drei Spalten, Radio",
|
|
350
|
+
en: "Choice cards, three columns, radio",
|
|
351
|
+
},
|
|
352
|
+
"widgets:catalog:variants-choice-label": { de: "Womit beginnen?", en: "Where to start?" },
|
|
353
|
+
"widgets:catalog:variants-choice-empty": { de: "Leer beginnen", en: "Start empty" },
|
|
354
|
+
"widgets:catalog:variants-choice-empty-desc": {
|
|
355
|
+
de: "Nur Anmeldung und Benutzer",
|
|
356
|
+
en: "Sign-in and users only",
|
|
357
|
+
},
|
|
358
|
+
"widgets:catalog:variants-choice-service": {
|
|
359
|
+
de: "Wartung und Prüfung",
|
|
360
|
+
en: "Service and checks",
|
|
361
|
+
},
|
|
362
|
+
"widgets:catalog:variants-choice-service-desc": {
|
|
363
|
+
de: "Vorlage: Anlagen, Intervalle, Prüfprotokolle",
|
|
364
|
+
en: "Template: assets, intervals, inspection reports",
|
|
365
|
+
},
|
|
366
|
+
"widgets:catalog:variants-choice-guests": { de: "Gästeliste", en: "Guest list" },
|
|
367
|
+
"widgets:catalog:variants-choice-guests-desc": {
|
|
368
|
+
de: "Vorlage: Veranstaltung, Zusage per Link",
|
|
369
|
+
en: "Template: event, RSVP by link",
|
|
370
|
+
},
|
|
371
|
+
"widgets:catalog:variants-mode-wide": {
|
|
372
|
+
de: "Modus mit breiten Segmenten, Warnrahmen um den ganzen Schalter",
|
|
373
|
+
en: "Mode switch with wide segments, warning frame around the whole switch",
|
|
374
|
+
},
|
|
375
|
+
"widgets:catalog:variants-compare": {
|
|
376
|
+
de: "Vergleichstabelle, Zeilenköpfe in Textfarbe",
|
|
377
|
+
en: "Comparison table, row headers in text colour",
|
|
378
|
+
},
|
|
379
|
+
"widgets:catalog:variants-compare-field": { de: "Angabe", en: "Item" },
|
|
380
|
+
"widgets:catalog:variants-compare-left": { de: "Aus dem Dokument", en: "From the document" },
|
|
381
|
+
"widgets:catalog:variants-compare-right": { de: "Im Bestand", en: "In stock" },
|
|
382
|
+
"widgets:catalog:variants-compare-name": { de: "Name", en: "Name" },
|
|
383
|
+
"widgets:catalog:variants-compare-city": { de: "Ort", en: "City" },
|
|
384
|
+
"widgets:catalog:variants-docked": {
|
|
385
|
+
de: "Angedockte Chat-Eingabe",
|
|
386
|
+
en: "Docked chat composer",
|
|
387
|
+
},
|
|
388
|
+
"widgets:catalog:variants-docked-message": {
|
|
389
|
+
de: "Der Verlauf scrollt, die Eingabe bleibt unten sichtbar.",
|
|
390
|
+
en: "The thread scrolls, the composer stays visible at the bottom.",
|
|
391
|
+
},
|
|
392
|
+
"widgets:catalog:variants-banner-below": {
|
|
393
|
+
de: "Hinweis mit Aktion unter dem Text",
|
|
394
|
+
en: "Banner with the action below the text",
|
|
395
|
+
},
|
|
396
|
+
"widgets:catalog:variants-banner-below-title": {
|
|
397
|
+
de: "Veröffentlichen gescheitert",
|
|
398
|
+
en: "Publishing failed",
|
|
399
|
+
},
|
|
400
|
+
"widgets:catalog:variants-banner-below-body": {
|
|
401
|
+
de: "Die Prüfung ist fehlgeschlagen. Bitte erneut versuchen.",
|
|
402
|
+
en: "The check failed. Please try again.",
|
|
403
|
+
},
|
|
404
|
+
"widgets:catalog:variants-banner-below-action": { de: "Erneut versuchen", en: "Try again" },
|
|
405
|
+
"widgets:catalog:variants-rail": {
|
|
406
|
+
de: "Wizard-Leiste: Schritt ohne Untertitel, Hinweis im Kasten",
|
|
407
|
+
en: "Wizard rail: active step without subtitle, hint in the box",
|
|
408
|
+
},
|
|
409
|
+
"widgets:catalog:variants-rail-heading": { de: "Schritt 1 von 2", en: "Step 1 of 2" },
|
|
410
|
+
"widgets:catalog:variants-rail-step-one": { de: "Beschreiben", en: "Describe" },
|
|
411
|
+
"widgets:catalog:variants-rail-step-two": { de: "Steckbrief", en: "Profile" },
|
|
412
|
+
"widgets:catalog:variants-rail-subtitle": {
|
|
413
|
+
de: "Rollen, Funktionen, Personendaten und noch ein langer Zusatz, der umbricht",
|
|
414
|
+
en: "Roles, features, personal data and a long addition that wraps",
|
|
415
|
+
},
|
|
416
|
+
"widgets:catalog:variants-rail-up-next": { de: "Als Nächstes", en: "Up next" },
|
|
417
|
+
"widgets:catalog:variants-rail-hint": {
|
|
418
|
+
de: "Die KI fragt nur nach, was offen ist",
|
|
419
|
+
en: "The AI only asks about what is open",
|
|
420
|
+
},
|
|
278
421
|
} as const;
|