@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
@@ -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 Union({anyOf}) containing Null or Undefined.
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
- | Union({anyOf}) =>
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
- | Union({anyOf}) =>
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 = (items: array<S.item>): option<string> =>
116
- items
117
- ->Array.find(item => item.location == "TAG")
118
- ->Option.flatMap(item =>
119
- switch item.schema {
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
- | Union({anyOf}) =>
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({items, properties}) =>
154
- tagConstOf(items)->Option.map(name => {
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 "union" :
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 === "union") {
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(items) {
104
- return Stdlib_Option.flatMap(items.find(item => item.location === "TAG"), item => {
105
- let match = item.schema;
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 = match.const;
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 "union" :
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(variantSchema.items), name => ({
149
+ return Stdlib_Option.map(tagConstOf(properties), name => ({
151
150
  name: name,
152
151
  fields: extractFields(properties)
153
152
  }));
@@ -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_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
5
5
  import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
6
6
  import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
@@ -79,19 +79,6 @@ function Make(Spec) {
79
79
  };
80
80
  let directiveHandler = async (createSchedule, deleteSchedule, queryEngine, directive) => {
81
81
  switch (directive.TAG) {
82
- case "CreateDisconnectSchedule" :
83
- let id = directive._0;
84
- return await createSchedule({
85
- name: disconnectScheduleName(id),
86
- rate: ScheduleOps$ReventlessCore.minutesFromNow(directive._1),
87
- payload: JSON.stringify(Message$ReventlessCore.encodeCommand$p({
88
- id: id,
89
- meta: Message$ReventlessCore.generateMeta(PluginExtensionPointSpec$ReventlessInfra.name, undefined, "Scheduler", undefined, undefined, undefined, undefined, undefined),
90
- command: "DisconnectPlugin"
91
- }, S.string, PluginExtensionPointSpec$ReventlessInfra.commandSchema))
92
- });
93
- case "DeleteDisconnectSchedule" :
94
- return await deleteSchedule(disconnectScheduleName(directive._0));
95
82
  case "DoConnectPlugin" :
96
83
  let fn = Spec.manageSubscriptions;
97
84
  if (fn !== undefined) {
@@ -117,6 +104,19 @@ function Make(Spec) {
117
104
  case "ForwardCommand" :
118
105
  let match = directive._0;
119
106
  return await forwardCommand(match.id, match.command, match.extensionPointName, queryEngine);
107
+ case "CreateDisconnectSchedule" :
108
+ let id = directive._0;
109
+ return await createSchedule({
110
+ name: disconnectScheduleName(id),
111
+ rate: ScheduleOps$ReventlessCore.minutesFromNow(directive._1),
112
+ payload: JSON.stringify(Message$ReventlessCore.encodeCommand$p({
113
+ id: id,
114
+ meta: Message$ReventlessCore.generateMeta(PluginExtensionPointSpec$ReventlessInfra.name, undefined, "Scheduler", undefined, undefined, undefined, undefined, undefined),
115
+ command: "DisconnectPlugin"
116
+ }, Sury.string, PluginExtensionPointSpec$ReventlessInfra.commandSchema))
117
+ });
118
+ case "DeleteDisconnectSchedule" :
119
+ return await deleteSchedule(disconnectScheduleName(directive._0));
120
120
  }
121
121
  };
122
122
  let mapIncomingCommand = (id, cmd, _meta) => {
@@ -380,4 +380,4 @@ export {
380
380
  Make,
381
381
  moduleUrl,
382
382
  }
383
- /* S Not a pure module */
383
+ /* sury Not a pure module */
@@ -1,26 +1,26 @@
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_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
5
5
  import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
6
6
  import * as Plugin$Reventless from "@reventlessdev/reventless-spec/src/components/Plugin.res.mjs";
7
7
  import * as Plugin$ReventlessCore from "../component/Plugin.res.mjs";
8
8
 
9
- let versionStatusSchema = S.union([
10
- S.literal("Connected"),
11
- S.literal("Disconnected"),
12
- S.literal("Inactive"),
13
- S.literal("Retired")
9
+ let versionStatusSchema = Sury.union([
10
+ Sury.literal("Connected"),
11
+ Sury.literal("Disconnected"),
12
+ Sury.literal("Inactive"),
13
+ Sury.literal("Retired")
14
14
  ]);
15
15
 
16
- let knownVersionSchema = S.schema(s => ({
16
+ let knownVersionSchema = Sury.$schema(s => ({
17
17
  definition: s.m(Plugin$Reventless.pluginDefinitionSchema),
18
18
  status: s.m(versionStatusSchema)
19
19
  }));
20
20
 
21
- let stateSchema = S.schema(s => ({
22
- current: s.m(S.option(Plugin$Reventless.versionSchema)),
23
- known: s.m(S.dict(knownVersionSchema))
21
+ let stateSchema = Sury.$schema(s => ({
22
+ current: s.m(Sury.$option(Plugin$Reventless.versionSchema)),
23
+ known: s.m(Sury.dict(knownVersionSchema))
24
24
  }));
25
25
 
26
26
  let initialState_known = {};
@@ -119,23 +119,56 @@ function promoteEvents(state, v) {
119
119
 
120
120
  function decide(state, command) {
121
121
  switch (command.TAG) {
122
- case "Heartbeat" :
123
- let v = command._0;
122
+ case "Connect" :
123
+ let def = command._0;
124
+ let v = def.version;
124
125
  let match = state.known[v];
125
- if (match === undefined) {
126
+ if (match !== undefined && match.status === "Connected") {
127
+ if (Primitive_object.equal(match.definition, def)) {
128
+ return {
129
+ TAG: "Ok",
130
+ _0: []
131
+ };
132
+ } else {
133
+ return {
134
+ TAG: "Ok",
135
+ _0: [{
136
+ TAG: "VersionConnected",
137
+ _0: def
138
+ }]
139
+ };
140
+ }
141
+ } else {
142
+ return {
143
+ TAG: "Ok",
144
+ _0: connectEvents(state, v, def)
145
+ };
146
+ }
147
+ case "ReportIncompatibility" :
148
+ return {
149
+ TAG: "Ok",
150
+ _0: [{
151
+ TAG: "IncompatiblePluginDetected",
152
+ _0: command._0
153
+ }]
154
+ };
155
+ case "Heartbeat" :
156
+ let v$1 = command._0;
157
+ let match$1 = state.known[v$1];
158
+ if (match$1 === undefined) {
126
159
  return {
127
160
  TAG: "Ok",
128
161
  _0: [{
129
162
  TAG: "VersionDetected",
130
- _0: v
163
+ _0: v$1
131
164
  }]
132
165
  };
133
166
  }
134
- switch (match.status) {
167
+ switch (match$1.status) {
135
168
  case "Disconnected" :
136
169
  return {
137
170
  TAG: "Ok",
138
- _0: connectEvents(state, v, match.definition)
171
+ _0: connectEvents(state, v$1, match$1.definition)
139
172
  };
140
173
  case "Connected" :
141
174
  case "Inactive" :
@@ -146,25 +179,25 @@ function decide(state, command) {
146
179
  };
147
180
  }
148
181
  case "Redetect" :
149
- let v$1 = command._0;
150
- let match$1 = state.known[v$1];
151
- if (match$1 === undefined) {
182
+ let v$2 = command._0;
183
+ let match$2 = state.known[v$2];
184
+ if (match$2 === undefined) {
152
185
  return {
153
186
  TAG: "Ok",
154
187
  _0: [{
155
188
  TAG: "VersionDetected",
156
- _0: v$1
189
+ _0: v$2
157
190
  }]
158
191
  };
159
192
  }
160
- switch (match$1.status) {
193
+ switch (match$2.status) {
161
194
  case "Connected" :
162
195
  case "Disconnected" :
163
196
  return {
164
197
  TAG: "Ok",
165
198
  _0: [{
166
199
  TAG: "VersionDetected",
167
- _0: v$1
200
+ _0: v$2
168
201
  }]
169
202
  };
170
203
  case "Inactive" :
@@ -174,31 +207,6 @@ function decide(state, command) {
174
207
  _0: []
175
208
  };
176
209
  }
177
- case "Connect" :
178
- let def = command._0;
179
- let v$2 = def.version;
180
- let match$2 = state.known[v$2];
181
- if (match$2 !== undefined && match$2.status === "Connected") {
182
- if (Primitive_object.equal(match$2.definition, def)) {
183
- return {
184
- TAG: "Ok",
185
- _0: []
186
- };
187
- } else {
188
- return {
189
- TAG: "Ok",
190
- _0: [{
191
- TAG: "VersionConnected",
192
- _0: def
193
- }]
194
- };
195
- }
196
- } else {
197
- return {
198
- TAG: "Ok",
199
- _0: connectEvents(state, v$2, def)
200
- };
201
- }
202
210
  case "Disconnect" :
203
211
  let v$3 = command._0;
204
212
  let match$3 = state.known[v$3];
@@ -309,14 +317,6 @@ function decide(state, command) {
309
317
  }].concat(promoteEvents(state, v$5))
310
318
  };
311
319
  break;
312
- case "ReportIncompatibility" :
313
- return {
314
- TAG: "Ok",
315
- _0: [{
316
- TAG: "IncompatiblePluginDetected",
317
- _0: command._0
318
- }]
319
- };
320
320
  case "Retire" :
321
321
  let v$6 = command._0;
322
322
  let match$7 = state.known[v$6];
@@ -2,29 +2,44 @@
2
2
 
3
3
  open Reventless.Plugin
4
4
 
5
+ // Alias, not `open`: the PPX strips `@transition` before the typechecker, so the
6
+ // state constructors never reach it and an `open` would warn as unused.
7
+ module Plugins = PluginsReadModelSpec
8
+
5
9
  // The Plugin aggregate is keyed by plugin **name** (not name@version). One
6
10
  // instance owns the whole lifecycle of every version of that name, deciding
7
11
  // supersession synchronously. Version-scoped commands carry the `version`
8
12
  // the transition targets; the ExtensionPoint→Plugin mapping supplies it
9
13
  // (translated from the transport-level `name@version` id — Approach 1).
14
+ // Order is load-bearing: sury strands constructors declared after a run of two or
15
+ // more same-shaped ones, so the `pluginDefinition` pair must lead (DZakh/sury#392).
10
16
  @schema
11
17
  type command =
18
+ // The handshake brings the version's row into being, so it runs from no state
19
+ // — `decide` accepts it against an unknown version and against every status
20
+ // but `Connected`, where it is a definition refresh rather than a move.
21
+ | @noApi @transition(() => Plugins.Connected) Connect(pluginDefinition)
22
+ // Records a protocol-version incompatibility without changing connection state.
23
+ | @noApi ReportIncompatibility(pluginDefinition)
12
24
  | @noApi Heartbeat(version)
13
25
  // Deploy-time re-detect (from RedetectPlugin). Forces the connect handshake to
14
26
  // re-run for an already-connected version so its definition is refreshed on the
15
27
  // row — unlike Heartbeat, which no-ops a connected keep-alive.
16
28
  | @noApi Redetect(version)
17
- | @noApi Connect(pluginDefinition)
18
- | @noApi Disconnect(version)
29
+ // A heartbeat timing out is the only way a row reaches `Disconnected`, and
30
+ // `decide` moves the row for exactly one status — anything else is a stray
31
+ // disconnect it tolerates without emitting.
32
+ | @noApi @transition(([Plugins.Connected]) => Plugins.Disconnected) Disconnect(version)
19
33
  // Admin lifecycle commands — API-exposed (auto-derived admin mutations,
20
34
  // Cognito group-gated). `version` selects which known version to act on.
21
- | Activate(version)
22
- | Deactivate(version)
23
- // Records a protocol-version incompatibility without changing connection state.
24
- | @noApi ReportIncompatibility(pluginDefinition)
35
+ // The `@transition` edges must agree with `decide` below; `Platform_Admin_Structure`
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)
25
39
  // Manual admin retirement of a specific version (archive). Distinct from the
26
40
  // automatic `Superseded` transition (which is decided, not commanded).
27
- | Retire(version)
41
+ | @transition(([Plugins.Connected, Plugins.Disconnected, Plugins.Inactive]) => Plugins.Retired)
42
+ Retire(version)
28
43
 
29
44
  // Carries both the superseded and the superseding version's full definition —
30
45
  // a deterministic trigger for version-to-version schema/data migrations
@@ -1,103 +1,155 @@
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 Plugin$Reventless from "@reventlessdev/reventless-spec/src/components/Plugin.res.mjs";
5
5
  import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
6
6
 
7
- let commandSchema = S.union([
8
- S.schema(s => ({
7
+ let commandSchema = Sury.union([
8
+ Sury.$schema(s => ({
9
+ TAG: "Connect",
10
+ _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
11
+ })),
12
+ Sury.$schema(s => ({
13
+ TAG: "ReportIncompatibility",
14
+ _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
15
+ })),
16
+ Sury.$schema(s => ({
9
17
  TAG: "Heartbeat",
10
18
  _0: s.m(Plugin$Reventless.versionSchema)
11
19
  })),
12
- S.schema(s => ({
20
+ Sury.$schema(s => ({
13
21
  TAG: "Redetect",
14
22
  _0: s.m(Plugin$Reventless.versionSchema)
15
23
  })),
16
- S.schema(s => ({
17
- TAG: "Connect",
18
- _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
19
- })),
20
- S.schema(s => ({
24
+ Sury.$schema(s => ({
21
25
  TAG: "Disconnect",
22
26
  _0: s.m(Plugin$Reventless.versionSchema)
23
27
  })),
24
- S.schema(s => ({
28
+ Sury.$schema(s => ({
25
29
  TAG: "Activate",
26
30
  _0: s.m(Plugin$Reventless.versionSchema)
27
31
  })),
28
- S.schema(s => ({
32
+ Sury.$schema(s => ({
29
33
  TAG: "Deactivate",
30
34
  _0: s.m(Plugin$Reventless.versionSchema)
31
35
  })),
32
- S.schema(s => ({
33
- TAG: "ReportIncompatibility",
34
- _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
35
- })),
36
- S.schema(s => ({
36
+ Sury.$schema(s => ({
37
37
  TAG: "Retire",
38
38
  _0: s.m(Plugin$Reventless.versionSchema)
39
39
  }))
40
40
  ]);
41
41
 
42
- let versionSupersededDataSchema = S.schema(s => ({
42
+ let versionSupersededDataSchema = Sury.$schema(s => ({
43
43
  supersededVersion: s.m(Plugin$Reventless.versionSchema),
44
44
  supersededDefinition: s.m(Plugin$Reventless.pluginDefinitionSchema),
45
45
  newVersion: s.m(Plugin$Reventless.versionSchema),
46
46
  newDefinition: s.m(Plugin$Reventless.pluginDefinitionSchema)
47
47
  }));
48
48
 
49
- let eventSchema = S.union([
50
- S.schema(s => ({
49
+ let eventSchema = Sury.union([
50
+ Sury.$schema(s => ({
51
51
  TAG: "VersionDetected",
52
52
  _0: s.m(Plugin$Reventless.versionSchema)
53
53
  })),
54
- S.schema(s => ({
54
+ Sury.$schema(s => ({
55
55
  TAG: "VersionConnected",
56
56
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
57
57
  })),
58
- S.schema(s => ({
58
+ Sury.$schema(s => ({
59
59
  TAG: "VersionSuperseded",
60
60
  _0: s.m(versionSupersededDataSchema)
61
61
  })),
62
- S.schema(s => ({
62
+ Sury.$schema(s => ({
63
63
  TAG: "VersionPromoted",
64
64
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
65
65
  })),
66
- S.schema(s => ({
66
+ Sury.$schema(s => ({
67
67
  TAG: "VersionDisconnected",
68
68
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
69
69
  })),
70
- S.schema(s => ({
70
+ Sury.$schema(s => ({
71
71
  TAG: "VersionActivated",
72
72
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
73
73
  })),
74
- S.schema(s => ({
74
+ Sury.$schema(s => ({
75
75
  TAG: "VersionDeactivated",
76
76
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
77
77
  })),
78
- S.schema(s => ({
78
+ Sury.$schema(s => ({
79
79
  TAG: "VersionRetired",
80
80
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
81
81
  })),
82
- S.schema(s => ({
82
+ Sury.$schema(s => ({
83
83
  TAG: "IncompatiblePluginDetected",
84
84
  _0: s.m(Plugin$Reventless.pluginDefinitionSchema)
85
85
  }))
86
86
  ]);
87
87
 
88
- let errorSchema = S.union([
89
- S.literal("UnknownVersion"),
90
- S.literal("AlreadyConnected"),
91
- S.literal("IsDisconnected"),
92
- S.literal("IsInactive")
88
+ let errorSchema = Sury.union([
89
+ Sury.literal("UnknownVersion"),
90
+ Sury.literal("AlreadyConnected"),
91
+ Sury.literal("IsDisconnected"),
92
+ Sury.literal("IsInactive")
93
93
  ]);
94
94
 
95
95
  let commandSchema$1 = Api$ReventlessInfra.markNoApiVariants(commandSchema, [
96
+ "Connect",
97
+ "ReportIncompatibility",
96
98
  "Heartbeat",
97
99
  "Redetect",
98
- "Connect",
99
- "Disconnect",
100
- "ReportIncompatibility"
100
+ "Disconnect"
101
+ ]);
102
+
103
+ let commandSchema$2 = Api$ReventlessInfra.markAllowedStates(commandSchema$1, [
104
+ [
105
+ "Disconnect",
106
+ ["Connected"]
107
+ ],
108
+ [
109
+ "Activate",
110
+ [
111
+ "Inactive",
112
+ "Retired"
113
+ ]
114
+ ],
115
+ [
116
+ "Deactivate",
117
+ [
118
+ "Connected",
119
+ "Disconnected"
120
+ ]
121
+ ],
122
+ [
123
+ "Retire",
124
+ [
125
+ "Connected",
126
+ "Disconnected",
127
+ "Inactive"
128
+ ]
129
+ ]
130
+ ]);
131
+
132
+ let commandSchema$3 = Api$ReventlessInfra.markTargetState(commandSchema$2, [
133
+ [
134
+ "Connect",
135
+ "Connected"
136
+ ],
137
+ [
138
+ "Disconnect",
139
+ "Disconnected"
140
+ ],
141
+ [
142
+ "Activate",
143
+ "Connected"
144
+ ],
145
+ [
146
+ "Deactivate",
147
+ "Inactive"
148
+ ],
149
+ [
150
+ "Retire",
151
+ "Retired"
152
+ ]
101
153
  ]);
102
154
 
103
155
  function commandAuthorization(param) {
@@ -108,15 +160,18 @@ let name = "Plugin";
108
160
 
109
161
  let Id;
110
162
 
163
+ let Plugins;
164
+
111
165
  let moduleUrl = "@reventlessdev/reventless-core/src/plugin/lifecycle/PluginSpec.res.mjs";
112
166
 
113
167
  export {
114
168
  name,
115
169
  Id,
170
+ Plugins,
116
171
  versionSupersededDataSchema,
117
172
  eventSchema,
118
173
  errorSchema,
119
- commandSchema$1 as commandSchema,
174
+ commandSchema$3 as commandSchema,
120
175
  moduleUrl,
121
176
  commandAuthorization,
122
177
  }