@relyio/sdk 0.6.0 → 0.8.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/CHANGELOG.md +400 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-DY2XT7OF.cjs → chunk-72UK5U7T.cjs} +70 -60
- package/dist/{chunk-I3ESNANB.js → chunk-H6IBQSMM.js} +2 -2
- package/dist/{chunk-7ABNXVWL.js → chunk-QFHVF3YF.js} +1617 -404
- package/dist/{chunk-HT6NFRM2.cjs → chunk-TZL374LS.cjs} +2 -2
- package/dist/{chunk-GCMQUM6N.cjs → chunk-XIE7WJV3.cjs} +1621 -407
- package/dist/{chunk-XJVY2CLY.js → chunk-YEJUMW4X.js} +70 -60
- package/dist/client/index.cjs +4 -3
- package/dist/client/index.d.cts +5 -4
- package/dist/client/index.d.ts +5 -4
- package/dist/client/index.js +2 -1
- package/dist/{index-d1Kz1e19.d.cts → define-content-type-cEGjIwT5.d.cts} +1859 -733
- package/dist/{index-yPbhZc6q.d.ts → define-content-type-cEGjIwT5.d.ts} +1859 -733
- package/dist/{define-schema-1kr2HIzN.d.cts → define-schema-BPj2srgh.d.ts} +189 -85
- package/dist/{define-schema-ChvAzY8H.d.ts → define-schema-DgbJ5Kwn.d.cts} +189 -85
- package/dist/index-B_rIWO_l.d.cts +860 -0
- package/dist/index-Cv4tmcrw.d.ts +860 -0
- package/dist/{index-Df1VsfJR.d.cts → index-DBoPPlT1.d.cts} +684 -277
- package/dist/{index-XqoGUaAY.d.ts → index-yRJ2IqM_.d.ts} +684 -277
- package/dist/index.cjs +148 -124
- package/dist/index.d.cts +174 -64
- package/dist/index.d.ts +174 -64
- package/dist/index.js +43 -18
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +13 -11
- package/dist/schema/index.d.ts +13 -11
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/index.cjs +19 -19
- package/dist/utils/index.d.cts +10 -1
- package/dist/utils/index.d.ts +10 -1
- package/dist/utils/index.js +1 -1
- package/package.json +2 -1
- package/dist/define-content-type-CDB3kyeA.d.cts +0 -1173
- package/dist/define-content-type-CDB3kyeA.d.ts +0 -1173
|
@@ -6,8 +6,8 @@ var chunkMWMSFIWN_cjs = require('./chunk-MWMSFIWN.cjs');
|
|
|
6
6
|
|
|
7
7
|
// src/schema/define-schema.ts
|
|
8
8
|
function defineSchema(config) {
|
|
9
|
-
if (config.contentTypes == null
|
|
10
|
-
throw new Error("Schema must
|
|
9
|
+
if (config.contentTypes == null) {
|
|
10
|
+
throw new Error("Schema must declare contentTypes (an empty object declares none)");
|
|
11
11
|
}
|
|
12
12
|
if (config.locales && config.locales.length > 0) {
|
|
13
13
|
const defaultLocales = config.locales.filter((l) => l.default === true);
|
|
@@ -49,7 +49,7 @@ function defineSchema(config) {
|
|
|
49
49
|
const builtInRoles = /* @__PURE__ */ new Set(["admin", "editor", "viewer"]);
|
|
50
50
|
const customRoleIds = new Set(config.roles?.map((r) => r.id) ?? []);
|
|
51
51
|
const allRoleIds = /* @__PURE__ */ new Set([...builtInRoles, ...customRoleIds]);
|
|
52
|
-
for (const stage of config.workflow.stages) {
|
|
52
|
+
for (const stage of config.workflow.stages ?? []) {
|
|
53
53
|
if (stage.allowedRoles) {
|
|
54
54
|
for (const roleId of stage.allowedRoles) {
|
|
55
55
|
if (!allRoleIds.has(roleId)) {
|
|
@@ -95,16 +95,16 @@ function defineSchema(config) {
|
|
|
95
95
|
}
|
|
96
96
|
return {
|
|
97
97
|
_tag: "schema",
|
|
98
|
-
...config.locales
|
|
98
|
+
...config.locales !== void 0 && { locales: config.locales },
|
|
99
99
|
contentTypes: config.contentTypes,
|
|
100
100
|
components: config.components ?? {},
|
|
101
101
|
singletonContentTypes: config.singletonContentTypes ?? {},
|
|
102
102
|
queries: config.queries ?? {},
|
|
103
103
|
settingsGroups: config.settingsGroups,
|
|
104
104
|
...config.assetTypes && { assetTypes: config.assetTypes },
|
|
105
|
-
...config.roles
|
|
105
|
+
...config.roles !== void 0 && { roles: config.roles },
|
|
106
106
|
...config.workflow && { workflow: config.workflow },
|
|
107
|
-
...config.views
|
|
107
|
+
...config.views !== void 0 && { views: config.views }
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
chunkMWMSFIWN_cjs.__name(defineSchema, "defineSchema");
|
|
@@ -137,9 +137,9 @@ function defineLocale(code, options) {
|
|
|
137
137
|
code,
|
|
138
138
|
displayName: options.displayName,
|
|
139
139
|
...options.default !== void 0 && { default: options.default },
|
|
140
|
-
...options.fallback
|
|
141
|
-
...options.direction
|
|
142
|
-
...options.active !== void 0 &&
|
|
140
|
+
...options.fallback !== void 0 && { fallback: options.fallback },
|
|
141
|
+
...options.direction !== void 0 && { direction: options.direction },
|
|
142
|
+
...options.active !== void 0 && { active: options.active }
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
chunkMWMSFIWN_cjs.__name(defineLocale, "defineLocale");
|
|
@@ -187,6 +187,9 @@ function fieldset(id, config) {
|
|
|
187
187
|
id,
|
|
188
188
|
displayName: config.displayName,
|
|
189
189
|
description: config.description,
|
|
190
|
+
...config.collapsedByDefault !== void 0 && {
|
|
191
|
+
collapsedByDefault: config.collapsedByDefault
|
|
192
|
+
},
|
|
190
193
|
ai: config.ai,
|
|
191
194
|
fields: config.fields
|
|
192
195
|
};
|
|
@@ -201,8 +204,10 @@ function defineContentType(name, config) {
|
|
|
201
204
|
description: config.description,
|
|
202
205
|
ai: config.ai,
|
|
203
206
|
displayField: config.displayField,
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
// Written only when given: it was `false` whenever not, so the same content type was one
|
|
208
|
+
// definition from YAML and another from TypeScript, with a different schemaHash (REL-1458)
|
|
209
|
+
...config.hierarchical !== void 0 && { hierarchical: config.hierarchical },
|
|
210
|
+
...config.accessTags !== void 0 && { accessTags: config.accessTags },
|
|
206
211
|
...config.workflow !== void 0 && { workflow: config.workflow }
|
|
207
212
|
};
|
|
208
213
|
if ("fields" in config && config.fields) {
|
|
@@ -225,8 +230,11 @@ function defineSingletonContentType(name, config) {
|
|
|
225
230
|
description: config.description,
|
|
226
231
|
ai: config.ai,
|
|
227
232
|
displayField: config.displayField,
|
|
228
|
-
|
|
229
|
-
...config.
|
|
233
|
+
// Written only when given, as a content type's is (REL-1458)
|
|
234
|
+
...config.hierarchical !== void 0 && { hierarchical: config.hierarchical },
|
|
235
|
+
...config.accessTags !== void 0 && { accessTags: config.accessTags },
|
|
236
|
+
// Its config type took `workflow` and this dropped it, so a singleton's workflow never deployed
|
|
237
|
+
...config.workflow !== void 0 && { workflow: config.workflow }
|
|
230
238
|
};
|
|
231
239
|
if ("fields" in config && config.fields) {
|
|
232
240
|
return { ...base, fields: config.fields };
|
|
@@ -247,7 +255,9 @@ function defineComponent(name, config) {
|
|
|
247
255
|
displayName: config.displayName,
|
|
248
256
|
description: config.description,
|
|
249
257
|
ai: config.ai,
|
|
250
|
-
|
|
258
|
+
// Written only when given: `false` whenever not made a YAML and a TypeScript component two
|
|
259
|
+
// definitions (REL-1458)
|
|
260
|
+
...config.deprecated !== void 0 && { deprecated: config.deprecated },
|
|
251
261
|
fields: config.fields,
|
|
252
262
|
metadata: config.metadata
|
|
253
263
|
};
|
|
@@ -262,7 +272,7 @@ function defineSettingsGroup(name, config) {
|
|
|
262
272
|
displayName: config.displayName,
|
|
263
273
|
description: config.description,
|
|
264
274
|
ai: config.ai,
|
|
265
|
-
...config.accessTags !== void 0 &&
|
|
275
|
+
...config.accessTags !== void 0 && { accessTags: config.accessTags },
|
|
266
276
|
fields: config.fields
|
|
267
277
|
};
|
|
268
278
|
}
|
|
@@ -287,7 +297,8 @@ function defineAssetType(name, config) {
|
|
|
287
297
|
description: config.description,
|
|
288
298
|
ai: config.ai,
|
|
289
299
|
displayField: config.displayField,
|
|
290
|
-
|
|
300
|
+
// An empty list too, as a content type's and a settings group's are kept (REL-1457, REL-1458)
|
|
301
|
+
...config.accessTags !== void 0 && { accessTags: config.accessTags },
|
|
291
302
|
...config.workflow !== void 0 && { workflow: config.workflow },
|
|
292
303
|
...config.image !== void 0 && { image: config.image },
|
|
293
304
|
...config.video !== void 0 && { video: config.video },
|
|
@@ -299,7 +310,7 @@ function defineAssetType(name, config) {
|
|
|
299
310
|
if ("fieldsets" in config && config.fieldsets) {
|
|
300
311
|
return { ...base, fieldsets: config.fieldsets };
|
|
301
312
|
}
|
|
302
|
-
|
|
313
|
+
return base;
|
|
303
314
|
}
|
|
304
315
|
chunkMWMSFIWN_cjs.__name(defineAssetType, "defineAssetType");
|
|
305
316
|
|
|
@@ -369,10 +380,10 @@ function defineRole(id, config) {
|
|
|
369
380
|
_tag: "role",
|
|
370
381
|
id,
|
|
371
382
|
displayName: config.displayName,
|
|
372
|
-
...config.description !== void 0 &&
|
|
383
|
+
...config.description !== void 0 && { description: config.description },
|
|
373
384
|
...config.baseRole !== void 0 && { baseRole: config.baseRole },
|
|
374
|
-
...
|
|
375
|
-
...
|
|
385
|
+
...config.includes !== void 0 && { includes: config.includes },
|
|
386
|
+
...config.permissions !== void 0 && { permissions: config.permissions },
|
|
376
387
|
...config.fields !== void 0 && { fields: config.fields }
|
|
377
388
|
};
|
|
378
389
|
}
|
|
@@ -413,8 +424,7 @@ function defineWorkflowStage(id, config) {
|
|
|
413
424
|
if (config.description != null && config.description.length > 512) {
|
|
414
425
|
throw new Error(`Workflow stage description must be 512 characters or less`);
|
|
415
426
|
}
|
|
416
|
-
|
|
417
|
-
if (requiredApprovals < 1 || requiredApprovals > 10) {
|
|
427
|
+
if (config.requiredApprovals !== void 0 && (config.requiredApprovals < 1 || config.requiredApprovals > 10)) {
|
|
418
428
|
throw new Error(`requiredApprovals must be between 1 and 10`);
|
|
419
429
|
}
|
|
420
430
|
if (config.timeoutDays !== void 0) {
|
|
@@ -431,9 +441,9 @@ function defineWorkflowStage(id, config) {
|
|
|
431
441
|
_tag: "workflowStage",
|
|
432
442
|
id,
|
|
433
443
|
displayName: config.displayName,
|
|
434
|
-
...config.description !== void 0 &&
|
|
435
|
-
requiredApprovals,
|
|
436
|
-
...config.allowedRoles !== void 0 &&
|
|
444
|
+
...config.description !== void 0 && { description: config.description },
|
|
445
|
+
...config.requiredApprovals !== void 0 && { requiredApprovals: config.requiredApprovals },
|
|
446
|
+
...config.allowedRoles !== void 0 && { allowedRoles: config.allowedRoles },
|
|
437
447
|
...config.autoAssign !== void 0 && { autoAssign: config.autoAssign },
|
|
438
448
|
...config.timeoutDays !== void 0 && { timeoutDays: config.timeoutDays },
|
|
439
449
|
...config.escalation !== void 0 && { escalation: config.escalation }
|
|
@@ -441,28 +451,25 @@ function defineWorkflowStage(id, config) {
|
|
|
441
451
|
}
|
|
442
452
|
chunkMWMSFIWN_cjs.__name(defineWorkflowStage, "defineWorkflowStage");
|
|
443
453
|
function defineWorkflow(config) {
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
for (const stage of stages) {
|
|
449
|
-
if (stageIds.has(stage.id)) {
|
|
450
|
-
throw new Error(`Duplicate workflow stage ID '${stage.id}'`);
|
|
451
|
-
}
|
|
452
|
-
stageIds.add(stage.id);
|
|
454
|
+
const stageIds = /* @__PURE__ */ new Set();
|
|
455
|
+
for (const stage of config.stages ?? []) {
|
|
456
|
+
if (stageIds.has(stage.id)) {
|
|
457
|
+
throw new Error(`Duplicate workflow stage ID '${stage.id}'`);
|
|
453
458
|
}
|
|
459
|
+
stageIds.add(stage.id);
|
|
454
460
|
}
|
|
455
461
|
return {
|
|
456
462
|
_tag: "workflow",
|
|
457
|
-
enabled,
|
|
458
|
-
stages
|
|
463
|
+
...config.enabled !== void 0 && { enabled: config.enabled },
|
|
464
|
+
...config.stages !== void 0 && { stages: config.stages }
|
|
459
465
|
};
|
|
460
466
|
}
|
|
461
467
|
chunkMWMSFIWN_cjs.__name(defineWorkflow, "defineWorkflow");
|
|
462
468
|
function defineContentTypeWorkflow(config) {
|
|
463
469
|
return {
|
|
464
470
|
...config.enabled !== void 0 && { enabled: config.enabled },
|
|
465
|
-
|
|
471
|
+
// An empty list too, as YAML keeps it (REL-1458)
|
|
472
|
+
...config.stages !== void 0 && { stages: config.stages },
|
|
466
473
|
...config.autoPublish !== void 0 && { autoPublish: config.autoPublish },
|
|
467
474
|
...config.requireAllLocales !== void 0 && { requireAllLocales: config.requireAllLocales }
|
|
468
475
|
};
|
|
@@ -476,41 +483,44 @@ function isWorkflowDefinition(value) {
|
|
|
476
483
|
return typeof value === "object" && value !== null && "_tag" in value && value._tag === "workflow";
|
|
477
484
|
}
|
|
478
485
|
chunkMWMSFIWN_cjs.__name(isWorkflowDefinition, "isWorkflowDefinition");
|
|
486
|
+
function stagesOf(workflow) {
|
|
487
|
+
return workflow.stages ?? [];
|
|
488
|
+
}
|
|
489
|
+
chunkMWMSFIWN_cjs.__name(stagesOf, "stagesOf");
|
|
479
490
|
function getWorkflowStageIds(workflow) {
|
|
480
|
-
return workflow.
|
|
491
|
+
return stagesOf(workflow).map((s) => s.id);
|
|
481
492
|
}
|
|
482
493
|
chunkMWMSFIWN_cjs.__name(getWorkflowStageIds, "getWorkflowStageIds");
|
|
483
494
|
function findWorkflowStage(workflow, stageId) {
|
|
484
|
-
return workflow.
|
|
495
|
+
return stagesOf(workflow).find((s) => s.id === stageId);
|
|
485
496
|
}
|
|
486
497
|
chunkMWMSFIWN_cjs.__name(findWorkflowStage, "findWorkflowStage");
|
|
487
498
|
function getNextWorkflowStage(workflow, currentStageId) {
|
|
488
|
-
const
|
|
489
|
-
|
|
499
|
+
const stages = stagesOf(workflow);
|
|
500
|
+
const currentIndex = stages.findIndex((s) => s.id === currentStageId);
|
|
501
|
+
if (currentIndex === -1 || currentIndex === stages.length - 1) {
|
|
490
502
|
return null;
|
|
491
503
|
}
|
|
492
|
-
const nextStage =
|
|
504
|
+
const nextStage = stages[currentIndex + 1];
|
|
493
505
|
return nextStage ?? null;
|
|
494
506
|
}
|
|
495
507
|
chunkMWMSFIWN_cjs.__name(getNextWorkflowStage, "getNextWorkflowStage");
|
|
496
508
|
function getFirstWorkflowStage(workflow) {
|
|
497
|
-
|
|
498
|
-
|
|
509
|
+
const stages = stagesOf(workflow);
|
|
510
|
+
if (stages.length === 0) return null;
|
|
511
|
+
const firstStage = stages[0];
|
|
499
512
|
return firstStage ?? null;
|
|
500
513
|
}
|
|
501
514
|
chunkMWMSFIWN_cjs.__name(getFirstWorkflowStage, "getFirstWorkflowStage");
|
|
502
515
|
function isFinalWorkflowStage(workflow, stageId) {
|
|
503
|
-
|
|
504
|
-
|
|
516
|
+
const stages = stagesOf(workflow);
|
|
517
|
+
if (stages.length === 0) return false;
|
|
518
|
+
const lastStage = stages[stages.length - 1];
|
|
505
519
|
return lastStage?.id === stageId;
|
|
506
520
|
}
|
|
507
521
|
chunkMWMSFIWN_cjs.__name(isFinalWorkflowStage, "isFinalWorkflowStage");
|
|
508
522
|
|
|
509
523
|
// src/schema/define-view.ts
|
|
510
|
-
function generateSlugFromId(id) {
|
|
511
|
-
return id.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
|
|
512
|
-
}
|
|
513
|
-
chunkMWMSFIWN_cjs.__name(generateSlugFromId, "generateSlugFromId");
|
|
514
524
|
function defineView(id, config) {
|
|
515
525
|
if (!id.match(/^[a-zA-Z][a-zA-Z0-9_-]*$/)) {
|
|
516
526
|
throw new Error(
|
|
@@ -526,16 +536,14 @@ function defineView(id, config) {
|
|
|
526
536
|
if (!config.scope?.type) {
|
|
527
537
|
throw new Error(`View '${id}' must have a valid scope`);
|
|
528
538
|
}
|
|
529
|
-
|
|
530
|
-
if (!slug2.match(/^[a-z][a-z0-9-]*$/)) {
|
|
539
|
+
if (config.slug !== void 0 && !/^[a-z][a-z0-9-]*$/.test(config.slug)) {
|
|
531
540
|
throw new Error(
|
|
532
|
-
`View '${id}' slug '${
|
|
541
|
+
`View '${id}' slug '${config.slug}' must be lowercase, start with a letter, and contain only letters, numbers, and hyphens`
|
|
533
542
|
);
|
|
534
543
|
}
|
|
535
544
|
return {
|
|
536
545
|
_tag: "view",
|
|
537
546
|
id,
|
|
538
|
-
slug: slug2,
|
|
539
547
|
...config
|
|
540
548
|
};
|
|
541
549
|
}
|
|
@@ -543,8 +551,8 @@ chunkMWMSFIWN_cjs.__name(defineView, "defineView");
|
|
|
543
551
|
|
|
544
552
|
// src/schema/define-query.ts
|
|
545
553
|
function defineQuery(name, config) {
|
|
546
|
-
if (!config.fetch && !config.aggregate && !config.search
|
|
547
|
-
throw new Error("Query must have at least one of: fetch, aggregate
|
|
554
|
+
if (!config.fetch && !config.aggregate && !config.search) {
|
|
555
|
+
throw new Error("Query must have at least one of: fetch, aggregate or search");
|
|
548
556
|
}
|
|
549
557
|
if (!config.endpoint.startsWith("/api/")) {
|
|
550
558
|
throw new Error("Query endpoint must start with /api/");
|
|
@@ -552,14 +560,15 @@ function defineQuery(name, config) {
|
|
|
552
560
|
return {
|
|
553
561
|
_tag: "query",
|
|
554
562
|
name,
|
|
563
|
+
type: config.type,
|
|
555
564
|
endpoint: config.endpoint,
|
|
556
565
|
description: config.description,
|
|
557
566
|
fetch: config.fetch,
|
|
558
567
|
aggregate: config.aggregate,
|
|
559
568
|
search: config.search,
|
|
560
|
-
similar: config.similar,
|
|
561
569
|
include: config.include,
|
|
562
570
|
filters: config.filters,
|
|
571
|
+
fullText: config.fullText,
|
|
563
572
|
select: config.select,
|
|
564
573
|
cache: config.cache,
|
|
565
574
|
parameters: config.parameters,
|
|
@@ -597,7 +606,8 @@ function createField(id, type, options = {}) {
|
|
|
597
606
|
...options.config !== void 0 && { config: options.config },
|
|
598
607
|
...options.ui !== void 0 && { ui: options.ui },
|
|
599
608
|
...options.ai !== void 0 && { ai: options.ai },
|
|
600
|
-
|
|
609
|
+
// An empty list too: dropping it made a YAML field and a TypeScript one two definitions (REL-1458)
|
|
610
|
+
...options.rules !== void 0 && { rules: options.rules },
|
|
601
611
|
...options.localization !== void 0 && { localization: options.localization },
|
|
602
612
|
...options.fallback !== void 0 && { fallback: options.fallback },
|
|
603
613
|
...options.deprecated !== void 0 && { deprecated: options.deprecated }
|
|
@@ -707,5 +717,5 @@ exports.isLocaleDefinition = isLocaleDefinition;
|
|
|
707
717
|
exports.isRoleDefinition = isRoleDefinition;
|
|
708
718
|
exports.isWorkflowDefinition = isWorkflowDefinition;
|
|
709
719
|
exports.isWorkflowStageDefinition = isWorkflowStageDefinition;
|
|
710
|
-
//# sourceMappingURL=chunk-
|
|
711
|
-
//# sourceMappingURL=chunk-
|
|
720
|
+
//# sourceMappingURL=chunk-72UK5U7T.cjs.map
|
|
721
|
+
//# sourceMappingURL=chunk-72UK5U7T.cjs.map
|
|
@@ -173,5 +173,5 @@ function isValidUrl(url) {
|
|
|
173
173
|
__name(isValidUrl, "isValidUrl");
|
|
174
174
|
|
|
175
175
|
export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString };
|
|
176
|
-
//# sourceMappingURL=chunk-
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
176
|
+
//# sourceMappingURL=chunk-H6IBQSMM.js.map
|
|
177
|
+
//# sourceMappingURL=chunk-H6IBQSMM.js.map
|