@reventlessdev/reventless-core 3.0.0-alpha.250 → 3.0.0-alpha.252

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 (70) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/package.json +7 -7
  3. package/src/admin/Platform_Admin_Structure.res +4 -1
  4. package/src/admin/Platform_Admin_Structure.res.mjs +4 -2
  5. package/src/admin/Platform_BakedManifest.res.mjs +3 -1
  6. package/src/admin/Platform_ComponentDefinitionsApi.res +31 -1
  7. package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +29 -1
  8. package/src/admin/Platform_PluginStructuresApi.res +80 -8
  9. package/src/admin/Platform_PluginStructuresApi.res.mjs +76 -2
  10. package/src/admin/UiFragmentRegistry/StateChangeSlice/UiFragmentRegistry.res.mjs +8 -0
  11. package/src/components/Api/ApiNoApiHelpers.res +37 -3
  12. package/src/components/Api/ApiNoApiHelpers.res.mjs +29 -2
  13. package/src/components/AutomationSlice/AutomationSlice_Callback.res +4 -4
  14. package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +3 -3
  15. package/src/plugin/api/PluginBaseFragment.res +3 -3
  16. package/src/plugin/component/Plugin_Structure.res +787 -384
  17. package/src/plugin/component/Plugin_Structure.res.mjs +430 -20
  18. package/src/plugin/connect/PluginConnectExtension_Mapping.res +3 -6
  19. package/src/plugin/connect/PluginConnectExtension_Mapping.res.mjs +14 -2
  20. package/src/plugin/connect/PluginExtensionPoint_Plugin.res +0 -1
  21. package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +63 -3
  22. package/src/plugin/connect/PluginExtensionPoint_UiFragment.res.mjs +22 -3
  23. package/src/plugin/lifecycle/PluginBehavior.res +11 -11
  24. package/src/plugin/lifecycle/PluginBehavior.res.mjs +11 -11
  25. package/src/plugin/lifecycle/PluginSpec.res +11 -3
  26. package/src/plugin/lifecycle/PluginSpec.res.mjs +11 -3
  27. package/tests/admin/AdminApiSchemaDriftTest.res +486 -0
  28. package/tests/admin/AdminApiSchemaDriftTest.res.mjs +619 -0
  29. package/tests/admin/Platform_Admin_StructureTest.res +8 -3
  30. package/tests/admin/Platform_Admin_StructureTest.res.mjs +8 -2
  31. package/tests/admin/Platform_BakedManifestTest.res +2 -0
  32. package/tests/admin/Platform_BakedManifestTest.res.mjs +3 -1
  33. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +10 -0
  34. package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +30 -8
  35. package/tests/admin/Platform_PluginStructuresApiTest.res +28 -1
  36. package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +27 -5
  37. package/tests/aggregate/AggregateCacheTest.res.mjs +15 -3
  38. package/tests/aggregate/AggregateConflictTest.res.mjs +15 -3
  39. package/tests/aggregate/AggregateFixtures.res.mjs +15 -3
  40. package/tests/aggregate/AggregateSnapshotTest.res.mjs +21 -5
  41. package/tests/api/ApiNoApiTest.res +46 -0
  42. package/tests/api/ApiNoApiTest.res.mjs +49 -1
  43. package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +27 -3
  44. package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +12 -2
  45. package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +2 -0
  46. package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +12 -2
  47. package/tests/dcb/DcbFixtures.res.mjs +8 -0
  48. package/tests/dcb/DcbStateChangeSliceTest.res.mjs +18 -0
  49. package/tests/eventmapper/EventMapperFixtures.res.mjs +15 -3
  50. package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +9 -1
  51. package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +9 -1
  52. package/tests/message/MessageTest.res +2 -0
  53. package/tests/message/MessageTest.res.mjs +3 -1
  54. package/tests/plugin/PluginStructureAccessTest.res.mjs +2 -0
  55. package/tests/plugin/PluginStructureTest.res +294 -1
  56. package/tests/plugin/PluginStructureTest.res.mjs +373 -3
  57. package/tests/plugin/StateChangeSlice/PsAttachInvoice.res.mjs +8 -0
  58. package/tests/plugin/StateChangeSlice/PsChangePhoto.res.mjs +8 -0
  59. package/tests/plugin/StateChangeSlice/PsDispatchShipment.res.mjs +8 -0
  60. package/tests/plugin/StateChangeSlice/PsGatedCommands.res.mjs +8 -0
  61. package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +8 -0
  62. package/tests/plugin/StateChangeSlice/PsReserveStock.res.mjs +8 -0
  63. package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +8 -0
  64. package/tests/plugin/StateChangeSlice/PsTransitionSwitch.res +59 -0
  65. package/tests/plugin/StateChangeSlice/PsTransitionSwitch.res.mjs +115 -0
  66. package/tests/plugin/StateChangeSlice/PsTypoStore.res.mjs +8 -0
  67. package/tests/plugin/StateChangeSlice/PsUploadAvatar.res.mjs +8 -0
  68. package/tests/plugin/StateChangeSlice/PsUploadImages.res.mjs +8 -0
  69. package/tests/plugin/pluginDefinitionRequiredScalars.txt +26 -0
  70. package/tests/util/CommandPublisherTest.res.mjs +9 -1
@@ -327,12 +327,68 @@ function Make(Spec) {
327
327
  }
328
328
  ];
329
329
  };
330
+ let publishedEvents = [
331
+ {
332
+ name: "UnknownPluginDetected",
333
+ fromEventTypes: ["VersionDetected"]
334
+ },
335
+ {
336
+ name: "PluginConnected",
337
+ fromEventTypes: [
338
+ "VersionConnected",
339
+ "VersionPromoted"
340
+ ]
341
+ },
342
+ {
343
+ name: "PluginDisconnected",
344
+ fromEventTypes: ["VersionDisconnected"]
345
+ },
346
+ {
347
+ name: "PluginDeactivated",
348
+ fromEventTypes: ["VersionDeactivated"]
349
+ },
350
+ {
351
+ name: "PluginActivated",
352
+ fromEventTypes: ["VersionActivated"]
353
+ },
354
+ {
355
+ name: "PluginRetired",
356
+ fromEventTypes: ["VersionRetired"]
357
+ },
358
+ {
359
+ name: "IncompatiblePlugin",
360
+ fromEventTypes: ["IncompatiblePluginDetected"]
361
+ }
362
+ ];
363
+ let acceptedCommands = [
364
+ {
365
+ name: "Heartbeat",
366
+ toCommandTypes: ["Heartbeat"]
367
+ },
368
+ {
369
+ name: "RedetectPlugin",
370
+ toCommandTypes: ["Redetect"]
371
+ },
372
+ {
373
+ name: "ConnectPlugin",
374
+ toCommandTypes: [
375
+ "Connect",
376
+ "ReportIncompatibility"
377
+ ]
378
+ },
379
+ {
380
+ name: "DisconnectPlugin",
381
+ toCommandTypes: ["Disconnect"]
382
+ }
383
+ ];
330
384
  let PluginMapping = {
331
385
  ExtensionPoint: undefined,
332
386
  Delegate: undefined,
333
387
  moduleUrl: PluginExtensionPointSpec$ReventlessInfra.moduleUrl,
334
388
  mapIncomingCommand: mapIncomingCommand,
335
- mapOutgoingEvent: mapOutgoingEvent
389
+ mapOutgoingEvent: mapOutgoingEvent,
390
+ publishedEvents: publishedEvents,
391
+ acceptedCommands: acceptedCommands
336
392
  };
337
393
  let Mapping = ExtensionPointMapping$ReventlessInfra.Make({
338
394
  ExtensionPoint: {
@@ -349,11 +405,15 @@ function Make(Spec) {
349
405
  errorSchema: PluginSpec$ReventlessCore.errorSchema,
350
406
  commandSchema: PluginSpec$ReventlessCore.commandSchema,
351
407
  moduleUrl: PluginSpec$ReventlessCore.moduleUrl,
352
- commandAuthorization: PluginSpec$ReventlessCore.commandAuthorization
408
+ commandAuthorization: PluginSpec$ReventlessCore.commandAuthorization,
409
+ commandTransition: PluginSpec$ReventlessCore.commandTransition,
410
+ traits: PluginSpec$ReventlessCore.traits
353
411
  },
354
412
  moduleUrl: PluginExtensionPointSpec$ReventlessInfra.moduleUrl,
355
413
  mapIncomingCommand: mapIncomingCommand,
356
- mapOutgoingEvent: mapOutgoingEvent
414
+ mapOutgoingEvent: mapOutgoingEvent,
415
+ publishedEvents: publishedEvents,
416
+ acceptedCommands: acceptedCommands
357
417
  });
358
418
  return {
359
419
  disconnectScheduleName: disconnectScheduleName,
@@ -34,12 +34,27 @@ function mapIncomingCommand(id, cmd, meta) {
34
34
  }
35
35
  }
36
36
 
37
+ let publishedEvents = [];
38
+
39
+ let acceptedCommands = [
40
+ {
41
+ name: "RegisterUiFragment",
42
+ toCommandTypes: ["RegisterUiFragment"]
43
+ },
44
+ {
45
+ name: "DisconnectPlugin",
46
+ toCommandTypes: ["DeregisterUiFragment"]
47
+ }
48
+ ];
49
+
37
50
  let UiFragmentMapping = {
38
51
  ExtensionPoint: undefined,
39
52
  Delegate: undefined,
40
53
  moduleUrl: moduleUrl,
41
54
  mapIncomingCommand: mapIncomingCommand,
42
- mapOutgoingEvent: undefined
55
+ mapOutgoingEvent: undefined,
56
+ publishedEvents: publishedEvents,
57
+ acceptedCommands: acceptedCommands
43
58
  };
44
59
 
45
60
  let Mapping = ExtensionPointMapping$ReventlessInfra.Make({
@@ -57,11 +72,15 @@ let Mapping = ExtensionPointMapping$ReventlessInfra.Make({
57
72
  errorSchema: UiFragmentRegistry$ReventlessCore.errorSchema,
58
73
  commandSchema: UiFragmentRegistry$ReventlessCore.commandSchema,
59
74
  moduleUrl: UiFragmentRegistry$ReventlessCore.moduleUrl,
60
- commandAuthorization: UiFragmentRegistry$ReventlessCore.commandAuthorization
75
+ commandAuthorization: UiFragmentRegistry$ReventlessCore.commandAuthorization,
76
+ commandTransition: UiFragmentRegistry$ReventlessCore.commandTransition,
77
+ traits: UiFragmentRegistry$ReventlessCore.traits
61
78
  },
62
79
  moduleUrl: moduleUrl,
63
80
  mapIncomingCommand: mapIncomingCommand,
64
- mapOutgoingEvent: undefined
81
+ mapOutgoingEvent: undefined,
82
+ publishedEvents: publishedEvents,
83
+ acceptedCommands: acceptedCommands
65
84
  });
66
85
 
67
86
  let PluginExtensionPointSpec;
@@ -159,19 +159,19 @@ let decide = (state, command) =>
159
159
  Ok(Array.concat([VersionDisconnected(definition)], promoteEvents(state, v)))
160
160
  | _ => Ok([]) // not connected / unknown → tolerate stray disconnect
161
161
  }
162
- | Activate(v) =>
163
- switch state.known->Dict.get(v) {
162
+ | Activate({version}) =>
163
+ switch state.known->Dict.get(version) {
164
164
  | Some({status: Inactive | Retired, definition}) =>
165
165
  let base = [VersionActivated(definition)]
166
- let supersede = if currentAfterConnect(state.known, v) == v {
166
+ let supersede = if currentAfterConnect(state.known, version) == version {
167
167
  switch state.current {
168
- | Some(c) if c != v =>
168
+ | Some(c) if c != version =>
169
169
  switch state.known->Dict.get(c) {
170
170
  | Some({definition: defC}) => [
171
171
  VersionSuperseded({
172
172
  supersededVersion: c,
173
173
  supersededDefinition: defC,
174
- newVersion: v,
174
+ newVersion: version,
175
175
  newDefinition: definition,
176
176
  }),
177
177
  ]
@@ -187,18 +187,18 @@ let decide = (state, command) =>
187
187
  | Some({status: Disconnected}) => Error(IsDisconnected)
188
188
  | None => Error(UnknownVersion)
189
189
  }
190
- | Deactivate(v) =>
191
- switch state.known->Dict.get(v) {
190
+ | Deactivate({version}) =>
191
+ switch state.known->Dict.get(version) {
192
192
  | Some({status: Connected | Disconnected, definition}) =>
193
- Ok(Array.concat([VersionDeactivated(definition)], promoteEvents(state, v)))
193
+ Ok(Array.concat([VersionDeactivated(definition)], promoteEvents(state, version)))
194
194
  | Some({status: Inactive | Retired}) => Ok([]) // idempotent / archived no-op
195
195
  | None => Error(UnknownVersion)
196
196
  }
197
- | Retire(v) =>
198
- switch state.known->Dict.get(v) {
197
+ | Retire({version}) =>
198
+ switch state.known->Dict.get(version) {
199
199
  | Some({status: Retired}) => Ok([]) // idempotent
200
200
  | Some({definition}) =>
201
- Ok(Array.concat([VersionRetired(definition)], promoteEvents(state, v)))
201
+ Ok(Array.concat([VersionRetired(definition)], promoteEvents(state, version)))
202
202
  | None => Error(UnknownVersion)
203
203
  }
204
204
  | ReportIncompatibility(def) => Ok([IncompatiblePluginDetected(def)])
@@ -232,8 +232,8 @@ function decide(state, command) {
232
232
  };
233
233
  }
234
234
  case "Activate" :
235
- let v$4 = command._0;
236
- let match$4 = state.known[v$4];
235
+ let version = command.version;
236
+ let match$4 = state.known[version];
237
237
  if (match$4 === undefined) {
238
238
  return {
239
239
  TAG: "Error",
@@ -261,17 +261,17 @@ function decide(state, command) {
261
261
  _0: definition
262
262
  }];
263
263
  let supersede;
264
- if (currentAfterConnect(state.known, v$4) === v$4) {
264
+ if (currentAfterConnect(state.known, version) === version) {
265
265
  let c = state.current;
266
266
  if (c !== undefined) {
267
- if (c !== v$4) {
267
+ if (c !== version) {
268
268
  let match$5 = state.known[c];
269
269
  supersede = match$5 !== undefined ? [{
270
270
  TAG: "VersionSuperseded",
271
271
  _0: {
272
272
  supersededVersion: c,
273
273
  supersededDefinition: match$5.definition,
274
- newVersion: v$4,
274
+ newVersion: version,
275
275
  newDefinition: definition
276
276
  }
277
277
  }] : [];
@@ -290,8 +290,8 @@ function decide(state, command) {
290
290
  };
291
291
  break;
292
292
  case "Deactivate" :
293
- let v$5 = command._0;
294
- let match$6 = state.known[v$5];
293
+ let version$1 = command.version;
294
+ let match$6 = state.known[version$1];
295
295
  if (match$6 === undefined) {
296
296
  return {
297
297
  TAG: "Error",
@@ -314,12 +314,12 @@ function decide(state, command) {
314
314
  _0: [{
315
315
  TAG: "VersionDeactivated",
316
316
  _0: match$6.definition
317
- }].concat(promoteEvents(state, v$5))
317
+ }].concat(promoteEvents(state, version$1))
318
318
  };
319
319
  break;
320
320
  case "Retire" :
321
- let v$6 = command._0;
322
- let match$7 = state.known[v$6];
321
+ let version$2 = command.version;
322
+ let match$7 = state.known[version$2];
323
323
  if (match$7 !== undefined) {
324
324
  if (match$7.status === "Retired") {
325
325
  return {
@@ -332,7 +332,7 @@ function decide(state, command) {
332
332
  _0: [{
333
333
  TAG: "VersionRetired",
334
334
  _0: match$7.definition
335
- }].concat(promoteEvents(state, v$6))
335
+ }].concat(promoteEvents(state, version$2))
336
336
  };
337
337
  }
338
338
  } else {
@@ -34,12 +34,20 @@ type command =
34
34
  // Cognito group-gated). `version` selects which known version to act on.
35
35
  // The `@transition` edges must agree with `decide` below; `Platform_Admin_Structure`
36
36
  // reads them off this schema rather than restating them.
37
- | @transition(([Plugins.Inactive, Plugins.Retired]) => Plugins.Connected) Activate(version)
38
- | @transition(([Plugins.Connected, Plugins.Disconnected]) => Plugins.Inactive) Deactivate(version)
37
+ //
38
+ // Inline records, unlike the `@noApi` commands above, and the difference is the
39
+ // API. A positional payload publishes its argument as `_0`, which names nothing:
40
+ // a caller cannot match it against a field it holds, and a coercion failure says
41
+ // `Variable '_0'` rather than what was missing. These three are the ones a person
42
+ // calls, so their argument carries its own name.
43
+ | @transition(([Plugins.Inactive, Plugins.Retired]) => Plugins.Connected)
44
+ Activate({version: version})
45
+ | @transition(([Plugins.Connected, Plugins.Disconnected]) => Plugins.Inactive)
46
+ Deactivate({version: version})
39
47
  // Manual admin retirement of a specific version (archive). Distinct from the
40
48
  // automatic `Superseded` transition (which is decided, not commanded).
41
49
  | @transition(([Plugins.Connected, Plugins.Disconnected, Plugins.Inactive]) => Plugins.Retired)
42
- Retire(version)
50
+ Retire({version: version})
43
51
 
44
52
  // Carries both the superseded and the superseding version's full definition —
45
53
  // a deterministic trigger for version-to-version schema/data migrations
@@ -27,15 +27,15 @@ let commandSchema = Sury.union([
27
27
  })),
28
28
  Sury.$schema(s => ({
29
29
  TAG: "Activate",
30
- _0: s.m(Plugin$Reventless.versionSchema)
30
+ version: s.m(Plugin$Reventless.versionSchema)
31
31
  })),
32
32
  Sury.$schema(s => ({
33
33
  TAG: "Deactivate",
34
- _0: s.m(Plugin$Reventless.versionSchema)
34
+ version: s.m(Plugin$Reventless.versionSchema)
35
35
  })),
36
36
  Sury.$schema(s => ({
37
37
  TAG: "Retire",
38
- _0: s.m(Plugin$Reventless.versionSchema)
38
+ version: s.m(Plugin$Reventless.versionSchema)
39
39
  }))
40
40
  ]);
41
41
 
@@ -156,6 +156,12 @@ function commandAuthorization(param) {
156
156
  return "AllowAuthenticated";
157
157
  }
158
158
 
159
+ function commandTransition(param) {
160
+ return "Unrestricted";
161
+ }
162
+
163
+ let traits = [];
164
+
159
165
  let name = "Plugin";
160
166
 
161
167
  let Id;
@@ -174,5 +180,7 @@ export {
174
180
  commandSchema$3 as commandSchema,
175
181
  moduleUrl,
176
182
  commandAuthorization,
183
+ commandTransition,
184
+ traits,
177
185
  }
178
186
  /* commandSchema Not a pure module */