@noodleseed/one 0.83.0 → 0.84.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 (230) hide show
  1. package/dist/cli.d.ts.map +1 -1
  2. package/dist/cli.js +4 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/catalog-data-platform-auth.d.ts.map +1 -1
  5. package/dist/commands/catalog-data-platform-auth.js +70 -2
  6. package/dist/commands/catalog-data-platform-auth.js.map +1 -1
  7. package/dist/commands/platform-account-reset-args.d.ts +40 -0
  8. package/dist/commands/platform-account-reset-args.d.ts.map +1 -0
  9. package/dist/commands/platform-account-reset-args.js +181 -0
  10. package/dist/commands/platform-account-reset-args.js.map +1 -0
  11. package/dist/commands/platform-account-reset-files.d.ts +9 -0
  12. package/dist/commands/platform-account-reset-files.d.ts.map +1 -0
  13. package/dist/commands/platform-account-reset-files.js +45 -0
  14. package/dist/commands/platform-account-reset-files.js.map +1 -0
  15. package/dist/commands/platform-account-reset-ops.d.ts +3 -0
  16. package/dist/commands/platform-account-reset-ops.d.ts.map +1 -0
  17. package/dist/commands/platform-account-reset-ops.js +162 -0
  18. package/dist/commands/platform-account-reset-ops.js.map +1 -0
  19. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +1 -1
  20. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js.map +1 -1
  21. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js +1 -1
  22. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js.map +1 -1
  23. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  24. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts +4 -4
  25. package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts +6 -6
  26. package/node_modules/@noodle-borg/service/dist/index.d.ts +4 -1
  27. package/node_modules/@noodle-borg/service/dist/index.d.ts.map +1 -1
  28. package/node_modules/@noodle-borg/service/dist/index.js +2 -0
  29. package/node_modules/@noodle-borg/service/dist/index.js.map +1 -1
  30. package/node_modules/@noodle-borg/service/dist/main.js +5 -0
  31. package/node_modules/@noodle-borg/service/dist/main.js.map +1 -1
  32. package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.d.ts.map +1 -1
  33. package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.js +1 -0
  34. package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.js.map +1 -1
  35. package/node_modules/@noodle-borg/service/dist/oauth/provider.d.ts.map +1 -1
  36. package/node_modules/@noodle-borg/service/dist/oauth/provider.js +1 -0
  37. package/node_modules/@noodle-borg/service/dist/oauth/provider.js.map +1 -1
  38. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.d.ts.map +1 -1
  39. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.js +17 -0
  40. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.js.map +1 -1
  41. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.d.ts +2 -2
  42. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.d.ts.map +1 -1
  43. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.js +25 -5
  44. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.js.map +1 -1
  45. package/node_modules/@noodle-borg/service/dist/oauth/store.d.ts +5 -3
  46. package/node_modules/@noodle-borg/service/dist/oauth/store.d.ts.map +1 -1
  47. package/node_modules/@noodle-borg/service/dist/oauth/store.js +5 -5
  48. package/node_modules/@noodle-borg/service/dist/oauth/store.js.map +1 -1
  49. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.d.ts.map +1 -1
  50. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.js +7 -2
  51. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.js.map +1 -1
  52. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.d.ts +1 -1
  53. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.d.ts.map +1 -1
  54. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.js.map +1 -1
  55. package/node_modules/@noodle-borg/service/dist/oauth/upstream-consent.d.ts.map +1 -1
  56. package/node_modules/@noodle-borg/service/dist/oauth/upstream-consent.js +1 -1
  57. package/node_modules/@noodle-borg/service/dist/oauth/upstream-consent.js.map +1 -1
  58. package/node_modules/@noodle-borg/service/dist/oauth/upstream-federation.d.ts.map +1 -1
  59. package/node_modules/@noodle-borg/service/dist/oauth/upstream-federation.js +6 -1
  60. package/node_modules/@noodle-borg/service/dist/oauth/upstream-federation.js.map +1 -1
  61. package/node_modules/@noodle-borg/service/dist/options.d.ts +13 -0
  62. package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
  63. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.d.ts +9 -0
  64. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.d.ts.map +1 -0
  65. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.js +24 -0
  66. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.js.map +1 -0
  67. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.d.ts +12 -0
  68. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.d.ts.map +1 -0
  69. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.js +110 -0
  70. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.js.map +1 -0
  71. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.d.ts +9 -0
  72. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.d.ts.map +1 -0
  73. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.js +46 -0
  74. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.js.map +1 -0
  75. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.d.ts +77 -0
  76. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.d.ts.map +1 -0
  77. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.js +144 -0
  78. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.js.map +1 -0
  79. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.d.ts +29 -0
  80. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.d.ts.map +1 -0
  81. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.js +59 -0
  82. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.js.map +1 -0
  83. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.d.ts +11 -0
  84. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.d.ts.map +1 -0
  85. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.js +22 -0
  86. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.js.map +1 -0
  87. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.d.ts +41 -0
  88. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.d.ts.map +1 -0
  89. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.js +314 -0
  90. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.js.map +1 -0
  91. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.d.ts +14 -0
  92. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.d.ts.map +1 -0
  93. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.js +210 -0
  94. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.js.map +1 -0
  95. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.d.ts +11 -0
  96. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.d.ts.map +1 -0
  97. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.js +71 -0
  98. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.js.map +1 -0
  99. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.d.ts +12 -0
  100. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.d.ts.map +1 -0
  101. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.js +2 -0
  102. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.js.map +1 -0
  103. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.d.ts +22 -0
  104. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.d.ts.map +1 -0
  105. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.js +177 -0
  106. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.js.map +1 -0
  107. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.d.ts +35 -0
  108. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.d.ts.map +1 -0
  109. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.js +184 -0
  110. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.js.map +1 -0
  111. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.d.ts +11 -0
  112. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.d.ts.map +1 -0
  113. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.js +120 -0
  114. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.js.map +1 -0
  115. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.d.ts +79 -0
  116. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.d.ts.map +1 -0
  117. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.js +286 -0
  118. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.js.map +1 -0
  119. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.d.ts +21 -0
  120. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.d.ts.map +1 -0
  121. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.js +81 -0
  122. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.js.map +1 -0
  123. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.d.ts +46 -0
  124. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.d.ts.map +1 -0
  125. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.js +283 -0
  126. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.js.map +1 -0
  127. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.d.ts +13 -0
  128. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.d.ts.map +1 -0
  129. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.js +81 -0
  130. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.js.map +1 -0
  131. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.d.ts +30 -0
  132. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.d.ts.map +1 -0
  133. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.js +248 -0
  134. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.js.map +1 -0
  135. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.d.ts +29 -0
  136. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.d.ts.map +1 -0
  137. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.js +281 -0
  138. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.js.map +1 -0
  139. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.d.ts +55 -0
  140. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.d.ts.map +1 -0
  141. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.js +262 -0
  142. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.js.map +1 -0
  143. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.d.ts +7 -0
  144. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.d.ts.map +1 -0
  145. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.js +439 -0
  146. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.js.map +1 -0
  147. package/node_modules/@noodle-borg/service/dist/platform-account-reset.d.ts +276 -0
  148. package/node_modules/@noodle-borg/service/dist/platform-account-reset.d.ts.map +1 -0
  149. package/node_modules/@noodle-borg/service/dist/platform-account-reset.js +141 -0
  150. package/node_modules/@noodle-borg/service/dist/platform-account-reset.js.map +1 -0
  151. package/node_modules/@noodle-borg/service/dist/platform-auth-configuration.d.ts +1 -1
  152. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-legacy-sources-postgres.d.ts.map +1 -1
  153. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-legacy-sources-postgres.js +5 -1
  154. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-legacy-sources-postgres.js.map +1 -1
  155. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-local-subjects-postgres.d.ts.map +1 -1
  156. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-local-subjects-postgres.js +10 -1
  157. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-local-subjects-postgres.js.map +1 -1
  158. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.d.ts +5 -10
  159. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.d.ts.map +1 -1
  160. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.js +86 -47
  161. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.js.map +1 -1
  162. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.d.ts +17 -0
  163. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.d.ts.map +1 -0
  164. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.js +240 -0
  165. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.js.map +1 -0
  166. package/node_modules/@noodle-borg/service/dist/platform-auth-operator.d.ts +63 -63
  167. package/node_modules/@noodle-borg/service/dist/platform-auth-rollout-support.d.ts +1 -1
  168. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.d.ts +18 -1
  169. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.d.ts.map +1 -1
  170. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.js +97 -2
  171. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.js.map +1 -1
  172. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.d.ts +4 -1
  173. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.d.ts.map +1 -1
  174. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.js +4 -0
  175. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.js.map +1 -1
  176. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.d.ts +7 -2
  177. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.d.ts.map +1 -1
  178. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.js +24 -2
  179. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.js.map +1 -1
  180. package/node_modules/@noodle-borg/service/dist/platform-identity-schema-postgres.d.ts.map +1 -1
  181. package/node_modules/@noodle-borg/service/dist/platform-identity-schema-postgres.js +4 -0
  182. package/node_modules/@noodle-borg/service/dist/platform-identity-schema-postgres.js.map +1 -1
  183. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.d.ts +7 -1
  184. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.d.ts.map +1 -1
  185. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.js +121 -8
  186. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.js.map +1 -1
  187. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-recovery-postgres.d.ts.map +1 -1
  188. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-recovery-postgres.js +11 -1
  189. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-recovery-postgres.js.map +1 -1
  190. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.d.ts +5 -3
  191. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.d.ts.map +1 -1
  192. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.js +15 -1
  193. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.js.map +1 -1
  194. package/node_modules/@noodle-borg/service/dist/platform-identity.d.ts +23 -2
  195. package/node_modules/@noodle-borg/service/dist/platform-identity.d.ts.map +1 -1
  196. package/node_modules/@noodle-borg/service/dist/platform-identity.js +21 -0
  197. package/node_modules/@noodle-borg/service/dist/platform-identity.js.map +1 -1
  198. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts +8 -0
  199. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts.map +1 -1
  200. package/node_modules/@noodle-borg/service/dist/registry-state.js +15 -2
  201. package/node_modules/@noodle-borg/service/dist/registry-state.js.map +1 -1
  202. package/node_modules/@noodle-borg/service/dist/registry.d.ts +2 -0
  203. package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
  204. package/node_modules/@noodle-borg/service/dist/registry.js +4 -1
  205. package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
  206. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.d.ts +8 -0
  207. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.d.ts.map +1 -0
  208. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.js +36 -0
  209. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.js.map +1 -0
  210. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.d.ts +22 -0
  211. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.d.ts.map +1 -0
  212. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.js +201 -0
  213. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.js.map +1 -0
  214. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.d.ts +18 -0
  215. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.d.ts.map +1 -0
  216. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.js +36 -0
  217. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.js.map +1 -0
  218. package/node_modules/@noodle-borg/service/dist/serve-options.d.ts +2 -1
  219. package/node_modules/@noodle-borg/service/dist/serve-options.d.ts.map +1 -1
  220. package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
  221. package/node_modules/@noodle-borg/service/dist/serve.js +16 -1
  222. package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
  223. package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
  224. package/node_modules/@noodle-borg/service/dist/service.js +4 -5
  225. package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
  226. package/node_modules/@noodle-borg/service/dist/workos-directory.d.ts +22 -3
  227. package/node_modules/@noodle-borg/service/dist/workos-directory.d.ts.map +1 -1
  228. package/node_modules/@noodle-borg/service/dist/workos-directory.js +56 -5
  229. package/node_modules/@noodle-borg/service/dist/workos-directory.js.map +1 -1
  230. package/package.json +1 -1
@@ -1,12 +1,56 @@
1
+ import { PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX } from './platform-auth-inventory-source-fence-transaction-postgres.js';
1
2
  import { PLATFORM_AUTH_INVENTORY_AUTHORITY_SOURCES, } from './platform-auth-inventory-sources.js';
2
3
  import { PlatformAuthMigrationError } from './platform-auth-migration.js';
4
+ export { acquirePlatformAuthInventorySourceFence, releasePlatformAuthInventorySourceFence, runPlatformAuthInventorySourceFenceTransaction, } from './platform-auth-inventory-source-fence-transaction-postgres.js';
3
5
  const SOURCE_FENCE_TRIGGER = 'platform_auth_inventory_source_epoch_trigger';
4
- const SOURCE_FENCE_LOCK_PREFIX = 'platform-auth-inventory-source-fence:v1:';
6
+ export const PLATFORM_ACCOUNT_RESET_PREVIEW_TABLES = [
7
+ 'apps',
8
+ 'billing_account_defaults',
9
+ 'billing_account_members',
10
+ 'billing_accounts',
11
+ 'billing_stripe_customers',
12
+ 'billing_stripe_subscription_bindings',
13
+ 'deploy_records',
14
+ 'developer_access_grants',
15
+ 'environments',
16
+ 'oauth_authorization_codes',
17
+ 'oauth_consent_grant_provenance',
18
+ 'oauth_consent_grants',
19
+ 'oauth_device_authorizations',
20
+ 'oauth_refresh_tokens',
21
+ 'org_billing_home_accounts',
22
+ 'org_billing_links',
23
+ 'org_members',
24
+ 'orgs',
25
+ 'personal_workspace_bindings',
26
+ 'platform_auth_rollout_state',
27
+ 'platform_identity_links',
28
+ 'platform_principals',
29
+ 'platform_verified_emails',
30
+ 'repo_connections',
31
+ 'state_handle_records',
32
+ 'welcome_email_outbox',
33
+ 'workos_import_attempt_evidence',
34
+ 'workos_import_ledger',
35
+ ];
36
+ export const PLATFORM_ACCOUNT_RESET_EXECUTION_TABLES = [
37
+ ...PLATFORM_ACCOUNT_RESET_PREVIEW_TABLES,
38
+ 'identity_migration_runs',
39
+ 'platform_account_reset_cleanup_ledger',
40
+ 'platform_account_reset_email_reservations',
41
+ 'platform_account_reset_events',
42
+ 'platform_account_reset_operations',
43
+ 'platform_account_reset_rollback_previews',
44
+ 'platform_account_reset_targets',
45
+ 'platform_auth_inventory_candidates',
46
+ 'platform_identity_sync_outbox',
47
+ ];
5
48
  export const PLATFORM_AUTH_INVENTORY_CANONICAL_TABLES = [
6
49
  'platform_principals',
7
50
  'platform_identity_links',
8
51
  'platform_verified_emails',
9
52
  ];
53
+ const PLATFORM_AUTH_INVENTORY_COMPANION_TABLES = ['oauth_consent_grant_provenance'];
10
54
  /** Installs additive, statement-level change evidence without serializing writers on a counter row. */
11
55
  export async function ensurePlatformAuthInventorySourceFenceSchema(pool) {
12
56
  await pool.query(`
@@ -30,7 +74,7 @@ export async function ensurePlatformAuthInventorySourceFenceSchema(pool) {
30
74
  CREATE OR REPLACE FUNCTION platform_auth_inventory_bump_source_epoch() RETURNS trigger AS $$
31
75
  BEGIN
32
76
  PERFORM pg_advisory_xact_lock_shared(
33
- hashtextextended('${SOURCE_FENCE_LOCK_PREFIX}' || TG_TABLE_SCHEMA, 0)
77
+ hashtextextended('${PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX}' || TG_TABLE_SCHEMA, 0)
34
78
  );
35
79
  PERFORM nextval(
36
80
  format('%I.%I', TG_TABLE_SCHEMA, 'platform_auth_inventory_source_epoch_seq')::regclass
@@ -43,57 +87,60 @@ export async function ensurePlatformAuthInventorySourceFenceSchema(pool) {
43
87
  }
44
88
  /** Reconciles triggers after later service schema initializers create their owned source tables. */
45
89
  export async function installPlatformAuthInventorySourceFenceTriggers(pool) {
46
- const foundation = await pool.query(`SELECT to_regclass('platform_auth_inventory_source_epoch_seq')::text AS sequence,
47
- to_regprocedure('platform_auth_inventory_bump_source_epoch()')::text AS fn`);
90
+ const foundation = await pool.query(`SELECT current_schema() AS schema_name,
91
+ to_regclass(format(
92
+ '%I.%I', current_schema(), 'platform_auth_inventory_source_epoch_seq'
93
+ ))::text AS sequence,
94
+ to_regprocedure(format(
95
+ '%I.%I()', current_schema(), 'platform_auth_inventory_bump_source_epoch'
96
+ ))::text AS fn`);
48
97
  const foundationRow = foundation.rows[0];
49
- if (foundationRow === undefined || foundationRow.sequence === null || foundationRow.fn === null)
98
+ if (foundationRow === undefined ||
99
+ foundationRow.schema_name === null ||
100
+ foundationRow.sequence === null ||
101
+ foundationRow.fn === null)
50
102
  return;
103
+ const schema = quoteIdentifier(foundationRow.schema_name);
51
104
  for (const table of [
52
105
  ...PLATFORM_AUTH_INVENTORY_CANONICAL_TABLES,
53
106
  ...PLATFORM_AUTH_INVENTORY_AUTHORITY_SOURCES,
107
+ ...PLATFORM_AUTH_INVENTORY_COMPANION_TABLES,
54
108
  ]) {
55
- const relation = await pool.query('SELECT relkind::text FROM pg_class WHERE oid = to_regclass($1)', [table]);
109
+ const relation = await pool.query('SELECT relkind::text FROM pg_class WHERE oid = to_regclass($1)', [`${schema}.${quoteIdentifier(table)}`]);
56
110
  if (relation.rows[0]?.relkind !== 'r' && relation.rows[0]?.relkind !== 'p')
57
111
  continue;
58
- const installed = await pool.query(`SELECT 1 FROM pg_trigger
59
- WHERE tgrelid = to_regclass($1) AND tgname = $2 AND NOT tgisinternal
60
- AND tgenabled <> 'D'
61
- AND tgfoid = to_regprocedure('platform_auth_inventory_bump_source_epoch()')`, [table, SOURCE_FENCE_TRIGGER]);
62
- if (installed.rows[0] !== undefined)
63
- continue;
64
- await pool.query(`CREATE TRIGGER ${SOURCE_FENCE_TRIGGER}
65
- AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON "${table}"
66
- FOR EACH STATEMENT EXECUTE FUNCTION platform_auth_inventory_bump_source_epoch()`);
112
+ await pool.query(`CREATE OR REPLACE TRIGGER ${SOURCE_FENCE_TRIGGER}
113
+ AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON ${schema}.${quoteIdentifier(table)}
114
+ FOR EACH STATEMENT EXECUTE FUNCTION ${schema}.platform_auth_inventory_bump_source_epoch()`);
67
115
  }
68
116
  }
69
117
  export async function assertPlatformAuthInventorySourceFence(pool, manifest) {
70
118
  const required = [
71
119
  ...PLATFORM_AUTH_INVENTORY_CANONICAL_TABLES,
72
120
  ...PLATFORM_AUTH_INVENTORY_AUTHORITY_SOURCES.filter((source) => manifest[source] === 'configured'),
121
+ ...(manifest.oauth_consent_grants === 'configured'
122
+ ? PLATFORM_AUTH_INVENTORY_COMPANION_TABLES
123
+ : []),
73
124
  ];
74
125
  const coverage = await pool.query(`SELECT required.table_name
75
126
  FROM unnest($1::text[]) AS required(table_name)
76
- WHERE to_regclass(required.table_name) IS NULL
127
+ WHERE to_regclass(format('%I.%I', current_schema(), required.table_name)) IS NULL
77
128
  OR NOT EXISTS (
78
129
  SELECT 1 FROM pg_trigger trigger
79
- WHERE trigger.tgrelid = to_regclass(required.table_name)
130
+ WHERE trigger.tgrelid =
131
+ to_regclass(format('%I.%I', current_schema(), required.table_name))
80
132
  AND trigger.tgname = $2 AND NOT trigger.tgisinternal
81
133
  AND trigger.tgenabled <> 'D'
82
134
  AND trigger.tgfoid =
83
- to_regprocedure('platform_auth_inventory_bump_source_epoch()')
135
+ to_regprocedure(format(
136
+ '%I.%I()', current_schema(), 'platform_auth_inventory_bump_source_epoch'
137
+ ))
84
138
  )`, [required, SOURCE_FENCE_TRIGGER]);
85
139
  if (coverage.rows.length !== 0)
86
140
  throw new PlatformAuthMigrationError('inventory_unavailable');
87
141
  }
88
- export async function acquirePlatformAuthInventorySourceFence(connection) {
89
- await connection.query(`SELECT pg_advisory_lock(
90
- hashtextextended($1 || current_schema(), 0)
91
- )`, [SOURCE_FENCE_LOCK_PREFIX]);
92
- }
93
- export async function releasePlatformAuthInventorySourceFence(connection) {
94
- await connection.query(`SELECT pg_advisory_unlock(
95
- hashtextextended($1 || current_schema(), 0)
96
- )`, [SOURCE_FENCE_LOCK_PREFIX]);
142
+ function quoteIdentifier(value) {
143
+ return `"${value.replaceAll('"', '""')}"`;
97
144
  }
98
145
  export async function readPlatformAuthInventorySourceEpoch(pool) {
99
146
  const result = await pool.query('SELECT last_value::text AS epoch FROM platform_auth_inventory_source_epoch_seq');
@@ -102,25 +149,17 @@ export async function readPlatformAuthInventorySourceEpoch(pool) {
102
149
  throw new PlatformAuthMigrationError('inventory_unavailable');
103
150
  return epoch;
104
151
  }
105
- export async function runPlatformAuthInventorySourceFenceTransaction(pool, task) {
106
- const connection = pool.connect === undefined ? pool : await pool.connect();
107
- let sourceFenceHeld = false;
108
- try {
109
- await acquirePlatformAuthInventorySourceFence(connection);
110
- sourceFenceHeld = true;
111
- await connection.query('BEGIN ISOLATION LEVEL REPEATABLE READ');
112
- const result = await task(connection);
113
- await connection.query('COMMIT');
114
- return result;
115
- }
116
- catch (error) {
117
- await connection.query('ROLLBACK').catch(() => undefined);
118
- throw error;
119
- }
120
- finally {
121
- if (sourceFenceHeld)
122
- await releasePlatformAuthInventorySourceFence(connection).catch(() => undefined);
123
- connection.release?.();
124
- }
152
+ /** Serializes reset previews/execution for the same immutable principal IDs, independent of input order. */
153
+ export async function lockPlatformAuthInventorySourceFenceTargets(connection, principalIds) {
154
+ const targets = [...new Set(principalIds)].sort((left, right) => left.localeCompare(right));
155
+ for (const target of targets)
156
+ await connection.query(`SELECT pg_advisory_xact_lock(
157
+ hashtextextended('platform-account-reset-target:' || $1, 0)
158
+ )`, [target]);
159
+ await connection.query(`SELECT principal_id
160
+ FROM platform_principals
161
+ WHERE principal_id = ANY($1::text[])
162
+ ORDER BY principal_id
163
+ FOR SHARE`, [targets]);
125
164
  }
126
165
  //# sourceMappingURL=platform-auth-inventory-source-fence-postgres.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-auth-inventory-source-fence-postgres.js","sourceRoot":"","sources":["../src/platform-auth-inventory-source-fence-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yCAAyC,GAE1C,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAM1E,MAAM,oBAAoB,GAAG,8CAA8C,CAAC;AAC5E,MAAM,wBAAwB,GAAG,0CAA0C,CAAC;AAC5E,MA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e,EACf,IAAiD;IAEjD,MAAM,UAAU,GAAoB,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7F,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC;QACH,MAAM,uCAAuC,CAAC,UAAU,CAAC,CAAC;QAC1D,eAAe,GAAG,IAAI,CAAC;QACvB,MAAM,UAAU,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;QACtC,MAAM,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,eAAe;YACjB,MAAM,uCAAuC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACnF,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"platform-auth-inventory-source-fence-postgres.js","sourceRoot":"","sources":["../src/platform-auth-inventory-source-fence-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gDAAgD,EAAE,MAAM,gEAAgE,CAAC;AAClI,OAAO,EACL,yCAAyC,GAE1C,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,EACL,uCAAuC,EACvC,uCAAuC,EACvC,8CAA8C,GAC/C,MAAM,gEAAgE,CAAC;AAExE,MAAM,oBAAoB,GAAG,8CAA8C,CAAC;A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CAC/B;;;;;;;;;;;;;cAaU,EACV,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CACjC,CAAC;IACF,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,0BAA0B,CAAC,uBAAuB,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oCAAoC,CACxD,IAA+B;IAE/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAC7B,gFAAgF,CACjF,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,0BAA0B,CAAC,uBAAuB,CAAC,CAAC;IACvF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,4GAA4G;AAC5G,MAAM,CAAC,KAAK,UAAU,2CAA2C,CAC/D,UAAqC,EACrC,YAA+B;IAE/B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5F,KAAK,MAAM,MAAM,IAAI,OAAO;QAC1B,MAAM,UAAU,CAAC,KAAK,CACpB;;SAEG,EACH,CAAC,MAAM,CAAC,CACT,CAAC;IACJ,MAAM,UAAU,CAAC,KAAK,CACpB;;;;gBAIY,EACZ,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { PlatformIdentityQueryable } from './platform-identity-postgres.js';
2
+ type FenceConnection = PlatformIdentityQueryable & {
3
+ release?: (error?: Error) => void;
4
+ };
5
+ type FencePool = PlatformIdentityQueryable & {
6
+ connect?: () => Promise<FenceConnection>;
7
+ };
8
+ export declare const PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX = "platform-auth-inventory-source-fence:v1:";
9
+ export declare function acquirePlatformAuthInventorySourceFence(connection: PlatformIdentityQueryable): Promise<void>;
10
+ export declare function releasePlatformAuthInventorySourceFence(connection: PlatformIdentityQueryable): Promise<void>;
11
+ export declare function runPlatformAuthInventorySourceFenceTransaction<T>(pool: FencePool, task: (connection: FenceConnection) => Promise<T>, options?: {
12
+ readonly lockTables?: readonly string[];
13
+ readonly lockTimeoutMs?: number;
14
+ readonly statementTimeoutMs?: number;
15
+ }): Promise<T>;
16
+ export {};
17
+ //# sourceMappingURL=platform-auth-inventory-source-fence-transaction-postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-auth-inventory-source-fence-transaction-postgres.d.ts","sourceRoot":"","sources":["../src/platform-auth-inventory-source-fence-transaction-postgres.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,KAAK,eAAe,GAAG,yBAAyB,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;CAAE,CAAC;AACzF,KAAK,SAAS,GAAG,yBAAyB,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,CAAC;AAE1F,eAAO,MAAM,gDAAgD,6CACjB,CAAC;AAE7C,wBAAsB,uCAAuC,CAC3D,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,uCAAuC,CAC3D,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAsB,8CAA8C,CAAC,CAAC,EACpE,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,EACjD,OAAO,GAAE;IACP,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACjC,GACL,OAAO,CAAC,CAAC,CAAC,CAmGZ"}
@@ -0,0 +1,240 @@
1
+ import { PlatformAuthMigrationError } from './platform-auth-migration.js';
2
+ export const PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX = 'platform-auth-inventory-source-fence:v1:';
3
+ export async function acquirePlatformAuthInventorySourceFence(connection) {
4
+ await connection.query(`SELECT pg_advisory_lock(
5
+ hashtextextended($1 || current_schema(), 0)
6
+ )`, [PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX]);
7
+ }
8
+ export async function releasePlatformAuthInventorySourceFence(connection) {
9
+ const unlocked = await connection.query(`SELECT pg_advisory_unlock(
10
+ hashtextextended($1 || current_schema(), 0)
11
+ ) AS unlocked`, [PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX]);
12
+ if (unlocked.rows[0]?.unlocked !== true)
13
+ throw new PlatformAuthMigrationError('inventory_unavailable');
14
+ }
15
+ export async function runPlatformAuthInventorySourceFenceTransaction(pool, task, options = {}) {
16
+ const lockTables = validatedPlatformAuthInventoryFenceTables(options.lockTables);
17
+ const deadline = platformAuthInventoryFenceDeadline(options);
18
+ const connection = pool.connect === undefined
19
+ ? pool
20
+ : await connectPlatformAuthInventoryFenceWithinDeadline(pool.connect.bind(pool), deadline);
21
+ const taskConnection = budgetedPlatformAuthInventoryFenceConnection(connection, deadline, options);
22
+ let sourceFenceHeld = false;
23
+ let transactionStarted = false;
24
+ let completed = false;
25
+ let result;
26
+ let failed = false;
27
+ let failure;
28
+ try {
29
+ if (lockTables.length === 0) {
30
+ await acquirePlatformAuthInventorySourceFenceWithinDeadline(connection, deadline);
31
+ sourceFenceHeld = true;
32
+ }
33
+ await queryPlatformAuthInventoryFenceWithinDeadline(connection, 'BEGIN ISOLATION LEVEL REPEATABLE READ', undefined, deadline);
34
+ transactionStarted = true;
35
+ await setPlatformAuthInventoryFenceTransactionTimeouts(connection, options, deadline);
36
+ if (lockTables.length !== 0)
37
+ await queryPlatformAuthInventoryFenceWithinDeadline(connection, `LOCK TABLE ${lockTables.map((table) => `"${table}"`).join(', ')} IN SHARE MODE`, undefined, deadline);
38
+ if (lockTables.length !== 0) {
39
+ await acquirePlatformAuthInventorySourceFenceWithinDeadline(connection, deadline);
40
+ sourceFenceHeld = true;
41
+ }
42
+ result = await runPlatformAuthInventoryFenceWithinDeadline(task(taskConnection.connection), deadline);
43
+ await setPlatformAuthInventoryFenceTransactionTimeouts(connection, options, deadline);
44
+ await queryPlatformAuthInventoryFenceWithinDeadline(connection, 'COMMIT', undefined, deadline);
45
+ transactionStarted = false;
46
+ completed = true;
47
+ }
48
+ catch (error) {
49
+ failed = true;
50
+ failure = error;
51
+ }
52
+ taskConnection.abort();
53
+ let cleanupFailed = false;
54
+ let cleanupFailure;
55
+ if (transactionStarted) {
56
+ try {
57
+ await queryPlatformAuthInventoryFenceWithinDeadline(connection, 'ROLLBACK', undefined, deadline);
58
+ transactionStarted = false;
59
+ }
60
+ catch (error) {
61
+ cleanupFailed = true;
62
+ cleanupFailure = error;
63
+ }
64
+ }
65
+ if (sourceFenceHeld && !cleanupFailed) {
66
+ try {
67
+ await releasePlatformAuthInventorySourceFenceWithinDeadline(connection, deadline);
68
+ sourceFenceHeld = false;
69
+ }
70
+ catch (error) {
71
+ cleanupFailed = true;
72
+ cleanupFailure = error;
73
+ }
74
+ }
75
+ const unsafeFailure = cleanupFailed ||
76
+ failure instanceof PlatformAuthInventoryFenceDeadlineError ||
77
+ platformAuthInventoryFenceDeadlineElapsed(deadline)
78
+ ? platformAuthInventoryFenceError(cleanupFailure ?? failure)
79
+ : undefined;
80
+ try {
81
+ connection.release?.(unsafeFailure);
82
+ }
83
+ catch (error) {
84
+ cleanupFailed = true;
85
+ cleanupFailure ??= error;
86
+ }
87
+ if (failed)
88
+ throw failure;
89
+ if (cleanupFailed)
90
+ throw cleanupFailure;
91
+ if (!completed)
92
+ throw new PlatformAuthMigrationError('inventory_unavailable');
93
+ return result;
94
+ }
95
+ class PlatformAuthInventoryFenceDeadlineError extends PlatformAuthMigrationError {
96
+ constructor() {
97
+ super('inventory_unavailable');
98
+ this.name = 'PlatformAuthInventoryFenceDeadlineError';
99
+ }
100
+ }
101
+ async function connectPlatformAuthInventoryFenceWithinDeadline(connect, deadline) {
102
+ const acquisition = connect();
103
+ try {
104
+ return await runPlatformAuthInventoryFenceWithinDeadline(acquisition, deadline);
105
+ }
106
+ catch (error) {
107
+ void acquisition.then((connection) => {
108
+ try {
109
+ connection.release?.(platformAuthInventoryFenceError(error));
110
+ }
111
+ catch {
112
+ // The pool already rejected acquisition; there is no further safe cleanup path.
113
+ }
114
+ }, () => undefined);
115
+ throw error;
116
+ }
117
+ }
118
+ async function queryPlatformAuthInventoryFenceWithinDeadline(connection, sql, values, deadline) {
119
+ assertPlatformAuthInventoryFenceWithinDeadline(deadline);
120
+ return runPlatformAuthInventoryFenceWithinDeadline(values === undefined ? connection.query(sql) : connection.query(sql, values), deadline);
121
+ }
122
+ async function releasePlatformAuthInventorySourceFenceWithinDeadline(connection, deadline) {
123
+ const unlocked = await queryPlatformAuthInventoryFenceWithinDeadline(connection, `SELECT pg_advisory_unlock(
124
+ hashtextextended($1 || current_schema(), 0)
125
+ ) AS unlocked`, [PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX], deadline);
126
+ if (unlocked.rows[0]?.unlocked !== true)
127
+ throw new PlatformAuthMigrationError('inventory_unavailable');
128
+ }
129
+ function platformAuthInventoryFenceError(error) {
130
+ return error instanceof Error ? error : new PlatformAuthMigrationError('inventory_unavailable');
131
+ }
132
+ function platformAuthInventoryFenceDeadlineElapsed(deadline) {
133
+ return deadline !== undefined && performance.now() >= deadline;
134
+ }
135
+ async function setPlatformAuthInventoryFenceTransactionTimeouts(connection, options, deadline = platformAuthInventoryFenceDeadline(options)) {
136
+ for (const [setting, timeout] of [
137
+ ['lock_timeout', options.lockTimeoutMs],
138
+ ['statement_timeout', options.statementTimeoutMs],
139
+ ]) {
140
+ if (timeout === undefined)
141
+ continue;
142
+ if (!Number.isSafeInteger(timeout) || timeout <= 0)
143
+ throw new PlatformAuthMigrationError('inventory_unavailable');
144
+ const remaining = remainingPlatformAuthInventoryFenceMilliseconds(deadline);
145
+ await queryPlatformAuthInventoryFenceWithinDeadline(connection, `SET LOCAL ${setting} TO '${Math.min(timeout, remaining)}ms'`, undefined, deadline);
146
+ }
147
+ }
148
+ function validatedPlatformAuthInventoryFenceTables(tables) {
149
+ const validated = [...new Set(tables ?? [])].sort();
150
+ if (validated.some((table) => !/^[a-z][a-z0-9_]*$/.test(table)))
151
+ throw new PlatformAuthMigrationError('inventory_unavailable');
152
+ return validated;
153
+ }
154
+ function platformAuthInventoryFenceDeadline(options) {
155
+ const configured = [options.lockTimeoutMs, options.statementTimeoutMs].filter((value) => value !== undefined);
156
+ for (const timeout of configured)
157
+ if (!Number.isSafeInteger(timeout) || timeout <= 0)
158
+ throw new PlatformAuthMigrationError('inventory_unavailable');
159
+ return configured.length === 0 ? undefined : performance.now() + Math.min(...configured);
160
+ }
161
+ async function acquirePlatformAuthInventorySourceFenceWithinDeadline(connection, deadline) {
162
+ if (deadline === undefined) {
163
+ await acquirePlatformAuthInventorySourceFence(connection);
164
+ return;
165
+ }
166
+ for (;;) {
167
+ assertPlatformAuthInventoryFenceWithinDeadline(deadline);
168
+ const acquired = await queryPlatformAuthInventoryFenceWithinDeadline(connection, `SELECT pg_try_advisory_lock(
169
+ hashtextextended($1 || current_schema(), 0)
170
+ ) AS acquired`, [PLATFORM_AUTH_INVENTORY_SOURCE_FENCE_LOCK_PREFIX], deadline);
171
+ if (acquired.rows[0]?.acquired === true)
172
+ return;
173
+ await delayPlatformAuthInventoryFence(Math.min(10, remainingPlatformAuthInventoryFenceMilliseconds(deadline)));
174
+ }
175
+ }
176
+ function budgetedPlatformAuthInventoryFenceConnection(connection, deadline, options) {
177
+ if (deadline === undefined)
178
+ return { connection, abort: () => undefined };
179
+ let aborted = false;
180
+ let pending = Promise.resolve();
181
+ return {
182
+ connection: {
183
+ query: (sql, values) => {
184
+ const query = pending.then(async () => {
185
+ if (aborted)
186
+ throw new PlatformAuthMigrationError('inventory_unavailable');
187
+ await setPlatformAuthInventoryFenceTransactionTimeouts(connection, options, deadline);
188
+ if (aborted)
189
+ throw new PlatformAuthMigrationError('inventory_unavailable');
190
+ return queryPlatformAuthInventoryFenceWithinDeadline(connection, sql, values, deadline);
191
+ });
192
+ pending = query.then(() => undefined, () => undefined);
193
+ return query;
194
+ },
195
+ },
196
+ abort: () => {
197
+ aborted = true;
198
+ },
199
+ };
200
+ }
201
+ async function runPlatformAuthInventoryFenceWithinDeadline(operation, deadline) {
202
+ if (deadline === undefined)
203
+ return operation;
204
+ let remaining;
205
+ try {
206
+ remaining = remainingPlatformAuthInventoryFenceMilliseconds(deadline);
207
+ }
208
+ catch (error) {
209
+ void operation.catch(() => undefined);
210
+ throw error;
211
+ }
212
+ let timeout;
213
+ try {
214
+ return await Promise.race([
215
+ operation,
216
+ new Promise((_, reject) => {
217
+ timeout = setTimeout(() => reject(new PlatformAuthInventoryFenceDeadlineError()), remaining);
218
+ }),
219
+ ]);
220
+ }
221
+ finally {
222
+ if (timeout !== undefined)
223
+ clearTimeout(timeout);
224
+ }
225
+ }
226
+ function remainingPlatformAuthInventoryFenceMilliseconds(deadline) {
227
+ if (deadline === undefined)
228
+ return Number.MAX_SAFE_INTEGER;
229
+ const remaining = Math.ceil(deadline - performance.now());
230
+ if (remaining <= 0)
231
+ throw new PlatformAuthInventoryFenceDeadlineError();
232
+ return remaining;
233
+ }
234
+ function assertPlatformAuthInventoryFenceWithinDeadline(deadline) {
235
+ remainingPlatformAuthInventoryFenceMilliseconds(deadline);
236
+ }
237
+ function delayPlatformAuthInventoryFence(milliseconds) {
238
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
239
+ }
240
+ //# sourceMappingURL=platform-auth-inventory-source-fence-transaction-postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-auth-inventory-source-fence-transaction-postgres.js","sourceRoot":"","sources":["../src/platform-auth-inventory-source-fence-transaction-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAM1E,MAAM,CAAC,MAAM,gDAAgD,GAC3D,0CAA0C,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAC3D,UAAqC;IAErC,MAAM,UAAU,CAAC,KAAK,CACpB;;OAEG,EACH,CAAC,gDAAgD,CAAC,CACnD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAC3D,UAAqC;IAErC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,KAAK,CACrC;;mBAEe,EACf,CAAC,gDAAgD,CAAC,CACnD,CAAC;IACF,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI;QACrC,MAAM,IAAI,0BAA0B,CAAC,uBAAuB,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8CAA8C,CAClE,IAAe,EACf,IAAiD,EACjD,UAII,EAAE;IAEN,MAAM,UAAU,GAAG,yCAAyC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,UAAU,GACd,IAAI,CAAC,OAAO,KAAK,SAAS;QACxB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM,+CAA+C,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,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