@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.
Files changed (133) hide show
  1. package/CHANGELOG.md +3 -6
  2. package/README.md +148 -0
  3. package/build/js/chunk-3NRUGBBO.browser.mjs +15 -0
  4. package/build/js/chunk-3NRUGBBO.browser.mjs.map +1 -0
  5. package/build/js/chunk-C5C5AQYT.browser.mjs +9 -0
  6. package/build/js/{chunk-ZSTKOCBT.mjs → chunk-E2SEJZTC.mjs} +1 -1
  7. package/build/js/chunk-F6DFEGKQ.browser.mjs +118 -0
  8. package/build/js/chunk-F6DFEGKQ.browser.mjs.map +1 -0
  9. package/build/js/chunk-FRT6INSG.browser.mjs +65 -0
  10. package/build/js/chunk-FRT6INSG.browser.mjs.map +1 -0
  11. package/build/js/{chunk-7G2FSZUY.cjs → chunk-HQDDGVB7.cjs} +1 -1
  12. package/build/js/chunk-HQDDGVB7.cjs.map +1 -0
  13. package/build/js/{chunk-DKCYYJ36.mjs → chunk-MQIOUPGJ.mjs} +40 -40
  14. package/build/js/chunk-MQIOUPGJ.mjs.map +1 -0
  15. package/build/js/chunk-NTRB7WUY.browser.mjs +199 -0
  16. package/build/js/chunk-NTRB7WUY.browser.mjs.map +1 -0
  17. package/build/js/{chunk-DKKDHTGT.cjs → chunk-RHOIENYA.cjs} +41 -41
  18. package/build/js/chunk-RHOIENYA.cjs.map +1 -0
  19. package/build/js/{handleGenerate-ZYXEGPSG-Q3HISCOY.cjs → handleGenerate-YNVZFAXQ-3KAATT5S.cjs} +5 -5
  20. package/build/js/handleGenerate-YNVZFAXQ-3KAATT5S.cjs.map +1 -0
  21. package/build/js/handleGenerate-YNVZFAXQ-FJO7YEOC.browser.mjs +151 -0
  22. package/build/js/handleGenerate-YNVZFAXQ-FJO7YEOC.browser.mjs.map +1 -0
  23. package/build/js/{handleGenerate-ZYXEGPSG-T7AGZBSH.mjs → handleGenerate-YNVZFAXQ-RJ45FF22.mjs} +5 -5
  24. package/build/js/handleGenerate-YNVZFAXQ-RJ45FF22.mjs.map +1 -0
  25. package/build/js/index.browser.mjs +527 -0
  26. package/build/js/index.browser.mjs.map +1 -0
  27. package/build/js/index.cjs +12 -12
  28. package/build/js/index.cjs.map +1 -1
  29. package/build/js/index.mjs +12 -12
  30. package/build/js/index.mjs.map +1 -1
  31. package/build/js/loginFlow-H6IOYVXH.browser.mjs +4 -0
  32. package/build/js/{loginFlow-3V5OVOTH.cjs → loginFlow-QTUKYZEL.cjs} +2 -2
  33. package/build/js/{loginFlow-IBTRFIH3.mjs → loginFlow-ZFVT2AFZ.mjs} +2 -2
  34. package/build/js/loginFlow-ZFVT2AFZ.mjs.map +1 -0
  35. package/build/js/siteDeployCommand-CY2WWLXP.browser.mjs +135 -0
  36. package/build/js/siteDeployCommand-CY2WWLXP.browser.mjs.map +1 -0
  37. package/build/js/{siteDeployCommand-P2IDJRWT.cjs → siteDeployCommand-EYM2TXE6.cjs} +10 -10
  38. package/build/js/siteDeployCommand-EYM2TXE6.cjs.map +1 -0
  39. package/build/js/{siteDeployCommand-PJJT2NNF.mjs → siteDeployCommand-GV3QRLZD.mjs} +8 -8
  40. package/build/js/siteDeployCommand-GV3QRLZD.mjs.map +1 -0
  41. package/build/js/versionDeleteCommand-2OJI3HPR.browser.mjs +33 -0
  42. package/build/js/versionDeleteCommand-2OJI3HPR.browser.mjs.map +1 -0
  43. package/build/js/{versionDeleteCommand-4FUKGJQ2.mjs → versionDeleteCommand-E6727BXW.mjs} +4 -4
  44. package/build/js/versionDeleteCommand-E6727BXW.mjs.map +1 -0
  45. package/build/js/{versionDeleteCommand-X7IHRPH3.cjs → versionDeleteCommand-LZJDT2HD.cjs} +6 -6
  46. package/build/js/versionDeleteCommand-LZJDT2HD.cjs.map +1 -0
  47. package/build/js/versionGetCommand-4LGRRMQM.cjs +29 -0
  48. package/build/js/versionGetCommand-4LGRRMQM.cjs.map +1 -0
  49. package/build/js/versionGetCommand-A6BVV3GL.browser.mjs +27 -0
  50. package/build/js/versionGetCommand-A6BVV3GL.browser.mjs.map +1 -0
  51. package/build/js/{versionGetCommand-7ZWZ3BQY.mjs → versionGetCommand-XCXFCFAP.mjs} +7 -6
  52. package/build/js/versionGetCommand-XCXFCFAP.mjs.map +1 -0
  53. package/build/js/versionListCommand-2LWNOKV2.browser.mjs +32 -0
  54. package/build/js/versionListCommand-2LWNOKV2.browser.mjs.map +1 -0
  55. package/build/js/{versionListCommand-5K3FUVCO.mjs → versionListCommand-TSPBNGWW.mjs} +5 -5
  56. package/build/js/versionListCommand-TSPBNGWW.mjs.map +1 -0
  57. package/build/js/{versionListCommand-RZYNYI4A.cjs → versionListCommand-ZHIPVSQP.cjs} +7 -7
  58. package/build/js/versionListCommand-ZHIPVSQP.cjs.map +1 -0
  59. package/build/js/{versionSetCommand-C2NZCHJY.mjs → versionSetCommand-FUZKBVIF.mjs} +4 -4
  60. package/build/js/versionSetCommand-FUZKBVIF.mjs.map +1 -0
  61. package/build/js/versionSetCommand-SN2KIDW3.browser.mjs +27 -0
  62. package/build/js/versionSetCommand-SN2KIDW3.browser.mjs.map +1 -0
  63. package/build/js/{versionSetCommand-CXMMMNSS.cjs → versionSetCommand-TAHDYWUK.cjs} +6 -6
  64. package/build/js/versionSetCommand-TAHDYWUK.cjs.map +1 -0
  65. package/build/js/{versionUnsetCommand-ZQHUGPWQ.mjs → versionUnsetCommand-BJPJ2XCE.mjs} +4 -4
  66. package/build/js/{versionUnsetCommand-I46GWIIR.cjs.map → versionUnsetCommand-BJPJ2XCE.mjs.map} +1 -1
  67. package/build/js/{versionUnsetCommand-I46GWIIR.cjs → versionUnsetCommand-MGG4LFZL.cjs} +6 -6
  68. package/build/js/{versionUnsetCommand-ZQHUGPWQ.mjs.map → versionUnsetCommand-MGG4LFZL.cjs.map} +1 -1
  69. package/build/js/versionUnsetCommand-Q6IDL3M4.browser.mjs +32 -0
  70. package/build/js/versionUnsetCommand-Q6IDL3M4.browser.mjs.map +1 -0
  71. package/build/types/commands/site/version/get/versionGetCommand.d.mts.map +1 -1
  72. package/build/types/net/third-party-applications/DeployWebsiteRequest.d.mts +4 -0
  73. package/build/types/net/third-party-applications/DeployWebsiteRequest.d.mts.map +1 -0
  74. package/build/types/net/third-party-applications/ListVersionsResponse.d.mts +6 -0
  75. package/build/types/net/third-party-applications/ListVersionsResponse.d.mts.map +1 -0
  76. package/build/types/net/third-party-applications/Version.d.mts +4 -0
  77. package/build/types/net/third-party-applications/Version.d.mts.map +1 -0
  78. package/build/types/net/third-party-applications/Website.d.mts +5 -0
  79. package/build/types/net/third-party-applications/Website.d.mts.map +1 -0
  80. package/build/types/net/third-party-applications/deleteVersion.d.mts +4 -0
  81. package/build/types/net/third-party-applications/deleteVersion.d.mts.map +1 -0
  82. package/build/types/net/third-party-applications/deployWebsite.d.mts +6 -0
  83. package/build/types/net/third-party-applications/deployWebsite.d.mts.map +1 -0
  84. package/build/types/net/third-party-applications/getWebsite.d.mts +5 -0
  85. package/build/types/net/third-party-applications/getWebsite.d.mts.map +1 -0
  86. package/build/types/net/third-party-applications/index.d.mts +10 -10
  87. package/build/types/net/third-party-applications/index.d.mts.map +1 -1
  88. package/build/types/net/third-party-applications/listVersions.d.mts +5 -0
  89. package/build/types/net/third-party-applications/listVersions.d.mts.map +1 -0
  90. package/build/types/net/third-party-applications/undeployWebsite.d.mts +4 -0
  91. package/build/types/net/third-party-applications/undeployWebsite.d.mts.map +1 -0
  92. package/build/types/net/third-party-applications/uploadVersion.d.mts +5 -0
  93. package/build/types/net/third-party-applications/uploadVersion.d.mts.map +1 -0
  94. package/package.json +6 -4
  95. package/build/js/chunk-DKCYYJ36.mjs.map +0 -1
  96. package/build/js/chunk-DKKDHTGT.cjs.map +0 -1
  97. package/build/js/handleGenerate-ZYXEGPSG-Q3HISCOY.cjs.map +0 -1
  98. package/build/js/handleGenerate-ZYXEGPSG-T7AGZBSH.mjs.map +0 -1
  99. package/build/js/siteDeployCommand-P2IDJRWT.cjs.map +0 -1
  100. package/build/js/siteDeployCommand-PJJT2NNF.mjs.map +0 -1
  101. package/build/js/versionDeleteCommand-4FUKGJQ2.mjs.map +0 -1
  102. package/build/js/versionDeleteCommand-X7IHRPH3.cjs.map +0 -1
  103. package/build/js/versionGetCommand-3HMZEFY6.cjs +0 -28
  104. package/build/js/versionGetCommand-3HMZEFY6.cjs.map +0 -1
  105. package/build/js/versionGetCommand-7ZWZ3BQY.mjs.map +0 -1
  106. package/build/js/versionListCommand-5K3FUVCO.mjs.map +0 -1
  107. package/build/js/versionListCommand-RZYNYI4A.cjs.map +0 -1
  108. package/build/js/versionSetCommand-C2NZCHJY.mjs.map +0 -1
  109. package/build/js/versionSetCommand-CXMMMNSS.cjs.map +0 -1
  110. package/build/types/net/third-party-applications/ListWebsiteVersionsResponse.d.mts +0 -6
  111. package/build/types/net/third-party-applications/ListWebsiteVersionsResponse.d.mts.map +0 -1
  112. package/build/types/net/third-party-applications/UpdateWebsiteDeploymentRequest.d.mts +0 -4
  113. package/build/types/net/third-party-applications/UpdateWebsiteDeploymentRequest.d.mts.map +0 -1
  114. package/build/types/net/third-party-applications/WebsiteDeployment.d.mts +0 -5
  115. package/build/types/net/third-party-applications/WebsiteDeployment.d.mts.map +0 -1
  116. package/build/types/net/third-party-applications/WebsiteVersion.d.mts +0 -4
  117. package/build/types/net/third-party-applications/WebsiteVersion.d.mts.map +0 -1
  118. package/build/types/net/third-party-applications/deleteWebsiteDeployment.d.mts +0 -4
  119. package/build/types/net/third-party-applications/deleteWebsiteDeployment.d.mts.map +0 -1
  120. package/build/types/net/third-party-applications/deleteWebsiteVersion.d.mts +0 -4
  121. package/build/types/net/third-party-applications/deleteWebsiteVersion.d.mts.map +0 -1
  122. package/build/types/net/third-party-applications/getWebsiteDeployment.d.mts +0 -5
  123. package/build/types/net/third-party-applications/getWebsiteDeployment.d.mts.map +0 -1
  124. package/build/types/net/third-party-applications/listWebsiteVersions.d.mts +0 -5
  125. package/build/types/net/third-party-applications/listWebsiteVersions.d.mts.map +0 -1
  126. package/build/types/net/third-party-applications/updateWebsiteDeployment.d.mts +0 -6
  127. package/build/types/net/third-party-applications/updateWebsiteDeployment.d.mts.map +0 -1
  128. package/build/types/net/third-party-applications/uploadWebsiteVersion.d.mts +0 -5
  129. package/build/types/net/third-party-applications/uploadWebsiteVersion.d.mts.map +0 -1
  130. /package/build/js/{chunk-7G2FSZUY.cjs.map → chunk-C5C5AQYT.browser.mjs.map} +0 -0
  131. /package/build/js/{chunk-ZSTKOCBT.mjs.map → chunk-E2SEJZTC.mjs.map} +0 -0
  132. /package/build/js/{loginFlow-3V5OVOTH.cjs.map → loginFlow-H6IOYVXH.browser.mjs.map} +0 -0
  133. /package/build/js/{loginFlow-IBTRFIH3.mjs.map → loginFlow-QTUKYZEL.cjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,15 +1,12 @@
1
1
  # @osdk/cli
2
2
 
3
- ## 0.19.0-next-20240426195134
3
+ ## 0.19.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
+ - 4cd0d04: Move site command out of unstable
7
8
  - 63ff4b2: Only producing ESM now
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies [2bb1acb]
12
- - @osdk/generator@1.11.0-next-20240426195134
9
+ - fa7fc46: Update site APIs in preparation for stable
13
10
 
14
11
  ## 0.18.0
15
12
 
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @osdk/cli
2
+
3
+ A CLI for generating OSDKs and managing Foundry site deployments
4
+
5
+ The CLI may be run directly through npx with `npx @osdk/cli@latest`. When the NPM package is explicitly installed for example with `npm install -g @osdk/cli@latest` the `osdk` binary is also available.
6
+
7
+ ## Running locally
8
+
9
+ Run the following commands from the repository root:
10
+
11
+ ```sh
12
+ pnpm install
13
+ pnpm build
14
+ cd packages/cli
15
+ ./bin/osdk.mjs
16
+ ```
17
+
18
+ ## `site` subcommand
19
+
20
+ The site subcommand allows users to manage their Foundry site
21
+
22
+ ```
23
+ npx @osdk/cli site [subcommand]
24
+ ```
25
+
26
+ Common options
27
+
28
+ | Option | Description |
29
+ | ------------- | -------------------------------------------------- |
30
+ | --foundryUrl | URL for the Foundry stack [string] |
31
+ | --application | Application resource identifier (rid) [string] |
32
+ | --token | Foundry API token [string] |
33
+ | --tokenFile | Path to file containing Foundry API token [string] |
34
+
35
+ `--token` and `--tokenFile` are mutually exclusive and only one can be passed. If neither are passed the CLI runtime looks for these environment variables in order `[FOUNDRY_TOKEN, FOUNDRY_SDK_AUTH_TOKEN]`. If a token is not specified using any of those options, the CLI will exit with a failure.
36
+
37
+ ---
38
+
39
+ ### Project config file
40
+
41
+ A `foundry.config.json` file may be used in your project's root to simplify usage of the CLI by populating default values for commands. The current working directory will be traversed up to the root directory and the first `foundry.config.json` file, if found, will be used.
42
+
43
+ An example of a full `foundry.config.json` is show below:
44
+
45
+ ```json
46
+ {
47
+ "foundryUrl": "https://example.palantirfoundry.com",
48
+ "site": {
49
+ "application": "ri.third-party-applications.main.application.1c66b352-4e00-40d2-995d-061c9d533ace",
50
+ "directory": "./dist",
51
+ "autoVersion": {
52
+ "type": "git-describe",
53
+ "tagPrefix": ""
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ---
60
+
61
+ The `site` subcommand is not runnable without passing a specific subcommand i.e (`deploy` or `version`)
62
+
63
+ ### `deploy`subcommand
64
+
65
+ The deploy subcommand allows users to upload new versions of their site and set it as deployed
66
+
67
+ ```
68
+ npx @osdk/cli site deploy
69
+ ```
70
+
71
+ Deploy options
72
+
73
+ | Option | Description |
74
+ | ------------ | ------------------------------------------------------------------------------ |
75
+ | --directory | Directory containing site files [string] |
76
+ | --version | New version of site to deploy [string] |
77
+ | --uploadOnly | Upload new site version only without setting as live [boolean][default: false] |
78
+
79
+ Auto Version options
80
+
81
+ | Option | Description |
82
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
+ | --autoVersion | Enable auto versioning [string][choices: "git-describe"] |
84
+ | --gitTagPrefix | Prefix to match git tags on when 'git-describe' auto versioning is used. If not provided, all tags are matched and the prefix 'v ' is stripped if present. [string] |
85
+
86
+ `--version` and `--autoVersion` are mutually exclusive and only one can be passed.
87
+
88
+ If `git-describe` is used for `--autoVersion`, the CLI will try to infer the version by running the `git describe` command with optionally `--match=<gitTagPrefix>` set if `--gitTagPrefix` is passed.
89
+
90
+ ### `version` subcommand
91
+
92
+ The version subcommand allows users to manage their site versions.
93
+
94
+ The version subcommand is not runnable without passing a specific subcommand i.e (`list` or `get`)
95
+
96
+ #### `list` subcommand
97
+
98
+ The list subcommand allows users to list their site versions
99
+
100
+ ```
101
+ npx @osdk/cli site version list
102
+ ```
103
+
104
+ #### `get` subcommand
105
+
106
+ The get subcommand allows users to get their live site version
107
+
108
+ ```
109
+ npx @osdk/cli site version get
110
+ ```
111
+
112
+ #### `set <version>` subcommand
113
+
114
+ The set subcommand allows users to set their live site version
115
+
116
+ ```
117
+ npx @osdk/cli site version set 0.1.0
118
+ ```
119
+
120
+ #### `unset` subcommand
121
+
122
+ The unset subcommand allows users to clear their live site version
123
+
124
+ ```
125
+ npx @osdk/cli site version unset
126
+ ```
127
+
128
+ #### `delete <version>` subcommand
129
+
130
+ The delete subcommand allows users to delete a site version
131
+
132
+ ```
133
+ npx @osdk/cli site version delete 0.1.0
134
+ ```
135
+
136
+ ## Help and debugging
137
+
138
+ To see all supported commands and their expected arguments, run a command with the --help flag
139
+
140
+ ```
141
+ npx @osdk/cli site version --help
142
+ ```
143
+
144
+ For additional information for debugging, use the --verbose flag
145
+
146
+ ```
147
+ npx @osdk/cli site version --verbose
148
+ ```
@@ -0,0 +1,15 @@
1
+ import { consola } from 'consola';
2
+
3
+ // src/consola/handlePromptCancel.ts
4
+ function handlePromptCancel(promptResponse) {
5
+ const isFalse = typeof promptResponse === "boolean" && !promptResponse;
6
+ const isSigInt = typeof promptResponse === "symbol" && promptResponse.toString() === "Symbol(clack:cancel)";
7
+ if (isSigInt || isFalse) {
8
+ consola.fail("Operation cancelled");
9
+ process.exit(0);
10
+ }
11
+ }
12
+
13
+ export { handlePromptCancel };
14
+ //# sourceMappingURL=out.js.map
15
+ //# sourceMappingURL=chunk-3NRUGBBO.browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/consola/handlePromptCancel.ts"],"names":[],"mappings":";AAgBA,SAAS,eAAe;AACjB,SAAS,mBAAmB,gBAAgB;AACjD,QAAM,UAAU,OAAO,mBAAmB,aAAa,CAAC;AAExD,QAAM,WAAW,OAAO,mBAAmB,YAAY,eAAe,SAAS,MAAM;AACrF,MAAI,YAAY,SAAS;AACvB,YAAQ,KAAK,qBAAqB;AAClC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF","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\nimport { consola } from \"consola\";\nexport function handlePromptCancel(promptResponse) {\n const isFalse = typeof promptResponse === \"boolean\" && !promptResponse;\n // https://github.com/unjs/consola/issues/251\n const isSigInt = typeof promptResponse === \"symbol\" && promptResponse.toString() === \"Symbol(clack:cancel)\";\n if (isSigInt || isFalse) {\n consola.fail(\"Operation cancelled\");\n process.exit(0);\n }\n}"]}
@@ -0,0 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export { __export };
8
+ //# sourceMappingURL=out.js.map
9
+ //# sourceMappingURL=chunk-C5C5AQYT.browser.mjs.map
@@ -6,4 +6,4 @@ var __export = (target, all) => {
6
6
 
7
7
  export { __export };
8
8
  //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-ZSTKOCBT.mjs.map
9
+ //# sourceMappingURL=chunk-E2SEJZTC.mjs.map
@@ -0,0 +1,118 @@
1
+ import consola from 'consola';
2
+ import { getRandomValues, subtle } from 'crypto';
3
+ import { createServer } from 'http';
4
+ import { join } from 'path/posix';
5
+ import { exit } from 'process';
6
+ import { parse } from 'url';
7
+ import open from 'open';
8
+
9
+ // ../cli.common/build/js/public/loginFlow.mjs
10
+ function isTokenErrorResponse(response) {
11
+ return response.error != null;
12
+ }
13
+ var BROWSER_PROMPT_TIME_MS = 60 * 1e3;
14
+ async function invokeLoginFlow(args) {
15
+ consola.start(`Authenticating using application id: ${args.clientId}`);
16
+ const redirectUrl = "http://localhost:8080/auth/callback";
17
+ const port = parse(redirectUrl).port;
18
+ let resolve;
19
+ const authCode = new Promise((_res) => {
20
+ resolve = _res;
21
+ });
22
+ const server = createServer((req, res) => {
23
+ const query = parse(req.url, true).query;
24
+ res.end("Authenticated");
25
+ resolve(query["code"]);
26
+ });
27
+ server.on("error", (e) => {
28
+ if (e.code === "EADDRINUSE") {
29
+ consola.error(`Port ${port} is already in use, unable to perform authentication flow.`);
30
+ server.close();
31
+ exit(1);
32
+ }
33
+ });
34
+ server.listen(port);
35
+ const clientId = args.clientId;
36
+ const state = generateRandomString();
37
+ const codeVerifier = generateRandomString();
38
+ const codeChallenge = await generateCodeChallenge(codeVerifier);
39
+ const authorizeUrl = generateAuthorizeUrl(args.foundryUrl, clientId, state, redirectUrl, codeChallenge);
40
+ try {
41
+ await open(authorizeUrl);
42
+ } catch {
43
+ consola.warn(`Unable to open browser, please open this url in your browser to to authenticate: ${authorizeUrl}`);
44
+ }
45
+ const browserPrompt = setTimeout(() => {
46
+ consola.warn(`Still waiting for the authentication to complete. Please open a browser to ${authorizeUrl}`);
47
+ }, BROWSER_PROMPT_TIME_MS);
48
+ const code = await authCode;
49
+ server.close();
50
+ clearTimeout(browserPrompt);
51
+ const token = await getTokenWithCodeVerifier(clientId, redirectUrl, code, args.foundryUrl, codeVerifier);
52
+ if (isTokenErrorResponse(token)) {
53
+ consola.error("Unable to authenticate", token.error, token.error_description);
54
+ exit(1);
55
+ }
56
+ consola.success(`Successfully authenticated!`);
57
+ return token;
58
+ }
59
+ function generateRandomString(length = 128) {
60
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
61
+ let output = [];
62
+ let array = new Uint8Array(1);
63
+ const maxIndex = 256 - 256 % characters.length;
64
+ while (output.length < length) {
65
+ getRandomValues(array);
66
+ if (array[0] < maxIndex) {
67
+ output.push(characters[array[0] % characters.length]);
68
+ }
69
+ }
70
+ return output.join("");
71
+ }
72
+ async function generateCodeChallenge(codeVerifier) {
73
+ const data = new TextEncoder().encode(codeVerifier);
74
+ const digest = await subtle.digest("SHA-256", data);
75
+ const codeChallengeMethod = "S256";
76
+ const codeChallenge = btoa(String.fromCharCode(...new Uint8Array(digest))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
77
+ return {
78
+ codeChallenge,
79
+ codeChallengeMethod
80
+ };
81
+ }
82
+ function generateAuthorizeUrl(baseUrl, clientId, state, redirectUrl, codeChallenge) {
83
+ const queryParams = new URLSearchParams();
84
+ queryParams.append("client_id", clientId);
85
+ queryParams.append("response_type", "code");
86
+ queryParams.append("state", state);
87
+ queryParams.append("redirect_uri", redirectUrl);
88
+ queryParams.append("code_challenge", codeChallenge.codeChallenge);
89
+ queryParams.append("code_challenge_method", codeChallenge.codeChallengeMethod);
90
+ queryParams.append("scope", ["offline_access", "api:read-data"].join(" "));
91
+ return join(baseUrl, "multipass", "api", "oauth2", "authorize") + `?` + queryParams.toString();
92
+ }
93
+ async function getTokenWithCodeVerifier(clientId, redirectUrl, code, baseUrl, codeVerifier) {
94
+ const body = new URLSearchParams();
95
+ body.append("client_id", clientId);
96
+ body.append("grant_type", "authorization_code");
97
+ body.append("code", code);
98
+ body.append("redirect_uri", redirectUrl);
99
+ body.append("code_verifier", codeVerifier);
100
+ const tokenUrl = join(baseUrl, "multipass", "api", "oauth2", "token") + `?state=${codeVerifier}`;
101
+ try {
102
+ const response = await fetch(tokenUrl, {
103
+ body: body.toString(),
104
+ headers: {
105
+ "Content-Type": "application/x-www-form-urlencoded"
106
+ },
107
+ method: "POST"
108
+ });
109
+ const responseText = await response.json();
110
+ return responseText;
111
+ } catch (e) {
112
+ throw new Error(`Failed to get token: ${e?.cause?.toString() ?? e?.toString() ?? "Unknown error"}`);
113
+ }
114
+ }
115
+
116
+ export { invokeLoginFlow };
117
+ //# sourceMappingURL=out.js.map
118
+ //# sourceMappingURL=chunk-F6DFEGKQ.browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../cli.common/build/js/public/loginFlow.mjs"],"names":[],"mappings":";AAAA,OAAO,aAAa;AACpB,SAAS,iBAAiB,cAAc;AACxC,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,OAAO,UAAU;AAKjB,SAAS,qBAAqB,UAAU;AACtC,SAAO,SAAS,SAAS;AAC3B;AAGA,IAAI,yBAAyB,KAAK;AAClC,eAAe,gBAAgB,MAAM;AACnC,UAAQ,MAAM,wCAAwC,KAAK,QAAQ,EAAE;AACrE,QAAM,cAAc;AACpB,QAAM,OAAO,MAAM,WAAW,EAAE;AAChC,MAAI;AACJ,QAAM,WAAW,IAAI,QAAQ,UAAQ;AACnC,cAAU;AAAA,EACZ,CAAC;AACD,QAAM,SAAS,aAAa,CAAC,KAAK,QAAQ;AACxC,UAAM,QAAQ,MAAM,IAAI,KAAK,IAAI,EAAE;AACnC,QAAI,IAAI,eAAe;AACvB,YAAQ,MAAM,MAAM,CAAC;AAAA,EACvB,CAAC;AACD,SAAO,GAAG,SAAS,OAAK;AACtB,QAAI,EAAE,SAAS,cAAc;AAC3B,cAAQ,MAAM,QAAQ,IAAI,4DAA4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,IAAI,MAAM,wBAAwB,GAAG,OAAO,SAAS,KAAK,GAAG,SAAS,KAAK,eAAe,EAAE;AAAA,EACpG;AACF","sourcesContent":["import consola from 'consola';\nimport { getRandomValues, subtle } from 'crypto';\nimport { createServer } from 'http';\nimport { join } from 'path/posix';\nimport { exit } from 'process';\nimport { parse } from 'url';\nimport open from 'open';\n\n// src/commands/auth/login/loginFlow.ts\n\n// src/commands/auth/login/token.ts\nfunction isTokenErrorResponse(response) {\n return response.error != null;\n}\n\n// src/commands/auth/login/loginFlow.ts\nvar BROWSER_PROMPT_TIME_MS = 60 * 1e3;\nasync function invokeLoginFlow(args) {\n consola.start(`Authenticating using application id: ${args.clientId}`);\n const redirectUrl = \"http://localhost:8080/auth/callback\";\n const port = parse(redirectUrl).port;\n let resolve;\n const authCode = new Promise(_res => {\n resolve = _res;\n });\n const server = createServer((req, res) => {\n const query = parse(req.url, true).query;\n res.end(\"Authenticated\");\n resolve(query[\"code\"]);\n });\n server.on(\"error\", e => {\n if (e.code === \"EADDRINUSE\") {\n consola.error(`Port ${port} is already in use, unable to perform authentication flow.`);\n server.close();\n exit(1);\n }\n });\n server.listen(port);\n const clientId = args.clientId;\n const state = generateRandomString();\n const codeVerifier = generateRandomString();\n const codeChallenge = await generateCodeChallenge(codeVerifier);\n const authorizeUrl = generateAuthorizeUrl(args.foundryUrl, clientId, state, redirectUrl, codeChallenge);\n try {\n await open(authorizeUrl);\n } catch {\n consola.warn(`Unable to open browser, please open this url in your browser to to authenticate: ${authorizeUrl}`);\n }\n const browserPrompt = setTimeout(() => {\n consola.warn(`Still waiting for the authentication to complete. Please open a browser to ${authorizeUrl}`);\n }, BROWSER_PROMPT_TIME_MS);\n const code = await authCode;\n server.close();\n clearTimeout(browserPrompt);\n const token = await getTokenWithCodeVerifier(clientId, redirectUrl, code, args.foundryUrl, codeVerifier);\n if (isTokenErrorResponse(token)) {\n consola.error(\"Unable to authenticate\", token.error, token.error_description);\n exit(1);\n }\n consola.success(`Successfully authenticated!`);\n return token;\n}\nfunction generateRandomString(length = 128) {\n const characters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~\";\n let output = [];\n let array = new Uint8Array(1);\n const maxIndex = 256 - 256 % characters.length;\n while (output.length < length) {\n getRandomValues(array);\n if (array[0] < maxIndex) {\n output.push(characters[array[0] % characters.length]);\n }\n }\n return output.join(\"\");\n}\nasync function generateCodeChallenge(codeVerifier) {\n const data = new TextEncoder().encode(codeVerifier);\n const digest = await subtle.digest(\"SHA-256\", data);\n const codeChallengeMethod = \"S256\";\n const codeChallenge = btoa(String.fromCharCode(...new Uint8Array(digest))).replace(/\\//g, \"_\").replace(/\\+/g, \"-\").replace(/=/g, \"\");\n return {\n codeChallenge,\n codeChallengeMethod\n };\n}\nfunction generateAuthorizeUrl(baseUrl, clientId, state, redirectUrl, codeChallenge) {\n const queryParams = new URLSearchParams();\n queryParams.append(\"client_id\", clientId);\n queryParams.append(\"response_type\", \"code\");\n queryParams.append(\"state\", state);\n queryParams.append(\"redirect_uri\", redirectUrl);\n queryParams.append(\"code_challenge\", codeChallenge.codeChallenge);\n queryParams.append(\"code_challenge_method\", codeChallenge.codeChallengeMethod);\n queryParams.append(\"scope\", [\"offline_access\", \"api:read-data\"].join(\" \"));\n return join(baseUrl, \"multipass\", \"api\", \"oauth2\", \"authorize\") + `?` + queryParams.toString();\n}\nasync function getTokenWithCodeVerifier(clientId, redirectUrl, code, baseUrl, codeVerifier) {\n const body = new URLSearchParams();\n body.append(\"client_id\", clientId);\n body.append(\"grant_type\", \"authorization_code\");\n body.append(\"code\", code);\n body.append(\"redirect_uri\", redirectUrl);\n body.append(\"code_verifier\", codeVerifier);\n const tokenUrl = join(baseUrl, \"multipass\", \"api\", \"oauth2\", \"token\") + `?state=${codeVerifier}`;\n try {\n const response = await fetch(tokenUrl, {\n body: body.toString(),\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\"\n },\n method: \"POST\"\n });\n const responseText = await response.json();\n return responseText;\n } catch (e) {\n throw new Error(`Failed to get token: ${e?.cause?.toString() ?? e?.toString() ?? \"Unknown error\"}`);\n }\n}\nexport { invokeLoginFlow as default };"]}
@@ -0,0 +1,65 @@
1
+ import { consola } from 'consola';
2
+ import { colorize } from 'consola/utils';
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import { valid } from 'semver';
6
+
7
+ // ../cli.common/build/js/index.mjs
8
+ var ExitProcessError = class extends Error {
9
+ constructor(errorCode, msg, tip, originalError) {
10
+ super(msg);
11
+ this.errorCode = errorCode;
12
+ this.msg = msg;
13
+ this.tip = tip;
14
+ this.originalError = originalError;
15
+ }
16
+ };
17
+ var firstTime = true;
18
+ async function logLevelMiddleware(args) {
19
+ if (firstTime) {
20
+ firstTime = false;
21
+ consola.level = 3 + args.verbose;
22
+ if (consola.level > 3) {
23
+ consola.debug(`Verbose logging enabled (${consola.level === 4 ? "debug" : "trace"})
24
+ `);
25
+ }
26
+ }
27
+ }
28
+ var YargsCheckError = class extends Error {
29
+ constructor(msg) {
30
+ super(msg);
31
+ }
32
+ };
33
+ function getYargsBase(args) {
34
+ return yargs(hideBin(args)).wrap(Math.min(150, yargs().terminalWidth())).env("OSDK").version(false).option("verbose", {
35
+ alias: "v",
36
+ type: "boolean",
37
+ description: "Enable verbose logging",
38
+ count: true
39
+ }).demandCommand().middleware(logLevelMiddleware, true).strict().fail(async (msg, err, argv) => {
40
+ if (err instanceof ExitProcessError) {
41
+ consola.error(err.message);
42
+ if (err.tip != null) {
43
+ consola.log(colorize("bold", `\u{1F4A1} Tip: ${err.tip}`));
44
+ consola.log("");
45
+ }
46
+ consola.debug(err.stack);
47
+ } else {
48
+ if (err && err instanceof YargsCheckError === false) {
49
+ throw err;
50
+ } else {
51
+ argv.showHelp();
52
+ consola.log("");
53
+ consola.error(msg);
54
+ }
55
+ }
56
+ process.exit(1);
57
+ });
58
+ }
59
+ function isValidSemver(semverString) {
60
+ return valid(semverString) != null;
61
+ }
62
+
63
+ export { ExitProcessError, YargsCheckError, getYargsBase, isValidSemver };
64
+ //# sourceMappingURL=out.js.map
65
+ //# sourceMappingURL=chunk-FRT6INSG.browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../cli.common/build/js/index.mjs"],"names":[],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,aAAa;AAGtB,IAAI,mBAAmB,cAAc,MAAM;AAAA,EACzC,YAAY,WAAW,KAAK,KAAK,eAAe;AAC9C,UAAM,GAAG;AACT,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,MAAM;AACX,SAAK,gBAAgB;AAAA,EACvB;AACF;AACA,IAAI,YAAY;AAChB,eAAe,mBAAmB,MAAM;AACtC,MAAI,WAAW;AACb,gBAAY;AACZ,YAAQ,QAAQ,IAAI,KAAK;AACzB,QAAI,QAAQ,QAAQ,GAAG;AACrB,cAAQ,MAAM,4BAA4B,QAAQ,UAAU,IAAI,UAAU,OAAO;AAAA,CACtF;AAAA,IACG;AAAA,EACF;AACF;AAGA,IAAI,kBAAkB,cAAc,MAAM;AAAA,EACxC,YAAY,KAAK;AACf,UAAM,GAAG;AAAA,EACX;AACF;AAGA,SAAS,aAAa,MAAM;AAC1B,SAAO,MAAM,QAAQ,IAAI,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,MAAM,EAAE,QAAQ,KAAK,EAAE,OAAO,WAAW;AAAA,IACpH,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC,EAAE,cAAc,EAAE,WAAW,oBAAoB,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,KAAK,KAAK,SAAS;AAC9F,QAAI,eAAe,kBAAkB;AACnC,cAAQ,MAAM,IAAI,OAAO;AACzB,UAAI,IAAI,OAAO,MAAM;AACnB,gBAAQ,IAAI,SAAS,QAAQ,kBAAkB,IAAI,GAAG,EAAE,CAAC;AACzD,gBAAQ,IAAI,EAAE;AAAA,MAChB;AACA,cAAQ,MAAM,IAAI,KAAK;AAAA,IACzB,OAAO;AACL,UAAI,OAAO,eAAe,oBAAoB,OAAO;AACnD,cAAM;AAAA,MACR,OAAO;AACL,aAAK,SAAS;AACd,gBAAQ,IAAI,EAAE;AACd,gBAAQ,MAAM,GAAG;AAAA,MACnB;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;AACA,SAAS,cAAc,cAAc;AACnC,SAAO,MAAM,YAAY,KAAK;AAChC","sourcesContent":["import { consola } from 'consola';\nimport { colorize } from 'consola/utils';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { valid } from 'semver';\n\n// src/ExitProcessError.ts\nvar ExitProcessError = class extends Error {\n constructor(errorCode, msg, tip, originalError) {\n super(msg);\n this.errorCode = errorCode;\n this.msg = msg;\n this.tip = tip;\n this.originalError = originalError;\n }\n};\nvar firstTime = true;\nasync function logLevelMiddleware(args) {\n if (firstTime) {\n firstTime = false;\n consola.level = 3 + args.verbose;\n if (consola.level > 3) {\n consola.debug(`Verbose logging enabled (${consola.level === 4 ? \"debug\" : \"trace\"})\n`);\n }\n }\n}\n\n// src/YargsCheckError.ts\nvar YargsCheckError = class extends Error {\n constructor(msg) {\n super(msg);\n }\n};\n\n// src/getYargsBase.ts\nfunction getYargsBase(args) {\n return yargs(hideBin(args)).wrap(Math.min(150, yargs().terminalWidth())).env(\"OSDK\").version(false).option(\"verbose\", {\n alias: \"v\",\n type: \"boolean\",\n description: \"Enable verbose logging\",\n count: true\n }).demandCommand().middleware(logLevelMiddleware, true).strict().fail(async (msg, err, argv) => {\n if (err instanceof ExitProcessError) {\n consola.error(err.message);\n if (err.tip != null) {\n consola.log(colorize(\"bold\", `\\u{1F4A1} Tip: ${err.tip}`));\n consola.log(\"\");\n }\n consola.debug(err.stack);\n } else {\n if (err && err instanceof YargsCheckError === false) {\n throw err;\n } else {\n argv.showHelp();\n consola.log(\"\");\n consola.error(msg);\n }\n }\n process.exit(1);\n });\n}\nfunction isValidSemver(semverString) {\n return valid(semverString) != null;\n}\nexport { ExitProcessError, YargsCheckError, getYargsBase, isValidSemver };"]}
@@ -8,4 +8,4 @@ var __export = (target, all) => {
8
8
 
9
9
  exports.__export = __export;
10
10
  //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=chunk-7G2FSZUY.cjs.map
11
+ //# sourceMappingURL=chunk-HQDDGVB7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,5 +1,5 @@
1
1
  import { ExitProcessError } from './chunk-CWMSASIM.mjs';
2
- import { __export } from './chunk-ZSTKOCBT.mjs';
2
+ import { __export } from './chunk-E2SEJZTC.mjs';
3
3
  import { PalantirApiError, createFetchHeaderMutator, createFetchOrThrow } from '@osdk/shared.net';
4
4
  import { consola } from 'consola';
5
5
  import { promises } from 'fs';
@@ -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
- deleteWebsiteDeployment: () => deleteWebsiteDeployment,
20
- deleteWebsiteVersion: () => deleteWebsiteVersion,
21
- getWebsiteDeployment: () => getWebsiteDeployment,
22
- listWebsiteVersions: () => listWebsiteVersions,
23
- updateWebsiteDeployment: () => updateWebsiteDeployment,
24
- uploadWebsiteVersion: () => uploadWebsiteVersion
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.19.0-next-20240426195134"}`;
28
+ var USER_AGENT = `osdk-cli/${"0.19.0"}`;
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 === "CannotDeleteDeployedWebsiteVersion") {
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 === "InvalidWebsiteVersion") {
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 === "WebsiteVersionAlreadyExists") {
60
+ } else if (e.errorName === "VersionAlreadyExists") {
61
61
  message = "The site version already exists";
62
- } else if (e.errorName === "WebsiteVersionNotFound") {
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/deleteWebsiteDeployment.mts
79
- async function deleteWebsiteDeployment(ctx, thirdPartyAppRid) {
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}/websiteDeployment?preview=true`;
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/deleteWebsiteVersion.mts
88
- async function deleteWebsiteVersion(ctx, thirdPartyAppRid, version) {
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}/websiteVersions/${version}?preview=true`;
91
- await fetch2(url, {
92
- method: "DELETE"
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 getWebsiteDeployment(ctx, thirdPartyAppRid) {
100
+ async function getWebsite(ctx, thirdPartyAppRid) {
96
101
  const fetch2 = createFetch(ctx.tokenProvider);
97
- const url = `${ctx.foundryUrl}/api/v2/thirdPartyApplications/${thirdPartyAppRid}/websiteDeployment?preview=true`;
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 === "WebsiteDeploymentNotFound") {
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/listWebsiteVersions.mts
110
- async function listWebsiteVersions(ctx, thirdPartyAppRid) {
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}/websiteVersions?preview=true`;
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/updateWebsiteDeployment.mts
118
- async function updateWebsiteDeployment(ctx, thirdPartyAppRid, request) {
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}/websiteDeployment?preview=true`;
121
- const result = await fetch2(url, {
122
- method: "PUT",
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/uploadWebsiteVersion.mts
132
- async function uploadWebsiteVersion(ctx, thirdPartyAppRid, version, zipFile) {
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}/websiteVersions/upload?version=${version}&preview=true`;
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-DKCYYJ36.mjs.map
199
+ //# sourceMappingURL=chunk-MQIOUPGJ.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;AACA,MAAI;AACJ,MAAI,EAAE,eAAe,KAAK;AACxB,UAAM;AAAA,EACR,WAAW,EAAE,eAAe,KAAK;AAC/B,UAAM;AAAA,EACR;AACA,MAAI,UAAU,EAAE;AAChB,MAAI,EAAE,cAAc,+BAA+B;AACjD,cAAU;AACV,UAAM;AAAA,EACR,WAAW,EAAE,cAAc,kBAAkB;AAC3C,cAA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MAAM,iCAAiC;AAC/C,aAAS,KAAK;AACd,WAAO;AAAA,EACT;AACA,MAAI,WAAW;AACb,UAAM,cAAc,MAAM,cAAc,SAAS;AACjD,IAAAA,SAAQ,MAAM,gCAAgC,YAAY,QAAQ,SAAS;AAC3E,aAAS,YAAY,KAAK;AAC1B,WAAO,YAAY;AAAA,EACrB;AACA,aAAW,UAAU,gBAAgB;AACnC,UAAM,mBAAmB,QAAQ,IAAI,MAAM;AAC3C,QAAI,kBAAkB;AACpB,MAAAA,SAAQ,MAAM,oBAAoB,MAAM,uBAAuB;AAC/D,eAAS,gBAAgB;AACzB,UAAI,WAAW,0BAA0B;AACvC,QAAAA,SAAQ,KAAK,oGAAoG;AAAA,MACnH;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,IAAI,iBAAiB,GAAG,mBAAmB,+DAA+D,eAAe,CAAC,CAAC,uBAAuB;AAC1J;AAOA,eAAsB,cAAc,UAAU;AAC5C,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,mBAAe,KAAK,QAAQ,QAAQ;AACpC,YAAQ,MAAM,WAAW,SAAS,cAAc,MAAM;AACtD,YAAQ,MAAM,KAAK;AAAA,EACrB,SAAS,OAAO;AACd,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}"]}