@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,241 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HEADER_BREAK,
|
|
3
|
+
HEADER_NAME,
|
|
4
|
+
generated,
|
|
5
|
+
literalText
|
|
6
|
+
} from "./chunk-YGZHHAAB.js";
|
|
7
|
+
import {
|
|
8
|
+
fl
|
|
9
|
+
} from "./chunk-6HO3NCSJ.js";
|
|
10
|
+
import {
|
|
11
|
+
c,
|
|
12
|
+
resp,
|
|
13
|
+
withFilters
|
|
14
|
+
} from "./chunk-OXA6PSZT.js";
|
|
15
|
+
import {
|
|
16
|
+
describeEntry,
|
|
17
|
+
isTaggedArg
|
|
18
|
+
} from "./chunk-CIMQZRRE.js";
|
|
19
|
+
|
|
20
|
+
// src/statements/respond.ts
|
|
21
|
+
var REDIRECT_STATUSES = [301, 302, 303, 307];
|
|
22
|
+
function assertHeaderValue(helper, field, v) {
|
|
23
|
+
if (typeof v === "string" || isTaggedArg(v)) return;
|
|
24
|
+
throw new Error(`${helper}: ${field} must be a string or a tagged value (\`ref()\`, \`inp()\`, \u2026) \u2014 got ${describeEntry(v)}.`);
|
|
25
|
+
}
|
|
26
|
+
function assertNoHeaderBreak(helper, field, v) {
|
|
27
|
+
const literal = literalText(v);
|
|
28
|
+
if (literal === void 0 || !HEADER_BREAK.test(literal)) return;
|
|
29
|
+
throw new Error(
|
|
30
|
+
`${helper}: ${field} ${JSON.stringify(literal)} contains a newline or NUL, which would splice a second header into the response. Strip it.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
var setHeader = (value, duplicates) => generated.util.set_header(
|
|
34
|
+
duplicates === void 0 ? { value } : { value, duplicates }
|
|
35
|
+
);
|
|
36
|
+
var IGNORED_STATUS = {
|
|
37
|
+
102: "an interim status a final response cannot carry \u2014 drop it",
|
|
38
|
+
103: "an interim status a final response cannot carry \u2014 drop it",
|
|
39
|
+
308: "use 301 (Moved Permanently), which is honored; 307 is the temporary equivalent",
|
|
40
|
+
425: "use 429 (Too Many Requests) or 400, both honored",
|
|
41
|
+
451: "use 403 (Forbidden), which is honored"
|
|
42
|
+
};
|
|
43
|
+
var UNPARSEABLE_STATUS = {
|
|
44
|
+
100: "an informational status is not a final response; an HTTP client errors on it",
|
|
45
|
+
101: "a protocol switch is not something a stack can answer; an HTTP client errors on it",
|
|
46
|
+
407: "proxy authentication needs headers this surface cannot supply; an HTTP client errors on it"
|
|
47
|
+
};
|
|
48
|
+
function assertStatus(code) {
|
|
49
|
+
if (!Number.isInteger(code) || code < 100 || code > 599) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`respond.status(${code}): not an HTTP status code. Pass an integer between 100 and 599.`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const unparseable = Object.hasOwn(UNPARSEABLE_STATUS, code) ? UNPARSEABLE_STATUS[code] : void 0;
|
|
55
|
+
if (unparseable !== void 0) {
|
|
56
|
+
throw new Error(`respond.status(${code}) is refused: ${unparseable}.`);
|
|
57
|
+
}
|
|
58
|
+
const ignored = Object.hasOwn(IGNORED_STATUS, code) ? IGNORED_STATUS[code] : void 0;
|
|
59
|
+
if (ignored !== void 0) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`respond.status(${code}) is refused: the platform writes the header and does not act on it, so the response is 200 \u2014 measured live, with nothing reported anywhere. Instead, ${ignored}.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var respond = {
|
|
66
|
+
/**
|
|
67
|
+
* Answer with `code` instead of 200.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* stack: [s.db.add({ table: notes, row, as: "note" }), respond.status(201)],
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Position does not matter — the header is written while the stack runs and
|
|
74
|
+
* the body is serialized afterwards, so this works before or after the
|
|
75
|
+
* statement that builds the response.
|
|
76
|
+
*
|
|
77
|
+
* ⚠ A `204` answers with an EMPTY body whatever the def's `response` says:
|
|
78
|
+
* that is HTTP, not this helper. Do not pair it with a response a client
|
|
79
|
+
* needs to read.
|
|
80
|
+
*
|
|
81
|
+
* See the module note for the codes this refuses and why.
|
|
82
|
+
*/
|
|
83
|
+
status: (code) => {
|
|
84
|
+
assertStatus(code);
|
|
85
|
+
return setHeader(c.text(`HTTP/1.1 ${code}`));
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* Redirect to `url` — the status line plus the `Location` header, as a
|
|
89
|
+
* fixed-arity tuple to spread:
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* stack: [s.set_var("target", ref("row.url")), ...respond.redirect(ref("target"))],
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* `url` takes a literal or any `Value` (a `ref`, an `inp`, a filtered chain);
|
|
96
|
+
* a computed one is concatenated onto the header at request time.
|
|
97
|
+
*
|
|
98
|
+
* Defaults to **302** (temporary, and a client may switch the method to GET).
|
|
99
|
+
* `301` is the permanent form, `307` the temporary one that PRESERVES the
|
|
100
|
+
* method, and `303` forces GET. **`308` is not offered** — the platform
|
|
101
|
+
* ignores it and answers 200, measured live.
|
|
102
|
+
*
|
|
103
|
+
* ⚠ A `Location` header alone does NOT redirect: without the status line the
|
|
104
|
+
* response is a 200 carrying a header no client acts on. That is the whole
|
|
105
|
+
* reason this emits both.
|
|
106
|
+
*/
|
|
107
|
+
redirect: (url, opts = {}) => {
|
|
108
|
+
assertHeaderValue("respond.redirect", "url", url);
|
|
109
|
+
assertNoHeaderBreak("respond.redirect", "url", url);
|
|
110
|
+
opts = opts ?? {};
|
|
111
|
+
if (opts.status !== void 0 && !REDIRECT_STATUSES.includes(opts.status)) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`respond.redirect: status ${JSON.stringify(opts.status)} is not a redirect \u2014 use ${REDIRECT_STATUSES.join(", ")} (302 when omitted). 308 is not offered: the platform answers 200 for it. A non-3xx status with a Location header redirects nothing; for another status use respond.status().`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
const location = typeof url === "string" ? c.text(`Location: ${url}`) : withFilters(c.text("Location: "), fl.concat(url));
|
|
117
|
+
return [respond.status(opts.status ?? 302), setHeader(location)];
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* Add a response header, `name` and `value` given separately.
|
|
121
|
+
*
|
|
122
|
+
* The underlying statement takes ONE string — `"X-Request-Id: abc"` — so a
|
|
123
|
+
* computed value has to be concatenated onto the name by hand. This does that,
|
|
124
|
+
* and keeps a literal a literal.
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* respond.header("Cache-Control", "public, max-age=60"),
|
|
128
|
+
* respond.header("X-Request-Id", ref("id")),
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
header: (name, value, opts = {}) => {
|
|
132
|
+
if (typeof name !== "string") {
|
|
133
|
+
throw new Error(`respond.header: the header name must be a string \u2014 got ${describeEntry(name)}.`);
|
|
134
|
+
}
|
|
135
|
+
assertHeaderValue("respond.header", "value", value);
|
|
136
|
+
opts = opts ?? {};
|
|
137
|
+
if (opts.duplicates !== void 0 && opts.duplicates !== "replace" && opts.duplicates !== "append") {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`respond.header: duplicates accepts only "replace" | "append" \u2014 got ${typeof opts.duplicates === "string" ? JSON.stringify(opts.duplicates) : describeEntry(opts.duplicates)}.`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (!HEADER_NAME.test(name)) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
`respond.header: ${JSON.stringify(name)} is not a header name \u2014 use the token charset (letters, digits and !#$%&'*+-.^_\`|~), with no whitespace and no colon (the colon is added for you). Pass the name and the value separately: respond.header("X-Request-Id", ref("id")).`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
assertNoHeaderBreak("respond.header", "value", value);
|
|
148
|
+
const line = typeof value === "string" ? c.text(`${name}: ${value}`) : withFilters(c.text(`${name}: `), fl.concat(value));
|
|
149
|
+
return setHeader(line, opts.duplicates);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/values/expect.ts
|
|
154
|
+
var TEST_EXPECT_TYPES = [
|
|
155
|
+
"to_be_defined",
|
|
156
|
+
"to_be_empty",
|
|
157
|
+
"to_be_false",
|
|
158
|
+
"to_be_greater_than",
|
|
159
|
+
"to_be_in_the_future",
|
|
160
|
+
"to_be_in_the_past",
|
|
161
|
+
"to_be_less_than",
|
|
162
|
+
"to_be_null",
|
|
163
|
+
"to_be_true",
|
|
164
|
+
"to_be_within",
|
|
165
|
+
"to_contain",
|
|
166
|
+
"to_end_with",
|
|
167
|
+
"to_equal",
|
|
168
|
+
"to_match",
|
|
169
|
+
"to_not_be_defined",
|
|
170
|
+
"to_not_be_null",
|
|
171
|
+
"to_not_equal",
|
|
172
|
+
"to_start_with",
|
|
173
|
+
"to_throw"
|
|
174
|
+
];
|
|
175
|
+
function mk(type, ...vars) {
|
|
176
|
+
return { type, vars };
|
|
177
|
+
}
|
|
178
|
+
var expect = {
|
|
179
|
+
/** The subject is set (not undefined). */
|
|
180
|
+
to_be_defined: (subject) => mk("to_be_defined", subject),
|
|
181
|
+
/** The subject is undefined. */
|
|
182
|
+
to_not_be_defined: (subject) => mk("to_not_be_defined", subject),
|
|
183
|
+
/** The subject is empty — `""`, `[]`, `{}`, `0`, or null. */
|
|
184
|
+
to_be_empty: (subject) => mk("to_be_empty", subject),
|
|
185
|
+
/** The subject is `null`. */
|
|
186
|
+
to_be_null: (subject) => mk("to_be_null", subject),
|
|
187
|
+
/** The subject is not `null`. */
|
|
188
|
+
to_not_be_null: (subject) => mk("to_not_be_null", subject),
|
|
189
|
+
/** The subject is boolean true. */
|
|
190
|
+
to_be_true: (subject) => mk("to_be_true", subject),
|
|
191
|
+
/** The subject is boolean false. */
|
|
192
|
+
to_be_false: (subject) => mk("to_be_false", subject),
|
|
193
|
+
/** The subject is a timestamp later than now. */
|
|
194
|
+
to_be_in_the_future: (subject) => mk("to_be_in_the_future", subject),
|
|
195
|
+
/** The subject is a timestamp earlier than now. */
|
|
196
|
+
to_be_in_the_past: (subject) => mk("to_be_in_the_past", subject),
|
|
197
|
+
/** `subject === value`. */
|
|
198
|
+
to_equal: (subject, value) => mk("to_equal", subject, value),
|
|
199
|
+
/** `subject !== value`. */
|
|
200
|
+
to_not_equal: (subject, value) => mk("to_not_equal", subject, value),
|
|
201
|
+
/** `subject > value`, both read as numbers. */
|
|
202
|
+
to_be_greater_than: (subject, value) => mk("to_be_greater_than", subject, value),
|
|
203
|
+
/** `subject < value`, both read as numbers. */
|
|
204
|
+
to_be_less_than: (subject, value) => mk("to_be_less_than", subject, value),
|
|
205
|
+
/** A list subject contains the item; a text subject contains the substring. */
|
|
206
|
+
to_contain: (subject, item) => mk("to_contain", subject, item),
|
|
207
|
+
/** The subject, as text, starts with `prefix`. */
|
|
208
|
+
to_start_with: (subject, prefix) => mk("to_start_with", subject, prefix),
|
|
209
|
+
/** The subject, as text, ends with `suffix`. */
|
|
210
|
+
to_end_with: (subject, suffix) => mk("to_end_with", subject, suffix),
|
|
211
|
+
/**
|
|
212
|
+
* The subject matches a regular expression. `pattern` is a PCRE pattern
|
|
213
|
+
* INCLUDING its delimiters — build it with `c.regex(...)` rather than by hand;
|
|
214
|
+
* a bare `"^a"` is not a runnable pattern and the engine's match silently
|
|
215
|
+
* fails rather than erroring.
|
|
216
|
+
*/
|
|
217
|
+
to_match: (subject, pattern) => mk("to_match", subject, pattern),
|
|
218
|
+
/**
|
|
219
|
+
* `min < subject < max`, both bounds EXCLUSIVE and all three read as numbers.
|
|
220
|
+
* A subject equal to either bound fails.
|
|
221
|
+
*/
|
|
222
|
+
to_be_within: (subject, min, max) => mk("to_be_within", subject, min, max),
|
|
223
|
+
/**
|
|
224
|
+
* The run raised an error. Pass `exception` to require that text to appear in
|
|
225
|
+
* the error message (a case-insensitive substring, not an exact match);
|
|
226
|
+
* omit it to accept ANY error.
|
|
227
|
+
*
|
|
228
|
+
* Unlike every other matcher this one takes no subject: the thing under
|
|
229
|
+
* assertion is the run's failure, and the engine stores the response slot as
|
|
230
|
+
* a fixed first var. That is what the editor writes, and it is preserved so
|
|
231
|
+
* an authored test and a pulled one are the same bytes.
|
|
232
|
+
*/
|
|
233
|
+
to_throw: (exception) => mk("to_throw", resp(), exception ?? c.text(""))
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
respond,
|
|
238
|
+
TEST_EXPECT_TYPES,
|
|
239
|
+
expect
|
|
240
|
+
};
|
|
241
|
+
//# sourceMappingURL=chunk-3KZCLN4Z.js.map
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UsageError
|
|
3
|
+
} from "./chunk-PTHVMXZI.js";
|
|
4
|
+
|
|
5
|
+
// src/emit/module-manifest.ts
|
|
6
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
7
|
+
import { gunzipSync } from "zlib";
|
|
8
|
+
import { dirname, join, resolve, sep } from "path";
|
|
9
|
+
import { pathToFileURL } from "url";
|
|
10
|
+
import { createRequire } from "module";
|
|
11
|
+
var MODULE_KINDS = ["workspace", "toolchain"];
|
|
12
|
+
function packageNameOf(specifier) {
|
|
13
|
+
const at = specifier.lastIndexOf("@");
|
|
14
|
+
return at > 0 ? specifier.slice(0, at) : specifier;
|
|
15
|
+
}
|
|
16
|
+
function localPathOf(spec) {
|
|
17
|
+
if (/^file:/i.test(spec)) return spec.slice(5);
|
|
18
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(spec) || spec.startsWith("~")) return void 0;
|
|
19
|
+
if (/^\.{1,2}(\/|$)|^\//.test(spec) || /\.(tgz|tar\.gz)$/i.test(spec)) return spec;
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
function localPackageName(specifier, dir) {
|
|
23
|
+
const path = localPathOf(specifier);
|
|
24
|
+
if (path === void 0) return void 0;
|
|
25
|
+
const abs = resolve(dir, path);
|
|
26
|
+
try {
|
|
27
|
+
const raw = statSync(abs).isFile() ? tarballManifest(readFileSync(abs)) : readFileSync(join(abs, "package.json"), "utf8");
|
|
28
|
+
const name = raw === void 0 ? void 0 : JSON.parse(raw).name;
|
|
29
|
+
if (typeof name === "string" && name !== "") return name;
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
return recordedLocalDependency(dir, abs);
|
|
33
|
+
}
|
|
34
|
+
function recordedLocalDependency(dir, abs) {
|
|
35
|
+
try {
|
|
36
|
+
const manifest = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
37
|
+
for (const block of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
38
|
+
for (const [name, range] of Object.entries(manifest[block] ?? {})) {
|
|
39
|
+
if (typeof range === "string" && /^file:/i.test(range) && resolve(dir, range.slice(5)) === abs) return name;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
function tarballManifest(tgz) {
|
|
47
|
+
const tar = gunzipSync(tgz);
|
|
48
|
+
let longName;
|
|
49
|
+
for (let at = 0; at + 512 <= tar.length; ) {
|
|
50
|
+
const header = tar.subarray(at, at + 512);
|
|
51
|
+
if (header.every((b) => b === 0)) return void 0;
|
|
52
|
+
const field = (start, length) => {
|
|
53
|
+
const raw = header.subarray(start, start + length);
|
|
54
|
+
const end = raw.indexOf(0);
|
|
55
|
+
return raw.subarray(0, end === -1 ? length : end).toString("utf8");
|
|
56
|
+
};
|
|
57
|
+
const size = parseInt(field(124, 12).trim() || "0", 8);
|
|
58
|
+
const type = field(156, 1);
|
|
59
|
+
const prefix = field(345, 155);
|
|
60
|
+
const name = longName ?? (prefix === "" ? field(0, 100) : `${prefix}/${field(0, 100)}`);
|
|
61
|
+
const body = tar.subarray(at + 512, at + 512 + size);
|
|
62
|
+
longName = type === "L" ? body.toString("utf8").replace(/\0+$/, "") : void 0;
|
|
63
|
+
if ((type === "0" || type === "") && /^[^/]+\/package\.json$/.test(name.replace(/^\.\//, ""))) return body.toString("utf8");
|
|
64
|
+
at += 512 + Math.ceil(size / 512) * 512;
|
|
65
|
+
}
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
function manifestPathOf(dir, pkg) {
|
|
69
|
+
try {
|
|
70
|
+
return createRequire(join(dir, "package.json")).resolve(`${pkg}/package.json`);
|
|
71
|
+
} catch {
|
|
72
|
+
const literal = join(dir, "node_modules", ...pkg.split("/"), "package.json");
|
|
73
|
+
return existsSync(literal) ? literal : null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function installedPackageDir(dir, pkg) {
|
|
77
|
+
const path = manifestPathOf(dir, pkg);
|
|
78
|
+
return path === null ? null : dirname(path);
|
|
79
|
+
}
|
|
80
|
+
function readInstalledManifestState(dir, pkg) {
|
|
81
|
+
const path = manifestPathOf(dir, pkg);
|
|
82
|
+
if (path === null) return { kind: "absent" };
|
|
83
|
+
try {
|
|
84
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
85
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
86
|
+
return { kind: "unreadable", why: `${path} is not a JSON object` };
|
|
87
|
+
}
|
|
88
|
+
return { kind: "ok", manifest: parsed };
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return {
|
|
91
|
+
kind: "unreadable",
|
|
92
|
+
why: `${path} could not be parsed (${error instanceof Error ? error.message : String(error)})`
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function readInstalledManifest(dir, pkg) {
|
|
97
|
+
const state = readInstalledManifestState(dir, pkg);
|
|
98
|
+
return state.kind === "ok" ? state.manifest : null;
|
|
99
|
+
}
|
|
100
|
+
function moduleKind(pkg, manifest) {
|
|
101
|
+
const field = manifest["xanosdk"];
|
|
102
|
+
if (typeof field !== "object" || field === null) return "workspace";
|
|
103
|
+
const kind = field["kind"];
|
|
104
|
+
if (kind === void 0) return "workspace";
|
|
105
|
+
if (typeof kind === "string" && MODULE_KINDS.includes(kind)) {
|
|
106
|
+
return kind;
|
|
107
|
+
}
|
|
108
|
+
throw new UsageError(
|
|
109
|
+
`${pkg} declares "xanosdk": { "kind": ${JSON.stringify(kind)} }, which is not a module kind. Valid kinds are ${MODULE_KINDS.map((k) => JSON.stringify(k)).join(" and ")}. Omit the field entirely for a workspace module.`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function entryFileOf(dir, pkg, manifest) {
|
|
113
|
+
const exports = manifest["exports"];
|
|
114
|
+
const dot = typeof exports === "object" && exports !== null ? exports["."] : void 0;
|
|
115
|
+
const nested = typeof dot === "object" && dot !== null ? dot["import"] ?? dot["default"] : typeof dot === "string" ? dot : void 0;
|
|
116
|
+
const candidate = nested ?? manifest["module"] ?? manifest["main"];
|
|
117
|
+
if (typeof candidate !== "string") return null;
|
|
118
|
+
return fileInPackage(dir, pkg, candidate);
|
|
119
|
+
}
|
|
120
|
+
function fileInPackage(dir, pkg, relative) {
|
|
121
|
+
const manifest = manifestPathOf(dir, pkg);
|
|
122
|
+
if (manifest === null) return null;
|
|
123
|
+
const root = dirname(manifest);
|
|
124
|
+
const file = resolve(root, relative);
|
|
125
|
+
if (file !== root && !file.startsWith(root + sep)) return null;
|
|
126
|
+
return existsSync(file) ? file : null;
|
|
127
|
+
}
|
|
128
|
+
async function loadEntryExports(dir, pkg, manifest) {
|
|
129
|
+
const entry = entryFileOf(dir, pkg, manifest);
|
|
130
|
+
if (entry === null) {
|
|
131
|
+
return { kind: "missing", why: "its package.json names no entry we could read" };
|
|
132
|
+
}
|
|
133
|
+
return loadFile(entry);
|
|
134
|
+
}
|
|
135
|
+
async function loadFile(file) {
|
|
136
|
+
try {
|
|
137
|
+
return {
|
|
138
|
+
kind: "loaded",
|
|
139
|
+
exports: await import(pathToFileURL(file).href)
|
|
140
|
+
};
|
|
141
|
+
} catch (error) {
|
|
142
|
+
return {
|
|
143
|
+
kind: "failed",
|
|
144
|
+
why: `importing it failed (${error instanceof Error ? error.message : String(error)})`
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function homepageOf(manifest) {
|
|
149
|
+
const homepage = manifest["homepage"];
|
|
150
|
+
return typeof homepage === "string" && /^https?:\/\//.test(homepage) ? homepage : void 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
packageNameOf,
|
|
155
|
+
localPathOf,
|
|
156
|
+
localPackageName,
|
|
157
|
+
tarballManifest,
|
|
158
|
+
installedPackageDir,
|
|
159
|
+
readInstalledManifestState,
|
|
160
|
+
readInstalledManifest,
|
|
161
|
+
moduleKind,
|
|
162
|
+
entryFileOf,
|
|
163
|
+
fileInPackage,
|
|
164
|
+
loadEntryExports,
|
|
165
|
+
loadFile,
|
|
166
|
+
homepageOf
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=chunk-3LDULPRE.js.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
localEngineHome
|
|
3
|
+
} from "./chunk-AM4FKL4J.js";
|
|
4
|
+
import {
|
|
5
|
+
filledAt,
|
|
6
|
+
withValidFilled
|
|
7
|
+
} from "./chunk-ZYJP6BOO.js";
|
|
8
|
+
import {
|
|
9
|
+
atomicWrite
|
|
10
|
+
} from "./chunk-LLNZGEFK.js";
|
|
11
|
+
|
|
12
|
+
// src/deploy/local-engine-state.ts
|
|
13
|
+
import { createHash } from "crypto";
|
|
14
|
+
import { mkdirSync, readFileSync } from "fs";
|
|
15
|
+
import { join, resolve } from "path";
|
|
16
|
+
var LOCAL_ENGINE_STATE_FILE = "engines.json";
|
|
17
|
+
function localEngineStatePath(env = process.env) {
|
|
18
|
+
return join(localEngineHome(env), LOCAL_ENGINE_STATE_FILE);
|
|
19
|
+
}
|
|
20
|
+
function projectKey(dir) {
|
|
21
|
+
return resolve(dir);
|
|
22
|
+
}
|
|
23
|
+
function engineNameForProject(dir) {
|
|
24
|
+
return `xanosdk-${createHash("sha256").update(projectKey(dir)).digest("hex").slice(0, 12)}`;
|
|
25
|
+
}
|
|
26
|
+
function isRecord(value) {
|
|
27
|
+
if (value === null || typeof value !== "object") return false;
|
|
28
|
+
const raw = value;
|
|
29
|
+
return typeof raw.name === "string" && typeof raw.url === "string" && typeof raw.workspaceId === "number" && typeof raw.project === "string";
|
|
30
|
+
}
|
|
31
|
+
function readLocalEngineState(env = process.env) {
|
|
32
|
+
let text;
|
|
33
|
+
try {
|
|
34
|
+
text = readFileSync(localEngineStatePath(env), "utf8");
|
|
35
|
+
} catch {
|
|
36
|
+
return { version: 1, engines: {} };
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(text);
|
|
40
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
41
|
+
const rows = parsed.engines;
|
|
42
|
+
if (rows !== null && typeof rows === "object") {
|
|
43
|
+
const engines = {};
|
|
44
|
+
for (const [key, value] of Object.entries(rows)) {
|
|
45
|
+
if (isRecord(value)) engines[key] = withValidFilled(value);
|
|
46
|
+
}
|
|
47
|
+
return { version: 1, engines };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
return { version: 1, engines: {} };
|
|
53
|
+
}
|
|
54
|
+
function getEngineRecord(dir, env = process.env) {
|
|
55
|
+
return readLocalEngineState(env).engines[projectKey(dir)];
|
|
56
|
+
}
|
|
57
|
+
function listEngineRecords(env = process.env) {
|
|
58
|
+
return Object.values(readLocalEngineState(env).engines).sort(
|
|
59
|
+
(a, b) => (b.startedAt ?? 0) - (a.startedAt ?? 0)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function setEngineRecord(dir, record, env = process.env) {
|
|
63
|
+
const state = readLocalEngineState(env);
|
|
64
|
+
state.engines[projectKey(dir)] = { ...record, project: projectKey(dir) };
|
|
65
|
+
writeState(state, env);
|
|
66
|
+
}
|
|
67
|
+
function markEngineFilled(dir, url, env = process.env) {
|
|
68
|
+
const state = readLocalEngineState(env);
|
|
69
|
+
const record = state.engines[projectKey(dir)];
|
|
70
|
+
if (record === void 0) return;
|
|
71
|
+
state.engines[projectKey(dir)] = { ...record, filled: filledAt(url) };
|
|
72
|
+
writeState(state, env);
|
|
73
|
+
}
|
|
74
|
+
function clearEngineRecord(dir, env = process.env) {
|
|
75
|
+
const state = readLocalEngineState(env);
|
|
76
|
+
const key = projectKey(dir);
|
|
77
|
+
if (!(key in state.engines)) return false;
|
|
78
|
+
delete state.engines[key];
|
|
79
|
+
writeState(state, env);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function clearEngineRecordsNamed(name, env = process.env) {
|
|
83
|
+
const state = readLocalEngineState(env);
|
|
84
|
+
const cleared = Object.entries(state.engines).filter(([, record]) => record.name === name).map(([key]) => key);
|
|
85
|
+
if (cleared.length === 0) return [];
|
|
86
|
+
for (const key of cleared) delete state.engines[key];
|
|
87
|
+
writeState(state, env);
|
|
88
|
+
return cleared;
|
|
89
|
+
}
|
|
90
|
+
function writeState(state, env) {
|
|
91
|
+
const path = localEngineStatePath(env);
|
|
92
|
+
mkdirSync(localEngineHome(env), { recursive: true, mode: 448 });
|
|
93
|
+
atomicWrite(path, JSON.stringify({ version: 1, engines: state.engines }, null, 2) + "\n", {
|
|
94
|
+
mode: 384
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
LOCAL_ENGINE_STATE_FILE,
|
|
100
|
+
localEngineStatePath,
|
|
101
|
+
projectKey,
|
|
102
|
+
engineNameForProject,
|
|
103
|
+
readLocalEngineState,
|
|
104
|
+
getEngineRecord,
|
|
105
|
+
listEngineRecords,
|
|
106
|
+
setEngineRecord,
|
|
107
|
+
markEngineFilled,
|
|
108
|
+
clearEngineRecord,
|
|
109
|
+
clearEngineRecordsNamed
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=chunk-3M4LFYNQ.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/emit/project-dir.ts
|
|
2
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
function assertProjectDir(dir, ctx) {
|
|
5
|
+
const manifest = join(dir, "package.json");
|
|
6
|
+
if (!existsSync(manifest)) {
|
|
7
|
+
throw new Error(`No package.json in ${dir} \u2014 ${ctx.what}.
|
|
8
|
+
${ctx.remedy}`);
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
JSON.parse(readFileSync(manifest, "utf8"));
|
|
12
|
+
} catch (err) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`${manifest} is not valid JSON, so npm cannot install into it \u2014 fix it and re-run. (${err instanceof Error ? err.message : String(err)})`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
assertProjectDir
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-3XI5CTUE.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/fields/generated/field-methods.generated.ts
|
|
2
|
+
var FIELD_METHODS = {
|
|
3
|
+
"decimal": {
|
|
4
|
+
"max": "int",
|
|
5
|
+
"min": "int"
|
|
6
|
+
},
|
|
7
|
+
"email": {
|
|
8
|
+
"lower": "bool",
|
|
9
|
+
"trim": "bool"
|
|
10
|
+
},
|
|
11
|
+
"int": {
|
|
12
|
+
"max": "int",
|
|
13
|
+
"min": "int"
|
|
14
|
+
},
|
|
15
|
+
"password": {
|
|
16
|
+
"max": "int",
|
|
17
|
+
"min": "int",
|
|
18
|
+
"minAlpha": "int",
|
|
19
|
+
"minDigit": "int",
|
|
20
|
+
"minLowerAlpha": "int",
|
|
21
|
+
"minSymbol": "int",
|
|
22
|
+
"minUpperAlpha": "int",
|
|
23
|
+
"salt": "text"
|
|
24
|
+
},
|
|
25
|
+
"tableRef": {
|
|
26
|
+
"max": "int",
|
|
27
|
+
"min": "int"
|
|
28
|
+
},
|
|
29
|
+
"text": {
|
|
30
|
+
"alphaOk": "bool",
|
|
31
|
+
"digitOk": "bool",
|
|
32
|
+
"lower": "bool",
|
|
33
|
+
"max": "int",
|
|
34
|
+
"min": "int",
|
|
35
|
+
"ok": "text",
|
|
36
|
+
"pattern": "text",
|
|
37
|
+
"startsWith": "text",
|
|
38
|
+
"trim": "bool",
|
|
39
|
+
"upper": "bool"
|
|
40
|
+
},
|
|
41
|
+
"vector": {
|
|
42
|
+
"max": "int",
|
|
43
|
+
"min": "int"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
FIELD_METHODS
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-3YW23UFH.js.map
|