@fayz-ai/core 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-BEGXYHS4.js +566 -0
- package/dist/chunk-BEGXYHS4.js.map +1 -0
- package/dist/chunk-ED6NBH6U.js +348 -0
- package/dist/chunk-ED6NBH6U.js.map +1 -0
- package/dist/chunk-EWKX4VUM.js +429 -0
- package/dist/chunk-EWKX4VUM.js.map +1 -0
- package/dist/chunk-LARZWDHA.js +319 -0
- package/dist/chunk-LARZWDHA.js.map +1 -0
- package/dist/{chunk-732GZEUI.js → chunk-RRYFXUQX.js} +22 -367
- package/dist/chunk-RRYFXUQX.js.map +1 -0
- package/dist/{chunk-M27JPX3K.js → chunk-TDI6F6PT.js} +363 -24
- package/dist/chunk-TDI6F6PT.js.map +1 -0
- package/dist/{chunk-JO7Z2AOE.js → chunk-UVKH6RDX.js} +211 -335
- package/dist/chunk-UVKH6RDX.js.map +1 -0
- package/dist/chunk-V53GR4UT.js +289 -0
- package/dist/chunk-V53GR4UT.js.map +1 -0
- package/dist/connector-runtime/index.d.ts +15 -0
- package/dist/connector-runtime/index.d.ts.map +1 -0
- package/dist/connector-runtime/index.js +3 -0
- package/dist/connector-runtime/index.js.map +1 -0
- package/dist/data/archetype.d.ts.map +1 -1
- package/dist/data/bulk.d.ts +24 -0
- package/dist/data/bulk.d.ts.map +1 -1
- package/dist/data/cached.d.ts.map +1 -1
- package/dist/data/custom-fields.d.ts +5 -0
- package/dist/data/custom-fields.d.ts.map +1 -0
- package/dist/data/index.d.ts +2 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +3 -1
- package/dist/data/mock.d.ts.map +1 -1
- package/dist/data/platform-api.d.ts.map +1 -1
- package/dist/data/resolve.d.ts.map +1 -1
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/data/types.d.ts +8 -0
- package/dist/data/types.d.ts.map +1 -1
- package/dist/events/log.d.ts.map +1 -1
- package/dist/fields/store.d.ts +45 -0
- package/dist/fields/store.d.ts.map +1 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/shell-translations.en.d.ts.map +1 -1
- package/dist/i18n/shell-translations.pt-br.d.ts.map +1 -1
- package/dist/index.d.ts +22 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -29
- package/dist/index.js.map +1 -1
- package/dist/integrations/events.d.ts +7 -0
- package/dist/integrations/events.d.ts.map +1 -0
- package/dist/integrations/index.d.ts +663 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +3 -1
- package/dist/integrations/permissions.d.ts +132 -0
- package/dist/integrations/permissions.d.ts.map +1 -0
- package/dist/integrations/request.d.ts +170 -0
- package/dist/integrations/request.d.ts.map +1 -0
- package/dist/integrations/runtime-token.d.ts +33 -0
- package/dist/integrations/runtime-token.d.ts.map +1 -0
- package/dist/integrations/runtime.d.ts +398 -0
- package/dist/integrations/runtime.d.ts.map +1 -0
- package/dist/integrations/settings.d.ts +102 -0
- package/dist/integrations/settings.d.ts.map +1 -0
- package/dist/integrations/store.d.ts +145 -0
- package/dist/integrations/store.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -1
- package/dist/plugin/runtime.d.ts.map +1 -1
- package/dist/registry/entities.d.ts +41 -15
- package/dist/registry/entities.d.ts.map +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/{shell-translations.pt-br-2GWRQRRP.js → shell-translations.pt-br-BM5ZFSKJ.js} +72 -3
- package/dist/shell-translations.pt-br-BM5ZFSKJ.js.map +1 -0
- package/dist/telemetry/errors.d.ts +87 -0
- package/dist/telemetry/errors.d.ts.map +1 -0
- package/dist/testing/index.js +4 -1
- package/dist/testing.d.ts +2 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/types/analytics.d.ts +17 -0
- package/dist/types/analytics.d.ts.map +1 -1
- package/dist/types/crud.d.ts +15 -1
- package/dist/types/crud.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +83 -0
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +7 -3
- package/dist/chunk-6RBW2Y5K.js +0 -42
- package/dist/chunk-6RBW2Y5K.js.map +0 -1
- package/dist/chunk-732GZEUI.js.map +0 -1
- package/dist/chunk-CPMHCTX3.js +0 -77
- package/dist/chunk-CPMHCTX3.js.map +0 -1
- package/dist/chunk-JO7Z2AOE.js.map +0 -1
- package/dist/chunk-M27JPX3K.js.map +0 -1
- package/dist/integrations.d.ts +0 -159
- package/dist/integrations.d.ts.map +0 -1
- package/dist/shell-translations.pt-br-2GWRQRRP.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Registry } from './chunk-EWKX4VUM.js';
|
|
1
2
|
import { getAllEntities } from './chunk-CU64QI4A.js';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
|
|
@@ -153,59 +154,6 @@ function defaultPropsFromSettings(settings = []) {
|
|
|
153
154
|
return props;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
// src/registry/registry-class.ts
|
|
157
|
-
var Registry = class {
|
|
158
|
-
constructor(kind) {
|
|
159
|
-
this.kind = kind;
|
|
160
|
-
this.entries = /* @__PURE__ */ new Map();
|
|
161
|
-
}
|
|
162
|
-
register(id, value, meta = {}) {
|
|
163
|
-
const title = meta.title ?? meta.label;
|
|
164
|
-
this.entries.set(id, { id, value, meta: title === void 0 ? meta : { ...meta, title, label: title } });
|
|
165
|
-
}
|
|
166
|
-
get(id) {
|
|
167
|
-
return this.entries.get(id)?.value;
|
|
168
|
-
}
|
|
169
|
-
getEntry(id) {
|
|
170
|
-
return this.entries.get(id);
|
|
171
|
-
}
|
|
172
|
-
has(id) {
|
|
173
|
-
return this.entries.has(id);
|
|
174
|
-
}
|
|
175
|
-
list() {
|
|
176
|
-
return Array.from(this.entries.values());
|
|
177
|
-
}
|
|
178
|
-
ids() {
|
|
179
|
-
return Array.from(this.entries.keys());
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Every entry reduced to the uniform meta envelope, sorted by id.
|
|
183
|
-
*
|
|
184
|
-
* Sorted for the same reason as `describeBlocks`: this feeds prompts,
|
|
185
|
-
* documents and generated catalogs, and registration order is an
|
|
186
|
-
* implementation detail that would make every diff noisy.
|
|
187
|
-
*/
|
|
188
|
-
describe() {
|
|
189
|
-
return this.list().map(({ id, meta }) => ({
|
|
190
|
-
id,
|
|
191
|
-
kind: this.kind,
|
|
192
|
-
title: meta.title ?? meta.label,
|
|
193
|
-
description: meta.description,
|
|
194
|
-
schema: meta.propsSchema,
|
|
195
|
-
stability: meta.stability ?? "stable",
|
|
196
|
-
since: meta.since,
|
|
197
|
-
source: meta.source,
|
|
198
|
-
pluginId: meta.pluginId
|
|
199
|
-
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
200
|
-
}
|
|
201
|
-
clear() {
|
|
202
|
-
this.entries.clear();
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
function isCustomId(id) {
|
|
206
|
-
return id.startsWith("custom:");
|
|
207
|
-
}
|
|
208
|
-
|
|
209
157
|
// src/registry/handles.ts
|
|
210
158
|
var HANDLE_NAME_RE = /^[a-z0-9][a-z0-9-]*(\.[A-Za-z0-9_][A-Za-z0-9_-]*)+$/;
|
|
211
159
|
var handleRegistry = new Registry("handle");
|
|
@@ -314,314 +262,6 @@ function dataNeedKey(loader, params = {}) {
|
|
|
314
262
|
return `${loader} ${canonicalJson(params)}`;
|
|
315
263
|
}
|
|
316
264
|
|
|
317
|
-
// src/registry/entities.ts
|
|
318
|
-
var ENTITY_FIELD_TYPES = [
|
|
319
|
-
"text",
|
|
320
|
-
"richtext",
|
|
321
|
-
"number",
|
|
322
|
-
"boolean",
|
|
323
|
-
"json",
|
|
324
|
-
"image",
|
|
325
|
-
"url",
|
|
326
|
-
"ref",
|
|
327
|
-
"point",
|
|
328
|
-
"datetime"
|
|
329
|
-
];
|
|
330
|
-
var GENERIC_ENTITY_TABLE = "plg_entity_records";
|
|
331
|
-
var ENTITY_KEY_RE = /^[a-z][a-z0-9_]*$/;
|
|
332
|
-
var FIELD_NAME_RE = /^[a-z][a-z0-9_]*$/;
|
|
333
|
-
var RESERVED_ENTITY_FIELDS = ["id", "slug", "entity", "tenant_id", "created_at", "updated_at"];
|
|
334
|
-
var entityDeclarationRegistry = new Registry("entity");
|
|
335
|
-
function fail(message, valid) {
|
|
336
|
-
throw new Error(valid?.length ? `${message} Valid: ${valid.join(", ")}.` : message);
|
|
337
|
-
}
|
|
338
|
-
function normalizeDeclaration(key, input) {
|
|
339
|
-
if (!ENTITY_KEY_RE.test(key)) {
|
|
340
|
-
fail(`defineEntity: "${key}" is not a valid entity key \u2014 keys are snake_case (${ENTITY_KEY_RE}).`);
|
|
341
|
-
}
|
|
342
|
-
const fieldNames = Object.keys(input.fields ?? {});
|
|
343
|
-
if (fieldNames.length === 0) {
|
|
344
|
-
fail(`defineEntity("${key}"): an entity declares at least one field.`);
|
|
345
|
-
}
|
|
346
|
-
for (const [name, field] of Object.entries(input.fields)) {
|
|
347
|
-
if (!FIELD_NAME_RE.test(name)) {
|
|
348
|
-
fail(`defineEntity("${key}"): "${name}" is not a valid field name \u2014 fields are snake_case (${FIELD_NAME_RE}).`);
|
|
349
|
-
}
|
|
350
|
-
if (RESERVED_ENTITY_FIELDS.includes(name)) {
|
|
351
|
-
fail(`defineEntity("${key}"): "${name}" is a structural record column and cannot be a declared field.`, RESERVED_ENTITY_FIELDS);
|
|
352
|
-
}
|
|
353
|
-
if (!ENTITY_FIELD_TYPES.includes(field?.type)) {
|
|
354
|
-
fail(`defineEntity("${key}"): field "${name}" has unknown type "${String(field?.type)}".`, ENTITY_FIELD_TYPES);
|
|
355
|
-
}
|
|
356
|
-
if (field.type === "ref" && !field.entity) {
|
|
357
|
-
fail(`defineEntity("${key}"): ref field "${name}" must name the entity it points to ({ type: 'ref', entity: '<key>' }).`);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const knows = (name, where) => {
|
|
361
|
-
if (!fieldNames.includes(name)) {
|
|
362
|
-
fail(`defineEntity("${key}"): ${where} references undeclared field "${name}".`, fieldNames);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
for (const index of input.indexes ?? []) {
|
|
366
|
-
for (const name of index) knows(name, "an index");
|
|
367
|
-
}
|
|
368
|
-
if (input.titleField) knows(input.titleField, "titleField");
|
|
369
|
-
for (const name of input.displayFields ?? []) knows(name, "displayFields");
|
|
370
|
-
const titleField = input.titleField ?? fieldNames.find((name) => input.fields[name].type === "text");
|
|
371
|
-
const displayFields = input.displayFields ?? fieldNames.filter((name) => input.fields[name].type !== "json");
|
|
372
|
-
return {
|
|
373
|
-
key,
|
|
374
|
-
title: input.title ?? key,
|
|
375
|
-
description: input.description,
|
|
376
|
-
fields: input.fields,
|
|
377
|
-
scope: input.scope ?? "tenant",
|
|
378
|
-
access: { read: input.access?.read ?? "staff", write: "staff" },
|
|
379
|
-
indexes: input.indexes ?? [],
|
|
380
|
-
titleField,
|
|
381
|
-
displayFields,
|
|
382
|
-
storage: { mode: "generic", table: GENERIC_ENTITY_TABLE }
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function defineEntity(key, input, meta = {}) {
|
|
386
|
-
const declaration = normalizeDeclaration(key, input);
|
|
387
|
-
entityDeclarationRegistry.register(key, declaration, {
|
|
388
|
-
title: declaration.title,
|
|
389
|
-
description: declaration.description,
|
|
390
|
-
propsSchema: entityRecordSchema(declaration),
|
|
391
|
-
source: meta.source ?? "app",
|
|
392
|
-
pluginId: meta.pluginId,
|
|
393
|
-
since: meta.since
|
|
394
|
-
});
|
|
395
|
-
return declaration;
|
|
396
|
-
}
|
|
397
|
-
function formatValidEntities() {
|
|
398
|
-
const ids = entityDeclarationRegistry.ids().sort();
|
|
399
|
-
return ids.length ? `Declared entities: ${ids.join(", ")}` : "No entities are declared \u2014 call defineEntity(key, declaration) first.";
|
|
400
|
-
}
|
|
401
|
-
function resolveEntityDeclaration(key) {
|
|
402
|
-
const declaration = entityDeclarationRegistry.get(key);
|
|
403
|
-
if (!declaration) throw new Error(`Unknown entity "${key}". ${formatValidEntities()}`);
|
|
404
|
-
return declaration;
|
|
405
|
-
}
|
|
406
|
-
function hasEntityDeclaration(key) {
|
|
407
|
-
return entityDeclarationRegistry.has(key);
|
|
408
|
-
}
|
|
409
|
-
function listEntityDeclarations() {
|
|
410
|
-
return entityDeclarationRegistry.ids().sort();
|
|
411
|
-
}
|
|
412
|
-
function clearEntityDeclarations() {
|
|
413
|
-
entityDeclarationRegistry.clear();
|
|
414
|
-
}
|
|
415
|
-
var FIELD_FORMAT = {
|
|
416
|
-
image: "uri",
|
|
417
|
-
url: "uri",
|
|
418
|
-
datetime: "date-time"
|
|
419
|
-
};
|
|
420
|
-
function fieldToJsonSchema(name, field) {
|
|
421
|
-
const node = {
|
|
422
|
-
title: field.label ?? name,
|
|
423
|
-
// The control survives the compile, exactly as in block settings: a `ref`
|
|
424
|
-
// is a string in JSON Schema terms, but an editor rendering it as a text
|
|
425
|
-
// input (instead of a record picker) is a bug.
|
|
426
|
-
"x-fayz-control": field.type
|
|
427
|
-
};
|
|
428
|
-
if (field.help) node.description = field.help;
|
|
429
|
-
if (field.default !== void 0) node.default = field.default;
|
|
430
|
-
const format = FIELD_FORMAT[field.type];
|
|
431
|
-
if (format) node.format = format;
|
|
432
|
-
switch (field.type) {
|
|
433
|
-
case "number":
|
|
434
|
-
node.type = "number";
|
|
435
|
-
return node;
|
|
436
|
-
case "boolean":
|
|
437
|
-
node.type = "boolean";
|
|
438
|
-
return node;
|
|
439
|
-
case "json":
|
|
440
|
-
return node;
|
|
441
|
-
case "point":
|
|
442
|
-
node.type = "object";
|
|
443
|
-
node.properties = { lat: { type: "number" }, lng: { type: "number" } };
|
|
444
|
-
node.required = ["lat", "lng"];
|
|
445
|
-
node.additionalProperties = false;
|
|
446
|
-
return node;
|
|
447
|
-
case "ref":
|
|
448
|
-
node.type = "string";
|
|
449
|
-
node["x-fayz-ref-entity"] = field.entity;
|
|
450
|
-
return node;
|
|
451
|
-
default:
|
|
452
|
-
node.type = "string";
|
|
453
|
-
return node;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
function entityRecordSchema(declaration) {
|
|
457
|
-
const properties = {};
|
|
458
|
-
const required = [];
|
|
459
|
-
for (const [name, field] of Object.entries(declaration.fields)) {
|
|
460
|
-
properties[name] = fieldToJsonSchema(name, field);
|
|
461
|
-
if (field.required) required.push(name);
|
|
462
|
-
}
|
|
463
|
-
const schema = {
|
|
464
|
-
type: "object",
|
|
465
|
-
title: declaration.title,
|
|
466
|
-
properties,
|
|
467
|
-
additionalProperties: false
|
|
468
|
-
};
|
|
469
|
-
if (declaration.description) schema.description = declaration.description;
|
|
470
|
-
if (required.length > 0) schema.required = required;
|
|
471
|
-
return schema;
|
|
472
|
-
}
|
|
473
|
-
function typeOf(value) {
|
|
474
|
-
return Array.isArray(value) ? "array" : value === null ? "null" : typeof value;
|
|
475
|
-
}
|
|
476
|
-
function validateEntityRecordData(declaration, data) {
|
|
477
|
-
const issues = [];
|
|
478
|
-
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
479
|
-
return [{ path: "", code: "invalid-value", message: `record data is an object, got ${typeOf(data)}` }];
|
|
480
|
-
}
|
|
481
|
-
const record = data;
|
|
482
|
-
const fieldNames = Object.keys(declaration.fields);
|
|
483
|
-
for (const [name, value] of Object.entries(record)) {
|
|
484
|
-
const field = declaration.fields[name];
|
|
485
|
-
if (!field) {
|
|
486
|
-
issues.push({
|
|
487
|
-
path: name,
|
|
488
|
-
code: "unknown-field",
|
|
489
|
-
message: `field "${name}" is not declared by this entity`,
|
|
490
|
-
valid: fieldNames
|
|
491
|
-
});
|
|
492
|
-
continue;
|
|
493
|
-
}
|
|
494
|
-
if (value === null || value === void 0) continue;
|
|
495
|
-
switch (field.type) {
|
|
496
|
-
case "number":
|
|
497
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
498
|
-
issues.push({ path: name, code: "invalid-value", message: `"${name}" expects a number, got ${typeOf(value)}` });
|
|
499
|
-
}
|
|
500
|
-
break;
|
|
501
|
-
case "boolean":
|
|
502
|
-
if (typeof value !== "boolean") {
|
|
503
|
-
issues.push({ path: name, code: "invalid-value", message: `"${name}" expects a boolean, got ${typeOf(value)}` });
|
|
504
|
-
}
|
|
505
|
-
break;
|
|
506
|
-
case "json":
|
|
507
|
-
break;
|
|
508
|
-
// any JSON value
|
|
509
|
-
case "point": {
|
|
510
|
-
const point = value;
|
|
511
|
-
if (typeOf(value) !== "object" || typeof point.lat !== "number" || typeof point.lng !== "number" || Object.keys(point).length !== 2) {
|
|
512
|
-
issues.push({ path: name, code: "invalid-value", message: `"${name}" expects {lat: number, lng: number}` });
|
|
513
|
-
}
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
default:
|
|
517
|
-
if (typeof value !== "string") {
|
|
518
|
-
issues.push({ path: name, code: "invalid-value", message: `"${name}" expects a string, got ${typeOf(value)}` });
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
for (const [name, field] of Object.entries(declaration.fields)) {
|
|
523
|
-
if (field.required && (record[name] === void 0 || record[name] === null || record[name] === "")) {
|
|
524
|
-
issues.push({ path: name, code: "missing-field", message: `required field "${name}" is missing` });
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return issues;
|
|
528
|
-
}
|
|
529
|
-
function describeEntities() {
|
|
530
|
-
return entityDeclarationRegistry.describe().map((base) => {
|
|
531
|
-
const declaration = entityDeclarationRegistry.get(base.id);
|
|
532
|
-
return {
|
|
533
|
-
...base,
|
|
534
|
-
recordSchema: base.schema,
|
|
535
|
-
access: declaration.access,
|
|
536
|
-
scope: declaration.scope,
|
|
537
|
-
storage: declaration.storage,
|
|
538
|
-
indexes: declaration.indexes,
|
|
539
|
-
titleField: declaration.titleField,
|
|
540
|
-
displayFields: declaration.displayFields
|
|
541
|
-
};
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
var FIELD_TYPE_TO_INPUT = {
|
|
545
|
-
text: "text",
|
|
546
|
-
richtext: "markdown",
|
|
547
|
-
number: "number",
|
|
548
|
-
boolean: "boolean",
|
|
549
|
-
// JSON and point have no dedicated control yet; they degrade to text inputs
|
|
550
|
-
// with a hint, which is honest — the descriptor still names the real type in
|
|
551
|
-
// the record schema, so a richer control can adopt them without a migration.
|
|
552
|
-
json: "textarea",
|
|
553
|
-
point: "text",
|
|
554
|
-
image: "image",
|
|
555
|
-
url: "url",
|
|
556
|
-
ref: "relation",
|
|
557
|
-
datetime: "datetime"
|
|
558
|
-
};
|
|
559
|
-
function entityAdminForm(declaration) {
|
|
560
|
-
const fields = Object.entries(declaration.fields).map(([name, field]) => {
|
|
561
|
-
const def = {
|
|
562
|
-
key: name,
|
|
563
|
-
label: field.label ?? name,
|
|
564
|
-
type: FIELD_TYPE_TO_INPUT[field.type],
|
|
565
|
-
showInForm: true,
|
|
566
|
-
showInTable: declaration.displayFields.includes(name)
|
|
567
|
-
};
|
|
568
|
-
if (field.required) def.required = true;
|
|
569
|
-
if (field.help) def.hint = field.help;
|
|
570
|
-
if (field.default !== void 0) def.defaultValue = field.default;
|
|
571
|
-
if (field.type === "json") def.hint = field.help ?? "JSON value";
|
|
572
|
-
if (field.type === "point") def.hint = field.help ?? "lat,lng";
|
|
573
|
-
if (field.type === "ref" && field.entity) {
|
|
574
|
-
def.relation = {
|
|
575
|
-
table: declaration.storage.table,
|
|
576
|
-
valueField: "id",
|
|
577
|
-
labelField: "slug",
|
|
578
|
-
filter: { entity: field.entity }
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
return def;
|
|
582
|
-
});
|
|
583
|
-
return { entity: declaration.key, title: declaration.title, fields };
|
|
584
|
-
}
|
|
585
|
-
var SIDECAR_REFERENCES = ["product", "category"];
|
|
586
|
-
var sidecarDeclarationRegistry = new Registry("sidecar");
|
|
587
|
-
function defineSidecarFields(reference, fields, meta = {}) {
|
|
588
|
-
if (!SIDECAR_REFERENCES.includes(reference)) {
|
|
589
|
-
fail(`defineSidecarFields: "${reference}" is not a sidecar reference.`, SIDECAR_REFERENCES);
|
|
590
|
-
}
|
|
591
|
-
for (const [name, field] of Object.entries(fields)) {
|
|
592
|
-
if (!FIELD_NAME_RE.test(name)) {
|
|
593
|
-
fail(`defineSidecarFields("${reference}"): "${name}" is not a valid field name (${FIELD_NAME_RE}).`);
|
|
594
|
-
}
|
|
595
|
-
if (!ENTITY_FIELD_TYPES.includes(field?.type)) {
|
|
596
|
-
fail(`defineSidecarFields("${reference}"): field "${name}" has unknown type "${String(field?.type)}".`, ENTITY_FIELD_TYPES);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
const declaration = { reference, fields };
|
|
600
|
-
sidecarDeclarationRegistry.register(reference, declaration, {
|
|
601
|
-
title: `Custom fields: ${reference}`,
|
|
602
|
-
propsSchema: entityRecordSchema({ title: `${reference} custom fields`, fields }),
|
|
603
|
-
source: meta.source ?? "app",
|
|
604
|
-
pluginId: meta.pluginId
|
|
605
|
-
});
|
|
606
|
-
return declaration;
|
|
607
|
-
}
|
|
608
|
-
function resolveSidecarDeclaration(reference) {
|
|
609
|
-
const declaration = sidecarDeclarationRegistry.get(reference);
|
|
610
|
-
if (!declaration) {
|
|
611
|
-
const declared = sidecarDeclarationRegistry.ids().sort();
|
|
612
|
-
throw new Error(
|
|
613
|
-
`No sidecar fields are declared for "${reference}". ${declared.length ? `Declared references: ${declared.join(", ")}` : "Call defineSidecarFields(reference, fields) first."}`
|
|
614
|
-
);
|
|
615
|
-
}
|
|
616
|
-
return declaration;
|
|
617
|
-
}
|
|
618
|
-
function hasSidecarDeclaration(reference) {
|
|
619
|
-
return sidecarDeclarationRegistry.has(reference);
|
|
620
|
-
}
|
|
621
|
-
function clearSidecarDeclarations() {
|
|
622
|
-
sidecarDeclarationRegistry.clear();
|
|
623
|
-
}
|
|
624
|
-
|
|
625
265
|
// src/registry/block-constraints.ts
|
|
626
266
|
function metaFor(type) {
|
|
627
267
|
return blockRegistry.getEntry(type)?.meta;
|
|
@@ -751,7 +391,7 @@ function repairBlockTree(nodes) {
|
|
|
751
391
|
}
|
|
752
392
|
|
|
753
393
|
// src/registry/schema-check.ts
|
|
754
|
-
function
|
|
394
|
+
function typeOf(value) {
|
|
755
395
|
if (value === null) return "null";
|
|
756
396
|
if (Array.isArray(value)) return "array";
|
|
757
397
|
if (typeof value === "number") return Number.isInteger(value) ? "integer" : "number";
|
|
@@ -768,7 +408,7 @@ function checkAgainstSchema(schema, value, path = "") {
|
|
|
768
408
|
const issues = [];
|
|
769
409
|
const declaredType = schema.type;
|
|
770
410
|
if (declaredType !== void 0) {
|
|
771
|
-
const actual =
|
|
411
|
+
const actual = typeOf(value);
|
|
772
412
|
const accepted = Array.isArray(declaredType) ? declaredType.map(String) : [String(declaredType)];
|
|
773
413
|
if (!accepted.some((t) => typeMatches(t, actual))) {
|
|
774
414
|
issues.push({ path, message: `expected ${accepted.join(" | ")}, got ${actual}` });
|
|
@@ -1538,7 +1178,22 @@ function resolvePluginRuntime({
|
|
|
1538
1178
|
const order = { main: 0, secondary: 1, settings: 2 };
|
|
1539
1179
|
return (order[a.section] ?? 99) - (order[b.section] ?? 99) || a.position - b.position;
|
|
1540
1180
|
});
|
|
1541
|
-
|
|
1181
|
+
{
|
|
1182
|
+
const groupAnchor = /* @__PURE__ */ new Map();
|
|
1183
|
+
for (const tab of settingsTabs) {
|
|
1184
|
+
if (!tab.group) continue;
|
|
1185
|
+
const order = tab.order ?? 0;
|
|
1186
|
+
const current = groupAnchor.get(tab.group);
|
|
1187
|
+
if (current === void 0 || order < current) groupAnchor.set(tab.group, order);
|
|
1188
|
+
}
|
|
1189
|
+
settingsTabs.sort((a, b) => {
|
|
1190
|
+
const anchorA = a.group ? groupAnchor.get(a.group) : a.order ?? 0;
|
|
1191
|
+
const anchorB = b.group ? groupAnchor.get(b.group) : b.order ?? 0;
|
|
1192
|
+
if (anchorA !== anchorB) return anchorA - anchorB;
|
|
1193
|
+
if ((a.group ?? "") !== (b.group ?? "")) return (a.group ?? "").localeCompare(b.group ?? "");
|
|
1194
|
+
return (a.order ?? 0) - (b.order ?? 0);
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1542
1197
|
widgets.sort((a, b) => a.zone !== b.zone ? a.zone.localeCompare(b.zone) : a.order - b.order);
|
|
1543
1198
|
dashboardWidgets.sort((a, b) => a.order - b.order);
|
|
1544
1199
|
analyticsCards.sort((a, b) => a.order - b.order);
|
|
@@ -1587,6 +1242,6 @@ function useConnectorsForPlugin(hostPluginId) {
|
|
|
1587
1242
|
return usePluginRuntime().connectorsByHost.get(hostPluginId) ?? [];
|
|
1588
1243
|
}
|
|
1589
1244
|
|
|
1590
|
-
export { BLOCK_SETTING_TYPES,
|
|
1591
|
-
//# sourceMappingURL=chunk-
|
|
1592
|
-
//# sourceMappingURL=chunk-
|
|
1245
|
+
export { BLOCK_SETTING_TYPES, PLUGIN_API_VERSION, PluginRuntimeProvider, auditBlocks, blockRegistry, buildEntityDomainEvents, checkAgainstSchema, checkBlockConstraints, checkBlockContext, checkNodePlacement, clearExtensionPoints, clearHandles, clearLoaders, componentRegistry, dataNeedKey, defaultPropsFromSettings, defineBlock, defineExtensionPoint, defineLoader, definePlugin, describeBlock, describeBlocks, describeExtensionPoints, describeLoaders, entityEventKey, extensionAfterHooks, extensionPointRegistry, formatSchemaIssues, getAnalyticsCards, getBlock, getBlockMeta, getComponent, getDashboardWidgets, getHandle, getMetric, getPage, getPlugin, getPluginFactory, getScaffold, getWidgetsForZone, handleNameFor, handleRegistry, hasExtensionPoint, hasHandle, hasLoader, isBlockEnabledOn, isLoaderParamRef, isLoaderPropRef, listBlocks, listExtensionHandlers, listExtensionPoints, listHandles, listLoaders, listMetrics, listPluginFactories, listPlugins, loaderRegistry, metricRegistry, pageRegistry, pluginFactoryRegistry, pluginRegistry, registerBlock, registerComponent, registerExtensionHandler, registerHandle, registerMetric, registerPage, registerPlugin, registerPluginFactory, registerScaffold, repairBlockTree, resolveHandle, resolveLoader, resolvePluginComponent, resolvePluginRuntime, runEscapeValve, runExtensionPoint, scaffoldRegistry, settingsToJsonSchema, summarizeBlockAudit, unregisterExtensionHandler, useConnectorsForPlugin, usePluginRuntime, usePluginRuntimeOptional };
|
|
1246
|
+
//# sourceMappingURL=chunk-RRYFXUQX.js.map
|
|
1247
|
+
//# sourceMappingURL=chunk-RRYFXUQX.js.map
|