ppio-sandbox 2.0.3-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.3-a1";
63
+ var version = "2.0.4-a2";
64
64
 
65
65
  // src/core/utils.ts
66
66
  import platform from "platform";
@@ -399,9 +399,11 @@ var KEEPALIVE_PING_INTERVAL_SEC = 50;
399
399
  var KEEPALIVE_PING_HEADER = "Keepalive-Ping-Interval";
400
400
  var LEGACY_DOMAINS = [
401
401
  "sandbox.ppio.cn",
402
- "cn-beijing-1.sandbox.ppio.com",
403
402
  "sandbox-test.ppio.cn"
404
403
  ];
404
+ var DEFAULT_PPIO_API_URLS = {
405
+ "cn-beijing-1.sandbox.ppio.com": "https://api.cn-beijing-1.sandbox.ppio.com"
406
+ };
405
407
  function isLegacyDomain(domain) {
406
408
  return domain ? LEGACY_DOMAINS.includes(domain) : true;
407
409
  }
@@ -415,6 +417,13 @@ function validateDomain(domain) {
415
417
  throw new Error("Domain cannot be empty");
416
418
  }
417
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
+ }
418
427
  var _ConnectionConfig = class _ConnectionConfig {
419
428
  constructor(opts) {
420
429
  var _a3;
@@ -427,11 +436,11 @@ var _ConnectionConfig = class _ConnectionConfig {
427
436
  this.logger = opts == null ? void 0 : opts.logger;
428
437
  this.headers = (opts == null ? void 0 : opts.headers) || {};
429
438
  this.headers["User-Agent"] = `ppio-sandbox-sdk-js/${version}`;
430
- 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);
431
440
  this.sandboxUrl = (opts == null ? void 0 : opts.sandboxUrl) || _ConnectionConfig.sandboxUrl;
432
441
  }
433
442
  static get domain() {
434
- return getEnvVar("PPIO_DOMAIN") || "sandbox.ppio.cn";
443
+ return getEnvVar("PPIO_DOMAIN") || "cn-beijing-1.sandbox.ppio.com";
435
444
  }
436
445
  static get apiUrl() {
437
446
  return getEnvVar("PPIO_API_URL");
@@ -5740,6 +5749,20 @@ function handleCmdEntrypointInstruction(instruction, templateBuilder) {
5740
5749
 
5741
5750
  // src/core/template/index.ts
5742
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
+ }
5743
5766
  static async listTemplates(options) {
5744
5767
  var _a3, _b, _c, _d, _e, _f, _g, _h;
5745
5768
  const templateType = (_a3 = options == null ? void 0 : options.templateType) != null ? _a3 : "template_build";
@@ -5758,6 +5781,9 @@ var TemplateApi = class {
5758
5781
  }
5759
5782
  const config = new ConnectionConfig(options);
5760
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
+ }
5761
5787
  url.searchParams.set("template_type", templateType);
5762
5788
  url.searchParams.set("page", String(page));
5763
5789
  url.searchParams.set("limit", String(limit));
@@ -5965,6 +5991,9 @@ var TemplateBase = class _TemplateBase {
5965
5991
  static async listTemplates(options) {
5966
5992
  return TemplateApi.listTemplates(options);
5967
5993
  }
5994
+ static async get(templateId, options) {
5995
+ return TemplateApi.getTemplate(templateId, options);
5996
+ }
5968
5997
  static async delete(templateId, options) {
5969
5998
  await TemplateApi.deleteTemplate(templateId, options);
5970
5999
  }
@@ -6791,6 +6820,7 @@ function Template(options) {
6791
6820
  Template.build = TemplateBase.build;
6792
6821
  Template.buildInBackground = TemplateBase.buildInBackground;
6793
6822
  Template.getBuildStatus = TemplateBase.getBuildStatus;
6823
+ Template.get = TemplateBase.get;
6794
6824
  Template.exists = TemplateBase.exists;
6795
6825
  Template.aliasExists = TemplateBase.aliasExists;
6796
6826
  Template.assignTags = TemplateBase.assignTags;
@@ -6853,4 +6883,4 @@ export {
6853
6883
  Template,
6854
6884
  core_default
6855
6885
  };
6856
- //# sourceMappingURL=chunk-WFJJXB7T.mjs.map
6886
+ //# sourceMappingURL=chunk-TKMNGUIC.mjs.map