@lssm/example.learning-journey-studio-onboarding 0.0.0-canary-20251221132705 → 0.0.0-canary-20251221153314

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +59 -56
  2. package/.turbo/turbo-build.log +59 -56
  3. package/CHANGELOG.md +4 -4
  4. package/dist/contracts/index.js +1 -1
  5. package/dist/libs/contracts/dist/capabilities/index.js +1 -0
  6. package/dist/libs/contracts/dist/client/react/feature-render.js +2 -1
  7. package/dist/libs/contracts/dist/client/react/form-render.js +1 -1
  8. package/dist/libs/contracts/dist/data-views/data-views.js +1 -0
  9. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +2 -2
  10. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js.map +1 -1
  11. package/dist/libs/contracts/dist/forms/forms.js +1 -0
  12. package/dist/libs/contracts/dist/index.js +13 -10
  13. package/dist/libs/contracts/dist/index.js.map +1 -1
  14. package/dist/libs/contracts/dist/install.js +1 -1
  15. package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +2 -1
  16. package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js.map +1 -1
  17. package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +2 -1
  18. package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js.map +1 -1
  19. package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +2 -1
  20. package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js.map +1 -1
  21. package/dist/libs/contracts/dist/integrations/{contracts.js → operations.js} +4 -3
  22. package/dist/libs/contracts/dist/integrations/operations.js.map +1 -0
  23. package/dist/libs/contracts/dist/knowledge/{contracts.js → operations.js} +4 -3
  24. package/dist/libs/contracts/dist/knowledge/operations.js.map +1 -0
  25. package/dist/libs/contracts/dist/llm/exporters.js +1 -0
  26. package/dist/libs/contracts/dist/llm/exporters.js.map +1 -1
  27. package/dist/libs/contracts/dist/onboarding-base.js +2 -1
  28. package/dist/libs/contracts/dist/onboarding-base.js.map +1 -1
  29. package/dist/libs/contracts/dist/operations/index.js +2 -0
  30. package/dist/libs/contracts/dist/{operation.js → operations/operation.js} +1 -1
  31. package/dist/libs/contracts/dist/operations/operation.js.map +1 -0
  32. package/dist/libs/contracts/dist/operations/registry.js +2 -0
  33. package/dist/libs/contracts/dist/presentations/index.js +2 -0
  34. package/dist/libs/contracts/dist/presentations/presentations.js +2 -0
  35. package/dist/libs/contracts/dist/{presentations.v2.js → presentations/transform-engine.js} +2 -2
  36. package/dist/libs/contracts/dist/presentations/transform-engine.js.map +1 -0
  37. package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +3 -2
  38. package/package.json +6 -6
  39. package/tsconfig.tsbuildinfo +1 -1
  40. package/dist/libs/contracts/dist/data-views.js +0 -1
  41. package/dist/libs/contracts/dist/forms.js +0 -1
  42. package/dist/libs/contracts/dist/integrations/contracts.js.map +0 -1
  43. package/dist/libs/contracts/dist/knowledge/contracts.js.map +0 -1
  44. package/dist/libs/contracts/dist/operation.js.map +0 -1
  45. package/dist/libs/contracts/dist/presentations.js +0 -2
  46. package/dist/libs/contracts/dist/presentations.v2.js.map +0 -1
  47. package/dist/libs/contracts/dist/registry.js +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"exporters.js","names":[],"sources":["../../../../../../../libs/contracts/dist/llm/exporters.js"],"sourcesContent":["import { jsonSchemaForSpec } from \"../jsonschema.js\";\nimport { isEmitDeclRef } from \"../operation.js\";\n\n//#region src/llm/exporters.ts\nconst DEFAULT_SPEC_OPTIONS = {\n\tformat: \"full\",\n\tincludeSchemas: true,\n\tincludeScenarios: true,\n\tincludeExamples: true,\n\tincludePolicy: true,\n\tincludeSideEffects: true\n};\nconst DEFAULT_FEATURE_OPTIONS = {\n\t...DEFAULT_SPEC_OPTIONS,\n\tincludeRelatedSpecs: true,\n\tincludeRelatedEvents: true,\n\tincludeRelatedPresentations: true\n};\n/**\n* Export a single spec to context-focused markdown.\n* Includes: goal, context, description, acceptance scenarios.\n* Best for: Understanding what the spec does, providing context to LLMs.\n*/\nfunction specToContextMarkdown(spec) {\n\tconst m = spec.meta;\n\tconst lines = [];\n\tlines.push(`# ${m.name} (v${m.version})`);\n\tlines.push(\"\");\n\tlines.push(`> ${m.description}`);\n\tlines.push(\"\");\n\tlines.push(`**Type:** ${m.kind} | **Stability:** ${m.stability}`);\n\tlines.push(\"\");\n\tlines.push(\"## Goal\");\n\tlines.push(\"\");\n\tlines.push(m.goal);\n\tlines.push(\"\");\n\tlines.push(\"## Context\");\n\tlines.push(\"\");\n\tlines.push(m.context);\n\tlines.push(\"\");\n\tif (spec.acceptance?.scenarios?.length) {\n\t\tlines.push(\"## Acceptance Criteria\");\n\t\tlines.push(\"\");\n\t\tfor (const s of spec.acceptance.scenarios) {\n\t\t\tlines.push(`### ${s.name}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Given:**\");\n\t\t\tfor (const g of s.given) lines.push(`- ${g}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**When:**\");\n\t\t\tfor (const w of s.when) lines.push(`- ${w}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Then:**\");\n\t\t\tfor (const t of s.then) lines.push(`- ${t}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a single spec to full markdown with all details.\n* Includes: all fields, I/O schemas, policy, events, examples.\n* Best for: Complete documentation, implementation reference.\n*/\nfunction specToFullMarkdown(spec, options = {}) {\n\tconst opts = {\n\t\t...DEFAULT_SPEC_OPTIONS,\n\t\t...options\n\t};\n\tconst m = spec.meta;\n\tconst lines = [];\n\tlines.push(`# ${m.name}.v${m.version}`);\n\tlines.push(\"\");\n\tlines.push(`> ${m.description}`);\n\tlines.push(\"\");\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(\"| Field | Value |\");\n\tlines.push(\"|-------|-------|\");\n\tlines.push(`| Kind | ${m.kind} |`);\n\tlines.push(`| Stability | ${m.stability} |`);\n\tlines.push(`| Owners | ${m.owners.join(\", \")} |`);\n\tlines.push(`| Tags | ${m.tags.join(\", \")} |`);\n\tlines.push(\"\");\n\tlines.push(\"## Goal\");\n\tlines.push(\"\");\n\tlines.push(m.goal);\n\tlines.push(\"\");\n\tlines.push(\"## Context\");\n\tlines.push(\"\");\n\tlines.push(m.context);\n\tlines.push(\"\");\n\tif (opts.includeSchemas) {\n\t\tlines.push(\"## Input/Output\");\n\t\tlines.push(\"\");\n\t\tif (spec.io.input) {\n\t\t\tlines.push(\"### Input Schema\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"```json\");\n\t\t\ttry {\n\t\t\t\tconst schema = jsonSchemaForSpec(spec);\n\t\t\t\tlines.push(JSON.stringify(schema.input ?? {}, null, 2));\n\t\t\t} catch {\n\t\t\t\tlines.push(\"// Schema generation not available\");\n\t\t\t}\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tlines.push(\"### Output Schema\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"```json\");\n\t\ttry {\n\t\t\tconst schema = jsonSchemaForSpec(spec);\n\t\t\tlines.push(JSON.stringify(schema.output ?? {}, null, 2));\n\t\t} catch {\n\t\t\tlines.push(\"// Schema generation not available\");\n\t\t}\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t\tif (spec.io.errors && Object.keys(spec.io.errors).length) {\n\t\t\tlines.push(\"### Error Codes\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"| Code | HTTP | Description | When |\");\n\t\t\tlines.push(\"|------|------|-------------|------|\");\n\t\t\tfor (const [code, err] of Object.entries(spec.io.errors)) lines.push(`| \\`${code}\\` | ${err.http ?? 400} | ${err.description} | ${err.when} |`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (opts.includePolicy) {\n\t\tlines.push(\"## Policy\");\n\t\tlines.push(\"\");\n\t\tlines.push(`- **Auth Required:** ${spec.policy.auth}`);\n\t\tlines.push(`- **Idempotent:** ${spec.policy.idempotent ?? m.kind === \"query\"}`);\n\t\tif (spec.policy.rateLimit) lines.push(`- **Rate Limit:** ${spec.policy.rateLimit.rpm} rpm per ${spec.policy.rateLimit.key}`);\n\t\tif (spec.policy.flags?.length) lines.push(`- **Feature Flags:** ${spec.policy.flags.join(\", \")}`);\n\t\tif (spec.policy.pii?.length) lines.push(`- **PII Fields:** ${spec.policy.pii.join(\", \")}`);\n\t\tif (spec.policy.escalate) lines.push(`- **Escalation:** ${spec.policy.escalate}`);\n\t\tlines.push(\"\");\n\t}\n\tif (opts.includeSideEffects && spec.sideEffects) {\n\t\tif (spec.sideEffects.emits?.length) {\n\t\t\tlines.push(\"## Events Emitted\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const e of spec.sideEffects.emits) if (isEmitDeclRef(e)) lines.push(`- \\`${e.ref.name}.v${e.ref.version}\\` — ${e.when}`);\n\t\t\telse lines.push(`- \\`${e.name}.v${e.version}\\` — ${e.when}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tif (spec.sideEffects.analytics?.length) {\n\t\t\tlines.push(\"## Analytics Events\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const a of spec.sideEffects.analytics) lines.push(`- ${a}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (opts.includeScenarios && spec.acceptance?.scenarios?.length) {\n\t\tlines.push(\"## Acceptance Scenarios\");\n\t\tlines.push(\"\");\n\t\tfor (const s of spec.acceptance.scenarios) {\n\t\t\tlines.push(`### ${s.name}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Given:**\");\n\t\t\tfor (const g of s.given) lines.push(`- ${g}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**When:**\");\n\t\t\tfor (const w of s.when) lines.push(`- ${w}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Then:**\");\n\t\t\tfor (const t of s.then) lines.push(`- ${t}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (opts.includeExamples && spec.acceptance?.examples?.length) {\n\t\tlines.push(\"## Examples\");\n\t\tlines.push(\"\");\n\t\tfor (const ex of spec.acceptance.examples) {\n\t\t\tlines.push(`### ${ex.name}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Input:**\");\n\t\t\tlines.push(\"```json\");\n\t\t\tlines.push(JSON.stringify(ex.input, null, 2));\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Output:**\");\n\t\t\tlines.push(\"```json\");\n\t\t\tlines.push(JSON.stringify(ex.output, null, 2));\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (spec.transport) {\n\t\tlines.push(\"## Transport Configuration\");\n\t\tlines.push(\"\");\n\t\tif (spec.transport.rest) lines.push(`- **REST:** ${spec.transport.rest.method ?? \"POST\"} ${spec.transport.rest.path ?? \"auto\"}`);\n\t\tif (spec.transport.gql) lines.push(`- **GraphQL:** ${spec.transport.gql.field ?? \"auto\"}`);\n\t\tif (spec.transport.mcp) lines.push(`- **MCP Tool:** ${spec.transport.mcp.toolName ?? \"auto\"}`);\n\t\tlines.push(\"\");\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a single spec as an actionable agent prompt.\n* Includes: instructions, full spec, expected output format.\n* Best for: Directly feeding to coding agents for implementation.\n*/\nfunction specToAgentPrompt(spec, options) {\n\tconst taskType = options?.taskType ?? \"implement\";\n\tconst m = spec.meta;\n\tconst lines = [];\n\tconst taskVerb = {\n\t\timplement: \"Implement\",\n\t\ttest: \"Write tests for\",\n\t\trefactor: \"Refactor\",\n\t\treview: \"Review\"\n\t}[taskType];\n\tlines.push(`# Task: ${taskVerb} ${m.name}.v${m.version}`);\n\tlines.push(\"\");\n\tlines.push(\"## Context\");\n\tlines.push(\"\");\n\tlines.push(`You are working on a ContractSpec-driven codebase. This spec defines a ${m.kind} operation.`);\n\tlines.push(\"\");\n\tlines.push(`**Goal:** ${m.goal}`);\n\tlines.push(\"\");\n\tlines.push(`**Background:** ${m.context}`);\n\tlines.push(\"\");\n\tlines.push(\"## Specification\");\n\tlines.push(\"\");\n\tlines.push(specToFullMarkdown(spec));\n\tlines.push(\"\");\n\tlines.push(\"## Instructions\");\n\tlines.push(\"\");\n\tif (taskType === \"implement\") {\n\t\tlines.push(\"Implement this specification following these requirements:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. **Type Safety**: Use TypeScript with strict typing. No `any` types.\");\n\t\tlines.push(\"2. **Input Validation**: Validate input against the schema before processing.\");\n\t\tlines.push(\"3. **Error Handling**: Implement all error cases defined in the spec.\");\n\t\tlines.push(\"4. **Events**: Emit events as specified in sideEffects.emits.\");\n\t\tlines.push(\"5. **Policy**: Respect auth, rate limits, and feature flags.\");\n\t\tlines.push(\"6. **Idempotency**: \" + (spec.policy.idempotent ? \"This operation MUST be idempotent.\" : \"This operation may have side effects.\"));\n\t\tlines.push(\"\");\n\t\tif (spec.policy.pii?.length) {\n\t\t\tlines.push(\"**PII Handling**: The following fields contain PII and must be handled carefully:\");\n\t\t\tfor (const field of spec.policy.pii) lines.push(`- ${field}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t} else if (taskType === \"test\") {\n\t\tlines.push(\"Write comprehensive tests for this specification:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. Test all acceptance scenarios defined in the spec.\");\n\t\tlines.push(\"2. Test all error cases with appropriate assertions.\");\n\t\tlines.push(\"3. Test edge cases and boundary conditions.\");\n\t\tlines.push(\"4. Verify events are emitted correctly.\");\n\t\tlines.push(\"5. Use descriptive test names following the pattern: \\\"should [behavior] when [condition]\\\"\");\n\t\tlines.push(\"\");\n\t} else if (taskType === \"refactor\") {\n\t\tlines.push(\"Refactor this implementation while preserving all behavior:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. Maintain compliance with the specification.\");\n\t\tlines.push(\"2. Improve code clarity and maintainability.\");\n\t\tlines.push(\"3. Reduce complexity where possible.\");\n\t\tlines.push(\"4. Ensure all existing tests still pass.\");\n\t\tlines.push(\"\");\n\t} else if (taskType === \"review\") {\n\t\tlines.push(\"Review this implementation against the specification:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. Verify input/output types match the schema.\");\n\t\tlines.push(\"2. Check all error cases are handled.\");\n\t\tlines.push(\"3. Verify events are emitted as specified.\");\n\t\tlines.push(\"4. Check policy compliance (auth, rate limits).\");\n\t\tlines.push(\"5. Report any deviations from the spec.\");\n\t\tlines.push(\"\");\n\t}\n\tif (options?.existingCode) {\n\t\tlines.push(\"## Existing Code\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"```typescript\");\n\t\tlines.push(options.existingCode);\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Expected Output\");\n\tlines.push(\"\");\n\tif (taskType === \"implement\" || taskType === \"refactor\") {\n\t\tlines.push(\"Provide a complete TypeScript implementation. Include:\");\n\t\tlines.push(\"- Type definitions for input/output\");\n\t\tlines.push(\"- Handler function with proper error handling\");\n\t\tlines.push(\"- JSDoc comments explaining the implementation\");\n\t} else if (taskType === \"test\") lines.push(\"Provide a complete test file using the testing framework available (prefer Vitest).\");\n\telse if (taskType === \"review\") {\n\t\tlines.push(\"Provide a structured review with:\");\n\t\tlines.push(\"- Compliance status (pass/fail for each requirement)\");\n\t\tlines.push(\"- Issues found with severity (error/warning/info)\");\n\t\tlines.push(\"- Suggestions for improvement\");\n\t}\n\tlines.push(\"\");\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a feature module to markdown.\n* Includes all related specs, events, and presentations.\n*/\nfunction featureToMarkdown(feature, deps, options = {}) {\n\tconst opts = {\n\t\t...DEFAULT_FEATURE_OPTIONS,\n\t\t...options\n\t};\n\tconst m = feature.meta;\n\tconst lines = [];\n\tlines.push(`# Feature: ${m.title ?? m.key}`);\n\tlines.push(\"\");\n\tif (m.description) {\n\t\tlines.push(`> ${m.description}`);\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Overview\");\n\tlines.push(\"\");\n\tlines.push(`- **Key:** \\`${m.key}\\``);\n\tlines.push(`- **Stability:** ${m.stability}`);\n\tlines.push(`- **Owners:** ${m.owners.join(\", \")}`);\n\tif (m.tags?.length) lines.push(`- **Tags:** ${m.tags.join(\", \")}`);\n\tlines.push(\"\");\n\tif (feature.operations?.length) {\n\t\tlines.push(\"## Operations\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Name | Version | Type |\");\n\t\tlines.push(\"|------|---------|------|\");\n\t\tfor (const op of feature.operations) {\n\t\t\tconst kind = (deps?.specs?.getSpec(op.name, op.version))?.meta.kind ?? \"unknown\";\n\t\t\tlines.push(`| ${op.name} | v${op.version} | ${kind} |`);\n\t\t}\n\t\tlines.push(\"\");\n\t\tif (opts.includeRelatedSpecs && deps?.specs) {\n\t\t\tlines.push(\"### Operation Details\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const op of feature.operations) {\n\t\t\t\tconst spec = deps.specs.getSpec(op.name, op.version);\n\t\t\t\tif (spec) {\n\t\t\t\t\tlines.push(`---`);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t\tlines.push(specToFullMarkdown(spec, opts));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (feature.events?.length) {\n\t\tlines.push(\"## Events\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Name | Version |\");\n\t\tlines.push(\"|------|---------|\");\n\t\tfor (const evt of feature.events) lines.push(`| ${evt.name} | v${evt.version} |`);\n\t\tlines.push(\"\");\n\t}\n\tif (feature.presentations?.length) {\n\t\tlines.push(\"## Presentations\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Name | Version |\");\n\t\tlines.push(\"|------|---------|\");\n\t\tfor (const pres of feature.presentations) lines.push(`| ${pres.name} | v${pres.version} |`);\n\t\tlines.push(\"\");\n\t\tif (opts.includeRelatedPresentations && deps?.presentations) {\n\t\t\tlines.push(\"### Presentation Details\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const pres of feature.presentations) {\n\t\t\t\tconst p = deps.presentations.get(pres.name, pres.version);\n\t\t\t\tif (p) {\n\t\t\t\t\tlines.push(`#### ${pres.name}.v${pres.version}`);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t\tlines.push(`- **Kind:** ${p.content.kind ?? \"unknown\"}`);\n\t\t\t\t\tif (\"componentKey\" in p.content) lines.push(`- **Component:** ${p.content.componentKey}`);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (feature.capabilities) {\n\t\tif (feature.capabilities.provides?.length) {\n\t\t\tlines.push(\"## Capabilities Provided\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const cap of feature.capabilities.provides) lines.push(`- \\`${cap.key}.v${cap.version}\\``);\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tif (feature.capabilities.requires?.length) {\n\t\t\tlines.push(\"## Capabilities Required\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const cap of feature.capabilities.requires) lines.push(`- \\`${cap.key}\\`${cap.version ? `.v${cap.version}` : \"\"} (${cap.optional ? \"optional\" : \"required\"})`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a presentation descriptor to markdown.\n*/\nfunction presentationToMarkdown(presentation) {\n\tconst m = presentation.meta;\n\tconst lines = [];\n\tlines.push(`# Presentation: ${m.name}.v${m.version}`);\n\tlines.push(\"\");\n\tif (m.description) {\n\t\tlines.push(`> ${m.description}`);\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(`- **Name:** ${m.name}`);\n\tlines.push(`- **Version:** ${m.version}`);\n\tif (m.stability) lines.push(`- **Stability:** ${m.stability}`);\n\tif (m.owners?.length) lines.push(`- **Owners:** ${m.owners.join(\", \")}`);\n\tif (m.tags?.length) lines.push(`- **Tags:** ${m.tags.join(\", \")}`);\n\tlines.push(\"\");\n\tlines.push(\"## Source\");\n\tlines.push(\"\");\n\tlines.push(`- **Type:** ${presentation.source.type}`);\n\tif (presentation.source.type === \"component\") {\n\t\tlines.push(`- **Framework:** ${presentation.source.framework}`);\n\t\tlines.push(`- **Component Key:** ${presentation.source.componentKey}`);\n\t}\n\tlines.push(\"\");\n\tlines.push(\"## Supported Targets\");\n\tlines.push(\"\");\n\tfor (const target of presentation.targets) lines.push(`- ${target}`);\n\tlines.push(\"\");\n\tif (presentation.policy) {\n\t\tlines.push(\"## Policy\");\n\t\tlines.push(\"\");\n\t\tif (presentation.policy.flags?.length) lines.push(`- **Feature Flags:** ${presentation.policy.flags.join(\", \")}`);\n\t\tif (presentation.policy.pii?.length) lines.push(`- **PII Fields:** ${presentation.policy.pii.join(\", \")}`);\n\t\tlines.push(\"\");\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export an event spec to markdown.\n*/\nfunction eventToMarkdown(event) {\n\tconst lines = [];\n\tlines.push(`# Event: ${event.name}.v${event.version}`);\n\tlines.push(\"\");\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(`- **Name:** ${event.name}`);\n\tlines.push(`- **Version:** ${event.version}`);\n\tif (event.description) lines.push(`- **Description:** ${event.description}`);\n\tlines.push(\"\");\n\tlines.push(\"## Payload Schema\");\n\tlines.push(\"\");\n\tlines.push(\"```json\");\n\ttry {\n\t\tconst zodSchema = event.payload.getZod();\n\t\tif (\"shape\" in zodSchema && zodSchema.shape) {\n\t\t\tconst shape = zodSchema.shape;\n\t\t\tconst fields = Object.keys(shape);\n\t\t\tlines.push(JSON.stringify({ fields }, null, 2));\n\t\t} else lines.push(\"// Payload schema available at runtime\");\n\t} catch {\n\t\tlines.push(\"// Schema details available at runtime\");\n\t}\n\tlines.push(\"```\");\n\tlines.push(\"\");\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a DocBlock to markdown (already markdown, but formatted consistently).\n*/\nfunction docBlockToMarkdown(doc) {\n\tconst lines = [];\n\tlines.push(`# ${doc.title}`);\n\tlines.push(\"\");\n\tif (doc.summary) {\n\t\tlines.push(`> ${doc.summary}`);\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(`- **ID:** ${doc.id}`);\n\tlines.push(`- **Kind:** ${doc.kind ?? \"reference\"}`);\n\tlines.push(`- **Visibility:** ${doc.visibility ?? \"public\"}`);\n\tif (doc.tags?.length) lines.push(`- **Tags:** ${doc.tags.join(\", \")}`);\n\tif (doc.owners?.length) lines.push(`- **Owners:** ${doc.owners.join(\", \")}`);\n\tif (doc.domain) lines.push(`- **Domain:** ${doc.domain}`);\n\tlines.push(\"\");\n\tlines.push(\"## Content\");\n\tlines.push(\"\");\n\tlines.push(doc.body);\n\tlines.push(\"\");\n\tif (doc.links?.length) {\n\t\tlines.push(\"## Related Links\");\n\t\tlines.push(\"\");\n\t\tfor (const link of doc.links) lines.push(`- [${link.label}](${link.href})`);\n\t\tlines.push(\"\");\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a spec with a specific format.\n* Convenience function that wraps the format-specific functions.\n*/\nfunction exportSpec(spec, options = {}) {\n\tconst format = options.format ?? \"full\";\n\tlet markdown;\n\tswitch (format) {\n\t\tcase \"context\":\n\t\t\tmarkdown = specToContextMarkdown(spec);\n\t\t\tbreak;\n\t\tcase \"prompt\":\n\t\t\tmarkdown = specToAgentPrompt(spec);\n\t\t\tbreak;\n\t\tcase \"full\":\n\t\tdefault:\n\t\t\tmarkdown = specToFullMarkdown(spec, options);\n\t\t\tbreak;\n\t}\n\treturn {\n\t\tspec,\n\t\tmarkdown,\n\t\tformat,\n\t\tmeta: {\n\t\t\tspecName: spec.meta.name,\n\t\t\tspecVersion: spec.meta.version,\n\t\t\texportedAt: (/* @__PURE__ */ new Date()).toISOString(),\n\t\t\twordCount: markdown.split(/\\s+/).length\n\t\t}\n\t};\n}\n/**\n* Export a feature with a specific format.\n*/\nfunction exportFeature(feature, deps, options = {}) {\n\tconst format = options.format ?? \"full\";\n\treturn {\n\t\tfeature,\n\t\tmarkdown: featureToMarkdown(feature, deps, options),\n\t\tformat,\n\t\tincludedSpecs: feature.operations?.map((o) => `${o.name}.v${o.version}`) ?? [],\n\t\tincludedEvents: feature.events?.map((e) => `${e.name}.v${e.version}`) ?? [],\n\t\tincludedPresentations: feature.presentations?.map((p) => `${p.name}.v${p.version}`) ?? []\n\t};\n}\n\n//#endregion\nexport { docBlockToMarkdown, eventToMarkdown, exportFeature, exportSpec, featureToMarkdown, presentationToMarkdown, specToAgentPrompt, specToContextMarkdown, specToFullMarkdown };"],"mappings":";;;AAIA,MAAM,uBAAuB;CAC5B,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,eAAe;CACf,oBAAoB;CACpB;AACD,MAAM,0BAA0B;CAC/B,GAAG;CACH,qBAAqB;CACrB,sBAAsB;CACtB,6BAA6B;CAC7B"}
1
+ {"version":3,"file":"exporters.js","names":[],"sources":["../../../../../../../libs/contracts/dist/llm/exporters.js"],"sourcesContent":["import { jsonSchemaForSpec } from \"../jsonschema.js\";\nimport { isEmitDeclRef } from \"../operations/operation.js\";\nimport \"../operations/index.js\";\n\n//#region src/llm/exporters.ts\nconst DEFAULT_SPEC_OPTIONS = {\n\tformat: \"full\",\n\tincludeSchemas: true,\n\tincludeScenarios: true,\n\tincludeExamples: true,\n\tincludePolicy: true,\n\tincludeSideEffects: true\n};\nconst DEFAULT_FEATURE_OPTIONS = {\n\t...DEFAULT_SPEC_OPTIONS,\n\tincludeRelatedSpecs: true,\n\tincludeRelatedEvents: true,\n\tincludeRelatedPresentations: true\n};\n/**\n* Export a single spec to context-focused markdown.\n* Includes: goal, context, description, acceptance scenarios.\n* Best for: Understanding what the spec does, providing context to LLMs.\n*/\nfunction operationSpecToContextMarkdown(spec) {\n\tconst m = spec.meta;\n\tconst lines = [];\n\tlines.push(`# ${m.name} (v${m.version})`);\n\tlines.push(\"\");\n\tlines.push(`> ${m.description}`);\n\tlines.push(\"\");\n\tlines.push(`**Type:** ${m.kind} | **Stability:** ${m.stability}`);\n\tlines.push(\"\");\n\tlines.push(\"## Goal\");\n\tlines.push(\"\");\n\tlines.push(m.goal);\n\tlines.push(\"\");\n\tlines.push(\"## Context\");\n\tlines.push(\"\");\n\tlines.push(m.context);\n\tlines.push(\"\");\n\tif (spec.acceptance?.scenarios?.length) {\n\t\tlines.push(\"## Acceptance Criteria\");\n\t\tlines.push(\"\");\n\t\tfor (const s of spec.acceptance.scenarios) {\n\t\t\tlines.push(`### ${s.name}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Given:**\");\n\t\t\tfor (const g of s.given) lines.push(`- ${g}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**When:**\");\n\t\t\tfor (const w of s.when) lines.push(`- ${w}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Then:**\");\n\t\t\tfor (const t of s.then) lines.push(`- ${t}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a single spec to full markdown with all details.\n* Includes: all fields, I/O schemas, policy, events, examples.\n* Best for: Complete documentation, implementation reference.\n*/\nfunction operationSpecToFullMarkdown(spec, options = {}) {\n\tconst opts = {\n\t\t...DEFAULT_SPEC_OPTIONS,\n\t\t...options\n\t};\n\tconst m = spec.meta;\n\tconst lines = [];\n\tlines.push(`# ${m.name}.v${m.version}`);\n\tlines.push(\"\");\n\tlines.push(`> ${m.description}`);\n\tlines.push(\"\");\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(\"| Field | Value |\");\n\tlines.push(\"|-------|-------|\");\n\tlines.push(`| Kind | ${m.kind} |`);\n\tlines.push(`| Stability | ${m.stability} |`);\n\tlines.push(`| Owners | ${m.owners.join(\", \")} |`);\n\tlines.push(`| Tags | ${m.tags.join(\", \")} |`);\n\tlines.push(\"\");\n\tlines.push(\"## Goal\");\n\tlines.push(\"\");\n\tlines.push(m.goal);\n\tlines.push(\"\");\n\tlines.push(\"## Context\");\n\tlines.push(\"\");\n\tlines.push(m.context);\n\tlines.push(\"\");\n\tif (opts.includeSchemas) {\n\t\tlines.push(\"## Input/Output\");\n\t\tlines.push(\"\");\n\t\tif (spec.io.input) {\n\t\t\tlines.push(\"### Input Schema\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"```json\");\n\t\t\ttry {\n\t\t\t\tconst schema = jsonSchemaForSpec(spec);\n\t\t\t\tlines.push(JSON.stringify(schema.input ?? {}, null, 2));\n\t\t\t} catch {\n\t\t\t\tlines.push(\"// Schema generation not available\");\n\t\t\t}\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tlines.push(\"### Output Schema\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"```json\");\n\t\ttry {\n\t\t\tconst schema = jsonSchemaForSpec(spec);\n\t\t\tlines.push(JSON.stringify(schema.output ?? {}, null, 2));\n\t\t} catch {\n\t\t\tlines.push(\"// Schema generation not available\");\n\t\t}\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t\tif (spec.io.errors && Object.keys(spec.io.errors).length) {\n\t\t\tlines.push(\"### Error Codes\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"| Code | HTTP | Description | When |\");\n\t\t\tlines.push(\"|------|------|-------------|------|\");\n\t\t\tfor (const [code, err] of Object.entries(spec.io.errors)) lines.push(`| \\`${code}\\` | ${err.http ?? 400} | ${err.description} | ${err.when} |`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (opts.includePolicy) {\n\t\tlines.push(\"## Policy\");\n\t\tlines.push(\"\");\n\t\tlines.push(`- **Auth Required:** ${spec.policy.auth}`);\n\t\tlines.push(`- **Idempotent:** ${spec.policy.idempotent ?? m.kind === \"query\"}`);\n\t\tif (spec.policy.rateLimit) lines.push(`- **Rate Limit:** ${spec.policy.rateLimit.rpm} rpm per ${spec.policy.rateLimit.key}`);\n\t\tif (spec.policy.flags?.length) lines.push(`- **Feature Flags:** ${spec.policy.flags.join(\", \")}`);\n\t\tif (spec.policy.pii?.length) lines.push(`- **PII Fields:** ${spec.policy.pii.join(\", \")}`);\n\t\tif (spec.policy.escalate) lines.push(`- **Escalation:** ${spec.policy.escalate}`);\n\t\tlines.push(\"\");\n\t}\n\tif (opts.includeSideEffects && spec.sideEffects) {\n\t\tif (spec.sideEffects.emits?.length) {\n\t\t\tlines.push(\"## Events Emitted\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const e of spec.sideEffects.emits) if (isEmitDeclRef(e)) lines.push(`- \\`${e.ref.name}.v${e.ref.version}\\` — ${e.when}`);\n\t\t\telse lines.push(`- \\`${e.name}.v${e.version}\\` — ${e.when}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tif (spec.sideEffects.analytics?.length) {\n\t\t\tlines.push(\"## Analytics Events\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const a of spec.sideEffects.analytics) lines.push(`- ${a}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (opts.includeScenarios && spec.acceptance?.scenarios?.length) {\n\t\tlines.push(\"## Acceptance Scenarios\");\n\t\tlines.push(\"\");\n\t\tfor (const s of spec.acceptance.scenarios) {\n\t\t\tlines.push(`### ${s.name}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Given:**\");\n\t\t\tfor (const g of s.given) lines.push(`- ${g}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**When:**\");\n\t\t\tfor (const w of s.when) lines.push(`- ${w}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Then:**\");\n\t\t\tfor (const t of s.then) lines.push(`- ${t}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (opts.includeExamples && spec.acceptance?.examples?.length) {\n\t\tlines.push(\"## Examples\");\n\t\tlines.push(\"\");\n\t\tfor (const ex of spec.acceptance.examples) {\n\t\t\tlines.push(`### ${ex.name}`);\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Input:**\");\n\t\t\tlines.push(\"```json\");\n\t\t\tlines.push(JSON.stringify(ex.input, null, 2));\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"**Output:**\");\n\t\t\tlines.push(\"```json\");\n\t\t\tlines.push(JSON.stringify(ex.output, null, 2));\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\tif (spec.transport) {\n\t\tlines.push(\"## Transport Configuration\");\n\t\tlines.push(\"\");\n\t\tif (spec.transport.rest) lines.push(`- **REST:** ${spec.transport.rest.method ?? \"POST\"} ${spec.transport.rest.path ?? \"auto\"}`);\n\t\tif (spec.transport.gql) lines.push(`- **GraphQL:** ${spec.transport.gql.field ?? \"auto\"}`);\n\t\tif (spec.transport.mcp) lines.push(`- **MCP Tool:** ${spec.transport.mcp.toolName ?? \"auto\"}`);\n\t\tlines.push(\"\");\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a single spec as an actionable agent prompt.\n* Includes: instructions, full spec, expected output format.\n* Best for: Directly feeding to coding agents for implementation.\n*/\nfunction operationSpecToAgentPrompt(spec, options) {\n\tconst taskType = options?.taskType ?? \"implement\";\n\tconst m = spec.meta;\n\tconst lines = [];\n\tconst taskVerb = {\n\t\timplement: \"Implement\",\n\t\ttest: \"Write tests for\",\n\t\trefactor: \"Refactor\",\n\t\treview: \"Review\"\n\t}[taskType];\n\tlines.push(`# Task: ${taskVerb} ${m.name}.v${m.version}`);\n\tlines.push(\"\");\n\tlines.push(\"## Context\");\n\tlines.push(\"\");\n\tlines.push(`You are working on a ContractSpec-driven codebase. This spec defines a ${m.kind} operation.`);\n\tlines.push(\"\");\n\tlines.push(`**Goal:** ${m.goal}`);\n\tlines.push(\"\");\n\tlines.push(`**Background:** ${m.context}`);\n\tlines.push(\"\");\n\tlines.push(\"## Specification\");\n\tlines.push(\"\");\n\tlines.push(operationSpecToFullMarkdown(spec));\n\tlines.push(\"\");\n\tlines.push(\"## Instructions\");\n\tlines.push(\"\");\n\tif (taskType === \"implement\") {\n\t\tlines.push(\"Implement this specification following these requirements:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. **Type Safety**: Use TypeScript with strict typing. No `any` types.\");\n\t\tlines.push(\"2. **Input Validation**: Validate input against the schema before processing.\");\n\t\tlines.push(\"3. **Error Handling**: Implement all error cases defined in the spec.\");\n\t\tlines.push(\"4. **Events**: Emit events as specified in sideEffects.emits.\");\n\t\tlines.push(\"5. **Policy**: Respect auth, rate limits, and feature flags.\");\n\t\tlines.push(\"6. **Idempotency**: \" + (spec.policy.idempotent ? \"This operation MUST be idempotent.\" : \"This operation may have side effects.\"));\n\t\tlines.push(\"\");\n\t\tif (spec.policy.pii?.length) {\n\t\t\tlines.push(\"**PII Handling**: The following fields contain PII and must be handled carefully:\");\n\t\t\tfor (const field of spec.policy.pii) lines.push(`- ${field}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t} else if (taskType === \"test\") {\n\t\tlines.push(\"Write comprehensive tests for this specification:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. Test all acceptance scenarios defined in the spec.\");\n\t\tlines.push(\"2. Test all error cases with appropriate assertions.\");\n\t\tlines.push(\"3. Test edge cases and boundary conditions.\");\n\t\tlines.push(\"4. Verify events are emitted correctly.\");\n\t\tlines.push(\"5. Use descriptive test names following the pattern: \\\"should [behavior] when [condition]\\\"\");\n\t\tlines.push(\"\");\n\t} else if (taskType === \"refactor\") {\n\t\tlines.push(\"Refactor this implementation while preserving all behavior:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. Maintain compliance with the specification.\");\n\t\tlines.push(\"2. Improve code clarity and maintainability.\");\n\t\tlines.push(\"3. Reduce complexity where possible.\");\n\t\tlines.push(\"4. Ensure all existing tests still pass.\");\n\t\tlines.push(\"\");\n\t} else if (taskType === \"review\") {\n\t\tlines.push(\"Review this implementation against the specification:\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"1. Verify input/output types match the schema.\");\n\t\tlines.push(\"2. Check all error cases are handled.\");\n\t\tlines.push(\"3. Verify events are emitted as specified.\");\n\t\tlines.push(\"4. Check policy compliance (auth, rate limits).\");\n\t\tlines.push(\"5. Report any deviations from the spec.\");\n\t\tlines.push(\"\");\n\t}\n\tif (options?.existingCode) {\n\t\tlines.push(\"## Existing Code\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"```typescript\");\n\t\tlines.push(options.existingCode);\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Expected Output\");\n\tlines.push(\"\");\n\tif (taskType === \"implement\" || taskType === \"refactor\") {\n\t\tlines.push(\"Provide a complete TypeScript implementation. Include:\");\n\t\tlines.push(\"- Type definitions for input/output\");\n\t\tlines.push(\"- Handler function with proper error handling\");\n\t\tlines.push(\"- JSDoc comments explaining the implementation\");\n\t} else if (taskType === \"test\") lines.push(\"Provide a complete test file using the testing framework available (prefer Vitest).\");\n\telse if (taskType === \"review\") {\n\t\tlines.push(\"Provide a structured review with:\");\n\t\tlines.push(\"- Compliance status (pass/fail for each requirement)\");\n\t\tlines.push(\"- Issues found with severity (error/warning/info)\");\n\t\tlines.push(\"- Suggestions for improvement\");\n\t}\n\tlines.push(\"\");\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a feature module to markdown.\n* Includes all related specs, events, and presentations.\n*/\nfunction featureToMarkdown(feature, deps, options = {}) {\n\tconst opts = {\n\t\t...DEFAULT_FEATURE_OPTIONS,\n\t\t...options\n\t};\n\tconst m = feature.meta;\n\tconst lines = [];\n\tlines.push(`# Feature: ${m.title ?? m.key}`);\n\tlines.push(\"\");\n\tif (m.description) {\n\t\tlines.push(`> ${m.description}`);\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Overview\");\n\tlines.push(\"\");\n\tlines.push(`- **Key:** \\`${m.key}\\``);\n\tlines.push(`- **Stability:** ${m.stability}`);\n\tlines.push(`- **Owners:** ${m.owners.join(\", \")}`);\n\tif (m.tags?.length) lines.push(`- **Tags:** ${m.tags.join(\", \")}`);\n\tlines.push(\"\");\n\tif (feature.operations?.length) {\n\t\tlines.push(\"## Operations\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Name | Version | Type |\");\n\t\tlines.push(\"|------|---------|------|\");\n\t\tfor (const op of feature.operations) {\n\t\t\tconst kind = (deps?.specs?.getSpec(op.name, op.version))?.meta.kind ?? \"unknown\";\n\t\t\tlines.push(`| ${op.name} | v${op.version} | ${kind} |`);\n\t\t}\n\t\tlines.push(\"\");\n\t\tif (opts.includeRelatedSpecs && deps?.specs) {\n\t\t\tlines.push(\"### Operation Details\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const op of feature.operations) {\n\t\t\t\tconst spec = deps.specs.getSpec(op.name, op.version);\n\t\t\t\tif (spec) {\n\t\t\t\t\tlines.push(`---`);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t\tlines.push(operationSpecToFullMarkdown(spec, opts));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (feature.events?.length) {\n\t\tlines.push(\"## Events\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Name | Version |\");\n\t\tlines.push(\"|------|---------|\");\n\t\tfor (const evt of feature.events) lines.push(`| ${evt.name} | v${evt.version} |`);\n\t\tlines.push(\"\");\n\t}\n\tif (feature.presentations?.length) {\n\t\tlines.push(\"## Presentations\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Name | Version |\");\n\t\tlines.push(\"|------|---------|\");\n\t\tfor (const pres of feature.presentations) lines.push(`| ${pres.name} | v${pres.version} |`);\n\t\tlines.push(\"\");\n\t\tif (opts.includeRelatedPresentations && deps?.presentations) {\n\t\t\tlines.push(\"### Presentation Details\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const pres of feature.presentations) {\n\t\t\t\tconst p = deps.presentations.get(pres.name, pres.version);\n\t\t\t\tif (p) {\n\t\t\t\t\tlines.push(`#### ${pres.name}.v${pres.version}`);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t\tlines.push(`- **Kind:** ${p.content.kind ?? \"unknown\"}`);\n\t\t\t\t\tif (\"componentKey\" in p.content) lines.push(`- **Component:** ${p.content.componentKey}`);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (feature.capabilities) {\n\t\tif (feature.capabilities.provides?.length) {\n\t\t\tlines.push(\"## Capabilities Provided\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const cap of feature.capabilities.provides) lines.push(`- \\`${cap.key}.v${cap.version}\\``);\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tif (feature.capabilities.requires?.length) {\n\t\t\tlines.push(\"## Capabilities Required\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const cap of feature.capabilities.requires) lines.push(`- \\`${cap.key}\\`${cap.version ? `.v${cap.version}` : \"\"} (${cap.optional ? \"optional\" : \"required\"})`);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a presentation descriptor to markdown.\n*/\nfunction presentationToMarkdown(presentation) {\n\tconst m = presentation.meta;\n\tconst lines = [];\n\tlines.push(`# Presentation: ${m.name}.v${m.version}`);\n\tlines.push(\"\");\n\tif (m.description) {\n\t\tlines.push(`> ${m.description}`);\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(`- **Name:** ${m.name}`);\n\tlines.push(`- **Version:** ${m.version}`);\n\tif (m.stability) lines.push(`- **Stability:** ${m.stability}`);\n\tif (m.owners?.length) lines.push(`- **Owners:** ${m.owners.join(\", \")}`);\n\tif (m.tags?.length) lines.push(`- **Tags:** ${m.tags.join(\", \")}`);\n\tlines.push(\"\");\n\tlines.push(\"## Source\");\n\tlines.push(\"\");\n\tlines.push(`- **Type:** ${presentation.source.type}`);\n\tif (presentation.source.type === \"component\") {\n\t\tlines.push(`- **Framework:** ${presentation.source.framework}`);\n\t\tlines.push(`- **Component Key:** ${presentation.source.componentKey}`);\n\t}\n\tlines.push(\"\");\n\tlines.push(\"## Supported Targets\");\n\tlines.push(\"\");\n\tfor (const target of presentation.targets) lines.push(`- ${target}`);\n\tlines.push(\"\");\n\tif (presentation.policy) {\n\t\tlines.push(\"## Policy\");\n\t\tlines.push(\"\");\n\t\tif (presentation.policy.flags?.length) lines.push(`- **Feature Flags:** ${presentation.policy.flags.join(\", \")}`);\n\t\tif (presentation.policy.pii?.length) lines.push(`- **PII Fields:** ${presentation.policy.pii.join(\", \")}`);\n\t\tlines.push(\"\");\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export an event spec to markdown.\n*/\nfunction eventToMarkdown(event) {\n\tconst lines = [];\n\tlines.push(`# Event: ${event.name}.v${event.version}`);\n\tlines.push(\"\");\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(`- **Name:** ${event.name}`);\n\tlines.push(`- **Version:** ${event.version}`);\n\tif (event.description) lines.push(`- **Description:** ${event.description}`);\n\tlines.push(\"\");\n\tlines.push(\"## Payload Schema\");\n\tlines.push(\"\");\n\tlines.push(\"```json\");\n\ttry {\n\t\tconst zodSchema = event.payload.getZod();\n\t\tif (\"shape\" in zodSchema && zodSchema.shape) {\n\t\t\tconst shape = zodSchema.shape;\n\t\t\tconst fields = Object.keys(shape);\n\t\t\tlines.push(JSON.stringify({ fields }, null, 2));\n\t\t} else lines.push(\"// Payload schema available at runtime\");\n\t} catch {\n\t\tlines.push(\"// Schema details available at runtime\");\n\t}\n\tlines.push(\"```\");\n\tlines.push(\"\");\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a DocBlock to markdown (already markdown, but formatted consistently).\n*/\nfunction docBlockToMarkdown(doc) {\n\tconst lines = [];\n\tlines.push(`# ${doc.title}`);\n\tlines.push(\"\");\n\tif (doc.summary) {\n\t\tlines.push(`> ${doc.summary}`);\n\t\tlines.push(\"\");\n\t}\n\tlines.push(\"## Metadata\");\n\tlines.push(\"\");\n\tlines.push(`- **ID:** ${doc.id}`);\n\tlines.push(`- **Kind:** ${doc.kind ?? \"reference\"}`);\n\tlines.push(`- **Visibility:** ${doc.visibility ?? \"public\"}`);\n\tif (doc.tags?.length) lines.push(`- **Tags:** ${doc.tags.join(\", \")}`);\n\tif (doc.owners?.length) lines.push(`- **Owners:** ${doc.owners.join(\", \")}`);\n\tif (doc.domain) lines.push(`- **Domain:** ${doc.domain}`);\n\tlines.push(\"\");\n\tlines.push(\"## Content\");\n\tlines.push(\"\");\n\tlines.push(doc.body);\n\tlines.push(\"\");\n\tif (doc.links?.length) {\n\t\tlines.push(\"## Related Links\");\n\t\tlines.push(\"\");\n\t\tfor (const link of doc.links) lines.push(`- [${link.label}](${link.href})`);\n\t\tlines.push(\"\");\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Export a spec with a specific format.\n* Convenience function that wraps the format-specific functions.\n*/\nfunction exportSpec(spec, options = {}) {\n\tconst format = options.format ?? \"full\";\n\tlet markdown;\n\tswitch (format) {\n\t\tcase \"context\":\n\t\t\tmarkdown = operationSpecToContextMarkdown(spec);\n\t\t\tbreak;\n\t\tcase \"prompt\":\n\t\t\tmarkdown = operationSpecToAgentPrompt(spec);\n\t\t\tbreak;\n\t\tcase \"full\":\n\t\tdefault:\n\t\t\tmarkdown = operationSpecToFullMarkdown(spec, options);\n\t\t\tbreak;\n\t}\n\treturn {\n\t\tspec,\n\t\tmarkdown,\n\t\tformat,\n\t\tmeta: {\n\t\t\tspecName: spec.meta.name,\n\t\t\tspecVersion: spec.meta.version,\n\t\t\texportedAt: (/* @__PURE__ */ new Date()).toISOString(),\n\t\t\twordCount: markdown.split(/\\s+/).length\n\t\t}\n\t};\n}\n/**\n* Export a feature with a specific format.\n*/\nfunction exportFeature(feature, deps, options = {}) {\n\tconst format = options.format ?? \"full\";\n\treturn {\n\t\tfeature,\n\t\tmarkdown: featureToMarkdown(feature, deps, options),\n\t\tformat,\n\t\tincludedSpecs: feature.operations?.map((o) => `${o.name}.v${o.version}`) ?? [],\n\t\tincludedEvents: feature.events?.map((e) => `${e.name}.v${e.version}`) ?? [],\n\t\tincludedPresentations: feature.presentations?.map((p) => `${p.name}.v${p.version}`) ?? []\n\t};\n}\n\n//#endregion\nexport { docBlockToMarkdown, eventToMarkdown, exportFeature, exportSpec, featureToMarkdown, operationSpecToAgentPrompt, operationSpecToContextMarkdown, operationSpecToFullMarkdown, presentationToMarkdown };"],"mappings":";;;;AAKA,MAAM,uBAAuB;CAC5B,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,eAAe;CACf,oBAAoB;CACpB;AACD,MAAM,0BAA0B;CAC/B,GAAG;CACH,qBAAqB;CACrB,sBAAsB;CACtB,6BAA6B;CAC7B"}
@@ -1,6 +1,7 @@
1
1
  import { E5, x8 } from "./schema/dist/index.js";
2
- import { defineCommand, defineQuery } from "./operation.js";
3
2
  import { OwnersEnum, StabilityEnum } from "./ownership.js";
3
+ import { defineCommand, defineQuery } from "./operations/operation.js";
4
+ import "./operations/index.js";
4
5
 
5
6
  //#region ../../libs/contracts/dist/onboarding-base.js
6
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"onboarding-base.js","names":[],"sources":["../../../../../../libs/contracts/dist/onboarding-base.js"],"sourcesContent":["import { E5, x8 } from \"./schema/dist/index.js\";\nimport { defineCommand, defineQuery } from \"./operation.js\";\nimport { OwnersEnum, StabilityEnum } from \"./ownership.js\";\n\n//#region src/onboarding-base.ts\n/**\n* Shared base contracts for onboarding flows across verticals.\n* These operations are reusable for any app that needs multi-step onboarding with draft persistence.\n*/\n/** Save/update onboarding draft (auto-save during flow) */\nconst SaveOnboardingDraftInput = new x8({\n\tname: \"SaveOnboardingDraftInput\",\n\tdescription: \"Input for saving onboarding draft\",\n\tfields: { data: {\n\t\ttype: E5.JSON(),\n\t\tisOptional: false\n\t} }\n});\nconst SaveOnboardingDraftOutput = new x8({\n\tname: \"SaveOnboardingDraftOutput\",\n\tdescription: \"Output for saving onboarding draft\",\n\tfields: {\n\t\tid: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: false\n\t\t},\n\t\torganizationId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: false\n\t\t}\n\t}\n});\nconst SaveOnboardingDraftBaseSpec = defineCommand({\n\tmeta: {\n\t\tname: \"base.onboarding.saveDraft\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\", \"draft\"],\n\t\tdescription: \"Save or update onboarding draft for active organization\",\n\t\tgoal: \"Persist onboarding progress incrementally for resumption and safety\",\n\t\tcontext: \"Auto-saves every few seconds during onboarding; enables users to leave and resume\"\n\t},\n\tio: {\n\t\tinput: SaveOnboardingDraftInput,\n\t\toutput: SaveOnboardingDraftOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"saveOnboardingDraft\" },\n\t\trest: { method: \"POST\" }\n\t}\n});\n/** Get current onboarding draft (on mount/restore) */\nconst GetOnboardingDraftOutput = new x8({\n\tname: \"GetOnboardingDraftOutput\",\n\tdescription: \"Onboarding draft payload\",\n\tfields: {\n\t\tid: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t},\n\t\torganizationId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t},\n\t\tdata: {\n\t\t\ttype: E5.JSON(),\n\t\t\tisOptional: true\n\t\t},\n\t\tcreatedAt: {\n\t\t\ttype: E5.DateTime(),\n\t\t\tisOptional: true\n\t\t},\n\t\tupdatedAt: {\n\t\t\ttype: E5.DateTime(),\n\t\t\tisOptional: true\n\t\t}\n\t}\n});\nconst GetOnboardingDraftBaseSpec = defineQuery({\n\tmeta: {\n\t\tname: \"base.onboarding.getDraft\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\", \"draft\"],\n\t\tdescription: \"Get onboarding draft for active organization\",\n\t\tgoal: \"Retrieve saved onboarding progress\",\n\t\tcontext: \"Called on mount to restore in-progress onboarding\"\n\t},\n\tio: {\n\t\tinput: null,\n\t\toutput: GetOnboardingDraftOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"getOnboardingDraft\" },\n\t\trest: { method: \"GET\" }\n\t}\n});\n/** Delete onboarding draft (cleanup after completion or cancel) */\nconst DeleteOnboardingDraftOutput = new x8({\n\tname: \"DeleteOnboardingDraftOutput\",\n\tdescription: \"Result of delete operation\",\n\tfields: { ok: {\n\t\ttype: E5.Boolean(),\n\t\tisOptional: false\n\t} }\n});\nconst DeleteOnboardingDraftBaseSpec = defineCommand({\n\tmeta: {\n\t\tname: \"base.onboarding.deleteDraft\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\", \"draft\"],\n\t\tdescription: \"Delete onboarding draft for active organization\",\n\t\tgoal: \"Clear draft after completion or if user wants to restart\",\n\t\tcontext: \"Called after successful onboarding or explicit user reset\"\n\t},\n\tio: {\n\t\tinput: null,\n\t\toutput: DeleteOnboardingDraftOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"deleteOnboardingDraft\" },\n\t\trest: { method: \"POST\" }\n\t}\n});\n/** Complete onboarding (final submit, creates entities) */\nconst CompleteOnboardingBaseInput = new x8({\n\tname: \"CompleteOnboardingBaseInput\",\n\tdescription: \"Input for completing onboarding\",\n\tfields: { data: {\n\t\ttype: E5.JSON(),\n\t\tisOptional: false\n\t} }\n});\nconst CompleteOnboardingBaseOutput = new x8({\n\tname: \"CompleteOnboardingBaseOutput\",\n\tdescription: \"Result of onboarding completion\",\n\tfields: {\n\t\tsuccess: {\n\t\t\ttype: E5.Boolean(),\n\t\t\tisOptional: false\n\t\t},\n\t\tuserId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t},\n\t\torganizationId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t}\n\t}\n});\nconst CompleteOnboardingBaseSpec = defineCommand({\n\tmeta: {\n\t\tname: \"base.onboarding.complete\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\"],\n\t\tdescription: \"Complete onboarding and finalize user/organization setup\",\n\t\tgoal: \"Transition from draft to active profile\",\n\t\tcontext: \"Validates all required fields, creates/updates entities, marks onboarding complete\"\n\t},\n\tio: {\n\t\tinput: CompleteOnboardingBaseInput,\n\t\toutput: CompleteOnboardingBaseOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"completeOnboarding\" },\n\t\trest: { method: \"POST\" }\n\t}\n});\n\n//#endregion\nexport { CompleteOnboardingBaseInput, CompleteOnboardingBaseOutput, CompleteOnboardingBaseSpec, DeleteOnboardingDraftBaseSpec, DeleteOnboardingDraftOutput, GetOnboardingDraftBaseSpec, GetOnboardingDraftOutput, SaveOnboardingDraftBaseSpec, SaveOnboardingDraftInput, SaveOnboardingDraftOutput };"],"mappings":"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"}
1
+ {"version":3,"file":"onboarding-base.js","names":[],"sources":["../../../../../../libs/contracts/dist/onboarding-base.js"],"sourcesContent":["import { E5, x8 } from \"./schema/dist/index.js\";\nimport { OwnersEnum, StabilityEnum } from \"./ownership.js\";\nimport { defineCommand, defineQuery } from \"./operations/operation.js\";\nimport \"./operations/index.js\";\n\n//#region src/onboarding-base.ts\n/**\n* Shared base contracts for onboarding flows across verticals.\n* These operations are reusable for any app that needs multi-step onboarding with draft persistence.\n*/\n/** Save/update onboarding draft (auto-save during flow) */\nconst SaveOnboardingDraftInput = new x8({\n\tname: \"SaveOnboardingDraftInput\",\n\tdescription: \"Input for saving onboarding draft\",\n\tfields: { data: {\n\t\ttype: E5.JSON(),\n\t\tisOptional: false\n\t} }\n});\nconst SaveOnboardingDraftOutput = new x8({\n\tname: \"SaveOnboardingDraftOutput\",\n\tdescription: \"Output for saving onboarding draft\",\n\tfields: {\n\t\tid: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: false\n\t\t},\n\t\torganizationId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: false\n\t\t}\n\t}\n});\nconst SaveOnboardingDraftBaseSpec = defineCommand({\n\tmeta: {\n\t\tname: \"base.onboarding.saveDraft\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\", \"draft\"],\n\t\tdescription: \"Save or update onboarding draft for active organization\",\n\t\tgoal: \"Persist onboarding progress incrementally for resumption and safety\",\n\t\tcontext: \"Auto-saves every few seconds during onboarding; enables users to leave and resume\"\n\t},\n\tio: {\n\t\tinput: SaveOnboardingDraftInput,\n\t\toutput: SaveOnboardingDraftOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"saveOnboardingDraft\" },\n\t\trest: { method: \"POST\" }\n\t}\n});\n/** Get current onboarding draft (on mount/restore) */\nconst GetOnboardingDraftOutput = new x8({\n\tname: \"GetOnboardingDraftOutput\",\n\tdescription: \"Onboarding draft payload\",\n\tfields: {\n\t\tid: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t},\n\t\torganizationId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t},\n\t\tdata: {\n\t\t\ttype: E5.JSON(),\n\t\t\tisOptional: true\n\t\t},\n\t\tcreatedAt: {\n\t\t\ttype: E5.DateTime(),\n\t\t\tisOptional: true\n\t\t},\n\t\tupdatedAt: {\n\t\t\ttype: E5.DateTime(),\n\t\t\tisOptional: true\n\t\t}\n\t}\n});\nconst GetOnboardingDraftBaseSpec = defineQuery({\n\tmeta: {\n\t\tname: \"base.onboarding.getDraft\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\", \"draft\"],\n\t\tdescription: \"Get onboarding draft for active organization\",\n\t\tgoal: \"Retrieve saved onboarding progress\",\n\t\tcontext: \"Called on mount to restore in-progress onboarding\"\n\t},\n\tio: {\n\t\tinput: null,\n\t\toutput: GetOnboardingDraftOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"getOnboardingDraft\" },\n\t\trest: { method: \"GET\" }\n\t}\n});\n/** Delete onboarding draft (cleanup after completion or cancel) */\nconst DeleteOnboardingDraftOutput = new x8({\n\tname: \"DeleteOnboardingDraftOutput\",\n\tdescription: \"Result of delete operation\",\n\tfields: { ok: {\n\t\ttype: E5.Boolean(),\n\t\tisOptional: false\n\t} }\n});\nconst DeleteOnboardingDraftBaseSpec = defineCommand({\n\tmeta: {\n\t\tname: \"base.onboarding.deleteDraft\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\", \"draft\"],\n\t\tdescription: \"Delete onboarding draft for active organization\",\n\t\tgoal: \"Clear draft after completion or if user wants to restart\",\n\t\tcontext: \"Called after successful onboarding or explicit user reset\"\n\t},\n\tio: {\n\t\tinput: null,\n\t\toutput: DeleteOnboardingDraftOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"deleteOnboardingDraft\" },\n\t\trest: { method: \"POST\" }\n\t}\n});\n/** Complete onboarding (final submit, creates entities) */\nconst CompleteOnboardingBaseInput = new x8({\n\tname: \"CompleteOnboardingBaseInput\",\n\tdescription: \"Input for completing onboarding\",\n\tfields: { data: {\n\t\ttype: E5.JSON(),\n\t\tisOptional: false\n\t} }\n});\nconst CompleteOnboardingBaseOutput = new x8({\n\tname: \"CompleteOnboardingBaseOutput\",\n\tdescription: \"Result of onboarding completion\",\n\tfields: {\n\t\tsuccess: {\n\t\t\ttype: E5.Boolean(),\n\t\t\tisOptional: false\n\t\t},\n\t\tuserId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t},\n\t\torganizationId: {\n\t\t\ttype: E5.ID(),\n\t\t\tisOptional: true\n\t\t}\n\t}\n});\nconst CompleteOnboardingBaseSpec = defineCommand({\n\tmeta: {\n\t\tname: \"base.onboarding.complete\",\n\t\tversion: 1,\n\t\tstability: StabilityEnum.Beta,\n\t\towners: [OwnersEnum.PlatformSigil],\n\t\ttags: [\"onboarding\"],\n\t\tdescription: \"Complete onboarding and finalize user/organization setup\",\n\t\tgoal: \"Transition from draft to active profile\",\n\t\tcontext: \"Validates all required fields, creates/updates entities, marks onboarding complete\"\n\t},\n\tio: {\n\t\tinput: CompleteOnboardingBaseInput,\n\t\toutput: CompleteOnboardingBaseOutput\n\t},\n\tpolicy: {\n\t\tauth: \"user\",\n\t\tescalate: null\n\t},\n\ttransport: {\n\t\tgql: { field: \"completeOnboarding\" },\n\t\trest: { method: \"POST\" }\n\t}\n});\n\n//#endregion\nexport { CompleteOnboardingBaseInput, CompleteOnboardingBaseOutput, CompleteOnboardingBaseSpec, DeleteOnboardingDraftBaseSpec, DeleteOnboardingDraftOutput, GetOnboardingDraftBaseSpec, GetOnboardingDraftOutput, SaveOnboardingDraftBaseSpec, SaveOnboardingDraftInput, SaveOnboardingDraftOutput };"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import { defineCommand, defineQuery } from "./operation.js";
2
+ import "./registry.js";
@@ -1,4 +1,4 @@
1
- //#region ../../libs/contracts/dist/operation.js
1
+ //#region ../../libs/contracts/dist/operations/operation.js
2
2
  /**
3
3
  * Helper to define a Command (write operation).
4
4
  * Sets `kind: 'command'` and defaults `idempotent: false`.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.js","names":[],"sources":["../../../../../../../libs/contracts/dist/operations/operation.js"],"sourcesContent":["//#region src/operations/operation.ts\nconst isEmitDeclRef = (e) => \"ref\" in e;\n/**\n* Helper to define a Command (write operation).\n* Sets `kind: 'command'` and defaults `idempotent: false`.\n*/\nconst defineCommand = (spec) => ({\n\t...spec,\n\tmeta: {\n\t\t...spec.meta,\n\t\tkind: \"command\"\n\t},\n\tpolicy: {\n\t\t...spec.policy,\n\t\tidempotent: spec.policy?.[\"policy\"]?.idempotent ?? false\n\t}\n});\n/**\n* Helper to define a Query (read-only operation).\n* Sets `kind: 'query'` and forces `idempotent: true`.\n*/\nconst defineQuery = (spec) => ({\n\t...spec,\n\tmeta: {\n\t\t...spec.meta,\n\t\tkind: \"query\"\n\t},\n\tpolicy: {\n\t\t...spec.policy,\n\t\tidempotent: true\n\t}\n});\n\n//#endregion\nexport { defineCommand, defineQuery, isEmitDeclRef };"],"mappings":";;;;;AAMA,MAAM,iBAAiB,UAAU;CAChC,GAAG;CACH,MAAM;EACL,GAAG,KAAK;EACR,MAAM;EACN;CACD,QAAQ;EACP,GAAG,KAAK;EACR,YAAY,KAAK,SAAS,WAAW,cAAc;EACnD;CACD;;;;;AAKD,MAAM,eAAe,UAAU;CAC9B,GAAG;CACH,MAAM;EACL,GAAG,KAAK;EACR,MAAM;EACN;CACD,QAAQ;EACP,GAAG,KAAK;EACR,YAAY;EACZ;CACD"}
@@ -0,0 +1,2 @@
1
+ import "../events.js";
2
+ import "../registry-utils.js";
@@ -0,0 +1,2 @@
1
+ import "./transform-engine.js";
2
+ import "./presentations.js";
@@ -0,0 +1,2 @@
1
+ import "../registry-utils.js";
2
+ import z from "zod";
@@ -1,7 +1,7 @@
1
1
  import "react";
2
2
  import TurndownService from "turndown";
3
3
 
4
- //#region ../../libs/contracts/dist/presentations.v2.js
4
+ //#region ../../libs/contracts/dist/presentations/transform-engine.js
5
5
  /**
6
6
  * Pluggable transform engine that renders descriptors to various targets
7
7
  * and runs validators (e.g., basic metadata checks, PII redaction policies).
@@ -9,4 +9,4 @@ import TurndownService from "turndown";
9
9
  const turndown = new TurndownService();
10
10
 
11
11
  //#endregion
12
- //# sourceMappingURL=presentations.v2.js.map
12
+ //# sourceMappingURL=transform-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-engine.js","names":[],"sources":["../../../../../../../libs/contracts/dist/presentations/transform-engine.js"],"sourcesContent":["import { schemaToMarkdown } from \"../schema-to-markdown.js\";\nimport React from \"react\";\nimport TurndownService from \"turndown\";\n\n//#region src/presentations/transform-engine.ts\n/**\n* Pluggable transform engine that renders descriptors to various targets\n* and runs validators (e.g., basic metadata checks, PII redaction policies).\n*/\nconst turndown = new TurndownService();\nfunction renderTextNode(node) {\n\tconst text = node.text ?? \"\";\n\tif (!node.marks || node.marks.length === 0) return text;\n\treturn node.marks.reduce((acc, mark) => {\n\t\tswitch (mark.type) {\n\t\t\tcase \"bold\": return `**${acc}**`;\n\t\t\tcase \"italic\": return `*${acc}*`;\n\t\t\tcase \"underline\": return `__${acc}__`;\n\t\t\tcase \"strike\": return `~~${acc}~~`;\n\t\t\tcase \"code\": return `\\`${acc}\\``;\n\t\t\tcase \"link\": {\n\t\t\t\tconst href = mark.attrs?.href ?? \"\";\n\t\t\t\treturn href ? `[${acc}](${href})` : acc;\n\t\t\t}\n\t\t\tdefault: return acc;\n\t\t}\n\t}, text);\n}\nfunction renderInline(nodes) {\n\tif (!nodes?.length) return \"\";\n\treturn nodes.map((child) => renderNode(child)).join(\"\");\n}\nfunction renderList(nodes, ordered = false) {\n\tif (!nodes?.length) return \"\";\n\tlet counter = 1;\n\treturn nodes.map((item) => {\n\t\tconst body = renderInline(item.content ?? []);\n\t\tif (!body) return \"\";\n\t\treturn `${ordered ? `${counter++}. ` : \"- \"}${body}`;\n\t}).filter(Boolean).join(\"\\n\");\n}\nfunction renderNode(node) {\n\tswitch (node.type) {\n\t\tcase \"doc\": return renderInline(node.content);\n\t\tcase \"paragraph\": {\n\t\t\tconst text = renderInline(node.content);\n\t\t\treturn text.trim().length ? text : \"\";\n\t\t}\n\t\tcase \"heading\": {\n\t\t\tconst levelAttr = node.attrs?.level;\n\t\t\tconst levelVal = typeof levelAttr === \"number\" ? levelAttr : 1;\n\t\t\tconst level = Math.min(Math.max(levelVal, 1), 6);\n\t\t\treturn `${\"#\".repeat(level)} ${renderInline(node.content)}`.trim();\n\t\t}\n\t\tcase \"bullet_list\": return renderList(node.content, false);\n\t\tcase \"ordered_list\": return renderList(node.content, true);\n\t\tcase \"list_item\": return renderInline(node.content);\n\t\tcase \"blockquote\": return renderInline(node.content).split(\"\\n\").map((line) => `> ${line}`).join(\"\\n\");\n\t\tcase \"code_block\": {\n\t\t\tconst body = renderInline(node.content);\n\t\t\treturn body ? `\\`\\`\\`\\n${body}\\n\\`\\`\\`` : \"\";\n\t\t}\n\t\tcase \"horizontal_rule\": return \"---\";\n\t\tcase \"hard_break\": return \"\\n\";\n\t\tcase \"text\": return renderTextNode(node);\n\t\tdefault:\n\t\t\tif (node.text) return renderTextNode(node);\n\t\t\treturn \"\";\n\t}\n}\nfunction blockNoteToMarkdown(docJson) {\n\tif (typeof docJson === \"string\") return docJson;\n\tif (docJson && typeof docJson === \"object\" && \"html\" in docJson) {\n\t\tconst html = String(docJson.html);\n\t\treturn turndown.turndown(html);\n\t}\n\tconst root = docJson;\n\tif (root?.type === \"doc\" || root?.content) return (root.content ?? []).map((n) => renderNode(n)).filter(Boolean).join(\"\\n\\n\").trim();\n\ttry {\n\t\treturn JSON.stringify(docJson, null, 2);\n\t} catch {\n\t\treturn String(docJson);\n\t}\n}\nvar TransformEngine = class {\n\trenderers = /* @__PURE__ */ new Map();\n\tvalidators = [];\n\tregister(renderer) {\n\t\tconst arr = this.renderers.get(renderer.target) ?? [];\n\t\tarr.push(renderer);\n\t\tthis.renderers.set(renderer.target, arr);\n\t\treturn this;\n\t}\n\t/**\n\t* Register a renderer that will be tried BEFORE existing renderers for the same target.\n\t* Useful for custom renderers that should take priority over default ones.\n\t*/\n\tprependRegister(renderer) {\n\t\tconst arr = this.renderers.get(renderer.target) ?? [];\n\t\tarr.unshift(renderer);\n\t\tthis.renderers.set(renderer.target, arr);\n\t\treturn this;\n\t}\n\taddValidator(v) {\n\t\tthis.validators.push(v);\n\t\treturn this;\n\t}\n\tasync render(target, desc, ctx) {\n\t\tif (!desc.targets.includes(target)) throw new Error(`Target ${target} not declared for ${desc.meta.name}.v${desc.meta.version}`);\n\t\tfor (const v of this.validators) await v.validate(desc, target, ctx);\n\t\tconst arr = this.renderers.get(target) ?? [];\n\t\tfor (const r of arr) try {\n\t\t\treturn await r.render(desc, ctx);\n\t\t} catch (_e) {}\n\t\tthrow new Error(`No renderer available for ${target}`);\n\t}\n};\n/** Create a TransformEngine instance with default markdown/json/xml renderers. */\nfunction createDefaultTransformEngine() {\n\tconst engine = new TransformEngine();\n\tconst applyPii = (desc, obj) => {\n\t\tconst clone = JSON.parse(JSON.stringify(obj));\n\t\tconst paths = desc.policy?.pii ?? [];\n\t\tconst setAtPath = (root, path) => {\n\t\t\tconst segs = path.replace(/^\\//, \"\").replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\").filter(Boolean);\n\t\t\tlet cur = root;\n\t\t\tfor (let i = 0; i < segs.length - 1; i++) {\n\t\t\t\tconst k = segs[i];\n\t\t\t\tif (!k) continue;\n\t\t\t\tif (cur && typeof cur === \"object\" && k in cur) cur = cur[k];\n\t\t\t\telse return;\n\t\t\t}\n\t\t\tconst last = segs[segs.length - 1];\n\t\t\tif (cur && typeof cur === \"object\" && last && last in cur) cur[last] = \"[REDACTED]\";\n\t\t};\n\t\tfor (const p of paths) setAtPath(clone, p);\n\t\treturn clone;\n\t};\n\tengine.register({\n\t\ttarget: \"markdown\",\n\t\tasync render(desc, ctx) {\n\t\t\tlet data = ctx?.data;\n\t\t\tif (!data && ctx?.fetchData) data = await ctx.fetchData();\n\t\t\tif (desc.source.type === \"component\" && desc.source.props && data !== void 0) {\n\t\t\t\tconst isArray = Array.isArray(data);\n\t\t\t\tconst isSimpleObject = !isArray && typeof data === \"object\" && data !== null && !Object.values(data).some((v) => Array.isArray(v) || typeof v === \"object\" && v !== null);\n\t\t\t\tif (isArray || isSimpleObject) return {\n\t\t\t\t\tmimeType: \"text/markdown\",\n\t\t\t\t\tbody: schemaToMarkdown(desc.source.props, data, {\n\t\t\t\t\t\ttitle: desc.meta.description ?? desc.meta.name,\n\t\t\t\t\t\tdescription: `${desc.meta.name} v${desc.meta.version}`\n\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t\tthrow new Error(`Complex data structure for ${desc.meta.name} - expecting custom renderer`);\n\t\t\t}\n\t\t\tif (desc.source.type === \"blocknotejs\") {\n\t\t\t\tconst redacted = applyPii(desc, { text: blockNoteToMarkdown(desc.source.docJson) });\n\t\t\t\treturn {\n\t\t\t\t\tmimeType: \"text/markdown\",\n\t\t\t\t\tbody: String(redacted.text)\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (desc.source.type === \"component\" && data !== void 0) throw new Error(`No schema (source.props) available for ${desc.meta.name} - expecting custom renderer`);\n\t\t\tif (desc.source.type === \"component\") return {\n\t\t\t\tmimeType: \"text/markdown\",\n\t\t\t\tbody: `${`# ${desc.meta.name} v${desc.meta.version}`}${desc.meta.description ? `\\n\\n${desc.meta.description}` : \"\"}${desc.meta.tags && desc.meta.tags.length ? `\\n\\nTags: ${desc.meta.tags.join(\", \")}` : \"\"}${desc.meta.owners && desc.meta.owners.length ? `\\n\\nOwners: ${desc.meta.owners.join(\", \")}` : \"\"}${`\\n\\nComponent: \\`${desc.source.componentKey}\\``}${desc.policy?.pii?.length ? `\\n\\nRedacted paths: ${desc.policy.pii.map((p) => `\\`${p}\\``).join(\", \")}` : \"\"}`\n\t\t\t};\n\t\t\tthrow new Error(\"unsupported\");\n\t\t}\n\t});\n\tengine.register({\n\t\ttarget: \"application/json\",\n\t\tasync render(desc) {\n\t\t\tconst payload = applyPii(desc, {\n\t\t\t\tmeta: desc.meta,\n\t\t\t\tsource: desc.source\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tmimeType: \"application/json\",\n\t\t\t\tbody: JSON.stringify(payload, null, 2)\n\t\t\t};\n\t\t}\n\t});\n\tengine.register({\n\t\ttarget: \"application/xml\",\n\t\tasync render(desc) {\n\t\t\tconst json = applyPii(desc, {\n\t\t\t\tmeta: desc.meta,\n\t\t\t\tsource: desc.source\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tmimeType: \"application/xml\",\n\t\t\t\tbody: `<presentation name=\"${desc.meta.name}\" version=\"${desc.meta.version}\"><json>${encodeURIComponent(JSON.stringify(json))}</json></presentation>`\n\t\t\t};\n\t\t}\n\t});\n\treturn engine;\n}\n/** Register a default React target renderer that returns a serializable descriptor. */\nfunction registerDefaultReactRenderer(engine) {\n\tengine.register({\n\t\ttarget: \"react\",\n\t\tasync render(desc) {\n\t\t\tif (desc.source.type === \"component\") {\n\t\t\t\tconst props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : void 0 : void 0;\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"react_component\",\n\t\t\t\t\tcomponentKey: desc.source.componentKey,\n\t\t\t\t\tprops\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"blocknotejs\",\n\t\t\t\tdocJson: desc.source.docJson,\n\t\t\t\tblockConfig: desc.source.blockConfig\n\t\t\t};\n\t\t}\n\t});\n\treturn engine;\n}\n/**\n* Add basic validators (e.g., meta.description presence) to the engine.\n*/\nfunction registerBasicValidation(engine) {\n\tengine.addValidator({ validate(desc) {\n\t\tif (!desc.meta.description || desc.meta.description.length < 3) throw new Error(`Presentation ${desc.meta.name}.v${desc.meta.version} missing meta.description`);\n\t} });\n\treturn engine;\n}\n/**\n* Register a React-to-markdown renderer that renders React components to HTML\n* and converts them to markdown using turndown.\n* This renderer takes priority over the default metadata-only renderer.\n*/\nfunction registerReactToMarkdownRenderer(engine, componentMap) {\n\tconst turndownService = new TurndownService({\n\t\theadingStyle: \"atx\",\n\t\tcodeBlockStyle: \"fenced\",\n\t\tbulletListMarker: \"-\"\n\t});\n\tturndownService.addRule(\"link\", {\n\t\tfilter: \"a\",\n\t\treplacement: (content, node) => {\n\t\t\tconst href = node.href;\n\t\t\tif (href && content) return `[${content}](${href})`;\n\t\t\treturn content || \"\";\n\t\t}\n\t});\n\tengine.prependRegister({\n\t\ttarget: \"markdown\",\n\t\tasync render(desc, _ctx) {\n\t\t\tif (desc.source.type !== \"component\") throw new Error(\"React-to-markdown renderer only handles component presentations\");\n\t\t\tconst { renderToStaticMarkup } = await import(\"react-dom/server\");\n\t\t\tconst Component = componentMap[desc.source.componentKey];\n\t\t\tif (!Component) throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);\n\t\t\tlet html;\n\t\t\ttry {\n\t\t\t\thtml = renderToStaticMarkup(React.createElement(Component, desc.source.props ? {} : void 0));\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`Failed to render component ${desc.source.componentKey}: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\t}\n\t\t\tlet markdown;\n\t\t\ttry {\n\t\t\t\tmarkdown = turndownService.turndown(html);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`Failed to convert HTML to markdown: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\t}\n\t\t\tif (desc.policy?.pii && desc.policy.pii.length > 0) return {\n\t\t\t\tmimeType: \"text/markdown\",\n\t\t\t\tbody: markdown.replace(/\\[REDACTED\\]/g, \"[REDACTED]\")\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tmimeType: \"text/markdown\",\n\t\t\t\tbody: markdown\n\t\t\t};\n\t\t}\n\t});\n\treturn engine;\n}\n\n//#endregion\nexport { TransformEngine, createDefaultTransformEngine, registerBasicValidation, registerDefaultReactRenderer, registerReactToMarkdownRenderer };"],"mappings":";;;;;;;;AASA,MAAM,WAAW,IAAI,iBAAiB"}
@@ -1,2 +1,3 @@
1
- import "../../presentations.v2.js";
2
- import "../../presentations.js";
1
+ import "../../presentations/transform-engine.js";
2
+ import "../../presentations/presentations.js";
3
+ import "../../presentations/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/example.learning-journey-studio-onboarding",
3
- "version": "0.0.0-canary-20251221132705",
3
+ "version": "0.0.0-canary-20251221153314",
4
4
  "description": "Learning journey track for first 30 minutes in ContractSpec Studio.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,13 +30,13 @@
30
30
  "lint:check": "eslint src"
31
31
  },
32
32
  "dependencies": {
33
- "@lssm/lib.contracts": "0.0.0-canary-20251221132705",
34
- "@lssm/lib.schema": "0.0.0-canary-20251221132705",
35
- "@lssm/module.learning-journey": "0.0.0-canary-20251221132705"
33
+ "@lssm/lib.contracts": "0.0.0-canary-20251221153314",
34
+ "@lssm/lib.schema": "0.0.0-canary-20251221153314",
35
+ "@lssm/module.learning-journey": "0.0.0-canary-20251221153314"
36
36
  },
37
37
  "devDependencies": {
38
- "@lssm/tool.tsdown": "0.0.0-canary-20251221132705",
39
- "@lssm/tool.typescript": "0.0.0-canary-20251221132705",
38
+ "@lssm/tool.tsdown": "0.0.0-canary-20251221153314",
39
+ "@lssm/tool.typescript": "0.0.0-canary-20251221153314",
40
40
  "tsdown": "^0.18.1",
41
41
  "typescript": "^5.9.3"
42
42
  },