@unkey/api 2.3.5 → 2.4.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 (103) hide show
  1. package/dist/commonjs/funcs/apisListKeys.d.ts.map +1 -1
  2. package/dist/commonjs/funcs/apisListKeys.js +2 -2
  3. package/dist/commonjs/funcs/apisListKeys.js.map +1 -1
  4. package/dist/commonjs/funcs/identitiesListIdentities.d.ts.map +1 -1
  5. package/dist/commonjs/funcs/identitiesListIdentities.js +1 -2
  6. package/dist/commonjs/funcs/identitiesListIdentities.js.map +1 -1
  7. package/dist/commonjs/funcs/permissionsListPermissions.d.ts.map +1 -1
  8. package/dist/commonjs/funcs/permissionsListPermissions.js +2 -2
  9. package/dist/commonjs/funcs/permissionsListPermissions.js.map +1 -1
  10. package/dist/commonjs/funcs/permissionsListRoles.d.ts.map +1 -1
  11. package/dist/commonjs/funcs/permissionsListRoles.js +2 -2
  12. package/dist/commonjs/funcs/permissionsListRoles.js.map +1 -1
  13. package/dist/commonjs/funcs/ratelimitListOverrides.d.ts.map +1 -1
  14. package/dist/commonjs/funcs/ratelimitListOverrides.js +2 -2
  15. package/dist/commonjs/funcs/ratelimitListOverrides.js.map +1 -1
  16. package/dist/commonjs/hooks/types.d.ts +1 -0
  17. package/dist/commonjs/hooks/types.d.ts.map +1 -1
  18. package/dist/commonjs/lib/config.d.ts +3 -3
  19. package/dist/commonjs/lib/config.js +3 -3
  20. package/dist/commonjs/lib/encodings.js +12 -12
  21. package/dist/commonjs/lib/encodings.js.map +1 -1
  22. package/dist/commonjs/lib/env.d.ts.map +1 -1
  23. package/dist/commonjs/lib/env.js +3 -3
  24. package/dist/commonjs/lib/env.js.map +1 -1
  25. package/dist/commonjs/lib/matchers.js +3 -3
  26. package/dist/commonjs/lib/matchers.js.map +1 -1
  27. package/dist/commonjs/lib/primitives.d.ts +1 -0
  28. package/dist/commonjs/lib/primitives.d.ts.map +1 -1
  29. package/dist/commonjs/lib/primitives.js +18 -0
  30. package/dist/commonjs/lib/primitives.js.map +1 -1
  31. package/dist/commonjs/lib/retries.js +7 -0
  32. package/dist/commonjs/lib/retries.js.map +1 -1
  33. package/dist/commonjs/lib/sdks.d.ts.map +1 -1
  34. package/dist/commonjs/lib/sdks.js +50 -16
  35. package/dist/commonjs/lib/sdks.js.map +1 -1
  36. package/dist/esm/funcs/apisListKeys.d.ts.map +1 -1
  37. package/dist/esm/funcs/apisListKeys.js +2 -2
  38. package/dist/esm/funcs/apisListKeys.js.map +1 -1
  39. package/dist/esm/funcs/identitiesListIdentities.d.ts.map +1 -1
  40. package/dist/esm/funcs/identitiesListIdentities.js +1 -2
  41. package/dist/esm/funcs/identitiesListIdentities.js.map +1 -1
  42. package/dist/esm/funcs/permissionsListPermissions.d.ts.map +1 -1
  43. package/dist/esm/funcs/permissionsListPermissions.js +2 -2
  44. package/dist/esm/funcs/permissionsListPermissions.js.map +1 -1
  45. package/dist/esm/funcs/permissionsListRoles.d.ts.map +1 -1
  46. package/dist/esm/funcs/permissionsListRoles.js +2 -2
  47. package/dist/esm/funcs/permissionsListRoles.js.map +1 -1
  48. package/dist/esm/funcs/ratelimitListOverrides.d.ts.map +1 -1
  49. package/dist/esm/funcs/ratelimitListOverrides.js +2 -2
  50. package/dist/esm/funcs/ratelimitListOverrides.js.map +1 -1
  51. package/dist/esm/hooks/types.d.ts +1 -0
  52. package/dist/esm/hooks/types.d.ts.map +1 -1
  53. package/dist/esm/lib/config.d.ts +3 -3
  54. package/dist/esm/lib/config.js +3 -3
  55. package/dist/esm/lib/encodings.js +1 -1
  56. package/dist/esm/lib/encodings.js.map +1 -1
  57. package/dist/esm/lib/env.d.ts.map +1 -1
  58. package/dist/esm/lib/env.js +3 -3
  59. package/dist/esm/lib/env.js.map +1 -1
  60. package/dist/esm/lib/matchers.js +1 -1
  61. package/dist/esm/lib/matchers.js.map +1 -1
  62. package/dist/esm/lib/primitives.d.ts +1 -0
  63. package/dist/esm/lib/primitives.d.ts.map +1 -1
  64. package/dist/esm/lib/primitives.js +17 -0
  65. package/dist/esm/lib/primitives.js.map +1 -1
  66. package/dist/esm/lib/retries.js +7 -0
  67. package/dist/esm/lib/retries.js.map +1 -1
  68. package/dist/esm/lib/sdks.d.ts.map +1 -1
  69. package/dist/esm/lib/sdks.js +50 -16
  70. package/dist/esm/lib/sdks.js.map +1 -1
  71. package/jsr.json +1 -1
  72. package/package.json +2 -1
  73. package/src/funcs/apisListKeys.ts +2 -2
  74. package/src/funcs/identitiesListIdentities.ts +2 -2
  75. package/src/funcs/permissionsListPermissions.ts +2 -2
  76. package/src/funcs/permissionsListRoles.ts +2 -2
  77. package/src/funcs/ratelimitListOverrides.ts +2 -2
  78. package/src/hooks/types.ts +1 -0
  79. package/src/lib/config.ts +3 -3
  80. package/src/lib/encodings.ts +1 -1
  81. package/src/lib/env.ts +7 -3
  82. package/src/lib/matchers.ts +1 -1
  83. package/src/lib/primitives.ts +16 -0
  84. package/src/lib/retries.ts +8 -0
  85. package/src/lib/sdks.ts +54 -17
  86. package/dist/commonjs/lib/dlv.d.ts +0 -14
  87. package/dist/commonjs/lib/dlv.d.ts.map +0 -1
  88. package/dist/commonjs/lib/dlv.js +0 -49
  89. package/dist/commonjs/lib/dlv.js.map +0 -1
  90. package/dist/commonjs/lib/is-plain-object.d.ts +0 -2
  91. package/dist/commonjs/lib/is-plain-object.d.ts.map +0 -1
  92. package/dist/commonjs/lib/is-plain-object.js +0 -41
  93. package/dist/commonjs/lib/is-plain-object.js.map +0 -1
  94. package/dist/esm/lib/dlv.d.ts +0 -14
  95. package/dist/esm/lib/dlv.d.ts.map +0 -1
  96. package/dist/esm/lib/dlv.js +0 -46
  97. package/dist/esm/lib/dlv.js.map +0 -1
  98. package/dist/esm/lib/is-plain-object.d.ts +0 -2
  99. package/dist/esm/lib/is-plain-object.d.ts.map +0 -1
  100. package/dist/esm/lib/is-plain-object.js +0 -38
  101. package/dist/esm/lib/is-plain-object.js.map +0 -1
  102. package/src/lib/dlv.ts +0 -53
  103. package/src/lib/is-plain-object.ts +0 -43
@@ -148,3 +148,19 @@ export function allRequired<V extends Record<string, unknown>>(
148
148
 
149
149
  return v as ReturnType<typeof allRequired<V>>;
150
150
  }
151
+
152
+ export function isPlainObject(
153
+ value: unknown,
154
+ ): value is Record<string, unknown> {
155
+ if (value === null || typeof value !== "object") return false;
156
+ if (Object.prototype.toString.call(value) !== "[object Object]") return false;
157
+ const proto = Object.getPrototypeOf(value);
158
+ if (proto === null || proto === Object.prototype) return true;
159
+ // cross-realm plain objects (vm contexts, iframes) inherit from a
160
+ // different realm's Object.prototype, which itself has a null prototype
161
+ try {
162
+ return Object.getPrototypeOf(proto) === null;
163
+ } catch {
164
+ return false;
165
+ }
166
+ }
@@ -194,6 +194,14 @@ async function retryBackoff(
194
194
  }
195
195
 
196
196
  function retryIntervalFromResponse(res: Response): number {
197
+ const retryAfterMsVal = res.headers.get("retry-after-ms");
198
+ if (retryAfterMsVal) {
199
+ const parsedMs = Number(retryAfterMsVal);
200
+ if (Number.isFinite(parsedMs) && parsedMs >= 0) {
201
+ return parsedMs;
202
+ }
203
+ }
204
+
197
205
  const retryVal = res.headers.get("retry-after") || "";
198
206
  if (!retryVal) {
199
207
  return 0;
package/src/lib/sdks.ts CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  matchContentType,
25
25
  } from "./http.js";
26
26
  import { Logger } from "./logger.js";
27
+ import { combineSignals } from "./primitives.js";
27
28
  import { retry, RetryConfig } from "./retries.js";
28
29
  import { SecurityState } from "./security.js";
29
30
 
@@ -132,27 +133,55 @@ export class ClientSDK {
132
133
  if (path) {
133
134
  baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
134
135
  reqURL = new URL(path, baseURL);
136
+ if (!reqURL.search && baseURL.search) {
137
+ reqURL.search = baseURL.search;
138
+ }
135
139
  } else {
136
140
  reqURL = baseURL;
137
141
  }
138
142
  reqURL.hash = "";
139
143
 
140
- let finalQuery = query || "";
141
-
142
- const secQuery: string[] = [];
143
- for (const [k, v] of Object.entries(security?.queryParams || {})) {
144
- const q = encodeForm(k, v, { charEncoding: "percent" });
145
- if (typeof q !== "undefined") {
146
- secQuery.push(q);
144
+ // Appends already-encoded query pairs to a query string, replacing any
145
+ // existing pairs with the same key so later sources take precedence.
146
+ const mergeQuery = (current: string, additions: string): string => {
147
+ if (!additions) {
148
+ return current;
147
149
  }
148
- }
149
- if (secQuery.length) {
150
- finalQuery += `&${secQuery.join("&")}`;
151
- }
150
+ const additionKeys = new Set(
151
+ additions
152
+ .split("&")
153
+ .filter((pair) => pair !== "")
154
+ .map((pair) => pair.split("=")[0] ?? ""),
155
+ );
156
+ const kept = current.split("&").filter((pair) => {
157
+ return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
158
+ });
159
+ return [...kept, additions].join("&");
160
+ };
161
+
162
+ const encodeQueryRecord = (record: Record<string, unknown>): string => {
163
+ return Object.entries(record)
164
+ .map(([k, v]) => {
165
+ if (v == null) {
166
+ return undefined;
167
+ }
168
+ const value = v;
169
+ return encodeForm(k, value, {
170
+ explode: Array.isArray(value),
171
+ charEncoding: "percent",
172
+ });
173
+ })
174
+ .filter((pair): pair is string => typeof pair !== "undefined")
175
+ .join("&");
176
+ };
177
+
178
+ const finalQuery = [
179
+ query || "",
180
+ encodeQueryRecord(security?.queryParams || {}),
181
+ ].reduce(mergeQuery, reqURL.search.slice(1));
152
182
 
153
183
  if (finalQuery) {
154
- const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery;
155
- reqURL.search = `?${q}`;
184
+ reqURL.search = `?${finalQuery}`;
156
185
  }
157
186
 
158
187
  const headers = new Headers(opHeaders);
@@ -198,9 +227,8 @@ export class ClientSDK {
198
227
  ...options?.fetchOptions,
199
228
  ...options,
200
229
  };
201
- if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) {
202
- const timeoutSignal = AbortSignal.timeout(conf.timeoutMs);
203
- fetchOptions.signal = timeoutSignal;
230
+ if (!fetchOptions?.signal && conf.timeoutMs != null && conf.timeoutMs > 0) {
231
+ context.timeoutMs = conf.timeoutMs;
204
232
  }
205
233
 
206
234
  if (conf.body instanceof ReadableStream) {
@@ -247,10 +275,19 @@ export class ClientSDK {
247
275
  >
248
276
  > {
249
277
  const { context, isErrorStatusCode } = options;
278
+ const timeoutMs = context.timeoutMs;
250
279
 
251
280
  return retry(
252
281
  async () => {
253
- const req = await this.#hooks.beforeRequest(context, request.clone());
282
+ const cloned = request.clone();
283
+ let attempt = cloned;
284
+ if (timeoutMs != null && timeoutMs > 0) {
285
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
286
+ const combined = combineSignals(cloned.signal, timeoutSignal)
287
+ ?? timeoutSignal;
288
+ attempt = new Request(cloned, { signal: combined });
289
+ }
290
+ const req = await this.#hooks.beforeRequest(context, attempt);
254
291
  await logRequest(this.#logger, req).catch((e) =>
255
292
  this.#logger?.log("Failed to log request:", e)
256
293
  );
@@ -1,14 +0,0 @@
1
- /**
2
- * @param obj The object to walk
3
- * @param key The key path to walk the object with
4
- * @param def A default value to return if the result is undefined
5
- *
6
- * @example
7
- * dlv(obj, "a.b.c.d")
8
- * @example
9
- * dlv(object, ["a", "b", "c", "d"])
10
- * @example
11
- * dlv(object, "foo.bar.baz", "Hello, default value!")
12
- */
13
- export declare function dlv<T = any>(obj: any, key: string | string[], def?: T, p?: number, undef?: never): T | undefined;
14
- //# sourceMappingURL=dlv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dlv.d.ts","sourceRoot":"","sources":["../../../src/lib/dlv.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EACzB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACtB,GAAG,CAAC,EAAE,CAAC,EACP,CAAC,CAAC,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,KAAK,GACZ,CAAC,GAAG,SAAS,CAOf"}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- /*
3
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.dlv = dlv;
7
- /*
8
- MIT License
9
-
10
- Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining a copy of
13
- this software and associated documentation files (the "Software"), to deal in
14
- the Software without restriction, including without limitation the rights to
15
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16
- the Software, and to permit persons to whom the Software is furnished to do so,
17
- subject to the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be included in all
20
- copies or substantial portions of the Software.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- */
29
- /**
30
- * @param obj The object to walk
31
- * @param key The key path to walk the object with
32
- * @param def A default value to return if the result is undefined
33
- *
34
- * @example
35
- * dlv(obj, "a.b.c.d")
36
- * @example
37
- * dlv(object, ["a", "b", "c", "d"])
38
- * @example
39
- * dlv(object, "foo.bar.baz", "Hello, default value!")
40
- */
41
- function dlv(obj, key, def, p, undef) {
42
- key = Array.isArray(key) ? key : key.split(".");
43
- for (p = 0; p < key.length; p++) {
44
- const k = key[p];
45
- obj = k != null && obj ? obj[k] : undef;
46
- }
47
- return obj === undef ? def : obj;
48
- }
49
- //# sourceMappingURL=dlv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dlv.js","sourceRoot":"","sources":["../../../src/lib/dlv.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAqCH,kBAaC;AAhDD;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF;;;;;;;;;;;GAWG;AACH,SAAgB,GAAG,CACjB,GAAQ,EACR,GAAsB,EACtB,GAAO,EACP,CAAU,EACV,KAAa;IAEb,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,GAAG,GAAG,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACnC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function isPlainObject(value: unknown): value is object;
2
- //# sourceMappingURL=is-plain-object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-plain-object.d.ts","sourceRoot":"","sources":["../../../src/lib/is-plain-object.ts"],"names":[],"mappings":"AA6BA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAa7D"}
@@ -1,41 +0,0 @@
1
- "use strict";
2
- /*
3
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isPlainObject = isPlainObject;
7
- /*
8
- MIT License
9
-
10
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining a copy of
13
- this software and associated documentation files (the "Software"), to deal in
14
- the Software without restriction, including without limitation the rights to
15
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16
- the Software, and to permit persons to whom the Software is furnished to do so,
17
- subject to the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be included in all
20
- copies or substantial portions of the Software.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- */
29
- // Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
30
- function isPlainObject(value) {
31
- if (typeof value !== "object" || value === null) {
32
- return false;
33
- }
34
- const prototype = Object.getPrototypeOf(value);
35
- return ((prototype === null ||
36
- prototype === Object.prototype ||
37
- Object.getPrototypeOf(prototype) === null) &&
38
- !(Symbol.toStringTag in value) &&
39
- !(Symbol.iterator in value));
40
- }
41
- //# sourceMappingURL=is-plain-object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-plain-object.js","sourceRoot":"","sources":["../../../src/lib/is-plain-object.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA2BH,sCAaC;AAtCD;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF,iHAAiH;AAEjH,SAAgB,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CACL,CAAC,SAAS,KAAK,IAAI;QACjB,SAAS,KAAK,MAAM,CAAC,SAAS;QAC9B,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;QAC5C,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,CAC5B,CAAC;AACJ,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * @param obj The object to walk
3
- * @param key The key path to walk the object with
4
- * @param def A default value to return if the result is undefined
5
- *
6
- * @example
7
- * dlv(obj, "a.b.c.d")
8
- * @example
9
- * dlv(object, ["a", "b", "c", "d"])
10
- * @example
11
- * dlv(object, "foo.bar.baz", "Hello, default value!")
12
- */
13
- export declare function dlv<T = any>(obj: any, key: string | string[], def?: T, p?: number, undef?: never): T | undefined;
14
- //# sourceMappingURL=dlv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dlv.d.ts","sourceRoot":"","sources":["../../../src/lib/dlv.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EACzB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACtB,GAAG,CAAC,EAAE,CAAC,EACP,CAAC,CAAC,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,KAAK,GACZ,CAAC,GAAG,SAAS,CAOf"}
@@ -1,46 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- /*
5
- MIT License
6
-
7
- Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy of
10
- this software and associated documentation files (the "Software"), to deal in
11
- the Software without restriction, including without limitation the rights to
12
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13
- the Software, and to permit persons to whom the Software is furnished to do so,
14
- subject to the following conditions:
15
-
16
- The above copyright notice and this permission notice shall be included in all
17
- copies or substantial portions of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- */
26
- /**
27
- * @param obj The object to walk
28
- * @param key The key path to walk the object with
29
- * @param def A default value to return if the result is undefined
30
- *
31
- * @example
32
- * dlv(obj, "a.b.c.d")
33
- * @example
34
- * dlv(object, ["a", "b", "c", "d"])
35
- * @example
36
- * dlv(object, "foo.bar.baz", "Hello, default value!")
37
- */
38
- export function dlv(obj, key, def, p, undef) {
39
- key = Array.isArray(key) ? key : key.split(".");
40
- for (p = 0; p < key.length; p++) {
41
- const k = key[p];
42
- obj = k != null && obj ? obj[k] : undef;
43
- }
44
- return obj === undef ? def : obj;
45
- }
46
- //# sourceMappingURL=dlv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dlv.js","sourceRoot":"","sources":["../../../src/lib/dlv.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,GAAG,CACjB,GAAQ,EACR,GAAsB,EACtB,GAAO,EACP,CAAU,EACV,KAAa;IAEb,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,GAAG,GAAG,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACnC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function isPlainObject(value: unknown): value is object;
2
- //# sourceMappingURL=is-plain-object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-plain-object.d.ts","sourceRoot":"","sources":["../../../src/lib/is-plain-object.ts"],"names":[],"mappings":"AA6BA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAa7D"}
@@ -1,38 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- /*
5
- MIT License
6
-
7
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy of
10
- this software and associated documentation files (the "Software"), to deal in
11
- the Software without restriction, including without limitation the rights to
12
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13
- the Software, and to permit persons to whom the Software is furnished to do so,
14
- subject to the following conditions:
15
-
16
- The above copyright notice and this permission notice shall be included in all
17
- copies or substantial portions of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- */
26
- // Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
27
- export function isPlainObject(value) {
28
- if (typeof value !== "object" || value === null) {
29
- return false;
30
- }
31
- const prototype = Object.getPrototypeOf(value);
32
- return ((prototype === null ||
33
- prototype === Object.prototype ||
34
- Object.getPrototypeOf(prototype) === null) &&
35
- !(Symbol.toStringTag in value) &&
36
- !(Symbol.iterator in value));
37
- }
38
- //# sourceMappingURL=is-plain-object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-plain-object.js","sourceRoot":"","sources":["../../../src/lib/is-plain-object.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF,iHAAiH;AAEjH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CACL,CAAC,SAAS,KAAK,IAAI;QACjB,SAAS,KAAK,MAAM,CAAC,SAAS;QAC9B,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;QAC5C,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,CAC5B,CAAC;AACJ,CAAC"}
package/src/lib/dlv.ts DELETED
@@ -1,53 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- /*
6
- MIT License
7
-
8
- Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy of
11
- this software and associated documentation files (the "Software"), to deal in
12
- the Software without restriction, including without limitation the rights to
13
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
- the Software, and to permit persons to whom the Software is furnished to do so,
15
- subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- /**
29
- * @param obj The object to walk
30
- * @param key The key path to walk the object with
31
- * @param def A default value to return if the result is undefined
32
- *
33
- * @example
34
- * dlv(obj, "a.b.c.d")
35
- * @example
36
- * dlv(object, ["a", "b", "c", "d"])
37
- * @example
38
- * dlv(object, "foo.bar.baz", "Hello, default value!")
39
- */
40
- export function dlv<T = any>(
41
- obj: any,
42
- key: string | string[],
43
- def?: T,
44
- p?: number,
45
- undef?: never,
46
- ): T | undefined {
47
- key = Array.isArray(key) ? key : key.split(".");
48
- for (p = 0; p < key.length; p++) {
49
- const k = key[p];
50
- obj = k != null && obj ? obj[k] : undef;
51
- }
52
- return obj === undef ? def : obj;
53
- }
@@ -1,43 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- /*
6
- MIT License
7
-
8
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy of
11
- this software and associated documentation files (the "Software"), to deal in
12
- the Software without restriction, including without limitation the rights to
13
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
- the Software, and to permit persons to whom the Software is furnished to do so,
15
- subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- // Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
29
-
30
- export function isPlainObject(value: unknown): value is object {
31
- if (typeof value !== "object" || value === null) {
32
- return false;
33
- }
34
-
35
- const prototype = Object.getPrototypeOf(value);
36
- return (
37
- (prototype === null ||
38
- prototype === Object.prototype ||
39
- Object.getPrototypeOf(prototype) === null) &&
40
- !(Symbol.toStringTag in value) &&
41
- !(Symbol.iterator in value)
42
- );
43
- }