@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,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asTimestamp
|
|
3
|
+
} from "./chunk-2MNLRIOX.js";
|
|
4
|
+
import {
|
|
5
|
+
impersonateEphemeral,
|
|
6
|
+
projectTenant
|
|
7
|
+
} from "./chunk-7G3CTU7I.js";
|
|
8
|
+
import {
|
|
9
|
+
deleteAnswer,
|
|
10
|
+
hasString,
|
|
11
|
+
isRecord,
|
|
12
|
+
listAnswer,
|
|
13
|
+
recordAnswer,
|
|
14
|
+
writeTransportFailure
|
|
15
|
+
} from "./chunk-6PBR37LN.js";
|
|
16
|
+
import {
|
|
17
|
+
SENT_AFTERMATH,
|
|
18
|
+
fetchOrExplain,
|
|
19
|
+
fetchReadOrExplain,
|
|
20
|
+
readBodyText,
|
|
21
|
+
safeHttpFailure,
|
|
22
|
+
writeStatusAftermath
|
|
23
|
+
} from "./chunk-YLDALTWZ.js";
|
|
24
|
+
|
|
25
|
+
// src/deploy/tenant.ts
|
|
26
|
+
var TIMEOUT_MS = 3e4;
|
|
27
|
+
var DEPLOY_TIMEOUT_MS = 6e5;
|
|
28
|
+
var TenantHttpError = class extends Error {
|
|
29
|
+
constructor(status, action, statusText, body, bind, remedy) {
|
|
30
|
+
const head = safeHttpFailure(action, { status, statusText }, body, bind);
|
|
31
|
+
super(remedy === void 0 ? head : `${head}
|
|
32
|
+
${remedy}`);
|
|
33
|
+
this.status = status;
|
|
34
|
+
this.name = "TenantHttpError";
|
|
35
|
+
}
|
|
36
|
+
status;
|
|
37
|
+
};
|
|
38
|
+
function relationId(v) {
|
|
39
|
+
if (v === null || typeof v !== "object") return void 0;
|
|
40
|
+
const id = v.id;
|
|
41
|
+
return typeof id === "number" && id > 0 ? id : void 0;
|
|
42
|
+
}
|
|
43
|
+
function projectTenantRecord(raw, instance) {
|
|
44
|
+
return {
|
|
45
|
+
...projectTenant(raw, instance),
|
|
46
|
+
deployedAt: asTimestamp(raw.deployed_at),
|
|
47
|
+
deployedReleaseId: relationId(raw.release)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function metaRequest(auth, path, init, timeoutMs) {
|
|
51
|
+
return {
|
|
52
|
+
url: new URL(path, auth.instance).href,
|
|
53
|
+
init: {
|
|
54
|
+
...init,
|
|
55
|
+
headers: {
|
|
56
|
+
accept: "application/json",
|
|
57
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
58
|
+
...init.headers ?? {}
|
|
59
|
+
},
|
|
60
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function metaWrite(auth, path, action, init, timeoutMs = TIMEOUT_MS) {
|
|
65
|
+
const req = metaRequest(auth, path, init, timeoutMs);
|
|
66
|
+
return fetchOrExplain(req.url, req.init, action, timeoutMs).catch((err) => {
|
|
67
|
+
throw writeTransportFailure(err);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function metaRead(auth, path, action) {
|
|
71
|
+
const req = metaRequest(auth, path, { method: "GET" }, TIMEOUT_MS);
|
|
72
|
+
return fetchReadOrExplain(req.url, req.init, action, TIMEOUT_MS);
|
|
73
|
+
}
|
|
74
|
+
function binding(auth, workspaceId) {
|
|
75
|
+
return {
|
|
76
|
+
boundWorkspaceId: auth.workspaceId,
|
|
77
|
+
instance: auth.instance,
|
|
78
|
+
profile: auth.profile,
|
|
79
|
+
addressedWorkspaceId: workspaceId,
|
|
80
|
+
credentialType: auth.credentialType,
|
|
81
|
+
tenantHost: false
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function readText(res, action, bind) {
|
|
85
|
+
const text = await readBodyText(res, action);
|
|
86
|
+
if (!res.ok) throw new TenantHttpError(res.status, action, res.statusText, text, bind);
|
|
87
|
+
return text;
|
|
88
|
+
}
|
|
89
|
+
var isTenantRow = (row) => hasString(row, "name");
|
|
90
|
+
function base(workspaceId) {
|
|
91
|
+
return `/api:meta/workspace/${workspaceId}/tenant`;
|
|
92
|
+
}
|
|
93
|
+
var PER_PAGE = 100;
|
|
94
|
+
async function listTenants(auth, opts) {
|
|
95
|
+
const out = [];
|
|
96
|
+
for (let page = 1; ; page++) {
|
|
97
|
+
const path = `${base(opts.workspaceId)}?page=${page}&per_page=${PER_PAGE}`;
|
|
98
|
+
const res = await metaRead(auth, path, "list tenants");
|
|
99
|
+
const url = new URL(path, auth.instance).href;
|
|
100
|
+
const { rows } = listAnswer(await readText(res, "list tenants", binding(auth, opts.workspaceId)), "list tenants", url, isTenantRow, {
|
|
101
|
+
safe: true
|
|
102
|
+
});
|
|
103
|
+
for (const r of rows) out.push(projectTenantRecord(r, auth.instance));
|
|
104
|
+
if (rows.length < PER_PAGE) return out;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function getTenant(auth, opts) {
|
|
108
|
+
const path = `${base(opts.workspaceId)}/${encodeURIComponent(opts.name)}`;
|
|
109
|
+
const res = await metaRead(auth, path, "get tenant");
|
|
110
|
+
if (res.status === 404) {
|
|
111
|
+
await res.text().catch(() => "");
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const url = new URL(path, auth.instance).href;
|
|
115
|
+
const text = await readText(res, "get tenant", binding(auth, opts.workspaceId));
|
|
116
|
+
return projectTenantRecord(recordAnswer(text, "get tenant", url, isTenantRow, { safe: true }), auth.instance);
|
|
117
|
+
}
|
|
118
|
+
async function tenantHasWorkspace(auth, base2) {
|
|
119
|
+
const url = `${base2.replace(/\/$/, "")}/api:meta/workspace`;
|
|
120
|
+
try {
|
|
121
|
+
const res = await metaRead(auth, url, "list the tenant's workspaces");
|
|
122
|
+
const text = await res.text();
|
|
123
|
+
if (!res.ok) return true;
|
|
124
|
+
const data = JSON.parse(text);
|
|
125
|
+
return !(Array.isArray(data) && data.length === 0);
|
|
126
|
+
} catch {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function isFailedMicroservice(m) {
|
|
131
|
+
return /^(error|failed)$/i.test(m.status);
|
|
132
|
+
}
|
|
133
|
+
var MAX_MICROSERVICE_DETAIL = 300;
|
|
134
|
+
function projectMicroservice(raw) {
|
|
135
|
+
if (raw === null || typeof raw !== "object") return void 0;
|
|
136
|
+
const r = raw;
|
|
137
|
+
if (typeof r.name !== "string" || typeof r.status !== "string") return void 0;
|
|
138
|
+
const id = typeof r.microservice_id === "number" && r.microservice_id > 0 ? r.microservice_id : void 0;
|
|
139
|
+
const detail = typeof r.detail === "string" && r.detail.trim() !== "" ? capDetail(r.detail) : void 0;
|
|
140
|
+
return {
|
|
141
|
+
...id === void 0 ? {} : { id },
|
|
142
|
+
name: r.name,
|
|
143
|
+
status: r.status,
|
|
144
|
+
...detail === void 0 ? {} : { detail }
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function capDetail(text) {
|
|
148
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
149
|
+
return flat.length > MAX_MICROSERVICE_DETAIL ? `${flat.slice(0, MAX_MICROSERVICE_DETAIL)}\u2026` : flat;
|
|
150
|
+
}
|
|
151
|
+
function readDeployOutcome(text, action, url) {
|
|
152
|
+
const record = recordAnswer(
|
|
153
|
+
text,
|
|
154
|
+
action,
|
|
155
|
+
url,
|
|
156
|
+
(row) => hasString(row, "name") || "deployed_at" in row || Array.isArray(row.microservices) || isRecord(row.release),
|
|
157
|
+
{ safe: true, write: true }
|
|
158
|
+
);
|
|
159
|
+
const list = Array.isArray(record.microservices) ? record.microservices : [];
|
|
160
|
+
return {
|
|
161
|
+
deployedAt: asTimestamp(record.deployed_at),
|
|
162
|
+
deployedReleaseId: relationId(record.release),
|
|
163
|
+
microservices: list.flatMap((m) => projectMicroservice(m) ?? [])
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
var DEPLOY_REFUSED_REMEDY = `The tenant refused the deploy, and nothing was landed. A tenant can require an approved deployment request before a release lands on it, and deploying needs permission to deploy to tenants in this workspace. Get the deployment approved (or the permission granted), then run it again.`;
|
|
167
|
+
async function deployReleaseToTenant(auth, opts) {
|
|
168
|
+
const path = `${base(opts.workspaceId)}/${encodeURIComponent(opts.tenant)}/deploy`;
|
|
169
|
+
const res = await metaWrite(
|
|
170
|
+
auth,
|
|
171
|
+
path,
|
|
172
|
+
"deploy release to tenant",
|
|
173
|
+
{
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { "Content-Type": "application/json" },
|
|
176
|
+
body: JSON.stringify({ release_name: opts.release })
|
|
177
|
+
},
|
|
178
|
+
DEPLOY_TIMEOUT_MS
|
|
179
|
+
);
|
|
180
|
+
const text = await readBodyText(res, "deploy release to tenant", { aftermath: SENT_AFTERMATH });
|
|
181
|
+
if (!res.ok) {
|
|
182
|
+
if (res.status === 403) {
|
|
183
|
+
throw new TenantHttpError(res.status, "deploy release to tenant", res.statusText, text, void 0, DEPLOY_REFUSED_REMEDY);
|
|
184
|
+
}
|
|
185
|
+
throw new TenantHttpError(res.status, "deploy release to tenant", res.statusText, text, binding(auth, opts.workspaceId));
|
|
186
|
+
}
|
|
187
|
+
return readDeployOutcome(text, "deploy release to tenant", new URL(path, auth.instance).href);
|
|
188
|
+
}
|
|
189
|
+
async function deleteTenant(auth, opts) {
|
|
190
|
+
const path = `${base(opts.workspaceId)}/${encodeURIComponent(opts.name)}`;
|
|
191
|
+
const res = await metaWrite(auth, path, "delete tenant", { method: "DELETE" });
|
|
192
|
+
const text = await readBodyText(res, "delete tenant", { aftermath: SENT_AFTERMATH });
|
|
193
|
+
if (res.status === 404) return { alreadyGone: true };
|
|
194
|
+
if (!res.ok) {
|
|
195
|
+
throw new TenantHttpError(
|
|
196
|
+
res.status,
|
|
197
|
+
"delete tenant",
|
|
198
|
+
res.statusText,
|
|
199
|
+
text,
|
|
200
|
+
binding(auth, opts.workspaceId),
|
|
201
|
+
writeStatusAftermath(res.status)
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
deleteAnswer(text, "delete tenant", new URL(path, auth.instance).href, { safe: true });
|
|
205
|
+
return { alreadyGone: false };
|
|
206
|
+
}
|
|
207
|
+
async function impersonateTenant(auth, opts) {
|
|
208
|
+
return impersonateEphemeral(auth, { parentWorkspaceId: opts.workspaceId, name: opts.name, guest: opts.guest });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export {
|
|
212
|
+
TenantHttpError,
|
|
213
|
+
projectTenantRecord,
|
|
214
|
+
listTenants,
|
|
215
|
+
getTenant,
|
|
216
|
+
tenantHasWorkspace,
|
|
217
|
+
isFailedMicroservice,
|
|
218
|
+
deployReleaseToTenant,
|
|
219
|
+
deleteTenant,
|
|
220
|
+
impersonateTenant
|
|
221
|
+
};
|
|
222
|
+
//# sourceMappingURL=chunk-A3UDOZB6.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BranchHttpError,
|
|
3
|
+
BranchTakenError
|
|
4
|
+
} from "./chunk-TRJCALW3.js";
|
|
5
|
+
import {
|
|
6
|
+
SourceError
|
|
7
|
+
} from "./chunk-QCNYHBL7.js";
|
|
8
|
+
import {
|
|
9
|
+
ReleaseHttpError
|
|
10
|
+
} from "./chunk-2ZUEE4EK.js";
|
|
11
|
+
import {
|
|
12
|
+
ImportHttpError
|
|
13
|
+
} from "./chunk-AN6BL47T.js";
|
|
14
|
+
import {
|
|
15
|
+
TenantHttpError
|
|
16
|
+
} from "./chunk-A3UDOZB6.js";
|
|
17
|
+
import {
|
|
18
|
+
TLS_CERTIFICATE_CODES,
|
|
19
|
+
isTimeoutError,
|
|
20
|
+
writeRefusedBy
|
|
21
|
+
} from "./chunk-YLDALTWZ.js";
|
|
22
|
+
import {
|
|
23
|
+
UsageError
|
|
24
|
+
} from "./chunk-PTHVMXZI.js";
|
|
25
|
+
|
|
26
|
+
// src/emit/operation-outcome.ts
|
|
27
|
+
var SettledWriteFailure = class extends Error {
|
|
28
|
+
name = "SettledWriteFailure";
|
|
29
|
+
};
|
|
30
|
+
var NEVER_OPENED = /* @__PURE__ */ new Set([
|
|
31
|
+
"ECONNREFUSED",
|
|
32
|
+
"ENOTFOUND",
|
|
33
|
+
"EAI_AGAIN",
|
|
34
|
+
"ENETUNREACH",
|
|
35
|
+
// A certificate the TLS handshake refused: the connection closed before a
|
|
36
|
+
// request was written.
|
|
37
|
+
...TLS_CERTIFICATE_CODES
|
|
38
|
+
]);
|
|
39
|
+
var MAX_CHAIN = 16;
|
|
40
|
+
function httpStatusOf(err) {
|
|
41
|
+
if (err instanceof ReleaseHttpError || err instanceof TenantHttpError || err instanceof BranchHttpError || err instanceof ImportHttpError) {
|
|
42
|
+
return err.status;
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
function chainOf(err) {
|
|
47
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48
|
+
const out = [];
|
|
49
|
+
const queue = [err];
|
|
50
|
+
while (queue.length > 0 && out.length < MAX_CHAIN) {
|
|
51
|
+
const next = queue.shift();
|
|
52
|
+
if (next === void 0 || next === null || seen.has(next)) continue;
|
|
53
|
+
seen.add(next);
|
|
54
|
+
out.push(next);
|
|
55
|
+
if (typeof next !== "object") continue;
|
|
56
|
+
const cause = next.cause;
|
|
57
|
+
if (cause !== void 0) queue.push(cause);
|
|
58
|
+
const errors = next.errors;
|
|
59
|
+
if (Array.isArray(errors)) queue.push(...errors);
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
function classifyFailure(err, opts) {
|
|
64
|
+
if (!opts.writeSent) return "no";
|
|
65
|
+
const chain = chainOf(err);
|
|
66
|
+
if (chain.some(
|
|
67
|
+
(e) => e instanceof UsageError || e instanceof SourceError || e instanceof BranchTakenError || e instanceof SettledWriteFailure
|
|
68
|
+
))
|
|
69
|
+
return "no";
|
|
70
|
+
for (const e of chain) {
|
|
71
|
+
const status = httpStatusOf(e);
|
|
72
|
+
if (status !== void 0) return writeRefusedBy(status) ? "no" : "unknown";
|
|
73
|
+
}
|
|
74
|
+
if (chain.some(isTimeoutError)) return "unknown";
|
|
75
|
+
if (chain.some((e) => e instanceof Error && e.message === "bad port")) return "no";
|
|
76
|
+
const codes = chain.map((e) => typeof e === "object" && e !== null ? e.code : void 0).filter((c) => typeof c === "string");
|
|
77
|
+
if (codes.length > 0 && codes.every((c) => NEVER_OPENED.has(c))) return "no";
|
|
78
|
+
return "unknown";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
SettledWriteFailure,
|
|
83
|
+
classifyFailure
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=chunk-A6E77GDW.js.map
|