@cubicweb/client 3.0.0-alpha.10 → 3.0.0-alpha.11
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/lib/Errors.js +3 -9
- package/lib/Errors.js.map +1 -1
- package/lib/api/Api.d.ts +2 -2
- package/lib/api/Api.d.ts.map +1 -1
- package/lib/api/Api.js +128 -147
- package/lib/api/Api.js.map +1 -1
- package/lib/api/Client.d.ts +4 -4
- package/lib/api/Client.d.ts.map +1 -1
- package/lib/api/Client.js +25 -53
- package/lib/api/Client.js.map +1 -1
- package/lib/api/Transaction.d.ts +2 -2
- package/lib/api/Transaction.d.ts.map +1 -1
- package/lib/api/Transaction.js +15 -18
- package/lib/api/Transaction.js.map +1 -1
- package/lib/index.d.ts +13 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12 -33
- package/lib/index.js.map +1 -1
- package/lib/schema/classes/EntitySchema.d.ts +5 -5
- package/lib/schema/classes/EntitySchema.d.ts.map +1 -1
- package/lib/schema/classes/EntitySchema.js +3 -5
- package/lib/schema/classes/EntitySchema.js.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.d.ts +6 -6
- package/lib/schema/classes/RelationDefinitionSchema.d.ts.map +1 -1
- package/lib/schema/classes/RelationDefinitionSchema.js +8 -10
- package/lib/schema/classes/RelationDefinitionSchema.js.map +1 -1
- package/lib/schema/classes/Schema.d.ts +7 -7
- package/lib/schema/classes/Schema.d.ts.map +1 -1
- package/lib/schema/classes/Schema.js +8 -11
- package/lib/schema/classes/Schema.js.map +1 -1
- package/lib/schema/classes/Utils.d.ts +10 -10
- package/lib/schema/classes/Utils.d.ts.map +1 -1
- package/lib/schema/classes/Utils.js +19 -35
- package/lib/schema/classes/Utils.js.map +1 -1
- package/lib/schema/raw/Constraints.js +1 -2
- package/lib/schema/raw/Entities.js +1 -2
- package/lib/schema/raw/RelationDefinitions.d.ts +3 -3
- package/lib/schema/raw/RelationDefinitions.d.ts.map +1 -1
- package/lib/schema/raw/RelationDefinitions.js +1 -2
- package/lib/schema/raw/Schema.d.ts +2 -2
- package/lib/schema/raw/Schema.d.ts.map +1 -1
- package/lib/schema/raw/Schema.js +1 -2
- package/lib/schema/raw/Utils.d.ts +1 -1
- package/lib/schema/raw/Utils.d.ts.map +1 -1
- package/lib/schema/raw/Utils.js +1 -2
- package/package.json +6 -5
- package/src/api/Api.ts +3 -3
- package/src/api/Client.ts +7 -3
- package/src/api/Transaction.ts +1 -1
- package/src/index.ts +13 -13
- package/src/schema/classes/EntitySchema.ts +8 -5
- package/src/schema/classes/RelationDefinitionSchema.ts +7 -7
- package/src/schema/classes/Schema.ts +10 -7
- package/src/schema/classes/Utils.ts +4 -4
- package/src/schema/raw/RelationDefinitions.ts +3 -3
- package/src/schema/raw/Schema.ts +2 -2
- package/src/schema/raw/Utils.ts +1 -1
package/lib/Errors.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionClosedError = exports.ValidationError = exports.InconsistentSchemaError = void 0;
|
|
4
|
-
class InconsistentSchemaError extends Error {
|
|
1
|
+
export class InconsistentSchemaError extends Error {
|
|
5
2
|
constructor(message) {
|
|
6
3
|
super(`Inconsistent schema: ${message}`);
|
|
7
4
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
class ValidationError extends Error {
|
|
7
|
+
export class ValidationError extends Error {
|
|
12
8
|
constructor(message) {
|
|
13
9
|
super(message);
|
|
14
10
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
class TransactionClosedError extends Error {
|
|
13
|
+
export class TransactionClosedError extends Error {
|
|
19
14
|
constructor() {
|
|
20
15
|
super("Trying to use a closed transaction");
|
|
21
16
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
|
-
exports.TransactionClosedError = TransactionClosedError;
|
|
25
19
|
//# sourceMappingURL=Errors.js.map
|
package/lib/Errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/lib/api/Api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RawSchema } from "../schema/raw/Schema";
|
|
2
|
-
import { TransactionResult, Transaction, TransactionQueryScalarRef, TransactionQueryBinaryRef } from "./Transaction";
|
|
1
|
+
import { RawSchema } from "../schema/raw/Schema.js";
|
|
2
|
+
import { TransactionResult, Transaction, TransactionQueryScalarRef, TransactionQueryBinaryRef } from "./Transaction.js";
|
|
3
3
|
/**
|
|
4
4
|
* Type representing an RQL request and its associated parameters.
|
|
5
5
|
*
|
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,
|
|
1
|
+
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B;;;;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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF;;;;GAIG;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;;;;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;YAOd,oBAAoB;YAmBpB,eAAe;IAY7B,OAAO,CAAC,gBAAgB;CAgBzB"}
|
package/lib/api/Api.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const Errors_1 = require("../Errors");
|
|
13
|
-
const Transaction_1 = require("./Transaction");
|
|
1
|
+
import { ValidationError } from "../Errors.js";
|
|
2
|
+
import { TransactionResult, } from "./Transaction.js";
|
|
14
3
|
/**
|
|
15
4
|
* Class used to handle requests to the CubicWeb API.
|
|
16
5
|
*
|
|
@@ -19,7 +8,15 @@ const Transaction_1 = require("./Transaction");
|
|
|
19
8
|
*
|
|
20
9
|
* @internal
|
|
21
10
|
*/
|
|
22
|
-
class Api {
|
|
11
|
+
export default class Api {
|
|
12
|
+
_apiUrl;
|
|
13
|
+
_version = "v1";
|
|
14
|
+
_rqlApiUrl;
|
|
15
|
+
_schemaApiUrl;
|
|
16
|
+
_loginApiUrl;
|
|
17
|
+
_logoutApiUrl;
|
|
18
|
+
_currentUserApiUrl;
|
|
19
|
+
_binaryApiUrl;
|
|
23
20
|
/**
|
|
24
21
|
* Class used to handle requests to the CubicWeb API.
|
|
25
22
|
*
|
|
@@ -31,7 +28,6 @@ class Api {
|
|
|
31
28
|
* use https://example.com/api as `apiUrl`.
|
|
32
29
|
*/
|
|
33
30
|
constructor(apiUrl) {
|
|
34
|
-
this._version = "v1";
|
|
35
31
|
this._apiUrl = apiUrl;
|
|
36
32
|
this._rqlApiUrl = this.getApiRoute("rql");
|
|
37
33
|
this._schemaApiUrl = this.getApiRoute("schema");
|
|
@@ -51,12 +47,10 @@ class Api {
|
|
|
51
47
|
*
|
|
52
48
|
* @returns The CubicWeb instance's JSON schema.
|
|
53
49
|
*/
|
|
54
|
-
schema() {
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
credentials: "include",
|
|
59
|
-
});
|
|
50
|
+
async schema() {
|
|
51
|
+
return nonNullFetchApi(this._schemaApiUrl, {
|
|
52
|
+
method: "GET",
|
|
53
|
+
credentials: "include",
|
|
60
54
|
});
|
|
61
55
|
}
|
|
62
56
|
/**
|
|
@@ -66,35 +60,31 @@ class Api {
|
|
|
66
60
|
* @param password THe user password
|
|
67
61
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
68
62
|
*/
|
|
69
|
-
login(login, password) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
});
|
|
63
|
+
async login(login, password) {
|
|
64
|
+
try {
|
|
65
|
+
await fetchApi(this._loginApiUrl, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
login,
|
|
69
|
+
password,
|
|
70
|
+
}),
|
|
71
|
+
credentials: "include",
|
|
72
|
+
});
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch (_error) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
86
78
|
}
|
|
87
79
|
/**
|
|
88
80
|
* Logs out the current user. Will invalidate any authentication cookie active.
|
|
89
81
|
*
|
|
90
82
|
* @returns A promise which will resolve when the user is properly logged out
|
|
91
83
|
*/
|
|
92
|
-
logout() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
credentials: "include",
|
|
97
|
-
});
|
|
84
|
+
async logout() {
|
|
85
|
+
await fetchApi(this._logoutApiUrl, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
credentials: "include",
|
|
98
88
|
});
|
|
99
89
|
}
|
|
100
90
|
/**
|
|
@@ -102,12 +92,10 @@ class Api {
|
|
|
102
92
|
*
|
|
103
93
|
* @returns A promise resolving to the current user
|
|
104
94
|
*/
|
|
105
|
-
currentUser() {
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
credentials: "include",
|
|
110
|
-
});
|
|
95
|
+
async currentUser() {
|
|
96
|
+
return await nonNullFetchApi(this._currentUserApiUrl, {
|
|
97
|
+
method: "GET",
|
|
98
|
+
credentials: "include",
|
|
111
99
|
});
|
|
112
100
|
}
|
|
113
101
|
/**
|
|
@@ -115,32 +103,28 @@ class Api {
|
|
|
115
103
|
*
|
|
116
104
|
* @returns A promise resolving to the binary
|
|
117
105
|
*/
|
|
118
|
-
binary(eid, attribute) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
credentials: "include",
|
|
127
|
-
});
|
|
106
|
+
async binary(eid, attribute) {
|
|
107
|
+
const params = new URLSearchParams({
|
|
108
|
+
eid: eid.toString(),
|
|
109
|
+
attribute,
|
|
110
|
+
});
|
|
111
|
+
return await nonNullFetchApi(this._binaryApiUrl + params, {
|
|
112
|
+
method: "GET",
|
|
113
|
+
credentials: "include",
|
|
128
114
|
});
|
|
129
115
|
}
|
|
130
|
-
rql(transaction) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return yield this.multipartTransaction(transaction);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return yield this.jsonTransaction(transaction);
|
|
138
|
-
}
|
|
116
|
+
async rql(transaction) {
|
|
117
|
+
try {
|
|
118
|
+
if (Object.keys(transaction.binaries).length > 0) {
|
|
119
|
+
return await this.multipartTransaction(transaction);
|
|
139
120
|
}
|
|
140
|
-
|
|
141
|
-
this.
|
|
121
|
+
else {
|
|
122
|
+
return await this.jsonTransaction(transaction);
|
|
142
123
|
}
|
|
143
|
-
}
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
this.handleUserErrors(e);
|
|
127
|
+
}
|
|
144
128
|
}
|
|
145
129
|
getTransactionParams(transaction) {
|
|
146
130
|
return transaction.queries.map((transactionQuery) => ({
|
|
@@ -148,31 +132,27 @@ class Api {
|
|
|
148
132
|
params: transactionQuery.params,
|
|
149
133
|
}));
|
|
150
134
|
}
|
|
151
|
-
multipartTransaction(transaction) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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);
|
|
135
|
+
async multipartTransaction(transaction) {
|
|
136
|
+
const jsonParams = this.getTransactionParams(transaction);
|
|
137
|
+
const formData = new FormData();
|
|
138
|
+
formData.append("queries", JSON.stringify(jsonParams));
|
|
139
|
+
Object.entries(transaction.binaries).forEach(([key, value]) => {
|
|
140
|
+
formData.append(key, value);
|
|
165
141
|
});
|
|
142
|
+
const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
|
|
143
|
+
method: "POST",
|
|
144
|
+
credentials: "include",
|
|
145
|
+
body: formData,
|
|
146
|
+
});
|
|
147
|
+
return new TransactionResult(resultSets);
|
|
166
148
|
}
|
|
167
|
-
jsonTransaction(transaction) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
173
|
-
});
|
|
174
|
-
return new Transaction_1.TransactionResult(resultSets);
|
|
149
|
+
async jsonTransaction(transaction) {
|
|
150
|
+
const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
|
|
151
|
+
method: "POST",
|
|
152
|
+
credentials: "include",
|
|
153
|
+
body: JSON.stringify(this.getTransactionParams(transaction)),
|
|
175
154
|
});
|
|
155
|
+
return new TransactionResult(resultSets);
|
|
176
156
|
}
|
|
177
157
|
handleUserErrors(error) {
|
|
178
158
|
if (typeof error === "object" &&
|
|
@@ -182,14 +162,13 @@ class Api {
|
|
|
182
162
|
"message" in error &&
|
|
183
163
|
typeof error.message === "string") {
|
|
184
164
|
if (error.title === "ValidationError") {
|
|
185
|
-
throw new
|
|
165
|
+
throw new ValidationError(error.message);
|
|
186
166
|
}
|
|
187
167
|
throw error;
|
|
188
168
|
}
|
|
189
169
|
throw error;
|
|
190
170
|
}
|
|
191
171
|
}
|
|
192
|
-
exports.default = Api;
|
|
193
172
|
/**
|
|
194
173
|
* Behaves the same as `fetchAPI` but forbids null responses.
|
|
195
174
|
* If this function detects a null response from the API,
|
|
@@ -199,19 +178,17 @@ exports.default = Api;
|
|
|
199
178
|
* @param init Additional request parameters
|
|
200
179
|
* @returns A promise with the non-null fetched result
|
|
201
180
|
*/
|
|
202
|
-
function nonNullFetchApi(input, init) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return result;
|
|
214
|
-
});
|
|
181
|
+
async function nonNullFetchApi(input, init) {
|
|
182
|
+
const result = await fetchApi(input, init);
|
|
183
|
+
if (result == null) {
|
|
184
|
+
const error = {
|
|
185
|
+
status: 500,
|
|
186
|
+
title: "Unexpected null response",
|
|
187
|
+
message: "Response was null but a value was expected",
|
|
188
|
+
};
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
215
192
|
}
|
|
216
193
|
/**
|
|
217
194
|
* Sends a request to the given API route with the `Content-Type` header set and waits for a response.
|
|
@@ -222,46 +199,50 @@ function nonNullFetchApi(input, init) {
|
|
|
222
199
|
* @param init Additional request parameters
|
|
223
200
|
* @returns A promise with the fetched result
|
|
224
201
|
*/
|
|
225
|
-
function fetchApi(input, init) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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);
|
|
202
|
+
async function fetchApi(input, init) {
|
|
203
|
+
let headers = init?.headers;
|
|
204
|
+
if (init?.method && init.method !== "GET") {
|
|
205
|
+
headers = {
|
|
206
|
+
// CSRF custom header necessary for POST requests
|
|
207
|
+
"X-Client-Name": "XMLHttpRequest",
|
|
208
|
+
};
|
|
209
|
+
// Browsers will automatically set the multipart content type
|
|
210
|
+
// with the right boundary if the body is FormData
|
|
211
|
+
if (!(init.body instanceof FormData)) {
|
|
212
|
+
headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
239
213
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
214
|
+
headers = {
|
|
215
|
+
...headers,
|
|
216
|
+
...init?.headers,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const response = await fetch(input, {
|
|
220
|
+
...init,
|
|
221
|
+
headers,
|
|
222
|
+
});
|
|
223
|
+
const status = response.status;
|
|
224
|
+
if (status >= 200 && status < 300) {
|
|
225
|
+
if (status === 204) {
|
|
226
|
+
return null;
|
|
253
227
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
try {
|
|
257
|
-
json = yield response.json();
|
|
258
|
-
}
|
|
259
|
-
catch (e) {
|
|
260
|
-
console.error(e);
|
|
261
|
-
throw { status, title: "Error", message: "" };
|
|
262
|
-
}
|
|
263
|
-
throw Object.assign({ status }, json);
|
|
228
|
+
try {
|
|
229
|
+
return await response.json();
|
|
264
230
|
}
|
|
265
|
-
|
|
231
|
+
catch (e) {
|
|
232
|
+
console.error(e);
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
let json;
|
|
238
|
+
try {
|
|
239
|
+
json = await response.json();
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
console.error(e);
|
|
243
|
+
throw { status, title: "Error", message: "" };
|
|
244
|
+
}
|
|
245
|
+
throw { status, ...json };
|
|
246
|
+
}
|
|
266
247
|
}
|
|
267
248
|
//# sourceMappingURL=Api.js.map
|
package/lib/api/Api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"
|
|
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,EACL,iBAAiB,GAIlB,MAAM,kBAAkB,CAAC;AAiE1B;;;;;;;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,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CA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C,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,6 @@
|
|
|
1
|
-
import { Schema } from "../schema/classes/Schema";
|
|
2
|
-
import { RQLParams, ResultSet, CurrentUser } from "./Api";
|
|
3
|
-
import { BinariesParam, Transaction, TransactionResult } from "./Transaction";
|
|
1
|
+
import { Schema } from "../schema/classes/Schema.js";
|
|
2
|
+
import { RQLParams, ResultSet, CurrentUser } from "./Api.js";
|
|
3
|
+
import { BinariesParam, Transaction, TransactionResult } from "./Transaction.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class used to communicate with a CubicWeb instance's API.
|
|
6
6
|
*
|
|
@@ -30,7 +30,7 @@ export default class Client {
|
|
|
30
30
|
*
|
|
31
31
|
* @returns The CubicWeb instance's JSON schema.
|
|
32
32
|
*/
|
|
33
|
-
schema(): Promise<Schema<import("
|
|
33
|
+
schema(): Promise<Schema<import("../index.js").EntityRawSchemaArray, import("../index.js").RelationDefinitionRawSchemaArray<import("../index.js").EntityRawSchemaArray>>>;
|
|
34
34
|
/**
|
|
35
35
|
* Tries to log in the user on the configured CubicWeb instance with the given credentials.
|
|
36
36
|
*
|
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,
|
|
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,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EACL,aAAa,EACb,WAAW,EACX,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B;;;;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
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const Schema_1 = require("../schema/classes/Schema");
|
|
16
|
-
const Api_1 = __importDefault(require("./Api"));
|
|
17
|
-
const Transaction_1 = require("./Transaction");
|
|
1
|
+
import { Schema } from "../schema/classes/Schema.js";
|
|
2
|
+
import Api from "./Api.js";
|
|
3
|
+
import { Transaction, } from "./Transaction.js";
|
|
18
4
|
/**
|
|
19
5
|
* Class used to communicate with a CubicWeb instance's API.
|
|
20
6
|
*
|
|
21
7
|
* @category Api
|
|
22
8
|
*/
|
|
23
|
-
class Client {
|
|
9
|
+
export default class Client {
|
|
10
|
+
api;
|
|
24
11
|
/**
|
|
25
12
|
* Class used to communicate with a CubicWeb instance's API.
|
|
26
13
|
*
|
|
@@ -29,7 +16,7 @@ class Client {
|
|
|
29
16
|
* use https://example.com/api as `apiUrl`.
|
|
30
17
|
*/
|
|
31
18
|
constructor(apiUrl) {
|
|
32
|
-
this.api = new
|
|
19
|
+
this.api = new Api(apiUrl);
|
|
33
20
|
}
|
|
34
21
|
get apiUrl() {
|
|
35
22
|
return this.api.apiUrl;
|
|
@@ -41,25 +28,21 @@ class Client {
|
|
|
41
28
|
* @param params The additional parameters for the request
|
|
42
29
|
* @returns A promise with the request's result set
|
|
43
30
|
*/
|
|
44
|
-
execute(query, params = {}, binaries) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return result.resolveQuery(transactionQuery.ref());
|
|
51
|
-
});
|
|
31
|
+
async execute(query, params = {}, binaries) {
|
|
32
|
+
const transaction = new Transaction();
|
|
33
|
+
const transactionQuery = transaction.push(query, params);
|
|
34
|
+
transaction.setBinaries(binaries);
|
|
35
|
+
const result = await this.executeTransaction(transaction);
|
|
36
|
+
return result.resolveQuery(transactionQuery.ref());
|
|
52
37
|
}
|
|
53
38
|
/**
|
|
54
39
|
* Retrieves the CubicWeb instance's JSON schema.
|
|
55
40
|
*
|
|
56
41
|
* @returns The CubicWeb instance's JSON schema.
|
|
57
42
|
*/
|
|
58
|
-
schema() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return new Schema_1.Schema(schema);
|
|
62
|
-
});
|
|
43
|
+
async schema() {
|
|
44
|
+
const schema = await this.api.schema();
|
|
45
|
+
return new Schema(schema);
|
|
63
46
|
}
|
|
64
47
|
/**
|
|
65
48
|
* Tries to log in the user on the configured CubicWeb instance with the given credentials.
|
|
@@ -68,50 +51,39 @@ class Client {
|
|
|
68
51
|
* @param password THe user password
|
|
69
52
|
* @returns A promise returning true if the login was successful, false otherwise
|
|
70
53
|
*/
|
|
71
|
-
login(login, password) {
|
|
72
|
-
return
|
|
73
|
-
return yield this.api.login(login, password);
|
|
74
|
-
});
|
|
54
|
+
async login(login, password) {
|
|
55
|
+
return await this.api.login(login, password);
|
|
75
56
|
}
|
|
76
57
|
/**
|
|
77
58
|
* Logs out the current user. Will invalidate any authentication cookie active.
|
|
78
59
|
*
|
|
79
60
|
* @returns A promise which will resolve when the user is properly logged out
|
|
80
61
|
*/
|
|
81
|
-
logout() {
|
|
82
|
-
return
|
|
83
|
-
return yield this.api.logout();
|
|
84
|
-
});
|
|
62
|
+
async logout() {
|
|
63
|
+
return await this.api.logout();
|
|
85
64
|
}
|
|
86
65
|
/**
|
|
87
66
|
* Get the user associated to this client
|
|
88
67
|
*
|
|
89
68
|
* @returns A promise resolving to the current user
|
|
90
69
|
*/
|
|
91
|
-
currentUser() {
|
|
92
|
-
return
|
|
93
|
-
return yield this.api.currentUser();
|
|
94
|
-
});
|
|
70
|
+
async currentUser() {
|
|
71
|
+
return await this.api.currentUser();
|
|
95
72
|
}
|
|
96
73
|
/**
|
|
97
74
|
* @param transaction Transaction to execute
|
|
98
75
|
* @returns A promise fulfilled when the transaction is completed
|
|
99
76
|
*/
|
|
100
|
-
executeTransaction(transaction) {
|
|
101
|
-
return
|
|
102
|
-
return yield this.api.rql(transaction);
|
|
103
|
-
});
|
|
77
|
+
async executeTransaction(transaction) {
|
|
78
|
+
return await this.api.rql(transaction);
|
|
104
79
|
}
|
|
105
80
|
/**
|
|
106
81
|
* Get the binary for the given entity attribute
|
|
107
82
|
*
|
|
108
83
|
* @returns A promise resolving to the binary
|
|
109
84
|
*/
|
|
110
|
-
getBinary(eid, attribute) {
|
|
111
|
-
return
|
|
112
|
-
return yield this.api.binary(eid, attribute);
|
|
113
|
-
});
|
|
85
|
+
async getBinary(eid, attribute) {
|
|
86
|
+
return await this.api.binary(eid, attribute);
|
|
114
87
|
}
|
|
115
88
|
}
|
|
116
|
-
exports.default = Client;
|
|
117
89
|
//# sourceMappingURL=Client.js.map
|
package/lib/api/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,GAA0C,MAAM,UAAU,CAAC;AAClE,OAAO,EAEL,WAAW,GAEZ,MAAM,kBAAkB,CAAC;AAE1B;;;;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;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CACX,KAAa,EACb,SAAoB,EAAE,EACtB,QAAwB;QAExB,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,gBAAgB,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,WAAW,CAAC,QAAQ,CA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