fragment-dev 1.1.4 → 1.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca9648402c5c64f1f05ad890a4bb80df6f5b320197707d43ed372d7da569c406
4
- data.tar.gz: ab4e1040e6fb8c9696fa8832c531d8e1546097b44125d15cb3bc15decfdd18aa
3
+ metadata.gz: 7792c9e2713834c3670f63d2078e085121279d75e88228dc6d14c0bea9f53326
4
+ data.tar.gz: e163f59d66ea52fb638a2af301c24980e4c9892515e972abdb03b592d8992be4
5
5
  SHA512:
6
- metadata.gz: d15487fd0b5b31e7cd25120f1eb247790fc8160c7ba13a5bc9f44c7e4aa69c9156e6ae5bdfc41c59912eae87120efe34546cc62939e2a279336809d06e6d7bf2
7
- data.tar.gz: 415d1304fb197e2172a0a10349edfdf0f3dcfdb45219a633cb2f0d7eb5da2316f9dce5ac6aecf5ff1fd6f9158386b30c0c1ee6523185c8a2a0f74afa8ccba9e3
6
+ metadata.gz: 7367faa0017b5526f70a29188350f840174429d3498f2207860a3dbf6e9162a5e4e18d322f76f48907fb06e9b62c1764fffe53b960411377ad97d1e706665e5c
7
+ data.tar.gz: b701ae02ced592e2d813d3ab5efd9178003749ebe1136c6d36c8e21e95051ec43640bbf190e96b7b7c3c62a3ac01b6bcfeba9e828ac8bceb6d03678d6b0504a9
@@ -184,20 +184,20 @@
184
184
  {
185
185
  "kind": "ENUM",
186
186
  "name": "BalanceUpdateConsistencyMode",
187
- "description": "Used to configure the write-consistency of a Ledger Account's balance.\nSee [Configure consistency](https://fragment.dev/docs#configure-consistency).",
187
+ "description": "Used to configure the write-consistency of a Ledger Account's balance. See [Configure consistency](https://fragment.dev/docs#configure-consistency).",
188
188
  "fields": null,
189
189
  "inputFields": null,
190
190
  "interfaces": null,
191
191
  "enumValues": [
192
192
  {
193
193
  "name": "eventual",
194
- "description": "Eventually consistent balance updates.",
194
+ "description": null,
195
195
  "isDeprecated": false,
196
196
  "deprecationReason": null
197
197
  },
198
198
  {
199
199
  "name": "strong",
200
- "description": "Strongly consistent balance updates.",
200
+ "description": null,
201
201
  "isDeprecated": false,
202
202
  "deprecationReason": null
203
203
  }
@@ -460,8 +460,8 @@
460
460
  "kind": "NON_NULL",
461
461
  "name": null,
462
462
  "ofType": {
463
- "kind": "INTERFACE",
464
- "name": "Link",
463
+ "kind": "OBJECT",
464
+ "name": "CustomLink",
465
465
  "ofType": null
466
466
  }
467
467
  },
@@ -2727,6 +2727,120 @@
2727
2727
  "enumValues": null,
2728
2728
  "possibleTypes": null
2729
2729
  },
2730
+ {
2731
+ "kind": "UNION",
2732
+ "name": "DeleteLedgerResponse",
2733
+ "description": null,
2734
+ "fields": null,
2735
+ "inputFields": null,
2736
+ "interfaces": null,
2737
+ "enumValues": null,
2738
+ "possibleTypes": [
2739
+ {
2740
+ "kind": "OBJECT",
2741
+ "name": "BadRequestError",
2742
+ "ofType": null
2743
+ },
2744
+ {
2745
+ "kind": "OBJECT",
2746
+ "name": "DeleteLedgerResult",
2747
+ "ofType": null
2748
+ },
2749
+ {
2750
+ "kind": "OBJECT",
2751
+ "name": "InternalError",
2752
+ "ofType": null
2753
+ }
2754
+ ]
2755
+ },
2756
+ {
2757
+ "kind": "OBJECT",
2758
+ "name": "DeleteLedgerResult",
2759
+ "description": null,
2760
+ "fields": [
2761
+ {
2762
+ "name": "success",
2763
+ "description": null,
2764
+ "args": [
2765
+
2766
+ ],
2767
+ "type": {
2768
+ "kind": "NON_NULL",
2769
+ "name": null,
2770
+ "ofType": {
2771
+ "kind": "SCALAR",
2772
+ "name": "Boolean",
2773
+ "ofType": null
2774
+ }
2775
+ },
2776
+ "isDeprecated": false,
2777
+ "deprecationReason": null
2778
+ }
2779
+ ],
2780
+ "inputFields": null,
2781
+ "interfaces": [
2782
+
2783
+ ],
2784
+ "enumValues": null,
2785
+ "possibleTypes": null
2786
+ },
2787
+ {
2788
+ "kind": "UNION",
2789
+ "name": "DeleteSchemaResponse",
2790
+ "description": null,
2791
+ "fields": null,
2792
+ "inputFields": null,
2793
+ "interfaces": null,
2794
+ "enumValues": null,
2795
+ "possibleTypes": [
2796
+ {
2797
+ "kind": "OBJECT",
2798
+ "name": "BadRequestError",
2799
+ "ofType": null
2800
+ },
2801
+ {
2802
+ "kind": "OBJECT",
2803
+ "name": "DeleteSchemaResult",
2804
+ "ofType": null
2805
+ },
2806
+ {
2807
+ "kind": "OBJECT",
2808
+ "name": "InternalError",
2809
+ "ofType": null
2810
+ }
2811
+ ]
2812
+ },
2813
+ {
2814
+ "kind": "OBJECT",
2815
+ "name": "DeleteSchemaResult",
2816
+ "description": null,
2817
+ "fields": [
2818
+ {
2819
+ "name": "success",
2820
+ "description": null,
2821
+ "args": [
2822
+
2823
+ ],
2824
+ "type": {
2825
+ "kind": "NON_NULL",
2826
+ "name": null,
2827
+ "ofType": {
2828
+ "kind": "SCALAR",
2829
+ "name": "Boolean",
2830
+ "ofType": null
2831
+ }
2832
+ },
2833
+ "isDeprecated": false,
2834
+ "deprecationReason": null
2835
+ }
2836
+ ],
2837
+ "inputFields": null,
2838
+ "interfaces": [
2839
+
2840
+ ],
2841
+ "enumValues": null,
2842
+ "possibleTypes": null
2843
+ },
2730
2844
  {
2731
2845
  "kind": "INPUT_OBJECT",
2732
2846
  "name": "EntryGroupMatchInput",
@@ -3140,7 +3254,7 @@
3140
3254
  {
3141
3255
  "kind": "INPUT_OBJECT",
3142
3256
  "name": "ExternalAccountMatchInput",
3143
- "description": "Specify an External Account by using `id`, or `linkId` and `externalId`.",
3257
+ "description": "Specify an External Account by using `id`, or `linkId` and `externalId`.",
3144
3258
  "fields": null,
3145
3259
  "inputFields": [
3146
3260
  {
@@ -5333,7 +5447,7 @@
5333
5447
  "inputFields": [
5334
5448
  {
5335
5449
  "name": "id",
5336
- "description": "The FRAGMENT ID of the ledger account",
5450
+ "description": "The FRAGMENT ID of the Ledger Account",
5337
5451
  "type": {
5338
5452
  "kind": "SCALAR",
5339
5453
  "name": "ID",
@@ -5353,7 +5467,7 @@
5353
5467
  },
5354
5468
  {
5355
5469
  "name": "path",
5356
- "description": "The unique path of the ledger account.\n\nThis is a slash-delimited string containing the keys of an account and all its direct ancestors.",
5470
+ "description": "The unique path of the Ledger Account.\nThis is a slash-delimited string containing the keys of an account and all its direct ancestors.",
5357
5471
  "type": {
5358
5472
  "kind": "SCALAR",
5359
5473
  "name": "String",
@@ -5911,6 +6025,20 @@
5911
6025
  "isDeprecated": false,
5912
6026
  "deprecationReason": null
5913
6027
  },
6028
+ {
6029
+ "name": "parameters",
6030
+ "description": "The parameters used to post this Ledger Entry.",
6031
+ "args": [
6032
+
6033
+ ],
6034
+ "type": {
6035
+ "kind": "SCALAR",
6036
+ "name": "Parameters",
6037
+ "ofType": null
6038
+ },
6039
+ "isDeprecated": false,
6040
+ "deprecationReason": null
6041
+ },
5914
6042
  {
5915
6043
  "name": "posted",
5916
6044
  "description": "ISO-8601 timestamp this LedgerEntry posted to its Ledger.",
@@ -6252,6 +6380,24 @@
6252
6380
  "isDeprecated": false,
6253
6381
  "deprecationReason": null
6254
6382
  },
6383
+ {
6384
+ "name": "dashboardUrl",
6385
+ "description": "URL to the Fragment Dashboard for this Ledger Entry Group.",
6386
+ "args": [
6387
+
6388
+ ],
6389
+ "type": {
6390
+ "kind": "NON_NULL",
6391
+ "name": null,
6392
+ "ofType": {
6393
+ "kind": "SCALAR",
6394
+ "name": "String",
6395
+ "ofType": null
6396
+ }
6397
+ },
6398
+ "isDeprecated": false,
6399
+ "deprecationReason": null
6400
+ },
6255
6401
  {
6256
6402
  "name": "key",
6257
6403
  "description": "The key of this Ledger Entry Group.",
@@ -6270,6 +6416,24 @@
6270
6416
  "isDeprecated": false,
6271
6417
  "deprecationReason": null
6272
6418
  },
6419
+ {
6420
+ "name": "ledger",
6421
+ "description": "The Ledger that this Ledger Entry Group is within.",
6422
+ "args": [
6423
+
6424
+ ],
6425
+ "type": {
6426
+ "kind": "NON_NULL",
6427
+ "name": null,
6428
+ "ofType": {
6429
+ "kind": "OBJECT",
6430
+ "name": "Ledger",
6431
+ "ofType": null
6432
+ }
6433
+ },
6434
+ "isDeprecated": false,
6435
+ "deprecationReason": null
6436
+ },
6273
6437
  {
6274
6438
  "name": "ledgerEntries",
6275
6439
  "description": null,
@@ -6337,6 +6501,24 @@
6337
6501
  "isDeprecated": false,
6338
6502
  "deprecationReason": null
6339
6503
  },
6504
+ {
6505
+ "name": "ledgerId",
6506
+ "description": "The ID of the Ledger this Ledger Entry Group is within.",
6507
+ "args": [
6508
+
6509
+ ],
6510
+ "type": {
6511
+ "kind": "NON_NULL",
6512
+ "name": null,
6513
+ "ofType": {
6514
+ "kind": "SCALAR",
6515
+ "name": "ID",
6516
+ "ofType": null
6517
+ }
6518
+ },
6519
+ "isDeprecated": false,
6520
+ "deprecationReason": null
6521
+ },
6340
6522
  {
6341
6523
  "name": "value",
6342
6524
  "description": "The value associated with Ledger Entry Group.",
@@ -6694,7 +6876,7 @@
6694
6876
  "inputFields": [
6695
6877
  {
6696
6878
  "name": "created",
6697
- "description": "Use to filter ledger groups by their created timestamp",
6879
+ "description": "Use to filter Ledger Entry Groups by their created timestamp",
6698
6880
  "type": {
6699
6881
  "kind": "INPUT_OBJECT",
6700
6882
  "name": "DateTimeFilter",
@@ -6704,7 +6886,17 @@
6704
6886
  },
6705
6887
  {
6706
6888
  "name": "key",
6707
- "description": "Use to filter ledger groups by their type",
6889
+ "description": "Use to filter Ledger Entry Groups by their key",
6890
+ "type": {
6891
+ "kind": "INPUT_OBJECT",
6892
+ "name": "StringFilter",
6893
+ "ofType": null
6894
+ },
6895
+ "defaultValue": null
6896
+ },
6897
+ {
6898
+ "name": "value",
6899
+ "description": "Use to filter Ledger Entry Groups by their value",
6708
6900
  "type": {
6709
6901
  "kind": "INPUT_OBJECT",
6710
6902
  "name": "StringFilter",
@@ -6844,6 +7036,16 @@
6844
7036
  "ofType": null
6845
7037
  },
6846
7038
  "defaultValue": null
7039
+ },
7040
+ {
7041
+ "name": "version",
7042
+ "description": "Experimental: This field is reserved for an upcoming feature and is not yet supported.",
7043
+ "type": {
7044
+ "kind": "SCALAR",
7045
+ "name": "Int",
7046
+ "ofType": null
7047
+ },
7048
+ "defaultValue": null
6847
7049
  }
6848
7050
  ],
6849
7051
  "interfaces": null,
@@ -6868,7 +7070,7 @@
6868
7070
  },
6869
7071
  {
6870
7072
  "name": "ik",
6871
- "description": "The IK provided to the `addLedgerEntry` mutation or the `ik` field\nreturned from a `reconcileTx` mutation. This is required if you have not\nprovided `id`.",
7073
+ "description": "The IK provided to the `addLedgerEntry` mutation or the `ik` field returned from a `reconcileTx` mutation. This is required if you have not provided `id`.",
6872
7074
  "type": {
6873
7075
  "kind": "SCALAR",
6874
7076
  "name": "SafeString",
@@ -6878,7 +7080,7 @@
6878
7080
  },
6879
7081
  {
6880
7082
  "name": "ledger",
6881
- "description": "The FRAGMENT ID of the Ledger to which this Ledger Entry belongs. This\nis required if you have not provided `id`.",
7083
+ "description": "The FRAGMENT ID of the Ledger to which this Ledger Entry belongs. This is required if you have not provided `id`.",
6882
7084
  "type": {
6883
7085
  "kind": "INPUT_OBJECT",
6884
7086
  "name": "LedgerMatchInput",
@@ -7569,9 +7771,19 @@
7569
7771
  "description": null,
7570
7772
  "fields": null,
7571
7773
  "inputFields": [
7774
+ {
7775
+ "name": "created",
7776
+ "description": "Filter by the created timestamp of the Ledger Line. This is the wall-clock time when the Ledger Line was created.",
7777
+ "type": {
7778
+ "kind": "INPUT_OBJECT",
7779
+ "name": "DateTimeFilter",
7780
+ "ofType": null
7781
+ },
7782
+ "defaultValue": null
7783
+ },
7572
7784
  {
7573
7785
  "name": "date",
7574
- "description": null,
7786
+ "description": "Filter by the posted date of the Ledger Line. This is identical to using `posted`, but only supports day-level granularity.",
7575
7787
  "type": {
7576
7788
  "kind": "INPUT_OBJECT",
7577
7789
  "name": "DateFilter",
@@ -7591,7 +7803,7 @@
7591
7803
  },
7592
7804
  {
7593
7805
  "name": "posted",
7594
- "description": null,
7806
+ "description": "Filter by the posted timestamp of the Ledger Line.",
7595
7807
  "type": {
7596
7808
  "kind": "INPUT_OBJECT",
7597
7809
  "name": "DateTimeFilter",
@@ -7622,7 +7834,7 @@
7622
7834
  "inputFields": [
7623
7835
  {
7624
7836
  "name": "id",
7625
- "description": "The FRAGMENT ID of the ledger",
7837
+ "description": "The FRAGMENT ID of the Ledger",
7626
7838
  "type": {
7627
7839
  "kind": "SCALAR",
7628
7840
  "name": "ID",
@@ -7632,7 +7844,7 @@
7632
7844
  },
7633
7845
  {
7634
7846
  "name": "ik",
7635
- "description": "The IK passed into the [createLedger](/api-reference#mutations-createledger) mutation. This is treated as a second unique identifier for this ledger.",
7847
+ "description": "The IK passed into the [createLedger](/api-reference#mutations-createledger) mutation. This is treated as a second unique identifier for this Ledger.",
7636
7848
  "type": {
7637
7849
  "kind": "SCALAR",
7638
7850
  "name": "SafeString",
@@ -8467,6 +8679,68 @@
8467
8679
  "isDeprecated": false,
8468
8680
  "deprecationReason": null
8469
8681
  },
8682
+ {
8683
+ "name": "deleteLedger",
8684
+ "description": "Delete a Ledger",
8685
+ "args": [
8686
+ {
8687
+ "name": "ledger",
8688
+ "description": null,
8689
+ "type": {
8690
+ "kind": "NON_NULL",
8691
+ "name": null,
8692
+ "ofType": {
8693
+ "kind": "INPUT_OBJECT",
8694
+ "name": "LedgerMatchInput",
8695
+ "ofType": null
8696
+ }
8697
+ },
8698
+ "defaultValue": null
8699
+ }
8700
+ ],
8701
+ "type": {
8702
+ "kind": "NON_NULL",
8703
+ "name": null,
8704
+ "ofType": {
8705
+ "kind": "UNION",
8706
+ "name": "DeleteLedgerResponse",
8707
+ "ofType": null
8708
+ }
8709
+ },
8710
+ "isDeprecated": false,
8711
+ "deprecationReason": null
8712
+ },
8713
+ {
8714
+ "name": "deleteSchema",
8715
+ "description": "Delete a Schema",
8716
+ "args": [
8717
+ {
8718
+ "name": "schema",
8719
+ "description": null,
8720
+ "type": {
8721
+ "kind": "NON_NULL",
8722
+ "name": null,
8723
+ "ofType": {
8724
+ "kind": "INPUT_OBJECT",
8725
+ "name": "SchemaMatchInput",
8726
+ "ofType": null
8727
+ }
8728
+ },
8729
+ "defaultValue": null
8730
+ }
8731
+ ],
8732
+ "type": {
8733
+ "kind": "NON_NULL",
8734
+ "name": null,
8735
+ "ofType": {
8736
+ "kind": "UNION",
8737
+ "name": "DeleteSchemaResponse",
8738
+ "ofType": null
8739
+ }
8740
+ },
8741
+ "isDeprecated": false,
8742
+ "deprecationReason": null
8743
+ },
8470
8744
  {
8471
8745
  "name": "reconcileTx",
8472
8746
  "description": "This mutation is used to [reconcile](https://fragment.dev/docs#reconcile-transactions) transactions from an external system into a Ledger Entry. This mutation does not require an idempotency key since a transaction can only be reconciled once per Linked Ledger Account. If you are reconciling a transfer between two Link Accounts which are both linked to the same Ledger, use a transit account in between to split the transfer into two `reconcileTx` calls.",
@@ -8936,6 +9210,16 @@
8936
9210
  "enumValues": null,
8937
9211
  "possibleTypes": null
8938
9212
  },
9213
+ {
9214
+ "kind": "SCALAR",
9215
+ "name": "Parameters",
9216
+ "description": "A mapping of parameter keys to values.",
9217
+ "fields": null,
9218
+ "inputFields": null,
9219
+ "interfaces": null,
9220
+ "enumValues": null,
9221
+ "possibleTypes": null
9222
+ },
8939
9223
  {
8940
9224
  "kind": "SCALAR",
8941
9225
  "name": "Period",
@@ -9436,14 +9720,14 @@
9436
9720
  {
9437
9721
  "kind": "ENUM",
9438
9722
  "name": "ReadBalanceConsistencyMode",
9439
- "description": "The consistency configuration of a Ledger Account's balance queries.\nIf not provided as an argument to a balance query, the default behavior is to read eventually consistent balances.\nSee [Configure consistency](https://fragment.dev/docs#configure-consistency).",
9723
+ "description": "The consistency configuration of a Ledger Account's balance queries. If not provided as an argument to a balance query, the default behavior is to read eventually consistent balances. See [Configure consistency](https://fragment.dev/docs#configure-consistency).",
9440
9724
  "fields": null,
9441
9725
  "inputFields": null,
9442
9726
  "interfaces": null,
9443
9727
  "enumValues": [
9444
9728
  {
9445
9729
  "name": "eventual",
9446
- "description": "Balance queries will read eventually consistent balances. This is the default behavior if `ReadBalanceConsistencyMode` is not provided as an argument to the balance field.\nBoth Ledger Accounts configured with strongly and eventually consistent balance updates support this enum.",
9730
+ "description": "Balance queries will read eventually consistent balances. This is the default behavior if `ReadBalanceConsistencyMode` is not provided as an argument to the balance field. Both Ledger Accounts configured with strongly and eventually consistent balance updates support this enum.",
9447
9731
  "isDeprecated": false,
9448
9732
  "deprecationReason": null
9449
9733
  },
@@ -10603,6 +10887,16 @@
10603
10887
  }
10604
10888
  },
10605
10889
  "defaultValue": null
10890
+ },
10891
+ {
10892
+ "name": "version",
10893
+ "description": "Experimental: This field is not yet supported.",
10894
+ "type": {
10895
+ "kind": "SCALAR",
10896
+ "name": "Int",
10897
+ "ofType": null
10898
+ },
10899
+ "defaultValue": null
10606
10900
  }
10607
10901
  ],
10608
10902
  "interfaces": null,
@@ -10749,7 +11043,7 @@
10749
11043
  },
10750
11044
  {
10751
11045
  "name": "version",
10752
- "description": "Optional parameter to specify version of requested Schema. If not provided, it defaults to 0,\nrepresenting the latest available version for the provided Schema key.",
11046
+ "description": "Optional parameter to specify version of requested Schema. If not provided, it defaults to 0, representing the latest available version for the provided Schema key.",
10753
11047
  "type": {
10754
11048
  "kind": "SCALAR",
10755
11049
  "name": "Int",
@@ -11047,6 +11341,16 @@
11047
11341
  "description": null,
11048
11342
  "fields": null,
11049
11343
  "inputFields": [
11344
+ {
11345
+ "name": "contains",
11346
+ "description": "Must contain the provided pattern somewhere within the string. For example, 'contains: hat' will match 'hat', 'chat', and 'hate'.",
11347
+ "type": {
11348
+ "kind": "SCALAR",
11349
+ "name": "String",
11350
+ "ofType": null
11351
+ },
11352
+ "defaultValue": null
11353
+ },
11050
11354
  {
11051
11355
  "name": "equalTo",
11052
11356
  "description": "Must exactly equal the provided value",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FragmentSDK
4
- VERSION = '1.1.4'
4
+ VERSION = '1.1.6'
5
5
  end
@@ -9,33 +9,23 @@ require 'uri'
9
9
  require 'net/http'
10
10
  require 'fragment_client/version'
11
11
 
12
- module GraphQL
13
- module StaticValidation
14
- class LiteralValidator
15
- alias recursive_validate_old recursively_validate
16
- def recursively_validate(ast_value, type)
17
- res = catch(:invalid) do
18
- recursive_validate_old(ast_value, type)
19
- end
20
- if !res.valid? && type.kind.scalar? && ast_value.is_a?(GraphQL::Language::Nodes::InputObject)
21
- maybe_raise_if_invalid(ast_value) do
22
- ['JSON', 'JSONObject', 'Any'].include?(type.graphql_name) ? @valid_response : @invalid_response
23
- end
24
- else
25
- res
26
- end
27
- end
28
- end
29
- end
30
-
31
- class Client
32
- # A monkey patch to change the definition name
33
- class Definition
34
- alias old_definition_name definition_name
35
- def definition_name
36
- old_definition_name.gsub(/#<Module.*>/, 'FragmentGraphQl__Dynamic')
37
- end
38
- end
12
+ module GraphQL
13
+ module StaticValidation
14
+ class LiteralValidator
15
+ alias recursive_validate_old recursively_validate
16
+ def recursively_validate(ast_value, type)
17
+ res = catch(:invalid) do
18
+ recursive_validate_old(ast_value, type)
19
+ end
20
+ if !res.valid? && type.kind.scalar? && ast_value.is_a?(GraphQL::Language::Nodes::InputObject)
21
+ maybe_raise_if_invalid(ast_value) do
22
+ ['JSON', 'JSONObject', 'Any'].include?(type.graphql_name) ? @valid_response : @invalid_response
23
+ end
24
+ else
25
+ res
26
+ end
27
+ end
28
+ end
39
29
  end
40
30
  end
41
31
 
@@ -57,7 +47,22 @@ module FragmentGraphQl
57
47
 
58
48
  FragmentSchema = T.let(GraphQL::Client.load_schema("#{__dir__}/fragment.schema.json"), T.untyped)
59
49
 
60
- Client = T.let(GraphQL::Client.new(schema: FragmentSchema, execute: HTTP), GraphQL::Client)
50
+ # Create a custom client class for Fragment-specific behavior
51
+ class CustomClient < GraphQL::Client
52
+ class Definition < GraphQL::Client::Definition
53
+ def definition_name
54
+ super.gsub(/#<Module.*>/, 'FragmentGraphQl__Dynamic')
55
+ end
56
+ end
57
+
58
+ # Add this method to allow creating new instances
59
+ def self.new(schema:, execute:)
60
+ super(schema: schema, execute: execute)
61
+ end
62
+ end
63
+
64
+ # Use our custom client instead of the base GraphQL::Client
65
+ Client = T.let(CustomClient.new(schema: FragmentSchema, execute: HTTP), CustomClient)
61
66
 
62
67
  FragmentQueries = T.let(Client.parse(
63
68
  File.read("#{__dir__}/queries.graphql")
@@ -89,7 +94,13 @@ class FragmentClient
89
94
  execute = api_url ? FragmentGraphQl::CustomHTTP.new(URI.parse(api_url).to_s) : FragmentGraphQl::HTTP
90
95
  @execute = T.let(execute, GraphQL::Client::HTTP)
91
96
 
92
- @client = T.let(GraphQL::Client.new(schema: FragmentGraphQl::FragmentSchema, execute: @execute), GraphQL::Client)
97
+ @client = T.let(
98
+ FragmentGraphQl::CustomClient.new(
99
+ schema: FragmentGraphQl::FragmentSchema,
100
+ execute: @execute
101
+ ),
102
+ FragmentGraphQl::CustomClient
103
+ )
93
104
  @token = T.let(create_token, Token)
94
105
 
95
106
  define_method_from_queries(FragmentGraphQl::FragmentQueries)
@@ -103,10 +114,15 @@ class FragmentClient
103
114
  end
104
115
  end
105
116
 
117
+ # Move these error class definitions up, before the query method
118
+ class ResponseError < GraphQL::Client::Error; end
119
+ class NetworkError < GraphQL::Client::Error; end
120
+ class AuthenticationError < StandardError; end
121
+ class TokenExpiredError < StandardError; end
122
+
106
123
  sig { params(query: T.untyped, variables: T.untyped).returns(T.untyped) }
107
124
  def query(query, variables)
108
- expiry_time_skew = 120
109
- @token = create_token if Time.now > @token.expires_at - expiry_time_skew
125
+ refresh_token_if_needed
110
126
  @client.query(query, variables: variables, context: { access_token: @token.token })
111
127
  end
112
128
 
@@ -138,17 +154,65 @@ class FragmentClient
138
154
 
139
155
  case response
140
156
  when Net::HTTPSuccess
141
- # Parse the response body
142
157
  body = JSON.parse(response.body)
143
158
  Token.new(
144
159
  token: T.let(body['access_token'], String),
145
160
  expires_at: Time.now + T.let(body['expires_in'], Integer)
146
161
  )
162
+ when Net::HTTPUnauthorized
163
+ raise AuthenticationError, "Invalid credentials: #{response.body}"
147
164
  else
148
- raise StandardError, format("oauth Authentication failed: '%s'", response.body)
165
+ raise AuthenticationError, "Authentication failed (#{response.code}): #{response.body}"
149
166
  end
167
+ rescue JSON::ParserError => e
168
+ raise AuthenticationError, "Invalid response format: #{e.message}"
150
169
  rescue StandardError => e
151
- raise StandardError, format("oauth Authentication failed: '%s'", e.to_s)
170
+ raise AuthenticationError, "Authentication failed: #{e.message}"
171
+ end
172
+ end
173
+
174
+ class Configuration
175
+ extend T::Sig
176
+
177
+ sig { returns(Integer) }
178
+ attr_accessor :token_expiry_buffer
179
+ sig { returns(Logger) }
180
+ attr_accessor :logger
181
+
182
+ sig { void }
183
+ def initialize
184
+ @token_expiry_buffer = T.let(120, Integer)
185
+ @logger = T.let(Logger.new($stdout), Logger)
186
+ end
187
+ end
188
+
189
+ class << self
190
+ extend T::Sig
191
+
192
+ sig { returns(Configuration) }
193
+ def configuration
194
+ @configuration ||= Configuration.new
152
195
  end
196
+
197
+ sig { params(blk: T.proc.params(config: Configuration).void).void }
198
+ def configure(&blk)
199
+ yield(configuration)
200
+ end
201
+ end
202
+
203
+ sig { returns(Logger) }
204
+ def logger
205
+ self.class.configuration.logger
206
+ end
207
+
208
+ sig { void }
209
+ def refresh_token_if_needed
210
+ return unless token_expired?
211
+ @token = create_token
212
+ end
213
+
214
+ sig { returns(T::Boolean) }
215
+ def token_expired?
216
+ Time.now > @token.expires_at - self.class.configuration.token_expiry_buffer
153
217
  end
154
218
  end
data/lib/queries.graphql CHANGED
@@ -14,6 +14,7 @@ mutation StoreSchema($schema: SchemaInput!) {
14
14
  ... on Error {
15
15
  code
16
16
  message
17
+ retryable
17
18
  }
18
19
  }
19
20
  }
@@ -40,6 +41,7 @@ mutation CreateLedger(
40
41
  ... on Error {
41
42
  code
42
43
  message
44
+ retryable
43
45
  }
44
46
  }
45
47
  }
@@ -85,6 +87,7 @@ mutation AddLedgerEntry(
85
87
  ... on Error {
86
88
  code
87
89
  message
90
+ retryable
88
91
  }
89
92
  }
90
93
  }
@@ -130,6 +133,7 @@ mutation AddLedgerEntryRuntime(
130
133
  ... on Error {
131
134
  code
132
135
  message
136
+ retryable
133
137
  }
134
138
  }
135
139
  }
@@ -172,6 +176,7 @@ mutation ReconcileTx(
172
176
  ... on Error {
173
177
  code
174
178
  message
179
+ retryable
175
180
  }
176
181
  }
177
182
  }
@@ -214,6 +219,7 @@ mutation ReconcileTxRuntime(
214
219
  ... on Error {
215
220
  code
216
221
  message
222
+ retryable
217
223
  }
218
224
  }
219
225
  }
@@ -274,6 +280,7 @@ mutation UpdateLedger($ledgerIk: SafeString!, $update: UpdateLedgerInput!) {
274
280
  ... on Error {
275
281
  code
276
282
  message
283
+ retryable
277
284
  }
278
285
  }
279
286
  }
@@ -291,6 +298,7 @@ mutation CreateCustomLink($name: String!, $ik: SafeString!) {
291
298
  ... on Error {
292
299
  code
293
300
  message
301
+ retryable
294
302
  }
295
303
  }
296
304
  }
@@ -312,6 +320,7 @@ mutation SyncCustomAccounts($linkId: ID!, $accounts: [CustomAccountInput!]!) {
312
320
  ... on Error {
313
321
  code
314
322
  message
323
+ retryable
315
324
  }
316
325
  }
317
326
  }
@@ -334,6 +343,7 @@ mutation SyncCustomTxs($linkId: ID!, $txs: [CustomTxInput!]!) {
334
343
  ... on Error {
335
344
  code
336
345
  message
346
+ retryable
337
347
  }
338
348
  }
339
349
  }
@@ -543,52 +553,6 @@ query GetLedgerAccountBalance(
543
553
  }
544
554
  }
545
555
 
546
- query ListLedgerEntryGroupBalances(
547
- $ledgerIk: SafeString!
548
- $groupKey: SafeString!
549
- $groupValue: SafeString!
550
- $consistencyMode: ReadBalanceConsistencyMode = use_account
551
- $after: String
552
- $before: String
553
- $first: Int
554
- $last: Int
555
- $filter: LedgerEntryGroupBalanceFilterSet
556
- ) {
557
- ledgerEntryGroup(ledgerEntryGroup: {
558
- ledger: { ik: $ledgerIk },
559
- key: $groupKey,
560
- value: $groupValue,
561
- }) {
562
- key
563
- value
564
- created
565
- balances(
566
- after: $after,
567
- before: $before,
568
- first: $first,
569
- last: $last,
570
- filter: $filter,
571
- ){
572
- nodes {
573
- account {
574
- path
575
- }
576
- currency {
577
- code
578
- customCurrencyId
579
- }
580
- ownBalance(consistencyMode: $consistencyMode)
581
- }
582
- pageInfo {
583
- hasNextPage
584
- endCursor
585
- hasPreviousPage
586
- startCursor
587
- }
588
- }
589
- }
590
- }
591
-
592
556
  query GetSchema($key: SafeString!, $version: Int) {
593
557
  schema(schema: { key: $key, version: $version }) {
594
558
  key
@@ -644,3 +608,49 @@ query GetWorkspace {
644
608
  name
645
609
  }
646
610
  }
611
+
612
+ query ListLedgerEntryGroupBalances(
613
+ $ledgerIk: SafeString!
614
+ $groupKey: SafeString!
615
+ $groupValue: SafeString!
616
+ $consistencyMode: ReadBalanceConsistencyMode = use_account
617
+ $after: String
618
+ $before: String
619
+ $first: Int
620
+ $last: Int
621
+ $filter: LedgerEntryGroupBalanceFilterSet
622
+ ) {
623
+ ledgerEntryGroup(ledgerEntryGroup: {
624
+ ledger: { ik: $ledgerIk },
625
+ key: $groupKey,
626
+ value: $groupValue,
627
+ }) {
628
+ key
629
+ value
630
+ created
631
+ balances(
632
+ after: $after,
633
+ before: $before,
634
+ first: $first,
635
+ last: $last,
636
+ filter: $filter,
637
+ ){
638
+ nodes {
639
+ account {
640
+ path
641
+ }
642
+ currency {
643
+ code
644
+ customCurrencyId
645
+ }
646
+ ownBalance(consistencyMode: $consistencyMode)
647
+ }
648
+ pageInfo {
649
+ hasNextPage
650
+ endCursor
651
+ hasPreviousPage
652
+ startCursor
653
+ }
654
+ }
655
+ }
656
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fragment-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - fragment
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-09 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.20'
39
+ version: 0.23.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.20'
46
+ version: 0.23.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sorbet-runtime
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.5.11
91
+ rubygems_version: 3.5.9
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: the ruby fragment client sdk