@unkey/api 2.3.4 → 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.
- package/README.md +4 -2
- package/dist/commonjs/funcs/apisListKeys.d.ts +5 -1
- package/dist/commonjs/funcs/apisListKeys.d.ts.map +1 -1
- package/dist/commonjs/funcs/apisListKeys.js +34 -6
- package/dist/commonjs/funcs/apisListKeys.js.map +1 -1
- package/dist/commonjs/funcs/identitiesListIdentities.d.ts.map +1 -1
- package/dist/commonjs/funcs/identitiesListIdentities.js +1 -2
- package/dist/commonjs/funcs/identitiesListIdentities.js.map +1 -1
- package/dist/commonjs/funcs/permissionsListPermissions.d.ts +5 -1
- package/dist/commonjs/funcs/permissionsListPermissions.d.ts.map +1 -1
- package/dist/commonjs/funcs/permissionsListPermissions.js +34 -6
- package/dist/commonjs/funcs/permissionsListPermissions.js.map +1 -1
- package/dist/commonjs/funcs/permissionsListRoles.d.ts +5 -1
- package/dist/commonjs/funcs/permissionsListRoles.d.ts.map +1 -1
- package/dist/commonjs/funcs/permissionsListRoles.js +34 -6
- package/dist/commonjs/funcs/permissionsListRoles.js.map +1 -1
- package/dist/commonjs/funcs/ratelimitListOverrides.d.ts +5 -1
- package/dist/commonjs/funcs/ratelimitListOverrides.d.ts.map +1 -1
- package/dist/commonjs/funcs/ratelimitListOverrides.js +34 -6
- package/dist/commonjs/funcs/ratelimitListOverrides.js.map +1 -1
- package/dist/commonjs/hooks/types.d.ts +1 -0
- package/dist/commonjs/hooks/types.d.ts.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/lib/encodings.js +12 -12
- package/dist/commonjs/lib/encodings.js.map +1 -1
- package/dist/commonjs/lib/env.d.ts.map +1 -1
- package/dist/commonjs/lib/env.js +3 -3
- package/dist/commonjs/lib/env.js.map +1 -1
- package/dist/commonjs/lib/matchers.js +3 -3
- package/dist/commonjs/lib/matchers.js.map +1 -1
- package/dist/commonjs/lib/primitives.d.ts +1 -0
- package/dist/commonjs/lib/primitives.d.ts.map +1 -1
- package/dist/commonjs/lib/primitives.js +18 -0
- package/dist/commonjs/lib/primitives.js.map +1 -1
- package/dist/commonjs/lib/retries.js +7 -0
- package/dist/commonjs/lib/retries.js.map +1 -1
- package/dist/commonjs/lib/sdks.d.ts.map +1 -1
- package/dist/commonjs/lib/sdks.js +50 -16
- package/dist/commonjs/lib/sdks.js.map +1 -1
- package/dist/commonjs/models/operations/apislistkeys.d.ts +11 -0
- package/dist/commonjs/models/operations/apislistkeys.d.ts.map +1 -0
- package/dist/commonjs/models/operations/apislistkeys.js +56 -0
- package/dist/commonjs/models/operations/apislistkeys.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +4 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +4 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/permissionslistpermissions.d.ts +11 -0
- package/dist/commonjs/models/operations/permissionslistpermissions.d.ts.map +1 -0
- package/dist/commonjs/models/operations/permissionslistpermissions.js +56 -0
- package/dist/commonjs/models/operations/permissionslistpermissions.js.map +1 -0
- package/dist/commonjs/models/operations/permissionslistroles.d.ts +11 -0
- package/dist/commonjs/models/operations/permissionslistroles.d.ts.map +1 -0
- package/dist/commonjs/models/operations/permissionslistroles.js +56 -0
- package/dist/commonjs/models/operations/permissionslistroles.js.map +1 -0
- package/dist/commonjs/models/operations/ratelimitlistoverrides.d.ts +11 -0
- package/dist/commonjs/models/operations/ratelimitlistoverrides.d.ts.map +1 -0
- package/dist/commonjs/models/operations/ratelimitlistoverrides.js +56 -0
- package/dist/commonjs/models/operations/ratelimitlistoverrides.js.map +1 -0
- package/dist/commonjs/sdk/apis.d.ts +5 -1
- package/dist/commonjs/sdk/apis.d.ts.map +1 -1
- package/dist/commonjs/sdk/apis.js +2 -1
- package/dist/commonjs/sdk/apis.js.map +1 -1
- package/dist/commonjs/sdk/permissions.d.ts +8 -2
- package/dist/commonjs/sdk/permissions.d.ts.map +1 -1
- package/dist/commonjs/sdk/permissions.js +3 -2
- package/dist/commonjs/sdk/permissions.js.map +1 -1
- package/dist/commonjs/sdk/ratelimit.d.ts +5 -1
- package/dist/commonjs/sdk/ratelimit.d.ts.map +1 -1
- package/dist/commonjs/sdk/ratelimit.js +2 -1
- package/dist/commonjs/sdk/ratelimit.js.map +1 -1
- package/dist/commonjs/types/async.d.ts.map +1 -1
- package/dist/commonjs/types/async.js +8 -7
- package/dist/commonjs/types/async.js.map +1 -1
- package/dist/esm/funcs/apisListKeys.d.ts +5 -1
- package/dist/esm/funcs/apisListKeys.d.ts.map +1 -1
- package/dist/esm/funcs/apisListKeys.js +34 -6
- package/dist/esm/funcs/apisListKeys.js.map +1 -1
- package/dist/esm/funcs/identitiesListIdentities.d.ts.map +1 -1
- package/dist/esm/funcs/identitiesListIdentities.js +1 -2
- package/dist/esm/funcs/identitiesListIdentities.js.map +1 -1
- package/dist/esm/funcs/permissionsListPermissions.d.ts +5 -1
- package/dist/esm/funcs/permissionsListPermissions.d.ts.map +1 -1
- package/dist/esm/funcs/permissionsListPermissions.js +34 -6
- package/dist/esm/funcs/permissionsListPermissions.js.map +1 -1
- package/dist/esm/funcs/permissionsListRoles.d.ts +5 -1
- package/dist/esm/funcs/permissionsListRoles.d.ts.map +1 -1
- package/dist/esm/funcs/permissionsListRoles.js +34 -6
- package/dist/esm/funcs/permissionsListRoles.js.map +1 -1
- package/dist/esm/funcs/ratelimitListOverrides.d.ts +5 -1
- package/dist/esm/funcs/ratelimitListOverrides.d.ts.map +1 -1
- package/dist/esm/funcs/ratelimitListOverrides.js +34 -6
- package/dist/esm/funcs/ratelimitListOverrides.js.map +1 -1
- package/dist/esm/hooks/types.d.ts +1 -0
- package/dist/esm/hooks/types.d.ts.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/lib/encodings.js +1 -1
- package/dist/esm/lib/encodings.js.map +1 -1
- package/dist/esm/lib/env.d.ts.map +1 -1
- package/dist/esm/lib/env.js +3 -3
- package/dist/esm/lib/env.js.map +1 -1
- package/dist/esm/lib/matchers.js +1 -1
- package/dist/esm/lib/matchers.js.map +1 -1
- package/dist/esm/lib/primitives.d.ts +1 -0
- package/dist/esm/lib/primitives.d.ts.map +1 -1
- package/dist/esm/lib/primitives.js +17 -0
- package/dist/esm/lib/primitives.js.map +1 -1
- package/dist/esm/lib/retries.js +7 -0
- package/dist/esm/lib/retries.js.map +1 -1
- package/dist/esm/lib/sdks.d.ts.map +1 -1
- package/dist/esm/lib/sdks.js +50 -16
- package/dist/esm/lib/sdks.js.map +1 -1
- package/dist/esm/models/operations/apislistkeys.d.ts +11 -0
- package/dist/esm/models/operations/apislistkeys.d.ts.map +1 -0
- package/dist/esm/models/operations/apislistkeys.js +19 -0
- package/dist/esm/models/operations/apislistkeys.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +4 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +4 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/permissionslistpermissions.d.ts +11 -0
- package/dist/esm/models/operations/permissionslistpermissions.d.ts.map +1 -0
- package/dist/esm/models/operations/permissionslistpermissions.js +19 -0
- package/dist/esm/models/operations/permissionslistpermissions.js.map +1 -0
- package/dist/esm/models/operations/permissionslistroles.d.ts +11 -0
- package/dist/esm/models/operations/permissionslistroles.d.ts.map +1 -0
- package/dist/esm/models/operations/permissionslistroles.js +19 -0
- package/dist/esm/models/operations/permissionslistroles.js.map +1 -0
- package/dist/esm/models/operations/ratelimitlistoverrides.d.ts +11 -0
- package/dist/esm/models/operations/ratelimitlistoverrides.d.ts.map +1 -0
- package/dist/esm/models/operations/ratelimitlistoverrides.js +19 -0
- package/dist/esm/models/operations/ratelimitlistoverrides.js.map +1 -0
- package/dist/esm/sdk/apis.d.ts +5 -1
- package/dist/esm/sdk/apis.d.ts.map +1 -1
- package/dist/esm/sdk/apis.js +2 -1
- package/dist/esm/sdk/apis.js.map +1 -1
- package/dist/esm/sdk/permissions.d.ts +8 -2
- package/dist/esm/sdk/permissions.d.ts.map +1 -1
- package/dist/esm/sdk/permissions.js +3 -2
- package/dist/esm/sdk/permissions.js.map +1 -1
- package/dist/esm/sdk/ratelimit.d.ts +5 -1
- package/dist/esm/sdk/ratelimit.d.ts.map +1 -1
- package/dist/esm/sdk/ratelimit.js +2 -1
- package/dist/esm/sdk/ratelimit.js.map +1 -1
- package/dist/esm/types/async.d.ts.map +1 -1
- package/dist/esm/types/async.js +8 -7
- package/dist/esm/types/async.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +2 -1
- package/src/funcs/apisListKeys.ts +110 -40
- package/src/funcs/identitiesListIdentities.ts +2 -2
- package/src/funcs/permissionsListPermissions.ts +107 -41
- package/src/funcs/permissionsListRoles.ts +110 -40
- package/src/funcs/ratelimitListOverrides.ts +110 -40
- package/src/hooks/types.ts +1 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/encodings.ts +1 -1
- package/src/lib/env.ts +7 -3
- package/src/lib/matchers.ts +1 -1
- package/src/lib/primitives.ts +16 -0
- package/src/lib/retries.ts +8 -0
- package/src/lib/sdks.ts +54 -17
- package/src/models/operations/apislistkeys.ts +37 -0
- package/src/models/operations/index.ts +4 -0
- package/src/models/operations/permissionslistpermissions.ts +38 -0
- package/src/models/operations/permissionslistroles.ts +37 -0
- package/src/models/operations/ratelimitlistoverrides.ts +37 -0
- package/src/sdk/apis.ts +6 -2
- package/src/sdk/permissions.ts +13 -4
- package/src/sdk/ratelimit.ts +6 -2
- package/src/types/async.ts +8 -7
- package/dist/commonjs/lib/dlv.d.ts +0 -14
- package/dist/commonjs/lib/dlv.d.ts.map +0 -1
- package/dist/commonjs/lib/dlv.js +0 -49
- package/dist/commonjs/lib/dlv.js.map +0 -1
- package/dist/commonjs/lib/is-plain-object.d.ts +0 -2
- package/dist/commonjs/lib/is-plain-object.d.ts.map +0 -1
- package/dist/commonjs/lib/is-plain-object.js +0 -41
- package/dist/commonjs/lib/is-plain-object.js.map +0 -1
- package/dist/esm/lib/dlv.d.ts +0 -14
- package/dist/esm/lib/dlv.d.ts.map +0 -1
- package/dist/esm/lib/dlv.js +0 -46
- package/dist/esm/lib/dlv.js.map +0 -1
- package/dist/esm/lib/is-plain-object.d.ts +0 -2
- package/dist/esm/lib/is-plain-object.d.ts.map +0 -1
- package/dist/esm/lib/is-plain-object.js +0 -38
- package/dist/esm/lib/is-plain-object.js.map +0 -1
- package/src/lib/dlv.ts +0 -53
- package/src/lib/is-plain-object.ts +0 -43
package/src/lib/matchers.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { APIError } from "../models/errors/apierror.js";
|
|
|
6
6
|
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
7
|
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
|
-
import { isPlainObject } from "./
|
|
9
|
+
import { isPlainObject } from "./primitives.js";
|
|
10
10
|
|
|
11
11
|
export type Encoding =
|
|
12
12
|
| "jsonl"
|
package/src/lib/primitives.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/lib/retries.ts
CHANGED
|
@@ -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
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import * as components from "../components/index.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export type ApisListKeysResponse = {
|
|
13
|
+
result: components.V2ApisListKeysResponseBody;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const ApisListKeysResponse$inboundSchema: z.ZodType<
|
|
18
|
+
ApisListKeysResponse,
|
|
19
|
+
z.ZodTypeDef,
|
|
20
|
+
unknown
|
|
21
|
+
> = z.object({
|
|
22
|
+
Result: components.V2ApisListKeysResponseBody$inboundSchema,
|
|
23
|
+
}).transform((v) => {
|
|
24
|
+
return remap$(v, {
|
|
25
|
+
"Result": "result",
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function apisListKeysResponseFromJSON(
|
|
30
|
+
jsonString: string,
|
|
31
|
+
): SafeParseResult<ApisListKeysResponse, SDKValidationError> {
|
|
32
|
+
return safeParse(
|
|
33
|
+
jsonString,
|
|
34
|
+
(x) => ApisListKeysResponse$inboundSchema.parse(JSON.parse(x)),
|
|
35
|
+
`Failed to parse 'ApisListKeysResponse' from JSON`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
export * from "./apislistkeys.js";
|
|
5
6
|
export * from "./identitieslistidentities.js";
|
|
7
|
+
export * from "./permissionslistpermissions.js";
|
|
8
|
+
export * from "./permissionslistroles.js";
|
|
6
9
|
export * from "./portalcreatesession.js";
|
|
7
10
|
export * from "./portalexchangesession.js";
|
|
11
|
+
export * from "./ratelimitlistoverrides.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import * as components from "../components/index.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export type PermissionsListPermissionsResponse = {
|
|
13
|
+
result: components.V2PermissionsListPermissionsResponseBody;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const PermissionsListPermissionsResponse$inboundSchema: z.ZodType<
|
|
18
|
+
PermissionsListPermissionsResponse,
|
|
19
|
+
z.ZodTypeDef,
|
|
20
|
+
unknown
|
|
21
|
+
> = z.object({
|
|
22
|
+
Result: components.V2PermissionsListPermissionsResponseBody$inboundSchema,
|
|
23
|
+
}).transform((v) => {
|
|
24
|
+
return remap$(v, {
|
|
25
|
+
"Result": "result",
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function permissionsListPermissionsResponseFromJSON(
|
|
30
|
+
jsonString: string,
|
|
31
|
+
): SafeParseResult<PermissionsListPermissionsResponse, SDKValidationError> {
|
|
32
|
+
return safeParse(
|
|
33
|
+
jsonString,
|
|
34
|
+
(x) =>
|
|
35
|
+
PermissionsListPermissionsResponse$inboundSchema.parse(JSON.parse(x)),
|
|
36
|
+
`Failed to parse 'PermissionsListPermissionsResponse' from JSON`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import * as components from "../components/index.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export type PermissionsListRolesResponse = {
|
|
13
|
+
result: components.V2PermissionsListRolesResponseBody;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const PermissionsListRolesResponse$inboundSchema: z.ZodType<
|
|
18
|
+
PermissionsListRolesResponse,
|
|
19
|
+
z.ZodTypeDef,
|
|
20
|
+
unknown
|
|
21
|
+
> = z.object({
|
|
22
|
+
Result: components.V2PermissionsListRolesResponseBody$inboundSchema,
|
|
23
|
+
}).transform((v) => {
|
|
24
|
+
return remap$(v, {
|
|
25
|
+
"Result": "result",
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function permissionsListRolesResponseFromJSON(
|
|
30
|
+
jsonString: string,
|
|
31
|
+
): SafeParseResult<PermissionsListRolesResponse, SDKValidationError> {
|
|
32
|
+
return safeParse(
|
|
33
|
+
jsonString,
|
|
34
|
+
(x) => PermissionsListRolesResponse$inboundSchema.parse(JSON.parse(x)),
|
|
35
|
+
`Failed to parse 'PermissionsListRolesResponse' from JSON`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import * as components from "../components/index.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export type RatelimitListOverridesResponse = {
|
|
13
|
+
result: components.V2RatelimitListOverridesResponseBody;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const RatelimitListOverridesResponse$inboundSchema: z.ZodType<
|
|
18
|
+
RatelimitListOverridesResponse,
|
|
19
|
+
z.ZodTypeDef,
|
|
20
|
+
unknown
|
|
21
|
+
> = z.object({
|
|
22
|
+
Result: components.V2RatelimitListOverridesResponseBody$inboundSchema,
|
|
23
|
+
}).transform((v) => {
|
|
24
|
+
return remap$(v, {
|
|
25
|
+
"Result": "result",
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function ratelimitListOverridesResponseFromJSON(
|
|
30
|
+
jsonString: string,
|
|
31
|
+
): SafeParseResult<RatelimitListOverridesResponse, SDKValidationError> {
|
|
32
|
+
return safeParse(
|
|
33
|
+
jsonString,
|
|
34
|
+
(x) => RatelimitListOverridesResponse$inboundSchema.parse(JSON.parse(x)),
|
|
35
|
+
`Failed to parse 'RatelimitListOverridesResponse' from JSON`,
|
|
36
|
+
);
|
|
37
|
+
}
|
package/src/sdk/apis.ts
CHANGED
|
@@ -8,7 +8,9 @@ import { apisGetApi } from "../funcs/apisGetApi.js";
|
|
|
8
8
|
import { apisListKeys } from "../funcs/apisListKeys.js";
|
|
9
9
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
10
10
|
import * as components from "../models/components/index.js";
|
|
11
|
+
import * as operations from "../models/operations/index.js";
|
|
11
12
|
import { unwrapAsync } from "../types/fp.js";
|
|
13
|
+
import { PageIterator, unwrapResultIterator } from "../types/operations.js";
|
|
12
14
|
|
|
13
15
|
export class Apis extends ClientSDK {
|
|
14
16
|
/**
|
|
@@ -116,8 +118,10 @@ export class Apis extends ClientSDK {
|
|
|
116
118
|
async listKeys(
|
|
117
119
|
request: components.V2ApisListKeysRequestBody,
|
|
118
120
|
options?: RequestOptions,
|
|
119
|
-
): Promise<
|
|
120
|
-
|
|
121
|
+
): Promise<
|
|
122
|
+
PageIterator<operations.ApisListKeysResponse, { cursor: string }>
|
|
123
|
+
> {
|
|
124
|
+
return unwrapResultIterator(apisListKeys(
|
|
121
125
|
this,
|
|
122
126
|
request,
|
|
123
127
|
options,
|
package/src/sdk/permissions.ts
CHANGED
|
@@ -12,7 +12,9 @@ import { permissionsListPermissions } from "../funcs/permissionsListPermissions.
|
|
|
12
12
|
import { permissionsListRoles } from "../funcs/permissionsListRoles.js";
|
|
13
13
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
14
14
|
import * as components from "../models/components/index.js";
|
|
15
|
+
import * as operations from "../models/operations/index.js";
|
|
15
16
|
import { unwrapAsync } from "../types/fp.js";
|
|
17
|
+
import { PageIterator, unwrapResultIterator } from "../types/operations.js";
|
|
16
18
|
|
|
17
19
|
export class Permissions extends ClientSDK {
|
|
18
20
|
/**
|
|
@@ -172,8 +174,13 @@ export class Permissions extends ClientSDK {
|
|
|
172
174
|
async listPermissions(
|
|
173
175
|
request: components.V2PermissionsListPermissionsRequestBody,
|
|
174
176
|
options?: RequestOptions,
|
|
175
|
-
): Promise<
|
|
176
|
-
|
|
177
|
+
): Promise<
|
|
178
|
+
PageIterator<
|
|
179
|
+
operations.PermissionsListPermissionsResponse,
|
|
180
|
+
{ cursor: string }
|
|
181
|
+
>
|
|
182
|
+
> {
|
|
183
|
+
return unwrapResultIterator(permissionsListPermissions(
|
|
177
184
|
this,
|
|
178
185
|
request,
|
|
179
186
|
options,
|
|
@@ -195,8 +202,10 @@ export class Permissions extends ClientSDK {
|
|
|
195
202
|
async listRoles(
|
|
196
203
|
request: components.V2PermissionsListRolesRequestBody,
|
|
197
204
|
options?: RequestOptions,
|
|
198
|
-
): Promise<
|
|
199
|
-
|
|
205
|
+
): Promise<
|
|
206
|
+
PageIterator<operations.PermissionsListRolesResponse, { cursor: string }>
|
|
207
|
+
> {
|
|
208
|
+
return unwrapResultIterator(permissionsListRoles(
|
|
200
209
|
this,
|
|
201
210
|
request,
|
|
202
211
|
options,
|
package/src/sdk/ratelimit.ts
CHANGED
|
@@ -10,7 +10,9 @@ import { ratelimitMultiLimit } from "../funcs/ratelimitMultiLimit.js";
|
|
|
10
10
|
import { ratelimitSetOverride } from "../funcs/ratelimitSetOverride.js";
|
|
11
11
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
12
12
|
import * as components from "../models/components/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
13
14
|
import { unwrapAsync } from "../types/fp.js";
|
|
15
|
+
import { PageIterator, unwrapResultIterator } from "../types/operations.js";
|
|
14
16
|
|
|
15
17
|
export class Ratelimit extends ClientSDK {
|
|
16
18
|
/**
|
|
@@ -101,8 +103,10 @@ export class Ratelimit extends ClientSDK {
|
|
|
101
103
|
async listOverrides(
|
|
102
104
|
request: components.V2RatelimitListOverridesRequestBody,
|
|
103
105
|
options?: RequestOptions,
|
|
104
|
-
): Promise<
|
|
105
|
-
|
|
106
|
+
): Promise<
|
|
107
|
+
PageIterator<operations.RatelimitListOverridesResponse, { cursor: string }>
|
|
108
|
+
> {
|
|
109
|
+
return unwrapResultIterator(ratelimitListOverrides(
|
|
106
110
|
this,
|
|
107
111
|
request,
|
|
108
112
|
options,
|
package/src/types/async.ts
CHANGED
|
@@ -21,16 +21,17 @@ export type APICall =
|
|
|
21
21
|
|
|
22
22
|
export class APIPromise<T> implements Promise<T> {
|
|
23
23
|
readonly #promise: Promise<[T, APICall]>;
|
|
24
|
-
|
|
24
|
+
#unwrapped: Promise<T> | null;
|
|
25
25
|
|
|
26
26
|
readonly [Symbol.toStringTag] = "APIPromise";
|
|
27
27
|
|
|
28
28
|
constructor(p: [T, APICall] | Promise<[T, APICall]>) {
|
|
29
29
|
this.#promise = p instanceof Promise ? p : Promise.resolve(p);
|
|
30
|
-
this.#unwrapped =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
this.#unwrapped = p instanceof Promise ? null : Promise.resolve(p[0]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#getUnwrapped(): Promise<T> {
|
|
34
|
+
return (this.#unwrapped ??= this.#promise.then(([value]) => value));
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
then<TResult1 = T, TResult2 = never>(
|
|
@@ -55,11 +56,11 @@ export class APIPromise<T> implements Promise<T> {
|
|
|
55
56
|
| null
|
|
56
57
|
| undefined,
|
|
57
58
|
): Promise<T | TResult> {
|
|
58
|
-
return this.#
|
|
59
|
+
return this.#getUnwrapped().catch(onrejected);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
finally(onfinally?: (() => void) | null | undefined): Promise<T> {
|
|
62
|
-
return this.#
|
|
63
|
+
return this.#getUnwrapped().finally(onfinally);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
$inspect(): Promise<[T, APICall]> {
|
|
@@ -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"}
|
package/dist/commonjs/lib/dlv.js
DELETED
|
@@ -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 +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"}
|
package/dist/esm/lib/dlv.d.ts
DELETED
|
@@ -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"}
|
package/dist/esm/lib/dlv.js
DELETED
|
@@ -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
|
package/dist/esm/lib/dlv.js.map
DELETED
|
@@ -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 +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"}
|