permdock 0.25.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/2020-bJfT8aIA.js +6760 -0
- package/dist/a2a/index.d.ts +5 -9
- package/dist/a2a/index.js +13 -15
- package/dist/adapter-context-lHq_i_77.js +28 -0
- package/dist/adoption-scan-b0_Xpab8.js +106 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/ai-sdk/index.d.ts +4 -6
- package/dist/ai-sdk/index.js +6 -7
- package/dist/annotate-doc-BCOCOrq_.js +214 -0
- package/dist/annotate-routes-BvSuEht3.js +75 -0
- package/dist/annotate-uZVGIRym.js +25 -0
- package/dist/app/index.d.ts +2 -103
- package/dist/app/index.js +1 -114
- package/dist/app-data-DbSPSPIl.js +62 -0
- package/dist/approval-header-BvszJE3l.js +25 -0
- package/dist/approval-normalize-Cpp8R0rY.js +190 -0
- package/dist/approval-prompt-C-vjNZyd.d.ts +57 -0
- package/dist/approval-prompt-Covyx_DB.js +60 -0
- package/dist/approval-required-B-R4Yw3J.js +5 -0
- package/dist/approvals/index.d.ts +5 -5
- package/dist/approvals/index.js +8 -8
- package/dist/approvals-7jHYXocE.js +1039 -0
- package/dist/approvers-BkY_ZfWl.js +76 -0
- package/dist/arazzo-DMmcumRx.js +76 -0
- package/dist/arazzo-Hxerfx3_.js +35 -0
- package/dist/args-0EWFk-4S.js +311 -0
- package/dist/astro/index.d.ts +6 -8
- package/dist/astro/index.js +3 -4
- package/dist/audience-DauhRBNg.js +54 -0
- package/dist/auth-WHKYWtnS.js +187 -0
- package/dist/authz-topic-D8x24Jv-.js +14 -0
- package/dist/authzen/index.d.ts +37 -22
- package/dist/authzen/index.js +69 -27
- package/dist/automation-CUcWz8uu.d.ts +122 -0
- package/dist/automation-CpPdFX91.js +157 -0
- package/dist/base-url--yJPQlIK.js +8 -0
- package/dist/better-auth/index.d.ts +2 -8
- package/dist/better-auth/index.js +10 -13
- package/dist/better-supabase/index.d.ts +141 -95
- package/dist/better-supabase/index.js +239 -794
- package/dist/better-supabase-DSbs4MtQ.js +201 -0
- package/dist/bind-B3MHrzw4.d.ts +56 -0
- package/dist/bind-up3QptTt.js +124 -0
- package/dist/body-W1_8r6Tw.js +9 -0
- package/dist/body-text-B-m3p-qY.js +55 -0
- package/dist/boundary--5Swp7sN.js +18 -0
- package/dist/boundary-DJqHADKu.d.ts +22 -0
- package/dist/budget-5LJ8kfZk.d.ts +12 -0
- package/dist/budget-BH81q2cj.js +19 -0
- package/dist/build-instance-hLKYe3-E.js +30 -0
- package/dist/canonical-json-BibZkXtE.js +28 -0
- package/dist/capability-CVt3lpVK.d.ts +128 -0
- package/dist/capability-_ZsyfYxU.js +204 -0
- package/dist/casbin-CYwbggCS.js +29 -0
- package/dist/casbin-Co1KcLWU.js +241 -0
- package/dist/casl-CrltbDPa.js +23 -0
- package/dist/casl-D7n7yE-h.js +307 -0
- package/dist/catalog/index.d.ts +6 -20
- package/dist/catalog/index.js +13 -15
- package/dist/catalog-B3MJShnZ.js +51 -0
- package/dist/catalog-CgK_L4Qf.js +1 -0
- package/dist/catalog-DyC3LKc7.js +130 -0
- package/dist/catalog-doc-Bp5khmCG.js +352 -0
- package/dist/catalog-fingerprint-DAWZARy6.js +31 -0
- package/dist/catalog-operations-dxuOZr4J.js +59 -0
- package/dist/catalog-path-bG0XxHMu.js +11 -0
- package/dist/challenge-CjwmjcuX.js +518 -0
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +10 -13
- package/dist/chat-sdk/index.d.ts +3 -11
- package/dist/chat-sdk/index.js +7 -11
- package/dist/checks-DSm45qH7.js +71 -0
- package/dist/claims-map-BGbpbvGD.js +15 -0
- package/dist/claims-map-CLKQWxJG.d.ts +33 -0
- package/dist/claims-size-DcjhvUv5.js +58 -0
- package/dist/claude-agent/index.d.ts +3 -5
- package/dist/claude-agent/index.js +4 -5
- package/dist/clerk/index.d.ts +4 -8
- package/dist/clerk/index.js +7 -8
- package/dist/cli/bin.js +6 -7
- package/dist/cli/generate/watch-worker.d.ts +20 -0
- package/dist/cli/generate/watch-worker.js +69 -0
- package/dist/cli/index.d.ts +11 -20
- package/dist/cli/index.js +8 -8
- package/dist/cli/plugins/app.d.ts +18 -0
- package/dist/cli/plugins/app.js +26 -0
- package/dist/cli/plugins/better-supabase.d.ts +10 -0
- package/dist/cli/plugins/better-supabase.js +18 -0
- package/dist/cli/plugins/openapi.d.ts +19 -0
- package/dist/cli/plugins/openapi.js +40 -0
- package/dist/cli/plugins/powersync.d.ts +7 -0
- package/dist/cli/plugins/powersync.js +29 -0
- package/dist/cli/plugins/rls.d.ts +8 -0
- package/dist/cli/plugins/rls.js +27 -0
- package/dist/cli/plugins/schemas.d.ts +13 -0
- package/dist/cli/plugins/schemas.js +23 -0
- package/dist/cli/plugins/scim.d.ts +10 -0
- package/dist/cli/plugins/scim.js +32 -0
- package/dist/cli/plugins/supabase-hook.d.ts +13 -0
- package/dist/cli/plugins/supabase-hook.js +40 -0
- package/dist/cli/plugins/supabase.d.ts +27 -0
- package/dist/cli/plugins/supabase.js +69 -0
- package/dist/cli/plugins/ui.d.ts +11 -0
- package/dist/cli/plugins/ui.js +19 -0
- package/dist/client-V95IvZsF.d.ts +43 -0
- package/dist/client-subject-v89t811z.d.ts +25 -0
- package/dist/clients-Bb_33pRE.js +22 -0
- package/dist/clients-DGcyFDCc.d.ts +10 -0
- package/dist/cloud/index.d.ts +8 -26
- package/dist/cloud/index.js +22 -28
- package/dist/cloud-BfEI9TLS.js +85 -0
- package/dist/codemod-DwH0IZ2x.js +2159 -0
- package/dist/codemod-p67ePW25.js +35 -0
- package/dist/collect-BJZsuBW4.js +535 -0
- package/dist/collect-CPvCXMQ-.js +1 -0
- package/dist/collect-CpGnmGpL.js +54 -0
- package/dist/command-9GAzSI7E.js +5 -0
- package/dist/compact-C4LFuqbW.js +28 -0
- package/dist/compare-dfHDj8kT.js +11 -0
- package/dist/compile/index.d.ts +2 -2
- package/dist/compile/index.js +1 -1
- package/dist/compile-BUKXrueE.js +685 -0
- package/dist/compile-Blrr5WWw.js +724 -0
- package/dist/compile-D8c1nFGy.d.ts +118 -0
- package/dist/completion-CfrZOGcB.js +150 -0
- package/dist/conditions-CkHgXoZB.js +385 -0
- package/dist/config-D6gh_xvs.js +25 -0
- package/dist/config-iyy90IOU.js +143 -0
- package/dist/config-report-BaHEBpt-.js +55 -0
- package/dist/config-shape-B6tdyBju.js +149 -0
- package/dist/connection-BnoSqYU1.js +196 -0
- package/dist/connector-schema-BSRMyq4M.js +433 -0
- package/dist/constants-PCJiir_3.js +19 -0
- package/dist/context-DmH-Eyvx.js +95 -0
- package/dist/convex/index.d.ts +5 -9
- package/dist/convex/index.js +7 -8
- package/dist/core-CnC47rSf.d.ts +200 -0
- package/dist/core-DKqrD_xW.js +338 -0
- package/dist/coverage-DL7JCZmb.d.ts +133 -0
- package/dist/coverage-nFSMjFxH.js +42 -0
- package/dist/create-BAMPoEga.js +133 -0
- package/dist/create-BsRcXm_m.d.ts +125 -0
- package/dist/create-D3oXoXxM.js +373 -0
- package/dist/create-DeQ5t8mZ.d.ts +124 -0
- package/dist/create-sGl1ccTp.d.ts +185 -0
- package/dist/credential-ke0KMQeB.js +430 -0
- package/dist/credentials-6ZWbJ-Re.js +72 -0
- package/dist/credentials-BfzdL5kv.d.ts +123 -0
- package/dist/credentials-DOeqknte.js +309 -0
- package/dist/decide-set-CgNcE6pP.js +99 -0
- package/dist/deciding-columns-BnglEKqU.js +143 -0
- package/dist/decision-hHv4UZgy.js +20 -0
- package/dist/define-permdock-BLpQ0m95.d.ts +99 -0
- package/dist/define-permdock-CIxHBykk.js +148 -0
- package/dist/definition-options-9o8Hdww3.js +370 -0
- package/dist/delegation-BaUNCrE_.js +263 -0
- package/dist/delegation-input-7Y5Rlja7.js +18 -0
- package/dist/delivery/index.d.ts +4 -4
- package/dist/delivery/index.js +5 -5
- package/dist/delivery-Cb3VCij5.js +555 -0
- package/dist/delivery-event-D5b9yhaJ.js +39 -0
- package/dist/denied-text-D6JJTDr3.d.ts +20 -0
- package/dist/describe-B7EosIKA.js +100 -0
- package/dist/describe-lAafaRQQ.d.ts +43 -0
- package/dist/device-f3JEnqa0.js +195 -0
- package/dist/diff-BIqibFnm.js +464 -0
- package/dist/diff-n6LONVwL.js +36 -0
- package/dist/digest-BaP8bQzX.js +26 -0
- package/dist/digest-BcIZRYvp.d.ts +17 -0
- package/dist/doctor-Bg12v-8M.js +4847 -0
- package/dist/doctor-DCsyH7YR.js +53 -0
- package/dist/drizzle/index.d.ts +5 -9
- package/dist/drizzle/index.js +5 -6
- package/dist/elysia/index.d.ts +6 -8
- package/dist/elysia/index.js +6 -7
- package/dist/env-hbYumkRp.js +7 -0
- package/dist/errors-DOSkVeTC.js +127 -0
- package/dist/errors-DUJ7wLlE.d.ts +137 -0
- package/dist/errors-Da88YLm5.js +26 -0
- package/dist/errors-DgLOqc6j.js +148 -0
- package/dist/errors-KngVdJT9.d.ts +12 -0
- package/dist/evaluate-D8SdfP3h.js +1948 -0
- package/dist/evaluations-BQkpE7hC.js +609 -0
- package/dist/evaluations-K9qglDP7.d.ts +36 -0
- package/dist/evaluator-Dlhn2d7D.js +2 -0
- package/dist/evaluator-eager-UuJK6NX_.js +8 -0
- package/dist/eve/index.d.ts +11 -10
- package/dist/eve/index.js +7 -8
- package/dist/event-time-ChIrhzy5.js +26 -0
- package/dist/execute-SN8_dlch.js +166 -0
- package/dist/express/index.d.ts +6 -8
- package/dist/express/index.js +6 -7
- package/dist/fastify/index.d.ts +5 -11
- package/dist/fastify/index.js +6 -8
- package/dist/fetch-adapter-gmTCu4FR.d.ts +32 -0
- package/dist/fetch-adapter-ovZdSvlT.js +124 -0
- package/dist/fields-6d1j-q3c.js +502 -0
- package/dist/fields-C0L2FoZk.js +25 -0
- package/dist/files-DAR51W3J.js +157 -0
- package/dist/files-DuV7wRim.js +139 -0
- package/dist/fixtures-Bm0G0A7H.js +79 -0
- package/dist/flags-C0e-BzGW.js +112 -0
- package/dist/freeze-DGfJq_j2.js +86 -0
- package/dist/from-snapshot-CCDF_ihX.js +173 -0
- package/dist/gen-B4GUqsfM.js +1160 -0
- package/dist/gen-BC66z5Fd.js +1 -0
- package/dist/gen-kind-Bahz_i3U.js +67 -0
- package/dist/gen-kind-DFQnQwFN.d.ts +13 -0
- package/dist/generate-5_kz2309.js +305 -0
- package/dist/generate-B-msjuaO.js +2339 -0
- package/dist/generate-CbtjKcjn.js +67 -0
- package/dist/generate-DhP0jQDR.js +97 -0
- package/dist/generate-options-BDgadlwe.js +1104 -0
- package/dist/grantee-BPUG6f0r.js +109 -0
- package/dist/grantee-conditions-Dob6QQAc.js +270 -0
- package/dist/grantee-match-CFQ-LRcL.js +147 -0
- package/dist/grants-BzjbUCdR.js +139 -0
- package/dist/graph-sql-Ds3nbevr.d.ts +27 -0
- package/dist/h3/index.d.ts +4 -6
- package/dist/h3/index.js +4 -5
- package/dist/headers-D1oRr-js.d.ts +8 -0
- package/dist/helpers-DSmj6SHi.js +533 -0
- package/dist/hono/index.d.ts +6 -8
- package/dist/hono/index.js +7 -8
- package/dist/hook-sql-BIR4fL7i.js +3412 -0
- package/dist/hosted-DMJKJPoc.js +361 -0
- package/dist/hosted-DUbuh0Td.d.ts +100 -0
- package/dist/http-BUIYu1Kc.d.ts +10 -0
- package/dist/http-BbX_Ou3_.js +48 -0
- package/dist/http-C9jDw_bZ.js +82 -0
- package/dist/http-dNltTpC8.js +71 -0
- package/dist/ids-0QDIxtxL.js +53 -0
- package/dist/import-BZi1tZxq.js +318 -0
- package/dist/import-BqoDHpFt.js +1158 -0
- package/dist/index-BXz-XXC3.d.ts +1108 -0
- package/dist/index-CVuc3E1O.d.ts +196 -0
- package/dist/index-Cq9N5B92.d.ts +506 -0
- package/dist/index-D8A1d_Tt.d.ts +214 -0
- package/dist/index-DegTwZxD.d.ts +93 -0
- package/dist/index-O0qbI8Ha.d.ts +221 -0
- package/dist/index.d.ts +24 -25
- package/dist/index.js +47 -46
- package/dist/init-9cqnSJWG.js +95 -0
- package/dist/init-K3tKOwf4.js +94 -0
- package/dist/instance-options-B4MD2wgl.d.ts +9 -0
- package/dist/instance-options-CLErhA76.js +23 -0
- package/dist/instance-snapshot-DdGOpSfN.js +716 -0
- package/dist/instant-Ih5riY_A.js +18 -0
- package/dist/interactive-only-BZu9rLpa.js +1567 -0
- package/dist/internals-D58TnmDB.js +19 -0
- package/dist/json-schema-SDkWXxhu.d.ts +38 -0
- package/dist/json-schema-jtX26ydD.js +148 -0
- package/dist/jwt/index.d.ts +6 -24
- package/dist/jwt/index.js +18 -26
- package/dist/kernel-Dn6pKMAF.js +423 -0
- package/dist/kysely/index.d.ts +5 -9
- package/dist/kysely/index.js +5 -6
- package/dist/lazy-provider-CydlnKkS.d.ts +4 -0
- package/dist/lazy-provider-DG5rMeqL.js +28 -0
- package/dist/limits-DpTxX6N4.js +166 -0
- package/dist/live-options-CIUmc-YQ.js +70 -0
- package/dist/load-BPzIqlGB.js +1 -0
- package/dist/load-CZnlAyZ8.js +98 -0
- package/dist/load-jose-CjzIBSKI.js +7 -0
- package/dist/login-C1I5KIsK.js +67 -0
- package/dist/login-CP0UxnLw.js +255 -0
- package/dist/lru-Cp-AEvpR.js +27 -0
- package/dist/manifest-B-8d2lhG.js +45 -0
- package/dist/manifest-CRHphHxo.d.ts +362 -0
- package/dist/manifest-DvS2IoXo.js +399 -0
- package/dist/manifest-json-DMaBWmcG.js +8 -0
- package/dist/manifest-schema-DJY5Q_pR.js +507 -0
- package/dist/map-claims-BKdnPwep.js +386 -0
- package/dist/map-error-DTi_JZT8.js +22 -0
- package/dist/markers-C-kThnKN.js +79 -0
- package/dist/may-use-Died1tNU.js +233 -0
- package/dist/mcp/index.d.ts +11 -21
- package/dist/mcp/index.js +56 -43
- package/dist/membership-filter-CSKH48eD.js +66 -0
- package/dist/migrate-CmTMk7rd.js +536 -0
- package/dist/model-B4EKVHMK.js +188 -0
- package/dist/module-values-Ddx0GLaJ.js +106 -0
- package/dist/nest/index.d.ts +7 -13
- package/dist/nest/index.js +12 -15
- package/dist/next/client.d.ts +1 -3
- package/dist/next/client.js +2 -3
- package/dist/next/index.d.ts +36 -16
- package/dist/next/index.js +161 -31
- package/dist/next/plugin.d.ts +1 -3
- package/dist/next/plugin.js +3 -4
- package/dist/node/index.d.ts +6 -8
- package/dist/node/index.js +4 -5
- package/dist/oauth-security-C8fjzFRF.js +25 -0
- package/dist/ocsf-DKRQc6uv.js +135 -0
- package/dist/openai/index.d.ts +5 -7
- package/dist/openai/index.js +5 -6
- package/dist/openapi/index.d.ts +4 -16
- package/dist/openapi/index.js +4 -3
- package/dist/openapi-BHqqNSoG.js +95 -0
- package/dist/openapi-BT5XY7HY.js +260 -0
- package/dist/openapi-D2dmyWZK.js +411 -0
- package/dist/openapi-document-Ca5yAjc6.js +35 -0
- package/dist/operation-findings-D5Uo-dcm.js +35 -0
- package/dist/operation-risks-BD-j14dj.js +12 -0
- package/dist/operations-B0yO77Zz.js +290 -0
- package/dist/operations-BS8ExH5A.d.ts +58 -0
- package/dist/operations-De3F7tlf.js +88 -0
- package/dist/optional-CaQWp9HA.js +46 -0
- package/dist/orpc/index.d.ts +8 -12
- package/dist/orpc/index.js +10 -12
- package/dist/otel/index.d.ts +3 -5
- package/dist/otel/index.js +5 -7
- package/dist/output-djxu62oH.js +244 -0
- package/dist/output-files-C5LFnQa4.js +1 -0
- package/dist/output-files-DNid6TBl.js +197 -0
- package/dist/ownership-BO0sI5FB.js +558 -0
- package/dist/parse-local-manifest-BGLWVchi.d.ts +8 -0
- package/dist/parse-local-manifest-CfMjZAFi.js +67 -0
- package/dist/parse-nfHSt1Wy.js +149 -0
- package/dist/parse-request-IEEzVFM8.js +24 -0
- package/dist/parse-sink-events-B6nZx41L.js +125 -0
- package/dist/paths-CeS_gpHf.js +44 -0
- package/dist/pdp/index.d.ts +3 -9
- package/dist/pdp/index.js +22 -18
- package/dist/peer-BWTpSLs2.js +1 -0
- package/dist/peer-D77JpXe-.js +978 -0
- package/dist/perf-token-dFGVP14-.js +155 -0
- package/dist/permdock-BueSeg7X.js +1514 -0
- package/dist/permdock-Dz3yzWrp.d.ts +853 -0
- package/dist/permission-registry-DMYRZVcn.js +413 -0
- package/dist/permissions-CQW3cr2S.js +17 -0
- package/dist/permissions-DWULToSb.d.ts +52 -0
- package/dist/permissions-ijDw4sO1.js +144 -0
- package/dist/pg-CA651850.js +59 -0
- package/dist/pins-CXXkVEiD.js +14 -0
- package/dist/pipeline-CXuwijr2.js +307 -0
- package/dist/pkce-DdsRBK7n.js +20 -0
- package/dist/plugin-DGmbeXwA.d.ts +221 -0
- package/dist/plugin-MQVfUBUS.js +93 -0
- package/dist/plugin-outputs-BE2YCiMj.js +28 -0
- package/dist/policy-BhSUlHRr.js +37 -0
- package/dist/policy-C-Lzp3Zh.d.ts +18 -0
- package/dist/policy-DFD2J5o_.js +476 -0
- package/dist/policy-bundle-97xaDULc.js +82 -0
- package/dist/policy-from-catalog-YKaTeaco.js +452 -0
- package/dist/policy-module-Bp4HvsRg.js +107 -0
- package/dist/policy-types-93NwI8iI.d.ts +2855 -0
- package/dist/postgres-store-CYFvw98w.js +1023 -0
- package/dist/postgrest-DyrYo_XT.d.ts +138 -0
- package/dist/powersync-CN7IQIKk.js +40 -0
- package/dist/powersync-DdDLP02A.js +1630 -0
- package/dist/powersync-m9uYgCFF.js +1 -0
- package/dist/preset/index.d.ts +0 -12
- package/dist/preset/index.js +1 -1
- package/dist/preset-BcFDaeqd.js +1849 -0
- package/dist/principal-source-BIcukkB3.js +102 -0
- package/dist/prisma/index.d.ts +4 -12
- package/dist/prisma/index.js +10 -14
- package/dist/problem-BZB7zPC7.js +202 -0
- package/dist/problem-details-EJHcvYCz.js +154 -0
- package/dist/problem-types-81BEw0IN.js +7 -0
- package/dist/prompt-CSXHcJxy.js +931 -0
- package/dist/protected-action-BMb0ftEu.js +241 -0
- package/dist/protected-action-D6T3eJyW.d.ts +73 -0
- package/dist/protected-action-DiXulRVj.js +78 -0
- package/dist/provider-BnnFjtWI.js +893 -0
- package/dist/provider-ClD4rfgT.js +11 -0
- package/dist/provider-CydlnKkS.d.ts +4 -0
- package/dist/provider-store-atQUfsVO.js +51 -0
- package/dist/provider-with-CSw4mBDU.js +70 -0
- package/dist/public-api-DIMZmzWi.js +5579 -0
- package/dist/pull-9oQvY18T.js +252 -0
- package/dist/pull-jvJPMQhP.js +1 -0
- package/dist/push-Cb7PqXdO.js +158 -0
- package/dist/pushed-policy-pH-EFWyx.d.ts +61 -0
- package/dist/pushed-policy-rpB6k77P.js +240 -0
- package/dist/quote-BKrTBbcH.js +36 -0
- package/dist/rbac-B-49toAp.js +90 -0
- package/dist/react/index.d.ts +10 -9
- package/dist/react/index.js +8 -7
- package/dist/react/lazy.d.ts +10 -12
- package/dist/react/lazy.js +8 -35
- package/dist/react/provider-client-lazy.d.ts +2 -0
- package/dist/react/provider-client-lazy.js +2 -0
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +12 -30
- package/dist/react-native/index.js +31 -41
- package/dist/read-memberships-BkePIa1F.js +63 -0
- package/dist/refresh-on-C1zIMtJr.d.ts +47 -0
- package/dist/refresh-online-CYGZNo6V.js +19 -0
- package/dist/refresh-online-vtUfV6dk.d.ts +10 -0
- package/dist/refs-Cix9Zjis.js +103 -0
- package/dist/relation-walk-BlWy9gBK.js +188 -0
- package/dist/relations-CIgB5KPJ.js +162 -0
- package/dist/replay-ClGIMp5p.d.ts +3 -0
- package/dist/replay-X2m6moK1.js +28 -0
- package/dist/request-context-CVJodWx8.js +70 -0
- package/dist/request-context-E3-ps-H_.d.ts +3 -0
- package/dist/request-schema-DzEoR310.js +155 -0
- package/dist/resend/index.d.ts +4 -10
- package/dist/resend/index.js +14 -17
- package/dist/resolve-names-Cmg6SPAa.js +266 -0
- package/dist/resolver-kdZ4HrpC.js +404 -0
- package/dist/resource-ref-BiQtFK-I.js +19 -0
- package/dist/resource-relations-Ck5sjYQR.js +251 -0
- package/dist/retire-BNiXnbBR.js +248 -0
- package/dist/revocations-3jyzniOz.js +26 -0
- package/dist/revocations-ku_f2d2y.d.ts +24 -0
- package/dist/rls-BrsMogAP.js +321 -0
- package/dist/rls-Cv1V8YfI.js +946 -0
- package/dist/rls-files-Bj446vbj.js +114 -0
- package/dist/rls-options-Dpj_pEyU.d.ts +26 -0
- package/dist/role-builder-DhsGEVq-.js +501 -0
- package/dist/role-grants-Bk6ZsaS0.js +46 -0
- package/dist/roles-B29psCem.js +29 -0
- package/dist/rolldown-runtime-B8NLbhFH.js +3 -0
- package/dist/row-conditions-DwIJocfQ.js +27 -0
- package/dist/row-pair-CxEhErJU.js +33 -0
- package/dist/rpc-B-4IZOiU.js +111 -0
- package/dist/rpc-DjgxFbjK.d.ts +18 -0
- package/dist/run-DX4D6S6V.js +726 -0
- package/dist/run-decqEKNa.js +1 -0
- package/dist/run-ticket-D6T39Xdi.js +370 -0
- package/dist/run-ticket-DXwrko2J.d.ts +157 -0
- package/dist/runtime-Cl6xSbEq.js +13 -0
- package/dist/saas-DzjKUQr5.js +1218 -0
- package/dist/scan-Cj7PQLrS.js +28 -0
- package/dist/schema-BeY3croo.js +403 -0
- package/dist/schema-CJPvTfeN.js +133 -0
- package/dist/scim/index.d.ts +2 -2
- package/dist/scim/index.js +2 -2
- package/dist/scim-B9QyJ23q.js +1046 -0
- package/dist/scopes-B-KX9EI8.js +238 -0
- package/dist/seed-sql-CjF7u0aX.js +60 -0
- package/dist/seeds/index.d.ts +2 -0
- package/dist/seeds/index.js +1 -0
- package/dist/seeds-BDTG7xl-.js +53 -0
- package/dist/seeds-uG196Ev4.d.ts +73 -0
- package/dist/server/index.d.ts +13 -13
- package/dist/server/index.js +14 -14
- package/dist/server-Co9CYGqk.js +146 -0
- package/dist/server-types-BrHOGAYx.d.ts +318 -0
- package/dist/sha256-DFsnyVPo.js +157 -0
- package/dist/shared-BOsJIQf4.js +124 -0
- package/dist/shared-BdF5DJDQ.js +330 -0
- package/dist/signals-a1NxAP0X.js +31 -0
- package/dist/sink-BD34OS8T.d.ts +247 -0
- package/dist/sink-Bgvf9lIz.js +966 -0
- package/dist/size-DF7xQ-nH.js +95 -0
- package/dist/skills-B5bc6JIA.js +50 -0
- package/dist/skills-Cr1C0b9D.js +202 -0
- package/dist/snapshot-DckMnHk8.js +352 -0
- package/dist/snapshot-cache-DTTEfmxv.js +69 -0
- package/dist/snapshot-cache-DoP3avLl.d.ts +68 -0
- package/dist/snapshot-compact-CwAop_6C.js +119 -0
- package/dist/snapshot-empty-DZ6sZ83n.js +17 -0
- package/dist/snapshot-evaluate-9RGy7J3N.js +552 -0
- package/dist/snapshot-reads-D775amTL.js +65 -0
- package/dist/snapshot-size-D-pCR8x0.js +139 -0
- package/dist/snapshot-size-DU7CvpMt.js +1 -0
- package/dist/solid/index.d.ts +18 -20
- package/dist/solid/index.js +15 -19
- package/dist/solid-start/index.d.ts +6 -8
- package/dist/solid-start/index.js +4 -5
- package/dist/sources-BbSUNmFX.js +10 -0
- package/dist/sources-DnjJPGfb.js +657 -0
- package/dist/sources-NQio1yFq.d.ts +727 -0
- package/dist/sql-BYYNi1lu.d.ts +8 -0
- package/dist/sql-T4GaBh9X.js +93 -0
- package/dist/src-D6_T4zd7.js +1811 -0
- package/dist/ssf/index.d.ts +3 -3
- package/dist/ssf/index.js +20 -31
- package/dist/standard-webhooks-B3MQihcP.d.ts +86 -0
- package/dist/standard-webhooks-BtIkXclH.js +227 -0
- package/dist/storage-BhGDhsXm.js +131 -0
- package/dist/store-AH8bmaxW.js +377 -0
- package/dist/store-core-eqG8jijs.d.ts +306 -0
- package/dist/store-options-C8x39AHa.js +1034 -0
- package/dist/stores-4DOaL4ZP.d.ts +58 -0
- package/dist/stores-DoA7ACkz.js +127 -0
- package/dist/stream-DdF94h7T.js +73 -0
- package/dist/style-CQDaLJtP.js +24 -0
- package/dist/style-Crf-90o6.js +1 -0
- package/dist/subject-DkxY-AhF.js +23 -0
- package/dist/subject-cache-BZeSj4Xf.d.ts +156 -0
- package/dist/subject-settings-BO-frcYx.js +147 -0
- package/dist/subject-settings-C9F1sU1d.d.ts +48 -0
- package/dist/supabase/client.d.ts +1 -1
- package/dist/supabase/client.js +2 -3
- package/dist/supabase/index.d.ts +77 -24
- package/dist/supabase/index.js +9 -8
- package/dist/supabase/middleware.d.ts +27 -9
- package/dist/supabase/middleware.js +51 -21
- package/dist/supabase-BG1HPdQU.js +30 -0
- package/dist/supabase-BI5ZhzLl.js +792 -0
- package/dist/supabase-config-mXcggV5I.js +890 -0
- package/dist/supabase-hook-hd9abKy4.js +2 -0
- package/dist/supabase-hook-tdR45aXY.js +405 -0
- package/dist/supabase-outcome-CMLuLW-V.js +9 -0
- package/dist/supautils-DXzJ2E2Q.js +96 -0
- package/dist/support-session-B8xrW28B.js +157 -0
- package/dist/svelte/index.d.ts +8 -10
- package/dist/svelte/index.js +12 -15
- package/dist/svelte/runtime.d.ts +4 -6
- package/dist/svelte/runtime.js +4 -4
- package/dist/svelte/source.d.ts +8 -10
- package/dist/svelte/source.js +6 -7
- package/dist/sveltekit/index.d.ts +6 -8
- package/dist/sveltekit/index.js +3 -4
- package/dist/tables-CRTCBuFi.js +3240 -0
- package/dist/tanstack-start/index.d.ts +6 -8
- package/dist/tanstack-start/index.js +3 -4
- package/dist/target-BGpxgKsN.js +50 -0
- package/dist/tenancy-B5Xxt9Sc.js +223 -0
- package/dist/terminal/index.d.ts +6 -16
- package/dist/terminal/index.js +18 -23
- package/dist/testing/core.d.ts +1 -1
- package/dist/testing/core.js +1 -1
- package/dist/testing/fixtures/index.d.ts +12 -10
- package/dist/testing/fixtures/index.js +48 -25
- package/dist/testing/index.d.ts +85 -85
- package/dist/testing/index.js +226 -115
- package/dist/testing/saas/index.d.ts +5 -15
- package/dist/testing/saas/index.js +2 -2
- package/dist/testing/saas/permissions.d.ts +1 -1
- package/dist/testing/saas/permissions.js +1 -1
- package/dist/text-D704xHVl.js +7 -0
- package/dist/text-diff-CsglY49A.js +440 -0
- package/dist/thenable-BxMy2v8w.js +39 -0
- package/dist/time-r0CKBm57.js +94 -0
- package/dist/timeout-nOqLpU2I.js +7 -0
- package/dist/token-BgswTQzt.d.ts +9 -0
- package/dist/token-CSljQqzA.js +76 -0
- package/dist/tool-refusal-DzCSbjp8.js +43 -0
- package/dist/trpc/index.d.ts +7 -9
- package/dist/trpc/index.js +7 -8
- package/dist/type-helpers-DHCQEPj8.d.ts +47 -0
- package/dist/types-3pRMqcvw.d.ts +84 -0
- package/dist/types-BFtFaI1W.d.ts +66 -0
- package/dist/types-BdNdMix7.d.ts +263 -0
- package/dist/types-C7QtRn3n.d.ts +66 -0
- package/dist/types-CVCRFYY_.d.ts +102 -0
- package/dist/types-CWmBZtQN.d.ts +274 -0
- package/dist/types-Cakw89Wx.d.ts +372 -0
- package/dist/types-D3tjoLwT.d.ts +124 -0
- package/dist/types-D8VXQxKL.d.ts +1231 -0
- package/dist/types-DFZKovb3.js +77 -0
- package/dist/types-DONLJQjY.d.ts +134 -0
- package/dist/types-OzSal_K_.d.ts +178 -0
- package/dist/types-XSfi6ihL.d.ts +65 -0
- package/dist/unplugin/index.d.ts +1 -3
- package/dist/unplugin/index.js +3 -4
- package/dist/usage-B-E747wO.js +31 -0
- package/dist/usage-B7nx0_aa.js +761 -0
- package/dist/usage-rqQ9ViXv.js +1 -0
- package/dist/validation-error-BAO1W1yk.d.ts +27 -0
- package/dist/validation-error-CgDOA6VS.js +35 -0
- package/dist/validity-YNEEm2MZ.js +56 -0
- package/dist/verifier-BIYkGcJc.js +530 -0
- package/dist/verify-9HObfifg.js +1102 -0
- package/dist/version-CU6e2wxV.js +7 -0
- package/dist/version-D-jWyJb9.js +46 -0
- package/dist/version-DcZCjWXb.js +1 -0
- package/dist/version-cache-BXkl7-Fz.js +462 -0
- package/dist/views-Dpr1uB16.js +164 -0
- package/dist/vocabulary-CE2k7s1a.js +157 -0
- package/dist/vocabulary-FYgI_NoI.d.ts +400 -0
- package/dist/vue/index.d.ts +18 -20
- package/dist/vue/index.js +13 -18
- package/dist/waiter-DKdFHKVZ.js +66 -0
- package/dist/waiter-hYLJXA7r.d.ts +37 -0
- package/dist/watch-BecZtEdU.js +155 -0
- package/dist/watch-CiN6WU9k.js +221 -0
- package/dist/watch-NAUnUXph.js +1 -0
- package/dist/webmcp/index.d.ts +2 -6
- package/dist/webmcp/index.js +8 -9
- package/dist/who-can-rUSZfLvI.js +366 -0
- package/dist/wire-delegation-DC5Cyec4.js +35 -0
- package/dist/wire-denial-BcRQnA7p.js +26 -0
- package/dist/workflow/index.d.ts +3 -3
- package/dist/workflow/index.js +12 -14
- package/dist/workflow-sdk/index.d.ts +6 -8
- package/dist/workflow-sdk/index.js +2 -3
- package/dist/wrap-CsfsaJhd.js +32 -0
- package/dist/wrap-D-KvhzaC.d.ts +16 -0
- package/package.json +83 -39
- package/schemas/catalog-v2.json +665 -0
- package/schemas/cli-commands-v1.json +1 -1
- package/schemas/cli-result-v2.json +163 -0
- package/schemas/cloud-api-v1.json +1 -1
- package/schemas/snapshot-v1.json +26 -0
- package/schemas/supabase-claims-v1.json +5 -1
- package/schemas/supabase-manifest-v1.json +11 -2
- package/skills/permdock/SKILL.md +1 -1
- package/skills/permdock-data/references/queries-and-rls.md +2 -1
- package/skills/permdock-wire/references/adapters.md +5 -3
- package/dist/2020-CJbO8Bvz.js +0 -6773
- package/dist/active-tenant-DVee32-T.js +0 -39
- package/dist/adapter-context-OHikyRqV.js +0 -29
- package/dist/adoption-scan-8F9VSQrK.js +0 -107
- package/dist/app-J9PE1LNm.js +0 -24
- package/dist/app-data-UNNm07jV.js +0 -63
- package/dist/approval-header-8QV6MU4H.js +0 -26
- package/dist/approval-normalize-KfhzpD93.js +0 -196
- package/dist/approval-policies-BiXMlYBu.d.ts +0 -138
- package/dist/approval-prompt-B8hQY69x.js +0 -61
- package/dist/approval-prompt-j5PTItiy.d.ts +0 -59
- package/dist/approval-required-TzNB9oQA.js +0 -6
- package/dist/approvals-BfzI8Foe.js +0 -1048
- package/dist/approvers-BaNwKYgd.js +0 -77
- package/dist/arazzo-BUVqRmaJ.js +0 -36
- package/dist/arazzo-CWmM8pWw.js +0 -77
- package/dist/args-iafbHiXn.js +0 -311
- package/dist/audience-DLoopY4q.js +0 -55
- package/dist/auth-BxXHxWRy.js +0 -189
- package/dist/authz-topic-Dbc-HDOS.js +0 -15
- package/dist/automation-BueW05db.js +0 -158
- package/dist/automation-_iGeP54L.d.ts +0 -124
- package/dist/base-url-BQbddZO5.js +0 -9
- package/dist/better-supabase-DF8f8oly.js +0 -194
- package/dist/bind-CTj4dHc1.d.ts +0 -58
- package/dist/bind-LQ6zbARV.js +0 -125
- package/dist/body-Cy9S8zhw.js +0 -10
- package/dist/body-text-DQhcmqdY.js +0 -56
- package/dist/boundary-BV3O1eud.js +0 -19
- package/dist/boundary-C9ck-3uK.d.ts +0 -24
- package/dist/budget-BBCPDOGP.js +0 -14
- package/dist/budget-CNLsV2SL.d.ts +0 -14
- package/dist/build-instance-Bq8wkJ4i.js +0 -31
- package/dist/canonical-json-DwilZ1iB.js +0 -29
- package/dist/capability-CenWwTMR.js +0 -205
- package/dist/capability-DqCyFGip.d.ts +0 -130
- package/dist/casbin-DIvUMac7.js +0 -242
- package/dist/casbin-qpG_ZphP.js +0 -30
- package/dist/casl-CjBVJj8R.js +0 -24
- package/dist/casl-CkBssiB1.js +0 -308
- package/dist/catalog-B1MAmRQI.js +0 -131
- package/dist/catalog-BCVIH7kq.js +0 -1
- package/dist/catalog-CaZoXBD8.js +0 -52
- package/dist/catalog-doc-DnQDviXY.js +0 -353
- package/dist/catalog-fingerprint-e6aCWosn.js +0 -157
- package/dist/catalog-operations-Do1eD-Rt.js +0 -60
- package/dist/catalog-path-CnI0XTFK.js +0 -12
- package/dist/challenge-DKJpP-5P.js +0 -521
- package/dist/checks-fyDOhcz0.js +0 -72
- package/dist/claims-map-CKkoAAYF.js +0 -16
- package/dist/claims-map-D1Pb5oRq.d.ts +0 -35
- package/dist/client-JK504UCq.d.ts +0 -45
- package/dist/clients-C_NOET3z.d.ts +0 -12
- package/dist/clients-DYr3U86j.js +0 -23
- package/dist/cloud-CXgE1qpa.js +0 -86
- package/dist/codemod-BJ0Kgv9b.js +0 -36
- package/dist/codemod-DjgVx3RQ.js +0 -2800
- package/dist/collect-BG-SXFQv.js +0 -537
- package/dist/collect-CxPJRjoc.js +0 -55
- package/dist/collect-ZLgHgujd.js +0 -1
- package/dist/command-L8EstFNm.js +0 -6
- package/dist/compact-CAf557ZB.js +0 -29
- package/dist/compare-DTfyUunF.js +0 -12
- package/dist/compile-Cvru58id.js +0 -661
- package/dist/compile-Dh9pW_Co.d.ts +0 -120
- package/dist/completion-DUHSRdoQ.js +0 -152
- package/dist/config-CgA_Z5Ts.js +0 -26
- package/dist/config-DC7aiuhP.js +0 -116
- package/dist/config-report-B31MnuKf.js +0 -56
- package/dist/config-shape-ChhsuGSV.js +0 -147
- package/dist/connection-zoAgwdsD.js +0 -197
- package/dist/connector-schema-CYLQNMYq.js +0 -434
- package/dist/constants-DcJABbLW.js +0 -20
- package/dist/context-BXM0MDB0.js +0 -95
- package/dist/core-BTJlqWsv.js +0 -341
- package/dist/core-BhZEo5Le.d.ts +0 -206
- package/dist/coverage-BuGlwUms.d.ts +0 -135
- package/dist/coverage-CGu_Kovx.js +0 -261
- package/dist/create--q7-j0hX.d.ts +0 -127
- package/dist/create-C5IQw_-i.d.ts +0 -191
- package/dist/create-CYj0cjTu.d.ts +0 -128
- package/dist/create-D7D94oNh.js +0 -376
- package/dist/create-DaddhCIg.js +0 -134
- package/dist/credential-BMsbcaeP.js +0 -431
- package/dist/credentials-BZU7Twpt.js +0 -310
- package/dist/credentials-Bq-Xa7Vq.d.ts +0 -125
- package/dist/credentials-dkycUsY3.js +0 -74
- package/dist/decide-set-DXEPepY1.js +0 -100
- package/dist/deciding-columns-NB4wcyBf.js +0 -134
- package/dist/decision-CaG5_eNJ.js +0 -21
- package/dist/delegation-CrdqnesZ.js +0 -262
- package/dist/delegation-input-DcXhiMkf.js +0 -19
- package/dist/delivery-BupfvJIV.js +0 -560
- package/dist/delivery-event-JioK5YbS.js +0 -40
- package/dist/denied-text-B6s29jcf.d.ts +0 -22
- package/dist/describe-BZAlPHxT.js +0 -101
- package/dist/describe-DwcoWMLB.d.ts +0 -45
- package/dist/device-BkSynWdg.js +0 -196
- package/dist/diff-BnYHpRSI.js +0 -466
- package/dist/diff-H75YU6Q-.js +0 -37
- package/dist/digest-8Yx2CchM.d.ts +0 -19
- package/dist/digest-BI-6aa6d.js +0 -27
- package/dist/doctor-Dvt1_ROJ.js +0 -3560
- package/dist/doctor-JLouRSQt.js +0 -54
- package/dist/env-DJZrPjRi.js +0 -8
- package/dist/errors-BDUwg2qC.js +0 -27
- package/dist/errors-BhRkoNS7.js +0 -145
- package/dist/errors-CHwoRRpB.d.ts +0 -14
- package/dist/errors-D_SnqcRn.d.ts +0 -141
- package/dist/errors-ynga1EQy.js +0 -128
- package/dist/evaluate-BQ2nWOki.js +0 -1905
- package/dist/evaluations-BVtY66lF.d.ts +0 -38
- package/dist/evaluations-Bj5xw0EM.js +0 -612
- package/dist/evaluator-CDl2YUd_.js +0 -2
- package/dist/evaluator-eager-CULtQ8t6.js +0 -9
- package/dist/event-time-BGy48400.js +0 -27
- package/dist/fetch-adapter-BJ76IZZg.d.ts +0 -34
- package/dist/fetch-adapter-CXeBg4CH.js +0 -124
- package/dist/fields-D9PIYlJy.js +0 -504
- package/dist/fields-DlKwZYiy.js +0 -26
- package/dist/files-BSjrtIHw.js +0 -141
- package/dist/files-CfiRtQ-m.js +0 -140
- package/dist/fixtures-BVZc7OCF.js +0 -80
- package/dist/flags-BlmpmXoY.js +0 -86
- package/dist/freeze-jjan0lCv.js +0 -63
- package/dist/from-snapshot-FdVXG_QZ.js +0 -159
- package/dist/gen-D17P8vo0.js +0 -827
- package/dist/gen-YA3SK59O.js +0 -58
- package/dist/generate-BqkZq8Dr.js +0 -165
- package/dist/generate-CezbCaTI.js +0 -275
- package/dist/grantee-OG4klcNr.js +0 -110
- package/dist/grantee-conditions-Dzprappv.js +0 -271
- package/dist/grantee-match-CPQ9zV-H.js +0 -148
- package/dist/graph-sql-BwFC4Qjs.d.ts +0 -29
- package/dist/headers-B9jQxjtW.d.ts +0 -10
- package/dist/helpers-CO2hDpBU.js +0 -537
- package/dist/hosted-CQW_YNx7.js +0 -362
- package/dist/hosted-D5StFpKa.d.ts +0 -102
- package/dist/http-B_LphE5Y.d.ts +0 -12
- package/dist/http-DH94eh6f.js +0 -72
- package/dist/http-DKLXrFGk.js +0 -83
- package/dist/http-dptLQzPP.js +0 -49
- package/dist/ids-DzhJaCUj.js +0 -55
- package/dist/import-B8zbuskR.js +0 -5950
- package/dist/import-BYYXmHvP.js +0 -1143
- package/dist/index-B1-tE0Kx.d.ts +0 -1159
- package/dist/index-BwSEp_O5.d.ts +0 -210
- package/dist/index-CB_eM-qx.d.ts +0 -101
- package/dist/index-CvcE9mYP.d.ts +0 -234
- package/dist/index-D7sMtTf6.d.ts +0 -542
- package/dist/index-d7f0hNss.d.ts +0 -233
- package/dist/init-BdgWNuc3.js +0 -96
- package/dist/init-DKRhYiGW.js +0 -95
- package/dist/instance-options-DhQVCuhT.d.ts +0 -11
- package/dist/instance-options-URVwqpMW.js +0 -24
- package/dist/instance-snapshot-DyG_5ASl.js +0 -693
- package/dist/instant-DK3Iz83e.js +0 -19
- package/dist/internals-B3IgHrvo.js +0 -20
- package/dist/json-schema-BPGa-RjQ.js +0 -149
- package/dist/json-schema-BfXgnRNT.d.ts +0 -40
- package/dist/kernel-D9AxUqmz.js +0 -427
- package/dist/limits-CAhpRrhk.js +0 -167
- package/dist/live-options-BBIT68le.js +0 -73
- package/dist/load-C4p4VgwR.js +0 -99
- package/dist/load-DiBUJx77.js +0 -1
- package/dist/load-jose-DZ4dnjri.js +0 -8
- package/dist/login-DEvccJwP.js +0 -68
- package/dist/login-IIUDSAYW.js +0 -257
- package/dist/lru-8q4WZjBV.js +0 -28
- package/dist/manifest-BoCYBbQL.js +0 -46
- package/dist/manifest-C6eFl3Vo.d.ts +0 -349
- package/dist/manifest-CZ-GmsOL.js +0 -401
- package/dist/manifest-json-CAGzls-C.js +0 -9
- package/dist/manifest-schema-svAkgqMc.js +0 -501
- package/dist/map-claims-CAa_bQt9.js +0 -387
- package/dist/map-error-BCdb2Nrp.js +0 -23
- package/dist/markers-BeHZ4x9Q.js +0 -80
- package/dist/may-use-WDhFPqGG.js +0 -125
- package/dist/membership-filter-BWnfRQzo.js +0 -68
- package/dist/migrate-DVsxeE0y.js +0 -537
- package/dist/module-values-CdaVwrab.js +0 -107
- package/dist/oauth-security-X7Em8DbH.js +0 -26
- package/dist/ocsf-TcjRBgIs.js +0 -136
- package/dist/openapi-BFUnL8Yi.js +0 -137
- package/dist/openapi-Cc-aS9xC.js +0 -416
- package/dist/openapi-DcjyfR1g.js +0 -256
- package/dist/operation-findings-CVwJHEu_.js +0 -36
- package/dist/operation-risks-BKOcTv8J.js +0 -13
- package/dist/operations-BMPx7HyO.d.ts +0 -62
- package/dist/operations-Bm9HFecz.js +0 -89
- package/dist/optional-8TKc-0j4.js +0 -47
- package/dist/output-LDciF_4t.js +0 -96
- package/dist/output-files-BYscrQl-.js +0 -1
- package/dist/output-files-CM0BnH05.js +0 -150
- package/dist/ownership-DvK6INyx.js +0 -1062
- package/dist/parse-CORUNcCo.js +0 -151
- package/dist/parse-local-manifest-Ce2N-Opr.js +0 -69
- package/dist/parse-local-manifest-w_ksIkB9.d.ts +0 -10
- package/dist/parse-request-DOBVaeiQ.js +0 -25
- package/dist/paths-CUvURzHp.js +0 -45
- package/dist/peer-BuK9F53f.js +0 -982
- package/dist/peer-n-swIV4H.js +0 -1
- package/dist/permdock-B3zE16To.js +0 -1203
- package/dist/permdock-DV3opaI3.d.ts +0 -674
- package/dist/permission-registry-B8tYxPIt.js +0 -398
- package/dist/permissions-BaoLxy66.js +0 -18
- package/dist/permissions-D-M48hW-.js +0 -146
- package/dist/permissions-DriWkV7q.d.ts +0 -54
- package/dist/pg-Ddxsd5ZB.js +0 -60
- package/dist/pins-nqarl3oE.js +0 -15
- package/dist/pkce-CnmmYqUZ.js +0 -21
- package/dist/policy-DIHfTqm6.d.ts +0 -20
- package/dist/policy-DnNOTENd.js +0 -430
- package/dist/policy-from-catalog-Z0hvSffr.js +0 -454
- package/dist/policy-module-xym9fnSq.js +0 -95
- package/dist/policy-types-DU389Elz.d.ts +0 -2809
- package/dist/postgres-store-DcyrPS-r.js +0 -1028
- package/dist/postgrest-3dE9SGx9.d.ts +0 -124
- package/dist/powersync-B5YjtUGd.js +0 -1532
- package/dist/powersync-BgUsk2Nf.js +0 -1
- package/dist/powersync-Dx7odzyw.js +0 -62
- package/dist/preset-Bn5Z54cH.js +0 -1858
- package/dist/principal-source-C6N60GtM.js +0 -103
- package/dist/problem-CPB8kqk7.js +0 -203
- package/dist/problem-details-CLDgX1KV.js +0 -156
- package/dist/problem-types-DSsRfONQ.js +0 -8
- package/dist/prompt-D1Gj1W4Y.js +0 -938
- package/dist/protected-action-CjSUoPGx.d.ts +0 -76
- package/dist/protected-action-D41o5LvP.js +0 -244
- package/dist/protected-action-OpOxtTsN.js +0 -80
- package/dist/provider-Bzzux0TR.js +0 -12
- package/dist/provider-D1jsNJ85.d.ts +0 -6
- package/dist/provider-store-tIAwP4aW.js +0 -52
- package/dist/provider-with-Do28DhxP.js +0 -69
- package/dist/pull-Pde1lapF.js +0 -257
- package/dist/pull-a4RpDxk8.js +0 -1
- package/dist/push-sJ5dy46a.js +0 -162
- package/dist/pushed-policy-Db651nih.d.ts +0 -63
- package/dist/pushed-policy-UZyQinrL.js +0 -241
- package/dist/refresh-on-L9UOwATg.d.ts +0 -49
- package/dist/refs-C8BKxc_e.js +0 -105
- package/dist/relation-walk-BDTaTKTM.js +0 -189
- package/dist/relations-CMsJ1ARY.js +0 -163
- package/dist/replay-BU09ad4L.js +0 -29
- package/dist/replay-BpmpY2ev.d.ts +0 -5
- package/dist/request-context-C2_1lchh.d.ts +0 -5
- package/dist/request-context-dyCY4V1t.js +0 -71
- package/dist/request-schema-CMP8Cmxd.js +0 -156
- package/dist/resolve-names-D5_kABup.js +0 -206
- package/dist/resource-ref-CaS9yVPi.js +0 -20
- package/dist/resource-relations-8-pCScBO.js +0 -252
- package/dist/retire-B2xffQgY.js +0 -249
- package/dist/revocations-BaUXHM1N.d.ts +0 -26
- package/dist/revocations-Bhr0aMIC.js +0 -27
- package/dist/rls-BI687j8q.js +0 -2700
- package/dist/rls-CKLHLcRl.js +0 -367
- package/dist/role-builder-BXdhhQcB.js +0 -507
- package/dist/rolldown-runtime-C3I60J0A.js +0 -4
- package/dist/row-conditions-BAGHOmVq.js +0 -28
- package/dist/row-pair-DglMdRFh.js +0 -34
- package/dist/rpc-BdFGYcWm.js +0 -112
- package/dist/rpc-DKRQobOX.d.ts +0 -22
- package/dist/run-B4heHtD1.js +0 -1
- package/dist/run-BG2kPruh.js +0 -694
- package/dist/run-ticket-Ddxt9OuU.js +0 -371
- package/dist/run-ticket-o4RxoaEN.d.ts +0 -159
- package/dist/runtime-rf0ZuyF3.js +0 -14
- package/dist/saas-D9maBt0q.js +0 -1223
- package/dist/scan-BvTBo9-D.js +0 -29
- package/dist/schema-BlnU_TzE.js +0 -414
- package/dist/schema-grK6TTBH.js +0 -134
- package/dist/scim-BG6uPUeW.js +0 -1056
- package/dist/scim-CovliQUg.js +0 -44
- package/dist/scopes-gdH__vDZ.js +0 -239
- package/dist/server-CKjFooaJ.js +0 -147
- package/dist/server-types-C4q8_8MM.d.ts +0 -325
- package/dist/sha256-C-4WXKIu.js +0 -158
- package/dist/shared-BRmCJxDK.js +0 -125
- package/dist/shared-DfaIWvIJ.js +0 -354
- package/dist/signals-B1vHR3fN.js +0 -32
- package/dist/sink-C3KDccl9.d.ts +0 -249
- package/dist/sink-D9_vh372.js +0 -968
- package/dist/skills-DzNdLezx.js +0 -51
- package/dist/skills-nPLVGtGH.js +0 -204
- package/dist/snapshot-D0VOanxQ.js +0 -334
- package/dist/snapshot-cache-B66h7FBK.js +0 -70
- package/dist/snapshot-cache-C1mN0pXe.d.ts +0 -70
- package/dist/snapshot-compact-CUtXsx6i.js +0 -75
- package/dist/snapshot-empty-F7d5BRlc.js +0 -18
- package/dist/snapshot-evaluate-C3ZA35O_.js +0 -501
- package/dist/snapshot-reads-CNNmp1cK.js +0 -66
- package/dist/sources-2virTxHt.d.ts +0 -721
- package/dist/sources-C4vkzZJV.js +0 -660
- package/dist/sources-qoIJQrJv.js +0 -11
- package/dist/sql-0WjxIp9g.js +0 -80
- package/dist/sql-B80DFdpG.d.ts +0 -10
- package/dist/src-ieIv22BA.js +0 -2080
- package/dist/standard-webhooks-B2g_yWK8.d.ts +0 -88
- package/dist/standard-webhooks-D67a3nzk.js +0 -228
- package/dist/storage-C2bWdvJH.js +0 -132
- package/dist/store-DXO0aVgf.js +0 -380
- package/dist/store-core-BI-9ZU-5.d.ts +0 -311
- package/dist/store-options-BYKNX_JG.js +0 -993
- package/dist/stores-DtM8pt8o.js +0 -128
- package/dist/stores-DwGfIcmq.d.ts +0 -57
- package/dist/stream-DQ3rbO3J.js +0 -74
- package/dist/style-DblOtSga.js +0 -1
- package/dist/style-Ds11Hmk4.js +0 -25
- package/dist/subject-C7RddW0G.js +0 -24
- package/dist/subject-cache-BT1fGuea.js +0 -193
- package/dist/subject-cache-TY2tw-k9.d.ts +0 -144
- package/dist/subject-jG6o8eKo.js +0 -556
- package/dist/subject-settings-8sH5HlII.js +0 -150
- package/dist/subject-settings-vNW8qmUH.d.ts +0 -52
- package/dist/supabase-BlAqmxD8.js +0 -723
- package/dist/supabase-dk1kB9bJ.js +0 -92
- package/dist/supabase-hook-Bu5gkzix.js +0 -1
- package/dist/supabase-hook-Cf9zKz8T.js +0 -4263
- package/dist/supautils-BREOPaHY.js +0 -1186
- package/dist/support-session-BGeEYDSq.js +0 -158
- package/dist/tables-DnNACfAr.js +0 -4003
- package/dist/target-qdEAnnhU.js +0 -51
- package/dist/tenancy-BlxY5T0q.js +0 -224
- package/dist/text-BMFRfBqc.js +0 -8
- package/dist/text-diff-BtfSmdUo.js +0 -444
- package/dist/thenable-BNSM1U2R.js +0 -40
- package/dist/time-nR1JesoH.js +0 -95
- package/dist/timeout-D51niuQP.js +0 -8
- package/dist/token-D6pWn8Uj.d.ts +0 -11
- package/dist/token-DaMnIU9O.js +0 -77
- package/dist/tool-refusal-D4spOJ7I.js +0 -44
- package/dist/type-helpers-tDoGEIsd.d.ts +0 -49
- package/dist/types-61f3KMtI.d.ts +0 -1136
- package/dist/types-BDgMzK1i.d.ts +0 -368
- package/dist/types-BIvkpVoc.d.ts +0 -180
- package/dist/types-BWjNPQkS.d.ts +0 -67
- package/dist/types-Bq4AU68k.d.ts +0 -105
- package/dist/types-BsqLNNvG.d.ts +0 -68
- package/dist/types-CH67RMvL.d.ts +0 -136
- package/dist/types-CcUXciSj.js +0 -79
- package/dist/types-DAyp592k.d.ts +0 -276
- package/dist/types-DEDocm4c.d.ts +0 -81
- package/dist/types-DQQkzF97.d.ts +0 -126
- package/dist/types-DdeivUBP.d.ts +0 -68
- package/dist/types-X40XNxRP.d.ts +0 -265
- package/dist/usage-BkDU1dYf.js +0 -762
- package/dist/usage-DNj42KHA.js +0 -32
- package/dist/usage-DrB_tDNk.js +0 -1
- package/dist/validation-error-CV0nV6_L.d.ts +0 -29
- package/dist/validation-error-CYg2kJEw.js +0 -36
- package/dist/validity-IcjQSR7I.js +0 -57
- package/dist/verifier-DUV6pLqZ.js +0 -519
- package/dist/verify-Boehaks6.js +0 -1736
- package/dist/version-DMQ0dnN5.js +0 -48
- package/dist/version-DizhmD72.js +0 -1
- package/dist/version-sources-BRb9ZteH.js +0 -34
- package/dist/views-MWmJ6Y4P.js +0 -147
- package/dist/vocabulary-BuYFWeCU.js +0 -158
- package/dist/vocabulary-DeZvUaTw.d.ts +0 -401
- package/dist/waiter-BophA4BT.d.ts +0 -39
- package/dist/waiter-aBLM63_f.js +0 -67
- package/dist/watch-CJKYQYNb.js +0 -167
- package/dist/watch-Cv-xvI6e.js +0 -1
- package/dist/who-can-Yh9WdiwK.js +0 -367
- package/dist/wire-delegation-Cv3W2eaM.js +0 -36
- package/dist/wire-denial-C7PaVYEM.js +0 -27
- package/dist/wrap-Bq9fHwuT.d.ts +0 -18
- package/dist/wrap-C5PWzgkq.js +0 -33
- package/schemas/catalog-v1.json +0 -679
- package/schemas/cli-result-v1.json +0 -95
package/dist/codemod-DjgVx3RQ.js
DELETED
|
@@ -1,2800 +0,0 @@
|
|
|
1
|
-
import { n as CliError } from "./errors-BhRkoNS7.js";
|
|
2
|
-
import { a as rel } from "./files-BSjrtIHw.js";
|
|
3
|
-
import { i as visitorKeyTypes, r as parseSync, t as createVisitor } from "./optional-8TKc-0j4.js";
|
|
4
|
-
import { t as beforeFirst } from "./text-BMFRfBqc.js";
|
|
5
|
-
import { n as ROOT } from "./manifest-CZ-GmsOL.js";
|
|
6
|
-
import { i as refuseDirty, t as applyFiles } from "./files-CfiRtQ-m.js";
|
|
7
|
-
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
8
|
-
import { basename, extname, join, resolve } from "node:path";
|
|
9
|
-
//#region src/cli/codemod/cli-renames-0.5.ts
|
|
10
|
-
const DB_COMMANDS = [
|
|
11
|
-
"rls generate",
|
|
12
|
-
"rls import",
|
|
13
|
-
"rls verify",
|
|
14
|
-
"supabase hook generate",
|
|
15
|
-
"powersync verify"
|
|
16
|
-
];
|
|
17
|
-
const FLAG_RENAMES = [
|
|
18
|
-
{
|
|
19
|
-
commands: DB_COMMANDS,
|
|
20
|
-
from: "--db",
|
|
21
|
-
to: "--db-url-stdin",
|
|
22
|
-
hint: "--db-url-stdin or DATABASE_URL"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
commands: DB_COMMANDS,
|
|
26
|
-
from: "--db-url",
|
|
27
|
-
to: "--db-url-stdin",
|
|
28
|
-
hint: "--db-url-stdin or DATABASE_URL"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
commands: ["rls generate"],
|
|
32
|
-
from: "--force",
|
|
33
|
-
to: "--force-rls"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
commands: ["rls verify"],
|
|
37
|
-
from: "--format",
|
|
38
|
-
to: "--kind"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
commands: ["rls verify"],
|
|
42
|
-
from: "--emit",
|
|
43
|
-
to: "--kind"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
commands: ["catalog"],
|
|
47
|
-
from: "--format",
|
|
48
|
-
to: "--kind",
|
|
49
|
-
values: {
|
|
50
|
-
json: "catalog",
|
|
51
|
-
schema: "json-schema",
|
|
52
|
-
markdown: "markdown"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
commands: ["openapi emit"],
|
|
57
|
-
from: "--format",
|
|
58
|
-
to: "--kind"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
commands: [
|
|
62
|
-
"rls generate",
|
|
63
|
-
"rls verify",
|
|
64
|
-
"rls migrate",
|
|
65
|
-
"powersync generate",
|
|
66
|
-
"powersync verify",
|
|
67
|
-
"openapi emit"
|
|
68
|
-
],
|
|
69
|
-
from: "--from",
|
|
70
|
-
to: "--policy"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
commands: ["catalog", "arazzo check"],
|
|
74
|
-
from: "--from",
|
|
75
|
-
to: "--permissions"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
commands: ["rls import", "openapi import"],
|
|
79
|
-
from: "--schema",
|
|
80
|
-
to: "--validator"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
commands: [
|
|
84
|
-
"usage",
|
|
85
|
-
"config",
|
|
86
|
-
"doctor"
|
|
87
|
-
],
|
|
88
|
-
from: "--strict",
|
|
89
|
-
to: "--fail-on",
|
|
90
|
-
hint: "--fail-on warning",
|
|
91
|
-
rewrite: "--fail-on warning"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
commands: ["login"],
|
|
95
|
-
from: "--write",
|
|
96
|
-
to: "--scope",
|
|
97
|
-
hint: "--scope catalog:write",
|
|
98
|
-
rewrite: "--scope catalog:write"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
commands: ["skills install", "skills update"],
|
|
102
|
-
from: "--agent",
|
|
103
|
-
to: "--for"
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
commands: ["skills install", "skills update"],
|
|
107
|
-
from: "--client",
|
|
108
|
-
to: "--for"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
commands: ["init"],
|
|
112
|
-
from: "--agent",
|
|
113
|
-
to: "--integration"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
commands: ["init"],
|
|
117
|
-
from: "--ui",
|
|
118
|
-
to: "--integration"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
commands: ["init"],
|
|
122
|
-
from: "--src",
|
|
123
|
-
to: "--out-dir"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
commands: [
|
|
127
|
-
"rls generate",
|
|
128
|
-
"rls verify",
|
|
129
|
-
"rls migrate"
|
|
130
|
-
],
|
|
131
|
-
from: "--rbac-scaffold",
|
|
132
|
-
to: "--rbac",
|
|
133
|
-
hint: "--rbac supabase",
|
|
134
|
-
rewrite: "--rbac supabase"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
commands: ["rls migrate"],
|
|
138
|
-
from: "--write",
|
|
139
|
-
hint: "rls migrate writes by default; --dry-run prints the plan without writing",
|
|
140
|
-
rewrite: ""
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
commands: ["cloud push"],
|
|
144
|
-
from: "--environment",
|
|
145
|
-
to: "--project",
|
|
146
|
-
hint: "--project <id>: a project id is its environment"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
commands: ["scan"],
|
|
150
|
-
from: "--legacy",
|
|
151
|
-
hint: "permdock scan lists the checks written without PermDock; drop --legacy",
|
|
152
|
-
rewrite: ""
|
|
153
|
-
}
|
|
154
|
-
];
|
|
155
|
-
const COMMAND_MOVES = [
|
|
156
|
-
{
|
|
157
|
-
from: "openapi",
|
|
158
|
-
to: "openapi emit"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
from: "skills",
|
|
162
|
-
to: "skills install"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
from: "arazzo",
|
|
166
|
-
to: "arazzo check"
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
const DEFAULT_CHANGES = [{
|
|
170
|
-
command: "rls migrate",
|
|
171
|
-
unless: ["--write", "--retire-out"],
|
|
172
|
-
add: "--dry-run"
|
|
173
|
-
}];
|
|
174
|
-
/** The rename that matches `flag` (as typed, before any `=`) on `command`. */
|
|
175
|
-
function flagRename(command, flag) {
|
|
176
|
-
return FLAG_RENAMES.find((rename) => rename.from === flag && rename.commands.includes(command));
|
|
177
|
-
}
|
|
178
|
-
function renameMessage(command, rename) {
|
|
179
|
-
const replacement = rename.hint ?? rename.to;
|
|
180
|
-
return replacement === void 0 ? `${command}: ${rename.from} was removed in 0.5.0.` : rename.to === void 0 ? `${command}: ${rename.from} was removed in 0.5.0: ${replacement}.` : `${command}: ${rename.from} is ${replacement} since 0.5.0.`;
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/cli/codemod/cli-calls.ts
|
|
184
|
-
/**
|
|
185
|
-
* `permdock`, `npx permdock@0.4`, `pnpm exec permdock`: the bin name followed
|
|
186
|
-
* by a space.
|
|
187
|
-
*/
|
|
188
|
-
const INVOCATION = /(?<![\w./@-])permdock(?:@[\w.^~-]+)?(?=[ \t])/gu;
|
|
189
|
-
/**
|
|
190
|
-
* Where a shell command ends: an operator, a pipe, a redirect, a comment or a
|
|
191
|
-
* closing backtick. A JSON string also ends at its closing quote. `<id>` is a
|
|
192
|
-
* placeholder, not a redirect, so a redirect needs a space on both sides.
|
|
193
|
-
*/
|
|
194
|
-
function commandEnd(text, from, json) {
|
|
195
|
-
const match = (json ? /&&|\|\||[;|`)\n"]|(?<=\s)\d?[<>]{1,2}(?:&\d|\s)|\s#/u : /&&|\|\||[;|`)\n]|(?<=\s)\d?[<>]{1,2}(?:&\d|\s)|\s#/u).exec(text.slice(from));
|
|
196
|
-
return match === null ? text.length : from + match.index;
|
|
197
|
-
}
|
|
198
|
-
function tokensOf(text, start, end) {
|
|
199
|
-
return [...text.slice(start, end).matchAll(/\S+/gu)].map((match) => ({
|
|
200
|
-
start: start + match.index,
|
|
201
|
-
end: start + match.index + match[0].length,
|
|
202
|
-
text: match[0]
|
|
203
|
-
}));
|
|
204
|
-
}
|
|
205
|
-
function lineColumn(text, offset) {
|
|
206
|
-
const before = text.slice(0, offset);
|
|
207
|
-
return {
|
|
208
|
-
line: before.split("\n").length,
|
|
209
|
-
column: offset - before.lastIndexOf("\n")
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* The leaf path the positional tokens name, with the token after which a moved
|
|
214
|
-
* subcommand goes.
|
|
215
|
-
*/
|
|
216
|
-
function commandOf(tokens) {
|
|
217
|
-
let node = ROOT;
|
|
218
|
-
const path = [];
|
|
219
|
-
let last;
|
|
220
|
-
for (const token of tokens) {
|
|
221
|
-
if (token.text.startsWith("-")) continue;
|
|
222
|
-
const child = node.children.find((item) => item.name === token.text);
|
|
223
|
-
if (child === void 0) break;
|
|
224
|
-
path.push(child.name);
|
|
225
|
-
last = token;
|
|
226
|
-
if (child.kind === "leaf") return { command: path.join(" ") };
|
|
227
|
-
node = child;
|
|
228
|
-
}
|
|
229
|
-
const move = COMMAND_MOVES.find((item) => item.from === path.join(" "));
|
|
230
|
-
if (move === void 0 || last === void 0) return { command: void 0 };
|
|
231
|
-
return {
|
|
232
|
-
command: move.to,
|
|
233
|
-
insertAfter: last,
|
|
234
|
-
insert: move.to.slice(move.from.length + 1)
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function flagEdits(command, tokens, notes) {
|
|
238
|
-
const edits = [];
|
|
239
|
-
for (const [index, token] of tokens.entries()) {
|
|
240
|
-
if (!token.text.startsWith("--")) continue;
|
|
241
|
-
const eq = token.text.indexOf("=");
|
|
242
|
-
const rename = flagRename(command, eq === -1 ? token.text : token.text.slice(0, eq));
|
|
243
|
-
if (rename === void 0) continue;
|
|
244
|
-
const edit = flagEdit(rename, token, eq, tokens[index + 1]);
|
|
245
|
-
if (edit === void 0) notes.push({
|
|
246
|
-
at: token.start,
|
|
247
|
-
message: renameMessage(command, rename)
|
|
248
|
-
});
|
|
249
|
-
else edits.push(...edit);
|
|
250
|
-
}
|
|
251
|
-
return edits;
|
|
252
|
-
}
|
|
253
|
-
function flagEdit(rename, token, eq, next) {
|
|
254
|
-
if (rename.rewrite !== void 0) return eq === -1 ? [{
|
|
255
|
-
start: token.start,
|
|
256
|
-
end: token.end,
|
|
257
|
-
text: rename.rewrite,
|
|
258
|
-
from: token.text
|
|
259
|
-
}] : void 0;
|
|
260
|
-
if (rename.to === void 0 || rename.hint !== void 0) return;
|
|
261
|
-
if (rename.values === void 0) {
|
|
262
|
-
const value = eq === -1 ? "" : token.text.slice(eq);
|
|
263
|
-
return [{
|
|
264
|
-
start: token.start,
|
|
265
|
-
end: token.end,
|
|
266
|
-
text: `${rename.to}${value}`,
|
|
267
|
-
from: token.text
|
|
268
|
-
}];
|
|
269
|
-
}
|
|
270
|
-
if (eq !== -1) {
|
|
271
|
-
const mapped = mappedValue(rename.values, token.text.slice(eq + 1));
|
|
272
|
-
return mapped === void 0 ? void 0 : [{
|
|
273
|
-
start: token.start,
|
|
274
|
-
end: token.end,
|
|
275
|
-
text: `${rename.to}=${mapped}`,
|
|
276
|
-
from: token.text
|
|
277
|
-
}];
|
|
278
|
-
}
|
|
279
|
-
const mapped = next === void 0 ? void 0 : mappedValue(rename.values, next.text);
|
|
280
|
-
if (next === void 0 || mapped === void 0) return;
|
|
281
|
-
return [{
|
|
282
|
-
start: token.start,
|
|
283
|
-
end: token.end,
|
|
284
|
-
text: rename.to,
|
|
285
|
-
from: token.text
|
|
286
|
-
}, {
|
|
287
|
-
start: next.start,
|
|
288
|
-
end: next.end,
|
|
289
|
-
text: mapped,
|
|
290
|
-
from: next.text
|
|
291
|
-
}];
|
|
292
|
-
}
|
|
293
|
-
function mappedValue(values, value) {
|
|
294
|
-
return Object.hasOwn(values, value) ? values[value] : void 0;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Rewrites the 0.5.0 CLI renames in shell commands: package.json scripts, CI
|
|
298
|
-
* workflows, shell scripts. A rename that needs a person, such as an
|
|
299
|
-
* environment name that must become a project id, is a follow-up instead.
|
|
300
|
-
*/
|
|
301
|
-
function rewriteCliCalls(text, options) {
|
|
302
|
-
const edits = [];
|
|
303
|
-
const notes = [];
|
|
304
|
-
for (const match of text.matchAll(INVOCATION)) {
|
|
305
|
-
const start = match.index + match[0].length;
|
|
306
|
-
const tokens = tokensOf(text, start, commandEnd(text, start, options.json));
|
|
307
|
-
const { command, insertAfter, insert } = commandOf(tokens);
|
|
308
|
-
if (command === void 0) continue;
|
|
309
|
-
if (insertAfter !== void 0 && insert !== void 0) edits.push({
|
|
310
|
-
start: insertAfter.end,
|
|
311
|
-
end: insertAfter.end,
|
|
312
|
-
text: ` ${insert}`,
|
|
313
|
-
from: insertAfter.text
|
|
314
|
-
});
|
|
315
|
-
edits.push(...flagEdits(command, tokens, notes));
|
|
316
|
-
for (const change of DEFAULT_CHANGES) {
|
|
317
|
-
const given = new Set(tokens.map((token) => token.text));
|
|
318
|
-
const last = tokens.at(-1);
|
|
319
|
-
if (change.command === command && last !== void 0 && !change.unless.some((flag) => given.has(flag)) && !given.has(change.add)) edits.push({
|
|
320
|
-
start: last.end,
|
|
321
|
-
end: last.end,
|
|
322
|
-
text: ` ${change.add}`,
|
|
323
|
-
from: last.text
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const changes = [];
|
|
328
|
-
let out = text;
|
|
329
|
-
for (const edit of edits.toSorted((a, b) => b.start - a.start)) {
|
|
330
|
-
const { start, end } = edit.text === "" ? dropWithSpace(out, edit) : edit;
|
|
331
|
-
out = `${out.slice(0, start)}${edit.text}${out.slice(end)}`;
|
|
332
|
-
changes.push({
|
|
333
|
-
...lineColumn(text, edit.start),
|
|
334
|
-
from: edit.from,
|
|
335
|
-
to: edit.start === edit.end ? `${edit.from}${edit.text}` : edit.text === "" ? "(removed)" : edit.text
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
return {
|
|
339
|
-
text: out,
|
|
340
|
-
changes: changes.toReversed(),
|
|
341
|
-
followUps: notes.map((note) => {
|
|
342
|
-
const { line, column } = lineColumn(text, note.at);
|
|
343
|
-
return {
|
|
344
|
-
line,
|
|
345
|
-
column,
|
|
346
|
-
name: "cli",
|
|
347
|
-
message: note.message
|
|
348
|
-
};
|
|
349
|
-
})
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
/** A dropped flag takes the space before it, so `a --legacy b` becomes `a b`. */
|
|
353
|
-
function dropWithSpace(text, edit) {
|
|
354
|
-
return text[edit.start - 1] === " " ? {
|
|
355
|
-
start: edit.start - 1,
|
|
356
|
-
end: edit.end
|
|
357
|
-
} : edit;
|
|
358
|
-
}
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region src/cli/codemod/ast.ts
|
|
361
|
-
function nameOf(node) {
|
|
362
|
-
if (node?.type === "Literal") return typeof node.value === "string" ? node.value : void 0;
|
|
363
|
-
return node?.name;
|
|
364
|
-
}
|
|
365
|
-
const NOT_REFERENCES = /* @__PURE__ */ new Set([
|
|
366
|
-
"ImportSpecifier",
|
|
367
|
-
"ImportDefaultSpecifier",
|
|
368
|
-
"ImportNamespaceSpecifier",
|
|
369
|
-
"LabeledStatement",
|
|
370
|
-
"BreakStatement",
|
|
371
|
-
"ContinueStatement",
|
|
372
|
-
"TSEnumMember",
|
|
373
|
-
"TSModuleDeclaration",
|
|
374
|
-
"TSTypeParameter"
|
|
375
|
-
]);
|
|
376
|
-
const KEYED_MEMBERS = /* @__PURE__ */ new Set([
|
|
377
|
-
"MethodDefinition",
|
|
378
|
-
"PropertyDefinition",
|
|
379
|
-
"AccessorProperty",
|
|
380
|
-
"TSPropertySignature",
|
|
381
|
-
"TSMethodSignature",
|
|
382
|
-
"TSAbstractMethodDefinition",
|
|
383
|
-
"TSAbstractPropertyDefinition"
|
|
384
|
-
]);
|
|
385
|
-
/**
|
|
386
|
-
* How an identifier is read: a plain reference, a shorthand property value, the
|
|
387
|
-
* local of an `export { }`, or not a reference.
|
|
388
|
-
*/
|
|
389
|
-
function referencePlace(node, parent, ancestors) {
|
|
390
|
-
const type = parent.type;
|
|
391
|
-
if (node.type === "JSXIdentifier") return type === "JSXOpeningElement" || type === "JSXClosingElement" || type === "JSXMemberExpression" && parent.object === node ? "reference" : "none";
|
|
392
|
-
if (type === "Property") {
|
|
393
|
-
if (ancestors.at(-2)?.type === "ObjectPattern") return "none";
|
|
394
|
-
if (parent.shorthand === true) return parent.value === node ? "shorthand" : "none";
|
|
395
|
-
return parent.key === node && parent.computed !== true ? "none" : "reference";
|
|
396
|
-
}
|
|
397
|
-
if (type === "MemberExpression" || KEYED_MEMBERS.has(type)) return (type === "MemberExpression" ? parent.property : parent.key) === node && parent.computed !== true ? "none" : "reference";
|
|
398
|
-
if (type === "ExportSpecifier") {
|
|
399
|
-
const reexport = ancestors.at(-2)?.source !== null;
|
|
400
|
-
return parent.local === node && !reexport ? "export" : "none";
|
|
401
|
-
}
|
|
402
|
-
if (type === "TSQualifiedName") return parent.right === node ? "none" : "reference";
|
|
403
|
-
return NOT_REFERENCES.has(type) ? "none" : "reference";
|
|
404
|
-
}
|
|
405
|
-
function nodes(value) {
|
|
406
|
-
return Array.isArray(value) ? value.filter(isNode) : [];
|
|
407
|
-
}
|
|
408
|
-
function isNode(value) {
|
|
409
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* A child node under a field `Estree` types as something else (`value`, a type
|
|
413
|
-
* parameter's `name`).
|
|
414
|
-
*/
|
|
415
|
-
function child(node, field) {
|
|
416
|
-
const value = Reflect.get(node, field);
|
|
417
|
-
return isNode(value) ? value : void 0;
|
|
418
|
-
}
|
|
419
|
-
function patternNames(pattern, into) {
|
|
420
|
-
if (pattern === null || pattern === void 0) return;
|
|
421
|
-
switch (pattern.type) {
|
|
422
|
-
case "Identifier":
|
|
423
|
-
into.add(pattern.name ?? "");
|
|
424
|
-
return;
|
|
425
|
-
case "ObjectPattern":
|
|
426
|
-
for (const property of nodes(pattern.properties)) patternNames(property.type === "RestElement" ? property.argument : child(property, "value"), into);
|
|
427
|
-
return;
|
|
428
|
-
case "ArrayPattern":
|
|
429
|
-
for (const element of nodes(pattern.elements)) patternNames(element, into);
|
|
430
|
-
return;
|
|
431
|
-
default: patternNames(pattern.left ?? pattern.argument ?? pattern.parameter, into);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
const DECLARATIONS_WITH_ID = /* @__PURE__ */ new Set([
|
|
435
|
-
"FunctionDeclaration",
|
|
436
|
-
"ClassDeclaration",
|
|
437
|
-
"TSEnumDeclaration",
|
|
438
|
-
"TSTypeAliasDeclaration",
|
|
439
|
-
"TSInterfaceDeclaration",
|
|
440
|
-
"TSModuleDeclaration",
|
|
441
|
-
"TSImportEqualsDeclaration",
|
|
442
|
-
"TSDeclareFunction"
|
|
443
|
-
]);
|
|
444
|
-
function declareStatement(statement, into) {
|
|
445
|
-
const type = statement.type;
|
|
446
|
-
if (type === "VariableDeclaration") for (const declarator of nodes(statement.declarations)) patternNames(declarator.id, into);
|
|
447
|
-
else if (DECLARATIONS_WITH_ID.has(type)) patternNames(statement.id, into);
|
|
448
|
-
else if (statement.declaration !== null && statement.declaration !== void 0) declareStatement(statement.declaration, into);
|
|
449
|
-
else if (type === "ImportDeclaration") for (const spec of nodes(statement.specifiers)) patternNames(spec.local, into);
|
|
450
|
-
}
|
|
451
|
-
const BLOCK_SCOPES = /* @__PURE__ */ new Set([
|
|
452
|
-
"Program",
|
|
453
|
-
"BlockStatement",
|
|
454
|
-
"StaticBlock",
|
|
455
|
-
"TSModuleBlock"
|
|
456
|
-
]);
|
|
457
|
-
const FUNCTION_SCOPES = /* @__PURE__ */ new Set([
|
|
458
|
-
"FunctionDeclaration",
|
|
459
|
-
"FunctionExpression",
|
|
460
|
-
"ArrowFunctionExpression",
|
|
461
|
-
"TSDeclareFunction"
|
|
462
|
-
]);
|
|
463
|
-
/**
|
|
464
|
-
* The names a node declares for the code inside it; `undefined` for a node that
|
|
465
|
-
* opens no scope.
|
|
466
|
-
*/
|
|
467
|
-
function scopeBindings(node) {
|
|
468
|
-
const names = /* @__PURE__ */ new Set();
|
|
469
|
-
const declare = (statements) => {
|
|
470
|
-
for (const statement of statements) if (statement !== null && statement !== void 0) declareStatement(statement, names);
|
|
471
|
-
};
|
|
472
|
-
const type = node.type;
|
|
473
|
-
let opens = true;
|
|
474
|
-
if (BLOCK_SCOPES.has(type)) declare(nodes(node.body));
|
|
475
|
-
else if (FUNCTION_SCOPES.has(type)) {
|
|
476
|
-
for (const param of nodes(node.params)) patternNames(param, names);
|
|
477
|
-
patternNames(type === "FunctionExpression" ? node.id : void 0, names);
|
|
478
|
-
} else if (type === "ClassExpression") patternNames(node.id, names);
|
|
479
|
-
else if (type === "ForStatement") declare([node.init]);
|
|
480
|
-
else if (type === "ForInStatement" || type === "ForOfStatement") declare([node.left]);
|
|
481
|
-
else if (type === "CatchClause") patternNames(node.param, names);
|
|
482
|
-
else if (type === "SwitchStatement") declare(nodes(node.cases).flatMap((branch) => nodes(branch.consequent)));
|
|
483
|
-
else if (type === "TSMappedType") patternNames(node.key, names);
|
|
484
|
-
else opens = false;
|
|
485
|
-
for (const param of nodes(node.typeParameters?.params)) {
|
|
486
|
-
opens = true;
|
|
487
|
-
patternNames(child(param, "name"), names);
|
|
488
|
-
}
|
|
489
|
-
return opens ? names : void 0;
|
|
490
|
-
}
|
|
491
|
-
function bindingsCached(node, cache) {
|
|
492
|
-
let found = cache.get(node);
|
|
493
|
-
if (found === void 0) {
|
|
494
|
-
found = scopeBindings(node) ?? null;
|
|
495
|
-
cache.set(node, found);
|
|
496
|
-
}
|
|
497
|
-
return found;
|
|
498
|
-
}
|
|
499
|
-
function applyEdits(source, edits) {
|
|
500
|
-
let out = source;
|
|
501
|
-
for (const item of edits.toSorted((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, item.start) + item.text + out.slice(item.end);
|
|
502
|
-
return out;
|
|
503
|
-
}
|
|
504
|
-
function position(lineAt, index) {
|
|
505
|
-
const { line, lineStart } = lineAt(index);
|
|
506
|
-
return {
|
|
507
|
-
line,
|
|
508
|
-
column: index - lineStart + 1
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
function lineIndex(source) {
|
|
512
|
-
const starts = [0];
|
|
513
|
-
for (let i = 0; i < source.length; i += 1) if (source.charCodeAt(i) === 10) starts.push(i + 1);
|
|
514
|
-
return (index) => {
|
|
515
|
-
let low = 0;
|
|
516
|
-
let high = starts.length - 1;
|
|
517
|
-
while (low < high) {
|
|
518
|
-
const mid = low + high + 1 >> 1;
|
|
519
|
-
if ((starts[mid] ?? 0) <= index) low = mid;
|
|
520
|
-
else high = mid - 1;
|
|
521
|
-
}
|
|
522
|
-
return {
|
|
523
|
-
line: low + 1,
|
|
524
|
-
lineStart: starts[low] ?? 0
|
|
525
|
-
};
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Every node in source order with its parent and ancestors: Oxc nodes carry no
|
|
530
|
-
* parent, so enter and exit keep a stack.
|
|
531
|
-
*/
|
|
532
|
-
function walk(program, visit) {
|
|
533
|
-
const stack = [];
|
|
534
|
-
const handlers = {};
|
|
535
|
-
for (const type of visitorKeyTypes()) {
|
|
536
|
-
handlers[type] = (node) => {
|
|
537
|
-
visit(node, stack.at(-1), stack);
|
|
538
|
-
stack.push(node);
|
|
539
|
-
};
|
|
540
|
-
handlers[`${type}:exit`] = () => {
|
|
541
|
-
stack.pop();
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
createVisitor(handlers).visit(program);
|
|
545
|
-
}
|
|
546
|
-
//#endregion
|
|
547
|
-
//#region src/cli/codemod/config-moves.ts
|
|
548
|
-
/** Passes over one file before the codemod stops; each pass moves one key. */
|
|
549
|
-
const MAX_PASSES = 500;
|
|
550
|
-
function unwrap(node) {
|
|
551
|
-
if (node?.type === "TSSatisfiesExpression" || node?.type === "TSAsExpression" || node?.type === "ParenthesizedExpression") return unwrap(child(node, "expression"));
|
|
552
|
-
if (node?.type === "CallExpression" && nameOf(node.callee) === "defineConfig") return unwrap(node.arguments?.[0]);
|
|
553
|
-
return node;
|
|
554
|
-
}
|
|
555
|
-
function configRoots(program, file) {
|
|
556
|
-
const roots = [];
|
|
557
|
-
const isConfigFile = basename(file).startsWith("permdock.config.");
|
|
558
|
-
walk(program, (node) => {
|
|
559
|
-
const root = node.type === "CallExpression" && nameOf(node.callee) === "defineConfig" ? unwrap(node) : node.type === "ExportDefaultDeclaration" && isConfigFile ? unwrap(node.declaration) : void 0;
|
|
560
|
-
if (root?.type === "ObjectExpression" && !roots.includes(root)) roots.push(root);
|
|
561
|
-
});
|
|
562
|
-
return roots;
|
|
563
|
-
}
|
|
564
|
-
function keyOf(property) {
|
|
565
|
-
return property.type === "Property" && property.computed !== true ? nameOf(property.key) : void 0;
|
|
566
|
-
}
|
|
567
|
-
function propertyOf(object, key) {
|
|
568
|
-
return nodes(object.properties).find((property) => keyOf(property) === key);
|
|
569
|
-
}
|
|
570
|
-
function objectValue(property) {
|
|
571
|
-
const value = child(property, "value");
|
|
572
|
-
return value?.type === "ObjectExpression" ? value : void 0;
|
|
573
|
-
}
|
|
574
|
-
/** The first property at `move.from` under `object`, with the concrete paths. */
|
|
575
|
-
function find(object, move, depth, path, skipped) {
|
|
576
|
-
const segment = move.from[depth];
|
|
577
|
-
if (segment === void 0) return;
|
|
578
|
-
const keys = segment === "*" ? nodes(object.properties).flatMap((property) => {
|
|
579
|
-
const key = keyOf(property);
|
|
580
|
-
return key === void 0 ? [] : [key];
|
|
581
|
-
}) : [segment];
|
|
582
|
-
for (const key of keys) {
|
|
583
|
-
const property = propertyOf(object, key);
|
|
584
|
-
if (property === void 0) continue;
|
|
585
|
-
const at = [...path, key];
|
|
586
|
-
if (depth === move.from.length - 1) {
|
|
587
|
-
if (skipped.has(property.start)) continue;
|
|
588
|
-
return {
|
|
589
|
-
parent: object,
|
|
590
|
-
property,
|
|
591
|
-
path: at
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
const next = objectValue(property);
|
|
595
|
-
const found = next === void 0 ? void 0 : find(next, move, depth + 1, at, skipped);
|
|
596
|
-
if (found !== void 0) return found;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
/** `move.to` with each `*` replaced by the key `from` matched there. */
|
|
600
|
-
function concreteTarget(move, path) {
|
|
601
|
-
return move.to.map((segment, index) => segment === "*" ? path[index] ?? segment : segment);
|
|
602
|
-
}
|
|
603
|
-
function removal(source, parent, property) {
|
|
604
|
-
const siblings = nodes(parent.properties);
|
|
605
|
-
const index = siblings.indexOf(property);
|
|
606
|
-
const next = siblings[index + 1];
|
|
607
|
-
if (next !== void 0) return {
|
|
608
|
-
start: property.start,
|
|
609
|
-
end: next.start,
|
|
610
|
-
text: ""
|
|
611
|
-
};
|
|
612
|
-
const previous = siblings[index - 1];
|
|
613
|
-
const end = /^\s*,/u.exec(source.slice(property.end))?.[0].length ?? 0;
|
|
614
|
-
return previous === void 0 ? {
|
|
615
|
-
start: property.start,
|
|
616
|
-
end: property.end + end,
|
|
617
|
-
text: ""
|
|
618
|
-
} : {
|
|
619
|
-
start: previous.end,
|
|
620
|
-
end: property.end,
|
|
621
|
-
text: ""
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
/** Adds `text` as the last property of `object`, so moved keys keep their order. */
|
|
625
|
-
function append(source, object, text) {
|
|
626
|
-
const last = nodes(object.properties).at(-1);
|
|
627
|
-
if (last === void 0) return {
|
|
628
|
-
start: object.start + 1,
|
|
629
|
-
end: object.start + 1,
|
|
630
|
-
text: ` ${text} `
|
|
631
|
-
};
|
|
632
|
-
const comma = /^\s*,/u.exec(source.slice(last.end))?.[0].length;
|
|
633
|
-
return comma === void 0 ? {
|
|
634
|
-
start: last.end,
|
|
635
|
-
end: last.end,
|
|
636
|
-
text: `, ${text}`
|
|
637
|
-
} : {
|
|
638
|
-
start: last.end + comma,
|
|
639
|
-
end: last.end + comma,
|
|
640
|
-
text: ` ${text},`
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
function nested(keys, value) {
|
|
644
|
-
const [first, ...rest] = keys;
|
|
645
|
-
return rest.length === 0 ? `${first}: ${value}` : `${first}: { ${nested(rest, value)} }`;
|
|
646
|
-
}
|
|
647
|
-
function step(source, found, to) {
|
|
648
|
-
const relative = to.slice(found.path.length - 1);
|
|
649
|
-
const value = child(found.property, "value");
|
|
650
|
-
const text = value === void 0 ? "" : source.slice(value.start, value.end);
|
|
651
|
-
const from = found.path.join(".");
|
|
652
|
-
const target = to.join(".");
|
|
653
|
-
let object = found.parent;
|
|
654
|
-
for (const [index, key] of relative.entries()) {
|
|
655
|
-
const existing = propertyOf(object, key);
|
|
656
|
-
const last = index === relative.length - 1;
|
|
657
|
-
if (existing === void 0) {
|
|
658
|
-
const insert = nested(relative.slice(index), text);
|
|
659
|
-
return {
|
|
660
|
-
kind: "edits",
|
|
661
|
-
at: found.property.start,
|
|
662
|
-
from,
|
|
663
|
-
to: target,
|
|
664
|
-
edits: object === found.parent ? [{
|
|
665
|
-
start: found.property.start,
|
|
666
|
-
end: found.property.end,
|
|
667
|
-
text: insert
|
|
668
|
-
}] : [removal(source, found.parent, found.property), append(source, object, insert)]
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
const next = objectValue(existing);
|
|
672
|
-
if (last || next === void 0) return {
|
|
673
|
-
kind: "conflict",
|
|
674
|
-
at: found.property.start,
|
|
675
|
-
message: `${from} moved to ${target}, which ${last ? "is already set" : "is not an object literal"}; merge it by hand`
|
|
676
|
-
};
|
|
677
|
-
object = next;
|
|
678
|
-
}
|
|
679
|
-
return {
|
|
680
|
-
kind: "conflict",
|
|
681
|
-
at: found.property.start,
|
|
682
|
-
message: `${from} moved to ${target}; move it by hand`
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* The first move that applies under any config root. A move that conflicts is
|
|
687
|
-
* skipped from then on and reported once in `followUps`.
|
|
688
|
-
*/
|
|
689
|
-
function nextEdits(program, file, source, moves, skipped, followUps) {
|
|
690
|
-
for (const root of configRoots(program, file)) for (const move of moves) {
|
|
691
|
-
const found = find(root, move, 0, [], skipped);
|
|
692
|
-
if (found === void 0) continue;
|
|
693
|
-
const result = step(source, found, concreteTarget(move, found.path));
|
|
694
|
-
if (result.kind === "edits") return result;
|
|
695
|
-
skipped.add(found.property.start);
|
|
696
|
-
if (!followUps.some((item) => item.message === result.message)) followUps.push({
|
|
697
|
-
...position(lineIndex(source), result.at),
|
|
698
|
-
name: found.path.join("."),
|
|
699
|
-
message: result.message
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Moves each key `moves` names to its new path, one key per pass, until no move
|
|
705
|
-
* applies. A key whose target is already set, or sits under a value that is not
|
|
706
|
-
* an object literal, is reported instead.
|
|
707
|
-
*/
|
|
708
|
-
function moveConfigKeys(file, original, moves) {
|
|
709
|
-
let source = original;
|
|
710
|
-
const lineAt = lineIndex(original);
|
|
711
|
-
const changes = [];
|
|
712
|
-
const followUps = [];
|
|
713
|
-
const skipped = /* @__PURE__ */ new Set();
|
|
714
|
-
for (let pass = 0; pass < MAX_PASSES; pass += 1) {
|
|
715
|
-
const parsed = parseSync(file, source, { sourceType: "module" });
|
|
716
|
-
if (parsed.errors.length > 0) break;
|
|
717
|
-
const program = parsed.program;
|
|
718
|
-
const applied = nextEdits(program, file, source, moves, skipped, followUps);
|
|
719
|
-
if (applied === void 0) break;
|
|
720
|
-
changes.push({
|
|
721
|
-
...position(lineAt, Math.min(applied.at, original.length)),
|
|
722
|
-
from: applied.from,
|
|
723
|
-
to: applied.to
|
|
724
|
-
});
|
|
725
|
-
source = applyEdits(source, applied.edits);
|
|
726
|
-
}
|
|
727
|
-
return {
|
|
728
|
-
source,
|
|
729
|
-
changes,
|
|
730
|
-
followUps
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
//#endregion
|
|
734
|
-
//#region src/cli/codemod/renames-0.5.ts
|
|
735
|
-
const SERVER_ADAPTERS = [
|
|
736
|
-
"permdock/server",
|
|
737
|
-
"permdock/hono",
|
|
738
|
-
"permdock/express",
|
|
739
|
-
"permdock/fastify",
|
|
740
|
-
"permdock/elysia",
|
|
741
|
-
"permdock/nest",
|
|
742
|
-
"permdock/node"
|
|
743
|
-
];
|
|
744
|
-
const rows = [
|
|
745
|
-
{
|
|
746
|
-
from: "createServerKernel",
|
|
747
|
-
to: "createPermDock",
|
|
748
|
-
entries: ["permdock/server"]
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
from: "ServerKernel",
|
|
752
|
-
to: "ServerPermDock",
|
|
753
|
-
entries: ["permdock/server"],
|
|
754
|
-
kind: "type"
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
from: "ServerKernelOptions",
|
|
758
|
-
to: "ServerPermDockOptions",
|
|
759
|
-
entries: ["permdock/server"],
|
|
760
|
-
kind: "type"
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
from: "createEvaluationsHandler",
|
|
764
|
-
to: "evaluationsHandler",
|
|
765
|
-
entries: ["permdock/server"]
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
from: "createNativeStore",
|
|
769
|
-
to: "nativeStore",
|
|
770
|
-
entries: ["permdock/react-native"]
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
from: "permdock",
|
|
774
|
-
to: "getPermDock",
|
|
775
|
-
entries: [
|
|
776
|
-
"permdock/server",
|
|
777
|
-
"permdock/node",
|
|
778
|
-
"permdock/terminal",
|
|
779
|
-
"permdock/openai",
|
|
780
|
-
"permdock/claude-agent",
|
|
781
|
-
"permdock/eve"
|
|
782
|
-
],
|
|
783
|
-
kind: "method"
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
from: "permdock",
|
|
787
|
-
to: "middleware",
|
|
788
|
-
entries: [
|
|
789
|
-
"permdock/hono",
|
|
790
|
-
"permdock/express",
|
|
791
|
-
"permdock/elysia",
|
|
792
|
-
"permdock/trpc",
|
|
793
|
-
"permdock/orpc"
|
|
794
|
-
],
|
|
795
|
-
kind: "method"
|
|
796
|
-
},
|
|
797
|
-
{
|
|
798
|
-
from: "load",
|
|
799
|
-
to: "data",
|
|
800
|
-
entries: ["permdock/authzen"],
|
|
801
|
-
kind: "option"
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
from: "loadData",
|
|
805
|
-
to: "data",
|
|
806
|
-
entries: ["permdock/nest"],
|
|
807
|
-
kind: "option"
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
from: "onDenied",
|
|
811
|
-
to: "deniedResponse",
|
|
812
|
-
entries: [
|
|
813
|
-
...SERVER_ADAPTERS,
|
|
814
|
-
"permdock/trpc",
|
|
815
|
-
"permdock/orpc",
|
|
816
|
-
"permdock/supabase/middleware"
|
|
817
|
-
],
|
|
818
|
-
kind: "option",
|
|
819
|
-
calls: ["createPermDock"]
|
|
820
|
-
},
|
|
821
|
-
{
|
|
822
|
-
from: "onDenied",
|
|
823
|
-
to: "deniedText",
|
|
824
|
-
entries: ["permdock/ai-sdk", "permdock/mcp"],
|
|
825
|
-
kind: "option",
|
|
826
|
-
calls: ["createPermDock"]
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
from: "tools",
|
|
830
|
-
to: "operations",
|
|
831
|
-
entries: [
|
|
832
|
-
"permdock/ai-sdk",
|
|
833
|
-
"permdock/openai",
|
|
834
|
-
"permdock/claude-agent",
|
|
835
|
-
"permdock/eve"
|
|
836
|
-
],
|
|
837
|
-
kind: "option",
|
|
838
|
-
calls: ["createPermDock"]
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
from: "OnDenied",
|
|
842
|
-
to: "DeniedResponse",
|
|
843
|
-
entries: ["permdock/server"],
|
|
844
|
-
kind: "type"
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
from: "OnDeniedEvent",
|
|
848
|
-
to: "DeniedResponseEvent",
|
|
849
|
-
entries: ["permdock/server"],
|
|
850
|
-
kind: "type"
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
from: "OnDeniedText",
|
|
854
|
-
to: "DeniedText",
|
|
855
|
-
entries: ["permdock/ai-sdk", "permdock/mcp"],
|
|
856
|
-
kind: "type"
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
from: "PermDockRequest",
|
|
860
|
-
to: "ExpressPermDockRequest",
|
|
861
|
-
entries: ["permdock/express"],
|
|
862
|
-
kind: "type"
|
|
863
|
-
},
|
|
864
|
-
{
|
|
865
|
-
from: "PermDockRequest",
|
|
866
|
-
to: "FastifyPermDockRequest",
|
|
867
|
-
entries: ["permdock/fastify"],
|
|
868
|
-
kind: "type"
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
from: "PermDockEnv",
|
|
872
|
-
to: "HonoPermDockEnv",
|
|
873
|
-
entries: ["permdock/hono"],
|
|
874
|
-
kind: "type"
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
from: "ElysiaContext",
|
|
878
|
-
to: "ElysiaPermDockContext",
|
|
879
|
-
entries: ["permdock/elysia"],
|
|
880
|
-
kind: "type"
|
|
881
|
-
},
|
|
882
|
-
{
|
|
883
|
-
from: "ElysiaCtx",
|
|
884
|
-
to: "ElysiaRequestContext",
|
|
885
|
-
entries: ["permdock/elysia"],
|
|
886
|
-
kind: "type"
|
|
887
|
-
},
|
|
888
|
-
{
|
|
889
|
-
from: "ConvexPermDockCtx",
|
|
890
|
-
to: "ConvexPermDockContext",
|
|
891
|
-
entries: ["permdock/convex"],
|
|
892
|
-
kind: "type"
|
|
893
|
-
},
|
|
894
|
-
{
|
|
895
|
-
from: "ServerPermDockProviderProps",
|
|
896
|
-
to: "NextPermDockProviderProps",
|
|
897
|
-
entries: ["permdock/next"],
|
|
898
|
-
kind: "type"
|
|
899
|
-
},
|
|
900
|
-
{
|
|
901
|
-
from: "NativePermDockProviderProps",
|
|
902
|
-
to: "ReactNativePermDockProviderProps",
|
|
903
|
-
entries: ["permdock/react-native"],
|
|
904
|
-
kind: "type"
|
|
905
|
-
},
|
|
906
|
-
{
|
|
907
|
-
from: "PermDockSvelteOptions",
|
|
908
|
-
to: "SveltePermDockOptions",
|
|
909
|
-
entries: ["permdock/svelte"],
|
|
910
|
-
kind: "type"
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
from: "subjectFromSession",
|
|
914
|
-
to: "subjectFromEve",
|
|
915
|
-
entries: ["permdock/eve"]
|
|
916
|
-
},
|
|
917
|
-
{
|
|
918
|
-
from: "actorFromSession",
|
|
919
|
-
to: "actorFromEve",
|
|
920
|
-
entries: ["permdock/eve"]
|
|
921
|
-
},
|
|
922
|
-
{
|
|
923
|
-
from: "CredentialPrincipal",
|
|
924
|
-
to: "ApiKeyPrincipal",
|
|
925
|
-
entries: ["permdock"],
|
|
926
|
-
kind: "type"
|
|
927
|
-
},
|
|
928
|
-
{
|
|
929
|
-
from: "LinkPrincipal",
|
|
930
|
-
to: "CapabilityPrincipal",
|
|
931
|
-
entries: ["permdock"],
|
|
932
|
-
kind: "type"
|
|
933
|
-
},
|
|
934
|
-
{
|
|
935
|
-
from: "SsfSubjectMapper",
|
|
936
|
-
to: "SsfSubjectResolver",
|
|
937
|
-
entries: ["permdock/ssf"],
|
|
938
|
-
kind: "type"
|
|
939
|
-
},
|
|
940
|
-
{
|
|
941
|
-
from: "memorySettings",
|
|
942
|
-
to: "memorySettingsSource",
|
|
943
|
-
entries: ["permdock"]
|
|
944
|
-
},
|
|
945
|
-
{
|
|
946
|
-
from: "memoryRelations",
|
|
947
|
-
to: "memoryRelationSource",
|
|
948
|
-
entries: ["permdock"]
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
from: "memorySink",
|
|
952
|
-
to: "memoryDecisionSink",
|
|
953
|
-
entries: ["permdock"]
|
|
954
|
-
},
|
|
955
|
-
{
|
|
956
|
-
from: "memoryApprovalPolicies",
|
|
957
|
-
to: "memoryApprovalPolicySource",
|
|
958
|
-
entries: ["permdock"]
|
|
959
|
-
},
|
|
960
|
-
{
|
|
961
|
-
from: "memoryApprovalDelegations",
|
|
962
|
-
to: "memoryApprovalDelegationSource",
|
|
963
|
-
entries: ["permdock/approvals"]
|
|
964
|
-
},
|
|
965
|
-
{
|
|
966
|
-
from: "memoryAccessReviews",
|
|
967
|
-
to: "memoryAccessReviewStore",
|
|
968
|
-
entries: ["permdock/approvals"]
|
|
969
|
-
},
|
|
970
|
-
{
|
|
971
|
-
from: "MemoryAccessReviews",
|
|
972
|
-
to: "MemoryAccessReviewStore",
|
|
973
|
-
entries: ["permdock/approvals"],
|
|
974
|
-
kind: "type"
|
|
975
|
-
},
|
|
976
|
-
{
|
|
977
|
-
from: "MemoryRelationsData",
|
|
978
|
-
to: "MemoryRelationSourceData",
|
|
979
|
-
entries: ["permdock"],
|
|
980
|
-
kind: "type"
|
|
981
|
-
},
|
|
982
|
-
{
|
|
983
|
-
from: "MemorySink",
|
|
984
|
-
to: "MemoryDecisionSink",
|
|
985
|
-
entries: ["permdock"],
|
|
986
|
-
kind: "type"
|
|
987
|
-
},
|
|
988
|
-
{
|
|
989
|
-
from: "MemorySinkOptions",
|
|
990
|
-
to: "MemoryDecisionSinkOptions",
|
|
991
|
-
entries: ["permdock"],
|
|
992
|
-
kind: "type"
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
from: "memoryCredentials",
|
|
996
|
-
to: "memoryCredentialStore",
|
|
997
|
-
entries: ["permdock/server"]
|
|
998
|
-
},
|
|
999
|
-
{
|
|
1000
|
-
from: "MemoryCredentials",
|
|
1001
|
-
to: "MemoryCredentialStore",
|
|
1002
|
-
entries: ["permdock/server"],
|
|
1003
|
-
kind: "type"
|
|
1004
|
-
},
|
|
1005
|
-
{
|
|
1006
|
-
from: "memoryStorage",
|
|
1007
|
-
to: "memorySnapshotStorage",
|
|
1008
|
-
entries: ["permdock/react-native"]
|
|
1009
|
-
},
|
|
1010
|
-
{
|
|
1011
|
-
from: "rlsParity",
|
|
1012
|
-
to: "testRlsParity",
|
|
1013
|
-
entries: ["permdock/testing"]
|
|
1014
|
-
},
|
|
1015
|
-
{
|
|
1016
|
-
from: "ormParity",
|
|
1017
|
-
to: "testOrmParity",
|
|
1018
|
-
entries: ["permdock/testing"]
|
|
1019
|
-
},
|
|
1020
|
-
{
|
|
1021
|
-
from: "fromStripeEntitlements",
|
|
1022
|
-
to: "stripeEntitlementSource",
|
|
1023
|
-
entries: ["permdock"]
|
|
1024
|
-
},
|
|
1025
|
-
{
|
|
1026
|
-
from: "fromTable",
|
|
1027
|
-
to: "tableMembershipSource",
|
|
1028
|
-
entries: ["permdock/supabase"]
|
|
1029
|
-
},
|
|
1030
|
-
{
|
|
1031
|
-
from: "fromJunction",
|
|
1032
|
-
to: "junctionMembershipSource",
|
|
1033
|
-
entries: ["permdock/supabase"]
|
|
1034
|
-
},
|
|
1035
|
-
{
|
|
1036
|
-
from: "fromSupabasePostgres",
|
|
1037
|
-
to: "supabasePostgresQuery",
|
|
1038
|
-
entries: ["permdock/supabase"]
|
|
1039
|
-
},
|
|
1040
|
-
{
|
|
1041
|
-
from: "verifyWebBotAuth",
|
|
1042
|
-
to: "webBotAuthVerifier",
|
|
1043
|
-
entries: SERVER_ADAPTERS
|
|
1044
|
-
},
|
|
1045
|
-
{
|
|
1046
|
-
from: "RoleSource",
|
|
1047
|
-
to: "CustomRoleSource",
|
|
1048
|
-
entries: ["permdock"],
|
|
1049
|
-
kind: "type"
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
from: "RoleSourceFactory",
|
|
1053
|
-
to: "CustomRoleSourceFactory",
|
|
1054
|
-
entries: ["permdock"],
|
|
1055
|
-
kind: "type"
|
|
1056
|
-
},
|
|
1057
|
-
{
|
|
1058
|
-
from: "memoryRoleSource",
|
|
1059
|
-
to: "memoryCustomRoleSource",
|
|
1060
|
-
entries: ["permdock"]
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
from: "testRoleSource",
|
|
1064
|
-
to: "testCustomRoleSource",
|
|
1065
|
-
entries: ["permdock/testing"]
|
|
1066
|
-
},
|
|
1067
|
-
{
|
|
1068
|
-
from: "betterAuthRoleSource",
|
|
1069
|
-
to: "betterAuthCustomRoleSource",
|
|
1070
|
-
entries: ["permdock/better-auth"]
|
|
1071
|
-
},
|
|
1072
|
-
{
|
|
1073
|
-
from: "BetterAuthRoleSourceOptions",
|
|
1074
|
-
to: "BetterAuthCustomRoleSourceOptions",
|
|
1075
|
-
entries: ["permdock/better-auth"],
|
|
1076
|
-
kind: "type"
|
|
1077
|
-
},
|
|
1078
|
-
{
|
|
1079
|
-
from: "PermDockStorage",
|
|
1080
|
-
to: "SnapshotStorage",
|
|
1081
|
-
entries: ["permdock/react-native"],
|
|
1082
|
-
kind: "type"
|
|
1083
|
-
},
|
|
1084
|
-
{
|
|
1085
|
-
from: "store",
|
|
1086
|
-
to: "directory",
|
|
1087
|
-
entries: ["permdock/scim"],
|
|
1088
|
-
kind: "option",
|
|
1089
|
-
calls: ["scimHandler"]
|
|
1090
|
-
},
|
|
1091
|
-
{
|
|
1092
|
-
from: "store",
|
|
1093
|
-
to: "reviews",
|
|
1094
|
-
entries: ["permdock/approvals"],
|
|
1095
|
-
kind: "option",
|
|
1096
|
-
calls: ["startAccessReview"]
|
|
1097
|
-
},
|
|
1098
|
-
{
|
|
1099
|
-
from: "delegations",
|
|
1100
|
-
to: "approvalDelegations",
|
|
1101
|
-
entries: ["permdock/approvals"],
|
|
1102
|
-
kind: "option",
|
|
1103
|
-
calls: ["approvalsHandler", "matchDelegation"]
|
|
1104
|
-
},
|
|
1105
|
-
{
|
|
1106
|
-
from: "source",
|
|
1107
|
-
to: "call",
|
|
1108
|
-
entries: ["permdock"],
|
|
1109
|
-
kind: "option"
|
|
1110
|
-
},
|
|
1111
|
-
{
|
|
1112
|
-
from: "testAuthZen",
|
|
1113
|
-
to: "testAuthzen",
|
|
1114
|
-
entries: ["permdock/testing"]
|
|
1115
|
-
},
|
|
1116
|
-
{
|
|
1117
|
-
from: "AuthZenVectors",
|
|
1118
|
-
to: "AuthzenVectors",
|
|
1119
|
-
entries: ["permdock/testing"],
|
|
1120
|
-
kind: "type"
|
|
1121
|
-
},
|
|
1122
|
-
{
|
|
1123
|
-
from: "AuthZenEvaluationVector",
|
|
1124
|
-
to: "AuthzenEvaluationVector",
|
|
1125
|
-
entries: ["permdock/testing"],
|
|
1126
|
-
kind: "type"
|
|
1127
|
-
},
|
|
1128
|
-
{
|
|
1129
|
-
from: "AuthZenEvaluationsVector",
|
|
1130
|
-
to: "AuthzenEvaluationsVector",
|
|
1131
|
-
entries: ["permdock/testing"],
|
|
1132
|
-
kind: "type"
|
|
1133
|
-
},
|
|
1134
|
-
{
|
|
1135
|
-
from: "AuthZenSearchVector",
|
|
1136
|
-
to: "AuthzenSearchVector",
|
|
1137
|
-
entries: ["permdock/testing"],
|
|
1138
|
-
kind: "type"
|
|
1139
|
-
},
|
|
1140
|
-
{
|
|
1141
|
-
from: "TestAuthZenOptions",
|
|
1142
|
-
to: "TestAuthzenOptions",
|
|
1143
|
-
entries: ["permdock/testing"],
|
|
1144
|
-
kind: "type"
|
|
1145
|
-
},
|
|
1146
|
-
{
|
|
1147
|
-
from: "powersyncSource",
|
|
1148
|
-
to: "powerSyncSource",
|
|
1149
|
-
entries: ["permdock/react-native"]
|
|
1150
|
-
},
|
|
1151
|
-
{
|
|
1152
|
-
from: "summariseSubject",
|
|
1153
|
-
to: "summarizeSubject",
|
|
1154
|
-
entries: ["permdock/approvals"]
|
|
1155
|
-
},
|
|
1156
|
-
{
|
|
1157
|
-
from: "WebhookFailureReason",
|
|
1158
|
-
to: "WebhookFailureCause",
|
|
1159
|
-
entries: ["permdock/cloud"],
|
|
1160
|
-
kind: "type"
|
|
1161
|
-
},
|
|
1162
|
-
{
|
|
1163
|
-
from: "ApprovalResumeFailure",
|
|
1164
|
-
to: "ApprovalResumeFailureCause",
|
|
1165
|
-
entries: ["permdock/approvals"],
|
|
1166
|
-
kind: "type"
|
|
1167
|
-
},
|
|
1168
|
-
{
|
|
1169
|
-
from: "window",
|
|
1170
|
-
to: "per",
|
|
1171
|
-
entries: ["permdock", ...SERVER_ADAPTERS],
|
|
1172
|
-
kind: "method"
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
from: "DefinePermissionsOptions",
|
|
1176
|
-
to: "PermissionsOptions",
|
|
1177
|
-
entries: ["permdock"],
|
|
1178
|
-
kind: "type"
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
from: "SignCapabilityOptions",
|
|
1182
|
-
to: "CapabilityOptions",
|
|
1183
|
-
entries: ["permdock"],
|
|
1184
|
-
kind: "type"
|
|
1185
|
-
},
|
|
1186
|
-
{
|
|
1187
|
-
from: "SignRunTicketOptions",
|
|
1188
|
-
to: "RunTicketOptions",
|
|
1189
|
-
entries: ["permdock/server"],
|
|
1190
|
-
kind: "type"
|
|
1191
|
-
},
|
|
1192
|
-
{
|
|
1193
|
-
from: "StartAccessReviewOptions",
|
|
1194
|
-
to: "AccessReviewOptions",
|
|
1195
|
-
entries: ["permdock/approvals"],
|
|
1196
|
-
kind: "type"
|
|
1197
|
-
},
|
|
1198
|
-
{
|
|
1199
|
-
from: "StartAutomationOptions",
|
|
1200
|
-
to: "AutomationOptions",
|
|
1201
|
-
entries: ["permdock/workflow", "permdock/workflow-sdk"],
|
|
1202
|
-
kind: "type"
|
|
1203
|
-
},
|
|
1204
|
-
{
|
|
1205
|
-
from: "VerifyWebhookOptions",
|
|
1206
|
-
to: "WebhookOptions",
|
|
1207
|
-
entries: ["permdock/cloud"],
|
|
1208
|
-
kind: "type"
|
|
1209
|
-
},
|
|
1210
|
-
{
|
|
1211
|
-
from: "UseRolesOptions",
|
|
1212
|
-
to: "RolesOptions",
|
|
1213
|
-
entries: [
|
|
1214
|
-
"permdock/vue",
|
|
1215
|
-
"permdock/svelte",
|
|
1216
|
-
"permdock/solid"
|
|
1217
|
-
],
|
|
1218
|
-
kind: "type"
|
|
1219
|
-
},
|
|
1220
|
-
{
|
|
1221
|
-
from: "ConvexCtxLike",
|
|
1222
|
-
to: "ConvexContextLike",
|
|
1223
|
-
entries: ["permdock/convex"],
|
|
1224
|
-
kind: "type"
|
|
1225
|
-
},
|
|
1226
|
-
{
|
|
1227
|
-
from: "createJwtSubjectResolver",
|
|
1228
|
-
to: "jwtSubjectResolver",
|
|
1229
|
-
entries: ["permdock/jwt"]
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
from: "createClerkSubjectResolver",
|
|
1233
|
-
to: "clerkSubjectResolver",
|
|
1234
|
-
entries: ["permdock/clerk"]
|
|
1235
|
-
},
|
|
1236
|
-
{
|
|
1237
|
-
from: "fromResponse",
|
|
1238
|
-
to: "sendResponse",
|
|
1239
|
-
entries: ["permdock/node"]
|
|
1240
|
-
},
|
|
1241
|
-
{
|
|
1242
|
-
from: "fromResponse",
|
|
1243
|
-
to: "send",
|
|
1244
|
-
entries: ["permdock/node"],
|
|
1245
|
-
kind: "method"
|
|
1246
|
-
},
|
|
1247
|
-
{
|
|
1248
|
-
from: "createPermDock",
|
|
1249
|
-
to: "getPermDockSync",
|
|
1250
|
-
entries: ["permdock"]
|
|
1251
|
-
},
|
|
1252
|
-
{
|
|
1253
|
-
from: "createPermDock",
|
|
1254
|
-
to: "getPermDock",
|
|
1255
|
-
entries: ["permdock/pdp"]
|
|
1256
|
-
},
|
|
1257
|
-
{
|
|
1258
|
-
from: "loadRelations",
|
|
1259
|
-
to: "prefetchRelations",
|
|
1260
|
-
entries: ["permdock", "permdock/pdp"],
|
|
1261
|
-
kind: "method"
|
|
1262
|
-
}
|
|
1263
|
-
];
|
|
1264
|
-
/** Every 0.5.0 rename, one row per `from` and target. */
|
|
1265
|
-
const RENAMES_0_5 = Object.freeze(rows.map((row) => Object.freeze({
|
|
1266
|
-
...row,
|
|
1267
|
-
entries: Object.freeze([...row.entries]),
|
|
1268
|
-
...row.calls === void 0 ? {} : { calls: Object.freeze([...row.calls]) }
|
|
1269
|
-
})));
|
|
1270
|
-
/** 0.5.0 changes the codemod lists as manual follow-ups. */
|
|
1271
|
-
const SIGNATURE_CHANGES_0_5 = Object.freeze([
|
|
1272
|
-
{
|
|
1273
|
-
name: "permittedIds",
|
|
1274
|
-
entries: ["permdock"],
|
|
1275
|
-
before: "permittedIds(permdock, permission, scope)",
|
|
1276
|
-
after: "permdock.permittedIds(permission, scope)"
|
|
1277
|
-
},
|
|
1278
|
-
{
|
|
1279
|
-
name: "defineApp",
|
|
1280
|
-
entries: ["permdock"],
|
|
1281
|
-
before: "defineApp(policy, options)",
|
|
1282
|
-
after: "definePermDock(policy, options), imported from permdock/app"
|
|
1283
|
-
},
|
|
1284
|
-
{
|
|
1285
|
-
name: "mayUse",
|
|
1286
|
-
entries: ["permdock"],
|
|
1287
|
-
before: "mayUse(permdock, permission)",
|
|
1288
|
-
after: "permdock.mayUse(permission)"
|
|
1289
|
-
},
|
|
1290
|
-
{
|
|
1291
|
-
name: "subjectFromApiKey",
|
|
1292
|
-
entries: ["permdock/server"],
|
|
1293
|
-
before: "subjectFromApiKey(options)(key)",
|
|
1294
|
-
after: "subjectFromApiKey(key, options)",
|
|
1295
|
-
shape: "curried"
|
|
1296
|
-
},
|
|
1297
|
-
{
|
|
1298
|
-
name: "subjectFromBetterAuth",
|
|
1299
|
-
entries: ["permdock/better-auth"],
|
|
1300
|
-
before: "subjectFromBetterAuth(auth, session, options)",
|
|
1301
|
-
after: "subjectFromBetterAuth(session, { auth, ...options })"
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
name: "capabilitySubject",
|
|
1305
|
-
entries: ["permdock"],
|
|
1306
|
-
before: "capabilitySubject(...)",
|
|
1307
|
-
after: "subjectFromCapability(token, options)"
|
|
1308
|
-
},
|
|
1309
|
-
{
|
|
1310
|
-
name: "credentialSubject",
|
|
1311
|
-
entries: ["permdock"],
|
|
1312
|
-
before: "credentialSubject(...)",
|
|
1313
|
-
after: "subjectFromApiKey(key, options)"
|
|
1314
|
-
},
|
|
1315
|
-
{
|
|
1316
|
-
name: "MappedSubject",
|
|
1317
|
-
entries: ["permdock/jwt"],
|
|
1318
|
-
before: "MappedSubject",
|
|
1319
|
-
after: "Subject<JwtPrincipal>"
|
|
1320
|
-
},
|
|
1321
|
-
{
|
|
1322
|
-
name: "verifyWebBotAuth",
|
|
1323
|
-
entries: SERVER_ADAPTERS,
|
|
1324
|
-
before: "verifyWebBotAuth(request, options)",
|
|
1325
|
-
after: "webBotAuthVerifier(options)(request)"
|
|
1326
|
-
},
|
|
1327
|
-
{
|
|
1328
|
-
name: "verifyWebhook",
|
|
1329
|
-
entries: ["permdock/cloud"],
|
|
1330
|
-
before: "verifyWebhook(request, options).reason",
|
|
1331
|
-
after: "verifyWebhook(request, options).cause"
|
|
1332
|
-
},
|
|
1333
|
-
{
|
|
1334
|
-
name: "inspectApproval",
|
|
1335
|
-
entries: ["permdock/approvals"],
|
|
1336
|
-
before: "inspectApproval(store, token).detail",
|
|
1337
|
-
after: "inspectApproval(store, token).cause"
|
|
1338
|
-
},
|
|
1339
|
-
{
|
|
1340
|
-
name: "consumeApproval",
|
|
1341
|
-
entries: ["permdock/approvals"],
|
|
1342
|
-
before: "consumeApproval(store, token).detail",
|
|
1343
|
-
after: "consumeApproval(store, token).cause"
|
|
1344
|
-
},
|
|
1345
|
-
{
|
|
1346
|
-
name: "requireAccess",
|
|
1347
|
-
entries: ["permdock/next"],
|
|
1348
|
-
before: "requireAccess({ permission, data, tenant, onDenied })",
|
|
1349
|
-
after: "requirePermission(permission, data, { tenant, onDenied })"
|
|
1350
|
-
},
|
|
1351
|
-
{
|
|
1352
|
-
name: "RequireAccessInput",
|
|
1353
|
-
entries: ["permdock/next"],
|
|
1354
|
-
before: "RequireAccessInput",
|
|
1355
|
-
after: "PermissionRequirementOptions"
|
|
1356
|
-
}
|
|
1357
|
-
]);
|
|
1358
|
-
/**
|
|
1359
|
-
* 0.8 folds the `tenant` / `team` config shorthands into the named-scope forms,
|
|
1360
|
-
* under the `tenant` / `team` aliases a policy's first and second scope answer
|
|
1361
|
-
* to.
|
|
1362
|
-
*/
|
|
1363
|
-
const CONFIG_MOVES_0_8 = Object.freeze([
|
|
1364
|
-
{
|
|
1365
|
-
from: ["rls", "tenantType"],
|
|
1366
|
-
to: [
|
|
1367
|
-
"rls",
|
|
1368
|
-
"scopeTypes",
|
|
1369
|
-
"tenant"
|
|
1370
|
-
]
|
|
1371
|
-
},
|
|
1372
|
-
{
|
|
1373
|
-
from: ["rls", "teamType"],
|
|
1374
|
-
to: [
|
|
1375
|
-
"rls",
|
|
1376
|
-
"scopeTypes",
|
|
1377
|
-
"team"
|
|
1378
|
-
]
|
|
1379
|
-
},
|
|
1380
|
-
{
|
|
1381
|
-
from: [
|
|
1382
|
-
"rls",
|
|
1383
|
-
"memberships",
|
|
1384
|
-
"tenant"
|
|
1385
|
-
],
|
|
1386
|
-
to: [
|
|
1387
|
-
"rls",
|
|
1388
|
-
"memberships",
|
|
1389
|
-
"scopes",
|
|
1390
|
-
"tenant"
|
|
1391
|
-
]
|
|
1392
|
-
},
|
|
1393
|
-
{
|
|
1394
|
-
from: [
|
|
1395
|
-
"rls",
|
|
1396
|
-
"memberships",
|
|
1397
|
-
"team"
|
|
1398
|
-
],
|
|
1399
|
-
to: [
|
|
1400
|
-
"rls",
|
|
1401
|
-
"memberships",
|
|
1402
|
-
"scopes",
|
|
1403
|
-
"team"
|
|
1404
|
-
]
|
|
1405
|
-
},
|
|
1406
|
-
...[[
|
|
1407
|
-
"rls",
|
|
1408
|
-
"memberships",
|
|
1409
|
-
"scopes",
|
|
1410
|
-
"*"
|
|
1411
|
-
], [
|
|
1412
|
-
"rls",
|
|
1413
|
-
"memberships",
|
|
1414
|
-
"resource",
|
|
1415
|
-
"*"
|
|
1416
|
-
]].flatMap((table) => ["tenant", "team"].map((scope) => ({
|
|
1417
|
-
from: [...table, scope],
|
|
1418
|
-
to: [
|
|
1419
|
-
...table,
|
|
1420
|
-
"columns",
|
|
1421
|
-
scope
|
|
1422
|
-
]
|
|
1423
|
-
})))
|
|
1424
|
-
]);
|
|
1425
|
-
/**
|
|
1426
|
-
* 0.8 drops `team` from the client `RolesOptions`; `{ scope, id }` names any
|
|
1427
|
-
* scope. Reported, since only the reader knows the scope a `team` id belongs
|
|
1428
|
-
* to.
|
|
1429
|
-
*/
|
|
1430
|
-
const SIGNATURE_CHANGES_0_8 = Object.freeze([{
|
|
1431
|
-
name: "useRoles",
|
|
1432
|
-
entries: [
|
|
1433
|
-
"permdock/react",
|
|
1434
|
-
"permdock/react-native",
|
|
1435
|
-
"permdock/vue",
|
|
1436
|
-
"permdock/solid"
|
|
1437
|
-
],
|
|
1438
|
-
before: "useRoles({ team: id })",
|
|
1439
|
-
after: "useRoles({ scope: \"team\", id })"
|
|
1440
|
-
}, ...["roles", "rolesFor"].map((name) => ({
|
|
1441
|
-
name,
|
|
1442
|
-
entries: ["permdock/svelte"],
|
|
1443
|
-
before: `${name}(() => ({ team: id }))`,
|
|
1444
|
-
after: `${name}(() => ({ scope: "team", id }))`
|
|
1445
|
-
}))]);
|
|
1446
|
-
//#endregion
|
|
1447
|
-
//#region src/cli/codemod/shapes-0.5.ts
|
|
1448
|
-
const JSX_KITS = [
|
|
1449
|
-
"permdock/react",
|
|
1450
|
-
"permdock/react-native",
|
|
1451
|
-
"permdock/solid"
|
|
1452
|
-
];
|
|
1453
|
-
const PROP_RENAMES_0_5 = Object.freeze([{
|
|
1454
|
-
component: "Protected",
|
|
1455
|
-
entries: [...JSX_KITS, "permdock/vue"],
|
|
1456
|
-
from: "fallback",
|
|
1457
|
-
to: "denied"
|
|
1458
|
-
}, {
|
|
1459
|
-
component: "PermDockProvider",
|
|
1460
|
-
entries: JSX_KITS,
|
|
1461
|
-
from: "fallback",
|
|
1462
|
-
to: "denied",
|
|
1463
|
-
within: "defaults"
|
|
1464
|
-
}]);
|
|
1465
|
-
const TEMPLATE_HINTS_0_5 = Object.freeze([{
|
|
1466
|
-
component: "Protected",
|
|
1467
|
-
entries: ["permdock/vue"],
|
|
1468
|
-
pattern: /(?:#|v-slot:)fallback\b/gu,
|
|
1469
|
-
name: "fallback",
|
|
1470
|
-
message: "the `<Protected>` slot `fallback` is `denied`: `#denied`"
|
|
1471
|
-
}, {
|
|
1472
|
-
component: "Protected",
|
|
1473
|
-
entries: ["permdock/svelte"],
|
|
1474
|
-
pattern: /\{#snippet\s+fallback\b|\bslot=["']fallback["']/gu,
|
|
1475
|
-
name: "fallback",
|
|
1476
|
-
message: "the `<Protected>` snippet `fallback` is `denied`: `{#snippet denied(decision)}`"
|
|
1477
|
-
}]);
|
|
1478
|
-
const AWAIT_RENAMES_0_5 = Object.freeze([{
|
|
1479
|
-
name: "createPermDock",
|
|
1480
|
-
entries: ["permdock"],
|
|
1481
|
-
to: "getPermDock",
|
|
1482
|
-
sync: "getPermDockSync"
|
|
1483
|
-
}]);
|
|
1484
|
-
const CALL_RENAMES_0_5 = Object.freeze([{
|
|
1485
|
-
from: "rolesOf",
|
|
1486
|
-
to: "rolesFor",
|
|
1487
|
-
entries: ["permdock"],
|
|
1488
|
-
kind: "option",
|
|
1489
|
-
calls: ["customRoleSource"]
|
|
1490
|
-
}]);
|
|
1491
|
-
const METHOD_FUNCTIONS_0_5 = Object.freeze([
|
|
1492
|
-
"decideRoleChange",
|
|
1493
|
-
"decideCredential",
|
|
1494
|
-
"decideAutomation",
|
|
1495
|
-
"decideSupportSession",
|
|
1496
|
-
"whoCan"
|
|
1497
|
-
].map((method) => ({
|
|
1498
|
-
method,
|
|
1499
|
-
to: method,
|
|
1500
|
-
entry: "permdock",
|
|
1501
|
-
anyReceiver: true
|
|
1502
|
-
})).concat([{
|
|
1503
|
-
method: "simulate",
|
|
1504
|
-
to: "simulateArazzo",
|
|
1505
|
-
entry: "permdock",
|
|
1506
|
-
anyReceiver: true,
|
|
1507
|
-
argument: "arazzo"
|
|
1508
|
-
}, {
|
|
1509
|
-
method: "activate",
|
|
1510
|
-
to: "activate",
|
|
1511
|
-
entry: "permdock",
|
|
1512
|
-
anyReceiver: false
|
|
1513
|
-
}]));
|
|
1514
|
-
const FUNCTION_METHODS_0_5 = Object.freeze([{
|
|
1515
|
-
name: "permittedIds",
|
|
1516
|
-
entry: "permdock",
|
|
1517
|
-
method: "permittedIds"
|
|
1518
|
-
}, {
|
|
1519
|
-
name: "mayUse",
|
|
1520
|
-
entry: "permdock",
|
|
1521
|
-
method: "mayUse"
|
|
1522
|
-
}]);
|
|
1523
|
-
const INSTANCE_FACTORIES = [
|
|
1524
|
-
"createPermDock",
|
|
1525
|
-
"getPermDock",
|
|
1526
|
-
"getPermDockSync"
|
|
1527
|
-
];
|
|
1528
|
-
const OPTION_WRAPS_0_5 = Object.freeze([{
|
|
1529
|
-
key: "approvalPolicies",
|
|
1530
|
-
wrapper: "approvalPolicies",
|
|
1531
|
-
entry: "permdock",
|
|
1532
|
-
calls: INSTANCE_FACTORIES,
|
|
1533
|
-
entries: ["permdock", "permdock/pdp"],
|
|
1534
|
-
already: [
|
|
1535
|
-
"approvalPolicies",
|
|
1536
|
-
"memoryApprovalPolicySource",
|
|
1537
|
-
"memoryApprovalPolicies"
|
|
1538
|
-
],
|
|
1539
|
-
reportElsewhere: true
|
|
1540
|
-
}, {
|
|
1541
|
-
key: "policies",
|
|
1542
|
-
wrapper: "hostedPolicies",
|
|
1543
|
-
entry: "permdock",
|
|
1544
|
-
calls: INSTANCE_FACTORIES,
|
|
1545
|
-
entries: ["permdock", "permdock/pdp"],
|
|
1546
|
-
already: ["hostedPolicies"],
|
|
1547
|
-
reportElsewhere: false
|
|
1548
|
-
}]);
|
|
1549
|
-
const DURATION_KEYS_0_5 = Object.freeze({
|
|
1550
|
-
keys: [
|
|
1551
|
-
"ttl",
|
|
1552
|
-
"after",
|
|
1553
|
-
"per",
|
|
1554
|
-
"window",
|
|
1555
|
-
"maxDuration",
|
|
1556
|
-
"duration"
|
|
1557
|
-
],
|
|
1558
|
-
lists: ["durations"]
|
|
1559
|
-
});
|
|
1560
|
-
//#endregion
|
|
1561
|
-
//#region src/cli/codemod/shapes-0.17.ts
|
|
1562
|
-
const COMBINATORS = /* @__PURE__ */ new Set([
|
|
1563
|
-
"any",
|
|
1564
|
-
"all",
|
|
1565
|
-
"sequential"
|
|
1566
|
-
]);
|
|
1567
|
-
/** The keys a 0.16 membership literal may carry. */
|
|
1568
|
-
const MEMBERSHIP_KEYS = /* @__PURE__ */ new Set([
|
|
1569
|
-
"tenant",
|
|
1570
|
-
"team",
|
|
1571
|
-
"roles",
|
|
1572
|
-
"eligible",
|
|
1573
|
-
"via",
|
|
1574
|
-
"expiresAt",
|
|
1575
|
-
"grantedBy",
|
|
1576
|
-
"reason",
|
|
1577
|
-
"member",
|
|
1578
|
-
"managedBy",
|
|
1579
|
-
"entitlements",
|
|
1580
|
-
"keep",
|
|
1581
|
-
"x"
|
|
1582
|
-
]);
|
|
1583
|
-
function keyed(object) {
|
|
1584
|
-
const out = [];
|
|
1585
|
-
for (const property of object.properties) {
|
|
1586
|
-
if (property.type !== "Property" || property.computed) continue;
|
|
1587
|
-
const { key } = property;
|
|
1588
|
-
if (key.type === "Identifier") out.push({
|
|
1589
|
-
key: key.name,
|
|
1590
|
-
property
|
|
1591
|
-
});
|
|
1592
|
-
else if (key.type === "Literal" && typeof key.value === "string") out.push({
|
|
1593
|
-
key: key.value,
|
|
1594
|
-
property
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
return out;
|
|
1598
|
-
}
|
|
1599
|
-
function stringLiteral(property) {
|
|
1600
|
-
const { value } = property;
|
|
1601
|
-
return value.type === "Literal" && typeof value.value === "string" ? value.value : void 0;
|
|
1602
|
-
}
|
|
1603
|
-
function langOf(file) {
|
|
1604
|
-
if (file.endsWith(".tsx")) return "tsx";
|
|
1605
|
-
if (file.endsWith(".jsx")) return "jsx";
|
|
1606
|
-
return /\.[cm]?ts$/u.test(file) ? "ts" : "js";
|
|
1607
|
-
}
|
|
1608
|
-
/**
|
|
1609
|
-
* The span of `property` with the comma after it, or the comma before it when
|
|
1610
|
-
* it is the last property, so removing the span leaves the object well formed.
|
|
1611
|
-
*/
|
|
1612
|
-
function withComma(source, property) {
|
|
1613
|
-
const after = /^\s*,\s*/u.exec(source.slice(property.end));
|
|
1614
|
-
if (after !== null) return {
|
|
1615
|
-
start: property.start,
|
|
1616
|
-
end: property.end + after[0].length
|
|
1617
|
-
};
|
|
1618
|
-
const before = /,\s*$/u.exec(source.slice(0, property.start));
|
|
1619
|
-
return {
|
|
1620
|
-
start: property.start - (before?.[0].length ?? 0),
|
|
1621
|
-
end: property.end
|
|
1622
|
-
};
|
|
1623
|
-
}
|
|
1624
|
-
/**
|
|
1625
|
-
* 0.17's object-literal rewrites:
|
|
1626
|
-
*
|
|
1627
|
-
* - A membership `{ tenant, team?, roles }` becomes `{ scope, id, within? }`
|
|
1628
|
-
* under the `tenant` and `team` scope aliases. Only an object whose keys are
|
|
1629
|
-
* all membership fields counts, so credentials, events and principals that
|
|
1630
|
-
* carry `tenant` and `roles` stay as they are.
|
|
1631
|
-
* - An approval option's `mode: 'any' | 'all' | 'sequential'` becomes `combine`,
|
|
1632
|
-
* `distinct: false` becomes `mode: 'confirm'`, and `distinct: true` (the
|
|
1633
|
-
* default) goes.
|
|
1634
|
-
*
|
|
1635
|
-
* A `distinct` that is not a literal and every `ApprovalMode` type reference
|
|
1636
|
-
* are follow-ups.
|
|
1637
|
-
*/
|
|
1638
|
-
function rewriteLiterals017(file, source) {
|
|
1639
|
-
let parsed;
|
|
1640
|
-
try {
|
|
1641
|
-
parsed = parseSync(file, source, {
|
|
1642
|
-
lang: langOf(file),
|
|
1643
|
-
sourceType: "module"
|
|
1644
|
-
});
|
|
1645
|
-
} catch (error) {
|
|
1646
|
-
if (error instanceof CliError) throw error;
|
|
1647
|
-
return {
|
|
1648
|
-
source,
|
|
1649
|
-
changes: [],
|
|
1650
|
-
followUps: []
|
|
1651
|
-
};
|
|
1652
|
-
}
|
|
1653
|
-
if (parsed.errors.length > 0) return {
|
|
1654
|
-
source,
|
|
1655
|
-
changes: [],
|
|
1656
|
-
followUps: []
|
|
1657
|
-
};
|
|
1658
|
-
const lineAt = lineIndex(source);
|
|
1659
|
-
const edits = [];
|
|
1660
|
-
const changes = [];
|
|
1661
|
-
const followUps = [];
|
|
1662
|
-
const text = (node) => source.slice(node.start, node.end);
|
|
1663
|
-
const change = (at, from, to) => {
|
|
1664
|
-
changes.push({
|
|
1665
|
-
...position(lineAt, at),
|
|
1666
|
-
from,
|
|
1667
|
-
to
|
|
1668
|
-
});
|
|
1669
|
-
};
|
|
1670
|
-
const membership = (node, props) => {
|
|
1671
|
-
const keys = new Set(props.map((item) => item.key));
|
|
1672
|
-
if (props.length !== node.properties.length || !keys.has("roles") || !keys.has("tenant") && !keys.has("team") || [...keys].some((key) => !MEMBERSHIP_KEYS.has(key))) return;
|
|
1673
|
-
const tenant = props.find((item) => item.key === "tenant")?.property;
|
|
1674
|
-
const team = props.find((item) => item.key === "team")?.property;
|
|
1675
|
-
if ([tenant, team].some((item) => item?.value.type === "ObjectExpression" || item?.value.type === "ArrayExpression")) return;
|
|
1676
|
-
if (team === void 0 && tenant !== void 0) {
|
|
1677
|
-
const to = `scope: "tenant", id: ${text(tenant.value)}`;
|
|
1678
|
-
edits.push({
|
|
1679
|
-
start: tenant.start,
|
|
1680
|
-
end: tenant.end,
|
|
1681
|
-
text: to
|
|
1682
|
-
});
|
|
1683
|
-
change(tenant.start, text(tenant), to);
|
|
1684
|
-
return;
|
|
1685
|
-
}
|
|
1686
|
-
if (team !== void 0) {
|
|
1687
|
-
const to = `scope: "team", id: ${text(team.value)}`;
|
|
1688
|
-
edits.push({
|
|
1689
|
-
start: team.start,
|
|
1690
|
-
end: team.end,
|
|
1691
|
-
text: to
|
|
1692
|
-
});
|
|
1693
|
-
change(team.start, text(team), to);
|
|
1694
|
-
}
|
|
1695
|
-
if (tenant !== void 0) {
|
|
1696
|
-
const value = text(tenant.value);
|
|
1697
|
-
const to = `within: { ${value === "tenant" ? value : `tenant: ${value}`} }`;
|
|
1698
|
-
edits.push({
|
|
1699
|
-
start: tenant.start,
|
|
1700
|
-
end: tenant.end,
|
|
1701
|
-
text: to
|
|
1702
|
-
});
|
|
1703
|
-
change(tenant.start, text(tenant), to);
|
|
1704
|
-
}
|
|
1705
|
-
};
|
|
1706
|
-
const approval = (props) => {
|
|
1707
|
-
const keys = new Set(props.map((item) => item.key));
|
|
1708
|
-
if (!keys.has("by") && !keys.has("stages")) return;
|
|
1709
|
-
const mode = props.find((item) => item.key === "mode")?.property;
|
|
1710
|
-
const value = mode === void 0 ? void 0 : stringLiteral(mode);
|
|
1711
|
-
if (mode !== void 0 && value !== void 0 && COMBINATORS.has(value)) {
|
|
1712
|
-
edits.push({
|
|
1713
|
-
start: mode.key.start,
|
|
1714
|
-
end: mode.key.end,
|
|
1715
|
-
text: "combine"
|
|
1716
|
-
});
|
|
1717
|
-
change(mode.start, text(mode), `combine: ${text(mode.value)}`);
|
|
1718
|
-
}
|
|
1719
|
-
const distinct = props.find((item) => item.key === "distinct")?.property;
|
|
1720
|
-
if (distinct === void 0) return;
|
|
1721
|
-
const literal = distinct.value;
|
|
1722
|
-
if (literal.type === "Literal" && literal.value === false) {
|
|
1723
|
-
edits.push({
|
|
1724
|
-
start: distinct.start,
|
|
1725
|
-
end: distinct.end,
|
|
1726
|
-
text: "mode: \"confirm\""
|
|
1727
|
-
});
|
|
1728
|
-
change(distinct.start, text(distinct), "mode: \"confirm\"");
|
|
1729
|
-
} else if (literal.type === "Literal" && literal.value === true) {
|
|
1730
|
-
edits.push({
|
|
1731
|
-
...withComma(source, distinct),
|
|
1732
|
-
text: ""
|
|
1733
|
-
});
|
|
1734
|
-
change(distinct.start, text(distinct), "(removed: authorize is the default)");
|
|
1735
|
-
} else followUps.push({
|
|
1736
|
-
...position(lineAt, distinct.start),
|
|
1737
|
-
name: "distinct",
|
|
1738
|
-
message: "distinct is gone since 0.17.0: `mode: \"confirm\"` where it was false; drop it where it was true"
|
|
1739
|
-
});
|
|
1740
|
-
};
|
|
1741
|
-
createVisitor({
|
|
1742
|
-
ObjectExpression(node) {
|
|
1743
|
-
const props = keyed(node);
|
|
1744
|
-
membership(node, props);
|
|
1745
|
-
approval(props);
|
|
1746
|
-
},
|
|
1747
|
-
TSTypeReference(node) {
|
|
1748
|
-
if (node.typeName.type === "Identifier" && node.typeName.name === "ApprovalMode") followUps.push({
|
|
1749
|
-
...position(lineAt, node.start),
|
|
1750
|
-
name: "ApprovalMode",
|
|
1751
|
-
message: "ApprovalMode is `'confirm' | 'authorize'` since 0.17.0; the stage combinator type is ApprovalCombine"
|
|
1752
|
-
});
|
|
1753
|
-
}
|
|
1754
|
-
}).visit(parsed.program);
|
|
1755
|
-
return {
|
|
1756
|
-
source: applyEdits(source, edits),
|
|
1757
|
-
changes,
|
|
1758
|
-
followUps
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
//#endregion
|
|
1762
|
-
//#region src/cli/codemod/context.ts
|
|
1763
|
-
/** One version's rename map: what the codemod rewrites and what it only reports. */
|
|
1764
|
-
const SCRIPT_BLOCK = /<script\b([^>]*)>([\s\S]*?)<\/script>/gu;
|
|
1765
|
-
function isPermDockSpecifier(value) {
|
|
1766
|
-
return typeof value === "string" && (value === "permdock" || value.startsWith("permdock/"));
|
|
1767
|
-
}
|
|
1768
|
-
function declaredBetween(ctx, name, ancestors) {
|
|
1769
|
-
return ancestors.some((scope) => scope !== ctx.program && bindingsCached(scope, ctx.scopes)?.has(name) === true);
|
|
1770
|
-
}
|
|
1771
|
-
function isModuleBinding(ctx, name, ancestors) {
|
|
1772
|
-
return ctx.moduleNames.has(name) && !declaredBetween(ctx, name, ancestors);
|
|
1773
|
-
}
|
|
1774
|
-
function edit(ctx, node, text, from, to) {
|
|
1775
|
-
if (ctx.edits.some((item) => item.start === node.start && item.end === node.end)) return;
|
|
1776
|
-
ctx.edits.push({
|
|
1777
|
-
start: node.start,
|
|
1778
|
-
end: node.end,
|
|
1779
|
-
text
|
|
1780
|
-
});
|
|
1781
|
-
ctx.changes.push({
|
|
1782
|
-
at: node.start,
|
|
1783
|
-
from,
|
|
1784
|
-
to
|
|
1785
|
-
});
|
|
1786
|
-
}
|
|
1787
|
-
function replace(ctx, node, text, from) {
|
|
1788
|
-
edit(ctx, node, text, from, beforeFirst(text, " as "));
|
|
1789
|
-
}
|
|
1790
|
-
function renameOf(set, name, entry) {
|
|
1791
|
-
return set.renames.find((row) => row.from === name && row.kind !== "option" && row.kind !== "method" && row.entries.includes(entry));
|
|
1792
|
-
}
|
|
1793
|
-
function listOf(items) {
|
|
1794
|
-
return new Intl.ListFormat("en-GB", { type: "disjunction" }).format(items);
|
|
1795
|
-
}
|
|
1796
|
-
/**
|
|
1797
|
-
* The import a call's callee is bound to: a named import, or a member of a
|
|
1798
|
-
* namespace import.
|
|
1799
|
-
*/
|
|
1800
|
-
function importedCallee(ctx, callee, ancestors) {
|
|
1801
|
-
if (callee?.type === "Identifier") {
|
|
1802
|
-
const name = callee.name ?? "";
|
|
1803
|
-
return isModuleBinding(ctx, name, ancestors) ? ctx.bindings.get(name) : void 0;
|
|
1804
|
-
}
|
|
1805
|
-
const object = callee?.type === "MemberExpression" && callee.computed !== true ? callee.object : void 0;
|
|
1806
|
-
const namespace = object?.type === "Identifier" && isModuleBinding(ctx, object.name ?? "", ancestors) ? ctx.namespaces.get(object.name ?? "") : void 0;
|
|
1807
|
-
const imported = callee?.property?.name;
|
|
1808
|
-
return namespace === void 0 || imported === void 0 ? void 0 : {
|
|
1809
|
-
entry: namespace,
|
|
1810
|
-
imported
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
function renameKey(ctx, property, from, to) {
|
|
1814
|
-
const key = property.key;
|
|
1815
|
-
if (property.type !== "Property" || key === void 0 || property.computed === true) return;
|
|
1816
|
-
ctx.handledKeys.add(key);
|
|
1817
|
-
if (property.shorthand === true) edit(ctx, {
|
|
1818
|
-
...property,
|
|
1819
|
-
end: property.start
|
|
1820
|
-
}, `${to}: `, from, to);
|
|
1821
|
-
else replace(ctx, key, key.type === "Literal" ? JSON.stringify(to) : to, from);
|
|
1822
|
-
}
|
|
1823
|
-
function renameKeys(ctx, object, from, to) {
|
|
1824
|
-
for (const property of nodes(object.properties)) if (nameOf(property.key) === from) renameKey(ctx, property, from, to);
|
|
1825
|
-
}
|
|
1826
|
-
function boundImport(ctx, node, ancestors) {
|
|
1827
|
-
const name = node?.name;
|
|
1828
|
-
return (node?.type === "Identifier" || node?.type === "JSXIdentifier") && name !== void 0 && isModuleBinding(ctx, name, ancestors) ? ctx.bindings.get(name) : void 0;
|
|
1829
|
-
}
|
|
1830
|
-
//#endregion
|
|
1831
|
-
//#region src/cli/codemod/imports.ts
|
|
1832
|
-
function removableBindings(ctx) {
|
|
1833
|
-
const out = /* @__PURE__ */ new Set();
|
|
1834
|
-
if (ctx.keepLocals) return out;
|
|
1835
|
-
for (const local of ctx.bindings.keys()) {
|
|
1836
|
-
const references = ctx.references.filter((item) => item.node.name === local);
|
|
1837
|
-
if (references.length > 0 && references.every((item) => ctx.consumed.has(item.node.start))) out.add(local);
|
|
1838
|
-
}
|
|
1839
|
-
return out;
|
|
1840
|
-
}
|
|
1841
|
-
function importedLocal(ctx, name, entry, ancestors) {
|
|
1842
|
-
for (const [local, binding] of ctx.bindings) if (binding.entry === entry && binding.imported === name && !typeOnly(binding) && !declaredBetween(ctx, local, ancestors)) return local;
|
|
1843
|
-
if (ctx.moduleNames.has(name) || declaredBetween(ctx, name, ancestors)) return;
|
|
1844
|
-
const names = ctx.additions.get(entry) ?? /* @__PURE__ */ new Set();
|
|
1845
|
-
names.add(name);
|
|
1846
|
-
ctx.additions.set(entry, names);
|
|
1847
|
-
return name;
|
|
1848
|
-
}
|
|
1849
|
-
function typeOnly(binding) {
|
|
1850
|
-
return Reflect.get(binding.declaration, "importKind") === "type" || Reflect.get(binding.spec, "importKind") === "type";
|
|
1851
|
-
}
|
|
1852
|
-
function finishImports(ctx, removed) {
|
|
1853
|
-
const gone = /* @__PURE__ */ new Set();
|
|
1854
|
-
for (const local of removed) {
|
|
1855
|
-
const spec = ctx.bindings.get(local)?.spec;
|
|
1856
|
-
if (spec !== void 0) gone.add(spec);
|
|
1857
|
-
}
|
|
1858
|
-
const pending = new Map(ctx.additions);
|
|
1859
|
-
for (const declaration of nodes(ctx.program.body)) {
|
|
1860
|
-
const all = nodes(declaration.specifiers);
|
|
1861
|
-
if (declaration.type !== "ImportDeclaration" || !all.some((spec) => gone.has(spec))) continue;
|
|
1862
|
-
if (all.some((spec) => spec.type !== "ImportSpecifier")) {
|
|
1863
|
-
for (const spec of all) gone.delete(spec);
|
|
1864
|
-
continue;
|
|
1865
|
-
}
|
|
1866
|
-
if (all.some((spec) => !gone.has(spec))) {
|
|
1867
|
-
removeSpecifiers(ctx, all, gone);
|
|
1868
|
-
continue;
|
|
1869
|
-
}
|
|
1870
|
-
const entry = String(declaration.source?.value);
|
|
1871
|
-
const names = Reflect.get(declaration, "importKind") === "type" ? void 0 : pending.get(entry);
|
|
1872
|
-
if (names === void 0) ctx.edits.push({
|
|
1873
|
-
start: declaration.start,
|
|
1874
|
-
end: lineEnd(ctx.code, declaration.end),
|
|
1875
|
-
text: ""
|
|
1876
|
-
});
|
|
1877
|
-
else {
|
|
1878
|
-
pending.delete(entry);
|
|
1879
|
-
ctx.edits.push({
|
|
1880
|
-
start: declaration.start,
|
|
1881
|
-
end: declaration.end,
|
|
1882
|
-
text: importText(ctx, entry, names)
|
|
1883
|
-
});
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
for (const [entry, names] of pending) addImport(ctx, entry, names, gone);
|
|
1887
|
-
}
|
|
1888
|
-
function lineEnd(code, end) {
|
|
1889
|
-
return code[end] === "\n" ? end + 1 : end;
|
|
1890
|
-
}
|
|
1891
|
-
function importText(ctx, entry, names) {
|
|
1892
|
-
const source = nodes(ctx.program.body).map((statement) => statement.source).find((node) => isPermDockSpecifier(node?.value));
|
|
1893
|
-
const mark = ctx.code[source?.start ?? -1] ?? "\"";
|
|
1894
|
-
return `import { ${[...names].join(", ")} } from ${mark}${entry}${mark};`;
|
|
1895
|
-
}
|
|
1896
|
-
function removeSpecifiers(ctx, all, gone) {
|
|
1897
|
-
const last = all.findLastIndex((spec) => !gone.has(spec));
|
|
1898
|
-
for (const [index, spec] of all.entries()) {
|
|
1899
|
-
const next = all[index + 1];
|
|
1900
|
-
if (gone.has(spec) && index < last && next !== void 0) ctx.edits.push({
|
|
1901
|
-
start: spec.start,
|
|
1902
|
-
end: next.start,
|
|
1903
|
-
text: ""
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
const survivor = all[last];
|
|
1907
|
-
const tail = all.at(-1);
|
|
1908
|
-
if (survivor !== void 0 && tail !== void 0 && tail !== survivor) ctx.edits.push({
|
|
1909
|
-
start: survivor.end,
|
|
1910
|
-
end: tail.end,
|
|
1911
|
-
text: ""
|
|
1912
|
-
});
|
|
1913
|
-
}
|
|
1914
|
-
function addImport(ctx, entry, names, gone) {
|
|
1915
|
-
const statements = nodes(ctx.program.body);
|
|
1916
|
-
const anchor = statements.filter((statement) => statement.type === "ImportDeclaration" && statement.source?.value === entry && Reflect.get(statement, "importKind") !== "type").flatMap((statement) => nodes(statement.specifiers)).findLast((spec) => spec.type === "ImportSpecifier" && !gone.has(spec));
|
|
1917
|
-
if (anchor !== void 0) {
|
|
1918
|
-
ctx.edits.push({
|
|
1919
|
-
start: anchor.end,
|
|
1920
|
-
end: anchor.end,
|
|
1921
|
-
text: `, ${[...names].join(", ")}`
|
|
1922
|
-
});
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
const lastImport = statements.findLast((statement) => statement.type === "ImportDeclaration");
|
|
1926
|
-
const at = lastImport?.end ?? 0;
|
|
1927
|
-
const text = importText(ctx, entry, names);
|
|
1928
|
-
ctx.edits.push({
|
|
1929
|
-
start: at,
|
|
1930
|
-
end: at,
|
|
1931
|
-
text: lastImport === void 0 ? `${text}\n` : `\n${text}`
|
|
1932
|
-
});
|
|
1933
|
-
}
|
|
1934
|
-
//#endregion
|
|
1935
|
-
//#region src/cli/codemod/shapes.ts
|
|
1936
|
-
function templateHints(file, source, set, components, lineAt) {
|
|
1937
|
-
const hints = (set.templates ?? []).filter((hint) => hint.entries.some((entry) => components.has(`${entry} ${hint.component}`)));
|
|
1938
|
-
if (hints.length === 0 || !/\.(?:vue|svelte)$/iu.test(file)) return [];
|
|
1939
|
-
const markup = source.replaceAll(SCRIPT_BLOCK, (block) => " ".repeat(block.length));
|
|
1940
|
-
return hints.flatMap((hint) => [...markup.matchAll(hint.pattern)].map((match) => {
|
|
1941
|
-
const { line, column } = position(lineAt, match.index);
|
|
1942
|
-
return {
|
|
1943
|
-
line,
|
|
1944
|
-
column,
|
|
1945
|
-
name: hint.name,
|
|
1946
|
-
message: hint.message
|
|
1947
|
-
};
|
|
1948
|
-
}));
|
|
1949
|
-
}
|
|
1950
|
-
function awaitRow(ctx, callee) {
|
|
1951
|
-
return (ctx.set.awaits ?? []).find((row) => callee !== void 0 && row.name === callee.imported && row.entries.includes(callee.entry));
|
|
1952
|
-
}
|
|
1953
|
-
function visitAwait(ctx, node, ancestors) {
|
|
1954
|
-
const call = node.argument;
|
|
1955
|
-
if (call?.type !== "CallExpression" || call.callee === void 0) return;
|
|
1956
|
-
const callee = importedCallee(ctx, call.callee, ancestors);
|
|
1957
|
-
const row = awaitRow(ctx, callee);
|
|
1958
|
-
if (row === void 0 || callee === void 0) return;
|
|
1959
|
-
swapCallee(ctx, call.callee, row.name, row.to, callee.entry, ancestors);
|
|
1960
|
-
}
|
|
1961
|
-
function swapCallee(ctx, callee, from, to, entry, ancestors) {
|
|
1962
|
-
if (callee.type === "MemberExpression" && callee.property !== void 0) {
|
|
1963
|
-
replace(ctx, callee.property, to, from);
|
|
1964
|
-
return true;
|
|
1965
|
-
}
|
|
1966
|
-
const local = importedLocal(ctx, to, entry, ancestors);
|
|
1967
|
-
if (local === void 0) {
|
|
1968
|
-
ctx.followUps.push({
|
|
1969
|
-
at: callee.start,
|
|
1970
|
-
name: from,
|
|
1971
|
-
message: `\`${from}\` is \`${to}\` from \`${entry}\` here; \`${to}\` is already bound in this scope`
|
|
1972
|
-
});
|
|
1973
|
-
return false;
|
|
1974
|
-
}
|
|
1975
|
-
ctx.consumed.add(callee.start);
|
|
1976
|
-
edit(ctx, callee, local, from, to);
|
|
1977
|
-
return true;
|
|
1978
|
-
}
|
|
1979
|
-
function reportUnawaited(ctx, node, ancestors, row) {
|
|
1980
|
-
const parent = ancestors.at(-1);
|
|
1981
|
-
if (parent?.type === "ReturnStatement" || parent?.type === "ArrowFunctionExpression" && parent.body === node || parent?.type === "MemberExpression" && parent.object === node && parent.property?.name === "then") ctx.followUps.push({
|
|
1982
|
-
at: node.start,
|
|
1983
|
-
name: row.name,
|
|
1984
|
-
message: `\`${row.name}\` without \`await\` is \`${row.sync}\`, which returns the instance, never a Promise; call \`${row.to}\` when a source answers asynchronously`
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
function propRows(ctx, binding) {
|
|
1988
|
-
return binding === void 0 ? [] : (ctx.set.props ?? []).filter((row) => row.component === binding.imported && row.entries.includes(binding.entry));
|
|
1989
|
-
}
|
|
1990
|
-
function visitElement(ctx, node, ancestors) {
|
|
1991
|
-
const tag = child(node, "name");
|
|
1992
|
-
const binding = boundImport(ctx, tag, ancestors);
|
|
1993
|
-
const rows = propRows(ctx, binding);
|
|
1994
|
-
const named = tag?.type === "JSXMemberExpression" ? child(tag, "property") : tag;
|
|
1995
|
-
const unbound = (ctx.set.props ?? []).filter((row) => binding === void 0 && row.within !== void 0 && named?.type === "JSXIdentifier" && named.name === row.component);
|
|
1996
|
-
for (const attribute of nodes(Reflect.get(node, "attributes"))) {
|
|
1997
|
-
const name = child(attribute, "name");
|
|
1998
|
-
if (attribute.type !== "JSXAttribute" || name?.type !== "JSXIdentifier") continue;
|
|
1999
|
-
for (const row of rows) if (row.within === void 0 && name.name === row.from) replace(ctx, name, row.to, row.from);
|
|
2000
|
-
else if (row.within !== void 0 && name.name === row.within) renameWithin(ctx, attribute, row);
|
|
2001
|
-
for (const row of unbound) if (name.name === row.within && holdsKey(attribute, row.from)) ctx.followUps.push({
|
|
2002
|
-
at: attribute.start,
|
|
2003
|
-
name: row.from,
|
|
2004
|
-
message: `\`${row.within}.${row.from}\` of \`<${row.component}>\` is \`${row.within}.${row.to}\``
|
|
2005
|
-
});
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
function attributeObject(attribute) {
|
|
2009
|
-
const value = child(attribute, "value");
|
|
2010
|
-
const expression = value?.type === "JSXExpressionContainer" ? child(value, "expression") : void 0;
|
|
2011
|
-
return expression?.type === "ObjectExpression" ? expression : void 0;
|
|
2012
|
-
}
|
|
2013
|
-
function holdsKey(attribute, key) {
|
|
2014
|
-
const object = attributeObject(attribute);
|
|
2015
|
-
return object === void 0 || nodes(object.properties).some((property) => nameOf(property.key) === key);
|
|
2016
|
-
}
|
|
2017
|
-
function renameWithin(ctx, attribute, row) {
|
|
2018
|
-
const object = attributeObject(attribute);
|
|
2019
|
-
if (object === void 0) {
|
|
2020
|
-
ctx.followUps.push({
|
|
2021
|
-
at: attribute.start,
|
|
2022
|
-
name: row.from,
|
|
2023
|
-
message: `\`${row.within}.${row.from}\` of \`<${row.component}>\` is \`${row.within}.${row.to}\``
|
|
2024
|
-
});
|
|
2025
|
-
return;
|
|
2026
|
-
}
|
|
2027
|
-
renameKeys(ctx, object, row.from, row.to);
|
|
2028
|
-
}
|
|
2029
|
-
function visitComponentArguments(ctx, node, ancestors) {
|
|
2030
|
-
const args = nodes(node.arguments);
|
|
2031
|
-
for (const [index, argument] of args.entries()) {
|
|
2032
|
-
const rows = propRows(ctx, boundImport(ctx, argument, ancestors)).filter((row) => row.within === void 0);
|
|
2033
|
-
for (const row of rows) for (const later of args.slice(index + 1)) if (later.type === "ObjectExpression") renameKeys(ctx, later, row.from, row.to);
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
function methodRow(ctx, node, ancestors) {
|
|
2037
|
-
const callee = node.callee;
|
|
2038
|
-
const receiver = callee?.object;
|
|
2039
|
-
const method = callee?.property?.name;
|
|
2040
|
-
const first = nodes(node.arguments)[0];
|
|
2041
|
-
return (ctx.set.methodFunctions ?? []).find((row) => callee?.type === "MemberExpression" && callee.computed !== true && row.method === method && (row.argument === void 0 || first?.type === "ObjectExpression" && nodes(first.properties).some((property) => nameOf(property.key) === row.argument)) && (row.anyReceiver || holdsInstance(ctx, receiver, ancestors)));
|
|
2042
|
-
}
|
|
2043
|
-
function holdsInstance(ctx, receiver, ancestors) {
|
|
2044
|
-
const name = receiver?.type === "Identifier" ? receiver.name : void 0;
|
|
2045
|
-
if (name === void 0) return false;
|
|
2046
|
-
return /permdock/iu.test(name) || isModuleBinding(ctx, name, ancestors) && ctx.factories.has(name);
|
|
2047
|
-
}
|
|
2048
|
-
function visitMethodCall(ctx, node, ancestors) {
|
|
2049
|
-
const row = node.type === "CallExpression" ? methodRow(ctx, node, ancestors) : void 0;
|
|
2050
|
-
const receiver = node.callee?.object;
|
|
2051
|
-
if (row === void 0 || receiver === void 0) return;
|
|
2052
|
-
const name = receiver.type === "Identifier" ? receiver.name : void 0;
|
|
2053
|
-
if (name !== void 0 && ctx.namespaces.has(name)) return;
|
|
2054
|
-
const open = ctx.code.indexOf("(", receiver.end);
|
|
2055
|
-
const between = ctx.code.slice(receiver.end, open);
|
|
2056
|
-
if (Reflect.get(node, "optional") === true || Reflect.get(node.callee ?? node, "optional") === true || receiver.type === "SequenceExpression" || !/^\s*\.\s*\w+\s*$/u.test(between)) {
|
|
2057
|
-
ctx.followUps.push({
|
|
2058
|
-
at: node.start,
|
|
2059
|
-
name: row.method,
|
|
2060
|
-
message: `\`permdock.${row.method}(…)\` is \`${row.to}(permdock, …)\` from \`${row.entry}\``
|
|
2061
|
-
});
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
2064
|
-
const local = importedLocal(ctx, row.to, row.entry, ancestors);
|
|
2065
|
-
if (local === void 0) {
|
|
2066
|
-
ctx.followUps.push({
|
|
2067
|
-
at: node.start,
|
|
2068
|
-
name: row.method,
|
|
2069
|
-
message: `\`permdock.${row.method}(…)\` is \`${row.to}(permdock, …)\` from \`${row.entry}\`; \`${row.to}\` is already bound in this scope`
|
|
2070
|
-
});
|
|
2071
|
-
return;
|
|
2072
|
-
}
|
|
2073
|
-
const separator = nodes(node.arguments).length === 0 ? "" : ",";
|
|
2074
|
-
const space = /\s/u.test(ctx.code[open + 1] ?? "") ? "" : " ";
|
|
2075
|
-
ctx.edits.push({
|
|
2076
|
-
start: receiver.start,
|
|
2077
|
-
end: receiver.start,
|
|
2078
|
-
text: `${local}(`
|
|
2079
|
-
}, {
|
|
2080
|
-
start: receiver.end,
|
|
2081
|
-
end: open + 1,
|
|
2082
|
-
text: separator === "" ? "" : `${separator}${space}`
|
|
2083
|
-
});
|
|
2084
|
-
ctx.changes.push({
|
|
2085
|
-
at: node.start,
|
|
2086
|
-
from: row.method,
|
|
2087
|
-
to: row.to
|
|
2088
|
-
});
|
|
2089
|
-
}
|
|
2090
|
-
const PLAIN_RECEIVERS = /* @__PURE__ */ new Set([
|
|
2091
|
-
"Identifier",
|
|
2092
|
-
"MemberExpression",
|
|
2093
|
-
"CallExpression",
|
|
2094
|
-
"ThisExpression"
|
|
2095
|
-
]);
|
|
2096
|
-
function visitFunctionCall(ctx, node, callee) {
|
|
2097
|
-
const row = (ctx.set.functionMethods ?? []).find((item) => item.name === callee.imported && item.entry === callee.entry);
|
|
2098
|
-
const [receiver, next] = nodes(node.arguments);
|
|
2099
|
-
if (row === void 0 || node.type !== "CallExpression" || node.callee === void 0 || receiver === void 0 || receiver.type === "SpreadElement" || Reflect.get(node, "optional") === true) return false;
|
|
2100
|
-
const plain = PLAIN_RECEIVERS.has(receiver.type);
|
|
2101
|
-
ctx.edits.push({
|
|
2102
|
-
start: node.callee.start,
|
|
2103
|
-
end: receiver.start,
|
|
2104
|
-
text: plain ? "" : "("
|
|
2105
|
-
}, {
|
|
2106
|
-
start: receiver.end,
|
|
2107
|
-
end: next?.start ?? node.end - 1,
|
|
2108
|
-
text: `${plain ? "" : ")"}.${row.method}(`
|
|
2109
|
-
});
|
|
2110
|
-
if (node.callee.type === "Identifier") ctx.consumed.add(node.callee.start);
|
|
2111
|
-
ctx.changes.push({
|
|
2112
|
-
at: node.start,
|
|
2113
|
-
from: row.name,
|
|
2114
|
-
to: row.method
|
|
2115
|
-
});
|
|
2116
|
-
return true;
|
|
2117
|
-
}
|
|
2118
|
-
function isWrapped(ctx, row, value, ancestors) {
|
|
2119
|
-
const callee = value?.type === "CallExpression" ? importedCallee(ctx, value.callee, ancestors) : void 0;
|
|
2120
|
-
return callee !== void 0 && callee.entry === row.entry && row.already.includes(callee.imported);
|
|
2121
|
-
}
|
|
2122
|
-
function visitWraps(ctx, node, callee, ancestors) {
|
|
2123
|
-
const rows = (ctx.set.wraps ?? []).filter((row) => row.entries.includes(callee.entry) && row.calls.includes(callee.imported));
|
|
2124
|
-
for (const argument of nodes(node.arguments)) for (const property of argument.type === "ObjectExpression" ? nodes(argument.properties) : []) {
|
|
2125
|
-
const row = rows.find((item) => item.key === nameOf(property.key));
|
|
2126
|
-
if (row !== void 0 && property.computed !== true) wrapOption(ctx, row, property, ancestors);
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
function wrapOption(ctx, row, property, ancestors) {
|
|
2130
|
-
const value = child(property, "value");
|
|
2131
|
-
if (property.key !== void 0) ctx.handledKeys.add(property.key);
|
|
2132
|
-
if (value === void 0 || isWrapped(ctx, row, value, ancestors)) return;
|
|
2133
|
-
const local = importedLocal(ctx, row.wrapper, row.entry, ancestors);
|
|
2134
|
-
if (local === void 0 || property.type !== "Property") {
|
|
2135
|
-
ctx.followUps.push({
|
|
2136
|
-
at: property.start,
|
|
2137
|
-
name: row.key,
|
|
2138
|
-
message: `option \`${row.key}\` takes \`${row.wrapper}(source)\` from \`${row.entry}\`; \`${row.wrapper}\` is already bound in this scope`
|
|
2139
|
-
});
|
|
2140
|
-
return;
|
|
2141
|
-
}
|
|
2142
|
-
ctx.edits.push(property.shorthand === true ? {
|
|
2143
|
-
start: property.start,
|
|
2144
|
-
end: property.start,
|
|
2145
|
-
text: `${row.key}: ${local}(`
|
|
2146
|
-
} : {
|
|
2147
|
-
start: value.start,
|
|
2148
|
-
end: value.start,
|
|
2149
|
-
text: `${local}(`
|
|
2150
|
-
}, {
|
|
2151
|
-
start: value.end,
|
|
2152
|
-
end: value.end,
|
|
2153
|
-
text: ")"
|
|
2154
|
-
});
|
|
2155
|
-
ctx.changes.push({
|
|
2156
|
-
at: value.start,
|
|
2157
|
-
from: row.key,
|
|
2158
|
-
to: row.wrapper
|
|
2159
|
-
});
|
|
2160
|
-
}
|
|
2161
|
-
function reportWraps(ctx, node, ancestors) {
|
|
2162
|
-
for (const property of nodes(node.properties)) {
|
|
2163
|
-
const row = (ctx.set.wraps ?? []).find((item) => item.reportElsewhere && item.key === nameOf(property.key));
|
|
2164
|
-
if (row !== void 0 && property.key !== void 0 && property.computed !== true && !ctx.handledKeys.has(property.key) && !isWrapped(ctx, row, child(property, "value"), ancestors)) ctx.followUps.push({
|
|
2165
|
-
at: property.start,
|
|
2166
|
-
name: row.key,
|
|
2167
|
-
message: `option \`${row.key}\` takes \`${row.wrapper}(source)\` from \`${row.entry}\` when this object reaches \`getPermDock\` or \`getPermDockSync\``
|
|
2168
|
-
});
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
const UNIT_SECONDS = Object.freeze({
|
|
2172
|
-
s: 1,
|
|
2173
|
-
m: 60,
|
|
2174
|
-
h: 3600,
|
|
2175
|
-
d: 86400,
|
|
2176
|
-
w: 604800
|
|
2177
|
-
});
|
|
2178
|
-
function seconds(value) {
|
|
2179
|
-
if (value?.type !== "Literal" || typeof value.value !== "string") return;
|
|
2180
|
-
const match = /^\s*(\d+)([smhdw])\s*$/u.exec(value.value);
|
|
2181
|
-
const amount = Number(match?.[1]);
|
|
2182
|
-
const unit = UNIT_SECONDS[match?.[2] ?? ""];
|
|
2183
|
-
return unit === void 0 || !(amount > 0) ? void 0 : amount * unit;
|
|
2184
|
-
}
|
|
2185
|
-
function insidePermDockCall(ctx, object, ancestors) {
|
|
2186
|
-
const chain = [...ancestors, object];
|
|
2187
|
-
return ancestors.some((node, index) => (node.type === "CallExpression" || node.type === "NewExpression") && nodes(node.arguments).includes(chain[index + 1] ?? node) && importedCallee(ctx, node.callee, ancestors.slice(0, index)) !== void 0);
|
|
2188
|
-
}
|
|
2189
|
-
function visitDurations(ctx, node, ancestors) {
|
|
2190
|
-
const keys = ctx.set.durations;
|
|
2191
|
-
if (keys === void 0) return;
|
|
2192
|
-
const rewrite = insidePermDockCall(ctx, node, ancestors);
|
|
2193
|
-
const parent = ancestors.at(-1);
|
|
2194
|
-
if (!rewrite && nodes(parent?.arguments).includes(node)) return;
|
|
2195
|
-
for (const property of nodes(node.properties)) {
|
|
2196
|
-
const key = nameOf(property.key);
|
|
2197
|
-
const value = child(property, "value");
|
|
2198
|
-
const literals = key !== void 0 && keys.keys.includes(key) ? [value] : key !== void 0 && keys.lists.includes(key) && value?.type === "ArrayExpression" ? nodes(value.elements) : [];
|
|
2199
|
-
for (const literal of literals) {
|
|
2200
|
-
const total = seconds(literal);
|
|
2201
|
-
if (literal === void 0 || total === void 0) continue;
|
|
2202
|
-
const text = String(literal.value);
|
|
2203
|
-
if (rewrite) {
|
|
2204
|
-
ctx.edits.push({
|
|
2205
|
-
start: literal.start,
|
|
2206
|
-
end: literal.end,
|
|
2207
|
-
text: String(total)
|
|
2208
|
-
});
|
|
2209
|
-
ctx.changes.push({
|
|
2210
|
-
at: literal.start,
|
|
2211
|
-
from: text,
|
|
2212
|
-
to: String(total)
|
|
2213
|
-
});
|
|
2214
|
-
} else ctx.followUps.push({
|
|
2215
|
-
at: literal.start,
|
|
2216
|
-
name: key ?? text,
|
|
2217
|
-
message: `duration \`"${text}"\` is \`${total}\` (seconds) when this object reaches PermDock`
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
//#endregion
|
|
2223
|
-
//#region src/cli/codemod/transform.ts
|
|
2224
|
-
/** Applies `set` to one file's source; `file` picks the parser by extension. */
|
|
2225
|
-
function transformSource(file, source, set) {
|
|
2226
|
-
const lineAt = lineIndex(source);
|
|
2227
|
-
const edits = [];
|
|
2228
|
-
const changes = [];
|
|
2229
|
-
const followUps = [];
|
|
2230
|
-
const components = /* @__PURE__ */ new Set();
|
|
2231
|
-
for (const segment of segmentsOf(file, source)) {
|
|
2232
|
-
const result = parseSync(`segment.${segment.lang}`, segment.code, {
|
|
2233
|
-
lang: segment.lang,
|
|
2234
|
-
sourceType: "module"
|
|
2235
|
-
});
|
|
2236
|
-
const error = result.errors.find((item) => {
|
|
2237
|
-
return item.severity === "Error";
|
|
2238
|
-
});
|
|
2239
|
-
if (error !== void 0) return {
|
|
2240
|
-
source,
|
|
2241
|
-
changes: [],
|
|
2242
|
-
followUps: [],
|
|
2243
|
-
error: error.message
|
|
2244
|
-
};
|
|
2245
|
-
const ctx = contextFor(result.program, set, segment);
|
|
2246
|
-
if (ctx === void 0) continue;
|
|
2247
|
-
transformProgram(ctx, segment);
|
|
2248
|
-
for (const binding of ctx.bindings.values()) components.add(`${binding.entry} ${binding.imported}`);
|
|
2249
|
-
const at = (index) => position(lineAt, index + segment.offset);
|
|
2250
|
-
for (const item of ctx.edits) edits.push({
|
|
2251
|
-
start: item.start + segment.offset,
|
|
2252
|
-
end: item.end + segment.offset,
|
|
2253
|
-
text: item.text
|
|
2254
|
-
});
|
|
2255
|
-
for (const change of ctx.changes) changes.push({
|
|
2256
|
-
...at(change.at),
|
|
2257
|
-
from: change.from,
|
|
2258
|
-
to: change.to
|
|
2259
|
-
});
|
|
2260
|
-
for (const note of ctx.followUps) followUps.push({
|
|
2261
|
-
...at(note.at),
|
|
2262
|
-
name: note.name,
|
|
2263
|
-
message: note.message
|
|
2264
|
-
});
|
|
2265
|
-
}
|
|
2266
|
-
followUps.push(...templateHints(file, source, set, components, lineAt));
|
|
2267
|
-
return {
|
|
2268
|
-
source: applyEdits(source, edits),
|
|
2269
|
-
changes: changes.toSorted(byPosition),
|
|
2270
|
-
followUps: followUps.toSorted(byPosition)
|
|
2271
|
-
};
|
|
2272
|
-
}
|
|
2273
|
-
function byPosition(a, b) {
|
|
2274
|
-
return a.line - b.line || a.column - b.column;
|
|
2275
|
-
}
|
|
2276
|
-
function segmentsOf(file, source) {
|
|
2277
|
-
const extension = file.slice(file.lastIndexOf(".") + 1).toLowerCase();
|
|
2278
|
-
if (extension === "vue" || extension === "svelte") return [...source.matchAll(SCRIPT_BLOCK)].map((match) => {
|
|
2279
|
-
const [whole, attributes = "", code = ""] = match;
|
|
2280
|
-
const typed = /\blang=["']?(?:ts|typescript)\b/u.test(attributes);
|
|
2281
|
-
return {
|
|
2282
|
-
code,
|
|
2283
|
-
offset: match.index + whole.indexOf(">") + 1,
|
|
2284
|
-
lang: typed ? "ts" : "jsx",
|
|
2285
|
-
keepLocals: true
|
|
2286
|
-
};
|
|
2287
|
-
});
|
|
2288
|
-
return [{
|
|
2289
|
-
code: source,
|
|
2290
|
-
offset: 0,
|
|
2291
|
-
lang: extension === "tsx" ? "tsx" : [
|
|
2292
|
-
"ts",
|
|
2293
|
-
"mts",
|
|
2294
|
-
"cts"
|
|
2295
|
-
].includes(extension) ? "ts" : "jsx",
|
|
2296
|
-
keepLocals: false
|
|
2297
|
-
}];
|
|
2298
|
-
}
|
|
2299
|
-
/** The module's `permdock` imports, or `undefined` when it has none. */
|
|
2300
|
-
function contextFor(program, set, segment) {
|
|
2301
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
2302
|
-
const namespaces = /* @__PURE__ */ new Map();
|
|
2303
|
-
const entries = /* @__PURE__ */ new Set();
|
|
2304
|
-
for (const statement of nodes(program.body)) {
|
|
2305
|
-
const entry = statement.source?.value;
|
|
2306
|
-
if (!isPermDockSpecifier(entry)) continue;
|
|
2307
|
-
entries.add(entry);
|
|
2308
|
-
if (statement.type !== "ImportDeclaration") continue;
|
|
2309
|
-
for (const spec of nodes(statement.specifiers)) {
|
|
2310
|
-
const local = spec.local?.name ?? "";
|
|
2311
|
-
if (spec.type === "ImportNamespaceSpecifier") namespaces.set(local, entry);
|
|
2312
|
-
const imported = nameOf(spec.imported);
|
|
2313
|
-
if (spec.type === "ImportSpecifier" && imported !== void 0) {
|
|
2314
|
-
const rename = renameOf(set, imported, entry);
|
|
2315
|
-
bindings.set(local, {
|
|
2316
|
-
entry,
|
|
2317
|
-
imported,
|
|
2318
|
-
spec,
|
|
2319
|
-
declaration: statement,
|
|
2320
|
-
rename
|
|
2321
|
-
});
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
if (entries.size === 0) return;
|
|
2326
|
-
const renamedLocals = /* @__PURE__ */ new Map();
|
|
2327
|
-
for (const [local, binding] of bindings) if (binding.rename !== void 0 && local === binding.imported) renamedLocals.set(local, binding.rename);
|
|
2328
|
-
const touches = (row) => row.entries.some((entry) => entries.has(entry));
|
|
2329
|
-
return {
|
|
2330
|
-
program,
|
|
2331
|
-
code: segment.code,
|
|
2332
|
-
keepLocals: segment.keepLocals,
|
|
2333
|
-
consumed: /* @__PURE__ */ new Set(),
|
|
2334
|
-
additions: /* @__PURE__ */ new Map(),
|
|
2335
|
-
set,
|
|
2336
|
-
edits: [],
|
|
2337
|
-
changes: [],
|
|
2338
|
-
followUps: [],
|
|
2339
|
-
bindings,
|
|
2340
|
-
namespaces,
|
|
2341
|
-
moduleNames: scopeBindings(program) ?? /* @__PURE__ */ new Set(),
|
|
2342
|
-
renamedLocals,
|
|
2343
|
-
kept: /* @__PURE__ */ new Set(),
|
|
2344
|
-
references: [],
|
|
2345
|
-
optionRows: set.renames.filter((row) => row.kind === "option" && touches(row)),
|
|
2346
|
-
methodRows: set.renames.filter((row) => row.kind === "method" && touches(row)),
|
|
2347
|
-
factories: factoryValues(program, bindings),
|
|
2348
|
-
handledKeys: /* @__PURE__ */ new Set(),
|
|
2349
|
-
newShapes: /* @__PURE__ */ new Set(),
|
|
2350
|
-
scopes: /* @__PURE__ */ new WeakMap()
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
function transformProgram(ctx, segment) {
|
|
2354
|
-
for (const [local, rename] of ctx.renamedLocals) if (segment.keepLocals || ctx.moduleNames.has(rename.to)) ctx.kept.add(local);
|
|
2355
|
-
walk(ctx.program, (node, parent, ancestors) => {
|
|
2356
|
-
switch (node.type) {
|
|
2357
|
-
case "Identifier":
|
|
2358
|
-
case "JSXIdentifier":
|
|
2359
|
-
visitIdentifier(ctx, node, parent, ancestors);
|
|
2360
|
-
break;
|
|
2361
|
-
case "MemberExpression":
|
|
2362
|
-
case "TSQualifiedName":
|
|
2363
|
-
visitMember(ctx, node, ancestors);
|
|
2364
|
-
break;
|
|
2365
|
-
case "ObjectPattern":
|
|
2366
|
-
reportMethods(ctx, propertyKeys(node), "destructured", "comes from");
|
|
2367
|
-
break;
|
|
2368
|
-
case "CallExpression":
|
|
2369
|
-
case "NewExpression":
|
|
2370
|
-
visitCall(ctx, node, ancestors);
|
|
2371
|
-
visitComponentArguments(ctx, node, ancestors);
|
|
2372
|
-
visitMethodCall(ctx, node, ancestors);
|
|
2373
|
-
break;
|
|
2374
|
-
case "JSXOpeningElement":
|
|
2375
|
-
visitElement(ctx, node, ancestors);
|
|
2376
|
-
break;
|
|
2377
|
-
case "AwaitExpression":
|
|
2378
|
-
visitAwait(ctx, node, ancestors);
|
|
2379
|
-
break;
|
|
2380
|
-
case "ObjectExpression":
|
|
2381
|
-
reportOptions(ctx, node, ancestors);
|
|
2382
|
-
reportWraps(ctx, node, ancestors);
|
|
2383
|
-
visitDurations(ctx, node, ancestors);
|
|
2384
|
-
}
|
|
2385
|
-
});
|
|
2386
|
-
const removed = removableBindings(ctx);
|
|
2387
|
-
rewriteImports(ctx, removed);
|
|
2388
|
-
rewriteReferences(ctx);
|
|
2389
|
-
rewriteReexports(ctx);
|
|
2390
|
-
reportUncalledSignatures(ctx, removed);
|
|
2391
|
-
finishImports(ctx, removed);
|
|
2392
|
-
}
|
|
2393
|
-
function visitIdentifier(ctx, node, parent, ancestors) {
|
|
2394
|
-
const name = node.name ?? "";
|
|
2395
|
-
if (parent === void 0 || !(ctx.bindings.has(name) || ctx.namespaces.has(name))) return;
|
|
2396
|
-
const place = referencePlace(node, parent, ancestors);
|
|
2397
|
-
if (place === "none" || !isModuleBinding(ctx, name, ancestors)) return;
|
|
2398
|
-
const rename = ctx.renamedLocals.get(name);
|
|
2399
|
-
if (rename !== void 0 && declaredBetween(ctx, rename.to, ancestors)) ctx.kept.add(name);
|
|
2400
|
-
ctx.references.push({
|
|
2401
|
-
node,
|
|
2402
|
-
place,
|
|
2403
|
-
parent
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
|
-
function visitMember(ctx, node, ancestors) {
|
|
2407
|
-
const member = node.type === "MemberExpression";
|
|
2408
|
-
const object = member ? node.object : node.left;
|
|
2409
|
-
const property = member ? node.property : node.right;
|
|
2410
|
-
if (node.computed === true || property?.name === void 0) return;
|
|
2411
|
-
const namespace = object?.type === "Identifier" && isModuleBinding(ctx, object.name ?? "", ancestors) ? ctx.namespaces.get(object.name ?? "") : void 0;
|
|
2412
|
-
const rename = namespace === void 0 ? void 0 : renameOf(ctx.set, property.name, namespace);
|
|
2413
|
-
if (rename !== void 0) replace(ctx, property, rename.to, rename.from);
|
|
2414
|
-
else if (member) {
|
|
2415
|
-
const receiver = object?.type === "Identifier" ? object.name : void 0;
|
|
2416
|
-
const origin = receiver !== void 0 && isModuleBinding(ctx, receiver, ancestors) ? ctx.factories.get(receiver) : void 0;
|
|
2417
|
-
const method = origin === void 0 ? void 0 : ctx.methodRows.find((row) => row.from === property.name && row.entries.includes(origin));
|
|
2418
|
-
if (method !== void 0) replace(ctx, property, method.to, method.from);
|
|
2419
|
-
else if (origin === void 0) reportMethods(ctx, [property], "member", "is on a value from");
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
/**
|
|
2423
|
-
* `const x = f(…)` or `const x = await f(…)` at module level, where `f` is
|
|
2424
|
-
* imported from a permdock entry.
|
|
2425
|
-
*/
|
|
2426
|
-
function factoryValues(program, bindings) {
|
|
2427
|
-
const out = /* @__PURE__ */ new Map();
|
|
2428
|
-
for (const statement of nodes(program.body)) {
|
|
2429
|
-
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
2430
|
-
if (declaration?.type !== "VariableDeclaration" || Reflect.get(declaration, "kind") !== "const") continue;
|
|
2431
|
-
for (const declarator of nodes(declaration.declarations)) {
|
|
2432
|
-
const init = declarator.init?.type === "AwaitExpression" ? declarator.init.argument : declarator.init;
|
|
2433
|
-
const callee = init?.type === "CallExpression" ? init.callee : void 0;
|
|
2434
|
-
const factory = callee?.type === "Identifier" ? callee.name : void 0;
|
|
2435
|
-
const entry = factory === void 0 ? void 0 : bindings.get(factory)?.entry;
|
|
2436
|
-
const name = declarator.id?.type === "Identifier" ? declarator.id.name : void 0;
|
|
2437
|
-
if (entry !== void 0 && name !== void 0) out.set(name, entry);
|
|
2438
|
-
}
|
|
2439
|
-
}
|
|
2440
|
-
return out;
|
|
2441
|
-
}
|
|
2442
|
-
function reportMethods(ctx, keys, what, where) {
|
|
2443
|
-
for (const key of keys) for (const row of ctx.methodRows) if (nameOf(key) === row.from) ctx.followUps.push({
|
|
2444
|
-
at: key.start,
|
|
2445
|
-
name: row.from,
|
|
2446
|
-
message: `${what} \`${row.from}\` is \`${row.to}\` when it ${where} ${listOf(row.entries)}`
|
|
2447
|
-
});
|
|
2448
|
-
}
|
|
2449
|
-
/** The non-computed keys of an object literal or pattern. */
|
|
2450
|
-
function propertyKeys(node) {
|
|
2451
|
-
return nodes(node.properties).flatMap((property) => property.type === "Property" && property.computed !== true && property.key !== void 0 ? [property.key] : []);
|
|
2452
|
-
}
|
|
2453
|
-
function visitCall(ctx, node, ancestors) {
|
|
2454
|
-
const callee = importedCallee(ctx, node.callee, ancestors);
|
|
2455
|
-
if (callee === void 0) return;
|
|
2456
|
-
const pending = awaitRow(ctx, callee);
|
|
2457
|
-
if (pending !== void 0 && ancestors.at(-1)?.type !== "AwaitExpression") reportUnawaited(ctx, node, ancestors, pending);
|
|
2458
|
-
const renamed = renameOf(ctx.set, callee.imported, callee.entry)?.to;
|
|
2459
|
-
const names = /* @__PURE__ */ new Set([callee.imported, renamed]);
|
|
2460
|
-
const moved = visitFunctionCall(ctx, node, callee);
|
|
2461
|
-
visitWraps(ctx, node, callee, ancestors);
|
|
2462
|
-
for (const signature of ctx.set.signatures) if (!moved && signature.entries.includes(callee.entry) && names.has(signature.name)) {
|
|
2463
|
-
if (signature.shape === "curried" && !isCurried(node, ancestors)) {
|
|
2464
|
-
ctx.newShapes.add(signature.name);
|
|
2465
|
-
continue;
|
|
2466
|
-
}
|
|
2467
|
-
ctx.followUps.push({
|
|
2468
|
-
at: node.start,
|
|
2469
|
-
name: signature.name,
|
|
2470
|
-
message: `\`${signature.before}\` is now \`${signature.after}\``
|
|
2471
|
-
});
|
|
2472
|
-
}
|
|
2473
|
-
const rows = ctx.optionRows.filter((row) => row.entries.includes(callee.entry) && (row.calls ?? []).some((call) => names.has(call)));
|
|
2474
|
-
for (const argument of nodes(node.arguments)) if (argument.type === "ObjectExpression") renameOptions(ctx, argument, rows);
|
|
2475
|
-
}
|
|
2476
|
-
/** `f(options)(key)`, or `f({ … })` whose result is kept for a later call. */
|
|
2477
|
-
function isCurried(node, ancestors) {
|
|
2478
|
-
const args = nodes(node.arguments);
|
|
2479
|
-
const parent = ancestors.at(-1);
|
|
2480
|
-
return args.length === 1 && (args[0]?.type === "ObjectExpression" || parent?.type === "CallExpression" && parent.callee === node);
|
|
2481
|
-
}
|
|
2482
|
-
function renameOptions(ctx, object, rows) {
|
|
2483
|
-
for (const property of nodes(object.properties)) {
|
|
2484
|
-
const row = rows.find((item) => item.from === nameOf(property.key));
|
|
2485
|
-
if (row !== void 0) renameKey(ctx, property, row.from, row.to);
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
/**
|
|
2489
|
-
* Rows with `calls` are renamed at those calls and nowhere else: their old key
|
|
2490
|
-
* (`store`) is still a valid option on every other factory. Rows without
|
|
2491
|
-
* `calls` are reported only on an object that reaches a permdock call.
|
|
2492
|
-
*/
|
|
2493
|
-
function reportOptions(ctx, node, ancestors) {
|
|
2494
|
-
const target = optionTarget(ctx, node, ancestors);
|
|
2495
|
-
if (target === void 0) return;
|
|
2496
|
-
const rows = ctx.optionRows.filter((row) => row.calls === void 0 && (target.entry === void 0 || row.entries.includes(target.entry)));
|
|
2497
|
-
for (const key of propertyKeys(node)) for (const row of rows) if (nameOf(key) === row.from && !ctx.handledKeys.has(key)) ctx.followUps.push({
|
|
2498
|
-
at: key.start,
|
|
2499
|
-
name: row.from,
|
|
2500
|
-
message: `option \`${row.from}\` is \`${row.to}\` when this object reaches ${listOf(row.entries)}`
|
|
2501
|
-
});
|
|
2502
|
-
}
|
|
2503
|
-
const PASS_THROUGH = /* @__PURE__ */ new Set([
|
|
2504
|
-
"ArrayExpression",
|
|
2505
|
-
"ObjectExpression",
|
|
2506
|
-
"ParenthesizedExpression",
|
|
2507
|
-
"TSAsExpression",
|
|
2508
|
-
"TSSatisfiesExpression",
|
|
2509
|
-
"TSNonNullExpression"
|
|
2510
|
-
]);
|
|
2511
|
-
/**
|
|
2512
|
-
* The permdock call an object literal is an argument of, directly or nested in
|
|
2513
|
-
* another argument's object, array or property value. `entry` is unset for a
|
|
2514
|
-
* method on a receiver named after PermDock, whose entry is unknown.
|
|
2515
|
-
*/
|
|
2516
|
-
function optionTarget(ctx, node, ancestors) {
|
|
2517
|
-
let child = node;
|
|
2518
|
-
for (let index = ancestors.length - 1; index >= 0; index -= 1) {
|
|
2519
|
-
const parent = ancestors[index];
|
|
2520
|
-
if (parent === void 0) return;
|
|
2521
|
-
if (parent.type === "CallExpression" || parent.type === "NewExpression") return nodes(parent.arguments).includes(child) ? calleeTarget(ctx, parent.callee, ancestors) : void 0;
|
|
2522
|
-
if (!(parent.type === "Property" && parent.value === child || PASS_THROUGH.has(parent.type))) return;
|
|
2523
|
-
child = parent;
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
function calleeTarget(ctx, callee, ancestors) {
|
|
2527
|
-
const imported = importedCallee(ctx, callee, ancestors);
|
|
2528
|
-
if (imported !== void 0) return { entry: imported.entry };
|
|
2529
|
-
const receiver = callee?.type === "MemberExpression" && callee.computed !== true ? callee.object : void 0;
|
|
2530
|
-
if (!holdsInstance(ctx, receiver, ancestors)) return;
|
|
2531
|
-
const name = receiver?.name ?? "";
|
|
2532
|
-
return { entry: isModuleBinding(ctx, name, ancestors) ? ctx.factories.get(name) : void 0 };
|
|
2533
|
-
}
|
|
2534
|
-
function rewriteImports(ctx, removed) {
|
|
2535
|
-
for (const [local, binding] of ctx.bindings) {
|
|
2536
|
-
const { rename, spec } = binding;
|
|
2537
|
-
const imported = spec.imported;
|
|
2538
|
-
if (rename === void 0 || imported === void 0 || removed.has(local)) continue;
|
|
2539
|
-
if (local === binding.imported) replace(ctx, imported, ctx.kept.has(local) ? `${rename.to} as ${local}` : rename.to, rename.from);
|
|
2540
|
-
else replace(ctx, imported, imported.type === "Literal" ? JSON.stringify(rename.to) : rename.to, rename.from);
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
function rewriteReferences(ctx) {
|
|
2544
|
-
for (const { node, place, parent } of ctx.references) {
|
|
2545
|
-
const name = node.name ?? "";
|
|
2546
|
-
const rename = ctx.renamedLocals.get(name);
|
|
2547
|
-
if (rename === void 0 || ctx.kept.has(name) || ctx.consumed.has(node.start)) continue;
|
|
2548
|
-
if (place === "shorthand" && parent.key !== void 0 && ctx.handledKeys.has(parent.key)) replace(ctx, node, rename.to, name);
|
|
2549
|
-
else if (place === "shorthand") edit(ctx, parent, `${name}: ${rename.to}`, name, rename.to);
|
|
2550
|
-
else if (place === "export" && parent.exported?.start === node.start) replace(ctx, node, `${rename.to} as ${name}`, name);
|
|
2551
|
-
else replace(ctx, node, rename.to, name);
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
/**
|
|
2555
|
-
* `export { a } from 'permdock'` keeps exporting `a`: the module's own export
|
|
2556
|
-
* name is not the codemod's to change.
|
|
2557
|
-
*/
|
|
2558
|
-
function rewriteReexports(ctx) {
|
|
2559
|
-
for (const statement of nodes(ctx.program.body)) {
|
|
2560
|
-
const entry = statement.source?.value;
|
|
2561
|
-
if (statement.type !== "ExportNamedDeclaration" || !isPermDockSpecifier(entry)) continue;
|
|
2562
|
-
for (const spec of nodes(statement.specifiers)) {
|
|
2563
|
-
const local = spec.local;
|
|
2564
|
-
const rename = renameOf(ctx.set, nameOf(local) ?? "", entry);
|
|
2565
|
-
if (rename !== void 0 && local !== void 0) replace(ctx, local, spec.exported?.start === local.start ? `${rename.to} as ${rename.from}` : rename.to, rename.from);
|
|
2566
|
-
}
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
function reportUncalledSignatures(ctx, removed) {
|
|
2570
|
-
for (const [local, binding] of ctx.bindings) {
|
|
2571
|
-
if (removed.has(local)) continue;
|
|
2572
|
-
const names = /* @__PURE__ */ new Set([binding.imported, binding.rename?.to]);
|
|
2573
|
-
for (const signature of ctx.set.signatures) if (signature.entries.includes(binding.entry) && names.has(signature.name) && !ctx.newShapes.has(signature.name) && !ctx.followUps.some((note) => note.name === signature.name)) ctx.followUps.push({
|
|
2574
|
-
at: binding.spec.start,
|
|
2575
|
-
name: signature.name,
|
|
2576
|
-
message: `\`${local}\` is imported; \`${signature.before}\` is now \`${signature.after}\``
|
|
2577
|
-
});
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
//#endregion
|
|
2581
|
-
//#region src/cli/codemod/codemod.ts
|
|
2582
|
-
const CODEMOD_0_5 = Object.freeze({
|
|
2583
|
-
renames: Object.freeze([...RENAMES_0_5, ...CALL_RENAMES_0_5]),
|
|
2584
|
-
signatures: SIGNATURE_CHANGES_0_5,
|
|
2585
|
-
props: PROP_RENAMES_0_5,
|
|
2586
|
-
templates: TEMPLATE_HINTS_0_5,
|
|
2587
|
-
awaits: AWAIT_RENAMES_0_5,
|
|
2588
|
-
methodFunctions: METHOD_FUNCTIONS_0_5,
|
|
2589
|
-
functionMethods: FUNCTION_METHODS_0_5,
|
|
2590
|
-
wraps: OPTION_WRAPS_0_5,
|
|
2591
|
-
durations: DURATION_KEYS_0_5
|
|
2592
|
-
});
|
|
2593
|
-
const CODEMOD_0_8 = Object.freeze({
|
|
2594
|
-
renames: [],
|
|
2595
|
-
signatures: SIGNATURE_CHANGES_0_8,
|
|
2596
|
-
configMoves: CONFIG_MOVES_0_8
|
|
2597
|
-
});
|
|
2598
|
-
const CODEMOD_0_17 = Object.freeze({
|
|
2599
|
-
renames: [],
|
|
2600
|
-
signatures: [],
|
|
2601
|
-
literals: rewriteLiterals017
|
|
2602
|
-
});
|
|
2603
|
-
/** Each codemod version and the rename map it applies. */
|
|
2604
|
-
const CODEMODS = Object.freeze({
|
|
2605
|
-
"0.5": CODEMOD_0_5,
|
|
2606
|
-
"0.8": CODEMOD_0_8,
|
|
2607
|
-
"0.17": CODEMOD_0_17
|
|
2608
|
-
});
|
|
2609
|
-
function codemodVersions() {
|
|
2610
|
-
return Object.keys(CODEMODS);
|
|
2611
|
-
}
|
|
2612
|
-
const EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2613
|
-
".ts",
|
|
2614
|
-
".tsx",
|
|
2615
|
-
".mts",
|
|
2616
|
-
".cts",
|
|
2617
|
-
".js",
|
|
2618
|
-
".jsx",
|
|
2619
|
-
".mjs",
|
|
2620
|
-
".cjs",
|
|
2621
|
-
".vue",
|
|
2622
|
-
".svelte"
|
|
2623
|
-
]);
|
|
2624
|
-
/**
|
|
2625
|
-
* Files whose shell commands the codemod rewrites when the version renames CLI
|
|
2626
|
-
* names.
|
|
2627
|
-
*/
|
|
2628
|
-
const CLI_FILE_NAMES = /* @__PURE__ */ new Set([
|
|
2629
|
-
"package.json",
|
|
2630
|
-
"Makefile",
|
|
2631
|
-
"justfile",
|
|
2632
|
-
"Dockerfile"
|
|
2633
|
-
]);
|
|
2634
|
-
const CLI_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2635
|
-
".yml",
|
|
2636
|
-
".yaml",
|
|
2637
|
-
".sh"
|
|
2638
|
-
]);
|
|
2639
|
-
/** Prose: the codemod lists the old calls in it and rewrites none. */
|
|
2640
|
-
const CLI_REVIEW_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".mdx"]);
|
|
2641
|
-
/** The versions whose renames include the CLI's own commands and flags. */
|
|
2642
|
-
const CLI_RENAME_VERSIONS = /* @__PURE__ */ new Set(["0.5"]);
|
|
2643
|
-
const SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
2644
|
-
"node_modules",
|
|
2645
|
-
"dist",
|
|
2646
|
-
".git",
|
|
2647
|
-
".next",
|
|
2648
|
-
".turbo",
|
|
2649
|
-
".svelte-kit",
|
|
2650
|
-
"coverage"
|
|
2651
|
-
]);
|
|
2652
|
-
function runCodemod(options) {
|
|
2653
|
-
const report = codemod(options);
|
|
2654
|
-
return {
|
|
2655
|
-
code: 0,
|
|
2656
|
-
output: options.json ? JSON.stringify(report, null, 2) : formatReport(report)
|
|
2657
|
-
};
|
|
2658
|
-
}
|
|
2659
|
-
function codemod(options) {
|
|
2660
|
-
const version = normaliseVersion(options.version);
|
|
2661
|
-
const set = CODEMODS[version];
|
|
2662
|
-
if (set === void 0) throw new CliError("usage", `unknown codemod version '${version}'. Supported: ${Object.keys(CODEMODS).join(", ")}.`);
|
|
2663
|
-
const files = sourceFiles(options.cwd, options.paths.length === 0 ? ["."] : options.paths, CLI_RENAME_VERSIONS.has(version));
|
|
2664
|
-
const changed = [];
|
|
2665
|
-
const followUps = [];
|
|
2666
|
-
const writes = [];
|
|
2667
|
-
for (const file of files) {
|
|
2668
|
-
const source = readFileSync(file, "utf8");
|
|
2669
|
-
if (!source.includes("permdock") && !basename(file).startsWith("permdock.config.")) continue;
|
|
2670
|
-
const name = rel(options.cwd, file);
|
|
2671
|
-
const result = isCodeFile(file) ? withConfigMoves(file, withLiterals(file, transformSource(file, source, set), set), set) : cliResult(file, source);
|
|
2672
|
-
if (result.error !== void 0) {
|
|
2673
|
-
followUps.push({
|
|
2674
|
-
file: name,
|
|
2675
|
-
line: 1,
|
|
2676
|
-
column: 1,
|
|
2677
|
-
name: "parse",
|
|
2678
|
-
message: `not parsed, left as it is: ${result.error}`
|
|
2679
|
-
});
|
|
2680
|
-
continue;
|
|
2681
|
-
}
|
|
2682
|
-
if (result.changes.length > 0) {
|
|
2683
|
-
changed.push({
|
|
2684
|
-
file: name,
|
|
2685
|
-
changes: result.changes
|
|
2686
|
-
});
|
|
2687
|
-
if (result.source !== source) writes.push({
|
|
2688
|
-
path: file,
|
|
2689
|
-
text: result.source
|
|
2690
|
-
});
|
|
2691
|
-
}
|
|
2692
|
-
for (const followUp of result.followUps) followUps.push({
|
|
2693
|
-
file: name,
|
|
2694
|
-
...followUp
|
|
2695
|
-
});
|
|
2696
|
-
}
|
|
2697
|
-
if (!options.dryRun && writes.length > 0) {
|
|
2698
|
-
refuseDirty({
|
|
2699
|
-
command: "codemod",
|
|
2700
|
-
invocation: [
|
|
2701
|
-
"codemod",
|
|
2702
|
-
version,
|
|
2703
|
-
...options.paths
|
|
2704
|
-
].join(" "),
|
|
2705
|
-
cwd: options.cwd,
|
|
2706
|
-
paths: writes.map((write) => write.path),
|
|
2707
|
-
force: options.force === true
|
|
2708
|
-
});
|
|
2709
|
-
applyFiles(options.cwd, writes);
|
|
2710
|
-
}
|
|
2711
|
-
return {
|
|
2712
|
-
version,
|
|
2713
|
-
dryRun: options.dryRun,
|
|
2714
|
-
scanned: files.length,
|
|
2715
|
-
files: changed,
|
|
2716
|
-
followUps
|
|
2717
|
-
};
|
|
2718
|
-
}
|
|
2719
|
-
function withLiterals(file, result, set) {
|
|
2720
|
-
if (result.error !== void 0 || set.literals === void 0) return result;
|
|
2721
|
-
const rewritten = set.literals(file, result.source);
|
|
2722
|
-
return {
|
|
2723
|
-
source: rewritten.source,
|
|
2724
|
-
changes: [...result.changes, ...rewritten.changes],
|
|
2725
|
-
followUps: [...result.followUps, ...rewritten.followUps]
|
|
2726
|
-
};
|
|
2727
|
-
}
|
|
2728
|
-
function withConfigMoves(file, result, set) {
|
|
2729
|
-
if (result.error !== void 0 || set.configMoves === void 0) return result;
|
|
2730
|
-
const moved = moveConfigKeys(file, result.source, set.configMoves);
|
|
2731
|
-
return {
|
|
2732
|
-
source: moved.source,
|
|
2733
|
-
changes: [...result.changes, ...moved.changes],
|
|
2734
|
-
followUps: [...result.followUps, ...moved.followUps]
|
|
2735
|
-
};
|
|
2736
|
-
}
|
|
2737
|
-
function normaliseVersion(version) {
|
|
2738
|
-
if (version === void 0) throw new CliError("usage", `codemod needs a version: permdock codemod <version>. Supported: ${Object.keys(CODEMODS).join(", ")}.`);
|
|
2739
|
-
return /^v?(\d+\.\d+)(?:\.\d+)?$/u.exec(version)?.[1] ?? version;
|
|
2740
|
-
}
|
|
2741
|
-
function isCodeFile(file) {
|
|
2742
|
-
return EXTENSIONS.has(extname(file));
|
|
2743
|
-
}
|
|
2744
|
-
function isCliFile(name) {
|
|
2745
|
-
return CLI_FILE_NAMES.has(name) || CLI_EXTENSIONS.has(extname(name)) || CLI_REVIEW_EXTENSIONS.has(extname(name));
|
|
2746
|
-
}
|
|
2747
|
-
function cliResult(file, source) {
|
|
2748
|
-
const result = rewriteCliCalls(source, { json: extname(file) === ".json" });
|
|
2749
|
-
if (!CLI_REVIEW_EXTENSIONS.has(extname(file))) return {
|
|
2750
|
-
source: result.text,
|
|
2751
|
-
changes: result.changes,
|
|
2752
|
-
followUps: result.followUps
|
|
2753
|
-
};
|
|
2754
|
-
return {
|
|
2755
|
-
source,
|
|
2756
|
-
changes: [],
|
|
2757
|
-
followUps: [...result.changes.map((change) => ({
|
|
2758
|
-
line: change.line,
|
|
2759
|
-
column: change.column,
|
|
2760
|
-
name: "cli",
|
|
2761
|
-
message: `${change.from} → ${change.to} since 0.5.0`
|
|
2762
|
-
})), ...result.followUps]
|
|
2763
|
-
};
|
|
2764
|
-
}
|
|
2765
|
-
function sourceFiles(cwd, paths, cli) {
|
|
2766
|
-
const out = /* @__PURE__ */ new Set();
|
|
2767
|
-
for (const path of paths) {
|
|
2768
|
-
const root = resolve(cwd, path);
|
|
2769
|
-
const stats = statSync(root, { throwIfNoEntry: false });
|
|
2770
|
-
if (stats === void 0) throw new CliError("usage", `not found: ${path}`);
|
|
2771
|
-
if (stats.isFile()) out.add(root);
|
|
2772
|
-
else walkDir(root, out, cli);
|
|
2773
|
-
}
|
|
2774
|
-
return [...out].toSorted();
|
|
2775
|
-
}
|
|
2776
|
-
function walkDir(dir, out, cli) {
|
|
2777
|
-
for (const name of readdirSync(dir)) {
|
|
2778
|
-
if (SKIP_DIRS.has(name)) continue;
|
|
2779
|
-
const full = join(dir, name);
|
|
2780
|
-
if (statSync(full).isDirectory()) walkDir(full, out, cli);
|
|
2781
|
-
else if (EXTENSIONS.has(extname(name)) || cli && isCliFile(name)) out.add(full);
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
function formatReport(report) {
|
|
2785
|
-
const lines = [];
|
|
2786
|
-
const changes = report.files.reduce((sum, file) => sum + file.changes.length, 0);
|
|
2787
|
-
const verb = report.dryRun ? "would change" : "changed";
|
|
2788
|
-
lines.push(`permdock codemod ${report.version}: ${verb} ${changes} ${changes === 1 ? "name" : "names"} in ${report.files.length} of ${report.scanned} ${report.scanned === 1 ? "file" : "files"}; ${report.followUps.length} manual ${report.followUps.length === 1 ? "follow-up" : "follow-ups"}${report.dryRun ? " (dry run, nothing written)" : ""}`);
|
|
2789
|
-
for (const file of report.files) {
|
|
2790
|
-
lines.push("", file.file);
|
|
2791
|
-
for (const change of file.changes) lines.push(` ${change.line}:${change.column} ${change.from} → ${change.to}`);
|
|
2792
|
-
}
|
|
2793
|
-
if (report.followUps.length > 0) {
|
|
2794
|
-
lines.push("", "Manual follow-ups");
|
|
2795
|
-
for (const item of report.followUps) lines.push(` ${item.file}:${item.line}:${item.column} ${item.message}`);
|
|
2796
|
-
}
|
|
2797
|
-
return lines.join("\n");
|
|
2798
|
-
}
|
|
2799
|
-
//#endregion
|
|
2800
|
-
export { codemodVersions, runCodemod };
|