@ogcio/building-blocks-sdk 0.2.84 → 0.2.86

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 (52) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/dist/client/clients/messaging/index.d.ts +8 -0
  4. package/dist/client/clients/messaging/index.d.ts.map +1 -1
  5. package/dist/client/clients/messaging/index.js +7 -1
  6. package/dist/client/clients/messaging/index.js.map +1 -1
  7. package/dist/client/clients/messaging/schema.d.ts +154 -0
  8. package/dist/client/clients/messaging/schema.d.ts.map +1 -1
  9. package/dist/client/clients/messaging/support.d.ts +125 -0
  10. package/dist/client/clients/messaging/support.d.ts.map +1 -0
  11. package/dist/client/clients/messaging/support.js +20 -0
  12. package/dist/client/clients/messaging/support.js.map +1 -0
  13. package/dist/client/clients/profile/citizen.d.ts.map +1 -1
  14. package/dist/client/clients/profile/index.d.ts +7 -79
  15. package/dist/client/clients/profile/index.d.ts.map +1 -1
  16. package/dist/client/clients/profile/index.js +13 -20
  17. package/dist/client/clients/profile/index.js.map +1 -1
  18. package/dist/client/clients/profile/organisation.d.ts.map +1 -1
  19. package/dist/client/clients/profile/schema.d.ts +1 -89
  20. package/dist/client/clients/profile/schema.d.ts.map +1 -1
  21. package/dist/client/clients/upload/index.d.ts +23 -0
  22. package/dist/client/clients/upload/index.d.ts.map +1 -1
  23. package/dist/client/clients/upload/index.js +26 -36
  24. package/dist/client/clients/upload/index.js.map +1 -1
  25. package/dist/client/clients/upload/schema.d.ts +321 -0
  26. package/dist/client/clients/upload/schema.d.ts.map +1 -1
  27. package/dist/client/clients/upload/shared.d.ts +47 -0
  28. package/dist/client/clients/upload/shared.d.ts.map +1 -0
  29. package/dist/client/clients/upload/shared.js +72 -0
  30. package/dist/client/clients/upload/shared.js.map +1 -0
  31. package/dist/client/clients/upload/support.d.ts +239 -0
  32. package/dist/client/clients/upload/support.d.ts.map +1 -0
  33. package/dist/client/clients/upload/support.js +73 -0
  34. package/dist/client/clients/upload/support.js.map +1 -0
  35. package/dist/client/utils/client-utils.d.ts +9 -0
  36. package/dist/client/utils/client-utils.d.ts.map +1 -1
  37. package/dist/client/utils/client-utils.js +43 -0
  38. package/dist/client/utils/client-utils.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/client/clients/messaging/index.ts +20 -1
  41. package/src/client/clients/messaging/open-api-definition.json +355 -0
  42. package/src/client/clients/messaging/schema.ts +154 -0
  43. package/src/client/clients/messaging/support.ts +27 -0
  44. package/src/client/clients/profile/index.ts +33 -35
  45. package/src/client/clients/profile/open-api-definition.json +3 -163
  46. package/src/client/clients/profile/schema.ts +1 -89
  47. package/src/client/clients/upload/index.ts +56 -37
  48. package/src/client/clients/upload/open-api-definition.json +621 -41
  49. package/src/client/clients/upload/schema.ts +321 -0
  50. package/src/client/clients/upload/shared.ts +122 -0
  51. package/src/client/clients/upload/support.ts +127 -0
  52. package/src/client/utils/client-utils.ts +59 -0
@@ -5379,6 +5379,9 @@
5379
5379
  "expiresAt": {
5380
5380
  "format": "date-time",
5381
5381
  "type": "string"
5382
+ },
5383
+ "uploadId": {
5384
+ "type": "string"
5382
5385
  }
5383
5386
  }
5384
5387
  },
@@ -5716,169 +5719,6 @@
5716
5719
  }
5717
5720
  }
5718
5721
  },
5719
- "/api/v1/lifecycle-tasks/{id}/action": {
5720
- "get": {
5721
- "operationId": "taskAction",
5722
- "tags": [
5723
- "Lifecycle Tasks"
5724
- ],
5725
- "parameters": [
5726
- {
5727
- "schema": {
5728
- "type": "string"
5729
- },
5730
- "in": "query",
5731
- "name": "profileId",
5732
- "required": true
5733
- },
5734
- {
5735
- "schema": {
5736
- "type": "string",
5737
- "enum": [
5738
- "download"
5739
- ]
5740
- },
5741
- "in": "query",
5742
- "name": "q",
5743
- "required": true
5744
- },
5745
- {
5746
- "schema": {
5747
- "format": "uuid",
5748
- "type": "string"
5749
- },
5750
- "in": "path",
5751
- "name": "id",
5752
- "required": true
5753
- }
5754
- ],
5755
- "responses": {
5756
- "302": {
5757
- "description": "Default Response"
5758
- },
5759
- "4XX": {
5760
- "description": "Default Response",
5761
- "content": {
5762
- "application/json": {
5763
- "schema": {
5764
- "type": "object",
5765
- "required": [
5766
- "code",
5767
- "detail",
5768
- "requestId",
5769
- "name",
5770
- "statusCode"
5771
- ],
5772
- "properties": {
5773
- "code": {
5774
- "description": "Code used to categorize the error",
5775
- "type": "string"
5776
- },
5777
- "detail": {
5778
- "description": "Description of the error",
5779
- "type": "string"
5780
- },
5781
- "requestId": {
5782
- "description": "Unique request id. This one will be used to troubleshoot the problems",
5783
- "type": "string"
5784
- },
5785
- "name": {
5786
- "description": "Name of the error type",
5787
- "type": "string"
5788
- },
5789
- "validation": {
5790
- "description": "List of the validation errors",
5791
- "type": "array",
5792
- "items": {
5793
- "type": "object",
5794
- "required": [
5795
- "fieldName",
5796
- "message"
5797
- ],
5798
- "properties": {
5799
- "fieldName": {
5800
- "type": "string"
5801
- },
5802
- "message": {
5803
- "type": "string"
5804
- }
5805
- }
5806
- }
5807
- },
5808
- "validationContext": {
5809
- "type": "string"
5810
- },
5811
- "statusCode": {
5812
- "type": "number"
5813
- }
5814
- }
5815
- }
5816
- }
5817
- }
5818
- },
5819
- "5XX": {
5820
- "description": "Default Response",
5821
- "content": {
5822
- "application/json": {
5823
- "schema": {
5824
- "type": "object",
5825
- "required": [
5826
- "code",
5827
- "detail",
5828
- "requestId",
5829
- "name",
5830
- "statusCode"
5831
- ],
5832
- "properties": {
5833
- "code": {
5834
- "description": "Code used to categorize the error",
5835
- "type": "string"
5836
- },
5837
- "detail": {
5838
- "description": "Description of the error",
5839
- "type": "string"
5840
- },
5841
- "requestId": {
5842
- "description": "Unique request id. This one will be used to troubleshoot the problems",
5843
- "type": "string"
5844
- },
5845
- "name": {
5846
- "description": "Name of the error type",
5847
- "type": "string"
5848
- },
5849
- "validation": {
5850
- "description": "List of the validation errors",
5851
- "type": "array",
5852
- "items": {
5853
- "type": "object",
5854
- "required": [
5855
- "fieldName",
5856
- "message"
5857
- ],
5858
- "properties": {
5859
- "fieldName": {
5860
- "type": "string"
5861
- },
5862
- "message": {
5863
- "type": "string"
5864
- }
5865
- }
5866
- }
5867
- },
5868
- "validationContext": {
5869
- "type": "string"
5870
- },
5871
- "statusCode": {
5872
- "type": "number"
5873
- }
5874
- }
5875
- }
5876
- }
5877
- }
5878
- }
5879
- }
5880
- }
5881
- },
5882
5722
  "/api/v1/organisations/profiles/{profileId}": {
5883
5723
  "patch": {
5884
5724
  "operationId": "adminProfilesPatch",
@@ -307,22 +307,6 @@ export interface paths {
307
307
  patch?: never;
308
308
  trace?: never;
309
309
  };
310
- "/api/v1/lifecycle-tasks/{id}/action": {
311
- parameters: {
312
- query?: never;
313
- header?: never;
314
- path?: never;
315
- cookie?: never;
316
- };
317
- get: operations["taskAction"];
318
- put?: never;
319
- post?: never;
320
- delete?: never;
321
- options?: never;
322
- head?: never;
323
- patch?: never;
324
- trace?: never;
325
- };
326
310
  "/api/v1/organisations/profiles/{profileId}": {
327
311
  parameters: {
328
312
  query?: never;
@@ -2300,6 +2284,7 @@ export interface operations {
2300
2284
  metadata: {
2301
2285
  /** Format: date-time */
2302
2286
  expiresAt?: string;
2287
+ uploadId?: string;
2303
2288
  } | null;
2304
2289
  }[];
2305
2290
  };
@@ -2441,79 +2426,6 @@ export interface operations {
2441
2426
  };
2442
2427
  };
2443
2428
  };
2444
- taskAction: {
2445
- parameters: {
2446
- query: {
2447
- profileId: string;
2448
- q: "download";
2449
- };
2450
- header?: never;
2451
- path: {
2452
- id: string;
2453
- };
2454
- cookie?: never;
2455
- };
2456
- requestBody?: never;
2457
- responses: {
2458
- /** @description Default Response */
2459
- 302: {
2460
- headers: {
2461
- [name: string]: unknown;
2462
- };
2463
- content?: never;
2464
- };
2465
- /** @description Default Response */
2466
- "4XX": {
2467
- headers: {
2468
- [name: string]: unknown;
2469
- };
2470
- content: {
2471
- "application/json": {
2472
- /** @description Code used to categorize the error */
2473
- code: string;
2474
- /** @description Description of the error */
2475
- detail: string;
2476
- /** @description Unique request id. This one will be used to troubleshoot the problems */
2477
- requestId: string;
2478
- /** @description Name of the error type */
2479
- name: string;
2480
- /** @description List of the validation errors */
2481
- validation?: {
2482
- fieldName: string;
2483
- message: string;
2484
- }[];
2485
- validationContext?: string;
2486
- statusCode: number;
2487
- };
2488
- };
2489
- };
2490
- /** @description Default Response */
2491
- "5XX": {
2492
- headers: {
2493
- [name: string]: unknown;
2494
- };
2495
- content: {
2496
- "application/json": {
2497
- /** @description Code used to categorize the error */
2498
- code: string;
2499
- /** @description Description of the error */
2500
- detail: string;
2501
- /** @description Unique request id. This one will be used to troubleshoot the problems */
2502
- requestId: string;
2503
- /** @description Name of the error type */
2504
- name: string;
2505
- /** @description List of the validation errors */
2506
- validation?: {
2507
- fieldName: string;
2508
- message: string;
2509
- }[];
2510
- validationContext?: string;
2511
- statusCode: number;
2512
- };
2513
- };
2514
- };
2515
- };
2516
- };
2517
2429
  adminProfilesPatch: {
2518
2430
  parameters: {
2519
2431
  query?: never;
@@ -1,5 +1,9 @@
1
1
  import type createClient from "openapi-fetch";
2
- import { UPLOAD } from "../../../types/index.js";
2
+ import {
3
+ type Logger,
4
+ type TokenFunction,
5
+ UPLOAD,
6
+ } from "../../../types/index.js";
3
7
  import { BaseClient } from "../../base-client.js";
4
8
  import {
5
9
  formatError,
@@ -7,11 +11,28 @@ import {
7
11
  throwIfEmpty,
8
12
  } from "../../utils/client-utils.js";
9
13
  import type { paths } from "./schema.js";
14
+ import { uploadFile, uploadStreamFile } from "./shared.js";
15
+ import { UploadSupport } from "./support.js";
10
16
 
11
17
  export class Upload extends BaseClient<paths> {
12
18
  protected declare client: ReturnType<typeof createClient<paths>>;
13
19
  protected serviceName = UPLOAD;
14
20
 
21
+ public readonly support: UploadSupport;
22
+
23
+ constructor(params: {
24
+ baseUrl: string;
25
+ getTokenFn?: TokenFunction;
26
+ logger?: Logger;
27
+ }) {
28
+ super(params);
29
+ this.support = new UploadSupport(
30
+ this.client,
31
+ this.serviceName,
32
+ this.logger,
33
+ );
34
+ }
35
+
15
36
  getFilesMetadata({
16
37
  organizationId,
17
38
  userId,
@@ -155,42 +176,40 @@ export class Upload extends BaseClient<paths> {
155
176
  };
156
177
  data?: { uploadId?: string };
157
178
  }> {
158
- const timeoutMs = options?.timeoutMs ?? 120000; // default 120s
159
- try {
160
- const { error, data } = await this.client.POST("/api/v1/files/", {
161
- body: {
162
- file,
163
- expirationDate,
164
- },
165
- signal: AbortSignal.timeout(timeoutMs),
166
- bodySerializer: (body: unknown) => {
167
- const parsed = body as { file: File; expirationDate?: string };
168
- const formData = new FormData();
169
- if (parsed.expirationDate) {
170
- formData.set("expirationDate", parsed.expirationDate);
171
- }
172
- formData.set("file", parsed.file);
173
- return formData;
174
- },
175
- });
179
+ return uploadFile({
180
+ file,
181
+ expirationDate,
182
+ options,
183
+ client: this.client,
184
+ path: "/api/v1/files/",
185
+ });
186
+ }
176
187
 
177
- return { error, data: { uploadId: data?.data.id } };
178
- } catch (e: unknown) {
179
- const err = e as Error & { name?: string };
180
- if (
181
- err?.name === "AbortError" ||
182
- err?.constructor?.name === "DOMException"
183
- ) {
184
- return {
185
- error: {
186
- name: "TimeoutError",
187
- detail: "Upload aborted after reaching timeout",
188
- requestId: "",
189
- code: "TIMEOUT_ERROR",
190
- },
191
- };
192
- }
193
- throw err;
194
- }
188
+ async uploadStreamFile(
189
+ file: ReadableStream<Uint8Array> | Blob,
190
+ filename: string,
191
+ mimeType: string,
192
+ expirationDate?: string,
193
+ options?: { timeoutMs?: number },
194
+ ): Promise<{
195
+ error?: {
196
+ code: string;
197
+ detail: string;
198
+ requestId: string;
199
+ name: string;
200
+ validation?: unknown;
201
+ validationContext?: string;
202
+ };
203
+ data?: { uploadId?: string };
204
+ }> {
205
+ return uploadStreamFile({
206
+ file,
207
+ filename,
208
+ mimeType,
209
+ expirationDate,
210
+ options,
211
+ client: this.client,
212
+ path: "/api/v1/files/",
213
+ });
195
214
  }
196
215
  }