rescript-relay 3.5.0 → 4.0.0

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.
@@ -14,11 +14,11 @@ type updatableFragmentRefs<'fragments>
14
14
 
15
15
  type dataId
16
16
  type dataIdObject = {id: dataId}
17
- type recordSourceRecords = Js.Json.t
17
+ type recordSourceRecords = JSON.t
18
18
  type uploadables
19
19
 
20
20
  module CatchResult = {
21
- type catchError = Js.Json.t
21
+ type catchError = JSON.t
22
22
 
23
23
  @tag("ok")
24
24
  type t<'value> = | @as(true) Ok({value: 'value}) | @as(false) Error({errors: array<catchError>})
@@ -53,8 +53,8 @@ type liveState<'value> = {
53
53
  external dataIdToString: dataId => string = "%identity"
54
54
  external makeDataId: string => dataId = "%identity"
55
55
  external makeArguments: {..} => arguments = "%identity"
56
- external makeUploadables: Js.Dict.t<'file> => uploadables = "%identity"
57
- external unwrapUploadables: uploadables => Js.Dict.t<'file> = "%identity"
56
+ external makeUploadables: dict<'file> => uploadables = "%identity"
57
+ external unwrapUploadables: uploadables => dict<'file> = "%identity"
58
58
 
59
59
  @module("relay-runtime/experimental")
60
60
  external resolverDataInjector: ('a, 'b, 'c, 'd) => 'return = "resolverDataInjector"
@@ -110,14 +110,14 @@ type featureFlags = {
110
110
  external relayFeatureFlags: featureFlags = "RelayFeatureFlags"
111
111
 
112
112
  @module("./utils")
113
- external convertObj: ('a, Js.Dict.t<Js.Dict.t<Js.Dict.t<string>>>, 'b, 'c) => 'd = "traverser"
113
+ external convertObj: ('a, dict<dict<dict<string>>>, 'b, 'c) => 'd = "traverser"
114
114
 
115
- let optArrayOfNullableToOptArrayOfOpt: option<array<Js.Nullable.t<'a>>> => option<
115
+ let optArrayOfNullableToOptArrayOfOpt: option<array<Nullable.t<'a>>> => option<
116
116
  array<option<'a>>,
117
117
  > = x =>
118
118
  switch x {
119
119
  | None => None
120
- | Some(arr) => Some(arr->Belt.Array.map(Js.Nullable.toOption))
120
+ | Some(arr) => Some(arr->Array.map(Nullable.toOption))
121
121
  }
122
122
 
123
123
  @module("relay-runtime") external storeRootId: dataId = "ROOT_ID"
@@ -136,7 +136,7 @@ module RecordProxy = {
136
136
  "getLinkedRecord"
137
137
 
138
138
  @send @return(nullable)
139
- external getLinkedRecords: (t, string, option<arguments>) => option<array<Js.Nullable.t<t>>> =
139
+ external getLinkedRecords: (t, string, option<arguments>) => option<array<Nullable.t<t>>> =
140
140
  "getLinkedRecords"
141
141
 
142
142
  let getLinkedRecords = (t, ~name, ~arguments=?): option<array<option<t>>> =>
@@ -322,10 +322,8 @@ module RecordSourceSelectorProxy = {
322
322
  external getRootField: (t, ~fieldName: string) => option<RecordProxy.t> = "getRootField"
323
323
 
324
324
  @send @return(nullable)
325
- external getPluralRootField: (
326
- t,
327
- ~fieldName: string,
328
- ) => option<array<Js.Nullable.t<RecordProxy.t>>> = "getPluralRootField"
325
+ external getPluralRootField: (t, ~fieldName: string) => option<array<Nullable.t<RecordProxy.t>>> =
326
+ "getPluralRootField"
329
327
 
330
328
  let getPluralRootField = (t, ~fieldName): option<array<option<RecordProxy.t>>> =>
331
329
  getPluralRootField(t, ~fieldName)->optArrayOfNullableToOptArrayOfOpt
@@ -333,8 +331,8 @@ module RecordSourceSelectorProxy = {
333
331
  @send external invalidateStore: t => unit = "invalidateStore"
334
332
 
335
333
  let invalidateRecordsByIds: (t, array<dataId>) => unit = (store, recordIds) => {
336
- recordIds->Js.Array2.forEach(dataId => {
337
- store->get(~dataId)->Belt.Option.forEach(r => r->RecordProxy.invalidateRecord)
334
+ recordIds->Array.forEach(dataId => {
335
+ store->get(~dataId)->Option.forEach(r => r->RecordProxy.invalidateRecord)
338
336
  })
339
337
  }
340
338
  }
@@ -356,20 +354,20 @@ module MissingFieldHandler = {
356
354
 
357
355
  type rec normalizationListValueArgument = {
358
356
  name: string,
359
- items: array<Js.Nullable.t<normalizationArgumentWrapped>>,
357
+ items: array<Nullable.t<normalizationArgumentWrapped>>,
360
358
  }
361
359
  and normalizationLiteralArgument = {
362
360
  name: string,
363
- @as("type") type_: Js.Nullable.t<string>,
364
- value: Js.Json.t,
361
+ @as("type") type_: Nullable.t<string>,
362
+ value: JSON.t,
365
363
  }
366
364
  and normalizationObjectValueArgument = {
367
365
  name: string,
368
- fields: Js.Nullable.t<array<normalizationArgumentWrapped>>,
366
+ fields: Nullable.t<array<normalizationArgumentWrapped>>,
369
367
  }
370
368
  and normalizationVariableArgument = {
371
369
  name: string,
372
- @as("type") type_: Js.Nullable.t<string>,
370
+ @as("type") type_: Nullable.t<string>,
373
371
  variableName: string,
374
372
  }
375
373
 
@@ -388,10 +386,10 @@ module MissingFieldHandler = {
388
386
  }
389
387
 
390
388
  type normalizationScalarField = {
391
- alias: Js.Nullable.t<string>,
389
+ alias: Nullable.t<string>,
392
390
  name: string,
393
- args: Js.Nullable.t<array<normalizationArgumentWrapped>>,
394
- storageKey: Js.Nullable.t<string>,
391
+ args: Nullable.t<array<normalizationArgumentWrapped>>,
392
+ storageKey: Nullable.t<string>,
395
393
  }
396
394
 
397
395
  let makeScalarMissingFieldHandler = handle =>
@@ -401,13 +399,13 @@ module MissingFieldHandler = {
401
399
  })
402
400
 
403
401
  type normalizationLinkedField = {
404
- alias: Js.Nullable.t<string>,
402
+ alias: Nullable.t<string>,
405
403
  name: string,
406
- storageKey: Js.Nullable.t<string>,
407
- args: Js.Nullable.t<array<normalizationArgument>>,
408
- concreteType: Js.Nullable.t<string>,
404
+ storageKey: Nullable.t<string>,
405
+ args: Nullable.t<array<normalizationArgument>>,
406
+ concreteType: Nullable.t<string>,
409
407
  plural: bool,
410
- selections: array<Js.Json.t>,
408
+ selections: array<JSON.t>,
411
409
  }
412
410
 
413
411
  let makeLinkedMissingFieldHandler = handle =>
@@ -430,7 +428,7 @@ let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFiel
430
428
  args,
431
429
  _store,
432
430
  ) =>
433
- switch (Js.Nullable.toOption(record), field["name"], Js.Nullable.toOption(args["id"])) {
431
+ switch (Nullable.toOption(record), field["name"], Nullable.toOption(args["id"])) {
434
432
  | (Some(record), "node", argsId) if record->RecordProxy.getType == storeRootType => argsId
435
433
  | _ => None
436
434
  }
@@ -499,7 +497,7 @@ module Observable = {
499
497
 
500
498
  type sink<'response> = {
501
499
  next: 'response => unit,
502
- error: Js.Exn.t => unit,
500
+ error: JsExn.t => unit,
503
501
  complete: unit => unit,
504
502
  closed: bool,
505
503
  }
@@ -510,7 +508,7 @@ module Observable = {
510
508
  external makeObserver: (
511
509
  ~start: subscription => unit=?,
512
510
  ~next: 'response => unit=?,
513
- ~error: Js.Exn.t => unit=?,
511
+ ~error: JsExn.t => unit=?,
514
512
  ~complete: unit => unit=?,
515
513
  ~unsubscribe: subscription => unit=?,
516
514
  ) => observer<'response> = ""
@@ -521,7 +519,7 @@ module Observable = {
521
519
  @send
522
520
  external subscribe: (t<'response>, observer<'response>) => subscription = "subscribe"
523
521
 
524
- @send external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
522
+ @send external toPromise: t<'t> => promise<'t> = "toPromise"
525
523
 
526
524
  external ignoreSubscription: subscription => unit = "%ignore"
527
525
  }
@@ -534,28 +532,28 @@ module Network = {
534
532
  type operationMetadata = {codesplits?: array<codesplitsMetadata>}
535
533
 
536
534
  type operation = {
537
- id: Js.Nullable.t<string>,
538
- text: Js.Nullable.t<string>,
535
+ id: Nullable.t<string>,
536
+ text: Nullable.t<string>,
539
537
  name: string,
540
538
  operationKind: string,
541
- metadata: Js.Nullable.t<operationMetadata>,
539
+ metadata: Nullable.t<operationMetadata>,
542
540
  }
543
541
 
544
- type subscribeFn = (operation, Js.Json.t, cacheConfig) => Observable.t<Js.Json.t>
542
+ type subscribeFn = (operation, JSON.t, cacheConfig) => Observable.t<JSON.t>
545
543
 
546
544
  type fetchFunctionPromise = (
547
545
  operation,
548
- Js.Json.t,
546
+ JSON.t,
549
547
  cacheConfig,
550
- Js.Nullable.t<uploadables>,
551
- ) => Js.Promise.t<Js.Json.t>
548
+ Nullable.t<uploadables>,
549
+ ) => promise<JSON.t>
552
550
 
553
551
  type fetchFunctionObservable = (
554
552
  operation,
555
- Js.Json.t,
553
+ JSON.t,
556
554
  cacheConfig,
557
- Js.Nullable.t<uploadables>,
558
- ) => Observable.t<Js.Json.t>
555
+ Nullable.t<uploadables>,
556
+ ) => Observable.t<JSON.t>
559
557
 
560
558
  @module("relay-runtime") @scope("Network")
561
559
  external makePromiseBased: (
@@ -571,8 +569,8 @@ module Network = {
571
569
 
572
570
  let preloadResources: (
573
571
  ~operation: operation,
574
- ~variables: Js.Json.t,
575
- ~response: Js.Json.t,
572
+ ~variables: JSON.t,
573
+ ~response: JSON.t,
576
574
  ) => unit = %raw(`
577
575
  function preloadResources(operation, variables, response) {
578
576
  let metadata = operation.metadata;
@@ -709,33 +707,33 @@ module RelayFieldLogger = {
709
707
  MissingRequiredFieldLog({
710
708
  owner: string,
711
709
  fieldPath: string,
712
- uiContext: option<Js.Json.t>,
710
+ uiContext: option<JSON.t>,
713
711
  })
714
712
  | @as("missing_required_field.throw")
715
713
  MissingRequiredFieldThrow({
716
714
  owner: string,
717
715
  fieldPath: string,
718
- uiContext: option<Js.Json.t>,
716
+ uiContext: option<JSON.t>,
719
717
  })
720
718
  | @as("missing_expected_data.log")
721
719
  MissingExpectedData({
722
720
  owner: string,
723
721
  fieldPath: string,
724
- uiContext: option<Js.Json.t>,
722
+ uiContext: option<JSON.t>,
725
723
  })
726
724
  | @as("missing_expected_data.throw")
727
725
  MissingExpectedDataThrow({
728
726
  owner: string,
729
727
  fieldPath: string,
730
728
  handled: bool,
731
- uiContext: option<Js.Json.t>,
729
+ uiContext: option<JSON.t>,
732
730
  })
733
731
  | @as("relay_resolver.error")
734
732
  RelayResolverError({
735
733
  owner: string,
736
734
  fieldPath: string,
737
- error: Js.Exn.t,
738
- uiContext: option<Js.Json.t>,
735
+ error: JsExn.t,
736
+ uiContext: option<JSON.t>,
739
737
  })
740
738
 
741
739
  type t = arg => unit
@@ -772,7 +770,7 @@ module Environment = {
772
770
  ?getDataID,
773
771
  ?treatMissingFieldsAsNull,
774
772
  missingFieldHandlers: switch missingFieldHandlers {
775
- | Some(handlers) => handlers->Belt.Array.concat([nodeInterfaceMissingFieldHandler])
773
+ | Some(handlers) => handlers->Array.concat([nodeInterfaceMissingFieldHandler])
776
774
  | None => [nodeInterfaceMissingFieldHandler]
777
775
  },
778
776
  ?relayFieldLogger,
@@ -788,20 +786,20 @@ module Environment = {
788
786
  external commitLocalUpdate: (t, ~updater: RecordSourceSelectorProxy.t => unit) => unit =
789
787
  "commitLocalUpdate"
790
788
 
791
- @send external mapGet: (Js.Map.t<'key, 'value>, 'key) => option<'value> = "get"
789
+ @send external mapGet: (Map.t<'key, 'value>, 'key) => option<'value> = "get"
792
790
 
793
791
  type recordValue = {__ref: dataId}
794
- @get external _records: RecordSource.t => Js.Map.t<string, Js.Dict.t<recordValue>> = "_records"
792
+ @get external _records: RecordSource.t => Map.t<string, dict<recordValue>> = "_records"
795
793
 
796
794
  let findAllConnectionIds = (environment: t, ~connectionKey: string, ~parentId: dataId) => {
797
795
  let ids = []
798
796
  switch environment->getStore->Store.getSource->_records->mapGet(parentId->dataIdToString) {
799
797
  | Some(value) =>
800
798
  value
801
- ->Js.Dict.entries
802
- ->Js.Array2.forEach(((key, v)) => {
803
- if key->Js.String2.startsWith("__" ++ connectionKey ++ "_connection") {
804
- let _ = ids->Js.Array2.push(v.__ref)
799
+ ->Dict.toArray
800
+ ->Array.forEach(((key, v)) => {
801
+ if key->String.startsWith("__" ++ connectionKey ++ "_connection") {
802
+ let _ = ids->Array.push(v.__ref)
805
803
  }
806
804
  })
807
805
  | _ => ()
@@ -818,11 +816,11 @@ module Environment = {
818
816
  environment->commitLocalUpdate(~updater=store => {
819
817
  environment
820
818
  ->findAllConnectionIds(~connectionKey, ~parentId)
821
- ->Js.Array2.forEach(dataId => {
822
- if !(excludedIds->Js.Array2.includes(dataId)) {
819
+ ->Array.forEach(dataId => {
820
+ if !(excludedIds->Array.includes(dataId)) {
823
821
  store
824
822
  ->RecordSourceSelectorProxy.get(~dataId)
825
- ->Belt.Option.forEach(r => r->RecordProxy.invalidateRecord)
823
+ ->Option.forEach(r => r->RecordProxy.invalidateRecord)
826
824
  }
827
825
  })
828
826
  })
@@ -853,7 +851,7 @@ let useEnvironmentFromContext = () => {
853
851
 
854
852
  switch context {
855
853
  | Some(ctx) => ctx["environment"]
856
- | None => raise(EnvironmentNotFoundInContext)
854
+ | None => throw(EnvironmentNotFoundInContext)
857
855
  }
858
856
  }
859
857
 
@@ -916,16 +914,16 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
916
914
  },
917
915
  )
918
916
 
919
- type rawPreloadToken<'response> = {source: Js.Nullable.t<Observable.t<'response>>}
917
+ type rawPreloadToken<'response> = {source: Nullable.t<Observable.t<'response>>}
920
918
  external tokenToRaw: C.loadedQueryRef => rawPreloadToken<C.response> = "%identity"
921
919
 
922
920
  let queryRefToObservable = token => {
923
921
  let raw = token->tokenToRaw
924
- raw.source->Js.Nullable.toOption
922
+ raw.source->Nullable.toOption
925
923
  }
926
924
 
927
925
  let queryRefToPromise = token => {
928
- Js.Promise.make((~resolve, ~reject as _) => {
926
+ Promise.make((resolve, _) => {
929
927
  switch token->queryRefToObservable {
930
928
  | None => resolve(Error())
931
929
  | Some(o) =>