@osdk/cli 0.18.0 → 0.19.0-main-20240430161814
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 +7 -0
- package/build/js/{chunk-7KPWDWPW.mjs → chunk-7662SBGP.mjs} +39 -39
- package/build/js/chunk-7662SBGP.mjs.map +1 -0
- package/build/js/{chunk-BV25PWLB.cjs → chunk-SD336GMJ.cjs} +39 -39
- package/build/js/chunk-SD336GMJ.cjs.map +1 -0
- package/build/js/{handleGenerate-O475QVDP-LPHRGOCS.mjs → handleGenerate-HUGJUFF2-FLKB6BT3.mjs} +4 -4
- package/build/js/handleGenerate-HUGJUFF2-FLKB6BT3.mjs.map +1 -0
- package/build/js/{handleGenerate-O475QVDP-36H6I4K6.cjs → handleGenerate-HUGJUFF2-KQARD36X.cjs} +4 -4
- package/build/js/handleGenerate-HUGJUFF2-KQARD36X.cjs.map +1 -0
- package/build/js/index.cjs +8 -8
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +8 -8
- package/build/js/index.mjs.map +1 -1
- package/build/js/{siteDeployCommand-WFDCTRE4.cjs → siteDeployCommand-GHNKC6RW.cjs} +9 -9
- package/build/js/siteDeployCommand-GHNKC6RW.cjs.map +1 -0
- package/build/js/{siteDeployCommand-BPKA37JG.mjs → siteDeployCommand-U6T4L2WN.mjs} +7 -7
- package/build/js/siteDeployCommand-U6T4L2WN.mjs.map +1 -0
- package/build/js/{versionDeleteCommand-OPW5GZJ7.cjs → versionDeleteCommand-BM3IM2CS.cjs} +5 -5
- package/build/js/versionDeleteCommand-BM3IM2CS.cjs.map +1 -0
- package/build/js/{versionDeleteCommand-Q6PV5OHT.mjs → versionDeleteCommand-CWOKGJ36.mjs} +3 -3
- package/build/js/versionDeleteCommand-CWOKGJ36.mjs.map +1 -0
- package/build/js/versionGetCommand-3JHQDWOZ.cjs +29 -0
- package/build/js/versionGetCommand-3JHQDWOZ.cjs.map +1 -0
- package/build/js/{versionGetCommand-X33VP7PZ.mjs → versionGetCommand-AUF23L76.mjs} +6 -5
- package/build/js/versionGetCommand-AUF23L76.mjs.map +1 -0
- package/build/js/{versionListCommand-MTMK4ZO7.cjs → versionListCommand-5ZDWGLEA.cjs} +6 -6
- package/build/js/versionListCommand-5ZDWGLEA.cjs.map +1 -0
- package/build/js/{versionListCommand-T2K6FMFG.mjs → versionListCommand-JBBL63SC.mjs} +4 -4
- package/build/js/versionListCommand-JBBL63SC.mjs.map +1 -0
- package/build/js/{versionSetCommand-EVMFV4VA.cjs → versionSetCommand-TKEVZJ33.cjs} +5 -5
- package/build/js/versionSetCommand-TKEVZJ33.cjs.map +1 -0
- package/build/js/{versionSetCommand-KM3YB43Q.mjs → versionSetCommand-YDU2OFIV.mjs} +3 -3
- package/build/js/versionSetCommand-YDU2OFIV.mjs.map +1 -0
- package/build/js/{versionUnsetCommand-BEU52IRT.cjs → versionUnsetCommand-BI7LZW2M.cjs} +5 -5
- package/build/js/{versionUnsetCommand-BEU52IRT.cjs.map → versionUnsetCommand-BI7LZW2M.cjs.map} +1 -1
- package/build/js/{versionUnsetCommand-MZD3D2VF.mjs → versionUnsetCommand-L4OY7JLA.mjs} +3 -3
- package/build/js/{versionUnsetCommand-MZD3D2VF.mjs.map → versionUnsetCommand-L4OY7JLA.mjs.map} +1 -1
- 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 +9 -12
- package/build/js/chunk-7KPWDWPW.mjs.map +0 -1
- package/build/js/chunk-BV25PWLB.cjs.map +0 -1
- package/build/js/handleGenerate-O475QVDP-36H6I4K6.cjs.map +0 -1
- package/build/js/handleGenerate-O475QVDP-LPHRGOCS.mjs.map +0 -1
- package/build/js/siteDeployCommand-BPKA37JG.mjs.map +0 -1
- package/build/js/siteDeployCommand-WFDCTRE4.cjs.map +0 -1
- package/build/js/versionDeleteCommand-OPW5GZJ7.cjs.map +0 -1
- package/build/js/versionDeleteCommand-Q6PV5OHT.mjs.map +0 -1
- package/build/js/versionGetCommand-X33VP7PZ.mjs.map +0 -1
- package/build/js/versionGetCommand-XNI4OY7J.cjs +0 -28
- package/build/js/versionGetCommand-XNI4OY7J.cjs.map +0 -1
- package/build/js/versionListCommand-MTMK4ZO7.cjs.map +0 -1
- package/build/js/versionListCommand-T2K6FMFG.mjs.map +0 -1
- package/build/js/versionSetCommand-EVMFV4VA.cjs.map +0 -1
- package/build/js/versionSetCommand-KM3YB43Q.mjs.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/CHANGELOG.md
CHANGED
|
@@ -16,16 +16,16 @@ function createInternalClientContext(foundryUrl, tokenProvider) {
|
|
|
16
16
|
// src/net/third-party-applications/index.mts
|
|
17
17
|
var third_party_applications_exports = {};
|
|
18
18
|
__export(third_party_applications_exports, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
deleteVersion: () => deleteVersion,
|
|
20
|
+
deployWebsite: () => deployWebsite,
|
|
21
|
+
getWebsite: () => getWebsite,
|
|
22
|
+
listVersions: () => listVersions,
|
|
23
|
+
undeployWebsite: () => undeployWebsite,
|
|
24
|
+
uploadVersion: () => uploadVersion
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
// src/net/UserAgent.ts
|
|
28
|
-
var USER_AGENT = `osdk-cli/${"0.
|
|
28
|
+
var USER_AGENT = `osdk-cli/${"0.19.0-main-20240430161814"}`;
|
|
29
29
|
|
|
30
30
|
// src/net/createFetch.mts
|
|
31
31
|
function createFetch(tokenProvider, fetchFn = fetch) {
|
|
@@ -52,14 +52,14 @@ function handleFetchError(e) {
|
|
|
52
52
|
tip = "Check your token has the required scopes for this operation";
|
|
53
53
|
}
|
|
54
54
|
let message = e.message;
|
|
55
|
-
if (e.errorName === "
|
|
55
|
+
if (e.errorName === "CannotDeleteDeployedVersion") {
|
|
56
56
|
message = "The site version to delete is live and cannot be deleted";
|
|
57
57
|
tip = "Run the `site version set` command to change the live site version";
|
|
58
|
-
} else if (e.errorName === "
|
|
58
|
+
} else if (e.errorName === "InvalidVersion") {
|
|
59
59
|
message = "The site version is invalid and must be a valid SemVer string";
|
|
60
|
-
} else if (e.errorName === "
|
|
60
|
+
} else if (e.errorName === "VersionAlreadyExists") {
|
|
61
61
|
message = "The site version already exists";
|
|
62
|
-
} else if (e.errorName === "
|
|
62
|
+
} else if (e.errorName === "VersionNotFound") {
|
|
63
63
|
message = "The site version could not be found";
|
|
64
64
|
}
|
|
65
65
|
throw new ExitProcessError(1, message, tip, e);
|
|
@@ -75,63 +75,63 @@ function createRequestLoggingFetch(fetchFn = fetch) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
// src/net/third-party-applications/
|
|
79
|
-
async function
|
|
78
|
+
// src/net/third-party-applications/deleteVersion.mts
|
|
79
|
+
async function deleteVersion(ctx, thirdPartyAppRid, version) {
|
|
80
80
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
81
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
81
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/${version}?preview=true`;
|
|
82
82
|
await fetch2(url, {
|
|
83
83
|
method: "DELETE"
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
// src/net/third-party-applications/
|
|
88
|
-
async function
|
|
87
|
+
// src/net/third-party-applications/deployWebsite.mts
|
|
88
|
+
async function deployWebsite(ctx, thirdPartyAppRid, request) {
|
|
89
89
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
90
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
91
|
-
await fetch2(url, {
|
|
92
|
-
method: "
|
|
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
|
+
}
|
|
93
97
|
});
|
|
98
|
+
return result.json();
|
|
94
99
|
}
|
|
95
|
-
async function
|
|
100
|
+
async function getWebsite(ctx, thirdPartyAppRid) {
|
|
96
101
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
97
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
102
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website?preview=true`;
|
|
98
103
|
try {
|
|
99
104
|
const result = await fetch2(url);
|
|
100
105
|
return result.json();
|
|
101
106
|
} catch (e) {
|
|
102
|
-
if (e instanceof ExitProcessError && e.originalError != null && e.originalError instanceof PalantirApiError && e.originalError.errorName === "
|
|
107
|
+
if (e instanceof ExitProcessError && e.originalError != null && e.originalError instanceof PalantirApiError && e.originalError.errorName === "WebsiteNotFound") {
|
|
103
108
|
return void 0;
|
|
104
109
|
}
|
|
105
110
|
throw e;
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
// src/net/third-party-applications/
|
|
110
|
-
async function
|
|
114
|
+
// src/net/third-party-applications/listVersions.mts
|
|
115
|
+
async function listVersions(ctx, thirdPartyAppRid) {
|
|
111
116
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
112
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
117
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions?preview=true`;
|
|
113
118
|
const result = await fetch2(url);
|
|
114
119
|
return result.json();
|
|
115
120
|
}
|
|
116
121
|
|
|
117
|
-
// src/net/third-party-applications/
|
|
118
|
-
async function
|
|
122
|
+
// src/net/third-party-applications/undeployWebsite.mts
|
|
123
|
+
async function undeployWebsite(ctx, thirdPartyAppRid) {
|
|
119
124
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
120
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
121
|
-
|
|
122
|
-
method: "
|
|
123
|
-
body: JSON.stringify(request),
|
|
124
|
-
headers: {
|
|
125
|
-
"Content-Type": "application/json"
|
|
126
|
-
}
|
|
125
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/undeploy?preview=true`;
|
|
126
|
+
await fetch2(url, {
|
|
127
|
+
method: "POST"
|
|
127
128
|
});
|
|
128
|
-
return result.json();
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
// src/net/third-party-applications/
|
|
132
|
-
async function
|
|
131
|
+
// src/net/third-party-applications/uploadVersion.mts
|
|
132
|
+
async function uploadVersion(ctx, thirdPartyAppRid, version, zipFile) {
|
|
133
133
|
const fetch2 = createFetch(ctx.tokenProvider);
|
|
134
|
-
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/
|
|
134
|
+
const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/website/versions/upload?version=${version}&preview=true`;
|
|
135
135
|
const result = await fetch2(url, {
|
|
136
136
|
method: "POST",
|
|
137
137
|
body: zipFile,
|
|
@@ -196,4 +196,4 @@ function isJWT(token) {
|
|
|
196
196
|
|
|
197
197
|
export { createInternalClientContext, loadToken, third_party_applications_exports };
|
|
198
198
|
//# sourceMappingURL=out.js.map
|
|
199
|
-
//# sourceMappingURL=chunk-
|
|
199
|
+
//# sourceMappingURL=chunk-7662SBGP.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,4BAA2B;;;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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ACd,UAAM,IAAI,iBAAiB,GAAG,8BAA8B,QAAQ,MAAM,KAAK,EAAE;AAAA,EACnF;AACA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,EACF;AACF;AACO,SAAS,SAAS,OAAO;AAC9B,MAAI,CAAC,MAAM,KAAK,GAAG;AACjB,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}"]}
|
|
@@ -22,16 +22,16 @@ function createInternalClientContext(foundryUrl, tokenProvider) {
|
|
|
22
22
|
// src/net/third-party-applications/index.mts
|
|
23
23
|
var third_party_applications_exports = {};
|
|
24
24
|
chunkHQDDGVB7_cjs.__export(third_party_applications_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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.
|
|
34
|
+
var USER_AGENT = `osdk-cli/${"0.19.0-main-20240430161814"}`;
|
|
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-SD336GMJ.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,4BAA2B;;;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;AAA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AA,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-O475QVDP-LPHRGOCS.mjs → handleGenerate-HUGJUFF2-FLKB6BT3.mjs}
RENAMED
|
@@ -10,7 +10,7 @@ import * as fs from 'fs';
|
|
|
10
10
|
import * as path from 'path';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
12
|
|
|
13
|
-
var USER_AGENT = `osdk-cli.cmd.typescript/${"0.
|
|
13
|
+
var USER_AGENT = `osdk-cli.cmd.typescript/${"0.2.0-main-20240430161814"}`;
|
|
14
14
|
async function handleGenerate(args) {
|
|
15
15
|
let success = false;
|
|
16
16
|
if (args.ontologyPath) {
|
|
@@ -86,7 +86,7 @@ async function generateClientSdk(ontology, args) {
|
|
|
86
86
|
await generateSourceFiles(args, ontology, createNormalFs());
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
|
-
await __UNSTABLE_generateClientSdkPackage(args.packageName, args.version, args.beta ? "2.0" : "1.1", args.outDir, ontology, minimalFs, dependencyVersions, "0.
|
|
89
|
+
await __UNSTABLE_generateClientSdkPackage(args.packageName, args.version, args.beta ? "2.0" : "1.1", args.outDir, ontology, minimalFs, dependencyVersions, "0.19.0-main-20240430161814");
|
|
90
90
|
return true;
|
|
91
91
|
} catch (e) {
|
|
92
92
|
consola.error("OSDK generation failed", e.message, e.stack);
|
|
@@ -99,7 +99,7 @@ async function getDependencyVersions() {
|
|
|
99
99
|
const typescriptVersion = ourPackageJson.devDependencies.typescript;
|
|
100
100
|
const tslibVersion = ourPackageJson.dependencies.tslib;
|
|
101
101
|
const areTheTypesWrongVersion = ourPackageJson.dependencies["@arethetypeswrong/cli"];
|
|
102
|
-
const osdkClientVersion = `^${"0.
|
|
102
|
+
const osdkClientVersion = `^${"0.17.0-main-20240430161814"}`;
|
|
103
103
|
const osdkApiVersion = `^${"1.7.0"}`;
|
|
104
104
|
const osdkLegacyClientVersion = `^${"2.2.0"}`;
|
|
105
105
|
return {
|
|
@@ -148,4 +148,4 @@ function createNormalFs() {
|
|
|
148
148
|
|
|
149
149
|
export { getDependencyVersions, handleGenerate };
|
|
150
150
|
//# sourceMappingURL=out.js.map
|
|
151
|
-
//# sourceMappingURL=handleGenerate-
|
|
151
|
+
//# sourceMappingURL=handleGenerate-HUGJUFF2-FLKB6BT3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../cli.cmd.typescript/build/js/handleGenerate-HUGJUFF2.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,2BAA2B,2BAA2B;AACvE,eAAe,eAAe,MAAM;AAClC,MAAI,UAAU;AACd,MAAI,KAAK,cAAc;AACrB,cAAU,MAAM,sBAAsB,IAAI;AAAA,EAC5C,WAAW,KAAK,cAAc,KAAK,UAAU;AAC3C,cAAU,MAAM,kBAAkB,IAAI;AAAA,EACxC,OAAO;AACL,UAAM,IAAI,gBAAgB,wDAAwD;AAAA,EACpF;AACA,MAAI,SAAS;AACX,YAAQ,KAAK,iBAAiB;AAAA,EAChC,OAAO;AACL,UAAM,IAAI,iBAAiB,GAAG,uCAAuC;AAAA,EACvE;AACF;AACA,eAAe,sBAAsB,MAAM;AACzC,MAAI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tD,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-main-20240430161814\"}`;\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-main-20240430161814\");\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-main-20240430161814\"}`;\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 };"]}
|
package/build/js/{handleGenerate-O475QVDP-36H6I4K6.cjs → handleGenerate-HUGJUFF2-KQARD36X.cjs}
RENAMED
|
@@ -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.
|
|
37
|
+
var USER_AGENT = `osdk-cli.cmd.typescript/${"0.2.0-main-20240430161814"}`;
|
|
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.
|
|
113
|
+
await generator.__UNSTABLE_generateClientSdkPackage(args.packageName, args.version, args.beta ? "2.0" : "1.1", args.outDir, ontology, minimalFs, dependencyVersions, "0.19.0-main-20240430161814");
|
|
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.
|
|
126
|
+
const osdkClientVersion = `^${"0.17.0-main-20240430161814"}`;
|
|
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-HUGJUFF2-KQARD36X.cjs.map
|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AAA,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-main-20240430161814\"}`;\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-main-20240430161814\");\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-main-20240430161814\"}`;\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 };"]}
|
package/build/js/index.cjs
CHANGED
|
@@ -92,7 +92,7 @@ var generateCommand = {
|
|
|
92
92
|
});
|
|
93
93
|
},
|
|
94
94
|
handler: async (args) => {
|
|
95
|
-
const command10 = await import('./handleGenerate-
|
|
95
|
+
const command10 = await import('./handleGenerate-HUGJUFF2-KQARD36X.cjs');
|
|
96
96
|
await command10.handleGenerate(args);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -314,7 +314,7 @@ var command2 = {
|
|
|
314
314
|
}).middleware((args) => logDeployCommandConfigFileOverride(args, siteConfig));
|
|
315
315
|
},
|
|
316
316
|
handler: async (args) => {
|
|
317
|
-
const command10 = await import('./siteDeployCommand-
|
|
317
|
+
const command10 = await import('./siteDeployCommand-GHNKC6RW.cjs');
|
|
318
318
|
const {
|
|
319
319
|
version,
|
|
320
320
|
autoVersion,
|
|
@@ -357,7 +357,7 @@ var command3 = {
|
|
|
357
357
|
}).group(["yes"], "Delete Options");
|
|
358
358
|
},
|
|
359
359
|
handler: async (args) => {
|
|
360
|
-
const command10 = await import('./versionDeleteCommand-
|
|
360
|
+
const command10 = await import('./versionDeleteCommand-BM3IM2CS.cjs');
|
|
361
361
|
await command10.default(args);
|
|
362
362
|
}
|
|
363
363
|
};
|
|
@@ -371,7 +371,7 @@ var command4 = {
|
|
|
371
371
|
return argv;
|
|
372
372
|
},
|
|
373
373
|
handler: async (args) => {
|
|
374
|
-
const command10 = await import('./versionGetCommand-
|
|
374
|
+
const command10 = await import('./versionGetCommand-3JHQDWOZ.cjs');
|
|
375
375
|
await command10.default(args);
|
|
376
376
|
}
|
|
377
377
|
};
|
|
@@ -385,7 +385,7 @@ var command5 = {
|
|
|
385
385
|
return argv;
|
|
386
386
|
},
|
|
387
387
|
handler: async (args) => {
|
|
388
|
-
const command10 = await import('./versionListCommand-
|
|
388
|
+
const command10 = await import('./versionListCommand-5ZDWGLEA.cjs');
|
|
389
389
|
await command10.default(args);
|
|
390
390
|
}
|
|
391
391
|
};
|
|
@@ -403,7 +403,7 @@ var command6 = {
|
|
|
403
403
|
});
|
|
404
404
|
},
|
|
405
405
|
handler: async (args) => {
|
|
406
|
-
const command10 = await import('./versionSetCommand-
|
|
406
|
+
const command10 = await import('./versionSetCommand-TKEVZJ33.cjs');
|
|
407
407
|
await command10.default(args);
|
|
408
408
|
}
|
|
409
409
|
};
|
|
@@ -421,7 +421,7 @@ var command7 = {
|
|
|
421
421
|
}).group(["yes"], "Unset Options");
|
|
422
422
|
},
|
|
423
423
|
handler: async (args) => {
|
|
424
|
-
const command10 = await import('./versionUnsetCommand-
|
|
424
|
+
const command10 = await import('./versionUnsetCommand-BI7LZW2M.cjs');
|
|
425
425
|
await command10.default(args);
|
|
426
426
|
}
|
|
427
427
|
};
|
|
@@ -503,7 +503,7 @@ async function logConfigFileMiddleware() {
|
|
|
503
503
|
|
|
504
504
|
// src/cli.ts
|
|
505
505
|
async function cli(args = process.argv) {
|
|
506
|
-
consola.consola.info(`Palantir OSDK CLI ${"0.
|
|
506
|
+
consola.consola.info(`Palantir OSDK CLI ${"0.19.0-main-20240430161814"}
|
|
507
507
|
`);
|
|
508
508
|
const base = chunk467BAS7X_cjs.getYargsBase(args);
|
|
509
509
|
try {
|