fragment-dev 1.1.9 → 1.1.10
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 +4 -4
- data/lib/fragment.schema.json +254 -0
- data/lib/fragment_client/version.rb +1 -1
- data/lib/fragment_client.rb +51 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 256c215954c1a9b706b9049c509e705c7cfc3c23ff2fd966f11dc9d907f3ffd6
|
4
|
+
data.tar.gz: 1d683c02a514f5ef6b60f3335f8a85ab2a8a7d916b17fb3c50b94d736b7ede55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edf339f6f8b090f218f4089bb2403b336e0e96d34f27d992c5c2b65a2b85c68496d04310a88c8c727acc86b5e5d45b6ccbc89b74779ddb1a81f98538e3100b16
|
7
|
+
data.tar.gz: 4589ff091c826cfeefbcb222f65095ca4e96733bec165c3dde1af4c716f7753c671d30dac8e5d5f55f062b0962262272b9b16aa506f90d9b80d935072df19128
|
data/lib/fragment.schema.json
CHANGED
@@ -3565,6 +3565,74 @@
|
|
3565
3565
|
"enumValues": null,
|
3566
3566
|
"possibleTypes": null
|
3567
3567
|
},
|
3568
|
+
{
|
3569
|
+
"kind": "INPUT_OBJECT",
|
3570
|
+
"name": "GroupFilter",
|
3571
|
+
"description": "Filter for finding entries by group membership",
|
3572
|
+
"fields": null,
|
3573
|
+
"inputFields": [
|
3574
|
+
{
|
3575
|
+
"name": "keyIn",
|
3576
|
+
"description": "Find entries that are members of a group with all of these group keys",
|
3577
|
+
"type": {
|
3578
|
+
"kind": "LIST",
|
3579
|
+
"name": null,
|
3580
|
+
"ofType": {
|
3581
|
+
"kind": "NON_NULL",
|
3582
|
+
"name": null,
|
3583
|
+
"ofType": {
|
3584
|
+
"kind": "SCALAR",
|
3585
|
+
"name": "SafeString",
|
3586
|
+
"ofType": null
|
3587
|
+
}
|
3588
|
+
}
|
3589
|
+
},
|
3590
|
+
"defaultValue": null
|
3591
|
+
},
|
3592
|
+
{
|
3593
|
+
"name": "not",
|
3594
|
+
"description": "Find entries that do not match this predicate",
|
3595
|
+
"type": {
|
3596
|
+
"kind": "INPUT_OBJECT",
|
3597
|
+
"name": "GroupNotFilter",
|
3598
|
+
"ofType": null
|
3599
|
+
},
|
3600
|
+
"defaultValue": null
|
3601
|
+
}
|
3602
|
+
],
|
3603
|
+
"interfaces": null,
|
3604
|
+
"enumValues": null,
|
3605
|
+
"possibleTypes": null
|
3606
|
+
},
|
3607
|
+
{
|
3608
|
+
"kind": "INPUT_OBJECT",
|
3609
|
+
"name": "GroupNotFilter",
|
3610
|
+
"description": "Filter for finding entries that do not match this predicate",
|
3611
|
+
"fields": null,
|
3612
|
+
"inputFields": [
|
3613
|
+
{
|
3614
|
+
"name": "keyIn",
|
3615
|
+
"description": "Find entries that are not members of all of these groups. This is an AND filter.",
|
3616
|
+
"type": {
|
3617
|
+
"kind": "LIST",
|
3618
|
+
"name": null,
|
3619
|
+
"ofType": {
|
3620
|
+
"kind": "NON_NULL",
|
3621
|
+
"name": null,
|
3622
|
+
"ofType": {
|
3623
|
+
"kind": "SCALAR",
|
3624
|
+
"name": "SafeString",
|
3625
|
+
"ofType": null
|
3626
|
+
}
|
3627
|
+
}
|
3628
|
+
},
|
3629
|
+
"defaultValue": null
|
3630
|
+
}
|
3631
|
+
],
|
3632
|
+
"interfaces": null,
|
3633
|
+
"enumValues": null,
|
3634
|
+
"possibleTypes": null
|
3635
|
+
},
|
3568
3636
|
{
|
3569
3637
|
"kind": "OBJECT",
|
3570
3638
|
"name": "HistoricalBalance",
|
@@ -6353,6 +6421,16 @@
|
|
6353
6421
|
},
|
6354
6422
|
"defaultValue": null
|
6355
6423
|
},
|
6424
|
+
{
|
6425
|
+
"name": "group",
|
6426
|
+
"description": "Use this to filter Ledger Entries by groups. The response will include entries that contain or do not contain specific groups.",
|
6427
|
+
"type": {
|
6428
|
+
"kind": "INPUT_OBJECT",
|
6429
|
+
"name": "GroupFilter",
|
6430
|
+
"ofType": null
|
6431
|
+
},
|
6432
|
+
"defaultValue": null
|
6433
|
+
},
|
6356
6434
|
{
|
6357
6435
|
"name": "ledgerEntry",
|
6358
6436
|
"description": "Use to filter Ledger Entries by their IDs or IKs.",
|
@@ -6543,6 +6621,54 @@
|
|
6543
6621
|
"isDeprecated": false,
|
6544
6622
|
"deprecationReason": null
|
6545
6623
|
},
|
6624
|
+
{
|
6625
|
+
"name": "isReversal",
|
6626
|
+
"description": "Indicates whether this Ledger Entry is a reversal of another Ledger Entry.\nIf so, reverses will point to that Ledger Entry.",
|
6627
|
+
"args": [],
|
6628
|
+
"type": {
|
6629
|
+
"kind": "NON_NULL",
|
6630
|
+
"name": null,
|
6631
|
+
"ofType": {
|
6632
|
+
"kind": "SCALAR",
|
6633
|
+
"name": "Boolean",
|
6634
|
+
"ofType": null
|
6635
|
+
}
|
6636
|
+
},
|
6637
|
+
"isDeprecated": false,
|
6638
|
+
"deprecationReason": null
|
6639
|
+
},
|
6640
|
+
{
|
6641
|
+
"name": "isReversed",
|
6642
|
+
"description": "Indicates whether this Ledger Entry has been reversed by another Ledger Entry.\nIf so, reversedBy will point to that Ledger Entry.",
|
6643
|
+
"args": [],
|
6644
|
+
"type": {
|
6645
|
+
"kind": "NON_NULL",
|
6646
|
+
"name": null,
|
6647
|
+
"ofType": {
|
6648
|
+
"kind": "SCALAR",
|
6649
|
+
"name": "Boolean",
|
6650
|
+
"ofType": null
|
6651
|
+
}
|
6652
|
+
},
|
6653
|
+
"isDeprecated": false,
|
6654
|
+
"deprecationReason": null
|
6655
|
+
},
|
6656
|
+
{
|
6657
|
+
"name": "isSuppressed",
|
6658
|
+
"description": "Indicates whether this Ledger Entry is suppressed when listing Ledger Entries.\nReversed and Reversal Ledger Entries are suppressed by default because taken together they have no impact on a Ledger's balances.",
|
6659
|
+
"args": [],
|
6660
|
+
"type": {
|
6661
|
+
"kind": "NON_NULL",
|
6662
|
+
"name": null,
|
6663
|
+
"ofType": {
|
6664
|
+
"kind": "SCALAR",
|
6665
|
+
"name": "Boolean",
|
6666
|
+
"ofType": null
|
6667
|
+
}
|
6668
|
+
},
|
6669
|
+
"isDeprecated": false,
|
6670
|
+
"deprecationReason": null
|
6671
|
+
},
|
6546
6672
|
{
|
6547
6673
|
"name": "ledger",
|
6548
6674
|
"description": "The Ledger that this Ledger Entry is posted to.",
|
@@ -6619,6 +6745,62 @@
|
|
6619
6745
|
"isDeprecated": false,
|
6620
6746
|
"deprecationReason": null
|
6621
6747
|
},
|
6748
|
+
{
|
6749
|
+
"name": "reversalHistory",
|
6750
|
+
"description": "The reversal history of this Ledger Entry. Each entry in this connection shares the same IK.",
|
6751
|
+
"args": [],
|
6752
|
+
"type": {
|
6753
|
+
"kind": "NON_NULL",
|
6754
|
+
"name": null,
|
6755
|
+
"ofType": {
|
6756
|
+
"kind": "OBJECT",
|
6757
|
+
"name": "LedgerEntriesConnection",
|
6758
|
+
"ofType": null
|
6759
|
+
}
|
6760
|
+
},
|
6761
|
+
"isDeprecated": false,
|
6762
|
+
"deprecationReason": null
|
6763
|
+
},
|
6764
|
+
{
|
6765
|
+
"name": "reversalPosition",
|
6766
|
+
"description": "The position of this Ledger Entry in its reversalHistory. This is a one-indexed value, so the initial entry will have reversalPosition 1.",
|
6767
|
+
"args": [],
|
6768
|
+
"type": {
|
6769
|
+
"kind": "NON_NULL",
|
6770
|
+
"name": null,
|
6771
|
+
"ofType": {
|
6772
|
+
"kind": "SCALAR",
|
6773
|
+
"name": "Int",
|
6774
|
+
"ofType": null
|
6775
|
+
}
|
6776
|
+
},
|
6777
|
+
"isDeprecated": false,
|
6778
|
+
"deprecationReason": null
|
6779
|
+
},
|
6780
|
+
{
|
6781
|
+
"name": "reversedBy",
|
6782
|
+
"description": "The Ledger Entry that reversed this Ledger Entry.",
|
6783
|
+
"args": [],
|
6784
|
+
"type": {
|
6785
|
+
"kind": "OBJECT",
|
6786
|
+
"name": "LedgerEntry",
|
6787
|
+
"ofType": null
|
6788
|
+
},
|
6789
|
+
"isDeprecated": false,
|
6790
|
+
"deprecationReason": null
|
6791
|
+
},
|
6792
|
+
{
|
6793
|
+
"name": "reverses",
|
6794
|
+
"description": "The Ledger Entry that was reversed by this Ledger Entry.",
|
6795
|
+
"args": [],
|
6796
|
+
"type": {
|
6797
|
+
"kind": "OBJECT",
|
6798
|
+
"name": "LedgerEntry",
|
6799
|
+
"ofType": null
|
6800
|
+
},
|
6801
|
+
"isDeprecated": false,
|
6802
|
+
"deprecationReason": null
|
6803
|
+
},
|
6622
6804
|
{
|
6623
6805
|
"name": "tags",
|
6624
6806
|
"description": "The set of tags attached to this Ledger Entry.",
|
@@ -7851,6 +8033,54 @@
|
|
7851
8033
|
"isDeprecated": false,
|
7852
8034
|
"deprecationReason": null
|
7853
8035
|
},
|
8036
|
+
{
|
8037
|
+
"name": "isReversal",
|
8038
|
+
"description": "Indicates whether this Ledger Line is a reversal of another Ledger Line.\nIf so, reverses will point to that Ledger Line.",
|
8039
|
+
"args": [],
|
8040
|
+
"type": {
|
8041
|
+
"kind": "NON_NULL",
|
8042
|
+
"name": null,
|
8043
|
+
"ofType": {
|
8044
|
+
"kind": "SCALAR",
|
8045
|
+
"name": "Boolean",
|
8046
|
+
"ofType": null
|
8047
|
+
}
|
8048
|
+
},
|
8049
|
+
"isDeprecated": false,
|
8050
|
+
"deprecationReason": null
|
8051
|
+
},
|
8052
|
+
{
|
8053
|
+
"name": "isReversed",
|
8054
|
+
"description": "Indicates whether this Ledger Line has been reversed by another Ledger Line.\nIf so, reversedBy will point to that Ledger Line.",
|
8055
|
+
"args": [],
|
8056
|
+
"type": {
|
8057
|
+
"kind": "NON_NULL",
|
8058
|
+
"name": null,
|
8059
|
+
"ofType": {
|
8060
|
+
"kind": "SCALAR",
|
8061
|
+
"name": "Boolean",
|
8062
|
+
"ofType": null
|
8063
|
+
}
|
8064
|
+
},
|
8065
|
+
"isDeprecated": false,
|
8066
|
+
"deprecationReason": null
|
8067
|
+
},
|
8068
|
+
{
|
8069
|
+
"name": "isSuppressed",
|
8070
|
+
"description": "Indicates whether this Ledger Line is suppressed when listing Ledger Lines.\nReversed and Reversal Ledger Lines are suppressed by default because taken together they have no impact on a Ledger Account's balance",
|
8071
|
+
"args": [],
|
8072
|
+
"type": {
|
8073
|
+
"kind": "NON_NULL",
|
8074
|
+
"name": null,
|
8075
|
+
"ofType": {
|
8076
|
+
"kind": "SCALAR",
|
8077
|
+
"name": "Boolean",
|
8078
|
+
"ofType": null
|
8079
|
+
}
|
8080
|
+
},
|
8081
|
+
"isDeprecated": false,
|
8082
|
+
"deprecationReason": null
|
8083
|
+
},
|
7854
8084
|
{
|
7855
8085
|
"name": "key",
|
7856
8086
|
"description": null,
|
@@ -7987,6 +8217,30 @@
|
|
7987
8217
|
"isDeprecated": false,
|
7988
8218
|
"deprecationReason": null
|
7989
8219
|
},
|
8220
|
+
{
|
8221
|
+
"name": "reversedBy",
|
8222
|
+
"description": "The Ledger Line that reverses the balance changes of this Ledger Line.",
|
8223
|
+
"args": [],
|
8224
|
+
"type": {
|
8225
|
+
"kind": "OBJECT",
|
8226
|
+
"name": "LedgerLine",
|
8227
|
+
"ofType": null
|
8228
|
+
},
|
8229
|
+
"isDeprecated": false,
|
8230
|
+
"deprecationReason": null
|
8231
|
+
},
|
8232
|
+
{
|
8233
|
+
"name": "reverses",
|
8234
|
+
"description": "The Ledger Line whose balance changes are reversed by this Ledger Line.",
|
8235
|
+
"args": [],
|
8236
|
+
"type": {
|
8237
|
+
"kind": "OBJECT",
|
8238
|
+
"name": "LedgerLine",
|
8239
|
+
"ofType": null
|
8240
|
+
},
|
8241
|
+
"isDeprecated": false,
|
8242
|
+
"deprecationReason": null
|
8243
|
+
},
|
7990
8244
|
{
|
7991
8245
|
"name": "tx",
|
7992
8246
|
"description": "The transaction linked to this LedgerLine",
|
data/lib/fragment_client.rb
CHANGED
@@ -8,24 +8,23 @@ require 'sorbet-runtime'
|
|
8
8
|
require 'uri'
|
9
9
|
require 'net/http'
|
10
10
|
require 'fragment_client/version'
|
11
|
-
|
12
|
-
module
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
11
|
+
module GraphQL
|
12
|
+
module StaticValidation
|
13
|
+
class LiteralValidator
|
14
|
+
alias recursive_validate_old recursively_validate
|
15
|
+
def recursively_validate(ast_value, type)
|
16
|
+
res = catch(:invalid) do
|
17
|
+
recursive_validate_old(ast_value, type)
|
18
|
+
end
|
19
|
+
if !res.valid? && type.kind.scalar? && ast_value.is_a?(GraphQL::Language::Nodes::InputObject)
|
20
|
+
maybe_raise_if_invalid(ast_value) do
|
21
|
+
%w[JSON JSONObject Any].include?(type.graphql_name) ? @valid_response : @invalid_response
|
22
|
+
end
|
23
|
+
else
|
24
|
+
res
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -64,9 +63,12 @@ module FragmentGraphQl
|
|
64
63
|
# Use our custom client instead of the base GraphQL::Client
|
65
64
|
Client = T.let(CustomClient.new(schema: FragmentSchema, execute: HTTP), CustomClient)
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def self.parse_queries(filename)
|
67
|
+
file_text = File.read(filename)
|
68
|
+
Client.parse(file_text)
|
69
|
+
end
|
70
|
+
|
71
|
+
FragmentQueries = T.let(parse_queries("#{__dir__}/queries.graphql"), T.untyped)
|
70
72
|
end
|
71
73
|
|
72
74
|
# A client for Fragment
|
@@ -96,9 +98,9 @@ class FragmentClient
|
|
96
98
|
|
97
99
|
@client = T.let(
|
98
100
|
FragmentGraphQl::CustomClient.new(
|
99
|
-
schema: FragmentGraphQl::FragmentSchema,
|
101
|
+
schema: FragmentGraphQl::FragmentSchema,
|
100
102
|
execute: @execute
|
101
|
-
),
|
103
|
+
),
|
102
104
|
FragmentGraphQl::CustomClient
|
103
105
|
)
|
104
106
|
@token = T.let(create_token, Token)
|
@@ -107,9 +109,7 @@ class FragmentClient
|
|
107
109
|
return if extra_queries_filenames.nil?
|
108
110
|
|
109
111
|
extra_queries_filenames.each do |filename|
|
110
|
-
queries =
|
111
|
-
File.read(filename)
|
112
|
-
)
|
112
|
+
queries = T.let(FragmentGraphQl.parse_queries(filename), T.untyped)
|
113
113
|
define_method_from_queries(queries)
|
114
114
|
end
|
115
115
|
end
|
@@ -133,8 +133,30 @@ class FragmentClient
|
|
133
133
|
name = qry.to_s.gsub(/[a-z]([A-Z])/) do |m|
|
134
134
|
format('%<lower>s_%<upper>s', lower: m[0], upper: m[1].downcase)
|
135
135
|
end.gsub(/^[A-Z]/, &:downcase)
|
136
|
+
|
137
|
+
# Get the original query
|
138
|
+
original_query = queries.const_get(qry)
|
139
|
+
|
140
|
+
# Create a monkey-patched version of the definition_node for this specific instance
|
141
|
+
# This avoids changing the class type while still modifying the behavior
|
142
|
+
if original_query.respond_to?(:definition_node)
|
143
|
+
definition_node = original_query.definition_node
|
144
|
+
|
145
|
+
# Only patch once to avoid infinite recursion
|
146
|
+
unless definition_node.singleton_class.method_defined?(:original_name)
|
147
|
+
# Store the original method
|
148
|
+
definition_node.singleton_class.send(:alias_method, :original_name, :name)
|
149
|
+
|
150
|
+
# Define the new method that uses the stored original method
|
151
|
+
definition_node.singleton_class.send(:define_method, :name) do
|
152
|
+
original_name.gsub(/#<Module.*?>/, 'FragmentGraphQl__Dynamic__Custom')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Define the method with the original query (which now has patched behavior)
|
136
158
|
define_singleton_method(name) do |v|
|
137
|
-
query(
|
159
|
+
query(original_query, v)
|
138
160
|
end
|
139
161
|
end
|
140
162
|
end
|
@@ -176,6 +198,7 @@ class FragmentClient
|
|
176
198
|
|
177
199
|
sig { returns(Integer) }
|
178
200
|
attr_accessor :token_expiry_buffer
|
201
|
+
|
179
202
|
sig { returns(Logger) }
|
180
203
|
attr_accessor :logger
|
181
204
|
|
@@ -208,6 +231,7 @@ class FragmentClient
|
|
208
231
|
sig { void }
|
209
232
|
def refresh_token_if_needed
|
210
233
|
return unless token_expired?
|
234
|
+
|
211
235
|
@token = create_token
|
212
236
|
end
|
213
237
|
|