create-ailk 0.36.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/component-catalog.json +40 -1
- package/component-catalog.md +7 -5
- package/dist/add-route.d.ts +5 -0
- package/dist/add-route.js +10 -2
- package/dist/surfaces.js +60 -19
- package/dist/sync-routes.d.ts +15 -1
- package/dist/sync-routes.js +58 -6
- package/dist/template-record.d.ts +11 -0
- package/dist/template-record.js +18 -0
- package/dist/update.d.ts +33 -1
- package/dist/update.js +439 -56
- package/package.json +3 -3
- package/templates/.env.example +17 -0
- package/templates/apps/api/.env.example +38 -0
- package/templates/apps/api/CLAUDE.md +3 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +1 -1
- package/templates/apps/web/CLAUDE.md +28 -1
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +240 -76
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +369 -196
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +19 -3
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +309 -113
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +192 -65
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +55 -58
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +2 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +3 -2
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +18 -21
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +263 -0
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
- package/templates/apps/web/lib/account-config.ts +132 -8
- package/templates/apps/web/lib/auth-routes.ts +11 -6
- package/templates/apps/web/lib/offerings-pricing.ts +4 -1
- package/templates/apps/web/messages/en.json +156 -80
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* artifacts/artifact-data.ts — the Artifacts pages' read and its helpers
|
|
3
3
|
* (#8234, spec docs/specs/8234-member-artifacts-account-artifacts-and-spec.md
|
|
4
|
-
* D2, C6).
|
|
4
|
+
* D2, C6; #11161).
|
|
5
5
|
*
|
|
6
6
|
* The list and the artifact page read the same artifacts, so the read lives
|
|
7
7
|
* here — not in `artifact-actions.ts`, where every export of a
|
|
@@ -15,37 +15,79 @@
|
|
|
15
15
|
* The read serves versions newest first and at least one (8169 D6), so
|
|
16
16
|
* `versions[0]` is the latest version. Items keep the read's order — newest
|
|
17
17
|
* delivery first — and are never re-sorted here.
|
|
18
|
+
*
|
|
19
|
+
* #11161 (operator rulings 2026-11-08): the member's Status is the piece's
|
|
20
|
+
* STAGE — the provider's own pipeline, served per artifact as `stage` with
|
|
21
|
+
* its `stageLabel`, and as the workspace's declared list `stages` with
|
|
22
|
+
* `stageLabels`, in declared order. The version review (approved / changes
|
|
23
|
+
* requested / none) is a tag beside it, never a status of its own. A stage
|
|
24
|
+
* reads for a member by its LABEL — the one the provider set in the Admin's
|
|
25
|
+
* Artifact stages section (point 6), never the slug; the terminal default
|
|
26
|
+
* reads "Delivered" until the provider renames it. A hub older than the
|
|
27
|
+
* labels serves the slug alone, which reads as its default label
|
|
28
|
+
* (`defaultPieceStageLabel`); one older still serves no stage, so its
|
|
29
|
+
* artifacts have no stage facet and the facet group is the four defaults.
|
|
18
30
|
*/
|
|
19
31
|
|
|
20
32
|
import { member } from "@working-theory/api-client";
|
|
21
33
|
import type { AccountContext } from "@working-theory/templates/account";
|
|
22
34
|
import { localeHref } from "@working-theory/ui";
|
|
23
|
-
import
|
|
35
|
+
import {
|
|
36
|
+
defaultPieceStageLabel,
|
|
37
|
+
type MemberArtifact,
|
|
38
|
+
type MemberPieceVersion,
|
|
39
|
+
} from "@working-theory/validation";
|
|
24
40
|
import { cache } from "react";
|
|
25
41
|
|
|
26
42
|
import { unwrapApiResult } from "../../../../../lib/server-api";
|
|
27
43
|
|
|
28
|
-
/**
|
|
44
|
+
/** One declared stage: the slug (the key) and the label a member reads. */
|
|
45
|
+
export interface MemberStage {
|
|
46
|
+
slug: string;
|
|
47
|
+
label: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface MemberArtifacts {
|
|
51
|
+
/** Newest delivery first, the read's order. */
|
|
52
|
+
items: MemberArtifact[];
|
|
53
|
+
/** The workspace's declared stages, in declared order, each with its label. */
|
|
54
|
+
stages: MemberStage[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The four product-default stages, for an older hub that serves no list. */
|
|
58
|
+
const DEFAULT_STAGES = ["requested", "in-progress", "in-review", "delivered"];
|
|
59
|
+
|
|
60
|
+
const stagesOf = (slugs: readonly string[], labels: readonly string[] = []): MemberStage[] =>
|
|
61
|
+
slugs.map((slug, index) => ({ slug, label: labels[index] ?? defaultPieceStageLabel(slug) }));
|
|
62
|
+
|
|
63
|
+
const EMPTY: MemberArtifacts = { items: [], stages: stagesOf(DEFAULT_STAGES) };
|
|
64
|
+
|
|
65
|
+
/** The member's artifacts and the workspace's stages. One read per request. */
|
|
29
66
|
export const loadArtifacts = cache(
|
|
30
|
-
async (ctx: AccountContext): Promise<
|
|
67
|
+
async (ctx: AccountContext): Promise<MemberArtifacts> => {
|
|
31
68
|
const res = await member.artifacts(ctx.init);
|
|
32
69
|
if (!res.ok) {
|
|
33
|
-
if (res.status === 404) return
|
|
34
|
-
if (!ctx.user.emailVerified && (res.status === 401 || res.status === 403))
|
|
35
|
-
return [];
|
|
70
|
+
if (res.status === 404) return EMPTY;
|
|
71
|
+
if (!ctx.user.emailVerified && (res.status === 401 || res.status === 403)) return EMPTY;
|
|
36
72
|
}
|
|
37
|
-
|
|
73
|
+
const body = await unwrapApiResult(Promise.resolve(res));
|
|
74
|
+
return {
|
|
75
|
+
items: body.items,
|
|
76
|
+
stages: body.stages === undefined ? EMPTY.stages : stagesOf(body.stages, body.stageLabels),
|
|
77
|
+
};
|
|
38
78
|
},
|
|
39
79
|
);
|
|
40
80
|
|
|
41
81
|
export type ArtifactState = "approved" | "changes-requested" | "ready";
|
|
42
82
|
|
|
43
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* The `account` catalog key that names each review state as a TAG — none for
|
|
85
|
+
* `ready`, whose artifact carries no review tag (#11161).
|
|
86
|
+
*/
|
|
44
87
|
export const STATE_KEYS = {
|
|
45
88
|
approved: "artifacts.states.approved",
|
|
46
89
|
"changes-requested": "artifacts.states.changesRequested",
|
|
47
|
-
|
|
48
|
-
} as const satisfies Record<ArtifactState, string>;
|
|
90
|
+
} as const satisfies Partial<Record<ArtifactState, string>>;
|
|
49
91
|
|
|
50
92
|
/** The artifact's review state, from its approval and its latest version. */
|
|
51
93
|
export function artifactState(a: MemberArtifact): ArtifactState {
|
|
@@ -55,6 +97,50 @@ export function artifactState(a: MemberArtifact): ArtifactState {
|
|
|
55
97
|
: "ready";
|
|
56
98
|
}
|
|
57
99
|
|
|
100
|
+
/**
|
|
101
|
+
* An artifact's stage as a member reads it (#11161): the label the hub served
|
|
102
|
+
* with it; for a hub older than the labels, the slug's default label; for one
|
|
103
|
+
* that serves no stage, `null`.
|
|
104
|
+
*/
|
|
105
|
+
export function artifactStageLabel(a: MemberArtifact): string | null {
|
|
106
|
+
if (a.stage === undefined) return null;
|
|
107
|
+
return a.stageLabel ?? defaultPieceStageLabel(a.stage);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A facet's glyph by its place in the declared order: first dashed, last a check, the rest a dot. */
|
|
111
|
+
export function stageGlyph(
|
|
112
|
+
index: number,
|
|
113
|
+
count: number,
|
|
114
|
+
): "circle-dashed" | "circle-dot" | "circle-check" {
|
|
115
|
+
if (index === 0) return "circle-dashed";
|
|
116
|
+
if (index === count - 1) return "circle-check";
|
|
117
|
+
return "circle-dot";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The `artifacts.types.*` key naming a version's file type — the Admin's own labels (#11161). */
|
|
121
|
+
const TYPE_KEYS = {
|
|
122
|
+
"application/pdf": "artifacts.types.pdf",
|
|
123
|
+
"image/png": "artifacts.types.png",
|
|
124
|
+
"image/jpeg": "artifacts.types.jpeg",
|
|
125
|
+
"image/gif": "artifacts.types.gif",
|
|
126
|
+
"image/webp": "artifacts.types.webp",
|
|
127
|
+
"image/avif": "artifacts.types.avif",
|
|
128
|
+
} as const;
|
|
129
|
+
type TypeKey =
|
|
130
|
+
| (typeof TYPE_KEYS)[keyof typeof TYPE_KEYS]
|
|
131
|
+
| "artifacts.types.file"
|
|
132
|
+
| "artifacts.types.link";
|
|
133
|
+
|
|
134
|
+
const isNamedType = (contentType: string): contentType is keyof typeof TYPE_KEYS =>
|
|
135
|
+
Object.prototype.hasOwnProperty.call(TYPE_KEYS, contentType);
|
|
136
|
+
|
|
137
|
+
/** The Type cell: the latest version's file type, or Link (#11161). Read as the preview reads it: parameters dropped, case folded. */
|
|
138
|
+
export function versionTypeKey(v: MemberPieceVersion): TypeKey {
|
|
139
|
+
if (v.file === null) return "artifacts.types.link";
|
|
140
|
+
const type = (v.file.contentType.split(";")[0] ?? "").trim().toLowerCase();
|
|
141
|
+
return isNamedType(type) ? TYPE_KEYS[type] : "artifacts.types.file";
|
|
142
|
+
}
|
|
143
|
+
|
|
58
144
|
/**
|
|
59
145
|
* True while the latest version can be reviewed: the artifact is not
|
|
60
146
|
* approved and that version has no review yet (8170 C7 — a reviewed version
|
|
@@ -97,3 +183,15 @@ export function versionFileHref(
|
|
|
97
183
|
): string {
|
|
98
184
|
return `${artifactHref(locale, pieceId)}/versions/${version}/file`;
|
|
99
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The preview route of one version's file (#11161): the same route, asked
|
|
189
|
+
* to answer inline — which it does for an image or a PDF only.
|
|
190
|
+
*/
|
|
191
|
+
export function versionPreviewHref(
|
|
192
|
+
locale: string,
|
|
193
|
+
pieceId: string,
|
|
194
|
+
version: number,
|
|
195
|
+
): string {
|
|
196
|
+
return `${versionFileHref(locale, pieceId, version)}?inline=1`;
|
|
197
|
+
}
|
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
*
|
|
6
6
|
* RSC, inside the account layout's SignedInShell (the rail's Artifacts row,
|
|
7
7
|
* #8231 D1, is selected here). Renders `AccountListFrame` — the Admin Docs
|
|
8
|
-
* page's structure: a second column with an "All
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* page's structure: a second column with an "All Artifacts" count and a
|
|
9
|
+
* Status facet group — the workspace's declared piece stages, every one in
|
|
10
|
+
* declared order and read by its LABEL (#11161; default Requested · In
|
|
11
|
+
* progress · In review · Delivered), each counted over every artifact with
|
|
12
|
+
* zeros kept — and a table of Title · Type · Version · Status in the read's
|
|
13
|
+
* order — newest delivery first. Type is the latest version's file type (the
|
|
14
|
+
* Admin's own labels) or Link; Version its number; Status the piece's stage
|
|
15
|
+
* label as a tag,
|
|
16
|
+
* with the member's review of the latest version (Approved / Changes
|
|
17
|
+
* requested) as a second tag when there is one — stage and review are never
|
|
18
|
+
* combined into one state. The Status column is wide enough for its longest
|
|
19
|
+
* stage label (#8361). Below `md` the column becomes a filter select and the
|
|
20
|
+
* table becomes the phone row list.
|
|
15
21
|
*
|
|
16
22
|
* A 404 read (no tenancy module, or a spoke route the hub does not admit)
|
|
17
23
|
* shows the frame with every count at 0 and the plain empty line; any other
|
|
@@ -28,7 +34,10 @@ import {
|
|
|
28
34
|
AccountListFrame,
|
|
29
35
|
type AccountListFrameRow,
|
|
30
36
|
} from "@working-theory/templates/account";
|
|
31
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
Heading,
|
|
39
|
+
Text,
|
|
40
|
+
} from "@working-theory/ui/primitives";
|
|
32
41
|
import type { MemberArtifact } from "@working-theory/validation";
|
|
33
42
|
import type { Metadata } from "next";
|
|
34
43
|
import { getTranslations } from "next-intl/server";
|
|
@@ -39,26 +48,20 @@ import { ErrorRow } from "../error-row";
|
|
|
39
48
|
|
|
40
49
|
import {
|
|
41
50
|
artifactHref,
|
|
51
|
+
artifactStageLabel,
|
|
42
52
|
artifactState,
|
|
43
53
|
isProposal,
|
|
44
54
|
loadArtifacts,
|
|
55
|
+
stageGlyph,
|
|
45
56
|
STATE_KEYS,
|
|
46
|
-
|
|
57
|
+
versionTypeKey,
|
|
58
|
+
type MemberArtifacts,
|
|
47
59
|
} from "./artifact-data";
|
|
48
60
|
|
|
49
61
|
interface Props {
|
|
50
62
|
params: Promise<{ locale: string }>;
|
|
51
63
|
}
|
|
52
64
|
|
|
53
|
-
const REVIEW_FACETS: Array<{
|
|
54
|
-
state: ArtifactState;
|
|
55
|
-
glyph: "circle-dashed" | "message-square" | "circle-check";
|
|
56
|
-
}> = [
|
|
57
|
-
{ state: "ready", glyph: "circle-dashed" },
|
|
58
|
-
{ state: "changes-requested", glyph: "message-square" },
|
|
59
|
-
{ state: "approved", glyph: "circle-check" },
|
|
60
|
-
];
|
|
61
|
-
|
|
62
65
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
63
66
|
const { locale } = await params;
|
|
64
67
|
const t = await getTranslations({ locale, namespace: "account" });
|
|
@@ -96,7 +99,7 @@ export default async function AccountArtifactsPage({
|
|
|
96
99
|
);
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
let artifacts:
|
|
102
|
+
let artifacts: MemberArtifacts | null;
|
|
100
103
|
try {
|
|
101
104
|
artifacts = await loadArtifacts(session.ctx);
|
|
102
105
|
} catch (err) {
|
|
@@ -117,14 +120,13 @@ export default async function AccountArtifactsPage({
|
|
|
117
120
|
);
|
|
118
121
|
}
|
|
119
122
|
|
|
123
|
+
const { items, stages } = artifacts;
|
|
120
124
|
const row = (artifact: MemberArtifact): AccountListFrameRow => {
|
|
121
125
|
const state = artifactState(artifact);
|
|
122
126
|
const latest = artifact.versions[0]!;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}).format(new Date(latest.deliveredAt));
|
|
127
|
-
const reviewWord = t(STATE_KEYS[state]);
|
|
127
|
+
// An older hub serves no stage: the row sits under All alone.
|
|
128
|
+
const stageWord = artifactStageLabel(artifact);
|
|
129
|
+
const reviewWord = state === "ready" ? null : t(STATE_KEYS[state]);
|
|
128
130
|
const versionWord = t("artifacts.version", { version: latest.version });
|
|
129
131
|
const latestWord = isProposal(artifact)
|
|
130
132
|
? `${t("artifacts.proposal.caption")} · ${versionWord}`
|
|
@@ -133,13 +135,15 @@ export default async function AccountArtifactsPage({
|
|
|
133
135
|
id: artifact.id,
|
|
134
136
|
title: artifact.title,
|
|
135
137
|
href: artifactHref(locale, artifact.id),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
// An older hub serves no stage: the empty facet matches no group row,
|
|
139
|
+
// so the artifact sits under All alone.
|
|
140
|
+
facet: artifact.stage ?? "",
|
|
141
|
+
caption: [latestWord, stageWord, reviewWord].filter(Boolean).join(" · "),
|
|
138
142
|
cells: {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
review: reviewWord,
|
|
143
|
+
type: t(versionTypeKey(latest)),
|
|
144
|
+
version: latestWord,
|
|
142
145
|
},
|
|
146
|
+
tags: { status: [stageWord, reviewWord].filter((word) => word !== null) },
|
|
143
147
|
};
|
|
144
148
|
};
|
|
145
149
|
|
|
@@ -150,26 +154,21 @@ export default async function AccountArtifactsPage({
|
|
|
150
154
|
glyph="layers"
|
|
151
155
|
all={{ label: t("artifacts.all") }}
|
|
152
156
|
group={{
|
|
153
|
-
heading: t("artifacts.
|
|
154
|
-
facets:
|
|
155
|
-
id:
|
|
156
|
-
label:
|
|
157
|
-
glyph,
|
|
157
|
+
heading: t("artifacts.statusGroup"),
|
|
158
|
+
facets: stages.map((stage, index) => ({
|
|
159
|
+
id: stage.slug,
|
|
160
|
+
label: stage.label,
|
|
161
|
+
glyph: stageGlyph(index, stages.length),
|
|
158
162
|
})),
|
|
159
163
|
}}
|
|
160
164
|
columns={[
|
|
161
165
|
{ key: "title", header: t("artifacts.columns.title") },
|
|
162
|
-
{ key: "
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
width: "1/6",
|
|
167
|
-
minWidth: "28",
|
|
168
|
-
},
|
|
169
|
-
// Sized by the frame from the longest state label (#8361).
|
|
170
|
-
{ key: "review", header: t("artifacts.columns.review"), fit: "facets" },
|
|
166
|
+
{ key: "type", header: t("artifacts.columns.type"), width: "1/6", minWidth: "24" },
|
|
167
|
+
{ key: "version", header: t("artifacts.columns.version"), width: "1/6", minWidth: "28" },
|
|
168
|
+
// Sized by the frame from the longest stage label (#8361).
|
|
169
|
+
{ key: "status", header: t("artifacts.columns.status"), fit: "facets", kind: "tags" },
|
|
171
170
|
]}
|
|
172
|
-
rows={
|
|
171
|
+
rows={items.map(row)}
|
|
173
172
|
labels={{
|
|
174
173
|
nav: t("artifacts.facets"),
|
|
175
174
|
table: t("artifacts.title"),
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `billingOfferings` (#11165 AC-2, AC-3) — the shown set's share of User
|
|
3
|
+
* settings › Billing, as a pure function: the base plan (the lowest-priced
|
|
4
|
+
* live plan), the Upgrade target (the next live plan above it by price —
|
|
5
|
+
* Essentials → Growth on a three-plan set), the first live offer, and the
|
|
6
|
+
* no-plan case. Sits beside the module: architecture.yaml bans a relative
|
|
7
|
+
* `../billing/` import from the account tree's own suites.
|
|
8
|
+
*/
|
|
9
|
+
import type { OfferingsProduct, WorkspaceShownSetWire } from "@working-theory/validation";
|
|
10
|
+
|
|
11
|
+
import { billingOfferings } from "../offerings";
|
|
12
|
+
|
|
13
|
+
function plan(slug: string, name: string, amount: number, extra: Partial<OfferingsProduct> = {}): OfferingsProduct {
|
|
14
|
+
return {
|
|
15
|
+
productId: `prod_${slug.replace(/-/g, "")}`,
|
|
16
|
+
plan: slug,
|
|
17
|
+
name,
|
|
18
|
+
description: null,
|
|
19
|
+
marketingFeatures: [],
|
|
20
|
+
unitLabel: null,
|
|
21
|
+
note: null,
|
|
22
|
+
termsNote: null,
|
|
23
|
+
ailkGroup: "plan",
|
|
24
|
+
ailkOrder: null,
|
|
25
|
+
prices: [
|
|
26
|
+
{
|
|
27
|
+
priceId: `price_${slug.replace(/-/g, "")}_monthly`,
|
|
28
|
+
lookupKey: `${slug}_monthly`,
|
|
29
|
+
plan: slug,
|
|
30
|
+
period: "monthly",
|
|
31
|
+
interval: "month",
|
|
32
|
+
amount,
|
|
33
|
+
currency: "usd",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
recommended: false,
|
|
37
|
+
...extra,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const OFFER: OfferingsProduct = {
|
|
42
|
+
...plan("welcome", "Two weeks of Growth, on us", 0),
|
|
43
|
+
productId: "prod_welcome",
|
|
44
|
+
description: "Try the Growth plan for two weeks before you commit.",
|
|
45
|
+
ailkGroup: "offer",
|
|
46
|
+
prices: [
|
|
47
|
+
{ priceId: "price_welcome_once", lookupKey: "welcome_once", plan: "welcome", period: "once", interval: null, amount: 0, currency: "usd" },
|
|
48
|
+
],
|
|
49
|
+
image: "https://files.stripe.com/links/offer.png",
|
|
50
|
+
promotionCode: "WELCOME20",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Growth listed before Essentials, so the order under test is the price's, not the snapshot's. */
|
|
54
|
+
function threePlans(offerings: OfferingsProduct[] = [plan("growth", "Growth", 2_500_000), plan("essentials", "Essentials", 1_250_000), plan("scale", "Scale", 5_000_000)]): WorkspaceShownSetWire {
|
|
55
|
+
return {
|
|
56
|
+
productIds: offerings.map((o) => o.productId),
|
|
57
|
+
recommended: { plan: null, addon: null },
|
|
58
|
+
offerings,
|
|
59
|
+
state: "current",
|
|
60
|
+
snapshotAt: "2026-11-08T00:00:00.000Z",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
describe("billingOfferings — the shown set's share (#11165 AC-2, AC-3)", () => {
|
|
66
|
+
it("pins Essentials → Growth on the three-plan set, by price and not by the snapshot's order, and the first offer", () => {
|
|
67
|
+
const out = billingOfferings(threePlans([OFFER, plan("growth", "Growth", 2_500_000), plan("essentials", "Essentials", 1_250_000), plan("scale", "Scale", 5_000_000)]));
|
|
68
|
+
expect(out.base).toMatchObject({ name: "Essentials", price: { amountMinor: 1_250_000, currency: "usd", interval: "month" }, checkoutHref: "/api/offerings/checkout/essentials_monthly" });
|
|
69
|
+
expect(out.next).toMatchObject({ name: "Growth", checkoutHref: "/api/offerings/checkout/growth_monthly" });
|
|
70
|
+
expect(out.offer).toEqual({
|
|
71
|
+
productId: "prod_welcome",
|
|
72
|
+
name: "Two weeks of Growth, on us",
|
|
73
|
+
description: "Try the Growth plan for two weeks before you commit.",
|
|
74
|
+
image: "https://files.stripe.com/links/offer.png",
|
|
75
|
+
claimHref: "/api/offerings/checkout/welcome_once?promo=WELCOME20",
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("the no-plan case: a set of add-ons and offers only, an expired set, or an unparsable body contributes nothing", () => {
|
|
80
|
+
const empty = { base: null, next: null, offer: null };
|
|
81
|
+
expect(billingOfferings(threePlans([{ ...plan("seo", "SEO audit", 1000), ailkGroup: "addon" }]))).toEqual(empty);
|
|
82
|
+
expect(billingOfferings({ ...threePlans(), state: "expired", offerings: [] })).toEqual(empty);
|
|
83
|
+
expect(billingOfferings({ nonsense: true })).toEqual(empty);
|
|
84
|
+
expect(billingOfferings(threePlans([OFFER])).base).toBeNull();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("one plan has a base and no next; an offer with no promotion code or image links its checkout bare", () => {
|
|
88
|
+
const out = billingOfferings(threePlans([plan("essentials", "Essentials", 1_250_000), { ...OFFER, promotionCode: undefined, image: undefined }]));
|
|
89
|
+
expect(out.base?.name).toBe("Essentials");
|
|
90
|
+
expect(out.next).toBeNull();
|
|
91
|
+
expect(out.offer).toMatchObject({ claimHref: "/api/offerings/checkout/welcome_once", image: null });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("strips format characters from Stripe text and turns a description's line breaks into spaces", () => {
|
|
95
|
+
const out = billingOfferings(threePlans([plan("essentials", "Essentials", 1_250_000, { description: "Two sites,\none seat." })]));
|
|
96
|
+
expect(out.base?.name).toBe("Essentials");
|
|
97
|
+
expect(out.base?.description).toBe("Two sites, one seat.");
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* account/billing/offerings.ts — what the shown set contributes to User
|
|
3
|
+
* settings › Billing (#11165 rulings A and B2): the base plan a member
|
|
4
|
+
* without a subscription starts on, the plan Upgrade goes to, and the offer
|
|
5
|
+
* card.
|
|
6
|
+
*
|
|
7
|
+
* One pure function over the Offerings shown set (`GET /v1/content/shown-offerings`,
|
|
8
|
+
* #8924 — the read `/pricing` renders from, parsed by the same schema):
|
|
9
|
+
*
|
|
10
|
+
* - `base` — the shown set's lowest-priced LIVE plan: every `plan` Product
|
|
11
|
+
* of a `current` set, ordered by its card price (its first shown Price —
|
|
12
|
+
* monthly before yearly before one-time, the order the snapshot keeps).
|
|
13
|
+
* A set with no live plan has none, and the page renders no plan card.
|
|
14
|
+
* - `next` — the plan Upgrade goes to: the next live plan above the base
|
|
15
|
+
* by price. Stripe has no upgrade relation and neither does our model,
|
|
16
|
+
* so next-by-price is the rule (operator, 2026-11-08). None with one plan.
|
|
17
|
+
* - `offer` — the first live `offer` Product (#11166): its name, description,
|
|
18
|
+
* first image and the Claim offer target — the Offerings checkout for its
|
|
19
|
+
* first Price (`offeringsCheckoutHref`, T3) with the product's promotion
|
|
20
|
+
* code carried as `?promo=` when it has one. Applying that code at Checkout
|
|
21
|
+
* is the buy route's and the checkout API's — neither reads it yet, so the
|
|
22
|
+
* link reaches Checkout at the Price's own amount (a follow-up named on
|
|
23
|
+
* #11165).
|
|
24
|
+
*
|
|
25
|
+
* Stripe text crosses into markup here, so contract 8879 T2 binds it: every
|
|
26
|
+
* string is emitted as plain text, format characters removed.
|
|
27
|
+
*/
|
|
28
|
+
import {
|
|
29
|
+
workspaceShownSetWireSchema,
|
|
30
|
+
type MemberBillingPlan,
|
|
31
|
+
type OfferingsPrice,
|
|
32
|
+
type OfferingsProduct,
|
|
33
|
+
} from "@working-theory/validation";
|
|
34
|
+
|
|
35
|
+
import { offeringsCheckoutHref } from "../../../../../lib/offerings-pricing";
|
|
36
|
+
|
|
37
|
+
export interface BillingPlanView {
|
|
38
|
+
productId: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
/** The card price, in the hub read's own shape so one label serves both. */
|
|
42
|
+
price: NonNullable<MemberBillingPlan["price"]>;
|
|
43
|
+
/** The Offerings checkout for the plan's card price, or `null` when its key is outside the grammar. */
|
|
44
|
+
checkoutHref: string | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface BillingOfferView {
|
|
48
|
+
productId: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string | null;
|
|
51
|
+
image: string | null;
|
|
52
|
+
/** The Offerings checkout for the offer's first Price, or `null` when its key is outside the grammar. */
|
|
53
|
+
claimHref: string | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface BillingOfferings {
|
|
57
|
+
base: BillingPlanView | null;
|
|
58
|
+
next: BillingPlanView | null;
|
|
59
|
+
offer: BillingOfferView | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const NO_BILLING_OFFERINGS: BillingOfferings = { base: null, next: null, offer: null };
|
|
63
|
+
|
|
64
|
+
// Cc, Cf, Zl, Zp and Cs — the T1 classes, the last guard before markup.
|
|
65
|
+
const FORMAT_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/gu;
|
|
66
|
+
|
|
67
|
+
function plain(text: string | null): string | null {
|
|
68
|
+
if (text === null) return null;
|
|
69
|
+
const stripped = text.replace(FORMAT_CHARACTERS, (ch) => (ch === "\n" ? " " : "")).trim();
|
|
70
|
+
return stripped.length > 0 ? stripped : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The Price a plan's card shows: its first shown Price, in the snapshot's period order. */
|
|
74
|
+
function cardPrice(product: OfferingsProduct): OfferingsPrice | undefined {
|
|
75
|
+
return product.prices[0];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function planView(product: OfferingsProduct, price: OfferingsPrice): BillingPlanView {
|
|
79
|
+
return {
|
|
80
|
+
productId: product.productId,
|
|
81
|
+
name: plain(product.name) ?? product.productId,
|
|
82
|
+
description: plain(product.description),
|
|
83
|
+
price: { amountMinor: price.amount, currency: price.currency, interval: price.interval },
|
|
84
|
+
checkoutHref: offeringsCheckoutHref(price.lookupKey),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The Claim offer target: the checkout for the offer's price, carrying its promotion code. */
|
|
89
|
+
function claimHrefOf(product: OfferingsProduct): string | null {
|
|
90
|
+
const price = cardPrice(product);
|
|
91
|
+
const href = price === undefined ? null : offeringsCheckoutHref(price.lookupKey);
|
|
92
|
+
if (href === null) return null;
|
|
93
|
+
return product.promotionCode === undefined ? href : `${href}?promo=${encodeURIComponent(product.promotionCode)}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The Billing page's share of a shown set; anything but a current, parsable set contributes nothing. */
|
|
97
|
+
export function billingOfferings(shownSet: unknown): BillingOfferings {
|
|
98
|
+
const parsed = workspaceShownSetWireSchema.safeParse(shownSet);
|
|
99
|
+
if (!parsed.success || parsed.data.state !== "current") return NO_BILLING_OFFERINGS;
|
|
100
|
+
|
|
101
|
+
const plans = parsed.data.offerings
|
|
102
|
+
.filter((product) => product.ailkGroup === "plan")
|
|
103
|
+
.map((product) => ({ product, price: cardPrice(product) }))
|
|
104
|
+
.filter((entry): entry is { product: OfferingsProduct; price: OfferingsPrice } => entry.price !== undefined)
|
|
105
|
+
// A stable sort, so two plans at one price keep the snapshot's order.
|
|
106
|
+
.sort((a, b) => a.price.amount - b.price.amount);
|
|
107
|
+
const base = plans[0] === undefined ? null : planView(plans[0].product, plans[0].price);
|
|
108
|
+
const next = plans[1] === undefined ? null : planView(plans[1].product, plans[1].price);
|
|
109
|
+
|
|
110
|
+
const first = parsed.data.offerings.find((product) => product.ailkGroup === "offer");
|
|
111
|
+
const offer: BillingOfferView | null =
|
|
112
|
+
first === undefined
|
|
113
|
+
? null
|
|
114
|
+
: {
|
|
115
|
+
productId: first.productId,
|
|
116
|
+
name: plain(first.name) ?? first.productId,
|
|
117
|
+
description: plain(first.description),
|
|
118
|
+
image: first.image ?? null,
|
|
119
|
+
claimHref: claimHrefOf(first),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return { base, next, offer };
|
|
123
|
+
}
|