@keboola/api-client 31.0.0 → 33.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 +91 -7
- package/API-SURFACE.md +5 -2
- package/CHANGELOG.md +327 -0
- package/README.md +45 -19
- package/dist/{ManagementClientAuthError-DFhi5yxe.cjs → ManagementClientAuthError-DqeXL8nv.cjs} +2 -2
- package/dist/{ManagementClientAuthError-DFhi5yxe.cjs.map → ManagementClientAuthError-DqeXL8nv.cjs.map} +1 -1
- package/dist/{ManagementClientAuthError-90pvsej0.js → ManagementClientAuthError-iKbBugKC.js} +2 -2
- package/dist/{ManagementClientAuthError-90pvsej0.js.map → ManagementClientAuthError-iKbBugKC.js.map} +1 -1
- 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/{appLogs-CLHhkQJn.js → appLogs-D72eD8vP.js} +2 -2
- package/dist/{appLogs-CLHhkQJn.js.map → appLogs-D72eD8vP.js.map} +1 -1
- package/dist/{appLogs-BCCi02w6.cjs → appLogs-D8K0VeNM.cjs} +2 -2
- package/dist/{appLogs-BCCi02w6.cjs.map → appLogs-D8K0VeNM.cjs.map} +1 -1
- package/dist/{appLogs-hQdKt_8J.d.cts → appLogs-Q4A7A_Fc.d.cts} +2 -2
- package/dist/{appLogs-BdMG6Cvn.d.ts → appLogs-u0XMZLjS.d.ts} +2 -2
- package/dist/apps/index.cjs +3 -3
- package/dist/apps/index.d.cts +3 -3
- package/dist/apps/index.d.ts +3 -3
- package/dist/apps/index.js +3 -3
- package/dist/apps/types.d.cts +2 -2
- package/dist/apps/types.d.ts +2 -2
- package/dist/assets/index.cjs +1 -1
- package/dist/assets/index.d.cts +1 -1
- package/dist/assets/index.d.ts +1 -1
- package/dist/assets/index.js +1 -1
- package/dist/auth/index.cjs +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/types.d.cts +2 -2
- package/dist/auth/types.d.ts +2 -2
- package/dist/{auth-DmgTH0uY.cjs → auth-C2_JLisH.cjs} +2 -2
- package/dist/{auth-DmgTH0uY.cjs.map → auth-C2_JLisH.cjs.map} +1 -1
- package/dist/{auth-CE6Hlc9W.js → auth-CE9rQV3-.js} +2 -2
- package/dist/{auth-CE6Hlc9W.js.map → auth-CE9rQV3-.js.map} +1 -1
- package/dist/{authClient-XBAUz9g-.js → authClient-DEyqR7GW.js} +43 -9
- package/dist/authClient-DEyqR7GW.js.map +1 -0
- package/dist/{authClient-BL6h78Q1.d.cts → authClient-DZ_8lvdJ.d.cts} +6 -6
- package/dist/{authClient-Bc_bDisO.d.ts → authClient-DwT6xdg5.d.ts} +6 -6
- package/dist/{authClient-Cixa8_L1.cjs → authClient-IwQ9Ti0J.cjs} +43 -9
- package/dist/authClient-IwQ9Ti0J.cjs.map +1 -0
- package/dist/chat/index.cjs +3 -3
- package/dist/chat/index.d.cts +2 -7
- package/dist/chat/index.d.ts +2 -7
- 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/{configurations-CujCwDcB.cjs → configurations-Ck-mNB_E.cjs} +2 -2
- package/dist/{configurations-CujCwDcB.cjs.map → configurations-Ck-mNB_E.cjs.map} +1 -1
- package/dist/{configurations-DCOJONZZ.cjs → configurations-CqwAxiQL.cjs} +5 -1
- package/dist/configurations-CqwAxiQL.cjs.map +1 -0
- package/dist/{configurations-Byt59bIa.js → configurations-ZwBXilW-.js} +2 -2
- package/dist/{configurations-Byt59bIa.js.map → configurations-ZwBXilW-.js.map} +1 -1
- package/dist/{configurations-iCbhe0tb.js → configurations-d7SZmw69.js} +5 -1
- package/dist/configurations-d7SZmw69.js.map +1 -0
- package/dist/constants/index.cjs +2 -1
- package/dist/constants/index.d.cts +3 -2
- package/dist/constants/index.d.ts +3 -2
- package/dist/constants/index.js +2 -2
- package/dist/{constants-qeWGfk_7.js → constants-ByEwVtGf.js} +38 -2
- package/dist/constants-ByEwVtGf.js.map +1 -0
- package/dist/{constants-CkAVvuUq.cjs → constants-lIfSdTzS.cjs} +43 -1
- package/dist/constants-lIfSdTzS.cjs.map +1 -0
- package/dist/{createFetchClient-B1h3-p65.js → createFetchClient-DdyZMhxO.js} +17 -11
- package/dist/createFetchClient-DdyZMhxO.js.map +1 -0
- package/dist/{createFetchClient-B9Cv0W9f.cjs → createFetchClient-DvZvD31l.cjs} +22 -10
- package/dist/createFetchClient-DvZvD31l.cjs.map +1 -0
- package/dist/{createGenericFetchClient-DhpvUSlX.js → createGenericFetchClient-MQeLRiNW.js} +2 -2
- package/dist/{createGenericFetchClient-DhpvUSlX.js.map → createGenericFetchClient-MQeLRiNW.js.map} +1 -1
- package/dist/{createGenericFetchClient-BWoSkTki.cjs → createGenericFetchClient-qfCZlCTv.cjs} +2 -2
- package/dist/{createGenericFetchClient-BWoSkTki.cjs.map → createGenericFetchClient-qfCZlCTv.cjs.map} +1 -1
- package/dist/{createOpenapiFetchClient-yirrW6Tg.cjs → createOpenapiFetchClient-C57Ljzi6.cjs} +2 -2
- package/dist/{createOpenapiFetchClient-yirrW6Tg.cjs.map → createOpenapiFetchClient-C57Ljzi6.cjs.map} +1 -1
- package/dist/{createOpenapiFetchClient-0_oqhdPv.js → createOpenapiFetchClient-E7OIVkYv.js} +2 -2
- package/dist/{createOpenapiFetchClient-0_oqhdPv.js.map → createOpenapiFetchClient-E7OIVkYv.js.map} +1 -1
- package/dist/{credential-dKxArMic.js → credential-Bxv7yxOZ.js} +7 -4
- package/dist/credential-Bxv7yxOZ.js.map +1 -0
- package/dist/{credential-D-tX9gP4.cjs → credential-D-X5QQrM.cjs} +7 -4
- package/dist/credential-D-X5QQrM.cjs.map +1 -0
- 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-BqNWX-Gr.cjs → dataScience-BPW993AG.cjs} +5 -5
- package/dist/{dataScience-BqNWX-Gr.cjs.map → dataScience-BPW993AG.cjs.map} +1 -1
- package/dist/{dataScience-jdbSSPYF.js → dataScience-B_TA7wCB.js} +5 -5
- package/dist/{dataScience-jdbSSPYF.js.map → dataScience-B_TA7wCB.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 -1
- package/dist/developerPortal/types.d.cts +1 -1
- package/dist/developerPortal/types.d.ts +1 -1
- package/dist/{developerPortalClient-B7lNR5q0.cjs → developerPortalClient-Db2XVB_o.cjs} +3 -3
- package/dist/{developerPortalClient-B7lNR5q0.cjs.map → developerPortalClient-Db2XVB_o.cjs.map} +1 -1
- package/dist/{developerPortalClient-5ABcxz1U.js → developerPortalClient-jk46sjwP.js} +3 -3
- package/dist/{developerPortalClient-5ABcxz1U.js.map → developerPortalClient-jk46sjwP.js.map} +1 -1
- package/dist/domain/permissions/index.cjs +63 -1
- package/dist/domain/permissions/index.cjs.map +1 -0
- package/dist/domain/permissions/index.d.cts +52 -3
- package/dist/domain/permissions/index.d.ts +52 -3
- package/dist/domain/permissions/index.js +59 -2
- package/dist/domain/permissions/index.js.map +1 -0
- 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/emitter-dLF1Fyfg.d.cts +11 -0
- package/dist/emitter-dLF1Fyfg.d.ts +11 -0
- 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-CExRbskw.js → import-2nqxQ9Rt.js} +3 -3
- package/dist/{import-CExRbskw.js.map → import-2nqxQ9Rt.js.map} +1 -1
- package/dist/{import-CXHppAxd.cjs → import-DJilJ6tq.cjs} +3 -3
- package/dist/{import-CXHppAxd.cjs.map → import-DJilJ6tq.cjs.map} +1 -1
- package/dist/{index-BR2Fu-Wo.d.ts → index-B0V1pJAa.d.ts} +618 -3103
- package/dist/{index-7RvXnXmd.d.ts → index-B2OGaUap.d.ts} +6 -6
- package/dist/{index-J1I2HlSm.d.ts → index-BjKjp3Rf.d.ts} +5 -5
- package/dist/{index-NicJZIzu.d.ts → index-C7gxKoDF.d.cts} +3 -3
- package/dist/{index-B6q7HxKJ.d.cts → index-CTd4YY8e.d.cts} +4 -4
- package/dist/{index-C9mAoXF6.d.cts → index-CUXEFQ7i.d.cts} +6 -6
- package/dist/{index-D_TnbEtp.d.cts → index-CVqk63at.d.ts} +3 -3
- package/dist/{index-CMb0ygwb.d.ts → index-C_cxKL1V.d.ts} +3 -3
- package/dist/{index-CYMAwD3E.d.ts → index-ChMtULt4.d.ts} +4 -4
- package/dist/{index-Cpjh05sx.d.cts → index-DCN2lH0v.d.cts} +4 -4
- package/dist/{index-cu8THqZV.d.cts → index-DIVvL54G.d.cts} +618 -3103
- package/dist/{index-CwJE18PJ.d.cts → index-DLYAvSWZ.d.cts} +3 -3
- package/dist/{index-CW4VC9oN.d.ts → index-DQef014j.d.ts} +4 -4
- package/dist/{index-Ds8e0l7-.d.ts → index-DVhTNwvu.d.ts} +7 -3
- package/dist/{index-B-frWtGW.d.cts → index-DhVFuQDv.d.cts} +7 -3
- package/dist/{index-DeMDxHTz.d.ts → index-GNKwr7EQ.d.ts} +4 -4
- package/dist/{index--pxLseaw.d.cts → index-NaYLwG_h.d.cts} +143 -2
- package/dist/{index--pxLseaw.d.ts → index-NaYLwG_h.d.ts} +143 -2
- package/dist/{index-Daks5CeX.d.ts → index-bB6wvw1f.d.ts} +4 -4
- package/dist/{index-BfVv8isU.d.cts → index-exNi3I2Q.d.cts} +4 -4
- package/dist/{index-CR9LsDaG.d.cts → index-qOK5FtAH.d.cts} +4 -4
- package/dist/{index-BSjfVDTr.d.cts → index-t-a7kYnx.d.cts} +5 -5
- package/dist/index.cjs +325 -257
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +306 -240
- package/dist/index.js.map +1 -1
- package/dist/{jobStatus-kQ9JqF8t.cjs → jobStatus-0_Y3Sr4i.cjs} +37 -20
- package/dist/jobStatus-0_Y3Sr4i.cjs.map +1 -0
- package/dist/{jobStatus-DbMupQEK.js → jobStatus-PSZJMTiA.js} +35 -18
- package/dist/jobStatus-PSZJMTiA.js.map +1 -0
- package/dist/kaiAgent/index.cjs +3 -0
- package/dist/kaiAgent/index.d.cts +2 -0
- package/dist/kaiAgent/index.d.ts +2 -0
- package/dist/kaiAgent/index.js +2 -0
- package/dist/kaiAgent/types.cjs +0 -0
- package/dist/kaiAgent/types.d.cts +2 -0
- package/dist/kaiAgent/types.d.ts +2 -0
- package/dist/kaiAgent/types.js +1 -0
- package/dist/kaiAgent-CMVub6Sc.cjs +266 -0
- package/dist/kaiAgent-CMVub6Sc.cjs.map +1 -0
- package/dist/kaiAgent-CYYn0QJW.js +261 -0
- package/dist/kaiAgent-CYYn0QJW.js.map +1 -0
- package/dist/kaiAgentClient-B2O0DF4d.d.ts +249 -0
- package/dist/kaiAgentClient-iCFR2tRU.d.cts +249 -0
- 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 +1 -1
- package/dist/management/types.d.ts +1 -1
- package/dist/{management-DlVdxzPw.cjs → management-DGfgKsaA.cjs} +5 -5
- package/dist/{management-DlVdxzPw.cjs.map → management-DGfgKsaA.cjs.map} +1 -1
- package/dist/{management-Cc8mKfnf.js → management-DNEKhR6a.js} +5 -5
- package/dist/{management-Cc8mKfnf.js.map → management-DNEKhR6a.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-CNf1412Z.js → metastore-CjwktHvw.js} +4 -4
- package/dist/{metastore-CNf1412Z.js.map → metastore-CjwktHvw.js.map} +1 -1
- package/dist/{metastore-DbsxqjhS.cjs → metastore-DksEte8P.cjs} +4 -4
- package/dist/{metastore-DbsxqjhS.cjs.map → metastore-DksEte8P.cjs.map} +1 -1
- package/dist/microsoftGraph/index.cjs +92 -0
- package/dist/microsoftGraph/index.cjs.map +1 -0
- package/dist/microsoftGraph/index.d.cts +305 -0
- package/dist/microsoftGraph/index.d.ts +305 -0
- package/dist/microsoftGraph/index.js +90 -0
- package/dist/microsoftGraph/index.js.map +1 -0
- package/dist/microsoftGraph/types.cjs +0 -0
- package/dist/microsoftGraph/types.d.cts +10 -0
- package/dist/microsoftGraph/types.d.ts +10 -0
- package/dist/microsoftGraph/types.js +1 -0
- package/dist/notifications/index.cjs +3 -3
- package/dist/notifications/index.d.cts +2 -2
- package/dist/notifications/index.d.ts +2 -2
- package/dist/notifications/index.js +3 -3
- package/dist/notifications/types.d.cts +1 -1
- package/dist/notifications/types.d.ts +1 -1
- package/dist/oauth/index.cjs +1 -1
- package/dist/oauth/index.d.cts +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-ClksaYRY.js → oauth-Bg5zro5S.js} +5 -5
- package/dist/{oauth-ClksaYRY.js.map → oauth-Bg5zro5S.js.map} +1 -1
- package/dist/{oauth-DsZgmtPj.cjs → oauth-DFsI1TE5.cjs} +5 -5
- package/dist/{oauth-DsZgmtPj.cjs.map → oauth-DFsI1TE5.cjs.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-5SLw86eZ.d.ts → project-Bh954iOA.d.ts} +2 -2
- package/dist/{project-CRrsxSAK.d.cts → project-D25GH8zK.d.cts} +2 -2
- package/dist/queryService/index.cjs +1 -1
- package/dist/queryService/index.d.cts +1 -1
- package/dist/queryService/index.d.ts +1 -1
- package/dist/queryService/index.js +1 -1
- package/dist/queryService/types.d.cts +1 -1
- package/dist/queryService/types.d.ts +1 -1
- package/dist/{queryService-DxUUkTcy.cjs → queryService--t_W9PSJ.cjs} +6 -6
- package/dist/{queryService-DxUUkTcy.cjs.map → queryService--t_W9PSJ.cjs.map} +1 -1
- package/dist/{queryService-BlyAcBxP.js → queryService-DX6zeAs_.js} +6 -6
- package/dist/{queryService-BlyAcBxP.js.map → queryService-DX6zeAs_.js.map} +1 -1
- 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-CpcqeMPz.cjs → queue-D1_TCe0z.cjs} +5 -5
- package/dist/{queue-CpcqeMPz.cjs.map → queue-D1_TCe0z.cjs.map} +1 -1
- package/dist/{queue-DpZTm7U7.js → queue-DrLUbk98.js} +5 -5
- package/dist/{queue-DpZTm7U7.js.map → queue-DrLUbk98.js.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/schema-D1oxyn1O.d.cts +8760 -0
- package/dist/schema-D1oxyn1O.d.ts +8760 -0
- package/dist/sdk/configurations/index.cjs +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 +1 -1
- package/dist/sdk/developerPortal/index.cjs +5 -5
- package/dist/sdk/developerPortal/index.cjs.map +1 -1
- package/dist/sdk/developerPortal/index.d.cts +5 -4
- package/dist/sdk/developerPortal/index.d.ts +5 -4
- package/dist/sdk/developerPortal/index.js +4 -4
- package/dist/sdk/queryService/index.cjs +1 -1
- package/dist/sdk/queryService/index.d.cts +1 -1
- package/dist/sdk/queryService/index.d.ts +1 -1
- package/dist/sdk/queryService/index.js +1 -1
- package/dist/sdk/semanticLayer/index.cjs +163 -74
- package/dist/sdk/semanticLayer/index.cjs.map +1 -1
- package/dist/sdk/semanticLayer/index.d.cts +16 -13
- package/dist/sdk/semanticLayer/index.d.ts +16 -13
- package/dist/sdk/semanticLayer/index.js +158 -75
- package/dist/sdk/semanticLayer/index.js.map +1 -1
- package/dist/sdk/semanticLayer/types.d.cts +2 -2
- package/dist/sdk/semanticLayer/types.d.ts +2 -2
- package/dist/sdk/storage/index.d.cts +1 -1
- package/dist/sdk/storage/index.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/serviceIds-fHLDwOg9.d.cts +31 -0
- package/dist/serviceIds-fHLDwOg9.d.ts +31 -0
- 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 +4 -4
- package/dist/storage/index.d.cts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +4 -4
- package/dist/storage/types.d.cts +4 -3
- package/dist/storage/types.d.ts +4 -3
- package/dist/{storage-CQxu0EY3.js → storage--cVaecFq.js} +150 -161
- package/dist/storage--cVaecFq.js.map +1 -0
- package/dist/{storage-vnH64B_Q.cjs → storage-DexWot8H.cjs} +150 -161
- package/dist/storage-DexWot8H.cjs.map +1 -0
- package/dist/store-C9FQCHGe.js +74 -0
- package/dist/store-C9FQCHGe.js.map +1 -0
- package/dist/store-xS-Cu_VS.cjs +85 -0
- package/dist/store-xS-Cu_VS.cjs.map +1 -0
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.d.cts +2 -2
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.js +3 -3
- package/dist/stream/types.d.cts +1 -1
- package/dist/stream/types.d.ts +1 -1
- package/dist/syncActions/index.cjs +1 -1
- package/dist/syncActions/index.d.cts +1 -1
- package/dist/syncActions/index.d.ts +1 -1
- 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-AgFiMjRS.js → syncActions-CkMHM-jB.js} +5 -5
- package/dist/{syncActions-AgFiMjRS.js.map → syncActions-CkMHM-jB.js.map} +1 -1
- package/dist/{syncActions-DPcAPYgJ.cjs → syncActions-DQq_A9v6.cjs} +5 -5
- package/dist/{syncActions-DPcAPYgJ.cjs.map → syncActions-DQq_A9v6.cjs.map} +1 -1
- package/dist/telemetry/index.cjs +1 -1
- package/dist/telemetry/index.d.cts +2 -2
- package/dist/telemetry/index.d.ts +2 -2
- package/dist/telemetry/index.js +1 -1
- package/dist/{telemetry-BLgaYEvi.cjs → telemetry-CAu1Qt7B.cjs} +3 -3
- package/dist/{telemetry-BLgaYEvi.cjs.map → telemetry-CAu1Qt7B.cjs.map} +1 -1
- package/dist/{telemetry-CPiGWpLi.js → telemetry-Ca6j0i9w.js} +3 -3
- package/dist/{telemetry-CPiGWpLi.js.map → telemetry-Ca6j0i9w.js.map} +1 -1
- package/dist/{types-eP06LqcE.d.cts → types-0xa_7cgo.d.cts} +2 -16
- package/dist/{types-DLazCdFR.d.cts → types-3p0adMdd.d.cts} +3 -3
- package/dist/{types-DWUd__fe.d.ts → types-6ThDkaJw.d.ts} +2 -2
- package/dist/{types-Culr5v8R.d.ts → types-6hh_3SZs.d.ts} +3 -3
- package/dist/{types-DN7RWWBw.d.ts → types-6ku2LeX6.d.ts} +2 -2
- package/dist/{types-DSBNqF1J.d.cts → types-B42HhyB0.d.cts} +2 -2
- package/dist/{types-C2p7JYQ3.d.cts → types-B4_MM5Wf.d.cts} +2 -2
- package/dist/{types-B2El99VY.d.cts → types-B6JJCta-.d.cts} +2 -2
- package/dist/{types-BHCigZFc.d.ts → types-B6lOyHY_.d.ts} +3 -3
- package/dist/{types-Bc3-a3DT.d.cts → types-B7O5koJb.d.cts} +2 -2
- package/dist/{types-D5VvEdOv.d.ts → types-BHI8Lin9.d.ts} +2 -2
- package/dist/{types-DnOGCb-p.d.cts → types-BO3sCD0a.d.cts} +41 -10
- package/dist/{types-Bv5vw2dc.d.cts → types-BOnf68s5.d.cts} +2 -2
- package/dist/{types-CIybfUJ9.d.cts → types-BS5M67xm.d.cts} +3 -3
- package/dist/{types-C0bGZqFI.d.cts → types-BT46XIgn.d.cts} +2 -2
- package/dist/types-BUYqdN7B.d.ts +205 -0
- package/dist/{types-DdeZK3BO.d.ts → types-BYKHr5bR.d.ts} +2 -2
- package/dist/{types-BIAP4CYp.d.cts → types-Be3Wgn1U.d.cts} +2 -2
- package/dist/{types-B1S60aS2.d.ts → types-BgVKG4vg.d.ts} +2 -2
- package/dist/{types-BJLRgXw0.d.ts → types-C2gzqtjf.d.ts} +2 -2
- package/dist/{types-DQOOWgLt.d.cts → types-C35GWNmq.d.ts} +408 -24
- package/dist/{types-DMMMQuNt.d.ts → types-C4mr0lop.d.ts} +279 -430
- package/dist/{types-CFhAduFK.d.cts → types-CCr1-9Q6.d.cts} +3 -3
- package/dist/{types-Dirp9mni.d.ts → types-CHCM9oNk.d.ts} +3 -3
- package/dist/types-CNQdtffE.d.ts +3454 -0
- package/dist/{types-mXM8MrYS.d.cts → types-CPaluTW7.d.cts} +3 -3
- package/dist/{types-RmbvQimP.d.ts → types-CSc8NQCY.d.ts} +41 -10
- package/dist/{types-CgF9R0Na.d.ts → types-C_ilZZkQ.d.ts} +2 -2
- package/dist/{types-lVXf05pr.d.ts → types-CaMfshWX.d.ts} +2 -2
- package/dist/{types-BXnUqdBB.d.cts → types-Ccgbipp4.d.cts} +2 -2
- package/dist/types-Cpjk0-ta.d.ts +33557 -0
- package/dist/types-CrH4H8M4.d.cts +33557 -0
- package/dist/{types-CQd9PuKY.d.cts → types-Cu-0LT4f.d.cts} +2 -2
- package/dist/{types-D7YGPUsm.d.ts → types-CxmV36rp.d.cts} +408 -24
- package/dist/{types-SX78XZZ0.d.ts → types-D-98DirB.d.ts} +2 -2
- package/dist/{types-DG_FlLJt.d.cts → types-D6ocCyGh.d.cts} +279 -430
- package/dist/{types-DkoyCUqv.d.ts → types-D7Wgcp0u.d.ts} +2 -2
- package/dist/{types-COFrOmuO.d.ts → types-DAzmGzlb.d.ts} +2 -2
- package/dist/{types-BdKtW2Ml.d.cts → types-DHI0g51U.d.cts} +2 -2
- package/dist/{types-BMsK6T5k.d.ts → types-DHqIJKwx.d.ts} +2 -2
- package/dist/types-DONxb2-c.d.cts +205 -0
- package/dist/{types-DyIKgbGB.d.ts → types-DTTC70Ac.d.ts} +2 -2
- package/dist/{types-B2Al1BNh.d.ts → types-DlvZeert.d.ts} +2 -2
- package/dist/{types-uP64XthM.d.cts → types-DqniGeDJ.d.cts} +2 -2
- package/dist/types-E3VT-zYz.d.cts +3454 -0
- package/dist/{types-CuAoZH8w.d.cts → types-Jt0ipbSm.d.cts} +2 -2
- package/dist/{types-Co8WobOo.d.ts → types-Ur37iOqb.d.ts} +3 -3
- package/dist/{types-Drk7PEhk.d.ts → types-ZGAWRIBW.d.ts} +2 -2
- package/dist/{types-056giLrn.d.cts → types-bY6K3y0O.d.cts} +2 -2
- package/dist/{types-BvXODdf5.d.ts → types-k4R8gQ4U.d.ts} +2 -16
- package/dist/{types-sTH4KiPc.d.cts → types-sO52qIAA.d.cts} +2 -2
- package/dist/{types-By47HWwB.d.cts → types-sp1rJY9E.d.cts} +2 -2
- package/dist/{validateConnectionStatus-DVHXGTdi.cjs → validateConnectionStatus-24zqIQ0p.cjs} +2 -2
- package/dist/{validateConnectionStatus-DVHXGTdi.cjs.map → validateConnectionStatus-24zqIQ0p.cjs.map} +1 -1
- package/dist/{validateConnectionStatus-CBhXmvWC.js → validateConnectionStatus-DhkWg6Eq.js} +2 -2
- package/dist/{validateConnectionStatus-CBhXmvWC.js.map → validateConnectionStatus-DhkWg6Eq.js.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 +55 -3
- package/surface/auth.md +2 -2
- package/surface/chat.md +1 -1
- package/surface/kaiAgent.md +5 -2
- package/surface/sdk.md +4 -4
- package/surface/storage.md +44 -44
- package/dist/authClient-Cixa8_L1.cjs.map +0 -1
- package/dist/authClient-XBAUz9g-.js.map +0 -1
- package/dist/configurations-DCOJONZZ.cjs.map +0 -1
- package/dist/configurations-iCbhe0tb.js.map +0 -1
- package/dist/constants-CkAVvuUq.cjs.map +0 -1
- package/dist/constants-qeWGfk_7.js.map +0 -1
- package/dist/createFetchClient-B1h3-p65.js.map +0 -1
- package/dist/createFetchClient-B9Cv0W9f.cjs.map +0 -1
- package/dist/createStore-BNiCRQXa.js +0 -148
- package/dist/createStore-BNiCRQXa.js.map +0 -1
- package/dist/createStore-MQbboXcB.cjs +0 -177
- package/dist/createStore-MQbboXcB.cjs.map +0 -1
- package/dist/credential-D-tX9gP4.cjs.map +0 -1
- package/dist/credential-dKxArMic.js.map +0 -1
- package/dist/jobStatus-DbMupQEK.js.map +0 -1
- package/dist/jobStatus-kQ9JqF8t.cjs.map +0 -1
- package/dist/storage-CQxu0EY3.js.map +0 -1
- package/dist/storage-vnH64B_Q.cjs.map +0 -1
- package/dist/types-BV74LS5r.d.ts +0 -148
- package/dist/types-CIJAtX8q.d.cts +0 -18784
- package/dist/types-X-gQF8F8.d.ts +0 -18784
- package/dist/types-ca-YNg1r.d.cts +0 -148
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_configurations = require("../../configurations-
|
|
2
|
+
const require_configurations = require("../../configurations-Ck-mNB_E.cjs");
|
|
3
3
|
exports.createConfigurationSdk = require_configurations.createConfigurationSdk;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as createEncryptionClient } from "../../index-
|
|
4
|
-
import { t as Project } from "../../project-
|
|
1
|
+
import { B as createStorageClient, I as RegisteredComponentId, L as registry, Wt as createDefaultBranch } from "../../index-DIVvL54G.cjs";
|
|
2
|
+
import { Dn as UpdateConfigurationInput, Xt as BaseComponentConfig, an as ConfigurationPath, sn as CreateConfigurationInput } from "../../types-D6ocCyGh.cjs";
|
|
3
|
+
import { t as createEncryptionClient } from "../../index-C7gxKoDF.cjs";
|
|
4
|
+
import { t as Project } from "../../project-D25GH8zK.cjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/sdks/configurations/configurationsSdk.d.ts
|
|
7
7
|
type ConfigurationSdkContext = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as createEncryptionClient } from "../../index-
|
|
4
|
-
import { t as Project } from "../../project-
|
|
1
|
+
import { B as createStorageClient, I as RegisteredComponentId, L as registry, Wt as createDefaultBranch } from "../../index-B0V1pJAa.js";
|
|
2
|
+
import { Dn as UpdateConfigurationInput, Xt as BaseComponentConfig, an as ConfigurationPath, sn as CreateConfigurationInput } from "../../types-C4mr0lop.js";
|
|
3
|
+
import { t as createEncryptionClient } from "../../index-CVqk63at.js";
|
|
4
|
+
import { t as Project } from "../../project-Bh954iOA.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/sdks/configurations/configurationsSdk.d.ts
|
|
7
7
|
type ConfigurationSdkContext = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createConfigurationSdk } from "../../configurations-
|
|
1
|
+
import { t as createConfigurationSdk } from "../../configurations-ZwBXilW-.js";
|
|
2
2
|
export { createConfigurationSdk };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_dedupe = require("../../dedupe-CiskLkGR.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_createFetchClient = require("../../createFetchClient-
|
|
5
|
-
const require_credential = require("../../credential-D-
|
|
6
|
-
const require_developerPortalClient = require("../../developerPortalClient-
|
|
3
|
+
const require_store = require("../../store-xS-Cu_VS.cjs");
|
|
4
|
+
const require_createFetchClient = require("../../createFetchClient-DvZvD31l.cjs");
|
|
5
|
+
const require_credential = require("../../credential-D-X5QQrM.cjs");
|
|
6
|
+
const require_developerPortalClient = require("../../developerPortalClient-Db2XVB_o.cjs");
|
|
7
7
|
//#region src/sdks/developerPortal/tokenExpiry.ts
|
|
8
8
|
/**
|
|
9
9
|
* Reads a JWT's `exp` claim as milliseconds, or `null` when unparseable ("expiry unknown", which the
|
|
@@ -103,7 +103,7 @@ const createDeveloperPortalAuthMiddleware = (credential) => {
|
|
|
103
103
|
* apps-api is its own identity domain.
|
|
104
104
|
*/
|
|
105
105
|
const createDeveloperPortalSdk = ({ baseUrl, tokens: initialTokens = null, onTokensChange, onSessionExpired, refreshLeadTimeMs, middlewares = [] }) => {
|
|
106
|
-
const store =
|
|
106
|
+
const store = require_store.createStore(initialTokens);
|
|
107
107
|
store.subscribe((value) => onTokensChange?.(value));
|
|
108
108
|
const getTokens = () => store.get();
|
|
109
109
|
const requireTokens = (action) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isUnauthorized","dedupe","HttpHeader","isUnauthorized","createStore","createDeveloperPortalClient"],"sources":["../../../src/sdks/developerPortal/tokenExpiry.ts","../../../src/sdks/developerPortal/credential.ts","../../../src/sdks/developerPortal/middleware.ts","../../../src/sdks/developerPortal/developerPortalSdk.ts"],"sourcesContent":["/**\n * Reads a JWT's `exp` claim as milliseconds, or `null` when unparseable (\"expiry unknown\", which the\n * caller leaves to the 401 path). A read, not a verification.\n *\n * Needed because apps-api reports `expiresIn` on login but never on refresh, so it cannot keep a\n * proactive-refresh clock honest past the first rotation. The token always carries its own expiry.\n */\nexport const readTokenExpiry = (token: string): number | null => {\n const segments = token.split('.');\n if (segments.length !== 3) return null;\n\n const payload = segments[1];\n if (payload === undefined || payload === '') return null;\n\n try {\n // base64url -> base64, and re-pad: `atob` requires padding, base64url omits it.\n const base64 = payload.replaceAll('-', '+').replaceAll('_', '/');\n const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');\n const claims: unknown = JSON.parse(atob(padded));\n if (typeof claims !== 'object' || claims === null || !('exp' in claims)) return null;\n const { exp } = claims as { exp: unknown };\n if (typeof exp !== 'number' || !Number.isFinite(exp)) return null;\n return exp * 1000;\n } catch {\n return null;\n }\n};\n","import type { DeveloperPortalTokens } from '../../clients/developerPortal/tokens';\nimport { isUnauthorized } from '../../keboola/bearer/credential';\nimport { dedupe } from '../../utils';\n\nimport { readTokenExpiry } from './tokenExpiry';\n\ntype Options = {\n refresh: () => Promise<DeveloperPortalTokens>;\n /** Live read from the session, so this holds no token of its own. `null` when signed out. */\n getTokens: () => DeveloperPortalTokens | null;\n /** May fire more than once; the caller owns any fire-once latch. */\n onSessionExpired?: () => void;\n /**\n * An absolute lead time rather than `createBearerCredential`'s fractional threshold: that needs the\n * token's full lifetime, and apps-api reports `expiresIn` on login only, never on refresh.\n */\n refreshLeadTimeMs?: number;\n};\n\nconst DEFAULT_REFRESH_LEAD_TIME_MS = 5 * 60 * 1000;\n\nexport type DeveloperPortalCredential = {\n getIdToken: (options?: { forceRefresh?: boolean }) => Promise<string | null>;\n getTokens: () => DeveloperPortalTokens | null;\n notifyExpired: () => void;\n};\n\n/** Mirrors `createBearerCredential`, over the id token of the trio. */\nexport const createDeveloperPortalCredential = ({\n refresh,\n getTokens,\n onSessionExpired,\n refreshLeadTimeMs = DEFAULT_REFRESH_LEAD_TIME_MS,\n}: Options): DeveloperPortalCredential => {\n const doRefresh = async (): Promise<DeveloperPortalTokens> => {\n try {\n return await refresh();\n } catch (error) {\n // Only a 401 means the refresh token is dead. Signing out over a 5xx would be a self-inflicted\n // logout, so anything else propagates without expiring the session.\n if (isUnauthorized(error)) onSessionExpired?.();\n throw error;\n }\n };\n\n // N concurrent 401s must cause one rotation: each extra one invalidates the tokens the others got.\n const refreshShared = dedupe(doRefresh);\n\n const getIdToken = async ({ forceRefresh = false } = {}): Promise<string | null> => {\n const tokens = getTokens();\n if (tokens === null) return null;\n if (forceRefresh) return (await refreshShared()).token;\n\n const expiresAt = readTokenExpiry(tokens.token);\n // Unknown expiry is left to the 401 path; a `0` here would rotate on every request.\n if (expiresAt === null) return tokens.token;\n if (Date.now() < expiresAt - refreshLeadTimeMs) return tokens.token;\n\n // Proactive rotation is best-effort — a real 401 drives the mandatory one.\n return refreshShared()\n .then((fresh) => fresh.token)\n .catch(() => tokens.token);\n };\n\n return { getIdToken, getTokens, notifyExpired: () => onSessionExpired?.() };\n};\n","import { HttpHeader, type MiddlewareFn } from '../../fetchClient';\nimport { isUnauthorized } from '../../keboola/bearer/credential';\n\nimport type { DeveloperPortalCredential } from './credential';\n\n/**\n * Stamps the id token, and on a 401 force-refreshes and replays once. Mirrors\n * `createBearerAuthMiddleware`, minus the `Bearer ` prefix apps-api does not use.\n *\n * An anonymous session passes through unstamped, so a failed login is never read as session expiry.\n */\nexport const createDeveloperPortalAuthMiddleware = (\n credential: DeveloperPortalCredential,\n): MiddlewareFn => {\n return (next) => async (request) => {\n const token = await credential.getIdToken();\n if (token === null) return next(request);\n\n // Cloned before the first attempt consumes the body. Cloning the `Request` carries a binary or\n // FormData payload through byte-for-byte.\n const retryRequest = request.request.clone();\n request.request.headers.set(HttpHeader.AUTHORIZATION, token);\n\n try {\n return await next(request);\n } catch (error) {\n if (!isUnauthorized(error)) throw error;\n\n const refreshed = await credential.getIdToken({ forceRefresh: true }).catch(() => null);\n // Nothing to replay with, because a concurrent sign-out landed or the rotation failed. The\n // caller's request failed with a 401, so that is what they see.\n if (refreshed === null) throw error;\n retryRequest.headers.set(HttpHeader.AUTHORIZATION, refreshed);\n\n try {\n return await next({ ...request, request: retryRequest });\n } catch (retryError) {\n if (isUnauthorized(retryError)) credential.notifyExpired();\n throw retryError;\n }\n }\n };\n};\n","import { createDeveloperPortalClient } from '../../clients/developerPortal/developerPortalClient';\nimport type { DeveloperPortalTokens } from '../../clients/developerPortal/tokens';\nimport type { LoginSuccess } from '../../clients/developerPortal/types';\nimport type { MiddlewareFn } from '../../fetchClient';\nimport { createStore } from '../../utils';\n\nimport { createDeveloperPortalCredential } from './credential';\nimport { createDeveloperPortalAuthMiddleware } from './middleware';\n\nexport type DeveloperPortalSdkOptions = {\n baseUrl: string;\n /** Session to restore on construction — e.g. a trio read back out of `localStorage`. */\n tokens?: DeveloperPortalTokens | null;\n /** Persistence hook, fired on sign-in, every rotation, and with `null` on sign-out or expiry. */\n onTokensChange?: (tokens: DeveloperPortalTokens | null) => void;\n /** The session is dead; tokens are already cleared. The consumer redirects to sign-in. */\n onSessionExpired?: () => void;\n refreshLeadTimeMs?: number;\n middlewares?: MiddlewareFn[];\n};\n\n/**\n * `createDeveloperPortalClient` plus the session that keeps it authenticated: the token store, the\n * credential, the auth middleware, and the tokens the four self-authenticating endpoints need.\n *\n * It constructs its client rather than receiving one like `createTagSdk` does, because the middleware\n * needs the credential, the credential needs the session, and the session needs a client to rotate\n * with. `createKeboola` closes the same cycle the same way, and stays separate from this one because\n * apps-api is its own identity domain.\n */\nexport const createDeveloperPortalSdk = ({\n baseUrl,\n tokens: initialTokens = null,\n onTokensChange,\n onSessionExpired,\n refreshLeadTimeMs,\n middlewares = [],\n}: DeveloperPortalSdkOptions) => {\n const store = createStore<DeveloperPortalTokens | null>(initialTokens);\n store.subscribe((value) => onTokensChange?.(value));\n\n const getTokens = () => store.get();\n\n const requireTokens = (action: string): DeveloperPortalTokens => {\n const tokens = store.get();\n if (tokens === null) {\n throw new Error(`Developer Portal: ${action} requires a signed-in session.`);\n }\n return tokens;\n };\n\n // No auth middleware: `refreshTokens` sets its own header, so a rotation cannot recurse into the\n // middleware that triggered it.\n const refreshClient = createDeveloperPortalClient({ baseUrl, middlewares });\n\n const refresh = async (): Promise<DeveloperPortalTokens> => {\n const before = store.get();\n if (before === null) {\n throw new Error('Cannot refresh the Developer Portal session: signed out.');\n }\n\n const { token, accessToken } = await refreshClient.auth.refreshTokens(before.refreshToken);\n const next: DeveloperPortalTokens = { token, accessToken, refreshToken: before.refreshToken };\n\n // Sign-out wins over an in-flight rotation: without this, a `clear()` that lands while the request\n // is on the wire is undone by the response, silently signing the user back in.\n const after = store.get();\n if (after === null || after.refreshToken !== before.refreshToken) {\n throw new Error('Developer Portal session changed while refreshing; discarding the result.');\n }\n\n store.set(next);\n return next;\n };\n\n const clear = () => store.set(null);\n\n const credential = createDeveloperPortalCredential({\n refresh,\n getTokens,\n refreshLeadTimeMs,\n onSessionExpired: () => {\n clear();\n onSessionExpired?.();\n },\n });\n\n const client = createDeveloperPortalClient({\n baseUrl,\n middlewares,\n authMiddleware: createDeveloperPortalAuthMiddleware(credential),\n });\n\n // `refreshTokens` is not re-exposed: rotating outside the store would leave the session holding\n // tokens the server has moved past. `session.refresh()` is the supported way.\n const { refreshTokens: _storeBypassingRotation, ...auth } = client.auth;\n\n const api = {\n ...client,\n auth: {\n ...auth,\n logout: async (signal?: AbortSignal) =>\n client.auth.logout(requireTokens('sign-out').accessToken, signal),\n // Both MFA calls bypass the reactive 401 path, so rotate proactively first.\n setupMfa: async (signal?: AbortSignal) => {\n await credential.getIdToken();\n const { token, accessToken } = requireTokens('MFA enrolment');\n return client.auth.setupMfa({ idToken: token, accessToken }, signal);\n },\n confirmMfa: async (code: string, signal?: AbortSignal) => {\n await credential.getIdToken();\n const { token, accessToken } = requireTokens('MFA confirmation');\n return client.auth.confirmMfa({ idToken: token, accessToken, code }, signal);\n },\n },\n };\n\n const session = {\n set: (result: LoginSuccess) => {\n store.set({\n token: result.token,\n accessToken: result.accessToken,\n refreshToken: result.refreshToken,\n });\n },\n get: getTokens,\n subscribe: store.subscribe,\n clear,\n /** Rotates if the id token is inside the lead time. Best-effort; the 401 path is the guarantee. */\n ensureFresh: async (): Promise<void> => {\n await credential.getIdToken();\n },\n /**\n * Rotates now, for a change of *claims* rather than age — leaving a vendor is the case that\n * matters, since the stale `profile` claim keeps scoping requests to a vendor the user just left.\n * Propagates failure: a caller forcing this needs to know whether the claims actually changed.\n */\n refresh: async (): Promise<void> => {\n await credential.getIdToken({ forceRefresh: true });\n },\n isAuthenticated: () => store.get() !== null,\n };\n\n return { api, session };\n};\n\nexport type DeveloperPortalSdk = ReturnType<typeof createDeveloperPortalSdk>;\nexport type DeveloperPortalSession = DeveloperPortalSdk['session'];\n"],"mappings":";;;;;;;;;;;;;;AAOA,MAAa,mBAAmB,UAAiC;CAC/D,MAAM,WAAW,MAAM,MAAM,GAAG;CAChC,IAAI,SAAS,WAAW,GAAG,OAAO;CAElC,MAAM,UAAU,SAAS;CACzB,IAAI,YAAY,KAAA,KAAa,YAAY,IAAI,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AAE,cAAc,KAAK,CAAC;GACpD;GACA,uBAAuB,MAAM,IAAI,MAAM;EAGrB;CAAE;AACxB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isUnauthorized","dedupe","HttpHeader","isUnauthorized","createStore","createDeveloperPortalClient"],"sources":["../../../src/sdks/developerPortal/tokenExpiry.ts","../../../src/sdks/developerPortal/credential.ts","../../../src/sdks/developerPortal/middleware.ts","../../../src/sdks/developerPortal/developerPortalSdk.ts"],"sourcesContent":["/**\n * Reads a JWT's `exp` claim as milliseconds, or `null` when unparseable (\"expiry unknown\", which the\n * caller leaves to the 401 path). A read, not a verification.\n *\n * Needed because apps-api reports `expiresIn` on login but never on refresh, so it cannot keep a\n * proactive-refresh clock honest past the first rotation. The token always carries its own expiry.\n */\nexport const readTokenExpiry = (token: string): number | null => {\n const segments = token.split('.');\n if (segments.length !== 3) return null;\n\n const payload = segments[1];\n if (payload === undefined || payload === '') return null;\n\n try {\n // base64url -> base64, and re-pad: `atob` requires padding, base64url omits it.\n const base64 = payload.replaceAll('-', '+').replaceAll('_', '/');\n const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');\n const claims: unknown = JSON.parse(atob(padded));\n if (typeof claims !== 'object' || claims === null || !('exp' in claims)) return null;\n const { exp } = claims as { exp: unknown };\n if (typeof exp !== 'number' || !Number.isFinite(exp)) return null;\n return exp * 1000;\n } catch {\n return null;\n }\n};\n","import type { DeveloperPortalTokens } from '../../clients/developerPortal/tokens';\nimport { isUnauthorized } from '../../keboola/bearer/credential';\nimport { dedupe } from '../../utils';\n\nimport { readTokenExpiry } from './tokenExpiry';\n\ntype Options = {\n refresh: () => Promise<DeveloperPortalTokens>;\n /** Live read from the session, so this holds no token of its own. `null` when signed out. */\n getTokens: () => DeveloperPortalTokens | null;\n /** May fire more than once; the caller owns any fire-once latch. */\n onSessionExpired?: () => void;\n /**\n * An absolute lead time rather than `createBearerCredential`'s fractional threshold: that needs the\n * token's full lifetime, and apps-api reports `expiresIn` on login only, never on refresh.\n */\n refreshLeadTimeMs?: number;\n};\n\nconst DEFAULT_REFRESH_LEAD_TIME_MS = 5 * 60 * 1000;\n\nexport type DeveloperPortalCredential = {\n getIdToken: (options?: { forceRefresh?: boolean }) => Promise<string | null>;\n getTokens: () => DeveloperPortalTokens | null;\n notifyExpired: () => void;\n};\n\n/** Mirrors `createBearerCredential`, over the id token of the trio. */\nexport const createDeveloperPortalCredential = ({\n refresh,\n getTokens,\n onSessionExpired,\n refreshLeadTimeMs = DEFAULT_REFRESH_LEAD_TIME_MS,\n}: Options): DeveloperPortalCredential => {\n const doRefresh = async (): Promise<DeveloperPortalTokens> => {\n try {\n return await refresh();\n } catch (error) {\n // Only a 401 means the refresh token is dead. Signing out over a 5xx would be a self-inflicted\n // logout, so anything else propagates without expiring the session.\n if (isUnauthorized(error)) onSessionExpired?.();\n throw error;\n }\n };\n\n // N concurrent 401s must cause one rotation: each extra one invalidates the tokens the others got.\n const refreshShared = dedupe(doRefresh);\n\n const getIdToken = async ({ forceRefresh = false } = {}): Promise<string | null> => {\n const tokens = getTokens();\n if (tokens === null) return null;\n if (forceRefresh) return (await refreshShared()).token;\n\n const expiresAt = readTokenExpiry(tokens.token);\n // Unknown expiry is left to the 401 path; a `0` here would rotate on every request.\n if (expiresAt === null) return tokens.token;\n if (Date.now() < expiresAt - refreshLeadTimeMs) return tokens.token;\n\n // Proactive rotation is best-effort — a real 401 drives the mandatory one.\n return refreshShared()\n .then((fresh) => fresh.token)\n .catch(() => tokens.token);\n };\n\n return { getIdToken, getTokens, notifyExpired: () => onSessionExpired?.() };\n};\n","import { HttpHeader, type MiddlewareFn } from '../../fetchClient';\nimport { isUnauthorized } from '../../keboola/bearer/credential';\n\nimport type { DeveloperPortalCredential } from './credential';\n\n/**\n * Stamps the id token, and on a 401 force-refreshes and replays once. Mirrors\n * `createBearerAuthMiddleware`, minus the `Bearer ` prefix apps-api does not use.\n *\n * An anonymous session passes through unstamped, so a failed login is never read as session expiry.\n */\nexport const createDeveloperPortalAuthMiddleware = (\n credential: DeveloperPortalCredential,\n): MiddlewareFn => {\n return (next) => async (request) => {\n const token = await credential.getIdToken();\n if (token === null) return next(request);\n\n // Cloned before the first attempt consumes the body. Cloning the `Request` carries a binary or\n // FormData payload through byte-for-byte.\n const retryRequest = request.request.clone();\n request.request.headers.set(HttpHeader.AUTHORIZATION, token);\n\n try {\n return await next(request);\n } catch (error) {\n if (!isUnauthorized(error)) throw error;\n\n const refreshed = await credential.getIdToken({ forceRefresh: true }).catch(() => null);\n // Nothing to replay with, because a concurrent sign-out landed or the rotation failed. The\n // caller's request failed with a 401, so that is what they see.\n if (refreshed === null) throw error;\n retryRequest.headers.set(HttpHeader.AUTHORIZATION, refreshed);\n\n try {\n return await next({ ...request, request: retryRequest });\n } catch (retryError) {\n if (isUnauthorized(retryError)) credential.notifyExpired();\n throw retryError;\n }\n }\n };\n};\n","import { createDeveloperPortalClient } from '../../clients/developerPortal/developerPortalClient';\nimport type { DeveloperPortalTokens } from '../../clients/developerPortal/tokens';\nimport type { LoginSuccess } from '../../clients/developerPortal/types';\nimport type { MiddlewareFn } from '../../fetchClient';\nimport { createStore } from '../../utils';\n\nimport { createDeveloperPortalCredential } from './credential';\nimport { createDeveloperPortalAuthMiddleware } from './middleware';\n\nexport type DeveloperPortalSdkOptions = {\n baseUrl: string;\n /** Session to restore on construction — e.g. a trio read back out of `localStorage`. */\n tokens?: DeveloperPortalTokens | null;\n /** Persistence hook, fired on sign-in, every rotation, and with `null` on sign-out or expiry. */\n onTokensChange?: (tokens: DeveloperPortalTokens | null) => void;\n /** The session is dead; tokens are already cleared. The consumer redirects to sign-in. */\n onSessionExpired?: () => void;\n refreshLeadTimeMs?: number;\n middlewares?: MiddlewareFn[];\n};\n\n/**\n * `createDeveloperPortalClient` plus the session that keeps it authenticated: the token store, the\n * credential, the auth middleware, and the tokens the four self-authenticating endpoints need.\n *\n * It constructs its client rather than receiving one like `createTagSdk` does, because the middleware\n * needs the credential, the credential needs the session, and the session needs a client to rotate\n * with. `createKeboola` closes the same cycle the same way, and stays separate from this one because\n * apps-api is its own identity domain.\n */\nexport const createDeveloperPortalSdk = ({\n baseUrl,\n tokens: initialTokens = null,\n onTokensChange,\n onSessionExpired,\n refreshLeadTimeMs,\n middlewares = [],\n}: DeveloperPortalSdkOptions) => {\n const store = createStore<DeveloperPortalTokens | null>(initialTokens);\n store.subscribe((value) => onTokensChange?.(value));\n\n const getTokens = () => store.get();\n\n const requireTokens = (action: string): DeveloperPortalTokens => {\n const tokens = store.get();\n if (tokens === null) {\n throw new Error(`Developer Portal: ${action} requires a signed-in session.`);\n }\n return tokens;\n };\n\n // No auth middleware: `refreshTokens` sets its own header, so a rotation cannot recurse into the\n // middleware that triggered it.\n const refreshClient = createDeveloperPortalClient({ baseUrl, middlewares });\n\n const refresh = async (): Promise<DeveloperPortalTokens> => {\n const before = store.get();\n if (before === null) {\n throw new Error('Cannot refresh the Developer Portal session: signed out.');\n }\n\n const { token, accessToken } = await refreshClient.auth.refreshTokens(before.refreshToken);\n const next: DeveloperPortalTokens = { token, accessToken, refreshToken: before.refreshToken };\n\n // Sign-out wins over an in-flight rotation: without this, a `clear()` that lands while the request\n // is on the wire is undone by the response, silently signing the user back in.\n const after = store.get();\n if (after === null || after.refreshToken !== before.refreshToken) {\n throw new Error('Developer Portal session changed while refreshing; discarding the result.');\n }\n\n store.set(next);\n return next;\n };\n\n const clear = () => store.set(null);\n\n const credential = createDeveloperPortalCredential({\n refresh,\n getTokens,\n refreshLeadTimeMs,\n onSessionExpired: () => {\n clear();\n onSessionExpired?.();\n },\n });\n\n const client = createDeveloperPortalClient({\n baseUrl,\n middlewares,\n authMiddleware: createDeveloperPortalAuthMiddleware(credential),\n });\n\n // `refreshTokens` is not re-exposed: rotating outside the store would leave the session holding\n // tokens the server has moved past. `session.refresh()` is the supported way.\n const { refreshTokens: _storeBypassingRotation, ...auth } = client.auth;\n\n const api = {\n ...client,\n auth: {\n ...auth,\n logout: async (signal?: AbortSignal) =>\n client.auth.logout(requireTokens('sign-out').accessToken, signal),\n // Both MFA calls bypass the reactive 401 path, so rotate proactively first.\n setupMfa: async (signal?: AbortSignal) => {\n await credential.getIdToken();\n const { token, accessToken } = requireTokens('MFA enrolment');\n return client.auth.setupMfa({ idToken: token, accessToken }, signal);\n },\n confirmMfa: async (code: string, signal?: AbortSignal) => {\n await credential.getIdToken();\n const { token, accessToken } = requireTokens('MFA confirmation');\n return client.auth.confirmMfa({ idToken: token, accessToken, code }, signal);\n },\n },\n };\n\n const session = {\n set: (result: LoginSuccess) => {\n store.set({\n token: result.token,\n accessToken: result.accessToken,\n refreshToken: result.refreshToken,\n });\n },\n get: getTokens,\n subscribe: store.subscribe,\n clear,\n /** Rotates if the id token is inside the lead time. Best-effort; the 401 path is the guarantee. */\n ensureFresh: async (): Promise<void> => {\n await credential.getIdToken();\n },\n /**\n * Rotates now, for a change of *claims* rather than age — leaving a vendor is the case that\n * matters, since the stale `profile` claim keeps scoping requests to a vendor the user just left.\n * Propagates failure: a caller forcing this needs to know whether the claims actually changed.\n */\n refresh: async (): Promise<void> => {\n await credential.getIdToken({ forceRefresh: true });\n },\n isAuthenticated: () => store.get() !== null,\n };\n\n return { api, session };\n};\n\nexport type DeveloperPortalSdk = ReturnType<typeof createDeveloperPortalSdk>;\nexport type DeveloperPortalSession = DeveloperPortalSdk['session'];\n"],"mappings":";;;;;;;;;;;;;;AAOA,MAAa,mBAAmB,UAAiC;CAC/D,MAAM,WAAW,MAAM,MAAM,GAAG;CAChC,IAAI,SAAS,WAAW,GAAG,OAAO;CAElC,MAAM,UAAU,SAAS;CACzB,IAAI,YAAY,KAAA,KAAa,YAAY,IAAI,OAAO;CAEpD,IAAI;EAEF,MAAM,SAAS,QAAQ,WAAW,KAAK,GAAG,CAAC,CAAC,WAAW,KAAK,GAAG;EAC/D,MAAM,SAAS,OAAO,OAAO,OAAO,UAAW,IAAK,OAAO,SAAS,KAAM,GAAI,GAAG;EACjF,MAAM,SAAkB,K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dateAppInput, L as UpdateVendorAsAdminInput, N as SignUpInput, R as UpdateVendorInput, S as LoginSuccess, W as components, _ as GetVendorUsersQuery, b as LoginInput, c as ConfirmAccountInput, d as CreateVendorAsAdminInput, f as CreateVendorInput, g as GetChangesQuery, h as GetAppsQuery, k as RejectAppInput, l as CreateAppInput, p as DeprecateAppInput, s as ApproveVendorInput, t as AdminPaginationQuery, u as CreateServiceAccountInput } from "../../types-
|
|
3
|
-
import { t as DeveloperPortalTokens } from "../../index-
|
|
1
|
+
import { E as MiddlewareFn } from "../../index-DhVFuQDv.cjs";
|
|
2
|
+
import { A as ResetPasswordConfirmInput, E as PaginationQuery, F as UpdateAppAsAdminInput, I as UpdateAppInput, L as UpdateVendorAsAdminInput, N as SignUpInput, R as UpdateVendorInput, S as LoginSuccess, W as components, _ as GetVendorUsersQuery, b as LoginInput, c as ConfirmAccountInput, d as CreateVendorAsAdminInput, f as CreateVendorInput, g as GetChangesQuery, h as GetAppsQuery, k as RejectAppInput, l as CreateAppInput, p as DeprecateAppInput, s as ApproveVendorInput, t as AdminPaginationQuery, u as CreateServiceAccountInput } from "../../types-B6JJCta-.cjs";
|
|
3
|
+
import { t as DeveloperPortalTokens } from "../../index-exNi3I2Q.cjs";
|
|
4
|
+
import { n as Listener } from "../../emitter-dLF1Fyfg.cjs";
|
|
4
5
|
//#region src/sdks/developerPortal/developerPortalSdk.d.ts
|
|
5
6
|
type DeveloperPortalSdkOptions = {
|
|
6
7
|
baseUrl: string;
|
|
@@ -1351,7 +1352,7 @@ declare const createDeveloperPortalSdk: ({ baseUrl, tokens: initialTokens, onTok
|
|
|
1351
1352
|
session: {
|
|
1352
1353
|
set: (result: LoginSuccess) => void;
|
|
1353
1354
|
get: () => DeveloperPortalTokens | null;
|
|
1354
|
-
subscribe: (listener:
|
|
1355
|
+
subscribe: (listener: Listener<DeveloperPortalTokens | null>) => () => void;
|
|
1355
1356
|
clear: () => void;
|
|
1356
1357
|
/** Rotates if the id token is inside the lead time. Best-effort; the 401 path is the guarantee. */
|
|
1357
1358
|
ensureFresh: () => Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as ResetPasswordConfirmInput, E as PaginationQuery, F as UpdateAppAsAdminInput, I as UpdateAppInput, L as UpdateVendorAsAdminInput, N as SignUpInput, R as UpdateVendorInput, S as LoginSuccess, W as components, _ as GetVendorUsersQuery, b as LoginInput, c as ConfirmAccountInput, d as CreateVendorAsAdminInput, f as CreateVendorInput, g as GetChangesQuery, h as GetAppsQuery, k as RejectAppInput, l as CreateAppInput, p as DeprecateAppInput, s as ApproveVendorInput, t as AdminPaginationQuery, u as CreateServiceAccountInput } from "../../types-
|
|
3
|
-
import { t as DeveloperPortalTokens } from "../../index-
|
|
1
|
+
import { E as MiddlewareFn } from "../../index-DVhTNwvu.js";
|
|
2
|
+
import { A as ResetPasswordConfirmInput, E as PaginationQuery, F as UpdateAppAsAdminInput, I as UpdateAppInput, L as UpdateVendorAsAdminInput, N as SignUpInput, R as UpdateVendorInput, S as LoginSuccess, W as components, _ as GetVendorUsersQuery, b as LoginInput, c as ConfirmAccountInput, d as CreateVendorAsAdminInput, f as CreateVendorInput, g as GetChangesQuery, h as GetAppsQuery, k as RejectAppInput, l as CreateAppInput, p as DeprecateAppInput, s as ApproveVendorInput, t as AdminPaginationQuery, u as CreateServiceAccountInput } from "../../types-DHqIJKwx.js";
|
|
3
|
+
import { t as DeveloperPortalTokens } from "../../index-ChMtULt4.js";
|
|
4
|
+
import { n as Listener } from "../../emitter-dLF1Fyfg.js";
|
|
4
5
|
//#region src/sdks/developerPortal/developerPortalSdk.d.ts
|
|
5
6
|
type DeveloperPortalSdkOptions = {
|
|
6
7
|
baseUrl: string;
|
|
@@ -1351,7 +1352,7 @@ declare const createDeveloperPortalSdk: ({ baseUrl, tokens: initialTokens, onTok
|
|
|
1351
1352
|
session: {
|
|
1352
1353
|
set: (result: LoginSuccess) => void;
|
|
1353
1354
|
get: () => DeveloperPortalTokens | null;
|
|
1354
|
-
subscribe: (listener:
|
|
1355
|
+
subscribe: (listener: Listener<DeveloperPortalTokens | null>) => () => void;
|
|
1355
1356
|
clear: () => void;
|
|
1356
1357
|
/** Rotates if the id token is inside the lead time. Best-effort; the 401 path is the guarantee. */
|
|
1357
1358
|
ensureFresh: () => Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as dedupe } from "../../dedupe-DYIHgZoG.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as isUnauthorized } from "../../credential-
|
|
5
|
-
import { t as createDeveloperPortalClient } from "../../developerPortalClient-
|
|
2
|
+
import { t as createStore } from "../../store-C9FQCHGe.js";
|
|
3
|
+
import { s as HttpHeader } from "../../createFetchClient-DdyZMhxO.js";
|
|
4
|
+
import { n as isUnauthorized } from "../../credential-Bxv7yxOZ.js";
|
|
5
|
+
import { t as createDeveloperPortalClient } from "../../developerPortalClient-jk46sjwP.js";
|
|
6
6
|
//#region src/sdks/developerPortal/tokenExpiry.ts
|
|
7
7
|
/**
|
|
8
8
|
* Reads a JWT's `exp` claim as milliseconds, or `null` when unparseable ("expiry unknown", which the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_jobStatus = require("../../jobStatus-
|
|
2
|
+
const require_jobStatus = require("../../jobStatus-0_Y3Sr4i.cjs");
|
|
3
3
|
const require_QueryJobTimeoutError = require("../../QueryJobTimeoutError-CVNPdCWX.cjs");
|
|
4
4
|
const require_ValidationError = require("../../ValidationError-h5qvwahi.cjs");
|
|
5
5
|
//#region src/sdks/queryService/queryServiceSdk.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createQueryServiceSdk, n as ExecuteQueryOptions, r as WaitForJobOptions } from "../../index-
|
|
1
|
+
import { i as createQueryServiceSdk, n as ExecuteQueryOptions, r as WaitForJobOptions } from "../../index-DIVvL54G.cjs";
|
|
2
2
|
export { ExecuteQueryOptions, WaitForJobOptions, createQueryServiceSdk };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createQueryServiceSdk, n as ExecuteQueryOptions, r as WaitForJobOptions } from "../../index-
|
|
1
|
+
import { i as createQueryServiceSdk, n as ExecuteQueryOptions, r as WaitForJobOptions } from "../../index-B0V1pJAa.js";
|
|
2
2
|
export { ExecuteQueryOptions, WaitForJobOptions, createQueryServiceSdk };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as poll, t as jobStatus } from "../../jobStatus-
|
|
1
|
+
import { i as poll, t as jobStatus } from "../../jobStatus-PSZJMTiA.js";
|
|
2
2
|
import { r as QueryJobError, t as QueryJobTimeoutError } from "../../QueryJobTimeoutError-C7JbNGOM.js";
|
|
3
3
|
import { t as ValidationError } from "../../ValidationError-CzPWydEb.js";
|
|
4
4
|
//#region src/sdks/queryService/queryServiceSdk.ts
|
|
@@ -2,6 +2,163 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_concurrent = require("../../concurrent-tbiIa0UL.cjs");
|
|
3
3
|
const require_generateUUID = require("../../generateUUID-C6qKBPIv.cjs");
|
|
4
4
|
let zod = require("zod");
|
|
5
|
+
//#region src/sdks/semanticLayer/errorMessage.ts
|
|
6
|
+
/**
|
|
7
|
+
* The message out of a metastore error body.
|
|
8
|
+
*
|
|
9
|
+
* - The metastore reports what is actually wrong with a write only inside `errors[].message`
|
|
10
|
+
* (`missing property 'fqn'`). The HTTP status and the response's own message say no more than
|
|
11
|
+
* "Validation failed", so a caller that renders those alone tells a user nothing actionable.
|
|
12
|
+
* - Every shape that is not that envelope returns `undefined` rather than a placeholder, so the
|
|
13
|
+
* caller keeps its own fallback (`?? error.message`) instead of rendering a stand-in for one.
|
|
14
|
+
* - Only the first error: the metastore reports fields one at a time, so a list would be a list
|
|
15
|
+
* of one.
|
|
16
|
+
*/
|
|
17
|
+
const metastoreErrorMessage = (data) => {
|
|
18
|
+
if (typeof data !== "object" || data === null) return void 0;
|
|
19
|
+
const errors = data.errors;
|
|
20
|
+
if (!Array.isArray(errors)) return void 0;
|
|
21
|
+
const first = errors[0];
|
|
22
|
+
if (typeof first !== "object" || first === null) return void 0;
|
|
23
|
+
const message = first.message;
|
|
24
|
+
return typeof message === "string" && message ? message : void 0;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/sdks/semanticLayer/vocabulary.ts
|
|
28
|
+
/**
|
|
29
|
+
* The closed value sets the metastore accepts inside a semantic object's `data`.
|
|
30
|
+
*
|
|
31
|
+
* - Each one is the single runtime source for a union in `./types`, which derives the type from
|
|
32
|
+
* the array here. A value cannot exist in the type and be missing from the list a dropdown or
|
|
33
|
+
* a validator is built from.
|
|
34
|
+
* - The addressing vocabulary (`SEMANTIC_OBJECT_TYPE`, `MODEL_CHILD_OBJECT_TYPES`) is a
|
|
35
|
+
* different axis — which object a call targets, not what may sit inside one — and stays beside
|
|
36
|
+
* the SDK methods that take it.
|
|
37
|
+
* - This file imports nothing: `./types` reads it, never the reverse.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* The dialects the metastore accepts, exactly as it spells them. A lowercase value is
|
|
41
|
+
* rejected with `422 value must be one of 'Snowflake', 'BigQuery'`, which surfaces only as a
|
|
42
|
+
* generic "Validation failed" — so callers need the real set rather than a bare `string`.
|
|
43
|
+
*
|
|
44
|
+
* `SemanticModelData.sql_dialect` stays `string` for now: narrowing it would break any caller
|
|
45
|
+
* passing a `string` variable, which is a major bump. Validate against this instead.
|
|
46
|
+
*/
|
|
47
|
+
const SQL_DIALECTS = ["Snowflake", "BigQuery"];
|
|
48
|
+
/** The metastore's constraint kinds. */
|
|
49
|
+
const CONSTRAINT_TYPES = [
|
|
50
|
+
"inequality",
|
|
51
|
+
"equality",
|
|
52
|
+
"range",
|
|
53
|
+
"composition",
|
|
54
|
+
"exclusion",
|
|
55
|
+
"temporal",
|
|
56
|
+
"conditional"
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* What a dataset field is for.
|
|
60
|
+
*
|
|
61
|
+
* - Enumerated, unlike a field's `type`: the metastore takes any type string, but only these
|
|
62
|
+
* four roles.
|
|
63
|
+
*/
|
|
64
|
+
const FIELD_ROLES = [
|
|
65
|
+
"key",
|
|
66
|
+
"dimension",
|
|
67
|
+
"measure",
|
|
68
|
+
"timestamp"
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* How loudly a violated constraint reports.
|
|
72
|
+
*
|
|
73
|
+
* - An unset severity is stored as `warning`, so a reader renders that rather than nothing.
|
|
74
|
+
*/
|
|
75
|
+
const CONSTRAINT_SEVERITIES = [
|
|
76
|
+
"error",
|
|
77
|
+
"warning",
|
|
78
|
+
"info"
|
|
79
|
+
];
|
|
80
|
+
/**
|
|
81
|
+
* What a constraint's rule is evaluated per.
|
|
82
|
+
*
|
|
83
|
+
* - An unset scope is stored as `global`.
|
|
84
|
+
*/
|
|
85
|
+
const CONSTRAINT_SCOPES = [
|
|
86
|
+
"global",
|
|
87
|
+
"per_location",
|
|
88
|
+
"per_date",
|
|
89
|
+
"per_category"
|
|
90
|
+
];
|
|
91
|
+
/** The comparisons a constraint's `ruleExpression` can make. */
|
|
92
|
+
const RULE_OPERATORS = [
|
|
93
|
+
"<",
|
|
94
|
+
"<=",
|
|
95
|
+
"=",
|
|
96
|
+
">=",
|
|
97
|
+
">",
|
|
98
|
+
"!=",
|
|
99
|
+
"between",
|
|
100
|
+
"in",
|
|
101
|
+
"sum_equals",
|
|
102
|
+
"ratio_between"
|
|
103
|
+
];
|
|
104
|
+
/** The join a relationship stands for. */
|
|
105
|
+
const RELATIONSHIP_JOIN_TYPES = ["left", "inner"];
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/sdks/semanticLayer/schemas.ts
|
|
108
|
+
/**
|
|
109
|
+
* Runtime validators for the semantic-layer payload shapes.
|
|
110
|
+
*
|
|
111
|
+
* These exist because the metastore's validation errors are opaque — a missing or misspelled
|
|
112
|
+
* field surfaces only as a generic "Validation failed", and a wrong `sql_dialect` casing as a
|
|
113
|
+
* 422 that names neither the field nor the accepted values. Parsing first turns those into a
|
|
114
|
+
* message that says what is wrong.
|
|
115
|
+
*
|
|
116
|
+
* **Only the fields the SDK types mark as required are declared.** The metastore owns each
|
|
117
|
+
* object type's full schema, so every schema is a `looseObject`: unknown fields pass through
|
|
118
|
+
* untouched rather than being stripped or rejected. Re-declaring the optional fields here
|
|
119
|
+
* would create a second source of truth that silently drops whatever the metastore adds next.
|
|
120
|
+
*
|
|
121
|
+
* The SDK does **not** parse on its own writes — these are for callers that accept untrusted
|
|
122
|
+
* or hand-authored input (an agent's tool call, a form submission) and want to fail early.
|
|
123
|
+
* `modelUUID` is omitted throughout: the SDK injects it, so callers never supply it.
|
|
124
|
+
*/
|
|
125
|
+
const semanticModelSchema = zod.z.looseObject({
|
|
126
|
+
name: zod.z.string().min(1),
|
|
127
|
+
sql_dialect: zod.z.enum(SQL_DIALECTS)
|
|
128
|
+
});
|
|
129
|
+
const semanticDatasetSchema = zod.z.looseObject({
|
|
130
|
+
name: zod.z.string().min(1),
|
|
131
|
+
tableId: zod.z.string().min(1),
|
|
132
|
+
fqn: zod.z.string().min(1)
|
|
133
|
+
});
|
|
134
|
+
const semanticMetricSchema = zod.z.looseObject({
|
|
135
|
+
name: zod.z.string().min(1),
|
|
136
|
+
sql: zod.z.string().min(1)
|
|
137
|
+
});
|
|
138
|
+
const semanticRelationshipSchema = zod.z.looseObject({
|
|
139
|
+
from: zod.z.string().min(1),
|
|
140
|
+
to: zod.z.string().min(1),
|
|
141
|
+
on: zod.z.string().min(1)
|
|
142
|
+
});
|
|
143
|
+
const semanticGlossarySchema = zod.z.looseObject({
|
|
144
|
+
term: zod.z.string().min(1),
|
|
145
|
+
definition: zod.z.string().min(1)
|
|
146
|
+
});
|
|
147
|
+
const semanticConstraintSchema = zod.z.looseObject({
|
|
148
|
+
name: zod.z.string().min(1),
|
|
149
|
+
constraintType: zod.z.enum(CONSTRAINT_TYPES),
|
|
150
|
+
metrics: zod.z.array(zod.z.string()),
|
|
151
|
+
rule: zod.z.string().min(1)
|
|
152
|
+
});
|
|
153
|
+
/** Keyed by object type so a caller can pick the schema from a `SemanticChildObjectType`. */
|
|
154
|
+
const SEMANTIC_CHILD_OBJECT_SCHEMAS = {
|
|
155
|
+
"semantic-dataset": semanticDatasetSchema,
|
|
156
|
+
"semantic-metric": semanticMetricSchema,
|
|
157
|
+
"semantic-relationship": semanticRelationshipSchema,
|
|
158
|
+
"semantic-glossary": semanticGlossarySchema,
|
|
159
|
+
"semantic-constraint": semanticConstraintSchema
|
|
160
|
+
};
|
|
161
|
+
//#endregion
|
|
5
162
|
//#region src/sdks/semanticLayer/semanticLayerSdk.ts
|
|
6
163
|
/**
|
|
7
164
|
* Thrown by `deleteModel` when the child cascade partially fails. Every child delete has
|
|
@@ -42,25 +199,6 @@ const MODEL_CHILD_OBJECT_TYPES = [
|
|
|
42
199
|
SEMANTIC_OBJECT_TYPE.GLOSSARY,
|
|
43
200
|
SEMANTIC_OBJECT_TYPE.CONSTRAINT
|
|
44
201
|
];
|
|
45
|
-
/**
|
|
46
|
-
* The dialects the metastore accepts, exactly as it spells them. A lowercase value is
|
|
47
|
-
* rejected with `422 value must be one of 'Snowflake', 'BigQuery'`, which surfaces only as a
|
|
48
|
-
* generic "Validation failed" — so callers need the real set rather than a bare `string`.
|
|
49
|
-
*
|
|
50
|
-
* `SemanticModelData.sql_dialect` stays `string` for now: narrowing it would break any caller
|
|
51
|
-
* passing a `string` variable, which is a major bump. Validate against this instead.
|
|
52
|
-
*/
|
|
53
|
-
const SQL_DIALECTS = ["Snowflake", "BigQuery"];
|
|
54
|
-
/** The metastore's constraint kinds. Runtime counterpart to `SemanticConstraintType`. */
|
|
55
|
-
const CONSTRAINT_TYPES = [
|
|
56
|
-
"inequality",
|
|
57
|
-
"equality",
|
|
58
|
-
"range",
|
|
59
|
-
"composition",
|
|
60
|
-
"exclusion",
|
|
61
|
-
"temporal",
|
|
62
|
-
"conditional"
|
|
63
|
-
];
|
|
64
202
|
const DEFAULT_BRANCH = "main";
|
|
65
203
|
const WRITE_CONCURRENCY = 5;
|
|
66
204
|
const mapObject = (item) => ({
|
|
@@ -288,68 +426,19 @@ const createSemanticLayerSdk = ({ metastoreClient }) => {
|
|
|
288
426
|
};
|
|
289
427
|
};
|
|
290
428
|
//#endregion
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
* Runtime validators for the semantic-layer payload shapes.
|
|
294
|
-
*
|
|
295
|
-
* These exist because the metastore's validation errors are opaque — a missing or misspelled
|
|
296
|
-
* field surfaces only as a generic "Validation failed", and a wrong `sql_dialect` casing as a
|
|
297
|
-
* 422 that names neither the field nor the accepted values. Parsing first turns those into a
|
|
298
|
-
* message that says what is wrong.
|
|
299
|
-
*
|
|
300
|
-
* **Only the fields the SDK types mark as required are declared.** The metastore owns each
|
|
301
|
-
* object type's full schema, so every schema is a `looseObject`: unknown fields pass through
|
|
302
|
-
* untouched rather than being stripped or rejected. Re-declaring the optional fields here
|
|
303
|
-
* would create a second source of truth that silently drops whatever the metastore adds next.
|
|
304
|
-
*
|
|
305
|
-
* The SDK does **not** parse on its own writes — these are for callers that accept untrusted
|
|
306
|
-
* or hand-authored input (an agent's tool call, a form submission) and want to fail early.
|
|
307
|
-
* `modelUUID` is omitted throughout: the SDK injects it, so callers never supply it.
|
|
308
|
-
*/
|
|
309
|
-
const semanticModelSchema = zod.z.looseObject({
|
|
310
|
-
name: zod.z.string().min(1),
|
|
311
|
-
sql_dialect: zod.z.enum(SQL_DIALECTS)
|
|
312
|
-
});
|
|
313
|
-
const semanticDatasetSchema = zod.z.looseObject({
|
|
314
|
-
name: zod.z.string().min(1),
|
|
315
|
-
tableId: zod.z.string().min(1),
|
|
316
|
-
fqn: zod.z.string().min(1)
|
|
317
|
-
});
|
|
318
|
-
const semanticMetricSchema = zod.z.looseObject({
|
|
319
|
-
name: zod.z.string().min(1),
|
|
320
|
-
sql: zod.z.string().min(1)
|
|
321
|
-
});
|
|
322
|
-
const semanticRelationshipSchema = zod.z.looseObject({
|
|
323
|
-
from: zod.z.string().min(1),
|
|
324
|
-
to: zod.z.string().min(1),
|
|
325
|
-
on: zod.z.string().min(1)
|
|
326
|
-
});
|
|
327
|
-
const semanticGlossarySchema = zod.z.looseObject({
|
|
328
|
-
term: zod.z.string().min(1),
|
|
329
|
-
definition: zod.z.string().min(1)
|
|
330
|
-
});
|
|
331
|
-
const semanticConstraintSchema = zod.z.looseObject({
|
|
332
|
-
name: zod.z.string().min(1),
|
|
333
|
-
constraintType: zod.z.enum(CONSTRAINT_TYPES),
|
|
334
|
-
metrics: zod.z.array(zod.z.string()),
|
|
335
|
-
rule: zod.z.string().min(1)
|
|
336
|
-
});
|
|
337
|
-
/** Keyed by object type so a caller can pick the schema from a `SemanticChildObjectType`. */
|
|
338
|
-
const SEMANTIC_CHILD_OBJECT_SCHEMAS = {
|
|
339
|
-
"semantic-dataset": semanticDatasetSchema,
|
|
340
|
-
"semantic-metric": semanticMetricSchema,
|
|
341
|
-
"semantic-relationship": semanticRelationshipSchema,
|
|
342
|
-
"semantic-glossary": semanticGlossarySchema,
|
|
343
|
-
"semantic-constraint": semanticConstraintSchema
|
|
344
|
-
};
|
|
345
|
-
//#endregion
|
|
429
|
+
exports.CONSTRAINT_SCOPES = CONSTRAINT_SCOPES;
|
|
430
|
+
exports.CONSTRAINT_SEVERITIES = CONSTRAINT_SEVERITIES;
|
|
346
431
|
exports.CONSTRAINT_TYPES = CONSTRAINT_TYPES;
|
|
432
|
+
exports.FIELD_ROLES = FIELD_ROLES;
|
|
347
433
|
exports.MODEL_CHILD_OBJECT_TYPES = MODEL_CHILD_OBJECT_TYPES;
|
|
434
|
+
exports.RELATIONSHIP_JOIN_TYPES = RELATIONSHIP_JOIN_TYPES;
|
|
435
|
+
exports.RULE_OPERATORS = RULE_OPERATORS;
|
|
348
436
|
exports.SEMANTIC_CHILD_OBJECT_SCHEMAS = SEMANTIC_CHILD_OBJECT_SCHEMAS;
|
|
349
437
|
exports.SEMANTIC_OBJECT_TYPE = SEMANTIC_OBJECT_TYPE;
|
|
350
438
|
exports.SQL_DIALECTS = SQL_DIALECTS;
|
|
351
439
|
exports.SemanticLayerCascadeDeleteError = SemanticLayerCascadeDeleteError;
|
|
352
440
|
exports.createSemanticLayerSdk = createSemanticLayerSdk;
|
|
441
|
+
exports.metastoreErrorMessage = metastoreErrorMessage;
|
|
353
442
|
exports.semanticConstraintSchema = semanticConstraintSchema;
|
|
354
443
|
exports.semanticDatasetSchema = semanticDatasetSchema;
|
|
355
444
|
exports.semanticGlossarySchema = semanticGlossarySchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["generateUUID","concurrent","z"],"sources":["../../../src/sdks/semanticLayer/semanticLayerSdk.ts","../../../src/sdks/semanticLayer/schemas.ts"],"sourcesContent":["import { concurrent, generateUUID } from '../../utils';\n\nimport type {\n CreateSemanticObjectMeta,\n MetastoreClient,\n SemanticChildObjectDataMap,\n SemanticChildObjectType,\n SemanticConstraintType,\n SemanticModelChildDeleteFailure,\n SemanticModelChildRef,\n SemanticModelData,\n SemanticObject,\n SemanticObjectMeta,\n SemanticObjectType,\n UpdateSemanticObjectMeta,\n} from './types';\n\n/**\n * Thrown by `deleteModel` when the child cascade partially fails. Every child delete has\n * settled by the time this is thrown — nothing keeps deleting in the background — and the\n * model itself was kept, so the exact remaining state is knowable: `deletedChildren` are gone,\n * `failedChildren` (and the model) still exist. `errors` carries the per-child rejection\n * reasons, AggregateError-style.\n */\nexport class SemanticLayerCascadeDeleteError extends AggregateError {\n readonly modelUUID: string;\n readonly deletedChildren: SemanticModelChildRef[];\n readonly failedChildren: SemanticModelChildDeleteFailure[];\n\n constructor({\n modelUUID,\n deletedChildren,\n failedChildren,\n }: {\n modelUUID: string;\n deletedChildren: SemanticModelChildRef[];\n failedChildren: SemanticModelChildDeleteFailure[];\n }) {\n const total = deletedChildren.length + failedChildren.length;\n super(\n failedChildren.map((failure) => failure.error),\n `The model was kept because ${failedChildren.length} of its ${total} child objects ` +\n `could not be deleted (${deletedChildren.length} deleted).`,\n );\n this.name = 'SemanticLayerCascadeDeleteError';\n this.modelUUID = modelUUID;\n this.deletedChildren = deletedChildren;\n this.failedChildren = failedChildren;\n }\n}\n\nexport const SEMANTIC_OBJECT_TYPE = {\n MODEL: 'semantic-model',\n DATASET: 'semantic-dataset',\n METRIC: 'semantic-metric',\n RELATIONSHIP: 'semantic-relationship',\n GLOSSARY: 'semantic-glossary',\n CONSTRAINT: 'semantic-constraint',\n} as const satisfies Record<string, SemanticObjectType>;\n\n/**\n * `readonly` because this drives `createModelTree`, `listModelChildren` and `deleteModel` —\n * a consumer-side `.push()` would silently change what a cascade delete touches.\n */\nexport const MODEL_CHILD_OBJECT_TYPES: readonly SemanticChildObjectType[] = [\n SEMANTIC_OBJECT_TYPE.DATASET,\n SEMANTIC_OBJECT_TYPE.METRIC,\n SEMANTIC_OBJECT_TYPE.RELATIONSHIP,\n SEMANTIC_OBJECT_TYPE.GLOSSARY,\n SEMANTIC_OBJECT_TYPE.CONSTRAINT,\n] as const;\n\n/**\n * The dialects the metastore accepts, exactly as it spells them. A lowercase value is\n * rejected with `422 value must be one of 'Snowflake', 'BigQuery'`, which surfaces only as a\n * generic \"Validation failed\" — so callers need the real set rather than a bare `string`.\n *\n * `SemanticModelData.sql_dialect` stays `string` for now: narrowing it would break any caller\n * passing a `string` variable, which is a major bump. Validate against this instead.\n */\nexport const SQL_DIALECTS = ['Snowflake', 'BigQuery'] as const;\n\n/** The metastore's constraint kinds. Runtime counterpart to `SemanticConstraintType`. */\nexport const CONSTRAINT_TYPES = [\n 'inequality',\n 'equality',\n 'range',\n 'composition',\n 'exclusion',\n 'temporal',\n 'conditional',\n] as const satisfies readonly SemanticConstraintType[];\n\nconst DEFAULT_BRANCH = 'main';\n\n// The metastore has no bulk endpoint; large semantic-layer inits are written as\n// concurrent single POSTs (the same approach the ai-kit sl-toolkit importer uses).\nconst WRITE_CONCURRENCY = 5;\n\n// The live metastore envelope: `attributes` carries the object's data payload directly,\n// the UUID is the top-level `id`, and revision/branch/audit fields live in `meta`. The\n// legacy wrapper types in clients/metastore/repository/types.ts do not match this shape.\ntype RawSemanticObject<TData> = {\n type: string;\n id: string;\n attributes: TData;\n meta: SemanticObjectMeta;\n};\n\nconst mapObject = <TData>(item: RawSemanticObject<TData>): SemanticObject<TData> => ({\n uuid: item.id,\n data: item.attributes,\n meta: item.meta,\n});\n\nconst deriveOptionalObjectName = (data: Record<string, unknown>): string | undefined => {\n if (typeof data.name === 'string') return data.name;\n if (typeof data.term === 'string') return data.term;\n return undefined;\n};\n\nconst deriveObjectName = (data: Record<string, unknown>) =>\n deriveOptionalObjectName(data) ?? generateUUID();\n\n/**\n * The label a UI shows for an object, as opposed to the identifier it is addressed by.\n *\n * Constraints carry an optional `displayName`; kbc-ui's constraint tables already render\n * `displayName ?? name`, so a confirmation listing what a cascade delete would destroy has to\n * agree with them or it names objects the user can't find on screen.\n *\n * Deliberately **not** used for lookup: `displayName` is optional and not unique, so matching on\n * it would make `findObjectsByName` ambiguous for callers that resolve a write target by name.\n */\nconst deriveObjectLabel = (data: Record<string, unknown>): string | undefined => {\n if (typeof data.displayName === 'string' && data.displayName !== '') return data.displayName;\n return deriveOptionalObjectName(data);\n};\n\ntype Options = {\n metastoreClient: MetastoreClient;\n};\n\nexport const createSemanticLayerSdk = ({ metastoreClient }: Options) => {\n const _listObjects = async <TData extends Record<string, unknown>>(\n objectType: SemanticObjectType,\n signal?: AbortSignal,\n ) => {\n const response = await metastoreClient.repository.getMetaObjects<TData>({ objectType }, signal);\n return (response.data as unknown as RawSemanticObject<TData>[]).map(mapObject);\n };\n\n const listModels = async (signal?: AbortSignal) =>\n _listObjects<SemanticModelData>(SEMANTIC_OBJECT_TYPE.MODEL, signal);\n\n const createModel = async (data: SemanticModelData, meta: CreateSemanticObjectMeta = {}) => {\n const response = await metastoreClient.repository.createMetaObject<SemanticModelData>({\n objectType: SEMANTIC_OBJECT_TYPE.MODEL,\n data,\n branch: DEFAULT_BRANCH,\n ...meta,\n // Derived name wins over meta so the metastore name stays in sync with the payload.\n name: data.name,\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticModelData>);\n };\n\n const updateModel = async (\n modelUUID: string,\n data: Partial<SemanticModelData>,\n meta: UpdateSemanticObjectMeta = {},\n ) => {\n const response = await metastoreClient.repository.updateMetaObject<SemanticModelData>({\n objectType: SEMANTIC_OBJECT_TYPE.MODEL,\n UUID: modelUUID,\n data,\n ...meta,\n // Derived rename wins over meta so the metastore name stays in sync with the payload.\n ...(data.name ? { name: data.name } : {}),\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticModelData>);\n };\n\n const listObjects = async <T extends SemanticChildObjectType>(\n objectType: T,\n modelUUID: string,\n signal?: AbortSignal,\n ) => {\n const objects = await _listObjects<SemanticChildObjectDataMap[T]>(objectType, signal);\n return objects.filter((object) => object.data.modelUUID === modelUUID);\n };\n\n /**\n * Find a model's child objects by their user-facing name.\n *\n * Returns every match rather than resolving to one, because a name is not unique: the caller\n * decides whether that's an error (an agent needs an unambiguous target) or a choice to offer\n * (a UI can render a picker). Glossary entries key on `term`, so both are matched.\n */\n const findObjectsByName = async <T extends SemanticChildObjectType>(\n objectType: T,\n name: string,\n modelUUID: string,\n signal?: AbortSignal,\n ) => {\n const objects = await listObjects(objectType, modelUUID, signal);\n return objects.filter((object) => deriveOptionalObjectName(object.data) === name);\n };\n\n const createObject = async <T extends SemanticChildObjectType>(\n objectType: T,\n data: SemanticChildObjectDataMap[T],\n meta: CreateSemanticObjectMeta = {},\n ) => {\n const response = await metastoreClient.repository.createMetaObject<\n SemanticChildObjectDataMap[T]\n >({\n objectType,\n data,\n branch: DEFAULT_BRANCH,\n ...meta,\n // Derived name wins over meta so the metastore name stays in sync with the payload.\n name: deriveObjectName(data),\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticChildObjectDataMap[T]>);\n };\n\n const createObjects = async <T extends SemanticChildObjectType>(\n objectType: T,\n items: SemanticChildObjectDataMap[T][],\n meta: CreateSemanticObjectMeta = {},\n ) =>\n concurrent({\n items,\n process: async (data) => createObject(objectType, data, meta),\n concurrency: WRITE_CONCURRENCY,\n });\n\n // Create a model and all its child objects in one call: the model first (so its\n // UUID exists), then every child concurrently with the modelUUID injected.\n const createModelTree = async (\n model: SemanticModelData,\n children: Partial<{\n [T in SemanticChildObjectType]: Omit<SemanticChildObjectDataMap[T], 'modelUUID'>[];\n }>,\n meta: CreateSemanticObjectMeta = {},\n ) => {\n const createdModel = await createModel(model, meta);\n\n const items = MODEL_CHILD_OBJECT_TYPES.flatMap((objectType) =>\n (children[objectType] ?? []).map((data) => ({\n objectType,\n data: {\n ...data,\n modelUUID: createdModel.uuid,\n } satisfies SemanticChildObjectDataMap[typeof objectType],\n })),\n );\n\n const createdChildren = await concurrent({\n items,\n process: async ({ objectType, data }) => createObject(objectType, data, meta),\n concurrency: WRITE_CONCURRENCY,\n });\n\n return { model: createdModel, children: createdChildren };\n };\n\n const updateObject = async <T extends SemanticChildObjectType>(\n objectType: T,\n objectUUID: string,\n data: Partial<SemanticChildObjectDataMap[T]>,\n meta: UpdateSemanticObjectMeta = {},\n ) => {\n const name = deriveOptionalObjectName(data);\n const response = await metastoreClient.repository.updateMetaObject<\n SemanticChildObjectDataMap[T]\n >({\n objectType,\n UUID: objectUUID,\n data,\n ...meta,\n // Derived rename wins over meta so the metastore name stays in sync with the payload.\n ...(name ? { name } : {}),\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticChildObjectDataMap[T]>);\n };\n\n const deleteObject = async (objectType: SemanticChildObjectType, objectUUID: string) => {\n await metastoreClient.repository.deleteMetaObject({\n objectType,\n UUID: objectUUID,\n });\n };\n\n /**\n * Every child object of a model, across all five types, flattened.\n *\n * `deleteModel` uses this to find what to remove; callers can use it to say what a delete\n * would destroy *before* asking the user to confirm. Each entry's `name` is the object's\n * display label (a constraint's `displayName` in preference to its `name`, matching what the\n * SL tables render), so a confirmation lists objects as the user sees them on screen.\n *\n * Costs five list requests: the metastore has no per-model filter, so `listObjects`\n * fetches each collection and filters client-side.\n */\n const listModelChildren = async (\n modelUUID: string,\n signal?: AbortSignal,\n ): Promise<SemanticModelChildRef[]> => {\n const childrenByType = await Promise.all(\n MODEL_CHILD_OBJECT_TYPES.map(async (objectType) => {\n const objects = await listObjects(objectType, modelUUID, signal);\n return objects.map((object) => ({\n objectType,\n objectUUID: object.uuid,\n name: deriveObjectLabel(object.data),\n }));\n }),\n );\n\n return childrenByType.flat();\n };\n\n /**\n * Cascade delete: every child object first, the model itself only once its whole tree is\n * gone. Child deletes all settle — a failing child never aborts the others, so no delete\n * runs on detached after this rejects — and a partial failure surfaces as\n * `SemanticLayerCascadeDeleteError`, which says exactly which children were deleted and\n * which survived. The model is kept on any child failure so it never orphans children.\n */\n const deleteModel = async (modelUUID: string) => {\n const children = await listModelChildren(modelUUID);\n\n const outcomes = await concurrent({\n items: children,\n process: async (child) => {\n try {\n await deleteObject(child.objectType, child.objectUUID);\n return { ok: true as const, child };\n } catch (error) {\n return { ok: false as const, child, error };\n }\n },\n concurrency: WRITE_CONCURRENCY,\n });\n\n const deletedChildren: SemanticModelChildRef[] = [];\n const failedChildren: SemanticModelChildDeleteFailure[] = [];\n for (const outcome of outcomes) {\n if (outcome.ok) deletedChildren.push(outcome.child);\n else failedChildren.push({ ...outcome.child, error: outcome.error });\n }\n\n if (failedChildren.length > 0) {\n throw new SemanticLayerCascadeDeleteError({ modelUUID, deletedChildren, failedChildren });\n }\n\n await metastoreClient.repository.deleteMetaObject({\n objectType: SEMANTIC_OBJECT_TYPE.MODEL,\n UUID: modelUUID,\n });\n };\n\n /**\n * Replace the sibling projects granted GET/consumption access to a `targeted`-scope object.\n *\n * Passing an empty array clears every grant, leaving the object visible to its owning project\n * only. A grant conveys read access alone — the target projects can consume the definition but\n * never edit it, which is enforced metastore-side rather than here.\n */\n const replaceTargetProjects = async (\n objectType: SemanticObjectType,\n objectUUID: string,\n targetProjectIds: number[],\n ) => {\n await metastoreClient.repository.replaceTargetProjects({\n objectType,\n UUID: objectUUID,\n targetProjectIds,\n });\n };\n\n /**\n * Step a project-scoped object up to the organization scope, in place.\n *\n * The object keeps its UUID and revision history; the step-up writes a new revision whose\n * `project_id` is null. Requires the caller to hold the organization-admin role for the target\n * organization — a project-admin gets 403 from the metastore, which callers should surface\n * rather than pre-empt (the same person is often both).\n */\n const promoteToOrganizationScope = async (objectType: SemanticObjectType, objectUUID: string) => {\n // Scope ONLY. No `data`, not even `{}`: the metastore's step-up guard rejects a PATCH that\n // also carries name or data, and `Data *JSONData` treats `{}` as present — which 400s with\n // \"A scope change cannot be combined with name or data changes\".\n const response = await metastoreClient.repository.updateMetaObject({\n objectType,\n UUID: objectUUID,\n scope: 'organization',\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<Record<string, unknown>>);\n };\n\n return {\n // models\n listModels,\n createModel,\n updateModel,\n deleteModel,\n listModelChildren,\n\n // child objects (datasets, metrics, relationships, glossary, constraints)\n listObjects,\n findObjectsByName,\n createObject,\n createObjects,\n createModelTree,\n updateObject,\n deleteObject,\n\n // scoping / sharing\n replaceTargetProjects,\n promoteToOrganizationScope,\n };\n};\n","import { z } from 'zod';\n\nimport { CONSTRAINT_TYPES, SQL_DIALECTS } from './semanticLayerSdk';\n\n/**\n * Runtime validators for the semantic-layer payload shapes.\n *\n * These exist because the metastore's validation errors are opaque — a missing or misspelled\n * field surfaces only as a generic \"Validation failed\", and a wrong `sql_dialect` casing as a\n * 422 that names neither the field nor the accepted values. Parsing first turns those into a\n * message that says what is wrong.\n *\n * **Only the fields the SDK types mark as required are declared.** The metastore owns each\n * object type's full schema, so every schema is a `looseObject`: unknown fields pass through\n * untouched rather than being stripped or rejected. Re-declaring the optional fields here\n * would create a second source of truth that silently drops whatever the metastore adds next.\n *\n * The SDK does **not** parse on its own writes — these are for callers that accept untrusted\n * or hand-authored input (an agent's tool call, a form submission) and want to fail early.\n * `modelUUID` is omitted throughout: the SDK injects it, so callers never supply it.\n */\n\nexport const semanticModelSchema = z.looseObject({\n name: z.string().min(1),\n sql_dialect: z.enum(SQL_DIALECTS),\n});\n\nexport const semanticDatasetSchema = z.looseObject({\n name: z.string().min(1),\n tableId: z.string().min(1),\n fqn: z.string().min(1),\n});\n\nexport const semanticMetricSchema = z.looseObject({\n name: z.string().min(1),\n sql: z.string().min(1),\n});\n\nexport const semanticRelationshipSchema = z.looseObject({\n from: z.string().min(1),\n to: z.string().min(1),\n on: z.string().min(1),\n});\n\nexport const semanticGlossarySchema = z.looseObject({\n term: z.string().min(1),\n definition: z.string().min(1),\n});\n\nexport const semanticConstraintSchema = z.looseObject({\n name: z.string().min(1),\n constraintType: z.enum(CONSTRAINT_TYPES),\n metrics: z.array(z.string()),\n rule: z.string().min(1),\n});\n\n/** Keyed by object type so a caller can pick the schema from a `SemanticChildObjectType`. */\nexport const SEMANTIC_CHILD_OBJECT_SCHEMAS = {\n 'semantic-dataset': semanticDatasetSchema,\n 'semantic-metric': semanticMetricSchema,\n 'semantic-relationship': semanticRelationshipSchema,\n 'semantic-glossary': semanticGlossarySchema,\n 'semantic-constraint': semanticConstraintSchema,\n} as const;\n"],"mappings":";;;;;;;;;;;;AAwBA,IAAa,kCAAb,cAAqD,eAAe;CAClE;CACA;CACA;CAEA,YAAY,EACV,WACA,iBACA,kBAKC;EACD,MAAM,QAAQ,gBAAgB,SAAS,eAAe;EACtD,MACE,eAAe,KAAK,YAAY,QAAQ,KAAK,GAC7C,8BAA8B,eAAe,OAAO,UAAU,MAAM,uCACzC,gBAAgB,OAAO,WACpD;EACA,KAAK,OAAO;EACZ,KAAK,YAAY;EACjB,KAAK,kBAAkB;EACvB,KAAK,iBAAiB;CACxB;AACF;AAEA,MAAa,uBAAuB;CAClC,OAAO;CACP,SAAS;CACT,QAAQ;CACR,cAAc;CACd,UAAU;CACV,YA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AE,OAAO,CAAC,CAAC,IAAI,CAAC;AACtB,CAAC;AAED,MAAa,yBAAyBA,IAAAA,EAAE,YAAY;CAClD,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,YAAYA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC9B,CAAC;AAED,MAAa,2BAA2BA,IAAAA,EAAE,YAAY;CACpD,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,gBAAgBA,IAAAA,EAAE,KAAK,gBAAgB;CACvC,SAASA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC;CAC3B,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AACxB,CAAC;;AAGD,MAAa,gCAAgC;CAC3C,oBAAoB;CACpB,mBAAmB;CACnB,yBAAyB;CACzB,qBAAqB;CACrB,uBAAuB;AACzB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["z","generateUUID","concurrent"],"sources":["../../../src/sdks/semanticLayer/errorMessage.ts","../../../src/sdks/semanticLayer/vocabulary.ts","../../../src/sdks/semanticLayer/schemas.ts","../../../src/sdks/semanticLayer/semanticLayerSdk.ts"],"sourcesContent":["/**\n * The message out of a metastore error body.\n *\n * - The metastore reports what is actually wrong with a write only inside `errors[].message`\n * (`missing property 'fqn'`). The HTTP status and the response's own message say no more than\n * \"Validation failed\", so a caller that renders those alone tells a user nothing actionable.\n * - Every shape that is not that envelope returns `undefined` rather than a placeholder, so the\n * caller keeps its own fallback (`?? error.message`) instead of rendering a stand-in for one.\n * - Only the first error: the metastore reports fields one at a time, so a list would be a list\n * of one.\n */\nexport const metastoreErrorMessage = (data: unknown): string | undefined => {\n if (typeof data !== 'object' || data === null) return undefined;\n const errors = (data as { errors?: unknown }).errors;\n if (!Array.isArray(errors)) return undefined;\n const first = errors[0];\n if (typeof first !== 'object' || first === null) return undefined;\n const message = (first as { message?: unknown }).message;\n return typeof message === 'string' && message ? message : undefined;\n};\n","/**\n * The closed value sets the metastore accepts inside a semantic object's `data`.\n *\n * - Each one is the single runtime source for a union in `./types`, which derives the type from\n * the array here. A value cannot exist in the type and be missing from the list a dropdown or\n * a validator is built from.\n * - The addressing vocabulary (`SEMANTIC_OBJECT_TYPE`, `MODEL_CHILD_OBJECT_TYPES`) is a\n * different axis — which object a call targets, not what may sit inside one — and stays beside\n * the SDK methods that take it.\n * - This file imports nothing: `./types` reads it, never the reverse.\n */\n\n/**\n * The dialects the metastore accepts, exactly as it spells them. A lowercase value is\n * rejected with `422 value must be one of 'Snowflake', 'BigQuery'`, which surfaces only as a\n * generic \"Validation failed\" — so callers need the real set rather than a bare `string`.\n *\n * `SemanticModelData.sql_dialect` stays `string` for now: narrowing it would break any caller\n * passing a `string` variable, which is a major bump. Validate against this instead.\n */\nexport const SQL_DIALECTS = ['Snowflake', 'BigQuery'] as const;\n\n/** The metastore's constraint kinds. */\nexport const CONSTRAINT_TYPES = [\n 'inequality',\n 'equality',\n 'range',\n 'composition',\n 'exclusion',\n 'temporal',\n 'conditional',\n] as const;\n\n/**\n * What a dataset field is for.\n *\n * - Enumerated, unlike a field's `type`: the metastore takes any type string, but only these\n * four roles.\n */\nexport const FIELD_ROLES = ['key', 'dimension', 'measure', 'timestamp'] as const;\n\n/**\n * How loudly a violated constraint reports.\n *\n * - An unset severity is stored as `warning`, so a reader renders that rather than nothing.\n */\nexport const CONSTRAINT_SEVERITIES = ['error', 'warning', 'info'] as const;\n\n/**\n * What a constraint's rule is evaluated per.\n *\n * - An unset scope is stored as `global`.\n */\nexport const CONSTRAINT_SCOPES = ['global', 'per_location', 'per_date', 'per_category'] as const;\n\n/** The comparisons a constraint's `ruleExpression` can make. */\nexport const RULE_OPERATORS = [\n '<',\n '<=',\n '=',\n '>=',\n '>',\n '!=',\n 'between',\n 'in',\n 'sum_equals',\n 'ratio_between',\n] as const;\n\n/** The join a relationship stands for. */\nexport const RELATIONSHIP_JOIN_TYPES = ['left', 'inner'] as const;\n","import { z } from 'zod';\n\nimport { CONSTRAINT_TYPES, SQL_DIALECTS } from './vocabulary';\n\n/**\n * Runtime validators for the semantic-layer payload shapes.\n *\n * These exist because the metastore's validation errors are opaque — a missing or misspelled\n * field surfaces only as a generic \"Validation failed\", and a wrong `sql_dialect` casing as a\n * 422 that names neither the field nor the accepted values. Parsing first turns those into a\n * message that says what is wrong.\n *\n * **Only the fields the SDK types mark as required are declared.** The metastore owns each\n * object type's full schema, so every schema is a `looseObject`: unknown fields pass through\n * untouched rather than being stripped or rejected. Re-declaring the optional fields here\n * would create a second source of truth that silently drops whatever the metastore adds next.\n *\n * The SDK does **not** parse on its own writes — these are for callers that accept untrusted\n * or hand-authored input (an agent's tool call, a form submission) and want to fail early.\n * `modelUUID` is omitted throughout: the SDK injects it, so callers never supply it.\n */\n\nexport const semanticModelSchema = z.looseObject({\n name: z.string().min(1),\n sql_dialect: z.enum(SQL_DIALECTS),\n});\n\nexport const semanticDatasetSchema = z.looseObject({\n name: z.string().min(1),\n tableId: z.string().min(1),\n fqn: z.string().min(1),\n});\n\nexport const semanticMetricSchema = z.looseObject({\n name: z.string().min(1),\n sql: z.string().min(1),\n});\n\nexport const semanticRelationshipSchema = z.looseObject({\n from: z.string().min(1),\n to: z.string().min(1),\n on: z.string().min(1),\n});\n\nexport const semanticGlossarySchema = z.looseObject({\n term: z.string().min(1),\n definition: z.string().min(1),\n});\n\nexport const semanticConstraintSchema = z.looseObject({\n name: z.string().min(1),\n constraintType: z.enum(CONSTRAINT_TYPES),\n metrics: z.array(z.string()),\n rule: z.string().min(1),\n});\n\n/** Keyed by object type so a caller can pick the schema from a `SemanticChildObjectType`. */\nexport const SEMANTIC_CHILD_OBJECT_SCHEMAS = {\n 'semantic-dataset': semanticDatasetSchema,\n 'semantic-metric': semanticMetricSchema,\n 'semantic-relationship': semanticRelationshipSchema,\n 'semantic-glossary': semanticGlossarySchema,\n 'semantic-constraint': semanticConstraintSchema,\n} as const;\n","import { concurrent, generateUUID } from '../../utils';\n\nimport type {\n CreateSemanticObjectMeta,\n MetastoreClient,\n SemanticChildObjectDataMap,\n SemanticChildObjectType,\n SemanticModelChildDeleteFailure,\n SemanticModelChildRef,\n SemanticModelData,\n SemanticObject,\n SemanticObjectMeta,\n SemanticObjectType,\n UpdateSemanticObjectMeta,\n} from './types';\n\n/**\n * Thrown by `deleteModel` when the child cascade partially fails. Every child delete has\n * settled by the time this is thrown — nothing keeps deleting in the background — and the\n * model itself was kept, so the exact remaining state is knowable: `deletedChildren` are gone,\n * `failedChildren` (and the model) still exist. `errors` carries the per-child rejection\n * reasons, AggregateError-style.\n */\nexport class SemanticLayerCascadeDeleteError extends AggregateError {\n readonly modelUUID: string;\n readonly deletedChildren: SemanticModelChildRef[];\n readonly failedChildren: SemanticModelChildDeleteFailure[];\n\n constructor({\n modelUUID,\n deletedChildren,\n failedChildren,\n }: {\n modelUUID: string;\n deletedChildren: SemanticModelChildRef[];\n failedChildren: SemanticModelChildDeleteFailure[];\n }) {\n const total = deletedChildren.length + failedChildren.length;\n super(\n failedChildren.map((failure) => failure.error),\n `The model was kept because ${failedChildren.length} of its ${total} child objects ` +\n `could not be deleted (${deletedChildren.length} deleted).`,\n );\n this.name = 'SemanticLayerCascadeDeleteError';\n this.modelUUID = modelUUID;\n this.deletedChildren = deletedChildren;\n this.failedChildren = failedChildren;\n }\n}\n\nexport const SEMANTIC_OBJECT_TYPE = {\n MODEL: 'semantic-model',\n DATASET: 'semantic-dataset',\n METRIC: 'semantic-metric',\n RELATIONSHIP: 'semantic-relationship',\n GLOSSARY: 'semantic-glossary',\n CONSTRAINT: 'semantic-constraint',\n} as const satisfies Record<string, SemanticObjectType>;\n\n/**\n * `readonly` because this drives `createModelTree`, `listModelChildren` and `deleteModel` —\n * a consumer-side `.push()` would silently change what a cascade delete touches.\n */\nexport const MODEL_CHILD_OBJECT_TYPES: readonly SemanticChildObjectType[] = [\n SEMANTIC_OBJECT_TYPE.DATASET,\n SEMANTIC_OBJECT_TYPE.METRIC,\n SEMANTIC_OBJECT_TYPE.RELATIONSHIP,\n SEMANTIC_OBJECT_TYPE.GLOSSARY,\n SEMANTIC_OBJECT_TYPE.CONSTRAINT,\n] as const;\n\nconst DEFAULT_BRANCH = 'main';\n\n// The metastore has no bulk endpoint; large semantic-layer inits are written as\n// concurrent single POSTs (the same approach the ai-kit sl-toolkit importer uses).\nconst WRITE_CONCURRENCY = 5;\n\n// The live metastore envelope: `attributes` carries the object's data payload directly,\n// the UUID is the top-level `id`, and revision/branch/audit fields live in `meta`. The\n// legacy wrapper types in clients/metastore/repository/types.ts do not match this shape.\ntype RawSemanticObject<TData> = {\n type: string;\n id: string;\n attributes: TData;\n meta: SemanticObjectMeta;\n};\n\nconst mapObject = <TData>(item: RawSemanticObject<TData>): SemanticObject<TData> => ({\n uuid: item.id,\n data: item.attributes,\n meta: item.meta,\n});\n\nconst deriveOptionalObjectName = (data: Record<string, unknown>): string | undefined => {\n if (typeof data.name === 'string') return data.name;\n if (typeof data.term === 'string') return data.term;\n return undefined;\n};\n\nconst deriveObjectName = (data: Record<string, unknown>) =>\n deriveOptionalObjectName(data) ?? generateUUID();\n\n/**\n * The label a UI shows for an object, as opposed to the identifier it is addressed by.\n *\n * Constraints carry an optional `displayName`; kbc-ui's constraint tables already render\n * `displayName ?? name`, so a confirmation listing what a cascade delete would destroy has to\n * agree with them or it names objects the user can't find on screen.\n *\n * Deliberately **not** used for lookup: `displayName` is optional and not unique, so matching on\n * it would make `findObjectsByName` ambiguous for callers that resolve a write target by name.\n */\nconst deriveObjectLabel = (data: Record<string, unknown>): string | undefined => {\n if (typeof data.displayName === 'string' && data.displayName !== '') return data.displayName;\n return deriveOptionalObjectName(data);\n};\n\ntype Options = {\n metastoreClient: MetastoreClient;\n};\n\nexport const createSemanticLayerSdk = ({ metastoreClient }: Options) => {\n const _listObjects = async <TData extends Record<string, unknown>>(\n objectType: SemanticObjectType,\n signal?: AbortSignal,\n ) => {\n const response = await metastoreClient.repository.getMetaObjects<TData>({ objectType }, signal);\n return (response.data as unknown as RawSemanticObject<TData>[]).map(mapObject);\n };\n\n const listModels = async (signal?: AbortSignal) =>\n _listObjects<SemanticModelData>(SEMANTIC_OBJECT_TYPE.MODEL, signal);\n\n const createModel = async (data: SemanticModelData, meta: CreateSemanticObjectMeta = {}) => {\n const response = await metastoreClient.repository.createMetaObject<SemanticModelData>({\n objectType: SEMANTIC_OBJECT_TYPE.MODEL,\n data,\n branch: DEFAULT_BRANCH,\n ...meta,\n // Derived name wins over meta so the metastore name stays in sync with the payload.\n name: data.name,\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticModelData>);\n };\n\n const updateModel = async (\n modelUUID: string,\n data: Partial<SemanticModelData>,\n meta: UpdateSemanticObjectMeta = {},\n ) => {\n const response = await metastoreClient.repository.updateMetaObject<SemanticModelData>({\n objectType: SEMANTIC_OBJECT_TYPE.MODEL,\n UUID: modelUUID,\n data,\n ...meta,\n // Derived rename wins over meta so the metastore name stays in sync with the payload.\n ...(data.name ? { name: data.name } : {}),\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticModelData>);\n };\n\n const listObjects = async <T extends SemanticChildObjectType>(\n objectType: T,\n modelUUID: string,\n signal?: AbortSignal,\n ) => {\n const objects = await _listObjects<SemanticChildObjectDataMap[T]>(objectType, signal);\n return objects.filter((object) => object.data.modelUUID === modelUUID);\n };\n\n /**\n * Find a model's child objects by their user-facing name.\n *\n * Returns every match rather than resolving to one, because a name is not unique: the caller\n * decides whether that's an error (an agent needs an unambiguous target) or a choice to offer\n * (a UI can render a picker). Glossary entries key on `term`, so both are matched.\n */\n const findObjectsByName = async <T extends SemanticChildObjectType>(\n objectType: T,\n name: string,\n modelUUID: string,\n signal?: AbortSignal,\n ) => {\n const objects = await listObjects(objectType, modelUUID, signal);\n return objects.filter((object) => deriveOptionalObjectName(object.data) === name);\n };\n\n const createObject = async <T extends SemanticChildObjectType>(\n objectType: T,\n data: SemanticChildObjectDataMap[T],\n meta: CreateSemanticObjectMeta = {},\n ) => {\n const response = await metastoreClient.repository.createMetaObject<\n SemanticChildObjectDataMap[T]\n >({\n objectType,\n data,\n branch: DEFAULT_BRANCH,\n ...meta,\n // Derived name wins over meta so the metastore name stays in sync with the payload.\n name: deriveObjectName(data),\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticChildObjectDataMap[T]>);\n };\n\n const createObjects = async <T extends SemanticChildObjectType>(\n objectType: T,\n items: SemanticChildObjectDataMap[T][],\n meta: CreateSemanticObjectMeta = {},\n ) =>\n concurrent({\n items,\n process: async (data) => createObject(objectType, data, meta),\n concurrency: WRITE_CONCURRENCY,\n });\n\n // Create a model and all its child objects in one call: the model first (so its\n // UUID exists), then every child concurrently with the modelUUID injected.\n const createModelTree = async (\n model: SemanticModelData,\n children: Partial<{\n [T in SemanticChildObjectType]: Omit<SemanticChildObjectDataMap[T], 'modelUUID'>[];\n }>,\n meta: CreateSemanticObjectMeta = {},\n ) => {\n const createdModel = await createModel(model, meta);\n\n const items = MODEL_CHILD_OBJECT_TYPES.flatMap((objectType) =>\n (children[objectType] ?? []).map((data) => ({\n objectType,\n data: {\n ...data,\n modelUUID: createdModel.uuid,\n } satisfies SemanticChildObjectDataMap[typeof objectType],\n })),\n );\n\n const createdChildren = await concurrent({\n items,\n process: async ({ objectType, data }) => createObject(objectType, data, meta),\n concurrency: WRITE_CONCURRENCY,\n });\n\n return { model: createdModel, children: createdChildren };\n };\n\n const updateObject = async <T extends SemanticChildObjectType>(\n objectType: T,\n objectUUID: string,\n data: Partial<SemanticChildObjectDataMap[T]>,\n meta: UpdateSemanticObjectMeta = {},\n ) => {\n const name = deriveOptionalObjectName(data);\n const response = await metastoreClient.repository.updateMetaObject<\n SemanticChildObjectDataMap[T]\n >({\n objectType,\n UUID: objectUUID,\n data,\n ...meta,\n // Derived rename wins over meta so the metastore name stays in sync with the payload.\n ...(name ? { name } : {}),\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<SemanticChildObjectDataMap[T]>);\n };\n\n const deleteObject = async (objectType: SemanticChildObjectType, objectUUID: string) => {\n await metastoreClient.repository.deleteMetaObject({\n objectType,\n UUID: objectUUID,\n });\n };\n\n /**\n * Every child object of a model, across all five types, flattened.\n *\n * `deleteModel` uses this to find what to remove; callers can use it to say what a delete\n * would destroy *before* asking the user to confirm. Each entry's `name` is the object's\n * display label (a constraint's `displayName` in preference to its `name`, matching what the\n * SL tables render), so a confirmation lists objects as the user sees them on screen.\n *\n * Costs five list requests: the metastore has no per-model filter, so `listObjects`\n * fetches each collection and filters client-side.\n */\n const listModelChildren = async (\n modelUUID: string,\n signal?: AbortSignal,\n ): Promise<SemanticModelChildRef[]> => {\n const childrenByType = await Promise.all(\n MODEL_CHILD_OBJECT_TYPES.map(async (objectType) => {\n const objects = await listObjects(objectType, modelUUID, signal);\n return objects.map((object) => ({\n objectType,\n objectUUID: object.uuid,\n name: deriveObjectLabel(object.data),\n }));\n }),\n );\n\n return childrenByType.flat();\n };\n\n /**\n * Cascade delete: every child object first, the model itself only once its whole tree is\n * gone. Child deletes all settle — a failing child never aborts the others, so no delete\n * runs on detached after this rejects — and a partial failure surfaces as\n * `SemanticLayerCascadeDeleteError`, which says exactly which children were deleted and\n * which survived. The model is kept on any child failure so it never orphans children.\n */\n const deleteModel = async (modelUUID: string) => {\n const children = await listModelChildren(modelUUID);\n\n const outcomes = await concurrent({\n items: children,\n process: async (child) => {\n try {\n await deleteObject(child.objectType, child.objectUUID);\n return { ok: true as const, child };\n } catch (error) {\n return { ok: false as const, child, error };\n }\n },\n concurrency: WRITE_CONCURRENCY,\n });\n\n const deletedChildren: SemanticModelChildRef[] = [];\n const failedChildren: SemanticModelChildDeleteFailure[] = [];\n for (const outcome of outcomes) {\n if (outcome.ok) deletedChildren.push(outcome.child);\n else failedChildren.push({ ...outcome.child, error: outcome.error });\n }\n\n if (failedChildren.length > 0) {\n throw new SemanticLayerCascadeDeleteError({ modelUUID, deletedChildren, failedChildren });\n }\n\n await metastoreClient.repository.deleteMetaObject({\n objectType: SEMANTIC_OBJECT_TYPE.MODEL,\n UUID: modelUUID,\n });\n };\n\n /**\n * Replace the sibling projects granted GET/consumption access to a `targeted`-scope object.\n *\n * Passing an empty array clears every grant, leaving the object visible to its owning project\n * only. A grant conveys read access alone — the target projects can consume the definition but\n * never edit it, which is enforced metastore-side rather than here.\n */\n const replaceTargetProjects = async (\n objectType: SemanticObjectType,\n objectUUID: string,\n targetProjectIds: number[],\n ) => {\n await metastoreClient.repository.replaceTargetProjects({\n objectType,\n UUID: objectUUID,\n targetProjectIds,\n });\n };\n\n /**\n * Step a project-scoped object up to the organization scope, in place.\n *\n * The object keeps its UUID and revision history; the step-up writes a new revision whose\n * `project_id` is null. Requires the caller to hold the organization-admin role for the target\n * organization — a project-admin gets 403 from the metastore, which callers should surface\n * rather than pre-empt (the same person is often both).\n */\n const promoteToOrganizationScope = async (objectType: SemanticObjectType, objectUUID: string) => {\n // Scope ONLY. No `data`, not even `{}`: the metastore's step-up guard rejects a PATCH that\n // also carries name or data, and `Data *JSONData` treats `{}` as present — which 400s with\n // \"A scope change cannot be combined with name or data changes\".\n const response = await metastoreClient.repository.updateMetaObject({\n objectType,\n UUID: objectUUID,\n scope: 'organization',\n });\n\n return mapObject(response.data as unknown as RawSemanticObject<Record<string, unknown>>);\n };\n\n return {\n // models\n listModels,\n createModel,\n updateModel,\n deleteModel,\n listModelChildren,\n\n // child objects (datasets, metrics, relationships, glossary, constraints)\n listObjects,\n findObjectsByName,\n createObject,\n createObjects,\n createModelTree,\n updateObject,\n deleteObject,\n\n // scoping / sharing\n replaceTargetProjects,\n promoteToOrganizationScope,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,MAAa,yBAAyB,SAAsC;CAC1E,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM,OAAO,KAAA;CACtD,MAAM,SAAU,KAA8B;CAC9C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAA;CACnC,MAAM,QAAQ,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