@lssm/module.contractspec-workspace 0.0.0-canary-20251217080011 → 1.41.0
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/ai/code-generation.js +13 -50
- package/dist/ai/spec-creation.js +18 -50
- package/dist/analysis/deps/graph.js +2 -84
- package/dist/analysis/deps/parse-imports.js +1 -30
- package/dist/analysis/diff/semantic.js +1 -96
- package/dist/analysis/feature-scan.js +1 -151
- package/dist/analysis/spec-scan.js +1 -344
- package/dist/analysis/validate/spec-structure.js +1 -122
- package/dist/index.js +1 -25
- package/dist/templates/app-config.js +28 -100
- package/dist/templates/data-view.js +27 -41
- package/dist/templates/event.js +14 -28
- package/dist/templates/experiment.js +51 -76
- package/dist/templates/handler.js +17 -49
- package/dist/templates/integration-utils.js +26 -97
- package/dist/templates/integration.js +23 -46
- package/dist/templates/knowledge.js +19 -59
- package/dist/templates/migration.js +26 -49
- package/dist/templates/operation.js +28 -40
- package/dist/templates/presentation.js +20 -45
- package/dist/templates/telemetry.js +53 -73
- package/dist/templates/utils.js +1 -38
- package/dist/templates/workflow-runner.js +6 -12
- package/dist/templates/workflow.js +24 -50
- package/dist/types/generation-types.js +1 -20
- package/package.json +6 -7
- package/dist/ai/code-generation.d.ts +0 -27
- package/dist/ai/spec-creation.d.ts +0 -26
- package/dist/analysis/deps/graph.d.ts +0 -33
- package/dist/analysis/deps/parse-imports.d.ts +0 -16
- package/dist/analysis/diff/semantic.d.ts +0 -10
- package/dist/analysis/feature-scan.d.ts +0 -14
- package/dist/analysis/spec-scan.d.ts +0 -33
- package/dist/analysis/validate/spec-structure.d.ts +0 -10
- package/dist/index.d.ts +0 -26
- package/dist/templates/app-config.d.ts +0 -6
- package/dist/templates/data-view.d.ts +0 -6
- package/dist/templates/event.d.ts +0 -10
- package/dist/templates/experiment.d.ts +0 -6
- package/dist/templates/handler.d.ts +0 -19
- package/dist/templates/integration.d.ts +0 -6
- package/dist/templates/knowledge.d.ts +0 -6
- package/dist/templates/migration.d.ts +0 -6
- package/dist/templates/operation.d.ts +0 -10
- package/dist/templates/presentation.d.ts +0 -10
- package/dist/templates/telemetry.d.ts +0 -6
- package/dist/templates/utils.d.ts +0 -26
- package/dist/templates/workflow-runner.d.ts +0 -15
- package/dist/templates/workflow.d.ts +0 -10
- package/dist/types/analysis-types.d.ts +0 -125
- package/dist/types/generation-types.d.ts +0 -83
- package/dist/types/spec-types.d.ts +0 -344
|
@@ -1,104 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
function renderConfigSchema(fields) {
|
|
3
|
-
const requiredFields = fields.filter((field) => field.required);
|
|
4
|
-
return ` schema: {
|
|
1
|
+
function e(e){let t=e.filter(e=>e.required);return` schema: {
|
|
5
2
|
type: 'object',
|
|
6
|
-
${
|
|
7
|
-
|
|
8
|
-
${(
|
|
9
|
-
|
|
10
|
-
return ` ${field.key}: { type: '${mapConfigType(field.type)}'${description} }`;
|
|
11
|
-
}).join(",\n") : "") || " "}
|
|
3
|
+
${t.length>0?` required: [${t.map(e=>`'${e.key}'`).join(`, `)}],
|
|
4
|
+
`:``} properties: {
|
|
5
|
+
${(e.length?e.map(e=>{let t=e.description?`, description: '${u(e.description)}'`:``;return` ${e.key}: { type: '${o(e.type)}'${t} }`}).join(`,
|
|
6
|
+
`):``)||` `}
|
|
12
7
|
},
|
|
13
|
-
},\n
|
|
14
|
-
}
|
|
15
|
-
function renderSecretSchema(fields) {
|
|
16
|
-
const requiredFields = fields.filter((field) => field.required);
|
|
17
|
-
return ` schema: {
|
|
8
|
+
},\n`}function t(e){let t=e.filter(e=>e.required);return` schema: {
|
|
18
9
|
type: 'object',
|
|
19
|
-
${
|
|
20
|
-
|
|
21
|
-
${(
|
|
22
|
-
|
|
23
|
-
return ` ${field.key}: { type: 'string'${description} }`;
|
|
24
|
-
}).join(",\n") : "") || " "}
|
|
10
|
+
${t.length>0?` required: [${t.map(e=>`'${e.key}'`).join(`, `)}],
|
|
11
|
+
`:``} properties: {
|
|
12
|
+
${(e.length?e.map(e=>{let t=e.description?`, description: '${u(e.description)}'`:``;return` ${e.key}: { type: 'string'${t} }`}).join(`,
|
|
13
|
+
`):``)||` `}
|
|
25
14
|
},
|
|
26
|
-
},\n
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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: {
|
|
15
|
+
},\n`}function n(e){return e.length===0?`{}`:`{
|
|
16
|
+
${e.map(e=>{switch(e.type){case`number`:return` ${e.key}: 0`;case`boolean`:return` ${e.key}: true`;case`string`:default:return` ${e.key}: '${e.key.toUpperCase()}_VALUE'`}}).join(`,
|
|
17
|
+
`)}
|
|
18
|
+
}`}function r(e){return e.length===0?`{}`:`{
|
|
19
|
+
${e.map(e=>` ${e.key}: '${e.key.toUpperCase()}_SECRET'`).join(`,
|
|
20
|
+
`)}
|
|
21
|
+
}`}function i(e,t){if(e==null&&t==null)return``;let n=[];return e!=null&&n.push(` rpm: ${e}`),t!=null&&n.push(` rph: ${t}`),` constraints: {
|
|
53
22
|
rateLimit: {
|
|
54
|
-
${
|
|
23
|
+
${n.join(`,
|
|
24
|
+
`)}
|
|
55
25
|
},
|
|
56
26
|
},
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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 };
|
|
27
|
+
`}function a(e,t,n){if(!e.includes(`byok`))return``;let r=t?` setupInstructions: '${u(t)}',\n`:``,i=n&&n.length?` requiredScopes: [${n.map(e=>`'${u(e)}'`).join(`, `)}],\n`:``;return!r&&!i?``:` byokSetup: {
|
|
28
|
+
${r}${i} },
|
|
29
|
+
`}function o(e){switch(e){case`number`:return`number`;case`boolean`:return`boolean`;case`string`:default:return`string`}}function s(e){switch(e){case`beta`:return`Beta`;case`stable`:return`Stable`;case`deprecated`:return`Deprecated`;case`experimental`:default:return`Experimental`}}function c(e){return e.capabilitiesProvided.map(e=>` { key: '${e.key}', version: ${e.version} }`).join(`,
|
|
30
|
+
`)}function l(e){return e.capabilitiesRequired.length===0?``:` requires: [
|
|
31
|
+
${e.capabilitiesRequired.map(e=>{let t=typeof e.version==`number`?`, version: ${e.version}`:``,n=e.optional?`, optional: true`:``,r=e.reason?`, reason: '${u(e.reason)}'`:``;return` { key: '${e.key}'${t}${n}${r} }`}).join(`,
|
|
32
|
+
`)}
|
|
33
|
+
],`}function u(e){return e.replace(/`/g,"\\`").replace(/'/g,`\\'`)}export{u as escape,a as renderByokSetup,n as renderConfigExample,e as renderConfigSchema,i as renderConstraints,c as renderProvides,l as renderRequires,r as renderSecretExample,t as renderSecretSchema,s as stabilityToEnum};
|
|
@@ -1,62 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { escape, renderByokSetup, renderConfigExample, renderConfigSchema, renderConstraints, renderProvides, renderRequires, renderSecretExample, renderSecretSchema, stabilityToEnum } from "./integration-utils.js";
|
|
3
|
-
|
|
4
|
-
//#region src/templates/integration.ts
|
|
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';
|
|
1
|
+
import{toPascalCase as e}from"./utils.js";import{escape as t,renderByokSetup as n,renderConfigExample as r,renderConfigSchema as i,renderConstraints as a,renderProvides as o,renderRequires as s,renderSecretExample as c,renderSecretSchema as l,stabilityToEnum as u}from"./integration-utils.js";function d(d){let f=e(d.name.split(`.`).pop()??`Integration`),p=`${f}IntegrationSpec`,m=`register${f}Integration`,h=d.supportedModes.length?d.supportedModes:[`managed`],g=h.map(e=>`'${e}'`).join(`, `),_=o(d),v=s(d),y=i(d.configFields),b=r(d.configFields),x=l(d.secretFields),S=c(d.secretFields),C=d.docsUrl?` docsUrl: '${t(d.docsUrl)}',\n`:``,w=a(d.rateLimitRpm,d.rateLimitRph),T=n(h,d.byokSetupInstructions,d.byokRequiredScopes);return`import { StabilityEnum } from '@lssm/lib.contracts/ownership';
|
|
21
2
|
import type { IntegrationSpec } from '@lssm/lib.contracts/integrations/spec';
|
|
22
3
|
import type { IntegrationSpecRegistry } from '@lssm/lib.contracts/integrations/spec';
|
|
23
4
|
|
|
24
|
-
export const ${
|
|
5
|
+
export const ${p}: IntegrationSpec = {
|
|
25
6
|
meta: {
|
|
26
|
-
key: '${
|
|
27
|
-
version: ${
|
|
28
|
-
category: '${
|
|
29
|
-
displayName: '${
|
|
30
|
-
title: '${
|
|
31
|
-
description: '${
|
|
32
|
-
domain: '${
|
|
33
|
-
owners: [${
|
|
34
|
-
tags: [${
|
|
35
|
-
stability: StabilityEnum.${
|
|
7
|
+
key: '${t(d.name)}',
|
|
8
|
+
version: ${d.version},
|
|
9
|
+
category: '${d.category}',
|
|
10
|
+
displayName: '${t(d.displayName)}',
|
|
11
|
+
title: '${t(d.title)}',
|
|
12
|
+
description: '${t(d.description)}',
|
|
13
|
+
domain: '${t(d.domain)}',
|
|
14
|
+
owners: [${d.owners.map(e=>`'${t(e)}'`).join(`, `)}],
|
|
15
|
+
tags: [${d.tags.map(e=>`'${t(e)}'`).join(`, `)}],
|
|
16
|
+
stability: StabilityEnum.${u(d.stability)},
|
|
36
17
|
},
|
|
37
|
-
supportedModes: [${
|
|
18
|
+
supportedModes: [${g}],
|
|
38
19
|
capabilities: {
|
|
39
20
|
provides: [
|
|
40
|
-
${
|
|
21
|
+
${_}
|
|
41
22
|
],
|
|
42
|
-
${
|
|
23
|
+
${v.length>0?`${v}\n`:``} },
|
|
43
24
|
configSchema: {
|
|
44
|
-
${
|
|
25
|
+
${y} example: ${b},
|
|
45
26
|
},
|
|
46
27
|
secretSchema: {
|
|
47
|
-
${
|
|
28
|
+
${x} example: ${S},
|
|
48
29
|
},
|
|
49
|
-
${
|
|
50
|
-
method: '${
|
|
51
|
-
timeoutMs: ${
|
|
30
|
+
${C}${w}${T} healthCheck: {
|
|
31
|
+
method: '${d.healthCheckMethod}',
|
|
32
|
+
timeoutMs: ${d.healthCheckTimeoutMs??5e3},
|
|
52
33
|
},
|
|
53
34
|
};
|
|
54
35
|
|
|
55
|
-
export function ${
|
|
56
|
-
return registry.register(${
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
36
|
+
export function ${m}(registry: IntegrationSpecRegistry): IntegrationSpecRegistry {
|
|
37
|
+
return registry.register(${p});
|
|
59
38
|
}
|
|
60
|
-
|
|
61
|
-
//#endregion
|
|
62
|
-
export { generateIntegrationSpec };
|
|
39
|
+
`}export{d as generateIntegrationSpec};
|
|
@@ -1,68 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/templates/knowledge.ts
|
|
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';
|
|
1
|
+
import{escapeString as e,toPascalCase as t}from"./utils.js";function n(n){let c=t(n.name.split(`.`).pop()??`KnowledgeSpace`),l=`${c}KnowledgeSpace`,u=`register${c}KnowledgeSpace`,d=r(n),f=i(n),p=a(n),m=n.policyName&&!n.policyVersion?` // defaults to latest version`:``;return`import { StabilityEnum } from '@lssm/lib.contracts/ownership';
|
|
13
2
|
import type { KnowledgeSpaceSpec } from '@lssm/lib.contracts/knowledge/spec';
|
|
14
3
|
import type { KnowledgeSpaceRegistry } from '@lssm/lib.contracts/knowledge/spec';
|
|
15
4
|
|
|
16
|
-
export const ${
|
|
5
|
+
export const ${l}: KnowledgeSpaceSpec = {
|
|
17
6
|
meta: {
|
|
18
|
-
key: '${
|
|
19
|
-
version: ${
|
|
20
|
-
category: '${
|
|
21
|
-
displayName: '${
|
|
22
|
-
title: '${
|
|
23
|
-
description: '${
|
|
24
|
-
domain: '${
|
|
25
|
-
owners: [${
|
|
26
|
-
tags: [${
|
|
27
|
-
stability: StabilityEnum.${
|
|
7
|
+
key: '${e(n.name)}',
|
|
8
|
+
version: ${n.version},
|
|
9
|
+
category: '${n.category}',
|
|
10
|
+
displayName: '${s(n.displayName)}',
|
|
11
|
+
title: '${s(n.title)}',
|
|
12
|
+
description: '${s(n.description)}',
|
|
13
|
+
domain: '${s(n.domain)}',
|
|
14
|
+
owners: [${n.owners.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
15
|
+
tags: [${n.tags.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
16
|
+
stability: StabilityEnum.${o(n.stability)},
|
|
28
17
|
},
|
|
29
|
-
retention: ${
|
|
18
|
+
retention: ${d},
|
|
30
19
|
access: {
|
|
31
|
-
${
|
|
32
|
-
${
|
|
20
|
+
${f}${n.policyName?` policy: { name: '${e(n.policyName)}',${n.policyVersion?` version: ${n.policyVersion}`:``} },${m}\n`:``} },
|
|
21
|
+
${p} description: '${s(n.description||n.displayName)}',
|
|
33
22
|
};
|
|
34
23
|
|
|
35
|
-
export function ${
|
|
36
|
-
return registry.register(${
|
|
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`}`;
|
|
24
|
+
export function ${u}(registry: KnowledgeSpaceRegistry): KnowledgeSpaceRegistry {
|
|
25
|
+
return registry.register(${l});
|
|
45
26
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
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 };
|
|
27
|
+
`}function r(e){return`{ ttlDays: ${e.retention.ttlDays===null?`null`:typeof e.retention.ttlDays==`number`?String(e.retention.ttlDays):`null`}${typeof e.retention.archiveAfterDays==`number`?`, archiveAfterDays: ${e.retention.archiveAfterDays}`:``} }`}function i(e){return`${` trustLevel: '${e.trustLevel}',\n`}${` automationWritable: ${e.automationWritable},\n`}`}function a(e){let t=[];return e.embeddingModel&&t.push(` embeddingModel: '${s(e.embeddingModel)}'`),typeof e.chunkSize==`number`&&t.push(` chunkSize: ${e.chunkSize}`),e.vectorDbIntegration&&t.push(` vectorDbIntegration: '${s(e.vectorDbIntegration)}'`),t.length===0?``:` indexing: {\n${t.join(`,
|
|
28
|
+
`)}\n },\n`}function o(e){switch(e){case`beta`:return`Beta`;case`stable`:return`Stable`;case`deprecated`:return`Deprecated`;case`experimental`:default:return`Experimental`}}function s(e){return e.replace(/`/g,"\\`").replace(/'/g,`\\'`)}export{n as generateKnowledgeSpaceSpec};
|
|
@@ -1,60 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{escapeString as e,toPascalCase as t}from"./utils.js";function n(n){let a=`${t(n.name.split(`.`).pop()??`Migration`)}Migration`,o=n.dependencies.length>0?`dependencies: [${n.dependencies.map(t=>`'${e(t)}'`).join(`, `)}],`:``;return`import type { MigrationSpec } from '@lssm/lib.contracts/migrations';
|
|
2
2
|
|
|
3
|
-
|
|
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 = {
|
|
3
|
+
export const ${a}: MigrationSpec = {
|
|
10
4
|
meta: {
|
|
11
|
-
name: '${
|
|
12
|
-
version: ${
|
|
13
|
-
title: '${
|
|
14
|
-
description: '${
|
|
15
|
-
domain: '${
|
|
16
|
-
owners: [${
|
|
17
|
-
tags: [${
|
|
18
|
-
stability: '${
|
|
5
|
+
name: '${e(n.name)}',
|
|
6
|
+
version: ${n.version},
|
|
7
|
+
title: '${i(n.title)}',
|
|
8
|
+
description: '${i(n.description??``)}',
|
|
9
|
+
domain: '${i(n.domain)}',
|
|
10
|
+
owners: [${n.owners.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
11
|
+
tags: [${n.tags.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
12
|
+
stability: '${n.stability}',
|
|
19
13
|
},
|
|
20
14
|
plan: {
|
|
21
15
|
up: [
|
|
22
|
-
${
|
|
23
|
-
],${
|
|
16
|
+
${r(n.up)}
|
|
17
|
+
],${n.down&&n.down.length?`
|
|
24
18
|
down: [
|
|
25
|
-
${
|
|
26
|
-
]
|
|
19
|
+
${r(n.down)}
|
|
20
|
+
],`:``}
|
|
27
21
|
},
|
|
28
|
-
${
|
|
22
|
+
${o}
|
|
29
23
|
};
|
|
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 ` {
|
|
24
|
+
`}function r(e){return e.map(e=>{let t=e.description?`description: '${i(e.description)}',`:``;switch(e.kind){case`schema`:return` {
|
|
37
25
|
kind: 'schema',
|
|
38
|
-
${
|
|
39
|
-
sql: \`${
|
|
40
|
-
}`;
|
|
41
|
-
case "data": return ` {
|
|
26
|
+
${t}
|
|
27
|
+
sql: \`${i(e.sql??``)}\`,
|
|
28
|
+
}`;case`data`:return` {
|
|
42
29
|
kind: 'data',
|
|
43
|
-
${
|
|
44
|
-
script: \`${
|
|
45
|
-
}`;
|
|
46
|
-
case "validation":
|
|
47
|
-
default: return ` {
|
|
30
|
+
${t}
|
|
31
|
+
script: \`${i(e.script??``)}\`,
|
|
32
|
+
}`;case`validation`:default:return` {
|
|
48
33
|
kind: 'validation',
|
|
49
|
-
${
|
|
50
|
-
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 };
|
|
34
|
+
${t}
|
|
35
|
+
assertion: \`${i(e.assertion??``)}\`,
|
|
36
|
+
}`}}).join(`,
|
|
37
|
+
`)}function i(e){return e.replace(/`/g,"\\`").replace(/'/g,`\\'`)}export{n as generateMigrationSpec};
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/templates/operation.ts
|
|
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';
|
|
1
|
+
import{capitalize as e,toPascalCase as t}from"./utils.js";function n(n){let{name:r,version:i,kind:a,description:o,goal:s,context:c,stability:l,owners:u,tags:d,auth:f,flags:p}=n,m=t(r.split(`.`).pop()??`Unknown`)+`Spec`,h=m.replace(`Spec`,`Input`),g=m.replace(`Spec`,`Output`);return`import { define${e(a)} } from '@lssm/lib.contracts';
|
|
13
2
|
import { ScalarTypeEnum, SchemaModel } from '@lssm/lib.schema';
|
|
14
3
|
|
|
15
4
|
// TODO: Define input schema
|
|
16
|
-
export const ${
|
|
17
|
-
name: '${
|
|
18
|
-
description: 'Input for ${
|
|
5
|
+
export const ${h} = new SchemaModel({
|
|
6
|
+
name: '${h}',
|
|
7
|
+
description: 'Input for ${r}',
|
|
19
8
|
fields: {
|
|
20
9
|
// Add your fields here
|
|
21
10
|
// example: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
@@ -23,30 +12,30 @@ export const ${inputSchemaName} = new SchemaModel({
|
|
|
23
12
|
});
|
|
24
13
|
|
|
25
14
|
// TODO: Define output schema
|
|
26
|
-
export const ${
|
|
27
|
-
name: '${
|
|
28
|
-
description: 'Output for ${
|
|
15
|
+
export const ${g} = new SchemaModel({
|
|
16
|
+
name: '${g}',
|
|
17
|
+
description: 'Output for ${r}',
|
|
29
18
|
fields: {
|
|
30
19
|
// Add your fields here
|
|
31
20
|
ok: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
32
21
|
},
|
|
33
22
|
});
|
|
34
23
|
|
|
35
|
-
export const ${
|
|
24
|
+
export const ${m} = define${e(a)}({
|
|
36
25
|
meta: {
|
|
37
|
-
name: '${
|
|
38
|
-
version: ${
|
|
39
|
-
stability: '${
|
|
40
|
-
owners: [${
|
|
41
|
-
tags: [${
|
|
42
|
-
description: '${
|
|
43
|
-
goal: '${
|
|
44
|
-
context: '${
|
|
26
|
+
name: '${r}',
|
|
27
|
+
version: ${i},
|
|
28
|
+
stability: '${l}',
|
|
29
|
+
owners: [${u.map(e=>`'${e}'`).join(`, `)}],
|
|
30
|
+
tags: [${d.map(e=>`'${e}'`).join(`, `)}],
|
|
31
|
+
description: '${o}',
|
|
32
|
+
goal: '${s}',
|
|
33
|
+
context: '${c}',
|
|
45
34
|
},
|
|
46
35
|
|
|
47
36
|
io: {
|
|
48
|
-
input: ${
|
|
49
|
-
output: ${
|
|
37
|
+
input: ${h},
|
|
38
|
+
output: ${g},
|
|
50
39
|
errors: {
|
|
51
40
|
// Define possible errors
|
|
52
41
|
// EXAMPLE_ERROR: {
|
|
@@ -58,21 +47,24 @@ export const ${specVarName} = define${capitalize(kind)}({
|
|
|
58
47
|
},
|
|
59
48
|
|
|
60
49
|
policy: {
|
|
61
|
-
auth: '${
|
|
62
|
-
${
|
|
50
|
+
auth: '${f}',
|
|
51
|
+
${p.length>0?`flags: [${p.map(e=>`'${e}'`).join(`, `)}],`:`// flags: [],`}
|
|
63
52
|
},
|
|
64
53
|
|
|
65
54
|
sideEffects: {
|
|
66
|
-
${
|
|
55
|
+
${n.emitsEvents?`emits: [
|
|
56
|
+
// Define events to emit
|
|
57
|
+
// { ref: SomeEventSpec, when: 'always' }
|
|
58
|
+
],`:`// emits: [],`}
|
|
67
59
|
analytics: [
|
|
68
60
|
// Define analytics events
|
|
69
61
|
],
|
|
70
62
|
},
|
|
71
63
|
|
|
72
64
|
transport: {
|
|
73
|
-
rest: { method: '${
|
|
74
|
-
gql: { field: '${
|
|
75
|
-
mcp: { toolName: '${
|
|
65
|
+
rest: { method: '${a===`command`?`POST`:`GET`}' },
|
|
66
|
+
gql: { field: '${r.replace(/\./g,`_`)}' },
|
|
67
|
+
mcp: { toolName: '${r}.v${i}' },
|
|
76
68
|
},
|
|
77
69
|
|
|
78
70
|
acceptance: {
|
|
@@ -93,8 +85,4 @@ export const ${specVarName} = define${capitalize(kind)}({
|
|
|
93
85
|
],
|
|
94
86
|
},
|
|
95
87
|
});
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//#endregion
|
|
100
|
-
export { generateOperationSpec };
|
|
88
|
+
`}export{n as generateOperationSpec};
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/templates/presentation.ts
|
|
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: {
|
|
1
|
+
import{toPascalCase as e}from"./utils.js";function t(t){let{name:n,version:r,description:i,stability:a,owners:o,tags:s,presentationKind:c}=t,l=e(n.replace(/\./g,`_`))+`Presentation`,u=``;switch(c){case`web_component`:u=` content: {
|
|
14
2
|
kind: 'web_component',
|
|
15
3
|
framework: 'react',
|
|
16
|
-
componentKey: '${
|
|
4
|
+
componentKey: '${n.replace(/\./g,`_`)}',
|
|
17
5
|
props: new SchemaModel({
|
|
18
|
-
name: '${
|
|
19
|
-
description: 'Props for ${
|
|
6
|
+
name: '${l}Props',
|
|
7
|
+
description: 'Props for ${n}',
|
|
20
8
|
fields: {
|
|
21
9
|
// TODO: Define component props
|
|
22
10
|
},
|
|
@@ -24,44 +12,35 @@ function generatePresentationSpec(data) {
|
|
|
24
12
|
analytics: [
|
|
25
13
|
// TODO: Define analytics events
|
|
26
14
|
],
|
|
27
|
-
},`;
|
|
28
|
-
break;
|
|
29
|
-
case "markdown":
|
|
30
|
-
contentBlock = ` content: {
|
|
15
|
+
},`;break;case`markdown`:u=` content: {
|
|
31
16
|
kind: 'markdown',
|
|
32
17
|
content: \`
|
|
33
|
-
# ${
|
|
18
|
+
# ${i}
|
|
34
19
|
|
|
35
20
|
TODO: Add markdown content here
|
|
36
21
|
\`,
|
|
37
|
-
// Or use resourceUri: 'feature://${
|
|
38
|
-
},`;
|
|
39
|
-
break;
|
|
40
|
-
case "data":
|
|
41
|
-
contentBlock = ` content: {
|
|
22
|
+
// Or use resourceUri: 'feature://${n}/guide.md'
|
|
23
|
+
},`;break;case`data`:u=` content: {
|
|
42
24
|
kind: 'data',
|
|
43
25
|
mimeType: 'application/json',
|
|
44
26
|
model: new SchemaModel({
|
|
45
|
-
name: '${
|
|
46
|
-
description: 'Data structure for ${
|
|
27
|
+
name: '${l}Data',
|
|
28
|
+
description: 'Data structure for ${n}',
|
|
47
29
|
fields: {
|
|
48
30
|
// TODO: Define data structure
|
|
49
31
|
},
|
|
50
32
|
}),
|
|
51
|
-
},`;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
return `import type { PresentationSpec } from '@lssm/lib.contracts/presentations';
|
|
33
|
+
},`;break}return`import type { PresentationSpec } from '@lssm/lib.contracts/presentations';
|
|
55
34
|
import { SchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
|
|
56
35
|
|
|
57
|
-
export const ${
|
|
36
|
+
export const ${l}: PresentationSpec = {
|
|
58
37
|
meta: {
|
|
59
|
-
name: '${
|
|
60
|
-
version: ${
|
|
61
|
-
stability: '${
|
|
62
|
-
owners: [${
|
|
63
|
-
tags: [${
|
|
64
|
-
description: '${
|
|
38
|
+
name: '${n}',
|
|
39
|
+
version: ${r},
|
|
40
|
+
stability: '${a}',
|
|
41
|
+
owners: [${o.map(e=>`'${e}'`).join(`, `)}],
|
|
42
|
+
tags: [${s.map(e=>`'${e}'`).join(`, `)}],
|
|
43
|
+
description: '${i}',
|
|
65
44
|
},
|
|
66
45
|
|
|
67
46
|
policy: {
|
|
@@ -69,10 +48,6 @@ export const ${varName}: PresentationSpec = {
|
|
|
69
48
|
// pii: [],
|
|
70
49
|
},
|
|
71
50
|
|
|
72
|
-
${
|
|
51
|
+
${u}
|
|
73
52
|
};
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
export { generatePresentationSpec };
|
|
53
|
+
`}export{t as generatePresentationSpec};
|