@cubicweb/client 3.0.0-alpha.11 → 3.0.0-alpha.12
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 +11 -20
- package/lib/api/Api.d.ts +29 -21
- package/lib/api/Api.d.ts.map +1 -1
- package/lib/api/Api.js +29 -16
- package/lib/api/Api.js.map +1 -1
- package/lib/api/Client.d.ts +19 -7
- package/lib/api/Client.d.ts.map +1 -1
- package/lib/api/Client.js +20 -9
- package/lib/api/Client.js.map +1 -1
- package/lib/api/ResultSet.d.ts +25 -0
- package/lib/api/ResultSet.d.ts.map +1 -0
- package/lib/api/ResultSet.js +12 -0
- package/lib/api/ResultSet.js.map +1 -0
- package/lib/api/binary/RQLBinary.d.ts +6 -0
- package/lib/api/binary/RQLBinary.d.ts.map +1 -0
- package/lib/api/binary/RQLBinary.js +10 -0
- package/lib/api/binary/RQLBinary.js.map +1 -0
- package/lib/api/query/RQLQuery.d.ts +40 -0
- package/lib/api/query/RQLQuery.d.ts.map +1 -0
- package/lib/api/query/RQLQuery.js +48 -0
- package/lib/api/query/RQLQuery.js.map +1 -0
- package/lib/api/query/references.d.ts +41 -0
- package/lib/api/query/references.d.ts.map +1 -0
- package/lib/api/query/references.js +50 -0
- package/lib/api/query/references.js.map +1 -0
- package/lib/api/transaction/Transaction.d.ts +25 -0
- package/lib/api/transaction/Transaction.d.ts.map +1 -0
- package/lib/api/transaction/Transaction.js +28 -0
- package/lib/api/transaction/Transaction.js.map +1 -0
- package/lib/api/transaction/TransactionResult.d.ts +32 -0
- package/lib/api/transaction/TransactionResult.d.ts.map +1 -0
- package/lib/api/transaction/TransactionResult.js +41 -0
- package/lib/api/transaction/TransactionResult.js.map +1 -0
- package/lib/{Errors.d.ts → errors.d.ts} +7 -4
- package/lib/errors.d.ts.map +1 -0
- package/lib/{Errors.js → errors.js} +7 -7
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +8 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -3
- package/lib/index.js.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.js +1 -1
- package/lib/schema/raw/Constraints.d.ts +27 -0
- package/lib/schema/raw/Constraints.d.ts.map +1 -1
- package/lib/utils.d.ts +39 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +58 -0
- package/lib/utils.js.map +1 -0
- package/package.json +7 -1
- package/src/api/Api.ts +48 -41
- package/src/api/Client.ts +23 -18
- package/src/api/ResultSet.ts +29 -0
- package/src/api/binary/RQLBinary.ts +9 -0
- package/src/api/query/RQLQuery.ts +51 -0
- package/src/api/query/references.ts +43 -0
- package/src/api/transaction/Transaction.ts +31 -0
- package/src/api/transaction/TransactionResult.ts +46 -0
- package/src/{Errors.ts → errors.ts} +6 -7
- package/src/index.ts +11 -7
- package/src/schema/classes/RelationDefinitionSchema.ts +1 -1
- package/src/schema/raw/Constraints.ts +28 -0
- package/src/utils.ts +91 -0
- package/lib/Errors.d.ts.map +0 -1
- package/lib/Errors.js.map +0 -1
- package/lib/api/Transaction.d.ts +0 -46
- package/lib/api/Transaction.d.ts.map +0 -1
- package/lib/api/Transaction.js +0 -72
- package/lib/api/Transaction.js.map +0 -1
- package/src/api/Transaction.ts +0 -94
package/src/utils.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { RQLQueryParams, RQLQueryParamValue } from "./api/Api";
|
|
2
|
+
import { RQLBinary } from "./api/binary/RQLBinary";
|
|
3
|
+
import { RQLQuery } from "./api/query/RQLQuery";
|
|
4
|
+
import { RQLQueryCellRef } from "./api/query/references";
|
|
5
|
+
import { Transaction } from "./api/transaction/Transaction";
|
|
6
|
+
|
|
7
|
+
type SerializedRQLParams = Record<
|
|
8
|
+
string,
|
|
9
|
+
RQLQueryParamValue | SerializedRqlQueryCellRef | SerializedRqlQueryBinaryRef
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
interface SerializedRqlQueryCellRef {
|
|
13
|
+
readonly queryIndex: number;
|
|
14
|
+
readonly row: number;
|
|
15
|
+
readonly column: number;
|
|
16
|
+
readonly type: "query_reference";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface SerializedRqlQueryBinaryRef {
|
|
20
|
+
readonly ref: string;
|
|
21
|
+
readonly type: "binary_reference";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves the query index in the given transaction from its eid
|
|
26
|
+
*
|
|
27
|
+
* @param transaction The transaction to search the query in
|
|
28
|
+
* @param queryUUID The UUID of the query to find
|
|
29
|
+
* @returns The query index in the transaction if found
|
|
30
|
+
* @throws When no query with the given UUID is found
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export function getQueryIndexInTransaction(
|
|
35
|
+
transaction: Transaction,
|
|
36
|
+
queryUUID: string
|
|
37
|
+
) {
|
|
38
|
+
const index = transaction.queries.findIndex((q) => q.queryUUID === queryUUID);
|
|
39
|
+
if (index < 0) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Cannot find query of id '${queryUUID}' in the transaction`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return index;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Serializes the user parameters to the format understood by the API
|
|
49
|
+
*
|
|
50
|
+
* @param params The params passed by the user
|
|
51
|
+
* @returns A serialized version of the parameters as understood by the API
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export function serializeQueryParams(
|
|
56
|
+
transaction: Transaction,
|
|
57
|
+
params: RQLQueryParams
|
|
58
|
+
) {
|
|
59
|
+
const newParams: SerializedRQLParams = {};
|
|
60
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
61
|
+
if (v instanceof RQLQueryCellRef) {
|
|
62
|
+
const queryIndex = getQueryIndexInTransaction(transaction, v.queryUUID);
|
|
63
|
+
newParams[k] = {
|
|
64
|
+
queryIndex,
|
|
65
|
+
column: v.column,
|
|
66
|
+
row: v.row,
|
|
67
|
+
type: "query_reference",
|
|
68
|
+
} as SerializedRqlQueryCellRef;
|
|
69
|
+
} else if (v instanceof RQLBinary) {
|
|
70
|
+
newParams[k] = {
|
|
71
|
+
ref: v.uuid,
|
|
72
|
+
type: "binary_reference",
|
|
73
|
+
} as SerializedRqlQueryBinaryRef;
|
|
74
|
+
} else {
|
|
75
|
+
newParams[k] = k;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return newParams;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function getBinariesFromTransaction(
|
|
82
|
+
transaction: Transaction
|
|
83
|
+
): RQLBinary[] {
|
|
84
|
+
return transaction.queries.flatMap(getBinariesFromRQLQuery);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getBinariesFromRQLQuery(query: RQLQuery): RQLBinary[] {
|
|
88
|
+
return Object.values(query.params).filter(
|
|
89
|
+
(p): p is RQLBinary => p instanceof RQLBinary
|
|
90
|
+
);
|
|
91
|
+
}
|
package/lib/Errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;;CAKhD"}
|
package/lib/Errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/lib/api/Transaction.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RQLParams, ResultSet } from "./Api.js";
|
|
2
|
-
export type BinariesParam = Record<string, Blob>;
|
|
3
|
-
export declare class Transaction {
|
|
4
|
-
private _queries;
|
|
5
|
-
private _binaries;
|
|
6
|
-
push(query: string, params: RQLParams): TransactionQuery;
|
|
7
|
-
setBinaries(binaries?: BinariesParam): void;
|
|
8
|
-
get binaries(): BinariesParam;
|
|
9
|
-
get queries(): ReadonlyArray<TransactionQuery>;
|
|
10
|
-
}
|
|
11
|
-
export declare class TransactionQuery {
|
|
12
|
-
readonly query: string;
|
|
13
|
-
readonly params: RQLParams;
|
|
14
|
-
readonly index: number;
|
|
15
|
-
constructor(query: string, params: RQLParams, index: number);
|
|
16
|
-
ref(): TransactionQueryRef;
|
|
17
|
-
}
|
|
18
|
-
export declare class TransactionResult {
|
|
19
|
-
private resultSets;
|
|
20
|
-
constructor(resultSets: ReadonlyArray<ResultSet>);
|
|
21
|
-
resolveQuery(ref: TransactionQueryRef): ResultSet;
|
|
22
|
-
resolveRow(ref: TransactionQueryRowRef): import("./Api.js").RqlRow;
|
|
23
|
-
resolveScalar(ref: TransactionQueryScalarRef): string | number | boolean | null;
|
|
24
|
-
}
|
|
25
|
-
export declare class TransactionQueryRef {
|
|
26
|
-
readonly queryIndex: number;
|
|
27
|
-
constructor(queryIndex: number);
|
|
28
|
-
row(r: number): TransactionQueryRowRef;
|
|
29
|
-
}
|
|
30
|
-
export declare class TransactionQueryRowRef {
|
|
31
|
-
readonly queryIndex: number;
|
|
32
|
-
readonly row: number;
|
|
33
|
-
constructor(queryIndex: number, row: number);
|
|
34
|
-
column(c: number): TransactionQueryScalarRef;
|
|
35
|
-
}
|
|
36
|
-
export interface TransactionQueryScalarRef {
|
|
37
|
-
readonly queryIndex: number;
|
|
38
|
-
readonly row: number;
|
|
39
|
-
readonly column: number;
|
|
40
|
-
readonly type: "query_reference";
|
|
41
|
-
}
|
|
42
|
-
export interface TransactionQueryBinaryRef {
|
|
43
|
-
readonly ref: string;
|
|
44
|
-
readonly type: "binary_reference";
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEjD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,SAAS,CAAqB;IAEtC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,gBAAgB;IAUxD,WAAW,CAAC,QAAQ,CAAC,EAAE,aAAa;IAIpC,IAAI,QAAQ,IAAI,aAAa,CAE5B;IAED,IAAI,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAE7C;CACF;AAED,qBAAa,gBAAgB;aAET,KAAK,EAAE,MAAM;aACb,MAAM,EAAE,SAAS;aACjB,KAAK,EAAE,MAAM;gBAFb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM;IAG/B,GAAG,IAAI,mBAAmB;CAG3B;AAED,qBAAa,iBAAiB;IAChB,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC;IAExD,YAAY,CAAC,GAAG,EAAE,mBAAmB;IAIrC,UAAU,CAAC,GAAG,EAAE,sBAAsB;IAItC,aAAa,CAAC,GAAG,EAAE,yBAAyB;CAG7C;AAED,qBAAa,mBAAmB;aACF,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM;IAE9C,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,sBAAsB;CAGvC;AAED,qBAAa,sBAAsB;aAEf,UAAU,EAAE,MAAM;aAClB,GAAG,EAAE,MAAM;gBADX,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM;IAG7B,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,yBAAyB;CAQ7C;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;CAClC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CACnC"}
|
package/lib/api/Transaction.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export class Transaction {
|
|
2
|
-
_queries = [];
|
|
3
|
-
_binaries = {};
|
|
4
|
-
push(query, params) {
|
|
5
|
-
const stackedQuery = new TransactionQuery(query, params, this._queries.length);
|
|
6
|
-
this._queries.push(stackedQuery);
|
|
7
|
-
return stackedQuery;
|
|
8
|
-
}
|
|
9
|
-
setBinaries(binaries) {
|
|
10
|
-
this._binaries = binaries ?? {};
|
|
11
|
-
}
|
|
12
|
-
get binaries() {
|
|
13
|
-
return this._binaries;
|
|
14
|
-
}
|
|
15
|
-
get queries() {
|
|
16
|
-
return this._queries;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export class TransactionQuery {
|
|
20
|
-
query;
|
|
21
|
-
params;
|
|
22
|
-
index;
|
|
23
|
-
constructor(query, params, index) {
|
|
24
|
-
this.query = query;
|
|
25
|
-
this.params = params;
|
|
26
|
-
this.index = index;
|
|
27
|
-
}
|
|
28
|
-
ref() {
|
|
29
|
-
return new TransactionQueryRef(this.index);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export class TransactionResult {
|
|
33
|
-
resultSets;
|
|
34
|
-
constructor(resultSets) {
|
|
35
|
-
this.resultSets = resultSets;
|
|
36
|
-
}
|
|
37
|
-
resolveQuery(ref) {
|
|
38
|
-
return this.resultSets[ref.queryIndex];
|
|
39
|
-
}
|
|
40
|
-
resolveRow(ref) {
|
|
41
|
-
return this.resultSets[ref.queryIndex][ref.row];
|
|
42
|
-
}
|
|
43
|
-
resolveScalar(ref) {
|
|
44
|
-
return this.resultSets[ref.queryIndex][ref.row][ref.column];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export class TransactionQueryRef {
|
|
48
|
-
queryIndex;
|
|
49
|
-
constructor(queryIndex) {
|
|
50
|
-
this.queryIndex = queryIndex;
|
|
51
|
-
}
|
|
52
|
-
row(r) {
|
|
53
|
-
return new TransactionQueryRowRef(this.queryIndex, r);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export class TransactionQueryRowRef {
|
|
57
|
-
queryIndex;
|
|
58
|
-
row;
|
|
59
|
-
constructor(queryIndex, row) {
|
|
60
|
-
this.queryIndex = queryIndex;
|
|
61
|
-
this.row = row;
|
|
62
|
-
}
|
|
63
|
-
column(c) {
|
|
64
|
-
return {
|
|
65
|
-
type: "query_reference",
|
|
66
|
-
queryIndex: this.queryIndex,
|
|
67
|
-
row: this.row,
|
|
68
|
-
column: c,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=Transaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,WAAW;IACd,QAAQ,GAA4B,EAAE,CAAC;IACvC,SAAS,GAAkB,EAAE,CAAC;IAEtC,IAAI,CAAC,KAAa,EAAE,MAAiB;QACnC,MAAM,YAAY,GAAG,IAAI,gBAAgB,CACvC,KAAK,EACL,MAAM,EACN,IAAI,CAAC,QAAQ,CAAC,MAAM,CACrB,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,WAAW,CAAC,QAAwB;QAClC,IAAI,CAAC,SAAS,GAAG,QAAQ,IAAI,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IAET;IACA;IACA;IAHlB,YACkB,KAAa,EACb,MAAiB,EACjB,KAAa;QAFb,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAW;QACjB,UAAK,GAAL,KAAK,CAAQ;IAC5B,CAAC;IAEJ,GAAG;QACD,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,OAAO,iBAAiB;IACR;IAApB,YAAoB,UAAoC;QAApC,eAAU,GAAV,UAAU,CAA0B;IAAG,CAAC;IAE5D,YAAY,CAAC,GAAwB;QACnC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,UAAU,CAAC,GAA2B;QACpC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,aAAa,CAAC,GAA8B;QAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;CACF;AAED,MAAM,OAAO,mBAAmB;IACF;IAA5B,YAA4B,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;IAElD,GAAG,CAAC,CAAS;QACX,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAED,MAAM,OAAO,sBAAsB;IAEf;IACA;IAFlB,YACkB,UAAkB,EAClB,GAAW;QADX,eAAU,GAAV,UAAU,CAAQ;QAClB,QAAG,GAAH,GAAG,CAAQ;IAC1B,CAAC;IAEJ,MAAM,CAAC,CAAS;QACd,OAAO;YACL,IAAI,EAAE,iBAAiB;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,CAAC;SACV,CAAC;IACJ,CAAC;CACF"}
|
package/src/api/Transaction.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { RQLParams, ResultSet } from "./Api.js";
|
|
2
|
-
|
|
3
|
-
export type BinariesParam = Record<string, Blob>;
|
|
4
|
-
|
|
5
|
-
export class Transaction {
|
|
6
|
-
private _queries: Array<TransactionQuery> = [];
|
|
7
|
-
private _binaries: BinariesParam = {};
|
|
8
|
-
|
|
9
|
-
push(query: string, params: RQLParams): TransactionQuery {
|
|
10
|
-
const stackedQuery = new TransactionQuery(
|
|
11
|
-
query,
|
|
12
|
-
params,
|
|
13
|
-
this._queries.length
|
|
14
|
-
);
|
|
15
|
-
this._queries.push(stackedQuery);
|
|
16
|
-
return stackedQuery;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
setBinaries(binaries?: BinariesParam) {
|
|
20
|
-
this._binaries = binaries ?? {};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get binaries(): BinariesParam {
|
|
24
|
-
return this._binaries;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get queries(): ReadonlyArray<TransactionQuery> {
|
|
28
|
-
return this._queries;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export class TransactionQuery {
|
|
33
|
-
constructor(
|
|
34
|
-
public readonly query: string,
|
|
35
|
-
public readonly params: RQLParams,
|
|
36
|
-
public readonly index: number
|
|
37
|
-
) {}
|
|
38
|
-
|
|
39
|
-
ref(): TransactionQueryRef {
|
|
40
|
-
return new TransactionQueryRef(this.index);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export class TransactionResult {
|
|
45
|
-
constructor(private resultSets: ReadonlyArray<ResultSet>) {}
|
|
46
|
-
|
|
47
|
-
resolveQuery(ref: TransactionQueryRef) {
|
|
48
|
-
return this.resultSets[ref.queryIndex];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
resolveRow(ref: TransactionQueryRowRef) {
|
|
52
|
-
return this.resultSets[ref.queryIndex][ref.row];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
resolveScalar(ref: TransactionQueryScalarRef) {
|
|
56
|
-
return this.resultSets[ref.queryIndex][ref.row][ref.column];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class TransactionQueryRef {
|
|
61
|
-
constructor(public readonly queryIndex: number) {}
|
|
62
|
-
|
|
63
|
-
row(r: number): TransactionQueryRowRef {
|
|
64
|
-
return new TransactionQueryRowRef(this.queryIndex, r);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class TransactionQueryRowRef {
|
|
69
|
-
constructor(
|
|
70
|
-
public readonly queryIndex: number,
|
|
71
|
-
public readonly row: number
|
|
72
|
-
) {}
|
|
73
|
-
|
|
74
|
-
column(c: number): TransactionQueryScalarRef {
|
|
75
|
-
return {
|
|
76
|
-
type: "query_reference",
|
|
77
|
-
queryIndex: this.queryIndex,
|
|
78
|
-
row: this.row,
|
|
79
|
-
column: c,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface TransactionQueryScalarRef {
|
|
85
|
-
readonly queryIndex: number;
|
|
86
|
-
readonly row: number;
|
|
87
|
-
readonly column: number;
|
|
88
|
-
readonly type: "query_reference";
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface TransactionQueryBinaryRef {
|
|
92
|
-
readonly ref: string;
|
|
93
|
-
readonly type: "binary_reference";
|
|
94
|
-
}
|