@lssm/example.learning-journey-ui-onboarding 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,12 +1,12 @@
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-onboarding/tsdown.config.js
5
5
  ℹ entry: src/index.ts, src/views/index.ts, src/components/index.ts
6
6
  ℹ target: esnext
7
7
  ℹ tsconfig: tsconfig.json
8
8
  ℹ Build start
9
- ℹ dist/index.mjs 100.15 kB │ gzip: 34.06 kB
9
+ ℹ dist/index.mjs 123.86 kB │ gzip: 41.01 kB
10
10
  ℹ dist/views/index.mjs  0.20 kB │ gzip: 0.15 kB
11
11
  ℹ dist/components/index.mjs  0.20 kB │ gzip: 0.15 kB
12
12
  ℹ dist/views-DBF-jKGQ.mjs  20.13 kB │ gzip: 3.57 kB
@@ -17,6 +17,6 @@ $ tsdown
17
17
  ℹ dist/components/index.d.mts  0.14 kB │ gzip: 0.13 kB
18
18
  ℹ dist/index-BsbXKz4M.d.mts  1.22 kB │ gzip: 0.46 kB
19
19
  ℹ dist/index-BNYp4weX.d.mts  0.93 kB │ gzip: 0.34 kB
20
- ℹ 11 files, total: 131.72 kB
21
- ✔ Build complete in 8669ms
20
+ ℹ 11 files, total: 155.42 kB
21
+ ✔ Build complete in 6809ms
22
22
  $ tsc --noEmit
package/CHANGELOG.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @lssm/example.learning-journey-ui-onboarding
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/example.learning-journey-ui-shared@0.0.0-canary-20251213172311
11
- - @lssm/example.learning-journey-platform-tour@0.0.0-canary-20251213172311
12
- - @lssm/example.learning-journey-studio-onboarding@0.0.0-canary-20251213172311
13
- - @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/example.learning-journey-ui-shared@0.0.0-canary-20251215220103
11
+ - @lssm/example.learning-journey-platform-tour@0.0.0-canary-20251215220103
12
+ - @lssm/example.learning-journey-studio-onboarding@0.0.0-canary-20251215220103
13
+ - @lssm/module.learning-journey@0.0.0-canary-20251215220103
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as CodeSnippet, r as StepChecklist, t as JourneyMap } from "./index-BsbXKz4M.mjs";
2
2
  import { i as Overview, n as ProgressView, r as Steps, t as Timeline } from "./index-BNYp4weX.mjs";
3
3
  import { LearningMiniAppProps } from "@lssm/example.learning-journey-ui-shared";
4
- import * as react_jsx_runtime6 from "react/jsx-runtime";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
 
6
6
  //#region src/OnboardingMiniApp.d.ts
7
7
  type OnboardingMiniAppProps = Omit<LearningMiniAppProps, 'progress'> & {
@@ -13,7 +13,7 @@ declare function OnboardingMiniApp({
13
13
  onStepComplete: externalOnStepComplete,
14
14
  onViewChange,
15
15
  initialView
16
- }: OnboardingMiniAppProps): react_jsx_runtime6.JSX.Element;
16
+ }: OnboardingMiniAppProps): react_jsx_runtime0.JSX.Element;
17
17
  //#endregion
18
18
  //#region src/example.d.ts
19
19
  declare const example: {
package/dist/index.mjs CHANGED
@@ -325,6 +325,84 @@ const tech_presentation_runtime_DocBlocks = [{
325
325
  }];
326
326
  registerDocBlocks(tech_presentation_runtime_DocBlocks);
327
327
 
328
+ //#endregion
329
+ //#region ../../libs/contracts/src/docs/tech/auth/better-auth-nextjs.docblock.ts
330
+ const tech_auth_better_auth_nextjs_DocBlocks = [{
331
+ id: "docs.tech.auth.better-auth-nextjs",
332
+ title: "Better Auth + Next.js integration (ContractSpec)",
333
+ summary: "How ContractSpec wires Better Auth into Next.js (server config, client singleton, and proxy cookie-only redirects).",
334
+ kind: "reference",
335
+ visibility: "public",
336
+ route: "/docs/tech/auth/better-auth-nextjs",
337
+ tags: [
338
+ "auth",
339
+ "better-auth",
340
+ "nextjs",
341
+ "cookies",
342
+ "proxy",
343
+ "hmr"
344
+ ],
345
+ body: `# Better Auth + Next.js integration (ContractSpec)
346
+
347
+ This repo uses Better Auth as the primary auth layer (sessions, organizations, teams, API keys, and OAuth).
348
+
349
+ ## Server config (Better Auth)
350
+
351
+ - Source: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
352
+ - Important: \`nextCookies()\` must be the **last** plugin in the Better Auth plugin list so \`Set-Cookie\` is applied correctly in Next.js environments.
353
+
354
+ ## Better Auth Admin plugin
355
+
356
+ ContractSpec Studio enables the Better Auth **Admin plugin** to support platform-admin user operations (list users, impersonation, etc.).
357
+
358
+ - Server: \`admin()\` plugin in \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
359
+ - Client: \`adminClient()\` in \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
360
+
361
+ ### PLATFORM_ADMIN ⇒ Better Auth admin role
362
+
363
+ Better Auth Admin endpoints authorize via \`user.role\`. ContractSpec enforces an org-driven rule:
364
+
365
+ - If the **active organization** has \`type = PLATFORM_ADMIN\`, the signed-in user is ensured to have \`User.role\` containing \`admin\`.
366
+ - This is applied in the session creation hook and re-checked in \`assertsPlatformAdmin()\`.
367
+
368
+ This keeps admin enablement deterministic and avoids manual role backfills.
369
+
370
+ ## Client config (React web + Expo)
371
+
372
+ To avoid duplicate background refresh/polling loops in dev (Fast Refresh/HMR), the Better Auth client is implemented as a singleton cached on \`globalThis\`.
373
+
374
+ - Web client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
375
+ - Native client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.native.ts\`
376
+
377
+ Import guidance:
378
+
379
+ - If you only need the context/hook, prefer importing from \`@lssm/bundle.contractspec-studio/presentation/providers/auth\`.
380
+ - 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\`.
381
+
382
+ ## Public routes (login / signup)
383
+
384
+ Public auth pages should avoid eager \`authClient\` initialization.
385
+
386
+ Pattern used:
387
+
388
+ - In the submit handler, dynamically import \`@lssm/bundle.contractspec-studio/presentation/providers/auth/index.web\` and call \`authClient.signIn.*\` / \`authClient.signUp.*\`.
389
+
390
+ This prevents session refresh behavior from starting just because a public page rendered.
391
+
392
+ ## Next.js proxy auth (web-landing)
393
+
394
+ The Next.js proxy/middleware is used for **redirect decisions only**. It must not perform DB-backed session reads on every request.
395
+
396
+ - Source: \`packages/apps/web-landing/src/proxy.ts\`
397
+ - Approach: cookie-only checks via Better Auth cookies helpers:
398
+ - \`getSessionCookie(request)\`
399
+ - \`getCookieCache(request)\`
400
+
401
+ These checks are intentionally optimistic and should only gate routing. Full authorization must still be enforced on server-side actions/routes and GraphQL resolvers.
402
+ `
403
+ }];
404
+ registerDocBlocks(tech_auth_better_auth_nextjs_DocBlocks);
405
+
328
406
  //#endregion
329
407
  //#region ../../libs/contracts/src/docs/tech/schema/README.docblock.ts
330
408
  const tech_schema_README_DocBlocks = [{
@@ -721,6 +799,529 @@ The registry module must export one of:
721
799
  }];
722
800
  registerDocBlocks(tech_contracts_openapi_export_DocBlocks);
723
801
 
802
+ //#endregion
803
+ //#region ../../libs/contracts/src/docs/tech/studio/workspaces.docblock.ts
804
+ const tech_studio_workspaces_DocBlocks = [{
805
+ id: "docs.tech.studio.workspaces",
806
+ title: "Studio projects, teams, environments",
807
+ summary: "Organization-first Studio: projects live under an organization; teams refine access; projects deploy to multiple environments.",
808
+ kind: "reference",
809
+ visibility: "mixed",
810
+ route: "/docs/tech/studio/workspaces",
811
+ tags: [
812
+ "studio",
813
+ "projects",
814
+ "teams",
815
+ "rbac",
816
+ "environments"
817
+ ],
818
+ body: `## Concepts
819
+
820
+ - **Organization**: the primary grouping boundary for Studio projects.
821
+ - **Project**: one application (specs, overlays, deployments, integrations, evolution, learning).
822
+ - **Team**: refines who can see/edit a project within an organization.
823
+ - **Environment**: deployment target (Development / Staging / Production).
824
+
825
+ ## Project access (teams + admin override)
826
+
827
+ Studio uses multi-team sharing to refine access:
828
+
829
+ - **Admins/owners** can access all projects.
830
+ - If a project is shared with **no teams**, it is **org-wide** (all org members).
831
+ - If a project is shared with **one or more teams**, it is visible to:
832
+ - admins/owners, and
833
+ - members of any linked team.
834
+
835
+ ## Current persistence (DB + GraphQL)
836
+
837
+ - DB (Prisma): \`StudioProject\`, \`Team\`, \`TeamMember\`, \`StudioProjectTeam\`
838
+ - GraphQL:
839
+ - \`myStudioProjects\`
840
+ - \`createStudioProject(input.teamIds?)\`
841
+ - \`myTeams\`
842
+ - \`projectTeams(projectId)\`
843
+ - \`setProjectTeams(projectId, teamIds)\`
844
+
845
+ ## UI shell behavior
846
+
847
+ Studio and Sandbox both use a shared shell:
848
+
849
+ - Project selector → Module navigation → Environment selector
850
+ - Always-on Assistant button (floating)
851
+ - Learning journey progress (Studio persists learning events; Sandbox stays local-only)
852
+
853
+ ## Routing
854
+
855
+ - \`/studio/projects\`: create/select/delete projects (organization-first).
856
+ - \`/studio/{projectSlug}/*\`: project modules (canvas/specs/deploy/integrations/evolution/learning).
857
+ - \`/studio/learning\`: learning hub without selecting a project.
858
+ `
859
+ }];
860
+ registerDocBlocks(tech_studio_workspaces_DocBlocks);
861
+
862
+ //#endregion
863
+ //#region ../../libs/contracts/src/docs/tech/studio/sandbox-unlogged.docblock.ts
864
+ const tech_studio_sandbox_unlogged_DocBlocks = [{
865
+ id: "docs.tech.studio.sandbox.unlogged",
866
+ title: "Sandbox (unlogged) vs Studio (authenticated)",
867
+ summary: "The sandbox is a lightweight, unlogged surface that mirrors Studio navigation without auth or analytics.",
868
+ kind: "reference",
869
+ visibility: "public",
870
+ route: "/docs/tech/studio/sandbox-unlogged",
871
+ tags: [
872
+ "studio",
873
+ "sandbox",
874
+ "privacy",
875
+ "analytics"
876
+ ],
877
+ body: `## Sandbox guarantees
878
+
879
+ - Route: \`/sandbox\`
880
+ - **No auth requirement**
881
+ - **No PostHog init**
882
+ - **No Vercel Analytics**
883
+ - Local-only state (in-browser runtime + localStorage where needed)
884
+
885
+ ## What Sandbox is for
886
+
887
+ - Try templates and feature modules safely
888
+ - Preview specs/builder/evolution/learning
889
+ - Produce copyable CLI commands (no side effects)
890
+
891
+ ## What Sandbox is *not* for
892
+
893
+ - Persisted projects/workspaces
894
+ - Real deployments
895
+ - Organization-scoped integrations (unless explicitly enabled later)
896
+ `
897
+ }];
898
+ registerDocBlocks(tech_studio_sandbox_unlogged_DocBlocks);
899
+
900
+ //#endregion
901
+ //#region ../../libs/contracts/src/docs/tech/studio/workspace-ops.docblock.ts
902
+ const tech_studio_workspace_ops_DocBlocks = [{
903
+ id: "docs.tech.studio.workspace_ops",
904
+ title: "Workspace ops (repo-linked): list / validate / deps / diff",
905
+ summary: "Read-only repo operations used by Studio to inspect and validate a linked ContractSpec workspace.",
906
+ kind: "reference",
907
+ visibility: "mixed",
908
+ route: "/docs/tech/studio/workspace-ops",
909
+ tags: [
910
+ "studio",
911
+ "repo",
912
+ "workspace",
913
+ "validate",
914
+ "diff"
915
+ ],
916
+ body: `## API surface (api-contractspec)
917
+
918
+ Base: \`/api/workspace-ops\`
919
+
920
+ These endpoints are **read-only** in v1 and never push to git:
921
+
922
+ - \`GET /api/workspace-ops/:integrationId/config?organizationId=\`
923
+ - \`GET /api/workspace-ops/:integrationId/specs?organizationId=\`
924
+ - \`POST /api/workspace-ops/:integrationId/validate\` (body: organizationId, files?, pattern?)
925
+ - \`POST /api/workspace-ops/:integrationId/deps\` (body: organizationId, pattern?)
926
+ - \`POST /api/workspace-ops/:integrationId/diff\` (body: organizationId, specPath, baseline?, breakingOnly?)
927
+
928
+ ## Repo resolution
929
+
930
+ - The repo root is resolved from the Studio Integration (\`IntegrationProvider.GITHUB\`) config:
931
+ - \`config.repoCachePath\` (preferred) or \`config.localPath\`
932
+ - Resolution is constrained to \`CONTRACTSPEC_REPO_CACHE_DIR\` (default: \`/tmp/contractspec-repos\`)
933
+
934
+ ## Intended UX
935
+
936
+ - Studio Assistant can run these checks and present results as suggestions.
937
+ - Users can copy equivalent CLI commands for local runs:
938
+ - \`contractspec validate\`
939
+ - \`contractspec deps\`
940
+ - \`contractspec diff --baseline <ref>\`
941
+ `
942
+ }];
943
+ registerDocBlocks(tech_studio_workspace_ops_DocBlocks);
944
+
945
+ //#endregion
946
+ //#region ../../libs/contracts/src/docs/tech/studio/project-routing.docblock.ts
947
+ const tech_studio_project_routing_DocBlocks = [{
948
+ id: "docs.tech.studio.project-routing",
949
+ title: "Studio Project Routing",
950
+ summary: "Studio uses slugged, project-first routes: /studio/{projectSlug}/* with canonical slug redirects and soft-deleted projects hidden.",
951
+ kind: "reference",
952
+ visibility: "public",
953
+ route: "/docs/tech/studio/project-routing",
954
+ tags: [
955
+ "studio",
956
+ "routing",
957
+ "projects",
958
+ "slug",
959
+ "redirects"
960
+ ],
961
+ body: `# Studio Project Routing
962
+
963
+ ContractSpec Studio uses a **project-first URL scheme**:
964
+
965
+ - \`/studio/projects\` — create, select, and delete projects.
966
+ - \`/studio/{projectSlug}/*\` — project modules (canvas/specs/deploy/integrations/evolution/learning).
967
+ - \`/studio/learning\` — learning hub that does not require selecting a project.
968
+
969
+ ## Studio layout shell
970
+
971
+ 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.
972
+
973
+ 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.
974
+
975
+ ## Slug behavior (rename-safe)
976
+
977
+ - Each project has a \`slug\` stored in the database (\`StudioProject.slug\`).
978
+ - When a project name changes, Studio **updates the slug** and stores the previous slug as an alias (\`StudioProjectSlugAlias\`).
979
+ - Requests to an alias slug are **redirected to the canonical slug**.
980
+
981
+ GraphQL entrypoint:
982
+
983
+ - \`studioProjectBySlug(slug: String!)\` returns:
984
+ - \`project\`
985
+ - \`canonicalSlug\`
986
+ - \`wasRedirect\`
987
+
988
+ ## Deletion behavior (soft delete)
989
+
990
+ Projects are **soft-deleted**:
991
+
992
+ - \`deleteStudioProject(id: String!)\` sets \`StudioProject.deletedAt\`.
993
+ - All listings and access checks filter \`deletedAt = null\`.
994
+ - Soft-deleted projects are treated as “not found” in Studio routes and GraphQL access checks.
995
+
996
+ ## Available modules for a selected project
997
+
998
+ The following project modules are expected under \`/studio/{projectSlug}\`:
999
+
1000
+ - \`/canvas\` — Visual builder canvas (stored via overlays and canvas versions).
1001
+ - \`/specs\` — Spec editor (stored as \`StudioSpec\`).
1002
+ - \`/deploy\` — Deployments history + triggers (stored as \`StudioDeployment\`).
1003
+ - \`/integrations\` — Integrations scoped to project (stored as \`StudioIntegration\`).
1004
+ - \`/evolution\` — Evolution sessions (stored as \`EvolutionSession\`).
1005
+ - \`/learning\` — Project learning activity.
1006
+ `
1007
+ }];
1008
+ registerDocBlocks(tech_studio_project_routing_DocBlocks);
1009
+
1010
+ //#endregion
1011
+ //#region ../../libs/contracts/src/docs/tech/studio/platform-admin-panel.docblock.ts
1012
+ const tech_studio_platform_admin_panel_DocBlocks = [{
1013
+ id: "docs.tech.studio.platform-admin-panel",
1014
+ title: "Studio Platform Admin Panel",
1015
+ summary: "How PLATFORM_ADMIN organizations manage tenant orgs and integration connections without session switching.",
1016
+ kind: "reference",
1017
+ visibility: "public",
1018
+ route: "/docs/tech/studio/platform-admin-panel",
1019
+ tags: [
1020
+ "studio",
1021
+ "admin",
1022
+ "multi-tenancy",
1023
+ "integrations",
1024
+ "better-auth"
1025
+ ],
1026
+ body: `# Studio Platform Admin Panel
1027
+
1028
+ ContractSpec Studio exposes a dedicated **Platform Admin Panel** for users whose **active organization** has:
1029
+
1030
+ - \`Organization.type = PLATFORM_ADMIN\`
1031
+
1032
+ The UI route is:
1033
+
1034
+ - \`/studio/admin\`
1035
+
1036
+ ## Authorization model (no org switching)
1037
+
1038
+ Platform admins **remain in their own organization**. Cross-tenant actions are always explicit and scoped:
1039
+
1040
+ - Admin operations require an explicit \`targetOrganizationId\`.
1041
+ - No session / activeOrganizationId switching is performed as part of admin operations.
1042
+
1043
+ ## Integrations management
1044
+
1045
+ The admin panel manages the full ContractSpec Integrations system:
1046
+
1047
+ - Lists all shipped \`IntegrationSpec\` entries (registry built via \`createDefaultIntegrationSpecRegistry()\`).
1048
+ - CRUD \`IntegrationConnection\` records for a selected tenant org.
1049
+
1050
+ ### Secrets (reference-only + write-only)
1051
+
1052
+ The admin UI supports two modes:
1053
+
1054
+ - **Reference-only (BYOK)**: store only \`secretProvider\` + \`secretRef\`.
1055
+ - **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**.
1056
+
1057
+ Supported backends:
1058
+
1059
+ - Env overrides (\`env://...\`)
1060
+ - Google Cloud Secret Manager (\`gcp://...\`)
1061
+ - AWS Secrets Manager (\`aws://secretsmanager/...\`)
1062
+ - Scaleway Secret Manager (\`scw://secret-manager/...\`)
1063
+
1064
+ ## Better Auth Admin plugin
1065
+
1066
+ The panel uses the Better Auth **Admin plugin** for user operations (list users, impersonation):
1067
+
1068
+ - Client calls use \`authClient.admin.*\`.
1069
+ - Server-side, ContractSpec enforces that users in a PLATFORM_ADMIN active org have \`User.role\` containing \`admin\` so Better Auth Admin endpoints authorize.
1070
+
1071
+ ## GraphQL surface
1072
+
1073
+ The platform-admin GraphQL operations are guarded by the active org type and include:
1074
+
1075
+ - \`platformAdminOrganizations(search, limit, offset)\`
1076
+ - \`platformAdminIntegrationSpecs\`
1077
+ - \`platformAdminIntegrationConnections(input: { targetOrganizationId, category?, status? })\`
1078
+ - \`platformAdminIntegrationConnectionCreate(input)\`
1079
+ - \`platformAdminIntegrationConnectionUpdate(input)\`
1080
+ - \`platformAdminIntegrationConnectionDelete(targetOrganizationId, connectionId)\`
1081
+
1082
+ ## Key implementation files
1083
+
1084
+ - Auth + role enforcement: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
1085
+ - Admin GraphQL module: \`packages/bundles/contractspec-studio/src/infrastructure/graphql/modules/platform-admin.ts\`
1086
+ - Integrations admin service: \`packages/bundles/contractspec-studio/src/modules/platform-integrations/index.ts\`
1087
+ - Web route: \`packages/apps/web-landing/src/app/(app-customer)/studio/admin/*\`
1088
+ `
1089
+ }];
1090
+ registerDocBlocks(tech_studio_platform_admin_panel_DocBlocks);
1091
+
1092
+ //#endregion
1093
+ //#region ../../libs/contracts/src/docs/tech/studio/learning-events.docblock.ts
1094
+ const tech_studio_learning_events_DocBlocks = [{
1095
+ id: "docs.tech.studio.learning-events",
1096
+ title: "Studio Learning Events",
1097
+ summary: "Studio persists learning/activity events to the database; Sandbox keeps learning local-first and unlogged.",
1098
+ kind: "reference",
1099
+ visibility: "public",
1100
+ route: "/docs/tech/studio/learning-events",
1101
+ tags: [
1102
+ "studio",
1103
+ "learning",
1104
+ "events",
1105
+ "analytics",
1106
+ "sandbox"
1107
+ ],
1108
+ body: `# Studio Learning Events
1109
+
1110
+ Studio emits lightweight **learning/activity events** to support onboarding, ambient coaching, and learning journeys.
1111
+
1112
+ ## Persistence model
1113
+
1114
+ - **Studio**: events are persisted to the database in \`StudioLearningEvent\` and are organization-scoped (optionally project-scoped).
1115
+ - **Sandbox**: events remain **local-only** (unlogged); they must never be sent to backend services.
1116
+
1117
+ ## GraphQL API
1118
+
1119
+ - \`recordLearningEvent(input: { name, projectId?, payload? })\`
1120
+ - \`myLearningEvents(projectId?, limit?)\`
1121
+ - \`myOnboardingTracks(productId?, includeProgress?)\`
1122
+ - \`myOnboardingProgress(trackKey)\`
1123
+ - \`dismissOnboardingTrack(trackKey)\`
1124
+
1125
+ ## Common event names (convention)
1126
+
1127
+ - \`module.navigated\` — user navigated to a Studio module (payload at minimum: \`{ moduleId }\`).
1128
+ - \`studio.template.instantiated\` — created a new Studio project (starter template). Payload commonly includes \`{ templateId, projectSlug }\`.
1129
+ - \`spec.changed\` — created or updated a Studio spec. Payload may include \`{ action: 'create' | 'update', specId?, specType? }\`.
1130
+ - \`regeneration.completed\` — finished a “regen/deploy” action (currently emitted on successful Studio deploy actions).
1131
+ - \`studio.evolution.applied\` — completed an Evolution session (payload commonly includes \`{ evolutionSessionId }\`).
1132
+
1133
+ These events are intentionally minimal and must avoid PII/secrets in payloads.
1134
+ `
1135
+ }];
1136
+ registerDocBlocks(tech_studio_learning_events_DocBlocks);
1137
+
1138
+ //#endregion
1139
+ //#region ../../libs/contracts/src/docs/tech/studio/learning-journeys.docblock.ts
1140
+ const tech_studio_learning_journeys_DocBlocks = [{
1141
+ id: "docs.tech.studio.learning-journeys",
1142
+ title: "Studio learning journeys (onboarding + coach)",
1143
+ summary: "DB-backed learning journeys tracked per organization: seeded tracks/steps, event-driven progress, XP/streaks, and a Studio coach surface.",
1144
+ kind: "reference",
1145
+ visibility: "public",
1146
+ route: "/docs/tech/studio/learning-journeys",
1147
+ tags: [
1148
+ "studio",
1149
+ "learning",
1150
+ "onboarding",
1151
+ "journey",
1152
+ "graphql",
1153
+ "database"
1154
+ ],
1155
+ body: `# Studio learning journeys
1156
+
1157
+ Studio supports **DB-backed learning journeys** (onboarding tracks + ambient coach tips) that are advanced by **recorded learning events**.
1158
+
1159
+ > See also: \`/docs/tech/studio/learning-events\` for event naming + payload guardrails.
1160
+
1161
+ ## Scope (multi-tenancy)
1162
+
1163
+ - Progress is tracked **per organization** (tenant/workspace), via a \`Learner\` record keyed by \`(userId, organizationId)\`.
1164
+ - Learning events are stored as \`StudioLearningEvent\` under the Studio DB schema, scoped to an organization (optionally a project).
1165
+
1166
+ ## Persistence model (Prisma)
1167
+
1168
+ Learning journey progress lives in the \`lssm_learning\` schema:
1169
+
1170
+ - \`Learner\` — one per \`(userId, organizationId)\`
1171
+ - \`OnboardingTrack\` — seeded track definitions (trackKey, name, metadata)
1172
+ - \`OnboardingStep\` — seeded step definitions (stepKey, completionCondition, xpReward, metadata)
1173
+ - \`OnboardingProgress\` — learner × track progress (progress %, xpEarned, completedAt, dismissedAt)
1174
+ - \`OnboardingStepCompletion\` — append-only completion records (stepKey, status, xpEarned, completedAt)
1175
+
1176
+ ## Track definition source (spec-first)
1177
+
1178
+ - Canonical track specs live in \`@lssm/example.learning-journey-registry\`.
1179
+ - The Studio API seeds/updates the DB definitions via an idempotent “ensure tracks” routine.
1180
+ - The DB is kept aligned with track specs (stale steps are removed) to prevent drift and unblock completion.
1181
+
1182
+ ## Progress advancement (event-driven)
1183
+
1184
+ 1) UI records an event via GraphQL \`recordLearningEvent\`
1185
+ 2) Backend creates \`StudioLearningEvent\`
1186
+ 3) Backend advances onboarding by matching the new event against step completion conditions
1187
+ 4) Backend persists step completions and recomputes:
1188
+ - \`progress\` percentage
1189
+ - \`xpEarned\` (including streak/completion bonuses when configured)
1190
+ - track completion state (\`completedAt\`)
1191
+
1192
+ ## GraphQL API (Studio)
1193
+
1194
+ - \`myOnboardingTracks(productId?, includeProgress?)\`
1195
+ - returns all tracks + optional progress for the current learner
1196
+ - \`myOnboardingProgress(trackKey)\`
1197
+ - returns progress + step completion list for a single track
1198
+ - \`dismissOnboardingTrack(trackKey)\`
1199
+ - marks a track dismissed for the learner (prevents auto-coach)
1200
+
1201
+ ## UI routes/surfaces (web)
1202
+
1203
+ - \`/studio/learning\` — learning hub (track list + progress widget)
1204
+ - \`/studio/learning/{trackKey}\` — track detail (steps + map)
1205
+ - Studio shell mounts a **coach sheet** that can auto-open for incomplete, non-dismissed onboarding.
1206
+
1207
+ ## Security + data hygiene
1208
+
1209
+ - Do not put secrets/PII in \`payload\` fields of learning events.
1210
+ - Prefer shallow payload filters (small, stable keys).
1211
+ `
1212
+ }];
1213
+ registerDocBlocks(tech_studio_learning_journeys_DocBlocks);
1214
+
1215
+ //#endregion
1216
+ //#region ../../libs/contracts/src/docs/tech/studio/project-access-teams.docblock.ts
1217
+ const tech_studio_project_access_teams_DocBlocks = [{
1218
+ id: "docs.tech.studio.project-access-teams",
1219
+ title: "Studio Project Access via Teams",
1220
+ summary: "Projects live under organizations; team sharing refines access with an admin/owner override.",
1221
+ kind: "reference",
1222
+ visibility: "public",
1223
+ route: "/docs/tech/studio/project-access-teams",
1224
+ tags: [
1225
+ "studio",
1226
+ "projects",
1227
+ "teams",
1228
+ "rbac",
1229
+ "access-control"
1230
+ ],
1231
+ body: `# Studio Project Access via Teams
1232
+
1233
+ Studio access control is **organization-first** with optional **team-based sharing**.
1234
+
1235
+ ## Data model
1236
+
1237
+ - \`Team\` and \`TeamMember\` define team membership inside an organization.
1238
+ - \`StudioProject\` is owned by an organization.
1239
+ - \`StudioProjectTeam\` links projects to 0..N teams.
1240
+
1241
+ ## Access rules
1242
+
1243
+ - **Admins/owners**: always have access to all projects in the organization.
1244
+ - **Org-wide projects**: if a project has **no team links**, all organization members can access it.
1245
+ - **Team-scoped projects**: if a project has **one or more team links**, a user must be a member of at least one linked team.
1246
+
1247
+ ## GraphQL surfaces
1248
+
1249
+ - 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
1250
+ ## Related\n+\n+- Team administration + invitations: see \`/docs/tech/studio/team-invitations\`.\n+
1251
+ ## Notes
1252
+
1253
+ Payloads and events must avoid secrets/PII. For Sandbox, the model remains local-first and unlogged.
1254
+ `
1255
+ }];
1256
+ registerDocBlocks(tech_studio_project_access_teams_DocBlocks);
1257
+
1258
+ //#endregion
1259
+ //#region ../../libs/contracts/src/docs/tech/studio/team-invitations.docblock.ts
1260
+ const tech_studio_team_invitations_DocBlocks = [{
1261
+ id: "docs.tech.studio.team-invitations",
1262
+ title: "Studio Teams & Invitations",
1263
+ summary: "Admin-only team management and email invitation flow to join an organization and optionally a team.",
1264
+ kind: "reference",
1265
+ visibility: "public",
1266
+ route: "/docs/tech/studio/team-invitations",
1267
+ tags: [
1268
+ "studio",
1269
+ "teams",
1270
+ "invitations",
1271
+ "access-control",
1272
+ "onboarding"
1273
+ ],
1274
+ body: `# Studio Teams & Invitations
1275
+
1276
+ Studio uses **organization membership** as the base access model. Teams are optional and used to refine access to projects.
1277
+
1278
+ ## Who can manage teams?
1279
+
1280
+ - **Admins/owners only**: create, rename, delete teams; manage project team access; issue invitations.
1281
+
1282
+ ## Invitation data model
1283
+
1284
+ - \`Invitation\` rows are stored under an organization and target an **email** address.\n
1285
+ - An invitation can optionally target a \`teamId\`, which will grant the user membership in that team upon acceptance.
1286
+
1287
+ Key fields:
1288
+ - \`email\`: invited address (must match the accepting user's account email)\n
1289
+ - \`status\`: \`pending | accepted | declined | expired\`\n
1290
+ - \`teamId?\`: optional team to join\n
1291
+ - \`inviterId\`: user who issued the invitation
1292
+
1293
+ ## GraphQL surfaces
1294
+
1295
+ - Team CRUD (admin-only):\n
1296
+ - \`createTeam(name)\`\n
1297
+ - \`renameTeam(teamId, name)\`\n
1298
+ - \`deleteTeam(teamId)\`\n
1299
+
1300
+ - Invitations (admin-only):\n
1301
+ - \`organizationInvitations\`\n
1302
+ - \`inviteToOrganization(email, role?, teamId?)\` → returns \`inviteUrl\` and whether an email was sent
1303
+
1304
+ ## Accepting an invitation
1305
+
1306
+ The invite link is served as:\n
1307
+ - \`/invite/{invitationId}\`
1308
+
1309
+ Acceptance rules:
1310
+ - The user must be authenticated.\n
1311
+ - The authenticated user’s email must match \`Invitation.email\`.\n
1312
+ - If not already a member, create \`Member(userId, organizationId, role)\`.\n
1313
+ - If \`teamId\` is present, ensure \`TeamMember(teamId, userId)\`.\n
1314
+ - Mark invitation \`status='accepted'\` and set \`acceptedAt\`.\n
1315
+ - Set \`activeOrganizationId\` for the session so \`/studio/*\` routes work immediately.
1316
+
1317
+ ## Email delivery
1318
+
1319
+ - If \`RESEND_API_KEY\` is set, the system attempts to send an email.\n
1320
+ - Otherwise, the UI uses the returned \`inviteUrl\` for manual copy/share.
1321
+ `
1322
+ }];
1323
+ registerDocBlocks(tech_studio_team_invitations_DocBlocks);
1324
+
724
1325
  //#endregion
725
1326
  //#region src/docs/learning-journey-ui-onboarding.docblock.ts
726
1327
  registerDocBlocks([{