@reventlessdev/reventless-core 3.0.0-alpha.238 → 3.0.0-alpha.240

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 (178) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/package.json +12 -12
  3. package/src/Message.res +11 -11
  4. package/src/Message.res.mjs +15 -14
  5. package/src/Projection.res +2 -2
  6. package/src/Projection.res.mjs +5 -4
  7. package/src/adapter/Monitoring/Monitoring.res +24 -2
  8. package/src/adapter/Monitoring/Monitoring.res.mjs +3 -3
  9. package/src/admin/Platform_AdminApi.res.mjs +3 -3
  10. package/src/admin/Platform_Admin_Structure.res +33 -112
  11. package/src/admin/Platform_Admin_Structure.res.mjs +8 -138
  12. package/src/admin/Platform_ComponentDefinitionsApi.res +2 -1
  13. package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +5 -1
  14. package/src/admin/UiFragmentRegistry/StateChangeSlice/UiFragmentRegistry.res.mjs +12 -12
  15. package/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments.res.mjs +14 -14
  16. package/src/components/Aggregate/Aggregate_Callback.res +2 -2
  17. package/src/components/Aggregate/Aggregate_Callback.res.mjs +4 -4
  18. package/src/components/Api/ApiAllowedStatesHelpers.res.mjs +3 -3
  19. package/src/components/Api/ApiNoApiHelpers.res.mjs +5 -5
  20. package/src/components/Api/ApiTargetStateHelpers.res.mjs +3 -3
  21. package/src/components/Api/GraphQL_FragmentGenerator.res +140 -24
  22. package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +48 -21
  23. package/src/components/Api/GraphQL_SchemaInspector.res +1 -1
  24. package/src/components/Api/GraphQL_SchemaInspector.res.mjs +1 -1
  25. package/src/components/Api/MCP_SchemaGenerator.res +1 -1
  26. package/src/components/Api/MCP_SchemaGenerator.res.mjs +1 -1
  27. package/src/components/Api/SchemaType.res +6 -10
  28. package/src/components/Api/SchemaType.res.mjs +4 -4
  29. package/src/components/Api/StorageRefFields.res +1 -1
  30. package/src/components/Api/StorageRefFields.res.mjs +1 -1
  31. package/src/components/Api/SuryToJsonSchema.res +19 -0
  32. package/src/components/Api/SuryToJsonSchema.res.mjs +10 -5
  33. package/src/components/AutomationSlice/AutomationSlice_Callback.res +3 -4
  34. package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +22 -23
  35. package/src/components/CommandTopic/CommandTopic_Callback.res +1 -2
  36. package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +3 -4
  37. package/src/components/CommandTopic/CommandTopic_Helpers.res +1 -1
  38. package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +3 -3
  39. package/src/components/Counter/Counter.res.mjs +2 -2
  40. package/src/components/Counter/Counter_Callback.res.mjs +4 -4
  41. package/src/components/Counter/Counter_Operations.res.mjs +4 -4
  42. package/src/components/Dcb/Dcb_Builder.res +1 -1
  43. package/src/components/Dcb/Dcb_Builder.res.mjs +8 -6
  44. package/src/components/DcbEventLog/DcbEventLog_Builder.res.mjs +4 -3
  45. package/src/components/EventCollector/EventCollector_Builder.res +1 -1
  46. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +1 -2
  47. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +11 -12
  48. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +3 -4
  49. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +24 -25
  50. package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +1 -1
  51. package/src/components/SideEffectHandler/SideEffectHandler_Callback.res.mjs +3 -3
  52. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +2 -2
  53. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +4 -4
  54. package/src/components/StateViewSlice/StateViewSlice_Builder.res +1 -1
  55. package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +3 -3
  56. package/src/plugin/api/PluginBaseFragment.res +12 -29
  57. package/src/plugin/api/PluginBaseFragment.res.mjs +3 -22
  58. package/src/plugin/component/Capability_Inference.res +118 -1
  59. package/src/plugin/component/Capability_Inference.res.mjs +128 -1
  60. package/src/plugin/component/Plugin_Builder.res +9 -2
  61. package/src/plugin/component/Plugin_Builder.res.mjs +5 -2
  62. package/src/plugin/component/Plugin_Helpers.res +11 -11
  63. package/src/plugin/component/Plugin_Helpers.res.mjs +11 -10
  64. package/src/plugin/component/Plugin_Structure.res +458 -296
  65. package/src/plugin/component/Plugin_Structure.res.mjs +259 -182
  66. package/src/plugin/component/Plugin_SubscriptionSchema.res +1 -1
  67. package/src/plugin/component/Plugin_SubscriptionSchema.res.mjs +1 -1
  68. package/src/plugin/component/SchemaWalker.res +11 -11
  69. package/src/plugin/component/SchemaWalker.res.mjs +8 -9
  70. package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +15 -15
  71. package/src/plugin/lifecycle/PluginBehavior.res.mjs +55 -55
  72. package/src/plugin/lifecycle/PluginSpec.res +22 -7
  73. package/src/plugin/lifecycle/PluginSpec.res.mjs +91 -36
  74. package/src/plugin/lifecycle/PluginsReadModelSpec.res +36 -9
  75. package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +33 -22
  76. package/src/util/Interstack.res +3 -3
  77. package/src/util/LogFormat.res +1 -2
  78. package/src/util/LogFormat.res.mjs +2 -2
  79. package/tests/IdentityTest.res +6 -7
  80. package/tests/IdentityTest.res.mjs +7 -9
  81. package/tests/adapter/MonitoringTest.res +30 -3
  82. package/tests/adapter/MonitoringTest.res.mjs +31 -12
  83. package/tests/adapter/RuntimeExtensionHookReachTest.res +0 -1
  84. package/tests/adapter/RuntimeExtensionHookReachTest.res.mjs +5 -7
  85. package/tests/admin/Platform_Admin_StructureTest.res +254 -0
  86. package/tests/admin/Platform_Admin_StructureTest.res.mjs +219 -0
  87. package/tests/admin/Platform_BakedManifestTest.res +1 -0
  88. package/tests/admin/Platform_BakedManifestTest.res.mjs +1 -0
  89. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +3 -0
  90. package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +6 -0
  91. package/tests/admin/Platform_PluginStructuresApiTest.res +1 -0
  92. package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +2 -0
  93. package/tests/aggregate/AggregateCacheTest.res +0 -1
  94. package/tests/aggregate/AggregateCacheTest.res.mjs +13 -15
  95. package/tests/aggregate/AggregateConflictTest.res +0 -1
  96. package/tests/aggregate/AggregateConflictTest.res.mjs +7 -9
  97. package/tests/aggregate/AggregateFixtures.res +0 -1
  98. package/tests/aggregate/AggregateFixtures.res.mjs +19 -21
  99. package/tests/aggregate/AggregateSnapshotTest.res +1 -2
  100. package/tests/aggregate/AggregateSnapshotTest.res.mjs +15 -16
  101. package/tests/api/ApiNoApiTest.res.mjs +17 -9
  102. package/tests/api/GraphQL_FragmentGeneratorTest.res +232 -0
  103. package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +207 -55
  104. package/tests/api/PsInternalFieldsReadModel.res +21 -0
  105. package/tests/api/PsInternalFieldsReadModel.res.mjs +74 -0
  106. package/tests/api/StorageRefFieldsTest.res.mjs +13 -13
  107. package/tests/api/SuryToJsonSchemaTest.res +73 -3
  108. package/tests/api/SuryToJsonSchemaTest.res.mjs +364 -816
  109. package/tests/commandgenerator/CommandGeneratorFixtures.res +0 -1
  110. package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +19 -21
  111. package/tests/commandgenerator/OwnerStampingTest.res +0 -1
  112. package/tests/commandgenerator/OwnerStampingTest.res.mjs +9 -11
  113. package/tests/commandtopic/CommandTopicCallbackFixtures.res +0 -1
  114. package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +7 -9
  115. package/tests/counter/CounterFixtures.res +0 -1
  116. package/tests/counter/CounterFixtures.res.mjs +1 -4
  117. package/tests/dcb/DcbDecodeTest.res.mjs +24 -24
  118. package/tests/dcb/DcbEventLogOperationsTest.res +2 -2
  119. package/tests/dcb/DcbEventLogOperationsTest.res.mjs +3 -3
  120. package/tests/dcb/DcbEventLogSchemaTest.res.mjs +7 -7
  121. package/tests/dcb/DcbFixtures.res +0 -1
  122. package/tests/dcb/DcbFixtures.res.mjs +87 -89
  123. package/tests/dcb/DcbTagTest.res.mjs +6 -6
  124. package/tests/dcb/DcbValidationTest.res.mjs +52 -52
  125. package/tests/eventlog/EventLogFixtures.res +0 -1
  126. package/tests/eventlog/EventLogFixtures.res.mjs +7 -9
  127. package/tests/eventmapper/EventMapperFixtures.res +0 -1
  128. package/tests/eventmapper/EventMapperFixtures.res.mjs +24 -26
  129. package/tests/eventtopic/EventTopicFixtures.res +0 -1
  130. package/tests/eventtopic/EventTopicFixtures.res.mjs +7 -9
  131. package/tests/extensionpoint/ExtensionPointFixtures.res +0 -1
  132. package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +10 -12
  133. package/tests/extensionpoint/ExtensionPointOperationsTest.res +1 -2
  134. package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +9 -10
  135. package/tests/logger/LogFormatTest.res +3 -2
  136. package/tests/logger/LogFormatTest.res.mjs +7 -9
  137. package/tests/message/MessageTest.res +2 -2
  138. package/tests/message/MessageTest.res.mjs +8 -7
  139. package/tests/message/MetaEnvelopeTest.res +5 -5
  140. package/tests/message/MetaEnvelopeTest.res.mjs +12 -11
  141. package/tests/plugin/ManifestVisibilityTest.res.mjs +7 -7
  142. package/tests/plugin/PluginDefinitionScalars.res +5 -3
  143. package/tests/plugin/PluginDefinitionScalars.res.mjs +2 -2
  144. package/tests/plugin/PluginLifecycleCorpusTest.res +4 -3
  145. package/tests/plugin/PluginLifecycleCorpusTest.res.mjs +3 -6
  146. package/tests/plugin/PluginSpecExperiment.res +0 -1
  147. package/tests/plugin/PluginSpecExperiment.res.mjs +12 -14
  148. package/tests/plugin/PluginStructureTest.res +292 -2
  149. package/tests/plugin/PluginStructureTest.res.mjs +391 -88
  150. package/tests/plugin/Plugin_EventQuerySchemaTest.res.mjs +3 -3
  151. package/tests/plugin/SchemaWalkerTest.res +0 -1
  152. package/tests/plugin/SchemaWalkerTest.res.mjs +17 -19
  153. package/tests/plugin/StateChangeSlice/PsAttachInvoice.res.mjs +5 -5
  154. package/tests/plugin/StateChangeSlice/PsChangePhoto.res.mjs +8 -8
  155. package/tests/plugin/StateChangeSlice/PsDispatchShipment.res.mjs +5 -5
  156. package/tests/plugin/StateChangeSlice/PsGatedCommands.res.mjs +9 -9
  157. package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +5 -5
  158. package/tests/plugin/StateChangeSlice/PsReserveStock.res.mjs +8 -8
  159. package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +15 -15
  160. package/tests/plugin/StateChangeSlice/PsTypoStore.res +31 -0
  161. package/tests/plugin/StateChangeSlice/PsTypoStore.res.mjs +62 -0
  162. package/tests/plugin/StateChangeSlice/PsUploadAvatar.res.mjs +8 -8
  163. package/tests/plugin/StateChangeSlice/PsUploadImages.res +40 -0
  164. package/tests/plugin/StateChangeSlice/PsUploadImages.res.mjs +66 -0
  165. package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +13 -12
  166. package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +8 -8
  167. package/tests/plugin/StateViewSlice/PsCategoriesView.res.mjs +6 -6
  168. package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +10 -10
  169. package/tests/plugin/StateViewSlice/PsGatedView.res.mjs +6 -6
  170. package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +9 -9
  171. package/tests/plugin/StateViewSlice/PsShipmentsView.res.mjs +11 -10
  172. package/tests/plugin/pluginDefinitionRequiredScalars.txt +15 -0
  173. package/tests/querydb/QueryDbFixtures.res +0 -1
  174. package/tests/querydb/QueryDbFixtures.res.mjs +5 -7
  175. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +0 -1
  176. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +4 -6
  177. package/tests/util/CommandPublisherTest.res +0 -1
  178. package/tests/util/CommandPublisherTest.res.mjs +4 -6
@@ -1,6 +1,6 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
- import * as S from "sury/src/S.res.mjs";
3
+ import * as Sury from "sury";
4
4
  import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
5
5
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
6
6
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
@@ -90,18 +90,18 @@ let emptySpec = {
90
90
  globalThis.describe("SuryToJsonSchema:", () => {
91
91
  globalThis.describe("deriveObjectSchema with no annotations:", () => {
92
92
  globalThis.test("emits plain JSON Schema when no metadata is attached", () => {
93
- let schema = S.schema(s => ({
94
- id: s.m(S.string),
95
- name: s.m(S.string)
93
+ let schema = Sury.$schema(s => ({
94
+ id: s.m(Sury.string),
95
+ name: s.m(Sury.string)
96
96
  }));
97
97
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
98
98
  let idSchema = getPropertyOf(json, "id");
99
99
  globalThis.expect(Stdlib_Option.flatMap(idSchema, s => getProperty(s, "x-reventless-id"))).toBe(undefined);
100
100
  });
101
101
  globalThis.test("emits format:\"date-time\" for a DateTime-marked string field", () => {
102
- let schema = S.schema(s => ({
102
+ let schema = Sury.$schema(s => ({
103
103
  placedAt: s.m(DateTime$Reventless.string),
104
- name: s.m(S.string)
104
+ name: s.m(Sury.string)
105
105
  }));
106
106
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
107
107
  globalThis.expect(Stdlib_Option.flatMap(Stdlib_Option.flatMap(getPropertyOf(json, "placedAt"), s => getProperty(s, "format")), Stdlib_JSON.Decode.string)).toBe("date-time");
@@ -110,9 +110,9 @@ globalThis.describe("SuryToJsonSchema:", () => {
110
110
  });
111
111
  globalThis.describe("deriveObjectSchema with an owner field:", () => {
112
112
  let ownerOf = (json, name) => Stdlib_Option.flatMap(getPropertyOf(json, name), s => getProperty(s, "x-reventless-owner"));
113
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
113
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
114
114
  customerId: s.m(Owner$Reventless.string),
115
- note: s.m(S.string)
115
+ note: s.m(Sury.string)
116
116
  })));
117
117
  globalThis.test("the marked field carries x-reventless-owner", () => {
118
118
  globalThis.expect(ownerOf(json, "customerId")).toEqual(true);
@@ -124,74 +124,39 @@ globalThis.describe("SuryToJsonSchema:", () => {
124
124
  globalThis.expect(Stdlib_Option.flatMap(getPropertyOf(json, "customerId"), s => getProperty(s, "type"))).toEqual("string");
125
125
  });
126
126
  globalThis.test("an optional owner field is still recognised", () => {
127
- let optJson = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
128
- customerId: s.m(S.option(Owner$Reventless.string))
127
+ let optJson = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
128
+ customerId: s.m(Sury.$option(Owner$Reventless.string))
129
129
  })));
130
130
  globalThis.expect(ownerOf(optJson, "customerId")).toEqual(true);
131
131
  });
132
132
  });
133
133
  globalThis.describe("deriveObjectSchema with stateAnnotations metadata:", () => {
134
- let withSpec = (schema, spec) => S.Metadata.set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
135
134
  globalThis.test("emits x-reventless-id on field listed in ids", () => {
136
- let schema = S.schema(s => ({
137
- entityId: s.m(S.string),
138
- name: s.m(S.string)
135
+ let schema = Sury.$schema(s => ({
136
+ entityId: s.m(Sury.string),
137
+ name: s.m(Sury.string)
139
138
  }));
140
- let schema$p = withSpec(schema, {
141
- ids: ["entityId"],
142
- compositeIds: emptySpec_compositeIds,
143
- subIds: emptySpec_subIds,
144
- compositeSubIds: emptySpec_compositeSubIds,
145
- indexes: emptySpec_indexes,
146
- hidden: emptySpec_hidden,
147
- summary: emptySpec_summary,
148
- drillTargets: emptySpec_drillTargets,
149
- drillTargetKeys: emptySpec_drillTargetKeys,
150
- collapsed: emptySpec_collapsed,
151
- scan: emptySpec_scan,
152
- scanSort: emptySpec_scanSort,
153
- semantic: emptySpec_semantic,
154
- metric: emptySpec_metric,
155
- lifecycle: undefined,
156
- groupBy: undefined,
157
- visibility: undefined,
158
- live: undefined,
159
- retired: undefined
160
- });
139
+ let newrecord = {...emptySpec};
140
+ newrecord.ids = ["entityId"];
141
+ let spec = newrecord;
142
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
161
143
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
162
144
  let entityIdSchema = getPropertyOf(json, "entityId");
163
145
  globalThis.expect(Stdlib_Option.flatMap(Stdlib_Option.flatMap(entityIdSchema, s => getProperty(s, "x-reventless-id")), Stdlib_JSON.Decode.bool)).toBe(true);
164
146
  });
165
147
  globalThis.test("emits x-reventless-compositeId on each compositeId field", () => {
166
- let schema = S.schema(s => ({
167
- environment: s.m(S.string),
168
- platformName: s.m(S.string),
169
- name: s.m(S.string)
148
+ let schema = Sury.$schema(s => ({
149
+ environment: s.m(Sury.string),
150
+ platformName: s.m(Sury.string),
151
+ name: s.m(Sury.string)
170
152
  }));
171
- let schema$p = withSpec(schema, {
172
- ids: emptySpec_ids,
173
- compositeIds: [
174
- "environment",
175
- "platformName"
176
- ],
177
- subIds: emptySpec_subIds,
178
- compositeSubIds: emptySpec_compositeSubIds,
179
- indexes: emptySpec_indexes,
180
- hidden: emptySpec_hidden,
181
- summary: emptySpec_summary,
182
- drillTargets: emptySpec_drillTargets,
183
- drillTargetKeys: emptySpec_drillTargetKeys,
184
- collapsed: emptySpec_collapsed,
185
- scan: emptySpec_scan,
186
- scanSort: emptySpec_scanSort,
187
- semantic: emptySpec_semantic,
188
- metric: emptySpec_metric,
189
- lifecycle: undefined,
190
- groupBy: undefined,
191
- visibility: undefined,
192
- live: undefined,
193
- retired: undefined
194
- });
153
+ let newrecord = {...emptySpec};
154
+ newrecord.compositeIds = [
155
+ "environment",
156
+ "platformName"
157
+ ];
158
+ let spec = newrecord;
159
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
195
160
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
196
161
  let envSchema = getPropertyOf(json, "environment");
197
162
  let platformSchema = getPropertyOf(json, "platformName");
@@ -204,157 +169,72 @@ globalThis.describe("SuryToJsonSchema:", () => {
204
169
  ]);
205
170
  });
206
171
  globalThis.test("emits x-reventless-subId on field listed in subIds", () => {
207
- let schema = S.schema(s => ({
208
- itemId: s.m(S.string),
209
- version: s.m(S.string)
172
+ let schema = Sury.$schema(s => ({
173
+ itemId: s.m(Sury.string),
174
+ version: s.m(Sury.string)
210
175
  }));
211
- let schema$p = withSpec(schema, {
212
- ids: emptySpec_ids,
213
- compositeIds: emptySpec_compositeIds,
214
- subIds: ["version"],
215
- compositeSubIds: emptySpec_compositeSubIds,
216
- indexes: emptySpec_indexes,
217
- hidden: emptySpec_hidden,
218
- summary: emptySpec_summary,
219
- drillTargets: emptySpec_drillTargets,
220
- drillTargetKeys: emptySpec_drillTargetKeys,
221
- collapsed: emptySpec_collapsed,
222
- scan: emptySpec_scan,
223
- scanSort: emptySpec_scanSort,
224
- semantic: emptySpec_semantic,
225
- metric: emptySpec_metric,
226
- lifecycle: undefined,
227
- groupBy: undefined,
228
- visibility: undefined,
229
- live: undefined,
230
- retired: undefined
231
- });
176
+ let newrecord = {...emptySpec};
177
+ newrecord.subIds = ["version"];
178
+ let spec = newrecord;
179
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
232
180
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
233
181
  let versionSchema = getPropertyOf(json, "version");
234
182
  globalThis.expect(Stdlib_Option.flatMap(Stdlib_Option.flatMap(versionSchema, s => getProperty(s, "x-reventless-subId")), Stdlib_JSON.Decode.bool)).toBe(true);
235
183
  });
236
184
  globalThis.test("emits x-reventless-index as the index name when named", () => {
237
- let schema = S.schema(s => ({
238
- id: s.m(S.string),
239
- ownerId: s.m(S.string)
185
+ let schema = Sury.$schema(s => ({
186
+ id: s.m(Sury.string),
187
+ ownerId: s.m(Sury.string)
240
188
  }));
241
- let schema$p = withSpec(schema, {
242
- ids: emptySpec_ids,
243
- compositeIds: emptySpec_compositeIds,
244
- subIds: emptySpec_subIds,
245
- compositeSubIds: emptySpec_compositeSubIds,
246
- indexes: [[
247
- "ownerId",
248
- "byOwner"
249
- ]],
250
- hidden: emptySpec_hidden,
251
- summary: emptySpec_summary,
252
- drillTargets: emptySpec_drillTargets,
253
- drillTargetKeys: emptySpec_drillTargetKeys,
254
- collapsed: emptySpec_collapsed,
255
- scan: emptySpec_scan,
256
- scanSort: emptySpec_scanSort,
257
- semantic: emptySpec_semantic,
258
- metric: emptySpec_metric,
259
- lifecycle: undefined,
260
- groupBy: undefined,
261
- visibility: undefined,
262
- live: undefined,
263
- retired: undefined
264
- });
189
+ let newrecord = {...emptySpec};
190
+ newrecord.indexes = [[
191
+ "ownerId",
192
+ "byOwner"
193
+ ]];
194
+ let spec = newrecord;
195
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
265
196
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
266
197
  let ownerIdSchema = getPropertyOf(json, "ownerId");
267
198
  globalThis.expect(Stdlib_Option.flatMap(Stdlib_Option.flatMap(ownerIdSchema, s => getProperty(s, "x-reventless-index")), Stdlib_JSON.Decode.string)).toBe("byOwner");
268
199
  });
269
200
  globalThis.test("emits x-reventless-index as true for unnamed @index", () => {
270
- let schema = S.schema(s => ({
271
- id: s.m(S.string),
272
- category: s.m(S.string)
201
+ let schema = Sury.$schema(s => ({
202
+ id: s.m(Sury.string),
203
+ category: s.m(Sury.string)
273
204
  }));
274
- let schema$p = withSpec(schema, {
275
- ids: emptySpec_ids,
276
- compositeIds: emptySpec_compositeIds,
277
- subIds: emptySpec_subIds,
278
- compositeSubIds: emptySpec_compositeSubIds,
279
- indexes: [[
280
- "category",
281
- ""
282
- ]],
283
- hidden: emptySpec_hidden,
284
- summary: emptySpec_summary,
285
- drillTargets: emptySpec_drillTargets,
286
- drillTargetKeys: emptySpec_drillTargetKeys,
287
- collapsed: emptySpec_collapsed,
288
- scan: emptySpec_scan,
289
- scanSort: emptySpec_scanSort,
290
- semantic: emptySpec_semantic,
291
- metric: emptySpec_metric,
292
- lifecycle: undefined,
293
- groupBy: undefined,
294
- visibility: undefined,
295
- live: undefined,
296
- retired: undefined
297
- });
205
+ let newrecord = {...emptySpec};
206
+ newrecord.indexes = [[
207
+ "category",
208
+ ""
209
+ ]];
210
+ let spec = newrecord;
211
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
298
212
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
299
213
  let categorySchema = getPropertyOf(json, "category");
300
214
  globalThis.expect(Stdlib_Option.flatMap(Stdlib_Option.flatMap(categorySchema, s => getProperty(s, "x-reventless-index")), Stdlib_JSON.Decode.bool)).toBe(true);
301
215
  });
302
216
  globalThis.test("does not emit x-reventless-* on unannotated fields", () => {
303
- let schema = S.schema(s => ({
304
- entityId: s.m(S.string),
305
- name: s.m(S.string)
217
+ let schema = Sury.$schema(s => ({
218
+ entityId: s.m(Sury.string),
219
+ name: s.m(Sury.string)
306
220
  }));
307
- let schema$p = withSpec(schema, {
308
- ids: ["entityId"],
309
- compositeIds: emptySpec_compositeIds,
310
- subIds: emptySpec_subIds,
311
- compositeSubIds: emptySpec_compositeSubIds,
312
- indexes: emptySpec_indexes,
313
- hidden: emptySpec_hidden,
314
- summary: emptySpec_summary,
315
- drillTargets: emptySpec_drillTargets,
316
- drillTargetKeys: emptySpec_drillTargetKeys,
317
- collapsed: emptySpec_collapsed,
318
- scan: emptySpec_scan,
319
- scanSort: emptySpec_scanSort,
320
- semantic: emptySpec_semantic,
321
- metric: emptySpec_metric,
322
- lifecycle: undefined,
323
- groupBy: undefined,
324
- visibility: undefined,
325
- live: undefined,
326
- retired: undefined
327
- });
221
+ let newrecord = {...emptySpec};
222
+ newrecord.ids = ["entityId"];
223
+ let spec = newrecord;
224
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
328
225
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
329
226
  let nameSchema = getPropertyOf(json, "name");
330
227
  globalThis.expect(Stdlib_Option.flatMap(nameSchema, s => getProperty(s, "x-reventless-id"))).toBe(undefined);
331
228
  });
332
229
  globalThis.test("emits x-reventless-hidden on field listed in hidden", () => {
333
- let schema = S.schema(s => ({
334
- id: s.m(S.string),
335
- deploymentId: s.m(S.string)
230
+ let schema = Sury.$schema(s => ({
231
+ id: s.m(Sury.string),
232
+ deploymentId: s.m(Sury.string)
336
233
  }));
337
- let schema$p = withSpec(schema, {
338
- ids: emptySpec_ids,
339
- compositeIds: emptySpec_compositeIds,
340
- subIds: emptySpec_subIds,
341
- compositeSubIds: emptySpec_compositeSubIds,
342
- indexes: emptySpec_indexes,
343
- hidden: ["deploymentId"],
344
- summary: emptySpec_summary,
345
- drillTargets: emptySpec_drillTargets,
346
- drillTargetKeys: emptySpec_drillTargetKeys,
347
- collapsed: emptySpec_collapsed,
348
- scan: emptySpec_scan,
349
- scanSort: emptySpec_scanSort,
350
- semantic: emptySpec_semantic,
351
- metric: emptySpec_metric,
352
- lifecycle: undefined,
353
- groupBy: undefined,
354
- visibility: undefined,
355
- live: undefined,
356
- retired: undefined
357
- });
234
+ let newrecord = {...emptySpec};
235
+ newrecord.hidden = ["deploymentId"];
236
+ let spec = newrecord;
237
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
358
238
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
359
239
  let deploymentIdSchema = getPropertyOf(json, "deploymentId");
360
240
  let idSchema = getPropertyOf(json, "id");
@@ -366,32 +246,44 @@ globalThis.describe("SuryToJsonSchema:", () => {
366
246
  undefined
367
247
  ]);
368
248
  });
249
+ globalThis.test("drops a field listed in internal rather than annotating it", () => {
250
+ let schema = Sury.$schema(s => ({
251
+ id: s.m(Sury.string),
252
+ eventCollector: s.m(Sury.string)
253
+ }));
254
+ let newrecord = {...emptySpec};
255
+ newrecord.internal = ["eventCollector"];
256
+ let spec = newrecord;
257
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
258
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
259
+ globalThis.expect([
260
+ Stdlib_Option.isNone(getPropertyOf(json, "eventCollector")),
261
+ Stdlib_Option.isSome(getPropertyOf(json, "id"))
262
+ ]).toEqual([
263
+ true,
264
+ true
265
+ ]);
266
+ });
267
+ globalThis.test("keeps a dropped field out of required", () => {
268
+ let schema = Sury.$schema(s => ({
269
+ id: s.m(Sury.string),
270
+ eventCollector: s.m(Sury.string)
271
+ }));
272
+ let newrecord = {...emptySpec};
273
+ newrecord.internal = ["eventCollector"];
274
+ let spec = newrecord;
275
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec));
276
+ globalThis.expect(Stdlib_Array.filterMap(Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(json), o => o["required"]), Stdlib_JSON.Decode.array), []), Stdlib_JSON.Decode.string)).toEqual(["id"]);
277
+ });
369
278
  globalThis.test("emits x-reventless-summary on field listed in summary", () => {
370
- let schema = S.schema(s => ({
371
- id: s.m(S.string),
372
- pluginName: s.m(S.string)
279
+ let schema = Sury.$schema(s => ({
280
+ id: s.m(Sury.string),
281
+ pluginName: s.m(Sury.string)
373
282
  }));
374
- let schema$p = withSpec(schema, {
375
- ids: emptySpec_ids,
376
- compositeIds: emptySpec_compositeIds,
377
- subIds: emptySpec_subIds,
378
- compositeSubIds: emptySpec_compositeSubIds,
379
- indexes: emptySpec_indexes,
380
- hidden: emptySpec_hidden,
381
- summary: ["pluginName"],
382
- drillTargets: emptySpec_drillTargets,
383
- drillTargetKeys: emptySpec_drillTargetKeys,
384
- collapsed: emptySpec_collapsed,
385
- scan: emptySpec_scan,
386
- scanSort: emptySpec_scanSort,
387
- semantic: emptySpec_semantic,
388
- metric: emptySpec_metric,
389
- lifecycle: undefined,
390
- groupBy: undefined,
391
- visibility: undefined,
392
- live: undefined,
393
- retired: undefined
394
- });
283
+ let newrecord = {...emptySpec};
284
+ newrecord.summary = ["pluginName"];
285
+ let spec = newrecord;
286
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
395
287
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
396
288
  let pluginNameSchema = getPropertyOf(json, "pluginName");
397
289
  let idSchema = getPropertyOf(json, "id");
@@ -404,34 +296,17 @@ globalThis.describe("SuryToJsonSchema:", () => {
404
296
  ]);
405
297
  });
406
298
  globalThis.test("emits x-reventless-drillTarget as the slice name", () => {
407
- let schema = S.schema(s => ({
408
- id: s.m(S.string),
409
- components: s.m(S.string)
299
+ let schema = Sury.$schema(s => ({
300
+ id: s.m(Sury.string),
301
+ components: s.m(Sury.string)
410
302
  }));
411
- let schema$p = withSpec(schema, {
412
- ids: emptySpec_ids,
413
- compositeIds: emptySpec_compositeIds,
414
- subIds: emptySpec_subIds,
415
- compositeSubIds: emptySpec_compositeSubIds,
416
- indexes: emptySpec_indexes,
417
- hidden: emptySpec_hidden,
418
- summary: emptySpec_summary,
419
- drillTargets: [[
420
- "components",
421
- "ResourceInventory"
422
- ]],
423
- drillTargetKeys: emptySpec_drillTargetKeys,
424
- collapsed: emptySpec_collapsed,
425
- scan: emptySpec_scan,
426
- scanSort: emptySpec_scanSort,
427
- semantic: emptySpec_semantic,
428
- metric: emptySpec_metric,
429
- lifecycle: undefined,
430
- groupBy: undefined,
431
- visibility: undefined,
432
- live: undefined,
433
- retired: undefined
434
- });
303
+ let newrecord = {...emptySpec};
304
+ newrecord.drillTargets = [[
305
+ "components",
306
+ "ResourceInventory"
307
+ ]];
308
+ let spec = newrecord;
309
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
435
310
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
436
311
  let componentsSchema = getPropertyOf(json, "components");
437
312
  let idSchema = getPropertyOf(json, "id");
@@ -444,100 +319,50 @@ globalThis.describe("SuryToJsonSchema:", () => {
444
319
  ]);
445
320
  });
446
321
  globalThis.test("emits x-reventless-drillTargetKey as the key path", () => {
447
- let schema = S.schema(s => ({
448
- id: s.m(S.string),
449
- components: s.m(S.string)
322
+ let schema = Sury.$schema(s => ({
323
+ id: s.m(Sury.string),
324
+ components: s.m(Sury.string)
450
325
  }));
451
- let schema$p = withSpec(schema, {
452
- ids: emptySpec_ids,
453
- compositeIds: emptySpec_compositeIds,
454
- subIds: emptySpec_subIds,
455
- compositeSubIds: emptySpec_compositeSubIds,
456
- indexes: emptySpec_indexes,
457
- hidden: emptySpec_hidden,
458
- summary: emptySpec_summary,
459
- drillTargets: [[
460
- "components",
461
- "ResourceInventory"
462
- ]],
463
- drillTargetKeys: [[
464
- "components",
465
- "kind/name"
466
- ]],
467
- collapsed: emptySpec_collapsed,
468
- scan: emptySpec_scan,
469
- scanSort: emptySpec_scanSort,
470
- semantic: emptySpec_semantic,
471
- metric: emptySpec_metric,
472
- lifecycle: undefined,
473
- groupBy: undefined,
474
- visibility: undefined,
475
- live: undefined,
476
- retired: undefined
477
- });
326
+ let newrecord = {...emptySpec};
327
+ newrecord.drillTargetKeys = [[
328
+ "components",
329
+ "kind/name"
330
+ ]];
331
+ newrecord.drillTargets = [[
332
+ "components",
333
+ "ResourceInventory"
334
+ ]];
335
+ let spec = newrecord;
336
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
478
337
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
479
338
  let componentsSchema = getPropertyOf(json, "components");
480
339
  globalThis.expect(Stdlib_Option.flatMap(Stdlib_Option.flatMap(componentsSchema, s => getProperty(s, "x-reventless-drillTargetKey")), Stdlib_JSON.Decode.string)).toBe("kind/name");
481
340
  });
482
341
  globalThis.test("does not emit x-reventless-drillTargetKey when no key was supplied", () => {
483
- let schema = S.schema(s => ({
484
- id: s.m(S.string),
485
- components: s.m(S.string)
342
+ let schema = Sury.$schema(s => ({
343
+ id: s.m(Sury.string),
344
+ components: s.m(Sury.string)
486
345
  }));
487
- let schema$p = withSpec(schema, {
488
- ids: emptySpec_ids,
489
- compositeIds: emptySpec_compositeIds,
490
- subIds: emptySpec_subIds,
491
- compositeSubIds: emptySpec_compositeSubIds,
492
- indexes: emptySpec_indexes,
493
- hidden: emptySpec_hidden,
494
- summary: emptySpec_summary,
495
- drillTargets: [[
496
- "components",
497
- "ResourceInventory"
498
- ]],
499
- drillTargetKeys: emptySpec_drillTargetKeys,
500
- collapsed: emptySpec_collapsed,
501
- scan: emptySpec_scan,
502
- scanSort: emptySpec_scanSort,
503
- semantic: emptySpec_semantic,
504
- metric: emptySpec_metric,
505
- lifecycle: undefined,
506
- groupBy: undefined,
507
- visibility: undefined,
508
- live: undefined,
509
- retired: undefined
510
- });
346
+ let newrecord = {...emptySpec};
347
+ newrecord.drillTargets = [[
348
+ "components",
349
+ "ResourceInventory"
350
+ ]];
351
+ let spec = newrecord;
352
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
511
353
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
512
354
  let componentsSchema = getPropertyOf(json, "components");
513
355
  globalThis.expect(Stdlib_Option.flatMap(componentsSchema, s => getProperty(s, "x-reventless-drillTargetKey"))).toBe(undefined);
514
356
  });
515
357
  globalThis.test("emits x-reventless-scan on field listed in scan", () => {
516
- let schema = S.schema(s => ({
517
- id: s.m(S.string),
518
- status: s.m(S.string)
358
+ let schema = Sury.$schema(s => ({
359
+ id: s.m(Sury.string),
360
+ status: s.m(Sury.string)
519
361
  }));
520
- let schema$p = withSpec(schema, {
521
- ids: emptySpec_ids,
522
- compositeIds: emptySpec_compositeIds,
523
- subIds: emptySpec_subIds,
524
- compositeSubIds: emptySpec_compositeSubIds,
525
- indexes: emptySpec_indexes,
526
- hidden: emptySpec_hidden,
527
- summary: emptySpec_summary,
528
- drillTargets: emptySpec_drillTargets,
529
- drillTargetKeys: emptySpec_drillTargetKeys,
530
- collapsed: emptySpec_collapsed,
531
- scan: ["status"],
532
- scanSort: emptySpec_scanSort,
533
- semantic: emptySpec_semantic,
534
- metric: emptySpec_metric,
535
- lifecycle: undefined,
536
- groupBy: undefined,
537
- visibility: undefined,
538
- live: undefined,
539
- retired: undefined
540
- });
362
+ let newrecord = {...emptySpec};
363
+ newrecord.scan = ["status"];
364
+ let spec = newrecord;
365
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
541
366
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
542
367
  let statusSchema = getPropertyOf(json, "status");
543
368
  let idSchema = getPropertyOf(json, "id");
@@ -550,31 +375,14 @@ globalThis.describe("SuryToJsonSchema:", () => {
550
375
  ]);
551
376
  });
552
377
  globalThis.test("emits x-reventless-scanSort on field listed in scanSort", () => {
553
- let schema = S.schema(s => ({
554
- id: s.m(S.string),
555
- name: s.m(S.string)
378
+ let schema = Sury.$schema(s => ({
379
+ id: s.m(Sury.string),
380
+ name: s.m(Sury.string)
556
381
  }));
557
- let schema$p = withSpec(schema, {
558
- ids: emptySpec_ids,
559
- compositeIds: emptySpec_compositeIds,
560
- subIds: emptySpec_subIds,
561
- compositeSubIds: emptySpec_compositeSubIds,
562
- indexes: emptySpec_indexes,
563
- hidden: emptySpec_hidden,
564
- summary: emptySpec_summary,
565
- drillTargets: emptySpec_drillTargets,
566
- drillTargetKeys: emptySpec_drillTargetKeys,
567
- collapsed: emptySpec_collapsed,
568
- scan: emptySpec_scan,
569
- scanSort: ["name"],
570
- semantic: emptySpec_semantic,
571
- metric: emptySpec_metric,
572
- lifecycle: undefined,
573
- groupBy: undefined,
574
- visibility: undefined,
575
- live: undefined,
576
- retired: undefined
577
- });
382
+ let newrecord = {...emptySpec};
383
+ newrecord.scanSort = ["name"];
384
+ let spec = newrecord;
385
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
578
386
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
579
387
  let nameSchema = getPropertyOf(json, "name");
580
388
  let idSchema = getPropertyOf(json, "id");
@@ -587,34 +395,17 @@ globalThis.describe("SuryToJsonSchema:", () => {
587
395
  ]);
588
396
  });
589
397
  globalThis.test("emits x-reventless-semantic on the field listed in semantic", () => {
590
- let schema = S.schema(s => ({
591
- id: s.m(S.string),
592
- total: s.m(S.float)
398
+ let schema = Sury.$schema(s => ({
399
+ id: s.m(Sury.string),
400
+ total: s.m(Sury.float)
593
401
  }));
594
- let schema$p = withSpec(schema, {
595
- ids: emptySpec_ids,
596
- compositeIds: emptySpec_compositeIds,
597
- subIds: emptySpec_subIds,
598
- compositeSubIds: emptySpec_compositeSubIds,
599
- indexes: emptySpec_indexes,
600
- hidden: emptySpec_hidden,
601
- summary: emptySpec_summary,
602
- drillTargets: emptySpec_drillTargets,
603
- drillTargetKeys: emptySpec_drillTargetKeys,
604
- collapsed: emptySpec_collapsed,
605
- scan: emptySpec_scan,
606
- scanSort: emptySpec_scanSort,
607
- semantic: [[
608
- "total",
609
- "currency"
610
- ]],
611
- metric: emptySpec_metric,
612
- lifecycle: undefined,
613
- groupBy: undefined,
614
- visibility: undefined,
615
- live: undefined,
616
- retired: undefined
617
- });
402
+ let newrecord = {...emptySpec};
403
+ newrecord.semantic = [[
404
+ "total",
405
+ "currency"
406
+ ]];
407
+ let spec = newrecord;
408
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
618
409
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
619
410
  let totalSchema = getPropertyOf(json, "total");
620
411
  let idSchema = getPropertyOf(json, "id");
@@ -627,37 +418,20 @@ globalThis.describe("SuryToJsonSchema:", () => {
627
418
  ]);
628
419
  });
629
420
  globalThis.test("emits x-reventless-metric {aggregate,label} on the field listed in metric", () => {
630
- let schema = S.schema(s => ({
631
- id: s.m(S.string),
632
- total: s.m(S.float)
421
+ let schema = Sury.$schema(s => ({
422
+ id: s.m(Sury.string),
423
+ total: s.m(Sury.float)
633
424
  }));
634
- let schema$p = withSpec(schema, {
635
- ids: emptySpec_ids,
636
- compositeIds: emptySpec_compositeIds,
637
- subIds: emptySpec_subIds,
638
- compositeSubIds: emptySpec_compositeSubIds,
639
- indexes: emptySpec_indexes,
640
- hidden: emptySpec_hidden,
641
- summary: emptySpec_summary,
642
- drillTargets: emptySpec_drillTargets,
643
- drillTargetKeys: emptySpec_drillTargetKeys,
644
- collapsed: emptySpec_collapsed,
645
- scan: emptySpec_scan,
646
- scanSort: emptySpec_scanSort,
647
- semantic: emptySpec_semantic,
648
- metric: [[
649
- "total",
650
- {
651
- aggregate: "sum",
652
- label: "Revenue"
653
- }
654
- ]],
655
- lifecycle: undefined,
656
- groupBy: undefined,
657
- visibility: undefined,
658
- live: undefined,
659
- retired: undefined
660
- });
425
+ let newrecord = {...emptySpec};
426
+ newrecord.metric = [[
427
+ "total",
428
+ {
429
+ aggregate: "sum",
430
+ label: "Revenue"
431
+ }
432
+ ]];
433
+ let spec = newrecord;
434
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
661
435
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
662
436
  let metricObj = Stdlib_Option.flatMap(getPropertyOf(json, "total"), s => getProperty(s, "x-reventless-metric"));
663
437
  globalThis.expect([
@@ -669,36 +443,19 @@ globalThis.describe("SuryToJsonSchema:", () => {
669
443
  ]);
670
444
  });
671
445
  globalThis.test("omits the metric label when empty (UI derives one from the field name)", () => {
672
- let schema = S.schema(s => ({
673
- total: s.m(S.float)
446
+ let schema = Sury.$schema(s => ({
447
+ total: s.m(Sury.float)
674
448
  }));
675
- let schema$p = withSpec(schema, {
676
- ids: emptySpec_ids,
677
- compositeIds: emptySpec_compositeIds,
678
- subIds: emptySpec_subIds,
679
- compositeSubIds: emptySpec_compositeSubIds,
680
- indexes: emptySpec_indexes,
681
- hidden: emptySpec_hidden,
682
- summary: emptySpec_summary,
683
- drillTargets: emptySpec_drillTargets,
684
- drillTargetKeys: emptySpec_drillTargetKeys,
685
- collapsed: emptySpec_collapsed,
686
- scan: emptySpec_scan,
687
- scanSort: emptySpec_scanSort,
688
- semantic: emptySpec_semantic,
689
- metric: [[
690
- "total",
691
- {
692
- aggregate: "sum",
693
- label: ""
694
- }
695
- ]],
696
- lifecycle: undefined,
697
- groupBy: undefined,
698
- visibility: undefined,
699
- live: undefined,
700
- retired: undefined
701
- });
449
+ let newrecord = {...emptySpec};
450
+ newrecord.metric = [[
451
+ "total",
452
+ {
453
+ aggregate: "sum",
454
+ label: ""
455
+ }
456
+ ]];
457
+ let spec = newrecord;
458
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
702
459
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
703
460
  let metricObj = Stdlib_Option.flatMap(getPropertyOf(json, "total"), s => getProperty(s, "x-reventless-metric"));
704
461
  globalThis.expect([
@@ -710,36 +467,20 @@ globalThis.describe("SuryToJsonSchema:", () => {
710
467
  ]);
711
468
  });
712
469
  globalThis.test("emits x-reventless-retired {label,showWhenFalse} on the retired field", () => {
713
- let schema = S.schema(s => ({
714
- id: s.m(S.string),
715
- archived: s.m(S.bool)
470
+ let schema = Sury.$schema(s => ({
471
+ id: s.m(Sury.string),
472
+ archived: s.m(Sury.bool)
716
473
  }));
717
- let schema$p = withSpec(schema, {
718
- ids: emptySpec_ids,
719
- compositeIds: emptySpec_compositeIds,
720
- subIds: emptySpec_subIds,
721
- compositeSubIds: emptySpec_compositeSubIds,
722
- indexes: emptySpec_indexes,
723
- hidden: emptySpec_hidden,
724
- summary: emptySpec_summary,
725
- drillTargets: emptySpec_drillTargets,
726
- drillTargetKeys: emptySpec_drillTargetKeys,
727
- collapsed: emptySpec_collapsed,
728
- scan: emptySpec_scan,
729
- scanSort: emptySpec_scanSort,
730
- semantic: emptySpec_semantic,
731
- metric: emptySpec_metric,
732
- lifecycle: undefined,
733
- groupBy: undefined,
734
- visibility: undefined,
735
- live: undefined,
736
- retired: {
737
- field: "archived",
738
- label: "Archived",
739
- showWhenFalse: true,
740
- values: undefined
741
- }
742
- });
474
+ let newrecord = {...emptySpec};
475
+ newrecord.retired = {
476
+ field: "archived",
477
+ label: "Archived",
478
+ showWhenFalse: true,
479
+ values: undefined,
480
+ namedWhenRetired: false
481
+ };
482
+ let spec = newrecord;
483
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
743
484
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
744
485
  let retiredObj = Stdlib_Option.flatMap(getPropertyOf(json, "archived"), s => getProperty(s, "x-reventless-retired"));
745
486
  globalThis.expect([
@@ -753,39 +494,24 @@ globalThis.describe("SuryToJsonSchema:", () => {
753
494
  ]);
754
495
  });
755
496
  let stateFormJson = values => {
756
- let schema = S.schema(s => ({
757
- customerId: s.m(S.string),
758
- accountStatus: s.m(S.union([
759
- S.literal("Active"),
760
- S.literal("Deactivated")
497
+ let schema = Sury.$schema(s => ({
498
+ customerId: s.m(Sury.string),
499
+ accountStatus: s.m(Sury.union([
500
+ Sury.literal("Active"),
501
+ Sury.literal("Deactivated")
761
502
  ]))
762
503
  }));
763
- return SuryToJsonSchema$ReventlessCore.deriveObjectSchema(withSpec(schema, {
764
- ids: emptySpec_ids,
765
- compositeIds: emptySpec_compositeIds,
766
- subIds: emptySpec_subIds,
767
- compositeSubIds: emptySpec_compositeSubIds,
768
- indexes: emptySpec_indexes,
769
- hidden: emptySpec_hidden,
770
- summary: emptySpec_summary,
771
- drillTargets: emptySpec_drillTargets,
772
- drillTargetKeys: emptySpec_drillTargetKeys,
773
- collapsed: emptySpec_collapsed,
774
- scan: emptySpec_scan,
775
- scanSort: emptySpec_scanSort,
776
- semantic: emptySpec_semantic,
777
- metric: emptySpec_metric,
778
- lifecycle: "accountStatus",
779
- groupBy: undefined,
780
- visibility: undefined,
781
- live: undefined,
782
- retired: {
783
- field: "accountStatus",
784
- label: "",
785
- showWhenFalse: false,
786
- values: values
787
- }
788
- }));
504
+ let newrecord = {...emptySpec};
505
+ newrecord.retired = {
506
+ field: "accountStatus",
507
+ label: "",
508
+ showWhenFalse: false,
509
+ values: values,
510
+ namedWhenRetired: false
511
+ };
512
+ newrecord.lifecycle = "accountStatus";
513
+ let spec = newrecord;
514
+ return SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec));
789
515
  };
790
516
  let retiredOn = (json, field) => Stdlib_Option.flatMap(getPropertyOf(json, field), s => getProperty(s, "x-reventless-retired"));
791
517
  let stringsAt = (retiredObj, key) => Stdlib_Option.map(Stdlib_Option.flatMap(Stdlib_Option.flatMap(retiredObj, r => getProperty(r, key)), Stdlib_JSON.Decode.array), a => Stdlib_Array.filterMap(a, Stdlib_JSON.Decode.string));
@@ -811,35 +537,19 @@ globalThis.describe("SuryToJsonSchema:", () => {
811
537
  ]), "accountStatus"), r => getProperty(r, "value"))).toEqual(undefined);
812
538
  });
813
539
  globalThis.test("omits both value and values entirely on the boolean form", () => {
814
- let schema = S.schema(s => ({
815
- archived: s.m(S.bool)
540
+ let schema = Sury.$schema(s => ({
541
+ archived: s.m(Sury.bool)
816
542
  }));
817
- let schema$p = withSpec(schema, {
818
- ids: emptySpec_ids,
819
- compositeIds: emptySpec_compositeIds,
820
- subIds: emptySpec_subIds,
821
- compositeSubIds: emptySpec_compositeSubIds,
822
- indexes: emptySpec_indexes,
823
- hidden: emptySpec_hidden,
824
- summary: emptySpec_summary,
825
- drillTargets: emptySpec_drillTargets,
826
- drillTargetKeys: emptySpec_drillTargetKeys,
827
- collapsed: emptySpec_collapsed,
828
- scan: emptySpec_scan,
829
- scanSort: emptySpec_scanSort,
830
- semantic: emptySpec_semantic,
831
- metric: emptySpec_metric,
832
- lifecycle: undefined,
833
- groupBy: undefined,
834
- visibility: undefined,
835
- live: undefined,
836
- retired: {
837
- field: "archived",
838
- label: "",
839
- showWhenFalse: false,
840
- values: undefined
841
- }
842
- });
543
+ let newrecord = {...emptySpec};
544
+ newrecord.retired = {
545
+ field: "archived",
546
+ label: "",
547
+ showWhenFalse: false,
548
+ values: undefined,
549
+ namedWhenRetired: false
550
+ };
551
+ let spec = newrecord;
552
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
843
553
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
844
554
  let retiredObj = retiredOn(json, "archived");
845
555
  globalThis.expect([
@@ -850,36 +560,44 @@ globalThis.describe("SuryToJsonSchema:", () => {
850
560
  undefined
851
561
  ]);
852
562
  });
853
- globalThis.test("omits the retired label when empty but always states showWhenFalse", () => {
854
- let schema = S.schema(s => ({
855
- deactivated: s.m(S.bool)
856
- }));
857
- let schema$p = withSpec(schema, {
858
- ids: emptySpec_ids,
859
- compositeIds: emptySpec_compositeIds,
860
- subIds: emptySpec_subIds,
861
- compositeSubIds: emptySpec_compositeSubIds,
862
- indexes: emptySpec_indexes,
863
- hidden: emptySpec_hidden,
864
- summary: emptySpec_summary,
865
- drillTargets: emptySpec_drillTargets,
866
- drillTargetKeys: emptySpec_drillTargetKeys,
867
- collapsed: emptySpec_collapsed,
868
- scan: emptySpec_scan,
869
- scanSort: emptySpec_scanSort,
870
- semantic: emptySpec_semantic,
871
- metric: emptySpec_metric,
872
- lifecycle: undefined,
873
- groupBy: undefined,
874
- visibility: undefined,
875
- live: undefined,
876
- retired: {
877
- field: "deactivated",
563
+ globalThis.test("carries namedWhenRetired only when the record opted in", () => {
564
+ let build = named => {
565
+ let schema = Sury.$schema(s => ({
566
+ archived: s.m(Sury.bool)
567
+ }));
568
+ let newrecord = {...emptySpec};
569
+ newrecord.retired = {
570
+ field: "archived",
878
571
  label: "",
879
572
  showWhenFalse: false,
880
- values: undefined
881
- }
882
- });
573
+ values: undefined,
574
+ namedWhenRetired: named
575
+ };
576
+ let spec = newrecord;
577
+ return Stdlib_Option.flatMap(Stdlib_Option.flatMap(retiredOn(SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec)), "archived"), r => getProperty(r, "namedWhenRetired")), Stdlib_JSON.Decode.bool);
578
+ };
579
+ globalThis.expect([
580
+ build(true),
581
+ build(false)
582
+ ]).toEqual([
583
+ true,
584
+ undefined
585
+ ]);
586
+ });
587
+ globalThis.test("omits the retired label when empty but always states showWhenFalse", () => {
588
+ let schema = Sury.$schema(s => ({
589
+ deactivated: s.m(Sury.bool)
590
+ }));
591
+ let newrecord = {...emptySpec};
592
+ newrecord.retired = {
593
+ field: "deactivated",
594
+ label: "",
595
+ showWhenFalse: false,
596
+ values: undefined,
597
+ namedWhenRetired: false
598
+ };
599
+ let spec = newrecord;
600
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
883
601
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
884
602
  let retiredObj = Stdlib_Option.flatMap(getPropertyOf(json, "deactivated"), s => getProperty(s, "x-reventless-retired"));
885
603
  globalThis.expect([
@@ -891,38 +609,21 @@ globalThis.describe("SuryToJsonSchema:", () => {
891
609
  ]);
892
610
  });
893
611
  globalThis.test("emits nothing for a schema with no retired annotation", () => {
894
- let schema = S.schema(s => ({
895
- archived: s.m(S.bool)
612
+ let schema = Sury.$schema(s => ({
613
+ archived: s.m(Sury.bool)
896
614
  }));
897
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(withSpec(schema, emptySpec));
615
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, emptySpec));
898
616
  globalThis.expect(Stdlib_Option.flatMap(getPropertyOf(json, "archived"), s => getProperty(s, "x-reventless-retired"))).toBe(undefined);
899
617
  });
900
618
  globalThis.test("emits x-reventless-group-by on the field named by groupBy", () => {
901
- let schema = S.schema(s => ({
902
- id: s.m(S.string),
903
- kind: s.m(S.string)
619
+ let schema = Sury.$schema(s => ({
620
+ id: s.m(Sury.string),
621
+ kind: s.m(Sury.string)
904
622
  }));
905
- let schema$p = withSpec(schema, {
906
- ids: emptySpec_ids,
907
- compositeIds: emptySpec_compositeIds,
908
- subIds: emptySpec_subIds,
909
- compositeSubIds: emptySpec_compositeSubIds,
910
- indexes: emptySpec_indexes,
911
- hidden: emptySpec_hidden,
912
- summary: emptySpec_summary,
913
- drillTargets: emptySpec_drillTargets,
914
- drillTargetKeys: emptySpec_drillTargetKeys,
915
- collapsed: emptySpec_collapsed,
916
- scan: emptySpec_scan,
917
- scanSort: emptySpec_scanSort,
918
- semantic: emptySpec_semantic,
919
- metric: emptySpec_metric,
920
- lifecycle: undefined,
921
- groupBy: "kind",
922
- visibility: undefined,
923
- live: undefined,
924
- retired: undefined
925
- });
623
+ let newrecord = {...emptySpec};
624
+ newrecord.groupBy = "kind";
625
+ let spec = newrecord;
626
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
926
627
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
927
628
  let kindSchema = getPropertyOf(json, "kind");
928
629
  let idSchema = getPropertyOf(json, "id");
@@ -935,31 +636,14 @@ globalThis.describe("SuryToJsonSchema:", () => {
935
636
  ]);
936
637
  });
937
638
  globalThis.test("emits x-reventless-collapsed on field listed in collapsed", () => {
938
- let schema = S.schema(s => ({
939
- id: s.m(S.string),
940
- primaryResource: s.m(S.string)
639
+ let schema = Sury.$schema(s => ({
640
+ id: s.m(Sury.string),
641
+ primaryResource: s.m(Sury.string)
941
642
  }));
942
- let schema$p = withSpec(schema, {
943
- ids: emptySpec_ids,
944
- compositeIds: emptySpec_compositeIds,
945
- subIds: emptySpec_subIds,
946
- compositeSubIds: emptySpec_compositeSubIds,
947
- indexes: emptySpec_indexes,
948
- hidden: emptySpec_hidden,
949
- summary: emptySpec_summary,
950
- drillTargets: emptySpec_drillTargets,
951
- drillTargetKeys: emptySpec_drillTargetKeys,
952
- collapsed: ["primaryResource"],
953
- scan: emptySpec_scan,
954
- scanSort: emptySpec_scanSort,
955
- semantic: emptySpec_semantic,
956
- metric: emptySpec_metric,
957
- lifecycle: undefined,
958
- groupBy: undefined,
959
- visibility: undefined,
960
- live: undefined,
961
- retired: undefined
962
- });
643
+ let newrecord = {...emptySpec};
644
+ newrecord.collapsed = ["primaryResource"];
645
+ let spec = newrecord;
646
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
963
647
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
964
648
  let primarySchema = getPropertyOf(json, "primaryResource");
965
649
  let idSchema = getPropertyOf(json, "id");
@@ -972,107 +656,39 @@ globalThis.describe("SuryToJsonSchema:", () => {
972
656
  ]);
973
657
  });
974
658
  globalThis.test("emits x-reventless-visibility at top level when visibility is Internal", () => {
975
- let schema = S.schema(s => ({
976
- id: s.m(S.string)
659
+ let schema = Sury.$schema(s => ({
660
+ id: s.m(Sury.string)
977
661
  }));
978
- let schema$p = withSpec(schema, {
979
- ids: emptySpec_ids,
980
- compositeIds: emptySpec_compositeIds,
981
- subIds: emptySpec_subIds,
982
- compositeSubIds: emptySpec_compositeSubIds,
983
- indexes: emptySpec_indexes,
984
- hidden: emptySpec_hidden,
985
- summary: emptySpec_summary,
986
- drillTargets: emptySpec_drillTargets,
987
- drillTargetKeys: emptySpec_drillTargetKeys,
988
- collapsed: emptySpec_collapsed,
989
- scan: emptySpec_scan,
990
- scanSort: emptySpec_scanSort,
991
- semantic: emptySpec_semantic,
992
- metric: emptySpec_metric,
993
- lifecycle: undefined,
994
- groupBy: undefined,
995
- visibility: "Internal",
996
- live: undefined,
997
- retired: undefined
998
- });
662
+ let newrecord = {...emptySpec};
663
+ newrecord.visibility = "Internal";
664
+ let spec = newrecord;
665
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
999
666
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
1000
667
  globalThis.expect(Stdlib_Option.flatMap(getProperty(json, "x-reventless-visibility"), Stdlib_JSON.Decode.string)).toBe("Internal");
1001
668
  });
1002
669
  globalThis.test("omits x-reventless-visibility when visibility is None (default Public)", () => {
1003
- let schema = S.schema(s => ({
1004
- id: s.m(S.string)
670
+ let schema = Sury.$schema(s => ({
671
+ id: s.m(Sury.string)
1005
672
  }));
1006
- let schema$p = withSpec(schema, {
1007
- ids: emptySpec_ids,
1008
- compositeIds: emptySpec_compositeIds,
1009
- subIds: emptySpec_subIds,
1010
- compositeSubIds: emptySpec_compositeSubIds,
1011
- indexes: emptySpec_indexes,
1012
- hidden: emptySpec_hidden,
1013
- summary: emptySpec_summary,
1014
- drillTargets: emptySpec_drillTargets,
1015
- drillTargetKeys: emptySpec_drillTargetKeys,
1016
- collapsed: emptySpec_collapsed,
1017
- scan: emptySpec_scan,
1018
- scanSort: emptySpec_scanSort,
1019
- semantic: emptySpec_semantic,
1020
- metric: emptySpec_metric,
1021
- lifecycle: undefined,
1022
- groupBy: undefined,
1023
- visibility: undefined,
1024
- live: undefined,
1025
- retired: undefined
1026
- });
673
+ let newrecord = {...emptySpec};
674
+ newrecord.visibility = undefined;
675
+ let spec = newrecord;
676
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
1027
677
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
1028
678
  globalThis.expect(getProperty(json, "x-reventless-visibility")).toBe(undefined);
1029
679
  });
1030
680
  globalThis.test("emits x-reventless-live at top level when live is declared", () => {
1031
- let schema = S.schema(s => ({
1032
- id: s.m(S.string)
1033
- }));
1034
- let offJson = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(withSpec(schema, {
1035
- ids: emptySpec_ids,
1036
- compositeIds: emptySpec_compositeIds,
1037
- subIds: emptySpec_subIds,
1038
- compositeSubIds: emptySpec_compositeSubIds,
1039
- indexes: emptySpec_indexes,
1040
- hidden: emptySpec_hidden,
1041
- summary: emptySpec_summary,
1042
- drillTargets: emptySpec_drillTargets,
1043
- drillTargetKeys: emptySpec_drillTargetKeys,
1044
- collapsed: emptySpec_collapsed,
1045
- scan: emptySpec_scan,
1046
- scanSort: emptySpec_scanSort,
1047
- semantic: emptySpec_semantic,
1048
- metric: emptySpec_metric,
1049
- lifecycle: undefined,
1050
- groupBy: undefined,
1051
- visibility: undefined,
1052
- live: false,
1053
- retired: undefined
1054
- }));
1055
- let onJson = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(withSpec(schema, {
1056
- ids: emptySpec_ids,
1057
- compositeIds: emptySpec_compositeIds,
1058
- subIds: emptySpec_subIds,
1059
- compositeSubIds: emptySpec_compositeSubIds,
1060
- indexes: emptySpec_indexes,
1061
- hidden: emptySpec_hidden,
1062
- summary: emptySpec_summary,
1063
- drillTargets: emptySpec_drillTargets,
1064
- drillTargetKeys: emptySpec_drillTargetKeys,
1065
- collapsed: emptySpec_collapsed,
1066
- scan: emptySpec_scan,
1067
- scanSort: emptySpec_scanSort,
1068
- semantic: emptySpec_semantic,
1069
- metric: emptySpec_metric,
1070
- lifecycle: undefined,
1071
- groupBy: undefined,
1072
- visibility: undefined,
1073
- live: true,
1074
- retired: undefined
681
+ let schema = Sury.$schema(s => ({
682
+ id: s.m(Sury.string)
1075
683
  }));
684
+ let newrecord = {...emptySpec};
685
+ newrecord.live = false;
686
+ let spec = newrecord;
687
+ let offJson = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec));
688
+ let newrecord$1 = {...emptySpec};
689
+ newrecord$1.live = true;
690
+ let spec$1 = newrecord$1;
691
+ let onJson = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec$1));
1076
692
  globalThis.expect([
1077
693
  Stdlib_Option.flatMap(getProperty(offJson, "x-reventless-live"), Stdlib_JSON.Decode.bool),
1078
694
  Stdlib_Option.flatMap(getProperty(onJson, "x-reventless-live"), Stdlib_JSON.Decode.bool)
@@ -1082,58 +698,25 @@ globalThis.describe("SuryToJsonSchema:", () => {
1082
698
  ]);
1083
699
  });
1084
700
  globalThis.test("omits x-reventless-live when live is None (no annotation)", () => {
1085
- let schema = S.schema(s => ({
1086
- id: s.m(S.string)
701
+ let schema = Sury.$schema(s => ({
702
+ id: s.m(Sury.string)
1087
703
  }));
1088
- let schema$p = withSpec(schema, {
1089
- ids: emptySpec_ids,
1090
- compositeIds: emptySpec_compositeIds,
1091
- subIds: emptySpec_subIds,
1092
- compositeSubIds: emptySpec_compositeSubIds,
1093
- indexes: emptySpec_indexes,
1094
- hidden: emptySpec_hidden,
1095
- summary: emptySpec_summary,
1096
- drillTargets: emptySpec_drillTargets,
1097
- drillTargetKeys: emptySpec_drillTargetKeys,
1098
- collapsed: emptySpec_collapsed,
1099
- scan: emptySpec_scan,
1100
- scanSort: emptySpec_scanSort,
1101
- semantic: emptySpec_semantic,
1102
- metric: emptySpec_metric,
1103
- lifecycle: undefined,
1104
- groupBy: undefined,
1105
- visibility: undefined,
1106
- live: undefined,
1107
- retired: undefined
1108
- });
704
+ let newrecord = {...emptySpec};
705
+ newrecord.live = undefined;
706
+ let spec = newrecord;
707
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
1109
708
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
1110
709
  globalThis.expect(getProperty(json, "x-reventless-live")).toBe(undefined);
1111
710
  });
1112
711
  globalThis.test("emits x-reventless-live and x-reventless-visibility together", () => {
1113
- let schema = S.schema(s => ({
1114
- id: s.m(S.string)
712
+ let schema = Sury.$schema(s => ({
713
+ id: s.m(Sury.string)
1115
714
  }));
1116
- let schema$p = withSpec(schema, {
1117
- ids: emptySpec_ids,
1118
- compositeIds: emptySpec_compositeIds,
1119
- subIds: emptySpec_subIds,
1120
- compositeSubIds: emptySpec_compositeSubIds,
1121
- indexes: emptySpec_indexes,
1122
- hidden: emptySpec_hidden,
1123
- summary: emptySpec_summary,
1124
- drillTargets: emptySpec_drillTargets,
1125
- drillTargetKeys: emptySpec_drillTargetKeys,
1126
- collapsed: emptySpec_collapsed,
1127
- scan: emptySpec_scan,
1128
- scanSort: emptySpec_scanSort,
1129
- semantic: emptySpec_semantic,
1130
- metric: emptySpec_metric,
1131
- lifecycle: undefined,
1132
- groupBy: undefined,
1133
- visibility: "Internal",
1134
- live: false,
1135
- retired: undefined
1136
- });
715
+ let newrecord = {...emptySpec};
716
+ newrecord.live = false;
717
+ newrecord.visibility = "Internal";
718
+ let spec = newrecord;
719
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
1137
720
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$p);
1138
721
  globalThis.expect([
1139
722
  Stdlib_Option.flatMap(getProperty(json, "x-reventless-visibility"), Stdlib_JSON.Decode.string),
@@ -1163,52 +746,34 @@ globalThis.describe("SuryToJsonSchema:", () => {
1163
746
  };
1164
747
  let sortStrings = xs => xs.toSorted(Primitive_string.compare);
1165
748
  globalThis.test("properties keyset matches between deriveObjectSchema and S.toJSONSchema", () => {
1166
- let schema = S.schema(s => ({
1167
- id: s.m(S.string),
1168
- name: s.m(S.string),
1169
- count: s.m(S.int)
749
+ let schema = Sury.$schema(s => ({
750
+ id: s.m(Sury.string),
751
+ name: s.m(Sury.string),
752
+ count: s.m(Sury.int)
1170
753
  }));
1171
754
  let derived = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
1172
- let native = S.toJSONSchema(schema);
755
+ let native = Sury.toJSONSchema(schema);
1173
756
  globalThis.expect(sortStrings(getKeys(derived))).toEqual(sortStrings(getKeys(native)));
1174
757
  });
1175
758
  globalThis.test("required array matches between deriveObjectSchema and S.toJSONSchema", () => {
1176
- let schema = S.schema(s => ({
1177
- id: s.m(S.string),
1178
- name: s.m(S.string)
759
+ let schema = Sury.$schema(s => ({
760
+ id: s.m(Sury.string),
761
+ name: s.m(Sury.string)
1179
762
  }));
1180
763
  let derived = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
1181
- let native = S.toJSONSchema(schema);
764
+ let native = Sury.toJSONSchema(schema);
1182
765
  globalThis.expect(sortStrings(getRequired(derived))).toEqual(sortStrings(getRequired(native)));
1183
766
  });
1184
767
  globalThis.test("S.toJSONSchema does NOT emit x-reventless-* keys even when metadata is set", () => {
1185
- let withSpec = (schema, spec) => S.Metadata.set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
1186
- let schema = S.schema(s => ({
1187
- entityId: s.m(S.string),
1188
- name: s.m(S.string)
768
+ let schema = Sury.$schema(s => ({
769
+ entityId: s.m(Sury.string),
770
+ name: s.m(Sury.string)
1189
771
  }));
1190
- let schema$p = withSpec(schema, {
1191
- ids: ["entityId"],
1192
- compositeIds: emptySpec_compositeIds,
1193
- subIds: emptySpec_subIds,
1194
- compositeSubIds: emptySpec_compositeSubIds,
1195
- indexes: emptySpec_indexes,
1196
- hidden: emptySpec_hidden,
1197
- summary: emptySpec_summary,
1198
- drillTargets: emptySpec_drillTargets,
1199
- drillTargetKeys: emptySpec_drillTargetKeys,
1200
- collapsed: emptySpec_collapsed,
1201
- scan: emptySpec_scan,
1202
- scanSort: emptySpec_scanSort,
1203
- semantic: emptySpec_semantic,
1204
- metric: emptySpec_metric,
1205
- lifecycle: undefined,
1206
- groupBy: undefined,
1207
- visibility: undefined,
1208
- live: undefined,
1209
- retired: undefined
1210
- });
1211
- let native = S.toJSONSchema(schema$p);
772
+ let newrecord = {...emptySpec};
773
+ newrecord.ids = ["entityId"];
774
+ let spec = newrecord;
775
+ let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
776
+ let native = Sury.toJSONSchema(schema$p);
1212
777
  let entityIdSchema = getPropertyOf(native, "entityId");
1213
778
  globalThis.expect(Stdlib_Option.flatMap(entityIdSchema, s => getProperty(s, "x-reventless-id"))).toBe(undefined);
1214
779
  });
@@ -1216,7 +781,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
1216
781
  globalThis.describe("reference / DCB-tag decoupling:", () => {
1217
782
  let formatOf = (schema, fieldName) => Stdlib_Option.flatMap(getPropertyOf(schema, fieldName), s => getProperty(s, "format"));
1218
783
  globalThis.test("a DCB-tagged field with no reference is still an entity id", () => {
1219
- let schema = S.schema(s => ({
784
+ let schema = Sury.$schema(s => ({
1220
785
  orderId: s.m(DcbTag$Reventless.string)
1221
786
  }));
1222
787
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
@@ -1225,7 +790,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
1225
790
  });
1226
791
  globalThis.test("a reference without a DCB tag is still an entity id", () => {
1227
792
  let field = Reference$Reventless.toWithoutDcbTag(undefined, "Customer");
1228
- let schema = S.schema(s => ({
793
+ let schema = Sury.$schema(s => ({
1229
794
  customerId: s.m(field)
1230
795
  }));
1231
796
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
@@ -1238,7 +803,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
1238
803
  globalThis.expect(Stdlib_Option.map(Reference$Reventless.getTarget(field), t => t.entity)).toEqual("Customer");
1239
804
  });
1240
805
  globalThis.test("neither reference nor tag emits x-reventless-semantic on the wire", () => {
1241
- let schema = S.schema(s => ({
806
+ let schema = Sury.$schema(s => ({
1242
807
  customerId: s.m(Reference$Reventless.to_(undefined, undefined, "Customer")),
1243
808
  placedAt: s.m(DateTime$Reventless.string)
1244
809
  }));
@@ -1251,8 +816,8 @@ globalThis.describe("SuryToJsonSchema:", () => {
1251
816
  globalThis.describe("type-carried semantics on a command field:", () => {
1252
817
  let semanticOf = (json, fieldName) => Stdlib_Option.flatMap(getPropertyOf(json, fieldName), s => getProperty(s, "x-reventless-semantic"));
1253
818
  globalThis.test("a storage-ref command field emits the semantic id", () => {
1254
- let schema = S.schema(s => ({
1255
- productId: s.m(S.string),
819
+ let schema = Sury.$schema(s => ({
820
+ productId: s.m(Sury.string),
1256
821
  imageUrl: s.m(StorageRef$Reventless.forStore(undefined, "productImages"))
1257
822
  }));
1258
823
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
@@ -1260,7 +825,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
1260
825
  globalThis.expect(semanticOf(json, "productId")).toBe(undefined);
1261
826
  });
1262
827
  globalThis.test("it carries the store identity and marks the type as its source", () => {
1263
- let schema = S.schema(s => ({
828
+ let schema = Sury.$schema(s => ({
1264
829
  imageUrl: s.m(StorageRef$Reventless.forStore("catalog", "productImages"))
1265
830
  }));
1266
831
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
@@ -1278,55 +843,38 @@ globalThis.describe("SuryToJsonSchema:", () => {
1278
843
  ]));
1279
844
  });
1280
845
  globalThis.test("the underlying string shape is unchanged", () => {
1281
- let schema = S.schema(s => ({
846
+ let schema = Sury.$schema(s => ({
1282
847
  imageUrl: s.m(StorageRef$Reventless.forStore(undefined, "productImages"))
1283
848
  }));
1284
849
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
1285
850
  globalThis.expect(Stdlib_Option.flatMap(getPropertyOf(json, "imageUrl"), s => getProperty(s, "type"))).toEqual("string");
1286
851
  });
1287
852
  globalThis.test("an optional storage-ref field keeps both its semantic and its nullability", () => {
1288
- let schema = S.schema(s => ({
1289
- imageUrl: s.m(S.option(StorageRef$Reventless.forStore(undefined, "productImages")))
853
+ let schema = Sury.$schema(s => ({
854
+ imageUrl: s.m(Sury.$option(StorageRef$Reventless.forStore(undefined, "productImages")))
1290
855
  }));
1291
856
  let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
1292
857
  globalThis.expect(semanticOf(json, "imageUrl")).toEqual("storageRef");
1293
858
  globalThis.expect(Stdlib_Option.isSome(Stdlib_Option.flatMap(getPropertyOf(json, "imageUrl"), s => getProperty(s, "oneOf")))).toBe(true);
1294
859
  });
1295
860
  globalThis.test("a type-carried semantic beats an annotation naming the same field", () => {
1296
- let withSpec = (schema, spec) => S.Metadata.set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
1297
- let schema = withSpec(S.schema(s => ({
861
+ let newrecord = {...emptySpec};
862
+ newrecord.semantic = [[
863
+ "imageUrl",
864
+ "image"
865
+ ]];
866
+ let spec = newrecord;
867
+ let schema = Sury.$schema(s => ({
1298
868
  imageUrl: s.m(StorageRef$Reventless.forStore(undefined, "productImages"))
1299
- })), {
1300
- ids: emptySpec_ids,
1301
- compositeIds: emptySpec_compositeIds,
1302
- subIds: emptySpec_subIds,
1303
- compositeSubIds: emptySpec_compositeSubIds,
1304
- indexes: emptySpec_indexes,
1305
- hidden: emptySpec_hidden,
1306
- summary: emptySpec_summary,
1307
- drillTargets: emptySpec_drillTargets,
1308
- drillTargetKeys: emptySpec_drillTargetKeys,
1309
- collapsed: emptySpec_collapsed,
1310
- scan: emptySpec_scan,
1311
- scanSort: emptySpec_scanSort,
1312
- semantic: [[
1313
- "imageUrl",
1314
- "image"
1315
- ]],
1316
- metric: emptySpec_metric,
1317
- lifecycle: undefined,
1318
- groupBy: undefined,
1319
- visibility: undefined,
1320
- live: undefined,
1321
- retired: undefined
1322
- });
1323
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema);
869
+ }));
870
+ let schema$1 = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
871
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(schema$1);
1324
872
  globalThis.expect(semanticOf(json, "imageUrl")).toEqual("storageRef");
1325
873
  });
1326
874
  });
1327
875
  globalThis.describe("branded scalars keep their underlying shape:", () => {
1328
876
  let keyOf = (json, name, key) => Stdlib_Option.flatMap(getPropertyOf(json, name), s => getProperty(s, key));
1329
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
877
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
1330
878
  contactEmail: s.m(Email$Reventless.schema),
1331
879
  taxRate: s.m(Percent$Reventless.schema)
1332
880
  })));
@@ -1359,9 +907,9 @@ globalThis.describe("SuryToJsonSchema:", () => {
1359
907
  });
1360
908
  });
1361
909
  globalThis.describe("Money changes the field's shape, and says so:", () => {
1362
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
910
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
1363
911
  price: s.m(Money$Reventless.schema),
1364
- quantity: s.m(S.float)
912
+ quantity: s.m(Sury.float)
1365
913
  })));
1366
914
  let keyOf = (name, key) => Stdlib_Option.flatMap(getPropertyOf(json, name), s => getProperty(s, key));
1367
915
  globalThis.test("the field is an object, not a number", () => {
@@ -1411,7 +959,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
1411
959
  });
1412
960
  });
1413
961
  globalThis.describe("DateRange is an object whose parts stay date-times:", () => {
1414
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
962
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
1415
963
  deliveryWindow: s.m(DateRange$Reventless.schema),
1416
964
  orderedAt: s.m(DateTime$Reventless.string)
1417
965
  })));
@@ -1449,9 +997,9 @@ globalThis.describe("SuryToJsonSchema:", () => {
1449
997
  });
1450
998
  });
1451
999
  globalThis.describe("GeoPoint is an object carrying the geoPoint marker:", () => {
1452
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
1000
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
1453
1001
  location: s.m(GeoPoint$Reventless.schema),
1454
- lat: s.m(S.float)
1002
+ lat: s.m(Sury.float)
1455
1003
  })));
1456
1004
  let keyOf = (name, key) => Stdlib_Option.flatMap(getPropertyOf(json, name), s => getProperty(s, key));
1457
1005
  globalThis.test("the field is an object, not a pair of numbers", () => {
@@ -1487,12 +1035,12 @@ globalThis.describe("SuryToJsonSchema:", () => {
1487
1035
  });
1488
1036
  });
1489
1037
  globalThis.describe("an optional field inside a nested record:", () => {
1490
- let inner = S.schema(s => ({
1491
- street: s.m(S.string),
1492
- unit: s.m(S.option(S.string))
1038
+ let inner = Sury.$schema(s => ({
1039
+ street: s.m(Sury.string),
1040
+ unit: s.m(Sury.$option(Sury.string))
1493
1041
  }));
1494
- let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(S.schema(s => ({
1495
- id: s.m(S.string),
1042
+ let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(Sury.$schema(s => ({
1043
+ id: s.m(Sury.string),
1496
1044
  address: s.m(inner)
1497
1045
  })));
1498
1046
  let nestedRequired = Stdlib_Array.filterMap(Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_Option.flatMap(getPropertyOf(json, "address"), a => getProperty(a, "required")), Stdlib_JSON.Decode.array), []), Stdlib_JSON.Decode.string);