@keboola/api-client 46.0.0 → 48.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 +95 -24
- package/API-SURFACE.md +52 -30
- package/CHANGELOG.md +85 -0
- package/README.md +47 -37
- package/dist/{ManagementSessionMintError-5FFyvBZi.js → ManagementSessionMintError-4Pkn5Oob.js} +2 -2
- package/dist/{ManagementSessionMintError-5FFyvBZi.js.map → ManagementSessionMintError-4Pkn5Oob.js.map} +1 -1
- package/dist/{ManagementSessionMintError-Bm8s6yDB.cjs → ManagementSessionMintError-Cu9beG7j.cjs} +2 -2
- package/dist/{ManagementSessionMintError-Bm8s6yDB.cjs.map → ManagementSessionMintError-Cu9beG7j.cjs.map} +1 -1
- package/dist/QueryJobError-ZZZ043Nm.js +22 -0
- package/dist/QueryJobError-ZZZ043Nm.js.map +1 -0
- package/dist/{QueryJobTimeoutError-CVNPdCWX.cjs → QueryJobError-irGiP5zh.cjs} +1 -29
- package/dist/QueryJobError-irGiP5zh.cjs.map +1 -0
- package/dist/QueueJobError-6qSEizWo.cjs +30 -0
- package/dist/QueueJobError-6qSEizWo.cjs.map +1 -0
- package/dist/QueueJobError-8bThS_Mc.js +19 -0
- package/dist/QueueJobError-8bThS_Mc.js.map +1 -0
- package/dist/adminRoles-B40yBcmq.js.map +1 -1
- package/dist/{adminRoles-C696kD_U.d.ts → adminRoles-BgpaBE7h.d.cts} +4 -2
- package/dist/adminRoles-CO7J5qAy.cjs.map +1 -1
- package/dist/{adminRoles-C696kD_U.d.cts → adminRoles-DsoGQipO.d.ts} +4 -2
- package/dist/ai/index.cjs +2 -7
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +2 -3
- package/dist/ai/index.d.ts +2 -3
- package/dist/ai/index.js +2 -7
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/types.d.cts +2 -2
- package/dist/ai/types.d.ts +2 -2
- package/dist/{appLogs-BG9ueGxA.cjs → appLogs-Cix2KWra.cjs} +2 -2
- package/dist/{appLogs-BG9ueGxA.cjs.map → appLogs-Cix2KWra.cjs.map} +1 -1
- package/dist/{appLogs-DGIctwbb.d.ts → appLogs-DpcqeOe5.d.ts} +2 -2
- package/dist/{appLogs-CEKz68bE.js → appLogs-KslK7qHr.js} +2 -2
- package/dist/{appLogs-CEKz68bE.js.map → appLogs-KslK7qHr.js.map} +1 -1
- package/dist/{appLogs-Dl0v684o.d.cts → appLogs-SjrflOHk.d.cts} +2 -2
- package/dist/apps/index.cjs +5 -5
- package/dist/apps/index.cjs.map +1 -1
- package/dist/apps/index.d.cts +3 -3
- package/dist/apps/index.d.ts +3 -3
- package/dist/apps/index.js +5 -5
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/types.d.cts +2 -2
- package/dist/apps/types.d.ts +2 -2
- package/dist/assets/index.cjs +1 -1
- package/dist/assets/index.d.cts +1 -1
- package/dist/assets/index.d.ts +1 -1
- package/dist/assets/index.js +1 -1
- package/dist/auth/index.cjs +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/types.d.cts +2 -2
- package/dist/auth/types.d.ts +2 -2
- package/dist/{auth-C6cHWIWx.js → auth-4coY1uwo.js} +2 -2
- package/dist/{auth-C6cHWIWx.js.map → auth-4coY1uwo.js.map} +1 -1
- package/dist/{auth-C9o_0bft.cjs → auth-C8Pjl0Mu.cjs} +2 -2
- package/dist/{auth-C9o_0bft.cjs.map → auth-C8Pjl0Mu.cjs.map} +1 -1
- package/dist/{authClient-CACOwVt0.js → authClient-2e8ZmzSP.js} +71 -7
- package/dist/authClient-2e8ZmzSP.js.map +1 -0
- package/dist/{authClient-DSa5t2Ft.d.cts → authClient-BYIGzL_u.d.ts} +22 -4
- package/dist/{authClient-ZiaKSKpp.d.ts → authClient-D06srBQE.d.cts} +22 -4
- package/dist/{authClient-DZcAR-eW.cjs → authClient-DfkKlc-2.cjs} +82 -6
- package/dist/authClient-DfkKlc-2.cjs.map +1 -0
- package/dist/billing/index.cjs +2 -2
- package/dist/billing/index.d.cts +1 -1
- package/dist/billing/index.d.ts +1 -1
- package/dist/billing/index.js +2 -2
- package/dist/billing/types.d.cts +1 -1
- package/dist/billing/types.d.ts +1 -1
- package/dist/chat/index.cjs +3 -3
- package/dist/chat/index.d.cts +2 -2
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/index.js +3 -3
- package/dist/chat/types.d.cts +1 -1
- package/dist/chat/types.d.ts +1 -1
- package/dist/{collect-97WhfEpt.js → collectByOffset-2XzJqmvr.js} +6 -6
- package/dist/collectByOffset-2XzJqmvr.js.map +1 -0
- package/dist/{collect-B5TCNiT1.cjs → collectByOffset-DQsqtmJg.cjs} +7 -7
- package/dist/collectByOffset-DQsqtmJg.cjs.map +1 -0
- package/dist/componentsMcp/index.cjs +3 -0
- package/dist/componentsMcp/index.d.cts +2 -0
- package/dist/componentsMcp/index.d.ts +2 -0
- package/dist/componentsMcp/index.js +2 -0
- package/dist/componentsMcp/types.cjs +0 -0
- package/dist/componentsMcp/types.d.cts +2 -0
- package/dist/componentsMcp/types.d.ts +2 -0
- package/dist/componentsMcp/types.js +1 -0
- package/dist/componentsMcp-CHobIsuU.js +57 -0
- package/dist/componentsMcp-CHobIsuU.js.map +1 -0
- package/dist/componentsMcp-pG-PcQrg.cjs +62 -0
- package/dist/componentsMcp-pG-PcQrg.cjs.map +1 -0
- package/dist/{configurations-D_Rbs0Wl.cjs → configurations-B2O8AAy0.cjs} +2 -2
- package/dist/{configurations-D_Rbs0Wl.cjs.map → configurations-B2O8AAy0.cjs.map} +1 -1
- package/dist/{configurations-Chg_JwJ1.js → configurations-CL0ouUMa.js} +3 -3
- package/dist/configurations-CL0ouUMa.js.map +1 -0
- package/dist/{configurations-BTRHVSRq.cjs → configurations-D9J3jh3g.cjs} +3 -3
- package/dist/configurations-D9J3jh3g.cjs.map +1 -0
- package/dist/{configurations-DcpUlC8I.js → configurations-DKINmjA3.js} +2 -2
- package/dist/{configurations-DcpUlC8I.js.map → configurations-DKINmjA3.js.map} +1 -1
- package/dist/constants/index.cjs +1 -1
- package/dist/constants/index.d.cts +2 -3
- package/dist/constants/index.d.ts +2 -3
- package/dist/constants/index.js +1 -1
- package/dist/{constants-Cifrqsls.js → constants-CA4UN2Xv.js} +11 -10
- package/dist/constants-CA4UN2Xv.js.map +1 -0
- package/dist/{constants-BDGRQqij.cjs → constants-a0jswUeK.cjs} +10 -9
- package/dist/constants-a0jswUeK.cjs.map +1 -0
- package/dist/{createFetchClient-DITkTV2k.js → createFetchClient-CkHdS_IG.js} +5 -5
- package/dist/createFetchClient-CkHdS_IG.js.map +1 -0
- package/dist/{createFetchClient-ClWD4ua3.cjs → createFetchClient-lZ_93Yrb.cjs} +5 -5
- package/dist/createFetchClient-lZ_93Yrb.cjs.map +1 -0
- package/dist/{createGenericFetchClient-KqiJhw8G.js → createGenericFetchClient-CQdNcPC3.js} +2 -2
- package/dist/{createGenericFetchClient-KqiJhw8G.js.map → createGenericFetchClient-CQdNcPC3.js.map} +1 -1
- package/dist/{createGenericFetchClient-B81Iezpb.cjs → createGenericFetchClient-MOx97wi-.cjs} +2 -2
- package/dist/{createGenericFetchClient-B81Iezpb.cjs.map → createGenericFetchClient-MOx97wi-.cjs.map} +1 -1
- package/dist/{createOpenapiFetchClient-CioTX11-.cjs → createOpenapiFetchClient-DHYo_k3t.cjs} +2 -2
- package/dist/{createOpenapiFetchClient-CioTX11-.cjs.map → createOpenapiFetchClient-DHYo_k3t.cjs.map} +1 -1
- package/dist/{createOpenapiFetchClient-wq8iGLZM.js → createOpenapiFetchClient-DXiMv9WL.js} +2 -2
- package/dist/{createOpenapiFetchClient-wq8iGLZM.js.map → createOpenapiFetchClient-DXiMv9WL.js.map} +1 -1
- package/dist/dataScience/index.cjs +2 -2
- package/dist/dataScience/index.d.cts +2 -2
- package/dist/dataScience/index.d.ts +2 -2
- package/dist/dataScience/index.js +2 -2
- package/dist/dataScience/types.d.cts +2 -2
- package/dist/dataScience/types.d.ts +2 -2
- package/dist/{dataScience-BwHmDoQb.js → dataScience-AwPMeGfz.js} +5 -5
- package/dist/{dataScience-BwHmDoQb.js.map → dataScience-AwPMeGfz.js.map} +1 -1
- package/dist/{dataScience-Hhoqoql_.cjs → dataScience-BjS1p8WO.cjs} +5 -5
- package/dist/{dataScience-Hhoqoql_.cjs.map → dataScience-BjS1p8WO.cjs.map} +1 -1
- package/dist/developerPortal/index.cjs +1 -1
- package/dist/developerPortal/index.d.cts +2 -2
- package/dist/developerPortal/index.d.ts +2 -2
- package/dist/developerPortal/index.js +1 -1
- package/dist/developerPortal/types.d.cts +1 -1
- package/dist/developerPortal/types.d.ts +1 -1
- package/dist/{developerPortalClient-loKq7X_U.js → developerPortalClient-Bb2suezr.js} +13 -5
- package/dist/{developerPortalClient-loKq7X_U.js.map → developerPortalClient-Bb2suezr.js.map} +1 -1
- package/dist/{developerPortalClient-COm7wJxS.cjs → developerPortalClient-DUerKw-7.cjs} +13 -5
- package/dist/{developerPortalClient-COm7wJxS.cjs.map → developerPortalClient-DUerKw-7.cjs.map} +1 -1
- package/dist/domain/permissions/index.cjs +1 -1
- package/dist/domain/permissions/index.d.cts +2 -3
- package/dist/domain/permissions/index.d.ts +2 -3
- package/dist/domain/permissions/index.js +1 -1
- package/dist/editor/index.cjs +2 -2
- package/dist/editor/index.d.cts +2 -2
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +2 -2
- package/dist/editor/types.d.cts +1 -1
- package/dist/editor/types.d.ts +1 -1
- package/dist/encryption/index.cjs +1 -1
- package/dist/encryption/index.d.cts +1 -1
- package/dist/encryption/index.d.ts +1 -1
- package/dist/encryption/index.js +1 -1
- package/dist/encryption/types.d.cts +1 -1
- package/dist/encryption/types.d.ts +1 -1
- package/dist/import/index.cjs +1 -1
- package/dist/import/index.d.cts +3 -3
- package/dist/import/index.d.ts +3 -3
- package/dist/import/index.js +1 -1
- package/dist/{import-B5DcJGMI.cjs → import-BahNYv91.cjs} +3 -3
- package/dist/{import-B5DcJGMI.cjs.map → import-BahNYv91.cjs.map} +1 -1
- package/dist/{import-JlH_QaDd.js → import-FWy_wQZ1.js} +3 -3
- package/dist/{import-JlH_QaDd.js.map → import-FWy_wQZ1.js.map} +1 -1
- package/dist/{index-BP3choXr.d.ts → index-B3QTeqfL.d.ts} +19976 -14513
- package/dist/{index-x8ET_BTN.d.cts → index-BCjU-g9t.d.cts} +3 -3
- package/dist/{index-DCxVLGHH.d.ts → index-BHiJu8LF.d.cts} +16 -28
- package/dist/{index-DXcTukgn.d.ts → index-BIldED4N.d.ts} +4 -4
- package/dist/index-BLvmyehw.d.ts +46 -0
- package/dist/{index-BnPYPXGQ.d.ts → index-BTrxCk90.d.ts} +3 -3
- package/dist/{index-DS6O4UDB.d.cts → index-ByLCYBaw.d.cts} +4 -4
- package/dist/{index-syAYY5LC.d.cts → index-C40Fbj-6.d.cts} +19976 -14513
- package/dist/{index-DWFxcmVD.d.ts → index-CIqWOEWD.d.ts} +4 -4
- package/dist/{index-Bt43tKyu.d.cts → index-Cc5wSIRJ.d.cts} +5 -5
- package/dist/{types-CESP1ONj.d.ts → index-ChDl6ig5.d.cts} +3780 -549
- package/dist/index-Co2Cd-nw.d.cts +46 -0
- package/dist/{index-CTKC-mwi.d.cts → index-CpGmmJbt.d.cts} +4 -4
- package/dist/{index-D-4TT5yW.d.cts → index-CpUYVB-d.d.cts} +4 -4
- package/dist/{index-DeQDdut6.d.ts → index-CzHrIfZS.d.ts} +34 -2
- package/dist/{index-BhDxP0x4.d.cts → index-D91RxB_S.d.cts} +18 -13
- package/dist/{index-GVxpBH6j.d.cts → index-DlZiWfQb.d.ts} +16 -28
- package/dist/{index-DRaVzOLM.d.ts → index-DzLXtE4Q.d.ts} +5 -5
- package/dist/{index-DeQDdut6.d.cts → index-VlzlOBkc.d.cts} +34 -2
- package/dist/{index-se5ee8U1.d.ts → index-avzO5sLa.d.ts} +18 -13
- package/dist/{index-yJ0HrxY6.d.ts → index-m7fX76x3.d.ts} +4 -4
- package/dist/{types-GaOcVZ3d.d.cts → index-sDHBkJhU.d.ts} +3780 -549
- package/dist/index.cjs +551 -375
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +493 -320
- package/dist/index.js.map +1 -1
- package/dist/{isLoginPageRedirect-CsyRa3_v.js → isLoginPageRedirect-B4QKSiSa.js} +2 -2
- package/dist/{isLoginPageRedirect-CsyRa3_v.js.map → isLoginPageRedirect-B4QKSiSa.js.map} +1 -1
- package/dist/{isLoginPageRedirect-iNbwl3iz.cjs → isLoginPageRedirect-r0Opgc1n.cjs} +2 -2
- package/dist/{isLoginPageRedirect-iNbwl3iz.cjs.map → isLoginPageRedirect-r0Opgc1n.cjs.map} +1 -1
- package/dist/kaiAgent/index.cjs +1 -1
- package/dist/kaiAgent/index.d.cts +3 -3
- package/dist/kaiAgent/index.d.ts +3 -3
- package/dist/kaiAgent/index.js +1 -1
- package/dist/kaiAgent/types.d.cts +1 -1
- package/dist/kaiAgent/types.d.ts +1 -1
- package/dist/{kaiAgent-CUeT53-K.js → kaiAgent-CYvrS8oZ.js} +16 -7
- package/dist/kaiAgent-CYvrS8oZ.js.map +1 -0
- package/dist/{kaiAgent-BhcUsBDk.cjs → kaiAgent-N2qbUFZm.cjs} +16 -7
- package/dist/kaiAgent-N2qbUFZm.cjs.map +1 -0
- package/dist/{kaiMemory-DaOh0zVn.js → kaiMemory-C9di17bd.js} +2 -2
- package/dist/{kaiMemory-DaOh0zVn.js.map → kaiMemory-C9di17bd.js.map} +1 -1
- package/dist/{kaiMemory-Cf81ghNd.cjs → kaiMemory-Qch09f-m.cjs} +2 -2
- package/dist/{kaiMemory-Cf81ghNd.cjs.map → kaiMemory-Qch09f-m.cjs.map} +1 -1
- package/dist/management/index.cjs +1 -1
- package/dist/management/index.d.cts +1 -1
- package/dist/management/index.d.ts +1 -1
- package/dist/management/index.js +1 -1
- package/dist/management/types.d.cts +2 -2
- package/dist/management/types.d.ts +2 -2
- package/dist/{management-0cWVLHei.cjs → management-CXHnxVaZ.cjs} +34 -10
- package/dist/management-CXHnxVaZ.cjs.map +1 -0
- package/dist/{management-eg4Ig-Cx.js → management-NYAD6ej4.js} +34 -10
- package/dist/management-NYAD6ej4.js.map +1 -0
- package/dist/metastore/index.cjs +1 -1
- package/dist/metastore/index.d.cts +1 -1
- package/dist/metastore/index.d.ts +1 -1
- package/dist/metastore/index.js +1 -1
- package/dist/metastore/types.d.cts +1 -1
- package/dist/metastore/types.d.ts +1 -1
- package/dist/{metastore-YPHUK3jJ.cjs → metastore-BXHg33ku.cjs} +4 -4
- package/dist/{metastore-YPHUK3jJ.cjs.map → metastore-BXHg33ku.cjs.map} +1 -1
- package/dist/{metastore-D0C6uaPX.js → metastore-Ywq08DBz.js} +4 -4
- package/dist/{metastore-D0C6uaPX.js.map → metastore-Ywq08DBz.js.map} +1 -1
- package/dist/microsoftGraph/index.cjs +2 -2
- package/dist/microsoftGraph/index.d.cts +2 -2
- package/dist/microsoftGraph/index.d.ts +2 -2
- package/dist/microsoftGraph/index.js +2 -2
- package/dist/microsoftGraph/types.d.cts +1 -1
- package/dist/microsoftGraph/types.d.ts +1 -1
- package/dist/{middleware-D_p5TctO.cjs → middleware-CEP6uu_D.cjs} +5 -5
- package/dist/middleware-CEP6uu_D.cjs.map +1 -0
- package/dist/{middleware-DmR6OhTY.js → middleware-GOfx8Apu.js} +5 -5
- package/dist/middleware-GOfx8Apu.js.map +1 -0
- package/dist/notifications/index.cjs +3 -3
- package/dist/notifications/index.d.cts +2 -2
- package/dist/notifications/index.d.ts +2 -2
- package/dist/notifications/index.js +3 -3
- package/dist/notifications/types.d.cts +1 -1
- package/dist/notifications/types.d.ts +1 -1
- package/dist/oauth/index.cjs +1 -1
- package/dist/oauth/index.d.cts +6 -2
- package/dist/oauth/index.d.ts +6 -2
- package/dist/oauth/index.js +1 -1
- package/dist/oauth/types.d.cts +2 -2
- package/dist/oauth/types.d.ts +2 -2
- package/dist/{oauth-DyUwTqHJ.cjs → oauth-DKZPuUlt.cjs} +17 -6
- package/dist/{oauth-DyUwTqHJ.cjs.map → oauth-DKZPuUlt.cjs.map} +1 -1
- package/dist/{oauth-Ck_Fe14o.js → oauth-GXmZ9agP.js} +17 -6
- package/dist/{oauth-Ck_Fe14o.js.map → oauth-GXmZ9agP.js.map} +1 -1
- package/dist/omnisearch/index.cjs +2 -2
- package/dist/omnisearch/index.d.cts +2 -2
- package/dist/omnisearch/index.d.ts +2 -2
- package/dist/omnisearch/index.js +2 -2
- package/dist/omnisearch/types.d.cts +1 -1
- package/dist/omnisearch/types.d.ts +1 -1
- package/dist/project-Dzu85cqr.d.cts +74 -0
- package/dist/project-nbv9yjpl.d.ts +74 -0
- package/dist/queryService/index.cjs +1 -1
- package/dist/queryService/index.d.cts +1 -1
- package/dist/queryService/index.d.ts +1 -1
- package/dist/queryService/index.js +1 -1
- package/dist/queryService/types.d.cts +2 -2
- package/dist/queryService/types.d.ts +2 -2
- package/dist/{queryService-Blfz59Ms.js → queryService-C-pZha5p.js} +36 -27
- package/dist/queryService-C-pZha5p.js.map +1 -0
- package/dist/{queryService-RlNYw7LG.cjs → queryService-CzK53q94.cjs} +36 -27
- package/dist/queryService-CzK53q94.cjs.map +1 -0
- package/dist/queue/index.cjs +1 -1
- package/dist/queue/index.d.cts +75 -7
- package/dist/queue/index.d.ts +75 -7
- package/dist/queue/index.js +1 -1
- package/dist/queue/types.d.cts +1 -1
- package/dist/queue/types.d.ts +1 -1
- package/dist/{queue-BrgRdtOr.cjs → queue-BJvDWriM.cjs} +35 -25
- package/dist/queue-BJvDWriM.cjs.map +1 -0
- package/dist/{queue-CNvR-M23.js → queue-D6-x4OGF.js} +35 -25
- package/dist/queue-D6-x4OGF.js.map +1 -0
- package/dist/scheduler/index.cjs +3 -3
- package/dist/scheduler/index.d.cts +2 -2
- package/dist/scheduler/index.d.ts +2 -2
- package/dist/scheduler/index.js +3 -3
- package/dist/scheduler/types.d.cts +1 -1
- package/dist/scheduler/types.d.ts +1 -1
- package/dist/sdk/configurations/index.cjs +1 -1
- package/dist/sdk/configurations/index.d.cts +2 -4
- package/dist/sdk/configurations/index.d.ts +2 -4
- package/dist/sdk/configurations/index.js +1 -1
- package/dist/sdk/developerPortal/index.cjs +3 -3
- package/dist/sdk/developerPortal/index.d.cts +3 -3
- package/dist/sdk/developerPortal/index.d.ts +3 -3
- package/dist/sdk/developerPortal/index.js +3 -3
- package/dist/sdk/kaiMemory/index.cjs +1 -1
- package/dist/sdk/kaiMemory/index.d.cts +1 -1
- package/dist/sdk/kaiMemory/index.d.ts +1 -1
- package/dist/sdk/kaiMemory/index.js +1 -1
- package/dist/sdk/kaiMemory/types.d.cts +1 -1
- package/dist/sdk/kaiMemory/types.d.ts +1 -1
- package/dist/sdk/queryService/index.cjs +34 -55
- package/dist/sdk/queryService/index.cjs.map +1 -1
- package/dist/sdk/queryService/index.d.cts +2 -2
- package/dist/sdk/queryService/index.d.ts +2 -2
- package/dist/sdk/queryService/index.js +34 -55
- package/dist/sdk/queryService/index.js.map +1 -1
- package/dist/sdk/semanticLayer/index.d.cts +1 -1
- package/dist/sdk/semanticLayer/index.d.ts +1 -1
- package/dist/sdk/semanticLayer/types.d.cts +1 -1
- package/dist/sdk/semanticLayer/types.d.ts +1 -1
- package/dist/sdk/storage/index.cjs +0 -119
- package/dist/sdk/storage/index.cjs.map +1 -1
- package/dist/sdk/storage/index.d.cts +103 -2
- package/dist/sdk/storage/index.d.ts +103 -2
- package/dist/sdk/storage/index.js +1 -119
- package/dist/sdk/storage/index.js.map +1 -1
- package/dist/sdk/tag/index.d.cts +2 -2
- package/dist/sdk/tag/index.d.ts +2 -2
- package/dist/sdk/tag/types.d.cts +1 -1
- package/dist/sdk/tag/types.d.ts +1 -1
- package/dist/sdk/vault/index.d.cts +1 -1
- package/dist/sdk/vault/index.d.ts +1 -1
- package/dist/status/index.cjs +1 -1
- package/dist/status/index.d.cts +1 -1
- package/dist/status/index.d.ts +1 -1
- package/dist/status/index.js +1 -1
- package/dist/storage/index.cjs +13 -9
- package/dist/storage/index.d.cts +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +7 -6
- package/dist/storage/types.d.cts +6 -5
- package/dist/storage/types.d.ts +6 -5
- package/dist/{storage-RkNaOFJ-.js → storage-BR-Kgi-6.js} +353 -169
- package/dist/storage-BR-Kgi-6.js.map +1 -0
- package/dist/{storage-76Sf_z_H.cjs → storage-CVBXivpB.cjs} +372 -170
- package/dist/storage-CVBXivpB.cjs.map +1 -0
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.d.cts +2 -2
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.js +3 -3
- package/dist/stream/types.d.cts +1 -1
- package/dist/stream/types.d.ts +1 -1
- package/dist/syncActions/index.cjs +1 -1
- package/dist/syncActions/index.d.cts +2 -2
- package/dist/syncActions/index.d.ts +2 -2
- package/dist/syncActions/index.js +1 -1
- package/dist/syncActions/types.d.cts +1 -1
- package/dist/syncActions/types.d.ts +1 -1
- package/dist/{syncActions-DlNPhZY4.cjs → syncActions-C1rE4R3f.cjs} +5 -5
- package/dist/{syncActions-DlNPhZY4.cjs.map → syncActions-C1rE4R3f.cjs.map} +1 -1
- package/dist/{syncActions-BvFUa9xV.js → syncActions-DM8vP7p3.js} +5 -5
- package/dist/{syncActions-BvFUa9xV.js.map → syncActions-DM8vP7p3.js.map} +1 -1
- package/dist/telemetry/index.cjs +3 -6
- package/dist/telemetry/index.cjs.map +1 -1
- package/dist/telemetry/index.d.cts +2 -5
- package/dist/telemetry/index.d.ts +2 -5
- package/dist/telemetry/index.js +3 -6
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/types.d.cts +1 -1
- package/dist/telemetry/types.d.ts +1 -1
- package/dist/{jobStatus-BJdbZ72V.js → transientRetries-B4iusp69.js} +79 -37
- package/dist/transientRetries-B4iusp69.js.map +1 -0
- package/dist/{jobStatus-B0E-MZ9I.cjs → transientRetries-DdJfH9QK.cjs} +82 -40
- package/dist/transientRetries-DdJfH9QK.cjs.map +1 -0
- package/dist/{types-QroFANIW.d.cts → types-0ZAMQhva.d.cts} +3 -3
- package/dist/{types-BMWeCO5M.d.ts → types-1LENlL5h.d.ts} +3 -3
- package/dist/{types-BRvs3fXN.d.cts → types-6KabdIyO.d.cts} +3 -3
- package/dist/{types-B5kkD7h4.d.cts → types-9d8ihjZh.d.cts} +2 -2
- package/dist/{types-qGMVZGSB.d.ts → types-B7L6uSYb.d.ts} +50 -3
- package/dist/{types-qWA5iU0j.d.ts → types-BTy_FFSu.d.ts} +2 -2
- package/dist/{types-B1GN_I06.d.ts → types-BWYtQkHu.d.ts} +2 -2
- package/dist/types-BXHZQvGy.d.ts +2111 -0
- package/dist/{types-Btb8r9iw.d.ts → types-BYFU_6Iz.d.ts} +95 -26
- package/dist/{types-Nwq1QtYe.d.ts → types-BaqdM92a.d.ts} +3 -4
- package/dist/{types-CFurl1xe.d.cts → types-BbwrMl0Q.d.cts} +2 -2
- package/dist/{types-Br04cEri.d.ts → types-Bt8CEZ6K.d.ts} +2 -2
- package/dist/types-BtS3DhGu.d.cts +2111 -0
- package/dist/{types-CaBhH99H.d.ts → types-C-GSYDTN.d.ts} +3 -3
- package/dist/{types-BGICH80a.d.cts → types-C4eQ-Zcx.d.cts} +2 -2
- package/dist/{types-BTqxM-IN.d.ts → types-C9VaQSqV.d.ts} +2 -2
- package/dist/{types-C05ALlV6.d.cts → types-CNkQuWnO.d.cts} +3 -3
- package/dist/{types-DMWfdZ5C.d.cts → types-CXv_e6xC.d.cts} +2 -2
- package/dist/{types-C8oZX0oP.d.cts → types-C_raqbl-.d.cts} +3 -3
- package/dist/{types-BtII5RSD.d.ts → types-Cc4yTEdK.d.ts} +11 -3
- package/dist/{types-BoNqe_Lz.d.ts → types-Ce5Blzhg.d.ts} +2 -2
- package/dist/{types-UI2aZ74n.d.ts → types-CfZLdfAL.d.ts} +3 -3
- package/dist/{types-sg2xnYlr.d.cts → types-Cfc-fYbq.d.cts} +95 -26
- package/dist/{types-C4yryy-R.d.ts → types-Cn8I0vcr.d.ts} +3 -3
- package/dist/{types-DQauEri3.d.ts → types-CpWE6Yg2.d.ts} +2 -2
- package/dist/{types-XHNJRi3-.d.cts → types-CrJIILXf.d.cts} +2 -2
- package/dist/{types-DHdXufVf.d.cts → types-CwGbiMF-.d.cts} +3 -3
- package/dist/{types-fAqPUl-a.d.ts → types-CwQ8_n8q.d.ts} +320 -43
- package/dist/{types-BksK2Eo0.d.cts → types-D3H3EAre.d.ts} +2 -2
- package/dist/{types-CyO8qCKl.d.cts → types-D3mj56iq.d.cts} +2 -2
- package/dist/{types-YdE2VJzw.d.cts → types-D8d5tyGi.d.cts} +2 -2
- package/dist/{types-Csmy6qFk.d.cts → types-DMpiG2q4.d.cts} +3 -3
- package/dist/{types-ggpJFEWZ.d.cts → types-DSBrhK_K.d.cts} +2 -2
- package/dist/{types-5HdT1rSH.d.cts → types-DXF6faow.d.cts} +2 -2
- package/dist/{types-DDjp9lXD.d.ts → types-DfJP6Dti.d.ts} +2 -2
- package/dist/{types-DSv1XS7s.d.ts → types-DgOLSRiy.d.ts} +3 -3
- package/dist/{types-tJLoKlMX.d.cts → types-DlgqPU_4.d.cts} +2 -2
- package/dist/{types-sI3K5t3w.d.cts → types-Dn1G-qv4.d.cts} +320 -43
- package/dist/{types--owScV0r.d.cts → types-EkyQ0_10.d.cts} +11 -3
- package/dist/{types-LxDyOfdY.d.cts → types-EmIcG-8K.d.cts} +2 -2
- package/dist/{types-DGu-wPPm.d.cts → types-NSxpnYW5.d.cts} +50 -3
- package/dist/{types-Dvysi2Eo.d.ts → types-QPW-7dPm.d.ts} +2 -2
- package/dist/{types-BE7mRarT.d.ts → types-UySfduQo.d.ts} +2 -2
- package/dist/{types-BHxsCu0f.d.ts → types-VehpPOQX.d.ts} +2 -2
- package/dist/{types-DiE081mn.d.ts → types-Vu09EUZs.d.ts} +3 -3
- package/dist/{types-CoQET4Ep.d.ts → types-c4h2YDMC.d.ts} +2 -2
- package/dist/{types-BuKviWct.d.ts → types-sOM2_KPc.d.cts} +2 -2
- package/dist/{types-DUDQg4ry.d.cts → types-wNuJUhco.d.cts} +3 -4
- package/dist/{validateConnectionStatus-DR-0h35y.cjs → validateConnectionStatus-BalWEyRk.cjs} +3 -3
- package/dist/{validateConnectionStatus-DR-0h35y.cjs.map → validateConnectionStatus-BalWEyRk.cjs.map} +1 -1
- package/dist/{validateConnectionStatus-CdTV3gsP.js → validateConnectionStatus-DyrYpn0G.js} +3 -3
- package/dist/{validateConnectionStatus-CdTV3gsP.js.map → validateConnectionStatus-DyrYpn0G.js.map} +1 -1
- package/dist/vault/index.cjs +6 -6
- package/dist/vault/index.cjs.map +1 -1
- package/dist/vault/index.d.cts +1 -1
- package/dist/vault/index.d.ts +1 -1
- package/dist/vault/index.js +6 -6
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/types.d.cts +1 -1
- package/dist/vault/types.d.ts +1 -1
- package/package.json +27 -1
- package/surface/ai.md +0 -1
- package/surface/apps.md +5 -5
- package/surface/auth.md +2 -0
- package/surface/chat.md +2 -2
- package/surface/componentsMcp.md +9 -0
- package/surface/dataScience.md +2 -2
- package/surface/kaiAgent.md +5 -4
- package/surface/management.md +5 -2
- package/surface/oauth.md +1 -0
- package/surface/queryService.md +4 -4
- package/surface/queue.md +2 -2
- package/surface/sdk.md +0 -24
- package/surface/storage.md +88 -57
- package/dist/QueryJobTimeoutError-C7JbNGOM.js +0 -38
- package/dist/QueryJobTimeoutError-C7JbNGOM.js.map +0 -1
- package/dist/QueryJobTimeoutError-CVNPdCWX.cjs.map +0 -1
- package/dist/authClient-CACOwVt0.js.map +0 -1
- package/dist/authClient-DZcAR-eW.cjs.map +0 -1
- package/dist/collect-97WhfEpt.js.map +0 -1
- package/dist/collect-B5TCNiT1.cjs.map +0 -1
- package/dist/configurations-BTRHVSRq.cjs.map +0 -1
- package/dist/configurations-Chg_JwJ1.js.map +0 -1
- package/dist/constants-BDGRQqij.cjs.map +0 -1
- package/dist/constants-Cifrqsls.js.map +0 -1
- package/dist/createFetchClient-ClWD4ua3.cjs.map +0 -1
- package/dist/createFetchClient-DITkTV2k.js.map +0 -1
- package/dist/index-BzhLY7el.d.cts +0 -254
- package/dist/index-CH5Sg3rk.d.ts +0 -77
- package/dist/index-CiwWDu-q.d.cts +0 -16
- package/dist/index-DCAnnlcL.d.ts +0 -16
- package/dist/index-DQwjlSJi.d.cts +0 -77
- package/dist/index-PyTPrtaL.d.ts +0 -254
- package/dist/jobStatus-B0E-MZ9I.cjs.map +0 -1
- package/dist/jobStatus-BJdbZ72V.js.map +0 -1
- package/dist/kaiAgent-BhcUsBDk.cjs.map +0 -1
- package/dist/kaiAgent-CUeT53-K.js.map +0 -1
- package/dist/management-0cWVLHei.cjs.map +0 -1
- package/dist/management-eg4Ig-Cx.js.map +0 -1
- package/dist/middleware-D_p5TctO.cjs.map +0 -1
- package/dist/middleware-DmR6OhTY.js.map +0 -1
- package/dist/project-BN7YRWFS.d.cts +0 -24
- package/dist/project-BpWTnoQ_.d.ts +0 -24
- package/dist/queryService-Blfz59Ms.js.map +0 -1
- package/dist/queryService-RlNYw7LG.cjs.map +0 -1
- package/dist/queue-BrgRdtOr.cjs.map +0 -1
- package/dist/queue-CNvR-M23.js.map +0 -1
- package/dist/serviceIds-DRcoTnSd.d.cts +0 -32
- package/dist/serviceIds-DRcoTnSd.d.ts +0 -32
- package/dist/storage-76Sf_z_H.cjs.map +0 -1
- package/dist/storage-RkNaOFJ-.js.map +0 -1
- package/dist/types-1B3ioN33.d.cts +0 -1868
- package/dist/types-BjIuVrAZ.d.ts +0 -66
- package/dist/types-CGhu0tID.d.cts +0 -1298
- package/dist/types-CclheyE7.d.cts +0 -66
- package/dist/types-M9vU_ONp.d.ts +0 -1868
- package/dist/types-P_61P9Nd.d.ts +0 -1298
- package/dist/types-j30rKMe6.d.ts +0 -957
- package/dist/types-q5lgElyc.d.cts +0 -957
package/dist/index.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
import { t as createProject } from "./project-BXLFrWJ6.js";
|
|
2
|
-
import { t as
|
|
2
|
+
import { t as collectByOffset } from "./collectByOffset-2XzJqmvr.js";
|
|
3
|
+
import { t as createAuthClient, v as collectByCursor, y as nextCursorOf } from "./authClient-2e8ZmzSP.js";
|
|
3
4
|
import { t as concurrent } from "./concurrent-BacWxPwi.js";
|
|
4
5
|
import { t as dedupe } from "./dedupe-Cky1gSUu.js";
|
|
5
|
-
import { a as poller, c as Result, d as delay, i as
|
|
6
|
+
import { a as poller, c as Result, d as delay, i as failureOf, l as asError, n as jobStatus, o as clamp, r as emitter, s as finiteOr, u as lazy } from "./transientRetries-B4iusp69.js";
|
|
6
7
|
import { n as createEmitter, t as createStore } from "./store-C9FQCHGe.js";
|
|
7
|
-
import { a as readableReason,
|
|
8
|
+
import { a as StorageJobError, c as readableReason, l as series, o as isStorageJobError, s as ServiceUnavailableError, t as createStorageClient } from "./storage-BR-Kgi-6.js";
|
|
8
9
|
import { n as keboolaUID, t as createTagSdk } from "./tag-hh-1nhNr.js";
|
|
9
10
|
import { t as generateUUID } from "./generateUUID-Dr8l-aoc.js";
|
|
10
11
|
import { t as isPlainObject } from "./isPlainObject-LYW-03uB.js";
|
|
11
|
-
import { n as schemaGuidedMerge, r as isEmptyDeep, t as createConfigurationSdk } from "./configurations-
|
|
12
|
+
import { n as schemaGuidedMerge, r as isEmptyDeep, t as createConfigurationSdk } from "./configurations-DKINmjA3.js";
|
|
12
13
|
import { t as UserError } from "./UserError-By_Zckmc.js";
|
|
13
|
-
import { _ as KeboolaHttpHeader, a as isTimeoutError, d as normalizeBaseUrl, g as HttpStatus, i as isFetchClientError, m as CREDENTIAL_HEADERS, n as isAbortError, o as HttpContentType, p as ApiError, r as isApiError, s as HttpHeader, v as REDACTED, y as redactHeaders } from "./createFetchClient-
|
|
14
|
-
import { n as HtmlResponseError, r as isHtmlResponseError } from "./validateConnectionStatus-
|
|
15
|
-
import { n as ManagementClientAuthError, t as ManagementSessionMintError } from "./ManagementSessionMintError-
|
|
16
|
-
import {
|
|
14
|
+
import { _ as KeboolaHttpHeader, a as isTimeoutError, d as normalizeBaseUrl, g as HttpStatus, i as isFetchClientError, m as CREDENTIAL_HEADERS, n as isAbortError, o as HttpContentType, p as ApiError, r as isApiError, s as HttpHeader, v as REDACTED, y as redactHeaders } from "./createFetchClient-CkHdS_IG.js";
|
|
15
|
+
import { n as HtmlResponseError, r as isHtmlResponseError } from "./validateConnectionStatus-DyrYpn0G.js";
|
|
16
|
+
import { n as ManagementClientAuthError, t as ManagementSessionMintError } from "./ManagementSessionMintError-4Pkn5Oob.js";
|
|
17
|
+
import { n as isQueryJobError, t as QueryJobError } from "./QueryJobError-ZZZ043Nm.js";
|
|
18
|
+
import { n as isQueueJobError, t as QueueJobError } from "./QueueJobError-8bThS_Mc.js";
|
|
17
19
|
import { n as isSyncActionError, t as SyncActionError } from "./SyncActionError-CoZFsdUk.js";
|
|
18
20
|
import { i as parseOrThrow, n as formatValidationIssues, r as isValidationError, t as ValidationError } from "./ValidationError-DjhtNMfZ.js";
|
|
19
|
-
import { t as createGenericFetchClient } from "./createGenericFetchClient-
|
|
20
|
-
import { t as createImportClient } from "./import-
|
|
21
|
-
import { t as
|
|
22
|
-
import {
|
|
23
|
-
import { s as ProjectFeature } from "./constants-Cifrqsls.js";
|
|
21
|
+
import { t as createGenericFetchClient } from "./createGenericFetchClient-CQdNcPC3.js";
|
|
22
|
+
import { t as createImportClient } from "./import-FWy_wQZ1.js";
|
|
23
|
+
import { n as isManagementClientAuthError, r as isManagementSessionMintError, t as createManagementClient } from "./management-NYAD6ej4.js";
|
|
24
|
+
import { o as ServiceId, s as ProjectFeature } from "./constants-CA4UN2Xv.js";
|
|
24
25
|
import { t as createStorageTable } from "./storageTable-BldTNyEk.js";
|
|
25
|
-
import { i as createKaiMemorySdk } from "./kaiMemory-
|
|
26
|
+
import { i as createKaiMemorySdk } from "./kaiMemory-C9di17bd.js";
|
|
26
27
|
import { i as createSemanticLayerSdk } from "./semanticLayer-DvjS_nzo.js";
|
|
27
|
-
import { createStorageSdk } from "./sdk/storage/index.js";
|
|
28
28
|
import { createVaultSdk } from "./sdk/vault/index.js";
|
|
29
29
|
import { createAiClient } from "./ai/index.js";
|
|
30
|
-
import { t as parseLogLines } from "./appLogs-
|
|
30
|
+
import { t as parseLogLines } from "./appLogs-KslK7qHr.js";
|
|
31
31
|
import { createAppsClient } from "./apps/index.js";
|
|
32
32
|
import { createBillingClient } from "./billing/index.js";
|
|
33
33
|
import { createChatClient } from "./chat/index.js";
|
|
34
|
-
import { t as
|
|
34
|
+
import { t as createComponentsMcpClient } from "./componentsMcp-CHobIsuU.js";
|
|
35
|
+
import { t as createDataScienceClient } from "./dataScience-AwPMeGfz.js";
|
|
35
36
|
import { createEditorClient } from "./editor/index.js";
|
|
36
37
|
import { createEncryptionClient } from "./encryption/index.js";
|
|
37
|
-
import { t as createKaiAgentClient } from "./kaiAgent-
|
|
38
|
-
import { t as createMetastoreClient } from "./metastore-
|
|
38
|
+
import { t as createKaiAgentClient } from "./kaiAgent-CYvrS8oZ.js";
|
|
39
|
+
import { t as createMetastoreClient } from "./metastore-Ywq08DBz.js";
|
|
39
40
|
import { createNotificationsClient } from "./notifications/index.js";
|
|
40
|
-
import { t as createOauthClient } from "./oauth-
|
|
41
|
+
import { t as createOauthClient } from "./oauth-GXmZ9agP.js";
|
|
41
42
|
import { createOmnisearchClient } from "./omnisearch/index.js";
|
|
42
|
-
import { t as createQueryServiceClient } from "./queryService-
|
|
43
|
-
import { t as createQueueClient } from "./queue-
|
|
43
|
+
import { t as createQueryServiceClient } from "./queryService-C-pZha5p.js";
|
|
44
|
+
import { t as createQueueClient } from "./queue-D6-x4OGF.js";
|
|
44
45
|
import { createSchedulerClient } from "./scheduler/index.js";
|
|
45
46
|
import { createStreamClient } from "./stream/index.js";
|
|
46
|
-
import { t as createSyncActionsClient } from "./syncActions-
|
|
47
|
+
import { t as createSyncActionsClient } from "./syncActions-DM8vP7p3.js";
|
|
47
48
|
import { createTelemetryClient } from "./telemetry/index.js";
|
|
48
49
|
import { createVaultClient } from "./vault/index.js";
|
|
49
|
-
import { n as isUnauthorized, t as createBearerAuthMiddleware } from "./middleware-
|
|
50
|
+
import { n as isUnauthorized, t as createBearerAuthMiddleware } from "./middleware-GOfx8Apu.js";
|
|
50
51
|
import { createQueryServiceSdk } from "./sdk/queryService/index.js";
|
|
51
52
|
import * as z$1 from "zod";
|
|
52
53
|
//#region src/utils/assert.ts
|
|
@@ -208,7 +209,7 @@ const createDerivedAsyncStore = ({ source, dependsOn, build, keyEquals = shallow
|
|
|
208
209
|
//#endregion
|
|
209
210
|
//#region src/utils/async/poll/registry.ts
|
|
210
211
|
const DEFAULT_LIMIT = 50;
|
|
211
|
-
const isFinished = ({ snapshot }) => snapshot.state !== "idle" && snapshot.state !== "polling";
|
|
212
|
+
const isFinished = ({ snapshot }) => snapshot.state !== "idle" && snapshot.state !== "requesting" && snapshot.state !== "polling";
|
|
212
213
|
const createPollRegistry = ({ limit = DEFAULT_LIMIT } = {}) => {
|
|
213
214
|
const entries = createStore([]);
|
|
214
215
|
const unsubscribes = /* @__PURE__ */ new Map();
|
|
@@ -259,6 +260,47 @@ const createPollRegistry = ({ limit = DEFAULT_LIMIT } = {}) => {
|
|
|
259
260
|
};
|
|
260
261
|
};
|
|
261
262
|
//#endregion
|
|
263
|
+
//#region src/utils/async/queueSeries.ts
|
|
264
|
+
const isPromiseLike = (value) => (typeof value === "object" && value !== null || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
265
|
+
/**
|
|
266
|
+
* Queues tasks added over time so a slower earlier task cannot finish after and overwrite a later one.
|
|
267
|
+
* Each `add` returns its task's result; a rejection does not stop the remaining queue.
|
|
268
|
+
*/
|
|
269
|
+
const queueSeries = () => {
|
|
270
|
+
let tail = null;
|
|
271
|
+
const add = (task) => {
|
|
272
|
+
if (tail !== null) {
|
|
273
|
+
const result = tail.then(task);
|
|
274
|
+
tail = result.then(() => void 0, () => void 0);
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
let value;
|
|
278
|
+
try {
|
|
279
|
+
value = task();
|
|
280
|
+
} catch (error) {
|
|
281
|
+
return Promise.reject(error);
|
|
282
|
+
}
|
|
283
|
+
if (!isPromiseLike(value)) return Promise.resolve(value);
|
|
284
|
+
const result = Promise.resolve(value);
|
|
285
|
+
tail = result.then(() => void 0, () => void 0);
|
|
286
|
+
return result;
|
|
287
|
+
};
|
|
288
|
+
const onIdle = async () => {
|
|
289
|
+
while (tail !== null) {
|
|
290
|
+
const current = tail;
|
|
291
|
+
await current;
|
|
292
|
+
if (tail === current) {
|
|
293
|
+
tail = null;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
return {
|
|
299
|
+
add,
|
|
300
|
+
onIdle
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
//#endregion
|
|
262
304
|
//#region src/utils/deepMerge.ts
|
|
263
305
|
/**
|
|
264
306
|
* Recursively merge `patch` into `base`. Plain-object values are merged key-by-key; every
|
|
@@ -316,6 +358,10 @@ const createWebStorage = (pick) => {
|
|
|
316
358
|
},
|
|
317
359
|
removeItem: (key) => {
|
|
318
360
|
storage.removeItem(key);
|
|
361
|
+
},
|
|
362
|
+
withLock: async (name, task) => {
|
|
363
|
+
if (typeof navigator === "undefined" || !("locks" in navigator)) return task();
|
|
364
|
+
return navigator.locks.request(`keboola:${name}`, { mode: "exclusive" }, task);
|
|
319
365
|
}
|
|
320
366
|
};
|
|
321
367
|
};
|
|
@@ -324,62 +370,56 @@ const createSessionStorage = () => createWebStorage(() => "sessionStorage" in gl
|
|
|
324
370
|
//#endregion
|
|
325
371
|
//#region src/utils/persistor/persistor.ts
|
|
326
372
|
const createPersistor = ({ storage = createNullStorage(), key, schema, defaultValue, encode = JSON.stringify, decode = JSON.parse }) => {
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const hasPersistedValue = () => {
|
|
335
|
-
try {
|
|
336
|
-
return !!storage.getItem(key);
|
|
337
|
-
} catch (err) {
|
|
338
|
-
console.warn(`createPersistor: failed to read "${key}", assuming empty`, err);
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
const hydrate = () => {
|
|
343
|
-
let raw;
|
|
344
|
-
try {
|
|
345
|
-
raw = storage.getItem(key);
|
|
346
|
-
} catch (err) {
|
|
347
|
-
console.warn(`createPersistor: failed to read "${key}", using default`, err);
|
|
348
|
-
return defaultValue;
|
|
349
|
-
}
|
|
350
|
-
if (raw === null) return defaultValue;
|
|
373
|
+
const writes = queueSeries();
|
|
374
|
+
const _load = async () => {
|
|
375
|
+
const raw = await storage.getItem(key);
|
|
376
|
+
if (raw === null) return {
|
|
377
|
+
value: defaultValue,
|
|
378
|
+
corrupt: false
|
|
379
|
+
};
|
|
351
380
|
let decoded;
|
|
352
381
|
try {
|
|
353
382
|
decoded = decode(raw);
|
|
354
383
|
} catch (err) {
|
|
355
|
-
console.warn(`createPersistor: failed to decode "${key}"
|
|
356
|
-
|
|
357
|
-
|
|
384
|
+
console.warn(`createPersistor: failed to decode "${key}"`, err);
|
|
385
|
+
return {
|
|
386
|
+
value: defaultValue,
|
|
387
|
+
corrupt: true
|
|
388
|
+
};
|
|
358
389
|
}
|
|
359
390
|
const parsed = schema.safeParse(decoded);
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
391
|
+
return parsed.success ? {
|
|
392
|
+
value: parsed.data,
|
|
393
|
+
corrupt: false
|
|
394
|
+
} : {
|
|
395
|
+
value: defaultValue,
|
|
396
|
+
corrupt: true
|
|
397
|
+
};
|
|
363
398
|
};
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
storage.setItem(key, raw);
|
|
374
|
-
} catch (err) {
|
|
375
|
-
console.warn(`createPersistor: failed to write "${key}"`, err);
|
|
376
|
-
}
|
|
399
|
+
const remove = () => writes.add(() => storage.removeItem(key));
|
|
400
|
+
const write = (value) => writes.add(() => storage.setItem(key, encode(value)));
|
|
401
|
+
const read = async () => {
|
|
402
|
+
await writes.onIdle();
|
|
403
|
+
const parsed = await _load();
|
|
404
|
+
if (parsed.corrupt) remove().catch((err) => {
|
|
405
|
+
console.warn(`createPersistor: failed to drop the corrupt "${key}"`, err);
|
|
406
|
+
});
|
|
407
|
+
return parsed.value;
|
|
377
408
|
};
|
|
409
|
+
const modify = (change) => writes.add(async () => {
|
|
410
|
+
const next = change((await _load()).value);
|
|
411
|
+
await storage.setItem(key, encode(next));
|
|
412
|
+
});
|
|
413
|
+
const cell = {
|
|
414
|
+
read,
|
|
415
|
+
write,
|
|
416
|
+
modify,
|
|
417
|
+
remove
|
|
418
|
+
};
|
|
419
|
+
const locked = (task) => storage.withLock ? storage.withLock(key, () => task(cell)) : task(cell);
|
|
378
420
|
return {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
clear,
|
|
382
|
-
hasPersistedValue
|
|
421
|
+
...cell,
|
|
422
|
+
locked
|
|
383
423
|
};
|
|
384
424
|
};
|
|
385
425
|
//#endregion
|
|
@@ -427,8 +467,7 @@ const KeboolaErrorType = {
|
|
|
427
467
|
NotBearer: "not-bearer",
|
|
428
468
|
NotReady: "not-ready",
|
|
429
469
|
InvalidBuildTransition: "invalid-build-transition",
|
|
430
|
-
StackActive: "stack-active"
|
|
431
|
-
CredentialKindMismatch: "credential-kind-mismatch"
|
|
470
|
+
StackActive: "stack-active"
|
|
432
471
|
};
|
|
433
472
|
const MESSAGES = {
|
|
434
473
|
[KeboolaErrorType.Unconfigured]: "The session is not configured — set a baseUrl first.",
|
|
@@ -441,8 +480,7 @@ const MESSAGES = {
|
|
|
441
480
|
[KeboolaErrorType.NotBearer]: "This operation requires a bearer (OAuth) session.",
|
|
442
481
|
[KeboolaErrorType.NotReady]: "The client is not ready — authenticate the storage realm first.",
|
|
443
482
|
[KeboolaErrorType.InvalidBuildTransition]: "Invalid storage build transition — the build goes idle → initializing → ready | failed.",
|
|
444
|
-
[KeboolaErrorType.StackActive]: "The active stack cannot be closed — select another first."
|
|
445
|
-
[KeboolaErrorType.CredentialKindMismatch]: "This client renews the other credential kind — log in the way its `credentials` mode expects."
|
|
483
|
+
[KeboolaErrorType.StackActive]: "The active stack cannot be closed — select another first."
|
|
446
484
|
};
|
|
447
485
|
var KeboolaError = class KeboolaError extends Error {
|
|
448
486
|
type;
|
|
@@ -603,10 +641,12 @@ const createDefaultBranch = ({ devBranches }) => {
|
|
|
603
641
|
};
|
|
604
642
|
//#endregion
|
|
605
643
|
//#region src/domain/stack.ts
|
|
644
|
+
const isServiceId = (id) => Object.values(ServiceId).includes(id);
|
|
606
645
|
const SERVICE_URL_OVERRIDES = { "kai-assistant": (url) => `${url}/api` };
|
|
607
646
|
const createStack = ({ stackInfo, clientServiceUrls }) => {
|
|
608
647
|
const { services, components, features, ...infoRest } = stackInfo;
|
|
609
648
|
const serviceMap = new Map(services.map((service) => {
|
|
649
|
+
if (!isServiceId(service.id)) return [service.id, service.url];
|
|
610
650
|
const devOverride = clientServiceUrls?.[service.id]?.(service.url);
|
|
611
651
|
const prodOverride = SERVICE_URL_OVERRIDES[service.id]?.(service.url);
|
|
612
652
|
const url = devOverride ?? prodOverride ?? service.url;
|
|
@@ -730,7 +770,6 @@ const createSdk = ({ storage, services, context }) => ({
|
|
|
730
770
|
tag: createTagSdk({ metastoreClient: services.metastore }),
|
|
731
771
|
semanticLayer: createSemanticLayerSdk({ metastoreClient: services.metastore }),
|
|
732
772
|
kaiMemory: createKaiMemorySdk({ metastoreClient: services.metastore }),
|
|
733
|
-
storage: createStorageSdk({ storageClient: storage }),
|
|
734
773
|
vault: createVaultSdk({
|
|
735
774
|
vaultClient: services.vault,
|
|
736
775
|
encryptionClient: services.encryption
|
|
@@ -857,6 +896,14 @@ const createServiceClients = ({ baseUrl, auth, getServiceBaseUrl, middlewareFor,
|
|
|
857
896
|
middlewares: middlewareFor("kaiAgent", [attachTokenMiddleware]),
|
|
858
897
|
auth
|
|
859
898
|
})
|
|
899
|
+
}).add({
|
|
900
|
+
serviceId: "components-mcp",
|
|
901
|
+
clientName: "componentsMcp",
|
|
902
|
+
clientFn: (serviceBaseUrl) => createComponentsMcpClient({
|
|
903
|
+
baseUrl: serviceBaseUrl,
|
|
904
|
+
middlewares: middlewareFor("componentsMcp", [attachTokenMiddleware]),
|
|
905
|
+
auth
|
|
906
|
+
})
|
|
860
907
|
}).add({
|
|
861
908
|
serviceId: "oauth",
|
|
862
909
|
clientName: "oauth",
|
|
@@ -1064,154 +1111,6 @@ const createLegacyKeboola = (options = {}) => {
|
|
|
1064
1111
|
};
|
|
1065
1112
|
};
|
|
1066
1113
|
//#endregion
|
|
1067
|
-
//#region src/keboola/bearer/credentials/renewal.ts
|
|
1068
|
-
const renewalGrant = (credential) => credential.type === "token" ? {
|
|
1069
|
-
type: "token",
|
|
1070
|
-
refreshToken: credential.refreshToken
|
|
1071
|
-
} : {
|
|
1072
|
-
type: "cookie",
|
|
1073
|
-
sessionId: credential.sessionId
|
|
1074
|
-
};
|
|
1075
|
-
const renew = async (client, grant) => {
|
|
1076
|
-
if (grant.type === "cookie") {
|
|
1077
|
-
const { accessToken, expiresIn, sessionId } = await client.token.refreshWithSession({ sessionId: grant.sessionId });
|
|
1078
|
-
return {
|
|
1079
|
-
type: "cookie",
|
|
1080
|
-
accessToken,
|
|
1081
|
-
expiresIn,
|
|
1082
|
-
sessionId
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
const { accessToken, expiresIn, refreshToken } = await client.token.refreshWithToken({ refreshToken: grant.refreshToken });
|
|
1086
|
-
if (!refreshToken) throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
1087
|
-
return {
|
|
1088
|
-
type: "token",
|
|
1089
|
-
accessToken,
|
|
1090
|
-
expiresIn,
|
|
1091
|
-
refreshToken
|
|
1092
|
-
};
|
|
1093
|
-
};
|
|
1094
|
-
//#endregion
|
|
1095
|
-
//#region src/keboola/bearer/credentials/credentials.ts
|
|
1096
|
-
const DEFAULT_REFRESH_THRESHOLD = .9;
|
|
1097
|
-
const signInEnded = () => new KeboolaError(KeboolaErrorType.SignInEnded);
|
|
1098
|
-
const createCredentials = ({ state, persistor, middlewares, mode = "token", refreshThreshold = DEFAULT_REFRESH_THRESHOLD, onSignedOut }) => {
|
|
1099
|
-
const rotationMap = /* @__PURE__ */ new Map();
|
|
1100
|
-
const generations = /* @__PURE__ */ new Map();
|
|
1101
|
-
const generationOf = (baseUrl) => generations.get(baseUrl) ?? 0;
|
|
1102
|
-
const refresh = async (baseUrl, grant) => {
|
|
1103
|
-
const client = createAuthClient({
|
|
1104
|
-
baseUrl,
|
|
1105
|
-
middlewares
|
|
1106
|
-
});
|
|
1107
|
-
const epochBefore = Result.unwrap(state.auth.getEpoch(baseUrl));
|
|
1108
|
-
const generationBefore = generationOf(baseUrl);
|
|
1109
|
-
const refreshed = await Result.tryCatchAsync(() => renew(client, grant));
|
|
1110
|
-
return Result.unwrapOr(state.auth.getEpoch(baseUrl), -1) === epochBefore && generationOf(baseUrl) === generationBefore ? refreshed : Result.failure(signInEnded());
|
|
1111
|
-
};
|
|
1112
|
-
/**
|
|
1113
|
-
* A stack's teardown, from the credential's side.
|
|
1114
|
-
*
|
|
1115
|
-
* - Bumps the generation, so an in-flight rotation can no longer write.
|
|
1116
|
-
* - Drops the deduped entry, so nothing joins that rotation.
|
|
1117
|
-
*/
|
|
1118
|
-
const forget = (baseUrl) => {
|
|
1119
|
-
generations.set(baseUrl, generationOf(baseUrl) + 1);
|
|
1120
|
-
rotationMap.delete(baseUrl);
|
|
1121
|
-
};
|
|
1122
|
-
/**
|
|
1123
|
-
* The rotation, and the one place a credential is declared dead.
|
|
1124
|
-
*
|
|
1125
|
-
* - A refused refresh token or session is unambiguous.
|
|
1126
|
-
* - The triggering 401 is not (an unreachable project answers the same), so never sign out on a replay.
|
|
1127
|
-
*/
|
|
1128
|
-
const rotateOnce = async (baseUrl) => {
|
|
1129
|
-
const credential = state.auth.requireCredentialOf(baseUrl, mode);
|
|
1130
|
-
if (!credential.success) return credential;
|
|
1131
|
-
const refreshed = await refresh(baseUrl, renewalGrant(credential.data));
|
|
1132
|
-
if (!refreshed.success) {
|
|
1133
|
-
if (isUnauthorized(refreshed.error)) expire(baseUrl);
|
|
1134
|
-
return refreshed;
|
|
1135
|
-
}
|
|
1136
|
-
return Result.map(state.auth.applyRefresh(baseUrl, refreshed.data), () => refreshed.data.accessToken);
|
|
1137
|
-
};
|
|
1138
|
-
const rotate = (baseUrl) => ensure(rotationMap, baseUrl, () => dedupe(() => rotateOnce(baseUrl)))();
|
|
1139
|
-
const restoreStack = async (baseUrl, grant) => {
|
|
1140
|
-
if (!state.auth.startRestore(baseUrl).success) return "unreachable";
|
|
1141
|
-
const refreshed = await refresh(baseUrl, grant);
|
|
1142
|
-
if (!refreshed.success) {
|
|
1143
|
-
state.auth.cancelRestore(baseUrl);
|
|
1144
|
-
return isUnauthorized(refreshed.error) ? "refused" : "unreachable";
|
|
1145
|
-
}
|
|
1146
|
-
state.auth.authenticate(baseUrl, refreshed.data);
|
|
1147
|
-
return "restored";
|
|
1148
|
-
};
|
|
1149
|
-
const restoreProjects = (baseUrl, projects) => {
|
|
1150
|
-
for (const { projectId } of projects) state.projects.open(baseUrl, projectId);
|
|
1151
|
-
};
|
|
1152
|
-
/**
|
|
1153
|
-
* Every persisted stack back into the table, with whatever credential it can hand back.
|
|
1154
|
-
*
|
|
1155
|
-
* - Never writes the scope. `lastActive` is what was scoped when the session was stored, for the
|
|
1156
|
-
* caller to select.
|
|
1157
|
-
* - `status` reports what became of `lastActive`'s credential; the client reads it to decide
|
|
1158
|
-
* when persistence may start.
|
|
1159
|
-
*/
|
|
1160
|
-
const restore = async () => {
|
|
1161
|
-
const hydrated = persistor.hydrate();
|
|
1162
|
-
const stacks = hydrated.stacks.map((stack) => stack.credential && stack.credential.type !== "static" && stack.credential.type !== mode ? {
|
|
1163
|
-
...stack,
|
|
1164
|
-
credential: null
|
|
1165
|
-
} : stack);
|
|
1166
|
-
const { current } = hydrated;
|
|
1167
|
-
const scoped = stacks.find(({ baseUrl }) => baseUrl === current?.baseUrl);
|
|
1168
|
-
const restored = stacks.map(async ({ baseUrl, credential, projects }) => {
|
|
1169
|
-
state.stacks.ensure(baseUrl);
|
|
1170
|
-
if (!credential) return "unreachable";
|
|
1171
|
-
if (Result.unwrapOr(state.auth.getEpoch(baseUrl), 0) > 0) return "skipped";
|
|
1172
|
-
const outcome = credential.type === "static" ? state.auth.authenticate(baseUrl, credential).success ? "restored" : "refused" : await restoreStack(baseUrl, credential);
|
|
1173
|
-
if (outcome === "restored") restoreProjects(baseUrl, projects);
|
|
1174
|
-
return outcome;
|
|
1175
|
-
});
|
|
1176
|
-
const results = await Promise.all(restored);
|
|
1177
|
-
const outcome = scoped?.credential ? results[stacks.indexOf(scoped)] : void 0;
|
|
1178
|
-
return {
|
|
1179
|
-
lastActive: current,
|
|
1180
|
-
status: outcome === void 0 || outcome === "skipped" ? "empty" : outcome === "restored" ? "restored" : outcome === "unreachable" ? "unreachable" : "expired"
|
|
1181
|
-
};
|
|
1182
|
-
};
|
|
1183
|
-
const isStale = (baseUrl) => {
|
|
1184
|
-
const ageing = Result.map(state.auth.requireCredentialOf(baseUrl, mode), ({ issuedAt, expiresIn }) => Date.now() >= issuedAt + expiresIn * 1e3 * refreshThreshold);
|
|
1185
|
-
return Result.unwrapOr(ageing, false);
|
|
1186
|
-
};
|
|
1187
|
-
const signOut = (baseUrl) => {
|
|
1188
|
-
rotationMap.delete(baseUrl);
|
|
1189
|
-
const signedOut = state.auth.signOut(baseUrl);
|
|
1190
|
-
onSignedOut?.(baseUrl);
|
|
1191
|
-
return signedOut;
|
|
1192
|
-
};
|
|
1193
|
-
const expire = (baseUrl) => {
|
|
1194
|
-
if (state.auth.notifyExpired(baseUrl)) signOut(baseUrl);
|
|
1195
|
-
};
|
|
1196
|
-
const canRefresh = (baseUrl) => state.auth.requireCredentialOf(baseUrl, mode).success;
|
|
1197
|
-
const renewIfStale = async (baseUrl) => {
|
|
1198
|
-
if (isStale(baseUrl)) await rotate(baseUrl);
|
|
1199
|
-
};
|
|
1200
|
-
const middleware = (baseUrl) => createBearerAuthMiddleware({ getAccessToken: async ({ forceRefresh = false } = {}) => {
|
|
1201
|
-
if (forceRefresh) return canRefresh(baseUrl) ? Result.unwrap(await rotate(baseUrl)) : null;
|
|
1202
|
-
await renewIfStale(baseUrl);
|
|
1203
|
-
return state.auth.getAccessToken(baseUrl);
|
|
1204
|
-
} });
|
|
1205
|
-
return {
|
|
1206
|
-
middleware,
|
|
1207
|
-
rotate,
|
|
1208
|
-
renewIfStale,
|
|
1209
|
-
restore,
|
|
1210
|
-
signOut,
|
|
1211
|
-
forget
|
|
1212
|
-
};
|
|
1213
|
-
};
|
|
1214
|
-
//#endregion
|
|
1215
1114
|
//#region src/keboola/bearer/state/factories.ts
|
|
1216
1115
|
/**
|
|
1217
1116
|
* Everything the table constructs: the entries themselves, and the failures reading them produces.
|
|
@@ -1229,9 +1128,16 @@ const authenticatedAuth = (credential) => ({
|
|
|
1229
1128
|
status: "authenticated",
|
|
1230
1129
|
credential
|
|
1231
1130
|
});
|
|
1232
|
-
const
|
|
1131
|
+
const credential = (input) => ({
|
|
1233
1132
|
...input,
|
|
1234
1133
|
issuedAt: Date.now()
|
|
1134
|
+
});
|
|
1135
|
+
const grant = (credential) => credential.type === "token" ? {
|
|
1136
|
+
type: "token",
|
|
1137
|
+
refreshToken: credential.refreshToken
|
|
1138
|
+
} : {
|
|
1139
|
+
type: "cookie",
|
|
1140
|
+
sessionId: credential.sessionId
|
|
1235
1141
|
};
|
|
1236
1142
|
const expiredCredential = (credential) => ({
|
|
1237
1143
|
...credential,
|
|
@@ -1241,7 +1147,8 @@ const stack = (baseUrl) => ({
|
|
|
1241
1147
|
baseUrl,
|
|
1242
1148
|
context: "idle",
|
|
1243
1149
|
epoch: 0,
|
|
1244
|
-
auth: anonymousAuth()
|
|
1150
|
+
auth: anonymousAuth(),
|
|
1151
|
+
retained: null
|
|
1245
1152
|
});
|
|
1246
1153
|
const project = (baseUrl, projectId) => ({
|
|
1247
1154
|
id: projectEntryId(baseUrl, projectId),
|
|
@@ -1273,7 +1180,8 @@ const Entry = {
|
|
|
1273
1180
|
anonymousAuth,
|
|
1274
1181
|
restoringAuth,
|
|
1275
1182
|
authenticatedAuth,
|
|
1276
|
-
|
|
1183
|
+
credential,
|
|
1184
|
+
grant,
|
|
1277
1185
|
expiredCredential
|
|
1278
1186
|
};
|
|
1279
1187
|
/**
|
|
@@ -1291,9 +1199,8 @@ const Errors = {
|
|
|
1291
1199
|
notReady: () => new KeboolaError(KeboolaErrorType.NotReady),
|
|
1292
1200
|
alreadyRestoring: (baseUrl) => /* @__PURE__ */ new Error(`Stack "${baseUrl}" is already being restored`),
|
|
1293
1201
|
notRestoring: (baseUrl) => /* @__PURE__ */ new Error(`Stack "${baseUrl}" is not being restored`),
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
credentialKindChanged: (from, to) => /* @__PURE__ */ new Error(`A ${from} credential cannot become ${to}`),
|
|
1202
|
+
grantTypeChanged: (from, to) => /* @__PURE__ */ new Error(`A ${from} grant cannot become ${to}`),
|
|
1203
|
+
nothingRetained: (baseUrl) => /* @__PURE__ */ new Error(`Stack "${baseUrl}" retains no credential`),
|
|
1297
1204
|
missingProject: (id) => /* @__PURE__ */ new Error(`No project "${id}"`)
|
|
1298
1205
|
};
|
|
1299
1206
|
const authenticated = (auth) => auth.status === "authenticated" ? Result.success(auth.credential) : Result.failure(Errors.notAuthenticated());
|
|
@@ -1325,8 +1232,6 @@ const createAuth = ({ stacks, projects, expiry }) => {
|
|
|
1325
1232
|
const requireUnauthenticated = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.auth.status === "authenticated" ? Result.failure(Errors.alreadyAuthenticated()) : Result.success(stack));
|
|
1326
1233
|
const requireAnonymous = (baseUrl) => Result.andThen(requireUnauthenticated(baseUrl), (stack) => stack.auth.status === "restoring" ? Result.failure(Errors.alreadyRestoring(baseUrl)) : Result.success(stack));
|
|
1327
1234
|
const requireRestoring = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.auth.status === "restoring" ? Result.success(stack) : Result.failure(Errors.notRestoring(baseUrl)));
|
|
1328
|
-
const requireRotatingCredential = (baseUrl) => Result.andThen(stacks.requireCredential(baseUrl), (credential) => credential.type === "static" ? Result.failure(Errors.notRotatingCredential(baseUrl)) : Result.success(credential));
|
|
1329
|
-
const requireCredentialOf = (baseUrl, mode) => Result.andThen(requireRotatingCredential(baseUrl), (credential) => credential.type === mode ? Result.success(credential) : Result.failure(Errors.unexpectedCredentialKind(baseUrl, credential.type)));
|
|
1330
1235
|
const startRestore = (baseUrl) => Result.map(requireAnonymous(baseUrl), (stack) => stacks.set({
|
|
1331
1236
|
...stack,
|
|
1332
1237
|
auth: Entry.restoringAuth()
|
|
@@ -1340,25 +1245,37 @@ const createAuth = ({ stacks, projects, expiry }) => {
|
|
|
1340
1245
|
return stacks.set({
|
|
1341
1246
|
...stack,
|
|
1342
1247
|
epoch: stack.epoch + 1,
|
|
1343
|
-
auth: Entry.authenticatedAuth(Entry.
|
|
1248
|
+
auth: Entry.authenticatedAuth(Entry.credential(input)),
|
|
1249
|
+
retained: null
|
|
1344
1250
|
});
|
|
1345
1251
|
});
|
|
1346
|
-
const applyRefresh = (baseUrl, input) => Result.andThen(
|
|
1252
|
+
const applyRefresh = (baseUrl, input) => Result.andThen(stacks.requireCredential(baseUrl), (credential) => credential.type !== input.type ? Result.failure(Errors.grantTypeChanged(credential.type, input.type)) : Result.map(stacks.get(baseUrl), (stack) => stacks.set({
|
|
1347
1253
|
...stack,
|
|
1348
|
-
auth: Entry.authenticatedAuth(Entry.
|
|
1254
|
+
auth: Entry.authenticatedAuth(Entry.credential(input))
|
|
1349
1255
|
})));
|
|
1350
|
-
const forceExpire = (baseUrl) => Result.andThen(
|
|
1256
|
+
const forceExpire = (baseUrl) => Result.andThen(stacks.requireCredential(baseUrl), (credential) => Result.map(stacks.get(baseUrl), (stack) => stacks.set({
|
|
1351
1257
|
...stack,
|
|
1352
1258
|
auth: Entry.authenticatedAuth(Entry.expiredCredential(credential))
|
|
1353
1259
|
})));
|
|
1354
|
-
const signOut = (baseUrl) => Result.map(stacks.get(baseUrl), (stack) => {
|
|
1260
|
+
const signOut = (baseUrl, { retain = false } = {}) => Result.map(stacks.get(baseUrl), (stack) => {
|
|
1355
1261
|
projects.closeAll(baseUrl);
|
|
1262
|
+
const retained = retain ? Result.unwrapOr(Result.map(authenticated(stack.auth), (credential) => ({ grant: Entry.grant(credential) })), stack.retained) : null;
|
|
1356
1263
|
return stacks.set({
|
|
1357
1264
|
...stack,
|
|
1358
1265
|
epoch: stack.epoch + 1,
|
|
1359
|
-
auth: Entry.anonymousAuth()
|
|
1266
|
+
auth: Entry.anonymousAuth(),
|
|
1267
|
+
retained
|
|
1360
1268
|
});
|
|
1361
1269
|
});
|
|
1270
|
+
const retain = (baseUrl, retained) => Result.map(stacks.get(baseUrl), (stack) => stacks.set({
|
|
1271
|
+
...stack,
|
|
1272
|
+
retained
|
|
1273
|
+
}));
|
|
1274
|
+
const dropRetained = (baseUrl) => Result.map(stacks.get(baseUrl), (stack) => stacks.set({
|
|
1275
|
+
...stack,
|
|
1276
|
+
retained: null
|
|
1277
|
+
}));
|
|
1278
|
+
const requireRetained = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.retained ? Result.success(stack.retained) : Result.failure(Errors.nothingRetained(baseUrl)));
|
|
1362
1279
|
const getEpoch = (baseUrl) => Result.map(stacks.get(baseUrl), (stack) => stack.epoch);
|
|
1363
1280
|
const getAccessToken = (baseUrl) => Result.unwrapOr(Result.map(stacks.requireCredential(baseUrl), ({ accessToken }) => accessToken), null);
|
|
1364
1281
|
return {
|
|
@@ -1368,10 +1285,11 @@ const createAuth = ({ stacks, projects, expiry }) => {
|
|
|
1368
1285
|
applyRefresh,
|
|
1369
1286
|
forceExpire,
|
|
1370
1287
|
signOut,
|
|
1288
|
+
retain,
|
|
1289
|
+
dropRetained,
|
|
1290
|
+
requireRetained,
|
|
1371
1291
|
notifyExpired: expiry.report,
|
|
1372
1292
|
requireCredential: stacks.requireCredential,
|
|
1373
|
-
requireRotatingCredential,
|
|
1374
|
-
requireCredentialOf,
|
|
1375
1293
|
getEpoch,
|
|
1376
1294
|
getAccessToken
|
|
1377
1295
|
};
|
|
@@ -1623,6 +1541,204 @@ const createState = (defaultBaseUrl) => {
|
|
|
1623
1541
|
};
|
|
1624
1542
|
};
|
|
1625
1543
|
//#endregion
|
|
1544
|
+
//#region src/keboola/bearer/credentials/renewal.ts
|
|
1545
|
+
const renew = async (client, grant) => {
|
|
1546
|
+
if (grant.type === "cookie") {
|
|
1547
|
+
const { accessToken, expiresIn, sessionId } = await client.token.refreshWithSession({ sessionId: grant.sessionId });
|
|
1548
|
+
return {
|
|
1549
|
+
type: "cookie",
|
|
1550
|
+
accessToken,
|
|
1551
|
+
expiresIn,
|
|
1552
|
+
sessionId
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
const { accessToken, expiresIn, refreshToken } = await client.token.refreshWithToken({ refreshToken: grant.refreshToken });
|
|
1556
|
+
if (!refreshToken) throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
1557
|
+
return {
|
|
1558
|
+
type: "token",
|
|
1559
|
+
accessToken,
|
|
1560
|
+
expiresIn,
|
|
1561
|
+
refreshToken
|
|
1562
|
+
};
|
|
1563
|
+
};
|
|
1564
|
+
//#endregion
|
|
1565
|
+
//#region src/keboola/bearer/credentials/credentials.ts
|
|
1566
|
+
const DEFAULT_REFRESH_THRESHOLD = .9;
|
|
1567
|
+
const signInEnded = () => new KeboolaError(KeboolaErrorType.SignInEnded);
|
|
1568
|
+
const toRestoreStatus = (outcome) => {
|
|
1569
|
+
if (outcome === void 0 || outcome === "skipped") return "empty";
|
|
1570
|
+
if (outcome === "refused") return "expired";
|
|
1571
|
+
return outcome;
|
|
1572
|
+
};
|
|
1573
|
+
const createCredentials = ({ state, persistor, middlewares, refreshThreshold = DEFAULT_REFRESH_THRESHOLD, onSignedOut, onExpired }) => {
|
|
1574
|
+
const rotationMap = /* @__PURE__ */ new Map();
|
|
1575
|
+
const generations = /* @__PURE__ */ new Map();
|
|
1576
|
+
const generationOf = (baseUrl) => generations.get(baseUrl) ?? 0;
|
|
1577
|
+
const refresh = async (baseUrl, grant) => {
|
|
1578
|
+
const client = createAuthClient({
|
|
1579
|
+
baseUrl,
|
|
1580
|
+
middlewares
|
|
1581
|
+
});
|
|
1582
|
+
const epochBefore = Result.unwrap(state.auth.getEpoch(baseUrl));
|
|
1583
|
+
const generationBefore = generationOf(baseUrl);
|
|
1584
|
+
const refreshed = await Result.tryCatchAsync(() => renew(client, grant));
|
|
1585
|
+
return Result.unwrapOr(state.auth.getEpoch(baseUrl), -1) === epochBefore && generationOf(baseUrl) === generationBefore ? refreshed : Result.failure(signInEnded());
|
|
1586
|
+
};
|
|
1587
|
+
/**
|
|
1588
|
+
* A stack's teardown, from the credential's side.
|
|
1589
|
+
*
|
|
1590
|
+
* - Bumps the generation, so an in-flight rotation can no longer write.
|
|
1591
|
+
* - Drops the deduped entry, so nothing joins that rotation.
|
|
1592
|
+
*/
|
|
1593
|
+
const forget = (baseUrl) => {
|
|
1594
|
+
generations.set(baseUrl, generationOf(baseUrl) + 1);
|
|
1595
|
+
rotationMap.delete(baseUrl);
|
|
1596
|
+
};
|
|
1597
|
+
/**
|
|
1598
|
+
* The rotation, and the one place a credential is declared dead.
|
|
1599
|
+
*
|
|
1600
|
+
* - Renews by the credential's grant: the refresh token, or the session id with the cookie.
|
|
1601
|
+
* - A refused refresh token or session is unambiguous.
|
|
1602
|
+
* - The triggering 401 is not (an unreachable project answers the same), so never sign out on a replay.
|
|
1603
|
+
*/
|
|
1604
|
+
const getGrantForRotation = async (store, baseUrl, credential) => {
|
|
1605
|
+
const epochBefore = Result.unwrap(state.auth.getEpoch(baseUrl));
|
|
1606
|
+
const generationBefore = generationOf(baseUrl);
|
|
1607
|
+
const hydrated = await Result.tryCatchAsync(() => store.read());
|
|
1608
|
+
if (!hydrated.success) return hydrated;
|
|
1609
|
+
if (Result.unwrapOr(state.auth.getEpoch(baseUrl), -1) !== epochBefore || generationOf(baseUrl) !== generationBefore) return Result.failure(signInEnded());
|
|
1610
|
+
const persistedStack = hydrated.data.stacks.find((stack) => stack.baseUrl === baseUrl);
|
|
1611
|
+
if (persistedStack && persistedStack.credential === null) return Result.failure(signInEnded());
|
|
1612
|
+
return Result.success(persistedStack?.credential ?? Entry.grant(credential));
|
|
1613
|
+
};
|
|
1614
|
+
const rotateOnce = async (baseUrl) => persistor.locked(async (store) => {
|
|
1615
|
+
const credential = state.auth.requireCredential(baseUrl);
|
|
1616
|
+
if (!credential.success) return credential;
|
|
1617
|
+
const grant = await getGrantForRotation(store, baseUrl, credential.data);
|
|
1618
|
+
if (!grant.success) return grant;
|
|
1619
|
+
const refreshed = await refresh(baseUrl, grant.data);
|
|
1620
|
+
if (!refreshed.success) {
|
|
1621
|
+
if (isUnauthorized(refreshed.error)) await expire(baseUrl, store);
|
|
1622
|
+
return refreshed;
|
|
1623
|
+
}
|
|
1624
|
+
const accessToken = Result.map(state.auth.applyRefresh(baseUrl, refreshed.data), () => refreshed.data.accessToken);
|
|
1625
|
+
await store.persistStack(baseUrl, state.store.get());
|
|
1626
|
+
return accessToken;
|
|
1627
|
+
});
|
|
1628
|
+
const rotate = (baseUrl) => ensure(rotationMap, baseUrl, () => dedupe(() => rotateOnce(baseUrl)))();
|
|
1629
|
+
const restoreStack = async (baseUrl, grant, retained = false) => persistor.locked(async (store) => {
|
|
1630
|
+
const storedStack = (await store.read()).stacks.find((stack) => stack.baseUrl === baseUrl);
|
|
1631
|
+
const latestGrant = retained ? storedStack?.retained?.grant : storedStack?.credential;
|
|
1632
|
+
if (storedStack && !latestGrant) return "skipped";
|
|
1633
|
+
if (!state.auth.startRestore(baseUrl).success) return "unreachable";
|
|
1634
|
+
const refreshed = await refresh(baseUrl, latestGrant ?? grant);
|
|
1635
|
+
if (!refreshed.success) {
|
|
1636
|
+
state.auth.cancelRestore(baseUrl);
|
|
1637
|
+
if (isUnauthorized(refreshed.error)) {
|
|
1638
|
+
if (retained) state.auth.dropRetained(baseUrl);
|
|
1639
|
+
await store.persistStack(baseUrl, state.store.get());
|
|
1640
|
+
return "refused";
|
|
1641
|
+
}
|
|
1642
|
+
return "unreachable";
|
|
1643
|
+
}
|
|
1644
|
+
state.auth.authenticate(baseUrl, refreshed.data);
|
|
1645
|
+
if (!state.auth.requireCredential(baseUrl).success) return "unreachable";
|
|
1646
|
+
if (retained) state.auth.dropRetained(baseUrl);
|
|
1647
|
+
await store.persistStack(baseUrl, state.store.get());
|
|
1648
|
+
return "restored";
|
|
1649
|
+
});
|
|
1650
|
+
const restoreProjects = (baseUrl, projects) => {
|
|
1651
|
+
for (const { projectId } of projects) state.projects.open(baseUrl, projectId);
|
|
1652
|
+
};
|
|
1653
|
+
/**
|
|
1654
|
+
* Every persisted stack back into the table, with whatever credential it can hand back.
|
|
1655
|
+
*
|
|
1656
|
+
* - Never writes the scope. `lastActive` is what was scoped when the session was stored, for the
|
|
1657
|
+
* caller to select.
|
|
1658
|
+
* - `status` reports what became of `lastActive`'s credential; the client reads it to decide
|
|
1659
|
+
* when persistence may start.
|
|
1660
|
+
*/
|
|
1661
|
+
const restore = async () => {
|
|
1662
|
+
const hydrated = await persistor.locked((store) => store.read()).catch((error) => {
|
|
1663
|
+
console.warn("createCredentials: the stored session could not be read", error);
|
|
1664
|
+
return null;
|
|
1665
|
+
});
|
|
1666
|
+
if (hydrated === null) return {
|
|
1667
|
+
lastActive: null,
|
|
1668
|
+
status: "unreachable"
|
|
1669
|
+
};
|
|
1670
|
+
const { stacks, current } = hydrated;
|
|
1671
|
+
const scoped = stacks.find(({ baseUrl }) => baseUrl === current?.baseUrl);
|
|
1672
|
+
const restored = stacks.map(async ({ baseUrl, credential, retained, projects }) => {
|
|
1673
|
+
state.stacks.ensure(baseUrl);
|
|
1674
|
+
if (!credential && !retained) return "unreachable";
|
|
1675
|
+
if (Result.unwrapOr(state.auth.getEpoch(baseUrl), 0) > 0) return "skipped";
|
|
1676
|
+
if (retained) state.auth.retain(baseUrl, retained);
|
|
1677
|
+
if (!credential) return "unreachable";
|
|
1678
|
+
const outcome = await restoreStack(baseUrl, credential);
|
|
1679
|
+
if (outcome === "restored") restoreProjects(baseUrl, projects);
|
|
1680
|
+
return outcome;
|
|
1681
|
+
});
|
|
1682
|
+
const results = await Promise.all(restored);
|
|
1683
|
+
const scopedOutcome = scoped?.credential ? results[stacks.indexOf(scoped)] : void 0;
|
|
1684
|
+
return {
|
|
1685
|
+
lastActive: current,
|
|
1686
|
+
status: toRestoreStatus(scopedOutcome)
|
|
1687
|
+
};
|
|
1688
|
+
};
|
|
1689
|
+
/**
|
|
1690
|
+
* Signs a retained stack back in from the grant it kept.
|
|
1691
|
+
*
|
|
1692
|
+
* - `restored` and `refused` empty the slot; `unreachable` keeps it for another try.
|
|
1693
|
+
* - Throws when the stack retains nothing.
|
|
1694
|
+
*/
|
|
1695
|
+
const restoreRetained = async (baseUrl) => {
|
|
1696
|
+
const { grant } = Result.unwrap(state.auth.requireRetained(baseUrl));
|
|
1697
|
+
return restoreStack(baseUrl, grant, true);
|
|
1698
|
+
};
|
|
1699
|
+
const isStale = (baseUrl) => {
|
|
1700
|
+
const ageing = Result.map(state.auth.requireCredential(baseUrl), ({ issuedAt, expiresIn }) => Date.now() >= issuedAt + expiresIn * 1e3 * refreshThreshold);
|
|
1701
|
+
return Result.unwrapOr(ageing, false);
|
|
1702
|
+
};
|
|
1703
|
+
/**
|
|
1704
|
+
* Drops the slot so the next sign-in's requests don't join the dying rotation.
|
|
1705
|
+
*
|
|
1706
|
+
* - Writes nothing: the caller persists the stack, under the lock it holds or takes.
|
|
1707
|
+
*/
|
|
1708
|
+
const signOut = (baseUrl, options) => {
|
|
1709
|
+
rotationMap.delete(baseUrl);
|
|
1710
|
+
const signedOut = state.auth.signOut(baseUrl, options);
|
|
1711
|
+
onSignedOut?.(baseUrl);
|
|
1712
|
+
return signedOut;
|
|
1713
|
+
};
|
|
1714
|
+
const expire = async (baseUrl, store) => {
|
|
1715
|
+
if (!state.auth.notifyExpired(baseUrl)) return;
|
|
1716
|
+
signOut(baseUrl);
|
|
1717
|
+
await store.persistStack(baseUrl, state.store.get());
|
|
1718
|
+
onExpired?.(baseUrl);
|
|
1719
|
+
};
|
|
1720
|
+
const renewIfStale = async (baseUrl) => {
|
|
1721
|
+
if (isStale(baseUrl)) await rotate(baseUrl);
|
|
1722
|
+
};
|
|
1723
|
+
const middleware = (baseUrl) => createBearerAuthMiddleware({ getAccessToken: async ({ forceRefresh = false } = {}) => {
|
|
1724
|
+
if (forceRefresh) {
|
|
1725
|
+
if (!state.auth.requireCredential(baseUrl).success) return null;
|
|
1726
|
+
return Result.unwrap(await rotate(baseUrl));
|
|
1727
|
+
}
|
|
1728
|
+
await renewIfStale(baseUrl);
|
|
1729
|
+
return state.auth.getAccessToken(baseUrl);
|
|
1730
|
+
} });
|
|
1731
|
+
return {
|
|
1732
|
+
middleware,
|
|
1733
|
+
rotate,
|
|
1734
|
+
renewIfStale,
|
|
1735
|
+
restore,
|
|
1736
|
+
restoreRetained,
|
|
1737
|
+
signOut,
|
|
1738
|
+
forget
|
|
1739
|
+
};
|
|
1740
|
+
};
|
|
1741
|
+
//#endregion
|
|
1626
1742
|
//#region src/keboola/bearer/context/resource.ts
|
|
1627
1743
|
/**
|
|
1628
1744
|
* Owns fetching one async value per key — a caller names what it needs and never orchestrates the
|
|
@@ -1939,61 +2055,86 @@ const createPerProject = ({ state, credentials, middlewareFor, stack, clientServ
|
|
|
1939
2055
|
*/
|
|
1940
2056
|
const SESSION_STORAGE_KEY = "keboola:session";
|
|
1941
2057
|
/**
|
|
1942
|
-
* What survives a reload, per
|
|
2058
|
+
* What survives a reload, per grant type.
|
|
2059
|
+
*
|
|
2060
|
+
* - Written under `credential`: the key every blob already stored carries.
|
|
1943
2061
|
*
|
|
1944
2062
|
* - `token`: the refresh token. It rotates, is single-use and is server-revocable, so a leaked
|
|
1945
2063
|
* snapshot has limited and revocable value. The access token is never written.
|
|
1946
|
-
* - `static`: the token itself — a long-lived PAT the user pasted, which nothing can re-mint.
|
|
1947
2064
|
* - `cookie`: the session id. The session cookie is the durable half and the browser keeps it;
|
|
1948
2065
|
* the id alone renews nothing.
|
|
1949
2066
|
*/
|
|
1950
|
-
const
|
|
1951
|
-
z$1.
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
z$1.
|
|
1956
|
-
|
|
1957
|
-
sessionId: z$1.string()
|
|
1958
|
-
}),
|
|
1959
|
-
z$1.object({
|
|
1960
|
-
type: z$1.literal("static"),
|
|
1961
|
-
accessToken: z$1.string()
|
|
1962
|
-
})
|
|
1963
|
-
]);
|
|
2067
|
+
const persistedGrantSchema = z$1.discriminatedUnion("type", [z$1.object({
|
|
2068
|
+
type: z$1.literal("token"),
|
|
2069
|
+
refreshToken: z$1.string()
|
|
2070
|
+
}), z$1.object({
|
|
2071
|
+
type: z$1.literal("cookie"),
|
|
2072
|
+
sessionId: z$1.string()
|
|
2073
|
+
})]);
|
|
1964
2074
|
/** A record per project rather than a bare id, so a project can grow a field without a migration. */
|
|
1965
2075
|
const persistedProjectSchema = z$1.object({ projectId: z$1.number() });
|
|
2076
|
+
const persistedStackSchema = z$1.object({
|
|
2077
|
+
baseUrl: z$1.string(),
|
|
2078
|
+
credential: persistedGrantSchema.nullable().catch(null),
|
|
2079
|
+
retained: z$1.object({ grant: persistedGrantSchema }).nullable().default(null).catch(null),
|
|
2080
|
+
projects: z$1.array(persistedProjectSchema)
|
|
2081
|
+
});
|
|
1966
2082
|
const persistedSessionSchema = z$1.object({
|
|
1967
2083
|
current: z$1.object({
|
|
1968
2084
|
baseUrl: z$1.string(),
|
|
1969
2085
|
projectId: z$1.number().nullable()
|
|
1970
2086
|
}).nullable(),
|
|
1971
|
-
stacks: z$1.array(
|
|
1972
|
-
baseUrl: z$1.string(),
|
|
1973
|
-
credential: persistedCredentialSchema.nullable(),
|
|
1974
|
-
projects: z$1.array(persistedProjectSchema)
|
|
1975
|
-
}))
|
|
2087
|
+
stacks: z$1.array(persistedStackSchema)
|
|
1976
2088
|
});
|
|
1977
2089
|
const EMPTY_PERSISTED_SESSION = {
|
|
1978
2090
|
current: null,
|
|
1979
2091
|
stacks: []
|
|
1980
2092
|
};
|
|
1981
|
-
const
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2093
|
+
const projectsOf = (projects, baseUrl) => Object.values(projects).filter((project) => project.baseUrl === baseUrl).map(({ projectId }) => ({ projectId }));
|
|
2094
|
+
const grantsOf = (stack) => ({
|
|
2095
|
+
credential: stack.auth.status === "authenticated" ? Entry.grant(stack.auth.credential) : null,
|
|
2096
|
+
retained: stack.retained
|
|
2097
|
+
});
|
|
2098
|
+
/**
|
|
2099
|
+
* The stored session, rewritten from the table except for the grants.
|
|
2100
|
+
*
|
|
2101
|
+
* - Scope, stack list and open projects come from memory.
|
|
2102
|
+
* - `credential` and `retained` stay as stored: a grant another document rotated must not be put
|
|
2103
|
+
* back by a snapshot of this one's older table.
|
|
2104
|
+
*/
|
|
2105
|
+
const mergeSnapshot = (stored, { active, stacks, projects }) => ({
|
|
2106
|
+
current: {
|
|
2107
|
+
baseUrl: active.baseUrl,
|
|
2108
|
+
projectId: active.projectId
|
|
2109
|
+
},
|
|
2110
|
+
stacks: Object.values(stacks).map(({ baseUrl }) => {
|
|
2111
|
+
const kept = stored.stacks.find((stack) => stack.baseUrl === baseUrl);
|
|
2112
|
+
return {
|
|
2113
|
+
baseUrl,
|
|
2114
|
+
credential: kept?.credential ?? null,
|
|
2115
|
+
retained: kept?.retained ?? null,
|
|
2116
|
+
projects: projectsOf(projects, baseUrl)
|
|
2117
|
+
};
|
|
2118
|
+
})
|
|
2119
|
+
});
|
|
2120
|
+
const upsertStack = (stored, baseUrl, update) => {
|
|
2121
|
+
const index = stored.stacks.findIndex((stack) => stack.baseUrl === baseUrl);
|
|
2122
|
+
const stacks = [...stored.stacks];
|
|
2123
|
+
if (index < 0) stacks.push(update(void 0));
|
|
2124
|
+
else stacks[index] = update(stacks[index]);
|
|
1992
2125
|
return {
|
|
1993
|
-
|
|
1994
|
-
|
|
2126
|
+
...stored,
|
|
2127
|
+
stacks
|
|
1995
2128
|
};
|
|
1996
2129
|
};
|
|
2130
|
+
/**
|
|
2131
|
+
* The stored session, reached in two ways.
|
|
2132
|
+
*
|
|
2133
|
+
* - `locked`: the only way to read, and the only way to a grant write. Rotation and restore hold
|
|
2134
|
+
* it across the refresh; sign-in, sign-out and the boot restore open it for one step.
|
|
2135
|
+
* - `snapshot`: the table minus its grants, under the lock, coalesced; what the store subscription
|
|
2136
|
+
* feeds, and what a scope change awaits before the document leaves.
|
|
2137
|
+
*/
|
|
1997
2138
|
const createSessionPersistor = (storage) => {
|
|
1998
2139
|
const persistor = createPersistor({
|
|
1999
2140
|
storage,
|
|
@@ -2001,20 +2142,35 @@ const createSessionPersistor = (storage) => {
|
|
|
2001
2142
|
schema: persistedSessionSchema,
|
|
2002
2143
|
defaultValue: EMPTY_PERSISTED_SESSION
|
|
2003
2144
|
});
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2145
|
+
const persistStack = (cell, baseUrl, { stacks, projects }) => {
|
|
2146
|
+
const stack = stacks[baseUrl];
|
|
2147
|
+
if (stack === void 0) return Promise.resolve();
|
|
2148
|
+
return cell.modify((stored) => upsertStack(stored, baseUrl, (existing) => ({
|
|
2149
|
+
baseUrl,
|
|
2150
|
+
...grantsOf(stack),
|
|
2151
|
+
projects: existing?.projects ?? projectsOf(projects, baseUrl)
|
|
2152
|
+
})));
|
|
2153
|
+
};
|
|
2154
|
+
const locked = (task) => persistor.locked((cell) => task({
|
|
2155
|
+
read: cell.read,
|
|
2156
|
+
persistStack: (baseUrl, state) => persistStack(cell, baseUrl, state)
|
|
2157
|
+
}));
|
|
2158
|
+
let latest = null;
|
|
2159
|
+
let pending = null;
|
|
2160
|
+
const snapshot = (state) => {
|
|
2161
|
+
latest = state;
|
|
2162
|
+
if (pending) return pending;
|
|
2163
|
+
const write = persistor.locked((cell) => {
|
|
2164
|
+
pending = null;
|
|
2165
|
+
const table = latest ?? state;
|
|
2166
|
+
return cell.modify((stored) => mergeSnapshot(stored, table));
|
|
2167
|
+
});
|
|
2168
|
+
pending = write;
|
|
2169
|
+
return write;
|
|
2170
|
+
};
|
|
2015
2171
|
return {
|
|
2016
|
-
|
|
2017
|
-
|
|
2172
|
+
locked,
|
|
2173
|
+
snapshot
|
|
2018
2174
|
};
|
|
2019
2175
|
};
|
|
2020
2176
|
//#endregion
|
|
@@ -2059,7 +2215,7 @@ const createPerStack = ({ state, credentials, middlewareFor }) => {
|
|
|
2059
2215
|
*
|
|
2060
2216
|
* - Credential-derived state is owned by the scope whose end ends it (`perStack`, `perProject`).
|
|
2061
2217
|
*/
|
|
2062
|
-
const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls,
|
|
2218
|
+
const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls, onExpired }) => {
|
|
2063
2219
|
const state = createState(normalizeBaseUrl(defaultBaseUrl));
|
|
2064
2220
|
const persistor = createSessionPersistor(storage);
|
|
2065
2221
|
const middlewareFor = createMiddlewareFor(middlewares);
|
|
@@ -2067,8 +2223,8 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2067
2223
|
state,
|
|
2068
2224
|
persistor,
|
|
2069
2225
|
middlewares: middlewareFor("auth"),
|
|
2070
|
-
|
|
2071
|
-
|
|
2226
|
+
onSignedOut: (baseUrl) => perProject.forgetUnder(baseUrl),
|
|
2227
|
+
onExpired
|
|
2072
2228
|
});
|
|
2073
2229
|
const perStack = createPerStack({
|
|
2074
2230
|
state,
|
|
@@ -2132,16 +2288,22 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2132
2288
|
await credentials.renewIfStale(project.baseUrl);
|
|
2133
2289
|
return headersFor(Result.unwrap(state.projects.get(project.id)));
|
|
2134
2290
|
};
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2137
|
-
if (input.type !== "static" && input.type !== mode) throw new KeboolaError(KeboolaErrorType.CredentialKindMismatch);
|
|
2138
|
-
if (input.type !== "token") return Result.unwrap(state.auth.authenticate(stack.baseUrl, input));
|
|
2291
|
+
const toCredential = (input) => {
|
|
2292
|
+
if (input.type !== "token") return input;
|
|
2139
2293
|
const { refreshToken } = input;
|
|
2140
2294
|
if (!refreshToken) throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
|
|
2141
|
-
return
|
|
2295
|
+
return {
|
|
2142
2296
|
...input,
|
|
2143
2297
|
refreshToken
|
|
2144
|
-
}
|
|
2298
|
+
};
|
|
2299
|
+
};
|
|
2300
|
+
const authenticate = (input) => {
|
|
2301
|
+
const { baseUrl } = state.scope.getActiveStack();
|
|
2302
|
+
const signedIn = Result.unwrap(state.auth.authenticate(baseUrl, toCredential(input)));
|
|
2303
|
+
persistor.locked((store) => store.persistStack(baseUrl, state.store.get())).catch((error) => {
|
|
2304
|
+
console.warn("createKeboola: the sign-in could not be stored", error);
|
|
2305
|
+
});
|
|
2306
|
+
return signedIn;
|
|
2145
2307
|
};
|
|
2146
2308
|
/**
|
|
2147
2309
|
* The flat product surface: `auth` and `management` per stack, the rest per project.
|
|
@@ -2181,11 +2343,21 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2181
2343
|
Result.unwrapOr(state.projects.open(baseUrl, projectId), null);
|
|
2182
2344
|
return perProject.get(project).api;
|
|
2183
2345
|
};
|
|
2184
|
-
/**
|
|
2185
|
-
|
|
2346
|
+
/**
|
|
2347
|
+
* The scope's sign-in, or a named stack's — and everything that sign-in derived.
|
|
2348
|
+
*
|
|
2349
|
+
* - `retain` keeps the grant on the stack, persisted beside the sign-in it ended, for
|
|
2350
|
+
* `restoreRetained`; the next sign-in on the stack replaces it.
|
|
2351
|
+
* - The table is signed out on return; the promise resolves once that is stored, so a caller
|
|
2352
|
+
* leaving the document waits for it.
|
|
2353
|
+
*/
|
|
2354
|
+
const signOut = ({ baseUrl, ...options } = {}) => {
|
|
2186
2355
|
const target = requireStackUrl(baseUrl);
|
|
2187
|
-
|
|
2356
|
+
const signedOut = Result.unwrap(credentials.signOut(target, options));
|
|
2357
|
+
return persistor.locked((store) => store.persistStack(target, state.store.get())).then(() => signedOut);
|
|
2188
2358
|
};
|
|
2359
|
+
/** Signs a stack back in from what a retained sign-out kept; `unreachable` leaves it to retry. */
|
|
2360
|
+
const restoreRetained = (baseUrl) => credentials.restoreRetained(normalizeBaseUrl(baseUrl));
|
|
2189
2361
|
/**
|
|
2190
2362
|
* `input` replaces the active stack's sign-in, whatever it holds.
|
|
2191
2363
|
*
|
|
@@ -2197,19 +2369,6 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2197
2369
|
return authenticate(input);
|
|
2198
2370
|
};
|
|
2199
2371
|
/**
|
|
2200
|
-
* A server-injected `token` credential, adopted whatever this client's mode.
|
|
2201
|
-
*
|
|
2202
|
-
* @deprecated Temporary, for the agent-project claim page only: Connection injects an API-mode
|
|
2203
|
-
* session through `UiConfig.programmaticAuth`. Remove together with that injection.
|
|
2204
|
-
*
|
|
2205
|
-
* - Replaces the active stack's sign-in, like `replace`.
|
|
2206
|
-
* - A cookie-mode client never rotates it, so it lasts as long as its access token.
|
|
2207
|
-
*/
|
|
2208
|
-
const adoptInjected = (input) => {
|
|
2209
|
-
signOut();
|
|
2210
|
-
return Result.unwrap(state.auth.authenticate(getActiveStack().baseUrl, input));
|
|
2211
|
-
};
|
|
2212
|
-
/**
|
|
2213
2372
|
* Leave one project: its row and everything built for it; its handles stop answering.
|
|
2214
2373
|
*
|
|
2215
2374
|
* - Counterpart of `getApi(projectId)`; without it the project is held and persisted until sign-out.
|
|
@@ -2235,16 +2394,22 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2235
2394
|
/**
|
|
2236
2395
|
* Persistence starts only once the restore has settled.
|
|
2237
2396
|
*
|
|
2238
|
-
* - Mid-hydration an unexchanged stack is `anonymous`;
|
|
2397
|
+
* - Mid-hydration an unexchanged stack is `anonymous`; the persistor would erase the
|
|
2239
2398
|
* refresh token the exchange is about to spend.
|
|
2240
2399
|
* - Writes the settled table once: the subscription fires only on the next change.
|
|
2241
2400
|
*/
|
|
2242
2401
|
const enablePersistence = () => {
|
|
2243
2402
|
if (persisting) return;
|
|
2244
2403
|
persisting = true;
|
|
2245
|
-
|
|
2246
|
-
state.store.subscribe(
|
|
2404
|
+
snapshot(state.store.get());
|
|
2405
|
+
state.store.subscribe(snapshot);
|
|
2406
|
+
};
|
|
2407
|
+
const snapshot = (table) => {
|
|
2408
|
+
persistor.snapshot(table).catch((error) => {
|
|
2409
|
+
console.warn("createKeboola: the session could not be stored", error);
|
|
2410
|
+
});
|
|
2247
2411
|
};
|
|
2412
|
+
const persistScope = () => persisting ? persistor.snapshot(state.store.get()) : Promise.resolve();
|
|
2248
2413
|
/**
|
|
2249
2414
|
* The same, deferred until a sign-in.
|
|
2250
2415
|
*
|
|
@@ -2298,14 +2463,22 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2298
2463
|
resume,
|
|
2299
2464
|
stack: {
|
|
2300
2465
|
getActive: getActiveStack,
|
|
2301
|
-
|
|
2466
|
+
/** Scoped on return; resolves once that is stored, for a caller leaving the document. */
|
|
2467
|
+
select: byCaller((baseUrl) => {
|
|
2468
|
+
const stack = selectStack(baseUrl);
|
|
2469
|
+
return persistScope().then(() => stack);
|
|
2470
|
+
}),
|
|
2302
2471
|
close: closeStack,
|
|
2303
2472
|
retryContext: perStack.context.retry,
|
|
2304
2473
|
getContext: (baseUrl) => perStack.context.get(requireStackUrl(baseUrl)),
|
|
2305
2474
|
getContextAsync: (baseUrl) => perStack.context.getAsync(requireStackUrl(baseUrl))
|
|
2306
2475
|
},
|
|
2307
2476
|
project: {
|
|
2308
|
-
|
|
2477
|
+
/** Scoped on return; resolves once that is stored, for a caller leaving the document. */
|
|
2478
|
+
select: byCaller((projectId) => {
|
|
2479
|
+
const project = selectProject(projectId);
|
|
2480
|
+
return persistScope().then(() => project);
|
|
2481
|
+
}),
|
|
2309
2482
|
close: closeProject,
|
|
2310
2483
|
deactivate: state.scope.deactivate,
|
|
2311
2484
|
retryContext: perProject.context.retry,
|
|
@@ -2315,8 +2488,8 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2315
2488
|
auth: {
|
|
2316
2489
|
authenticate: byCaller(authenticate),
|
|
2317
2490
|
replace: byCaller(replace),
|
|
2318
|
-
adoptInjected: byCaller(adoptInjected),
|
|
2319
2491
|
signOut: byCaller(signOut),
|
|
2492
|
+
restoreRetained: byCaller(restoreRetained),
|
|
2320
2493
|
/** Whether the active stack holds a credential — `restoring` is not one yet. */
|
|
2321
2494
|
isAuthenticated,
|
|
2322
2495
|
isAuthenticatedAsync: () => resume().then(isAuthenticated),
|
|
@@ -2510,6 +2683,6 @@ const createAdminAccount = ({ managementToken }) => {
|
|
|
2510
2683
|
};
|
|
2511
2684
|
};
|
|
2512
2685
|
//#endregion
|
|
2513
|
-
export { ApiError, HtmlResponseError, HttpContentType, HttpHeader, KeboolaError, KeboolaErrorType, KeboolaHttpHeader, ManagementClientAuthError, ManagementSessionMintError, QueryJobError,
|
|
2686
|
+
export { ApiError, HtmlResponseError, HttpContentType, HttpHeader, KeboolaError, KeboolaErrorType, KeboolaHttpHeader, ManagementClientAuthError, ManagementSessionMintError, QueryJobError, QueueJobError, Result, SESSION_STORAGE_KEY, ServiceUnavailableError, StorageJobError, SyncActionError, UserError, ValidationError, asError, assert, coalesce, collectByCursor, collectByOffset, concurrent, createAdminAccount, createDerivedAsyncStore, createDerivedStore, createEmitter, createGenericFetchClient, createKeboola, createLegacyKeboola, createLocalStorage, createLoggingMiddleware, createMemoryStorage, createNullStorage, createPersistor, createPollRegistry, createQueryServiceSdk, createRetryMiddleware, createSessionStorage, createStore, createUiVersionMiddleware, dedupe, deepMerge, delay, emitter, ensure, failureOf, formatValidationIssues, generateUUID, isAbortError, isApiError, isEmptyDeep, isFetchClientError, isHtmlResponseError, isKeboolaError, isManagementClientAuthError, isManagementSessionMintError, isPlainObject, isQueryJobError, isQueueJobError, isStorageJobError, isStorageTokenMutatingRequest, isSyncActionError, isTimeoutError, isValidationError, jobStatus, keboolaUID, lazy, nextCursorOf, parseLogLines, parseOrThrow, poller, queueSeries, readableReason, schemaGuidedMerge, series, shallowEqual };
|
|
2514
2687
|
|
|
2515
2688
|
//# sourceMappingURL=index.js.map
|