@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,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
debugEnabled,
|
|
3
|
+
fetchReadOrExplain,
|
|
4
|
+
parseJsonAnswer,
|
|
5
|
+
serverMessage,
|
|
6
|
+
transportTarget
|
|
7
|
+
} from "./chunk-YLDALTWZ.js";
|
|
8
|
+
import "./chunk-QXTKSOFI.js";
|
|
9
|
+
import "./chunk-X2NL4KUO.js";
|
|
10
|
+
import "./chunk-PTHVMXZI.js";
|
|
11
|
+
import "./chunk-UTI5G6OJ.js";
|
|
12
|
+
import "./chunk-2EZ3ZJZZ.js";
|
|
13
|
+
import "./chunk-5ZSO4T2G.js";
|
|
14
|
+
import "./chunk-TFFGOFVZ.js";
|
|
15
|
+
import "./chunk-36JUQZVQ.js";
|
|
16
|
+
import "./chunk-PZ5AY32C.js";
|
|
17
|
+
|
|
18
|
+
// src/deploy/workspace.ts
|
|
19
|
+
var RESOLVE_TIMEOUT_MS = 3e4;
|
|
20
|
+
var AmbiguousWorkspace = class extends Error {
|
|
21
|
+
};
|
|
22
|
+
async function resolveScopedWorkspaceId(auth, opts = {}) {
|
|
23
|
+
const again = opts.again ?? "xanosdk login";
|
|
24
|
+
try {
|
|
25
|
+
return await lookup(auth);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
const said = (err instanceof Error ? err.message : String(err)).trimEnd();
|
|
28
|
+
const reason = /[.?!]$/.test(said) ? said.slice(0, -1) + (said.endsWith("?") ? "?" : "") : said;
|
|
29
|
+
const lead = opts.again === void 0 ? "Reading the workspace this token is scoped to failed" : "Signed in, but reading your workspace failed";
|
|
30
|
+
const remedy = err instanceof AmbiguousWorkspace ? `Run \`${again}\` again and pick a single workspace at the consent screen. There is no workspace override \u2014 a credential addresses exactly one workspace.` : opts.again === void 0 ? "" : `Nothing was saved \u2014 run \`${again}\` again.`;
|
|
31
|
+
if (opts.again === void 0) {
|
|
32
|
+
const unanswered = await unansweredAfterExchange(lead, reason, err);
|
|
33
|
+
if (unanswered !== void 0) throw unanswered;
|
|
34
|
+
}
|
|
35
|
+
const end = reason.endsWith("?") ? "" : ".";
|
|
36
|
+
throw new Error(`${lead}: ${reason}${end}${remedy === "" ? "" : ` ${remedy}`}`, { cause: err });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function unansweredAfterExchange(lead, reason, err) {
|
|
40
|
+
const { isUnansweredLookup, LookupFailedError, unansweredCause } = await import("./source-resolve-S2XA3XZF.js");
|
|
41
|
+
if (!isUnansweredLookup(err)) return void 0;
|
|
42
|
+
const head = (reason.split("\n")[0] ?? reason).trim().replace(/[.:]$/, "");
|
|
43
|
+
const failed = new LookupFailedError(
|
|
44
|
+
`${lead}: ${head}. ${unansweredCause(err)} \u2014 nothing was changed`,
|
|
45
|
+
"unreachable",
|
|
46
|
+
"workspace"
|
|
47
|
+
);
|
|
48
|
+
failed.trailer = " The XANO_REFRESH_TOKEN exchange before this lookup succeeded, and a refresh token is single-use, so that token is spent: set XANO_REFRESH_TOKEN to a fresh one (and XANO_CLIENT_ID to the client it was minted for) before the rerun.";
|
|
49
|
+
failed.message += failed.trailer;
|
|
50
|
+
failed.cause = err;
|
|
51
|
+
return failed;
|
|
52
|
+
}
|
|
53
|
+
async function lookup(auth) {
|
|
54
|
+
const url = new URL("/api:meta/auth/me", auth.instance);
|
|
55
|
+
const res = await fetchReadOrExplain(
|
|
56
|
+
url.href,
|
|
57
|
+
{
|
|
58
|
+
headers: { Authorization: `Bearer ${auth.access_token}` },
|
|
59
|
+
signal: AbortSignal.timeout(RESOLVE_TIMEOUT_MS)
|
|
60
|
+
},
|
|
61
|
+
"the workspace lookup",
|
|
62
|
+
RESOLVE_TIMEOUT_MS
|
|
63
|
+
);
|
|
64
|
+
const text = await res.text();
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
const said = serverMessage(text);
|
|
67
|
+
const head = `${transportTarget(url.href)} answered HTTP ${res.status}${said === void 0 ? "" : ` \u2014 ${said}`}`;
|
|
68
|
+
throw Object.assign(new Error(debugEnabled() && text.trim() !== "" ? `${head}
|
|
69
|
+
${text}` : head), {
|
|
70
|
+
status: res.status
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const data = parseJsonAnswer(text, "the workspace lookup", url.href) ?? {};
|
|
74
|
+
const extras = data.extras ?? {};
|
|
75
|
+
const oauth = extras.oauth ?? {};
|
|
76
|
+
const instance = extras.instance ?? {};
|
|
77
|
+
const membership = instance.membership ?? {};
|
|
78
|
+
const list = Array.isArray(membership.workspace) ? membership.workspace : [];
|
|
79
|
+
const scopedGuid = typeof oauth.workspace === "string" ? oauth.workspace : void 0;
|
|
80
|
+
if (scopedGuid !== void 0 && scopedGuid !== "") {
|
|
81
|
+
const match = list.find((w) => w.guid === scopedGuid);
|
|
82
|
+
if (match !== void 0 && typeof match.id === "number") return match.id;
|
|
83
|
+
}
|
|
84
|
+
const ids = list.filter((w) => typeof w.id === "number");
|
|
85
|
+
if (ids.length === 1) return ids[0].id;
|
|
86
|
+
throw new AmbiguousWorkspace(
|
|
87
|
+
`could not resolve which workspace this token is scoped to (scoped workspace ${scopedGuid ?? "(none)"} not found among ${ids.length} membership workspaces)`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
resolveScopedWorkspaceId
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=workspace-2CLHU2LK.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
heldElsewhereError,
|
|
3
|
+
reachableInline,
|
|
4
|
+
reachableLines,
|
|
5
|
+
reachableWorkspaces,
|
|
6
|
+
readReachableWorkspaces,
|
|
7
|
+
refuseUnreachableWorkspace,
|
|
8
|
+
rerunInWorkspace,
|
|
9
|
+
unreachableWorkspaceMessage,
|
|
10
|
+
whereaboutsOf,
|
|
11
|
+
workspaceIdFix
|
|
12
|
+
} from "./chunk-KTSDSD36.js";
|
|
13
|
+
import "./chunk-ET4Y4XCB.js";
|
|
14
|
+
import "./chunk-5QU2P5CA.js";
|
|
15
|
+
import "./chunk-ZYJP6BOO.js";
|
|
16
|
+
import "./chunk-QO6BVGS5.js";
|
|
17
|
+
import "./chunk-JZGVVJSI.js";
|
|
18
|
+
import "./chunk-NAQDMEHV.js";
|
|
19
|
+
import "./chunk-FWD7AL6N.js";
|
|
20
|
+
import "./chunk-TLQE7ZN3.js";
|
|
21
|
+
import "./chunk-XW6KISBB.js";
|
|
22
|
+
import "./chunk-AWQ7BQTQ.js";
|
|
23
|
+
import "./chunk-EUUUMY7J.js";
|
|
24
|
+
import "./chunk-YLDALTWZ.js";
|
|
25
|
+
import "./chunk-5FBYXK5P.js";
|
|
26
|
+
import "./chunk-LLNZGEFK.js";
|
|
27
|
+
import "./chunk-QXTKSOFI.js";
|
|
28
|
+
import "./chunk-X2NL4KUO.js";
|
|
29
|
+
import "./chunk-PTHVMXZI.js";
|
|
30
|
+
import "./chunk-UTI5G6OJ.js";
|
|
31
|
+
import "./chunk-2EZ3ZJZZ.js";
|
|
32
|
+
import "./chunk-6MR5TI5V.js";
|
|
33
|
+
import "./chunk-5ZSO4T2G.js";
|
|
34
|
+
import "./chunk-XNCP4KYO.js";
|
|
35
|
+
import "./chunk-TFFGOFVZ.js";
|
|
36
|
+
import "./chunk-NZOWWHU5.js";
|
|
37
|
+
import "./chunk-4BW2SG2N.js";
|
|
38
|
+
import "./chunk-CIMQZRRE.js";
|
|
39
|
+
import "./chunk-OHX6MIUZ.js";
|
|
40
|
+
import "./chunk-36JUQZVQ.js";
|
|
41
|
+
import "./chunk-PZ5AY32C.js";
|
|
42
|
+
export {
|
|
43
|
+
heldElsewhereError,
|
|
44
|
+
reachableInline,
|
|
45
|
+
reachableLines,
|
|
46
|
+
reachableWorkspaces,
|
|
47
|
+
readReachableWorkspaces,
|
|
48
|
+
refuseUnreachableWorkspace,
|
|
49
|
+
rerunInWorkspace,
|
|
50
|
+
unreachableWorkspaceMessage,
|
|
51
|
+
whereaboutsOf,
|
|
52
|
+
workspaceIdFix
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=workspace-binding-56PIIPCP.js.map
|
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchWorkspaceBundle
|
|
3
|
+
} from "./chunk-X677DMZM.js";
|
|
4
|
+
import "./chunk-LRN4ZJCQ.js";
|
|
5
|
+
import "./chunk-RTJRZFFY.js";
|
|
6
|
+
import {
|
|
7
|
+
printMicroserviceSection,
|
|
8
|
+
readMicroservices
|
|
9
|
+
} from "./chunk-FXRQOWTE.js";
|
|
10
|
+
import {
|
|
11
|
+
confirm
|
|
12
|
+
} from "./chunk-65HWOMGV.js";
|
|
13
|
+
import "./chunk-TPHWJ7UG.js";
|
|
14
|
+
import {
|
|
15
|
+
listTables
|
|
16
|
+
} from "./chunk-C6RIMRU4.js";
|
|
17
|
+
import "./chunk-AOSYVMUS.js";
|
|
18
|
+
import "./chunk-CJHQKJU4.js";
|
|
19
|
+
import "./chunk-3DRXWLJ5.js";
|
|
20
|
+
import "./chunk-X4DVXBFY.js";
|
|
21
|
+
import {
|
|
22
|
+
listBranches
|
|
23
|
+
} from "./chunk-TRJCALW3.js";
|
|
24
|
+
import {
|
|
25
|
+
reachableWorkspaces,
|
|
26
|
+
refuseUnreachableWorkspace,
|
|
27
|
+
unreachableWorkspaceMessage
|
|
28
|
+
} from "./chunk-KTSDSD36.js";
|
|
29
|
+
import "./chunk-LIEOKXKD.js";
|
|
30
|
+
import "./chunk-D7VGG3WS.js";
|
|
31
|
+
import "./chunk-2TFRR6JV.js";
|
|
32
|
+
import {
|
|
33
|
+
resolveOutputTarget,
|
|
34
|
+
secretsPhrase,
|
|
35
|
+
writeExportFile
|
|
36
|
+
} from "./chunk-SAVJUS2X.js";
|
|
37
|
+
import {
|
|
38
|
+
secretsCarriedBy
|
|
39
|
+
} from "./chunk-45UIT5T2.js";
|
|
40
|
+
import "./chunk-HRVBLCVJ.js";
|
|
41
|
+
import "./chunk-YHEFQUQB.js";
|
|
42
|
+
import {
|
|
43
|
+
assertBundleFile,
|
|
44
|
+
assertBundleInput,
|
|
45
|
+
assertEntryFile,
|
|
46
|
+
assertValueFiles,
|
|
47
|
+
loadBundleText
|
|
48
|
+
} from "./chunk-ETO6LGLD.js";
|
|
49
|
+
import "./chunk-ZIY7RNUT.js";
|
|
50
|
+
import "./chunk-DAD3ONIS.js";
|
|
51
|
+
import "./chunk-HHN734BU.js";
|
|
52
|
+
import "./chunk-LPECSJ2J.js";
|
|
53
|
+
import "./chunk-6NNTNXN7.js";
|
|
54
|
+
import "./chunk-QCNYHBL7.js";
|
|
55
|
+
import "./chunk-2ZUEE4EK.js";
|
|
56
|
+
import "./chunk-AN6BL47T.js";
|
|
57
|
+
import {
|
|
58
|
+
getAccessToken
|
|
59
|
+
} from "./chunk-ET4Y4XCB.js";
|
|
60
|
+
import "./chunk-SWBF2LTK.js";
|
|
61
|
+
import "./chunk-UZ6QQWJT.js";
|
|
62
|
+
import "./chunk-A3UDOZB6.js";
|
|
63
|
+
import "./chunk-2MNLRIOX.js";
|
|
64
|
+
import "./chunk-3M4LFYNQ.js";
|
|
65
|
+
import "./chunk-AM4FKL4J.js";
|
|
66
|
+
import "./chunk-Q325JKYB.js";
|
|
67
|
+
import "./chunk-STSFNCY4.js";
|
|
68
|
+
import "./chunk-I4F5TCJH.js";
|
|
69
|
+
import "./chunk-5QU2P5CA.js";
|
|
70
|
+
import "./chunk-ZYJP6BOO.js";
|
|
71
|
+
import "./chunk-QO6BVGS5.js";
|
|
72
|
+
import "./chunk-JZGVVJSI.js";
|
|
73
|
+
import "./chunk-7G3CTU7I.js";
|
|
74
|
+
import "./chunk-6PBR37LN.js";
|
|
75
|
+
import {
|
|
76
|
+
yesRerun
|
|
77
|
+
} from "./chunk-T5KELPAR.js";
|
|
78
|
+
import "./chunk-622HUCZT.js";
|
|
79
|
+
import {
|
|
80
|
+
contextFlags
|
|
81
|
+
} from "./chunk-NAQDMEHV.js";
|
|
82
|
+
import "./chunk-5A2PLKZB.js";
|
|
83
|
+
import "./chunk-AHJWCYQO.js";
|
|
84
|
+
import "./chunk-DX4QR4B2.js";
|
|
85
|
+
import "./chunk-6QXLMMT3.js";
|
|
86
|
+
import "./chunk-ZFDZKNGG.js";
|
|
87
|
+
import "./chunk-FWD7AL6N.js";
|
|
88
|
+
import "./chunk-2GNFDZA2.js";
|
|
89
|
+
import "./chunk-JTUKLCXS.js";
|
|
90
|
+
import {
|
|
91
|
+
describeWrite
|
|
92
|
+
} from "./chunk-4KHEMC32.js";
|
|
93
|
+
import "./chunk-U64O2MXY.js";
|
|
94
|
+
import "./chunk-ROY4YAEQ.js";
|
|
95
|
+
import "./chunk-P2HAGF6H.js";
|
|
96
|
+
import "./chunk-TLQE7ZN3.js";
|
|
97
|
+
import "./chunk-WRBKLYSJ.js";
|
|
98
|
+
import "./chunk-3LDULPRE.js";
|
|
99
|
+
import "./chunk-XW6KISBB.js";
|
|
100
|
+
import {
|
|
101
|
+
writeData
|
|
102
|
+
} from "./chunk-AWQ7BQTQ.js";
|
|
103
|
+
import "./chunk-EUUUMY7J.js";
|
|
104
|
+
import {
|
|
105
|
+
bindingFor,
|
|
106
|
+
fetchOrExplain,
|
|
107
|
+
httpFailure,
|
|
108
|
+
parseJsonAnswer
|
|
109
|
+
} from "./chunk-YLDALTWZ.js";
|
|
110
|
+
import "./chunk-5FBYXK5P.js";
|
|
111
|
+
import "./chunk-LLNZGEFK.js";
|
|
112
|
+
import "./chunk-QXTKSOFI.js";
|
|
113
|
+
import "./chunk-X2NL4KUO.js";
|
|
114
|
+
import "./chunk-3KZCLN4Z.js";
|
|
115
|
+
import "./chunk-FXFV3KU6.js";
|
|
116
|
+
import "./chunk-OPHB5ORL.js";
|
|
117
|
+
import "./chunk-UCQ2VUTG.js";
|
|
118
|
+
import "./chunk-DGWHAVRG.js";
|
|
119
|
+
import "./chunk-27GWNP2I.js";
|
|
120
|
+
import "./chunk-3YW23UFH.js";
|
|
121
|
+
import "./chunk-JGE7CAWB.js";
|
|
122
|
+
import {
|
|
123
|
+
UsageError,
|
|
124
|
+
blank,
|
|
125
|
+
credentialWriteTarget,
|
|
126
|
+
detail,
|
|
127
|
+
discloseWriteTarget,
|
|
128
|
+
error,
|
|
129
|
+
formatFields,
|
|
130
|
+
info,
|
|
131
|
+
isMachineOutput,
|
|
132
|
+
printHuman,
|
|
133
|
+
stdoutStyle,
|
|
134
|
+
step,
|
|
135
|
+
success,
|
|
136
|
+
tablesCommand,
|
|
137
|
+
unknownSubcommand,
|
|
138
|
+
warn,
|
|
139
|
+
writeJson,
|
|
140
|
+
writeTargetPayload
|
|
141
|
+
} from "./chunk-PTHVMXZI.js";
|
|
142
|
+
import "./chunk-MXHSQOC4.js";
|
|
143
|
+
import "./chunk-6IUMKYWI.js";
|
|
144
|
+
import "./chunk-2CMJZDCL.js";
|
|
145
|
+
import "./chunk-CTMO46PK.js";
|
|
146
|
+
import "./chunk-ZDPP6RKB.js";
|
|
147
|
+
import "./chunk-K5BBGTYZ.js";
|
|
148
|
+
import "./chunk-LQCMKAJ7.js";
|
|
149
|
+
import "./chunk-YGZHHAAB.js";
|
|
150
|
+
import "./chunk-XVBGLISP.js";
|
|
151
|
+
import "./chunk-6HO3NCSJ.js";
|
|
152
|
+
import "./chunk-5V5XU32D.js";
|
|
153
|
+
import "./chunk-GSGDWJB5.js";
|
|
154
|
+
import "./chunk-HVRUQXGD.js";
|
|
155
|
+
import "./chunk-ERVIASGL.js";
|
|
156
|
+
import "./chunk-4POWHT2K.js";
|
|
157
|
+
import "./chunk-H2V3N23D.js";
|
|
158
|
+
import "./chunk-3JDU4VRL.js";
|
|
159
|
+
import "./chunk-WTPZRR4I.js";
|
|
160
|
+
import "./chunk-UTI5G6OJ.js";
|
|
161
|
+
import "./chunk-2EZ3ZJZZ.js";
|
|
162
|
+
import "./chunk-6MR5TI5V.js";
|
|
163
|
+
import "./chunk-5ZSO4T2G.js";
|
|
164
|
+
import {
|
|
165
|
+
HOSTED_ROW_PATH_PREFIX
|
|
166
|
+
} from "./chunk-XNCP4KYO.js";
|
|
167
|
+
import "./chunk-AKNCFVKZ.js";
|
|
168
|
+
import "./chunk-YU4HSQW7.js";
|
|
169
|
+
import "./chunk-TFFGOFVZ.js";
|
|
170
|
+
import "./chunk-EHP3WPEG.js";
|
|
171
|
+
import "./chunk-L5JYN3NM.js";
|
|
172
|
+
import "./chunk-Q7DGTQ5G.js";
|
|
173
|
+
import "./chunk-G554NZNI.js";
|
|
174
|
+
import "./chunk-N5GKCWE5.js";
|
|
175
|
+
import "./chunk-OXA6PSZT.js";
|
|
176
|
+
import "./chunk-VAX3UZOY.js";
|
|
177
|
+
import "./chunk-NZOWWHU5.js";
|
|
178
|
+
import "./chunk-4BW2SG2N.js";
|
|
179
|
+
import "./chunk-TTEIYD5P.js";
|
|
180
|
+
import "./chunk-CIMQZRRE.js";
|
|
181
|
+
import "./chunk-OHX6MIUZ.js";
|
|
182
|
+
import "./chunk-36JUQZVQ.js";
|
|
183
|
+
import "./chunk-PZ5AY32C.js";
|
|
184
|
+
|
|
185
|
+
// src/emit/workspace-command.ts
|
|
186
|
+
var TIMEOUT_MS = 3e4;
|
|
187
|
+
var DEFAULT_NAME = "workspace";
|
|
188
|
+
async function runWorkspaceCommand(args) {
|
|
189
|
+
switch (args.subcommand) {
|
|
190
|
+
case "details":
|
|
191
|
+
return runDetails(args);
|
|
192
|
+
case "export":
|
|
193
|
+
return runExport(args);
|
|
194
|
+
case "diff":
|
|
195
|
+
return runDiff(args);
|
|
196
|
+
case "reset-tables":
|
|
197
|
+
return runResetTables(args);
|
|
198
|
+
case "branch": {
|
|
199
|
+
const { runBranchCommand } = await import("./branch-commands-ACIRCEQJ.js");
|
|
200
|
+
return runBranchCommand(args);
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
throw unknownSubcommand("workspace", args.subcommand, args.positionals);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function fetchWorkspaces(auth) {
|
|
207
|
+
const url = new URL("/api:meta/workspace", auth.instance);
|
|
208
|
+
const res = await fetchOrExplain(
|
|
209
|
+
url.href,
|
|
210
|
+
{
|
|
211
|
+
headers: { accept: "application/json", Authorization: `Bearer ${auth.access_token}` },
|
|
212
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
213
|
+
},
|
|
214
|
+
"workspace list",
|
|
215
|
+
TIMEOUT_MS
|
|
216
|
+
);
|
|
217
|
+
const text = await res.text();
|
|
218
|
+
if (!res.ok) {
|
|
219
|
+
throw Object.assign(new Error(httpFailure("workspace list", res, text)), { status: res.status });
|
|
220
|
+
}
|
|
221
|
+
const parsed = parseJsonAnswer(text, "workspace list", url.href);
|
|
222
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
223
|
+
}
|
|
224
|
+
async function runDetails(args) {
|
|
225
|
+
const auth = await getAccessToken(args);
|
|
226
|
+
const workspaceId = auth.workspaceId;
|
|
227
|
+
const all = await fetchWorkspaces(auth).catch(async (err) => {
|
|
228
|
+
const { unansweredRead } = await import("./source-resolve-S2XA3XZF.js");
|
|
229
|
+
throw unansweredRead(err, "read the workspace list", "workspace");
|
|
230
|
+
});
|
|
231
|
+
const match = all.find((w) => w.id === workspaceId);
|
|
232
|
+
if (!match) throw new UsageError(unreachableWorkspaceMessage(auth, reachableWorkspaces(all)));
|
|
233
|
+
const summary = {
|
|
234
|
+
instance: auth.instance,
|
|
235
|
+
id: workspaceId,
|
|
236
|
+
name: typeof match.name === "string" ? match.name : void 0,
|
|
237
|
+
guid: typeof match.guid === "string" ? match.guid : void 0,
|
|
238
|
+
/** Which credential this command is acting under — the only thing that selects a workspace. */
|
|
239
|
+
credential: auth.credentialType
|
|
240
|
+
};
|
|
241
|
+
const microservices = await readMicroservices(auth, auth.instance, workspaceId);
|
|
242
|
+
if (isMachineOutput(args)) {
|
|
243
|
+
writeJson({ ...summary, microservices, workspaceId, selector: "workspace" });
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const s = stdoutStyle();
|
|
247
|
+
const rows = [
|
|
248
|
+
["instance", summary.instance],
|
|
249
|
+
["workspace", `${summary.name === void 0 ? "(unnamed)" : summary.name} ${s.dim(`#${summary.id}`)}`]
|
|
250
|
+
];
|
|
251
|
+
if (summary.guid !== void 0) rows.push(["guid", summary.guid]);
|
|
252
|
+
rows.push([
|
|
253
|
+
"source",
|
|
254
|
+
summary.credential === "token" ? "your meta API token credential" : "your sign-in (pinned at login)"
|
|
255
|
+
]);
|
|
256
|
+
printHuman(formatFields(rows) + "\n");
|
|
257
|
+
printMicroserviceSection(microservices);
|
|
258
|
+
}
|
|
259
|
+
async function runExport(args) {
|
|
260
|
+
if (args.path === "-" && args.name !== void 0) {
|
|
261
|
+
throw new UsageError(
|
|
262
|
+
"`--name` names the exported file, and `--path -` writes the bundle to stdout instead of a file. Drop one: `--path -` to pipe it, or `--name` (with or without a `--path` directory) to write a file.",
|
|
263
|
+
{ hintFor: { command: "workspace", subcommand: "export" } }
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const target = resolveOutputTarget({ path: args.path, name: args.name ?? DEFAULT_NAME, ext: "json" });
|
|
267
|
+
const auth = await getAccessToken(args);
|
|
268
|
+
const bundle = await fetchWorkspaceBundle(auth, args.branch);
|
|
269
|
+
const content = JSON.stringify(bundle, null, 2);
|
|
270
|
+
if (target.kind === "stdout") {
|
|
271
|
+
writeData(process.stdout, content + "\n");
|
|
272
|
+
const secrets = secretsCarriedBy(bundle);
|
|
273
|
+
if (secrets.length > 0) {
|
|
274
|
+
warn(
|
|
275
|
+
`The export carries ${secretsPhrase(secrets)} in cleartext \u2014 written to stdout, where no file permission protects it; do not commit or log it.`,
|
|
276
|
+
"secrets.cleartext-stdout"
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
writeExportFile(target.path, content + "\n", secretsCarriedBy(bundle));
|
|
282
|
+
if (isMachineOutput(args)) writeJson({ path: target.path });
|
|
283
|
+
success(`Exported workspace \u2192 ${target.path}`);
|
|
284
|
+
}
|
|
285
|
+
var EXIT_DIFF_MISMATCH = 2;
|
|
286
|
+
async function runDiff(args) {
|
|
287
|
+
if (args.file === void 0 && args.bundle === void 0) {
|
|
288
|
+
const { resolveProjectEntry } = await import("./deploy-source-3W45CXMP.js");
|
|
289
|
+
const entry = resolveProjectEntry(process.cwd());
|
|
290
|
+
if (entry !== void 0) args = { ...args, file: entry };
|
|
291
|
+
}
|
|
292
|
+
assertBundleInput(args, { command: "workspace", subcommand: "diff" });
|
|
293
|
+
assertBundleFile(args, { command: "workspace", subcommand: "diff" });
|
|
294
|
+
assertEntryFile(args);
|
|
295
|
+
const auth = await getAccessToken(args);
|
|
296
|
+
const local = await loadBundleText(args, { command: "workspace", subcommand: "diff" });
|
|
297
|
+
let live;
|
|
298
|
+
try {
|
|
299
|
+
live = await fetchWorkspaceBundle(auth, args.branch);
|
|
300
|
+
} catch (err) {
|
|
301
|
+
const { unansweredRead } = await import("./source-resolve-S2XA3XZF.js");
|
|
302
|
+
throw unansweredRead(err, "read the workspace to compare", "workspace");
|
|
303
|
+
}
|
|
304
|
+
const { compareToLive, SETTINGS_LABEL } = await import("./live-diff-YONW2VI3.js");
|
|
305
|
+
const { codePinnedCanonicals, releaseCanonicalLock } = await import("./release-command-N4ZPKMHR.js");
|
|
306
|
+
const pinned = codePinnedCanonicals(local.bundle, releaseCanonicalLock(args), args.file !== void 0);
|
|
307
|
+
const result = compareToLive(
|
|
308
|
+
JSON.parse(local.bundle),
|
|
309
|
+
live,
|
|
310
|
+
new Set(pinned.map((p) => `${p.payloadKey}:${p.name}`)),
|
|
311
|
+
// Everything, not the report's sample: a caller who ran a diff asked for the
|
|
312
|
+
// list, and a truncated one would hide the object they are looking for.
|
|
313
|
+
// The documentation token is compared as a value: this asks what the target
|
|
314
|
+
// SAYS, and the live token is the outcome of the one this project sends.
|
|
315
|
+
{ sample: "all", documentation: "compare" }
|
|
316
|
+
);
|
|
317
|
+
if (!result.converged) process.exitCode = EXIT_DIFF_MISMATCH;
|
|
318
|
+
const listed = await listBranches(auth, { baseUrl: auth.instance, workspaceId: auth.workspaceId }).catch(
|
|
319
|
+
() => void 0
|
|
320
|
+
);
|
|
321
|
+
const liveLabel = listed?.find((b) => b.live)?.label;
|
|
322
|
+
const comparedLabel = args.branch ?? liveLabel;
|
|
323
|
+
const comparedIsLive = args.branch === void 0 ? true : liveLabel === void 0 ? null : args.branch === liveLabel;
|
|
324
|
+
if (isMachineOutput(args)) {
|
|
325
|
+
writeJson({
|
|
326
|
+
branch: comparedLabel ?? null,
|
|
327
|
+
live: comparedIsLive,
|
|
328
|
+
compared: result.compared,
|
|
329
|
+
// Not `converged`: this answers "is everything I declared there, as
|
|
330
|
+
// declared", and an undeclared object the target also carries does not
|
|
331
|
+
// make that false. The `unexpected` list is how a caller asks the other
|
|
332
|
+
// question.
|
|
333
|
+
matched: result.converged,
|
|
334
|
+
missing: result.missing,
|
|
335
|
+
differing: result.differing,
|
|
336
|
+
// Beside `differing` rather than inside it, so its entries stay plain
|
|
337
|
+
// `<sdkKind>:<name>` strings a caller can match on.
|
|
338
|
+
settingsFields: result.settingsFields,
|
|
339
|
+
unexpected: result.liveOnly,
|
|
340
|
+
source: local.source
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const where = args.branch !== void 0 ? `branch "${args.branch}"` : liveLabel !== void 0 ? `live branch "${liveLabel}"` : "live";
|
|
345
|
+
if (result.converged) {
|
|
346
|
+
success(`${where} holds everything this project declares (${result.compared} ${result.compared === 1 ? "object" : "objects"} compared).`);
|
|
347
|
+
if (result.liveOnly.length > 0) {
|
|
348
|
+
blank();
|
|
349
|
+
report("unexpected there, not declared here", result.liveOnly);
|
|
350
|
+
blank();
|
|
351
|
+
detail(`Not a failure \u2014 a merge leaves them alone, and so does \`--prune\` unless this project released them.`);
|
|
352
|
+
detail(`To remove one this project never released, adopt it first (\`xanosdk lock import\`), then prune.`);
|
|
353
|
+
}
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
warn(
|
|
357
|
+
`${where} does not match this project\u2019s compile (${result.compared} ${result.compared === 1 ? "object" : "objects"} compared, ${result.differingCount} differing, ${result.missingCount} missing, ${result.liveOnly.length} unexpected).`,
|
|
358
|
+
"workspace.drift"
|
|
359
|
+
);
|
|
360
|
+
blank();
|
|
361
|
+
report("missing there, declared here", result.missing);
|
|
362
|
+
report(
|
|
363
|
+
"differing",
|
|
364
|
+
result.differing.map(
|
|
365
|
+
(row) => row === SETTINGS_LABEL && result.settingsFields.length > 0 ? `${row} \u2014 ${result.settingsFields.join(", ")}` : row
|
|
366
|
+
)
|
|
367
|
+
);
|
|
368
|
+
report("unexpected there, not declared here", result.liveOnly);
|
|
369
|
+
blank();
|
|
370
|
+
detail(`Compared against ${local.source}. Nothing was written.`);
|
|
371
|
+
}
|
|
372
|
+
function report(label, rows) {
|
|
373
|
+
if (rows.length === 0) return;
|
|
374
|
+
step(`${rows.length} ${label}`);
|
|
375
|
+
for (const row of rows) detail(row);
|
|
376
|
+
}
|
|
377
|
+
function projectTables(bundle) {
|
|
378
|
+
const dbo = JSON.parse(bundle).payload?.dbo;
|
|
379
|
+
if (!Array.isArray(dbo)) return [];
|
|
380
|
+
return dbo.flatMap((t) => {
|
|
381
|
+
const { guid, name } = t ?? {};
|
|
382
|
+
return typeof guid === "string" && typeof name === "string" ? [{ guid, name }] : [];
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
async function runResetTables(args) {
|
|
386
|
+
const target = { command: "workspace", subcommand: "reset-tables" };
|
|
387
|
+
const guids = args.table ?? [];
|
|
388
|
+
if (guids.length === 0) {
|
|
389
|
+
throw new UsageError(
|
|
390
|
+
`\`xanosdk workspace reset-tables\` needs at least one \`--table <guid>\`. Run \`${tablesCommand("workspace")}${contextFlags(args)}\` to see the guids this workspace holds.
|
|
391
|
+
Tables are named by guid rather than by name because a table name may contain anything at all \u2014 a comma, a space, or nothing but digits \u2014 so a name is display-only.`,
|
|
392
|
+
{ helpFor: target }
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
const bundleGiven = args.bundle !== void 0 ? "`--bundle`" : args.file !== void 0 && /\.json$/i.test(args.file) ? `\`${args.file}\`` : void 0;
|
|
396
|
+
if (bundleGiven !== void 0) {
|
|
397
|
+
throw new UsageError(
|
|
398
|
+
`\`workspace reset-tables\` needs the entry file, not ${bundleGiven}. Seed rows are resolved from the table definitions at compile time; an exported bundle carries each table's schema but none of its rows, so there would be nothing to reset to.
|
|
399
|
+
Pass the entry file: \`xanosdk workspace reset-tables ./index.ts --table <guid> --write${contextFlags(args)}\`.`
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
const willRefuse = args.write === true && args.yes !== true && process.stdin.isTTY !== true;
|
|
403
|
+
assertEntryFile(args);
|
|
404
|
+
assertValueFiles(args, target);
|
|
405
|
+
const auth = await getAccessToken(args);
|
|
406
|
+
const local = await loadBundleText(args.write === true && !willRefuse ? args : { ...args, lockReadOnly: true }, target, {
|
|
407
|
+
withSeed: true
|
|
408
|
+
});
|
|
409
|
+
const { seedRowsByTableGuid } = await import("./seed-VU7C3QYS.js");
|
|
410
|
+
const seeds = seedRowsByTableGuid(local.content);
|
|
411
|
+
const declared = projectTables(local.bundle);
|
|
412
|
+
const unknown = guids.filter((guid) => !declared.some((t) => t.guid === guid));
|
|
413
|
+
if (unknown.length > 0) {
|
|
414
|
+
throw new UsageError(
|
|
415
|
+
`${local.source} declares no table with guid ${unknown.join(", ")}.
|
|
416
|
+
` + (declared.length === 0 ? `It declares no tables at all.` : `Its tables:
|
|
417
|
+
${declared.map((t) => ` ${t.guid} ${t.name}${seeds.has(t.guid) ? " (seeded)" : ""}`).join("\n")}`)
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
const unseeded = guids.filter((guid) => !seeds.has(guid));
|
|
421
|
+
if (unseeded.length > 0) {
|
|
422
|
+
throw new UsageError(
|
|
423
|
+
`${unseeded.join(", ")} ${unseeded.length === 1 ? "is" : "are"} not a seeded table in ${local.source}. This command resets a table to the rows the PROJECT declares, so a table the compile carries no \`seed\` for has nothing to reset to \u2014 it would simply be emptied. Add a \`seed\` to the table, or drop it from this command.`
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
const withFiles = guids.filter((guid) => seeds.get(guid).some(holdsHostedFile));
|
|
427
|
+
if (withFiles.length > 0) {
|
|
428
|
+
const names = withFiles.map((guid) => declared.find((t) => t.guid === guid)?.name ?? guid);
|
|
429
|
+
throw new UsageError(
|
|
430
|
+
`${names.join(", ")} ${names.length === 1 ? "seeds" : "seed"} a file column from hostedFile(), which only lands through a deploy that ships the file. Reset ${names.length === 1 ? "it" : "them"} with \`xanosdk deploy\` instead.`
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
const tables = await listTables(auth, {
|
|
434
|
+
workspaceId: auth.workspaceId,
|
|
435
|
+
binding: bindingFor(auth, auth.workspaceId, false)
|
|
436
|
+
});
|
|
437
|
+
if (tables.length === 0) await refuseUnreachableWorkspace(auth);
|
|
438
|
+
const byGuid = new Map(tables.map((t) => [t.guid, t]));
|
|
439
|
+
const absent = guids.filter((guid) => !byGuid.has(guid));
|
|
440
|
+
if (absent.length > 0) {
|
|
441
|
+
throw new UsageError(
|
|
442
|
+
`${absent.join(", ")} ${absent.length === 1 ? "is" : "are"} not in this workspace. Run \`${tablesCommand("workspace")}\` to list the guids it holds.`
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
const destination = credentialWriteTarget(auth);
|
|
446
|
+
const { countTableRows } = await import("./table-ENAVMITR.js");
|
|
447
|
+
const planned = await Promise.all(
|
|
448
|
+
guids.map(async (guid) => {
|
|
449
|
+
const table = byGuid.get(guid);
|
|
450
|
+
const existing = await countTableRows(auth, {
|
|
451
|
+
workspaceId: auth.workspaceId,
|
|
452
|
+
tableId: table.id,
|
|
453
|
+
binding: bindingFor(auth, auth.workspaceId, false)
|
|
454
|
+
}).catch(() => void 0);
|
|
455
|
+
return { guid, id: table.id, name: table.name, rows: seeds.get(guid).length, existing: existing ?? null };
|
|
456
|
+
})
|
|
457
|
+
);
|
|
458
|
+
const tableDoc = (t) => ({ guid: t.guid, name: t.name, existingRows: t.existing, seedRows: t.rows });
|
|
459
|
+
if (args.write !== true) {
|
|
460
|
+
step(`Would reset ${planned.length} table(s) \u2014 nothing was written`);
|
|
461
|
+
discloseWriteTarget(destination);
|
|
462
|
+
for (const t of planned) detail(`${t.name} \u2014 ${existingPhrase(t.existing)} deleted, ${t.rows} seed row(s) from ${local.source} inserted`);
|
|
463
|
+
blank();
|
|
464
|
+
detail(`Re-run with \`--write\` to apply. Every other table is left alone.`);
|
|
465
|
+
if (isMachineOutput(args)) {
|
|
466
|
+
writeJson({ destination: writeTargetPayload(destination), dryRun: true, tables: planned.map(tableDoc) });
|
|
467
|
+
}
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
step(`Resetting ${planned.length} table(s) to their seed rows`);
|
|
471
|
+
discloseWriteTarget(destination);
|
|
472
|
+
if (args.yes !== true) {
|
|
473
|
+
const ok = await confirm(
|
|
474
|
+
`Delete ${planned.map((t) => `${existingPhrase(t.existing)} from "${t.name}"`).join(", ")} and re-seed ${planned.length === 1 ? "it" : "them"} on workspace #${auth.workspaceId}?`,
|
|
475
|
+
{ flag: "--yes", refusal: { details: { dryRun: false, declined: false, tables: [] }, ...yesRerun(args, "workspace reset-tables") } }
|
|
476
|
+
);
|
|
477
|
+
if (!ok) {
|
|
478
|
+
info("Cancelled \u2014 nothing was written.");
|
|
479
|
+
if (isMachineOutput(args)) {
|
|
480
|
+
writeJson({ destination: writeTargetPayload(destination), dryRun: false, declined: true, tables: [] });
|
|
481
|
+
}
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const { truncateTable, insertTableRows } = await import("./table-ENAVMITR.js");
|
|
486
|
+
const done = [];
|
|
487
|
+
for (const t of planned) {
|
|
488
|
+
step(`Resetting ${t.name}`);
|
|
489
|
+
try {
|
|
490
|
+
await describeWrite(
|
|
491
|
+
{ what: `the emptying of table "${t.name}"` },
|
|
492
|
+
() => truncateTable(auth, { workspaceId: auth.workspaceId, tableId: t.id })
|
|
493
|
+
);
|
|
494
|
+
} catch (err) {
|
|
495
|
+
error(`"${t.name}" could not be emptied \u2014 its rows were most likely left as they were.`);
|
|
496
|
+
detail(`Nothing was re-seeded for it. Re-run once the cause is fixed; the rows come from ${local.source}.`);
|
|
497
|
+
if (done.length > 0) detail(`Already reset: ${done.map((d) => d.name).join(", ")}.`);
|
|
498
|
+
throw err;
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
await describeWrite(
|
|
502
|
+
{ what: `the re-seed of table "${t.name}"` },
|
|
503
|
+
() => insertTableRows(auth, {
|
|
504
|
+
workspaceId: auth.workspaceId,
|
|
505
|
+
tableId: t.id,
|
|
506
|
+
rows: seeds.get(t.guid)
|
|
507
|
+
})
|
|
508
|
+
);
|
|
509
|
+
} catch (err) {
|
|
510
|
+
error(`"${t.name}" was emptied but its seed rows did not land \u2014 it is EMPTY now.`);
|
|
511
|
+
detail(`Run the same command again to finish it. The rows come from ${local.source}, so nothing is lost.`);
|
|
512
|
+
if (done.length > 0) detail(`Already reset: ${done.map((d) => d.name).join(", ")}.`);
|
|
513
|
+
throw err;
|
|
514
|
+
}
|
|
515
|
+
done.push(t);
|
|
516
|
+
}
|
|
517
|
+
success(`Reset ${done.length} table(s) to their seed rows`);
|
|
518
|
+
for (const t of done) detail(`${t.name} \u2014 ${existingPhrase(t.existing)} deleted, ${t.rows} seed row(s) inserted`);
|
|
519
|
+
detail(`Every other table in this workspace was left alone.`);
|
|
520
|
+
if (isMachineOutput(args)) {
|
|
521
|
+
writeJson({ destination: writeTargetPayload(destination), dryRun: false, tables: done.map(tableDoc) });
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function existingPhrase(existing) {
|
|
525
|
+
return existing === null ? "its existing rows (count unreadable)" : `${existing} existing row${existing === 1 ? "" : "s"}`;
|
|
526
|
+
}
|
|
527
|
+
function holdsHostedFile(row) {
|
|
528
|
+
const hosted = (v) => typeof v === "object" && v !== null && typeof v.path === "string" && v.path.startsWith(HOSTED_ROW_PATH_PREFIX);
|
|
529
|
+
return Object.values(row).some((v) => Array.isArray(v) ? v.some(hosted) : hosted(v));
|
|
530
|
+
}
|
|
531
|
+
export {
|
|
532
|
+
EXIT_DIFF_MISMATCH,
|
|
533
|
+
runWorkspaceCommand
|
|
534
|
+
};
|
|
535
|
+
//# sourceMappingURL=workspace-command-JEXQETJD.js.map
|