@cubicweb/client 2.1.1 → 3.0.0-alpha.5
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 +25 -10
- package/lib/api/Api.d.ts.map +1 -1
- package/lib/api/Api.js +69 -43
- package/lib/api/Api.js.map +1 -1
- package/lib/api/Client.d.ts +11 -6
- package/lib/api/Client.d.ts.map +1 -1
- package/lib/api/Client.js +20 -11
- package/lib/api/Client.js.map +1 -1
- package/lib/api/Transaction.d.ts +6 -9
- package/lib/api/Transaction.d.ts.map +1 -1
- package/lib/api/Transaction.js +11 -21
- 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 +13 -5
- 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 +79 -38
- package/src/api/Client.ts +24 -20
- package/src/api/Transaction.ts +16 -12
- 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 +13 -5
- 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.11 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
|
@@ -2,25 +2,35 @@ import { RawSchema } from "../schema/raw/Schema";
|
|
|
2
2
|
import { TransactionResult, Transaction } 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
15
|
export interface RQLParams {
|
|
12
16
|
[key: string]: RQLParamValue;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* Type representing a row returned in a result set.
|
|
20
|
+
*
|
|
21
|
+
* @category Api
|
|
16
22
|
*/
|
|
17
23
|
export type RqlRow = Array<string | number | boolean | null>;
|
|
18
24
|
/**
|
|
19
25
|
* Type representing a RQL request result.
|
|
26
|
+
*
|
|
27
|
+
* @category Api
|
|
20
28
|
*/
|
|
21
29
|
export type ResultSet = Array<RqlRow>;
|
|
22
30
|
/**
|
|
23
31
|
* Type representing the currently logged user's data
|
|
32
|
+
*
|
|
33
|
+
* @category Api
|
|
24
34
|
*/
|
|
25
35
|
export interface CurrentUser {
|
|
26
36
|
login: string;
|
|
@@ -29,6 +39,8 @@ export interface CurrentUser {
|
|
|
29
39
|
}
|
|
30
40
|
/**
|
|
31
41
|
* Type representing the body of an error sent by CubicWeb's API.
|
|
42
|
+
*
|
|
43
|
+
* @category Api
|
|
32
44
|
*/
|
|
33
45
|
type ApiError = {
|
|
34
46
|
title: string;
|
|
@@ -37,6 +49,8 @@ type ApiError = {
|
|
|
37
49
|
};
|
|
38
50
|
/**
|
|
39
51
|
* Type representing the error data sent to clients when retrieving an API error.
|
|
52
|
+
*
|
|
53
|
+
* @category Api
|
|
40
54
|
*/
|
|
41
55
|
export type ApiErrorResponse = {
|
|
42
56
|
status: number;
|
|
@@ -56,7 +70,7 @@ export default class Api {
|
|
|
56
70
|
private _schemaApiUrl;
|
|
57
71
|
private _loginApiUrl;
|
|
58
72
|
private _currentUserApiUrl;
|
|
59
|
-
private
|
|
73
|
+
private _binaryApiUrl;
|
|
60
74
|
/**
|
|
61
75
|
* Class used to handle requests to the CubicWeb API.
|
|
62
76
|
*
|
|
@@ -70,14 +84,6 @@ export default class Api {
|
|
|
70
84
|
constructor(apiUrl: string);
|
|
71
85
|
get apiUrl(): string;
|
|
72
86
|
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
87
|
/**
|
|
82
88
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
83
89
|
*
|
|
@@ -98,7 +104,16 @@ export default class Api {
|
|
|
98
104
|
* @returns A promise resolving to the current user
|
|
99
105
|
*/
|
|
100
106
|
currentUser(): Promise<CurrentUser>;
|
|
101
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Get the binary for the given entity attribute
|
|
109
|
+
*
|
|
110
|
+
* @returns A promise resolving to the binary
|
|
111
|
+
*/
|
|
112
|
+
binary(eid: number, attribute: string): Promise<Blob>;
|
|
113
|
+
rql(transaction: Transaction): Promise<TransactionResult>;
|
|
114
|
+
private getTransactionParams;
|
|
115
|
+
private multipartTransaction;
|
|
116
|
+
private jsonTransaction;
|
|
102
117
|
private handleUserErrors;
|
|
103
118
|
}
|
|
104
119
|
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,EAEZ,MAAM,eAAe,CAAC;AAEvB
|
|
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,EAEZ,MAAM,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W;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,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAOzC;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrD,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAY/D,OAAO,CAAC,oBAAoB;YAkBd,oBAAoB;YAmBpB,eAAe;IAY7B,OAAO,CAAC,gBAAgB;CAgBzB"}
|
package/lib/api/Api.js
CHANGED
|
@@ -37,7 +37,7 @@ class Api {
|
|
|
37
37
|
this._schemaApiUrl = this.getApiRoute("schema");
|
|
38
38
|
this._loginApiUrl = this.getApiRoute("login");
|
|
39
39
|
this._currentUserApiUrl = this.getApiRoute("current-user");
|
|
40
|
-
this.
|
|
40
|
+
this._binaryApiUrl = this.getApiRoute("binary");
|
|
41
41
|
}
|
|
42
42
|
get apiUrl() {
|
|
43
43
|
return this._apiUrl;
|
|
@@ -45,27 +45,6 @@ class Api {
|
|
|
45
45
|
getApiRoute(route) {
|
|
46
46
|
return `${this._apiUrl}/${this._version}/${route}`;
|
|
47
47
|
}
|
|
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
48
|
/**
|
|
70
49
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
71
50
|
*
|
|
@@ -117,34 +96,79 @@ class Api {
|
|
|
117
96
|
});
|
|
118
97
|
});
|
|
119
98
|
}
|
|
120
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Get the binary for the given entity attribute
|
|
101
|
+
*
|
|
102
|
+
* @returns A promise resolving to the binary
|
|
103
|
+
*/
|
|
104
|
+
binary(eid, attribute) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const params = new URLSearchParams({
|
|
107
|
+
eid: eid.toString(),
|
|
108
|
+
attribute,
|
|
109
|
+
});
|
|
110
|
+
return yield nonNullFetchApi(this._binaryApiUrl + params, {
|
|
111
|
+
method: "GET",
|
|
112
|
+
credentials: "include",
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
rql(transaction) {
|
|
121
117
|
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
118
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
119
|
+
if (Object.keys(transaction.binaries).length > 0) {
|
|
120
|
+
return yield this.multipartTransaction(transaction);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
return yield this.jsonTransaction(transaction);
|
|
124
|
+
}
|
|
142
125
|
}
|
|
143
126
|
catch (e) {
|
|
144
127
|
this.handleUserErrors(e);
|
|
145
128
|
}
|
|
146
129
|
});
|
|
147
130
|
}
|
|
131
|
+
getTransactionParams(transaction) {
|
|
132
|
+
return transaction.queries.map((transactionQuery) => ({
|
|
133
|
+
query: transactionQuery.query,
|
|
134
|
+
params: Object.fromEntries(Object.entries(transactionQuery.params).map(([key, value]) => [
|
|
135
|
+
key,
|
|
136
|
+
(0, Transaction_1.isTransactionQueryRef)(value)
|
|
137
|
+
? {
|
|
138
|
+
queryIndex: value.queryIndex,
|
|
139
|
+
row: value.row,
|
|
140
|
+
column: value.column,
|
|
141
|
+
}
|
|
142
|
+
: value,
|
|
143
|
+
])),
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
multipartTransaction(transaction) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const jsonParams = this.getTransactionParams(transaction);
|
|
149
|
+
const formData = new FormData();
|
|
150
|
+
formData.append("queries", JSON.stringify(jsonParams));
|
|
151
|
+
Object.entries(transaction.binaries).forEach(([key, value]) => {
|
|
152
|
+
formData.append(key, value);
|
|
153
|
+
});
|
|
154
|
+
const resultSets = yield nonNullFetchApi(this._rqlApiUrl, {
|
|
155
|
+
method: "POST",
|
|
156
|
+
credentials: "include",
|
|
157
|
+
body: formData,
|
|
158
|
+
});
|
|
159
|
+
return new Transaction_1.TransactionResult(resultSets);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
jsonTransaction(transaction) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const resultSets = yield nonNullFetchApi(this._rqlApiUrl, {
|
|
165
|
+
method: "POST",
|
|
166
|
+
credentials: "include",
|
|
167
|
+
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
168
|
+
});
|
|
169
|
+
return new Transaction_1.TransactionResult(resultSets);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
148
172
|
handleUserErrors(error) {
|
|
149
173
|
if (typeof error === "object" &&
|
|
150
174
|
error !== null &&
|
|
@@ -197,7 +221,9 @@ function fetchApi(input, init) {
|
|
|
197
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
198
222
|
let headers = init === null || init === void 0 ? void 0 : init.headers;
|
|
199
223
|
if ((init === null || init === void 0 ? void 0 : init.method) && init.method !== "GET" && init.method !== "DELETE") {
|
|
200
|
-
headers = Object.assign({ "Content-Type": "application/json;charset=UTF-8"
|
|
224
|
+
headers = Object.assign({ "Content-Type": "application/json;charset=UTF-8",
|
|
225
|
+
// CSRF custom header necessary for POST requests
|
|
226
|
+
"X-Requested-With": "XMLHttpRequest" }, init === null || init === void 0 ? void 0 : init.headers);
|
|
201
227
|
}
|
|
202
228
|
const response = yield fetch(input, Object.assign(Object.assign({}, init), { headers }));
|
|
203
229
|
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,+CAIuB;
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAA4C;AAE5C,+CAIuB;AAgEvB;;;;;;;GAOG;AACH,MAAqB,GAAG;IAStB;;;;;;;;;OASG;IACH,YAAY,MAAc;QAjBlB,aAAQ,GAAG,IAAI,CAAC;QAkBtB,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,C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AAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,OAAO,IAAI,CAAC;aACb;SACF;aAAM;YACL,IAAI,IAAI,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
|
*
|
|
@@ -51,5 +50,11 @@ export default class Client {
|
|
|
51
50
|
* @returns A promise fulfilled when the transaction is completed
|
|
52
51
|
*/
|
|
53
52
|
executeTransaction(transaction: Transaction): Promise<TransactionResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Get the binary for the given entity attribute
|
|
55
|
+
*
|
|
56
|
+
* @returns A promise resolving to the binary
|
|
57
|
+
*/
|
|
58
|
+
getBinary(eid: number, attribute: string): Promise<Blob>;
|
|
54
59
|
}
|
|
55
60
|
//# 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,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
|
+
transaction.push(query, params);
|
|
48
|
+
transaction.setBinaries(binaries);
|
|
49
|
+
const result = yield this.executeTransaction(transaction);
|
|
50
|
+
return result.get(0);
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
@@ -90,7 +89,17 @@ class Client {
|
|
|
90
89
|
*/
|
|
91
90
|
executeTransaction(transaction) {
|
|
92
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return yield this.
|
|
92
|
+
return yield this.api.rql(transaction);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the binary for the given entity attribute
|
|
97
|
+
*
|
|
98
|
+
* @returns A promise resolving to the binary
|
|
99
|
+
*/
|
|
100
|
+
getBinary(eid, attribute) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
return yield this.api.binary(eid, attribute);
|
|
94
103
|
});
|
|
95
104
|
}
|
|
96
105
|
}
|
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,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lib/api/Transaction.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ResultSet, RQLParamValue } from "./Api";
|
|
2
|
+
export type BinariesParam = Record<string, Blob>;
|
|
2
3
|
export declare class Transaction {
|
|
3
4
|
private _queries;
|
|
5
|
+
private _binaries;
|
|
4
6
|
push(query: string, params: Record<string, RQLParamValue | TransactionQueryRef>): TransactionQuery;
|
|
7
|
+
setBinaries(binaries?: BinariesParam): void;
|
|
8
|
+
get binaries(): BinariesParam;
|
|
5
9
|
get queries(): ReadonlyArray<TransactionQuery>;
|
|
6
10
|
}
|
|
7
11
|
export declare class TransactionResult {
|
|
8
12
|
private resultSets;
|
|
9
13
|
constructor(resultSets: ReadonlyArray<ResultSet>);
|
|
14
|
+
get(queryIndex: number): ResultSet;
|
|
10
15
|
resolve(ref: TransactionQueryRef): string | number | boolean | null;
|
|
11
16
|
}
|
|
12
17
|
export interface TransactionQueryRef {
|
|
@@ -22,12 +27,4 @@ export declare class TransactionQuery {
|
|
|
22
27
|
ref(row?: number, column?: number): TransactionQueryRef;
|
|
23
28
|
}
|
|
24
29
|
export declare function isTransactionQueryRef(value: RQLParamValue | TransactionQueryRef): value is TransactionQueryRef;
|
|
25
|
-
export interface TransactionBackend {
|
|
26
|
-
execute(transaction: Transaction): Promise<TransactionResult>;
|
|
27
|
-
}
|
|
28
|
-
export declare class NativeTransactionBackend implements TransactionBackend {
|
|
29
|
-
private _api;
|
|
30
|
-
constructor(_api: Api);
|
|
31
|
-
execute(transaction: Transaction): Promise<TransactionResult>;
|
|
32
|
-
}
|
|
33
30
|
//# 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":"A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GED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
3
|
+
exports.isTransactionQueryRef = exports.TransactionQuery = exports.TransactionResult = exports.Transaction = void 0;
|
|
13
4
|
class Transaction {
|
|
14
5
|
constructor() {
|
|
15
6
|
this._queries = [];
|
|
7
|
+
this._binaries = {};
|
|
16
8
|
}
|
|
17
9
|
push(query, params) {
|
|
18
10
|
const stackedQuery = new TransactionQuery(query, params, this._queries.length);
|
|
19
11
|
this._queries.push(stackedQuery);
|
|
20
12
|
return stackedQuery;
|
|
21
13
|
}
|
|
14
|
+
setBinaries(binaries) {
|
|
15
|
+
this._binaries = binaries !== null && binaries !== void 0 ? binaries : {};
|
|
16
|
+
}
|
|
17
|
+
get binaries() {
|
|
18
|
+
return this._binaries;
|
|
19
|
+
}
|
|
22
20
|
get queries() {
|
|
23
21
|
return this._queries;
|
|
24
22
|
}
|
|
@@ -28,6 +26,9 @@ class TransactionResult {
|
|
|
28
26
|
constructor(resultSets) {
|
|
29
27
|
this.resultSets = resultSets;
|
|
30
28
|
}
|
|
29
|
+
get(queryIndex) {
|
|
30
|
+
return this.resultSets[queryIndex];
|
|
31
|
+
}
|
|
31
32
|
resolve(ref) {
|
|
32
33
|
return this.resultSets[ref.queryIndex][ref.row][ref.column];
|
|
33
34
|
}
|
|
@@ -54,15 +55,4 @@ function isTransactionQueryRef(value) {
|
|
|
54
55
|
["queryIndex", "row", "column"].every((key) => Object.keys(value).includes(key)));
|
|
55
56
|
}
|
|
56
57
|
exports.isTransactionQueryRef = isTransactionQueryRef;
|
|
57
|
-
class NativeTransactionBackend {
|
|
58
|
-
constructor(_api) {
|
|
59
|
-
this._api = _api;
|
|
60
|
-
}
|
|
61
|
-
execute(transaction) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return this._api.executeTransaction(transaction);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.NativeTransactionBackend = NativeTransactionBackend;
|
|
68
58
|
//# sourceMappingURL=Transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":"
|
|
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;IA0BxC,CAAC;IAxBC,IAAI,CACF,KAAa,EACb,MAA2D;QAE3D,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,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA5BD,kCA4BC;AAED,MAAa,iBAAiB;IAC5B,YAAoB,UAAoC;QAApC,eAAU,GAAV,UAAU,CAA0B;IAAG,CAAC;IAE5D,GAAG,CAAC,UAAkB;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,CAAC,GAAwB;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;CACF;AAVD,8CAUC;AAQD,MAAa,gBAAgB;IAC3B,YACkB,KAAa,EACb,MAA2D,EAC3D,KAAa;QAFb,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAqD;QAC3D,UAAK,GAAL,KAAK,CAAQ;IAC5B,CAAC;IAEJ,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC;QACrB,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,KAAK;YACtB,GAAG;YACH,MAAM;SACP,CAAC;IACJ,CAAC;CACF;AAdD,4CAcC;AAED,SAAgB,qBAAqB,CACnC,KAA0C;IAE1C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAC5C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CACjC,CACF,CAAC;AACJ,CAAC;AAVD,sDAUC"}
|
|
@@ -7,6 +7,8 @@ import { MatchedRelationDefinition, RelationDefinitionMatcher } from "./Utils";
|
|
|
7
7
|
* Wrapper around raw entity schemas from the Schema.
|
|
8
8
|
* You should never have to create this object yourself.
|
|
9
9
|
* Instead, retrieve these objects from the methods in the `Schema` class.
|
|
10
|
+
*
|
|
11
|
+
* @category Schema
|
|
10
12
|
*/
|
|
11
13
|
export declare class EntitySchema<E extends EntityRawSchemaArray = EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<E> = RelationDefinitionRawSchemaArray<E>, ERawSchema extends E[number] = E[number]> {
|
|
12
14
|
private schema;
|
|
@@ -33,23 +35,23 @@ export declare class EntitySchema<E extends EntityRawSchemaArray = EntityRawSche
|
|
|
33
35
|
*/
|
|
34
36
|
get final(): ERawSchema["final"];
|
|
35
37
|
/**
|
|
36
|
-
* Gets the list of relation
|
|
37
|
-
*
|
|
38
|
-
* there will be dupicates when used along with `objectRelationsDefinitions`.
|
|
38
|
+
* Gets the list of attribute schemas (relation definition schemas with final at false)
|
|
39
|
+
* for this entity schema.
|
|
39
40
|
*/
|
|
40
|
-
get
|
|
41
|
+
get attributes(): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
41
42
|
subject: ERawSchema["type"];
|
|
42
|
-
final:
|
|
43
|
-
}>>[];
|
|
44
|
-
/**
|
|
45
|
-
* Gets the list of relation definitions schemas with this entity as object.
|
|
46
|
-
* In case a relation definition schema has this entity as both object and subject,
|
|
47
|
-
* there will be dupicates when used along with `subjectRelationDefinitions`.
|
|
48
|
-
*/
|
|
49
|
-
get objectRelationsDefinitions(): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
50
|
-
object: ERawSchema["type"];
|
|
51
|
-
final: false;
|
|
43
|
+
final: true;
|
|
52
44
|
}>>[];
|
|
45
|
+
get relationDefinitions(): {
|
|
46
|
+
subject: RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
47
|
+
subject: ERawSchema["type"];
|
|
48
|
+
final: false;
|
|
49
|
+
}>>[];
|
|
50
|
+
object: RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
51
|
+
object: ERawSchema["type"];
|
|
52
|
+
final: false;
|
|
53
|
+
}>>[];
|
|
54
|
+
};
|
|
53
55
|
/**
|
|
54
56
|
* Finds relations in the Schema matching the partial relation given.
|
|
55
57
|
*
|
|
@@ -59,13 +61,5 @@ export declare class EntitySchema<E extends EntityRawSchemaArray = EntityRawSche
|
|
|
59
61
|
matchRelationDefinitions<M extends RelationDefinitionMatcher<E>>(matcher: M): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
60
62
|
subject: ERawSchema["type"];
|
|
61
63
|
}>>[];
|
|
62
|
-
/**
|
|
63
|
-
* Gets the list of attribute schemas (relation definition schemas with final at false)
|
|
64
|
-
* for this entity schema.
|
|
65
|
-
*/
|
|
66
|
-
get attributes(): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
67
|
-
subject: ERawSchema["type"];
|
|
68
|
-
final: true;
|
|
69
|
-
}>>[];
|
|
70
64
|
}
|
|
71
65
|
//# sourceMappingURL=EntitySchema.d.ts.map
|