@reventlessdev/reventless-core 3.0.0-alpha.259 → 3.0.0-alpha.261

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 (209) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +11 -11
  3. package/src/Behavior.res +1 -4
  4. package/src/Message.res +17 -14
  5. package/src/Projection.res +51 -25
  6. package/src/RequestContext.res +8 -9
  7. package/src/ResourceAttribution.res +28 -14
  8. package/src/adapter/Adapter.res +48 -4
  9. package/src/adapter/EventLogProvisioning/EventLogProvisioning.res +5 -5
  10. package/src/adapter/Messaging/Messaging_Log_Backend.res +10 -7
  11. package/src/adapter/Messaging/Messaging_Log_Backend.res.mjs +2 -4
  12. package/src/adapter/Monitoring/Monitoring.res +16 -17
  13. package/src/adapter/QueryInterception/QueryInterception.res +0 -1
  14. package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res +12 -5
  15. package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +11 -7
  16. package/src/adapter/Runtime/PluginRuntime_Builder_Micro.res +1 -7
  17. package/src/adapter/Runtime/PluginRuntime_Builder_Single.res +1 -7
  18. package/src/adapter/RuntimeExtension/RuntimeExtension.res +0 -1
  19. package/src/admin/Platform_Admin.res +17 -6
  20. package/src/admin/Platform_AdminApi.res +14 -9
  21. package/src/admin/Platform_Admin_Callback.res +1 -1
  22. package/src/admin/Platform_BakedManifest.res +34 -34
  23. package/src/admin/Platform_ComponentDefinitionsApi.res +9 -21
  24. package/src/admin/Platform_PluginStructuresApi.res +15 -12
  25. package/src/admin/UiFragmentRegistry/StateChange/UiFragmentRegistry.res +1 -1
  26. package/src/components/Aggregate/Aggregate.res +13 -12
  27. package/src/components/Aggregate/Aggregate_Builder.res +22 -21
  28. package/src/components/Aggregate/Aggregate_Callback.res +91 -86
  29. package/src/components/Api/ApiNoApiHelpers.res +1 -3
  30. package/src/components/Api/Api_Ids.res +0 -1
  31. package/src/components/Api/Api_Naming.res +41 -18
  32. package/src/components/Api/GraphQL_FragmentGenerator.res +42 -52
  33. package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +11 -4
  34. package/src/components/Api/GraphQL_SchemaInspector.res +5 -3
  35. package/src/components/Api/GraphQL_Stitcher.res +9 -10
  36. package/src/components/Api/MCP_SchemaGenerator.res +8 -12
  37. package/src/components/Api/OwnerScopeDiagnostics.res +1 -2
  38. package/src/components/Api/QueryDbListQuery.res +13 -6
  39. package/src/components/Api/SchemaType.res +40 -20
  40. package/src/components/Api/SchemaType.res.mjs +16 -0
  41. package/src/components/Api/SuryToJsonSchema.res +18 -10
  42. package/src/components/Api/SuryToJsonSchema.res.mjs +135 -121
  43. package/src/components/AutomationSlice/AutomationSlice.res +4 -4
  44. package/src/components/AutomationSlice/AutomationSlice_Builder.res +15 -14
  45. package/src/components/AutomationSlice/AutomationSlice_Callback.res +3 -3
  46. package/src/components/Builder_Helpers.res +12 -23
  47. package/src/components/CommandGenerator/CommandGenerator.res +6 -1
  48. package/src/components/CommandGenerator/CommandGenerator_Builder.res +29 -21
  49. package/src/components/CommandGenerator/CommandGenerator_Callback.res +17 -21
  50. package/src/components/CommandTopic/CommandTopic.res +3 -3
  51. package/src/components/CommandTopic/CommandTopic_Builder.res +10 -10
  52. package/src/components/CommandTopic/CommandTopic_Callback.res +1 -4
  53. package/src/components/CommandTopic/CommandTopic_Helpers.res +1 -2
  54. package/src/components/Counter/Counter_Builder.res +1 -6
  55. package/src/components/Counter/Counter_Callback.res +3 -3
  56. package/src/components/Dcb/Dcb_Builder.res +970 -956
  57. package/src/components/DcbEventLog/DcbEventLog.res +4 -4
  58. package/src/components/DcbEventLog/DcbEventLog_Builder.res +0 -1
  59. package/src/components/DcbEventLog/DcbEventLog_Operations.res +17 -18
  60. package/src/components/EventCollector/EventCollector_Builder.res +2 -1
  61. package/src/components/EventLog/EventLog.res +5 -1
  62. package/src/components/EventLog/EventLog_Operations.res +12 -8
  63. package/src/components/EventMapper/EventMapper.res +8 -10
  64. package/src/components/EventMapper/EventMapper_Builder.res +4 -1
  65. package/src/components/EventMapper/EventMapper_Callback.res +46 -31
  66. package/src/components/EventTopic/EventTopic.res +3 -3
  67. package/src/components/EventTopic/EventTopic_Builder.res +1 -1
  68. package/src/components/Extension/Extension.res +4 -1
  69. package/src/components/Extension/Extension_Operations.res +11 -3
  70. package/src/components/ExtensionPoint/ExtensionPoint.res +3 -3
  71. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +9 -10
  72. package/src/components/ExtensionPoint/ExtensionPoint_Callback.res +2 -6
  73. package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +13 -5
  74. package/src/components/Heartbeat/Heartbeat_Callback.res +3 -3
  75. package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +4 -4
  76. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +7 -10
  77. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res +4 -4
  78. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +15 -14
  79. package/src/components/QueryDb/QueryDb_Adapter.res +1 -3
  80. package/src/components/QueryDb/QueryDb_Operations.res +10 -10
  81. package/src/components/ReadModel/ReadModel.res +3 -3
  82. package/src/components/ReadModel/ReadModel_Builder.res +1 -2
  83. package/src/components/ReadModel/ReadModel_Callback.res +2 -1
  84. package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +5 -2
  85. package/src/components/StateChangeSlice/StateChangeSlice.res +3 -3
  86. package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +23 -4
  87. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +22 -6
  88. package/src/components/StateTopic.res +1 -3
  89. package/src/components/StateViewSlice/StateViewSlice.res +4 -4
  90. package/src/components/StateViewSlice/StateViewSlice_Builder.res +79 -68
  91. package/src/components/StateViewSlice/StateViewSlice_Callback.res +3 -1
  92. package/src/components/Task/Task.res +3 -3
  93. package/src/components/Task/Task_Adapter.res +4 -1
  94. package/src/components/Task/Task_Builder.res +24 -21
  95. package/src/plugin/api/PluginBaseFragment.res +9 -3
  96. package/src/plugin/component/Capability_Inference.res +8 -10
  97. package/src/plugin/component/Plugin.res +6 -6
  98. package/src/plugin/component/Plugin_Builder.res +54 -50
  99. package/src/plugin/component/Plugin_Callback.res +10 -6
  100. package/src/plugin/component/Plugin_Helpers.res +264 -230
  101. package/src/plugin/component/Plugin_Structure.res +370 -324
  102. package/src/plugin/component/Plugin_SubscriptionSchema.res +8 -6
  103. package/src/plugin/component/SchemaWalker.res +11 -12
  104. package/src/plugin/connect/PluginConnectExtension_Mapping.res +45 -50
  105. package/src/plugin/lifecycle/PluginBehavior.res +3 -4
  106. package/src/plugin/lifecycle/PluginSpec.res +1 -2
  107. package/src/plugin/lifecycle/PluginsProjection.res +16 -5
  108. package/src/plugin/lifecycle/PluginsReadModelSpec.res +0 -2
  109. package/src/util/CommandPublisher.res +9 -2
  110. package/src/util/CsvStream.res +3 -3
  111. package/src/util/Interstack.res +7 -15
  112. package/src/util/Interstack.resi +3 -3
  113. package/src/util/LogFormat.res +5 -9
  114. package/src/util/Logger.res +1 -2
  115. package/src/util/Lru.res +2 -1
  116. package/src/util/Lru.resi +2 -3
  117. package/src/util/ScheduleOps.res +24 -27
  118. package/src/util/StorePrefixCollision.res +6 -9
  119. package/src/util/Util_Promise.res +4 -1
  120. package/src/util/Util_Promise.res.mjs +1 -1
  121. package/tests/IdentityTest.res +166 -113
  122. package/tests/ResourceAttributionTest.res +28 -25
  123. package/tests/StorePrefixCollisionTest.res +2 -1
  124. package/tests/TaskBucketNamingTest.res +3 -2
  125. package/tests/adapter/EventLogProvisioningTest.res +51 -48
  126. package/tests/adapter/MonitoringTest.res +81 -38
  127. package/tests/adapter/QueryInterceptionTest.res +2 -2
  128. package/tests/adapter/RefusalVocabularyTest.res +31 -23
  129. package/tests/adapter/RuntimeExtensionHookReachTest.res +9 -8
  130. package/tests/adapter/RuntimeExtensionTest.res +5 -3
  131. package/tests/admin/AdminApiSchemaDriftTest.res +22 -16
  132. package/tests/admin/Platform_Admin_StructureTest.res +10 -11
  133. package/tests/admin/Platform_BakedManifestTest.res +31 -35
  134. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +18 -15
  135. package/tests/admin/Platform_PluginStructuresApiTest.res +5 -3
  136. package/tests/admin/Platform_UIFragmentsApiTest.res +6 -3
  137. package/tests/aggregate/AggregateCacheTest.res +10 -12
  138. package/tests/aggregate/AggregateCallbackTest.res +75 -46
  139. package/tests/aggregate/AggregateCausationTest.res +19 -20
  140. package/tests/aggregate/AggregateConflictTest.res +41 -19
  141. package/tests/aggregate/AggregateFixtures.res +15 -5
  142. package/tests/aggregate/AggregateRejectionTest.res +97 -80
  143. package/tests/aggregate/AggregateSnapshotTest.res +44 -16
  144. package/tests/api/Api_IdsTest.res +10 -4
  145. package/tests/api/BrandedMarkerCompositionTest.res +48 -36
  146. package/tests/api/GeolocationSemanticTest.res +3 -3
  147. package/tests/api/GraphQL_FragmentGeneratorTest.res +66 -54
  148. package/tests/api/OwnerScopeDiagnosticsTest.res +31 -27
  149. package/tests/api/StorageRefFieldsTest.res +30 -18
  150. package/tests/api/SuryToJsonSchemaTest.res +1338 -981
  151. package/tests/api/SuryToJsonSchemaTest.res.mjs +31 -0
  152. package/tests/api/TaggedUnionSchemaTest.res +17 -24
  153. package/tests/commandgenerator/CommandGeneratorCallbackTest.res +235 -179
  154. package/tests/commandgenerator/CommandGeneratorFixtures.res +8 -13
  155. package/tests/commandgenerator/OwnerStampingTest.res +91 -76
  156. package/tests/commandtopic/CommandOutcomeHookTest.res +198 -155
  157. package/tests/commandtopic/CommandTopicCallbackFixtures.res +5 -4
  158. package/tests/commandtopic/CommandTopicCallbackTest.res +61 -43
  159. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res +70 -55
  160. package/tests/counter/CounterCallbackTest.res +40 -34
  161. package/tests/counter/CounterFixtures.res +4 -4
  162. package/tests/dcb/DcbDecodeTest.res +115 -84
  163. package/tests/dcb/DcbEventLogOperationsTest.res +194 -143
  164. package/tests/dcb/DcbEventLogSchemaTest.res +13 -13
  165. package/tests/dcb/DcbFixtures.res +4 -5
  166. package/tests/dcb/DcbScopeInferenceTest.res +173 -114
  167. package/tests/dcb/DcbStateChangeSliceTest.res +391 -262
  168. package/tests/dcb/DcbTagTest.res +22 -11
  169. package/tests/dcb/DcbValidationTest.res +288 -218
  170. package/tests/eventlog/EventLogFixtures.res +4 -4
  171. package/tests/eventlog/EventLogOperationsTest.res +102 -67
  172. package/tests/eventlog/EventLogRetryTest.res +104 -65
  173. package/tests/eventmapper/EventMapperCallbackTest.res +118 -83
  174. package/tests/eventmapper/EventMapperFixtures.res +15 -23
  175. package/tests/eventmapper/EventMapperTest.res +54 -38
  176. package/tests/eventtopic/EventTopicFixtures.res +3 -4
  177. package/tests/eventtopic/EventTopicOperationsTest.res +41 -29
  178. package/tests/extensionpoint/ExtensionPointCallbackTest.res +58 -45
  179. package/tests/extensionpoint/ExtensionPointFixtures.res +16 -20
  180. package/tests/extensionpoint/ExtensionPointOperationsTest.res +70 -49
  181. package/tests/extensionpoint/PluginDisconnectScheduleTest.res +2 -1
  182. package/tests/logger/LogFormatTest.res +104 -82
  183. package/tests/logger/LoggerLazyTest.res +21 -12
  184. package/tests/message/MessageTest.res +96 -93
  185. package/tests/message/MetaEnvelopeTest.res +26 -30
  186. package/tests/plugin/HeartbeatDisconnectGraceTest.res +31 -25
  187. package/tests/plugin/ManifestVisibilityTest.res +20 -12
  188. package/tests/plugin/PluginDefinitionScalars.res +1 -2
  189. package/tests/plugin/PluginLifecycleCorpusTest.res +15 -12
  190. package/tests/plugin/PluginSpecExperiment.res +0 -1
  191. package/tests/plugin/PluginStructureTest.res +1533 -1030
  192. package/tests/plugin/PluginStructureTest.res.mjs +6 -0
  193. package/tests/plugin/Plugin_EventQuerySchemaTest.res +21 -10
  194. package/tests/plugin/SchemaWalkerTest.res +116 -70
  195. package/tests/plugin/StateChange/PsReserveStock.res +4 -4
  196. package/tests/plugin/StateView/PsAnnotatedView.res +6 -4
  197. package/tests/plugin/StateView/PsAnnotatedView.res.mjs +7 -3
  198. package/tests/plugin/StateView/PsCustomersView.res +4 -4
  199. package/tests/plugin/StateView/PsShipmentsView.res +3 -2
  200. package/tests/projection/LifecycleTrailTest.res +1 -4
  201. package/tests/projection/ProjectionOptimizeTest.res +13 -9
  202. package/tests/querydb/QueryDbFixtures.res +0 -1
  203. package/tests/querydb/QueryDbOperationsTest.res +99 -64
  204. package/tests/querydb/TaggedUnionStampTest.res +10 -8
  205. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res +50 -35
  206. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +4 -10
  207. package/tests/util/CommandPublisherTest.res +0 -1
  208. package/tests/util/CsvStreamTest.res +3 -3
  209. package/tests/util/LruTest.res +84 -56
@@ -102,25 +102,23 @@ describe("resolveKeyField — the ladder", () => {
102
102
  })
103
103
 
104
104
  testSync("several `*Id` fields are disambiguated by the component name", () => {
105
- let schema = S.schema(s =>
106
- {"productId": s.matches(S.string), "categoryId": s.matches(S.string)}
105
+ let schema = S.schema(
106
+ s => {"productId": s.matches(S.string), "categoryId": s.matches(S.string)},
107
107
  )
108
108
  expect(rungFor(~entityName="Products", schema))->toEqual(Some(("productId", "convention")))
109
109
  })
110
110
 
111
111
  // The `-ies` plural the naive singulariser gets wrong, on the key side too.
112
112
  testSync("the convention rung singularises the way Api_Naming does", () => {
113
- let schema = S.schema(s =>
114
- {"categoryId": s.matches(S.string), "ownerId": s.matches(S.string)}
115
- )
113
+ let schema = S.schema(s => {"categoryId": s.matches(S.string), "ownerId": s.matches(S.string)})
116
114
  expect(rungFor(~entityName="Categories", schema))->toEqual(Some(("categoryId", "convention")))
117
115
  })
118
116
 
119
117
  // ProductDemand: two `*Id` fields, and the name yields `productDemandId`, which
120
118
  // is not a field. Declining is the honest answer — this is what `@id` is for.
121
119
  testSync("several `*Id` fields with no name match declines", () => {
122
- let schema = S.schema(s =>
123
- {"productId": s.matches(S.string), "categoryId": s.matches(S.string)}
120
+ let schema = S.schema(
121
+ s => {"productId": s.matches(S.string), "categoryId": s.matches(S.string)},
124
122
  )
125
123
  expect(rungFor(~entityName="ProductDemand", schema))->toEqual(None)
126
124
  })
@@ -144,14 +142,16 @@ describe("resolveKeyField — the ladder", () => {
144
142
  // which of the two ways to lose it is worth saying out loud.
145
143
  describe("keyFieldGapMessage — which gap is worth a warning", () => {
146
144
  let gapFor = (~entityName, schema) =>
147
- GraphQL_FragmentGenerator.classifyKeyField(~entityName, schema->S.castToUnknown)
148
- ->GraphQL_FragmentGenerator.keyFieldGapMessage
145
+ GraphQL_FragmentGenerator.classifyKeyField(
146
+ ~entityName,
147
+ schema->S.castToUnknown,
148
+ )->GraphQL_FragmentGenerator.keyFieldGapMessage
149
149
 
150
150
  // The accident §14b.2 named: the view had `productId` alone and somebody added
151
151
  // `categoryId`, so `sole` stopped firing and the name matches neither.
152
152
  testSync("a second `*Id` field taking the key away is named, with both fields", () => {
153
- let schema = S.schema(s =>
154
- {"productId": s.matches(S.string), "categoryId": s.matches(S.string)}
153
+ let schema = S.schema(
154
+ s => {"productId": s.matches(S.string), "categoryId": s.matches(S.string)},
155
155
  )
156
156
  let message = gapFor(~entityName="ProductDemand", schema)->Option.getOr("")
157
157
  expect(message->String.includes("productId, categoryId"))->toBe(true)
@@ -171,9 +171,9 @@ describe("keyFieldGapMessage — which gap is worth a warning", () => {
171
171
  )
172
172
 
173
173
  testSync("a resolved key says nothing", () =>
174
- expect(
175
- gapFor(~entityName="Orders", S.schema(s => {"orderId": s.matches(S.string)})),
176
- )->toEqual(None)
174
+ expect(gapFor(~entityName="Orders", S.schema(s => {"orderId": s.matches(S.string)})))->toEqual(
175
+ None,
176
+ )
177
177
  )
178
178
 
179
179
  testSync("an @id-less view whose name picks one of its `*Id` fields is fine", () =>
@@ -289,11 +289,12 @@ describe("semantic composites are named once, not once per field", () => {
289
289
  let types = GraphQL_FragmentGenerator.deriveObjectTypeWithNested(
290
290
  ~typeName="Catalog_Product",
291
291
  ~includeIdParam=false,
292
- S.schema(s =>
293
- {
294
- "productId": s.matches(S.string),
295
- "price": s.matches(Reventless.Money.schema),
296
- }
292
+ S.schema(
293
+ s =>
294
+ {
295
+ "productId": s.matches(S.string),
296
+ "price": s.matches(Reventless.Money.schema),
297
+ },
297
298
  )->S.castToUnknown,
298
299
  )
299
300
  expect((
@@ -315,16 +316,15 @@ module PlaceOrder = {
315
316
  // A single-payload command reaches the generator as a plain object schema —
316
317
  // the `Object(_)` branch of `generate` — which is also the shape one variant
317
318
  // of a union presents to `mutationArgTypes`.
318
- let schema =
319
- S.schema(s =>
320
- {
321
- "orderId": s.matches(S.string),
322
- "shippingMethod": s.matches(shippingMethodSchema),
323
- "total": s.matches(Reventless.Money.schema),
324
- "tip": s.matches(S.option(Reventless.Money.schema)),
325
- "itemCount": s.matches(S.int),
326
- }
327
- )->S.castToUnknown
319
+ let schema = S.schema(s =>
320
+ {
321
+ "orderId": s.matches(S.string),
322
+ "shippingMethod": s.matches(shippingMethodSchema),
323
+ "total": s.matches(Reventless.Money.schema),
324
+ "tip": s.matches(S.option(Reventless.Money.schema)),
325
+ "itemCount": s.matches(S.int),
326
+ }
327
+ )->S.castToUnknown
328
328
  }
329
329
 
330
330
  describe("GraphQL_FragmentGenerator.mutationArgTypes", () => {
@@ -409,7 +409,7 @@ let refDoorFragment = (~subIdField=?) =>
409
409
  stateSchema: RefDoorRow.stateSchema->S.castToUnknown,
410
410
  authorization: None,
411
411
  connectionSpec: true,
412
- subIdField: ?subIdField,
412
+ ?subIdField,
413
413
  },
414
414
  ],
415
415
  )
@@ -417,7 +417,6 @@ let refDoorFragment = (~subIdField=?) =>
417
417
  // What a caller holding a pointer to a withheld row may learn about it, and what
418
418
  // the two doors that could never answer for one can now be asked.
419
419
  describe("the reference door and the archive argument", () => {
420
-
421
420
  // The narrowness is the type's, not a rule each backend re-implements: a caller
422
421
  // cannot ask this door for a price, because there is no price on it.
423
422
  testSync("projects a reference to id, label and the state that retired it", () => {
@@ -490,7 +489,9 @@ describe("the reference door and the archive argument", () => {
490
489
  ~typeName="Ordering_OrderLine",
491
490
  ~subIdField="lineNo",
492
491
  ),
493
- )->toEqual(" Ordering_OrderLine(id: ID!, lineNo: String!, includeRetired: Boolean): Ordering_OrderLine")
492
+ )->toEqual(
493
+ " Ordering_OrderLine(id: ID!, lineNo: String!, includeRetired: Boolean): Ordering_OrderLine",
494
+ )
494
495
  )
495
496
  })
496
497
 
@@ -502,8 +503,8 @@ describe("the by-index door", () => {
502
503
  let index = (~index, ~idField=?, ~subIdField=?): Reventless.ReadModel.indexConfig => {
503
504
  index,
504
505
  type_: "S",
505
- idField: ?idField,
506
- subIdField: ?subIdField,
506
+ ?idField,
507
+ ?subIdField,
507
508
  projectionType: ALL,
508
509
  }
509
510
 
@@ -591,8 +592,10 @@ describe("the by-index door", () => {
591
592
  GraphQL_Stitcher.decode(
592
593
  GraphQL_FragmentGenerator.generate(~mutationEntries=[], ~queryEntries=[entryWith(indexes)]),
593
594
  ).queries->Array.filter(q => q->String.includes("Ordering_OrderBy"))
594
- expect((doorsOf([derived])->Array.length, doorsOf([authored, derived])->Array.length))
595
- ->toEqual((0, 1))
595
+ expect((
596
+ doorsOf([derived])->Array.length,
597
+ doorsOf([authored, derived])->Array.length,
598
+ ))->toEqual((0, 1))
596
599
  })
597
600
  })
598
601
 
@@ -681,7 +684,7 @@ module ResolvedFields = {
681
684
  returnTypeName: "Catalog_Order",
682
685
  stateSchema: orderSchema->S.castToUnknown,
683
686
  authorization: None,
684
- resolvedFields: ?resolvedFields,
687
+ ?resolvedFields,
685
688
  },
686
689
  {
687
690
  singleFieldName: "Catalog_Product",
@@ -755,10 +758,13 @@ describe("@resolves / @resolvesMany reach the SDL", () => {
755
758
  // it, not just this field. Refused where the declaration is, naming it.
756
759
  testSync("a target this plugin does not expose is refused", () =>
757
760
  expect(
758
- refused(() =>
759
- orderType(
760
- ~resolvedFields=Some([{fieldName: "supplier", typeName: "Supply_Supplier", multi: false}]),
761
- )
761
+ refused(
762
+ () =>
763
+ orderType(
764
+ ~resolvedFields=Some([
765
+ {fieldName: "supplier", typeName: "Supply_Supplier", multi: false},
766
+ ]),
767
+ ),
762
768
  ),
763
769
  )->toBe(true)
764
770
  )
@@ -768,11 +774,12 @@ describe("@resolves / @resolvesMany reach the SDL", () => {
768
774
  // handed over by the wider door.
769
775
  testSync("a target guarded differently from the parent is refused", () =>
770
776
  expect(
771
- refused(() =>
772
- orderType(
773
- ~resolvedFields=Some(ResolvedFields.bothFields),
774
- ~targetPermission=AllowGroups(["Admin"]),
775
- )
777
+ refused(
778
+ () =>
779
+ orderType(
780
+ ~resolvedFields=Some(ResolvedFields.bothFields),
781
+ ~targetPermission=AllowGroups(["Admin"]),
782
+ ),
776
783
  ),
777
784
  )->toBe(true)
778
785
  )
@@ -780,20 +787,25 @@ describe("@resolves / @resolvesMany reach the SDL", () => {
780
787
  // A target open to everyone can only narrow, so it needs no refusal.
781
788
  testSync("a target open to everyone is allowed under an authenticated parent", () =>
782
789
  expect(
783
- refused(() =>
784
- orderType(~resolvedFields=Some(ResolvedFields.bothFields), ~targetPermission=AllowAnonymous)
790
+ refused(
791
+ () =>
792
+ orderType(
793
+ ~resolvedFields=Some(ResolvedFields.bothFields),
794
+ ~targetPermission=AllowAnonymous,
795
+ ),
785
796
  ),
786
797
  )->toBe(false)
787
798
  )
788
799
 
789
800
  testSync("a resolved field colliding with a state field is refused", () =>
790
801
  expect(
791
- refused(() =>
792
- orderType(
793
- ~resolvedFields=Some([
794
- {fieldName: "productId", typeName: "Catalog_Product", multi: false},
795
- ]),
796
- )
802
+ refused(
803
+ () =>
804
+ orderType(
805
+ ~resolvedFields=Some([
806
+ {fieldName: "productId", typeName: "Catalog_Product", multi: false},
807
+ ]),
808
+ ),
797
809
  ),
798
810
  )->toBe(true)
799
811
  )
@@ -38,9 +38,9 @@ let warnFor = (~view, ~ownerField, ~elevated) => {
38
38
 
39
39
  describe("OwnerScopeDiagnostics:", () => {
40
40
  testSync("an owner-scoped view with no elevated groups warns", () =>
41
- expect(warnFor(~view="Orders", ~ownerField=Some("customerId"), ~elevated=[])->Array.length)->toBe(
42
- 1,
43
- )
41
+ expect(
42
+ warnFor(~view="Orders", ~ownerField=Some("customerId"), ~elevated=[])->Array.length,
43
+ )->toBe(1)
44
44
  )
45
45
 
46
46
  // The consequence is the whole point of the line — an operator reading
@@ -74,36 +74,40 @@ describe("OwnerScopeDiagnostics:", () => {
74
74
  testSync("the same view warns once, not once per registration", () => {
75
75
  OwnerScopeDiagnostics.resetWarnings()
76
76
  Reventless.OwnerScope.setElevatedGroups([])
77
- let lines = capture(() => {
78
- OwnerScopeDiagnostics.warnIfNoElevatedGroups(
79
- ~comp="Test",
80
- ~view="Orders",
81
- ~ownerField=Some("customerId"),
82
- )
83
- OwnerScopeDiagnostics.warnIfNoElevatedGroups(
84
- ~comp="Test",
85
- ~view="Orders",
86
- ~ownerField=Some("customerId"),
87
- )
88
- })
77
+ let lines = capture(
78
+ () => {
79
+ OwnerScopeDiagnostics.warnIfNoElevatedGroups(
80
+ ~comp="Test",
81
+ ~view="Orders",
82
+ ~ownerField=Some("customerId"),
83
+ )
84
+ OwnerScopeDiagnostics.warnIfNoElevatedGroups(
85
+ ~comp="Test",
86
+ ~view="Orders",
87
+ ~ownerField=Some("customerId"),
88
+ )
89
+ },
90
+ )
89
91
  expect(lines->Array.length)->toBe(1)
90
92
  })
91
93
 
92
94
  testSync("a second view gets its own warning", () => {
93
95
  OwnerScopeDiagnostics.resetWarnings()
94
96
  Reventless.OwnerScope.setElevatedGroups([])
95
- let lines = capture(() => {
96
- OwnerScopeDiagnostics.warnIfNoElevatedGroups(
97
- ~comp="Test",
98
- ~view="Orders",
99
- ~ownerField=Some("customerId"),
100
- )
101
- OwnerScopeDiagnostics.warnIfNoElevatedGroups(
102
- ~comp="Test",
103
- ~view="Invoices",
104
- ~ownerField=Some("payerId"),
105
- )
106
- })
97
+ let lines = capture(
98
+ () => {
99
+ OwnerScopeDiagnostics.warnIfNoElevatedGroups(
100
+ ~comp="Test",
101
+ ~view="Orders",
102
+ ~ownerField=Some("customerId"),
103
+ )
104
+ OwnerScopeDiagnostics.warnIfNoElevatedGroups(
105
+ ~comp="Test",
106
+ ~view="Invoices",
107
+ ~ownerField=Some("payerId"),
108
+ )
109
+ },
110
+ )
107
111
  expect(lines->Array.length)->toBe(2)
108
112
  })
109
113
  })
@@ -30,13 +30,14 @@ let ref_ = (~plugin: option<string>=?, ~store: string) =>
30
30
 
31
31
  describe("StorageRefFields.fromEventSchema", () => {
32
32
  testSync("finds a declared single-valued ref field and qualifies its store", () => {
33
- let schema = S.union([variant(~tag="ProductImageChanged", [("imageUrl", ref_(~store="productImages"))])])->S.castToUnknown
33
+ let schema =
34
+ S.union([
35
+ variant(~tag="ProductImageChanged", [("imageUrl", ref_(~store="productImages"))]),
36
+ ])->S.castToUnknown
34
37
  expect(Fields.fromEventSchema(~plugin="Catalog", schema))->toEqual([
35
38
  {
36
39
  Fields.eventType: "ProductImageChanged",
37
- fields: [
38
- {Fields.field: "imageUrl", arity: Single, store: "Catalog.productImages"},
39
- ],
40
+ fields: [{Fields.field: "imageUrl", arity: Single, store: "Catalog.productImages"}],
40
41
  },
41
42
  ])
42
43
  })
@@ -47,11 +48,15 @@ describe("StorageRefFields.fromEventSchema", () => {
47
48
  testSync("a qualified declaration keeps the store it names", () => {
48
49
  let schema =
49
50
  S.union([
50
- variant(~tag="OrderPhotoAttached", [("photo", ref_(~plugin="Catalog", ~store="productImages"))]),
51
+ variant(
52
+ ~tag="OrderPhotoAttached",
53
+ [("photo", ref_(~plugin="Catalog", ~store="productImages"))],
54
+ ),
51
55
  ])->S.castToUnknown
52
56
  expect(
53
- Fields.fromEventSchema(~plugin="Ordering", schema)
54
- ->Array.flatMap(e => e.fields->Array.map(f => f.store)),
57
+ Fields.fromEventSchema(~plugin="Ordering", schema)->Array.flatMap(
58
+ e => e.fields->Array.map(f => f.store),
59
+ ),
55
60
  )->toEqual(["Catalog.productImages"])
56
61
  })
57
62
 
@@ -61,7 +66,10 @@ describe("StorageRefFields.fromEventSchema", () => {
61
66
  testSync("finds a multi-valued ref field and records its arity", () => {
62
67
  let schema =
63
68
  S.union([
64
- variant(~tag="GalleryReplaced", [("imageUrls", S.array(ref_(~store="productImages"))->S.castToUnknown)]),
69
+ variant(
70
+ ~tag="GalleryReplaced",
71
+ [("imageUrls", S.array(ref_(~store="productImages"))->S.castToUnknown)],
72
+ ),
65
73
  ])->S.castToUnknown
66
74
  expect(
67
75
  Fields.fromEventSchema(~plugin="Catalog", schema)->Array.flatMap(e => e.fields),
@@ -77,13 +85,16 @@ describe("StorageRefFields.fromEventSchema", () => {
77
85
  variant(~tag="ProductRenamed", [("name", S.string->S.castToUnknown)]),
78
86
  variant(~tag="ProductImageChanged", [("imageUrl", ref_(~store="productImages"))]),
79
87
  ])->S.castToUnknown
80
- expect(Fields.fromEventSchema(~plugin="Catalog", schema)->Array.map(e => e.eventType))->toEqual([
81
- "ProductImageChanged",
82
- ])
88
+ expect(
89
+ Fields.fromEventSchema(~plugin="Catalog", schema)->Array.map(e => e.eventType),
90
+ )->toEqual(["ProductImageChanged"])
83
91
  })
84
92
 
85
93
  testSync("an event schema with no declaration anywhere yields nothing", () => {
86
- let schema = S.union([variant(~tag="ProductRenamed", [("name", S.string->S.castToUnknown)])])->S.castToUnknown
94
+ let schema =
95
+ S.union([
96
+ variant(~tag="ProductRenamed", [("name", S.string->S.castToUnknown)]),
97
+ ])->S.castToUnknown
87
98
  expect(Fields.fromEventSchema(~plugin="Catalog", schema))->toEqual([])
88
99
  })
89
100
 
@@ -93,15 +104,17 @@ describe("StorageRefFields.fromEventSchema", () => {
93
104
  // store the deploy actually provisioned.
94
105
  testSync("an unannotated string field is not treated as a ref", () => {
95
106
  let schema =
96
- S.union([variant(~tag="ProductImported", [("imageUrl", S.string->S.castToUnknown)])])->S.castToUnknown
107
+ S.union([
108
+ variant(~tag="ProductImported", [("imageUrl", S.string->S.castToUnknown)]),
109
+ ])->S.castToUnknown
97
110
  expect(Fields.fromEventSchema(~plugin="Catalog", schema))->toEqual([])
98
111
  })
99
112
 
100
113
  testSync("a single-variant (non-union) event schema is read the same way", () => {
101
114
  let schema = variant(~tag="ProductImageChanged", [("imageUrl", ref_(~store="productImages"))])
102
- expect(Fields.fromEventSchema(~plugin="Catalog", schema)->Array.map(e => e.eventType))->toEqual([
103
- "ProductImageChanged",
104
- ])
115
+ expect(
116
+ Fields.fromEventSchema(~plugin="Catalog", schema)->Array.map(e => e.eventType),
117
+ )->toEqual(["ProductImageChanged"])
105
118
  })
106
119
  })
107
120
 
@@ -122,8 +135,7 @@ describe("StorageRefFields.toJson", () => {
122
135
  },
123
136
  ]
124
137
  expect(Fields.toJson(entries)->JSON.stringify)->toBe(
125
- `{"ProductImageChanged":[{"field":"imageUrl","arity":"one","store":"Catalog.productImages"}],` ++
126
- `"GalleryReplaced":[{"field":"imageUrls","arity":"many","store":"Catalog.productImages"}]}`,
138
+ `{"ProductImageChanged":[{"field":"imageUrl","arity":"one","store":"Catalog.productImages"}],` ++ `"GalleryReplaced":[{"field":"imageUrls","arity":"many","store":"Catalog.productImages"}]}`,
127
139
  )
128
140
  })
129
141
  })