@cubicweb/client 3.0.0-alpha.14 → 3.0.0-alpha.15
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/README.md +1 -1
- package/lib/api/Api.d.ts.map +1 -1
- package/lib/api/Api.js +3 -4
- package/lib/api/Api.js.map +1 -1
- package/lib/api/ResultSet.d.ts +32 -5
- package/lib/api/ResultSet.d.ts.map +1 -1
- package/lib/api/ResultSet.js +55 -3
- package/lib/api/ResultSet.js.map +1 -1
- package/lib/api/query/RQLQuery.d.ts +1 -1
- package/lib/api/query/RQLQuery.d.ts.map +1 -1
- package/lib/api/query/RQLQuery.js.map +1 -1
- package/lib/api/query/references.d.ts +3 -3
- package/lib/api/query/references.d.ts.map +1 -1
- package/lib/api/query/references.js.map +1 -1
- package/lib/api/transaction/TransactionResult.d.ts +12 -3
- package/lib/api/transaction/TransactionResult.d.ts.map +1 -1
- package/lib/api/transaction/TransactionResult.js +10 -6
- package/lib/api/transaction/TransactionResult.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/Api.ts +6 -14
- package/src/api/ResultSet.ts +74 -8
- package/src/api/query/RQLQuery.ts +1 -1
- package/src/api/query/references.ts +2 -2
- package/src/api/transaction/TransactionResult.ts +28 -6
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ library.
|
|
|
7
7
|
|
|
8
8
|
The full documentation is available [here](https://cubicweb.pages.logilab.fr/cubicwebjs/client).
|
|
9
9
|
|
|
10
|
-
**Compatible with [API cube](https://forge.extranet.logilab.fr/cubicweb/cubes/api) version 0.
|
|
10
|
+
**Compatible with [API cube](https://forge.extranet.logilab.fr/cubicweb/cubes/api) version 0.15 only.**
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
package/lib/api/Api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/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AC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,aAAa,CAAS;IAE9B;;;;;;;;;OASG;gBACS,MAAM,EAAE,MAAM;IAU1B,IAAI,MAAM,WAET;IAED,OAAO,CAAC,WAAW;IAInB;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;IAOlC;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9D;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAOzC;;;;;;OAMG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3D;;;;;;;;OAQG;IACG,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAa/D,OAAO,CAAC,oBAAoB;YAOd,oBAAoB;YAsBpB,eAAe;IAY7B,OAAO,CAAC,gBAAgB;CAgBzB"}
|
package/lib/api/Api.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ValidationError } from "../errors.js";
|
|
2
2
|
import { getBinariesFromTransaction, serializeQueryParams } from "../utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import { TransactionResult } from "./transaction/TransactionResult.js";
|
|
3
|
+
import { TransactionResult, } from "./transaction/TransactionResult.js";
|
|
5
4
|
/**
|
|
6
5
|
* Class used to handle requests to the CubicWeb API.
|
|
7
6
|
*
|
|
@@ -158,7 +157,7 @@ export default class Api {
|
|
|
158
157
|
credentials: "include",
|
|
159
158
|
body: formData,
|
|
160
159
|
});
|
|
161
|
-
return new TransactionResult(transaction, resultSets
|
|
160
|
+
return new TransactionResult(transaction, resultSets);
|
|
162
161
|
}
|
|
163
162
|
async jsonTransaction(transaction) {
|
|
164
163
|
const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
|
|
@@ -166,7 +165,7 @@ export default class Api {
|
|
|
166
165
|
credentials: "include",
|
|
167
166
|
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
168
167
|
});
|
|
169
|
-
return new TransactionResult(transaction, resultSets
|
|
168
|
+
return new TransactionResult(transaction, resultSets);
|
|
170
169
|
}
|
|
171
170
|
handleUserErrors(error) {
|
|
172
171
|
if (typeof error === "object" &&
|
package/lib/api/Api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI/E,OAAO,EAEL,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAyD5C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACd,OAAO,CAAS;IAChB,QAAQ,GAAG,IAAI,CAAC;IAChB,UAAU,CAAS;IACnB,aAAa,CAAS;IACtB,YAAY,CAAS;IACrB,aAAa,CAAS;IACtB,kBAAkB,CAAS;IAC3B,aAAa,CAAS;IAE9B;;;;;;;;;OASG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,IA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B,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QAClC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,IAAI,CAAC;QACT,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAChD,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
package/lib/api/ResultSet.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing the json returned by the API for a single result set
|
|
3
|
+
*
|
|
4
|
+
* @category Api
|
|
5
|
+
*/
|
|
6
|
+
export interface RawResultSet {
|
|
7
|
+
readonly rows: ResultSetCell[][];
|
|
8
|
+
readonly column_names: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interface representing the json returned by the API for a single row in a result set
|
|
12
|
+
*
|
|
13
|
+
* @category Api
|
|
14
|
+
*/
|
|
15
|
+
export type RawResultSetRow = ResultSetCell[];
|
|
1
16
|
/**
|
|
2
17
|
* Type representing a final value in a result set.
|
|
3
18
|
*
|
|
@@ -8,18 +23,30 @@
|
|
|
8
23
|
*/
|
|
9
24
|
export type ResultSetCell = string | number | boolean | null;
|
|
10
25
|
/**
|
|
11
|
-
*
|
|
26
|
+
* Class representing a row returned in a result set.
|
|
12
27
|
*
|
|
13
28
|
* @category Api
|
|
14
29
|
*/
|
|
15
|
-
export
|
|
30
|
+
export declare class ResultSetRow implements Iterable<ResultSetCell> {
|
|
31
|
+
readonly columnNames: string[];
|
|
32
|
+
private readonly cells;
|
|
33
|
+
constructor(columnNames: string[], cells: RawResultSetRow);
|
|
34
|
+
[Symbol.iterator](): Generator<ResultSetCell, void, unknown>;
|
|
35
|
+
get length(): number;
|
|
36
|
+
getCell(column: number | string): ResultSetCell;
|
|
37
|
+
}
|
|
16
38
|
/**
|
|
17
39
|
* Class representing a RQL request result.
|
|
18
40
|
*
|
|
19
41
|
* @category Api
|
|
20
42
|
*/
|
|
21
|
-
export declare class ResultSet
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
export declare class ResultSet {
|
|
44
|
+
#private;
|
|
45
|
+
readonly columnNames: string[];
|
|
46
|
+
constructor(rawResultSet: RawResultSet);
|
|
47
|
+
[Symbol.iterator](): Generator<ResultSetRow, void, unknown>;
|
|
48
|
+
get length(): number;
|
|
49
|
+
getRow(row: number): ResultSetRow;
|
|
50
|
+
getCell(row: number, column: number | string): ResultSetCell;
|
|
24
51
|
}
|
|
25
52
|
//# sourceMappingURL=ResultSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultSet.d.ts","sourceRoot":"","sources":["../../src/api/ResultSet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"ResultSet.d.ts","sourceRoot":"","sources":["../../src/api/ResultSet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,EAAE,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D;;;;GAIG;AACH,qBAAa,YAAa,YAAW,QAAQ,CAAC,aAAa,CAAC;aAExC,WAAW,EAAE,MAAM,EAAE;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADN,WAAW,EAAE,MAAM,EAAE,EACpB,KAAK,EAAE,eAAe;IAGxC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAMlB,IAAI,MAAM,WAET;IAED,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAQhC;AAED;;;;GAIG;AACH,qBAAa,SAAS;;IACpB,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAC;gBAG1B,YAAY,EAAE,YAAY;IAKrC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAMlB,IAAI,MAAM,WAET;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAIjC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa;CAQ7D"}
|
package/lib/api/ResultSet.js
CHANGED
|
@@ -1,12 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class representing a row returned in a result set.
|
|
3
|
+
*
|
|
4
|
+
* @category Api
|
|
5
|
+
*/
|
|
6
|
+
export class ResultSetRow {
|
|
7
|
+
columnNames;
|
|
8
|
+
cells;
|
|
9
|
+
constructor(columnNames, cells) {
|
|
10
|
+
this.columnNames = columnNames;
|
|
11
|
+
this.cells = cells;
|
|
12
|
+
}
|
|
13
|
+
*[Symbol.iterator]() {
|
|
14
|
+
for (const cell of this.cells) {
|
|
15
|
+
yield cell;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
get length() {
|
|
19
|
+
return this.cells.length;
|
|
20
|
+
}
|
|
21
|
+
getCell(column) {
|
|
22
|
+
if (typeof column === "number") {
|
|
23
|
+
return this.cells[column];
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const columnIndex = this.columnNames.indexOf(column);
|
|
27
|
+
return this.cells[columnIndex];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
1
31
|
/**
|
|
2
32
|
* Class representing a RQL request result.
|
|
3
33
|
*
|
|
4
34
|
* @category Api
|
|
5
35
|
*/
|
|
6
36
|
export class ResultSet {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
37
|
+
columnNames;
|
|
38
|
+
#rows;
|
|
39
|
+
constructor(rawResultSet) {
|
|
40
|
+
this.columnNames = rawResultSet.column_names;
|
|
41
|
+
this.#rows = rawResultSet.rows;
|
|
42
|
+
}
|
|
43
|
+
*[Symbol.iterator]() {
|
|
44
|
+
for (const r of this.#rows) {
|
|
45
|
+
yield new ResultSetRow(this.columnNames, r);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
get length() {
|
|
49
|
+
return this.#rows.length;
|
|
50
|
+
}
|
|
51
|
+
getRow(row) {
|
|
52
|
+
return new ResultSetRow(this.columnNames, this.#rows[row]);
|
|
53
|
+
}
|
|
54
|
+
getCell(row, column) {
|
|
55
|
+
if (typeof column === "number") {
|
|
56
|
+
return this.#rows[row][column];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const columnIndex = this.columnNames.indexOf(column);
|
|
60
|
+
return this.#rows[row][columnIndex];
|
|
61
|
+
}
|
|
10
62
|
}
|
|
11
63
|
}
|
|
12
64
|
//# sourceMappingURL=ResultSet.js.map
|
package/lib/api/ResultSet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultSet.js","sourceRoot":"","sources":["../../src/api/ResultSet.ts"],"names":[],"mappings":"
|
|
1
|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AAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,MAAuB;QAC1C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -35,6 +35,6 @@ export declare class RQLQuery {
|
|
|
35
35
|
/**
|
|
36
36
|
* @returns A reference to a {@link ResultSetCell} in the result of this query.
|
|
37
37
|
*/
|
|
38
|
-
cellRef(row: number, column: number): RQLQueryCellRef;
|
|
38
|
+
cellRef(row: number, column: number | string): RQLQueryCellRef;
|
|
39
39
|
}
|
|
40
40
|
//# sourceMappingURL=RQLQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RQLQuery.d.ts","sourceRoot":"","sources":["../../../src/api/query/RQLQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;GASG;AACH,qBAAa,QAAQ;aAiBD,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,cAAc;IAjBxC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC;;;;;;;;;;;;OAYG;gBAEe,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,cAAmB;IAK7C;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;IAInC;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe;
|
|
1
|
+
{"version":3,"file":"RQLQuery.d.ts","sourceRoot":"","sources":["../../../src/api/query/RQLQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;GASG;AACH,qBAAa,QAAQ;aAiBD,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,cAAc;IAjBxC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC;;;;;;;;;;;;OAYG;gBAEe,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,cAAmB;IAK7C;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;IAInC;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe;CAG/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RQLQuery.js","sourceRoot":"","sources":["../../../src/api/query/RQLQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGlE;;;;;;;;;GASG;AACH,MAAM,OAAO,QAAQ;IAiBD;IACA;IAjBF,SAAS,CAAS;IAElC;;;;;;;;;;;;OAYG;IACH,YACkB,GAAW,EACX,SAAyB,EAAE;QAD3B,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAqB;QAE3C,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"RQLQuery.js","sourceRoot":"","sources":["../../../src/api/query/RQLQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGlE;;;;;;;;;GASG;AACH,MAAM,OAAO,QAAQ;IAiBD;IACA;IAjBF,SAAS,CAAS;IAElC;;;;;;;;;;;;OAYG;IACH,YACkB,GAAW,EACX,SAAyB,EAAE;QAD3B,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAqB;QAE3C,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAW,EAAE,MAAuB;QAC1C,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF"}
|
|
@@ -18,7 +18,7 @@ export declare class RQLQueryRowRef {
|
|
|
18
18
|
*
|
|
19
19
|
* @category Api
|
|
20
20
|
*/
|
|
21
|
-
column(c: number): RQLQueryCellRef;
|
|
21
|
+
column(c: number | string): RQLQueryCellRef;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Class representing a reference to a {@link ResultSetCell} in the result of a {@link RQLQuery}.
|
|
@@ -35,7 +35,7 @@ export declare class RQLQueryRowRef {
|
|
|
35
35
|
export declare class RQLQueryCellRef {
|
|
36
36
|
readonly queryUUID: string;
|
|
37
37
|
readonly row: number;
|
|
38
|
-
readonly column: number;
|
|
39
|
-
constructor(queryUUID: string, row: number, column: number);
|
|
38
|
+
readonly column: number | string;
|
|
39
|
+
constructor(queryUUID: string, row: number, column: number | string);
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=references.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/api/query/references.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,cAAc;aACG,SAAS,EAAE,MAAM;aAAkB,GAAG,EAAE,MAAM;gBAA9C,SAAS,EAAE,MAAM,EAAkB,GAAG,EAAE,MAAM;IAE1E;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe;
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/api/query/references.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,cAAc;aACG,SAAS,EAAE,MAAM;aAAkB,GAAG,EAAE,MAAM;gBAA9C,SAAS,EAAE,MAAM,EAAkB,GAAG,EAAE,MAAM;IAE1E;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe;CAG5C;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe;aAER,SAAS,EAAE,MAAM;aACjB,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,MAAM,GAAG,MAAM;gBAFvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GAAG,MAAM;CAE1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../../src/api/query/references.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACG;IAAmC;IAA/D,YAA4B,SAAiB,EAAkB,GAAW;QAA9C,cAAS,GAAT,SAAS,CAAQ;QAAkB,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE9E;;;;;;;OAOG;IACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../../src/api/query/references.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACG;IAAmC;IAA/D,YAA4B,SAAiB,EAAkB,GAAW;QAA9C,cAAS,GAAT,SAAS,CAAQ;QAAkB,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE9E;;;;;;;OAOG;IACH,MAAM,CAAC,CAAkB;QACvB,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,eAAe;IAER;IACA;IACA;IAHlB,YACkB,SAAiB,EACjB,GAAW,EACX,MAAuB;QAFvB,cAAS,GAAT,SAAS,CAAQ;QACjB,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAiB;IACtC,CAAC;CACL"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { ResultSet, ResultSetCell, ResultSetRow } from "../ResultSet.js";
|
|
1
|
+
import { RawResultSet, ResultSet, ResultSetCell, ResultSetRow } from "../ResultSet.js";
|
|
2
2
|
import { RQLQuery } from "../query/RQLQuery.js";
|
|
3
3
|
import { RQLQueryCellRef, RQLQueryRowRef } from "../query/references.js";
|
|
4
4
|
import { Transaction } from "./Transaction.js";
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing the json returned by the API when executing
|
|
7
|
+
* a Transaction
|
|
8
|
+
*
|
|
9
|
+
* @category Api
|
|
10
|
+
*/
|
|
11
|
+
export interface RawTransactionResult {
|
|
12
|
+
readonly result_sets: RawResultSet[];
|
|
13
|
+
}
|
|
5
14
|
/**
|
|
6
15
|
* Class representing the result of a transaction.
|
|
7
16
|
*
|
|
@@ -23,8 +32,8 @@ import { Transaction } from "./Transaction.js";
|
|
|
23
32
|
*/
|
|
24
33
|
export declare class TransactionResult {
|
|
25
34
|
private transaction;
|
|
26
|
-
private
|
|
27
|
-
constructor(transaction: Transaction,
|
|
35
|
+
private rawResultSets;
|
|
36
|
+
constructor(transaction: Transaction, rawTransactionResult: RawTransactionResult);
|
|
28
37
|
getResultSet(query: RQLQuery): ResultSet;
|
|
29
38
|
getRow(ref: RQLQueryRowRef): ResultSetRow;
|
|
30
39
|
getCell(ref: RQLQueryCellRef): ResultSetCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionResult.d.ts","sourceRoot":"","sources":["../../../src/api/transaction/TransactionResult.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"TransactionResult.d.ts","sourceRoot":"","sources":["../../../src/api/transaction/TransactionResult.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,YAAY,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,iBAAiB;IAI1B,OAAO,CAAC,WAAW;IAHrB,OAAO,CAAC,aAAa,CAAiB;gBAG5B,WAAW,EAAE,WAAW,EAChC,oBAAoB,EAAE,oBAAoB;IAK5C,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS;IAMxC,MAAM,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY;IAMzC,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa;CAK7C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getQueryIndexInTransaction } from "../../utils.js";
|
|
2
|
+
import { ResultSet, } from "../ResultSet.js";
|
|
2
3
|
/**
|
|
3
4
|
* Class representing the result of a transaction.
|
|
4
5
|
*
|
|
@@ -20,22 +21,25 @@ import { getQueryIndexInTransaction } from "../../utils.js";
|
|
|
20
21
|
*/
|
|
21
22
|
export class TransactionResult {
|
|
22
23
|
transaction;
|
|
23
|
-
|
|
24
|
-
constructor(transaction,
|
|
24
|
+
rawResultSets;
|
|
25
|
+
constructor(transaction, rawTransactionResult) {
|
|
25
26
|
this.transaction = transaction;
|
|
26
|
-
this.
|
|
27
|
+
this.rawResultSets = rawTransactionResult.result_sets;
|
|
27
28
|
}
|
|
28
29
|
getResultSet(query) {
|
|
29
30
|
const index = getQueryIndexInTransaction(this.transaction, query.queryUUID);
|
|
30
|
-
|
|
31
|
+
const resultSet = new ResultSet(this.rawResultSets[index]);
|
|
32
|
+
return resultSet;
|
|
31
33
|
}
|
|
32
34
|
getRow(ref) {
|
|
33
35
|
const index = getQueryIndexInTransaction(this.transaction, ref.queryUUID);
|
|
34
|
-
|
|
36
|
+
const resultSet = new ResultSet(this.rawResultSets[index]);
|
|
37
|
+
return resultSet.getRow(ref.row);
|
|
35
38
|
}
|
|
36
39
|
getCell(ref) {
|
|
37
40
|
const index = getQueryIndexInTransaction(this.transaction, ref.queryUUID);
|
|
38
|
-
|
|
41
|
+
const resultSet = new ResultSet(this.rawResultSets[index]);
|
|
42
|
+
return resultSet.getCell(ref.row, ref.column);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
//# sourceMappingURL=TransactionResult.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionResult.js","sourceRoot":"","sources":["../../../src/api/transaction/TransactionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
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AC,CAAC;IAChD,CAAC;CACF"}
|
package/lib/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export * from "./schema/classes/RelationDefinitionSchema.js";
|
|
|
10
10
|
export * from "./schema/classes/Schema.js";
|
|
11
11
|
export * from "./schema/classes/Utils.js";
|
|
12
12
|
export * from "./errors.js";
|
|
13
|
-
export { ResultSet } from "./api/ResultSet.js";
|
|
13
|
+
export { ResultSet, ResultSetRow } from "./api/ResultSet.js";
|
|
14
14
|
export { default as Client } from "./api/Client.js";
|
|
15
15
|
export { Transaction } from "./api/transaction/Transaction.js";
|
|
16
16
|
export { TransactionResult } from "./api/transaction/TransactionResult.js";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AAEtC,2BAA2B;AAC3B,cAAc,kCAAkC,CAAC;AACjD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAE1C,cAAc,aAAa,CAAC;AAS5B,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AAEtC,2BAA2B;AAC3B,cAAc,kCAAkC,CAAC;AACjD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAE1C,cAAc,aAAa,CAAC;AAS5B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAiB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@cubicweb/client",
|
|
3
3
|
"description": "Official JS client for CubicWeb API",
|
|
4
4
|
"author": "Logilab",
|
|
5
|
-
"version": "3.0.0-alpha.
|
|
5
|
+
"version": "3.0.0-alpha.15",
|
|
6
6
|
"license": "LGPL-3.0-or-later",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "run -T tsc --project tsconfig.build.json",
|
package/src/api/Api.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ValidationError } from "../errors.js";
|
|
2
2
|
import { RawSchema } from "../schema/raw/Schema.js";
|
|
3
3
|
import { getBinariesFromTransaction, serializeQueryParams } from "../utils.js";
|
|
4
|
-
import { ResultSet, ResultSetCell } from "./ResultSet.js";
|
|
5
4
|
import { RQLBinary } from "./binary/RQLBinary.js";
|
|
6
5
|
import { RQLQueryCellRef } from "./query/references.js";
|
|
7
6
|
import { Transaction } from "./transaction/Transaction.js";
|
|
8
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
RawTransactionResult,
|
|
9
|
+
TransactionResult,
|
|
10
|
+
} from "./transaction/TransactionResult.js";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Type representing valid final values to use as parameters in a RQL query.
|
|
@@ -62,10 +64,6 @@ export type ApiErrorResponse = {
|
|
|
62
64
|
status: number;
|
|
63
65
|
} & ApiError;
|
|
64
66
|
|
|
65
|
-
type RawTransactionResult = ReadonlyArray<
|
|
66
|
-
ReadonlyArray<ReadonlyArray<ResultSetCell>>
|
|
67
|
-
>;
|
|
68
|
-
|
|
69
67
|
/**
|
|
70
68
|
* Class used to handle requests to the CubicWeb API.
|
|
71
69
|
*
|
|
@@ -237,10 +235,7 @@ export default class Api {
|
|
|
237
235
|
body: formData,
|
|
238
236
|
}
|
|
239
237
|
);
|
|
240
|
-
return new TransactionResult(
|
|
241
|
-
transaction,
|
|
242
|
-
resultSets.map((r) => new ResultSet(r))
|
|
243
|
-
);
|
|
238
|
+
return new TransactionResult(transaction, resultSets);
|
|
244
239
|
}
|
|
245
240
|
|
|
246
241
|
private async jsonTransaction(transaction: Transaction) {
|
|
@@ -252,10 +247,7 @@ export default class Api {
|
|
|
252
247
|
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
253
248
|
}
|
|
254
249
|
);
|
|
255
|
-
return new TransactionResult(
|
|
256
|
-
transaction,
|
|
257
|
-
resultSets.map((r) => new ResultSet(r))
|
|
258
|
-
);
|
|
250
|
+
return new TransactionResult(transaction, resultSets);
|
|
259
251
|
}
|
|
260
252
|
|
|
261
253
|
private handleUserErrors(error: unknown): never {
|
package/src/api/ResultSet.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing the json returned by the API for a single result set
|
|
3
|
+
*
|
|
4
|
+
* @category Api
|
|
5
|
+
*/
|
|
6
|
+
export interface RawResultSet {
|
|
7
|
+
readonly rows: ResultSetCell[][];
|
|
8
|
+
readonly column_names: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Interface representing the json returned by the API for a single row in a result set
|
|
13
|
+
*
|
|
14
|
+
* @category Api
|
|
15
|
+
*/
|
|
16
|
+
export type RawResultSetRow = ResultSetCell[];
|
|
17
|
+
|
|
1
18
|
/**
|
|
2
19
|
* Type representing a final value in a result set.
|
|
3
20
|
*
|
|
@@ -9,21 +26,70 @@
|
|
|
9
26
|
export type ResultSetCell = string | number | boolean | null;
|
|
10
27
|
|
|
11
28
|
/**
|
|
12
|
-
*
|
|
29
|
+
* Class representing a row returned in a result set.
|
|
13
30
|
*
|
|
14
31
|
* @category Api
|
|
15
32
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
33
|
+
export class ResultSetRow implements Iterable<ResultSetCell> {
|
|
34
|
+
constructor(
|
|
35
|
+
public readonly columnNames: string[],
|
|
36
|
+
private readonly cells: RawResultSetRow
|
|
37
|
+
) {}
|
|
38
|
+
|
|
39
|
+
*[Symbol.iterator]() {
|
|
40
|
+
for (const cell of this.cells) {
|
|
41
|
+
yield cell;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get length() {
|
|
46
|
+
return this.cells.length;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getCell(column: number | string) {
|
|
50
|
+
if (typeof column === "number") {
|
|
51
|
+
return this.cells[column];
|
|
52
|
+
} else {
|
|
53
|
+
const columnIndex = this.columnNames.indexOf(column);
|
|
54
|
+
return this.cells[columnIndex];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
19
58
|
|
|
20
59
|
/**
|
|
21
60
|
* Class representing a RQL request result.
|
|
22
61
|
*
|
|
23
62
|
* @category Api
|
|
24
63
|
*/
|
|
25
|
-
export class ResultSet
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
64
|
+
export class ResultSet {
|
|
65
|
+
public readonly columnNames: string[];
|
|
66
|
+
readonly #rows: RawResultSetRow[];
|
|
67
|
+
|
|
68
|
+
constructor(rawResultSet: RawResultSet) {
|
|
69
|
+
this.columnNames = rawResultSet.column_names;
|
|
70
|
+
this.#rows = rawResultSet.rows;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
*[Symbol.iterator]() {
|
|
74
|
+
for (const r of this.#rows) {
|
|
75
|
+
yield new ResultSetRow(this.columnNames, r);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get length() {
|
|
80
|
+
return this.#rows.length;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getRow(row: number): ResultSetRow {
|
|
84
|
+
return new ResultSetRow(this.columnNames, this.#rows[row]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
getCell(row: number, column: number | string): ResultSetCell {
|
|
88
|
+
if (typeof column === "number") {
|
|
89
|
+
return this.#rows[row][column];
|
|
90
|
+
} else {
|
|
91
|
+
const columnIndex = this.columnNames.indexOf(column);
|
|
92
|
+
return this.#rows[row][columnIndex];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
29
95
|
}
|
|
@@ -45,7 +45,7 @@ export class RQLQuery {
|
|
|
45
45
|
/**
|
|
46
46
|
* @returns A reference to a {@link ResultSetCell} in the result of this query.
|
|
47
47
|
*/
|
|
48
|
-
cellRef(row: number, column: number): RQLQueryCellRef {
|
|
48
|
+
cellRef(row: number, column: number | string): RQLQueryCellRef {
|
|
49
49
|
return new RQLQueryCellRef(this.queryUUID, row, column);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -17,7 +17,7 @@ export class RQLQueryRowRef {
|
|
|
17
17
|
*
|
|
18
18
|
* @category Api
|
|
19
19
|
*/
|
|
20
|
-
column(c: number): RQLQueryCellRef {
|
|
20
|
+
column(c: number | string): RQLQueryCellRef {
|
|
21
21
|
return new RQLQueryCellRef(this.queryUUID, this.row, c);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -38,6 +38,6 @@ export class RQLQueryCellRef {
|
|
|
38
38
|
constructor(
|
|
39
39
|
public readonly queryUUID: string,
|
|
40
40
|
public readonly row: number,
|
|
41
|
-
public readonly column: number
|
|
41
|
+
public readonly column: number | string
|
|
42
42
|
) {}
|
|
43
43
|
}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { getQueryIndexInTransaction } from "../../utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
RawResultSet,
|
|
4
|
+
ResultSet,
|
|
5
|
+
ResultSetCell,
|
|
6
|
+
ResultSetRow,
|
|
7
|
+
} from "../ResultSet.js";
|
|
3
8
|
import { RQLQuery } from "../query/RQLQuery.js";
|
|
4
9
|
import { RQLQueryCellRef, RQLQueryRowRef } from "../query/references.js";
|
|
5
10
|
import { Transaction } from "./Transaction.js";
|
|
6
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Interface representing the json returned by the API when executing
|
|
14
|
+
* a Transaction
|
|
15
|
+
*
|
|
16
|
+
* @category Api
|
|
17
|
+
*/
|
|
18
|
+
export interface RawTransactionResult {
|
|
19
|
+
readonly result_sets: RawResultSet[];
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
/**
|
|
8
23
|
* Class representing the result of a transaction.
|
|
9
24
|
*
|
|
@@ -24,23 +39,30 @@ import { Transaction } from "./Transaction.js";
|
|
|
24
39
|
* @category Api
|
|
25
40
|
*/
|
|
26
41
|
export class TransactionResult {
|
|
42
|
+
private rawResultSets: RawResultSet[];
|
|
43
|
+
|
|
27
44
|
constructor(
|
|
28
45
|
private transaction: Transaction,
|
|
29
|
-
|
|
30
|
-
) {
|
|
46
|
+
rawTransactionResult: RawTransactionResult
|
|
47
|
+
) {
|
|
48
|
+
this.rawResultSets = rawTransactionResult.result_sets;
|
|
49
|
+
}
|
|
31
50
|
|
|
32
51
|
getResultSet(query: RQLQuery): ResultSet {
|
|
33
52
|
const index = getQueryIndexInTransaction(this.transaction, query.queryUUID);
|
|
34
|
-
|
|
53
|
+
const resultSet = new ResultSet(this.rawResultSets[index]);
|
|
54
|
+
return resultSet;
|
|
35
55
|
}
|
|
36
56
|
|
|
37
57
|
getRow(ref: RQLQueryRowRef): ResultSetRow {
|
|
38
58
|
const index = getQueryIndexInTransaction(this.transaction, ref.queryUUID);
|
|
39
|
-
|
|
59
|
+
const resultSet = new ResultSet(this.rawResultSets[index]);
|
|
60
|
+
return resultSet.getRow(ref.row);
|
|
40
61
|
}
|
|
41
62
|
|
|
42
63
|
getCell(ref: RQLQueryCellRef): ResultSetCell {
|
|
43
64
|
const index = getQueryIndexInTransaction(this.transaction, ref.queryUUID);
|
|
44
|
-
|
|
65
|
+
const resultSet = new ResultSet(this.rawResultSets[index]);
|
|
66
|
+
return resultSet.getCell(ref.row, ref.column);
|
|
45
67
|
}
|
|
46
68
|
}
|