@growi/sdk-typescript 1.7.0 → 1.10.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 (57) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +81 -29
  3. package/README_JP.md +81 -29
  4. package/dist/apiv1/index.d.ts +19 -19
  5. package/dist/apiv3/index.d.ts +239 -235
  6. package/dist/apiv3/index.d.ts.map +1 -1
  7. package/dist/generated/v1/index.d.ts +1 -1
  8. package/dist/generated/v1/index.schemas.d.ts +47 -2
  9. package/dist/generated/v1/index.schemas.d.ts.map +1 -1
  10. package/dist/generated/v1/index.schemas.js.map +1 -1
  11. package/dist/generated/v3/index.d.ts +21 -13
  12. package/dist/generated/v3/index.d.ts.map +1 -1
  13. package/dist/generated/v3/index.js +65 -35
  14. package/dist/generated/v3/index.js.map +1 -1
  15. package/dist/generated/v3/index.schemas.d.ts +217 -105
  16. package/dist/generated/v3/index.schemas.d.ts.map +1 -1
  17. package/dist/generated/v3/index.schemas.js +11 -0
  18. package/dist/generated/v3/index.schemas.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/utils/axios-instance-manager.d.ts +33 -0
  24. package/dist/utils/axios-instance-manager.d.ts.map +1 -0
  25. package/dist/utils/axios-instance-manager.js +59 -0
  26. package/dist/utils/axios-instance-manager.js.map +1 -0
  27. package/dist/utils/types/custom-instance.d.ts +6 -0
  28. package/dist/utils/types/custom-instance.d.ts.map +1 -0
  29. package/dist/utils/types/custom-instance.js +2 -0
  30. package/dist/utils/types/custom-instance.js.map +1 -0
  31. package/dist/utils/v1/axios-instance.d.ts +2 -1
  32. package/dist/utils/v1/axios-instance.d.ts.map +1 -1
  33. package/dist/utils/v1/axios-instance.js +9 -5
  34. package/dist/utils/v1/axios-instance.js.map +1 -1
  35. package/dist/utils/v3/axios-instance.d.ts +2 -1
  36. package/dist/utils/v3/axios-instance.d.ts.map +1 -1
  37. package/dist/utils/v3/axios-instance.js +9 -5
  38. package/dist/utils/v3/axios-instance.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/generated/v1/index.schemas.ts +49 -2
  41. package/src/generated/v1/index.ts +1 -1
  42. package/src/generated/v3/index.schemas.ts +238 -112
  43. package/src/generated/v3/index.ts +106 -54
  44. package/src/index.ts +1 -1
  45. package/src/utils/axios-instance-manager.test.ts +185 -0
  46. package/src/utils/axios-instance-manager.ts +61 -0
  47. package/src/utils/types/custom-instance.ts +6 -0
  48. package/src/utils/v1/axios-instance.test.ts +26 -15
  49. package/src/utils/v1/axios-instance.ts +13 -6
  50. package/src/utils/v3/axios-instance.test.ts +43 -25
  51. package/src/utils/v3/axios-instance.ts +13 -6
  52. package/dist/utils/axios-default-instance.d.ts +0 -14
  53. package/dist/utils/axios-default-instance.d.ts.map +0 -1
  54. package/dist/utils/axios-default-instance.js +0 -22
  55. package/dist/utils/axios-default-instance.js.map +0 -1
  56. package/src/utils/axios-default-instance.test.ts +0 -108
  57. package/src/utils/axios-default-instance.ts +0 -23
@@ -2,7 +2,7 @@
2
2
  * Generated by orval v7.9.0 🍺
3
3
  * Do not edit manually.
4
4
  * GROWI REST API v3
5
- * OpenAPI spec version: 7.3.0-RC.0
5
+ * OpenAPI spec version: 7.5.5-RC.0
6
6
  */
7
7
  import type {
8
8
  ActivityResponse,
@@ -46,8 +46,6 @@ import type {
46
46
  GetActivityParams,
47
47
  GetAdminHome200,
48
48
  GetAllShareLinksForSecuritySetting200,
49
- GetAncestorsChildrenForPageListing200,
50
- GetAncestorsChildrenForPageListingParams,
51
49
  GetAncestorsForExternalUserGroups200,
52
50
  GetAncestorsForExternalUserGroupsParams,
53
51
  GetAncestorsForUserGroups200,
@@ -64,6 +62,7 @@ import type {
64
62
  GetChildrenForUserGroups200,
65
63
  GetChildrenForUserGroupsParams,
66
64
  GetCollectionsForMongo200,
65
+ GetContentDispositionSettings200,
67
66
  GetCustomizeSetting200,
68
67
  GetEditorSettingsForPersonalSetting200,
69
68
  GetExistForPage200,
@@ -86,7 +85,6 @@ import type {
86
85
  GetGrowiInfoForG2gTransfer200,
87
86
  GetHealthcheck200,
88
87
  GetHealthcheckParams,
89
- GetImport200,
90
88
  GetInAppNotificationSettingsForPersonalSetting200,
91
89
  GetIndicesForSearch200,
92
90
  GetInfoForBookmarksParams,
@@ -94,6 +92,8 @@ import type {
94
92
  GetInfoForPageListingParams,
95
93
  GetInfoForPageParams,
96
94
  GetIsPasswordSetForPersonalSetting200,
95
+ GetItemForPageListing200,
96
+ GetItemForPageListingParams,
97
97
  GetLimitForAttachment200,
98
98
  GetLimitForAttachmentParams,
99
99
  GetListByUserIdForBookmarkFolder200,
@@ -110,6 +110,7 @@ import type {
110
110
  GetNonUserRelatedGroupsGrantedForPageParams,
111
111
  GetNotificationSetting200,
112
112
  GetPageParams,
113
+ GetPageResponse,
113
114
  GetPagesByIdForUserGroups200,
114
115
  GetPersonalSetting200,
115
116
  GetPluginTemplatesByLocaleByTemplateIdByReposIdByOrganizationIdForTemplates200,
@@ -126,6 +127,7 @@ import type {
126
127
  GetSelectableParentGroupsParams,
127
128
  GetShareLinks200,
128
129
  GetShareLinksParams,
130
+ GetSharedForPageParams,
129
131
  GetSlackIntegrationLegacySetting200,
130
132
  GetSlackIntegrationSettings200,
131
133
  GetStatusForExport200,
@@ -166,7 +168,7 @@ import type {
166
168
  NotifyForPageGrant,
167
169
  OidcAuthSetting,
168
170
  Page,
169
- PageInfoAll,
171
+ PageInfoExt,
170
172
  PersonalSettings,
171
173
  PostAccessTokenForPersonalSetting200,
172
174
  PostAddBookmarkToFolderForBookmarkFolder200,
@@ -230,6 +232,7 @@ import type {
230
232
  PostShareLinksBody,
231
233
  PostSlackAppIntegrationsForSlackIntegrationSettings200,
232
234
  PostSmtpTestForAppSettings200,
235
+ PostSuggestPathForAiToolsBody,
233
236
  PostTestForSlackIntegrationSettingsWithoutProxyBody,
234
237
  PostTransferForG2gTransfer200,
235
238
  PostTransferForG2gTransferBody,
@@ -250,6 +253,7 @@ import type {
250
253
  PutBookmarkFolder200,
251
254
  PutBookmarkFolderBody,
252
255
  PutBookmarks200,
256
+ PutContentDispositionSettings200,
253
257
  PutContentWidthByPageId200,
254
258
  PutContentWidthByPageIdBody,
255
259
  PutCustomizeCssForCustomizeSetting200,
@@ -289,6 +293,8 @@ import type {
289
293
  PutLdapForSecuritySetting200,
290
294
  PutLineBreakForMarkdownSetting200,
291
295
  PutLocalSettingForSecuritySetting200,
296
+ PutOauth2SettingForAppSettings200,
297
+ PutOauth2SettingForAppSettingsBody,
292
298
  PutOidcForSecuritySetting200,
293
299
  PutPage200,
294
300
  PutPageBody,
@@ -347,6 +353,7 @@ import type {
347
353
  SiteUrlSettingParams,
348
354
  SmtpSettingParams,
349
355
  StatisticsUserResponse,
356
+ SuggestPathResponse,
350
357
  SyncStatus,
351
358
  UserNotification,
352
359
  UserNotificationParams,
@@ -532,6 +539,17 @@ export const getGrowirestapiv3 = () => {
532
539
  );
533
540
  };
534
541
 
542
+ /**
543
+ * Analyzes the given content and suggests appropriate page paths using keyword extraction, search, and AI evaluation.
544
+ * @summary Suggest page paths based on content
545
+ */
546
+ const postSuggestPathForAiTools = (postSuggestPathForAiToolsBody: PostSuggestPathForAiToolsBody, options?: SecondParameter<typeof customInstance>) => {
547
+ return customInstance<SuggestPathResponse>(
548
+ { url: `/ai-tools/suggest-path`, method: 'POST', headers: { 'Content-Type': 'application/json' }, data: postSuggestPathForAiToolsBody },
549
+ options,
550
+ );
551
+ };
552
+
535
553
  /**
536
554
  * Install a plugin
537
555
  * @summary /plugins
@@ -571,6 +589,17 @@ export const getGrowirestapiv3 = () => {
571
589
  return customInstance<GetAdminHome200>({ url: `/admin-home/`, method: 'GET' }, options);
572
590
  };
573
591
 
592
+ /**
593
+ * Update fileUploadSetting
594
+ * @summary /app-settings/file-upload-setting
595
+ */
596
+ const putFileUploadSettingsForAppSettings = (fileUploadSettingParams: FileUploadSettingParams, options?: SecondParameter<typeof customInstance>) => {
597
+ return customInstance<PutFileUploadSettingsForAppSettings200>(
598
+ { url: `/app-settings/file-upload-settings`, method: 'PUT', headers: { 'Content-Type': 'application/json' }, data: fileUploadSettingParams },
599
+ options,
600
+ );
601
+ };
602
+
574
603
  /**
575
604
  * get app setting params
576
605
  * @summary /app-settings
@@ -632,12 +661,15 @@ export const getGrowirestapiv3 = () => {
632
661
  };
633
662
 
634
663
  /**
635
- * Update fileUploadSetting
636
- * @summary /app-settings/file-upload-setting
664
+ * Update OAuth 2.0 setting for email
665
+ * @summary /app-settings/oauth2-setting
637
666
  */
638
- const putFileUploadSettingsForAppSettings = (fileUploadSettingParams: FileUploadSettingParams, options?: SecondParameter<typeof customInstance>) => {
639
- return customInstance<PutFileUploadSettingsForAppSettings200>(
640
- { url: `/app-settings/file-upload-settings`, method: 'PUT', headers: { 'Content-Type': 'application/json' }, data: fileUploadSettingParams },
667
+ const putOauth2SettingForAppSettings = (
668
+ putOauth2SettingForAppSettingsBody: PutOauth2SettingForAppSettingsBody,
669
+ options?: SecondParameter<typeof customInstance>,
670
+ ) => {
671
+ return customInstance<PutOauth2SettingForAppSettings200>(
672
+ { url: `/app-settings/oauth2-setting`, method: 'PUT', headers: { 'Content-Type': 'application/json' }, data: putOauth2SettingForAppSettingsBody },
641
673
  options,
642
674
  );
643
675
  };
@@ -792,6 +824,20 @@ export const getGrowirestapiv3 = () => {
792
824
  );
793
825
  };
794
826
 
827
+ /**
828
+ * @summary Replace content disposition settings for configurable MIME types with recieved lists.
829
+ */
830
+ const putContentDispositionSettings = (options?: SecondParameter<typeof customInstance>) => {
831
+ return customInstance<PutContentDispositionSettings200>({ url: `/content-disposition-settings/`, method: 'PUT' }, options);
832
+ };
833
+
834
+ /**
835
+ * @summary Get content disposition settings for configurable MIME types
836
+ */
837
+ const getContentDispositionSettings = (options?: SecondParameter<typeof customInstance>) => {
838
+ return customInstance<GetContentDispositionSettings200>({ url: `/content-disposition-settings`, method: 'GET' }, options);
839
+ };
840
+
795
841
  /**
796
842
  * Get customize parameters
797
843
  * @summary /customize-setting
@@ -1110,11 +1156,11 @@ export const getGrowirestapiv3 = () => {
1110
1156
  };
1111
1157
 
1112
1158
  /**
1113
- * Get import settings params
1114
- * @summary /import
1159
+ * Get properties of stored zip files for import
1160
+ * @summary /import/status
1115
1161
  */
1116
- const getImport = (options?: SecondParameter<typeof customInstance>) => {
1117
- return customInstance<GetImport200>({ url: `/import`, method: 'GET' }, options);
1162
+ const getStatusForImport = (options?: SecondParameter<typeof customInstance>) => {
1163
+ return customInstance<GetStatusForImport200>({ url: `/import/status`, method: 'GET' }, options);
1118
1164
  };
1119
1165
 
1120
1166
  /**
@@ -1125,14 +1171,6 @@ export const getGrowirestapiv3 = () => {
1125
1171
  return customInstance<void>({ url: `/import`, method: 'POST', headers: { 'Content-Type': 'application/json' }, data: postImportBody }, options);
1126
1172
  };
1127
1173
 
1128
- /**
1129
- * Get properties of stored zip files for import
1130
- * @summary /import/status
1131
- */
1132
- const getStatusForImport = (options?: SecondParameter<typeof customInstance>) => {
1133
- return customInstance<GetStatusForImport200>({ url: `/import/status`, method: 'GET' }, options);
1134
- };
1135
-
1136
1174
  /**
1137
1175
  * upload a zip file
1138
1176
  * @summary /import/upload
@@ -1378,14 +1416,6 @@ export const getGrowirestapiv3 = () => {
1378
1416
  return customInstance<GetRootForPageListing200>({ url: `/page-listing/root`, method: 'GET' }, options);
1379
1417
  };
1380
1418
 
1381
- /**
1382
- * Get the ancestors and children of a page
1383
- * @summary /page-listing/ancestors-children
1384
- */
1385
- const getAncestorsChildrenForPageListing = (params: GetAncestorsChildrenForPageListingParams, options?: SecondParameter<typeof customInstance>) => {
1386
- return customInstance<GetAncestorsChildrenForPageListing200>({ url: `/page-listing/ancestors-children`, method: 'GET', params }, options);
1387
- };
1388
-
1389
1419
  /**
1390
1420
  * Get the children of a page
1391
1421
  * @summary /page-listing/children
@@ -1403,11 +1433,35 @@ export const getGrowirestapiv3 = () => {
1403
1433
  };
1404
1434
 
1405
1435
  /**
1406
- * get page by pagePath or pageId
1436
+ * Get a single page item for tree display
1437
+ * @summary /page-listing/item
1438
+ */
1439
+ const getItemForPageListing = (params: GetItemForPageListingParams, options?: SecondParameter<typeof customInstance>) => {
1440
+ return customInstance<GetItemForPageListing200>({ url: `/page-listing/item`, method: 'GET', params }, options);
1441
+ };
1442
+
1443
+ /**
1444
+ * Get page data via a valid share link (public endpoint, no authentication required)
1445
+ * @summary Get page by share link
1446
+ */
1447
+ const getSharedForPage = (params: GetSharedForPageParams, options?: SecondParameter<typeof customInstance>) => {
1448
+ return customInstance<GetPageResponse>({ url: `/page/shared`, method: 'GET', params }, options);
1449
+ };
1450
+
1451
+ /**
1452
+ * Get summary informations for a page
1453
+ * @summary /page/info
1454
+ */
1455
+ const getInfoForPage = (params: GetInfoForPageParams, options?: SecondParameter<typeof customInstance>) => {
1456
+ return customInstance<PageInfoExt>({ url: `/page/info`, method: 'GET', params }, options);
1457
+ };
1458
+
1459
+ /**
1460
+ * Get page by pagePath or pageId. Returns a single page or multiple pages based on parameters.
1407
1461
  * @summary Get page
1408
1462
  */
1409
1463
  const getPage = (params?: GetPageParams, options?: SecondParameter<typeof customInstance>) => {
1410
- return customInstance<Page>({ url: `/page`, method: 'GET', params }, options);
1464
+ return customInstance<GetPageResponse>({ url: `/page`, method: 'GET', params }, options);
1411
1465
  };
1412
1466
 
1413
1467
  /**
@@ -1441,14 +1495,6 @@ export const getGrowirestapiv3 = () => {
1441
1495
  return customInstance<Page>({ url: `/page/likes`, method: 'PUT', headers: { 'Content-Type': 'application/json' }, data: likeParams }, options);
1442
1496
  };
1443
1497
 
1444
- /**
1445
- * Get summary informations for a page
1446
- * @summary /page/info
1447
- */
1448
- const getInfoForPage = (params: GetInfoForPageParams, options?: SecondParameter<typeof customInstance>) => {
1449
- return customInstance<PageInfoAll>({ url: `/page/info`, method: 'GET', params }, options);
1450
- };
1451
-
1452
1498
  /**
1453
1499
  * Retrieve current page's grant data
1454
1500
  * @summary Get page grant data
@@ -2775,18 +2821,20 @@ export const getGrowirestapiv3 = () => {
2775
2821
  getTemplates,
2776
2822
  getPresetTemplatesByLocaleByTemplateIdForTemplates,
2777
2823
  getPluginTemplatesByLocaleByTemplateIdByReposIdByOrganizationIdForTemplates,
2824
+ postSuggestPathForAiTools,
2778
2825
  postPlugins,
2779
2826
  putActivateByIdForPlugins,
2780
2827
  deleteRemoveByIdForPlugins,
2781
2828
  getActivity,
2782
2829
  getAdminHome,
2830
+ putFileUploadSettingsForAppSettings,
2783
2831
  getAppSettings,
2784
2832
  putAppSettingForAppSettings,
2785
2833
  putSiteUrlSettingForAppSettings,
2786
2834
  putSmtpSettingForAppSettings,
2787
2835
  postSmtpTestForAppSettings,
2788
2836
  putSesSettingForAppSettings,
2789
- putFileUploadSettingsForAppSettings,
2837
+ putOauth2SettingForAppSettings,
2790
2838
  postV5SchemaMigrationForAppSettings,
2791
2839
  postMaintenanceModeForAppSettings,
2792
2840
  getListForAttachment,
@@ -2802,6 +2850,8 @@ export const getGrowirestapiv3 = () => {
2802
2850
  getInfoForBookmarks,
2803
2851
  getBookmarksByUserId,
2804
2852
  putBookmarks,
2853
+ putContentDispositionSettings,
2854
+ getContentDispositionSettings,
2805
2855
  getCustomizeSetting,
2806
2856
  getLayoutForCustomizeSetting,
2807
2857
  putLayoutForCustomizeSetting,
@@ -2831,9 +2881,8 @@ export const getGrowirestapiv3 = () => {
2831
2881
  postGenerateKeyForG2gTransfer,
2832
2882
  postTransferForG2gTransfer,
2833
2883
  getHealthcheck,
2834
- getImport,
2835
- postImport,
2836
2884
  getStatusForImport,
2885
+ postImport,
2837
2886
  postUploadForImport,
2838
2887
  deleteAllForImport,
2839
2888
  getListForInAppNotification,
@@ -2858,15 +2907,16 @@ export const getGrowirestapiv3 = () => {
2858
2907
  putNotifyForPageGrantForNotificationSetting,
2859
2908
  putEnabledByIdForNotificationSettingGlobalNotification,
2860
2909
  getRootForPageListing,
2861
- getAncestorsChildrenForPageListing,
2862
2910
  getChildrenForPageListing,
2863
2911
  getInfoForPageListing,
2912
+ getItemForPageListing,
2913
+ getSharedForPage,
2914
+ getInfoForPage,
2864
2915
  getPage,
2865
2916
  postPage,
2866
2917
  putPage,
2867
2918
  getExistForPage,
2868
2919
  putLikesForPage,
2869
- getInfoForPage,
2870
2920
  getGrantDataForPage,
2871
2921
  getNonUserRelatedGroupsGrantedForPage,
2872
2922
  getApplicableGrantForPage,
@@ -3037,20 +3087,22 @@ export type GetPresetTemplatesByLocaleByTemplateIdForTemplatesResult = NonNullab
3037
3087
  export type GetPluginTemplatesByLocaleByTemplateIdByReposIdByOrganizationIdForTemplatesResult = NonNullable<
3038
3088
  Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getPluginTemplatesByLocaleByTemplateIdByReposIdByOrganizationIdForTemplates']>>
3039
3089
  >;
3090
+ export type PostSuggestPathForAiToolsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postSuggestPathForAiTools']>>>;
3040
3091
  export type PostPluginsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postPlugins']>>>;
3041
3092
  export type PutActivateByIdForPluginsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putActivateByIdForPlugins']>>>;
3042
3093
  export type DeleteRemoveByIdForPluginsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['deleteRemoveByIdForPlugins']>>>;
3043
3094
  export type GetActivityResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getActivity']>>>;
3044
3095
  export type GetAdminHomeResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getAdminHome']>>>;
3096
+ export type PutFileUploadSettingsForAppSettingsResult = NonNullable<
3097
+ Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putFileUploadSettingsForAppSettings']>>
3098
+ >;
3045
3099
  export type GetAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getAppSettings']>>>;
3046
3100
  export type PutAppSettingForAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putAppSettingForAppSettings']>>>;
3047
3101
  export type PutSiteUrlSettingForAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putSiteUrlSettingForAppSettings']>>>;
3048
3102
  export type PutSmtpSettingForAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putSmtpSettingForAppSettings']>>>;
3049
3103
  export type PostSmtpTestForAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postSmtpTestForAppSettings']>>>;
3050
3104
  export type PutSesSettingForAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putSesSettingForAppSettings']>>>;
3051
- export type PutFileUploadSettingsForAppSettingsResult = NonNullable<
3052
- Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putFileUploadSettingsForAppSettings']>>
3053
- >;
3105
+ export type PutOauth2SettingForAppSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putOauth2SettingForAppSettings']>>>;
3054
3106
  export type PostV5SchemaMigrationForAppSettingsResult = NonNullable<
3055
3107
  Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postV5SchemaMigrationForAppSettings']>>
3056
3108
  >;
@@ -3074,6 +3126,8 @@ export type PutUpdateBookmarkForBookmarkFolderResult = NonNullable<
3074
3126
  export type GetInfoForBookmarksResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getInfoForBookmarks']>>>;
3075
3127
  export type GetBookmarksByUserIdResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getBookmarksByUserId']>>>;
3076
3128
  export type PutBookmarksResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putBookmarks']>>>;
3129
+ export type PutContentDispositionSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putContentDispositionSettings']>>>;
3130
+ export type GetContentDispositionSettingsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getContentDispositionSettings']>>>;
3077
3131
  export type GetCustomizeSettingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getCustomizeSetting']>>>;
3078
3132
  export type GetLayoutForCustomizeSettingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getLayoutForCustomizeSetting']>>>;
3079
3133
  export type PutLayoutForCustomizeSettingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putLayoutForCustomizeSetting']>>>;
@@ -3119,9 +3173,8 @@ export type GetGrowiInfoForG2gTransferResult = NonNullable<Awaited<ReturnType<Re
3119
3173
  export type PostGenerateKeyForG2gTransferResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postGenerateKeyForG2gTransfer']>>>;
3120
3174
  export type PostTransferForG2gTransferResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postTransferForG2gTransfer']>>>;
3121
3175
  export type GetHealthcheckResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getHealthcheck']>>>;
3122
- export type GetImportResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getImport']>>>;
3123
- export type PostImportResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postImport']>>>;
3124
3176
  export type GetStatusForImportResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getStatusForImport']>>>;
3177
+ export type PostImportResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postImport']>>>;
3125
3178
  export type PostUploadForImportResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postUploadForImport']>>>;
3126
3179
  export type DeleteAllForImportResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['deleteAllForImport']>>>;
3127
3180
  export type GetListForInAppNotificationResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getListForInAppNotification']>>>;
@@ -3164,17 +3217,16 @@ export type PutEnabledByIdForNotificationSettingGlobalNotificationResult = NonNu
3164
3217
  Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putEnabledByIdForNotificationSettingGlobalNotification']>>
3165
3218
  >;
3166
3219
  export type GetRootForPageListingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getRootForPageListing']>>>;
3167
- export type GetAncestorsChildrenForPageListingResult = NonNullable<
3168
- Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getAncestorsChildrenForPageListing']>>
3169
- >;
3170
3220
  export type GetChildrenForPageListingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getChildrenForPageListing']>>>;
3171
3221
  export type GetInfoForPageListingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getInfoForPageListing']>>>;
3222
+ export type GetItemForPageListingResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getItemForPageListing']>>>;
3223
+ export type GetSharedForPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getSharedForPage']>>>;
3224
+ export type GetInfoForPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getInfoForPage']>>>;
3172
3225
  export type GetPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getPage']>>>;
3173
3226
  export type PostPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['postPage']>>>;
3174
3227
  export type PutPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putPage']>>>;
3175
3228
  export type GetExistForPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getExistForPage']>>>;
3176
3229
  export type PutLikesForPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['putLikesForPage']>>>;
3177
- export type GetInfoForPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getInfoForPage']>>>;
3178
3230
  export type GetGrantDataForPageResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getGrantDataForPage']>>>;
3179
3231
  export type GetNonUserRelatedGroupsGrantedForPageResult = NonNullable<
3180
3232
  Awaited<ReturnType<ReturnType<typeof getGrowirestapiv3>['getNonUserRelatedGroupsGrantedForPage']>>
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AXIOS_DEFAULT } from './utils/axios-default-instance.js';
1
+ export { axiosInstanceManager } from './utils/axios-instance-manager.js';
2
2
 
3
3
  export type * as Apiv1Types from './apiv1/index.js';
4
4
  export type * as Apiv3Types from './apiv3/index.js';
@@ -0,0 +1,185 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { axiosInstanceManager } from './axios-instance-manager.js';
4
+
5
+ type CapturedHeaders = {
6
+ authorization: unknown;
7
+ hasGrowiAccessToken: boolean;
8
+ growiAccessToken: unknown;
9
+ };
10
+
11
+ /**
12
+ * Fire a request through the instance and capture the fully-merged outgoing headers via a request interceptor,
13
+ * rejecting before any network call. This asserts what GROWI would actually receive, rather than poking the
14
+ * instance's internal `defaults`, so the test stays meaningful even if the header wiring changes.
15
+ */
16
+ const captureRequestHeaders = async (instance: AxiosInstance): Promise<CapturedHeaders> => {
17
+ const marker = '__captured__';
18
+ let captured: CapturedHeaders = { authorization: undefined, hasGrowiAccessToken: false, growiAccessToken: undefined };
19
+
20
+ const interceptorId = instance.interceptors.request.use((config) => {
21
+ const headers = config.headers;
22
+ captured = {
23
+ authorization: headers.get('Authorization'),
24
+ hasGrowiAccessToken: headers.has('X-GROWI-ACCESS-TOKEN'),
25
+ growiAccessToken: headers.get('X-GROWI-ACCESS-TOKEN'),
26
+ };
27
+ return Promise.reject(new Error(marker));
28
+ });
29
+
30
+ try {
31
+ await instance.get('/probe');
32
+ } catch (error) {
33
+ if (!(error instanceof Error) || error.message !== marker) throw error;
34
+ } finally {
35
+ instance.interceptors.request.eject(interceptorId);
36
+ }
37
+
38
+ return captured;
39
+ };
40
+
41
+ describe('AxiosInstanceManager', () => {
42
+ describe('addAxiosInstance', () => {
43
+ it('sends a Bearer Authorization header and no GROWI access token by default', async () => {
44
+ axiosInstanceManager.addAxiosInstance({
45
+ appName: 'bearer-app',
46
+ baseURL: 'https://api.example.com',
47
+ token: 'test-token-123',
48
+ });
49
+
50
+ const headers = await captureRequestHeaders(axiosInstanceManager.getAxiosInstance('bearer-app'));
51
+
52
+ expect(headers.authorization).toBe('Bearer test-token-123');
53
+ expect(headers.hasGrowiAccessToken).toBe(false);
54
+ });
55
+
56
+ it('sends the custom Authorization header and the token via X-GROWI-ACCESS-TOKEN when authorizationHeader is provided', async () => {
57
+ axiosInstanceManager.addAxiosInstance({
58
+ appName: 'custom-auth-app',
59
+ baseURL: 'https://api.example.com',
60
+ token: 'growi-token-456',
61
+ authorizationHeader: 'Custom custom-auth-value',
62
+ });
63
+
64
+ const headers = await captureRequestHeaders(axiosInstanceManager.getAxiosInstance('custom-auth-app'));
65
+
66
+ expect(headers.authorization).toBe('Custom custom-auth-value');
67
+ expect(headers.growiAccessToken).toBe('growi-token-456');
68
+ });
69
+
70
+ it('applies the configured baseURL to the instance', () => {
71
+ axiosInstanceManager.addAxiosInstance({
72
+ appName: 'baseurl-app',
73
+ baseURL: 'https://api.example.com',
74
+ token: 'test-token',
75
+ });
76
+
77
+ expect(axiosInstanceManager.getAxiosInstance('baseurl-app').defaults.baseURL).toBe('https://api.example.com');
78
+ });
79
+
80
+ it('keeps instances isolated so each carries its own credentials', async () => {
81
+ axiosInstanceManager.addAxiosInstance({
82
+ appName: 'multi-1',
83
+ baseURL: 'https://api1.example.com',
84
+ token: 'token1',
85
+ });
86
+ axiosInstanceManager.addAxiosInstance({
87
+ appName: 'multi-2',
88
+ baseURL: 'https://api2.example.com',
89
+ token: 'token2',
90
+ authorizationHeader: 'Bearer custom-token',
91
+ });
92
+
93
+ const headers1 = await captureRequestHeaders(axiosInstanceManager.getAxiosInstance('multi-1'));
94
+ const headers2 = await captureRequestHeaders(axiosInstanceManager.getAxiosInstance('multi-2'));
95
+
96
+ expect(headers1.authorization).toBe('Bearer token1');
97
+ expect(headers1.hasGrowiAccessToken).toBe(false);
98
+ expect(headers2.authorization).toBe('Bearer custom-token');
99
+ expect(headers2.growiAccessToken).toBe('token2');
100
+ });
101
+
102
+ it('overwrites the existing instance when the same appName is reused', async () => {
103
+ axiosInstanceManager.addAxiosInstance({
104
+ appName: 'overwrite-app',
105
+ baseURL: 'https://api.example.com',
106
+ token: 'original-token',
107
+ });
108
+ axiosInstanceManager.addAxiosInstance({
109
+ appName: 'overwrite-app',
110
+ baseURL: 'https://api-updated.example.com',
111
+ token: 'updated-token',
112
+ authorizationHeader: 'Bearer updated-auth',
113
+ });
114
+
115
+ const instance = axiosInstanceManager.getAxiosInstance('overwrite-app');
116
+ const headers = await captureRequestHeaders(instance);
117
+
118
+ expect(instance.defaults.baseURL).toBe('https://api-updated.example.com');
119
+ expect(headers.authorization).toBe('Bearer updated-auth');
120
+ expect(headers.growiAccessToken).toBe('updated-token');
121
+ });
122
+
123
+ it('throws when appName is an empty string', () => {
124
+ expect(() => {
125
+ axiosInstanceManager.addAxiosInstance({ appName: '', baseURL: 'https://api.example.com', token: 'token' });
126
+ }).toThrow('appName must be a non-empty string');
127
+ });
128
+
129
+ it('throws when baseURL is an empty string', () => {
130
+ expect(() => {
131
+ axiosInstanceManager.addAxiosInstance({ appName: 'app-name', baseURL: '', token: 'token' });
132
+ }).toThrow('baseURL must be a non-empty string');
133
+ });
134
+
135
+ it('throws when token is an empty string', () => {
136
+ expect(() => {
137
+ axiosInstanceManager.addAxiosInstance({ appName: 'app-name', baseURL: 'https://api.example.com', token: '' });
138
+ }).toThrow('token must be a non-empty string');
139
+ });
140
+
141
+ it('throws when authorizationHeader is provided but empty, instead of silently falling back to Bearer', () => {
142
+ expect(() => {
143
+ axiosInstanceManager.addAxiosInstance({
144
+ appName: 'empty-auth-header',
145
+ baseURL: 'https://api.example.com',
146
+ token: 'token',
147
+ authorizationHeader: '',
148
+ });
149
+ }).toThrow('authorizationHeader must be a non-empty string when provided');
150
+ });
151
+ });
152
+
153
+ describe('getAxiosInstance', () => {
154
+ it('returns the same instance for a given appName', () => {
155
+ axiosInstanceManager.addAxiosInstance({
156
+ appName: 'stable-app',
157
+ baseURL: 'https://api.example.com',
158
+ token: 'test-token',
159
+ });
160
+
161
+ expect(axiosInstanceManager.getAxiosInstance('stable-app')).toBe(axiosInstanceManager.getAxiosInstance('stable-app'));
162
+ });
163
+
164
+ it('returns different instances for different appNames', () => {
165
+ axiosInstanceManager.addAxiosInstance({
166
+ appName: 'distinct-1',
167
+ baseURL: 'https://api1.example.com',
168
+ token: 'token1',
169
+ });
170
+ axiosInstanceManager.addAxiosInstance({
171
+ appName: 'distinct-2',
172
+ baseURL: 'https://api2.example.com',
173
+ token: 'token2',
174
+ });
175
+
176
+ expect(axiosInstanceManager.getAxiosInstance('distinct-1')).not.toBe(axiosInstanceManager.getAxiosInstance('distinct-2'));
177
+ });
178
+
179
+ it('throws for a non-existent appName', () => {
180
+ expect(() => {
181
+ axiosInstanceManager.getAxiosInstance('non-existent-app');
182
+ }).toThrow('No Axios instance found for appName: non-existent-app');
183
+ });
184
+ });
185
+ });
@@ -0,0 +1,61 @@
1
+ import Axios, { type AxiosRequestConfig, type AxiosInstance } from 'axios';
2
+
3
+ /**
4
+ * A singleton class for managing multiple named Axios instances.
5
+ */
6
+ class AxiosInstanceManager {
7
+ private instances: Map<string, AxiosInstance> = new Map();
8
+
9
+ /**
10
+ * Add or update a named Axios instance.
11
+ * @param config The configuration for the Axios instance.
12
+ * @param config.appName The name/key for the instance.
13
+ * @param config.baseURL The base URL of the GROWI instance.
14
+ * @param config.token The GROWI API token.
15
+ * @param config.authorizationHeader Optional custom `Authorization` header value. When provided, it must be a non-empty
16
+ * string; it overrides the default Bearer scheme and the token is sent via the `X-GROWI-ACCESS-TOKEN` header instead.
17
+ * Useful when GROWI sits behind Digest, Basic, or custom proxy authentication.
18
+ */
19
+ addAxiosInstance(config: { appName: string; baseURL: string; token: string; authorizationHeader?: string }) {
20
+ if (typeof config.appName !== 'string' || config.appName.length === 0) throw new Error('appName must be a non-empty string');
21
+ if (typeof config.baseURL !== 'string' || config.baseURL.length === 0) throw new Error('baseURL must be a non-empty string');
22
+ if (typeof config.token !== 'string' || config.token.length === 0) throw new Error('token must be a non-empty string');
23
+ // Validate authorizationHeader for parity with the required fields: when present it must be a usable header value,
24
+ // so an empty/non-string value fails loudly instead of silently falling back to the default Bearer scheme.
25
+ if (config.authorizationHeader !== undefined && (typeof config.authorizationHeader !== 'string' || config.authorizationHeader.length === 0)) {
26
+ throw new Error('authorizationHeader must be a non-empty string when provided');
27
+ }
28
+
29
+ const axiosInstance = Axios.create({
30
+ baseURL: config.baseURL,
31
+ });
32
+
33
+ // Set the Authorization header. When a custom authorization header is provided (e.g. Digest/Basic/proxy auth),
34
+ // send the GROWI access token via X-GROWI-ACCESS-TOKEN instead of the default Bearer scheme.
35
+ if (config.authorizationHeader) {
36
+ axiosInstance.defaults.headers.common.Authorization = config.authorizationHeader;
37
+ axiosInstance.defaults.headers.common['X-GROWI-ACCESS-TOKEN'] = config.token;
38
+ } else {
39
+ axiosInstance.defaults.headers.common.Authorization = `Bearer ${config.token}`;
40
+ }
41
+
42
+ this.instances.set(config.appName, axiosInstance);
43
+ }
44
+
45
+ /**
46
+ * Get a named Axios instance.
47
+ * @param appName The name/key of the instance.
48
+ * @returns The AxiosInstance.
49
+ * @throws Error if no instance is found for the given appName.
50
+ */
51
+ getAxiosInstance(appName: string): AxiosInstance {
52
+ const instance = this.instances.get(appName);
53
+ if (!instance) {
54
+ throw new Error(`No Axios instance found for appName: ${appName}`);
55
+ }
56
+ return instance;
57
+ }
58
+ }
59
+
60
+ // Export singleton instance
61
+ export const axiosInstanceManager = new AxiosInstanceManager();
@@ -0,0 +1,6 @@
1
+ import type { AxiosRequestConfig } from 'axios';
2
+
3
+ export type CustomInstanceOptions = {
4
+ appName?: string;
5
+ axiosOptions?: AxiosRequestConfig;
6
+ };