@lssm/example.learning-journey-ui-shared 0.0.0-canary-20251213172311 → 0.0.0-canary-20251215220103

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.
@@ -1,24 +1,24 @@
1
1
  $ bun build:bundle && bun build:types
2
2
  $ tsdown
3
- ℹ tsdown v0.17.0 powered by rolldown v1.0.0-beta.53
3
+ ℹ tsdown v0.17.4 powered by rolldown v1.0.0-beta.53
4
4
  ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/learning-journey-ui-shared/tsdown.config.js
5
5
  ℹ entry: src/index.ts, src/hooks/index.ts, src/components/index.ts, src/types.ts
6
6
  ℹ target: esnext
7
7
  ℹ tsconfig: tsconfig.json
8
8
  ℹ Build start
9
- ℹ dist/index.mjs 97.89 kB │ gzip: 33.49 kB
10
- ℹ dist/components/index.mjs  0.17 kB │ gzip: 0.14 kB
11
- ℹ dist/hooks/index.mjs  0.10 kB │ gzip: 0.09 kB
12
- ℹ dist/types.mjs  0.01 kB │ gzip: 0.03 kB
13
- ℹ dist/components-tyJAN4Ru.mjs  4.53 kB │ gzip: 1.63 kB
14
- ℹ dist/hooks-B-tDvppY.mjs  2.48 kB │ gzip: 0.87 kB
15
- ℹ dist/index.d.mts  1.58 kB │ gzip: 0.60 kB
16
- ℹ dist/types.d.mts  0.38 kB │ gzip: 0.19 kB
17
- ℹ dist/components/index.d.mts  0.16 kB │ gzip: 0.14 kB
18
- ℹ dist/hooks/index.d.mts  0.10 kB │ gzip: 0.09 kB
19
- ℹ dist/types-BMAby_Ku.d.mts  1.70 kB │ gzip: 0.60 kB
20
- ℹ dist/index-EWErSKip.d.mts  0.95 kB │ gzip: 0.37 kB
21
- ℹ dist/index-D_7WU_xm.d.mts  0.68 kB │ gzip: 0.35 kB
22
- ℹ 13 files, total: 110.72 kB
23
- ✔ Build complete in 9285ms
9
+ ℹ dist/index.mjs 121.60 kB │ gzip: 40.46 kB
10
+ ℹ dist/components/index.mjs  0.17 kB │ gzip: 0.14 kB
11
+ ℹ dist/hooks/index.mjs  0.10 kB │ gzip: 0.09 kB
12
+ ℹ dist/types.mjs  0.01 kB │ gzip: 0.03 kB
13
+ ℹ dist/components-tyJAN4Ru.mjs  4.53 kB │ gzip: 1.63 kB
14
+ ℹ dist/hooks-B-tDvppY.mjs  2.48 kB │ gzip: 0.87 kB
15
+ ℹ dist/index.d.mts  1.58 kB │ gzip: 0.60 kB
16
+ ℹ dist/types.d.mts  0.38 kB │ gzip: 0.19 kB
17
+ ℹ dist/components/index.d.mts  0.16 kB │ gzip: 0.14 kB
18
+ ℹ dist/hooks/index.d.mts  0.10 kB │ gzip: 0.09 kB
19
+ ℹ dist/types-BMAby_Ku.d.mts  1.70 kB │ gzip: 0.60 kB
20
+ ℹ dist/index-EWErSKip.d.mts  0.95 kB │ gzip: 0.37 kB
21
+ ℹ dist/index-D_7WU_xm.d.mts  0.68 kB │ gzip: 0.35 kB
22
+ ℹ 13 files, total: 134.43 kB
23
+ ✔ Build complete in 8575ms
24
24
  $ tsc --noEmit
package/CHANGELOG.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @lssm/example.learning-journey-ui-shared
2
2
 
3
- ## 0.0.0-canary-20251213172311
3
+ ## 0.0.0-canary-20251215220103
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - Updated dependencies [3086383]
8
- - @lssm/lib.design-system@0.0.0-canary-20251213172311
9
- - @lssm/lib.ui-kit-web@0.0.0-canary-20251213172311
10
- - @lssm/module.learning-journey@0.0.0-canary-20251213172311
8
+ - @lssm/lib.design-system@0.0.0-canary-20251215220103
9
+ - @lssm/lib.ui-kit-web@0.0.0-canary-20251215220103
10
+ - @lssm/module.learning-journey@0.0.0-canary-20251215220103
package/dist/index.mjs CHANGED
@@ -270,6 +270,84 @@ const tech_presentation_runtime_DocBlocks = [{
270
270
  }];
271
271
  registerDocBlocks(tech_presentation_runtime_DocBlocks);
272
272
 
273
+ //#endregion
274
+ //#region ../../libs/contracts/src/docs/tech/auth/better-auth-nextjs.docblock.ts
275
+ const tech_auth_better_auth_nextjs_DocBlocks = [{
276
+ id: "docs.tech.auth.better-auth-nextjs",
277
+ title: "Better Auth + Next.js integration (ContractSpec)",
278
+ summary: "How ContractSpec wires Better Auth into Next.js (server config, client singleton, and proxy cookie-only redirects).",
279
+ kind: "reference",
280
+ visibility: "public",
281
+ route: "/docs/tech/auth/better-auth-nextjs",
282
+ tags: [
283
+ "auth",
284
+ "better-auth",
285
+ "nextjs",
286
+ "cookies",
287
+ "proxy",
288
+ "hmr"
289
+ ],
290
+ body: `# Better Auth + Next.js integration (ContractSpec)
291
+
292
+ This repo uses Better Auth as the primary auth layer (sessions, organizations, teams, API keys, and OAuth).
293
+
294
+ ## Server config (Better Auth)
295
+
296
+ - Source: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
297
+ - Important: \`nextCookies()\` must be the **last** plugin in the Better Auth plugin list so \`Set-Cookie\` is applied correctly in Next.js environments.
298
+
299
+ ## Better Auth Admin plugin
300
+
301
+ ContractSpec Studio enables the Better Auth **Admin plugin** to support platform-admin user operations (list users, impersonation, etc.).
302
+
303
+ - Server: \`admin()\` plugin in \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
304
+ - Client: \`adminClient()\` in \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
305
+
306
+ ### PLATFORM_ADMIN ⇒ Better Auth admin role
307
+
308
+ Better Auth Admin endpoints authorize via \`user.role\`. ContractSpec enforces an org-driven rule:
309
+
310
+ - If the **active organization** has \`type = PLATFORM_ADMIN\`, the signed-in user is ensured to have \`User.role\` containing \`admin\`.
311
+ - This is applied in the session creation hook and re-checked in \`assertsPlatformAdmin()\`.
312
+
313
+ This keeps admin enablement deterministic and avoids manual role backfills.
314
+
315
+ ## Client config (React web + Expo)
316
+
317
+ To avoid duplicate background refresh/polling loops in dev (Fast Refresh/HMR), the Better Auth client is implemented as a singleton cached on \`globalThis\`.
318
+
319
+ - Web client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
320
+ - Native client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.native.ts\`
321
+
322
+ Import guidance:
323
+
324
+ - If you only need the context/hook, prefer importing from \`@lssm/bundle.contractspec-studio/presentation/providers/auth\`.
325
+ - If you explicitly need the Better Auth client instance (e.g. admin impersonation, direct API calls), import from \`@lssm/bundle.contractspec-studio/presentation/providers/auth/client\`.
326
+
327
+ ## Public routes (login / signup)
328
+
329
+ Public auth pages should avoid eager \`authClient\` initialization.
330
+
331
+ Pattern used:
332
+
333
+ - In the submit handler, dynamically import \`@lssm/bundle.contractspec-studio/presentation/providers/auth/index.web\` and call \`authClient.signIn.*\` / \`authClient.signUp.*\`.
334
+
335
+ This prevents session refresh behavior from starting just because a public page rendered.
336
+
337
+ ## Next.js proxy auth (web-landing)
338
+
339
+ The Next.js proxy/middleware is used for **redirect decisions only**. It must not perform DB-backed session reads on every request.
340
+
341
+ - Source: \`packages/apps/web-landing/src/proxy.ts\`
342
+ - Approach: cookie-only checks via Better Auth cookies helpers:
343
+ - \`getSessionCookie(request)\`
344
+ - \`getCookieCache(request)\`
345
+
346
+ These checks are intentionally optimistic and should only gate routing. Full authorization must still be enforced on server-side actions/routes and GraphQL resolvers.
347
+ `
348
+ }];
349
+ registerDocBlocks(tech_auth_better_auth_nextjs_DocBlocks);
350
+
273
351
  //#endregion
274
352
  //#region ../../libs/contracts/src/docs/tech/schema/README.docblock.ts
275
353
  const tech_schema_README_DocBlocks = [{
@@ -666,6 +744,529 @@ The registry module must export one of:
666
744
  }];
667
745
  registerDocBlocks(tech_contracts_openapi_export_DocBlocks);
668
746
 
747
+ //#endregion
748
+ //#region ../../libs/contracts/src/docs/tech/studio/workspaces.docblock.ts
749
+ const tech_studio_workspaces_DocBlocks = [{
750
+ id: "docs.tech.studio.workspaces",
751
+ title: "Studio projects, teams, environments",
752
+ summary: "Organization-first Studio: projects live under an organization; teams refine access; projects deploy to multiple environments.",
753
+ kind: "reference",
754
+ visibility: "mixed",
755
+ route: "/docs/tech/studio/workspaces",
756
+ tags: [
757
+ "studio",
758
+ "projects",
759
+ "teams",
760
+ "rbac",
761
+ "environments"
762
+ ],
763
+ body: `## Concepts
764
+
765
+ - **Organization**: the primary grouping boundary for Studio projects.
766
+ - **Project**: one application (specs, overlays, deployments, integrations, evolution, learning).
767
+ - **Team**: refines who can see/edit a project within an organization.
768
+ - **Environment**: deployment target (Development / Staging / Production).
769
+
770
+ ## Project access (teams + admin override)
771
+
772
+ Studio uses multi-team sharing to refine access:
773
+
774
+ - **Admins/owners** can access all projects.
775
+ - If a project is shared with **no teams**, it is **org-wide** (all org members).
776
+ - If a project is shared with **one or more teams**, it is visible to:
777
+ - admins/owners, and
778
+ - members of any linked team.
779
+
780
+ ## Current persistence (DB + GraphQL)
781
+
782
+ - DB (Prisma): \`StudioProject\`, \`Team\`, \`TeamMember\`, \`StudioProjectTeam\`
783
+ - GraphQL:
784
+ - \`myStudioProjects\`
785
+ - \`createStudioProject(input.teamIds?)\`
786
+ - \`myTeams\`
787
+ - \`projectTeams(projectId)\`
788
+ - \`setProjectTeams(projectId, teamIds)\`
789
+
790
+ ## UI shell behavior
791
+
792
+ Studio and Sandbox both use a shared shell:
793
+
794
+ - Project selector → Module navigation → Environment selector
795
+ - Always-on Assistant button (floating)
796
+ - Learning journey progress (Studio persists learning events; Sandbox stays local-only)
797
+
798
+ ## Routing
799
+
800
+ - \`/studio/projects\`: create/select/delete projects (organization-first).
801
+ - \`/studio/{projectSlug}/*\`: project modules (canvas/specs/deploy/integrations/evolution/learning).
802
+ - \`/studio/learning\`: learning hub without selecting a project.
803
+ `
804
+ }];
805
+ registerDocBlocks(tech_studio_workspaces_DocBlocks);
806
+
807
+ //#endregion
808
+ //#region ../../libs/contracts/src/docs/tech/studio/sandbox-unlogged.docblock.ts
809
+ const tech_studio_sandbox_unlogged_DocBlocks = [{
810
+ id: "docs.tech.studio.sandbox.unlogged",
811
+ title: "Sandbox (unlogged) vs Studio (authenticated)",
812
+ summary: "The sandbox is a lightweight, unlogged surface that mirrors Studio navigation without auth or analytics.",
813
+ kind: "reference",
814
+ visibility: "public",
815
+ route: "/docs/tech/studio/sandbox-unlogged",
816
+ tags: [
817
+ "studio",
818
+ "sandbox",
819
+ "privacy",
820
+ "analytics"
821
+ ],
822
+ body: `## Sandbox guarantees
823
+
824
+ - Route: \`/sandbox\`
825
+ - **No auth requirement**
826
+ - **No PostHog init**
827
+ - **No Vercel Analytics**
828
+ - Local-only state (in-browser runtime + localStorage where needed)
829
+
830
+ ## What Sandbox is for
831
+
832
+ - Try templates and feature modules safely
833
+ - Preview specs/builder/evolution/learning
834
+ - Produce copyable CLI commands (no side effects)
835
+
836
+ ## What Sandbox is *not* for
837
+
838
+ - Persisted projects/workspaces
839
+ - Real deployments
840
+ - Organization-scoped integrations (unless explicitly enabled later)
841
+ `
842
+ }];
843
+ registerDocBlocks(tech_studio_sandbox_unlogged_DocBlocks);
844
+
845
+ //#endregion
846
+ //#region ../../libs/contracts/src/docs/tech/studio/workspace-ops.docblock.ts
847
+ const tech_studio_workspace_ops_DocBlocks = [{
848
+ id: "docs.tech.studio.workspace_ops",
849
+ title: "Workspace ops (repo-linked): list / validate / deps / diff",
850
+ summary: "Read-only repo operations used by Studio to inspect and validate a linked ContractSpec workspace.",
851
+ kind: "reference",
852
+ visibility: "mixed",
853
+ route: "/docs/tech/studio/workspace-ops",
854
+ tags: [
855
+ "studio",
856
+ "repo",
857
+ "workspace",
858
+ "validate",
859
+ "diff"
860
+ ],
861
+ body: `## API surface (api-contractspec)
862
+
863
+ Base: \`/api/workspace-ops\`
864
+
865
+ These endpoints are **read-only** in v1 and never push to git:
866
+
867
+ - \`GET /api/workspace-ops/:integrationId/config?organizationId=\`
868
+ - \`GET /api/workspace-ops/:integrationId/specs?organizationId=\`
869
+ - \`POST /api/workspace-ops/:integrationId/validate\` (body: organizationId, files?, pattern?)
870
+ - \`POST /api/workspace-ops/:integrationId/deps\` (body: organizationId, pattern?)
871
+ - \`POST /api/workspace-ops/:integrationId/diff\` (body: organizationId, specPath, baseline?, breakingOnly?)
872
+
873
+ ## Repo resolution
874
+
875
+ - The repo root is resolved from the Studio Integration (\`IntegrationProvider.GITHUB\`) config:
876
+ - \`config.repoCachePath\` (preferred) or \`config.localPath\`
877
+ - Resolution is constrained to \`CONTRACTSPEC_REPO_CACHE_DIR\` (default: \`/tmp/contractspec-repos\`)
878
+
879
+ ## Intended UX
880
+
881
+ - Studio Assistant can run these checks and present results as suggestions.
882
+ - Users can copy equivalent CLI commands for local runs:
883
+ - \`contractspec validate\`
884
+ - \`contractspec deps\`
885
+ - \`contractspec diff --baseline <ref>\`
886
+ `
887
+ }];
888
+ registerDocBlocks(tech_studio_workspace_ops_DocBlocks);
889
+
890
+ //#endregion
891
+ //#region ../../libs/contracts/src/docs/tech/studio/project-routing.docblock.ts
892
+ const tech_studio_project_routing_DocBlocks = [{
893
+ id: "docs.tech.studio.project-routing",
894
+ title: "Studio Project Routing",
895
+ summary: "Studio uses slugged, project-first routes: /studio/{projectSlug}/* with canonical slug redirects and soft-deleted projects hidden.",
896
+ kind: "reference",
897
+ visibility: "public",
898
+ route: "/docs/tech/studio/project-routing",
899
+ tags: [
900
+ "studio",
901
+ "routing",
902
+ "projects",
903
+ "slug",
904
+ "redirects"
905
+ ],
906
+ body: `# Studio Project Routing
907
+
908
+ ContractSpec Studio uses a **project-first URL scheme**:
909
+
910
+ - \`/studio/projects\` — create, select, and delete projects.
911
+ - \`/studio/{projectSlug}/*\` — project modules (canvas/specs/deploy/integrations/evolution/learning).
912
+ - \`/studio/learning\` — learning hub that does not require selecting a project.
913
+
914
+ ## Studio layout shell
915
+
916
+ Studio routes are wrapped in a dedicated **Studio app shell** (header + footer) that provides in-app navigation (Projects/Learning/Teams), organization switching, and account actions.
917
+
918
+ Project module routes (\`/studio/{projectSlug}/*\`) render their own module shell (\`WorkspaceProjectShellLayout\`). When combined with the global Studio header, the project shell uses a **sticky header offset** to avoid overlapping sticky headers.
919
+
920
+ ## Slug behavior (rename-safe)
921
+
922
+ - Each project has a \`slug\` stored in the database (\`StudioProject.slug\`).
923
+ - When a project name changes, Studio **updates the slug** and stores the previous slug as an alias (\`StudioProjectSlugAlias\`).
924
+ - Requests to an alias slug are **redirected to the canonical slug**.
925
+
926
+ GraphQL entrypoint:
927
+
928
+ - \`studioProjectBySlug(slug: String!)\` returns:
929
+ - \`project\`
930
+ - \`canonicalSlug\`
931
+ - \`wasRedirect\`
932
+
933
+ ## Deletion behavior (soft delete)
934
+
935
+ Projects are **soft-deleted**:
936
+
937
+ - \`deleteStudioProject(id: String!)\` sets \`StudioProject.deletedAt\`.
938
+ - All listings and access checks filter \`deletedAt = null\`.
939
+ - Soft-deleted projects are treated as “not found” in Studio routes and GraphQL access checks.
940
+
941
+ ## Available modules for a selected project
942
+
943
+ The following project modules are expected under \`/studio/{projectSlug}\`:
944
+
945
+ - \`/canvas\` — Visual builder canvas (stored via overlays and canvas versions).
946
+ - \`/specs\` — Spec editor (stored as \`StudioSpec\`).
947
+ - \`/deploy\` — Deployments history + triggers (stored as \`StudioDeployment\`).
948
+ - \`/integrations\` — Integrations scoped to project (stored as \`StudioIntegration\`).
949
+ - \`/evolution\` — Evolution sessions (stored as \`EvolutionSession\`).
950
+ - \`/learning\` — Project learning activity.
951
+ `
952
+ }];
953
+ registerDocBlocks(tech_studio_project_routing_DocBlocks);
954
+
955
+ //#endregion
956
+ //#region ../../libs/contracts/src/docs/tech/studio/platform-admin-panel.docblock.ts
957
+ const tech_studio_platform_admin_panel_DocBlocks = [{
958
+ id: "docs.tech.studio.platform-admin-panel",
959
+ title: "Studio Platform Admin Panel",
960
+ summary: "How PLATFORM_ADMIN organizations manage tenant orgs and integration connections without session switching.",
961
+ kind: "reference",
962
+ visibility: "public",
963
+ route: "/docs/tech/studio/platform-admin-panel",
964
+ tags: [
965
+ "studio",
966
+ "admin",
967
+ "multi-tenancy",
968
+ "integrations",
969
+ "better-auth"
970
+ ],
971
+ body: `# Studio Platform Admin Panel
972
+
973
+ ContractSpec Studio exposes a dedicated **Platform Admin Panel** for users whose **active organization** has:
974
+
975
+ - \`Organization.type = PLATFORM_ADMIN\`
976
+
977
+ The UI route is:
978
+
979
+ - \`/studio/admin\`
980
+
981
+ ## Authorization model (no org switching)
982
+
983
+ Platform admins **remain in their own organization**. Cross-tenant actions are always explicit and scoped:
984
+
985
+ - Admin operations require an explicit \`targetOrganizationId\`.
986
+ - No session / activeOrganizationId switching is performed as part of admin operations.
987
+
988
+ ## Integrations management
989
+
990
+ The admin panel manages the full ContractSpec Integrations system:
991
+
992
+ - Lists all shipped \`IntegrationSpec\` entries (registry built via \`createDefaultIntegrationSpecRegistry()\`).
993
+ - CRUD \`IntegrationConnection\` records for a selected tenant org.
994
+
995
+ ### Secrets (reference-only + write-only)
996
+
997
+ The admin UI supports two modes:
998
+
999
+ - **Reference-only (BYOK)**: store only \`secretProvider\` + \`secretRef\`.
1000
+ - **Write-only provisioning/rotation**: paste a raw secret payload; server writes to the selected backend and stores the resulting reference. The secret value is **never returned or displayed**.
1001
+
1002
+ Supported backends:
1003
+
1004
+ - Env overrides (\`env://...\`)
1005
+ - Google Cloud Secret Manager (\`gcp://...\`)
1006
+ - AWS Secrets Manager (\`aws://secretsmanager/...\`)
1007
+ - Scaleway Secret Manager (\`scw://secret-manager/...\`)
1008
+
1009
+ ## Better Auth Admin plugin
1010
+
1011
+ The panel uses the Better Auth **Admin plugin** for user operations (list users, impersonation):
1012
+
1013
+ - Client calls use \`authClient.admin.*\`.
1014
+ - Server-side, ContractSpec enforces that users in a PLATFORM_ADMIN active org have \`User.role\` containing \`admin\` so Better Auth Admin endpoints authorize.
1015
+
1016
+ ## GraphQL surface
1017
+
1018
+ The platform-admin GraphQL operations are guarded by the active org type and include:
1019
+
1020
+ - \`platformAdminOrganizations(search, limit, offset)\`
1021
+ - \`platformAdminIntegrationSpecs\`
1022
+ - \`platformAdminIntegrationConnections(input: { targetOrganizationId, category?, status? })\`
1023
+ - \`platformAdminIntegrationConnectionCreate(input)\`
1024
+ - \`platformAdminIntegrationConnectionUpdate(input)\`
1025
+ - \`platformAdminIntegrationConnectionDelete(targetOrganizationId, connectionId)\`
1026
+
1027
+ ## Key implementation files
1028
+
1029
+ - Auth + role enforcement: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
1030
+ - Admin GraphQL module: \`packages/bundles/contractspec-studio/src/infrastructure/graphql/modules/platform-admin.ts\`
1031
+ - Integrations admin service: \`packages/bundles/contractspec-studio/src/modules/platform-integrations/index.ts\`
1032
+ - Web route: \`packages/apps/web-landing/src/app/(app-customer)/studio/admin/*\`
1033
+ `
1034
+ }];
1035
+ registerDocBlocks(tech_studio_platform_admin_panel_DocBlocks);
1036
+
1037
+ //#endregion
1038
+ //#region ../../libs/contracts/src/docs/tech/studio/learning-events.docblock.ts
1039
+ const tech_studio_learning_events_DocBlocks = [{
1040
+ id: "docs.tech.studio.learning-events",
1041
+ title: "Studio Learning Events",
1042
+ summary: "Studio persists learning/activity events to the database; Sandbox keeps learning local-first and unlogged.",
1043
+ kind: "reference",
1044
+ visibility: "public",
1045
+ route: "/docs/tech/studio/learning-events",
1046
+ tags: [
1047
+ "studio",
1048
+ "learning",
1049
+ "events",
1050
+ "analytics",
1051
+ "sandbox"
1052
+ ],
1053
+ body: `# Studio Learning Events
1054
+
1055
+ Studio emits lightweight **learning/activity events** to support onboarding, ambient coaching, and learning journeys.
1056
+
1057
+ ## Persistence model
1058
+
1059
+ - **Studio**: events are persisted to the database in \`StudioLearningEvent\` and are organization-scoped (optionally project-scoped).
1060
+ - **Sandbox**: events remain **local-only** (unlogged); they must never be sent to backend services.
1061
+
1062
+ ## GraphQL API
1063
+
1064
+ - \`recordLearningEvent(input: { name, projectId?, payload? })\`
1065
+ - \`myLearningEvents(projectId?, limit?)\`
1066
+ - \`myOnboardingTracks(productId?, includeProgress?)\`
1067
+ - \`myOnboardingProgress(trackKey)\`
1068
+ - \`dismissOnboardingTrack(trackKey)\`
1069
+
1070
+ ## Common event names (convention)
1071
+
1072
+ - \`module.navigated\` — user navigated to a Studio module (payload at minimum: \`{ moduleId }\`).
1073
+ - \`studio.template.instantiated\` — created a new Studio project (starter template). Payload commonly includes \`{ templateId, projectSlug }\`.
1074
+ - \`spec.changed\` — created or updated a Studio spec. Payload may include \`{ action: 'create' | 'update', specId?, specType? }\`.
1075
+ - \`regeneration.completed\` — finished a “regen/deploy” action (currently emitted on successful Studio deploy actions).
1076
+ - \`studio.evolution.applied\` — completed an Evolution session (payload commonly includes \`{ evolutionSessionId }\`).
1077
+
1078
+ These events are intentionally minimal and must avoid PII/secrets in payloads.
1079
+ `
1080
+ }];
1081
+ registerDocBlocks(tech_studio_learning_events_DocBlocks);
1082
+
1083
+ //#endregion
1084
+ //#region ../../libs/contracts/src/docs/tech/studio/learning-journeys.docblock.ts
1085
+ const tech_studio_learning_journeys_DocBlocks = [{
1086
+ id: "docs.tech.studio.learning-journeys",
1087
+ title: "Studio learning journeys (onboarding + coach)",
1088
+ summary: "DB-backed learning journeys tracked per organization: seeded tracks/steps, event-driven progress, XP/streaks, and a Studio coach surface.",
1089
+ kind: "reference",
1090
+ visibility: "public",
1091
+ route: "/docs/tech/studio/learning-journeys",
1092
+ tags: [
1093
+ "studio",
1094
+ "learning",
1095
+ "onboarding",
1096
+ "journey",
1097
+ "graphql",
1098
+ "database"
1099
+ ],
1100
+ body: `# Studio learning journeys
1101
+
1102
+ Studio supports **DB-backed learning journeys** (onboarding tracks + ambient coach tips) that are advanced by **recorded learning events**.
1103
+
1104
+ > See also: \`/docs/tech/studio/learning-events\` for event naming + payload guardrails.
1105
+
1106
+ ## Scope (multi-tenancy)
1107
+
1108
+ - Progress is tracked **per organization** (tenant/workspace), via a \`Learner\` record keyed by \`(userId, organizationId)\`.
1109
+ - Learning events are stored as \`StudioLearningEvent\` under the Studio DB schema, scoped to an organization (optionally a project).
1110
+
1111
+ ## Persistence model (Prisma)
1112
+
1113
+ Learning journey progress lives in the \`lssm_learning\` schema:
1114
+
1115
+ - \`Learner\` — one per \`(userId, organizationId)\`
1116
+ - \`OnboardingTrack\` — seeded track definitions (trackKey, name, metadata)
1117
+ - \`OnboardingStep\` — seeded step definitions (stepKey, completionCondition, xpReward, metadata)
1118
+ - \`OnboardingProgress\` — learner × track progress (progress %, xpEarned, completedAt, dismissedAt)
1119
+ - \`OnboardingStepCompletion\` — append-only completion records (stepKey, status, xpEarned, completedAt)
1120
+
1121
+ ## Track definition source (spec-first)
1122
+
1123
+ - Canonical track specs live in \`@lssm/example.learning-journey-registry\`.
1124
+ - The Studio API seeds/updates the DB definitions via an idempotent “ensure tracks” routine.
1125
+ - The DB is kept aligned with track specs (stale steps are removed) to prevent drift and unblock completion.
1126
+
1127
+ ## Progress advancement (event-driven)
1128
+
1129
+ 1) UI records an event via GraphQL \`recordLearningEvent\`
1130
+ 2) Backend creates \`StudioLearningEvent\`
1131
+ 3) Backend advances onboarding by matching the new event against step completion conditions
1132
+ 4) Backend persists step completions and recomputes:
1133
+ - \`progress\` percentage
1134
+ - \`xpEarned\` (including streak/completion bonuses when configured)
1135
+ - track completion state (\`completedAt\`)
1136
+
1137
+ ## GraphQL API (Studio)
1138
+
1139
+ - \`myOnboardingTracks(productId?, includeProgress?)\`
1140
+ - returns all tracks + optional progress for the current learner
1141
+ - \`myOnboardingProgress(trackKey)\`
1142
+ - returns progress + step completion list for a single track
1143
+ - \`dismissOnboardingTrack(trackKey)\`
1144
+ - marks a track dismissed for the learner (prevents auto-coach)
1145
+
1146
+ ## UI routes/surfaces (web)
1147
+
1148
+ - \`/studio/learning\` — learning hub (track list + progress widget)
1149
+ - \`/studio/learning/{trackKey}\` — track detail (steps + map)
1150
+ - Studio shell mounts a **coach sheet** that can auto-open for incomplete, non-dismissed onboarding.
1151
+
1152
+ ## Security + data hygiene
1153
+
1154
+ - Do not put secrets/PII in \`payload\` fields of learning events.
1155
+ - Prefer shallow payload filters (small, stable keys).
1156
+ `
1157
+ }];
1158
+ registerDocBlocks(tech_studio_learning_journeys_DocBlocks);
1159
+
1160
+ //#endregion
1161
+ //#region ../../libs/contracts/src/docs/tech/studio/project-access-teams.docblock.ts
1162
+ const tech_studio_project_access_teams_DocBlocks = [{
1163
+ id: "docs.tech.studio.project-access-teams",
1164
+ title: "Studio Project Access via Teams",
1165
+ summary: "Projects live under organizations; team sharing refines access with an admin/owner override.",
1166
+ kind: "reference",
1167
+ visibility: "public",
1168
+ route: "/docs/tech/studio/project-access-teams",
1169
+ tags: [
1170
+ "studio",
1171
+ "projects",
1172
+ "teams",
1173
+ "rbac",
1174
+ "access-control"
1175
+ ],
1176
+ body: `# Studio Project Access via Teams
1177
+
1178
+ Studio access control is **organization-first** with optional **team-based sharing**.
1179
+
1180
+ ## Data model
1181
+
1182
+ - \`Team\` and \`TeamMember\` define team membership inside an organization.
1183
+ - \`StudioProject\` is owned by an organization.
1184
+ - \`StudioProjectTeam\` links projects to 0..N teams.
1185
+
1186
+ ## Access rules
1187
+
1188
+ - **Admins/owners**: always have access to all projects in the organization.
1189
+ - **Org-wide projects**: if a project has **no team links**, all organization members can access it.
1190
+ - **Team-scoped projects**: if a project has **one or more team links**, a user must be a member of at least one linked team.
1191
+
1192
+ ## GraphQL surfaces
1193
+
1194
+ - Read:\n - \`myStudioProjects\` (returns only projects you can access)\n - \`studioProjectBySlug(slug)\` (enforces the same access rules)\n - \`myTeams\`\n - \`projectTeams(projectId)\`\n\n- Write:\n - \`createStudioProject(input.teamIds?)\` (teamIds optional)\n - \`setProjectTeams(projectId, teamIds)\` (admin-only)\n
1195
+ ## Related\n+\n+- Team administration + invitations: see \`/docs/tech/studio/team-invitations\`.\n+
1196
+ ## Notes
1197
+
1198
+ Payloads and events must avoid secrets/PII. For Sandbox, the model remains local-first and unlogged.
1199
+ `
1200
+ }];
1201
+ registerDocBlocks(tech_studio_project_access_teams_DocBlocks);
1202
+
1203
+ //#endregion
1204
+ //#region ../../libs/contracts/src/docs/tech/studio/team-invitations.docblock.ts
1205
+ const tech_studio_team_invitations_DocBlocks = [{
1206
+ id: "docs.tech.studio.team-invitations",
1207
+ title: "Studio Teams & Invitations",
1208
+ summary: "Admin-only team management and email invitation flow to join an organization and optionally a team.",
1209
+ kind: "reference",
1210
+ visibility: "public",
1211
+ route: "/docs/tech/studio/team-invitations",
1212
+ tags: [
1213
+ "studio",
1214
+ "teams",
1215
+ "invitations",
1216
+ "access-control",
1217
+ "onboarding"
1218
+ ],
1219
+ body: `# Studio Teams & Invitations
1220
+
1221
+ Studio uses **organization membership** as the base access model. Teams are optional and used to refine access to projects.
1222
+
1223
+ ## Who can manage teams?
1224
+
1225
+ - **Admins/owners only**: create, rename, delete teams; manage project team access; issue invitations.
1226
+
1227
+ ## Invitation data model
1228
+
1229
+ - \`Invitation\` rows are stored under an organization and target an **email** address.\n
1230
+ - An invitation can optionally target a \`teamId\`, which will grant the user membership in that team upon acceptance.
1231
+
1232
+ Key fields:
1233
+ - \`email\`: invited address (must match the accepting user's account email)\n
1234
+ - \`status\`: \`pending | accepted | declined | expired\`\n
1235
+ - \`teamId?\`: optional team to join\n
1236
+ - \`inviterId\`: user who issued the invitation
1237
+
1238
+ ## GraphQL surfaces
1239
+
1240
+ - Team CRUD (admin-only):\n
1241
+ - \`createTeam(name)\`\n
1242
+ - \`renameTeam(teamId, name)\`\n
1243
+ - \`deleteTeam(teamId)\`\n
1244
+
1245
+ - Invitations (admin-only):\n
1246
+ - \`organizationInvitations\`\n
1247
+ - \`inviteToOrganization(email, role?, teamId?)\` → returns \`inviteUrl\` and whether an email was sent
1248
+
1249
+ ## Accepting an invitation
1250
+
1251
+ The invite link is served as:\n
1252
+ - \`/invite/{invitationId}\`
1253
+
1254
+ Acceptance rules:
1255
+ - The user must be authenticated.\n
1256
+ - The authenticated user’s email must match \`Invitation.email\`.\n
1257
+ - If not already a member, create \`Member(userId, organizationId, role)\`.\n
1258
+ - If \`teamId\` is present, ensure \`TeamMember(teamId, userId)\`.\n
1259
+ - Mark invitation \`status='accepted'\` and set \`acceptedAt\`.\n
1260
+ - Set \`activeOrganizationId\` for the session so \`/studio/*\` routes work immediately.
1261
+
1262
+ ## Email delivery
1263
+
1264
+ - If \`RESEND_API_KEY\` is set, the system attempts to send an email.\n
1265
+ - Otherwise, the UI uses the returned \`inviteUrl\` for manual copy/share.
1266
+ `
1267
+ }];
1268
+ registerDocBlocks(tech_studio_team_invitations_DocBlocks);
1269
+
669
1270
  //#endregion
670
1271
  //#region src/docs/learning-journey-ui-shared.docblock.ts
671
1272
  registerDocBlocks([{