@ogcio/building-blocks-sdk 0.2.97 → 0.2.99

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 (41) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/dist/client/clients/journey/index.d.ts +7 -0
  4. package/dist/client/clients/journey/index.d.ts.map +1 -1
  5. package/dist/client/clients/journey/schema.d.ts +10 -0
  6. package/dist/client/clients/journey/schema.d.ts.map +1 -1
  7. package/dist/client/clients/messaging-public-api/citizen/index.d.ts +602 -0
  8. package/dist/client/clients/messaging-public-api/citizen/index.d.ts.map +1 -0
  9. package/dist/client/clients/messaging-public-api/citizen/index.js +34 -0
  10. package/dist/client/clients/messaging-public-api/citizen/index.js.map +1 -0
  11. package/dist/client/clients/messaging-public-api/index.d.ts +18 -0
  12. package/dist/client/clients/messaging-public-api/index.d.ts.map +1 -0
  13. package/dist/client/clients/messaging-public-api/index.js +15 -0
  14. package/dist/client/clients/messaging-public-api/index.js.map +1 -0
  15. package/dist/client/clients/messaging-public-api/organisation/index.d.ts +621 -0
  16. package/dist/client/clients/messaging-public-api/organisation/index.d.ts.map +1 -0
  17. package/dist/client/clients/messaging-public-api/organisation/index.js +49 -0
  18. package/dist/client/clients/messaging-public-api/organisation/index.js.map +1 -0
  19. package/dist/client/clients/messaging-public-api/schema.d.ts +2464 -0
  20. package/dist/client/clients/messaging-public-api/schema.d.ts.map +1 -0
  21. package/dist/client/clients/messaging-public-api/schema.js +2 -0
  22. package/dist/client/clients/messaging-public-api/schema.js.map +1 -0
  23. package/dist/clients-configurations/clients-configuration.json +17 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/types/index.d.ts +9 -3
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/index.js +2 -1
  30. package/dist/types/index.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/client/clients/journey/open-api-definition.json +26 -0
  33. package/src/client/clients/journey/schema.ts +10 -0
  34. package/src/client/clients/messaging-public-api/citizen/index.ts +57 -0
  35. package/src/client/clients/messaging-public-api/index.ts +35 -0
  36. package/src/client/clients/messaging-public-api/open-api-definition.json +4539 -0
  37. package/src/client/clients/messaging-public-api/organisation/index.ts +79 -0
  38. package/src/client/clients/messaging-public-api/schema.ts +2463 -0
  39. package/src/clients-configurations/clients-configuration.json +17 -1
  40. package/src/index.ts +7 -0
  41. package/src/types/index.ts +9 -0
@@ -0,0 +1,79 @@
1
+ import type createClient from "openapi-fetch";
2
+ import type { Logger } from "../../../../types/index.js";
3
+ import {
4
+ formatError,
5
+ formatResponse,
6
+ throwIfEmpty,
7
+ } from "../../../utils/client-utils.js";
8
+ import type { paths } from "../schema.js";
9
+
10
+ type SendMessageBody =
11
+ paths["/api/v1/organisations/messages/"]["post"]["requestBody"]["content"]["multipart/form-data"];
12
+
13
+ export class MessagingPublicApiOrganisation {
14
+ constructor(
15
+ private readonly client: ReturnType<typeof createClient<paths>>,
16
+ private readonly serviceName: string,
17
+ private readonly logger: Logger | undefined,
18
+ ) {}
19
+
20
+ async send(
21
+ message: Omit<SendMessageBody, "attachments">,
22
+ attachments?: File[],
23
+ ) {
24
+ return this.client
25
+ .POST("/api/v1/organisations/messages/", {
26
+ body: { ...message, attachments },
27
+ bodySerializer: (body: unknown) => {
28
+ const parsed = (body ?? {}) as Record<string, unknown>;
29
+ const formData = new FormData();
30
+ for (const [key, value] of Object.entries(parsed)) {
31
+ if (key === "attachments" || value === undefined) {
32
+ continue;
33
+ }
34
+ formData.set(
35
+ key,
36
+ typeof value === "object" ? JSON.stringify(value) : String(value),
37
+ );
38
+ }
39
+ for (const attachment of attachments ?? []) {
40
+ formData.append("attachments", attachment);
41
+ }
42
+ return formData;
43
+ },
44
+ })
45
+ .then(
46
+ (response) => formatResponse(response, this.serviceName, this.logger),
47
+ (reason) => formatError(reason, this.serviceName, this.logger),
48
+ );
49
+ }
50
+
51
+ async getMessageEvents(
52
+ messageId: paths["/api/v1/organisations/messages/{messageId}/events"]["get"]["parameters"]["path"]["messageId"],
53
+ ) {
54
+ throwIfEmpty(messageId);
55
+ return this.client
56
+ .GET("/api/v1/organisations/messages/{messageId}/events", {
57
+ params: { path: { messageId } },
58
+ })
59
+ .then(
60
+ (response) => formatResponse(response, this.serviceName, this.logger),
61
+ (reason) => formatError(reason, this.serviceName, this.logger),
62
+ );
63
+ }
64
+
65
+ async getLatestEvents(
66
+ filter: paths["/api/v1/organisations/messages/events"]["post"]["requestBody"]["content"]["application/json"],
67
+ query?: paths["/api/v1/organisations/messages/events"]["post"]["parameters"]["query"],
68
+ ) {
69
+ return this.client
70
+ .POST("/api/v1/organisations/messages/events", {
71
+ params: { query },
72
+ body: filter,
73
+ })
74
+ .then(
75
+ (response) => formatResponse(response, this.serviceName, this.logger),
76
+ (reason) => formatError(reason, this.serviceName, this.logger),
77
+ );
78
+ }
79
+ }