@osdk/cli 0.15.0 → 0.16.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 (109) hide show
  1. package/build/js/{chunk-F6Y3FTY6.cjs → chunk-2KJDB4YP.cjs} +13 -13
  2. package/build/js/{chunk-EALLTV7S.mjs.map → chunk-2KJDB4YP.cjs.map} +1 -1
  3. package/build/js/chunk-AX5HH3ZN.cjs +73 -0
  4. package/build/js/chunk-AX5HH3ZN.cjs.map +1 -0
  5. package/build/js/{chunk-TZGNA5WR.cjs → chunk-EVW4VRJL.cjs} +3 -7
  6. package/build/js/chunk-EVW4VRJL.cjs.map +1 -0
  7. package/build/js/{chunk-EALLTV7S.mjs → chunk-JTZ7GUB4.mjs} +3 -3
  8. package/build/js/{chunk-F6Y3FTY6.cjs.map → chunk-JTZ7GUB4.mjs.map} +1 -1
  9. package/build/js/chunk-MTJA6DOB.mjs +64 -0
  10. package/build/js/chunk-MTJA6DOB.mjs.map +1 -0
  11. package/build/js/{chunk-HD6SVFKA.mjs → chunk-SFL6QONJ.mjs} +3 -7
  12. package/build/js/chunk-SFL6QONJ.mjs.map +1 -0
  13. package/build/js/{handleGenerate-KCAGHMHC.cjs → handleGenerate-XC5RBDDW-DL73JJG6.cjs} +12 -16
  14. package/build/js/handleGenerate-XC5RBDDW-DL73JJG6.cjs.map +1 -0
  15. package/build/js/{handleGenerate-FSKXULOJ.mjs → handleGenerate-XC5RBDDW-T333WMC4.mjs} +9 -10
  16. package/build/js/handleGenerate-XC5RBDDW-T333WMC4.mjs.map +1 -0
  17. package/build/js/index.cjs +138 -186
  18. package/build/js/index.cjs.map +1 -1
  19. package/build/js/index.mjs +129 -173
  20. package/build/js/index.mjs.map +1 -1
  21. package/build/js/loginFlow-QTUKYZEL.cjs +10 -0
  22. package/build/js/loginFlow-ZFVT2AFZ.mjs +4 -0
  23. package/build/js/{siteDeployCommand-NF4NIH2Y.cjs → siteDeployCommand-FTCDKKU4.cjs} +17 -18
  24. package/build/js/siteDeployCommand-FTCDKKU4.cjs.map +1 -0
  25. package/build/js/{siteDeployCommand-QMX5EY2K.mjs → siteDeployCommand-WHR7PIJE.mjs} +3 -4
  26. package/build/js/siteDeployCommand-WHR7PIJE.mjs.map +1 -0
  27. package/build/js/{versionDeleteCommand-7XQQMEP6.cjs → versionDeleteCommand-KQCJ7CHQ.cjs} +6 -6
  28. package/build/js/{versionDeleteCommand-S3PG23IT.mjs → versionDeleteCommand-YFVUCYVQ.mjs} +3 -3
  29. package/build/js/{versionGetCommand-PBCSZZ2W.cjs → versionGetCommand-45C2JZC4.cjs} +8 -8
  30. package/build/js/{versionGetCommand-IKDSYKJM.mjs → versionGetCommand-AKPCEBQZ.mjs} +3 -3
  31. package/build/js/{versionListCommand-KSQJH2CQ.cjs → versionListCommand-4TM6YYNJ.cjs} +8 -8
  32. package/build/js/{versionListCommand-YP6X66SJ.mjs → versionListCommand-6OVL7FF2.mjs} +3 -3
  33. package/build/js/{versionSetCommand-KXNXVRXK.mjs → versionSetCommand-BD3O7OAX.mjs} +3 -3
  34. package/build/js/{versionSetCommand-2L3BCYZ7.cjs → versionSetCommand-FIWT6CFW.cjs} +8 -8
  35. package/build/js/{versionUnsetCommand-BIBSMJRY.cjs → versionUnsetCommand-BZ2SAFEM.cjs} +8 -8
  36. package/build/js/{versionUnsetCommand-XH4PGAIP.mjs → versionUnsetCommand-W7ACW5O3.mjs} +3 -3
  37. package/build/types/cli.d.ts.map +1 -1
  38. package/build/types/commands/auth/index.d.ts +3 -4
  39. package/build/types/commands/auth/index.d.ts.map +1 -1
  40. package/build/types/commands/auth/login/index.d.ts +1 -2
  41. package/build/types/commands/auth/login/index.d.ts.map +1 -1
  42. package/build/types/commands/site/CommonSiteArgs.d.ts +1 -1
  43. package/build/types/commands/site/CommonSiteArgs.d.ts.map +1 -1
  44. package/build/types/commands/site/deploy/index.d.ts.map +1 -1
  45. package/build/types/commands/site/index.d.ts +1 -1
  46. package/build/types/commands/site/index.d.ts.map +1 -1
  47. package/build/types/util/autoVersion.d.ts.map +1 -1
  48. package/changelog/0.16.0/pr-143.v2.yml +5 -0
  49. package/package.json +9 -8
  50. package/build/js/chunk-CCA2T5YW.cjs +0 -12
  51. package/build/js/chunk-CCA2T5YW.cjs.map +0 -1
  52. package/build/js/chunk-CLAEREOL.mjs +0 -13
  53. package/build/js/chunk-CLAEREOL.mjs.map +0 -1
  54. package/build/js/chunk-GX2IOTA6.mjs +0 -10
  55. package/build/js/chunk-GX2IOTA6.mjs.map +0 -1
  56. package/build/js/chunk-HD6SVFKA.mjs.map +0 -1
  57. package/build/js/chunk-HZ3XILMW.cjs +0 -15
  58. package/build/js/chunk-HZ3XILMW.cjs.map +0 -1
  59. package/build/js/chunk-MU5KWUEI.mjs +0 -10
  60. package/build/js/chunk-MU5KWUEI.mjs.map +0 -1
  61. package/build/js/chunk-TZGNA5WR.cjs.map +0 -1
  62. package/build/js/chunk-UE2TMWJL.cjs +0 -12
  63. package/build/js/chunk-UE2TMWJL.cjs.map +0 -1
  64. package/build/js/handleGenerate-FSKXULOJ.mjs.map +0 -1
  65. package/build/js/handleGenerate-KCAGHMHC.cjs.map +0 -1
  66. package/build/js/loginFlow-5ZAMXQKE.cjs +0 -10
  67. package/build/js/loginFlow-BWWZBM36.mjs +0 -4
  68. package/build/js/siteDeployCommand-NF4NIH2Y.cjs.map +0 -1
  69. package/build/js/siteDeployCommand-QMX5EY2K.mjs.map +0 -1
  70. package/build/types/CliCommonArgs.d.ts +0 -4
  71. package/build/types/CliCommonArgs.d.ts.map +0 -1
  72. package/build/types/ExitProcessError.d.ts +0 -7
  73. package/build/types/ExitProcessError.d.ts.map +0 -1
  74. package/build/types/YargsCheckError.d.ts +0 -4
  75. package/build/types/YargsCheckError.d.ts.map +0 -1
  76. package/build/types/commands/auth/CommonAuthArgs.d.ts +0 -5
  77. package/build/types/commands/auth/CommonAuthArgs.d.ts.map +0 -1
  78. package/build/types/commands/auth/login/LoginArgs.d.ts +0 -5
  79. package/build/types/commands/auth/login/LoginArgs.d.ts.map +0 -1
  80. package/build/types/commands/auth/login/loginFlow.d.ts +0 -3
  81. package/build/types/commands/auth/login/loginFlow.d.ts.map +0 -1
  82. package/build/types/commands/auth/login/token.d.ts +0 -13
  83. package/build/types/commands/auth/login/token.d.ts.map +0 -1
  84. package/build/types/commands/typescript/generate/TypescriptGenerateArgs.d.ts +0 -15
  85. package/build/types/commands/typescript/generate/TypescriptGenerateArgs.d.ts.map +0 -1
  86. package/build/types/commands/typescript/generate/generate.d.ts +0 -5
  87. package/build/types/commands/typescript/generate/generate.d.ts.map +0 -1
  88. package/build/types/commands/typescript/generate/handleGenerate.d.mts +0 -45
  89. package/build/types/commands/typescript/generate/handleGenerate.d.mts.map +0 -1
  90. package/build/types/commands/typescript/generate/handleGenerate.test.d.mts +0 -2
  91. package/build/types/commands/typescript/generate/handleGenerate.test.d.mts.map +0 -1
  92. package/build/types/commands/typescript/index.d.ts +0 -5
  93. package/build/types/commands/typescript/index.d.ts.map +0 -1
  94. package/build/types/util/isValidSemver.d.ts +0 -2
  95. package/build/types/util/isValidSemver.d.ts.map +0 -1
  96. package/build/types/yargs/logLevelMiddleware.d.ts +0 -3
  97. package/build/types/yargs/logLevelMiddleware.d.ts.map +0 -1
  98. /package/build/js/{loginFlow-5ZAMXQKE.cjs.map → loginFlow-QTUKYZEL.cjs.map} +0 -0
  99. /package/build/js/{loginFlow-BWWZBM36.mjs.map → loginFlow-ZFVT2AFZ.mjs.map} +0 -0
  100. /package/build/js/{versionDeleteCommand-7XQQMEP6.cjs.map → versionDeleteCommand-KQCJ7CHQ.cjs.map} +0 -0
  101. /package/build/js/{versionDeleteCommand-S3PG23IT.mjs.map → versionDeleteCommand-YFVUCYVQ.mjs.map} +0 -0
  102. /package/build/js/{versionGetCommand-IKDSYKJM.mjs.map → versionGetCommand-45C2JZC4.cjs.map} +0 -0
  103. /package/build/js/{versionGetCommand-PBCSZZ2W.cjs.map → versionGetCommand-AKPCEBQZ.mjs.map} +0 -0
  104. /package/build/js/{versionListCommand-KSQJH2CQ.cjs.map → versionListCommand-4TM6YYNJ.cjs.map} +0 -0
  105. /package/build/js/{versionListCommand-YP6X66SJ.mjs.map → versionListCommand-6OVL7FF2.mjs.map} +0 -0
  106. /package/build/js/{versionSetCommand-2L3BCYZ7.cjs.map → versionSetCommand-BD3O7OAX.mjs.map} +0 -0
  107. /package/build/js/{versionSetCommand-KXNXVRXK.mjs.map → versionSetCommand-FIWT6CFW.cjs.map} +0 -0
  108. /package/build/js/{versionUnsetCommand-BIBSMJRY.cjs.map → versionUnsetCommand-BZ2SAFEM.cjs.map} +0 -0
  109. /package/build/js/{versionUnsetCommand-XH4PGAIP.mjs.map → versionUnsetCommand-W7ACW5O3.mjs.map} +0 -0
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkDQYIDDJN_cjs = require('./chunk-DQYIDDJN.cjs');
4
- var chunkF6Y3FTY6_cjs = require('./chunk-F6Y3FTY6.cjs');
5
- require('./chunk-HZ3XILMW.cjs');
4
+ var chunk2KJDB4YP_cjs = require('./chunk-2KJDB4YP.cjs');
5
+ require('./chunk-AX5HH3ZN.cjs');
6
6
  require('./chunk-HQDDGVB7.cjs');
7
7
  var consola = require('consola');
8
8
  var utils = require('consola/utils');
@@ -21,16 +21,16 @@ ${utils.colorize("bold", "Your site will no longer be accessible until a new liv
21
21
  });
22
22
  chunkDQYIDDJN_cjs.handlePromptCancel(confirmed);
23
23
  }
24
- const loadedToken = await chunkF6Y3FTY6_cjs.loadToken(token, tokenFile);
24
+ const loadedToken = await chunk2KJDB4YP_cjs.loadToken(token, tokenFile);
25
25
  const tokenProvider = () => loadedToken;
26
- const clientCtx = chunkF6Y3FTY6_cjs.createInternalClientContext(foundryUrl, tokenProvider);
26
+ const clientCtx = chunk2KJDB4YP_cjs.createInternalClientContext(foundryUrl, tokenProvider);
27
27
  consola.consola.start("Clearing live site version");
28
- const repositoryRid = await chunkF6Y3FTY6_cjs.third_party_application_service_exports.fetchWebsiteRepositoryRid(clientCtx, application);
29
- const ctx = chunkF6Y3FTY6_cjs.createConjureContext(foundryUrl, "/artifacts/api", tokenProvider);
30
- await chunkF6Y3FTY6_cjs.ArtifactsSitesAdminV2Service_exports.clearDeployedVersion(ctx, repositoryRid);
28
+ const repositoryRid = await chunk2KJDB4YP_cjs.third_party_application_service_exports.fetchWebsiteRepositoryRid(clientCtx, application);
29
+ const ctx = chunk2KJDB4YP_cjs.createConjureContext(foundryUrl, "/artifacts/api", tokenProvider);
30
+ await chunk2KJDB4YP_cjs.ArtifactsSitesAdminV2Service_exports.clearDeployedVersion(ctx, repositoryRid);
31
31
  consola.consola.success("Cleared live site version");
32
32
  }
33
33
 
34
34
  module.exports = versionUnsetCommand;
35
35
  //# sourceMappingURL=out.js.map
36
- //# sourceMappingURL=versionUnsetCommand-BIBSMJRY.cjs.map
36
+ //# sourceMappingURL=versionUnsetCommand-BZ2SAFEM.cjs.map
@@ -1,6 +1,6 @@
1
1
  import { handlePromptCancel } from './chunk-IV3QY3PZ.mjs';
2
- import { loadToken, createInternalClientContext, third_party_application_service_exports, createConjureContext, ArtifactsSitesAdminV2Service_exports } from './chunk-EALLTV7S.mjs';
3
- import './chunk-CLAEREOL.mjs';
2
+ import { loadToken, createInternalClientContext, third_party_application_service_exports, createConjureContext, ArtifactsSitesAdminV2Service_exports } from './chunk-JTZ7GUB4.mjs';
3
+ import './chunk-MTJA6DOB.mjs';
4
4
  import './chunk-E2SEJZTC.mjs';
5
5
  import { consola } from 'consola';
6
6
  import { colorize } from 'consola/utils';
@@ -31,4 +31,4 @@ ${colorize("bold", "Your site will no longer be accessible until a new live site
31
31
 
32
32
  export { versionUnsetCommand as default };
33
33
  //# sourceMappingURL=out.js.map
34
- //# sourceMappingURL=versionUnsetCommand-XH4PGAIP.mjs.map
34
+ //# sourceMappingURL=versionUnsetCommand-W7ACW5O3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AA8BA,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB;;;;;eA+DtD"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAyBA,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB;;;;;eA6BtD"}
@@ -1,6 +1,5 @@
1
+ import type { CliCommonArgs, CommonAuthArgs } from "@osdk/cli.common";
1
2
  import type * as yargs from "yargs";
2
- import type { CliCommonArgs } from "../../CliCommonArgs.js";
3
- import type { CommonAuthArgs } from "./CommonAuthArgs.js";
4
- declare const site: yargs.CommandModule<CliCommonArgs, CommonAuthArgs>;
5
- export default site;
3
+ declare const auth: yargs.CommandModule<CliCommonArgs, CommonAuthArgs>;
4
+ export default auth;
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,cAAc,CAkB5D,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAGpC,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,cAAc,CAkB5D,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,6 +1,5 @@
1
+ import type { CommonAuthArgs, LoginArgs } from "@osdk/cli.common";
1
2
  import type { CommandModule } from "yargs";
2
- import type { CommonAuthArgs } from "../CommonAuthArgs.js";
3
- import type { LoginArgs } from "./LoginArgs.js";
4
3
  export declare const command: CommandModule<CommonAuthArgs, LoginArgs>;
5
4
  export default command;
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/auth/login/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,OAAO,EAAE,aAAa,CACjC,cAAc,EACd,SAAS,CAiBV,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/auth/login/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,OAAO,EAAE,aAAa,CACjC,cAAc,EACd,SAAS,CAiBV,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CliCommonArgs } from "../../CliCommonArgs.js";
1
+ import type { CliCommonArgs } from "@osdk/cli.common";
2
2
  import type { ThirdPartyAppRid } from "../../net/ThirdPartyAppRid.js";
3
3
  export interface CommonSiteArgs extends CliCommonArgs {
4
4
  application: ThirdPartyAppRid;
@@ -1 +1 @@
1
- {"version":3,"file":"CommonSiteArgs.d.ts","sourceRoot":"","sources":["../../../../src/commands/site/CommonSiteArgs.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,WAAW,EAAE,gBAAgB,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
1
+ {"version":3,"file":"CommonSiteArgs.d.ts","sourceRoot":"","sources":["../../../../src/commands/site/CommonSiteArgs.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,WAAW,EAAE,gBAAgB,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/site/deploy/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAS3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,QAAA,MAAM,OAAO,EAAE,aAAa,CAC1B,cAAc,EACd,cAAc,CA8Gf,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/site/deploy/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAO3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,QAAA,MAAM,OAAO,EAAE,aAAa,CAC1B,cAAc,EACd,cAAc,CA8Gf,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,5 +1,5 @@
1
+ import type { CliCommonArgs } from "@osdk/cli.common";
1
2
  import type { CommandModule } from "yargs";
2
- import type { CliCommonArgs } from "../../CliCommonArgs.js";
3
3
  import type { CommonSiteArgs } from "./CommonSiteArgs.js";
4
4
  declare const command: CommandModule<CliCommonArgs, CommonSiteArgs>;
5
5
  export default command;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/site/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,QAAA,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,EAAE,cAAc,CAsDzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/site/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,QAAA,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,EAAE,cAAc,CAsDzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"autoVersion.d.ts","sourceRoot":"","sources":["../../../src/util/autoVersion.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,SAAS,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAezE"}
1
+ {"version":3,"file":"autoVersion.d.ts","sourceRoot":"","sources":["../../../src/util/autoVersion.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,SAAS,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAezE"}
@@ -0,0 +1,5 @@
1
+ type: improvement
2
+ improvement:
3
+ description: Refactors to improve devx
4
+ links:
5
+ - https://github.com/palantir/osdk-ts/pull/143
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/cli",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -31,10 +31,10 @@
31
31
  "semver": "^7.6.0",
32
32
  "tslib": "^2.6.2",
33
33
  "yargs": "^17.7.2",
34
- "@osdk/api": "1.5.0",
35
- "@osdk/gateway": "2.1.0",
36
- "@osdk/generator": "1.8.0",
37
- "@osdk/shared.net": "1.8.0"
34
+ "@osdk/api": "1.6.0",
35
+ "@osdk/gateway": "2.2.0",
36
+ "@osdk/generator": "1.9.0",
37
+ "@osdk/shared.net": "1.9.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/archiver": "^6.0.0",
@@ -43,7 +43,9 @@
43
43
  "@types/semver": "^7.5.7",
44
44
  "@types/yargs": "^17.0.29",
45
45
  "ts-expect": "^1.3.0",
46
- "typescript": "^5.4.2"
46
+ "typescript": "^5.4.2",
47
+ "@osdk/cli.cmd.typescript": "0.0.0",
48
+ "@osdk/cli.common": "0.0.0"
47
49
  },
48
50
  "publishConfig": {
49
51
  "access": "public"
@@ -70,13 +72,12 @@
70
72
  "type": "module",
71
73
  "scripts": {
72
74
  "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
73
- "dev:transpile": "tsup --watch",
74
75
  "fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
75
76
  "lint": "eslint . && dprint check --config $(find-up dprint.json)",
76
77
  "test": "vitest run",
77
78
  "test:watch": "vitest",
78
79
  "transpile": "tsup",
79
80
  "transpileWatch": "tsup --watch",
80
- "typecheck": "tsc-absolute --build"
81
+ "typecheck": "tsc-absolute"
81
82
  }
82
83
  }
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- // src/YargsCheckError.ts
4
- var YargsCheckError = class extends Error {
5
- constructor(msg) {
6
- super(msg);
7
- }
8
- };
9
-
10
- exports.YargsCheckError = YargsCheckError;
11
- //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-CCA2T5YW.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/YargsCheckError.ts"],"names":[],"mappings":";AAgBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YAAY,KAAK;AACf,UAAM,GAAG;AAAA,EACX;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\nexport class YargsCheckError extends Error {\n constructor(msg) {\n super(msg);\n }\n}"]}
@@ -1,13 +0,0 @@
1
- // src/ExitProcessError.ts
2
- var ExitProcessError = class extends Error {
3
- constructor(errorCode, msg, tip) {
4
- super(msg);
5
- this.errorCode = errorCode;
6
- this.msg = msg;
7
- this.tip = tip;
8
- }
9
- };
10
-
11
- export { ExitProcessError };
12
- //# sourceMappingURL=out.js.map
13
- //# sourceMappingURL=chunk-CLAEREOL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ExitProcessError.ts"],"names":[],"mappings":";AAgBO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1C,YAAY,WAAW,KAAK,KAAK;AAC/B,UAAM,GAAG;AACT,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,MAAM;AAAA,EACb;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\nexport class ExitProcessError extends Error {\n constructor(errorCode, msg, tip) {\n super(msg);\n this.errorCode = errorCode;\n this.msg = msg;\n this.tip = tip;\n }\n}"]}
@@ -1,10 +0,0 @@
1
- import { valid } from 'semver';
2
-
3
- // src/util/isValidSemver.ts
4
- function isValidSemver(semverString) {
5
- return valid(semverString) != null;
6
- }
7
-
8
- export { isValidSemver };
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-GX2IOTA6.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/isValidSemver.ts"],"names":[],"mappings":";AAgBA,SAAS,aAAa;AACf,SAAS,cAAc,cAAc;AAC1C,SAAO,MAAM,YAAY,KAAK;AAChC","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 { valid } from \"semver\";\nexport function isValidSemver(semverString) {\n return valid(semverString) != null;\n}"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/auth/login/loginFlow.ts","../../src/commands/auth/login/token.ts"],"names":[],"mappings":";AAiBA,OAAO,aAAa;AACpB,SAAS,iBAAiB,cAAc;AACxC,SAAS,oBAAoB;AAC7B,OAAO,UAAU;AACjB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,aAAa;;;ACPf,SAAS,qBAAqB,UAAU;AAC7C,SAAO,SAAS,SAAS;AAC3B;;;ADOA,IAAM,yBAAyB,KAAK;AACpC,eAAO,gBAAuC,MAAM;AAClD,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,4DAA4D;AACtF,aAAO,MAAM;AACb,WAAK,CAAC;AAAA,IACR;AAAA,EACF,CAAC;AACD,SAAO,OAAO,IAAI;AAClB,QAAM,WAAW,KAAK;AACtB,QAAM,QAAQ,qBAAqB;AACnC,QAAM,eAAe,qBAAqB;AAC1C,QAAM,gBAAgB,MAAM,sBAAsB,YAAY;AAC9D,QAAM,eAAe,qBAAqB,KAAK,YAAY,UAAU,OAAO,aAAa,aAAa;AACtG,MAAI;AACF,UAAM,KAAK,YAAY;AAAA,EACzB,QAAQ;AACN,YAAQ,KAAK,oFAAoF,YAAY,EAAE;AAAA,EACjH;AAGA,QAAM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,cAAY,OAAO,SAAS,KAAK;AACjC,cAAY,OAAO,gBAAgB,WAAW;AAC9C,cAAY,OAAO,kBAAkB,cAAc,aAAa;AAChE,cAAY,OAAO,yBAAyB,cAAc,mBAAmB;AAC7E,cAAY,OAAO,SAAS,CAAC,kBAAkB,eAAe,EAAE,KAAK,GAAG,CAAC;AACzE,SAAO,KAAK,SAAS,aAAa,OAAO,UAAU,WAAW,IAAI,MAAM,YAAY,SAAS;AAC/F;AACA,eAAe,yBAAyB,UAAU,aAAa,MAAM,SAAS,cAAc;AAC1F,QAAM,OAAO,IAAI,gBAAgB;AACjC,OAAK,OAAO,aAAa,QAAQ;AACjC,OAAK,OAAO,cAAc,oBAAoB;AAC9C,OAAK,OAAO,QAAQ,IAAI;AACxB,OAAK,OAAO,gBAAgB,WAAW;AACvC,OAAK,OAAO,iBAAiB,YAAY;AACzC,QAAM,WAAW,KAAK,SAAS,aAAa,OAAO,UAAU,OAAO,IAAI,UAAU,YAAY;AAC9F,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,UAAU;AAAA,MACrC,MAAM,KAAK,SAAS;AAAA,MACpB,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,QAAQ;AAAA,IACV,CAAC;AACD,UAAM,eAAe,MAAM,SAAS,KAAK;AACzC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,wBAAwB,GAAG,OAAO,SAAS,KAAK,GAAG,SAAS,KAAK,eAAe,EAAE;AAAA,EACpG;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\n// eslint-disable-next-line import/no-named-as-default\nimport consola from \"consola\";\nimport { getRandomValues, subtle } from \"crypto\";\nimport { createServer } from \"http\";\nimport open from \"open\";\nimport { join } from \"path/posix\";\nimport { exit } from \"process\";\nimport { parse } from \"url\";\nimport { isTokenErrorResponse } from \"./token.js\";\nconst BROWSER_PROMPT_TIME_MS = 60 * 1000;\nexport default async 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\n // nag the user if we didn't get an auth token for a relatively long time\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}","/*\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 isTokenErrorResponse(response) {\n return response.error != null;\n}"]}
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- // src/ExitProcessError.ts
4
- var ExitProcessError = class extends Error {
5
- constructor(errorCode, msg, tip) {
6
- super(msg);
7
- this.errorCode = errorCode;
8
- this.msg = msg;
9
- this.tip = tip;
10
- }
11
- };
12
-
13
- exports.ExitProcessError = ExitProcessError;
14
- //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-HZ3XILMW.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ExitProcessError.ts"],"names":[],"mappings":";AAgBO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1C,YAAY,WAAW,KAAK,KAAK;AAC/B,UAAM,GAAG;AACT,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,MAAM;AAAA,EACb;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\nexport class ExitProcessError extends Error {\n constructor(errorCode, msg, tip) {\n super(msg);\n this.errorCode = errorCode;\n this.msg = msg;\n this.tip = tip;\n }\n}"]}
@@ -1,10 +0,0 @@
1
- // src/YargsCheckError.ts
2
- var YargsCheckError = class extends Error {
3
- constructor(msg) {
4
- super(msg);
5
- }
6
- };
7
-
8
- export { YargsCheckError };
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-MU5KWUEI.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/YargsCheckError.ts"],"names":[],"mappings":";AAgBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YAAY,KAAK;AACf,UAAM,GAAG;AAAA,EACX;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\nexport class YargsCheckError extends Error {\n constructor(msg) {\n super(msg);\n }\n}"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/auth/login/loginFlow.ts","../../src/commands/auth/login/token.ts"],"names":[],"mappings":";AAiBA,OAAO,aAAa;AACpB,SAAS,iBAAiB,cAAc;AACxC,SAAS,oBAAoB;AAC7B,OAAO,UAAU;AACjB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,aAAa;;;ACPf,SAAS,qBAAqB,UAAU;AAC7C,SAAO,SAAS,SAAS;AAC3B;;;ADOA,IAAM,yBAAyB,KAAK;AACpC,eAAO,gBAAuC,MAAM;AAClD,UAAQ,MAAM,wCAAwC,KAAK,QAAQ,EAAE;AACrE,QAAM,cAAc;AACpB,QAAM,OAAO,MAAM,WAAW,EAAE;AAChC,MAAI;AACJ,QAAM,WAAW,IAAI,QAAQ,UAAQ;AACnC,cAA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,aAAa,OAAO,UAAU,OAAO,IAAI,UAAU,YAAY;AAC9F,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,UAAU;AAAA,MACrC,MAAM,KAAK,SAAS;AAAA,MACpB,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,QAAQ;AAAA,IACV,CAAC;AACD,UAAM,eAAe,MAAM,SAAS,KAAK;AACzC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,wBAAwB,GAAG,OAAO,SAAS,KAAK,GAAG,SAAS,KAAK,eAAe,EAAE;AAAA,EACpG;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\n// eslint-disable-next-line import/no-named-as-default\nimport consola from \"consola\";\nimport { getRandomValues, subtle } from \"crypto\";\nimport { createServer } from \"http\";\nimport open from \"open\";\nimport { join } from \"path/posix\";\nimport { exit } from \"process\";\nimport { parse } from \"url\";\nimport { isTokenErrorResponse } from \"./token.js\";\nconst BROWSER_PROMPT_TIME_MS = 60 * 1000;\nexport default async 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\n // nag the user if we didn't get an auth token for a relatively long time\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}","/*\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 isTokenErrorResponse(response) {\n return response.error != null;\n}"]}
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- var semver = require('semver');
4
-
5
- // src/util/isValidSemver.ts
6
- function isValidSemver(semverString) {
7
- return semver.valid(semverString) != null;
8
- }
9
-
10
- exports.isValidSemver = isValidSemver;
11
- //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-UE2TMWJL.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/isValidSemver.ts"],"names":[],"mappings":";AAgBA,SAAS,aAAa;AACf,SAAS,cAAc,cAAc;AAC1C,SAAO,MAAM,YAAY,KAAK;AAChC","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 { valid } from \"semver\";\nexport function isValidSemver(semverString) {\n return valid(semverString) != null;\n}"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/typescript/generate/handleGenerate.mts"],"names":["fs","path"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,yBAAyB,wBAAwB;AAC1D,SAAS,mCAAmC,4CAA4C;AACxF,SAAS,qBAAqB,4BAA4B;AAC1D,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,YAAY,QAAQ;AAEpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAI9B,IAAM,aAAa,YAAY,QAA2B;AAC1D,eAAO,eAAsC,MAAM;AACjD,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,CAA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,cAAc,IAAI;AACnD,SAAO,MAAS,YAAS,UAAU,UAAU,KAAK,UAAU,MAAM,QAAW,CAAC,IAAI,IAAI;AACxF","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 { getOntologyFullMetadata, listOntologiesV2 } from \"@osdk/gateway/requests\";\nimport { generateClientSdkVersionOneDotOne, generateClientSdkVersionTwoPointZero } from \"@osdk/generator\";\nimport { createClientContext, createOpenApiRequest } from \"@osdk/shared.net\";\nimport { consola } from \"consola\";\nimport { findUp } from \"find-up\";\nimport * as fs from \"node:fs\";\nimport { mkdir, readdir } from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { ExitProcessError } from \"../../../ExitProcessError.js\";\nimport { YargsCheckError } from \"../../../YargsCheckError.js\";\nimport invokeLoginFlow from \"../../auth/login/loginFlow.js\";\nconst USER_AGENT = `osdk-cli/${process.env.PACKAGE_VERSION}`;\nexport default async 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 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 const packageName = args.packageName;\n if (!packageName) throw new Error(\"Package name is require\");\n const version = args.version;\n for (const packageType of [\"module\", \"commonjs\"]) {\n const outDir = path.join(args.outDir, \"dist\", packageType);\n\n // source files per type\n await generateSourceFiles({\n ...args,\n outDir,\n packageType\n }, ontology, minimalFs);\n await fs.promises.mkdir(outDir, {\n recursive: true\n });\n await writeJson(path.join(outDir, \"package.json\"), {\n type: packageType\n });\n await writeJson(path.join(outDir, `tsconfig.json`), {\n compilerOptions: getTsCompilerOptions(packageType)\n });\n }\n await writeJson(path.join(args.outDir, \"package.json\"), await getPackageJsonContents(packageName, version, args.beta ? 2 : 1));\n\n // we need to shim for the node10 resolver\n await fs.promises.mkdir(path.join(args.outDir, \"ontology\"), {\n recursive: true\n });\n await fs.promises.writeFile(path.join(args.outDir, \"ontology/objects.js\"), `module.exports = require(\"../../dist/module/ontology/objects\")`);\n await fs.promises.writeFile(path.join(args.outDir, \"ontology/objects.d.ts\"), `export * from \"../dist/module/ontology/objects\"`);\n return true;\n } catch (e) {\n consola.error(\"OSDK generation failed\", e.message, e.stack);\n return false;\n }\n} //\n\nfunction getTsCompilerOptions(packageType) {\n const commonTsconfig = {\n importHelpers: true,\n declaration: true,\n isolatedModules: true,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n strict: true,\n skipLibCheck: true\n };\n const compilerOptions = packageType === \"commonjs\" ? {\n ...commonTsconfig,\n module: \"commonjs\",\n target: \"es2018\"\n } : {\n ...commonTsconfig,\n module: \"NodeNext\",\n target: \"ES2020\"\n };\n return compilerOptions;\n}\n\n/** @internal */\nexport async function getPackageJsonContents(name, version, sdkVersion) {\n const ourPackageJsonPath = await getOurPackageJsonPath();\n const ourPackageJson = JSON.parse(await fs.promises.readFile(ourPackageJsonPath, \"utf-8\"));\n const esmPrefix = \"./dist/module\";\n const commonjsPrefix = \"./dist/commonjs\";\n return {\n name,\n version,\n main: `${commonjsPrefix}/index.js`,\n module: `${esmPrefix}/index.js`,\n exports: {\n \".\": {\n import: `${esmPrefix}/index.js`,\n require: `${commonjsPrefix}/index.js`\n },\n \"./ontology/objects\": {\n import: `${esmPrefix}/ontology/objects${sdkVersion === 2 ? \"\" : \"/index\"}.js`,\n require: `${commonjsPrefix}/ontology/objects${sdkVersion === 2 ? \"\" : \"/index\"}.js`\n }\n },\n scripts: {\n prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,\n check: \"npm exec attw $(npm pack)\"\n },\n devDependencies: {\n \"typescript\": ourPackageJson.devDependencies.typescript,\n \"tslib\": ourPackageJson.dependencies.tslib,\n \"@arethetypeswrong/cli\": ourPackageJson.dependencies[\"@arethetypeswrong/cli\"],\n \"@osdk/api\": `^${process.env.PACKAGE_API_VERSION}`,\n ...(sdkVersion === 2 ? {\n \"@osdk/client\": `^${process.env.PACKAGE_CLIENT_VERSION}`\n } : {\n \"@osdk/legacy-client\": `^${process.env.PACKAGE_LEGACY_CLIENT_VERSION}`\n })\n },\n peerDependencies: {\n \"@osdk/api\": `^${process.env.PACKAGE_API_VERSION}`,\n ...(sdkVersion === 2 ? {\n \"@osdk/client\": `^${process.env.PACKAGE_CLIENT_VERSION}`\n } : {\n \"@osdk/legacy-client\": `^${process.env.PACKAGE_LEGACY_CLIENT_VERSION}`\n })\n },\n files: [\"**/*.js\", \"**/*.d.ts\", \"dist/**/package.json\"]\n };\n}\nlet cachedOurPackageJsonPath;\nasync function getOurPackageJsonPath() {\n if (cachedOurPackageJsonPath) return cachedOurPackageJsonPath;\n const __dir = path.dirname(fileURLToPath(import.meta.url));\n // todo replace with find package json alt from sid\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, fs) {\n await (args.beta ? generateClientSdkVersionTwoPointZero : generateClientSdkVersionOneDotOne)(ontology, getUserAgent(args.version), fs, args.outDir, args.packageType);\n}\n\n// If the user passed us `dev` as our version, we use that for both our generated package version AND the cli version.\n// This makes it so that releases don't force us to have to regenerate the code when the version strings change.\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 createInMemoryFs() {\n const files = {};\n return [files, {\n writeFile: async (path, contents) => {\n files[path.normalize(path)] = contents;\n },\n mkdir: async (path, _options) => {\n await mkdir(path.normalize(path), {\n recursive: true\n });\n },\n readdir: async path => await readdir(path)\n }];\n}\nfunction createNormalFs() {\n return {\n writeFile: (path, contents) => {\n return fs.promises.writeFile(path, contents, \"utf-8\");\n },\n mkdir: async (path, options) => {\n await fs.promises.mkdir(path, options);\n },\n readdir: async path => fs.promises.readdir(path)\n };\n}\nasync function writeJson(filePath, body) {\n consola.info(`Writing ${filePath}`);\n consola.debug(`Writing ${filePath} with body`, body);\n return await fs.promises.writeFile(filePath, JSON.stringify(body, undefined, 2) + \"\\n\");\n}"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/typescript/generate/handleGenerate.mts"],"names":["fs","path"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,yBAAyB,wBAAwB;AAC1D,SAAS,mCAAmC,4CAA4C;AACxF,SAAS,qBAAqB,4BAA4B;AAC1D,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,YAAY,QAAQ;AACpB,SAAS,OAAO,eAAe;AAC/B,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAI9B,IAAM,aAAa,YAAY,QAA2B;AAC1D,eAAO,eAAsC,MAAM;AACjD,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,CAAI,cAAW,KAAK,YAAY,GAAG;AACrC,YAAQ,MAAM,iCAAiC,KAAK,YAAY,EAAE;AAClE,WAAO;AAAA,EACT;AACA,QAAM,WAAW,KAAK,MAAM,MAAS,YAAS,SAAS,KAAK,cAAc,OAAO,CAAC;AAClF,SAAO,MAAM,kBAAkB,UAAU,IAAI;AAC/C;AACA,eAAe,kBAAkB,MAAM;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;AAAA,IACA,OAAO,CAAC,WAAW,aAAa,sBAAsB;AAAA,EACxD;AACF;AACA,IAAI;AACJ,eAAe,wBAAwB;AACrC,MAAI;AAA0B,WAAO;AACrC,QAAM,QAAa,aAAQ,cAAc,YAAY,GAAG,CAAC;AAEzD,QAAM,qBAAqB,MAAM,OAAO,gBAAgB;AAAA,IACtD,KAAK;AAAA,EACP,CAAC;AACD,MAAI,CAAC,oBAAoB;AACvB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,SAAO,2BAA2B;AACpC;AACA,eAAe,oBAAoB,MAAM,UAAUA,KAAI;AACrD,SAAO,KAAK,OAAO,uCAAuC,mCAAmC,UAAU,aAAa,KAAK,OAAO,GAAGA,KAAI,KAAK,QAAQ,KAAK,WAAW;AACtK;AAIA,SAAS,aAAa,SAAS;AAC7B,MAAI,YAAY,OAAO;AACrB,WAAO;AAAA,EACT,OAAO;AACL,WAAO,kBAAkB,OAAO,IAAI,UAAU;AAAA,EAChD;AACF;AAeA,SAAS,iBAAiB;AACxB,SAAO;AAAA,IACL,WAAW,CAACC,OAAM,aAAa;AAC7B,aAAU,YAAS,UAAUA,OAAM,UAAU,OAAO;AAAA,IACtD;AAAA,IACA,OAAO,OAAOA,OAAM,YAAY;AAC9B,YAAS,YAAS,MAAMA,OAAM,OAAO;AAAA,IACvC;AAAA,IACA,SAAS,OAAMA,UAAW,YAAS,QAAQA,KAAI;AAAA,EACjD;AACF;AACA,eAAe,UAAU,UAAU,MAAM;AACvC,UAAQ,KAAK,WAAW,QAAQ,EAAE;AAClC,UAAQ,MAAM,WAAW,QAAQ,cAAc,IAAI;AACnD,SAAO,MAAS,YAAS,UAAU,UAAU,KAAK,UAAU,MAAM,QAAW,CAAC,IAAI,IAAI;AACxF","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 { getOntologyFullMetadata, listOntologiesV2 } from \"@osdk/gateway/requests\";\nimport { generateClientSdkVersionOneDotOne, generateClientSdkVersionTwoPointZero } from \"@osdk/generator\";\nimport { createClientContext, createOpenApiRequest } from \"@osdk/shared.net\";\nimport { consola } from \"consola\";\nimport { findUp } from \"find-up\";\nimport * as fs from \"node:fs\";\nimport { mkdir, readdir } from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { ExitProcessError } from \"../../../ExitProcessError.js\";\nimport { YargsCheckError } from \"../../../YargsCheckError.js\";\nimport invokeLoginFlow from \"../../auth/login/loginFlow.js\";\nconst USER_AGENT = `osdk-cli/${process.env.PACKAGE_VERSION}`;\nexport default async 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 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 const packageName = args.packageName;\n if (!packageName) throw new Error(\"Package name is require\");\n const version = args.version;\n for (const packageType of [\"module\", \"commonjs\"]) {\n const outDir = path.join(args.outDir, \"dist\", packageType);\n\n // source files per type\n await generateSourceFiles({\n ...args,\n outDir,\n packageType\n }, ontology, minimalFs);\n await fs.promises.mkdir(outDir, {\n recursive: true\n });\n await writeJson(path.join(outDir, \"package.json\"), {\n type: packageType\n });\n await writeJson(path.join(outDir, `tsconfig.json`), {\n compilerOptions: getTsCompilerOptions(packageType)\n });\n }\n await writeJson(path.join(args.outDir, \"package.json\"), await getPackageJsonContents(packageName, version, args.beta ? 2 : 1));\n\n // we need to shim for the node10 resolver\n await fs.promises.mkdir(path.join(args.outDir, \"ontology\"), {\n recursive: true\n });\n await fs.promises.writeFile(path.join(args.outDir, \"ontology/objects.js\"), `module.exports = require(\"../../dist/module/ontology/objects\")`);\n await fs.promises.writeFile(path.join(args.outDir, \"ontology/objects.d.ts\"), `export * from \"../dist/module/ontology/objects\"`);\n return true;\n } catch (e) {\n consola.error(\"OSDK generation failed\", e.message, e.stack);\n return false;\n }\n} //\n\nfunction getTsCompilerOptions(packageType) {\n const commonTsconfig = {\n importHelpers: true,\n declaration: true,\n isolatedModules: true,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n strict: true,\n skipLibCheck: true\n };\n const compilerOptions = packageType === \"commonjs\" ? {\n ...commonTsconfig,\n module: \"commonjs\",\n target: \"es2018\"\n } : {\n ...commonTsconfig,\n module: \"NodeNext\",\n target: \"ES2020\"\n };\n return compilerOptions;\n}\n\n/** @internal */\nexport async function getPackageJsonContents(name, version, sdkVersion) {\n const ourPackageJsonPath = await getOurPackageJsonPath();\n const ourPackageJson = JSON.parse(await fs.promises.readFile(ourPackageJsonPath, \"utf-8\"));\n const esmPrefix = \"./dist/module\";\n const commonjsPrefix = \"./dist/commonjs\";\n return {\n name,\n version,\n main: `${commonjsPrefix}/index.js`,\n module: `${esmPrefix}/index.js`,\n exports: {\n \".\": {\n import: `${esmPrefix}/index.js`,\n require: `${commonjsPrefix}/index.js`\n },\n \"./ontology/objects\": {\n import: `${esmPrefix}/ontology/objects${sdkVersion === 2 ? \"\" : \"/index\"}.js`,\n require: `${commonjsPrefix}/ontology/objects${sdkVersion === 2 ? \"\" : \"/index\"}.js`\n }\n },\n scripts: {\n prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,\n check: \"npm exec attw $(npm pack)\"\n },\n devDependencies: {\n \"typescript\": ourPackageJson.devDependencies.typescript,\n \"tslib\": ourPackageJson.dependencies.tslib,\n \"@arethetypeswrong/cli\": ourPackageJson.dependencies[\"@arethetypeswrong/cli\"],\n \"@osdk/api\": `^${process.env.PACKAGE_API_VERSION}`,\n ...(sdkVersion === 2 ? {\n \"@osdk/client\": `^${process.env.PACKAGE_CLIENT_VERSION}`\n } : {\n \"@osdk/legacy-client\": `^${process.env.PACKAGE_LEGACY_CLIENT_VERSION}`\n })\n },\n peerDependencies: {\n \"@osdk/api\": `^${process.env.PACKAGE_API_VERSION}`,\n ...(sdkVersion === 2 ? {\n \"@osdk/client\": `^${process.env.PACKAGE_CLIENT_VERSION}`\n } : {\n \"@osdk/legacy-client\": `^${process.env.PACKAGE_LEGACY_CLIENT_VERSION}`\n })\n },\n files: [\"**/*.js\", \"**/*.d.ts\", \"dist/**/package.json\"]\n };\n}\nlet cachedOurPackageJsonPath;\nasync function getOurPackageJsonPath() {\n if (cachedOurPackageJsonPath) return cachedOurPackageJsonPath;\n const __dir = path.dirname(fileURLToPath(import.meta.url));\n // todo replace with find package json alt from sid\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, fs) {\n await (args.beta ? generateClientSdkVersionTwoPointZero : generateClientSdkVersionOneDotOne)(ontology, getUserAgent(args.version), fs, args.outDir, args.packageType);\n}\n\n// If the user passed us `dev` as our version, we use that for both our generated package version AND the cli version.\n// This makes it so that releases don't force us to have to regenerate the code when the version strings change.\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 createInMemoryFs() {\n const files = {};\n return [files, {\n writeFile: async (path, contents) => {\n files[path.normalize(path)] = contents;\n },\n mkdir: async (path, _options) => {\n await mkdir(path.normalize(path), {\n recursive: true\n });\n },\n readdir: async path => await readdir(path)\n }];\n}\nfunction createNormalFs() {\n return {\n writeFile: (path, contents) => {\n return fs.promises.writeFile(path, contents, \"utf-8\");\n },\n mkdir: async (path, options) => {\n await fs.promises.mkdir(path, options);\n },\n readdir: async path => fs.promises.readdir(path)\n };\n}\nasync function writeJson(filePath, body) {\n consola.info(`Writing ${filePath}`);\n consola.debug(`Writing ${filePath} with body`, body);\n return await fs.promises.writeFile(filePath, JSON.stringify(body, undefined, 2) + \"\\n\");\n}"]}
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkTZGNA5WR_cjs = require('./chunk-TZGNA5WR.cjs');
4
- require('./chunk-HQDDGVB7.cjs');
5
-
6
-
7
-
8
- module.exports = chunkTZGNA5WR_cjs.invokeLoginFlow;
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=loginFlow-5ZAMXQKE.cjs.map
@@ -1,4 +0,0 @@
1
- export { invokeLoginFlow as default } from './chunk-HD6SVFKA.mjs';
2
- import './chunk-E2SEJZTC.mjs';
3
- //# sourceMappingURL=out.js.map
4
- //# sourceMappingURL=loginFlow-BWWZBM36.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/site/deploy/siteDeployCommand.mts","../../src/util/autoVersion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAS,eAAe;AAExB,OAAO,cAAc;AACrB,SAAS,gBAAgB;AACzB,YAAY,QAAQ;AACpB,OAAO,UAAU;AACjB,SAAS,gBAAgB;;;ACNzB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAW1B,eAAsB,YAAY,YAAY,IAAI;AAChD,QAAM,CAAC,aAAa,WAAW,IAAI,cAAc,KAAK,CAAC,WAAW,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC,IAAI,CAAC,QAAW,IAAI,OAAO,KAAK,CAAC;AAC9H,QAAM,aAAa,MAAM,YAAY,WAAW;AAChD,QAAM,UAAU,WAAW,KAAK,EAAE,QAAQ,aAAa,EAAE;AACzD,MAAI,CAAC,cAAc,OAAO,GAAG;AAC3B,UAAM,IAAI,iBAAiB,GAAG,sBAAsB,OAAO,2BAA2B;AAAA,EACxF;AACA,SAAO;AACT;AACA,eAAe,YAAY,aAAa;AACtC,MAAI;AACJ,MAAI;AACF,UAAM,YAAY,UAAU,IAAI;AAChC,UAAM;AAAA,MACJ;AAAA,IACF,IAAI,MAAM,UAAU,6CAA6C,eAAe,OAAO,aAAa,WAAW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YAAY,OAAO,MAAM;AAChC,UAAQ,IAAI;AAAA,IACV,SAAS,GAAG,KAAK;AAAA;AAAA,EAAO,SAAS,SAAS,IAAI,CAAC;AAAA,IAC/C,OAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,EACF,CAAC;AACH;AACA,SAAS,mBAAmB,SAAS;AACnC,MAAI,QAAQ,WAAW,GAAG;AACxB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AACA,UAAQ,QAAQ,CAAC,EAAE,MAAM;AAAA,IACvB,KAAK;AACH,aAAO,QAAQ,CAAC,EAAE,oBAAoB,WAAW;AAAA,IACnD;AACE,YAAM,IAAI,QAAQ,CAAC,EAAE;AAAA,EACzB;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\";\nimport { artifacts, ArtifactsSitesAdminV2Service, createConjureContext, createInternalClientContext, thirdPartyApplicationService } from \"#net\";\nimport archiver from \"archiver\";\nimport { colorize } from \"consola/utils\";\nimport * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport { ExitProcessError } from \"../../../ExitProcessError.js\";\nimport { autoVersion as findAutoVersion } from \"../../../util/autoVersion.js\";\nimport { loadToken } from \"../../../util/token.js\";\nexport default async function siteDeployCommand({\n selectedVersion,\n application,\n foundryUrl,\n uploadOnly,\n directory,\n token,\n tokenFile\n}) {\n const loadedToken = await loadToken(token, tokenFile);\n const tokenProvider = () => loadedToken;\n const clientCtx = createInternalClientContext(foundryUrl, tokenProvider);\n const ctx = createConjureContext(foundryUrl, \"/artifacts/api\", tokenProvider);\n let siteVersion;\n if (typeof selectedVersion === \"string\") {\n siteVersion = selectedVersion;\n } else {\n siteVersion = await findAutoVersion(selectedVersion.tagPrefix);\n consola.info(`Auto version inferred next version to be: ${siteVersion}`);\n }\n consola.debug(`Using directory for site files: \"${path.resolve(directory)}`);\n const stat = await fs.promises.stat(directory);\n if (!stat.isDirectory()) {\n throw new ExitProcessError(2, \"Specified path exists but is not a directory\");\n }\n consola.start(\"Zipping site files\");\n const archive = archiver(\"zip\").directory(directory, false);\n logArchiveStats(archive);\n consola.start(\"Uploading site files\");\n await Promise.all([artifacts.SiteAssetArtifactsService.uploadZippedSiteAsset(clientCtx, {\n application,\n version: siteVersion,\n zipFile: Readable.toWeb(archive) // This cast is because the dom fetch doesnt align type wise with streams\n }), archive.finalize()]);\n consola.success(\"Upload complete\");\n const repositoryRid = await thirdPartyApplicationService.fetchWebsiteRepositoryRid(clientCtx, application);\n const registeredSiteDomains = await ArtifactsSitesAdminV2Service.getRegisteredSiteDomains(ctx, repositoryRid);\n const domain = getFirstSiteDomain(registeredSiteDomains);\n if (!uploadOnly) {\n await ArtifactsSitesAdminV2Service.updateDeployedVersion(ctx, repositoryRid, {\n siteVersion: {\n version: siteVersion\n }\n });\n consola.success(`Deployed ${siteVersion} successfully`);\n if (domain != null) {\n logSiteLink(\"View live site:\", `https://${domain}`);\n }\n } else {\n consola.debug(\"Upload only mode enabled, skipping deployment\");\n if (domain != null) {\n logSiteLink(\"Preview link:\", `https://${domain}/.system/preview?previewVersion=${siteVersion}`);\n }\n }\n}\nfunction logArchiveStats(archive) {\n let archiveStats = {\n fileCount: 0,\n bytes: 0\n };\n archive.on(\"progress\", progress => {\n archiveStats = {\n fileCount: progress.entries.total,\n bytes: progress.fs.totalBytes\n };\n });\n archive.on(\"finish\", () => {\n consola.debug(`Zipped ${archiveStats.fileCount} files and ${archiveStats.bytes} bytes`);\n });\n}\nfunction logSiteLink(title, link) {\n consola.box({\n message: `${title}\\n\\n${colorize(\"green\", link)}`,\n style: {\n padding: 2,\n borderColor: \"green\",\n borderStyle: \"rounded\"\n }\n });\n}\nfunction getFirstSiteDomain(domains) {\n if (domains.length === 0) {\n consola.warn(\"No registered domains for site found\");\n return undefined;\n }\n switch (domains[0].type) {\n case \"controlPanelManaged\":\n return domains[0].controlPanelManaged.siteDomain.domain;\n default:\n const _ = domains[0].type;\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\nimport { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { ExitProcessError } from \"../ExitProcessError.js\";\nimport { isValidSemver } from \"./isValidSemver.js\";\n\n/**\n * Gets the version string using git describe. If the @param tagPrefix is empty, git describe will return the\n * latest tag (without any filtering) and if the tag starts with \"v\", it will be removed.\n * @param tagPrefix The prefix to use for matching against tags. Defaults to an empty string.\n * @returns A promise that resolves to the version string.\n * @throws An error if the version string is not SemVer compliant or if the version cannot be determined.\n */\nexport async function autoVersion(tagPrefix = \"\") {\n const [matchPrefix, prefixRegex] = tagPrefix !== \"\" ? [tagPrefix, new RegExp(`^${tagPrefix}`)] : [undefined, new RegExp(`^v?`)];\n const gitVersion = await gitDescribe(matchPrefix);\n const version = gitVersion.trim().replace(prefixRegex, \"\");\n if (!isValidSemver(version)) {\n throw new ExitProcessError(2, `The version string ${version} is not SemVer compliant.`);\n }\n return version;\n}\nasync function gitDescribe(matchPrefix) {\n let gitVersion;\n try {\n const execAsync = promisify(exec);\n const {\n stdout\n } = await execAsync(`git describe --tags --first-parent --dirty${matchPrefix != null ? ` --match=\"${matchPrefix}*\"` : \"\"}`, {\n encoding: \"utf8\"\n });\n gitVersion = stdout;\n } catch (error) {\n if (error instanceof Error) {\n const errorMessage = error.message.toLowerCase();\n if (errorMessage.includes(\"not recognized\") || errorMessage.includes(\"command not found\") || errorMessage.includes(\"no such file or directory\")) {\n throw new ExitProcessError(2, \"Unable to determine auto version using git-describe as git is not installed or found in the PATH.\", `You can set up git and try again or supply a --version option to set the version manually`);\n }\n if (errorMessage.includes(\"fatal: not a git repository\")) {\n throw new ExitProcessError(2, `Unable to determine auto version using git-describe as the current directory is not a git repository.`, `You can run the command in a git repository and try again or supply a --version option to set the version manually`);\n }\n if (errorMessage.includes(\"fatal: no names found, cannot describe anything.\")) {\n throw new ExitProcessError(2, `Unable to determine auto version using git-describe as no matching tags were found.`, `You can create a tag matching the configured tag prefix and try again or supply a --version option to set the version manually`);\n }\n }\n throw new ExitProcessError(2, `Unable to determine auto version using git-describe: ${error}.`, `You can supply a --version option to set the version manually`);\n }\n return gitVersion;\n}"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/site/deploy/siteDeployCommand.mts","../../src/util/autoVersion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAS,eAAe;AAExB,OAAO,cAAc;AACrB,SAAS,gBAAgB;AACzB,YAAY,QAAQ;AACpB,OAAO,UAAU;AACjB,SAAS,gBAAgB;;;ACNzB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAW1B,eAAsB,YAAY,YAAY,IAAI;AAChD,QAAM,CAAC,aAAa,WAAW,IAAI,cAAc,KAAK,CAAC,WAAW,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC,IAAI,CAAC,QAAW,IAAI,OAAO,KAAK,CAAC;AAC9H,QAAM,aAAa,MAAM,YAAY,WAAW;AAChD,QAAM,UAAU,WAAW,KAAK,EAAE,QAAQ,aAAa,EAAE;AACzD,MAAI,CAAC,c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;AACA,UAAQ,GAAG,YAAY,cAAY;AACjC,mBAAe;AAAA,MACb,WAAW,SAAS,QAAQ;AAAA,MAC5B,OAAO,SAAS,GAAG;AAAA,IACrB;AAAA,EACF,CAAC;AACD,UAAQ,GAAG,UAAU,MAAM;AACzB,YAAQ,MAAM,UAAU,aAAa,SAAS,cAAc,aAAa,KAAK,QAAQ;AAAA,EACxF,CAAC;AACH;AACA,SAAS,YAAY,OAAO,MAAM;AAChC,UAAQ,IAAI;AAAA,IACV,SAAS,GAAG,KAAK;AAAA;AAAA,EAAO,SAAS,SAAS,IAAI,CAAC;AAAA,IAC/C,OAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,EACF,CAAC;AACH;AACA,SAAS,mBAAmB,SAAS;AACnC,MAAI,QAAQ,WAAW,GAAG;AACxB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AACA,UAAQ,QAAQ,CAAC,EAAE,MAAM;AAAA,IACvB,KAAK;AACH,aAAO,QAAQ,CAAC,EAAE,oBAAoB,WAAW;AAAA,IACnD;AACE,YAAM,IAAI,QAAQ,CAAC,EAAE;AAAA,EACzB;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\";\nimport { artifacts, ArtifactsSitesAdminV2Service, createConjureContext, createInternalClientContext, thirdPartyApplicationService } from \"#net\";\nimport archiver from \"archiver\";\nimport { colorize } from \"consola/utils\";\nimport * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport { ExitProcessError } from \"../../../ExitProcessError.js\";\nimport { autoVersion as findAutoVersion } from \"../../../util/autoVersion.js\";\nimport { loadToken } from \"../../../util/token.js\";\nexport default async function siteDeployCommand({\n selectedVersion,\n application,\n foundryUrl,\n uploadOnly,\n directory,\n token,\n tokenFile\n}) {\n const loadedToken = await loadToken(token, tokenFile);\n const tokenProvider = () => loadedToken;\n const clientCtx = createInternalClientContext(foundryUrl, tokenProvider);\n const ctx = createConjureContext(foundryUrl, \"/artifacts/api\", tokenProvider);\n let siteVersion;\n if (typeof selectedVersion === \"string\") {\n siteVersion = selectedVersion;\n } else {\n siteVersion = await findAutoVersion(selectedVersion.tagPrefix);\n consola.info(`Auto version inferred next version to be: ${siteVersion}`);\n }\n consola.debug(`Using directory for site files: \"${path.resolve(directory)}`);\n const stat = await fs.promises.stat(directory);\n if (!stat.isDirectory()) {\n throw new ExitProcessError(2, \"Specified path exists but is not a directory\");\n }\n consola.start(\"Zipping site files\");\n const archive = archiver(\"zip\").directory(directory, false);\n logArchiveStats(archive);\n consola.start(\"Uploading site files\");\n await Promise.all([artifacts.SiteAssetArtifactsService.uploadZippedSiteAsset(clientCtx, {\n application,\n version: siteVersion,\n zipFile: Readable.toWeb(archive) // This cast is because the dom fetch doesnt align type wise with streams\n }), archive.finalize()]);\n consola.success(\"Upload complete\");\n const repositoryRid = await thirdPartyApplicationService.fetchWebsiteRepositoryRid(clientCtx, application);\n const registeredSiteDomains = await ArtifactsSitesAdminV2Service.getRegisteredSiteDomains(ctx, repositoryRid);\n const domain = getFirstSiteDomain(registeredSiteDomains);\n if (!uploadOnly) {\n await ArtifactsSitesAdminV2Service.updateDeployedVersion(ctx, repositoryRid, {\n siteVersion: {\n version: siteVersion\n }\n });\n consola.success(`Deployed ${siteVersion} successfully`);\n if (domain != null) {\n logSiteLink(\"View live site:\", `https://${domain}`);\n }\n } else {\n consola.debug(\"Upload only mode enabled, skipping deployment\");\n if (domain != null) {\n logSiteLink(\"Preview link:\", `https://${domain}/.system/preview?previewVersion=${siteVersion}`);\n }\n }\n}\nfunction logArchiveStats(archive) {\n let archiveStats = {\n fileCount: 0,\n bytes: 0\n };\n archive.on(\"progress\", progress => {\n archiveStats = {\n fileCount: progress.entries.total,\n bytes: progress.fs.totalBytes\n };\n });\n archive.on(\"finish\", () => {\n consola.debug(`Zipped ${archiveStats.fileCount} files and ${archiveStats.bytes} bytes`);\n });\n}\nfunction logSiteLink(title, link) {\n consola.box({\n message: `${title}\\n\\n${colorize(\"green\", link)}`,\n style: {\n padding: 2,\n borderColor: \"green\",\n borderStyle: \"rounded\"\n }\n });\n}\nfunction getFirstSiteDomain(domains) {\n if (domains.length === 0) {\n consola.warn(\"No registered domains for site found\");\n return undefined;\n }\n switch (domains[0].type) {\n case \"controlPanelManaged\":\n return domains[0].controlPanelManaged.siteDomain.domain;\n default:\n const _ = domains[0].type;\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\nimport { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { ExitProcessError } from \"../ExitProcessError.js\";\nimport { isValidSemver } from \"./isValidSemver.js\";\n\n/**\n * Gets the version string using git describe. If the @param tagPrefix is empty, git describe will return the\n * latest tag (without any filtering) and if the tag starts with \"v\", it will be removed.\n * @param tagPrefix The prefix to use for matching against tags. Defaults to an empty string.\n * @returns A promise that resolves to the version string.\n * @throws An error if the version string is not SemVer compliant or if the version cannot be determined.\n */\nexport async function autoVersion(tagPrefix = \"\") {\n const [matchPrefix, prefixRegex] = tagPrefix !== \"\" ? [tagPrefix, new RegExp(`^${tagPrefix}`)] : [undefined, new RegExp(`^v?`)];\n const gitVersion = await gitDescribe(matchPrefix);\n const version = gitVersion.trim().replace(prefixRegex, \"\");\n if (!isValidSemver(version)) {\n throw new ExitProcessError(2, `The version string ${version} is not SemVer compliant.`);\n }\n return version;\n}\nasync function gitDescribe(matchPrefix) {\n let gitVersion;\n try {\n const execAsync = promisify(exec);\n const {\n stdout\n } = await execAsync(`git describe --tags --first-parent --dirty${matchPrefix != null ? ` --match=\"${matchPrefix}*\"` : \"\"}`, {\n encoding: \"utf8\"\n });\n gitVersion = stdout;\n } catch (error) {\n if (error instanceof Error) {\n const errorMessage = error.message.toLowerCase();\n if (errorMessage.includes(\"not recognized\") || errorMessage.includes(\"command not found\") || errorMessage.includes(\"no such file or directory\")) {\n throw new ExitProcessError(2, \"Unable to determine auto version using git-describe as git is not installed or found in the PATH.\", `You can set up git and try again or supply a --version option to set the version manually`);\n }\n if (errorMessage.includes(\"fatal: not a git repository\")) {\n throw new ExitProcessError(2, `Unable to determine auto version using git-describe as the current directory is not a git repository.`, `You can run the command in a git repository and try again or supply a --version option to set the version manually`);\n }\n if (errorMessage.includes(\"fatal: no names found, cannot describe anything.\")) {\n throw new ExitProcessError(2, `Unable to determine auto version using git-describe as no matching tags were found.`, `You can create a tag matching the configured tag prefix and try again or supply a --version option to set the version manually`);\n }\n }\n throw new ExitProcessError(2, `Unable to determine auto version using git-describe: ${error}.`, `You can supply a --version option to set the version manually`);\n }\n return gitVersion;\n}"]}
@@ -1,4 +0,0 @@
1
- export interface CliCommonArgs {
2
- verbose: number;
3
- }
4
- //# sourceMappingURL=CliCommonArgs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CliCommonArgs.d.ts","sourceRoot":"","sources":["../../src/CliCommonArgs.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -1,7 +0,0 @@
1
- export declare class ExitProcessError extends Error {
2
- readonly errorCode: number;
3
- readonly msg?: string | undefined;
4
- readonly tip?: string | undefined;
5
- constructor(errorCode: number, msg?: string | undefined, tip?: string | undefined);
6
- }
7
- //# sourceMappingURL=ExitProcessError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExitProcessError.d.ts","sourceRoot":"","sources":["../../src/ExitProcessError.ts"],"names":[],"mappings":"AAgBA,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,SAAS,EAAE,MAAM;aACjB,GAAG,CAAC;aACJ,GAAG,CAAC;gBAFJ,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,oBAAQ,EACZ,GAAG,CAAC,oBAAQ;CAI/B"}
@@ -1,4 +0,0 @@
1
- export declare class YargsCheckError extends Error {
2
- constructor(msg?: string);
3
- }
4
- //# sourceMappingURL=YargsCheckError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"YargsCheckError.d.ts","sourceRoot":"","sources":["../../src/YargsCheckError.ts"],"names":[],"mappings":"AAgBA,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,GAAG,CAAC,EAAE,MAAM;CAGzB"}
@@ -1,5 +0,0 @@
1
- import type { CliCommonArgs } from "../../CliCommonArgs.js";
2
- export interface CommonAuthArgs extends CliCommonArgs {
3
- foundryUrl: string;
4
- }
5
- //# sourceMappingURL=CommonAuthArgs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommonAuthArgs.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/CommonAuthArgs.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -1,5 +0,0 @@
1
- import type { CommonAuthArgs } from "../CommonAuthArgs.js";
2
- export interface LoginArgs extends CommonAuthArgs {
3
- clientId: string;
4
- }
5
- //# sourceMappingURL=LoginArgs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoginArgs.d.ts","sourceRoot":"","sources":["../../../../../src/commands/auth/login/LoginArgs.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -1,3 +0,0 @@
1
- import type { LoginArgs } from "./LoginArgs.js";
2
- export default function invokeLoginFlow(args: LoginArgs): Promise<import("./token.js").TokenSuccessResponse>;
3
- //# sourceMappingURL=loginFlow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loginFlow.d.ts","sourceRoot":"","sources":["../../../../../src/commands/auth/login/loginFlow.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD,wBAA8B,eAAe,CAAC,IAAI,EAAE,SAAS,sDA8E5D"}
@@ -1,13 +0,0 @@
1
- export interface TokenSuccessResponse {
2
- access_token: string;
3
- token_type: string;
4
- refresh_token: string;
5
- expires_in: number;
6
- }
7
- export interface TokenErrorResponse {
8
- error: string;
9
- error_description: string;
10
- }
11
- export type TokenResponse = TokenErrorResponse | TokenSuccessResponse;
12
- export declare function isTokenErrorResponse(response: TokenSuccessResponse | TokenErrorResponse): response is TokenErrorResponse;
13
- //# sourceMappingURL=token.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../../src/commands/auth/login/token.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAEtE,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,oBAAoB,GAAG,kBAAkB,GAClD,QAAQ,IAAI,kBAAkB,CAEhC"}