@homeflare/alchemy 0.43.0 → 0.45.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 (612) hide show
  1. package/README.md +10 -1
  2. package/dist/caddy/index.js +35 -1
  3. package/dist/caddy/index.js.map +3 -3
  4. package/dist/launchd/index.js +35 -1
  5. package/dist/launchd/index.js.map +3 -3
  6. package/dist/linux/index.js +35 -1
  7. package/dist/linux/index.js.map +3 -3
  8. package/dist/litellm/access-group-form.d.ts +26 -0
  9. package/dist/litellm/access-group-form.d.ts.map +1 -0
  10. package/dist/litellm/access-group-operations.d.ts +37 -0
  11. package/dist/litellm/access-group-operations.d.ts.map +1 -0
  12. package/dist/litellm/access-group-types.d.ts +49 -0
  13. package/dist/litellm/access-group-types.d.ts.map +1 -0
  14. package/dist/litellm/access-group.d.ts +55 -0
  15. package/dist/litellm/access-group.d.ts.map +1 -0
  16. package/dist/litellm/credential-errors.d.ts +131 -0
  17. package/dist/litellm/credential-errors.d.ts.map +1 -0
  18. package/dist/litellm/credential-form.d.ts +79 -0
  19. package/dist/litellm/credential-form.d.ts.map +1 -0
  20. package/dist/litellm/credential-operations.d.ts +84 -0
  21. package/dist/litellm/credential-operations.d.ts.map +1 -0
  22. package/dist/litellm/credential-rewrite.d.ts +6 -0
  23. package/dist/litellm/credential-rewrite.d.ts.map +1 -0
  24. package/dist/litellm/credential-types.d.ts +87 -0
  25. package/dist/litellm/credential-types.d.ts.map +1 -0
  26. package/dist/litellm/credential-values.d.ts +53 -0
  27. package/dist/litellm/credential-values.d.ts.map +1 -0
  28. package/dist/litellm/credential.d.ts +83 -0
  29. package/dist/litellm/credential.d.ts.map +1 -0
  30. package/dist/litellm/fake-access-group-litellm.d.ts +34 -0
  31. package/dist/litellm/fake-access-group-litellm.d.ts.map +1 -0
  32. package/dist/litellm/fake-credential-litellm.d.ts +54 -0
  33. package/dist/litellm/fake-credential-litellm.d.ts.map +1 -0
  34. package/dist/litellm/fake-keys.d.ts +53 -0
  35. package/dist/litellm/fake-keys.d.ts.map +1 -0
  36. package/dist/litellm/fake-litellm.d.ts +4 -1
  37. package/dist/litellm/fake-litellm.d.ts.map +1 -1
  38. package/dist/litellm/fake-mcp-litellm.d.ts +67 -0
  39. package/dist/litellm/fake-mcp-litellm.d.ts.map +1 -0
  40. package/dist/litellm/fake-model-litellm-post-update.d.ts +49 -0
  41. package/dist/litellm/fake-model-litellm-post-update.d.ts.map +1 -0
  42. package/dist/litellm/fake-model-litellm.d.ts +48 -0
  43. package/dist/litellm/fake-model-litellm.d.ts.map +1 -0
  44. package/dist/litellm/fake-policy-attachment-litellm.d.ts +33 -0
  45. package/dist/litellm/fake-policy-attachment-litellm.d.ts.map +1 -0
  46. package/dist/litellm/fake-policy-litellm.d.ts +32 -0
  47. package/dist/litellm/fake-policy-litellm.d.ts.map +1 -0
  48. package/dist/litellm/fake-registry-base.d.ts +42 -0
  49. package/dist/litellm/fake-registry-base.d.ts.map +1 -0
  50. package/dist/litellm/fake-stack.d.ts +8 -1
  51. package/dist/litellm/fake-stack.d.ts.map +1 -1
  52. package/dist/litellm/fake-team-litellm.d.ts +47 -0
  53. package/dist/litellm/fake-team-litellm.d.ts.map +1 -0
  54. package/dist/litellm/fake-tool-litellm.d.ts +28 -0
  55. package/dist/litellm/fake-tool-litellm.d.ts.map +1 -0
  56. package/dist/litellm/fake-toolset-litellm.d.ts +29 -0
  57. package/dist/litellm/fake-toolset-litellm.d.ts.map +1 -0
  58. package/dist/litellm/index.d.ts +18 -0
  59. package/dist/litellm/index.d.ts.map +1 -1
  60. package/dist/litellm/index.js +3078 -2
  61. package/dist/litellm/index.js.map +65 -4
  62. package/dist/litellm/key-errors.d.ts +169 -0
  63. package/dist/litellm/key-errors.d.ts.map +1 -0
  64. package/dist/litellm/key-form.d.ts +119 -0
  65. package/dist/litellm/key-form.d.ts.map +1 -0
  66. package/dist/litellm/key-harness.d.ts +41 -0
  67. package/dist/litellm/key-harness.d.ts.map +1 -0
  68. package/dist/litellm/key-metadata-errors.d.ts +30 -0
  69. package/dist/litellm/key-metadata-errors.d.ts.map +1 -0
  70. package/dist/litellm/key-metadata.d.ts +22 -0
  71. package/dist/litellm/key-metadata.d.ts.map +1 -0
  72. package/dist/litellm/key-operations.d.ts +63 -0
  73. package/dist/litellm/key-operations.d.ts.map +1 -0
  74. package/dist/litellm/key-secret.d.ts +33 -0
  75. package/dist/litellm/key-secret.d.ts.map +1 -0
  76. package/dist/litellm/key.d.ts +78 -0
  77. package/dist/litellm/key.d.ts.map +1 -0
  78. package/dist/litellm/mcp-server-credential.d.ts +50 -0
  79. package/dist/litellm/mcp-server-credential.d.ts.map +1 -0
  80. package/dist/litellm/mcp-server-errors.d.ts +101 -0
  81. package/dist/litellm/mcp-server-errors.d.ts.map +1 -0
  82. package/dist/litellm/mcp-server-form.d.ts +56 -0
  83. package/dist/litellm/mcp-server-form.d.ts.map +1 -0
  84. package/dist/litellm/mcp-server-locate.d.ts +26 -0
  85. package/dist/litellm/mcp-server-locate.d.ts.map +1 -0
  86. package/dist/litellm/mcp-server-operations.d.ts +63 -0
  87. package/dist/litellm/mcp-server-operations.d.ts.map +1 -0
  88. package/dist/litellm/mcp-server-shadow.d.ts +24 -0
  89. package/dist/litellm/mcp-server-shadow.d.ts.map +1 -0
  90. package/dist/litellm/mcp-server-types.d.ts +118 -0
  91. package/dist/litellm/mcp-server-types.d.ts.map +1 -0
  92. package/dist/litellm/mcp-server-url.d.ts +11 -0
  93. package/dist/litellm/mcp-server-url.d.ts.map +1 -0
  94. package/dist/litellm/mcp-server.d.ts +95 -0
  95. package/dist/litellm/mcp-server.d.ts.map +1 -0
  96. package/dist/litellm/model-claim.d.ts +24 -0
  97. package/dist/litellm/model-claim.d.ts.map +1 -0
  98. package/dist/litellm/model-credential.d.ts +12 -0
  99. package/dist/litellm/model-credential.d.ts.map +1 -0
  100. package/dist/litellm/model-errors.d.ts +119 -0
  101. package/dist/litellm/model-errors.d.ts.map +1 -0
  102. package/dist/litellm/model-form.d.ts +78 -0
  103. package/dist/litellm/model-form.d.ts.map +1 -0
  104. package/dist/litellm/model-locate.d.ts +13 -0
  105. package/dist/litellm/model-locate.d.ts.map +1 -0
  106. package/dist/litellm/model-operations.d.ts +59 -0
  107. package/dist/litellm/model-operations.d.ts.map +1 -0
  108. package/dist/litellm/model-types.d.ts +91 -0
  109. package/dist/litellm/model-types.d.ts.map +1 -0
  110. package/dist/litellm/model.d.ts +88 -0
  111. package/dist/litellm/model.d.ts.map +1 -0
  112. package/dist/litellm/policy-attachment-form.d.ts +19 -0
  113. package/dist/litellm/policy-attachment-form.d.ts.map +1 -0
  114. package/dist/litellm/policy-attachment-operations.d.ts +31 -0
  115. package/dist/litellm/policy-attachment-operations.d.ts.map +1 -0
  116. package/dist/litellm/policy-attachment-types.d.ts +48 -0
  117. package/dist/litellm/policy-attachment-types.d.ts.map +1 -0
  118. package/dist/litellm/policy-attachment.d.ts +61 -0
  119. package/dist/litellm/policy-attachment.d.ts.map +1 -0
  120. package/dist/litellm/policy-form.d.ts +22 -0
  121. package/dist/litellm/policy-form.d.ts.map +1 -0
  122. package/dist/litellm/policy-operations.d.ts +42 -0
  123. package/dist/litellm/policy-operations.d.ts.map +1 -0
  124. package/dist/litellm/policy-types.d.ts +57 -0
  125. package/dist/litellm/policy-types.d.ts.map +1 -0
  126. package/dist/litellm/policy.d.ts +65 -0
  127. package/dist/litellm/policy.d.ts.map +1 -0
  128. package/dist/litellm/providers.d.ts +1 -1
  129. package/dist/litellm/providers.d.ts.map +1 -1
  130. package/dist/litellm/registry-errors.d.ts +62 -0
  131. package/dist/litellm/registry-errors.d.ts.map +1 -0
  132. package/dist/litellm/registry-support.d.ts +42 -0
  133. package/dist/litellm/registry-support.d.ts.map +1 -0
  134. package/dist/litellm/team-form.d.ts +26 -0
  135. package/dist/litellm/team-form.d.ts.map +1 -0
  136. package/dist/litellm/team-members.d.ts +10 -0
  137. package/dist/litellm/team-members.d.ts.map +1 -0
  138. package/dist/litellm/team-operations.d.ts +38 -0
  139. package/dist/litellm/team-operations.d.ts.map +1 -0
  140. package/dist/litellm/team-permission.d.ts +35 -0
  141. package/dist/litellm/team-permission.d.ts.map +1 -0
  142. package/dist/litellm/team-types.d.ts +101 -0
  143. package/dist/litellm/team-types.d.ts.map +1 -0
  144. package/dist/litellm/team.d.ts +67 -0
  145. package/dist/litellm/team.d.ts.map +1 -0
  146. package/dist/litellm/tool-policy-form.d.ts +21 -0
  147. package/dist/litellm/tool-policy-form.d.ts.map +1 -0
  148. package/dist/litellm/tool-policy-operations.d.ts +30 -0
  149. package/dist/litellm/tool-policy-operations.d.ts.map +1 -0
  150. package/dist/litellm/tool-policy-types.d.ts +46 -0
  151. package/dist/litellm/tool-policy-types.d.ts.map +1 -0
  152. package/dist/litellm/tool-policy.d.ts +62 -0
  153. package/dist/litellm/tool-policy.d.ts.map +1 -0
  154. package/dist/litellm/toolset-form.d.ts +20 -0
  155. package/dist/litellm/toolset-form.d.ts.map +1 -0
  156. package/dist/litellm/toolset-operations.d.ts +39 -0
  157. package/dist/litellm/toolset-operations.d.ts.map +1 -0
  158. package/dist/litellm/toolset-types.d.ts +46 -0
  159. package/dist/litellm/toolset-types.d.ts.map +1 -0
  160. package/dist/litellm/toolset.d.ts +55 -0
  161. package/dist/litellm/toolset.d.ts.map +1 -0
  162. package/dist/openbao/index.js +35 -1
  163. package/dist/openbao/index.js.map +3 -3
  164. package/dist/ownership/rows.d.ts +11 -0
  165. package/dist/ownership/rows.d.ts.map +1 -1
  166. package/dist/postgres/connection.d.ts +14 -2
  167. package/dist/postgres/connection.d.ts.map +1 -1
  168. package/dist/postgres/database-sql.d.ts +27 -8
  169. package/dist/postgres/database-sql.d.ts.map +1 -1
  170. package/dist/postgres/fake-grants-parse.d.ts +37 -0
  171. package/dist/postgres/fake-grants-parse.d.ts.map +1 -0
  172. package/dist/postgres/fake-grants-read.d.ts +61 -0
  173. package/dist/postgres/fake-grants-read.d.ts.map +1 -0
  174. package/dist/postgres/fake-grants-sql.d.ts +46 -0
  175. package/dist/postgres/fake-grants-sql.d.ts.map +1 -0
  176. package/dist/postgres/fake-grants-write.d.ts +29 -0
  177. package/dist/postgres/fake-grants-write.d.ts.map +1 -0
  178. package/dist/postgres/fake-role-sql.d.ts +41 -0
  179. package/dist/postgres/fake-role-sql.d.ts.map +1 -0
  180. package/dist/postgres/fake-schema-sql.d.ts +42 -0
  181. package/dist/postgres/fake-schema-sql.d.ts.map +1 -0
  182. package/dist/postgres/fake-sql-parse.d.ts +23 -0
  183. package/dist/postgres/fake-sql-parse.d.ts.map +1 -0
  184. package/dist/postgres/fake-sql-quote.d.ts +12 -0
  185. package/dist/postgres/fake-sql-quote.d.ts.map +1 -0
  186. package/dist/postgres/fake-sql.d.ts +42 -0
  187. package/dist/postgres/fake-sql.d.ts.map +1 -1
  188. package/dist/postgres/grants-attrs.d.ts +115 -0
  189. package/dist/postgres/grants-attrs.d.ts.map +1 -0
  190. package/dist/postgres/grants-declare.d.ts +88 -0
  191. package/dist/postgres/grants-declare.d.ts.map +1 -0
  192. package/dist/postgres/grants-diff.d.ts +25 -0
  193. package/dist/postgres/grants-diff.d.ts.map +1 -0
  194. package/dist/postgres/grants-errors.d.ts +137 -0
  195. package/dist/postgres/grants-errors.d.ts.map +1 -0
  196. package/dist/postgres/grants-existence.d.ts +14 -0
  197. package/dist/postgres/grants-existence.d.ts.map +1 -0
  198. package/dist/postgres/grants-ops.d.ts +65 -0
  199. package/dist/postgres/grants-ops.d.ts.map +1 -0
  200. package/dist/postgres/grants-ownership.d.ts +18 -0
  201. package/dist/postgres/grants-ownership.d.ts.map +1 -0
  202. package/dist/postgres/grants-plan-restore.d.ts +22 -0
  203. package/dist/postgres/grants-plan-restore.d.ts.map +1 -0
  204. package/dist/postgres/grants-plan.d.ts +65 -0
  205. package/dist/postgres/grants-plan.d.ts.map +1 -0
  206. package/dist/postgres/grants-read-defaults.d.ts +17 -0
  207. package/dist/postgres/grants-read-defaults.d.ts.map +1 -0
  208. package/dist/postgres/grants-read.d.ts +77 -0
  209. package/dist/postgres/grants-read.d.ts.map +1 -0
  210. package/dist/postgres/grants-refuse.d.ts +25 -0
  211. package/dist/postgres/grants-refuse.d.ts.map +1 -0
  212. package/dist/postgres/grants-sql.d.ts +42 -0
  213. package/dist/postgres/grants-sql.d.ts.map +1 -0
  214. package/dist/postgres/grants-words.d.ts +29 -0
  215. package/dist/postgres/grants-words.d.ts.map +1 -0
  216. package/dist/postgres/grants.d.ts +37 -0
  217. package/dist/postgres/grants.d.ts.map +1 -0
  218. package/dist/postgres/index.d.ts +31 -6
  219. package/dist/postgres/index.d.ts.map +1 -1
  220. package/dist/postgres/index.js +1998 -37
  221. package/dist/postgres/index.js.map +46 -7
  222. package/dist/postgres/installed-classifier.d.ts +13 -0
  223. package/dist/postgres/installed-classifier.d.ts.map +1 -0
  224. package/dist/postgres/providers.d.ts +16 -8
  225. package/dist/postgres/providers.d.ts.map +1 -1
  226. package/dist/postgres/psql-executor.d.ts +4 -0
  227. package/dist/postgres/psql-executor.d.ts.map +1 -1
  228. package/dist/postgres/role-attrs.d.ts +112 -0
  229. package/dist/postgres/role-attrs.d.ts.map +1 -0
  230. package/dist/postgres/role-diff.d.ts +22 -0
  231. package/dist/postgres/role-diff.d.ts.map +1 -0
  232. package/dist/postgres/role-errors.d.ts +132 -0
  233. package/dist/postgres/role-errors.d.ts.map +1 -0
  234. package/dist/postgres/role-membership-sql.d.ts +78 -0
  235. package/dist/postgres/role-membership-sql.d.ts.map +1 -0
  236. package/dist/postgres/role-provider.d.ts +11 -0
  237. package/dist/postgres/role-provider.d.ts.map +1 -0
  238. package/dist/postgres/role-scram.d.ts +8 -0
  239. package/dist/postgres/role-scram.d.ts.map +1 -0
  240. package/dist/postgres/role-secrets.d.ts +38 -0
  241. package/dist/postgres/role-secrets.d.ts.map +1 -0
  242. package/dist/postgres/role-sql.d.ts +68 -0
  243. package/dist/postgres/role-sql.d.ts.map +1 -0
  244. package/dist/postgres/role.d.ts +57 -0
  245. package/dist/postgres/role.d.ts.map +1 -0
  246. package/dist/postgres/schema-assert.d.ts +50 -0
  247. package/dist/postgres/schema-assert.d.ts.map +1 -0
  248. package/dist/postgres/schema-attrs.d.ts +51 -0
  249. package/dist/postgres/schema-attrs.d.ts.map +1 -0
  250. package/dist/postgres/schema-delete.d.ts +28 -0
  251. package/dist/postgres/schema-delete.d.ts.map +1 -0
  252. package/dist/postgres/schema-diff.d.ts +14 -0
  253. package/dist/postgres/schema-diff.d.ts.map +1 -0
  254. package/dist/postgres/schema-errors.d.ts +139 -0
  255. package/dist/postgres/schema-errors.d.ts.map +1 -0
  256. package/dist/postgres/schema-identity.d.ts +8 -0
  257. package/dist/postgres/schema-identity.d.ts.map +1 -0
  258. package/dist/postgres/schema-reconcile.d.ts +12 -0
  259. package/dist/postgres/schema-reconcile.d.ts.map +1 -0
  260. package/dist/postgres/schema-sql.d.ts +45 -0
  261. package/dist/postgres/schema-sql.d.ts.map +1 -0
  262. package/dist/postgres/schema-test-kit.d.ts +67 -0
  263. package/dist/postgres/schema-test-kit.d.ts.map +1 -0
  264. package/dist/postgres/schema.d.ts +54 -0
  265. package/dist/postgres/schema.d.ts.map +1 -0
  266. package/dist/proxmox/index.js +35 -1
  267. package/dist/proxmox/index.js.map +3 -3
  268. package/dist/release/fake-engine.d.ts +10 -0
  269. package/dist/release/fake-engine.d.ts.map +1 -1
  270. package/dist/release/index.js +35 -1
  271. package/dist/release/index.js.map +3 -3
  272. package/dist/valkey/acl-attrs.d.ts +94 -0
  273. package/dist/valkey/acl-attrs.d.ts.map +1 -0
  274. package/dist/valkey/acl-compare.d.ts +28 -0
  275. package/dist/valkey/acl-compare.d.ts.map +1 -0
  276. package/dist/valkey/acl-connection.d.ts +6 -0
  277. package/dist/valkey/acl-connection.d.ts.map +1 -0
  278. package/dist/valkey/acl-form.d.ts +62 -0
  279. package/dist/valkey/acl-form.d.ts.map +1 -0
  280. package/dist/valkey/acl-managed.d.ts +4 -0
  281. package/dist/valkey/acl-managed.d.ts.map +1 -0
  282. package/dist/valkey/acl-ops.d.ts +37 -0
  283. package/dist/valkey/acl-ops.d.ts.map +1 -0
  284. package/dist/valkey/acl-profiles.d.ts +53 -0
  285. package/dist/valkey/acl-profiles.d.ts.map +1 -0
  286. package/dist/valkey/acl-reconcile.d.ts +26 -0
  287. package/dist/valkey/acl-reconcile.d.ts.map +1 -0
  288. package/dist/valkey/acl.d.ts +24 -0
  289. package/dist/valkey/acl.d.ts.map +1 -0
  290. package/dist/valkey/connection-service.d.ts +22 -0
  291. package/dist/valkey/connection-service.d.ts.map +1 -0
  292. package/dist/valkey/connection.d.ts +59 -0
  293. package/dist/valkey/connection.d.ts.map +1 -0
  294. package/dist/valkey/errors.d.ts +165 -0
  295. package/dist/valkey/errors.d.ts.map +1 -0
  296. package/dist/valkey/fake-acl.d.ts +29 -0
  297. package/dist/valkey/fake-acl.d.ts.map +1 -0
  298. package/dist/valkey/fake-valkey.d.ts +35 -0
  299. package/dist/valkey/fake-valkey.d.ts.map +1 -0
  300. package/dist/valkey/handler-test-fixture.d.ts +20 -0
  301. package/dist/valkey/handler-test-fixture.d.ts.map +1 -0
  302. package/dist/valkey/index.d.ts +18 -0
  303. package/dist/valkey/index.d.ts.map +1 -0
  304. package/dist/valkey/index.js +964 -0
  305. package/dist/valkey/index.js.map +27 -0
  306. package/dist/valkey/instance-attrs.d.ts +46 -0
  307. package/dist/valkey/instance-attrs.d.ts.map +1 -0
  308. package/dist/valkey/instance-form.d.ts +22 -0
  309. package/dist/valkey/instance-form.d.ts.map +1 -0
  310. package/dist/valkey/instance.d.ts +48 -0
  311. package/dist/valkey/instance.d.ts.map +1 -0
  312. package/dist/valkey/provider-socket-fixture.d.ts +8 -0
  313. package/dist/valkey/provider-socket-fixture.d.ts.map +1 -0
  314. package/dist/valkey/providers.d.ts +16 -0
  315. package/dist/valkey/providers.d.ts.map +1 -0
  316. package/dist/valkey/resp.d.ts +38 -0
  317. package/dist/valkey/resp.d.ts.map +1 -0
  318. package/dist/valkey/transport-error.d.ts +36 -0
  319. package/dist/valkey/transport-error.d.ts.map +1 -0
  320. package/dist/valkey/transport.d.ts +50 -0
  321. package/dist/valkey/transport.d.ts.map +1 -0
  322. package/docs/litellm-access-group.md +105 -0
  323. package/docs/litellm-credential.md +60 -0
  324. package/docs/litellm-key-metadata.md +56 -0
  325. package/docs/litellm-key.md +194 -0
  326. package/docs/litellm-mcp.md +187 -0
  327. package/docs/litellm-model.md +111 -0
  328. package/docs/litellm-policy-attachment.md +86 -0
  329. package/docs/litellm-policy.md +103 -0
  330. package/docs/litellm-team.md +117 -0
  331. package/docs/litellm-tool-policy.md +90 -0
  332. package/docs/litellm-toolset.md +92 -0
  333. package/docs/litellm.md +16 -9
  334. package/docs/peers.md +15 -6
  335. package/docs/postgres-grants-example.md +55 -0
  336. package/docs/postgres-grants.md +157 -0
  337. package/docs/postgres-role.md +126 -0
  338. package/docs/postgres-schema.md +139 -0
  339. package/docs/postgres.md +20 -3
  340. package/docs/valkey-transport.md +29 -0
  341. package/docs/valkey.md +187 -0
  342. package/package.json +6 -2
  343. package/src/ceph/ceph-argv.test.ts +1 -1
  344. package/src/launchd/sudo-allowlist.test.ts +2 -2
  345. package/src/linux/sudo-allowlist.test.ts +3 -3
  346. package/src/linux/sudo-runner.test.ts +2 -2
  347. package/src/litellm/access-group-form.ts +105 -0
  348. package/src/litellm/access-group-operations.ts +92 -0
  349. package/src/litellm/access-group-types.ts +49 -0
  350. package/src/litellm/access-group.test.ts +197 -0
  351. package/src/litellm/access-group.ts +151 -0
  352. package/src/litellm/credential-errors.ts +183 -0
  353. package/src/litellm/credential-form.test.ts +151 -0
  354. package/src/litellm/credential-form.ts +211 -0
  355. package/src/litellm/credential-guards.test.ts +241 -0
  356. package/src/litellm/credential-operations.ts +208 -0
  357. package/src/litellm/credential-recovery.test.ts +93 -0
  358. package/src/litellm/credential-rewrite.test.ts +164 -0
  359. package/src/litellm/credential-rewrite.ts +50 -0
  360. package/src/litellm/credential-types.ts +117 -0
  361. package/src/litellm/credential-values.ts +94 -0
  362. package/src/litellm/credential.test.ts +218 -0
  363. package/src/litellm/credential.ts +227 -0
  364. package/src/litellm/fake-access-group-litellm.ts +127 -0
  365. package/src/litellm/fake-credential-litellm.ts +216 -0
  366. package/src/litellm/fake-keys.ts +190 -0
  367. package/src/litellm/fake-litellm.ts +19 -9
  368. package/src/litellm/fake-mcp-litellm.ts +214 -0
  369. package/src/litellm/fake-model-litellm-post-update.ts +103 -0
  370. package/src/litellm/fake-model-litellm.ts +233 -0
  371. package/src/litellm/fake-policy-attachment-litellm.ts +97 -0
  372. package/src/litellm/fake-policy-litellm.ts +186 -0
  373. package/src/litellm/fake-registry-base.ts +69 -0
  374. package/src/litellm/fake-stack.ts +17 -1
  375. package/src/litellm/fake-team-litellm.ts +229 -0
  376. package/src/litellm/fake-tool-litellm.ts +88 -0
  377. package/src/litellm/fake-toolset-litellm.ts +110 -0
  378. package/src/litellm/index.ts +140 -0
  379. package/src/litellm/key-delete.test.ts +212 -0
  380. package/src/litellm/key-errors.ts +241 -0
  381. package/src/litellm/key-form.ts +200 -0
  382. package/src/litellm/key-harness.ts +121 -0
  383. package/src/litellm/key-metadata-errors.ts +49 -0
  384. package/src/litellm/key-metadata.test.ts +156 -0
  385. package/src/litellm/key-metadata.ts +74 -0
  386. package/src/litellm/key-operations.ts +184 -0
  387. package/src/litellm/key-rotation.test.ts +110 -0
  388. package/src/litellm/key-scope.test.ts +135 -0
  389. package/src/litellm/key-secret.test.ts +248 -0
  390. package/src/litellm/key-secret.ts +137 -0
  391. package/src/litellm/key-transport.test.ts +166 -0
  392. package/src/litellm/key.test.ts +231 -0
  393. package/src/litellm/key.ts +213 -0
  394. package/src/litellm/mcp-server-adopt.test.ts +86 -0
  395. package/src/litellm/mcp-server-alias.test.ts +184 -0
  396. package/src/litellm/mcp-server-credential.ts +85 -0
  397. package/src/litellm/mcp-server-errors.ts +141 -0
  398. package/src/litellm/mcp-server-exports.test.ts +15 -0
  399. package/src/litellm/mcp-server-form.test.ts +241 -0
  400. package/src/litellm/mcp-server-form.ts +233 -0
  401. package/src/litellm/mcp-server-handlers.test.ts +150 -0
  402. package/src/litellm/mcp-server-locate.ts +66 -0
  403. package/src/litellm/mcp-server-operations.ts +111 -0
  404. package/src/litellm/mcp-server-registry.test.ts +146 -0
  405. package/src/litellm/mcp-server-retype.test.ts +114 -0
  406. package/src/litellm/mcp-server-shadow.test.ts +91 -0
  407. package/src/litellm/mcp-server-shadow.ts +45 -0
  408. package/src/litellm/mcp-server-tools.test.ts +85 -0
  409. package/src/litellm/mcp-server-types.ts +143 -0
  410. package/src/litellm/mcp-server-url.ts +66 -0
  411. package/src/litellm/mcp-server.test.ts +213 -0
  412. package/src/litellm/mcp-server.ts +225 -0
  413. package/src/litellm/model-claim.ts +69 -0
  414. package/src/litellm/model-credential.ts +45 -0
  415. package/src/litellm/model-errors.ts +168 -0
  416. package/src/litellm/model-foreign-row.test.ts +173 -0
  417. package/src/litellm/model-form.test.ts +228 -0
  418. package/src/litellm/model-form.ts +223 -0
  419. package/src/litellm/model-locate.test.ts +128 -0
  420. package/src/litellm/model-locate.ts +67 -0
  421. package/src/litellm/model-operations.test.ts +93 -0
  422. package/src/litellm/model-operations.ts +146 -0
  423. package/src/litellm/model-params-preserve.test.ts +119 -0
  424. package/src/litellm/model-recovery.test.ts +57 -0
  425. package/src/litellm/model-types.ts +112 -0
  426. package/src/litellm/model.test.ts +222 -0
  427. package/src/litellm/model.ts +237 -0
  428. package/src/litellm/policy-attachment-form.ts +103 -0
  429. package/src/litellm/policy-attachment-operations.ts +74 -0
  430. package/src/litellm/policy-attachment-types.ts +48 -0
  431. package/src/litellm/policy-attachment.test.ts +198 -0
  432. package/src/litellm/policy-attachment.ts +178 -0
  433. package/src/litellm/policy-form.ts +122 -0
  434. package/src/litellm/policy-operations.ts +112 -0
  435. package/src/litellm/policy-types.ts +58 -0
  436. package/src/litellm/policy.test.ts +214 -0
  437. package/src/litellm/policy.ts +146 -0
  438. package/src/litellm/providers.ts +24 -3
  439. package/src/litellm/registry-errors.ts +88 -0
  440. package/src/litellm/registry-exports.test.ts +66 -0
  441. package/src/litellm/registry-support.ts +109 -0
  442. package/src/litellm/team-form.ts +140 -0
  443. package/src/litellm/team-members.test.ts +150 -0
  444. package/src/litellm/team-members.ts +58 -0
  445. package/src/litellm/team-operations.ts +90 -0
  446. package/src/litellm/team-permission.ts +159 -0
  447. package/src/litellm/team-read.test.ts +89 -0
  448. package/src/litellm/team-types.ts +106 -0
  449. package/src/litellm/team.test.ts +206 -0
  450. package/src/litellm/team.ts +159 -0
  451. package/src/litellm/tool-policy-form.ts +94 -0
  452. package/src/litellm/tool-policy-operations.ts +58 -0
  453. package/src/litellm/tool-policy-types.ts +48 -0
  454. package/src/litellm/tool-policy.test.ts +172 -0
  455. package/src/litellm/tool-policy.ts +125 -0
  456. package/src/litellm/toolset-form.ts +104 -0
  457. package/src/litellm/toolset-operations.ts +90 -0
  458. package/src/litellm/toolset-types.ts +47 -0
  459. package/src/litellm/toolset.test.ts +198 -0
  460. package/src/litellm/toolset.ts +151 -0
  461. package/src/ownership/ownership.test.ts +33 -1
  462. package/src/ownership/rows.ts +53 -0
  463. package/src/postgres/connection.ts +42 -7
  464. package/src/postgres/database-bigint-serialization.test.ts +1 -0
  465. package/src/postgres/database-refusals.test.ts +2 -2
  466. package/src/postgres/database-sql.ts +36 -9
  467. package/src/postgres/fake-grants-parse.ts +189 -0
  468. package/src/postgres/fake-grants-read.ts +250 -0
  469. package/src/postgres/fake-grants-sql.ts +207 -0
  470. package/src/postgres/fake-grants-write.ts +90 -0
  471. package/src/postgres/fake-role-sql.ts +240 -0
  472. package/src/postgres/fake-schema-semantics.test.ts +36 -0
  473. package/src/postgres/fake-schema-sql.ts +146 -0
  474. package/src/postgres/fake-sql-parse.ts +86 -0
  475. package/src/postgres/fake-sql-quote.ts +36 -0
  476. package/src/postgres/fake-sql.ts +166 -46
  477. package/src/postgres/fixtures/pg-REL_18_6-acl.h.txt +147 -0
  478. package/src/postgres/fixtures/pg-REL_18_6-aclexplode-func.txt +31 -0
  479. package/src/postgres/fixtures/pg-REL_18_6-alter-default-privileges-synopsis.txt +82 -0
  480. package/src/postgres/fixtures/pg-REL_18_6-alter_role.sgml.txt +44 -0
  481. package/src/postgres/fixtures/pg-REL_18_6-create_role.sgml.txt +26 -0
  482. package/src/postgres/fixtures/pg-REL_18_6-grant-synopsis.txt +95 -0
  483. package/src/postgres/fixtures/pg-REL_18_6-pg_attribute.h.txt +24 -0
  484. package/src/postgres/fixtures/pg-REL_18_6-pg_auth_members.h.txt +62 -0
  485. package/src/postgres/fixtures/pg-REL_18_6-pg_authid.h.txt +70 -0
  486. package/src/postgres/fixtures/pg-REL_18_6-pg_class.h.txt +33 -0
  487. package/src/postgres/fixtures/pg-REL_18_6-pg_default_acl.h.txt +81 -0
  488. package/src/postgres/fixtures/pg-REL_18_6-pg_namespace.h.txt +28 -0
  489. package/src/postgres/fixtures/pg-REL_18_6-revoke-synopsis.txt +124 -0
  490. package/src/postgres/grants-acl.test.ts +61 -0
  491. package/src/postgres/grants-attrs.ts +185 -0
  492. package/src/postgres/grants-database.test.ts +158 -0
  493. package/src/postgres/grants-declare.ts +172 -0
  494. package/src/postgres/grants-delete-proof.test.ts +154 -0
  495. package/src/postgres/grants-diff.ts +101 -0
  496. package/src/postgres/grants-errors.ts +215 -0
  497. package/src/postgres/grants-existence-guards.test.ts +113 -0
  498. package/src/postgres/grants-existence.ts +101 -0
  499. package/src/postgres/grants-lifecycle-guards.test.ts +208 -0
  500. package/src/postgres/grants-lifecycle-repair.test.ts +208 -0
  501. package/src/postgres/grants-lifecycle.test.ts +181 -0
  502. package/src/postgres/grants-ops.ts +229 -0
  503. package/src/postgres/grants-owner-revoke.test.ts +121 -0
  504. package/src/postgres/grants-ownership.ts +49 -0
  505. package/src/postgres/grants-plan-collateral.test.ts +202 -0
  506. package/src/postgres/grants-plan-diff.test.ts +204 -0
  507. package/src/postgres/grants-plan-restore.ts +43 -0
  508. package/src/postgres/grants-plan-revocations.test.ts +69 -0
  509. package/src/postgres/grants-plan.test.ts +148 -0
  510. package/src/postgres/grants-plan.ts +245 -0
  511. package/src/postgres/grants-provenance.test.ts +134 -0
  512. package/src/postgres/grants-psql-lifecycle.test.ts +105 -0
  513. package/src/postgres/grants-read-absent.test.ts +91 -0
  514. package/src/postgres/grants-read-defaults.ts +51 -0
  515. package/src/postgres/grants-read.ts +250 -0
  516. package/src/postgres/grants-refusals.test.ts +136 -0
  517. package/src/postgres/grants-refuse.ts +119 -0
  518. package/src/postgres/grants-relkind-wire.test.ts +111 -0
  519. package/src/postgres/grants-repair-plan.test.ts +201 -0
  520. package/src/postgres/grants-sql.test.ts +128 -0
  521. package/src/postgres/grants-sql.ts +144 -0
  522. package/src/postgres/grants-words.ts +34 -0
  523. package/src/postgres/grants.ts +110 -0
  524. package/src/postgres/index.ts +129 -5
  525. package/src/postgres/installed-classifier.ts +36 -0
  526. package/src/postgres/providers.ts +33 -9
  527. package/src/postgres/psql-executor-escaping.test.ts +67 -0
  528. package/src/postgres/psql-executor.test.ts +63 -2
  529. package/src/postgres/psql-executor.ts +74 -34
  530. package/src/postgres/role-adopt.test.ts +98 -0
  531. package/src/postgres/role-attrs.ts +137 -0
  532. package/src/postgres/role-diff.ts +93 -0
  533. package/src/postgres/role-errors.ts +206 -0
  534. package/src/postgres/role-guard.test.ts +60 -0
  535. package/src/postgres/role-identity.test.ts +197 -0
  536. package/src/postgres/role-lifecycle.test.ts +228 -0
  537. package/src/postgres/role-membership-options.test.ts +73 -0
  538. package/src/postgres/role-membership-repair.test.ts +153 -0
  539. package/src/postgres/role-membership-sql.ts +223 -0
  540. package/src/postgres/role-password-ascii.test.ts +53 -0
  541. package/src/postgres/role-password-transports.test.ts +123 -0
  542. package/src/postgres/role-password.test.ts +158 -0
  543. package/src/postgres/role-privilege.test.ts +107 -0
  544. package/src/postgres/role-provenance.test.ts +200 -0
  545. package/src/postgres/role-provider.ts +105 -0
  546. package/src/postgres/role-refusals.test.ts +225 -0
  547. package/src/postgres/role-scram.test.ts +38 -0
  548. package/src/postgres/role-scram.ts +40 -0
  549. package/src/postgres/role-secrets.ts +61 -0
  550. package/src/postgres/role-sql.ts +213 -0
  551. package/src/postgres/role-valid-until.test.ts +68 -0
  552. package/src/postgres/role.ts +226 -0
  553. package/src/postgres/schema-assert.ts +139 -0
  554. package/src/postgres/schema-attrs.ts +71 -0
  555. package/src/postgres/schema-delete-proofs.test.ts +192 -0
  556. package/src/postgres/schema-delete.ts +96 -0
  557. package/src/postgres/schema-diff.ts +44 -0
  558. package/src/postgres/schema-drop-2bp01.test.ts +146 -0
  559. package/src/postgres/schema-errors.ts +209 -0
  560. package/src/postgres/schema-handlers.test.ts +193 -0
  561. package/src/postgres/schema-identity.ts +39 -0
  562. package/src/postgres/schema-lifecycle.test.ts +246 -0
  563. package/src/postgres/schema-race.test.ts +70 -0
  564. package/src/postgres/schema-reconcile.ts +100 -0
  565. package/src/postgres/schema-refusals.test.ts +144 -0
  566. package/src/postgres/schema-socket.test.ts +162 -0
  567. package/src/postgres/schema-sql.ts +130 -0
  568. package/src/postgres/schema-takeover.test.ts +149 -0
  569. package/src/postgres/schema-test-kit.ts +85 -0
  570. package/src/postgres/schema.ts +130 -0
  571. package/src/release/binary-alias.test.ts +3 -3
  572. package/src/release/binary-claims.test.ts +3 -3
  573. package/src/release/binary-directory-umask.test.ts +65 -0
  574. package/src/release/fake-engine.ts +15 -0
  575. package/src/valkey/acl-attrs.ts +98 -0
  576. package/src/valkey/acl-compare.ts +57 -0
  577. package/src/valkey/acl-connection.ts +13 -0
  578. package/src/valkey/acl-delete.test.ts +127 -0
  579. package/src/valkey/acl-form.ts +239 -0
  580. package/src/valkey/acl-managed.ts +13 -0
  581. package/src/valkey/acl-ops.ts +122 -0
  582. package/src/valkey/acl-ownership.test.ts +118 -0
  583. package/src/valkey/acl-prefix.test.ts +38 -0
  584. package/src/valkey/acl-profiles.ts +81 -0
  585. package/src/valkey/acl-reconcile.ts +180 -0
  586. package/src/valkey/acl-reserved.test.ts +69 -0
  587. package/src/valkey/acl-revocation.test.ts +94 -0
  588. package/src/valkey/acl-seat-prefix.test.ts +111 -0
  589. package/src/valkey/acl-validation.test.ts +54 -0
  590. package/src/valkey/acl.test.ts +215 -0
  591. package/src/valkey/acl.ts +169 -0
  592. package/src/valkey/connection-service.ts +46 -0
  593. package/src/valkey/connection.ts +180 -0
  594. package/src/valkey/errors.ts +239 -0
  595. package/src/valkey/fake-acl.ts +128 -0
  596. package/src/valkey/fake-valkey.ts +224 -0
  597. package/src/valkey/handler-test-fixture.ts +43 -0
  598. package/src/valkey/handlers.test.ts +205 -0
  599. package/src/valkey/index.ts +54 -0
  600. package/src/valkey/instance-attrs.ts +48 -0
  601. package/src/valkey/instance-form.ts +104 -0
  602. package/src/valkey/instance.test.ts +108 -0
  603. package/src/valkey/instance.ts +160 -0
  604. package/src/valkey/provider-socket-fixture.ts +71 -0
  605. package/src/valkey/providers.test.ts +129 -0
  606. package/src/valkey/providers.ts +21 -0
  607. package/src/valkey/resp.ts +212 -0
  608. package/src/valkey/transport-bounds.test.ts +150 -0
  609. package/src/valkey/transport-error.ts +37 -0
  610. package/src/valkey/transport.test.ts +158 -0
  611. package/src/valkey/transport.ts +109 -0
  612. package/src/valkey/upstream-bounds.test.ts +14 -0
@@ -30,6 +30,17 @@ export declare const recordedInstance: (fqn: string, instanceId: string) => Effe
30
30
  * let it write over whatever sits at its new identity (adopt.ts adoptsAtApply).
31
31
  */
32
32
  export declare const isCreate: (fqn: string, instanceId: string) => Effect.Effect<boolean>;
33
+ /**
34
+ * `attr.id` on every generation OLDER than `instanceId` in this FQN's state chain (and a former
35
+ * FQN `renamedFrom` names). Walks `old` the way {@link generationOf} does, and skips the current
36
+ * generation itself.
37
+ * ⛔ THOSE IDS ARE NOT THIS GENERATION'S. A `replacing` row's reconcile runs with no attributes, so
38
+ * a live row found by name can be the previous generation's own deployment. Recording that id on
39
+ * the new generation makes both the same id, and `destroy()` then deletes the old generation by
40
+ * it (Apply.ts, the retain check near 2168 and the provider delete that follows when the policy
41
+ * is not `retain`). A same-instance `old` snapshot (an `updating` row) is not one of these.
42
+ */
43
+ export declare const olderGenerationIds: (fqn: string, instanceId: string) => Effect.Effect<readonly string[]>;
33
44
  /**
34
45
  * ⛔ A REFUSED CREATE MUST NOT LEAVE A ROW THAT CLAIMS THE OBJECT IT REFUSED. Apply commits a
35
46
  * `creating` row for this instance before it calls reconcile, and a failed reconcile leaves it
@@ -1 +1 @@
1
- {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/ownership/rows.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAmBxC,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAaF,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,QACxB,MAAM,cACC,MAAM,KACjB,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,SAAS,CASnC,CAAC;AAEL;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtD,eAAO,MAAM,gBAAgB,QAAS,MAAM,cAAc,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAKrF,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,cAAc,MAAM,KAAG,MAAM,CAAC,M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ACH,eAAO,MAAM,mBAAmB,QAAS,MAAM,cAAc,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAUpF,CAAC"}
@@ -41,9 +41,12 @@ export interface PostgresRunnerConfig {
41
41
  readonly username: string;
42
42
  readonly template?: string;
43
43
  }
44
- /** What `withPg`'s callback learns about the transport beyond the client. */
44
+ /** What `withPg`'s callback learns about the transport beyond the client. `database` is the
45
+ * database the statements run IN: the family connection's, or the override `Postgres.Schema`
46
+ * and `Postgres.Grants` pass so they open their declared database and then prove it. */
45
47
  export interface PgContext {
46
48
  readonly template?: string;
49
+ readonly database: string;
47
50
  }
48
51
  declare const PostgresConnection_base: Context.ServiceClass<PostgresConnection, "Postgres.Connection", Effect.Effect<PostgresConnectionConfig | PostgresRunnerConfig, never, never>>;
49
52
  /** The lazy connection service. Its value is an `Effect` of the config, per S24 — see the file
@@ -55,6 +58,8 @@ export declare class PostgresConnection extends PostgresConnection_base {
55
58
  export declare const postgresConnection: (config: PostgresConnectionConfig) => Layer.Layer<PostgresConnection>;
56
59
  /** A stack's one-line way to provide a cluster reached through a command runner. */
57
60
  export declare const postgresRunnerConnection: (config: PostgresRunnerConfig) => Layer.Layer<PostgresConnection>;
61
+ /** Effect-scoped pool factory, like BaoGate: tests override it without process-wide module mocks. */
62
+ export declare const PostgresPool: Context.Reference<(config: PgClient.PgPoolConfig) => Layer.Layer<PgClient.PgClient | import("effect/unstable/sql/SqlClient").SqlClient, SqlError>>;
58
63
  /**
59
64
  * Run one operation against a freshly built, freshly closed connection pool.
60
65
  *
@@ -62,7 +67,14 @@ export declare const postgresRunnerConnection: (config: PostgresRunnerConfig) =>
62
67
  * operation — never once per statement — so a reconcile that runs a `SELECT`, then a `CREATE`,
63
68
  * then a re-read shares one pool and closes it once, while a plan-only `read` still opens and
64
69
  * closes its own.
70
+ *
71
+ * `database` overrides which database of the SAME cluster the pool opens — the declared
72
+ * database of `Postgres.Schema` and `Postgres.Grants`. The family connection is pointed at a
73
+ * maintenance database (a brand-new database cannot be connected to on a cold plan), so those
74
+ * resources pass their declared database here: the runner transport swaps the `psql -d` target,
75
+ * the socket path swaps the pool's `database`. The swap is proven, not trusted: schema rows
76
+ * carry `current_database()` (`schema-sql.ts`) and grants calls the same function before writing.
65
77
  */
66
- export declare const withPg: <A, E>(build: (pg: PgClient.PgClient | PgExecutor, context: PgContext) => Effect.Effect<A, E>) => Effect.Effect<A, E | SqlError, PostgresConnection>;
78
+ export declare const withPg: <A, E>(build: (pg: PgExecutor, context: PgContext) => Effect.Effect<A, E>, database?: string) => Effect.Effect<A, E | SqlError, PostgresConnection>;
67
79
  export {};
68
80
  //# sourceMappingURL=connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/postgres/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,oBAAoB,CAAC;AAEvE;;;uFAGuF;AACvF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;wFAGwF;AACxF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG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AAM,KAChB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,kBAAkB,CAgChD,CAAC"}
@@ -19,26 +19,36 @@
19
19
  * `createdb_opt_item`'s string branch is `opt_boolean_or_string → NonReservedWord_or_Sconst →
20
20
  * NonReservedWord | Sconst`. A locale like `en_US.UTF-8` would hit the same dot-splitting
21
21
  * `quoteIdent` avoids if it were identifier-quoted; a plain `Sconst` (`quoteStringLiteral`) has
22
- * no such rule. This rests on `standard_conforming_strings = on` (the PG18 default, and
23
- * measured live 2026-09-23 — `docs/postgres.md#measured`); the escaper only ever doubles `'`
24
- * and never emits a backslash, so it never depends on which way that setting points.
22
+ * no such rule. Use E'…' with doubled backslashes and quotes: PostgreSQL 18 lexical
23
+ * section 4.1.2.2 makes escape strings independent of standard_conforming_strings.
24
+ * Measured 2026-10-01: the former quote-only escaper allowed comment SQL injection when
25
+ * that setting was off; an input backslash escaped the first quote of a doubled pair.
25
26
  */
26
27
  import type { SqlError } from 'effect/unstable/sql/SqlError';
27
28
  import * as Effect from 'effect/Effect';
28
29
  import type { PostgresDatabaseAttributes, PostgresDatabaseProps } from './database-attrs.ts';
29
30
  /** What every function in this file needs from a client — real (`PgClient.PgClient`) or fake
30
- * (`fake-sql.ts`). Deliberately smaller than `SqlClient`: nothing here ever needs the tagged
31
- * template, transactions or streaming, because every statement is either bound params through
32
- * `.unsafe(text, params)` or a hand-escaped literal through `.unsafe(text)`. */
31
+ * (`fake-sql.ts`). Deliberately smaller than `SqlClient`: nothing here needs the tagged template
32
+ * or streaming. `transaction` is the exception `Postgres.Role`'s create and `Postgres.Grants`'
33
+ * repair share: role DDL commits per statement unless the statements share a transaction, and
34
+ * a grants repair's `REVOKE` must not autocommit apart from the `GRANT`s that restore it. */
33
35
  export interface PgExecutor {
34
36
  readonly unsafe: <A extends object>(sql: string, params?: ReadonlyArray<unknown>) => Effect.Effect<ReadonlyArray<A>, SqlError>;
37
+ /**
38
+ * Run `statements` in one transaction. `CREATE ROLE`, `ALTER ROLE` and `GRANT`/`REVOKE` of
39
+ * membership are transactional (`utility.c@REL_18_6`: those cases do not call
40
+ * `PreventInTransactionBlock`; `CREATE DATABASE` does). The socket client reserves one
41
+ * connection (`SqlClient.withTransaction`); the runner sends one `psql` script, because each
42
+ * `unsafe` call is its own session and would autocommit.
43
+ */
44
+ readonly transaction: (statements: readonly string[]) => Effect.Effect<void, SqlError>;
35
45
  }
36
46
  /** Single-token identifier quoting: wrap in `"`, double any embedded `"`. No dot-splitting —
37
47
  * see the file header. Used for the database name and, since a role or tablespace name is a
38
48
  * `NonReservedWord` too, for `OWNER` and `TABLESPACE`. */
39
49
  export declare const quoteIdent: (value: string) => string;
40
- /** SQL string-literal quoting: wrap in `'`, double any embedded `'`. Used for every `WITH`
41
- * value that is locale or encoding text, never for an identifier (see the file header). */
50
+ /** Escape-string quoting is safe with standard_conforming_strings either on or off.
51
+ * Double backslashes BEFORE quotes, so caller text cannot escape a closing delimiter. */
42
52
  export declare const quoteStringLiteral: (value: string) => string;
43
53
  /**
44
54
  * Build the exact `CREATE DATABASE` text — a pure function, unit-tested on its own with no
@@ -58,6 +68,15 @@ export declare const isDuplicateDatabaseRace: (error: SqlError) => boolean;
58
68
  * `PostgresDatabaseOwnerMissing` at reconcile time rather than the server's own
59
69
  * `ERROR: role "…" does not exist` surfacing as an unclassified statement failure. */
60
70
  export declare const roleExists: (pg: PgExecutor, role: string) => Effect.Effect<boolean, SqlError>;
71
+ /**
72
+ * Does one database of the cluster exist? `Postgres.Schema` runs this over the FAMILY
73
+ * connection (no `withPg` database override) before `read` and `delete`, so a declared
74
+ * database that does not exist yet answers "schema absent" instead of the transports' untyped
75
+ * connect failures (`ConnectionError` over psql, `UnknownError` 3D000 over the socket). The
76
+ * probe targets the maintenance database the family connection already points at, which a
77
+ * cold plan can always reach.
78
+ */
79
+ export declare const databaseExists: (pg: PgExecutor, name: string) => Effect.Effect<boolean, SqlError>;
61
80
  /** The read: one bound `SELECT` on `pg_database`, joined to the two functions that turn its raw
62
81
  * owner and encoding columns into names (`docs/postgres.md#mapping`). `undefined` when the row
63
82
  * is absent — ownership branding happens one layer up, in `database.ts`, not here. */
@@ -1 +1 @@
1
- {"version":3,"file":"database-sql.d.ts","sourceRoot":"","sources":["../../src/postgres/database-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE7F;;;gFAGgF;AAChF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,EAChC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,KAC5B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;CAChD;AAED;;0DAE0D;AAC1D,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAA0C,CAAC;AAEtF;2FAC2F;AAC3F,eAAO,MAAM,kBAAkB,UAAW,MAAM,KAAG,MAA0C,CAAC;AAwB9F;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,UAAW,qBAAqB,aAAa,MAAM,KAAG,MACP,CAAC;AAEnF;;;;;mFAKmF;AACnF,eAAO,MAAM,uBAAuB,UAAW,QAAQ,KAAG,OAMzD,CAAC;AAIF;;sFAEsF;AACtF,eAAO,MAAM,UAAU,OAAQ,UAAU,QAAQ,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAItF,CAAC;AAwCJ;;sFAEsF;AACtF,eAAO,MAAM,cAAc,OACrB,UAAU,QACR,MAAM,KACX,MAAM,CAAC,MAAM,CAAC,0BAA0B,GAAG,SAAS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uB,UAAW,QAAQ,KAAG,OAMzD,CAAC;AAIF;;sFAEsF;AACtF,eAAO,MAAM,UAAU,OAAQ,UAAU,QAAQ,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAItF,CAAC;AAIJ;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,OAAQ,UAAU,QAAQ,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAI1F,CAAC;AAwCJ;;sFAEsF;AACtF,eAAO,MAAM,cAAc,OACrB,UAAU,QACR,MAAM,KACX,MAAM,CAAC,MAAM,CAAC,0BAA0B,GAAG,SAAS,EAAE,QAAQ,CACkC,CAAC;AAEpG;;qFAEqF;AACrF,eAAO,MAAM,UAAU,UACd,qBAAqB,QACtB,0BAA0B,KAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,SAgBlF,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The statement parser half of the `Postgres.Grants` test fake: it understands EXACTLY the
3
+ * ten statement shapes `grants-sql.ts` generates — `quoteIdent`'s quoting, one clause
4
+ * order — and nothing else, so a quoting or clause-order bug in a builder trips the parser
5
+ * instead of hiding behind lenient matching. The server-model half (entries, grant/revoke
6
+ * semantics, the aclexplode-shaped reads) lives in `fake-grants-sql.ts`.
7
+ *
8
+ * ⛔ IT PARSES ITS OWN OUTPUT, NOT SQL IN GENERAL (`fake-sql.ts`'s own rule): every value
9
+ * the builders `quoteIdent` is read back through the same `"…""…"` unquoting, and every
10
+ * statement ends in exactly one of the accepted shapes or the parse refuses.
11
+ * ⛔ A COLUMN GRANT CARRIES ONE COLUMN LIST PER WORD — `GRANT select ("id"), update ("id")`:
12
+ * a single trailing list binds only to the privilege it follows (gram.y@REL_18_6), so
13
+ * `GRANT select, update ("id")` is a table-level SELECT on a real server. The parser
14
+ * refuses that shape instead of filing it as a column-only grant.
15
+ */
16
+ export interface AclObject {
17
+ readonly schema: string;
18
+ readonly table?: string;
19
+ readonly column?: string;
20
+ readonly defaultFor?: string;
21
+ }
22
+ /** One parsed write statement, already reduced to what the model applies. */
23
+ export interface ParsedWrite {
24
+ readonly kind: 'grant' | 'revoke';
25
+ /** `REVOKE ALL ON ALL TABLES IN SCHEMA … FROM PUBLIC` — applied per known relation. */
26
+ readonly allTables?: boolean;
27
+ readonly object: AclObject;
28
+ /** `'PUBLIC'` or a role name. */
29
+ readonly grantee: string;
30
+ /** Declared privilege words, lowercase, no `*` marks (the option clause carries the flag). */
31
+ readonly words: ReadonlyArray<string>;
32
+ readonly option: boolean;
33
+ }
34
+ /** `undefined` when the text is no statement this family generates — the model refuses it
35
+ * rather than guessing (a parse miss on a GRANT-shaped text means a builder regressed). */
36
+ export declare const parseGrantStatement: (text: string) => ParsedWrite | undefined;
37
+ //# sourceMappingURL=fake-grants-parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-grants-parse.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-grants-parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,uFAAuF;IACvF,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAgJD;2FAC2F;AAC3F,eAAO,MAAM,mBAAmB,SAAU,MAAM,KAAG,WAAW,GAAG,SAShE,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The read-answering half of the `Postgres.Grants` test fake: the `aclexplode`-shaped
3
+ * queries and the existence/ownership checks, answered from the server model's ACL
4
+ * (`fake-grants-sql.ts`), never from the statement list (S28). The entry and model shape
5
+ * are defined HERE so the write half (`fake-grants-write.ts`) can import them without a
6
+ * cycle.
7
+ */
8
+ import * as Effect from 'effect/Effect';
9
+ import type { SqlError } from 'effect/unstable/sql/SqlError';
10
+ import type { AclObject } from './fake-grants-parse.ts';
11
+ /** One `aclitem` as the fake stores it: one (object, grantee, grantor) with the words that
12
+ * grantor granted, `*`-marked when WITH GRANT OPTION. `words` is mutable: grants and
13
+ * revokes edit it. */
14
+ export interface AclEntry {
15
+ readonly object: AclObject;
16
+ readonly grantee: string;
17
+ readonly grantor: string;
18
+ words: string[];
19
+ }
20
+ /** One relation in the fake's catalog: every relation a table/column statement may name,
21
+ * with its columns, its `relkind` (default `'r'`) and its owner (default: the executor
22
+ * role, which no declared seat role owns). A sequence is a row with `relkind: 'S'`. */
23
+ export interface FakeCatalogTable {
24
+ readonly schema: string;
25
+ readonly table: string;
26
+ readonly columns?: ReadonlyArray<string>;
27
+ readonly relkind?: string;
28
+ readonly owner?: string;
29
+ }
30
+ /** What the read half needs from the factory, keyed per schema so two schemas may hold
31
+ * same-named relations: `relkinds`/`tableOwners` map `"schema\0table"`, `schemaOwners`
32
+ * maps the schema to its owning role. */
33
+ export interface FakeGrantsModel {
34
+ readonly schemas: ReadonlySet<string>;
35
+ readonly roles: ReadonlySet<string>;
36
+ readonly databases: ReadonlySet<string>;
37
+ readonly tables: ReadonlyArray<FakeCatalogTable>;
38
+ readonly acl: AclEntry[];
39
+ readonly relkinds: ReadonlyMap<string, string>;
40
+ readonly tableOwners: ReadonlyMap<string, string>;
41
+ readonly schemaOwners: ReadonlyMap<string, string>;
42
+ /** `current_user` — the grantor a write records, and the revoker the column read reports. */
43
+ readonly executor: string;
44
+ /** Whether `current_user` is a superuser: one arm of `revokesAsOwner` (a superuser revokes
45
+ * as the object owner, `revoke.sgml`). */
46
+ readonly executorSuper: boolean;
47
+ /** The roles `current_user` is a member of (recursively): a member of the owning role revokes
48
+ * as that role (`revokesAsOwner`). */
49
+ readonly executorMemberships: ReadonlySet<string>;
50
+ /** What `SELECT current_database()` answers. */
51
+ readonly connected: string;
52
+ }
53
+ /** Whether a `REVOKE` from the executor is performed as the object's owner (`select_best_grantor`
54
+ * acl.c@REL_18_6): a superuser, the owner itself, or a member of the owning role. Gates the
55
+ * column read's `grantor === owner` arm; the write path removes the owner's grant under it. */
56
+ export declare const revokesAsOwner: (model: FakeGrantsModel, owner: string) => boolean;
57
+ /** Answer the reads the family issues: the two existence checks, the schema/table/column/
58
+ * default `aclexplode` reads, and the two ownership reads. `undefined` when the text is no
59
+ * read this fake answers — the caller applies it as a write. */
60
+ export declare const answerRead: <A extends object>(text: string, params: ReadonlyArray<unknown>, model: FakeGrantsModel) => Effect.Effect<ReadonlyArray<A>, SqlError> | undefined;
61
+ //# sourceMappingURL=fake-grants-read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-grants-read.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-grants-read.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD;;sBAEsB;AACtB,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EA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,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAOD;;+FAE+F;AAC/F,eAAO,MAAM,cAAc,UAAW,eAAe,SAAS,MAAM,KAAG,OACkB,CAAC;AAuB1F;;gEAEgE;AAChE,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,QACnC,MAAM,UACJ,aAAa,CAAC,OAAO,CAAC,SACvB,eAAe,KACrB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,SA0J9C,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { PgExecutor } from './database-sql.ts';
2
+ import { type AclEntry, type FakeCatalogTable } from './fake-grants-read.ts';
3
+ export type { AclEntry, FakeCatalogTable };
4
+ export interface RecordedStatement {
5
+ readonly text: string;
6
+ readonly params: ReadonlyArray<unknown>;
7
+ }
8
+ export interface FakeGrants extends PgExecutor {
9
+ readonly statements: ReadonlyArray<RecordedStatement>;
10
+ /** Each `transaction` call, in order — the statement list that committed together. */
11
+ readonly transactions: ReadonlyArray<ReadonlyArray<string>>;
12
+ /** Mutable on purpose: a test seeds a "competing" grant the same way `fake-sql.ts`'s
13
+ * `databases` map is seeded before the reconcile ever runs. */
14
+ readonly acl: AclEntry[];
15
+ }
16
+ export interface FakeGrantsOptions {
17
+ /** Schemas the existence check (`pg_namespace`) answers yes for. */
18
+ readonly schemas?: ReadonlyArray<string>;
19
+ /** Roles the existence check (`pg_roles`) answers yes for. */
20
+ readonly roles?: ReadonlyArray<string>;
21
+ /** Databases the existence check (`pg_database`) answers yes for. */
22
+ readonly databases?: ReadonlyArray<string>;
23
+ /** The catalog: every relation a table/column statement may name, with its columns,
24
+ * relkind and owner (see `fake-grants-read.ts#FakeCatalogTable`). */
25
+ readonly tables?: ReadonlyArray<FakeCatalogTable>;
26
+ /** The role that owns each seeded schema; unset means the executor owns it. */
27
+ readonly schemaOwner?: string;
28
+ /** Seed grants, each carrying its own grantor (the third-grantor survival cases). */
29
+ readonly acl?: ReadonlyArray<Omit<AclEntry, 'words'> & {
30
+ readonly words: ReadonlyArray<string>;
31
+ }>;
32
+ /** The role the statements run AS — the grantor recorded on every write, and
33
+ * `current_user` on the column read (default `postgres`, the owner the fixtures assume). */
34
+ readonly executor?: string;
35
+ /** Whether the executor is a superuser (default `true`: `postgres` is). A superuser, the
36
+ * owner itself, or a member of the owning role revokes as the owner — `revoke.sgml`'s rule,
37
+ * modelled by `revokesAsOwner` (fake-grants-read.ts) on both the read and the write. */
38
+ readonly executorSuper?: boolean;
39
+ /** The roles the executor is a member of (recursively): a member of a table's owning role
40
+ * revokes that table's grants as the owner, the same as a superuser. */
41
+ readonly executorMemberships?: ReadonlyArray<string>;
42
+ /** What `current_database()` answers (default `agents`, the declaration the fixtures use). */
43
+ readonly connected?: string;
44
+ }
45
+ export declare const makeFakeGrants: (options?: FakeGrantsOptions) => FakeGrants;
46
+ //# sourceMappingURL=fake-grants-sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-grants-sql.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-grants-sql.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAc,MAAM,uBAAuB,CAAC;AAKzF,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAE3C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACtD,sFAAsF;IACtF,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D;mEAC+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,qEAAqE;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C;yEACqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAClD,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,qFAAqF;IACrF,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAClG;gGAC4F;IAC5F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;4FAEwF;IACxF,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;4EACwE;IACxE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrD,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAaD,eAAO,MAAM,cAAc,aAAa,iBAAiB,KAAQ,UA+HhE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The write-semantics half of the `Postgres.Grants` test fake, extracted from
3
+ * `fake-grants-sql.ts` (the factory and the statement parser) to keep both files under the
4
+ * cap: how one `GRANT`/`REVOKE` edits the in-memory ACL with the server's rule that a
5
+ * superuser, the owner itself, or a member of the owning role performs the command AS the
6
+ * owner (`select_best_grantor`, acl.c@REL_18_6; `revoke.sgml@REL_18_6`).
7
+ *
8
+ * ★ THE EFFECTIVE GRANTOR. `effectiveGrantor` names the role a write is recorded as: the
9
+ * owner when the executor acts as owner, otherwise the executor. A relation (table, column)
10
+ * is owned by its `relowner`; a schema by its `nspowner`; a default ACL has no owner, so the
11
+ * executor's own grants are the only ones its writes touch.
12
+ * ★ `GRANT` records the words on the effective grantor's entry, upgrading a base word to its
13
+ * `*` (WITH GRANT OPTION) form rather than keeping both — one `aclitem` per pair.
14
+ * ★ `REVOKE ALL` removes the effective grantor's entry only: a third grantor's grant to the
15
+ * same grantee SURVIVES silently (the survival `PostgresGrantsRepairRefused` surfaces), and
16
+ * a grantee that re-granted onward fails like the server without CASCADE (`2BP01`).
17
+ */
18
+ import { SqlError } from 'effect/unstable/sql/SqlError';
19
+ import type { AclObject } from './fake-grants-parse.ts';
20
+ import { type FakeGrantsModel } from './fake-grants-read.ts';
21
+ /** The role a `GRANT`/`REVOKE` from the executor on `object` is performed AS (see the header). */
22
+ export declare const effectiveGrantor: (model: FakeGrantsModel, object: AclObject) => string;
23
+ /** Add words to the (object, grantee, effective-grantor) entry, upgrading a base word to its
24
+ * `*` form rather than keeping both. */
25
+ export declare const grantWords: (model: FakeGrantsModel, object: AclObject, grantee: string, words: ReadonlyArray<string>, option: boolean) => void;
26
+ /** Remove the effective grantor's grants for (object, grantee); a third grantor's entry
27
+ * survives by the keying, and a grantee that re-granted onward fails without CASCADE. */
28
+ export declare const revoke: (model: FakeGrantsModel, object: AclObject, grantee: string, operation: string) => SqlError | undefined;
29
+ //# sourceMappingURL=fake-grants-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-grants-write.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-grants-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,QAAQ,EAAkB,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,uBAAuB,CAAC;AAQ7E,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,UAAW,eAAe,UAAU,SAAS,KAAG,MAU5E,CAAC;AAEF;wCACwC;AACxC,eAAO,MAAM,UAAU,UACd,eAAe,UACd,SAAS,WACR,MAAM,SACR,aAAa,CAAC,MAAM,CAAC,UACpB,OAAO,KACd,IAeF,CAAC;AAEF;yFACyF;AACzF,eAAO,MAAM,MAAM,UACV,eAAe,UACd,SAAS,WACR,MAAM,aACJ,MAAM,KAChB,QAAQ,GAAG,SAiBb,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `Postgres.Role` half of `fake-sql.ts`: the in-memory `pg_roles` / `pg_auth_members` catalog
3
+ * and every statement branch that touches it, split out so each fake file serves one family.
4
+ *
5
+ * ⛔ IT PARSES ITS OWN OUTPUT, NOT SQL IN GENERAL (the rule `fake-sql.ts` documents). Every
6
+ * parser here understands exactly the text `role-sql.ts` produces — quoted with `quoteIdent` /
7
+ * `quoteStringLiteral` — because that is the only `CREATE ROLE`, per-field `ALTER ROLE`,
8
+ * `GRANT`, `REVOKE` and `DROP ROLE` this family ever issues. A general SQL parser would hide a
9
+ * quoting bug instead of tripping over it.
10
+ * ★ THE DEDICATED PASSWORD `ALTER ROLE … WITH PASSWORD` IS RECORDED, NEVER PARSED: `pg_roles`
11
+ * answers no password value (S25), so the fake stores none either — the seal lives only in the
12
+ * attributes a test seeds or a reconcile returns.
13
+ */
14
+ import * as Effect from 'effect/Effect';
15
+ import type { SqlError } from 'effect/unstable/sql/SqlError';
16
+ import type { PostgresRoleAttributes } from './role-attrs.ts';
17
+ /** The role catalog `fake-sql.ts` constructs and shares with its callers: seeded by a test, then
18
+ * mutated by the statements this module applies. */
19
+ export interface FakeRoleState {
20
+ /** Bare role names, backing the `roleExists` check the database family's owner probe uses. */
21
+ readonly roleNames: Set<string>;
22
+ readonly roleRows: Map<string, PostgresRoleAttributes>;
23
+ /** `member\0parent\0grantor` triples backing `pg_auth_members` (`''` grantor = unresolvable
24
+ * grantor); `GRANT`/`REVOKE` mutate it. */
25
+ readonly memberships: Set<string>;
26
+ /** Options a name-only compare would hide, keyed `member\0parent\0grantor`. */
27
+ readonly membershipOptions: Map<string, {
28
+ readonly admin: boolean;
29
+ readonly set: boolean;
30
+ readonly inherit?: boolean;
31
+ }>;
32
+ /** Hands out the next `oid` a real cluster would assign. */
33
+ nextOid(): number;
34
+ }
35
+ /**
36
+ * Every `Postgres.Role` statement and both role reads, applied against the fake catalog. Answers
37
+ * the effect the statement produces — `undefined` when the text belongs to another family, so
38
+ * `fake-sql.ts` can fall through to its own branches.
39
+ */
40
+ export declare const applyRoleStatement: <A extends object>(state: FakeRoleState, text: string, params: ReadonlyArray<unknown>) => Effect.Effect<ReadonlyArray<A>, SqlError> | undefined;
41
+ //# sourceMappingURL=fake-role-sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-role-sql.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-role-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG9D;oDACoD;AACpD,MAAM,WAAW,aAAa;IAC5B,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACvD;+CAC2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAC7B,MAAM,EACN;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAC/E,CAAC;IACF,4DAA4D;IAC5D,OAAO,IAAI,MAAM,CAAC;CACnB;AAuDD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,SAC1C,aAAa,QACd,MAAM,UACJ,aAAa,CAAC,OAAO,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,SA6I9C,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The `Postgres.Schema` half of `fake-sql.ts`: the in-memory `pg_namespace` catalog and every
3
+ * statement branch that touches it, split out so each fake file serves one family.
4
+ *
5
+ * ⛔ IT PARSES ITS OWN OUTPUT, NOT SQL IN GENERAL (the rule `fake-sql.ts` documents). Every
6
+ * parser understands exactly the text `schema-sql.ts` produces. A general SQL parser would
7
+ * hide a quoting bug instead of tripping over it.
8
+ * ★ Reads answer `current_database()` from this fake's `database` — the same a real server
9
+ * answers for the connection it opened — and `schemaIsEmpty` from a seeded relation set.
10
+ */
11
+ import * as Effect from 'effect/Effect';
12
+ import { SqlError } from 'effect/unstable/sql/SqlError';
13
+ import type { PostgresSchemaAttributes } from './schema-attrs.ts';
14
+ /** The schema catalog `fake-sql.ts` constructs and shares with its callers. */
15
+ export interface FakeSchemaState {
16
+ readonly schemas: Map<string, PostgresSchemaAttributes>;
17
+ /** Names of schemas this fake pretends hold at least one relation. */
18
+ readonly relationsIn: Set<string>;
19
+ /** What `current_database()` answers, and the stamp on every read row. */
20
+ readonly database: string;
21
+ /** What `current_user` answers, and the owner of a `CREATE SCHEMA` without `AUTHORIZATION`. */
22
+ readonly sessionRole: string;
23
+ readonly standardConformingStrings: boolean;
24
+ /** Remaining swallowed `CREATE SCHEMA`s (the S10 lie). */
25
+ swallowRemaining: number;
26
+ /** Owner a raced `CREATE SCHEMA` stores instead, consumed once. */
27
+ raceOwner: string | undefined;
28
+ nextOid(): number;
29
+ }
30
+ /**
31
+ * Every `Postgres.Schema` statement and the reads that back it. `undefined` when the text
32
+ * belongs to another family, so `fake-sql.ts` can fall through.
33
+ *
34
+ * ⚠️ THE EMPTY CHECK BEFORE THE NAMESPACE READ: `SCHEMA_EMPTY_SQL` contains `FROM pg_namespace`,
35
+ * so a plain `includes('FROM pg_namespace')` test would swallow it.
36
+ * ⚠️ `current_database()` is `startsWith`, not `includes`: `SELECT_SCHEMA_SQL` also projects
37
+ * `current_database() AS database`.
38
+ */
39
+ export declare const applySchemaStatement: <A extends object>(state: FakeSchemaState, text: string, params: ReadonlyArray<unknown>) => Effect.Effect<ReadonlyArray<A>, SqlError> | undefined;
40
+ /** REL_18_6 pg_namespace.dat: public exists on bootstrap, owned by pg_database_owner. */
41
+ export declare const seedSchemas: (rows: readonly PostgresSchemaAttributes[] | undefined, database: string) => Map<string, PostgresSchemaAttributes>;
42
+ //# sourceMappingURL=fake-schema-sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-schema-sql.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-schema-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAgC,MAAM,8BAA8B,CAAC;AAEtF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,+EAA+E;AAC/E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACxD,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+FAA+F;IAC/F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,yBAAyB,EAAE,OAAO,CAAC;IAC5C,0DAA0D;IAC1D,gBAAgB,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,SAC5C,eAAe,QAChB,MAAM,UACJ,aAAa,CAAC,OAAO,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,SAqE9C,CAAC;AAcF,yFAAyF;AACzF,eAAO,MAAM,WAAW,SAChB,SAAS,wBAAwB,EAAE,GAAG,SAAS,YAC3C,MAAM,KACf,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAanC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Parsers for exactly the SQL `fake-sql.ts` records — the text this family's builders emit,
3
+ * not SQL in general. A general parser would hide a quoting bug instead of tripping over it.
4
+ */
5
+ import type { PostgresDatabaseAttributes } from './database-attrs.ts';
6
+ import type { PostgresSchemaAttributes } from './schema-attrs.ts';
7
+ /** Pull every field back out of exactly the text `buildCreateDatabaseSql` writes. */
8
+ export declare const parseCreate: (text: string) => PostgresDatabaseAttributes;
9
+ /** Parse exactly the text `buildCreateSchemaSql` writes. The caller stamps `database` and
10
+ * `oid`. Absent `AUTHORIZATION`, the owner is `executingRole` — Postgres's own default, the
11
+ * role `current_user` answers. */
12
+ export declare const parseCreateSchema: (text: string, executingRole: string) => Omit<PostgresSchemaAttributes, 'database' | 'oid'>;
13
+ /** Parse exactly the text `buildCommentSchemaSql` writes. */
14
+ export declare const parseCommentSchema: (text: string, standardConformingStrings?: boolean) => {
15
+ readonly name: string;
16
+ readonly comment: string;
17
+ };
18
+ /** Parse exactly the text `buildDropSchemaSql` writes. */
19
+ export declare const parseDropSchema: (text: string) => {
20
+ readonly name: string;
21
+ readonly cascade: boolean;
22
+ };
23
+ //# sourceMappingURL=fake-sql-parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-sql-parse.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-sql-parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAIlE,qFAAqF;AACrF,eAAO,MAAM,WAAW,SAAU,MAAM,KAAG,0BA4B1C,CAAC;AAEF;;kCAEkC;AAClC,eAAO,MAAM,iBAAiB,SACtB,MAAM,iBACG,MAAM,KACpB,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,KAAK,CAanD,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,SACvB,MAAM,0CAEX;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CASnD,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,eAAe,SACpB,MAAM,KACX;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAMpD,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The inverse of `quoteIdent` / `quoteStringLiteral` (`database-sql.ts`), for the fakes that
3
+ * parse their own generated statement text. One place, so the database and role fakes can never
4
+ * disagree about what a doubled quote means.
5
+ */
6
+ export declare const unquoteIdent: (raw: string) => string;
7
+ export declare const unquoteLiteral: (raw: string) => string;
8
+ /** Decode one entire literal, rejecting trailing SQL. PG18 §4.1.2.2: only E strings
9
+ * interpret backslashes when standard_conforming_strings is on. Deliberately tiny:
10
+ * accepts generated escapes, not the server's octal/hex/unicode grammar. */
11
+ export declare const parseLiteral: (text: string, standardConformingStrings?: boolean) => string;
12
+ //# sourceMappingURL=fake-sql-quote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-sql-quote.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-sql-quote.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,MAAiC,CAAC;AAE7E,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,MACG,CAAC;AAEjD;;4EAE4E;AAC5E,eAAO,MAAM,YAAY,SAAU,MAAM,0CAAqC,MAsB7E,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import type { PostgresDatabaseAttributes } from './database-attrs.ts';
2
2
  import type { PgExecutor } from './database-sql.ts';
3
+ import type { PostgresRoleAttributes } from './role-attrs.ts';
4
+ import type { PostgresSchemaAttributes } from './schema-attrs.ts';
3
5
  export interface RecordedStatement {
4
6
  readonly text: string;
5
7
  readonly params: ReadonlyArray<unknown>;
@@ -9,14 +11,54 @@ export interface FakeSql extends PgExecutor {
9
11
  /** Mutable on purpose: a test seeds a row a "competing" statement would have produced (the
10
12
  * `42P04` race case) before the fake ever sees it. */
11
13
  readonly databases: Map<string, PostgresDatabaseAttributes>;
14
+ /** Mutable on purpose: a test seeds a live role (adoption, drift) or clears one (drop). */
15
+ readonly roleRows: Map<string, PostgresRoleAttributes>;
16
+ /** `member\0parent\0grantor` triples backing `pg_auth_members` (a plain `pg_auth_members`
17
+ * read, a grant, a revoke and a DROP ROLE cascade all go through `fake-role-sql.ts`);
18
+ * `GRANT`/`REVOKE` mutate it. An empty grantor segment is an inconsistent catalog/test row. */
19
+ readonly memberships: Set<string>;
20
+ /** Options on a membership the name alone hides, keyed `member\0parent\0grantor`. Absent
21
+ * means neither ADMIN, SET nor an explicit per-grant INHERIT. */
22
+ readonly membershipOptions: Map<string, {
23
+ readonly admin: boolean;
24
+ readonly set: boolean;
25
+ readonly inherit?: boolean;
26
+ }>;
27
+ /** Mutable on purpose: a test seeds a live schema (adoption, drift) or clears one (drop). */
28
+ readonly schemas: Map<string, PostgresSchemaAttributes>;
29
+ /** Mutable on purpose: names of schemas this fake pretends hold at least one relation, so a
30
+ * `cascade: false` drop refusal has something to refuse. */
31
+ readonly relationsIn: Set<string>;
12
32
  }
13
33
  export interface FakeSqlOptions {
34
+ readonly standardConformingStrings?: boolean;
14
35
  readonly roles?: ReadonlyArray<string>;
15
36
  readonly databases?: ReadonlyArray<PostgresDatabaseAttributes>;
37
+ readonly roleRows?: ReadonlyArray<PostgresRoleAttributes>;
16
38
  /** Fail the NEXT `CREATE DATABASE` with SQLSTATE `42P04` (duplicate_database), once, the way a
17
39
  * concurrent creator racing this reconcile would — classified exactly as
18
40
  * `@effect/sql-pg`'s own driver classifies it (`database-sql.ts`'s header). */
19
41
  readonly raceNextCreate?: boolean;
42
+ /** Fail the next statement whose text starts with this prefix, once, without applying it.
43
+ * A `transaction` that included earlier statements rolls them back. */
44
+ readonly failNext?: string;
45
+ readonly schemas?: ReadonlyArray<PostgresSchemaAttributes>;
46
+ /** Names of schemas the fake answers `schemaIsEmpty` with `false` for. */
47
+ readonly schemasWithRelations?: ReadonlyArray<string>;
48
+ /** Accept the NEXT `CREATE SCHEMA` (no error) but record nothing — the S10 case where the
49
+ * write's own report is a lie and the immediate re-read finds nothing. */
50
+ readonly swallowNextCreateSchema?: boolean;
51
+ /** What `current_database()` answers and every schema row is stamped with (a real server
52
+ * always reports the database its connection opened). Default `postgres`. */
53
+ readonly database?: string;
54
+ /** The NEXT `CREATE SCHEMA` races with a row owned by THIS role — a
55
+ * concurrent creator won between the first `SELECT` and the `IF NOT EXISTS`, which then
56
+ * does nothing; plain CREATE instead fails with 42P06. Consumed once. */
57
+ readonly raceNextCreateSchema?: string;
58
+ /** What `current_user` answers, and the owner a `CREATE SCHEMA` without `AUTHORIZATION`
59
+ * stores. Default `postgres`. A test that sets this pins the omitted-owner comparison
60
+ * against the session role, not a hardcoded name. */
61
+ readonly currentUser?: string;
20
62
  }
21
63
  export declare const makeFakeSql: (options?: FakeSqlOptions) => FakeSql;
22
64
  //# sourceMappingURL=fake-sql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fake-sql.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-sql.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,OAAQ,SAAQ,UAAU;IACzC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACtD;0DACsD;IACtD,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAAC;IAC/D;;mFAE+E;IAC/E,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAoCD,eAAO,MAAM,WAAW,aAAa,cAAc,KAAQ,OAkD1D,CAAC"}
1
+ {"version":3,"file":"fake-sql.d.ts","sourceRoot":"","sources":["../../src/postgres/fake-sql.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,wB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