@appsemble/utils 0.30.14-test.6 → 0.32.1-test.15

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 (171) hide show
  1. package/README.md +3 -3
  2. package/allActions.js +5 -3
  3. package/api/components/parameters/$orderby.js +2 -2
  4. package/api/components/parameters/index.d.ts +2 -1
  5. package/api/components/parameters/index.js +2 -1
  6. package/api/components/parameters/webhookName.d.ts +2 -0
  7. package/api/components/parameters/webhookName.js +10 -0
  8. package/api/components/parameters/webhookSecretId.d.ts +2 -0
  9. package/api/components/parameters/webhookSecretId.js +8 -0
  10. package/api/components/schemas/ActionDefinition.js +3 -0
  11. package/api/components/schemas/App.js +8 -0
  12. package/api/components/schemas/AppDefinition.js +6 -0
  13. package/api/components/schemas/AppLayoutDefinition.js +8 -0
  14. package/api/components/schemas/AppServiceSecret.js +5 -0
  15. package/api/components/schemas/AppWebhookSecret.d.ts +2 -0
  16. package/api/components/schemas/AppWebhookSecret.js +25 -0
  17. package/api/components/schemas/DialogOkActionDefinition.js +1 -1
  18. package/api/components/schemas/FilterParametersDefinition.d.ts +2 -0
  19. package/api/components/schemas/FilterParametersDefinition.js +15 -0
  20. package/api/components/schemas/FlowCancelActionDefinition.js +1 -1
  21. package/api/components/schemas/FlowFinishActionDefinition.js +1 -1
  22. package/api/components/schemas/GroupMemberDeleteActionDefinition.js +1 -1
  23. package/api/components/schemas/ResourceDefinition.js +5 -0
  24. package/api/components/schemas/ResourceDeleteAllActionDefinition.d.ts +1 -0
  25. package/api/components/schemas/ResourceDeleteAllActionDefinition.js +21 -0
  26. package/api/components/schemas/ResourceDeleteBulkActionDefinition.d.ts +1 -0
  27. package/api/components/schemas/ResourceDeleteBulkActionDefinition.js +18 -0
  28. package/api/components/schemas/ResourceGetActionDefinition.js +3 -0
  29. package/api/components/schemas/ResourcePatchActionDefinition.js +3 -0
  30. package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.js +1 -0
  31. package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.js +1 -0
  32. package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.js +1 -0
  33. package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.js +1 -0
  34. package/api/components/schemas/ResourceUpdatePositionsActionDefinition.d.ts +1 -0
  35. package/api/components/schemas/ResourceUpdatePositionsActionDefinition.js +21 -0
  36. package/api/components/schemas/SecurityCronDefinition.d.ts +2 -0
  37. package/api/components/schemas/SecurityCronDefinition.js +26 -0
  38. package/api/components/schemas/SecurityDefinition.js +1 -0
  39. package/api/components/schemas/StorageSubtractActionDefinition.js +2 -2
  40. package/api/components/schemas/Training.js +2 -25
  41. package/api/components/schemas/TrainingCompleted.d.ts +2 -0
  42. package/api/components/schemas/TrainingCompleted.js +17 -0
  43. package/api/components/schemas/WebhookDefinition.d.ts +2 -0
  44. package/api/components/schemas/WebhookDefinition.js +17 -0
  45. package/api/components/schemas/index.d.ts +8 -1
  46. package/api/components/schemas/index.js +8 -1
  47. package/api/components/schemas/utils.js +1 -1
  48. package/api/components/securitySchemes/index.d.ts +1 -0
  49. package/api/components/securitySchemes/index.js +1 -0
  50. package/api/components/securitySchemes/webhook.d.ts +2 -0
  51. package/api/components/securitySchemes/webhook.js +6 -0
  52. package/api/paths/apps/appId/resources/resourceType/resourceId/positions.js +54 -0
  53. package/api/paths/apps/appId/secrets/webhook/secretId.js +61 -0
  54. package/api/paths/apps/appId/secrets/webhook.js +44 -0
  55. package/api/paths/apps/appId/webhooks/webhookName.js +35 -0
  56. package/api/paths/apps/appId.js +6 -0
  57. package/api/paths/auth/email/patchPassword.js +30 -0
  58. package/api/paths/index.d.ts +7 -5
  59. package/api/paths/index.js +16 -12
  60. package/api/paths/trainings/completeTraining.js +18 -0
  61. package/api/paths/trainings/completedTrainings.d.ts +2 -0
  62. package/api/paths/trainings/completedTrainings.js +21 -0
  63. package/api/paths/trainings/trainingIds.d.ts +2 -0
  64. package/api/paths/trainings/trainingIds.js +20 -0
  65. package/api/tags/index.js +4 -4
  66. package/appMessages.js +1 -1
  67. package/assets.js +1 -1
  68. package/authorization.d.ts +1 -1
  69. package/authorization.js +1 -1
  70. package/blockUtils.d.ts +1 -1
  71. package/blockUtils.js +1 -0
  72. package/convertToCsv.js +2 -0
  73. package/examples.js +214 -4
  74. package/formatRequestAction.js +2 -2
  75. package/has.d.ts +1 -1
  76. package/has.js +1 -1
  77. package/i18n.js +6 -8
  78. package/ics.js +1 -1
  79. package/iterApp.js +3 -3
  80. package/jsonschema.js +16 -3
  81. package/package.json +15 -11
  82. package/reference-schemas/actions/appMember.d.ts +2 -0
  83. package/reference-schemas/actions/appMember.js +21 -0
  84. package/reference-schemas/actions/flow.d.ts +2 -0
  85. package/reference-schemas/actions/flow.js +13 -0
  86. package/reference-schemas/actions/group.d.ts +2 -0
  87. package/reference-schemas/actions/group.js +13 -0
  88. package/reference-schemas/actions/index.d.ts +7 -0
  89. package/reference-schemas/actions/index.js +8 -0
  90. package/reference-schemas/actions/link.d.ts +2 -0
  91. package/reference-schemas/actions/link.js +9 -0
  92. package/reference-schemas/actions/miscellaneous.d.ts +2 -0
  93. package/reference-schemas/actions/miscellaneous.js +41 -0
  94. package/reference-schemas/actions/resources.d.ts +2 -0
  95. package/reference-schemas/actions/resources.js +19 -0
  96. package/reference-schemas/actions/storage.d.ts +2 -0
  97. package/reference-schemas/actions/storage.js +15 -0
  98. package/reference-schemas/remappers/conditionals.js +39 -0
  99. package/reference-schemas/remappers/data.js +26 -2
  100. package/reference-schemas/remappers/index.d.ts +1 -0
  101. package/reference-schemas/remappers/index.js +1 -0
  102. package/reference-schemas/remappers/objects.js +32 -0
  103. package/reference-schemas/remappers/odata.d.ts +2 -0
  104. package/reference-schemas/remappers/odata.js +95 -0
  105. package/reference-schemas/remappers/strings.js +33 -0
  106. package/reference-schemas/remappers/unsorted.js +9 -0
  107. package/remap.d.ts +2 -0
  108. package/remap.js +192 -15
  109. package/serializeResource.d.ts +7 -0
  110. package/serializeResource.js +7 -0
  111. package/serverActions.d.ts +1 -1
  112. package/serverActions.js +2 -0
  113. package/theme.js +5 -1
  114. package/validateStyle.js +2 -0
  115. package/validation.js +52 -16
  116. package/api/components/parameters/trainingBlockId.d.ts +0 -2
  117. package/api/components/parameters/trainingBlockId.js +0 -8
  118. package/api/components/schemas/TrainingBlock.d.ts +0 -2
  119. package/api/components/schemas/TrainingBlock.js +0 -38
  120. package/api/components/securitySchemes/cli.test.d.ts +0 -1
  121. package/api/components/securitySchemes/cli.test.js +0 -7
  122. package/api/index.test.d.ts +0 -1
  123. package/api/index.test.js +0 -180
  124. package/api/paths/trainingBlocks/trainingBlockId.js +0 -41
  125. package/api/paths/trainings/trainingId/blocks.js +0 -51
  126. package/api/paths/trainings/trainingId/users/current.js +0 -62
  127. package/api/paths/trainings/trainingId/users.js +0 -25
  128. package/api/paths/trainings/trainingId.js +0 -85
  129. package/api/paths/trainings.js +0 -44
  130. package/appMessages.test.d.ts +0 -1
  131. package/appMessages.test.js +0 -409
  132. package/blockUtils.test.d.ts +0 -1
  133. package/blockUtils.test.js +0 -77
  134. package/constants/patterns.test.d.ts +0 -1
  135. package/constants/patterns.test.js +0 -83
  136. package/convertToCsv.test.d.ts +0 -1
  137. package/convertToCsv.test.js +0 -55
  138. package/has.test.d.ts +0 -1
  139. package/has.test.js +0 -17
  140. package/i18n.test.d.ts +0 -1
  141. package/i18n.test.js +0 -76
  142. package/iterApp.test.d.ts +0 -1
  143. package/iterApp.test.js +0 -439
  144. package/jsonschema.test.d.ts +0 -1
  145. package/jsonschema.test.js +0 -256
  146. package/mapValues.test.d.ts +0 -1
  147. package/mapValues.test.js +0 -16
  148. package/miscellaneous.test.d.ts +0 -1
  149. package/miscellaneous.test.js +0 -87
  150. package/normalize.test.d.ts +0 -1
  151. package/normalize.test.js +0 -23
  152. package/objectCache.test.d.ts +0 -1
  153. package/objectCache.test.js +0 -20
  154. package/prefix.test.d.ts +0 -1
  155. package/prefix.test.js +0 -11
  156. package/remap.test.d.ts +0 -1
  157. package/remap.test.js +0 -1387
  158. package/string.test.d.ts +0 -1
  159. package/string.test.js +0 -27
  160. package/theme.test.d.ts +0 -1
  161. package/theme.test.js +0 -91
  162. package/validateStyle.test.d.ts +0 -1
  163. package/validateStyle.test.js +0 -13
  164. package/validation.test.d.ts +0 -1
  165. package/validation.test.js +0 -3121
  166. /package/api/paths/{trainingBlocks/trainingBlockId.d.ts → apps/appId/resources/resourceType/resourceId/positions.d.ts} +0 -0
  167. /package/api/paths/{trainings/trainingId.d.ts → apps/appId/secrets/webhook/secretId.d.ts} +0 -0
  168. /package/api/paths/{trainings.d.ts → apps/appId/secrets/webhook.d.ts} +0 -0
  169. /package/api/paths/{trainings/trainingId/blocks.d.ts → apps/appId/webhooks/webhookName.d.ts} +0 -0
  170. /package/api/paths/{trainings/trainingId/users.d.ts → auth/email/patchPassword.d.ts} +0 -0
  171. /package/api/paths/trainings/{trainingId/users/current.d.ts → completeTraining.d.ts} +0 -0
package/examples.js CHANGED
@@ -52,6 +52,12 @@ export const examples = {
52
52
  item: {
53
53
  array: 'item',
54
54
  },
55
+ prevItem: {
56
+ array: 'prevItem',
57
+ },
58
+ nextItem: {
59
+ array: 'nextItem',
60
+ },
55
61
  },
56
62
  },
57
63
  },
@@ -60,19 +66,30 @@ export const examples = {
60
66
  index: 0,
61
67
  length: 3,
62
68
  item: 'a',
69
+ prevItem: undefined,
70
+ nextItem: 'b',
63
71
  },
64
72
  {
65
73
  index: 1,
66
74
  length: 3,
67
75
  item: 'b',
76
+ prevItem: 'a',
77
+ nextItem: 'c',
68
78
  },
69
79
  {
70
80
  index: 2,
71
81
  length: 3,
72
82
  item: 'c',
83
+ prevItem: 'b',
84
+ nextItem: undefined,
73
85
  },
74
86
  ],
75
87
  },
88
+ len: {
89
+ input: 'string',
90
+ remapper: { len: null },
91
+ result: 6,
92
+ },
76
93
  'array.append': {
77
94
  input: [
78
95
  {
@@ -516,6 +533,16 @@ export const examples = {
516
533
  remapper: { not: [{ prop: 'number' }, 4] },
517
534
  result: true,
518
535
  },
536
+ and: {
537
+ input: { foo: true },
538
+ remapper: { and: [{ prop: 'foo' }, true] },
539
+ result: true,
540
+ },
541
+ or: {
542
+ input: { foo: true },
543
+ remapper: { or: [{ prop: 'foo' }, false] },
544
+ result: true,
545
+ },
519
546
  'null.strip': {
520
547
  input: null,
521
548
  remapper: {},
@@ -570,6 +597,64 @@ export const examples = {
570
597
  title: 'Weekly fishing 21',
571
598
  },
572
599
  },
600
+ 'object.compare': {
601
+ input: { name: 'Alice' },
602
+ remapper: {
603
+ 'object.compare': [
604
+ {
605
+ 'object.from': {
606
+ name: { prop: 'name' },
607
+ age: 25,
608
+ address: {
609
+ 'object.from': {
610
+ city: 'Paris',
611
+ zip: 7500,
612
+ },
613
+ },
614
+ },
615
+ },
616
+ {
617
+ 'object.from': {
618
+ name: 'Alice',
619
+ age: 26,
620
+ address: {
621
+ 'object.from': {
622
+ city: 'Lyon',
623
+ country: 'France',
624
+ },
625
+ },
626
+ },
627
+ },
628
+ ],
629
+ },
630
+ result: [
631
+ { path: ['age'], type: 'changed', from: 25, to: 26 },
632
+ { path: ['address', 'city'], type: 'changed', from: 'Paris', to: 'Lyon' },
633
+ { path: ['address', 'zip'], type: 'removed', value: 7500 },
634
+ { path: ['address', 'country'], type: 'added', value: 'France' },
635
+ ],
636
+ },
637
+ 'object.explode': {
638
+ input: {
639
+ ownerName: 'John',
640
+ country: 'USA',
641
+ pets: [
642
+ { name: 'Milka' },
643
+ { name: 'Sven', country: 'Sweden' },
644
+ { name: 'Tom', likes: ['mice', 'fish'] },
645
+ { name: 'Jerry', looks: { color: 'brown' } },
646
+ ],
647
+ },
648
+ remapper: {
649
+ 'object.explode': 'pets',
650
+ },
651
+ result: [
652
+ { ownerName: 'John', name: 'Milka', country: 'USA' },
653
+ { ownerName: 'John', name: 'Sven', country: 'Sweden' },
654
+ { ownerName: 'John', name: 'Tom', country: 'USA', likes: ['mice', 'fish'] },
655
+ { ownerName: 'John', name: 'Jerry', country: 'USA', looks: { color: 'brown' } },
656
+ ],
657
+ },
573
658
  'omit.history': {
574
659
  input: null,
575
660
  remapper: {},
@@ -647,6 +732,30 @@ export const examples = {
647
732
  },
648
733
  result: 'PATRICK',
649
734
  },
735
+ 'string.startsWith': {
736
+ input: 'Random string here',
737
+ remapper: {
738
+ 'string.startsWith': 'Random',
739
+ },
740
+ result: true,
741
+ },
742
+ 'string.endsWith': {
743
+ input: 'Random string here',
744
+ remapper: {
745
+ 'string.endsWith': {
746
+ substring: 'Here',
747
+ strict: false,
748
+ },
749
+ },
750
+ result: true,
751
+ },
752
+ slice: {
753
+ input: 'Laziness',
754
+ remapper: {
755
+ slice: [3, 6],
756
+ },
757
+ result: 'ine',
758
+ },
650
759
  'string.format': {
651
760
  input: {
652
761
  lotteryPrize: '5000',
@@ -684,6 +793,107 @@ export const examples = {
684
793
  result: {},
685
794
  skip: true,
686
795
  },
796
+ 'filter.from': {
797
+ input: { exclude: 'Peter' },
798
+ remapper: {
799
+ 'filter.from': {
800
+ name: { type: 'String', comparator: 'ne', value: { prop: 'exclude' } },
801
+ age: { type: 'Number', comparator: 'lt', value: 10 },
802
+ height: { type: 'Number', comparator: 'le', value: 1.75 },
803
+ heightString: { type: 'Number', comparator: 'le', value: '1.75' },
804
+ birthday: { type: 'Date', comparator: 'ge', value: '2000-01-01' },
805
+ friendsSince: { type: 'Date', comparator: 'ge', value: '2014-01-01T00:00:00Z' },
806
+ job: { type: 'String', comparator: 'eq', value: null },
807
+ employed: { type: 'Boolean', comparator: 'eq', value: false },
808
+ id: { type: 'Guid', comparator: 'eq', value: '03a0a47b-e3a2-e311-9402-00155d104c24' },
809
+ undefined: { type: 'String', comparator: 'eq', value: undefined },
810
+ special: {
811
+ type: 'String',
812
+ comparator: 'eq',
813
+ value: 'Special character\'s "test" \\%&+?^/',
814
+ },
815
+ },
816
+ },
817
+ result: "name ne 'Peter' and age lt 10 and height le 1.75 and heightString le 1.75 and birthday ge 2000-01-01 and friendsSince ge 2014-01-01T00:00:00Z and job eq null and employed eq false and id eq 03a0a47b-e3a2-e311-9402-00155d104c24 and undefined eq null and special eq 'Special character''s \"test\" \\\\%&+?^/'",
818
+ },
819
+ 'order.from': {
820
+ input: null,
821
+ remapper: {
822
+ 'order.from': {
823
+ name: 'asc',
824
+ age: 'desc',
825
+ },
826
+ },
827
+ result: 'name asc,age desc',
828
+ },
829
+ 'xml.parse': {
830
+ input: {
831
+ xml: `
832
+ <obj>
833
+ <foo>bar</foo>
834
+ <item foo="bar">
835
+ <item foo="bar">
836
+ <text>text</text>
837
+ </item>
838
+ </item>
839
+ <item bar="baz">
840
+ <item bar="baz">
841
+ <text>text 2</text>
842
+ </item>
843
+ </item>
844
+ <item>
845
+ <item foo="bar">
846
+ <item foo="bar">
847
+ <text>text</text>
848
+ </item>
849
+ </item>
850
+ <item bar="baz">
851
+ <item bar="baz">
852
+ <text>text 2</text>
853
+ </item>
854
+ </item>
855
+ </item>
856
+ </obj>
857
+ `,
858
+ },
859
+ remapper: { 'xml.parse': { prop: 'xml' } },
860
+ result: {
861
+ obj: {
862
+ foo: 'bar',
863
+ item: [
864
+ {
865
+ foo: 'bar',
866
+ item: { foo: 'bar', text: 'text' },
867
+ },
868
+ {
869
+ bar: 'baz',
870
+ item: { bar: 'baz', text: 'text 2' },
871
+ },
872
+ {
873
+ item: [
874
+ {
875
+ foo: 'bar',
876
+ item: { foo: 'bar', text: 'text' },
877
+ },
878
+ {
879
+ bar: 'baz',
880
+ item: { bar: 'baz', text: 'text 2' },
881
+ },
882
+ ],
883
+ },
884
+ ],
885
+ },
886
+ },
887
+ },
888
+ defined: {
889
+ input: [0, '', false, undefined, null],
890
+ remapper: {
891
+ 'array.map': {
892
+ defined: { array: 'item' },
893
+ },
894
+ },
895
+ result: [true, true, true, false, false],
896
+ },
687
897
  };
688
898
  /**
689
899
  * @param remapper The remapper example to use.
@@ -695,21 +905,21 @@ export function schemaExample(remapper, options) {
695
905
  let example = '';
696
906
  if (!exclude.includes('input')) {
697
907
  const spacing = input === 'pretty' && 2;
698
- example += `Input:\n\n\`\`\`json\n${JSON.stringify(examples[remapper].input, null, spacing)}\n\`\`\`\n`;
908
+ example += `Input:\n\n\`\`\`json\n${JSON.stringify(examples[remapper].input, null, spacing || undefined)}\n\`\`\`\n`;
699
909
  }
700
910
  if (!exclude.includes('remapper')) {
701
911
  example += `\`\`\`yaml\n${stringify(examples[remapper].remapper)}\n\`\`\`\n`;
702
912
  }
703
913
  if (!exclude.includes('result')) {
704
914
  const spacing = result === 'pretty' && 2;
705
- example += `Result:\n\n\`\`\`json\n${JSON.stringify(examples[remapper].result, null, spacing)}\n\`\`\`\n`;
915
+ example += `Result:\n\n\`\`\`json\n${JSON.stringify(examples[remapper].result, null, spacing || undefined)}\n\`\`\`\n`;
706
916
  }
707
917
  return example;
708
918
  }
709
919
  export function createExampleContext(url, lang, userInfo, history) {
710
920
  return {
711
- getMessage: ({ defaultMessage }) => new IntlMessageFormat(defaultMessage, lang, undefined),
712
- getVariable: (name) => (name === 'MY_VARIABLE' ? 'variable value' : null),
921
+ getMessage: ({ defaultMessage }) => new IntlMessageFormat(defaultMessage ?? [], lang, undefined),
922
+ getVariable: (name) => (name === 'MY_VARIABLE' ? 'variable value' : undefined),
713
923
  url: String(url),
714
924
  appUrl: `${url.protocol}//example-app.example-organization.${url.host}`,
715
925
  context: {},
@@ -1,8 +1,8 @@
1
1
  export function formatRequestAction({ method = 'GET', query, ...action }, data, remap, context) {
2
2
  return {
3
3
  method,
4
- url: String(remap(action.url, data, context)),
5
- params: remap(query, data, context),
4
+ url: String(remap(action.url ?? null, data, context)),
5
+ params: remap(query ?? null, data, context),
6
6
  responseType: 'arraybuffer',
7
7
  headers: {},
8
8
  };
package/has.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  * @param key The key to check for on the target.
6
6
  * @returns Whether or not the key exists on the target.
7
7
  */
8
- export declare function has(target: object, key: string): boolean;
8
+ export declare function has(target: object | null | undefined, key: string): boolean;
package/has.js CHANGED
@@ -6,6 +6,6 @@
6
6
  * @returns Whether or not the key exists on the target.
7
7
  */
8
8
  export function has(target, key) {
9
- return target != null && Object.hasOwnProperty.call(target, key);
9
+ return target != null && target !== undefined && Object.hasOwnProperty.call(target, key);
10
10
  }
11
11
  //# sourceMappingURL=has.js.map
package/i18n.js CHANGED
@@ -36,14 +36,12 @@ export function sortLocales(languages) {
36
36
  export function detectLocale(languages, choices) {
37
37
  const supportedLocales = sortLocales(languages);
38
38
  const wantedLocales = sortLocales(choices);
39
- let result;
40
- wantedLocales.some((wanted) => supportedLocales.some((supported) => {
41
- if (wanted.startsWith(supported)) {
42
- result = supported;
43
- return true;
39
+ for (const wanted of wantedLocales) {
40
+ for (const supported of supportedLocales) {
41
+ if (wanted.startsWith(supported)) {
42
+ return supported;
43
+ }
44
44
  }
45
- return false;
46
- }));
47
- return result;
45
+ }
48
46
  }
49
47
  //# sourceMappingURL=i18n.js.map
package/ics.js CHANGED
@@ -5,7 +5,7 @@ const hourLength = 60 * minuteLength;
5
5
  const dayLength = 24 * hourLength;
6
6
  const weekLength = 7 * dayLength;
7
7
  export function getDuration(duration) {
8
- let milliseconds = typeof duration === 'string' ? parseDuration(duration) : duration;
8
+ let milliseconds = typeof duration === 'string' ? (parseDuration(duration) ?? 0) : duration;
9
9
  const weeks = Math.floor(milliseconds / weekLength);
10
10
  milliseconds %= weekLength;
11
11
  const days = Math.floor(milliseconds / dayLength);
package/iterApp.js CHANGED
@@ -92,14 +92,14 @@ export function iterPage(page, callbacks, prefix = []) {
92
92
  if (page.type === 'flow' || page.type === 'tabs') {
93
93
  let result = false;
94
94
  if ('actions' in page) {
95
- result = Object.entries(page.actions).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]));
95
+ result = Object.entries(page.actions ?? {}).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]));
96
96
  }
97
97
  return (result ||
98
98
  (page.type === 'flow'
99
99
  ? page.steps.some((step, index) => iterBlockList(step.blocks, callbacks, [...prefix, 'steps', index, 'blocks']))
100
100
  : page.tabs
101
101
  ? page.tabs.some((tab, index) => iterBlockList(tab.blocks, callbacks, [...prefix, 'tabs', index, 'blocks']))
102
- : iterBlockList(page.definition.foreach.blocks, callbacks, [
102
+ : iterBlockList(page.definition?.foreach.blocks ?? [], callbacks, [
103
103
  ...prefix,
104
104
  'tabs',
105
105
  0,
@@ -109,7 +109,7 @@ export function iterPage(page, callbacks, prefix = []) {
109
109
  if (page.type === 'loop') {
110
110
  let result = false;
111
111
  if ('actions' in page) {
112
- result = Object.entries(page.actions).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]));
112
+ result = Object.entries(page.actions ?? {}).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]));
113
113
  }
114
114
  return (result ||
115
115
  ['steps.first', 'steps', 'steps.last'].some((suffix) => iterBlockList(page.foreach.blocks, callbacks, [...prefix, suffix, 'blocks'])));
package/jsonschema.js CHANGED
@@ -11,16 +11,16 @@ import { mapValues } from './mapValues.js';
11
11
  */
12
12
  export function generateDataFromSchema(schema) {
13
13
  if (!schema) {
14
- return;
14
+ return null;
15
15
  }
16
16
  // Let’s assume the default conforms to the schema, although this might not be true.
17
17
  if ('default' in schema) {
18
- return schema.default;
18
+ return schema.default ?? null;
19
19
  }
20
20
  // If no predefined value exists, generate something based on its type.
21
21
  switch (schema.type) {
22
22
  case 'array':
23
- return Array.from({ length: schema.minItems }, (empty, index) => generateDataFromSchema(Array.isArray(schema.items)
23
+ return Array.from({ length: schema.minItems ?? 0 }, (empty, index) => generateDataFromSchema(Array.isArray(schema.items)
24
24
  ? schema.items[index] ||
25
25
  (typeof schema.additionalItems === 'object' && schema.additionalItems)
26
26
  : schema.items));
@@ -46,6 +46,7 @@ export function generateDataFromSchema(schema) {
46
46
  default:
47
47
  break;
48
48
  }
49
+ return null;
49
50
  }
50
51
  /**
51
52
  * Combine a list of schemas into one schema matching all of them.
@@ -67,18 +68,30 @@ export function combineSchemas(...schemas) {
67
68
  }
68
69
  if ('minimum' in schema) {
69
70
  result.minimum =
71
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
72
+ // @ts-ignore 2345 argument of type is not assignable to parameter of type
73
+ // (strictNullChecks)
70
74
  'minimum' in result ? Math.max(result.minimum, schema.minimum) : schema.minimum;
71
75
  }
72
76
  if ('minLength' in schema) {
73
77
  result.minLength =
78
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
79
+ // @ts-ignore 2345 argument of type is not assignable to parameter of type
80
+ // (strictNullChecks)
74
81
  'minLength' in result ? Math.max(result.minLength, schema.minLength) : schema.minLength;
75
82
  }
76
83
  if ('maximum' in schema) {
77
84
  result.maximum =
85
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
86
+ // @ts-ignore 2345 argument of type is not assignable to parameter of type
87
+ // (strictNullChecks)
78
88
  'maximum' in result ? Math.min(result.maximum, schema.maximum) : schema.maximum;
79
89
  }
80
90
  if ('maxLength' in schema) {
81
91
  result.maxLength =
92
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
93
+ // @ts-ignore 2345 argument of type is not assignable to parameter of type
94
+ // (strictNullChecks)
82
95
  'maxLength' in result ? Math.min(result.maxLength, schema.maxLength) : schema.maxLength;
83
96
  }
84
97
  if (schema.multipleOf) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/utils",
3
- "version": "0.30.14-test.6",
3
+ "version": "0.32.1-test.15",
4
4
  "description": "Utility functions used in Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -22,14 +22,16 @@
22
22
  "sideEffects": false,
23
23
  "type": "module",
24
24
  "exports": {
25
- ".": [
26
- "./index.js",
27
- "./index.ts"
28
- ]
25
+ ".": {
26
+ "ts-source": "./index.ts",
27
+ "default": "./index.js"
28
+ }
29
29
  },
30
30
  "files": [
31
31
  "**/*.d.ts",
32
32
  "**/*.js",
33
+ "!**/*.test.js",
34
+ "!**/*.test.d.ts",
33
35
  "!*.config.js"
34
36
  ],
35
37
  "scripts": {
@@ -37,30 +39,32 @@
37
39
  "test": "vitest"
38
40
  },
39
41
  "dependencies": {
40
- "@appsemble/types": "0.30.14-test.6",
42
+ "@appsemble/types": "0.32.1-test.15",
43
+ "@odata/parser": "^0.2.14",
41
44
  "axios": "^1.0.0",
42
45
  "cron-parser": "^4.0.0",
43
46
  "date-fns": "^2.0.0",
44
47
  "fast-deep-equal": "^3.0.0",
48
+ "fast-xml-parser": "^5.0.8",
45
49
  "ics": "^3.0.0",
46
50
  "intl-messageformat": "^10.0.0",
47
- "jsonschema": "^1.0.0",
51
+ "jsonschema": "~1.4.1",
48
52
  "langmap": "^0.0.16",
49
53
  "language-tags": "^1.0.0",
50
54
  "lcm": "^0.0.3",
51
55
  "openapi-types": "^12.0.0",
52
56
  "parse-duration": "^1.0.0",
53
57
  "postcss": "^8.0.0",
54
- "yaml": "^2.0.0",
55
- "type-fest": "^4.0.0"
58
+ "type-fest": "^4.0.0",
59
+ "yaml": "^2.0.0"
56
60
  },
57
61
  "devDependencies": {
58
62
  "@types/langmap": "^0.0.3",
59
63
  "@types/language-tags": "^1.0.0",
60
64
  "@types/lcm": "^0.0.2",
61
- "bulma": "0.9.3",
65
+ "bulma": "=0.9.3",
62
66
  "koas-core": "^0.7.0",
63
- "vitest": "^1.0.0"
67
+ "vitest": "^2.0.0"
64
68
  },
65
69
  "engines": {
66
70
  "node": ">=20"
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const appMemberActions: Record<string, OpenAPIV3.SchemaObject>;
@@ -0,0 +1,21 @@
1
+ import { AppMemberCurrentPatchActionDefinition } from '../../api/components/schemas/AppMemberCurrentPatchActionDefinition.js';
2
+ import { AppMemberDeleteActionDefinition } from '../../api/components/schemas/AppMemberDeleteActionDefinition.js';
3
+ import { AppMemberInviteActionDefinition } from '../../api/components/schemas/AppMemberInviteActionDefinition.js';
4
+ import { AppMemberLoginActionDefinition } from '../../api/components/schemas/AppMemberLoginActionDefinition.js';
5
+ import { AppMemberLogoutActionDefinition } from '../../api/components/schemas/AppMemberLogoutActionDefinition.js';
6
+ import { AppMemberPropertiesPatchActionDefinition } from '../../api/components/schemas/AppMemberPropertiesPatchActionDefinition.js';
7
+ import { AppMemberQueryActionDefinition } from '../../api/components/schemas/AppMemberQueryActionDefinition.js';
8
+ import { AppMemberRegisterActionDefinition } from '../../api/components/schemas/AppMemberRegisterActionDefinition.js';
9
+ import { AppMemberRoleUpdateActionDefinition } from '../../api/components/schemas/AppMemberRoleUpdateActionDefinition.js';
10
+ export const appMemberActions = {
11
+ 'app.member.register': AppMemberRegisterActionDefinition,
12
+ 'app.member.invite': AppMemberInviteActionDefinition,
13
+ 'app.member.login': AppMemberLoginActionDefinition,
14
+ 'app.member.logout': AppMemberLogoutActionDefinition,
15
+ 'app.member.query': AppMemberQueryActionDefinition,
16
+ 'app.member.current.patch': AppMemberCurrentPatchActionDefinition,
17
+ 'app.member.role.update': AppMemberRoleUpdateActionDefinition,
18
+ 'app.member.properties.patch': AppMemberPropertiesPatchActionDefinition,
19
+ 'app.member.delete': AppMemberDeleteActionDefinition,
20
+ };
21
+ //# sourceMappingURL=appMember.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const flowActions: Record<string, OpenAPIV3.SchemaObject>;
@@ -0,0 +1,13 @@
1
+ import { FlowBackActionDefinition } from '../../api/components/schemas/FlowBackActionDefinition.js';
2
+ import { FlowCancelActionDefinition } from '../../api/components/schemas/FlowCancelActionDefinition.js';
3
+ import { FlowFinishActionDefinition } from '../../api/components/schemas/FlowFinishActionDefinition.js';
4
+ import { FlowNextActionDefinition } from '../../api/components/schemas/FlowNextActionDefinition.js';
5
+ import { FlowToActionDefinition } from '../../api/components/schemas/FlowToActionDefinition.js';
6
+ export const flowActions = {
7
+ 'flow.next': FlowNextActionDefinition,
8
+ 'flow.finish': FlowFinishActionDefinition,
9
+ 'flow.back': FlowBackActionDefinition,
10
+ 'flow.cancel': FlowCancelActionDefinition,
11
+ 'flow.to': FlowToActionDefinition,
12
+ };
13
+ //# sourceMappingURL=flow.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const groupActions: Record<string, OpenAPIV3.SchemaObject>;
@@ -0,0 +1,13 @@
1
+ import { GroupMemberDeleteActionDefinition } from '../../api/components/schemas/GroupMemberDeleteActionDefinition.js';
2
+ import { GroupMemberInviteActionDefinition } from '../../api/components/schemas/GroupMemberInviteActionDefinition.js';
3
+ import { GroupMemberQueryActionDefinition } from '../../api/components/schemas/GroupMemberQueryActionDefinition.js';
4
+ import { GroupMemberRoleUpdateActionDefinition } from '../../api/components/schemas/GroupMemberRoleUpdateActionDefinition.js';
5
+ import { GroupQueryActionDefinition } from '../../api/components/schemas/GroupQueryActionDefinition.js';
6
+ export const groupActions = {
7
+ 'group.query': GroupQueryActionDefinition,
8
+ 'group.member.invite': GroupMemberInviteActionDefinition,
9
+ 'group.member.query': GroupMemberQueryActionDefinition,
10
+ 'group.member.delete': GroupMemberDeleteActionDefinition,
11
+ 'group.member.role.update': GroupMemberRoleUpdateActionDefinition,
12
+ };
13
+ //# sourceMappingURL=group.js.map
@@ -0,0 +1,7 @@
1
+ export * from './appMember.js';
2
+ export * from './flow.js';
3
+ export * from './group.js';
4
+ export * from './link.js';
5
+ export * from './miscellaneous.js';
6
+ export * from './resources.js';
7
+ export * from './storage.js';
@@ -0,0 +1,8 @@
1
+ export * from './appMember.js';
2
+ export * from './flow.js';
3
+ export * from './group.js';
4
+ export * from './link.js';
5
+ export * from './miscellaneous.js';
6
+ export * from './resources.js';
7
+ export * from './storage.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const linkActions: Record<string, OpenAPIV3.SchemaObject>;
@@ -0,0 +1,9 @@
1
+ import { LinkActionDefinition } from '../../api/components/schemas/LinkActionDefinition.js';
2
+ import { LinkBackActionDefinition } from '../../api/components/schemas/LinkBackActionDefinition.js';
3
+ import { LinkNextActionDefinition } from '../../api/components/schemas/LinkNextActionDefinition.js';
4
+ export const linkActions = {
5
+ link: LinkActionDefinition,
6
+ 'link.back': LinkBackActionDefinition,
7
+ 'link.next': LinkNextActionDefinition,
8
+ };
9
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const miscellaneousActions: Record<string, OpenAPIV3.SchemaObject>;
@@ -0,0 +1,41 @@
1
+ import { AnalyticsActionDefinition } from '../../api/components/schemas/AnalyticsActionDefinition.js';
2
+ import { ConditionActionDefinition } from '../../api/components/schemas/ConditionActionDefinition.js';
3
+ import { ControllerActionDefinition } from '../../api/components/schemas/ControllerActionDefinition.js';
4
+ import { DialogActionDefinition } from '../../api/components/schemas/DialogActionDefinition.js';
5
+ import { DialogErrorActionDefinition } from '../../api/components/schemas/DialogErrorActionDefinition.js';
6
+ import { DialogOkActionDefinition } from '../../api/components/schemas/DialogOkActionDefinition.js';
7
+ import { DownloadActionDefinition } from '../../api/components/schemas/DownloadActionDefinition.js';
8
+ import { EachActionDefinition } from '../../api/components/schemas/EachActionDefinition.js';
9
+ import { EmailActionDefinition } from '../../api/components/schemas/EmailActionDefinition.js';
10
+ import { EventActionDefinition } from '../../api/components/schemas/EventActionDefinition.js';
11
+ import { LogActionDefinition } from '../../api/components/schemas/LogActionDefinition.js';
12
+ import { MatchActionDefinition } from '../../api/components/schemas/MatchActionDefinition.js';
13
+ import { MessageActionDefinition } from '../../api/components/schemas/MessageActionDefinition.js';
14
+ import { NoopActionDefinition } from '../../api/components/schemas/NoopActionDefinition.js';
15
+ import { NotifyActionDefinition } from '../../api/components/schemas/NotifyActionDefinition.js';
16
+ import { RequestActionDefinition } from '../../api/components/schemas/RequestActionDefinition.js';
17
+ import { ShareActionDefinition } from '../../api/components/schemas/ShareActionDefinition.js';
18
+ import { StaticActionDefinition } from '../../api/components/schemas/StaticActionDefinition.js';
19
+ import { ThrowActionDefinition } from '../../api/components/schemas/ThrowActionDefinition.js';
20
+ export const miscellaneousActions = {
21
+ analytics: AnalyticsActionDefinition,
22
+ condition: ConditionActionDefinition,
23
+ controller: ControllerActionDefinition,
24
+ download: DownloadActionDefinition,
25
+ dialog: DialogActionDefinition,
26
+ 'dialog.ok': DialogOkActionDefinition,
27
+ 'dialog.error': DialogErrorActionDefinition,
28
+ each: EachActionDefinition,
29
+ event: EventActionDefinition,
30
+ email: EmailActionDefinition,
31
+ log: LogActionDefinition,
32
+ match: MatchActionDefinition,
33
+ message: MessageActionDefinition,
34
+ noop: NoopActionDefinition,
35
+ notify: NotifyActionDefinition,
36
+ request: RequestActionDefinition,
37
+ share: ShareActionDefinition,
38
+ static: StaticActionDefinition,
39
+ throw: ThrowActionDefinition,
40
+ };
41
+ //# sourceMappingURL=miscellaneous.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const resourceActions: Record<string, OpenAPIV3.SchemaObject>;