@reventlessdev/reventless-spec 3.0.0-alpha.117 → 3.0.0-alpha.119

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 (68) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/package.json +3 -3
  3. package/src/components/CapabilityManifest.res +1 -1
  4. package/src/components/CapabilityManifest.res.mjs +13 -12
  5. package/src/components/DcbDecode.res +8 -8
  6. package/src/components/DcbDecode.res.mjs +9 -8
  7. package/src/components/DcbTag.res +43 -42
  8. package/src/components/DcbTag.res.mjs +90 -87
  9. package/src/components/DcbValidation.res +6 -6
  10. package/src/components/DcbValidation.res.mjs +6 -6
  11. package/src/components/DisplayName.res.mjs +3 -3
  12. package/src/components/Owner.res +1 -1
  13. package/src/components/Owner.res.mjs +7 -7
  14. package/src/components/Plugin.res +8 -11
  15. package/src/components/Plugin.res.mjs +133 -134
  16. package/src/components/Reference.res.mjs +5 -5
  17. package/src/components/StateAnnotations.res +23 -0
  18. package/src/components/StateAnnotations.res.mjs +3 -3
  19. package/src/components/TaggedUnion.res +238 -0
  20. package/src/components/TaggedUnion.res.mjs +193 -0
  21. package/src/generator/PlatformCodegen.res +17 -14
  22. package/src/generator/PlatformCodegen.res.mjs +1 -1
  23. package/src/generator/PlatformGenerator.res +1 -1
  24. package/src/semantic/Bytes.res.mjs +2 -2
  25. package/src/semantic/Color.res.mjs +2 -2
  26. package/src/semantic/Currency.res.mjs +167 -167
  27. package/src/semantic/DateRange.res.mjs +2 -2
  28. package/src/semantic/Duration.res.mjs +2 -2
  29. package/src/semantic/Email.res +2 -2
  30. package/src/semantic/Email.res.mjs +3 -2
  31. package/src/semantic/FileRef.res +28 -0
  32. package/src/semantic/FileRef.res.mjs +17 -0
  33. package/src/semantic/GeoPoint.res +14 -10
  34. package/src/semantic/GeoPoint.res.mjs +10 -17
  35. package/src/semantic/ImageRef.res +51 -0
  36. package/src/semantic/ImageRef.res.mjs +17 -0
  37. package/src/semantic/Media_Ref.res +33 -0
  38. package/src/semantic/Media_Ref.res.mjs +37 -0
  39. package/src/semantic/Money.res +7 -5
  40. package/src/semantic/Money.res.mjs +6 -9
  41. package/src/semantic/Offload.res +29 -43
  42. package/src/semantic/Offload.res.mjs +18 -49
  43. package/src/semantic/Percent.res.mjs +2 -2
  44. package/src/semantic/Phone.res.mjs +2 -2
  45. package/src/semantic/Semantic.res +24 -6
  46. package/src/semantic/Semantic.res.mjs +13 -12
  47. package/src/semantic/StorageRef.res +33 -19
  48. package/src/semantic/StorageRef.res.mjs +14 -14
  49. package/src/semantic/UploadableFile.res +30 -0
  50. package/src/semantic/UploadableFile.res.mjs +23 -0
  51. package/src/semantic/UploadableImage.res +56 -0
  52. package/src/semantic/UploadableImage.res.mjs +23 -0
  53. package/src/semantic/Url.res +8 -2
  54. package/src/semantic/Url.res.mjs +3 -2
  55. package/src/types/Authorization.res.mjs +7 -7
  56. package/src/types/DateTime.res.mjs +2 -2
  57. package/src/types/Id.res.mjs +6 -4
  58. package/src/types/Identity.res +0 -1
  59. package/src/types/Identity.res.mjs +12 -14
  60. package/src/types/Message.res +29 -10
  61. package/src/types/Message.res.mjs +56 -37
  62. package/src/types/ReadConsistency.res.mjs +5 -5
  63. package/src/types/Schedule.res.mjs +37 -37
  64. package/src/types/StoredEvent.res +2 -2
  65. package/src/types/StoredEvent.res.mjs +11 -10
  66. package/src/types/Visibility.res.mjs +4 -4
  67. package/src/util/Util_Sury.res +32 -0
  68. package/src/util/Util_Sury.res.mjs +39 -0
@@ -0,0 +1,56 @@
1
+ /**
2
+ An image the platform stores, referenced by the path its store minted.
3
+
4
+ ## What this says that `@storageRef` does not
5
+
6
+ `@storageRef("productImages") imageUrl?: string` states two facts and declares
7
+ only one. It says *where* the value lives — typed, validated, provisioned — and
8
+ leaves *what the value is* to be guessed from the field being called `imageUrl`.
9
+ This type states both, so the same declaration picks the renderer and the upload
10
+ endpoint.
11
+
12
+ ## No store argument
13
+
14
+ The store is the field's name, pluralised, derived by the ppx —
15
+ `productImage: UploadableImage.t` requires the `productImages` store. So a field
16
+ declares its store by being named, and renaming the field renames the store:
17
+ treat a rename of a live field as a data migration, or keep the old store with an
18
+ explicit `@storageRef("…")`, which still wins.
19
+
20
+ The stored value is unchanged from `StorageRef`: an origin-relative
21
+ `/{prefix}/{key}` string, validated by the same refinement. Retyping an existing
22
+ `@storageRef` field to this one alters no stored bytes — only the field's *name*
23
+ does, and only because the store is derived from it.
24
+
25
+ @example
26
+ ```rescript
27
+ @schema type command =
28
+ | ChangeProductImage({
29
+ productId: @s.matches(DcbTag.string) string,
30
+ productImage: UploadableImage.t,
31
+ })
32
+ ```
33
+ */
34
+
35
+ /** Transparent `string`, for `StorageRef.t`'s reason: the marker refines an
36
+ existing field rather than replacing it, so nothing stored changes. */
37
+ type t = string
38
+
39
+ external unsafe: string => t = "%identity"
40
+ external toString: t => string = "%identity"
41
+
42
+ /** The grammar, which is `StorageRef`'s — one definition, no second copy. */
43
+ let fromString = (raw: string): result<t, string> => StorageRef.fromString(raw)
44
+
45
+ /**
46
+ The schema for a field of this type, bound to the store the ppx derived.
47
+
48
+ Prefer typing the field `UploadableImage.t` and letting `UploadableInference`
49
+ call this. Written by hand it needs the derived store name, which defeats the
50
+ point of the type.
51
+ */
52
+ let forField = (~plugin: option<string>=?, ~store: string): S.t<t> =>
53
+ StorageRef.refinement->Semantic.mark(
54
+ ~id=Semantic.Id.uploadableImage,
55
+ ~payload=StoredIn({plugin, store, threshold: None}),
56
+ )
@@ -0,0 +1,23 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Semantic$Reventless from "./Semantic.res.mjs";
4
+ import * as StorageRef$Reventless from "./StorageRef.res.mjs";
5
+
6
+ let fromString = StorageRef$Reventless.fromString;
7
+
8
+ function forField(plugin, store) {
9
+ return Semantic$Reventless.mark(StorageRef$Reventless.refinement, Semantic$Reventless.Id.uploadableImage, {
10
+ TAG: "StoredIn",
11
+ _0: {
12
+ plugin: plugin,
13
+ store: store,
14
+ threshold: undefined
15
+ }
16
+ });
17
+ }
18
+
19
+ export {
20
+ fromString,
21
+ forField,
22
+ }
23
+ /* Semantic-Reventless Not a pure module */
@@ -33,7 +33,13 @@ external toString: t => string = "%identity"
33
33
 
34
34
  // Sury's parse, held once — `fromString` runs it and adds the scheme check, and
35
35
  // `schema` derives from `fromString`. One grammar, in one place.
36
- let grammar: S.t<string> = S.string->S.url
36
+ //
37
+ // `S.uri`, not `S.url`: sury 11 turned `S.url` into a `URL` *instance*, whose
38
+ // `href` is normalised (`http://x` comes back `http://x/`). This value is written
39
+ // to an append-only log, so the address has to survive the round trip as the
40
+ // caller wrote it. `S.uri` is the string-preserving arm — it still rejects what
41
+ // does not parse, and returns exactly what it was given.
42
+ let grammar: S.t<string> = S.uri
37
43
 
38
44
  // Schemes are case-insensitive per RFC 3986, and `HTTPS://x` parses fine, so the
39
45
  // allowlist has to fold case or it rejects a valid address on a technicality.
@@ -44,7 +50,7 @@ let hasWebScheme = (raw: string): bool => {
44
50
 
45
51
  /** Validate a raw string as an `http`/`https` URL, saying why when it is not one. */
46
52
  let fromString = (raw: string): result<t, string> =>
47
- switch raw->S.parseOrThrow(grammar) {
53
+ switch raw->S.parseOrThrow(~to=grammar) {
48
54
  | value =>
49
55
  if hasWebScheme(value) {
50
56
  Ok(value)
@@ -1,9 +1,10 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as S from "sury/src/S.res.mjs";
4
+ import * as Sury from "sury";
4
5
  import * as Semantic$Reventless from "./Semantic.res.mjs";
5
6
 
6
- let grammar = S.url(S.string, undefined);
7
+ let grammar = Sury.uri;
7
8
 
8
9
  function hasWebScheme(raw) {
9
10
  let lower = raw.toLowerCase();
@@ -37,7 +38,7 @@ function fromString(raw) {
37
38
  }
38
39
  }
39
40
 
40
- let schema = Semantic$Reventless.refined(S.string, Semantic$Reventless.Id.url, fromString);
41
+ let schema = Semantic$Reventless.refined(Sury.string, Semantic$Reventless.Id.url, fromString);
41
42
 
42
43
  export {
43
44
  grammar,
@@ -1,15 +1,15 @@
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
 
5
- let permissionSchema = S.union([
6
- S.schema(s => ({
5
+ let permissionSchema = Sury.union([
6
+ Sury.$schema(s => ({
7
7
  TAG: "AllowGroups",
8
- _0: s.m(S.array(S.string))
8
+ _0: s.m(Sury.array(Sury.string))
9
9
  })),
10
- S.literal("AllowAuthenticated"),
11
- S.literal("AllowAnonymous"),
12
- S.literal("DenyAll")
10
+ Sury.literal("AllowAuthenticated"),
11
+ Sury.literal("AllowAnonymous"),
12
+ Sury.literal("DenyAll")
13
13
  ]);
14
14
 
15
15
  function isAllowed(rule, identity) {
@@ -1,9 +1,9 @@
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 Semantic$Reventless from "../semantic/Semantic.res.mjs";
5
5
 
6
- let string = Semantic$Reventless.mark(S.string, Semantic$Reventless.Id.dateTime, undefined);
6
+ let string = Semantic$Reventless.mark(Sury.string, Semantic$Reventless.Id.dateTime, undefined);
7
7
 
8
8
  function isDateTime(fieldSchema) {
9
9
  return Semantic$Reventless.has(fieldSchema, Semantic$Reventless.Id.dateTime);
@@ -1,12 +1,14 @@
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 Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
5
5
 
6
+ let schema = Sury.string;
7
+
6
8
  let cmp = Primitive_string.compare;
7
9
 
8
10
  let StringPure = {
9
- schema: S.string,
11
+ schema: schema,
10
12
  cmp: cmp
11
13
  };
12
14
 
@@ -23,7 +25,7 @@ function String_toString(prim) {
23
25
  }
24
26
 
25
27
  let $$String = {
26
- schema: S.string,
28
+ schema: schema,
27
29
  make: String_make,
28
30
  makeFromString: String_makeFromString,
29
31
  toString: String_toString,
@@ -34,4 +36,4 @@ export {
34
36
  StringPure,
35
37
  $$String,
36
38
  }
37
- /* S Not a pure module */
39
+ /* schema Not a pure module */
@@ -1,4 +1,3 @@
1
- S.enableJson()
2
1
 
3
2
  /** Identity provider that authenticated the user. */
4
3
  @schema
@@ -1,23 +1,21 @@
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
 
5
- S.enableJson();
6
-
7
- let providerSchema = S.union([
8
- S.literal("Cognito"),
9
- S.literal("InMemory"),
10
- S.schema(s => ({
5
+ let providerSchema = Sury.union([
6
+ Sury.literal("Cognito"),
7
+ Sury.literal("InMemory"),
8
+ Sury.$schema(s => ({
11
9
  TAG: "Custom",
12
- _0: s.m(S.string)
10
+ _0: s.m(Sury.string)
13
11
  }))
14
12
  ]);
15
13
 
16
- let schema = S.schema(s => ({
17
- userId: s.m(S.string),
18
- username: s.m(S.string),
19
- groups: s.m(S.array(S.string)),
20
- claims: s.m(S.option(S.dict(S.string))),
14
+ let schema = Sury.$schema(s => ({
15
+ userId: s.m(Sury.string),
16
+ username: s.m(Sury.string),
17
+ groups: s.m(Sury.array(Sury.string)),
18
+ claims: s.m(Sury.$option(Sury.dict(Sury.string))),
21
19
  provider: s.m(providerSchema)
22
20
  }));
23
21
 
@@ -48,4 +46,4 @@ export {
48
46
  hasGroup,
49
47
  getClaim,
50
48
  }
51
- /* Not a pure module */
49
+ /* providerSchema Not a pure module */
@@ -1,4 +1,3 @@
1
- S.enableJson()
2
1
 
3
2
  /** Identifies the service that produced or is addressed by a message. */
4
3
  @schema
@@ -182,6 +181,25 @@ type commandJson = {
182
181
  let fillMissingDefaults: (S.t<'a>, JSON.t, array<string>) => JSON.t = %raw(`function(schema, json, scalarFills){
183
182
  function isSchema(x){ return x && typeof x === "object" && typeof x.type === "string"; }
184
183
  function firstConst(anyOf){ var m=(anyOf||[]).find(function(s){return s.const!==undefined;}); return m ? m.const : undefined; }
184
+ // Which object-typed member of an anyOf a plain (untagged) object value belongs to.
185
+ // Scored by how many of the value's own keys the member declares, so an untagged
186
+ // either-or codec resolves by shape: an offload field is a sentinel-keyed reference
187
+ // object OR the inline value, and healing an inline payload against the reference
188
+ // member would invent a reference with an empty key that then decodes cleanly —
189
+ // corruption, not an error. Ties keep the earliest member, which is the declared
190
+ // preference order; a value sharing no key with any member is a tie at zero and
191
+ // picks the first, the same guess this made before scoring existed.
192
+ function bestObjectMember(members, value){
193
+ var keys=Object.keys(value), best, bestScore=-1;
194
+ for(var i=0;i<members.length;i++){
195
+ var s=members[i];
196
+ if(s.type!=="object") continue;
197
+ var props=s.properties||{}, score=0;
198
+ for(var k=0;k<keys.length;k++){ if(Object.prototype.hasOwnProperty.call(props,keys[k])) score++; }
199
+ if(score>bestScore){ bestScore=score; best=s; }
200
+ }
201
+ return best;
202
+ }
185
203
  function scalarDefault(schema){
186
204
  if(schema.const!==undefined) return schema.const;
187
205
  switch(schema.type){
@@ -197,8 +215,9 @@ let fillMissingDefaults: (S.t<'a>, JSON.t, array<string>) => JSON.t = %raw(`func
197
215
  case "object": {
198
216
  if(value===undefined){ value={}; }
199
217
  else if(value===null || typeof value!=="object" || Array.isArray(value)) return value;
200
- var items=schema.items||[];
201
- for(var i=0;i<items.length;i++){ var it=items[i]; value[it.location]=fill(it.schema, value[it.location], path+"."+it.location); }
218
+ var props=schema.properties||{};
219
+ var names=Object.keys(props);
220
+ for(var i=0;i<names.length;i++){ var n=names[i]; value[n]=fill(props[n], value[n], path+"."+n); }
202
221
  return value;
203
222
  }
204
223
  case "array": {
@@ -206,7 +225,7 @@ let fillMissingDefaults: (S.t<'a>, JSON.t, array<string>) => JSON.t = %raw(`func
206
225
  if(value===undefined) return [];
207
226
  return value;
208
227
  }
209
- case "union": {
228
+ case "anyOf": {
210
229
  var has=schema.has||{};
211
230
  if(value===undefined){
212
231
  if(has.null) return null;
@@ -218,8 +237,8 @@ let fillMissingDefaults: (S.t<'a>, JSON.t, array<string>) => JSON.t = %raw(`func
218
237
  var members=schema.anyOf||[];
219
238
  if(Array.isArray(value)){ var a=members.find(function(s){return s.type==="array";}); return a ? fill(a,value,path) : value; }
220
239
  if(typeof value==="object"){
221
- var m=members.find(function(s){return s.type==="object" && (s.items||[]).some(function(it){return it.location==="TAG" && it.schema.const===value.TAG;});});
222
- if(!m) m=members.find(function(s){return s.type==="object";});
240
+ var m=members.find(function(s){return s.type==="object" && s.properties && s.properties.TAG && s.properties.TAG.const===value.TAG;});
241
+ if(!m) m=bestObjectMember(members, value);
223
242
  return m ? fill(m,value,path) : value;
224
243
  }
225
244
  return value;
@@ -239,11 +258,11 @@ let fillMissingDefaults: (S.t<'a>, JSON.t, array<string>) => JSON.t = %raw(`func
239
258
 
240
259
  // Strict parse with a single schema-migration-on-read retry (see fillMissingDefaults).
241
260
  let parseJsonTolerant = (json, schema) =>
242
- switch json->S.parseJsonOrThrow(schema) {
261
+ switch json->Util_Sury.fromJson(schema) {
243
262
  | value => value
244
263
  | exception firstErr =>
245
264
  let scalarFills = []
246
- switch fillMissingDefaults(schema, json, scalarFills)->S.parseJsonOrThrow(schema) {
265
+ switch fillMissingDefaults(schema, json, scalarFills)->Util_Sury.fromJson(schema) {
247
266
  | value =>
248
267
  // Only the invented values are worth a line. A heal that used nothing but
249
268
  // schema-derived defaults is the mechanism working as designed.
@@ -285,7 +304,7 @@ Encode a value to JSON using a sury schema.
285
304
  let json = event->Message.encode(Category.eventSchema)
286
305
  ```
287
306
  */
288
- let encode = (value, schema: S.t<'a>) => value->S.reverseConvertToJsonOrThrow(schema)
307
+ let encode = (value, schema: S.t<'a>) => value->Util_Sury.toJson(schema)
289
308
 
290
309
  /** Raised by adapters when an incoming event JSON cannot be matched to a known event variant. */
291
310
  exception InvalidEvent(JSON.t)
@@ -319,7 +338,7 @@ let variantNameOfJson = json =>
319
338
  let composeEventJson' = (id, meta, eventJson) =>
320
339
  [
321
340
  ("id", id->JSON.Encode.string),
322
- ("meta", meta->S.reverseConvertToJsonOrThrow(metaSchema)),
341
+ ("meta", meta->Util_Sury.toJson(metaSchema)),
323
342
  ("event", eventJson),
324
343
  ]
325
344
  ->Dict.fromArray
@@ -1,43 +1,63 @@
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 Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
5
-
6
- S.enableJson();
7
-
8
- let metaSchema = S.schema(s => ({
9
- service: s.m(S.string),
10
- time: s.m(S.string),
11
- ip: s.m(S.option(S.string)),
12
- user: s.m(S.option(S.string)),
13
- msgId: s.m(S.string),
14
- correlationId: s.m(S.string),
15
- causationId: s.m(S.option(S.string)),
16
- traceparent: s.m(S.option(S.string)),
17
- schemaVersion: s.m(S.option(S.string)),
18
- headers: s.m(S.option(S.dict(S.string)))
5
+ import * as Util_Sury$Reventless from "../util/Util_Sury.res.mjs";
6
+
7
+ let serviceSchema = Sury.string;
8
+
9
+ let metaSchema = Sury.$schema(s => ({
10
+ service: s.m(serviceSchema),
11
+ time: s.m(Sury.string),
12
+ ip: s.m(Sury.$option(Sury.string)),
13
+ user: s.m(Sury.$option(Sury.string)),
14
+ msgId: s.m(Sury.string),
15
+ correlationId: s.m(Sury.string),
16
+ causationId: s.m(Sury.$option(Sury.string)),
17
+ traceparent: s.m(Sury.$option(Sury.string)),
18
+ schemaVersion: s.m(Sury.$option(Sury.string)),
19
+ headers: s.m(Sury.$option(Sury.dict(Sury.string)))
19
20
  }));
20
21
 
21
- let contextSchema = S.schema(s => ({
22
- id: s.m(S.string),
22
+ let contextSchema = Sury.$schema(s => ({
23
+ id: s.m(Sury.string),
23
24
  meta: s.m(metaSchema)
24
25
  }));
25
26
 
26
- let statusChangeSchema = S.schema(s => ({
27
- at: s.m(S.string),
28
- by: s.m(S.string)
27
+ let statusChangeSchema = Sury.$schema(s => ({
28
+ at: s.m(Sury.string),
29
+ by: s.m(Sury.string)
29
30
  }));
30
31
 
31
- let commandJsonSchema = S.schema(s => ({
32
- id: s.m(S.string),
32
+ let commandJsonSchema = Sury.$schema(s => ({
33
+ id: s.m(Sury.string),
33
34
  meta: s.m(metaSchema),
34
- commandJson: s.m(S.json),
35
- delay: s.m(S.option(S.int))
35
+ commandJson: s.m(Sury.json),
36
+ delay: s.m(Sury.$option(Sury.int))
36
37
  }));
37
38
 
38
39
  let fillMissingDefaults = (function(schema, json, scalarFills){
39
40
  function isSchema(x){ return x && typeof x === "object" && typeof x.type === "string"; }
40
41
  function firstConst(anyOf){ var m=(anyOf||[]).find(function(s){return s.const!==undefined;}); return m ? m.const : undefined; }
42
+ // Which object-typed member of an anyOf a plain (untagged) object value belongs to.
43
+ // Scored by how many of the value's own keys the member declares, so an untagged
44
+ // either-or codec resolves by shape: an offload field is a sentinel-keyed reference
45
+ // object OR the inline value, and healing an inline payload against the reference
46
+ // member would invent a reference with an empty key that then decodes cleanly —
47
+ // corruption, not an error. Ties keep the earliest member, which is the declared
48
+ // preference order; a value sharing no key with any member is a tie at zero and
49
+ // picks the first, the same guess this made before scoring existed.
50
+ function bestObjectMember(members, value){
51
+ var keys=Object.keys(value), best, bestScore=-1;
52
+ for(var i=0;i<members.length;i++){
53
+ var s=members[i];
54
+ if(s.type!=="object") continue;
55
+ var props=s.properties||{}, score=0;
56
+ for(var k=0;k<keys.length;k++){ if(Object.prototype.hasOwnProperty.call(props,keys[k])) score++; }
57
+ if(score>bestScore){ bestScore=score; best=s; }
58
+ }
59
+ return best;
60
+ }
41
61
  function scalarDefault(schema){
42
62
  if(schema.const!==undefined) return schema.const;
43
63
  switch(schema.type){
@@ -53,8 +73,9 @@ let fillMissingDefaults = (function(schema, json, scalarFills){
53
73
  case "object": {
54
74
  if(value===undefined){ value={}; }
55
75
  else if(value===null || typeof value!=="object" || Array.isArray(value)) return value;
56
- var items=schema.items||[];
57
- for(var i=0;i<items.length;i++){ var it=items[i]; value[it.location]=fill(it.schema, value[it.location], path+"."+it.location); }
76
+ var props=schema.properties||{};
77
+ var names=Object.keys(props);
78
+ for(var i=0;i<names.length;i++){ var n=names[i]; value[n]=fill(props[n], value[n], path+"."+n); }
58
79
  return value;
59
80
  }
60
81
  case "array": {
@@ -62,7 +83,7 @@ let fillMissingDefaults = (function(schema, json, scalarFills){
62
83
  if(value===undefined) return [];
63
84
  return value;
64
85
  }
65
- case "union": {
86
+ case "anyOf": {
66
87
  var has=schema.has||{};
67
88
  if(value===undefined){
68
89
  if(has.null) return null;
@@ -74,8 +95,8 @@ let fillMissingDefaults = (function(schema, json, scalarFills){
74
95
  var members=schema.anyOf||[];
75
96
  if(Array.isArray(value)){ var a=members.find(function(s){return s.type==="array";}); return a ? fill(a,value,path) : value; }
76
97
  if(typeof value==="object"){
77
- var m=members.find(function(s){return s.type==="object" && (s.items||[]).some(function(it){return it.location==="TAG" && it.schema.const===value.TAG;});});
78
- if(!m) m=members.find(function(s){return s.type==="object";});
98
+ var m=members.find(function(s){return s.type==="object" && s.properties && s.properties.TAG && s.properties.TAG.const===value.TAG;});
99
+ if(!m) m=bestObjectMember(members, value);
79
100
  return m ? fill(m,value,path) : value;
80
101
  }
81
102
  return value;
@@ -95,12 +116,12 @@ let fillMissingDefaults = (function(schema, json, scalarFills){
95
116
 
96
117
  function parseJsonTolerant(json, schema) {
97
118
  try {
98
- return S.parseJsonOrThrow(json, schema);
119
+ return Util_Sury$Reventless.fromJson(json, schema);
99
120
  } catch (firstErr) {
100
121
  let scalarFills = [];
101
122
  let value;
102
123
  try {
103
- value = S.parseJsonOrThrow(fillMissingDefaults(schema, json, scalarFills), schema);
124
+ value = Util_Sury$Reventless.fromJson(fillMissingDefaults(schema, json, scalarFills), schema);
104
125
  } catch (exn) {
105
126
  throw firstErr;
106
127
  }
@@ -113,12 +134,12 @@ function parseJsonTolerant(json, schema) {
113
134
 
114
135
  let decode = parseJsonTolerant;
115
136
 
116
- let encode = S.reverseConvertToJsonOrThrow;
137
+ let encode = Util_Sury$Reventless.toJson;
117
138
 
118
139
  let InvalidEvent = /* @__PURE__ */Primitive_exceptions.create("Message-Reventless.InvalidEvent");
119
140
 
120
141
  function toEventSchema$p(idSchema, eventSchema) {
121
- return S.object(s => ({
142
+ return Sury.object(s => ({
122
143
  id: s.f("id", idSchema),
123
144
  meta: s.f("meta", metaSchema),
124
145
  event: s.f("event", eventSchema)
@@ -156,7 +177,7 @@ function composeEventJson$p(id, meta, eventJson) {
156
177
  ],
157
178
  [
158
179
  "meta",
159
- S.reverseConvertToJsonOrThrow(meta, metaSchema)
180
+ Util_Sury$Reventless.toJson(meta, metaSchema)
160
181
  ],
161
182
  [
162
183
  "event",
@@ -165,8 +186,6 @@ function composeEventJson$p(id, meta, eventJson) {
165
186
  ]);
166
187
  }
167
188
 
168
- let serviceSchema = S.string;
169
-
170
189
  export {
171
190
  serviceSchema,
172
191
  metaSchema,
@@ -183,4 +202,4 @@ export {
183
202
  variantNameOfJson,
184
203
  composeEventJson$p,
185
204
  }
186
- /* Not a pure module */
205
+ /* serviceSchema Not a pure module */
@@ -1,11 +1,11 @@
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
 
5
- let schema = S.union([
6
- S.literal("EscalateOnRetry"),
7
- S.literal("AlwaysStrong"),
8
- S.literal("AlwaysEventual")
5
+ let schema = Sury.union([
6
+ Sury.literal("EscalateOnRetry"),
7
+ Sury.literal("AlwaysStrong"),
8
+ Sury.literal("AlwaysEventual")
9
9
  ]);
10
10
 
11
11
  function toString(v) {
@@ -1,61 +1,61 @@
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
 
5
- let rateSchema = S.union([
6
- S.schema(s => ({
5
+ let yearSchema = Sury.int;
6
+
7
+ let monthSchema = Sury.int;
8
+
9
+ let daySchema = Sury.int;
10
+
11
+ let hourSchema = Sury.int;
12
+
13
+ let minuteSchema = Sury.int;
14
+
15
+ let rateSchema = Sury.union([
16
+ Sury.$schema(s => ({
7
17
  TAG: "Single",
8
- _0: s.m(S.int),
9
- _1: s.m(S.int),
10
- _2: s.m(S.int),
11
- _3: s.m(S.int),
12
- _4: s.m(S.int)
18
+ _0: s.m(yearSchema),
19
+ _1: s.m(monthSchema),
20
+ _2: s.m(daySchema),
21
+ _3: s.m(hourSchema),
22
+ _4: s.m(minuteSchema)
13
23
  })),
14
- S.schema(s => ({
24
+ Sury.$schema(s => ({
15
25
  TAG: "Minutes",
16
- _0: s.m(S.int)
26
+ _0: s.m(Sury.int)
17
27
  })),
18
- S.schema(s => ({
28
+ Sury.$schema(s => ({
19
29
  TAG: "Hours",
20
- _0: s.m(S.int)
30
+ _0: s.m(Sury.int)
21
31
  })),
22
- S.schema(s => ({
32
+ Sury.$schema(s => ({
23
33
  TAG: "Days",
24
- _0: s.m(S.int)
34
+ _0: s.m(Sury.int)
25
35
  })),
26
- S.schema(s => ({
36
+ Sury.$schema(s => ({
27
37
  TAG: "Daily",
28
- _0: s.m(S.int),
29
- _1: s.m(S.int)
38
+ _0: s.m(hourSchema),
39
+ _1: s.m(minuteSchema)
30
40
  })),
31
- S.schema(s => ({
41
+ Sury.$schema(s => ({
32
42
  TAG: "Weekdays",
33
- _0: s.m(S.int),
34
- _1: s.m(S.int)
43
+ _0: s.m(hourSchema),
44
+ _1: s.m(minuteSchema)
35
45
  })),
36
- S.schema(s => ({
46
+ Sury.$schema(s => ({
37
47
  TAG: "WeekdaysAndSaturday",
38
- _0: s.m(S.int),
39
- _1: s.m(S.int)
48
+ _0: s.m(hourSchema),
49
+ _1: s.m(minuteSchema)
40
50
  }))
41
51
  ]);
42
52
 
43
- let scheduleSchema = S.schema(s => ({
44
- name: s.m(S.string),
53
+ let scheduleSchema = Sury.$schema(s => ({
54
+ name: s.m(Sury.string),
45
55
  rate: s.m(rateSchema),
46
- payload: s.m(S.string)
56
+ payload: s.m(Sury.string)
47
57
  }));
48
58
 
49
- let yearSchema = S.int;
50
-
51
- let monthSchema = S.int;
52
-
53
- let daySchema = S.int;
54
-
55
- let hourSchema = S.int;
56
-
57
- let minuteSchema = S.int;
58
-
59
59
  export {
60
60
  yearSchema,
61
61
  monthSchema,
@@ -65,4 +65,4 @@ export {
65
65
  rateSchema,
66
66
  scheduleSchema,
67
67
  }
68
- /* rateSchema Not a pure module */
68
+ /* yearSchema Not a pure module */
@@ -39,8 +39,8 @@ let toStoredEventSchema = (idSchema: S.t<'id>): S.t<storedEvent<'id>> =>
39
39
 
40
40
  /** Decode a `storedEvent<'id>` from JSON. */
41
41
  let decode = (json, idSchema) =>
42
- json->S.parseJsonOrThrow(toStoredEventSchema(idSchema))
42
+ json->Util_Sury.fromJson(toStoredEventSchema(idSchema))
43
43
 
44
44
  /** Encode a `storedEvent<'id>` to JSON. */
45
45
  let encode = (stored, idSchema) =>
46
- stored->S.reverseConvertToJsonOrThrow(toStoredEventSchema(idSchema))
46
+ stored->Util_Sury.toJson(toStoredEventSchema(idSchema))