@lushly-dev/violet-afd 0.0.0-stage → 0.3.0-preview.1
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 +21 -0
- package/README.md +29 -2
- package/dist/commands/analyze/compare.d.ts +36 -0
- package/dist/commands/analyze/compare.d.ts.map +1 -0
- package/dist/commands/analyze/compare.js +196 -0
- package/dist/commands/analyze/compare.js.map +1 -0
- package/dist/commands/analyze/compliance.d.ts +41 -0
- package/dist/commands/analyze/compliance.d.ts.map +1 -0
- package/dist/commands/analyze/compliance.js +166 -0
- package/dist/commands/analyze/compliance.js.map +1 -0
- package/dist/commands/analyze/deviations.d.ts +30 -0
- package/dist/commands/analyze/deviations.d.ts.map +1 -0
- package/dist/commands/analyze/deviations.js +201 -0
- package/dist/commands/analyze/deviations.js.map +1 -0
- package/dist/commands/analyze/health.d.ts +211 -0
- package/dist/commands/analyze/health.d.ts.map +1 -0
- package/dist/commands/analyze/health.js +697 -0
- package/dist/commands/analyze/health.js.map +1 -0
- package/dist/commands/analyze/index.d.ts +15 -0
- package/dist/commands/analyze/index.d.ts.map +1 -0
- package/dist/commands/analyze/index.js +31 -0
- package/dist/commands/analyze/index.js.map +1 -0
- package/dist/commands/analyze/snapshot.d.ts +64 -0
- package/dist/commands/analyze/snapshot.d.ts.map +1 -0
- package/dist/commands/analyze/snapshot.js +126 -0
- package/dist/commands/analyze/snapshot.js.map +1 -0
- package/dist/commands/analyze/trends.d.ts +82 -0
- package/dist/commands/analyze/trends.d.ts.map +1 -0
- package/dist/commands/analyze/trends.js +312 -0
- package/dist/commands/analyze/trends.js.map +1 -0
- package/dist/commands/analyze/violations.d.ts +84 -0
- package/dist/commands/analyze/violations.d.ts.map +1 -0
- package/dist/commands/analyze/violations.js +158 -0
- package/dist/commands/analyze/violations.js.map +1 -0
- package/dist/commands/apikeys/check.d.ts +39 -0
- package/dist/commands/apikeys/check.d.ts.map +1 -0
- package/dist/commands/apikeys/check.js +61 -0
- package/dist/commands/apikeys/check.js.map +1 -0
- package/dist/commands/apikeys/create.d.ts +36 -0
- package/dist/commands/apikeys/create.d.ts.map +1 -0
- package/dist/commands/apikeys/create.js +116 -0
- package/dist/commands/apikeys/create.js.map +1 -0
- package/dist/commands/apikeys/index.d.ts +15 -0
- package/dist/commands/apikeys/index.d.ts.map +1 -0
- package/dist/commands/apikeys/index.js +21 -0
- package/dist/commands/apikeys/index.js.map +1 -0
- package/dist/commands/apikeys/keys.d.ts +79 -0
- package/dist/commands/apikeys/keys.d.ts.map +1 -0
- package/dist/commands/apikeys/keys.js +239 -0
- package/dist/commands/apikeys/keys.js.map +1 -0
- package/dist/commands/audit/index.d.ts +11 -0
- package/dist/commands/audit/index.d.ts.map +1 -0
- package/dist/commands/audit/index.js +15 -0
- package/dist/commands/audit/index.js.map +1 -0
- package/dist/commands/audit/list.d.ts +101 -0
- package/dist/commands/audit/list.d.ts.map +1 -0
- package/dist/commands/audit/list.js +230 -0
- package/dist/commands/audit/list.js.map +1 -0
- package/dist/commands/changes/impact.d.ts +477 -0
- package/dist/commands/changes/impact.d.ts.map +1 -0
- package/dist/commands/changes/impact.js +541 -0
- package/dist/commands/changes/impact.js.map +1 -0
- package/dist/commands/changes/index.d.ts +11 -0
- package/dist/commands/changes/index.d.ts.map +1 -0
- package/dist/commands/changes/index.js +15 -0
- package/dist/commands/changes/index.js.map +1 -0
- package/dist/commands/constraints/index.d.ts +11 -0
- package/dist/commands/constraints/index.d.ts.map +1 -0
- package/dist/commands/constraints/index.js +19 -0
- package/dist/commands/constraints/index.js.map +1 -0
- package/dist/commands/constraints/list.d.ts +52 -0
- package/dist/commands/constraints/list.d.ts.map +1 -0
- package/dist/commands/constraints/list.js +103 -0
- package/dist/commands/constraints/list.js.map +1 -0
- package/dist/commands/constraints/set.d.ts +50 -0
- package/dist/commands/constraints/set.d.ts.map +1 -0
- package/dist/commands/constraints/set.js +137 -0
- package/dist/commands/constraints/set.js.map +1 -0
- package/dist/commands/constraints/validate.d.ts +38 -0
- package/dist/commands/constraints/validate.d.ts.map +1 -0
- package/dist/commands/constraints/validate.js +164 -0
- package/dist/commands/constraints/validate.js.map +1 -0
- package/dist/commands/docs/generator.d.ts +77 -0
- package/dist/commands/docs/generator.d.ts.map +1 -0
- package/dist/commands/docs/generator.js +256 -0
- package/dist/commands/docs/generator.js.map +1 -0
- package/dist/commands/docs/index.d.ts +6 -0
- package/dist/commands/docs/index.d.ts.map +1 -0
- package/dist/commands/docs/index.js +6 -0
- package/dist/commands/docs/index.js.map +1 -0
- package/dist/commands/export/export.d.ts +64 -0
- package/dist/commands/export/export.d.ts.map +1 -0
- package/dist/commands/export/export.js +193 -0
- package/dist/commands/export/export.js.map +1 -0
- package/dist/commands/export/index.d.ts +9 -0
- package/dist/commands/export/index.d.ts.map +1 -0
- package/dist/commands/export/index.js +13 -0
- package/dist/commands/export/index.js.map +1 -0
- package/dist/commands/import/flatten.d.ts +30 -0
- package/dist/commands/import/flatten.d.ts.map +1 -0
- package/dist/commands/import/flatten.js +121 -0
- package/dist/commands/import/flatten.js.map +1 -0
- package/dist/commands/import/index.d.ts +11 -0
- package/dist/commands/import/index.d.ts.map +1 -0
- package/dist/commands/import/index.js +19 -0
- package/dist/commands/import/index.js.map +1 -0
- package/dist/commands/import/json.d.ts +40 -0
- package/dist/commands/import/json.d.ts.map +1 -0
- package/dist/commands/import/json.js +209 -0
- package/dist/commands/import/json.js.map +1 -0
- package/dist/commands/import/tree.d.ts +39 -0
- package/dist/commands/import/tree.d.ts.map +1 -0
- package/dist/commands/import/tree.js +247 -0
- package/dist/commands/import/tree.js.map +1 -0
- package/dist/commands/import/validate.d.ts +53 -0
- package/dist/commands/import/validate.d.ts.map +1 -0
- package/dist/commands/import/validate.js +201 -0
- package/dist/commands/import/validate.js.map +1 -0
- package/dist/commands/index.d.ts +21 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +21 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/json-schema.d.ts +21 -0
- package/dist/commands/json-schema.d.ts.map +1 -0
- package/dist/commands/json-schema.js +41 -0
- package/dist/commands/json-schema.js.map +1 -0
- package/dist/commands/node/create.d.ts +80 -0
- package/dist/commands/node/create.d.ts.map +1 -0
- package/dist/commands/node/create.js +174 -0
- package/dist/commands/node/create.js.map +1 -0
- package/dist/commands/node/delete.d.ts +28 -0
- package/dist/commands/node/delete.d.ts.map +1 -0
- package/dist/commands/node/delete.js +134 -0
- package/dist/commands/node/delete.js.map +1 -0
- package/dist/commands/node/deprecation.d.ts +23 -0
- package/dist/commands/node/deprecation.d.ts.map +1 -0
- package/dist/commands/node/deprecation.js +59 -0
- package/dist/commands/node/deprecation.js.map +1 -0
- package/dist/commands/node/get.d.ts +79 -0
- package/dist/commands/node/get.d.ts.map +1 -0
- package/dist/commands/node/get.js +106 -0
- package/dist/commands/node/get.js.map +1 -0
- package/dist/commands/node/graph.d.ts +138 -0
- package/dist/commands/node/graph.d.ts.map +1 -0
- package/dist/commands/node/graph.js +285 -0
- package/dist/commands/node/graph.js.map +1 -0
- package/dist/commands/node/index.d.ts +17 -0
- package/dist/commands/node/index.d.ts.map +1 -0
- package/dist/commands/node/index.js +31 -0
- package/dist/commands/node/index.js.map +1 -0
- package/dist/commands/node/list.d.ts +74 -0
- package/dist/commands/node/list.d.ts.map +1 -0
- package/dist/commands/node/list.js +130 -0
- package/dist/commands/node/list.js.map +1 -0
- package/dist/commands/node/operations.d.ts +35 -0
- package/dist/commands/node/operations.d.ts.map +1 -0
- package/dist/commands/node/operations.js +66 -0
- package/dist/commands/node/operations.js.map +1 -0
- package/dist/commands/node/scope.d.ts +14 -0
- package/dist/commands/node/scope.d.ts.map +1 -0
- package/dist/commands/node/scope.js +49 -0
- package/dist/commands/node/scope.js.map +1 -0
- package/dist/commands/node/update.d.ts +84 -0
- package/dist/commands/node/update.d.ts.map +1 -0
- package/dist/commands/node/update.js +229 -0
- package/dist/commands/node/update.js.map +1 -0
- package/dist/commands/registry.d.ts +126 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +141 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/specimen/get.d.ts +47 -0
- package/dist/commands/specimen/get.d.ts.map +1 -0
- package/dist/commands/specimen/get.js +124 -0
- package/dist/commands/specimen/get.js.map +1 -0
- package/dist/commands/specimen/index.d.ts +10 -0
- package/dist/commands/specimen/index.d.ts.map +1 -0
- package/dist/commands/specimen/index.js +16 -0
- package/dist/commands/specimen/index.js.map +1 -0
- package/dist/commands/specimen/set.d.ts +31 -0
- package/dist/commands/specimen/set.d.ts.map +1 -0
- package/dist/commands/specimen/set.js +198 -0
- package/dist/commands/specimen/set.js.map +1 -0
- package/dist/commands/specimen/shared.d.ts +15 -0
- package/dist/commands/specimen/shared.d.ts.map +1 -0
- package/dist/commands/specimen/shared.js +26 -0
- package/dist/commands/specimen/shared.js.map +1 -0
- package/dist/commands/system/doctor.d.ts +48 -0
- package/dist/commands/system/doctor.d.ts.map +1 -0
- package/dist/commands/system/doctor.js +224 -0
- package/dist/commands/system/doctor.js.map +1 -0
- package/dist/commands/system/index.d.ts +12 -0
- package/dist/commands/system/index.d.ts.map +1 -0
- package/dist/commands/system/index.js +17 -0
- package/dist/commands/system/index.js.map +1 -0
- package/dist/commands/system/validate.d.ts +47 -0
- package/dist/commands/system/validate.d.ts.map +1 -0
- package/dist/commands/system/validate.js +245 -0
- package/dist/commands/system/validate.js.map +1 -0
- package/dist/commands/token/add.d.ts +94 -0
- package/dist/commands/token/add.d.ts.map +1 -0
- package/dist/commands/token/add.js +162 -0
- package/dist/commands/token/add.js.map +1 -0
- package/dist/commands/token/catalog.d.ts +69 -0
- package/dist/commands/token/catalog.d.ts.map +1 -0
- package/dist/commands/token/catalog.js +175 -0
- package/dist/commands/token/catalog.js.map +1 -0
- package/dist/commands/token/compare.d.ts +140 -0
- package/dist/commands/token/compare.d.ts.map +1 -0
- package/dist/commands/token/compare.js +207 -0
- package/dist/commands/token/compare.js.map +1 -0
- package/dist/commands/token/copy.d.ts +31 -0
- package/dist/commands/token/copy.d.ts.map +1 -0
- package/dist/commands/token/copy.js +179 -0
- package/dist/commands/token/copy.js.map +1 -0
- package/dist/commands/token/definitions.d.ts +29 -0
- package/dist/commands/token/definitions.d.ts.map +1 -0
- package/dist/commands/token/definitions.js +63 -0
- package/dist/commands/token/definitions.js.map +1 -0
- package/dist/commands/token/index.d.ts +22 -0
- package/dist/commands/token/index.d.ts.map +1 -0
- package/dist/commands/token/index.js +44 -0
- package/dist/commands/token/index.js.map +1 -0
- package/dist/commands/token/lineage.d.ts +43 -0
- package/dist/commands/token/lineage.d.ts.map +1 -0
- package/dist/commands/token/lineage.js +187 -0
- package/dist/commands/token/lineage.js.map +1 -0
- package/dist/commands/token/matrix.d.ts +249 -0
- package/dist/commands/token/matrix.d.ts.map +1 -0
- package/dist/commands/token/matrix.js +658 -0
- package/dist/commands/token/matrix.js.map +1 -0
- package/dist/commands/token/override.d.ts +51 -0
- package/dist/commands/token/override.d.ts.map +1 -0
- package/dist/commands/token/override.js +158 -0
- package/dist/commands/token/override.js.map +1 -0
- package/dist/commands/token/previous-value.d.ts +23 -0
- package/dist/commands/token/previous-value.d.ts.map +1 -0
- package/dist/commands/token/previous-value.js +26 -0
- package/dist/commands/token/previous-value.js.map +1 -0
- package/dist/commands/token/reset.d.ts +29 -0
- package/dist/commands/token/reset.d.ts.map +1 -0
- package/dist/commands/token/reset.js +143 -0
- package/dist/commands/token/reset.js.map +1 -0
- package/dist/commands/token/resolve.d.ts +43 -0
- package/dist/commands/token/resolve.d.ts.map +1 -0
- package/dist/commands/token/resolve.js +136 -0
- package/dist/commands/token/resolve.js.map +1 -0
- package/dist/commands/token/subtract.d.ts +27 -0
- package/dist/commands/token/subtract.d.ts.map +1 -0
- package/dist/commands/token/subtract.js +129 -0
- package/dist/commands/token/subtract.js.map +1 -0
- package/dist/commands/webhooks/delete.d.ts +31 -0
- package/dist/commands/webhooks/delete.d.ts.map +1 -0
- package/dist/commands/webhooks/delete.js +94 -0
- package/dist/commands/webhooks/delete.js.map +1 -0
- package/dist/commands/webhooks/get.d.ts +50 -0
- package/dist/commands/webhooks/get.d.ts.map +1 -0
- package/dist/commands/webhooks/get.js +122 -0
- package/dist/commands/webhooks/get.js.map +1 -0
- package/dist/commands/webhooks/index.d.ts +24 -0
- package/dist/commands/webhooks/index.d.ts.map +1 -0
- package/dist/commands/webhooks/index.js +41 -0
- package/dist/commands/webhooks/index.js.map +1 -0
- package/dist/commands/webhooks/list.d.ts +72 -0
- package/dist/commands/webhooks/list.d.ts.map +1 -0
- package/dist/commands/webhooks/list.js +116 -0
- package/dist/commands/webhooks/list.js.map +1 -0
- package/dist/commands/webhooks/logs.d.ts +65 -0
- package/dist/commands/webhooks/logs.d.ts.map +1 -0
- package/dist/commands/webhooks/logs.js +138 -0
- package/dist/commands/webhooks/logs.js.map +1 -0
- package/dist/commands/webhooks/redact.d.ts +18 -0
- package/dist/commands/webhooks/redact.d.ts.map +1 -0
- package/dist/commands/webhooks/redact.js +24 -0
- package/dist/commands/webhooks/redact.js.map +1 -0
- package/dist/commands/webhooks/register.d.ts +78 -0
- package/dist/commands/webhooks/register.d.ts.map +1 -0
- package/dist/commands/webhooks/register.js +175 -0
- package/dist/commands/webhooks/register.js.map +1 -0
- package/dist/commands/webhooks/test.d.ts +32 -0
- package/dist/commands/webhooks/test.d.ts.map +1 -0
- package/dist/commands/webhooks/test.js +101 -0
- package/dist/commands/webhooks/test.js.map +1 -0
- package/dist/commands/webhooks/update.d.ts +77 -0
- package/dist/commands/webhooks/update.d.ts.map +1 -0
- package/dist/commands/webhooks/update.js +198 -0
- package/dist/commands/webhooks/update.js.map +1 -0
- package/dist/css.d.ts +3 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +3 -0
- package/dist/css.js.map +1 -0
- package/dist/demo/index.d.ts +8 -0
- package/dist/demo/index.d.ts.map +1 -0
- package/dist/demo/index.js +8 -0
- package/dist/demo/index.js.map +1 -0
- package/dist/demo/realistic-system.d.ts +54 -0
- package/dist/demo/realistic-system.d.ts.map +1 -0
- package/dist/demo/realistic-system.js +919 -0
- package/dist/demo/realistic-system.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/types/command-result.d.ts +10 -0
- package/dist/types/command-result.d.ts.map +1 -0
- package/dist/types/command-result.js +11 -0
- package/dist/types/command-result.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/dist/webhooks/dispatcher.d.ts +147 -0
- package/dist/webhooks/dispatcher.d.ts.map +1 -0
- package/dist/webhooks/dispatcher.js +420 -0
- package/dist/webhooks/dispatcher.js.map +1 -0
- package/dist/webhooks/index.d.ts +9 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +9 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/signer.d.ts +119 -0
- package/dist/webhooks/signer.d.ts.map +1 -0
- package/dist/webhooks/signer.js +149 -0
- package/dist/webhooks/signer.js.map +1 -0
- package/dist/webhooks/url-policy.d.ts +73 -0
- package/dist/webhooks/url-policy.d.ts.map +1 -0
- package/dist/webhooks/url-policy.js +250 -0
- package/dist/webhooks/url-policy.js.map +1 -0
- package/dist/worker.d.ts +11 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +31 -0
- package/dist/worker.js.map +1 -0
- package/package.json +84 -3
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { findDependencyPath } from '@lushly-dev/violet-core/engine';
|
|
2
|
+
import { NodeSchema, UpdateNodeInputSchema } from '@lushly-dev/violet-core/types';
|
|
3
|
+
import { nanoid } from 'nanoid';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { ErrorCodes, failure, success } from '../../types/command-result.js';
|
|
6
|
+
import { checkDeprecationPlan } from './deprecation.js';
|
|
7
|
+
/**
|
|
8
|
+
* Input schema for node.update command
|
|
9
|
+
*/
|
|
10
|
+
const InputSchema = z.object({
|
|
11
|
+
id: z.string().min(1),
|
|
12
|
+
updates: UpdateNodeInputSchema,
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Output schema for node.update command
|
|
16
|
+
*/
|
|
17
|
+
const OutputSchema = z.object({
|
|
18
|
+
node: NodeSchema,
|
|
19
|
+
changedFields: z.array(z.string()),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* node.update command
|
|
23
|
+
*
|
|
24
|
+
* Update a node's properties.
|
|
25
|
+
*/
|
|
26
|
+
export const nodeUpdateCommand = {
|
|
27
|
+
name: 'node.update',
|
|
28
|
+
description: 'Update a node in the design system tree',
|
|
29
|
+
category: 'node',
|
|
30
|
+
inputSchema: InputSchema,
|
|
31
|
+
outputSchema: OutputSchema,
|
|
32
|
+
async handler(rawInput, context) {
|
|
33
|
+
const { db, actor } = context;
|
|
34
|
+
// Parse input to apply defaults
|
|
35
|
+
const input = InputSchema.parse(rawInput);
|
|
36
|
+
const node = await db.getNode(input.id);
|
|
37
|
+
if (!node) {
|
|
38
|
+
return failure({
|
|
39
|
+
code: ErrorCodes.NODE_NOT_FOUND,
|
|
40
|
+
message: `Node '${input.id}' not found`,
|
|
41
|
+
suggestion: `Use 'node.list' to see available nodes`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (node.deletedAt) {
|
|
45
|
+
return failure({
|
|
46
|
+
code: ErrorCodes.NODE_NOT_FOUND,
|
|
47
|
+
message: `Node '${input.id}' has been deleted`,
|
|
48
|
+
suggestion: 'Deleted nodes cannot be updated. Contact an admin to restore.',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Validate includes if being updated
|
|
52
|
+
if (input.updates.includes) {
|
|
53
|
+
for (const includeId of input.updates.includes) {
|
|
54
|
+
// Prevent self-reference
|
|
55
|
+
if (includeId === input.id) {
|
|
56
|
+
return failure({
|
|
57
|
+
code: ErrorCodes.CIRCULAR_REFERENCE,
|
|
58
|
+
message: 'Node cannot include itself',
|
|
59
|
+
suggestion: `Remove '${input.id}' from the includes list`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const includeNode = await db.getNode(includeId);
|
|
63
|
+
if (!includeNode) {
|
|
64
|
+
return failure({
|
|
65
|
+
code: ErrorCodes.NODE_NOT_FOUND,
|
|
66
|
+
message: `Include node '${includeId}' not found`,
|
|
67
|
+
suggestion: 'Make sure all include nodes exist',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Check for circular reference. Resolving a node depends on its parent
|
|
71
|
+
// chain, its includes, and its copy sources, so the include would be
|
|
72
|
+
// circular if input.id is reachable from includeId through ANY of those
|
|
73
|
+
// edges (e.g. a parent including its own descendant).
|
|
74
|
+
const cyclePath = await findDependencyPath(db, includeId, input.id);
|
|
75
|
+
if (cyclePath) {
|
|
76
|
+
return failure({
|
|
77
|
+
code: ErrorCodes.CIRCULAR_REFERENCE,
|
|
78
|
+
message: `Including '${includeId}' would create a circular reference`,
|
|
79
|
+
suggestion: `'${includeId}' already depends on '${input.id}' (${cyclePath.join(' -> ')}) through parent, include, or copy relationships`,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// The plan the node will have, so a write that leaves it alone still warns about it
|
|
85
|
+
const plan = await checkDeprecationPlan(db, input.id, {
|
|
86
|
+
sunsetAt: input.updates.sunsetAt === undefined ? node.sunsetAt : input.updates.sunsetAt,
|
|
87
|
+
replacedBy: input.updates.replacedBy === undefined ? node.replacedBy : input.updates.replacedBy,
|
|
88
|
+
});
|
|
89
|
+
if ('error' in plan)
|
|
90
|
+
return failure(plan.error);
|
|
91
|
+
const warnings = [...plan.warnings];
|
|
92
|
+
// Track what changed
|
|
93
|
+
const changedFields = [];
|
|
94
|
+
const oldNode = { ...node };
|
|
95
|
+
// Apply updates
|
|
96
|
+
const now = new Date().toISOString();
|
|
97
|
+
const updates = {
|
|
98
|
+
updatedAt: now,
|
|
99
|
+
};
|
|
100
|
+
if (input.updates.name !== undefined && input.updates.name !== node.name) {
|
|
101
|
+
updates.name = input.updates.name;
|
|
102
|
+
changedFields.push('name');
|
|
103
|
+
}
|
|
104
|
+
if (input.updates.type !== undefined && input.updates.type !== node.type) {
|
|
105
|
+
updates.type = input.updates.type;
|
|
106
|
+
changedFields.push('type');
|
|
107
|
+
}
|
|
108
|
+
if (input.updates.owner !== undefined && input.updates.owner !== node.owner) {
|
|
109
|
+
updates.owner = input.updates.owner;
|
|
110
|
+
changedFields.push('owner');
|
|
111
|
+
}
|
|
112
|
+
if (input.updates.status !== undefined && input.updates.status !== node.status) {
|
|
113
|
+
updates.status = input.updates.status;
|
|
114
|
+
changedFields.push('status');
|
|
115
|
+
}
|
|
116
|
+
if (input.updates.sunsetAt !== undefined &&
|
|
117
|
+
input.updates.sunsetAt !== (node.sunsetAt ?? null)) {
|
|
118
|
+
updates.sunsetAt = input.updates.sunsetAt;
|
|
119
|
+
changedFields.push('sunsetAt');
|
|
120
|
+
}
|
|
121
|
+
if (input.updates.replacedBy !== undefined &&
|
|
122
|
+
input.updates.replacedBy !== (node.replacedBy ?? null)) {
|
|
123
|
+
updates.replacedBy = input.updates.replacedBy;
|
|
124
|
+
changedFields.push('replacedBy');
|
|
125
|
+
}
|
|
126
|
+
if (input.updates.includes !== undefined &&
|
|
127
|
+
JSON.stringify(input.updates.includes) !== JSON.stringify(node.includes)) {
|
|
128
|
+
updates.includes = input.updates.includes;
|
|
129
|
+
changedFields.push('includes');
|
|
130
|
+
}
|
|
131
|
+
if (input.updates.includePolicy !== undefined &&
|
|
132
|
+
input.updates.includePolicy !== node.includePolicy) {
|
|
133
|
+
updates.includePolicy = input.updates.includePolicy;
|
|
134
|
+
changedFields.push('includePolicy');
|
|
135
|
+
}
|
|
136
|
+
if (input.updates.tags !== undefined &&
|
|
137
|
+
JSON.stringify(input.updates.tags) !== JSON.stringify(node.tags)) {
|
|
138
|
+
updates.tags = input.updates.tags;
|
|
139
|
+
changedFields.push('tags');
|
|
140
|
+
}
|
|
141
|
+
if (changedFields.length === 0) {
|
|
142
|
+
return success({ node, changedFields: [] }, {
|
|
143
|
+
reasoning: 'No changes detected',
|
|
144
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// Deprecating a node other nodes name as their replacement leaves them pointing at it
|
|
148
|
+
if (updates.status === 'deprecated') {
|
|
149
|
+
const replaced = (await db.listNodes())
|
|
150
|
+
.filter((other) => other.replacedBy === input.id && !other.deletedAt)
|
|
151
|
+
.map((other) => other.id);
|
|
152
|
+
if (replaced.length > 0) {
|
|
153
|
+
warnings.push({
|
|
154
|
+
code: 'REPLACEMENT_DEPRECATED',
|
|
155
|
+
message: `'${input.id}' is the replacement for ${replaced.join(', ')}, and is now deprecated itself`,
|
|
156
|
+
severity: 'warning',
|
|
157
|
+
details: { replaces: replaced },
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
await db.updateNode(input.id, updates);
|
|
162
|
+
// Get updated node
|
|
163
|
+
const updatedNode = await db.getNode(input.id);
|
|
164
|
+
if (!updatedNode) {
|
|
165
|
+
return failure({
|
|
166
|
+
code: ErrorCodes.INTERNAL_ERROR,
|
|
167
|
+
message: 'Failed to retrieve updated node',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// Log audit event
|
|
171
|
+
await db.addAuditEvent({
|
|
172
|
+
id: nanoid(),
|
|
173
|
+
timestamp: now,
|
|
174
|
+
eventType: 'node_updated',
|
|
175
|
+
actor: actor || 'system',
|
|
176
|
+
targetNode: input.id,
|
|
177
|
+
targetToken: null,
|
|
178
|
+
oldValue: JSON.stringify(oldNode),
|
|
179
|
+
newValue: JSON.stringify(updatedNode),
|
|
180
|
+
metadata: JSON.stringify({ changedFields }),
|
|
181
|
+
});
|
|
182
|
+
return success({ node: updatedNode, changedFields }, {
|
|
183
|
+
reasoning: `Updated ${changedFields.length} field(s): ${changedFields.join(', ')}`,
|
|
184
|
+
sources: [{ type: 'node', id: updatedNode.id, title: updatedNode.name }],
|
|
185
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
examples: [
|
|
189
|
+
{
|
|
190
|
+
description: 'Update node name',
|
|
191
|
+
input: {
|
|
192
|
+
id: 'xbox',
|
|
193
|
+
updates: {
|
|
194
|
+
name: 'Xbox Gaming',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
description: 'Update node status',
|
|
200
|
+
input: {
|
|
201
|
+
id: 'old-product',
|
|
202
|
+
updates: {
|
|
203
|
+
status: 'deprecated',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
description: 'Plan a deprecated node: the day it goes away and what replaces it',
|
|
209
|
+
input: {
|
|
210
|
+
id: 'old-product',
|
|
211
|
+
updates: {
|
|
212
|
+
status: 'deprecated',
|
|
213
|
+
sunsetAt: '2027-03-31',
|
|
214
|
+
replacedBy: 'new-product',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
description: 'Add includes to a node',
|
|
220
|
+
input: {
|
|
221
|
+
id: 'my-app',
|
|
222
|
+
updates: {
|
|
223
|
+
includes: ['accessibility-enhanced', 'motion-reduced'],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/node/update.ts"],"names":[],"mapp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C,KAAK,EAAE;gBACN,EAAE,EAAE,QAAQ;gBACZ,OAAO,EAAE;oBACR,QAAQ,EAAE,CAAC,wBAAwB,EAAE,gBAAgB,CAAC;iBACtD;aACD;SACD;KACD;CACD,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { Database, ResolutionCache } from '@lushly-dev/violet-core';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { CommandResult } from '../types/command-result.js';
|
|
4
|
+
import { type JsonSchema } from './json-schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Command definition with typed input/output schemas
|
|
7
|
+
*
|
|
8
|
+
* TSchema: The Zod schema type
|
|
9
|
+
* TOutput: The output type returned by the handler
|
|
10
|
+
*
|
|
11
|
+
* This uses Zod's built-in type inference to properly handle input vs output types:
|
|
12
|
+
* - z.input<TSchema>: What callers provide (with optional fields)
|
|
13
|
+
* - z.output<TSchema>: What handlers receive (after defaults applied)
|
|
14
|
+
*/
|
|
15
|
+
/** What a deprecated command points to and when it goes away. */
|
|
16
|
+
export interface CommandDeprecation {
|
|
17
|
+
/** The command that replaces it (e.g., 'tokens.compare') */
|
|
18
|
+
replacement: string;
|
|
19
|
+
/** The release that removes it, as a sentence fragment (e.g., '@lushly-dev/violet-afd 0.5.0') */
|
|
20
|
+
removal: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CommandDefinition<TSchema extends z.ZodType, TOutput> {
|
|
23
|
+
/** Unique command name (e.g., 'node.create') */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Human-readable description */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Category for grouping commands */
|
|
28
|
+
category: 'node' | 'token' | 'export' | 'import' | 'analyze' | 'constraint' | 'system' | 'webhook' | 'audit' | 'specimen';
|
|
29
|
+
/**
|
|
30
|
+
* Marks the command as superseded. Surfaces that list or run it (the docs, the
|
|
31
|
+
* HTTP API's `Deprecation` header) read it; the command's own result carries the note.
|
|
32
|
+
*/
|
|
33
|
+
deprecated?: CommandDeprecation;
|
|
34
|
+
/** Zod schema for input validation */
|
|
35
|
+
inputSchema: TSchema;
|
|
36
|
+
/** Zod schema for output type (for documentation) */
|
|
37
|
+
outputSchema: z.ZodType<TOutput, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* The command handler
|
|
40
|
+
* - Accepts z.input<TSchema> (what callers provide - optional fields allowed)
|
|
41
|
+
* - Internally parses to z.output<TSchema> (with defaults applied)
|
|
42
|
+
*/
|
|
43
|
+
handler: (input: z.input<TSchema>, context: CommandContext) => Promise<CommandResult<TOutput>>;
|
|
44
|
+
/** Examples for documentation - uses input type (optional fields allowed) */
|
|
45
|
+
examples?: Array<{
|
|
46
|
+
description: string;
|
|
47
|
+
input: z.input<TSchema>;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Context passed to command handlers
|
|
52
|
+
*/
|
|
53
|
+
export interface CommandContext {
|
|
54
|
+
/** Database instance */
|
|
55
|
+
db: Database;
|
|
56
|
+
/** Current actor (user/system) */
|
|
57
|
+
actor?: string;
|
|
58
|
+
/** Trace ID for logging */
|
|
59
|
+
traceId?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Store reads and resolved chains shared by the resolutions of one read-only
|
|
62
|
+
* command execution. Set by withResolutionCache on a context made for that
|
|
63
|
+
* execution; never set it on a context that outlives it or sees writes.
|
|
64
|
+
*/
|
|
65
|
+
resolutionCache?: ResolutionCache;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Database interface (implemented by storage layer). Native: @lushly-dev/violet-core.
|
|
69
|
+
*/
|
|
70
|
+
export type { Database } from '@lushly-dev/violet-core';
|
|
71
|
+
/**
|
|
72
|
+
* Command Registry
|
|
73
|
+
*
|
|
74
|
+
* Central registry for all Violet commands. Supports:
|
|
75
|
+
* - Auto-discovery of commands
|
|
76
|
+
* - Schema-based validation
|
|
77
|
+
* - Help/documentation generation
|
|
78
|
+
*/
|
|
79
|
+
export declare class CommandRegistry {
|
|
80
|
+
private commands;
|
|
81
|
+
/**
|
|
82
|
+
* Register a command
|
|
83
|
+
*/
|
|
84
|
+
register<TSchema extends z.ZodType, TOutput>(command: CommandDefinition<TSchema, TOutput>): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get a command by name
|
|
87
|
+
*/
|
|
88
|
+
get<TSchema extends z.ZodType, TOutput>(name: string): CommandDefinition<TSchema, TOutput> | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* List all registered commands
|
|
91
|
+
*/
|
|
92
|
+
list(): Array<{
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
category: string;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* List commands by category
|
|
99
|
+
*/
|
|
100
|
+
listByCategory(category: string): Array<{
|
|
101
|
+
name: string;
|
|
102
|
+
description: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Get input schema for a command (for documentation/validation)
|
|
106
|
+
*/
|
|
107
|
+
getInputSchema(name: string): z.ZodType | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Get a command's input schema as JSON Schema (the form MCP, the CLI and
|
|
110
|
+
* the generated docs show), or undefined for an unknown command
|
|
111
|
+
*/
|
|
112
|
+
getInputJsonSchema(name: string): JsonSchema | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Execute a command with validation
|
|
115
|
+
*/
|
|
116
|
+
execute<TInput, TOutput>(name: string, input: TInput, context: CommandContext): Promise<CommandResult<TOutput>>;
|
|
117
|
+
/**
|
|
118
|
+
* Generate documentation for all commands
|
|
119
|
+
*/
|
|
120
|
+
generateDocs(): string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Global command registry instance
|
|
124
|
+
*/
|
|
125
|
+
export declare const registry: CommandRegistry;
|
|
126
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/commands/registry.ts"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ACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,GACrB,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAqDjC;IAED;;OAEG;IACH,YAAY,IAAI,MAAM,CAmBrB;CACD;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,iBAAwB,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { toJsonSchema } from './json-schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Command Registry
|
|
4
|
+
*
|
|
5
|
+
* Central registry for all Violet commands. Supports:
|
|
6
|
+
* - Auto-discovery of commands
|
|
7
|
+
* - Schema-based validation
|
|
8
|
+
* - Help/documentation generation
|
|
9
|
+
*/
|
|
10
|
+
export class CommandRegistry {
|
|
11
|
+
commands = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Register a command
|
|
14
|
+
*/
|
|
15
|
+
register(command) {
|
|
16
|
+
if (this.commands.has(command.name)) {
|
|
17
|
+
throw new Error(`Command '${command.name}' is already registered`);
|
|
18
|
+
}
|
|
19
|
+
this.commands.set(command.name, command);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a command by name
|
|
23
|
+
*/
|
|
24
|
+
get(name) {
|
|
25
|
+
return this.commands.get(name);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* List all registered commands
|
|
29
|
+
*/
|
|
30
|
+
list() {
|
|
31
|
+
return Array.from(this.commands.values()).map((cmd) => ({
|
|
32
|
+
name: cmd.name,
|
|
33
|
+
description: cmd.description,
|
|
34
|
+
category: cmd.category,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* List commands by category
|
|
39
|
+
*/
|
|
40
|
+
listByCategory(category) {
|
|
41
|
+
return Array.from(this.commands.values())
|
|
42
|
+
.filter((cmd) => cmd.category === category)
|
|
43
|
+
.map((cmd) => ({
|
|
44
|
+
name: cmd.name,
|
|
45
|
+
description: cmd.description,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get input schema for a command (for documentation/validation)
|
|
50
|
+
*/
|
|
51
|
+
getInputSchema(name) {
|
|
52
|
+
return this.commands.get(name)?.inputSchema;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get a command's input schema as JSON Schema (the form MCP, the CLI and
|
|
56
|
+
* the generated docs show), or undefined for an unknown command
|
|
57
|
+
*/
|
|
58
|
+
getInputJsonSchema(name) {
|
|
59
|
+
const schema = this.commands.get(name)?.inputSchema;
|
|
60
|
+
return schema ? toJsonSchema(schema) : undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Execute a command with validation
|
|
64
|
+
*/
|
|
65
|
+
async execute(name, input, context) {
|
|
66
|
+
const command = this.commands.get(name);
|
|
67
|
+
if (!command) {
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
error: {
|
|
71
|
+
code: 'COMMAND_NOT_FOUND',
|
|
72
|
+
message: `Command '${name}' not found`,
|
|
73
|
+
suggestion: `Use 'violet --help' to see available commands`,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Validate input
|
|
78
|
+
const validation = command.inputSchema.safeParse(input);
|
|
79
|
+
if (!validation.success) {
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
error: {
|
|
83
|
+
code: 'VALIDATION_ERROR',
|
|
84
|
+
message: `Invalid input: ${validation.error.message}`,
|
|
85
|
+
suggestion: `Check the command schema with 'violet call ${name} --schema'`,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Execute handler
|
|
90
|
+
const startTime = Date.now();
|
|
91
|
+
try {
|
|
92
|
+
const result = await command.handler(validation.data, context);
|
|
93
|
+
return {
|
|
94
|
+
...result,
|
|
95
|
+
metadata: {
|
|
96
|
+
...result.metadata,
|
|
97
|
+
executionTimeMs: Date.now() - startTime,
|
|
98
|
+
traceId: context.traceId,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
error: {
|
|
106
|
+
code: 'INTERNAL_ERROR',
|
|
107
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
108
|
+
retryable: false,
|
|
109
|
+
},
|
|
110
|
+
metadata: {
|
|
111
|
+
executionTimeMs: Date.now() - startTime,
|
|
112
|
+
traceId: context.traceId,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Generate documentation for all commands
|
|
119
|
+
*/
|
|
120
|
+
generateDocs() {
|
|
121
|
+
const categories = new Map();
|
|
122
|
+
for (const cmd of this.commands.values()) {
|
|
123
|
+
const category = categories.get(cmd.category) || [];
|
|
124
|
+
category.push({ name: cmd.name, description: cmd.description });
|
|
125
|
+
categories.set(cmd.category, category);
|
|
126
|
+
}
|
|
127
|
+
let docs = '# Violet Design Commands\n\n';
|
|
128
|
+
for (const [category, commands] of categories) {
|
|
129
|
+
docs += `## ${category}\n\n`;
|
|
130
|
+
for (const cmd of commands) {
|
|
131
|
+
docs += `### \`${cmd.name}\`\n\n${cmd.description}\n\n`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return docs;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Global command registry instance
|
|
139
|
+
*/
|
|
140
|
+
export const registry = new CommandRegistry();
|
|
141
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/commands/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA4FjE;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IACnB,QAAQ,GAAG,IAAI,GAAG,EAAiD,CAAC;IAE5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AAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CommandDefinition } from '../registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* Input schema for specimen.get command
|
|
5
|
+
*/
|
|
6
|
+
declare const InputSchema: z.ZodObject<{
|
|
7
|
+
nodeId: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
/**
|
|
10
|
+
* Output schema for specimen.get command
|
|
11
|
+
*/
|
|
12
|
+
declare const OutputSchema: z.ZodObject<{
|
|
13
|
+
nodeId: z.ZodString;
|
|
14
|
+
rootId: z.ZodString;
|
|
15
|
+
map: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
16
|
+
stored: z.ZodBoolean;
|
|
17
|
+
updatedAt: z.ZodNullable<z.ZodString>;
|
|
18
|
+
updatedBy: z.ZodNullable<z.ZodString>;
|
|
19
|
+
components: z.ZodArray<z.ZodObject<{
|
|
20
|
+
component: z.ZodString;
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
required: z.ZodString;
|
|
23
|
+
drawn: z.ZodBoolean;
|
|
24
|
+
roles: z.ZodArray<z.ZodObject<{
|
|
25
|
+
role: z.ZodString;
|
|
26
|
+
tokenId: z.ZodString;
|
|
27
|
+
source: z.ZodEnum<{
|
|
28
|
+
convention: "convention";
|
|
29
|
+
map: "map";
|
|
30
|
+
}>;
|
|
31
|
+
resolves: z.ZodBoolean;
|
|
32
|
+
valid: z.ZodBoolean;
|
|
33
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* specimen.get command
|
|
40
|
+
*
|
|
41
|
+
* The specimen role map of a node's tree (#118) and, for each component the
|
|
42
|
+
* Specimens view draws, which token draws each role on the node, whether it
|
|
43
|
+
* resolves there, and whether its value passes the role's CSS validator.
|
|
44
|
+
*/
|
|
45
|
+
export declare const specimenGetCommand: CommandDefinition<typeof InputSchema, Output>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/specimen/get.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAkB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE;;GAEG;AACH,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAgBH;;GAEG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;iBAqBhB,CAAC;AAEH,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,OAAO,WAAW,EAAE,MAAM,CA6E5E,CAAC"}
|