@cubicweb/client 3.0.0-alpha.10 → 3.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +11 -20
  2. package/lib/api/Api.d.ts +30 -22
  3. package/lib/api/Api.d.ts.map +1 -1
  4. package/lib/api/Api.js +148 -154
  5. package/lib/api/Api.js.map +1 -1
  6. package/lib/api/Client.d.ts +21 -9
  7. package/lib/api/Client.d.ts.map +1 -1
  8. package/lib/api/Client.js +40 -57
  9. package/lib/api/Client.js.map +1 -1
  10. package/lib/api/ResultSet.d.ts +25 -0
  11. package/lib/api/ResultSet.d.ts.map +1 -0
  12. package/lib/api/ResultSet.js +12 -0
  13. package/lib/api/ResultSet.js.map +1 -0
  14. package/lib/api/binary/RQLBinary.d.ts +6 -0
  15. package/lib/api/binary/RQLBinary.d.ts.map +1 -0
  16. package/lib/api/binary/RQLBinary.js +10 -0
  17. package/lib/api/binary/RQLBinary.js.map +1 -0
  18. package/lib/api/query/RQLQuery.d.ts +40 -0
  19. package/lib/api/query/RQLQuery.d.ts.map +1 -0
  20. package/lib/api/query/RQLQuery.js +48 -0
  21. package/lib/api/query/RQLQuery.js.map +1 -0
  22. package/lib/api/query/references.d.ts +41 -0
  23. package/lib/api/query/references.d.ts.map +1 -0
  24. package/lib/api/query/references.js +50 -0
  25. package/lib/api/query/references.js.map +1 -0
  26. package/lib/api/transaction/Transaction.d.ts +25 -0
  27. package/lib/api/transaction/Transaction.d.ts.map +1 -0
  28. package/lib/api/transaction/Transaction.js +28 -0
  29. package/lib/api/transaction/Transaction.js.map +1 -0
  30. package/lib/api/transaction/TransactionResult.d.ts +32 -0
  31. package/lib/api/transaction/TransactionResult.d.ts.map +1 -0
  32. package/lib/api/transaction/TransactionResult.js +41 -0
  33. package/lib/api/transaction/TransactionResult.js.map +1 -0
  34. package/lib/{Errors.d.ts → errors.d.ts} +7 -4
  35. package/lib/errors.d.ts.map +1 -0
  36. package/lib/errors.js +19 -0
  37. package/lib/errors.js.map +1 -0
  38. package/lib/index.d.ts +18 -13
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/index.js +17 -34
  41. package/lib/index.js.map +1 -1
  42. package/lib/schema/classes/EntitySchema.d.ts +5 -5
  43. package/lib/schema/classes/EntitySchema.d.ts.map +1 -1
  44. package/lib/schema/classes/EntitySchema.js +3 -5
  45. package/lib/schema/classes/EntitySchema.js.map +1 -1
  46. package/lib/schema/classes/RelationDefinitionSchema.d.ts +6 -6
  47. package/lib/schema/classes/RelationDefinitionSchema.d.ts.map +1 -1
  48. package/lib/schema/classes/RelationDefinitionSchema.js +8 -10
  49. package/lib/schema/classes/RelationDefinitionSchema.js.map +1 -1
  50. package/lib/schema/classes/Schema.d.ts +7 -7
  51. package/lib/schema/classes/Schema.d.ts.map +1 -1
  52. package/lib/schema/classes/Schema.js +8 -11
  53. package/lib/schema/classes/Schema.js.map +1 -1
  54. package/lib/schema/classes/Utils.d.ts +10 -10
  55. package/lib/schema/classes/Utils.d.ts.map +1 -1
  56. package/lib/schema/classes/Utils.js +19 -35
  57. package/lib/schema/classes/Utils.js.map +1 -1
  58. package/lib/schema/raw/Constraints.d.ts +27 -0
  59. package/lib/schema/raw/Constraints.d.ts.map +1 -1
  60. package/lib/schema/raw/Constraints.js +1 -2
  61. package/lib/schema/raw/Entities.js +1 -2
  62. package/lib/schema/raw/RelationDefinitions.d.ts +3 -3
  63. package/lib/schema/raw/RelationDefinitions.d.ts.map +1 -1
  64. package/lib/schema/raw/RelationDefinitions.js +1 -2
  65. package/lib/schema/raw/Schema.d.ts +2 -2
  66. package/lib/schema/raw/Schema.d.ts.map +1 -1
  67. package/lib/schema/raw/Schema.js +1 -2
  68. package/lib/schema/raw/Utils.d.ts +1 -1
  69. package/lib/schema/raw/Utils.d.ts.map +1 -1
  70. package/lib/schema/raw/Utils.js +1 -2
  71. package/lib/utils.d.ts +39 -0
  72. package/lib/utils.d.ts.map +1 -0
  73. package/lib/utils.js +58 -0
  74. package/lib/utils.js.map +1 -0
  75. package/package.json +12 -5
  76. package/src/api/Api.ts +49 -42
  77. package/src/api/Client.ts +24 -15
  78. package/src/api/ResultSet.ts +29 -0
  79. package/src/api/binary/RQLBinary.ts +9 -0
  80. package/src/api/query/RQLQuery.ts +51 -0
  81. package/src/api/query/references.ts +43 -0
  82. package/src/api/transaction/Transaction.ts +31 -0
  83. package/src/api/transaction/TransactionResult.ts +46 -0
  84. package/src/{Errors.ts → errors.ts} +6 -7
  85. package/src/index.ts +21 -17
  86. package/src/schema/classes/EntitySchema.ts +8 -5
  87. package/src/schema/classes/RelationDefinitionSchema.ts +7 -7
  88. package/src/schema/classes/Schema.ts +10 -7
  89. package/src/schema/classes/Utils.ts +4 -4
  90. package/src/schema/raw/Constraints.ts +28 -0
  91. package/src/schema/raw/RelationDefinitions.ts +3 -3
  92. package/src/schema/raw/Schema.ts +2 -2
  93. package/src/schema/raw/Utils.ts +1 -1
  94. package/src/utils.ts +91 -0
  95. package/lib/Errors.d.ts.map +0 -1
  96. package/lib/Errors.js +0 -25
  97. package/lib/Errors.js.map +0 -1
  98. package/lib/api/Transaction.d.ts +0 -46
  99. package/lib/api/Transaction.d.ts.map +0 -1
  100. package/lib/api/Transaction.js +0 -75
  101. package/lib/api/Transaction.js.map +0 -1
  102. package/src/api/Transaction.ts +0 -94
package/README.md CHANGED
@@ -7,7 +7,7 @@ library.
7
7
 
8
8
  The full documentation is available [here](https://cubicweb.pages.logilab.fr/cubicwebjs/client).
9
9
 
10
- **Compatible with [API cube](https://forge.extranet.logilab.fr/cubicweb/cubes/api) version 0.13 only.**
10
+ **Compatible with [API cube](https://forge.extranet.logilab.fr/cubicweb/cubes/api) version 0.14 only.**
11
11
 
12
12
  ## Installation
13
13
 
@@ -78,23 +78,18 @@ client
78
78
 
79
79
  // Execute a series of request in a transaction
80
80
  const transaction = new Transaction()
81
- 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
- }
92
- }
93
- })
81
+ const insertQuery = new RQLQuery(`INSERT Person X: X name "test"`)
82
+ transaction.push(insertQuery)
83
+ transaction.push(
84
+ new RQLQuery(
85
+ `INSERT Person X: X name "test"`,
86
+ { created_eid: insertQuery.cellRef(0, 0) }
87
+ )
88
+ )
94
89
  client
95
90
  .executeTransaction(transaction)
96
91
  .then((callbackResult) => {
97
- console.log("Transaction was successul and the callback returned:");
92
+ console.log("Transaction was successful and the callback returned:");
98
93
  console.log(callbackResult);
99
94
  })
100
95
  .catch((e) => {
@@ -122,11 +117,7 @@ you must authorize the URL the client is running on as well as the `Content-Type
122
117
 
123
118
  ## Authentication
124
119
 
125
- The API cube uses cookie authentication using [JWT](https://jwt.io).
126
- A `CW_JWT` [HTTP Only](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#security) cookie
127
- will be automatically created by the browser when executing the login request.
128
- This cookie cannot be accessed by the JavaScript so you will have to implement your own
129
- logic to save the login state.
120
+ The API cube uses a cookie authentication method by default. When you call the login route, the cookie will be automatically created by the browser.
130
121
 
131
122
  If the client is running on a different server from your CubicWeb instance,
132
123
  make sure you setup CORS as described above.
package/lib/api/Api.d.ts CHANGED
@@ -1,32 +1,26 @@
1
- import { RawSchema } from "../schema/raw/Schema";
2
- import { TransactionResult, Transaction, TransactionQueryScalarRef, TransactionQueryBinaryRef } from "./Transaction";
1
+ import { RawSchema } from "../schema/raw/Schema.js";
2
+ import { RQLBinary } from "./binary/RQLBinary.js";
3
+ import { RQLQueryCellRef } from "./query/references.js";
4
+ import { Transaction } from "./transaction/Transaction.js";
5
+ import { TransactionResult } from "./transaction/TransactionResult.js";
3
6
  /**
4
- * Type representing an RQL request and its associated parameters.
7
+ * Type representing valid final values to use as parameters in a RQL query.
8
+ *
9
+ * For references to requests/binaries, see {@link RQLQueryCellRef} and {@link RQLQueryBinaryRef}
5
10
  *
6
11
  * @category Api
7
12
  */
8
- export type RQLQuery = [string, RQLParams];
9
- export type RQLParamValue = string | number | boolean | null;
13
+ export type RQLQueryParamValue = string | number | boolean | null;
10
14
  /**
11
15
  * Type representing RQL parameters to send along a request.
12
16
  *
13
- * @category Api
14
- */
15
- export type RQLParams = Record<string, RQLParamValue | TransactionQueryScalarRef | TransactionQueryBinaryRef>;
16
- /**
17
- * Type representing a row returned in a result set.
17
+ * Each key must be referenced in the RQL query.
18
18
  *
19
19
  * @category Api
20
20
  */
21
- export type RqlRow = Array<string | number | boolean | null>;
21
+ export type RQLQueryParams = Record<string, RQLQueryParamValue | RQLQueryCellRef | RQLBinary>;
22
22
  /**
23
- * Type representing a RQL request result.
24
- *
25
- * @category Api
26
- */
27
- export type ResultSet = Array<RqlRow>;
28
- /**
29
- * Type representing the currently logged user's data
23
+ * Type representing the currently logged user's data as returned by the `/current-user` route
30
24
  *
31
25
  * @category Api
32
26
  */
@@ -48,6 +42,9 @@ type ApiError = {
48
42
  /**
49
43
  * Type representing the error data sent to clients when retrieving an API error.
50
44
  *
45
+ * It simply adds the HTTP status code in a `status` key to the regular CubicWeb api error,
46
+ * so users can handle HTTP status codes in their code.
47
+ *
51
48
  * @category Api
52
49
  */
53
50
  export type ApiErrorResponse = {
@@ -57,7 +54,7 @@ export type ApiErrorResponse = {
57
54
  * Class used to handle requests to the CubicWeb API.
58
55
  *
59
56
  * You should never have to create this object yourself.
60
- * Instead, retrieve this object from the methods in the `Client` class.
57
+ * Instead, retrieve this object from the methods in the {@link Client} class.
61
58
  *
62
59
  * @internal
63
60
  */
@@ -74,7 +71,7 @@ export default class Api {
74
71
  * Class used to handle requests to the CubicWeb API.
75
72
  *
76
73
  * You should never have to create this object yourself.
77
- * Instead, retrieve this object from the methods in the `Client` class.
74
+ * Instead, retrieve this object from the methods in the {@link Client} class.
78
75
  *
79
76
  * @param apiUrl The API url. It should not include the API version as it will be automatically added.
80
77
  * Example: if you can retrieve the schema with https://example.com/api/v1/schema,
@@ -93,7 +90,7 @@ export default class Api {
93
90
  * Tries to log in the user on the configured CubicWeb instance with the given credentials.
94
91
  *
95
92
  * @param login The user login
96
- * @param password THe user password
93
+ * @param password The user password
97
94
  * @returns A promise returning true if the login was successful, false otherwise
98
95
  */
99
96
  login(login: string, password: string): Promise<boolean>;
@@ -112,9 +109,20 @@ export default class Api {
112
109
  /**
113
110
  * Get the binary for the given entity attribute
114
111
  *
115
- * @returns A promise resolving to the binary
112
+ * @param eid Entity eid to fetch the binary from
113
+ * @param attribute Attribute on the entity in which the binary is stored
114
+ * @returns A promise resolving to the binary as a Blob
116
115
  */
117
116
  binary(eid: number, attribute: string): Promise<Blob>;
117
+ /**
118
+ * Executes the given transaction.
119
+ *
120
+ * If the {@link Transaction} object contains binaries, the request is automatically
121
+ * sent using `multipart/form-data` to allow uploading binaries.
122
+ *
123
+ * @param transaction Transaction to execute
124
+ * @returns A promise returning the transaction result on success
125
+ */
118
126
  rql(transaction: Transaction): Promise<TransactionResult>;
119
127
  private getTransactionParams;
120
128
  private multipartTransaction;
@@ -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,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,MAA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G;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,aAAa,CAAS;IAE9B;;;;;;;;;OASG;gBACS,MAAM,EAAE,MAAM;IAU1B,IAAI,MAAM,WAET;IAED,OAAO,CAAC,WAAW;IAInB;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;IAOlC;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9D;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAOzC;;;;;;OAMG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3D;;;;;;;;OAQG;IACG,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAa/D,OAAO,CAAC,oBAAoB;YAOd,oBAAoB;YAsBpB,eAAe;IAY7B,OAAO,CAAC,gBAAgB;CAgBzB"}
package/lib/api/Api.js CHANGED
@@ -1,37 +1,34 @@
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;
23
21
  /**
24
22
  * Class used to handle requests to the CubicWeb API.
25
23
  *
26
24
  * You should never have to create this object yourself.
27
- * Instead, retrieve this object from the methods in the `Client` class.
25
+ * Instead, retrieve this object from the methods in the {@link Client} class.
28
26
  *
29
27
  * @param apiUrl The API url. It should not include the API version as it will be automatically added.
30
28
  * Example: if you can retrieve the schema with https://example.com/api/v1/schema,
31
29
  * use https://example.com/api as `apiUrl`.
32
30
  */
33
31
  constructor(apiUrl) {
34
- this._version = "v1";
35
32
  this._apiUrl = apiUrl;
36
33
  this._rqlApiUrl = this.getApiRoute("rql");
37
34
  this._schemaApiUrl = this.getApiRoute("schema");
@@ -51,50 +48,44 @@ class Api {
51
48
  *
52
49
  * @returns The CubicWeb instance's JSON schema.
53
50
  */
54
- schema() {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- return nonNullFetchApi(this._schemaApiUrl, {
57
- method: "GET",
58
- credentials: "include",
59
- });
51
+ async schema() {
52
+ return nonNullFetchApi(this._schemaApiUrl, {
53
+ method: "GET",
54
+ credentials: "include",
60
55
  });
61
56
  }
62
57
  /**
63
58
  * Tries to log in the user on the configured CubicWeb instance with the given credentials.
64
59
  *
65
60
  * @param login The user login
66
- * @param password THe user password
61
+ * @param password The user password
67
62
  * @returns A promise returning true if the login was successful, false otherwise
68
63
  */
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
- });
64
+ async login(login, password) {
65
+ try {
66
+ await fetchApi(this._loginApiUrl, {
67
+ method: "POST",
68
+ body: JSON.stringify({
69
+ login,
70
+ password,
71
+ }),
72
+ credentials: "include",
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 fetchApi(this._logoutApiUrl, {
87
+ method: "POST",
88
+ credentials: "include",
98
89
  });
99
90
  }
100
91
  /**
@@ -102,77 +93,79 @@ class Api {
102
93
  *
103
94
  * @returns A promise resolving to the current user
104
95
  */
105
- currentUser() {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- return yield nonNullFetchApi(this._currentUserApiUrl, {
108
- method: "GET",
109
- credentials: "include",
110
- });
96
+ async currentUser() {
97
+ return await nonNullFetchApi(this._currentUserApiUrl, {
98
+ method: "GET",
99
+ credentials: "include",
111
100
  });
112
101
  }
113
102
  /**
114
103
  * Get the binary for the given entity attribute
115
104
  *
116
- * @returns A promise resolving to the binary
105
+ * @param eid Entity eid to fetch the binary from
106
+ * @param attribute Attribute on the entity in which the binary is stored
107
+ * @returns A promise resolving to the binary as a Blob
117
108
  */
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
- });
109
+ async binary(eid, attribute) {
110
+ const params = new URLSearchParams({
111
+ eid: eid.toString(),
112
+ attribute,
113
+ });
114
+ return await nonNullFetchApi(this._binaryApiUrl + params, {
115
+ method: "GET",
116
+ credentials: "include",
128
117
  });
129
118
  }
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
- }
119
+ /**
120
+ * Executes the given transaction.
121
+ *
122
+ * If the {@link Transaction} object contains binaries, the request is automatically
123
+ * sent using `multipart/form-data` to allow uploading binaries.
124
+ *
125
+ * @param transaction Transaction to execute
126
+ * @returns A promise returning the transaction result on success
127
+ */
128
+ async rql(transaction) {
129
+ const binaries = getBinariesFromTransaction(transaction);
130
+ try {
131
+ if (binaries.length > 0) {
132
+ return await this.multipartTransaction(transaction, binaries);
139
133
  }
140
- catch (e) {
141
- this.handleUserErrors(e);
134
+ else {
135
+ return await this.jsonTransaction(transaction);
142
136
  }
143
- });
137
+ }
138
+ catch (e) {
139
+ this.handleUserErrors(e);
140
+ }
144
141
  }
145
142
  getTransactionParams(transaction) {
146
- return transaction.queries.map((transactionQuery) => ({
147
- query: transactionQuery.query,
148
- params: transactionQuery.params,
143
+ return transaction.queries.map((rqlQuery) => ({
144
+ query: rqlQuery.rql,
145
+ params: serializeQueryParams(transaction, rqlQuery.params),
149
146
  }));
150
147
  }
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);
148
+ async multipartTransaction(transaction, binaries) {
149
+ const jsonParams = this.getTransactionParams(transaction);
150
+ const formData = new FormData();
151
+ formData.append("queries", JSON.stringify(jsonParams));
152
+ binaries.forEach((binary) => {
153
+ formData.append(binary.uuid, binary.blob);
165
154
  });
155
+ const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
156
+ method: "POST",
157
+ credentials: "include",
158
+ body: formData,
159
+ });
160
+ return new TransactionResult(transaction, resultSets);
166
161
  }
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);
162
+ async jsonTransaction(transaction) {
163
+ const resultSets = await nonNullFetchApi(this._rqlApiUrl, {
164
+ method: "POST",
165
+ credentials: "include",
166
+ body: JSON.stringify(this.getTransactionParams(transaction)),
175
167
  });
168
+ return new TransactionResult(transaction, resultSets);
176
169
  }
177
170
  handleUserErrors(error) {
178
171
  if (typeof error === "object" &&
@@ -182,14 +175,13 @@ class Api {
182
175
  "message" in error &&
183
176
  typeof error.message === "string") {
184
177
  if (error.title === "ValidationError") {
185
- throw new Errors_1.ValidationError(error.message);
178
+ throw new ValidationError(error.message);
186
179
  }
187
180
  throw error;
188
181
  }
189
182
  throw error;
190
183
  }
191
184
  }
192
- exports.default = Api;
193
185
  /**
194
186
  * Behaves the same as `fetchAPI` but forbids null responses.
195
187
  * If this function detects a null response from the API,
@@ -199,19 +191,17 @@ exports.default = Api;
199
191
  * @param init Additional request parameters
200
192
  * @returns A promise with the non-null fetched result
201
193
  */
202
- function nonNullFetchApi(input, init) {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- const result = yield fetchApi(input, init);
205
- if (result == null) {
206
- const error = {
207
- status: 500,
208
- title: "Unexpected null response",
209
- message: "Response was null but a value was expected",
210
- };
211
- throw error;
212
- }
213
- return result;
214
- });
194
+ async function nonNullFetchApi(input, init) {
195
+ const result = await fetchApi(input, init);
196
+ if (result == null) {
197
+ const error = {
198
+ status: 500,
199
+ title: "Unexpected null response",
200
+ message: "Response was null but a value was expected",
201
+ };
202
+ throw error;
203
+ }
204
+ return result;
215
205
  }
216
206
  /**
217
207
  * Sends a request to the given API route with the `Content-Type` header set and waits for a response.
@@ -222,46 +212,50 @@ function nonNullFetchApi(input, init) {
222
212
  * @param init Additional request parameters
223
213
  * @returns A promise with the fetched result
224
214
  */
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 = {
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);
215
+ async function fetchApi(input, init) {
216
+ let headers = init?.headers;
217
+ if (init?.method && init.method !== "GET") {
218
+ headers = {
219
+ // CSRF custom header necessary for POST requests
220
+ "X-Client-Name": "XMLHttpRequest",
221
+ };
222
+ // Browsers will automatically set the multipart content type
223
+ // with the right boundary if the body is FormData
224
+ if (!(init.body instanceof FormData)) {
225
+ headers["Content-Type"] = "application/json;charset=UTF-8";
239
226
  }
240
- const response = yield fetch(input, Object.assign(Object.assign({}, init), { headers }));
241
- const status = response.status;
242
- if (status >= 200 && status < 300) {
243
- if (status === 204) {
244
- return null;
245
- }
246
- try {
247
- return yield response.json();
248
- }
249
- catch (e) {
250
- console.error(e);
251
- return null;
252
- }
227
+ headers = {
228
+ ...headers,
229
+ ...init?.headers,
230
+ };
231
+ }
232
+ const response = await fetch(input, {
233
+ ...init,
234
+ headers,
235
+ });
236
+ const status = response.status;
237
+ if (status >= 200 && status < 300) {
238
+ if (status === 204) {
239
+ return null;
253
240
  }
254
- else {
255
- let json;
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);
241
+ try {
242
+ return await response.json();
264
243
  }
265
- });
244
+ catch (e) {
245
+ console.error(e);
246
+ return null;
247
+ }
248
+ }
249
+ else {
250
+ let json;
251
+ try {
252
+ json = await response.json();
253
+ }
254
+ catch (e) {
255
+ console.error(e);
256
+ throw { status, title: "Error", message: "" };
257
+ }
258
+ throw { status, ...json };
259
+ }
266
260
  }
267
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;QA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