@reventlessdev/reventless-core 3.0.0-alpha.239 → 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.
- package/CHANGELOG.md +28 -0
- package/package.json +9 -9
- package/src/Message.res +11 -11
- package/src/Message.res.mjs +15 -14
- package/src/Projection.res +2 -2
- package/src/Projection.res.mjs +5 -4
- package/src/adapter/Monitoring/Monitoring.res +24 -2
- package/src/adapter/Monitoring/Monitoring.res.mjs +3 -3
- package/src/admin/Platform_AdminApi.res.mjs +3 -3
- package/src/admin/Platform_Admin_Structure.res +33 -113
- package/src/admin/Platform_Admin_Structure.res.mjs +8 -139
- package/src/admin/UiFragmentRegistry/StateChangeSlice/UiFragmentRegistry.res.mjs +12 -12
- package/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments.res.mjs +14 -14
- package/src/components/Aggregate/Aggregate_Callback.res +2 -2
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +4 -4
- package/src/components/Api/ApiAllowedStatesHelpers.res.mjs +3 -3
- package/src/components/Api/ApiNoApiHelpers.res.mjs +5 -5
- package/src/components/Api/ApiTargetStateHelpers.res.mjs +3 -3
- package/src/components/Api/GraphQL_FragmentGenerator.res +18 -12
- package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +7 -13
- package/src/components/Api/GraphQL_SchemaInspector.res +1 -1
- package/src/components/Api/GraphQL_SchemaInspector.res.mjs +1 -1
- package/src/components/Api/MCP_SchemaGenerator.res +1 -1
- package/src/components/Api/MCP_SchemaGenerator.res.mjs +1 -1
- package/src/components/Api/SchemaType.res +6 -10
- package/src/components/Api/SchemaType.res.mjs +4 -4
- package/src/components/Api/StorageRefFields.res +1 -1
- package/src/components/Api/StorageRefFields.res.mjs +1 -1
- package/src/components/Api/SuryToJsonSchema.res +11 -0
- package/src/components/Api/SuryToJsonSchema.res.mjs +2 -1
- package/src/components/AutomationSlice/AutomationSlice_Callback.res +3 -4
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +22 -23
- package/src/components/CommandTopic/CommandTopic_Callback.res +1 -2
- package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +3 -4
- package/src/components/CommandTopic/CommandTopic_Helpers.res +1 -1
- package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +3 -3
- package/src/components/Counter/Counter.res.mjs +2 -2
- package/src/components/Counter/Counter_Callback.res.mjs +4 -4
- package/src/components/Counter/Counter_Operations.res.mjs +4 -4
- package/src/components/Dcb/Dcb_Builder.res +1 -1
- package/src/components/Dcb/Dcb_Builder.res.mjs +8 -6
- package/src/components/DcbEventLog/DcbEventLog_Builder.res.mjs +4 -3
- package/src/components/EventCollector/EventCollector_Builder.res +1 -1
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +1 -2
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +11 -12
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +3 -4
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +24 -25
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +1 -1
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res.mjs +3 -3
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +2 -2
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +4 -4
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +1 -1
- package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +3 -3
- package/src/plugin/api/PluginBaseFragment.res +12 -29
- package/src/plugin/api/PluginBaseFragment.res.mjs +3 -22
- package/src/plugin/component/Capability_Inference.res +118 -1
- package/src/plugin/component/Capability_Inference.res.mjs +128 -1
- package/src/plugin/component/Plugin_Builder.res +2 -2
- package/src/plugin/component/Plugin_Builder.res.mjs +2 -1
- package/src/plugin/component/Plugin_Helpers.res +11 -11
- package/src/plugin/component/Plugin_Helpers.res.mjs +11 -10
- package/src/plugin/component/Plugin_Structure.res +349 -274
- package/src/plugin/component/Plugin_Structure.res.mjs +212 -175
- package/src/plugin/component/Plugin_SubscriptionSchema.res +1 -1
- package/src/plugin/component/Plugin_SubscriptionSchema.res.mjs +1 -1
- package/src/plugin/component/SchemaWalker.res +11 -11
- package/src/plugin/component/SchemaWalker.res.mjs +8 -9
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +15 -15
- package/src/plugin/lifecycle/PluginBehavior.res.mjs +55 -55
- package/src/plugin/lifecycle/PluginSpec.res +22 -7
- package/src/plugin/lifecycle/PluginSpec.res.mjs +91 -36
- package/src/plugin/lifecycle/PluginsReadModelSpec.res +36 -9
- package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +33 -22
- package/src/util/Interstack.res +3 -3
- package/src/util/LogFormat.res +1 -2
- package/src/util/LogFormat.res.mjs +2 -2
- package/tests/IdentityTest.res +6 -7
- package/tests/IdentityTest.res.mjs +7 -9
- package/tests/adapter/MonitoringTest.res +30 -3
- package/tests/adapter/MonitoringTest.res.mjs +31 -12
- package/tests/adapter/RuntimeExtensionHookReachTest.res +0 -1
- package/tests/adapter/RuntimeExtensionHookReachTest.res.mjs +5 -7
- package/tests/admin/Platform_Admin_StructureTest.res +254 -0
- package/tests/admin/Platform_Admin_StructureTest.res.mjs +219 -0
- package/tests/aggregate/AggregateCacheTest.res +0 -1
- package/tests/aggregate/AggregateCacheTest.res.mjs +13 -15
- package/tests/aggregate/AggregateConflictTest.res +0 -1
- package/tests/aggregate/AggregateConflictTest.res.mjs +7 -9
- package/tests/aggregate/AggregateFixtures.res +0 -1
- package/tests/aggregate/AggregateFixtures.res.mjs +19 -21
- package/tests/aggregate/AggregateSnapshotTest.res +1 -2
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +15 -16
- package/tests/api/ApiNoApiTest.res.mjs +17 -9
- package/tests/api/GraphQL_FragmentGeneratorTest.res +62 -1
- package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +102 -58
- package/tests/api/PsInternalFieldsReadModel.res +21 -0
- package/tests/api/PsInternalFieldsReadModel.res.mjs +74 -0
- package/tests/api/StorageRefFieldsTest.res.mjs +13 -13
- package/tests/api/SuryToJsonSchemaTest.res +43 -0
- package/tests/api/SuryToJsonSchemaTest.res.mjs +352 -849
- package/tests/commandgenerator/CommandGeneratorFixtures.res +0 -1
- package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +19 -21
- package/tests/commandgenerator/OwnerStampingTest.res +0 -1
- package/tests/commandgenerator/OwnerStampingTest.res.mjs +9 -11
- package/tests/commandtopic/CommandTopicCallbackFixtures.res +0 -1
- package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +7 -9
- package/tests/counter/CounterFixtures.res +0 -1
- package/tests/counter/CounterFixtures.res.mjs +1 -4
- package/tests/dcb/DcbDecodeTest.res.mjs +24 -24
- package/tests/dcb/DcbEventLogOperationsTest.res +2 -2
- package/tests/dcb/DcbEventLogOperationsTest.res.mjs +3 -3
- package/tests/dcb/DcbEventLogSchemaTest.res.mjs +7 -7
- package/tests/dcb/DcbFixtures.res +0 -1
- package/tests/dcb/DcbFixtures.res.mjs +87 -89
- package/tests/dcb/DcbTagTest.res.mjs +6 -6
- package/tests/dcb/DcbValidationTest.res.mjs +52 -52
- package/tests/eventlog/EventLogFixtures.res +0 -1
- package/tests/eventlog/EventLogFixtures.res.mjs +7 -9
- package/tests/eventmapper/EventMapperFixtures.res +0 -1
- package/tests/eventmapper/EventMapperFixtures.res.mjs +24 -26
- package/tests/eventtopic/EventTopicFixtures.res +0 -1
- package/tests/eventtopic/EventTopicFixtures.res.mjs +7 -9
- package/tests/extensionpoint/ExtensionPointFixtures.res +0 -1
- package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +10 -12
- package/tests/extensionpoint/ExtensionPointOperationsTest.res +1 -2
- package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +9 -10
- package/tests/logger/LogFormatTest.res +3 -2
- package/tests/logger/LogFormatTest.res.mjs +7 -9
- package/tests/message/MessageTest.res +2 -2
- package/tests/message/MessageTest.res.mjs +8 -7
- package/tests/message/MetaEnvelopeTest.res +5 -5
- package/tests/message/MetaEnvelopeTest.res.mjs +12 -11
- package/tests/plugin/ManifestVisibilityTest.res.mjs +7 -7
- package/tests/plugin/PluginDefinitionScalars.res +5 -3
- package/tests/plugin/PluginDefinitionScalars.res.mjs +2 -2
- package/tests/plugin/PluginLifecycleCorpusTest.res +4 -3
- package/tests/plugin/PluginLifecycleCorpusTest.res.mjs +3 -6
- package/tests/plugin/PluginSpecExperiment.res +0 -1
- package/tests/plugin/PluginSpecExperiment.res.mjs +12 -14
- package/tests/plugin/PluginStructureTest.res +188 -1
- package/tests/plugin/PluginStructureTest.res.mjs +293 -102
- package/tests/plugin/Plugin_EventQuerySchemaTest.res.mjs +3 -3
- package/tests/plugin/SchemaWalkerTest.res +0 -1
- package/tests/plugin/SchemaWalkerTest.res.mjs +17 -19
- package/tests/plugin/StateChangeSlice/PsAttachInvoice.res.mjs +5 -5
- package/tests/plugin/StateChangeSlice/PsChangePhoto.res.mjs +8 -8
- package/tests/plugin/StateChangeSlice/PsDispatchShipment.res.mjs +5 -5
- package/tests/plugin/StateChangeSlice/PsGatedCommands.res.mjs +9 -9
- package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +5 -5
- package/tests/plugin/StateChangeSlice/PsReserveStock.res.mjs +8 -8
- package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +15 -15
- package/tests/plugin/StateChangeSlice/PsTypoStore.res +31 -0
- package/tests/plugin/StateChangeSlice/PsTypoStore.res.mjs +62 -0
- package/tests/plugin/StateChangeSlice/PsUploadAvatar.res.mjs +8 -8
- package/tests/plugin/StateChangeSlice/PsUploadImages.res +40 -0
- package/tests/plugin/StateChangeSlice/PsUploadImages.res.mjs +66 -0
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +13 -12
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +8 -8
- package/tests/plugin/StateViewSlice/PsCategoriesView.res.mjs +6 -6
- package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +10 -10
- package/tests/plugin/StateViewSlice/PsGatedView.res.mjs +6 -6
- package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +9 -9
- package/tests/plugin/StateViewSlice/PsShipmentsView.res.mjs +11 -10
- package/tests/plugin/pluginDefinitionRequiredScalars.txt +15 -0
- package/tests/querydb/QueryDbFixtures.res +0 -1
- package/tests/querydb/QueryDbFixtures.res.mjs +5 -7
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +0 -1
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +4 -6
- package/tests/util/CommandPublisherTest.res +0 -1
- package/tests/util/CommandPublisherTest.res.mjs +4 -6
|
@@ -65,9 +65,7 @@ let conventionalLabelNames = [
|
|
|
65
65
|
"displayname"
|
|
66
66
|
];
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
return SchemaType$ReventlessCore.fromSury(entityName, item.location, item.schema);
|
|
70
|
-
}
|
|
68
|
+
let shapeOfField = SchemaType$ReventlessCore.fromSury;
|
|
71
69
|
|
|
72
70
|
function lifecycleFieldFromStateSchema(entityName, stateSchema) {
|
|
73
71
|
let spec = StateAnnotations$Reventless.getSpec(stateSchema);
|
|
@@ -75,13 +73,11 @@ function lifecycleFieldFromStateSchema(entityName, stateSchema) {
|
|
|
75
73
|
if (annotated !== undefined) {
|
|
76
74
|
return annotated;
|
|
77
75
|
} else if (stateSchema.type === "object") {
|
|
78
|
-
return Stdlib_Option.
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
} else {
|
|
82
|
-
return false;
|
|
76
|
+
return Stdlib_Option.flatMap(stateSchema.properties["lifecycle"], schema => {
|
|
77
|
+
if (isLifecycleShape(SchemaType$ReventlessCore.fromSury(entityName, "lifecycle", schema))) {
|
|
78
|
+
return "lifecycle";
|
|
83
79
|
}
|
|
84
|
-
})
|
|
80
|
+
});
|
|
85
81
|
} else {
|
|
86
82
|
return;
|
|
87
83
|
}
|
|
@@ -122,8 +118,8 @@ function checkRetiredValue(entityName, stateSchema) {
|
|
|
122
118
|
log.warn("Plugin_Structure", undefined, entityName + `: @retired(` + named + `) is on "` + field + `", which is not this record's lifecycle field` + Stdlib_Option.getOr(Stdlib_Option.map(lifecycle, f => ` (that is "` + f + `")`), " (it declares none)") + `. A retirement state no command's @transition can name loses the command filtering the state form exists for.`);
|
|
123
119
|
}
|
|
124
120
|
let declared;
|
|
125
|
-
declared = stateSchema.type === "object" ? Stdlib_Option.getOr(Stdlib_Option.map(stateSchema.
|
|
126
|
-
let match =
|
|
121
|
+
declared = stateSchema.type === "object" ? Stdlib_Option.getOr(Stdlib_Option.map(stateSchema.properties[field], schema => {
|
|
122
|
+
let match = SchemaType$ReventlessCore.fromSury(entityName, field, schema);
|
|
127
123
|
if (typeof match !== "object") {
|
|
128
124
|
return [];
|
|
129
125
|
}
|
|
@@ -168,8 +164,8 @@ function reportRetiredStates(pluginName, failures, unchecked) {
|
|
|
168
164
|
function lifecycleStatesFromStateSchema(entityName, stateSchema) {
|
|
169
165
|
return Stdlib_Option.flatMap(lifecycleFieldFromStateSchema(entityName, stateSchema), field => {
|
|
170
166
|
if (stateSchema.type === "object") {
|
|
171
|
-
return Stdlib_Option.map(stateSchema.
|
|
172
|
-
let match =
|
|
167
|
+
return Stdlib_Option.map(stateSchema.properties[field], schema => {
|
|
168
|
+
let match = SchemaType$ReventlessCore.fromSury(entityName, field, schema);
|
|
173
169
|
if (typeof match !== "object") {
|
|
174
170
|
return [];
|
|
175
171
|
}
|
|
@@ -235,29 +231,17 @@ function lifecycleTopologyFindings(writables, lifecycleStatesByView) {
|
|
|
235
231
|
Object.entries(lifecycleStatesByView).forEach(param => {
|
|
236
232
|
let states = param[1];
|
|
237
233
|
let view = param[0];
|
|
238
|
-
let
|
|
234
|
+
let reachable = Stdlib_Array.reduce(writables, [], (acc, w) => {
|
|
239
235
|
if (w.linkedViews.includes(view)) {
|
|
240
|
-
return acc.concat(Stdlib_Array.
|
|
241
|
-
let match = cmd.allowedStates;
|
|
242
|
-
let match$1 = cmd.targetState;
|
|
243
|
-
if (match !== undefined && match$1 !== undefined) {
|
|
244
|
-
return inner.concat(match.map(from => [
|
|
245
|
-
from,
|
|
246
|
-
match$1
|
|
247
|
-
]));
|
|
248
|
-
} else {
|
|
249
|
-
return inner;
|
|
250
|
-
}
|
|
251
|
-
}));
|
|
236
|
+
return acc.concat(Stdlib_Array.filterMap(w.commands, cmd => cmd.targetState));
|
|
252
237
|
} else {
|
|
253
238
|
return acc;
|
|
254
239
|
}
|
|
255
240
|
});
|
|
256
|
-
if (
|
|
241
|
+
if (reachable.length === 0) {
|
|
257
242
|
return;
|
|
258
243
|
}
|
|
259
244
|
let initial = states[0];
|
|
260
|
-
let reachable = edges.map(param => param[1]);
|
|
261
245
|
states.forEach(state => {
|
|
262
246
|
if (!reachable.includes(state) && Primitive_object.notequal(state, initial)) {
|
|
263
247
|
findings.push([
|
|
@@ -298,29 +282,30 @@ function labelFieldsFromStateSchema(entityName, stateSchema) {
|
|
|
298
282
|
};
|
|
299
283
|
}
|
|
300
284
|
let candidates;
|
|
301
|
-
candidates = stateSchema.type === "object" ? stateSchema.
|
|
302
|
-
|
|
303
|
-
|
|
285
|
+
candidates = stateSchema.type === "object" ? Object.entries(stateSchema.properties).filter(param => {
|
|
286
|
+
let name = param[0];
|
|
287
|
+
if (name !== "TAG" && name !== "id") {
|
|
288
|
+
return isLabelShape(SchemaType$ReventlessCore.fromSury(entityName, name, param[1]));
|
|
304
289
|
} else {
|
|
305
290
|
return false;
|
|
306
291
|
}
|
|
307
292
|
}) : [];
|
|
308
|
-
let conventional = candidates.find(
|
|
309
|
-
let lower =
|
|
293
|
+
let conventional = candidates.find(param => {
|
|
294
|
+
let lower = param[0].toLowerCase();
|
|
310
295
|
return conventionalLabelNames.some(n => n === lower);
|
|
311
296
|
});
|
|
312
297
|
let picked = conventional !== undefined ? [
|
|
313
|
-
conventional,
|
|
298
|
+
conventional[0],
|
|
314
299
|
"Convention"
|
|
315
|
-
] : Stdlib_Option.map(candidates[0],
|
|
316
|
-
|
|
300
|
+
] : Stdlib_Option.map(candidates[0], param => [
|
|
301
|
+
param[0],
|
|
317
302
|
"Position"
|
|
318
303
|
]);
|
|
319
304
|
if (picked !== undefined) {
|
|
320
|
-
let
|
|
305
|
+
let name = picked[0];
|
|
321
306
|
return {
|
|
322
|
-
field:
|
|
323
|
-
searchableFields: [
|
|
307
|
+
field: name,
|
|
308
|
+
searchableFields: [name],
|
|
324
309
|
source: picked[1]
|
|
325
310
|
};
|
|
326
311
|
}
|
|
@@ -377,7 +362,7 @@ function toEventDef(v) {
|
|
|
377
362
|
}
|
|
378
363
|
|
|
379
364
|
function extractEventDefs(eventSchema) {
|
|
380
|
-
if (eventSchema.type === "
|
|
365
|
+
if (eventSchema.type === "anyOf") {
|
|
381
366
|
return Stdlib_Array.filterMap(eventSchema.anyOf, toEventDef);
|
|
382
367
|
} else {
|
|
383
368
|
return Stdlib_Option.mapOr(toEventDef(eventSchema), [], def => [def]);
|
|
@@ -392,19 +377,8 @@ function extractErrorDefs(errorSchema) {
|
|
|
392
377
|
}));
|
|
393
378
|
}
|
|
394
379
|
|
|
395
|
-
function
|
|
396
|
-
|
|
397
|
-
let readModels = readModelsOpt !== undefined ? readModelsOpt : [];
|
|
398
|
-
let stateViewSlices = stateViewSlicesOpt !== undefined ? stateViewSlicesOpt : [];
|
|
399
|
-
let stateChangeSlices = stateChangeSlicesOpt !== undefined ? stateChangeSlicesOpt : [];
|
|
400
|
-
let automationSlices = automationSlicesOpt !== undefined ? automationSlicesOpt : [];
|
|
401
|
-
let outboundTranslationSlices = outboundTranslationSlicesOpt !== undefined ? outboundTranslationSlicesOpt : [];
|
|
402
|
-
let inboundTranslationSlices = inboundTranslationSlicesOpt !== undefined ? inboundTranslationSlicesOpt : [];
|
|
403
|
-
let extensions = extensionsOpt !== undefined ? extensionsOpt : [];
|
|
404
|
-
let extensionPoints = extensionPointsOpt !== undefined ? extensionPointsOpt : [];
|
|
405
|
-
let componentChapters = componentChaptersOpt !== undefined ? componentChaptersOpt : ({});
|
|
406
|
-
let qualify = (prefix, names) => names.map(n => prefix + "." + n);
|
|
407
|
-
let isCreateCommandName = name => [
|
|
380
|
+
function isCreateCommandName(name) {
|
|
381
|
+
return [
|
|
408
382
|
"Add",
|
|
409
383
|
"Create",
|
|
410
384
|
"Register",
|
|
@@ -414,135 +388,193 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
414
388
|
"Start",
|
|
415
389
|
"Place"
|
|
416
390
|
].some(p => name.startsWith(p));
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
"Collection",
|
|
422
|
-
undefined
|
|
423
|
-
];
|
|
424
|
-
} else {
|
|
425
|
-
return [
|
|
426
|
-
"Instance",
|
|
427
|
-
undefined
|
|
428
|
-
];
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
let taggedFields = Object.entries(properties).filter(param => {
|
|
432
|
-
let fieldSchema = param[1];
|
|
433
|
-
if (param[0] !== "TAG") {
|
|
434
|
-
if (DcbTag$Reventless.isTagged(fieldSchema)) {
|
|
435
|
-
return true;
|
|
436
|
-
} else {
|
|
437
|
-
return DcbTag$Reventless.isTaggedArray(fieldSchema);
|
|
438
|
-
}
|
|
439
|
-
} else {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
let taggedField = Stdlib_Option.orElse(taggedFields.find(param => DcbTag$Reventless.isPartitionTag(param[1])), taggedFields[0]);
|
|
444
|
-
if (taggedField === undefined) {
|
|
445
|
-
return [
|
|
446
|
-
"Collection",
|
|
447
|
-
undefined
|
|
448
|
-
];
|
|
449
|
-
}
|
|
450
|
-
let fieldName = taggedField[0];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function commandLevelAndId(isAggregate, variantName, properties) {
|
|
394
|
+
if (isAggregate) {
|
|
451
395
|
if (isCreateCommandName(variantName)) {
|
|
452
396
|
return [
|
|
453
397
|
"Collection",
|
|
454
|
-
|
|
398
|
+
undefined
|
|
455
399
|
];
|
|
456
400
|
} else {
|
|
457
401
|
return [
|
|
458
402
|
"Instance",
|
|
459
|
-
|
|
403
|
+
undefined
|
|
460
404
|
];
|
|
461
405
|
}
|
|
462
|
-
}
|
|
463
|
-
let
|
|
464
|
-
|
|
465
|
-
|
|
406
|
+
}
|
|
407
|
+
let taggedFields = Object.entries(properties).filter(param => {
|
|
408
|
+
let fieldSchema = param[1];
|
|
409
|
+
if (param[0] !== "TAG") {
|
|
410
|
+
if (DcbTag$Reventless.isTagged(fieldSchema)) {
|
|
411
|
+
return true;
|
|
412
|
+
} else {
|
|
413
|
+
return DcbTag$Reventless.isTaggedArray(fieldSchema);
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
return false;
|
|
466
417
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
418
|
+
});
|
|
419
|
+
let taggedField = Stdlib_Option.orElse(taggedFields.find(param => DcbTag$Reventless.isPartitionTag(param[1])), taggedFields[0]);
|
|
420
|
+
if (taggedField === undefined) {
|
|
421
|
+
return [
|
|
422
|
+
"Collection",
|
|
423
|
+
undefined
|
|
424
|
+
];
|
|
425
|
+
}
|
|
426
|
+
let fieldName = taggedField[0];
|
|
427
|
+
if (isCreateCommandName(variantName)) {
|
|
428
|
+
return [
|
|
429
|
+
"Collection",
|
|
430
|
+
fieldName
|
|
431
|
+
];
|
|
432
|
+
} else {
|
|
433
|
+
return [
|
|
434
|
+
"Instance",
|
|
435
|
+
fieldName
|
|
436
|
+
];
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function accessKeysFor(rule) {
|
|
441
|
+
if (typeof rule !== "object") {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
let groups = rule._0;
|
|
445
|
+
if (groups.length !== 0) {
|
|
446
|
+
return groups;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function annotateArgTypes(schema, argTypes) {
|
|
451
|
+
Stdlib_Option.forEach(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(schema), o => o["properties"]), Stdlib_JSON.Decode.object), props => {
|
|
452
|
+
Object.entries(props).forEach(param => {
|
|
453
|
+
let match = argTypes[param[0]];
|
|
454
|
+
let match$1 = Stdlib_JSON.Decode.object(param[1]);
|
|
455
|
+
if (match !== undefined && match$1 !== undefined) {
|
|
456
|
+
match$1["x-reventless-graphql-type"] = match;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
return schema;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function toCommandDef(isAggregate, mutationFieldFor, parentSchema, commandAuthorization, v) {
|
|
465
|
+
let mkDef = (variantName, properties) => {
|
|
466
|
+
let match = commandLevelAndId(isAggregate, variantName, properties);
|
|
467
|
+
let references = extractReferences(properties);
|
|
468
|
+
let allowedStates = ApiAllowedStatesHelpers$ReventlessCore.getAllowedStates(parentSchema, variantName);
|
|
469
|
+
let targetState = ApiTargetStateHelpers$ReventlessCore.getTargetState(parentSchema, variantName);
|
|
470
|
+
let apiExposed = false;
|
|
471
|
+
if (!ApiNoApiHelpers$ReventlessCore.isNoApi(parentSchema)) {
|
|
472
|
+
let excluded = ApiNoApiHelpers$ReventlessCore.getExcludedVariants(parentSchema);
|
|
473
|
+
apiExposed = excluded !== undefined ? !excluded.has(variantName) : true;
|
|
470
474
|
}
|
|
475
|
+
let syntheticCommand = DcbTag$Reventless.isVariantPayloadBearing(parentSchema, variantName) ? ({
|
|
476
|
+
TAG: variantName
|
|
477
|
+
}) : variantName;
|
|
478
|
+
let requiredAccess = accessKeysFor(commandAuthorization(syntheticCommand));
|
|
479
|
+
let mutationField = apiExposed ? mutationFieldFor(variantName) : "";
|
|
480
|
+
let jsonSchema = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(v);
|
|
481
|
+
let annotatedSchema = apiExposed ? Stdlib_Option.mapOr(GraphQL_FragmentGenerator$ReventlessCore.mutationArgTypes(mutationField, v), jsonSchema, __x => annotateArgTypes(jsonSchema, __x)) : jsonSchema;
|
|
482
|
+
return {
|
|
483
|
+
name: variantName,
|
|
484
|
+
schema: JSON.stringify(annotatedSchema),
|
|
485
|
+
level: match[0],
|
|
486
|
+
aggregateIdField: match[1],
|
|
487
|
+
mutationField: mutationField,
|
|
488
|
+
references: references,
|
|
489
|
+
allowedStates: allowedStates,
|
|
490
|
+
targetState: targetState,
|
|
491
|
+
apiExposed: apiExposed,
|
|
492
|
+
requiredAccess: requiredAccess,
|
|
493
|
+
ownerField: Owner$Reventless.fieldNamesOfProperties(properties)[0]
|
|
494
|
+
};
|
|
471
495
|
};
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
let
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (!ApiNoApiHelpers$ReventlessCore.isNoApi(parentSchema)) {
|
|
480
|
-
let excluded = ApiNoApiHelpers$ReventlessCore.getExcludedVariants(parentSchema);
|
|
481
|
-
apiExposed = excluded !== undefined ? !excluded.has(variantName) : true;
|
|
496
|
+
switch (v.type) {
|
|
497
|
+
case "string" :
|
|
498
|
+
let variantName = v.const;
|
|
499
|
+
if (variantName !== undefined) {
|
|
500
|
+
return mkDef(variantName, {});
|
|
501
|
+
} else {
|
|
502
|
+
return;
|
|
482
503
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
let mutationField = apiExposed ? mutationFieldFor(variantName) : "";
|
|
488
|
-
let jsonSchema = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(v);
|
|
489
|
-
let annotatedSchema = apiExposed ? Stdlib_Option.mapOr(GraphQL_FragmentGenerator$ReventlessCore.mutationArgTypes(mutationField, v), jsonSchema, __x => {
|
|
490
|
-
Stdlib_Option.forEach(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(jsonSchema), o => o["properties"]), Stdlib_JSON.Decode.object), props => {
|
|
491
|
-
Object.entries(props).forEach(param => {
|
|
492
|
-
let match = __x[param[0]];
|
|
493
|
-
let match$1 = Stdlib_JSON.Decode.object(param[1]);
|
|
494
|
-
if (match !== undefined && match$1 !== undefined) {
|
|
495
|
-
match$1["x-reventless-graphql-type"] = match;
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
return jsonSchema;
|
|
501
|
-
}) : jsonSchema;
|
|
502
|
-
return {
|
|
503
|
-
name: variantName,
|
|
504
|
-
schema: JSON.stringify(annotatedSchema),
|
|
505
|
-
level: match[0],
|
|
506
|
-
aggregateIdField: match[1],
|
|
507
|
-
mutationField: mutationField,
|
|
508
|
-
references: references,
|
|
509
|
-
allowedStates: allowedStates,
|
|
510
|
-
targetState: targetState,
|
|
511
|
-
apiExposed: apiExposed,
|
|
512
|
-
requiredAccess: requiredAccess,
|
|
513
|
-
ownerField: Owner$Reventless.fieldNamesOfProperties(properties)[0]
|
|
514
|
-
};
|
|
515
|
-
};
|
|
516
|
-
switch (v.type) {
|
|
517
|
-
case "string" :
|
|
518
|
-
let variantName = v.const;
|
|
519
|
-
if (variantName !== undefined) {
|
|
520
|
-
return mkDef(variantName, {});
|
|
521
|
-
} else {
|
|
504
|
+
case "object" :
|
|
505
|
+
let properties = v.properties;
|
|
506
|
+
return Stdlib_Option.flatMap(properties["TAG"], tagSchema => {
|
|
507
|
+
if (tagSchema.type !== "string") {
|
|
522
508
|
return;
|
|
523
509
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
510
|
+
let variantName = tagSchema.const;
|
|
511
|
+
if (variantName !== undefined) {
|
|
512
|
+
return mkDef(variantName, properties);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
default:
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function extractCommandDefs(isAggregate, mutationFieldFor, commandAuthorization, commandSchema) {
|
|
521
|
+
if (commandSchema.type === "anyOf") {
|
|
522
|
+
return Stdlib_Array.filterMap(commandSchema.anyOf, v => toCommandDef(isAggregate, mutationFieldFor, commandSchema, commandAuthorization, v));
|
|
523
|
+
} else {
|
|
524
|
+
return Stdlib_Option.mapOr(toCommandDef(isAggregate, mutationFieldFor, commandSchema, commandAuthorization, commandSchema), [], def => [def]);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function visibilityTag(v) {
|
|
529
|
+
if (v === "Public") {
|
|
530
|
+
return;
|
|
531
|
+
} else {
|
|
532
|
+
return "Internal";
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function queryableDefFromSpec(plugin, name, stateSchema, authorization, visibilityOpt, consumedEventTypesOpt, linkedWriteSideOpt, chapter) {
|
|
537
|
+
let visibility = visibilityOpt !== undefined ? visibilityOpt : "Public";
|
|
538
|
+
let consumedEventTypes = consumedEventTypesOpt !== undefined ? consumedEventTypesOpt : [];
|
|
539
|
+
let linkedWriteSide = linkedWriteSideOpt !== undefined ? linkedWriteSideOpt : [];
|
|
540
|
+
let qf = Api_Naming$ReventlessCore.queryFieldNamesForReadModel(plugin, name, undefined);
|
|
541
|
+
let label = labelFieldsFromStateSchema(name, stateSchema);
|
|
542
|
+
let keyField = GraphQL_FragmentGenerator$ReventlessCore.resolveKeyField(name, stateSchema);
|
|
543
|
+
return {
|
|
544
|
+
name: name,
|
|
545
|
+
queryField: qf.listFieldName,
|
|
546
|
+
schema: JSON.stringify(SuryToJsonSchema$ReventlessCore.deriveObjectSchema(stateSchema)),
|
|
547
|
+
consumedEventTypes: consumedEventTypes,
|
|
548
|
+
linkedWriteSide: linkedWriteSide,
|
|
549
|
+
labelField: label.field,
|
|
550
|
+
searchableFields: label.searchableFields,
|
|
551
|
+
labelFieldSource: labelFieldSourceToString(label.source),
|
|
552
|
+
lifecycleField: lifecycleFieldFromStateSchema(name, stateSchema),
|
|
553
|
+
ownerField: Owner$Reventless.fieldNames(stateSchema)[0],
|
|
554
|
+
retiredField: retiredFieldFromStateSchema(stateSchema),
|
|
555
|
+
retiredValues: retiredValuesFromStateSchema(stateSchema),
|
|
556
|
+
namedWhenRetired: namedWhenRetiredFromStateSchema(stateSchema),
|
|
557
|
+
visibility: visibilityTag(visibility),
|
|
558
|
+
chapter: chapter,
|
|
559
|
+
singleQueryField: qf.singleFieldName,
|
|
560
|
+
idField: Stdlib_Option.map(keyField, param => param[0]),
|
|
561
|
+
idFieldSource: Stdlib_Option.map(keyField, param => param[1]),
|
|
562
|
+
requiredAccess: accessKeysFor(authorization)
|
|
545
563
|
};
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChangeSlicesOpt, automationSlicesOpt, outboundTranslationSlicesOpt, inboundTranslationSlicesOpt, extensionsOpt, extensionPointsOpt, componentChaptersOpt) {
|
|
567
|
+
let aggregates = aggregatesOpt !== undefined ? aggregatesOpt : [];
|
|
568
|
+
let readModels = readModelsOpt !== undefined ? readModelsOpt : [];
|
|
569
|
+
let stateViewSlices = stateViewSlicesOpt !== undefined ? stateViewSlicesOpt : [];
|
|
570
|
+
let stateChangeSlices = stateChangeSlicesOpt !== undefined ? stateChangeSlicesOpt : [];
|
|
571
|
+
let automationSlices = automationSlicesOpt !== undefined ? automationSlicesOpt : [];
|
|
572
|
+
let outboundTranslationSlices = outboundTranslationSlicesOpt !== undefined ? outboundTranslationSlicesOpt : [];
|
|
573
|
+
let inboundTranslationSlices = inboundTranslationSlicesOpt !== undefined ? inboundTranslationSlicesOpt : [];
|
|
574
|
+
let extensions = extensionsOpt !== undefined ? extensionsOpt : [];
|
|
575
|
+
let extensionPoints = extensionPointsOpt !== undefined ? extensionPointsOpt : [];
|
|
576
|
+
let componentChapters = componentChaptersOpt !== undefined ? componentChaptersOpt : ({});
|
|
577
|
+
let qualify = (prefix, names) => names.map(n => prefix + "." + n);
|
|
546
578
|
let scsProduced = stateChangeSlices.map(SCS => [
|
|
547
579
|
SCS.Spec.name,
|
|
548
580
|
qualify(name, DcbTag$Reventless.extractVariantNames(SCS.Spec.eventSchema))
|
|
@@ -690,7 +722,7 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
690
722
|
return [];
|
|
691
723
|
}
|
|
692
724
|
};
|
|
693
|
-
if (schema.type === "
|
|
725
|
+
if (schema.type === "anyOf") {
|
|
694
726
|
return schema.anyOf.flatMap(fromVariant);
|
|
695
727
|
} else {
|
|
696
728
|
return fromVariant(schema);
|
|
@@ -708,16 +740,13 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
708
740
|
}
|
|
709
741
|
});
|
|
710
742
|
let requiredStores = Belt_SetString.toArray(Belt_SetString.fromArray(requiredStoreDeclarations.map(d => d.store)));
|
|
743
|
+
let found = Capability_Inference$ReventlessCore.collisions(requiredStoreDeclarations);
|
|
744
|
+
if (found.length !== 0) {
|
|
745
|
+
Stdlib_JsError.throwWithMessage(name + `: two declared object stores look like one store misspelled.\n` + found.map(Capability_Inference$ReventlessCore.collisionMessage).join("\n"));
|
|
746
|
+
}
|
|
711
747
|
storeDeclarationSites.forEach(param => {
|
|
712
748
|
Capability_Inference$ReventlessCore.scanSchema(param[0], param[1]).forEach(w => log.warn("Plugin_Structure", undefined, Capability_Inference$ReventlessCore.message(w)));
|
|
713
749
|
});
|
|
714
|
-
let visibilityTag = v => {
|
|
715
|
-
if (v === "Public") {
|
|
716
|
-
return;
|
|
717
|
-
} else {
|
|
718
|
-
return "Internal";
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
750
|
let lifecycleStatesByView = {};
|
|
722
751
|
let recordLifecycle = (entityName, stateSchema) => {
|
|
723
752
|
let states = lifecycleStatesFromStateSchema(entityName, stateSchema);
|
|
@@ -916,7 +945,7 @@ export {
|
|
|
916
945
|
isLabelShape,
|
|
917
946
|
isLifecycleShape,
|
|
918
947
|
conventionalLabelNames,
|
|
919
|
-
|
|
948
|
+
shapeOfField,
|
|
920
949
|
lifecycleFieldFromStateSchema,
|
|
921
950
|
retiredFromStateSchema,
|
|
922
951
|
retiredFieldFromStateSchema,
|
|
@@ -934,6 +963,14 @@ export {
|
|
|
934
963
|
toEventDef,
|
|
935
964
|
extractEventDefs,
|
|
936
965
|
extractErrorDefs,
|
|
966
|
+
isCreateCommandName,
|
|
967
|
+
commandLevelAndId,
|
|
968
|
+
accessKeysFor,
|
|
969
|
+
annotateArgTypes,
|
|
970
|
+
toCommandDef,
|
|
971
|
+
extractCommandDefs,
|
|
972
|
+
visibilityTag,
|
|
973
|
+
queryableDefFromSpec,
|
|
937
974
|
make,
|
|
938
975
|
}
|
|
939
976
|
/* log Not a pure module */
|
|
@@ -44,7 +44,7 @@ let sourceCFields = (
|
|
|
44
44
|
mutationEntries->Array.forEach(entry => {
|
|
45
45
|
let schema = entry.commandSchema
|
|
46
46
|
switch schema {
|
|
47
|
-
|
|
|
47
|
+
| AnyOf({anyOf}) =>
|
|
48
48
|
anyOf->Array.forEachWithIndex((_, i) => {
|
|
49
49
|
let fieldName = entry.fieldNames->Array.get(i)->Option.getOr("")
|
|
50
50
|
if fieldName->String.length > 0 {
|
|
@@ -10,7 +10,7 @@ open Plugin_BuiltHook
|
|
|
10
10
|
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// Type description — maps a sury schema node to a human-readable string.
|
|
13
|
-
// Optional fields in sury are
|
|
13
|
+
// Optional fields in sury are AnyOf({anyOf}) containing Null or Undefined.
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
let rec describeSchema = (schema: S.t<unknown>): string =>
|
|
16
16
|
switch schema {
|
|
@@ -20,7 +20,7 @@ let rec describeSchema = (schema: S.t<unknown>): string =>
|
|
|
20
20
|
| Boolean(_) => "bool"
|
|
21
21
|
| BigInt(_) => "bigint"
|
|
22
22
|
| Null(_) => "null"
|
|
23
|
-
|
|
|
23
|
+
| AnyOf({anyOf}) =>
|
|
24
24
|
// Nullable/optional field: Union of Null/Undefined + one real type.
|
|
25
25
|
let nonNull = anyOf->Array.filter(v =>
|
|
26
26
|
switch v {
|
|
@@ -58,7 +58,7 @@ let rec describeSchema = (schema: S.t<unknown>): string =>
|
|
|
58
58
|
// (Union containing Null or Undefined).
|
|
59
59
|
let isOptionalSchema = (schema: S.t<unknown>): bool =>
|
|
60
60
|
switch schema {
|
|
61
|
-
|
|
|
61
|
+
| AnyOf({anyOf}) =>
|
|
62
62
|
anyOf->Array.some(v =>
|
|
63
63
|
switch v {
|
|
64
64
|
| Null(_) | Undefined(_) => true
|
|
@@ -112,11 +112,11 @@ let hashConstructors = (ctors: array<constructorSchema>): string => {
|
|
|
112
112
|
// ---------------------------------------------------------------------------
|
|
113
113
|
// TAG item helper — extracts the const string value from a TAG schema item.
|
|
114
114
|
// ---------------------------------------------------------------------------
|
|
115
|
-
let tagConstOf = (
|
|
116
|
-
|
|
117
|
-
->
|
|
118
|
-
->Option.flatMap(
|
|
119
|
-
switch
|
|
115
|
+
let tagConstOf = (properties: dict<S.t<unknown>>): option<string> =>
|
|
116
|
+
properties
|
|
117
|
+
->Dict.get("TAG")
|
|
118
|
+
->Option.flatMap(schema =>
|
|
119
|
+
switch schema {
|
|
120
120
|
| String({const: ?Some(v)}) => Some(v)
|
|
121
121
|
| _ => None
|
|
122
122
|
}
|
|
@@ -135,7 +135,7 @@ let walkSchema = (typeName: string, schema: S.t<unknown>): typeSchema =>
|
|
|
135
135
|
fields,
|
|
136
136
|
structuralHash: hashFields(fields),
|
|
137
137
|
}
|
|
138
|
-
|
|
|
138
|
+
| AnyOf({anyOf}) =>
|
|
139
139
|
// Check if this is a nullable scalar vs. a true variant union.
|
|
140
140
|
let hasNullLike = anyOf->Array.some(v =>
|
|
141
141
|
switch v {
|
|
@@ -150,8 +150,8 @@ let walkSchema = (typeName: string, schema: S.t<unknown>): typeSchema =>
|
|
|
150
150
|
let constructors =
|
|
151
151
|
anyOf->Array.filterMap(variantSchema =>
|
|
152
152
|
switch variantSchema {
|
|
153
|
-
| Object({
|
|
154
|
-
tagConstOf(
|
|
153
|
+
| Object({properties}) =>
|
|
154
|
+
tagConstOf(properties)->Option.map(name => {
|
|
155
155
|
name,
|
|
156
156
|
fields: extractFields(properties),
|
|
157
157
|
})
|
|
@@ -25,7 +25,7 @@ function describeSchema(schema) {
|
|
|
25
25
|
case "object" :
|
|
26
26
|
let inner = Object.entries(schema.properties).filter(param => param[0] !== "TAG").toSorted((param, param$1) => Primitive_string.compare(param[0], param$1[0])).map(param => param[0] + ":" + describeSchema(param[1])).join(",");
|
|
27
27
|
return "{" + inner + "}";
|
|
28
|
-
case "
|
|
28
|
+
case "anyOf" :
|
|
29
29
|
let nonNull = schema.anyOf.filter(v => {
|
|
30
30
|
switch (v.type) {
|
|
31
31
|
case "null" :
|
|
@@ -47,7 +47,7 @@ function describeSchema(schema) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function isOptionalSchema(schema) {
|
|
50
|
-
if (schema.type === "
|
|
50
|
+
if (schema.type === "anyOf") {
|
|
51
51
|
return schema.anyOf.some(v => {
|
|
52
52
|
switch (v.type) {
|
|
53
53
|
case "null" :
|
|
@@ -100,13 +100,12 @@ function hashConstructors(ctors) {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
function tagConstOf(
|
|
104
|
-
return Stdlib_Option.flatMap(
|
|
105
|
-
|
|
106
|
-
if (match.type !== "string") {
|
|
103
|
+
function tagConstOf(properties) {
|
|
104
|
+
return Stdlib_Option.flatMap(properties["TAG"], schema => {
|
|
105
|
+
if (schema.type !== "string") {
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
109
|
-
let v =
|
|
108
|
+
let v = schema.const;
|
|
110
109
|
if (v !== undefined) {
|
|
111
110
|
return v;
|
|
112
111
|
}
|
|
@@ -123,7 +122,7 @@ function walkSchema(typeName, schema) {
|
|
|
123
122
|
fields: fields,
|
|
124
123
|
structuralHash: hashFields(fields)
|
|
125
124
|
};
|
|
126
|
-
case "
|
|
125
|
+
case "anyOf" :
|
|
127
126
|
let anyOf = schema.anyOf;
|
|
128
127
|
let hasNullLike = anyOf.some(v => {
|
|
129
128
|
switch (v.type) {
|
|
@@ -147,7 +146,7 @@ function walkSchema(typeName, schema) {
|
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
148
|
let properties = variantSchema.properties;
|
|
150
|
-
return Stdlib_Option.map(tagConstOf(
|
|
149
|
+
return Stdlib_Option.map(tagConstOf(properties), name => ({
|
|
151
150
|
name: name,
|
|
152
151
|
fields: extractFields(properties)
|
|
153
152
|
}));
|