@ixo/domain.md 0.3.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/LICENSE +201 -0
- package/NOTICE +6 -0
- package/README.md +30 -0
- package/assets/domain-md.schema.json +1103 -0
- package/assets/oracle-capsule-jcs-vectors.json +57 -0
- package/assets/oracle-capsule-manifest-contract.md +72 -0
- package/assets/oracle-capsule-source-lock.schema.json +45 -0
- package/assets/oracle-capsule.schema.json +265 -0
- package/assets/rules.json +275 -0
- package/assets/spec.md +1434 -0
- package/assets/template-manifest.schema.json +57 -0
- package/dist/capsule/index.d.ts +75 -0
- package/dist/capsule/index.js +20 -0
- package/dist/capsule/index.js.map +1 -0
- package/dist/chunk-BYBC2TSS.js +597 -0
- package/dist/chunk-BYBC2TSS.js.map +1 -0
- package/dist/chunk-G7PZJYAJ.js +31826 -0
- package/dist/chunk-G7PZJYAJ.js.map +1 -0
- package/dist/chunk-R6QZRNEX.js +164 -0
- package/dist/chunk-R6QZRNEX.js.map +1 -0
- package/dist/chunk-T3STBWXP.js +46 -0
- package/dist/chunk-T3STBWXP.js.map +1 -0
- package/dist/chunk-W7MRQP7I.js +862 -0
- package/dist/chunk-W7MRQP7I.js.map +1 -0
- package/dist/chunk-XDIWMZVF.js +1150 -0
- package/dist/chunk-XDIWMZVF.js.map +1 -0
- package/dist/cli-KcUIQEiE.d.ts +171 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +400 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/resolver-B3mwnjJq.d.ts +96 -0
- package/dist/spec.d.ts +20 -0
- package/dist/spec.js +23 -0
- package/dist/spec.js.map +1 -0
- package/dist/templates/index.d.ts +7 -0
- package/dist/templates/index.js +24 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/workers-Dr8B8a2O.d.ts +19 -0
- package/dist/workers.d.ts +3 -0
- package/dist/workers.js +31 -0
- package/dist/workers.js.map +1 -0
- package/package.json +97 -0
- package/src/capsule/canonical.ts +74 -0
- package/src/capsule/index.ts +10 -0
- package/src/capsule/json.ts +373 -0
- package/src/capsule/types.ts +63 -0
- package/src/capsule/validate.ts +551 -0
- package/src/cli.ts +405 -0
- package/src/compiled-validators.d.ts +7 -0
- package/src/compiled-validators.js +32512 -0
- package/src/constants.ts +250 -0
- package/src/diff.ts +111 -0
- package/src/export.ts +28 -0
- package/src/index.ts +36 -0
- package/src/lint.ts +42 -0
- package/src/parser.ts +174 -0
- package/src/sarif.ts +49 -0
- package/src/semantic.ts +1156 -0
- package/src/spec.ts +48 -0
- package/src/templates/errors.ts +3 -0
- package/src/templates/index.ts +11 -0
- package/src/templates/manifest.ts +94 -0
- package/src/templates/render.ts +435 -0
- package/src/templates/resolver.ts +200 -0
- package/src/templates/types.ts +98 -0
- package/src/types.ts +195 -0
- package/src/workers.ts +6 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
diffDomains,
|
|
4
|
+
exportDomain,
|
|
5
|
+
toSarif
|
|
6
|
+
} from "./chunk-R6QZRNEX.js";
|
|
7
|
+
import {
|
|
8
|
+
TemplateValidationError,
|
|
9
|
+
renderTemplateBundle
|
|
10
|
+
} from "./chunk-BYBC2TSS.js";
|
|
11
|
+
import {
|
|
12
|
+
getRules,
|
|
13
|
+
getSchemaSource,
|
|
14
|
+
getSpecification
|
|
15
|
+
} from "./chunk-T3STBWXP.js";
|
|
16
|
+
import {
|
|
17
|
+
lint
|
|
18
|
+
} from "./chunk-XDIWMZVF.js";
|
|
19
|
+
import {
|
|
20
|
+
MAX_DOMAIN_BYTES,
|
|
21
|
+
MAX_LINKED_BYTES,
|
|
22
|
+
MAX_SCALAR_LENGTH,
|
|
23
|
+
MAX_YAML_DEPTH,
|
|
24
|
+
MAX_YAML_NODES,
|
|
25
|
+
PACKAGE_VERSION
|
|
26
|
+
} from "./chunk-G7PZJYAJ.js";
|
|
27
|
+
|
|
28
|
+
// src/cli.ts
|
|
29
|
+
import { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from "fs/promises";
|
|
30
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
31
|
+
import { pathToFileURL } from "url";
|
|
32
|
+
import { defineCommand, runCommand, showUsage } from "citty";
|
|
33
|
+
import { isAlias, parseDocument, visit as visitYaml } from "yaml";
|
|
34
|
+
var InputError = class extends Error {
|
|
35
|
+
};
|
|
36
|
+
var ConformanceError = class extends Error {
|
|
37
|
+
};
|
|
38
|
+
function stdinBytes(maxBytes) {
|
|
39
|
+
return new Promise((resolvePromise, reject) => {
|
|
40
|
+
const chunks = [];
|
|
41
|
+
let size = 0;
|
|
42
|
+
process.stdin.on("data", (chunk) => {
|
|
43
|
+
const bytes = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
44
|
+
size += bytes.length;
|
|
45
|
+
if (size > maxBytes) {
|
|
46
|
+
process.stdin.pause();
|
|
47
|
+
reject(new InputError(`Standard input exceeds ${maxBytes} bytes.`));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
chunks.push(bytes);
|
|
51
|
+
});
|
|
52
|
+
process.stdin.once("end", () => resolvePromise(Buffer.concat(chunks)));
|
|
53
|
+
process.stdin.once("error", reject);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function readInput(input) {
|
|
57
|
+
let bytes;
|
|
58
|
+
let sourceName = input;
|
|
59
|
+
if (input === "-") bytes = await stdinBytes(MAX_DOMAIN_BYTES);
|
|
60
|
+
else {
|
|
61
|
+
let path = resolve(input);
|
|
62
|
+
let stat = await lstat(path).catch(() => void 0);
|
|
63
|
+
if (!stat) throw new InputError(`Input does not exist: ${input}`);
|
|
64
|
+
if (stat.isSymbolicLink()) throw new InputError(`Symlink inputs are forbidden: ${input}`);
|
|
65
|
+
if (stat.isDirectory()) {
|
|
66
|
+
path = join(path, "domain.md");
|
|
67
|
+
stat = await lstat(path).catch(() => void 0);
|
|
68
|
+
}
|
|
69
|
+
if (!stat?.isFile() || stat.isSymbolicLink())
|
|
70
|
+
throw new InputError(`Expected a regular domain.md file: ${input}`);
|
|
71
|
+
if (stat.size > MAX_DOMAIN_BYTES)
|
|
72
|
+
throw new InputError(`Input exceeds ${MAX_DOMAIN_BYTES} bytes: ${input}`);
|
|
73
|
+
bytes = await readFile(path);
|
|
74
|
+
sourceName = path;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
return { content: new TextDecoder("utf-8", { fatal: true }).decode(bytes), sourceName };
|
|
78
|
+
} catch {
|
|
79
|
+
throw new InputError(`Input is not valid UTF-8: ${sourceName}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function textReport(report) {
|
|
83
|
+
const lines = report.findings.map((item) => {
|
|
84
|
+
const location = item.path ? ` ${item.path}` : "";
|
|
85
|
+
return `${item.severity.toUpperCase()} ${item.code}${location}: ${item.message}`;
|
|
86
|
+
});
|
|
87
|
+
lines.push(
|
|
88
|
+
`${report.ok ? "STATIC PASS" : "FAIL"}: ${report.summary.errors} errors, ${report.summary.warnings} warnings, ${report.summary.infos} info`
|
|
89
|
+
);
|
|
90
|
+
if (report.externalChecksRequired.length > 0) {
|
|
91
|
+
lines.push(
|
|
92
|
+
`External checks required: ${report.externalChecksRequired.map((check) => check.code).join(", ")}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return `${lines.join("\n")}
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
function outputLint(report, format) {
|
|
99
|
+
if (format === "json") return `${JSON.stringify(report, null, 2)}
|
|
100
|
+
`;
|
|
101
|
+
if (format === "sarif") return `${JSON.stringify(toSarif(report), null, 2)}
|
|
102
|
+
`;
|
|
103
|
+
if (format === "text") return textReport(report);
|
|
104
|
+
throw new InputError(`Unsupported format ${format}.`);
|
|
105
|
+
}
|
|
106
|
+
var lintCommand = defineCommand({
|
|
107
|
+
meta: { name: "lint", description: "Statically validate a domain.md file or package." },
|
|
108
|
+
args: {
|
|
109
|
+
input: {
|
|
110
|
+
type: "positional",
|
|
111
|
+
required: true,
|
|
112
|
+
description: "File, package directory, or - for stdin"
|
|
113
|
+
},
|
|
114
|
+
format: { type: "string", default: "json", description: "json, text, or sarif" },
|
|
115
|
+
profile: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "Assert authoring_draft, persisted_draft, anchored, or runtime"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
async run({ args }) {
|
|
121
|
+
const input = await readInput(args.input);
|
|
122
|
+
const validProfiles = [
|
|
123
|
+
"authoring_draft",
|
|
124
|
+
"persisted_draft",
|
|
125
|
+
"anchored",
|
|
126
|
+
"runtime"
|
|
127
|
+
];
|
|
128
|
+
if (args.profile !== void 0 && !validProfiles.includes(args.profile)) {
|
|
129
|
+
throw new InputError(`Unsupported profile ${args.profile}.`);
|
|
130
|
+
}
|
|
131
|
+
const profile = args.profile;
|
|
132
|
+
const report = lint(input.content, {
|
|
133
|
+
sourceName: input.sourceName,
|
|
134
|
+
...profile === void 0 ? {} : { expectedProfile: profile }
|
|
135
|
+
});
|
|
136
|
+
process.stdout.write(outputLint(report, args.format));
|
|
137
|
+
process.exitCode = report.ok ? 0 : 1;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
var diffCommand = defineCommand({
|
|
141
|
+
meta: { name: "diff", description: "Compare domain.md documents and classify changes." },
|
|
142
|
+
args: {
|
|
143
|
+
before: { type: "positional", required: true },
|
|
144
|
+
after: { type: "positional", required: true },
|
|
145
|
+
format: { type: "string", default: "json", description: "json or text" },
|
|
146
|
+
failOn: { type: "string", default: "regression", description: "regression or review" }
|
|
147
|
+
},
|
|
148
|
+
async run({ args }) {
|
|
149
|
+
const [before, after] = await Promise.all([readInput(args.before), readInput(args.after)]);
|
|
150
|
+
if (args.failOn !== "regression" && args.failOn !== "review")
|
|
151
|
+
throw new InputError(`Unsupported fail-on mode ${args.failOn}.`);
|
|
152
|
+
const failOn = args.failOn === "review" ? "review" : "regression";
|
|
153
|
+
const report = diffDomains(before.content, after.content, { failOn });
|
|
154
|
+
if (args.format === "json") process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
155
|
+
`);
|
|
156
|
+
else if (args.format === "text") {
|
|
157
|
+
const lines = report.changes.map(
|
|
158
|
+
(change) => `${change.classification.toUpperCase()} ${change.path}`
|
|
159
|
+
);
|
|
160
|
+
lines.push(
|
|
161
|
+
`Regression: ${report.conformanceRegression}; review required: ${report.requiresReview}`
|
|
162
|
+
);
|
|
163
|
+
process.stdout.write(`${lines.join("\n")}
|
|
164
|
+
`);
|
|
165
|
+
} else throw new InputError(`Unsupported format ${args.format}.`);
|
|
166
|
+
process.exitCode = report.regression ? 1 : 0;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
var exportCommand = defineCommand({
|
|
170
|
+
meta: { name: "export", description: "Export a parsed JSON model or SARIF conformance report." },
|
|
171
|
+
args: {
|
|
172
|
+
input: { type: "positional", required: true },
|
|
173
|
+
format: { type: "string", required: true, description: "json or sarif" }
|
|
174
|
+
},
|
|
175
|
+
async run({ args }) {
|
|
176
|
+
if (args.format !== "json" && args.format !== "sarif")
|
|
177
|
+
throw new InputError("Export format must be json or sarif.");
|
|
178
|
+
const input = await readInput(args.input);
|
|
179
|
+
const report = lint(input.content, { sourceName: input.sourceName });
|
|
180
|
+
if (args.format === "json" && !report.ok) {
|
|
181
|
+
throw new ConformanceError(
|
|
182
|
+
`JSON model export refused: ${report.summary.errors} conformance error(s) remain.`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
process.stdout.write(
|
|
186
|
+
exportDomain(input.content, { format: args.format, sourceName: input.sourceName })
|
|
187
|
+
);
|
|
188
|
+
process.exitCode = report.ok ? 0 : 1;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
var specCommand = defineCommand({
|
|
192
|
+
meta: { name: "spec", description: "Output the bundled domain.md specification." },
|
|
193
|
+
args: {
|
|
194
|
+
format: { type: "string", default: "markdown", description: "markdown or json" },
|
|
195
|
+
rules: { type: "boolean", default: false }
|
|
196
|
+
},
|
|
197
|
+
run({ args }) {
|
|
198
|
+
if (args.format === "markdown") {
|
|
199
|
+
process.stdout.write(getSpecification());
|
|
200
|
+
if (args.rules) process.stdout.write(`
|
|
201
|
+
|
|
202
|
+
${JSON.stringify(getRules(), null, 2)}
|
|
203
|
+
`);
|
|
204
|
+
} else if (args.format === "json") {
|
|
205
|
+
process.stdout.write(
|
|
206
|
+
`${JSON.stringify({ specification: getSpecification(), ...args.rules ? { rules: getRules().rules } : {} }, null, 2)}
|
|
207
|
+
`
|
|
208
|
+
);
|
|
209
|
+
} else throw new InputError(`Unsupported format ${args.format}.`);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
var schemaCommand = defineCommand({
|
|
213
|
+
meta: { name: "schema", description: "Output the matching domain.md JSON Schema." },
|
|
214
|
+
run() {
|
|
215
|
+
process.stdout.write(getSchemaSource());
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
async function parseParameters(path) {
|
|
219
|
+
let bytes;
|
|
220
|
+
if (path === "-") bytes = await stdinBytes(MAX_LINKED_BYTES);
|
|
221
|
+
else {
|
|
222
|
+
const parameterPath = resolve(path);
|
|
223
|
+
const stat = await lstat(parameterPath).catch(() => void 0);
|
|
224
|
+
if (!stat?.isFile() || stat.isSymbolicLink())
|
|
225
|
+
throw new InputError(`Expected a regular parameter file: ${path}`);
|
|
226
|
+
if (stat.size > MAX_LINKED_BYTES)
|
|
227
|
+
throw new InputError(`Parameter file exceeds ${MAX_LINKED_BYTES} bytes: ${path}`);
|
|
228
|
+
bytes = await readFile(parameterPath);
|
|
229
|
+
}
|
|
230
|
+
const source = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
231
|
+
const document = parseDocument(source, { prettyErrors: true, uniqueKeys: true, version: "1.2" });
|
|
232
|
+
if (document.errors.length > 0 || document.warnings.length > 0)
|
|
233
|
+
throw new InputError("Parameter file contains invalid or unsafe YAML/JSON.");
|
|
234
|
+
let unsafe = false;
|
|
235
|
+
let nodes = 0;
|
|
236
|
+
let depth = 0;
|
|
237
|
+
let scalarTooLong = false;
|
|
238
|
+
visitYaml(document, {
|
|
239
|
+
Node(_key, node, parents) {
|
|
240
|
+
const candidate = node;
|
|
241
|
+
nodes += 1;
|
|
242
|
+
depth = Math.max(depth, parents.length + 1);
|
|
243
|
+
if (typeof candidate.value === "string" && candidate.value.length > MAX_SCALAR_LENGTH)
|
|
244
|
+
scalarTooLong = true;
|
|
245
|
+
if (isAlias(node) || candidate.anchor || candidate.tag?.startsWith("!")) unsafe = true;
|
|
246
|
+
},
|
|
247
|
+
Pair(_key, pair) {
|
|
248
|
+
const key = pair.key;
|
|
249
|
+
if (key?.value === "<<") unsafe = true;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
if (unsafe)
|
|
253
|
+
throw new InputError("Parameter file contains aliases, anchors, merge keys, or custom tags.");
|
|
254
|
+
if (nodes > MAX_YAML_NODES || depth > MAX_YAML_DEPTH || scalarTooLong) {
|
|
255
|
+
throw new InputError("Parameter file exceeds YAML node, depth, or scalar limits.");
|
|
256
|
+
}
|
|
257
|
+
const value = document.toJS({ maxAliasCount: 0 });
|
|
258
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
259
|
+
throw new InputError("Parameters must be a mapping.");
|
|
260
|
+
return value;
|
|
261
|
+
}
|
|
262
|
+
function safeOutputPath(root, relativePath) {
|
|
263
|
+
const target = resolve(root, relativePath);
|
|
264
|
+
const fromRoot = relative(resolve(root), target);
|
|
265
|
+
if (fromRoot === "" || fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
|
|
266
|
+
throw new InputError(`Rendered path escapes output root: ${relativePath}`);
|
|
267
|
+
}
|
|
268
|
+
return target;
|
|
269
|
+
}
|
|
270
|
+
var initCommand = defineCommand({
|
|
271
|
+
meta: {
|
|
272
|
+
name: "init",
|
|
273
|
+
description: "Render a verified protocol template bundle into an authoring draft."
|
|
274
|
+
},
|
|
275
|
+
args: {
|
|
276
|
+
manifest: { type: "string", required: true },
|
|
277
|
+
protocol: { type: "string", required: true },
|
|
278
|
+
derivedType: { type: "string", required: true },
|
|
279
|
+
params: { type: "string", required: true, description: "JSON/YAML path or -" },
|
|
280
|
+
output: { type: "string", required: true },
|
|
281
|
+
manifestSha256: { type: "string" },
|
|
282
|
+
manifestCid: { type: "string" },
|
|
283
|
+
ipfsGateway: { type: "string" }
|
|
284
|
+
},
|
|
285
|
+
async run({ args }) {
|
|
286
|
+
const output = resolve(args.output);
|
|
287
|
+
if (await lstat(output).then(
|
|
288
|
+
() => true,
|
|
289
|
+
() => false
|
|
290
|
+
))
|
|
291
|
+
throw new InputError(`Output already exists: ${output}`);
|
|
292
|
+
const manifestUri = /^[A-Za-z][A-Za-z0-9+.-]*:/.test(args.manifest) ? args.manifest : pathToFileURL(resolve(args.manifest)).href;
|
|
293
|
+
const derivedTypes = [
|
|
294
|
+
"dao",
|
|
295
|
+
"organisation",
|
|
296
|
+
"project",
|
|
297
|
+
"asset",
|
|
298
|
+
"deed",
|
|
299
|
+
"investment",
|
|
300
|
+
"oracle",
|
|
301
|
+
"service",
|
|
302
|
+
"dataset",
|
|
303
|
+
"device",
|
|
304
|
+
"place",
|
|
305
|
+
"portfolio",
|
|
306
|
+
"marketplace",
|
|
307
|
+
"pod",
|
|
308
|
+
"claim_collection",
|
|
309
|
+
"custom"
|
|
310
|
+
];
|
|
311
|
+
if (!derivedTypes.includes(args.derivedType)) {
|
|
312
|
+
throw new InputError(`Unsupported derived type ${args.derivedType}.`);
|
|
313
|
+
}
|
|
314
|
+
const derivedType = args.derivedType;
|
|
315
|
+
let result;
|
|
316
|
+
try {
|
|
317
|
+
result = await renderTemplateBundle({
|
|
318
|
+
manifestUri,
|
|
319
|
+
expectedProtocol: args.protocol,
|
|
320
|
+
derivedType,
|
|
321
|
+
parameters: await parseParameters(args.params),
|
|
322
|
+
...args.manifestSha256 ? { manifestSha256: args.manifestSha256 } : {},
|
|
323
|
+
...args.manifestCid ? { manifestCid: args.manifestCid } : {},
|
|
324
|
+
...args.ipfsGateway ? { ipfsGateway: args.ipfsGateway } : {}
|
|
325
|
+
});
|
|
326
|
+
} catch (error) {
|
|
327
|
+
if (error instanceof TemplateValidationError) throw new ConformanceError(error.message);
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
const parent = dirname(output);
|
|
331
|
+
await mkdir(parent, { recursive: true });
|
|
332
|
+
const temporary = await mkdtemp(join(parent, `.${basename(output)}-`));
|
|
333
|
+
try {
|
|
334
|
+
for (const file of result.files) {
|
|
335
|
+
const target = safeOutputPath(temporary, file.path);
|
|
336
|
+
await mkdir(dirname(target), { recursive: true });
|
|
337
|
+
await writeFile(target, file.bytes, { flag: "wx" });
|
|
338
|
+
}
|
|
339
|
+
await writeFile(join(temporary, "provenance.yaml"), result.provenance, { flag: "wx" });
|
|
340
|
+
if ((await readdir(temporary)).length === 0)
|
|
341
|
+
throw new InputError("Renderer produced no files.");
|
|
342
|
+
await rename(temporary, output);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
await rm(temporary, { recursive: true, force: true });
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
347
|
+
process.stdout.write(
|
|
348
|
+
`${JSON.stringify(
|
|
349
|
+
{
|
|
350
|
+
state: "authoring_draft",
|
|
351
|
+
output,
|
|
352
|
+
files: result.files.map((file) => ({
|
|
353
|
+
path: file.path,
|
|
354
|
+
role: file.role,
|
|
355
|
+
sha256: file.sha256
|
|
356
|
+
})),
|
|
357
|
+
validation: result.report.summary
|
|
358
|
+
},
|
|
359
|
+
null,
|
|
360
|
+
2
|
|
361
|
+
)}
|
|
362
|
+
`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
var main = defineCommand({
|
|
367
|
+
meta: {
|
|
368
|
+
name: "domain.md",
|
|
369
|
+
version: PACKAGE_VERSION,
|
|
370
|
+
description: "Authority-aware specification, validation, diff, export, and template tooling for domain.md."
|
|
371
|
+
},
|
|
372
|
+
subCommands: {
|
|
373
|
+
lint: lintCommand,
|
|
374
|
+
diff: diffCommand,
|
|
375
|
+
export: exportCommand,
|
|
376
|
+
spec: specCommand,
|
|
377
|
+
schema: schemaCommand,
|
|
378
|
+
init: initCommand
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
async function execute() {
|
|
382
|
+
const rawArgs = process.argv.slice(2);
|
|
383
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h") || rawArgs.length === 0) {
|
|
384
|
+
await showUsage(main);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (rawArgs.length === 1 && (rawArgs[0] === "--version" || rawArgs[0] === "-v")) {
|
|
388
|
+
process.stdout.write(`${PACKAGE_VERSION}
|
|
389
|
+
`);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
await runCommand(main, { rawArgs });
|
|
393
|
+
}
|
|
394
|
+
execute().catch((error) => {
|
|
395
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
396
|
+
process.stderr.write(`Error: ${message}
|
|
397
|
+
`);
|
|
398
|
+
process.exitCode = error instanceof ConformanceError ? 1 : 2;
|
|
399
|
+
});
|
|
400
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { defineCommand, runCommand, showUsage } from 'citty';\nimport { isAlias, parseDocument, visit as visitYaml } from 'yaml';\n\nimport {\n MAX_DOMAIN_BYTES,\n MAX_LINKED_BYTES,\n MAX_SCALAR_LENGTH,\n MAX_YAML_DEPTH,\n MAX_YAML_NODES,\n PACKAGE_VERSION,\n} from './constants.js';\nimport { diffDomains } from './diff.js';\nimport { exportDomain } from './export.js';\nimport { lint } from './lint.js';\nimport { toSarif } from './sarif.js';\nimport { getRules, getSchemaSource, getSpecification } from './spec.js';\nimport { TemplateValidationError } from './templates/errors.js';\nimport { renderTemplateBundle } from './templates/render.js';\nimport type { TemplateDerivedType } from './templates/types.js';\nimport type { ConformanceProfile, Finding, LintReport } from './types.js';\n\nclass InputError extends Error {}\nclass ConformanceError extends Error {}\n\nfunction stdinBytes(maxBytes: number): Promise<Buffer> {\n return new Promise((resolvePromise, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n process.stdin.on('data', (chunk: Buffer | string) => {\n const bytes = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;\n size += bytes.length;\n if (size > maxBytes) {\n process.stdin.pause();\n reject(new InputError(`Standard input exceeds ${maxBytes} bytes.`));\n return;\n }\n chunks.push(bytes);\n });\n process.stdin.once('end', () => resolvePromise(Buffer.concat(chunks)));\n process.stdin.once('error', reject);\n });\n}\n\nasync function readInput(input: string): Promise<{ content: string; sourceName: string }> {\n let bytes: Uint8Array;\n let sourceName = input;\n if (input === '-') bytes = await stdinBytes(MAX_DOMAIN_BYTES);\n else {\n let path = resolve(input);\n let stat = await lstat(path).catch(() => undefined);\n if (!stat) throw new InputError(`Input does not exist: ${input}`);\n if (stat.isSymbolicLink()) throw new InputError(`Symlink inputs are forbidden: ${input}`);\n if (stat.isDirectory()) {\n path = join(path, 'domain.md');\n stat = await lstat(path).catch(() => undefined);\n }\n if (!stat?.isFile() || stat.isSymbolicLink())\n throw new InputError(`Expected a regular domain.md file: ${input}`);\n if (stat.size > MAX_DOMAIN_BYTES)\n throw new InputError(`Input exceeds ${MAX_DOMAIN_BYTES} bytes: ${input}`);\n bytes = await readFile(path);\n sourceName = path;\n }\n try {\n return { content: new TextDecoder('utf-8', { fatal: true }).decode(bytes), sourceName };\n } catch {\n throw new InputError(`Input is not valid UTF-8: ${sourceName}`);\n }\n}\n\nfunction textReport(report: LintReport): string {\n const lines = report.findings.map((item) => {\n const location = item.path ? ` ${item.path}` : '';\n return `${item.severity.toUpperCase()} ${item.code}${location}: ${item.message}`;\n });\n lines.push(\n `${report.ok ? 'STATIC PASS' : 'FAIL'}: ${report.summary.errors} errors, ${report.summary.warnings} warnings, ${report.summary.infos} info`,\n );\n if (report.externalChecksRequired.length > 0) {\n lines.push(\n `External checks required: ${report.externalChecksRequired.map((check) => check.code).join(', ')}`,\n );\n }\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction outputLint(report: LintReport, format: string): string {\n if (format === 'json') return `${JSON.stringify(report, null, 2)}\\n`;\n if (format === 'sarif') return `${JSON.stringify(toSarif(report), null, 2)}\\n`;\n if (format === 'text') return textReport(report);\n throw new InputError(`Unsupported format ${format}.`);\n}\n\nconst lintCommand = defineCommand({\n meta: { name: 'lint', description: 'Statically validate a domain.md file or package.' },\n args: {\n input: {\n type: 'positional',\n required: true,\n description: 'File, package directory, or - for stdin',\n },\n format: { type: 'string', default: 'json', description: 'json, text, or sarif' },\n profile: {\n type: 'string',\n description: 'Assert authoring_draft, persisted_draft, anchored, or runtime',\n },\n },\n async run({ args }) {\n const input = await readInput(args.input);\n const validProfiles: ConformanceProfile[] = [\n 'authoring_draft',\n 'persisted_draft',\n 'anchored',\n 'runtime',\n ];\n if (args.profile !== undefined && !validProfiles.includes(args.profile as ConformanceProfile)) {\n throw new InputError(`Unsupported profile ${args.profile}.`);\n }\n const profile = args.profile as ConformanceProfile | undefined;\n const report = lint(input.content, {\n sourceName: input.sourceName,\n ...(profile === undefined ? {} : { expectedProfile: profile }),\n });\n process.stdout.write(outputLint(report, args.format));\n process.exitCode = report.ok ? 0 : 1;\n },\n});\n\nconst diffCommand = defineCommand({\n meta: { name: 'diff', description: 'Compare domain.md documents and classify changes.' },\n args: {\n before: { type: 'positional', required: true },\n after: { type: 'positional', required: true },\n format: { type: 'string', default: 'json', description: 'json or text' },\n failOn: { type: 'string', default: 'regression', description: 'regression or review' },\n },\n async run({ args }) {\n const [before, after] = await Promise.all([readInput(args.before), readInput(args.after)]);\n if (args.failOn !== 'regression' && args.failOn !== 'review')\n throw new InputError(`Unsupported fail-on mode ${args.failOn}.`);\n const failOn = args.failOn === 'review' ? 'review' : 'regression';\n const report = diffDomains(before.content, after.content, { failOn });\n if (args.format === 'json') process.stdout.write(`${JSON.stringify(report, null, 2)}\\n`);\n else if (args.format === 'text') {\n const lines = report.changes.map(\n (change) => `${change.classification.toUpperCase()} ${change.path}`,\n );\n lines.push(\n `Regression: ${report.conformanceRegression}; review required: ${report.requiresReview}`,\n );\n process.stdout.write(`${lines.join('\\n')}\\n`);\n } else throw new InputError(`Unsupported format ${args.format}.`);\n process.exitCode = report.regression ? 1 : 0;\n },\n});\n\nconst exportCommand = defineCommand({\n meta: { name: 'export', description: 'Export a parsed JSON model or SARIF conformance report.' },\n args: {\n input: { type: 'positional', required: true },\n format: { type: 'string', required: true, description: 'json or sarif' },\n },\n async run({ args }) {\n if (args.format !== 'json' && args.format !== 'sarif')\n throw new InputError('Export format must be json or sarif.');\n const input = await readInput(args.input);\n const report = lint(input.content, { sourceName: input.sourceName });\n if (args.format === 'json' && !report.ok) {\n throw new ConformanceError(\n `JSON model export refused: ${report.summary.errors} conformance error(s) remain.`,\n );\n }\n process.stdout.write(\n exportDomain(input.content, { format: args.format, sourceName: input.sourceName }),\n );\n process.exitCode = report.ok ? 0 : 1;\n },\n});\n\nconst specCommand = defineCommand({\n meta: { name: 'spec', description: 'Output the bundled domain.md specification.' },\n args: {\n format: { type: 'string', default: 'markdown', description: 'markdown or json' },\n rules: { type: 'boolean', default: false },\n },\n run({ args }) {\n if (args.format === 'markdown') {\n process.stdout.write(getSpecification());\n if (args.rules) process.stdout.write(`\\n\\n${JSON.stringify(getRules(), null, 2)}\\n`);\n } else if (args.format === 'json') {\n process.stdout.write(\n `${JSON.stringify({ specification: getSpecification(), ...(args.rules ? { rules: getRules().rules } : {}) }, null, 2)}\\n`,\n );\n } else throw new InputError(`Unsupported format ${args.format}.`);\n },\n});\n\nconst schemaCommand = defineCommand({\n meta: { name: 'schema', description: 'Output the matching domain.md JSON Schema.' },\n run() {\n process.stdout.write(getSchemaSource());\n },\n});\n\nasync function parseParameters(path: string): Promise<Record<string, unknown>> {\n let bytes: Uint8Array;\n if (path === '-') bytes = await stdinBytes(MAX_LINKED_BYTES);\n else {\n const parameterPath = resolve(path);\n const stat = await lstat(parameterPath).catch(() => undefined);\n if (!stat?.isFile() || stat.isSymbolicLink())\n throw new InputError(`Expected a regular parameter file: ${path}`);\n if (stat.size > MAX_LINKED_BYTES)\n throw new InputError(`Parameter file exceeds ${MAX_LINKED_BYTES} bytes: ${path}`);\n bytes = await readFile(parameterPath);\n }\n const source = new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n const document = parseDocument(source, { prettyErrors: true, uniqueKeys: true, version: '1.2' });\n if (document.errors.length > 0 || document.warnings.length > 0)\n throw new InputError('Parameter file contains invalid or unsafe YAML/JSON.');\n let unsafe = false;\n let nodes = 0;\n let depth = 0;\n let scalarTooLong = false;\n visitYaml(document, {\n Node(_key, node, parents) {\n const candidate = node as { anchor?: string; tag?: string; value?: unknown };\n nodes += 1;\n depth = Math.max(depth, parents.length + 1);\n if (typeof candidate.value === 'string' && candidate.value.length > MAX_SCALAR_LENGTH)\n scalarTooLong = true;\n if (isAlias(node) || candidate.anchor || candidate.tag?.startsWith('!')) unsafe = true;\n },\n Pair(_key, pair) {\n const key = pair.key as { value?: unknown } | null;\n if (key?.value === '<<') unsafe = true;\n },\n });\n if (unsafe)\n throw new InputError('Parameter file contains aliases, anchors, merge keys, or custom tags.');\n if (nodes > MAX_YAML_NODES || depth > MAX_YAML_DEPTH || scalarTooLong) {\n throw new InputError('Parameter file exceeds YAML node, depth, or scalar limits.');\n }\n const value: unknown = document.toJS({ maxAliasCount: 0 });\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new InputError('Parameters must be a mapping.');\n return value as Record<string, unknown>;\n}\n\nfunction safeOutputPath(root: string, relativePath: string): string {\n const target = resolve(root, relativePath);\n const fromRoot = relative(resolve(root), target);\n if (\n fromRoot === '' ||\n fromRoot === '..' ||\n fromRoot.startsWith(`..${sep}`) ||\n isAbsolute(fromRoot)\n ) {\n throw new InputError(`Rendered path escapes output root: ${relativePath}`);\n }\n return target;\n}\n\nconst initCommand = defineCommand({\n meta: {\n name: 'init',\n description: 'Render a verified protocol template bundle into an authoring draft.',\n },\n args: {\n manifest: { type: 'string', required: true },\n protocol: { type: 'string', required: true },\n derivedType: { type: 'string', required: true },\n params: { type: 'string', required: true, description: 'JSON/YAML path or -' },\n output: { type: 'string', required: true },\n manifestSha256: { type: 'string' },\n manifestCid: { type: 'string' },\n ipfsGateway: { type: 'string' },\n },\n async run({ args }) {\n const output = resolve(args.output);\n if (\n await lstat(output).then(\n () => true,\n () => false,\n )\n )\n throw new InputError(`Output already exists: ${output}`);\n const manifestUri = /^[A-Za-z][A-Za-z0-9+.-]*:/.test(args.manifest)\n ? args.manifest\n : pathToFileURL(resolve(args.manifest)).href;\n const derivedTypes: TemplateDerivedType[] = [\n 'dao',\n 'organisation',\n 'project',\n 'asset',\n 'deed',\n 'investment',\n 'oracle',\n 'service',\n 'dataset',\n 'device',\n 'place',\n 'portfolio',\n 'marketplace',\n 'pod',\n 'claim_collection',\n 'custom',\n ];\n if (!derivedTypes.includes(args.derivedType as TemplateDerivedType)) {\n throw new InputError(`Unsupported derived type ${args.derivedType}.`);\n }\n const derivedType = args.derivedType as TemplateDerivedType;\n let result;\n try {\n result = await renderTemplateBundle({\n manifestUri,\n expectedProtocol: args.protocol,\n derivedType,\n parameters: await parseParameters(args.params),\n ...(args.manifestSha256 ? { manifestSha256: args.manifestSha256 } : {}),\n ...(args.manifestCid ? { manifestCid: args.manifestCid } : {}),\n ...(args.ipfsGateway ? { ipfsGateway: args.ipfsGateway } : {}),\n });\n } catch (error) {\n if (error instanceof TemplateValidationError) throw new ConformanceError(error.message);\n throw error;\n }\n const parent = dirname(output);\n await mkdir(parent, { recursive: true });\n const temporary = await mkdtemp(join(parent, `.${basename(output)}-`));\n try {\n for (const file of result.files) {\n const target = safeOutputPath(temporary, file.path);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, file.bytes, { flag: 'wx' });\n }\n await writeFile(join(temporary, 'provenance.yaml'), result.provenance, { flag: 'wx' });\n if ((await readdir(temporary)).length === 0)\n throw new InputError('Renderer produced no files.');\n await rename(temporary, output);\n } catch (error) {\n await rm(temporary, { recursive: true, force: true });\n throw error;\n }\n process.stdout.write(\n `${JSON.stringify(\n {\n state: 'authoring_draft',\n output,\n files: result.files.map((file) => ({\n path: file.path,\n role: file.role,\n sha256: file.sha256,\n })),\n validation: result.report.summary,\n },\n null,\n 2,\n )}\\n`,\n );\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: 'domain.md',\n version: PACKAGE_VERSION,\n description:\n 'Authority-aware specification, validation, diff, export, and template tooling for domain.md.',\n },\n subCommands: {\n lint: lintCommand,\n diff: diffCommand,\n export: exportCommand,\n spec: specCommand,\n schema: schemaCommand,\n init: initCommand,\n },\n});\n\nasync function execute(): Promise<void> {\n const rawArgs = process.argv.slice(2);\n if (rawArgs.includes('--help') || rawArgs.includes('-h') || rawArgs.length === 0) {\n await showUsage(main);\n return;\n }\n if (rawArgs.length === 1 && (rawArgs[0] === '--version' || rawArgs[0] === '-v')) {\n process.stdout.write(`${PACKAGE_VERSION}\\n`);\n return;\n }\n await runCommand(main, { rawArgs });\n}\n\nexecute().catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`Error: ${message}\\n`);\n process.exitCode = error instanceof ConformanceError ? 1 : 2;\n});\n\nexport type { Finding };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,OAAO,OAAO,SAAS,UAAU,SAAS,QAAQ,I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ACF;AACA,MAAI,QAAQ,WAAW,MAAM,QAAQ,CAAC,MAAM,eAAe,QAAQ,CAAC,MAAM,OAAO;AAC/E,YAAQ,OAAO,MAAM,GAAG,eAAe;AAAA,CAAI;AAC3C;AAAA,EACF;AACA,QAAM,WAAW,MAAM,EAAE,QAAQ,CAAC;AACpC;AAEA,QAAQ,EAAE,MAAM,CAAC,UAAmB;AAClC,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAQ,OAAO,MAAM,UAAU,OAAO;AAAA,CAAI;AAC1C,UAAQ,WAAW,iBAAiB,mBAAmB,IAAI;AAC7D,CAAC;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a as DiffOptions, b as DiffReport, E as ExportOptions } from './cli-KcUIQEiE.js';
|
|
2
|
+
export { C as ChangeClassification, c as ConformanceProfile, d as ConstitutionDeclaration, e as ConstitutionStatus, f as ConstitutionalAI, g as ConstitutionalExecution, h as ConstitutionalGovernance, i as ConstitutionalInstrument, j as ConstitutionalInstrumentFunction, k as ConstitutionalSubjectProfile, l as DomainChange, m as DomainDocument, n as DomainMode, D as DomainRecord, o as DomainSection, p as ExternalCheck, F as Finding, q as FindingSummary, L as LegalEffect, r as LintOptions, s as LintReport, P as ParseOptions, t as ParseResult, S as Severity, u as SourceLocation } from './cli-KcUIQEiE.js';
|
|
3
|
+
export { C as CONSTITUTIONAL_ARCHETYPES, a as CONSTITUTIONAL_SUBJECT_TYPES, b as CONSTITUTION_AI_MODES, c as CONSTITUTION_EXECUTION_MODES, d as CONSTITUTION_INSTRUMENT_FUNCTIONS, e as CONSTITUTION_STATUSES, f as CONSTITUTION_TYPES, P as PACKAGE_VERSION, S as SPEC_VERSION, l as lint, p as parseDomain } from './workers-Dr8B8a2O.js';
|
|
4
|
+
export { CapsuleCanonicalizationError, CapsuleExternalCheck, CapsuleExternalCheckCategory, CapsuleValidationOptions, CapsuleValidationReport, JcsGoldenVector, JsonPrimitive, JsonValue, StrictJsonDocument, StrictJsonOptions, StrictJsonResult, canonicalizeCapsuleJson, capsuleJcsSha256, oracleCapsuleReleaseDigest, oracleCapsuleReleaseProjection, parseCapsuleJson, validateOracleCapsule } from './capsule/index.js';
|
|
5
|
+
export { getOracleCapsuleContract, getOracleCapsuleJcsVectors, getOracleCapsuleSchema, getOracleCapsuleSourceLockSchema, getRules, getSchema, getSchemaSource, getSpecification, getTemplateManifestSchema } from './spec.js';
|
|
6
|
+
export { F as FileTemplateResolver, H as HttpsTemplateResolver, I as IpfsTemplateResolver, R as RenderTemplateRequest, a as RenderTemplateResult, b as RenderedFile, c as ResolvedTemplateResource, d as TemplateBundleRecord, e as TemplateDerivedType, f as TemplateFileRecord, T as TemplateManifest, g as TemplateResolver, h as TemplateResolverContext, i as TemplateRole, j as TemplateValidationError, k as renderTemplateBundle } from './resolver-B3mwnjJq.js';
|
|
7
|
+
|
|
8
|
+
declare function diffDomains(beforeContent: string, afterContent: string, options?: DiffOptions): DiffReport;
|
|
9
|
+
|
|
10
|
+
declare function exportDomain(content: string, options: ExportOptions): string;
|
|
11
|
+
|
|
12
|
+
export { DiffOptions, DiffReport, ExportOptions, diffDomains, exportDomain };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
diffDomains,
|
|
3
|
+
exportDomain
|
|
4
|
+
} from "./chunk-R6QZRNEX.js";
|
|
5
|
+
import {
|
|
6
|
+
CapsuleCanonicalizationError,
|
|
7
|
+
canonicalizeCapsuleJson,
|
|
8
|
+
capsuleJcsSha256,
|
|
9
|
+
oracleCapsuleReleaseDigest,
|
|
10
|
+
oracleCapsuleReleaseProjection,
|
|
11
|
+
parseCapsuleJson,
|
|
12
|
+
validateOracleCapsule
|
|
13
|
+
} from "./chunk-W7MRQP7I.js";
|
|
14
|
+
import {
|
|
15
|
+
FileTemplateResolver,
|
|
16
|
+
HttpsTemplateResolver,
|
|
17
|
+
IpfsTemplateResolver,
|
|
18
|
+
TemplateValidationError,
|
|
19
|
+
renderTemplateBundle
|
|
20
|
+
} from "./chunk-BYBC2TSS.js";
|
|
21
|
+
import {
|
|
22
|
+
getOracleCapsuleContract,
|
|
23
|
+
getOracleCapsuleJcsVectors,
|
|
24
|
+
getOracleCapsuleSchema,
|
|
25
|
+
getOracleCapsuleSourceLockSchema,
|
|
26
|
+
getRules,
|
|
27
|
+
getSchema,
|
|
28
|
+
getSchemaSource,
|
|
29
|
+
getSpecification,
|
|
30
|
+
getTemplateManifestSchema
|
|
31
|
+
} from "./chunk-T3STBWXP.js";
|
|
32
|
+
import {
|
|
33
|
+
lint,
|
|
34
|
+
parseDomain
|
|
35
|
+
} from "./chunk-XDIWMZVF.js";
|
|
36
|
+
import {
|
|
37
|
+
CONSTITUTIONAL_ARCHETYPES,
|
|
38
|
+
CONSTITUTIONAL_SUBJECT_TYPES,
|
|
39
|
+
CONSTITUTION_AI_MODES,
|
|
40
|
+
CONSTITUTION_EXECUTION_MODES,
|
|
41
|
+
CONSTITUTION_INSTRUMENT_FUNCTIONS,
|
|
42
|
+
CONSTITUTION_STATUSES,
|
|
43
|
+
CONSTITUTION_TYPES,
|
|
44
|
+
PACKAGE_VERSION,
|
|
45
|
+
SPEC_VERSION
|
|
46
|
+
} from "./chunk-G7PZJYAJ.js";
|
|
47
|
+
export {
|
|
48
|
+
CONSTITUTIONAL_ARCHETYPES,
|
|
49
|
+
CONSTITUTIONAL_SUBJECT_TYPES,
|
|
50
|
+
CONSTITUTION_AI_MODES,
|
|
51
|
+
CONSTITUTION_EXECUTION_MODES,
|
|
52
|
+
CONSTITUTION_INSTRUMENT_FUNCTIONS,
|
|
53
|
+
CONSTITUTION_STATUSES,
|
|
54
|
+
CONSTITUTION_TYPES,
|
|
55
|
+
CapsuleCanonicalizationError,
|
|
56
|
+
FileTemplateResolver,
|
|
57
|
+
HttpsTemplateResolver,
|
|
58
|
+
IpfsTemplateResolver,
|
|
59
|
+
PACKAGE_VERSION,
|
|
60
|
+
SPEC_VERSION,
|
|
61
|
+
TemplateValidationError,
|
|
62
|
+
canonicalizeCapsuleJson,
|
|
63
|
+
capsuleJcsSha256,
|
|
64
|
+
diffDomains,
|
|
65
|
+
exportDomain,
|
|
66
|
+
getOracleCapsuleContract,
|
|
67
|
+
getOracleCapsuleJcsVectors,
|
|
68
|
+
getOracleCapsuleSchema,
|
|
69
|
+
getOracleCapsuleSourceLockSchema,
|
|
70
|
+
getRules,
|
|
71
|
+
getSchema,
|
|
72
|
+
getSchemaSource,
|
|
73
|
+
getSpecification,
|
|
74
|
+
getTemplateManifestSchema,
|
|
75
|
+
lint,
|
|
76
|
+
oracleCapsuleReleaseDigest,
|
|
77
|
+
oracleCapsuleReleaseProjection,
|
|
78
|
+
parseCapsuleJson,
|
|
79
|
+
parseDomain,
|
|
80
|
+
renderTemplateBundle,
|
|
81
|
+
validateOracleCapsule
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { s as LintReport } from './cli-KcUIQEiE.js';
|
|
2
|
+
|
|
3
|
+
type TemplateRole = 'domain.md' | 'description' | 'changelog' | 'manifest' | 'playbook' | 'schema' | 'resource' | 'policy' | 'supporting';
|
|
4
|
+
type TemplateDerivedType = 'dao' | 'organisation' | 'project' | 'asset' | 'deed' | 'investment' | 'oracle' | 'service' | 'dataset' | 'device' | 'place' | 'portfolio' | 'marketplace' | 'pod' | 'claim_collection' | 'custom';
|
|
5
|
+
interface TemplateFileRecord {
|
|
6
|
+
role: TemplateRole;
|
|
7
|
+
path: string;
|
|
8
|
+
media_type: 'text/markdown' | 'application/yaml' | 'application/json' | 'text/plain';
|
|
9
|
+
max_bytes: number;
|
|
10
|
+
uri?: string;
|
|
11
|
+
cid?: string | null;
|
|
12
|
+
sha256?: string | null;
|
|
13
|
+
required: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface TemplateBundleRecord {
|
|
16
|
+
derived_type: TemplateDerivedType;
|
|
17
|
+
bundle_version: string;
|
|
18
|
+
files: TemplateFileRecord[];
|
|
19
|
+
}
|
|
20
|
+
interface TemplateManifest {
|
|
21
|
+
version: '1.0.0-rc.3';
|
|
22
|
+
kind: 'domain.md/template-manifest';
|
|
23
|
+
protocol: string;
|
|
24
|
+
protocol_version: string;
|
|
25
|
+
bundles: TemplateBundleRecord[];
|
|
26
|
+
}
|
|
27
|
+
interface ResolvedTemplateResource {
|
|
28
|
+
uri: string;
|
|
29
|
+
bytes: Uint8Array;
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
}
|
|
32
|
+
interface TemplateResolverContext {
|
|
33
|
+
maxBytes: number;
|
|
34
|
+
timeoutMs: number;
|
|
35
|
+
}
|
|
36
|
+
interface TemplateResolver {
|
|
37
|
+
supports(uri: string): boolean;
|
|
38
|
+
resolve(uri: string, context: TemplateResolverContext): Promise<ResolvedTemplateResource>;
|
|
39
|
+
}
|
|
40
|
+
interface RenderTemplateRequest {
|
|
41
|
+
manifestUri: string;
|
|
42
|
+
expectedProtocol: string;
|
|
43
|
+
derivedType: TemplateDerivedType;
|
|
44
|
+
parameters: Record<string, unknown>;
|
|
45
|
+
manifestSha256?: string;
|
|
46
|
+
manifestCid?: string;
|
|
47
|
+
ipfsGateway?: string;
|
|
48
|
+
resolvers?: TemplateResolver[];
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
}
|
|
51
|
+
interface RenderedFile {
|
|
52
|
+
role: string;
|
|
53
|
+
path: string;
|
|
54
|
+
bytes: Uint8Array;
|
|
55
|
+
sha256: string;
|
|
56
|
+
sourceUri: string;
|
|
57
|
+
}
|
|
58
|
+
interface RenderTemplateResult {
|
|
59
|
+
files: RenderedFile[];
|
|
60
|
+
provenance: string;
|
|
61
|
+
report: LintReport;
|
|
62
|
+
manifest: TemplateManifest;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare function renderTemplateBundle(request: RenderTemplateRequest): Promise<RenderTemplateResult>;
|
|
66
|
+
|
|
67
|
+
declare class TemplateValidationError extends Error {
|
|
68
|
+
readonly name = "TemplateValidationError";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare function validateHttpsTarget(url: URL, addresses?: string[]): void;
|
|
72
|
+
declare class FileTemplateResolver implements TemplateResolver {
|
|
73
|
+
supports(uri: string): boolean;
|
|
74
|
+
resolve(uri: string, context: TemplateResolverContext): Promise<ResolvedTemplateResource>;
|
|
75
|
+
static resolveRelative(manifestUri: string, logicalPath: string): Promise<string>;
|
|
76
|
+
}
|
|
77
|
+
interface HttpsResolverOptions {
|
|
78
|
+
maxRedirects?: number;
|
|
79
|
+
}
|
|
80
|
+
declare class HttpsTemplateResolver implements TemplateResolver {
|
|
81
|
+
readonly maxRedirects: number;
|
|
82
|
+
constructor(options?: HttpsResolverOptions);
|
|
83
|
+
supports(uri: string): boolean;
|
|
84
|
+
resolve(uri: string, context: TemplateResolverContext): Promise<ResolvedTemplateResource>;
|
|
85
|
+
private fetch;
|
|
86
|
+
}
|
|
87
|
+
declare class IpfsTemplateResolver implements TemplateResolver {
|
|
88
|
+
private readonly gateway;
|
|
89
|
+
private readonly https;
|
|
90
|
+
constructor(gateway: string, httpsResolver?: HttpsTemplateResolver);
|
|
91
|
+
supports(uri: string): boolean;
|
|
92
|
+
resolve(uri: string, context: TemplateResolverContext): Promise<ResolvedTemplateResource>;
|
|
93
|
+
}
|
|
94
|
+
declare function relativeTemplateUri(manifestUri: string, logicalPath: string): string;
|
|
95
|
+
|
|
96
|
+
export { FileTemplateResolver as F, HttpsTemplateResolver as H, IpfsTemplateResolver as I, type RenderTemplateRequest as R, type TemplateManifest as T, type RenderTemplateResult as a, type RenderedFile as b, type ResolvedTemplateResource as c, type TemplateBundleRecord as d, type TemplateDerivedType as e, type TemplateFileRecord as f, type TemplateResolver as g, type TemplateResolverContext as h, type TemplateRole as i, TemplateValidationError as j, renderTemplateBundle as k, relativeTemplateUri as r, validateHttpsTarget as v };
|
package/dist/spec.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { D as DomainRecord } from './cli-KcUIQEiE.js';
|
|
2
|
+
|
|
3
|
+
declare function getSpecification(): string;
|
|
4
|
+
declare function getSchema(): DomainRecord;
|
|
5
|
+
declare function getSchemaSource(): string;
|
|
6
|
+
declare function getTemplateManifestSchema(): DomainRecord;
|
|
7
|
+
declare function getOracleCapsuleSchema(): DomainRecord;
|
|
8
|
+
declare function getOracleCapsuleSourceLockSchema(): DomainRecord;
|
|
9
|
+
declare function getOracleCapsuleContract(): string;
|
|
10
|
+
declare function getOracleCapsuleJcsVectors(): unknown;
|
|
11
|
+
declare function getRules(): {
|
|
12
|
+
specVersion: string;
|
|
13
|
+
rules: Array<{
|
|
14
|
+
code: string;
|
|
15
|
+
severity: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { getOracleCapsuleContract, getOracleCapsuleJcsVectors, getOracleCapsuleSchema, getOracleCapsuleSourceLockSchema, getRules, getSchema, getSchemaSource, getSpecification, getTemplateManifestSchema };
|