@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,560 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readArchiveEntries
|
|
3
|
+
} from "./chunk-3DRXWLJ5.js";
|
|
4
|
+
import {
|
|
5
|
+
tarGz
|
|
6
|
+
} from "./chunk-X4DVXBFY.js";
|
|
7
|
+
import {
|
|
8
|
+
ImportHttpError
|
|
9
|
+
} from "./chunk-AN6BL47T.js";
|
|
10
|
+
import {
|
|
11
|
+
describeWrite
|
|
12
|
+
} from "./chunk-4KHEMC32.js";
|
|
13
|
+
import {
|
|
14
|
+
TransportError,
|
|
15
|
+
certificateFailureCode,
|
|
16
|
+
closeSentence,
|
|
17
|
+
debugEnabled,
|
|
18
|
+
describeTransportFailure,
|
|
19
|
+
explainBodyFailure,
|
|
20
|
+
isTimeoutError,
|
|
21
|
+
lostAnswerHead,
|
|
22
|
+
notJsonError,
|
|
23
|
+
noteMetaAnswer,
|
|
24
|
+
noteRateLimit,
|
|
25
|
+
serverMessage,
|
|
26
|
+
statusLabel,
|
|
27
|
+
transportTarget,
|
|
28
|
+
writeStatusAftermath
|
|
29
|
+
} from "./chunk-YLDALTWZ.js";
|
|
30
|
+
import {
|
|
31
|
+
calcSignatureJson,
|
|
32
|
+
signatureHolds
|
|
33
|
+
} from "./chunk-LQCMKAJ7.js";
|
|
34
|
+
import {
|
|
35
|
+
HOSTED_FILE_SCHEME,
|
|
36
|
+
HOSTED_ICON_KINDS,
|
|
37
|
+
HOSTED_ROW_PATH_PREFIX
|
|
38
|
+
} from "./chunk-XNCP4KYO.js";
|
|
39
|
+
|
|
40
|
+
// src/deploy/xanosdk-import.ts
|
|
41
|
+
var IMPORT_TIMEOUT_MS = 12e4;
|
|
42
|
+
var PROBE_TIMEOUT_MS = 15e3;
|
|
43
|
+
var READ_ATTEMPTS = 3;
|
|
44
|
+
var READ_BACKOFF_MS = 400;
|
|
45
|
+
var XANOSDK_IMPORT_CONFLICT_CODE = "conflict";
|
|
46
|
+
var XANOSDK_IMPORT_IN_PROGRESS_CODE = "import_in_progress";
|
|
47
|
+
var XANOSDK_IMPORT_UNIQUENESS_CODE = "uniqueness_violation";
|
|
48
|
+
var XANOSDK_IMPORT_UNRESOLVED_FILE_CODE = "unresolved_hosted_file";
|
|
49
|
+
var CANONICAL_OUTCOMES = ["honored", "kept", "minted", "conflict"];
|
|
50
|
+
var ImportNotSentError = class extends TransportError {
|
|
51
|
+
};
|
|
52
|
+
var XanoSdkImportRefusal = class extends Error {
|
|
53
|
+
constructor(status, code, reason, conflicts, canonicals, raw, message) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.status = status;
|
|
56
|
+
this.code = code;
|
|
57
|
+
this.reason = reason;
|
|
58
|
+
this.conflicts = conflicts;
|
|
59
|
+
this.canonicals = canonicals;
|
|
60
|
+
this.raw = raw;
|
|
61
|
+
this.name = "XanoSdkImportRefusal";
|
|
62
|
+
}
|
|
63
|
+
status;
|
|
64
|
+
code;
|
|
65
|
+
reason;
|
|
66
|
+
conflicts;
|
|
67
|
+
canonicals;
|
|
68
|
+
raw;
|
|
69
|
+
/**
|
|
70
|
+
* True only for the in-progress refusal — a second caller that lost the race
|
|
71
|
+
* for the instance-wide lock. Every other refusal names something the project
|
|
72
|
+
* has to change, so retrying it unchanged would just refuse again.
|
|
73
|
+
*/
|
|
74
|
+
get retryable() {
|
|
75
|
+
return this.code === XANOSDK_IMPORT_IN_PROGRESS_CODE;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function endpoint(target, qs = "") {
|
|
79
|
+
return `${target.baseUrl.replace(/\/$/, "")}/api:meta/workspace/${target.workspaceId}/xanosdk/import${qs}`;
|
|
80
|
+
}
|
|
81
|
+
function query(opts) {
|
|
82
|
+
const params = new URLSearchParams();
|
|
83
|
+
if (opts.mode !== void 0) params.set("mode", opts.mode);
|
|
84
|
+
if (opts.prune !== void 0) params.set("delete", String(opts.prune));
|
|
85
|
+
if (opts.records !== void 0) params.set("records", String(opts.records));
|
|
86
|
+
if (opts.truncate !== void 0) params.set("truncate", String(opts.truncate));
|
|
87
|
+
if (opts.branch !== void 0) params.set("branch", opts.branch);
|
|
88
|
+
if (opts.preserveGuids !== void 0) params.set("preserve_guids", String(opts.preserveGuids));
|
|
89
|
+
params.set("dry_run", String(opts.dryRun));
|
|
90
|
+
for (const guid of opts.pinned ?? []) params.append("pinned[]", guid);
|
|
91
|
+
return `?${params.toString()}`;
|
|
92
|
+
}
|
|
93
|
+
function body(archive) {
|
|
94
|
+
const form = new FormData();
|
|
95
|
+
form.append("file", new Blob([archive], { type: "application/gzip" }), "workspace.gz");
|
|
96
|
+
return form;
|
|
97
|
+
}
|
|
98
|
+
var detectionByBaseUrl = /* @__PURE__ */ new Map();
|
|
99
|
+
function detectionKey(baseUrl) {
|
|
100
|
+
return baseUrl.replace(/\/$/, "");
|
|
101
|
+
}
|
|
102
|
+
function resetXanoSdkImportDetection(baseUrl) {
|
|
103
|
+
if (baseUrl === void 0) detectionByBaseUrl.clear();
|
|
104
|
+
else detectionByBaseUrl.delete(detectionKey(baseUrl));
|
|
105
|
+
}
|
|
106
|
+
function undecidable(baseUrl, why, status) {
|
|
107
|
+
const err = new Error(
|
|
108
|
+
`Could not determine whether this instance supports a merging deploy: ${why}
|
|
109
|
+
instance: ${baseUrl}
|
|
110
|
+
Only a 404 means the route is absent. Every other answer leaves the question open, and guessing either way would decide how this deploy writes on no evidence.
|
|
111
|
+
Nothing was deployed \u2014 fix the access or reachability problem, then retry the deploy.`
|
|
112
|
+
);
|
|
113
|
+
if (status !== void 0) Object.defineProperty(err, "status", { value: status, enumerable: false });
|
|
114
|
+
return err;
|
|
115
|
+
}
|
|
116
|
+
async function detectXanoSdkImportRoute(auth, target) {
|
|
117
|
+
const key = detectionKey(target.baseUrl);
|
|
118
|
+
const cached = detectionByBaseUrl.get(key);
|
|
119
|
+
if (cached !== void 0) return cached;
|
|
120
|
+
const probe = probeXanoSdkImportRoute(auth, target);
|
|
121
|
+
detectionByBaseUrl.set(key, probe);
|
|
122
|
+
probe.catch(() => detectionByBaseUrl.delete(key));
|
|
123
|
+
return probe;
|
|
124
|
+
}
|
|
125
|
+
async function probeXanoSdkImportRoute(auth, target) {
|
|
126
|
+
const fetchFn = target.fetchFn ?? fetch;
|
|
127
|
+
let res;
|
|
128
|
+
try {
|
|
129
|
+
res = await fetchFn(endpoint(target, "?dry_run=true"), {
|
|
130
|
+
method: "POST",
|
|
131
|
+
headers: { accept: "application/json", Authorization: `Bearer ${auth.access_token}` },
|
|
132
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS)
|
|
133
|
+
});
|
|
134
|
+
await noteMetaAnswer(endpoint(target, ""), res);
|
|
135
|
+
noteRateLimit(res);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
throw undecidable(target.baseUrl, `could not reach it (${describeTransportFailure(err)}).`);
|
|
138
|
+
}
|
|
139
|
+
if (res.status === 404) return false;
|
|
140
|
+
if (res.ok || res.status === 400 || res.status === 422) return true;
|
|
141
|
+
const text = await res.text().catch(() => "");
|
|
142
|
+
const detail = serverMessage(text);
|
|
143
|
+
throw undecidable(
|
|
144
|
+
target.baseUrl,
|
|
145
|
+
// `statusLabel`: an empty statusText left "answered 503 : injected" (E2E pass 28).
|
|
146
|
+
`the probe answered ${statusLabel(res)}${detail !== void 0 ? `: ${detail}` : "."}`,
|
|
147
|
+
res.status
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
function isRecord(value) {
|
|
151
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
152
|
+
}
|
|
153
|
+
function malformed(field, why, ctx) {
|
|
154
|
+
const target = ctx.target;
|
|
155
|
+
const Target = target.charAt(0).toUpperCase() + target.slice(1);
|
|
156
|
+
const detail = `(no usable \`${field}\`: ${why})`;
|
|
157
|
+
const head = ctx.answer === "refusal" ? `${Target} refused the ${ctx.verb} with a detail that could not be read ${detail}.` : ctx.answer === "preview" ? `${Target} answered the ${ctx.verb} with something that isn't a preview result ${detail}. A dry run writes nothing, so ${target} is untouched.` : `${Target} answered the ${ctx.verb} with something that isn't a ${ctx.verb} result ${detail} \u2014 it may or may not have landed; check ${target} before retrying.`;
|
|
158
|
+
return new Error(debugEnabled() && ctx.raw.trim() !== "" ? `${head}
|
|
159
|
+
${ctx.raw}` : head);
|
|
160
|
+
}
|
|
161
|
+
function kindOf(value) {
|
|
162
|
+
if (value === void 0) return "the field is not present";
|
|
163
|
+
if (value === null) return "got null";
|
|
164
|
+
if (typeof value === "boolean") return `got ${value}`;
|
|
165
|
+
if (Array.isArray(value)) return "got a list";
|
|
166
|
+
if (typeof value === "object") return "got an object";
|
|
167
|
+
return `got a ${typeof value}`;
|
|
168
|
+
}
|
|
169
|
+
function requiredString(value, field, raw) {
|
|
170
|
+
if (typeof value !== "string" || value === "") {
|
|
171
|
+
throw malformed(field, kindOf(value), raw);
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
function optionalString(value) {
|
|
176
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
177
|
+
}
|
|
178
|
+
function decodeConflict(entry, index, raw) {
|
|
179
|
+
const field = `conflicts[${index}]`;
|
|
180
|
+
if (!isRecord(entry)) throw malformed(field, kindOf(entry), raw);
|
|
181
|
+
const owner = entry.owner;
|
|
182
|
+
if (!isRecord(owner)) throw malformed(`${field}.owner`, "a conflict must name the object that already holds the identity", raw);
|
|
183
|
+
const workspaceId = owner.workspace_id;
|
|
184
|
+
if (typeof workspaceId !== "number") {
|
|
185
|
+
throw malformed(`${field}.owner.workspace_id`, kindOf(workspaceId), raw);
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
kind: requiredString(entry.kind, `${field}.kind`, raw),
|
|
189
|
+
identity: requiredString(entry.identity, `${field}.identity`, raw),
|
|
190
|
+
archiveGuid: optionalString(entry.archive_guid),
|
|
191
|
+
owner: {
|
|
192
|
+
workspaceId,
|
|
193
|
+
// The descriptive half degrades to "unknown" without changing any
|
|
194
|
+
// decision, so it is read liberally: which workspace owns it is the fact
|
|
195
|
+
// the remedy turns on, and that one is checked above.
|
|
196
|
+
workspaceName: optionalString(owner.workspace_name),
|
|
197
|
+
guid: optionalString(owner.guid),
|
|
198
|
+
branch: optionalString(owner.branch),
|
|
199
|
+
deleted: owner.deleted === true
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function decodeCanonical(entry, index, raw) {
|
|
204
|
+
const field = `canonicals[${index}]`;
|
|
205
|
+
if (!isRecord(entry)) throw malformed(field, kindOf(entry), raw);
|
|
206
|
+
const outcome = entry.outcome;
|
|
207
|
+
if (typeof outcome !== "string" || !CANONICAL_OUTCOMES.includes(outcome)) {
|
|
208
|
+
throw malformed(
|
|
209
|
+
`${field}.outcome`,
|
|
210
|
+
`${kindOf(outcome)}${typeof outcome === "string" ? " this CLI does not know" : ""}, expected one of ${CANONICAL_OUTCOMES.map((o) => JSON.stringify(o)).join(", ")}`,
|
|
211
|
+
raw
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
kind: requiredString(entry.kind, `${field}.kind`, raw),
|
|
216
|
+
name: requiredString(entry.name, `${field}.name`, raw),
|
|
217
|
+
guid: optionalString(entry.guid),
|
|
218
|
+
requested: optionalString(entry.requested),
|
|
219
|
+
served: optionalString(entry.served),
|
|
220
|
+
outcome
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function decodePlan(value, raw) {
|
|
224
|
+
if (!isRecord(value)) throw malformed("plan", kindOf(value), raw);
|
|
225
|
+
if (!isRecord(value.summary)) throw malformed("plan.summary", kindOf(value.summary), raw);
|
|
226
|
+
if (!Array.isArray(value.operations)) {
|
|
227
|
+
throw malformed("plan.operations", kindOf(value.operations), raw);
|
|
228
|
+
}
|
|
229
|
+
const operations = value.operations.map((entry) => {
|
|
230
|
+
const op = isRecord(entry) ? entry : {};
|
|
231
|
+
return {
|
|
232
|
+
type: typeof op.type === "string" ? op.type : "",
|
|
233
|
+
name: typeof op.name === "string" ? op.name : "",
|
|
234
|
+
action: typeof op.action === "string" ? op.action : "",
|
|
235
|
+
...typeof op.details === "string" ? { details: op.details } : {},
|
|
236
|
+
...typeof op.reason === "string" ? { reason: op.reason } : {}
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
summary: value.summary,
|
|
241
|
+
operations,
|
|
242
|
+
hasRecords: value.has_records === true,
|
|
243
|
+
hasEnv: value.has_env === true
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function decodeResponse(text, dryRun, where) {
|
|
247
|
+
let parsed;
|
|
248
|
+
try {
|
|
249
|
+
parsed = JSON.parse(text);
|
|
250
|
+
} catch {
|
|
251
|
+
const head = notJsonError(where.action, text, where.baseUrl).message;
|
|
252
|
+
const target = where.label ?? "the target";
|
|
253
|
+
throw new Error(
|
|
254
|
+
`${head}
|
|
255
|
+
` + (dryRun ? `A dry run writes nothing, so ${target} is untouched.` : `Whether the import ran cannot be read from that answer \u2014 it may or may not have landed, in whole or in part. Check ${target} before retrying.`)
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
const raw = {
|
|
259
|
+
raw: text,
|
|
260
|
+
target: where.label ?? "the target",
|
|
261
|
+
verb: "deploy",
|
|
262
|
+
answer: dryRun ? "preview" : "write"
|
|
263
|
+
};
|
|
264
|
+
if (!isRecord(parsed)) throw malformed("response", kindOf(parsed), raw);
|
|
265
|
+
if (typeof parsed.applied !== "boolean") {
|
|
266
|
+
throw malformed("applied", kindOf(parsed.applied), raw);
|
|
267
|
+
}
|
|
268
|
+
if (parsed.applied !== !dryRun) {
|
|
269
|
+
throw malformed(
|
|
270
|
+
"applied",
|
|
271
|
+
dryRun ? `a dry run must not report \`applied: true\` \u2014 something may have been written` : `an import reported \`applied: false\` with a success status, so it is not knowable whether anything landed`,
|
|
272
|
+
// A preview that says it applied is no longer a preview: it may have written.
|
|
273
|
+
{ ...raw, answer: "write" }
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
if (!Array.isArray(parsed.conflicts)) throw malformed("conflicts", kindOf(parsed.conflicts), raw);
|
|
277
|
+
if (!Array.isArray(parsed.canonicals)) throw malformed("canonicals", kindOf(parsed.canonicals), raw);
|
|
278
|
+
const workspace = isRecord(parsed.workspace) ? parsed.workspace : {};
|
|
279
|
+
return {
|
|
280
|
+
workspace: {
|
|
281
|
+
id: typeof workspace.id === "number" ? workspace.id : void 0,
|
|
282
|
+
name: optionalString(workspace.name)
|
|
283
|
+
},
|
|
284
|
+
branch: requiredString(parsed.branch, "branch", raw),
|
|
285
|
+
applied: parsed.applied,
|
|
286
|
+
plan: decodePlan(parsed.plan, raw),
|
|
287
|
+
conflicts: parsed.conflicts.map((entry, i) => decodeConflict(entry, i, raw)),
|
|
288
|
+
canonicals: parsed.canonicals.map((entry, i) => decodeCanonical(entry, i, raw)),
|
|
289
|
+
...decodeHostedFiles(parsed.hosted_files),
|
|
290
|
+
raw: text
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function decodeHostedFiles(value) {
|
|
294
|
+
if (!isRecord(value)) return {};
|
|
295
|
+
const { resolved, unresolved } = value;
|
|
296
|
+
if (!Number.isInteger(resolved) || !Number.isInteger(unresolved)) return {};
|
|
297
|
+
return { hostedFiles: { resolved, unresolved } };
|
|
298
|
+
}
|
|
299
|
+
function hostedReferencesOf(archive) {
|
|
300
|
+
const entries = readArchiveEntries(archive);
|
|
301
|
+
const referenced = /* @__PURE__ */ new Map();
|
|
302
|
+
const carried = /* @__PURE__ */ new Set();
|
|
303
|
+
let icons = 0;
|
|
304
|
+
for (const name of Object.keys(entries)) {
|
|
305
|
+
const m = /^vault\/([^/]+)\//.exec(name);
|
|
306
|
+
if (m) carried.add(m[1]);
|
|
307
|
+
}
|
|
308
|
+
const parse = (raw) => {
|
|
309
|
+
if (raw === void 0) return void 0;
|
|
310
|
+
try {
|
|
311
|
+
return JSON.parse(raw.toString("utf8")).payload;
|
|
312
|
+
} catch {
|
|
313
|
+
return void 0;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const payload = parse(entries["workspace.json"]);
|
|
317
|
+
if (isRecord(payload)) {
|
|
318
|
+
for (const key of HOSTED_ICON_KINDS) {
|
|
319
|
+
const objects = payload[key];
|
|
320
|
+
if (!Array.isArray(objects)) continue;
|
|
321
|
+
for (const obj of objects) {
|
|
322
|
+
const list = isRecord(obj) ? obj.icons : void 0;
|
|
323
|
+
if (!Array.isArray(list)) continue;
|
|
324
|
+
for (const icon of list) {
|
|
325
|
+
if (!isRecord(icon) || typeof icon.src !== "string" || !icon.src.startsWith(HOSTED_FILE_SCHEME)) continue;
|
|
326
|
+
icons++;
|
|
327
|
+
const [canonical = "", file = ""] = icon.src.slice(HOSTED_FILE_SCHEME.length).split("/");
|
|
328
|
+
referenced.set(canonical, decodeURIComponent(file));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const noteRowValue = (value) => {
|
|
334
|
+
const path = isRecord(value) ? value.path : void 0;
|
|
335
|
+
if (typeof path !== "string" || !path.startsWith(HOSTED_ROW_PATH_PREFIX)) return;
|
|
336
|
+
const [canonical = "", , file = ""] = path.slice(HOSTED_ROW_PATH_PREFIX.length).split("/");
|
|
337
|
+
referenced.set(canonical, decodeURIComponent(file));
|
|
338
|
+
};
|
|
339
|
+
for (const [name, raw] of Object.entries(entries)) {
|
|
340
|
+
if (!name.startsWith("content/")) continue;
|
|
341
|
+
const rows = parse(raw);
|
|
342
|
+
if (!Array.isArray(rows)) continue;
|
|
343
|
+
for (const row of rows) {
|
|
344
|
+
if (!isRecord(row)) continue;
|
|
345
|
+
for (const value of Object.values(row)) {
|
|
346
|
+
if (Array.isArray(value)) value.forEach(noteRowValue);
|
|
347
|
+
else noteRowValue(value);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return { icons, referenced, carried };
|
|
352
|
+
}
|
|
353
|
+
function hostedReferencesIn(archive) {
|
|
354
|
+
return hostedReferencesOf(archive).icons;
|
|
355
|
+
}
|
|
356
|
+
function assertHostedFilesCarried(archive, where) {
|
|
357
|
+
const { referenced, carried } = hostedReferencesOf(archive);
|
|
358
|
+
const missing = [...referenced].filter(([canonical]) => !carried.has(canonical)).map(([, name]) => name || "(unnamed)");
|
|
359
|
+
if (missing.length === 0) return;
|
|
360
|
+
throw new ImportNotSentError(
|
|
361
|
+
`This archive references ${missing.length === 1 ? "a hostedFile()" : `${missing.length} hostedFile()s`} it does not carry (${[...new Set(missing)].join(", ")}), so ${where.label ?? "the target"} would store fields pointing at nothing. A bundle written by \`xanosdk export\` or built in a browser carries no hosted files: deploy from an entry file that reads each with \`hostedFile("./<file>", import.meta.url)\`, so the bytes ship with it \u2014 a literal \`xanosdk-file://\` src in source carries none, so save the image in the repo and write the hostedFile() line in its place. Nothing was sent.`,
|
|
362
|
+
false
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
var HostedFilesUnresolvedError = class extends Error {
|
|
366
|
+
constructor(message, applied) {
|
|
367
|
+
super(message);
|
|
368
|
+
this.applied = applied;
|
|
369
|
+
this.name = "HostedFilesUnresolvedError";
|
|
370
|
+
}
|
|
371
|
+
applied;
|
|
372
|
+
};
|
|
373
|
+
function assertHostedFilesResolved(res, expected, where) {
|
|
374
|
+
if (expected === 0) return;
|
|
375
|
+
const target = where.label ?? "the target";
|
|
376
|
+
const done = res.applied ? "The import has already been applied" : "This preview wrote nothing";
|
|
377
|
+
if (res.hostedFiles === void 0) {
|
|
378
|
+
throw new HostedFilesUnresolvedError(
|
|
379
|
+
`${target} did not report \`hosted_files\` for an archive carrying ${expected} hostedFile() reference${expected === 1 ? "" : "s"}, so it cannot be shown that any of them point at a file there. This instance does not support hostedFile() yet. ${done}${res.applied ? "; redeploy once the instance is updated, or remove the hostedFile() references" : ""}.`,
|
|
380
|
+
res.applied
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
if (res.hostedFiles.resolved < expected || res.hostedFiles.unresolved > 0) {
|
|
384
|
+
throw new HostedFilesUnresolvedError(
|
|
385
|
+
`${target} resolved ${res.hostedFiles.resolved} of the ${expected} hostedFile() references in this archive (${res.hostedFiles.unresolved} unresolved), so a field would point at nothing. ${done}.`,
|
|
386
|
+
res.applied
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function decodeRefusal(status, raw, baseUrl, label) {
|
|
391
|
+
let parsed;
|
|
392
|
+
try {
|
|
393
|
+
parsed = JSON.parse(raw);
|
|
394
|
+
} catch {
|
|
395
|
+
return void 0;
|
|
396
|
+
}
|
|
397
|
+
if (!isRecord(parsed)) return void 0;
|
|
398
|
+
const payload = isRecord(parsed.payload) ? parsed.payload : {};
|
|
399
|
+
const code = optionalString(payload.reason);
|
|
400
|
+
if (code === void 0) return void 0;
|
|
401
|
+
const reason = optionalString(parsed.message) ?? code;
|
|
402
|
+
let conflicts = [];
|
|
403
|
+
let canonicals = [];
|
|
404
|
+
let undecoded;
|
|
405
|
+
const ctx = { raw, target: label ?? "the target", verb: "deploy", answer: "refusal" };
|
|
406
|
+
try {
|
|
407
|
+
conflicts = Array.isArray(payload.conflicts) ? payload.conflicts.map((e, i) => decodeConflict(e, i, ctx)) : [];
|
|
408
|
+
canonicals = Array.isArray(payload.canonicals) ? payload.canonicals.map((e, i) => decodeCanonical(e, i, ctx)) : [];
|
|
409
|
+
} catch (err) {
|
|
410
|
+
conflicts = [];
|
|
411
|
+
canonicals = [];
|
|
412
|
+
undecoded = err instanceof Error ? err.message : String(err);
|
|
413
|
+
}
|
|
414
|
+
const detail = undecoded === void 0 ? "" : `
|
|
415
|
+
The refusal's detail could not be decoded, so it is not listed below:
|
|
416
|
+
${undecoded}`;
|
|
417
|
+
return new XanoSdkImportRefusal(
|
|
418
|
+
status,
|
|
419
|
+
code,
|
|
420
|
+
reason,
|
|
421
|
+
conflicts,
|
|
422
|
+
canonicals,
|
|
423
|
+
raw,
|
|
424
|
+
`The instance refused this import (${status} ${code}): ${reason}
|
|
425
|
+
instance: ${baseUrl}
|
|
426
|
+
The route computes every conflict BEFORE it writes, so nothing was applied.${detail}`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
async function post(auth, url, opts, action) {
|
|
430
|
+
const fetchFn = opts.fetchFn ?? fetch;
|
|
431
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
432
|
+
const writes = !opts.dryRun;
|
|
433
|
+
const attempts = writes ? 1 : READ_ATTEMPTS;
|
|
434
|
+
let res;
|
|
435
|
+
let failure;
|
|
436
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
437
|
+
try {
|
|
438
|
+
const send = () => fetchFn(url, {
|
|
439
|
+
method: "POST",
|
|
440
|
+
headers: { accept: "application/json", Authorization: `Bearer ${auth.access_token}` },
|
|
441
|
+
body: body(opts.archive),
|
|
442
|
+
signal: AbortSignal.timeout(IMPORT_TIMEOUT_MS)
|
|
443
|
+
});
|
|
444
|
+
res = writes ? await describeWrite(
|
|
445
|
+
{
|
|
446
|
+
...opts.label === void 0 ? {} : { what: `the ${opts.mode === "merge" ? "merge" : "import"} into ${opts.label}` },
|
|
447
|
+
...opts.stateCheck === void 0 ? {} : { check: opts.stateCheck }
|
|
448
|
+
},
|
|
449
|
+
send
|
|
450
|
+
) : await send();
|
|
451
|
+
await noteMetaAnswer(url, res);
|
|
452
|
+
noteRateLimit(res);
|
|
453
|
+
break;
|
|
454
|
+
} catch (err) {
|
|
455
|
+
failure = err;
|
|
456
|
+
if (isTimeoutError(err) || attempt === attempts - 1) break;
|
|
457
|
+
await sleep(READ_BACKOFF_MS * 2 ** attempt);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
const target = opts.label ?? "the target";
|
|
461
|
+
const aftermath = !writes ? `A dry run writes nothing, so ${target} is untouched. Retry when the instance is reachable.` : opts.mode === "replace" ? `The request did not complete, so the import may or may not have landed, in whole or in part. A replace rewrites all of ${target}, so it is safe to run again once the instance is reachable.` : `The request did not complete, so the import may or may not have landed, in whole or in part.` + (opts.stateCheck !== void 0 ? ` ${opts.stateCheck}` : "");
|
|
462
|
+
const where = `${transportTarget(url)}${opts.label !== void 0 ? ` (${opts.label})` : ""}`;
|
|
463
|
+
if (res === void 0) {
|
|
464
|
+
const { classifyFailure } = await import("./operation-outcome-TZSESNC7.js");
|
|
465
|
+
if (writes && !isTimeoutError(failure) && classifyFailure(failure, { writeSent: true }) === "no") {
|
|
466
|
+
const untrusted = certificateFailureCode(failure) !== void 0;
|
|
467
|
+
throw new ImportNotSentError(
|
|
468
|
+
`${closeSentence(`${action} could not reach ${where}: ${describeTransportFailure(failure)}`)}
|
|
469
|
+
Nothing was sent, so ${target} is untouched${untrusted ? "." : " \u2014 retry once the instance is reachable."}`,
|
|
470
|
+
false,
|
|
471
|
+
{ cause: failure }
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
const head = `${action} could not reach ${where}: ${describeTransportFailure(failure)}`;
|
|
475
|
+
throw new TransportError(`${closeSentence(writes ? lostAnswerHead(head, failure) : head)}
|
|
476
|
+
${aftermath}`, isTimeoutError(failure), {
|
|
477
|
+
cause: failure
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
let text;
|
|
481
|
+
try {
|
|
482
|
+
text = await res.text();
|
|
483
|
+
} catch (err) {
|
|
484
|
+
const lost = explainBodyFailure(err, { url, what: action, timeoutMs: IMPORT_TIMEOUT_MS, aftermath, display: where });
|
|
485
|
+
throw lost;
|
|
486
|
+
}
|
|
487
|
+
if (!res.ok) {
|
|
488
|
+
const refusal = decodeRefusal(res.status, text, opts.baseUrl, opts.label);
|
|
489
|
+
if (refusal !== void 0) throw refusal;
|
|
490
|
+
throw new ImportHttpError(
|
|
491
|
+
res.status,
|
|
492
|
+
action,
|
|
493
|
+
res.statusText,
|
|
494
|
+
text,
|
|
495
|
+
writes ? writeStatusAftermath(res.status, aftermath, { atomic: opts.mode === void 0 || opts.mode === "replace" }) : void 0
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
return text;
|
|
499
|
+
}
|
|
500
|
+
function assertXanoSdkBranchHonored(res, requested, baseUrl) {
|
|
501
|
+
if (res.branch === requested) return;
|
|
502
|
+
throw new Error(
|
|
503
|
+
`Refusing to deploy to branch "${requested}": the instance planned against "${res.branch}".
|
|
504
|
+
instance: ${baseUrl}
|
|
505
|
+
A deploy that looked staged would have written to a different branch, which is not recoverable \u2014 so it is not attempted against an instance that has not confirmed the target.`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
var DEFAULT_BRANCH_ID = 0;
|
|
509
|
+
function withDefaultBranchPointer(archive) {
|
|
510
|
+
const entries = readArchiveEntries(archive);
|
|
511
|
+
const raw = entries["workspace.json"];
|
|
512
|
+
if (raw === void 0) return archive;
|
|
513
|
+
const envelope = JSON.parse(raw.toString("utf8"));
|
|
514
|
+
const payload = envelope.payload;
|
|
515
|
+
const workspace = payload?.workspace;
|
|
516
|
+
if (payload === void 0 || workspace === void 0) return archive;
|
|
517
|
+
const branch = workspace.branch;
|
|
518
|
+
if (branch?.id === DEFAULT_BRANCH_ID) return archive;
|
|
519
|
+
const held = signatureHolds(raw.toString("utf8"));
|
|
520
|
+
const { sig: stored, ...unsigned } = envelope;
|
|
521
|
+
const pinned = {
|
|
522
|
+
...unsigned,
|
|
523
|
+
payload: { ...payload, workspace: { ...workspace, branch: { id: DEFAULT_BRANCH_ID } } }
|
|
524
|
+
};
|
|
525
|
+
const signed = held === void 0 ? pinned : { ...pinned, sig: held ? calcSignatureJson(pinned) : stored };
|
|
526
|
+
const files = [{ name: "workspace.json", data: Buffer.from(JSON.stringify(signed), "utf8") }];
|
|
527
|
+
for (const [name, data] of Object.entries(entries)) {
|
|
528
|
+
if (name !== "workspace.json") files.push({ name, data });
|
|
529
|
+
}
|
|
530
|
+
return tarGz(files);
|
|
531
|
+
}
|
|
532
|
+
async function xanosdkImport(auth, opts) {
|
|
533
|
+
const action = opts.dryRun ? "The deploy preview" : "The deploy";
|
|
534
|
+
const replaces = opts.mode === void 0 || opts.mode === "replace";
|
|
535
|
+
const sent = replaces ? { ...opts, archive: withDefaultBranchPointer(opts.archive) } : opts;
|
|
536
|
+
assertHostedFilesCarried(sent.archive, { label: opts.label });
|
|
537
|
+
const text = await post(auth, endpoint(sent, query(sent)), sent, action);
|
|
538
|
+
const decoded = decodeResponse(text, opts.dryRun, { action, baseUrl: opts.baseUrl, label: opts.label });
|
|
539
|
+
if (opts.branch !== void 0) assertXanoSdkBranchHonored(decoded, opts.branch, opts.baseUrl);
|
|
540
|
+
assertHostedFilesResolved(decoded, hostedReferencesIn(opts.archive), { label: opts.label });
|
|
541
|
+
return decoded;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export {
|
|
545
|
+
XANOSDK_IMPORT_CONFLICT_CODE,
|
|
546
|
+
XANOSDK_IMPORT_IN_PROGRESS_CODE,
|
|
547
|
+
XANOSDK_IMPORT_UNIQUENESS_CODE,
|
|
548
|
+
XANOSDK_IMPORT_UNRESOLVED_FILE_CODE,
|
|
549
|
+
ImportNotSentError,
|
|
550
|
+
XanoSdkImportRefusal,
|
|
551
|
+
resetXanoSdkImportDetection,
|
|
552
|
+
detectXanoSdkImportRoute,
|
|
553
|
+
hostedReferencesOf,
|
|
554
|
+
hostedReferencesIn,
|
|
555
|
+
HostedFilesUnresolvedError,
|
|
556
|
+
assertXanoSdkBranchHonored,
|
|
557
|
+
withDefaultBranchPointer,
|
|
558
|
+
xanosdkImport
|
|
559
|
+
};
|
|
560
|
+
//# sourceMappingURL=chunk-WQFNASK4.js.map
|