@relyio/sdk 0.2.1 → 0.3.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 (35) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/{chunk-7W4MJXQ4.cjs → chunk-54WP2PWG.cjs} +215 -96
  4. package/dist/chunk-BBUB7C2Z.js +81 -0
  5. package/dist/{chunk-FJK7ZWKK.cjs → chunk-HMVGXUGR.cjs} +156 -221
  6. package/dist/chunk-LSRPMNPT.cjs +89 -0
  7. package/dist/{chunk-2QUK2ZGD.js → chunk-LYRYCIX5.js} +157 -219
  8. package/dist/{chunk-RJBIJ2ZK.js → chunk-QIZOBT5F.js} +215 -96
  9. package/dist/client/index.cjs +4 -3
  10. package/dist/client/index.d.cts +4 -3
  11. package/dist/client/index.d.ts +4 -3
  12. package/dist/client/index.js +2 -1
  13. package/dist/define-content-type-CBfnTWSS.d.cts +716 -0
  14. package/dist/define-content-type-CBfnTWSS.d.ts +716 -0
  15. package/dist/{define-schema-DHvUCKwj.d.cts → define-schema-BD6HSPnG.d.ts} +55 -722
  16. package/dist/{define-schema-DHvUCKwj.d.ts → define-schema-BfXeR6K8.d.cts} +55 -722
  17. package/dist/dev-handshake/index.cjs +37 -0
  18. package/dist/dev-handshake/index.d.cts +144 -0
  19. package/dist/dev-handshake/index.d.ts +144 -0
  20. package/dist/dev-handshake/index.js +4 -0
  21. package/dist/{index-DGWaawHt.d.cts → index-BDpar3FO.d.cts} +22 -6
  22. package/dist/{index-BsUqCAu8.d.cts → index-DuEhsGdE.d.ts} +516 -2155
  23. package/dist/{index-B-KiFHbx.d.ts → index-Dx01iwaf.d.ts} +22 -6
  24. package/dist/{index-BsUqCAu8.d.ts → index-ulOrcfPa.d.cts} +516 -2155
  25. package/dist/index.cjs +67 -70
  26. package/dist/index.d.cts +28 -13
  27. package/dist/index.d.ts +28 -13
  28. package/dist/index.js +3 -2
  29. package/dist/schema/index.cjs +35 -47
  30. package/dist/schema/index.d.cts +3 -2
  31. package/dist/schema/index.d.ts +3 -2
  32. package/dist/schema/index.js +1 -1
  33. package/dist/types/index.d.cts +2 -1
  34. package/dist/types/index.d.ts +2 -1
  35. package/package.json +11 -5
@@ -2,174 +2,6 @@ import { __name, __export } from './chunk-XQ4QHWZE.js';
2
2
 
3
3
  /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
4
4
 
5
- // src/schema/define-workflow.ts
6
- function defineWorkflowStage(id, config) {
7
- if (!id || id.length === 0) {
8
- throw new Error("Workflow stage ID is required");
9
- }
10
- const stageIdPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$|^[a-z][a-zA-Z0-9]*$/;
11
- if (!stageIdPattern.test(id)) {
12
- throw new Error(
13
- `Workflow stage ID '${id}' must be kebab-case (e.g., editorial-review) or camelCase (e.g., editorialReview)`
14
- );
15
- }
16
- if (id.length > 64) {
17
- throw new Error(`Workflow stage ID '${id}' must be 64 characters or less`);
18
- }
19
- if (!config.displayName || config.displayName.length === 0) {
20
- throw new Error("Workflow stage displayName is required");
21
- }
22
- if (config.displayName.length > 128) {
23
- throw new Error(`Workflow stage displayName must be 128 characters or less`);
24
- }
25
- if (config.description != null && config.description.length > 512) {
26
- throw new Error(`Workflow stage description must be 512 characters or less`);
27
- }
28
- const requiredApprovals = config.requiredApprovals ?? 1;
29
- if (requiredApprovals < 1 || requiredApprovals > 10) {
30
- throw new Error(`requiredApprovals must be between 1 and 10`);
31
- }
32
- if (config.timeoutDays !== void 0) {
33
- if (config.timeoutDays < 1 || config.timeoutDays > 365) {
34
- throw new Error(`timeoutDays must be between 1 and 365`);
35
- }
36
- }
37
- if (config.autoAssign) {
38
- if (!Array.isArray(config.autoAssign.roles) || config.autoAssign.roles.length === 0) {
39
- throw new Error(`autoAssign.roles must be a non-empty array`);
40
- }
41
- }
42
- return {
43
- _tag: "workflowStage",
44
- id,
45
- displayName: config.displayName,
46
- ...config.description !== void 0 && config.description !== "" && { description: config.description },
47
- requiredApprovals,
48
- ...config.allowedRoles !== void 0 && config.allowedRoles.length > 0 && { allowedRoles: config.allowedRoles },
49
- ...config.autoAssign !== void 0 && { autoAssign: config.autoAssign },
50
- ...config.timeoutDays !== void 0 && { timeoutDays: config.timeoutDays },
51
- ...config.escalation !== void 0 && { escalation: config.escalation }
52
- };
53
- }
54
- __name(defineWorkflowStage, "defineWorkflowStage");
55
- function defineWorkflow(config) {
56
- const enabled = config.enabled ?? false;
57
- const stages = config.stages ?? [];
58
- if (stages.length > 0) {
59
- const stageIds = /* @__PURE__ */ new Set();
60
- for (const stage of stages) {
61
- if (stageIds.has(stage.id)) {
62
- throw new Error(`Duplicate workflow stage ID '${stage.id}'`);
63
- }
64
- stageIds.add(stage.id);
65
- }
66
- }
67
- return {
68
- _tag: "workflow",
69
- enabled,
70
- stages
71
- };
72
- }
73
- __name(defineWorkflow, "defineWorkflow");
74
- function defineContentTypeWorkflow(config) {
75
- return {
76
- ...config.enabled !== void 0 && { enabled: config.enabled },
77
- ...config.stages !== void 0 && config.stages.length > 0 && { stages: config.stages },
78
- ...config.autoPublish !== void 0 && { autoPublish: config.autoPublish },
79
- ...config.requireAllLocales !== void 0 && { requireAllLocales: config.requireAllLocales }
80
- };
81
- }
82
- __name(defineContentTypeWorkflow, "defineContentTypeWorkflow");
83
- function isWorkflowStageDefinition(value) {
84
- return typeof value === "object" && value !== null && "_tag" in value && value._tag === "workflowStage";
85
- }
86
- __name(isWorkflowStageDefinition, "isWorkflowStageDefinition");
87
- function isWorkflowDefinition(value) {
88
- return typeof value === "object" && value !== null && "_tag" in value && value._tag === "workflow";
89
- }
90
- __name(isWorkflowDefinition, "isWorkflowDefinition");
91
- function getWorkflowStageIds(workflow) {
92
- return workflow.stages.map((s) => s.id);
93
- }
94
- __name(getWorkflowStageIds, "getWorkflowStageIds");
95
- function findWorkflowStage(workflow, stageId) {
96
- return workflow.stages.find((s) => s.id === stageId);
97
- }
98
- __name(findWorkflowStage, "findWorkflowStage");
99
- function getNextWorkflowStage(workflow, currentStageId) {
100
- const currentIndex = workflow.stages.findIndex((s) => s.id === currentStageId);
101
- if (currentIndex === -1 || currentIndex === workflow.stages.length - 1) {
102
- return null;
103
- }
104
- const nextStage = workflow.stages[currentIndex + 1];
105
- return nextStage ?? null;
106
- }
107
- __name(getNextWorkflowStage, "getNextWorkflowStage");
108
- function getFirstWorkflowStage(workflow) {
109
- if (workflow.stages.length === 0) return null;
110
- const firstStage = workflow.stages[0];
111
- return firstStage ?? null;
112
- }
113
- __name(getFirstWorkflowStage, "getFirstWorkflowStage");
114
- function isFinalWorkflowStage(workflow, stageId) {
115
- if (workflow.stages.length === 0) return false;
116
- const lastStage = workflow.stages[workflow.stages.length - 1];
117
- return lastStage?.id === stageId;
118
- }
119
- __name(isFinalWorkflowStage, "isFinalWorkflowStage");
120
- function workflowToJSON(workflow) {
121
- return {
122
- enabled: workflow.enabled,
123
- ...workflow.stages.length > 0 && {
124
- stages: workflow.stages.map((stage) => {
125
- const { _tag: _, ...rest } = stage;
126
- return rest;
127
- })
128
- }
129
- };
130
- }
131
- __name(workflowToJSON, "workflowToJSON");
132
-
133
- // src/schema/define-view.ts
134
- function generateSlugFromId(id) {
135
- return id.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
136
- }
137
- __name(generateSlugFromId, "generateSlugFromId");
138
- function defineView(id, config) {
139
- if (!id.match(/^[a-zA-Z][a-zA-Z0-9_-]*$/)) {
140
- throw new Error(
141
- `View ID '${id}' must start with a letter and contain only letters, numbers, underscores, and hyphens`
142
- );
143
- }
144
- if (!config.name || config.name.length === 0) {
145
- throw new Error(`View '${id}' must have a name`);
146
- }
147
- if (config.metadataFields && config.metadataFields.length > 3) {
148
- throw new Error(`View '${id}' can have at most 3 metadata fields`);
149
- }
150
- if (!config.scope?.type) {
151
- throw new Error(`View '${id}' must have a valid scope`);
152
- }
153
- const slug2 = config.slug ?? generateSlugFromId(id);
154
- if (!slug2.match(/^[a-z][a-z0-9-]*$/)) {
155
- throw new Error(
156
- `View '${id}' slug '${slug2}' must be lowercase, start with a letter, and contain only letters, numbers, and hyphens`
157
- );
158
- }
159
- return {
160
- _tag: "view",
161
- id,
162
- slug: slug2,
163
- ...config
164
- };
165
- }
166
- __name(defineView, "defineView");
167
- function viewToJSON(view) {
168
- const { _tag, ...rest } = view;
169
- return rest;
170
- }
171
- __name(viewToJSON, "viewToJSON");
172
-
173
5
  // src/schema/define-schema.ts
174
6
  function defineSchema(config) {
175
7
  if (config.contentTypes == null || Object.keys(config.contentTypes).length === 0) {
@@ -274,53 +106,6 @@ function defineSchema(config) {
274
106
  };
275
107
  }
276
108
  __name(defineSchema, "defineSchema");
277
- function schemaToJSON(schema) {
278
- const stripTag = /* @__PURE__ */ __name((obj) => {
279
- const { _tag, ...rest } = obj;
280
- return rest;
281
- }, "stripTag");
282
- return {
283
- // Include locales if defined (strip _tag from each locale)
284
- ...schema.locales && schema.locales.length > 0 && {
285
- locales: schema.locales.map((locale) => stripTag(locale))
286
- },
287
- contentTypes: Object.fromEntries(
288
- Object.entries(schema.contentTypes).map(([key, value]) => [key, stripTag(value)])
289
- ),
290
- components: Object.fromEntries(
291
- Object.entries(schema.components).map(([key, value]) => [key, stripTag(value)])
292
- ),
293
- singletonContentTypes: Object.fromEntries(
294
- Object.entries(schema.singletonContentTypes).map(([key, value]) => [key, stripTag(value)])
295
- ),
296
- queries: Object.fromEntries(
297
- Object.entries(schema.queries).map(([key, value]) => [key, stripTag(value)])
298
- ),
299
- ...schema.settingsGroups && {
300
- settingsGroups: Object.fromEntries(
301
- Object.entries(schema.settingsGroups).map(([key, value]) => [key, stripTag(value)])
302
- )
303
- },
304
- ...schema.assetTypes && Object.keys(schema.assetTypes).length > 0 && {
305
- assetTypes: Object.fromEntries(
306
- Object.entries(schema.assetTypes).map(([key, value]) => [key, stripTag(value)])
307
- )
308
- },
309
- // Include roles if defined (strip _tag from each role)
310
- ...schema.roles && schema.roles.length > 0 && {
311
- roles: schema.roles.map((role) => stripTag(role))
312
- },
313
- // Include workflow if defined (convert to JSON format)
314
- ...schema.workflow && {
315
- workflow: workflowToJSON(schema.workflow)
316
- },
317
- // Include views if defined (convert to JSON format)
318
- ...schema.views && schema.views.length > 0 && {
319
- views: schema.views.map((view) => viewToJSON(view))
320
- }
321
- };
322
- }
323
- __name(schemaToJSON, "schemaToJSON");
324
109
 
325
110
  // src/schema/define-locale.ts
326
111
  var BCP47_PATTERN = /^[a-z]{2}(-[A-Z]{2})?$/;
@@ -603,6 +388,157 @@ function getBuiltInRoleActions(roleId) {
603
388
  }
604
389
  __name(getBuiltInRoleActions, "getBuiltInRoleActions");
605
390
 
391
+ // src/schema/define-workflow.ts
392
+ function defineWorkflowStage(id, config) {
393
+ if (!id || id.length === 0) {
394
+ throw new Error("Workflow stage ID is required");
395
+ }
396
+ const stageIdPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$|^[a-z][a-zA-Z0-9]*$/;
397
+ if (!stageIdPattern.test(id)) {
398
+ throw new Error(
399
+ `Workflow stage ID '${id}' must be kebab-case (e.g., editorial-review) or camelCase (e.g., editorialReview)`
400
+ );
401
+ }
402
+ if (id.length > 64) {
403
+ throw new Error(`Workflow stage ID '${id}' must be 64 characters or less`);
404
+ }
405
+ if (!config.displayName || config.displayName.length === 0) {
406
+ throw new Error("Workflow stage displayName is required");
407
+ }
408
+ if (config.displayName.length > 128) {
409
+ throw new Error(`Workflow stage displayName must be 128 characters or less`);
410
+ }
411
+ if (config.description != null && config.description.length > 512) {
412
+ throw new Error(`Workflow stage description must be 512 characters or less`);
413
+ }
414
+ const requiredApprovals = config.requiredApprovals ?? 1;
415
+ if (requiredApprovals < 1 || requiredApprovals > 10) {
416
+ throw new Error(`requiredApprovals must be between 1 and 10`);
417
+ }
418
+ if (config.timeoutDays !== void 0) {
419
+ if (config.timeoutDays < 1 || config.timeoutDays > 365) {
420
+ throw new Error(`timeoutDays must be between 1 and 365`);
421
+ }
422
+ }
423
+ if (config.autoAssign) {
424
+ if (!Array.isArray(config.autoAssign.roles) || config.autoAssign.roles.length === 0) {
425
+ throw new Error(`autoAssign.roles must be a non-empty array`);
426
+ }
427
+ }
428
+ return {
429
+ _tag: "workflowStage",
430
+ id,
431
+ 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 },
435
+ ...config.autoAssign !== void 0 && { autoAssign: config.autoAssign },
436
+ ...config.timeoutDays !== void 0 && { timeoutDays: config.timeoutDays },
437
+ ...config.escalation !== void 0 && { escalation: config.escalation }
438
+ };
439
+ }
440
+ __name(defineWorkflowStage, "defineWorkflowStage");
441
+ 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);
451
+ }
452
+ }
453
+ return {
454
+ _tag: "workflow",
455
+ enabled,
456
+ stages
457
+ };
458
+ }
459
+ __name(defineWorkflow, "defineWorkflow");
460
+ function defineContentTypeWorkflow(config) {
461
+ return {
462
+ ...config.enabled !== void 0 && { enabled: config.enabled },
463
+ ...config.stages !== void 0 && config.stages.length > 0 && { stages: config.stages },
464
+ ...config.autoPublish !== void 0 && { autoPublish: config.autoPublish },
465
+ ...config.requireAllLocales !== void 0 && { requireAllLocales: config.requireAllLocales }
466
+ };
467
+ }
468
+ __name(defineContentTypeWorkflow, "defineContentTypeWorkflow");
469
+ function isWorkflowStageDefinition(value) {
470
+ return typeof value === "object" && value !== null && "_tag" in value && value._tag === "workflowStage";
471
+ }
472
+ __name(isWorkflowStageDefinition, "isWorkflowStageDefinition");
473
+ function isWorkflowDefinition(value) {
474
+ return typeof value === "object" && value !== null && "_tag" in value && value._tag === "workflow";
475
+ }
476
+ __name(isWorkflowDefinition, "isWorkflowDefinition");
477
+ function getWorkflowStageIds(workflow) {
478
+ return workflow.stages.map((s) => s.id);
479
+ }
480
+ __name(getWorkflowStageIds, "getWorkflowStageIds");
481
+ function findWorkflowStage(workflow, stageId) {
482
+ return workflow.stages.find((s) => s.id === stageId);
483
+ }
484
+ __name(findWorkflowStage, "findWorkflowStage");
485
+ function getNextWorkflowStage(workflow, currentStageId) {
486
+ const currentIndex = workflow.stages.findIndex((s) => s.id === currentStageId);
487
+ if (currentIndex === -1 || currentIndex === workflow.stages.length - 1) {
488
+ return null;
489
+ }
490
+ const nextStage = workflow.stages[currentIndex + 1];
491
+ return nextStage ?? null;
492
+ }
493
+ __name(getNextWorkflowStage, "getNextWorkflowStage");
494
+ function getFirstWorkflowStage(workflow) {
495
+ if (workflow.stages.length === 0) return null;
496
+ const firstStage = workflow.stages[0];
497
+ return firstStage ?? null;
498
+ }
499
+ __name(getFirstWorkflowStage, "getFirstWorkflowStage");
500
+ function isFinalWorkflowStage(workflow, stageId) {
501
+ if (workflow.stages.length === 0) return false;
502
+ const lastStage = workflow.stages[workflow.stages.length - 1];
503
+ return lastStage?.id === stageId;
504
+ }
505
+ __name(isFinalWorkflowStage, "isFinalWorkflowStage");
506
+
507
+ // 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
+ function defineView(id, config) {
513
+ if (!id.match(/^[a-zA-Z][a-zA-Z0-9_-]*$/)) {
514
+ throw new Error(
515
+ `View ID '${id}' must start with a letter and contain only letters, numbers, underscores, and hyphens`
516
+ );
517
+ }
518
+ if (!config.name || config.name.length === 0) {
519
+ throw new Error(`View '${id}' must have a name`);
520
+ }
521
+ if (config.metadataFields && config.metadataFields.length > 3) {
522
+ throw new Error(`View '${id}' can have at most 3 metadata fields`);
523
+ }
524
+ if (!config.scope?.type) {
525
+ throw new Error(`View '${id}' must have a valid scope`);
526
+ }
527
+ const slug2 = config.slug ?? generateSlugFromId(id);
528
+ if (!slug2.match(/^[a-z][a-z0-9-]*$/)) {
529
+ throw new Error(
530
+ `View '${id}' slug '${slug2}' must be lowercase, start with a letter, and contain only letters, numbers, and hyphens`
531
+ );
532
+ }
533
+ return {
534
+ _tag: "view",
535
+ id,
536
+ slug: slug2,
537
+ ...config
538
+ };
539
+ }
540
+ __name(defineView, "defineView");
541
+
606
542
  // src/schema/define-query.ts
607
543
  function defineQuery(name, config) {
608
544
  if (!config.fetch && !config.aggregate && !config.search && !config.similar) {
@@ -623,7 +559,9 @@ function defineQuery(name, config) {
623
559
  include: config.include,
624
560
  filters: config.filters,
625
561
  select: config.select,
626
- cache: config.cache
562
+ cache: config.cache,
563
+ parameters: config.parameters,
564
+ cardinality: config.cardinality
627
565
  };
628
566
  }
629
567
  __name(defineQuery, "defineQuery");
@@ -733,6 +671,6 @@ __name(component, "component");
733
671
  // src/schema/index.ts
734
672
  var fields = fields_exports;
735
673
 
736
- 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, schemaToJSON, viewToJSON, workflowToJSON };
737
- //# sourceMappingURL=chunk-2QUK2ZGD.js.map
738
- //# sourceMappingURL=chunk-2QUK2ZGD.js.map
674
+ 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-LYRYCIX5.js.map
676
+ //# sourceMappingURL=chunk-LYRYCIX5.js.map