@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.
Files changed (37) hide show
  1. package/CHANGELOG.md +400 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/{chunk-DY2XT7OF.cjs → chunk-72UK5U7T.cjs} +70 -60
  4. package/dist/{chunk-I3ESNANB.js → chunk-H6IBQSMM.js} +2 -2
  5. package/dist/{chunk-7ABNXVWL.js → chunk-QFHVF3YF.js} +1617 -404
  6. package/dist/{chunk-HT6NFRM2.cjs → chunk-TZL374LS.cjs} +2 -2
  7. package/dist/{chunk-GCMQUM6N.cjs → chunk-XIE7WJV3.cjs} +1621 -407
  8. package/dist/{chunk-XJVY2CLY.js → chunk-YEJUMW4X.js} +70 -60
  9. package/dist/client/index.cjs +4 -3
  10. package/dist/client/index.d.cts +5 -4
  11. package/dist/client/index.d.ts +5 -4
  12. package/dist/client/index.js +2 -1
  13. package/dist/{index-d1Kz1e19.d.cts → define-content-type-cEGjIwT5.d.cts} +1859 -733
  14. package/dist/{index-yPbhZc6q.d.ts → define-content-type-cEGjIwT5.d.ts} +1859 -733
  15. package/dist/{define-schema-1kr2HIzN.d.cts → define-schema-BPj2srgh.d.ts} +189 -85
  16. package/dist/{define-schema-ChvAzY8H.d.ts → define-schema-DgbJ5Kwn.d.cts} +189 -85
  17. package/dist/index-B_rIWO_l.d.cts +860 -0
  18. package/dist/index-Cv4tmcrw.d.ts +860 -0
  19. package/dist/{index-Df1VsfJR.d.cts → index-DBoPPlT1.d.cts} +684 -277
  20. package/dist/{index-XqoGUaAY.d.ts → index-yRJ2IqM_.d.ts} +684 -277
  21. package/dist/index.cjs +148 -124
  22. package/dist/index.d.cts +174 -64
  23. package/dist/index.d.ts +174 -64
  24. package/dist/index.js +43 -18
  25. package/dist/schema/index.cjs +35 -35
  26. package/dist/schema/index.d.cts +13 -11
  27. package/dist/schema/index.d.ts +13 -11
  28. package/dist/schema/index.js +1 -1
  29. package/dist/types/index.d.cts +2 -2
  30. package/dist/types/index.d.ts +2 -2
  31. package/dist/utils/index.cjs +19 -19
  32. package/dist/utils/index.d.cts +10 -1
  33. package/dist/utils/index.d.ts +10 -1
  34. package/dist/utils/index.js +1 -1
  35. package/package.json +2 -1
  36. package/dist/define-content-type-CDB3kyeA.d.cts +0 -1173
  37. package/dist/define-content-type-CDB3kyeA.d.ts +0 -1173
@@ -4,8 +4,8 @@ import { __name, __export } from './chunk-XQ4QHWZE.js';
4
4
 
5
5
  // src/schema/define-schema.ts
6
6
  function defineSchema(config) {
7
- if (config.contentTypes == null || Object.keys(config.contentTypes).length === 0) {
8
- throw new Error("Schema must have at least one content type");
7
+ if (config.contentTypes == null) {
8
+ throw new Error("Schema must declare contentTypes (an empty object declares none)");
9
9
  }
10
10
  if (config.locales && config.locales.length > 0) {
11
11
  const defaultLocales = config.locales.filter((l) => l.default === true);
@@ -47,7 +47,7 @@ function defineSchema(config) {
47
47
  const builtInRoles = /* @__PURE__ */ new Set(["admin", "editor", "viewer"]);
48
48
  const customRoleIds = new Set(config.roles?.map((r) => r.id) ?? []);
49
49
  const allRoleIds = /* @__PURE__ */ new Set([...builtInRoles, ...customRoleIds]);
50
- for (const stage of config.workflow.stages) {
50
+ for (const stage of config.workflow.stages ?? []) {
51
51
  if (stage.allowedRoles) {
52
52
  for (const roleId of stage.allowedRoles) {
53
53
  if (!allRoleIds.has(roleId)) {
@@ -93,16 +93,16 @@ function defineSchema(config) {
93
93
  }
94
94
  return {
95
95
  _tag: "schema",
96
- ...config.locales && config.locales.length > 0 && { locales: config.locales },
96
+ ...config.locales !== void 0 && { locales: config.locales },
97
97
  contentTypes: config.contentTypes,
98
98
  components: config.components ?? {},
99
99
  singletonContentTypes: config.singletonContentTypes ?? {},
100
100
  queries: config.queries ?? {},
101
101
  settingsGroups: config.settingsGroups,
102
102
  ...config.assetTypes && { assetTypes: config.assetTypes },
103
- ...config.roles && config.roles.length > 0 && { roles: config.roles },
103
+ ...config.roles !== void 0 && { roles: config.roles },
104
104
  ...config.workflow && { workflow: config.workflow },
105
- ...config.views && config.views.length > 0 && { views: config.views }
105
+ ...config.views !== void 0 && { views: config.views }
106
106
  };
107
107
  }
108
108
  __name(defineSchema, "defineSchema");
@@ -135,9 +135,9 @@ function defineLocale(code, options) {
135
135
  code,
136
136
  displayName: options.displayName,
137
137
  ...options.default !== void 0 && { default: options.default },
138
- ...options.fallback && options.fallback.length > 0 && { fallback: options.fallback },
139
- ...options.direction && options.direction !== "ltr" && { direction: options.direction },
140
- ...options.active !== void 0 && options.active !== true && { active: options.active }
138
+ ...options.fallback !== void 0 && { fallback: options.fallback },
139
+ ...options.direction !== void 0 && { direction: options.direction },
140
+ ...options.active !== void 0 && { active: options.active }
141
141
  };
142
142
  }
143
143
  __name(defineLocale, "defineLocale");
@@ -185,6 +185,9 @@ function fieldset(id, config) {
185
185
  id,
186
186
  displayName: config.displayName,
187
187
  description: config.description,
188
+ ...config.collapsedByDefault !== void 0 && {
189
+ collapsedByDefault: config.collapsedByDefault
190
+ },
188
191
  ai: config.ai,
189
192
  fields: config.fields
190
193
  };
@@ -199,8 +202,10 @@ function defineContentType(name, config) {
199
202
  description: config.description,
200
203
  ai: config.ai,
201
204
  displayField: config.displayField,
202
- hierarchical: config.hierarchical ?? false,
203
- ...config.accessTags !== void 0 && config.accessTags.length > 0 && { accessTags: config.accessTags },
205
+ // Written only when given: it was `false` whenever not, so the same content type was one
206
+ // definition from YAML and another from TypeScript, with a different schemaHash (REL-1458)
207
+ ...config.hierarchical !== void 0 && { hierarchical: config.hierarchical },
208
+ ...config.accessTags !== void 0 && { accessTags: config.accessTags },
204
209
  ...config.workflow !== void 0 && { workflow: config.workflow }
205
210
  };
206
211
  if ("fields" in config && config.fields) {
@@ -223,8 +228,11 @@ function defineSingletonContentType(name, config) {
223
228
  description: config.description,
224
229
  ai: config.ai,
225
230
  displayField: config.displayField,
226
- hierarchical: false,
227
- ...config.accessTags !== void 0 && config.accessTags.length > 0 && { accessTags: config.accessTags }
231
+ // Written only when given, as a content type's is (REL-1458)
232
+ ...config.hierarchical !== void 0 && { hierarchical: config.hierarchical },
233
+ ...config.accessTags !== void 0 && { accessTags: config.accessTags },
234
+ // Its config type took `workflow` and this dropped it, so a singleton's workflow never deployed
235
+ ...config.workflow !== void 0 && { workflow: config.workflow }
228
236
  };
229
237
  if ("fields" in config && config.fields) {
230
238
  return { ...base, fields: config.fields };
@@ -245,7 +253,9 @@ function defineComponent(name, config) {
245
253
  displayName: config.displayName,
246
254
  description: config.description,
247
255
  ai: config.ai,
248
- deprecated: config.deprecated ?? false,
256
+ // Written only when given: `false` whenever not made a YAML and a TypeScript component two
257
+ // definitions (REL-1458)
258
+ ...config.deprecated !== void 0 && { deprecated: config.deprecated },
249
259
  fields: config.fields,
250
260
  metadata: config.metadata
251
261
  };
@@ -260,7 +270,7 @@ function defineSettingsGroup(name, config) {
260
270
  displayName: config.displayName,
261
271
  description: config.description,
262
272
  ai: config.ai,
263
- ...config.accessTags !== void 0 && config.accessTags.length > 0 && { accessTags: config.accessTags },
273
+ ...config.accessTags !== void 0 && { accessTags: config.accessTags },
264
274
  fields: config.fields
265
275
  };
266
276
  }
@@ -285,7 +295,8 @@ function defineAssetType(name, config) {
285
295
  description: config.description,
286
296
  ai: config.ai,
287
297
  displayField: config.displayField,
288
- ...config.accessTags !== void 0 && config.accessTags.length > 0 && { accessTags: config.accessTags },
298
+ // An empty list too, as a content type's and a settings group's are kept (REL-1457, REL-1458)
299
+ ...config.accessTags !== void 0 && { accessTags: config.accessTags },
289
300
  ...config.workflow !== void 0 && { workflow: config.workflow },
290
301
  ...config.image !== void 0 && { image: config.image },
291
302
  ...config.video !== void 0 && { video: config.video },
@@ -297,7 +308,7 @@ function defineAssetType(name, config) {
297
308
  if ("fieldsets" in config && config.fieldsets) {
298
309
  return { ...base, fieldsets: config.fieldsets };
299
310
  }
300
- throw new Error(`Asset type '${name}' must have either fields or fieldsets`);
311
+ return base;
301
312
  }
302
313
  __name(defineAssetType, "defineAssetType");
303
314
 
@@ -367,10 +378,10 @@ function defineRole(id, config) {
367
378
  _tag: "role",
368
379
  id,
369
380
  displayName: config.displayName,
370
- ...config.description !== void 0 && config.description !== "" && { description: config.description },
381
+ ...config.description !== void 0 && { description: config.description },
371
382
  ...config.baseRole !== void 0 && { baseRole: config.baseRole },
372
- ...hasIncludes && { includes: config.includes },
373
- ...hasPermissions && { permissions: config.permissions },
383
+ ...config.includes !== void 0 && { includes: config.includes },
384
+ ...config.permissions !== void 0 && { permissions: config.permissions },
374
385
  ...config.fields !== void 0 && { fields: config.fields }
375
386
  };
376
387
  }
@@ -411,8 +422,7 @@ function defineWorkflowStage(id, config) {
411
422
  if (config.description != null && config.description.length > 512) {
412
423
  throw new Error(`Workflow stage description must be 512 characters or less`);
413
424
  }
414
- const requiredApprovals = config.requiredApprovals ?? 1;
415
- if (requiredApprovals < 1 || requiredApprovals > 10) {
425
+ if (config.requiredApprovals !== void 0 && (config.requiredApprovals < 1 || config.requiredApprovals > 10)) {
416
426
  throw new Error(`requiredApprovals must be between 1 and 10`);
417
427
  }
418
428
  if (config.timeoutDays !== void 0) {
@@ -429,9 +439,9 @@ function defineWorkflowStage(id, config) {
429
439
  _tag: "workflowStage",
430
440
  id,
431
441
  displayName: config.displayName,
432
- ...config.description !== void 0 && config.description !== "" && { description: config.description },
433
- requiredApprovals,
434
- ...config.allowedRoles !== void 0 && config.allowedRoles.length > 0 && { allowedRoles: config.allowedRoles },
442
+ ...config.description !== void 0 && { description: config.description },
443
+ ...config.requiredApprovals !== void 0 && { requiredApprovals: config.requiredApprovals },
444
+ ...config.allowedRoles !== void 0 && { allowedRoles: config.allowedRoles },
435
445
  ...config.autoAssign !== void 0 && { autoAssign: config.autoAssign },
436
446
  ...config.timeoutDays !== void 0 && { timeoutDays: config.timeoutDays },
437
447
  ...config.escalation !== void 0 && { escalation: config.escalation }
@@ -439,28 +449,25 @@ function defineWorkflowStage(id, config) {
439
449
  }
440
450
  __name(defineWorkflowStage, "defineWorkflowStage");
441
451
  function defineWorkflow(config) {
442
- const enabled = config.enabled ?? false;
443
- const stages = config.stages ?? [];
444
- if (stages.length > 0) {
445
- const stageIds = /* @__PURE__ */ new Set();
446
- for (const stage of stages) {
447
- if (stageIds.has(stage.id)) {
448
- throw new Error(`Duplicate workflow stage ID '${stage.id}'`);
449
- }
450
- stageIds.add(stage.id);
452
+ const stageIds = /* @__PURE__ */ new Set();
453
+ for (const stage of config.stages ?? []) {
454
+ if (stageIds.has(stage.id)) {
455
+ throw new Error(`Duplicate workflow stage ID '${stage.id}'`);
451
456
  }
457
+ stageIds.add(stage.id);
452
458
  }
453
459
  return {
454
460
  _tag: "workflow",
455
- enabled,
456
- stages
461
+ ...config.enabled !== void 0 && { enabled: config.enabled },
462
+ ...config.stages !== void 0 && { stages: config.stages }
457
463
  };
458
464
  }
459
465
  __name(defineWorkflow, "defineWorkflow");
460
466
  function defineContentTypeWorkflow(config) {
461
467
  return {
462
468
  ...config.enabled !== void 0 && { enabled: config.enabled },
463
- ...config.stages !== void 0 && config.stages.length > 0 && { stages: config.stages },
469
+ // An empty list too, as YAML keeps it (REL-1458)
470
+ ...config.stages !== void 0 && { stages: config.stages },
464
471
  ...config.autoPublish !== void 0 && { autoPublish: config.autoPublish },
465
472
  ...config.requireAllLocales !== void 0 && { requireAllLocales: config.requireAllLocales }
466
473
  };
@@ -474,41 +481,44 @@ function isWorkflowDefinition(value) {
474
481
  return typeof value === "object" && value !== null && "_tag" in value && value._tag === "workflow";
475
482
  }
476
483
  __name(isWorkflowDefinition, "isWorkflowDefinition");
484
+ function stagesOf(workflow) {
485
+ return workflow.stages ?? [];
486
+ }
487
+ __name(stagesOf, "stagesOf");
477
488
  function getWorkflowStageIds(workflow) {
478
- return workflow.stages.map((s) => s.id);
489
+ return stagesOf(workflow).map((s) => s.id);
479
490
  }
480
491
  __name(getWorkflowStageIds, "getWorkflowStageIds");
481
492
  function findWorkflowStage(workflow, stageId) {
482
- return workflow.stages.find((s) => s.id === stageId);
493
+ return stagesOf(workflow).find((s) => s.id === stageId);
483
494
  }
484
495
  __name(findWorkflowStage, "findWorkflowStage");
485
496
  function getNextWorkflowStage(workflow, currentStageId) {
486
- const currentIndex = workflow.stages.findIndex((s) => s.id === currentStageId);
487
- if (currentIndex === -1 || currentIndex === workflow.stages.length - 1) {
497
+ const stages = stagesOf(workflow);
498
+ const currentIndex = stages.findIndex((s) => s.id === currentStageId);
499
+ if (currentIndex === -1 || currentIndex === stages.length - 1) {
488
500
  return null;
489
501
  }
490
- const nextStage = workflow.stages[currentIndex + 1];
502
+ const nextStage = stages[currentIndex + 1];
491
503
  return nextStage ?? null;
492
504
  }
493
505
  __name(getNextWorkflowStage, "getNextWorkflowStage");
494
506
  function getFirstWorkflowStage(workflow) {
495
- if (workflow.stages.length === 0) return null;
496
- const firstStage = workflow.stages[0];
507
+ const stages = stagesOf(workflow);
508
+ if (stages.length === 0) return null;
509
+ const firstStage = stages[0];
497
510
  return firstStage ?? null;
498
511
  }
499
512
  __name(getFirstWorkflowStage, "getFirstWorkflowStage");
500
513
  function isFinalWorkflowStage(workflow, stageId) {
501
- if (workflow.stages.length === 0) return false;
502
- const lastStage = workflow.stages[workflow.stages.length - 1];
514
+ const stages = stagesOf(workflow);
515
+ if (stages.length === 0) return false;
516
+ const lastStage = stages[stages.length - 1];
503
517
  return lastStage?.id === stageId;
504
518
  }
505
519
  __name(isFinalWorkflowStage, "isFinalWorkflowStage");
506
520
 
507
521
  // src/schema/define-view.ts
508
- function generateSlugFromId(id) {
509
- return id.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
510
- }
511
- __name(generateSlugFromId, "generateSlugFromId");
512
522
  function defineView(id, config) {
513
523
  if (!id.match(/^[a-zA-Z][a-zA-Z0-9_-]*$/)) {
514
524
  throw new Error(
@@ -524,16 +534,14 @@ function defineView(id, config) {
524
534
  if (!config.scope?.type) {
525
535
  throw new Error(`View '${id}' must have a valid scope`);
526
536
  }
527
- const slug2 = config.slug ?? generateSlugFromId(id);
528
- if (!slug2.match(/^[a-z][a-z0-9-]*$/)) {
537
+ if (config.slug !== void 0 && !/^[a-z][a-z0-9-]*$/.test(config.slug)) {
529
538
  throw new Error(
530
- `View '${id}' slug '${slug2}' must be lowercase, start with a letter, and contain only letters, numbers, and hyphens`
539
+ `View '${id}' slug '${config.slug}' must be lowercase, start with a letter, and contain only letters, numbers, and hyphens`
531
540
  );
532
541
  }
533
542
  return {
534
543
  _tag: "view",
535
544
  id,
536
- slug: slug2,
537
545
  ...config
538
546
  };
539
547
  }
@@ -541,8 +549,8 @@ __name(defineView, "defineView");
541
549
 
542
550
  // src/schema/define-query.ts
543
551
  function defineQuery(name, config) {
544
- if (!config.fetch && !config.aggregate && !config.search && !config.similar) {
545
- throw new Error("Query must have at least one of: fetch, aggregate, search, or similar");
552
+ if (!config.fetch && !config.aggregate && !config.search) {
553
+ throw new Error("Query must have at least one of: fetch, aggregate or search");
546
554
  }
547
555
  if (!config.endpoint.startsWith("/api/")) {
548
556
  throw new Error("Query endpoint must start with /api/");
@@ -550,14 +558,15 @@ function defineQuery(name, config) {
550
558
  return {
551
559
  _tag: "query",
552
560
  name,
561
+ type: config.type,
553
562
  endpoint: config.endpoint,
554
563
  description: config.description,
555
564
  fetch: config.fetch,
556
565
  aggregate: config.aggregate,
557
566
  search: config.search,
558
- similar: config.similar,
559
567
  include: config.include,
560
568
  filters: config.filters,
569
+ fullText: config.fullText,
561
570
  select: config.select,
562
571
  cache: config.cache,
563
572
  parameters: config.parameters,
@@ -595,7 +604,8 @@ function createField(id, type, options = {}) {
595
604
  ...options.config !== void 0 && { config: options.config },
596
605
  ...options.ui !== void 0 && { ui: options.ui },
597
606
  ...options.ai !== void 0 && { ai: options.ai },
598
- ...options.rules !== void 0 && options.rules.length > 0 && { rules: options.rules },
607
+ // An empty list too: dropping it made a YAML field and a TypeScript one two definitions (REL-1458)
608
+ ...options.rules !== void 0 && { rules: options.rules },
599
609
  ...options.localization !== void 0 && { localization: options.localization },
600
610
  ...options.fallback !== void 0 && { fallback: options.fallback },
601
611
  ...options.deprecated !== void 0 && { deprecated: options.deprecated }
@@ -672,5 +682,5 @@ __name(component, "component");
672
682
  var fields = fields_exports;
673
683
 
674
684
  export { BUILT_IN_ROLES, BUILT_IN_ROLE_ACTIONS, ROLE_ACTIONS, buildFallbackChain, defineAssetType, defineComponent, defineContentType, defineContentTypeWorkflow, defineLocale, defineQuery, defineRole, defineSchema, defineSettingsGroup, defineSingleton, defineSingletonContentType, defineView, defineWorkflow, defineWorkflowStage, fields, fieldset, findDefaultLocale, findWorkflowStage, getActiveLocales, getBuiltInRoleActions, getFirstWorkflowStage, getLocaleCodes, getNextWorkflowStage, getWorkflowStageIds, isBuiltInRole, isFinalWorkflowStage, isLocaleDefinition, isRoleDefinition, isWorkflowDefinition, isWorkflowStageDefinition };
675
- //# sourceMappingURL=chunk-XJVY2CLY.js.map
676
- //# sourceMappingURL=chunk-XJVY2CLY.js.map
685
+ //# sourceMappingURL=chunk-YEJUMW4X.js.map
686
+ //# sourceMappingURL=chunk-YEJUMW4X.js.map
@@ -1,18 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkGCMQUM6N_cjs = require('../chunk-GCMQUM6N.cjs');
3
+ var chunkXIE7WJV3_cjs = require('../chunk-XIE7WJV3.cjs');
4
4
  require('../chunk-LSRPMNPT.cjs');
5
+ require('../chunk-TZL374LS.cjs');
5
6
  require('../chunk-MWMSFIWN.cjs');
6
7
 
7
8
 
8
9
 
9
10
  Object.defineProperty(exports, "TypedRelyIOClient", {
10
11
  enumerable: true,
11
- get: function () { return chunkGCMQUM6N_cjs.TypedRelyIOClient; }
12
+ get: function () { return chunkXIE7WJV3_cjs.TypedRelyIOClient; }
12
13
  });
13
14
  Object.defineProperty(exports, "createClient", {
14
15
  enumerable: true,
15
- get: function () { return chunkGCMQUM6N_cjs.createClient; }
16
+ get: function () { return chunkXIE7WJV3_cjs.createClient; }
16
17
  });
17
18
  //# sourceMappingURL=index.cjs.map
18
19
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,6 @@
1
- export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-Df1VsfJR.cjs';
2
- import '../index-d1Kz1e19.cjs';
3
- import '../define-content-type-CDB3kyeA.cjs';
4
- import '../define-schema-1kr2HIzN.cjs';
1
+ export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-DBoPPlT1.cjs';
2
+ import '../index-B_rIWO_l.cjs';
3
+ import '../define-content-type-cEGjIwT5.cjs';
4
+ import '../define-schema-DgbJ5Kwn.cjs';
5
+ import './live-visitor.js';
5
6
  import '../dev-handshake/index.cjs';
@@ -1,5 +1,6 @@
1
- export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-XqoGUaAY.js';
2
- import '../index-yPbhZc6q.js';
3
- import '../define-content-type-CDB3kyeA.js';
4
- import '../define-schema-ChvAzY8H.js';
1
+ export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-yRJ2IqM_.js';
2
+ import '../index-Cv4tmcrw.js';
3
+ import '../define-content-type-cEGjIwT5.js';
4
+ import '../define-schema-BPj2srgh.js';
5
+ import './live-visitor.js';
5
6
  import '../dev-handshake/index.js';
@@ -1,5 +1,6 @@
1
- export { TypedRelyIOClient, createClient } from '../chunk-7ABNXVWL.js';
1
+ export { TypedRelyIOClient, createClient } from '../chunk-QFHVF3YF.js';
2
2
  import '../chunk-BBUB7C2Z.js';
3
+ import '../chunk-H6IBQSMM.js';
3
4
  import '../chunk-XQ4QHWZE.js';
4
5
  //# sourceMappingURL=index.js.map
5
6
  //# sourceMappingURL=index.js.map