@growi/sdk-typescript 1.6.0 → 1.8.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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/apiv1/index.d.ts +19 -19
  3. package/dist/apiv3/index.d.ts +235 -235
  4. package/dist/generated/v1/index.d.ts +1 -1
  5. package/dist/generated/v1/index.schemas.d.ts +1 -1
  6. package/dist/generated/v3/index.d.ts +9 -9
  7. package/dist/generated/v3/index.d.ts.map +1 -1
  8. package/dist/generated/v3/index.js +11 -11
  9. package/dist/generated/v3/index.js.map +1 -1
  10. package/dist/generated/v3/index.schemas.d.ts +14 -17
  11. package/dist/generated/v3/index.schemas.d.ts.map +1 -1
  12. package/dist/generated/v3/index.schemas.js.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/utils/axios-instance-manager.d.ts +27 -0
  18. package/dist/utils/axios-instance-manager.d.ts.map +1 -0
  19. package/dist/utils/axios-instance-manager.js +36 -0
  20. package/dist/utils/axios-instance-manager.js.map +1 -0
  21. package/dist/utils/types/custom-instance.d.ts +6 -0
  22. package/dist/utils/types/custom-instance.d.ts.map +1 -0
  23. package/dist/utils/types/custom-instance.js +2 -0
  24. package/dist/utils/types/custom-instance.js.map +1 -0
  25. package/dist/utils/v1/axios-instance.d.ts +2 -1
  26. package/dist/utils/v1/axios-instance.d.ts.map +1 -1
  27. package/dist/utils/v1/axios-instance.js +9 -5
  28. package/dist/utils/v1/axios-instance.js.map +1 -1
  29. package/dist/utils/v3/axios-instance.d.ts +2 -1
  30. package/dist/utils/v3/axios-instance.d.ts.map +1 -1
  31. package/dist/utils/v3/axios-instance.js +9 -5
  32. package/dist/utils/v3/axios-instance.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/generated/v1/index.schemas.ts +1 -1
  35. package/src/generated/v1/index.ts +1 -1
  36. package/src/generated/v3/index.schemas.ts +15 -18
  37. package/src/generated/v3/index.ts +20 -17
  38. package/src/index.ts +1 -1
  39. package/src/utils/axios-instance-manager.ts +41 -0
  40. package/src/utils/types/custom-instance.ts +6 -0
  41. package/src/utils/v1/axios-instance.test.ts +26 -15
  42. package/src/utils/v1/axios-instance.ts +13 -6
  43. package/src/utils/v3/axios-instance.test.ts +43 -25
  44. package/src/utils/v3/axios-instance.ts +13 -6
  45. package/dist/utils/axios-default-instance.d.ts +0 -14
  46. package/dist/utils/axios-default-instance.d.ts.map +0 -1
  47. package/dist/utils/axios-default-instance.js +0 -22
  48. package/dist/utils/axios-default-instance.js.map +0 -1
  49. package/src/utils/axios-default-instance.test.ts +0 -108
  50. package/src/utils/axios-default-instance.ts +0 -23
@@ -1,22 +0,0 @@
1
- import Axios from 'axios';
2
- const DEFAULT_AXIOS_INSTANCE = Axios.create({
3
- baseURL: 'http://localhost', // set baseURL if you need
4
- });
5
- export const AXIOS_DEFAULT = {
6
- instance: DEFAULT_AXIOS_INSTANCE,
7
- /**
8
- * Set the base URL for the default Axios instance.
9
- * @param baseURL The base URL to set for the Axios instance.
10
- */
11
- setBaseURL: (baseURL) => {
12
- DEFAULT_AXIOS_INSTANCE.defaults.baseURL = baseURL;
13
- },
14
- /**
15
- * Set the Authorization header for the default Axios instance.
16
- * @param token The authentication token to set in the Authorization header.
17
- */
18
- setAuthorizationHeader: (token) => {
19
- DEFAULT_AXIOS_INSTANCE.defaults.headers.common.Authorization = `Bearer ${token}`;
20
- },
21
- };
22
- //# sourceMappingURL=axios-default-instance.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"axios-default-instance.js","sourceRoot":"","sources":["../../src/utils/axios-default-instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAEvD,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,kBAAkB,EAAE,0BAA0B;CACxD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,sBAAsB;IAChC;;;OAGG;IACH,UAAU,EAAE,CAAC,OAAe,EAAQ,EAAE;QACpC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;IACpD,CAAC;IACD;;;OAGG;IACH,sBAAsB,EAAE,CAAC,KAAa,EAAQ,EAAE;QAC9C,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAC;IACnF,CAAC;CACF,CAAC"}
@@ -1,108 +0,0 @@
1
- import type { AxiosInstance } from 'axios';
2
- /**
3
- * Tests for axios-default-instance.ts
4
- *
5
- * This file manages the default Axios instance for GROWI SDK,
6
- * providing functionality to configure base URL and authentication headers.
7
- */
8
- import { beforeEach, describe, expect, it, vi } from 'vitest';
9
- import { AXIOS_DEFAULT } from './axios-default-instance.js';
10
-
11
- describe('AXIOS_DEFAULT', () => {
12
- beforeEach(() => {
13
- // Reset the instance before each test
14
- AXIOS_DEFAULT.instance.defaults.baseURL = 'http://localhost';
15
- AXIOS_DEFAULT.instance.defaults.headers.common.Authorization = undefined;
16
- });
17
-
18
- describe('setBaseURL', () => {
19
- it('should update base URL when setting a valid URL', () => {
20
- // Arrange
21
- const newBaseURL = 'https://api.example.com';
22
-
23
- // Act
24
- AXIOS_DEFAULT.setBaseURL(newBaseURL);
25
-
26
- // Assert
27
- expect(AXIOS_DEFAULT.instance.defaults.baseURL).toBe(newBaseURL);
28
- });
29
-
30
- it('should set base URL to empty string when empty string is provided', () => {
31
- // Arrange
32
- const emptyURL = '';
33
-
34
- // Act
35
- AXIOS_DEFAULT.setBaseURL(emptyURL);
36
-
37
- // Assert
38
- expect(AXIOS_DEFAULT.instance.defaults.baseURL).toBe(emptyURL);
39
- });
40
-
41
- it('should use the last value when called multiple times', () => {
42
- // Arrange
43
- const firstURL = 'https://first.example.com';
44
- const secondURL = 'https://second.example.com';
45
-
46
- // Act
47
- AXIOS_DEFAULT.setBaseURL(firstURL);
48
- AXIOS_DEFAULT.setBaseURL(secondURL);
49
-
50
- // Assert
51
- expect(AXIOS_DEFAULT.instance.defaults.baseURL).toBe(secondURL);
52
- });
53
- });
54
-
55
- describe('setAuthorizationHeader', () => {
56
- it('should set authorization header in Bearer token format when valid token is provided', () => {
57
- // Arrange
58
- const token = 'test-token-123';
59
- const expectedHeader = `Bearer ${token}`;
60
-
61
- // Act
62
- AXIOS_DEFAULT.setAuthorizationHeader(token);
63
-
64
- // Assert
65
- expect(AXIOS_DEFAULT.instance.defaults.headers.common.Authorization).toBe(expectedHeader);
66
- });
67
-
68
- it('should set Bearer header with empty string when empty token is provided', () => {
69
- // Arrange
70
- const emptyToken = '';
71
- const expectedHeader = 'Bearer ';
72
-
73
- // Act
74
- AXIOS_DEFAULT.setAuthorizationHeader(emptyToken);
75
-
76
- // Assert
77
- expect(AXIOS_DEFAULT.instance.defaults.headers.common.Authorization).toBe(expectedHeader);
78
- });
79
-
80
- it('should use the last token when called multiple times', () => {
81
- // Arrange
82
- const firstToken = 'first-token';
83
- const secondToken = 'second-token';
84
- const expectedHeader = `Bearer ${secondToken}`;
85
-
86
- // Act
87
- AXIOS_DEFAULT.setAuthorizationHeader(firstToken);
88
- AXIOS_DEFAULT.setAuthorizationHeader(secondToken);
89
-
90
- // Assert
91
- expect(AXIOS_DEFAULT.instance.defaults.headers.common.Authorization).toBe(expectedHeader);
92
- });
93
- });
94
-
95
- describe('instance', () => {
96
- it('should have default base URL set to localhost', () => {
97
- // Assert
98
- expect(AXIOS_DEFAULT.instance.defaults.baseURL).toBe('http://localhost');
99
- });
100
-
101
- it('should have Axios instance properly created', () => {
102
- // Assert
103
- expect(AXIOS_DEFAULT.instance).toBeDefined();
104
- expect(typeof AXIOS_DEFAULT.instance).toBe('function');
105
- expect(AXIOS_DEFAULT.instance.defaults).toBeDefined();
106
- });
107
- });
108
- });
@@ -1,23 +0,0 @@
1
- import Axios, { type AxiosRequestConfig } from 'axios';
2
-
3
- const DEFAULT_AXIOS_INSTANCE = Axios.create({
4
- baseURL: 'http://localhost', // set baseURL if you need
5
- });
6
-
7
- export const AXIOS_DEFAULT = {
8
- instance: DEFAULT_AXIOS_INSTANCE,
9
- /**
10
- * Set the base URL for the default Axios instance.
11
- * @param baseURL The base URL to set for the Axios instance.
12
- */
13
- setBaseURL: (baseURL: string): void => {
14
- DEFAULT_AXIOS_INSTANCE.defaults.baseURL = baseURL;
15
- },
16
- /**
17
- * Set the Authorization header for the default Axios instance.
18
- * @param token The authentication token to set in the Authorization header.
19
- */
20
- setAuthorizationHeader: (token: string): void => {
21
- DEFAULT_AXIOS_INSTANCE.defaults.headers.common.Authorization = `Bearer ${token}`;
22
- },
23
- };