@elytracms/studio 0.0.47 → 0.0.48

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.
Files changed (72) hide show
  1. package/convex/auth.ts +61 -12
  2. package/convex/authority.ts +40 -2
  3. package/convex/functions.ts +9 -0
  4. package/convex/invites.ts +75 -0
  5. package/convex/members.ts +44 -18
  6. package/convex/schema.ts +37 -0
  7. package/convex/users.ts +89 -2
  8. package/dist/components/account/account-settings.d.ts +13 -0
  9. package/dist/components/account/account-settings.js +54 -0
  10. package/dist/components/account/account-settings.js.map +1 -0
  11. package/dist/components/account/credential-panel.d.ts +14 -0
  12. package/dist/components/account/credential-panel.js +52 -0
  13. package/dist/components/account/credential-panel.js.map +1 -0
  14. package/dist/components/account/self-account-schema.d.ts +19 -0
  15. package/dist/components/account/self-account-schema.js +52 -0
  16. package/dist/components/account/self-account-schema.js.map +1 -0
  17. package/dist/components/account/self-account-view-source.d.ts +35 -0
  18. package/dist/components/account/self-account-view-source.js +110 -0
  19. package/dist/components/account/self-account-view-source.js.map +1 -0
  20. package/dist/components/auth-context.d.ts +5 -1
  21. package/dist/components/auth-context.js +9 -0
  22. package/dist/components/auth-context.js.map +1 -1
  23. package/dist/components/current-user-menu.js +11 -2
  24. package/dist/components/current-user-menu.js.map +1 -1
  25. package/dist/components/deployment-setup-gate.d.ts +31 -0
  26. package/dist/components/deployment-setup-gate.js +92 -0
  27. package/dist/components/deployment-setup-gate.js.map +1 -0
  28. package/dist/components/project-session.d.ts +1 -1
  29. package/dist/components/project-session.js.map +1 -1
  30. package/dist/components/use-hydration-phase.js +1 -1
  31. package/dist/components/use-hydration-phase.js.map +1 -1
  32. package/dist/components/users/invite-user-bar.d.ts +3 -0
  33. package/dist/components/users/invite-user-bar.js +91 -0
  34. package/dist/components/users/invite-user-bar.js.map +1 -0
  35. package/dist/components/users/users-module.js +13 -2
  36. package/dist/components/users/users-module.js.map +1 -1
  37. package/dist/lib/auth/auth-adapter.d.ts +50 -2
  38. package/dist/lib/auth/auth-adapter.js.map +1 -1
  39. package/dist/lib/auth/convex-auth-adapter.d.ts +28 -1
  40. package/dist/lib/auth/convex-auth-adapter.js +113 -1
  41. package/dist/lib/auth/convex-auth-adapter.js.map +1 -1
  42. package/dist/lib/auth/dev-auto-login-adapter.d.ts +3 -1
  43. package/dist/lib/auth/dev-auto-login-adapter.js +6 -0
  44. package/dist/lib/auth/dev-auto-login-adapter.js.map +1 -1
  45. package/dist/lib/auth/index.d.ts +2 -2
  46. package/dist/lib/auth/index.js +1 -1
  47. package/dist/lib/auth/index.js.map +1 -1
  48. package/dist/lib/auth/local-auth-adapter.d.ts +3 -1
  49. package/dist/lib/auth/local-auth-adapter.js +16 -0
  50. package/dist/lib/auth/local-auth-adapter.js.map +1 -1
  51. package/dist/lib/i18n/messages.en.js +45 -0
  52. package/dist/lib/i18n/messages.en.js.map +1 -1
  53. package/dist/lib/operations/studio-operations.js +1 -1
  54. package/dist/lib/operations/studio-operations.js.map +1 -1
  55. package/dist/lib/persistence/backend-mode.d.ts +1 -1
  56. package/dist/lib/persistence/backend-mode.js +1 -1
  57. package/dist/lib/persistence/backend-mode.js.map +1 -1
  58. package/dist/lib/persistence/convex-adapter.d.ts +2 -1
  59. package/dist/lib/persistence/convex-adapter.js +69 -1
  60. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  61. package/dist/lib/persistence/deployment-readiness.d.ts +36 -0
  62. package/dist/lib/persistence/deployment-readiness.js +26 -0
  63. package/dist/lib/persistence/deployment-readiness.js.map +1 -0
  64. package/dist/lib/persistence/index.d.ts +3 -1
  65. package/dist/lib/persistence/index.js +4 -1
  66. package/dist/lib/persistence/index.js.map +1 -1
  67. package/dist/lib/workspace/switcher-source.js +1 -1
  68. package/dist/lib/workspace/switcher-source.js.map +1 -1
  69. package/dist/lib/workspace/workspace-source.d.ts +1 -1
  70. package/dist/lib/workspace/workspace-source.js +1 -1
  71. package/dist/lib/workspace/workspace-source.js.map +1 -1
  72. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-panel.js","sourceRoot":"","sources":["../../../src/components/account/credential-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,KAAK,EACL,OAAO,EACP,KAAK,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,GACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC1C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IACpC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC1C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAwB,MAAM,CAAC,CAAA;IACjE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAEvD,KAAK,UAAU,YAAY,CAAC,KAAiC;QAC3D,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,QAAQ,CAAC,IAAI,CAAC,CAAA;QACd,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,QAAQ,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC,CAAA;YAChD,OAAM;QACR,CAAC;QACD,QAAQ,CAAC,YAAY,CAA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AAC,SAAS,CAAC,yBAAyB,CAAC,IACjC,GACL,IACA,GACH,IACD,GACI,GACT,CACR,CAAA;AACH,CAAC","sourcesContent":["import { useState } from 'react'\nimport type { FormEvent } from 'react'\nimport { KeyRound, ShieldCheck } from 'lucide-react'\nimport {\n Button,\n Card,\n CardContent,\n Field,\n Heading,\n Input,\n Row,\n Stack,\n Text,\n toast,\n} from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { useAuth } from '../auth-context'\n\n/**\n * The credential seam (EC-240 H-tail item 3) — part of the account **property\n * surface**, never a modal. Two blocks:\n *\n * - **Sign-in method** (read-only): today every studio account is email + password.\n * OAuth \"connected accounts\" is a deferred extension.\n * - **Change password**: current + new + confirm, handed straight to\n * `AuthAdapter.changePassword` (provider-delegated). SEAM ONLY — the raw values\n * are never logged, stored, or inspected here; they leave in the adapter call.\n *\n * The current-password field is the gate around this sensitive action (no separate\n * confirm dialog needed).\n */\nexport function CredentialPanel() {\n const auth = useAuth()\n const [current, setCurrent] = useState('')\n const [next, setNext] = useState('')\n const [confirm, setConfirm] = useState('')\n const [phase, setPhase] = useState<'idle' | 'submitting'>('idle')\n const [error, setError] = useState<string | null>(null)\n\n async function handleSubmit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault()\n setError(null)\n if (next !== confirm) {\n setError(translate('account.password.mismatch'))\n return\n }\n setPhase('submitting')\n // The raw values leave here ONLY into the provider adapter — never logged.\n const result = await auth.changePassword({ currentPassword: current, newPassword: next })\n setPhase('idle')\n if (result.ok) {\n setCurrent('')\n setNext('')\n setConfirm('')\n toast.success(translate('account.password.changed'))\n return\n }\n setError(result.message)\n }\n\n const submitting = phase === 'submitting'\n\n return (\n <Card data-testid=\"credential-panel\">\n <CardContent className=\"pt-5\">\n <Stack gap=\"4\">\n <Stack gap=\"1\">\n <Row gap=\"2\" align=\"center\">\n <ShieldCheck className=\"size-4 text-muted-foreground\" />\n <Heading level={3} size=\"h4\">\n {translate('account.security.title')}\n </Heading>\n </Row>\n <Text size=\"sm\" tone=\"muted\">\n {translate('account.security.method')}\n </Text>\n </Stack>\n\n <form onSubmit={handleSubmit} noValidate>\n <Stack gap=\"3\">\n <Field\n label={translate('account.password.current')}\n htmlFor=\"account-current-password\"\n required\n >\n <Input\n id=\"account-current-password\"\n type=\"password\"\n autoComplete=\"current-password\"\n value={current}\n onChange={(e) => setCurrent(e.target.value)}\n disabled={submitting}\n />\n </Field>\n <Field\n label={translate('account.password.new')}\n htmlFor=\"account-new-password\"\n required\n >\n <Input\n id=\"account-new-password\"\n type=\"password\"\n autoComplete=\"new-password\"\n value={next}\n onChange={(e) => setNext(e.target.value)}\n disabled={submitting}\n />\n </Field>\n <Field\n label={translate('account.password.confirm')}\n htmlFor=\"account-confirm-password\"\n required\n error={error}\n >\n <Input\n id=\"account-confirm-password\"\n type=\"password\"\n autoComplete=\"new-password\"\n value={confirm}\n onChange={(e) => setConfirm(e.target.value)}\n disabled={submitting}\n />\n </Field>\n <Row>\n <Button\n type=\"submit\"\n variant=\"outline\"\n disabled={submitting || !current || !next || !confirm}\n >\n <KeyRound />\n {submitting\n ? translate('account.password.changing')\n : translate('account.password.change')}\n </Button>\n </Row>\n </Stack>\n </form>\n </Stack>\n </CardContent>\n </Card>\n )\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { CollectionDef } from '@elytracms/core/cms-core';
2
+ /**
3
+ * The **account-settings** field lens (EC-240 H-tail) — the schema the portable
4
+ * edit shell renders when a member opens their OWN record (via the user menu). It
5
+ * diverges from the admin `usersCollectionDef` in exactly the way the ratified
6
+ * scope dictates:
7
+ *
8
+ * - **name / avatar are EDITABLE** (not `form.readOnly`) — the person edits their
9
+ * own identity; the source's `save` routes these to `AuthAdapter.updateProfile`
10
+ * (auth-owned), never the members rail.
11
+ * - **email is read-only** (email change is a separate, deferred seam).
12
+ * - **role is read-only** — you never change your own role (the server integrity
13
+ * floor also guards it).
14
+ *
15
+ * Avatar is a plain URL text field for now; the media-picker convention is a
16
+ * deferred polish item — this keeps the mechanism (name + avatar → updateProfile)
17
+ * honest and complete without a half-built picker.
18
+ */
19
+ export declare const selfAccountCollectionDef: CollectionDef;
@@ -0,0 +1,52 @@
1
+ import { collectionDefSchema } from '@elytracms/core/cms-core';
2
+ import { roleOptions } from '@elytracms/core/persistence';
3
+ import { msgLabel } from '@elytracms/studio/lib/i18n';
4
+ /**
5
+ * The **account-settings** field lens (EC-240 H-tail) — the schema the portable
6
+ * edit shell renders when a member opens their OWN record (via the user menu). It
7
+ * diverges from the admin `usersCollectionDef` in exactly the way the ratified
8
+ * scope dictates:
9
+ *
10
+ * - **name / avatar are EDITABLE** (not `form.readOnly`) — the person edits their
11
+ * own identity; the source's `save` routes these to `AuthAdapter.updateProfile`
12
+ * (auth-owned), never the members rail.
13
+ * - **email is read-only** (email change is a separate, deferred seam).
14
+ * - **role is read-only** — you never change your own role (the server integrity
15
+ * floor also guards it).
16
+ *
17
+ * Avatar is a plain URL text field for now; the media-picker convention is a
18
+ * deferred polish item — this keeps the mechanism (name + avatar → updateProfile)
19
+ * honest and complete without a half-built picker.
20
+ */
21
+ export const selfAccountCollectionDef = collectionDefSchema.parse({
22
+ id: 'account',
23
+ kind: 'document',
24
+ titleField: 'name',
25
+ form: {
26
+ label: msgLabel('account.rail.label'),
27
+ labelSingular: msgLabel('account.rail.labelSingular'),
28
+ },
29
+ fields: [
30
+ { name: 'name', type: 'text', form: { label: msgLabel('account.field.name.label') } },
31
+ {
32
+ name: 'avatar',
33
+ type: 'text',
34
+ form: {
35
+ label: msgLabel('account.field.avatar.label'),
36
+ description: msgLabel('account.field.avatar.hint'),
37
+ },
38
+ },
39
+ {
40
+ name: 'email',
41
+ type: 'text',
42
+ form: { label: msgLabel('account.field.email.label'), readOnly: true },
43
+ },
44
+ {
45
+ name: 'role',
46
+ type: 'select',
47
+ options: [...roleOptions()],
48
+ form: { label: msgLabel('account.field.role.label'), readOnly: true },
49
+ },
50
+ ],
51
+ });
52
+ //# sourceMappingURL=self-account-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-account-schema.js","sourceRoot":"","sources":["../../../src/components/account/self-account-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkB,mBAAmB,CAAC,KAAK,CAAC;IAC/E,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE;QACJ,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC;QACrC,aAAa,EAAE,QAAQ,CAAC,4BAA4B,CAAC;KACtD;IACD,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EAAE,EAAE;QACrF;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE;gBACJ,KAAK,EAAE,QAAQ,CAAC,4BAA4B,CAAC;gBAC7C,WAAW,EAAE,QAAQ,CAAC,2BAA2B,CAAC;aACnD;SACF;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;SACvE;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC;YAC3B,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;SACtE;KACF;CACF,CAAC,CAAA","sourcesContent":["import { collectionDefSchema } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport { roleOptions } from '@elytracms/core/persistence'\nimport { msgLabel } from '@elytracms/studio/lib/i18n'\n\n/**\n * The **account-settings** field lens (EC-240 H-tail) — the schema the portable\n * edit shell renders when a member opens their OWN record (via the user menu). It\n * diverges from the admin `usersCollectionDef` in exactly the way the ratified\n * scope dictates:\n *\n * - **name / avatar are EDITABLE** (not `form.readOnly`) — the person edits their\n * own identity; the source's `save` routes these to `AuthAdapter.updateProfile`\n * (auth-owned), never the members rail.\n * - **email is read-only** (email change is a separate, deferred seam).\n * - **role is read-only** — you never change your own role (the server integrity\n * floor also guards it).\n *\n * Avatar is a plain URL text field for now; the media-picker convention is a\n * deferred polish item — this keeps the mechanism (name + avatar → updateProfile)\n * honest and complete without a half-built picker.\n */\nexport const selfAccountCollectionDef: CollectionDef = collectionDefSchema.parse({\n id: 'account',\n kind: 'document',\n titleField: 'name',\n form: {\n label: msgLabel('account.rail.label'),\n labelSingular: msgLabel('account.rail.labelSingular'),\n },\n fields: [\n { name: 'name', type: 'text', form: { label: msgLabel('account.field.name.label') } },\n {\n name: 'avatar',\n type: 'text',\n form: {\n label: msgLabel('account.field.avatar.label'),\n description: msgLabel('account.field.avatar.hint'),\n },\n },\n {\n name: 'email',\n type: 'text',\n form: { label: msgLabel('account.field.email.label'), readOnly: true },\n },\n {\n name: 'role',\n type: 'select',\n options: [...roleOptions()],\n form: { label: msgLabel('account.field.role.label'), readOnly: true },\n },\n ],\n})\n"]}
@@ -0,0 +1,35 @@
1
+ import type { CmsDocument } from '@elytracms/core/cms-core';
2
+ import type { UserRecord } from '@elytracms/core/persistence';
3
+ import type { CollectionViewCapabilities, CollectionViewSource } from '@elytracms/studio/lib/collection-view/collection-view-source';
4
+ /**
5
+ * The capability profile of the account surface (EC-240 H-tail): a single self
6
+ * record edited in place — no publish/versions/create/remove/import. The record
7
+ * is the caller's own; there is nothing to delete or list.
8
+ */
9
+ export declare const ACCOUNT_CAPABILITIES: CollectionViewCapabilities;
10
+ /** Project the self record into the account lens's `values`. */
11
+ export declare function selfToDocument(record: UserRecord): CmsDocument;
12
+ /**
13
+ * Compute the identity diff (name / avatar) an edited account document carries —
14
+ * the exact seam handed to `AuthAdapter.updateProfile`. Pure so the split-write is
15
+ * unit-testable: only the fields the person changed are sent (an empty diff is a
16
+ * no-op the caller can short-circuit). Never carries `email`/`role` — those are
17
+ * read-only on this surface and are not auth-adapter-writable here.
18
+ */
19
+ export declare function accountIdentityDiff(doc: CmsDocument, previous: UserRecord): {
20
+ name?: string;
21
+ avatar?: string;
22
+ };
23
+ /**
24
+ * Assemble a {@link CollectionViewSource} for the **account-settings** surface
25
+ * (EC-240 H-tail). Reuses the portable edit shell over the caller's OWN record —
26
+ * name/avatar editable, email/role read-only (per the schema). The `save` routes
27
+ * the identity diff to `AuthAdapter.updateProfile` (auth-owned) — NOT the
28
+ * members-rail `users.save` — then refreshes the loaded record. `EDITABLE_IDENTITY`
29
+ * marks which fields the save may write; everything else is display-only.
30
+ */
31
+ export declare function useSelfAccountViewSource(input: {
32
+ projectId: string;
33
+ self: UserRecord;
34
+ refresh: () => Promise<void>;
35
+ }): CollectionViewSource;
@@ -0,0 +1,110 @@
1
+ import { useCallback } from 'react';
2
+ import { studioPath } from '@elytracms/studio/router';
3
+ import { useAuth } from '../auth-context';
4
+ import { selfAccountCollectionDef } from './self-account-schema';
5
+ import { normalizeOkResult, useRailViewSource } from '../rail-view-source';
6
+ /** The account surface is not localized — one implicit locale keeps the lens honest. */
7
+ const ACCOUNT_LOCALE = 'en';
8
+ const ACCOUNT_LOCALE_CONFIG = { default: ACCOUNT_LOCALE, locales: [ACCOUNT_LOCALE] };
9
+ /**
10
+ * The capability profile of the account surface (EC-240 H-tail): a single self
11
+ * record edited in place — no publish/versions/create/remove/import. The record
12
+ * is the caller's own; there is nothing to delete or list.
13
+ */
14
+ export const ACCOUNT_CAPABILITIES = {
15
+ publish: false,
16
+ versions: false,
17
+ locales: false,
18
+ inlineEdit: false,
19
+ create: false,
20
+ remove: false,
21
+ bulk: false,
22
+ liveUrl: false,
23
+ hierarchy: false,
24
+ importExport: false,
25
+ };
26
+ /** Everything in `values` that is NOT an editable identity field is display-only. */
27
+ const EDITABLE_IDENTITY = new Set(['name', 'avatar']);
28
+ /** Project the self record into the account lens's `values`. */
29
+ export function selfToDocument(record) {
30
+ return {
31
+ collection: selfAccountCollectionDef.id,
32
+ id: record.id,
33
+ values: {
34
+ name: record.name ?? '',
35
+ avatar: record.avatar ?? '',
36
+ email: record.email,
37
+ role: record.roles[0] ?? 'viewer',
38
+ },
39
+ };
40
+ }
41
+ /**
42
+ * Compute the identity diff (name / avatar) an edited account document carries —
43
+ * the exact seam handed to `AuthAdapter.updateProfile`. Pure so the split-write is
44
+ * unit-testable: only the fields the person changed are sent (an empty diff is a
45
+ * no-op the caller can short-circuit). Never carries `email`/`role` — those are
46
+ * read-only on this surface and are not auth-adapter-writable here.
47
+ */
48
+ export function accountIdentityDiff(doc, previous) {
49
+ const values = doc.values ?? {};
50
+ const diff = {};
51
+ const nextName = typeof values.name === 'string' ? values.name : '';
52
+ const nextAvatar = typeof values.avatar === 'string' ? values.avatar : '';
53
+ if (nextName !== (previous.name ?? ''))
54
+ diff.name = nextName;
55
+ if (nextAvatar !== (previous.avatar ?? ''))
56
+ diff.avatar = nextAvatar;
57
+ return diff;
58
+ }
59
+ /**
60
+ * Assemble a {@link CollectionViewSource} for the **account-settings** surface
61
+ * (EC-240 H-tail). Reuses the portable edit shell over the caller's OWN record —
62
+ * name/avatar editable, email/role read-only (per the schema). The `save` routes
63
+ * the identity diff to `AuthAdapter.updateProfile` (auth-owned) — NOT the
64
+ * members-rail `users.save` — then refreshes the loaded record. `EDITABLE_IDENTITY`
65
+ * marks which fields the save may write; everything else is display-only.
66
+ */
67
+ export function useSelfAccountViewSource(input) {
68
+ const { projectId, self, refresh } = input;
69
+ const auth = useAuth();
70
+ const documents = useCallback(() => [selfToDocument(self)], [self]);
71
+ const get = useCallback((ref) => ref.id === self.id ? selfToDocument(self) : undefined, [self]);
72
+ const titleOf = useCallback(() => self.name || self.email || self.id, [self]);
73
+ const save = useCallback(async (doc) => {
74
+ const diff = accountIdentityDiff(doc, self);
75
+ // No identity change (e.g. a read-only-only edit) → nothing to write.
76
+ if (diff.name === undefined && diff.avatar === undefined)
77
+ return { ok: true };
78
+ const result = await auth.updateProfile(diff);
79
+ if (!result.ok)
80
+ return { ok: false, message: result.message };
81
+ // Reflect the new identity in the loaded record (session already refreshed).
82
+ await refresh();
83
+ return { ok: true };
84
+ }, [auth, self, refresh]);
85
+ const noRemove = useCallback(async () => ({ ok: true }), []);
86
+ const noValidation = useCallback(() => [], []);
87
+ const createUnsupported = useCallback(() => {
88
+ throw new Error('the account surface has no create');
89
+ }, []);
90
+ return useRailViewSource({
91
+ projectId,
92
+ schema: selfAccountCollectionDef,
93
+ capabilities: ACCOUNT_CAPABILITIES,
94
+ localeConfig: ACCOUNT_LOCALE_CONFIG,
95
+ documents,
96
+ get,
97
+ titleOf,
98
+ // Editable-identity fields drive writability; the rest are read-only per schema.
99
+ isFieldReadOnly: (field) => !EDITABLE_IDENTITY.has(field.name) || (field.form?.readOnly ?? false),
100
+ detailPath: (id) => studioPath.user(id),
101
+ listPath: studioPath.users(),
102
+ validate: noValidation,
103
+ create: createUnsupported,
104
+ save,
105
+ remove: noRemove,
106
+ normalizeSaveResult: normalizeOkResult,
107
+ normalizeRemoveResult: () => null,
108
+ });
109
+ }
110
+ //# sourceMappingURL=self-account-view-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-account-view-source.js","sourceRoot":"","sources":["../../../src/components/account/self-account-view-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAMrD,OAAO,EAAE,OAAO,EAAE,M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AAK,CAAC,IAAI,EAAE,QAAQ,IAAI,KAAK,CAAC;QACjG,UAAU,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,QAAQ,EAAE,UAAU,CAAC,KAAK,EAAE;QAC5B,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,iBAAiB;QACzB,IAAI;QACJ,MAAM,EAAE,QAAQ;QAChB,mBAAmB,EAAE,iBAAiB;QACtC,qBAAqB,EAAE,GAA0B,EAAE,CAAC,IAAI;KACzD,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { useCallback } from 'react'\nimport type { CmsDocument, CmsValidationIssue, DocumentRef, Locale, LocaleConfig } from '@elytracms/core/cms-core'\nimport type { UserRecord } from '@elytracms/core/persistence'\nimport { studioPath } from '@elytracms/studio/router'\nimport type {\n CollectionViewCapabilities,\n CollectionViewSource,\n} from '@elytracms/studio/lib/collection-view/collection-view-source'\nimport type { OperationError } from '@elytracms/core/operations'\nimport { useAuth } from '../auth-context'\nimport { selfAccountCollectionDef } from './self-account-schema'\nimport { normalizeOkResult, useRailViewSource } from '../rail-view-source'\n\n/** The account surface is not localized — one implicit locale keeps the lens honest. */\nconst ACCOUNT_LOCALE: Locale = 'en'\nconst ACCOUNT_LOCALE_CONFIG: LocaleConfig = { default: ACCOUNT_LOCALE, locales: [ACCOUNT_LOCALE] }\n\n/**\n * The capability profile of the account surface (EC-240 H-tail): a single self\n * record edited in place — no publish/versions/create/remove/import. The record\n * is the caller's own; there is nothing to delete or list.\n */\nexport const ACCOUNT_CAPABILITIES: CollectionViewCapabilities = {\n publish: false,\n versions: false,\n locales: false,\n inlineEdit: false,\n create: false,\n remove: false,\n bulk: false,\n liveUrl: false,\n hierarchy: false,\n importExport: false,\n}\n\n/** Everything in `values` that is NOT an editable identity field is display-only. */\nconst EDITABLE_IDENTITY = new Set(['name', 'avatar'])\n\n/** Project the self record into the account lens's `values`. */\nexport function selfToDocument(record: UserRecord): CmsDocument {\n return {\n collection: selfAccountCollectionDef.id,\n id: record.id,\n values: {\n name: record.name ?? '',\n avatar: record.avatar ?? '',\n email: record.email,\n role: record.roles[0] ?? 'viewer',\n },\n }\n}\n\n/**\n * Compute the identity diff (name / avatar) an edited account document carries —\n * the exact seam handed to `AuthAdapter.updateProfile`. Pure so the split-write is\n * unit-testable: only the fields the person changed are sent (an empty diff is a\n * no-op the caller can short-circuit). Never carries `email`/`role` — those are\n * read-only on this surface and are not auth-adapter-writable here.\n */\nexport function accountIdentityDiff(\n doc: CmsDocument,\n previous: UserRecord,\n): { name?: string; avatar?: string } {\n const values = doc.values ?? {}\n const diff: { name?: string; avatar?: string } = {}\n const nextName = typeof values.name === 'string' ? values.name : ''\n const nextAvatar = typeof values.avatar === 'string' ? values.avatar : ''\n if (nextName !== (previous.name ?? '')) diff.name = nextName\n if (nextAvatar !== (previous.avatar ?? '')) diff.avatar = nextAvatar\n return diff\n}\n\n/**\n * Assemble a {@link CollectionViewSource} for the **account-settings** surface\n * (EC-240 H-tail). Reuses the portable edit shell over the caller's OWN record —\n * name/avatar editable, email/role read-only (per the schema). The `save` routes\n * the identity diff to `AuthAdapter.updateProfile` (auth-owned) — NOT the\n * members-rail `users.save` — then refreshes the loaded record. `EDITABLE_IDENTITY`\n * marks which fields the save may write; everything else is display-only.\n */\nexport function useSelfAccountViewSource(input: {\n projectId: string\n self: UserRecord\n refresh: () => Promise<void>\n}): CollectionViewSource {\n const { projectId, self, refresh } = input\n const auth = useAuth()\n\n const documents = useCallback(() => [selfToDocument(self)], [self])\n const get = useCallback(\n (ref: DocumentRef): CmsDocument | undefined =>\n ref.id === self.id ? selfToDocument(self) : undefined,\n [self],\n )\n const titleOf = useCallback(() => self.name || self.email || self.id, [self])\n\n const save = useCallback(\n async (doc: CmsDocument): Promise<{ ok: true } | { ok: false; message: string }> => {\n const diff = accountIdentityDiff(doc, self)\n // No identity change (e.g. a read-only-only edit) → nothing to write.\n if (diff.name === undefined && diff.avatar === undefined) return { ok: true }\n const result = await auth.updateProfile(diff)\n if (!result.ok) return { ok: false, message: result.message }\n // Reflect the new identity in the loaded record (session already refreshed).\n await refresh()\n return { ok: true }\n },\n [auth, self, refresh],\n )\n\n const noRemove = useCallback(\n async (): Promise<{ ok: true }> => ({ ok: true }),\n [],\n )\n const noValidation = useCallback((): CmsValidationIssue[] => [], [])\n const createUnsupported = useCallback((): DocumentRef => {\n throw new Error('the account surface has no create')\n }, [])\n\n return useRailViewSource({\n projectId,\n schema: selfAccountCollectionDef,\n capabilities: ACCOUNT_CAPABILITIES,\n localeConfig: ACCOUNT_LOCALE_CONFIG,\n documents,\n get,\n titleOf,\n // Editable-identity fields drive writability; the rest are read-only per schema.\n isFieldReadOnly: (field) => !EDITABLE_IDENTITY.has(field.name) || (field.form?.readOnly ?? false),\n detailPath: (id: string) => studioPath.user(id),\n listPath: studioPath.users(),\n validate: noValidation,\n create: createUnsupported,\n save,\n remove: noRemove,\n normalizeSaveResult: normalizeOkResult,\n normalizeRemoveResult: (): OperationError | null => null,\n })\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { ProjectRole } from '@elytracms/core/persistence';
3
- import type { AuthAdapter, AuthSession, AuthStatus, SignInResult } from '@elytracms/studio/lib/auth';
3
+ import type { AuthAdapter, AuthSession, AuthStatus, ChangePasswordInput, ChangePasswordResult, SignInResult, UpdateProfileInput, UpdateProfileResult } from '@elytracms/studio/lib/auth';
4
4
  /**
5
5
  * Session store (EC-150). Owns the one `AuthAdapter` the app talks to, keeps
6
6
  * the session in React state, and binds/unbinds the operations-layer principal
@@ -15,6 +15,10 @@ export interface AuthStore {
15
15
  /** Register the first/new user on the active backend, then sign in (EC-179). */
16
16
  signUp(email: string, password: string): Promise<SignInResult>;
17
17
  signOut(): Promise<void>;
18
+ /** Edit the signed-in user's OWN name/avatar (EC-240 H-tail); refreshes the session. */
19
+ updateProfile(input: UpdateProfileInput): Promise<UpdateProfileResult>;
20
+ /** Change the signed-in user's OWN password (EC-240 H-tail); provider-delegated. */
21
+ changePassword(input: ChangePasswordInput): Promise<ChangePasswordResult>;
18
22
  }
19
23
  declare const useAuth: () => AuthStore;
20
24
  export interface AuthProviderProps {
@@ -46,6 +46,15 @@ export function AuthProvider({ children, adapter }) {
46
46
  await auth.signOut();
47
47
  apply(null);
48
48
  },
49
+ updateProfile: async (input) => {
50
+ const result = await auth.updateProfile(input);
51
+ // A successful identity edit refreshes the session so the shell (and the
52
+ // account surface) reflect the new name immediately.
53
+ if (result.ok)
54
+ apply(result.session);
55
+ return result;
56
+ },
57
+ changePassword: (input) => auth.changePassword(input),
49
58
  }), [auth, status, session, apply]);
50
59
  return _jsx(AuthContext.Provider, { value: store, children: children });
51
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-context.js","sourceRoot":"","sources":["../../src/components/auth-context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAG7E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAmB9E,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,qBAAqB,CAAY,MAAM,EAAE;IAC9F,OAAO,EAAE,IAAI;CACd,CAAC,CAAA;AAQF,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAqB;IACnE,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAc,GAAG,EAAE,CAAC,OAAO,IAAI,iBAAiB,EAAE,CAAC,CAAA;IAC1E,MAAM,CAAC,MAAM,EAAE,SAAS,CA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AAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACxD,CAAC;QACD,YAAY,EAAE,CAAC,SAAS,CAAC;QACzB,OAAO,EAAE,SAAS,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI;KAC/C,CAAC,CAAA;IACF,OAAO,KAAK,CAAC,IAAI,IAAI,IAAI,CAAA;AAC3B,CAAC","sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport type { ProjectRole } from '@elytracms/core/persistence'\nimport { selectAuthAdapter, sessionPrincipal } from '@elytracms/studio/lib/auth'\nimport type { AuthAdapter, AuthSession, AuthStatus, SignInResult } from '@elytracms/studio/lib/auth'\nimport { setStudioSession } from '@elytracms/studio/lib/operations'\nimport { useOperationQuery } from '@elytracms/studio/lib/query'\nimport { createRequiredContext } from '@elytracms/studio/lib/required-context'\n\n/**\n * Session store (EC-150). Owns the one `AuthAdapter` the app talks to, keeps\n * the session in React state, and binds/unbinds the operations-layer principal\n * (`setStudioSession`) so every studio mutation runs through the role hook as\n * the signed-in user. Auth state machine: `loading` (restoring) →\n * `signed-in` | `signed-out` — all three are deterministic, renderable states.\n */\n\nexport interface AuthStore {\n status: AuthStatus\n session: AuthSession | null\n signIn(email: string, password: string): Promise<SignInResult>\n /** Register the first/new user on the active backend, then sign in (EC-179). */\n signUp(email: string, password: string): Promise<SignInResult>\n signOut(): Promise<void>\n}\n\nconst { Context: AuthContext, useRequired: useAuth } = createRequiredContext<AuthStore>('Auth', {\n article: 'an',\n})\n\nexport interface AuthProviderProps {\n children: ReactNode\n /** Test seam: inject an adapter; defaults to `selectAuthAdapter()`. */\n adapter?: AuthAdapter\n}\n\nexport function AuthProvider({ children, adapter }: AuthProviderProps) {\n const [auth] = useState<AuthAdapter>(() => adapter ?? selectAuthAdapter())\n const [status, setStatus] = useState<AuthStatus>('loading')\n const [session, setSession] = useState<AuthSession | null>(null)\n\n const apply = useCallback((next: AuthSession | null) => {\n setStudioSession(next ? sessionPrincipal(next) : null)\n setSession(next)\n setStatus(next ? 'signed-in' : 'signed-out')\n }, [])\n\n // Restore the session once on the client (SSR renders the 'loading' state).\n useEffect(() => {\n let cancelled = false\n void auth.currentSession().then((restored) => {\n if (!cancelled) apply(restored)\n })\n return () => {\n cancelled = true\n }\n }, [auth, apply])\n\n const store = useMemo<AuthStore>(\n () => ({\n status,\n session,\n signIn: async (email, password) => {\n const result = await auth.signIn({ email, password })\n if (result.ok) apply(result.session)\n return result\n },\n signUp: async (email, password) => {\n const result = await auth.signUp({ email, password })\n if (result.ok) apply(result.session)\n return result\n },\n signOut: async () => {\n await auth.signOut()\n apply(null)\n },\n }),\n [auth, status, session, apply],\n )\n\n return <AuthContext.Provider value={store}>{children}</AuthContext.Provider>\n}\n\nexport { useAuth }\n\n/**\n * Like {@link useAuth}, but tolerant of provider-less renders. For shared\n * leaf surfaces (e.g. the operation-error banner's \"Sign in again\" action)\n * that are also rendered standalone in tests/styleguides: they degrade\n * gracefully instead of demanding the full provider tree.\n */\nexport function useOptionalAuth(): AuthStore | null {\n return useContext(AuthContext)\n}\n\n/**\n * The signed-in user's role on a project (for the shell's role badge).\n * Read through the one operations-backed query cache (EC-308/AD-17) via the\n * `members.find` query — no longer reaching past the spine into\n * `adapter.members` — and re-read when membership changes. `null` while loading\n * or when the user is not a member.\n */\nexport function useProjectRole(projectId: string | null): ProjectRole | null {\n const { session } = useAuth()\n const userId = session?.user.id ?? null\n const query = useOperationQuery<ProjectRole | null>({\n queryKey: ['projectRole', projectId ?? '∅', userId ?? '∅'],\n loader: async (operations) => {\n const result = await operations.members.find({\n projectId: projectId as string,\n userId: userId as string,\n })\n return result.ok ? (result.value?.role ?? null) : null\n },\n invalidateOn: ['members'],\n enabled: projectId !== null && userId !== null,\n })\n return query.data ?? null\n}\n"]}
1
+ {"version":3,"file":"auth-context.js","sourceRoot":"","sources":["../../src/components/auth-context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EA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B,CAAC","sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport type { ProjectRole } from '@elytracms/core/persistence'\nimport { selectAuthAdapter, sessionPrincipal } from '@elytracms/studio/lib/auth'\nimport type {\n AuthAdapter,\n AuthSession,\n AuthStatus,\n ChangePasswordInput,\n ChangePasswordResult,\n SignInResult,\n UpdateProfileInput,\n UpdateProfileResult,\n} from '@elytracms/studio/lib/auth'\nimport { setStudioSession } from '@elytracms/studio/lib/operations'\nimport { useOperationQuery } from '@elytracms/studio/lib/query'\nimport { createRequiredContext } from '@elytracms/studio/lib/required-context'\n\n/**\n * Session store (EC-150). Owns the one `AuthAdapter` the app talks to, keeps\n * the session in React state, and binds/unbinds the operations-layer principal\n * (`setStudioSession`) so every studio mutation runs through the role hook as\n * the signed-in user. Auth state machine: `loading` (restoring) →\n * `signed-in` | `signed-out` — all three are deterministic, renderable states.\n */\n\nexport interface AuthStore {\n status: AuthStatus\n session: AuthSession | null\n signIn(email: string, password: string): Promise<SignInResult>\n /** Register the first/new user on the active backend, then sign in (EC-179). */\n signUp(email: string, password: string): Promise<SignInResult>\n signOut(): Promise<void>\n /** Edit the signed-in user's OWN name/avatar (EC-240 H-tail); refreshes the session. */\n updateProfile(input: UpdateProfileInput): Promise<UpdateProfileResult>\n /** Change the signed-in user's OWN password (EC-240 H-tail); provider-delegated. */\n changePassword(input: ChangePasswordInput): Promise<ChangePasswordResult>\n}\n\nconst { Context: AuthContext, useRequired: useAuth } = createRequiredContext<AuthStore>('Auth', {\n article: 'an',\n})\n\nexport interface AuthProviderProps {\n children: ReactNode\n /** Test seam: inject an adapter; defaults to `selectAuthAdapter()`. */\n adapter?: AuthAdapter\n}\n\nexport function AuthProvider({ children, adapter }: AuthProviderProps) {\n const [auth] = useState<AuthAdapter>(() => adapter ?? selectAuthAdapter())\n const [status, setStatus] = useState<AuthStatus>('loading')\n const [session, setSession] = useState<AuthSession | null>(null)\n\n const apply = useCallback((next: AuthSession | null) => {\n setStudioSession(next ? sessionPrincipal(next) : null)\n setSession(next)\n setStatus(next ? 'signed-in' : 'signed-out')\n }, [])\n\n // Restore the session once on the client (SSR renders the 'loading' state).\n useEffect(() => {\n let cancelled = false\n void auth.currentSession().then((restored) => {\n if (!cancelled) apply(restored)\n })\n return () => {\n cancelled = true\n }\n }, [auth, apply])\n\n const store = useMemo<AuthStore>(\n () => ({\n status,\n session,\n signIn: async (email, password) => {\n const result = await auth.signIn({ email, password })\n if (result.ok) apply(result.session)\n return result\n },\n signUp: async (email, password) => {\n const result = await auth.signUp({ email, password })\n if (result.ok) apply(result.session)\n return result\n },\n signOut: async () => {\n await auth.signOut()\n apply(null)\n },\n updateProfile: async (input) => {\n const result = await auth.updateProfile(input)\n // A successful identity edit refreshes the session so the shell (and the\n // account surface) reflect the new name immediately.\n if (result.ok) apply(result.session)\n return result\n },\n changePassword: (input) => auth.changePassword(input),\n }),\n [auth, status, session, apply],\n )\n\n return <AuthContext.Provider value={store}>{children}</AuthContext.Provider>\n}\n\nexport { useAuth }\n\n/**\n * Like {@link useAuth}, but tolerant of provider-less renders. For shared\n * leaf surfaces (e.g. the operation-error banner's \"Sign in again\" action)\n * that are also rendered standalone in tests/styleguides: they degrade\n * gracefully instead of demanding the full provider tree.\n */\nexport function useOptionalAuth(): AuthStore | null {\n return useContext(AuthContext)\n}\n\n/**\n * The signed-in user's role on a project (for the shell's role badge).\n * Read through the one operations-backed query cache (EC-308/AD-17) via the\n * `members.find` query — no longer reaching past the spine into\n * `adapter.members` — and re-read when membership changes. `null` while loading\n * or when the user is not a member.\n */\nexport function useProjectRole(projectId: string | null): ProjectRole | null {\n const { session } = useAuth()\n const userId = session?.user.id ?? null\n const query = useOperationQuery<ProjectRole | null>({\n queryKey: ['projectRole', projectId ?? '∅', userId ?? '∅'],\n loader: async (operations) => {\n const result = await operations.members.find({\n projectId: projectId as string,\n userId: userId as string,\n })\n return result.ok ? (result.value?.role ?? null) : null\n },\n invalidateOn: ['members'],\n enabled: projectId !== null && userId !== null,\n })\n return query.data ?? null\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { LogOut, Moon, Settings, Sun } from 'lucide-react';
3
3
  import { roleGrantsCapability } from '@elytracms/core/persistence';
4
- import { Avatar, Badge, Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Row, Spacer, Stack, Text, } from '@elytracms/studio/ui';
4
+ import { Avatar, Badge, Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Row, Stack, Text, } from '@elytracms/studio/ui';
5
+ import { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router';
5
6
  import { useT } from '@elytracms/studio/lib/i18n';
6
7
  import { useAuth, useProjectRole } from './auth-context';
7
8
  import { useTheme } from './theme-context';
@@ -15,6 +16,7 @@ export function CurrentUserMenu({ projectId }) {
15
16
  const auth = useAuth();
16
17
  const role = useProjectRole(projectId);
17
18
  const { theme, setTheme } = useTheme();
19
+ const navigate = useNavigate();
18
20
  const t = useT();
19
21
  const user = auth.session?.user;
20
22
  if (!user)
@@ -25,7 +27,14 @@ export function CurrentUserMenu({ projectId }) {
25
27
  return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon-sm", className: "rounded-full", "aria-label": t('userMenu.accountMenu'), children: _jsx(Avatar, { label: displayName, size: "sm" }) }) }), _jsxs(DropdownMenuContent, { align: "end", className: "min-w-60", children: [_jsxs(Row, { gap: "2", className: "px-2 py-2", children: [_jsx(Avatar, { label: displayName, size: "md" }), _jsxs(Stack, { gap: "1", className: "min-w-0 flex-1", children: [_jsx(Text, { size: "sm", weight: "medium", className: "truncate leading-tight", children: displayName }), role ? (_jsx(Row, { children: _jsx(RoleBadge, { role: role }) })) : null] })] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onSelect: (event) => {
26
28
  event.preventDefault();
27
29
  setTheme(isDark ? 'light' : 'dark');
28
- }, children: [isDark ? _jsx(Sun, {}) : _jsx(Moon, {}), isDark ? t('userMenu.lightMode') : t('userMenu.darkMode')] }), _jsxs(DropdownMenuItem, { disabled: true, children: [_jsx(Settings, {}), t('userMenu.accountSettings'), _jsx(Spacer, {}), _jsx(Badge, { variant: "outline", children: t('userMenu.soon') })] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", onSelect: () => void auth.signOut(), children: [_jsx(LogOut, {}), t('userMenu.signOut')] })] })] }));
30
+ }, children: [isDark ? _jsx(Sun, {}) : _jsx(Moon, {}), isDark ? t('userMenu.lightMode') : t('userMenu.darkMode')] }), _jsxs(DropdownMenuItem, { disabled: !projectId, onSelect: () => {
31
+ if (projectId) {
32
+ void navigate({
33
+ to: STUDIO_PROJECT_ROUTE,
34
+ params: { projectId, _splat: studioPath.user(user.id) },
35
+ });
36
+ }
37
+ }, children: [_jsx(Settings, {}), t('userMenu.accountSettings')] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", onSelect: () => void auth.signOut(), children: [_jsx(LogOut, {}), t('userMenu.signOut')] })] })] }));
29
38
  }
30
39
  export function RoleBadge({ role }) {
31
40
  // Variant by capability tier (EC-240c), not role literals — a custom role set
@@ -1 +1 @@
1
- {"version":3,"file":"current-user-menu.js","sourceRoot":"","sources":["../../src/components/current-user-menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,GAAG,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EAA8E;IAC9E,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,EAAE,oBAAoB,CAAC;QAC9D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,eAAe,CAAC;YAC3C,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAA;IACf,OAAO,KAAC,KAAK,IAAC,OAAO,EAAE,OAAO,YAAG,IAAI,GAAS,CAAA;AAChD,CAAC","sourcesContent":["import { LogOut, Moon, Settings, Sun } from 'lucide-react'\nimport { roleGrantsCapability } from '@elytracms/core/persistence'\nimport type { ProjectRole } from '@elytracms/core/persistence'\nimport {\n Avatar,\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { useT } from '@elytracms/studio/lib/i18n'\nimport { useAuth, useProjectRole } from './auth-context'\nimport { useTheme } from './theme-context'\n\n/**\n * Current-user affordance in the shell header (EC-150): who is signed in,\n * their role on the active project (badge), theme switch, and sign-out. Role\n * display is informational — actual enforcement happens at the operations\n * chokepoint and server-side, never in the UI.\n */\nexport function CurrentUserMenu({ projectId }: { projectId: string | null }) {\n const auth = useAuth()\n const role = useProjectRole(projectId)\n const { theme, setTheme } = useTheme()\n const t = useT()\n const user = auth.session?.user\n if (!user) return null\n\n // Show one identity line — the name if set, otherwise the email (never both).\n const displayName = user.name ?? user.email\n const isDark = theme === 'dark'\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"icon-sm\" className=\"rounded-full\" aria-label={t('userMenu.accountMenu')}>\n <Avatar label={displayName} size=\"sm\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-60\">\n {/* Identity header — normal case, single line, with the project role. */}\n <Row gap=\"2\" className=\"px-2 py-2\">\n <Avatar label={displayName} size=\"md\" />\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <Text size=\"sm\" weight=\"medium\" className=\"truncate leading-tight\">\n {displayName}\n </Text>\n {role ? (\n <Row>\n <RoleBadge role={role} />\n </Row>\n ) : null}\n </Stack>\n </Row>\n <DropdownMenuSeparator />\n {/* Theme switch — preventDefault keeps the menu open so the change is visible. */}\n <DropdownMenuItem\n onSelect={(event) => {\n event.preventDefault()\n setTheme(isDark ? 'light' : 'dark')\n }}\n >\n {isDark ? <Sun /> : <Moon />}\n {isDark ? t('userMenu.lightMode') : t('userMenu.darkMode')}\n </DropdownMenuItem>\n {/* TODO(user-settings): point this at an account-settings surface once one\n exists (today only project-scoped settings are implemented). */}\n <DropdownMenuItem disabled>\n <Settings />\n {t('userMenu.accountSettings')}\n <Spacer />\n <Badge variant=\"outline\">{t('userMenu.soon')}</Badge>\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant=\"destructive\" onSelect={() => void auth.signOut()}>\n <LogOut />\n {t('userMenu.signOut')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\nexport function RoleBadge({ role }: { role: ProjectRole }) {\n // Variant by capability tier (EC-240c), not role literals — a custom role set\n // styles by what it grants: administer → primary, write → info, else outline.\n const variant = roleGrantsCapability(role, 'project.administer')\n ? 'primary'\n : roleGrantsCapability(role, 'content.write')\n ? 'info'\n : 'outline'\n return <Badge variant={variant}>{role}</Badge>\n}\n"]}
1
+ {"version":3,"file":"current-user-menu.js","sourceRoot":"","sources":["../../src/components/current-user-menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACr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ACb,EACnB,KAAC,qBAAqB,KAAG,EACzB,MAAC,gBAAgB,IAAC,OAAO,EAAC,aAAa,EAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,aACzE,KAAC,MAAM,KAAG,EACT,CAAC,CAAC,kBAAkB,CAAC,IACL,IACC,IACT,CAChB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAyB;IACvD,8EAA8E;IAC9E,8EAA8E;IAC9E,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,EAAE,oBAAoB,CAAC;QAC9D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,eAAe,CAAC;YAC3C,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAA;IACf,OAAO,KAAC,KAAK,IAAC,OAAO,EAAE,OAAO,YAAG,IAAI,GAAS,CAAA;AAChD,CAAC","sourcesContent":["import { LogOut, Moon, Settings, Sun } from 'lucide-react'\nimport { roleGrantsCapability } from '@elytracms/core/persistence'\nimport type { ProjectRole } from '@elytracms/core/persistence'\nimport {\n Avatar,\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Row,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router'\nimport { useT } from '@elytracms/studio/lib/i18n'\nimport { useAuth, useProjectRole } from './auth-context'\nimport { useTheme } from './theme-context'\n\n/**\n * Current-user affordance in the shell header (EC-150): who is signed in,\n * their role on the active project (badge), theme switch, and sign-out. Role\n * display is informational — actual enforcement happens at the operations\n * chokepoint and server-side, never in the UI.\n */\nexport function CurrentUserMenu({ projectId }: { projectId: string | null }) {\n const auth = useAuth()\n const role = useProjectRole(projectId)\n const { theme, setTheme } = useTheme()\n const navigate = useNavigate()\n const t = useT()\n const user = auth.session?.user\n if (!user) return null\n\n // Show one identity line — the name if set, otherwise the email (never both).\n const displayName = user.name ?? user.email\n const isDark = theme === 'dark'\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"icon-sm\" className=\"rounded-full\" aria-label={t('userMenu.accountMenu')}>\n <Avatar label={displayName} size=\"sm\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-60\">\n {/* Identity header — normal case, single line, with the project role. */}\n <Row gap=\"2\" className=\"px-2 py-2\">\n <Avatar label={displayName} size=\"md\" />\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <Text size=\"sm\" weight=\"medium\" className=\"truncate leading-tight\">\n {displayName}\n </Text>\n {role ? (\n <Row>\n <RoleBadge role={role} />\n </Row>\n ) : null}\n </Stack>\n </Row>\n <DropdownMenuSeparator />\n {/* Theme switch — preventDefault keeps the menu open so the change is visible. */}\n <DropdownMenuItem\n onSelect={(event) => {\n event.preventDefault()\n setTheme(isDark ? 'light' : 'dark')\n }}\n >\n {isDark ? <Sun /> : <Moon />}\n {isDark ? t('userMenu.lightMode') : t('userMenu.darkMode')}\n </DropdownMenuItem>\n {/* Account settings (EC-240 H-tail item 4): the member's OWN record in the\n portable edit shell — self-permitted identity + password. Needs a project\n scope to address the users route; disabled on the project-less shell. */}\n <DropdownMenuItem\n disabled={!projectId}\n onSelect={() => {\n if (projectId) {\n void navigate({\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: studioPath.user(user.id) },\n })\n }\n }}\n >\n <Settings />\n {t('userMenu.accountSettings')}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant=\"destructive\" onSelect={() => void auth.signOut()}>\n <LogOut />\n {t('userMenu.signOut')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\nexport function RoleBadge({ role }: { role: ProjectRole }) {\n // Variant by capability tier (EC-240c), not role literals — a custom role set\n // styles by what it grants: administer → primary, write → info, else outline.\n const variant = roleGrantsCapability(role, 'project.administer')\n ? 'primary'\n : roleGrantsCapability(role, 'content.write')\n ? 'info'\n : 'outline'\n return <Badge variant={variant}>{role}</Badge>\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DeploymentReadinessReport } from '@elytracms/core/export-sync/deployment-ready';
3
+ /**
4
+ * Deployment-setup boot gate (EC-258) — the single readiness surface that
5
+ * supersedes the separate `BackendGate` (missing `VITE_CONVEX_URL` / unreachable)
6
+ * and `WorkspaceGate` (invalid config) screens by composing the shared
7
+ * `checkDeploymentReady` contract. It renders ONE deterministic "Deployment setup"
8
+ * screen listing each failing precondition with its copy-pasteable fix, instead of
9
+ * letting the app boot into a misleading downstream error (most painfully the
10
+ * Konditorei JWT-key footgun). All checks passing → children render untouched.
11
+ *
12
+ * Runs before auth and any adapter is constructed (it is the thing that keeps
13
+ * `selectAuthAdapter`/`selectPersistenceAdapter` from throwing on a misconfigured
14
+ * backend). Convex mode probes reachability once on the client (`adapter.status()`)
15
+ * with a retry; playground and unconfigured resolve synchronously. SSR renders the
16
+ * deterministic "checking" state. Auth-signing-keys is reported as `unknown` at boot
17
+ * (the JWKS endpoint is CORS-blocked from the browser — EC-257's honest sign-in error
18
+ * is the browser's actionable surface; `elytra doctor` probes it from node), and the
19
+ * per-user bucket stays `unknown` (this gate runs pre-auth), so neither ever blocks boot.
20
+ */
21
+ export declare function DeploymentSetupGate({ children }: {
22
+ children: ReactNode;
23
+ }): import("react").JSX.Element;
24
+ /**
25
+ * The unified "Deployment setup" screen (EC-258): every failing check + its exact
26
+ * fix. Pure/presentational so it is fixture-reproducible and static-render testable.
27
+ */
28
+ export declare function DeploymentSetupScreen({ report, onRetry, }: {
29
+ report: DeploymentReadinessReport;
30
+ onRetry?: () => void;
31
+ }): import("react").JSX.Element;
@@ -0,0 +1,92 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState } from 'react';
3
+ import { Button, Card, CardContent, CardHeader, CardTitle, Code, Stack, Text } from '@elytracms/studio/ui';
4
+ import { resolveBackendConfig, selectPersistenceAdapter, studioDeploymentReadiness, } from '@elytracms/studio/lib/persistence';
5
+ import { getWorkspaceState, resolveDeploymentCollections, resolveDeploymentUrl, } from '@elytracms/studio/lib/workspace';
6
+ import { translate } from '@elytracms/studio/lib/i18n';
7
+ /**
8
+ * Deployment-setup boot gate (EC-258) — the single readiness surface that
9
+ * supersedes the separate `BackendGate` (missing `VITE_CONVEX_URL` / unreachable)
10
+ * and `WorkspaceGate` (invalid config) screens by composing the shared
11
+ * `checkDeploymentReady` contract. It renders ONE deterministic "Deployment setup"
12
+ * screen listing each failing precondition with its copy-pasteable fix, instead of
13
+ * letting the app boot into a misleading downstream error (most painfully the
14
+ * Konditorei JWT-key footgun). All checks passing → children render untouched.
15
+ *
16
+ * Runs before auth and any adapter is constructed (it is the thing that keeps
17
+ * `selectAuthAdapter`/`selectPersistenceAdapter` from throwing on a misconfigured
18
+ * backend). Convex mode probes reachability once on the client (`adapter.status()`)
19
+ * with a retry; playground and unconfigured resolve synchronously. SSR renders the
20
+ * deterministic "checking" state. Auth-signing-keys is reported as `unknown` at boot
21
+ * (the JWKS endpoint is CORS-blocked from the browser — EC-257's honest sign-in error
22
+ * is the browser's actionable surface; `elytra doctor` probes it from node), and the
23
+ * per-user bucket stays `unknown` (this gate runs pre-auth), so neither ever blocks boot.
24
+ */
25
+ export function DeploymentSetupGate({ children }) {
26
+ const config = useMemo(() => resolveBackendConfig(), []);
27
+ const staticReport = useCallback(() => studioDeploymentReadiness({
28
+ backend: config,
29
+ workspace: getWorkspaceState(),
30
+ collections: resolveDeploymentCollections(),
31
+ }), [config]);
32
+ const [state, setState] = useState(() => config.kind === 'convex' ? { phase: 'checking' } : { phase: 'resolved', report: staticReport() });
33
+ const check = useCallback(() => {
34
+ if (config.kind !== 'convex') {
35
+ setState({ phase: 'resolved', report: staticReport() });
36
+ return;
37
+ }
38
+ const effectiveUrl = resolveDeploymentUrl(config.url);
39
+ const resolve = (reachable) => setState({
40
+ phase: 'resolved',
41
+ report: studioDeploymentReadiness({
42
+ backend: config,
43
+ effectiveUrl,
44
+ workspace: getWorkspaceState(),
45
+ collections: resolveDeploymentCollections(),
46
+ reachable,
47
+ }),
48
+ });
49
+ setState({ phase: 'checking' });
50
+ void selectPersistenceAdapter()
51
+ .then((adapter) => adapter.status())
52
+ .then((status) => resolve({ available: status.available, ...(status.detail ? { detail: status.detail } : {}) }))
53
+ .catch((error) => resolve({ available: false, detail: error instanceof Error ? error.message : String(error) }));
54
+ }, [config, staticReport]);
55
+ useEffect(() => {
56
+ if (config.kind === 'convex')
57
+ check();
58
+ }, [config.kind, check]);
59
+ if (state.phase === 'checking')
60
+ return _jsx(DeploymentChecking, {});
61
+ if (blockingFailures(state.report).length > 0) {
62
+ return (_jsx(DeploymentSetupScreen, { report: state.report, onRetry: config.kind === 'convex' ? check : undefined }));
63
+ }
64
+ return _jsx(_Fragment, { children: children });
65
+ }
66
+ /**
67
+ * The checks that BLOCK boot: a failed deployment- or app-level precondition. The
68
+ * per-user bucket ("not a member") is not a boot blocker — it is surfaced post-auth
69
+ * ("ask an admin"), and at boot it is `unknown` (pre-auth) anyway.
70
+ */
71
+ function blockingFailures(report) {
72
+ return report.checks.filter((c) => c.status === 'fail' && (c.bucket === 'deployment' || c.bucket === 'app'));
73
+ }
74
+ /** Deterministic boot state while the backend probe is in flight (also SSR output). */
75
+ function DeploymentChecking() {
76
+ return (_jsx(BootScreenFrame, { children: _jsx(Text, { size: "sm", tone: "muted", children: translate('shell.deploymentSetup.checking') }) }));
77
+ }
78
+ /**
79
+ * The unified "Deployment setup" screen (EC-258): every failing check + its exact
80
+ * fix. Pure/presentational so it is fixture-reproducible and static-render testable.
81
+ */
82
+ export function DeploymentSetupScreen({ report, onRetry, }) {
83
+ const failures = report.checks.filter((c) => c.status === 'fail');
84
+ return (_jsx(BootScreenFrame, { children: _jsxs(Card, { className: "max-w-2xl border-destructive/40", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: translate('shell.deploymentSetup.title') }) }), _jsx(CardContent, { children: _jsxs(Stack, { gap: "3", children: [_jsx(Text, { size: "sm", tone: "muted", children: translate('shell.deploymentSetup.description') }), _jsx(Stack, { gap: "2", role: "list", "aria-label": translate('shell.deploymentSetup.issuesLabel'), children: failures.map((check) => (_jsx(CheckRow, { check: check }, check.id))) }), onRetry ? (_jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, className: "self-start", children: translate('shell.deploymentSetup.retry') })) : null] }) })] }) }));
85
+ }
86
+ function CheckRow({ check }) {
87
+ return (_jsxs("div", { role: "listitem", className: "rounded-md border border-destructive/30 bg-destructive/5 p-2", children: [_jsxs(Text, { size: "xs", mono: true, className: "text-destructive", children: ["[", check.id, "]"] }), _jsx(Text, { size: "sm", children: check.detail }), check.fix ? (_jsxs(Text, { size: "xs", tone: "muted", className: "mt-1", children: [translate('shell.deploymentSetup.fixLabel'), ": ", _jsx(Code, { className: "break-all", children: check.fix })] })) : null] }));
88
+ }
89
+ function BootScreenFrame({ children }) {
90
+ return _jsx("div", { className: "grid min-h-dvh place-items-center bg-background p-6", children: children });
91
+ }
92
+ //# sourceMappingURL=deployment-setup-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-setup-gate.js","sourceRoot":"","sources":["../../src/components/deployment-setup-gate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEjE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC1G,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,mCAAmC,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CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACvB,KAAC,QAAQ,IAAgB,KAAK,EAAE,KAAK,IAAtB,KAAK,CAAC,EAAE,CAAkB,CAC1C,CAAC,GACI,EACP,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,YAAY,YACzE,SAAS,CAAC,6BAA6B,CAAC,GAClC,CACV,CAAC,CAAC,CAAC,IAAI,IACF,GACI,IACT,GACS,CACnB,CAAA;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,EAAE,KAAK,EAA6B;IACpD,OAAO,CACL,eAAK,IAAI,EAAC,UAAU,EAAC,SAAS,EAAC,8DAA8D,aAC3F,MAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,QAAC,SAAS,EAAC,kBAAkB,kBAC7C,KAAK,CAAC,EAAE,SACL,EACP,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,YAAE,KAAK,CAAC,MAAM,GAAQ,EACpC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CACX,MAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,MAAM,aAC1C,SAAS,CAAC,gCAAgC,CAAC,QAAG,KAAC,IAAI,IAAC,SAAS,EAAC,WAAW,YAAE,KAAK,CAAC,GAAG,GAAQ,IACxF,CACR,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAA;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,QAAQ,EAA2B;IAC5D,OAAO,cAAK,SAAS,EAAC,qDAAqD,YAAE,QAAQ,GAAO,CAAA;AAC9F,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport { Button, Card, CardContent, CardHeader, CardTitle, Code, Stack, Text } from '@elytracms/studio/ui'\nimport {\n resolveBackendConfig,\n selectPersistenceAdapter,\n studioDeploymentReadiness,\n} from '@elytracms/studio/lib/persistence'\nimport {\n getWorkspaceState,\n resolveDeploymentCollections,\n resolveDeploymentUrl,\n} from '@elytracms/studio/lib/workspace'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport type {\n DeploymentReadinessReport,\n ReadinessCheck,\n} from '@elytracms/core/export-sync/deployment-ready'\n\n/**\n * Deployment-setup boot gate (EC-258) — the single readiness surface that\n * supersedes the separate `BackendGate` (missing `VITE_CONVEX_URL` / unreachable)\n * and `WorkspaceGate` (invalid config) screens by composing the shared\n * `checkDeploymentReady` contract. It renders ONE deterministic \"Deployment setup\"\n * screen listing each failing precondition with its copy-pasteable fix, instead of\n * letting the app boot into a misleading downstream error (most painfully the\n * Konditorei JWT-key footgun). All checks passing → children render untouched.\n *\n * Runs before auth and any adapter is constructed (it is the thing that keeps\n * `selectAuthAdapter`/`selectPersistenceAdapter` from throwing on a misconfigured\n * backend). Convex mode probes reachability once on the client (`adapter.status()`)\n * with a retry; playground and unconfigured resolve synchronously. SSR renders the\n * deterministic \"checking\" state. Auth-signing-keys is reported as `unknown` at boot\n * (the JWKS endpoint is CORS-blocked from the browser — EC-257's honest sign-in error\n * is the browser's actionable surface; `elytra doctor` probes it from node), and the\n * per-user bucket stays `unknown` (this gate runs pre-auth), so neither ever blocks boot.\n */\nexport function DeploymentSetupGate({ children }: { children: ReactNode }) {\n const config = useMemo(() => resolveBackendConfig(), [])\n\n const staticReport = useCallback(\n (): DeploymentReadinessReport =>\n studioDeploymentReadiness({\n backend: config,\n workspace: getWorkspaceState(),\n collections: resolveDeploymentCollections(),\n }),\n [config],\n )\n\n const [state, setState] = useState<GateState>(() =>\n config.kind === 'convex' ? { phase: 'checking' } : { phase: 'resolved', report: staticReport() },\n )\n\n const check = useCallback(() => {\n if (config.kind !== 'convex') {\n setState({ phase: 'resolved', report: staticReport() })\n return\n }\n const effectiveUrl = resolveDeploymentUrl(config.url)\n const resolve = (reachable: { available: boolean; detail?: string }) =>\n setState({\n phase: 'resolved',\n report: studioDeploymentReadiness({\n backend: config,\n effectiveUrl,\n workspace: getWorkspaceState(),\n collections: resolveDeploymentCollections(),\n reachable,\n }),\n })\n setState({ phase: 'checking' })\n void selectPersistenceAdapter()\n .then((adapter) => adapter.status())\n .then((status) =>\n resolve({ available: status.available, ...(status.detail ? { detail: status.detail } : {}) }),\n )\n .catch((error: unknown) =>\n resolve({ available: false, detail: error instanceof Error ? error.message : String(error) }),\n )\n }, [config, staticReport])\n\n useEffect(() => {\n if (config.kind === 'convex') check()\n }, [config.kind, check])\n\n if (state.phase === 'checking') return <DeploymentChecking />\n if (blockingFailures(state.report).length > 0) {\n return (\n <DeploymentSetupScreen\n report={state.report}\n onRetry={config.kind === 'convex' ? check : undefined}\n />\n )\n }\n return <>{children}</>\n}\n\ntype GateState = { phase: 'checking' } | { phase: 'resolved'; report: DeploymentReadinessReport }\n\n/**\n * The checks that BLOCK boot: a failed deployment- or app-level precondition. The\n * per-user bucket (\"not a member\") is not a boot blocker — it is surfaced post-auth\n * (\"ask an admin\"), and at boot it is `unknown` (pre-auth) anyway.\n */\nfunction blockingFailures(report: DeploymentReadinessReport): ReadinessCheck[] {\n return report.checks.filter(\n (c) => c.status === 'fail' && (c.bucket === 'deployment' || c.bucket === 'app'),\n )\n}\n\n/** Deterministic boot state while the backend probe is in flight (also SSR output). */\nfunction DeploymentChecking() {\n return (\n <BootScreenFrame>\n <Text size=\"sm\" tone=\"muted\">\n {translate('shell.deploymentSetup.checking')}\n </Text>\n </BootScreenFrame>\n )\n}\n\n/**\n * The unified \"Deployment setup\" screen (EC-258): every failing check + its exact\n * fix. Pure/presentational so it is fixture-reproducible and static-render testable.\n */\nexport function DeploymentSetupScreen({\n report,\n onRetry,\n}: {\n report: DeploymentReadinessReport\n onRetry?: () => void\n}) {\n const failures = report.checks.filter((c) => c.status === 'fail')\n return (\n <BootScreenFrame>\n <Card className=\"max-w-2xl border-destructive/40\">\n <CardHeader>\n <CardTitle>{translate('shell.deploymentSetup.title')}</CardTitle>\n </CardHeader>\n <CardContent>\n <Stack gap=\"3\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('shell.deploymentSetup.description')}\n </Text>\n <Stack gap=\"2\" role=\"list\" aria-label={translate('shell.deploymentSetup.issuesLabel')}>\n {failures.map((check) => (\n <CheckRow key={check.id} check={check} />\n ))}\n </Stack>\n {onRetry ? (\n <Button variant=\"outline\" size=\"sm\" onClick={onRetry} className=\"self-start\">\n {translate('shell.deploymentSetup.retry')}\n </Button>\n ) : null}\n </Stack>\n </CardContent>\n </Card>\n </BootScreenFrame>\n )\n}\n\nfunction CheckRow({ check }: { check: ReadinessCheck }) {\n return (\n <div role=\"listitem\" className=\"rounded-md border border-destructive/30 bg-destructive/5 p-2\">\n <Text size=\"xs\" mono className=\"text-destructive\">\n [{check.id}]\n </Text>\n <Text size=\"sm\">{check.detail}</Text>\n {check.fix ? (\n <Text size=\"xs\" tone=\"muted\" className=\"mt-1\">\n {translate('shell.deploymentSetup.fixLabel')}: <Code className=\"break-all\">{check.fix}</Code>\n </Text>\n ) : null}\n </div>\n )\n}\n\nfunction BootScreenFrame({ children }: { children: ReactNode }) {\n return <div className=\"grid min-h-dvh place-items-center bg-background p-6\">{children}</div>\n}\n"]}
@@ -7,7 +7,7 @@ import type { HydratedCms, HydratedProjectSession, OperationResult } from '@elyt
7
7
  * builder from the latest persisted graph revision, the CMS from the saved
8
8
  * schema + documents, publishing from the persisted environment states.
9
9
  * This provider runs the `@elytracms/core/operations` hydration queries
10
- * (`lib/operations/session-hydration`) and — like `BackendGate` — gates its
10
+ * (`lib/operations/session-hydration`) and — like `DeploymentSetupGate` — gates its
11
11
  * children on a deterministic loading state, so fixture content never
12
12
  * flashes (and is never editable) before the persisted state arrives.
13
13
  *