@linqapp/sdk 0.1.0 → 0.1.3
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 +36 -0
- package/LICENSE +198 -4
- package/README.md +52 -52
- package/client.d.mts +34 -22
- package/client.d.mts.map +1 -1
- package/client.d.ts +34 -22
- package/client.d.ts.map +1 -1
- package/client.js +50 -41
- package/client.js.map +1 -1
- package/client.mjs +49 -40
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts +2 -2
- 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 +2 -2
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +2 -2
- package/core/error.d.ts.map +1 -1
- package/core/error.js +4 -4
- 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 +3 -3
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +3 -3
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/index.d.mts +3 -3
- package/index.d.mts.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/index.mjs.map +1 -1
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +2 -2
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/shims.js +1 -1
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +4 -4
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +6 -6
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +4 -4
- package/resources/attachments.d.mts +28 -3
- package/resources/attachments.d.mts.map +1 -1
- package/resources/attachments.d.ts +28 -3
- package/resources/attachments.d.ts.map +1 -1
- package/resources/capability.d.mts +74 -0
- package/resources/capability.d.mts.map +1 -0
- package/resources/capability.d.ts +74 -0
- package/resources/capability.d.ts.map +1 -0
- package/resources/capability.js +36 -0
- package/resources/capability.js.map +1 -0
- package/resources/capability.mjs +32 -0
- package/resources/capability.mjs.map +1 -0
- package/resources/chats/chats.d.mts +133 -663
- package/resources/chats/chats.d.mts.map +1 -1
- package/resources/chats/chats.d.ts +133 -663
- package/resources/chats/chats.d.ts.map +1 -1
- package/resources/chats/chats.js +2 -2
- package/resources/chats/chats.js.map +1 -1
- package/resources/chats/chats.mjs +2 -2
- package/resources/chats/chats.mjs.map +1 -1
- package/resources/chats/index.d.mts +2 -2
- package/resources/chats/index.d.mts.map +1 -1
- package/resources/chats/index.d.ts +2 -2
- package/resources/chats/index.d.ts.map +1 -1
- package/resources/chats/index.js.map +1 -1
- package/resources/chats/index.mjs.map +1 -1
- package/resources/chats/messages.d.mts +55 -716
- package/resources/chats/messages.d.mts.map +1 -1
- package/resources/chats/messages.d.ts +55 -716
- package/resources/chats/messages.d.ts.map +1 -1
- package/resources/chats/messages.js.map +1 -1
- package/resources/chats/messages.mjs.map +1 -1
- package/resources/index.d.mts +8 -5
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +8 -5
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +9 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +5 -2
- package/resources/index.mjs.map +1 -1
- package/resources/messages.d.mts +129 -553
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +129 -553
- package/resources/messages.d.ts.map +1 -1
- package/resources/messages.js +1 -1
- package/resources/messages.js.map +1 -1
- package/resources/messages.mjs +1 -1
- package/resources/messages.mjs.map +1 -1
- package/resources/phone-numbers.d.mts +1 -50
- package/resources/phone-numbers.d.mts.map +1 -1
- package/resources/phone-numbers.d.ts +1 -50
- package/resources/phone-numbers.d.ts.map +1 -1
- package/resources/phone-numbers.js +0 -8
- package/resources/phone-numbers.js.map +1 -1
- package/resources/phone-numbers.mjs +0 -8
- package/resources/phone-numbers.mjs.map +1 -1
- package/resources/phonenumbers.d.mts +58 -0
- package/resources/phonenumbers.d.mts.map +1 -0
- package/resources/phonenumbers.d.ts +58 -0
- package/resources/phonenumbers.d.ts.map +1 -0
- package/resources/phonenumbers.js +17 -0
- package/resources/phonenumbers.js.map +1 -0
- package/resources/phonenumbers.mjs +13 -0
- package/resources/phonenumbers.mjs.map +1 -0
- package/resources/webhook-events.d.mts +29 -0
- package/resources/webhook-events.d.mts.map +1 -0
- package/resources/webhook-events.d.ts +29 -0
- package/resources/webhook-events.d.ts.map +1 -0
- package/resources/{webhooks/events.js → webhook-events.js} +5 -10
- package/resources/webhook-events.js.map +1 -0
- package/resources/{webhooks/events.mjs → webhook-events.mjs} +3 -8
- package/resources/webhook-events.mjs.map +1 -0
- package/resources/webhook-subscriptions.d.mts +184 -0
- package/resources/webhook-subscriptions.d.mts.map +1 -0
- package/resources/webhook-subscriptions.d.ts +184 -0
- package/resources/webhook-subscriptions.d.ts.map +1 -0
- package/resources/{webhooks/subscriptions.js → webhook-subscriptions.js} +16 -16
- package/resources/webhook-subscriptions.js.map +1 -0
- package/resources/{webhooks/subscriptions.mjs → webhook-subscriptions.mjs} +14 -14
- package/resources/webhook-subscriptions.mjs.map +1 -0
- package/src/client.ts +97 -41
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/attachments.ts +81 -106
- package/src/resources/capability.ts +98 -0
- package/src/resources/chats/chats.ts +135 -770
- package/src/resources/chats/index.ts +4 -2
- package/src/resources/chats/messages.ts +60 -839
- package/src/resources/index.ts +29 -9
- package/src/resources/messages.ts +153 -659
- package/src/resources/phone-numbers.ts +1 -65
- package/src/resources/phonenumbers.ts +72 -0
- package/src/resources/webhook-events.ts +57 -0
- package/src/resources/webhook-subscriptions.ts +238 -0
- 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/resources/webhooks/events.d.mts +0 -30
- package/resources/webhooks/events.d.mts.map +0 -1
- package/resources/webhooks/events.d.ts +0 -30
- package/resources/webhooks/events.d.ts.map +0 -1
- package/resources/webhooks/events.js.map +0 -1
- package/resources/webhooks/events.mjs.map +0 -1
- package/resources/webhooks/index.d.mts +0 -4
- package/resources/webhooks/index.d.mts.map +0 -1
- package/resources/webhooks/index.d.ts +0 -4
- package/resources/webhooks/index.d.ts.map +0 -1
- package/resources/webhooks/index.js +0 -11
- package/resources/webhooks/index.js.map +0 -1
- package/resources/webhooks/index.mjs +0 -5
- package/resources/webhooks/index.mjs.map +0 -1
- package/resources/webhooks/subscriptions.d.mts +0 -237
- package/resources/webhooks/subscriptions.d.mts.map +0 -1
- package/resources/webhooks/subscriptions.d.ts +0 -237
- package/resources/webhooks/subscriptions.d.ts.map +0 -1
- package/resources/webhooks/subscriptions.js.map +0 -1
- package/resources/webhooks/subscriptions.mjs.map +0 -1
- package/resources/webhooks/webhooks.d.mts +0 -14
- package/resources/webhooks/webhooks.d.mts.map +0 -1
- package/resources/webhooks/webhooks.d.ts +0 -14
- package/resources/webhooks/webhooks.d.ts.map +0 -1
- package/resources/webhooks/webhooks.js +0 -21
- package/resources/webhooks/webhooks.js.map +0 -1
- package/resources/webhooks/webhooks.mjs +0 -16
- package/resources/webhooks/webhooks.mjs.map +0 -1
- package/resources/webhooks.d.mts +0 -2
- package/resources/webhooks.d.mts.map +0 -1
- package/resources/webhooks.d.ts +0 -2
- package/resources/webhooks.d.ts.map +0 -1
- package/resources/webhooks.js +0 -6
- package/resources/webhooks.js.map +0 -1
- package/resources/webhooks.mjs +0 -3
- package/resources/webhooks.mjs.map +0 -1
- package/src/resources/webhooks/events.ts +0 -55
- package/src/resources/webhooks/index.ts +0 -13
- package/src/resources/webhooks/subscriptions.ts +0 -409
- package/src/resources/webhooks/webhooks.ts +0 -37
- package/src/resources/webhooks.ts +0 -3
package/src/client.ts
CHANGED
|
@@ -21,34 +21,54 @@ import {
|
|
|
21
21
|
AttachmentCreateResponse,
|
|
22
22
|
AttachmentRetrieveResponse,
|
|
23
23
|
Attachments,
|
|
24
|
+
SupportedContentType,
|
|
24
25
|
} from './resources/attachments';
|
|
25
26
|
import {
|
|
27
|
+
Capability,
|
|
28
|
+
CapabilityCheckImessageParams,
|
|
29
|
+
CapabilityCheckImessageResponse,
|
|
30
|
+
CapabilityCheckRcsParams,
|
|
31
|
+
CapabilityCheckRcsResponse,
|
|
32
|
+
} from './resources/capability';
|
|
33
|
+
import {
|
|
34
|
+
ChatHandle,
|
|
35
|
+
MediaPart,
|
|
36
|
+
Message,
|
|
26
37
|
MessageAddReactionParams,
|
|
27
|
-
MessageAddReactionResponse,
|
|
28
38
|
MessageDeleteParams,
|
|
29
|
-
|
|
39
|
+
MessageEffect,
|
|
30
40
|
MessageRetrieveThreadParams,
|
|
31
41
|
MessageRetrieveThreadResponse,
|
|
32
42
|
Messages,
|
|
43
|
+
Reaction,
|
|
44
|
+
ReactionType,
|
|
45
|
+
ReplyTo,
|
|
46
|
+
TextPart,
|
|
33
47
|
} from './resources/messages';
|
|
48
|
+
import { PhoneNumberListResponse, PhoneNumbers } from './resources/phone-numbers';
|
|
49
|
+
import { PhonenumberListResponse, Phonenumbers } from './resources/phonenumbers';
|
|
50
|
+
import { WebhookEventListResponse, WebhookEventType, WebhookEvents } from './resources/webhook-events';
|
|
34
51
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
WebhookSubscription,
|
|
53
|
+
WebhookSubscriptionCreateParams,
|
|
54
|
+
WebhookSubscriptionCreateResponse,
|
|
55
|
+
WebhookSubscriptionListResponse,
|
|
56
|
+
WebhookSubscriptionUpdateParams,
|
|
57
|
+
WebhookSubscriptions,
|
|
58
|
+
} from './resources/webhook-subscriptions';
|
|
39
59
|
import {
|
|
60
|
+
Chat,
|
|
40
61
|
ChatCreateParams,
|
|
41
62
|
ChatCreateResponse,
|
|
42
63
|
ChatListParams,
|
|
43
64
|
ChatListResponse,
|
|
44
|
-
ChatRetrieveResponse,
|
|
45
65
|
ChatSendVoicememoParams,
|
|
46
66
|
ChatSendVoicememoResponse,
|
|
47
67
|
ChatUpdateParams,
|
|
48
|
-
ChatUpdateResponse,
|
|
49
68
|
Chats,
|
|
69
|
+
MessageContent,
|
|
70
|
+
ServiceType,
|
|
50
71
|
} from './resources/chats/chats';
|
|
51
|
-
import { Webhooks } from './resources/webhooks/webhooks';
|
|
52
72
|
import { type Fetch } from './internal/builtin-types';
|
|
53
73
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
54
74
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -64,14 +84,17 @@ import { isEmptyObj } from './internal/utils/values';
|
|
|
64
84
|
|
|
65
85
|
export interface ClientOptions {
|
|
66
86
|
/**
|
|
67
|
-
*
|
|
87
|
+
* Bearer token authentication. Include your API token in the Authorization header.
|
|
88
|
+
*
|
|
89
|
+
* Format: `Authorization: Bearer <your-token>`
|
|
90
|
+
*
|
|
68
91
|
*/
|
|
69
92
|
apiKey?: string | undefined;
|
|
70
93
|
|
|
71
94
|
/**
|
|
72
95
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
73
96
|
*
|
|
74
|
-
* Defaults to process.env['
|
|
97
|
+
* Defaults to process.env['LINQ_API_V3_BASE_URL'].
|
|
75
98
|
*/
|
|
76
99
|
baseURL?: string | null | undefined;
|
|
77
100
|
|
|
@@ -125,7 +148,7 @@ export interface ClientOptions {
|
|
|
125
148
|
/**
|
|
126
149
|
* Set the log level.
|
|
127
150
|
*
|
|
128
|
-
* Defaults to process.env['
|
|
151
|
+
* Defaults to process.env['LINQ_API_V3_LOG'] or 'warn' if it isn't set.
|
|
129
152
|
*/
|
|
130
153
|
logLevel?: LogLevel | undefined;
|
|
131
154
|
|
|
@@ -138,9 +161,9 @@ export interface ClientOptions {
|
|
|
138
161
|
}
|
|
139
162
|
|
|
140
163
|
/**
|
|
141
|
-
* API Client for interfacing with the Linq API.
|
|
164
|
+
* API Client for interfacing with the Linq API V3 API.
|
|
142
165
|
*/
|
|
143
|
-
export class
|
|
166
|
+
export class LinqAPIV3 {
|
|
144
167
|
apiKey: string;
|
|
145
168
|
|
|
146
169
|
baseURL: string;
|
|
@@ -156,10 +179,10 @@ export class Linq {
|
|
|
156
179
|
private _options: ClientOptions;
|
|
157
180
|
|
|
158
181
|
/**
|
|
159
|
-
* API Client for interfacing with the Linq API.
|
|
182
|
+
* API Client for interfacing with the Linq API V3 API.
|
|
160
183
|
*
|
|
161
|
-
* @param {string | undefined} [opts.apiKey=process.env['
|
|
162
|
-
* @param {string} [opts.baseURL=process.env['
|
|
184
|
+
* @param {string | undefined} [opts.apiKey=process.env['LINQ_API_V3_API_KEY'] ?? undefined]
|
|
185
|
+
* @param {string} [opts.baseURL=process.env['LINQ_API_V3_BASE_URL'] ?? https://api.linqapp.com/api/partner] - Override the default base URL for the API.
|
|
163
186
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
164
187
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
165
188
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -168,13 +191,13 @@ export class Linq {
|
|
|
168
191
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
169
192
|
*/
|
|
170
193
|
constructor({
|
|
171
|
-
baseURL = readEnv('
|
|
172
|
-
apiKey = readEnv('
|
|
194
|
+
baseURL = readEnv('LINQ_API_V3_BASE_URL'),
|
|
195
|
+
apiKey = readEnv('LINQ_API_V3_API_KEY'),
|
|
173
196
|
...opts
|
|
174
197
|
}: ClientOptions = {}) {
|
|
175
198
|
if (apiKey === undefined) {
|
|
176
|
-
throw new Errors.
|
|
177
|
-
"The
|
|
199
|
+
throw new Errors.LinqAPIV3Error(
|
|
200
|
+
"The LINQ_API_V3_API_KEY environment variable is missing or empty; either provide it, or instantiate the LinqAPIV3 client with an apiKey option, like new LinqAPIV3({ apiKey: 'My API Key' }).",
|
|
178
201
|
);
|
|
179
202
|
}
|
|
180
203
|
|
|
@@ -185,14 +208,14 @@ export class Linq {
|
|
|
185
208
|
};
|
|
186
209
|
|
|
187
210
|
this.baseURL = options.baseURL!;
|
|
188
|
-
this.timeout = options.timeout ??
|
|
211
|
+
this.timeout = options.timeout ?? LinqAPIV3.DEFAULT_TIMEOUT /* 1 minute */;
|
|
189
212
|
this.logger = options.logger ?? console;
|
|
190
213
|
const defaultLogLevel = 'warn';
|
|
191
214
|
// Set default logLevel early so that we can log a warning in parseLogLevel.
|
|
192
215
|
this.logLevel = defaultLogLevel;
|
|
193
216
|
this.logLevel =
|
|
194
217
|
parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ??
|
|
195
|
-
parseLogLevel(readEnv('
|
|
218
|
+
parseLogLevel(readEnv('LINQ_API_V3_LOG'), "process.env['LINQ_API_V3_LOG']", this) ??
|
|
196
219
|
defaultLogLevel;
|
|
197
220
|
this.fetchOptions = options.fetchOptions;
|
|
198
221
|
this.maxRetries = options.maxRetries ?? 2;
|
|
@@ -255,7 +278,7 @@ export class Linq {
|
|
|
255
278
|
if (value === null) {
|
|
256
279
|
return `${encodeURIComponent(key)}=`;
|
|
257
280
|
}
|
|
258
|
-
throw new Errors.
|
|
281
|
+
throw new Errors.LinqAPIV3Error(
|
|
259
282
|
`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.`,
|
|
260
283
|
);
|
|
261
284
|
})
|
|
@@ -742,10 +765,10 @@ export class Linq {
|
|
|
742
765
|
}
|
|
743
766
|
}
|
|
744
767
|
|
|
745
|
-
static
|
|
768
|
+
static LinqAPIV3 = this;
|
|
746
769
|
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
747
770
|
|
|
748
|
-
static
|
|
771
|
+
static LinqAPIV3Error = Errors.LinqAPIV3Error;
|
|
749
772
|
static APIError = Errors.APIError;
|
|
750
773
|
static APIConnectionError = Errors.APIConnectionError;
|
|
751
774
|
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
@@ -764,24 +787,31 @@ export class Linq {
|
|
|
764
787
|
chats: API.Chats = new API.Chats(this);
|
|
765
788
|
messages: API.Messages = new API.Messages(this);
|
|
766
789
|
attachments: API.Attachments = new API.Attachments(this);
|
|
790
|
+
phonenumbers: API.Phonenumbers = new API.Phonenumbers(this);
|
|
767
791
|
phoneNumbers: API.PhoneNumbers = new API.PhoneNumbers(this);
|
|
768
|
-
|
|
792
|
+
webhookEvents: API.WebhookEvents = new API.WebhookEvents(this);
|
|
793
|
+
webhookSubscriptions: API.WebhookSubscriptions = new API.WebhookSubscriptions(this);
|
|
794
|
+
capability: API.Capability = new API.Capability(this);
|
|
769
795
|
}
|
|
770
796
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
797
|
+
LinqAPIV3.Chats = Chats;
|
|
798
|
+
LinqAPIV3.Messages = Messages;
|
|
799
|
+
LinqAPIV3.Attachments = Attachments;
|
|
800
|
+
LinqAPIV3.Phonenumbers = Phonenumbers;
|
|
801
|
+
LinqAPIV3.PhoneNumbers = PhoneNumbers;
|
|
802
|
+
LinqAPIV3.WebhookEvents = WebhookEvents;
|
|
803
|
+
LinqAPIV3.WebhookSubscriptions = WebhookSubscriptions;
|
|
804
|
+
LinqAPIV3.Capability = Capability;
|
|
776
805
|
|
|
777
|
-
export declare namespace
|
|
806
|
+
export declare namespace LinqAPIV3 {
|
|
778
807
|
export type RequestOptions = Opts.RequestOptions;
|
|
779
808
|
|
|
780
809
|
export {
|
|
781
810
|
Chats as Chats,
|
|
811
|
+
type Chat as Chat,
|
|
812
|
+
type MessageContent as MessageContent,
|
|
813
|
+
type ServiceType as ServiceType,
|
|
782
814
|
type ChatCreateResponse as ChatCreateResponse,
|
|
783
|
-
type ChatRetrieveResponse as ChatRetrieveResponse,
|
|
784
|
-
type ChatUpdateResponse as ChatUpdateResponse,
|
|
785
815
|
type ChatListResponse as ChatListResponse,
|
|
786
816
|
type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
|
|
787
817
|
type ChatCreateParams as ChatCreateParams,
|
|
@@ -792,8 +822,14 @@ export declare namespace Linq {
|
|
|
792
822
|
|
|
793
823
|
export {
|
|
794
824
|
Messages as Messages,
|
|
795
|
-
type
|
|
796
|
-
type
|
|
825
|
+
type ChatHandle as ChatHandle,
|
|
826
|
+
type MediaPart as MediaPart,
|
|
827
|
+
type Message as Message,
|
|
828
|
+
type MessageEffect as MessageEffect,
|
|
829
|
+
type Reaction as Reaction,
|
|
830
|
+
type ReactionType as ReactionType,
|
|
831
|
+
type ReplyTo as ReplyTo,
|
|
832
|
+
type TextPart as TextPart,
|
|
797
833
|
type MessageRetrieveThreadResponse as MessageRetrieveThreadResponse,
|
|
798
834
|
type MessageDeleteParams as MessageDeleteParams,
|
|
799
835
|
type MessageAddReactionParams as MessageAddReactionParams,
|
|
@@ -802,16 +838,36 @@ export declare namespace Linq {
|
|
|
802
838
|
|
|
803
839
|
export {
|
|
804
840
|
Attachments as Attachments,
|
|
841
|
+
type SupportedContentType as SupportedContentType,
|
|
805
842
|
type AttachmentCreateResponse as AttachmentCreateResponse,
|
|
806
843
|
type AttachmentRetrieveResponse as AttachmentRetrieveResponse,
|
|
807
844
|
type AttachmentCreateParams as AttachmentCreateParams,
|
|
808
845
|
};
|
|
809
846
|
|
|
847
|
+
export { Phonenumbers as Phonenumbers, type PhonenumberListResponse as PhonenumberListResponse };
|
|
848
|
+
|
|
849
|
+
export { PhoneNumbers as PhoneNumbers, type PhoneNumberListResponse as PhoneNumberListResponse };
|
|
850
|
+
|
|
851
|
+
export {
|
|
852
|
+
WebhookEvents as WebhookEvents,
|
|
853
|
+
type WebhookEventType as WebhookEventType,
|
|
854
|
+
type WebhookEventListResponse as WebhookEventListResponse,
|
|
855
|
+
};
|
|
856
|
+
|
|
810
857
|
export {
|
|
811
|
-
|
|
812
|
-
type
|
|
813
|
-
type
|
|
858
|
+
WebhookSubscriptions as WebhookSubscriptions,
|
|
859
|
+
type WebhookSubscription as WebhookSubscription,
|
|
860
|
+
type WebhookSubscriptionCreateResponse as WebhookSubscriptionCreateResponse,
|
|
861
|
+
type WebhookSubscriptionListResponse as WebhookSubscriptionListResponse,
|
|
862
|
+
type WebhookSubscriptionCreateParams as WebhookSubscriptionCreateParams,
|
|
863
|
+
type WebhookSubscriptionUpdateParams as WebhookSubscriptionUpdateParams,
|
|
814
864
|
};
|
|
815
865
|
|
|
816
|
-
export {
|
|
866
|
+
export {
|
|
867
|
+
Capability as Capability,
|
|
868
|
+
type CapabilityCheckImessageResponse as CapabilityCheckImessageResponse,
|
|
869
|
+
type CapabilityCheckRcsResponse as CapabilityCheckRcsResponse,
|
|
870
|
+
type CapabilityCheckImessageParams as CapabilityCheckImessageParams,
|
|
871
|
+
type CapabilityCheckRcsParams as CapabilityCheckRcsParams,
|
|
872
|
+
};
|
|
817
873
|
}
|
package/src/core/api-promise.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 { type
|
|
3
|
+
import { type LinqAPIV3 } from '../client';
|
|
4
4
|
|
|
5
5
|
import { type PromiseOrValue } from '../internal/types';
|
|
6
6
|
import { APIResponseProps, defaultParseResponse } from '../internal/parse';
|
|
@@ -11,13 +11,13 @@ import { APIResponseProps, defaultParseResponse } from '../internal/parse';
|
|
|
11
11
|
*/
|
|
12
12
|
export class APIPromise<T> extends Promise<T> {
|
|
13
13
|
private parsedPromise: Promise<T> | undefined;
|
|
14
|
-
#client:
|
|
14
|
+
#client: LinqAPIV3;
|
|
15
15
|
|
|
16
16
|
constructor(
|
|
17
|
-
client:
|
|
17
|
+
client: LinqAPIV3,
|
|
18
18
|
private responsePromise: Promise<APIResponseProps>,
|
|
19
19
|
private parseResponse: (
|
|
20
|
-
client:
|
|
20
|
+
client: LinqAPIV3,
|
|
21
21
|
props: APIResponseProps,
|
|
22
22
|
) => PromiseOrValue<T> = defaultParseResponse,
|
|
23
23
|
) {
|
package/src/core/error.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { castToError } from '../internal/errors';
|
|
4
4
|
|
|
5
|
-
export class
|
|
5
|
+
export class LinqAPIV3Error extends Error {}
|
|
6
6
|
|
|
7
7
|
export class APIError<
|
|
8
8
|
TStatus extends number | undefined = number | undefined,
|
|
9
9
|
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
10
|
TError extends Object | undefined = Object | undefined,
|
|
11
|
-
> extends
|
|
11
|
+
> extends LinqAPIV3Error {
|
|
12
12
|
/** HTTP status for the response that caused the error */
|
|
13
13
|
readonly status: TStatus;
|
|
14
14
|
/** HTTP headers for the response that caused the error */
|
package/src/core/resource.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { LinqAPIV3 } from '../client';
|
|
4
4
|
|
|
5
5
|
export abstract class APIResource {
|
|
6
|
-
protected _client:
|
|
6
|
+
protected _client: LinqAPIV3;
|
|
7
7
|
|
|
8
|
-
constructor(client:
|
|
8
|
+
constructor(client: LinqAPIV3) {
|
|
9
9
|
this._client = client;
|
|
10
10
|
}
|
|
11
11
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { LinqAPIV3 as default } from './client';
|
|
4
4
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
|
-
export {
|
|
7
|
+
export { LinqAPIV3, type ClientOptions } from './client';
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
LinqAPIV3Error,
|
|
10
10
|
APIError,
|
|
11
11
|
APIConnectionError,
|
|
12
12
|
APIConnectionTimeoutError,
|
package/src/internal/parse.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import type { FinalRequestOptions } from './request-options';
|
|
4
|
-
import { type
|
|
4
|
+
import { type LinqAPIV3 } from '../client';
|
|
5
5
|
import { formatRequestDetails, loggerFor } from './utils/log';
|
|
6
6
|
|
|
7
7
|
export type APIResponseProps = {
|
|
@@ -13,7 +13,7 @@ export type APIResponseProps = {
|
|
|
13
13
|
startTime: number;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export async function defaultParseResponse<T>(client:
|
|
16
|
+
export async function defaultParseResponse<T>(client: LinqAPIV3, props: APIResponseProps): Promise<T> {
|
|
17
17
|
const { response, requestLogID, retryOfRequestLogID, startTime } = props;
|
|
18
18
|
const body = await (async () => {
|
|
19
19
|
// fetch refuses to read the body when the status code is 204.
|
package/src/internal/shims.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function getDefaultFetch(): Fetch {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
throw new Error(
|
|
19
|
-
'`fetch` is not defined as a global; Either pass `fetch` to the client, `new
|
|
19
|
+
'`fetch` is not defined as a global; Either pass `fetch` to the client, `new LinqAPIV3({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
|
package/src/internal/uploads.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RequestOptions } from './request-options';
|
|
2
2
|
import type { FilePropertyBag, Fetch } from './builtin-types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LinqAPIV3 } from '../client';
|
|
4
4
|
import { ReadableStreamFrom } from './shims';
|
|
5
5
|
|
|
6
6
|
export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
|
|
@@ -74,7 +74,7 @@ export const isAsyncIterable = (value: any): value is AsyncIterable<any> =>
|
|
|
74
74
|
*/
|
|
75
75
|
export const maybeMultipartFormRequestOptions = async (
|
|
76
76
|
opts: RequestOptions,
|
|
77
|
-
fetch:
|
|
77
|
+
fetch: LinqAPIV3 | Fetch,
|
|
78
78
|
): Promise<RequestOptions> => {
|
|
79
79
|
if (!hasUploadableValue(opts.body)) return opts;
|
|
80
80
|
|
|
@@ -85,7 +85,7 @@ type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & { body: unknow
|
|
|
85
85
|
|
|
86
86
|
export const multipartFormRequestOptions = async (
|
|
87
87
|
opts: MultipartFormRequestOptions,
|
|
88
|
-
fetch:
|
|
88
|
+
fetch: LinqAPIV3 | Fetch,
|
|
89
89
|
): Promise<RequestOptions> => {
|
|
90
90
|
return { ...opts, body: await createForm(opts.body, fetch) };
|
|
91
91
|
};
|
|
@@ -98,7 +98,7 @@ const supportsFormDataMap = /* @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>
|
|
|
98
98
|
* This function detects if the fetch function provided supports the global FormData object to avoid
|
|
99
99
|
* confusing error messages later on.
|
|
100
100
|
*/
|
|
101
|
-
function supportsFormData(fetchObject:
|
|
101
|
+
function supportsFormData(fetchObject: LinqAPIV3 | Fetch): Promise<boolean> {
|
|
102
102
|
const fetch: Fetch = typeof fetchObject === 'function' ? fetchObject : (fetchObject as any).fetch;
|
|
103
103
|
const cached = supportsFormDataMap.get(fetch);
|
|
104
104
|
if (cached) return cached;
|
|
@@ -124,7 +124,7 @@ function supportsFormData(fetchObject: Linq | Fetch): Promise<boolean> {
|
|
|
124
124
|
|
|
125
125
|
export const createForm = async <T = Record<string, unknown>>(
|
|
126
126
|
body: T | undefined,
|
|
127
|
-
fetch:
|
|
127
|
+
fetch: LinqAPIV3 | Fetch,
|
|
128
128
|
): Promise<FormData> => {
|
|
129
129
|
if (!(await supportsFormData(fetch))) {
|
|
130
130
|
throw new TypeError(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { LinqAPIV3Error } from '../../core/error';
|
|
4
4
|
import { encodeUTF8 } from './bytes';
|
|
5
5
|
|
|
6
6
|
export const toBase64 = (data: string | Uint8Array | null | undefined): string => {
|
|
@@ -18,7 +18,7 @@ export const toBase64 = (data: string | Uint8Array | null | undefined): string =
|
|
|
18
18
|
return btoa(String.fromCharCode.apply(null, data as any));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
throw new
|
|
21
|
+
throw new LinqAPIV3Error('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const fromBase64 = (str: string): Uint8Array => {
|
|
@@ -36,5 +36,5 @@ export const fromBase64 = (str: string): Uint8Array => {
|
|
|
36
36
|
return buf;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
throw new
|
|
39
|
+
throw new LinqAPIV3Error('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
|
|
40
40
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { hasOwn } from './values';
|
|
4
|
-
import { type
|
|
4
|
+
import { type LinqAPIV3 } from '../../client';
|
|
5
5
|
import { RequestOptions } from '../request-options';
|
|
6
6
|
|
|
7
7
|
type LogFn = (message: string, ...rest: unknown[]) => void;
|
|
@@ -24,7 +24,7 @@ const levelNumbers = {
|
|
|
24
24
|
export const parseLogLevel = (
|
|
25
25
|
maybeLevel: string | undefined,
|
|
26
26
|
sourceName: string,
|
|
27
|
-
client:
|
|
27
|
+
client: LinqAPIV3,
|
|
28
28
|
): LogLevel | undefined => {
|
|
29
29
|
if (!maybeLevel) {
|
|
30
30
|
return undefined;
|
|
@@ -60,7 +60,7 @@ const noopLogger = {
|
|
|
60
60
|
|
|
61
61
|
let cachedLoggers = /* @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
|
|
62
62
|
|
|
63
|
-
export function loggerFor(client:
|
|
63
|
+
export function loggerFor(client: LinqAPIV3): Logger {
|
|
64
64
|
const logger = client.logger;
|
|
65
65
|
const logLevel = client.logLevel ?? 'off';
|
|
66
66
|
if (!logger) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinqAPIV3Error } from '../../core/error';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Percent-encode everything that isn't safe to have in a path without encoding safe chars.
|
|
@@ -72,7 +72,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
72
72
|
return acc + spaces + arrows;
|
|
73
73
|
}, '');
|
|
74
74
|
|
|
75
|
-
throw new
|
|
75
|
+
throw new LinqAPIV3Error(
|
|
76
76
|
`Path parameters result in path with invalid segments:\n${invalidSegments
|
|
77
77
|
.map((e) => e.error)
|
|
78
78
|
.join('\n')}\n${path}\n${underline}`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { LinqAPIV3Error } from '../../core/error';
|
|
4
4
|
|
|
5
5
|
// https://url.spec.whatwg.org/#url-scheme-string
|
|
6
6
|
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
@@ -39,7 +39,7 @@ export function isObj(obj: unknown): obj is Record<string, unknown> {
|
|
|
39
39
|
|
|
40
40
|
export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
41
41
|
if (value == null) {
|
|
42
|
-
throw new
|
|
42
|
+
throw new LinqAPIV3Error(`Expected a value to be given but received ${value} instead.`);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return value;
|
|
@@ -47,10 +47,10 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
|
47
47
|
|
|
48
48
|
export const validatePositiveInteger = (name: string, n: unknown): number => {
|
|
49
49
|
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new LinqAPIV3Error(`${name} must be an integer`);
|
|
51
51
|
}
|
|
52
52
|
if (n < 0) {
|
|
53
|
-
throw new
|
|
53
|
+
throw new LinqAPIV3Error(`${name} must be a positive integer`);
|
|
54
54
|
}
|
|
55
55
|
return n;
|
|
56
56
|
};
|
|
@@ -59,14 +59,14 @@ export const coerceInteger = (value: unknown): number => {
|
|
|
59
59
|
if (typeof value === 'number') return Math.round(value);
|
|
60
60
|
if (typeof value === 'string') return parseInt(value, 10);
|
|
61
61
|
|
|
62
|
-
throw new
|
|
62
|
+
throw new LinqAPIV3Error(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export const coerceFloat = (value: unknown): number => {
|
|
66
66
|
if (typeof value === 'number') return value;
|
|
67
67
|
if (typeof value === 'string') return parseFloat(value);
|
|
68
68
|
|
|
69
|
-
throw new
|
|
69
|
+
throw new LinqAPIV3Error(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
export const coerceBoolean = (value: unknown): boolean => {
|