@sepveneto/dnde-core 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Node-CnqlVnWy.d.cts → capability-Ce3qGTm3.d.cts} +184 -107
- package/dist/{Node-CnqlVnWy.d.ts → capability-Ce3qGTm3.d.ts} +184 -107
- package/dist/capability.cjs +172 -0
- package/dist/capability.d.cts +4 -0
- package/dist/capability.d.ts +4 -0
- package/dist/capability.js +15 -0
- package/dist/{chunk-PRK4NPVH.js → chunk-62FPS6PZ.js} +2 -0
- package/dist/chunk-W7WBD3NX.js +360 -0
- package/dist/chunk-XXR7SKZ3.js +132 -0
- package/dist/class/Container.d.cts +2 -2
- package/dist/class/Container.d.ts +2 -2
- package/dist/class/Node.d.cts +1 -1
- package/dist/class/Node.d.ts +1 -1
- package/dist/class/Widget.d.cts +1 -1
- package/dist/class/Widget.d.ts +1 -1
- package/dist/class/index.d.cts +2 -2
- package/dist/class/index.d.ts +2 -2
- package/dist/class/index.js +3 -3
- package/dist/dsl.cjs +405 -0
- package/dist/dsl.d.cts +85 -0
- package/dist/dsl.d.ts +85 -0
- package/dist/dsl.js +12 -0
- package/dist/helper/index.cjs +2 -0
- package/dist/helper/index.d.cts +1 -1
- package/dist/helper/index.d.ts +1 -1
- package/dist/helper/index.js +1 -1
- package/dist/helper/schema.cjs +2 -0
- package/dist/helper/schema.d.cts +3 -1
- package/dist/helper/schema.d.ts +3 -1
- package/dist/helper/schema.js +1 -1
- package/dist/helper/widget.d.cts +1 -1
- package/dist/helper/widget.d.ts +1 -1
- package/dist/index.cjs +484 -0
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +24 -4
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/tokens.d.cts +1 -1
- package/dist/tokens.d.ts +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -71,11 +71,19 @@ __export(index_exports, {
|
|
|
71
71
|
EventEmitter: () => EventEmitter,
|
|
72
72
|
Node: () => Node,
|
|
73
73
|
Widget: () => Widget,
|
|
74
|
+
createCapabilityCatalog: () => createCapabilityCatalog,
|
|
74
75
|
createCopy: () => createCopy,
|
|
75
76
|
createDelete: () => createDelete,
|
|
76
77
|
editorContextKey: () => editorContextKey,
|
|
78
|
+
findCustomCapability: () => findCustomCapability,
|
|
79
|
+
findFieldCapability: () => findFieldCapability,
|
|
80
|
+
findWidgetCapability: () => findWidgetCapability,
|
|
77
81
|
isBox: () => isBox,
|
|
82
|
+
isKnownScope: () => isKnownScope,
|
|
83
|
+
isStyleField: () => isStyleField,
|
|
84
|
+
listStaticOptions: () => listStaticOptions,
|
|
78
85
|
schema: () => schema,
|
|
86
|
+
validateEditorDsl: () => validateEditorDsl,
|
|
79
87
|
widget: () => widget,
|
|
80
88
|
widgetType: () => widgetType
|
|
81
89
|
});
|
|
@@ -254,6 +262,472 @@ var Node = class _Node {
|
|
|
254
262
|
}
|
|
255
263
|
};
|
|
256
264
|
|
|
265
|
+
// src/capability.ts
|
|
266
|
+
function optionValues(item) {
|
|
267
|
+
if (!("options" in item) || !Array.isArray(item.options))
|
|
268
|
+
return;
|
|
269
|
+
return item.options.map((option) => option && typeof option === "object" ? option.value : void 0).filter((value) => value !== void 0);
|
|
270
|
+
}
|
|
271
|
+
function fieldFromSchema(item, scope) {
|
|
272
|
+
var _a, _b, _c;
|
|
273
|
+
if (item.type === "custom")
|
|
274
|
+
return;
|
|
275
|
+
let valueType = "unknown";
|
|
276
|
+
let enumValues;
|
|
277
|
+
let minimum;
|
|
278
|
+
let maximum;
|
|
279
|
+
switch (item.type) {
|
|
280
|
+
case "input":
|
|
281
|
+
case "colorPicker":
|
|
282
|
+
case "datetimePicker":
|
|
283
|
+
valueType = "string";
|
|
284
|
+
break;
|
|
285
|
+
case "number":
|
|
286
|
+
case "styleNumber":
|
|
287
|
+
valueType = "number";
|
|
288
|
+
minimum = typeof ((_a = item.attrs) == null ? void 0 : _a.min) === "number" ? item.attrs.min : void 0;
|
|
289
|
+
maximum = typeof ((_b = item.attrs) == null ? void 0 : _b.max) === "number" ? item.attrs.max : void 0;
|
|
290
|
+
break;
|
|
291
|
+
case "switch":
|
|
292
|
+
if ("attrs" in item && item.attrs && ("activeValue" in item.attrs || "inactiveValue" in item.attrs)) {
|
|
293
|
+
valueType = "enum";
|
|
294
|
+
enumValues = [
|
|
295
|
+
item.attrs.activeValue,
|
|
296
|
+
item.attrs.inactiveValue
|
|
297
|
+
].filter((value) => value !== void 0);
|
|
298
|
+
} else {
|
|
299
|
+
valueType = "boolean";
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
case "checkbox":
|
|
303
|
+
valueType = "boolean";
|
|
304
|
+
break;
|
|
305
|
+
case "select":
|
|
306
|
+
case "radio":
|
|
307
|
+
case "radioButton":
|
|
308
|
+
valueType = "enum";
|
|
309
|
+
enumValues = optionValues(item);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
const rules = Array.isArray(item.rules) ? item.rules : item.rules ? [item.rules] : [];
|
|
313
|
+
return {
|
|
314
|
+
source: "prop",
|
|
315
|
+
key: item.key,
|
|
316
|
+
label: item.label,
|
|
317
|
+
valueType,
|
|
318
|
+
scope: (_c = item.scope) != null ? _c : scope,
|
|
319
|
+
required: rules.some((rule) => rule.required === true),
|
|
320
|
+
readOnly: item.readOnly === true,
|
|
321
|
+
enum: enumValues,
|
|
322
|
+
minimum,
|
|
323
|
+
maximum
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function registeredCustomTypes(registration) {
|
|
327
|
+
var _a;
|
|
328
|
+
return ((_a = registration == null ? void 0 : registration.customTypes) != null ? _a : []).map((type) => ({
|
|
329
|
+
type: type.type,
|
|
330
|
+
capabilities: type.capabilities.map((capability) => __spreadValues({}, capability))
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
function schemaCustomTypes(widget2) {
|
|
334
|
+
var _a, _b;
|
|
335
|
+
return ((_b = (_a = widget2.schema) == null ? void 0 : _a.props) != null ? _b : []).filter((item) => item.type === "custom").map((item) => item.name);
|
|
336
|
+
}
|
|
337
|
+
function createCapabilityCatalog(widgets, registry = {}) {
|
|
338
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
339
|
+
const catalog = {
|
|
340
|
+
catalogVersion: "1.0",
|
|
341
|
+
widgets: []
|
|
342
|
+
};
|
|
343
|
+
for (const widget2 of widgets) {
|
|
344
|
+
const registration = registry[widget2._view];
|
|
345
|
+
const declared = registeredCustomTypes(registration);
|
|
346
|
+
const declaredMap = new Map(declared.map((type) => [type.type, type]));
|
|
347
|
+
const customTypes = schemaCustomTypes(widget2).map((type) => {
|
|
348
|
+
var _a2;
|
|
349
|
+
return (_a2 = declaredMap.get(type)) != null ? _a2 : { type, capabilities: [] };
|
|
350
|
+
});
|
|
351
|
+
catalog.widgets.push({
|
|
352
|
+
type: widget2._view,
|
|
353
|
+
name: widget2._name,
|
|
354
|
+
description: (_e = (_d = (_a = widget2.agent) == null ? void 0 : _a.description) != null ? _d : (_c = (_b = widget2.agent) == null ? void 0 : _b.layout) == null ? void 0 : _c.description) != null ? _e : "",
|
|
355
|
+
defaultData: JSON.parse(JSON.stringify((_f = widget2.data) != null ? _f : {})),
|
|
356
|
+
defaultStyle: JSON.parse(JSON.stringify((_g = widget2.style) != null ? _g : {})),
|
|
357
|
+
fields: [
|
|
358
|
+
...((_i = (_h = widget2.schema) == null ? void 0 : _h.props) != null ? _i : []).map((item) => fieldFromSchema(item, "content")).filter((item) => Boolean(item)),
|
|
359
|
+
...((_k = (_j = widget2.schema) == null ? void 0 : _j.style) != null ? _k : []).map((item) => fieldFromSchema(item, "style")).filter((item) => Boolean(item))
|
|
360
|
+
],
|
|
361
|
+
customTypes,
|
|
362
|
+
staticOptions: ((_l = registration == null ? void 0 : registration.staticOptions) != null ? _l : []).map((option) => __spreadProps(__spreadValues({}, option), {
|
|
363
|
+
aliases: [...option.aliases],
|
|
364
|
+
types: [...option.types]
|
|
365
|
+
}))
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return catalog;
|
|
369
|
+
}
|
|
370
|
+
function findWidgetCapability(catalog, type) {
|
|
371
|
+
return catalog.widgets.find((widget2) => widget2.type === type);
|
|
372
|
+
}
|
|
373
|
+
function findFieldCapability(widget2, key) {
|
|
374
|
+
return widget2.fields.find((field) => field.key === key);
|
|
375
|
+
}
|
|
376
|
+
function findCustomCapability(widget2, type, name) {
|
|
377
|
+
var _a;
|
|
378
|
+
return (_a = widget2.customTypes.find((item) => item.type === type)) == null ? void 0 : _a.capabilities.find((capability) => capability.name === name);
|
|
379
|
+
}
|
|
380
|
+
function listStaticOptions(catalog, widgetTypes, types) {
|
|
381
|
+
const selected = (widgetTypes == null ? void 0 : widgetTypes.length) ? catalog.widgets.filter((widget2) => widgetTypes.includes(widget2.type)) : catalog.widgets;
|
|
382
|
+
return selected.flatMap((widget2) => widget2.staticOptions).filter((option) => !(types == null ? void 0 : types.length) || option.types.some((type) => types.includes(type)));
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/dsl.ts
|
|
386
|
+
function asRecord(value) {
|
|
387
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
388
|
+
}
|
|
389
|
+
function isScope(value) {
|
|
390
|
+
return value === "style" || value === "content" || value === "layout";
|
|
391
|
+
}
|
|
392
|
+
function allowsScope(mode, scope) {
|
|
393
|
+
if (mode === "any")
|
|
394
|
+
return true;
|
|
395
|
+
return mode === "style_only" && scope === "style" || mode === "content_only" && scope === "content" || mode === "layout_only" && scope === "layout";
|
|
396
|
+
}
|
|
397
|
+
function matchesValueType(field, value) {
|
|
398
|
+
var _a, _b;
|
|
399
|
+
if (!field)
|
|
400
|
+
return false;
|
|
401
|
+
switch (field.valueType) {
|
|
402
|
+
case "string":
|
|
403
|
+
return typeof value === "string";
|
|
404
|
+
case "number":
|
|
405
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
406
|
+
case "integer":
|
|
407
|
+
return Number.isInteger(value);
|
|
408
|
+
case "boolean":
|
|
409
|
+
return typeof value === "boolean";
|
|
410
|
+
case "enum":
|
|
411
|
+
return (_b = (_a = field.enum) == null ? void 0 : _a.some((item) => Object.is(item, value))) != null ? _b : true;
|
|
412
|
+
case "array":
|
|
413
|
+
return Array.isArray(value);
|
|
414
|
+
case "object":
|
|
415
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
416
|
+
default:
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function validateFieldValue(widget2, key, value, scopeMode, path, issues) {
|
|
421
|
+
const field = findFieldCapability(widget2, key);
|
|
422
|
+
if (!field) {
|
|
423
|
+
issues.push({
|
|
424
|
+
code: "unknown_prop",
|
|
425
|
+
path,
|
|
426
|
+
message: `${widget2.type} \u6CA1\u6709\u767B\u8BB0\u6807\u51C6\u5B57\u6BB5 ${key}`
|
|
427
|
+
});
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
if (field.readOnly) {
|
|
431
|
+
issues.push({
|
|
432
|
+
code: "read_only_prop",
|
|
433
|
+
path,
|
|
434
|
+
message: `${widget2.type}.${key} \u4E3A\u53EA\u8BFB\u5B57\u6BB5`
|
|
435
|
+
});
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
if (!allowsScope(scopeMode, field.scope)) {
|
|
439
|
+
issues.push({
|
|
440
|
+
code: "scope_violation",
|
|
441
|
+
path,
|
|
442
|
+
message: `${widget2.type}.${key} \u5C5E\u4E8E ${field.scope}\uFF0C\u5F53\u524D scope \u4E0D\u5141\u8BB8\u5199\u5165`
|
|
443
|
+
});
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
if (!matchesValueType(field, value)) {
|
|
447
|
+
issues.push({
|
|
448
|
+
code: "invalid_prop_type",
|
|
449
|
+
path,
|
|
450
|
+
message: `${widget2.type}.${key} \u9700\u8981 ${field.valueType} \u7C7B\u578B`
|
|
451
|
+
});
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
if (typeof value === "number" && field.minimum !== void 0 && value < field.minimum) {
|
|
455
|
+
issues.push({
|
|
456
|
+
code: "prop_below_minimum",
|
|
457
|
+
path,
|
|
458
|
+
message: `${widget2.type}.${key} \u4E0D\u80FD\u5C0F\u4E8E ${field.minimum}`
|
|
459
|
+
});
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
if (typeof value === "number" && field.maximum !== void 0 && value > field.maximum) {
|
|
463
|
+
issues.push({
|
|
464
|
+
code: "prop_above_maximum",
|
|
465
|
+
path,
|
|
466
|
+
message: `${widget2.type}.${key} \u4E0D\u80FD\u5927\u4E8E ${field.maximum}`
|
|
467
|
+
});
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
function validateProps(widget2, props, container, scopeMode, path, issues) {
|
|
473
|
+
if (props === void 0)
|
|
474
|
+
return;
|
|
475
|
+
if (!props || typeof props !== "object" || Array.isArray(props)) {
|
|
476
|
+
issues.push({
|
|
477
|
+
code: "invalid_props",
|
|
478
|
+
path,
|
|
479
|
+
message: "props \u5FC5\u987B\u662F\u5BF9\u8C61"
|
|
480
|
+
});
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
484
|
+
const field = findFieldCapability(widget2, key);
|
|
485
|
+
if (field && container === "props" && field.scope === "style") {
|
|
486
|
+
issues.push({
|
|
487
|
+
code: "style_field_in_props",
|
|
488
|
+
path: `${path}.${key}`,
|
|
489
|
+
message: `${widget2.type}.${key} \u662F\u6837\u5F0F\u5B57\u6BB5\uFF0C\u5FC5\u987B\u5199\u5165 style`
|
|
490
|
+
});
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (field && container === "style" && field.scope !== "style") {
|
|
494
|
+
issues.push({
|
|
495
|
+
code: "non_style_field_in_style",
|
|
496
|
+
path: `${path}.${key}`,
|
|
497
|
+
message: `${widget2.type}.${key} \u4E0D\u662F\u6837\u5F0F\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u5199\u5165 style`
|
|
498
|
+
});
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
validateFieldValue(widget2, key, value, scopeMode, `${path}.${key}`, issues);
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
function validateCustom(widget2, custom, scopeMode, path, issues) {
|
|
505
|
+
if (custom === void 0)
|
|
506
|
+
return;
|
|
507
|
+
if (!Array.isArray(custom)) {
|
|
508
|
+
issues.push({
|
|
509
|
+
code: "invalid_custom_operations",
|
|
510
|
+
path,
|
|
511
|
+
message: "custom \u5FC5\u987B\u662F\u80FD\u529B\u64CD\u4F5C\u6570\u7EC4"
|
|
512
|
+
});
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
custom.forEach((rawOperation, index) => {
|
|
516
|
+
const operation = asRecord(rawOperation);
|
|
517
|
+
const type = typeof operation.type === "string" ? operation.type : "";
|
|
518
|
+
const name = typeof operation.capability === "string" ? operation.capability : "";
|
|
519
|
+
const capability = findCustomCapability(widget2, type, name);
|
|
520
|
+
if (!capability) {
|
|
521
|
+
issues.push({
|
|
522
|
+
code: "unsupported_capability",
|
|
523
|
+
path: `${path}[${index}]`,
|
|
524
|
+
message: `${widget2.type} \u672A\u767B\u8BB0 custom type ${type} \u7684\u80FD\u529B ${name}`
|
|
525
|
+
});
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (!allowsScope(scopeMode, capability.writableScope)) {
|
|
529
|
+
issues.push({
|
|
530
|
+
code: "scope_violation",
|
|
531
|
+
path: `${path}[${index}]`,
|
|
532
|
+
message: `\u80FD\u529B ${name} \u5C5E\u4E8E ${capability.writableScope}\uFF0C\u5F53\u524D scope \u4E0D\u5141\u8BB8\u5199\u5165`
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
function placementCount(placement) {
|
|
538
|
+
return ["afterUuid", "beforeUuid", "afterKey", "beforeKey"].filter((key) => typeof placement[key] === "string" && placement[key]).length;
|
|
539
|
+
}
|
|
540
|
+
function validateEditorDsl(input, options) {
|
|
541
|
+
const issues = [];
|
|
542
|
+
const dsl = asRecord(input);
|
|
543
|
+
const operations = Array.isArray(dsl.operations) ? dsl.operations : [];
|
|
544
|
+
const scope = asRecord(dsl.scope);
|
|
545
|
+
const scopeMode = scope.mode;
|
|
546
|
+
if (dsl.dslVersion !== "1.1") {
|
|
547
|
+
issues.push({
|
|
548
|
+
code: "unsupported_dsl_version",
|
|
549
|
+
path: "dslVersion",
|
|
550
|
+
message: "\u4EC5\u652F\u6301 dslVersion 1.1"
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
if (dsl.baseRevision !== options.snapshot.revision) {
|
|
554
|
+
issues.push({
|
|
555
|
+
code: "stale_revision",
|
|
556
|
+
path: "baseRevision",
|
|
557
|
+
message: `DSL \u57FA\u4E8E revision ${String(dsl.baseRevision)}\uFF0C\u5F53\u524D\u4E3A ${options.snapshot.revision}`
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
if (scopeMode !== "style_only" && scopeMode !== "content_only" && scopeMode !== "layout_only" && scopeMode !== "any") {
|
|
561
|
+
issues.push({
|
|
562
|
+
code: "invalid_scope",
|
|
563
|
+
path: "scope.mode",
|
|
564
|
+
message: "scope.mode \u5FC5\u987B\u662F style_only/content_only/layout_only/any"
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const scopeTargets = Array.isArray(scope.targets) ? scope.targets.filter((target) => typeof target === "string") : [];
|
|
568
|
+
if (!operations.length) {
|
|
569
|
+
issues.push({
|
|
570
|
+
code: "empty_operations",
|
|
571
|
+
path: "operations",
|
|
572
|
+
message: "DSL \u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u64CD\u4F5C"
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
const nodeUuids = new Set(options.snapshot.nodes.map((node) => node.uuid));
|
|
576
|
+
const addKeys = /* @__PURE__ */ new Set();
|
|
577
|
+
const normalizedOperations = [];
|
|
578
|
+
operations.forEach((rawOperation, index) => {
|
|
579
|
+
var _a, _b;
|
|
580
|
+
const operation = asRecord(rawOperation);
|
|
581
|
+
const path = `operations[${index}]`;
|
|
582
|
+
const op = operation.op;
|
|
583
|
+
if (op !== "add" && op !== "update" && op !== "delete") {
|
|
584
|
+
issues.push({
|
|
585
|
+
code: "unsupported_operation",
|
|
586
|
+
path: `${path}.op`,
|
|
587
|
+
message: `\u4E0D\u652F\u6301\u7684\u64CD\u4F5C ${String(op)}`
|
|
588
|
+
});
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (op === "add") {
|
|
592
|
+
const key = typeof operation.key === "string" ? operation.key : "";
|
|
593
|
+
const widgetType2 = typeof operation.widget === "string" ? operation.widget : "";
|
|
594
|
+
const widget3 = findWidgetCapability(options.catalog, widgetType2);
|
|
595
|
+
if (!key) {
|
|
596
|
+
issues.push({ code: "missing_key", path: `${path}.key`, message: "add \u5FC5\u987B\u63D0\u4F9B\u6279\u5185\u552F\u4E00 key" });
|
|
597
|
+
} else if (addKeys.has(key)) {
|
|
598
|
+
issues.push({ code: "duplicate_key", path: `${path}.key`, message: `\u6279\u5185 key \u91CD\u590D\uFF1A${key}` });
|
|
599
|
+
}
|
|
600
|
+
if (!widget3) {
|
|
601
|
+
issues.push({
|
|
602
|
+
code: "unknown_widget",
|
|
603
|
+
path: `${path}.widget`,
|
|
604
|
+
message: `\u7EC4\u4EF6\u80FD\u529B\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${widgetType2}`
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
const placement = asRecord(operation.placement);
|
|
608
|
+
if (placementCount(placement) > 1) {
|
|
609
|
+
issues.push({
|
|
610
|
+
code: "ambiguous_placement",
|
|
611
|
+
path: `${path}.placement`,
|
|
612
|
+
message: "placement \u53EA\u80FD\u6307\u5B9A\u4E00\u4E2A\u76F8\u5BF9\u4F4D\u7F6E"
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
for (const keyName of ["afterKey", "beforeKey"]) {
|
|
616
|
+
const reference = typeof placement[keyName] === "string" ? placement[keyName] : "";
|
|
617
|
+
if (reference && !addKeys.has(reference)) {
|
|
618
|
+
issues.push({
|
|
619
|
+
code: "unknown_batch_key",
|
|
620
|
+
path: `${path}.placement.${keyName}`,
|
|
621
|
+
message: `\u6279\u5185 key ${reference} \u5C1A\u672A\u521B\u5EFA`
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
for (const uuidName of ["afterUuid", "beforeUuid"]) {
|
|
626
|
+
const reference = typeof placement[uuidName] === "string" ? placement[uuidName] : "";
|
|
627
|
+
if (reference && !nodeUuids.has(reference)) {
|
|
628
|
+
issues.push({
|
|
629
|
+
code: "unknown_node",
|
|
630
|
+
path: `${path}.placement.${uuidName}`,
|
|
631
|
+
message: `\u8282\u70B9 ${reference} \u4E0D\u5B58\u5728`
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (widget3) {
|
|
636
|
+
const customOperations = operation.custom === void 0 ? [] : operation.custom;
|
|
637
|
+
validateProps(widget3, operation.props, "props", scopeMode, `${path}.props`, issues);
|
|
638
|
+
validateProps(widget3, operation.style, "style", scopeMode, `${path}.style`, issues);
|
|
639
|
+
validateCustom(widget3, customOperations, scopeMode, `${path}.custom`, issues);
|
|
640
|
+
}
|
|
641
|
+
if (key)
|
|
642
|
+
addKeys.add(key);
|
|
643
|
+
normalizedOperations.push({
|
|
644
|
+
op,
|
|
645
|
+
key,
|
|
646
|
+
widget: widgetType2,
|
|
647
|
+
placement,
|
|
648
|
+
props: asRecord(operation.props),
|
|
649
|
+
style: asRecord(operation.style),
|
|
650
|
+
custom: Array.isArray(operation.custom) ? operation.custom : []
|
|
651
|
+
});
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const uuid = typeof operation.uuid === "string" ? operation.uuid : "";
|
|
655
|
+
const node = options.snapshot.nodes.find((item) => item.uuid === uuid);
|
|
656
|
+
if (!node) {
|
|
657
|
+
issues.push({
|
|
658
|
+
code: "unknown_node",
|
|
659
|
+
path: `${path}.uuid`,
|
|
660
|
+
message: `\u8282\u70B9 ${uuid || "(\u7A7A)"} \u4E0D\u5B58\u5728`
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
if (scopeTargets.length && !scopeTargets.includes(uuid)) {
|
|
664
|
+
issues.push({
|
|
665
|
+
code: "target_outside_scope",
|
|
666
|
+
path: `${path}.uuid`,
|
|
667
|
+
message: `\u8282\u70B9 ${uuid} \u4E0D\u5728 scope.targets \u5185`
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
if (op === "delete") {
|
|
671
|
+
if (!operation.confirmToken) {
|
|
672
|
+
issues.push({
|
|
673
|
+
code: "delete_confirmation_required",
|
|
674
|
+
path: `${path}.confirmToken`,
|
|
675
|
+
message: "\u5220\u9664\u64CD\u4F5C\u5FC5\u987B\u643A\u5E26\u4E00\u6B21\u6027\u786E\u8BA4\u4EE4\u724C"
|
|
676
|
+
});
|
|
677
|
+
} else if (!((_a = options.snapshot.confirmTokens) == null ? void 0 : _a.includes(String(operation.confirmToken)))) {
|
|
678
|
+
issues.push({
|
|
679
|
+
code: "invalid_confirm_token",
|
|
680
|
+
path: `${path}.confirmToken`,
|
|
681
|
+
message: "\u5220\u9664\u786E\u8BA4\u4EE4\u724C\u65E0\u6548\u6216\u5DF2\u8FC7\u671F"
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
normalizedOperations.push({ op, uuid, confirmToken: String((_b = operation.confirmToken) != null ? _b : "") });
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
const widget2 = node ? findWidgetCapability(options.catalog, node.type) : void 0;
|
|
688
|
+
if (node && widget2) {
|
|
689
|
+
validateProps(widget2, operation.props, "props", scopeMode, `${path}.props`, issues);
|
|
690
|
+
validateProps(widget2, operation.style, "style", scopeMode, `${path}.style`, issues);
|
|
691
|
+
validateCustom(widget2, operation.custom, scopeMode, `${path}.custom`, issues);
|
|
692
|
+
}
|
|
693
|
+
normalizedOperations.push({
|
|
694
|
+
op,
|
|
695
|
+
uuid,
|
|
696
|
+
props: asRecord(operation.props),
|
|
697
|
+
style: asRecord(operation.style),
|
|
698
|
+
custom: Array.isArray(operation.custom) ? operation.custom : []
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
if (scopeTargets.some((target) => !nodeUuids.has(target))) {
|
|
702
|
+
issues.push({
|
|
703
|
+
code: "unknown_scope_target",
|
|
704
|
+
path: "scope.targets",
|
|
705
|
+
message: "scope.targets \u5305\u542B\u4E0D\u5B58\u5728\u7684\u8282\u70B9"
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
return __spreadValues({
|
|
709
|
+
ok: issues.length === 0,
|
|
710
|
+
issues
|
|
711
|
+
}, issues.length ? {} : {
|
|
712
|
+
normalized: {
|
|
713
|
+
dslVersion: "1.1",
|
|
714
|
+
baseRevision: options.snapshot.revision,
|
|
715
|
+
scope: {
|
|
716
|
+
mode: scopeMode,
|
|
717
|
+
targets: scopeTargets
|
|
718
|
+
},
|
|
719
|
+
operations: normalizedOperations
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function isStyleField(widget2, key) {
|
|
724
|
+
var _a;
|
|
725
|
+
return ((_a = findFieldCapability(widget2, key)) == null ? void 0 : _a.scope) === "style";
|
|
726
|
+
}
|
|
727
|
+
function isKnownScope(value) {
|
|
728
|
+
return isScope(value);
|
|
729
|
+
}
|
|
730
|
+
|
|
257
731
|
// src/helper/EventEmitter.ts
|
|
258
732
|
var EventEmitter = class {
|
|
259
733
|
constructor(subscribeFn) {
|
|
@@ -299,6 +773,8 @@ var schema = {
|
|
|
299
773
|
_role: config._role,
|
|
300
774
|
label: config.label,
|
|
301
775
|
key: config.key,
|
|
776
|
+
scope: config.scope,
|
|
777
|
+
readOnly: config.readOnly,
|
|
302
778
|
type,
|
|
303
779
|
formItem: config.formItem,
|
|
304
780
|
rules: normalizeRules(config),
|
|
@@ -469,11 +945,19 @@ function isBox(schema2) {
|
|
|
469
945
|
EventEmitter,
|
|
470
946
|
Node,
|
|
471
947
|
Widget,
|
|
948
|
+
createCapabilityCatalog,
|
|
472
949
|
createCopy,
|
|
473
950
|
createDelete,
|
|
474
951
|
editorContextKey,
|
|
952
|
+
findCustomCapability,
|
|
953
|
+
findFieldCapability,
|
|
954
|
+
findWidgetCapability,
|
|
475
955
|
isBox,
|
|
956
|
+
isKnownScope,
|
|
957
|
+
isStyleField,
|
|
958
|
+
listStaticOptions,
|
|
476
959
|
schema,
|
|
960
|
+
validateEditorDsl,
|
|
477
961
|
widget,
|
|
478
962
|
widgetType
|
|
479
963
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { Container } from './class/Container.cjs';
|
|
2
|
-
export { B as Base, D as DisabledItemFn, E as EditorConfig,
|
|
2
|
+
export { B as Base, j as CapabilityCatalog, C as CapabilityValueType, D as DisabledItemFn, E as EditorConfig, J as EditorData, A as EditorRoute, y as EditorSchema, H as EditorSettings, z as EditorWidget, G as EditorWidgets, F as FieldScope, w as ISchema, I as IWidget, N as Node, O as Option, a as RadioButtonOption, R as RadioOption, v as SchemaBox, b as SchemaItem, S as SchemaItemCustom, u as SchemaOther, f as StaticOption, W as Widget, t as WidgetAgent, i as WidgetCapability, s as WidgetCapabilityAdapter, r as WidgetCapabilityExecutionContext, g as WidgetCapabilityRegistration, h as WidgetCapabilityRegistry, d as WidgetCustomCapability, e as WidgetCustomTypeCapability, c as WidgetFieldCapability, q as WidgetLayoutItem, p as WidgetPos, k as createCapabilityCatalog, n as findCustomCapability, m as findFieldCapability, l as findWidgetCapability, x as isBox, o as listStaticOptions } from './capability-Ce3qGTm3.cjs';
|
|
3
|
+
export { DslAddOperation, DslCustomOperation, DslDeleteOperation, DslDocumentSnapshot, DslIssue, DslNodeSummary, DslOperation, DslPlacement, DslScope, DslScopeMode, DslUpdateOperation, DslValidationOptions, DslValidationResult, EditorDsl, isKnownScope, isStyleField, validateEditorDsl } from './dsl.cjs';
|
|
3
4
|
export { EventEmitter } from './helper/EventEmitter.cjs';
|
|
4
5
|
export { schema } from './helper/schema.cjs';
|
|
5
6
|
export { widget, widgetType } from './helper/widget.cjs';
|
|
6
7
|
export { createCopy, createDelete } from './internal.cjs';
|
|
7
8
|
export { EditorContext, editorContextKey } from './tokens.cjs';
|
|
8
|
-
import 'vue';
|
|
9
9
|
import 'element-plus';
|
|
10
|
+
import 'vue';
|
|
10
11
|
import 'async-validator';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { Container } from './class/Container.js';
|
|
2
|
-
export { B as Base, D as DisabledItemFn, E as EditorConfig,
|
|
2
|
+
export { B as Base, j as CapabilityCatalog, C as CapabilityValueType, D as DisabledItemFn, E as EditorConfig, J as EditorData, A as EditorRoute, y as EditorSchema, H as EditorSettings, z as EditorWidget, G as EditorWidgets, F as FieldScope, w as ISchema, I as IWidget, N as Node, O as Option, a as RadioButtonOption, R as RadioOption, v as SchemaBox, b as SchemaItem, S as SchemaItemCustom, u as SchemaOther, f as StaticOption, W as Widget, t as WidgetAgent, i as WidgetCapability, s as WidgetCapabilityAdapter, r as WidgetCapabilityExecutionContext, g as WidgetCapabilityRegistration, h as WidgetCapabilityRegistry, d as WidgetCustomCapability, e as WidgetCustomTypeCapability, c as WidgetFieldCapability, q as WidgetLayoutItem, p as WidgetPos, k as createCapabilityCatalog, n as findCustomCapability, m as findFieldCapability, l as findWidgetCapability, x as isBox, o as listStaticOptions } from './capability-Ce3qGTm3.js';
|
|
3
|
+
export { DslAddOperation, DslCustomOperation, DslDeleteOperation, DslDocumentSnapshot, DslIssue, DslNodeSummary, DslOperation, DslPlacement, DslScope, DslScopeMode, DslUpdateOperation, DslValidationOptions, DslValidationResult, EditorDsl, isKnownScope, isStyleField, validateEditorDsl } from './dsl.js';
|
|
3
4
|
export { EventEmitter } from './helper/EventEmitter.js';
|
|
4
5
|
export { schema } from './helper/schema.js';
|
|
5
6
|
export { widget, widgetType } from './helper/widget.js';
|
|
6
7
|
export { createCopy, createDelete } from './internal.js';
|
|
7
8
|
export { EditorContext, editorContextKey } from './tokens.js';
|
|
8
|
-
import 'vue';
|
|
9
9
|
import 'element-plus';
|
|
10
|
+
import 'vue';
|
|
10
11
|
import 'async-validator';
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import "./chunk-IQ5LOS7W.js";
|
|
2
|
+
import {
|
|
3
|
+
Node
|
|
4
|
+
} from "./chunk-RLMXVDJK.js";
|
|
2
5
|
import "./chunk-4QVESRP3.js";
|
|
3
6
|
import {
|
|
4
7
|
EventEmitter
|
|
5
8
|
} from "./chunk-W776G2UQ.js";
|
|
6
9
|
import {
|
|
7
10
|
schema
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-62FPS6PZ.js";
|
|
9
12
|
import {
|
|
10
13
|
widget,
|
|
11
14
|
widgetType
|
|
12
15
|
} from "./chunk-3HT56K6Y.js";
|
|
16
|
+
import {
|
|
17
|
+
isKnownScope,
|
|
18
|
+
isStyleField,
|
|
19
|
+
validateEditorDsl
|
|
20
|
+
} from "./chunk-W7WBD3NX.js";
|
|
21
|
+
import {
|
|
22
|
+
createCapabilityCatalog,
|
|
23
|
+
findCustomCapability,
|
|
24
|
+
findFieldCapability,
|
|
25
|
+
findWidgetCapability,
|
|
26
|
+
listStaticOptions
|
|
27
|
+
} from "./chunk-XXR7SKZ3.js";
|
|
13
28
|
import {
|
|
14
29
|
createCopy,
|
|
15
30
|
createDelete
|
|
@@ -24,9 +39,6 @@ import "./chunk-XJ2IJHKH.js";
|
|
|
24
39
|
import {
|
|
25
40
|
Container
|
|
26
41
|
} from "./chunk-VLEUQG7E.js";
|
|
27
|
-
import {
|
|
28
|
-
Node
|
|
29
|
-
} from "./chunk-RLMXVDJK.js";
|
|
30
42
|
import {
|
|
31
43
|
Widget
|
|
32
44
|
} from "./chunk-CI6CS5LG.js";
|
|
@@ -36,11 +48,19 @@ export {
|
|
|
36
48
|
EventEmitter,
|
|
37
49
|
Node,
|
|
38
50
|
Widget,
|
|
51
|
+
createCapabilityCatalog,
|
|
39
52
|
createCopy,
|
|
40
53
|
createDelete,
|
|
41
54
|
editorContextKey,
|
|
55
|
+
findCustomCapability,
|
|
56
|
+
findFieldCapability,
|
|
57
|
+
findWidgetCapability,
|
|
42
58
|
isBox,
|
|
59
|
+
isKnownScope,
|
|
60
|
+
isStyleField,
|
|
61
|
+
listStaticOptions,
|
|
43
62
|
schema,
|
|
63
|
+
validateEditorDsl,
|
|
44
64
|
widget,
|
|
45
65
|
widgetType
|
|
46
66
|
};
|
package/dist/internal.d.cts
CHANGED
package/dist/internal.d.ts
CHANGED
package/dist/tokens.d.cts
CHANGED
package/dist/tokens.d.ts
CHANGED
package/dist/types.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'element-plus';
|
|
2
2
|
import 'vue';
|
|
3
|
-
export { B as Base, D as DisabledItemFn, E as EditorConfig,
|
|
3
|
+
export { B as Base, D as DisabledItemFn, E as EditorConfig, J as EditorData, A as EditorRoute, y as EditorSchema, H as EditorSettings, z as EditorWidget, G as EditorWidgets, w as ISchema, I as IWidget, v as SchemaBox, u as SchemaOther, t as WidgetAgent, s as WidgetCapabilityAdapter, r as WidgetCapabilityExecutionContext, q as WidgetLayoutItem, p as WidgetPos, x as isBox } from './capability-Ce3qGTm3.cjs';
|
|
4
4
|
import 'async-validator';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'element-plus';
|
|
2
2
|
import 'vue';
|
|
3
|
-
export { B as Base, D as DisabledItemFn, E as EditorConfig,
|
|
3
|
+
export { B as Base, D as DisabledItemFn, E as EditorConfig, J as EditorData, A as EditorRoute, y as EditorSchema, H as EditorSettings, z as EditorWidget, G as EditorWidgets, w as ISchema, I as IWidget, v as SchemaBox, u as SchemaOther, t as WidgetAgent, s as WidgetCapabilityAdapter, r as WidgetCapabilityExecutionContext, q as WidgetLayoutItem, p as WidgetPos, x as isBox } from './capability-Ce3qGTm3.js';
|
|
4
4
|
import 'async-validator';
|