ppio-sandbox 2.0.4-a1 → 2.0.4-a2

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.
@@ -60,7 +60,7 @@ import createClient from "openapi-fetch";
60
60
  import platform2 from "platform";
61
61
 
62
62
  // package.json
63
- var version = "2.0.4-a1";
63
+ var version = "2.0.4-a2";
64
64
 
65
65
  // src/core/utils.ts
66
66
  import platform from "platform";
@@ -401,6 +401,9 @@ var LEGACY_DOMAINS = [
401
401
  "sandbox.ppio.cn",
402
402
  "sandbox-test.ppio.cn"
403
403
  ];
404
+ var DEFAULT_PPIO_API_URLS = {
405
+ "cn-beijing-1.sandbox.ppio.com": "https://api.cn-beijing-1.sandbox.ppio.com"
406
+ };
404
407
  function isLegacyDomain(domain) {
405
408
  return domain ? LEGACY_DOMAINS.includes(domain) : true;
406
409
  }
@@ -414,6 +417,13 @@ function validateDomain(domain) {
414
417
  throw new Error("Domain cannot be empty");
415
418
  }
416
419
  }
420
+ function getDefaultApiUrl(domain, debug) {
421
+ var _a3;
422
+ if (debug) {
423
+ return "http://localhost:3000";
424
+ }
425
+ return (_a3 = DEFAULT_PPIO_API_URLS[domain]) != null ? _a3 : `https://api.${domain}`;
426
+ }
417
427
  var _ConnectionConfig = class _ConnectionConfig {
418
428
  constructor(opts) {
419
429
  var _a3;
@@ -426,11 +436,11 @@ var _ConnectionConfig = class _ConnectionConfig {
426
436
  this.logger = opts == null ? void 0 : opts.logger;
427
437
  this.headers = (opts == null ? void 0 : opts.headers) || {};
428
438
  this.headers["User-Agent"] = `ppio-sandbox-sdk-js/${version}`;
429
- this.apiUrl = (opts == null ? void 0 : opts.apiUrl) || _ConnectionConfig.apiUrl || (this.debug ? "http://localhost:3000" : `https://api.${this.domain}`);
439
+ this.apiUrl = (opts == null ? void 0 : opts.apiUrl) || _ConnectionConfig.apiUrl || getDefaultApiUrl(this.domain, this.debug);
430
440
  this.sandboxUrl = (opts == null ? void 0 : opts.sandboxUrl) || _ConnectionConfig.sandboxUrl;
431
441
  }
432
442
  static get domain() {
433
- return getEnvVar("PPIO_DOMAIN") || "sandbox.ppio.cn";
443
+ return getEnvVar("PPIO_DOMAIN") || "cn-beijing-1.sandbox.ppio.com";
434
444
  }
435
445
  static get apiUrl() {
436
446
  return getEnvVar("PPIO_API_URL");
@@ -5739,6 +5749,20 @@ function handleCmdEntrypointInstruction(instruction, templateBuilder) {
5739
5749
 
5740
5750
  // src/core/template/index.ts
5741
5751
  var TemplateApi = class {
5752
+ static async getTemplate(templateId, options) {
5753
+ const config = new ConnectionConfig(options);
5754
+ const client = new ApiClient(config);
5755
+ const response = await client.api.GET("/templates/{templateID}", {
5756
+ params: { path: { templateID: templateId } },
5757
+ signal: config.getSignal(options == null ? void 0 : options.requestTimeoutMs)
5758
+ });
5759
+ const error = handleApiError(response);
5760
+ if (error) throw error;
5761
+ if (!response.data) {
5762
+ throw new BuildError("Template details response data is missing");
5763
+ }
5764
+ return response.data;
5765
+ }
5742
5766
  static async listTemplates(options) {
5743
5767
  var _a3, _b, _c, _d, _e, _f, _g, _h;
5744
5768
  const templateType = (_a3 = options == null ? void 0 : options.templateType) != null ? _a3 : "template_build";
@@ -5757,6 +5781,9 @@ var TemplateApi = class {
5757
5781
  }
5758
5782
  const config = new ConnectionConfig(options);
5759
5783
  const url = new URL(`${config.apiUrl}/v2/templates`);
5784
+ if (options == null ? void 0 : options.teamID) {
5785
+ url.searchParams.set("teamID", options.teamID);
5786
+ }
5760
5787
  url.searchParams.set("template_type", templateType);
5761
5788
  url.searchParams.set("page", String(page));
5762
5789
  url.searchParams.set("limit", String(limit));
@@ -5964,6 +5991,9 @@ var TemplateBase = class _TemplateBase {
5964
5991
  static async listTemplates(options) {
5965
5992
  return TemplateApi.listTemplates(options);
5966
5993
  }
5994
+ static async get(templateId, options) {
5995
+ return TemplateApi.getTemplate(templateId, options);
5996
+ }
5967
5997
  static async delete(templateId, options) {
5968
5998
  await TemplateApi.deleteTemplate(templateId, options);
5969
5999
  }
@@ -6790,6 +6820,7 @@ function Template(options) {
6790
6820
  Template.build = TemplateBase.build;
6791
6821
  Template.buildInBackground = TemplateBase.buildInBackground;
6792
6822
  Template.getBuildStatus = TemplateBase.getBuildStatus;
6823
+ Template.get = TemplateBase.get;
6793
6824
  Template.exists = TemplateBase.exists;
6794
6825
  Template.aliasExists = TemplateBase.aliasExists;
6795
6826
  Template.assignTags = TemplateBase.assignTags;
@@ -6852,4 +6883,4 @@ export {
6852
6883
  Template,
6853
6884
  core_default
6854
6885
  };
6855
- //# sourceMappingURL=chunk-E4DEQD23.mjs.map
6886
+ //# sourceMappingURL=chunk-TKMNGUIC.mjs.map