@relayapi/sdk 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/api-promise.d.ts +2 -0
  2. package/dist/api-promise.js +18 -0
  3. package/dist/client.d.ts +225 -0
  4. package/dist/client.js +552 -0
  5. package/dist/core/api-promise.d.ts +45 -0
  6. package/dist/core/api-promise.js +83 -0
  7. package/dist/core/error.d.ts +45 -0
  8. package/dist/core/error.js +112 -0
  9. package/dist/core/resource.d.ts +5 -0
  10. package/dist/core/resource.js +10 -0
  11. package/dist/core/uploads.d.ts +2 -0
  12. package/dist/core/uploads.js +5 -0
  13. package/dist/error.d.ts +2 -0
  14. package/dist/error.js +18 -0
  15. package/dist/index.d.ts +5 -0
  16. package/dist/index.js +26 -0
  17. package/dist/internal/builtin-types.d.ts +72 -0
  18. package/dist/internal/builtin-types.js +3 -0
  19. package/dist/internal/detect-platform.d.ts +14 -0
  20. package/dist/internal/detect-platform.js +161 -0
  21. package/dist/internal/errors.d.ts +2 -0
  22. package/dist/internal/errors.js +40 -0
  23. package/dist/internal/headers.d.ts +19 -0
  24. package/dist/internal/headers.js +78 -0
  25. package/dist/internal/parse.d.ts +11 -0
  26. package/dist/internal/parse.js +39 -0
  27. package/dist/internal/request-options.d.ts +74 -0
  28. package/dist/internal/request-options.js +13 -0
  29. package/dist/internal/shim-types.d.ts +16 -0
  30. package/dist/internal/shim-types.js +3 -0
  31. package/dist/internal/shims.d.ts +23 -0
  32. package/dist/internal/shims.js +90 -0
  33. package/dist/internal/to-file.d.ts +44 -0
  34. package/dist/internal/to-file.js +90 -0
  35. package/dist/internal/types.d.ts +68 -0
  36. package/dist/internal/types.js +3 -0
  37. package/dist/internal/uploads.d.ts +41 -0
  38. package/dist/internal/uploads.js +140 -0
  39. package/dist/internal/utils/base64.d.ts +2 -0
  40. package/dist/internal/utils/base64.js +37 -0
  41. package/dist/internal/utils/bytes.d.ts +3 -0
  42. package/dist/internal/utils/bytes.js +30 -0
  43. package/dist/internal/utils/env.d.ts +8 -0
  44. package/dist/internal/utils/env.js +21 -0
  45. package/dist/internal/utils/log.d.ts +36 -0
  46. package/dist/internal/utils/log.js +84 -0
  47. package/dist/internal/utils/path.d.ts +14 -0
  48. package/dist/internal/utils/path.js +78 -0
  49. package/dist/internal/utils/query.d.ts +4 -0
  50. package/dist/internal/utils/query.js +22 -0
  51. package/dist/internal/utils/sleep.d.ts +1 -0
  52. package/dist/internal/utils/sleep.js +6 -0
  53. package/dist/internal/utils/uuid.d.ts +4 -0
  54. package/dist/internal/utils/uuid.js +18 -0
  55. package/dist/internal/utils/values.d.ts +17 -0
  56. package/dist/internal/utils/values.js +111 -0
  57. package/dist/internal/utils.d.ts +7 -0
  58. package/dist/internal/utils.js +24 -0
  59. package/dist/resource.d.ts +2 -0
  60. package/dist/resource.js +18 -0
  61. package/dist/resources/account-groups.d.ts +52 -0
  62. package/dist/resources/account-groups.js +37 -0
  63. package/dist/resources/accounts/accounts.d.ts +148 -0
  64. package/dist/resources/accounts/accounts.js +101 -0
  65. package/dist/resources/accounts/facebook-pages.d.ts +48 -0
  66. package/dist/resources/accounts/facebook-pages.js +21 -0
  67. package/dist/resources/accounts/gmb-locations.d.ts +48 -0
  68. package/dist/resources/accounts/gmb-locations.js +21 -0
  69. package/dist/resources/accounts/health.d.ts +49 -0
  70. package/dist/resources/accounts/health.js +21 -0
  71. package/dist/resources/accounts/index.d.ts +8 -0
  72. package/dist/resources/accounts/index.js +20 -0
  73. package/dist/resources/accounts/linkedin-organizations.d.ts +52 -0
  74. package/dist/resources/accounts/linkedin-organizations.js +21 -0
  75. package/dist/resources/accounts/pinterest-boards.d.ts +48 -0
  76. package/dist/resources/accounts/pinterest-boards.js +21 -0
  77. package/dist/resources/accounts/reddit-flairs.d.ts +27 -0
  78. package/dist/resources/accounts/reddit-flairs.js +15 -0
  79. package/dist/resources/accounts/reddit-subreddits.d.ts +48 -0
  80. package/dist/resources/accounts/reddit-subreddits.js +21 -0
  81. package/dist/resources/accounts.d.ts +1 -0
  82. package/dist/resources/accounts.js +18 -0
  83. package/dist/resources/analytics/analytics.d.ts +369 -0
  84. package/dist/resources/analytics/analytics.js +84 -0
  85. package/dist/resources/analytics/index.d.ts +2 -0
  86. package/dist/resources/analytics/index.js +8 -0
  87. package/dist/resources/analytics/youtube.d.ts +49 -0
  88. package/dist/resources/analytics/youtube.js +14 -0
  89. package/dist/resources/analytics.d.ts +1 -0
  90. package/dist/resources/analytics.js +18 -0
  91. package/dist/resources/api-keys.d.ts +110 -0
  92. package/dist/resources/api-keys.js +32 -0
  93. package/dist/resources/connect/connect.d.ts +188 -0
  94. package/dist/resources/connect/connect.js +97 -0
  95. package/dist/resources/connect/facebook/facebook.d.ts +9 -0
  96. package/dist/resources/connect/facebook/facebook.js +48 -0
  97. package/dist/resources/connect/facebook/index.d.ts +2 -0
  98. package/dist/resources/connect/facebook/index.js +8 -0
  99. package/dist/resources/connect/facebook/pages.d.ts +70 -0
  100. package/dist/resources/connect/facebook/pages.js +20 -0
  101. package/dist/resources/connect/facebook.d.ts +1 -0
  102. package/dist/resources/connect/facebook.js +18 -0
  103. package/dist/resources/connect/googlebusiness/googlebusiness.d.ts +9 -0
  104. package/dist/resources/connect/googlebusiness/googlebusiness.js +48 -0
  105. package/dist/resources/connect/googlebusiness/index.d.ts +2 -0
  106. package/dist/resources/connect/googlebusiness/index.js +8 -0
  107. package/dist/resources/connect/googlebusiness/locations.d.ts +70 -0
  108. package/dist/resources/connect/googlebusiness/locations.js +20 -0
  109. package/dist/resources/connect/googlebusiness.d.ts +1 -0
  110. package/dist/resources/connect/googlebusiness.js +18 -0
  111. package/dist/resources/connect/index.d.ts +8 -0
  112. package/dist/resources/connect/index.js +20 -0
  113. package/dist/resources/connect/linkedin/index.d.ts +2 -0
  114. package/dist/resources/connect/linkedin/index.js +8 -0
  115. package/dist/resources/connect/linkedin/linkedin.d.ts +9 -0
  116. package/dist/resources/connect/linkedin/linkedin.js +48 -0
  117. package/dist/resources/connect/linkedin/organizations.d.ts +85 -0
  118. package/dist/resources/connect/linkedin/organizations.js +20 -0
  119. package/dist/resources/connect/linkedin.d.ts +1 -0
  120. package/dist/resources/connect/linkedin.js +18 -0
  121. package/dist/resources/connect/pinterest/boards.d.ts +70 -0
  122. package/dist/resources/connect/pinterest/boards.js +20 -0
  123. package/dist/resources/connect/pinterest/index.d.ts +2 -0
  124. package/dist/resources/connect/pinterest/index.js +8 -0
  125. package/dist/resources/connect/pinterest/pinterest.d.ts +9 -0
  126. package/dist/resources/connect/pinterest/pinterest.js +48 -0
  127. package/dist/resources/connect/pinterest.d.ts +1 -0
  128. package/dist/resources/connect/pinterest.js +18 -0
  129. package/dist/resources/connect/snapchat/index.d.ts +2 -0
  130. package/dist/resources/connect/snapchat/index.js +8 -0
  131. package/dist/resources/connect/snapchat/profiles.d.ts +74 -0
  132. package/dist/resources/connect/snapchat/profiles.js +20 -0
  133. package/dist/resources/connect/snapchat/snapchat.d.ts +9 -0
  134. package/dist/resources/connect/snapchat/snapchat.js +48 -0
  135. package/dist/resources/connect/snapchat.d.ts +1 -0
  136. package/dist/resources/connect/snapchat.js +18 -0
  137. package/dist/resources/connect/telegram.d.ts +122 -0
  138. package/dist/resources/connect/telegram.js +26 -0
  139. package/dist/resources/connect/whatsapp.d.ts +92 -0
  140. package/dist/resources/connect/whatsapp.js +26 -0
  141. package/dist/resources/connect.d.ts +1 -0
  142. package/dist/resources/connect.js +18 -0
  143. package/dist/resources/connections.d.ts +55 -0
  144. package/dist/resources/connections.js +14 -0
  145. package/dist/resources/inbox/comments/comments.d.ts +220 -0
  146. package/dist/resources/inbox/comments/comments.js +83 -0
  147. package/dist/resources/inbox/comments/hide.d.ts +36 -0
  148. package/dist/resources/inbox/comments/hide.js +21 -0
  149. package/dist/resources/inbox/comments/index.d.ts +3 -0
  150. package/dist/resources/inbox/comments/index.js +10 -0
  151. package/dist/resources/inbox/comments/like.d.ts +36 -0
  152. package/dist/resources/inbox/comments/like.js +21 -0
  153. package/dist/resources/inbox/comments.d.ts +1 -0
  154. package/dist/resources/inbox/comments.js +18 -0
  155. package/dist/resources/inbox/inbox.d.ts +17 -0
  156. package/dist/resources/inbox/inbox.js +56 -0
  157. package/dist/resources/inbox/index.d.ts +4 -0
  158. package/dist/resources/inbox/index.js +12 -0
  159. package/dist/resources/inbox/messages.d.ts +205 -0
  160. package/dist/resources/inbox/messages.js +40 -0
  161. package/dist/resources/inbox/reviews/index.d.ts +2 -0
  162. package/dist/resources/inbox/reviews/index.js +8 -0
  163. package/dist/resources/inbox/reviews/reply.d.ts +38 -0
  164. package/dist/resources/inbox/reviews/reply.js +21 -0
  165. package/dist/resources/inbox/reviews/reviews.d.ts +76 -0
  166. package/dist/resources/inbox/reviews/reviews.js +54 -0
  167. package/dist/resources/inbox/reviews.d.ts +1 -0
  168. package/dist/resources/inbox/reviews.js +18 -0
  169. package/dist/resources/inbox.d.ts +1 -0
  170. package/dist/resources/inbox.js +18 -0
  171. package/dist/resources/index.d.ts +16 -0
  172. package/dist/resources/index.js +36 -0
  173. package/dist/resources/media.d.ts +177 -0
  174. package/dist/resources/media.js +51 -0
  175. package/dist/resources/posts/index.d.ts +2 -0
  176. package/dist/resources/posts/index.js +8 -0
  177. package/dist/resources/posts/logs.d.ts +134 -0
  178. package/dist/resources/posts/logs.js +31 -0
  179. package/dist/resources/posts/posts.d.ts +607 -0
  180. package/dist/resources/posts/posts.js +149 -0
  181. package/dist/resources/posts.d.ts +1 -0
  182. package/dist/resources/posts.js +18 -0
  183. package/dist/resources/queue/index.d.ts +2 -0
  184. package/dist/resources/queue/index.js +8 -0
  185. package/dist/resources/queue/queue.d.ts +42 -0
  186. package/dist/resources/queue/queue.js +60 -0
  187. package/dist/resources/queue/slots.d.ts +215 -0
  188. package/dist/resources/queue/slots.js +36 -0
  189. package/dist/resources/queue.d.ts +1 -0
  190. package/dist/resources/queue.js +18 -0
  191. package/dist/resources/reddit.d.ts +186 -0
  192. package/dist/resources/reddit.js +20 -0
  193. package/dist/resources/tools/index.d.ts +3 -0
  194. package/dist/resources/tools/index.js +10 -0
  195. package/dist/resources/tools/instagram.d.ts +41 -0
  196. package/dist/resources/tools/instagram.js +22 -0
  197. package/dist/resources/tools/tools.d.ts +13 -0
  198. package/dist/resources/tools/tools.js +52 -0
  199. package/dist/resources/tools/validate.d.ts +689 -0
  200. package/dist/resources/tools/validate.js +63 -0
  201. package/dist/resources/tools.d.ts +1 -0
  202. package/dist/resources/tools.js +18 -0
  203. package/dist/resources/twitter/bookmark.d.ts +48 -0
  204. package/dist/resources/twitter/bookmark.js +20 -0
  205. package/dist/resources/twitter/follow.d.ts +48 -0
  206. package/dist/resources/twitter/follow.js +20 -0
  207. package/dist/resources/twitter/index.d.ts +4 -0
  208. package/dist/resources/twitter/index.js +12 -0
  209. package/dist/resources/twitter/retweet.d.ts +48 -0
  210. package/dist/resources/twitter/retweet.js +20 -0
  211. package/dist/resources/twitter/twitter.d.ts +17 -0
  212. package/dist/resources/twitter/twitter.js +56 -0
  213. package/dist/resources/twitter.d.ts +1 -0
  214. package/dist/resources/twitter.js +18 -0
  215. package/dist/resources/usage.d.ts +97 -0
  216. package/dist/resources/usage.js +14 -0
  217. package/dist/resources/webhooks.d.ts +205 -0
  218. package/dist/resources/webhooks.js +50 -0
  219. package/dist/resources/whatsapp/broadcasts.d.ts +291 -0
  220. package/dist/resources/whatsapp/broadcasts.js +49 -0
  221. package/dist/resources/whatsapp/business-profile.d.ts +85 -0
  222. package/dist/resources/whatsapp/business-profile.js +20 -0
  223. package/dist/resources/whatsapp/contacts.d.ts +250 -0
  224. package/dist/resources/whatsapp/contacts.js +49 -0
  225. package/dist/resources/whatsapp/groups.d.ts +87 -0
  226. package/dist/resources/whatsapp/groups.js +31 -0
  227. package/dist/resources/whatsapp/index.d.ts +6 -0
  228. package/dist/resources/whatsapp/index.js +16 -0
  229. package/dist/resources/whatsapp/templates.d.ts +250 -0
  230. package/dist/resources/whatsapp/templates.js +39 -0
  231. package/dist/resources/whatsapp/whatsapp.d.ts +148 -0
  232. package/dist/resources/whatsapp/whatsapp.js +76 -0
  233. package/dist/resources/whatsapp.d.ts +1 -0
  234. package/dist/resources/whatsapp.js +18 -0
  235. package/dist/resources.d.ts +1 -0
  236. package/dist/resources.js +17 -0
  237. package/dist/uploads.d.ts +2 -0
  238. package/dist/uploads.js +18 -0
  239. package/dist/version.d.ts +1 -0
  240. package/dist/version.js +5 -0
  241. package/package.json +28 -0
  242. package/src/index.ts +22 -0
@@ -0,0 +1,2 @@
1
+ export declare const toBase64: (data: string | Uint8Array | null | undefined) => string;
2
+ export declare const fromBase64: (str: string) => Uint8Array;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.fromBase64 = exports.toBase64 = void 0;
5
+ const error_1 = require("../../core/error");
6
+ const bytes_1 = require("./bytes");
7
+ const toBase64 = (data) => {
8
+ if (!data)
9
+ return '';
10
+ if (typeof globalThis.Buffer !== 'undefined') {
11
+ return globalThis.Buffer.from(data).toString('base64');
12
+ }
13
+ if (typeof data === 'string') {
14
+ data = (0, bytes_1.encodeUTF8)(data);
15
+ }
16
+ if (typeof btoa !== 'undefined') {
17
+ return btoa(String.fromCharCode.apply(null, data));
18
+ }
19
+ throw new error_1.RelayError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
20
+ };
21
+ exports.toBase64 = toBase64;
22
+ const fromBase64 = (str) => {
23
+ if (typeof globalThis.Buffer !== 'undefined') {
24
+ const buf = globalThis.Buffer.from(str, 'base64');
25
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
26
+ }
27
+ if (typeof atob !== 'undefined') {
28
+ const bstr = atob(str);
29
+ const buf = new Uint8Array(bstr.length);
30
+ for (let i = 0; i < bstr.length; i++) {
31
+ buf[i] = bstr.charCodeAt(i);
32
+ }
33
+ return buf;
34
+ }
35
+ throw new error_1.RelayError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
36
+ };
37
+ exports.fromBase64 = fromBase64;
@@ -0,0 +1,3 @@
1
+ export declare function concatBytes(buffers: Uint8Array[]): Uint8Array;
2
+ export declare function encodeUTF8(str: string): Uint8Array<ArrayBufferLike>;
3
+ export declare function decodeUTF8(bytes: Uint8Array): string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.concatBytes = concatBytes;
4
+ exports.encodeUTF8 = encodeUTF8;
5
+ exports.decodeUTF8 = decodeUTF8;
6
+ function concatBytes(buffers) {
7
+ let length = 0;
8
+ for (const buffer of buffers) {
9
+ length += buffer.length;
10
+ }
11
+ const output = new Uint8Array(length);
12
+ let index = 0;
13
+ for (const buffer of buffers) {
14
+ output.set(buffer, index);
15
+ index += buffer.length;
16
+ }
17
+ return output;
18
+ }
19
+ let encodeUTF8_;
20
+ function encodeUTF8(str) {
21
+ let encoder;
22
+ return (encodeUTF8_ ??
23
+ ((encoder = new globalThis.TextEncoder()), (encodeUTF8_ = encoder.encode.bind(encoder))))(str);
24
+ }
25
+ let decodeUTF8_;
26
+ function decodeUTF8(bytes) {
27
+ let decoder;
28
+ return (decodeUTF8_ ??
29
+ ((decoder = new globalThis.TextDecoder()), (decodeUTF8_ = decoder.decode.bind(decoder))))(bytes);
30
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Read an environment variable.
3
+ *
4
+ * Trims beginning and trailing whitespace.
5
+ *
6
+ * Will return undefined if the environment variable doesn't exist or cannot be accessed.
7
+ */
8
+ export declare const readEnv: (env: string) => string | undefined;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.readEnv = void 0;
5
+ /**
6
+ * Read an environment variable.
7
+ *
8
+ * Trims beginning and trailing whitespace.
9
+ *
10
+ * Will return undefined if the environment variable doesn't exist or cannot be accessed.
11
+ */
12
+ const readEnv = (env) => {
13
+ if (typeof globalThis.process !== 'undefined') {
14
+ return globalThis.process.env?.[env]?.trim() ?? undefined;
15
+ }
16
+ if (typeof globalThis.Deno !== 'undefined') {
17
+ return globalThis.Deno.env?.get?.(env)?.trim();
18
+ }
19
+ return undefined;
20
+ };
21
+ exports.readEnv = readEnv;
@@ -0,0 +1,36 @@
1
+ import { type Relay } from '../../client';
2
+ import { RequestOptions } from '../request-options';
3
+ type LogFn = (message: string, ...rest: unknown[]) => void;
4
+ export type Logger = {
5
+ error: LogFn;
6
+ warn: LogFn;
7
+ info: LogFn;
8
+ debug: LogFn;
9
+ };
10
+ export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
11
+ export declare const parseLogLevel: (maybeLevel: string | undefined, sourceName: string, client: Relay) => LogLevel | undefined;
12
+ export declare function loggerFor(client: Relay): Logger;
13
+ export declare const formatRequestDetails: (details: {
14
+ options?: RequestOptions | undefined;
15
+ headers?: Headers | Record<string, string> | undefined;
16
+ retryOfRequestLogID?: string | undefined;
17
+ retryOf?: string | undefined;
18
+ url?: string | undefined;
19
+ status?: number | undefined;
20
+ method?: string | undefined;
21
+ durationMs?: number | undefined;
22
+ message?: unknown;
23
+ body?: unknown;
24
+ }) => {
25
+ options?: RequestOptions | undefined;
26
+ headers?: Headers | Record<string, string> | undefined;
27
+ retryOfRequestLogID?: string | undefined;
28
+ retryOf?: string | undefined;
29
+ url?: string | undefined;
30
+ status?: number | undefined;
31
+ method?: string | undefined;
32
+ durationMs?: number | undefined;
33
+ message?: unknown;
34
+ body?: unknown;
35
+ };
36
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.formatRequestDetails = exports.parseLogLevel = void 0;
5
+ exports.loggerFor = loggerFor;
6
+ const values_1 = require("./values");
7
+ const levelNumbers = {
8
+ off: 0,
9
+ error: 200,
10
+ warn: 300,
11
+ info: 400,
12
+ debug: 500,
13
+ };
14
+ const parseLogLevel = (maybeLevel, sourceName, client) => {
15
+ if (!maybeLevel) {
16
+ return undefined;
17
+ }
18
+ if ((0, values_1.hasOwn)(levelNumbers, maybeLevel)) {
19
+ return maybeLevel;
20
+ }
21
+ loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`);
22
+ return undefined;
23
+ };
24
+ exports.parseLogLevel = parseLogLevel;
25
+ function noop() { }
26
+ function makeLogFn(fnLevel, logger, logLevel) {
27
+ if (!logger || levelNumbers[fnLevel] > levelNumbers[logLevel]) {
28
+ return noop;
29
+ }
30
+ else {
31
+ // Don't wrap logger functions, we want the stacktrace intact!
32
+ return logger[fnLevel].bind(logger);
33
+ }
34
+ }
35
+ const noopLogger = {
36
+ error: noop,
37
+ warn: noop,
38
+ info: noop,
39
+ debug: noop,
40
+ };
41
+ let cachedLoggers = /* @__PURE__ */ new WeakMap();
42
+ function loggerFor(client) {
43
+ const logger = client.logger;
44
+ const logLevel = client.logLevel ?? 'off';
45
+ if (!logger) {
46
+ return noopLogger;
47
+ }
48
+ const cachedLogger = cachedLoggers.get(logger);
49
+ if (cachedLogger && cachedLogger[0] === logLevel) {
50
+ return cachedLogger[1];
51
+ }
52
+ const levelLogger = {
53
+ error: makeLogFn('error', logger, logLevel),
54
+ warn: makeLogFn('warn', logger, logLevel),
55
+ info: makeLogFn('info', logger, logLevel),
56
+ debug: makeLogFn('debug', logger, logLevel),
57
+ };
58
+ cachedLoggers.set(logger, [logLevel, levelLogger]);
59
+ return levelLogger;
60
+ }
61
+ const formatRequestDetails = (details) => {
62
+ if (details.options) {
63
+ details.options = { ...details.options };
64
+ delete details.options['headers']; // redundant + leaks internals
65
+ }
66
+ if (details.headers) {
67
+ details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
68
+ name,
69
+ (name.toLowerCase() === 'authorization' ||
70
+ name.toLowerCase() === 'cookie' ||
71
+ name.toLowerCase() === 'set-cookie') ?
72
+ '***'
73
+ : value,
74
+ ]));
75
+ }
76
+ if ('retryOfRequestLogID' in details) {
77
+ if (details.retryOfRequestLogID) {
78
+ details.retryOf = details.retryOfRequestLogID;
79
+ }
80
+ delete details.retryOfRequestLogID;
81
+ }
82
+ return details;
83
+ };
84
+ exports.formatRequestDetails = formatRequestDetails;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
3
+ *
4
+ * Taken from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3:
5
+ * > unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
6
+ * > sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
7
+ * > pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
8
+ */
9
+ export declare function encodeURIPath(str: string): string;
10
+ export declare const createPathTagFunction: (pathEncoder?: typeof encodeURIPath) => (statics: readonly string[], ...params: readonly unknown[]) => string;
11
+ /**
12
+ * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
13
+ */
14
+ export declare const path: (statics: readonly string[], ...params: readonly unknown[]) => string;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.path = exports.createPathTagFunction = void 0;
4
+ exports.encodeURIPath = encodeURIPath;
5
+ const error_1 = require("../../core/error");
6
+ /**
7
+ * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
8
+ *
9
+ * Taken from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3:
10
+ * > unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
11
+ * > sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
12
+ * > pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
13
+ */
14
+ function encodeURIPath(str) {
15
+ return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
16
+ }
17
+ const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
18
+ const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(statics, ...params) {
19
+ // If there are no params, no processing is needed.
20
+ if (statics.length === 1)
21
+ return statics[0];
22
+ let postPath = false;
23
+ const invalidSegments = [];
24
+ const path = statics.reduce((previousValue, currentValue, index) => {
25
+ if (/[?#]/.test(currentValue)) {
26
+ postPath = true;
27
+ }
28
+ const value = params[index];
29
+ let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
30
+ if (index !== params.length &&
31
+ (value == null ||
32
+ (typeof value === 'object' &&
33
+ // handle values from other realms
34
+ value.toString ===
35
+ Object.getPrototypeOf(Object.getPrototypeOf(value.hasOwnProperty ?? EMPTY) ?? EMPTY)
36
+ ?.toString))) {
37
+ encoded = value + '';
38
+ invalidSegments.push({
39
+ start: previousValue.length + currentValue.length,
40
+ length: encoded.length,
41
+ error: `Value of type ${Object.prototype.toString
42
+ .call(value)
43
+ .slice(8, -1)} is not a valid path parameter`,
44
+ });
45
+ }
46
+ return previousValue + currentValue + (index === params.length ? '' : encoded);
47
+ }, '');
48
+ const pathOnly = path.split(/[?#]/, 1)[0];
49
+ const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
50
+ let match;
51
+ // Find all invalid segments
52
+ while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
53
+ invalidSegments.push({
54
+ start: match.index,
55
+ length: match[0].length,
56
+ error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
57
+ });
58
+ }
59
+ invalidSegments.sort((a, b) => a.start - b.start);
60
+ if (invalidSegments.length > 0) {
61
+ let lastEnd = 0;
62
+ const underline = invalidSegments.reduce((acc, segment) => {
63
+ const spaces = ' '.repeat(segment.start - lastEnd);
64
+ const arrows = '^'.repeat(segment.length);
65
+ lastEnd = segment.start + segment.length;
66
+ return acc + spaces + arrows;
67
+ }, '');
68
+ throw new error_1.RelayError(`Path parameters result in path with invalid segments:\n${invalidSegments
69
+ .map((e) => e.error)
70
+ .join('\n')}\n${path}\n${underline}`);
71
+ }
72
+ return path;
73
+ };
74
+ exports.createPathTagFunction = createPathTagFunction;
75
+ /**
76
+ * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
77
+ */
78
+ exports.path = (0, exports.createPathTagFunction)(encodeURIPath);
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Basic re-implementation of `qs.stringify` for primitive types.
3
+ */
4
+ export declare function stringifyQuery(query: object | Record<string, unknown>): string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.stringifyQuery = stringifyQuery;
5
+ const error_1 = require("../../core/error");
6
+ /**
7
+ * Basic re-implementation of `qs.stringify` for primitive types.
8
+ */
9
+ function stringifyQuery(query) {
10
+ return Object.entries(query)
11
+ .filter(([_, value]) => typeof value !== 'undefined')
12
+ .map(([key, value]) => {
13
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
14
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
15
+ }
16
+ if (value === null) {
17
+ return `${encodeURIComponent(key)}=`;
18
+ }
19
+ throw new error_1.RelayError(`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.`);
20
+ })
21
+ .join('&');
22
+ }
@@ -0,0 +1 @@
1
+ export declare const sleep: (ms: number) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.sleep = void 0;
5
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
6
+ exports.sleep = sleep;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * https://stackoverflow.com/a/2117523
3
+ */
4
+ export declare let uuid4: () => any;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.uuid4 = void 0;
5
+ /**
6
+ * https://stackoverflow.com/a/2117523
7
+ */
8
+ let uuid4 = function () {
9
+ const { crypto } = globalThis;
10
+ if (crypto?.randomUUID) {
11
+ exports.uuid4 = crypto.randomUUID.bind(crypto);
12
+ return crypto.randomUUID();
13
+ }
14
+ const u8 = new Uint8Array(1);
15
+ const randomByte = crypto ? () => crypto.getRandomValues(u8)[0] : () => (Math.random() * 0xff) & 0xff;
16
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16));
17
+ };
18
+ exports.uuid4 = uuid4;
@@ -0,0 +1,17 @@
1
+ export declare const isAbsoluteURL: (url: string) => boolean;
2
+ export declare let isArray: (val: unknown) => val is unknown[];
3
+ export declare let isReadonlyArray: (val: unknown) => val is readonly unknown[];
4
+ /** Returns an object if the given value isn't an object, otherwise returns as-is */
5
+ export declare function maybeObj(x: unknown): object;
6
+ export declare function isEmptyObj(obj: Object | null | undefined): boolean;
7
+ export declare function hasOwn<T extends object = object>(obj: T, key: PropertyKey): key is keyof T;
8
+ export declare function isObj(obj: unknown): obj is Record<string, unknown>;
9
+ export declare const ensurePresent: <T>(value: T | null | undefined) => T;
10
+ export declare const validatePositiveInteger: (name: string, n: unknown) => number;
11
+ export declare const coerceInteger: (value: unknown) => number;
12
+ export declare const coerceFloat: (value: unknown) => number;
13
+ export declare const coerceBoolean: (value: unknown) => boolean;
14
+ export declare const maybeCoerceInteger: (value: unknown) => number | undefined;
15
+ export declare const maybeCoerceFloat: (value: unknown) => number | undefined;
16
+ export declare const maybeCoerceBoolean: (value: unknown) => boolean | undefined;
17
+ export declare const safeJSON: (text: string) => any;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.safeJSON = exports.maybeCoerceBoolean = exports.maybeCoerceFloat = exports.maybeCoerceInteger = exports.coerceBoolean = exports.coerceFloat = exports.coerceInteger = exports.validatePositiveInteger = exports.ensurePresent = exports.isReadonlyArray = exports.isArray = exports.isAbsoluteURL = void 0;
5
+ exports.maybeObj = maybeObj;
6
+ exports.isEmptyObj = isEmptyObj;
7
+ exports.hasOwn = hasOwn;
8
+ exports.isObj = isObj;
9
+ const error_1 = require("../../core/error");
10
+ // https://url.spec.whatwg.org/#url-scheme-string
11
+ const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
12
+ const isAbsoluteURL = (url) => {
13
+ return startsWithSchemeRegexp.test(url);
14
+ };
15
+ exports.isAbsoluteURL = isAbsoluteURL;
16
+ let isArray = (val) => ((exports.isArray = Array.isArray), (0, exports.isArray)(val));
17
+ exports.isArray = isArray;
18
+ exports.isReadonlyArray = exports.isArray;
19
+ /** Returns an object if the given value isn't an object, otherwise returns as-is */
20
+ function maybeObj(x) {
21
+ if (typeof x !== 'object') {
22
+ return {};
23
+ }
24
+ return x ?? {};
25
+ }
26
+ // https://stackoverflow.com/a/34491287
27
+ function isEmptyObj(obj) {
28
+ if (!obj)
29
+ return true;
30
+ for (const _k in obj)
31
+ return false;
32
+ return true;
33
+ }
34
+ // https://eslint.org/docs/latest/rules/no-prototype-builtins
35
+ function hasOwn(obj, key) {
36
+ return Object.prototype.hasOwnProperty.call(obj, key);
37
+ }
38
+ function isObj(obj) {
39
+ return obj != null && typeof obj === 'object' && !Array.isArray(obj);
40
+ }
41
+ const ensurePresent = (value) => {
42
+ if (value == null) {
43
+ throw new error_1.RelayError(`Expected a value to be given but received ${value} instead.`);
44
+ }
45
+ return value;
46
+ };
47
+ exports.ensurePresent = ensurePresent;
48
+ const validatePositiveInteger = (name, n) => {
49
+ if (typeof n !== 'number' || !Number.isInteger(n)) {
50
+ throw new error_1.RelayError(`${name} must be an integer`);
51
+ }
52
+ if (n < 0) {
53
+ throw new error_1.RelayError(`${name} must be a positive integer`);
54
+ }
55
+ return n;
56
+ };
57
+ exports.validatePositiveInteger = validatePositiveInteger;
58
+ const coerceInteger = (value) => {
59
+ if (typeof value === 'number')
60
+ return Math.round(value);
61
+ if (typeof value === 'string')
62
+ return parseInt(value, 10);
63
+ throw new error_1.RelayError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
64
+ };
65
+ exports.coerceInteger = coerceInteger;
66
+ const coerceFloat = (value) => {
67
+ if (typeof value === 'number')
68
+ return value;
69
+ if (typeof value === 'string')
70
+ return parseFloat(value);
71
+ throw new error_1.RelayError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
72
+ };
73
+ exports.coerceFloat = coerceFloat;
74
+ const coerceBoolean = (value) => {
75
+ if (typeof value === 'boolean')
76
+ return value;
77
+ if (typeof value === 'string')
78
+ return value === 'true';
79
+ return Boolean(value);
80
+ };
81
+ exports.coerceBoolean = coerceBoolean;
82
+ const maybeCoerceInteger = (value) => {
83
+ if (value == null) {
84
+ return undefined;
85
+ }
86
+ return (0, exports.coerceInteger)(value);
87
+ };
88
+ exports.maybeCoerceInteger = maybeCoerceInteger;
89
+ const maybeCoerceFloat = (value) => {
90
+ if (value == null) {
91
+ return undefined;
92
+ }
93
+ return (0, exports.coerceFloat)(value);
94
+ };
95
+ exports.maybeCoerceFloat = maybeCoerceFloat;
96
+ const maybeCoerceBoolean = (value) => {
97
+ if (value == null) {
98
+ return undefined;
99
+ }
100
+ return (0, exports.coerceBoolean)(value);
101
+ };
102
+ exports.maybeCoerceBoolean = maybeCoerceBoolean;
103
+ const safeJSON = (text) => {
104
+ try {
105
+ return JSON.parse(text);
106
+ }
107
+ catch (err) {
108
+ return undefined;
109
+ }
110
+ };
111
+ exports.safeJSON = safeJSON;
@@ -0,0 +1,7 @@
1
+ export * from './utils/values';
2
+ export * from './utils/base64';
3
+ export * from './utils/env';
4
+ export * from './utils/log';
5
+ export * from './utils/uuid';
6
+ export * from './utils/sleep';
7
+ export * from './utils/query';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./utils/values"), exports);
19
+ __exportStar(require("./utils/base64"), exports);
20
+ __exportStar(require("./utils/env"), exports);
21
+ __exportStar(require("./utils/log"), exports);
22
+ __exportStar(require("./utils/uuid"), exports);
23
+ __exportStar(require("./utils/sleep"), exports);
24
+ __exportStar(require("./utils/query"), exports);
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/resource instead */
2
+ export * from './core/resource';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /** @deprecated Import from ./core/resource instead */
18
+ __exportStar(require("./core/resource"), exports);
@@ -0,0 +1,52 @@
1
+ import { APIResource } from '../core/resource';
2
+ import { APIPromise } from '../core/api-promise';
3
+ import { RequestOptions } from '../internal/request-options';
4
+ export declare class AccountGroups extends APIResource {
5
+ /**
6
+ * Create an account group
7
+ */
8
+ create(body: AccountGroupCreateParams, options?: RequestOptions): APIPromise<AccountGroupCreateResponse>;
9
+ /**
10
+ * Update an account group
11
+ */
12
+ update(id: string, body?: AccountGroupUpdateParams | null | undefined, options?: RequestOptions): APIPromise<AccountGroupUpdateResponse>;
13
+ /**
14
+ * List account groups
15
+ */
16
+ list(query?: AccountGroupListParams, options?: RequestOptions): APIPromise<AccountGroupListResponse>;
17
+ /**
18
+ * Delete an account group
19
+ */
20
+ delete(id: string, options?: RequestOptions): APIPromise<void>;
21
+ }
22
+ export interface AccountGroupResponse {
23
+ id: string;
24
+ name: string;
25
+ description: string | null;
26
+ account_count: number;
27
+ created_at: string;
28
+ updated_at: string;
29
+ }
30
+ export type AccountGroupCreateResponse = AccountGroupResponse;
31
+ export type AccountGroupUpdateResponse = AccountGroupResponse;
32
+ export interface AccountGroupListResponse {
33
+ data: Array<AccountGroupResponse>;
34
+ next_cursor: string | null;
35
+ has_more: boolean;
36
+ }
37
+ export interface AccountGroupCreateParams {
38
+ name: string;
39
+ description?: string;
40
+ }
41
+ export interface AccountGroupUpdateParams {
42
+ name?: string;
43
+ description?: string | null;
44
+ }
45
+ export interface AccountGroupListParams {
46
+ search?: string;
47
+ limit?: number;
48
+ cursor?: string;
49
+ }
50
+ export declare namespace AccountGroups {
51
+ export { type AccountGroupResponse as AccountGroupResponse, type AccountGroupCreateResponse as AccountGroupCreateResponse, type AccountGroupUpdateResponse as AccountGroupUpdateResponse, type AccountGroupListResponse as AccountGroupListResponse, type AccountGroupCreateParams as AccountGroupCreateParams, type AccountGroupUpdateParams as AccountGroupUpdateParams, type AccountGroupListParams as AccountGroupListParams, };
52
+ }