@se-uulm/snowballr-api-client 0.2.1-alpha.5864cf1 → 0.2.1-alpha.5b91c23

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 (48) hide show
  1. package/README.md +111 -28
  2. package/dist/apis/AuthControllerApi.d.ts +64 -1
  3. package/dist/apis/AuthControllerApi.js +64 -18
  4. package/dist/apis/ProjectsControllerApi.d.ts +54 -1
  5. package/dist/apis/ProjectsControllerApi.js +56 -19
  6. package/dist/apis/UsersControllerApi.d.ts +15 -1
  7. package/dist/apis/UsersControllerApi.js +14 -5
  8. package/dist/esm/apis/AuthControllerApi.d.ts +64 -1
  9. package/dist/esm/apis/AuthControllerApi.js +62 -16
  10. package/dist/esm/apis/ProjectsControllerApi.d.ts +54 -1
  11. package/dist/esm/apis/ProjectsControllerApi.js +52 -15
  12. package/dist/esm/apis/UsersControllerApi.d.ts +15 -1
  13. package/dist/esm/apis/UsersControllerApi.js +13 -4
  14. package/dist/esm/models/ChangePasswordRequest.d.ts +0 -4
  15. package/dist/esm/models/CreateProjectRequest.d.ts +0 -2
  16. package/dist/esm/models/DecisionMatrixPattern.d.ts +0 -4
  17. package/dist/esm/models/DecisionMatrixPattern.js +1 -1
  18. package/dist/esm/models/DecisionMatrixPatternEntry.d.ts +0 -4
  19. package/dist/esm/models/DecisionMatrixPatternEntry.js +1 -1
  20. package/dist/esm/models/LoginRequest.d.ts +0 -4
  21. package/dist/esm/models/ProjectResponse.d.ts +2 -53
  22. package/dist/esm/models/ProjectResponse.js +7 -22
  23. package/dist/esm/models/ProjectSettings.d.ts +60 -0
  24. package/dist/esm/models/ProjectSettings.js +58 -0
  25. package/dist/esm/models/RegisterRequest.d.ts +0 -8
  26. package/dist/esm/models/ReviewDecisionMatrix.d.ts +0 -4
  27. package/dist/esm/models/index.d.ts +1 -0
  28. package/dist/esm/models/index.js +1 -0
  29. package/dist/esm/runtime.d.ts +34 -1
  30. package/dist/esm/runtime.js +130 -4
  31. package/dist/models/ChangePasswordRequest.d.ts +0 -4
  32. package/dist/models/CreateProjectRequest.d.ts +0 -2
  33. package/dist/models/DecisionMatrixPattern.d.ts +0 -4
  34. package/dist/models/DecisionMatrixPattern.js +1 -1
  35. package/dist/models/DecisionMatrixPatternEntry.d.ts +0 -4
  36. package/dist/models/DecisionMatrixPatternEntry.js +1 -1
  37. package/dist/models/LoginRequest.d.ts +0 -4
  38. package/dist/models/ProjectResponse.d.ts +2 -53
  39. package/dist/models/ProjectResponse.js +8 -23
  40. package/dist/models/ProjectSettings.d.ts +60 -0
  41. package/dist/models/ProjectSettings.js +66 -0
  42. package/dist/models/RegisterRequest.d.ts +0 -8
  43. package/dist/models/ReviewDecisionMatrix.d.ts +0 -4
  44. package/dist/models/index.d.ts +1 -0
  45. package/dist/models/index.js +1 -0
  46. package/dist/runtime.d.ts +34 -1
  47. package/dist/runtime.js +136 -4
  48. package/package.json +2 -2
@@ -4,5 +4,6 @@ export * from './DecisionMatrixPattern';
4
4
  export * from './DecisionMatrixPatternEntry';
5
5
  export * from './LoginRequest';
6
6
  export * from './ProjectResponse';
7
+ export * from './ProjectSettings';
7
8
  export * from './RegisterRequest';
8
9
  export * from './ReviewDecisionMatrix';
@@ -22,5 +22,6 @@ __exportStar(require("./DecisionMatrixPattern"), exports);
22
22
  __exportStar(require("./DecisionMatrixPatternEntry"), exports);
23
23
  __exportStar(require("./LoginRequest"), exports);
24
24
  __exportStar(require("./ProjectResponse"), exports);
25
+ __exportStar(require("./ProjectSettings"), exports);
25
26
  __exportStar(require("./RegisterRequest"), exports);
26
27
  __exportStar(require("./ReviewDecisionMatrix"), exports);
package/dist/runtime.d.ts CHANGED
@@ -124,9 +124,21 @@ export interface RequestOpts {
124
124
  }
125
125
  export declare function querystring(params: HTTPQuery, prefix?: string): string;
126
126
  export declare function exists(json: any, key: string): boolean;
127
+ /**
128
+ * Every generated date call site routes through these.
129
+ *
130
+ * `format: date` is a calendar date, with no time and no offset, so it is converted
131
+ * against the local calendar on both ends: they have to agree or the date shifts by
132
+ * a day. `format: date-time` is an instant and uses UTC.
133
+ */
134
+ export declare function serializeDateTime(value: Date): string;
135
+ export declare function serializeDate(value: Date): string;
136
+ export declare function parseDate(value: Date | string): Date;
137
+ export declare function parseDateTime(value: any): Date;
127
138
  export declare function mapValues(data: any, fn: (item: any) => any): {
128
139
  [key: string]: any;
129
140
  };
141
+ export declare function anyToJSON(value: any): any;
130
142
  export declare function canConsumeForm(consumes: Consume[]): boolean;
131
143
  export interface Consume {
132
144
  contentType: string;
@@ -172,11 +184,32 @@ export declare class VoidApiResponse {
172
184
  constructor(raw: Response);
173
185
  value(): Promise<void>;
174
186
  }
187
+ /**
188
+ * A Blob carrying the file name the server advertised, empty when it did not send one. It is a File
189
+ * wherever one can be built, and the bare Blob given a name otherwise. Same name and shape as the
190
+ * `typescript` generator's browser HttpFile.
191
+ */
192
+ export type HttpFile = Blob & {
193
+ readonly name: string;
194
+ };
175
195
  export declare class BlobApiResponse {
176
196
  raw: Response;
177
197
  constructor(raw: Response);
178
- value(): Promise<Blob>;
198
+ /**
199
+ * The body named after the Content-Disposition header, so that a download keeps the name the
200
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
201
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
202
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
203
+ * would stringify instead of wrapping.
204
+ */
205
+ value(): Promise<HttpFile>;
179
206
  }
207
+ /**
208
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
209
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
210
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
211
+ */
212
+ export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
180
213
  export declare class TextApiResponse {
181
214
  raw: Response;
182
215
  constructor(raw: Response);
package/dist/runtime.js CHANGED
@@ -25,8 +25,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.DefaultConfig = exports.Configuration = exports.BASE_PATH = void 0;
26
26
  exports.querystring = querystring;
27
27
  exports.exists = exists;
28
+ exports.serializeDateTime = serializeDateTime;
29
+ exports.serializeDate = serializeDate;
30
+ exports.parseDate = parseDate;
31
+ exports.parseDateTime = parseDateTime;
28
32
  exports.mapValues = mapValues;
33
+ exports.anyToJSON = anyToJSON;
29
34
  exports.canConsumeForm = canConsumeForm;
35
+ exports.parseContentDispositionFilename = parseContentDispositionFilename;
30
36
  exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
31
37
  class Configuration {
32
38
  constructor(configuration = {}) {
@@ -219,7 +225,7 @@ class BaseAPI {
219
225
  }
220
226
  }
221
227
  exports.BaseAPI = BaseAPI;
222
- BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
228
+ BaseAPI.jsonRegex = /^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$/i;
223
229
  ;
224
230
  function isBlob(value) {
225
231
  return typeof Blob !== 'undefined' && value instanceof Blob;
@@ -232,6 +238,11 @@ class ResponseError extends Error {
232
238
  super(msg);
233
239
  this.response = response;
234
240
  this.name = "ResponseError";
241
+ // restore prototype chain
242
+ const actualProto = new.target.prototype;
243
+ if (Object.setPrototypeOf) {
244
+ Object.setPrototypeOf(this, actualProto);
245
+ }
235
246
  }
236
247
  }
237
248
  exports.ResponseError = ResponseError;
@@ -240,6 +251,11 @@ class FetchError extends Error {
240
251
  super(msg);
241
252
  this.cause = cause;
242
253
  this.name = "FetchError";
254
+ // restore prototype chain
255
+ const actualProto = new.target.prototype;
256
+ if (Object.setPrototypeOf) {
257
+ Object.setPrototypeOf(this, actualProto);
258
+ }
243
259
  }
244
260
  }
245
261
  exports.FetchError = FetchError;
@@ -248,6 +264,11 @@ class RequiredError extends Error {
248
264
  super(msg);
249
265
  this.field = field;
250
266
  this.name = "RequiredError";
267
+ // restore prototype chain
268
+ const actualProto = new.target.prototype;
269
+ if (Object.setPrototypeOf) {
270
+ Object.setPrototypeOf(this, actualProto);
271
+ }
251
272
  }
252
273
  }
253
274
  exports.RequiredError = RequiredError;
@@ -275,7 +296,7 @@ function querystringSingleKey(key, value, keyPrefix = '') {
275
296
  return querystringSingleKey(key, valueAsArray, keyPrefix);
276
297
  }
277
298
  if (value instanceof Date) {
278
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
299
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(serializeDateTime(value))}`;
279
300
  }
280
301
  if (value instanceof Object) {
281
302
  return querystring(value, fullKey);
@@ -286,6 +307,52 @@ function exists(json, key) {
286
307
  const value = json[key];
287
308
  return value !== null && value !== undefined;
288
309
  }
310
+ /**
311
+ * Every generated date call site routes through these.
312
+ *
313
+ * `format: date` is a calendar date, with no time and no offset, so it is converted
314
+ * against the local calendar on both ends: they have to agree or the date shifts by
315
+ * a day. `format: date-time` is an instant and uses UTC.
316
+ */
317
+ function serializeDateTime(value) {
318
+ return value.toISOString();
319
+ }
320
+ function serializeDate(value) {
321
+ if (isNaN(value.getTime())) {
322
+ throw new RangeError('Invalid time value');
323
+ }
324
+ const year = ('000' + value.getFullYear()).slice(-4);
325
+ const month = ('0' + (value.getMonth() + 1)).slice(-2);
326
+ const day = ('0' + value.getDate()).slice(-2);
327
+ return `${year}-${month}-${day}`;
328
+ }
329
+ function parseDate(value) {
330
+ if (value instanceof Date) {
331
+ return value;
332
+ }
333
+ // `new Date("2026-08-05")` would parse as UTC midnight: a different day west of UTC.
334
+ // Local midnight is the stated day everywhere. setFullYear avoids the 1900 offset the
335
+ // multi-argument constructor applies to years 0-99.
336
+ const fullDate = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(value));
337
+ if (fullDate) {
338
+ const year = Number(fullDate[1]);
339
+ const month = Number(fullDate[2]) - 1;
340
+ const day = Number(fullDate[3]);
341
+ const date = new Date(0);
342
+ date.setFullYear(year, month, day);
343
+ date.setHours(0, 0, 0, 0);
344
+ // Out-of-range components (or a day the local zone skipped) silently roll over,
345
+ // which would hand back a date the server never sent.
346
+ if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
347
+ return new Date(NaN);
348
+ }
349
+ return date;
350
+ }
351
+ return new Date(value);
352
+ }
353
+ function parseDateTime(value) {
354
+ return new Date(value);
355
+ }
289
356
  function mapValues(data, fn) {
290
357
  const result = {};
291
358
  for (const key of Object.keys(data)) {
@@ -293,9 +360,14 @@ function mapValues(data, fn) {
293
360
  }
294
361
  return result;
295
362
  }
363
+ // Pass-through serializer for `any`-typed properties in form data. See #1877.
364
+ function anyToJSON(value) {
365
+ return value;
366
+ }
296
367
  function canConsumeForm(consumes) {
368
+ var _a;
297
369
  for (const consume of consumes) {
298
- if ('multipart/form-data' === consume.contentType) {
370
+ if (((_a = consume.contentType) === null || _a === void 0 ? void 0 : _a.startsWith('multipart/form-data')) == true) {
299
371
  return true;
300
372
  }
301
373
  }
@@ -328,14 +400,74 @@ class BlobApiResponse {
328
400
  constructor(raw) {
329
401
  this.raw = raw;
330
402
  }
403
+ /**
404
+ * The body named after the Content-Disposition header, so that a download keeps the name the
405
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
406
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
407
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
408
+ * would stringify instead of wrapping.
409
+ */
331
410
  value() {
332
411
  return __awaiter(this, void 0, void 0, function* () {
333
- return yield this.raw.blob();
412
+ var _a;
413
+ const blob = yield this.raw.blob();
414
+ const name = (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '';
415
+ if (typeof File !== 'undefined' && blob instanceof Blob) {
416
+ try {
417
+ return new File([blob], name, { type: blob.type });
418
+ }
419
+ catch (_b) {
420
+ // File cannot be constructed: name the Blob itself
421
+ }
422
+ }
423
+ return Object.assign(blob, { name });
334
424
  });
335
425
  }
336
426
  ;
337
427
  }
338
428
  exports.BlobApiResponse = BlobApiResponse;
429
+ /**
430
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
431
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
432
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
433
+ */
434
+ function parseContentDispositionFilename(headers) {
435
+ var _a, _b;
436
+ const params = parseHeaderParameters((_a = headers.get('Content-Disposition')) !== null && _a !== void 0 ? _a : '');
437
+ return (_b = basename(decodeExtValue(params.get('filename*')))) !== null && _b !== void 0 ? _b : basename(params.get('filename'));
438
+ }
439
+ /** The decoded RFC 5987 ext-value, or undefined when it is not UTF-8 or its percent-encoding is malformed. */
440
+ function decodeExtValue(value) {
441
+ const match = value === undefined ? null : /^utf-8'[^']*'(.*)$/i.exec(value);
442
+ try {
443
+ return match ? decodeURIComponent(match[1]) : undefined;
444
+ }
445
+ catch (_a) {
446
+ return undefined;
447
+ }
448
+ }
449
+ /**
450
+ * The `name=value` parameters of a header value, consumed one at a time so that a quoted-string is
451
+ * taken whole, `;` included. Names are lower-cased, quoted-string values are unquoted with their
452
+ * backslash escapes resolved, and the first occurrence of a name wins.
453
+ */
454
+ function parseHeaderParameters(value) {
455
+ const params = new Map();
456
+ const parameter = /(?:^|;)\s*([^=;]+?)\s*=\s*(?:"((?:[^"\\]|\\.)*)"?|([^;]*))/g;
457
+ let match;
458
+ while ((match = parameter.exec(value)) !== null) {
459
+ const name = match[1].toLowerCase();
460
+ if (!params.has(name)) {
461
+ params.set(name, match[2] !== undefined ? match[2].replace(/\\(.)/g, '$1') : match[3].trim());
462
+ }
463
+ }
464
+ return params;
465
+ }
466
+ /** The last `/` or `\` separated segment of a file name, or undefined when it is not a file name. */
467
+ function basename(name) {
468
+ const base = name === null || name === void 0 ? void 0 : name.split(/[\\/]/).pop();
469
+ return !base || base === '.' || base === '..' ? undefined : base;
470
+ }
339
471
  class TextApiResponse {
340
472
  constructor(raw) {
341
473
  this.raw = raw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-uulm/snowballr-api-client",
3
- "version": "0.2.1-alpha.5864cf1",
3
+ "version": "0.2.1-alpha.5b91c23",
4
4
  "description": "API client for the SnowballR Web Application",
5
5
  "author": "SnowballR",
6
6
  "repository": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "license": "GPL-3.0-or-later",
11
11
  "main": "./dist/index.js",
12
- "typings": "./dist/index.d.ts",
12
+ "types": "./dist/index.d.ts",
13
13
  "module": "./dist/esm/index.js",
14
14
  "sideEffects": false,
15
15
  "scripts": {