@ogcio/building-blocks-sdk 0.0.1

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 (106) hide show
  1. package/.husky/commit-msg +1 -0
  2. package/.husky/pre-push +1 -0
  3. package/.nvmrc +1 -0
  4. package/.vscode/settings.json +20 -0
  5. package/biome.jsonc +45 -0
  6. package/commitlint.config.js +6 -0
  7. package/dist/client/auth/index.d.ts +4 -0
  8. package/dist/client/auth/index.d.ts.map +1 -0
  9. package/dist/client/auth/index.js +83 -0
  10. package/dist/client/auth/index.js.map +1 -0
  11. package/dist/client/base-client.d.ts +18 -0
  12. package/dist/client/base-client.d.ts.map +1 -0
  13. package/dist/client/base-client.js +71 -0
  14. package/dist/client/base-client.js.map +1 -0
  15. package/dist/client/clients/messaging/index.d.ts +2407 -0
  16. package/dist/client/clients/messaging/index.d.ts.map +1 -0
  17. package/dist/client/clients/messaging/index.js +430 -0
  18. package/dist/client/clients/messaging/index.js.map +1 -0
  19. package/dist/client/clients/messaging/schema.d.ts +3823 -0
  20. package/dist/client/clients/messaging/schema.d.ts.map +1 -0
  21. package/dist/client/clients/messaging/schema.js +2 -0
  22. package/dist/client/clients/messaging/schema.js.map +1 -0
  23. package/dist/client/clients/payments/index.d.ts +2294 -0
  24. package/dist/client/clients/payments/index.d.ts.map +1 -0
  25. package/dist/client/clients/payments/index.js +217 -0
  26. package/dist/client/clients/payments/index.js.map +1 -0
  27. package/dist/client/clients/payments/schema.d.ts +2534 -0
  28. package/dist/client/clients/payments/schema.d.ts.map +1 -0
  29. package/dist/client/clients/payments/schema.js +2 -0
  30. package/dist/client/clients/payments/schema.js.map +1 -0
  31. package/dist/client/clients/profile/index.d.ts +1364 -0
  32. package/dist/client/clients/profile/index.d.ts.map +1 -0
  33. package/dist/client/clients/profile/index.js +102 -0
  34. package/dist/client/clients/profile/index.js.map +1 -0
  35. package/dist/client/clients/profile/schema.d.ts +1429 -0
  36. package/dist/client/clients/profile/schema.d.ts.map +1 -0
  37. package/dist/client/clients/profile/schema.js +2 -0
  38. package/dist/client/clients/profile/schema.js.map +1 -0
  39. package/dist/client/clients/scheduler/index.d.ts +14 -0
  40. package/dist/client/clients/scheduler/index.d.ts.map +1 -0
  41. package/dist/client/clients/scheduler/index.js +14 -0
  42. package/dist/client/clients/scheduler/index.js.map +1 -0
  43. package/dist/client/clients/scheduler/schema.d.ts +114 -0
  44. package/dist/client/clients/scheduler/schema.d.ts.map +1 -0
  45. package/dist/client/clients/scheduler/schema.js +2 -0
  46. package/dist/client/clients/scheduler/schema.js.map +1 -0
  47. package/dist/client/clients/upload/index.d.ts +390 -0
  48. package/dist/client/clients/upload/index.d.ts.map +1 -0
  49. package/dist/client/clients/upload/index.js +93 -0
  50. package/dist/client/clients/upload/index.js.map +1 -0
  51. package/dist/client/clients/upload/schema.d.ts +564 -0
  52. package/dist/client/clients/upload/schema.d.ts.map +1 -0
  53. package/dist/client/clients/upload/schema.js +2 -0
  54. package/dist/client/clients/upload/schema.js.map +1 -0
  55. package/dist/client/utils/client-utils.d.ts +15 -0
  56. package/dist/client/utils/client-utils.d.ts.map +1 -0
  57. package/dist/client/utils/client-utils.js +14 -0
  58. package/dist/client/utils/client-utils.js.map +1 -0
  59. package/dist/clients-configurations/clients-configuration.json +92 -0
  60. package/dist/clients-configurations/read-configuration-file.d.ts +22 -0
  61. package/dist/clients-configurations/read-configuration-file.d.ts.map +1 -0
  62. package/dist/clients-configurations/read-configuration-file.js +47 -0
  63. package/dist/clients-configurations/read-configuration-file.js.map +1 -0
  64. package/dist/index.d.ts +6 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +33 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/types/index.d.ts +63 -0
  69. package/dist/types/index.d.ts.map +1 -0
  70. package/dist/types/index.js +6 -0
  71. package/dist/types/index.js.map +1 -0
  72. package/dist/utils/get-absolute-path.d.ts +3 -0
  73. package/dist/utils/get-absolute-path.d.ts.map +1 -0
  74. package/dist/utils/get-absolute-path.js +8 -0
  75. package/dist/utils/get-absolute-path.js.map +1 -0
  76. package/package.json +44 -0
  77. package/src/cli/cli-utils.ts +25 -0
  78. package/src/cli/index.ts +13 -0
  79. package/src/cli/outdated-clients-command.ts +148 -0
  80. package/src/cli/update-clients-command.ts +298 -0
  81. package/src/client/auth/index.ts +131 -0
  82. package/src/client/base-client.ts +97 -0
  83. package/src/client/clients/messaging/index.ts +683 -0
  84. package/src/client/clients/messaging/open-api-definition.json +8394 -0
  85. package/src/client/clients/messaging/schema.ts +3822 -0
  86. package/src/client/clients/payments/index.ts +349 -0
  87. package/src/client/clients/payments/open-api-definition.json +6094 -0
  88. package/src/client/clients/payments/schema.ts +2533 -0
  89. package/src/client/clients/profile/index.ts +182 -0
  90. package/src/client/clients/profile/open-api-definition.json +2876 -0
  91. package/src/client/clients/profile/schema.ts +1428 -0
  92. package/src/client/clients/scheduler/index.ts +28 -0
  93. package/src/client/clients/scheduler/open-api-definition.json +120 -0
  94. package/src/client/clients/scheduler/schema.ts +113 -0
  95. package/src/client/clients/upload/index.ts +129 -0
  96. package/src/client/clients/upload/open-api-definition.json +985 -0
  97. package/src/client/clients/upload/schema.ts +563 -0
  98. package/src/client/utils/client-utils.ts +50 -0
  99. package/src/clients-configurations/clients-configuration.json +92 -0
  100. package/src/clients-configurations/read-configuration-file.ts +68 -0
  101. package/src/index.ts +43 -0
  102. package/src/logto-node.d.ts +12 -0
  103. package/src/types/index.ts +82 -0
  104. package/src/utils/get-absolute-path.ts +10 -0
  105. package/tsconfig.json +18 -0
  106. package/tsconfig.prod.json +4 -0
@@ -0,0 +1,28 @@
1
+ import type createClient from "openapi-fetch";
2
+ import { SCHEDULER } from "../../../types/index.js";
3
+ import BaseClient from "../../base-client.js";
4
+ import type { paths } from "./schema.js";
5
+
6
+ class Scheduler extends BaseClient<paths> {
7
+ declare client: ReturnType<typeof createClient<paths>>;
8
+ protected serviceName = SCHEDULER;
9
+
10
+ async scheduleTasks(
11
+ tasks: {
12
+ webhookUrl: string;
13
+ webhookAuth: string;
14
+ executeAt: string;
15
+ }[],
16
+ ) {
17
+ return this.client
18
+ .POST("/api/v1/tasks/", {
19
+ body: tasks,
20
+ })
21
+ .then(
22
+ (response) => this.formatResponse(response),
23
+ (reason) => this.formatError(reason),
24
+ );
25
+ }
26
+ }
27
+
28
+ export default Scheduler;
@@ -0,0 +1,120 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "OGCIO Scheduler API",
5
+ "description": "API for OGCIO Scheduler",
6
+ "version": "0.1.0"
7
+ },
8
+ "components": {
9
+ "schemas": {}
10
+ },
11
+ "paths": {
12
+ "/health": {
13
+ "get": {
14
+ "responses": {
15
+ "200": {
16
+ "description": "Default Response"
17
+ }
18
+ }
19
+ }
20
+ },
21
+ "/api/v1/tasks/": {
22
+ "post": {
23
+ "tags": [
24
+ "Tasks"
25
+ ],
26
+ "requestBody": {
27
+ "content": {
28
+ "application/json": {
29
+ "schema": {
30
+ "type": "array",
31
+ "items": {
32
+ "type": "object",
33
+ "properties": {
34
+ "webhookUrl": {
35
+ "format": "uri",
36
+ "type": "string"
37
+ },
38
+ "webhookAuth": {
39
+ "type": "string"
40
+ },
41
+ "executeAt": {
42
+ "format": "date-time",
43
+ "type": "string"
44
+ }
45
+ },
46
+ "required": [
47
+ "webhookUrl",
48
+ "webhookAuth",
49
+ "executeAt"
50
+ ]
51
+ }
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "responses": {
57
+ "202": {
58
+ "description": "Default Response"
59
+ },
60
+ "500": {
61
+ "description": "Default Response",
62
+ "content": {
63
+ "application/json": {
64
+ "schema": {
65
+ "type": "object",
66
+ "properties": {
67
+ "code": {
68
+ "description": "Code used to categorize the error",
69
+ "type": "string"
70
+ },
71
+ "detail": {
72
+ "description": "Description of the error",
73
+ "type": "string"
74
+ },
75
+ "requestId": {
76
+ "description": "Unique request id. This one will be used to troubleshoot the problems",
77
+ "type": "string"
78
+ },
79
+ "name": {
80
+ "description": "Name of the error type",
81
+ "type": "string"
82
+ },
83
+ "validation": {
84
+ "description": "List of the validation errors",
85
+ "type": "array",
86
+ "items": {
87
+ "type": "object",
88
+ "properties": {
89
+ "fieldName": {
90
+ "type": "string"
91
+ },
92
+ "message": {
93
+ "type": "string"
94
+ }
95
+ },
96
+ "required": [
97
+ "fieldName",
98
+ "message"
99
+ ]
100
+ }
101
+ },
102
+ "validationContext": {
103
+ "type": "string"
104
+ }
105
+ },
106
+ "required": [
107
+ "code",
108
+ "detail",
109
+ "requestId",
110
+ "name"
111
+ ]
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
@@ -0,0 +1,113 @@
1
+ export interface paths {
2
+ "/health": {
3
+ parameters: {
4
+ query?: never;
5
+ header?: never;
6
+ path?: never;
7
+ cookie?: never;
8
+ };
9
+ get: {
10
+ parameters: {
11
+ query?: never;
12
+ header?: never;
13
+ path?: never;
14
+ cookie?: never;
15
+ };
16
+ requestBody?: never;
17
+ responses: {
18
+ /** @description Default Response */
19
+ 200: {
20
+ headers: {
21
+ [name: string]: unknown;
22
+ };
23
+ content?: never;
24
+ };
25
+ };
26
+ };
27
+ put?: never;
28
+ post?: never;
29
+ delete?: never;
30
+ options?: never;
31
+ head?: never;
32
+ patch?: never;
33
+ trace?: never;
34
+ };
35
+ "/api/v1/tasks/": {
36
+ parameters: {
37
+ query?: never;
38
+ header?: never;
39
+ path?: never;
40
+ cookie?: never;
41
+ };
42
+ get?: never;
43
+ put?: never;
44
+ post: {
45
+ parameters: {
46
+ query?: never;
47
+ header?: never;
48
+ path?: never;
49
+ cookie?: never;
50
+ };
51
+ requestBody?: {
52
+ content: {
53
+ "application/json": {
54
+ /** Format: uri */
55
+ webhookUrl: string;
56
+ webhookAuth: string;
57
+ /** Format: date-time */
58
+ executeAt: string;
59
+ }[];
60
+ };
61
+ };
62
+ responses: {
63
+ /** @description Default Response */
64
+ 202: {
65
+ headers: {
66
+ [name: string]: unknown;
67
+ };
68
+ content?: never;
69
+ };
70
+ /** @description Default Response */
71
+ 500: {
72
+ headers: {
73
+ [name: string]: unknown;
74
+ };
75
+ content: {
76
+ "application/json": {
77
+ /** @description Code used to categorize the error */
78
+ code: string;
79
+ /** @description Description of the error */
80
+ detail: string;
81
+ /** @description Unique request id. This one will be used to troubleshoot the problems */
82
+ requestId: string;
83
+ /** @description Name of the error type */
84
+ name: string;
85
+ /** @description List of the validation errors */
86
+ validation?: {
87
+ fieldName: string;
88
+ message: string;
89
+ }[];
90
+ validationContext?: string;
91
+ };
92
+ };
93
+ };
94
+ };
95
+ };
96
+ delete?: never;
97
+ options?: never;
98
+ head?: never;
99
+ patch?: never;
100
+ trace?: never;
101
+ };
102
+ }
103
+ export type webhooks = Record<string, never>;
104
+ export interface components {
105
+ schemas: never;
106
+ responses: never;
107
+ parameters: never;
108
+ requestBodies: never;
109
+ headers: never;
110
+ pathItems: never;
111
+ }
112
+ export type $defs = Record<string, never>;
113
+ export type operations = Record<string, never>;
@@ -0,0 +1,129 @@
1
+ import type createClient from "openapi-fetch";
2
+ import { UPLOAD } from "../../../types/index.js";
3
+ import BaseClient from "../../base-client.js";
4
+ import type { paths } from "./schema.js";
5
+
6
+ class Upload extends BaseClient<paths> {
7
+ declare client: ReturnType<typeof createClient<paths>>;
8
+ protected serviceName = UPLOAD;
9
+
10
+ getFilesMetadata(organizationId: string) {
11
+ return this.client
12
+ .GET("/api/v1/metadata/", {
13
+ params: {
14
+ query: {
15
+ organizationId,
16
+ },
17
+ },
18
+ })
19
+ .then(
20
+ (response) => this.formatResponse(response),
21
+ (reason) => this.formatError(reason),
22
+ );
23
+ }
24
+
25
+ shareFile(fileId: string, userId: string) {
26
+ return this.client
27
+ .POST("/api/v1/permissions/", {
28
+ body: { fileId, userId },
29
+ })
30
+ .then(
31
+ (response) => this.formatResponse(response),
32
+ (reason) => this.formatError(reason),
33
+ );
34
+ }
35
+
36
+ removeFileSharing(fileId: string, userId: string) {
37
+ return this.client
38
+ .DELETE("/api/v1/permissions/", {
39
+ body: { fileId, userId },
40
+ })
41
+ .then(
42
+ (response) => this.formatResponse(response),
43
+ (reason) => this.formatError(reason),
44
+ );
45
+ }
46
+
47
+ async getFile(id: string) {
48
+ try {
49
+ const {
50
+ error,
51
+ data,
52
+ response: { headers, status },
53
+ } = await this.client.GET("/api/v1/files/{id}", {
54
+ params: { path: { id } },
55
+ parseAs: "stream",
56
+ });
57
+
58
+ return {
59
+ error,
60
+ data,
61
+ headers: Object.fromEntries(headers.entries()),
62
+ status,
63
+ };
64
+ } catch (e) {
65
+ return {
66
+ error: e,
67
+ data: null,
68
+ headers: null,
69
+ status: 500,
70
+ };
71
+ }
72
+ }
73
+
74
+ getSharedFilesForUser(userId: string) {
75
+ return this.client
76
+ .GET("/api/v1/metadata/", {
77
+ params: { query: { userId } },
78
+ })
79
+ .then(
80
+ (response) => this.formatResponse(response),
81
+ (reason) => this.formatError(reason),
82
+ );
83
+ }
84
+
85
+ getFileMetadata(id: string) {
86
+ return this.client
87
+ .GET("/api/v1/metadata/{id}", {
88
+ params: { path: { id } },
89
+ })
90
+ .then(
91
+ (response) => this.formatResponse(response),
92
+ (reason) => this.formatError(reason),
93
+ );
94
+ }
95
+
96
+ scheduleFileDeletion(id: string) {
97
+ return this.client
98
+ .DELETE("/api/v1/metadata/", {
99
+ body: { fileId: id },
100
+ })
101
+ .then(
102
+ (response) => this.formatResponse(response),
103
+ (reason) => this.formatError(reason),
104
+ );
105
+ }
106
+
107
+ async uploadFile(file: File, expirationDate?: string) {
108
+ const { error } = await this.client.POST("/api/v1/files/", {
109
+ body: {
110
+ file,
111
+ expirationDate,
112
+ },
113
+
114
+ bodySerializer: (body: unknown) => {
115
+ const pasrsed = body as { file: File; expirationDate: string };
116
+ const formData = new FormData();
117
+ if (pasrsed.expirationDate) {
118
+ formData.set("expirationDate", pasrsed.expirationDate);
119
+ }
120
+ formData.set("file", pasrsed.file);
121
+ return formData;
122
+ },
123
+ });
124
+
125
+ return { error };
126
+ }
127
+ }
128
+
129
+ export default Upload;