@keboola/api-client 51.0.0 → 52.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 +46 -8
- package/API-SURFACE.md +1 -10
- package/CHANGELOG.md +27 -0
- package/README.md +2 -2
- package/dist/{ManagementSessionMintError-DNMbYauw.js → ManagementSessionMintError-BMHDcEqV.js} +2 -2
- package/dist/{ManagementSessionMintError-DNMbYauw.js.map → ManagementSessionMintError-BMHDcEqV.js.map} +1 -1
- package/dist/{ManagementSessionMintError-ByOulHQH.cjs → ManagementSessionMintError-Bc9bc7Ai.cjs} +2 -2
- package/dist/{ManagementSessionMintError-ByOulHQH.cjs.map → ManagementSessionMintError-Bc9bc7Ai.cjs.map} +1 -1
- package/dist/RowLevelSecurityError-CObFqj3E.js +33 -0
- package/dist/RowLevelSecurityError-CObFqj3E.js.map +1 -0
- package/dist/RowLevelSecurityError-RK_NhhAx.cjs +56 -0
- package/dist/RowLevelSecurityError-RK_NhhAx.cjs.map +1 -0
- package/dist/{adminRoles-FFyl7Dyx.d.cts → adminRoles-BTKVwEy8.d.cts} +2 -2
- package/dist/{adminRoles-DAwl657q.d.ts → adminRoles-Cm513r1G.d.ts} +2 -2
- package/dist/ai/index.cjs +2 -2
- package/dist/ai/index.d.cts +2 -2
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.js +2 -2
- package/dist/ai/types.d.cts +1 -1
- package/dist/ai/types.d.ts +1 -1
- package/dist/apps/index.cjs +3 -234
- package/dist/apps/index.d.cts +3 -221
- package/dist/apps/index.d.ts +3 -221
- package/dist/apps/index.js +1 -234
- package/dist/apps/types.d.cts +1 -2
- package/dist/apps/types.d.ts +1 -2
- package/dist/apps-BN7fWtSm.js +361 -0
- package/dist/apps-BN7fWtSm.js.map +1 -0
- package/dist/apps-C1x5IKNQ.cjs +376 -0
- package/dist/apps-C1x5IKNQ.cjs.map +1 -0
- package/dist/assets/index.cjs +1 -1
- package/dist/assets/index.d.cts +1 -1
- package/dist/assets/index.d.ts +1 -1
- package/dist/assets/index.js +1 -1
- package/dist/auth/index.cjs +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/types.d.cts +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/{auth-CvB4MukT.cjs → auth-AehUDNRK.cjs} +2 -2
- package/dist/{auth-CvB4MukT.cjs.map → auth-AehUDNRK.cjs.map} +1 -1
- package/dist/{auth-DYfQMQCs.js → auth-ZBQWCJPM.js} +2 -2
- package/dist/{auth-DYfQMQCs.js.map → auth-ZBQWCJPM.js.map} +1 -1
- package/dist/{authClient-oB5ydxWp.js → authClient-BM4L8XEN.js} +5 -5
- package/dist/{authClient-oB5ydxWp.js.map → authClient-BM4L8XEN.js.map} +1 -1
- package/dist/{authClient-DcKBpMcU.cjs → authClient-DspK50e7.cjs} +5 -5
- package/dist/{authClient-DcKBpMcU.cjs.map → authClient-DspK50e7.cjs.map} +1 -1
- package/dist/{authClient-Df3U4q_6.d.cts → authClient-NBi0pqD5.d.cts} +4 -4
- package/dist/{authClient-JtMVJWXY.d.ts → authClient-ij_Rm2Yn.d.ts} +4 -4
- package/dist/billing/index.cjs +2 -2
- package/dist/billing/index.d.cts +1 -1
- package/dist/billing/index.d.ts +1 -1
- package/dist/billing/index.js +2 -2
- package/dist/billing/types.d.cts +1 -1
- package/dist/billing/types.d.ts +1 -1
- package/dist/chat/index.cjs +3 -3
- package/dist/chat/index.d.cts +2 -2
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/index.js +3 -3
- package/dist/chat/types.d.cts +1 -1
- package/dist/chat/types.d.ts +1 -1
- package/dist/{componentId-b_qBbJEM.js → componentId-DZP1rBix.js} +54 -2
- package/dist/componentId-DZP1rBix.js.map +1 -0
- package/dist/{componentId-C8ZTXXDo.cjs → componentId-olp0tltf.cjs} +54 -2
- package/dist/componentId-olp0tltf.cjs.map +1 -0
- 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 -1
- package/dist/componentsMcp/types.d.cts +1 -1
- package/dist/componentsMcp/types.d.ts +1 -1
- package/dist/{componentsMcp-BrB4js6b.js → componentsMcp-CAmrCpzV.js} +3 -3
- package/dist/{componentsMcp-BrB4js6b.js.map → componentsMcp-CAmrCpzV.js.map} +1 -1
- package/dist/{componentsMcp-BaHy5iLr.cjs → componentsMcp-DXu-0Qt-.cjs} +3 -3
- package/dist/{componentsMcp-BaHy5iLr.cjs.map → componentsMcp-DXu-0Qt-.cjs.map} +1 -1
- package/dist/constants/index.cjs +2 -2
- package/dist/constants/index.d.cts +3 -3
- package/dist/constants/index.d.ts +3 -3
- package/dist/constants/index.js +2 -2
- package/dist/{constants-BMSHGwOR.js → constants-Dqi0ewGv.js} +3 -2
- package/dist/constants-Dqi0ewGv.js.map +1 -0
- package/dist/{constants-DhFQWQgy.cjs → constants-d0Do9NSN.cjs} +3 -2
- package/dist/constants-d0Do9NSN.cjs.map +1 -0
- package/dist/{createFetchClient-DEkUH662.cjs → createFetchClient-CDKSkd7i.cjs} +19 -1
- package/dist/{createFetchClient-DlGCbltR.js.map → createFetchClient-CDKSkd7i.cjs.map} +1 -1
- package/dist/{createFetchClient-DlGCbltR.js → createFetchClient-Dc_ZMuq7.js} +8 -2
- package/dist/createFetchClient-Dc_ZMuq7.js.map +1 -0
- package/dist/{createGenericFetchClient-wGxemBwR.js → createGenericFetchClient-Ba4E4T-Y.js} +2 -2
- package/dist/{createGenericFetchClient-wGxemBwR.js.map → createGenericFetchClient-Ba4E4T-Y.js.map} +1 -1
- package/dist/{createGenericFetchClient-2oU-PXVo.cjs → createGenericFetchClient-BuYzzV_D.cjs} +2 -2
- package/dist/{createGenericFetchClient-2oU-PXVo.cjs.map → createGenericFetchClient-BuYzzV_D.cjs.map} +1 -1
- package/dist/{createOpenapiFetchClient-Bhz62MUE.js → createOpenapiFetchClient-DSk29o_s.js} +2 -2
- package/dist/{createOpenapiFetchClient-Bhz62MUE.js.map → createOpenapiFetchClient-DSk29o_s.js.map} +1 -1
- package/dist/{createOpenapiFetchClient-DL9w7vU-.cjs → createOpenapiFetchClient-dkssExkU.cjs} +2 -2
- package/dist/{createOpenapiFetchClient-DL9w7vU-.cjs.map → createOpenapiFetchClient-dkssExkU.cjs.map} +1 -1
- package/dist/dataScience/index.cjs +60 -4
- package/dist/dataScience/index.cjs.map +1 -0
- package/dist/dataScience/index.d.cts +105 -3
- package/dist/dataScience/index.d.ts +105 -3
- package/dist/dataScience/index.js +60 -3
- package/dist/dataScience/index.js.map +1 -0
- package/dist/dataScience/types.d.cts +2 -3
- package/dist/dataScience/types.d.ts +2 -3
- package/dist/developerPortal/index.cjs +1 -1
- package/dist/developerPortal/index.d.cts +2 -2
- package/dist/developerPortal/index.d.ts +2 -2
- package/dist/developerPortal/index.js +1 -1
- package/dist/developerPortal/types.d.cts +1 -1
- package/dist/developerPortal/types.d.ts +1 -1
- package/dist/{developerPortalClient-BfRxYrWj.cjs → developerPortalClient-BcK9F-Fs.cjs} +3 -3
- package/dist/{developerPortalClient-BfRxYrWj.cjs.map → developerPortalClient-BcK9F-Fs.cjs.map} +1 -1
- package/dist/{developerPortalClient-D9XOYwWF.js → developerPortalClient-CzCJ5sE3.js} +3 -3
- package/dist/{developerPortalClient-D9XOYwWF.js.map → developerPortalClient-CzCJ5sE3.js.map} +1 -1
- package/dist/domain/permissions/index.d.cts +1 -1
- package/dist/domain/permissions/index.d.ts +1 -1
- package/dist/editor/index.cjs +2 -2
- package/dist/editor/index.d.cts +2 -2
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +2 -2
- package/dist/editor/types.d.cts +1 -1
- package/dist/editor/types.d.ts +1 -1
- package/dist/encryption/index.cjs +1 -1
- package/dist/encryption/index.d.cts +1 -1
- package/dist/encryption/index.d.ts +1 -1
- package/dist/encryption/index.js +1 -1
- package/dist/encryption/types.d.cts +1 -1
- package/dist/encryption/types.d.ts +1 -1
- package/dist/import/index.cjs +1 -1
- package/dist/import/index.d.cts +3 -3
- package/dist/import/index.d.ts +3 -3
- package/dist/import/index.js +1 -1
- package/dist/{import-CABlFMQX.cjs → import-DHq6q3Fm.cjs} +3 -3
- package/dist/{import-CABlFMQX.cjs.map → import-DHq6q3Fm.cjs.map} +1 -1
- package/dist/{import-CT1Ce5Rp.js → import-DxN6CJzJ.js} +3 -3
- package/dist/{import-CT1Ce5Rp.js.map → import-DxN6CJzJ.js.map} +1 -1
- package/dist/{index-Db266tLz.d.cts → index-81wn1jc3.d.cts} +4 -4
- package/dist/{index-xX8-Stoq.d.cts → index-8QhOqFLY.d.cts} +4 -4
- package/dist/{index-DjSthn8d.d.ts → index-B5rELADq.d.cts} +55 -2
- package/dist/{index-qJ2IjXIM.d.cts → index-B7el5pJU.d.cts} +71 -151
- package/dist/index-B8K-Bbdq.d.cts +220 -0
- package/dist/{index-DQagqTVa.d.cts → index-BGE3eZfd.d.cts} +3 -3
- package/dist/{index-DVBQgFg0.d.ts → index-BVe4S2CK.d.ts} +4 -4
- package/dist/{index-CbSh3KFw.d.cts → index-BXgjPlZN.d.cts} +4 -4
- package/dist/{index-BsT_cBJd.d.ts → index-C7JcNvbd.d.ts} +71 -151
- package/dist/{index-lTrNMlj6.d.ts → index-CEDjFidH.d.ts} +3 -3
- package/dist/{index-DgGpQsAT.d.cts → index-CNJBmCHM.d.cts} +4 -4
- package/dist/index-CQNwp6wX.d.ts +220 -0
- package/dist/{index-CuI8OI9E.d.ts → index-CZvBjQvl.d.ts} +4 -4
- package/dist/{index-Day1Yr5s.d.ts → index-CdeWTy8t.d.ts} +4 -4
- package/dist/{index-BfAcp7O2.d.ts → index-CveF5RFQ.d.ts} +3 -3
- package/dist/{index-m9-mN8Gg.d.ts → index-DLWMm1-T.d.ts} +4 -4
- package/dist/{index-BDPxm9qu.d.ts → index-DTGOEke4.d.ts} +3 -3
- package/dist/{index-C1ndNdrN.d.cts → index-Df8lZNSH.d.cts} +3 -3
- package/dist/{index-AA3MRfRn.d.cts → index-Dhyrg5zd.d.ts} +55 -2
- package/dist/{index-D1mduJne.d.cts → index-FrsEkDvX.d.cts} +7 -2
- package/dist/{index-D1mduJne.d.ts → index-FrsEkDvX.d.ts} +7 -2
- package/dist/{index-DIPMzH--.d.ts → index-JoKfPQND.d.ts} +4 -4
- package/dist/{index-xhzuWloV.d.cts → index-d9zxFmNI.d.cts} +4 -4
- package/dist/{index-z-2okomN.d.cts → index-iFCann29.d.cts} +3 -3
- package/dist/index.cjs +45 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +38 -33
- package/dist/index.js.map +1 -1
- package/dist/{isLoginPageRedirect-CoUxJi2x.cjs → isLoginPageRedirect-DUmsOC2o.cjs} +2 -2
- package/dist/{isLoginPageRedirect-CoUxJi2x.cjs.map → isLoginPageRedirect-DUmsOC2o.cjs.map} +1 -1
- package/dist/{isLoginPageRedirect-D-lqF_kZ.js → isLoginPageRedirect-lbeVmeB2.js} +2 -2
- package/dist/{isLoginPageRedirect-D-lqF_kZ.js.map → isLoginPageRedirect-lbeVmeB2.js.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 -1
- package/dist/kaiAgent/types.d.cts +1 -1
- package/dist/kaiAgent/types.d.ts +1 -1
- package/dist/{kaiAgent-CYU1Uda8.js → kaiAgent-D0MoKqXe.js} +5 -5
- package/dist/{kaiAgent-CYU1Uda8.js.map → kaiAgent-D0MoKqXe.js.map} +1 -1
- package/dist/{kaiAgent-CDhg0MAw.cjs → kaiAgent-De2T6G4G.cjs} +5 -5
- package/dist/{kaiAgent-CDhg0MAw.cjs.map → kaiAgent-De2T6G4G.cjs.map} +1 -1
- package/dist/{kaiMemory-oir_qCo_.js → kaiMemory-B1wIwH8Y.js} +2 -2
- package/dist/{kaiMemory-oir_qCo_.js.map → kaiMemory-B1wIwH8Y.js.map} +1 -1
- package/dist/{kaiMemory-CkLQfJXD.cjs → kaiMemory-DZ6hXni_.cjs} +2 -2
- package/dist/{kaiMemory-CkLQfJXD.cjs.map → kaiMemory-DZ6hXni_.cjs.map} +1 -1
- package/dist/management/index.cjs +1 -1
- package/dist/management/index.d.cts +1 -1
- package/dist/management/index.d.ts +1 -1
- package/dist/management/index.js +1 -1
- package/dist/management/types.d.cts +2 -2
- package/dist/management/types.d.ts +2 -2
- package/dist/{management-BEGOEQxM.cjs → management-CUXgB2rb.cjs} +6 -6
- package/dist/{management-BEGOEQxM.cjs.map → management-CUXgB2rb.cjs.map} +1 -1
- package/dist/{management-BcGHyxAP.js → management-Cz5ut18k.js} +6 -6
- package/dist/{management-BcGHyxAP.js.map → management-Cz5ut18k.js.map} +1 -1
- package/dist/metastore/index.cjs +1 -1
- package/dist/metastore/index.d.cts +1 -1
- package/dist/metastore/index.d.ts +1 -1
- package/dist/metastore/index.js +1 -1
- package/dist/metastore/types.d.cts +1 -1
- package/dist/metastore/types.d.ts +1 -1
- package/dist/{metastore-DeRQ2VIv.cjs → metastore-CV4DUDxP.cjs} +4 -4
- package/dist/{metastore-DeRQ2VIv.cjs.map → metastore-CV4DUDxP.cjs.map} +1 -1
- package/dist/{metastore-CGsgxjng.js → metastore-CkqFnEfu.js} +4 -4
- package/dist/{metastore-CGsgxjng.js.map → metastore-CkqFnEfu.js.map} +1 -1
- package/dist/microsoftGraph/index.cjs +2 -2
- package/dist/microsoftGraph/index.d.cts +2 -2
- package/dist/microsoftGraph/index.d.ts +2 -2
- package/dist/microsoftGraph/index.js +2 -2
- package/dist/microsoftGraph/types.d.cts +1 -1
- package/dist/microsoftGraph/types.d.ts +1 -1
- package/dist/{middleware-8zaJWcyU.js → middleware-DxGv7DG8.js} +2 -2
- package/dist/{middleware-8zaJWcyU.js.map → middleware-DxGv7DG8.js.map} +1 -1
- package/dist/{middleware-B9RNuLfD.cjs → middleware-vIaPDtQI.cjs} +2 -2
- package/dist/{middleware-B9RNuLfD.cjs.map → middleware-vIaPDtQI.cjs.map} +1 -1
- package/dist/notifications/index.cjs +3 -3
- package/dist/notifications/index.d.cts +2 -2
- package/dist/notifications/index.d.ts +2 -2
- package/dist/notifications/index.js +3 -3
- package/dist/notifications/types.d.cts +1 -1
- package/dist/notifications/types.d.ts +1 -1
- package/dist/oauth/index.cjs +1 -1
- package/dist/oauth/index.d.cts +2 -2
- package/dist/oauth/index.d.ts +2 -2
- package/dist/oauth/index.js +1 -1
- package/dist/oauth/types.d.cts +1 -1
- package/dist/oauth/types.d.ts +1 -1
- package/dist/{oauth-B5Biqz21.cjs → oauth-CSBChWuf.cjs} +5 -5
- package/dist/{oauth-B5Biqz21.cjs.map → oauth-CSBChWuf.cjs.map} +1 -1
- package/dist/{oauth-ByCdISsV.js → oauth-DOveZKUv.js} +5 -5
- package/dist/{oauth-ByCdISsV.js.map → oauth-DOveZKUv.js.map} +1 -1
- package/dist/omnisearch/index.cjs +2 -2
- package/dist/omnisearch/index.d.cts +2 -2
- package/dist/omnisearch/index.d.ts +2 -2
- package/dist/omnisearch/index.js +2 -2
- package/dist/omnisearch/types.d.cts +1 -1
- package/dist/omnisearch/types.d.ts +1 -1
- package/dist/{project-UHZGFmmG.d.cts → project-BGk9CtOq.d.cts} +3 -3
- package/dist/{project-iBm4cIIR.d.ts → project-DS0HOV3M.d.ts} +3 -3
- package/dist/queryService/index.cjs +1 -1
- package/dist/queryService/index.d.cts +2 -2
- package/dist/queryService/index.d.ts +2 -2
- package/dist/queryService/index.js +1 -1
- package/dist/queryService/types.d.cts +1 -1
- package/dist/queryService/types.d.ts +1 -1
- package/dist/queryService-C3BQ6GKW.cjs +214 -0
- package/dist/queryService-C3BQ6GKW.cjs.map +1 -0
- package/dist/queryService-DQHtHy2-.js +209 -0
- package/dist/queryService-DQHtHy2-.js.map +1 -0
- package/dist/queue/index.cjs +1 -1
- package/dist/queue/index.d.cts +3 -3
- package/dist/queue/index.d.ts +3 -3
- package/dist/queue/index.js +1 -1
- package/dist/queue/types.d.cts +1 -1
- package/dist/queue/types.d.ts +1 -1
- package/dist/{queue-BiIs9fX4.js → queue-6cywDnA-.js} +5 -5
- package/dist/{queue-BiIs9fX4.js.map → queue-6cywDnA-.js.map} +1 -1
- package/dist/{queue-CBi9Q8vp.cjs → queue-J2uXzXR9.cjs} +5 -5
- package/dist/{queue-CBi9Q8vp.cjs.map → queue-J2uXzXR9.cjs.map} +1 -1
- package/dist/scheduler/index.cjs +3 -3
- package/dist/scheduler/index.d.cts +2 -2
- package/dist/scheduler/index.d.ts +2 -2
- package/dist/scheduler/index.js +3 -3
- package/dist/scheduler/types.d.cts +1 -1
- package/dist/scheduler/types.d.ts +1 -1
- package/dist/sdk/configurations/index.cjs +3 -3
- package/dist/sdk/configurations/index.cjs.map +1 -1
- package/dist/sdk/configurations/index.d.cts +4 -4
- package/dist/sdk/configurations/index.d.ts +4 -4
- package/dist/sdk/configurations/index.js +3 -3
- package/dist/sdk/configurations/index.js.map +1 -1
- package/dist/sdk/developerPortal/index.cjs +3 -3
- package/dist/sdk/developerPortal/index.d.cts +3 -3
- package/dist/sdk/developerPortal/index.d.ts +3 -3
- package/dist/sdk/developerPortal/index.js +3 -3
- package/dist/sdk/kaiMemory/index.cjs +1 -1
- package/dist/sdk/kaiMemory/index.d.cts +1 -1
- package/dist/sdk/kaiMemory/index.d.ts +1 -1
- package/dist/sdk/kaiMemory/index.js +1 -1
- package/dist/sdk/kaiMemory/types.d.cts +1 -1
- package/dist/sdk/kaiMemory/types.d.ts +1 -1
- package/dist/sdk/queryService/index.d.cts +1 -1
- package/dist/sdk/queryService/index.d.ts +1 -1
- package/dist/sdk/semanticLayer/index.d.cts +1 -1
- package/dist/sdk/semanticLayer/index.d.ts +1 -1
- package/dist/sdk/semanticLayer/types.d.cts +1 -1
- package/dist/sdk/semanticLayer/types.d.ts +1 -1
- package/dist/sdk/tag/index.d.cts +2 -2
- package/dist/sdk/tag/index.d.ts +2 -2
- package/dist/sdk/tag/types.d.cts +1 -1
- package/dist/sdk/tag/types.d.ts +1 -1
- package/dist/sdk/vault/index.d.cts +1 -1
- package/dist/sdk/vault/index.d.ts +1 -1
- package/dist/status/index.cjs +1 -1
- package/dist/status/index.d.cts +1 -1
- package/dist/status/index.d.ts +1 -1
- package/dist/status/index.js +1 -1
- package/dist/storage/index.cjs +9 -7
- package/dist/storage/index.d.cts +4 -4
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.js +6 -6
- package/dist/storage/types.d.cts +5 -5
- package/dist/storage/types.d.ts +5 -5
- package/dist/{storage-BpOLWT6h.js → storage--2FvvLAw.js} +7 -7
- package/dist/{storage-BpOLWT6h.js.map → storage--2FvvLAw.js.map} +1 -1
- package/dist/{storage-KJ5Ki_ma.cjs → storage-BMrYlyLB.cjs} +7 -7
- package/dist/{storage-KJ5Ki_ma.cjs.map → storage-BMrYlyLB.cjs.map} +1 -1
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.d.cts +2 -2
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.js +3 -3
- package/dist/stream/types.d.cts +1 -1
- package/dist/stream/types.d.ts +1 -1
- package/dist/syncActions/index.cjs +1 -1
- package/dist/syncActions/index.d.cts +2 -2
- package/dist/syncActions/index.d.ts +2 -2
- package/dist/syncActions/index.js +1 -1
- package/dist/syncActions/types.d.cts +1 -1
- package/dist/syncActions/types.d.ts +1 -1
- package/dist/{syncActions-BcX3jm2E.cjs → syncActions-DToUhyP3.cjs} +6 -6
- package/dist/{syncActions-BcX3jm2E.cjs.map → syncActions-DToUhyP3.cjs.map} +1 -1
- package/dist/{syncActions-giPLTfje.js → syncActions-DV_aObTQ.js} +6 -6
- package/dist/{syncActions-giPLTfje.js.map → syncActions-DV_aObTQ.js.map} +1 -1
- package/dist/telemetry/index.cjs +3 -3
- package/dist/telemetry/index.d.cts +2 -2
- package/dist/telemetry/index.d.ts +2 -2
- package/dist/telemetry/index.js +3 -3
- package/dist/telemetry/types.d.cts +1 -1
- package/dist/telemetry/types.d.ts +1 -1
- package/dist/{transientRetries-BKqmb85B.js → transientRetries-BORv47mH.js} +2 -2
- package/dist/{transientRetries-BKqmb85B.js.map → transientRetries-BORv47mH.js.map} +1 -1
- package/dist/{transientRetries-CM7rAEXQ.cjs → transientRetries-CBorl4Ue.cjs} +2 -2
- package/dist/{transientRetries-CM7rAEXQ.cjs.map → transientRetries-CBorl4Ue.cjs.map} +1 -1
- package/dist/{types-BWMOK6eL.d.cts → types-B4Vwz45w.d.cts} +2 -2
- package/dist/{types-Dryq2GGE.d.cts → types-B4ezB18r.d.cts} +2 -2
- package/dist/{types-Bdl7EFMc.d.ts → types-B6JcEPEu.d.ts} +2 -2
- package/dist/{types-eFi8xJIM.d.cts → types-B6f6LpZ_.d.cts} +2 -2
- package/dist/{types-C9okze_R.d.ts → types-BD0B1KQ6.d.ts} +3 -26
- package/dist/{types-DeyXJzWz.d.cts → types-BEw98Dd2.d.cts} +2 -2
- package/dist/{types-1IBnjBVJ.d.cts → types-BVJmcoqA.d.cts} +2 -2
- package/dist/{types-B1qe1etN.d.cts → types-BljDxuWG.d.cts} +3 -3
- package/dist/{types-BiDdBXSm.d.ts → types-Bp8G9yta.d.ts} +2 -2
- package/dist/{types-PZzNANiS.d.cts → types-Bv2Ds1hL.d.cts} +2 -2
- package/dist/{types-D-tJt0hQ.d.cts → types-BynQKst1.d.cts} +2 -2
- package/dist/{types-BuclMPeY.d.cts → types-C5B3Pfob.d.cts} +2 -2
- package/dist/{types-DNgazFnF.d.cts → types-CIlBSV99.d.cts} +2 -2
- package/dist/{types-DschSZHf.d.cts → types-CKdNf_2k.d.cts} +3 -3
- package/dist/{types-B0e-no6u.d.ts → types-CLtYOszN.d.cts} +20 -3
- package/dist/{types-Du5o-tud.d.ts → types-CQYyULrw.d.ts} +2 -2
- package/dist/{types-BrEVh0WE.d.cts → types-CRC4lbPw.d.cts} +8 -4
- package/dist/{types-CxEJ77m3.d.cts → types-CSE8bHiq.d.cts} +3 -3
- package/dist/{types-DRCttnIN.d.ts → types-CTYTMXXj.d.ts} +2 -2
- package/dist/{types-6T04_qUf.d.ts → types-CepTvkfm.d.ts} +2 -2
- package/dist/{types-DHMxPJZq.d.cts → types-Cf0WE6qK.d.cts} +2 -2
- package/dist/{types-DwbTiyhZ.d.cts → types-ChOJ-Az7.d.cts} +2 -2
- package/dist/{types-wYrC2boT.d.ts → types-Cr6WA6CN.d.ts} +2 -2
- package/dist/{types-D6lre27s.d.ts → types-CsVRsObb.d.ts} +2 -2
- package/dist/{types-CcGp6O3B.d.cts → types-D-ufoskb.d.cts} +2 -2
- package/dist/{types-LconaX98.d.cts → types-D2hhEGem.d.cts} +2 -2
- package/dist/{types-inG9y3dP.d.ts → types-D5bxXqEU.d.ts} +2 -2
- package/dist/{types-BE8abIig.d.cts → types-DKKHKj19.d.cts} +2 -2
- package/dist/{types-E8tzafsk.d.cts → types-DNwIMEuB.d.cts} +3 -26
- package/dist/{types-DtOfhDzz.d.ts → types-DSWIIMdv.d.ts} +3 -3
- package/dist/{types-Bat0SIZA.d.cts → types-DU8aPTFW.d.cts} +2 -2
- package/dist/{types-B8k1DqlU.d.ts → types-DX1Dz0xK.d.ts} +2 -2
- package/dist/{types-ZZwdKCBl.d.ts → types-DbthI3r-.d.ts} +2 -2
- package/dist/{types-B3ri-iiC.d.ts → types-DjSjUKUl.d.ts} +2 -2
- package/dist/{types-YpOm4yXE.d.cts → types-DjWubjvP.d.cts} +2 -2
- package/dist/{types-CRubbBcU.d.cts → types-Do3__S4Q.d.cts} +2 -2
- package/dist/{types-DKSUG2dZ.d.ts → types-DoSZQ1Bi.d.ts} +8 -4
- package/dist/{types-CWcdaq-K.d.ts → types-Dsf7CYmm.d.ts} +2 -2
- package/dist/{types-CPWjRdnj.d.cts → types-Ey59ZILC.d.ts} +20 -3
- package/dist/{types--Rp5wvaz.d.ts → types-OHt0D_f2.d.ts} +2 -2
- package/dist/{types-Cr5lyI99.d.ts → types-Rrcx-8LM.d.ts} +2 -2
- package/dist/{types-DUpVIuk7.d.ts → types-Tg3euEN_.d.ts} +2 -2
- package/dist/{types-37vwxse4.d.cts → types-Y4e8GGa3.d.cts} +2 -2
- package/dist/{types-DJzTVMu1.d.ts → types-d5Bt8Mr3.d.ts} +2 -2
- package/dist/{types-jjOulnni.d.ts → types-dU3EA8gk.d.ts} +2 -2
- package/dist/{types-ir7T2a9a.d.ts → types-iU1Sc1IM.d.ts} +3 -3
- package/dist/{types-zPY-XGnM.d.ts → types-kGZQQcIK.d.ts} +2 -2
- package/dist/{types-xzt_2H63.d.ts → types-zlYUn0oi.d.ts} +3 -3
- package/dist/{validateConnectionStatus-DYwWeWVo.js → validateConnectionStatus-DV00sDmu.js} +3 -3
- package/dist/{validateConnectionStatus-DYwWeWVo.js.map → validateConnectionStatus-DV00sDmu.js.map} +1 -1
- package/dist/{validateConnectionStatus-BjemGI1e.cjs → validateConnectionStatus-ckaHcRx8.cjs} +3 -3
- package/dist/{validateConnectionStatus-BjemGI1e.cjs.map → validateConnectionStatus-ckaHcRx8.cjs.map} +1 -1
- package/dist/vault/index.cjs +4 -4
- package/dist/vault/index.d.cts +1 -1
- package/dist/vault/index.d.ts +1 -1
- package/dist/vault/index.js +4 -4
- package/dist/vault/types.d.cts +1 -1
- package/dist/vault/types.d.ts +1 -1
- package/package.json +2 -2
- package/surface/apps.md +3 -3
- package/surface/dataScience.md +2 -11
- package/surface/editor.md +5 -5
- package/surface/queue.md +1 -1
- package/dist/QueryJobError-Iq9O90Uh.js +0 -21
- package/dist/QueryJobError-Iq9O90Uh.js.map +0 -1
- package/dist/QueryJobError-Oy0fl4aw.cjs +0 -32
- package/dist/QueryJobError-Oy0fl4aw.cjs.map +0 -1
- package/dist/appLogs-CTvZAihm.d.ts +0 -8
- package/dist/appLogs-CnLNMH7M.d.cts +0 -8
- package/dist/appLogs-CoAWQGxs.cjs +0 -152
- package/dist/appLogs-CoAWQGxs.cjs.map +0 -1
- package/dist/appLogs-DFcPwVk8.js +0 -131
- package/dist/appLogs-DFcPwVk8.js.map +0 -1
- package/dist/apps/index.cjs.map +0 -1
- package/dist/apps/index.js.map +0 -1
- package/dist/componentId-C8ZTXXDo.cjs.map +0 -1
- package/dist/componentId-b_qBbJEM.js.map +0 -1
- package/dist/constants-BMSHGwOR.js.map +0 -1
- package/dist/constants-DhFQWQgy.cjs.map +0 -1
- package/dist/createFetchClient-DEkUH662.cjs.map +0 -1
- package/dist/dataScience-CXmkEOAi.js +0 -118
- package/dist/dataScience-CXmkEOAi.js.map +0 -1
- package/dist/dataScience-CufjHPSd.cjs +0 -123
- package/dist/dataScience-CufjHPSd.cjs.map +0 -1
- package/dist/index-BZDxWvZW.d.ts +0 -214
- package/dist/index-ClIV2Lch.d.cts +0 -214
- package/dist/queryService-Cg-eMysa.cjs +0 -126
- package/dist/queryService-Cg-eMysa.cjs.map +0 -1
- package/dist/queryService-x8kq8Z2-.js +0 -121
- package/dist/queryService-x8kq8Z2-.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as GetExportResultsQuery, Q as ExportResultsResponse, Z as QueryJobPollOptions, at as JobStatusResponse, ct as PostQueryPath, dt as Statements, et as GetQueriesHistoryQuery, it as GetQueryResutsQuery, lt as QueryJobStatus, nt as GetQueryJobPath, ot as PostCancelQueryJobPath, rt as GetQueryResultsPath, st as PostQueryBody, tt as GetQueriesPath, ut as QueryResult } from "../index-B7el5pJU.cjs";
|
|
2
2
|
export { ExportResultsResponse, GetExportResultsQuery, GetQueriesHistoryQuery, GetQueriesPath, GetQueryJobPath, GetQueryResultsPath, GetQueryResutsQuery, JobStatusResponse, PostCancelQueryJobPath, PostQueryBody, PostQueryPath, type QueryJobPollOptions, QueryJobStatus, QueryResult, Statements };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as GetExportResultsQuery, Q as ExportResultsResponse, Z as QueryJobPollOptions, at as JobStatusResponse, ct as PostQueryPath, dt as Statements, et as GetQueriesHistoryQuery, it as GetQueryResutsQuery, lt as QueryJobStatus, nt as GetQueryJobPath, ot as PostCancelQueryJobPath, rt as GetQueryResultsPath, st as PostQueryBody, tt as GetQueriesPath, ut as QueryResult } from "../index-C7JcNvbd.js";
|
|
2
2
|
export { ExportResultsResponse, GetExportResultsQuery, GetQueriesHistoryQuery, GetQueriesPath, GetQueryJobPath, GetQueryResultsPath, GetQueryResutsQuery, JobStatusResponse, PostCancelQueryJobPath, PostQueryBody, PostQueryPath, type QueryJobPollOptions, QueryJobStatus, QueryResult, Statements };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
const require_createFetchClient = require("./createFetchClient-CDKSkd7i.cjs");
|
|
2
|
+
const require_RowLevelSecurityError = require("./RowLevelSecurityError-RK_NhhAx.cjs");
|
|
3
|
+
const require_ValidationError = require("./ValidationError-BXcFX4nD.cjs");
|
|
4
|
+
const require_createGenericFetchClient = require("./createGenericFetchClient-BuYzzV_D.cjs");
|
|
5
|
+
const require_createOpenapiFetchClient = require("./createOpenapiFetchClient-dkssExkU.cjs");
|
|
6
|
+
const require_transientRetries = require("./transientRetries-CBorl4Ue.cjs");
|
|
7
|
+
const require_auth = require("./auth-AehUDNRK.cjs");
|
|
8
|
+
// src/clients/queryService/auth.ts
|
|
9
|
+
const PRINTABLE_ASCII_WITHOUT_SPACES = /^[\x21-\x7E]+$/;
|
|
10
|
+
const requireToken = (token) => {
|
|
11
|
+
if (typeof token !== "string" || !PRINTABLE_ASCII_WITHOUT_SPACES.test(token)) throw new require_ValidationError.ValidationError("token must be non-empty printable ASCII without spaces");
|
|
12
|
+
return token;
|
|
13
|
+
};
|
|
14
|
+
const readToken = async (source) => requireToken(typeof source === "function" ? await source() : source);
|
|
15
|
+
const hasCallback = (credential) => typeof credential.token === "function" || credential.type === "app-user-token" && typeof credential.storageToken === "function";
|
|
16
|
+
/**
|
|
17
|
+
* Fixed headers for a credential with only string tokens.
|
|
18
|
+
*
|
|
19
|
+
* - `app-user-token` tokens are checked here, so an empty user token throws at client creation.
|
|
20
|
+
* - `sapi-token` / `bearer` strings go out unchecked: service clients send an empty `bearer` token
|
|
21
|
+
* that their own middleware replaces.
|
|
22
|
+
*/
|
|
23
|
+
const staticHeaders = (credential) => {
|
|
24
|
+
const { token } = credential;
|
|
25
|
+
if (typeof token !== "string") return {};
|
|
26
|
+
if (credential.type === "app-user-token") return typeof credential.storageToken === "string" ? {
|
|
27
|
+
[require_createFetchClient.KeboolaHttpHeader.STORAGE_API_TOKEN]: requireToken(credential.storageToken),
|
|
28
|
+
[require_createFetchClient.APP_USER_TOKEN_HEADER]: requireToken(token)
|
|
29
|
+
} : {};
|
|
30
|
+
return require_auth.createAuthHeaders({
|
|
31
|
+
...credential,
|
|
32
|
+
token
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const resolvedHeaders = async (credential) => {
|
|
36
|
+
const token = await readToken(credential.token);
|
|
37
|
+
if (credential.type === "app-user-token") return {
|
|
38
|
+
[require_createFetchClient.KeboolaHttpHeader.STORAGE_API_TOKEN]: await readToken(credential.storageToken),
|
|
39
|
+
[require_createFetchClient.APP_USER_TOKEN_HEADER]: token
|
|
40
|
+
};
|
|
41
|
+
if (credential.type === "bearer" && (!Number.isInteger(credential.projectId) || credential.projectId <= 0)) throw new require_ValidationError.ValidationError("projectId must be a positive integer");
|
|
42
|
+
return require_auth.createAuthHeaders({
|
|
43
|
+
...credential,
|
|
44
|
+
token
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const CREDENTIAL_HEADER_NAMES = [
|
|
48
|
+
require_createFetchClient.KeboolaHttpHeader.STORAGE_API_TOKEN,
|
|
49
|
+
require_createFetchClient.KeboolaHttpHeader.MANAGEMENT_API_TOKEN,
|
|
50
|
+
require_createFetchClient.KeboolaHttpHeader.PROJECT_ID,
|
|
51
|
+
require_createFetchClient.HttpHeader.AUTHORIZATION,
|
|
52
|
+
require_createFetchClient.APP_USER_TOKEN_HEADER
|
|
53
|
+
];
|
|
54
|
+
const createCredentialMiddleware = (provider) => (next) => async (request) => {
|
|
55
|
+
const credentialHeaders = await resolvedHeaders(await provider());
|
|
56
|
+
const { headers } = request.request;
|
|
57
|
+
for (const name of CREDENTIAL_HEADER_NAMES) headers.delete(name);
|
|
58
|
+
for (const [name, value] of Object.entries(credentialHeaders)) headers.set(name, value);
|
|
59
|
+
return next(request);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The Query Service client's credential setup for its `auth`.
|
|
63
|
+
*
|
|
64
|
+
* 1. A credential with only string tokens: default headers, set once (as `createAuthHeaders`).
|
|
65
|
+
* 2. A credential with a token callback, or a provider: no default headers; the innermost
|
|
66
|
+
* middleware resolves and checks every token on every attempt.
|
|
67
|
+
*/
|
|
68
|
+
const resolveAuth = (auth, middlewares) => {
|
|
69
|
+
if (typeof auth === "function") return {
|
|
70
|
+
headers: void 0,
|
|
71
|
+
middlewares: [...middlewares, createCredentialMiddleware(auth)]
|
|
72
|
+
};
|
|
73
|
+
if (hasCallback(auth)) return {
|
|
74
|
+
headers: void 0,
|
|
75
|
+
middlewares: [...middlewares, createCredentialMiddleware(() => auth)]
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
headers: staticHeaders(auth),
|
|
79
|
+
middlewares
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
// src/clients/queryService/poller.ts
|
|
83
|
+
const DEFAULT_POLL_INTERVAL = 2e3;
|
|
84
|
+
const createJobPoller = ({ getQueryJob }) => ({ init, interval, maxAttempts, timeout, signal }) => {
|
|
85
|
+
const retries = require_transientRetries.transientRetries();
|
|
86
|
+
return require_transientRetries.poller({
|
|
87
|
+
pollKey: ({ id }) => ["queryService.job", { id }],
|
|
88
|
+
init,
|
|
89
|
+
pollFn: async ({ init: { id }, signal: pollSignal }) => {
|
|
90
|
+
const job = await getQueryJob(id, pollSignal);
|
|
91
|
+
retries.reset();
|
|
92
|
+
return job;
|
|
93
|
+
},
|
|
94
|
+
isRetryable: retries.isRetryable,
|
|
95
|
+
until: ({ data }) => require_transientRetries.jobStatus.query.isTerminal(data.status),
|
|
96
|
+
failed: (job) => {
|
|
97
|
+
if (job.status !== "failed") return void 0;
|
|
98
|
+
const failedStatements = job.statements.filter((statement) => statement.status === "failed").map((statement) => ({
|
|
99
|
+
id: statement.id,
|
|
100
|
+
error: statement.error
|
|
101
|
+
}));
|
|
102
|
+
return new require_RowLevelSecurityError.QueryJobError(failedStatements[0]?.error ?? "Job failed", job.queryJobId, { failedStatements });
|
|
103
|
+
},
|
|
104
|
+
backoff: {
|
|
105
|
+
type: "constant",
|
|
106
|
+
interval: interval ?? DEFAULT_POLL_INTERVAL
|
|
107
|
+
},
|
|
108
|
+
maxAttempts,
|
|
109
|
+
timeout,
|
|
110
|
+
signal
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
// src/clients/queryService/validateStatus.ts
|
|
114
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
115
|
+
/**
|
|
116
|
+
* Status validation for Query Service, which reads a row-level security refusal as `RowLevelSecurityError`.
|
|
117
|
+
*
|
|
118
|
+
* - The fixed `exception` text is the only signal: `X-KBC-RLS-Mode` is not exposed through CORS,
|
|
119
|
+
* and a credentials 403 on a governed workspace carries that header too.
|
|
120
|
+
*/
|
|
121
|
+
const validateQueryServiceStatus = (apiResponse) => {
|
|
122
|
+
const { response, data } = apiResponse;
|
|
123
|
+
if (response.status === require_createFetchClient.HttpStatus.FORBIDDEN && isRecord(data) && data.exception === "Row-level security does not allow this query") return new require_RowLevelSecurityError.RowLevelSecurityError(apiResponse);
|
|
124
|
+
return require_createFetchClient.defaultValidateStatus(apiResponse);
|
|
125
|
+
};
|
|
126
|
+
// src/clients/queryService/queryServiceClient.ts
|
|
127
|
+
const createQueryServiceClient = ({ baseUrl, middlewares = [], auth }) => {
|
|
128
|
+
const client = require_createOpenapiFetchClient.createOpenapiFetchClient({
|
|
129
|
+
baseUrl,
|
|
130
|
+
...resolveAuth(auth, middlewares),
|
|
131
|
+
validateStatus: validateQueryServiceStatus
|
|
132
|
+
});
|
|
133
|
+
const genericClient = require_createGenericFetchClient.createGenericFetchClient({
|
|
134
|
+
baseUrl,
|
|
135
|
+
middlewares
|
|
136
|
+
});
|
|
137
|
+
const createQueryJob = async (branchId, workspaceId, body) => {
|
|
138
|
+
const { data } = await client.post("/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries", {
|
|
139
|
+
path: {
|
|
140
|
+
branchId,
|
|
141
|
+
workspaceId
|
|
142
|
+
},
|
|
143
|
+
body
|
|
144
|
+
});
|
|
145
|
+
return data;
|
|
146
|
+
};
|
|
147
|
+
const cancelQueryJob = async (queryJobId) => {
|
|
148
|
+
const { data } = await client.post("/api/v1/queries/{queryJobId}/cancel", {
|
|
149
|
+
path: { queryJobId },
|
|
150
|
+
body: { reason: "Cancelled by user" }
|
|
151
|
+
});
|
|
152
|
+
return data;
|
|
153
|
+
};
|
|
154
|
+
const getQueryJob = async (queryJobId, signal) => {
|
|
155
|
+
const { data } = await client.get("/api/v1/queries/{queryJobId}", { path: { queryJobId } }, { signal });
|
|
156
|
+
return data;
|
|
157
|
+
};
|
|
158
|
+
const getQueryResults = async (queryJobId, statementId, query) => {
|
|
159
|
+
const { data } = await client.get("/api/v1/queries/{queryJobId}/{statementId}/results", {
|
|
160
|
+
path: {
|
|
161
|
+
queryJobId,
|
|
162
|
+
statementId
|
|
163
|
+
},
|
|
164
|
+
query
|
|
165
|
+
});
|
|
166
|
+
return data;
|
|
167
|
+
};
|
|
168
|
+
const getQueryHistory = async (branchId, workspaceId, query) => {
|
|
169
|
+
const { data } = await client.get("/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries", {
|
|
170
|
+
path: {
|
|
171
|
+
branchId,
|
|
172
|
+
workspaceId
|
|
173
|
+
},
|
|
174
|
+
query
|
|
175
|
+
});
|
|
176
|
+
return data;
|
|
177
|
+
};
|
|
178
|
+
const exportResults = async (queryJobId, statementId, query, signal) => {
|
|
179
|
+
const { data, response } = await client.get("/api/v1/queries/{queryJobId}/{statementId}/export", {
|
|
180
|
+
path: {
|
|
181
|
+
queryJobId,
|
|
182
|
+
statementId
|
|
183
|
+
},
|
|
184
|
+
query
|
|
185
|
+
}, { signal });
|
|
186
|
+
return {
|
|
187
|
+
mimeType: response.headers.get(require_createFetchClient.HttpHeader.CONTENT_TYPE) ?? "text/csv",
|
|
188
|
+
content: data,
|
|
189
|
+
fileName: require_createFetchClient.parseContentDispositionHeader(response.headers.get(require_createFetchClient.HttpHeader.CONTENT_DISPOSITION))?.filename ?? "export.csv"
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const healthCheck = async (signal) => {
|
|
193
|
+
const { data } = await genericClient.get("/health-check", {}, { signal });
|
|
194
|
+
return data;
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
healthCheck,
|
|
198
|
+
poller: createJobPoller({ getQueryJob }),
|
|
199
|
+
createQueryJob,
|
|
200
|
+
cancelQueryJob,
|
|
201
|
+
getQueryJob,
|
|
202
|
+
getQueryResults,
|
|
203
|
+
getQueryHistory,
|
|
204
|
+
exportResults
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
Object.defineProperty(exports, "createQueryServiceClient", {
|
|
208
|
+
enumerable: true,
|
|
209
|
+
get: function() {
|
|
210
|
+
return createQueryServiceClient;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
//# sourceMappingURL=queryService-C3BQ6GKW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryService-C3BQ6GKW.cjs","names":["ValidationError","KeboolaHttpHeader","APP_USER_TOKEN_HEADER","createAuthHeaders","HttpHeader","transientRetries","poller","jobStatus","QueryJobError","HttpStatus","RowLevelSecurityError","defaultValidateStatus","createOpenapiFetchClient","createGenericFetchClient","HttpHeader","parseContentDispositionHeader"],"sources":["../src/clients/queryService/auth.ts","../src/clients/queryService/poller.ts","../src/clients/queryService/validateStatus.ts","../src/clients/queryService/queryServiceClient.ts"],"sourcesContent":["import { ValidationError } from '../../errors';\nimport { HttpHeader, type MiddlewareFn } from '../../fetchClient';\nimport { APP_USER_TOKEN_HEADER, KeboolaHttpHeader } from '../../internal';\nimport { createAuthHeaders } from '../auth';\n\n/** A token value, or a callback that returns the current one (read before every request). */\nexport type TokenSource = string | (() => string | Promise<string>);\n\n/** A data app user's token, sent as `X-Kbc-App-User-Token` together with the app's Storage token. */\nexport type AppUserTokenAuth = {\n type: 'app-user-token';\n token: TokenSource;\n storageToken: TokenSource;\n};\n\n/** One credential; a request carries exactly that credential's headers. */\nexport type QueryServiceCredential =\n | { type: 'sapi-token'; token: TokenSource }\n | { type: 'bearer'; token: TokenSource; projectId: number }\n | AppUserTokenAuth;\n\n/** Resolved before every request, retries included. */\nexport type QueryServiceCredentialProvider = () =>\n | QueryServiceCredential\n | Promise<QueryServiceCredential>;\n\nconst PRINTABLE_ASCII_WITHOUT_SPACES = /^[\\x21-\\x7E]+$/;\n\nconst requireToken = (token: unknown): string => {\n if (typeof token !== 'string' || !PRINTABLE_ASCII_WITHOUT_SPACES.test(token)) {\n throw new ValidationError('token must be non-empty printable ASCII without spaces');\n }\n return token;\n};\n\nconst readToken = async (source: TokenSource) =>\n requireToken(typeof source === 'function' ? await source() : source);\n\nconst hasCallback = (credential: QueryServiceCredential) =>\n typeof credential.token === 'function' ||\n (credential.type === 'app-user-token' && typeof credential.storageToken === 'function');\n\n/**\n * Fixed headers for a credential with only string tokens.\n *\n * - `app-user-token` tokens are checked here, so an empty user token throws at client creation.\n * - `sapi-token` / `bearer` strings go out unchecked: service clients send an empty `bearer` token\n * that their own middleware replaces.\n */\nconst staticHeaders = (credential: QueryServiceCredential): Record<string, string> => {\n const { token } = credential;\n if (typeof token !== 'string') return {};\n if (credential.type === 'app-user-token') {\n return typeof credential.storageToken === 'string'\n ? {\n [KeboolaHttpHeader.STORAGE_API_TOKEN]: requireToken(credential.storageToken),\n [APP_USER_TOKEN_HEADER]: requireToken(token),\n }\n : {};\n }\n return createAuthHeaders({ ...credential, token });\n};\n\nconst resolvedHeaders = async (\n credential: QueryServiceCredential,\n): Promise<Record<string, string>> => {\n const token = await readToken(credential.token);\n if (credential.type === 'app-user-token') {\n return {\n [KeboolaHttpHeader.STORAGE_API_TOKEN]: await readToken(credential.storageToken),\n [APP_USER_TOKEN_HEADER]: token,\n };\n }\n if (\n credential.type === 'bearer' &&\n (!Number.isInteger(credential.projectId) || credential.projectId <= 0)\n ) {\n throw new ValidationError('projectId must be a positive integer');\n }\n return createAuthHeaders({ ...credential, token });\n};\n\nconst CREDENTIAL_HEADER_NAMES = [\n KeboolaHttpHeader.STORAGE_API_TOKEN,\n KeboolaHttpHeader.MANAGEMENT_API_TOKEN,\n KeboolaHttpHeader.PROJECT_ID,\n HttpHeader.AUTHORIZATION,\n APP_USER_TOKEN_HEADER,\n];\n\nconst createCredentialMiddleware =\n (provider: QueryServiceCredentialProvider): MiddlewareFn =>\n (next) =>\n async (request) => {\n const credentialHeaders = await resolvedHeaders(await provider());\n const { headers } = request.request;\n for (const name of CREDENTIAL_HEADER_NAMES) headers.delete(name);\n for (const [name, value] of Object.entries(credentialHeaders)) headers.set(name, value);\n return next(request);\n };\n\n/**\n * The Query Service client's credential setup for its `auth`.\n *\n * 1. A credential with only string tokens: default headers, set once (as `createAuthHeaders`).\n * 2. A credential with a token callback, or a provider: no default headers; the innermost\n * middleware resolves and checks every token on every attempt.\n */\nexport const resolveAuth = (\n auth: QueryServiceCredential | QueryServiceCredentialProvider,\n middlewares: MiddlewareFn[],\n) => {\n if (typeof auth === 'function') {\n return { headers: undefined, middlewares: [...middlewares, createCredentialMiddleware(auth)] };\n }\n if (hasCallback(auth)) {\n return {\n headers: undefined,\n middlewares: [...middlewares, createCredentialMiddleware(() => auth)],\n };\n }\n return { headers: staticHeaders(auth), middlewares };\n};\n","import { jobStatus } from '../../domain/jobStatus';\nimport { QueryJobError } from '../../errors';\nimport { poller } from '../../utils/async';\nimport { transientRetries } from '../transientRetries';\n\nimport type { GetQueryJobPath, JobStatusResponse } from './types';\n\nconst DEFAULT_POLL_INTERVAL = 2000;\n\nexport type QueryJobPollOptions = {\n interval?: number;\n maxAttempts?: number;\n timeout?: number;\n signal?: AbortSignal;\n};\n\ntype GetQueryJob = (\n queryJobId: GetQueryJobPath['queryJobId'],\n signal?: AbortSignal,\n) => Promise<JobStatusResponse>;\n\n/**\n * Waits on a query job.\n *\n * - `init` is the job, or the request that yields it, so a caller hands over what `createQueryJob` gave it.\n * - Terminal is the job's own terminal set, not its statements': a `completed` job can still hold a\n * statement that failed, and what that means is the caller's business.\n */\ntype JobRef = { id: GetQueryJobPath['queryJobId'] };\n\nexport const createJobPoller =\n ({ getQueryJob }: { getQueryJob: GetQueryJob }) =>\n ({\n init,\n interval,\n maxAttempts,\n timeout,\n signal,\n }: QueryJobPollOptions & { init: JobRef | ((signal: AbortSignal) => Promise<JobRef>) }) => {\n const retries = transientRetries();\n\n return poller({\n pollKey: ({ id }) => ['queryService.job', { id }] as const,\n init,\n pollFn: async ({ init: { id }, signal: pollSignal }) => {\n const job = await getQueryJob(id, pollSignal);\n retries.reset();\n return job;\n },\n isRetryable: retries.isRetryable,\n until: ({ data }) => jobStatus.query.isTerminal(data.status),\n failed: (job) => {\n if (job.status !== 'failed') return undefined;\n const failedStatements = job.statements\n .filter((statement) => statement.status === 'failed')\n .map((statement) => ({ id: statement.id, error: statement.error }));\n\n return new QueryJobError(failedStatements[0]?.error ?? 'Job failed', job.queryJobId, {\n failedStatements,\n });\n },\n backoff: { type: 'constant', interval: interval ?? DEFAULT_POLL_INTERVAL },\n maxAttempts,\n timeout,\n signal,\n });\n };\n","import { RowLevelSecurityError } from '../../errors';\nimport { defaultValidateStatus, type ValidateStatusFn } from '../../fetchClient';\nimport { HttpStatus, ROW_LEVEL_SECURITY_DENIED_MESSAGE } from '../../internal';\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null;\n\n/**\n * Status validation for Query Service, which reads a row-level security refusal as `RowLevelSecurityError`.\n *\n * - The fixed `exception` text is the only signal: `X-KBC-RLS-Mode` is not exposed through CORS,\n * and a credentials 403 on a governed workspace carries that header too.\n */\nexport const validateQueryServiceStatus: ValidateStatusFn = (apiResponse) => {\n const { response, data } = apiResponse;\n\n if (\n response.status === HttpStatus.FORBIDDEN &&\n isRecord(data) &&\n data.exception === ROW_LEVEL_SECURITY_DENIED_MESSAGE\n ) {\n return new RowLevelSecurityError(apiResponse);\n }\n\n return defaultValidateStatus(apiResponse);\n};\n","import {\n createGenericFetchClient,\n createOpenapiFetchClient,\n HttpHeader,\n type MiddlewareFn,\n parseContentDispositionHeader,\n} from '../../fetchClient';\nimport type { ClientInitOptions } from '../types';\n\nimport type { paths } from './__generated__/schema';\nimport {\n type QueryServiceCredential,\n type QueryServiceCredentialProvider,\n resolveAuth,\n} from './auth';\nimport { createJobPoller } from './poller';\nimport type {\n ExportResultsResponse,\n GetExportResultsQuery,\n GetQueriesHistoryQuery,\n GetQueriesPath,\n GetQueryJobPath,\n GetQueryResultsPath,\n GetQueryResutsQuery,\n PostCancelQueryJobPath,\n PostQueryBody,\n PostQueryPath,\n} from './types';\nimport { validateQueryServiceStatus } from './validateStatus';\n\nexport type QueryServiceClientInitOptions = Omit<ClientInitOptions, 'auth' | 'middlewares'> & {\n auth: QueryServiceCredential | QueryServiceCredentialProvider;\n middlewares?: MiddlewareFn[];\n};\n\nexport const createQueryServiceClient = ({\n baseUrl,\n middlewares = [],\n auth,\n}: QueryServiceClientInitOptions) => {\n const client = createOpenapiFetchClient<paths>({\n baseUrl,\n ...resolveAuth(auth, middlewares),\n validateStatus: validateQueryServiceStatus,\n });\n const genericClient = createGenericFetchClient({ baseUrl, middlewares });\n\n const createQueryJob = async (\n branchId: PostQueryPath['branchId'],\n workspaceId: PostQueryPath['workspaceId'],\n body: PostQueryBody,\n ) => {\n const { data } = await client.post(\n '/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries',\n { path: { branchId, workspaceId }, body },\n );\n\n return data;\n };\n\n const cancelQueryJob = async (queryJobId: PostCancelQueryJobPath['queryJobId']) => {\n const { data } = await client.post('/api/v1/queries/{queryJobId}/cancel', {\n path: { queryJobId },\n body: { reason: 'Cancelled by user' },\n });\n\n return data;\n };\n\n const getQueryJob = async (queryJobId: GetQueryJobPath['queryJobId'], signal?: AbortSignal) => {\n const { data } = await client.get(\n '/api/v1/queries/{queryJobId}',\n { path: { queryJobId } },\n { signal },\n );\n\n return data;\n };\n\n const getQueryResults = async (\n queryJobId: GetQueryResultsPath['queryJobId'],\n statementId: GetQueryResultsPath['statementId'],\n query?: GetQueryResutsQuery,\n ) => {\n const { data } = await client.get('/api/v1/queries/{queryJobId}/{statementId}/results', {\n path: { queryJobId, statementId },\n query,\n });\n\n return data;\n };\n\n const getQueryHistory = async (\n branchId: GetQueriesPath['branchId'],\n workspaceId: GetQueriesPath['workspaceId'],\n query?: GetQueriesHistoryQuery,\n ) => {\n const { data } = await client.get(\n '/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries',\n {\n path: { branchId, workspaceId },\n query,\n },\n );\n\n return data;\n };\n\n const exportResults = async (\n queryJobId: GetQueryResultsPath['queryJobId'],\n statementId: GetQueryResultsPath['statementId'],\n query: GetExportResultsQuery,\n signal?: AbortSignal,\n ): Promise<ExportResultsResponse> => {\n const { data, response } = await client.get(\n '/api/v1/queries/{queryJobId}/{statementId}/export',\n {\n path: { queryJobId, statementId },\n query,\n },\n { signal },\n );\n\n const mimeType = response.headers.get(HttpHeader.CONTENT_TYPE) ?? 'text/csv';\n const contentDisposition = parseContentDispositionHeader(\n response.headers.get(HttpHeader.CONTENT_DISPOSITION),\n );\n\n return {\n mimeType,\n content: data,\n fileName: contentDisposition?.filename ?? 'export.csv',\n };\n };\n\n const healthCheck = async (signal?: AbortSignal) => {\n const { data } = await genericClient.get('/health-check', {}, { signal });\n\n return data;\n };\n\n // Every wait on a query job is the same wait, so it is the client's rather than a caller's.\n const poller = createJobPoller({ getQueryJob });\n\n return {\n healthCheck,\n poller,\n createQueryJob,\n cancelQueryJob,\n getQueryJob,\n getQueryResults,\n getQueryHistory,\n exportResults,\n };\n};\n"],"mappings":";;;;;;;;AA0BA,MAAM,iCAAiC;AAEvC,MAAM,gBAAgB,UAA2B;CAC/C,IAAI,OAAO,UAAU,YAAY,CAAC,+BAA+B,KAAK,KAAK,GACzE,MAAM,IAAIA,wBAAAA,gBAAgB,wDAAwD;CAEpF,OAAO;AACT;AAEA,MAAM,YAAY,OAAO,WACvB,aAAa,OAAO,WAAW,aAAa,MAAM,OAAO,IAAI,MAAM;AAErE,MAAM,eAAe,eACnB,OAAO,WAAW,UAAU,cAC3B,WAAW,SAAS,oBAAoB,OAAO,WAAW,iBAAiB;;;;;;;;AAS9E,MAAM,iBAAiB,eAA+D;CACpF,MAAM,EAAE,UAAU;CAClB,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC;CACvC,IAAI,WAAW,SAAS,kBACtB,OAAO,OAAO,WAAW,iBAAiB,WACtC;GACGC,0BAAAA,kBAAkB,oBAAoB,aAAa,WAAW,YAAY;GAC1EC,0BAAAA,wBAAwB,aAAa,KAAK;CAC7C,IACA,CAAC;CAEP,OAAOC,aAAAA,kBAAkB;EAAE,GAAG;EAAY;CAAM,CAAC;AACnD;AAEA,MAAM,kBAAkB,OACtB,eACoC;CACpC,MAAM,QAAQ,MAAM,UAAU,WAAW,KAAK;CAC9C,IAAI,WAAW,SAAS,kBACtB,OAAO;GACJF,0BAAAA,kBAAkB,oBAAoB,MAAM,UAAU,WAAW,YAAY;GAC7EC,0BAAAA,wBAAwB;CAC3B;CAEF,IACE,WAAW,SAAS,aACnB,CAAC,OAAO,UAAU,WAAW,SAAS,KAAK,WAAW,aAAa,IAEpE,MAAM,IAAIF,wBAAAA,gBAAgB,sCAAsC;CAEl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AA2C,WAAyB;EAC7F,MAAM,EAAE,SAAS,MAAM,OAAO,IAC5B,gCACA,EAAE,MAAM,EAAE,WAAW,EAAE,GACvB,EAAE,OAAO,CACX;EAEA,OAAO;CACT;CAEA,MAAM,kBAAkB,OACtB,YACA,aACA,UACG;EACH,MAAM,EAAE,SAAS,MAAM,OAAO,IAAI,sDAAsD;GACtF,MAAM;IAAE;IAAY;GAAY;GAChC;EACF,CAAC;EAED,OAAO;CACT;CAEA,MAAM,kBAAkB,OACtB,UACA,aACA,UACG;EACH,MAAM,EAAE,SAAS,MAAM,OAAO,IAC5B,gEACA;GACE,MAAM;IAAE;IAAU;GAAY;GAC9B;EACF,CACF;EAEA,OAAO;CACT;CAEA,MAAM,gBAAgB,OACpB,YACA,aACA,OACA,WACmC;EACnC,MAAM,EAAE,MAAM,aAAa,MAAM,OAAO,IACtC,qDACA;GACE,MAAM;IAAE;IAAY;GAAY;GAChC;EACF,GACA,EAAE,OAAO,CACX;EAOA,OAAO;GACL,UANe,SAAS,QAAQ,IAAIC,0BAAAA,WAAW,YAAY,KAAK;GAOhE,SAAS;GACT,UAPyBC,0BAAAA,8BACzB,SAAS,QAAQ,IAAID,0BAAAA,WAAW,mBAAmB,CAMxB,CAAC,EAAE,YAAY;EAC5C;CACF;CAEA,MAAM,cAAc,OAAO,WAAyB;EAClD,MAAM,EAAE,SAAS,MAAM,cAAc,IAAI,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC;EAExE,OAAO;CACT;CAKA,OAAO;EACL;EACA,QAJa,gBAAgB,EAAE,YAAY,CAItC;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { _ as HttpStatus, c as defaultValidateStatus, f as parseContentDispositionHeader, m as APP_USER_TOKEN_HEADER, s as HttpHeader, v as KeboolaHttpHeader } from "./createFetchClient-Dc_ZMuq7.js";
|
|
2
|
+
import { r as QueryJobError, t as RowLevelSecurityError } from "./RowLevelSecurityError-CObFqj3E.js";
|
|
3
|
+
import { t as ValidationError } from "./ValidationError-BsdFDGY2.js";
|
|
4
|
+
import { t as createGenericFetchClient } from "./createGenericFetchClient-Ba4E4T-Y.js";
|
|
5
|
+
import { t as createOpenapiFetchClient } from "./createOpenapiFetchClient-DSk29o_s.js";
|
|
6
|
+
import { a as poller, n as jobStatus, t as transientRetries } from "./transientRetries-BORv47mH.js";
|
|
7
|
+
import { t as createAuthHeaders } from "./auth-ZBQWCJPM.js";
|
|
8
|
+
// src/clients/queryService/auth.ts
|
|
9
|
+
const PRINTABLE_ASCII_WITHOUT_SPACES = /^[\x21-\x7E]+$/;
|
|
10
|
+
const requireToken = (token) => {
|
|
11
|
+
if (typeof token !== "string" || !PRINTABLE_ASCII_WITHOUT_SPACES.test(token)) throw new ValidationError("token must be non-empty printable ASCII without spaces");
|
|
12
|
+
return token;
|
|
13
|
+
};
|
|
14
|
+
const readToken = async (source) => requireToken(typeof source === "function" ? await source() : source);
|
|
15
|
+
const hasCallback = (credential) => typeof credential.token === "function" || credential.type === "app-user-token" && typeof credential.storageToken === "function";
|
|
16
|
+
/**
|
|
17
|
+
* Fixed headers for a credential with only string tokens.
|
|
18
|
+
*
|
|
19
|
+
* - `app-user-token` tokens are checked here, so an empty user token throws at client creation.
|
|
20
|
+
* - `sapi-token` / `bearer` strings go out unchecked: service clients send an empty `bearer` token
|
|
21
|
+
* that their own middleware replaces.
|
|
22
|
+
*/
|
|
23
|
+
const staticHeaders = (credential) => {
|
|
24
|
+
const { token } = credential;
|
|
25
|
+
if (typeof token !== "string") return {};
|
|
26
|
+
if (credential.type === "app-user-token") return typeof credential.storageToken === "string" ? {
|
|
27
|
+
[KeboolaHttpHeader.STORAGE_API_TOKEN]: requireToken(credential.storageToken),
|
|
28
|
+
[APP_USER_TOKEN_HEADER]: requireToken(token)
|
|
29
|
+
} : {};
|
|
30
|
+
return createAuthHeaders({
|
|
31
|
+
...credential,
|
|
32
|
+
token
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const resolvedHeaders = async (credential) => {
|
|
36
|
+
const token = await readToken(credential.token);
|
|
37
|
+
if (credential.type === "app-user-token") return {
|
|
38
|
+
[KeboolaHttpHeader.STORAGE_API_TOKEN]: await readToken(credential.storageToken),
|
|
39
|
+
[APP_USER_TOKEN_HEADER]: token
|
|
40
|
+
};
|
|
41
|
+
if (credential.type === "bearer" && (!Number.isInteger(credential.projectId) || credential.projectId <= 0)) throw new ValidationError("projectId must be a positive integer");
|
|
42
|
+
return createAuthHeaders({
|
|
43
|
+
...credential,
|
|
44
|
+
token
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const CREDENTIAL_HEADER_NAMES = [
|
|
48
|
+
KeboolaHttpHeader.STORAGE_API_TOKEN,
|
|
49
|
+
KeboolaHttpHeader.MANAGEMENT_API_TOKEN,
|
|
50
|
+
KeboolaHttpHeader.PROJECT_ID,
|
|
51
|
+
HttpHeader.AUTHORIZATION,
|
|
52
|
+
APP_USER_TOKEN_HEADER
|
|
53
|
+
];
|
|
54
|
+
const createCredentialMiddleware = (provider) => (next) => async (request) => {
|
|
55
|
+
const credentialHeaders = await resolvedHeaders(await provider());
|
|
56
|
+
const { headers } = request.request;
|
|
57
|
+
for (const name of CREDENTIAL_HEADER_NAMES) headers.delete(name);
|
|
58
|
+
for (const [name, value] of Object.entries(credentialHeaders)) headers.set(name, value);
|
|
59
|
+
return next(request);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The Query Service client's credential setup for its `auth`.
|
|
63
|
+
*
|
|
64
|
+
* 1. A credential with only string tokens: default headers, set once (as `createAuthHeaders`).
|
|
65
|
+
* 2. A credential with a token callback, or a provider: no default headers; the innermost
|
|
66
|
+
* middleware resolves and checks every token on every attempt.
|
|
67
|
+
*/
|
|
68
|
+
const resolveAuth = (auth, middlewares) => {
|
|
69
|
+
if (typeof auth === "function") return {
|
|
70
|
+
headers: void 0,
|
|
71
|
+
middlewares: [...middlewares, createCredentialMiddleware(auth)]
|
|
72
|
+
};
|
|
73
|
+
if (hasCallback(auth)) return {
|
|
74
|
+
headers: void 0,
|
|
75
|
+
middlewares: [...middlewares, createCredentialMiddleware(() => auth)]
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
headers: staticHeaders(auth),
|
|
79
|
+
middlewares
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
// src/clients/queryService/poller.ts
|
|
83
|
+
const DEFAULT_POLL_INTERVAL = 2e3;
|
|
84
|
+
const createJobPoller = ({ getQueryJob }) => ({ init, interval, maxAttempts, timeout, signal }) => {
|
|
85
|
+
const retries = transientRetries();
|
|
86
|
+
return poller({
|
|
87
|
+
pollKey: ({ id }) => ["queryService.job", { id }],
|
|
88
|
+
init,
|
|
89
|
+
pollFn: async ({ init: { id }, signal: pollSignal }) => {
|
|
90
|
+
const job = await getQueryJob(id, pollSignal);
|
|
91
|
+
retries.reset();
|
|
92
|
+
return job;
|
|
93
|
+
},
|
|
94
|
+
isRetryable: retries.isRetryable,
|
|
95
|
+
until: ({ data }) => jobStatus.query.isTerminal(data.status),
|
|
96
|
+
failed: (job) => {
|
|
97
|
+
if (job.status !== "failed") return void 0;
|
|
98
|
+
const failedStatements = job.statements.filter((statement) => statement.status === "failed").map((statement) => ({
|
|
99
|
+
id: statement.id,
|
|
100
|
+
error: statement.error
|
|
101
|
+
}));
|
|
102
|
+
return new QueryJobError(failedStatements[0]?.error ?? "Job failed", job.queryJobId, { failedStatements });
|
|
103
|
+
},
|
|
104
|
+
backoff: {
|
|
105
|
+
type: "constant",
|
|
106
|
+
interval: interval ?? DEFAULT_POLL_INTERVAL
|
|
107
|
+
},
|
|
108
|
+
maxAttempts,
|
|
109
|
+
timeout,
|
|
110
|
+
signal
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
// src/clients/queryService/validateStatus.ts
|
|
114
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
115
|
+
/**
|
|
116
|
+
* Status validation for Query Service, which reads a row-level security refusal as `RowLevelSecurityError`.
|
|
117
|
+
*
|
|
118
|
+
* - The fixed `exception` text is the only signal: `X-KBC-RLS-Mode` is not exposed through CORS,
|
|
119
|
+
* and a credentials 403 on a governed workspace carries that header too.
|
|
120
|
+
*/
|
|
121
|
+
const validateQueryServiceStatus = (apiResponse) => {
|
|
122
|
+
const { response, data } = apiResponse;
|
|
123
|
+
if (response.status === HttpStatus.FORBIDDEN && isRecord(data) && data.exception === "Row-level security does not allow this query") return new RowLevelSecurityError(apiResponse);
|
|
124
|
+
return defaultValidateStatus(apiResponse);
|
|
125
|
+
};
|
|
126
|
+
// src/clients/queryService/queryServiceClient.ts
|
|
127
|
+
const createQueryServiceClient = ({ baseUrl, middlewares = [], auth }) => {
|
|
128
|
+
const client = createOpenapiFetchClient({
|
|
129
|
+
baseUrl,
|
|
130
|
+
...resolveAuth(auth, middlewares),
|
|
131
|
+
validateStatus: validateQueryServiceStatus
|
|
132
|
+
});
|
|
133
|
+
const genericClient = createGenericFetchClient({
|
|
134
|
+
baseUrl,
|
|
135
|
+
middlewares
|
|
136
|
+
});
|
|
137
|
+
const createQueryJob = async (branchId, workspaceId, body) => {
|
|
138
|
+
const { data } = await client.post("/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries", {
|
|
139
|
+
path: {
|
|
140
|
+
branchId,
|
|
141
|
+
workspaceId
|
|
142
|
+
},
|
|
143
|
+
body
|
|
144
|
+
});
|
|
145
|
+
return data;
|
|
146
|
+
};
|
|
147
|
+
const cancelQueryJob = async (queryJobId) => {
|
|
148
|
+
const { data } = await client.post("/api/v1/queries/{queryJobId}/cancel", {
|
|
149
|
+
path: { queryJobId },
|
|
150
|
+
body: { reason: "Cancelled by user" }
|
|
151
|
+
});
|
|
152
|
+
return data;
|
|
153
|
+
};
|
|
154
|
+
const getQueryJob = async (queryJobId, signal) => {
|
|
155
|
+
const { data } = await client.get("/api/v1/queries/{queryJobId}", { path: { queryJobId } }, { signal });
|
|
156
|
+
return data;
|
|
157
|
+
};
|
|
158
|
+
const getQueryResults = async (queryJobId, statementId, query) => {
|
|
159
|
+
const { data } = await client.get("/api/v1/queries/{queryJobId}/{statementId}/results", {
|
|
160
|
+
path: {
|
|
161
|
+
queryJobId,
|
|
162
|
+
statementId
|
|
163
|
+
},
|
|
164
|
+
query
|
|
165
|
+
});
|
|
166
|
+
return data;
|
|
167
|
+
};
|
|
168
|
+
const getQueryHistory = async (branchId, workspaceId, query) => {
|
|
169
|
+
const { data } = await client.get("/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries", {
|
|
170
|
+
path: {
|
|
171
|
+
branchId,
|
|
172
|
+
workspaceId
|
|
173
|
+
},
|
|
174
|
+
query
|
|
175
|
+
});
|
|
176
|
+
return data;
|
|
177
|
+
};
|
|
178
|
+
const exportResults = async (queryJobId, statementId, query, signal) => {
|
|
179
|
+
const { data, response } = await client.get("/api/v1/queries/{queryJobId}/{statementId}/export", {
|
|
180
|
+
path: {
|
|
181
|
+
queryJobId,
|
|
182
|
+
statementId
|
|
183
|
+
},
|
|
184
|
+
query
|
|
185
|
+
}, { signal });
|
|
186
|
+
return {
|
|
187
|
+
mimeType: response.headers.get(HttpHeader.CONTENT_TYPE) ?? "text/csv",
|
|
188
|
+
content: data,
|
|
189
|
+
fileName: parseContentDispositionHeader(response.headers.get(HttpHeader.CONTENT_DISPOSITION))?.filename ?? "export.csv"
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const healthCheck = async (signal) => {
|
|
193
|
+
const { data } = await genericClient.get("/health-check", {}, { signal });
|
|
194
|
+
return data;
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
healthCheck,
|
|
198
|
+
poller: createJobPoller({ getQueryJob }),
|
|
199
|
+
createQueryJob,
|
|
200
|
+
cancelQueryJob,
|
|
201
|
+
getQueryJob,
|
|
202
|
+
getQueryResults,
|
|
203
|
+
getQueryHistory,
|
|
204
|
+
exportResults
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export { createQueryServiceClient as t };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=queryService-DQHtHy2-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryService-DQHtHy2-.js","names":[],"sources":["../src/clients/queryService/auth.ts","../src/clients/queryService/poller.ts","../src/clients/queryService/validateStatus.ts","../src/clients/queryService/queryServiceClient.ts"],"sourcesContent":["import { ValidationError } from '../../errors';\nimport { HttpHeader, type MiddlewareFn } from '../../fetchClient';\nimport { APP_USER_TOKEN_HEADER, KeboolaHttpHeader } from '../../internal';\nimport { createAuthHeaders } from '../auth';\n\n/** A token value, or a callback that returns the current one (read before every request). */\nexport type TokenSource = string | (() => string | Promise<string>);\n\n/** A data app user's token, sent as `X-Kbc-App-User-Token` together with the app's Storage token. */\nexport type AppUserTokenAuth = {\n type: 'app-user-token';\n token: TokenSource;\n storageToken: TokenSource;\n};\n\n/** One credential; a request carries exactly that credential's headers. */\nexport type QueryServiceCredential =\n | { type: 'sapi-token'; token: TokenSource }\n | { type: 'bearer'; token: TokenSource; projectId: number }\n | AppUserTokenAuth;\n\n/** Resolved before every request, retries included. */\nexport type QueryServiceCredentialProvider = () =>\n | QueryServiceCredential\n | Promise<QueryServiceCredential>;\n\nconst PRINTABLE_ASCII_WITHOUT_SPACES = /^[\\x21-\\x7E]+$/;\n\nconst requireToken = (token: unknown): string => {\n if (typeof token !== 'string' || !PRINTABLE_ASCII_WITHOUT_SPACES.test(token)) {\n throw new ValidationError('token must be non-empty printable ASCII without spaces');\n }\n return token;\n};\n\nconst readToken = async (source: TokenSource) =>\n requireToken(typeof source === 'function' ? await source() : source);\n\nconst hasCallback = (credential: QueryServiceCredential) =>\n typeof credential.token === 'function' ||\n (credential.type === 'app-user-token' && typeof credential.storageToken === 'function');\n\n/**\n * Fixed headers for a credential with only string tokens.\n *\n * - `app-user-token` tokens are checked here, so an empty user token throws at client creation.\n * - `sapi-token` / `bearer` strings go out unchecked: service clients send an empty `bearer` token\n * that their own middleware replaces.\n */\nconst staticHeaders = (credential: QueryServiceCredential): Record<string, string> => {\n const { token } = credential;\n if (typeof token !== 'string') return {};\n if (credential.type === 'app-user-token') {\n return typeof credential.storageToken === 'string'\n ? {\n [KeboolaHttpHeader.STORAGE_API_TOKEN]: requireToken(credential.storageToken),\n [APP_USER_TOKEN_HEADER]: requireToken(token),\n }\n : {};\n }\n return createAuthHeaders({ ...credential, token });\n};\n\nconst resolvedHeaders = async (\n credential: QueryServiceCredential,\n): Promise<Record<string, string>> => {\n const token = await readToken(credential.token);\n if (credential.type === 'app-user-token') {\n return {\n [KeboolaHttpHeader.STORAGE_API_TOKEN]: await readToken(credential.storageToken),\n [APP_USER_TOKEN_HEADER]: token,\n };\n }\n if (\n credential.type === 'bearer' &&\n (!Number.isInteger(credential.projectId) || credential.projectId <= 0)\n ) {\n throw new ValidationError('projectId must be a positive integer');\n }\n return createAuthHeaders({ ...credential, token });\n};\n\nconst CREDENTIAL_HEADER_NAMES = [\n KeboolaHttpHeader.STORAGE_API_TOKEN,\n KeboolaHttpHeader.MANAGEMENT_API_TOKEN,\n KeboolaHttpHeader.PROJECT_ID,\n HttpHeader.AUTHORIZATION,\n APP_USER_TOKEN_HEADER,\n];\n\nconst createCredentialMiddleware =\n (provider: QueryServiceCredentialProvider): MiddlewareFn =>\n (next) =>\n async (request) => {\n const credentialHeaders = await resolvedHeaders(await provider());\n const { headers } = request.request;\n for (const name of CREDENTIAL_HEADER_NAMES) headers.delete(name);\n for (const [name, value] of Object.entries(credentialHeaders)) headers.set(name, value);\n return next(request);\n };\n\n/**\n * The Query Service client's credential setup for its `auth`.\n *\n * 1. A credential with only string tokens: default headers, set once (as `createAuthHeaders`).\n * 2. A credential with a token callback, or a provider: no default headers; the innermost\n * middleware resolves and checks every token on every attempt.\n */\nexport const resolveAuth = (\n auth: QueryServiceCredential | QueryServiceCredentialProvider,\n middlewares: MiddlewareFn[],\n) => {\n if (typeof auth === 'function') {\n return { headers: undefined, middlewares: [...middlewares, createCredentialMiddleware(auth)] };\n }\n if (hasCallback(auth)) {\n return {\n headers: undefined,\n middlewares: [...middlewares, createCredentialMiddleware(() => auth)],\n };\n }\n return { headers: staticHeaders(auth), middlewares };\n};\n","import { jobStatus } from '../../domain/jobStatus';\nimport { QueryJobError } from '../../errors';\nimport { poller } from '../../utils/async';\nimport { transientRetries } from '../transientRetries';\n\nimport type { GetQueryJobPath, JobStatusResponse } from './types';\n\nconst DEFAULT_POLL_INTERVAL = 2000;\n\nexport type QueryJobPollOptions = {\n interval?: number;\n maxAttempts?: number;\n timeout?: number;\n signal?: AbortSignal;\n};\n\ntype GetQueryJob = (\n queryJobId: GetQueryJobPath['queryJobId'],\n signal?: AbortSignal,\n) => Promise<JobStatusResponse>;\n\n/**\n * Waits on a query job.\n *\n * - `init` is the job, or the request that yields it, so a caller hands over what `createQueryJob` gave it.\n * - Terminal is the job's own terminal set, not its statements': a `completed` job can still hold a\n * statement that failed, and what that means is the caller's business.\n */\ntype JobRef = { id: GetQueryJobPath['queryJobId'] };\n\nexport const createJobPoller =\n ({ getQueryJob }: { getQueryJob: GetQueryJob }) =>\n ({\n init,\n interval,\n maxAttempts,\n timeout,\n signal,\n }: QueryJobPollOptions & { init: JobRef | ((signal: AbortSignal) => Promise<JobRef>) }) => {\n const retries = transientRetries();\n\n return poller({\n pollKey: ({ id }) => ['queryService.job', { id }] as const,\n init,\n pollFn: async ({ init: { id }, signal: pollSignal }) => {\n const job = await getQueryJob(id, pollSignal);\n retries.reset();\n return job;\n },\n isRetryable: retries.isRetryable,\n until: ({ data }) => jobStatus.query.isTerminal(data.status),\n failed: (job) => {\n if (job.status !== 'failed') return undefined;\n const failedStatements = job.statements\n .filter((statement) => statement.status === 'failed')\n .map((statement) => ({ id: statement.id, error: statement.error }));\n\n return new QueryJobError(failedStatements[0]?.error ?? 'Job failed', job.queryJobId, {\n failedStatements,\n });\n },\n backoff: { type: 'constant', interval: interval ?? DEFAULT_POLL_INTERVAL },\n maxAttempts,\n timeout,\n signal,\n });\n };\n","import { RowLevelSecurityError } from '../../errors';\nimport { defaultValidateStatus, type ValidateStatusFn } from '../../fetchClient';\nimport { HttpStatus, ROW_LEVEL_SECURITY_DENIED_MESSAGE } from '../../internal';\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null;\n\n/**\n * Status validation for Query Service, which reads a row-level security refusal as `RowLevelSecurityError`.\n *\n * - The fixed `exception` text is the only signal: `X-KBC-RLS-Mode` is not exposed through CORS,\n * and a credentials 403 on a governed workspace carries that header too.\n */\nexport const validateQueryServiceStatus: ValidateStatusFn = (apiResponse) => {\n const { response, data } = apiResponse;\n\n if (\n response.status === HttpStatus.FORBIDDEN &&\n isRecord(data) &&\n data.exception === ROW_LEVEL_SECURITY_DENIED_MESSAGE\n ) {\n return new RowLevelSecurityError(apiResponse);\n }\n\n return defaultValidateStatus(apiResponse);\n};\n","import {\n createGenericFetchClient,\n createOpenapiFetchClient,\n HttpHeader,\n type MiddlewareFn,\n parseContentDispositionHeader,\n} from '../../fetchClient';\nimport type { ClientInitOptions } from '../types';\n\nimport type { paths } from './__generated__/schema';\nimport {\n type QueryServiceCredential,\n type QueryServiceCredentialProvider,\n resolveAuth,\n} from './auth';\nimport { createJobPoller } from './poller';\nimport type {\n ExportResultsResponse,\n GetExportResultsQuery,\n GetQueriesHistoryQuery,\n GetQueriesPath,\n GetQueryJobPath,\n GetQueryResultsPath,\n GetQueryResutsQuery,\n PostCancelQueryJobPath,\n PostQueryBody,\n PostQueryPath,\n} from './types';\nimport { validateQueryServiceStatus } from './validateStatus';\n\nexport type QueryServiceClientInitOptions = Omit<ClientInitOptions, 'auth' | 'middlewares'> & {\n auth: QueryServiceCredential | QueryServiceCredentialProvider;\n middlewares?: MiddlewareFn[];\n};\n\nexport const createQueryServiceClient = ({\n baseUrl,\n middlewares = [],\n auth,\n}: QueryServiceClientInitOptions) => {\n const client = createOpenapiFetchClient<paths>({\n baseUrl,\n ...resolveAuth(auth, middlewares),\n validateStatus: validateQueryServiceStatus,\n });\n const genericClient = createGenericFetchClient({ baseUrl, middlewares });\n\n const createQueryJob = async (\n branchId: PostQueryPath['branchId'],\n workspaceId: PostQueryPath['workspaceId'],\n body: PostQueryBody,\n ) => {\n const { data } = await client.post(\n '/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries',\n { path: { branchId, workspaceId }, body },\n );\n\n return data;\n };\n\n const cancelQueryJob = async (queryJobId: PostCancelQueryJobPath['queryJobId']) => {\n const { data } = await client.post('/api/v1/queries/{queryJobId}/cancel', {\n path: { queryJobId },\n body: { reason: 'Cancelled by user' },\n });\n\n return data;\n };\n\n const getQueryJob = async (queryJobId: GetQueryJobPath['queryJobId'], signal?: AbortSignal) => {\n const { data } = await client.get(\n '/api/v1/queries/{queryJobId}',\n { path: { queryJobId } },\n { signal },\n );\n\n return data;\n };\n\n const getQueryResults = async (\n queryJobId: GetQueryResultsPath['queryJobId'],\n statementId: GetQueryResultsPath['statementId'],\n query?: GetQueryResutsQuery,\n ) => {\n const { data } = await client.get('/api/v1/queries/{queryJobId}/{statementId}/results', {\n path: { queryJobId, statementId },\n query,\n });\n\n return data;\n };\n\n const getQueryHistory = async (\n branchId: GetQueriesPath['branchId'],\n workspaceId: GetQueriesPath['workspaceId'],\n query?: GetQueriesHistoryQuery,\n ) => {\n const { data } = await client.get(\n '/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries',\n {\n path: { branchId, workspaceId },\n query,\n },\n );\n\n return data;\n };\n\n const exportResults = async (\n queryJobId: GetQueryResultsPath['queryJobId'],\n statementId: GetQueryResultsPath['statementId'],\n query: GetExportResultsQuery,\n signal?: AbortSignal,\n ): Promise<ExportResultsResponse> => {\n const { data, response } = await client.get(\n '/api/v1/queries/{queryJobId}/{statementId}/export',\n {\n path: { queryJobId, statementId },\n query,\n },\n { signal },\n );\n\n const mimeType = response.headers.get(HttpHeader.CONTENT_TYPE) ?? 'text/csv';\n const contentDisposition = parseContentDispositionHeader(\n response.headers.get(HttpHeader.CONTENT_DISPOSITION),\n );\n\n return {\n mimeType,\n content: data,\n fileName: contentDisposition?.filename ?? 'export.csv',\n };\n };\n\n const healthCheck = async (signal?: AbortSignal) => {\n const { data } = await genericClient.get('/health-check', {}, { signal });\n\n return data;\n };\n\n // Every wait on a query job is the same wait, so it is the client's rather than a caller's.\n const poller = createJobPoller({ getQueryJob });\n\n return {\n healthCheck,\n poller,\n createQueryJob,\n cancelQueryJob,\n getQueryJob,\n getQueryResults,\n getQueryHistory,\n exportResults,\n };\n};\n"],"mappings":";;;;;;;;AA0BA,MAAM,iCAAiC;AAEvC,MAAM,gBAAgB,UAA2B;CAC/C,IAAI,OAAO,UAAU,YAAY,CAAC,+BAA+B,KAAK,KAAK,GACzE,MAAM,IAAI,gBAAgB,wDAAwD;CAEpF,OAAO;AACT;AAEA,MAAM,YAAY,OAAO,WACvB,aAAa,OAAO,WAAW,aAAa,MAAM,OAAO,IAAI,MAAM;AAErE,MAAM,eAAe,eACnB,OAAO,WAAW,UAAU,cAC3B,WAAW,SAAS,oBAAoB,OAAO,WAAW,iBAAiB;;;;;;;;AAS9E,MAAM,iBAAiB,eAA+D;CACpF,MAAM,EAAE,UAAU;CAClB,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC;CACvC,IAAI,WAAW,SAAS,kBACtB,OAAO,OAAO,WAAW,iBAAiB,WACtC;GACG,kBAAkB,oBAAoB,aAAa,WAAW,YAAY;GAC1E,wBAAwB,aAAa,KAAK;CAC7C,IACA,CAAC;CAEP,OAAO,kBAAkB;EAAE,GAAG;EAAY;CAAM,CAAC;AACnD;AAEA,MAAM,kBAAkB,OACtB,eACoC;CACpC,MAAM,QAAQ,MAAM,UAAU,WAAW,KAAK;CAC9C,IAAI,WAAW,SAAS,kBACtB,OAAO;GACJ,kBAAkB,oBAAoB,MAAM,UAAU,WAAW,YAAY;GAC7E,wBAAwB;CAC3B;CAEF,IACE,WAAW,SAAS,aACnB,CAAC,OAAO,UAAU,WAAW,SAAS,KA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,EAAE,GACvB,EAAE,OAAO,CACX;EAEA,OAAO;CACT;CAEA,MAAM,kBAAkB,OACtB,YACA,aACA,UACG;EACH,MAAM,EAAE,SAAS,MAAM,OAAO,IAAI,sDAAsD;GACtF,MAAM;IAAE;IAAY;GAAY;GAChC;EACF,CAAC;EAED,OAAO;CACT;CAEA,MAAM,kBAAkB,OACtB,UACA,aACA,UACG;EACH,MAAM,EAAE,SAAS,MAAM,OAAO,IAC5B,gEACA;GACE,MAAM;IAAE;IAAU;GAAY;GAC9B;EACF,CACF;EAEA,OAAO;CACT;CAEA,MAAM,gBAAgB,OACpB,YACA,aACA,OACA,WACmC;EACnC,MAAM,EAAE,MAAM,aAAa,MAAM,OAAO,IACtC,qDACA;GACE,MAAM;IAAE;IAAY;GAAY;GAChC;EACF,GACA,EAAE,OAAO,CACX;EAOA,OAAO;GACL,UANe,SAAS,QAAQ,IAAI,WAAW,YAAY,KAAK;GAOhE,SAAS;GACT,UAPyB,8BACzB,SAAS,QAAQ,IAAI,WAAW,mBAAmB,CAMxB,CAAC,EAAE,YAAY;EAC5C;CACF;CAEA,MAAM,cAAc,OAAO,WAAyB;EAClD,MAAM,EAAE,SAAS,MAAM,cAAc,IAAI,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC;EAExE,OAAO;CACT;CAKA,OAAO;EACL;EACA,QAJa,gBAAgB,EAAE,YAAY,CAItC;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
package/dist/queue/index.cjs
CHANGED
package/dist/queue/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-
|
|
3
|
-
import { n as ClientInitOptions } from "../types-
|
|
1
|
+
import { Hr as CreateJobBody, Kr as OrchestrationRerunPlanPath, Qr as SearchJobsQuery, Ur as GetQueueJobPath, Wr as KillJobPath, Xr as SearchGroupedJobsQuery, Yr as SearchAllJobsQuery, ei as components } from "../index-FrsEkDvX.cjs";
|
|
2
|
+
import "../index-B7el5pJU.cjs";
|
|
3
|
+
import { n as ClientInitOptions } from "../types-B4ezB18r.cjs";
|
|
4
4
|
import { c as Poller } from "../index-24GpnYhn.cjs";
|
|
5
5
|
declare const createQueueClient: ({ baseUrl, middlewares, auth }: ClientInitOptions) => {
|
|
6
6
|
healthCheck: (signal?: AbortSignal) => Promise<unknown>;
|
package/dist/queue/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-
|
|
3
|
-
import { n as ClientInitOptions } from "../types-
|
|
1
|
+
import { Hr as CreateJobBody, Kr as OrchestrationRerunPlanPath, Qr as SearchJobsQuery, Ur as GetQueueJobPath, Wr as KillJobPath, Xr as SearchGroupedJobsQuery, Yr as SearchAllJobsQuery, ei as components } from "../index-FrsEkDvX.js";
|
|
2
|
+
import "../index-C7JcNvbd.js";
|
|
3
|
+
import { n as ClientInitOptions } from "../types-Tg3euEN_.js";
|
|
4
4
|
import { c as Poller } from "../index-BUZ-vTRt.js";
|
|
5
5
|
declare const createQueueClient: ({ baseUrl, middlewares, auth }: ClientInitOptions) => {
|
|
6
6
|
healthCheck: (signal?: AbortSignal) => Promise<unknown>;
|
package/dist/queue/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createQueueClient } from "../queue-
|
|
1
|
+
export { t as createQueueClient } from "../queue-6cywDnA-.js";
|
package/dist/queue/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as SearchJobsResponse, Gr as OrchestrationRerunPlan, Hr as CreateJobBody, Jr as QueueJobStatus, Kr as OrchestrationRerunPlanPath, Qr as SearchJobsQuery, Ur as GetQueueJobPath, Wr as KillJobPath, Xr as SearchGroupedJobsQuery, Yr as SearchAllJobsQuery, Zr as SearchGroupedJobsResponse, qr as QueueJob } from "../index-FrsEkDvX.cjs";
|
|
2
2
|
export { CreateJobBody, GetQueueJobPath, KillJobPath, OrchestrationRerunPlan, OrchestrationRerunPlanPath, QueueJob, QueueJobStatus, SearchAllJobsQuery, SearchGroupedJobsQuery, SearchGroupedJobsResponse, SearchJobsQuery, SearchJobsResponse };
|
package/dist/queue/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as SearchJobsResponse, Gr as OrchestrationRerunPlan, Hr as CreateJobBody, Jr as QueueJobStatus, Kr as OrchestrationRerunPlanPath, Qr as SearchJobsQuery, Ur as GetQueueJobPath, Wr as KillJobPath, Xr as SearchGroupedJobsQuery, Yr as SearchAllJobsQuery, Zr as SearchGroupedJobsResponse, qr as QueueJob } from "../index-FrsEkDvX.js";
|
|
2
2
|
export { CreateJobBody, GetQueueJobPath, KillJobPath, OrchestrationRerunPlan, OrchestrationRerunPlanPath, QueueJob, QueueJobStatus, SearchAllJobsQuery, SearchGroupedJobsQuery, SearchGroupedJobsResponse, SearchJobsQuery, SearchJobsResponse };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as QueueJobError } from "./QueueJobError-BJNUINXW.js";
|
|
2
|
-
import { t as createGenericFetchClient } from "./createGenericFetchClient-
|
|
3
|
-
import { t as createOpenapiFetchClient } from "./createOpenapiFetchClient-
|
|
2
|
+
import { t as createGenericFetchClient } from "./createGenericFetchClient-Ba4E4T-Y.js";
|
|
3
|
+
import { t as createOpenapiFetchClient } from "./createOpenapiFetchClient-DSk29o_s.js";
|
|
4
4
|
import { t as collectByOffset } from "./collectByOffset-i8Tdoze7.js";
|
|
5
|
-
import { a as poller, n as jobStatus, t as transientRetries } from "./transientRetries-
|
|
6
|
-
import { t as createAuthHeaders } from "./auth-
|
|
5
|
+
import { a as poller, n as jobStatus, t as transientRetries } from "./transientRetries-BORv47mH.js";
|
|
6
|
+
import { t as createAuthHeaders } from "./auth-ZBQWCJPM.js";
|
|
7
7
|
// src/clients/queue/poller.ts
|
|
8
8
|
const DEFAULT_POLL_INTERVAL = 2e3;
|
|
9
9
|
/**
|
|
@@ -103,4 +103,4 @@ const createQueueClient = ({ baseUrl, middlewares, auth }) => {
|
|
|
103
103
|
};
|
|
104
104
|
export { createQueueClient as t };
|
|
105
105
|
|
|
106
|
-
//# sourceMappingURL=queue-
|
|
106
|
+
//# sourceMappingURL=queue-6cywDnA-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-
|
|
1
|
+
{"version":3,"file":"queue-6cywDnA-.js","names":[],"sources":["../src/clients/queue/poller.ts","../src/clients/queue/queueClient.ts"],"sourcesContent":["import { jobStatus } from '../../domain/jobStatus';\nimport { QueueJobError } from '../../errors';\nimport { poller } from '../../utils/async';\nimport { transientRetries } from '../transientRetries';\n\nimport type { GetQueueJobPath, QueueJob } from './types';\n\nconst DEFAULT_POLL_INTERVAL = 2000;\n\ntype QueueJobPollOptions = {\n interval?: number;\n maxAttempts?: number;\n timeout?: number;\n signal?: AbortSignal;\n};\n\ntype GetJob = (jobId: GetQueueJobPath['jobId'], signal?: AbortSignal) => Promise<QueueJob>;\n\ntype JobRef = { id: GetQueueJobPath['jobId']; component: string };\n\n/**\n * Waits on a queue job.\n *\n * - `init` is the job, or the enqueue that yields it; the job names the poll in dev tools.\n * - `start()` resolves any terminal job; `wait()` throws `QueueJobError` for one that ended `error`.\n */\nexport const createJobPoller =\n ({ getJob }: { getJob: GetJob }) =>\n ({\n init,\n interval,\n maxAttempts,\n timeout,\n signal,\n }: QueueJobPollOptions & { init: JobRef | ((signal: AbortSignal) => Promise<JobRef>) }) => {\n const retries = transientRetries();\n\n return poller({\n pollKey: ({ id, component }) => ['queue.job', { id, component }] as const,\n init,\n pollFn: async ({ init: { id }, signal: pollSignal }) => {\n const job = await getJob(id, pollSignal);\n retries.reset();\n return job;\n },\n isRetryable: retries.isRetryable,\n until: ({ data }) => jobStatus.queue.isTerminal(data.status),\n failed: (job) => (job.status === 'error' ? new QueueJobError(job) : undefined),\n backoff: { type: 'constant', interval: interval ?? DEFAULT_POLL_INTERVAL },\n maxAttempts,\n timeout,\n signal,\n });\n };\n","import { createGenericFetchClient, createOpenapiFetchClient } from '../../fetchClient';\nimport { collectByOffset } from '../../utils';\nimport { createAuthHeaders } from '../auth';\nimport type { ClientInitOptions } from '../types';\n\nimport type { paths } from './__generated__/schema';\nimport { createJobPoller } from './poller';\nimport type {\n CreateJobBody,\n GetQueueJobPath,\n KillJobPath,\n OrchestrationRerunPlanPath,\n SearchAllJobsQuery,\n SearchGroupedJobsQuery,\n SearchJobsQuery,\n} from './types';\n\nexport const createQueueClient = ({ baseUrl, middlewares, auth }: ClientInitOptions) => {\n const client = createOpenapiFetchClient<paths>({\n baseUrl,\n middlewares,\n headers: createAuthHeaders(auth),\n });\n const genericClient = createGenericFetchClient({ baseUrl, middlewares });\n\n const getJob = async (jobId: GetQueueJobPath['jobId'], signal?: AbortSignal) => {\n const { data } = await client.get(\n '/jobs/{jobId}',\n {\n path: { jobId },\n },\n { signal },\n );\n\n return data;\n };\n\n const searchJobs = async (query?: SearchJobsQuery, signal?: AbortSignal) => {\n const { data } = await client.get(\n '/search/jobs',\n {\n query,\n },\n { signal },\n );\n\n return data;\n };\n\n const searchAllJobs = (query: SearchAllJobsQuery, signal?: AbortSignal) => {\n return collectByOffset({\n pageSize: query.limit,\n signal,\n fetchFrom: (offset, pageSize, batchSignal) => {\n return searchJobs({ ...query, limit: pageSize, offset }, batchSignal);\n },\n });\n };\n\n const createJob = async (body: CreateJobBody, signal?: AbortSignal) => {\n const { data } = await client.post('/jobs', { body }, { signal });\n\n return data;\n };\n\n const killJob = async (jobId: KillJobPath['jobId'], signal?: AbortSignal) => {\n const { data } = await client.post(\n '/jobs/{jobId}/kill',\n {\n path: { jobId },\n },\n { signal },\n );\n\n return data;\n };\n\n const searchGroupedJobs = async (query: SearchGroupedJobsQuery, signal?: AbortSignal) => {\n const { data } = await client.get(\n '/search/grouped-jobs',\n {\n query,\n },\n { signal },\n );\n\n return data;\n };\n\n const getOrchestrationRerunPlan = async (\n jobId: OrchestrationRerunPlanPath['jobId'],\n signal?: AbortSignal,\n ) => {\n const { data } = await client.get(\n '/orchestration-rerun-plan/{jobId}',\n {\n path: { jobId },\n },\n { signal },\n );\n\n return data;\n };\n\n const healthCheck = async (signal?: AbortSignal) => {\n const { data } = await genericClient.get('/health-check', {}, { signal });\n\n return data;\n };\n\n // Every wait on a queue job is the same wait, so it is the client's rather than a caller's.\n const poller = createJobPoller({ getJob });\n\n return {\n healthCheck,\n poller,\n getJob,\n searchJobs,\n searchAllJobs,\n createJob,\n killJob,\n searchGroupedJobs,\n getOrchestrationRerunPlan,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAM,wBAAwB;;;;;;;AAmB9B,MAAa,mBACV,EAAE,cACF,EACC,MACA,UACA,aACA,SACA,aACyF;CACzF,MAAM,UAAU,iBAAiB;CAEjC,OAAO,OAAO;EACZ,UAAU,EAAE,IAAI,gBAAgB,CAAC,aAAa;GAAE;GAAI;EAAU,CAAC;EAC/D;EACA,QAAQ,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,iBAAiB;GACtD,MAAM,MAAM,MAAM,OAAO,IAAI,UAAU;GACvC,QAAQ,MAAM;GACd,OAAO;EACT;EACA,aAAa,QAAQ;EACrB,QAAQ,EAAE,WAAW,UAAU,MAAM,WAAW,KAAK,MAAM;EAC3D,SAAS,QAAS,IAAI,WAAW,UAAU,IAAI,cAAc,GAAG,IAAI,KAAA;EACpE,SAAS;GAAE,MAAM;GAAY,UAAU,YAAY;EAAsB;EACzE;EACA;EACA;CACF,CAAC;AACH;;ACpCF,MAAa,qBAAqB,EAAE,SAAS,aAAa,WAA8B;CACtF,MAAM,SAAS,yBAAgC;EAC7C;EACA;EACA,SAAS,kBAAkB,IAAI;CACjC,CAAC;CACD,MAAM,gBAAgB,yBAAyB;EAAE;EAAS;CAAY,CAAC;CAEvE,MAAM,SAAS,OAAO,OAAiC,WAAyB;EAC9E,MAAM,EAAE,SAAS,MAAM,OAAO,IAC5B,iBACA,EACE,MAAM,EAAE,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