@keboola/api-client 27.0.0 → 31.0.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.
- package/AGENTS.md +145 -11
- package/API-SURFACE.md +13 -1
- package/CHANGELOG.md +1785 -0
- package/README.md +53 -18
- package/dist/ManagementClientAuthError-90pvsej0.js +15 -0
- package/dist/ManagementClientAuthError-90pvsej0.js.map +1 -0
- package/dist/ManagementClientAuthError-DFhi5yxe.cjs +20 -0
- package/dist/ManagementClientAuthError-DFhi5yxe.cjs.map +1 -0
- package/dist/QueryJobTimeoutError-C7JbNGOM.js +38 -0
- package/dist/QueryJobTimeoutError-C7JbNGOM.js.map +1 -0
- package/dist/QueryJobTimeoutError-CVNPdCWX.cjs +61 -0
- package/dist/QueryJobTimeoutError-CVNPdCWX.cjs.map +1 -0
- package/dist/SyncActionError-BG0zwchi.cjs +35 -0
- package/dist/SyncActionError-BG0zwchi.cjs.map +1 -0
- package/dist/SyncActionError-CoZFsdUk.js +24 -0
- package/dist/SyncActionError-CoZFsdUk.js.map +1 -0
- package/dist/UserError-By_Zckmc.js +10 -0
- package/dist/UserError-By_Zckmc.js.map +1 -0
- package/dist/UserError-CSGO1qII.cjs +15 -0
- package/dist/UserError-CSGO1qII.cjs.map +1 -0
- package/dist/ValidationError-CzPWydEb.js +44 -0
- package/dist/ValidationError-CzPWydEb.js.map +1 -0
- package/dist/ValidationError-h5qvwahi.cjs +61 -0
- package/dist/ValidationError-h5qvwahi.cjs.map +1 -0
- package/dist/adminRoles-B40yBcmq.js +14 -0
- package/dist/adminRoles-B40yBcmq.js.map +1 -0
- package/dist/adminRoles-C696kD_U.d.cts +14 -0
- package/dist/adminRoles-C696kD_U.d.ts +14 -0
- package/dist/adminRoles-CO7J5qAy.cjs +19 -0
- package/dist/adminRoles-CO7J5qAy.cjs.map +1 -0
- package/dist/ai/index.cjs +62 -12
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +52 -53
- package/dist/ai/index.d.ts +52 -53
- package/dist/ai/index.js +62 -4
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/types.cjs +0 -4
- package/dist/ai/types.d.cts +2 -2
- package/dist/ai/types.d.ts +2 -2
- package/dist/ai/types.js +1 -3
- package/dist/appLogs-BCCi02w6.cjs +153 -0
- package/dist/appLogs-BCCi02w6.cjs.map +1 -0
- package/dist/appLogs-BdMG6Cvn.d.ts +10 -0
- package/dist/appLogs-CLHhkQJn.js +132 -0
- package/dist/appLogs-CLHhkQJn.js.map +1 -0
- package/dist/appLogs-hQdKt_8J.d.cts +10 -0
- package/dist/apps/index.cjs +229 -14
- package/dist/apps/index.cjs.map +1 -1
- package/dist/apps/index.d.cts +219 -220
- package/dist/apps/index.d.ts +219 -220
- package/dist/apps/index.js +229 -6
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/types.cjs +0 -4
- package/dist/apps/types.d.cts +3 -3
- package/dist/apps/types.d.ts +3 -3
- package/dist/apps/types.js +1 -3
- package/dist/assets/index.cjs +33 -38
- package/dist/assets/index.cjs.map +1 -1
- package/dist/assets/index.d.cts +22 -22
- package/dist/assets/index.d.ts +22 -22
- package/dist/assets/index.js +32 -36
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/schema.cjs +23 -13
- package/dist/assets/schema.cjs.map +1 -1
- package/dist/assets/schema.d.cts +29 -28
- package/dist/assets/schema.d.ts +29 -28
- package/dist/assets/schema.js +21 -2
- package/dist/assets/schema.js.map +1 -1
- package/dist/auth/index.cjs +15 -57
- package/dist/auth/index.d.cts +2 -318
- package/dist/auth/index.d.ts +2 -318
- package/dist/auth/index.js +2 -4
- package/dist/auth/types.cjs +0 -4
- package/dist/auth/types.d.cts +2 -7
- package/dist/auth/types.d.ts +2 -7
- package/dist/auth/types.js +1 -3
- package/dist/auth-CE6Hlc9W.js +13 -0
- package/dist/{chunk-5A3AQIXR.js.map → auth-CE6Hlc9W.js.map} +1 -1
- package/dist/auth-DmgTH0uY.cjs +18 -0
- package/dist/auth-DmgTH0uY.cjs.map +1 -0
- package/dist/authClient-BL6h78Q1.d.cts +367 -0
- package/dist/authClient-Bc_bDisO.d.ts +367 -0
- package/dist/authClient-Cixa8_L1.cjs +476 -0
- package/dist/authClient-Cixa8_L1.cjs.map +1 -0
- package/dist/authClient-XBAUz9g-.js +397 -0
- package/dist/authClient-XBAUz9g-.js.map +1 -0
- package/dist/backends-DKBz5OxE.d.cts +9 -0
- package/dist/backends-DKBz5OxE.d.ts +9 -0
- package/dist/chat/index.cjs +134 -13
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +49 -51
- package/dist/chat/index.d.ts +49 -51
- package/dist/chat/index.js +134 -5
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/suggestions.cjs +152 -74
- package/dist/chat/suggestions.cjs.map +1 -1
- package/dist/chat/suggestions.d.cts +2 -437
- package/dist/chat/suggestions.d.ts +2 -437
- package/dist/chat/suggestions.js +136 -2
- package/dist/chat/suggestions.js.map +1 -1
- package/dist/chat/types.cjs +6 -8
- package/dist/chat/types.cjs.map +1 -1
- package/dist/chat/types.d.cts +2 -3
- package/dist/chat/types.d.ts +2 -3
- package/dist/chat/types.js +5 -6
- package/dist/chat/types.js.map +1 -1
- package/dist/componentId-DkyQ8PM0.cjs +73 -0
- package/dist/componentId-DkyQ8PM0.cjs.map +1 -0
- package/dist/componentId-vJz-kWs6.js +68 -0
- package/dist/componentId-vJz-kWs6.js.map +1 -0
- package/dist/concurrent-CH9fbNr3.js +34 -0
- package/dist/concurrent-CH9fbNr3.js.map +1 -0
- package/dist/concurrent-tbiIa0UL.cjs +39 -0
- package/dist/concurrent-tbiIa0UL.cjs.map +1 -0
- package/dist/configurations-Byt59bIa.js +726 -0
- package/dist/configurations-Byt59bIa.js.map +1 -0
- package/dist/configurations-CujCwDcB.cjs +743 -0
- package/dist/configurations-CujCwDcB.cjs.map +1 -0
- package/dist/configurations-DCOJONZZ.cjs +313 -0
- package/dist/configurations-DCOJONZZ.cjs.map +1 -0
- package/dist/configurations-iCbhe0tb.js +158 -0
- package/dist/configurations-iCbhe0tb.js.map +1 -0
- package/dist/constants/index.cjs +12 -34
- package/dist/constants/index.d.cts +4 -104
- package/dist/constants/index.d.ts +4 -104
- package/dist/constants/index.js +4 -5
- package/dist/constants-CkAVvuUq.cjs +219 -0
- package/dist/constants-CkAVvuUq.cjs.map +1 -0
- package/dist/constants-qeWGfk_7.js +184 -0
- package/dist/constants-qeWGfk_7.js.map +1 -0
- package/dist/createFetchClient-B1h3-p65.js +192 -0
- package/dist/createFetchClient-B1h3-p65.js.map +1 -0
- package/dist/createFetchClient-B9Cv0W9f.cjs +277 -0
- package/dist/createFetchClient-B9Cv0W9f.cjs.map +1 -0
- package/dist/createGenericFetchClient-BWoSkTki.cjs +12 -0
- package/dist/createGenericFetchClient-BWoSkTki.cjs.map +1 -0
- package/dist/createGenericFetchClient-DhpvUSlX.js +7 -0
- package/dist/createGenericFetchClient-DhpvUSlX.js.map +1 -0
- package/dist/createOpenapiFetchClient-0_oqhdPv.js +7 -0
- package/dist/createOpenapiFetchClient-0_oqhdPv.js.map +1 -0
- package/dist/createOpenapiFetchClient-yirrW6Tg.cjs +12 -0
- package/dist/createOpenapiFetchClient-yirrW6Tg.cjs.map +1 -0
- package/dist/createStore-BNiCRQXa.js +148 -0
- package/dist/createStore-BNiCRQXa.js.map +1 -0
- package/dist/createStore-MQbboXcB.cjs +177 -0
- package/dist/createStore-MQbboXcB.cjs.map +1 -0
- package/dist/credential-D-tX9gP4.cjs +44 -0
- package/dist/credential-D-tX9gP4.cjs.map +1 -0
- package/dist/credential-dKxArMic.js +33 -0
- package/dist/credential-dKxArMic.js.map +1 -0
- package/dist/dataScience/index.cjs +5 -20
- package/dist/dataScience/index.d.cts +3 -209
- package/dist/dataScience/index.d.ts +3 -209
- package/dist/dataScience/index.js +3 -7
- package/dist/dataScience/types.cjs +0 -4
- package/dist/dataScience/types.d.cts +3 -2172
- package/dist/dataScience/types.d.ts +3 -2172
- package/dist/dataScience/types.js +1 -3
- package/dist/dataScience-BqNWX-Gr.cjs +114 -0
- package/dist/dataScience-BqNWX-Gr.cjs.map +1 -0
- package/dist/dataScience-jdbSSPYF.js +109 -0
- package/dist/dataScience-jdbSSPYF.js.map +1 -0
- package/dist/dedupe-CiskLkGR.cjs +30 -0
- package/dist/dedupe-CiskLkGR.cjs.map +1 -0
- package/dist/dedupe-DYIHgZoG.js +25 -0
- package/dist/dedupe-DYIHgZoG.js.map +1 -0
- package/dist/developerPortal/index.cjs +6 -0
- package/dist/developerPortal/index.d.cts +3 -0
- package/dist/developerPortal/index.d.ts +3 -0
- package/dist/developerPortal/index.js +2 -0
- package/dist/developerPortal/types.cjs +0 -0
- package/dist/developerPortal/types.d.cts +2 -0
- package/dist/developerPortal/types.d.ts +2 -0
- package/dist/developerPortal/types.js +1 -0
- package/dist/developerPortalClient-5ABcxz1U.js +485 -0
- package/dist/developerPortalClient-5ABcxz1U.js.map +1 -0
- package/dist/developerPortalClient-B7lNR5q0.cjs +508 -0
- package/dist/developerPortalClient-B7lNR5q0.cjs.map +1 -0
- package/dist/domain/permissions/index.cjs +31 -122
- package/dist/domain/permissions/index.d.cts +19 -52
- package/dist/domain/permissions/index.d.ts +19 -52
- package/dist/domain/permissions/index.js +3 -5
- package/dist/domain/storageTable/index.cjs +4 -16
- package/dist/domain/storageTable/index.d.cts +2 -131
- package/dist/domain/storageTable/index.d.ts +2 -131
- package/dist/domain/storageTable/index.js +2 -3
- package/dist/editor/index.cjs +96 -12
- package/dist/editor/index.cjs.map +1 -1
- package/dist/editor/index.d.cts +163 -164
- package/dist/editor/index.d.ts +163 -164
- package/dist/editor/index.js +96 -4
- package/dist/editor/index.js.map +1 -1
- package/dist/editor/types.cjs +0 -4
- package/dist/editor/types.d.cts +2 -2
- package/dist/editor/types.d.ts +2 -2
- package/dist/editor/types.js +1 -3
- package/dist/encryption/index.cjs +58 -11
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +2 -20
- package/dist/encryption/index.d.ts +2 -20
- package/dist/encryption/index.js +58 -3
- package/dist/encryption/index.js.map +1 -1
- package/dist/encryption/types.cjs +0 -4
- package/dist/encryption/types.d.cts +2 -69
- package/dist/encryption/types.d.ts +2 -69
- package/dist/encryption/types.js +1 -3
- package/dist/generateUUID-C6qKBPIv.cjs +11 -0
- package/dist/generateUUID-C6qKBPIv.cjs.map +1 -0
- package/dist/generateUUID-Dr8l-aoc.js +6 -0
- package/dist/generateUUID-Dr8l-aoc.js.map +1 -0
- package/dist/import/index.cjs +3 -14
- package/dist/import/index.d.cts +41 -41
- package/dist/import/index.d.ts +41 -41
- package/dist/import/index.js +2 -5
- package/dist/import-CExRbskw.js +116 -0
- package/dist/import-CExRbskw.js.map +1 -0
- package/dist/import-CXHppAxd.cjs +121 -0
- package/dist/import-CXHppAxd.cjs.map +1 -0
- package/dist/index--pxLseaw.d.cts +125 -0
- package/dist/index--pxLseaw.d.ts +125 -0
- package/dist/index-7RvXnXmd.d.ts +77 -0
- package/dist/index-B-frWtGW.d.cts +235 -0
- package/dist/index-B6q7HxKJ.d.cts +1075 -0
- package/dist/index-BMqLPS6S.d.cts +135 -0
- package/dist/index-BMqLPS6S.d.ts +135 -0
- package/dist/index-BR2Fu-Wo.d.ts +19883 -0
- package/dist/index-BSjfVDTr.d.cts +208 -0
- package/dist/index-BfVv8isU.d.cts +1388 -0
- package/dist/index-C9mAoXF6.d.cts +77 -0
- package/dist/index-CMb0ygwb.d.ts +26 -0
- package/dist/index-CR9LsDaG.d.cts +65 -0
- package/dist/index-CW4VC9oN.d.ts +65 -0
- package/dist/index-CYMAwD3E.d.ts +1388 -0
- package/dist/index-Cpjh05sx.d.cts +31 -0
- package/dist/index-CwJE18PJ.d.cts +26 -0
- package/dist/index-D_TnbEtp.d.cts +16 -0
- package/dist/index-Daks5CeX.d.ts +31 -0
- package/dist/index-DeMDxHTz.d.ts +1075 -0
- package/dist/index-Ds8e0l7-.d.ts +235 -0
- package/dist/index-J1I2HlSm.d.ts +208 -0
- package/dist/index-NC1dXRTD.d.cts +40 -0
- package/dist/index-NC1dXRTD.d.ts +40 -0
- package/dist/index-NicJZIzu.d.ts +16 -0
- package/dist/index-cu8THqZV.d.cts +19883 -0
- package/dist/index.cjs +1735 -1884
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -15778
- package/dist/index.d.ts +7 -15778
- package/dist/index.js +1683 -1724
- package/dist/index.js.map +1 -1
- package/dist/isPlainObject-BB3iy87C.cjs +16 -0
- package/dist/isPlainObject-BB3iy87C.cjs.map +1 -0
- package/dist/isPlainObject-LYW-03uB.js +11 -0
- package/dist/isPlainObject-LYW-03uB.js.map +1 -0
- package/dist/jobStatus-DbMupQEK.js +423 -0
- package/dist/jobStatus-DbMupQEK.js.map +1 -0
- package/dist/jobStatus-kQ9JqF8t.cjs +494 -0
- package/dist/jobStatus-kQ9JqF8t.cjs.map +1 -0
- package/dist/management/index.cjs +4 -18
- package/dist/management/index.d.cts +2 -1076
- package/dist/management/index.d.ts +2 -1076
- package/dist/management/index.js +2 -5
- package/dist/management/types.cjs +0 -4
- package/dist/management/types.d.cts +2 -12
- package/dist/management/types.d.ts +2 -12
- package/dist/management/types.js +1 -3
- package/dist/management-Cc8mKfnf.js +1064 -0
- package/dist/management-Cc8mKfnf.js.map +1 -0
- package/dist/management-DlVdxzPw.cjs +1075 -0
- package/dist/management-DlVdxzPw.cjs.map +1 -0
- package/dist/metastore/index.cjs +3 -14
- package/dist/metastore/index.d.cts +2 -32
- package/dist/metastore/index.d.ts +2 -32
- package/dist/metastore/index.js +2 -5
- package/dist/metastore/types.cjs +0 -4
- package/dist/metastore/types.d.cts +2 -2
- package/dist/metastore/types.d.ts +2 -2
- package/dist/metastore/types.js +1 -3
- package/dist/metastore-CNf1412Z.js +134 -0
- package/dist/metastore-CNf1412Z.js.map +1 -0
- package/dist/metastore-DbsxqjhS.cjs +139 -0
- package/dist/metastore-DbsxqjhS.cjs.map +1 -0
- package/dist/notifications/index.cjs +67 -13
- package/dist/notifications/index.cjs.map +1 -1
- package/dist/notifications/index.d.cts +56 -57
- package/dist/notifications/index.d.ts +56 -57
- package/dist/notifications/index.js +67 -5
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/types.cjs +0 -4
- package/dist/notifications/types.d.cts +2 -2
- package/dist/notifications/types.d.ts +2 -2
- package/dist/notifications/types.js +1 -3
- package/dist/oauth/index.cjs +3 -14
- package/dist/oauth/index.d.cts +49 -50
- package/dist/oauth/index.d.ts +49 -50
- package/dist/oauth/index.js +2 -5
- package/dist/oauth/types.cjs +0 -4
- package/dist/oauth/types.d.cts +2 -725
- package/dist/oauth/types.d.ts +2 -725
- package/dist/oauth/types.js +1 -3
- package/dist/oauth-ClksaYRY.js +83 -0
- package/dist/oauth-ClksaYRY.js.map +1 -0
- package/dist/oauth-DsZgmtPj.cjs +88 -0
- package/dist/oauth-DsZgmtPj.cjs.map +1 -0
- package/dist/omnisearch/index.cjs +47 -12
- package/dist/omnisearch/index.cjs.map +1 -1
- package/dist/omnisearch/index.d.cts +12 -14
- package/dist/omnisearch/index.d.ts +12 -14
- package/dist/omnisearch/index.js +47 -4
- package/dist/omnisearch/index.js.map +1 -1
- package/dist/omnisearch/types.cjs +0 -4
- package/dist/omnisearch/types.d.cts +2 -3
- package/dist/omnisearch/types.d.ts +2 -3
- package/dist/omnisearch/types.js +1 -3
- package/dist/project-5SLw86eZ.d.ts +18 -0
- package/dist/project-BvFi19K_.cjs +56 -0
- package/dist/project-BvFi19K_.cjs.map +1 -0
- package/dist/project-CRrsxSAK.d.cts +18 -0
- package/dist/project-DWwZv66D.js +39 -0
- package/dist/project-DWwZv66D.js.map +1 -0
- package/dist/queryService/index.cjs +3 -14
- package/dist/queryService/index.d.cts +2 -40
- package/dist/queryService/index.d.ts +2 -40
- package/dist/queryService/index.js +2 -5
- package/dist/queryService/types.cjs +0 -4
- package/dist/queryService/types.d.cts +2 -2
- package/dist/queryService/types.d.ts +2 -2
- package/dist/queryService/types.js +1 -3
- package/dist/queryService-BlyAcBxP.js +114 -0
- package/dist/queryService-BlyAcBxP.js.map +1 -0
- package/dist/queryService-DxUUkTcy.cjs +119 -0
- package/dist/queryService-DxUUkTcy.cjs.map +1 -0
- package/dist/queue/index.cjs +3 -15
- package/dist/queue/index.d.cts +411 -340
- package/dist/queue/index.d.ts +411 -340
- package/dist/queue/index.js +2 -6
- package/dist/queue/types.cjs +0 -4
- package/dist/queue/types.d.cts +2 -2
- package/dist/queue/types.d.ts +2 -2
- package/dist/queue/types.js +1 -3
- package/dist/queue-CpcqeMPz.cjs +137 -0
- package/dist/queue-CpcqeMPz.cjs.map +1 -0
- package/dist/queue-DpZTm7U7.js +126 -0
- package/dist/queue-DpZTm7U7.js.map +1 -0
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/scheduler/index.cjs +61 -13
- package/dist/scheduler/index.cjs.map +1 -1
- package/dist/scheduler/index.d.cts +73 -74
- package/dist/scheduler/index.d.ts +73 -74
- package/dist/scheduler/index.js +61 -5
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/types.cjs +0 -4
- package/dist/scheduler/types.d.cts +2 -372
- package/dist/scheduler/types.d.ts +2 -372
- package/dist/scheduler/types.js +1 -3
- package/dist/sdk/configurations/index.cjs +3 -16
- package/dist/sdk/configurations/index.d.cts +3066 -3078
- package/dist/sdk/configurations/index.d.ts +3066 -3078
- package/dist/sdk/configurations/index.js +2 -7
- package/dist/sdk/developerPortal/index.cjs +203 -0
- package/dist/sdk/developerPortal/index.cjs.map +1 -0
- package/dist/sdk/developerPortal/index.d.cts +1371 -0
- package/dist/sdk/developerPortal/index.d.ts +1371 -0
- package/dist/sdk/developerPortal/index.js +202 -0
- package/dist/sdk/developerPortal/index.js.map +1 -0
- package/dist/sdk/queryService/index.cjs +91 -14
- package/dist/sdk/queryService/index.cjs.map +1 -1
- package/dist/sdk/queryService/index.d.cts +2 -35
- package/dist/sdk/queryService/index.d.ts +2 -35
- package/dist/sdk/queryService/index.js +91 -6
- package/dist/sdk/queryService/index.js.map +1 -1
- package/dist/sdk/semanticLayer/index.cjs +352 -54
- package/dist/sdk/semanticLayer/index.cjs.map +1 -1
- package/dist/sdk/semanticLayer/index.d.cts +95 -99
- package/dist/sdk/semanticLayer/index.d.ts +95 -99
- package/dist/sdk/semanticLayer/index.js +346 -4
- package/dist/sdk/semanticLayer/index.js.map +1 -1
- package/dist/sdk/semanticLayer/types.cjs +0 -4
- package/dist/sdk/semanticLayer/types.d.cts +2 -152
- package/dist/sdk/semanticLayer/types.d.ts +2 -152
- package/dist/sdk/semanticLayer/types.js +1 -3
- package/dist/sdk/storage/index.cjs +267 -48
- package/dist/sdk/storage/index.cjs.map +1 -1
- package/dist/sdk/storage/index.d.cts +2 -120
- package/dist/sdk/storage/index.d.ts +2 -120
- package/dist/sdk/storage/index.js +258 -4
- package/dist/sdk/storage/index.js.map +1 -1
- package/dist/sdk/tag/index.cjs +3 -14
- package/dist/sdk/tag/index.d.cts +16 -20
- package/dist/sdk/tag/index.d.ts +16 -20
- package/dist/sdk/tag/index.js +2 -5
- package/dist/sdk/tag/types.cjs +0 -4
- package/dist/sdk/tag/types.d.cts +2 -36
- package/dist/sdk/tag/types.d.ts +2 -36
- package/dist/sdk/tag/types.js +1 -3
- package/dist/sdk/vault/index.cjs +93 -31
- package/dist/sdk/vault/index.cjs.map +1 -1
- package/dist/sdk/vault/index.d.cts +2 -73
- package/dist/sdk/vault/index.d.ts +2 -73
- package/dist/sdk/vault/index.js +88 -3
- package/dist/sdk/vault/index.js.map +1 -1
- package/dist/status/index.cjs +16 -20
- package/dist/status/index.cjs.map +1 -1
- package/dist/status/index.d.cts +8 -9
- package/dist/status/index.d.ts +8 -9
- package/dist/status/index.js +15 -18
- package/dist/status/index.js.map +1 -1
- package/dist/status/types.cjs +0 -6
- package/dist/status/types.d.cts +17 -15
- package/dist/status/types.d.ts +17 -15
- package/dist/status/types.js +1 -3
- package/dist/storage/index.cjs +30 -92
- package/dist/storage/index.d.cts +3 -24
- package/dist/storage/index.d.ts +3 -24
- package/dist/storage/index.js +9 -11
- package/dist/storage/types.cjs +0 -4
- package/dist/storage/types.d.cts +5 -1949
- package/dist/storage/types.d.ts +5 -1949
- package/dist/storage/types.js +1 -3
- package/dist/storage-CQxu0EY3.js +2432 -0
- package/dist/storage-CQxu0EY3.js.map +1 -0
- package/dist/storage-vnH64B_Q.cjs +2461 -0
- package/dist/storage-vnH64B_Q.cjs.map +1 -0
- package/dist/storageTable-C9crh4Ef.cjs +310 -0
- package/dist/storageTable-C9crh4Ef.cjs.map +1 -0
- package/dist/storageTable-DslXtqNL.js +299 -0
- package/dist/storageTable-DslXtqNL.js.map +1 -0
- package/dist/stream/index.cjs +363 -12
- package/dist/stream/index.cjs.map +1 -1
- package/dist/stream/index.d.cts +345 -346
- package/dist/stream/index.d.ts +345 -346
- package/dist/stream/index.js +363 -4
- package/dist/stream/index.js.map +1 -1
- package/dist/stream/types.cjs +0 -4
- package/dist/stream/types.d.cts +2 -2
- package/dist/stream/types.d.ts +2 -2
- package/dist/stream/types.js +1 -3
- package/dist/suggestions-BH3x7xU7.d.cts +438 -0
- package/dist/suggestions-BH3x7xU7.d.ts +438 -0
- package/dist/syncActions/index.cjs +3 -19
- package/dist/syncActions/index.d.cts +2 -67
- package/dist/syncActions/index.d.ts +2 -67
- package/dist/syncActions/index.js +2 -10
- package/dist/syncActions/types.cjs +0 -4
- package/dist/syncActions/types.d.cts +2 -614
- package/dist/syncActions/types.d.ts +2 -614
- package/dist/syncActions/types.js +1 -3
- package/dist/syncActions-AgFiMjRS.js +497 -0
- package/dist/syncActions-AgFiMjRS.js.map +1 -0
- package/dist/syncActions-DPcAPYgJ.cjs +504 -0
- package/dist/syncActions-DPcAPYgJ.cjs.map +1 -0
- package/dist/tag-CsoOZWB_.cjs +175 -0
- package/dist/tag-CsoOZWB_.cjs.map +1 -0
- package/dist/tag-DCsoewjL.js +164 -0
- package/dist/{chunk-WUFODWZV.js.map → tag-DCsoewjL.js.map} +1 -1
- package/dist/telemetry/index.cjs +3 -14
- package/dist/telemetry/index.d.cts +10 -10
- package/dist/telemetry/index.d.ts +10 -10
- package/dist/telemetry/index.js +2 -5
- package/dist/telemetry/types.cjs +0 -4
- package/dist/telemetry/types.d.cts +2 -12
- package/dist/telemetry/types.d.ts +2 -12
- package/dist/telemetry/types.js +1 -3
- package/dist/telemetry-BLgaYEvi.cjs +29 -0
- package/dist/telemetry-BLgaYEvi.cjs.map +1 -0
- package/dist/telemetry-CPiGWpLi.js +24 -0
- package/dist/telemetry-CPiGWpLi.js.map +1 -0
- package/dist/{types-DM1glEQI.d.ts → types-056giLrn.d.cts} +8 -10
- package/dist/types-B1S60aS2.d.ts +373 -0
- package/dist/{types-Dpwb4dD0.d.ts → types-B2Al1BNh.d.ts} +8 -13
- package/dist/types-B2El99VY.d.cts +2835 -0
- package/dist/types-BHCigZFc.d.ts +32 -0
- package/dist/{types-ebolWqn1.d.ts → types-BIAP4CYp.d.cts} +27 -16
- package/dist/types-BJLRgXw0.d.ts +726 -0
- package/dist/types-BMsK6T5k.d.ts +2835 -0
- package/dist/types-BV74LS5r.d.ts +148 -0
- package/dist/types-BXnUqdBB.d.cts +621 -0
- package/dist/{types-nt7I4XNc.d.cts → types-Bc3-a3DT.d.cts} +7 -6
- package/dist/types-BdKtW2Ml.d.cts +23 -0
- package/dist/types-Bv5vw2dc.d.cts +726 -0
- package/dist/{types-BALUbGA5.d.ts → types-BvXODdf5.d.ts} +48 -80
- package/dist/types-By47HWwB.d.cts +386 -0
- package/dist/{types-DOc5_aYZ.d.ts → types-C0bGZqFI.d.cts} +16 -21
- package/dist/types-C2p7JYQ3.d.cts +373 -0
- package/dist/types-CFhAduFK.d.cts +2162 -0
- package/dist/{types-EZBBpiFU.d.ts → types-CIJAtX8q.d.cts} +238 -349
- package/dist/types-CIybfUJ9.d.cts +66 -0
- package/dist/{types-CFeOCzzg.d.cts → types-COFrOmuO.d.ts} +27 -16
- package/dist/{types-D2qGShlS.d.ts → types-CQd9PuKY.d.cts} +31 -106
- package/dist/{types-COti0FGo.d.ts → types-CgF9R0Na.d.ts} +9 -12
- package/dist/types-Co8WobOo.d.ts +2162 -0
- package/dist/{types-D6dnnju2.d.ts → types-CuAoZH8w.d.cts} +32 -30
- package/dist/{types-BsejtGjZ.d.ts → types-Culr5v8R.d.ts} +9 -15
- package/dist/{types-Y1ynT2PH.d.cts → types-D5VvEdOv.d.ts} +31 -106
- package/dist/{types-BuEkMmKT.d.ts → types-D7YGPUsm.d.ts} +219 -234
- package/dist/types-DG_FlLJt.d.cts +2088 -0
- package/dist/{types-BcaALDYY.d.cts → types-DLazCdFR.d.cts} +9 -15
- package/dist/types-DMMMQuNt.d.ts +2088 -0
- package/dist/{types-Bp8d9PJf.d.cts → types-DN7RWWBw.d.ts} +16 -21
- package/dist/{types-DNyZ0z3L.d.cts → types-DQOOWgLt.d.cts} +219 -234
- package/dist/{types-DrGnvgkB.d.ts → types-DSBNqF1J.d.cts} +9 -14
- package/dist/{types-BCBF_5cU.d.cts → types-DWUd__fe.d.ts} +32 -30
- package/dist/types-DdeZK3BO.d.ts +386 -0
- package/dist/types-Dirp9mni.d.ts +66 -0
- package/dist/{types-CfzHhZVG.d.ts → types-DkoyCUqv.d.ts} +7 -6
- package/dist/{types-Cffam0Nw.d.ts → types-DnOGCb-p.d.cts} +105 -80
- package/dist/{types-CniF_D1P.d.cts → types-Drk7PEhk.d.ts} +8 -10
- package/dist/types-DyIKgbGB.d.ts +621 -0
- package/dist/{types-qvle4Ydu.d.cts → types-RmbvQimP.d.ts} +105 -80
- package/dist/types-SX78XZZ0.d.ts +23 -0
- package/dist/{types-cxk-0ftN.d.cts → types-X-gQF8F8.d.ts} +238 -349
- package/dist/types-ca-YNg1r.d.cts +148 -0
- package/dist/{types-CwAYn1EJ.d.cts → types-eP06LqcE.d.cts} +48 -80
- package/dist/types-lFsTSkhe.d.cts +14 -0
- package/dist/types-lFsTSkhe.d.ts +14 -0
- package/dist/{types-Bom93Zx2.d.cts → types-lVXf05pr.d.ts} +9 -14
- package/dist/types-mXM8MrYS.d.cts +32 -0
- package/dist/{types-BPKQRahf.d.cts → types-sTH4KiPc.d.cts} +8 -13
- package/dist/{types-CxAH36ip.d.cts → types-uP64XthM.d.cts} +9 -12
- package/dist/validateConnectionStatus-CBhXmvWC.js +38 -0
- package/dist/validateConnectionStatus-CBhXmvWC.js.map +1 -0
- package/dist/validateConnectionStatus-DVHXGTdi.cjs +55 -0
- package/dist/validateConnectionStatus-DVHXGTdi.cjs.map +1 -0
- package/dist/vault/index.cjs +49 -13
- package/dist/vault/index.cjs.map +1 -1
- package/dist/vault/index.d.cts +2 -27
- package/dist/vault/index.d.ts +2 -27
- package/dist/vault/index.js +49 -5
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/types.cjs +0 -4
- package/dist/vault/types.d.cts +2 -385
- package/dist/vault/types.d.ts +2 -385
- package/dist/vault/types.js +1 -3
- package/package.json +46 -7
- package/surface/apps.md +2 -2
- package/surface/auth.md +9 -2
- package/surface/chat.md +2 -2
- package/surface/dataScience.md +2 -2
- package/surface/kaiAgent.md +2 -1
- package/surface/queryService.md +4 -3
- package/surface/queue.md +2 -1
- package/surface/sdk.md +8 -8
- package/surface/storage.md +40 -35
- package/surface/syncActions.md +2 -2
- package/dist/ManagementClientAuthError-4J0S5tV-.d.ts +0 -9
- package/dist/ManagementClientAuthError-CyDpa4NS.d.cts +0 -9
- package/dist/adminRoles-BSUPLfNf.d.cts +0 -12
- package/dist/adminRoles-BSUPLfNf.d.ts +0 -12
- package/dist/ai/types.cjs.map +0 -1
- package/dist/ai/types.js.map +0 -1
- package/dist/appLogs-BbgAJ5I8.d.cts +0 -7
- package/dist/appLogs-BbgAJ5I8.d.ts +0 -7
- package/dist/apps/types.cjs.map +0 -1
- package/dist/apps/types.js.map +0 -1
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/types.cjs.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/backends-UNp_e5y9.d.cts +0 -7
- package/dist/backends-UNp_e5y9.d.ts +0 -7
- package/dist/chunk-22E6IGXR.js +0 -6
- package/dist/chunk-22E6IGXR.js.map +0 -1
- package/dist/chunk-24YVNNAG.js +0 -83
- package/dist/chunk-24YVNNAG.js.map +0 -1
- package/dist/chunk-255CHZ3U.js +0 -200
- package/dist/chunk-255CHZ3U.js.map +0 -1
- package/dist/chunk-2BCH2U57.js +0 -67
- package/dist/chunk-2BCH2U57.js.map +0 -1
- package/dist/chunk-2BQBKU6E.js +0 -270
- package/dist/chunk-2BQBKU6E.js.map +0 -1
- package/dist/chunk-2JKTV7UG.cjs +0 -35
- package/dist/chunk-2JKTV7UG.cjs.map +0 -1
- package/dist/chunk-3UBGQFBU.js +0 -29
- package/dist/chunk-3UBGQFBU.js.map +0 -1
- package/dist/chunk-4RC5E3SL.js +0 -140
- package/dist/chunk-4RC5E3SL.js.map +0 -1
- package/dist/chunk-552FC4ZV.js +0 -14
- package/dist/chunk-552FC4ZV.js.map +0 -1
- package/dist/chunk-57Q4CY4H.js +0 -190
- package/dist/chunk-57Q4CY4H.js.map +0 -1
- package/dist/chunk-5A3AQIXR.js +0 -14
- package/dist/chunk-5HEIR4DC.js +0 -39
- package/dist/chunk-5HEIR4DC.js.map +0 -1
- package/dist/chunk-5SR2L35Y.cjs +0 -1828
- package/dist/chunk-5SR2L35Y.cjs.map +0 -1
- package/dist/chunk-62LG5KPI.js +0 -285
- package/dist/chunk-62LG5KPI.js.map +0 -1
- package/dist/chunk-67P5UI6H.js +0 -58
- package/dist/chunk-67P5UI6H.js.map +0 -1
- package/dist/chunk-6PVEHUJL.cjs +0 -1308
- package/dist/chunk-6PVEHUJL.cjs.map +0 -1
- package/dist/chunk-6XFXU5N4.js +0 -119
- package/dist/chunk-6XFXU5N4.js.map +0 -1
- package/dist/chunk-6YZQIMML.cjs +0 -163
- package/dist/chunk-6YZQIMML.cjs.map +0 -1
- package/dist/chunk-6ZQBFK2Y.js +0 -24
- package/dist/chunk-6ZQBFK2Y.js.map +0 -1
- package/dist/chunk-7J2R6XHB.js +0 -3
- package/dist/chunk-7J2R6XHB.js.map +0 -1
- package/dist/chunk-AJ3SCWUB.cjs +0 -69
- package/dist/chunk-AJ3SCWUB.cjs.map +0 -1
- package/dist/chunk-AXYNFDUI.cjs +0 -43
- package/dist/chunk-AXYNFDUI.cjs.map +0 -1
- package/dist/chunk-B45B4AYG.js +0 -272
- package/dist/chunk-B45B4AYG.js.map +0 -1
- package/dist/chunk-B4T4QCLB.js +0 -116
- package/dist/chunk-B4T4QCLB.js.map +0 -1
- package/dist/chunk-BCZPCMGL.cjs +0 -49
- package/dist/chunk-BCZPCMGL.cjs.map +0 -1
- package/dist/chunk-BGJWHTBJ.js +0 -66
- package/dist/chunk-BGJWHTBJ.js.map +0 -1
- package/dist/chunk-BVRPZKRE.cjs +0 -147
- package/dist/chunk-BVRPZKRE.cjs.map +0 -1
- package/dist/chunk-BZB4UVQA.cjs +0 -192
- package/dist/chunk-BZB4UVQA.cjs.map +0 -1
- package/dist/chunk-CHRBWCL7.cjs +0 -472
- package/dist/chunk-CHRBWCL7.cjs.map +0 -1
- package/dist/chunk-CPZME73I.js +0 -16
- package/dist/chunk-CPZME73I.js.map +0 -1
- package/dist/chunk-DVV35AIS.js +0 -468
- package/dist/chunk-DVV35AIS.js.map +0 -1
- package/dist/chunk-E7GGDLAH.cjs +0 -202
- package/dist/chunk-E7GGDLAH.cjs.map +0 -1
- package/dist/chunk-EQPBR3BE.cjs +0 -85
- package/dist/chunk-EQPBR3BE.cjs.map +0 -1
- package/dist/chunk-ERZEQ5JR.js +0 -40
- package/dist/chunk-ERZEQ5JR.js.map +0 -1
- package/dist/chunk-ES3ADC2G.cjs +0 -18
- package/dist/chunk-ES3ADC2G.cjs.map +0 -1
- package/dist/chunk-EWMXK3EI.cjs +0 -8
- package/dist/chunk-EWMXK3EI.cjs.map +0 -1
- package/dist/chunk-FEAE6L3K.cjs +0 -60
- package/dist/chunk-FEAE6L3K.cjs.map +0 -1
- package/dist/chunk-FPB6OGTV.js +0 -26
- package/dist/chunk-FPB6OGTV.js.map +0 -1
- package/dist/chunk-FVU7WU2H.cjs +0 -66
- package/dist/chunk-FVU7WU2H.cjs.map +0 -1
- package/dist/chunk-FW5GBBKL.js +0 -67
- package/dist/chunk-FW5GBBKL.js.map +0 -1
- package/dist/chunk-G2SWCC3X.js +0 -90
- package/dist/chunk-G2SWCC3X.js.map +0 -1
- package/dist/chunk-G3JHVIDZ.cjs +0 -286
- package/dist/chunk-G3JHVIDZ.cjs.map +0 -1
- package/dist/chunk-G3N5KDEY.js +0 -10
- package/dist/chunk-G3N5KDEY.js.map +0 -1
- package/dist/chunk-HGKDXF35.js +0 -301
- package/dist/chunk-HGKDXF35.js.map +0 -1
- package/dist/chunk-HITKHHWN.cjs +0 -174
- package/dist/chunk-HITKHHWN.cjs.map +0 -1
- package/dist/chunk-HQO572JW.cjs +0 -34
- package/dist/chunk-HQO572JW.cjs.map +0 -1
- package/dist/chunk-HUQ5ATIL.cjs +0 -290
- package/dist/chunk-HUQ5ATIL.cjs.map +0 -1
- package/dist/chunk-HZDVMHU6.js +0 -344
- package/dist/chunk-HZDVMHU6.js.map +0 -1
- package/dist/chunk-ICWUR5WA.cjs +0 -68
- package/dist/chunk-ICWUR5WA.cjs.map +0 -1
- package/dist/chunk-IQFNHQWP.cjs +0 -47
- package/dist/chunk-IQFNHQWP.cjs.map +0 -1
- package/dist/chunk-IZ4QM7O4.js +0 -1304
- package/dist/chunk-IZ4QM7O4.js.map +0 -1
- package/dist/chunk-J5JCXSAS.cjs +0 -117
- package/dist/chunk-J5JCXSAS.cjs.map +0 -1
- package/dist/chunk-JI7HLIDL.cjs +0 -119
- package/dist/chunk-JI7HLIDL.cjs.map +0 -1
- package/dist/chunk-JWISA775.cjs +0 -92
- package/dist/chunk-JWISA775.cjs.map +0 -1
- package/dist/chunk-K3BLXPLA.cjs +0 -16
- package/dist/chunk-K3BLXPLA.cjs.map +0 -1
- package/dist/chunk-KATUDT3E.js +0 -45
- package/dist/chunk-KATUDT3E.js.map +0 -1
- package/dist/chunk-KGBWWS6I.js +0 -32
- package/dist/chunk-KGBWWS6I.js.map +0 -1
- package/dist/chunk-KQENBXPS.cjs +0 -34
- package/dist/chunk-KQENBXPS.cjs.map +0 -1
- package/dist/chunk-KTKJD4DM.js +0 -60
- package/dist/chunk-KTKJD4DM.js.map +0 -1
- package/dist/chunk-LNZP2O4P.js +0 -169
- package/dist/chunk-LNZP2O4P.js.map +0 -1
- package/dist/chunk-LWQP7OWA.js +0 -75
- package/dist/chunk-LWQP7OWA.js.map +0 -1
- package/dist/chunk-MRHQJNWF.cjs +0 -8
- package/dist/chunk-MRHQJNWF.cjs.map +0 -1
- package/dist/chunk-MSI6FVGG.js +0 -6
- package/dist/chunk-MSI6FVGG.js.map +0 -1
- package/dist/chunk-N4COL54U.cjs +0 -22
- package/dist/chunk-N4COL54U.cjs.map +0 -1
- package/dist/chunk-NFJKJGXR.js +0 -397
- package/dist/chunk-NFJKJGXR.js.map +0 -1
- package/dist/chunk-NH2TQGRL.cjs +0 -28
- package/dist/chunk-NH2TQGRL.cjs.map +0 -1
- package/dist/chunk-NHYL5QPM.js +0 -74
- package/dist/chunk-NHYL5QPM.js.map +0 -1
- package/dist/chunk-ON4ILCHP.js +0 -1822
- package/dist/chunk-ON4ILCHP.js.map +0 -1
- package/dist/chunk-PLF4JX5B.cjs +0 -155
- package/dist/chunk-PLF4JX5B.cjs.map +0 -1
- package/dist/chunk-PSR3N4NC.js +0 -136
- package/dist/chunk-PSR3N4NC.js.map +0 -1
- package/dist/chunk-QHD4LPAQ.cjs +0 -8
- package/dist/chunk-QHD4LPAQ.cjs.map +0 -1
- package/dist/chunk-QNF3L4B7.js +0 -115
- package/dist/chunk-QNF3L4B7.js.map +0 -1
- package/dist/chunk-RBN3ITTM.js +0 -153
- package/dist/chunk-RBN3ITTM.js.map +0 -1
- package/dist/chunk-RRC5RKF7.cjs +0 -12
- package/dist/chunk-RRC5RKF7.cjs.map +0 -1
- package/dist/chunk-RXYT7EMN.cjs +0 -318
- package/dist/chunk-RXYT7EMN.cjs.map +0 -1
- package/dist/chunk-S46FMY4G.cjs +0 -64
- package/dist/chunk-S46FMY4G.cjs.map +0 -1
- package/dist/chunk-S6BWQKHJ.cjs +0 -116
- package/dist/chunk-S6BWQKHJ.cjs.map +0 -1
- package/dist/chunk-SFTI6QFB.cjs +0 -85
- package/dist/chunk-SFTI6QFB.cjs.map +0 -1
- package/dist/chunk-SNP577FA.cjs +0 -346
- package/dist/chunk-SNP577FA.cjs.map +0 -1
- package/dist/chunk-SUVM3S2T.cjs +0 -69
- package/dist/chunk-SUVM3S2T.cjs.map +0 -1
- package/dist/chunk-SYZ5OFNT.js +0 -114
- package/dist/chunk-SYZ5OFNT.js.map +0 -1
- package/dist/chunk-SZBW4EE2.cjs +0 -180
- package/dist/chunk-SZBW4EE2.cjs.map +0 -1
- package/dist/chunk-T526LPBK.js +0 -6
- package/dist/chunk-T526LPBK.js.map +0 -1
- package/dist/chunk-TBHJQCAE.js +0 -64
- package/dist/chunk-TBHJQCAE.js.map +0 -1
- package/dist/chunk-U3E5YMLO.cjs +0 -82
- package/dist/chunk-U3E5YMLO.cjs.map +0 -1
- package/dist/chunk-U5SE6W5M.cjs +0 -158
- package/dist/chunk-U5SE6W5M.cjs.map +0 -1
- package/dist/chunk-UUY6LQT6.cjs +0 -267
- package/dist/chunk-UUY6LQT6.cjs.map +0 -1
- package/dist/chunk-UVX733BX.js +0 -83
- package/dist/chunk-UVX733BX.js.map +0 -1
- package/dist/chunk-V6FT3RTU.cjs +0 -42
- package/dist/chunk-V6FT3RTU.cjs.map +0 -1
- package/dist/chunk-VB56OVFM.cjs +0 -312
- package/dist/chunk-VB56OVFM.cjs.map +0 -1
- package/dist/chunk-WQ7NNIJ3.js +0 -33
- package/dist/chunk-WQ7NNIJ3.js.map +0 -1
- package/dist/chunk-WUFODWZV.js +0 -177
- package/dist/chunk-WUJ53PP7.cjs +0 -76
- package/dist/chunk-WUJ53PP7.cjs.map +0 -1
- package/dist/chunk-XPDEQND7.cjs +0 -4
- package/dist/chunk-XPDEQND7.cjs.map +0 -1
- package/dist/chunk-YDOSWWE4.cjs +0 -419
- package/dist/chunk-YDOSWWE4.cjs.map +0 -1
- package/dist/chunk-YGEJDWGG.js +0 -19
- package/dist/chunk-YGEJDWGG.js.map +0 -1
- package/dist/chunk-YXGBD4WP.cjs +0 -16
- package/dist/chunk-YXGBD4WP.cjs.map +0 -1
- package/dist/chunk-ZOREOLGE.js +0 -264
- package/dist/chunk-ZOREOLGE.js.map +0 -1
- package/dist/constants/index.cjs.map +0 -1
- package/dist/constants/index.js.map +0 -1
- package/dist/createFetchClient-BHAsPDgF.d.cts +0 -86
- package/dist/createFetchClient-CFIwc6Lh.d.ts +0 -86
- package/dist/createGenericFetchClient-JcbIIqwF.d.cts +0 -18
- package/dist/createGenericFetchClient-ZGG5wbAC.d.ts +0 -18
- package/dist/createOpenapiFetchClient-CduEua6F.d.cts +0 -24
- package/dist/createOpenapiFetchClient-wLlVgp3k.d.ts +0 -24
- package/dist/dataScience/index.cjs.map +0 -1
- package/dist/dataScience/index.js.map +0 -1
- package/dist/dataScience/types.cjs.map +0 -1
- package/dist/dataScience/types.js.map +0 -1
- package/dist/domain/permissions/index.cjs.map +0 -1
- package/dist/domain/permissions/index.js.map +0 -1
- package/dist/domain/storageTable/index.cjs.map +0 -1
- package/dist/domain/storageTable/index.js.map +0 -1
- package/dist/editor/types.cjs.map +0 -1
- package/dist/editor/types.js.map +0 -1
- package/dist/encryption/types.cjs.map +0 -1
- package/dist/encryption/types.js.map +0 -1
- package/dist/import/index.cjs.map +0 -1
- package/dist/import/index.js.map +0 -1
- package/dist/keboolaUID-D1DGSbge.d.cts +0 -19
- package/dist/keboolaUID-D1DGSbge.d.ts +0 -19
- package/dist/management/index.cjs.map +0 -1
- package/dist/management/index.js.map +0 -1
- package/dist/management/types.cjs.map +0 -1
- package/dist/management/types.js.map +0 -1
- package/dist/metastore/index.cjs.map +0 -1
- package/dist/metastore/index.js.map +0 -1
- package/dist/metastore/types.cjs.map +0 -1
- package/dist/metastore/types.js.map +0 -1
- package/dist/notifications/types.cjs.map +0 -1
- package/dist/notifications/types.js.map +0 -1
- package/dist/oauth/index.cjs.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/types.cjs.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/omnisearch/types.cjs.map +0 -1
- package/dist/omnisearch/types.js.map +0 -1
- package/dist/project-Dmr-zrQG.d.ts +0 -17
- package/dist/project-DstzWVMN.d.cts +0 -17
- package/dist/queryService/index.cjs.map +0 -1
- package/dist/queryService/index.js.map +0 -1
- package/dist/queryService/types.cjs.map +0 -1
- package/dist/queryService/types.js.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.js.map +0 -1
- package/dist/queue/types.cjs.map +0 -1
- package/dist/queue/types.js.map +0 -1
- package/dist/registry-CcKlB-yY.d.ts +0 -1046
- package/dist/registry-Cg0Yng1z.d.cts +0 -1046
- package/dist/scheduler/types.cjs.map +0 -1
- package/dist/scheduler/types.js.map +0 -1
- package/dist/sdk/configurations/index.cjs.map +0 -1
- package/dist/sdk/configurations/index.js.map +0 -1
- package/dist/sdk/semanticLayer/types.cjs.map +0 -1
- package/dist/sdk/semanticLayer/types.js.map +0 -1
- package/dist/sdk/tag/index.cjs.map +0 -1
- package/dist/sdk/tag/index.js.map +0 -1
- package/dist/sdk/tag/types.cjs.map +0 -1
- package/dist/sdk/tag/types.js.map +0 -1
- package/dist/status/types.cjs.map +0 -1
- package/dist/status/types.js.map +0 -1
- package/dist/storage/index.cjs.map +0 -1
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/types.cjs.map +0 -1
- package/dist/storage/types.js.map +0 -1
- package/dist/storageClient-BAid0vi2.d.cts +0 -1750
- package/dist/storageClient-BX50Attd.d.ts +0 -1750
- package/dist/storageSdk-BS5982c_.d.cts +0 -753
- package/dist/storageSdk-BeJcnEIO.d.ts +0 -753
- package/dist/stream/types.cjs.map +0 -1
- package/dist/stream/types.js.map +0 -1
- package/dist/syncActions/index.cjs.map +0 -1
- package/dist/syncActions/index.js.map +0 -1
- package/dist/syncActions/types.cjs.map +0 -1
- package/dist/syncActions/types.js.map +0 -1
- package/dist/telemetry/index.cjs.map +0 -1
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/types.cjs.map +0 -1
- package/dist/telemetry/types.js.map +0 -1
- package/dist/types-C5DdOzx8.d.cts +0 -12
- package/dist/types-C_jxWM7A.d.ts +0 -12
- package/dist/types-UwuKN9Kx.d.cts +0 -60
- package/dist/types-UwuKN9Kx.d.ts +0 -60
- package/dist/types-f8dUjMX4.d.cts +0 -90
- package/dist/types-f8dUjMX4.d.ts +0 -90
- package/dist/vault/types.cjs.map +0 -1
- package/dist/vault/types.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,1804 +1,1763 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import
|
|
50
|
-
import {
|
|
51
|
-
|
|
52
|
-
import { isPlainObject } from './chunk-MSI6FVGG.js';
|
|
53
|
-
export { isPlainObject } from './chunk-MSI6FVGG.js';
|
|
54
|
-
import { createEditorClient } from './chunk-QNF3L4B7.js';
|
|
55
|
-
import { createAuthHeaders } from './chunk-5A3AQIXR.js';
|
|
56
|
-
import { KeboolaHttpHeader, HttpStatus, isApiError, ApiError, normalizeBaseUrl, HttpHeader, createOpenapiFetchClient, createGenericFetchClient } from './chunk-2BQBKU6E.js';
|
|
57
|
-
export { ApiError, HttpContentType, HttpHeader, KeboolaHttpHeader, createGenericFetchClient, isAbortError, isApiError, isFetchClientError } from './chunk-2BQBKU6E.js';
|
|
58
|
-
import * as z2 from 'zod';
|
|
59
|
-
import { z } from 'zod';
|
|
60
|
-
|
|
61
|
-
// src/utils/assert.ts
|
|
1
|
+
import { t as createProject } from "./project-DWwZv66D.js";
|
|
2
|
+
import { a as poller, c as Result, d as delay, i as poll, l as asError, n as emitter, o as clamp, r as failureOf, s as finiteOr, t as jobStatus, u as lazy } from "./jobStatus-DbMupQEK.js";
|
|
3
|
+
import { n as collect, t as createQueueClient } from "./queue-DpZTm7U7.js";
|
|
4
|
+
import { t as concurrent } from "./concurrent-CH9fbNr3.js";
|
|
5
|
+
import { t as dedupe } from "./dedupe-DYIHgZoG.js";
|
|
6
|
+
import { a as shallowEqual, i as createStore, n as createDerivedStore, r as createEmitter, t as createDerivedAsyncStore } from "./createStore-BNiCRQXa.js";
|
|
7
|
+
import { a as series, i as ServiceUnavailableError, t as createStorageClient } from "./storage-CQxu0EY3.js";
|
|
8
|
+
import { n as keboolaUID, t as createTagSdk } from "./tag-DCsoewjL.js";
|
|
9
|
+
import { t as generateUUID } from "./generateUUID-Dr8l-aoc.js";
|
|
10
|
+
import { t as isPlainObject } from "./isPlainObject-LYW-03uB.js";
|
|
11
|
+
import { n as schemaGuidedMerge, r as isEmptyDeep, t as createConfigurationSdk } from "./configurations-Byt59bIa.js";
|
|
12
|
+
import { t as UserError } from "./UserError-By_Zckmc.js";
|
|
13
|
+
import { a as HttpContentType, f as HttpStatus, i as isFetchClientError, l as normalizeBaseUrl, m as ApiError, n as isAbortError, o as HttpHeader, p as KeboolaHttpHeader, r as isApiError } from "./createFetchClient-B1h3-p65.js";
|
|
14
|
+
import { n as HtmlResponseError, r as isHtmlResponseError } from "./validateConnectionStatus-CBhXmvWC.js";
|
|
15
|
+
import { t as ManagementClientAuthError } from "./ManagementClientAuthError-90pvsej0.js";
|
|
16
|
+
import { i as isQueryJobError, n as isQueryJobTimeoutError, r as QueryJobError, t as QueryJobTimeoutError } from "./QueryJobTimeoutError-C7JbNGOM.js";
|
|
17
|
+
import { n as isSyncActionError, t as SyncActionError } from "./SyncActionError-CoZFsdUk.js";
|
|
18
|
+
import { n as isValidationError, r as parseOrThrow, t as ValidationError } from "./ValidationError-CzPWydEb.js";
|
|
19
|
+
import { t as createGenericFetchClient } from "./createGenericFetchClient-DhpvUSlX.js";
|
|
20
|
+
import { t as createImportClient } from "./import-CExRbskw.js";
|
|
21
|
+
import { t as createOpenapiFetchClient } from "./createOpenapiFetchClient-0_oqhdPv.js";
|
|
22
|
+
import { t as createAuthClient } from "./authClient-XBAUz9g-.js";
|
|
23
|
+
import { n as isManagementClientAuthError, t as createManagementClient } from "./management-Cc8mKfnf.js";
|
|
24
|
+
import { t as createAuthHeaders } from "./auth-CE6Hlc9W.js";
|
|
25
|
+
import { o as ProjectFeature } from "./constants-qeWGfk_7.js";
|
|
26
|
+
import { t as createStorageTable } from "./storageTable-DslXtqNL.js";
|
|
27
|
+
import { createSemanticLayerSdk } from "./sdk/semanticLayer/index.js";
|
|
28
|
+
import { createStorageSdk } from "./sdk/storage/index.js";
|
|
29
|
+
import { createVaultSdk } from "./sdk/vault/index.js";
|
|
30
|
+
import { createAiClient } from "./ai/index.js";
|
|
31
|
+
import { t as parseLogLines } from "./appLogs-CLHhkQJn.js";
|
|
32
|
+
import { createAppsClient } from "./apps/index.js";
|
|
33
|
+
import { createChatClient } from "./chat/index.js";
|
|
34
|
+
import { t as createDataScienceClient } from "./dataScience-jdbSSPYF.js";
|
|
35
|
+
import { createEditorClient } from "./editor/index.js";
|
|
36
|
+
import { createEncryptionClient } from "./encryption/index.js";
|
|
37
|
+
import { t as createMetastoreClient } from "./metastore-CNf1412Z.js";
|
|
38
|
+
import { createNotificationsClient } from "./notifications/index.js";
|
|
39
|
+
import { t as createOauthClient } from "./oauth-ClksaYRY.js";
|
|
40
|
+
import { createOmnisearchClient } from "./omnisearch/index.js";
|
|
41
|
+
import { t as createQueryServiceClient } from "./queryService-BlyAcBxP.js";
|
|
42
|
+
import { createSchedulerClient } from "./scheduler/index.js";
|
|
43
|
+
import { createStreamClient } from "./stream/index.js";
|
|
44
|
+
import { t as createSyncActionsClient } from "./syncActions-AgFiMjRS.js";
|
|
45
|
+
import { t as createTelemetryClient } from "./telemetry-CPiGWpLi.js";
|
|
46
|
+
import { createVaultClient } from "./vault/index.js";
|
|
47
|
+
import { n as isUnauthorized, t as createBearerCredential } from "./credential-dKxArMic.js";
|
|
48
|
+
import { createQueryServiceSdk } from "./sdk/queryService/index.js";
|
|
49
|
+
import * as z$1 from "zod";
|
|
50
|
+
import { z } from "zod";
|
|
51
|
+
//#region src/utils/assert.ts
|
|
62
52
|
function assert(value, message) {
|
|
63
|
-
|
|
64
|
-
throw new Error(message);
|
|
65
|
-
}
|
|
53
|
+
if (value == null) throw new Error(message);
|
|
66
54
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var createStore = (initial) => {
|
|
107
|
-
let value = initial;
|
|
108
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
109
|
-
return {
|
|
110
|
-
get: () => value,
|
|
111
|
-
set: (next) => {
|
|
112
|
-
if (Object.is(next, value)) return;
|
|
113
|
-
value = next;
|
|
114
|
-
listeners.forEach((listener) => listener(value));
|
|
115
|
-
},
|
|
116
|
-
subscribe: (listener) => {
|
|
117
|
-
listeners.add(listener);
|
|
118
|
-
return () => {
|
|
119
|
-
listeners.delete(listener);
|
|
120
|
-
};
|
|
121
|
-
},
|
|
122
|
-
dispose: () => {
|
|
123
|
-
value = initial;
|
|
124
|
-
listeners.clear();
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
var isPlainObjectOrArray = (value) => {
|
|
129
|
-
if (Array.isArray(value)) return true;
|
|
130
|
-
const proto = Object.getPrototypeOf(value);
|
|
131
|
-
return proto === Object.prototype || proto === null;
|
|
132
|
-
};
|
|
133
|
-
var shallowEqual = (a, b) => {
|
|
134
|
-
if (Object.is(a, b)) return true;
|
|
135
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) return false;
|
|
136
|
-
if (!isPlainObjectOrArray(a) || !isPlainObjectOrArray(b)) return false;
|
|
137
|
-
const aKeys = Object.keys(a);
|
|
138
|
-
const bKeys = Object.keys(b);
|
|
139
|
-
return aKeys.length === bKeys.length && aKeys.every((key) => Object.is(a[key], b[key]));
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/utils/async/coalesce.ts
|
|
57
|
+
/**
|
|
58
|
+
* Coalesces concurrent triggers onto a single, never-parallel run of `task`.
|
|
59
|
+
* Triggers fired while a run is busy collapse into one trailing run, and each
|
|
60
|
+
* resolves with the first run that started after it — so it never sees stale state.
|
|
61
|
+
*
|
|
62
|
+
* Example — A triggers, then B and C trigger while A's run is still going:
|
|
63
|
+
* 1. trigger A → run #1 starts
|
|
64
|
+
* 2. trigger B, C → run #1 busy, so they wait
|
|
65
|
+
* 3. run #1 done → A resolves
|
|
66
|
+
* 4. run #2 starts → covers B and C together (one trailing run, not two)
|
|
67
|
+
* 5. run #2 done → B and C resolve
|
|
68
|
+
*
|
|
69
|
+
* @returns a trigger; each call returns a promise of the task result.
|
|
70
|
+
* @throws The returned promise rejects with whatever `task` throws or rejects
|
|
71
|
+
* with — the caller handles it (try/catch, or `.catch` on `void trigger()`).
|
|
72
|
+
*/
|
|
73
|
+
const coalesce = (task) => {
|
|
74
|
+
let running = false;
|
|
75
|
+
const waiters = [];
|
|
76
|
+
const drain = async () => {
|
|
77
|
+
running = true;
|
|
78
|
+
const batch = waiters.splice(0);
|
|
79
|
+
try {
|
|
80
|
+
const result = await task();
|
|
81
|
+
batch.forEach((waiter) => waiter.resolve(result));
|
|
82
|
+
} catch (error) {
|
|
83
|
+
batch.forEach((waiter) => waiter.reject(error));
|
|
84
|
+
}
|
|
85
|
+
if (waiters.length > 0) return drain();
|
|
86
|
+
running = false;
|
|
87
|
+
};
|
|
88
|
+
return () => {
|
|
89
|
+
const waiter = Promise.withResolvers();
|
|
90
|
+
waiters.push(waiter);
|
|
91
|
+
if (!running) drain();
|
|
92
|
+
return waiter.promise;
|
|
93
|
+
};
|
|
140
94
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/utils/async/poll/registry.ts
|
|
97
|
+
const DEFAULT_LIMIT = 50;
|
|
98
|
+
const isFinished = ({ snapshot }) => snapshot.state !== "idle" && snapshot.state !== "polling";
|
|
99
|
+
const createPollRegistry = ({ limit = DEFAULT_LIMIT } = {}) => {
|
|
100
|
+
const entries = createStore([]);
|
|
101
|
+
const unsubscribes = /* @__PURE__ */ new Map();
|
|
102
|
+
const maxEntries = clamp(finiteOr(limit, DEFAULT_LIMIT), 1);
|
|
103
|
+
let nextKey = 1;
|
|
104
|
+
const forget = (key) => {
|
|
105
|
+
unsubscribes.get(key)?.();
|
|
106
|
+
unsubscribes.delete(key);
|
|
107
|
+
};
|
|
108
|
+
const trim = (list) => {
|
|
109
|
+
let kept = list;
|
|
110
|
+
while (kept.length > maxEntries) {
|
|
111
|
+
const dropped = kept.findLast(isFinished) ?? kept.at(-1);
|
|
112
|
+
if (!dropped) break;
|
|
113
|
+
forget(dropped.key);
|
|
114
|
+
kept = kept.filter((entry) => entry !== dropped);
|
|
115
|
+
}
|
|
116
|
+
return kept;
|
|
117
|
+
};
|
|
118
|
+
const replace = (key, snapshot) => entries.set(entries.get().map((entry) => entry.key === key ? {
|
|
119
|
+
...entry,
|
|
120
|
+
snapshot
|
|
121
|
+
} : entry));
|
|
122
|
+
const register = (poller) => {
|
|
123
|
+
const key = nextKey++;
|
|
124
|
+
const entry = {
|
|
125
|
+
key,
|
|
126
|
+
startedAt: Date.now(),
|
|
127
|
+
snapshot: poller.debug(),
|
|
128
|
+
stop: poller.stop,
|
|
129
|
+
start: poller.start
|
|
130
|
+
};
|
|
131
|
+
unsubscribes.set(key, poller.subscribe((snapshot) => replace(key, snapshot)));
|
|
132
|
+
entries.set(trim([entry, ...entries.get()]));
|
|
133
|
+
};
|
|
134
|
+
const collect = () => {
|
|
135
|
+
emitter.subscribe(register);
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
list: entries.get,
|
|
139
|
+
collect,
|
|
140
|
+
subscribe: (listener) => entries.subscribe(() => listener()),
|
|
141
|
+
clear: () => {
|
|
142
|
+
entries.get().forEach(({ key }) => forget(key));
|
|
143
|
+
entries.set([]);
|
|
144
|
+
},
|
|
145
|
+
stopAll: (reason) => entries.get().forEach((entry) => entry.stop(reason))
|
|
146
|
+
};
|
|
163
147
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
(value) => {
|
|
181
|
-
if (runGeneration === generation) store.set({ state: "ready", value });
|
|
182
|
-
},
|
|
183
|
-
(error) => {
|
|
184
|
-
if (runGeneration === generation) store.set({ state: "errored", error });
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
};
|
|
188
|
-
const sync = (state) => {
|
|
189
|
-
const next = dependsOn(state);
|
|
190
|
-
if (next === null) {
|
|
191
|
-
if (currentKey === null) return;
|
|
192
|
-
controller?.abort();
|
|
193
|
-
controller = null;
|
|
194
|
-
generation += 1;
|
|
195
|
-
currentKey = null;
|
|
196
|
-
store.set({ state: "idle" });
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (currentKey !== null && keyEquals(currentKey, next)) return;
|
|
200
|
-
currentKey = next;
|
|
201
|
-
run(next);
|
|
202
|
-
};
|
|
203
|
-
sync(source.get());
|
|
204
|
-
const unsubscribe = source.subscribe(sync);
|
|
205
|
-
const readable = {
|
|
206
|
-
get: store.get,
|
|
207
|
-
subscribe: store.subscribe,
|
|
208
|
-
dispose: () => {
|
|
209
|
-
controller?.abort();
|
|
210
|
-
unsubscribe();
|
|
211
|
-
store.dispose();
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const settled = () => new Promise((resolve) => {
|
|
215
|
-
let unsubscribeSettled = () => {
|
|
216
|
-
};
|
|
217
|
-
const check = (state) => {
|
|
218
|
-
if (state.state === "ready" || state.state === "errored") {
|
|
219
|
-
unsubscribeSettled();
|
|
220
|
-
resolve(state);
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
unsubscribeSettled = store.subscribe(check);
|
|
224
|
-
check(store.get());
|
|
225
|
-
});
|
|
226
|
-
return { store: readable, settled };
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
// src/utils/deepMerge.ts
|
|
230
|
-
var deepMerge = (base, patch) => {
|
|
231
|
-
const out = { ...base };
|
|
232
|
-
for (const [key, value] of Object.entries(patch)) {
|
|
233
|
-
if (value === void 0) continue;
|
|
234
|
-
const current = out[key];
|
|
235
|
-
out[key] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
|
|
236
|
-
}
|
|
237
|
-
return out;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/utils/deepMerge.ts
|
|
150
|
+
/**
|
|
151
|
+
* Recursively merge `patch` into `base`. Plain-object values are merged key-by-key; every
|
|
152
|
+
* other value (primitives, arrays, or a type mismatch between the two sides) replaces the
|
|
153
|
+
* base value. `undefined` patch values are skipped, so a partial patch leaves untouched
|
|
154
|
+
* fields alone. Pure — neither argument is mutated; the result preserves `base`'s type.
|
|
155
|
+
*/
|
|
156
|
+
const deepMerge = (base, patch) => {
|
|
157
|
+
const out = { ...base };
|
|
158
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
159
|
+
if (value === void 0) continue;
|
|
160
|
+
const current = out[key];
|
|
161
|
+
out[key] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
|
|
162
|
+
}
|
|
163
|
+
return out;
|
|
238
164
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
removeItem: () => {
|
|
246
|
-
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/utils/persistor/adapters.ts
|
|
167
|
+
const createNullStorage = () => ({
|
|
168
|
+
getItem: () => null,
|
|
169
|
+
setItem: () => {},
|
|
170
|
+
removeItem: () => {}
|
|
247
171
|
});
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
172
|
+
const createMemoryStorage = () => {
|
|
173
|
+
const store = /* @__PURE__ */ new Map();
|
|
174
|
+
return {
|
|
175
|
+
getItem: (key) => store.get(key) ?? null,
|
|
176
|
+
setItem: (key, value) => {
|
|
177
|
+
store.set(key, value);
|
|
178
|
+
},
|
|
179
|
+
removeItem: (key) => {
|
|
180
|
+
store.delete(key);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
259
183
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
184
|
+
const createWebStorage = (pick) => {
|
|
185
|
+
let web = null;
|
|
186
|
+
try {
|
|
187
|
+
web = pick();
|
|
188
|
+
if (web) {
|
|
189
|
+
const probe = "__keboola_storage_probe__";
|
|
190
|
+
web.setItem(probe, probe);
|
|
191
|
+
web.removeItem(probe);
|
|
192
|
+
}
|
|
193
|
+
} catch (err) {
|
|
194
|
+
console.warn("createWebStorage: web storage unavailable, falling back to memory", err);
|
|
195
|
+
web = null;
|
|
196
|
+
}
|
|
197
|
+
if (!web) return createMemoryStorage();
|
|
198
|
+
const storage = web;
|
|
199
|
+
return {
|
|
200
|
+
getItem: (key) => storage.getItem(key),
|
|
201
|
+
setItem: (key, value) => {
|
|
202
|
+
storage.setItem(key, value);
|
|
203
|
+
},
|
|
204
|
+
removeItem: (key) => {
|
|
205
|
+
storage.removeItem(key);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
284
208
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
};
|
|
348
|
-
return { hydrate, persist, clear, hasPersistedValue };
|
|
209
|
+
const createLocalStorage = () => createWebStorage(() => "localStorage" in globalThis ? globalThis.localStorage : null);
|
|
210
|
+
const createSessionStorage = () => createWebStorage(() => "sessionStorage" in globalThis ? globalThis.sessionStorage : null);
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/utils/persistor/persistor.ts
|
|
213
|
+
const createPersistor = ({ storage = createNullStorage(), key, schema, defaultValue, encode = JSON.stringify, decode = JSON.parse }) => {
|
|
214
|
+
const clear = () => {
|
|
215
|
+
try {
|
|
216
|
+
storage.removeItem(key);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
console.warn(`createPersistor: failed to clear "${key}"`, err);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const hasPersistedValue = () => {
|
|
222
|
+
try {
|
|
223
|
+
return !!storage.getItem(key);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
console.warn(`createPersistor: failed to read "${key}", assuming empty`, err);
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
const hydrate = () => {
|
|
230
|
+
let raw;
|
|
231
|
+
try {
|
|
232
|
+
raw = storage.getItem(key);
|
|
233
|
+
} catch (err) {
|
|
234
|
+
console.warn(`createPersistor: failed to read "${key}", using default`, err);
|
|
235
|
+
return defaultValue;
|
|
236
|
+
}
|
|
237
|
+
if (raw === null) return defaultValue;
|
|
238
|
+
let decoded;
|
|
239
|
+
try {
|
|
240
|
+
decoded = decode(raw);
|
|
241
|
+
} catch (err) {
|
|
242
|
+
console.warn(`createPersistor: failed to decode "${key}", resetting`, err);
|
|
243
|
+
clear();
|
|
244
|
+
return defaultValue;
|
|
245
|
+
}
|
|
246
|
+
const parsed = schema.safeParse(decoded);
|
|
247
|
+
if (parsed.success) return parsed.data;
|
|
248
|
+
clear();
|
|
249
|
+
return defaultValue;
|
|
250
|
+
};
|
|
251
|
+
const persist = (value) => {
|
|
252
|
+
let raw;
|
|
253
|
+
try {
|
|
254
|
+
raw = encode(value);
|
|
255
|
+
} catch (err) {
|
|
256
|
+
console.warn(`createPersistor: failed to encode "${key}", not persisting`, err);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
storage.setItem(key, raw);
|
|
261
|
+
} catch (err) {
|
|
262
|
+
console.warn(`createPersistor: failed to write "${key}"`, err);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
hydrate,
|
|
267
|
+
persist,
|
|
268
|
+
clear,
|
|
269
|
+
hasPersistedValue
|
|
270
|
+
};
|
|
349
271
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
// Project feature toggles — changes token.owner.features. Anchored to
|
|
358
|
-
// /projects/{id}/features so /manage/features and /users/{id}/features don't match.
|
|
359
|
-
/\/projects\/[^/]+\/features(\/[^/]+)?$/
|
|
360
|
-
];
|
|
361
|
-
var isStorageTokenMutatingRequest = (request) => {
|
|
362
|
-
if (request.method === "GET") return false;
|
|
363
|
-
const { pathname } = new URL(request.url);
|
|
364
|
-
return STORAGE_TOKEN_MUTATING_PATTERNS.some((pattern) => pattern.test(pathname));
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/keboola/createLiveProject.ts
|
|
274
|
+
const STORAGE_TOKEN_MUTATING_PATTERNS = [/\/buckets(\/[^/]+)?$/, /\/projects\/[^/]+\/features(\/[^/]+)?$/];
|
|
275
|
+
const isStorageTokenMutatingRequest = (request) => {
|
|
276
|
+
if (request.method === "GET") return false;
|
|
277
|
+
const { pathname } = new URL(request.url);
|
|
278
|
+
return STORAGE_TOKEN_MUTATING_PATTERNS.some((pattern) => pattern.test(pathname));
|
|
365
279
|
};
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
280
|
+
const createProjectRefreshMiddleware = (shouldRefresh, requestRefresh) => (next) => async (request) => {
|
|
281
|
+
const response = await next(request);
|
|
282
|
+
if (shouldRefresh(request.request)) await requestRefresh();
|
|
283
|
+
return response;
|
|
370
284
|
};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
285
|
+
/**
|
|
286
|
+
* The live project store: seeded from the verified token, re-verified (coalesced) after a
|
|
287
|
+
* token-mutating request or an explicit re-scope. Its `middleware` drives the auto re-verify.
|
|
288
|
+
*/
|
|
289
|
+
const createLiveProject = ({ initialToken, verify }) => {
|
|
290
|
+
const store = createStore(createProject({ sapiToken: initialToken }));
|
|
291
|
+
const refresh = coalesce(async () => store.set(createProject({ sapiToken: await verify() })));
|
|
292
|
+
const middleware = createProjectRefreshMiddleware(isStorageTokenMutatingRequest, refresh);
|
|
293
|
+
return {
|
|
294
|
+
store,
|
|
295
|
+
getProject: () => store.get(),
|
|
296
|
+
subscribe: store.subscribe,
|
|
297
|
+
middleware,
|
|
298
|
+
refresh
|
|
299
|
+
};
|
|
379
300
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/keboola/errors.ts
|
|
303
|
+
/**
|
|
304
|
+
* The single error the keboola client / session throws. It carries a stable `type` (the switchable
|
|
305
|
+
* contract) and a human-readable message derived from that type — no per-call message strings.
|
|
306
|
+
*/
|
|
307
|
+
const KeboolaErrorType = {
|
|
308
|
+
Unconfigured: "unconfigured",
|
|
309
|
+
NotAuthenticated: "not-authenticated",
|
|
310
|
+
AlreadyAuthenticated: "already-authenticated",
|
|
311
|
+
NoStorageToken: "no-storage-token",
|
|
312
|
+
NoManagementToken: "no-management-token",
|
|
313
|
+
MissingProject: "missing-project",
|
|
314
|
+
NotBearer: "not-bearer",
|
|
315
|
+
NotReady: "not-ready",
|
|
316
|
+
InvalidBuildTransition: "invalid-build-transition"
|
|
392
317
|
};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
318
|
+
const MESSAGES = {
|
|
319
|
+
[KeboolaErrorType.Unconfigured]: "The session is not configured — set a baseUrl first.",
|
|
320
|
+
[KeboolaErrorType.NotAuthenticated]: "The session is not authenticated — sign in first.",
|
|
321
|
+
[KeboolaErrorType.AlreadyAuthenticated]: "The session is already authenticated — reset before authenticating again.",
|
|
322
|
+
[KeboolaErrorType.NoStorageToken]: "No storage token — authenticate the storage realm first.",
|
|
323
|
+
[KeboolaErrorType.NoManagementToken]: "No management token — authenticate the management realm first.",
|
|
324
|
+
[KeboolaErrorType.MissingProject]: "A bearer storage session requires a project — call setProject(projectId) first.",
|
|
325
|
+
[KeboolaErrorType.NotBearer]: "This operation requires a bearer (OAuth) session.",
|
|
326
|
+
[KeboolaErrorType.NotReady]: "The client is not ready — authenticate the storage realm first.",
|
|
327
|
+
[KeboolaErrorType.InvalidBuildTransition]: "Invalid storage build transition — the build goes idle → initializing → ready | failed."
|
|
403
328
|
};
|
|
404
|
-
var KeboolaError = class
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
329
|
+
var KeboolaError = class KeboolaError extends Error {
|
|
330
|
+
type;
|
|
331
|
+
constructor(type) {
|
|
332
|
+
super(MESSAGES[type]);
|
|
333
|
+
this.type = type;
|
|
334
|
+
this.name = "KeboolaError";
|
|
335
|
+
Object.setPrototypeOf(this, KeboolaError.prototype);
|
|
336
|
+
}
|
|
412
337
|
};
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
338
|
+
const isKeboolaError = (error) => error instanceof KeboolaError;
|
|
339
|
+
/** Throw a {@link KeboolaError} of `type` when `value` is null/undefined; otherwise narrow it. */
|
|
340
|
+
function assert$1(value, type) {
|
|
341
|
+
if (value == null) throw new KeboolaError(type);
|
|
416
342
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/middlewares/loggingMiddleware.ts
|
|
345
|
+
const CORRELATION_ID_HEADER = "X-Correlation-ID";
|
|
346
|
+
const ALWAYS_REDACTED_HEADERS = [
|
|
347
|
+
KeboolaHttpHeader.MANAGEMENT_API_TOKEN,
|
|
348
|
+
KeboolaHttpHeader.STORAGE_API_TOKEN,
|
|
349
|
+
"authorization",
|
|
350
|
+
"cookie",
|
|
351
|
+
"set-cookie"
|
|
426
352
|
];
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
353
|
+
const ALWAYS_REDACTED_QUERY_PARAMS = /* @__PURE__ */ new Set([
|
|
354
|
+
"token",
|
|
355
|
+
"apikey",
|
|
356
|
+
"api_key",
|
|
357
|
+
"access_token",
|
|
358
|
+
"refresh_token",
|
|
359
|
+
"code",
|
|
360
|
+
"state",
|
|
361
|
+
"signature",
|
|
362
|
+
"sig",
|
|
363
|
+
"x-amz-signature",
|
|
364
|
+
"x-amz-credential",
|
|
365
|
+
"x-amz-security-token",
|
|
366
|
+
"password",
|
|
367
|
+
"secret"
|
|
442
368
|
]);
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
});
|
|
453
|
-
return url.toString();
|
|
369
|
+
const REDACTED = "[REDACTED]";
|
|
370
|
+
const getRedactedUrl = (rawUrl) => {
|
|
371
|
+
const url = new URL(rawUrl);
|
|
372
|
+
if (url.username) url.username = REDACTED;
|
|
373
|
+
if (url.password) url.password = REDACTED;
|
|
374
|
+
url.searchParams.forEach((_value, key) => {
|
|
375
|
+
if (ALWAYS_REDACTED_QUERY_PARAMS.has(key.toLowerCase())) url.searchParams.set(key, REDACTED);
|
|
376
|
+
});
|
|
377
|
+
return url.toString();
|
|
454
378
|
};
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
379
|
+
const ensureCorrelationId = (request) => {
|
|
380
|
+
const correlationId = request.headers.get(CORRELATION_ID_HEADER) ?? generateUUID();
|
|
381
|
+
request.headers.set(CORRELATION_ID_HEADER, correlationId);
|
|
382
|
+
return correlationId;
|
|
459
383
|
};
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
});
|
|
468
|
-
return result;
|
|
384
|
+
const getRedactedHeaders = (headers, redacted) => {
|
|
385
|
+
const redactedSet = new Set([...ALWAYS_REDACTED_HEADERS, ...redacted].map((h) => h.toLowerCase()));
|
|
386
|
+
const result = {};
|
|
387
|
+
headers.forEach((value, name) => {
|
|
388
|
+
result[name] = redactedSet.has(name.toLowerCase()) ? REDACTED : value;
|
|
389
|
+
});
|
|
390
|
+
return result;
|
|
469
391
|
};
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
392
|
+
const getRequestLog = (request, redactedHeaders) => ({
|
|
393
|
+
url: getRedactedUrl(request.url),
|
|
394
|
+
headers: getRedactedHeaders(request.headers, redactedHeaders)
|
|
473
395
|
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
396
|
+
const getResponseLog = (response, redactedHeaders) => ({
|
|
397
|
+
status: response.status,
|
|
398
|
+
statusText: response.statusText,
|
|
399
|
+
headers: getRedactedHeaders(response.headers, redactedHeaders)
|
|
478
400
|
});
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
401
|
+
const redactApiError = (error, redactedHeaders) => new ApiError({
|
|
402
|
+
request: new Request(getRedactedUrl(error.request.url), {
|
|
403
|
+
method: error.request.method,
|
|
404
|
+
headers: getRedactedHeaders(error.request.headers, redactedHeaders)
|
|
405
|
+
}),
|
|
406
|
+
response: new Response(null, {
|
|
407
|
+
status: error.response.status,
|
|
408
|
+
statusText: error.response.statusText,
|
|
409
|
+
headers: getRedactedHeaders(error.response.headers, redactedHeaders)
|
|
410
|
+
}),
|
|
411
|
+
data: error.data
|
|
490
412
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
413
|
+
const formatLog = (level, log) => {
|
|
414
|
+
const parts = [
|
|
415
|
+
`[${level.toUpperCase()}]`,
|
|
416
|
+
`${Math.round(log.durationMs)}ms`,
|
|
417
|
+
log.method
|
|
418
|
+
];
|
|
419
|
+
parts.push(log.request.url);
|
|
420
|
+
if ("response" in log) parts.push(String(log.response.status));
|
|
421
|
+
return parts.join(" ");
|
|
496
422
|
};
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
};
|
|
423
|
+
const createSafeLogger = (logger, level = "error-only") => {
|
|
424
|
+
return {
|
|
425
|
+
info: (log) => {
|
|
426
|
+
if (level !== "all") return;
|
|
427
|
+
try {
|
|
428
|
+
if (logger?.info) {
|
|
429
|
+
logger.info(log);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
console.info(formatLog("info", log));
|
|
433
|
+
} catch {}
|
|
434
|
+
},
|
|
435
|
+
error: (log) => {
|
|
436
|
+
try {
|
|
437
|
+
if (logger?.error) {
|
|
438
|
+
logger.error(log);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
console.error(formatLog("error", log));
|
|
442
|
+
} catch {}
|
|
443
|
+
}
|
|
444
|
+
};
|
|
521
445
|
};
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
};
|
|
446
|
+
const createLoggingMiddleware = (options = {}) => {
|
|
447
|
+
const safeLogger = createSafeLogger(options.logger, options.level);
|
|
448
|
+
const redactHeaders = options.redactHeaders ?? [];
|
|
449
|
+
return (next) => async (fetchRequest) => {
|
|
450
|
+
const correlationId = ensureCorrelationId(fetchRequest.request);
|
|
451
|
+
const start = performance.now();
|
|
452
|
+
const method = fetchRequest.request.method.toLowerCase();
|
|
453
|
+
const requestLog = getRequestLog(fetchRequest.request, redactHeaders);
|
|
454
|
+
try {
|
|
455
|
+
const result = await next(fetchRequest);
|
|
456
|
+
safeLogger.info({
|
|
457
|
+
correlationId,
|
|
458
|
+
method,
|
|
459
|
+
durationMs: performance.now() - start,
|
|
460
|
+
request: requestLog,
|
|
461
|
+
response: getResponseLog(result.response, redactHeaders)
|
|
462
|
+
});
|
|
463
|
+
return result;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
if (error instanceof Error) safeLogger.error({
|
|
466
|
+
correlationId,
|
|
467
|
+
method,
|
|
468
|
+
durationMs: performance.now() - start,
|
|
469
|
+
request: requestLog,
|
|
470
|
+
error: isApiError(error) ? redactApiError(error, redactHeaders) : error
|
|
471
|
+
});
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
};
|
|
552
475
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/middlewares/retryMiddleware.ts
|
|
478
|
+
const DEFAULT_MAX_RETRIES = 5;
|
|
479
|
+
const DEFAULT_RETRYABLE_STATUSES = [
|
|
480
|
+
HttpStatus.INTERNAL_SERVER_ERROR,
|
|
481
|
+
HttpStatus.BAD_GATEWAY,
|
|
482
|
+
HttpStatus.SERVICE_UNAVAILABLE,
|
|
483
|
+
HttpStatus.GATEWAY_TIMEOUT
|
|
561
484
|
];
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (attempt === maxRetries || !shouldRetry(error, attempt)) {
|
|
582
|
-
throw error;
|
|
583
|
-
}
|
|
584
|
-
const delayMs = backoffFactor * 1e3 * Math.pow(2, attempt);
|
|
585
|
-
await delay(delayMs, request.request.signal ?? void 0);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
throw new Error("unreachable");
|
|
589
|
-
};
|
|
485
|
+
const DEFAULT_BACKOFF_FACTOR = .3;
|
|
486
|
+
const defaultShouldRetry = (error) => error instanceof ApiError && DEFAULT_RETRYABLE_STATUSES.includes(error.response.status);
|
|
487
|
+
const createRetryMiddleware = (options) => {
|
|
488
|
+
const { maxRetries = DEFAULT_MAX_RETRIES, backoffFactor = DEFAULT_BACKOFF_FACTOR, shouldRetry = defaultShouldRetry } = options ?? {};
|
|
489
|
+
if (!Number.isInteger(maxRetries) || maxRetries < 0) throw new RangeError("maxRetries must be a non-negative integer");
|
|
490
|
+
if (!Number.isFinite(backoffFactor) || backoffFactor < 0) throw new RangeError("backoffFactor must be a finite non-negative number");
|
|
491
|
+
return (next) => async (request) => {
|
|
492
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) try {
|
|
493
|
+
return await next({
|
|
494
|
+
...request,
|
|
495
|
+
request: request.request.clone()
|
|
496
|
+
});
|
|
497
|
+
} catch (error) {
|
|
498
|
+
if (attempt === maxRetries || !shouldRetry(error, attempt)) throw error;
|
|
499
|
+
const delayMs = backoffFactor * 1e3 * Math.pow(2, attempt);
|
|
500
|
+
await delay(delayMs, request.request.signal ?? void 0);
|
|
501
|
+
}
|
|
502
|
+
throw new Error("unreachable");
|
|
503
|
+
};
|
|
590
504
|
};
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
});
|
|
607
|
-
return createProxy();
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/serviceClientRegistry/utils.ts
|
|
507
|
+
const isBuiltInProperty = (property) => typeof property === "symbol" || property === "then" || property === "constructor" || property === "toString" || property === "valueOf";
|
|
508
|
+
/**
|
|
509
|
+
* Creates a dummy client that intercepts method calls and invokes the provided onCall callback.
|
|
510
|
+
*/
|
|
511
|
+
const createDummyClient = ({ onCall }) => {
|
|
512
|
+
const createProxy = (path = []) => new Proxy(() => {}, {
|
|
513
|
+
get: (_target, prop) => {
|
|
514
|
+
if (isBuiltInProperty(prop)) return void 0;
|
|
515
|
+
return createProxy([...path, prop]);
|
|
516
|
+
},
|
|
517
|
+
apply: (_target, _thisArgs, args) => onCall(path, args)
|
|
518
|
+
});
|
|
519
|
+
return createProxy();
|
|
608
520
|
};
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
return {
|
|
651
|
-
client: clientMap,
|
|
652
|
-
meta: clientMeta
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
};
|
|
656
|
-
return registry;
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/serviceClientRegistry/createServiceClientRegistry.ts
|
|
523
|
+
const createServiceClientRegistry = () => ({ getServiceBaseUrl, onUnavailable }) => {
|
|
524
|
+
const dummy = (serviceId, clientName) => createDummyClient({ onCall: (path, args) => {
|
|
525
|
+
onUnavailable?.({
|
|
526
|
+
serviceId,
|
|
527
|
+
path,
|
|
528
|
+
args,
|
|
529
|
+
clientName
|
|
530
|
+
});
|
|
531
|
+
} });
|
|
532
|
+
const configs = [];
|
|
533
|
+
const resolveClient = ({ serviceId, clientFn, clientName }) => {
|
|
534
|
+
const serviceBaseUrl = getServiceBaseUrl(serviceId);
|
|
535
|
+
return serviceBaseUrl ? clientFn(serviceBaseUrl) : dummy(serviceId, clientName);
|
|
536
|
+
};
|
|
537
|
+
const registry = {
|
|
538
|
+
add: (config) => {
|
|
539
|
+
configs.push(config);
|
|
540
|
+
return registry;
|
|
541
|
+
},
|
|
542
|
+
build: () => {
|
|
543
|
+
const clientMap = {};
|
|
544
|
+
const clientMeta = [];
|
|
545
|
+
configs.forEach((config) => {
|
|
546
|
+
clientMap[config.clientName] = resolveClient(config);
|
|
547
|
+
clientMeta.push({
|
|
548
|
+
clientName: config.clientName,
|
|
549
|
+
serviceId: config.serviceId,
|
|
550
|
+
isAvailable: !!getServiceBaseUrl(config.serviceId)
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
return {
|
|
554
|
+
client: clientMap,
|
|
555
|
+
meta: clientMeta
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
return registry;
|
|
657
560
|
};
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/keboola/createApi.ts
|
|
563
|
+
const createApi = (state) => new Proxy({}, { get(_target, property) {
|
|
564
|
+
if (isBuiltInProperty(property)) return void 0;
|
|
565
|
+
if (property === "auth") {
|
|
566
|
+
const authClient = state.getAuthClient();
|
|
567
|
+
assert$1(authClient, KeboolaErrorType.Unconfigured);
|
|
568
|
+
return authClient;
|
|
569
|
+
}
|
|
570
|
+
if (property === "management") {
|
|
571
|
+
const management = state.getManagementClient();
|
|
572
|
+
assert$1(management, KeboolaErrorType.NoManagementToken);
|
|
573
|
+
return management;
|
|
574
|
+
}
|
|
575
|
+
const clients = state.getProjectClients();
|
|
576
|
+
assert$1(clients, KeboolaErrorType.NotReady);
|
|
577
|
+
return clients[property];
|
|
578
|
+
} });
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/keboola/createMiddlewareFor.ts
|
|
581
|
+
const createMiddlewareFor = (middlewares) => {
|
|
582
|
+
return (target, baseline = []) => {
|
|
583
|
+
if (Array.isArray(middlewares)) return [...baseline, ...middlewares];
|
|
584
|
+
const all = middlewares?.all ?? [];
|
|
585
|
+
const targeted = middlewares?.[target] ?? [];
|
|
586
|
+
return [
|
|
587
|
+
...baseline,
|
|
588
|
+
...all,
|
|
589
|
+
...targeted
|
|
590
|
+
];
|
|
591
|
+
};
|
|
687
592
|
};
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const store = createStore(initial);
|
|
694
|
-
let expiredNotified = false;
|
|
695
|
-
const setBaseUrl = (baseUrl) => {
|
|
696
|
-
if (store.get().status !== "anonymous")
|
|
697
|
-
throw new KeboolaError(KeboolaErrorType.AlreadyAuthenticated);
|
|
698
|
-
store.set({ status: "anonymous", baseUrl });
|
|
699
|
-
};
|
|
700
|
-
const authenticate = (tokens) => {
|
|
701
|
-
const state = store.get();
|
|
702
|
-
if (state.status !== "anonymous") throw new KeboolaError(KeboolaErrorType.AlreadyAuthenticated);
|
|
703
|
-
if (!state.baseUrl) throw new KeboolaError(KeboolaErrorType.Unconfigured);
|
|
704
|
-
expiredNotified = false;
|
|
705
|
-
store.set({ status: "authenticated", baseUrl: state.baseUrl, credential: stamp(tokens) });
|
|
706
|
-
};
|
|
707
|
-
const setProjectId = (projectId) => {
|
|
708
|
-
const state = store.get();
|
|
709
|
-
if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
710
|
-
store.set({
|
|
711
|
-
status: "scoped",
|
|
712
|
-
baseUrl: state.baseUrl,
|
|
713
|
-
credential: state.credential,
|
|
714
|
-
projectId
|
|
715
|
-
});
|
|
716
|
-
};
|
|
717
|
-
const clearProjectId = () => {
|
|
718
|
-
const state = store.get();
|
|
719
|
-
if (state.status !== "scoped") return;
|
|
720
|
-
store.set({ status: "authenticated", baseUrl: state.baseUrl, credential: state.credential });
|
|
721
|
-
};
|
|
722
|
-
const reset = () => {
|
|
723
|
-
store.set({ status: "anonymous", baseUrl: store.get().baseUrl });
|
|
724
|
-
};
|
|
725
|
-
const applyRefresh = (tokens) => {
|
|
726
|
-
const state = store.get();
|
|
727
|
-
if (state.status === "anonymous") return;
|
|
728
|
-
store.set({ ...state, credential: stamp(tokens) });
|
|
729
|
-
};
|
|
730
|
-
const forceExpire = () => {
|
|
731
|
-
const state = store.get();
|
|
732
|
-
if (state.status === "anonymous") return;
|
|
733
|
-
const issuedAt = Date.now() - state.credential.expiresIn * 1e3;
|
|
734
|
-
store.set({ ...state, credential: { ...state.credential, issuedAt } });
|
|
735
|
-
};
|
|
736
|
-
const requireCredential = () => {
|
|
737
|
-
const state = store.get();
|
|
738
|
-
if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
739
|
-
return state.credential;
|
|
740
|
-
};
|
|
741
|
-
const getBaseUrl = () => store.get().baseUrl;
|
|
742
|
-
const notifyExpired = () => {
|
|
743
|
-
if (expiredNotified) return false;
|
|
744
|
-
expiredNotified = true;
|
|
745
|
-
return true;
|
|
746
|
-
};
|
|
747
|
-
const debug = () => store.get();
|
|
748
|
-
const readable = {
|
|
749
|
-
get: store.get,
|
|
750
|
-
subscribe: store.subscribe,
|
|
751
|
-
dispose: store.dispose
|
|
752
|
-
};
|
|
753
|
-
return {
|
|
754
|
-
store: readable,
|
|
755
|
-
setBaseUrl,
|
|
756
|
-
authenticate,
|
|
757
|
-
setProjectId,
|
|
758
|
-
clearProjectId,
|
|
759
|
-
reset,
|
|
760
|
-
applyRefresh,
|
|
761
|
-
forceExpire,
|
|
762
|
-
requireCredential,
|
|
763
|
-
getBaseUrl,
|
|
764
|
-
notifyExpired,
|
|
765
|
-
debug
|
|
766
|
-
};
|
|
593
|
+
//#endregion
|
|
594
|
+
//#region src/keboola/bearer/createConfig.ts
|
|
595
|
+
const INITIAL = {
|
|
596
|
+
status: "anonymous",
|
|
597
|
+
baseUrl: null
|
|
767
598
|
};
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
599
|
+
const stamp = (tokens) => ({
|
|
600
|
+
...tokens,
|
|
601
|
+
issuedAt: Date.now()
|
|
602
|
+
});
|
|
603
|
+
const createConfig$1 = (initial = INITIAL) => {
|
|
604
|
+
const store = createStore(initial);
|
|
605
|
+
let expiredNotified = false;
|
|
606
|
+
const setBaseUrl = (baseUrl) => {
|
|
607
|
+
if (store.get().status !== "anonymous") throw new KeboolaError(KeboolaErrorType.AlreadyAuthenticated);
|
|
608
|
+
store.set({
|
|
609
|
+
status: "anonymous",
|
|
610
|
+
baseUrl
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
const authenticate = (tokens) => {
|
|
614
|
+
const state = store.get();
|
|
615
|
+
if (state.status !== "anonymous") throw new KeboolaError(KeboolaErrorType.AlreadyAuthenticated);
|
|
616
|
+
if (!state.baseUrl) throw new KeboolaError(KeboolaErrorType.Unconfigured);
|
|
617
|
+
expiredNotified = false;
|
|
618
|
+
store.set({
|
|
619
|
+
status: "authenticated",
|
|
620
|
+
baseUrl: state.baseUrl,
|
|
621
|
+
credential: stamp(tokens)
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
const setProjectId = (projectId) => {
|
|
625
|
+
const state = store.get();
|
|
626
|
+
if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
627
|
+
store.set({
|
|
628
|
+
status: "scoped",
|
|
629
|
+
baseUrl: state.baseUrl,
|
|
630
|
+
credential: state.credential,
|
|
631
|
+
projectId
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* Drop the project scope, keeping the credential — the inverse of `setProjectId`, for leaving a
|
|
636
|
+
* project without signing out. The project clients are keyed on the scope, so they tear down and
|
|
637
|
+
* the storage build returns to `idle`; the session stays usable for `auth` and `management`.
|
|
638
|
+
* No-op unless currently scoped.
|
|
639
|
+
*/
|
|
640
|
+
const clearProjectId = () => {
|
|
641
|
+
const state = store.get();
|
|
642
|
+
if (state.status !== "scoped") return;
|
|
643
|
+
store.set({
|
|
644
|
+
status: "authenticated",
|
|
645
|
+
baseUrl: state.baseUrl,
|
|
646
|
+
credential: state.credential
|
|
647
|
+
});
|
|
648
|
+
};
|
|
649
|
+
/** Drop the credential (sign out); keeps the configured baseUrl. */
|
|
650
|
+
const reset = () => {
|
|
651
|
+
store.set({
|
|
652
|
+
status: "anonymous",
|
|
653
|
+
baseUrl: store.get().baseUrl
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
/** Apply a token refresh: replace the credential (fresh tokens, new issue time); no-op before auth. */
|
|
657
|
+
const applyRefresh = (tokens) => {
|
|
658
|
+
const state = store.get();
|
|
659
|
+
if (state.status === "anonymous") return;
|
|
660
|
+
store.set({
|
|
661
|
+
...state,
|
|
662
|
+
credential: stamp(tokens)
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Dev/test lever: backdate the current token's issue time by a full lifetime so it reads as
|
|
667
|
+
* expired, making the refresh policy rotate it on the next request. No-op before auth.
|
|
668
|
+
*/
|
|
669
|
+
const forceExpire = () => {
|
|
670
|
+
const state = store.get();
|
|
671
|
+
if (state.status === "anonymous") return;
|
|
672
|
+
const issuedAt = Date.now() - state.credential.expiresIn * 1e3;
|
|
673
|
+
store.set({
|
|
674
|
+
...state,
|
|
675
|
+
credential: {
|
|
676
|
+
...state.credential,
|
|
677
|
+
issuedAt
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* The current credential, asserting the session is authenticated (or scoped). Single point for that
|
|
683
|
+
* check so callers (token attach, refresh) don't each re-narrow the state.
|
|
684
|
+
*/
|
|
685
|
+
const requireCredential = () => {
|
|
686
|
+
const state = store.get();
|
|
687
|
+
if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
688
|
+
return state.credential;
|
|
689
|
+
};
|
|
690
|
+
const getBaseUrl = () => store.get().baseUrl;
|
|
691
|
+
/**
|
|
692
|
+
* Session-expiry latch (fire-once):
|
|
693
|
+
* - why: concurrent 401s all report expiry, but the app must sign out once; and the credential /
|
|
694
|
+
* auth middleware are long-lived singletons, so the latch can't live in them — it must reset
|
|
695
|
+
* per session.
|
|
696
|
+
* - how: returns `true` only for the first call since the last `authenticate` (which re-arms it),
|
|
697
|
+
* so the caller runs its sign-out exactly once per session death.
|
|
698
|
+
*/
|
|
699
|
+
const notifyExpired = () => {
|
|
700
|
+
if (expiredNotified) return false;
|
|
701
|
+
expiredNotified = true;
|
|
702
|
+
return true;
|
|
703
|
+
};
|
|
704
|
+
const debug = () => store.get();
|
|
705
|
+
return {
|
|
706
|
+
store: {
|
|
707
|
+
get: store.get,
|
|
708
|
+
subscribe: store.subscribe,
|
|
709
|
+
dispose: store.dispose
|
|
710
|
+
},
|
|
711
|
+
setBaseUrl,
|
|
712
|
+
authenticate,
|
|
713
|
+
setProjectId,
|
|
714
|
+
clearProjectId,
|
|
715
|
+
reset,
|
|
716
|
+
applyRefresh,
|
|
717
|
+
forceExpire,
|
|
718
|
+
requireCredential,
|
|
719
|
+
getBaseUrl,
|
|
720
|
+
notifyExpired,
|
|
721
|
+
debug
|
|
722
|
+
};
|
|
784
723
|
};
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/domain/defaultBranch.ts
|
|
726
|
+
const createDefaultBranch = ({ devBranches }) => {
|
|
727
|
+
const defaultBranch = devBranches.find((branch) => branch.isDefault);
|
|
728
|
+
assert(defaultBranch, "No default branch found for the project.");
|
|
729
|
+
const getType = (branchId) => {
|
|
730
|
+
if (branchId == null || branchId === "default") return "default";
|
|
731
|
+
return Number(branchId) === defaultBranch.id ? "default" : "dev";
|
|
732
|
+
};
|
|
733
|
+
return {
|
|
734
|
+
id: defaultBranch.id,
|
|
735
|
+
name: defaultBranch.name,
|
|
736
|
+
getType,
|
|
737
|
+
isDev: (branchId) => getType(branchId) === "dev",
|
|
738
|
+
isDefault: (branchId) => getType(branchId) === "default"
|
|
739
|
+
};
|
|
791
740
|
};
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region src/domain/stack.ts
|
|
743
|
+
const SERVICE_URL_OVERRIDES = { "kai-assistant": (url) => `${url}/api` };
|
|
744
|
+
const createStack = ({ stackInfo, clientServiceUrls }) => {
|
|
745
|
+
const { services, components, features, ...infoRest } = stackInfo;
|
|
746
|
+
const serviceMap = new Map(services.map((service) => {
|
|
747
|
+
const devOverride = clientServiceUrls?.[service.id]?.(service.url);
|
|
748
|
+
const prodOverride = SERVICE_URL_OVERRIDES[service.id]?.(service.url);
|
|
749
|
+
const url = devOverride ?? prodOverride ?? service.url;
|
|
750
|
+
return [service.id, url];
|
|
751
|
+
}));
|
|
752
|
+
const componentMap = new Map(components.map((component) => [component.id, component]));
|
|
753
|
+
const featureSet = new Set(features);
|
|
754
|
+
const hasFeature = (...feature) => {
|
|
755
|
+
if (feature.length === 0) return false;
|
|
756
|
+
return feature.every((x) => featureSet.has(x));
|
|
757
|
+
};
|
|
758
|
+
const hasComponent = (...componentId) => {
|
|
759
|
+
if (componentId.length === 0) return false;
|
|
760
|
+
return componentId.every((x) => componentMap.has(x));
|
|
761
|
+
};
|
|
762
|
+
const getComponent = (componentId) => componentMap.get(componentId) ?? null;
|
|
763
|
+
const hasService = (serviceId) => serviceMap.has(serviceId);
|
|
764
|
+
const getServiceUrl = (serviceId) => serviceMap.get(serviceId) ?? null;
|
|
765
|
+
return {
|
|
766
|
+
...infoRest,
|
|
767
|
+
services,
|
|
768
|
+
features,
|
|
769
|
+
components,
|
|
770
|
+
hasFeature,
|
|
771
|
+
getServiceUrl,
|
|
772
|
+
hasService,
|
|
773
|
+
getComponent,
|
|
774
|
+
hasComponent
|
|
775
|
+
};
|
|
826
776
|
};
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/sdks/variables/variablesSdk.ts
|
|
779
|
+
const VARIABLES_COMPONENT_ID = "keboola.variables";
|
|
780
|
+
/** Union the definitions by name; on a name conflict the target's definition is kept. */
|
|
781
|
+
const mergeVariableDefinitions = (target, source) => {
|
|
782
|
+
const targetNames = new Set(target.map((definition) => definition.name));
|
|
783
|
+
return [...target, ...source.filter((definition) => !targetNames.has(definition.name))];
|
|
833
784
|
};
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
];
|
|
785
|
+
/** Add values missing in the target; on a name conflict the value is updated to the source's. */
|
|
786
|
+
const mergeVariableValues = (target, source) => {
|
|
787
|
+
const sourceByName = new Map(source.map((value) => [value.name, value.value]));
|
|
788
|
+
const targetNames = new Set(target.map((value) => value.name));
|
|
789
|
+
return [...target.map((value) => sourceByName.has(value.name) ? {
|
|
790
|
+
...value,
|
|
791
|
+
value: sourceByName.get(value.name)
|
|
792
|
+
} : value), ...source.filter((value) => !targetNames.has(value.name))];
|
|
843
793
|
};
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const [target, source] = await Promise.all([
|
|
909
|
-
readVariables(targetVariablesId, targetValuesId, branchId),
|
|
910
|
-
readVariables(sourceVariablesId, sourceValuesId, branchId)
|
|
911
|
-
]);
|
|
912
|
-
return createVariables(
|
|
913
|
-
mergeVariableDefinitions(target.definitions, source.definitions),
|
|
914
|
-
mergeVariableValues(target.values, source.values),
|
|
915
|
-
branchId
|
|
916
|
-
);
|
|
917
|
-
}
|
|
918
|
-
};
|
|
794
|
+
/**
|
|
795
|
+
* Orchestration for `keboola.variables` configs: copy a config, or merge two configs into a fresh
|
|
796
|
+
* one (union definitions, upsert values — source wins on a name conflict). Each result is a brand
|
|
797
|
+
* new config + values row, so the caller can reference it without sharing lineage with the source.
|
|
798
|
+
*/
|
|
799
|
+
const createVariablesSdk = ({ storageClient }) => {
|
|
800
|
+
const configs = storageClient.configurations;
|
|
801
|
+
const rows = storageClient.configurationRows;
|
|
802
|
+
const readVariables = async (configId, valuesRowId, branchId) => {
|
|
803
|
+
const config = await configs.getConfiguration({
|
|
804
|
+
componentId: VARIABLES_COMPONENT_ID,
|
|
805
|
+
configId,
|
|
806
|
+
branchId
|
|
807
|
+
});
|
|
808
|
+
const row = config.rows.find((candidate) => candidate.id === valuesRowId) ?? config.rows[0];
|
|
809
|
+
const rawDefinitions = config.configuration?.variables;
|
|
810
|
+
const rawValues = row?.configuration?.values;
|
|
811
|
+
return {
|
|
812
|
+
definitions: Array.isArray(rawDefinitions) ? rawDefinitions : [],
|
|
813
|
+
values: Array.isArray(rawValues) ? rawValues : []
|
|
814
|
+
};
|
|
815
|
+
};
|
|
816
|
+
const createVariables = async (definitions, values, branchId) => {
|
|
817
|
+
const config = await configs.createConfiguration({
|
|
818
|
+
branchId,
|
|
819
|
+
componentId: VARIABLES_COMPONENT_ID,
|
|
820
|
+
name: "Variables definition",
|
|
821
|
+
configuration: { variables: definitions }
|
|
822
|
+
});
|
|
823
|
+
try {
|
|
824
|
+
const row = await rows.createConfigurationRow({
|
|
825
|
+
branchId: String(branchId),
|
|
826
|
+
componentId: VARIABLES_COMPONENT_ID,
|
|
827
|
+
configurationId: config.id,
|
|
828
|
+
name: "Default values",
|
|
829
|
+
configuration: { values }
|
|
830
|
+
});
|
|
831
|
+
return {
|
|
832
|
+
variablesId: config.id,
|
|
833
|
+
variablesValuesId: row.id
|
|
834
|
+
};
|
|
835
|
+
} catch (error) {
|
|
836
|
+
await configs.deleteConfiguration({
|
|
837
|
+
branchId,
|
|
838
|
+
componentId: VARIABLES_COMPONENT_ID,
|
|
839
|
+
configId: config.id
|
|
840
|
+
}).catch((cleanupError) => {
|
|
841
|
+
if (error instanceof Error && error.cause === void 0) error.cause = cleanupError;
|
|
842
|
+
});
|
|
843
|
+
throw error;
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
return {
|
|
847
|
+
/** Copy a variables config into a fresh, independent config + values row. */
|
|
848
|
+
copy: async ({ variablesId, variablesValuesId, branchId = "default" }) => {
|
|
849
|
+
const { definitions, values } = await readVariables(variablesId, variablesValuesId, branchId);
|
|
850
|
+
return createVariables(definitions, values, branchId);
|
|
851
|
+
},
|
|
852
|
+
/** Merge the source's variables into the target's and create a fresh merged config + values row. */
|
|
853
|
+
merge: async ({ targetVariablesId, targetValuesId, sourceVariablesId, sourceValuesId, branchId = "default" }) => {
|
|
854
|
+
const [target, source] = await Promise.all([readVariables(targetVariablesId, targetValuesId, branchId), readVariables(sourceVariablesId, sourceValuesId, branchId)]);
|
|
855
|
+
return createVariables(mergeVariableDefinitions(target.definitions, source.definitions), mergeVariableValues(target.values, source.values), branchId);
|
|
856
|
+
}
|
|
857
|
+
};
|
|
919
858
|
};
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
var userAgentSettingsSchema = z.object({
|
|
928
|
-
projectId: z.string(),
|
|
929
|
-
userId: z.string(),
|
|
930
|
-
customInstructions: z.string().nullable(),
|
|
931
|
-
toolPermissions: z.record(z.string(), toolPermissionValueSchema).nullable(),
|
|
932
|
-
createdAt: z.string(),
|
|
933
|
-
updatedAt: z.string()
|
|
934
|
-
});
|
|
935
|
-
var toolInfoSchema = z.object({
|
|
936
|
-
name: z.string(),
|
|
937
|
-
description: z.string(),
|
|
938
|
-
readOnly: z.boolean()
|
|
939
|
-
});
|
|
940
|
-
var toolsListResponseSchema = z.object({
|
|
941
|
-
tools: z.array(toolInfoSchema)
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/clients/kaiAgent/kaiAgentClient.ts
|
|
861
|
+
const agentSettingsSchema = z.object({
|
|
862
|
+
projectId: z.string(),
|
|
863
|
+
customInstructions: z.string().nullable(),
|
|
864
|
+
createdAt: z.string(),
|
|
865
|
+
updatedAt: z.string()
|
|
942
866
|
});
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
867
|
+
const toolPermissionValueSchema = z.enum([
|
|
868
|
+
"always_allow",
|
|
869
|
+
"always_ask",
|
|
870
|
+
"blocked"
|
|
871
|
+
]);
|
|
872
|
+
const userAgentSettingsSchema = z.object({
|
|
873
|
+
projectId: z.string(),
|
|
874
|
+
userId: z.string(),
|
|
875
|
+
customInstructions: z.string().nullable(),
|
|
876
|
+
toolPermissions: z.record(z.string(), toolPermissionValueSchema).nullable(),
|
|
877
|
+
createdAt: z.string(),
|
|
878
|
+
updatedAt: z.string()
|
|
947
879
|
});
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
880
|
+
const toolInfoSchema = z.object({
|
|
881
|
+
name: z.string(),
|
|
882
|
+
description: z.string(),
|
|
883
|
+
readOnly: z.boolean()
|
|
951
884
|
});
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
885
|
+
const toolsListResponseSchema = z.object({ tools: z.array(toolInfoSchema) });
|
|
886
|
+
const skillInfoSchema = z.object({
|
|
887
|
+
name: z.string(),
|
|
888
|
+
description: z.string().nullable(),
|
|
889
|
+
source: z.enum([
|
|
890
|
+
"first-party",
|
|
891
|
+
"vendored",
|
|
892
|
+
"project"
|
|
893
|
+
])
|
|
955
894
|
});
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
type: z.enum(["file", "dir"]),
|
|
960
|
-
size: z.number().int().nonnegative().optional()
|
|
895
|
+
const builtInCommandSchema = z.object({
|
|
896
|
+
name: z.string(),
|
|
897
|
+
description: z.string()
|
|
961
898
|
});
|
|
962
|
-
|
|
963
|
-
|
|
899
|
+
const skillsListResponseSchema = z.object({
|
|
900
|
+
skills: z.array(skillInfoSchema),
|
|
901
|
+
commands: z.array(builtInCommandSchema)
|
|
964
902
|
});
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
903
|
+
const sandboxFileEntrySchema = z.object({
|
|
904
|
+
name: z.string(),
|
|
905
|
+
path: z.string(),
|
|
906
|
+
type: z.enum(["file", "dir"]),
|
|
907
|
+
size: z.number().int().nonnegative().optional()
|
|
970
908
|
});
|
|
971
|
-
|
|
972
|
-
|
|
909
|
+
const sandboxFileListingSchema = z.object({ entries: z.array(sandboxFileEntrySchema) });
|
|
910
|
+
const sandboxFileContentSchema = z.object({
|
|
911
|
+
content: z.string(),
|
|
912
|
+
encoding: z.enum(["utf-8", "binary"]),
|
|
913
|
+
truncated: z.boolean(),
|
|
914
|
+
size: z.number().int().nonnegative()
|
|
973
915
|
});
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
)
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
{ signal }
|
|
1127
|
-
);
|
|
1128
|
-
const result = sandboxGitBranchSchema.safeParse(data);
|
|
1129
|
-
if (!result.success) {
|
|
1130
|
-
throw new Error("Invalid sandbox git-branch response format");
|
|
1131
|
-
}
|
|
1132
|
-
return result.data;
|
|
1133
|
-
};
|
|
1134
|
-
const chatStreamUrl = clientOptions.baseUrl + "/api/chat";
|
|
1135
|
-
const healthCheck = async (signal) => {
|
|
1136
|
-
const { data } = await genericClient.get("/health", {}, { signal });
|
|
1137
|
-
return data;
|
|
1138
|
-
};
|
|
1139
|
-
return {
|
|
1140
|
-
healthCheck,
|
|
1141
|
-
getHistory,
|
|
1142
|
-
getChat,
|
|
1143
|
-
deleteChat,
|
|
1144
|
-
createChat,
|
|
1145
|
-
getVotes,
|
|
1146
|
-
submitVote,
|
|
1147
|
-
getUsage,
|
|
1148
|
-
approveToolCall,
|
|
1149
|
-
submitToolOutput,
|
|
1150
|
-
stopChat,
|
|
1151
|
-
getSuggestions,
|
|
1152
|
-
getAgentSettings,
|
|
1153
|
-
updateAgentSettings,
|
|
1154
|
-
getUserAgentSettings,
|
|
1155
|
-
updateUserAgentSettings,
|
|
1156
|
-
getToolsList,
|
|
1157
|
-
getSkillsList,
|
|
1158
|
-
listSandboxFiles,
|
|
1159
|
-
readSandboxFile,
|
|
1160
|
-
getSandboxGitBranch,
|
|
1161
|
-
chatStreamUrl
|
|
1162
|
-
};
|
|
916
|
+
const sandboxGitBranchSchema = z.object({ branch: z.string().nullable() });
|
|
917
|
+
const votesResponseSchema = z.array(z.object({
|
|
918
|
+
chatId: z.string(),
|
|
919
|
+
messageId: z.string(),
|
|
920
|
+
isUpvoted: z.boolean()
|
|
921
|
+
}));
|
|
922
|
+
const createKaiAgentClient = ({ baseUrl, middlewares, auth }) => {
|
|
923
|
+
const clientOptions = {
|
|
924
|
+
baseUrl,
|
|
925
|
+
middlewares,
|
|
926
|
+
headers: createAuthHeaders(auth)
|
|
927
|
+
};
|
|
928
|
+
const client = createOpenapiFetchClient(clientOptions);
|
|
929
|
+
const genericClient = createGenericFetchClient(clientOptions);
|
|
930
|
+
const getHistory = async (params) => {
|
|
931
|
+
const { data } = await client.get("/api/history", { query: params });
|
|
932
|
+
return data;
|
|
933
|
+
};
|
|
934
|
+
const getChat = async (chatId, signal) => {
|
|
935
|
+
const { data } = await client.get("/api/chat/{id}", { path: { id: chatId } }, { signal });
|
|
936
|
+
return data;
|
|
937
|
+
};
|
|
938
|
+
const deleteChat = async (chatId) => {
|
|
939
|
+
const { data } = await client.delete("/api/chat", { query: { id: chatId } });
|
|
940
|
+
return data;
|
|
941
|
+
};
|
|
942
|
+
const createChat = async (request) => {
|
|
943
|
+
const { response } = await client.post("/api/chat", { body: request });
|
|
944
|
+
return response;
|
|
945
|
+
};
|
|
946
|
+
const getVotes = async (chatId) => {
|
|
947
|
+
const { data } = await client.get("/api/vote", { query: { chatId } });
|
|
948
|
+
const result = votesResponseSchema.safeParse(data);
|
|
949
|
+
if (!result.success) throw new Error("Invalid votes response format");
|
|
950
|
+
return result.data;
|
|
951
|
+
};
|
|
952
|
+
const submitVote = async (params) => {
|
|
953
|
+
await client.patch("/api/vote", { body: params });
|
|
954
|
+
};
|
|
955
|
+
const getUsage = async (signal) => {
|
|
956
|
+
const { data } = await client.get("/api/usage", {}, { signal });
|
|
957
|
+
return data;
|
|
958
|
+
};
|
|
959
|
+
const approveToolCall = async (chatId, body) => {
|
|
960
|
+
await client.post("/api/chat/{id}/approval", {
|
|
961
|
+
path: { id: chatId },
|
|
962
|
+
body
|
|
963
|
+
});
|
|
964
|
+
};
|
|
965
|
+
const submitToolOutput = async (chatId, body) => {
|
|
966
|
+
await client.post("/api/chat/{id}/ui-tool-result", {
|
|
967
|
+
path: { id: chatId },
|
|
968
|
+
body
|
|
969
|
+
});
|
|
970
|
+
};
|
|
971
|
+
const stopChat = async (chatId) => {
|
|
972
|
+
const { data } = await client.post("/api/chat/{id}/stop", { path: { id: chatId } });
|
|
973
|
+
return data;
|
|
974
|
+
};
|
|
975
|
+
const getSuggestions = async (request, signal) => {
|
|
976
|
+
const { data } = await client.post("/api/suggestions", { body: request }, { signal });
|
|
977
|
+
return data;
|
|
978
|
+
};
|
|
979
|
+
const getAgentSettings = async (signal) => {
|
|
980
|
+
const { data } = await genericClient.get("/api/settings", {}, { signal });
|
|
981
|
+
const result = agentSettingsSchema.safeParse(data);
|
|
982
|
+
if (!result.success) throw new Error("Invalid agent settings response format");
|
|
983
|
+
return result.data;
|
|
984
|
+
};
|
|
985
|
+
const updateAgentSettings = async (request, signal) => {
|
|
986
|
+
const { data } = await genericClient.patch("/api/settings", { body: request }, { signal });
|
|
987
|
+
const result = agentSettingsSchema.safeParse(data);
|
|
988
|
+
if (!result.success) throw new Error("Invalid agent settings response format");
|
|
989
|
+
return result.data;
|
|
990
|
+
};
|
|
991
|
+
const getUserAgentSettings = async (signal) => {
|
|
992
|
+
const { data } = await genericClient.get("/api/settings/user", {}, { signal });
|
|
993
|
+
const result = userAgentSettingsSchema.safeParse(data);
|
|
994
|
+
if (!result.success) throw new Error("Invalid user agent settings response format");
|
|
995
|
+
return result.data;
|
|
996
|
+
};
|
|
997
|
+
const updateUserAgentSettings = async (request, signal) => {
|
|
998
|
+
const { data } = await genericClient.patch("/api/settings/user", { body: request }, { signal });
|
|
999
|
+
const result = userAgentSettingsSchema.safeParse(data);
|
|
1000
|
+
if (!result.success) throw new Error("Invalid user agent settings response format");
|
|
1001
|
+
return result.data;
|
|
1002
|
+
};
|
|
1003
|
+
const getToolsList = async (signal) => {
|
|
1004
|
+
const { data } = await genericClient.get("/api/settings/tools", {}, { signal });
|
|
1005
|
+
const result = toolsListResponseSchema.safeParse(data);
|
|
1006
|
+
if (!result.success) throw new Error("Invalid tools list response format");
|
|
1007
|
+
return result.data;
|
|
1008
|
+
};
|
|
1009
|
+
const getSkillsList = async (signal) => {
|
|
1010
|
+
const { data } = await genericClient.get("/api/skills", {}, { signal });
|
|
1011
|
+
const result = skillsListResponseSchema.safeParse(data);
|
|
1012
|
+
if (!result.success) throw new Error("Invalid skills list response format");
|
|
1013
|
+
return result.data;
|
|
1014
|
+
};
|
|
1015
|
+
const listSandboxFiles = async (chatId, path, signal) => {
|
|
1016
|
+
const { data } = await genericClient.get(`/api/chat/${encodeURIComponent(chatId)}/sandbox/files`, { query: path ? { path } : void 0 }, { signal });
|
|
1017
|
+
const result = sandboxFileListingSchema.safeParse(data);
|
|
1018
|
+
if (!result.success) throw new Error("Invalid sandbox files response format");
|
|
1019
|
+
return result.data;
|
|
1020
|
+
};
|
|
1021
|
+
const readSandboxFile = async (chatId, path, signal) => {
|
|
1022
|
+
const { data } = await genericClient.get(`/api/chat/${encodeURIComponent(chatId)}/sandbox/file`, { query: { path } }, { signal });
|
|
1023
|
+
const result = sandboxFileContentSchema.safeParse(data);
|
|
1024
|
+
if (!result.success) throw new Error("Invalid sandbox file response format");
|
|
1025
|
+
return result.data;
|
|
1026
|
+
};
|
|
1027
|
+
const downloadSandboxFile = async (chatId, path, signal) => {
|
|
1028
|
+
const { data } = await genericClient.get(`/api/chat/${encodeURIComponent(chatId)}/sandbox/file/download`, { query: { path } }, { signal });
|
|
1029
|
+
if (!(data instanceof Blob)) throw new Error("Invalid sandbox file download response format");
|
|
1030
|
+
return data;
|
|
1031
|
+
};
|
|
1032
|
+
const getSandboxGitBranch = async (chatId, signal) => {
|
|
1033
|
+
const { data } = await genericClient.get(`/api/chat/${encodeURIComponent(chatId)}/sandbox/git-branch`, {}, { signal });
|
|
1034
|
+
const result = sandboxGitBranchSchema.safeParse(data);
|
|
1035
|
+
if (!result.success) throw new Error("Invalid sandbox git-branch response format");
|
|
1036
|
+
return result.data;
|
|
1037
|
+
};
|
|
1038
|
+
const chatStreamUrl = clientOptions.baseUrl + "/api/chat";
|
|
1039
|
+
const healthCheck = async (signal) => {
|
|
1040
|
+
const { data } = await genericClient.get("/health", {}, { signal });
|
|
1041
|
+
return data;
|
|
1042
|
+
};
|
|
1043
|
+
return {
|
|
1044
|
+
healthCheck,
|
|
1045
|
+
getHistory,
|
|
1046
|
+
getChat,
|
|
1047
|
+
deleteChat,
|
|
1048
|
+
createChat,
|
|
1049
|
+
getVotes,
|
|
1050
|
+
submitVote,
|
|
1051
|
+
getUsage,
|
|
1052
|
+
approveToolCall,
|
|
1053
|
+
submitToolOutput,
|
|
1054
|
+
stopChat,
|
|
1055
|
+
getSuggestions,
|
|
1056
|
+
getAgentSettings,
|
|
1057
|
+
updateAgentSettings,
|
|
1058
|
+
getUserAgentSettings,
|
|
1059
|
+
updateUserAgentSettings,
|
|
1060
|
+
getToolsList,
|
|
1061
|
+
getSkillsList,
|
|
1062
|
+
listSandboxFiles,
|
|
1063
|
+
readSandboxFile,
|
|
1064
|
+
downloadSandboxFile,
|
|
1065
|
+
getSandboxGitBranch,
|
|
1066
|
+
chatStreamUrl
|
|
1067
|
+
};
|
|
1163
1068
|
};
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
attachTokenMiddleware
|
|
1172
|
-
}) => createServiceClientRegistry()({
|
|
1173
|
-
getServiceBaseUrl,
|
|
1174
|
-
onUnavailable: ({ serviceId, path, clientName }) => {
|
|
1175
|
-
throw new ServiceUnavailableError(serviceId, path, clientName);
|
|
1176
|
-
}
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#region src/keboola/createServiceClients.ts
|
|
1071
|
+
const createServiceClients = ({ baseUrl, auth, getServiceBaseUrl, middlewareFor, attachTokenMiddleware }) => createServiceClientRegistry()({
|
|
1072
|
+
getServiceBaseUrl,
|
|
1073
|
+
onUnavailable: ({ serviceId, path, clientName }) => {
|
|
1074
|
+
throw new ServiceUnavailableError(serviceId, path, clientName);
|
|
1075
|
+
}
|
|
1177
1076
|
}).add({
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1077
|
+
serviceId: "vault",
|
|
1078
|
+
clientName: "vault",
|
|
1079
|
+
clientFn: (serviceBaseUrl) => createVaultClient({
|
|
1080
|
+
baseUrl: serviceBaseUrl,
|
|
1081
|
+
middlewares: middlewareFor("vault", [attachTokenMiddleware]),
|
|
1082
|
+
auth
|
|
1083
|
+
})
|
|
1185
1084
|
}).add({
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1085
|
+
serviceId: "data-science",
|
|
1086
|
+
clientName: "dataScience",
|
|
1087
|
+
clientFn: (serviceBaseUrl) => createDataScienceClient({
|
|
1088
|
+
baseUrl: serviceBaseUrl,
|
|
1089
|
+
middlewares: middlewareFor("dataScience", [attachTokenMiddleware]),
|
|
1090
|
+
auth
|
|
1091
|
+
})
|
|
1193
1092
|
}).add({
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
clientName: "apps",
|
|
1202
|
-
clientFn: (serviceBaseUrl) => createAppsClient({
|
|
1203
|
-
baseUrl: `${serviceBaseUrl}/v2`,
|
|
1204
|
-
middlewares: middlewareFor("apps", [attachTokenMiddleware]),
|
|
1205
|
-
auth
|
|
1206
|
-
})
|
|
1093
|
+
serviceId: "data-science",
|
|
1094
|
+
clientName: "apps",
|
|
1095
|
+
clientFn: (serviceBaseUrl) => createAppsClient({
|
|
1096
|
+
baseUrl: `${serviceBaseUrl}/v2`,
|
|
1097
|
+
middlewares: middlewareFor("apps", [attachTokenMiddleware]),
|
|
1098
|
+
auth
|
|
1099
|
+
})
|
|
1207
1100
|
}).add({
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1101
|
+
serviceId: "encryption",
|
|
1102
|
+
clientName: "encryption",
|
|
1103
|
+
clientFn: (serviceBaseUrl) => createEncryptionClient({
|
|
1104
|
+
baseUrl: serviceBaseUrl,
|
|
1105
|
+
middlewares: middlewareFor("encryption")
|
|
1106
|
+
})
|
|
1214
1107
|
}).add({
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1108
|
+
serviceId: "editor",
|
|
1109
|
+
clientName: "editor",
|
|
1110
|
+
clientFn: (serviceBaseUrl) => createEditorClient({
|
|
1111
|
+
baseUrl: serviceBaseUrl,
|
|
1112
|
+
middlewares: middlewareFor("editor", [attachTokenMiddleware]),
|
|
1113
|
+
auth
|
|
1114
|
+
})
|
|
1222
1115
|
}).add({
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1116
|
+
serviceId: "sync-actions",
|
|
1117
|
+
clientName: "syncActions",
|
|
1118
|
+
clientFn: (serviceBaseUrl) => createSyncActionsClient({
|
|
1119
|
+
baseUrl: serviceBaseUrl,
|
|
1120
|
+
middlewares: middlewareFor("syncActions", [attachTokenMiddleware]),
|
|
1121
|
+
auth
|
|
1122
|
+
})
|
|
1230
1123
|
}).add({
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1124
|
+
serviceId: "telemetry",
|
|
1125
|
+
clientName: "telemetry",
|
|
1126
|
+
clientFn: (serviceBaseUrl) => createTelemetryClient({
|
|
1127
|
+
baseUrl: serviceBaseUrl,
|
|
1128
|
+
middlewares: middlewareFor("telemetry", [attachTokenMiddleware]),
|
|
1129
|
+
auth
|
|
1130
|
+
})
|
|
1238
1131
|
}).add({
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1132
|
+
serviceId: "query",
|
|
1133
|
+
clientName: "queryService",
|
|
1134
|
+
clientFn: (serviceBaseUrl) => createQueryServiceClient({
|
|
1135
|
+
baseUrl: serviceBaseUrl,
|
|
1136
|
+
middlewares: middlewareFor("queryService", [attachTokenMiddleware]),
|
|
1137
|
+
auth
|
|
1138
|
+
})
|
|
1246
1139
|
}).add({
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1140
|
+
serviceId: "queue",
|
|
1141
|
+
clientName: "queue",
|
|
1142
|
+
clientFn: (serviceBaseUrl) => createQueueClient({
|
|
1143
|
+
baseUrl: serviceBaseUrl,
|
|
1144
|
+
middlewares: middlewareFor("queue", [attachTokenMiddleware]),
|
|
1145
|
+
auth
|
|
1146
|
+
})
|
|
1254
1147
|
}).add({
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1148
|
+
serviceId: "kai-assistant",
|
|
1149
|
+
clientName: "chat",
|
|
1150
|
+
clientFn: (serviceBaseUrl) => createChatClient({
|
|
1151
|
+
storageApiUrl: baseUrl,
|
|
1152
|
+
baseUrl: serviceBaseUrl,
|
|
1153
|
+
middlewares: middlewareFor("chat", [attachTokenMiddleware]),
|
|
1154
|
+
auth
|
|
1155
|
+
})
|
|
1263
1156
|
}).add({
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1157
|
+
serviceId: "ai",
|
|
1158
|
+
clientName: "ai",
|
|
1159
|
+
clientFn: (serviceBaseUrl) => createAiClient({
|
|
1160
|
+
baseUrl: serviceBaseUrl,
|
|
1161
|
+
middlewares: middlewareFor("ai", [attachTokenMiddleware]),
|
|
1162
|
+
auth
|
|
1163
|
+
})
|
|
1271
1164
|
}).add({
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
middlewares: middlewareFor("omnisearch", [attachTokenMiddleware]),
|
|
1280
|
-
auth
|
|
1281
|
-
})
|
|
1165
|
+
serviceId: "ai",
|
|
1166
|
+
clientName: "omnisearch",
|
|
1167
|
+
clientFn: (serviceBaseUrl) => createOmnisearchClient({
|
|
1168
|
+
baseUrl: `${serviceBaseUrl}/omnisearch`,
|
|
1169
|
+
middlewares: middlewareFor("omnisearch", [attachTokenMiddleware]),
|
|
1170
|
+
auth
|
|
1171
|
+
})
|
|
1282
1172
|
}).add({
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1173
|
+
serviceId: "import",
|
|
1174
|
+
clientName: "import",
|
|
1175
|
+
clientFn: (serviceBaseUrl) => createImportClient({
|
|
1176
|
+
baseUrl: serviceBaseUrl,
|
|
1177
|
+
middlewares: middlewareFor("import", [attachTokenMiddleware]),
|
|
1178
|
+
auth
|
|
1179
|
+
})
|
|
1290
1180
|
}).add({
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1181
|
+
serviceId: "kai-agent",
|
|
1182
|
+
clientName: "kaiAgent",
|
|
1183
|
+
clientFn: (serviceBaseUrl) => createKaiAgentClient({
|
|
1184
|
+
baseUrl: serviceBaseUrl,
|
|
1185
|
+
middlewares: middlewareFor("kaiAgent", [attachTokenMiddleware]),
|
|
1186
|
+
auth
|
|
1187
|
+
})
|
|
1298
1188
|
}).add({
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1189
|
+
serviceId: "oauth",
|
|
1190
|
+
clientName: "oauth",
|
|
1191
|
+
clientFn: (serviceBaseUrl) => createOauthClient({
|
|
1192
|
+
baseUrl: serviceBaseUrl,
|
|
1193
|
+
middlewares: middlewareFor("oauth", [attachTokenMiddleware]),
|
|
1194
|
+
auth
|
|
1195
|
+
})
|
|
1306
1196
|
}).add({
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1197
|
+
serviceId: "scheduler",
|
|
1198
|
+
clientName: "scheduler",
|
|
1199
|
+
clientFn: (serviceBaseUrl) => createSchedulerClient({
|
|
1200
|
+
baseUrl: serviceBaseUrl,
|
|
1201
|
+
middlewares: middlewareFor("scheduler", [attachTokenMiddleware]),
|
|
1202
|
+
auth
|
|
1203
|
+
})
|
|
1314
1204
|
}).add({
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1205
|
+
serviceId: "stream",
|
|
1206
|
+
clientName: "stream",
|
|
1207
|
+
clientFn: (serviceBaseUrl) => createStreamClient({
|
|
1208
|
+
baseUrl: serviceBaseUrl,
|
|
1209
|
+
middlewares: middlewareFor("stream", [attachTokenMiddleware]),
|
|
1210
|
+
auth
|
|
1211
|
+
})
|
|
1322
1212
|
}).add({
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1213
|
+
serviceId: "notification",
|
|
1214
|
+
clientName: "notifications",
|
|
1215
|
+
clientFn: (serviceBaseUrl) => createNotificationsClient({
|
|
1216
|
+
baseUrl: serviceBaseUrl,
|
|
1217
|
+
middlewares: middlewareFor("notifications", [attachTokenMiddleware]),
|
|
1218
|
+
auth
|
|
1219
|
+
})
|
|
1330
1220
|
}).add({
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1221
|
+
serviceId: "metastore",
|
|
1222
|
+
clientName: "metastore",
|
|
1223
|
+
clientFn: (serviceBaseUrl) => createMetastoreClient({
|
|
1224
|
+
baseUrl: serviceBaseUrl,
|
|
1225
|
+
middlewares: middlewareFor("metastore", [attachTokenMiddleware]),
|
|
1226
|
+
auth
|
|
1227
|
+
})
|
|
1338
1228
|
}).build();
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
const snapshot = getToken();
|
|
1434
|
-
if (snapshot === null) return null;
|
|
1435
|
-
const { accessToken, timing } = snapshot;
|
|
1436
|
-
if (forceRefresh) return refreshShared();
|
|
1437
|
-
if (Date.now() < refreshAt(timing)) return accessToken;
|
|
1438
|
-
return refreshShared().catch(() => accessToken);
|
|
1439
|
-
};
|
|
1440
|
-
return { getAccessToken, notifyExpired: () => onSessionExpired?.() };
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/keboola/bearer/createProjectClients.ts
|
|
1231
|
+
/**
|
|
1232
|
+
* Bearer (OAuth) project surface. Same handshake + assembly as the legacy build. The
|
|
1233
|
+
* `Authorization: Bearer` header + transparent refresh come from the engine-shared `authMiddleware`
|
|
1234
|
+
* (one instance for management + every project client). This build only adds the project-scoped
|
|
1235
|
+
* `X-KBC-ProjectId` header, composed *outside* the auth middleware so the header is present
|
|
1236
|
+
* before it clones the request for the 401 replay. Bearer has no static token header, so this
|
|
1237
|
+
* combined `attach` rides on every client — including the operational storage and the bootstrap reader.
|
|
1238
|
+
*/
|
|
1239
|
+
const createProjectClients$1 = async ({ baseUrl, projectId, authMiddleware, middlewareFor, clientServiceUrls }) => {
|
|
1240
|
+
const auth = {
|
|
1241
|
+
type: "bearer",
|
|
1242
|
+
token: "",
|
|
1243
|
+
projectId
|
|
1244
|
+
};
|
|
1245
|
+
const projectIdMiddleware = (next) => (request) => {
|
|
1246
|
+
request.request.headers.set(KeboolaHttpHeader.PROJECT_ID, String(projectId));
|
|
1247
|
+
return next(request);
|
|
1248
|
+
};
|
|
1249
|
+
const attach = (next) => projectIdMiddleware(authMiddleware(next));
|
|
1250
|
+
const reader = createStorageClient({
|
|
1251
|
+
baseUrl,
|
|
1252
|
+
auth,
|
|
1253
|
+
middlewares: [attach]
|
|
1254
|
+
});
|
|
1255
|
+
const [stackInfo, sapiToken, devBranches] = await Promise.all([
|
|
1256
|
+
reader.getStackInfo({ exclude: "componentDetails" }),
|
|
1257
|
+
reader.tokens.verify(),
|
|
1258
|
+
reader.branches.getDevBranches()
|
|
1259
|
+
]);
|
|
1260
|
+
const stack = createStack({
|
|
1261
|
+
stackInfo,
|
|
1262
|
+
clientServiceUrls
|
|
1263
|
+
});
|
|
1264
|
+
const defaultBranch = createDefaultBranch({ devBranches });
|
|
1265
|
+
const liveProject = createLiveProject({
|
|
1266
|
+
initialToken: sapiToken,
|
|
1267
|
+
verify: () => reader.tokens.verify()
|
|
1268
|
+
});
|
|
1269
|
+
const storageTableStore = createDerivedStore({
|
|
1270
|
+
source: liveProject.store,
|
|
1271
|
+
build: createStorageTable,
|
|
1272
|
+
dependsOn: (project) => ({
|
|
1273
|
+
useLegacyBucketPrefix: !project.hasFeature(ProjectFeature.DisableLegacyBucketPrefix),
|
|
1274
|
+
hasProtectedDefaultBranch: project.hasFeature(ProjectFeature.SoxProtectedDefaultBranch),
|
|
1275
|
+
hasStorageBranches: project.hasFeature(ProjectFeature.StorageBranches)
|
|
1276
|
+
})
|
|
1277
|
+
});
|
|
1278
|
+
const context = {
|
|
1279
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
1280
|
+
stack,
|
|
1281
|
+
defaultBranch,
|
|
1282
|
+
get project() {
|
|
1283
|
+
return liveProject.getProject();
|
|
1284
|
+
},
|
|
1285
|
+
get st() {
|
|
1286
|
+
return storageTableStore.get();
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
const storage = createStorageClient({
|
|
1290
|
+
baseUrl,
|
|
1291
|
+
auth,
|
|
1292
|
+
middlewares: middlewareFor("storage", [attach, liveProject.middleware])
|
|
1293
|
+
});
|
|
1294
|
+
const { client: services, meta: serviceMeta } = createServiceClients({
|
|
1295
|
+
baseUrl,
|
|
1296
|
+
auth,
|
|
1297
|
+
getServiceBaseUrl: context.stack.getServiceUrl,
|
|
1298
|
+
middlewareFor,
|
|
1299
|
+
attachTokenMiddleware: attach
|
|
1300
|
+
});
|
|
1301
|
+
const sdk = {
|
|
1302
|
+
configuration: createConfigurationSdk({
|
|
1303
|
+
storageClient: storage,
|
|
1304
|
+
encryptionClient: services.encryption,
|
|
1305
|
+
context
|
|
1306
|
+
}),
|
|
1307
|
+
tag: createTagSdk({ metastoreClient: services.metastore }),
|
|
1308
|
+
semanticLayer: createSemanticLayerSdk({ metastoreClient: services.metastore }),
|
|
1309
|
+
storage: createStorageSdk({ storageClient: storage }),
|
|
1310
|
+
vault: createVaultSdk({
|
|
1311
|
+
vaultClient: services.vault,
|
|
1312
|
+
encryptionClient: services.encryption
|
|
1313
|
+
}),
|
|
1314
|
+
variables: createVariablesSdk({ storageClient: storage })
|
|
1315
|
+
};
|
|
1316
|
+
return {
|
|
1317
|
+
context,
|
|
1318
|
+
serviceMeta,
|
|
1319
|
+
storage,
|
|
1320
|
+
...services,
|
|
1321
|
+
sdk
|
|
1322
|
+
};
|
|
1441
1323
|
};
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1324
|
+
//#endregion
|
|
1325
|
+
//#region src/keboola/bearer/middleware.ts
|
|
1326
|
+
/**
|
|
1327
|
+
* Bearer auth for every outgoing request:
|
|
1328
|
+
* - Stamps the current access token (from the credential) as the `Authorization` header.
|
|
1329
|
+
* - On a 401, force-refreshes the token and replays the request once.
|
|
1330
|
+
* - If the replay still 401s, the fresh token is rejected → marks the session expired.
|
|
1331
|
+
*
|
|
1332
|
+
* When the session is anonymous (`getAccessToken` → `null`) the request is passed through untouched
|
|
1333
|
+
* with no 401 dance — so pre-auth calls on the auth client (`login`, `refresh`) work and a failed
|
|
1334
|
+
* login is never mistaken for session expiry.
|
|
1335
|
+
*
|
|
1336
|
+
* Holds no token and never touches config — all token and refresh state lives in the credential.
|
|
1337
|
+
*/
|
|
1338
|
+
const createBearerAuthMiddleware = (credential) => {
|
|
1339
|
+
return (next) => async (request) => {
|
|
1340
|
+
const token = await credential.getAccessToken({ forceRefresh: false });
|
|
1341
|
+
if (token === null) return next(request);
|
|
1342
|
+
const retryRequest = request.request.clone();
|
|
1343
|
+
request.request.headers.set(HttpHeader.AUTHORIZATION, `Bearer ${token}`);
|
|
1344
|
+
try {
|
|
1345
|
+
return await next(request);
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
if (!isUnauthorized(error)) throw error;
|
|
1348
|
+
const refreshed = await credential.getAccessToken({ forceRefresh: true });
|
|
1349
|
+
if (refreshed === null) throw error;
|
|
1350
|
+
retryRequest.headers.set(HttpHeader.AUTHORIZATION, `Bearer ${refreshed}`);
|
|
1351
|
+
try {
|
|
1352
|
+
return await next({
|
|
1353
|
+
...request,
|
|
1354
|
+
request: retryRequest
|
|
1355
|
+
});
|
|
1356
|
+
} catch (retryError) {
|
|
1357
|
+
if (isUnauthorized(retryError)) credential.notifyExpired();
|
|
1358
|
+
throw retryError;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1465
1362
|
};
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1363
|
+
//#endregion
|
|
1364
|
+
//#region src/keboola/bearer/persistor.ts
|
|
1365
|
+
const SESSION_KEY = "keboola:bearer-session";
|
|
1366
|
+
const persistedSessionSchema = z$1.object({
|
|
1367
|
+
baseUrl: z$1.string().nullable(),
|
|
1368
|
+
projectId: z$1.number().nullable(),
|
|
1369
|
+
refreshToken: z$1.string().nullable()
|
|
1471
1370
|
});
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1371
|
+
const EMPTY_PERSISTED_SESSION = {
|
|
1372
|
+
baseUrl: null,
|
|
1373
|
+
projectId: null,
|
|
1374
|
+
refreshToken: null
|
|
1476
1375
|
};
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1376
|
+
const createSessionPersistor = (storage) => createPersistor({
|
|
1377
|
+
storage,
|
|
1378
|
+
key: SESSION_KEY,
|
|
1379
|
+
schema: persistedSessionSchema,
|
|
1380
|
+
defaultValue: EMPTY_PERSISTED_SESSION
|
|
1482
1381
|
});
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1382
|
+
//#endregion
|
|
1383
|
+
//#region src/keboola/bearer/keboola.ts
|
|
1384
|
+
const createKeboola = (options = {}) => {
|
|
1385
|
+
const persistor = createSessionPersistor(options.storage);
|
|
1386
|
+
const config = createConfig$1();
|
|
1387
|
+
const middlewareFor = createMiddlewareFor(options.middlewares);
|
|
1388
|
+
const retryContention = createRetryMiddleware({ shouldRetry: (error) => error instanceof ApiError && error.response.status === HttpStatus.SERVICE_UNAVAILABLE });
|
|
1389
|
+
const authClientBare = createDerivedStore({
|
|
1390
|
+
source: config.store,
|
|
1391
|
+
dependsOn: (state) => state.baseUrl,
|
|
1392
|
+
build: (baseUrl) => baseUrl ? createAuthClient({
|
|
1393
|
+
baseUrl,
|
|
1394
|
+
middlewares: middlewareFor("auth", [retryContention])
|
|
1395
|
+
}) : null
|
|
1396
|
+
});
|
|
1397
|
+
const refresh = async () => {
|
|
1398
|
+
const client = authClientBare.get();
|
|
1399
|
+
assert$1(client, KeboolaErrorType.NotReady);
|
|
1400
|
+
const refreshed = await client.token.refresh(config.requireCredential().refreshToken);
|
|
1401
|
+
config.applyRefresh(refreshed);
|
|
1402
|
+
return refreshed.accessToken;
|
|
1403
|
+
};
|
|
1404
|
+
const getToken = () => {
|
|
1405
|
+
const state = config.store.get();
|
|
1406
|
+
if (state.status === "anonymous") return null;
|
|
1407
|
+
const { accessToken, issuedAt, expiresIn } = state.credential;
|
|
1408
|
+
return {
|
|
1409
|
+
accessToken,
|
|
1410
|
+
timing: {
|
|
1411
|
+
issuedAt,
|
|
1412
|
+
expiresIn
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
};
|
|
1416
|
+
const signOut = () => {
|
|
1417
|
+
config.reset();
|
|
1418
|
+
persistor.clear();
|
|
1419
|
+
};
|
|
1420
|
+
const onSessionExpired = () => {
|
|
1421
|
+
if (config.notifyExpired()) signOut();
|
|
1422
|
+
};
|
|
1423
|
+
const credential = createBearerCredential({
|
|
1424
|
+
refresh,
|
|
1425
|
+
getToken,
|
|
1426
|
+
onSessionExpired
|
|
1427
|
+
});
|
|
1428
|
+
const authMiddleware = createBearerAuthMiddleware(credential);
|
|
1429
|
+
const authClient = createDerivedStore({
|
|
1430
|
+
source: config.store,
|
|
1431
|
+
dependsOn: (state) => state.baseUrl,
|
|
1432
|
+
build: (baseUrl) => baseUrl ? createAuthClient({
|
|
1433
|
+
baseUrl,
|
|
1434
|
+
middlewares: middlewareFor("auth", [retryContention, authMiddleware])
|
|
1435
|
+
}) : null
|
|
1436
|
+
});
|
|
1437
|
+
const management = createDerivedStore({
|
|
1438
|
+
source: config.store,
|
|
1439
|
+
dependsOn: (state) => state.status === "anonymous" ? null : state.baseUrl,
|
|
1440
|
+
build: (baseUrl) => baseUrl ? createManagementClient({
|
|
1441
|
+
baseUrl,
|
|
1442
|
+
auth: {
|
|
1443
|
+
type: "bearer",
|
|
1444
|
+
token: ""
|
|
1445
|
+
},
|
|
1446
|
+
middlewares: middlewareFor("management", [authMiddleware])
|
|
1447
|
+
}) : null
|
|
1448
|
+
});
|
|
1449
|
+
const projectClientsAsync = createDerivedAsyncStore({
|
|
1450
|
+
source: config.store,
|
|
1451
|
+
dependsOn: (state) => state.status === "scoped" ? {
|
|
1452
|
+
baseUrl: state.baseUrl,
|
|
1453
|
+
projectId: state.projectId
|
|
1454
|
+
} : null,
|
|
1455
|
+
build: ({ baseUrl, projectId }) => {
|
|
1456
|
+
return createProjectClients$1({
|
|
1457
|
+
baseUrl,
|
|
1458
|
+
authMiddleware,
|
|
1459
|
+
projectId,
|
|
1460
|
+
middlewareFor,
|
|
1461
|
+
clientServiceUrls: options.clientServiceUrls
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
if (options.baseUrl) config.setBaseUrl(options.baseUrl);
|
|
1466
|
+
config.store.subscribe((state) => {
|
|
1467
|
+
if (state.status === "anonymous") return;
|
|
1468
|
+
persistor.persist({
|
|
1469
|
+
baseUrl: state.baseUrl,
|
|
1470
|
+
projectId: state.status === "scoped" ? state.projectId : null,
|
|
1471
|
+
refreshToken: state.credential.refreshToken
|
|
1472
|
+
});
|
|
1473
|
+
});
|
|
1474
|
+
const debug = () => ({
|
|
1475
|
+
type: "Bearer",
|
|
1476
|
+
config: config.debug(),
|
|
1477
|
+
authReady: authClient.get() !== null,
|
|
1478
|
+
managementReady: management.get() !== null,
|
|
1479
|
+
storage: projectClientsAsync.store.get().state
|
|
1480
|
+
});
|
|
1481
|
+
const session = {
|
|
1482
|
+
hasPersistedValue: persistor.hasPersistedValue,
|
|
1483
|
+
setBaseUrl: config.setBaseUrl,
|
|
1484
|
+
isStorageReady: () => projectClientsAsync.store.get().state === "ready",
|
|
1485
|
+
authenticate: (tokens) => config.authenticate(tokens),
|
|
1486
|
+
setProject: config.setProjectId,
|
|
1487
|
+
setProjectAsync: async (projectId) => {
|
|
1488
|
+
config.setProjectId(projectId);
|
|
1489
|
+
await projectClientsAsync.settled();
|
|
1490
|
+
},
|
|
1491
|
+
/**
|
|
1492
|
+
* Leave the current project but stay signed in — the storage build returns to `idle`, so a
|
|
1493
|
+
* consumer gating on it falls back to its project picker. The persisted session is rewritten with
|
|
1494
|
+
* `projectId: null` by the subscription above, so a reload lands on the picker rather than
|
|
1495
|
+
* re-entering the project. Use `reset` to sign out instead.
|
|
1496
|
+
*/
|
|
1497
|
+
clearProject: config.clearProjectId,
|
|
1498
|
+
reset: signOut,
|
|
1499
|
+
/**
|
|
1500
|
+
* Dev/test only: mark the current access token as expired so the bearer credential rotates it on
|
|
1501
|
+
* the next request. Pair with any authenticated call (e.g. `api.storage.tokens.verify()`) to force
|
|
1502
|
+
* the rotation immediately and observe the new credential.
|
|
1503
|
+
*/
|
|
1504
|
+
debugForceRefresh: config.forceExpire,
|
|
1505
|
+
restore: async () => {
|
|
1506
|
+
const persisted = persistor.hydrate();
|
|
1507
|
+
if (!persisted.refreshToken || !persisted.baseUrl) return { status: "empty" };
|
|
1508
|
+
const configured = config.getBaseUrl();
|
|
1509
|
+
if (configured && configured !== persisted.baseUrl) {
|
|
1510
|
+
persistor.clear();
|
|
1511
|
+
return { status: "empty" };
|
|
1512
|
+
}
|
|
1513
|
+
if (!configured) config.setBaseUrl(persisted.baseUrl);
|
|
1514
|
+
const client = authClientBare.get();
|
|
1515
|
+
assert$1(client, KeboolaErrorType.NotReady);
|
|
1516
|
+
try {
|
|
1517
|
+
const refreshed = await client.token.refresh(persisted.refreshToken);
|
|
1518
|
+
config.authenticate(refreshed);
|
|
1519
|
+
if (persisted.projectId !== null) {
|
|
1520
|
+
config.setProjectId(persisted.projectId);
|
|
1521
|
+
await projectClientsAsync.settled();
|
|
1522
|
+
}
|
|
1523
|
+
return { status: "restored" };
|
|
1524
|
+
} catch (err) {
|
|
1525
|
+
if (isUnauthorized(err)) {
|
|
1526
|
+
persistor.clear();
|
|
1527
|
+
return { status: "expired" };
|
|
1528
|
+
}
|
|
1529
|
+
throw err;
|
|
1530
|
+
}
|
|
1531
|
+
},
|
|
1532
|
+
subscribe: (listener) => {
|
|
1533
|
+
const unsubscribeConfig = config.store.subscribe(() => listener(debug()));
|
|
1534
|
+
const unsubscribeBuild = projectClientsAsync.store.subscribe(() => listener(debug()));
|
|
1535
|
+
return () => {
|
|
1536
|
+
unsubscribeConfig();
|
|
1537
|
+
unsubscribeBuild();
|
|
1538
|
+
};
|
|
1539
|
+
},
|
|
1540
|
+
debug
|
|
1541
|
+
};
|
|
1542
|
+
return {
|
|
1543
|
+
api: createApi({
|
|
1544
|
+
getAuthClient: () => authClient.get(),
|
|
1545
|
+
getManagementClient: () => management.get(),
|
|
1546
|
+
getProjectClients: () => {
|
|
1547
|
+
const state = projectClientsAsync.store.get();
|
|
1548
|
+
return state.state === "ready" ? state.value : null;
|
|
1549
|
+
}
|
|
1550
|
+
}),
|
|
1551
|
+
session
|
|
1552
|
+
};
|
|
1636
1553
|
};
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1554
|
+
//#endregion
|
|
1555
|
+
//#region src/keboola/legacy/createConfig.ts
|
|
1556
|
+
const createConfig = () => {
|
|
1557
|
+
const store = createStore({
|
|
1558
|
+
baseUrl: null,
|
|
1559
|
+
sapiToken: null,
|
|
1560
|
+
managementToken: null
|
|
1561
|
+
});
|
|
1562
|
+
const setBaseUrl = (baseUrl) => {
|
|
1563
|
+
store.set({
|
|
1564
|
+
...store.get(),
|
|
1565
|
+
baseUrl
|
|
1566
|
+
});
|
|
1567
|
+
};
|
|
1568
|
+
const authenticate = (tokens) => {
|
|
1569
|
+
const current = store.get();
|
|
1570
|
+
store.set({
|
|
1571
|
+
...current,
|
|
1572
|
+
sapiToken: tokens.sapiToken ?? current.sapiToken,
|
|
1573
|
+
managementToken: tokens.managementToken ?? current.managementToken
|
|
1574
|
+
});
|
|
1575
|
+
};
|
|
1576
|
+
const getStorageToken = () => store.get().sapiToken ?? "";
|
|
1577
|
+
const setStorageToken = (sapiToken) => store.set({
|
|
1578
|
+
...store.get(),
|
|
1579
|
+
sapiToken
|
|
1580
|
+
});
|
|
1581
|
+
/** Current state, for diagnostics. */
|
|
1582
|
+
const debug = () => store.get();
|
|
1583
|
+
return {
|
|
1584
|
+
store,
|
|
1585
|
+
setBaseUrl,
|
|
1586
|
+
authenticate,
|
|
1587
|
+
getStorageToken,
|
|
1588
|
+
setStorageToken,
|
|
1589
|
+
debug
|
|
1590
|
+
};
|
|
1656
1591
|
};
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1592
|
+
//#endregion
|
|
1593
|
+
//#region src/keboola/legacy/createProjectClients.ts
|
|
1594
|
+
const createAttachStorageToken = (getToken) => (next) => (request) => {
|
|
1595
|
+
request.request.headers.set(KeboolaHttpHeader.STORAGE_API_TOKEN, getToken());
|
|
1596
|
+
return next(request);
|
|
1662
1597
|
};
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1598
|
+
const createProjectClients = async ({ baseUrl, getStorageToken, onStorageTokenRefreshed, middlewareFor, clientServiceUrls }) => {
|
|
1599
|
+
const auth = {
|
|
1600
|
+
type: "sapi-token",
|
|
1601
|
+
token: getStorageToken()
|
|
1602
|
+
};
|
|
1603
|
+
const attach = createAttachStorageToken(getStorageToken);
|
|
1604
|
+
const _storage = createStorageClient({
|
|
1605
|
+
baseUrl,
|
|
1606
|
+
auth,
|
|
1607
|
+
middlewares: [attach]
|
|
1608
|
+
});
|
|
1609
|
+
const [stackInfo, sapiToken, devBranches] = await Promise.all([
|
|
1610
|
+
_storage.getStackInfo({ exclude: "componentDetails" }),
|
|
1611
|
+
_storage.tokens.verify(),
|
|
1612
|
+
_storage.branches.getDevBranches()
|
|
1613
|
+
]);
|
|
1614
|
+
const stack = createStack({
|
|
1615
|
+
stackInfo,
|
|
1616
|
+
clientServiceUrls
|
|
1617
|
+
});
|
|
1618
|
+
const defaultBranch = createDefaultBranch({ devBranches });
|
|
1619
|
+
const liveProject = createLiveProject({
|
|
1620
|
+
initialToken: sapiToken,
|
|
1621
|
+
verify: () => _storage.tokens.verify()
|
|
1622
|
+
});
|
|
1623
|
+
const storageTableStore = createDerivedStore({
|
|
1624
|
+
source: liveProject.store,
|
|
1625
|
+
build: createStorageTable,
|
|
1626
|
+
dependsOn: (project) => ({
|
|
1627
|
+
useLegacyBucketPrefix: !project.hasFeature(ProjectFeature.DisableLegacyBucketPrefix),
|
|
1628
|
+
hasProtectedDefaultBranch: project.hasFeature(ProjectFeature.SoxProtectedDefaultBranch),
|
|
1629
|
+
hasStorageBranches: project.hasFeature(ProjectFeature.StorageBranches)
|
|
1630
|
+
})
|
|
1631
|
+
});
|
|
1632
|
+
const context = {
|
|
1633
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
1634
|
+
stack,
|
|
1635
|
+
defaultBranch,
|
|
1636
|
+
get project() {
|
|
1637
|
+
return liveProject.getProject();
|
|
1638
|
+
},
|
|
1639
|
+
get st() {
|
|
1640
|
+
return storageTableStore.get();
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
const storage = createStorageClient({
|
|
1644
|
+
baseUrl,
|
|
1645
|
+
auth,
|
|
1646
|
+
middlewares: middlewareFor("storage", [liveProject.middleware]),
|
|
1647
|
+
onRefreshToken: onStorageTokenRefreshed
|
|
1648
|
+
});
|
|
1649
|
+
const { client: services, meta: serviceMeta } = createServiceClients({
|
|
1650
|
+
baseUrl,
|
|
1651
|
+
auth,
|
|
1652
|
+
getServiceBaseUrl: context.stack.getServiceUrl,
|
|
1653
|
+
middlewareFor,
|
|
1654
|
+
attachTokenMiddleware: attach
|
|
1655
|
+
});
|
|
1656
|
+
const sdk = {
|
|
1657
|
+
configuration: createConfigurationSdk({
|
|
1658
|
+
storageClient: storage,
|
|
1659
|
+
encryptionClient: services.encryption,
|
|
1660
|
+
context
|
|
1661
|
+
}),
|
|
1662
|
+
tag: createTagSdk({ metastoreClient: services.metastore }),
|
|
1663
|
+
semanticLayer: createSemanticLayerSdk({ metastoreClient: services.metastore }),
|
|
1664
|
+
storage: createStorageSdk({ storageClient: storage }),
|
|
1665
|
+
vault: createVaultSdk({
|
|
1666
|
+
vaultClient: services.vault,
|
|
1667
|
+
encryptionClient: services.encryption
|
|
1668
|
+
}),
|
|
1669
|
+
variables: createVariablesSdk({ storageClient: storage })
|
|
1670
|
+
};
|
|
1671
|
+
return {
|
|
1672
|
+
context,
|
|
1673
|
+
serviceMeta,
|
|
1674
|
+
storage,
|
|
1675
|
+
...services,
|
|
1676
|
+
sdk
|
|
1677
|
+
};
|
|
1730
1678
|
};
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1679
|
+
//#endregion
|
|
1680
|
+
//#region src/keboola/legacy/keboola.ts
|
|
1681
|
+
const createLegacyKeboola = (options = {}) => {
|
|
1682
|
+
const config = createConfig();
|
|
1683
|
+
const middlewareFor = createMiddlewareFor(options.middlewares);
|
|
1684
|
+
const authClient = createDerivedStore({
|
|
1685
|
+
source: config.store,
|
|
1686
|
+
dependsOn: (state) => state.baseUrl,
|
|
1687
|
+
build: (baseUrl) => baseUrl ? createAuthClient({
|
|
1688
|
+
baseUrl,
|
|
1689
|
+
middlewares: middlewareFor("auth", [])
|
|
1690
|
+
}) : null
|
|
1691
|
+
});
|
|
1692
|
+
const management = createDerivedStore({
|
|
1693
|
+
source: config.store,
|
|
1694
|
+
dependsOn: (state) => ({
|
|
1695
|
+
baseUrl: state.baseUrl,
|
|
1696
|
+
token: state.managementToken
|
|
1697
|
+
}),
|
|
1698
|
+
build: ({ baseUrl, token }) => baseUrl ? createManagementClient({
|
|
1699
|
+
baseUrl,
|
|
1700
|
+
auth: token ? {
|
|
1701
|
+
type: "management-token",
|
|
1702
|
+
token
|
|
1703
|
+
} : { type: "management-token" },
|
|
1704
|
+
middlewares: middlewareFor("management", [])
|
|
1705
|
+
}) : null
|
|
1706
|
+
});
|
|
1707
|
+
const build = createDerivedAsyncStore({
|
|
1708
|
+
source: config.store,
|
|
1709
|
+
dependsOn: (state) => state.sapiToken && state.baseUrl ? state.baseUrl : null,
|
|
1710
|
+
build: (baseUrl) => createProjectClients({
|
|
1711
|
+
baseUrl,
|
|
1712
|
+
getStorageToken: config.getStorageToken,
|
|
1713
|
+
onStorageTokenRefreshed: config.setStorageToken,
|
|
1714
|
+
middlewareFor,
|
|
1715
|
+
clientServiceUrls: options.clientServiceUrls
|
|
1716
|
+
})
|
|
1717
|
+
});
|
|
1718
|
+
if (options.baseUrl) config.setBaseUrl(options.baseUrl);
|
|
1719
|
+
const debug = () => {
|
|
1720
|
+
const info = config.debug();
|
|
1721
|
+
return {
|
|
1722
|
+
type: "Sapi",
|
|
1723
|
+
config: info,
|
|
1724
|
+
authReady: authClient.get() !== null,
|
|
1725
|
+
managementReady: !!info.managementToken,
|
|
1726
|
+
storage: build.store.get().state
|
|
1727
|
+
};
|
|
1728
|
+
};
|
|
1729
|
+
const session = {
|
|
1730
|
+
setBaseUrl: config.setBaseUrl,
|
|
1731
|
+
isStorageReady: () => build.store.get().state === "ready",
|
|
1732
|
+
authenticateStorage: (sapiToken) => config.authenticate({ sapiToken }),
|
|
1733
|
+
authenticateStorageAsync: async (sapiToken) => {
|
|
1734
|
+
config.authenticate({ sapiToken });
|
|
1735
|
+
await build.settled();
|
|
1736
|
+
},
|
|
1737
|
+
authenticateManagement: (managementToken) => config.authenticate({ managementToken }),
|
|
1738
|
+
subscribe: (listener) => {
|
|
1739
|
+
const unsubscribeConfig = config.store.subscribe(() => listener(debug()));
|
|
1740
|
+
const unsubscribeBuild = build.store.subscribe(() => listener(debug()));
|
|
1741
|
+
return () => {
|
|
1742
|
+
unsubscribeConfig();
|
|
1743
|
+
unsubscribeBuild();
|
|
1744
|
+
};
|
|
1745
|
+
},
|
|
1746
|
+
debug
|
|
1747
|
+
};
|
|
1748
|
+
return {
|
|
1749
|
+
api: createApi({
|
|
1750
|
+
getAuthClient: () => authClient.get(),
|
|
1751
|
+
getManagementClient: () => management.get(),
|
|
1752
|
+
getProjectClients: () => {
|
|
1753
|
+
const state = build.store.get();
|
|
1754
|
+
return state.state === "ready" ? state.value : null;
|
|
1755
|
+
}
|
|
1756
|
+
}),
|
|
1757
|
+
session
|
|
1758
|
+
};
|
|
1800
1759
|
};
|
|
1760
|
+
//#endregion
|
|
1761
|
+
export { ApiError, HtmlResponseError, HttpContentType, HttpHeader, KeboolaError, KeboolaErrorType, KeboolaHttpHeader, ManagementClientAuthError, QueryJobError, QueryJobTimeoutError, Result, ServiceUnavailableError, SyncActionError, UserError, ValidationError, asError, assert, coalesce, collect, concurrent, createDerivedAsyncStore, createDerivedStore, createEmitter, createGenericFetchClient, createKeboola, createLegacyKeboola, createLocalStorage, createLoggingMiddleware, createMemoryStorage, createNullStorage, createPersistor, createPollRegistry, createQueryServiceSdk, createRetryMiddleware, createSessionStorage, createStorageSdk, createStore, dedupe, deepMerge, delay, emitter, failureOf, generateUUID, isAbortError, isApiError, isEmptyDeep, isFetchClientError, isHtmlResponseError, isKeboolaError, isManagementClientAuthError, isPlainObject, isQueryJobError, isQueryJobTimeoutError, isStorageTokenMutatingRequest, isSyncActionError, isValidationError, jobStatus, keboolaUID, lazy, parseLogLines, parseOrThrow, poll, poller, schemaGuidedMerge, series, shallowEqual };
|
|
1801
1762
|
|
|
1802
|
-
export { KeboolaError, KeboolaErrorType, assert, coalesce, createDerivedAsyncStore, createDerivedStore, createKeboola, createLegacyKeboola, createLocalStorage, createLoggingMiddleware, createMemoryStorage, createNullStorage, createPersistor, createRetryMiddleware, createSessionStorage, createStore, deepMerge, isKeboolaError, isStorageTokenMutatingRequest, lazy, shallowEqual };
|
|
1803
|
-
//# sourceMappingURL=index.js.map
|
|
1804
1763
|
//# sourceMappingURL=index.js.map
|