@osdk/cli 0.19.0-next-20240426195134 → 0.19.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 +3 -6
- package/README.md +148 -0
- package/build/js/chunk-3NRUGBBO.browser.mjs +15 -0
- package/build/js/chunk-3NRUGBBO.browser.mjs.map +1 -0
- package/build/js/chunk-C5C5AQYT.browser.mjs +9 -0
- package/build/js/{chunk-ZSTKOCBT.mjs → chunk-E2SEJZTC.mjs} +1 -1
- package/build/js/chunk-F6DFEGKQ.browser.mjs +118 -0
- package/build/js/chunk-F6DFEGKQ.browser.mjs.map +1 -0
- package/build/js/chunk-FRT6INSG.browser.mjs +65 -0
- package/build/js/chunk-FRT6INSG.browser.mjs.map +1 -0
- package/build/js/{chunk-7G2FSZUY.cjs → chunk-HQDDGVB7.cjs} +1 -1
- package/build/js/chunk-HQDDGVB7.cjs.map +1 -0
- package/build/js/{chunk-DKCYYJ36.mjs → chunk-MQIOUPGJ.mjs} +40 -40
- package/build/js/chunk-MQIOUPGJ.mjs.map +1 -0
- package/build/js/chunk-NTRB7WUY.browser.mjs +199 -0
- package/build/js/chunk-NTRB7WUY.browser.mjs.map +1 -0
- package/build/js/{chunk-DKKDHTGT.cjs → chunk-RHOIENYA.cjs} +41 -41
- package/build/js/chunk-RHOIENYA.cjs.map +1 -0
- package/build/js/{handleGenerate-ZYXEGPSG-Q3HISCOY.cjs → handleGenerate-YNVZFAXQ-3KAATT5S.cjs} +5 -5
- package/build/js/handleGenerate-YNVZFAXQ-3KAATT5S.cjs.map +1 -0
- package/build/js/handleGenerate-YNVZFAXQ-FJO7YEOC.browser.mjs +151 -0
- package/build/js/handleGenerate-YNVZFAXQ-FJO7YEOC.browser.mjs.map +1 -0
- package/build/js/{handleGenerate-ZYXEGPSG-T7AGZBSH.mjs → handleGenerate-YNVZFAXQ-RJ45FF22.mjs} +5 -5
- package/build/js/handleGenerate-YNVZFAXQ-RJ45FF22.mjs.map +1 -0
- package/build/js/index.browser.mjs +527 -0
- package/build/js/index.browser.mjs.map +1 -0
- package/build/js/index.cjs +12 -12
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +12 -12
- package/build/js/index.mjs.map +1 -1
- package/build/js/loginFlow-H6IOYVXH.browser.mjs +4 -0
- package/build/js/{loginFlow-3V5OVOTH.cjs → loginFlow-QTUKYZEL.cjs} +2 -2
- package/build/js/{loginFlow-IBTRFIH3.mjs → loginFlow-ZFVT2AFZ.mjs} +2 -2
- package/build/js/loginFlow-ZFVT2AFZ.mjs.map +1 -0
- package/build/js/siteDeployCommand-CY2WWLXP.browser.mjs +135 -0
- package/build/js/siteDeployCommand-CY2WWLXP.browser.mjs.map +1 -0
- package/build/js/{siteDeployCommand-P2IDJRWT.cjs → siteDeployCommand-EYM2TXE6.cjs} +10 -10
- package/build/js/siteDeployCommand-EYM2TXE6.cjs.map +1 -0
- package/build/js/{siteDeployCommand-PJJT2NNF.mjs → siteDeployCommand-GV3QRLZD.mjs} +8 -8
- package/build/js/siteDeployCommand-GV3QRLZD.mjs.map +1 -0
- package/build/js/versionDeleteCommand-2OJI3HPR.browser.mjs +33 -0
- package/build/js/versionDeleteCommand-2OJI3HPR.browser.mjs.map +1 -0
- package/build/js/{versionDeleteCommand-4FUKGJQ2.mjs → versionDeleteCommand-E6727BXW.mjs} +4 -4
- package/build/js/versionDeleteCommand-E6727BXW.mjs.map +1 -0
- package/build/js/{versionDeleteCommand-X7IHRPH3.cjs → versionDeleteCommand-LZJDT2HD.cjs} +6 -6
- package/build/js/versionDeleteCommand-LZJDT2HD.cjs.map +1 -0
- package/build/js/versionGetCommand-4LGRRMQM.cjs +29 -0
- package/build/js/versionGetCommand-4LGRRMQM.cjs.map +1 -0
- package/build/js/versionGetCommand-A6BVV3GL.browser.mjs +27 -0
- package/build/js/versionGetCommand-A6BVV3GL.browser.mjs.map +1 -0
- package/build/js/{versionGetCommand-7ZWZ3BQY.mjs → versionGetCommand-XCXFCFAP.mjs} +7 -6
- package/build/js/versionGetCommand-XCXFCFAP.mjs.map +1 -0
- package/build/js/versionListCommand-2LWNOKV2.browser.mjs +32 -0
- package/build/js/versionListCommand-2LWNOKV2.browser.mjs.map +1 -0
- package/build/js/{versionListCommand-5K3FUVCO.mjs → versionListCommand-TSPBNGWW.mjs} +5 -5
- package/build/js/versionListCommand-TSPBNGWW.mjs.map +1 -0
- package/build/js/{versionListCommand-RZYNYI4A.cjs → versionListCommand-ZHIPVSQP.cjs} +7 -7
- package/build/js/versionListCommand-ZHIPVSQP.cjs.map +1 -0
- package/build/js/{versionSetCommand-C2NZCHJY.mjs → versionSetCommand-FUZKBVIF.mjs} +4 -4
- package/build/js/versionSetCommand-FUZKBVIF.mjs.map +1 -0
- package/build/js/versionSetCommand-SN2KIDW3.browser.mjs +27 -0
- package/build/js/versionSetCommand-SN2KIDW3.browser.mjs.map +1 -0
- package/build/js/{versionSetCommand-CXMMMNSS.cjs → versionSetCommand-TAHDYWUK.cjs} +6 -6
- package/build/js/versionSetCommand-TAHDYWUK.cjs.map +1 -0
- package/build/js/{versionUnsetCommand-ZQHUGPWQ.mjs → versionUnsetCommand-BJPJ2XCE.mjs} +4 -4
- package/build/js/{versionUnsetCommand-I46GWIIR.cjs.map → versionUnsetCommand-BJPJ2XCE.mjs.map} +1 -1
- package/build/js/{versionUnsetCommand-I46GWIIR.cjs → versionUnsetCommand-MGG4LFZL.cjs} +6 -6
- package/build/js/{versionUnsetCommand-ZQHUGPWQ.mjs.map → versionUnsetCommand-MGG4LFZL.cjs.map} +1 -1
- package/build/js/versionUnsetCommand-Q6IDL3M4.browser.mjs +32 -0
- package/build/js/versionUnsetCommand-Q6IDL3M4.browser.mjs.map +1 -0
- package/build/types/commands/site/version/get/versionGetCommand.d.mts.map +1 -1
- package/build/types/net/third-party-applications/DeployWebsiteRequest.d.mts +4 -0
- package/build/types/net/third-party-applications/DeployWebsiteRequest.d.mts.map +1 -0
- package/build/types/net/third-party-applications/ListVersionsResponse.d.mts +6 -0
- package/build/types/net/third-party-applications/ListVersionsResponse.d.mts.map +1 -0
- package/build/types/net/third-party-applications/Version.d.mts +4 -0
- package/build/types/net/third-party-applications/Version.d.mts.map +1 -0
- package/build/types/net/third-party-applications/Website.d.mts +5 -0
- package/build/types/net/third-party-applications/Website.d.mts.map +1 -0
- package/build/types/net/third-party-applications/deleteVersion.d.mts +4 -0
- package/build/types/net/third-party-applications/deleteVersion.d.mts.map +1 -0
- package/build/types/net/third-party-applications/deployWebsite.d.mts +6 -0
- package/build/types/net/third-party-applications/deployWebsite.d.mts.map +1 -0
- package/build/types/net/third-party-applications/getWebsite.d.mts +5 -0
- package/build/types/net/third-party-applications/getWebsite.d.mts.map +1 -0
- package/build/types/net/third-party-applications/index.d.mts +10 -10
- package/build/types/net/third-party-applications/index.d.mts.map +1 -1
- package/build/types/net/third-party-applications/listVersions.d.mts +5 -0
- package/build/types/net/third-party-applications/listVersions.d.mts.map +1 -0
- package/build/types/net/third-party-applications/undeployWebsite.d.mts +4 -0
- package/build/types/net/third-party-applications/undeployWebsite.d.mts.map +1 -0
- package/build/types/net/third-party-applications/uploadVersion.d.mts +5 -0
- package/build/types/net/third-party-applications/uploadVersion.d.mts.map +1 -0
- package/package.json +6 -4
- package/build/js/chunk-DKCYYJ36.mjs.map +0 -1
- package/build/js/chunk-DKKDHTGT.cjs.map +0 -1
- package/build/js/handleGenerate-ZYXEGPSG-Q3HISCOY.cjs.map +0 -1
- package/build/js/handleGenerate-ZYXEGPSG-T7AGZBSH.mjs.map +0 -1
- package/build/js/siteDeployCommand-P2IDJRWT.cjs.map +0 -1
- package/build/js/siteDeployCommand-PJJT2NNF.mjs.map +0 -1
- package/build/js/versionDeleteCommand-4FUKGJQ2.mjs.map +0 -1
- package/build/js/versionDeleteCommand-X7IHRPH3.cjs.map +0 -1
- package/build/js/versionGetCommand-3HMZEFY6.cjs +0 -28
- package/build/js/versionGetCommand-3HMZEFY6.cjs.map +0 -1
- package/build/js/versionGetCommand-7ZWZ3BQY.mjs.map +0 -1
- package/build/js/versionListCommand-5K3FUVCO.mjs.map +0 -1
- package/build/js/versionListCommand-RZYNYI4A.cjs.map +0 -1
- package/build/js/versionSetCommand-C2NZCHJY.mjs.map +0 -1
- package/build/js/versionSetCommand-CXMMMNSS.cjs.map +0 -1
- package/build/types/net/third-party-applications/ListWebsiteVersionsResponse.d.mts +0 -6
- package/build/types/net/third-party-applications/ListWebsiteVersionsResponse.d.mts.map +0 -1
- package/build/types/net/third-party-applications/UpdateWebsiteDeploymentRequest.d.mts +0 -4
- package/build/types/net/third-party-applications/UpdateWebsiteDeploymentRequest.d.mts.map +0 -1
- package/build/types/net/third-party-applications/WebsiteDeployment.d.mts +0 -5
- package/build/types/net/third-party-applications/WebsiteDeployment.d.mts.map +0 -1
- package/build/types/net/third-party-applications/WebsiteVersion.d.mts +0 -4
- package/build/types/net/third-party-applications/WebsiteVersion.d.mts.map +0 -1
- package/build/types/net/third-party-applications/deleteWebsiteDeployment.d.mts +0 -4
- package/build/types/net/third-party-applications/deleteWebsiteDeployment.d.mts.map +0 -1
- package/build/types/net/third-party-applications/deleteWebsiteVersion.d.mts +0 -4
- package/build/types/net/third-party-applications/deleteWebsiteVersion.d.mts.map +0 -1
- package/build/types/net/third-party-applications/getWebsiteDeployment.d.mts +0 -5
- package/build/types/net/third-party-applications/getWebsiteDeployment.d.mts.map +0 -1
- package/build/types/net/third-party-applications/listWebsiteVersions.d.mts +0 -5
- package/build/types/net/third-party-applications/listWebsiteVersions.d.mts.map +0 -1
- package/build/types/net/third-party-applications/updateWebsiteDeployment.d.mts +0 -6
- package/build/types/net/third-party-applications/updateWebsiteDeployment.d.mts.map +0 -1
- package/build/types/net/third-party-applications/uploadWebsiteVersion.d.mts +0 -5
- package/build/types/net/third-party-applications/uploadWebsiteVersion.d.mts.map +0 -1
- /package/build/js/{chunk-7G2FSZUY.cjs.map → chunk-C5C5AQYT.browser.mjs.map} +0 -0
- /package/build/js/{chunk-ZSTKOCBT.mjs.map → chunk-E2SEJZTC.mjs.map} +0 -0
- /package/build/js/{loginFlow-3V5OVOTH.cjs.map → loginFlow-H6IOYVXH.browser.mjs.map} +0 -0
- /package/build/js/{loginFlow-IBTRFIH3.mjs.map → loginFlow-QTUKYZEL.cjs.map} +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { ExitProcessError } from './chunk-FRT6INSG.browser.mjs';
|
|
2
|
+
import { __export } from './chunk-C5C5AQYT.browser.mjs';
|
|
3
|
+
import { PalantirApiError, createFetchHeaderMutator, createFetchOrThrow } from '@osdk/shared.net';
|
|
4
|
+
import { consola } from 'consola';
|
|
5
|
+
import { promises } from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
|
|
8
|
+
// src/net/createInternalClientContext.mts
|
|
9
|
+
function createInternalClientContext(foundryUrl, tokenProvider) {
|
|
10
|
+
return {
|
|
11
|
+
tokenProvider,
|
|
12
|
+
foundryUrl
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/net/third-party-applications/index.mts
|
|
17
|
+
var third_party_applications_exports = {};
|
|
18
|
+
__export(third_party_applications_exports, {
|
|
19
|
+
deleteVersion: () => deleteVersion,
|
|
20
|
+
deployWebsite: () => deployWebsite,
|
|
21
|
+
getWebsite: () => getWebsite,
|
|
22
|
+
listVersions: () => listVersions,
|
|
23
|
+
undeployWebsite: () => undeployWebsite,
|
|
24
|
+
uploadVersion: () => uploadVersion
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// src/net/UserAgent.ts
|
|
28
|
+
var USER_AGENT = `osdk-cli/${"0.19.0"}`;
|
|
29
|
+
|
|
30
|
+
// src/net/createFetch.mts
|
|
31
|
+
function createFetch(tokenProvider, fetchFn = fetch) {
|
|
32
|
+
return createFetchHeaderMutator(createRequestLoggingFetch(createErrorExitingFetch(createFetchOrThrow(fetchFn))), async (headers) => {
|
|
33
|
+
const token = await tokenProvider();
|
|
34
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
35
|
+
headers.set("Fetch-User-Agent", USER_AGENT);
|
|
36
|
+
return headers;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function createErrorExitingFetch(fetchFn = fetch) {
|
|
40
|
+
return function errorExitingFetch(input, init) {
|
|
41
|
+
return fetchFn(input, init).catch(handleFetchError);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function handleFetchError(e) {
|
|
45
|
+
if (!(e instanceof PalantirApiError)) {
|
|
46
|
+
throw new ExitProcessError(1, "Unexpected fetch error");
|
|
47
|
+
}
|
|
48
|
+
let tip;
|
|
49
|
+
if (e.statusCode === 401) {
|
|
50
|
+
tip = "Check your token is valid and has not expired or been disabled";
|
|
51
|
+
} else if (e.statusCode === 403) {
|
|
52
|
+
tip = "Check your token has the required scopes for this operation";
|
|
53
|
+
}
|
|
54
|
+
let message = e.message;
|
|
55
|
+
if (e.errorName === "CannotDeleteDeployedVersion") {
|
|
56
|
+
message = "The site version to delete is live and cannot be deleted";
|
|
57
|
+
tip = "Run the `site version set` command to change the live site version";
|
|
58
|
+
} else if (e.errorName === "InvalidVersion") {
|
|
59
|
+
message = "The site version is invalid and must be a valid SemVer string";
|
|
60
|
+
} else if (e.errorName === "VersionAlreadyExists") {
|
|
61
|
+
message = "The site version already exists";
|
|
62
|
+
} else if (e.errorName === "VersionNotFound") {
|
|
63
|
+
message = "The site version could not be found";
|
|
64
|
+
}
|
|
65
|
+
throw new ExitProcessError(1, message, tip, e);
|
|
66
|
+
}
|
|
67
|
+
function createRequestLoggingFetch(fetchFn = fetch) {
|
|
68
|
+
return function requestLoggingFetch(input, init) {
|
|
69
|
+
const requestLog = typeof input === "string" || input instanceof URL ? `${init?.method ?? "GET"}: ${input.toString().trim()}` : `${input.method ?? "GET"}: ${input.url.toString().trim()}`;
|
|
70
|
+
consola.trace(requestLog);
|
|
71
|
+
return fetchFn(input, init).then((a) => {
|
|
72
|
+
consola.trace(`FINISH ${requestLog}`);
|
|
73
|
+
return a;
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/net/third-party-applications/deleteVersion.mts
|
|
79
|
+
async function deleteVersion(ctx, thirdPartyAppRid, version) {
|
|
80
|
+
const fetch2 = createFetch(ctx.tokenProvider);
|
|
81
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/${version}?preview=true`;
|
|
82
|
+
await fetch2(url, {
|
|
83
|
+
method: "DELETE"
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/net/third-party-applications/deployWebsite.mts
|
|
88
|
+
async function deployWebsite(ctx, thirdPartyAppRid, request) {
|
|
89
|
+
const fetch2 = createFetch(ctx.tokenProvider);
|
|
90
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/deploy?preview=true`;
|
|
91
|
+
const result = await fetch2(url, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
body: JSON.stringify(request),
|
|
94
|
+
headers: {
|
|
95
|
+
"Content-Type": "application/json"
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return result.json();
|
|
99
|
+
}
|
|
100
|
+
async function getWebsite(ctx, thirdPartyAppRid) {
|
|
101
|
+
const fetch2 = createFetch(ctx.tokenProvider);
|
|
102
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website?preview=true`;
|
|
103
|
+
try {
|
|
104
|
+
const result = await fetch2(url);
|
|
105
|
+
return result.json();
|
|
106
|
+
} catch (e) {
|
|
107
|
+
if (e instanceof ExitProcessError && e.originalError != null && e.originalError instanceof PalantirApiError && e.originalError.errorName === "WebsiteNotFound") {
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/net/third-party-applications/listVersions.mts
|
|
115
|
+
async function listVersions(ctx, thirdPartyAppRid) {
|
|
116
|
+
const fetch2 = createFetch(ctx.tokenProvider);
|
|
117
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions?preview=true`;
|
|
118
|
+
const result = await fetch2(url);
|
|
119
|
+
return result.json();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/net/third-party-applications/undeployWebsite.mts
|
|
123
|
+
async function undeployWebsite(ctx, thirdPartyAppRid) {
|
|
124
|
+
const fetch2 = createFetch(ctx.tokenProvider);
|
|
125
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/undeploy?preview=true`;
|
|
126
|
+
await fetch2(url, {
|
|
127
|
+
method: "POST"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/net/third-party-applications/uploadVersion.mts
|
|
132
|
+
async function uploadVersion(ctx, thirdPartyAppRid, version, zipFile) {
|
|
133
|
+
const fetch2 = createFetch(ctx.tokenProvider);
|
|
134
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/upload?version=${version}&preview=true`;
|
|
135
|
+
const result = await fetch2(url, {
|
|
136
|
+
method: "POST",
|
|
137
|
+
body: zipFile,
|
|
138
|
+
headers: {
|
|
139
|
+
"Content-Type": "application/octet-stream"
|
|
140
|
+
},
|
|
141
|
+
duplex: "half"
|
|
142
|
+
// Node hates me
|
|
143
|
+
});
|
|
144
|
+
return result.json();
|
|
145
|
+
}
|
|
146
|
+
var TOKEN_ENV_VARS = ["FOUNDRY_TOKEN", "FOUNDRY_SDK_AUTH_TOKEN"];
|
|
147
|
+
async function loadToken(token, tokenFile) {
|
|
148
|
+
if (token) {
|
|
149
|
+
consola.debug(`Using token from --token option`);
|
|
150
|
+
validate(token);
|
|
151
|
+
return token;
|
|
152
|
+
}
|
|
153
|
+
if (tokenFile) {
|
|
154
|
+
const loadedToken = await loadTokenFile(tokenFile);
|
|
155
|
+
consola.debug(`Using token from --tokenFile=${loadedToken.filePath} option`);
|
|
156
|
+
validate(loadedToken.token);
|
|
157
|
+
return loadedToken.token;
|
|
158
|
+
}
|
|
159
|
+
for (const envVar of TOKEN_ENV_VARS) {
|
|
160
|
+
const environmentToken = process.env[envVar];
|
|
161
|
+
if (environmentToken) {
|
|
162
|
+
consola.debug(`Using token from ${envVar} environment variable`);
|
|
163
|
+
validate(environmentToken);
|
|
164
|
+
if (envVar === "FOUNDRY_SDK_AUTH_TOKEN") {
|
|
165
|
+
consola.warn(`Using FOUNDRY_SDK_AUTH_TOKEN environment variable is deprecated. Please use FOUNDRY_TOKEN instead.`);
|
|
166
|
+
}
|
|
167
|
+
return environmentToken;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
throw new ExitProcessError(2, `No token found.`, `You can supply a --token or --token-file option, or set the ${TOKEN_ENV_VARS[0]} environment variable`);
|
|
171
|
+
}
|
|
172
|
+
async function loadTokenFile(filePath) {
|
|
173
|
+
let token;
|
|
174
|
+
let resolvedPath;
|
|
175
|
+
try {
|
|
176
|
+
resolvedPath = path.resolve(filePath);
|
|
177
|
+
token = await promises.readFile(resolvedPath, "utf8");
|
|
178
|
+
token = token.trim();
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw new ExitProcessError(2, `Unable to read token file "${filePath}": ${error}`);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
filePath: resolvedPath,
|
|
184
|
+
token
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function validate(token) {
|
|
188
|
+
if (!isJWT(token)) {
|
|
189
|
+
throw new ExitProcessError(2, `Token does not appear to be a JWT`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function isJWT(token) {
|
|
193
|
+
const jwtPattern = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
194
|
+
return jwtPattern.test(token);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export { createInternalClientContext, loadToken, third_party_applications_exports };
|
|
198
|
+
//# sourceMappingURL=out.js.map
|
|
199
|
+
//# sourceMappingURL=chunk-NTRB7WUY.browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/net/createInternalClientContext.mts","../../src/net/third-party-applications/index.mts","../../src/net/createFetch.mts","../../src/net/UserAgent.ts","../../src/net/third-party-applications/deleteVersion.mts","../../src/net/third-party-applications/deployWebsite.mts","../../src/net/third-party-applications/getWebsite.mts","../../src/net/third-party-applications/listVersions.mts","../../src/net/third-party-applications/undeployWebsite.mts","../../src/net/third-party-applications/uploadVersion.mts","../../src/util/token.ts"],"names":["fetch","PalantirApiError","consola"],"mappings":";;;;;;;;AAgBO,SAAS,4BAA4B,YAAY,eAAe;AACrE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;;;ACrBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBA,SAAS,0BAA0B,oBAAoB,wBAAwB;AAC/E,SAAS,eAAe;;;ACFjB,IAAM,aAAa,YAAY,QAA2B;;;ADI1D,SAAS,YAAY,eAAe,UAAU,OAAO;AAC1D,SAAO,yBAAyB,0BAA0B,wBAAwB,mBAAmB,OAAO,CAAC,CAAC,GAAG,OAAM,YAAW;AAChI,UAAM,QAAQ,MAAM,cAAc;AAClC,YAAQ,IAAI,iBAAiB,UAAU,KAAK,EAAE;AAC9C,YAAQ,IAAI,oBAAoB,UAAU;AAC1C,WAAO;AAAA,EACT,CAAC;AACH;AACA,SAAS,wBAAwB,UAAU,OAAO;AAChD,SAAO,SAAS,kBAAkB,OAAO,MAAM;AAC7C,WAAO,QAAQ,OAAO,IAAI,EAAE,MAAM,gBAAgB;AAAA,EACpD;AACF;AACA,SAAS,iBAAiB,GAAG;AAC3B,MAAI,EAAE,aAAa,mBAAmB;AACpC,UAAM,IAAI,iBAAiB,GAAG,wBAAwB;AAAA,EACxD;A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AACF;AACA,SAAS,MAAM,OAAO;AAEpB,QAAM,aAAa;AACnB,SAAO,WAAW,KAAK,KAAK;AAC9B","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function createInternalClientContext(foundryUrl, tokenProvider) {\n return {\n tokenProvider,\n foundryUrl\n };\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { deleteVersion } from \"./deleteVersion.mjs\";\nexport { deployWebsite } from \"./deployWebsite.mjs\";\nexport { getWebsite } from \"./getWebsite.mjs\";\nexport { listVersions } from \"./listVersions.mjs\";\nexport { undeployWebsite } from \"./undeployWebsite.mjs\";\nexport { uploadVersion } from \"./uploadVersion.mjs\";","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExitProcessError } from \"@osdk/cli.common\";\nimport { createFetchHeaderMutator, createFetchOrThrow, PalantirApiError } from \"@osdk/shared.net\";\nimport { consola } from \"consola\";\nimport { USER_AGENT } from \"./UserAgent.js\";\nexport function createFetch(tokenProvider, fetchFn = fetch) {\n return createFetchHeaderMutator(createRequestLoggingFetch(createErrorExitingFetch(createFetchOrThrow(fetchFn))), async headers => {\n const token = await tokenProvider();\n headers.set(\"Authorization\", `Bearer ${token}`);\n headers.set(\"Fetch-User-Agent\", USER_AGENT);\n return headers;\n });\n}\nfunction createErrorExitingFetch(fetchFn = fetch) {\n return function errorExitingFetch(input, init) {\n return fetchFn(input, init).catch(handleFetchError);\n };\n}\nfunction handleFetchError(e) {\n if (!(e instanceof PalantirApiError)) {\n throw new ExitProcessError(1, \"Unexpected fetch error\");\n }\n let tip;\n if (e.statusCode === 401) {\n tip = \"Check your token is valid and has not expired or been disabled\";\n } else if (e.statusCode === 403) {\n tip = \"Check your token has the required scopes for this operation\";\n }\n let message = e.message;\n if (e.errorName === \"CannotDeleteDeployedVersion\") {\n message = \"The site version to delete is live and cannot be deleted\";\n tip = \"Run the `site version set` command to change the live site version\";\n } else if (e.errorName === \"InvalidVersion\") {\n message = \"The site version is invalid and must be a valid SemVer string\";\n } else if (e.errorName === \"VersionAlreadyExists\") {\n message = \"The site version already exists\";\n } else if (e.errorName === \"VersionNotFound\") {\n message = \"The site version could not be found\";\n }\n throw new ExitProcessError(1, message, tip, e);\n}\nfunction createRequestLoggingFetch(fetchFn = fetch) {\n return function requestLoggingFetch(input, init) {\n const requestLog = typeof input === \"string\" || input instanceof URL ? `${init?.method ?? \"GET\"}: ${input.toString().trim()}` : `${input.method ?? \"GET\"}: ${input.url.toString().trim()}`;\n consola.trace(requestLog);\n return fetchFn(input, init).then(a => {\n consola.trace(`FINISH ${requestLog}`);\n return a;\n });\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT = `osdk-cli/${process.env.PACKAGE_VERSION}`;","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function deleteVersion(ctx, thirdPartyAppRid, version) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/${version}?preview=true`;\n await fetch(url, {\n method: \"DELETE\"\n });\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function deployWebsite(ctx, thirdPartyAppRid, request) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/deploy?preview=true`;\n const result = await fetch(url, {\n method: \"POST\",\n body: JSON.stringify(request),\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n return result.json();\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExitProcessError } from \"@osdk/cli.common\";\nimport { PalantirApiError } from \"@osdk/shared.net\";\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function getWebsite(ctx, thirdPartyAppRid) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website?preview=true`;\n try {\n const result = await fetch(url);\n return result.json();\n } catch (e) {\n // Revisit this error handling in the API\n if (e instanceof ExitProcessError && e.originalError != null && e.originalError instanceof PalantirApiError && e.originalError.errorName === \"WebsiteNotFound\") {\n return undefined;\n }\n throw e;\n }\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function listVersions(ctx, thirdPartyAppRid) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions?preview=true`;\n const result = await fetch(url);\n return result.json();\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function undeployWebsite(ctx, thirdPartyAppRid) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/undeploy?preview=true`;\n await fetch(url, {\n method: \"POST\"\n });\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function uploadVersion(ctx, thirdPartyAppRid, version, zipFile) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/upload?version=${version}&preview=true`;\n const result = await fetch(url, {\n method: \"POST\",\n body: zipFile,\n headers: {\n \"Content-Type\": \"application/octet-stream\"\n },\n duplex: \"half\" // Node hates me\n });\n return result.json();\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExitProcessError } from \"@osdk/cli.common\";\nimport { consola } from \"consola\";\nimport { promises as fsPromises } from \"node:fs\";\nimport path from \"node:path\";\nconst TOKEN_ENV_VARS = [\"FOUNDRY_TOKEN\", \"FOUNDRY_SDK_AUTH_TOKEN\"];\n\n/**\n * Loads a JWT Auth Token from an argument, a file, or environment variable returning the first found.\n * @param token The token as a string.\n * @param tokenFile The path to the token file.\n * @returns The token as a string.\n * @throws An error if no token is found.\n */\nexport async function loadToken(token, tokenFile) {\n if (token) {\n consola.debug(`Using token from --token option`);\n validate(token);\n return token;\n }\n if (tokenFile) {\n const loadedToken = await loadTokenFile(tokenFile);\n consola.debug(`Using token from --tokenFile=${loadedToken.filePath} option`);\n validate(loadedToken.token);\n return loadedToken.token;\n }\n for (const envVar of TOKEN_ENV_VARS) {\n const environmentToken = process.env[envVar];\n if (environmentToken) {\n consola.debug(`Using token from ${envVar} environment variable`);\n validate(environmentToken);\n if (envVar === \"FOUNDRY_SDK_AUTH_TOKEN\") {\n consola.warn(`Using FOUNDRY_SDK_AUTH_TOKEN environment variable is deprecated. Please use FOUNDRY_TOKEN instead.`);\n }\n return environmentToken;\n }\n }\n throw new ExitProcessError(2, `No token found.`, `You can supply a --token or --token-file option, or set the ${TOKEN_ENV_VARS[0]} environment variable`);\n}\n/**\n * Reads a JWT Auth Token from a file.\n * @param filePath The path to the token file.\n * @returns The token as a string.\n * @throws An error if the file cannot be read.\n */\nexport async function loadTokenFile(filePath) {\n let token;\n let resolvedPath;\n try {\n resolvedPath = path.resolve(filePath);\n token = await fsPromises.readFile(resolvedPath, \"utf8\");\n token = token.trim();\n } catch (error) {\n throw new ExitProcessError(2, `Unable to read token file \"${filePath}\": ${error}`);\n }\n return {\n filePath: resolvedPath,\n token\n };\n}\nexport function validate(token) {\n if (!isJWT(token)) {\n throw new ExitProcessError(2, `Token does not appear to be a JWT`);\n }\n}\nfunction isJWT(token) {\n // https://stackoverflow.com/a/65755789\n const jwtPattern = /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/;\n return jwtPattern.test(token);\n}"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk467BAS7X_cjs = require('./chunk-467BAS7X.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkHQDDGVB7_cjs = require('./chunk-HQDDGVB7.cjs');
|
|
5
5
|
var shared_net = require('@osdk/shared.net');
|
|
6
6
|
var consola = require('consola');
|
|
7
7
|
var fs = require('fs');
|
|
@@ -21,17 +21,17 @@ function createInternalClientContext(foundryUrl, tokenProvider) {
|
|
|
21
21
|
|
|
22
22
|
// src/net/third-party-applications/index.mts
|
|
23
23
|
var third_party_applications_exports = {};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
chunkHQDDGVB7_cjs.__export(third_party_applications_exports, {
|
|
25
|
+
deleteVersion: () => deleteVersion,
|
|
26
|
+
deployWebsite: () => deployWebsite,
|
|
27
|
+
getWebsite: () => getWebsite,
|
|
28
|
+
listVersions: () => listVersions,
|
|
29
|
+
undeployWebsite: () => undeployWebsite,
|
|
30
|
+
uploadVersion: () => uploadVersion
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// src/net/UserAgent.ts
|
|
34
|
-
var USER_AGENT = `osdk-cli/${"0.19.0
|
|
34
|
+
var USER_AGENT = `osdk-cli/${"0.19.0"}`;
|
|
35
35
|
|
|
36
36
|
// src/net/createFetch.mts
|
|
37
37
|
function createFetch(tokenProvider, fetchFn = fetch) {
|
|
@@ -58,14 +58,14 @@ function handleFetchError(e) {
|
|
|
58
58
|
tip = "Check your token has the required scopes for this operation";
|
|
59
59
|
}
|
|
60
60
|
let message = e.message;
|
|
61
|
-
if (e.errorName === "
|
|
61
|
+
if (e.errorName === "CannotDeleteDeployedVersion") {
|
|
62
62
|
message = "The site version to delete is live and cannot be deleted";
|
|
63
63
|
tip = "Run the `site version set` command to change the live site version";
|
|
64
|
-
} else if (e.errorName === "
|
|
64
|
+
} else if (e.errorName === "InvalidVersion") {
|
|
65
65
|
message = "The site version is invalid and must be a valid SemVer string";
|
|
66
|
-
} else if (e.errorName === "
|
|
66
|
+
} else if (e.errorName === "VersionAlreadyExists") {
|
|
67
67
|
message = "The site version already exists";
|
|
68
|
-
} else if (e.errorName === "
|
|
68
|
+
} else if (e.errorName === "VersionNotFound") {
|
|
69
69
|
message = "The site version could not be found";
|
|
70
70
|
}
|
|
71
71
|
throw new chunk467BAS7X_cjs.ExitProcessError(1, message, tip, e);
|
|
@@ -81,63 +81,63 @@ function createRequestLoggingFetch(fetchFn = fetch) {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// src/net/third-party-applications/
|
|
85
|
-
async function
|
|
84
|
+
// src/net/third-party-applications/deleteVersion.mts
|
|
85
|
+
async function deleteVersion(ctx, thirdPartyAppRid, version) {
|
|
86
86
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
87
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
87
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/${version}?preview=true`;
|
|
88
88
|
await fetch2(url, {
|
|
89
89
|
method: "DELETE"
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
// src/net/third-party-applications/
|
|
94
|
-
async function
|
|
93
|
+
// src/net/third-party-applications/deployWebsite.mts
|
|
94
|
+
async function deployWebsite(ctx, thirdPartyAppRid, request) {
|
|
95
95
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
96
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
97
|
-
await fetch2(url, {
|
|
98
|
-
method: "
|
|
96
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/deploy?preview=true`;
|
|
97
|
+
const result = await fetch2(url, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
body: JSON.stringify(request),
|
|
100
|
+
headers: {
|
|
101
|
+
"Content-Type": "application/json"
|
|
102
|
+
}
|
|
99
103
|
});
|
|
104
|
+
return result.json();
|
|
100
105
|
}
|
|
101
|
-
async function
|
|
106
|
+
async function getWebsite(ctx, thirdPartyAppRid) {
|
|
102
107
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
103
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
108
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website?preview=true`;
|
|
104
109
|
try {
|
|
105
110
|
const result = await fetch2(url);
|
|
106
111
|
return result.json();
|
|
107
112
|
} catch (e) {
|
|
108
|
-
if (e instanceof chunk467BAS7X_cjs.ExitProcessError && e.originalError != null && e.originalError instanceof shared_net.PalantirApiError && e.originalError.errorName === "
|
|
113
|
+
if (e instanceof chunk467BAS7X_cjs.ExitProcessError && e.originalError != null && e.originalError instanceof shared_net.PalantirApiError && e.originalError.errorName === "WebsiteNotFound") {
|
|
109
114
|
return void 0;
|
|
110
115
|
}
|
|
111
116
|
throw e;
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
// src/net/third-party-applications/
|
|
116
|
-
async function
|
|
120
|
+
// src/net/third-party-applications/listVersions.mts
|
|
121
|
+
async function listVersions(ctx, thirdPartyAppRid) {
|
|
117
122
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
118
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
123
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions?preview=true`;
|
|
119
124
|
const result = await fetch2(url);
|
|
120
125
|
return result.json();
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
// src/net/third-party-applications/
|
|
124
|
-
async function
|
|
128
|
+
// src/net/third-party-applications/undeployWebsite.mts
|
|
129
|
+
async function undeployWebsite(ctx, thirdPartyAppRid) {
|
|
125
130
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
126
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
127
|
-
|
|
128
|
-
method: "
|
|
129
|
-
body: JSON.stringify(request),
|
|
130
|
-
headers: {
|
|
131
|
-
"Content-Type": "application/json"
|
|
132
|
-
}
|
|
131
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/undeploy?preview=true`;
|
|
132
|
+
await fetch2(url, {
|
|
133
|
+
method: "POST"
|
|
133
134
|
});
|
|
134
|
-
return result.json();
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
// src/net/third-party-applications/
|
|
138
|
-
async function
|
|
137
|
+
// src/net/third-party-applications/uploadVersion.mts
|
|
138
|
+
async function uploadVersion(ctx, thirdPartyAppRid, version, zipFile) {
|
|
139
139
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
140
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
140
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/upload?version=${version}&preview=true`;
|
|
141
141
|
const result = await fetch2(url, {
|
|
142
142
|
method: "POST",
|
|
143
143
|
body: zipFile,
|
|
@@ -204,4 +204,4 @@ exports.createInternalClientContext = createInternalClientContext;
|
|
|
204
204
|
exports.loadToken = loadToken;
|
|
205
205
|
exports.third_party_applications_exports = third_party_applications_exports;
|
|
206
206
|
//# sourceMappingURL=out.js.map
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-RHOIENYA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/net/createInternalClientContext.mts","../../src/net/third-party-applications/index.mts","../../src/net/createFetch.mts","../../src/net/UserAgent.ts","../../src/net/third-party-applications/deleteVersion.mts","../../src/net/third-party-applications/deployWebsite.mts","../../src/net/third-party-applications/getWebsite.mts","../../src/net/third-party-applications/listVersions.mts","../../src/net/third-party-applications/undeployWebsite.mts","../../src/net/third-party-applications/uploadVersion.mts","../../src/util/token.ts"],"names":["fetch","PalantirApiError","consola"],"mappings":";;;;;;;;AAgBO,SAAS,4BAA4B,YAAY,eAAe;AACrE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;;;ACrBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBA,SAAS,0BAA0B,oBAAoB,wBAAwB;AAC/E,SAAS,eAAe;;;ACFjB,IAAM,aAAa,YAAY,QAA2B;;;ADI1D,SAAS,YAAY,eAAe,UAAU,OAAO;AAC1D,SAAO,yBAAyB,0BAA0B,wBAAwB,mBAAmB,OAAO,CAAC,CAAC,GAAG,OAAM,YAAW;AAChI,UAAM,QAAQ,MAAM,cAAc;AAClC,YAAQ,IAAI,iBAAiB,UAAU,KAAK,EAAE;AAC9C,YAAQ,IAAI,oBAAoB,UAAU;AAC1C,WAAO;AAAA,EACT,CAAC;AACH;AACA,SAAS,wBAAwB,UAAU,OAAO;AAChD,SAAO,SAAS,kBAAkB,OAAO,MAAM;AAC7C,WAAO,QAAQ,OAAO,IAAI,EAAE,MAAM,gBAAgB;AAAA,EACpD;AACF;AACA,SAAS,iBAAiB,GAAG;AAC3B,MAAI,EAAE,aAAa,mBAAmB;AACpC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B,UAAM,IAAI,iBAAiB,GAAG,mCAAmC;AAAA,EACnE;AACF;AACA,SAAS,MAAM,OAAO;AAEpB,QAAM,aAAa;AACnB,SAAO,WAAW,KAAK,KAAK;AAC9B","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function createInternalClientContext(foundryUrl, tokenProvider) {\n return {\n tokenProvider,\n foundryUrl\n };\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { deleteVersion } from \"./deleteVersion.mjs\";\nexport { deployWebsite } from \"./deployWebsite.mjs\";\nexport { getWebsite } from \"./getWebsite.mjs\";\nexport { listVersions } from \"./listVersions.mjs\";\nexport { undeployWebsite } from \"./undeployWebsite.mjs\";\nexport { uploadVersion } from \"./uploadVersion.mjs\";","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExitProcessError } from \"@osdk/cli.common\";\nimport { createFetchHeaderMutator, createFetchOrThrow, PalantirApiError } from \"@osdk/shared.net\";\nimport { consola } from \"consola\";\nimport { USER_AGENT } from \"./UserAgent.js\";\nexport function createFetch(tokenProvider, fetchFn = fetch) {\n return createFetchHeaderMutator(createRequestLoggingFetch(createErrorExitingFetch(createFetchOrThrow(fetchFn))), async headers => {\n const token = await tokenProvider();\n headers.set(\"Authorization\", `Bearer ${token}`);\n headers.set(\"Fetch-User-Agent\", USER_AGENT);\n return headers;\n });\n}\nfunction createErrorExitingFetch(fetchFn = fetch) {\n return function errorExitingFetch(input, init) {\n return fetchFn(input, init).catch(handleFetchError);\n };\n}\nfunction handleFetchError(e) {\n if (!(e instanceof PalantirApiError)) {\n throw new ExitProcessError(1, \"Unexpected fetch error\");\n }\n let tip;\n if (e.statusCode === 401) {\n tip = \"Check your token is valid and has not expired or been disabled\";\n } else if (e.statusCode === 403) {\n tip = \"Check your token has the required scopes for this operation\";\n }\n let message = e.message;\n if (e.errorName === \"CannotDeleteDeployedVersion\") {\n message = \"The site version to delete is live and cannot be deleted\";\n tip = \"Run the `site version set` command to change the live site version\";\n } else if (e.errorName === \"InvalidVersion\") {\n message = \"The site version is invalid and must be a valid SemVer string\";\n } else if (e.errorName === \"VersionAlreadyExists\") {\n message = \"The site version already exists\";\n } else if (e.errorName === \"VersionNotFound\") {\n message = \"The site version could not be found\";\n }\n throw new ExitProcessError(1, message, tip, e);\n}\nfunction createRequestLoggingFetch(fetchFn = fetch) {\n return function requestLoggingFetch(input, init) {\n const requestLog = typeof input === \"string\" || input instanceof URL ? `${init?.method ?? \"GET\"}: ${input.toString().trim()}` : `${input.method ?? \"GET\"}: ${input.url.toString().trim()}`;\n consola.trace(requestLog);\n return fetchFn(input, init).then(a => {\n consola.trace(`FINISH ${requestLog}`);\n return a;\n });\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT = `osdk-cli/${process.env.PACKAGE_VERSION}`;","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function deleteVersion(ctx, thirdPartyAppRid, version) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/${version}?preview=true`;\n await fetch(url, {\n method: \"DELETE\"\n });\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function deployWebsite(ctx, thirdPartyAppRid, request) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/deploy?preview=true`;\n const result = await fetch(url, {\n method: \"POST\",\n body: JSON.stringify(request),\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n return result.json();\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExitProcessError } from \"@osdk/cli.common\";\nimport { PalantirApiError } from \"@osdk/shared.net\";\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function getWebsite(ctx, thirdPartyAppRid) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website?preview=true`;\n try {\n const result = await fetch(url);\n return result.json();\n } catch (e) {\n // Revisit this error handling in the API\n if (e instanceof ExitProcessError && e.originalError != null && e.originalError instanceof PalantirApiError && e.originalError.errorName === \"WebsiteNotFound\") {\n return undefined;\n }\n throw e;\n }\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function listVersions(ctx, thirdPartyAppRid) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions?preview=true`;\n const result = await fetch(url);\n return result.json();\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function undeployWebsite(ctx, thirdPartyAppRid) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/undeploy?preview=true`;\n await fetch(url, {\n method: \"POST\"\n });\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetch } from \"../createFetch.mjs\";\nexport async function uploadVersion(ctx, thirdPartyAppRid, version, zipFile) {\n const fetch = createFetch(ctx.tokenProvider);\n const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/upload?version=${version}&preview=true`;\n const result = await fetch(url, {\n method: \"POST\",\n body: zipFile,\n headers: {\n \"Content-Type\": \"application/octet-stream\"\n },\n duplex: \"half\" // Node hates me\n });\n return result.json();\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExitProcessError } from \"@osdk/cli.common\";\nimport { consola } from \"consola\";\nimport { promises as fsPromises } from \"node:fs\";\nimport path from \"node:path\";\nconst TOKEN_ENV_VARS = [\"FOUNDRY_TOKEN\", \"FOUNDRY_SDK_AUTH_TOKEN\"];\n\n/**\n * Loads a JWT Auth Token from an argument, a file, or environment variable returning the first found.\n * @param token The token as a string.\n * @param tokenFile The path to the token file.\n * @returns The token as a string.\n * @throws An error if no token is found.\n */\nexport async function loadToken(token, tokenFile) {\n if (token) {\n consola.debug(`Using token from --token option`);\n validate(token);\n return token;\n }\n if (tokenFile) {\n const loadedToken = await loadTokenFile(tokenFile);\n consola.debug(`Using token from --tokenFile=${loadedToken.filePath} option`);\n validate(loadedToken.token);\n return loadedToken.token;\n }\n for (const envVar of TOKEN_ENV_VARS) {\n const environmentToken = process.env[envVar];\n if (environmentToken) {\n consola.debug(`Using token from ${envVar} environment variable`);\n validate(environmentToken);\n if (envVar === \"FOUNDRY_SDK_AUTH_TOKEN\") {\n consola.warn(`Using FOUNDRY_SDK_AUTH_TOKEN environment variable is deprecated. Please use FOUNDRY_TOKEN instead.`);\n }\n return environmentToken;\n }\n }\n throw new ExitProcessError(2, `No token found.`, `You can supply a --token or --token-file option, or set the ${TOKEN_ENV_VARS[0]} environment variable`);\n}\n/**\n * Reads a JWT Auth Token from a file.\n * @param filePath The path to the token file.\n * @returns The token as a string.\n * @throws An error if the file cannot be read.\n */\nexport async function loadTokenFile(filePath) {\n let token;\n let resolvedPath;\n try {\n resolvedPath = path.resolve(filePath);\n token = await fsPromises.readFile(resolvedPath, \"utf8\");\n token = token.trim();\n } catch (error) {\n throw new ExitProcessError(2, `Unable to read token file \"${filePath}\": ${error}`);\n }\n return {\n filePath: resolvedPath,\n token\n };\n}\nexport function validate(token) {\n if (!isJWT(token)) {\n throw new ExitProcessError(2, `Token does not appear to be a JWT`);\n }\n}\nfunction isJWT(token) {\n // https://stackoverflow.com/a/65755789\n const jwtPattern = /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/;\n return jwtPattern.test(token);\n}"]}
|
package/build/js/{handleGenerate-ZYXEGPSG-Q3HISCOY.cjs → handleGenerate-YNVZFAXQ-3KAATT5S.cjs}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkEVW4VRJL_cjs = require('./chunk-EVW4VRJL.cjs');
|
|
4
4
|
var chunk467BAS7X_cjs = require('./chunk-467BAS7X.cjs');
|
|
5
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-HQDDGVB7.cjs');
|
|
6
6
|
var requests = require('@osdk/gateway/requests');
|
|
7
7
|
var generator = require('@osdk/generator');
|
|
8
8
|
var shared_net = require('@osdk/shared.net');
|
|
@@ -34,7 +34,7 @@ function _interopNamespace(e) {
|
|
|
34
34
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
35
35
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
36
36
|
|
|
37
|
-
var USER_AGENT = `osdk-cli.cmd.typescript/${"0.2.0
|
|
37
|
+
var USER_AGENT = `osdk-cli.cmd.typescript/${"0.2.0"}`;
|
|
38
38
|
async function handleGenerate(args) {
|
|
39
39
|
let success = false;
|
|
40
40
|
if (args.ontologyPath) {
|
|
@@ -110,7 +110,7 @@ async function generateClientSdk(ontology, args) {
|
|
|
110
110
|
await generateSourceFiles(args, ontology, createNormalFs());
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
|
-
await generator.__UNSTABLE_generateClientSdkPackage(args.packageName, args.version, args.beta ? "2.0" : "1.1", args.outDir, ontology, minimalFs, dependencyVersions, "0.19.0
|
|
113
|
+
await generator.__UNSTABLE_generateClientSdkPackage(args.packageName, args.version, args.beta ? "2.0" : "1.1", args.outDir, ontology, minimalFs, dependencyVersions, "0.19.0");
|
|
114
114
|
return true;
|
|
115
115
|
} catch (e) {
|
|
116
116
|
consola.consola.error("OSDK generation failed", e.message, e.stack);
|
|
@@ -123,7 +123,7 @@ async function getDependencyVersions() {
|
|
|
123
123
|
const typescriptVersion = ourPackageJson.devDependencies.typescript;
|
|
124
124
|
const tslibVersion = ourPackageJson.dependencies.tslib;
|
|
125
125
|
const areTheTypesWrongVersion = ourPackageJson.dependencies["@arethetypeswrong/cli"];
|
|
126
|
-
const osdkClientVersion = `^${"0.17.0
|
|
126
|
+
const osdkClientVersion = `^${"0.17.0"}`;
|
|
127
127
|
const osdkApiVersion = `^${"1.7.0"}`;
|
|
128
128
|
const osdkLegacyClientVersion = `^${"2.2.0"}`;
|
|
129
129
|
return {
|
|
@@ -173,4 +173,4 @@ function createNormalFs() {
|
|
|
173
173
|
exports.getDependencyVersions = getDependencyVersions;
|
|
174
174
|
exports.handleGenerate = handleGenerate;
|
|
175
175
|
//# sourceMappingURL=out.js.map
|
|
176
|
-
//# sourceMappingURL=handleGenerate-
|
|
176
|
+
//# sourceMappingURL=handleGenerate-YNVZFAXQ-3KAATT5S.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../cli.cmd.typescript/build/js/handleGenerate-YNVZFAXQ.mjs"],"names":[],"mappings":";;;;;;;;;;AAEA,SAAS,kBAAkB,+BAA+B;AAC1D,SAAS,qCAAqC,sCAAsC,yCAAyC;AAC7H,SAAS,qBAAqB,4BAA4B;AAC1D,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAG9B,IAAI,aAAa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,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AACA,IAAI;AACJ,eAAe,wBAAwB;AACrC,MAAI;AAA0B,WAAO;AACrC,QAAM,QAAa,aAAQ,cAAc,YAAY,GAAG,CAAC;AACzD,QAAM,qBAAqB,MAAM,OAAO,gBAAgB;AAAA,IACtD,KAAK;AAAA,EACP,CAAC;AACD,MAAI,CAAC,oBAAoB;AACvB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,SAAO,2BAA2B;AACpC;AACA,eAAe,oBAAoB,MAAM,UAAU,KAAK;AACtD,SAAO,KAAK,OAAO,uCAAuC,mCAAmC,UAAU,aAAa,KAAK,OAAO,GAAG,KAAK,KAAK,QAAQ,KAAK,WAAW;AACvK;AACA,SAAS,aAAa,SAAS;AAC7B,MAAI,YAAY,OAAO;AACrB,WAAO;AAAA,EACT,OAAO;AACL,WAAO,kBAAkB,OAAO,IAAI,UAAU;AAAA,EAChD;AACF;AACA,SAAS,iBAAiB;AACxB,SAAO;AAAA,IACL,WAAW,CAAC,OAAO,aAAa;AAC9B,aAAU,YAAS,UAAU,OAAO,UAAU,OAAO;AAAA,IACvD;AAAA,IACA,OAAO,OAAO,OAAO,YAAY;AAC/B,YAAS,YAAS,MAAM,OAAO,OAAO;AAAA,IACxC;AAAA,IACA,SAAS,OAAM,UAAY,YAAS,QAAQ,KAAK;AAAA,EACnD;AACF","sourcesContent":["import { YargsCheckError, ExitProcessError } from '@osdk/cli.common';\nimport invokeLoginFlow from '@osdk/cli.common/loginFlow';\nimport { listOntologiesV2, getOntologyFullMetadata } from '@osdk/gateway/requests';\nimport { __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionTwoPointZero, generateClientSdkVersionOneDotOne } from '@osdk/generator';\nimport { createClientContext, createOpenApiRequest } from '@osdk/shared.net';\nimport { consola } from 'consola';\nimport { findUp } from 'find-up';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\n\n// src/generate/handleGenerate.mts\nvar USER_AGENT = `osdk-cli.cmd.typescript/${\"0.2.0\"}`;\nasync function handleGenerate(args) {\n let success = false;\n if (args.ontologyPath) {\n success = await generateFromLocalFile(args);\n } else if (args.foundryUrl && args.clientId) {\n success = await generateFromStack(args);\n } else {\n throw new YargsCheckError(\"Must have specified ontologyPath or stack and clientId\");\n }\n if (success) {\n consola.info(\"OSDK Generated!\");\n } else {\n throw new ExitProcessError(1, \"Failed to generate the TypeScript SDK\");\n }\n}\nasync function generateFromLocalFile(args) {\n if (!fs.existsSync(args.ontologyPath)) {\n consola.error(`Ontology file does not exist: ${args.ontologyPath}`);\n return false;\n }\n const ontology = JSON.parse(await fs.promises.readFile(args.ontologyPath, \"utf-8\"));\n return await generateClientSdk(ontology, args);\n}\nasync function generateFromStack(args) {\n const {\n foundryUrl,\n clientId,\n ontologyWritePath\n } = args;\n const token = await invokeLoginFlow({\n clientId,\n foundryUrl,\n verbose: 0\n });\n const {\n fetch\n } = createClientContext({\n metadata: {\n userAgent: USER_AGENT\n }\n }, args.foundryUrl, () => token.access_token, USER_AGENT);\n try {\n const ontologies = await listOntologiesV2(createOpenApiRequest(foundryUrl, fetch));\n if (args.ontologyRid) {\n ontologies.data = ontologies.data.filter(o => o.rid === args.ontologyRid);\n }\n if (ontologies.data.length !== 1) {\n consola.error(`Could not look up ontology with these credentials. Found ${ontologies.data.length} ontologies.`);\n return false;\n }\n const ontology = await getOntologyFullMetadata(createOpenApiRequest(foundryUrl, fetch), ontologies.data[0].apiName);\n if (ontologyWritePath) {\n fs.writeFileSync(ontologyWritePath, JSON.stringify(ontology, null, 2));\n }\n return await generateClientSdk(ontology, args);\n } catch (e) {\n consola.error(\"Failed to generate the ontology\", e);\n return false;\n }\n}\nasync function generateClientSdk(ontology, args) {\n const minimalFs = createNormalFs();\n const dependencyVersions = await getDependencyVersions();\n try {\n if (args.clean) {\n consola.info(\"Cleaning output directory\", args.outDir);\n await fs.promises.rm(args.outDir, {\n recursive: true,\n force: true\n });\n }\n if (!args.asPackage) {\n await generateSourceFiles(args, ontology, createNormalFs());\n return true;\n }\n await __UNSTABLE_generateClientSdkPackage(args.packageName, args.version, args.beta ? \"2.0\" : \"1.1\", args.outDir, ontology, minimalFs, dependencyVersions, \"0.19.0\");\n return true;\n } catch (e) {\n consola.error(\"OSDK generation failed\", e.message, e.stack);\n return false;\n }\n}\nasync function getDependencyVersions() {\n const ourPackageJsonPath = await getOurPackageJsonPath();\n const ourPackageJson = JSON.parse(await fs.promises.readFile(ourPackageJsonPath, \"utf-8\"));\n const typescriptVersion = ourPackageJson.devDependencies.typescript;\n const tslibVersion = ourPackageJson.dependencies.tslib;\n const areTheTypesWrongVersion = ourPackageJson.dependencies[\"@arethetypeswrong/cli\"];\n const osdkClientVersion = `^${\"0.17.0\"}`;\n const osdkApiVersion = `^${\"1.7.0\"}`;\n const osdkLegacyClientVersion = `^${\"2.2.0\"}`;\n return {\n typescriptVersion,\n tslibVersion,\n areTheTypesWrongVersion,\n osdkApiVersion,\n osdkClientVersion,\n osdkLegacyClientVersion\n };\n}\nvar cachedOurPackageJsonPath;\nasync function getOurPackageJsonPath() {\n if (cachedOurPackageJsonPath) return cachedOurPackageJsonPath;\n const __dir = path.dirname(fileURLToPath(import.meta.url));\n const ourPackageJsonPath = await findUp(\"package.json\", {\n cwd: __dir\n });\n if (!ourPackageJsonPath) {\n throw new Error(\"Could not find our package.json\");\n }\n return cachedOurPackageJsonPath = ourPackageJsonPath;\n}\nasync function generateSourceFiles(args, ontology, fs2) {\n await (args.beta ? generateClientSdkVersionTwoPointZero : generateClientSdkVersionOneDotOne)(ontology, getUserAgent(args.version), fs2, args.outDir, args.packageType);\n}\nfunction getUserAgent(version) {\n if (version === \"dev\") {\n return \"typescript-sdk/dev osdk-cli/dev\";\n } else {\n return `typescript-sdk/${version} ${USER_AGENT}`;\n }\n}\nfunction createNormalFs() {\n return {\n writeFile: (path2, contents) => {\n return fs.promises.writeFile(path2, contents, \"utf-8\");\n },\n mkdir: async (path2, options) => {\n await fs.promises.mkdir(path2, options);\n },\n readdir: async path2 => fs.promises.readdir(path2)\n };\n}\nexport { getDependencyVersions, handleGenerate };"]}
|