@limrun/api 0.20.2 → 0.21.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/CHANGELOG.md +30 -0
- package/client.d.mts +1 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -1
- package/client.d.ts.map +1 -1
- package/client.js +15 -17
- package/client.js.map +1 -1
- package/client.mjs +15 -17
- package/client.mjs.map +1 -1
- package/folder-sync.d.mts +1 -1
- package/folder-sync.d.mts.map +1 -1
- package/folder-sync.d.ts +1 -1
- package/folder-sync.d.ts.map +1 -1
- package/instance-client.d.mts +109 -0
- package/instance-client.d.mts.map +1 -1
- package/instance-client.d.ts +109 -0
- package/instance-client.d.ts.map +1 -1
- package/instance-client.js +262 -69
- package/instance-client.js.map +1 -1
- package/instance-client.mjs +262 -69
- package/instance-client.mjs.map +1 -1
- package/internal/utils/query.d.mts +5 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +5 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +23 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +20 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/ios-client.d.mts +12 -4
- package/ios-client.d.mts.map +1 -1
- package/ios-client.d.ts +12 -4
- package/ios-client.d.ts.map +1 -1
- package/ios-client.js +7 -2
- package/ios-client.js.map +1 -1
- package/ios-client.mjs +7 -2
- package/ios-client.mjs.map +1 -1
- package/package.json +12 -1
- package/resources/android-instances.d.mts +1 -0
- package/resources/android-instances.d.mts.map +1 -1
- package/resources/android-instances.d.ts +1 -0
- package/resources/android-instances.d.ts.map +1 -1
- package/resources/ios-instances.d.mts +1 -1
- package/resources/ios-instances.d.mts.map +1 -1
- package/resources/ios-instances.d.ts +1 -1
- package/resources/ios-instances.d.ts.map +1 -1
- package/src/client.ts +18 -21
- package/src/folder-sync.ts +2 -2
- package/src/instance-client.ts +516 -96
- package/src/internal/utils/query.ts +23 -0
- package/src/internal/utils.ts +1 -0
- package/src/ios-client.ts +25 -7
- package/src/resources/android-instances.ts +2 -0
- package/src/resources/ios-instances.ts +1 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/client.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
+
import { stringifyQuery } from './internal/utils/query';
|
|
14
15
|
import { VERSION } from './version';
|
|
15
16
|
import * as Errors from './core/error';
|
|
16
17
|
import * as Pagination from './core/pagination';
|
|
@@ -242,21 +243,8 @@ export class Limrun {
|
|
|
242
243
|
/**
|
|
243
244
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
244
245
|
*/
|
|
245
|
-
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
246
|
-
return
|
|
247
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
248
|
-
.map(([key, value]) => {
|
|
249
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
250
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
251
|
-
}
|
|
252
|
-
if (value === null) {
|
|
253
|
-
return `${encodeURIComponent(key)}=`;
|
|
254
|
-
}
|
|
255
|
-
throw new Errors.LimrunError(
|
|
256
|
-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
257
|
-
);
|
|
258
|
-
})
|
|
259
|
-
.join('&');
|
|
246
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string {
|
|
247
|
+
return stringifyQuery(query);
|
|
260
248
|
}
|
|
261
249
|
|
|
262
250
|
private getUserAgent(): string {
|
|
@@ -288,12 +276,13 @@ export class Limrun {
|
|
|
288
276
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
289
277
|
|
|
290
278
|
const defaultQuery = this.defaultQuery();
|
|
291
|
-
|
|
292
|
-
|
|
279
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
280
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
281
|
+
query = { ...pathQuery, ...defaultQuery, ...query };
|
|
293
282
|
}
|
|
294
283
|
|
|
295
284
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
296
|
-
url.search = this.stringifyQuery(query
|
|
285
|
+
url.search = this.stringifyQuery(query);
|
|
297
286
|
}
|
|
298
287
|
|
|
299
288
|
return url.toString();
|
|
@@ -622,9 +611,9 @@ export class Limrun {
|
|
|
622
611
|
}
|
|
623
612
|
}
|
|
624
613
|
|
|
625
|
-
// If the API asks us to wait a certain amount of time
|
|
626
|
-
//
|
|
627
|
-
if (
|
|
614
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
615
|
+
// says, but otherwise calculate a default
|
|
616
|
+
if (timeoutMillis === undefined) {
|
|
628
617
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
629
618
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
630
619
|
}
|
|
@@ -750,6 +739,14 @@ export class Limrun {
|
|
|
750
739
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
|
|
751
740
|
) {
|
|
752
741
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
|
|
742
|
+
} else if (
|
|
743
|
+
typeof body === 'object' &&
|
|
744
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
|
|
745
|
+
) {
|
|
746
|
+
return {
|
|
747
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
748
|
+
body: this.stringifyQuery(body),
|
|
749
|
+
};
|
|
753
750
|
} else {
|
|
754
751
|
return this.#encoder({ body, headers });
|
|
755
752
|
}
|
package/src/folder-sync.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type FolderSyncOptions = {
|
|
|
25
25
|
*/
|
|
26
26
|
basisCacheDir?: string;
|
|
27
27
|
install?: boolean;
|
|
28
|
-
launchMode?: 'ForegroundIfRunning' | 'RelaunchIfRunning'
|
|
28
|
+
launchMode?: 'ForegroundIfRunning' | 'RelaunchIfRunning';
|
|
29
29
|
/** If true, watch the folder and re-sync on any changes (debounced, single-flight). */
|
|
30
30
|
watch?: boolean;
|
|
31
31
|
/** Max patch size (bytes) to send as delta before falling back to full upload. */
|
|
@@ -72,7 +72,7 @@ type FolderSyncHttpMeta = {
|
|
|
72
72
|
id: string;
|
|
73
73
|
rootName: string;
|
|
74
74
|
install?: boolean;
|
|
75
|
-
launchMode?: 'ForegroundIfRunning' | 'RelaunchIfRunning'
|
|
75
|
+
launchMode?: 'ForegroundIfRunning' | 'RelaunchIfRunning';
|
|
76
76
|
files: { path: string; size: number; sha256: string; mode: number }[];
|
|
77
77
|
payloads: FolderSyncHttpPayload[];
|
|
78
78
|
};
|