@keboola/api-client 49.0.0 → 50.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 +109 -95
- package/API-SURFACE.md +12 -31
- package/CHANGELOG.md +44 -0
- package/README.md +33 -29
- package/dist/{ManagementSessionMintError-Cu9beG7j.cjs → ManagementSessionMintError-ByOulHQH.cjs} +4 -6
- package/dist/{ManagementSessionMintError-Cu9beG7j.cjs.map → ManagementSessionMintError-ByOulHQH.cjs.map} +1 -1
- package/dist/{ManagementSessionMintError-4Pkn5Oob.js → ManagementSessionMintError-DNMbYauw.js} +4 -6
- package/dist/{ManagementSessionMintError-4Pkn5Oob.js.map → ManagementSessionMintError-DNMbYauw.js.map} +1 -1
- package/dist/{QueryJobError-ZZZ043Nm.js → QueryJobError-Iq9O90Uh.js} +2 -3
- package/dist/{QueryJobError-ZZZ043Nm.js.map → QueryJobError-Iq9O90Uh.js.map} +1 -1
- package/dist/{QueryJobError-irGiP5zh.cjs → QueryJobError-Oy0fl4aw.cjs} +2 -3
- package/dist/{QueryJobError-irGiP5zh.cjs.map → QueryJobError-Oy0fl4aw.cjs.map} +1 -1
- package/dist/{QueueJobError-8bThS_Mc.js → QueueJobError-BJNUINXW.js} +2 -3
- package/dist/{QueueJobError-8bThS_Mc.js.map → QueueJobError-BJNUINXW.js.map} +1 -1
- package/dist/{QueueJobError-6qSEizWo.cjs → QueueJobError-DruZK3tc.cjs} +2 -3
- package/dist/{QueueJobError-6qSEizWo.cjs.map → QueueJobError-DruZK3tc.cjs.map} +1 -1
- package/dist/{SyncActionError-CoZFsdUk.js → SyncActionError-DuGcDbkd.js} +2 -3
- package/dist/{SyncActionError-CoZFsdUk.js.map → SyncActionError-DuGcDbkd.js.map} +1 -1
- package/dist/{SyncActionError-BG0zwchi.cjs → SyncActionError-mbpVg63X.cjs} +2 -3
- package/dist/{SyncActionError-BG0zwchi.cjs.map → SyncActionError-mbpVg63X.cjs.map} +1 -1
- package/dist/{UserError-By_Zckmc.js → UserError-BxoOJJ_u.js} +2 -3
- package/dist/{UserError-By_Zckmc.js.map → UserError-BxoOJJ_u.js.map} +1 -1
- package/dist/{UserError-CSGO1qII.cjs → UserError-D4P9Tbhf.cjs} +2 -3
- package/dist/{UserError-CSGO1qII.cjs.map → UserError-D4P9Tbhf.cjs.map} +1 -1
- package/dist/{ValidationError-D65QU0uq.cjs → ValidationError-BXcFX4nD.cjs} +2 -3
- package/dist/{ValidationError-D65QU0uq.cjs.map → ValidationError-BXcFX4nD.cjs.map} +1 -1
- package/dist/{ValidationError-DjhtNMfZ.js → ValidationError-BsdFDGY2.js} +2 -3
- package/dist/{ValidationError-DjhtNMfZ.js.map → ValidationError-BsdFDGY2.js.map} +1 -1
- package/dist/{configurations-CL0ouUMa.js → admin-CbMOsfgs.js} +5 -53
- package/dist/admin-CbMOsfgs.js.map +1 -0
- package/dist/{configurations-D9J3jh3g.cjs → admin-Di-MmGFP.cjs} +4 -124
- package/dist/admin-Di-MmGFP.cjs.map +1 -0
- package/dist/{adminRoles-BX1gk3At.d.ts → adminRoles-DAwl657q.d.ts} +2 -4
- package/dist/{adminRoles-CO7J5qAy.cjs → adminRoles-DnFpO_2W.cjs} +2 -3
- package/dist/{adminRoles-CO7J5qAy.cjs.map → adminRoles-DnFpO_2W.cjs.map} +1 -1
- package/dist/{adminRoles-BbxFgfX-.d.cts → adminRoles-FFyl7Dyx.d.cts} +2 -4
- package/dist/{adminRoles-B40yBcmq.js → adminRoles-asa-MhDD.js} +2 -3
- package/dist/{adminRoles-B40yBcmq.js.map → adminRoles-asa-MhDD.js.map} +1 -1
- package/dist/ai/index.cjs +3 -4
- package/dist/ai/index.d.cts +2 -4
- package/dist/ai/index.d.ts +2 -4
- package/dist/ai/index.js +3 -4
- package/dist/ai/types.d.cts +1 -1
- package/dist/ai/types.d.ts +1 -1
- package/dist/{appLogs-DI2Y4imY.d.ts → appLogs-CTvZAihm.d.ts} +2 -4
- package/dist/{appLogs-IhRA3xyv.d.cts → appLogs-CnLNMH7M.d.cts} +2 -4
- package/dist/{appLogs-Cix2KWra.cjs → appLogs-CoAWQGxs.cjs} +5 -6
- package/dist/{appLogs-Cix2KWra.cjs.map → appLogs-CoAWQGxs.cjs.map} +1 -1
- package/dist/{appLogs-KslK7qHr.js → appLogs-DFcPwVk8.js} +4 -5
- package/dist/{appLogs-KslK7qHr.js.map → appLogs-DFcPwVk8.js.map} +1 -1
- package/dist/apps/index.cjs +28 -5
- package/dist/apps/index.cjs.map +1 -1
- package/dist/apps/index.d.cts +13 -5
- package/dist/apps/index.d.ts +13 -5
- package/dist/apps/index.js +28 -5
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/types.d.cts +3 -3
- package/dist/apps/types.d.ts +3 -3
- package/dist/assets/index.cjs +2 -3
- package/dist/assets/index.d.cts +1 -3
- package/dist/assets/index.d.ts +1 -3
- package/dist/assets/index.js +2 -3
- package/dist/assets/schema.cjs +2 -3
- package/dist/assets/schema.d.cts +0 -2
- package/dist/assets/schema.d.ts +0 -2
- package/dist/assets/schema.js +1 -2
- 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 -2
- package/dist/auth/types.d.cts +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/{auth-C8Pjl0Mu.cjs → auth-CvB4MukT.cjs} +3 -4
- package/dist/{auth-C8Pjl0Mu.cjs.map → auth-CvB4MukT.cjs.map} +1 -1
- package/dist/{auth-4coY1uwo.js → auth-DYfQMQCs.js} +3 -4
- package/dist/{auth-4coY1uwo.js.map → auth-DYfQMQCs.js.map} +1 -1
- package/dist/{authClient-DfkKlc-2.cjs → authClient-DcKBpMcU.cjs} +66 -85
- package/dist/{authClient-DfkKlc-2.cjs.map → authClient-DcKBpMcU.cjs.map} +1 -1
- package/dist/{authClient-6Aau_4Zt.d.ts → authClient-Df3U4q_6.d.cts} +4 -16
- package/dist/{authClient-B3P6WtWW.d.cts → authClient-JtMVJWXY.d.ts} +4 -16
- package/dist/{authClient-2e8ZmzSP.js → authClient-oB5ydxWp.js} +66 -85
- package/dist/{authClient-2e8ZmzSP.js.map → authClient-oB5ydxWp.js.map} +1 -1
- package/dist/{backends-DKBz5OxE.d.ts → backends-BHotIdL0.d.cts} +1 -3
- package/dist/{backends-DKBz5OxE.d.cts → backends-BHotIdL0.d.ts} +1 -3
- package/dist/billing/index.cjs +3 -4
- package/dist/billing/index.d.cts +1 -3
- package/dist/billing/index.d.ts +1 -3
- package/dist/billing/index.js +3 -4
- package/dist/billing/types.d.cts +1 -5
- package/dist/billing/types.d.ts +1 -5
- package/dist/chat/index.cjs +4 -5
- package/dist/chat/index.d.cts +3 -5
- package/dist/chat/index.d.ts +3 -5
- package/dist/chat/index.js +4 -5
- package/dist/chat/suggestions.cjs +1 -2
- package/dist/chat/suggestions.d.cts +1 -1
- package/dist/chat/suggestions.d.ts +1 -1
- package/dist/chat/suggestions.js +1 -2
- package/dist/chat/types.cjs +1 -2
- package/dist/chat/types.d.cts +1 -1
- package/dist/chat/types.d.ts +1 -1
- package/dist/chat/types.js +1 -2
- package/dist/{collectByOffset-DQsqtmJg.cjs → collectByOffset-DgxJ3zT9.cjs} +3 -4
- package/dist/{collectByOffset-DQsqtmJg.cjs.map → collectByOffset-DgxJ3zT9.cjs.map} +1 -1
- package/dist/{collectByOffset-2XzJqmvr.js → collectByOffset-i8Tdoze7.js} +3 -4
- package/dist/{collectByOffset-2XzJqmvr.js.map → collectByOffset-i8Tdoze7.js.map} +1 -1
- package/dist/{componentId-D4jp6a13.cjs → componentId-C8ZTXXDo.cjs} +2 -3
- package/dist/{componentId-D4jp6a13.cjs.map → componentId-C8ZTXXDo.cjs.map} +1 -1
- package/dist/{componentId-DmHwHG5V.js → componentId-b_qBbJEM.js} +2 -3
- package/dist/{componentId-DmHwHG5V.js.map → componentId-b_qBbJEM.js.map} +1 -1
- package/dist/componentsMcp/index.cjs +1 -1
- package/dist/componentsMcp/index.d.cts +1 -1
- package/dist/componentsMcp/index.d.ts +1 -1
- package/dist/componentsMcp/index.js +1 -2
- package/dist/componentsMcp/types.d.cts +1 -1
- package/dist/componentsMcp/types.d.ts +1 -1
- package/dist/{componentsMcp-pG-PcQrg.cjs → componentsMcp-BaHy5iLr.cjs} +5 -7
- package/dist/{componentsMcp-pG-PcQrg.cjs.map → componentsMcp-BaHy5iLr.cjs.map} +1 -1
- package/dist/{componentsMcp-CHobIsuU.js → componentsMcp-BrB4js6b.js} +5 -7
- package/dist/{componentsMcp-CHobIsuU.js.map → componentsMcp-BrB4js6b.js.map} +1 -1
- package/dist/{concurrent-BacWxPwi.js → concurrent-BtsT10Xe.js} +2 -3
- package/dist/{concurrent-BacWxPwi.js.map → concurrent-BtsT10Xe.js.map} +1 -1
- package/dist/{concurrent-CdVfR1N5.cjs → concurrent-DnTV_ppY.cjs} +2 -3
- package/dist/{concurrent-CdVfR1N5.cjs.map → concurrent-DnTV_ppY.cjs.map} +1 -1
- package/dist/configurations-Cd6Nsox-.js +49 -0
- package/dist/configurations-Cd6Nsox-.js.map +1 -0
- package/dist/configurations-WI8H4zLk.cjs +120 -0
- package/dist/configurations-WI8H4zLk.cjs.map +1 -0
- package/dist/constants/index.cjs +3 -3
- package/dist/constants/index.d.cts +4 -4
- package/dist/constants/index.d.ts +4 -4
- package/dist/constants/index.js +3 -3
- package/dist/{constants-VpSwBtCb.js → constants-BMSHGwOR.js} +46 -52
- package/dist/constants-BMSHGwOR.js.map +1 -0
- package/dist/{constants-DErcRkWl.cjs → constants-DhFQWQgy.cjs} +45 -51
- package/dist/constants-DhFQWQgy.cjs.map +1 -0
- package/dist/{createAbortError-RendOpo7.cjs → createAbortError-Dzc9yObN.cjs} +2 -3
- package/dist/{createAbortError-RendOpo7.cjs.map → createAbortError-Dzc9yObN.cjs.map} +1 -1
- package/dist/{createAbortError-BxupOt-6.js → createAbortError-c6ekCpRy.js} +2 -3
- package/dist/{createAbortError-BxupOt-6.js.map → createAbortError-c6ekCpRy.js.map} +1 -1
- package/dist/{createFetchClient-lZ_93Yrb.cjs → createFetchClient-DEkUH662.cjs} +6 -10
- package/dist/{createFetchClient-lZ_93Yrb.cjs.map → createFetchClient-DEkUH662.cjs.map} +1 -1
- package/dist/{createFetchClient-CkHdS_IG.js → createFetchClient-DlGCbltR.js} +5 -9
- package/dist/{createFetchClient-CkHdS_IG.js.map → createFetchClient-DlGCbltR.js.map} +1 -1
- package/dist/{createGenericFetchClient-MOx97wi-.cjs → createGenericFetchClient-2oU-PXVo.cjs} +3 -4
- package/dist/{createGenericFetchClient-MOx97wi-.cjs.map → createGenericFetchClient-2oU-PXVo.cjs.map} +1 -1
- package/dist/createGenericFetchClient-wGxemBwR.js +6 -0
- package/dist/{createGenericFetchClient-CQdNcPC3.js.map → createGenericFetchClient-wGxemBwR.js.map} +1 -1
- package/dist/createOpenapiFetchClient-Bhz62MUE.js +6 -0
- package/dist/{createOpenapiFetchClient-DXiMv9WL.js.map → createOpenapiFetchClient-Bhz62MUE.js.map} +1 -1
- package/dist/{createOpenapiFetchClient-DHYo_k3t.cjs → createOpenapiFetchClient-DL9w7vU-.cjs} +3 -4
- package/dist/{createOpenapiFetchClient-DHYo_k3t.cjs.map → createOpenapiFetchClient-DL9w7vU-.cjs.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-AwPMeGfz.js → dataScience-CXmkEOAi.js} +7 -9
- package/dist/{dataScience-AwPMeGfz.js.map → dataScience-CXmkEOAi.js.map} +1 -1
- package/dist/{dataScience-BjS1p8WO.cjs → dataScience-CufjHPSd.cjs} +7 -9
- package/dist/{dataScience-BjS1p8WO.cjs.map → dataScience-CufjHPSd.cjs.map} +1 -1
- package/dist/{dedupe-OSnnst2u.cjs → dedupe-Bf0gl9TJ.cjs} +2 -3
- package/dist/{dedupe-OSnnst2u.cjs.map → dedupe-Bf0gl9TJ.cjs.map} +1 -1
- package/dist/{dedupe-Cky1gSUu.js → dedupe-Bu0d2i_w.js} +2 -3
- package/dist/{dedupe-Cky1gSUu.js.map → dedupe-Bu0d2i_w.js.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 -2
- package/dist/developerPortal/types.d.cts +1 -1
- package/dist/developerPortal/types.d.ts +1 -1
- package/dist/{developerPortalClient-DUerKw-7.cjs → developerPortalClient-BfRxYrWj.cjs} +9 -15
- package/dist/{developerPortalClient-DUerKw-7.cjs.map → developerPortalClient-BfRxYrWj.cjs.map} +1 -1
- package/dist/{developerPortalClient-Bb2suezr.js → developerPortalClient-D9XOYwWF.js} +9 -15
- package/dist/{developerPortalClient-Bb2suezr.js.map → developerPortalClient-D9XOYwWF.js.map} +1 -1
- package/dist/domain/permissions/index.cjs +18 -17
- package/dist/domain/permissions/index.d.cts +1 -11
- package/dist/domain/permissions/index.d.ts +1 -11
- package/dist/domain/permissions/index.js +3 -2
- package/dist/domain/storageTable/index.cjs +403 -9
- package/dist/domain/storageTable/index.cjs.map +1 -0
- package/dist/domain/storageTable/index.d.cts +189 -2
- package/dist/domain/storageTable/index.d.ts +189 -2
- package/dist/domain/storageTable/index.js +395 -1
- package/dist/domain/storageTable/index.js.map +1 -0
- package/dist/editor/index.cjs +3 -4
- package/dist/editor/index.d.cts +2 -4
- package/dist/editor/index.d.ts +2 -4
- package/dist/editor/index.js +3 -4
- package/dist/editor/types.d.cts +1 -1
- package/dist/editor/types.d.ts +1 -1
- package/dist/{emitter-dLF1Fyfg.d.ts → emitter-raKkIqRp.d.cts} +1 -3
- package/dist/{emitter-dLF1Fyfg.d.cts → emitter-raKkIqRp.d.ts} +1 -3
- package/dist/encryption/index.cjs +2 -3
- package/dist/encryption/index.d.cts +1 -1
- package/dist/encryption/index.d.ts +1 -1
- package/dist/encryption/index.js +2 -3
- package/dist/encryption/types.d.cts +1 -1
- package/dist/encryption/types.d.ts +1 -1
- package/dist/generateUUID-DE9sNyJF.js +5 -0
- package/dist/{generateUUID-Dr8l-aoc.js.map → generateUUID-DE9sNyJF.js.map} +1 -1
- package/dist/{generateUUID-C6qKBPIv.cjs → generateUUID-DbSTmvVP.cjs} +2 -3
- package/dist/{generateUUID-C6qKBPIv.cjs.map → generateUUID-DbSTmvVP.cjs.map} +1 -1
- package/dist/import/index.cjs +1 -1
- package/dist/import/index.d.cts +3 -5
- package/dist/import/index.d.ts +3 -5
- package/dist/import/index.js +1 -2
- package/dist/{import-BahNYv91.cjs → import-CABlFMQX.cjs} +6 -9
- package/dist/{import-BahNYv91.cjs.map → import-CABlFMQX.cjs.map} +1 -1
- package/dist/{import-FWy_wQZ1.js → import-CT1Ce5Rp.js} +6 -9
- package/dist/{import-FWy_wQZ1.js.map → import-CT1Ce5Rp.js.map} +1 -1
- package/dist/index-24GpnYhn.d.cts +150 -0
- package/dist/{index-BT88-GpA.d.ts → index-AA3MRfRn.d.cts} +4 -16
- package/dist/{index-C6oPUTWZ.d.ts → index-BDPxm9qu.d.ts} +3 -7
- package/dist/index-BUZ-vTRt.d.ts +150 -0
- package/dist/{index-XcnkRVb0.d.ts → index-BZDxWvZW.d.ts} +5 -7
- package/dist/index-C9iNazAc.d.ts +15103 -0
- package/dist/{index-D6JMbJ9b.d.ts → index-CCcdySOC.d.cts} +5 -7
- package/dist/{index-CrrHvDiX.d.cts → index-CN0--VsY.d.ts} +5 -7
- package/dist/index-CTMnmISl.d.cts +15103 -0
- package/dist/{index-BiZR9BjN.d.ts → index-CbSh3KFw.d.cts} +4 -12
- package/dist/{index-BM_fXKq5.d.cts → index-ClIV2Lch.d.cts} +5 -7
- package/dist/{index-DReKz9Zt.d.ts → index-CuI8OI9E.d.ts} +4 -13
- package/dist/{index-BPMr8PQJ.d.ts → index-D1mduJne.d.cts} +2 -52
- package/dist/{index-CL4iKFic.d.cts → index-D1mduJne.d.ts} +1 -51
- package/dist/{index-DorowSay.d.ts → index-DIPMzH--.d.ts} +5 -9
- package/dist/{index-CbZQCDkD.d.cts → index-DQagqTVa.d.cts} +3 -7
- package/dist/{index-dgu6udMy.d.ts → index-DVBQgFg0.d.ts} +4 -6
- package/dist/index-DXoN8VwV.d.cts +10 -0
- package/dist/{index-Dkb8CynB.d.cts → index-Db266tLz.d.cts} +5 -9
- package/dist/{index-BVjhAkXW.d.cts → index-DgGpQsAT.d.cts} +4 -6
- package/dist/{index-PqJGDHHl.d.cts → index-DjSthn8d.d.ts} +4 -16
- package/dist/index-Xpu7qIZk.d.ts +10 -0
- package/dist/{index-DhZTIejy.d.ts → index-lTrNMlj6.d.ts} +3 -5
- package/dist/{index-DYNVbgm8.d.cts → index-m9-mN8Gg.d.ts} +4 -12
- package/dist/{index-CtQl-Iqw.d.cts → index-xX8-Stoq.d.cts} +4 -13
- package/dist/{index-DGKCTQkb.d.cts → index-z-2okomN.d.cts} +3 -5
- package/dist/index.cjs +431 -1054
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +427 -1051
- package/dist/index.js.map +1 -1
- package/dist/{isLoginPageRedirect-r0Opgc1n.cjs → isLoginPageRedirect-CoUxJi2x.cjs} +3 -4
- package/dist/{isLoginPageRedirect-r0Opgc1n.cjs.map → isLoginPageRedirect-CoUxJi2x.cjs.map} +1 -1
- package/dist/{isLoginPageRedirect-B4QKSiSa.js → isLoginPageRedirect-D-lqF_kZ.js} +3 -4
- package/dist/{isLoginPageRedirect-B4QKSiSa.js.map → isLoginPageRedirect-D-lqF_kZ.js.map} +1 -1
- package/dist/{isPlainObject-LYW-03uB.js → isPlainObject-BxsT8_t2.js} +2 -3
- package/dist/{isPlainObject-LYW-03uB.js.map → isPlainObject-BxsT8_t2.js.map} +1 -1
- package/dist/{isPlainObject-BB3iy87C.cjs → isPlainObject-CcvQt0qB.cjs} +2 -3
- package/dist/{isPlainObject-BB3iy87C.cjs.map → isPlainObject-CcvQt0qB.cjs.map} +1 -1
- package/dist/kaiAgent/index.cjs +1 -1
- package/dist/kaiAgent/index.d.cts +2 -2
- package/dist/kaiAgent/index.d.ts +2 -2
- package/dist/kaiAgent/index.js +1 -2
- package/dist/kaiAgent/types.d.cts +1 -1
- package/dist/kaiAgent/types.d.ts +1 -1
- package/dist/{kaiAgent-CYvrS8oZ.js → kaiAgent-D2TiMDjW.js} +6 -7
- package/dist/{kaiAgent-CYvrS8oZ.js.map → kaiAgent-D2TiMDjW.js.map} +1 -1
- package/dist/{kaiAgent-N2qbUFZm.cjs → kaiAgent-gaA7dqki.cjs} +6 -7
- package/dist/{kaiAgent-N2qbUFZm.cjs.map → kaiAgent-gaA7dqki.cjs.map} +1 -1
- package/dist/{kaiMemory-Qch09f-m.cjs → kaiMemory-CkLQfJXD.cjs} +6 -9
- package/dist/{kaiMemory-Qch09f-m.cjs.map → kaiMemory-CkLQfJXD.cjs.map} +1 -1
- package/dist/{kaiMemory-C9di17bd.js → kaiMemory-oir_qCo_.js} +6 -9
- package/dist/{kaiMemory-C9di17bd.js.map → kaiMemory-oir_qCo_.js.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 -2
- package/dist/management/types.cjs +1 -2
- package/dist/management/types.d.cts +2 -2
- package/dist/management/types.d.ts +2 -2
- package/dist/management/types.js +1 -2
- package/dist/{management-B1o6RpKF.cjs → management-BEGOEQxM.cjs} +26 -45
- package/dist/management-BEGOEQxM.cjs.map +1 -0
- package/dist/{management-C9w3DNhs.js → management-BcGHyxAP.js} +26 -45
- package/dist/management-BcGHyxAP.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 -2
- package/dist/metastore/types.d.cts +1 -1
- package/dist/metastore/types.d.ts +1 -1
- package/dist/{metastore-Ywq08DBz.js → metastore-CGsgxjng.js} +7 -10
- package/dist/{metastore-Ywq08DBz.js.map → metastore-CGsgxjng.js.map} +1 -1
- package/dist/{metastore-BXHg33ku.cjs → metastore-DeRQ2VIv.cjs} +7 -10
- package/dist/{metastore-BXHg33ku.cjs.map → metastore-DeRQ2VIv.cjs.map} +1 -1
- package/dist/microsoftGraph/index.cjs +5 -8
- package/dist/microsoftGraph/index.cjs.map +1 -1
- package/dist/microsoftGraph/index.d.cts +3 -7
- package/dist/microsoftGraph/index.d.ts +3 -7
- package/dist/microsoftGraph/index.js +5 -8
- package/dist/microsoftGraph/index.js.map +1 -1
- package/dist/microsoftGraph/types.d.cts +2 -4
- package/dist/microsoftGraph/types.d.ts +2 -4
- package/dist/{middleware-GOfx8Apu.js → middleware-8zaJWcyU.js} +3 -5
- package/dist/middleware-8zaJWcyU.js.map +1 -0
- package/dist/{middleware-CEP6uu_D.cjs → middleware-B9RNuLfD.cjs} +3 -5
- package/dist/middleware-B9RNuLfD.cjs.map +1 -0
- package/dist/notifications/index.cjs +5 -6
- package/dist/notifications/index.d.cts +2 -4
- package/dist/notifications/index.d.ts +2 -4
- package/dist/notifications/index.js +5 -6
- 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 +2 -4
- package/dist/oauth/index.d.ts +2 -4
- package/dist/oauth/index.js +1 -2
- package/dist/oauth/types.d.cts +1 -1
- package/dist/oauth/types.d.ts +1 -1
- package/dist/{oauth-DKZPuUlt.cjs → oauth-B5Biqz21.cjs} +7 -9
- package/dist/{oauth-DKZPuUlt.cjs.map → oauth-B5Biqz21.cjs.map} +1 -1
- package/dist/{oauth-GXmZ9agP.js → oauth-ByCdISsV.js} +7 -9
- package/dist/{oauth-GXmZ9agP.js.map → oauth-ByCdISsV.js.map} +1 -1
- package/dist/omnisearch/index.cjs +3 -4
- package/dist/omnisearch/index.d.cts +2 -4
- package/dist/omnisearch/index.d.ts +2 -4
- package/dist/omnisearch/index.js +3 -4
- package/dist/omnisearch/types.d.cts +1 -1
- package/dist/omnisearch/types.d.ts +1 -1
- package/dist/{project-ClH22nzH.js → project-DmuC0bMK.js} +6 -9
- package/dist/{project-ClH22nzH.js.map → project-DmuC0bMK.js.map} +1 -1
- package/dist/{project-Rh4nXiWh.cjs → project-Onf-IcPW.cjs} +9 -12
- package/dist/{project-Rh4nXiWh.cjs.map → project-Onf-IcPW.cjs.map} +1 -1
- package/dist/{project-DTfBtIJs.d.ts → project-UHZGFmmG.d.cts} +5 -9
- package/dist/{project-vOnvjo80.d.cts → project-iBm4cIIR.d.ts} +5 -9
- 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 -2
- package/dist/queryService/types.d.cts +1 -1
- package/dist/queryService/types.d.ts +1 -1
- package/dist/{queryService-CzK53q94.cjs → queryService-Cg-eMysa.cjs} +9 -11
- package/dist/{queryService-CzK53q94.cjs.map → queryService-Cg-eMysa.cjs.map} +1 -1
- package/dist/{queryService-C-pZha5p.js → queryService-x8kq8Z2-.js} +9 -11
- package/dist/{queryService-C-pZha5p.js.map → queryService-x8kq8Z2-.js.map} +1 -1
- package/dist/queue/index.cjs +1 -1
- package/dist/queue/index.d.cts +4 -5
- package/dist/queue/index.d.ts +4 -5
- package/dist/queue/index.js +1 -2
- package/dist/queue/types.d.cts +1 -1
- package/dist/queue/types.d.ts +1 -1
- package/dist/{queue-D6-x4OGF.js → queue-BiIs9fX4.js} +9 -11
- package/dist/{queue-D6-x4OGF.js.map → queue-BiIs9fX4.js.map} +1 -1
- package/dist/{queue-BJvDWriM.cjs → queue-CBi9Q8vp.cjs} +9 -11
- package/dist/{queue-BJvDWriM.cjs.map → queue-CBi9Q8vp.cjs.map} +1 -1
- package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/dist/scheduler/index.cjs +5 -6
- package/dist/scheduler/index.d.cts +2 -4
- package/dist/scheduler/index.d.ts +2 -4
- package/dist/scheduler/index.js +5 -6
- package/dist/scheduler/types.d.cts +1 -1
- package/dist/scheduler/types.d.ts +1 -1
- package/dist/{schema-BUyMwQnM.d.cts → schema-DLmBEgPM.d.cts} +1 -3
- package/dist/{schema-BUyMwQnM.d.ts → schema-DLmBEgPM.d.ts} +1 -3
- package/dist/schemaGuidedMerge-C8CqrNGe.cjs +55 -0
- package/dist/schemaGuidedMerge-C8CqrNGe.cjs.map +1 -0
- package/dist/schemaGuidedMerge-DFNqj9Nz.js +44 -0
- package/dist/schemaGuidedMerge-DFNqj9Nz.js.map +1 -0
- package/dist/sdk/configurations/index.cjs +634 -2
- package/dist/sdk/configurations/index.cjs.map +1 -0
- package/dist/sdk/configurations/index.d.cts +1030 -4
- package/dist/sdk/configurations/index.d.ts +1030 -4
- package/dist/sdk/configurations/index.js +633 -1
- package/dist/sdk/configurations/index.js.map +1 -0
- package/dist/sdk/developerPortal/index.cjs +9 -13
- package/dist/sdk/developerPortal/index.cjs.map +1 -1
- package/dist/sdk/developerPortal/index.d.cts +4 -6
- package/dist/sdk/developerPortal/index.d.ts +4 -6
- package/dist/sdk/developerPortal/index.js +9 -13
- package/dist/sdk/developerPortal/index.js.map +1 -1
- package/dist/sdk/kaiMemory/index.cjs +1 -1
- package/dist/sdk/kaiMemory/index.d.cts +1 -3
- package/dist/sdk/kaiMemory/index.d.ts +1 -3
- package/dist/sdk/kaiMemory/index.js +1 -2
- package/dist/sdk/kaiMemory/types.d.cts +1 -1
- package/dist/sdk/kaiMemory/types.d.ts +1 -1
- package/dist/sdk/queryService/index.cjs +3 -4
- package/dist/sdk/queryService/index.d.cts +1 -1
- package/dist/sdk/queryService/index.d.ts +1 -1
- package/dist/sdk/queryService/index.js +3 -4
- package/dist/sdk/semanticLayer/index.cjs +1 -1
- package/dist/sdk/semanticLayer/index.d.cts +1 -7
- package/dist/sdk/semanticLayer/index.d.ts +1 -7
- package/dist/sdk/semanticLayer/index.js +1 -2
- package/dist/sdk/semanticLayer/types.d.cts +1 -1
- package/dist/sdk/semanticLayer/types.d.ts +1 -1
- package/dist/sdk/storage/index.cjs +3 -6
- package/dist/sdk/storage/index.cjs.map +1 -1
- package/dist/sdk/storage/index.d.cts +0 -6
- package/dist/sdk/storage/index.d.ts +0 -6
- package/dist/sdk/storage/index.js +3 -6
- package/dist/sdk/storage/index.js.map +1 -1
- package/dist/sdk/tag/index.cjs +1 -1
- package/dist/sdk/tag/index.d.cts +3 -5
- package/dist/sdk/tag/index.d.ts +3 -5
- package/dist/sdk/tag/index.js +1 -2
- package/dist/sdk/tag/types.d.cts +1 -1
- package/dist/sdk/tag/types.d.ts +1 -1
- package/dist/sdk/vault/index.cjs +3 -5
- package/dist/sdk/vault/index.cjs.map +1 -1
- package/dist/sdk/vault/index.d.cts +1 -1
- package/dist/sdk/vault/index.d.ts +1 -1
- package/dist/sdk/vault/index.js +3 -5
- package/dist/sdk/vault/index.js.map +1 -1
- package/dist/{semanticLayer-DvjS_nzo.js → semanticLayer-BdPW_wLo.js} +9 -14
- package/dist/{semanticLayer-DvjS_nzo.js.map → semanticLayer-BdPW_wLo.js.map} +1 -1
- package/dist/{semanticLayer-7BejcMj_.cjs → semanticLayer-djom-J78.cjs} +9 -14
- package/dist/{semanticLayer-7BejcMj_.cjs.map → semanticLayer-djom-J78.cjs.map} +1 -1
- package/dist/status/index.cjs +2 -3
- package/dist/status/index.d.cts +1 -3
- package/dist/status/index.d.ts +1 -3
- package/dist/status/index.js +2 -3
- package/dist/status/types.d.cts +0 -2
- package/dist/status/types.d.ts +0 -2
- package/dist/storage/index.cjs +9 -9
- package/dist/storage/index.d.cts +3 -2
- package/dist/storage/index.d.ts +3 -2
- package/dist/storage/index.js +9 -9
- package/dist/storage/types.d.cts +6 -6
- package/dist/storage/types.d.ts +6 -6
- package/dist/{storage-CChfKlrb.js → storage-BpOLWT6h.js} +54 -89
- package/dist/{storage-CChfKlrb.js.map → storage-BpOLWT6h.js.map} +1 -1
- package/dist/{storage-Ci9gXgcw.cjs → storage-KJ5Ki_ma.cjs} +53 -88
- package/dist/{storage-Ci9gXgcw.cjs.map → storage-KJ5Ki_ma.cjs.map} +1 -1
- package/dist/{store-xS-Cu_VS.cjs → store-2OyH1XOP.cjs} +3 -5
- package/dist/{store-xS-Cu_VS.cjs.map → store-2OyH1XOP.cjs.map} +1 -1
- package/dist/{store-C9FQCHGe.js → store-HP0zRcLz.js} +3 -5
- package/dist/{store-C9FQCHGe.js.map → store-HP0zRcLz.js.map} +1 -1
- package/dist/stream/index.cjs +4 -5
- package/dist/stream/index.d.cts +2 -4
- package/dist/stream/index.d.ts +2 -4
- package/dist/stream/index.js +4 -5
- package/dist/stream/types.d.cts +1 -1
- package/dist/stream/types.d.ts +1 -1
- package/dist/{suggestions-BH3x7xU7.d.ts → suggestions-xhIjrlvi.d.cts} +1 -3
- package/dist/{suggestions-BH3x7xU7.d.cts → suggestions-xhIjrlvi.d.ts} +1 -3
- 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 -2
- package/dist/syncActions/types.d.cts +2 -2
- package/dist/syncActions/types.d.ts +2 -2
- package/dist/{syncActions-C1rE4R3f.cjs → syncActions-BcX3jm2E.cjs} +74 -187
- package/dist/syncActions-BcX3jm2E.cjs.map +1 -0
- package/dist/{syncActions-DM8vP7p3.js → syncActions-giPLTfje.js} +73 -186
- package/dist/syncActions-giPLTfje.js.map +1 -0
- package/dist/{tag-DHS_soa7.cjs → tag-A5z4tJn1.cjs} +5 -7
- package/dist/{tag-DHS_soa7.cjs.map → tag-A5z4tJn1.cjs.map} +1 -1
- package/dist/{tag-hh-1nhNr.js → tag-BwjbG3tT.js} +5 -7
- package/dist/{tag-hh-1nhNr.js.map → tag-BwjbG3tT.js.map} +1 -1
- package/dist/telemetry/index.cjs +4 -5
- package/dist/telemetry/index.d.cts +2 -4
- package/dist/telemetry/index.d.ts +2 -4
- package/dist/telemetry/index.js +4 -5
- package/dist/telemetry/types.d.cts +1 -1
- package/dist/telemetry/types.d.ts +1 -1
- package/dist/{transientRetries-B4iusp69.js → transientRetries-BKqmb85B.js} +13 -22
- package/dist/{transientRetries-B4iusp69.js.map → transientRetries-BKqmb85B.js.map} +1 -1
- package/dist/{transientRetries-DdJfH9QK.cjs → transientRetries-CM7rAEXQ.cjs} +13 -22
- package/dist/{transientRetries-DdJfH9QK.cjs.map → transientRetries-CM7rAEXQ.cjs.map} +1 -1
- package/dist/{types-DODAZKEm.d.ts → types--Rp5wvaz.d.ts} +2 -6
- package/dist/{types-JZ0Bdlpk.d.cts → types-1IBnjBVJ.d.cts} +2 -6
- package/dist/{types-BZ--6pIt.d.ts → types-37vwxse4.d.cts} +2 -6
- package/dist/{types-RogkWzOu.d.ts → types-6T04_qUf.d.ts} +2 -6
- package/dist/{types-TmrPVMhy.d.cts → types-B0e-no6u.d.ts} +18 -38
- package/dist/{types-ptynVnkv.d.cts → types-B1qe1etN.d.cts} +3 -7
- package/dist/{types-BXybSjn-.d.ts → types-B3ri-iiC.d.ts} +2 -26
- package/dist/{types-dn6MHur3.d.cts → types-BB49alHP.d.cts} +243 -9
- package/dist/{types-Duurgaqk.d.cts → types-BCGrKW1K.d.cts} +6 -10
- package/dist/{types-BOT6TgOS.d.ts → types-BE8abIig.d.cts} +2 -6
- package/dist/{types-BrpIEj_N.d.ts → types-BWMOK6eL.d.cts} +2 -6
- package/dist/{types-D53zBV25.d.ts → types-Bat0SIZA.d.cts} +16 -97
- package/dist/{types-Dy6EdWPG.d.ts → types-Bdl7EFMc.d.ts} +2 -6
- package/dist/{types-CfXqFz2e.d.ts → types-BfB-XXLF.d.ts} +243 -9
- package/dist/{types-_zKX6JmD.d.ts → types-BiDdBXSm.d.ts} +2 -8
- package/dist/{types-BnmsuDfH.d.cts → types-BuclMPeY.d.cts} +2 -26
- package/dist/{types-302-NBaU.d.ts → types-C9okze_R.d.ts} +3 -7
- package/dist/{types-BT5e9TSQ.d.ts → types-CPWjRdnj.d.cts} +18 -38
- package/dist/{types-C614wC5h.d.cts → types-CRubbBcU.d.cts} +2 -6
- package/dist/{types-DlhNay1n.d.ts → types-CWcdaq-K.d.ts} +2 -6
- package/dist/{types-D9ZKJYZk.d.ts → types-CcGp6O3B.d.cts} +3 -7
- package/dist/{types-45O2dU2w.d.ts → types-Cr5lyI99.d.ts} +2 -6
- package/dist/{types-CY8X39qv.d.cts → types-CxEJ77m3.d.cts} +3 -7
- package/dist/{types-DmzSFOhK.d.cts → types-D-tJt0hQ.d.cts} +2 -6
- package/dist/{types-BjwbzqJd.d.ts → types-D6lre27s.d.ts} +2 -8
- package/dist/{types-0R9-osUJ.d.ts → types-DHMxPJZq.d.cts} +2 -6
- package/dist/{types-jN2KmMet.d.cts → types-DJzTVMu1.d.ts} +2 -6
- package/dist/{types-CpJhWBmH.d.cts → types-DNgazFnF.d.cts} +2 -8
- package/dist/{types-DjadPty5.d.ts → types-DRCttnIN.d.ts} +2 -6
- package/dist/{types-CeqZuOEC.d.ts → types-DUpVIuk7.d.ts} +2 -6
- package/dist/{types-DqOxIujY.d.ts → types-DeyXJzWz.d.cts} +2 -6
- package/dist/{types-O6XM48J8.d.cts → types-Dryq2GGE.d.cts} +2 -6
- package/dist/{types-CjNl7O7f.d.cts → types-DschSZHf.d.cts} +3 -5
- package/dist/{types-BUirSne-.d.ts → types-DtOfhDzz.d.ts} +3 -5
- package/dist/{types-CkJxMoTk.d.cts → types-Du5o-tud.d.ts} +16 -97
- package/dist/{types-ChLWY8aU.d.cts → types-DwbTiyhZ.d.cts} +2 -6
- package/dist/{types-tdIo5FpR.d.ts → types-Dz9vyloX.d.ts} +6 -10
- package/dist/{types-HmK8iKp5.d.cts → types-E8tzafsk.d.cts} +3 -7
- package/dist/{types-DpbrGDRf.d.cts → types-LconaX98.d.cts} +2 -6
- package/dist/{types-CTS2NSIb.d.cts → types-YpOm4yXE.d.cts} +2 -8
- package/dist/{types-DbXV0g8U.d.cts → types-ZZwdKCBl.d.ts} +2 -6
- package/dist/{types-jfPoUlO8.d.cts → types-eFi8xJIM.d.cts} +2 -6
- package/dist/{types-DV7K07oX.d.cts → types-inG9y3dP.d.ts} +2 -6
- package/dist/{types-BM6rri7-.d.ts → types-ir7T2a9a.d.ts} +3 -7
- package/dist/{types-BAsYMltG.d.cts → types-jjOulnni.d.ts} +2 -6
- package/dist/{types-vvw_H7wp.d.cts → types-wYrC2boT.d.ts} +3 -7
- package/dist/{types-BWzt1ju_.d.ts → types-xzt_2H63.d.ts} +3 -7
- package/dist/{types-D2Pb_4FA.d.cts → types-zPY-XGnM.d.ts} +2 -6
- package/dist/{validateConnectionStatus-BalWEyRk.cjs → validateConnectionStatus-BjemGI1e.cjs} +5 -7
- package/dist/{validateConnectionStatus-BalWEyRk.cjs.map → validateConnectionStatus-BjemGI1e.cjs.map} +1 -1
- package/dist/{validateConnectionStatus-DyrYpn0G.js → validateConnectionStatus-DYwWeWVo.js} +5 -7
- package/dist/{validateConnectionStatus-DyrYpn0G.js.map → validateConnectionStatus-DYwWeWVo.js.map} +1 -1
- package/dist/vault/index.cjs +7 -8
- package/dist/vault/index.d.cts +1 -1
- package/dist/vault/index.d.ts +1 -1
- package/dist/vault/index.js +7 -8
- package/dist/vault/types.d.cts +1 -1
- package/dist/vault/types.d.ts +1 -1
- package/package.json +7 -7
- package/surface/apps.md +12 -10
- package/surface/chat.md +1 -1
- package/surface/dataScience.md +1 -1
- package/surface/editor.md +5 -5
- package/surface/kaiAgent.md +4 -4
- package/surface/management.md +1 -1
- package/surface/queue.md +3 -3
- package/surface/sdk.md +0 -6
- package/surface/stack.md +11 -0
- package/surface/storage.md +2 -2
- package/surface/stream.md +6 -6
- package/surface/syncActions.md +1 -2
- package/dist/configurations-B44z6BSO.js +0 -718
- package/dist/configurations-B44z6BSO.js.map +0 -1
- package/dist/configurations-CL0ouUMa.js.map +0 -1
- package/dist/configurations-D9J3jh3g.cjs.map +0 -1
- package/dist/configurations-Dkxsa3Uf.cjs +0 -735
- package/dist/configurations-Dkxsa3Uf.cjs.map +0 -1
- package/dist/constants-DErcRkWl.cjs.map +0 -1
- package/dist/constants-VpSwBtCb.js.map +0 -1
- package/dist/createGenericFetchClient-CQdNcPC3.js +0 -7
- package/dist/createOpenapiFetchClient-DXiMv9WL.js +0 -7
- package/dist/generateUUID-Dr8l-aoc.js +0 -6
- package/dist/index-Be2dNJ_N.d.cts +0 -23582
- package/dist/index-BfqkgPGI.d.cts +0 -34
- package/dist/index-BfqkgPGI.d.ts +0 -34
- package/dist/index-fMoM8SeH.d.cts +0 -199
- package/dist/index-fMoM8SeH.d.ts +0 -199
- package/dist/index-uGRdAORl.d.ts +0 -23582
- package/dist/management-B1o6RpKF.cjs.map +0 -1
- package/dist/management-C9w3DNhs.js.map +0 -1
- package/dist/middleware-CEP6uu_D.cjs.map +0 -1
- package/dist/middleware-GOfx8Apu.js.map +0 -1
- package/dist/storageTable-BNOR2FCh.cjs +0 -442
- package/dist/storageTable-BNOR2FCh.cjs.map +0 -1
- package/dist/storageTable-BldTNyEk.js +0 -395
- package/dist/storageTable-BldTNyEk.js.map +0 -1
- package/dist/syncActions-C1rE4R3f.cjs.map +0 -1
- package/dist/syncActions-DM8vP7p3.js.map +0 -1
- package/surface/context.md +0 -40
package/dist/index.js
CHANGED
|
@@ -1,61 +1,102 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
9
|
-
import { n as
|
|
10
|
-
import { t as
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
13
|
-
import { t as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { n as
|
|
17
|
-
import { n as
|
|
18
|
-
import { n as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { t as
|
|
22
|
-
import { t as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { i as createKaiMemorySdk } from "./kaiMemory-C9di17bd.js";
|
|
27
|
-
import { i as createSemanticLayerSdk } from "./semanticLayer-DvjS_nzo.js";
|
|
1
|
+
import { t as UserError } from "./UserError-BxoOJJ_u.js";
|
|
2
|
+
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-DlGCbltR.js";
|
|
3
|
+
import { n as HtmlResponseError, r as isHtmlResponseError } from "./validateConnectionStatus-DYwWeWVo.js";
|
|
4
|
+
import { a as series, c as ServiceUnavailableError, d as isManageError, f as manageErrorCode, l as retryAfterSeconds, o as StorageJobError, s as isStorageJobError, t as createStorageClient, u as readableReason } from "./storage-BpOLWT6h.js";
|
|
5
|
+
import { n as ManagementClientAuthError, t as ManagementSessionMintError } from "./ManagementSessionMintError-DNMbYauw.js";
|
|
6
|
+
import { n as isQueryJobError, t as QueryJobError } from "./QueryJobError-Iq9O90Uh.js";
|
|
7
|
+
import { n as isQueueJobError, t as QueueJobError } from "./QueueJobError-BJNUINXW.js";
|
|
8
|
+
import { n as isSyncActionError, t as SyncActionError } from "./SyncActionError-DuGcDbkd.js";
|
|
9
|
+
import { i as parseOrThrow, n as formatValidationIssues, r as isValidationError, t as ValidationError } from "./ValidationError-BsdFDGY2.js";
|
|
10
|
+
import { t as createGenericFetchClient } from "./createGenericFetchClient-wGxemBwR.js";
|
|
11
|
+
import { t as createImportClient } from "./import-CT1Ce5Rp.js";
|
|
12
|
+
import { d as collectByCursor, f as nextCursorOf, t as createAuthClient } from "./authClient-oB5ydxWp.js";
|
|
13
|
+
import { t as collectByOffset } from "./collectByOffset-i8Tdoze7.js";
|
|
14
|
+
import { t as concurrent } from "./concurrent-BtsT10Xe.js";
|
|
15
|
+
import { t as dedupe } from "./dedupe-Bu0d2i_w.js";
|
|
16
|
+
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-BKqmb85B.js";
|
|
17
|
+
import { n as createEmitter, t as createStore } from "./store-HP0zRcLz.js";
|
|
18
|
+
import { n as keboolaUID, t as createTagSdk } from "./tag-BwjbG3tT.js";
|
|
19
|
+
import { t as generateUUID } from "./generateUUID-DE9sNyJF.js";
|
|
20
|
+
import { t as isPlainObject } from "./isPlainObject-BxsT8_t2.js";
|
|
21
|
+
import { n as isEmptyDeep, t as schemaGuidedMerge } from "./schemaGuidedMerge-DFNqj9Nz.js";
|
|
22
|
+
import { n as isManagementClientAuthError, r as isManagementSessionMintError, t as createManagementClient } from "./management-BcGHyxAP.js";
|
|
23
|
+
import { u as ServiceId } from "./constants-BMSHGwOR.js";
|
|
24
|
+
import { i as createKaiMemorySdk } from "./kaiMemory-oir_qCo_.js";
|
|
25
|
+
import { i as createSemanticLayerSdk } from "./semanticLayer-BdPW_wLo.js";
|
|
28
26
|
import { createVaultSdk } from "./sdk/vault/index.js";
|
|
29
27
|
import { createAiClient } from "./ai/index.js";
|
|
30
|
-
import { t as parseLogLines } from "./appLogs-
|
|
28
|
+
import { t as parseLogLines } from "./appLogs-DFcPwVk8.js";
|
|
31
29
|
import { createAppsClient } from "./apps/index.js";
|
|
32
30
|
import { createBillingClient } from "./billing/index.js";
|
|
33
31
|
import { createChatClient } from "./chat/index.js";
|
|
34
|
-
import { t as createComponentsMcpClient } from "./componentsMcp-
|
|
35
|
-
import { t as createDataScienceClient } from "./dataScience-
|
|
32
|
+
import { t as createComponentsMcpClient } from "./componentsMcp-BrB4js6b.js";
|
|
33
|
+
import { t as createDataScienceClient } from "./dataScience-CXmkEOAi.js";
|
|
36
34
|
import { createEditorClient } from "./editor/index.js";
|
|
37
35
|
import { createEncryptionClient } from "./encryption/index.js";
|
|
38
|
-
import { t as createKaiAgentClient } from "./kaiAgent-
|
|
39
|
-
import { t as createMetastoreClient } from "./metastore-
|
|
36
|
+
import { t as createKaiAgentClient } from "./kaiAgent-D2TiMDjW.js";
|
|
37
|
+
import { t as createMetastoreClient } from "./metastore-CGsgxjng.js";
|
|
40
38
|
import { createNotificationsClient } from "./notifications/index.js";
|
|
41
|
-
import { t as createOauthClient } from "./oauth-
|
|
39
|
+
import { t as createOauthClient } from "./oauth-ByCdISsV.js";
|
|
42
40
|
import { createOmnisearchClient } from "./omnisearch/index.js";
|
|
43
|
-
import { t as createQueryServiceClient } from "./queryService-
|
|
44
|
-
import { t as createQueueClient } from "./queue-
|
|
41
|
+
import { t as createQueryServiceClient } from "./queryService-x8kq8Z2-.js";
|
|
42
|
+
import { t as createQueueClient } from "./queue-BiIs9fX4.js";
|
|
45
43
|
import { createSchedulerClient } from "./scheduler/index.js";
|
|
46
44
|
import { createStreamClient } from "./stream/index.js";
|
|
47
|
-
import { t as createSyncActionsClient } from "./syncActions-
|
|
45
|
+
import { t as createSyncActionsClient } from "./syncActions-giPLTfje.js";
|
|
48
46
|
import { createTelemetryClient } from "./telemetry/index.js";
|
|
49
47
|
import { createVaultClient } from "./vault/index.js";
|
|
50
|
-
import { n as isUnauthorized, t as createBearerAuthMiddleware } from "./middleware-
|
|
48
|
+
import { n as isUnauthorized, t as createBearerAuthMiddleware } from "./middleware-8zaJWcyU.js";
|
|
49
|
+
import { t as createProject } from "./project-DmuC0bMK.js";
|
|
51
50
|
import { createQueryServiceSdk } from "./sdk/queryService/index.js";
|
|
52
51
|
import * as z$1 from "zod";
|
|
53
|
-
|
|
52
|
+
// src/keboola/errors.ts
|
|
53
|
+
/**
|
|
54
|
+
* The single error the keboola client / session throws. It carries a stable `type` (the switchable
|
|
55
|
+
* contract) and a human-readable message derived from that type — no per-call message strings.
|
|
56
|
+
*/
|
|
57
|
+
const KeboolaErrorType = {
|
|
58
|
+
Unconfigured: "unconfigured",
|
|
59
|
+
NotAuthenticated: "not-authenticated",
|
|
60
|
+
SignInEnded: "sign-in-ended",
|
|
61
|
+
AlreadyAuthenticated: "already-authenticated",
|
|
62
|
+
NoStorageToken: "no-storage-token",
|
|
63
|
+
NoManagementToken: "no-management-token",
|
|
64
|
+
MissingProject: "missing-project",
|
|
65
|
+
NotBearer: "not-bearer",
|
|
66
|
+
NotReady: "not-ready",
|
|
67
|
+
InvalidBuildTransition: "invalid-build-transition"
|
|
68
|
+
};
|
|
69
|
+
const MESSAGES = {
|
|
70
|
+
[KeboolaErrorType.Unconfigured]: "The session is not configured — set a baseUrl first.",
|
|
71
|
+
[KeboolaErrorType.NotAuthenticated]: "The session is not authenticated — sign in first.",
|
|
72
|
+
[KeboolaErrorType.SignInEnded]: "The sign-in this operation started under has ended — its result belongs to nobody.",
|
|
73
|
+
[KeboolaErrorType.AlreadyAuthenticated]: "The session is already authenticated — reset before authenticating again.",
|
|
74
|
+
[KeboolaErrorType.NoStorageToken]: "No storage token — authenticate the storage realm first.",
|
|
75
|
+
[KeboolaErrorType.NoManagementToken]: "No management token — authenticate the management realm first.",
|
|
76
|
+
[KeboolaErrorType.MissingProject]: "A bearer storage session requires a project — call setProject(projectId) first.",
|
|
77
|
+
[KeboolaErrorType.NotBearer]: "This operation requires a bearer (OAuth) session.",
|
|
78
|
+
[KeboolaErrorType.NotReady]: "The client is not ready — authenticate the storage realm first.",
|
|
79
|
+
[KeboolaErrorType.InvalidBuildTransition]: "Invalid storage build transition — the build goes idle → initializing → ready | failed."
|
|
80
|
+
};
|
|
81
|
+
var KeboolaError = class KeboolaError extends Error {
|
|
82
|
+
type;
|
|
83
|
+
constructor(type) {
|
|
84
|
+
super(MESSAGES[type]);
|
|
85
|
+
this.type = type;
|
|
86
|
+
this.name = "KeboolaError";
|
|
87
|
+
Object.setPrototypeOf(this, KeboolaError.prototype);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const isKeboolaError = (error) => error instanceof KeboolaError;
|
|
91
|
+
/** Throw a {@link KeboolaError} of `type` when `value` is null/undefined; otherwise narrow it. */
|
|
92
|
+
function assert$1(value, type) {
|
|
93
|
+
if (value == null) throw new KeboolaError(type);
|
|
94
|
+
}
|
|
95
|
+
// src/utils/assert.ts
|
|
54
96
|
function assert(value, message) {
|
|
55
97
|
if (value == null) throw new Error(message);
|
|
56
98
|
}
|
|
57
|
-
|
|
58
|
-
//#region src/utils/ensure.ts
|
|
99
|
+
// src/utils/ensure.ts
|
|
59
100
|
/**
|
|
60
101
|
* Read a key, or build its value and keep it.
|
|
61
102
|
*
|
|
@@ -70,8 +111,7 @@ const ensure = (map, key, build) => {
|
|
|
70
111
|
map.set(key, created);
|
|
71
112
|
return created;
|
|
72
113
|
};
|
|
73
|
-
|
|
74
|
-
//#region src/utils/async/coalesce.ts
|
|
114
|
+
// src/utils/async/coalesce.ts
|
|
75
115
|
/**
|
|
76
116
|
* Coalesces concurrent triggers onto a single, never-parallel run of `task`.
|
|
77
117
|
*
|
|
@@ -101,8 +141,7 @@ const coalesce = (task) => {
|
|
|
101
141
|
return waiter.promise;
|
|
102
142
|
};
|
|
103
143
|
};
|
|
104
|
-
|
|
105
|
-
//#region src/utils/store/derivedStore.ts
|
|
144
|
+
// src/utils/store/derivedStore.ts
|
|
106
145
|
const isPlainObjectOrArray = (value) => {
|
|
107
146
|
if (Array.isArray(value)) return true;
|
|
108
147
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -137,8 +176,7 @@ const createDerivedStore = ({ source, dependsOn, build, keyEquals = shallowEqual
|
|
|
137
176
|
dispose
|
|
138
177
|
};
|
|
139
178
|
};
|
|
140
|
-
|
|
141
|
-
//#region src/utils/store/derivedAsyncStore.ts
|
|
179
|
+
// src/utils/store/derivedAsyncStore.ts
|
|
142
180
|
const createDerivedAsyncStore = ({ source, dependsOn, build, keyEquals = shallowEqual }) => {
|
|
143
181
|
const store = createStore({ state: "idle" });
|
|
144
182
|
let currentKey = null;
|
|
@@ -206,8 +244,7 @@ const createDerivedAsyncStore = ({ source, dependsOn, build, keyEquals = shallow
|
|
|
206
244
|
settled
|
|
207
245
|
};
|
|
208
246
|
};
|
|
209
|
-
|
|
210
|
-
//#region src/utils/async/poll/registry.ts
|
|
247
|
+
// src/utils/async/poll/registry.ts
|
|
211
248
|
const DEFAULT_LIMIT = 50;
|
|
212
249
|
const isFinished = ({ snapshot }) => snapshot.state !== "idle" && snapshot.state !== "requesting" && snapshot.state !== "polling";
|
|
213
250
|
const createPollRegistry = ({ limit = DEFAULT_LIMIT } = {}) => {
|
|
@@ -259,8 +296,7 @@ const createPollRegistry = ({ limit = DEFAULT_LIMIT } = {}) => {
|
|
|
259
296
|
stopAll: (reason) => entries.get().forEach((entry) => entry.stop(reason))
|
|
260
297
|
};
|
|
261
298
|
};
|
|
262
|
-
|
|
263
|
-
//#region src/utils/async/queueSeries.ts
|
|
299
|
+
// src/utils/async/queueSeries.ts
|
|
264
300
|
const isPromiseLike = (value) => (typeof value === "object" && value !== null || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
265
301
|
/**
|
|
266
302
|
* Queues tasks added over time so a slower earlier task cannot finish after and overwrite a later one.
|
|
@@ -300,8 +336,7 @@ const queueSeries = () => {
|
|
|
300
336
|
onIdle
|
|
301
337
|
};
|
|
302
338
|
};
|
|
303
|
-
|
|
304
|
-
//#region src/utils/deepMerge.ts
|
|
339
|
+
// src/utils/deepMerge.ts
|
|
305
340
|
/**
|
|
306
341
|
* Recursively merge `patch` into `base`. Plain-object values are merged key-by-key; every
|
|
307
342
|
* other value (primitives, arrays, or a type mismatch between the two sides) replaces the
|
|
@@ -317,8 +352,7 @@ const deepMerge = (base, patch) => {
|
|
|
317
352
|
}
|
|
318
353
|
return out;
|
|
319
354
|
};
|
|
320
|
-
|
|
321
|
-
//#region src/utils/persistor/adapters.ts
|
|
355
|
+
// src/utils/persistor/adapters.ts
|
|
322
356
|
const createNullStorage = () => ({
|
|
323
357
|
getItem: () => null,
|
|
324
358
|
setItem: () => {},
|
|
@@ -367,8 +401,7 @@ const createWebStorage = (pick) => {
|
|
|
367
401
|
};
|
|
368
402
|
const createLocalStorage = () => createWebStorage(() => "localStorage" in globalThis ? globalThis.localStorage : null);
|
|
369
403
|
const createSessionStorage = () => createWebStorage(() => "sessionStorage" in globalThis ? globalThis.sessionStorage : null);
|
|
370
|
-
|
|
371
|
-
//#region src/utils/persistor/persistor.ts
|
|
404
|
+
// src/utils/persistor/persistor.ts
|
|
372
405
|
const createPersistor = ({ storage = createNullStorage(), key, schema, defaultValue, encode = JSON.stringify, decode = JSON.parse }) => {
|
|
373
406
|
const writes = queueSeries();
|
|
374
407
|
const _load = async () => {
|
|
@@ -422,82 +455,7 @@ const createPersistor = ({ storage = createNullStorage(), key, schema, defaultVa
|
|
|
422
455
|
locked
|
|
423
456
|
};
|
|
424
457
|
};
|
|
425
|
-
|
|
426
|
-
//#region src/keboola/createLiveProject.ts
|
|
427
|
-
const STORAGE_TOKEN_MUTATING_PATTERNS = [/\/buckets(\/[^/]+)?$/, /\/projects\/[^/]+\/features(\/[^/]+)?$/];
|
|
428
|
-
const isStorageTokenMutatingRequest = (request) => {
|
|
429
|
-
if (request.method === "GET") return false;
|
|
430
|
-
const { pathname } = new URL(request.url);
|
|
431
|
-
return STORAGE_TOKEN_MUTATING_PATTERNS.some((pattern) => pattern.test(pathname));
|
|
432
|
-
};
|
|
433
|
-
const createProjectRefreshMiddleware = (shouldRefresh, requestRefresh) => (next) => async (request) => {
|
|
434
|
-
const response = await next(request);
|
|
435
|
-
if (shouldRefresh(request.request)) await requestRefresh();
|
|
436
|
-
return response;
|
|
437
|
-
};
|
|
438
|
-
/**
|
|
439
|
-
* The live project store, re-verified (coalesced) after a token-mutating request or a re-scope.
|
|
440
|
-
*/
|
|
441
|
-
const createLiveProject = ({ initialToken, verify }) => {
|
|
442
|
-
const store = createStore(createProject({ sapiToken: initialToken }));
|
|
443
|
-
const refresh = coalesce(async () => store.set(createProject({ sapiToken: await verify() })));
|
|
444
|
-
const middleware = createProjectRefreshMiddleware(isStorageTokenMutatingRequest, refresh);
|
|
445
|
-
return {
|
|
446
|
-
store,
|
|
447
|
-
getProject: () => store.get(),
|
|
448
|
-
subscribe: store.subscribe,
|
|
449
|
-
middleware,
|
|
450
|
-
refresh
|
|
451
|
-
};
|
|
452
|
-
};
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/keboola/errors.ts
|
|
455
|
-
/**
|
|
456
|
-
* The single error the keboola client / session throws. It carries a stable `type` (the switchable
|
|
457
|
-
* contract) and a human-readable message derived from that type — no per-call message strings.
|
|
458
|
-
*/
|
|
459
|
-
const KeboolaErrorType = {
|
|
460
|
-
Unconfigured: "unconfigured",
|
|
461
|
-
NotAuthenticated: "not-authenticated",
|
|
462
|
-
SignInEnded: "sign-in-ended",
|
|
463
|
-
AlreadyAuthenticated: "already-authenticated",
|
|
464
|
-
NoStorageToken: "no-storage-token",
|
|
465
|
-
NoManagementToken: "no-management-token",
|
|
466
|
-
MissingProject: "missing-project",
|
|
467
|
-
NotBearer: "not-bearer",
|
|
468
|
-
NotReady: "not-ready",
|
|
469
|
-
InvalidBuildTransition: "invalid-build-transition",
|
|
470
|
-
StackActive: "stack-active"
|
|
471
|
-
};
|
|
472
|
-
const MESSAGES = {
|
|
473
|
-
[KeboolaErrorType.Unconfigured]: "The session is not configured — set a baseUrl first.",
|
|
474
|
-
[KeboolaErrorType.NotAuthenticated]: "The session is not authenticated — sign in first.",
|
|
475
|
-
[KeboolaErrorType.SignInEnded]: "The sign-in this operation started under has ended — its result belongs to nobody.",
|
|
476
|
-
[KeboolaErrorType.AlreadyAuthenticated]: "The session is already authenticated — reset before authenticating again.",
|
|
477
|
-
[KeboolaErrorType.NoStorageToken]: "No storage token — authenticate the storage realm first.",
|
|
478
|
-
[KeboolaErrorType.NoManagementToken]: "No management token — authenticate the management realm first.",
|
|
479
|
-
[KeboolaErrorType.MissingProject]: "A bearer storage session requires a project — call setProject(projectId) first.",
|
|
480
|
-
[KeboolaErrorType.NotBearer]: "This operation requires a bearer (OAuth) session.",
|
|
481
|
-
[KeboolaErrorType.NotReady]: "The client is not ready — authenticate the storage realm first.",
|
|
482
|
-
[KeboolaErrorType.InvalidBuildTransition]: "Invalid storage build transition — the build goes idle → initializing → ready | failed.",
|
|
483
|
-
[KeboolaErrorType.StackActive]: "The active stack cannot be closed — select another first."
|
|
484
|
-
};
|
|
485
|
-
var KeboolaError = class KeboolaError extends Error {
|
|
486
|
-
type;
|
|
487
|
-
constructor(type) {
|
|
488
|
-
super(MESSAGES[type]);
|
|
489
|
-
this.type = type;
|
|
490
|
-
this.name = "KeboolaError";
|
|
491
|
-
Object.setPrototypeOf(this, KeboolaError.prototype);
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
const isKeboolaError = (error) => error instanceof KeboolaError;
|
|
495
|
-
/** Throw a {@link KeboolaError} of `type` when `value` is null/undefined; otherwise narrow it. */
|
|
496
|
-
function assert$1(value, type) {
|
|
497
|
-
if (value == null) throw new KeboolaError(type);
|
|
498
|
-
}
|
|
499
|
-
//#endregion
|
|
500
|
-
//#region src/serviceClientRegistry/utils.ts
|
|
458
|
+
// src/serviceClientRegistry/utils.ts
|
|
501
459
|
const isBuiltInProperty = (property) => typeof property === "symbol" || property === "then" || property === "constructor" || property === "toString" || property === "valueOf";
|
|
502
460
|
/**
|
|
503
461
|
* Creates a dummy client that intercepts method calls and invokes the provided onCall callback.
|
|
@@ -512,8 +470,7 @@ const createDummyClient = ({ onCall }) => {
|
|
|
512
470
|
});
|
|
513
471
|
return createProxy();
|
|
514
472
|
};
|
|
515
|
-
|
|
516
|
-
//#region src/serviceClientRegistry/createServiceClientRegistry.ts
|
|
473
|
+
// src/serviceClientRegistry/createServiceClientRegistry.ts
|
|
517
474
|
const createServiceClientRegistry = () => ({ getServiceBaseUrl, onUnavailable }) => {
|
|
518
475
|
const dummy = (serviceId, clientName) => createDummyClient({ onCall: (path, args) => {
|
|
519
476
|
onUnavailable?.({
|
|
@@ -552,8 +509,7 @@ const createServiceClientRegistry = () => ({ getServiceBaseUrl, onUnavailable })
|
|
|
552
509
|
};
|
|
553
510
|
return registry;
|
|
554
511
|
};
|
|
555
|
-
|
|
556
|
-
//#region src/keboola/createApi.ts
|
|
512
|
+
// src/keboola/createApi.ts
|
|
557
513
|
const createApi = (state) => new Proxy({}, { get(_target, property) {
|
|
558
514
|
if (isBuiltInProperty(property)) return void 0;
|
|
559
515
|
if (property === "auth") {
|
|
@@ -570,8 +526,7 @@ const createApi = (state) => new Proxy({}, { get(_target, property) {
|
|
|
570
526
|
assert$1(clients, KeboolaErrorType.NotReady);
|
|
571
527
|
return clients[property];
|
|
572
528
|
} });
|
|
573
|
-
|
|
574
|
-
//#region src/keboola/createMiddlewareFor.ts
|
|
529
|
+
// src/keboola/createMiddlewareFor.ts
|
|
575
530
|
const createMiddlewareFor = (middlewares) => {
|
|
576
531
|
return (target, baseline = []) => {
|
|
577
532
|
if (Array.isArray(middlewares)) return [...baseline, ...middlewares];
|
|
@@ -584,8 +539,7 @@ const createMiddlewareFor = (middlewares) => {
|
|
|
584
539
|
];
|
|
585
540
|
};
|
|
586
541
|
};
|
|
587
|
-
|
|
588
|
-
//#region src/keboola/legacy/createConfig.ts
|
|
542
|
+
// src/keboola/legacy/createConfig.ts
|
|
589
543
|
const createConfig = () => {
|
|
590
544
|
const store = createStore({
|
|
591
545
|
baseUrl: null,
|
|
@@ -622,25 +576,7 @@ const createConfig = () => {
|
|
|
622
576
|
debug
|
|
623
577
|
};
|
|
624
578
|
};
|
|
625
|
-
|
|
626
|
-
//#region src/domain/defaultBranch.ts
|
|
627
|
-
const createDefaultBranch = ({ devBranches }) => {
|
|
628
|
-
const defaultBranch = devBranches.find((branch) => branch.isDefault);
|
|
629
|
-
assert(defaultBranch, "No default branch found for the project.");
|
|
630
|
-
const getType = (branchId) => {
|
|
631
|
-
if (branchId == null || branchId === "default") return "default";
|
|
632
|
-
return Number(branchId) === defaultBranch.id ? "default" : "dev";
|
|
633
|
-
};
|
|
634
|
-
return {
|
|
635
|
-
id: defaultBranch.id,
|
|
636
|
-
name: defaultBranch.name,
|
|
637
|
-
getType,
|
|
638
|
-
isDev: (branchId) => getType(branchId) === "dev",
|
|
639
|
-
isDefault: (branchId) => getType(branchId) === "default"
|
|
640
|
-
};
|
|
641
|
-
};
|
|
642
|
-
//#endregion
|
|
643
|
-
//#region src/domain/stack.ts
|
|
579
|
+
// src/domain/stack.ts
|
|
644
580
|
const isServiceId = (id) => Object.values(ServiceId).includes(id);
|
|
645
581
|
const SERVICE_URL_OVERRIDES = { "kai-assistant": (url) => `${url}/api` };
|
|
646
582
|
const createStack = ({ stackInfo, clientServiceUrls }) => {
|
|
@@ -677,8 +613,7 @@ const createStack = ({ stackInfo, clientServiceUrls }) => {
|
|
|
677
613
|
hasComponent
|
|
678
614
|
};
|
|
679
615
|
};
|
|
680
|
-
|
|
681
|
-
//#region src/sdks/variables/variablesSdk.ts
|
|
616
|
+
// src/sdks/variables/variablesSdk.ts
|
|
682
617
|
const VARIABLES_COMPONENT_ID = "keboola.variables";
|
|
683
618
|
/** Union the definitions by name; on a name conflict the target's definition is kept. */
|
|
684
619
|
const mergeVariableDefinitions = (target, source) => {
|
|
@@ -759,14 +694,8 @@ const createVariablesSdk = ({ storageClient }) => {
|
|
|
759
694
|
}
|
|
760
695
|
};
|
|
761
696
|
};
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
const createSdk = ({ storage, services, context }) => ({
|
|
765
|
-
configuration: createConfigurationSdk({
|
|
766
|
-
storageClient: storage,
|
|
767
|
-
encryptionClient: services.encryption,
|
|
768
|
-
context
|
|
769
|
-
}),
|
|
697
|
+
// src/keboola/createSdk.ts
|
|
698
|
+
const createSdk = ({ storage, services }) => ({
|
|
770
699
|
tag: createTagSdk({ metastoreClient: services.metastore }),
|
|
771
700
|
semanticLayer: createSemanticLayerSdk({ metastoreClient: services.metastore }),
|
|
772
701
|
kaiMemory: createKaiMemorySdk({ metastoreClient: services.metastore }),
|
|
@@ -776,8 +705,7 @@ const createSdk = ({ storage, services, context }) => ({
|
|
|
776
705
|
}),
|
|
777
706
|
variables: createVariablesSdk({ storageClient: storage })
|
|
778
707
|
});
|
|
779
|
-
|
|
780
|
-
//#region src/keboola/createServiceClients.ts
|
|
708
|
+
// src/keboola/createServiceClients.ts
|
|
781
709
|
const withPath = (serviceBaseUrl, path) => typeof serviceBaseUrl === "string" ? `${serviceBaseUrl}${path}` : async () => `${await serviceBaseUrl()}${path}`;
|
|
782
710
|
const createServiceClients = ({ baseUrl, auth, getServiceBaseUrl, middlewareFor, attachTokenMiddleware }) => createServiceClientRegistry()({
|
|
783
711
|
getServiceBaseUrl,
|
|
@@ -953,8 +881,7 @@ const createServiceClients = ({ baseUrl, auth, getServiceBaseUrl, middlewareFor,
|
|
|
953
881
|
auth
|
|
954
882
|
})
|
|
955
883
|
}).build();
|
|
956
|
-
|
|
957
|
-
//#region src/keboola/legacy/createProjectClients.ts
|
|
884
|
+
// src/keboola/legacy/createProjectClients.ts
|
|
958
885
|
const createAttachStorageToken = (getToken) => (next) => (request) => {
|
|
959
886
|
request.request.headers.set(KeboolaHttpHeader.STORAGE_API_TOKEN, getToken());
|
|
960
887
|
return next(request);
|
|
@@ -965,72 +892,41 @@ const createProjectClients = async ({ baseUrl, getStorageToken, onStorageTokenRe
|
|
|
965
892
|
token: getStorageToken()
|
|
966
893
|
};
|
|
967
894
|
const attach = createAttachStorageToken(getStorageToken);
|
|
968
|
-
const
|
|
895
|
+
const stackInfo = await createStorageClient({
|
|
969
896
|
baseUrl,
|
|
970
897
|
auth,
|
|
971
898
|
middlewares: [attach]
|
|
972
|
-
});
|
|
973
|
-
const [stackInfo, sapiToken, devBranches] = await Promise.all([
|
|
974
|
-
_storage.getStackInfo({ exclude: "componentDetails" }),
|
|
975
|
-
_storage.tokens.verify(),
|
|
976
|
-
_storage.branches.getDevBranches()
|
|
977
|
-
]);
|
|
899
|
+
}).getStackInfo({ exclude: "componentDetails" });
|
|
978
900
|
const stack = createStack({
|
|
979
901
|
stackInfo,
|
|
980
902
|
clientServiceUrls
|
|
981
903
|
});
|
|
982
|
-
const defaultBranch = createDefaultBranch({ devBranches });
|
|
983
|
-
const liveProject = createLiveProject({
|
|
984
|
-
initialToken: sapiToken,
|
|
985
|
-
verify: () => _storage.tokens.verify()
|
|
986
|
-
});
|
|
987
|
-
const storageTableStore = createDerivedStore({
|
|
988
|
-
source: liveProject.store,
|
|
989
|
-
build: createStorageTable,
|
|
990
|
-
dependsOn: (project) => ({
|
|
991
|
-
useLegacyBucketPrefix: !project.hasFeature(ProjectFeature.DisableLegacyBucketPrefix),
|
|
992
|
-
hasProtectedDefaultBranch: project.hasFeature(ProjectFeature.SoxProtectedDefaultBranch),
|
|
993
|
-
hasStorageBranches: project.hasFeature(ProjectFeature.StorageBranches)
|
|
994
|
-
})
|
|
995
|
-
});
|
|
996
|
-
const context = {
|
|
997
|
-
baseUrl: normalizeBaseUrl(baseUrl),
|
|
998
|
-
stack,
|
|
999
|
-
defaultBranch,
|
|
1000
|
-
get project() {
|
|
1001
|
-
return liveProject.getProject();
|
|
1002
|
-
},
|
|
1003
|
-
get st() {
|
|
1004
|
-
return storageTableStore.get();
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
904
|
const storage = createStorageClient({
|
|
1008
905
|
baseUrl,
|
|
1009
906
|
auth,
|
|
1010
|
-
middlewares: middlewareFor("storage", [
|
|
907
|
+
middlewares: middlewareFor("storage", []),
|
|
1011
908
|
onRefreshToken: onStorageTokenRefreshed
|
|
1012
909
|
});
|
|
1013
910
|
const { client: services, meta: serviceMeta } = createServiceClients({
|
|
1014
911
|
baseUrl,
|
|
1015
912
|
auth,
|
|
1016
|
-
getServiceBaseUrl:
|
|
913
|
+
getServiceBaseUrl: stack.getServiceUrl,
|
|
1017
914
|
middlewareFor,
|
|
1018
915
|
attachTokenMiddleware: attach
|
|
1019
916
|
});
|
|
1020
917
|
return {
|
|
1021
|
-
|
|
918
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
919
|
+
stack,
|
|
1022
920
|
serviceMeta,
|
|
1023
921
|
storage,
|
|
1024
922
|
...services,
|
|
1025
923
|
sdk: createSdk({
|
|
1026
924
|
storage,
|
|
1027
|
-
services
|
|
1028
|
-
context
|
|
925
|
+
services
|
|
1029
926
|
})
|
|
1030
927
|
};
|
|
1031
928
|
};
|
|
1032
|
-
|
|
1033
|
-
//#region src/keboola/legacy/keboola.ts
|
|
929
|
+
// src/keboola/legacy/keboola.ts
|
|
1034
930
|
const createLegacyKeboola = (options = {}) => {
|
|
1035
931
|
const config = createConfig();
|
|
1036
932
|
const middlewareFor = createMiddlewareFor(options.middlewares);
|
|
@@ -1110,160 +1006,74 @@ const createLegacyKeboola = (options = {}) => {
|
|
|
1110
1006
|
session
|
|
1111
1007
|
};
|
|
1112
1008
|
};
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
/**
|
|
1116
|
-
* Everything the table constructs: the entries themselves, and the failures reading them produces.
|
|
1117
|
-
*
|
|
1118
|
-
* Nothing here touches the store — a factory takes what it is told and returns a value, so the
|
|
1119
|
-
* namespaces the tables build on can be read without following a dependency.
|
|
1120
|
-
*/
|
|
1121
|
-
const projectEntryId = (baseUrl, projectId) => `${baseUrl}#${projectId}`;
|
|
1122
|
-
/** What every project entry of one stack shares — the one thing a per-stack teardown matches on. */
|
|
1123
|
-
const projectEntryPrefix = (baseUrl) => `${baseUrl}#`;
|
|
1124
|
-
const isUnderStack = (baseUrl) => (id) => id.startsWith(projectEntryPrefix(baseUrl));
|
|
1125
|
-
const anonymousAuth = () => ({ status: "anonymous" });
|
|
1126
|
-
const restoringAuth = () => ({ status: "restoring" });
|
|
1127
|
-
const authenticatedAuth = (credential) => ({
|
|
1128
|
-
status: "authenticated",
|
|
1129
|
-
credential
|
|
1130
|
-
});
|
|
1131
|
-
const credential = (input) => ({
|
|
1132
|
-
...input,
|
|
1133
|
-
issuedAt: Date.now()
|
|
1134
|
-
});
|
|
1135
|
-
const grant = (credential) => credential.type === "token" ? {
|
|
1009
|
+
// src/keboola/bearer/state/auth.ts
|
|
1010
|
+
const grantOf = (credential) => credential.type === "token" ? {
|
|
1136
1011
|
type: "token",
|
|
1137
1012
|
refreshToken: credential.refreshToken
|
|
1138
1013
|
} : {
|
|
1139
1014
|
type: "cookie",
|
|
1140
1015
|
sessionId: credential.sessionId
|
|
1141
1016
|
};
|
|
1142
|
-
const
|
|
1143
|
-
...
|
|
1144
|
-
issuedAt: Date.now()
|
|
1145
|
-
});
|
|
1146
|
-
const stack = (baseUrl) => ({
|
|
1147
|
-
baseUrl,
|
|
1148
|
-
context: "idle",
|
|
1149
|
-
epoch: 0,
|
|
1150
|
-
auth: anonymousAuth(),
|
|
1151
|
-
retained: null
|
|
1152
|
-
});
|
|
1153
|
-
const project = (baseUrl, projectId) => ({
|
|
1154
|
-
id: projectEntryId(baseUrl, projectId),
|
|
1155
|
-
baseUrl,
|
|
1156
|
-
projectId,
|
|
1157
|
-
context: "idle"
|
|
1158
|
-
});
|
|
1159
|
-
const stackAddress = (baseUrl) => ({
|
|
1160
|
-
baseUrl,
|
|
1161
|
-
projectId: null
|
|
1162
|
-
});
|
|
1163
|
-
const projectAddress = (baseUrl, projectId) => ({
|
|
1164
|
-
baseUrl,
|
|
1165
|
-
projectId
|
|
1166
|
-
});
|
|
1167
|
-
const table = (defaultBaseUrl) => ({
|
|
1168
|
-
active: stackAddress(defaultBaseUrl),
|
|
1169
|
-
stacks: { [defaultBaseUrl]: stack(defaultBaseUrl) },
|
|
1170
|
-
projects: {}
|
|
1017
|
+
const stamped = (input) => ({
|
|
1018
|
+
...input,
|
|
1019
|
+
issuedAt: Date.now()
|
|
1171
1020
|
});
|
|
1172
|
-
const
|
|
1173
|
-
projectEntryId,
|
|
1174
|
-
isUnderStack,
|
|
1175
|
-
stack,
|
|
1176
|
-
project,
|
|
1177
|
-
stackAddress,
|
|
1178
|
-
projectAddress,
|
|
1179
|
-
table,
|
|
1180
|
-
anonymousAuth,
|
|
1181
|
-
restoringAuth,
|
|
1182
|
-
authenticatedAuth,
|
|
1183
|
-
credential,
|
|
1184
|
-
grant,
|
|
1185
|
-
expiredCredential
|
|
1186
|
-
};
|
|
1187
|
-
/**
|
|
1188
|
-
* Every failure the table can produce.
|
|
1189
|
-
*
|
|
1190
|
-
* - The typed ones carry a `KeboolaErrorType` a consumer branches on; the rest are plain `Error`s
|
|
1191
|
-
* whose message names the entry, because nothing branches on them.
|
|
1192
|
-
*/
|
|
1193
|
-
const Errors = {
|
|
1194
|
-
notAuthenticated: () => new KeboolaError(KeboolaErrorType.NotAuthenticated),
|
|
1195
|
-
stackActive: () => new KeboolaError(KeboolaErrorType.StackActive),
|
|
1196
|
-
/** A stack that was never opened — nothing has been configured for it. */
|
|
1197
|
-
unconfigured: () => new KeboolaError(KeboolaErrorType.Unconfigured),
|
|
1198
|
-
alreadyAuthenticated: () => new KeboolaError(KeboolaErrorType.AlreadyAuthenticated),
|
|
1199
|
-
notReady: () => new KeboolaError(KeboolaErrorType.NotReady),
|
|
1200
|
-
alreadyRestoring: (baseUrl) => /* @__PURE__ */ new Error(`Stack "${baseUrl}" is already being restored`),
|
|
1201
|
-
notRestoring: (baseUrl) => /* @__PURE__ */ new Error(`Stack "${baseUrl}" is not being restored`),
|
|
1202
|
-
grantTypeChanged: (from, to) => /* @__PURE__ */ new Error(`A ${from} grant cannot become ${to}`),
|
|
1203
|
-
nothingRetained: (baseUrl) => /* @__PURE__ */ new Error(`Stack "${baseUrl}" retains no credential`),
|
|
1204
|
-
missingProject: (id) => /* @__PURE__ */ new Error(`No project "${id}"`)
|
|
1205
|
-
};
|
|
1206
|
-
const authenticated = (auth) => auth.status === "authenticated" ? Result.success(auth.credential) : Result.failure(Errors.notAuthenticated());
|
|
1207
|
-
//#endregion
|
|
1208
|
-
//#region src/keboola/bearer/state/auth.ts
|
|
1209
|
-
/**
|
|
1210
|
-
* Fire-once per sign-in: the first report of a dead credential returns `true`, the rest `false`,
|
|
1211
|
-
* and `authenticate` re-arms it. Held beside the table because it is not state anyone restores.
|
|
1212
|
-
*/
|
|
1213
|
-
const createExpiryLatch = () => {
|
|
1214
|
-
const notified = /* @__PURE__ */ new Map();
|
|
1215
|
-
return {
|
|
1216
|
-
arm: (baseUrl) => notified.set(baseUrl, false),
|
|
1217
|
-
forget: (baseUrl) => notified.delete(baseUrl),
|
|
1218
|
-
report: (baseUrl) => {
|
|
1219
|
-
if (notified.get(baseUrl)) return false;
|
|
1220
|
-
notified.set(baseUrl, true);
|
|
1221
|
-
return true;
|
|
1222
|
-
}
|
|
1223
|
-
};
|
|
1224
|
-
};
|
|
1021
|
+
const credentialOf = (auth) => auth.status === "authenticated" ? Result.success(auth.credential) : Result.failure(new KeboolaError(KeboolaErrorType.NotAuthenticated));
|
|
1225
1022
|
/**
|
|
1226
1023
|
* The stack's credential and its sign-in pin.
|
|
1227
1024
|
*
|
|
1228
1025
|
* - `epoch` moves on `authenticate` and `signOut` and never on a rotation, so it is exactly "which
|
|
1229
1026
|
* sign-in is this" — what an in-flight exchange compares itself against.
|
|
1230
1027
|
*/
|
|
1231
|
-
const createAuth = (
|
|
1232
|
-
const
|
|
1233
|
-
const
|
|
1234
|
-
const
|
|
1028
|
+
const createAuth = (stacks) => {
|
|
1029
|
+
const expired = /* @__PURE__ */ new Set();
|
|
1030
|
+
const requireCredential = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => credentialOf(stack.auth));
|
|
1031
|
+
const requireUnauthenticated = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.auth.status === "authenticated" ? Result.failure(new KeboolaError(KeboolaErrorType.AlreadyAuthenticated)) : Result.success(stack));
|
|
1032
|
+
const requireAnonymous = (baseUrl) => Result.andThen(requireUnauthenticated(baseUrl), (stack) => stack.auth.status === "restoring" ? Result.failure(/* @__PURE__ */ new Error(`Stack "${baseUrl}" is already being restored`)) : Result.success(stack));
|
|
1033
|
+
const requireRestoring = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.auth.status === "restoring" ? Result.success(stack) : Result.failure(/* @__PURE__ */ new Error(`Stack "${baseUrl}" is not being restored`)));
|
|
1235
1034
|
const startRestore = (baseUrl) => Result.map(requireAnonymous(baseUrl), (stack) => stacks.set({
|
|
1236
1035
|
...stack,
|
|
1237
|
-
auth:
|
|
1036
|
+
auth: { status: "restoring" }
|
|
1238
1037
|
}));
|
|
1239
1038
|
const cancelRestore = (baseUrl) => Result.map(requireRestoring(baseUrl), (stack) => stacks.set({
|
|
1240
1039
|
...stack,
|
|
1241
|
-
auth:
|
|
1040
|
+
auth: { status: "anonymous" }
|
|
1242
1041
|
}));
|
|
1243
1042
|
const authenticate = (baseUrl, input) => Result.map(requireUnauthenticated(baseUrl), (stack) => {
|
|
1244
|
-
|
|
1043
|
+
expired.delete(baseUrl);
|
|
1245
1044
|
return stacks.set({
|
|
1246
1045
|
...stack,
|
|
1247
1046
|
epoch: stack.epoch + 1,
|
|
1248
|
-
auth:
|
|
1047
|
+
auth: {
|
|
1048
|
+
status: "authenticated",
|
|
1049
|
+
credential: stamped(input)
|
|
1050
|
+
},
|
|
1249
1051
|
retained: null
|
|
1250
1052
|
});
|
|
1251
1053
|
});
|
|
1252
|
-
const applyRefresh = (baseUrl, input) => Result.andThen(
|
|
1054
|
+
const applyRefresh = (baseUrl, input) => Result.andThen(requireCredential(baseUrl), (credential) => credential.type !== input.type ? Result.failure(/* @__PURE__ */ new Error(`A ${credential.type} grant cannot become ${input.type}`)) : Result.map(stacks.get(baseUrl), (stack) => stacks.set({
|
|
1253
1055
|
...stack,
|
|
1254
|
-
auth:
|
|
1056
|
+
auth: {
|
|
1057
|
+
status: "authenticated",
|
|
1058
|
+
credential: stamped(input)
|
|
1059
|
+
}
|
|
1255
1060
|
})));
|
|
1256
|
-
const forceExpire = (baseUrl) => Result.andThen(
|
|
1061
|
+
const forceExpire = (baseUrl) => Result.andThen(requireCredential(baseUrl), (credential) => Result.map(stacks.get(baseUrl), (stack) => stacks.set({
|
|
1257
1062
|
...stack,
|
|
1258
|
-
auth:
|
|
1063
|
+
auth: {
|
|
1064
|
+
status: "authenticated",
|
|
1065
|
+
credential: {
|
|
1066
|
+
...credential,
|
|
1067
|
+
issuedAt: Date.now() - credential.expiresIn * 1e3
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1259
1070
|
})));
|
|
1260
1071
|
const signOut = (baseUrl, { retain = false } = {}) => Result.map(stacks.get(baseUrl), (stack) => {
|
|
1261
|
-
|
|
1262
|
-
const retained = retain ? Result.unwrapOr(Result.map(authenticated(stack.auth), (credential) => ({ grant: Entry.grant(credential) })), stack.retained) : null;
|
|
1072
|
+
const retained = retain ? Result.unwrapOr(Result.map(credentialOf(stack.auth), (credential) => ({ grant: grantOf(credential) })), stack.retained) : null;
|
|
1263
1073
|
return stacks.set({
|
|
1264
1074
|
...stack,
|
|
1265
1075
|
epoch: stack.epoch + 1,
|
|
1266
|
-
auth:
|
|
1076
|
+
auth: { status: "anonymous" },
|
|
1267
1077
|
retained
|
|
1268
1078
|
});
|
|
1269
1079
|
});
|
|
@@ -1275,9 +1085,14 @@ const createAuth = ({ stacks, projects, expiry }) => {
|
|
|
1275
1085
|
...stack,
|
|
1276
1086
|
retained: null
|
|
1277
1087
|
}));
|
|
1278
|
-
const requireRetained = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.retained ? Result.success(stack.retained) : Result.failure(
|
|
1088
|
+
const requireRetained = (baseUrl) => Result.andThen(stacks.get(baseUrl), (stack) => stack.retained ? Result.success(stack.retained) : Result.failure(/* @__PURE__ */ new Error(`Stack "${baseUrl}" retains no credential`)));
|
|
1089
|
+
const notifyExpired = (baseUrl) => {
|
|
1090
|
+
if (expired.has(baseUrl)) return false;
|
|
1091
|
+
expired.add(baseUrl);
|
|
1092
|
+
return true;
|
|
1093
|
+
};
|
|
1279
1094
|
const getEpoch = (baseUrl) => Result.map(stacks.get(baseUrl), (stack) => stack.epoch);
|
|
1280
|
-
const getAccessToken = (baseUrl) => Result.unwrapOr(Result.map(
|
|
1095
|
+
const getAccessToken = (baseUrl) => Result.unwrapOr(Result.map(requireCredential(baseUrl), ({ accessToken }) => accessToken), null);
|
|
1281
1096
|
return {
|
|
1282
1097
|
startRestore,
|
|
1283
1098
|
cancelRestore,
|
|
@@ -1288,171 +1103,26 @@ const createAuth = ({ stacks, projects, expiry }) => {
|
|
|
1288
1103
|
retain,
|
|
1289
1104
|
dropRetained,
|
|
1290
1105
|
requireRetained,
|
|
1291
|
-
notifyExpired
|
|
1292
|
-
requireCredential
|
|
1106
|
+
notifyExpired,
|
|
1107
|
+
requireCredential,
|
|
1293
1108
|
getEpoch,
|
|
1294
1109
|
getAccessToken
|
|
1295
1110
|
};
|
|
1296
1111
|
};
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
/** Every open project with this id, whatever stack it sits on — a project number is not unique. */
|
|
1308
|
-
const findAll = (projectId) => Object.values(store.get().projects).filter((project) => project.projectId === projectId);
|
|
1309
|
-
const set = (project) => {
|
|
1310
|
-
const state = store.get();
|
|
1311
|
-
store.set({
|
|
1312
|
-
...state,
|
|
1313
|
-
projects: {
|
|
1314
|
-
...state.projects,
|
|
1315
|
-
[project.id]: project
|
|
1316
|
-
}
|
|
1317
|
-
});
|
|
1318
|
-
return project;
|
|
1319
|
-
};
|
|
1320
|
-
const update = (id, updater) => Result.map(get(id), (project) => set(updater(project)));
|
|
1321
|
-
const removeMany = (ids, nextActive) => {
|
|
1322
|
-
const state = store.get();
|
|
1323
|
-
const projects = { ...state.projects };
|
|
1324
|
-
for (const id of ids) delete projects[id];
|
|
1325
|
-
store.set({
|
|
1326
|
-
...state,
|
|
1327
|
-
active: nextActive,
|
|
1328
|
-
projects
|
|
1329
|
-
});
|
|
1330
|
-
};
|
|
1331
|
-
const requireCredential = (id) => Result.andThen(get(id), (project) => stacks.requireCredential(project.baseUrl));
|
|
1332
|
-
const open = (baseUrl, projectId) => {
|
|
1333
|
-
const id = Entry.projectEntryId(baseUrl, projectId);
|
|
1334
|
-
if (has(id)) return get(id);
|
|
1335
|
-
return Result.map(stacks.requireCredential(baseUrl), () => set(Entry.project(baseUrl, projectId)));
|
|
1336
|
-
};
|
|
1337
|
-
const close = (id) => Result.tap(get(id), ({ baseUrl, projectId }) => {
|
|
1338
|
-
const { active } = store.get();
|
|
1339
|
-
const isScoped = active.baseUrl === baseUrl && active.projectId === projectId;
|
|
1340
|
-
removeMany([id], isScoped ? Entry.stackAddress(baseUrl) : active);
|
|
1341
|
-
});
|
|
1342
|
-
/** Every project under a stack, with the scope falling back to the stack itself. */
|
|
1343
|
-
const closeAll = (baseUrl) => {
|
|
1344
|
-
const ids = list(baseUrl).map((project) => project.id);
|
|
1345
|
-
const { active } = store.get();
|
|
1346
|
-
removeMany(ids, active.baseUrl === baseUrl ? Entry.stackAddress(baseUrl) : active);
|
|
1347
|
-
};
|
|
1348
|
-
const updateContext = (id, context) => update(id, (project) => ({
|
|
1349
|
-
...project,
|
|
1350
|
-
context
|
|
1351
|
-
}));
|
|
1352
|
-
return {
|
|
1353
|
-
has,
|
|
1354
|
-
get,
|
|
1355
|
-
list,
|
|
1356
|
-
findAll,
|
|
1357
|
-
set,
|
|
1358
|
-
update,
|
|
1359
|
-
open,
|
|
1360
|
-
close,
|
|
1361
|
-
closeAll,
|
|
1362
|
-
updateContext,
|
|
1363
|
-
requireCredential
|
|
1364
|
-
};
|
|
1365
|
-
};
|
|
1366
|
-
//#endregion
|
|
1367
|
-
//#region src/keboola/bearer/state/scope.ts
|
|
1368
|
-
/**
|
|
1369
|
-
* What `api.*` addresses: the `active` slot, and the address in it resolved against the tables it
|
|
1370
|
-
* points into.
|
|
1371
|
-
*
|
|
1372
|
-
* The tables never write here — they read `active` through the pure helpers in `address.ts`, so
|
|
1373
|
-
* that this can depend on them rather than the other way round.
|
|
1374
|
-
*/
|
|
1375
|
-
const createScope = ({ store, stacks, projects }) => {
|
|
1376
|
-
const get = () => store.get().active;
|
|
1377
|
-
const isSame = (a, b) => a === b || a.baseUrl === b.baseUrl && a.projectId === b.projectId;
|
|
1378
|
-
const set = (active) => {
|
|
1379
|
-
if (isSame(store.get().active, active)) return;
|
|
1380
|
-
store.set({
|
|
1381
|
-
...store.get(),
|
|
1382
|
-
active
|
|
1383
|
-
});
|
|
1384
|
-
};
|
|
1385
|
-
const locate = (active) => {
|
|
1386
|
-
const stack = stacks.get(active.baseUrl);
|
|
1387
|
-
if (!stack.success) return null;
|
|
1388
|
-
if (active.projectId === null) return {
|
|
1389
|
-
stack: stack.data,
|
|
1390
|
-
project: null
|
|
1391
|
-
};
|
|
1392
|
-
const project = projects.get(Entry.projectEntryId(active.baseUrl, active.projectId));
|
|
1393
|
-
if (!project.success) return null;
|
|
1394
|
-
return {
|
|
1395
|
-
stack: stack.data,
|
|
1396
|
-
project: project.data
|
|
1397
|
-
};
|
|
1398
|
-
};
|
|
1399
|
-
const getActive = () => {
|
|
1400
|
-
const location = locate(get());
|
|
1401
|
-
if (!location) throw new Error(`The scope names no row: ${JSON.stringify(get())}`);
|
|
1402
|
-
return location;
|
|
1403
|
-
};
|
|
1404
|
-
const getActiveStack = () => getActive().stack;
|
|
1405
|
-
const activateStack = (baseUrl) => Result.map(stacks.get(baseUrl), (stack) => {
|
|
1406
|
-
const next = Entry.stackAddress(stack.baseUrl);
|
|
1407
|
-
set(next);
|
|
1408
|
-
return next;
|
|
1409
|
-
});
|
|
1410
|
-
const activateProject = (baseUrl, projectId) => Result.map(projects.requireCredential(Entry.projectEntryId(baseUrl, projectId)), () => {
|
|
1411
|
-
const next = Entry.projectAddress(baseUrl, projectId);
|
|
1412
|
-
set(next);
|
|
1413
|
-
return next;
|
|
1414
|
-
});
|
|
1415
|
-
const selectStack = (baseUrl) => {
|
|
1416
|
-
const stack = stacks.ensure(baseUrl);
|
|
1417
|
-
return Result.map(activateStack(stack.baseUrl), () => stack);
|
|
1418
|
-
};
|
|
1419
|
-
const selectProject = (projectId) => {
|
|
1420
|
-
const { baseUrl } = getActiveStack();
|
|
1421
|
-
const project = projects.open(baseUrl, projectId);
|
|
1422
|
-
if (!project.success) return project;
|
|
1423
|
-
return Result.map(activateProject(baseUrl, projectId), () => project.data);
|
|
1424
|
-
};
|
|
1425
|
-
const deactivate = () => {
|
|
1426
|
-
const active = get();
|
|
1427
|
-
if (active.projectId === null) return;
|
|
1428
|
-
set(Entry.stackAddress(active.baseUrl));
|
|
1429
|
-
};
|
|
1430
|
-
const requireActiveProject = () => {
|
|
1431
|
-
const { project } = getActive();
|
|
1432
|
-
return project ? Result.success(project) : Result.failure(Errors.notReady());
|
|
1433
|
-
};
|
|
1434
|
-
return {
|
|
1435
|
-
get,
|
|
1436
|
-
getActive,
|
|
1437
|
-
activateStack,
|
|
1438
|
-
activateProject,
|
|
1439
|
-
selectStack,
|
|
1440
|
-
selectProject,
|
|
1441
|
-
deactivate,
|
|
1442
|
-
getActiveStack,
|
|
1443
|
-
requireActiveProject
|
|
1444
|
-
};
|
|
1445
|
-
};
|
|
1446
|
-
//#endregion
|
|
1447
|
-
//#region src/keboola/bearer/state/stacks.ts
|
|
1448
|
-
/** One entry per stack: the entries, and the verbs that open and close them. */
|
|
1449
|
-
const createStacks = ({ store, forgetExpiry }) => {
|
|
1450
|
-
const has = (baseUrl) => baseUrl in store.get().stacks;
|
|
1112
|
+
// src/keboola/bearer/state/stacks.ts
|
|
1113
|
+
const newStack = (baseUrl) => ({
|
|
1114
|
+
baseUrl,
|
|
1115
|
+
context: "idle",
|
|
1116
|
+
epoch: 0,
|
|
1117
|
+
auth: { status: "anonymous" },
|
|
1118
|
+
retained: null
|
|
1119
|
+
});
|
|
1120
|
+
/** One entry per stack, and the verbs that open and select them. */
|
|
1121
|
+
const createStacks = (store) => {
|
|
1451
1122
|
const get = (baseUrl) => {
|
|
1452
1123
|
const stack = store.get().stacks[baseUrl];
|
|
1453
|
-
return stack ? Result.success(stack) : Result.failure(
|
|
1124
|
+
return stack ? Result.success(stack) : Result.failure(new KeboolaError(KeboolaErrorType.Unconfigured));
|
|
1454
1125
|
};
|
|
1455
|
-
const list = () => Object.values(store.get().stacks);
|
|
1456
1126
|
const set = (stack) => {
|
|
1457
1127
|
const state = store.get();
|
|
1458
1128
|
store.set({
|
|
@@ -1465,26 +1135,24 @@ const createStacks = ({ store, forgetExpiry }) => {
|
|
|
1465
1135
|
return stack;
|
|
1466
1136
|
};
|
|
1467
1137
|
const update = (baseUrl, updater) => Result.map(get(baseUrl), (stack) => set(updater(stack)));
|
|
1468
|
-
const requireCredential = (baseUrl) => Result.andThen(get(baseUrl), (stack) => authenticated(stack.auth));
|
|
1469
1138
|
const ensure = (baseUrl) => {
|
|
1470
1139
|
const existing = get(baseUrl);
|
|
1471
1140
|
if (existing.success) return existing.data;
|
|
1472
|
-
return set(
|
|
1141
|
+
return set(newStack(baseUrl));
|
|
1142
|
+
};
|
|
1143
|
+
const getActive = () => {
|
|
1144
|
+
const { active } = store.get();
|
|
1145
|
+
const stack = get(active);
|
|
1146
|
+
if (!stack.success) throw new Error(`The active stack has no row: ${active}`);
|
|
1147
|
+
return stack.data;
|
|
1473
1148
|
};
|
|
1474
|
-
const
|
|
1475
|
-
const stack =
|
|
1476
|
-
if (!stack.success) return stack;
|
|
1149
|
+
const select = (baseUrl) => {
|
|
1150
|
+
const stack = ensure(baseUrl);
|
|
1477
1151
|
const state = store.get();
|
|
1478
|
-
if (state.active
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
const projects = Object.fromEntries(Object.entries(state.projects).filter(([, project]) => project.baseUrl !== baseUrl));
|
|
1482
|
-
store.set({
|
|
1483
|
-
active: state.active,
|
|
1484
|
-
stacks,
|
|
1485
|
-
projects
|
|
1152
|
+
if (state.active !== baseUrl) store.set({
|
|
1153
|
+
...state,
|
|
1154
|
+
active: baseUrl
|
|
1486
1155
|
});
|
|
1487
|
-
forgetExpiry(baseUrl);
|
|
1488
1156
|
return stack;
|
|
1489
1157
|
};
|
|
1490
1158
|
const updateContext = (baseUrl, context) => update(baseUrl, (stack) => ({
|
|
@@ -1492,56 +1160,42 @@ const createStacks = ({ store, forgetExpiry }) => {
|
|
|
1492
1160
|
context
|
|
1493
1161
|
}));
|
|
1494
1162
|
return {
|
|
1495
|
-
has,
|
|
1496
1163
|
get,
|
|
1497
|
-
list,
|
|
1498
1164
|
set,
|
|
1499
1165
|
update,
|
|
1500
1166
|
ensure,
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1167
|
+
getActive,
|
|
1168
|
+
select,
|
|
1169
|
+
updateContext
|
|
1504
1170
|
};
|
|
1505
1171
|
};
|
|
1506
|
-
|
|
1507
|
-
//#region src/keboola/bearer/state/state.ts
|
|
1172
|
+
// src/keboola/bearer/state/state.ts
|
|
1508
1173
|
/**
|
|
1509
1174
|
* The stack table and the rules over it, one namespace per concern.
|
|
1510
1175
|
*
|
|
1511
|
-
* -
|
|
1512
|
-
* the active address against both tables.
|
|
1176
|
+
* - Starts active on its default stack, which is its one row.
|
|
1513
1177
|
*/
|
|
1514
1178
|
const createState = (defaultBaseUrl) => {
|
|
1515
|
-
const store = createStore(
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
store,
|
|
1519
|
-
forgetExpiry: expiry.forget
|
|
1520
|
-
});
|
|
1521
|
-
const projects = createProjects({
|
|
1522
|
-
store,
|
|
1523
|
-
stacks
|
|
1524
|
-
});
|
|
1525
|
-
const scope = createScope({
|
|
1526
|
-
store,
|
|
1527
|
-
stacks,
|
|
1528
|
-
projects
|
|
1529
|
-
});
|
|
1530
|
-
const auth = createAuth({
|
|
1531
|
-
stacks,
|
|
1532
|
-
projects,
|
|
1533
|
-
expiry
|
|
1179
|
+
const store = createStore({
|
|
1180
|
+
active: defaultBaseUrl,
|
|
1181
|
+
stacks: { [defaultBaseUrl]: newStack(defaultBaseUrl) }
|
|
1534
1182
|
});
|
|
1183
|
+
const stacks = createStacks(store);
|
|
1184
|
+
const auth = createAuth(stacks);
|
|
1535
1185
|
return {
|
|
1536
1186
|
store: store.asReadable(),
|
|
1537
1187
|
stacks,
|
|
1538
|
-
|
|
1539
|
-
auth,
|
|
1540
|
-
scope
|
|
1188
|
+
auth
|
|
1541
1189
|
};
|
|
1542
1190
|
};
|
|
1543
|
-
|
|
1544
|
-
|
|
1191
|
+
// src/keboola/bearer/credentials/credentials.ts
|
|
1192
|
+
const DEFAULT_REFRESH_THRESHOLD = .9;
|
|
1193
|
+
const signInEnded = () => new KeboolaError(KeboolaErrorType.SignInEnded);
|
|
1194
|
+
const toRestoreStatus = (outcome) => {
|
|
1195
|
+
if (outcome === void 0 || outcome === "skipped") return "empty";
|
|
1196
|
+
if (outcome === "refused") return "expired";
|
|
1197
|
+
return outcome;
|
|
1198
|
+
};
|
|
1545
1199
|
const renew = async (client, grant) => {
|
|
1546
1200
|
if (grant.type === "cookie") {
|
|
1547
1201
|
const { accessToken, expiresIn, sessionId } = await client.token.refreshWithSession({ sessionId: grant.sessionId });
|
|
@@ -1561,55 +1215,29 @@ const renew = async (client, grant) => {
|
|
|
1561
1215
|
refreshToken
|
|
1562
1216
|
};
|
|
1563
1217
|
};
|
|
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
1218
|
const createCredentials = ({ state, persistor, middlewares, refreshThreshold = DEFAULT_REFRESH_THRESHOLD, onSignedOut, onExpired }) => {
|
|
1574
1219
|
const rotationMap = /* @__PURE__ */ new Map();
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1220
|
+
const markSignIn = (baseUrl) => {
|
|
1221
|
+
const epoch = Result.unwrap(state.auth.getEpoch(baseUrl));
|
|
1222
|
+
return () => Result.unwrapOr(state.auth.getEpoch(baseUrl), -1) === epoch;
|
|
1223
|
+
};
|
|
1577
1224
|
const refresh = async (baseUrl, grant) => {
|
|
1578
1225
|
const client = createAuthClient({
|
|
1579
1226
|
baseUrl,
|
|
1580
1227
|
middlewares
|
|
1581
1228
|
});
|
|
1582
|
-
const
|
|
1583
|
-
const generationBefore = generationOf(baseUrl);
|
|
1229
|
+
const isSameSignIn = markSignIn(baseUrl);
|
|
1584
1230
|
const refreshed = await Result.tryCatchAsync(() => renew(client, grant));
|
|
1585
|
-
return
|
|
1231
|
+
return isSameSignIn() ? refreshed : Result.failure(signInEnded());
|
|
1586
1232
|
};
|
|
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
1233
|
const getGrantForRotation = async (store, baseUrl, credential) => {
|
|
1605
|
-
const
|
|
1606
|
-
const generationBefore = generationOf(baseUrl);
|
|
1234
|
+
const isSameSignIn = markSignIn(baseUrl);
|
|
1607
1235
|
const hydrated = await Result.tryCatchAsync(() => store.read());
|
|
1608
1236
|
if (!hydrated.success) return hydrated;
|
|
1609
|
-
if (
|
|
1237
|
+
if (!isSameSignIn()) return Result.failure(signInEnded());
|
|
1610
1238
|
const persistedStack = hydrated.data.stacks.find((stack) => stack.baseUrl === baseUrl);
|
|
1611
1239
|
if (persistedStack && persistedStack.credential === null) return Result.failure(signInEnded());
|
|
1612
|
-
return Result.success(persistedStack?.credential ??
|
|
1240
|
+
return Result.success(persistedStack?.credential ?? grantOf(credential));
|
|
1613
1241
|
};
|
|
1614
1242
|
const rotateOnce = async (baseUrl) => persistor.locked(async (store) => {
|
|
1615
1243
|
const credential = state.auth.requireCredential(baseUrl);
|
|
@@ -1647,17 +1275,6 @@ const createCredentials = ({ state, persistor, middlewares, refreshThreshold = D
|
|
|
1647
1275
|
await store.persistStack(baseUrl, state.store.get());
|
|
1648
1276
|
return "restored";
|
|
1649
1277
|
});
|
|
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
1278
|
const restore = async () => {
|
|
1662
1279
|
const hydrated = await persistor.locked((store) => store.read()).catch((error) => {
|
|
1663
1280
|
console.warn("createCredentials: the stored session could not be read", error);
|
|
@@ -1669,15 +1286,13 @@ const createCredentials = ({ state, persistor, middlewares, refreshThreshold = D
|
|
|
1669
1286
|
};
|
|
1670
1287
|
const { stacks, current } = hydrated;
|
|
1671
1288
|
const scoped = stacks.find(({ baseUrl }) => baseUrl === current?.baseUrl);
|
|
1672
|
-
const restored = stacks.map(async ({ baseUrl, credential, retained
|
|
1289
|
+
const restored = stacks.map(async ({ baseUrl, credential, retained }) => {
|
|
1673
1290
|
state.stacks.ensure(baseUrl);
|
|
1674
1291
|
if (!credential && !retained) return "unreachable";
|
|
1675
1292
|
if (Result.unwrapOr(state.auth.getEpoch(baseUrl), 0) > 0) return "skipped";
|
|
1676
1293
|
if (retained) state.auth.retain(baseUrl, retained);
|
|
1677
1294
|
if (!credential) return "unreachable";
|
|
1678
|
-
|
|
1679
|
-
if (outcome === "restored") restoreProjects(baseUrl, projects);
|
|
1680
|
-
return outcome;
|
|
1295
|
+
return restoreStack(baseUrl, credential);
|
|
1681
1296
|
});
|
|
1682
1297
|
const results = await Promise.all(restored);
|
|
1683
1298
|
const scopedOutcome = scoped?.credential ? results[stacks.indexOf(scoped)] : void 0;
|
|
@@ -1686,23 +1301,12 @@ const createCredentials = ({ state, persistor, middlewares, refreshThreshold = D
|
|
|
1686
1301
|
status: toRestoreStatus(scopedOutcome)
|
|
1687
1302
|
};
|
|
1688
1303
|
};
|
|
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
1304
|
const restoreRetained = async (baseUrl) => {
|
|
1696
1305
|
const { grant } = Result.unwrap(state.auth.requireRetained(baseUrl));
|
|
1697
1306
|
return restoreStack(baseUrl, grant, true);
|
|
1698
1307
|
};
|
|
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
1308
|
/**
|
|
1704
|
-
* Drops the
|
|
1705
|
-
*
|
|
1309
|
+
* - Drops the rotation, so the next sign-in's requests don't join the dying one.
|
|
1706
1310
|
* - Writes nothing: the caller persists the stack, under the lock it holds or takes.
|
|
1707
1311
|
*/
|
|
1708
1312
|
const signOut = (baseUrl, options) => {
|
|
@@ -1718,7 +1322,8 @@ const createCredentials = ({ state, persistor, middlewares, refreshThreshold = D
|
|
|
1718
1322
|
onExpired?.(baseUrl);
|
|
1719
1323
|
};
|
|
1720
1324
|
const renewIfStale = async (baseUrl) => {
|
|
1721
|
-
|
|
1325
|
+
const isStale = Result.map(state.auth.requireCredential(baseUrl), ({ issuedAt, expiresIn }) => Date.now() >= issuedAt + expiresIn * 1e3 * refreshThreshold);
|
|
1326
|
+
if (Result.unwrapOr(isStale, false)) await rotate(baseUrl);
|
|
1722
1327
|
};
|
|
1723
1328
|
const middleware = (baseUrl) => createBearerAuthMiddleware({ getAccessToken: async ({ forceRefresh = false } = {}) => {
|
|
1724
1329
|
if (forceRefresh) {
|
|
@@ -1734,187 +1339,18 @@ const createCredentials = ({ state, persistor, middlewares, refreshThreshold = D
|
|
|
1734
1339
|
renewIfStale,
|
|
1735
1340
|
restore,
|
|
1736
1341
|
restoreRetained,
|
|
1737
|
-
signOut
|
|
1738
|
-
forget
|
|
1342
|
+
signOut
|
|
1739
1343
|
};
|
|
1740
1344
|
};
|
|
1741
|
-
|
|
1742
|
-
|
|
1345
|
+
// src/keboola/bearer/perProject.ts
|
|
1346
|
+
const projectKey = ({ baseUrl, projectId }) => `${baseUrl}#${projectId}`;
|
|
1743
1347
|
/**
|
|
1744
|
-
*
|
|
1745
|
-
* request. Backs the stack and project contexts.
|
|
1348
|
+
* One handle per project, and the one call that drops it.
|
|
1746
1349
|
*
|
|
1747
|
-
*
|
|
1748
|
-
*
|
|
1749
|
-
* - Status lives here and nowhere else; a consumer that has to mirror it subscribes.
|
|
1350
|
+
* Every client belongs to the credential that built it — a client set carries its middleware
|
|
1351
|
+
* chain — so the handle dies with the sign-in, and `forgetUnder` is the only thing that ends one.
|
|
1750
1352
|
*/
|
|
1751
|
-
const
|
|
1752
|
-
const entries = /* @__PURE__ */ new Map();
|
|
1753
|
-
const changes = createEmitter();
|
|
1754
|
-
const set = (id, entry) => {
|
|
1755
|
-
entries.set(id, entry);
|
|
1756
|
-
changes.emit({
|
|
1757
|
-
key: id,
|
|
1758
|
-
status: entry.status
|
|
1759
|
-
});
|
|
1760
|
-
};
|
|
1761
|
-
const run = (id, input) => {
|
|
1762
|
-
const settle = (next) => {
|
|
1763
|
-
if (entries.get(id) === entry) set(id, {
|
|
1764
|
-
input,
|
|
1765
|
-
...next
|
|
1766
|
-
});
|
|
1767
|
-
return next;
|
|
1768
|
-
};
|
|
1769
|
-
const attempt = async () => await fetch(input);
|
|
1770
|
-
const entry = {
|
|
1771
|
-
input,
|
|
1772
|
-
status: "pending",
|
|
1773
|
-
settled: attempt().then((value) => settle({
|
|
1774
|
-
status: "ready",
|
|
1775
|
-
value
|
|
1776
|
-
}), (error) => settle({
|
|
1777
|
-
status: "errored",
|
|
1778
|
-
error
|
|
1779
|
-
}))
|
|
1780
|
-
};
|
|
1781
|
-
set(id, entry);
|
|
1782
|
-
return entry;
|
|
1783
|
-
};
|
|
1784
|
-
const get = (id) => {
|
|
1785
|
-
const entry = entries.get(id);
|
|
1786
|
-
return entry?.status === "ready" ? entry.value : null;
|
|
1787
|
-
};
|
|
1788
|
-
const getAsync = async (input) => {
|
|
1789
|
-
const id = key(input);
|
|
1790
|
-
const cached = entries.get(id);
|
|
1791
|
-
const entry = cached === void 0 || cached.status === "errored" ? run(id, input) : cached;
|
|
1792
|
-
const settled = entry.status === "pending" ? await entry.settled : entry;
|
|
1793
|
-
if (settled.status === "errored") throw settled.error;
|
|
1794
|
-
return settled.value;
|
|
1795
|
-
};
|
|
1796
|
-
const forget = (matches) => {
|
|
1797
|
-
for (const id of entries.keys()) if (matches(id)) entries.delete(id);
|
|
1798
|
-
};
|
|
1799
|
-
const prefetch = (input) => {
|
|
1800
|
-
const id = key(input);
|
|
1801
|
-
if (!entries.has(id)) run(id, input);
|
|
1802
|
-
};
|
|
1803
|
-
const retry = (id) => {
|
|
1804
|
-
const entry = entries.get(id);
|
|
1805
|
-
if (entry !== void 0) run(id, entry.input);
|
|
1806
|
-
};
|
|
1807
|
-
return {
|
|
1808
|
-
get,
|
|
1809
|
-
getAsync,
|
|
1810
|
-
prefetch,
|
|
1811
|
-
retry,
|
|
1812
|
-
forget,
|
|
1813
|
-
subscribe: changes.subscribe
|
|
1814
|
-
};
|
|
1815
|
-
};
|
|
1816
|
-
//#endregion
|
|
1817
|
-
//#region src/keboola/bearer/context/project.ts
|
|
1818
|
-
const createProjectContext = ({ state, credentials, stackContext }) => {
|
|
1819
|
-
const resource = createResource({
|
|
1820
|
-
key: (project) => project.id,
|
|
1821
|
-
fetch: async ({ baseUrl, projectId }) => {
|
|
1822
|
-
const withProjectId = (next) => (request) => {
|
|
1823
|
-
request.request.headers.set(KeboolaHttpHeader.PROJECT_ID, String(projectId));
|
|
1824
|
-
return next(request);
|
|
1825
|
-
};
|
|
1826
|
-
const client = createStorageClient({
|
|
1827
|
-
baseUrl,
|
|
1828
|
-
auth: {
|
|
1829
|
-
type: "bearer",
|
|
1830
|
-
token: "",
|
|
1831
|
-
projectId
|
|
1832
|
-
},
|
|
1833
|
-
middlewares: [(next) => withProjectId(credentials.middleware(baseUrl)(next))]
|
|
1834
|
-
});
|
|
1835
|
-
const [token, devBranches] = await Promise.all([
|
|
1836
|
-
client.tokens.verify(),
|
|
1837
|
-
client.branches.getDevBranches(),
|
|
1838
|
-
stackContext.getAsync(baseUrl)
|
|
1839
|
-
]);
|
|
1840
|
-
return {
|
|
1841
|
-
token,
|
|
1842
|
-
defaultBranch: createDefaultBranch({ devBranches })
|
|
1843
|
-
};
|
|
1844
|
-
}
|
|
1845
|
-
});
|
|
1846
|
-
resource.subscribe(({ key, status }) => {
|
|
1847
|
-
state.projects.updateContext(key, status);
|
|
1848
|
-
});
|
|
1849
|
-
const subscriber = ({ projects }) => {
|
|
1850
|
-
for (const project of Object.values(projects)) resource.prefetch(project);
|
|
1851
|
-
};
|
|
1852
|
-
/**
|
|
1853
|
-
* Dropped with the sign-in that fetched them: a verified token is what a credential answered
|
|
1854
|
-
* for, so it belongs to that credential and not to the project id it was keyed by.
|
|
1855
|
-
*/
|
|
1856
|
-
const forgetUnder = (baseUrl) => resource.forget(Entry.isUnderStack(baseUrl));
|
|
1857
|
-
/** One project, closed on purpose. */
|
|
1858
|
-
const forget = (id) => resource.forget((key) => key === id);
|
|
1859
|
-
return {
|
|
1860
|
-
subscriber,
|
|
1861
|
-
get: resource.get,
|
|
1862
|
-
getAsync: resource.getAsync,
|
|
1863
|
-
retry: resource.retry,
|
|
1864
|
-
forget,
|
|
1865
|
-
forgetUnder
|
|
1866
|
-
};
|
|
1867
|
-
};
|
|
1868
|
-
//#endregion
|
|
1869
|
-
//#region src/keboola/bearer/context/stack.ts
|
|
1870
|
-
const STACK_INDEX_TIMEOUT_MS = 3e4;
|
|
1871
|
-
const createStackContext = (state) => {
|
|
1872
|
-
const resource = createResource({
|
|
1873
|
-
key: (baseUrl) => baseUrl,
|
|
1874
|
-
fetch: (baseUrl) => createStorageClient({
|
|
1875
|
-
baseUrl,
|
|
1876
|
-
auth: {
|
|
1877
|
-
type: "sapi-token",
|
|
1878
|
-
token: ""
|
|
1879
|
-
}
|
|
1880
|
-
}).getStackInfo({ exclude: "componentDetails" }, AbortSignal.timeout(STACK_INDEX_TIMEOUT_MS))
|
|
1881
|
-
});
|
|
1882
|
-
resource.subscribe(({ key, status }) => {
|
|
1883
|
-
state.stacks.updateContext(key, status);
|
|
1884
|
-
});
|
|
1885
|
-
const subscriber = ({ stacks }) => {
|
|
1886
|
-
for (const { baseUrl } of Object.values(stacks)) resource.prefetch(baseUrl);
|
|
1887
|
-
};
|
|
1888
|
-
/** Dropped with the stack itself — a stack that comes back re-reads its index. */
|
|
1889
|
-
const forget = (baseUrl) => resource.forget((key) => key === baseUrl);
|
|
1890
|
-
return {
|
|
1891
|
-
subscriber,
|
|
1892
|
-
get: resource.get,
|
|
1893
|
-
getAsync: resource.getAsync,
|
|
1894
|
-
retry: resource.retry,
|
|
1895
|
-
forget
|
|
1896
|
-
};
|
|
1897
|
-
};
|
|
1898
|
-
//#endregion
|
|
1899
|
-
//#region src/keboola/bearer/perProject.ts
|
|
1900
|
-
const once = (build) => {
|
|
1901
|
-
let value = null;
|
|
1902
|
-
return () => value ??= build();
|
|
1903
|
-
};
|
|
1904
|
-
/**
|
|
1905
|
-
* Everything one project derives, and the one call that drops it.
|
|
1906
|
-
*
|
|
1907
|
-
* Every field belongs to the credential that built it — a client set carries its middleware chain,
|
|
1908
|
-
* the storage client holds a `liveProject` seeded with its token, a fetched context *is* what it
|
|
1909
|
-
* answered for `tokens.verify` — so the record dies with the sign-in, and `forgetUnder` is the
|
|
1910
|
-
* only thing that ends one.
|
|
1911
|
-
*/
|
|
1912
|
-
const createPerProject = ({ state, credentials, middlewareFor, stack, clientServiceUrls, buildApi }) => {
|
|
1913
|
-
const context = createProjectContext({
|
|
1914
|
-
state,
|
|
1915
|
-
credentials,
|
|
1916
|
-
stackContext: stack.context
|
|
1917
|
-
});
|
|
1353
|
+
const createPerProject = ({ state, credentials, middlewareFor, stack }) => {
|
|
1918
1354
|
const attachFor = ({ baseUrl, projectId }) => {
|
|
1919
1355
|
const withProjectId = (next) => (request) => {
|
|
1920
1356
|
request.request.headers.set(KeboolaHttpHeader.PROJECT_ID, String(projectId));
|
|
@@ -1922,131 +1358,72 @@ const createPerProject = ({ state, credentials, middlewareFor, stack, clientServ
|
|
|
1922
1358
|
};
|
|
1923
1359
|
return (next) => withProjectId(credentials.middleware(baseUrl)(next));
|
|
1924
1360
|
};
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
token: "",
|
|
1930
|
-
projectId
|
|
1931
|
-
},
|
|
1932
|
-
getServiceBaseUrl: (serviceId) => async () => {
|
|
1933
|
-
const stackInfo = await stack.context.getAsync(baseUrl);
|
|
1934
|
-
const serviceUrl = createStack({
|
|
1935
|
-
stackInfo,
|
|
1936
|
-
clientServiceUrls
|
|
1937
|
-
}).getServiceUrl(serviceId);
|
|
1938
|
-
assert$1(serviceUrl, KeboolaErrorType.NotReady);
|
|
1939
|
-
return serviceUrl;
|
|
1940
|
-
},
|
|
1941
|
-
middlewareFor,
|
|
1942
|
-
attachTokenMiddleware: attach
|
|
1361
|
+
const authFor = ({ projectId }) => ({
|
|
1362
|
+
type: "bearer",
|
|
1363
|
+
token: "",
|
|
1364
|
+
projectId
|
|
1943
1365
|
});
|
|
1944
1366
|
/**
|
|
1945
|
-
*
|
|
1946
|
-
* carries its re-verify middleware, the context reports the project it re-verifies.
|
|
1367
|
+
* One project's surface: the stack's fields from `perStack`, the rest built for the project.
|
|
1947
1368
|
*
|
|
1948
|
-
* -
|
|
1949
|
-
*
|
|
1950
|
-
* - `storage` is gated on the stack index too, though it addresses the project's own `baseUrl`
|
|
1951
|
-
* and does not need it — that is the gate as it stands, not a requirement.
|
|
1369
|
+
* - Checked per property read but `baseUrl`: `SignInEnded` once the sign-in it was built under
|
|
1370
|
+
* ends, and `NotAuthenticated` before one lands.
|
|
1952
1371
|
*/
|
|
1953
|
-
const
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
const
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
type: "bearer",
|
|
1961
|
-
token: "",
|
|
1962
|
-
projectId
|
|
1963
|
-
};
|
|
1964
|
-
const reader = createStorageClient({
|
|
1965
|
-
baseUrl,
|
|
1966
|
-
auth,
|
|
1967
|
-
middlewares: [attach]
|
|
1372
|
+
const build = (project) => {
|
|
1373
|
+
let isLive = true;
|
|
1374
|
+
const attach = attachFor(project);
|
|
1375
|
+
const storage = createStorageClient({
|
|
1376
|
+
baseUrl: project.baseUrl,
|
|
1377
|
+
auth: authFor(project),
|
|
1378
|
+
middlewares: middlewareFor("storage", [attach])
|
|
1968
1379
|
});
|
|
1969
|
-
const
|
|
1970
|
-
|
|
1971
|
-
|
|
1380
|
+
const { client, meta } = createServiceClients({
|
|
1381
|
+
baseUrl: project.baseUrl,
|
|
1382
|
+
auth: authFor(project),
|
|
1383
|
+
getServiceBaseUrl: (serviceId) => async () => {
|
|
1384
|
+
const serviceUrl = (await stack.context.getAsync(project.baseUrl)).getServiceUrl(serviceId);
|
|
1385
|
+
assert$1(serviceUrl, KeboolaErrorType.NotReady);
|
|
1386
|
+
return serviceUrl;
|
|
1387
|
+
},
|
|
1388
|
+
middlewareFor,
|
|
1389
|
+
attachTokenMiddleware: attach
|
|
1972
1390
|
});
|
|
1973
|
-
const
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
dependsOn: (live) => ({
|
|
1977
|
-
useLegacyBucketPrefix: !live.hasFeature(ProjectFeature.DisableLegacyBucketPrefix),
|
|
1978
|
-
hasProtectedDefaultBranch: live.hasFeature(ProjectFeature.SoxProtectedDefaultBranch),
|
|
1979
|
-
hasStorageBranches: live.hasFeature(ProjectFeature.StorageBranches)
|
|
1980
|
-
})
|
|
1391
|
+
const sdk = createSdk({
|
|
1392
|
+
storage,
|
|
1393
|
+
services: client
|
|
1981
1394
|
});
|
|
1982
1395
|
return {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
return liveProject.getProject();
|
|
1997
|
-
},
|
|
1998
|
-
get st() {
|
|
1999
|
-
return storageTableStore.get();
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
};
|
|
2003
|
-
};
|
|
2004
|
-
const build = (project) => {
|
|
2005
|
-
const attach = attachFor(project);
|
|
2006
|
-
const live = once(() => buildLive(project, attach));
|
|
2007
|
-
const clients = once(() => buildClients(project, attach));
|
|
2008
|
-
const sdk = once(() => createSdk({
|
|
2009
|
-
storage: live().storage,
|
|
2010
|
-
services: clients().client,
|
|
2011
|
-
context: live().context
|
|
2012
|
-
}));
|
|
2013
|
-
return {
|
|
2014
|
-
api: buildApi(project),
|
|
2015
|
-
get clients() {
|
|
2016
|
-
return clients();
|
|
2017
|
-
},
|
|
2018
|
-
get storage() {
|
|
2019
|
-
return live().storage;
|
|
2020
|
-
},
|
|
2021
|
-
get context() {
|
|
2022
|
-
return live().context;
|
|
2023
|
-
},
|
|
2024
|
-
get sdk() {
|
|
2025
|
-
return sdk();
|
|
1396
|
+
api: new Proxy({}, { get: (_target, property) => {
|
|
1397
|
+
if (isBuiltInProperty(property)) return void 0;
|
|
1398
|
+
if (property === "baseUrl") return project.baseUrl;
|
|
1399
|
+
if (!isLive) throw new KeboolaError(KeboolaErrorType.SignInEnded);
|
|
1400
|
+
Result.unwrap(state.auth.requireCredential(project.baseUrl));
|
|
1401
|
+
if (property === "stack" || property === "auth" || property === "management") return stack.get(project.baseUrl)[property];
|
|
1402
|
+
if (property === "storage") return storage;
|
|
1403
|
+
if (property === "sdk") return sdk;
|
|
1404
|
+
if (property === "serviceMeta") return meta;
|
|
1405
|
+
return client[property];
|
|
1406
|
+
} }),
|
|
1407
|
+
end: () => {
|
|
1408
|
+
isLive = false;
|
|
2026
1409
|
}
|
|
2027
1410
|
};
|
|
2028
1411
|
};
|
|
2029
1412
|
const derived = /* @__PURE__ */ new Map();
|
|
2030
|
-
const get = (project) => ensure(derived, project
|
|
2031
|
-
/** One project, closed on purpose — a handle for it stops answering from the next read. */
|
|
2032
|
-
const forget = (id) => {
|
|
2033
|
-
derived.delete(id);
|
|
2034
|
-
context.forget(id);
|
|
2035
|
-
};
|
|
1413
|
+
const get = (project) => ensure(derived, projectKey(project), () => build(project)).api;
|
|
2036
1414
|
const forgetUnder = (baseUrl) => {
|
|
2037
|
-
const
|
|
2038
|
-
|
|
2039
|
-
|
|
1415
|
+
for (const [key, record] of derived) {
|
|
1416
|
+
if (!key.startsWith(`${baseUrl}#`)) continue;
|
|
1417
|
+
record.end();
|
|
1418
|
+
derived.delete(key);
|
|
1419
|
+
}
|
|
2040
1420
|
};
|
|
2041
1421
|
return {
|
|
2042
|
-
context,
|
|
2043
1422
|
get,
|
|
2044
|
-
forget,
|
|
2045
1423
|
forgetUnder
|
|
2046
1424
|
};
|
|
2047
1425
|
};
|
|
2048
|
-
|
|
2049
|
-
//#region src/keboola/bearer/persistor.ts
|
|
1426
|
+
// src/keboola/bearer/persistor.ts
|
|
2050
1427
|
/**
|
|
2051
1428
|
* Where a bearer session is persisted, under whichever adapter the client was given.
|
|
2052
1429
|
*
|
|
@@ -2072,17 +1449,23 @@ const persistedGrantSchema = z$1.discriminatedUnion("type", [z$1.object({
|
|
|
2072
1449
|
type: z$1.literal("cookie"),
|
|
2073
1450
|
sessionId: z$1.string()
|
|
2074
1451
|
})]);
|
|
2075
|
-
/** A record per project rather than a bare id, so a project can grow a field without a migration. */
|
|
2076
|
-
const persistedProjectSchema = z$1.object({ projectId: z$1.number() });
|
|
2077
1452
|
const persistedStackSchema = z$1.object({
|
|
2078
1453
|
baseUrl: z$1.string(),
|
|
2079
1454
|
credential: persistedGrantSchema.nullable().catch(null),
|
|
2080
1455
|
retained: z$1.object({ grant: persistedGrantSchema }).nullable().default(null).catch(null),
|
|
2081
|
-
|
|
1456
|
+
/**
|
|
1457
|
+
* Written empty, never read.
|
|
1458
|
+
* - An older build parses a stack without it as corrupt, and signs out.
|
|
1459
|
+
*/
|
|
1460
|
+
projects: z$1.array(z$1.unknown())
|
|
2082
1461
|
});
|
|
2083
1462
|
const persistedSessionSchema = z$1.object({
|
|
2084
1463
|
current: z$1.object({
|
|
2085
1464
|
baseUrl: z$1.string(),
|
|
1465
|
+
/**
|
|
1466
|
+
* Written `null`, never read: the project is the app's to keep.
|
|
1467
|
+
* - An older build parses a `current` without it as corrupt, and signs out.
|
|
1468
|
+
*/
|
|
2086
1469
|
projectId: z$1.number().nullable()
|
|
2087
1470
|
}).nullable(),
|
|
2088
1471
|
stacks: z$1.array(persistedStackSchema)
|
|
@@ -2091,22 +1474,21 @@ const EMPTY_PERSISTED_SESSION = {
|
|
|
2091
1474
|
current: null,
|
|
2092
1475
|
stacks: []
|
|
2093
1476
|
};
|
|
2094
|
-
const projectsOf = (projects, baseUrl) => Object.values(projects).filter((project) => project.baseUrl === baseUrl).map(({ projectId }) => ({ projectId }));
|
|
2095
1477
|
const grantsOf = (stack) => ({
|
|
2096
|
-
credential: stack.auth.status === "authenticated" ?
|
|
1478
|
+
credential: stack.auth.status === "authenticated" ? grantOf(stack.auth.credential) : null,
|
|
2097
1479
|
retained: stack.retained
|
|
2098
1480
|
});
|
|
2099
1481
|
/**
|
|
2100
1482
|
* The stored session, rewritten from the table except for the grants.
|
|
2101
1483
|
*
|
|
2102
|
-
* - Scope
|
|
1484
|
+
* - Scope and stack list come from memory.
|
|
2103
1485
|
* - `credential` and `retained` stay as stored: a grant another document rotated must not be put
|
|
2104
1486
|
* back by a snapshot of this one's older table.
|
|
2105
1487
|
*/
|
|
2106
|
-
const mergeSnapshot = (stored, { active, stacks
|
|
1488
|
+
const mergeSnapshot = (stored, { active, stacks }) => ({
|
|
2107
1489
|
current: {
|
|
2108
|
-
baseUrl: active
|
|
2109
|
-
projectId:
|
|
1490
|
+
baseUrl: active,
|
|
1491
|
+
projectId: null
|
|
2110
1492
|
},
|
|
2111
1493
|
stacks: Object.values(stacks).map(({ baseUrl }) => {
|
|
2112
1494
|
const kept = stored.stacks.find((stack) => stack.baseUrl === baseUrl);
|
|
@@ -2114,15 +1496,15 @@ const mergeSnapshot = (stored, { active, stacks, projects }) => ({
|
|
|
2114
1496
|
baseUrl,
|
|
2115
1497
|
credential: kept?.credential ?? null,
|
|
2116
1498
|
retained: kept?.retained ?? null,
|
|
2117
|
-
projects:
|
|
1499
|
+
projects: []
|
|
2118
1500
|
};
|
|
2119
1501
|
})
|
|
2120
1502
|
});
|
|
2121
|
-
const upsertStack = (stored,
|
|
2122
|
-
const index = stored.stacks.findIndex((stack) => stack.baseUrl === baseUrl);
|
|
1503
|
+
const upsertStack = (stored, row) => {
|
|
1504
|
+
const index = stored.stacks.findIndex((stack) => stack.baseUrl === row.baseUrl);
|
|
2123
1505
|
const stacks = [...stored.stacks];
|
|
2124
|
-
if (index < 0) stacks.push(
|
|
2125
|
-
else stacks[index] =
|
|
1506
|
+
if (index < 0) stacks.push(row);
|
|
1507
|
+
else stacks[index] = row;
|
|
2126
1508
|
return {
|
|
2127
1509
|
...stored,
|
|
2128
1510
|
stacks
|
|
@@ -2143,14 +1525,14 @@ const createSessionPersistor = (storage) => {
|
|
|
2143
1525
|
schema: persistedSessionSchema,
|
|
2144
1526
|
defaultValue: EMPTY_PERSISTED_SESSION
|
|
2145
1527
|
});
|
|
2146
|
-
const persistStack = (cell, baseUrl, { stacks
|
|
1528
|
+
const persistStack = (cell, baseUrl, { stacks }) => {
|
|
2147
1529
|
const stack = stacks[baseUrl];
|
|
2148
1530
|
if (stack === void 0) return Promise.resolve();
|
|
2149
|
-
return cell.modify((stored) => upsertStack(stored,
|
|
1531
|
+
return cell.modify((stored) => upsertStack(stored, {
|
|
2150
1532
|
baseUrl,
|
|
2151
1533
|
...grantsOf(stack),
|
|
2152
|
-
projects:
|
|
2153
|
-
}))
|
|
1534
|
+
projects: []
|
|
1535
|
+
}));
|
|
2154
1536
|
};
|
|
2155
1537
|
const locked = (task) => persistor.locked((cell) => task({
|
|
2156
1538
|
read: cell.read,
|
|
@@ -2174,18 +1556,92 @@ const createSessionPersistor = (storage) => {
|
|
|
2174
1556
|
snapshot
|
|
2175
1557
|
};
|
|
2176
1558
|
};
|
|
2177
|
-
|
|
2178
|
-
|
|
1559
|
+
// src/keboola/bearer/context.ts
|
|
1560
|
+
const STACK_INDEX_TIMEOUT_MS = 3e4;
|
|
2179
1561
|
/**
|
|
2180
|
-
*
|
|
1562
|
+
* One parsed stack index per stack; `createStack` applies the dev and production overrides.
|
|
1563
|
+
*
|
|
1564
|
+
* - One fetch per stack: concurrent askers share it, a landed index is never refetched.
|
|
1565
|
+
* - A failure is held until a retry; nothing here needs a rejection handler.
|
|
1566
|
+
* - Every status change is copied onto the stack's row, for the consumers that render it.
|
|
1567
|
+
*/
|
|
1568
|
+
const createStackContext = ({ state, clientServiceUrls }) => {
|
|
1569
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1570
|
+
const set = (baseUrl, entry) => {
|
|
1571
|
+
entries.set(baseUrl, entry);
|
|
1572
|
+
state.stacks.updateContext(baseUrl, entry.status);
|
|
1573
|
+
};
|
|
1574
|
+
const fetchStack = async (baseUrl) => {
|
|
1575
|
+
const stackInfo = await createStorageClient({
|
|
1576
|
+
baseUrl,
|
|
1577
|
+
auth: {
|
|
1578
|
+
type: "sapi-token",
|
|
1579
|
+
token: ""
|
|
1580
|
+
}
|
|
1581
|
+
}).getStackInfo({ exclude: "componentDetails" }, AbortSignal.timeout(STACK_INDEX_TIMEOUT_MS));
|
|
1582
|
+
return createStack({
|
|
1583
|
+
stackInfo,
|
|
1584
|
+
clientServiceUrls
|
|
1585
|
+
});
|
|
1586
|
+
};
|
|
1587
|
+
const run = (baseUrl) => {
|
|
1588
|
+
const settle = (next) => {
|
|
1589
|
+
set(baseUrl, next);
|
|
1590
|
+
return next;
|
|
1591
|
+
};
|
|
1592
|
+
const entry = {
|
|
1593
|
+
status: "pending",
|
|
1594
|
+
settled: fetchStack(baseUrl).then((value) => settle({
|
|
1595
|
+
status: "ready",
|
|
1596
|
+
value
|
|
1597
|
+
}), (error) => settle({
|
|
1598
|
+
status: "errored",
|
|
1599
|
+
error
|
|
1600
|
+
}))
|
|
1601
|
+
};
|
|
1602
|
+
set(baseUrl, entry);
|
|
1603
|
+
return entry;
|
|
1604
|
+
};
|
|
1605
|
+
const get = (baseUrl) => {
|
|
1606
|
+
const entry = entries.get(baseUrl);
|
|
1607
|
+
return entry?.status === "ready" ? entry.value : null;
|
|
1608
|
+
};
|
|
1609
|
+
const getAsync = async (baseUrl) => {
|
|
1610
|
+
const cached = entries.get(baseUrl);
|
|
1611
|
+
const entry = cached === void 0 || cached.status === "errored" ? run(baseUrl) : cached;
|
|
1612
|
+
const settled = entry.status === "pending" ? await entry.settled : entry;
|
|
1613
|
+
if (settled.status === "errored") throw settled.error;
|
|
1614
|
+
return settled.value;
|
|
1615
|
+
};
|
|
1616
|
+
const subscriber = ({ stacks }) => {
|
|
1617
|
+
for (const { baseUrl } of Object.values(stacks)) if (!entries.has(baseUrl)) run(baseUrl);
|
|
1618
|
+
};
|
|
1619
|
+
return {
|
|
1620
|
+
subscriber,
|
|
1621
|
+
get,
|
|
1622
|
+
getAsync
|
|
1623
|
+
};
|
|
1624
|
+
};
|
|
1625
|
+
// src/keboola/bearer/perStack.ts
|
|
1626
|
+
/**
|
|
1627
|
+
* Everything one stack derives.
|
|
2181
1628
|
*
|
|
2182
1629
|
* Outlives a sign-out, unlike anything in `perProject`: both clients read the credential live per
|
|
2183
1630
|
* request, so neither belongs to one sign-in, and the stack index is public.
|
|
2184
1631
|
*/
|
|
2185
|
-
const createPerStack = ({ state, credentials, middlewareFor }) => {
|
|
2186
|
-
const context = createStackContext(
|
|
1632
|
+
const createPerStack = ({ state, credentials, middlewareFor, clientServiceUrls }) => {
|
|
1633
|
+
const context = createStackContext({
|
|
1634
|
+
state,
|
|
1635
|
+
clientServiceUrls
|
|
1636
|
+
});
|
|
2187
1637
|
const derived = /* @__PURE__ */ new Map();
|
|
2188
1638
|
const get = (baseUrl) => ensure(derived, baseUrl, () => ({
|
|
1639
|
+
baseUrl,
|
|
1640
|
+
get stack() {
|
|
1641
|
+
const parsed = context.get(baseUrl);
|
|
1642
|
+
assert$1(parsed, KeboolaErrorType.NotReady);
|
|
1643
|
+
return parsed;
|
|
1644
|
+
},
|
|
2189
1645
|
auth: createAuthClient({
|
|
2190
1646
|
baseUrl,
|
|
2191
1647
|
middlewares: middlewareFor("auth", [credentials.middleware(baseUrl)])
|
|
@@ -2199,18 +1655,12 @@ const createPerStack = ({ state, credentials, middlewareFor }) => {
|
|
|
2199
1655
|
middlewares: middlewareFor("management", [credentials.middleware(baseUrl)])
|
|
2200
1656
|
})
|
|
2201
1657
|
}));
|
|
2202
|
-
const forget = (baseUrl) => {
|
|
2203
|
-
derived.delete(baseUrl);
|
|
2204
|
-
context.forget(baseUrl);
|
|
2205
|
-
};
|
|
2206
1658
|
return {
|
|
2207
1659
|
context,
|
|
2208
|
-
get
|
|
2209
|
-
forget
|
|
1660
|
+
get
|
|
2210
1661
|
};
|
|
2211
1662
|
};
|
|
2212
|
-
|
|
2213
|
-
//#region src/keboola/bearer/keboola.ts
|
|
1663
|
+
// src/keboola/bearer/keboola.ts
|
|
2214
1664
|
/**
|
|
2215
1665
|
* The bearer client: the session table, its two scopes, and the surface they back.
|
|
2216
1666
|
*
|
|
@@ -2230,65 +1680,41 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2230
1680
|
const perStack = createPerStack({
|
|
2231
1681
|
state,
|
|
2232
1682
|
credentials,
|
|
2233
|
-
middlewareFor
|
|
1683
|
+
middlewareFor,
|
|
1684
|
+
clientServiceUrls
|
|
2234
1685
|
});
|
|
2235
1686
|
const perProject = createPerProject({
|
|
2236
1687
|
state,
|
|
2237
1688
|
credentials,
|
|
2238
1689
|
middlewareFor,
|
|
2239
|
-
stack: perStack
|
|
2240
|
-
clientServiceUrls,
|
|
2241
|
-
buildApi: (project) => createApiFor({
|
|
2242
|
-
stackUrl: () => project.baseUrl,
|
|
2243
|
-
project: () => Result.unwrap(state.projects.get(project.id)),
|
|
2244
|
-
pinned: true
|
|
2245
|
-
})
|
|
1690
|
+
stack: perStack
|
|
2246
1691
|
});
|
|
2247
1692
|
state.store.subscribe(perStack.context.subscriber);
|
|
2248
1693
|
perStack.context.subscriber(state.store.get());
|
|
2249
|
-
state.
|
|
2250
|
-
|
|
2251
|
-
const
|
|
2252
|
-
/**
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2255
|
-
|
|
1694
|
+
const selectStack = (baseUrl) => state.stacks.select(normalizeBaseUrl(baseUrl));
|
|
1695
|
+
/** The active stack, or a named one — normalised to key like `select`. */
|
|
1696
|
+
const requireStackUrl = (baseUrl) => baseUrl === void 0 ? state.stacks.getActive().baseUrl : normalizeBaseUrl(baseUrl);
|
|
1697
|
+
/** A project id is unique only within its stack: it always names one on the active stack. */
|
|
1698
|
+
const onActiveStack = (projectId) => ({
|
|
1699
|
+
baseUrl: requireStackUrl(),
|
|
1700
|
+
projectId
|
|
1701
|
+
});
|
|
2256
1702
|
/**
|
|
2257
|
-
*
|
|
1703
|
+
* Auth headers for a non-fetch transport (the chat stream), renewed first once near expiry.
|
|
2258
1704
|
*
|
|
2259
|
-
* -
|
|
1705
|
+
* - No middleware recovers a 401 there.
|
|
1706
|
+
* - Pinned to the stack active at the call: a stack switch mid-renewal does not re-point it.
|
|
1707
|
+
* - Throws `NotAuthenticated` if that stack signed out meanwhile.
|
|
2260
1708
|
*/
|
|
2261
|
-
const
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
const [only, ...rest] = state.projects.findAll(projectId);
|
|
2266
|
-
return only !== void 0 && rest.length === 0 ? only : Result.unwrap(scoped);
|
|
2267
|
-
};
|
|
2268
|
-
const headersFor = (project) => {
|
|
2269
|
-
const credential = Result.unwrap(state.auth.requireCredential(project.baseUrl));
|
|
1709
|
+
const getAuthHeadersAsync = async (projectId) => {
|
|
1710
|
+
const { baseUrl } = onActiveStack(projectId);
|
|
1711
|
+
await credentials.renewIfStale(baseUrl);
|
|
1712
|
+
const credential = Result.unwrap(state.auth.requireCredential(baseUrl));
|
|
2270
1713
|
return {
|
|
2271
1714
|
[HttpHeader.AUTHORIZATION]: `Bearer ${credential.accessToken}`,
|
|
2272
|
-
[KeboolaHttpHeader.PROJECT_ID]: String(
|
|
1715
|
+
[KeboolaHttpHeader.PROJECT_ID]: String(projectId)
|
|
2273
1716
|
};
|
|
2274
1717
|
};
|
|
2275
|
-
/**
|
|
2276
|
-
* Auth headers for a non-fetch transport (the chat stream).
|
|
2277
|
-
*
|
|
2278
|
-
* - A read, not a rotation: no middleware recovers a 401 there; the fetch clients keep it fresh.
|
|
2279
|
-
*/
|
|
2280
|
-
const getAuthHeaders = (projectId) => headersFor(requireProject(projectId));
|
|
2281
|
-
/**
|
|
2282
|
-
* `getAuthHeaders`, with the token renewed first once it nears expiry.
|
|
2283
|
-
*
|
|
2284
|
-
* - Pinned to the project resolved at the call: a scope move during the renewal does not re-point it.
|
|
2285
|
-
* - Throws like the read if that project closed, or its stack signed out, meanwhile.
|
|
2286
|
-
*/
|
|
2287
|
-
const getAuthHeadersAsync = async (projectId) => {
|
|
2288
|
-
const project = requireProject(projectId);
|
|
2289
|
-
await credentials.renewIfStale(project.baseUrl);
|
|
2290
|
-
return headersFor(Result.unwrap(state.projects.get(project.id)));
|
|
2291
|
-
};
|
|
2292
1718
|
const toCredential = (input) => {
|
|
2293
1719
|
if (input.type !== "token") return input;
|
|
2294
1720
|
const { refreshToken } = input;
|
|
@@ -2299,51 +1725,30 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2299
1725
|
};
|
|
2300
1726
|
};
|
|
2301
1727
|
const authenticate = (input) => {
|
|
2302
|
-
const { baseUrl } = state.
|
|
1728
|
+
const { baseUrl } = state.stacks.getActive();
|
|
2303
1729
|
const signedIn = Result.unwrap(state.auth.authenticate(baseUrl, toCredential(input)));
|
|
2304
1730
|
persistor.locked((store) => store.persistStack(baseUrl, state.store.get())).catch((error) => {
|
|
2305
1731
|
console.warn("createKeboola: the sign-in could not be stored", error);
|
|
2306
1732
|
});
|
|
2307
1733
|
return signedIn;
|
|
2308
1734
|
};
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
1735
|
+
const active = () => perStack.get(state.stacks.getActive().baseUrl);
|
|
1736
|
+
const stackApi = {
|
|
1737
|
+
get baseUrl() {
|
|
1738
|
+
return active().baseUrl;
|
|
1739
|
+
},
|
|
1740
|
+
get stack() {
|
|
1741
|
+
return active().stack;
|
|
1742
|
+
},
|
|
1743
|
+
get auth() {
|
|
1744
|
+
return active().auth;
|
|
1745
|
+
},
|
|
1746
|
+
get management() {
|
|
1747
|
+
return active().management;
|
|
2320
1748
|
}
|
|
2321
|
-
const derived = perProject.get(resolve.project());
|
|
2322
|
-
if (property === "context") return derived.context;
|
|
2323
|
-
if (property === "storage") return derived.storage;
|
|
2324
|
-
if (property === "sdk") return derived.sdk;
|
|
2325
|
-
const { client, meta } = derived.clients;
|
|
2326
|
-
if (property === "serviceMeta") return meta;
|
|
2327
|
-
return client[property];
|
|
2328
|
-
} });
|
|
2329
|
-
const activeApi = createApiFor({
|
|
2330
|
-
stackUrl: () => state.scope.getActiveStack().baseUrl,
|
|
2331
|
-
project: () => Result.unwrap(state.scope.requireActiveProject())
|
|
2332
|
-
});
|
|
2333
|
-
/** The scoped project's surface. Re-points when the scope moves. */
|
|
2334
|
-
const getActiveApi = () => activeApi;
|
|
2335
|
-
/**
|
|
2336
|
-
* One project's surface, on the active stack — one credential serves all of them.
|
|
2337
|
-
*
|
|
2338
|
-
* - Pinned: never re-points; stops once the project closes (`session.project.close`, sign-out).
|
|
2339
|
-
* - Memoised per project: a React `key` or a hook dep compares handles by identity.
|
|
2340
|
-
*/
|
|
2341
|
-
const getApi = (projectId) => {
|
|
2342
|
-
const { baseUrl } = state.scope.getActiveStack();
|
|
2343
|
-
const project = Entry.project(baseUrl, projectId);
|
|
2344
|
-
Result.unwrapOr(state.projects.open(baseUrl, projectId), null);
|
|
2345
|
-
return perProject.get(project).api;
|
|
2346
1749
|
};
|
|
1750
|
+
const getStackApi = () => stackApi;
|
|
1751
|
+
const getProjectApi = (projectId) => perProject.get(onActiveStack(projectId));
|
|
2347
1752
|
/**
|
|
2348
1753
|
* The scope's sign-in, or a named stack's — and everything that sign-in derived.
|
|
2349
1754
|
*
|
|
@@ -2369,28 +1774,6 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2369
1774
|
signOut();
|
|
2370
1775
|
return authenticate(input);
|
|
2371
1776
|
};
|
|
2372
|
-
/**
|
|
2373
|
-
* Leave one project: its row and everything built for it; its handles stop answering.
|
|
2374
|
-
*
|
|
2375
|
-
* - Counterpart of `getApi(projectId)`; without it the project is held and persisted until sign-out.
|
|
2376
|
-
*/
|
|
2377
|
-
const closeProject = (projectId) => {
|
|
2378
|
-
const id = Entry.projectEntryId(requireStackUrl(), projectId);
|
|
2379
|
-
const closed = Result.unwrapOr(state.projects.close(id), null);
|
|
2380
|
-
if (closed === null) return null;
|
|
2381
|
-
perProject.forget(id);
|
|
2382
|
-
return closed;
|
|
2383
|
-
};
|
|
2384
|
-
const closeStack = (baseUrl) => {
|
|
2385
|
-
const target = normalizeBaseUrl(baseUrl);
|
|
2386
|
-
if (state.scope.get().baseUrl === target) throw new KeboolaError(KeboolaErrorType.StackActive);
|
|
2387
|
-
const closed = Result.unwrapOr(state.stacks.close(target), null);
|
|
2388
|
-
if (closed === null) return null;
|
|
2389
|
-
perProject.forgetUnder(target);
|
|
2390
|
-
perStack.forget(target);
|
|
2391
|
-
credentials.forget(target);
|
|
2392
|
-
return closed;
|
|
2393
|
-
};
|
|
2394
1777
|
let persisting = false;
|
|
2395
1778
|
/**
|
|
2396
1779
|
* Persistence starts only once the restore has settled.
|
|
@@ -2432,12 +1815,12 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2432
1815
|
enablePersistenceOnSignIn();
|
|
2433
1816
|
throw error;
|
|
2434
1817
|
}));
|
|
2435
|
-
const getActiveStack = state.
|
|
1818
|
+
const getActiveStack = state.stacks.getActive;
|
|
2436
1819
|
const isAuthenticated = () => getActiveStack().auth.status === "authenticated";
|
|
2437
1820
|
/**
|
|
2438
1821
|
* Picks up where the stored session left off, once.
|
|
2439
1822
|
*
|
|
2440
|
-
* 1.
|
|
1823
|
+
* 1. The stored stack becomes active again.
|
|
2441
1824
|
* 2. Nothing stored, or the restore failed: `defaultBaseUrl` stays active; a failure rethrows.
|
|
2442
1825
|
* 3. The caller got there first (a select, sign-in or sign-out): its scope and sign-ins stand.
|
|
2443
1826
|
*
|
|
@@ -2445,9 +1828,7 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2445
1828
|
* - Other stacks still come back, persistence still starts; repeat calls share one promise.
|
|
2446
1829
|
*/
|
|
2447
1830
|
const resume = lazy(() => restore().then(({ lastActive, status }) => {
|
|
2448
|
-
if (
|
|
2449
|
-
const stack = selectStack(lastActive.baseUrl);
|
|
2450
|
-
if (lastActive.projectId !== null && stack.auth.status === "authenticated") selectProject(lastActive.projectId);
|
|
1831
|
+
if (lastActive && !callerScoped) selectStack(lastActive.baseUrl);
|
|
2451
1832
|
return status;
|
|
2452
1833
|
}));
|
|
2453
1834
|
let callerScoped = false;
|
|
@@ -2456,8 +1837,8 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2456
1837
|
return verb(...args);
|
|
2457
1838
|
};
|
|
2458
1839
|
return {
|
|
2459
|
-
|
|
2460
|
-
|
|
1840
|
+
getStackApi,
|
|
1841
|
+
getProjectApi,
|
|
2461
1842
|
session: {
|
|
2462
1843
|
getState: state.store.get,
|
|
2463
1844
|
subscribe: state.store.subscribe,
|
|
@@ -2469,23 +1850,9 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2469
1850
|
const stack = selectStack(baseUrl);
|
|
2470
1851
|
return persistScope().then(() => stack);
|
|
2471
1852
|
}),
|
|
2472
|
-
close: closeStack,
|
|
2473
|
-
retryContext: perStack.context.retry,
|
|
2474
1853
|
getContext: (baseUrl) => perStack.context.get(requireStackUrl(baseUrl)),
|
|
2475
1854
|
getContextAsync: (baseUrl) => perStack.context.getAsync(requireStackUrl(baseUrl))
|
|
2476
1855
|
},
|
|
2477
|
-
project: {
|
|
2478
|
-
/** Scoped on return; resolves once that is stored, for a caller leaving the document. */
|
|
2479
|
-
select: byCaller((projectId) => {
|
|
2480
|
-
const project = selectProject(projectId);
|
|
2481
|
-
return persistScope().then(() => project);
|
|
2482
|
-
}),
|
|
2483
|
-
close: closeProject,
|
|
2484
|
-
deactivate: state.scope.deactivate,
|
|
2485
|
-
retryContext: perProject.context.retry,
|
|
2486
|
-
getContext: (id) => perProject.context.get(id ?? requireProjectEntry().id),
|
|
2487
|
-
getContextAsync: (id) => perProject.context.getAsync(requireProjectEntry(id))
|
|
2488
|
-
},
|
|
2489
1856
|
auth: {
|
|
2490
1857
|
authenticate: byCaller(authenticate),
|
|
2491
1858
|
replace: byCaller(replace),
|
|
@@ -2494,15 +1861,12 @@ const createKeboola = ({ defaultBaseUrl, storage, middlewares, clientServiceUrls
|
|
|
2494
1861
|
/** Whether the active stack holds a credential — `restoring` is not one yet. */
|
|
2495
1862
|
isAuthenticated,
|
|
2496
1863
|
isAuthenticatedAsync: () => resume().then(isAuthenticated),
|
|
2497
|
-
rotate: (baseUrl) => credentials.rotate(baseUrl).then(Result.unwrap),
|
|
2498
|
-
getHeaders: getAuthHeaders,
|
|
2499
1864
|
getHeadersAsync: getAuthHeadersAsync
|
|
2500
1865
|
}
|
|
2501
1866
|
}
|
|
2502
1867
|
};
|
|
2503
1868
|
};
|
|
2504
|
-
|
|
2505
|
-
//#region src/middlewares/loggingMiddleware.ts
|
|
1869
|
+
// src/middlewares/loggingMiddleware.ts
|
|
2506
1870
|
const CORRELATION_ID_HEADER = "X-Correlation-ID";
|
|
2507
1871
|
const ALWAYS_REDACTED_HEADERS = [...CREDENTIAL_HEADERS, "set-cookie"];
|
|
2508
1872
|
const ALWAYS_REDACTED_QUERY_PARAMS = /* @__PURE__ */ new Set([
|
|
@@ -2620,8 +1984,7 @@ const createLoggingMiddleware = (options = {}) => {
|
|
|
2620
1984
|
}
|
|
2621
1985
|
};
|
|
2622
1986
|
};
|
|
2623
|
-
|
|
2624
|
-
//#region src/middlewares/retryMiddleware.ts
|
|
1987
|
+
// src/middlewares/retryMiddleware.ts
|
|
2625
1988
|
const DEFAULT_MAX_RETRIES = 5;
|
|
2626
1989
|
const DEFAULT_RETRYABLE_STATUSES = [
|
|
2627
1990
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
|
@@ -2649,8 +2012,7 @@ const createRetryMiddleware = (options) => {
|
|
|
2649
2012
|
throw new Error("unreachable");
|
|
2650
2013
|
};
|
|
2651
2014
|
};
|
|
2652
|
-
|
|
2653
|
-
//#region src/middlewares/uiVersionMiddleware.ts
|
|
2015
|
+
// src/middlewares/uiVersionMiddleware.ts
|
|
2654
2016
|
/** Stamps `X-KBC-Ui-Version`; an empty `uiVersion` sends no header. */
|
|
2655
2017
|
const createUiVersionMiddleware = (uiVersion) => {
|
|
2656
2018
|
if (!uiVersion) return (next) => next;
|
|
@@ -2659,8 +2021,7 @@ const createUiVersionMiddleware = (uiVersion) => {
|
|
|
2659
2021
|
return next(request);
|
|
2660
2022
|
};
|
|
2661
2023
|
};
|
|
2662
|
-
|
|
2663
|
-
//#region src/domain/adminAccount.ts
|
|
2024
|
+
// src/domain/adminAccount.ts
|
|
2664
2025
|
/**
|
|
2665
2026
|
* The admin behind a Manage token: `GET /manage/tokens/verify`, with the admin-level helpers.
|
|
2666
2027
|
*
|
|
@@ -2683,7 +2044,22 @@ const createAdminAccount = ({ managementToken }) => {
|
|
|
2683
2044
|
managementToken
|
|
2684
2045
|
};
|
|
2685
2046
|
};
|
|
2686
|
-
|
|
2687
|
-
|
|
2047
|
+
// src/domain/defaultBranch.ts
|
|
2048
|
+
const createDefaultBranch = ({ devBranches }) => {
|
|
2049
|
+
const defaultBranch = devBranches.find((branch) => branch.isDefault);
|
|
2050
|
+
assert(defaultBranch, "No default branch found for the project.");
|
|
2051
|
+
const getType = (branchId) => {
|
|
2052
|
+
if (branchId == null || branchId === "default") return "default";
|
|
2053
|
+
return Number(branchId) === defaultBranch.id ? "default" : "dev";
|
|
2054
|
+
};
|
|
2055
|
+
return {
|
|
2056
|
+
id: defaultBranch.id,
|
|
2057
|
+
name: defaultBranch.name,
|
|
2058
|
+
getType,
|
|
2059
|
+
isDev: (branchId) => getType(branchId) === "dev",
|
|
2060
|
+
isDefault: (branchId) => getType(branchId) === "default"
|
|
2061
|
+
};
|
|
2062
|
+
};
|
|
2063
|
+
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, createDefaultBranch, createDerivedAsyncStore, createDerivedStore, createEmitter, createGenericFetchClient, createKeboola, createLegacyKeboola, createLocalStorage, createLoggingMiddleware, createMemoryStorage, createNullStorage, createPersistor, createPollRegistry, createProject, createQueryServiceSdk, createRetryMiddleware, createSessionStorage, createStore, createUiVersionMiddleware, dedupe, deepMerge, delay, emitter, ensure, failureOf, formatValidationIssues, generateUUID, isAbortError, isApiError, isEmptyDeep, isFetchClientError, isHtmlResponseError, isKeboolaError, isManageError, isManagementClientAuthError, isManagementSessionMintError, isPlainObject, isQueryJobError, isQueueJobError, isStorageJobError, isSyncActionError, isTimeoutError, isValidationError, jobStatus, keboolaUID, lazy, manageErrorCode, nextCursorOf, parseLogLines, parseOrThrow, poller, queueSeries, readableReason, retryAfterSeconds, schemaGuidedMerge, series, shallowEqual };
|
|
2688
2064
|
|
|
2689
2065
|
//# sourceMappingURL=index.js.map
|