@cotrrackpro-dev/sdk 0.1.0 → 0.1.2
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/CHANGELOG.md +23 -0
- package/dist/diagram/mermaid.d.ts +24 -0
- package/dist/diagram/mermaid.js +32 -0
- package/dist/diagram/mermaid.js.map +1 -1
- package/dist/diagram/validate.js +22 -0
- package/dist/diagram/validate.js.map +1 -1
- package/dist/nocode/assemble.d.ts +20 -0
- package/dist/nocode/assemble.js +65 -0
- package/dist/nocode/assemble.js.map +1 -0
- package/dist/nocode/core.d.ts +1 -0
- package/dist/nocode/core.js +1 -0
- package/dist/nocode/core.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@cotrackpro/sdk` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.1.2 - 2026-07-06
|
|
6
|
+
|
|
7
|
+
No SDK changes — version bumped in lockstep with the CLI's 0.1.2 legibility pass
|
|
8
|
+
(a new `cotrackpro glossary` command + per-command help examples) so the preview
|
|
9
|
+
packages republish together.
|
|
10
|
+
|
|
11
|
+
## 0.1.1 - 2026-07-06
|
|
12
|
+
|
|
13
|
+
### diagram
|
|
14
|
+
- **approve helpers** — `approveMarkdown`, `isApproved`, and the `STATUS_LINE_RE`
|
|
15
|
+
/ `APPROVED_STATUS_RE` constants: one shared, line-anchored source of truth for
|
|
16
|
+
the approval-doc `Status` line, used by the CLI's `diagram approve` and the
|
|
17
|
+
scaffold "approve before build" gate so they can't drift.
|
|
18
|
+
- **validateMermaid** — stronger, still parser-free: flags unbalanced
|
|
19
|
+
`[](){}` brackets and arrow edges with a missing endpoint (bare-id edges stay
|
|
20
|
+
valid Mermaid).
|
|
21
|
+
|
|
22
|
+
### nocode
|
|
23
|
+
- **assemble** — `deriveMcp`, `deriveVariables`, and `repairApp`: derive an app's
|
|
24
|
+
`settings.mcp` allow-list and `variables` from its node graph (union-merge,
|
|
25
|
+
non-destructive), the shared core behind the CLI's `nocode fix` and the web
|
|
26
|
+
builder's canvas.
|
|
27
|
+
|
|
5
28
|
## 0.1.0 - 2026-07-05
|
|
6
29
|
|
|
7
30
|
Initial public release. Synced the catalog from the canonical
|
|
@@ -8,3 +8,27 @@ export declare function toMermaid(d: Diagram): string;
|
|
|
8
8
|
* Set the status to `Approved` once signed off (the scaffold gate looks for it).
|
|
9
9
|
*/
|
|
10
10
|
export declare function toMarkdown(d: Diagram, meta?: ApprovalMeta): string;
|
|
11
|
+
/** The approval-doc status line (`- **Status:** …`), wherever it sits in the doc.
|
|
12
|
+
* The leading list dash is optional so a hand-written doc matches too. */
|
|
13
|
+
export declare const STATUS_LINE_RE: RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* Line-anchored test for a genuinely-approved doc: the Status line itself must
|
|
16
|
+
* begin with `Approved`. Deliberately strict — the Draft template's line starts
|
|
17
|
+
* with `Draft` (even though the word "Approved" appears later in its hint), so
|
|
18
|
+
* this won't false-match an unreviewed document. The scaffold "approve before
|
|
19
|
+
* build" gate uses this.
|
|
20
|
+
*/
|
|
21
|
+
export declare const APPROVED_STATUS_RE: RegExp;
|
|
22
|
+
/** True when the approval doc's Status line reads `Approved`. */
|
|
23
|
+
export declare function isApproved(markdown: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Flip an approval doc's Status line to `Approved`, optionally stamping the
|
|
26
|
+
* approver/date. Returns the rewritten markdown, or `null` if there is no
|
|
27
|
+
* `- **Status:**` line to flip (so the caller can tell the user to generate the
|
|
28
|
+
* doc with `diagram extract` first). Idempotent — approving an approved doc is a
|
|
29
|
+
* no-op on the status token.
|
|
30
|
+
*/
|
|
31
|
+
export declare function approveMarkdown(markdown: string, meta?: {
|
|
32
|
+
by?: string;
|
|
33
|
+
date?: string;
|
|
34
|
+
}): string | null;
|
package/dist/diagram/mermaid.js
CHANGED
|
@@ -47,4 +47,36 @@ export function toMarkdown(d, meta = {}) {
|
|
|
47
47
|
"",
|
|
48
48
|
].join("\n");
|
|
49
49
|
}
|
|
50
|
+
/** The approval-doc status line (`- **Status:** …`), wherever it sits in the doc.
|
|
51
|
+
* The leading list dash is optional so a hand-written doc matches too. */
|
|
52
|
+
export const STATUS_LINE_RE = /^[ \t]*-?[ \t]*\*\*Status:\*\*.*$/im;
|
|
53
|
+
/**
|
|
54
|
+
* Line-anchored test for a genuinely-approved doc: the Status line itself must
|
|
55
|
+
* begin with `Approved`. Deliberately strict — the Draft template's line starts
|
|
56
|
+
* with `Draft` (even though the word "Approved" appears later in its hint), so
|
|
57
|
+
* this won't false-match an unreviewed document. The scaffold "approve before
|
|
58
|
+
* build" gate uses this.
|
|
59
|
+
*/
|
|
60
|
+
export const APPROVED_STATUS_RE = /^[ \t]*-?[ \t]*\*\*Status:\*\*[ \t]*Approved\b/im;
|
|
61
|
+
/** True when the approval doc's Status line reads `Approved`. */
|
|
62
|
+
export function isApproved(markdown) {
|
|
63
|
+
return APPROVED_STATUS_RE.test(markdown);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Flip an approval doc's Status line to `Approved`, optionally stamping the
|
|
67
|
+
* approver/date. Returns the rewritten markdown, or `null` if there is no
|
|
68
|
+
* `- **Status:**` line to flip (so the caller can tell the user to generate the
|
|
69
|
+
* doc with `diagram extract` first). Idempotent — approving an approved doc is a
|
|
70
|
+
* no-op on the status token.
|
|
71
|
+
*/
|
|
72
|
+
export function approveMarkdown(markdown, meta = {}) {
|
|
73
|
+
if (!STATUS_LINE_RE.test(markdown))
|
|
74
|
+
return null;
|
|
75
|
+
let out = markdown.replace(STATUS_LINE_RE, "- **Status:** Approved");
|
|
76
|
+
if (meta.by) {
|
|
77
|
+
const stamp = `- **Approved by:** ${meta.by}` + (meta.date ? ` **Date:** ${meta.date}` : "");
|
|
78
|
+
out = out.replace(/^[ \t]*-[ \t]*\*\*Approved by:\*\*.*$/im, stamp);
|
|
79
|
+
}
|
|
80
|
+
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
CHANGED
|
@@ -37,6 +37,28 @@ export function validateMermaid(src) {
|
|
|
37
37
|
const body = trimmed.split(/\r?\n/).slice(1).filter((l) => l.trim());
|
|
38
38
|
if (body.length === 0)
|
|
39
39
|
errors.push("diagram has no nodes or edges");
|
|
40
|
+
// Balanced node-shape brackets — the most common hand-editing breakage.
|
|
41
|
+
for (const [open, close, name] of [["[", "]", "square"], ["(", ")", "round"], ["{", "}", "curly"]]) {
|
|
42
|
+
const opens = trimmed.split(open).length - 1;
|
|
43
|
+
const closes = trimmed.split(close).length - 1;
|
|
44
|
+
if (opens !== closes)
|
|
45
|
+
errors.push(`unbalanced ${name} brackets ('${open}' × ${opens}, '${close}' × ${closes})`);
|
|
46
|
+
}
|
|
47
|
+
// Edge sanity: an arrow edge must have a node on each side. Strip node-shape
|
|
48
|
+
// contents and edge labels first so `--` inside a label can't look like a link.
|
|
49
|
+
const EDGE = /-\.?-*>|={2,}>/;
|
|
50
|
+
for (const raw of body) {
|
|
51
|
+
const stripped = raw
|
|
52
|
+
.replace(/\[[^\]]*\]/g, "[]")
|
|
53
|
+
.replace(/\([^)]*\)/g, "()")
|
|
54
|
+
.replace(/\{[^}]*\}/g, "{}")
|
|
55
|
+
.replace(/\|[^|]*\|/g, " ");
|
|
56
|
+
if (!EDGE.test(stripped))
|
|
57
|
+
continue;
|
|
58
|
+
const parts = stripped.split(/-\.?-*>|={2,}>/).map((p) => p.trim());
|
|
59
|
+
if (parts.some((p) => p === ""))
|
|
60
|
+
errors.push(`edge with a missing endpoint: "${raw.trim()}"`);
|
|
61
|
+
}
|
|
40
62
|
return { valid: errors.length === 0, errors };
|
|
41
63
|
}
|
|
42
64
|
/** Extract the first ```mermaid fenced block from a markdown document. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/diagram/validate.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,MAAM,UAAU,eAAe,CAAC,CAAU;IACxC,MAAM,MAAM,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CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the parts of a NoCodeApp that a graph implies but a hand-editor
|
|
3
|
+
* shouldn't have to maintain — `settings.mcp` (every mcpTool node's server must
|
|
4
|
+
* be declared or `validateApp` rejects it) and `variables` (each producing
|
|
5
|
+
* node's output). This is the same logic the browser builder runs on its canvas
|
|
6
|
+
* (`apps/builder/src/lib/assemble.ts`), lifted into the shared core so the CLI's
|
|
7
|
+
* `nocode fix` and the builder derive identically. Import-free by construction.
|
|
8
|
+
*/
|
|
9
|
+
import type { AppNode, McpRef, Variable, NoCodeApp } from "./types.js";
|
|
10
|
+
/** The distinct `{serverId, toolName}` of every mcpTool node — the MCP allow-list. */
|
|
11
|
+
export declare function deriveMcp(nodes: AppNode[]): McpRef[];
|
|
12
|
+
/** Variables the graph produces, in node order: each input's variable + each step's `out`. */
|
|
13
|
+
export declare function deriveVariables(nodes: AppNode[]): Variable[];
|
|
14
|
+
/**
|
|
15
|
+
* Repair an app so it validates: ensure `settings.mcp` covers every mcpTool node
|
|
16
|
+
* and `variables` covers every produced value — WITHOUT dropping anything the
|
|
17
|
+
* author already declared (union by key). Safe on a partial/hand-stripped app:
|
|
18
|
+
* missing `nodes`/`variables`/`settings` are treated as empty and defaulted.
|
|
19
|
+
*/
|
|
20
|
+
export declare function repairApp(app: NoCodeApp): NoCodeApp;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
function str(v) {
|
|
2
|
+
return typeof v === "string" ? v : "";
|
|
3
|
+
}
|
|
4
|
+
/** The distinct `{serverId, toolName}` of every mcpTool node — the MCP allow-list. */
|
|
5
|
+
export function deriveMcp(nodes) {
|
|
6
|
+
const seen = new Set();
|
|
7
|
+
const refs = [];
|
|
8
|
+
for (const n of nodes) {
|
|
9
|
+
if (n.type !== "mcpTool")
|
|
10
|
+
continue;
|
|
11
|
+
const serverId = str(n.data.serverId);
|
|
12
|
+
const toolName = str(n.data.toolName);
|
|
13
|
+
if (!serverId || !toolName)
|
|
14
|
+
continue;
|
|
15
|
+
const key = `${serverId}::${toolName}`;
|
|
16
|
+
if (seen.has(key))
|
|
17
|
+
continue;
|
|
18
|
+
seen.add(key);
|
|
19
|
+
const argMapping = (n.data.argMapping && typeof n.data.argMapping === "object" ? n.data.argMapping : {});
|
|
20
|
+
refs.push({ serverId, toolName, argMapping });
|
|
21
|
+
}
|
|
22
|
+
return refs;
|
|
23
|
+
}
|
|
24
|
+
/** Variables the graph produces, in node order: each input's variable + each step's `out`. */
|
|
25
|
+
export function deriveVariables(nodes) {
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
const vars = [];
|
|
28
|
+
const add = (key, type) => {
|
|
29
|
+
if (!key || seen.has(key))
|
|
30
|
+
return;
|
|
31
|
+
seen.add(key);
|
|
32
|
+
vars.push({ key, type, scope: "local" });
|
|
33
|
+
};
|
|
34
|
+
for (const n of nodes) {
|
|
35
|
+
if (n.type === "input")
|
|
36
|
+
add(str(n.data.variable) || str(n.data.key), "string");
|
|
37
|
+
else if (n.type === "mcpTool")
|
|
38
|
+
add(str(n.data.out), "json");
|
|
39
|
+
else if (n.type === "transform" || n.type === "condition")
|
|
40
|
+
add(str(n.data.out), "string");
|
|
41
|
+
}
|
|
42
|
+
return vars;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Repair an app so it validates: ensure `settings.mcp` covers every mcpTool node
|
|
46
|
+
* and `variables` covers every produced value — WITHOUT dropping anything the
|
|
47
|
+
* author already declared (union by key). Safe on a partial/hand-stripped app:
|
|
48
|
+
* missing `nodes`/`variables`/`settings` are treated as empty and defaulted.
|
|
49
|
+
*/
|
|
50
|
+
export function repairApp(app) {
|
|
51
|
+
const nodes = Array.isArray(app.nodes) ? app.nodes : [];
|
|
52
|
+
const existingVars = Array.isArray(app.variables) ? app.variables : [];
|
|
53
|
+
const varKeys = new Set(existingVars.map((v) => v.key));
|
|
54
|
+
const variables = [...existingVars, ...deriveVariables(nodes).filter((v) => !varKeys.has(v.key))];
|
|
55
|
+
const existingMcp = Array.isArray(app.settings?.mcp) ? app.settings.mcp : [];
|
|
56
|
+
const mcpKeys = new Set(existingMcp.map((m) => `${m.serverId}::${m.toolName}`));
|
|
57
|
+
const mcp = [...existingMcp, ...deriveMcp(nodes).filter((m) => !mcpKeys.has(`${m.serverId}::${m.toolName}`))];
|
|
58
|
+
return {
|
|
59
|
+
...app,
|
|
60
|
+
nodes,
|
|
61
|
+
variables,
|
|
62
|
+
settings: { ...app.settings, storage: app.settings?.storage ?? "memory", mcp },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=assemble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../src/nocode/assemble.ts"],"names":[],"mappings":"AAUA,SAAS,GAAG,CAAC,CAAU;IACrB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxC,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,SAAS,CAAC,KAAgB;IACxC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;YAAE,SAAS;QACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,IAA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,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAChF,MAAM,GAAG,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IAE9G,OAAO;QACL,GAAG,GAAG;QACN,KAAK;QACL,SAAS;QACT,QAAQ,EAAE,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO,IAAI,QAAQ,EAAE,GAAG,EAAE;KAC/E,CAAC;AACJ,CAAC"}
|
package/dist/nocode/core.d.ts
CHANGED
package/dist/nocode/core.js
CHANGED
package/dist/nocode/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/nocode/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/nocode/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotrrackpro-dev/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Typed TypeScript SDK for the CoTrackPro platform — transport, pluggable auth, typed API resources, and MCP/artifact bindings. Consumed by the CLI and every cotrackpro* repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|