@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217060834 → 0.0.0-canary-20251217072406
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/_virtual/rolldown_runtime.js +22 -1
- package/dist/adapters/ai.js +82 -1
- package/dist/adapters/factory.js +36 -1
- package/dist/adapters/fs.js +118 -1
- package/dist/adapters/git.js +54 -1
- package/dist/adapters/index.js +7 -1
- package/dist/adapters/logger.js +80 -1
- package/dist/adapters/watcher.js +69 -1
- package/dist/adapters/workspace.js +190 -2
- package/dist/ai/agents/claude-code-agent.js +146 -9
- package/dist/ai/agents/cursor-agent.js +286 -17
- package/dist/ai/agents/index.js +5 -1
- package/dist/ai/agents/openai-codex-agent.js +140 -8
- package/dist/ai/agents/orchestrator.js +142 -1
- package/dist/ai/agents/simple-agent.js +80 -4
- package/dist/ai/client.js +162 -1
- package/dist/ai/index.js +27 -1
- package/dist/ai/prompts/code-generation.js +55 -13
- package/dist/ai/prompts/index.js +12 -1
- package/dist/ai/prompts/spec-creation.js +61 -20
- package/dist/ai/providers.js +40 -1
- package/dist/formatters/index.js +18 -1
- package/dist/formatters/json.js +71 -1
- package/dist/formatters/sarif.js +163 -1
- package/dist/formatters/text.js +208 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.js +81 -1
- package/dist/libs/ai-providers/dist/factory.js +154 -0
- package/dist/libs/ai-providers/dist/index.js +4 -0
- package/dist/libs/ai-providers/dist/legacy.js +72 -0
- package/dist/libs/ai-providers/dist/models.js +287 -0
- package/dist/libs/ai-providers/dist/validation.js +1 -0
- package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -0
- package/dist/libs/contracts/dist/client/index.js +5 -0
- package/dist/libs/contracts/dist/client/react/feature-render.js +2 -0
- package/dist/libs/contracts/dist/client/react/form-render.js +4 -0
- package/dist/libs/contracts/dist/client/react/index.js +4 -0
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -0
- package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -0
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/index.js +29 -0
- package/dist/libs/contracts/dist/docs/presentations.js +71 -0
- package/dist/libs/contracts/dist/docs/registry.js +44 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +80 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +57 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +357 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +79 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +84 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +45 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +40 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +69 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +62 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +155 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +101 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -0
- package/dist/libs/contracts/dist/events.js +8 -0
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
- package/dist/libs/contracts/dist/index.js +72 -0
- package/dist/libs/contracts/dist/install.js +2 -0
- package/dist/libs/contracts/dist/integrations/contracts.js +377 -0
- package/dist/libs/contracts/dist/integrations/index.js +18 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -0
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -0
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -0
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -0
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -0
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -0
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -0
- package/dist/libs/contracts/dist/integrations/providers/index.js +11 -0
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -0
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -0
- package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -0
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -0
- package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -0
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -0
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -0
- package/dist/libs/contracts/dist/jsonschema.js +24 -0
- package/dist/libs/contracts/dist/knowledge/contracts.js +306 -0
- package/dist/libs/contracts/dist/knowledge/index.js +7 -0
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -0
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -0
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -0
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -0
- package/dist/libs/contracts/dist/llm/exporters.js +352 -0
- package/dist/libs/contracts/dist/llm/index.js +2 -0
- package/dist/libs/contracts/dist/llm/prompts.js +211 -0
- package/dist/libs/contracts/dist/onboarding-base.js +196 -0
- package/dist/libs/contracts/dist/openapi.js +75 -0
- package/dist/libs/contracts/dist/ownership.js +21 -0
- package/dist/libs/contracts/dist/presentations.js +1 -0
- package/dist/libs/contracts/dist/presentations.v2.js +11 -0
- package/dist/libs/contracts/dist/prompt.js +1 -0
- package/dist/libs/contracts/dist/promptRegistry.js +1 -0
- package/dist/libs/contracts/dist/regenerator/index.js +2 -0
- package/dist/libs/contracts/dist/regenerator/service.js +92 -0
- package/dist/libs/contracts/dist/regenerator/utils.js +51 -0
- package/dist/libs/contracts/dist/registry.js +208 -0
- package/dist/libs/contracts/dist/resources.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -0
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -0
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -0
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +34 -0
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -0
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/index.js +6 -0
- package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -0
- package/dist/libs/contracts/dist/server/index.js +8 -0
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -0
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -0
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -0
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -0
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
- package/dist/libs/contracts/dist/server/rest-express.js +1 -0
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
- package/dist/libs/contracts/dist/spec.js +35 -0
- package/dist/libs/contracts/dist/telemetry/index.js +1 -0
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
- package/dist/libs/contracts/dist/tests/index.js +1 -0
- package/dist/libs/contracts/dist/tests/runner.js +150 -0
- package/dist/libs/contracts/dist/workflow/index.js +1 -0
- package/dist/libs/contracts/dist/workflow/runner.js +1 -0
- package/dist/libs/contracts-transformers/dist/common/utils.js +47 -0
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -0
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +255 -0
- package/dist/libs/contracts-transformers/dist/openapi/index.js +4 -0
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +231 -0
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +201 -0
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +137 -0
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +101 -0
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +84 -0
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +30 -0
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +96 -0
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +151 -0
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +344 -0
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +122 -0
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +105 -0
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +68 -0
- package/dist/modules/contractspec-workspace/dist/templates/event.js +38 -0
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +87 -0
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +95 -0
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +104 -0
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +62 -0
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +68 -0
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +60 -0
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +100 -0
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +78 -0
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +89 -0
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +38 -0
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +48 -0
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +67 -0
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +20 -0
- package/dist/services/agent-guide/adapters/claude-code.js +144 -3
- package/dist/services/agent-guide/adapters/cursor-cli.js +135 -3
- package/dist/services/agent-guide/adapters/generic-mcp.js +159 -3
- package/dist/services/agent-guide/adapters/index.js +30 -1
- package/dist/services/agent-guide/agent-guide-service.js +148 -1
- package/dist/services/agent-guide/index.js +5 -1
- package/dist/services/build.js +140 -1
- package/dist/services/ci-check/ci-check-service.js +393 -1
- package/dist/services/ci-check/index.js +2 -1
- package/dist/services/ci-check/types.js +28 -1
- package/dist/services/clean.js +71 -1
- package/dist/services/config.js +76 -1
- package/dist/services/deps.js +62 -1
- package/dist/services/diff.js +33 -1
- package/dist/services/doctor/checks/ai.js +118 -2
- package/dist/services/doctor/checks/cli.js +146 -1
- package/dist/services/doctor/checks/config.js +170 -1
- package/dist/services/doctor/checks/deps.js +180 -1
- package/dist/services/doctor/checks/index.js +6 -1
- package/dist/services/doctor/checks/mcp.js +144 -1
- package/dist/services/doctor/checks/workspace.js +243 -1
- package/dist/services/doctor/doctor-service.js +115 -2
- package/dist/services/doctor/index.js +2 -1
- package/dist/services/doctor/types.js +26 -1
- package/dist/services/implementation/discovery.js +143 -2
- package/dist/services/implementation/index.js +2 -1
- package/dist/services/implementation/resolver.js +223 -1
- package/dist/services/index.js +53 -1
- package/dist/services/integrity-diagram.js +274 -6
- package/dist/services/integrity.js +272 -1
- package/dist/services/list.js +35 -1
- package/dist/services/openapi/export-service.js +51 -2
- package/dist/services/openapi/import-service.js +75 -1
- package/dist/services/openapi/index.js +4 -1
- package/dist/services/openapi/sync-service.js +121 -1
- package/dist/services/openapi/validate-service.js +130 -1
- package/dist/services/regenerator.js +23 -1
- package/dist/services/registry.js +73 -1
- package/dist/services/setup/config-generators.js +113 -26
- package/dist/services/setup/file-merger.js +60 -2
- package/dist/services/setup/index.js +4 -1
- package/dist/services/setup/setup-service.js +95 -1
- package/dist/services/setup/targets/agents-md.js +46 -1
- package/dist/services/setup/targets/cli-config.js +59 -1
- package/dist/services/setup/targets/cursor-rules.js +47 -1
- package/dist/services/setup/targets/mcp-claude.js +59 -1
- package/dist/services/setup/targets/mcp-cursor.js +58 -1
- package/dist/services/setup/targets/vscode-settings.js +62 -1
- package/dist/services/setup/types.js +26 -1
- package/dist/services/sync.js +62 -1
- package/dist/services/test.js +30 -1
- package/dist/services/validate-implementation.js +69 -1
- package/dist/services/validate.js +47 -1
- package/dist/services/verification-cache/adapters/filesystem.js +121 -1
- package/dist/services/verification-cache/adapters/in-memory.js +45 -1
- package/dist/services/verification-cache/adapters/index.js +3 -1
- package/dist/services/verification-cache/adapters/workspace-state.js +90 -1
- package/dist/services/verification-cache/cache-service.js +255 -1
- package/dist/services/verification-cache/index.js +6 -1
- package/dist/services/verification-cache/types.js +15 -1
- package/dist/services/verify/ai-verifier.js +336 -9
- package/dist/services/verify/behavior-verifier.js +185 -1
- package/dist/services/verify/index.js +4 -1
- package/dist/services/verify/structure-verifier.js +195 -2
- package/dist/services/verify/verify-service.js +203 -3
- package/dist/services/watch.js +31 -1
- package/dist/services/workspace-info.js +102 -2
- package/dist/templates/app-config.template.js +101 -28
- package/dist/templates/data-view.template.js +42 -27
- package/dist/templates/event.template.js +29 -14
- package/dist/templates/experiment.template.js +77 -51
- package/dist/templates/handler.template.js +53 -17
- package/dist/templates/index.js +36 -1
- package/dist/templates/integration.template.js +134 -50
- package/dist/templates/knowledge.template.js +62 -21
- package/dist/templates/migration.template.js +50 -26
- package/dist/templates/operation.template.js +44 -28
- package/dist/templates/presentation.template.js +46 -20
- package/dist/templates/telemetry.template.js +74 -53
- package/dist/templates/workflow-runner.template.js +12 -6
- package/dist/templates/workflow.template.js +51 -24
- package/package.json +13 -9
- package/dist/adapters/index.d.ts +0 -7
- package/dist/ports/index.d.ts +0 -5
- package/dist/services/agent-guide/index.d.ts +0 -6
- package/dist/services/ci-check/index.d.ts +0 -2
- package/dist/services/doctor/index.d.ts +0 -2
- package/dist/services/implementation/index.d.ts +0 -3
- package/dist/services/index.d.ts +0 -56
- package/dist/services/openapi/index.d.ts +0 -5
- package/dist/services/verification-cache/adapters/index.d.ts +0 -3
- package/dist/services/verification-cache/index.d.ts +0 -6
- package/dist/services/verify/index.d.ts +0 -5
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/experiment.js
|
|
4
|
+
function generateExperimentSpec(data) {
|
|
5
|
+
const specVar = toPascalCase(data.name.split(".").pop() ?? "Experiment") + "Experiment";
|
|
6
|
+
const variants = data.variants.map((variant) => {
|
|
7
|
+
const overrides = variant.overrides?.length ? ` overrides: [
|
|
8
|
+
${variant.overrides.map((override) => ` {
|
|
9
|
+
type: '${override.type}',
|
|
10
|
+
target: '${escapeString(override.target)}',
|
|
11
|
+
${typeof override.version === "number" ? `version: ${override.version},` : ""}
|
|
12
|
+
}`).join(",\n")}
|
|
13
|
+
],` : "";
|
|
14
|
+
return ` {
|
|
15
|
+
id: '${escapeString(variant.id)}',
|
|
16
|
+
name: '${escapeString(variant.name)}',
|
|
17
|
+
${variant.description ? `description: '${escapeString(variant.description)}',` : ""}
|
|
18
|
+
${typeof variant.weight === "number" ? `weight: ${variant.weight},` : ""}
|
|
19
|
+
${overrides}
|
|
20
|
+
}`;
|
|
21
|
+
}).join(",\n");
|
|
22
|
+
const allocation = renderAllocation(data.allocation);
|
|
23
|
+
const metrics = data.successMetrics?.length ? ` successMetrics: [
|
|
24
|
+
${data.successMetrics.map((metric) => ` {
|
|
25
|
+
name: '${escapeString(metric.name)}',
|
|
26
|
+
telemetryEvent: { name: '${escapeString(metric.eventName)}', version: ${metric.eventVersion} },
|
|
27
|
+
aggregation: '${metric.aggregation}',
|
|
28
|
+
${typeof metric.target === "number" ? `target: ${metric.target},` : ""}
|
|
29
|
+
}`).join(",\n")}
|
|
30
|
+
],` : "";
|
|
31
|
+
return `import type { ExperimentSpec } from '@lssm/lib.contracts/experiments';
|
|
32
|
+
|
|
33
|
+
export const ${specVar}: ExperimentSpec = {
|
|
34
|
+
meta: {
|
|
35
|
+
name: '${escapeString(data.name)}',
|
|
36
|
+
version: ${data.version},
|
|
37
|
+
title: '${escapeString(data.name)} experiment',
|
|
38
|
+
description: '${escapeString(data.description || "Describe the experiment goal.")}',
|
|
39
|
+
domain: '${escapeString(data.domain)}',
|
|
40
|
+
owners: [${data.owners.map((owner) => `'${escapeString(owner)}'`).join(", ")}],
|
|
41
|
+
tags: [${data.tags.map((tag) => `'${escapeString(tag)}'`).join(", ")}],
|
|
42
|
+
stability: '${data.stability}',
|
|
43
|
+
},
|
|
44
|
+
controlVariant: '${escapeString(data.controlVariant)}',
|
|
45
|
+
variants: [
|
|
46
|
+
${variants}
|
|
47
|
+
],
|
|
48
|
+
allocation: ${allocation},
|
|
49
|
+
${metrics}
|
|
50
|
+
};
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
function renderAllocation(allocation) {
|
|
54
|
+
switch (allocation.type) {
|
|
55
|
+
case "random": return `{
|
|
56
|
+
type: 'random',
|
|
57
|
+
${allocation.salt ? `salt: '${escapeString(allocation.salt)}',` : ""}
|
|
58
|
+
}`;
|
|
59
|
+
case "sticky": return `{
|
|
60
|
+
type: 'sticky',
|
|
61
|
+
attribute: '${allocation.attribute}',
|
|
62
|
+
${allocation.salt ? `salt: '${escapeString(allocation.salt)}',` : ""}
|
|
63
|
+
}`;
|
|
64
|
+
case "targeted": return `{
|
|
65
|
+
type: 'targeted',
|
|
66
|
+
rules: [
|
|
67
|
+
${allocation.rules.map((rule) => ` {
|
|
68
|
+
variantId: '${escapeString(rule.variantId)}',
|
|
69
|
+
${typeof rule.percentage === "number" ? `percentage: ${rule.percentage},` : ""}
|
|
70
|
+
${rule.policy ? `policy: { name: '${escapeString(rule.policy.name)}'${typeof rule.policy.version === "number" ? `, version: ${rule.policy.version}` : ""} },` : ""}
|
|
71
|
+
${rule.expression ? `expression: '${escapeString(rule.expression)}',` : ""}
|
|
72
|
+
}`).join(",\n")}
|
|
73
|
+
],
|
|
74
|
+
fallback: '${allocation.fallback ?? "control"}',
|
|
75
|
+
}`;
|
|
76
|
+
default: return renderUnsupportedAllocation(allocation);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function escapeString(value) {
|
|
80
|
+
return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
81
|
+
}
|
|
82
|
+
function renderUnsupportedAllocation(allocation) {
|
|
83
|
+
throw new Error(`Unsupported allocation type ${allocation}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { generateExperimentSpec };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { toCamelCase, toKebabCase, toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/handler.js
|
|
4
|
+
/**
|
|
5
|
+
* Handler and component template generation.
|
|
6
|
+
* Extracted from cli-contracts/src/templates/handler.template.ts
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generate handler implementation template.
|
|
10
|
+
*/
|
|
11
|
+
function generateHandlerTemplate(specName, kind) {
|
|
12
|
+
const handlerName = toCamelCase(specName.split(".").pop() ?? "unknown") + "Handler";
|
|
13
|
+
const specVarName = toPascalCase(specName.split(".").pop() ?? "Unknown") + "Spec";
|
|
14
|
+
return `import type { ContractHandler } from '@lssm/lib.contracts';
|
|
15
|
+
import { ${specVarName} } from '../contracts/${toKebabCase(specName)}.contracts';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Handler for ${specName}
|
|
19
|
+
*/
|
|
20
|
+
export const ${handlerName}: ContractHandler<typeof ${specVarName}> = async (
|
|
21
|
+
input,
|
|
22
|
+
context
|
|
23
|
+
) => {
|
|
24
|
+
// TODO: Implement ${kind} logic
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// 1. Validate prerequisites
|
|
28
|
+
// 2. Perform business logic
|
|
29
|
+
// 3. Emit events if needed
|
|
30
|
+
// 4. Return result
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
ok: true,
|
|
34
|
+
};
|
|
35
|
+
} catch (error) {
|
|
36
|
+
// Handle and map errors to spec.io.errors
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate React component template.
|
|
44
|
+
*/
|
|
45
|
+
function generateComponentTemplate(componentName, description) {
|
|
46
|
+
const pascalName = toPascalCase(componentName);
|
|
47
|
+
return `import React from 'react';
|
|
48
|
+
|
|
49
|
+
interface ${pascalName}Props {
|
|
50
|
+
// TODO: Define props based on presentation spec
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* ${description}
|
|
55
|
+
*/
|
|
56
|
+
export const ${pascalName}: React.FC<${pascalName}Props> = (props) => {
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
{/* TODO: Implement component UI */}
|
|
60
|
+
<p>Component: ${pascalName}</p>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate test template.
|
|
68
|
+
*/
|
|
69
|
+
function generateTestTemplate(targetName, type) {
|
|
70
|
+
const importPath = type === "handler" ? "../handlers" : "../components";
|
|
71
|
+
const testName = toPascalCase(targetName);
|
|
72
|
+
return `import { describe, it, expect } from 'bun:test';
|
|
73
|
+
import { ${testName} } from '${importPath}/${toKebabCase(targetName)}';
|
|
74
|
+
|
|
75
|
+
describe('${testName}', () => {
|
|
76
|
+
it('should ${type === "handler" ? "handle valid input" : "render correctly"}', async () => {
|
|
77
|
+
// TODO: Implement test
|
|
78
|
+
expect(true).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should handle edge cases', async () => {
|
|
82
|
+
// TODO: Test edge cases
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
${type === "handler" ? `it('should handle errors appropriately', async () => {
|
|
86
|
+
// TODO: Test error scenarios
|
|
87
|
+
});` : `it('should be accessible', async () => {
|
|
88
|
+
// TODO: Test accessibility
|
|
89
|
+
});`}
|
|
90
|
+
});
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { generateComponentTemplate, generateHandlerTemplate, generateTestTemplate };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region ../../modules/contractspec-workspace/dist/templates/integration-utils.js
|
|
2
|
+
function renderConfigSchema(fields) {
|
|
3
|
+
const requiredFields = fields.filter((field) => field.required);
|
|
4
|
+
return ` schema: {
|
|
5
|
+
type: 'object',
|
|
6
|
+
${requiredFields.length > 0 ? ` required: [${requiredFields.map((field) => `'${field.key}'`).join(", ")}],
|
|
7
|
+
` : ""} properties: {
|
|
8
|
+
${(fields.length ? fields.map((field) => {
|
|
9
|
+
const description = field.description ? `, description: '${escape(field.description)}'` : "";
|
|
10
|
+
return ` ${field.key}: { type: '${mapConfigType(field.type)}'${description} }`;
|
|
11
|
+
}).join(",\n") : "") || " "}
|
|
12
|
+
},
|
|
13
|
+
},\n`;
|
|
14
|
+
}
|
|
15
|
+
function renderSecretSchema(fields) {
|
|
16
|
+
const requiredFields = fields.filter((field) => field.required);
|
|
17
|
+
return ` schema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
${requiredFields.length > 0 ? ` required: [${requiredFields.map((field) => `'${field.key}'`).join(", ")}],
|
|
20
|
+
` : ""} properties: {
|
|
21
|
+
${(fields.length ? fields.map((field) => {
|
|
22
|
+
const description = field.description ? `, description: '${escape(field.description)}'` : "";
|
|
23
|
+
return ` ${field.key}: { type: 'string'${description} }`;
|
|
24
|
+
}).join(",\n") : "") || " "}
|
|
25
|
+
},
|
|
26
|
+
},\n`;
|
|
27
|
+
}
|
|
28
|
+
function renderConfigExample(fields) {
|
|
29
|
+
if (fields.length === 0) return `{}`;
|
|
30
|
+
return `{
|
|
31
|
+
${fields.map((field) => {
|
|
32
|
+
switch (field.type) {
|
|
33
|
+
case "number": return ` ${field.key}: 0`;
|
|
34
|
+
case "boolean": return ` ${field.key}: true`;
|
|
35
|
+
case "string":
|
|
36
|
+
default: return ` ${field.key}: '${field.key.toUpperCase()}_VALUE'`;
|
|
37
|
+
}
|
|
38
|
+
}).join(",\n")}
|
|
39
|
+
}`;
|
|
40
|
+
}
|
|
41
|
+
function renderSecretExample(fields) {
|
|
42
|
+
if (fields.length === 0) return `{}`;
|
|
43
|
+
return `{
|
|
44
|
+
${fields.map((field) => ` ${field.key}: '${field.key.toUpperCase()}_SECRET'`).join(",\n")}
|
|
45
|
+
}`;
|
|
46
|
+
}
|
|
47
|
+
function renderConstraints(rpm, rph) {
|
|
48
|
+
if (rpm == null && rph == null) return "";
|
|
49
|
+
const entries = [];
|
|
50
|
+
if (rpm != null) entries.push(` rpm: ${rpm}`);
|
|
51
|
+
if (rph != null) entries.push(` rph: ${rph}`);
|
|
52
|
+
return ` constraints: {
|
|
53
|
+
rateLimit: {
|
|
54
|
+
${entries.join(",\n")}
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
function renderByokSetup(modes, instructions, scopes) {
|
|
60
|
+
if (!modes.includes("byok")) return "";
|
|
61
|
+
const instructionsLine = instructions ? ` setupInstructions: '${escape(instructions)}',\n` : "";
|
|
62
|
+
const scopesLine = scopes && scopes.length ? ` requiredScopes: [${scopes.map((scope) => `'${escape(scope)}'`).join(", ")}],\n` : "";
|
|
63
|
+
if (!instructionsLine && !scopesLine) return "";
|
|
64
|
+
return ` byokSetup: {
|
|
65
|
+
${instructionsLine}${scopesLine} },
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
function mapConfigType(type) {
|
|
69
|
+
switch (type) {
|
|
70
|
+
case "number": return "number";
|
|
71
|
+
case "boolean": return "boolean";
|
|
72
|
+
case "string":
|
|
73
|
+
default: return "string";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function stabilityToEnum(stability) {
|
|
77
|
+
switch (stability) {
|
|
78
|
+
case "beta": return "Beta";
|
|
79
|
+
case "stable": return "Stable";
|
|
80
|
+
case "deprecated": return "Deprecated";
|
|
81
|
+
case "experimental":
|
|
82
|
+
default: return "Experimental";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function renderProvides(data) {
|
|
86
|
+
return data.capabilitiesProvided.map((cap) => ` { key: '${cap.key}', version: ${cap.version} }`).join(",\n");
|
|
87
|
+
}
|
|
88
|
+
function renderRequires(data) {
|
|
89
|
+
if (data.capabilitiesRequired.length === 0) return "";
|
|
90
|
+
return ` requires: [
|
|
91
|
+
${data.capabilitiesRequired.map((req) => {
|
|
92
|
+
const version = typeof req.version === "number" ? `, version: ${req.version}` : "";
|
|
93
|
+
const optional = req.optional ? ", optional: true" : "";
|
|
94
|
+
const reason = req.reason ? `, reason: '${escape(req.reason)}'` : "";
|
|
95
|
+
return ` { key: '${req.key}'${version}${optional}${reason} }`;
|
|
96
|
+
}).join(",\n")}
|
|
97
|
+
],`;
|
|
98
|
+
}
|
|
99
|
+
function escape(value) {
|
|
100
|
+
return value.replace(/`/g, "\\`").replace(/'/g, "\\'");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { escape, renderByokSetup, renderConfigExample, renderConfigSchema, renderConstraints, renderProvides, renderRequires, renderSecretExample, renderSecretSchema, stabilityToEnum };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { toPascalCase } from "./utils.js";
|
|
2
|
+
import { escape, renderByokSetup, renderConfigExample, renderConfigSchema, renderConstraints, renderProvides, renderRequires, renderSecretExample, renderSecretSchema, stabilityToEnum } from "./integration-utils.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../modules/contractspec-workspace/dist/templates/integration.js
|
|
5
|
+
function generateIntegrationSpec(data) {
|
|
6
|
+
const specName = toPascalCase(data.name.split(".").pop() ?? "Integration");
|
|
7
|
+
const varName = `${specName}IntegrationSpec`;
|
|
8
|
+
const registerFn = `register${specName}Integration`;
|
|
9
|
+
const supportedModes = data.supportedModes.length ? data.supportedModes : ["managed"];
|
|
10
|
+
const supportedModesLine = supportedModes.map((mode) => `'${mode}'`).join(", ");
|
|
11
|
+
const provides = renderProvides(data);
|
|
12
|
+
const requires = renderRequires(data);
|
|
13
|
+
const configSchema = renderConfigSchema(data.configFields);
|
|
14
|
+
const configExample = renderConfigExample(data.configFields);
|
|
15
|
+
const secretSchema = renderSecretSchema(data.secretFields);
|
|
16
|
+
const secretExample = renderSecretExample(data.secretFields);
|
|
17
|
+
const docsUrl = data.docsUrl ? ` docsUrl: '${escape(data.docsUrl)}',\n` : "";
|
|
18
|
+
const constraints = renderConstraints(data.rateLimitRpm, data.rateLimitRph);
|
|
19
|
+
const byokSetup = renderByokSetup(supportedModes, data.byokSetupInstructions, data.byokRequiredScopes);
|
|
20
|
+
return `import { StabilityEnum } from '@lssm/lib.contracts/ownership';
|
|
21
|
+
import type { IntegrationSpec } from '@lssm/lib.contracts/integrations/spec';
|
|
22
|
+
import type { IntegrationSpecRegistry } from '@lssm/lib.contracts/integrations/spec';
|
|
23
|
+
|
|
24
|
+
export const ${varName}: IntegrationSpec = {
|
|
25
|
+
meta: {
|
|
26
|
+
key: '${escape(data.name)}',
|
|
27
|
+
version: ${data.version},
|
|
28
|
+
category: '${data.category}',
|
|
29
|
+
displayName: '${escape(data.displayName)}',
|
|
30
|
+
title: '${escape(data.title)}',
|
|
31
|
+
description: '${escape(data.description)}',
|
|
32
|
+
domain: '${escape(data.domain)}',
|
|
33
|
+
owners: [${data.owners.map((owner) => `'${escape(owner)}'`).join(", ")}],
|
|
34
|
+
tags: [${data.tags.map((tag) => `'${escape(tag)}'`).join(", ")}],
|
|
35
|
+
stability: StabilityEnum.${stabilityToEnum(data.stability)},
|
|
36
|
+
},
|
|
37
|
+
supportedModes: [${supportedModesLine}],
|
|
38
|
+
capabilities: {
|
|
39
|
+
provides: [
|
|
40
|
+
${provides}
|
|
41
|
+
],
|
|
42
|
+
${requires.length > 0 ? `${requires}\n` : ""} },
|
|
43
|
+
configSchema: {
|
|
44
|
+
${configSchema} example: ${configExample},
|
|
45
|
+
},
|
|
46
|
+
secretSchema: {
|
|
47
|
+
${secretSchema} example: ${secretExample},
|
|
48
|
+
},
|
|
49
|
+
${docsUrl}${constraints}${byokSetup} healthCheck: {
|
|
50
|
+
method: '${data.healthCheckMethod}',
|
|
51
|
+
timeoutMs: ${data.healthCheckTimeoutMs ?? 5e3},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export function ${registerFn}(registry: IntegrationSpecRegistry): IntegrationSpecRegistry {
|
|
56
|
+
return registry.register(${varName});
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { generateIntegrationSpec };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { escapeString, toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/knowledge.js
|
|
4
|
+
function generateKnowledgeSpaceSpec(data) {
|
|
5
|
+
const specName = toPascalCase(data.name.split(".").pop() ?? "KnowledgeSpace");
|
|
6
|
+
const varName = `${specName}KnowledgeSpace`;
|
|
7
|
+
const registerFn = `register${specName}KnowledgeSpace`;
|
|
8
|
+
const retention = renderRetention(data);
|
|
9
|
+
const access = renderAccess(data);
|
|
10
|
+
const indexing = renderIndexing(data);
|
|
11
|
+
const policyComment = data.policyName && !data.policyVersion ? ` // defaults to latest version` : "";
|
|
12
|
+
return `import { StabilityEnum } from '@lssm/lib.contracts/ownership';
|
|
13
|
+
import type { KnowledgeSpaceSpec } from '@lssm/lib.contracts/knowledge/spec';
|
|
14
|
+
import type { KnowledgeSpaceRegistry } from '@lssm/lib.contracts/knowledge/spec';
|
|
15
|
+
|
|
16
|
+
export const ${varName}: KnowledgeSpaceSpec = {
|
|
17
|
+
meta: {
|
|
18
|
+
key: '${escapeString(data.name)}',
|
|
19
|
+
version: ${data.version},
|
|
20
|
+
category: '${data.category}',
|
|
21
|
+
displayName: '${escape(data.displayName)}',
|
|
22
|
+
title: '${escape(data.title)}',
|
|
23
|
+
description: '${escape(data.description)}',
|
|
24
|
+
domain: '${escape(data.domain)}',
|
|
25
|
+
owners: [${data.owners.map((owner) => `'${escapeString(owner)}'`).join(", ")}],
|
|
26
|
+
tags: [${data.tags.map((tag) => `'${escapeString(tag)}'`).join(", ")}],
|
|
27
|
+
stability: StabilityEnum.${stabilityToEnum(data.stability)},
|
|
28
|
+
},
|
|
29
|
+
retention: ${retention},
|
|
30
|
+
access: {
|
|
31
|
+
${access}${data.policyName ? ` policy: { name: '${escapeString(data.policyName)}',${data.policyVersion ? ` version: ${data.policyVersion}` : ""} },${policyComment}\n` : ""} },
|
|
32
|
+
${indexing} description: '${escape(data.description || data.displayName)}',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function ${registerFn}(registry: KnowledgeSpaceRegistry): KnowledgeSpaceRegistry {
|
|
36
|
+
return registry.register(${varName});
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
function renderRetention(data) {
|
|
41
|
+
return `{ ttlDays: ${data.retention.ttlDays === null ? "null" : typeof data.retention.ttlDays === "number" ? String(data.retention.ttlDays) : "null"}${typeof data.retention.archiveAfterDays === "number" ? `, archiveAfterDays: ${data.retention.archiveAfterDays}` : ""} }`;
|
|
42
|
+
}
|
|
43
|
+
function renderAccess(data) {
|
|
44
|
+
return `${` trustLevel: '${data.trustLevel}',\n`}${` automationWritable: ${data.automationWritable},\n`}`;
|
|
45
|
+
}
|
|
46
|
+
function renderIndexing(data) {
|
|
47
|
+
const entries = [];
|
|
48
|
+
if (data.embeddingModel) entries.push(` embeddingModel: '${escape(data.embeddingModel)}'`);
|
|
49
|
+
if (typeof data.chunkSize === "number") entries.push(` chunkSize: ${data.chunkSize}`);
|
|
50
|
+
if (data.vectorDbIntegration) entries.push(` vectorDbIntegration: '${escape(data.vectorDbIntegration)}'`);
|
|
51
|
+
if (entries.length === 0) return "";
|
|
52
|
+
return ` indexing: {\n${entries.join(",\n")}\n },\n`;
|
|
53
|
+
}
|
|
54
|
+
function stabilityToEnum(stability) {
|
|
55
|
+
switch (stability) {
|
|
56
|
+
case "beta": return "Beta";
|
|
57
|
+
case "stable": return "Stable";
|
|
58
|
+
case "deprecated": return "Deprecated";
|
|
59
|
+
case "experimental":
|
|
60
|
+
default: return "Experimental";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function escape(value) {
|
|
64
|
+
return value.replace(/`/g, "\\`").replace(/'/g, "\\'");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { generateKnowledgeSpaceSpec };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { escapeString, toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/migration.js
|
|
4
|
+
function generateMigrationSpec(data) {
|
|
5
|
+
const migrationVar = `${toPascalCase(data.name.split(".").pop() ?? "Migration")}Migration`;
|
|
6
|
+
const dependencies = data.dependencies.length > 0 ? `dependencies: [${data.dependencies.map((dep) => `'${escapeString(dep)}'`).join(", ")}],` : "";
|
|
7
|
+
return `import type { MigrationSpec } from '@lssm/lib.contracts/migrations';
|
|
8
|
+
|
|
9
|
+
export const ${migrationVar}: MigrationSpec = {
|
|
10
|
+
meta: {
|
|
11
|
+
name: '${escapeString(data.name)}',
|
|
12
|
+
version: ${data.version},
|
|
13
|
+
title: '${escape(data.title)}',
|
|
14
|
+
description: '${escape(data.description ?? "")}',
|
|
15
|
+
domain: '${escape(data.domain)}',
|
|
16
|
+
owners: [${data.owners.map((owner) => `'${escapeString(owner)}'`).join(", ")}],
|
|
17
|
+
tags: [${data.tags.map((tag) => `'${escapeString(tag)}'`).join(", ")}],
|
|
18
|
+
stability: '${data.stability}',
|
|
19
|
+
},
|
|
20
|
+
plan: {
|
|
21
|
+
up: [
|
|
22
|
+
${renderSteps(data.up)}
|
|
23
|
+
],${data.down && data.down.length ? `
|
|
24
|
+
down: [
|
|
25
|
+
${renderSteps(data.down)}
|
|
26
|
+
],` : ""}
|
|
27
|
+
},
|
|
28
|
+
${dependencies}
|
|
29
|
+
};
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
function renderSteps(steps) {
|
|
33
|
+
return steps.map((step) => {
|
|
34
|
+
const description = step.description ? `description: '${escape(step.description)}',` : "";
|
|
35
|
+
switch (step.kind) {
|
|
36
|
+
case "schema": return ` {
|
|
37
|
+
kind: 'schema',
|
|
38
|
+
${description}
|
|
39
|
+
sql: \`${escape(step.sql ?? "")}\`,
|
|
40
|
+
}`;
|
|
41
|
+
case "data": return ` {
|
|
42
|
+
kind: 'data',
|
|
43
|
+
${description}
|
|
44
|
+
script: \`${escape(step.script ?? "")}\`,
|
|
45
|
+
}`;
|
|
46
|
+
case "validation":
|
|
47
|
+
default: return ` {
|
|
48
|
+
kind: 'validation',
|
|
49
|
+
${description}
|
|
50
|
+
assertion: \`${escape(step.assertion ?? "")}\`,
|
|
51
|
+
}`;
|
|
52
|
+
}
|
|
53
|
+
}).join(",\n");
|
|
54
|
+
}
|
|
55
|
+
function escape(value) {
|
|
56
|
+
return value.replace(/`/g, "\\`").replace(/'/g, "\\'");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { generateMigrationSpec };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { capitalize, toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/operation.js
|
|
4
|
+
/**
|
|
5
|
+
* Generate operation spec TypeScript code.
|
|
6
|
+
*/
|
|
7
|
+
function generateOperationSpec(data) {
|
|
8
|
+
const { name, version, kind, description, goal, context, stability, owners, tags, auth, flags } = data;
|
|
9
|
+
const specVarName = toPascalCase(name.split(".").pop() ?? "Unknown") + "Spec";
|
|
10
|
+
const inputSchemaName = specVarName.replace("Spec", "Input");
|
|
11
|
+
const outputSchemaName = specVarName.replace("Spec", "Output");
|
|
12
|
+
return `import { define${capitalize(kind)} } from '@lssm/lib.contracts';
|
|
13
|
+
import { ScalarTypeEnum, SchemaModel } from '@lssm/lib.schema';
|
|
14
|
+
|
|
15
|
+
// TODO: Define input schema
|
|
16
|
+
export const ${inputSchemaName} = new SchemaModel({
|
|
17
|
+
name: '${inputSchemaName}',
|
|
18
|
+
description: 'Input for ${name}',
|
|
19
|
+
fields: {
|
|
20
|
+
// Add your fields here
|
|
21
|
+
// example: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// TODO: Define output schema
|
|
26
|
+
export const ${outputSchemaName} = new SchemaModel({
|
|
27
|
+
name: '${outputSchemaName}',
|
|
28
|
+
description: 'Output for ${name}',
|
|
29
|
+
fields: {
|
|
30
|
+
// Add your fields here
|
|
31
|
+
ok: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const ${specVarName} = define${capitalize(kind)}({
|
|
36
|
+
meta: {
|
|
37
|
+
name: '${name}',
|
|
38
|
+
version: ${version},
|
|
39
|
+
stability: '${stability}',
|
|
40
|
+
owners: [${owners.map((o) => `'${o}'`).join(", ")}],
|
|
41
|
+
tags: [${tags.map((t) => `'${t}'`).join(", ")}],
|
|
42
|
+
description: '${description}',
|
|
43
|
+
goal: '${goal}',
|
|
44
|
+
context: '${context}',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
io: {
|
|
48
|
+
input: ${inputSchemaName},
|
|
49
|
+
output: ${outputSchemaName},
|
|
50
|
+
errors: {
|
|
51
|
+
// Define possible errors
|
|
52
|
+
// EXAMPLE_ERROR: {
|
|
53
|
+
// description: 'Example error description',
|
|
54
|
+
// http: 400,
|
|
55
|
+
// when: 'When this error occurs',
|
|
56
|
+
// },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
policy: {
|
|
61
|
+
auth: '${auth}',
|
|
62
|
+
${flags.length > 0 ? `flags: [${flags.map((f) => `'${f}'`).join(", ")}],` : "// flags: [],"}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
sideEffects: {
|
|
66
|
+
${data.emitsEvents ? "emits: [\n // Define events to emit\n // { ref: SomeEventSpec, when: 'always' }\n ]," : "// emits: [],"}
|
|
67
|
+
analytics: [
|
|
68
|
+
// Define analytics events
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
transport: {
|
|
73
|
+
rest: { method: '${kind === "command" ? "POST" : "GET"}' },
|
|
74
|
+
gql: { field: '${name.replace(/\./g, "_")}' },
|
|
75
|
+
mcp: { toolName: '${name}.v${version}' },
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
acceptance: {
|
|
79
|
+
scenarios: [
|
|
80
|
+
{
|
|
81
|
+
name: 'Happy path',
|
|
82
|
+
given: ['preconditions'],
|
|
83
|
+
when: ['action taken'],
|
|
84
|
+
then: ['expected outcome'],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
examples: [
|
|
88
|
+
{
|
|
89
|
+
name: 'Example usage',
|
|
90
|
+
input: { /* example input */ },
|
|
91
|
+
output: { ok: true },
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { generateOperationSpec };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/presentation.js
|
|
4
|
+
/**
|
|
5
|
+
* Generate presentation spec TypeScript code.
|
|
6
|
+
*/
|
|
7
|
+
function generatePresentationSpec(data) {
|
|
8
|
+
const { name, version, description, stability, owners, tags, presentationKind } = data;
|
|
9
|
+
const varName = toPascalCase(name.replace(/\./g, "_")) + "Presentation";
|
|
10
|
+
let contentBlock = "";
|
|
11
|
+
switch (presentationKind) {
|
|
12
|
+
case "web_component":
|
|
13
|
+
contentBlock = ` content: {
|
|
14
|
+
kind: 'web_component',
|
|
15
|
+
framework: 'react',
|
|
16
|
+
componentKey: '${name.replace(/\./g, "_")}',
|
|
17
|
+
props: new SchemaModel({
|
|
18
|
+
name: '${varName}Props',
|
|
19
|
+
description: 'Props for ${name}',
|
|
20
|
+
fields: {
|
|
21
|
+
// TODO: Define component props
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
analytics: [
|
|
25
|
+
// TODO: Define analytics events
|
|
26
|
+
],
|
|
27
|
+
},`;
|
|
28
|
+
break;
|
|
29
|
+
case "markdown":
|
|
30
|
+
contentBlock = ` content: {
|
|
31
|
+
kind: 'markdown',
|
|
32
|
+
content: \`
|
|
33
|
+
# ${description}
|
|
34
|
+
|
|
35
|
+
TODO: Add markdown content here
|
|
36
|
+
\`,
|
|
37
|
+
// Or use resourceUri: 'feature://${name}/guide.md'
|
|
38
|
+
},`;
|
|
39
|
+
break;
|
|
40
|
+
case "data":
|
|
41
|
+
contentBlock = ` content: {
|
|
42
|
+
kind: 'data',
|
|
43
|
+
mimeType: 'application/json',
|
|
44
|
+
model: new SchemaModel({
|
|
45
|
+
name: '${varName}Data',
|
|
46
|
+
description: 'Data structure for ${name}',
|
|
47
|
+
fields: {
|
|
48
|
+
// TODO: Define data structure
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
},`;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return `import type { PresentationSpec } from '@lssm/lib.contracts/presentations';
|
|
55
|
+
import { SchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
|
|
56
|
+
|
|
57
|
+
export const ${varName}: PresentationSpec = {
|
|
58
|
+
meta: {
|
|
59
|
+
name: '${name}',
|
|
60
|
+
version: ${version},
|
|
61
|
+
stability: '${stability}',
|
|
62
|
+
owners: [${owners.map((o) => `'${o}'`).join(", ")}],
|
|
63
|
+
tags: [${tags.map((t) => `'${t}'`).join(", ")}],
|
|
64
|
+
description: '${description}',
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
policy: {
|
|
68
|
+
// flags: [],
|
|
69
|
+
// pii: [],
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
${contentBlock}
|
|
73
|
+
};
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { generatePresentationSpec };
|