@cubicweb/client 2.1.1 → 3.0.0-alpha.10
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 +28 -16
- package/lib/api/Api.d.ts +34 -14
- package/lib/api/Api.d.ts.map +1 -1
- package/lib/api/Api.js +82 -44
- package/lib/api/Api.js.map +1 -1
- package/lib/api/Client.d.ts +17 -6
- package/lib/api/Client.d.ts.map +1 -1
- package/lib/api/Client.js +30 -11
- package/lib/api/Client.js.map +1 -1
- package/lib/api/Transaction.d.ts +33 -20
- package/lib/api/Transaction.d.ts.map +1 -1
- package/lib/api/Transaction.js +44 -37
- package/lib/api/Transaction.js.map +1 -1
- package/lib/schema/classes/EntitySchema.d.ts +16 -22
- package/lib/schema/classes/EntitySchema.d.ts.map +1 -1
- package/lib/schema/classes/EntitySchema.js +17 -25
- package/lib/schema/classes/EntitySchema.js.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.d.ts +8 -10
- package/lib/schema/classes/RelationDefinitionSchema.d.ts.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.js +7 -21
- package/lib/schema/classes/RelationDefinitionSchema.js.map +1 -1
- package/lib/schema/classes/Schema.d.ts +2 -0
- package/lib/schema/classes/Schema.d.ts.map +1 -1
- package/lib/schema/classes/Schema.js +2 -0
- package/lib/schema/classes/Schema.js.map +1 -1
- package/lib/schema/classes/Utils.d.ts +135 -1
- package/lib/schema/classes/Utils.d.ts.map +1 -1
- package/lib/schema/classes/Utils.js +165 -3
- package/lib/schema/classes/Utils.js.map +1 -1
- package/lib/schema/raw/Constraints.d.ts +17 -9
- package/lib/schema/raw/Constraints.d.ts.map +1 -1
- package/lib/schema/raw/Entities.d.ts +4 -0
- package/lib/schema/raw/Entities.d.ts.map +1 -1
- package/lib/schema/raw/RelationDefinitions.d.ts +15 -2
- package/lib/schema/raw/RelationDefinitions.d.ts.map +1 -1
- package/lib/schema/raw/Schema.d.ts +2 -0
- package/lib/schema/raw/Schema.d.ts.map +1 -1
- package/lib/schema/raw/Utils.d.ts +6 -0
- package/lib/schema/raw/Utils.d.ts.map +1 -1
- package/package.json +4 -8
- package/src/api/Api.ts +107 -54
- package/src/api/Client.ts +33 -20
- package/src/api/Transaction.ts +56 -37
- package/src/schema/classes/EntitySchema.ts +35 -41
- package/src/schema/classes/RelationDefinitionSchema.ts +10 -25
- package/src/schema/classes/Schema.ts +2 -0
- package/src/schema/classes/Utils.ts +178 -1
- package/src/schema/raw/Constraints.ts +20 -8
- package/src/schema/raw/Entities.ts +4 -0
- package/src/schema/raw/RelationDefinitions.ts +15 -2
- package/src/schema/raw/Schema.ts +2 -0
- package/src/schema/raw/Utils.ts +6 -0
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# @cubicweb/client
|
|
2
2
|
|
|
3
|
-
This library
|
|
4
|
-
used to communicate with instances running with the
|
|
3
|
+
This library allows any JavaScript client to communicate with a [CubicWeb](https://cubicweb.org/) instance running with the
|
|
5
4
|
[API cube](https://forge.extranet.logilab.fr/cubicweb/cubes/api).
|
|
6
5
|
It replaces the [cwclientlibjs](https://forge.extranet.logilab.fr/open-source/cwclientlibjs)
|
|
7
6
|
library.
|
|
8
7
|
|
|
9
8
|
The full documentation is available [here](https://cubicweb.pages.logilab.fr/cubicwebjs/client).
|
|
10
9
|
|
|
10
|
+
**Compatible with [API cube](https://forge.extranet.logilab.fr/cubicweb/cubes/api) version 0.13 only.**
|
|
11
|
+
|
|
11
12
|
## Installation
|
|
12
13
|
|
|
13
|
-
@cubicweb/client is
|
|
14
|
+
@cubicweb/client is available from NPM:
|
|
14
15
|
```bash
|
|
15
16
|
# With NPM
|
|
16
17
|
npm i @cubicweb/client
|
|
@@ -76,20 +77,22 @@ client
|
|
|
76
77
|
});
|
|
77
78
|
|
|
78
79
|
// Execute a series of request in a transaction
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
const transaction = new Transaction()
|
|
81
|
+
transaction.push({
|
|
82
|
+
query: `INSERT Person X: X name "test"`
|
|
83
|
+
})
|
|
84
|
+
transaction.push({
|
|
85
|
+
query: `Any X Where X eid %(created_eid)s`,
|
|
86
|
+
params: {
|
|
87
|
+
created_eid: {
|
|
88
|
+
queryIndex: 0,
|
|
89
|
+
row: 0,
|
|
90
|
+
column: 0,
|
|
91
|
+
}
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
})
|
|
94
|
+
client
|
|
95
|
+
.executeTransaction(transaction)
|
|
93
96
|
.then((callbackResult) => {
|
|
94
97
|
console.log("Transaction was successul and the callback returned:");
|
|
95
98
|
console.log(callbackResult);
|
|
@@ -203,3 +206,12 @@ const entity = schema.getEntity("InvalidEntityType");
|
|
|
203
206
|
// TS will be happy and your entity will have the type 'ValidEntityType'.
|
|
204
207
|
const entity = schema.getEntity("ValidEntityType");
|
|
205
208
|
```
|
|
209
|
+
|
|
210
|
+
## Contribute
|
|
211
|
+
|
|
212
|
+
All `@cubicweb` libraries are in the [cubicwebjs monorepo](https://forge.extranet.logilab.fr/cubicweb/cubicwebjs).
|
|
213
|
+
Please refer to the main README.
|
|
214
|
+
|
|
215
|
+
## Get Help
|
|
216
|
+
|
|
217
|
+
Contact us on [Matrix](https://matrix.to/#/#cubicweb:matrix.logilab.org) and check the roadmap on the [CubicWeb Repository](https://forge.extranet.logilab.fr/cubicweb/cubicweb).
|
package/lib/api/Api.d.ts
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { RawSchema } from "../schema/raw/Schema";
|
|
2
|
-
import { TransactionResult, Transaction } from "./Transaction";
|
|
2
|
+
import { TransactionResult, Transaction, TransactionQueryScalarRef, TransactionQueryBinaryRef } from "./Transaction";
|
|
3
3
|
/**
|
|
4
4
|
* Type representing an RQL request and its associated parameters.
|
|
5
|
+
*
|
|
6
|
+
* @category Api
|
|
5
7
|
*/
|
|
6
8
|
export type RQLQuery = [string, RQLParams];
|
|
7
9
|
export type RQLParamValue = string | number | boolean | null;
|
|
8
10
|
/**
|
|
9
11
|
* Type representing RQL parameters to send along a request.
|
|
12
|
+
*
|
|
13
|
+
* @category Api
|
|
10
14
|
*/
|
|
11
|
-
export
|
|
12
|
-
[key: string]: RQLParamValue;
|
|
13
|
-
}
|
|
15
|
+
export type RQLParams = Record<string, RQLParamValue | TransactionQueryScalarRef | TransactionQueryBinaryRef>;
|
|
14
16
|
/**
|
|
15
17
|
* Type representing a row returned in a result set.
|
|
18
|
+
*
|
|
19
|
+
* @category Api
|
|
16
20
|
*/
|
|
17
21
|
export type RqlRow = Array<string | number | boolean | null>;
|
|
18
22
|
/**
|
|
19
23
|
* Type representing a RQL request result.
|
|
24
|
+
*
|
|
25
|
+
* @category Api
|
|
20
26
|
*/
|
|
21
27
|
export type ResultSet = Array<RqlRow>;
|
|
22
28
|
/**
|
|
23
29
|
* Type representing the currently logged user's data
|
|
30
|
+
*
|
|
31
|
+
* @category Api
|
|
24
32
|
*/
|
|
25
33
|
export interface CurrentUser {
|
|
26
34
|
login: string;
|
|
@@ -29,6 +37,8 @@ export interface CurrentUser {
|
|
|
29
37
|
}
|
|
30
38
|
/**
|
|
31
39
|
* Type representing the body of an error sent by CubicWeb's API.
|
|
40
|
+
*
|
|
41
|
+
* @category Api
|
|
32
42
|
*/
|
|
33
43
|
type ApiError = {
|
|
34
44
|
title: string;
|
|
@@ -37,6 +47,8 @@ type ApiError = {
|
|
|
37
47
|
};
|
|
38
48
|
/**
|
|
39
49
|
* Type representing the error data sent to clients when retrieving an API error.
|
|
50
|
+
*
|
|
51
|
+
* @category Api
|
|
40
52
|
*/
|
|
41
53
|
export type ApiErrorResponse = {
|
|
42
54
|
status: number;
|
|
@@ -55,8 +67,9 @@ export default class Api {
|
|
|
55
67
|
private _rqlApiUrl;
|
|
56
68
|
private _schemaApiUrl;
|
|
57
69
|
private _loginApiUrl;
|
|
70
|
+
private _logoutApiUrl;
|
|
58
71
|
private _currentUserApiUrl;
|
|
59
|
-
private
|
|
72
|
+
private _binaryApiUrl;
|
|
60
73
|
/**
|
|
61
74
|
* Class used to handle requests to the CubicWeb API.
|
|
62
75
|
*
|
|
@@ -70,14 +83,6 @@ export default class Api {
|
|
|
70
83
|
constructor(apiUrl: string);
|
|
71
84
|
get apiUrl(): string;
|
|
72
85
|
private getApiRoute;
|
|
73
|
-
/**
|
|
74
|
-
* Executes the given query and waits for the response.
|
|
75
|
-
*
|
|
76
|
-
* @param query The RQL query to send
|
|
77
|
-
* @param params The additional parameters for the request
|
|
78
|
-
* @returns A promise with the request's result set
|
|
79
|
-
*/
|
|
80
|
-
execute(query: string, params: RQLParams): Promise<ResultSet>;
|
|
81
86
|
/**
|
|
82
87
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
83
88
|
*
|
|
@@ -92,13 +97,28 @@ export default class Api {
|
|
|
92
97
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
93
98
|
*/
|
|
94
99
|
login(login: string, password: string): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* Logs out the current user. Will invalidate any authentication cookie active.
|
|
102
|
+
*
|
|
103
|
+
* @returns A promise which will resolve when the user is properly logged out
|
|
104
|
+
*/
|
|
105
|
+
logout(): Promise<void>;
|
|
95
106
|
/**
|
|
96
107
|
* Get the current user associated to this client
|
|
97
108
|
*
|
|
98
109
|
* @returns A promise resolving to the current user
|
|
99
110
|
*/
|
|
100
111
|
currentUser(): Promise<CurrentUser>;
|
|
101
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Get the binary for the given entity attribute
|
|
114
|
+
*
|
|
115
|
+
* @returns A promise resolving to the binary
|
|
116
|
+
*/
|
|
117
|
+
binary(eid: number, attribute: string): Promise<Blob>;
|
|
118
|
+
rql(transaction: Transaction): Promise<TransactionResult>;
|
|
119
|
+
private getTransactionParams;
|
|
120
|
+
private multipartTransaction;
|
|
121
|
+
private jsonTransaction;
|
|
102
122
|
private handleUserErrors;
|
|
103
123
|
}
|
|
104
124
|
export {};
|
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,sBAAsB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,WAAW,
|
|
1
|
+
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAC5B,MAAM,EACN,aAAa,GAAG,yBAAyB,GAAG,yBAAyB,CACtE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAEtC;;;;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,M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iRoute("schema");
|
|
38
38
|
this._loginApiUrl = this.getApiRoute("login");
|
|
39
|
+
this._logoutApiUrl = this.getApiRoute("logout");
|
|
39
40
|
this._currentUserApiUrl = this.getApiRoute("current-user");
|
|
40
|
-
this.
|
|
41
|
+
this._binaryApiUrl = this.getApiRoute("binary");
|
|
41
42
|
}
|
|
42
43
|
get apiUrl() {
|
|
43
44
|
return this._apiUrl;
|
|
@@ -45,27 +46,6 @@ class Api {
|
|
|
45
46
|
getApiRoute(route) {
|
|
46
47
|
return `${this._apiUrl}/${this._version}/${route}`;
|
|
47
48
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Executes the given query and waits for the response.
|
|
50
|
-
*
|
|
51
|
-
* @param query The RQL query to send
|
|
52
|
-
* @param params The additional parameters for the request
|
|
53
|
-
* @returns A promise with the request's result set
|
|
54
|
-
*/
|
|
55
|
-
execute(query, params) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
try {
|
|
58
|
-
return yield nonNullFetchApi(this._rqlApiUrl, {
|
|
59
|
-
method: "POST",
|
|
60
|
-
body: JSON.stringify({ query, params }),
|
|
61
|
-
credentials: "include", // FIXME is it secure?
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
this.handleUserErrors(e);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
49
|
/**
|
|
70
50
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
71
51
|
*
|
|
@@ -104,6 +84,19 @@ class Api {
|
|
|
104
84
|
}
|
|
105
85
|
});
|
|
106
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Logs out the current user. Will invalidate any authentication cookie active.
|
|
89
|
+
*
|
|
90
|
+
* @returns A promise which will resolve when the user is properly logged out
|
|
91
|
+
*/
|
|
92
|
+
logout() {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
yield fetchApi(this._logoutApiUrl, {
|
|
95
|
+
method: "POST",
|
|
96
|
+
credentials: "include",
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
107
100
|
/**
|
|
108
101
|
* Get the current user associated to this client
|
|
109
102
|
*
|
|
@@ -117,34 +110,70 @@ class Api {
|
|
|
117
110
|
});
|
|
118
111
|
});
|
|
119
112
|
}
|
|
120
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Get the binary for the given entity attribute
|
|
115
|
+
*
|
|
116
|
+
* @returns A promise resolving to the binary
|
|
117
|
+
*/
|
|
118
|
+
binary(eid, attribute) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const params = new URLSearchParams({
|
|
121
|
+
eid: eid.toString(),
|
|
122
|
+
attribute,
|
|
123
|
+
});
|
|
124
|
+
return yield nonNullFetchApi(this._binaryApiUrl + params, {
|
|
125
|
+
method: "GET",
|
|
126
|
+
credentials: "include",
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
rql(transaction) {
|
|
121
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const data = transaction.queries.map((transactionQuery) => ({
|
|
123
|
-
query: transactionQuery.query,
|
|
124
|
-
params: Object.fromEntries(Object.entries(transactionQuery.params).map(([key, value]) => [
|
|
125
|
-
key,
|
|
126
|
-
(0, Transaction_1.isTransactionQueryRef)(value)
|
|
127
|
-
? {
|
|
128
|
-
queryIndex: value.queryIndex,
|
|
129
|
-
row: value.row,
|
|
130
|
-
column: value.column,
|
|
131
|
-
}
|
|
132
|
-
: value,
|
|
133
|
-
])),
|
|
134
|
-
}));
|
|
135
132
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
if (Object.keys(transaction.binaries).length > 0) {
|
|
134
|
+
return yield this.multipartTransaction(transaction);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return yield this.jsonTransaction(transaction);
|
|
138
|
+
}
|
|
142
139
|
}
|
|
143
140
|
catch (e) {
|
|
144
141
|
this.handleUserErrors(e);
|
|
145
142
|
}
|
|
146
143
|
});
|
|
147
144
|
}
|
|
145
|
+
getTransactionParams(transaction) {
|
|
146
|
+
return transaction.queries.map((transactionQuery) => ({
|
|
147
|
+
query: transactionQuery.query,
|
|
148
|
+
params: transactionQuery.params,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
multipartTransaction(transaction) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
const jsonParams = this.getTransactionParams(transaction);
|
|
154
|
+
const formData = new FormData();
|
|
155
|
+
formData.append("queries", JSON.stringify(jsonParams));
|
|
156
|
+
Object.entries(transaction.binaries).forEach(([key, value]) => {
|
|
157
|
+
formData.append(key, value);
|
|
158
|
+
});
|
|
159
|
+
const resultSets = yield nonNullFetchApi(this._rqlApiUrl, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
credentials: "include",
|
|
162
|
+
body: formData,
|
|
163
|
+
});
|
|
164
|
+
return new Transaction_1.TransactionResult(resultSets);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
jsonTransaction(transaction) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const resultSets = yield nonNullFetchApi(this._rqlApiUrl, {
|
|
170
|
+
method: "POST",
|
|
171
|
+
credentials: "include",
|
|
172
|
+
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
173
|
+
});
|
|
174
|
+
return new Transaction_1.TransactionResult(resultSets);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
148
177
|
handleUserErrors(error) {
|
|
149
178
|
if (typeof error === "object" &&
|
|
150
179
|
error !== null &&
|
|
@@ -196,8 +225,17 @@ function nonNullFetchApi(input, init) {
|
|
|
196
225
|
function fetchApi(input, init) {
|
|
197
226
|
return __awaiter(this, void 0, void 0, function* () {
|
|
198
227
|
let headers = init === null || init === void 0 ? void 0 : init.headers;
|
|
199
|
-
if ((init === null || init === void 0 ? void 0 : init.method) && init.method !== "GET"
|
|
200
|
-
headers =
|
|
228
|
+
if ((init === null || init === void 0 ? void 0 : init.method) && init.method !== "GET") {
|
|
229
|
+
headers = {
|
|
230
|
+
// CSRF custom header necessary for POST requests
|
|
231
|
+
"X-Client-Name": "XMLHttpRequest",
|
|
232
|
+
};
|
|
233
|
+
// Browsers will automatically set the multipart content type
|
|
234
|
+
// with the right boundary if the body is FormData
|
|
235
|
+
if (!(init.body instanceof FormData)) {
|
|
236
|
+
headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
237
|
+
}
|
|
238
|
+
headers = Object.assign(Object.assign({}, headers), init === null || init === void 0 ? void 0 : init.headers);
|
|
201
239
|
}
|
|
202
240
|
const response = yield fetch(input, Object.assign(Object.assign({}, init), { headers }));
|
|
203
241
|
const status = response.status;
|
package/lib/api/Api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAA4C;AAE5C,+
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAA4C;AAE5C,+CAKuB;AAiEvB;;;;;;;GAOG;AACH,MAAqB,GAAG;IAUtB;;;;;;;;;OASG;IACH,YAAY,MAAc;QAlBlB,aAAQ,GAAG,IAAI,CAAC;QAmBtB,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,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,C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AI,CAAC;YACT,IAAI;gBACF,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;aAC9B;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;aAC/C;YACD,sBAAQ,MAAM,IAAK,IAAI,EAAG;SAC3B;IACH,CAAC;CAAA"}
|
package/lib/api/Client.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Schema } from "../schema/classes/Schema";
|
|
2
2
|
import { RQLParams, ResultSet, CurrentUser } from "./Api";
|
|
3
|
-
import {
|
|
3
|
+
import { BinariesParam, Transaction, TransactionResult } from "./Transaction";
|
|
4
4
|
/**
|
|
5
5
|
* Class used to communicate with a CubicWeb instance's API.
|
|
6
|
+
*
|
|
7
|
+
* @category Api
|
|
6
8
|
*/
|
|
7
9
|
export default class Client {
|
|
8
10
|
private api;
|
|
9
|
-
private transactionBackend;
|
|
10
11
|
/**
|
|
11
12
|
* Class used to communicate with a CubicWeb instance's API.
|
|
12
13
|
*
|
|
@@ -14,9 +15,7 @@ export default class Client {
|
|
|
14
15
|
* Example: if you can retrieve the schema with https://example.com/api/v1/schema,
|
|
15
16
|
* use https://example.com/api as `apiUrl`.
|
|
16
17
|
*/
|
|
17
|
-
constructor(apiUrl: string
|
|
18
|
-
transactionBackend?: TransactionBackend;
|
|
19
|
-
});
|
|
18
|
+
constructor(apiUrl: string);
|
|
20
19
|
get apiUrl(): string;
|
|
21
20
|
/**
|
|
22
21
|
* Executes the given query and waits for the response.
|
|
@@ -25,7 +24,7 @@ export default class Client {
|
|
|
25
24
|
* @param params The additional parameters for the request
|
|
26
25
|
* @returns A promise with the request's result set
|
|
27
26
|
*/
|
|
28
|
-
execute(query: string, params?: RQLParams): Promise<ResultSet>;
|
|
27
|
+
execute(query: string, params?: RQLParams, binaries?: BinariesParam): Promise<ResultSet>;
|
|
29
28
|
/**
|
|
30
29
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
31
30
|
*
|
|
@@ -40,6 +39,12 @@ export default class Client {
|
|
|
40
39
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
41
40
|
*/
|
|
42
41
|
login(login: string, password: string): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Logs out the current user. Will invalidate any authentication cookie active.
|
|
44
|
+
*
|
|
45
|
+
* @returns A promise which will resolve when the user is properly logged out
|
|
46
|
+
*/
|
|
47
|
+
logout(): Promise<void>;
|
|
43
48
|
/**
|
|
44
49
|
* Get the user associated to this client
|
|
45
50
|
*
|
|
@@ -51,5 +56,11 @@ export default class Client {
|
|
|
51
56
|
* @returns A promise fulfilled when the transaction is completed
|
|
52
57
|
*/
|
|
53
58
|
executeTransaction(transaction: Transaction): Promise<TransactionResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Get the binary for the given entity attribute
|
|
61
|
+
*
|
|
62
|
+
* @returns A promise resolving to the binary
|
|
63
|
+
*/
|
|
64
|
+
getBinary(eid: number, attribute: string): Promise<Blob>;
|
|
54
65
|
}
|
|
55
66
|
//# sourceMappingURL=Client.d.ts.map
|
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,0BAA0B,CAAC;AAClD,OAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,OAAO,CAAC,GAAG,CAAM;IAEjB;;;;;;OAMG;gBACS,MAAM,EAAE,MAAM;IAI1B,IAAI,MAAM,WAET;IAED;;;;;;OAMG;IACG,OAAO,CACX,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,SAAc,EACtB,QAAQ,CAAC,EAAE,aAAa,GACvB,OAAO,CAAC,SAAS,CAAC;IAQrB;;;;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;;;OAGG;IACG,kBAAkB,CACtB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;OAIG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAG/C"}
|
package/lib/api/Client.js
CHANGED
|
@@ -17,6 +17,8 @@ const Api_1 = __importDefault(require("./Api"));
|
|
|
17
17
|
const Transaction_1 = require("./Transaction");
|
|
18
18
|
/**
|
|
19
19
|
* Class used to communicate with a CubicWeb instance's API.
|
|
20
|
+
*
|
|
21
|
+
* @category Api
|
|
20
22
|
*/
|
|
21
23
|
class Client {
|
|
22
24
|
/**
|
|
@@ -26,15 +28,8 @@ class Client {
|
|
|
26
28
|
* Example: if you can retrieve the schema with https://example.com/api/v1/schema,
|
|
27
29
|
* use https://example.com/api as `apiUrl`.
|
|
28
30
|
*/
|
|
29
|
-
constructor(apiUrl
|
|
31
|
+
constructor(apiUrl) {
|
|
30
32
|
this.api = new Api_1.default(apiUrl);
|
|
31
|
-
const { transactionBackend } = options;
|
|
32
|
-
if (transactionBackend === undefined) {
|
|
33
|
-
this.transactionBackend = new Transaction_1.NativeTransactionBackend(this.api);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.transactionBackend = transactionBackend;
|
|
37
|
-
}
|
|
38
33
|
}
|
|
39
34
|
get apiUrl() {
|
|
40
35
|
return this.api.apiUrl;
|
|
@@ -46,9 +41,13 @@ class Client {
|
|
|
46
41
|
* @param params The additional parameters for the request
|
|
47
42
|
* @returns A promise with the request's result set
|
|
48
43
|
*/
|
|
49
|
-
execute(query, params = {}) {
|
|
44
|
+
execute(query, params = {}, binaries) {
|
|
50
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
|
|
46
|
+
const transaction = new Transaction_1.Transaction();
|
|
47
|
+
const transactionQuery = transaction.push(query, params);
|
|
48
|
+
transaction.setBinaries(binaries);
|
|
49
|
+
const result = yield this.executeTransaction(transaction);
|
|
50
|
+
return result.resolveQuery(transactionQuery.ref());
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
@@ -74,6 +73,16 @@ class Client {
|
|
|
74
73
|
return yield this.api.login(login, password);
|
|
75
74
|
});
|
|
76
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Logs out the current user. Will invalidate any authentication cookie active.
|
|
78
|
+
*
|
|
79
|
+
* @returns A promise which will resolve when the user is properly logged out
|
|
80
|
+
*/
|
|
81
|
+
logout() {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
return yield this.api.logout();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
77
86
|
/**
|
|
78
87
|
* Get the user associated to this client
|
|
79
88
|
*
|
|
@@ -90,7 +99,17 @@ class Client {
|
|
|
90
99
|
*/
|
|
91
100
|
executeTransaction(transaction) {
|
|
92
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return yield this.
|
|
102
|
+
return yield this.api.rql(transaction);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the binary for the given entity attribute
|
|
107
|
+
*
|
|
108
|
+
* @returns A promise resolving to the binary
|
|
109
|
+
*/
|
|
110
|
+
getBinary(eid, attribute) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
return yield this.api.binary(eid, attribute);
|
|
94
113
|
});
|
|
95
114
|
}
|
|
96
115
|
}
|
package/lib/api/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAClD,gDAA+D;AAC/D,+
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAClD,gDAA+D;AAC/D,+CAA8E;AAE9E;;;;GAIG;AACH,MAAqB,MAAM;IAGzB;;;;;;OAMG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,aAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACG,OAAO,CACX,KAAa,EACb,SAAoB,EAAE,EACtB,QAAwB;;YAExB,MAAM,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;YACtC,MAAM,gBAAgB,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACzD,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC;QACrD,CAAC;KAAA;IAED;;;;OAIG;IACG,MAAM;;YACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,IAAI,eAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;KAAA;IAED;;;;;;OAMG;IACG,KAAK,CAAC,KAAa,EAAE,QAAgB;;YACzC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/C,CAAC;KAAA;IAED;;;;OAIG;IACG,MAAM;;YACV,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACjC,CAAC;KAAA;IAED;;;;OAIG;IACG,WAAW;;YACf,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;KAAA;IAED;;;OAGG;IACG,kBAAkB,CACtB,WAAwB;;YAExB,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;KAAA;IAED;;;;OAIG;IACG,SAAS,CAAC,GAAW,EAAE,SAAiB;;YAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;KAAA;CACF;AA9FD,yBA8FC"}
|
package/lib/api/Transaction.d.ts
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RQLParams, ResultSet } from "./Api";
|
|
2
|
+
export type BinariesParam = Record<string, Blob>;
|
|
2
3
|
export declare class Transaction {
|
|
3
4
|
private _queries;
|
|
4
|
-
|
|
5
|
+
private _binaries;
|
|
6
|
+
push(query: string, params: RQLParams): TransactionQuery;
|
|
7
|
+
setBinaries(binaries?: BinariesParam): void;
|
|
8
|
+
get binaries(): BinariesParam;
|
|
5
9
|
get queries(): ReadonlyArray<TransactionQuery>;
|
|
6
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
|
+
}
|
|
7
18
|
export declare class TransactionResult {
|
|
8
19
|
private resultSets;
|
|
9
20
|
constructor(resultSets: ReadonlyArray<ResultSet>);
|
|
10
|
-
|
|
21
|
+
resolveQuery(ref: TransactionQueryRef): ResultSet;
|
|
22
|
+
resolveRow(ref: TransactionQueryRowRef): import("./Api").RqlRow;
|
|
23
|
+
resolveScalar(ref: TransactionQueryScalarRef): string | number | boolean | null;
|
|
11
24
|
}
|
|
12
|
-
export
|
|
13
|
-
queryIndex: number;
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
export declare class TransactionQueryRef {
|
|
26
|
+
readonly queryIndex: number;
|
|
27
|
+
constructor(queryIndex: number);
|
|
28
|
+
row(r: number): TransactionQueryRowRef;
|
|
16
29
|
}
|
|
17
|
-
export declare class
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ref(row?: number, column?: number): TransactionQueryRef;
|
|
30
|
+
export declare class TransactionQueryRowRef {
|
|
31
|
+
readonly queryIndex: number;
|
|
32
|
+
readonly row: number;
|
|
33
|
+
constructor(queryIndex: number, row: number);
|
|
34
|
+
column(c: number): TransactionQueryScalarRef;
|
|
23
35
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
export interface TransactionQueryScalarRef {
|
|
37
|
+
readonly queryIndex: number;
|
|
38
|
+
readonly row: number;
|
|
39
|
+
readonly column: number;
|
|
40
|
+
readonly type: "query_reference";
|
|
27
41
|
}
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
execute(transaction: Transaction): Promise<TransactionResult>;
|
|
42
|
+
export interface TransactionQueryBinaryRef {
|
|
43
|
+
readonly ref: string;
|
|
44
|
+
readonly type: "binary_reference";
|
|
32
45
|
}
|
|
33
46
|
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,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;aAE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