@cubicweb/client 3.0.0-alpha.9 → 3.0.2
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 +58 -34
- package/lib/Authenticator.d.ts +8 -0
- package/lib/Authenticator.d.ts.map +1 -0
- package/lib/Authenticator.js +2 -0
- package/lib/Authenticator.js.map +1 -0
- package/lib/api/Api.d.ts +56 -23
- package/lib/api/Api.d.ts.map +1 -1
- package/lib/api/Api.js +152 -149
- package/lib/api/Api.js.map +1 -1
- package/lib/api/Client.d.ts +26 -10
- package/lib/api/Client.d.ts.map +1 -1
- package/lib/api/Client.js +41 -58
- package/lib/api/Client.js.map +1 -1
- package/lib/api/ResultSet.d.ts +52 -0
- package/lib/api/ResultSet.d.ts.map +1 -0
- package/lib/api/ResultSet.js +64 -0
- package/lib/api/ResultSet.js.map +1 -0
- package/lib/api/authenticators/CookieAuthenticator.d.ts +10 -0
- package/lib/api/authenticators/CookieAuthenticator.d.ts.map +1 -0
- package/lib/api/authenticators/CookieAuthenticator.js +11 -0
- package/lib/api/authenticators/CookieAuthenticator.js.map +1 -0
- package/lib/api/authenticators/SignedRequestAuthenticator.d.ts +32 -0
- package/lib/api/authenticators/SignedRequestAuthenticator.d.ts.map +1 -0
- package/lib/api/authenticators/SignedRequestAuthenticator.js +89 -0
- package/lib/api/authenticators/SignedRequestAuthenticator.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 +41 -0
- package/lib/api/transaction/TransactionResult.d.ts.map +1 -0
- package/lib/api/transaction/TransactionResult.js +45 -0
- package/lib/api/transaction/TransactionResult.js.map +1 -0
- package/lib/encodeFormData.d.ts +5 -0
- package/lib/encodeFormData.d.ts.map +1 -0
- package/lib/encodeFormData.js +94 -0
- package/lib/encodeFormData.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 +19 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +19 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +17 -34
- package/lib/index.js.map +1 -1
- package/lib/schema/classes/EntitySchema.d.ts +5 -5
- package/lib/schema/classes/EntitySchema.d.ts.map +1 -1
- package/lib/schema/classes/EntitySchema.js +3 -5
- package/lib/schema/classes/EntitySchema.js.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.d.ts +6 -6
- package/lib/schema/classes/RelationDefinitionSchema.d.ts.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.js +8 -10
- package/lib/schema/classes/RelationDefinitionSchema.js.map +1 -1
- package/lib/schema/classes/Schema.d.ts +7 -7
- package/lib/schema/classes/Schema.d.ts.map +1 -1
- package/lib/schema/classes/Schema.js +8 -11
- package/lib/schema/classes/Schema.js.map +1 -1
- package/lib/schema/classes/Utils.d.ts +10 -10
- package/lib/schema/classes/Utils.d.ts.map +1 -1
- package/lib/schema/classes/Utils.js +19 -35
- package/lib/schema/classes/Utils.js.map +1 -1
- package/lib/schema/raw/Constraints.d.ts +27 -0
- package/lib/schema/raw/Constraints.d.ts.map +1 -1
- package/lib/schema/raw/Constraints.js +1 -2
- package/lib/schema/raw/Entities.js +1 -2
- package/lib/schema/raw/RelationDefinitions.d.ts +3 -3
- package/lib/schema/raw/RelationDefinitions.d.ts.map +1 -1
- package/lib/schema/raw/RelationDefinitions.js +1 -2
- package/lib/schema/raw/Schema.d.ts +2 -2
- package/lib/schema/raw/Schema.d.ts.map +1 -1
- package/lib/schema/raw/Schema.js +1 -2
- package/lib/schema/raw/Utils.d.ts +1 -1
- package/lib/schema/raw/Utils.d.ts.map +1 -1
- package/lib/schema/raw/Utils.js +1 -2
- 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 +15 -5
- package/src/Authenticator.ts +8 -0
- package/src/api/Api.ts +154 -125
- package/src/api/Client.ts +31 -18
- package/src/api/ResultSet.ts +95 -0
- package/src/api/authenticators/CookieAuthenticator.ts +17 -0
- package/src/api/authenticators/SignedRequestAuthenticator.ts +133 -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 +68 -0
- package/src/encodeFormData.ts +126 -0
- package/src/{Errors.ts → errors.ts} +6 -7
- package/src/index.ts +24 -17
- package/src/schema/classes/EntitySchema.ts +8 -5
- package/src/schema/classes/RelationDefinitionSchema.ts +7 -7
- package/src/schema/classes/Schema.ts +10 -7
- package/src/schema/classes/Utils.ts +4 -4
- package/src/schema/raw/Constraints.ts +28 -0
- package/src/schema/raw/RelationDefinitions.ts +3 -3
- package/src/schema/raw/Schema.ts +2 -2
- package/src/schema/raw/Utils.ts +1 -1
- package/src/utils.ts +91 -0
- package/lib/Errors.d.ts.map +0 -1
- package/lib/Errors.js +0 -25
- 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 -75
- package/lib/api/Transaction.js.map +0 -1
- package/src/api/Transaction.ts +0 -94
|
@@ -14,16 +14,25 @@ type ConstraintBase<
|
|
|
14
14
|
*/
|
|
15
15
|
type ConstraintMessage = string | null;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* A Unique constraint on an attribute.
|
|
19
|
+
*/
|
|
17
20
|
export type UniqueConstraint = ConstraintBase<
|
|
18
21
|
"UniqueConstraint",
|
|
19
22
|
{ msg: ConstraintMessage }
|
|
20
23
|
>;
|
|
21
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A constraint on the size of a string
|
|
27
|
+
*/
|
|
22
28
|
export type SizeConstraint = ConstraintBase<
|
|
23
29
|
"SizeConstraint",
|
|
24
30
|
{ min: number | null; max: number | null; msg: ConstraintMessage }
|
|
25
31
|
>;
|
|
26
32
|
|
|
33
|
+
/**
|
|
34
|
+
* A Regexp constraint on a string
|
|
35
|
+
*/
|
|
27
36
|
export type RegexpConstraint = ConstraintBase<
|
|
28
37
|
"RegexpConstraint",
|
|
29
38
|
{ regexp: string; flags: number; msg: ConstraintMessage }
|
|
@@ -81,6 +90,9 @@ export interface Now {
|
|
|
81
90
|
*/
|
|
82
91
|
export type ConstraintOperator = ">" | ">=" | "<" | "<=";
|
|
83
92
|
|
|
93
|
+
/**
|
|
94
|
+
* A boundary constraint on a number attribute.
|
|
95
|
+
*/
|
|
84
96
|
export type BoundaryConstraint = ConstraintBase<
|
|
85
97
|
"BoundaryConstraint",
|
|
86
98
|
{
|
|
@@ -89,6 +101,10 @@ export type BoundaryConstraint = ConstraintBase<
|
|
|
89
101
|
msg: ConstraintMessage;
|
|
90
102
|
}
|
|
91
103
|
>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* An interval constraint on a number attribute.
|
|
107
|
+
*/
|
|
92
108
|
export type IntervalBoundConstraint = ConstraintBase<
|
|
93
109
|
"IntervalBoundConstraint",
|
|
94
110
|
{
|
|
@@ -98,11 +114,17 @@ export type IntervalBoundConstraint = ConstraintBase<
|
|
|
98
114
|
}
|
|
99
115
|
>;
|
|
100
116
|
|
|
117
|
+
/**
|
|
118
|
+
* A static vocabulary constraint on a string attribute.
|
|
119
|
+
*/
|
|
101
120
|
export type StaticVocabularyConstraint = ConstraintBase<
|
|
102
121
|
"StaticVocabularyConstraint",
|
|
103
122
|
{ values: string[]; msg: ConstraintMessage }
|
|
104
123
|
>;
|
|
105
124
|
|
|
125
|
+
/**
|
|
126
|
+
* A format constraint on a string attribute.
|
|
127
|
+
*/
|
|
106
128
|
export type FormatConstraint = ConstraintBase<
|
|
107
129
|
"FormatConstraint",
|
|
108
130
|
{
|
|
@@ -111,11 +133,17 @@ export type FormatConstraint = ConstraintBase<
|
|
|
111
133
|
}
|
|
112
134
|
>;
|
|
113
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A vocabulary constraint on a string attribute described by a RQL.
|
|
138
|
+
*/
|
|
114
139
|
export type RQLVocabularyConstraint = ConstraintBase<
|
|
115
140
|
"RQLVocabularyConstraint",
|
|
116
141
|
{ expression: string; mainvars: string[] }
|
|
117
142
|
>;
|
|
118
143
|
|
|
144
|
+
/**
|
|
145
|
+
* A constraint on an attribute described by a RQL.
|
|
146
|
+
*/
|
|
119
147
|
export type RQLConstraint = ConstraintBase<
|
|
120
148
|
"RQLConstraint",
|
|
121
149
|
{ expression: string; mainvars: string[]; msg: ConstraintMessage }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityRole } from "../classes/Utils";
|
|
2
|
-
import { AttributeConstraint, RelationConstraint } from "./Constraints";
|
|
3
|
-
import { EntityRawSchema, EntityRawSchemaArray } from "./Entities";
|
|
1
|
+
import { EntityRole } from "../classes/Utils.js";
|
|
2
|
+
import { AttributeConstraint, RelationConstraint } from "./Constraints.js";
|
|
3
|
+
import { EntityRawSchema, EntityRawSchemaArray } from "./Entities.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Type representing all the possible cardinalities in CubicWeb.
|
package/src/schema/raw/Schema.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntityRawSchemaArray } from "./Entities";
|
|
2
|
-
import { RelationDefinitionRawSchemaArray } from "./RelationDefinitions";
|
|
1
|
+
import { EntityRawSchemaArray } from "./Entities.js";
|
|
2
|
+
import { RelationDefinitionRawSchemaArray } from "./RelationDefinitions.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The full raw JSON schema type as returned by the API.
|
package/src/schema/raw/Utils.ts
CHANGED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { RQLQueryParams, RQLQueryParamValue } from "./api/Api.js";
|
|
2
|
+
import { RQLBinary } from "./api/binary/RQLBinary.js";
|
|
3
|
+
import { RQLQuery } from "./api/query/RQLQuery.js";
|
|
4
|
+
import { RQLQueryCellRef } from "./api/query/references.js";
|
|
5
|
+
import { Transaction } from "./api/transaction/Transaction.js";
|
|
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] = v;
|
|
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
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionClosedError = exports.ValidationError = exports.InconsistentSchemaError = void 0;
|
|
4
|
-
class InconsistentSchemaError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(`Inconsistent schema: ${message}`);
|
|
7
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.InconsistentSchemaError = InconsistentSchemaError;
|
|
11
|
-
class ValidationError extends Error {
|
|
12
|
-
constructor(message) {
|
|
13
|
-
super(message);
|
|
14
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ValidationError = ValidationError;
|
|
18
|
-
class TransactionClosedError extends Error {
|
|
19
|
-
constructor() {
|
|
20
|
-
super("Trying to use a closed transaction");
|
|
21
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.TransactionClosedError = TransactionClosedError;
|
|
25
|
-
//# sourceMappingURL=Errors.js.map
|
package/lib/Errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,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;AALD,0DAKC;AAED,MAAa,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;AALD,0CAKC;AAED,MAAa,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;AALD,wDAKC"}
|
package/lib/api/Transaction.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RQLParams, ResultSet } from "./Api";
|
|
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").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,OAAO,CAAC;AAE7C,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,E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.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionQueryRowRef = exports.TransactionQueryRef = exports.TransactionResult = exports.TransactionQuery = exports.Transaction = void 0;
|
|
4
|
-
class Transaction {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._queries = [];
|
|
7
|
-
this._binaries = {};
|
|
8
|
-
}
|
|
9
|
-
push(query, params) {
|
|
10
|
-
const stackedQuery = new TransactionQuery(query, params, this._queries.length);
|
|
11
|
-
this._queries.push(stackedQuery);
|
|
12
|
-
return stackedQuery;
|
|
13
|
-
}
|
|
14
|
-
setBinaries(binaries) {
|
|
15
|
-
this._binaries = binaries !== null && binaries !== void 0 ? binaries : {};
|
|
16
|
-
}
|
|
17
|
-
get binaries() {
|
|
18
|
-
return this._binaries;
|
|
19
|
-
}
|
|
20
|
-
get queries() {
|
|
21
|
-
return this._queries;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.Transaction = Transaction;
|
|
25
|
-
class TransactionQuery {
|
|
26
|
-
constructor(query, params, index) {
|
|
27
|
-
this.query = query;
|
|
28
|
-
this.params = params;
|
|
29
|
-
this.index = index;
|
|
30
|
-
}
|
|
31
|
-
ref() {
|
|
32
|
-
return new TransactionQueryRef(this.index);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.TransactionQuery = TransactionQuery;
|
|
36
|
-
class TransactionResult {
|
|
37
|
-
constructor(resultSets) {
|
|
38
|
-
this.resultSets = resultSets;
|
|
39
|
-
}
|
|
40
|
-
resolveQuery(ref) {
|
|
41
|
-
return this.resultSets[ref.queryIndex];
|
|
42
|
-
}
|
|
43
|
-
resolveRow(ref) {
|
|
44
|
-
return this.resultSets[ref.queryIndex][ref.row];
|
|
45
|
-
}
|
|
46
|
-
resolveScalar(ref) {
|
|
47
|
-
return this.resultSets[ref.queryIndex][ref.row][ref.column];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.TransactionResult = TransactionResult;
|
|
51
|
-
class TransactionQueryRef {
|
|
52
|
-
constructor(queryIndex) {
|
|
53
|
-
this.queryIndex = queryIndex;
|
|
54
|
-
}
|
|
55
|
-
row(r) {
|
|
56
|
-
return new TransactionQueryRowRef(this.queryIndex, r);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.TransactionQueryRef = TransactionQueryRef;
|
|
60
|
-
class TransactionQueryRowRef {
|
|
61
|
-
constructor(queryIndex, row) {
|
|
62
|
-
this.queryIndex = queryIndex;
|
|
63
|
-
this.row = row;
|
|
64
|
-
}
|
|
65
|
-
column(c) {
|
|
66
|
-
return {
|
|
67
|
-
type: "query_reference",
|
|
68
|
-
queryIndex: this.queryIndex,
|
|
69
|
-
row: this.row,
|
|
70
|
-
column: c,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.TransactionQueryRowRef = TransactionQueryRowRef;
|
|
75
|
-
//# sourceMappingURL=Transaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":";;;AAIA,MAAa,WAAW;IAAxB;QACU,aAAQ,GAA4B,EAAE,CAAC;QACvC,cAAS,GAAkB,EAAE,CAAC;IAuBxC,CAAC;IArBC,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,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,Q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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;AAdD,wDAcC"}
|
package/src/api/Transaction.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { RQLParams, ResultSet } from "./Api";
|
|
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
|
-
}
|