@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,407 @@
|
|
|
1
|
+
import {
|
|
2
|
+
repoBoundaryFrom
|
|
3
|
+
} from "./chunk-ROY4YAEQ.js";
|
|
4
|
+
import {
|
|
5
|
+
LocalFileNotFoundError
|
|
6
|
+
} from "./chunk-PTHVMXZI.js";
|
|
7
|
+
import {
|
|
8
|
+
buildContentEnvelope
|
|
9
|
+
} from "./chunk-LQCMKAJ7.js";
|
|
10
|
+
import {
|
|
11
|
+
SEED_FILE,
|
|
12
|
+
assertSeedIds,
|
|
13
|
+
assertSeedUnique,
|
|
14
|
+
coerceSeedRowValues,
|
|
15
|
+
isNonPublicColumn,
|
|
16
|
+
isSeedFileSource,
|
|
17
|
+
seedFailure,
|
|
18
|
+
tableColumns,
|
|
19
|
+
tableIndexes
|
|
20
|
+
} from "./chunk-HVRUQXGD.js";
|
|
21
|
+
import {
|
|
22
|
+
DiagnosticError
|
|
23
|
+
} from "./chunk-2EZ3ZJZZ.js";
|
|
24
|
+
import {
|
|
25
|
+
HOSTED_FILE,
|
|
26
|
+
HOSTED_FILE_SCHEME,
|
|
27
|
+
HOSTED_ROW_PATH_PREFIX,
|
|
28
|
+
isHostedFile
|
|
29
|
+
} from "./chunk-XNCP4KYO.js";
|
|
30
|
+
import {
|
|
31
|
+
resolveRef
|
|
32
|
+
} from "./chunk-NZOWWHU5.js";
|
|
33
|
+
|
|
34
|
+
// src/workspace/seed.ts
|
|
35
|
+
import { createHash as createHash2 } from "crypto";
|
|
36
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
37
|
+
|
|
38
|
+
// src/util/local-file.ts
|
|
39
|
+
function isMissingFile(err) {
|
|
40
|
+
const code = err?.code;
|
|
41
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/workspace/seed.ts
|
|
45
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
|
|
46
|
+
|
|
47
|
+
// src/workspace/hosted-file.ts
|
|
48
|
+
import { createHash } from "crypto";
|
|
49
|
+
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
50
|
+
import { basename, dirname, extname, isAbsolute, relative } from "path";
|
|
51
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
52
|
+
var HOSTED_FILE_MAX_BYTES = 10 * 1024 * 1024;
|
|
53
|
+
var MIME_BY_EXT = {
|
|
54
|
+
".png": "image/png",
|
|
55
|
+
".jpg": "image/jpeg",
|
|
56
|
+
".jpeg": "image/jpeg",
|
|
57
|
+
".webp": "image/webp",
|
|
58
|
+
".gif": "image/gif",
|
|
59
|
+
".svg": "image/svg+xml",
|
|
60
|
+
".ico": "image/x-icon",
|
|
61
|
+
".mp3": "audio/mpeg",
|
|
62
|
+
".wav": "audio/wav",
|
|
63
|
+
".mp4": "video/mp4",
|
|
64
|
+
".webm": "video/webm",
|
|
65
|
+
".pdf": "application/pdf",
|
|
66
|
+
".json": "application/json",
|
|
67
|
+
".txt": "text/plain",
|
|
68
|
+
".csv": "text/csv"
|
|
69
|
+
};
|
|
70
|
+
var IMAGE_SIGNATURES = {
|
|
71
|
+
"image/png": (b) => b.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])),
|
|
72
|
+
"image/jpeg": (b) => b[0] === 255 && b[1] === 216 && b[2] === 255,
|
|
73
|
+
"image/webp": (b) => b.subarray(0, 4).toString("latin1") === "RIFF" && b.subarray(8, 12).toString("latin1") === "WEBP",
|
|
74
|
+
"image/gif": (b) => b.subarray(0, 6).toString("latin1") === "GIF87a" || b.subarray(0, 6).toString("latin1") === "GIF89a",
|
|
75
|
+
"image/x-icon": (b) => b[0] === 0 && b[1] === 0 && b[2] === 1 && b[3] === 0
|
|
76
|
+
};
|
|
77
|
+
function assertInsideRepo(where, file, base) {
|
|
78
|
+
if (!base.startsWith("file:")) return;
|
|
79
|
+
const boundary = repoBoundaryFrom(dirname(fileURLToPath(base)));
|
|
80
|
+
const root = realpathSync(boundary.root);
|
|
81
|
+
const real = realpathSync(file);
|
|
82
|
+
const rel = relative(root, real);
|
|
83
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) {
|
|
84
|
+
const via = lstatSync(file).isSymbolicLink() ? ` (a link to "${real}")` : "";
|
|
85
|
+
throw new Error(
|
|
86
|
+
`${where}: "${file}"${via} is outside the ${boundary.kind} (${root}). A hosted file ships only from inside it \u2014 copy the file into ${root} and point at the copy.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function resolveHostedFile(ref, rules = {}) {
|
|
91
|
+
const { path, base, access } = ref[HOSTED_FILE];
|
|
92
|
+
const where = `${rules.field ? `${rules.field}: ` : ""}hostedFile("${path}")`;
|
|
93
|
+
const baseUrl = /^[a-z][a-z0-9+.-]*:/i.test(base) ? base : pathToFileURL(base).href;
|
|
94
|
+
const file = fileURLToPath(new URL(path, baseUrl));
|
|
95
|
+
let bytes;
|
|
96
|
+
try {
|
|
97
|
+
bytes = readFileSync(file);
|
|
98
|
+
} catch (cause) {
|
|
99
|
+
const relative2 = "The path is resolved relative to the module that declares it (the `import.meta.url` you passed as `base`).";
|
|
100
|
+
if (isMissingFile(cause)) throw new LocalFileNotFoundError(`${where}: no file at "${file}". ${relative2}`);
|
|
101
|
+
throw new Error(`${where}: cannot read "${file}". ${relative2}`, { cause });
|
|
102
|
+
}
|
|
103
|
+
assertInsideRepo(where, file, baseUrl);
|
|
104
|
+
if (bytes.length === 0) throw new Error(`${where}: "${file}" is empty.`);
|
|
105
|
+
if (bytes.length > HOSTED_FILE_MAX_BYTES) {
|
|
106
|
+
throw new Error(`${where}: "${file}" is ${bytes.length} bytes, over the ${HOSTED_FILE_MAX_BYTES}-byte limit for a hosted file.`);
|
|
107
|
+
}
|
|
108
|
+
const mime = MIME_BY_EXT[extname(file).toLowerCase()] ?? "application/octet-stream";
|
|
109
|
+
const signature = IMAGE_SIGNATURES[mime];
|
|
110
|
+
if (signature !== void 0 && !signature(bytes)) {
|
|
111
|
+
throw new Error(`${where}: "${file}" is named as ${mime}, but its contents are not a ${mime.slice(6).toUpperCase()} image.`);
|
|
112
|
+
}
|
|
113
|
+
if (rules.declaredMime !== void 0 && rules.declaredMime !== mime) {
|
|
114
|
+
throw new Error(`${where}: \`mimeType\` says ${rules.declaredMime}, but "${file}" is ${mime}. Drop \`mimeType\` or make it ${mime}.`);
|
|
115
|
+
}
|
|
116
|
+
if (rules.allowedMimes && !rules.allowedMimes.includes(mime)) {
|
|
117
|
+
throw new Error(`${where}: "${file}" is ${mime}, but this field accepts ${rules.allowedMimes.join(", ")}.`);
|
|
118
|
+
}
|
|
119
|
+
if (rules.mimeKind && !mime.startsWith(`${rules.mimeKind}/`)) {
|
|
120
|
+
throw new Error(`${where}: "${file}" is ${mime}, but this field holds ${rules.mimeKind}/* files.`);
|
|
121
|
+
}
|
|
122
|
+
if (rules.requirePublic && access !== "public") {
|
|
123
|
+
throw new Error(`${where}: a private file cannot be used here \u2014 this field is fetched with no credentials, so the file must be public.`);
|
|
124
|
+
}
|
|
125
|
+
const canonical = createHash("sha256").update(bytes).digest("hex").slice(0, 32);
|
|
126
|
+
const name = basename(file);
|
|
127
|
+
if (Buffer.byteLength(`vault/${canonical}/${name}`) > 100) {
|
|
128
|
+
throw new Error(`${where}: the file name "${name}" is too long to ship \u2014 keep it under ${100 - `vault/${canonical}/`.length} bytes.`);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
name,
|
|
132
|
+
bytes,
|
|
133
|
+
size: bytes.length,
|
|
134
|
+
mime,
|
|
135
|
+
access,
|
|
136
|
+
canonical,
|
|
137
|
+
sig: createHash("sha1").update(bytes).digest("hex")
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function hostedFileResolver() {
|
|
141
|
+
const byCanonical = /* @__PURE__ */ new Map();
|
|
142
|
+
const resolveFile = (ref, rules) => {
|
|
143
|
+
const file = resolveHostedFile(ref, rules);
|
|
144
|
+
const seen = byCanonical.get(file.canonical);
|
|
145
|
+
if (seen !== void 0 && seen.access !== file.access) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`${rules.field ? `${rules.field}: ` : ""}hostedFile("${ref[HOSTED_FILE].path}") is ${file.access}, but the same file is already used as ${seen.access} (as "${seen.name}"). One file cannot be both \u2014 give the ${file.access === "private" ? "private" : "public"} use its own copy.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
if (seen !== void 0) return seen;
|
|
151
|
+
byCanonical.set(file.canonical, file);
|
|
152
|
+
return file;
|
|
153
|
+
};
|
|
154
|
+
return {
|
|
155
|
+
resolve: (ref, rules) => hostedFilePlaceholder(resolveFile(ref, rules)),
|
|
156
|
+
resolveFile,
|
|
157
|
+
files: () => [...byCanonical.values()],
|
|
158
|
+
libraryRows: () => [...byCanonical.values()].map(hostedFileLibraryRow)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function hostedFilePlaceholder(file) {
|
|
162
|
+
return `${HOSTED_FILE_SCHEME}${file.canonical}/${encodeURIComponent(file.name)}`;
|
|
163
|
+
}
|
|
164
|
+
function libraryType(mime) {
|
|
165
|
+
if (mime.startsWith("image/")) return "image";
|
|
166
|
+
if (mime.startsWith("video/")) return "video";
|
|
167
|
+
if (mime.startsWith("audio/")) return "audio";
|
|
168
|
+
return "attachment";
|
|
169
|
+
}
|
|
170
|
+
function hostedFileColumnValue(file) {
|
|
171
|
+
return {
|
|
172
|
+
access: file.access,
|
|
173
|
+
path: `${HOSTED_ROW_PATH_PREFIX}${file.canonical}/_/${encodeURIComponent(file.name)}`,
|
|
174
|
+
name: file.name,
|
|
175
|
+
type: libraryType(file.mime),
|
|
176
|
+
size: file.size,
|
|
177
|
+
mime: file.mime,
|
|
178
|
+
meta: {}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function hostedFileLibraryRow(file) {
|
|
182
|
+
return {
|
|
183
|
+
name: file.name,
|
|
184
|
+
size: file.size,
|
|
185
|
+
type: libraryType(file.mime),
|
|
186
|
+
mime: file.mime,
|
|
187
|
+
canonical: file.canonical,
|
|
188
|
+
// The row's identity on import is its guid, so the content identity doubles
|
|
189
|
+
// as it: re-importing the same file updates its row instead of adding one.
|
|
190
|
+
guid: file.canonical,
|
|
191
|
+
sig: file.sig,
|
|
192
|
+
access: file.access,
|
|
193
|
+
meta: {}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function hostedFileArchivePath(file) {
|
|
197
|
+
return `vault/${file.canonical}/${file.name}`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/workspace/seed.ts
|
|
201
|
+
var SEED_PAGE_TARGET_BYTES = 512 * 1024;
|
|
202
|
+
async function resolveSeedRows(source) {
|
|
203
|
+
if (isSeedFileSource(source)) return readSeedFile(source[SEED_FILE]);
|
|
204
|
+
const resolved = typeof source === "function" ? await source() : source;
|
|
205
|
+
const rows = Array.isArray(resolved) ? resolved : unwrapDefaultExport(resolved);
|
|
206
|
+
if (!Array.isArray(rows)) {
|
|
207
|
+
throw new Error(`seed source did not resolve to an array of rows (got ${typeof resolved}).`);
|
|
208
|
+
}
|
|
209
|
+
return rows;
|
|
210
|
+
}
|
|
211
|
+
function readSeedFile(ref) {
|
|
212
|
+
const where = `seedFile("${ref.path}")`;
|
|
213
|
+
const base = /^[a-z][a-z0-9+.-]*:/i.test(ref.base) ? ref.base : pathToFileURL2(ref.base).href;
|
|
214
|
+
const file = fileURLToPath2(new URL(ref.path, base));
|
|
215
|
+
let text;
|
|
216
|
+
try {
|
|
217
|
+
text = readFileSync2(file, "utf8");
|
|
218
|
+
} catch (cause) {
|
|
219
|
+
const relative2 = `The path is resolved relative to the module that declares the table (the \`import.meta.url\` you passed as \`base\`).`;
|
|
220
|
+
if (isMissingFile(cause)) throw new LocalFileNotFoundError(`${where}: no file at "${file}". ${relative2}`);
|
|
221
|
+
throw new Error(`${where}: cannot read "${file}". ${relative2}`, { cause });
|
|
222
|
+
}
|
|
223
|
+
let parsed;
|
|
224
|
+
try {
|
|
225
|
+
parsed = JSON.parse(text);
|
|
226
|
+
} catch (cause) {
|
|
227
|
+
throw new Error(`${where}: "${file}" is not valid JSON \u2014 ${cause.message}`, {
|
|
228
|
+
cause
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const lossy = lossyJsonInteger(text);
|
|
232
|
+
if (lossy !== void 0) {
|
|
233
|
+
throw new Error(
|
|
234
|
+
`${where}: "${file}" holds the number ${lossy}, which JSON parsing reads as ${BigInt(Number(lossy))} \u2014 past \xB19007199254740991 a JSON number loses its low digits. Quote it ("${lossy}") so it is seeded exactly.`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
const rows = Array.isArray(parsed) ? parsed : unwrapDefaultExport(parsed);
|
|
238
|
+
if (!Array.isArray(rows)) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`${where}: "${file}" must hold an array of seed rows (got ${typeof parsed}).`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return rows;
|
|
244
|
+
}
|
|
245
|
+
function lossyJsonInteger(text) {
|
|
246
|
+
for (const [token] of text.matchAll(/"(?:[^"\\]|\\.)*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g)) {
|
|
247
|
+
if (!/^-?\d{16,}$/.test(token)) continue;
|
|
248
|
+
if (BigInt(Number(token)) !== BigInt(token)) return token;
|
|
249
|
+
}
|
|
250
|
+
return void 0;
|
|
251
|
+
}
|
|
252
|
+
function unwrapDefaultExport(value) {
|
|
253
|
+
if (value === null || typeof value !== "object") return value;
|
|
254
|
+
const fallback = value.default;
|
|
255
|
+
return Array.isArray(fallback) ? fallback : value;
|
|
256
|
+
}
|
|
257
|
+
function coerceSeedRows(tableName, columns, rows, opts = {}) {
|
|
258
|
+
const coerced = coerceSeedRowValues(tableName, columns, rows, opts);
|
|
259
|
+
assignPrimaryKeys(tableName, columns, coerced);
|
|
260
|
+
return coerced;
|
|
261
|
+
}
|
|
262
|
+
function assignPrimaryKeys(tableName, columns, rows) {
|
|
263
|
+
if (!assertSeedIds(tableName, columns, rows)) return;
|
|
264
|
+
const idType = columns.find((c) => c.name === "id")?.type;
|
|
265
|
+
rows.forEach((r, i) => {
|
|
266
|
+
r.id = idType === "int" ? i + 1 : seedUuid(tableName, i);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function seedUuid(tableName, index) {
|
|
270
|
+
const h = createHash2("sha256").update(`xanosdk:seed-id:${tableName}:${index}`).digest("hex");
|
|
271
|
+
const version5 = `5${h.slice(13, 16)}`;
|
|
272
|
+
const variant = (parseInt(h.slice(16, 17), 16) & 3 | 8).toString(16) + h.slice(17, 20);
|
|
273
|
+
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${version5}-${variant}-${h.slice(20, 32)}`;
|
|
274
|
+
}
|
|
275
|
+
function paginateRows(rows, budgetBytes = SEED_PAGE_TARGET_BYTES) {
|
|
276
|
+
const pages = [];
|
|
277
|
+
let page = [];
|
|
278
|
+
let size = 0;
|
|
279
|
+
for (const row of rows) {
|
|
280
|
+
const rowBytes = Buffer.byteLength(JSON.stringify(row), "utf8");
|
|
281
|
+
if (page.length > 0 && size + rowBytes > budgetBytes) {
|
|
282
|
+
pages.push(page);
|
|
283
|
+
page = [];
|
|
284
|
+
size = 0;
|
|
285
|
+
}
|
|
286
|
+
page.push(row);
|
|
287
|
+
size += rowBytes;
|
|
288
|
+
}
|
|
289
|
+
if (page.length > 0) pages.push(page);
|
|
290
|
+
return pages;
|
|
291
|
+
}
|
|
292
|
+
async function buildSeedContentFiles(tableDefs, hostedFiles = hostedFileResolver(), workspaceUseXdo = false) {
|
|
293
|
+
const files = [];
|
|
294
|
+
const problems = [];
|
|
295
|
+
for (const def of tableDefs) {
|
|
296
|
+
if (def.seed === void 0) continue;
|
|
297
|
+
const rows = await resolveSeedRows(def.seed);
|
|
298
|
+
if (rows.length === 0) continue;
|
|
299
|
+
let coerced;
|
|
300
|
+
try {
|
|
301
|
+
coerced = coerceSeedRows(def.name, tableColumns(def), rows, { useXdo: def.useXdo ?? workspaceUseXdo });
|
|
302
|
+
assertSeedUnique(def.name, tableIndexes(def), coerced);
|
|
303
|
+
resolveSeedFiles(def.name, tableColumns(def), coerced, hostedFiles);
|
|
304
|
+
} catch (err) {
|
|
305
|
+
if (err instanceof DiagnosticError) problems.push(...err.details);
|
|
306
|
+
else problems.push({ severity: "error", code: "seed.invalid", message: err.message });
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const guid = resolveRef("dbo", def);
|
|
310
|
+
const pages = paginateRows(coerced);
|
|
311
|
+
pages.forEach((page, i) => {
|
|
312
|
+
files.push({ name: contentFileName(guid, i + 1), content: JSON.stringify(buildContentEnvelope(page)) });
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (problems.length > 0) throw seedFailure(problems);
|
|
316
|
+
return files;
|
|
317
|
+
}
|
|
318
|
+
async function registerSeedHostedFiles(tableDefs, hostedFiles, workspaceUseXdo = false) {
|
|
319
|
+
for (const def of tableDefs) {
|
|
320
|
+
if (def.seed === void 0) continue;
|
|
321
|
+
try {
|
|
322
|
+
const columns = tableColumns(def);
|
|
323
|
+
resolveSeedFiles(def.name, columns, coerceSeedRows(def.name, columns, await resolveSeedRows(def.seed), { useXdo: def.useXdo ?? workspaceUseXdo }), hostedFiles);
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
var FILE_COLUMN_KIND = {
|
|
329
|
+
blob_img: "image",
|
|
330
|
+
blob_video: "video",
|
|
331
|
+
blob_audio: "audio"
|
|
332
|
+
};
|
|
333
|
+
function resolveSeedFiles(table, columns, rows, hostedFiles) {
|
|
334
|
+
const fileColumns = columns.filter((c) => c.type.startsWith("blob"));
|
|
335
|
+
if (fileColumns.length === 0) return;
|
|
336
|
+
rows.forEach((row, i) => {
|
|
337
|
+
for (const col of fileColumns) {
|
|
338
|
+
const rules = { field: `table "${table}" seed row ${i}, column "${col.name}"`, mimeKind: FILE_COLUMN_KIND[col.type] };
|
|
339
|
+
const value = row[col.name];
|
|
340
|
+
const one = (v) => isHostedFile(v) ? hostedFileColumnValue(hostedFiles.resolveFile(v, rules)) : v;
|
|
341
|
+
if (isHostedFile(value)) row[col.name] = one(value);
|
|
342
|
+
else if (Array.isArray(value) && value.some(isHostedFile)) row[col.name] = value.map(one);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function contentFileName(guid, page) {
|
|
347
|
+
return `content/${guid}-${page}.json`;
|
|
348
|
+
}
|
|
349
|
+
function parseContentFileName(name) {
|
|
350
|
+
const match = /^content\/(.+)-(\d+)\.json$/.exec(name);
|
|
351
|
+
return match === void 0 || match === null ? void 0 : { guid: match[1], page: Number(match[2]) };
|
|
352
|
+
}
|
|
353
|
+
function seedSourceKind(source) {
|
|
354
|
+
return typeof source === "function" ? "thunk" : isSeedFileSource(source) ? "file" : "inline";
|
|
355
|
+
}
|
|
356
|
+
var MIN_SCANNABLE_LENGTH = 6;
|
|
357
|
+
async function collectNonPublicSeedValues(tableDefs) {
|
|
358
|
+
const found = [];
|
|
359
|
+
for (const def of tableDefs) {
|
|
360
|
+
if (def.seed === void 0) continue;
|
|
361
|
+
const exempt = new Set(def.publicSeed ?? []);
|
|
362
|
+
const guarded = tableColumns(def).filter((c) => isNonPublicColumn(c) && !exempt.has(c.name));
|
|
363
|
+
if (guarded.length === 0) continue;
|
|
364
|
+
const source = seedSourceKind(def.seed);
|
|
365
|
+
const rows = await resolveSeedRows(def.seed);
|
|
366
|
+
for (const row of rows) {
|
|
367
|
+
for (const col of guarded) {
|
|
368
|
+
const value = Object.hasOwn(row, col.name) ? row[col.name] : void 0;
|
|
369
|
+
if (value === void 0 || value === null) continue;
|
|
370
|
+
const scannable = typeof value === "string" && value.length >= MIN_SCANNABLE_LENGTH;
|
|
371
|
+
found.push({ table: def.name, column: col.name, value: String(value), scannable, source });
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return found;
|
|
376
|
+
}
|
|
377
|
+
function seedRowsByTableGuid(files) {
|
|
378
|
+
const out = /* @__PURE__ */ new Map();
|
|
379
|
+
const parsed = files.flatMap((f) => {
|
|
380
|
+
const parsedName = parseContentFileName(f.name);
|
|
381
|
+
return parsedName === void 0 ? [] : [{ ...parsedName, content: f.content }];
|
|
382
|
+
}).sort((a, b) => a.page - b.page);
|
|
383
|
+
for (const entry of parsed) {
|
|
384
|
+
const payload = JSON.parse(entry.content).payload;
|
|
385
|
+
if (!Array.isArray(payload)) continue;
|
|
386
|
+
const rows = out.get(entry.guid) ?? [];
|
|
387
|
+
rows.push(...payload);
|
|
388
|
+
out.set(entry.guid, rows);
|
|
389
|
+
}
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export {
|
|
394
|
+
isMissingFile,
|
|
395
|
+
hostedFileResolver,
|
|
396
|
+
hostedFileArchivePath,
|
|
397
|
+
SEED_PAGE_TARGET_BYTES,
|
|
398
|
+
resolveSeedRows,
|
|
399
|
+
coerceSeedRows,
|
|
400
|
+
paginateRows,
|
|
401
|
+
buildSeedContentFiles,
|
|
402
|
+
registerSeedHostedFiles,
|
|
403
|
+
seedSourceKind,
|
|
404
|
+
collectNonPublicSeedValues,
|
|
405
|
+
seedRowsByTableGuid
|
|
406
|
+
};
|
|
407
|
+
//# sourceMappingURL=chunk-U64O2MXY.js.map
|