@reventlessdev/reventless-core 3.0.0-alpha.338 → 3.0.0-alpha.339

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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +4 -4
  3. package/src/ComponentType.res +38 -62
  4. package/src/ComponentType.res.mjs +34 -115
  5. package/src/ResourceAttribution.res +7 -33
  6. package/src/ResourceAttribution.res.mjs +2 -51
  7. package/src/ViewChange.res.mjs +2 -2
  8. package/src/admin/Platform_ComponentDefinitionsApi.res +10 -11
  9. package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +9 -8
  10. package/src/admin/Platform_PluginStructuresApi.res +1 -1
  11. package/src/admin/Platform_SelfRegistration.res.mjs +3 -3
  12. package/src/components/QueryDb/QueryDb.res.mjs +1 -1
  13. package/src/plugin/component/Plugin_Builder.res +1 -1
  14. package/src/plugin/component/Plugin_Builder.res.mjs +2 -2
  15. package/src/plugin/component/Plugin_BuiltHook.res +7 -2
  16. package/src/plugin/component/Plugin_Structure.res +8 -14
  17. package/src/plugin/component/Plugin_Structure.res.mjs +9 -18
  18. package/src/plugin/component/SchemaWalker.res +4 -4
  19. package/src/plugin/component/SchemaWalker.res.mjs +4 -4
  20. package/src/plugin/connect/PluginExtensionPoint_Builder.res +4 -1
  21. package/src/plugin/connect/PluginExtensionPoint_Plugin.res +7 -3
  22. package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +2 -2
  23. package/src/util/EffectLogger.res.mjs +8 -8
  24. package/src/util/Logger.res +21 -7
  25. package/src/util/Logger.res.mjs +44 -30
  26. package/tests/ClosedSetWordsTest.res +105 -0
  27. package/tests/ClosedSetWordsTest.res.mjs +145 -0
  28. package/tests/ResourceAttributionTest.res.mjs +4 -7
  29. package/tests/admin/AdminApiSchemaDriftTest.res +1 -1
  30. package/tests/admin/Platform_BakedManifestTest.res +1 -1
  31. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +1 -1
  32. package/tests/admin/Platform_PluginStructuresApiTest.res +3 -3
  33. package/tests/admin/Platform_SelfRegistrationTest.res +2 -2
  34. package/tests/commandgenerator/OwnerStampingTest.res.mjs +1 -1
  35. package/tests/logger/LogFormatTest.res.mjs +2 -2
  36. package/tests/logger/LoggerLazyTest.res.mjs +2 -2
  37. package/tests/logger/LoggerSinkTest.res.mjs +26 -26
  38. package/tests/plugin/ManifestVisibilityTest.res +4 -2
  39. package/tests/plugin/ManifestVisibilityTest.res.mjs +5 -1
  40. package/tests/plugin/SchemaWalkerTest.res +3 -3
  41. package/tests/plugin/SchemaWalkerTest.res.mjs +3 -3
  42. package/tests/projection/ViewChangeTest.res.mjs +1 -1
@@ -522,18 +522,12 @@ let checkLifecycleTopology = (
522
522
  // Which rung produced the label, published as `labelFieldSource`: a consumer with
523
523
  // a name rule of its own has to rank a declaration (rung 1) against a guess.
524
524
  type labelFieldSource =
525
- | Annotation
526
- | Convention
527
- | Position
528
- | Fallback
529
-
530
- let labelFieldSourceToString = (s: labelFieldSource): string =>
531
- switch s {
532
- | Annotation => "annotation"
533
- | Convention => "convention"
534
- | Position => "position"
535
- | Fallback => "fallback"
536
- }
525
+ | @as("annotation") Annotation
526
+ | @as("convention") Convention
527
+ | @as("position") Position
528
+ | @as("fallback") Fallback
529
+
530
+ let labelFieldSourceToString = (s: labelFieldSource): string => (s :> string)
537
531
 
538
532
  type labelResolution = {
539
533
  field: string,
@@ -1131,10 +1125,10 @@ let extractCommandDefs = (
1131
1125
  // Omitted for the default `Public` so a published def stays compact: absent and
1132
1126
  // "public" are the same answer, and writing one would make every ordinary view
1133
1127
  // carry a word that says nothing.
1134
- let visibilityTag = (v: Reventless.Visibility.t): option<string> =>
1128
+ let visibilityTag = (v: Reventless.Visibility.t): option<Reventless.Visibility.t> =>
1135
1129
  switch v {
1136
1130
  | Public => None
1137
- | Internal => Some("Internal")
1131
+ | _ => Some(v)
1138
1132
  }
1139
1133
 
1140
1134
  /**
@@ -392,16 +392,7 @@ function checkLifecycleTopology(pluginName, writeSides, lifecycleStatesByView) {
392
392
  }
393
393
 
394
394
  function labelFieldSourceToString(s) {
395
- switch (s) {
396
- case "Annotation" :
397
- return "annotation";
398
- case "Convention" :
399
- return "convention";
400
- case "Position" :
401
- return "position";
402
- case "Fallback" :
403
- return "fallback";
404
- }
395
+ return s;
405
396
  }
406
397
 
407
398
  function labelFieldsFromStateSchema(entityName, stateSchema) {
@@ -410,7 +401,7 @@ function labelFieldsFromStateSchema(entityName, stateSchema) {
410
401
  return {
411
402
  field: "displayName",
412
403
  searchableFields: spec.fields,
413
- source: "Annotation"
404
+ source: "annotation"
414
405
  };
415
406
  }
416
407
  let candidates;
@@ -428,10 +419,10 @@ function labelFieldsFromStateSchema(entityName, stateSchema) {
428
419
  });
429
420
  let picked = conventional !== undefined ? [
430
421
  conventional[0],
431
- "Convention"
422
+ "convention"
432
423
  ] : Stdlib_Option.map(candidates[0], param => [
433
424
  param[0],
434
- "Position"
425
+ "position"
435
426
  ]);
436
427
  if (picked !== undefined) {
437
428
  let name = picked[0];
@@ -445,7 +436,7 @@ function labelFieldsFromStateSchema(entityName, stateSchema) {
445
436
  return {
446
437
  field: "id",
447
438
  searchableFields: [],
448
- source: "Fallback"
439
+ source: "fallback"
449
440
  };
450
441
  }
451
442
 
@@ -842,7 +833,7 @@ function visibilityTag(v) {
842
833
  if (v === "Public") {
843
834
  return;
844
835
  } else {
845
- return "Internal";
836
+ return v;
846
837
  }
847
838
  }
848
839
 
@@ -861,7 +852,7 @@ function readSideDefFromSpec(plugin, name, stateSchema, authorization, visibilit
861
852
  linkedWriteSide: linkedWriteSide,
862
853
  labelField: label.field,
863
854
  searchableFields: label.searchableFields,
864
- labelFieldSource: labelFieldSourceToString(label.source),
855
+ labelFieldSource: label.source,
865
856
  lifecycleField: Lifecycle$Reventless.fieldName(stateSchema),
866
857
  ownerField: Owner$Reventless.fieldNames(stateSchema)[0],
867
858
  retiredField: retiredFieldFromStateSchema(stateSchema),
@@ -1183,7 +1174,7 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
1183
1174
  linkedWriteSide: linkedWriteSideFor(consumed),
1184
1175
  labelField: label.field,
1185
1176
  searchableFields: label.searchableFields,
1186
- labelFieldSource: labelFieldSourceToString(label.source),
1177
+ labelFieldSource: label.source,
1187
1178
  lifecycleField: Lifecycle$Reventless.fieldName(stateSchema),
1188
1179
  ownerField: Owner$Reventless.fieldNames(stateSchema)[0],
1189
1180
  retiredField: retiredFieldFromStateSchema(stateSchema),
@@ -1224,7 +1215,7 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
1224
1215
  linkedWriteSide: linkedWriteSideFor(consumed),
1225
1216
  labelField: label.field,
1226
1217
  searchableFields: label.searchableFields,
1227
- labelFieldSource: labelFieldSourceToString(label.source),
1218
+ labelFieldSource: label.source,
1228
1219
  lifecycleField: Lifecycle$Reventless.fieldName(stateSchema),
1229
1220
  ownerField: Owner$Reventless.fieldNames(stateSchema)[0],
1230
1221
  retiredField: retiredFieldFromStateSchema(stateSchema),
@@ -144,7 +144,7 @@ let walkSchema = (typeName: string, schema: S.t<unknown>): typeSchema =>
144
144
  let fields = extractFields(properties)
145
145
  {
146
146
  typeName,
147
- kind: "record",
147
+ kind: RecordSchema,
148
148
  fields,
149
149
  structuralHash: hashFields(fields),
150
150
  }
@@ -158,7 +158,7 @@ let walkSchema = (typeName: string, schema: S.t<unknown>): typeSchema =>
158
158
  )
159
159
  if hasNullLike {
160
160
  // It's an optional/nullable scalar at the top level, treat as unknown.
161
- {typeName, kind: "unknown", fields: [], structuralHash: ""}
161
+ {typeName, kind: UnknownSchema, fields: [], structuralHash: ""}
162
162
  } else {
163
163
  let constructors = anyOf->Array.filterMap(variantSchema =>
164
164
  switch variantSchema {
@@ -172,13 +172,13 @@ let walkSchema = (typeName: string, schema: S.t<unknown>): typeSchema =>
172
172
  )
173
173
  {
174
174
  typeName,
175
- kind: "variant",
175
+ kind: VariantSchema,
176
176
  fields: [],
177
177
  constructors,
178
178
  structuralHash: hashConstructors(constructors),
179
179
  }
180
180
  }
181
- | _ => {typeName, kind: "unknown", fields: [], structuralHash: ""}
181
+ | _ => {typeName, kind: UnknownSchema, fields: [], structuralHash: ""}
182
182
  }
183
183
 
184
184
  // ---------------------------------------------------------------------------
@@ -129,7 +129,7 @@ function walkSchema(typeName, schema) {
129
129
  let fields = extractFields(schema.properties);
130
130
  return {
131
131
  typeName: typeName,
132
- kind: "record",
132
+ kind: "RecordSchema",
133
133
  fields: fields,
134
134
  structuralHash: hashFields(fields)
135
135
  };
@@ -147,7 +147,7 @@ function walkSchema(typeName, schema) {
147
147
  if (hasNullLike) {
148
148
  return {
149
149
  typeName: typeName,
150
- kind: "unknown",
150
+ kind: "UnknownSchema",
151
151
  fields: [],
152
152
  structuralHash: ""
153
153
  };
@@ -164,7 +164,7 @@ function walkSchema(typeName, schema) {
164
164
  });
165
165
  return {
166
166
  typeName: typeName,
167
- kind: "variant",
167
+ kind: "VariantSchema",
168
168
  fields: [],
169
169
  constructors: constructors,
170
170
  structuralHash: hashConstructors(constructors)
@@ -172,7 +172,7 @@ function walkSchema(typeName, schema) {
172
172
  default:
173
173
  return {
174
174
  typeName: typeName,
175
- kind: "unknown",
175
+ kind: "UnknownSchema",
176
176
  fields: [],
177
177
  structuralHash: ""
178
178
  };
@@ -5,7 +5,10 @@ module type Spec = {
5
5
  let environment: string
6
6
  let updateApiSchema: option<Reventless.QueryEngine.operations => promise<unit>>
7
7
  let manageSubscriptions: option<
8
- (Reventless.Plugin.pluginDefinition, [#connect | #disconnect]) => promise<unit>,
8
+ (
9
+ Reventless.Plugin.pluginDefinition,
10
+ PluginExtensionPoint_Plugin.subscriptionChange,
11
+ ) => promise<unit>,
9
12
  >
10
13
  }
11
14
 
@@ -12,6 +12,10 @@ module PluginExtensionPointSpec = ReventlessInfra.PluginExtensionPointSpec
12
12
  // small intervals and ≥ +50% for large ones (5→7, 10→15, 60→90).
13
13
  let disconnectGrace = interval => interval + max(2, interval / 2)
14
14
 
15
+ /** What the admin does with a plugin's cross-plugin subscriptions: wires them
16
+ when the plugin connects, removes them when it disconnects. */
17
+ type subscriptionChange = ConnectSubscriptions | DisconnectSubscriptions
18
+
15
19
  module type Spec = {
16
20
  let runtimeOps: PluginRuntimeOperations.operations
17
21
  let environment: string
@@ -23,7 +27,7 @@ module type Spec = {
23
27
  // Lambda (which only handles incoming commands like Heartbeat). Some only
24
28
  // on the admin EventCollector entry point.
25
29
  let manageSubscriptions: option<
26
- (Reventless.Plugin.pluginDefinition, [#connect | #disconnect]) => promise<unit>,
30
+ (Reventless.Plugin.pluginDefinition, subscriptionChange) => promise<unit>,
27
31
  >
28
32
  }
29
33
 
@@ -125,7 +129,7 @@ module Make = (Spec: Spec) => {
125
129
  await forwardCommand(id, command, extensionPointName, queryEngine)
126
130
  | DoConnectPlugin(pluginDef) =>
127
131
  switch Spec.manageSubscriptions {
128
- | Some(fn) => await fn(pluginDef, #connect)
132
+ | Some(fn) => await fn(pluginDef, ConnectSubscriptions)
129
133
  | None => ()
130
134
  }
131
135
  switch Spec.updateApiSchema {
@@ -134,7 +138,7 @@ module Make = (Spec: Spec) => {
134
138
  }
135
139
  | DoDisconnectPlugin(pluginDef) =>
136
140
  switch Spec.manageSubscriptions {
137
- | Some(fn) => await fn(pluginDef, #disconnect)
141
+ | Some(fn) => await fn(pluginDef, DisconnectSubscriptions)
138
142
  | None => ()
139
143
  }
140
144
  switch Spec.updateApiSchema {
@@ -82,7 +82,7 @@ function Make(Spec) {
82
82
  case "DoConnectPlugin" :
83
83
  let fn = Spec.manageSubscriptions;
84
84
  if (fn !== undefined) {
85
- await fn(directive._0, "connect");
85
+ await fn(directive._0, "ConnectSubscriptions");
86
86
  }
87
87
  let fn$1 = Spec.updateApiSchema;
88
88
  if (fn$1 !== undefined) {
@@ -93,7 +93,7 @@ function Make(Spec) {
93
93
  case "DoDisconnectPlugin" :
94
94
  let fn$2 = Spec.manageSubscriptions;
95
95
  if (fn$2 !== undefined) {
96
- await fn$2(directive._0, "disconnect");
96
+ await fn$2(directive._0, "DisconnectSubscriptions");
97
97
  }
98
98
  let fn$3 = Spec.updateApiSchema;
99
99
  if (fn$3 !== undefined) {
@@ -32,26 +32,26 @@ function _effectMin(comp, param) {
32
32
  return "None";
33
33
  }
34
34
  switch (match) {
35
- case "Debug" :
35
+ case "DEBUG" :
36
36
  return "Debug";
37
- case "Info" :
37
+ case "INFO" :
38
38
  return "Info";
39
- case "Warn" :
39
+ case "WARN" :
40
40
  return "Warn";
41
- case "Error" :
41
+ case "ERROR" :
42
42
  return "Error";
43
43
  }
44
44
  }
45
45
 
46
46
  function levelOf(level) {
47
47
  if (level === "Fatal" || level === "Error") {
48
- return "Error";
48
+ return "ERROR";
49
49
  } else if (level === "Info") {
50
- return "Info";
50
+ return "INFO";
51
51
  } else if (level === "Warn") {
52
- return "Warn";
52
+ return "WARN";
53
53
  } else {
54
- return "Debug";
54
+ return "DEBUG";
55
55
  }
56
56
  }
57
57
 
@@ -44,7 +44,15 @@ type t = {
44
44
  debugLazy: (~comp: string=?, unit => string) => unit,
45
45
  }
46
46
 
47
- type level = Debug | Info | Warn | Error
47
+ /** A log line's level. Its text is the upper-case word a JSON line, the platform
48
+ API and a level setting carry. */
49
+ type level =
50
+ | @as("DEBUG") Debug
51
+ | @as("INFO") Info
52
+ | @as("WARN") Warn
53
+ | @as("ERROR") Error
54
+
55
+ let levels = [Debug, Info, Warn, Error]
48
56
 
49
57
  let levelToInt = l =>
50
58
  switch l {
@@ -54,13 +62,19 @@ let levelToInt = l =>
54
62
  | Error => 3
55
63
  }
56
64
 
57
- let levelLabel = l =>
58
- switch l {
59
- | Debug => "DEBUG"
60
- | Info => "INFO"
61
- | Warn => "WARN"
62
- | Error => "ERROR"
65
+ let levelLabel = (l: level): string => (l :> string)
66
+
67
+ /** The level an upper-case word names (`WARN`); `None` for a word that names none. */
68
+ let levelOfLabel = (label: string): option<level> => levels->Array.find(l => levelLabel(l) == label)
69
+
70
+ /** The level a word names in any case (`warn`, `Warn`), `warning` included. */
71
+ let levelOfWord = (word: string): option<level> => {
72
+ let lower = word->String.toLowerCase
73
+ switch lower {
74
+ | "warning" => Some(Warn)
75
+ | _ => levels->Array.find(l => levelLabel(l)->String.toLowerCase == lower)
63
76
  }
77
+ }
64
78
 
65
79
  // ─── Shared format + output ──────────────────────────────────────────────────
66
80
  // Single definition used by Logger.t AND EffectLogger.
@@ -22,29 +22,40 @@ let s = process.env.REVENTLESS_LOG_MAX_DETAIL_BYTES;
22
22
 
23
23
  let maxDetailBytes = s !== undefined ? Stdlib_Option.getOr(Stdlib_Int.fromString(s, undefined), 32768) : 32768;
24
24
 
25
+ let levels = [
26
+ "DEBUG",
27
+ "INFO",
28
+ "WARN",
29
+ "ERROR"
30
+ ];
31
+
25
32
  function levelToInt(l) {
26
33
  switch (l) {
27
- case "Debug" :
34
+ case "DEBUG" :
28
35
  return 0;
29
- case "Info" :
36
+ case "INFO" :
30
37
  return 1;
31
- case "Warn" :
38
+ case "WARN" :
32
39
  return 2;
33
- case "Error" :
40
+ case "ERROR" :
34
41
  return 3;
35
42
  }
36
43
  }
37
44
 
38
45
  function levelLabel(l) {
39
- switch (l) {
40
- case "Debug" :
41
- return "DEBUG";
42
- case "Info" :
43
- return "INFO";
44
- case "Warn" :
45
- return "WARN";
46
- case "Error" :
47
- return "ERROR";
46
+ return l;
47
+ }
48
+
49
+ function levelOfLabel(label) {
50
+ return levels.find(l => l === label);
51
+ }
52
+
53
+ function levelOfWord(word) {
54
+ let lower = word.toLowerCase();
55
+ if (lower === "warning") {
56
+ return "WARN";
57
+ } else {
58
+ return levels.find(l => l.toLowerCase() === lower);
48
59
  }
49
60
  }
50
61
 
@@ -100,7 +111,7 @@ function recordFields(r) {
100
111
  ],
101
112
  [
102
113
  "level",
103
- levelLabel(r.level)
114
+ r.level
104
115
  ],
105
116
  [
106
117
  "message",
@@ -197,23 +208,23 @@ function emit(level, comp, plugin, detail, annotations, msg) {
197
208
  let t = hms();
198
209
  let c = LogPrefix$Reventless.fmtComp(comp, undefined);
199
210
  switch (level) {
200
- case "Debug" :
211
+ case "DEBUG" :
201
212
  console.log(t + ` ` + dim + `D` + reset + ` ` + c + msg);
202
213
  return;
203
- case "Info" :
214
+ case "INFO" :
204
215
  console.log(t + ` ` + cyan + `I` + reset + ` ` + c + msg);
205
216
  return;
206
- case "Warn" :
217
+ case "WARN" :
207
218
  console.warn(t + ` ` + yellow + `W` + reset + ` ` + c + msg);
208
219
  return;
209
- case "Error" :
220
+ case "ERROR" :
210
221
  console.error(t + ` ` + red + `E` + reset + ` ` + c + msg);
211
222
  return;
212
223
  }
213
224
  }
214
225
 
215
226
  let defaultMinLevel = {
216
- contents: "Info"
227
+ contents: "INFO"
217
228
  };
218
229
 
219
230
  function setDefaultMinLevel(l) {
@@ -229,20 +240,20 @@ function makeLoggerWith(shouldLog) {
229
240
  emit(level, comp, undefined, undefined, undefined, msg + dataStr);
230
241
  };
231
242
  return {
232
- debug: (comp, data, msg) => log("Debug", comp, data, msg),
233
- info: (comp, data, msg) => log("Info", comp, data, msg),
234
- warn: (comp, data, msg) => log("Warn", comp, data, msg),
235
- error: (comp, data, msg) => log("Error", comp, data, msg),
243
+ debug: (comp, data, msg) => log("DEBUG", comp, data, msg),
244
+ info: (comp, data, msg) => log("INFO", comp, data, msg),
245
+ warn: (comp, data, msg) => log("WARN", comp, data, msg),
246
+ error: (comp, data, msg) => log("ERROR", comp, data, msg),
236
247
  debugLazy: (comp, makeMsg) => {
237
- if (shouldLog("Debug", comp)) {
238
- return emit("Debug", comp, undefined, undefined, undefined, makeMsg());
248
+ if (shouldLog("DEBUG", comp)) {
249
+ return emit("DEBUG", comp, undefined, undefined, undefined, makeMsg());
239
250
  }
240
251
  }
241
252
  };
242
253
  }
243
254
 
244
255
  function makeLogger(minLevelOpt) {
245
- let minLevel = minLevelOpt !== undefined ? minLevelOpt : "Info";
256
+ let minLevel = minLevelOpt !== undefined ? minLevelOpt : "INFO";
246
257
  return makeLoggerWith((l, param) => levelToInt(l) >= levelToInt(minLevel));
247
258
  }
248
259
 
@@ -281,15 +292,15 @@ function effectiveMin() {
281
292
  }
282
293
  switch (match) {
283
294
  case "debug" :
284
- return "Debug";
295
+ return "DEBUG";
285
296
  case "error" :
286
- return "Error";
297
+ return "ERROR";
287
298
  case "silent" :
288
299
  return;
289
300
  case "warn" :
290
- return "Warn";
301
+ return "WARN";
291
302
  default:
292
- return "Info";
303
+ return "INFO";
293
304
  }
294
305
  }
295
306
 
@@ -453,8 +464,11 @@ let resolvePlugin = LogPrefix$Reventless.resolvePlugin;
453
464
  export {
454
465
  serviceName,
455
466
  maxDetailBytes,
467
+ levels,
456
468
  levelToInt,
457
469
  levelLabel,
470
+ levelOfLabel,
471
+ levelOfWord,
458
472
  red,
459
473
  yellow,
460
474
  cyan,
@@ -0,0 +1,105 @@
1
+ open JestGlobals
2
+
3
+ // Each closed set below is held as a variant and turned into text only where a
4
+ // deployment, a published structure or a log line carries it. These pin that
5
+ // text: every word reads back as its case and prints as the same word.
6
+
7
+ describe("ComponentType", () => {
8
+ let words = [
9
+ "Aggregate",
10
+ "Counter",
11
+ "Plugin",
12
+ "Platform",
13
+ "CommandGenerator",
14
+ "CommandTopic",
15
+ "EventCollector",
16
+ "EventLog",
17
+ "EventMapper",
18
+ "EventTopic",
19
+ "ExtensionPoint",
20
+ "Extension",
21
+ "QueryDB",
22
+ "ReadModel",
23
+ "Scheduler",
24
+ "Service",
25
+ "SideEffectHandler",
26
+ "Task",
27
+ "Vpc",
28
+ "Heartbeat",
29
+ "Cloner",
30
+ "DcbEventLog",
31
+ "StateChangeSlice",
32
+ "StateViewSlice",
33
+ "AutomationSlice",
34
+ "OutboundTranslationSlice",
35
+ "InboundTranslationSlice",
36
+ ]
37
+
38
+ testSync("prints each kind as the word a deployment carries", () =>
39
+ expect(ComponentType.all->Array.map(ComponentType.toString))->toEqual(words)
40
+ )
41
+
42
+ testSync("reads each word back, and no other", () =>
43
+ expect(
44
+ Array.concat(words, ["QueryDb", "Runtime"])->Array.map(
45
+ w => ComponentType.ofString(w)->Option.map(ComponentType.toString),
46
+ ),
47
+ )->toEqual(Array.concat(words->Array.map(w => Some(w)), [None, None]))
48
+ )
49
+
50
+ // The short name every physical resource is named with: a second spelling of
51
+ // the query store that is not the kind's word.
52
+ testSync("the query store's short name stays QueryDb", () =>
53
+ expect(ComponentType.QueryDb->ComponentType.toName)->toBe("QueryDb")
54
+ )
55
+ })
56
+
57
+ describe("ResourceAttribution", () => {
58
+ testSync("a role's text is its name, and an other role is its own word", () =>
59
+ expect(
60
+ [
61
+ ResourceAttribution.Role.QueryDb,
62
+ Runtime,
63
+ EventSourceMapping,
64
+ Other("ChangeFeed"),
65
+ ]->Array.map(ResourceAttribution.Role.toString),
66
+ )->toEqual(["QueryDb", "Runtime", "EventSourceMapping", "ChangeFeed"])
67
+ )
68
+ })
69
+
70
+ describe("Plugin_Structure.labelFieldSource", () => {
71
+ testSync("prints each source in lower case", () =>
72
+ expect(
73
+ [Plugin_Structure.Annotation, Convention, Position, Fallback]->Array.map(
74
+ Plugin_Structure.labelFieldSourceToString,
75
+ ),
76
+ )->toEqual(["annotation", "convention", "position", "fallback"])
77
+ )
78
+ })
79
+
80
+ describe("Plugin_BuiltHook.schemaKind", () => {
81
+ testSync("prints each kind as a published schema carries it", () =>
82
+ expect(
83
+ [Plugin_BuiltHook.RecordSchema, VariantSchema, UnknownSchema]->Array.map(k => (k :> string)),
84
+ )->toEqual(["RecordSchema", "VariantSchema", "UnknownSchema"])
85
+ )
86
+ })
87
+
88
+ describe("Logger levels", () => {
89
+ testSync("a level's label is its upper-case word, and reads back exactly", () => {
90
+ expect(Logger.levels->Array.map(Logger.levelLabel))->toEqual(["DEBUG", "INFO", "WARN", "ERROR"])
91
+ expect(
92
+ ["DEBUG", "INFO", "WARN", "ERROR", "warn", "WARNING"]->Array.map(
93
+ w => Logger.levelOfLabel(w)->Option.map(Logger.levelLabel),
94
+ ),
95
+ )->toEqual([Some("DEBUG"), Some("INFO"), Some("WARN"), Some("ERROR"), None, None])
96
+ })
97
+
98
+ testSync("a word reads in any case, warning included", () =>
99
+ expect(
100
+ ["debug", "Info", "WARN", "warning", "Error", "trace"]->Array.map(
101
+ w => Logger.levelOfWord(w)->Option.map(Logger.levelLabel),
102
+ ),
103
+ )->toEqual([Some("DEBUG"), Some("INFO"), Some("WARN"), Some("WARN"), Some("ERROR"), None])
104
+ )
105
+ })