@subsquid/openreader 2.0.0 → 3.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.
- package/lib/context.d.ts +5 -2
- package/lib/context.d.ts.map +1 -1
- package/lib/ir/args.d.ts +1 -1
- package/lib/ir/args.d.ts.map +1 -1
- package/lib/ir/connection.d.ts +3 -4
- package/lib/ir/connection.d.ts.map +1 -1
- package/lib/ir/connection.js.map +1 -1
- package/lib/ir/fields.d.ts +6 -2
- package/lib/ir/fields.d.ts.map +1 -1
- package/lib/ir/fields.js +15 -0
- package/lib/ir/fields.js.map +1 -1
- package/lib/limit.size.d.ts +7 -2
- package/lib/limit.size.d.ts.map +1 -1
- package/lib/limit.size.js +106 -12
- package/lib/limit.size.js.map +1 -1
- package/lib/main.js +6 -9
- package/lib/main.js.map +1 -1
- package/lib/model.d.ts +3 -1
- package/lib/model.d.ts.map +1 -1
- package/lib/model.schema.d.ts +2 -2
- package/lib/model.schema.d.ts.map +1 -1
- package/lib/model.schema.js +29 -7
- package/lib/model.schema.js.map +1 -1
- package/lib/model.tools.d.ts +6 -1
- package/lib/model.tools.d.ts.map +1 -1
- package/lib/model.tools.js +111 -8
- package/lib/model.tools.js.map +1 -1
- package/lib/opencrud/orderBy.d.ts +2 -2
- package/lib/opencrud/orderBy.d.ts.map +1 -1
- package/lib/opencrud/orderBy.js +13 -17
- package/lib/opencrud/orderBy.js.map +1 -1
- package/lib/opencrud/schema.d.ts +4 -4
- package/lib/opencrud/schema.d.ts.map +1 -1
- package/lib/opencrud/schema.js +60 -64
- package/lib/opencrud/schema.js.map +1 -1
- package/lib/opencrud/tree.d.ts +9 -7
- package/lib/opencrud/tree.d.ts.map +1 -1
- package/lib/opencrud/tree.js +32 -14
- package/lib/opencrud/tree.js.map +1 -1
- package/lib/server.d.ts +16 -12
- package/lib/server.d.ts.map +1 -1
- package/lib/server.js +29 -4
- package/lib/server.js.map +1 -1
- package/lib/sql/cursor.js +2 -2
- package/lib/sql/cursor.js.map +1 -1
- package/lib/sql/mapping.d.ts +3 -1
- package/lib/sql/mapping.d.ts.map +1 -1
- package/lib/sql/mapping.js +16 -1
- package/lib/sql/mapping.js.map +1 -1
- package/lib/sql/printer.d.ts +29 -11
- package/lib/sql/printer.d.ts.map +1 -1
- package/lib/sql/printer.js +106 -10
- package/lib/sql/printer.js.map +1 -1
- package/lib/sql/query.d.ts +11 -11
- package/lib/sql/query.d.ts.map +1 -1
- package/lib/sql/query.js +41 -19
- package/lib/sql/query.js.map +1 -1
- package/lib/test/limits.test.d.ts +2 -0
- package/lib/test/limits.test.d.ts.map +1 -0
- package/lib/test/limits.test.js +159 -0
- package/lib/test/limits.test.js.map +1 -0
- package/lib/test/queryable.test.d.ts +2 -0
- package/lib/test/queryable.test.d.ts.map +1 -0
- package/lib/test/queryable.test.js +255 -0
- package/lib/test/queryable.test.js.map +1 -0
- package/lib/test/setup.d.ts +2 -1
- package/lib/test/setup.d.ts.map +1 -1
- package/lib/test/setup.js +5 -2
- package/lib/test/setup.js.map +1 -1
- package/lib/util/execute.d.ts +5 -0
- package/lib/util/execute.d.ts.map +1 -0
- package/lib/util/execute.js +28 -0
- package/lib/util/execute.js.map +1 -0
- package/lib/util/limit.d.ts +11 -0
- package/lib/util/limit.d.ts.map +1 -0
- package/lib/util/limit.js +39 -0
- package/lib/util/limit.js.map +1 -0
- package/package.json +3 -3
- package/src/context.ts +5 -2
- package/src/ir/args.ts +1 -1
- package/src/ir/connection.ts +3 -4
- package/src/ir/fields.ts +22 -2
- package/src/limit.size.ts +122 -13
- package/src/main.ts +18 -20
- package/src/model.schema.ts +40 -13
- package/src/model.tools.ts +121 -8
- package/src/model.ts +3 -1
- package/src/opencrud/orderBy.ts +13 -17
- package/src/opencrud/schema.ts +86 -85
- package/src/opencrud/tree.ts +55 -26
- package/src/server.ts +66 -26
- package/src/sql/cursor.ts +2 -2
- package/src/sql/mapping.ts +18 -1
- package/src/sql/printer.ts +137 -21
- package/src/sql/query.ts +50 -30
- package/src/test/limits.test.ts +163 -0
- package/src/test/queryable.test.ts +258 -0
- package/src/test/setup.ts +6 -3
- package/src/util/execute.ts +53 -0
- package/src/util/limit.ts +34 -0
package/lib/sql/query.js
CHANGED
|
@@ -3,29 +3,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ConnectionQuery = exports.CountQuery = exports.EntityByIdQuery = exports.ListQuery = void 0;
|
|
7
7
|
const util_internal_1 = require("@subsquid/util-internal");
|
|
8
8
|
const assert_1 = __importDefault(require("assert"));
|
|
9
9
|
const connection_1 = require("../ir/connection");
|
|
10
10
|
const util_1 = require("../util/util");
|
|
11
11
|
const mapping_1 = require("./mapping");
|
|
12
12
|
const printer_1 = require("./printer");
|
|
13
|
-
class
|
|
14
|
-
constructor(model, dialect,
|
|
13
|
+
class ListQuery {
|
|
14
|
+
constructor(model, dialect, typeName, fields, args) {
|
|
15
15
|
this.fields = fields;
|
|
16
16
|
this.params = [];
|
|
17
|
-
|
|
17
|
+
if (model[typeName].kind == 'entity') {
|
|
18
|
+
(0, assert_1.default)(Array.isArray(fields));
|
|
19
|
+
this.sql = new printer_1.EntitySqlPrinter(model, dialect, typeName, this.params, args, fields).print();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
(0, assert_1.default)(!Array.isArray(fields));
|
|
23
|
+
this.sql = new printer_1.QueryableSqlPrinter(model, dialect, typeName, this.params, args, fields).print();
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
map(rows) {
|
|
20
|
-
|
|
27
|
+
if (Array.isArray(this.fields)) {
|
|
28
|
+
return (0, mapping_1.mapRows)(rows, this.fields);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return (0, mapping_1.mapQueryableRows)(rows, this.fields);
|
|
32
|
+
}
|
|
21
33
|
}
|
|
22
34
|
}
|
|
23
|
-
exports.
|
|
35
|
+
exports.ListQuery = ListQuery;
|
|
24
36
|
class EntityByIdQuery {
|
|
25
37
|
constructor(model, dialect, entityName, fields, id) {
|
|
26
38
|
this.fields = fields;
|
|
27
39
|
this.params = [];
|
|
28
|
-
this.sql = new printer_1.
|
|
40
|
+
this.sql = new printer_1.EntitySqlPrinter(model, dialect, entityName, this.params, { where: { op: 'eq', field: 'id', value: id } }, fields).print();
|
|
29
41
|
}
|
|
30
42
|
map(rows) {
|
|
31
43
|
(0, assert_1.default)(rows.length < 2);
|
|
@@ -33,18 +45,19 @@ class EntityByIdQuery {
|
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
exports.EntityByIdQuery = EntityByIdQuery;
|
|
36
|
-
class
|
|
37
|
-
constructor(model, dialect,
|
|
48
|
+
class CountQuery {
|
|
49
|
+
constructor(model, dialect, typeName, where) {
|
|
38
50
|
this.params = [];
|
|
39
|
-
|
|
51
|
+
let Printer = model[typeName].kind == 'entity' ? printer_1.EntitySqlPrinter : printer_1.QueryableSqlPrinter;
|
|
52
|
+
this.sql = new Printer(model, dialect, typeName, this.params, { where }).printAsCount();
|
|
40
53
|
}
|
|
41
54
|
map(rows) {
|
|
42
55
|
return toCount(rows);
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
|
-
exports.
|
|
46
|
-
class
|
|
47
|
-
constructor(model, dialect,
|
|
58
|
+
exports.CountQuery = CountQuery;
|
|
59
|
+
class ConnectionQuery {
|
|
60
|
+
constructor(model, dialect, typeName, req) {
|
|
48
61
|
this.params = [];
|
|
49
62
|
this.offset = 0;
|
|
50
63
|
this.limit = 100;
|
|
@@ -52,18 +65,27 @@ class EntityConnectionQuery {
|
|
|
52
65
|
this.edgeCursor = req.edgeCursor;
|
|
53
66
|
this.pageInfo = req.pageInfo;
|
|
54
67
|
this.totalCount = req.totalCount;
|
|
55
|
-
let
|
|
68
|
+
let args = {
|
|
56
69
|
orderBy: req.orderBy,
|
|
57
70
|
where: req.where,
|
|
58
71
|
offset: this.offset,
|
|
59
72
|
limit: this.limit + 1
|
|
60
|
-
}
|
|
61
|
-
|
|
73
|
+
};
|
|
74
|
+
let printer;
|
|
75
|
+
if (model[typeName].kind == 'entity') {
|
|
76
|
+
(0, assert_1.default)(req.edgeNode == null || Array.isArray(req.edgeNode));
|
|
77
|
+
printer = new printer_1.EntitySqlPrinter(model, dialect, typeName, this.params, args, req.edgeNode);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
(0, assert_1.default)(req.edgeNode == null || !Array.isArray(req.edgeNode));
|
|
81
|
+
printer = new printer_1.QueryableSqlPrinter(model, dialect, typeName, this.params, args, req.edgeNode);
|
|
82
|
+
}
|
|
83
|
+
if (req.edgeNode) {
|
|
62
84
|
this.edgeNode = req.edgeNode;
|
|
63
85
|
this.sql = printer.print();
|
|
64
86
|
}
|
|
65
87
|
else {
|
|
66
|
-
this.sql =
|
|
88
|
+
this.sql = printer.printAsCount();
|
|
67
89
|
}
|
|
68
90
|
}
|
|
69
91
|
setOffsetAndLimit(req) {
|
|
@@ -78,7 +100,7 @@ class EntityConnectionQuery {
|
|
|
78
100
|
map(rows) {
|
|
79
101
|
let res = {};
|
|
80
102
|
if (this.edgeNode) {
|
|
81
|
-
let nodes = (0, mapping_1.mapRows)(rows, this.edgeNode);
|
|
103
|
+
let nodes = Array.isArray(this.edgeNode) ? (0, mapping_1.mapRows)(rows, this.edgeNode) : (0, mapping_1.mapQueryableRows)(rows, this.edgeNode);
|
|
82
104
|
let edges = new Array(Math.min(this.limit, nodes.length));
|
|
83
105
|
for (let i = 0; i < edges.length; i++) {
|
|
84
106
|
edges[i] = {
|
|
@@ -126,7 +148,7 @@ class EntityConnectionQuery {
|
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
150
|
}
|
|
129
|
-
exports.
|
|
151
|
+
exports.ConnectionQuery = ConnectionQuery;
|
|
130
152
|
function toCount(rows) {
|
|
131
153
|
(0, assert_1.default)(rows.length == 1);
|
|
132
154
|
return (0, util_1.toSafeInteger)(rows[0][0]);
|
package/lib/sql/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/sql/query.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAqD;AACrD,oDAA2B;AAG3B,iDAOyB;AAGzB,uCAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/sql/query.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAqD;AACrD,oDAA2B;AAG3B,iDAOyB;AAGzB,uCAA0C;AAC1C,uCAAmD;AACnD,uCAA+D;AAU/D,MAAa,SAAS;IAIlB,YACI,KAAY,EACZ,OAAgB,EAChB,QAAgB,EACR,MAAiB,EACzB,IAAkB;QADV,WAAM,GAAN,MAAM,CAAW;QANb,WAAM,GAAc,EAAE,CAAA;QASlC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,QAAQ,EAAE;YAClC,IAAA,gBAAM,EAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;YAC7B,IAAI,CAAC,GAAG,GAAG,IAAI,0BAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAA;SAC/F;aAAM;YACH,IAAA,gBAAM,EAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;YAC9B,IAAI,CAAC,GAAG,GAAG,IAAI,6BAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAA;SAClG;IACL,CAAC;IAED,GAAG,CAAC,IAAa;QACb,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,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C,QAAQ;YAAE,OAAM;QAC1B,OAAO;YACH,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC,KAAK;YAC/B,eAAe,EAAE,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YAC7C,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,wCAA2B,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YAC1E,SAAS,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,wCAA2B,EAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;SACrG,CAAA;IACL,CAAC;IAEO,aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAM;QAC5B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE;YAClC,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;SAC7B;aAAM;YACH,OAAO,SAAS,CAAA;SACnB;IACL,CAAC;CACJ;AAvGD,0CAuGC;AAGD,SAAS,OAAO,CAAC,IAAa;IAC1B,IAAA,gBAAM,EAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAA;IACxB,OAAO,IAAA,oBAAa,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.test.d.ts","sourceRoot":"","sources":["../../src/test/limits.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const expect_1 = __importDefault(require("expect"));
|
|
7
|
+
const setup_1 = require("./setup");
|
|
8
|
+
describe('response size limits', function () {
|
|
9
|
+
(0, setup_1.useDatabase)([
|
|
10
|
+
`create table "order1" (id text primary key)`,
|
|
11
|
+
`create table item1 (id text primary key, order_id text, name text)`,
|
|
12
|
+
`create table "order2" (id text primary key)`,
|
|
13
|
+
`create table item2 (id text primary key, order_id text, name text)`,
|
|
14
|
+
`create table "order3" (id text primary key)`,
|
|
15
|
+
`create table item3 (id text primary key, order_id text, name text)`,
|
|
16
|
+
]);
|
|
17
|
+
const client = (0, setup_1.useServer)(`
|
|
18
|
+
type Order1 @entity {
|
|
19
|
+
id: ID!
|
|
20
|
+
items: [Item1!]! @derivedFrom(field: "order")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type Item1 @entity {
|
|
24
|
+
id: ID!
|
|
25
|
+
order: Order1!
|
|
26
|
+
name: String
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type Order2 @entity @cardinality(value: 10) {
|
|
30
|
+
id: ID!
|
|
31
|
+
items: [Item2!]! @derivedFrom(field: "order")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type Item2 @entity {
|
|
35
|
+
id: ID!
|
|
36
|
+
order: Order2!
|
|
37
|
+
name: String
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type Order3 @entity {
|
|
41
|
+
id: ID!
|
|
42
|
+
items: [Item3!]! @derivedFrom(field: "order") @cardinality(value: 10)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type Item3 @entity {
|
|
46
|
+
id: ID!
|
|
47
|
+
order: Order3!
|
|
48
|
+
name: String @byteWeight(value: 10.0)
|
|
49
|
+
}
|
|
50
|
+
`, {
|
|
51
|
+
maxResponseNodes: 50,
|
|
52
|
+
maxRootFields: 3
|
|
53
|
+
});
|
|
54
|
+
it('unlimited requests fail', async function () {
|
|
55
|
+
let result = await client.query(`
|
|
56
|
+
query {
|
|
57
|
+
order1s {
|
|
58
|
+
id
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`);
|
|
62
|
+
(0, expect_1.default)(result).toMatchObject({
|
|
63
|
+
data: null,
|
|
64
|
+
errors: [
|
|
65
|
+
expect_1.default.objectContaining({ message: 'response might exceed the size limit', path: ['order1s'] })
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
it('limited requests work', function () {
|
|
70
|
+
return client.test(`
|
|
71
|
+
query {
|
|
72
|
+
order1s(limit: 10) {
|
|
73
|
+
items(limit: 2) {
|
|
74
|
+
id
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`, {
|
|
79
|
+
order1s: []
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
it('entity level cardinalities are respected', function () {
|
|
83
|
+
return client.test(`
|
|
84
|
+
query {
|
|
85
|
+
order2s {
|
|
86
|
+
id
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`, {
|
|
90
|
+
order2s: []
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
it('item cardinalities are respected', function () {
|
|
94
|
+
return client.test(`
|
|
95
|
+
query {
|
|
96
|
+
order3s(limit: 1) {
|
|
97
|
+
items { id }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`, {
|
|
101
|
+
order3s: []
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
it('@byteWeight annotations are respected', async function () {
|
|
105
|
+
let result = await client.query(`
|
|
106
|
+
query {
|
|
107
|
+
order3s(limit: 1) {
|
|
108
|
+
items(limit: 8) { name }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`);
|
|
112
|
+
(0, expect_1.default)(result).toEqual({
|
|
113
|
+
data: null,
|
|
114
|
+
errors: [
|
|
115
|
+
expect_1.default.objectContaining({
|
|
116
|
+
message: 'response might exceed the size limit',
|
|
117
|
+
path: ['order3s']
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
await client.test(`
|
|
122
|
+
query {
|
|
123
|
+
order3s(limit: 1) {
|
|
124
|
+
items(limit: 4) { name }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`, {
|
|
128
|
+
order3s: []
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
it('id_in conditions are understood', function () {
|
|
132
|
+
return client.test(`
|
|
133
|
+
query {
|
|
134
|
+
order1s(where: {id_in: ["1", "2", "3"]}) {
|
|
135
|
+
id
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
`, {
|
|
139
|
+
order1s: []
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
it('root query fields limit', async function () {
|
|
143
|
+
return client.errorTest(`
|
|
144
|
+
query {
|
|
145
|
+
a: order1ById(id: "1") { id }
|
|
146
|
+
b: order1ById(id: "1") { id }
|
|
147
|
+
c: order1ById(id: "1") { id }
|
|
148
|
+
d: order1ById(id: "1") { id }
|
|
149
|
+
}
|
|
150
|
+
`, {
|
|
151
|
+
errors: [
|
|
152
|
+
expect_1.default.objectContaining({
|
|
153
|
+
message: 'only 3 root query fields allowed, but got 4'
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=limits.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.test.js","sourceRoot":"","sources":["../../src/test/limits.test.ts"],"names":[],"mappings":";;;;;AAAA,oDAA2B;AAC3B,mCAA8C;AAG9C,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,IAAA,mBAAW,EAAC;QACR,6CAA6C;QAC7C,oEAAoE;QACpE,6CAA6C;QAC7C,oEAAoE;QACpE,6CAA6C;QAC7C,oEAAoE;KACvE,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAA,iBAAS,EAAC;;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AI,EAAE,CAAC,SAAS,CAAC;iBACpB,CAAC;aACL;SACJ,CAAC,CAAA;QACF,MAAM,MAAM,CAAC,IAAI,CAAC;;;;;;SAMjB,EAAE;YACC,OAAO,EAAE,EAAE;SACd,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iCAAiC,EAAE;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC;;;;;;SAMlB,EAAE;YACC,OAAO,EAAE,EAAE;SACd,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yBAAyB,EAAE,KAAK;QAC/B,OAAO,MAAM,CAAC,SAAS,CAAC;;;;;;;SAOvB,EAAE;YACC,MAAM,EAAE;gBACJ,gBAAM,CAAC,gBAAgB,CAAC;oBACpB,OAAO,EAAE,6CAA6C;iBACzD,CAAC;aACL;SACJ,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryable.test.d.ts","sourceRoot":"","sources":["../../src/test/queryable.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const setup_1 = require("./setup");
|
|
4
|
+
describe('queryable interfaces', function () {
|
|
5
|
+
(0, setup_1.useDatabase)([
|
|
6
|
+
`create table foo (id text primary key, name text, foo int)`,
|
|
7
|
+
`create table bar (id text primary key, name text, bar int)`,
|
|
8
|
+
`create table ref (id text primary key, name text, foo_id text not null unique references foo, bar_id text not null unique references bar)`,
|
|
9
|
+
`create table baz (id text primary key, name text, ref_id text references ref, baz int)`,
|
|
10
|
+
`insert into foo (id, name, foo) values ('foo-1', 'hello-foo-1', 1)`,
|
|
11
|
+
`insert into foo (id, name, foo) values ('foo-2', 'hello-foo-2', 2)`,
|
|
12
|
+
`insert into bar (id, name, bar) values ('bar-1', 'hello-bar-1', 10)`,
|
|
13
|
+
`insert into bar (id, name, bar) values ('bar-2', 'hello-bar-2', 20)`,
|
|
14
|
+
`insert into ref (id, name, foo_id, bar_id) values ('1', 'ref-1', 'foo-1', 'bar-2')`,
|
|
15
|
+
`insert into ref (id, name, foo_id, bar_id) values ('2', 'ref-2', 'foo-2', 'bar-1')`,
|
|
16
|
+
`insert into baz (id, name, baz, ref_id) values ('baz-1', 'hello-baz-1', 100, '1')`,
|
|
17
|
+
`create table one (id text primary key)`,
|
|
18
|
+
`create table two (id text primary key)`,
|
|
19
|
+
`create table relation (id text primary key, one_id text references one, two_id text references two)`,
|
|
20
|
+
`insert into one (id) values ('1-1')`,
|
|
21
|
+
`insert into one (id) values ('1-2')`,
|
|
22
|
+
`insert into two (id) values ('2-1')`,
|
|
23
|
+
`insert into two (id) values ('2-2')`,
|
|
24
|
+
`insert into relation (id, one_id, two_id) values ('r-1', '1-1', '2-1')`,
|
|
25
|
+
`insert into relation (id, one_id, two_id) values ('r-2', '1-2', '2-1')`,
|
|
26
|
+
]);
|
|
27
|
+
const client = (0, setup_1.useServer)(`
|
|
28
|
+
interface Entity @query {
|
|
29
|
+
id: ID!
|
|
30
|
+
name: String
|
|
31
|
+
ref: Ref
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type Ref @entity {
|
|
35
|
+
id: ID!
|
|
36
|
+
name: String
|
|
37
|
+
foo: Foo! @unique
|
|
38
|
+
bar: Bar! @unique
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type Foo implements Entity @entity {
|
|
42
|
+
id: ID!
|
|
43
|
+
name: String
|
|
44
|
+
ref: Ref @derivedFrom(field: "foo")
|
|
45
|
+
foo: Int
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type Bar implements Entity @entity {
|
|
49
|
+
id: ID!
|
|
50
|
+
name: String
|
|
51
|
+
ref: Ref @derivedFrom(field: "bar")
|
|
52
|
+
bar: Int
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type Baz implements Entity @entity {
|
|
56
|
+
id: ID!
|
|
57
|
+
name: String
|
|
58
|
+
ref: Ref
|
|
59
|
+
baz: Int
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface Number @query {
|
|
63
|
+
id: ID!
|
|
64
|
+
relations: [Relation!]!
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type One implements Number @entity {
|
|
68
|
+
id: ID!
|
|
69
|
+
relations: [Relation!]! @derivedFrom(field: "one")
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type Two implements Number @entity {
|
|
73
|
+
id: ID!
|
|
74
|
+
relations: [Relation!]! @derivedFrom(field: "two")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type Relation @entity {
|
|
78
|
+
id: ID!
|
|
79
|
+
one: One
|
|
80
|
+
two: Two
|
|
81
|
+
}
|
|
82
|
+
`);
|
|
83
|
+
it('fetching', function () {
|
|
84
|
+
return client.test(`
|
|
85
|
+
query {
|
|
86
|
+
entities(orderBy: id_ASC) {
|
|
87
|
+
id
|
|
88
|
+
name
|
|
89
|
+
ref {
|
|
90
|
+
id
|
|
91
|
+
name
|
|
92
|
+
}
|
|
93
|
+
... on Foo { foo }
|
|
94
|
+
... on Bar { bar }
|
|
95
|
+
... on Baz { baz }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`, {
|
|
99
|
+
entities: [
|
|
100
|
+
{
|
|
101
|
+
id: 'bar-1',
|
|
102
|
+
name: 'hello-bar-1',
|
|
103
|
+
ref: {
|
|
104
|
+
id: '2',
|
|
105
|
+
name: 'ref-2'
|
|
106
|
+
},
|
|
107
|
+
bar: 10
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'bar-2',
|
|
111
|
+
name: 'hello-bar-2',
|
|
112
|
+
ref: {
|
|
113
|
+
id: '1',
|
|
114
|
+
name: 'ref-1'
|
|
115
|
+
},
|
|
116
|
+
bar: 20
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'baz-1',
|
|
120
|
+
name: 'hello-baz-1',
|
|
121
|
+
ref: {
|
|
122
|
+
id: '1',
|
|
123
|
+
name: 'ref-1'
|
|
124
|
+
},
|
|
125
|
+
baz: 100
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: 'foo-1',
|
|
129
|
+
name: 'hello-foo-1',
|
|
130
|
+
ref: {
|
|
131
|
+
id: '1',
|
|
132
|
+
name: 'ref-1'
|
|
133
|
+
},
|
|
134
|
+
foo: 1
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 'foo-2',
|
|
138
|
+
name: 'hello-foo-2',
|
|
139
|
+
ref: {
|
|
140
|
+
id: '2',
|
|
141
|
+
name: 'ref-2'
|
|
142
|
+
},
|
|
143
|
+
foo: 2
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
it('sorting by entity type', function () {
|
|
149
|
+
return client.test(`
|
|
150
|
+
query {
|
|
151
|
+
entities(orderBy: [_type_DESC, id_ASC]) {
|
|
152
|
+
id
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`, {
|
|
156
|
+
entities: [
|
|
157
|
+
{ id: 'foo-1' },
|
|
158
|
+
{ id: 'foo-2' },
|
|
159
|
+
{ id: 'baz-1' },
|
|
160
|
+
{ id: 'bar-1' },
|
|
161
|
+
{ id: 'bar-2' }
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
it('pagination', function () {
|
|
166
|
+
return client.test(`
|
|
167
|
+
query {
|
|
168
|
+
page1: entitiesConnection(orderBy: id_ASC, first: 2) {
|
|
169
|
+
...fields
|
|
170
|
+
}
|
|
171
|
+
page2: entitiesConnection(orderBy: id_ASC, first: 2, after: "2") {
|
|
172
|
+
...fields
|
|
173
|
+
}
|
|
174
|
+
page3: entitiesConnection(orderBy: id_ASC, first: 2, after: "4") {
|
|
175
|
+
...fields
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fragment fields on EntitiesConnection {
|
|
180
|
+
edges {
|
|
181
|
+
cursor
|
|
182
|
+
node {
|
|
183
|
+
... on Foo { foo }
|
|
184
|
+
... on Bar { bar }
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
pageInfo {
|
|
188
|
+
hasNextPage
|
|
189
|
+
hasPreviousPage
|
|
190
|
+
startCursor
|
|
191
|
+
endCursor
|
|
192
|
+
}
|
|
193
|
+
totalCount
|
|
194
|
+
}
|
|
195
|
+
`, {
|
|
196
|
+
page1: {
|
|
197
|
+
edges: [
|
|
198
|
+
{ cursor: '1', node: { bar: 10 } },
|
|
199
|
+
{ cursor: '2', node: { bar: 20 } },
|
|
200
|
+
],
|
|
201
|
+
pageInfo: {
|
|
202
|
+
hasNextPage: true,
|
|
203
|
+
hasPreviousPage: false,
|
|
204
|
+
startCursor: '1',
|
|
205
|
+
endCursor: '2'
|
|
206
|
+
},
|
|
207
|
+
totalCount: 5
|
|
208
|
+
},
|
|
209
|
+
page2: {
|
|
210
|
+
edges: [
|
|
211
|
+
{ cursor: '3', node: {} },
|
|
212
|
+
{ cursor: '4', node: { foo: 1 } },
|
|
213
|
+
],
|
|
214
|
+
pageInfo: {
|
|
215
|
+
hasNextPage: true,
|
|
216
|
+
hasPreviousPage: true,
|
|
217
|
+
startCursor: '3',
|
|
218
|
+
endCursor: '4'
|
|
219
|
+
},
|
|
220
|
+
totalCount: 5
|
|
221
|
+
},
|
|
222
|
+
page3: {
|
|
223
|
+
edges: [
|
|
224
|
+
{ cursor: '5', node: { foo: 2 } },
|
|
225
|
+
],
|
|
226
|
+
pageInfo: {
|
|
227
|
+
hasNextPage: false,
|
|
228
|
+
hasPreviousPage: true,
|
|
229
|
+
startCursor: '5',
|
|
230
|
+
endCursor: '5'
|
|
231
|
+
},
|
|
232
|
+
totalCount: 5
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
it('list lookup fields in interfaces', function () {
|
|
237
|
+
return client.test(`
|
|
238
|
+
query {
|
|
239
|
+
numbers(orderBy: id_ASC) {
|
|
240
|
+
id
|
|
241
|
+
relations { id }
|
|
242
|
+
__typename
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
`, {
|
|
246
|
+
numbers: [
|
|
247
|
+
{ __typename: 'One', id: '1-1', relations: [{ id: 'r-1' }] },
|
|
248
|
+
{ __typename: 'One', id: '1-2', relations: [{ id: 'r-2' }] },
|
|
249
|
+
{ __typename: 'Two', id: '2-1', relations: [{ id: 'r-1' }, { id: 'r-2' }] },
|
|
250
|
+
{ __typename: 'Two', id: '2-2', relations: [] }
|
|
251
|
+
]
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
//# sourceMappingURL=queryable.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryable.test.js","sourceRoot":"","sources":["../../src/test/queryable.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAE9C,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,IAAA,mBAAW,EAAC;QACR,4DAA4D;QAC5D,4DAA4D;QAC5D,2IAA2I;QAC3I,wFAAwF;QACxF,oEAAoE;QACpE,oEAAoE;QACpE,qEAAqE;QACrE,qEAAqE;QACrE,oFAAoF;QACpF,oFAAoF;QACpF,mFAAmF;QACnF,wCAAwC;QACxC,wCAAwC;QACxC,qGAAqG;QACrG,qCAAqC;QACrC,qCAAqC;QACrC,qCAAqC;QACrC,qCAAqC;QACrC,wEAAwE;QACxE,wEAAwE;KAC3E,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAA,iBAAS,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuDxB,CAAC,CAAA;IAEF,EAAE,CAAC,UAAU,EAAE;QACX,OAAO,MAAM,CAAC,IAAI,CAAC;;;;;;;;;;;;;;SAclB,EAAE;YACC,QAAQ,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AK,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAC,EAAE,EAAE,KAAK,EAAC,CAAC,EAAC;gBACxD,EAAC,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAC,EAAE,EAAE,KAAK,EAAC,CAAC,EAAC;gBACxD,EAAC,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAC,EAAE,EAAE,KAAK,EAAC,EAAE,EAAC,EAAE,EAAE,KAAK,EAAC,CAAC,EAAC;gBACrE,EAAC,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAC;aAChD;SACJ,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/lib/test/setup.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Client } from "gql-test-client";
|
|
2
2
|
import { ClientBase } from "pg";
|
|
3
|
+
import { ServerOptions } from '../server';
|
|
3
4
|
export declare function isCockroach(): boolean;
|
|
4
5
|
export declare const db_config: {
|
|
5
6
|
host: string;
|
|
@@ -12,5 +13,5 @@ export declare function withDatabase(block: (client: ClientBase) => Promise<void
|
|
|
12
13
|
export declare function databaseExecute(sql: string[]): Promise<void>;
|
|
13
14
|
export declare function databaseDelete(): Promise<void>;
|
|
14
15
|
export declare function useDatabase(sql: string[]): void;
|
|
15
|
-
export declare function useServer(schema: string): Client;
|
|
16
|
+
export declare function useServer(schema: string, options?: Partial<ServerOptions>): Client;
|
|
16
17
|
//# sourceMappingURL=setup.d.ts.map
|
package/lib/test/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAA;AAEtC,OAAO,EAAqB,UAAU,EAAO,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAA;AAEtC,OAAO,EAAqB,UAAU,EAAO,MAAM,IAAI,CAAA;AAEvD,OAAO,EAAQ,aAAa,EAAC,MAAM,WAAW,CAAA;AAG9C,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAGD,eAAO,MAAM,SAAS;;;;;;CAQrB,CAAA;AAGD,wBAAsB,YAAY,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9F;AAGD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5D;AAGD,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAK9C;AAGD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAK/C;AAGD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM,CAoBlF"}
|
package/lib/test/setup.js
CHANGED
|
@@ -51,7 +51,7 @@ function useDatabase(sql) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
exports.useDatabase = useDatabase;
|
|
54
|
-
function useServer(schema) {
|
|
54
|
+
function useServer(schema, options) {
|
|
55
55
|
let client = new gql_test_client_1.Client('not defined');
|
|
56
56
|
let db = new pg_1.Pool(exports.db_config);
|
|
57
57
|
let info;
|
|
@@ -61,7 +61,10 @@ function useServer(schema) {
|
|
|
61
61
|
model: (0, model_schema_1.buildModel)((0, model_schema_1.buildSchema)((0, graphql_1.parse)(schema))),
|
|
62
62
|
port: 0,
|
|
63
63
|
dialect: isCockroach() ? 'cockroach' : 'postgres',
|
|
64
|
-
subscriptions: true
|
|
64
|
+
subscriptions: true,
|
|
65
|
+
subscriptionPollInterval: 500,
|
|
66
|
+
maxRootFields: 10,
|
|
67
|
+
...options
|
|
65
68
|
});
|
|
66
69
|
client.endpoint = `http://localhost:${info.port}/graphql`;
|
|
67
70
|
});
|
package/lib/test/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAErD,qDAAsC;AACtC,qCAA6B;AAC7B,2BAAuD;AACvD,kDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAErD,qDAAsC;AACtC,qCAA6B;AAC7B,2BAAuD;AACvD,kDAAuD;AACvD,sCAA8C;AAG9C,SAAgB,WAAW;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,WAAW,CAAA;AAC7C,CAAC;AAFD,kCAEC;AAGY,QAAA,SAAS,GAAG;IACrB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ,CAAC,IAAA,6BAAa,EACxB,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CACzE,CAAC;IACF,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,WAAW;CACxB,CAAA;AAGM,KAAK,UAAU,YAAY,CAAC,KAA4C;IAC3E,IAAI,MAAM,GAAG,IAAI,WAAQ,CAAC,iBAAS,CAAC,CAAA;IACpC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;IACtB,IAAI;QACA,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA;KACtB;YAAS;QACN,MAAM,MAAM,CAAC,GAAG,EAA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WAAW,CAAC,CAAC,CAAC,UAAU;YACjD,aAAa,EAAE,IAAI;YACnB,wBAAwB,EAAE,GAAG;YAC7B,aAAa,EAAE,EAAE;YACjB,GAAG,OAAO;SACb,CAAC,CAAA;QACF,MAAM,CAAC,QAAQ,GAAG,oBAAoB,IAAI,CAAC,IAAI,UAAU,CAAA;IAC7D,CAAC,CAAC,CAAA;IACF,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1B,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;IACrB,OAAO,MAAM,CAAA;AACjB,CAAC;AApBD,8BAoBC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExecutionResult } from 'graphql-ws';
|
|
2
|
+
import { ExecutionArgs } from 'graphql/execution/execute';
|
|
3
|
+
import { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue';
|
|
4
|
+
export declare function executeWithLimit(maxQueries: number, args: ExecutionArgs): PromiseOrValue<ExecutionResult>;
|
|
5
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/util/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAA;AAC1C,OAAO,EAKH,aAAa,EAEhB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAC,cAAc,EAAC,MAAM,gCAAgC,CAAA;AAG7D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,cAAc,CAAC,eAAe,CAAC,CAuCzG"}
|