@xano/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +788 -0
- package/LICENSE +21 -0
- package/README.md +541 -0
- package/dist/.build-fingerprint +1 -0
- package/dist/agent-file-refresh-ZEMK33AX.js +38 -0
- package/dist/answer-shape-K67TAAPY.js +33 -0
- package/dist/backend-dir-2U53CIAL.js +39 -0
- package/dist/backend-slot-7QXW2QYC.js +28 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +255 -0
- package/dist/branch-NCRNWQBQ.js +61 -0
- package/dist/branch-commands-ACIRCEQJ.js +79 -0
- package/dist/bundle.d.ts +223 -0
- package/dist/bundle.js +153 -0
- package/dist/capture-WAXPD7DR.js +41 -0
- package/dist/chunk-27GWNP2I.js +23 -0
- package/dist/chunk-2CMJZDCL.js +177 -0
- package/dist/chunk-2EZ3ZJZZ.js +302 -0
- package/dist/chunk-2GNFDZA2.js +390 -0
- package/dist/chunk-2MNLRIOX.js +11 -0
- package/dist/chunk-2TFRR6JV.js +104 -0
- package/dist/chunk-2ZUEE4EK.js +408 -0
- package/dist/chunk-36JUQZVQ.js +22 -0
- package/dist/chunk-3DRXWLJ5.js +83 -0
- package/dist/chunk-3JDU4VRL.js +137 -0
- package/dist/chunk-3KZCLN4Z.js +241 -0
- package/dist/chunk-3LDULPRE.js +168 -0
- package/dist/chunk-3M4LFYNQ.js +111 -0
- package/dist/chunk-3XI5CTUE.js +22 -0
- package/dist/chunk-3YW23UFH.js +50 -0
- package/dist/chunk-45UIT5T2.js +862 -0
- package/dist/chunk-4BW2SG2N.js +46 -0
- package/dist/chunk-4KHEMC32.js +79 -0
- package/dist/chunk-4POWHT2K.js +321 -0
- package/dist/chunk-4Q2GN7NW.js +192 -0
- package/dist/chunk-5A2PLKZB.js +70 -0
- package/dist/chunk-5FBYXK5P.js +159 -0
- package/dist/chunk-5HVXPTU4.js +323 -0
- package/dist/chunk-5QU2P5CA.js +304 -0
- package/dist/chunk-5V5XU32D.js +191 -0
- package/dist/chunk-5ZSO4T2G.js +10 -0
- package/dist/chunk-622HUCZT.js +10 -0
- package/dist/chunk-65HWOMGV.js +177 -0
- package/dist/chunk-6ELFRN3P.js +365 -0
- package/dist/chunk-6HO3NCSJ.js +1055 -0
- package/dist/chunk-6IUMKYWI.js +457 -0
- package/dist/chunk-6KEB3C3U.js +65 -0
- package/dist/chunk-6MR5TI5V.js +987 -0
- package/dist/chunk-6NNTNXN7.js +157 -0
- package/dist/chunk-6PBR37LN.js +97 -0
- package/dist/chunk-6QXLMMT3.js +155 -0
- package/dist/chunk-6ZGJCBZS.js +224 -0
- package/dist/chunk-73IVBKMA.js +250 -0
- package/dist/chunk-7G3CTU7I.js +286 -0
- package/dist/chunk-A3UDOZB6.js +222 -0
- package/dist/chunk-A6E77GDW.js +85 -0
- package/dist/chunk-AHJWCYQO.js +660 -0
- package/dist/chunk-AKNCFVKZ.js +36 -0
- package/dist/chunk-AM4FKL4J.js +237 -0
- package/dist/chunk-AN6BL47T.js +26 -0
- package/dist/chunk-AOSYVMUS.js +147 -0
- package/dist/chunk-APWXY5SL.js +182 -0
- package/dist/chunk-AWEIIR2U.js +218 -0
- package/dist/chunk-AWQ7BQTQ.js +73 -0
- package/dist/chunk-BAUZOWGX.js +393 -0
- package/dist/chunk-BHACRS6R.js +940 -0
- package/dist/chunk-BWPNT55T.js +680 -0
- package/dist/chunk-C6RIMRU4.js +187 -0
- package/dist/chunk-CGVQZXYG.js +263 -0
- package/dist/chunk-CIMQZRRE.js +162 -0
- package/dist/chunk-CJHQKJU4.js +113 -0
- package/dist/chunk-CTMO46PK.js +1897 -0
- package/dist/chunk-D53J55C5.js +106 -0
- package/dist/chunk-D7VGG3WS.js +90 -0
- package/dist/chunk-DAD3ONIS.js +245 -0
- package/dist/chunk-DGWHAVRG.js +162 -0
- package/dist/chunk-DX4QR4B2.js +483 -0
- package/dist/chunk-EHP3WPEG.js +21 -0
- package/dist/chunk-ELP2HMXC.js +432 -0
- package/dist/chunk-ERVIASGL.js +21 -0
- package/dist/chunk-ET4Y4XCB.js +865 -0
- package/dist/chunk-ETO6LGLD.js +4750 -0
- package/dist/chunk-EUUUMY7J.js +24 -0
- package/dist/chunk-FQJ2TTHP.js +218 -0
- package/dist/chunk-FQOF7E2E.js +133 -0
- package/dist/chunk-FWD7AL6N.js +21 -0
- package/dist/chunk-FXFV3KU6.js +138 -0
- package/dist/chunk-FXRQOWTE.js +171 -0
- package/dist/chunk-G554NZNI.js +210 -0
- package/dist/chunk-GSGDWJB5.js +13 -0
- package/dist/chunk-H2V3N23D.js +66 -0
- package/dist/chunk-H5C7MBCR.js +159 -0
- package/dist/chunk-HHN734BU.js +371 -0
- package/dist/chunk-HRVBLCVJ.js +243 -0
- package/dist/chunk-HVRUQXGD.js +1264 -0
- package/dist/chunk-I4F5TCJH.js +130 -0
- package/dist/chunk-IDOTCMDV.js +57 -0
- package/dist/chunk-IGOLHKWF.js +427 -0
- package/dist/chunk-JGE7CAWB.js +148 -0
- package/dist/chunk-JTUKLCXS.js +92 -0
- package/dist/chunk-JZGVVJSI.js +66 -0
- package/dist/chunk-K4WX6UUU.js +923 -0
- package/dist/chunk-K5BBGTYZ.js +217 -0
- package/dist/chunk-K6RXBGUB.js +427 -0
- package/dist/chunk-KTSDSD36.js +165 -0
- package/dist/chunk-L5JYN3NM.js +1038 -0
- package/dist/chunk-LIEOKXKD.js +354 -0
- package/dist/chunk-LLNZGEFK.js +51 -0
- package/dist/chunk-LPECSJ2J.js +55 -0
- package/dist/chunk-LQCMKAJ7.js +413 -0
- package/dist/chunk-LRN4ZJCQ.js +1145 -0
- package/dist/chunk-MJ4ZVHKN.js +17 -0
- package/dist/chunk-MXHSQOC4.js +3061 -0
- package/dist/chunk-N5GKCWE5.js +367 -0
- package/dist/chunk-NA3PXMEF.js +10 -0
- package/dist/chunk-NAQDMEHV.js +76 -0
- package/dist/chunk-NWKXM5RD.js +109 -0
- package/dist/chunk-NZOWWHU5.js +196 -0
- package/dist/chunk-OHX6MIUZ.js +184 -0
- package/dist/chunk-OOXWYAA4.js +15 -0
- package/dist/chunk-OPHB5ORL.js +1990 -0
- package/dist/chunk-OXA6PSZT.js +1725 -0
- package/dist/chunk-P2HAGF6H.js +73 -0
- package/dist/chunk-PTHVMXZI.js +3036 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-Q325JKYB.js +189 -0
- package/dist/chunk-Q7DGTQ5G.js +255 -0
- package/dist/chunk-QCNYHBL7.js +601 -0
- package/dist/chunk-QO6BVGS5.js +145 -0
- package/dist/chunk-QXTKSOFI.js +76 -0
- package/dist/chunk-ROY4YAEQ.js +66 -0
- package/dist/chunk-RTJRZFFY.js +447 -0
- package/dist/chunk-SAVJUS2X.js +128 -0
- package/dist/chunk-SFLHVCKX.js +173 -0
- package/dist/chunk-STSFNCY4.js +127 -0
- package/dist/chunk-SWBF2LTK.js +170 -0
- package/dist/chunk-T5KELPAR.js +109 -0
- package/dist/chunk-TFFGOFVZ.js +1481 -0
- package/dist/chunk-TLHIFK4M.js +256 -0
- package/dist/chunk-TLQE7ZN3.js +156 -0
- package/dist/chunk-TPHWJ7UG.js +1981 -0
- package/dist/chunk-TRJCALW3.js +291 -0
- package/dist/chunk-TTEIYD5P.js +133 -0
- package/dist/chunk-U64O2MXY.js +407 -0
- package/dist/chunk-UCQ2VUTG.js +630 -0
- package/dist/chunk-UTI5G6OJ.js +44 -0
- package/dist/chunk-UVHDMMIP.js +188 -0
- package/dist/chunk-UZ6QQWJT.js +120 -0
- package/dist/chunk-VAX3UZOY.js +686 -0
- package/dist/chunk-W3HBUKFO.js +57 -0
- package/dist/chunk-WKQLGKCL.js +2823 -0
- package/dist/chunk-WQFNASK4.js +560 -0
- package/dist/chunk-WRBKLYSJ.js +224 -0
- package/dist/chunk-WTPZRR4I.js +17 -0
- package/dist/chunk-WZDJ2LLX.js +2385 -0
- package/dist/chunk-X2NL4KUO.js +14 -0
- package/dist/chunk-X4DVXBFY.js +38 -0
- package/dist/chunk-X677DMZM.js +7050 -0
- package/dist/chunk-XBKMWY7F.js +612 -0
- package/dist/chunk-XNCP4KYO.js +78 -0
- package/dist/chunk-XVBGLISP.js +35 -0
- package/dist/chunk-XW6KISBB.js +1192 -0
- package/dist/chunk-YGZHHAAB.js +8156 -0
- package/dist/chunk-YHEFQUQB.js +186 -0
- package/dist/chunk-YLDALTWZ.js +653 -0
- package/dist/chunk-YU4HSQW7.js +229 -0
- package/dist/chunk-ZDPP6RKB.js +27 -0
- package/dist/chunk-ZFDZKNGG.js +194 -0
- package/dist/chunk-ZIY7RNUT.js +49 -0
- package/dist/chunk-ZYJP6BOO.js +30 -0
- package/dist/cli.d.ts +1111 -0
- package/dist/cli.js +165 -0
- package/dist/codegen-command-VR2GWR6C.js +173 -0
- package/dist/codegen.d.ts +115 -0
- package/dist/codegen.js +19 -0
- package/dist/commands-GJMJ4XYZ.js +76 -0
- package/dist/completion-ZQLO6PB6.js +738 -0
- package/dist/config-MBYGCAFK.js +136 -0
- package/dist/deploy-command-JVZPWHMK.js +180 -0
- package/dist/deploy-source-3W45CXMP.js +81 -0
- package/dist/dev-env-sync-HN44K4D5.js +188 -0
- package/dist/diagnostics-UEAAHWVF.js +30 -0
- package/dist/display-name-hint-ABBPVQIR.js +46 -0
- package/dist/emit-CyhBDxli.d.ts +7007 -0
- package/dist/env-example-refresh-ET5HMMDW.js +126 -0
- package/dist/env-pull-command-TNMNB3CV.js +323 -0
- package/dist/env-target-O4HRKTGZ.js +40 -0
- package/dist/env-var-command-ZIRDCAZA.js +427 -0
- package/dist/ephemeral-P7F3PMAD.js +54 -0
- package/dist/ephemeral-command-CLJJKOFT.js +592 -0
- package/dist/ephemeral-state-PYCBSOGX.js +61 -0
- package/dist/file-lock-PT74GWYW.js +10 -0
- package/dist/generate-command-AYEOLA26.js +510 -0
- package/dist/gitignore-3SJ3WNRG.js +51 -0
- package/dist/guards-4EBNCZDC.js +162 -0
- package/dist/hosted-file-PSHJB3HX.js +28 -0
- package/dist/impersonate-command-5JAS3WSV.js +152 -0
- package/dist/import-EQSFU6JC.js +19 -0
- package/dist/index.d.ts +5470 -0
- package/dist/index.js +371 -0
- package/dist/init-command-X2FR4UAK.js +125 -0
- package/dist/init-modules-RY7UHAOL.js +50 -0
- package/dist/init-web-M4YZSZK6.js +42 -0
- package/dist/internal.d.ts +179 -0
- package/dist/internal.js +2634 -0
- package/dist/io-RC56QSN5.js +26 -0
- package/dist/keep-data-merge-7MPLVAVI.js +1119 -0
- package/dist/lambda-config-reconcile-OUZ4OYAB.js +116 -0
- package/dist/landed-753YLJ5H.js +40 -0
- package/dist/landing-record-SU52SKXU.js +61 -0
- package/dist/live-diff-YONW2VI3.js +65 -0
- package/dist/local-engine-choice-CH5X3W7E.js +79 -0
- package/dist/local-engine-command-Z3OL7VOD.js +766 -0
- package/dist/local-engine-config-5U3SC434.js +39 -0
- package/dist/local-engine-deploy-PCQ4SNPB.js +39 -0
- package/dist/local-engine-process-EHTE5LLU.js +63 -0
- package/dist/local-engine-state-A4FTRFAF.js +32 -0
- package/dist/local-engine-update-check-6L645VBL.js +162 -0
- package/dist/lock-MRRHW5GS.js +87 -0
- package/dist/lock-commands-2QG25HL7.js +963 -0
- package/dist/login-command-QPYRWOXZ.js +538 -0
- package/dist/logout-command-WOIQLDP6.js +56 -0
- package/dist/loop-ALIZLOSX.js +191 -0
- package/dist/marketplace-command-K5YL42NO.js +977 -0
- package/dist/marketplace-resolve-LY32JES5.js +40 -0
- package/dist/meta-client-YXGPW53C.js +244 -0
- package/dist/module-manifest-JFGHU2TC.js +38 -0
- package/dist/near-key.d.ts +13 -0
- package/dist/near-key.js +8 -0
- package/dist/node.d.ts +95 -0
- package/dist/node.js +969 -0
- package/dist/operation-outcome-TZSESNC7.js +51 -0
- package/dist/output-target-AL3I44GG.js +47 -0
- package/dist/package-manager-PRAHUSCN.js +34 -0
- package/dist/plan-disclosure-6G4MLZKD.js +114 -0
- package/dist/plugin-contributions-WRNY5ABG.js +28 -0
- package/dist/plugin-prompt-4VA3B4FF.js +20 -0
- package/dist/plugin-questions-JTSYA74Q.js +24 -0
- package/dist/plugin.d.ts +396 -0
- package/dist/plugin.js +1 -0
- package/dist/preflight-command-2T5Z36MI.js +321 -0
- package/dist/profile-command-AH3PIM4X.js +800 -0
- package/dist/profile-pointer-GRWJU3YD.js +31 -0
- package/dist/profile-select-74TRDEPD.js +23 -0
- package/dist/project-dependency-KSH63ODT.js +35 -0
- package/dist/project-sdk-REPPOIBD.js +24 -0
- package/dist/promote-command-PCWT5N6S.js +140 -0
- package/dist/prompt-II3F3LND.js +27 -0
- package/dist/publish-command-TTDUUJI5.js +414 -0
- package/dist/pull-command-VBO7C4S3.js +161 -0
- package/dist/pull-superseded-GJWLG7XO.js +20 -0
- package/dist/release-command-N4ZPKMHR.js +146 -0
- package/dist/release-ns-command-3KFDMZ6G.js +1745 -0
- package/dist/response-HlXahv4K.d.ts +925 -0
- package/dist/retry-command-AS5EVREX.js +34 -0
- package/dist/routes-manifest-SNWUVBT6.js +43 -0
- package/dist/runtime-XETHVF33.js +14 -0
- package/dist/scaffold.d.ts +1911 -0
- package/dist/scaffold.js +107 -0
- package/dist/secrets-file-LVZD6IIM.js +56 -0
- package/dist/secrets-fill-command-TTCPSVXN.js +218 -0
- package/dist/seed-VU7C3QYS.js +46 -0
- package/dist/sent-writes-N7X4OVXT.js +22 -0
- package/dist/source-resolve-S2XA3XZF.js +83 -0
- package/dist/static-host-B2Y6AG3W.js +352 -0
- package/dist/status-command-RUDXTF7I.js +554 -0
- package/dist/store-6VNCD4D7.js +20 -0
- package/dist/store-ARM6VMO5.js +98 -0
- package/dist/store-DuYfzKlW.d.ts +3144 -0
- package/dist/suggest-6FOOYKHG.js +12 -0
- package/dist/sveltekit.d.ts +154 -0
- package/dist/sveltekit.js +109 -0
- package/dist/sync-contributions-UCEROO26.js +415 -0
- package/dist/table-ENAVMITR.js +42 -0
- package/dist/tables-command-GUPXXSB5.js +156 -0
- package/dist/tenant-IIHPOHGP.js +42 -0
- package/dist/tenant-command-D5HGI2X4.js +965 -0
- package/dist/test-command-TIKZMDPZ.js +476 -0
- package/dist/tests-BGGIOK3L.js +26 -0
- package/dist/token-NICJUTMT.js +72 -0
- package/dist/toolchain-hooks-GHKLUJOH.js +96 -0
- package/dist/toolchain-modules-5EAZUONB.js +24 -0
- package/dist/tracked-backend-EIBUMDZA.js +80 -0
- package/dist/update-check-2W2NLDTC.js +136 -0
- package/dist/upgrade-command-QHNFWM7O.js +531 -0
- package/dist/verify-rollout-DRCK5TDD.js +61 -0
- package/dist/whoami-command-STGINTXH.js +51 -0
- package/dist/workspace-2CLHU2LK.js +93 -0
- package/dist/workspace-binding-56PIIPCP.js +54 -0
- package/dist/workspace-command-JEXQETJD.js +535 -0
- package/dist/workspace-env-F2RFMSC5.js +70 -0
- package/dist/workspace-export-OJSH2HIW.js +21 -0
- package/dist/writable-VA7OISSK.js +25 -0
- package/dist/xano-ICFUSPFR.js +42 -0
- package/dist/xanosdk-import-GN42TO2B.js +56 -0
- package/dist/xanosdk-project-S6DXJONQ.js +41 -0
- package/dist/xdo-CxDr2Q1C.d.ts +1371 -0
- package/guides/README.md +33 -0
- package/guides/authoring.md +921 -0
- package/guides/cli.md +401 -0
- package/guides/codegen.md +177 -0
- package/guides/codes.md +404 -0
- package/guides/coverage.md +74 -0
- package/guides/deploying.md +1525 -0
- package/guides/environment.md +400 -0
- package/guides/marketplace.md +415 -0
- package/guides/module-contract.md +558 -0
- package/guides/object-kinds.md +433 -0
- package/guides/project-structure.md +43 -0
- package/guides/scaffold.md +351 -0
- package/guides/typed-frontend.md +242 -0
- package/llms/client.md +63 -0
- package/llms/errors.md +56 -0
- package/llms/fields.md +176 -0
- package/llms/filters.md +183 -0
- package/llms/kinds-agent-mcp.md +30 -0
- package/llms/kinds-core.md +100 -0
- package/llms/kinds-knowledge.md +20 -0
- package/llms/kinds-realtime.md +76 -0
- package/llms/lambda.md +94 -0
- package/llms/legacy.md +44 -0
- package/llms/lock.md +40 -0
- package/llms/object-kinds.md +34 -0
- package/llms/statements-calls.md +62 -0
- package/llms/statements-catalog.md +320 -0
- package/llms/statements-data.md +66 -0
- package/llms/statements-runtime.md +68 -0
- package/llms/tests.md +59 -0
- package/llms/toolchain.md +16 -0
- package/llms/triggers.md +36 -0
- package/llms/values.md +29 -0
- package/llms-full.txt +2085 -0
- package/llms.txt +493 -0
- package/manifest.json +11224 -0
- package/package.json +162 -0
- package/types/lambda-globals.d.ts +129 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server half of a static build: a directory a server-rendering build
|
|
3
|
+
* carries beside its static files (`@xano/sdk/sveltekit` writes it), which a
|
|
4
|
+
* local engine runs and every other host leaves out.
|
|
5
|
+
*
|
|
6
|
+
* It is a DOT directory on purpose. The server bundle can hold the app's
|
|
7
|
+
* private build-time env (SvelteKit inlines `$env/static/private` into it), and
|
|
8
|
+
* a Xano static-host build never publishes a hidden file, so a host that
|
|
9
|
+
* serves files only drops it even when it is uploaded.
|
|
10
|
+
*
|
|
11
|
+
* Not `.xano/`: that is the CLI's own state directory, which every scaffolded
|
|
12
|
+
* project's `.gitignore` ignores at any depth, so a committed build would lose
|
|
13
|
+
* its server bundle without a word.
|
|
14
|
+
*/
|
|
15
|
+
/** The directory, relative to the build's root. */
|
|
16
|
+
declare const SERVER_DIR = ".xano-ssr";
|
|
17
|
+
/** The server bundle, relative to the build's root. */
|
|
18
|
+
declare const SERVER_BUNDLE = ".xano-ssr/server.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `@xano/sdk/sveltekit`: a SvelteKit adapter whose output a Xano static host
|
|
22
|
+
* publishes, and a local engine also renders on the server.
|
|
23
|
+
*
|
|
24
|
+
* It goes wherever the project configures SvelteKit. A project `npx sv create`
|
|
25
|
+
* makes today has no `svelte.config.js`: the config is the object passed to
|
|
26
|
+
* `sveltekit()` in `vite.config.ts` (so is a `xanosdk init` scaffold's):
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* // vite.config.ts
|
|
30
|
+
* import { sveltekit } from "@sveltejs/kit/vite";
|
|
31
|
+
* import adapter from "@xano/sdk/sveltekit";
|
|
32
|
+
* export default defineConfig({ plugins: [sveltekit({ adapter: adapter() })] });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* A project that keeps a `svelte.config.js` sets `kit.adapter` there instead:
|
|
36
|
+
*
|
|
37
|
+
* ```js
|
|
38
|
+
* // svelte.config.js
|
|
39
|
+
* import adapter from "@xano/sdk/sveltekit";
|
|
40
|
+
* export default { kit: { adapter: adapter() } };
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* `vite build` then writes one directory (`build/` by default), which is what
|
|
44
|
+
* `xanosdk deploy --static build` uploads:
|
|
45
|
+
*
|
|
46
|
+
* - the STATIC half at its root: the client assets (`_app/…`), every prerendered
|
|
47
|
+
* page, and a `404.html` fallback shell. Any static host serves these files,
|
|
48
|
+
* and answers a path it holds no file for with `404.html` (status 404): the
|
|
49
|
+
* shell boots the app, which renders a route it knows and `+error.svelte`
|
|
50
|
+
* for one it does not. A prerendered `/404` route is kept as `404.html` only
|
|
51
|
+
* when every page route is prerendered; otherwise the shell replaces it, so
|
|
52
|
+
* the routes left to the browser still boot.
|
|
53
|
+
* - the SERVER half at `.xano-ssr/server.js`: SvelteKit's server and the app's
|
|
54
|
+
* routes in one script, which answers every request that is not a file. A
|
|
55
|
+
* local engine (`xanosdk deploy --local-engine --static build`) runs it, so a
|
|
56
|
+
* dynamic route arrives as HTML with its own `<title>` and meta tags.
|
|
57
|
+
*
|
|
58
|
+
* ## The server bundle is never public
|
|
59
|
+
*
|
|
60
|
+
* SvelteKit inlines every `$env/static/private` value into the server code at
|
|
61
|
+
* build time, so `.xano-ssr/server.js` can hold secrets. It sits in a dot directory
|
|
62
|
+
* for that reason: `xanosdk deploy` sends it only to a local engine, which keeps
|
|
63
|
+
* it privately and answers `/.xano-ssr/…` with a 404, and a static host that is
|
|
64
|
+
* sent it anyway (an older SDK, another uploader) never publishes a hidden file.
|
|
65
|
+
*
|
|
66
|
+
* ## The contract
|
|
67
|
+
*
|
|
68
|
+
* `.xano-ssr/server.js` is a classic script (no `import`/`export`) that assigns
|
|
69
|
+
* `globalThis.__respond(request, clientAddress) -> Promise<Response>`, taking
|
|
70
|
+
* and returning web `Request`/`Response` objects. The host that runs it
|
|
71
|
+
* supplies, before loading it:
|
|
72
|
+
*
|
|
73
|
+
* - the web platform APIs a fetch handler expects (`fetch`, `URL`, `Headers`,
|
|
74
|
+
* `TextEncoder`, `crypto`, timers);
|
|
75
|
+
* - `globalThis.__env`, which SvelteKit reads for `$env/dynamic/*`;
|
|
76
|
+
* - optionally `globalThis.__import(specifier) -> Promise<module>`, which
|
|
77
|
+
* answers the dynamic imports the bundle cannot hold (see
|
|
78
|
+
* {@link UNBUNDLABLE_IMPORT}). Without one they reject, and SvelteKit falls
|
|
79
|
+
* back from both.
|
|
80
|
+
*
|
|
81
|
+
* The engine supplies all three. The engine sets `XANO_HOST` there: its own base URL, for
|
|
82
|
+
* a `load` that calls the workspace's API. A rendered page also gets the same
|
|
83
|
+
* `window.XANO_HOST` (and `--static-env`) globals the deploy writes into the
|
|
84
|
+
* prerendered documents.
|
|
85
|
+
*
|
|
86
|
+
* Needs `esbuild` in the app (`npm i -D esbuild`); it bundles the server half.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
interface XanoAdapterOptions {
|
|
90
|
+
/** The output directory, relative to the project. Default `build`. */
|
|
91
|
+
out?: string;
|
|
92
|
+
/**
|
|
93
|
+
* A fallback page for hosts that serve files only: SvelteKit's app shell,
|
|
94
|
+
* which renders the requested route in the browser. Written as `404.html`
|
|
95
|
+
* by default, which a multipage static host serves (with status 404) for a
|
|
96
|
+
* path it holds no file for. `false` writes none. A local engine that runs
|
|
97
|
+
* the server half never serves it: SvelteKit renders the route itself.
|
|
98
|
+
*/
|
|
99
|
+
fallback?: string | false;
|
|
100
|
+
/** The JavaScript version the server bundle is lowered to. Default `es2017`. */
|
|
101
|
+
target?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The parts of SvelteKit's `Builder` this adapter calls. Declared here so the
|
|
105
|
+
* SDK takes no dependency on `@sveltejs/kit`; SvelteKit 2 passes the real one.
|
|
106
|
+
*/
|
|
107
|
+
interface SvelteKitBuilder {
|
|
108
|
+
rimraf(dir: string): void;
|
|
109
|
+
mkdirp(dir: string): void;
|
|
110
|
+
writeClient(dest: string): string[];
|
|
111
|
+
writePrerendered(dest: string): string[];
|
|
112
|
+
writeServer(dest: string): string[];
|
|
113
|
+
generateFallback(dest: string): Promise<void>;
|
|
114
|
+
generateManifest(opts: {
|
|
115
|
+
relativePath: string;
|
|
116
|
+
}): string;
|
|
117
|
+
getBuildDirectory(name: string): string;
|
|
118
|
+
prerendered: {
|
|
119
|
+
paths: string[];
|
|
120
|
+
};
|
|
121
|
+
routes: {
|
|
122
|
+
id: string;
|
|
123
|
+
prerender: boolean | "auto";
|
|
124
|
+
page: {
|
|
125
|
+
methods: string[];
|
|
126
|
+
};
|
|
127
|
+
}[];
|
|
128
|
+
log: {
|
|
129
|
+
minor(msg: string): void;
|
|
130
|
+
warn(msg: string): void;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** The shape SvelteKit expects from `kit.adapter`. */
|
|
134
|
+
interface SvelteKitAdapter {
|
|
135
|
+
name: string;
|
|
136
|
+
adapt(builder: SvelteKitBuilder): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The `import(` calls the engine cannot run, found in SvelteKit's server
|
|
140
|
+
* runtime. goja compiles no dynamic import, and SvelteKit calls it for two
|
|
141
|
+
* optional Node modules (`node:async_hooks`, and `node:crypto` through a
|
|
142
|
+
* variable), falling back when it fails. So exactly those two shapes (a
|
|
143
|
+
* `node:` literal, a variable argument) go to the host's `globalThis.__import`
|
|
144
|
+
* when it has one, and otherwise to a rejected promise. A relative `import('./nodes/0.js')` is left for esbuild to bundle,
|
|
145
|
+
* and `import(${…})` is left alone: SvelteKit WRITES that into the page's
|
|
146
|
+
* hydration script, which the browser must receive unchanged.
|
|
147
|
+
*/
|
|
148
|
+
declare const UNBUNDLABLE_IMPORT: RegExp;
|
|
149
|
+
/** Rewrite the dynamic imports {@link UNBUNDLABLE_IMPORT} matches. Exported for tests. */
|
|
150
|
+
declare function rewriteDynamicImports(source: string): string;
|
|
151
|
+
/** The SvelteKit adapter. See the module comment for what it writes. */
|
|
152
|
+
declare function adapter(options?: XanoAdapterOptions): SvelteKitAdapter;
|
|
153
|
+
|
|
154
|
+
export { SERVER_BUNDLE, SERVER_DIR, type SvelteKitAdapter, type SvelteKitBuilder, UNBUNDLABLE_IMPORT, type XanoAdapterOptions, adapter as default, rewriteDynamicImports };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SERVER_BUNDLE,
|
|
3
|
+
SERVER_DIR
|
|
4
|
+
} from "./chunk-OOXWYAA4.js";
|
|
5
|
+
import "./chunk-PZ5AY32C.js";
|
|
6
|
+
|
|
7
|
+
// src/sveltekit.ts
|
|
8
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
9
|
+
import { resolve } from "path";
|
|
10
|
+
var ADAPTER_NAME = "@xano/sdk/sveltekit";
|
|
11
|
+
var ENTRY = `import { Server } from './server/index.js';
|
|
12
|
+
import { manifest } from './manifest.js';
|
|
13
|
+
|
|
14
|
+
const server = new Server(manifest);
|
|
15
|
+
let ready;
|
|
16
|
+
|
|
17
|
+
globalThis.__respond = async (request, clientAddress) => {
|
|
18
|
+
ready = ready || server.init({ env: globalThis.__env || {} });
|
|
19
|
+
await ready;
|
|
20
|
+
return server.respond(request, { getClientAddress: () => clientAddress });
|
|
21
|
+
};
|
|
22
|
+
`;
|
|
23
|
+
var UNBUNDLABLE_IMPORT = /\bimport\(\s*(?:\/\*[\s\S]*?\*\/\s*)?(?=["']node:|(?!\$\{)[A-Za-z_$])/g;
|
|
24
|
+
function rewriteDynamicImports(source) {
|
|
25
|
+
return source.replace(UNBUNDLABLE_IMPORT, HOST_IMPORT);
|
|
26
|
+
}
|
|
27
|
+
var HOST_IMPORT = '(globalThis.__import || (function (s) { return Promise.reject(new Error("cannot import " + s)); }))(';
|
|
28
|
+
function adapter(options = {}) {
|
|
29
|
+
const out = options.out ?? "build";
|
|
30
|
+
const fallback = options.fallback ?? "404.html";
|
|
31
|
+
const target = options.target ?? "es2017";
|
|
32
|
+
return {
|
|
33
|
+
name: ADAPTER_NAME,
|
|
34
|
+
async adapt(builder) {
|
|
35
|
+
let esbuild;
|
|
36
|
+
try {
|
|
37
|
+
esbuild = await import("esbuild");
|
|
38
|
+
} catch {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`${ADAPTER_NAME} bundles the server half with esbuild, which this project does not have. Install it (\`npm i -D esbuild\`) and build again.`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
builder.rimraf(out);
|
|
44
|
+
builder.writeClient(out);
|
|
45
|
+
const prerendered = builder.writePrerendered(out);
|
|
46
|
+
if (fallback !== false) {
|
|
47
|
+
const browserRendered = builder.routes.filter((r) => r.prerender !== true && r.page.methods.length > 0).map((r) => r.id);
|
|
48
|
+
if (!prerendered.includes(fallback)) {
|
|
49
|
+
await builder.generateFallback(`${out}/${fallback}`);
|
|
50
|
+
} else if (browserRendered.length > 0) {
|
|
51
|
+
builder.rimraf(`${out}/${fallback}`);
|
|
52
|
+
await builder.generateFallback(`${out}/${fallback}`);
|
|
53
|
+
builder.log.warn(
|
|
54
|
+
`${ADAPTER_NAME}: wrote the app shell over the prerendered ${fallback}, so a host that serves files only boots the routes that are not prerendered (${browserRendered.join(", ")}). An unknown path still answers 404 there, and renders +error.svelte.`
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
builder.log.minor(`${ADAPTER_NAME}: every page route is prerendered, so the prerendered ${fallback} is kept.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const tmp = builder.getBuildDirectory("xanosdk-sveltekit");
|
|
61
|
+
builder.rimraf(tmp);
|
|
62
|
+
builder.mkdirp(tmp);
|
|
63
|
+
builder.writeServer(`${tmp}/server`);
|
|
64
|
+
writeFileSync(
|
|
65
|
+
`${tmp}/manifest.js`,
|
|
66
|
+
`export const manifest = ${builder.generateManifest({ relativePath: "./server" })};
|
|
67
|
+
`
|
|
68
|
+
);
|
|
69
|
+
writeFileSync(`${tmp}/entry.js`, ENTRY);
|
|
70
|
+
const result = await esbuild.build({
|
|
71
|
+
plugins: [
|
|
72
|
+
{
|
|
73
|
+
name: "xanosdk-no-dynamic-import",
|
|
74
|
+
setup(build) {
|
|
75
|
+
build.onLoad({ filter: /\.js$/ }, (args) => ({
|
|
76
|
+
contents: rewriteDynamicImports(readFileSync(args.path, "utf8")),
|
|
77
|
+
loader: "js"
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
// Absolute, and with the working directory named: esbuild's service
|
|
83
|
+
// process keeps the one it started in, which a later build in the same
|
|
84
|
+
// process (a second app, a test) does not share.
|
|
85
|
+
entryPoints: [resolve(tmp, "entry.js")],
|
|
86
|
+
absWorkingDir: process.cwd(),
|
|
87
|
+
bundle: true,
|
|
88
|
+
format: "iife",
|
|
89
|
+
platform: "neutral",
|
|
90
|
+
mainFields: ["module", "main"],
|
|
91
|
+
conditions: ["worker", "browser", "import"],
|
|
92
|
+
target,
|
|
93
|
+
outfile: resolve(out, SERVER_BUNDLE),
|
|
94
|
+
metafile: true,
|
|
95
|
+
logLevel: "warning"
|
|
96
|
+
});
|
|
97
|
+
const bytes = Object.values(result.metafile.outputs).reduce((n, o) => n + o.bytes, 0);
|
|
98
|
+
builder.log.minor(`server bundle: ${out}/${SERVER_BUNDLE} (${bytes} bytes, ${target})`);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
SERVER_BUNDLE,
|
|
104
|
+
SERVER_DIR,
|
|
105
|
+
UNBUNDLABLE_IMPORT,
|
|
106
|
+
adapter as default,
|
|
107
|
+
rewriteDynamicImports
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=sveltekit.js.map
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import {
|
|
2
|
+
discoverToolchainPlugins
|
|
3
|
+
} from "./chunk-4Q2GN7NW.js";
|
|
4
|
+
import {
|
|
5
|
+
contributionOutcomes,
|
|
6
|
+
recordedConfig,
|
|
7
|
+
runPluginQuestionnaire
|
|
8
|
+
} from "./chunk-6ZGJCBZS.js";
|
|
9
|
+
import {
|
|
10
|
+
pluginPrompter
|
|
11
|
+
} from "./chunk-IDOTCMDV.js";
|
|
12
|
+
import {
|
|
13
|
+
flagFor,
|
|
14
|
+
hostHelpTarget
|
|
15
|
+
} from "./chunk-H5C7MBCR.js";
|
|
16
|
+
import "./chunk-65HWOMGV.js";
|
|
17
|
+
import "./chunk-2TFRR6JV.js";
|
|
18
|
+
import {
|
|
19
|
+
SDK_PACKAGE,
|
|
20
|
+
declaredDependencies,
|
|
21
|
+
writeToolchainConfig
|
|
22
|
+
} from "./chunk-JTUKLCXS.js";
|
|
23
|
+
import "./chunk-4KHEMC32.js";
|
|
24
|
+
import "./chunk-3LDULPRE.js";
|
|
25
|
+
import {
|
|
26
|
+
assertWritable,
|
|
27
|
+
atomicWrite
|
|
28
|
+
} from "./chunk-LLNZGEFK.js";
|
|
29
|
+
import {
|
|
30
|
+
HASH_DIALECT,
|
|
31
|
+
blockPackages,
|
|
32
|
+
composeBlock,
|
|
33
|
+
findBlock,
|
|
34
|
+
gitattributesSpec,
|
|
35
|
+
linesOutsideBlocks,
|
|
36
|
+
removeBlock,
|
|
37
|
+
upsertBlock
|
|
38
|
+
} from "./chunk-DGWHAVRG.js";
|
|
39
|
+
import {
|
|
40
|
+
UsageError,
|
|
41
|
+
warn
|
|
42
|
+
} from "./chunk-PTHVMXZI.js";
|
|
43
|
+
import "./chunk-UTI5G6OJ.js";
|
|
44
|
+
import "./chunk-2EZ3ZJZZ.js";
|
|
45
|
+
import "./chunk-5ZSO4T2G.js";
|
|
46
|
+
import "./chunk-TFFGOFVZ.js";
|
|
47
|
+
import {
|
|
48
|
+
withArticle
|
|
49
|
+
} from "./chunk-36JUQZVQ.js";
|
|
50
|
+
import "./chunk-PZ5AY32C.js";
|
|
51
|
+
|
|
52
|
+
// src/emit/sync-contributions.ts
|
|
53
|
+
import { existsSync, readFileSync, rmSync } from "fs";
|
|
54
|
+
import { join } from "path";
|
|
55
|
+
async function syncContributions(projectDir, opts) {
|
|
56
|
+
if (opts.ask === "package" && (opts.pkg ?? "") === "") {
|
|
57
|
+
throw new Error(
|
|
58
|
+
'syncContributions({ ask: "package" }) needs the package to re-ask'
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const manifestPath = join(projectDir, "package.json");
|
|
62
|
+
const raw = readManifestText(manifestPath);
|
|
63
|
+
const manifest = parseManifest(manifestPath, raw);
|
|
64
|
+
const block = readWritableBlock(manifestPath, manifest);
|
|
65
|
+
const depended = new Set(declaredDependencies(manifest));
|
|
66
|
+
const gitattributesPath = join(projectDir, ".gitattributes");
|
|
67
|
+
const before = existsSync(gitattributesPath) ? readFileSync(gitattributesPath, "utf8") : null;
|
|
68
|
+
const removed = [
|
|
69
|
+
.../* @__PURE__ */ new Set([
|
|
70
|
+
...Object.keys(block),
|
|
71
|
+
...blockPackages(before ?? "", HASH_DIALECT)
|
|
72
|
+
])
|
|
73
|
+
].filter((pkg) => pkg !== SDK_PACKAGE && !depended.has(pkg));
|
|
74
|
+
const { loaded, untouchable, configured, recomputable, sources, flags, outcomes } = await interrogate(projectDir, opts);
|
|
75
|
+
const decided = {
|
|
76
|
+
dropped: removed,
|
|
77
|
+
enable: opts.enable ?? [],
|
|
78
|
+
outcomes
|
|
79
|
+
};
|
|
80
|
+
const base = { text: before, block };
|
|
81
|
+
const projected = applyDecisions(base, decided);
|
|
82
|
+
const after = projected.state.text;
|
|
83
|
+
const actions = projected.actions;
|
|
84
|
+
warnDuplicated(base, outcomes);
|
|
85
|
+
const applied = opts.apply ? applyToDisk({ manifestPath, gitattributesPath, projectDir }, decided) : { written: [], changed: differs(base, projected.state) };
|
|
86
|
+
const { written, changed } = applied;
|
|
87
|
+
const modules = describeRun({
|
|
88
|
+
loaded,
|
|
89
|
+
actions,
|
|
90
|
+
dropped: removed,
|
|
91
|
+
block,
|
|
92
|
+
projected: projected.state,
|
|
93
|
+
before,
|
|
94
|
+
after,
|
|
95
|
+
configured,
|
|
96
|
+
recomputable,
|
|
97
|
+
untouchable,
|
|
98
|
+
sources,
|
|
99
|
+
flags
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
projectDir,
|
|
103
|
+
modules,
|
|
104
|
+
// DERIVED from `modules`, not accumulated alongside it. Both were built in
|
|
105
|
+
// the same loop that built `modules` and were exact projections of it, with
|
|
106
|
+
// nothing enforcing the agreement — so a later edit to one arm of the
|
|
107
|
+
// classification could leave a package reported `unconfigured` in the list
|
|
108
|
+
// and something else in the table. Computed from the table, they cannot.
|
|
109
|
+
unconfigured: packagesWhere(modules, "unconfigured"),
|
|
110
|
+
removed: packagesWhere(modules, "removed"),
|
|
111
|
+
written,
|
|
112
|
+
changed
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function interrogate(projectDir, opts) {
|
|
116
|
+
const { loaded, skipped, unconfigured: neverConfigured } = await discoverToolchainPlugins(projectDir, {
|
|
117
|
+
frozen: false,
|
|
118
|
+
configuring: true,
|
|
119
|
+
// `enable` is applied HERE and nowhere else — folding the pending flag
|
|
120
|
+
// into what discovery reads is what lets the re-enabling land inside the
|
|
121
|
+
// reconciler's single write. See `SyncOptions.enable`.
|
|
122
|
+
...opts.enable === void 0 || opts.enable.length === 0 ? {} : {
|
|
123
|
+
configOverride: Object.fromEntries(
|
|
124
|
+
opts.enable.map((pkg) => [pkg, { enabled: true }])
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const untouchable = /* @__PURE__ */ new Set([
|
|
129
|
+
...skipped.map((s) => s.pkg),
|
|
130
|
+
...loaded.map((p) => p.pkg)
|
|
131
|
+
]);
|
|
132
|
+
const neverConfiguredSet = new Set(neverConfigured);
|
|
133
|
+
const configured = new Set(
|
|
134
|
+
loaded.map((p) => p.pkg).filter((pkg) => !neverConfiguredSet.has(pkg))
|
|
135
|
+
);
|
|
136
|
+
const askSet = whoToAsk(opts, loaded, configured);
|
|
137
|
+
const actionable = loaded.filter(
|
|
138
|
+
(p) => configured.has(p.pkg) || askSet.has(p.pkg)
|
|
139
|
+
);
|
|
140
|
+
const { answers, sources, flags, prior } = await runPluginQuestionnaire(actionable, {
|
|
141
|
+
host: opts.host,
|
|
142
|
+
unknownFlags: opts.unknownFlags ?? [],
|
|
143
|
+
prompter: gate(
|
|
144
|
+
askSet,
|
|
145
|
+
opts.prompter ?? pluginPrompter({ json: opts.json })
|
|
146
|
+
)
|
|
147
|
+
});
|
|
148
|
+
const recomputable = new Set(
|
|
149
|
+
actionable.filter(
|
|
150
|
+
(p) => askSet.has(p.pkg) || (p.plugin.questions?.length ?? 0) === 0 || prior[p.pkg]
|
|
151
|
+
).map((p) => p.pkg)
|
|
152
|
+
);
|
|
153
|
+
assertNoFlagsForCarried(actionable, recomputable, sources, opts.host);
|
|
154
|
+
const outcomes = contributionOutcomes(
|
|
155
|
+
actionable.filter((p) => recomputable.has(p.pkg)),
|
|
156
|
+
answers,
|
|
157
|
+
opts.host
|
|
158
|
+
);
|
|
159
|
+
return { loaded, untouchable, configured, recomputable, sources, flags, outcomes };
|
|
160
|
+
}
|
|
161
|
+
function applyToDisk(paths, decisions) {
|
|
162
|
+
const freshManifest = parseManifest(
|
|
163
|
+
paths.manifestPath,
|
|
164
|
+
readManifestText(paths.manifestPath)
|
|
165
|
+
);
|
|
166
|
+
const fresh = {
|
|
167
|
+
text: existsSync(paths.gitattributesPath) ? readFileSync(paths.gitattributesPath, "utf8") : null,
|
|
168
|
+
block: readWritableBlock(paths.manifestPath, freshManifest)
|
|
169
|
+
};
|
|
170
|
+
const depended = new Set(declaredDependencies(freshManifest));
|
|
171
|
+
const stillGone = decisions.dropped.filter((pkg) => !depended.has(pkg));
|
|
172
|
+
const final = applyDecisions(fresh, { ...decisions, dropped: stillGone }).state;
|
|
173
|
+
const written = [];
|
|
174
|
+
refuseUnwritable(paths.manifestPath);
|
|
175
|
+
refuseUnwritable(paths.gitattributesPath);
|
|
176
|
+
if (textChanged(fresh.text, final.text) && final.text !== null) {
|
|
177
|
+
if (final.text === "" && fresh.text !== null && fresh.text !== "") {
|
|
178
|
+
rmSync(paths.gitattributesPath, { force: true });
|
|
179
|
+
} else {
|
|
180
|
+
write(paths.gitattributesPath, final.text);
|
|
181
|
+
}
|
|
182
|
+
written.push(paths.gitattributesPath);
|
|
183
|
+
}
|
|
184
|
+
if (!sameBlock(fresh.block, final.block)) {
|
|
185
|
+
try {
|
|
186
|
+
if (writeToolchainConfig(paths.projectDir, final.block))
|
|
187
|
+
written.push(paths.manifestPath);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
throw writeFailure(paths.manifestPath, error, written.length > 0);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return { written, changed: differs(fresh, final) };
|
|
193
|
+
}
|
|
194
|
+
function packagesWhere(modules, action) {
|
|
195
|
+
return modules.filter((m) => m.action === action).map((m) => m.pkg);
|
|
196
|
+
}
|
|
197
|
+
function describeRun(ctx) {
|
|
198
|
+
const nextBlock = ctx.projected.block;
|
|
199
|
+
const modules = [];
|
|
200
|
+
for (const p of ctx.loaded) {
|
|
201
|
+
const action = ctx.actions.get(p.pkg) ?? classify(p, {
|
|
202
|
+
configured: ctx.configured,
|
|
203
|
+
nextBlock,
|
|
204
|
+
recomputable: ctx.recomputable
|
|
205
|
+
});
|
|
206
|
+
modules.push({
|
|
207
|
+
pkg: p.pkg,
|
|
208
|
+
action: action === "configured" && !changedFor(p.pkg, ctx.block, nextBlock, ctx.before, ctx.after) ? "unchanged" : action,
|
|
209
|
+
...ctx.sources[p.pkg] === void 0 ? {} : { sources: ctx.sources[p.pkg] },
|
|
210
|
+
...ctx.flags[p.pkg] === void 0 ? {} : { flags: ctx.flags[p.pkg] },
|
|
211
|
+
...nextBlock[p.pkg] === void 0 ? {} : { config: nextBlock[p.pkg] }
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
for (const pkg of ctx.dropped) modules.push({ pkg, action: "removed" });
|
|
215
|
+
for (const [pkg, config] of Object.entries(ctx.block)) {
|
|
216
|
+
if (pkg === SDK_PACKAGE || ctx.untouchable.has(pkg) || ctx.dropped.includes(pkg)) continue;
|
|
217
|
+
if (config?.enabled === false)
|
|
218
|
+
modules.push({ pkg, action: "disabled" });
|
|
219
|
+
}
|
|
220
|
+
return modules;
|
|
221
|
+
}
|
|
222
|
+
function applyDecisions(base, decisions) {
|
|
223
|
+
let text = base.text;
|
|
224
|
+
const block = { ...base.block };
|
|
225
|
+
for (const pkg of decisions.dropped) {
|
|
226
|
+
delete block[pkg];
|
|
227
|
+
text = removeBlock(text, gitattributesSpec(pkg)).text;
|
|
228
|
+
}
|
|
229
|
+
for (const pkg of decisions.enable) {
|
|
230
|
+
const stored = block[pkg];
|
|
231
|
+
block[pkg] = {
|
|
232
|
+
...typeof stored === "object" && stored !== null && !Array.isArray(stored) ? stored : {},
|
|
233
|
+
enabled: true
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const actions = /* @__PURE__ */ new Map();
|
|
237
|
+
for (const outcome of decisions.outcomes) {
|
|
238
|
+
if (outcome.status === "failed") {
|
|
239
|
+
actions.set(outcome.pkg, "failed");
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (outcome.status === "contributed") {
|
|
243
|
+
const spec = gitattributesSpec(outcome.pkg);
|
|
244
|
+
const lines = outcome.parts?.gitattributes ?? [];
|
|
245
|
+
text = upsertBlock(text, spec, composeBlock(spec, lines, outcome.version)).text;
|
|
246
|
+
}
|
|
247
|
+
const record = recordedConfig(outcome, block[outcome.pkg]);
|
|
248
|
+
if (record !== void 0) block[outcome.pkg] = record;
|
|
249
|
+
}
|
|
250
|
+
return { state: { text, block }, actions };
|
|
251
|
+
}
|
|
252
|
+
function refuseUnwritable(path) {
|
|
253
|
+
try {
|
|
254
|
+
assertWritable(path);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
throw writeFailure(path, error);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function textChanged(before, after) {
|
|
260
|
+
if (before === null) return (after ?? "").trim() !== "";
|
|
261
|
+
return after !== null && after !== before;
|
|
262
|
+
}
|
|
263
|
+
function sameBlock(a, b) {
|
|
264
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
265
|
+
}
|
|
266
|
+
function differs(before, after) {
|
|
267
|
+
return textChanged(before.text, after.text) || !sameBlock(before.block, after.block);
|
|
268
|
+
}
|
|
269
|
+
function warnDuplicated(base, outcomes) {
|
|
270
|
+
if (base.text === null) return;
|
|
271
|
+
const unmarked = new Set(linesOutsideBlocks(base.text, HASH_DIALECT));
|
|
272
|
+
for (const outcome of outcomes) {
|
|
273
|
+
if (outcome.status !== "contributed") continue;
|
|
274
|
+
warnIfDuplicated(base.text, outcome.pkg, outcome.parts?.gitattributes ?? [], unmarked);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function whoToAsk(opts, loaded, configured) {
|
|
278
|
+
if (opts.ask === "none") return /* @__PURE__ */ new Set();
|
|
279
|
+
if (opts.ask === "package") {
|
|
280
|
+
return new Set(loaded.filter((p) => p.pkg === opts.pkg).map((p) => p.pkg));
|
|
281
|
+
}
|
|
282
|
+
return new Set(
|
|
283
|
+
loaded.filter((p) => !configured.has(p.pkg)).map((p) => p.pkg)
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function gate(askSet, inner) {
|
|
287
|
+
return {
|
|
288
|
+
ask: (pkg, question, fallback) => askSet.has(pkg) ? inner.ask(pkg, question, fallback) : Promise.resolve(void 0)
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function warnIfDuplicated(text, pkg, lines, outside) {
|
|
292
|
+
if (text === null || lines.length === 0) return;
|
|
293
|
+
if (findBlock(text, gitattributesSpec(pkg)) !== null) return;
|
|
294
|
+
const already = lines.map((l) => l.trim()).filter((l) => l !== "" && outside.has(l));
|
|
295
|
+
if (already.length === 0) return;
|
|
296
|
+
warn(
|
|
297
|
+
`.gitattributes already carries ${already.length === 1 ? "a rule" : "rules"} ${pkg} contributes, outside any managed block.`,
|
|
298
|
+
"module.gitattributes-conflict",
|
|
299
|
+
[
|
|
300
|
+
...already,
|
|
301
|
+
`A block for ${pkg} was added anyway \u2014 the SDK can only rewrite the span it marks. Delete the unmarked ${already.length === 1 ? "copy" : "copies"} by hand.`
|
|
302
|
+
]
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
function classify(p, ctx) {
|
|
306
|
+
if (ctx.recomputable.has(p.pkg)) return "configured";
|
|
307
|
+
if (ctx.configured.has(p.pkg)) return "carried";
|
|
308
|
+
return "unconfigured";
|
|
309
|
+
}
|
|
310
|
+
function changedFor(pkg, block, nextBlock, before, after) {
|
|
311
|
+
if (JSON.stringify(block[pkg]) !== JSON.stringify(nextBlock[pkg]))
|
|
312
|
+
return true;
|
|
313
|
+
return blockText(before, pkg) !== blockText(after, pkg);
|
|
314
|
+
}
|
|
315
|
+
function blockText(text, pkg) {
|
|
316
|
+
if (text === null) return null;
|
|
317
|
+
try {
|
|
318
|
+
return findBlock(text, gitattributesSpec(pkg))?.text ?? null;
|
|
319
|
+
} catch {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function readManifestText(path) {
|
|
324
|
+
if (!existsSync(path)) {
|
|
325
|
+
throw new UsageError(
|
|
326
|
+
`${path} does not exist, so there is no project here to reconcile.`,
|
|
327
|
+
{
|
|
328
|
+
suggestion: "Run this from a project directory, or scaffold one with `xanosdk init`."
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
return readFileSync(path, "utf8");
|
|
333
|
+
}
|
|
334
|
+
function parseManifest(path, raw) {
|
|
335
|
+
let parsed;
|
|
336
|
+
try {
|
|
337
|
+
parsed = JSON.parse(raw);
|
|
338
|
+
} catch (error) {
|
|
339
|
+
throw new UsageError(
|
|
340
|
+
`${path} is not valid JSON, so this project's toolchain modules cannot be reconciled: ${error instanceof Error ? error.message : String(error)}`,
|
|
341
|
+
{ suggestion: "Repair the file and re-run. Nothing was written." }
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
345
|
+
throw new UsageError(
|
|
346
|
+
`${path} is not a JSON object, so it is not a usable package manifest.`,
|
|
347
|
+
{
|
|
348
|
+
suggestion: "Repair the file and re-run. Nothing was written."
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
return parsed;
|
|
353
|
+
}
|
|
354
|
+
function readWritableBlock(path, manifest) {
|
|
355
|
+
const block = manifest["xanosdk"];
|
|
356
|
+
if (block === void 0) return {};
|
|
357
|
+
if (typeof block !== "object" || block === null || Array.isArray(block)) {
|
|
358
|
+
throw new UsageError(
|
|
359
|
+
`the "xanosdk" key in ${path} is ${describe(block)} where a map from package name to that module's settings is expected, so this run would have written over it.`,
|
|
360
|
+
{
|
|
361
|
+
suggestion: "Repair or delete the key and re-run. Nothing was written."
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
for (const [pkg, own] of Object.entries(block)) {
|
|
366
|
+
if (typeof own !== "object" || own === null || Array.isArray(own)) {
|
|
367
|
+
throw new UsageError(
|
|
368
|
+
`the "xanosdk" entry for ${pkg} in ${path} is ${describe(own)} where that module's settings object is expected, so this run would have written over it.`,
|
|
369
|
+
{
|
|
370
|
+
suggestion: "Repair or delete the entry and re-run. Nothing was written."
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return block;
|
|
376
|
+
}
|
|
377
|
+
function describe(value) {
|
|
378
|
+
if (value === null) return "null";
|
|
379
|
+
if (Array.isArray(value)) return "an array";
|
|
380
|
+
return withArticle(typeof value);
|
|
381
|
+
}
|
|
382
|
+
function write(path, text) {
|
|
383
|
+
try {
|
|
384
|
+
assertWritable(path);
|
|
385
|
+
atomicWrite(path, text);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
throw writeFailure(path, error);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function writeFailure(path, error, partial = false) {
|
|
391
|
+
return new UsageError(
|
|
392
|
+
`${path} could not be written: ${error instanceof Error ? error.message : String(error)}`,
|
|
393
|
+
{
|
|
394
|
+
suggestion: partial ? `Check the file's permissions and re-run. \`.gitattributes\` was already written, but nothing was recorded in package.json \u2014 so re-running re-asks and completes the job, and the block it writes is the one already there.` : "Check the file's permissions and re-run."
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
function assertNoFlagsForCarried(actionable, recomputable, sources, host) {
|
|
399
|
+
for (const p of actionable) {
|
|
400
|
+
if (recomputable.has(p.pkg)) continue;
|
|
401
|
+
const names = Object.entries(sources[p.pkg] ?? {}).filter(([, source]) => source === "flag").flatMap(([id]) => (p.plugin.questions ?? []).filter((q) => q.id === id)).map((q) => `\`--${flagFor(q)}\``);
|
|
402
|
+
if (names.length === 0) continue;
|
|
403
|
+
throw new UsageError(
|
|
404
|
+
`${names.join(", ")} answers a question for ${p.pkg}, but this run does not re-derive that module's contributions \u2014 it has no way to read its stored settings back, so it carries them forward untouched and the flag would have changed nothing.`,
|
|
405
|
+
{
|
|
406
|
+
helpFor: hostHelpTarget(host),
|
|
407
|
+
suggestion: `Run \`xanosdk marketplace reinstall ${p.pkg}\` with the flag: that is the verb that re-asks one module and rewrites what it contributes.`
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
export {
|
|
413
|
+
syncContributions
|
|
414
|
+
};
|
|
415
|
+
//# sourceMappingURL=sync-contributions-UCEROO26.js.map
|