@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/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.14 only.**
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
@@ -78,23 +78,18 @@ client
|
|
|
78
78
|
|
|
79
79
|
// Execute a series of request in a transaction
|
|
80
80
|
const transaction = new Transaction()
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
row: 0,
|
|
90
|
-
column: 0,
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
81
|
+
const insertQuery = new RQLQuery(`INSERT Person X: X name "test"`)
|
|
82
|
+
transaction.push(insertQuery)
|
|
83
|
+
transaction.push(
|
|
84
|
+
new RQLQuery(
|
|
85
|
+
`INSERT Person X: X name "test"`,
|
|
86
|
+
{ created_eid: insertQuery.cellRef(0, 0) }
|
|
87
|
+
)
|
|
88
|
+
)
|
|
94
89
|
client
|
|
95
90
|
.executeTransaction(transaction)
|
|
96
91
|
.then((callbackResult) => {
|
|
97
|
-
console.log("Transaction was
|
|
92
|
+
console.log("Transaction was successful and the callback returned:");
|
|
98
93
|
console.log(callbackResult);
|
|
99
94
|
})
|
|
100
95
|
.catch((e) => {
|
|
@@ -122,11 +117,7 @@ you must authorize the URL the client is running on as well as the `Content-Type
|
|
|
122
117
|
|
|
123
118
|
## Authentication
|
|
124
119
|
|
|
125
|
-
The API cube uses cookie authentication
|
|
126
|
-
A `CW_JWT` [HTTP Only](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#security) cookie
|
|
127
|
-
will be automatically created by the browser when executing the login request.
|
|
128
|
-
This cookie cannot be accessed by the JavaScript so you will have to implement your own
|
|
129
|
-
logic to save the login state.
|
|
120
|
+
The API cube uses a cookie authentication method by default. When you call the login route, the cookie will be automatically created by the browser.
|
|
130
121
|
|
|
131
122
|
If the client is running on a different server from your CubicWeb instance,
|
|
132
123
|
make sure you setup CORS as described above.
|
package/lib/api/Api.d.ts
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import { RawSchema } from "../schema/raw/Schema.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RQLBinary } from "./binary/RQLBinary.js";
|
|
3
|
+
import { RQLQueryCellRef } from "./query/references.js";
|
|
4
|
+
import { Transaction } from "./transaction/Transaction.js";
|
|
5
|
+
import { TransactionResult } from "./transaction/TransactionResult.js";
|
|
3
6
|
/**
|
|
4
|
-
* Type representing
|
|
7
|
+
* Type representing valid final values to use as parameters in a RQL query.
|
|
8
|
+
*
|
|
9
|
+
* For references to requests/binaries, see {@link RQLQueryCellRef} and {@link RQLQueryBinaryRef}
|
|
5
10
|
*
|
|
6
11
|
* @category Api
|
|
7
12
|
*/
|
|
8
|
-
export type
|
|
9
|
-
export type RQLParamValue = string | number | boolean | null;
|
|
13
|
+
export type RQLQueryParamValue = string | number | boolean | null;
|
|
10
14
|
/**
|
|
11
15
|
* Type representing RQL parameters to send along a request.
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export type RQLParams = Record<string, RQLParamValue | TransactionQueryScalarRef | TransactionQueryBinaryRef>;
|
|
16
|
-
/**
|
|
17
|
-
* Type representing a row returned in a result set.
|
|
17
|
+
* Each key must be referenced in the RQL query.
|
|
18
18
|
*
|
|
19
19
|
* @category Api
|
|
20
20
|
*/
|
|
21
|
-
export type
|
|
21
|
+
export type RQLQueryParams = Record<string, RQLQueryParamValue | RQLQueryCellRef | RQLBinary>;
|
|
22
22
|
/**
|
|
23
|
-
* Type representing
|
|
24
|
-
*
|
|
25
|
-
* @category Api
|
|
26
|
-
*/
|
|
27
|
-
export type ResultSet = Array<RqlRow>;
|
|
28
|
-
/**
|
|
29
|
-
* Type representing the currently logged user's data
|
|
23
|
+
* Type representing the currently logged user's data as returned by the `/current-user` route
|
|
30
24
|
*
|
|
31
25
|
* @category Api
|
|
32
26
|
*/
|
|
@@ -48,6 +42,9 @@ type ApiError = {
|
|
|
48
42
|
/**
|
|
49
43
|
* Type representing the error data sent to clients when retrieving an API error.
|
|
50
44
|
*
|
|
45
|
+
* It simply adds the HTTP status code in a `status` key to the regular CubicWeb api error,
|
|
46
|
+
* so users can handle HTTP status codes in their code.
|
|
47
|
+
*
|
|
51
48
|
* @category Api
|
|
52
49
|
*/
|
|
53
50
|
export type ApiErrorResponse = {
|
|
@@ -57,7 +54,7 @@ export type ApiErrorResponse = {
|
|
|
57
54
|
* Class used to handle requests to the CubicWeb API.
|
|
58
55
|
*
|
|
59
56
|
* You should never have to create this object yourself.
|
|
60
|
-
* Instead, retrieve this object from the methods in the
|
|
57
|
+
* Instead, retrieve this object from the methods in the {@link Client} class.
|
|
61
58
|
*
|
|
62
59
|
* @internal
|
|
63
60
|
*/
|
|
@@ -74,7 +71,7 @@ export default class Api {
|
|
|
74
71
|
* Class used to handle requests to the CubicWeb API.
|
|
75
72
|
*
|
|
76
73
|
* You should never have to create this object yourself.
|
|
77
|
-
* Instead, retrieve this object from the methods in the
|
|
74
|
+
* Instead, retrieve this object from the methods in the {@link Client} class.
|
|
78
75
|
*
|
|
79
76
|
* @param apiUrl The API url. It should not include the API version as it will be automatically added.
|
|
80
77
|
* Example: if you can retrieve the schema with https://example.com/api/v1/schema,
|
|
@@ -93,7 +90,7 @@ export default class Api {
|
|
|
93
90
|
* Tries to log in the user on the configured CubicWeb instance with the given credentials.
|
|
94
91
|
*
|
|
95
92
|
* @param login The user login
|
|
96
|
-
* @param password
|
|
93
|
+
* @param password The user password
|
|
97
94
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
98
95
|
*/
|
|
99
96
|
login(login: string, password: string): Promise<boolean>;
|
|
@@ -112,9 +109,20 @@ export default class Api {
|
|
|
112
109
|
/**
|
|
113
110
|
* Get the binary for the given entity attribute
|
|
114
111
|
*
|
|
115
|
-
* @
|
|
112
|
+
* @param eid Entity eid to fetch the binary from
|
|
113
|
+
* @param attribute Attribute on the entity in which the binary is stored
|
|
114
|
+
* @returns A promise resolving to the binary as a Blob
|
|
116
115
|
*/
|
|
117
116
|
binary(eid: number, attribute: string): Promise<Blob>;
|
|
117
|
+
/**
|
|
118
|
+
* Executes the given transaction.
|
|
119
|
+
*
|
|
120
|
+
* If the {@link Transaction} object contains binaries, the request is automatically
|
|
121
|
+
* sent using `multipart/form-data` to allow uploading binaries.
|
|
122
|
+
*
|
|
123
|
+
* @param transaction Transaction to execute
|
|
124
|
+
* @returns A promise returning the transaction result on success
|
|
125
|
+
*/
|
|
118
126
|
rql(transaction: Transaction): Promise<TransactionResult>;
|
|
119
127
|
private getTransactionParams;
|
|
120
128
|
private multipartTransaction;
|
package/lib/api/Api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CACjC,MAAM,EACN,kBAAkB,GAAG,eAAe,GAAG,SAAS,CACjD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,QAAQ,CAAC;AAEb;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,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,10 +1,11 @@
|
|
|
1
|
-
import { ValidationError } from "../
|
|
2
|
-
import {
|
|
1
|
+
import { ValidationError } from "../errors.js";
|
|
2
|
+
import { getBinariesFromTransaction, serializeQueryParams } from "../utils.js";
|
|
3
|
+
import { TransactionResult } from "./transaction/TransactionResult.js";
|
|
3
4
|
/**
|
|
4
5
|
* Class used to handle requests to the CubicWeb API.
|
|
5
6
|
*
|
|
6
7
|
* You should never have to create this object yourself.
|
|
7
|
-
* Instead, retrieve this object from the methods in the
|
|
8
|
+
* Instead, retrieve this object from the methods in the {@link Client} class.
|
|
8
9
|
*
|
|
9
10
|
* @internal
|
|
10
11
|
*/
|
|
@@ -21,7 +22,7 @@ export default class Api {
|
|
|
21
22
|
* Class used to handle requests to the CubicWeb API.
|
|
22
23
|
*
|
|
23
24
|
* You should never have to create this object yourself.
|
|
24
|
-
* Instead, retrieve this object from the methods in the
|
|
25
|
+
* Instead, retrieve this object from the methods in the {@link Client} class.
|
|
25
26
|
*
|
|
26
27
|
* @param apiUrl The API url. It should not include the API version as it will be automatically added.
|
|
27
28
|
* Example: if you can retrieve the schema with https://example.com/api/v1/schema,
|
|
@@ -57,7 +58,7 @@ export default class Api {
|
|
|
57
58
|
* Tries to log in the user on the configured CubicWeb instance with the given credentials.
|
|
58
59
|
*
|
|
59
60
|
* @param login The user login
|
|
60
|
-
* @param password
|
|
61
|
+
* @param password The user password
|
|
61
62
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
62
63
|
*/
|
|
63
64
|
async login(login, password) {
|
|
@@ -101,7 +102,9 @@ export default class Api {
|
|
|
101
102
|
/**
|
|
102
103
|
* Get the binary for the given entity attribute
|
|
103
104
|
*
|
|
104
|
-
* @
|
|
105
|
+
* @param eid Entity eid to fetch the binary from
|
|
106
|
+
* @param attribute Attribute on the entity in which the binary is stored
|
|
107
|
+
* @returns A promise resolving to the binary as a Blob
|
|
105
108
|
*/
|
|
106
109
|
async binary(eid, attribute) {
|
|
107
110
|
const params = new URLSearchParams({
|
|
@@ -113,10 +116,20 @@ export default class Api {
|
|
|
113
116
|
credentials: "include",
|
|
114
117
|
});
|
|
115
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Executes the given transaction.
|
|
121
|
+
*
|
|
122
|
+
* If the {@link Transaction} object contains binaries, the request is automatically
|
|
123
|
+
* sent using `multipart/form-data` to allow uploading binaries.
|
|
124
|
+
*
|
|
125
|
+
* @param transaction Transaction to execute
|
|
126
|
+
* @returns A promise returning the transaction result on success
|
|
127
|
+
*/
|
|
116
128
|
async rql(transaction) {
|
|
129
|
+
const binaries = getBinariesFromTransaction(transaction);
|
|
117
130
|
try {
|
|
118
|
-
if (
|
|
119
|
-
return await this.multipartTransaction(transaction);
|
|
131
|
+
if (binaries.length > 0) {
|
|
132
|
+
return await this.multipartTransaction(transaction, binaries);
|
|
120
133
|
}
|
|
121
134
|
else {
|
|
122
135
|
return await this.jsonTransaction(transaction);
|
|
@@ -127,24 +140,24 @@ export default class Api {
|
|
|
127
140
|
}
|
|
128
141
|
}
|
|
129
142
|
getTransactionParams(transaction) {
|
|
130
|
-
return transaction.queries.map((
|
|
131
|
-
query:
|
|
132
|
-
params:
|
|
143
|
+
return transaction.queries.map((rqlQuery) => ({
|
|
144
|
+
query: rqlQuery.rql,
|
|
145
|
+
params: serializeQueryParams(transaction, rqlQuery.params),
|
|
133
146
|
}));
|
|
134
147
|
}
|
|
135
|
-
async multipartTransaction(transaction) {
|
|
148
|
+
async multipartTransaction(transaction, binaries) {
|
|
136
149
|
const jsonParams = this.getTransactionParams(transaction);
|
|
137
150
|
const formData = new FormData();
|
|
138
151
|
formData.append("queries", JSON.stringify(jsonParams));
|
|
139
|
-
|
|
140
|
-
formData.append(
|
|
152
|
+
binaries.forEach((binary) => {
|
|
153
|
+
formData.append(binary.uuid, binary.blob);
|
|
141
154
|
});
|
|
142
155
|
const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
|
|
143
156
|
method: "POST",
|
|
144
157
|
credentials: "include",
|
|
145
158
|
body: formData,
|
|
146
159
|
});
|
|
147
|
-
return new TransactionResult(resultSets);
|
|
160
|
+
return new TransactionResult(transaction, resultSets);
|
|
148
161
|
}
|
|
149
162
|
async jsonTransaction(transaction) {
|
|
150
163
|
const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
|
|
@@ -152,7 +165,7 @@ export default class Api {
|
|
|
152
165
|
credentials: "include",
|
|
153
166
|
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
154
167
|
});
|
|
155
|
-
return new TransactionResult(resultSets);
|
|
168
|
+
return new TransactionResult(transaction, resultSets);
|
|
156
169
|
}
|
|
157
170
|
handleUserErrors(error) {
|
|
158
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,
|
|
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;AAK/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAyDvE;;;;;;;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,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,aA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,IAAI,CAAC;SACb;KACF;SAAM;QACL,IAAI,IAAI,CAAC;QACT,IAAI;YACF,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC9B;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;SAC/C;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;KAC3B;AACH,CAAC"}
|
package/lib/api/Client.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Schema } from "../schema/classes/Schema.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { RQLQueryParams, CurrentUser } from "./Api.js";
|
|
3
|
+
import { ResultSet } from "./ResultSet.js";
|
|
4
|
+
import { Transaction } from "./transaction/Transaction.js";
|
|
5
|
+
import { TransactionResult } from "./transaction/TransactionResult.js";
|
|
4
6
|
/**
|
|
5
7
|
* Class used to communicate with a CubicWeb instance's API.
|
|
6
8
|
*
|
|
@@ -20,11 +22,14 @@ export default class Client {
|
|
|
20
22
|
/**
|
|
21
23
|
* Executes the given query and waits for the response.
|
|
22
24
|
*
|
|
23
|
-
*
|
|
25
|
+
* If binaries are given, the request is automatically
|
|
26
|
+
* sent using `multipart/form-data` to allow uploading binaries.
|
|
27
|
+
*
|
|
28
|
+
* @param rql The RQL query to send
|
|
24
29
|
* @param params The additional parameters for the request
|
|
25
30
|
* @returns A promise with the request's result set
|
|
26
31
|
*/
|
|
27
|
-
execute(
|
|
32
|
+
execute(rql: string, params?: RQLQueryParams): Promise<ResultSet>;
|
|
28
33
|
/**
|
|
29
34
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
30
35
|
*
|
|
@@ -35,7 +40,7 @@ export default class Client {
|
|
|
35
40
|
* Tries to log in the user on the configured CubicWeb instance with the given credentials.
|
|
36
41
|
*
|
|
37
42
|
* @param login The user login
|
|
38
|
-
* @param password
|
|
43
|
+
* @param password The user password
|
|
39
44
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
40
45
|
*/
|
|
41
46
|
login(login: string, password: string): Promise<boolean>;
|
|
@@ -52,14 +57,21 @@ export default class Client {
|
|
|
52
57
|
*/
|
|
53
58
|
currentUser(): Promise<CurrentUser>;
|
|
54
59
|
/**
|
|
60
|
+
* Executes the given transaction.
|
|
61
|
+
*
|
|
62
|
+
* If the {@link Transaction} object contains binaries, the request is automatically
|
|
63
|
+
* sent using `multipart/form-data` to allow uploading binaries.
|
|
64
|
+
*
|
|
55
65
|
* @param transaction Transaction to execute
|
|
56
|
-
* @returns A promise
|
|
66
|
+
* @returns A promise returning the transaction result on success
|
|
57
67
|
*/
|
|
58
68
|
executeTransaction(transaction: Transaction): Promise<TransactionResult>;
|
|
59
69
|
/**
|
|
60
70
|
* Get the binary for the given entity attribute
|
|
61
71
|
*
|
|
62
|
-
* @
|
|
72
|
+
* @param eid Entity eid to fetch the binary from
|
|
73
|
+
* @param attribute Attribute on the entity in which the binary is stored
|
|
74
|
+
* @returns A promise resolving to the binary as a Blob
|
|
63
75
|
*/
|
|
64
76
|
getBinary(eid: number, attribute: string): Promise<Blob>;
|
|
65
77
|
}
|
package/lib/api/Client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,OAAO,CAAC,GAAG,CAAM;IAEjB;;;;;;OAMG;gBACS,MAAM,EAAE,MAAM;IAI1B,IAAI,MAAM,WAET;IAED;;;;;;;;;OASG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,cAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IAQ3E;;;;OAIG;IACG,MAAM;IAKZ;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAI3C;;;;OAIG;IACG,MAAM;IAIZ;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAIzC;;;;;;;;OAQG;IACG,kBAAkB,CACtB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;;;OAMG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAG/C"}
|
package/lib/api/Client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Schema } from "../schema/classes/Schema.js";
|
|
2
2
|
import Api from "./Api.js";
|
|
3
|
-
import {
|
|
3
|
+
import { RQLQuery } from "./query/RQLQuery.js";
|
|
4
|
+
import { Transaction } from "./transaction/Transaction.js";
|
|
4
5
|
/**
|
|
5
6
|
* Class used to communicate with a CubicWeb instance's API.
|
|
6
7
|
*
|
|
@@ -24,16 +25,19 @@ export default class Client {
|
|
|
24
25
|
/**
|
|
25
26
|
* Executes the given query and waits for the response.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
+
* If binaries are given, the request is automatically
|
|
29
|
+
* sent using `multipart/form-data` to allow uploading binaries.
|
|
30
|
+
*
|
|
31
|
+
* @param rql The RQL query to send
|
|
28
32
|
* @param params The additional parameters for the request
|
|
29
33
|
* @returns A promise with the request's result set
|
|
30
34
|
*/
|
|
31
|
-
async execute(
|
|
35
|
+
async execute(rql, params = {}) {
|
|
32
36
|
const transaction = new Transaction();
|
|
33
|
-
const
|
|
34
|
-
transaction.
|
|
37
|
+
const query = new RQLQuery(rql, params);
|
|
38
|
+
transaction.push(query);
|
|
35
39
|
const result = await this.executeTransaction(transaction);
|
|
36
|
-
return result.
|
|
40
|
+
return result.getResultSet(query);
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
@@ -48,7 +52,7 @@ export default class Client {
|
|
|
48
52
|
* Tries to log in the user on the configured CubicWeb instance with the given credentials.
|
|
49
53
|
*
|
|
50
54
|
* @param login The user login
|
|
51
|
-
* @param password
|
|
55
|
+
* @param password The user password
|
|
52
56
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
53
57
|
*/
|
|
54
58
|
async login(login, password) {
|
|
@@ -71,8 +75,13 @@ export default class Client {
|
|
|
71
75
|
return await this.api.currentUser();
|
|
72
76
|
}
|
|
73
77
|
/**
|
|
78
|
+
* Executes the given transaction.
|
|
79
|
+
*
|
|
80
|
+
* If the {@link Transaction} object contains binaries, the request is automatically
|
|
81
|
+
* sent using `multipart/form-data` to allow uploading binaries.
|
|
82
|
+
*
|
|
74
83
|
* @param transaction Transaction to execute
|
|
75
|
-
* @returns A promise
|
|
84
|
+
* @returns A promise returning the transaction result on success
|
|
76
85
|
*/
|
|
77
86
|
async executeTransaction(transaction) {
|
|
78
87
|
return await this.api.rql(transaction);
|
|
@@ -80,7 +89,9 @@ export default class Client {
|
|
|
80
89
|
/**
|
|
81
90
|
* Get the binary for the given entity attribute
|
|
82
91
|
*
|
|
83
|
-
* @
|
|
92
|
+
* @param eid Entity eid to fetch the binary from
|
|
93
|
+
* @param attribute Attribute on the entity in which the binary is stored
|
|
94
|
+
* @returns A promise resolving to the binary as a Blob
|
|
84
95
|
*/
|
|
85
96
|
async getBinary(eid, attribute) {
|
|
86
97
|
return await this.api.binary(eid, attribute);
|
package/lib/api/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,GAAoC,MAAM,UAAU,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACjB,GAAG,CAAM;IAEjB;;;;;;OAMG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,SAAyB,EAAE;QACpD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAC1D,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACvC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,QAAgB;QACzC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,kBAAkB,CACtB,WAAwB;QAExB,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,SAAiB;QAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type representing a final value in a result set.
|
|
3
|
+
*
|
|
4
|
+
* Please not this type may not be accurate if you use entity methods,
|
|
5
|
+
* as those methods may return any data structure.
|
|
6
|
+
*
|
|
7
|
+
* @category Api
|
|
8
|
+
*/
|
|
9
|
+
export type ResultSetCell = string | number | boolean | null;
|
|
10
|
+
/**
|
|
11
|
+
* Type representing a row returned in a result set.
|
|
12
|
+
*
|
|
13
|
+
* @category Api
|
|
14
|
+
*/
|
|
15
|
+
export type ResultSetRow<T extends ReadonlyArray<ResultSetCell> = ReadonlyArray<ResultSetCell>> = T;
|
|
16
|
+
/**
|
|
17
|
+
* Class representing a RQL request result.
|
|
18
|
+
*
|
|
19
|
+
* @category Api
|
|
20
|
+
*/
|
|
21
|
+
export declare class ResultSet<T extends ReadonlyArray<ResultSetCell> = ReadonlyArray<ResultSetCell>> {
|
|
22
|
+
readonly rows: T[];
|
|
23
|
+
constructor(rows: T[]);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ResultSet.d.ts.map
|
|
@@ -0,0 +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,MAAM,MAAM,YAAY,CACtB,CAAC,SAAS,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,IACnE,CAAC,CAAC;AAEN;;;;GAIG;AACH,qBAAa,SAAS,CACpB,CAAC,SAAS,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC;aAEzC,IAAI,EAAE,CAAC,EAAE;gBAAT,IAAI,EAAE,CAAC,EAAE;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultSet.js","sourceRoot":"","sources":["../../src/api/ResultSet.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAGQ;IAA5B,YAA4B,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RQLBinary.d.ts","sourceRoot":"","sources":["../../../src/api/binary/RQLBinary.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;aAGQ,IAAI,EAAE,IAAI;IAFtC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE,IAAI;CAGvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RQLBinary.js","sourceRoot":"","sources":["../../../src/api/binary/RQLBinary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,OAAO,SAAS;IAGQ;IAFZ,IAAI,CAAS;IAE7B,YAA4B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QACpC,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RQLQueryCellRef, RQLQueryRowRef } from "./references";
|
|
2
|
+
import { RQLQueryParams } from "../Api";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a RQL query to be sent to the API.
|
|
5
|
+
*
|
|
6
|
+
* Queries are identified by a uuid and are independent from transactions.
|
|
7
|
+
*
|
|
8
|
+
* If a query has been used in a transaction, RQLQuery objects can easily retrieve
|
|
9
|
+
* a reference to the query for later resolving the values in a {@link TransactionResult}.
|
|
10
|
+
*
|
|
11
|
+
* @category Api
|
|
12
|
+
*/
|
|
13
|
+
export declare class RQLQuery {
|
|
14
|
+
readonly rql: string;
|
|
15
|
+
readonly params: RQLQueryParams;
|
|
16
|
+
readonly queryUUID: string;
|
|
17
|
+
/**
|
|
18
|
+
* Class representing a RQL query to be sent to the API.
|
|
19
|
+
*
|
|
20
|
+
* Queries are identified by a uuid and are independent from transactions.
|
|
21
|
+
*
|
|
22
|
+
* If a query has been used in a transaction, RQLQuery objects can easily retrieve
|
|
23
|
+
* a reference to the query for later resolving the values in a {@link TransactionResult}.
|
|
24
|
+
*
|
|
25
|
+
* @param rql The rql query
|
|
26
|
+
* @param params The parameters for the rql query
|
|
27
|
+
*
|
|
28
|
+
* @category Api
|
|
29
|
+
*/
|
|
30
|
+
constructor(rql: string, params?: RQLQueryParams);
|
|
31
|
+
/**
|
|
32
|
+
* @returns A reference to a {@link ResultSetRow} in the result of this query.
|
|
33
|
+
*/
|
|
34
|
+
rowRef(row: number): RQLQueryRowRef;
|
|
35
|
+
/**
|
|
36
|
+
* @returns A reference to a {@link ResultSetCell} in the result of this query.
|
|
37
|
+
*/
|
|
38
|
+
cellRef(row: number, column: number): RQLQueryCellRef;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=RQLQuery.d.ts.map
|
|
@@ -0,0 +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,cAAc,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC;;;;;;;;;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;CAGtD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import { RQLQueryCellRef, RQLQueryRowRef } from "./references";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a RQL query to be sent to the API.
|
|
5
|
+
*
|
|
6
|
+
* Queries are identified by a uuid and are independent from transactions.
|
|
7
|
+
*
|
|
8
|
+
* If a query has been used in a transaction, RQLQuery objects can easily retrieve
|
|
9
|
+
* a reference to the query for later resolving the values in a {@link TransactionResult}.
|
|
10
|
+
*
|
|
11
|
+
* @category Api
|
|
12
|
+
*/
|
|
13
|
+
export class RQLQuery {
|
|
14
|
+
rql;
|
|
15
|
+
params;
|
|
16
|
+
queryUUID;
|
|
17
|
+
/**
|
|
18
|
+
* Class representing a RQL query to be sent to the API.
|
|
19
|
+
*
|
|
20
|
+
* Queries are identified by a uuid and are independent from transactions.
|
|
21
|
+
*
|
|
22
|
+
* If a query has been used in a transaction, RQLQuery objects can easily retrieve
|
|
23
|
+
* a reference to the query for later resolving the values in a {@link TransactionResult}.
|
|
24
|
+
*
|
|
25
|
+
* @param rql The rql query
|
|
26
|
+
* @param params The parameters for the rql query
|
|
27
|
+
*
|
|
28
|
+
* @category Api
|
|
29
|
+
*/
|
|
30
|
+
constructor(rql, params = {}) {
|
|
31
|
+
this.rql = rql;
|
|
32
|
+
this.params = params;
|
|
33
|
+
this.queryUUID = uuidv4();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @returns A reference to a {@link ResultSetRow} in the result of this query.
|
|
37
|
+
*/
|
|
38
|
+
rowRef(row) {
|
|
39
|
+
return new RQLQueryRowRef(this.queryUUID, row);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @returns A reference to a {@link ResultSetCell} in the result of this query.
|
|
43
|
+
*/
|
|
44
|
+
cellRef(row, column) {
|
|
45
|
+
return new RQLQueryCellRef(this.queryUUID, row, column);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=RQLQuery.js.map
|
|
@@ -0,0 +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,cAAc,CAAC;AAG/D;;;;;;;;;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,MAAc;QACjC,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF"}
|