@postpeer/node 0.5.0 → 0.7.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 +48 -0
- package/api-promise.d.mts +1 -0
- package/api-promise.d.mts.map +1 -1
- package/api-promise.d.ts +1 -0
- package/api-promise.d.ts.map +1 -1
- package/api-promise.js.map +1 -1
- package/api-promise.mjs +1 -0
- package/api-promise.mjs.map +1 -1
- package/client.d.mts +5 -5
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -5
- package/client.d.ts.map +1 -1
- package/client.js +75 -19
- package/client.js.map +1 -1
- package/client.mjs +77 -21
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts.map +1 -1
- package/core/error.js +2 -2
- package/core/error.js.map +1 -1
- package/core/error.mjs +2 -2
- package/core/error.mjs.map +1 -1
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts.map +1 -1
- package/core/uploads.d.mts.map +1 -1
- package/core/uploads.d.ts.map +1 -1
- package/core/uploads.mjs.map +1 -1
- package/error.d.mts +1 -0
- package/error.d.mts.map +1 -1
- package/error.d.ts +1 -0
- package/error.d.ts.map +1 -1
- package/error.js.map +1 -1
- package/error.mjs +1 -0
- package/error.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/internal/builtin-types.d.mts +5 -5
- package/internal/builtin-types.d.mts.map +1 -1
- package/internal/builtin-types.d.ts +5 -5
- package/internal/builtin-types.d.ts.map +1 -1
- package/internal/detect-platform.d.mts.map +1 -1
- package/internal/detect-platform.d.ts.map +1 -1
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/errors.js +6 -5
- package/internal/errors.js.map +1 -1
- package/internal/errors.mjs +6 -5
- package/internal/errors.mjs.map +1 -1
- package/internal/headers.js +2 -2
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +2 -2
- package/internal/headers.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +7 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +7 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/qs/formats.d.mts.map +1 -1
- package/internal/qs/formats.d.ts.map +1 -1
- package/internal/qs/index.d.mts +2 -2
- package/internal/qs/index.d.mts.map +1 -1
- package/internal/qs/index.d.ts +2 -2
- package/internal/qs/index.d.ts.map +1 -1
- package/internal/qs/index.mjs.map +1 -1
- package/internal/qs/stringify.d.mts.map +1 -1
- package/internal/qs/stringify.d.ts.map +1 -1
- package/internal/qs/stringify.mjs.map +1 -1
- package/internal/qs/utils.d.mts.map +1 -1
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +1 -2
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs +1 -2
- package/internal/qs/utils.mjs.map +1 -1
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/shim-types.d.mts.map +1 -1
- package/internal/shim-types.d.ts.map +1 -1
- package/internal/shims.d.mts +6 -0
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +6 -0
- package/internal/shims.d.ts.map +1 -1
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/to-file.d.mts.map +1 -1
- package/internal/to-file.d.ts.map +1 -1
- package/internal/to-file.js.map +1 -1
- package/internal/to-file.mjs.map +1 -1
- package/internal/types.d.mts +17 -11
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +17 -11
- package/internal/types.d.ts.map +1 -1
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +11 -2
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +11 -2
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/query.js.map +1 -1
- package/internal/utils/query.mjs.map +1 -1
- package/internal/utils/uuid.d.mts.map +1 -1
- package/internal/utils/uuid.d.ts.map +1 -1
- package/internal/utils/uuid.js +2 -4
- package/internal/utils/uuid.js.map +1 -1
- package/internal/utils/uuid.mjs +2 -4
- package/internal/utils/uuid.mjs.map +1 -1
- package/internal/utils/values.mjs.map +1 -1
- package/internal/utils.d.mts.map +1 -1
- package/internal/utils.d.ts.map +1 -1
- package/internal/utils.mjs.map +1 -1
- package/package.json +1 -1
- package/resource.d.mts +1 -0
- package/resource.d.mts.map +1 -1
- package/resource.d.ts +1 -0
- package/resource.d.ts.map +1 -1
- package/resource.js.map +1 -1
- package/resource.mjs +1 -0
- package/resource.mjs.map +1 -1
- package/resources/connect/connect.d.mts +9 -4
- package/resources/connect/connect.d.mts.map +1 -1
- package/resources/connect/connect.d.ts +9 -4
- package/resources/connect/connect.d.ts.map +1 -1
- package/resources/connect/connect.js.map +1 -1
- package/resources/connect/connect.mjs +1 -1
- package/resources/connect/connect.mjs.map +1 -1
- package/resources/connect/index.d.mts +1 -1
- package/resources/connect/index.d.mts.map +1 -1
- package/resources/connect/index.d.ts +1 -1
- package/resources/connect/index.d.ts.map +1 -1
- package/resources/connect/index.js +0 -2
- package/resources/connect/index.js.map +1 -1
- package/resources/connect/index.mjs +1 -3
- package/resources/connect/index.mjs.map +1 -1
- package/resources/connect/integrations.d.mts +35 -4
- package/resources/connect/integrations.d.mts.map +1 -1
- package/resources/connect/integrations.d.ts +35 -4
- package/resources/connect/integrations.d.ts.map +1 -1
- package/resources/connect/integrations.js +3 -3
- package/resources/connect/integrations.js.map +1 -1
- package/resources/connect/integrations.mjs +3 -3
- package/resources/connect/integrations.mjs.map +1 -1
- package/resources/connect.d.mts.map +1 -1
- package/resources/connect.d.ts.map +1 -1
- package/resources/connect.mjs.map +1 -1
- package/resources/health.d.mts +1 -1
- package/resources/health.d.mts.map +1 -1
- package/resources/health.d.ts +1 -1
- package/resources/health.d.ts.map +1 -1
- package/resources/health.mjs.map +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/index.js +0 -5
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -6
- package/resources/index.mjs.map +1 -1
- package/resources/media.d.mts.map +1 -1
- package/resources/media.d.ts.map +1 -1
- package/resources/media.mjs.map +1 -1
- package/resources/platforms.d.mts +1 -1
- package/resources/platforms.d.mts.map +1 -1
- package/resources/platforms.d.ts +1 -1
- package/resources/platforms.d.ts.map +1 -1
- package/resources/platforms.mjs.map +1 -1
- package/resources/posts/index.d.mts +2 -2
- package/resources/posts/index.d.mts.map +1 -1
- package/resources/posts/index.d.ts +2 -2
- package/resources/posts/index.d.ts.map +1 -1
- package/resources/posts/index.js +0 -2
- package/resources/posts/index.js.map +1 -1
- package/resources/posts/index.mjs +2 -4
- package/resources/posts/index.mjs.map +1 -1
- package/resources/posts/posts.d.mts +36 -8
- package/resources/posts/posts.d.mts.map +1 -1
- package/resources/posts/posts.d.ts +36 -8
- package/resources/posts/posts.d.ts.map +1 -1
- package/resources/posts/posts.js.map +1 -1
- package/resources/posts/posts.mjs +1 -1
- package/resources/posts/posts.mjs.map +1 -1
- package/resources/posts/scheduled.d.mts +20 -4
- package/resources/posts/scheduled.d.mts.map +1 -1
- package/resources/posts/scheduled.d.ts +20 -4
- package/resources/posts/scheduled.d.ts.map +1 -1
- package/resources/posts/scheduled.js +4 -3
- package/resources/posts/scheduled.js.map +1 -1
- package/resources/posts/scheduled.mjs +4 -3
- package/resources/posts/scheduled.mjs.map +1 -1
- package/resources/posts.d.mts.map +1 -1
- package/resources/posts.d.ts.map +1 -1
- package/resources/posts.mjs.map +1 -1
- package/resources.d.mts.map +1 -1
- package/resources.d.ts.map +1 -1
- package/resources.mjs.map +1 -1
- package/src/api-promise.ts +1 -1
- package/src/client.ts +180 -79
- package/src/core/api-promise.ts +7 -2
- package/src/core/error.ts +22 -24
- package/src/error.ts +1 -1
- package/src/index.ts +15 -1
- package/src/internal/builtin-types.ts +14 -9
- package/src/internal/detect-platform.ts +5 -1
- package/src/internal/errors.ts +7 -7
- package/src/internal/headers.ts +2 -2
- package/src/internal/parse.ts +10 -2
- package/src/internal/qs/utils.ts +1 -4
- package/src/internal/request-options.ts +1 -5
- package/src/internal/shim-types.ts +2 -2
- package/src/internal/shims.ts +3 -1
- package/src/internal/to-file.ts +7 -7
- package/src/internal/types.ts +20 -16
- package/src/internal/utils/log.ts +32 -8
- package/src/internal/utils/query.ts +1 -1
- package/src/internal/utils/uuid.ts +3 -5
- package/src/resource.ts +1 -1
- package/src/resources/connect/connect.ts +29 -4
- package/src/resources/connect/index.ts +7 -2
- package/src/resources/connect/integrations.ts +66 -5
- package/src/resources/health.ts +1 -1
- package/src/resources/index.ts +14 -5
- package/src/resources/media.ts +1 -4
- package/src/resources/platforms.ts +11 -4
- package/src/resources/posts/index.ts +18 -2
- package/src/resources/posts/posts.ts +102 -10
- package/src/resources/posts/scheduled.ts +43 -6
- package/src/uploads.ts +1 -1
- package/src/version.ts +1 -1
- package/uploads.d.mts +1 -0
- package/uploads.d.mts.map +1 -1
- package/uploads.d.ts +1 -0
- package/uploads.d.ts.map +1 -1
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -0
- package/uploads.mjs.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/src/index.ts
CHANGED
|
@@ -5,4 +5,18 @@ export { Postpeer as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { Postpeer, type ClientOptions } from './client';
|
|
8
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
PostpeerError,
|
|
10
|
+
APIError,
|
|
11
|
+
APIConnectionError,
|
|
12
|
+
APIConnectionTimeoutError,
|
|
13
|
+
APIUserAbortError,
|
|
14
|
+
NotFoundError,
|
|
15
|
+
ConflictError,
|
|
16
|
+
RateLimitError,
|
|
17
|
+
BadRequestError,
|
|
18
|
+
AuthenticationError,
|
|
19
|
+
InternalServerError,
|
|
20
|
+
PermissionDeniedError,
|
|
21
|
+
UnprocessableEntityError,
|
|
22
|
+
} from './core/error';
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
export type Fetch = (
|
|
4
|
-
input: string | URL | Request,
|
|
5
|
-
init?: RequestInit,
|
|
6
|
-
) => Promise<Response>
|
|
3
|
+
export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* An alias to the builtin `RequestInit` type so we can
|
|
10
7
|
* easily alias it in import statements if there are name clashes.
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
*
|
|
9
|
+
* https://developer.mozilla.org/docs/Web/API/RequestInit
|
|
13
10
|
*/
|
|
14
11
|
type _RequestInit = RequestInit;
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* An alias to the builtin `Response` type so we can
|
|
18
15
|
* easily alias it in import statements if there are name clashes.
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
*
|
|
17
|
+
* https://developer.mozilla.org/docs/Web/API/Response
|
|
21
18
|
*/
|
|
22
19
|
type _Response = Response;
|
|
23
20
|
|
|
@@ -54,7 +51,15 @@ type _Array<T> = Array<T>;
|
|
|
54
51
|
*/
|
|
55
52
|
type _Record<K extends keyof any, T> = Record<K, T>;
|
|
56
53
|
|
|
57
|
-
export type {
|
|
54
|
+
export type {
|
|
55
|
+
_Array as Array,
|
|
56
|
+
_BodyInit as BodyInit,
|
|
57
|
+
_HeadersInit as HeadersInit,
|
|
58
|
+
_Record as Record,
|
|
59
|
+
_RequestInfo as RequestInfo,
|
|
60
|
+
_RequestInit as RequestInit,
|
|
61
|
+
_Response as Response,
|
|
62
|
+
};
|
|
58
63
|
|
|
59
64
|
/**
|
|
60
65
|
* A copy of the builtin `EndingType` type as it isn't fully supported in certain
|
|
@@ -25,7 +25,11 @@ function getDetectedPlatform(): DetectedPlatform {
|
|
|
25
25
|
if (typeof EdgeRuntime !== 'undefined') {
|
|
26
26
|
return 'edge';
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
28
|
+
if (
|
|
29
|
+
Object.prototype.toString.call(
|
|
30
|
+
typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0,
|
|
31
|
+
) === '[object process]'
|
|
32
|
+
) {
|
|
29
33
|
return 'node';
|
|
30
34
|
}
|
|
31
35
|
return 'unknown';
|
package/src/internal/errors.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
export function isAbortError(err: unknown) {
|
|
4
4
|
return (
|
|
5
|
-
typeof err === 'object' &&
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
typeof err === 'object' &&
|
|
6
|
+
err !== null &&
|
|
7
|
+
// Spec-compliant fetch implementations
|
|
8
|
+
(('name' in err && (err as any).name === 'AbortError') ||
|
|
8
9
|
// Expo fetch
|
|
9
|
-
('message' in err && String((err as any).message).includes('FetchRequestCanceledException'))
|
|
10
|
-
)
|
|
10
|
+
('message' in err && String((err as any).message).includes('FetchRequestCanceledException')))
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -24,10 +24,10 @@ export const castToError = (err: any): Error => {
|
|
|
24
24
|
if (err.name) error.name = err.name;
|
|
25
25
|
return error;
|
|
26
26
|
}
|
|
27
|
-
} catch {
|
|
27
|
+
} catch {}
|
|
28
28
|
try {
|
|
29
29
|
return new Error(JSON.stringify(err));
|
|
30
|
-
} catch {
|
|
30
|
+
} catch {}
|
|
31
31
|
}
|
|
32
32
|
return new Error(err);
|
|
33
33
|
};
|
package/src/internal/headers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { isReadonlyArray } from
|
|
3
|
+
import { isReadonlyArray } from './utils/values';
|
|
4
4
|
|
|
5
5
|
type HeaderValue = string | undefined | null;
|
|
6
6
|
export type HeadersLike =
|
|
@@ -51,7 +51,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
|
|
|
51
51
|
}
|
|
52
52
|
for (let row of iter) {
|
|
53
53
|
const name = row[0];
|
|
54
|
-
if (typeof name !==
|
|
54
|
+
if (typeof name !== 'string') throw new TypeError('expected header name to be a string');
|
|
55
55
|
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
|
|
56
56
|
let didClear = false;
|
|
57
57
|
for (const value of values) {
|
package/src/internal/parse.ts
CHANGED
|
@@ -16,7 +16,6 @@ export type APIResponseProps = {
|
|
|
16
16
|
export async function defaultParseResponse<T>(client: Postpeer, props: APIResponseProps): Promise<T> {
|
|
17
17
|
const { response, requestLogID, retryOfRequestLogID, startTime } = props;
|
|
18
18
|
const body = await (async () => {
|
|
19
|
-
|
|
20
19
|
// fetch refuses to read the body when the status code is 204.
|
|
21
20
|
if (response.status === 204) {
|
|
22
21
|
return null as T;
|
|
@@ -43,6 +42,15 @@ export async function defaultParseResponse<T>(client: Postpeer, props: APIRespon
|
|
|
43
42
|
const text = await response.text();
|
|
44
43
|
return text as unknown as T;
|
|
45
44
|
})();
|
|
46
|
-
loggerFor(client).debug(
|
|
45
|
+
loggerFor(client).debug(
|
|
46
|
+
`[${requestLogID}] response parsed`,
|
|
47
|
+
formatRequestDetails({
|
|
48
|
+
retryOfRequestLogID,
|
|
49
|
+
url: response.url,
|
|
50
|
+
status: response.status,
|
|
51
|
+
body,
|
|
52
|
+
durationMs: Date.now() - startTime,
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
47
55
|
return body;
|
|
48
56
|
}
|
package/src/internal/qs/utils.ts
CHANGED
|
@@ -62,10 +62,7 @@ export function merge(
|
|
|
62
62
|
if (isArray(target)) {
|
|
63
63
|
target.push(source);
|
|
64
64
|
} else if (target && typeof target === 'object') {
|
|
65
|
-
if (
|
|
66
|
-
(options && (options.plainObjects || options.allowPrototypes)) ||
|
|
67
|
-
!has(Object.prototype, source)
|
|
68
|
-
) {
|
|
65
|
+
if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) {
|
|
69
66
|
target[source] = true;
|
|
70
67
|
}
|
|
71
68
|
} else {
|
|
@@ -76,14 +76,10 @@ export type RequestOptions = {
|
|
|
76
76
|
defaultBaseURL?: string | undefined;
|
|
77
77
|
|
|
78
78
|
__binaryResponse?: boolean | undefined;
|
|
79
|
-
|
|
80
79
|
};
|
|
81
80
|
|
|
82
81
|
export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
|
|
83
|
-
export type RequestEncoder = (request: {
|
|
84
|
-
headers: NullableHeaders;
|
|
85
|
-
body: unknown;
|
|
86
|
-
}) => EncodedContent;
|
|
82
|
+
export type RequestEncoder = (request: { headers: NullableHeaders; body: unknown }) => EncodedContent;
|
|
87
83
|
|
|
88
84
|
export const FallbackEncoder: RequestEncoder = ({ headers, body }) => {
|
|
89
85
|
return {
|
|
@@ -19,8 +19,8 @@ type _ConditionalNodeReadableStream<R = any> =
|
|
|
19
19
|
typeof globalThis extends { ReadableStream: any } ? never : _NodeReadableStream<R>;
|
|
20
20
|
|
|
21
21
|
type _ReadableStream<R = any> = NeverToAny<
|
|
22
|
-
([0] extends [1 & _DOMReadableStream<R>] ? never : _DOMReadableStream<R>)
|
|
23
|
-
([0] extends [1 & _ConditionalNodeReadableStream<R>] ? never : _ConditionalNodeReadableStream<R>)
|
|
22
|
+
| ([0] extends [1 & _DOMReadableStream<R>] ? never : _DOMReadableStream<R>)
|
|
23
|
+
| ([0] extends [1 & _ConditionalNodeReadableStream<R>] ? never : _ConditionalNodeReadableStream<R>)
|
|
24
24
|
>;
|
|
25
25
|
|
|
26
26
|
export type { _ReadableStream as ReadableStream };
|
package/src/internal/shims.ts
CHANGED
|
@@ -27,7 +27,9 @@ export function makeReadableStream(...args: ReadableStreamArgs): ReadableStream
|
|
|
27
27
|
if (typeof ReadableStream === 'undefined') {
|
|
28
28
|
// Note: All of the platforms / runtimes we officially support already define
|
|
29
29
|
// `ReadableStream` as a global, so this should only ever be hit on unsupported runtimes.
|
|
30
|
-
throw new Error(
|
|
30
|
+
throw new Error(
|
|
31
|
+
'`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`',
|
|
32
|
+
);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
return new ReadableStream(...args);
|
package/src/internal/to-file.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlobPart, getName, makeFile, isAsyncIterable } from
|
|
1
|
+
import { BlobPart, getName, makeFile, isAsyncIterable } from './uploads';
|
|
2
2
|
import type { FilePropertyBag } from './builtin-types';
|
|
3
3
|
import { checkFileSupport } from './uploads';
|
|
4
4
|
|
|
@@ -65,8 +65,11 @@ const isResponseLike = (value: any): value is ResponseLike =>
|
|
|
65
65
|
typeof value.url === 'string' &&
|
|
66
66
|
typeof value.blob === 'function';
|
|
67
67
|
|
|
68
|
-
export type ToFileInput =
|
|
69
|
-
|
|
68
|
+
export type ToFileInput =
|
|
69
|
+
| FileLike
|
|
70
|
+
| ResponseLike
|
|
71
|
+
| Exclude<BlobLikePart, string>
|
|
72
|
+
| AsyncIterable<BlobLikePart>;
|
|
70
73
|
|
|
71
74
|
/**
|
|
72
75
|
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
@@ -116,9 +119,7 @@ export async function toFile(
|
|
|
116
119
|
return makeFile(parts, name, options);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
async function getBytes(
|
|
120
|
-
value: BlobLikePart | AsyncIterable<BlobLikePart>,
|
|
121
|
-
): Promise<Array<BlobPart>> {
|
|
122
|
+
async function getBytes(value: BlobLikePart | AsyncIterable<BlobLikePart>): Promise<Array<BlobPart>> {
|
|
122
123
|
let parts: Array<BlobPart> = [];
|
|
123
124
|
if (
|
|
124
125
|
typeof value === 'string' ||
|
|
@@ -151,4 +152,3 @@ function propsForError(value: unknown): string {
|
|
|
151
152
|
const props = Object.getOwnPropertyNames(value);
|
|
152
153
|
return `; props: [${props.map((p) => `"${p}"`).join(', ')}]`;
|
|
153
154
|
}
|
|
154
|
-
|
package/src/internal/types.ts
CHANGED
|
@@ -7,34 +7,39 @@ export type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
|
|
7
7
|
|
|
8
8
|
export type FinalizedRequestInit = RequestInit & { headers: Headers };
|
|
9
9
|
|
|
10
|
-
type NotAny<T> = [0] extends [
|
|
10
|
+
type NotAny<T> = [0] extends [1 & T] ? never : T;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Some environments overload the global fetch function, and Parameters<T> only gets the last signature.
|
|
14
14
|
*/
|
|
15
|
-
type OverloadedParameters<T> =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(...args: infer C): unknown;
|
|
19
|
-
(...args: infer D): unknown;
|
|
20
|
-
}
|
|
21
|
-
? A | B | C | D
|
|
22
|
-
: T extends {
|
|
15
|
+
type OverloadedParameters<T> =
|
|
16
|
+
T extends (
|
|
17
|
+
{
|
|
23
18
|
(...args: infer A): unknown;
|
|
24
19
|
(...args: infer B): unknown;
|
|
25
20
|
(...args: infer C): unknown;
|
|
21
|
+
(...args: infer D): unknown;
|
|
26
22
|
}
|
|
27
|
-
?
|
|
28
|
-
|
|
23
|
+
) ?
|
|
24
|
+
A | B | C | D
|
|
25
|
+
: T extends (
|
|
26
|
+
{
|
|
27
|
+
(...args: infer A): unknown;
|
|
28
|
+
(...args: infer B): unknown;
|
|
29
|
+
(...args: infer C): unknown;
|
|
30
|
+
}
|
|
31
|
+
) ?
|
|
32
|
+
A | B | C
|
|
33
|
+
: T extends (
|
|
34
|
+
{
|
|
29
35
|
(...args: infer A): unknown;
|
|
30
36
|
(...args: infer B): unknown;
|
|
31
37
|
}
|
|
32
|
-
?
|
|
33
|
-
|
|
34
|
-
? A
|
|
38
|
+
) ?
|
|
39
|
+
A | B
|
|
40
|
+
: T extends (...args: infer A) => unknown ? A
|
|
35
41
|
: never;
|
|
36
42
|
|
|
37
|
-
|
|
38
43
|
/**
|
|
39
44
|
* These imports attempt to get types from a parent package's dependencies.
|
|
40
45
|
* Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which
|
|
@@ -69,7 +74,6 @@ type NodeFetch2RequestInit = NotAny<import('../node_modules/@types/node-fetch/in
|
|
|
69
74
|
type NodeFetch3RequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
|
|
70
75
|
/** @ts-ignore For users who use Deno */ /* prettier-ignore */
|
|
71
76
|
type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
|
|
72
|
-
|
|
73
77
|
|
|
74
78
|
type RequestInits =
|
|
75
79
|
| NotAny<UndiciTypesRequestInit>
|
|
@@ -4,7 +4,7 @@ import { hasOwn } from './values';
|
|
|
4
4
|
import { type Postpeer } from '../../client';
|
|
5
5
|
import { RequestOptions } from '../request-options';
|
|
6
6
|
|
|
7
|
-
type LogFn = (message: string, ...rest: unknown[]) => void
|
|
7
|
+
type LogFn = (message: string, ...rest: unknown[]) => void;
|
|
8
8
|
export type Logger = {
|
|
9
9
|
error: LogFn;
|
|
10
10
|
warn: LogFn;
|
|
@@ -21,14 +21,22 @@ const levelNumbers = {
|
|
|
21
21
|
debug: 500,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const parseLogLevel = (
|
|
24
|
+
export const parseLogLevel = (
|
|
25
|
+
maybeLevel: string | undefined,
|
|
26
|
+
sourceName: string,
|
|
27
|
+
client: Postpeer,
|
|
28
|
+
): LogLevel | undefined => {
|
|
25
29
|
if (!maybeLevel) {
|
|
26
30
|
return undefined;
|
|
27
31
|
}
|
|
28
32
|
if (hasOwn(levelNumbers, maybeLevel)) {
|
|
29
33
|
return maybeLevel;
|
|
30
|
-
}
|
|
31
|
-
loggerFor(client).warn(
|
|
34
|
+
}
|
|
35
|
+
loggerFor(client).warn(
|
|
36
|
+
`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(
|
|
37
|
+
Object.keys(levelNumbers),
|
|
38
|
+
)}`,
|
|
39
|
+
);
|
|
32
40
|
return undefined;
|
|
33
41
|
};
|
|
34
42
|
|
|
@@ -89,11 +97,27 @@ export const formatRequestDetails = (details: {
|
|
|
89
97
|
body?: unknown;
|
|
90
98
|
}) => {
|
|
91
99
|
if (details.options) {
|
|
92
|
-
details.options = {...details.options};
|
|
100
|
+
details.options = { ...details.options };
|
|
93
101
|
delete details.options['headers']; // redundant + leaks internals
|
|
94
102
|
}
|
|
95
103
|
if (details.headers) {
|
|
96
|
-
details.headers = Object.fromEntries(
|
|
104
|
+
details.headers = Object.fromEntries(
|
|
105
|
+
(details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(
|
|
106
|
+
([name, value]) => [
|
|
107
|
+
name,
|
|
108
|
+
(
|
|
109
|
+
name.toLowerCase() === 'authorization' ||
|
|
110
|
+
name.toLowerCase() === 'api-key' ||
|
|
111
|
+
name.toLowerCase() === 'x-api-key' ||
|
|
112
|
+
name.toLowerCase() === 'cookie' ||
|
|
113
|
+
name.toLowerCase() === 'set-cookie' ||
|
|
114
|
+
name.toLowerCase() === 'x-access-key'
|
|
115
|
+
) ?
|
|
116
|
+
'***'
|
|
117
|
+
: value,
|
|
118
|
+
],
|
|
119
|
+
),
|
|
120
|
+
);
|
|
97
121
|
}
|
|
98
122
|
if ('retryOfRequestLogID' in details) {
|
|
99
123
|
if (details.retryOfRequestLogID) {
|
|
@@ -101,5 +125,5 @@ export const formatRequestDetails = (details: {
|
|
|
101
125
|
}
|
|
102
126
|
delete details.retryOfRequestLogID;
|
|
103
127
|
}
|
|
104
|
-
return details
|
|
105
|
-
}
|
|
128
|
+
return details;
|
|
129
|
+
};
|
|
@@ -10,10 +10,8 @@ export let uuid4 = function () {
|
|
|
10
10
|
return crypto.randomUUID();
|
|
11
11
|
}
|
|
12
12
|
const u8 = new Uint8Array(1);
|
|
13
|
-
const randomByte = crypto
|
|
14
|
-
|
|
15
|
-
: () => (Math.random() * 0xff) & 0xff;
|
|
16
|
-
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) =>
|
|
13
|
+
const randomByte = crypto ? () => crypto.getRandomValues(u8)[0]! : () => (Math.random() * 0xff) & 0xff;
|
|
14
|
+
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) =>
|
|
17
15
|
(+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16),
|
|
18
16
|
);
|
|
19
|
-
}
|
|
17
|
+
};
|
package/src/resource.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @deprecated Import from ./core/resource instead */
|
|
2
|
-
export * from
|
|
2
|
+
export * from './core/resource';
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
4
|
import * as IntegrationsAPI from './integrations';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IntegrationDisconnectResponse,
|
|
7
|
+
IntegrationListParams,
|
|
8
|
+
IntegrationListResponse,
|
|
9
|
+
Integrations,
|
|
10
|
+
} from './integrations';
|
|
6
11
|
import { APIPromise } from '../../core/api-promise';
|
|
7
12
|
import { RequestOptions } from '../../internal/request-options';
|
|
8
13
|
import { path } from '../../internal/utils/path';
|
|
@@ -13,7 +18,20 @@ export class Connect extends APIResource {
|
|
|
13
18
|
/**
|
|
14
19
|
* Get OAuth URL for a platform
|
|
15
20
|
*/
|
|
16
|
-
getOAuthURL(
|
|
21
|
+
getOAuthURL(
|
|
22
|
+
platform:
|
|
23
|
+
| 'twitter'
|
|
24
|
+
| 'instagram'
|
|
25
|
+
| 'youtube'
|
|
26
|
+
| 'tiktok'
|
|
27
|
+
| 'pinterest'
|
|
28
|
+
| 'linkedin'
|
|
29
|
+
| 'bluesky'
|
|
30
|
+
| 'facebook'
|
|
31
|
+
| 'threads',
|
|
32
|
+
query: ConnectGetOAuthURLParams | null | undefined = {},
|
|
33
|
+
options?: RequestOptions,
|
|
34
|
+
): APIPromise<ConnectGetOAuthURLResponse> {
|
|
17
35
|
return this._client.get(path`/v1/connect/${platform}`, { query, ...options });
|
|
18
36
|
}
|
|
19
37
|
}
|
|
@@ -23,6 +41,12 @@ export interface ConnectGetOAuthURLResponse {
|
|
|
23
41
|
}
|
|
24
42
|
|
|
25
43
|
export interface ConnectGetOAuthURLParams {
|
|
44
|
+
/**
|
|
45
|
+
* Profile to associate the resulting integration with. Must belong to the same
|
|
46
|
+
* project. Omit to connect without a profile.
|
|
47
|
+
*/
|
|
48
|
+
profileId?: string;
|
|
49
|
+
|
|
26
50
|
/**
|
|
27
51
|
* URL to redirect to after a successful connection
|
|
28
52
|
*/
|
|
@@ -34,12 +58,13 @@ Connect.Integrations = Integrations;
|
|
|
34
58
|
export declare namespace Connect {
|
|
35
59
|
export {
|
|
36
60
|
type ConnectGetOAuthURLResponse as ConnectGetOAuthURLResponse,
|
|
37
|
-
type ConnectGetOAuthURLParams as ConnectGetOAuthURLParams
|
|
61
|
+
type ConnectGetOAuthURLParams as ConnectGetOAuthURLParams,
|
|
38
62
|
};
|
|
39
63
|
|
|
40
64
|
export {
|
|
41
65
|
Integrations as Integrations,
|
|
42
66
|
type IntegrationListResponse as IntegrationListResponse,
|
|
43
|
-
type IntegrationDisconnectResponse as IntegrationDisconnectResponse
|
|
67
|
+
type IntegrationDisconnectResponse as IntegrationDisconnectResponse,
|
|
68
|
+
type IntegrationListParams as IntegrationListParams,
|
|
44
69
|
};
|
|
45
70
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
export { Connect, type ConnectGetOAuthURLResponse, type ConnectGetOAuthURLParams } from './connect'
|
|
4
|
-
export {
|
|
3
|
+
export { Connect, type ConnectGetOAuthURLResponse, type ConnectGetOAuthURLParams } from './connect';
|
|
4
|
+
export {
|
|
5
|
+
Integrations,
|
|
6
|
+
type IntegrationListResponse,
|
|
7
|
+
type IntegrationDisconnectResponse,
|
|
8
|
+
type IntegrationListParams,
|
|
9
|
+
} from './integrations';
|
|
@@ -7,10 +7,13 @@ import { path } from '../../internal/utils/path';
|
|
|
7
7
|
|
|
8
8
|
export class Integrations extends APIResource {
|
|
9
9
|
/**
|
|
10
|
-
* List
|
|
10
|
+
* List integrations connected to this project
|
|
11
11
|
*/
|
|
12
|
-
list(
|
|
13
|
-
|
|
12
|
+
list(
|
|
13
|
+
query: IntegrationListParams | null | undefined = {},
|
|
14
|
+
options?: RequestOptions,
|
|
15
|
+
): APIPromise<IntegrationListResponse> {
|
|
16
|
+
return this._client.get('/v1/connect/integrations', { query, ...options });
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -25,6 +28,11 @@ export interface IntegrationListResponse {
|
|
|
25
28
|
integrations: Array<IntegrationListResponse.Integration>;
|
|
26
29
|
|
|
27
30
|
success: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Total matched integrations across all pages
|
|
34
|
+
*/
|
|
35
|
+
total: number;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
export namespace IntegrationListResponse {
|
|
@@ -46,12 +54,27 @@ export namespace IntegrationListResponse {
|
|
|
46
54
|
*/
|
|
47
55
|
imageUrl: string | null;
|
|
48
56
|
|
|
49
|
-
platform:
|
|
57
|
+
platform:
|
|
58
|
+
| 'twitter'
|
|
59
|
+
| 'instagram'
|
|
60
|
+
| 'youtube'
|
|
61
|
+
| 'tiktok'
|
|
62
|
+
| 'pinterest'
|
|
63
|
+
| 'linkedin'
|
|
64
|
+
| 'bluesky'
|
|
65
|
+
| 'facebook'
|
|
66
|
+
| 'threads';
|
|
50
67
|
|
|
51
68
|
/**
|
|
52
69
|
* The user ID on the platform, or null if not yet retrieved
|
|
53
70
|
*/
|
|
54
71
|
platformUserId: string | null;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Profile this integration belongs to, or null if it was connected without a
|
|
75
|
+
* profile
|
|
76
|
+
*/
|
|
77
|
+
profileId: string | null;
|
|
55
78
|
}
|
|
56
79
|
}
|
|
57
80
|
|
|
@@ -61,9 +84,47 @@ export interface IntegrationDisconnectResponse {
|
|
|
61
84
|
success: boolean;
|
|
62
85
|
}
|
|
63
86
|
|
|
87
|
+
export interface IntegrationListParams {
|
|
88
|
+
/**
|
|
89
|
+
* Page size (max 100)
|
|
90
|
+
*/
|
|
91
|
+
limit?: number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Number of integrations to skip
|
|
95
|
+
*/
|
|
96
|
+
offset?: number;
|
|
97
|
+
|
|
98
|
+
platform?:
|
|
99
|
+
| 'twitter'
|
|
100
|
+
| 'instagram'
|
|
101
|
+
| 'youtube'
|
|
102
|
+
| 'tiktok'
|
|
103
|
+
| 'pinterest'
|
|
104
|
+
| 'linkedin'
|
|
105
|
+
| 'bluesky'
|
|
106
|
+
| 'facebook'
|
|
107
|
+
| 'threads';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Filter to integrations belonging to this profile. Pass "null" (literal string)
|
|
111
|
+
* to filter to integrations with no profile.
|
|
112
|
+
*/
|
|
113
|
+
profileId?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Case-insensitive search across the connected account name (displayName) and the
|
|
117
|
+
* platform user ID.
|
|
118
|
+
*/
|
|
119
|
+
q?: string;
|
|
120
|
+
|
|
121
|
+
sort?: 'asc' | 'desc';
|
|
122
|
+
}
|
|
123
|
+
|
|
64
124
|
export declare namespace Integrations {
|
|
65
125
|
export {
|
|
66
126
|
type IntegrationListResponse as IntegrationListResponse,
|
|
67
|
-
type IntegrationDisconnectResponse as IntegrationDisconnectResponse
|
|
127
|
+
type IntegrationDisconnectResponse as IntegrationDisconnectResponse,
|
|
128
|
+
type IntegrationListParams as IntegrationListParams,
|
|
68
129
|
};
|
|
69
130
|
}
|
package/src/resources/health.ts
CHANGED
|
@@ -31,6 +31,6 @@ export interface HealthVerifyAccessKeyResponse {
|
|
|
31
31
|
export declare namespace Health {
|
|
32
32
|
export {
|
|
33
33
|
type HealthCheckResponse as HealthCheckResponse,
|
|
34
|
-
type HealthVerifyAccessKeyResponse as HealthVerifyAccessKeyResponse
|
|
34
|
+
type HealthVerifyAccessKeyResponse as HealthVerifyAccessKeyResponse,
|
|
35
35
|
};
|
|
36
36
|
}
|
package/src/resources/index.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
export { Connect, type ConnectGetOAuthURLResponse, type ConnectGetOAuthURLParams } from './connect/connect'
|
|
4
|
-
export { Health, type HealthCheckResponse, type HealthVerifyAccessKeyResponse } from './health'
|
|
5
|
-
export { Media, type MediaUploadResponse, type MediaUploadParams } from './media'
|
|
6
|
-
export { Platforms, type PlatformListResponse } from './platforms'
|
|
7
|
-
export {
|
|
3
|
+
export { Connect, type ConnectGetOAuthURLResponse, type ConnectGetOAuthURLParams } from './connect/connect';
|
|
4
|
+
export { Health, type HealthCheckResponse, type HealthVerifyAccessKeyResponse } from './health';
|
|
5
|
+
export { Media, type MediaUploadResponse, type MediaUploadParams } from './media';
|
|
6
|
+
export { Platforms, type PlatformListResponse } from './platforms';
|
|
7
|
+
export {
|
|
8
|
+
Posts,
|
|
9
|
+
type Status,
|
|
10
|
+
type PostCreateResponse,
|
|
11
|
+
type PostRetrieveResponse,
|
|
12
|
+
type PostListResponse,
|
|
13
|
+
type PostDeleteResponse,
|
|
14
|
+
type PostCreateParams,
|
|
15
|
+
type PostListParams,
|
|
16
|
+
} from './posts/posts';
|
package/src/resources/media.ts
CHANGED
|
@@ -34,8 +34,5 @@ export interface MediaUploadParams {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export declare namespace Media {
|
|
37
|
-
export {
|
|
38
|
-
type MediaUploadResponse as MediaUploadResponse,
|
|
39
|
-
type MediaUploadParams as MediaUploadParams
|
|
40
|
-
};
|
|
37
|
+
export { type MediaUploadResponse as MediaUploadResponse, type MediaUploadParams as MediaUploadParams };
|
|
41
38
|
}
|
|
@@ -19,14 +19,21 @@ export interface PlatformListResponse {
|
|
|
19
19
|
|
|
20
20
|
export namespace PlatformListResponse {
|
|
21
21
|
export interface Platform {
|
|
22
|
-
name:
|
|
22
|
+
name:
|
|
23
|
+
| 'twitter'
|
|
24
|
+
| 'instagram'
|
|
25
|
+
| 'youtube'
|
|
26
|
+
| 'tiktok'
|
|
27
|
+
| 'pinterest'
|
|
28
|
+
| 'linkedin'
|
|
29
|
+
| 'bluesky'
|
|
30
|
+
| 'facebook'
|
|
31
|
+
| 'threads';
|
|
23
32
|
|
|
24
33
|
status: 'prod' | 'beta' | 'dev';
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
export declare namespace Platforms {
|
|
29
|
-
export {
|
|
30
|
-
type PlatformListResponse as PlatformListResponse
|
|
31
|
-
};
|
|
38
|
+
export { type PlatformListResponse as PlatformListResponse };
|
|
32
39
|
}
|