@keboola/api-client 52.0.0 → 54.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 (164) hide show
  1. package/AGENTS.md +33 -6
  2. package/API-SURFACE.md +5 -1
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +1 -1
  5. package/dist/{admin-Di-MmGFP.cjs → admin-BZ7knTd0.cjs} +18 -2
  6. package/dist/admin-BZ7knTd0.cjs.map +1 -0
  7. package/dist/{admin-CbMOsfgs.js → admin-xFfHSZHQ.js} +13 -3
  8. package/dist/admin-xFfHSZHQ.js.map +1 -0
  9. package/dist/{componentId-DZP1rBix.js → componentId-Cps6WBy1.js} +1 -2
  10. package/dist/{componentId-DZP1rBix.js.map → componentId-Cps6WBy1.js.map} +1 -1
  11. package/dist/{componentId-olp0tltf.cjs → componentId-_tRhEv6W.cjs} +1 -2
  12. package/dist/{componentId-olp0tltf.cjs.map → componentId-_tRhEv6W.cjs.map} +1 -1
  13. package/dist/{configurations-WI8H4zLk.cjs → configurations-BM63ep1s.cjs} +2 -2
  14. package/dist/{configurations-WI8H4zLk.cjs.map → configurations-BM63ep1s.cjs.map} +1 -1
  15. package/dist/{configurations-Cd6Nsox-.js → configurations-BqvtIQm4.js} +2 -2
  16. package/dist/{configurations-Cd6Nsox-.js.map → configurations-BqvtIQm4.js.map} +1 -1
  17. package/dist/constants/index.cjs +4 -3
  18. package/dist/constants/index.d.cts +1 -1
  19. package/dist/constants/index.d.ts +1 -1
  20. package/dist/constants/index.js +3 -2
  21. package/dist/{constants-Dqi0ewGv.js → constants-DLPkpnGv.js} +4 -32
  22. package/dist/{constants-Dqi0ewGv.js.map → constants-DLPkpnGv.js.map} +1 -1
  23. package/dist/{constants-d0Do9NSN.cjs → constants-Day8CU5i.cjs} +3 -37
  24. package/dist/{constants-d0Do9NSN.cjs.map → constants-Day8CU5i.cjs.map} +1 -1
  25. package/dist/domain/permissions/index.cjs +4 -3
  26. package/dist/domain/permissions/index.d.cts +9 -1
  27. package/dist/domain/permissions/index.d.ts +9 -1
  28. package/dist/domain/permissions/index.js +4 -4
  29. package/dist/encryption/index.d.cts +1 -1
  30. package/dist/encryption/index.d.ts +1 -1
  31. package/dist/encryption/types.d.cts +1 -1
  32. package/dist/encryption/types.d.ts +1 -1
  33. package/dist/{index-Df8lZNSH.d.cts → index-B04rWq_0.d.cts} +2 -2
  34. package/dist/{index-B7el5pJU.d.cts → index-BtvWJBYh.d.cts} +20 -7
  35. package/dist/{index-B5rELADq.d.cts → index-Cd0naVic.d.cts} +2 -2
  36. package/dist/{index-CveF5RFQ.d.ts → index-DCfumWzq.d.ts} +2 -2
  37. package/dist/{index-81wn1jc3.d.cts → index-DX7qciZA.d.cts} +36 -2
  38. package/dist/{index-Dhyrg5zd.d.ts → index-DbStyQKc.d.ts} +2 -2
  39. package/dist/{index-C7JcNvbd.d.ts → index-Df30jjpZ.d.ts} +20 -7
  40. package/dist/{index-JoKfPQND.d.ts → index-DzqHh0lE.d.ts} +36 -2
  41. package/dist/index.cjs +9 -9
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +2 -2
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.js +7 -7
  46. package/dist/management/index.cjs +1 -1
  47. package/dist/management/index.d.cts +1 -1
  48. package/dist/management/index.d.ts +1 -1
  49. package/dist/management/index.js +1 -1
  50. package/dist/management/types.d.cts +2 -2
  51. package/dist/management/types.d.ts +2 -2
  52. package/dist/{management-Cz5ut18k.js → management-BAfg8BmK.js} +45 -4
  53. package/dist/management-BAfg8BmK.js.map +1 -0
  54. package/dist/{management-CUXgB2rb.cjs → management-BuNIc7Mr.cjs} +45 -4
  55. package/dist/management-BuNIc7Mr.cjs.map +1 -0
  56. package/dist/metaObject-CSGF3d-o.js +53 -0
  57. package/dist/metaObject-CSGF3d-o.js.map +1 -0
  58. package/dist/metaObject-Ciyow2gr.cjs +64 -0
  59. package/dist/metaObject-Ciyow2gr.cjs.map +1 -0
  60. package/dist/metaObject-ClvW342q.d.ts +35 -0
  61. package/dist/metaObject-D7oudegV.d.cts +35 -0
  62. package/dist/oauth/index.cjs +2 -1
  63. package/dist/oauth/index.d.cts +34 -2
  64. package/dist/oauth/index.d.ts +34 -2
  65. package/dist/oauth/index.js +1 -1
  66. package/dist/oauth/types.d.cts +2 -2
  67. package/dist/oauth/types.d.ts +2 -2
  68. package/dist/{oauth-CSBChWuf.cjs → oauth-CXcrilOp.cjs} +47 -1
  69. package/dist/oauth-CXcrilOp.cjs.map +1 -0
  70. package/dist/{oauth-DOveZKUv.js → oauth-Ci0qeaS2.js} +43 -3
  71. package/dist/oauth-Ci0qeaS2.js.map +1 -0
  72. package/dist/{project-Onf-IcPW.cjs → project-BQ2oD6IW.cjs} +2 -2
  73. package/dist/{project-Onf-IcPW.cjs.map → project-BQ2oD6IW.cjs.map} +1 -1
  74. package/dist/{project-DmuC0bMK.js → project-aAVAOcmx.js} +2 -2
  75. package/dist/{project-DmuC0bMK.js.map → project-aAVAOcmx.js.map} +1 -1
  76. package/dist/queryService/index.d.cts +1 -1
  77. package/dist/queryService/index.d.ts +1 -1
  78. package/dist/queryService/types.d.cts +1 -1
  79. package/dist/queryService/types.d.ts +1 -1
  80. package/dist/queryService-B4h1Ez44.cjs +117 -0
  81. package/dist/queryService-B4h1Ez44.cjs.map +1 -0
  82. package/dist/queryService-DE_yE_S4.js +106 -0
  83. package/dist/queryService-DE_yE_S4.js.map +1 -0
  84. package/dist/queue/index.d.cts +1 -1
  85. package/dist/queue/index.d.ts +1 -1
  86. package/dist/readJwtClaims-CMZ3cNC_.js +28 -0
  87. package/dist/readJwtClaims-CMZ3cNC_.js.map +1 -0
  88. package/dist/readJwtClaims-SVJgo04x.cjs +33 -0
  89. package/dist/readJwtClaims-SVJgo04x.cjs.map +1 -0
  90. package/dist/sdk/configurations/index.cjs +2 -2
  91. package/dist/sdk/configurations/index.d.cts +2 -2
  92. package/dist/sdk/configurations/index.d.ts +2 -2
  93. package/dist/sdk/configurations/index.js +2 -2
  94. package/dist/sdk/dataAppServer/index.cjs +230 -0
  95. package/dist/sdk/dataAppServer/index.cjs.map +1 -0
  96. package/dist/sdk/dataAppServer/index.d.cts +55 -0
  97. package/dist/sdk/dataAppServer/index.d.ts +55 -0
  98. package/dist/sdk/dataAppServer/index.js +228 -0
  99. package/dist/sdk/dataAppServer/index.js.map +1 -0
  100. package/dist/sdk/developerPortal/index.cjs +3 -15
  101. package/dist/sdk/developerPortal/index.cjs.map +1 -1
  102. package/dist/sdk/developerPortal/index.js +3 -15
  103. package/dist/sdk/developerPortal/index.js.map +1 -1
  104. package/dist/sdk/queryService/index.cjs +3 -70
  105. package/dist/sdk/queryService/index.d.cts +2 -2
  106. package/dist/sdk/queryService/index.d.ts +2 -2
  107. package/dist/sdk/queryService/index.js +1 -70
  108. package/dist/sdk/securityPolicy/index.cjs +355 -0
  109. package/dist/sdk/securityPolicy/index.cjs.map +1 -0
  110. package/dist/sdk/securityPolicy/index.d.cts +100 -0
  111. package/dist/sdk/securityPolicy/index.d.ts +100 -0
  112. package/dist/sdk/securityPolicy/index.js +342 -0
  113. package/dist/sdk/securityPolicy/index.js.map +1 -0
  114. package/dist/sdk/securityPolicy/types.cjs +0 -0
  115. package/dist/sdk/securityPolicy/types.d.cts +2 -0
  116. package/dist/sdk/securityPolicy/types.d.ts +2 -0
  117. package/dist/sdk/securityPolicy/types.js +1 -0
  118. package/dist/sdk/semanticLayer/index.cjs +3 -2
  119. package/dist/sdk/semanticLayer/index.d.cts +8 -3
  120. package/dist/sdk/semanticLayer/index.d.ts +8 -3
  121. package/dist/sdk/semanticLayer/index.js +3 -1
  122. package/dist/sdk/semanticLayer/types.d.cts +1 -1
  123. package/dist/sdk/semanticLayer/types.d.ts +1 -1
  124. package/dist/sdk/vault/index.d.cts +1 -1
  125. package/dist/sdk/vault/index.d.ts +1 -1
  126. package/dist/{semanticLayer-djom-J78.cjs → semanticLayer-BVpdWKJn.cjs} +19 -52
  127. package/dist/semanticLayer-BVpdWKJn.cjs.map +1 -0
  128. package/dist/{semanticLayer-BdPW_wLo.js → semanticLayer-Btj1Qy9O.js} +20 -47
  129. package/dist/semanticLayer-Btj1Qy9O.js.map +1 -0
  130. package/dist/serviceIds-Bg1pWiPE.cjs +37 -0
  131. package/dist/serviceIds-Bg1pWiPE.cjs.map +1 -0
  132. package/dist/serviceIds-RAVtP4nK.js +32 -0
  133. package/dist/serviceIds-RAVtP4nK.js.map +1 -0
  134. package/dist/storage/index.d.cts +2 -2
  135. package/dist/storage/index.d.ts +2 -2
  136. package/dist/storage/types.d.cts +2 -2
  137. package/dist/storage/types.d.ts +2 -2
  138. package/dist/syncActions/index.cjs +1 -1
  139. package/dist/syncActions/index.js +1 -1
  140. package/dist/{syncActions-DToUhyP3.cjs → syncActions-CR7xvuIv.cjs} +2 -2
  141. package/dist/{syncActions-DToUhyP3.cjs.map → syncActions-CR7xvuIv.cjs.map} +1 -1
  142. package/dist/{syncActions-DV_aObTQ.js → syncActions-CU4cIGRf.js} +2 -2
  143. package/dist/{syncActions-DV_aObTQ.js.map → syncActions-CU4cIGRf.js.map} +1 -1
  144. package/dist/{types-CLtYOszN.d.cts → types-B7FKoyfy.d.cts} +442 -2
  145. package/dist/{types-iU1Sc1IM.d.ts → types-BDgOF2WN.d.ts} +6 -29
  146. package/dist/types-BXKL0wTI.d.cts +85 -0
  147. package/dist/{types-Ey59ZILC.d.ts → types-COb2O9c1.d.ts} +442 -2
  148. package/dist/{types-DjWubjvP.d.cts → types-CaBcgsT2.d.cts} +121 -53
  149. package/dist/{types-BljDxuWG.d.cts → types-DCARsJWs.d.cts} +6 -29
  150. package/dist/{types-CsVRsObb.d.ts → types-DFcj9YyQ.d.ts} +121 -53
  151. package/dist/types-DK1bSUNr.d.ts +85 -0
  152. package/package.json +40 -1
  153. package/surface/management.md +5 -0
  154. package/surface/sdk.md +2 -0
  155. package/dist/admin-CbMOsfgs.js.map +0 -1
  156. package/dist/admin-Di-MmGFP.cjs.map +0 -1
  157. package/dist/management-CUXgB2rb.cjs.map +0 -1
  158. package/dist/management-Cz5ut18k.js.map +0 -1
  159. package/dist/oauth-CSBChWuf.cjs.map +0 -1
  160. package/dist/oauth-DOveZKUv.js.map +0 -1
  161. package/dist/sdk/queryService/index.cjs.map +0 -1
  162. package/dist/sdk/queryService/index.js.map +0 -1
  163. package/dist/semanticLayer-BdPW_wLo.js.map +0 -1
  164. package/dist/semanticLayer-djom-J78.cjs.map +0 -1
@@ -210,14 +210,15 @@ type paths = {
210
210
  * registration is usable):
211
211
  *
212
212
  * * Repository permissions: Contents → Read-only; Organization permissions: Members →
213
- * Read-only (the install callback needs it to confirm the installer owns the GitHub
213
+ * Read-only (the callback needs it to confirm the user connecting owns the GitHub
214
214
  * organization).
215
- * * "Where can this GitHub App be installed?" → Any account.
216
- * * **"Request user authorization (OAuth) during installation" must be enabled**, and the
217
- * App's Callback URL set to this service's
218
- * `/platform-consumers/github-app/callback`. Without it GitHub sends no `code` with the
219
- * install redirect, the callback cannot prove the installer owns the installation they
220
- * returned with, and every connection attempt fails there.
215
+ * * "Where can this GitHub App be installed?" → Any account, for an App that third parties
216
+ * install.
217
+ * * The App's Callback URL list must include this service's
218
+ * `/platform-consumers/github-app/callback`: connecting goes through the App's OAuth web
219
+ * flow with that URL as `redirect_uri`. "Request user authorization (OAuth) during
220
+ * installation" is not needed; when it is on, the redirect GitHub sends right after an
221
+ * install has no `state` and is answered with directions to connect from Keboola.
221
222
  * * `clientId` / `clientSecret` come from the same App's page ("Client ID", "Generate a new
222
223
  * client secret") — they are not the App ID and private key.
223
224
  *
@@ -265,10 +266,11 @@ type paths = {
265
266
  cookie?: never;
266
267
  };
267
268
  /**
268
- * GitHub App install callback
269
- * @description Invoked by GitHub, not by API consumers. This is the App's Callback URL, configured once on
270
- * the GitHub side and identical for every install, which is why it carries no organization
271
- * segment — the organization is recovered from the install session that `state` resolves to.
269
+ * GitHub App OAuth callback
270
+ * @description Invoked by GitHub, not by API consumers. This is one of the App's Callback URLs, configured
271
+ * once on the GitHub side and identical for every connection, which is why it carries no
272
+ * organization segment — the organization is recovered from the install session that `state`
273
+ * resolves to.
272
274
  *
273
275
  * It is the only endpoint that records an installation, and it requires no Keboola credential.
274
276
  * Three things authorise it, all of them necessary:
@@ -276,22 +278,29 @@ type paths = {
276
278
  * 1. `state` must match the `__Host-orgInstallSession` cookie set when the flow started (the
277
279
  * legacy `oauthSessionId` cookie is ignored here);
278
280
  * 2. `state` must resolve to an unexpired install session;
279
- * 3. the installing user must own the account the installation belongs to. GitHub, asked as
280
- * the App, says which account that is (`GET /app/installations/{id}`); asked with the
281
- * user-to-server token obtained from `code`, it says whether the installer is an active
282
- * owner of that organization (`GET /user/memberships/orgs/{login}` → `role: admin`,
283
- * `state: active`) or, for a personal account, that very user (`GET /user`). Being a
284
- * collaborator or an ordinary member is not enough.
281
+ * 3. the user who authorized (`code`, exchanged for a user-to-server token) must own the
282
+ * account the bound installation belongs to: an active owner of that organization
283
+ * (`GET /user/memberships/orgs/{login}` → `role: admin`, `state: active`) or, for a
284
+ * personal account, that very user (`GET /user`). Being a collaborator or an ordinary
285
+ * member is not enough. This is why the App needs "Organization members: read".
285
286
  *
286
- * Point 3 is why the App needs "Request user authorization (OAuth) during installation" and
287
- * the "Organization members: read" permission. Installation ids are small sequential
288
- * integers, so without that confirmation anyone able to start an install for an organization
289
- * they do administer could bind a stranger's installation and mint read tokens on that
290
- * stranger's private repositories.
287
+ * Which installation is bound:
291
288
  *
292
- * When the installer is not a GitHub organization owner, GitHub returns
293
- * `setup_action=request` with no installation id: the installation is pending an owner's
294
- * approval and nothing is recorded.
289
+ * * **OAuth web flow** (started by `POST /authorize/organizations/{organizationId}`; only
290
+ * `code` and `state` come back): the App's installations the user can reach
291
+ * (`GET /user/installations`, all pages), narrowed to the `account` given at the start if
292
+ * any, each run through check 3. Exactly one owned installation is connected. None
293
+ * installed is a `400` and none owned a `403`, both naming the App's install page
294
+ * `{webBaseUrl}/apps/{slug}/installations/new`; several owned without `account` is a `400`
295
+ * naming them — start again with `account`.
296
+ * * **No `state`** — GitHub's redirect after an install started on GitHub, for an App that
297
+ * requests user authorization during installation: a `400` saying the connection has to
298
+ * be started from Keboola. Nothing is asked of GitHub or recorded.
299
+ *
300
+ * Any `installation_id` GitHub adds to the query is ignored. Installation ids are small
301
+ * sequential integers: believing one would let anyone able to start a connection for an
302
+ * organization they do administer bind a stranger's installation and mint read tokens on
303
+ * that stranger's private repositories.
295
304
  *
296
305
  * An organization holds at most one connection per GitHub account and registration. When the
297
306
  * account is already connected under a *different* installation id — the App was
@@ -318,23 +327,30 @@ type paths = {
318
327
  put?: never;
319
328
  /**
320
329
  * Connect a GitHub organization
321
- * @description Starts the GitHub App install flow and redirects to GitHub.
330
+ * @description Starts connecting a GitHub organization and redirects to the GitHub App's OAuth web flow,
331
+ * `{webBaseUrl}/login/oauth/authorize?client_id=…&redirect_uri=…&state=…`, where
332
+ * `redirect_uri` is this service's `/platform-consumers/github-app/callback`. GitHub signs
333
+ * the user in, asks them to authorize the App the first time, and returns to the callback,
334
+ * which connects the installation the user owns (or the one on `account`). The App must
335
+ * already be installed on the GitHub organization — by anyone, from anywhere; the callback
336
+ * links the install page if it is not.
322
337
  *
323
- * Submitted by the browser as a form — a top-level navigation — exactly like
324
- * `POST /authorize/{componentId}`, with the caller's Storage API token in the `token` form
325
- * field, verified with Storage API by this service. The token may belong to any project the
326
- * caller can reach: it establishes only *who* the caller is. A token without an admin
327
- * (component or legacy token) is refused with `403`.
338
+ * Submitted by the browser as a form — a top-level navigation from the organization's page
339
+ * in the Control Panel — with the caller's Manage API token in the `manageToken` form field,
340
+ * verified by this service with `GET /manage/tokens/verify`. The token must have a user
341
+ * behind it: the Control Panel's session token or a personal Manage token. An application
342
+ * token is refused with `403`; a token Manage API does not know, or reports as expired or
343
+ * disabled, with `401`. Storage API tokens and programmatic `kbc_pat_*` tokens are not
344
+ * accepted. The token establishes only *who* the
345
+ * caller is, and it is never stored.
328
346
  *
329
347
  * The organization is taken from the URL and the caller must be an administrator of it — `GET /manage/organizations/{id}/users` is
330
348
  * Connection's organization administrators listing, so appearing in it is the admin check.
331
- * Deriving the organization from the token instead would be unsafe — users belong to projects
332
- * across several organizations and the project-to-organization link is invisible in the UI.
349
+ * Super admins who are not listed are refused.
333
350
  *
334
351
  * The credentials row is created incomplete and only becomes usable once the install
335
352
  * callback records the installation. Starting again under the name of an incomplete row (an
336
- * abandoned tab, or an install that became an owner-approval request) replaces that row and
337
- * its session; otherwise the `app:expire-auth-sessions` cron sweeps it after an hour. A name
353
+ * abandoned tab or a refused callback) replaces that row and its session; otherwise the `app:expire-auth-sessions` cron sweeps it after an hour. A name
338
354
  * already taken by a completed connection is a `409`.
339
355
  *
340
356
  * The response sets the session cookie `__Host-orgInstallSession` (Secure, HttpOnly,
@@ -366,7 +382,8 @@ type paths = {
366
382
  /**
367
383
  * List connected GitHub organizations
368
384
  * @description Lists the GitHub accounts this Keboola organization has connected. Connections whose
369
- * install never completed are omitted.
385
+ * install never completed are omitted. The caller must be an administrator of the
386
+ * organization; see `ManageApiUserToken` for the accepted tokens.
370
387
  */
371
388
  get: operations['organizationCredentialsList'];
372
389
  put?: never;
@@ -423,7 +440,8 @@ type paths = {
423
440
  /**
424
441
  * Disconnect a GitHub organization
425
442
  * @description Removes the connection on the Keboola side. The App stays installed on GitHub until an
426
- * owner removes it there.
443
+ * owner removes it there. The caller must be an administrator of the organization; see
444
+ * `ManageApiUserToken` for the accepted tokens.
427
445
  */
428
446
  delete: operations['organizationCredentialsDelete'];
429
447
  options?: never;
@@ -555,8 +573,8 @@ type components = {
555
573
  webHost?: string;
556
574
  };
557
575
  OrganizationCredentialsInitRequest: {
558
- /** @description Storage API token of the caller; identifies who they are */
559
- token: string;
576
+ /** @description Manage API token of the caller with a user behind it (the Control Panel's session token or a personal Manage token); identifies who they are */
577
+ manageToken: string;
560
578
  /**
561
579
  * @description Unique within the organization.
562
580
  * @example acme-github
@@ -564,7 +582,7 @@ type components = {
564
582
  name: string;
565
583
  /**
566
584
  * Format: url
567
- * @description Where GitHub returns the user after the install completes. Must be https.
585
+ * @description Where the browser returns after the connection completes. Must be https.
568
586
  */
569
587
  returnUrl: string;
570
588
  description?: string | null;
@@ -573,6 +591,11 @@ type components = {
573
591
  * @example acme.ghe.com
574
592
  */
575
593
  host?: string | null;
594
+ /**
595
+ * @description The GitHub account (organization or user login, case-insensitive) to connect. Needed only when the caller owns several accounts the GitHub App is installed on; omitted, the callback connects the only one.
596
+ * @example acme
597
+ */
598
+ account?: string | null;
576
599
  };
577
600
  OrganizationCredentials: {
578
601
  /** Format: uuid */
@@ -590,8 +613,22 @@ type components = {
590
613
  */
591
614
  host?: string;
592
615
  creator?: {
616
+ /** @description ID of the token the connection was started with. */
593
617
  id?: string;
618
+ /** @description Description of that token; for the Control Panel's session token, the user's email. */
594
619
  description?: string | null;
620
+ /**
621
+ * @description Which API the token belongs to. Connections are started with a Manage API token; `storage` marks connections started with a Storage API token before that.
622
+ * @enum {string}
623
+ */
624
+ type?: 'manage' | 'storage';
625
+ /** @description The user behind the Manage API token. A session token expires after about an hour, so this is what still says who connected the organization. Null for `storage`. */
626
+ user?: {
627
+ /** @example 76 */
628
+ id?: string;
629
+ /** @example admin@keboola.com */
630
+ email?: string | null;
631
+ } | null;
595
632
  };
596
633
  /** Format: date-time */
597
634
  created?: string;
@@ -1247,15 +1284,11 @@ interface operations {
1247
1284
  };
1248
1285
  platformConsumerInstallCallback: {
1249
1286
  parameters: {
1250
- query: {
1251
- /** @description GitHub installation ID. */
1252
- installation_id?: string;
1253
- /** @description Temporary user authorization code. Present only when the App has "Request user authorization (OAuth) during installation" enabled; the callback exchanges it for a user-to-server token and verifies installation ownership with it. */
1287
+ query?: {
1288
+ /** @description Temporary user authorization code; exchanged for a user-to-server token that identifies the user and verifies installation ownership. Missing when the user did not authorize the App (`error=access_denied`). */
1254
1289
  code?: string;
1255
- /** @description What GitHub did. `request` means an owner still has to approve. */
1256
- setup_action?: 'install' | 'request' | 'update';
1257
- /** @description Opaque install-session ID issued when the flow started. */
1258
- state: string;
1290
+ /** @description Opaque install-session ID issued when the flow started. Required; GitHub omits it on the redirect after an install started on GitHub, which is answered with a `400`. */
1291
+ state?: string;
1259
1292
  };
1260
1293
  header?: never;
1261
1294
  path?: never;
@@ -1270,8 +1303,16 @@ interface operations {
1270
1303
  };
1271
1304
  content?: never;
1272
1305
  };
1273
- 400: components['responses']['400_BadRequest'];
1274
- /** @description The installer is not an active owner of the GitHub organization (or not the personal account) the installation belongs to, or the App lacks "Organization members: read" */
1306
+ /** @description No `state` (the connection has to be started from Keboola); no matching session cookie or an expired session; no `code`, or GitHub rejected it; the App is not installed on any account the user can reach (or on the requested `account`) — the message links the install page; or the user owns several accounts with the App installed and no `account` was given — the message names them */
1307
+ 400: {
1308
+ headers: {
1309
+ [name: string]: unknown;
1310
+ };
1311
+ content: {
1312
+ 'application/json': components['schemas']['Error'];
1313
+ };
1314
+ };
1315
+ /** @description The user owns none of the accounts the App is installed on that they can reach (or not the requested `account`): neither an active owner of the organization nor the personal account itself. The message links the install page, or names an organization enforcing SAML SSO the user's GitHub session is not authorized for. Also when the App lacks "Organization members: read" */
1275
1316
  403: {
1276
1317
  headers: {
1277
1318
  [name: string]: unknown;
@@ -1289,6 +1330,24 @@ interface operations {
1289
1330
  'application/json': components['schemas']['Error'];
1290
1331
  };
1291
1332
  };
1333
+ /** @description GitHub is rate limiting requests; see `Retry-After` */
1334
+ 429: {
1335
+ headers: {
1336
+ [name: string]: unknown;
1337
+ };
1338
+ content: {
1339
+ 'application/json': components['schemas']['Error'];
1340
+ };
1341
+ };
1342
+ /** @description GitHub failed or returned a malformed answer */
1343
+ 502: {
1344
+ headers: {
1345
+ [name: string]: unknown;
1346
+ };
1347
+ content: {
1348
+ 'application/json': components['schemas']['Error'];
1349
+ };
1350
+ };
1292
1351
  };
1293
1352
  };
1294
1353
  organizationCredentialsInit: {
@@ -1307,7 +1366,7 @@ interface operations {
1307
1366
  };
1308
1367
  };
1309
1368
  responses: {
1310
- /** @description Redirect to GitHub to install the App */
1369
+ /** @description Redirect to the GitHub App's OAuth web flow (`/login/oauth/authorize`) */
1311
1370
  302: {
1312
1371
  headers: {
1313
1372
  [name: string]: unknown;
@@ -1315,6 +1374,7 @@ interface operations {
1315
1374
  content?: never;
1316
1375
  };
1317
1376
  400: components['responses']['400_BadRequest'];
1377
+ 401: components['responses']['401_Unauthorized'];
1318
1378
  403: components['responses']['403_Forbidden'];
1319
1379
  /** @description A completed connection with this name already exists in the organization */
1320
1380
  409: {
@@ -1526,5 +1586,13 @@ type CredentialInput = ComponentPath & {
1526
1586
  type CreateCredentialInput = ComponentPath & Omit<CreateCredentialBody, '#data'> & {
1527
1587
  data: Record<string, unknown>;
1528
1588
  };
1529
- export { CredentialInput as a, GetCredentialsInput as c, Credential as i, CreateCredentialBody as n, CredentialPath as o, CreateCredentialInput as r, OrganizationConnection as s, ComponentPath as t };
1530
- //# sourceMappingURL=types-CsVRsObb.d.ts.map
1589
+ type OrganizationCredentials = OpenapiReturnType<paths['/organizations/{organizationId}/credentials']['get']>[number];
1590
+ type ManageTokenInput = {
1591
+ /** A Manage API token with a user behind it, e.g. the Control Panel's session token. */
1592
+ manageToken: string;
1593
+ };
1594
+ type GetOrganizationCredentialsInput = OpenapiPathType<paths['/organizations/{organizationId}/credentials']['get']> & ManageTokenInput;
1595
+ type DeleteOrganizationCredentialsInput = OpenapiPathType<paths['/organizations/{organizationId}/credentials/{id}']['delete']> & ManageTokenInput;
1596
+ type GetOrganizationConnectFormInput = OpenapiPathType<paths['/authorize/organizations/{organizationId}']['post']> & OpenapiBodyType<paths['/authorize/organizations/{organizationId}']['post']>;
1597
+ export { CredentialInput as a, GetOrganizationConnectFormInput as c, OrganizationCredentials as d, GetCredentialsInput as f, Credential as i, GetOrganizationCredentialsInput as l, CreateCredentialBody as n, CredentialPath as o, CreateCredentialInput as r, DeleteOrganizationCredentialsInput as s, ComponentPath as t, OrganizationConnection as u };
1598
+ //# sourceMappingURL=types-DFcj9YyQ.d.ts.map
@@ -0,0 +1,85 @@
1
+ import { n as createMetastoreClient } from "./index-BVe4S2CK.js";
2
+ import { t as MetastoreObject } from "./metaObject-ClvW342q.js";
3
+ /**
4
+ * The metastore's row- and column-level security vocabulary, schema version 1.2.0.
5
+ *
6
+ * - Each list is the one place a value is added; the types in `./types` derive from it.
7
+ */
8
+ declare const SECURITY_POLICY_TYPES: readonly ['rls-policy', 'cls-policy'];
9
+ declare const POLICY_SQL_DIALECTS: readonly ['snowflake', 'bigquery'];
10
+ declare const RLS_COMPARISON_OPS: readonly ['eq', 'ne', 'gt', 'gte', 'lt', 'lte'];
11
+ declare const RLS_LIST_OPS: readonly ['in', 'not_in'];
12
+ declare const RLS_NULL_OPS: readonly ['is_null', 'is_not_null'];
13
+ type MetastoreClient = ReturnType<typeof createMetastoreClient>;
14
+ type SecurityPolicyType = (typeof SECURITY_POLICY_TYPES)[number];
15
+ type PolicyDialect = (typeof POLICY_SQL_DIALECTS)[number];
16
+ /** `{"$identity": "email"}`: the reading identity's email, bound as a query parameter. */
17
+ type RlsIdentityEmail = {
18
+ $identity: 'email';
19
+ };
20
+ /** `{"$identity": "groups"}`: the reading identity's IdP groups, bound as a list. */
21
+ type RlsIdentityGroups = {
22
+ $identity: 'groups';
23
+ };
24
+ type RlsLiteral = string | number | boolean | null;
25
+ type RlsCondition = {
26
+ true: true;
27
+ } | {
28
+ false: true;
29
+ } | {
30
+ and: RlsCondition[];
31
+ } | {
32
+ or: RlsCondition[];
33
+ } | {
34
+ column: string;
35
+ op: (typeof RLS_COMPARISON_OPS)[number];
36
+ value: RlsLiteral | RlsIdentityEmail;
37
+ } | {
38
+ column: string;
39
+ op: (typeof RLS_LIST_OPS)[number];
40
+ values: RlsLiteral[] | RlsIdentityGroups;
41
+ } | {
42
+ column: string;
43
+ op: (typeof RLS_NULL_OPS)[number];
44
+ };
45
+ /** One selector kind per rule: IdP `groups` or `<idp>|<sub>` `subjects`. `["*"]` is everyone. */
46
+ type PolicySelector = {
47
+ subjects: string[];
48
+ } | {
49
+ groups: string[];
50
+ };
51
+ type RlsRule = PolicySelector & {
52
+ condition: RlsCondition;
53
+ };
54
+ type ClsRule = PolicySelector & {
55
+ visible_columns: string[];
56
+ };
57
+ type RlsPolicyData = {
58
+ table: string;
59
+ dialect?: PolicyDialect;
60
+ rules: RlsRule[];
61
+ default?: RlsCondition;
62
+ };
63
+ type ClsPolicyData = {
64
+ table: string;
65
+ dialect?: PolicyDialect;
66
+ rules: ClsRule[];
67
+ };
68
+ type SecurityPolicyDataMap = {
69
+ 'rls-policy': RlsPolicyData;
70
+ 'cls-policy': ClsPolicyData;
71
+ };
72
+ /**
73
+ * What a read hands back.
74
+ *
75
+ * - Rules stay untyped: policies written under schema 1.0.0 or 1.1.0 (`principal`) list too.
76
+ */
77
+ type SecurityPolicyReadData = {
78
+ table: string;
79
+ dialect?: PolicyDialect;
80
+ rules: Record<string, unknown>[];
81
+ default?: unknown;
82
+ };
83
+ type SecurityPolicy = MetastoreObject<SecurityPolicyReadData>;
84
+ export { RLS_COMPARISON_OPS as _, PolicySelector as a, SECURITY_POLICY_TYPES as b, RlsIdentityGroups as c, RlsRule as d, SecurityPolicy as f, POLICY_SQL_DIALECTS as g, SecurityPolicyType as h, PolicyDialect as i, RlsLiteral as l, SecurityPolicyReadData as m, ClsRule as n, RlsCondition as o, SecurityPolicyDataMap as p, MetastoreClient as r, RlsIdentityEmail as s, ClsPolicyData as t, RlsPolicyData as u, RLS_LIST_OPS as v, RLS_NULL_OPS as y };
85
+ //# sourceMappingURL=types-DK1bSUNr.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keboola/api-client",
3
- "version": "52.0.0",
3
+ "version": "54.0.0",
4
4
  "description": "TypeScript SDK for Keboola APIs",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -200,6 +200,12 @@
200
200
  "sdk/semanticLayer/types": [
201
201
  "./dist/sdk/semanticLayer/types.d.ts"
202
202
  ],
203
+ "sdk/securityPolicy": [
204
+ "./dist/sdk/securityPolicy/index.d.ts"
205
+ ],
206
+ "sdk/securityPolicy/types": [
207
+ "./dist/sdk/securityPolicy/types.d.ts"
208
+ ],
203
209
  "sdk/kaiMemory": [
204
210
  "./dist/sdk/kaiMemory/index.d.ts"
205
211
  ],
@@ -218,6 +224,9 @@
218
224
  "sdk/configurations": [
219
225
  "./dist/sdk/configurations/index.d.ts"
220
226
  ],
227
+ "sdk/dataAppServer": [
228
+ "./dist/sdk/dataAppServer/index.d.ts"
229
+ ],
221
230
  "domain/permissions": [
222
231
  "./dist/domain/permissions/index.d.ts"
223
232
  ],
@@ -874,6 +883,26 @@
874
883
  "default": "./dist/sdk/semanticLayer/types.cjs"
875
884
  }
876
885
  },
886
+ "./sdk/securityPolicy": {
887
+ "import": {
888
+ "types": "./dist/sdk/securityPolicy/index.d.ts",
889
+ "default": "./dist/sdk/securityPolicy/index.js"
890
+ },
891
+ "require": {
892
+ "types": "./dist/sdk/securityPolicy/index.d.cts",
893
+ "default": "./dist/sdk/securityPolicy/index.cjs"
894
+ }
895
+ },
896
+ "./sdk/securityPolicy/types": {
897
+ "import": {
898
+ "types": "./dist/sdk/securityPolicy/types.d.ts",
899
+ "default": "./dist/sdk/securityPolicy/types.js"
900
+ },
901
+ "require": {
902
+ "types": "./dist/sdk/securityPolicy/types.d.cts",
903
+ "default": "./dist/sdk/securityPolicy/types.cjs"
904
+ }
905
+ },
877
906
  "./sdk/kaiMemory": {
878
907
  "import": {
879
908
  "types": "./dist/sdk/kaiMemory/index.d.ts",
@@ -934,6 +963,16 @@
934
963
  "default": "./dist/sdk/configurations/index.cjs"
935
964
  }
936
965
  },
966
+ "./sdk/dataAppServer": {
967
+ "import": {
968
+ "types": "./dist/sdk/dataAppServer/index.d.ts",
969
+ "default": "./dist/sdk/dataAppServer/index.js"
970
+ },
971
+ "require": {
972
+ "types": "./dist/sdk/dataAppServer/index.d.cts",
973
+ "default": "./dist/sdk/dataAppServer/index.cjs"
974
+ }
975
+ },
937
976
  "./domain/permissions": {
938
977
  "import": {
939
978
  "types": "./dist/domain/permissions/index.d.ts",
@@ -53,6 +53,7 @@ Part of the [`@keboola/api-client` surface index](../API-SURFACE.md).
53
53
  - `api.management.fileStorage.createFileStorageGcs(body: { gcsCredentials: { type: string; project_id: string; private_key_id: string; private_key: string; client_email: string; client_id: string; auth_uri: string; token_uri: string; auth_provider_x509_cert_url: string; client_x509_cert_url: string; }; filesBucket: string; owner: "client" | "keboola"; region: string; }): Promise<FileStorageGcs>`
54
54
  - `api.management.fileStorage.createFileStorageS3(body: { awsKey: string; awsSecret: string; filesBucket: string; owner: string; region: string; }): Promise<{ id: number; awsKey: string; region: string; filesBucket: string; provider: string; owner: string; isDefault: boolean; created: string; creator: { id: number | null; name: string | null; }; }>`
55
55
  - `api.management.fileStorage.deleteFileStorage(fileStorageId: number): Promise<void>`
56
+ - `api.management.fileStorage.getFileStorageProjects(fileStorageId: number, query?: { page?: { after?: string | undefined; limit?: number | undefined; } | undefined; } | undefined, signal?: AbortSignal | undefined): Promise<{ data: { id: number; name: string; isDeleted: boolean; }[]; meta: { total: number; limit: number; cursor: { param: string; encoding: string; fields: { name: string; type: "string" | "integer" | "date-time"; nullable: boolean; }[]; order: string; }; }; links: { self: string; first: string; next: string | null; }; }>`
56
57
  - `api.management.fileStorage.getFileStoragesAbs(signal?: AbortSignal | undefined): Promise<{ id: number; accountName: string; region: string; containerName: string; provider: string; owner: string; isDefault: boolean; created: string; creator: { id: number | null; name: string | null; }; }[]>`
57
58
  - `api.management.fileStorage.getFileStoragesGcs(signal?: AbortSignal | undefined): Promise<FileStorageGcs[]>`
58
59
  - `api.management.fileStorage.getFileStoragesS3(signal?: AbortSignal | undefined): Promise<{ id: number; awsKey: string; region: string; filesBucket: string; provider: string; owner: string; isDefault: boolean; created: string; creator: { id: number | null; name: string | null; }; }[]>`
@@ -169,6 +170,10 @@ Part of the [`@keboola/api-client` surface index](../API-SURFACE.md).
169
170
  - `api.management.projects.setProjectReviewers({ projectId, adminIds, }: SetProjectReviewersPath & SetProjectReviewersBody): Promise<void>`
170
171
  - `api.management.projects.updateProject({ projectId, ...body }: UpdateProjectInput): Promise<ProjectBase>`
171
172
 
173
+ ### `api.management.search`
174
+
175
+ - `api.management.search.find(query: { q: string; page?: { after?: string | undefined; limit?: number | undefined; } | undefined; filter?: { types?: string | undefined; } | undefined; }, signal?: AbortSignal | undefined): Promise<{ project?: { data: { rank: 0 | 1 | 2; id: number; name: string; organization: { id: number; name: string; }; isDisabled: boolean; }[]; meta: { total: number; limit: number; cursor: { param: string; encoding: string; fields: { name: string; type: "string" | "integer" | "date-time"; nullable: boolean; }[]; order: string; }; }; links: { self: string; first: string; next: string | null; }; } | undefined; organization?: { data: { rank: 0 | 1 | 2; id: number; name: string; maintainer: { id: number; name: string | null; }; }[]; meta: { total: number; limit: number; cursor: { param: string; encoding: string; fields: { name: string; type: "string" | "integer" | "date-time"; nullable: boolean; }[]; order: string; }; }; links: { self: string; first: string; next: string | null; }; } | undefined; maintainer?: { data: { rank: 0 | 1 | 2; id: number; name: string | null; }[]; meta: { total: number; limit: number; cursor: { param: string; encoding: string; fields: { name: string; type: "string" | "integer" | "date-time"; nullable: boolean; }[]; order: string; }; }; links: { self: string; first: string; next: string | null; }; } | undefined; user?: { data: { rank: 0 | 1 | 2; id: number; name: string; email: string; }[]; meta: { total: number; limit: number; cursor: { param: string; encoding: string; fields: { name: string; type: "string" | "integer" | "date-time"; nullable: boolean; }[]; order: string; }; }; links: { self: string; first: string; next: string | null; }; } | undefined; }>`
176
+
172
177
  ### `api.management.snowflakePartnerConnect`
173
178
 
174
179
  - `api.management.snowflakePartnerConnect.check(projectId: number, signal?: AbortSignal | undefined): Promise<{ testPassed: boolean; queriesToRun: string[]; }>`
package/surface/sdk.md CHANGED
@@ -25,6 +25,8 @@ Part of the [`@keboola/api-client` surface index](../API-SURFACE.md).
25
25
  - `api.sdk.semanticLayer.deleteObject(objectType: keyof SemanticChildObjectDataMap, objectUUID: string): Promise<void>`
26
26
  - `api.sdk.semanticLayer.findObjectsByName<T extends SemanticChildObjectType>(objectType: T, name: string, modelUUID: string, signal?: AbortSignal | undefined): Promise<SemanticObject<SemanticChildObjectDataMap[T]>[]>`
27
27
  - `api.sdk.semanticLayer.getModel(modelUUID: string, signal?: AbortSignal | undefined): Promise<SemanticObject<SemanticModelData>>`
28
+ - `api.sdk.semanticLayer.listAllObjects<T extends SemanticChildObjectType>(objectType: T, signal?: AbortSignal | undefined): Promise<SemanticObject<SemanticChildObjectDataMap[T]>[]>`
29
+ - `api.sdk.semanticLayer.listAllObjectsWithUnreadable<T extends SemanticChildObjectType>(objectType: T, signal?: AbortSignal | undefined): Promise<{ objects: SemanticObject<SemanticChildObjectDataMap[T]>[]; unreadable: SemanticUnreadableObjectRef[]; }>`
28
30
  - `api.sdk.semanticLayer.listModelChildren(modelUUID: string, signal?: AbortSignal | undefined): Promise<SemanticModelChildRef[]>`
29
31
  - `api.sdk.semanticLayer.listModels(signal?: AbortSignal | undefined): Promise<SemanticObject<SemanticModelData>[]>`
30
32
  - `api.sdk.semanticLayer.listMyPendingScopeElevationRequests(objectType: SemanticObjectType, signal?: AbortSignal | undefined): Promise<SemanticObject<Record<string, unknown>>[]>`
@@ -1 +0,0 @@
1
- {"version":3,"file":"admin-CbMOsfgs.js","names":[],"sources":["../src/domain/permissions/errors.ts","../src/domain/permissions/admin.ts"],"sourcesContent":["/**\n * @module domain/permissions/errors\n *\n * - What every `assertCan*` throws; its public fields are SDK contract — renames break consumers.\n * - `subject` is a debugging hint only — never a `StorageToken`, raw token or secret.\n */\nexport class PermissionDeniedError extends Error {\n public readonly action: string;\n public readonly reason?: string;\n public readonly subject?: string;\n\n constructor({ action, reason, subject }: { action: string; reason?: string; subject?: string }) {\n super(reason ? `Permission denied: ${action} (${reason})` : `Permission denied: ${action}`);\n this.name = 'PermissionDeniedError';\n this.action = action;\n this.reason = reason;\n this.subject = subject;\n }\n}\n","/**\n * @module domain/permissions/admin\n *\n * Admin-role predicates read from `token.admin.role` alone.\n */\nimport type { StorageToken } from '../../clients/storage/tokens/types';\nimport { AdminRole } from '../../constants/adminRoles';\n\nimport { PermissionDeniedError } from './errors';\n\nconst role = (token: StorageToken): AdminRole | null => token.admin.role;\n\nexport const isAdmin = (token: StorageToken): boolean => role(token) === AdminRole.Admin;\n\nexport const isAdminOrShare = (token: StorageToken): boolean =>\n role(token) === AdminRole.Admin || role(token) === AdminRole.Share;\n\nexport const isProductionManager = (token: StorageToken): boolean =>\n role(token) === AdminRole.ProductionManager;\n\nexport const isDeveloperOrReviewer = (token: StorageToken): boolean =>\n role(token) === AdminRole.Developer || role(token) === AdminRole.Reviewer;\n\nexport const isReadOnlyRole = (token: StorageToken): boolean => role(token) === AdminRole.ReadOnly;\n\n/**\n * Whether a role string is a member of `AdminRole` at all.\n *\n * - Failing it means *unrecognized*, not denied — log it loudly.\n */\nexport const isKnownAdminRole = (adminRole: string | null | undefined): boolean =>\n (Object.values(AdminRole) as string[]).includes(adminRole ?? '');\n\n/**\n * Whether an admin role may write Kai's project-wide settings.\n *\n * - `admin` and `share` only: a shared prompt-injection surface is project administration.\n * - `developer`/`reviewer` are denied: `agent_settings` is keyed by `project_id` alone, so a dev-branch edit hits production.\n * - An allowlist, so new upstream `AdminRole` members are denied by default.\n * - Spend caps use `./organization#canWriteKaiSpendCaps`; don't widen this for them.\n */\nexport const isKaiSettingsWriterRole = (adminRole: string | null | undefined): boolean => {\n switch (adminRole) {\n case AdminRole.Admin:\n case AdminRole.Share:\n return true;\n default:\n return false;\n }\n};\n\n/**\n * Whether this token may write Kai's project-wide settings.\n *\n * - A limited (non-master) token never may; its `admin` block is absent despite the type.\n */\nexport const canWriteKaiSettings = (token: StorageToken): boolean =>\n token.isMasterToken && isKaiSettingsWriterRole(token.admin?.role);\n\nexport const assertCanWriteKaiSettings = (token: StorageToken): void => {\n if (!canWriteKaiSettings(token)) {\n throw new PermissionDeniedError({\n action: 'write-kai-settings',\n reason: token.isMasterToken\n ? `role '${token.admin?.role ?? 'none'}' may not write Kai settings`\n : 'a limited (non-master) token may not write Kai settings',\n });\n }\n};\n\n/**\n * Whether this token may write the project's semantic layer in the metastore.\n *\n * - Mirrors the metastore's role mapping (go-monorepo `services/metastore/internal/authz`):\n * only a master token with the `admin`, `productionManager` or `share` role gets `project-admin`.\n * - Every other role, and a limited token (no `admin` block), gets a 403.\n * - Organization-scope promotion is left to the metastore's 403.\n */\nexport const canWriteSemanticLayer = (token: StorageToken): boolean =>\n token.admin?.role === AdminRole.Admin ||\n token.admin?.role === AdminRole.ProductionManager ||\n token.admin?.role === AdminRole.Share;\n\nexport const assertCanAdmin = (token: StorageToken): void => {\n if (!isAdmin(token)) {\n throw new PermissionDeniedError({\n action: 'admin',\n reason: `role '${role(token)}' is not admin`,\n });\n }\n};\n\nexport const assertCanAdminOrShare = (token: StorageToken): void => {\n if (!isAdminOrShare(token)) {\n throw new PermissionDeniedError({\n action: 'admin-or-share',\n reason: `role '${role(token)}' is not admin or share`,\n });\n }\n};\n\nexport const assertCanProductionManage = (token: StorageToken): void => {\n if (!isProductionManager(token)) {\n throw new PermissionDeniedError({\n action: 'production-manage',\n reason: `role '${role(token)}' is not productionManager`,\n });\n }\n};\n\nexport const assertCanDevelopOrReview = (token: StorageToken): void => {\n if (!isDeveloperOrReviewer(token)) {\n throw new PermissionDeniedError({\n action: 'develop-or-review',\n reason: `role '${role(token)}' is not developer or reviewer`,\n });\n }\n};\n"],"mappings":";;;;;;;;AAMA,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CACA;CACA;CAEA,YAAY,EAAE,QAAQ,QAAQ,WAAkE;EAC9F,MAAM,SAAS,sBAAsB,OAAO,IAAI,OAAO,KAAK,sBAAsB,QAAQ;EAC1F,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,UAAU;CACjB;AACF;;ACRA,MAAM,QAAQ,UAA0C,MAAM,MAAM;AAEpE,MAAa,WAAW,UAAiC,KAAK,KAAK,MAAM,UAAU;AAEnF,MAAa,kBAAkB,UAC7B,KAAK,KAAK,MAAM,UAAU,SAAS,KAAK,KAAK,MAAM,UAAU;AAE/D,MAAa,uBAAuB,UAClC,KAAK,KAAK,MAAM,UAAU;AAE5B,MAAa,yBAAyB,UACpC,KAAK,KAAK,MAAM,UAAU,aAAa,KAAK,KAAK,MAAM,UAAU;AAEnE,MAAa,kBAAkB,UAAiC,KAAK,KAAK,MAAM,UAAU;;;;;;AAO1F,MAAa,oBAAoB,cAC9B,OAAO,OAAO,SAAS,CAAC,CAAc,SAAS,aAAa,EAAE;;;;;;;;;AAUjE,MAAa,2BAA2B,cAAkD;CACxF,QAAQ,WAAR;EACE,KAAK,UAAU;EACf,KAAK,UAAU,OACb,OAAO;EACT,SACE,OAAO;CACX;AACF;;;;;;AAOA,MAAa,uBAAuB,UAClC,MAAM,iBAAiB,wBAAwB,MAAM,OAAO,IAAI;AAElE,MAAa,6BAA6B,UAA8B;CACtE,IAAI,CAAC,oBAAoB,KAAK,GAC5B,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,MAAM,gBACV,SAAS,MAAM,OAAO,QAAQ,OAAO,gCACrC;CACN,CAAC;AAEL;;;;;;;;;AAUA,MAAa,yBAAyB,UACpC,MAAM,OAAO,SAAS,UAAU,SAChC,MAAM,OAAO,SAAS,UAAU,qBAChC,MAAM,OAAO,SAAS,UAAU;AAElC,MAAa,kBAAkB,UAA8B;CAC3D,IAAI,CAAC,QAAQ,KAAK,GAChB,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL;AAEA,MAAa,yBAAyB,UAA8B;CAClE,IAAI,CAAC,eAAe,KAAK,GACvB,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL;AAEA,MAAa,6BAA6B,UAA8B;CACtE,IAAI,CAAC,oBAAoB,KAAK,GAC5B,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL;AAEA,MAAa,4BAA4B,UAA8B;CACrE,IAAI,CAAC,sBAAsB,KAAK,GAC9B,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"admin-Di-MmGFP.cjs","names":["AdminRole"],"sources":["../src/domain/permissions/errors.ts","../src/domain/permissions/admin.ts"],"sourcesContent":["/**\n * @module domain/permissions/errors\n *\n * - What every `assertCan*` throws; its public fields are SDK contract — renames break consumers.\n * - `subject` is a debugging hint only — never a `StorageToken`, raw token or secret.\n */\nexport class PermissionDeniedError extends Error {\n public readonly action: string;\n public readonly reason?: string;\n public readonly subject?: string;\n\n constructor({ action, reason, subject }: { action: string; reason?: string; subject?: string }) {\n super(reason ? `Permission denied: ${action} (${reason})` : `Permission denied: ${action}`);\n this.name = 'PermissionDeniedError';\n this.action = action;\n this.reason = reason;\n this.subject = subject;\n }\n}\n","/**\n * @module domain/permissions/admin\n *\n * Admin-role predicates read from `token.admin.role` alone.\n */\nimport type { StorageToken } from '../../clients/storage/tokens/types';\nimport { AdminRole } from '../../constants/adminRoles';\n\nimport { PermissionDeniedError } from './errors';\n\nconst role = (token: StorageToken): AdminRole | null => token.admin.role;\n\nexport const isAdmin = (token: StorageToken): boolean => role(token) === AdminRole.Admin;\n\nexport const isAdminOrShare = (token: StorageToken): boolean =>\n role(token) === AdminRole.Admin || role(token) === AdminRole.Share;\n\nexport const isProductionManager = (token: StorageToken): boolean =>\n role(token) === AdminRole.ProductionManager;\n\nexport const isDeveloperOrReviewer = (token: StorageToken): boolean =>\n role(token) === AdminRole.Developer || role(token) === AdminRole.Reviewer;\n\nexport const isReadOnlyRole = (token: StorageToken): boolean => role(token) === AdminRole.ReadOnly;\n\n/**\n * Whether a role string is a member of `AdminRole` at all.\n *\n * - Failing it means *unrecognized*, not denied — log it loudly.\n */\nexport const isKnownAdminRole = (adminRole: string | null | undefined): boolean =>\n (Object.values(AdminRole) as string[]).includes(adminRole ?? '');\n\n/**\n * Whether an admin role may write Kai's project-wide settings.\n *\n * - `admin` and `share` only: a shared prompt-injection surface is project administration.\n * - `developer`/`reviewer` are denied: `agent_settings` is keyed by `project_id` alone, so a dev-branch edit hits production.\n * - An allowlist, so new upstream `AdminRole` members are denied by default.\n * - Spend caps use `./organization#canWriteKaiSpendCaps`; don't widen this for them.\n */\nexport const isKaiSettingsWriterRole = (adminRole: string | null | undefined): boolean => {\n switch (adminRole) {\n case AdminRole.Admin:\n case AdminRole.Share:\n return true;\n default:\n return false;\n }\n};\n\n/**\n * Whether this token may write Kai's project-wide settings.\n *\n * - A limited (non-master) token never may; its `admin` block is absent despite the type.\n */\nexport const canWriteKaiSettings = (token: StorageToken): boolean =>\n token.isMasterToken && isKaiSettingsWriterRole(token.admin?.role);\n\nexport const assertCanWriteKaiSettings = (token: StorageToken): void => {\n if (!canWriteKaiSettings(token)) {\n throw new PermissionDeniedError({\n action: 'write-kai-settings',\n reason: token.isMasterToken\n ? `role '${token.admin?.role ?? 'none'}' may not write Kai settings`\n : 'a limited (non-master) token may not write Kai settings',\n });\n }\n};\n\n/**\n * Whether this token may write the project's semantic layer in the metastore.\n *\n * - Mirrors the metastore's role mapping (go-monorepo `services/metastore/internal/authz`):\n * only a master token with the `admin`, `productionManager` or `share` role gets `project-admin`.\n * - Every other role, and a limited token (no `admin` block), gets a 403.\n * - Organization-scope promotion is left to the metastore's 403.\n */\nexport const canWriteSemanticLayer = (token: StorageToken): boolean =>\n token.admin?.role === AdminRole.Admin ||\n token.admin?.role === AdminRole.ProductionManager ||\n token.admin?.role === AdminRole.Share;\n\nexport const assertCanAdmin = (token: StorageToken): void => {\n if (!isAdmin(token)) {\n throw new PermissionDeniedError({\n action: 'admin',\n reason: `role '${role(token)}' is not admin`,\n });\n }\n};\n\nexport const assertCanAdminOrShare = (token: StorageToken): void => {\n if (!isAdminOrShare(token)) {\n throw new PermissionDeniedError({\n action: 'admin-or-share',\n reason: `role '${role(token)}' is not admin or share`,\n });\n }\n};\n\nexport const assertCanProductionManage = (token: StorageToken): void => {\n if (!isProductionManager(token)) {\n throw new PermissionDeniedError({\n action: 'production-manage',\n reason: `role '${role(token)}' is not productionManager`,\n });\n }\n};\n\nexport const assertCanDevelopOrReview = (token: StorageToken): void => {\n if (!isDeveloperOrReviewer(token)) {\n throw new PermissionDeniedError({\n action: 'develop-or-review',\n reason: `role '${role(token)}' is not developer or reviewer`,\n });\n }\n};\n"],"mappings":";;;;;;;;AAMA,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CACA;CACA;CAEA,YAAY,EAAE,QAAQ,QAAQ,WAAkE;EAC9F,MAAM,SAAS,sBAAsB,OAAO,IAAI,OAAO,KAAK,sBAAsB,QAAQ;EAC1F,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,UAAU;CACjB;AACF;;ACRA,MAAM,QAAQ,UAA0C,MAAM,MAAM;AAEpE,MAAa,WAAW,UAAiC,KAAK,KAAK,MAAMA,mBAAAA,UAAU;AAEnF,MAAa,kBAAkB,UAC7B,KAAK,KAAK,MAAMA,mBAAAA,UAAU,SAAS,KAAK,KAAK,MAAMA,mBAAAA,UAAU;AAE/D,MAAa,uBAAuB,UAClC,KAAK,KAAK,MAAMA,mBAAAA,UAAU;AAE5B,MAAa,yBAAyB,UACpC,KAAK,KAAK,MAAMA,mBAAAA,UAAU,aAAa,KAAK,KAAK,MAAMA,mBAAAA,UAAU;AAEnE,MAAa,kBAAkB,UAAiC,KAAK,KAAK,MAAMA,mBAAAA,UAAU;;;;;;AAO1F,MAAa,oBAAoB,cAC9B,OAAO,OAAOA,mBAAAA,SAAS,CAAC,CAAc,SAAS,aAAa,EAAE;;;;;;;;;AAUjE,MAAa,2BAA2B,cAAkD;CACxF,QAAQ,WAAR;EACE,KAAKA,mBAAAA,UAAU;EACf,KAAKA,mBAAAA,UAAU,OACb,OAAO;EACT,SACE,OAAO;CACX;AACF;;;;;;AAOA,MAAa,uBAAuB,UAClC,MAAM,iBAAiB,wBAAwB,MAAM,OAAO,IAAI;AAElE,MAAa,6BAA6B,UAA8B;CACtE,IAAI,CAAC,oBAAoB,KAAK,GAC5B,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,MAAM,gBACV,SAAS,MAAM,OAAO,QAAQ,OAAO,gCACrC;CACN,CAAC;AAEL;;;;;;;;;AAUA,MAAa,yBAAyB,UACpC,MAAM,OAAO,SAASA,mBAAAA,UAAU,SAChC,MAAM,OAAO,SAASA,mBAAAA,UAAU,qBAChC,MAAM,OAAO,SAASA,mBAAAA,UAAU;AAElC,MAAa,kBAAkB,UAA8B;CAC3D,IAAI,CAAC,QAAQ,KAAK,GAChB,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL;AAEA,MAAa,yBAAyB,UAA8B;CAClE,IAAI,CAAC,eAAe,KAAK,GACvB,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL;AAEA,MAAa,6BAA6B,UAA8B;CACtE,IAAI,CAAC,oBAAoB,KAAK,GAC5B,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL;AAEA,MAAa,4BAA4B,UAA8B;CACrE,IAAI,CAAC,sBAAsB,KAAK,GAC9B,MAAM,IAAI,sBAAsB;EAC9B,QAAQ;EACR,QAAQ,SAAS,KAAK,KAAK,EAAE;CAC/B,CAAC;AAEL"}