@replit/connectors 0.17.0 → 0.19.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 +43 -0
- package/client.d.mts +5 -24
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -24
- package/client.d.ts.map +1 -1
- package/client.js +18 -36
- package/client.js.map +1 -1
- package/client.mjs +18 -36
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/top-level.d.mts +5013 -5044
- package/resources/top-level.d.mts.map +1 -1
- package/resources/top-level.d.ts +5013 -5044
- package/resources/top-level.d.ts.map +1 -1
- package/src/client.ts +26 -86
- package/src/internal/parse.ts +6 -0
- package/src/resources/index.ts +0 -11
- package/src/resources/top-level.ts +6588 -6379
- 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
|
@@ -39,24 +39,17 @@ import {
|
|
|
39
39
|
GetConectorConfigResponse,
|
|
40
40
|
GetConnectionParams,
|
|
41
41
|
GetConnectionResponse,
|
|
42
|
-
GetCurrentUserResponse,
|
|
43
42
|
Integration,
|
|
44
43
|
ListAssignmentsResponse,
|
|
45
44
|
ListConnectionsParams,
|
|
46
45
|
ListConnectionsResponse,
|
|
47
46
|
ListConnectionsResponsesOffsetPagination,
|
|
48
|
-
ListConnectorConfigsParams,
|
|
49
|
-
ListConnectorConfigsResponse,
|
|
50
|
-
ListConnectorConfigsResponsesOffsetPagination,
|
|
51
47
|
ListConnectorsParams,
|
|
52
48
|
ListConnectorsResponse,
|
|
53
49
|
ListConnectorsResponsesOffsetPagination,
|
|
54
50
|
ListConnnectorConfigsParams,
|
|
55
51
|
ListConnnectorConfigsResponse,
|
|
56
52
|
ListConnnectorConfigsResponsesOffsetPagination,
|
|
57
|
-
ListCustomersParams,
|
|
58
|
-
ListCustomersResponse,
|
|
59
|
-
ListCustomersResponsesOffsetPagination,
|
|
60
53
|
ListEventsParams,
|
|
61
54
|
ListEventsResponse,
|
|
62
55
|
ListEventsResponsesOffsetPagination,
|
|
@@ -68,10 +61,6 @@ import {
|
|
|
68
61
|
PreConnectResponse,
|
|
69
62
|
UpsertConnnectorConfigParams,
|
|
70
63
|
UpsertConnnectorConfigResponse,
|
|
71
|
-
UpsertCustomerParams,
|
|
72
|
-
UpsertCustomerResponse,
|
|
73
|
-
UpsertOrganizationParams,
|
|
74
|
-
UpsertOrganizationResponse,
|
|
75
64
|
} from './resources/top-level';
|
|
76
65
|
import { APIPromise } from './core/api-promise';
|
|
77
66
|
import { type Fetch } from './internal/builtin-types';
|
|
@@ -358,13 +347,6 @@ export class Replit {
|
|
|
358
347
|
return this.get(path`/v2/connection/${id}`, { query, ...options });
|
|
359
348
|
}
|
|
360
349
|
|
|
361
|
-
/**
|
|
362
|
-
* Get information about the current authenticated user
|
|
363
|
-
*/
|
|
364
|
-
getCurrentUser(options?: RequestOptions): APIPromise<TopLevelAPI.GetCurrentUserResponse> {
|
|
365
|
-
return this.get('/v1/viewer', options);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
350
|
/**
|
|
369
351
|
* Get the list of assignments for a specific connection
|
|
370
352
|
*/
|
|
@@ -388,23 +370,6 @@ export class Replit {
|
|
|
388
370
|
);
|
|
389
371
|
}
|
|
390
372
|
|
|
391
|
-
/**
|
|
392
|
-
* List Configured Connectors
|
|
393
|
-
*/
|
|
394
|
-
listConnectorConfigs(
|
|
395
|
-
query: TopLevelAPI.ListConnectorConfigsParams | null | undefined = {},
|
|
396
|
-
options?: RequestOptions,
|
|
397
|
-
): Pagination.PagePromise<
|
|
398
|
-
ListConnectorConfigsResponsesOffsetPagination,
|
|
399
|
-
TopLevelAPI.ListConnectorConfigsResponse
|
|
400
|
-
> {
|
|
401
|
-
return this.getAPIList(
|
|
402
|
-
'/v2/connector-config',
|
|
403
|
-
Pagination.OffsetPagination<TopLevelAPI.ListConnectorConfigsResponse>,
|
|
404
|
-
{ query, ...options },
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
373
|
/**
|
|
409
374
|
* List all connectors to understand what integrations are available to configure
|
|
410
375
|
*/
|
|
@@ -435,19 +400,6 @@ export class Replit {
|
|
|
435
400
|
);
|
|
436
401
|
}
|
|
437
402
|
|
|
438
|
-
/**
|
|
439
|
-
* List all customers
|
|
440
|
-
*/
|
|
441
|
-
listCustomers(
|
|
442
|
-
query: TopLevelAPI.ListCustomersParams | null | undefined = {},
|
|
443
|
-
options?: RequestOptions,
|
|
444
|
-
): Pagination.PagePromise<ListCustomersResponsesOffsetPagination, TopLevelAPI.ListCustomersResponse> {
|
|
445
|
-
return this.getAPIList('/v1/customer', Pagination.OffsetPagination<TopLevelAPI.ListCustomersResponse>, {
|
|
446
|
-
query,
|
|
447
|
-
...options,
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
|
|
451
403
|
/**
|
|
452
404
|
* List all events for an organization
|
|
453
405
|
*/
|
|
@@ -490,27 +442,6 @@ export class Replit {
|
|
|
490
442
|
return this.put(path`/v2/connector-config/${id}`, { body, ...options });
|
|
491
443
|
}
|
|
492
444
|
|
|
493
|
-
/**
|
|
494
|
-
* Create or update a customer
|
|
495
|
-
*/
|
|
496
|
-
upsertCustomer(
|
|
497
|
-
body: TopLevelAPI.UpsertCustomerParams,
|
|
498
|
-
options?: RequestOptions,
|
|
499
|
-
): APIPromise<TopLevelAPI.UpsertCustomerResponse> {
|
|
500
|
-
return this.put('/v1/customer', { body, ...options });
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Upsert an organization by ID. Creates if it does not exist.
|
|
505
|
-
*/
|
|
506
|
-
upsertOrganization(
|
|
507
|
-
orgID: string,
|
|
508
|
-
body: TopLevelAPI.UpsertOrganizationParams,
|
|
509
|
-
options?: RequestOptions,
|
|
510
|
-
): APIPromise<TopLevelAPI.UpsertOrganizationResponse> {
|
|
511
|
-
return this.put(path`/v2/organization/${orgID}`, { body, ...options });
|
|
512
|
-
}
|
|
513
|
-
|
|
514
445
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
515
446
|
return this._options.defaultQuery;
|
|
516
447
|
}
|
|
@@ -757,7 +688,7 @@ export class Replit {
|
|
|
757
688
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
758
689
|
|
|
759
690
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
760
|
-
const errJSON = safeJSON(errText);
|
|
691
|
+
const errJSON = safeJSON(errText) as any;
|
|
761
692
|
const errMessage = errJSON ? undefined : errText;
|
|
762
693
|
|
|
763
694
|
loggerFor(this).debug(
|
|
@@ -794,9 +725,14 @@ export class Replit {
|
|
|
794
725
|
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
795
726
|
path: string,
|
|
796
727
|
Page: new (...args: any[]) => PageClass,
|
|
797
|
-
opts?: RequestOptions
|
|
728
|
+
opts?: PromiseOrValue<RequestOptions>,
|
|
798
729
|
): Pagination.PagePromise<PageClass, Item> {
|
|
799
|
-
return this.requestAPIList(
|
|
730
|
+
return this.requestAPIList(
|
|
731
|
+
Page,
|
|
732
|
+
opts && 'then' in opts ?
|
|
733
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
734
|
+
: { method: 'get', path, ...opts },
|
|
735
|
+
);
|
|
800
736
|
}
|
|
801
737
|
|
|
802
738
|
requestAPIList<
|
|
@@ -804,7 +740,7 @@ export class Replit {
|
|
|
804
740
|
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
805
741
|
>(
|
|
806
742
|
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
807
|
-
options: FinalRequestOptions
|
|
743
|
+
options: PromiseOrValue<FinalRequestOptions>,
|
|
808
744
|
): Pagination.PagePromise<PageClass, Item> {
|
|
809
745
|
const request = this.makeRequest(options, null, undefined);
|
|
810
746
|
return new Pagination.PagePromise<PageClass, Item>(this as any as Replit, request, Page);
|
|
@@ -817,9 +753,10 @@ export class Replit {
|
|
|
817
753
|
controller: AbortController,
|
|
818
754
|
): Promise<Response> {
|
|
819
755
|
const { signal, method, ...options } = init || {};
|
|
820
|
-
|
|
756
|
+
const abort = this._makeAbort(controller);
|
|
757
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
821
758
|
|
|
822
|
-
const timeout = setTimeout(
|
|
759
|
+
const timeout = setTimeout(abort, ms);
|
|
823
760
|
|
|
824
761
|
const isReadableBody =
|
|
825
762
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -986,6 +923,12 @@ export class Replit {
|
|
|
986
923
|
return headers.values;
|
|
987
924
|
}
|
|
988
925
|
|
|
926
|
+
private _makeAbort(controller: AbortController) {
|
|
927
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
928
|
+
// would capture all request options, and cause a memory leak.
|
|
929
|
+
return () => controller.abort();
|
|
930
|
+
}
|
|
931
|
+
|
|
989
932
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
990
933
|
bodyHeaders: HeadersLike;
|
|
991
934
|
body: BodyInit | undefined;
|
|
@@ -1018,6 +961,14 @@ export class Replit {
|
|
|
1018
961
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
|
|
1019
962
|
) {
|
|
1020
963
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
|
|
964
|
+
} else if (
|
|
965
|
+
typeof body === 'object' &&
|
|
966
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
|
|
967
|
+
) {
|
|
968
|
+
return {
|
|
969
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
970
|
+
body: this.stringifyQuery(body as Record<string, unknown>),
|
|
971
|
+
};
|
|
1021
972
|
} else {
|
|
1022
973
|
return this.#encoder({ body, headers });
|
|
1023
974
|
}
|
|
@@ -1066,25 +1017,18 @@ export declare namespace Replit {
|
|
|
1066
1017
|
type DeleteConnectorConfigResponse as DeleteConnectorConfigResponse,
|
|
1067
1018
|
type GetConectorConfigResponse as GetConectorConfigResponse,
|
|
1068
1019
|
type GetConnectionResponse as GetConnectionResponse,
|
|
1069
|
-
type GetCurrentUserResponse as GetCurrentUserResponse,
|
|
1070
1020
|
type ListAssignmentsResponse as ListAssignmentsResponse,
|
|
1071
1021
|
type ListConnectionsResponse as ListConnectionsResponse,
|
|
1072
|
-
type ListConnectorConfigsResponse as ListConnectorConfigsResponse,
|
|
1073
1022
|
type ListConnectorsResponse as ListConnectorsResponse,
|
|
1074
1023
|
type ListConnnectorConfigsResponse as ListConnnectorConfigsResponse,
|
|
1075
|
-
type ListCustomersResponse as ListCustomersResponse,
|
|
1076
1024
|
type ListEventsResponse as ListEventsResponse,
|
|
1077
1025
|
type PostConnectResponse as PostConnectResponse,
|
|
1078
1026
|
type PreConfigureConnectorResponse as PreConfigureConnectorResponse,
|
|
1079
1027
|
type PreConnectResponse as PreConnectResponse,
|
|
1080
1028
|
type UpsertConnnectorConfigResponse as UpsertConnnectorConfigResponse,
|
|
1081
|
-
type UpsertCustomerResponse as UpsertCustomerResponse,
|
|
1082
|
-
type UpsertOrganizationResponse as UpsertOrganizationResponse,
|
|
1083
1029
|
type ListConnectionsResponsesOffsetPagination as ListConnectionsResponsesOffsetPagination,
|
|
1084
|
-
type ListConnectorConfigsResponsesOffsetPagination as ListConnectorConfigsResponsesOffsetPagination,
|
|
1085
1030
|
type ListConnectorsResponsesOffsetPagination as ListConnectorsResponsesOffsetPagination,
|
|
1086
1031
|
type ListConnnectorConfigsResponsesOffsetPagination as ListConnnectorConfigsResponsesOffsetPagination,
|
|
1087
|
-
type ListCustomersResponsesOffsetPagination as ListCustomersResponsesOffsetPagination,
|
|
1088
1032
|
type ListEventsResponsesOffsetPagination as ListEventsResponsesOffsetPagination,
|
|
1089
1033
|
type AssignConnectionParams as AssignConnectionParams,
|
|
1090
1034
|
type ConnectorRpcParams as ConnectorRpcParams,
|
|
@@ -1095,16 +1039,12 @@ export declare namespace Replit {
|
|
|
1095
1039
|
type GetConectorConfigParams as GetConectorConfigParams,
|
|
1096
1040
|
type GetConnectionParams as GetConnectionParams,
|
|
1097
1041
|
type ListConnectionsParams as ListConnectionsParams,
|
|
1098
|
-
type ListConnectorConfigsParams as ListConnectorConfigsParams,
|
|
1099
1042
|
type ListConnectorsParams as ListConnectorsParams,
|
|
1100
1043
|
type ListConnnectorConfigsParams as ListConnnectorConfigsParams,
|
|
1101
|
-
type ListCustomersParams as ListCustomersParams,
|
|
1102
1044
|
type ListEventsParams as ListEventsParams,
|
|
1103
1045
|
type PostConnectParams as PostConnectParams,
|
|
1104
1046
|
type PreConfigureConnectorParams as PreConfigureConnectorParams,
|
|
1105
1047
|
type PreConnectParams as PreConnectParams,
|
|
1106
1048
|
type UpsertConnnectorConfigParams as UpsertConnnectorConfigParams,
|
|
1107
|
-
type UpsertCustomerParams as UpsertCustomerParams,
|
|
1108
|
-
type UpsertOrganizationParams as UpsertOrganizationParams,
|
|
1109
1049
|
};
|
|
1110
1050
|
}
|
package/src/internal/parse.ts
CHANGED
|
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Replit, props: APIResponse
|
|
|
29
29
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
30
30
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
31
31
|
if (isJSON) {
|
|
32
|
+
const contentLength = response.headers.get('content-length');
|
|
33
|
+
if (contentLength === '0') {
|
|
34
|
+
// if there is no content we can't do anything
|
|
35
|
+
return undefined as T;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
const json = await response.json();
|
|
33
39
|
return json as T;
|
|
34
40
|
}
|
package/src/resources/index.ts
CHANGED
|
@@ -14,20 +14,15 @@ export {
|
|
|
14
14
|
type DeleteConnectorConfigResponse,
|
|
15
15
|
type GetConectorConfigResponse,
|
|
16
16
|
type GetConnectionResponse,
|
|
17
|
-
type GetCurrentUserResponse,
|
|
18
17
|
type ListAssignmentsResponse,
|
|
19
18
|
type ListConnectionsResponse,
|
|
20
|
-
type ListConnectorConfigsResponse,
|
|
21
19
|
type ListConnectorsResponse,
|
|
22
20
|
type ListConnnectorConfigsResponse,
|
|
23
|
-
type ListCustomersResponse,
|
|
24
21
|
type ListEventsResponse,
|
|
25
22
|
type PostConnectResponse,
|
|
26
23
|
type PreConfigureConnectorResponse,
|
|
27
24
|
type PreConnectResponse,
|
|
28
25
|
type UpsertConnnectorConfigResponse,
|
|
29
|
-
type UpsertCustomerResponse,
|
|
30
|
-
type UpsertOrganizationResponse,
|
|
31
26
|
type AssignConnectionParams,
|
|
32
27
|
type ConnectorRpcParams,
|
|
33
28
|
type CreateConnectionParams,
|
|
@@ -37,21 +32,15 @@ export {
|
|
|
37
32
|
type GetConectorConfigParams,
|
|
38
33
|
type GetConnectionParams,
|
|
39
34
|
type ListConnectionsParams,
|
|
40
|
-
type ListConnectorConfigsParams,
|
|
41
35
|
type ListConnectorsParams,
|
|
42
36
|
type ListConnnectorConfigsParams,
|
|
43
|
-
type ListCustomersParams,
|
|
44
37
|
type ListEventsParams,
|
|
45
38
|
type PostConnectParams,
|
|
46
39
|
type PreConfigureConnectorParams,
|
|
47
40
|
type PreConnectParams,
|
|
48
41
|
type UpsertConnnectorConfigParams,
|
|
49
|
-
type UpsertCustomerParams,
|
|
50
|
-
type UpsertOrganizationParams,
|
|
51
42
|
type ListConnectionsResponsesOffsetPagination,
|
|
52
|
-
type ListConnectorConfigsResponsesOffsetPagination,
|
|
53
43
|
type ListConnectorsResponsesOffsetPagination,
|
|
54
44
|
type ListConnnectorConfigsResponsesOffsetPagination,
|
|
55
|
-
type ListCustomersResponsesOffsetPagination,
|
|
56
45
|
type ListEventsResponsesOffsetPagination,
|
|
57
46
|
} from './top-level';
|