@lssm/lib.contracts 0.0.0-canary-20251212230121 → 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.
- package/dist/contract-registry/index.js +1 -0
- package/dist/contract-registry/schemas.js +1 -0
- package/dist/contract-registry/types.js +0 -0
- package/dist/docs/index.js +1 -1
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +58 -0
- package/dist/docs/tech/contracts/README.docblock.js +1 -1
- package/dist/docs/tech/contracts/openapi-export.docblock.js +38 -0
- package/dist/docs/tech/mcp-endpoints.docblock.js +1 -1
- package/dist/docs/tech/studio/learning-events.docblock.js +1 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.js +57 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +63 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.js +36 -0
- package/dist/docs/tech/studio/project-routing.docblock.js +1 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +20 -0
- package/dist/docs/tech/studio/team-invitations.docblock.js +65 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.js +1 -0
- package/dist/docs/tech/studio/workspaces.docblock.js +41 -0
- package/dist/docs/tech/telemetry-ingest.docblock.js +122 -0
- package/dist/docs/tech/vscode-extension.docblock.js +68 -0
- package/dist/index.js +1 -1
- package/dist/integrations/docs/integrations.docblock.js +1 -101
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/providers/impls/index.js +1 -1
- package/dist/integrations/providers/impls/provider-factory.js +1 -1
- package/dist/integrations/providers/index.js +1 -1
- package/dist/integrations/providers/registry.js +1 -0
- package/dist/integrations/secrets/aws-secret-manager.js +1 -0
- package/dist/integrations/secrets/index.js +1 -1
- package/dist/integrations/secrets/scaleway-secret-manager.js +1 -0
- package/dist/jobs/define-job.js +1 -1
- package/dist/jobs/gcp-cloud-tasks.js +1 -1
- package/dist/jobs/gcp-pubsub.js +1 -1
- package/dist/jobs/handlers/index.js +1 -1
- package/dist/jobs/index.js +1 -1
- package/dist/jobs/memory-queue.js +1 -1
- package/dist/jobs/queue.js +1 -0
- package/dist/jobs/scaleway-sqs-queue.js +1 -1
- package/dist/node_modules/@pothos/plugin-prisma/esm/util/datamodel.js +1 -1
- package/dist/node_modules/@pothos/plugin-prisma/esm/util/map-query.js +1 -1
- package/dist/openapi.js +1 -0
- package/dist/server/index.js +1 -1
- package/dist/server/mcp/createMcpServer.js +1 -0
- package/dist/server/mcp/mcpTypes.js +0 -0
- package/dist/server/mcp/registerPresentations.js +1 -0
- package/dist/server/mcp/registerPrompts.js +3 -0
- package/dist/server/mcp/registerResources.js +1 -0
- package/dist/server/mcp/registerTools.js +1 -0
- package/dist/server/provider-mcp.js +1 -1
- package/package.json +65 -11
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/index.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +0 -3
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ContractRegistryFileSchema as e,ContractRegistryItemSchema as t,ContractRegistryItemTypeSchema as n,ContractRegistryManifestSchema as r}from"./schemas.js";export{e as ContractRegistryFileSchema,t as ContractRegistryItemSchema,n as ContractRegistryItemTypeSchema,r as ContractRegistryManifestSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StabilityEnum as e}from"../ownership.js";import t from"zod";const n=t.enum([`contractspec:operation`,`contractspec:event`,`contractspec:presentation`,`contractspec:form`,`contractspec:feature`,`contractspec:workflow`,`contractspec:template`,`contractspec:integration`,`contractspec:data-view`,`contractspec:migration`,`contractspec:telemetry`,`contractspec:experiment`,`contractspec:app-config`,`contractspec:knowledge`]),r=t.object({path:t.string().min(1),type:t.string().min(1),content:t.string().optional()}),i=t.object({name:t.string().min(1),type:n,version:t.number().int().nonnegative(),title:t.string().min(1),description:t.string().min(1),meta:t.object({stability:t.enum([e.Idea,e.InCreation,e.Experimental,e.Beta,e.Stable,e.Deprecated]),owners:t.array(t.string().min(1)).default([]),tags:t.array(t.string().min(1)).default([])}),dependencies:t.array(t.string().min(1)).optional(),registryDependencies:t.array(t.string().min(1)).optional(),files:t.array(r).min(1),schema:t.object({input:t.unknown().optional(),output:t.unknown().optional()}).optional()}),a=t.object({$schema:t.string().min(1).optional(),name:t.string().min(1),homepage:t.string().min(1).optional(),items:t.array(i)});export{r as ContractRegistryFileSchema,i as ContractRegistryItemSchema,n as ContractRegistryItemTypeSchema,a as ContractRegistryManifestSchema};
|
|
File without changes
|
package/dist/docs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{docBlockToPresentationSpec as e,docBlockToPresentationV2 as t,docBlocksToPresentationRoutes as n,docBlocksToPresentationSpecs as r,mapDocRoutes as i}from"./presentations.js";import{DocRegistry as a,defaultDocRegistry as o,docId as s,listRegisteredDocBlocks as c,registerDocBlocks as l}from"./registry.js";import{techContractsDocs as u}from"./tech-contracts.docs.js";import{metaDocs as d}from"./meta.docs.js";import"./PUBLISHING.docblock.js";import"./accessibility_wcag_compliance_specs.docblock.js";import"./tech/PHASE_1_QUICKSTART.docblock.js";import"./tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js";import"./tech/PHASE_3_AUTO_EVOLUTION.docblock.js";import"./tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js";import"./tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js";import"./tech/lifecycle-stage-system.docblock.js";import"./tech/presentation-runtime.docblock.js";import"./tech/schema/README.docblock.js";import"./tech/templates/runtime.docblock.js";import"./tech/workflows/overview.docblock.js";import"./tech/mcp-endpoints.docblock.js";export{a as DocRegistry,o as defaultDocRegistry,e as docBlockToPresentationSpec,t as docBlockToPresentationV2,n as docBlocksToPresentationRoutes,r as docBlocksToPresentationSpecs,s as docId,c as listRegisteredDocBlocks,i as mapDocRoutes,d as metaDocs,l as registerDocBlocks,u as techContractsDocs};
|
|
1
|
+
import{docBlockToPresentationSpec as e,docBlockToPresentationV2 as t,docBlocksToPresentationRoutes as n,docBlocksToPresentationSpecs as r,mapDocRoutes as i}from"./presentations.js";import{DocRegistry as a,defaultDocRegistry as o,docId as s,listRegisteredDocBlocks as c,registerDocBlocks as l}from"./registry.js";import{techContractsDocs as u}from"./tech-contracts.docs.js";import{metaDocs as d}from"./meta.docs.js";import"./PUBLISHING.docblock.js";import"./accessibility_wcag_compliance_specs.docblock.js";import"./tech/PHASE_1_QUICKSTART.docblock.js";import"./tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js";import"./tech/PHASE_3_AUTO_EVOLUTION.docblock.js";import"./tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js";import"./tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js";import"./tech/lifecycle-stage-system.docblock.js";import"./tech/presentation-runtime.docblock.js";import"./tech/auth/better-auth-nextjs.docblock.js";import"./tech/schema/README.docblock.js";import"./tech/templates/runtime.docblock.js";import"./tech/workflows/overview.docblock.js";import"./tech/mcp-endpoints.docblock.js";import"./tech/vscode-extension.docblock.js";import"./tech/telemetry-ingest.docblock.js";import"./tech/contracts/openapi-export.docblock.js";import"./tech/studio/workspaces.docblock.js";import"./tech/studio/sandbox-unlogged.docblock.js";import"./tech/studio/workspace-ops.docblock.js";import"./tech/studio/project-routing.docblock.js";import"./tech/studio/platform-admin-panel.docblock.js";import"./tech/studio/learning-events.docblock.js";import"./tech/studio/learning-journeys.docblock.js";import"./tech/studio/project-access-teams.docblock.js";import"./tech/studio/team-invitations.docblock.js";export{a as DocRegistry,o as defaultDocRegistry,e as docBlockToPresentationSpec,t as docBlockToPresentationV2,n as docBlocksToPresentationRoutes,r as docBlocksToPresentationSpecs,s as docId,c as listRegisteredDocBlocks,i as mapDocRoutes,d as metaDocs,l as registerDocBlocks,u as techContractsDocs};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.auth.better-auth-nextjs`,title:`Better Auth + Next.js integration (ContractSpec)`,summary:`How ContractSpec wires Better Auth into Next.js (server config, client singleton, and proxy cookie-only redirects).`,kind:`reference`,visibility:`public`,route:`/docs/tech/auth/better-auth-nextjs`,tags:[`auth`,`better-auth`,`nextjs`,`cookies`,`proxy`,`hmr`],body:`# Better Auth + Next.js integration (ContractSpec)
|
|
2
|
+
|
|
3
|
+
This repo uses Better Auth as the primary auth layer (sessions, organizations, teams, API keys, and OAuth).
|
|
4
|
+
|
|
5
|
+
## Server config (Better Auth)
|
|
6
|
+
|
|
7
|
+
- Source: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
|
|
8
|
+
- Important: \`nextCookies()\` must be the **last** plugin in the Better Auth plugin list so \`Set-Cookie\` is applied correctly in Next.js environments.
|
|
9
|
+
|
|
10
|
+
## Better Auth Admin plugin
|
|
11
|
+
|
|
12
|
+
ContractSpec Studio enables the Better Auth **Admin plugin** to support platform-admin user operations (list users, impersonation, etc.).
|
|
13
|
+
|
|
14
|
+
- Server: \`admin()\` plugin in \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
|
|
15
|
+
- Client: \`adminClient()\` in \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
|
|
16
|
+
|
|
17
|
+
### PLATFORM_ADMIN ⇒ Better Auth admin role
|
|
18
|
+
|
|
19
|
+
Better Auth Admin endpoints authorize via \`user.role\`. ContractSpec enforces an org-driven rule:
|
|
20
|
+
|
|
21
|
+
- If the **active organization** has \`type = PLATFORM_ADMIN\`, the signed-in user is ensured to have \`User.role\` containing \`admin\`.
|
|
22
|
+
- This is applied in the session creation hook and re-checked in \`assertsPlatformAdmin()\`.
|
|
23
|
+
|
|
24
|
+
This keeps admin enablement deterministic and avoids manual role backfills.
|
|
25
|
+
|
|
26
|
+
## Client config (React web + Expo)
|
|
27
|
+
|
|
28
|
+
To avoid duplicate background refresh/polling loops in dev (Fast Refresh/HMR), the Better Auth client is implemented as a singleton cached on \`globalThis\`.
|
|
29
|
+
|
|
30
|
+
- Web client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
|
|
31
|
+
- Native client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.native.ts\`
|
|
32
|
+
|
|
33
|
+
Import guidance:
|
|
34
|
+
|
|
35
|
+
- If you only need the context/hook, prefer importing from \`@lssm/bundle.contractspec-studio/presentation/providers/auth\`.
|
|
36
|
+
- 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\`.
|
|
37
|
+
|
|
38
|
+
## Public routes (login / signup)
|
|
39
|
+
|
|
40
|
+
Public auth pages should avoid eager \`authClient\` initialization.
|
|
41
|
+
|
|
42
|
+
Pattern used:
|
|
43
|
+
|
|
44
|
+
- In the submit handler, dynamically import \`@lssm/bundle.contractspec-studio/presentation/providers/auth/index.web\` and call \`authClient.signIn.*\` / \`authClient.signUp.*\`.
|
|
45
|
+
|
|
46
|
+
This prevents session refresh behavior from starting just because a public page rendered.
|
|
47
|
+
|
|
48
|
+
## Next.js proxy auth (web-landing)
|
|
49
|
+
|
|
50
|
+
The Next.js proxy/middleware is used for **redirect decisions only**. It must not perform DB-backed session reads on every request.
|
|
51
|
+
|
|
52
|
+
- Source: \`packages/apps/web-landing/src/proxy.ts\`
|
|
53
|
+
- Approach: cookie-only checks via Better Auth cookies helpers:
|
|
54
|
+
- \`getSessionCookie(request)\`
|
|
55
|
+
- \`getCookieCache(request)\`
|
|
56
|
+
|
|
57
|
+
These checks are intentionally optimistic and should only gate routing. Full authorization must still be enforced on server-side actions/routes and GraphQL resolvers.
|
|
58
|
+
`}];e(t);export{t as tech_auth_better_auth_nextjs_DocBlocks};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.contracts.README`,title:`Contracts: Specs, Registry, Handlers, Adapters`,summary:"- `packages/lssm/libs/contracts` defines the contracts core (SpecRegistry, ContractSpec, install helpers, REST/MCP adapters).",kind:`reference`,visibility:`public`,route:`/docs/tech/contracts/README`,tags:[`tech`,`contracts`,`README`],body:"## Contracts: Specs, Registry, Handlers, Adapters\n\n### What lives where\n\n- `packages/lssm/libs/contracts` defines the contracts core (SpecRegistry, ContractSpec, install helpers, REST/MCP adapters).\n- `packages/lssm/libs/schema` defines the schema dictionary (`SchemaModel`, `FieldType`) used to describe I/O once and map to multiple targets (zod, GraphQL, JSON Schema).\n- App adapters (e.g. GraphQL) live close to the app. Example: `packages/hcircle/apps/api-coliving/src/graphql/contracts-adapter.ts`.\n\n### npm distribution\n\n- `@lssm/lib.contracts` (root) keeps the legacy \\\"everything\\\" surface for backward compatibility.\n- `@lssm/lib.contracts/client` exposes only browser-safe helpers (React renderers, client SDK, drivers). Import from this entry when bundling for the web or React Native to avoid dragging server adapters.\n- `@lssm/lib.contracts/server` covers HTTP/MCP adapters, registries, integrations, and other Node-only helpers.\n- `@lssm/lib.contracts/types` exports the runtime handler context utilities, while `@lssm/lib.contracts/types/all` re-exports every type alias/interface across the package via `export type` so consumers can import a single module for typings without shipping runtime code.\n- `@lssm/lib.schema`, `@lssm/lib.design-system`, `@lssm/lib.ui-kit`, `@lssm/lib.ui-kit-web`, `@lssm/lib.accessibility`, and the presentation runtime packages are published to npm alongside contracts; prefer the scoped packages to keep tree-shaking intact.\n- Bundlers with conditional exports should resolve subpaths first; keep root imports for server-only code paths.\n\n### Core concepts\n\n- **ContractSpec**: immutable description of an operation.\n - `meta`: `{ name, version, kind: 'query' | 'command' }`\n - `io`: `{ input: SchemaModel | zod schema, output: SchemaModel | zod schema }`\n - `policy`: `{ auth?: {...}, rateLimit?: {...}, flags?: string[] }`\n - `transport.gql.field?`: explicit GraphQL field name (otherwise derived via `defaultGqlField`).\n- **SpecRegistry**: registry of specs + handlers. Use `installOp(reg, spec, handler)` to attach a handler.\n- **Handler**: `(ctx, input) => Promise<output>` implementing the operation.\n- **CapabilitySpec**: canonical capability declaration stored in `src/capabilities.ts`. Tracks `meta` (`{ key, version, kind, title, description, domain, owners, tags, stability }`), `provides` surfaces (`operation`, `event`, `workflow`, `presentation`, `resource`), and `requires` which other capabilities must be present. Enforced during `installFeature`.\n- **PolicySpec**: declarative policy rules (`src/policy/spec.ts`) covering ABAC/ReBAC, consent + rate limit requirements, field-level controls, and PII guidance. `PolicyEngine` evaluates refs, while `OPAPolicyAdapter` lets OPA override/augment runtime decisions.\n- **TelemetrySpec**: analytics definitions (`src/telemetry/spec.ts`) describing event semantics, privacy level, retention, sampling, and anomaly detection. `TelemetryTracker` handles redaction/sampling, `TelemetryAnomalyMonitor` raises alerts, and specs integrate with contracts/workflows via `ctx.telemetry`.\n- **TestSpec**: declarative scenario definitions in `src/tests/spec.ts`. `TestRunner` executes fixtures/actions/assertions against a `SpecRegistry`, and the CLI (`contractspec test`) wraps the runner for automation.\n- **ExperimentSpec**: experiment definitions (`src/experiments/spec.ts`) describing variants, allocation strategies, and success metrics. `ExperimentEvaluator` assigns variants (random/sticky/targeted) and integrates with Policy/Telemetry for safe experimentation.\n- **AppBlueprintSpec / TenantAppConfig**: global blueprints and per-tenant overrides (`src/app-config/spec.ts`). `resolveAppConfig()` merges the two into a `ResolvedAppConfig`, while `composeAppConfig()` hydrates the merged view against registries and reports missing references for safe rollout.\n- **RegeneratorService**: background daemon (`src/regenerator/service.ts`) that consumes telemetry/error/behavior signals, evaluates regeneration rules, and produces `SpecChangeProposal`s for Studio review.\n- **DataViewSpec**: declarative data presentation layer in `src/data-views.ts`. Describes entity projections (`fields`, `filters`, `actions`) with `view.kind` (`list`, `table`, `detail`, `grid`), ties to query operations via `source.primary`, and exposes optional presentation-based empty/error states.\n- **ThemeSpec**: design token + component variant definitions in `src/themes.ts`. Supports inheritance (`extends`), tenant/user overrides, and component-specific variant metadata for the design system.\n- **MigrationSpec**: schema/data migration descriptors (`src/migrations.ts`) with ordered step plans, dependency tracking, and pre/post checks to support automated database/content migrations.\n- **WorkflowSpec**: typed definition of multi-step workflows living in `src/workflow/spec.ts`. `WorkflowRegistry` stores versioned specs, and `validateWorkflowSpec()` (in `src/workflow/validation.ts`) checks graph integrity, step references, and reachability.\n\n### Lifecycle\n\n1. Define the spec (I/O via `SchemaModel` or zod) in a vertical lib (e.g. `contracts-coliving`).\n2. Register it: `installOp(registry, spec, handler)` within the app/service.\n3. Expose it via an adapter (REST, GraphQL, MCP). Each adapter maps the I/O to its transport and enforces policy.\n4. Validate at runtime: parse `input` before executing, parse `output` before returning.\n\n### Adapters\n\n- **REST**: see `packages/lssm/libs/contracts/src/server/rest-*`. Binds routes, validates request/response, maps errors/policies.\n- **MCP**: see `packages/lssm/libs/contracts/src/server/provider-mcp.ts` (standalone MCP server) and `packages/lssm/libs/contracts/src/server/rest-next-mcp.ts` (MCP over Next.js route). Provides tools/resources/prompts
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.contracts.README`,title:`Contracts: Specs, Registry, Handlers, Adapters`,summary:"- `packages/lssm/libs/contracts` defines the contracts core (SpecRegistry, ContractSpec, install helpers, REST/MCP adapters).",kind:`reference`,visibility:`public`,route:`/docs/tech/contracts/README`,tags:[`tech`,`contracts`,`README`],body:"## Contracts: Specs, Registry, Handlers, Adapters\n\n### What lives where\n\n- `packages/lssm/libs/contracts` defines the contracts core (SpecRegistry, ContractSpec, install helpers, REST/MCP adapters).\n- `packages/lssm/libs/schema` defines the schema dictionary (`SchemaModel`, `FieldType`) used to describe I/O once and map to multiple targets (zod, GraphQL, JSON Schema).\n- App adapters (e.g. GraphQL) live close to the app. Example: `packages/hcircle/apps/api-coliving/src/graphql/contracts-adapter.ts`.\n\n### npm distribution\n\n- `@lssm/lib.contracts` (root) keeps the legacy \\\"everything\\\" surface for backward compatibility.\n- `@lssm/lib.contracts/client` exposes only browser-safe helpers (React renderers, client SDK, drivers). Import from this entry when bundling for the web or React Native to avoid dragging server adapters.\n- `@lssm/lib.contracts/server` covers HTTP/MCP adapters, registries, integrations, and other Node-only helpers.\n- `@lssm/lib.contracts/types` exports the runtime handler context utilities, while `@lssm/lib.contracts/types/all` re-exports every type alias/interface across the package via `export type` so consumers can import a single module for typings without shipping runtime code.\n- `@lssm/lib.schema`, `@lssm/lib.design-system`, `@lssm/lib.ui-kit`, `@lssm/lib.ui-kit-web`, `@lssm/lib.accessibility`, and the presentation runtime packages are published to npm alongside contracts; prefer the scoped packages to keep tree-shaking intact.\n- Bundlers with conditional exports should resolve subpaths first; keep root imports for server-only code paths.\n\n### Core concepts\n\n- **ContractSpec**: immutable description of an operation.\n - `meta`: `{ name, version, kind: 'query' | 'command' }`\n - `io`: `{ input: SchemaModel | zod schema, output: SchemaModel | zod schema }`\n - `policy`: `{ auth?: {...}, rateLimit?: {...}, flags?: string[] }`\n - `transport.gql.field?`: explicit GraphQL field name (otherwise derived via `defaultGqlField`).\n- **SpecRegistry**: registry of specs + handlers. Use `installOp(reg, spec, handler)` to attach a handler.\n- **Handler**: `(ctx, input) => Promise<output>` implementing the operation.\n- **CapabilitySpec**: canonical capability declaration stored in `src/capabilities.ts`. Tracks `meta` (`{ key, version, kind, title, description, domain, owners, tags, stability }`), `provides` surfaces (`operation`, `event`, `workflow`, `presentation`, `resource`), and `requires` which other capabilities must be present. Enforced during `installFeature`.\n- **PolicySpec**: declarative policy rules (`src/policy/spec.ts`) covering ABAC/ReBAC, consent + rate limit requirements, field-level controls, and PII guidance. `PolicyEngine` evaluates refs, while `OPAPolicyAdapter` lets OPA override/augment runtime decisions.\n- **TelemetrySpec**: analytics definitions (`src/telemetry/spec.ts`) describing event semantics, privacy level, retention, sampling, and anomaly detection. `TelemetryTracker` handles redaction/sampling, `TelemetryAnomalyMonitor` raises alerts, and specs integrate with contracts/workflows via `ctx.telemetry`.\n- **TestSpec**: declarative scenario definitions in `src/tests/spec.ts`. `TestRunner` executes fixtures/actions/assertions against a `SpecRegistry`, and the CLI (`contractspec test`) wraps the runner for automation.\n- **ExperimentSpec**: experiment definitions (`src/experiments/spec.ts`) describing variants, allocation strategies, and success metrics. `ExperimentEvaluator` assigns variants (random/sticky/targeted) and integrates with Policy/Telemetry for safe experimentation.\n- **AppBlueprintSpec / TenantAppConfig**: global blueprints and per-tenant overrides (`src/app-config/spec.ts`). `resolveAppConfig()` merges the two into a `ResolvedAppConfig`, while `composeAppConfig()` hydrates the merged view against registries and reports missing references for safe rollout.\n- **RegeneratorService**: background daemon (`src/regenerator/service.ts`) that consumes telemetry/error/behavior signals, evaluates regeneration rules, and produces `SpecChangeProposal`s for Studio review.\n- **DataViewSpec**: declarative data presentation layer in `src/data-views.ts`. Describes entity projections (`fields`, `filters`, `actions`) with `view.kind` (`list`, `table`, `detail`, `grid`), ties to query operations via `source.primary`, and exposes optional presentation-based empty/error states.\n- **ThemeSpec**: design token + component variant definitions in `src/themes.ts`. Supports inheritance (`extends`), tenant/user overrides, and component-specific variant metadata for the design system.\n- **MigrationSpec**: schema/data migration descriptors (`src/migrations.ts`) with ordered step plans, dependency tracking, and pre/post checks to support automated database/content migrations.\n- **WorkflowSpec**: typed definition of multi-step workflows living in `src/workflow/spec.ts`. `WorkflowRegistry` stores versioned specs, and `validateWorkflowSpec()` (in `src/workflow/validation.ts`) checks graph integrity, step references, and reachability.\n\n### Lifecycle\n\n1. Define the spec (I/O via `SchemaModel` or zod) in a vertical lib (e.g. `contracts-coliving`).\n2. Register it: `installOp(registry, spec, handler)` within the app/service.\n3. Expose it via an adapter (REST, GraphQL, MCP). Each adapter maps the I/O to its transport and enforces policy.\n4. Validate at runtime: parse `input` before executing, parse `output` before returning.\n\n### Adapters\n\n- **REST**: see `packages/lssm/libs/contracts/src/server/rest-*`. Binds routes, validates request/response, maps errors/policies.\n- **MCP**: see `packages/lssm/libs/contracts/src/server/provider-mcp.ts` (standalone MCP server) and `packages/lssm/libs/contracts/src/server/rest-next-mcp.ts` (MCP over Next.js route). Provides tools/resources/prompts.\n - Tools + resources are registered from Zod schemas.\n - Resource templates are keyed by full `ResourceMeta.uriTemplate` (e.g. `docs://list`, `docs://doc/{id}`), so multiple templates can share a scheme (`docs://*`) without collisions.\n- **GraphQL (Pothos)**: see `packages/lssm/libs/contracts/src/server/graphql-pothos.ts`. Adds Query/Mutation fields by transforming contract I/O to GraphQL types.\n\n### GraphQL adapter behaviour (summary)\n\n- Field naming: `spec.transport.gql.field` or `<name_with_dots>_v<version>`.\n- Input/Output types from `SchemaModel` (preferred) or fallback zod introspection.\n- Scalars: String/Int/Float/Boolean/Date/JSON; Objects/Arrays/Enums; unions for outputs; input unions => JSON.\n- Policy: auth gate checks GraphQL context; optional feature flag gating.\n- Complexity & tracing: attaches hints and records timings; log includes `{ specName, version }`.\n\n#### Returns mapping and hydration\n\n- `spec.transport.gql.returns` can declare the GraphQL return wrapper: e.g. `\"Spot\"` or `[Spot]`. If omitted, the adapter infers from `io.output` (SchemaModel) or `resourceRef.graphQLType`.\n- Resource outputs: when `io.output` is a `resourceRef(...)` or `transport.gql.resource` is set, the adapter will optionally hydrate via a `ResourceRegistry` using `contracts-adapter-hydration.ts`:\n - Grammar is parsed with `parseReturns()`.\n - Entities are resolved via `hydrateResourceIfNeeded(resources, result, { template, varName, returns })` after handler execution.\n\n### Resource outputs\n\n- Declare resource outputs using `resourceRef(uriTemplate, opts)`.\n- `opts.varName` (default `id`) selects the identifier field returned by the handler for URI substitution.\n- `opts.graphQLType` is the GraphQL return type name (e.g., `Spot`) or list form (e.g., `[Spot]`).\n- `opts.many: true` indicates the handler returns an array of resources. The handler type becomes an array of items that include the identifier field.\n\nExample:\n\n```ts\nio: {\n input: ListThingsInput,\n output: resourceRef('myapp://thing/{id}', { graphQLType: '[Thing]', many: true }),\n}\n```\n\nHandler return (simplified): `{ id: string | number }[]`.\n\n### Errors\n\n- Validation errors → transport 400/GraphQL UserInputError.\n- Policy/auth errors → 401/403 or GraphQL ForbiddenError.\n- Handler errors → mapped to transport error with safe message.\n\n### Versioning & naming\n\n- Keep `meta.version` monotonic. Clients should pin to a versioned field/key.\n- Avoid renaming existing fields; add new fields with new versions.\n\n### Ownership metadata (OwnerShipMeta)\n\nAll contracts, events, features, and presentations reference a shared ownership schema (source of truth in `packages/lssm/libs/contracts/src/ownership.ts`).\n\n- Required fields: `title`, `description`, `domain`, `owners[]`, `tags[]`, `stability`.\n- Curated enums: the library exports suggested constants for owners and tags; free-form strings are still allowed for forward-compatibility.\n- Operations (`spec.ts`): `meta` requires `stability`, `owners`, and `tags` alongside `name`, `version`, `kind`, `description`, `goal`, and `context`.\n- Presentations V2: `meta` is a partial of ownership plus `description`.\n- Events: may specify `ownership` (recommended) for discoverability and docs.\n\n### Quick start\n\n```ts\n// app bootstrap\nconst reg = new SpecRegistry();\ninstallOp(reg, BeginSignupSpec, beginSignupHandler);\nregisterContractsOnBuilder(gqlSchemaBuilder, reg); // GraphQL\n// or: createRestRouter(reg) // REST\n```\n"}];e(t);export{t as tech_contracts_README_DocBlocks};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.contracts.openapi-export`,title:`OpenAPI export (OpenAPI 3.1) from SpecRegistry`,summary:`Generate a deterministic OpenAPI document from a SpecRegistry using jsonSchemaForSpec + REST transport metadata.`,kind:`reference`,visibility:`public`,route:`/docs/tech/contracts/openapi-export`,tags:[`contracts`,`openapi`,`rest`],body:`## OpenAPI export (OpenAPI 3.1) from SpecRegistry
|
|
2
|
+
|
|
3
|
+
### Purpose
|
|
4
|
+
|
|
5
|
+
ContractSpec specs can be exported into an **OpenAPI 3.1** document for tooling (SDK generation, docs, gateways).
|
|
6
|
+
|
|
7
|
+
The export is **spec-first**:
|
|
8
|
+
|
|
9
|
+
- Uses \`jsonSchemaForSpec(spec)\` for input/output JSON Schema (from SchemaModel → zod → JSON Schema)
|
|
10
|
+
- Uses \`spec.transport.rest.method/path\` when present
|
|
11
|
+
- Falls back to deterministic defaults:
|
|
12
|
+
- Method: \`POST\` for commands, \`GET\` for queries
|
|
13
|
+
- Path: \`defaultRestPath(name, version)\` → \`/<dot/name>/v<version>\`
|
|
14
|
+
|
|
15
|
+
### Library API
|
|
16
|
+
|
|
17
|
+
- Function: \`openApiForRegistry(registry, options?)\`
|
|
18
|
+
- Location: \`@lssm/lib.contracts/openapi\`
|
|
19
|
+
|
|
20
|
+
### CLI
|
|
21
|
+
|
|
22
|
+
Export OpenAPI from a registry module:
|
|
23
|
+
|
|
24
|
+
\`\`\`bash
|
|
25
|
+
contractspec openapi --registry ./src/registry.ts --out ./openapi.json
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
The registry module must export one of:
|
|
29
|
+
|
|
30
|
+
- \`registry: SpecRegistry\`
|
|
31
|
+
- \`default(): SpecRegistry | Promise<SpecRegistry>\`
|
|
32
|
+
- \`createRegistry(): SpecRegistry | Promise<SpecRegistry>\`
|
|
33
|
+
|
|
34
|
+
### Notes / limitations (current)
|
|
35
|
+
|
|
36
|
+
- Responses are generated as a basic \`200\` response (plus schemas when available).
|
|
37
|
+
- Query (GET) inputs are currently represented as a JSON request body when an input schema exists.
|
|
38
|
+
- Errors are not yet expanded into OpenAPI responses; that will be added when we standardize error envelopes.`}];e(t);export{t as tech_contracts_openapi_export_DocBlocks};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerDocBlocks as e}from"../registry.js";const t=[{id:`docs.tech.mcp.endpoints`,title:`ContractSpec MCP endpoints`,summary:`Dedicated MCP servers for docs, CLI usage, and internal development.`,kind:`reference`,visibility:`mixed`,route:`/docs/tech/mcp/endpoints`,tags:[`mcp`,`docs`,`cli`,`internal`],body:"# ContractSpec MCP endpoints\n\nThree dedicated MCP servers keep AI agents efficient and scoped:\n\n- **Docs MCP**: `/api/mcp/docs` — exposes DocBlocks as resources + presentations. Tool: `docs.search`.\n- **CLI MCP**: `/api/mcp/cli` — surfaces CLI quickstart/reference/README and suggests commands. Tool: `cli.suggestCommand`.\n- **Internal MCP**: `/api/mcp/internal` — internal routing hints and
|
|
1
|
+
import{registerDocBlocks as e}from"../registry.js";const t=[{id:`docs.tech.mcp.endpoints`,title:`ContractSpec MCP endpoints`,summary:`Dedicated MCP servers for docs, CLI usage, and internal development.`,kind:`reference`,visibility:`mixed`,route:`/docs/tech/mcp/endpoints`,tags:[`mcp`,`docs`,`cli`,`internal`],body:"# ContractSpec MCP endpoints\n\nThree dedicated MCP servers keep AI agents efficient and scoped:\n\n- **Docs MCP**: `/api/mcp/docs` — exposes DocBlocks as resources + presentations. Tool: `docs.search`.\n- **CLI MCP**: `/api/mcp/cli` — surfaces CLI quickstart/reference/README and suggests commands. Tool: `cli.suggestCommand`.\n- **Internal MCP**: `/api/mcp/internal` — internal routing hints, playbook, and example registry access. Tool: `internal.describe`.\n\n### Usage notes\n- Transports are HTTP POST (streamable HTTP); SSE is disabled.\n- Resources are namespaced (`docs://*`, `cli://*`, `internal://*`) and are read-only.\n- Internal MCP also exposes the examples registry via `examples://*` resources:\n - `examples://list?q=<query>`\n - `examples://example/<id>`\n- Prompts mirror each surface (navigator, usage, bootstrap) for quick agent onboarding.\n- GraphQL remains at `/graphql`; health at `/health`.\n"}];e(t);export{t as tech_mcp_endpoints_DocBlocks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.learning-events`,title:`Studio Learning Events`,summary:`Studio persists learning/activity events to the database; Sandbox keeps learning local-first and unlogged.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/learning-events`,tags:[`studio`,`learning`,`events`,`analytics`,`sandbox`],body:"# Studio Learning Events\n\nStudio emits lightweight **learning/activity events** to support onboarding, ambient coaching, and learning journeys.\n\n## Persistence model\n\n- **Studio**: events are persisted to the database in `StudioLearningEvent` and are organization-scoped (optionally project-scoped).\n- **Sandbox**: events remain **local-only** (unlogged); they must never be sent to backend services.\n\n## GraphQL API\n\n- `recordLearningEvent(input: { name, projectId?, payload? })`\n- `myLearningEvents(projectId?, limit?)`\n- `myOnboardingTracks(productId?, includeProgress?)`\n- `myOnboardingProgress(trackKey)`\n- `dismissOnboardingTrack(trackKey)`\n\n## Common event names (convention)\n\n- `module.navigated` — user navigated to a Studio module (payload at minimum: `{ moduleId }`).\n- `studio.template.instantiated` — created a new Studio project (starter template). Payload commonly includes `{ templateId, projectSlug }`.\n- `spec.changed` — created or updated a Studio spec. Payload may include `{ action: 'create' | 'update', specId?, specType? }`.\n- `regeneration.completed` — finished a “regen/deploy” action (currently emitted on successful Studio deploy actions).\n- `studio.evolution.applied` — completed an Evolution session (payload commonly includes `{ evolutionSessionId }`).\n\nThese events are intentionally minimal and must avoid PII/secrets in payloads.\n"}];e(t);export{t as tech_studio_learning_events_DocBlocks};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.learning-journeys`,title:`Studio learning journeys (onboarding + coach)`,summary:`DB-backed learning journeys tracked per organization: seeded tracks/steps, event-driven progress, XP/streaks, and a Studio coach surface.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/learning-journeys`,tags:[`studio`,`learning`,`onboarding`,`journey`,`graphql`,`database`],body:`# Studio learning journeys
|
|
2
|
+
|
|
3
|
+
Studio supports **DB-backed learning journeys** (onboarding tracks + ambient coach tips) that are advanced by **recorded learning events**.
|
|
4
|
+
|
|
5
|
+
> See also: \`/docs/tech/studio/learning-events\` for event naming + payload guardrails.
|
|
6
|
+
|
|
7
|
+
## Scope (multi-tenancy)
|
|
8
|
+
|
|
9
|
+
- Progress is tracked **per organization** (tenant/workspace), via a \`Learner\` record keyed by \`(userId, organizationId)\`.
|
|
10
|
+
- Learning events are stored as \`StudioLearningEvent\` under the Studio DB schema, scoped to an organization (optionally a project).
|
|
11
|
+
|
|
12
|
+
## Persistence model (Prisma)
|
|
13
|
+
|
|
14
|
+
Learning journey progress lives in the \`lssm_learning\` schema:
|
|
15
|
+
|
|
16
|
+
- \`Learner\` — one per \`(userId, organizationId)\`
|
|
17
|
+
- \`OnboardingTrack\` — seeded track definitions (trackKey, name, metadata)
|
|
18
|
+
- \`OnboardingStep\` — seeded step definitions (stepKey, completionCondition, xpReward, metadata)
|
|
19
|
+
- \`OnboardingProgress\` — learner × track progress (progress %, xpEarned, completedAt, dismissedAt)
|
|
20
|
+
- \`OnboardingStepCompletion\` — append-only completion records (stepKey, status, xpEarned, completedAt)
|
|
21
|
+
|
|
22
|
+
## Track definition source (spec-first)
|
|
23
|
+
|
|
24
|
+
- Canonical track specs live in \`@lssm/example.learning-journey-registry\`.
|
|
25
|
+
- The Studio API seeds/updates the DB definitions via an idempotent “ensure tracks” routine.
|
|
26
|
+
- The DB is kept aligned with track specs (stale steps are removed) to prevent drift and unblock completion.
|
|
27
|
+
|
|
28
|
+
## Progress advancement (event-driven)
|
|
29
|
+
|
|
30
|
+
1) UI records an event via GraphQL \`recordLearningEvent\`
|
|
31
|
+
2) Backend creates \`StudioLearningEvent\`
|
|
32
|
+
3) Backend advances onboarding by matching the new event against step completion conditions
|
|
33
|
+
4) Backend persists step completions and recomputes:
|
|
34
|
+
- \`progress\` percentage
|
|
35
|
+
- \`xpEarned\` (including streak/completion bonuses when configured)
|
|
36
|
+
- track completion state (\`completedAt\`)
|
|
37
|
+
|
|
38
|
+
## GraphQL API (Studio)
|
|
39
|
+
|
|
40
|
+
- \`myOnboardingTracks(productId?, includeProgress?)\`
|
|
41
|
+
- returns all tracks + optional progress for the current learner
|
|
42
|
+
- \`myOnboardingProgress(trackKey)\`
|
|
43
|
+
- returns progress + step completion list for a single track
|
|
44
|
+
- \`dismissOnboardingTrack(trackKey)\`
|
|
45
|
+
- marks a track dismissed for the learner (prevents auto-coach)
|
|
46
|
+
|
|
47
|
+
## UI routes/surfaces (web)
|
|
48
|
+
|
|
49
|
+
- \`/studio/learning\` — learning hub (track list + progress widget)
|
|
50
|
+
- \`/studio/learning/{trackKey}\` — track detail (steps + map)
|
|
51
|
+
- Studio shell mounts a **coach sheet** that can auto-open for incomplete, non-dismissed onboarding.
|
|
52
|
+
|
|
53
|
+
## Security + data hygiene
|
|
54
|
+
|
|
55
|
+
- Do not put secrets/PII in \`payload\` fields of learning events.
|
|
56
|
+
- Prefer shallow payload filters (small, stable keys).
|
|
57
|
+
`}];e(t);export{t as tech_studio_learning_journeys_DocBlocks};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.platform-admin-panel`,title:`Studio Platform Admin Panel`,summary:`How PLATFORM_ADMIN organizations manage tenant orgs and integration connections without session switching.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/platform-admin-panel`,tags:[`studio`,`admin`,`multi-tenancy`,`integrations`,`better-auth`],body:`# Studio Platform Admin Panel
|
|
2
|
+
|
|
3
|
+
ContractSpec Studio exposes a dedicated **Platform Admin Panel** for users whose **active organization** has:
|
|
4
|
+
|
|
5
|
+
- \`Organization.type = PLATFORM_ADMIN\`
|
|
6
|
+
|
|
7
|
+
The UI route is:
|
|
8
|
+
|
|
9
|
+
- \`/studio/admin\`
|
|
10
|
+
|
|
11
|
+
## Authorization model (no org switching)
|
|
12
|
+
|
|
13
|
+
Platform admins **remain in their own organization**. Cross-tenant actions are always explicit and scoped:
|
|
14
|
+
|
|
15
|
+
- Admin operations require an explicit \`targetOrganizationId\`.
|
|
16
|
+
- No session / activeOrganizationId switching is performed as part of admin operations.
|
|
17
|
+
|
|
18
|
+
## Integrations management
|
|
19
|
+
|
|
20
|
+
The admin panel manages the full ContractSpec Integrations system:
|
|
21
|
+
|
|
22
|
+
- Lists all shipped \`IntegrationSpec\` entries (registry built via \`createDefaultIntegrationSpecRegistry()\`).
|
|
23
|
+
- CRUD \`IntegrationConnection\` records for a selected tenant org.
|
|
24
|
+
|
|
25
|
+
### Secrets (reference-only + write-only)
|
|
26
|
+
|
|
27
|
+
The admin UI supports two modes:
|
|
28
|
+
|
|
29
|
+
- **Reference-only (BYOK)**: store only \`secretProvider\` + \`secretRef\`.
|
|
30
|
+
- **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**.
|
|
31
|
+
|
|
32
|
+
Supported backends:
|
|
33
|
+
|
|
34
|
+
- Env overrides (\`env://...\`)
|
|
35
|
+
- Google Cloud Secret Manager (\`gcp://...\`)
|
|
36
|
+
- AWS Secrets Manager (\`aws://secretsmanager/...\`)
|
|
37
|
+
- Scaleway Secret Manager (\`scw://secret-manager/...\`)
|
|
38
|
+
|
|
39
|
+
## Better Auth Admin plugin
|
|
40
|
+
|
|
41
|
+
The panel uses the Better Auth **Admin plugin** for user operations (list users, impersonation):
|
|
42
|
+
|
|
43
|
+
- Client calls use \`authClient.admin.*\`.
|
|
44
|
+
- Server-side, ContractSpec enforces that users in a PLATFORM_ADMIN active org have \`User.role\` containing \`admin\` so Better Auth Admin endpoints authorize.
|
|
45
|
+
|
|
46
|
+
## GraphQL surface
|
|
47
|
+
|
|
48
|
+
The platform-admin GraphQL operations are guarded by the active org type and include:
|
|
49
|
+
|
|
50
|
+
- \`platformAdminOrganizations(search, limit, offset)\`
|
|
51
|
+
- \`platformAdminIntegrationSpecs\`
|
|
52
|
+
- \`platformAdminIntegrationConnections(input: { targetOrganizationId, category?, status? })\`
|
|
53
|
+
- \`platformAdminIntegrationConnectionCreate(input)\`
|
|
54
|
+
- \`platformAdminIntegrationConnectionUpdate(input)\`
|
|
55
|
+
- \`platformAdminIntegrationConnectionDelete(targetOrganizationId, connectionId)\`
|
|
56
|
+
|
|
57
|
+
## Key implementation files
|
|
58
|
+
|
|
59
|
+
- Auth + role enforcement: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
|
|
60
|
+
- Admin GraphQL module: \`packages/bundles/contractspec-studio/src/infrastructure/graphql/modules/platform-admin.ts\`
|
|
61
|
+
- Integrations admin service: \`packages/bundles/contractspec-studio/src/modules/platform-integrations/index.ts\`
|
|
62
|
+
- Web route: \`packages/apps/web-landing/src/app/(app-customer)/studio/admin/*\`
|
|
63
|
+
`}];e(t);export{t as tech_studio_platform_admin_panel_DocBlocks};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.project-access-teams`,title:`Studio Project Access via Teams`,summary:`Projects live under organizations; team sharing refines access with an admin/owner override.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/project-access-teams`,tags:[`studio`,`projects`,`teams`,`rbac`,`access-control`],body:`# Studio Project Access via Teams
|
|
2
|
+
|
|
3
|
+
Studio access control is **organization-first** with optional **team-based sharing**.
|
|
4
|
+
|
|
5
|
+
## Data model
|
|
6
|
+
|
|
7
|
+
- \`Team\` and \`TeamMember\` define team membership inside an organization.
|
|
8
|
+
- \`StudioProject\` is owned by an organization.
|
|
9
|
+
- \`StudioProjectTeam\` links projects to 0..N teams.
|
|
10
|
+
|
|
11
|
+
## Access rules
|
|
12
|
+
|
|
13
|
+
- **Admins/owners**: always have access to all projects in the organization.
|
|
14
|
+
- **Org-wide projects**: if a project has **no team links**, all organization members can access it.
|
|
15
|
+
- **Team-scoped projects**: if a project has **one or more team links**, a user must be a member of at least one linked team.
|
|
16
|
+
|
|
17
|
+
## GraphQL surfaces
|
|
18
|
+
|
|
19
|
+
- Read:
|
|
20
|
+
- \`myStudioProjects\` (returns only projects you can access)
|
|
21
|
+
- \`studioProjectBySlug(slug)\` (enforces the same access rules)
|
|
22
|
+
- \`myTeams\`
|
|
23
|
+
- \`projectTeams(projectId)\`
|
|
24
|
+
|
|
25
|
+
- Write:
|
|
26
|
+
- \`createStudioProject(input.teamIds?)\` (teamIds optional)
|
|
27
|
+
- \`setProjectTeams(projectId, teamIds)\` (admin-only)
|
|
28
|
+
|
|
29
|
+
## Related
|
|
30
|
+
+
|
|
31
|
+
+- Team administration + invitations: see \`/docs/tech/studio/team-invitations\`.
|
|
32
|
+
+
|
|
33
|
+
## Notes
|
|
34
|
+
|
|
35
|
+
Payloads and events must avoid secrets/PII. For Sandbox, the model remains local-first and unlogged.
|
|
36
|
+
`}];e(t);export{t as tech_studio_project_access_teams_DocBlocks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.project-routing`,title:`Studio Project Routing`,summary:`Studio uses slugged, project-first routes: /studio/{projectSlug}/* with canonical slug redirects and soft-deleted projects hidden.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/project-routing`,tags:[`studio`,`routing`,`projects`,`slug`,`redirects`],body:"# Studio Project Routing\n\nContractSpec Studio uses a **project-first URL scheme**:\n\n- `/studio/projects` — create, select, and delete projects.\n- `/studio/{projectSlug}/*` — project modules (canvas/specs/deploy/integrations/evolution/learning).\n- `/studio/learning` — learning hub that does not require selecting a project.\n\n## Studio layout shell\n\nStudio routes are wrapped in a dedicated **Studio app shell** (header + footer) that provides in-app navigation (Projects/Learning/Teams), organization switching, and account actions.\n\nProject 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.\n\n## Slug behavior (rename-safe)\n\n- Each project has a `slug` stored in the database (`StudioProject.slug`).\n- When a project name changes, Studio **updates the slug** and stores the previous slug as an alias (`StudioProjectSlugAlias`).\n- Requests to an alias slug are **redirected to the canonical slug**.\n\nGraphQL entrypoint:\n\n- `studioProjectBySlug(slug: String!)` returns:\n - `project`\n - `canonicalSlug`\n - `wasRedirect`\n\n## Deletion behavior (soft delete)\n\nProjects are **soft-deleted**:\n\n- `deleteStudioProject(id: String!)` sets `StudioProject.deletedAt`.\n- All listings and access checks filter `deletedAt = null`.\n- Soft-deleted projects are treated as “not found” in Studio routes and GraphQL access checks.\n\n## Available modules for a selected project\n\nThe following project modules are expected under `/studio/{projectSlug}`:\n\n- `/canvas` — Visual builder canvas (stored via overlays and canvas versions).\n- `/specs` — Spec editor (stored as `StudioSpec`).\n- `/deploy` — Deployments history + triggers (stored as `StudioDeployment`).\n- `/integrations` — Integrations scoped to project (stored as `StudioIntegration`).\n- `/evolution` — Evolution sessions (stored as `EvolutionSession`).\n- `/learning` — Project learning activity.\n"}];e(t);export{t as tech_studio_project_routing_DocBlocks};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.sandbox.unlogged`,title:`Sandbox (unlogged) vs Studio (authenticated)`,summary:`The sandbox is a lightweight, unlogged surface that mirrors Studio navigation without auth or analytics.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/sandbox-unlogged`,tags:[`studio`,`sandbox`,`privacy`,`analytics`],body:`## Sandbox guarantees
|
|
2
|
+
|
|
3
|
+
- Route: \`/sandbox\`
|
|
4
|
+
- **No auth requirement**
|
|
5
|
+
- **No PostHog init**
|
|
6
|
+
- **No Vercel Analytics**
|
|
7
|
+
- Local-only state (in-browser runtime + localStorage where needed)
|
|
8
|
+
|
|
9
|
+
## What Sandbox is for
|
|
10
|
+
|
|
11
|
+
- Try templates and feature modules safely
|
|
12
|
+
- Preview specs/builder/evolution/learning
|
|
13
|
+
- Produce copyable CLI commands (no side effects)
|
|
14
|
+
|
|
15
|
+
## What Sandbox is *not* for
|
|
16
|
+
|
|
17
|
+
- Persisted projects/workspaces
|
|
18
|
+
- Real deployments
|
|
19
|
+
- Organization-scoped integrations (unless explicitly enabled later)
|
|
20
|
+
`}];e(t);export{t as tech_studio_sandbox_unlogged_DocBlocks};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.team-invitations`,title:`Studio Teams & Invitations`,summary:`Admin-only team management and email invitation flow to join an organization and optionally a team.`,kind:`reference`,visibility:`public`,route:`/docs/tech/studio/team-invitations`,tags:[`studio`,`teams`,`invitations`,`access-control`,`onboarding`],body:`# Studio Teams & Invitations
|
|
2
|
+
|
|
3
|
+
Studio uses **organization membership** as the base access model. Teams are optional and used to refine access to projects.
|
|
4
|
+
|
|
5
|
+
## Who can manage teams?
|
|
6
|
+
|
|
7
|
+
- **Admins/owners only**: create, rename, delete teams; manage project team access; issue invitations.
|
|
8
|
+
|
|
9
|
+
## Invitation data model
|
|
10
|
+
|
|
11
|
+
- \`Invitation\` rows are stored under an organization and target an **email** address.
|
|
12
|
+
|
|
13
|
+
- An invitation can optionally target a \`teamId\`, which will grant the user membership in that team upon acceptance.
|
|
14
|
+
|
|
15
|
+
Key fields:
|
|
16
|
+
- \`email\`: invited address (must match the accepting user's account email)
|
|
17
|
+
|
|
18
|
+
- \`status\`: \`pending | accepted | declined | expired\`
|
|
19
|
+
|
|
20
|
+
- \`teamId?\`: optional team to join
|
|
21
|
+
|
|
22
|
+
- \`inviterId\`: user who issued the invitation
|
|
23
|
+
|
|
24
|
+
## GraphQL surfaces
|
|
25
|
+
|
|
26
|
+
- Team CRUD (admin-only):
|
|
27
|
+
|
|
28
|
+
- \`createTeam(name)\`
|
|
29
|
+
|
|
30
|
+
- \`renameTeam(teamId, name)\`
|
|
31
|
+
|
|
32
|
+
- \`deleteTeam(teamId)\`
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
- Invitations (admin-only):
|
|
36
|
+
|
|
37
|
+
- \`organizationInvitations\`
|
|
38
|
+
|
|
39
|
+
- \`inviteToOrganization(email, role?, teamId?)\` → returns \`inviteUrl\` and whether an email was sent
|
|
40
|
+
|
|
41
|
+
## Accepting an invitation
|
|
42
|
+
|
|
43
|
+
The invite link is served as:
|
|
44
|
+
|
|
45
|
+
- \`/invite/{invitationId}\`
|
|
46
|
+
|
|
47
|
+
Acceptance rules:
|
|
48
|
+
- The user must be authenticated.
|
|
49
|
+
|
|
50
|
+
- The authenticated user’s email must match \`Invitation.email\`.
|
|
51
|
+
|
|
52
|
+
- If not already a member, create \`Member(userId, organizationId, role)\`.
|
|
53
|
+
|
|
54
|
+
- If \`teamId\` is present, ensure \`TeamMember(teamId, userId)\`.
|
|
55
|
+
|
|
56
|
+
- Mark invitation \`status='accepted'\` and set \`acceptedAt\`.
|
|
57
|
+
|
|
58
|
+
- Set \`activeOrganizationId\` for the session so \`/studio/*\` routes work immediately.
|
|
59
|
+
|
|
60
|
+
## Email delivery
|
|
61
|
+
|
|
62
|
+
- If \`RESEND_API_KEY\` is set, the system attempts to send an email.
|
|
63
|
+
|
|
64
|
+
- Otherwise, the UI uses the returned \`inviteUrl\` for manual copy/share.
|
|
65
|
+
`}];e(t);export{t as tech_studio_team_invitations_DocBlocks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.workspace_ops`,title:`Workspace ops (repo-linked): list / validate / deps / diff`,summary:`Read-only repo operations used by Studio to inspect and validate a linked ContractSpec workspace.`,kind:`reference`,visibility:`mixed`,route:`/docs/tech/studio/workspace-ops`,tags:[`studio`,`repo`,`workspace`,`validate`,`diff`],body:"## API surface (api-contractspec)\n\nBase: `/api/workspace-ops`\n\nThese endpoints are **read-only** in v1 and never push to git:\n\n- `GET /api/workspace-ops/:integrationId/config?organizationId=`\n- `GET /api/workspace-ops/:integrationId/specs?organizationId=`\n- `POST /api/workspace-ops/:integrationId/validate` (body: organizationId, files?, pattern?)\n- `POST /api/workspace-ops/:integrationId/deps` (body: organizationId, pattern?)\n- `POST /api/workspace-ops/:integrationId/diff` (body: organizationId, specPath, baseline?, breakingOnly?)\n\n## Repo resolution\n\n- The repo root is resolved from the Studio Integration (`IntegrationProvider.GITHUB`) config:\n - `config.repoCachePath` (preferred) or `config.localPath`\n- Resolution is constrained to `CONTRACTSPEC_REPO_CACHE_DIR` (default: `/tmp/contractspec-repos`)\n\n## Intended UX\n\n- Studio Assistant can run these checks and present results as suggestions.\n- Users can copy equivalent CLI commands for local runs:\n - `contractspec validate`\n - `contractspec deps`\n - `contractspec diff --baseline <ref>`\n"}];e(t);export{t as tech_studio_workspace_ops_DocBlocks};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../../registry.js";const t=[{id:`docs.tech.studio.workspaces`,title:`Studio projects, teams, environments`,summary:`Organization-first Studio: projects live under an organization; teams refine access; projects deploy to multiple environments.`,kind:`reference`,visibility:`mixed`,route:`/docs/tech/studio/workspaces`,tags:[`studio`,`projects`,`teams`,`rbac`,`environments`],body:`## Concepts
|
|
2
|
+
|
|
3
|
+
- **Organization**: the primary grouping boundary for Studio projects.
|
|
4
|
+
- **Project**: one application (specs, overlays, deployments, integrations, evolution, learning).
|
|
5
|
+
- **Team**: refines who can see/edit a project within an organization.
|
|
6
|
+
- **Environment**: deployment target (Development / Staging / Production).
|
|
7
|
+
|
|
8
|
+
## Project access (teams + admin override)
|
|
9
|
+
|
|
10
|
+
Studio uses multi-team sharing to refine access:
|
|
11
|
+
|
|
12
|
+
- **Admins/owners** can access all projects.
|
|
13
|
+
- If a project is shared with **no teams**, it is **org-wide** (all org members).
|
|
14
|
+
- If a project is shared with **one or more teams**, it is visible to:
|
|
15
|
+
- admins/owners, and
|
|
16
|
+
- members of any linked team.
|
|
17
|
+
|
|
18
|
+
## Current persistence (DB + GraphQL)
|
|
19
|
+
|
|
20
|
+
- DB (Prisma): \`StudioProject\`, \`Team\`, \`TeamMember\`, \`StudioProjectTeam\`
|
|
21
|
+
- GraphQL:
|
|
22
|
+
- \`myStudioProjects\`
|
|
23
|
+
- \`createStudioProject(input.teamIds?)\`
|
|
24
|
+
- \`myTeams\`
|
|
25
|
+
- \`projectTeams(projectId)\`
|
|
26
|
+
- \`setProjectTeams(projectId, teamIds)\`
|
|
27
|
+
|
|
28
|
+
## UI shell behavior
|
|
29
|
+
|
|
30
|
+
Studio and Sandbox both use a shared shell:
|
|
31
|
+
|
|
32
|
+
- Project selector → Module navigation → Environment selector
|
|
33
|
+
- Always-on Assistant button (floating)
|
|
34
|
+
- Learning journey progress (Studio persists learning events; Sandbox stays local-only)
|
|
35
|
+
|
|
36
|
+
## Routing
|
|
37
|
+
|
|
38
|
+
- \`/studio/projects\`: create/select/delete projects (organization-first).
|
|
39
|
+
- \`/studio/{projectSlug}/*\`: project modules (canvas/specs/deploy/integrations/evolution/learning).
|
|
40
|
+
- \`/studio/learning\`: learning hub without selecting a project.
|
|
41
|
+
`}];e(t);export{t as tech_studio_workspaces_DocBlocks};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import{registerDocBlocks as e}from"../registry.js";const t=[{id:`docs.tech.telemetry.ingest`,title:`Telemetry Ingest Endpoint`,summary:`Server-side telemetry ingestion for ContractSpec clients (VS Code extension, CLI, etc.).`,kind:`reference`,visibility:`internal`,route:`/docs/tech/telemetry/ingest`,tags:[`telemetry`,`api`,`posthog`,`analytics`],body:`# Telemetry Ingest Endpoint
|
|
2
|
+
|
|
3
|
+
The ContractSpec API provides a telemetry ingest endpoint for clients to send product analytics events.
|
|
4
|
+
|
|
5
|
+
## Endpoint
|
|
6
|
+
|
|
7
|
+
\`\`\`
|
|
8
|
+
POST /api/telemetry/ingest
|
|
9
|
+
\`\`\`
|
|
10
|
+
|
|
11
|
+
## Request
|
|
12
|
+
|
|
13
|
+
\`\`\`json
|
|
14
|
+
{
|
|
15
|
+
"event": "contractspec.vscode.command_run",
|
|
16
|
+
"distinct_id": "client-uuid",
|
|
17
|
+
"properties": {
|
|
18
|
+
"command": "validate"
|
|
19
|
+
},
|
|
20
|
+
"timestamp": "2024-01-15T10:30:00.000Z"
|
|
21
|
+
}
|
|
22
|
+
\`\`\`
|
|
23
|
+
|
|
24
|
+
### Headers
|
|
25
|
+
|
|
26
|
+
| Header | Description |
|
|
27
|
+
|--------|-------------|
|
|
28
|
+
| \`x-contractspec-client-id\` | Optional client identifier (used as fallback for distinct_id) |
|
|
29
|
+
| \`Content-Type\` | Must be \`application/json\` |
|
|
30
|
+
|
|
31
|
+
### Body
|
|
32
|
+
|
|
33
|
+
| Field | Type | Required | Description |
|
|
34
|
+
|-------|------|----------|-------------|
|
|
35
|
+
| \`event\` | string | Yes | Event name (e.g., \`contractspec.vscode.activated\`) |
|
|
36
|
+
| \`distinct_id\` | string | Yes | Anonymous client identifier |
|
|
37
|
+
| \`properties\` | object | No | Event properties |
|
|
38
|
+
| \`timestamp\` | string | No | ISO 8601 timestamp |
|
|
39
|
+
|
|
40
|
+
## Response
|
|
41
|
+
|
|
42
|
+
\`\`\`json
|
|
43
|
+
{
|
|
44
|
+
"success": true
|
|
45
|
+
}
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
The endpoint requires \`POSTHOG_PROJECT_KEY\` environment variable to be set. If not configured, events are accepted but not forwarded.
|
|
51
|
+
|
|
52
|
+
| Environment Variable | Description | Default |
|
|
53
|
+
|---------------------|-------------|---------|
|
|
54
|
+
| \`POSTHOG_HOST\` | PostHog host URL | \`https://eu.posthog.com\` |
|
|
55
|
+
| \`POSTHOG_PROJECT_KEY\` | PostHog project API key | (required) |
|
|
56
|
+
|
|
57
|
+
## Privacy
|
|
58
|
+
|
|
59
|
+
- No PII is collected or stored
|
|
60
|
+
- \`distinct_id\` is an anonymous client-generated UUID
|
|
61
|
+
- File paths and source code are never included in events
|
|
62
|
+
- Respects VS Code telemetry settings on the client side
|
|
63
|
+
|
|
64
|
+
## Events
|
|
65
|
+
|
|
66
|
+
### Extension Events
|
|
67
|
+
|
|
68
|
+
| Event | Description | Properties |
|
|
69
|
+
|-------|-------------|------------|
|
|
70
|
+
| \`contractspec.vscode.activated\` | Extension activated | \`version\` |
|
|
71
|
+
| \`contractspec.vscode.command_run\` | Command executed | \`command\` |
|
|
72
|
+
| \`contractspec.vscode.mcp_call\` | MCP call made | \`endpoint\`, \`tool\` |
|
|
73
|
+
|
|
74
|
+
### API Events
|
|
75
|
+
|
|
76
|
+
| Event | Description | Properties |
|
|
77
|
+
|-------|-------------|------------|
|
|
78
|
+
| \`contractspec.api.mcp_request\` | MCP request processed | \`endpoint\`, \`method\`, \`success\`, \`duration_ms\` |
|
|
79
|
+
`},{id:`docs.tech.telemetry.hybrid`,title:`Hybrid Telemetry Model`,summary:`How ContractSpec clients choose between direct PostHog and API-routed telemetry.`,kind:`usage`,visibility:`internal`,route:`/docs/tech/telemetry/hybrid`,tags:[`telemetry`,`architecture`,`posthog`],body:`# Hybrid Telemetry Model
|
|
80
|
+
|
|
81
|
+
ContractSpec uses a hybrid telemetry model where clients can send events either directly to PostHog or via the API server.
|
|
82
|
+
|
|
83
|
+
## Decision Flow
|
|
84
|
+
|
|
85
|
+
\`\`\`
|
|
86
|
+
Is contractspec.api.baseUrl configured?
|
|
87
|
+
├── Yes → Send via /api/telemetry/ingest
|
|
88
|
+
└── No → Is posthogProjectKey configured?
|
|
89
|
+
├── Yes → Send directly to PostHog
|
|
90
|
+
└── No → Telemetry disabled
|
|
91
|
+
\`\`\`
|
|
92
|
+
|
|
93
|
+
## Benefits
|
|
94
|
+
|
|
95
|
+
### Direct PostHog
|
|
96
|
+
- No server dependency
|
|
97
|
+
- Works offline (with batching)
|
|
98
|
+
- Lower latency
|
|
99
|
+
|
|
100
|
+
### Via API
|
|
101
|
+
- Centralized key management (no client-side keys)
|
|
102
|
+
- Server-side enrichment and validation
|
|
103
|
+
- Rate limiting and abuse prevention
|
|
104
|
+
- Easier migration to other providers
|
|
105
|
+
|
|
106
|
+
## Recommendation
|
|
107
|
+
|
|
108
|
+
- **Development**: Use direct PostHog with a dev project key
|
|
109
|
+
- **Production**: Route via API for better governance
|
|
110
|
+
|
|
111
|
+
## Future: OpenTelemetry
|
|
112
|
+
|
|
113
|
+
The current PostHog implementation is behind a simple interface that can be swapped for OpenTelemetry:
|
|
114
|
+
|
|
115
|
+
\`\`\`typescript
|
|
116
|
+
interface TelemetryClient {
|
|
117
|
+
send(event: TelemetryEvent): Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
\`\`\`
|
|
120
|
+
|
|
121
|
+
This allows future migration without changing client code.
|
|
122
|
+
`}];e(t);export{t as tech_telemetry_ingest_DocBlocks};
|