@aneuhold/core-ts-api-lib 2.1.24 → 2.2.0

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 (32) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/index.d.ts +3 -2
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/index.ts +2 -2
  6. package/lib/services/APIService/APIService.d.ts +4 -4
  7. package/lib/services/APIService/APIService.d.ts.map +1 -1
  8. package/lib/services/APIService/APIService.js +4 -4
  9. package/lib/services/APIService/APIService.js.map +1 -1
  10. package/lib/services/APIService/APIService.ts +7 -7
  11. package/lib/services/DOFunctionService/DOFunction.d.ts +2 -9
  12. package/lib/services/DOFunctionService/DOFunction.d.ts.map +1 -1
  13. package/lib/services/DOFunctionService/DOFunction.js.map +1 -1
  14. package/lib/services/DOFunctionService/DOFunction.ts +4 -12
  15. package/lib/services/DOFunctionService/DOFunctionService.d.ts +3 -2
  16. package/lib/services/DOFunctionService/DOFunctionService.d.ts.map +1 -1
  17. package/lib/services/DOFunctionService/DOFunctionService.js.map +1 -1
  18. package/lib/services/DOFunctionService/DOFunctionService.ts +4 -4
  19. package/lib/services/GCloudAPIService/GCloudAPIService.d.ts +30 -0
  20. package/lib/services/GCloudAPIService/GCloudAPIService.d.ts.map +1 -0
  21. package/lib/services/GCloudAPIService/GCloudAPIService.js +66 -0
  22. package/lib/services/GCloudAPIService/GCloudAPIService.js.map +1 -0
  23. package/lib/services/GCloudAPIService/GCloudAPIService.ts +81 -0
  24. package/lib/types/APIResponse.d.ts +9 -0
  25. package/lib/types/APIResponse.d.ts.map +1 -0
  26. package/lib/types/APIResponse.js +2 -0
  27. package/lib/types/APIResponse.js.map +1 -0
  28. package/lib/types/APIResponse.ts +8 -0
  29. package/lib/types/DashboardConfig.d.ts +4 -0
  30. package/lib/types/DashboardConfig.d.ts.map +1 -1
  31. package/lib/types/DashboardConfig.ts +4 -0
  32. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 🔖 [2.2.0] (2025-07-12)
9
+
10
+ ### ✅ Added
11
+
12
+ - Added new `APIResponse<T>` generic type for standardized API responses
13
+ - Added `GCloudAPIService` for interacting with Google Cloud API endpoints
14
+ - Added `gcloudBackendUrl` field to `DashboardConfig` type
15
+
16
+ ### 🏗️ Changed
17
+
18
+ - _Breaking Change:_ Replaced `DOFunctionCallOutput<T>` with `APIResponse<T>` throughout the codebase
19
+ - Updated `APIService.callDashboardAPI()` to use `GCloudAPIService` instead of `DOFunctionService`
20
+ - Updated `APIService.setDashboardAPIUrl()` to set URL on `GCloudAPIService`
21
+ - Enhanced JSDoc comment for `setDashboardAPIUrl()` to clarify URL format requirements
22
+
23
+ ### 🔥 Removed
24
+
25
+ - _Breaking Change:_ Removed `DOFunctionCallOutput` type from public exports
26
+
27
+ ## 🔖 [2.1.25] (2025-07-04)
28
+
29
+ ### 🏗️ Changed
30
+
31
+ - Updated dependencies including @aneuhold/core-ts-lib and @aneuhold/main-scripts
32
+
8
33
  ## 🔖 [2.1.24] (2025-06-26)
9
34
 
10
35
  ### 🏗️ Changed
@@ -32,6 +57,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
32
57
 
33
58
  <!-- Link References -->
34
59
 
60
+ [2.2.0]: https://github.com/aneuhold/ts-libs/compare/core-ts-api-lib-v2.1.25...core-ts-api-lib-v2.2.0
61
+ [2.1.25]: https://github.com/aneuhold/ts-libs/compare/core-ts-api-lib-v2.1.24...core-ts-api-lib-v2.1.25
35
62
  [2.1.24]: https://github.com/aneuhold/ts-libs/compare/core-ts-api-lib-v2.1.23...core-ts-api-lib-v2.1.24
36
63
  [2.1.23]: https://github.com/aneuhold/ts-libs/compare/core-ts-api-lib-v2.1.22...core-ts-api-lib-v2.1.23
37
64
  [2.1.22]: https://github.com/aneuhold/ts-libs/releases/tag/core-ts-api-lib-v2.1.22
package/lib/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import APIService from './services/APIService/APIService.js';
2
- import { DOFunctionCallOutput, DOFunctionRawInput, DOFunctionRawOutput } from './services/DOFunctionService/DOFunction.js';
2
+ import { DOFunctionRawInput, DOFunctionRawOutput } from './services/DOFunctionService/DOFunction.js';
3
3
  import DOFunctionService from './services/DOFunctionService/DOFunctionService.js';
4
4
  import { AuthCheckPasswordInput, AuthCheckPasswordOutput } from './services/DOFunctionService/functions/authCheckPassword.js';
5
5
  import { AuthValidateUserInput, AuthValidateUserOutput } from './services/DOFunctionService/functions/authValidateUser.js';
6
6
  import { ProjectDashboardInput, ProjectDashboardOptions, ProjectDashboardOutput } from './services/DOFunctionService/functions/projectDashboard.js';
7
+ import { APIResponse } from './types/APIResponse.js';
7
8
  import { DashboardConfig } from './types/DashboardConfig.js';
8
9
  import { Translation, Translations } from './types/Translations.js';
9
10
  export { APIService, DOFunctionService };
10
- export type { AuthCheckPasswordInput, AuthCheckPasswordOutput, AuthValidateUserInput, AuthValidateUserOutput, DashboardConfig, DOFunctionCallOutput, DOFunctionRawInput, DOFunctionRawOutput, ProjectDashboardInput, ProjectDashboardOptions, ProjectDashboardOutput, Translation, Translations };
11
+ export type { APIResponse, AuthCheckPasswordInput, AuthCheckPasswordOutput, AuthValidateUserInput, AuthValidateUserOutput, DashboardConfig, DOFunctionRawInput, DOFunctionRawOutput, ProjectDashboardInput, ProjectDashboardOptions, ProjectDashboardOutput, Translation, Translations };
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,mBA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AAyB,CAAC;AAGpE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AAGzC,YAAY,EACV,WAAW,EACX,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACb,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qCAAqC,CAAC;AAM7D,OAAO,iBAAiB,MAAM,mDAAmD,CAAC;AAiBlF,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qCAAqC,CAAC;AAK7D,OAAO,iBAAiB,MAAM,mDAAmD,CAAC;AAkBlF,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
package/lib/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import APIService from './services/APIService/APIService.js';
2
2
  import {
3
- DOFunctionCallOutput,
4
3
  DOFunctionRawInput,
5
4
  DOFunctionRawOutput
6
5
  } from './services/DOFunctionService/DOFunction.js';
@@ -18,6 +17,7 @@ import {
18
17
  ProjectDashboardOptions,
19
18
  ProjectDashboardOutput
20
19
  } from './services/DOFunctionService/functions/projectDashboard.js';
20
+ import { APIResponse } from './types/APIResponse.js';
21
21
  import { DashboardConfig } from './types/DashboardConfig.js';
22
22
  import { Translation, Translations } from './types/Translations.js';
23
23
 
@@ -26,12 +26,12 @@ export { APIService, DOFunctionService };
26
26
 
27
27
  // Export TypeScript types where needed
28
28
  export type {
29
+ APIResponse,
29
30
  AuthCheckPasswordInput,
30
31
  AuthCheckPasswordOutput,
31
32
  AuthValidateUserInput,
32
33
  AuthValidateUserOutput,
33
34
  DashboardConfig,
34
- DOFunctionCallOutput,
35
35
  DOFunctionRawInput,
36
36
  DOFunctionRawOutput,
37
37
  ProjectDashboardInput,
@@ -1,4 +1,4 @@
1
- import { DOFunctionCallOutput } from '../DOFunctionService/DOFunction.js';
1
+ import { APIResponse } from '../../types/APIResponse.js';
2
2
  import { AuthValidateUserInput, AuthValidateUserOutput } from '../DOFunctionService/functions/authValidateUser.js';
3
3
  import { ProjectDashboardInput, ProjectDashboardOutput } from '../DOFunctionService/functions/projectDashboard.js';
4
4
  /**
@@ -13,11 +13,11 @@ export default class APIService {
13
13
  * @param input - The input containing username and password.
14
14
  * @returns A promise that resolves to the user's information if validation is successful.
15
15
  */
16
- static validateUser(input: AuthValidateUserInput): Promise<DOFunctionCallOutput<AuthValidateUserOutput>>;
16
+ static validateUser(input: AuthValidateUserInput): Promise<APIResponse<AuthValidateUserOutput>>;
17
17
  /**
18
18
  * Sets the URL for the dashboard API.
19
19
  *
20
- * @param url - The URL to be set for the dashboard API.
20
+ * @param url - The URL to be set for the dashboard API. This should include a trailing slash.
21
21
  */
22
22
  static setDashboardAPIUrl(url: string): void;
23
23
  /**
@@ -27,6 +27,6 @@ export default class APIService {
27
27
  * @param input - The input for the dashboard API call.
28
28
  * @returns A promise that resolves to the result of the dashboard API call.
29
29
  */
30
- static callDashboardAPI(input: ProjectDashboardInput): Promise<DOFunctionCallOutput<ProjectDashboardOutput>>;
30
+ static callDashboardAPI(input: ProjectDashboardInput): Promise<APIResponse<ProjectDashboardOutput>>;
31
31
  }
32
32
  //# sourceMappingURL=APIService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"APIService.d.ts","sourceRoot":"","sources":["../../../src/services/APIService/APIService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;;;;;OAMG;WACU,YAAY,CACvB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;IAKxD;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM;IAIrC;;;;;;OAMG;WACU,gBAAgB,CAC3B,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CAIzD"}
1
+ {"version":3,"file":"APIService.d.ts","sourceRoot":"","sources":["../../../src/services/APIService/APIService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAG5D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;;;;;OAMG;WACU,YAAY,CACvB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAK/C;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM;IAIrC;;;;;;OAMG;WACU,gBAAgB,CAC3B,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CAGhD"}
@@ -1,4 +1,5 @@
1
1
  import DOFunctionService from '../DOFunctionService/DOFunctionService.js';
2
+ import GCloudAPIService from '../GCloudAPIService/GCloudAPIService.js';
2
3
  /**
3
4
  * A service for making calls to the backend API for personal projects. This is
4
5
  * abstracted so that the backend implementation can change over time.
@@ -18,10 +19,10 @@ export default class APIService {
18
19
  /**
19
20
  * Sets the URL for the dashboard API.
20
21
  *
21
- * @param url - The URL to be set for the dashboard API.
22
+ * @param url - The URL to be set for the dashboard API. This should include a trailing slash.
22
23
  */
23
24
  static setDashboardAPIUrl(url) {
24
- DOFunctionService.projectDashboard.setUrl(url);
25
+ GCloudAPIService.setUrl(url);
25
26
  }
26
27
  /**
27
28
  * Calls the dashboard API and returns the result. This will fail if the
@@ -31,8 +32,7 @@ export default class APIService {
31
32
  * @returns A promise that resolves to the result of the dashboard API call.
32
33
  */
33
34
  static async callDashboardAPI(input) {
34
- const result = await DOFunctionService.projectDashboard.call(input);
35
- return result;
35
+ return GCloudAPIService.projectDashboard(input);
36
36
  }
37
37
  }
38
38
  //# sourceMappingURL=APIService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"APIService.js","sourceRoot":"","sources":["../../../src/services/APIService/APIService.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,2CAA2C,CAAC;AAU1E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAW;QACnC,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,KAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
1
+ {"version":3,"file":"APIService.js","sourceRoot":"","sources":["../../../src/services/APIService/APIService.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,2CAA2C,CAAC;AAS1E,OAAO,gBAAgB,MAAM,yCAAyC,CAAC;AAEvE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAW;QACnC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,KAA4B;QAE5B,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import { DOFunctionCallOutput } from '../DOFunctionService/DOFunction.js';
1
+ import { APIResponse } from '../../types/APIResponse.js';
2
2
  import DOFunctionService from '../DOFunctionService/DOFunctionService.js';
3
3
  import {
4
4
  AuthValidateUserInput,
@@ -8,6 +8,7 @@ import {
8
8
  ProjectDashboardInput,
9
9
  ProjectDashboardOutput
10
10
  } from '../DOFunctionService/functions/projectDashboard.js';
11
+ import GCloudAPIService from '../GCloudAPIService/GCloudAPIService.js';
11
12
 
12
13
  /**
13
14
  * A service for making calls to the backend API for personal projects. This is
@@ -23,7 +24,7 @@ export default class APIService {
23
24
  */
24
25
  static async validateUser(
25
26
  input: AuthValidateUserInput
26
- ): Promise<DOFunctionCallOutput<AuthValidateUserOutput>> {
27
+ ): Promise<APIResponse<AuthValidateUserOutput>> {
27
28
  const result = await DOFunctionService.authValidateUser.call(input);
28
29
  return result;
29
30
  }
@@ -31,10 +32,10 @@ export default class APIService {
31
32
  /**
32
33
  * Sets the URL for the dashboard API.
33
34
  *
34
- * @param url - The URL to be set for the dashboard API.
35
+ * @param url - The URL to be set for the dashboard API. This should include a trailing slash.
35
36
  */
36
37
  static setDashboardAPIUrl(url: string) {
37
- DOFunctionService.projectDashboard.setUrl(url);
38
+ GCloudAPIService.setUrl(url);
38
39
  }
39
40
 
40
41
  /**
@@ -46,8 +47,7 @@ export default class APIService {
46
47
  */
47
48
  static async callDashboardAPI(
48
49
  input: ProjectDashboardInput
49
- ): Promise<DOFunctionCallOutput<ProjectDashboardOutput>> {
50
- const result = await DOFunctionService.projectDashboard.call(input);
51
- return result;
50
+ ): Promise<APIResponse<ProjectDashboardOutput>> {
51
+ return GCloudAPIService.projectDashboard(input);
52
52
  }
53
53
  }
@@ -1,3 +1,4 @@
1
+ import { APIResponse } from '../../types/APIResponse.js';
1
2
  /**
2
3
  * The input to a Digital Ocean function must always be an object.
3
4
  */
@@ -61,14 +62,6 @@ export interface DOFunctionRawOutput {
61
62
  'Content-Type': string;
62
63
  };
63
64
  }
64
- /**
65
- * A generic interface representing the output of a Digital Ocean function call.
66
- */
67
- export interface DOFunctionCallOutput<TOutput extends DOFunctionOutput> {
68
- success: boolean;
69
- errors: string[];
70
- data: TOutput;
71
- }
72
65
  /**
73
66
  * Type guard to check if an input object conforms to the DOFunctionRawInput structure.
74
67
  *
@@ -104,7 +97,7 @@ export default abstract class DOFunction<TInput extends DOFunctionInput, TOutput
104
97
  * @returns A promise that resolves to the output of the function call, wrapped in {@link DOFunctionCallOutput}.
105
98
  * @throws Will throw an error if the URL is not set.
106
99
  */
107
- call(input: TInput): Promise<DOFunctionCallOutput<TOutput>>;
100
+ call(input: TInput): Promise<APIResponse<TOutput>>;
108
101
  /**
109
102
  * Decodes the response from the Digital Ocean function.
110
103
  *
@@ -1 +1 @@
1
- {"version":3,"file":"DOFunction.d.ts","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,eAAe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SAAS,gBAAgB;IAEhC;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B,SAAS;IAIT;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB;;;;;;;;OAQG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAgBjE;;;;;OAKG;YACW,cAAc;CAgB7B"}
1
+ {"version":3,"file":"DOFunction.d.ts","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE;QACJ;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE;YACP,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAC3B;;eAEG;YACH,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;YAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;SACzB,CAAC;QACF;;WAEG;QACH,eAAe,EAAE,OAAO,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP;;;;WAIG;QACH,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAShF;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,UAAU,CACtC,MAAM,SAAS,eAAe,EAC9B,OAAO,SAAS,gBAAgB;IAEhC;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B,SAAS;IAIT;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB;;;;;;;;OAQG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAgBxD;;;;;OAKG;YACW,cAAc;CAgB7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"DOFunction.js","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA8E5B;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,CACL,CAAC,CAAC,KAAK;QACP,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,IAAI,KAAK;QACf,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ;QACtD,MAAM,IAAK,KAA4B,CAAC,IAAI,IAAI,sCAAsC;QACtF,iBAAiB,IAAK,KAA4B,CAAC,IAAI,CACxD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAgB,UAAU;IAItC;;OAEG;IACO,GAAG,CAAU;IAEb,YAAY,CAAS;IAE/B;QACE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AAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gBACzC,IAAI,EAAE,EAAa;aACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"DOFunction.js","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAsE5B;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,CACL,CAAC,CAAC,KAAK;QACP,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,IAAI,KAAK;QACf,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ;QACtD,MAAM,IAAK,KAA4B,CAAC,IAAI,IAAI,sCAAsC;QACtF,iBAAiB,IAAK,KAA4B,CAAC,IAAI,CACxD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAgB,UAAU;IAItC;;OAEG;IACO,GAAG,CAAU;IAEb,YAAY,CAAS;IAE/B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,iBAAiB,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACrC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,UAAU,EAAE,YAAY;gBACxB,cAAc,EAAE,0BAA0B;gBAC1C,MAAM,EAAE,0BAA0B;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC5B,CAAC,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,cAAc,CAAC,QAAkB;QAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,0BAA0B,CAAC;QACnF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC5C,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAyB,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,kDAAkD;YAClD,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAY,CAAC;YAClD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gBACzC,IAAI,EAAE,EAAa;aACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -1,4 +1,5 @@
1
1
  import { BSON } from 'bson';
2
+ import { APIResponse } from '../../types/APIResponse.js';
2
3
 
3
4
  /**
4
5
  * The input to a Digital Ocean function must always be an object.
@@ -67,15 +68,6 @@ export interface DOFunctionRawOutput {
67
68
  };
68
69
  }
69
70
 
70
- /**
71
- * A generic interface representing the output of a Digital Ocean function call.
72
- */
73
- export interface DOFunctionCallOutput<TOutput extends DOFunctionOutput> {
74
- success: boolean;
75
- errors: string[];
76
- data: TOutput;
77
- }
78
-
79
71
  /**
80
72
  * Type guard to check if an input object conforms to the DOFunctionRawInput structure.
81
73
  *
@@ -132,7 +124,7 @@ export default abstract class DOFunction<
132
124
  * @returns A promise that resolves to the output of the function call, wrapped in {@link DOFunctionCallOutput}.
133
125
  * @throws Will throw an error if the URL is not set.
134
126
  */
135
- async call(input: TInput): Promise<DOFunctionCallOutput<TOutput>> {
127
+ async call(input: TInput): Promise<APIResponse<TOutput>> {
136
128
  if (!this.url) {
137
129
  throw new Error(`${this.functionName} URL is not set`);
138
130
  }
@@ -154,12 +146,12 @@ export default abstract class DOFunction<
154
146
  * @param response - The response to decode.
155
147
  * @returns The decoded output.
156
148
  */
157
- private async decodeResponse(response: Response): Promise<DOFunctionCallOutput<TOutput>> {
149
+ private async decodeResponse(response: Response): Promise<APIResponse<TOutput>> {
158
150
  const isBson = response.headers.get('Content-Type') === 'application/octet-stream';
159
151
  if (isBson) {
160
152
  const buffer = await response.arrayBuffer();
161
153
  const uint8Array = new Uint8Array(buffer);
162
- return BSON.deserialize(uint8Array) as DOFunctionCallOutput<TOutput>;
154
+ return BSON.deserialize(uint8Array) as APIResponse<TOutput>;
163
155
  } else {
164
156
  // This normally only happens if there is an error
165
157
  const result = (await response.json()) as unknown;
@@ -1,4 +1,5 @@
1
- import { DOFunctionCallOutput, DOFunctionInput, DOFunctionOutput, DOFunctionRawInput, DOFunctionRawOutput } from './DOFunction.js';
1
+ import { APIResponse } from '../../types/APIResponse.js';
2
+ import { DOFunctionInput, DOFunctionOutput, DOFunctionRawInput, DOFunctionRawOutput } from './DOFunction.js';
2
3
  import AuthCheckPassword from './functions/authCheckPassword.js';
3
4
  import AuthValidateUser from './functions/authValidateUser.js';
4
5
  import ProjectDashboard from './functions/projectDashboard.js';
@@ -32,7 +33,7 @@ export default class DOFunctionService {
32
33
  * @param handler - The handler function to process the input.
33
34
  * @returns The raw output of the function call.
34
35
  */
35
- static handleApiRequest<TInput extends DOFunctionInput, TOutput extends DOFunctionOutput>(functionName: string, rawInputFromDO: DOFunctionRawInput | TInput, handler: (input: TInput) => Promise<DOFunctionCallOutput<TOutput>>): Promise<DOFunctionRawOutput>;
36
+ static handleApiRequest<TInput extends DOFunctionInput, TOutput extends DOFunctionOutput>(functionName: string, rawInputFromDO: DOFunctionRawInput | TInput, handler: (input: TInput) => Promise<APIResponse<TOutput>>): Promise<DOFunctionRawOutput>;
36
37
  /**
37
38
  * Deserializes the raw input into a typed input object using type guards.
38
39
  * Handles raw HTTP input, the DO UI wrapper, or already deserialized input.
@@ -1 +1 @@
1
- {"version":3,"file":"DOFunctionService.d.ts","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAmC;IAE9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;;;;;;;;;;;;OAaG;WACU,gBAAgB,CAAC,MAAM,SAAS,eAAe,EAAE,OAAO,SAAS,gBAAgB,EAC5F,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,kBAAkB,GAAG,MAAM,EAC3C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,GACjE,OAAO,CAAC,mBAAmB,CAAC;IA2D/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IA4D/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;CAM/B"}
1
+ {"version":3,"file":"DOFunctionService.d.ts","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAmC;IAE9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;;;;;;;;;;;;OAaG;WACU,gBAAgB,CAAC,MAAM,SAAS,eAAe,EAAE,OAAO,SAAS,gBAAgB,EAC5F,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,kBAAkB,GAAG,MAAM,EAC3C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,GACxD,OAAO,CAAC,mBAAmB,CAAC;IA2D/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IA4D/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;CAM/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"DOFunctionService.js","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAML,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;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,CAAC;YACD,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,iDAAiD;aAC5C,CAAC;YACJ,EAAE,CAAC,MAAM,CAAC,IAAI,CACZ,mGAAmG,CACpG,CAAC;YACF,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,eAAe,CAC5B,MAAqC;QAErC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC"}
1
+ {"version":3,"file":"DOFunctionService.js","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAKL,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,GAAsB,iBAAiB,CAAC,WAAW,EAAE,CAAC;IAE9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,GAAqB,gBAAgB,CAAC,WAAW,EAAE,CAAC;IAE3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,GAAqB,gBAAgB,CAAC,WAAW,EAAE,CAAC;IAE3E;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,YAAoB,EACpB,cAA2C,EAC3C,OAAyD;QAEzD,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,YAAY,IAAI,CAAC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AC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAW,CAAC;oBACnE,CAAC;oBAAC,OAAO,SAAS,EAAE,CAAC;wBACnB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,mDAAmD,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;wBACxF,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;oBACvE,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;gBACnF,IAAI,CAAC;oBACH,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAW,CAAC;gBACnE,CAAC;gBAAC,OAAO,SAAS,EAAE,CAAC;oBACnB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;oBAC/E,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;YACD,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,iDAAiD;aAC5C,CAAC;YACJ,EAAE,CAAC,MAAM,CAAC,IAAI,CACZ,mGAAmG,CACpG,CAAC;YACF,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,eAAe,CAC5B,MAA4B;QAE5B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { DR } from '@aneuhold/core-ts-lib';
2
2
  import { BSON } from 'bson';
3
+ import { APIResponse } from '../../types/APIResponse.js';
3
4
  import {
4
- DOFunctionCallOutput,
5
5
  DOFunctionInput,
6
6
  DOFunctionOutput,
7
7
  DOFunctionRawInput,
@@ -48,7 +48,7 @@ export default class DOFunctionService {
48
48
  static async handleApiRequest<TInput extends DOFunctionInput, TOutput extends DOFunctionOutput>(
49
49
  functionName: string,
50
50
  rawInputFromDO: DOFunctionRawInput | TInput,
51
- handler: (input: TInput) => Promise<DOFunctionCallOutput<TOutput>>
51
+ handler: (input: TInput) => Promise<APIResponse<TOutput>>
52
52
  ): Promise<DOFunctionRawOutput> {
53
53
  DR.logger.info(`[DOFunctionService] handleApiRequest called for "${functionName}".`); // Log entry
54
54
  DR.logger.info(`[DOFunctionService] Calling DR.tracer.startSpan for "${functionName}"...`); // Log before startSpan
@@ -61,7 +61,7 @@ export default class DOFunctionService {
61
61
  'Content-Type': 'application/octet-stream'
62
62
  }
63
63
  };
64
- const defaultOutput: DOFunctionCallOutput<TOutput> = {
64
+ const defaultOutput: APIResponse<TOutput> = {
65
65
  success: false,
66
66
  errors: [],
67
67
  data: {} as TOutput
@@ -183,7 +183,7 @@ export default class DOFunctionService {
183
183
  * @returns The serialized output as a base64 string.
184
184
  */
185
185
  private static serializeOutput<TOutput extends DOFunctionOutput>(
186
- output: DOFunctionCallOutput<TOutput>
186
+ output: APIResponse<TOutput>
187
187
  ): string {
188
188
  const bsonBuffer = BSON.serialize(output);
189
189
  return Buffer.from(bsonBuffer).toString('base64');
@@ -0,0 +1,30 @@
1
+ import { APIResponse } from '../../types/APIResponse.js';
2
+ import { ProjectDashboardInput, ProjectDashboardOutput } from '../DOFunctionService/functions/projectDashboard.js';
3
+ /**
4
+ * A service for interacting with the Google Cloud API service for personal projects.
5
+ */
6
+ export default class GCloudAPIService {
7
+ #private;
8
+ /**
9
+ * Sets the URL of the Google Cloud API.
10
+ *
11
+ * @param url - The URL to set.
12
+ */
13
+ static setUrl(url: string): void;
14
+ /**
15
+ * Calls the project dashboard endpoint to get, insert, update, or delete dashboard data.
16
+ *
17
+ * @param input - The input for the project dashboard function.
18
+ */
19
+ static projectDashboard(input: ProjectDashboardInput): Promise<APIResponse<ProjectDashboardOutput>>;
20
+ /**
21
+ * Makes a call to the Google Cloud API.
22
+ *
23
+ * @param urlPath - The path to the endpoint.
24
+ * @param input - The input to the endpoint.
25
+ * @returns A promise that resolves to the output of the function call, wrapped in {@link APIResponse}.
26
+ * @throws Will throw an error if the URL is not set.
27
+ */
28
+ private static call;
29
+ }
30
+ //# sourceMappingURL=GCloudAPIService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GCloudAPIService.d.ts","sourceRoot":"","sources":["../../../src/services/GCloudAPIService/GCloudAPIService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;;IAOnC;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIhC;;;;OAIG;WACU,gBAAgB,CAC3B,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAI/C;;;;;;;OAOG;mBACkB,IAAI;CAoC1B"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * A service for interacting with the Google Cloud API service for personal projects.
3
+ */
4
+ export default class GCloudAPIService {
5
+ /**
6
+ * The base URL of the Google Cloud API. For example, `something.com/api/`. It will include
7
+ * the trailing slash.
8
+ */
9
+ static #baseUrl;
10
+ /**
11
+ * Sets the URL of the Google Cloud API.
12
+ *
13
+ * @param url - The URL to set.
14
+ */
15
+ static setUrl(url) {
16
+ this.#baseUrl = url;
17
+ }
18
+ /**
19
+ * Calls the project dashboard endpoint to get, insert, update, or delete dashboard data.
20
+ *
21
+ * @param input - The input for the project dashboard function.
22
+ */
23
+ static async projectDashboard(input) {
24
+ return this.call('project/dashboard', input);
25
+ }
26
+ /**
27
+ * Makes a call to the Google Cloud API.
28
+ *
29
+ * @param urlPath - The path to the endpoint.
30
+ * @param input - The input to the endpoint.
31
+ * @returns A promise that resolves to the output of the function call, wrapped in {@link APIResponse}.
32
+ * @throws Will throw an error if the URL is not set.
33
+ */
34
+ static async call(urlPath, input) {
35
+ if (!this.#baseUrl) {
36
+ throw new Error('GCloudAPI URL is not set');
37
+ }
38
+ const response = await fetch(this.#baseUrl + urlPath, {
39
+ method: 'POST',
40
+ headers: {
41
+ 'Content-Type': 'application/json',
42
+ Accept: 'application/json'
43
+ },
44
+ body: JSON.stringify(input)
45
+ });
46
+ if (!response.ok) {
47
+ return {
48
+ success: false,
49
+ errors: [`HTTP ${response.status}: ${response.statusText}`],
50
+ data: {}
51
+ };
52
+ }
53
+ try {
54
+ const result = (await response.json());
55
+ return result;
56
+ }
57
+ catch (error) {
58
+ return {
59
+ success: false,
60
+ errors: [`Failed to parse response: ${String(error)}`],
61
+ data: {}
62
+ };
63
+ }
64
+ }
65
+ }
66
+ //# sourceMappingURL=GCloudAPIService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GCloudAPIService.js","sourceRoot":"","sources":["../../../src/services/GCloudAPIService/GCloudAPIService.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAU;IAEzB;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,KAA4B;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAgD,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAC9F,CAAC;IAED;;;;;;;OAOG;IACK,MAAM,CAAC,KAAK,CAAC,IAAI,CACvB,OAAe,EACf,KAAa;QAEb,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,kBAAkB;aAC3B;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;gBAC3D,IAAI,EAAE,EAAa;aACpB,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAyB,CAAC;YAC/D,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,CAAC,6BAA6B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtD,IAAI,EAAE,EAAa;aACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,81 @@
1
+ import { APIResponse } from '../../types/APIResponse.js';
2
+ import {
3
+ ProjectDashboardInput,
4
+ ProjectDashboardOutput
5
+ } from '../DOFunctionService/functions/projectDashboard.js';
6
+
7
+ /**
8
+ * A service for interacting with the Google Cloud API service for personal projects.
9
+ */
10
+ export default class GCloudAPIService {
11
+ /**
12
+ * The base URL of the Google Cloud API. For example, `something.com/api/`. It will include
13
+ * the trailing slash.
14
+ */
15
+ static #baseUrl?: string;
16
+
17
+ /**
18
+ * Sets the URL of the Google Cloud API.
19
+ *
20
+ * @param url - The URL to set.
21
+ */
22
+ static setUrl(url: string): void {
23
+ this.#baseUrl = url;
24
+ }
25
+
26
+ /**
27
+ * Calls the project dashboard endpoint to get, insert, update, or delete dashboard data.
28
+ *
29
+ * @param input - The input for the project dashboard function.
30
+ */
31
+ static async projectDashboard(
32
+ input: ProjectDashboardInput
33
+ ): Promise<APIResponse<ProjectDashboardOutput>> {
34
+ return this.call<ProjectDashboardInput, ProjectDashboardOutput>('project/dashboard', input);
35
+ }
36
+
37
+ /**
38
+ * Makes a call to the Google Cloud API.
39
+ *
40
+ * @param urlPath - The path to the endpoint.
41
+ * @param input - The input to the endpoint.
42
+ * @returns A promise that resolves to the output of the function call, wrapped in {@link APIResponse}.
43
+ * @throws Will throw an error if the URL is not set.
44
+ */
45
+ private static async call<TInput, TOutput>(
46
+ urlPath: string,
47
+ input: TInput
48
+ ): Promise<APIResponse<TOutput>> {
49
+ if (!this.#baseUrl) {
50
+ throw new Error('GCloudAPI URL is not set');
51
+ }
52
+
53
+ const response = await fetch(this.#baseUrl + urlPath, {
54
+ method: 'POST',
55
+ headers: {
56
+ 'Content-Type': 'application/json',
57
+ Accept: 'application/json'
58
+ },
59
+ body: JSON.stringify(input)
60
+ });
61
+
62
+ if (!response.ok) {
63
+ return {
64
+ success: false,
65
+ errors: [`HTTP ${response.status}: ${response.statusText}`],
66
+ data: {} as TOutput
67
+ };
68
+ }
69
+
70
+ try {
71
+ const result = (await response.json()) as APIResponse<TOutput>;
72
+ return result;
73
+ } catch (error) {
74
+ return {
75
+ success: false,
76
+ errors: [`Failed to parse response: ${String(error)}`],
77
+ data: {} as TOutput
78
+ };
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generic for API responses for personal APIs.
3
+ */
4
+ export type APIResponse<T> = {
5
+ success: boolean;
6
+ errors: string[];
7
+ data: T;
8
+ };
9
+ //# sourceMappingURL=APIResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIResponse.d.ts","sourceRoot":"","sources":["../../src/types/APIResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;CACT,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=APIResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIResponse.js","sourceRoot":"","sources":["../../src/types/APIResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generic for API responses for personal APIs.
3
+ */
4
+ export type APIResponse<T> = {
5
+ success: boolean;
6
+ errors: string[];
7
+ data: T;
8
+ };
@@ -4,6 +4,10 @@
4
4
  */
5
5
  export type DashboardConfig = {
6
6
  projectDashboardFunctionUrl: string;
7
+ /**
8
+ * The URL for the GCloud backend API. This should contain the trailing slash.
9
+ */
10
+ gcloudBackendUrl: string;
7
11
  automationUrls: {
8
12
  sunLight: string;
9
13
  zoomLighting: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardConfig.d.ts","sourceRoot":"","sources":["../../src/types/DashboardConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B,EAAE,MAAM,CAAC;IACpC,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,4BAA4B,EAAE,MAAM,CAAC;QACrC,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"DashboardConfig.d.ts","sourceRoot":"","sources":["../../src/types/DashboardConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B,EAAE,MAAM,CAAC;IACpC;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,4BAA4B,EAAE,MAAM,CAAC;QACrC,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC"}
@@ -4,6 +4,10 @@
4
4
  */
5
5
  export type DashboardConfig = {
6
6
  projectDashboardFunctionUrl: string;
7
+ /**
8
+ * The URL for the GCloud backend API. This should contain the trailing slash.
9
+ */
10
+ gcloudBackendUrl: string;
7
11
  automationUrls: {
8
12
  sunLight: string;
9
13
  zoomLighting: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aneuhold/core-ts-api-lib",
3
3
  "author": "Anton G. Neuhold Jr.",
4
4
  "license": "MIT",
5
- "version": "2.1.24",
5
+ "version": "2.2.0",
6
6
  "description": "A library for interacting with the backend and defining the backend API for personal projects.",
7
7
  "packageManager": "pnpm@10.12.1",
8
8
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@aneuhold/local-npm-registry": "*",
58
- "@aneuhold/main-scripts": "^2.5.0",
58
+ "@aneuhold/main-scripts": "^2.5.2",
59
59
  "@types/node": "^22.15.32",
60
60
  "eslint": "^9.29.0",
61
61
  "jsr": "^0.13.4",