@keboola/api-client 32.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.
Files changed (377) hide show
  1. package/AGENTS.md +80 -2
  2. package/API-SURFACE.md +4 -1
  3. package/CHANGELOG.md +222 -0
  4. package/dist/{ManagementClientAuthError-B-tyPlyG.cjs → ManagementClientAuthError-DqeXL8nv.cjs} +2 -2
  5. package/dist/{ManagementClientAuthError-B-tyPlyG.cjs.map → ManagementClientAuthError-DqeXL8nv.cjs.map} +1 -1
  6. package/dist/{ManagementClientAuthError-BAFNvOdf.js → ManagementClientAuthError-iKbBugKC.js} +2 -2
  7. package/dist/{ManagementClientAuthError-BAFNvOdf.js.map → ManagementClientAuthError-iKbBugKC.js.map} +1 -1
  8. package/dist/ai/index.cjs +2 -2
  9. package/dist/ai/index.d.cts +2 -2
  10. package/dist/ai/index.d.ts +2 -2
  11. package/dist/ai/index.js +2 -2
  12. package/dist/ai/types.d.cts +1 -1
  13. package/dist/ai/types.d.ts +1 -1
  14. package/dist/{appLogs-DTLE6HTy.js → appLogs-D72eD8vP.js} +2 -2
  15. package/dist/{appLogs-DTLE6HTy.js.map → appLogs-D72eD8vP.js.map} +1 -1
  16. package/dist/{appLogs-NIEDTDHf.cjs → appLogs-D8K0VeNM.cjs} +2 -2
  17. package/dist/{appLogs-NIEDTDHf.cjs.map → appLogs-D8K0VeNM.cjs.map} +1 -1
  18. package/dist/{appLogs-BAaaGYKg.d.cts → appLogs-Q4A7A_Fc.d.cts} +2 -2
  19. package/dist/{appLogs-DX_WTBCa.d.ts → appLogs-u0XMZLjS.d.ts} +2 -2
  20. package/dist/apps/index.cjs +3 -3
  21. package/dist/apps/index.d.cts +3 -3
  22. package/dist/apps/index.d.ts +3 -3
  23. package/dist/apps/index.js +3 -3
  24. package/dist/apps/types.d.cts +2 -2
  25. package/dist/apps/types.d.ts +2 -2
  26. package/dist/assets/index.cjs +1 -1
  27. package/dist/assets/index.d.cts +1 -1
  28. package/dist/assets/index.d.ts +1 -1
  29. package/dist/assets/index.js +1 -1
  30. package/dist/auth/index.cjs +1 -1
  31. package/dist/auth/index.d.cts +1 -1
  32. package/dist/auth/index.d.ts +1 -1
  33. package/dist/auth/index.js +1 -1
  34. package/dist/auth/types.d.cts +2 -2
  35. package/dist/auth/types.d.ts +2 -2
  36. package/dist/{auth-DP-6TFiM.cjs → auth-C2_JLisH.cjs} +2 -2
  37. package/dist/{auth-DP-6TFiM.cjs.map → auth-C2_JLisH.cjs.map} +1 -1
  38. package/dist/{auth-DtbQaeDj.js → auth-CE9rQV3-.js} +2 -2
  39. package/dist/{auth-DtbQaeDj.js.map → auth-CE9rQV3-.js.map} +1 -1
  40. package/dist/{authClient--BtZgjIc.js → authClient-DEyqR7GW.js} +43 -9
  41. package/dist/authClient-DEyqR7GW.js.map +1 -0
  42. package/dist/{authClient-DhfzOUaa.d.cts → authClient-DZ_8lvdJ.d.cts} +6 -6
  43. package/dist/{authClient-CtfyVHRD.d.ts → authClient-DwT6xdg5.d.ts} +6 -6
  44. package/dist/{authClient-b7uec7sw.cjs → authClient-IwQ9Ti0J.cjs} +43 -9
  45. package/dist/authClient-IwQ9Ti0J.cjs.map +1 -0
  46. package/dist/chat/index.cjs +3 -3
  47. package/dist/chat/index.d.cts +2 -2
  48. package/dist/chat/index.d.ts +2 -2
  49. package/dist/chat/index.js +3 -3
  50. package/dist/chat/types.d.cts +1 -1
  51. package/dist/chat/types.d.ts +1 -1
  52. package/dist/{createFetchClient-BbG46bL0.js → createFetchClient-DdyZMhxO.js} +3 -2
  53. package/dist/{createFetchClient-BbG46bL0.js.map → createFetchClient-DdyZMhxO.js.map} +1 -1
  54. package/dist/{createFetchClient-BRfTjBLV.cjs → createFetchClient-DvZvD31l.cjs} +8 -1
  55. package/dist/{createFetchClient-BRfTjBLV.cjs.map → createFetchClient-DvZvD31l.cjs.map} +1 -1
  56. package/dist/{createGenericFetchClient-BHYQLZhe.js → createGenericFetchClient-MQeLRiNW.js} +2 -2
  57. package/dist/{createGenericFetchClient-BHYQLZhe.js.map → createGenericFetchClient-MQeLRiNW.js.map} +1 -1
  58. package/dist/{createGenericFetchClient-DHs-i7_O.cjs → createGenericFetchClient-qfCZlCTv.cjs} +2 -2
  59. package/dist/{createGenericFetchClient-DHs-i7_O.cjs.map → createGenericFetchClient-qfCZlCTv.cjs.map} +1 -1
  60. package/dist/{createOpenapiFetchClient-CyDUFxHB.cjs → createOpenapiFetchClient-C57Ljzi6.cjs} +2 -2
  61. package/dist/{createOpenapiFetchClient-CyDUFxHB.cjs.map → createOpenapiFetchClient-C57Ljzi6.cjs.map} +1 -1
  62. package/dist/{createOpenapiFetchClient-Bn6_Pn0H.js → createOpenapiFetchClient-E7OIVkYv.js} +2 -2
  63. package/dist/{createOpenapiFetchClient-Bn6_Pn0H.js.map → createOpenapiFetchClient-E7OIVkYv.js.map} +1 -1
  64. package/dist/{credential-d2RDcXRB.js → credential-Bxv7yxOZ.js} +7 -4
  65. package/dist/credential-Bxv7yxOZ.js.map +1 -0
  66. package/dist/{credential-DOXH7XRS.cjs → credential-D-X5QQrM.cjs} +7 -4
  67. package/dist/credential-D-X5QQrM.cjs.map +1 -0
  68. package/dist/dataScience/index.cjs +2 -2
  69. package/dist/dataScience/index.d.cts +2 -2
  70. package/dist/dataScience/index.d.ts +2 -2
  71. package/dist/dataScience/index.js +2 -2
  72. package/dist/dataScience/types.d.cts +2 -2
  73. package/dist/dataScience/types.d.ts +2 -2
  74. package/dist/{dataScience-wexHEIue.cjs → dataScience-BPW993AG.cjs} +5 -5
  75. package/dist/{dataScience-wexHEIue.cjs.map → dataScience-BPW993AG.cjs.map} +1 -1
  76. package/dist/{dataScience-Sm8iONhP.js → dataScience-B_TA7wCB.js} +5 -5
  77. package/dist/{dataScience-Sm8iONhP.js.map → dataScience-B_TA7wCB.js.map} +1 -1
  78. package/dist/developerPortal/index.cjs +1 -1
  79. package/dist/developerPortal/index.d.cts +2 -2
  80. package/dist/developerPortal/index.d.ts +2 -2
  81. package/dist/developerPortal/index.js +1 -1
  82. package/dist/developerPortal/types.d.cts +1 -1
  83. package/dist/developerPortal/types.d.ts +1 -1
  84. package/dist/{developerPortalClient-CgTSzLoG.cjs → developerPortalClient-Db2XVB_o.cjs} +3 -3
  85. package/dist/{developerPortalClient-CgTSzLoG.cjs.map → developerPortalClient-Db2XVB_o.cjs.map} +1 -1
  86. package/dist/{developerPortalClient-DywKpDlW.js → developerPortalClient-jk46sjwP.js} +3 -3
  87. package/dist/{developerPortalClient-DywKpDlW.js.map → developerPortalClient-jk46sjwP.js.map} +1 -1
  88. package/dist/domain/permissions/index.d.cts +2 -2
  89. package/dist/domain/permissions/index.d.ts +2 -2
  90. package/dist/editor/index.cjs +2 -2
  91. package/dist/editor/index.d.cts +2 -2
  92. package/dist/editor/index.d.ts +2 -2
  93. package/dist/editor/index.js +2 -2
  94. package/dist/editor/types.d.cts +1 -1
  95. package/dist/editor/types.d.ts +1 -1
  96. package/dist/emitter-dLF1Fyfg.d.cts +11 -0
  97. package/dist/emitter-dLF1Fyfg.d.ts +11 -0
  98. package/dist/encryption/index.cjs +1 -1
  99. package/dist/encryption/index.d.cts +1 -1
  100. package/dist/encryption/index.d.ts +1 -1
  101. package/dist/encryption/index.js +1 -1
  102. package/dist/encryption/types.d.cts +1 -1
  103. package/dist/encryption/types.d.ts +1 -1
  104. package/dist/import/index.cjs +1 -1
  105. package/dist/import/index.d.cts +3 -3
  106. package/dist/import/index.d.ts +3 -3
  107. package/dist/import/index.js +1 -1
  108. package/dist/{import-SQuurg1G.js → import-2nqxQ9Rt.js} +3 -3
  109. package/dist/{import-SQuurg1G.js.map → import-2nqxQ9Rt.js.map} +1 -1
  110. package/dist/{import-C0-y1GQK.cjs → import-DJilJ6tq.cjs} +3 -3
  111. package/dist/{import-C0-y1GQK.cjs.map → import-DJilJ6tq.cjs.map} +1 -1
  112. package/dist/{index-FhKX7Cv1.d.ts → index-B0V1pJAa.d.ts} +241 -200
  113. package/dist/{index-Bg1P6Bb2.d.ts → index-B2OGaUap.d.ts} +6 -6
  114. package/dist/{index-Dbzjvy5h.d.ts → index-BjKjp3Rf.d.ts} +5 -5
  115. package/dist/{index-DeKPpYQy.d.ts → index-C7gxKoDF.d.cts} +3 -3
  116. package/dist/{index-D_7yCRKy.d.cts → index-CTd4YY8e.d.cts} +4 -4
  117. package/dist/{index-DiHHyMEo.d.cts → index-CUXEFQ7i.d.cts} +6 -6
  118. package/dist/{index-eAlN694c.d.cts → index-CVqk63at.d.ts} +3 -3
  119. package/dist/{index-Bc_hXWae.d.ts → index-C_cxKL1V.d.ts} +3 -3
  120. package/dist/{index-tKsiUarj.d.ts → index-ChMtULt4.d.ts} +4 -4
  121. package/dist/{index-Gn1H63Hk.d.cts → index-DCN2lH0v.d.cts} +4 -4
  122. package/dist/{index-Bjk-tCpG.d.cts → index-DIVvL54G.d.cts} +241 -200
  123. package/dist/{index-C7e3wBt9.d.cts → index-DLYAvSWZ.d.cts} +3 -3
  124. package/dist/{index-fHfc_VqS.d.ts → index-DQef014j.d.ts} +4 -4
  125. package/dist/{index-CeJOmN-P.d.ts → index-DVhTNwvu.d.ts} +3 -2
  126. package/dist/{index-CQrKS7PV.d.cts → index-DhVFuQDv.d.cts} +3 -2
  127. package/dist/{index-Ctqkm3Fx.d.ts → index-GNKwr7EQ.d.ts} +4 -4
  128. package/dist/{index-GDdFZCXp.d.ts → index-bB6wvw1f.d.ts} +4 -4
  129. package/dist/{index-BKh0prif.d.cts → index-exNi3I2Q.d.cts} +4 -4
  130. package/dist/{index-CXtdQ7be.d.cts → index-qOK5FtAH.d.cts} +4 -4
  131. package/dist/{index-DqOAjqxN.d.cts → index-t-a7kYnx.d.cts} +5 -5
  132. package/dist/index.cjs +303 -47
  133. package/dist/index.cjs.map +1 -1
  134. package/dist/index.d.cts +7 -6
  135. package/dist/index.d.ts +7 -6
  136. package/dist/index.js +285 -30
  137. package/dist/index.js.map +1 -1
  138. package/dist/{jobStatus-kQ9JqF8t.cjs → jobStatus-0_Y3Sr4i.cjs} +37 -20
  139. package/dist/jobStatus-0_Y3Sr4i.cjs.map +1 -0
  140. package/dist/{jobStatus-DbMupQEK.js → jobStatus-PSZJMTiA.js} +35 -18
  141. package/dist/jobStatus-PSZJMTiA.js.map +1 -0
  142. package/dist/kaiAgent/index.cjs +1 -1
  143. package/dist/kaiAgent/index.d.cts +2 -210
  144. package/dist/kaiAgent/index.d.ts +2 -210
  145. package/dist/kaiAgent/index.js +1 -1
  146. package/dist/kaiAgent/types.d.cts +1 -1
  147. package/dist/kaiAgent/types.d.ts +1 -1
  148. package/dist/{kaiAgent-4OiIK1C2.cjs → kaiAgent-CMVub6Sc.cjs} +48 -4
  149. package/dist/kaiAgent-CMVub6Sc.cjs.map +1 -0
  150. package/dist/{kaiAgent-HDaFS9BR.js → kaiAgent-CYYn0QJW.js} +48 -4
  151. package/dist/kaiAgent-CYYn0QJW.js.map +1 -0
  152. package/dist/kaiAgentClient-B2O0DF4d.d.ts +249 -0
  153. package/dist/kaiAgentClient-iCFR2tRU.d.cts +249 -0
  154. package/dist/management/index.cjs +1 -1
  155. package/dist/management/index.d.cts +1 -1
  156. package/dist/management/index.d.ts +1 -1
  157. package/dist/management/index.js +1 -1
  158. package/dist/management/types.d.cts +1 -1
  159. package/dist/management/types.d.ts +1 -1
  160. package/dist/{management-DfjwQo7z.cjs → management-DGfgKsaA.cjs} +5 -5
  161. package/dist/{management-DfjwQo7z.cjs.map → management-DGfgKsaA.cjs.map} +1 -1
  162. package/dist/{management-CIFhu1Nm.js → management-DNEKhR6a.js} +5 -5
  163. package/dist/{management-CIFhu1Nm.js.map → management-DNEKhR6a.js.map} +1 -1
  164. package/dist/metastore/index.cjs +1 -1
  165. package/dist/metastore/index.d.cts +1 -1
  166. package/dist/metastore/index.d.ts +1 -1
  167. package/dist/metastore/index.js +1 -1
  168. package/dist/metastore/types.d.cts +1 -1
  169. package/dist/metastore/types.d.ts +1 -1
  170. package/dist/{metastore-CrXkKufo.js → metastore-CjwktHvw.js} +4 -4
  171. package/dist/{metastore-CrXkKufo.js.map → metastore-CjwktHvw.js.map} +1 -1
  172. package/dist/{metastore-Dq2NS6jb.cjs → metastore-DksEte8P.cjs} +4 -4
  173. package/dist/{metastore-Dq2NS6jb.cjs.map → metastore-DksEte8P.cjs.map} +1 -1
  174. package/dist/microsoftGraph/index.cjs +2 -2
  175. package/dist/microsoftGraph/index.d.cts +2 -2
  176. package/dist/microsoftGraph/index.d.ts +2 -2
  177. package/dist/microsoftGraph/index.js +2 -2
  178. package/dist/microsoftGraph/types.d.cts +1 -1
  179. package/dist/microsoftGraph/types.d.ts +1 -1
  180. package/dist/notifications/index.cjs +3 -3
  181. package/dist/notifications/index.d.cts +2 -2
  182. package/dist/notifications/index.d.ts +2 -2
  183. package/dist/notifications/index.js +3 -3
  184. package/dist/notifications/types.d.cts +1 -1
  185. package/dist/notifications/types.d.ts +1 -1
  186. package/dist/oauth/index.cjs +1 -1
  187. package/dist/oauth/index.d.cts +2 -2
  188. package/dist/oauth/index.d.ts +2 -2
  189. package/dist/oauth/index.js +1 -1
  190. package/dist/oauth/types.d.cts +1 -1
  191. package/dist/oauth/types.d.ts +1 -1
  192. package/dist/{oauth-CFwSNz37.js → oauth-Bg5zro5S.js} +5 -5
  193. package/dist/{oauth-CFwSNz37.js.map → oauth-Bg5zro5S.js.map} +1 -1
  194. package/dist/{oauth-CkW5gln-.cjs → oauth-DFsI1TE5.cjs} +5 -5
  195. package/dist/{oauth-CkW5gln-.cjs.map → oauth-DFsI1TE5.cjs.map} +1 -1
  196. package/dist/omnisearch/index.cjs +2 -2
  197. package/dist/omnisearch/index.d.cts +2 -2
  198. package/dist/omnisearch/index.d.ts +2 -2
  199. package/dist/omnisearch/index.js +2 -2
  200. package/dist/omnisearch/types.d.cts +1 -1
  201. package/dist/omnisearch/types.d.ts +1 -1
  202. package/dist/{project-BOGaVs-q.d.ts → project-Bh954iOA.d.ts} +2 -2
  203. package/dist/{project-BnQkL8cb.d.cts → project-D25GH8zK.d.cts} +2 -2
  204. package/dist/queryService/index.cjs +1 -1
  205. package/dist/queryService/index.d.cts +1 -1
  206. package/dist/queryService/index.d.ts +1 -1
  207. package/dist/queryService/index.js +1 -1
  208. package/dist/queryService/types.d.cts +1 -1
  209. package/dist/queryService/types.d.ts +1 -1
  210. package/dist/{queryService-BLaGbpm-.cjs → queryService--t_W9PSJ.cjs} +6 -6
  211. package/dist/{queryService-BLaGbpm-.cjs.map → queryService--t_W9PSJ.cjs.map} +1 -1
  212. package/dist/{queryService-DK-jUnET.js → queryService-DX6zeAs_.js} +6 -6
  213. package/dist/{queryService-DK-jUnET.js.map → queryService-DX6zeAs_.js.map} +1 -1
  214. package/dist/queue/index.cjs +1 -1
  215. package/dist/queue/index.d.cts +3 -3
  216. package/dist/queue/index.d.ts +3 -3
  217. package/dist/queue/index.js +1 -1
  218. package/dist/queue/types.d.cts +1 -1
  219. package/dist/queue/types.d.ts +1 -1
  220. package/dist/{queue-B7TY4JLf.cjs → queue-D1_TCe0z.cjs} +5 -5
  221. package/dist/{queue-B7TY4JLf.cjs.map → queue-D1_TCe0z.cjs.map} +1 -1
  222. package/dist/{queue-DViSQ-eq.js → queue-DrLUbk98.js} +5 -5
  223. package/dist/{queue-DViSQ-eq.js.map → queue-DrLUbk98.js.map} +1 -1
  224. package/dist/scheduler/index.cjs +3 -3
  225. package/dist/scheduler/index.d.cts +2 -2
  226. package/dist/scheduler/index.d.ts +2 -2
  227. package/dist/scheduler/index.js +3 -3
  228. package/dist/scheduler/types.d.cts +1 -1
  229. package/dist/scheduler/types.d.ts +1 -1
  230. package/dist/sdk/configurations/index.d.cts +4 -4
  231. package/dist/sdk/configurations/index.d.ts +4 -4
  232. package/dist/sdk/developerPortal/index.cjs +5 -5
  233. package/dist/sdk/developerPortal/index.cjs.map +1 -1
  234. package/dist/sdk/developerPortal/index.d.cts +5 -4
  235. package/dist/sdk/developerPortal/index.d.ts +5 -4
  236. package/dist/sdk/developerPortal/index.js +4 -4
  237. package/dist/sdk/queryService/index.cjs +1 -1
  238. package/dist/sdk/queryService/index.d.cts +1 -1
  239. package/dist/sdk/queryService/index.d.ts +1 -1
  240. package/dist/sdk/queryService/index.js +1 -1
  241. package/dist/sdk/semanticLayer/index.cjs +163 -74
  242. package/dist/sdk/semanticLayer/index.cjs.map +1 -1
  243. package/dist/sdk/semanticLayer/index.d.cts +16 -13
  244. package/dist/sdk/semanticLayer/index.d.ts +16 -13
  245. package/dist/sdk/semanticLayer/index.js +158 -75
  246. package/dist/sdk/semanticLayer/index.js.map +1 -1
  247. package/dist/sdk/semanticLayer/types.d.cts +2 -2
  248. package/dist/sdk/semanticLayer/types.d.ts +2 -2
  249. package/dist/sdk/storage/index.d.cts +1 -1
  250. package/dist/sdk/storage/index.d.ts +1 -1
  251. package/dist/sdk/tag/index.d.cts +2 -2
  252. package/dist/sdk/tag/index.d.ts +2 -2
  253. package/dist/sdk/tag/types.d.cts +1 -1
  254. package/dist/sdk/tag/types.d.ts +1 -1
  255. package/dist/sdk/vault/index.d.cts +1 -1
  256. package/dist/sdk/vault/index.d.ts +1 -1
  257. package/dist/status/index.cjs +1 -1
  258. package/dist/status/index.d.cts +1 -1
  259. package/dist/status/index.d.ts +1 -1
  260. package/dist/status/index.js +1 -1
  261. package/dist/storage/index.cjs +4 -4
  262. package/dist/storage/index.d.cts +2 -2
  263. package/dist/storage/index.d.ts +2 -2
  264. package/dist/storage/index.js +4 -4
  265. package/dist/storage/types.d.cts +2 -2
  266. package/dist/storage/types.d.ts +2 -2
  267. package/dist/{storage-kgxscFEg.js → storage--cVaecFq.js} +7 -7
  268. package/dist/{storage-kgxscFEg.js.map → storage--cVaecFq.js.map} +1 -1
  269. package/dist/{storage-CihHwZ7z.cjs → storage-DexWot8H.cjs} +7 -7
  270. package/dist/{storage-CihHwZ7z.cjs.map → storage-DexWot8H.cjs.map} +1 -1
  271. package/dist/store-C9FQCHGe.js +74 -0
  272. package/dist/store-C9FQCHGe.js.map +1 -0
  273. package/dist/store-xS-Cu_VS.cjs +85 -0
  274. package/dist/store-xS-Cu_VS.cjs.map +1 -0
  275. package/dist/stream/index.cjs +3 -3
  276. package/dist/stream/index.d.cts +2 -2
  277. package/dist/stream/index.d.ts +2 -2
  278. package/dist/stream/index.js +3 -3
  279. package/dist/stream/types.d.cts +1 -1
  280. package/dist/stream/types.d.ts +1 -1
  281. package/dist/syncActions/index.cjs +1 -1
  282. package/dist/syncActions/index.d.cts +1 -1
  283. package/dist/syncActions/index.d.ts +1 -1
  284. package/dist/syncActions/index.js +1 -1
  285. package/dist/syncActions/types.d.cts +1 -1
  286. package/dist/syncActions/types.d.ts +1 -1
  287. package/dist/{syncActions-B75t0NwP.js → syncActions-CkMHM-jB.js} +5 -5
  288. package/dist/{syncActions-B75t0NwP.js.map → syncActions-CkMHM-jB.js.map} +1 -1
  289. package/dist/{syncActions-CevF_TEb.cjs → syncActions-DQq_A9v6.cjs} +5 -5
  290. package/dist/{syncActions-CevF_TEb.cjs.map → syncActions-DQq_A9v6.cjs.map} +1 -1
  291. package/dist/telemetry/index.cjs +1 -1
  292. package/dist/telemetry/index.d.cts +2 -2
  293. package/dist/telemetry/index.d.ts +2 -2
  294. package/dist/telemetry/index.js +1 -1
  295. package/dist/{telemetry-DwlSLVAU.cjs → telemetry-CAu1Qt7B.cjs} +3 -3
  296. package/dist/{telemetry-DwlSLVAU.cjs.map → telemetry-CAu1Qt7B.cjs.map} +1 -1
  297. package/dist/{telemetry-FXpodtJN.js → telemetry-Ca6j0i9w.js} +3 -3
  298. package/dist/{telemetry-FXpodtJN.js.map → telemetry-Ca6j0i9w.js.map} +1 -1
  299. package/dist/{types-CGH_lfxS.d.cts → types-0xa_7cgo.d.cts} +2 -2
  300. package/dist/{types-CyiRYRVq.d.cts → types-3p0adMdd.d.cts} +3 -3
  301. package/dist/{types-BlCoTm7n.d.ts → types-6ThDkaJw.d.ts} +2 -2
  302. package/dist/{types-CkcMoXRk.d.ts → types-6hh_3SZs.d.ts} +3 -3
  303. package/dist/{types-dybUhlU2.d.ts → types-6ku2LeX6.d.ts} +2 -2
  304. package/dist/{types-BH9ljNmj.d.cts → types-B42HhyB0.d.cts} +2 -2
  305. package/dist/{types-C1vhYcic.d.cts → types-B4_MM5Wf.d.cts} +2 -2
  306. package/dist/{types-DlbiVsVo.d.cts → types-B6JJCta-.d.cts} +2 -2
  307. package/dist/{types-sVYo0o9_.d.ts → types-B6lOyHY_.d.ts} +3 -3
  308. package/dist/{types-BZBdLUpH.d.ts → types-B7O5koJb.d.cts} +2 -2
  309. package/dist/{types-De_DA2ga.d.ts → types-BHI8Lin9.d.ts} +2 -2
  310. package/dist/{types-Cj4bLPp5.d.cts → types-BO3sCD0a.d.cts} +37 -6
  311. package/dist/{types-zA3H84SM.d.cts → types-BOnf68s5.d.cts} +2 -2
  312. package/dist/{types-CPanB0p7.d.cts → types-BS5M67xm.d.cts} +3 -3
  313. package/dist/{types-COIsNoTQ.d.cts → types-BT46XIgn.d.cts} +2 -2
  314. package/dist/types-BUYqdN7B.d.ts +205 -0
  315. package/dist/{types-D-qI9ne4.d.ts → types-BYKHr5bR.d.ts} +2 -2
  316. package/dist/{types-D1uloiuY.d.cts → types-Be3Wgn1U.d.cts} +2 -2
  317. package/dist/{types-BTbczawY.d.ts → types-BgVKG4vg.d.ts} +2 -2
  318. package/dist/{types-CyHZ1ZQe.d.ts → types-C2gzqtjf.d.ts} +2 -2
  319. package/dist/{types-Av2egS_l.d.ts → types-C35GWNmq.d.ts} +2 -2
  320. package/dist/{types-D6jKxUv_.d.ts → types-C4mr0lop.d.ts} +35 -3
  321. package/dist/{types-BI2jI-3-.d.cts → types-CCr1-9Q6.d.cts} +3 -3
  322. package/dist/{types-DeSd3gqW.d.ts → types-CHCM9oNk.d.ts} +3 -3
  323. package/dist/{types-BMQW-2Yw.d.ts → types-CNQdtffE.d.ts} +729 -79
  324. package/dist/{types-MbcIiKDI.d.cts → types-CPaluTW7.d.cts} +3 -3
  325. package/dist/{types-CXTqFYah.d.ts → types-CSc8NQCY.d.ts} +37 -6
  326. package/dist/{types-Cz1dj_TM.d.ts → types-C_ilZZkQ.d.ts} +2 -2
  327. package/dist/{types-EJEoI3ZK.d.ts → types-CaMfshWX.d.ts} +2 -2
  328. package/dist/{types-BoV9M5Xg.d.cts → types-Ccgbipp4.d.cts} +2 -2
  329. package/dist/{types-DuiUN0h8.d.ts → types-Cpjk0-ta.d.ts} +2 -2
  330. package/dist/{types-GuWtMCMn.d.cts → types-CrH4H8M4.d.cts} +2 -2
  331. package/dist/{types-DNXC_-fA.d.cts → types-Cu-0LT4f.d.cts} +2 -2
  332. package/dist/{types-BptQ7jpP.d.cts → types-CxmV36rp.d.cts} +2 -2
  333. package/dist/{types-DwpRt3e9.d.ts → types-D-98DirB.d.ts} +2 -2
  334. package/dist/{types-BV2BDccJ.d.cts → types-D6ocCyGh.d.cts} +35 -3
  335. package/dist/{types-COc-nind.d.cts → types-D7Wgcp0u.d.ts} +2 -2
  336. package/dist/{types-ByWD2oeV.d.ts → types-DAzmGzlb.d.ts} +2 -2
  337. package/dist/{types-BREGN3qo.d.cts → types-DHI0g51U.d.cts} +2 -2
  338. package/dist/{types-Dfc58bPE.d.ts → types-DHqIJKwx.d.ts} +2 -2
  339. package/dist/types-DONxb2-c.d.cts +205 -0
  340. package/dist/{types-Di8VIZwQ.d.ts → types-DTTC70Ac.d.ts} +2 -2
  341. package/dist/{types-C2CLlR4i.d.ts → types-DlvZeert.d.ts} +2 -2
  342. package/dist/{types-cDU_J45_.d.cts → types-DqniGeDJ.d.cts} +2 -2
  343. package/dist/{types-iNlsdRkx.d.cts → types-E3VT-zYz.d.cts} +729 -79
  344. package/dist/{types-B4jdPHoL.d.cts → types-Jt0ipbSm.d.cts} +2 -2
  345. package/dist/{types-Bpnpa2Wt.d.ts → types-Ur37iOqb.d.ts} +3 -3
  346. package/dist/{types-BnaAo7xn.d.ts → types-ZGAWRIBW.d.ts} +2 -2
  347. package/dist/{types-CvkqEvhv.d.cts → types-bY6K3y0O.d.cts} +2 -2
  348. package/dist/{types-CpALS017.d.ts → types-k4R8gQ4U.d.ts} +2 -2
  349. package/dist/{types-CcuG9cid.d.cts → types-sO52qIAA.d.cts} +2 -2
  350. package/dist/{types-CJHi0zdD.d.cts → types-sp1rJY9E.d.cts} +2 -2
  351. package/dist/{validateConnectionStatus-V9q6Nl6u.cjs → validateConnectionStatus-24zqIQ0p.cjs} +2 -2
  352. package/dist/{validateConnectionStatus-V9q6Nl6u.cjs.map → validateConnectionStatus-24zqIQ0p.cjs.map} +1 -1
  353. package/dist/{validateConnectionStatus-BrLXkoSI.js → validateConnectionStatus-DhkWg6Eq.js} +2 -2
  354. package/dist/{validateConnectionStatus-BrLXkoSI.js.map → validateConnectionStatus-DhkWg6Eq.js.map} +1 -1
  355. package/dist/vault/index.cjs +4 -4
  356. package/dist/vault/index.d.cts +1 -1
  357. package/dist/vault/index.d.ts +1 -1
  358. package/dist/vault/index.js +4 -4
  359. package/dist/vault/types.d.cts +1 -1
  360. package/dist/vault/types.d.ts +1 -1
  361. package/package.json +2 -2
  362. package/surface/auth.md +2 -2
  363. package/surface/kaiAgent.md +5 -2
  364. package/dist/authClient--BtZgjIc.js.map +0 -1
  365. package/dist/authClient-b7uec7sw.cjs.map +0 -1
  366. package/dist/createStore-BNiCRQXa.js +0 -148
  367. package/dist/createStore-BNiCRQXa.js.map +0 -1
  368. package/dist/createStore-MQbboXcB.cjs +0 -177
  369. package/dist/createStore-MQbboXcB.cjs.map +0 -1
  370. package/dist/credential-DOXH7XRS.cjs.map +0 -1
  371. package/dist/credential-d2RDcXRB.js.map +0 -1
  372. package/dist/jobStatus-DbMupQEK.js.map +0 -1
  373. package/dist/jobStatus-kQ9JqF8t.cjs.map +0 -1
  374. package/dist/kaiAgent-4OiIK1C2.cjs.map +0 -1
  375. package/dist/kaiAgent-HDaFS9BR.js.map +0 -1
  376. package/dist/types-B2vmg_UF.d.cts +0 -148
  377. package/dist/types-RfaldD4P.d.ts +0 -148
package/dist/index.cjs CHANGED
@@ -1,51 +1,51 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
3
  const require_project = require("./project-BvFi19K_.cjs");
4
- const require_jobStatus = require("./jobStatus-kQ9JqF8t.cjs");
5
- const require_queue = require("./queue-B7TY4JLf.cjs");
4
+ const require_jobStatus = require("./jobStatus-0_Y3Sr4i.cjs");
5
+ const require_queue = require("./queue-D1_TCe0z.cjs");
6
6
  const require_concurrent = require("./concurrent-tbiIa0UL.cjs");
7
7
  const require_dedupe = require("./dedupe-CiskLkGR.cjs");
8
- const require_createStore = require("./createStore-MQbboXcB.cjs");
9
- const require_storage = require("./storage-CihHwZ7z.cjs");
8
+ const require_store = require("./store-xS-Cu_VS.cjs");
9
+ const require_storage = require("./storage-DexWot8H.cjs");
10
10
  const require_tag = require("./tag-CsoOZWB_.cjs");
11
11
  const require_generateUUID = require("./generateUUID-C6qKBPIv.cjs");
12
12
  const require_isPlainObject = require("./isPlainObject-BB3iy87C.cjs");
13
13
  const require_configurations = require("./configurations-Ck-mNB_E.cjs");
14
14
  const require_UserError = require("./UserError-CSGO1qII.cjs");
15
- const require_createFetchClient = require("./createFetchClient-BRfTjBLV.cjs");
16
- const require_validateConnectionStatus = require("./validateConnectionStatus-V9q6Nl6u.cjs");
17
- const require_ManagementClientAuthError = require("./ManagementClientAuthError-B-tyPlyG.cjs");
15
+ const require_createFetchClient = require("./createFetchClient-DvZvD31l.cjs");
16
+ const require_validateConnectionStatus = require("./validateConnectionStatus-24zqIQ0p.cjs");
17
+ const require_ManagementClientAuthError = require("./ManagementClientAuthError-DqeXL8nv.cjs");
18
18
  const require_QueryJobTimeoutError = require("./QueryJobTimeoutError-CVNPdCWX.cjs");
19
19
  const require_SyncActionError = require("./SyncActionError-BG0zwchi.cjs");
20
20
  const require_ValidationError = require("./ValidationError-h5qvwahi.cjs");
21
- const require_createGenericFetchClient = require("./createGenericFetchClient-DHs-i7_O.cjs");
22
- const require_import = require("./import-C0-y1GQK.cjs");
23
- const require_authClient = require("./authClient-b7uec7sw.cjs");
24
- const require_management = require("./management-DfjwQo7z.cjs");
21
+ const require_createGenericFetchClient = require("./createGenericFetchClient-qfCZlCTv.cjs");
22
+ const require_import = require("./import-DJilJ6tq.cjs");
23
+ const require_authClient = require("./authClient-IwQ9Ti0J.cjs");
24
+ const require_management = require("./management-DGfgKsaA.cjs");
25
25
  const require_constants = require("./constants-lIfSdTzS.cjs");
26
26
  const require_storageTable = require("./storageTable-C9crh4Ef.cjs");
27
27
  const require_sdk_semanticLayer_index = require("./sdk/semanticLayer/index.cjs");
28
28
  const require_sdk_storage_index = require("./sdk/storage/index.cjs");
29
29
  const require_sdk_vault_index = require("./sdk/vault/index.cjs");
30
30
  const require_ai_index = require("./ai/index.cjs");
31
- const require_appLogs = require("./appLogs-NIEDTDHf.cjs");
31
+ const require_appLogs = require("./appLogs-D8K0VeNM.cjs");
32
32
  const require_apps_index = require("./apps/index.cjs");
33
33
  const require_chat_index = require("./chat/index.cjs");
34
- const require_dataScience = require("./dataScience-wexHEIue.cjs");
34
+ const require_dataScience = require("./dataScience-BPW993AG.cjs");
35
35
  const require_editor_index = require("./editor/index.cjs");
36
36
  const require_encryption_index = require("./encryption/index.cjs");
37
- const require_kaiAgent = require("./kaiAgent-4OiIK1C2.cjs");
38
- const require_metastore = require("./metastore-Dq2NS6jb.cjs");
37
+ const require_kaiAgent = require("./kaiAgent-CMVub6Sc.cjs");
38
+ const require_metastore = require("./metastore-DksEte8P.cjs");
39
39
  const require_notifications_index = require("./notifications/index.cjs");
40
- const require_oauth = require("./oauth-CkW5gln-.cjs");
40
+ const require_oauth = require("./oauth-DFsI1TE5.cjs");
41
41
  const require_omnisearch_index = require("./omnisearch/index.cjs");
42
- const require_queryService = require("./queryService-BLaGbpm-.cjs");
42
+ const require_queryService = require("./queryService--t_W9PSJ.cjs");
43
43
  const require_scheduler_index = require("./scheduler/index.cjs");
44
44
  const require_stream_index = require("./stream/index.cjs");
45
- const require_syncActions = require("./syncActions-CevF_TEb.cjs");
46
- const require_telemetry = require("./telemetry-DwlSLVAU.cjs");
45
+ const require_syncActions = require("./syncActions-DQq_A9v6.cjs");
46
+ const require_telemetry = require("./telemetry-CAu1Qt7B.cjs");
47
47
  const require_vault_index = require("./vault/index.cjs");
48
- const require_credential = require("./credential-DOXH7XRS.cjs");
48
+ const require_credential = require("./credential-D-X5QQrM.cjs");
49
49
  const require_sdk_queryService_index = require("./sdk/queryService/index.cjs");
50
50
  let zod = require("zod");
51
51
  zod = require_rolldown_runtime.__toESM(zod, 1);
@@ -94,11 +94,116 @@ const coalesce = (task) => {
94
94
  };
95
95
  };
96
96
  //#endregion
97
+ //#region src/utils/store/derivedStore.ts
98
+ const isPlainObjectOrArray = (value) => {
99
+ if (Array.isArray(value)) return true;
100
+ const proto = Object.getPrototypeOf(value);
101
+ return proto === Object.prototype || proto === null;
102
+ };
103
+ const shallowEqual = (a, b) => {
104
+ if (Object.is(a, b)) return true;
105
+ if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) return false;
106
+ if (!isPlainObjectOrArray(a) || !isPlainObjectOrArray(b)) return false;
107
+ const aKeys = Object.keys(a);
108
+ const bKeys = Object.keys(b);
109
+ return aKeys.length === bKeys.length && aKeys.every((key) => Object.is(a[key], b[key]));
110
+ };
111
+ const createDerivedStore = ({ source, dependsOn, build, keyEquals = shallowEqual }) => {
112
+ let key = dependsOn(source.get());
113
+ const store = require_store.createStore(build(key));
114
+ const unsubscribe = source.subscribe((state) => {
115
+ const next = dependsOn(state);
116
+ if (keyEquals(key, next)) return;
117
+ key = next;
118
+ store.set(build(next));
119
+ });
120
+ const get = store.get;
121
+ const subscribe = store.subscribe;
122
+ const dispose = () => {
123
+ unsubscribe();
124
+ store.dispose();
125
+ };
126
+ return {
127
+ get,
128
+ subscribe,
129
+ dispose
130
+ };
131
+ };
132
+ //#endregion
133
+ //#region src/utils/store/derivedAsyncStore.ts
134
+ const createDerivedAsyncStore = ({ source, dependsOn, build, keyEquals = shallowEqual }) => {
135
+ const store = require_store.createStore({ state: "idle" });
136
+ let currentKey = null;
137
+ let generation = 0;
138
+ let controller = null;
139
+ const run = (key) => {
140
+ controller?.abort();
141
+ controller = new AbortController();
142
+ const runGeneration = ++generation;
143
+ store.set({ state: "pending" });
144
+ build(key, controller.signal).then((value) => {
145
+ if (runGeneration === generation) store.set({
146
+ state: "ready",
147
+ value
148
+ });
149
+ }, (error) => {
150
+ if (runGeneration === generation) store.set({
151
+ state: "errored",
152
+ error
153
+ });
154
+ });
155
+ };
156
+ const sync = (state) => {
157
+ const next = dependsOn(state);
158
+ if (next === null) {
159
+ if (currentKey === null) return;
160
+ controller?.abort();
161
+ controller = null;
162
+ generation += 1;
163
+ currentKey = null;
164
+ store.set({ state: "idle" });
165
+ return;
166
+ }
167
+ if (currentKey !== null && keyEquals(currentKey, next)) return;
168
+ currentKey = next;
169
+ run(next);
170
+ };
171
+ sync(source.get());
172
+ const unsubscribe = source.subscribe(sync);
173
+ const get = store.get;
174
+ const subscribe = store.subscribe;
175
+ const dispose = () => {
176
+ controller?.abort();
177
+ unsubscribe();
178
+ store.dispose();
179
+ };
180
+ const readable = {
181
+ get,
182
+ subscribe,
183
+ dispose
184
+ };
185
+ const settled = () => new Promise((resolve) => {
186
+ let unsubscribeSettled = () => {};
187
+ const check = (state) => {
188
+ if (state.state === "ready" || state.state === "errored") {
189
+ unsubscribeSettled();
190
+ resolve(state);
191
+ }
192
+ };
193
+ unsubscribeSettled = store.subscribe(check);
194
+ check(store.get());
195
+ });
196
+ return {
197
+ store: readable,
198
+ settled
199
+ };
200
+ };
201
+ //#endregion
97
202
  //#region src/utils/async/poll/registry.ts
98
203
  const DEFAULT_LIMIT = 50;
99
204
  const isFinished = ({ snapshot }) => snapshot.state !== "idle" && snapshot.state !== "polling";
100
205
  const createPollRegistry = ({ limit = DEFAULT_LIMIT } = {}) => {
101
- const entries = require_createStore.createStore([]);
206
+ const entries = require_store.createStore([]);
102
207
  const unsubscribes = /* @__PURE__ */ new Map();
103
208
  const maxEntries = require_jobStatus.clamp(require_jobStatus.finiteOr(limit, DEFAULT_LIMIT), 1);
104
209
  let nextKey = 1;
@@ -288,7 +393,7 @@ const createProjectRefreshMiddleware = (shouldRefresh, requestRefresh) => (next)
288
393
  * token-mutating request or an explicit re-scope. Its `middleware` drives the auto re-verify.
289
394
  */
290
395
  const createLiveProject = ({ initialToken, verify }) => {
291
- const store = require_createStore.createStore(require_project.createProject({ sapiToken: initialToken }));
396
+ const store = require_store.createStore(require_project.createProject({ sapiToken: initialToken }));
292
397
  const refresh = coalesce(async () => store.set(require_project.createProject({ sapiToken: await verify() })));
293
398
  const middleware = createProjectRefreshMiddleware(isStorageTokenMutatingRequest, refresh);
294
399
  return {
@@ -602,8 +707,9 @@ const stamp = (tokens) => ({
602
707
  issuedAt: Date.now()
603
708
  });
604
709
  const createConfig$1 = (initial = INITIAL) => {
605
- const store = require_createStore.createStore(initial);
710
+ const store = require_store.createStore(initial);
606
711
  let expiredNotified = false;
712
+ let epoch = 0;
607
713
  const setBaseUrl = (baseUrl) => {
608
714
  if (store.get().status !== "anonymous") throw new KeboolaError(KeboolaErrorType.AlreadyAuthenticated);
609
715
  store.set({
@@ -616,6 +722,7 @@ const createConfig$1 = (initial = INITIAL) => {
616
722
  if (state.status !== "anonymous") throw new KeboolaError(KeboolaErrorType.AlreadyAuthenticated);
617
723
  if (!state.baseUrl) throw new KeboolaError(KeboolaErrorType.Unconfigured);
618
724
  expiredNotified = false;
725
+ epoch += 1;
619
726
  store.set({
620
727
  status: "authenticated",
621
728
  baseUrl: state.baseUrl,
@@ -649,6 +756,7 @@ const createConfig$1 = (initial = INITIAL) => {
649
756
  };
650
757
  /** Drop the credential (sign out); keeps the configured baseUrl. */
651
758
  const reset = () => {
759
+ epoch += 1;
652
760
  store.set({
653
761
  status: "anonymous",
654
762
  baseUrl: store.get().baseUrl
@@ -690,6 +798,15 @@ const createConfig$1 = (initial = INITIAL) => {
690
798
  };
691
799
  const getBaseUrl = () => store.get().baseUrl;
692
800
  /**
801
+ * Which sign-in this is — a counter, bumped by `authenticate` and `reset`.
802
+ *
803
+ * - For anything long-lived that must not outlive the credential it was built against: capture it,
804
+ * compare it later. A rotation does not move it; only a new session or a sign-out does.
805
+ * - Distinct from `notifyExpired`'s latch, which answers "report this death once" rather than
806
+ * "which session are we in".
807
+ */
808
+ const getEpoch = () => epoch;
809
+ /**
693
810
  * Session-expiry latch (fire-once):
694
811
  * - why: concurrent 401s all report expiry, but the app must sign out once; and the credential /
695
812
  * auth middleware are long-lived singletons, so the latch can't live in them — it must reset
@@ -718,6 +835,7 @@ const createConfig$1 = (initial = INITIAL) => {
718
835
  forceExpire,
719
836
  requireCredential,
720
837
  getBaseUrl,
838
+ getEpoch,
721
839
  notifyExpired,
722
840
  debug
723
841
  };
@@ -1057,7 +1175,7 @@ const createProjectClients$1 = async ({ baseUrl, projectId, authMiddleware, midd
1057
1175
  initialToken: sapiToken,
1058
1176
  verify: () => reader.tokens.verify()
1059
1177
  });
1060
- const storageTableStore = require_createStore.createDerivedStore({
1178
+ const storageTableStore = createDerivedStore({
1061
1179
  source: liveProject.store,
1062
1180
  build: require_storageTable.createStorageTable,
1063
1181
  dependsOn: (project) => ({
@@ -1177,7 +1295,7 @@ const createKeboola = (options = {}) => {
1177
1295
  const config = createConfig$1();
1178
1296
  const middlewareFor = createMiddlewareFor(options.middlewares);
1179
1297
  const retryContention = createRetryMiddleware({ shouldRetry: (error) => error instanceof require_createFetchClient.ApiError && error.response.status === require_createFetchClient.HttpStatus.SERVICE_UNAVAILABLE });
1180
- const authClientBare = require_createStore.createDerivedStore({
1298
+ const authClientBare = createDerivedStore({
1181
1299
  source: config.store,
1182
1300
  dependsOn: (state) => state.baseUrl,
1183
1301
  build: (baseUrl) => baseUrl ? require_authClient.createAuthClient({
@@ -1188,7 +1306,12 @@ const createKeboola = (options = {}) => {
1188
1306
  const refresh = async () => {
1189
1307
  const client = authClientBare.get();
1190
1308
  assert$1(client, KeboolaErrorType.NotReady);
1191
- const refreshed = await client.token.refresh(config.requireCredential().refreshToken);
1309
+ const epoch = config.getEpoch();
1310
+ const refreshed = await client.token.refresh(config.requireCredential().refreshToken).catch((error) => {
1311
+ if (config.getEpoch() !== epoch) throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
1312
+ throw error;
1313
+ });
1314
+ if (config.getEpoch() !== epoch) throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
1192
1315
  config.applyRefresh(refreshed);
1193
1316
  return refreshed.accessToken;
1194
1317
  };
@@ -1204,8 +1327,36 @@ const createKeboola = (options = {}) => {
1204
1327
  }
1205
1328
  };
1206
1329
  };
1330
+ /**
1331
+ * The project this session is scoped to, right now.
1332
+ *
1333
+ * - Read at every point that stamps a project, never snapshotted across an `await`: the scope moves
1334
+ * with `setProject`/`clearProject`, and neither ends the session, so it is not in the epoch and
1335
+ * `assertSameSession` cannot see it change.
1336
+ * - `NotReady` rather than `NotAuthenticated` when merely unscoped — the credential is fine, the
1337
+ * project is what is missing. A credential alone does not authorize a project request: kai-agent
1338
+ * reads the project from the header, not the token, and cannot attribute a call that omits it.
1339
+ */
1340
+ const requireScopedProject = () => {
1341
+ const state = config.store.get();
1342
+ if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
1343
+ if (state.status !== "scoped") throw new KeboolaError(KeboolaErrorType.NotReady);
1344
+ return state.projectId;
1345
+ };
1346
+ /**
1347
+ * The project client sets `forProject` has handed out, keyed by project id.
1348
+ *
1349
+ * - Not keyed by stack: `setBaseUrl` throws once authenticated and `signOut` empties this, so one
1350
+ * entry can never belong to a different `baseUrl` than the live session.
1351
+ * - A `lazy` per key, not a bare promise: concurrent callers share one bootstrap, later ones replay
1352
+ * the resolved set, and a rejected build clears only its own slot — so a build orphaned by a
1353
+ * sign-out cannot evict the entry that replaced it.
1354
+ */
1355
+ const extraProjects = /* @__PURE__ */ new Map();
1207
1356
  const signOut = () => {
1208
1357
  config.reset();
1358
+ credential.abandonRefresh();
1359
+ extraProjects.clear();
1209
1360
  persistor.clear();
1210
1361
  };
1211
1362
  const onSessionExpired = () => {
@@ -1216,16 +1367,78 @@ const createKeboola = (options = {}) => {
1216
1367
  getToken,
1217
1368
  onSessionExpired
1218
1369
  });
1219
- const authMiddleware = createBearerAuthMiddleware(credential);
1220
- const authClient = require_createStore.createDerivedStore({
1370
+ const sessionGuard = (epoch) => () => {
1371
+ if (config.getEpoch() !== epoch) throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
1372
+ };
1373
+ /**
1374
+ * The auth middleware, refusing to carry a request across a change of session.
1375
+ *
1376
+ * - The middleware holds no token — it reads the credential live — so anything built on it acts as
1377
+ * whoever is signed in *at request time*, not whoever built it. Rebuilding a store on sign-out
1378
+ * only stops new reads; a request already in flight completes as the next user, still stamped
1379
+ * with the old project. `config`'s epoch moves on `authenticate` and `reset` and never on a
1380
+ * rotation, so it is exactly "which sign-in is this".
1381
+ * - `epochFor` says which sign-in a request answers to, resolved per request:
1382
+ * 1. a client set pins to the sign-in that *built* it (`pinToSession`) — a set the caller still
1383
+ * holds must not ride the session that replaced it;
1384
+ * 2. `api.auth` pins to the sign-in the request *started* on, because its store is keyed on
1385
+ * `baseUrl` alone: it is built once, while anonymous, so a build-time pin would freeze at that
1386
+ * epoch and refuse every authenticated call.
1387
+ * - The guard covers every credential read, not only the wire request, so it wraps the credential
1388
+ * rather than sitting beside it. The 401 path rotates the token by calling the credential
1389
+ * directly: a straggler from a dead session would otherwise spend the *live* session's
1390
+ * single-use refresh token, and sign that session out if the rotation itself came back 401.
1391
+ * - `expiresSession` decides whether a 401 that survives a rotation means the session is dead.
1392
+ * True for this session's own realms; false where the 401 may be about the project instead of
1393
+ * the credential (see `forProject`).
1394
+ * - `inner` is for middleware that **re-invokes `next`** — a retry. Composed outside the pin it
1395
+ * would re-enter it per attempt, and with a per-request `epochFor` each attempt would re-pin to
1396
+ * whoever is signed in by then: a 503 backoff is exactly long enough for a sign-out to land, and
1397
+ * the retry then goes out as the next user. Inside, one epoch covers every attempt and each
1398
+ * attempt still passes the guard. Anything new that retries belongs here, not in the array.
1399
+ */
1400
+ const createPinnedAuthMiddleware = (epochFor, { expiresSession = true, inner = [] } = {}) => {
1401
+ return (next) => (request) => {
1402
+ const assertSameSession = sessionGuard(epochFor());
1403
+ const pinnedCredential = {
1404
+ ...credential,
1405
+ getAccessToken: async (options) => {
1406
+ assertSameSession();
1407
+ return credential.getAccessToken(options);
1408
+ },
1409
+ notifyExpired: expiresSession ? credential.notifyExpired : () => {}
1410
+ };
1411
+ const guarded = (wire) => (repeated) => {
1412
+ assertSameSession();
1413
+ return wire(repeated);
1414
+ };
1415
+ const chain = inner.reduceRight((acc, middleware) => middleware(acc), guarded(next));
1416
+ return createBearerAuthMiddleware(pinnedCredential)(chain)(request);
1417
+ };
1418
+ };
1419
+ /**
1420
+ * Pin something long-lived to the sign-in live right now.
1421
+ *
1422
+ * - `assertSameSession` is for whatever no middleware chain covers: a bootstrap whose every
1423
+ * request passed the guard before the sign-out resolves anyway and must not be handed back, and
1424
+ * `getAuthHeaders`, which emits the credential by hand.
1425
+ */
1426
+ const pinToSession = (options) => {
1427
+ const epoch = config.getEpoch();
1428
+ return {
1429
+ assertSameSession: sessionGuard(epoch),
1430
+ pinnedAuthMiddleware: createPinnedAuthMiddleware(() => epoch, options)
1431
+ };
1432
+ };
1433
+ const authClient = createDerivedStore({
1221
1434
  source: config.store,
1222
1435
  dependsOn: (state) => state.baseUrl,
1223
1436
  build: (baseUrl) => baseUrl ? require_authClient.createAuthClient({
1224
1437
  baseUrl,
1225
- middlewares: middlewareFor("auth", [retryContention, authMiddleware])
1438
+ middlewares: middlewareFor("auth", [createPinnedAuthMiddleware(config.getEpoch, { inner: [retryContention] })])
1226
1439
  }) : null
1227
1440
  });
1228
- const management = require_createStore.createDerivedStore({
1441
+ const management = createDerivedStore({
1229
1442
  source: config.store,
1230
1443
  dependsOn: (state) => state.status === "anonymous" ? null : state.baseUrl,
1231
1444
  build: (baseUrl) => baseUrl ? require_management.createManagementClient({
@@ -1234,10 +1447,10 @@ const createKeboola = (options = {}) => {
1234
1447
  type: "bearer",
1235
1448
  token: ""
1236
1449
  },
1237
- middlewares: middlewareFor("management", [authMiddleware])
1450
+ middlewares: middlewareFor("management", [pinToSession().pinnedAuthMiddleware])
1238
1451
  }) : null
1239
1452
  });
1240
- const projectClientsAsync = require_createStore.createDerivedAsyncStore({
1453
+ const projectClientsAsync = createDerivedAsyncStore({
1241
1454
  source: config.store,
1242
1455
  dependsOn: (state) => state.status === "scoped" ? {
1243
1456
  baseUrl: state.baseUrl,
@@ -1246,13 +1459,33 @@ const createKeboola = (options = {}) => {
1246
1459
  build: ({ baseUrl, projectId }) => {
1247
1460
  return createProjectClients$1({
1248
1461
  baseUrl,
1249
- authMiddleware,
1462
+ authMiddleware: pinToSession().pinnedAuthMiddleware,
1250
1463
  projectId,
1251
1464
  middlewareFor,
1252
1465
  clientServiceUrls: options.clientServiceUrls
1253
1466
  });
1254
1467
  }
1255
1468
  });
1469
+ const forProject = async (projectId) => {
1470
+ const state = config.store.get();
1471
+ if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
1472
+ const cached = extraProjects.get(projectId);
1473
+ if (cached) return cached();
1474
+ const { assertSameSession, pinnedAuthMiddleware } = pinToSession({ expiresSession: false });
1475
+ const build = require_jobStatus.lazy(async () => {
1476
+ const clients = await createProjectClients$1({
1477
+ baseUrl: state.baseUrl,
1478
+ authMiddleware: pinnedAuthMiddleware,
1479
+ projectId,
1480
+ middlewareFor,
1481
+ clientServiceUrls: options.clientServiceUrls
1482
+ });
1483
+ assertSameSession();
1484
+ return clients;
1485
+ });
1486
+ extraProjects.set(projectId, build);
1487
+ return build();
1488
+ };
1256
1489
  if (options.baseUrl) config.setBaseUrl(options.baseUrl);
1257
1490
  config.store.subscribe((state) => {
1258
1491
  if (state.status === "anonymous") return;
@@ -1286,6 +1519,19 @@ const createKeboola = (options = {}) => {
1286
1519
  * re-entering the project. Use `reset` to sign out instead.
1287
1520
  */
1288
1521
  clearProject: config.clearProjectId,
1522
+ /**
1523
+ * The clients for one project, off this session — for reaching a second project without leaving
1524
+ * the first.
1525
+ *
1526
+ * - `setProjectAsync` *moves* the session (and `api`) to another project; this *adds* one. The
1527
+ * returned set is the caller's to hold and never appears on `api`.
1528
+ * - Every set shares this session's auth middleware, so one rotation serves all of them. A second
1529
+ * `createKeboola()` does not: both hold the same single-use refresh token, and the first to
1530
+ * rotate invalidates the other's, whose next refresh 401s and signs it out.
1531
+ * - Independent of the scope, including for the scoped project itself — asking for that one
1532
+ * builds a second set with its own `liveProject`, so prefer `api.*` there.
1533
+ */
1534
+ forProject,
1289
1535
  reset: signOut,
1290
1536
  /**
1291
1537
  * Dev/test only: mark the current access token as expired so the bearer credential rotates it on
@@ -1304,16 +1550,22 @@ const createKeboola = (options = {}) => {
1304
1550
  * one is never re-sent. A snapshot held by the caller would do neither.
1305
1551
  * - Throws rather than emitting a half-formed `Bearer null`: an unauthenticated or unscoped
1306
1552
  * session has nothing to authorize with.
1553
+ * - Pinned to the sign-in it was called on, like every client here. This is the one
1554
+ * credential-emitting surface with no middleware chain for the guard to sit in, so the check
1555
+ * is written out around the `await` that rotates the token.
1556
+ * - The scope is re-read after that `await`, not carried across it. The epoch the pin compares
1557
+ * moves on a sign-in and a sign-out only, so a project switch mid-rotation is invisible to it.
1307
1558
  */
1308
1559
  getAuthHeaders: async () => {
1309
- const state = config.store.get();
1310
- if (state.status === "anonymous") throw new KeboolaError(KeboolaErrorType.NotAuthenticated);
1311
- if (state.status !== "scoped") throw new KeboolaError(KeboolaErrorType.NotReady);
1560
+ const { assertSameSession } = pinToSession();
1561
+ requireScopedProject();
1312
1562
  const accessToken = await credential.getAccessToken();
1563
+ assertSameSession();
1564
+ const projectId = requireScopedProject();
1313
1565
  assert$1(accessToken, KeboolaErrorType.NotAuthenticated);
1314
1566
  return {
1315
1567
  [require_createFetchClient.HttpHeader.AUTHORIZATION]: `Bearer ${accessToken}`,
1316
- [require_createFetchClient.KeboolaHttpHeader.PROJECT_ID]: String(state.projectId)
1568
+ [require_createFetchClient.KeboolaHttpHeader.PROJECT_ID]: String(projectId)
1317
1569
  };
1318
1570
  },
1319
1571
  restore: async () => {
@@ -1327,8 +1579,10 @@ const createKeboola = (options = {}) => {
1327
1579
  if (!configured) config.setBaseUrl(persisted.baseUrl);
1328
1580
  const client = authClientBare.get();
1329
1581
  assert$1(client, KeboolaErrorType.NotReady);
1582
+ const startedOn = config.getEpoch();
1330
1583
  try {
1331
1584
  const refreshed = await client.token.refresh(persisted.refreshToken);
1585
+ if (config.getEpoch() !== startedOn) return { status: "empty" };
1332
1586
  config.authenticate(refreshed);
1333
1587
  if (persisted.projectId !== null) {
1334
1588
  config.setProjectId(persisted.projectId);
@@ -1336,6 +1590,7 @@ const createKeboola = (options = {}) => {
1336
1590
  }
1337
1591
  return { status: "restored" };
1338
1592
  } catch (err) {
1593
+ if (config.getEpoch() !== startedOn) return { status: "empty" };
1339
1594
  if (require_credential.isUnauthorized(err)) {
1340
1595
  persistor.clear();
1341
1596
  return { status: "expired" };
@@ -1368,7 +1623,7 @@ const createKeboola = (options = {}) => {
1368
1623
  //#endregion
1369
1624
  //#region src/keboola/legacy/createConfig.ts
1370
1625
  const createConfig = () => {
1371
- const store = require_createStore.createStore({
1626
+ const store = require_store.createStore({
1372
1627
  baseUrl: null,
1373
1628
  sapiToken: null,
1374
1629
  managementToken: null
@@ -1434,7 +1689,7 @@ const createProjectClients = async ({ baseUrl, getStorageToken, onStorageTokenRe
1434
1689
  initialToken: sapiToken,
1435
1690
  verify: () => _storage.tokens.verify()
1436
1691
  });
1437
- const storageTableStore = require_createStore.createDerivedStore({
1692
+ const storageTableStore = createDerivedStore({
1438
1693
  source: liveProject.store,
1439
1694
  build: require_storageTable.createStorageTable,
1440
1695
  dependsOn: (project) => ({
@@ -1495,7 +1750,7 @@ const createProjectClients = async ({ baseUrl, getStorageToken, onStorageTokenRe
1495
1750
  const createLegacyKeboola = (options = {}) => {
1496
1751
  const config = createConfig();
1497
1752
  const middlewareFor = createMiddlewareFor(options.middlewares);
1498
- const authClient = require_createStore.createDerivedStore({
1753
+ const authClient = createDerivedStore({
1499
1754
  source: config.store,
1500
1755
  dependsOn: (state) => state.baseUrl,
1501
1756
  build: (baseUrl) => baseUrl ? require_authClient.createAuthClient({
@@ -1503,7 +1758,7 @@ const createLegacyKeboola = (options = {}) => {
1503
1758
  middlewares: middlewareFor("auth", [])
1504
1759
  }) : null
1505
1760
  });
1506
- const management = require_createStore.createDerivedStore({
1761
+ const management = createDerivedStore({
1507
1762
  source: config.store,
1508
1763
  dependsOn: (state) => ({
1509
1764
  baseUrl: state.baseUrl,
@@ -1518,7 +1773,7 @@ const createLegacyKeboola = (options = {}) => {
1518
1773
  middlewares: middlewareFor("management", [])
1519
1774
  }) : null
1520
1775
  });
1521
- const build = require_createStore.createDerivedAsyncStore({
1776
+ const build = createDerivedAsyncStore({
1522
1777
  source: config.store,
1523
1778
  dependsOn: (state) => state.sapiToken && state.baseUrl ? state.baseUrl : null,
1524
1779
  build: (baseUrl) => createProjectClients({
@@ -1592,9 +1847,9 @@ exports.assert = assert;
1592
1847
  exports.coalesce = coalesce;
1593
1848
  exports.collect = require_queue.collect;
1594
1849
  exports.concurrent = require_concurrent.concurrent;
1595
- exports.createDerivedAsyncStore = require_createStore.createDerivedAsyncStore;
1596
- exports.createDerivedStore = require_createStore.createDerivedStore;
1597
- exports.createEmitter = require_createStore.createEmitter;
1850
+ exports.createDerivedAsyncStore = createDerivedAsyncStore;
1851
+ exports.createDerivedStore = createDerivedStore;
1852
+ exports.createEmitter = require_store.createEmitter;
1598
1853
  exports.createGenericFetchClient = require_createGenericFetchClient.createGenericFetchClient;
1599
1854
  exports.createKeboola = createKeboola;
1600
1855
  exports.createLegacyKeboola = createLegacyKeboola;
@@ -1608,7 +1863,7 @@ exports.createQueryServiceSdk = require_sdk_queryService_index.createQueryServic
1608
1863
  exports.createRetryMiddleware = createRetryMiddleware;
1609
1864
  exports.createSessionStorage = createSessionStorage;
1610
1865
  exports.createStorageSdk = require_sdk_storage_index.createStorageSdk;
1611
- exports.createStore = require_createStore.createStore;
1866
+ exports.createStore = require_store.createStore;
1612
1867
  exports.dedupe = require_dedupe.dedupe;
1613
1868
  exports.deepMerge = deepMerge;
1614
1869
  exports.delay = require_jobStatus.delay;
@@ -1627,6 +1882,7 @@ exports.isQueryJobError = require_QueryJobTimeoutError.isQueryJobError;
1627
1882
  exports.isQueryJobTimeoutError = require_QueryJobTimeoutError.isQueryJobTimeoutError;
1628
1883
  exports.isStorageTokenMutatingRequest = isStorageTokenMutatingRequest;
1629
1884
  exports.isSyncActionError = require_SyncActionError.isSyncActionError;
1885
+ exports.isTimeoutError = require_createFetchClient.isTimeoutError;
1630
1886
  exports.isValidationError = require_ValidationError.isValidationError;
1631
1887
  exports.jobStatus = require_jobStatus.jobStatus;
1632
1888
  exports.keboolaUID = require_tag.keboolaUID;
@@ -1637,6 +1893,6 @@ exports.poll = require_jobStatus.poll;
1637
1893
  exports.poller = require_jobStatus.poller;
1638
1894
  exports.schemaGuidedMerge = require_configurations.schemaGuidedMerge;
1639
1895
  exports.series = require_storage.series;
1640
- exports.shallowEqual = require_createStore.shallowEqual;
1896
+ exports.shallowEqual = shallowEqual;
1641
1897
 
1642
1898
  //# sourceMappingURL=index.cjs.map