@cubicweb/client 3.0.0-alpha.8 → 3.0.0

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.
Files changed (122) hide show
  1. package/README.md +58 -34
  2. package/lib/Authenticator.d.ts +8 -0
  3. package/lib/Authenticator.d.ts.map +1 -0
  4. package/lib/Authenticator.js +2 -0
  5. package/lib/Authenticator.js.map +1 -0
  6. package/lib/api/Api.d.ts +56 -23
  7. package/lib/api/Api.d.ts.map +1 -1
  8. package/lib/api/Api.js +141 -140
  9. package/lib/api/Api.js.map +1 -1
  10. package/lib/api/Client.d.ts +26 -10
  11. package/lib/api/Client.d.ts.map +1 -1
  12. package/lib/api/Client.js +41 -58
  13. package/lib/api/Client.js.map +1 -1
  14. package/lib/api/ResultSet.d.ts +52 -0
  15. package/lib/api/ResultSet.d.ts.map +1 -0
  16. package/lib/api/ResultSet.js +64 -0
  17. package/lib/api/ResultSet.js.map +1 -0
  18. package/lib/api/authenticators/CookieAuthenticator.d.ts +10 -0
  19. package/lib/api/authenticators/CookieAuthenticator.d.ts.map +1 -0
  20. package/lib/api/authenticators/CookieAuthenticator.js +11 -0
  21. package/lib/api/authenticators/CookieAuthenticator.js.map +1 -0
  22. package/lib/api/authenticators/SignedRequestAuthenticator.d.ts +32 -0
  23. package/lib/api/authenticators/SignedRequestAuthenticator.d.ts.map +1 -0
  24. package/lib/api/authenticators/SignedRequestAuthenticator.js +89 -0
  25. package/lib/api/authenticators/SignedRequestAuthenticator.js.map +1 -0
  26. package/lib/api/binary/RQLBinary.d.ts +6 -0
  27. package/lib/api/binary/RQLBinary.d.ts.map +1 -0
  28. package/lib/api/binary/RQLBinary.js +10 -0
  29. package/lib/api/binary/RQLBinary.js.map +1 -0
  30. package/lib/api/query/RQLQuery.d.ts +40 -0
  31. package/lib/api/query/RQLQuery.d.ts.map +1 -0
  32. package/lib/api/query/RQLQuery.js +48 -0
  33. package/lib/api/query/RQLQuery.js.map +1 -0
  34. package/lib/api/query/references.d.ts +41 -0
  35. package/lib/api/query/references.d.ts.map +1 -0
  36. package/lib/api/query/references.js +50 -0
  37. package/lib/api/query/references.js.map +1 -0
  38. package/lib/api/transaction/Transaction.d.ts +25 -0
  39. package/lib/api/transaction/Transaction.d.ts.map +1 -0
  40. package/lib/api/transaction/Transaction.js +28 -0
  41. package/lib/api/transaction/Transaction.js.map +1 -0
  42. package/lib/api/transaction/TransactionResult.d.ts +41 -0
  43. package/lib/api/transaction/TransactionResult.d.ts.map +1 -0
  44. package/lib/api/transaction/TransactionResult.js +45 -0
  45. package/lib/api/transaction/TransactionResult.js.map +1 -0
  46. package/lib/encodeFormData.d.ts +5 -0
  47. package/lib/encodeFormData.d.ts.map +1 -0
  48. package/lib/encodeFormData.js +94 -0
  49. package/lib/encodeFormData.js.map +1 -0
  50. package/lib/{Errors.d.ts → errors.d.ts} +7 -4
  51. package/lib/errors.d.ts.map +1 -0
  52. package/lib/errors.js +19 -0
  53. package/lib/errors.js.map +1 -0
  54. package/lib/index.d.ts +19 -13
  55. package/lib/index.d.ts.map +1 -1
  56. package/lib/index.js +17 -34
  57. package/lib/index.js.map +1 -1
  58. package/lib/schema/classes/EntitySchema.d.ts +5 -5
  59. package/lib/schema/classes/EntitySchema.d.ts.map +1 -1
  60. package/lib/schema/classes/EntitySchema.js +3 -5
  61. package/lib/schema/classes/EntitySchema.js.map +1 -1
  62. package/lib/schema/classes/RelationDefinitionSchema.d.ts +6 -6
  63. package/lib/schema/classes/RelationDefinitionSchema.d.ts.map +1 -1
  64. package/lib/schema/classes/RelationDefinitionSchema.js +8 -10
  65. package/lib/schema/classes/RelationDefinitionSchema.js.map +1 -1
  66. package/lib/schema/classes/Schema.d.ts +7 -7
  67. package/lib/schema/classes/Schema.d.ts.map +1 -1
  68. package/lib/schema/classes/Schema.js +8 -11
  69. package/lib/schema/classes/Schema.js.map +1 -1
  70. package/lib/schema/classes/Utils.d.ts +10 -10
  71. package/lib/schema/classes/Utils.d.ts.map +1 -1
  72. package/lib/schema/classes/Utils.js +19 -35
  73. package/lib/schema/classes/Utils.js.map +1 -1
  74. package/lib/schema/raw/Constraints.d.ts +27 -0
  75. package/lib/schema/raw/Constraints.d.ts.map +1 -1
  76. package/lib/schema/raw/Constraints.js +1 -2
  77. package/lib/schema/raw/Entities.js +1 -2
  78. package/lib/schema/raw/RelationDefinitions.d.ts +3 -3
  79. package/lib/schema/raw/RelationDefinitions.d.ts.map +1 -1
  80. package/lib/schema/raw/RelationDefinitions.js +1 -2
  81. package/lib/schema/raw/Schema.d.ts +2 -2
  82. package/lib/schema/raw/Schema.d.ts.map +1 -1
  83. package/lib/schema/raw/Schema.js +1 -2
  84. package/lib/schema/raw/Utils.d.ts +1 -1
  85. package/lib/schema/raw/Utils.d.ts.map +1 -1
  86. package/lib/schema/raw/Utils.js +1 -2
  87. package/lib/utils.d.ts +39 -0
  88. package/lib/utils.d.ts.map +1 -0
  89. package/lib/utils.js +58 -0
  90. package/lib/utils.js.map +1 -0
  91. package/package.json +15 -5
  92. package/src/Authenticator.ts +8 -0
  93. package/src/api/Api.ts +148 -122
  94. package/src/api/Client.ts +31 -18
  95. package/src/api/ResultSet.ts +95 -0
  96. package/src/api/authenticators/CookieAuthenticator.ts +17 -0
  97. package/src/api/authenticators/SignedRequestAuthenticator.ts +133 -0
  98. package/src/api/binary/RQLBinary.ts +9 -0
  99. package/src/api/query/RQLQuery.ts +51 -0
  100. package/src/api/query/references.ts +43 -0
  101. package/src/api/transaction/Transaction.ts +31 -0
  102. package/src/api/transaction/TransactionResult.ts +68 -0
  103. package/src/encodeFormData.ts +126 -0
  104. package/src/{Errors.ts → errors.ts} +6 -7
  105. package/src/index.ts +24 -17
  106. package/src/schema/classes/EntitySchema.ts +8 -5
  107. package/src/schema/classes/RelationDefinitionSchema.ts +7 -7
  108. package/src/schema/classes/Schema.ts +10 -7
  109. package/src/schema/classes/Utils.ts +4 -4
  110. package/src/schema/raw/Constraints.ts +28 -0
  111. package/src/schema/raw/RelationDefinitions.ts +3 -3
  112. package/src/schema/raw/Schema.ts +2 -2
  113. package/src/schema/raw/Utils.ts +1 -1
  114. package/src/utils.ts +91 -0
  115. package/lib/Errors.d.ts.map +0 -1
  116. package/lib/Errors.js +0 -25
  117. package/lib/Errors.js.map +0 -1
  118. package/lib/api/Transaction.d.ts +0 -46
  119. package/lib/api/Transaction.d.ts.map +0 -1
  120. package/lib/api/Transaction.js +0 -75
  121. package/lib/api/Transaction.js.map +0 -1
  122. package/src/api/Transaction.ts +0 -94
package/lib/api/Api.js CHANGED
@@ -1,37 +1,35 @@
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
- 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 { getBinariesFromTransaction, serializeQueryParams } from "../utils.js";
3
+ import { TransactionResult, } from "./transaction/TransactionResult.js";
14
4
  /**
15
5
  * Class used to handle requests to the CubicWeb API.
16
6
  *
17
7
  * You should never have to create this object yourself.
18
- * Instead, retrieve this object from the methods in the `Client` class.
8
+ * Instead, retrieve this object from the methods in the {@link Client} class.
19
9
  *
20
10
  * @internal
21
11
  */
22
- class Api {
12
+ export default class Api {
13
+ _apiUrl;
14
+ _version = "v1";
15
+ _rqlApiUrl;
16
+ _schemaApiUrl;
17
+ _loginApiUrl;
18
+ _logoutApiUrl;
19
+ _currentUserApiUrl;
20
+ _binaryApiUrl;
21
+ _authenticator;
23
22
  /**
24
23
  * Class used to handle requests to the CubicWeb API.
25
24
  *
26
25
  * You should never have to create this object yourself.
27
- * Instead, retrieve this object from the methods in the `Client` class.
26
+ * Instead, retrieve this object from the methods in the {@link Client} class.
28
27
  *
29
28
  * @param apiUrl The API url. It should not include the API version as it will be automatically added.
30
29
  * Example: if you can retrieve the schema with https://example.com/api/v1/schema,
31
30
  * use https://example.com/api as `apiUrl`.
32
31
  */
33
- constructor(apiUrl) {
34
- this._version = "v1";
32
+ constructor(apiUrl, options) {
35
33
  this._apiUrl = apiUrl;
36
34
  this._rqlApiUrl = this.getApiRoute("rql");
37
35
  this._schemaApiUrl = this.getApiRoute("schema");
@@ -39,6 +37,7 @@ class Api {
39
37
  this._logoutApiUrl = this.getApiRoute("logout");
40
38
  this._currentUserApiUrl = this.getApiRoute("current-user");
41
39
  this._binaryApiUrl = this.getApiRoute("binary");
40
+ this._authenticator = options.authenticator;
42
41
  }
43
42
  get apiUrl() {
44
43
  return this._apiUrl;
@@ -51,50 +50,41 @@ class Api {
51
50
  *
52
51
  * @returns The CubicWeb instance's JSON schema.
53
52
  */
54
- schema() {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- return nonNullFetchApi(this._schemaApiUrl, {
57
- method: "GET",
58
- credentials: "include",
59
- });
53
+ async schema() {
54
+ return this.nonNullFetchApi(this._schemaApiUrl, {
55
+ method: "GET",
60
56
  });
61
57
  }
62
58
  /**
63
59
  * Tries to log in the user on the configured CubicWeb instance with the given credentials.
64
60
  *
65
61
  * @param login The user login
66
- * @param password THe user password
62
+ * @param password The user password
67
63
  * @returns A promise returning true if the login was successful, false otherwise
68
64
  */
69
- login(login, password) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- try {
72
- yield fetchApi(this._loginApiUrl, {
73
- method: "POST",
74
- body: JSON.stringify({
75
- login,
76
- password,
77
- }),
78
- credentials: "include",
79
- });
80
- return true;
81
- }
82
- catch (_error) {
83
- return false;
84
- }
85
- });
65
+ async login(login, password) {
66
+ try {
67
+ await this.fetchApi(this._loginApiUrl, {
68
+ method: "POST",
69
+ body: JSON.stringify({
70
+ login,
71
+ password,
72
+ }),
73
+ });
74
+ return true;
75
+ }
76
+ catch (_error) {
77
+ return false;
78
+ }
86
79
  }
87
80
  /**
88
81
  * Logs out the current user. Will invalidate any authentication cookie active.
89
82
  *
90
83
  * @returns A promise which will resolve when the user is properly logged out
91
84
  */
92
- logout() {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- yield fetchApi(this._logoutApiUrl, {
95
- method: "POST",
96
- credentials: "include",
97
- });
85
+ async logout() {
86
+ await this.fetchApi(this._logoutApiUrl, {
87
+ method: "POST",
98
88
  });
99
89
  }
100
90
  /**
@@ -102,77 +92,75 @@ class Api {
102
92
  *
103
93
  * @returns A promise resolving to the current user
104
94
  */
105
- currentUser() {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- return yield nonNullFetchApi(this._currentUserApiUrl, {
108
- method: "GET",
109
- credentials: "include",
110
- });
95
+ async currentUser() {
96
+ return await this.nonNullFetchApi(this._currentUserApiUrl, {
97
+ method: "GET",
111
98
  });
112
99
  }
113
100
  /**
114
101
  * Get the binary for the given entity attribute
115
102
  *
116
- * @returns A promise resolving to the binary
103
+ * @param eid Entity eid to fetch the binary from
104
+ * @param attribute Attribute on the entity in which the binary is stored
105
+ * @returns A promise resolving to the binary as a Blob
117
106
  */
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
- });
107
+ async binary(eid, attribute) {
108
+ const params = new URLSearchParams({
109
+ eid: eid.toString(),
110
+ attribute,
111
+ });
112
+ return await this.nonNullFetchApi(this._binaryApiUrl + params, {
113
+ method: "GET",
128
114
  });
129
115
  }
130
- rql(transaction) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- try {
133
- if (Object.keys(transaction.binaries).length > 0) {
134
- return yield this.multipartTransaction(transaction);
135
- }
136
- else {
137
- return yield this.jsonTransaction(transaction);
138
- }
116
+ /**
117
+ * Executes the given transaction.
118
+ *
119
+ * If the {@link Transaction} object contains binaries, the request is automatically
120
+ * sent using `multipart/form-data` to allow uploading binaries.
121
+ *
122
+ * @param transaction Transaction to execute
123
+ * @returns A promise returning the transaction result on success
124
+ */
125
+ async rql(transaction) {
126
+ const binaries = getBinariesFromTransaction(transaction);
127
+ try {
128
+ if (binaries.length > 0) {
129
+ return await this.multipartTransaction(transaction, binaries);
139
130
  }
140
- catch (e) {
141
- this.handleUserErrors(e);
131
+ else {
132
+ return await this.jsonTransaction(transaction);
142
133
  }
143
- });
134
+ }
135
+ catch (e) {
136
+ this.handleUserErrors(e);
137
+ }
144
138
  }
145
139
  getTransactionParams(transaction) {
146
- return transaction.queries.map((transactionQuery) => ({
147
- query: transactionQuery.query,
148
- params: transactionQuery.params,
140
+ return transaction.queries.map((rqlQuery) => ({
141
+ query: rqlQuery.rql,
142
+ params: serializeQueryParams(transaction, rqlQuery.params),
149
143
  }));
150
144
  }
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);
145
+ async multipartTransaction(transaction, binaries) {
146
+ const jsonParams = this.getTransactionParams(transaction);
147
+ const formData = new FormData();
148
+ formData.append("queries", JSON.stringify(jsonParams));
149
+ binaries.forEach((binary) => {
150
+ formData.append(binary.uuid, binary.blob);
165
151
  });
152
+ const resultSets = await this.nonNullFetchApi(this._rqlApiUrl, {
153
+ method: "POST",
154
+ body: formData,
155
+ });
156
+ return new TransactionResult(transaction, resultSets);
166
157
  }
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);
158
+ async jsonTransaction(transaction) {
159
+ const resultSets = await this.nonNullFetchApi(this._rqlApiUrl, {
160
+ method: "POST",
161
+ body: JSON.stringify(this.getTransactionParams(transaction)),
175
162
  });
163
+ return new TransactionResult(transaction, resultSets);
176
164
  }
177
165
  handleUserErrors(error) {
178
166
  if (typeof error === "object" &&
@@ -182,26 +170,23 @@ class Api {
182
170
  "message" in error &&
183
171
  typeof error.message === "string") {
184
172
  if (error.title === "ValidationError") {
185
- throw new Errors_1.ValidationError(error.message);
173
+ throw new ValidationError(error.message);
186
174
  }
187
175
  throw error;
188
176
  }
189
177
  throw error;
190
178
  }
191
- }
192
- exports.default = Api;
193
- /**
194
- * Behaves the same as `fetchAPI` but forbids null responses.
195
- * If this function detects a null response from the API,
196
- * the promise will be rejected with a 500 error code.
197
- *
198
- * @param input The API route to use
199
- * @param init Additional request parameters
200
- * @returns A promise with the non-null fetched result
201
- */
202
- function nonNullFetchApi(input, init) {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- const result = yield fetchApi(input, init);
179
+ /**
180
+ * Behaves the same as `fetchAPI` but forbids null responses.
181
+ * If this function detects a null response from the API,
182
+ * the promise will be rejected with a 500 error code.
183
+ *
184
+ * @param input The API route to use
185
+ * @param init Additional request parameters
186
+ * @returns A promise with the non-null fetched result
187
+ */
188
+ async nonNullFetchApi(url, init) {
189
+ const result = await this.fetchApi(url, init);
205
190
  if (result == null) {
206
191
  const error = {
207
192
  status: 500,
@@ -211,33 +196,49 @@ function nonNullFetchApi(input, init) {
211
196
  throw error;
212
197
  }
213
198
  return result;
214
- });
215
- }
216
- /**
217
- * Sends a request to the given API route with the `Content-Type` header set and waits for a response.
218
- * The returned promise will be rejected if the API returns HTTP error codes.
219
- * The rejected promise will contain an `ApiErrorResponse` object.
220
- *
221
- * @param input The API route to use
222
- * @param init Additional request parameters
223
- * @returns A promise with the fetched result
224
- */
225
- function fetchApi(input, init) {
226
- return __awaiter(this, void 0, void 0, function* () {
227
- let headers = init === null || init === void 0 ? void 0 : init.headers;
228
- if ((init === null || init === void 0 ? void 0 : init.method) && init.method !== "GET") {
229
- headers = Object.assign({ "Content-Type": "application/json;charset=UTF-8",
230
- // CSRF custom header necessary for POST requests
231
- "X-Client-Name": "XMLHttpRequest" }, init === null || init === void 0 ? void 0 : init.headers);
199
+ }
200
+ /**
201
+ * Sends a request to the given API route with the `Content-Type` header set and waits for a response.
202
+ * The returned promise will be rejected if the API returns HTTP error codes.
203
+ * The rejected promise will contain an `ApiErrorResponse` object.
204
+ *
205
+ * @param input The API route to use
206
+ * @param init Additional request parameters
207
+ * @returns A promise with the fetched result
208
+ */
209
+ async fetchApi(url, init) {
210
+ const headers = new Headers(init.headers);
211
+ // Add custom header used as CSRF protection
212
+ // note: it is only necessary for non GET requests but can also be useful
213
+ // while debugging.
214
+ if (!headers.has("X-Client-Name")) {
215
+ headers.append("X-Client-Name", "XMLHttpRequest");
232
216
  }
233
- const response = yield fetch(input, Object.assign(Object.assign({}, init), { headers }));
217
+ // Add a "Content-Type" header whenever a body is passed.
218
+ // The header might already have been set (either by the caller of this
219
+ // function or by and encoder)
220
+ if (init.body &&
221
+ !headers.has("Content-Type") &&
222
+ !(init.body instanceof FormData)) {
223
+ headers.append("Content-Type", "application/json;charset=UTF-8");
224
+ }
225
+ init.headers = headers;
226
+ // Authenticate request
227
+ if (this._authenticator) {
228
+ const authenticatedRequest = await this._authenticator.authenticate(url, init);
229
+ url = authenticatedRequest.url;
230
+ init = authenticatedRequest.init;
231
+ }
232
+ // Execute request
233
+ const response = await fetch(url, init);
234
+ // Parse response body and handle errors
234
235
  const status = response.status;
235
236
  if (status >= 200 && status < 300) {
236
237
  if (status === 204) {
237
238
  return null;
238
239
  }
239
240
  try {
240
- return yield response.json();
241
+ return await response.json();
241
242
  }
242
243
  catch (e) {
243
244
  console.error(e);
@@ -247,14 +248,14 @@ function fetchApi(input, init) {
247
248
  else {
248
249
  let json;
249
250
  try {
250
- json = yield response.json();
251
+ json = await response.json();
251
252
  }
252
253
  catch (e) {
253
254
  console.error(e);
254
255
  throw { status, title: "Error", message: "" };
255
256
  }
256
- throw Object.assign({ status }, json);
257
+ throw { status, ...json };
257
258
  }
258
- });
259
+ }
259
260
  }
260
261
  //# sourceMappingURL=Api.js.map
@@ -1 +1 @@
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,CAAC,CAAC;QAChD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEO,WAAW,CAAC,KAAa;QAC/B,OAAO,GAAG,IAAI,CAAC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N,IAAI,IAAI,CAAC;YACT,IAAI,CAAC;gBACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC/B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAChD,CAAC;YACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
@@ -1,6 +1,12 @@
1
- import { Schema } from "../schema/classes/Schema";
2
- import { RQLParams, ResultSet, CurrentUser } from "./Api";
3
- import { BinariesParam, Transaction, TransactionResult } from "./Transaction";
1
+ import { Authenticator } from "../Authenticator.js";
2
+ import { Schema } from "../schema/classes/Schema.js";
3
+ import { RQLQueryParams, CurrentUser } from "./Api.js";
4
+ import { ResultSet } from "./ResultSet.js";
5
+ import { Transaction } from "./transaction/Transaction.js";
6
+ import { TransactionResult } from "./transaction/TransactionResult.js";
7
+ export interface ClientOptions {
8
+ authenticator?: Authenticator;
9
+ }
4
10
  /**
5
11
  * Class used to communicate with a CubicWeb instance's API.
6
12
  *
@@ -15,27 +21,30 @@ export default class Client {
15
21
  * Example: if you can retrieve the schema with https://example.com/api/v1/schema,
16
22
  * use https://example.com/api as `apiUrl`.
17
23
  */
18
- constructor(apiUrl: string);
24
+ constructor(apiUrl: string, options?: ClientOptions);
19
25
  get apiUrl(): string;
20
26
  /**
21
27
  * Executes the given query and waits for the response.
22
28
  *
23
- * @param query The RQL query to send
29
+ * If binaries are given, the request is automatically
30
+ * sent using `multipart/form-data` to allow uploading binaries.
31
+ *
32
+ * @param rql The RQL query to send
24
33
  * @param params The additional parameters for the request
25
34
  * @returns A promise with the request's result set
26
35
  */
27
- execute(query: string, params?: RQLParams, binaries?: BinariesParam): Promise<ResultSet>;
36
+ execute(rql: string, params?: RQLQueryParams): Promise<ResultSet>;
28
37
  /**
29
38
  * Retrieves the CubicWeb instance's JSON schema.
30
39
  *
31
40
  * @returns The CubicWeb instance's JSON schema.
32
41
  */
33
- schema(): Promise<Schema<import("..").EntityRawSchemaArray, import("..").RelationDefinitionRawSchemaArray<import("..").EntityRawSchemaArray>>>;
42
+ schema(): Promise<Schema<import("../index.js").EntityRawSchemaArray, import("../index.js").RelationDefinitionRawSchemaArray<import("../index.js").EntityRawSchemaArray>>>;
34
43
  /**
35
44
  * Tries to log in the user on the configured CubicWeb instance with the given credentials.
36
45
  *
37
46
  * @param login The user login
38
- * @param password THe user password
47
+ * @param password The user password
39
48
  * @returns A promise returning true if the login was successful, false otherwise
40
49
  */
41
50
  login(login: string, password: string): Promise<boolean>;
@@ -52,14 +61,21 @@ export default class Client {
52
61
  */
53
62
  currentUser(): Promise<CurrentUser>;
54
63
  /**
64
+ * Executes the given transaction.
65
+ *
66
+ * If the {@link Transaction} object contains binaries, the request is automatically
67
+ * sent using `multipart/form-data` to allow uploading binaries.
68
+ *
55
69
  * @param transaction Transaction to execute
56
- * @returns A promise fulfilled when the transaction is completed
70
+ * @returns A promise returning the transaction result on success
57
71
  */
58
72
  executeTransaction(transaction: Transaction): Promise<TransactionResult>;
59
73
  /**
60
74
  * Get the binary for the given entity attribute
61
75
  *
62
- * @returns A promise resolving to the binary
76
+ * @param eid Entity eid to fetch the binary from
77
+ * @param attribute Attribute on the entity in which the binary is stored
78
+ * @returns A promise resolving to the binary as a Blob
63
79
  */
64
80
  getBinary(eid: number, attribute: string): Promise<Blob>;
65
81
  }
@@ -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,EAAE,aAAa,EAAE,WAAW,EAAE,i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