@uniformdev/context 18.5.0 → 18.6.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.
package/dist/api/api.d.ts CHANGED
@@ -44,6 +44,7 @@ declare class ApiClient<TOptions extends ClientOptions = ClientOptions> {
44
44
  expectNoContent?: boolean;
45
45
  }): Promise<TResponse>;
46
46
  protected createUrl(path: string, queryParams?: Record<string, string | boolean | undefined | null | number | Array<string | boolean | number>>, hostOverride?: string): URL;
47
+ private ensureApiHost;
47
48
  private static getRequestId;
48
49
  }
49
50
 
package/dist/api/api.js CHANGED
@@ -90,7 +90,7 @@ var ApiClientError = class extends Error {
90
90
  var ApiClient = class {
91
91
  constructor(options) {
92
92
  __publicField(this, "options");
93
- var _a, _b, _c, _d, _e, _f;
93
+ var _a, _b, _c, _d, _e;
94
94
  if (!options.apiKey && !options.bearerToken) {
95
95
  throw new Error("You must provide an API key or a bearer token");
96
96
  }
@@ -107,12 +107,12 @@ var ApiClient = class {
107
107
  this.options = {
108
108
  ...options,
109
109
  fetch: leFetch,
110
- apiHost: (_a = options.apiHost) != null ? _a : "https://uniform.app",
111
- apiKey: (_b = options.apiKey) != null ? _b : null,
112
- projectId: (_c = options.projectId) != null ? _c : null,
113
- bearerToken: (_d = options.bearerToken) != null ? _d : null,
114
- limitPolicy: (_e = options.limitPolicy) != null ? _e : nullLimitPolicy,
115
- bypassCache: (_f = options.bypassCache) != null ? _f : false
110
+ apiHost: this.ensureApiHost(options.apiHost),
111
+ apiKey: (_a = options.apiKey) != null ? _a : null,
112
+ projectId: (_b = options.projectId) != null ? _b : null,
113
+ bearerToken: (_c = options.bearerToken) != null ? _c : null,
114
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : nullLimitPolicy,
115
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
116
116
  };
117
117
  }
118
118
  async apiClient(fetchUri, options) {
@@ -175,6 +175,23 @@ var ApiClient = class {
175
175
  });
176
176
  return url;
177
177
  }
178
+ ensureApiHost(apiHost) {
179
+ if (!apiHost)
180
+ return "https://uniform.app";
181
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("https://"))) {
182
+ throw new Error('Your apiHost must start with "https://"');
183
+ }
184
+ if (apiHost.indexOf("/", 8) > -1) {
185
+ throw new Error("Your apiHost must not contain a path element after the domain");
186
+ }
187
+ if (apiHost.indexOf("?") > -1) {
188
+ throw new Error("Your apiHost must not contain a query string");
189
+ }
190
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
191
+ apiHost = apiHost.substring(0, apiHost.length - 1);
192
+ }
193
+ return apiHost;
194
+ }
178
195
  static getRequestId(response) {
179
196
  const apigRequestId = response.headers.get("apigw-requestid");
180
197
  if (apigRequestId) {
package/dist/api/api.mjs CHANGED
@@ -40,7 +40,7 @@ var ApiClientError = class extends Error {
40
40
  var ApiClient = class {
41
41
  constructor(options) {
42
42
  __publicField(this, "options");
43
- var _a, _b, _c, _d, _e, _f;
43
+ var _a, _b, _c, _d, _e;
44
44
  if (!options.apiKey && !options.bearerToken) {
45
45
  throw new Error("You must provide an API key or a bearer token");
46
46
  }
@@ -57,12 +57,12 @@ var ApiClient = class {
57
57
  this.options = {
58
58
  ...options,
59
59
  fetch: leFetch,
60
- apiHost: (_a = options.apiHost) != null ? _a : "https://uniform.app",
61
- apiKey: (_b = options.apiKey) != null ? _b : null,
62
- projectId: (_c = options.projectId) != null ? _c : null,
63
- bearerToken: (_d = options.bearerToken) != null ? _d : null,
64
- limitPolicy: (_e = options.limitPolicy) != null ? _e : nullLimitPolicy,
65
- bypassCache: (_f = options.bypassCache) != null ? _f : false
60
+ apiHost: this.ensureApiHost(options.apiHost),
61
+ apiKey: (_a = options.apiKey) != null ? _a : null,
62
+ projectId: (_b = options.projectId) != null ? _b : null,
63
+ bearerToken: (_c = options.bearerToken) != null ? _c : null,
64
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : nullLimitPolicy,
65
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
66
66
  };
67
67
  }
68
68
  async apiClient(fetchUri, options) {
@@ -125,6 +125,23 @@ var ApiClient = class {
125
125
  });
126
126
  return url;
127
127
  }
128
+ ensureApiHost(apiHost) {
129
+ if (!apiHost)
130
+ return "https://uniform.app";
131
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("https://"))) {
132
+ throw new Error('Your apiHost must start with "https://"');
133
+ }
134
+ if (apiHost.indexOf("/", 8) > -1) {
135
+ throw new Error("Your apiHost must not contain a path element after the domain");
136
+ }
137
+ if (apiHost.indexOf("?") > -1) {
138
+ throw new Error("Your apiHost must not contain a query string");
139
+ }
140
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
141
+ apiHost = apiHost.substring(0, apiHost.length - 1);
142
+ }
143
+ return apiHost;
144
+ }
128
145
  static getRequestId(response) {
129
146
  const apigRequestId = response.headers.get("apigw-requestid");
130
147
  if (apigRequestId) {
package/dist/cli/cli.js CHANGED
@@ -19619,7 +19619,7 @@ var ApiClientError = class extends Error {
19619
19619
  var ApiClient = class {
19620
19620
  constructor(options) {
19621
19621
  __publicField(this, "options");
19622
- var _a2, _b2, _c2, _d, _e, _f;
19622
+ var _a2, _b2, _c2, _d, _e;
19623
19623
  if (!options.apiKey && !options.bearerToken) {
19624
19624
  throw new Error("You must provide an API key or a bearer token");
19625
19625
  }
@@ -19636,12 +19636,12 @@ var ApiClient = class {
19636
19636
  this.options = {
19637
19637
  ...options,
19638
19638
  fetch: leFetch,
19639
- apiHost: (_a2 = options.apiHost) != null ? _a2 : "https://uniform.app",
19640
- apiKey: (_b2 = options.apiKey) != null ? _b2 : null,
19641
- projectId: (_c2 = options.projectId) != null ? _c2 : null,
19642
- bearerToken: (_d = options.bearerToken) != null ? _d : null,
19643
- limitPolicy: (_e = options.limitPolicy) != null ? _e : nullLimitPolicy,
19644
- bypassCache: (_f = options.bypassCache) != null ? _f : false
19639
+ apiHost: this.ensureApiHost(options.apiHost),
19640
+ apiKey: (_a2 = options.apiKey) != null ? _a2 : null,
19641
+ projectId: (_b2 = options.projectId) != null ? _b2 : null,
19642
+ bearerToken: (_c2 = options.bearerToken) != null ? _c2 : null,
19643
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : nullLimitPolicy,
19644
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
19645
19645
  };
19646
19646
  }
19647
19647
  async apiClient(fetchUri, options) {
@@ -19704,6 +19704,23 @@ var ApiClient = class {
19704
19704
  });
19705
19705
  return url;
19706
19706
  }
19707
+ ensureApiHost(apiHost) {
19708
+ if (!apiHost)
19709
+ return "https://uniform.app";
19710
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("https://"))) {
19711
+ throw new Error('Your apiHost must start with "https://"');
19712
+ }
19713
+ if (apiHost.indexOf("/", 8) > -1) {
19714
+ throw new Error("Your apiHost must not contain a path element after the domain");
19715
+ }
19716
+ if (apiHost.indexOf("?") > -1) {
19717
+ throw new Error("Your apiHost must not contain a query string");
19718
+ }
19719
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
19720
+ apiHost = apiHost.substring(0, apiHost.length - 1);
19721
+ }
19722
+ return apiHost;
19723
+ }
19707
19724
  static getRequestId(response) {
19708
19725
  const apigRequestId = response.headers.get("apigw-requestid");
19709
19726
  if (apigRequestId) {
package/dist/cli/cli.mjs CHANGED
@@ -19616,7 +19616,7 @@ var ApiClientError = class extends Error {
19616
19616
  var ApiClient = class {
19617
19617
  constructor(options) {
19618
19618
  __publicField(this, "options");
19619
- var _a2, _b2, _c2, _d, _e, _f;
19619
+ var _a2, _b2, _c2, _d, _e;
19620
19620
  if (!options.apiKey && !options.bearerToken) {
19621
19621
  throw new Error("You must provide an API key or a bearer token");
19622
19622
  }
@@ -19633,12 +19633,12 @@ var ApiClient = class {
19633
19633
  this.options = {
19634
19634
  ...options,
19635
19635
  fetch: leFetch,
19636
- apiHost: (_a2 = options.apiHost) != null ? _a2 : "https://uniform.app",
19637
- apiKey: (_b2 = options.apiKey) != null ? _b2 : null,
19638
- projectId: (_c2 = options.projectId) != null ? _c2 : null,
19639
- bearerToken: (_d = options.bearerToken) != null ? _d : null,
19640
- limitPolicy: (_e = options.limitPolicy) != null ? _e : nullLimitPolicy,
19641
- bypassCache: (_f = options.bypassCache) != null ? _f : false
19636
+ apiHost: this.ensureApiHost(options.apiHost),
19637
+ apiKey: (_a2 = options.apiKey) != null ? _a2 : null,
19638
+ projectId: (_b2 = options.projectId) != null ? _b2 : null,
19639
+ bearerToken: (_c2 = options.bearerToken) != null ? _c2 : null,
19640
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : nullLimitPolicy,
19641
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
19642
19642
  };
19643
19643
  }
19644
19644
  async apiClient(fetchUri, options) {
@@ -19701,6 +19701,23 @@ var ApiClient = class {
19701
19701
  });
19702
19702
  return url;
19703
19703
  }
19704
+ ensureApiHost(apiHost) {
19705
+ if (!apiHost)
19706
+ return "https://uniform.app";
19707
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("https://"))) {
19708
+ throw new Error('Your apiHost must start with "https://"');
19709
+ }
19710
+ if (apiHost.indexOf("/", 8) > -1) {
19711
+ throw new Error("Your apiHost must not contain a path element after the domain");
19712
+ }
19713
+ if (apiHost.indexOf("?") > -1) {
19714
+ throw new Error("Your apiHost must not contain a query string");
19715
+ }
19716
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
19717
+ apiHost = apiHost.substring(0, apiHost.length - 1);
19718
+ }
19719
+ return apiHost;
19720
+ }
19704
19721
  static getRequestId(response) {
19705
19722
  const apigRequestId = response.headers.get("apigw-requestid");
19706
19723
  if (apigRequestId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context",
3
- "version": "18.5.0",
3
+ "version": "18.6.0",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -59,7 +59,7 @@
59
59
  "devDependencies": {
60
60
  "@types/js-cookie": "3.0.2",
61
61
  "@types/yargs": "17.0.20",
62
- "@uniformdev/cli": "18.5.0",
62
+ "@uniformdev/cli": "18.6.0",
63
63
  "benny": "3.7.1",
64
64
  "yargs": "17.6.2"
65
65
  },
@@ -76,5 +76,5 @@
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  },
79
- "gitHead": "757923e90bece28162621d867709e08674bdaa05"
79
+ "gitHead": "2e2b4d179180900386f8b3ceb30d4a854a7e22fd"
80
80
  }