@linqapp/sdk 0.1.0 → 0.1.4
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 +46 -0
- package/LICENSE +198 -4
- package/README.md +52 -52
- package/client.d.mts +35 -22
- package/client.d.mts.map +1 -1
- package/client.d.ts +35 -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/tslib.js +6 -6
- 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 +129 -663
- package/resources/chats/chats.d.mts.map +1 -1
- package/resources/chats/chats.d.ts +129 -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 +56 -716
- package/resources/chats/messages.d.mts.map +1 -1
- package/resources/chats/messages.d.ts +56 -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 +9 -5
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +9 -5
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +11 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +6 -2
- package/resources/index.mjs.map +1 -1
- package/resources/messages.d.mts +156 -544
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +156 -544
- 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/shared.d.mts +5 -0
- package/resources/shared.d.mts.map +1 -0
- package/resources/shared.d.ts +5 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/{webhooks.js → shared.js} +1 -3
- package/resources/shared.js.map +1 -0
- package/{src/resources/webhooks.ts → resources/shared.mjs} +2 -2
- package/resources/shared.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 +130 -771
- package/src/resources/chats/index.ts +3 -2
- package/src/resources/chats/messages.ts +61 -839
- package/src/resources/index.ts +29 -9
- package/src/resources/messages.ts +186 -642
- package/src/resources/phone-numbers.ts +1 -65
- package/src/resources/phonenumbers.ts +72 -0
- package/src/resources/shared.ts +6 -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.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/client.ts
CHANGED
|
@@ -21,34 +21,53 @@ 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,
|
|
50
70
|
} from './resources/chats/chats';
|
|
51
|
-
import { Webhooks } from './resources/webhooks/webhooks';
|
|
52
71
|
import { type Fetch } from './internal/builtin-types';
|
|
53
72
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
54
73
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -64,14 +83,17 @@ import { isEmptyObj } from './internal/utils/values';
|
|
|
64
83
|
|
|
65
84
|
export interface ClientOptions {
|
|
66
85
|
/**
|
|
67
|
-
*
|
|
86
|
+
* Bearer token authentication. Include your API token in the Authorization header.
|
|
87
|
+
*
|
|
88
|
+
* Format: `Authorization: Bearer <your-token>`
|
|
89
|
+
*
|
|
68
90
|
*/
|
|
69
91
|
apiKey?: string | undefined;
|
|
70
92
|
|
|
71
93
|
/**
|
|
72
94
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
73
95
|
*
|
|
74
|
-
* Defaults to process.env['
|
|
96
|
+
* Defaults to process.env['LINQ_API_V3_BASE_URL'].
|
|
75
97
|
*/
|
|
76
98
|
baseURL?: string | null | undefined;
|
|
77
99
|
|
|
@@ -125,7 +147,7 @@ export interface ClientOptions {
|
|
|
125
147
|
/**
|
|
126
148
|
* Set the log level.
|
|
127
149
|
*
|
|
128
|
-
* Defaults to process.env['
|
|
150
|
+
* Defaults to process.env['LINQ_API_V3_LOG'] or 'warn' if it isn't set.
|
|
129
151
|
*/
|
|
130
152
|
logLevel?: LogLevel | undefined;
|
|
131
153
|
|
|
@@ -138,9 +160,9 @@ export interface ClientOptions {
|
|
|
138
160
|
}
|
|
139
161
|
|
|
140
162
|
/**
|
|
141
|
-
* API Client for interfacing with the Linq API.
|
|
163
|
+
* API Client for interfacing with the Linq API V3 API.
|
|
142
164
|
*/
|
|
143
|
-
export class
|
|
165
|
+
export class LinqAPIV3 {
|
|
144
166
|
apiKey: string;
|
|
145
167
|
|
|
146
168
|
baseURL: string;
|
|
@@ -156,10 +178,10 @@ export class Linq {
|
|
|
156
178
|
private _options: ClientOptions;
|
|
157
179
|
|
|
158
180
|
/**
|
|
159
|
-
* API Client for interfacing with the Linq API.
|
|
181
|
+
* API Client for interfacing with the Linq API V3 API.
|
|
160
182
|
*
|
|
161
|
-
* @param {string | undefined} [opts.apiKey=process.env['
|
|
162
|
-
* @param {string} [opts.baseURL=process.env['
|
|
183
|
+
* @param {string | undefined} [opts.apiKey=process.env['LINQ_API_V3_API_KEY'] ?? undefined]
|
|
184
|
+
* @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
185
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
164
186
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
165
187
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -168,13 +190,13 @@ export class Linq {
|
|
|
168
190
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
169
191
|
*/
|
|
170
192
|
constructor({
|
|
171
|
-
baseURL = readEnv('
|
|
172
|
-
apiKey = readEnv('
|
|
193
|
+
baseURL = readEnv('LINQ_API_V3_BASE_URL'),
|
|
194
|
+
apiKey = readEnv('LINQ_API_V3_API_KEY'),
|
|
173
195
|
...opts
|
|
174
196
|
}: ClientOptions = {}) {
|
|
175
197
|
if (apiKey === undefined) {
|
|
176
|
-
throw new Errors.
|
|
177
|
-
"The
|
|
198
|
+
throw new Errors.LinqAPIV3Error(
|
|
199
|
+
"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
200
|
);
|
|
179
201
|
}
|
|
180
202
|
|
|
@@ -185,14 +207,14 @@ export class Linq {
|
|
|
185
207
|
};
|
|
186
208
|
|
|
187
209
|
this.baseURL = options.baseURL!;
|
|
188
|
-
this.timeout = options.timeout ??
|
|
210
|
+
this.timeout = options.timeout ?? LinqAPIV3.DEFAULT_TIMEOUT /* 1 minute */;
|
|
189
211
|
this.logger = options.logger ?? console;
|
|
190
212
|
const defaultLogLevel = 'warn';
|
|
191
213
|
// Set default logLevel early so that we can log a warning in parseLogLevel.
|
|
192
214
|
this.logLevel = defaultLogLevel;
|
|
193
215
|
this.logLevel =
|
|
194
216
|
parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ??
|
|
195
|
-
parseLogLevel(readEnv('
|
|
217
|
+
parseLogLevel(readEnv('LINQ_API_V3_LOG'), "process.env['LINQ_API_V3_LOG']", this) ??
|
|
196
218
|
defaultLogLevel;
|
|
197
219
|
this.fetchOptions = options.fetchOptions;
|
|
198
220
|
this.maxRetries = options.maxRetries ?? 2;
|
|
@@ -255,7 +277,7 @@ export class Linq {
|
|
|
255
277
|
if (value === null) {
|
|
256
278
|
return `${encodeURIComponent(key)}=`;
|
|
257
279
|
}
|
|
258
|
-
throw new Errors.
|
|
280
|
+
throw new Errors.LinqAPIV3Error(
|
|
259
281
|
`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
282
|
);
|
|
261
283
|
})
|
|
@@ -742,10 +764,10 @@ export class Linq {
|
|
|
742
764
|
}
|
|
743
765
|
}
|
|
744
766
|
|
|
745
|
-
static
|
|
767
|
+
static LinqAPIV3 = this;
|
|
746
768
|
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
747
769
|
|
|
748
|
-
static
|
|
770
|
+
static LinqAPIV3Error = Errors.LinqAPIV3Error;
|
|
749
771
|
static APIError = Errors.APIError;
|
|
750
772
|
static APIConnectionError = Errors.APIConnectionError;
|
|
751
773
|
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
@@ -764,24 +786,30 @@ export class Linq {
|
|
|
764
786
|
chats: API.Chats = new API.Chats(this);
|
|
765
787
|
messages: API.Messages = new API.Messages(this);
|
|
766
788
|
attachments: API.Attachments = new API.Attachments(this);
|
|
789
|
+
phonenumbers: API.Phonenumbers = new API.Phonenumbers(this);
|
|
767
790
|
phoneNumbers: API.PhoneNumbers = new API.PhoneNumbers(this);
|
|
768
|
-
|
|
791
|
+
webhookEvents: API.WebhookEvents = new API.WebhookEvents(this);
|
|
792
|
+
webhookSubscriptions: API.WebhookSubscriptions = new API.WebhookSubscriptions(this);
|
|
793
|
+
capability: API.Capability = new API.Capability(this);
|
|
769
794
|
}
|
|
770
795
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
796
|
+
LinqAPIV3.Chats = Chats;
|
|
797
|
+
LinqAPIV3.Messages = Messages;
|
|
798
|
+
LinqAPIV3.Attachments = Attachments;
|
|
799
|
+
LinqAPIV3.Phonenumbers = Phonenumbers;
|
|
800
|
+
LinqAPIV3.PhoneNumbers = PhoneNumbers;
|
|
801
|
+
LinqAPIV3.WebhookEvents = WebhookEvents;
|
|
802
|
+
LinqAPIV3.WebhookSubscriptions = WebhookSubscriptions;
|
|
803
|
+
LinqAPIV3.Capability = Capability;
|
|
776
804
|
|
|
777
|
-
export declare namespace
|
|
805
|
+
export declare namespace LinqAPIV3 {
|
|
778
806
|
export type RequestOptions = Opts.RequestOptions;
|
|
779
807
|
|
|
780
808
|
export {
|
|
781
809
|
Chats as Chats,
|
|
810
|
+
type Chat as Chat,
|
|
811
|
+
type MessageContent as MessageContent,
|
|
782
812
|
type ChatCreateResponse as ChatCreateResponse,
|
|
783
|
-
type ChatRetrieveResponse as ChatRetrieveResponse,
|
|
784
|
-
type ChatUpdateResponse as ChatUpdateResponse,
|
|
785
813
|
type ChatListResponse as ChatListResponse,
|
|
786
814
|
type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
|
|
787
815
|
type ChatCreateParams as ChatCreateParams,
|
|
@@ -792,8 +820,14 @@ export declare namespace Linq {
|
|
|
792
820
|
|
|
793
821
|
export {
|
|
794
822
|
Messages as Messages,
|
|
795
|
-
type
|
|
796
|
-
type
|
|
823
|
+
type ChatHandle as ChatHandle,
|
|
824
|
+
type MediaPart as MediaPart,
|
|
825
|
+
type Message as Message,
|
|
826
|
+
type MessageEffect as MessageEffect,
|
|
827
|
+
type Reaction as Reaction,
|
|
828
|
+
type ReactionType as ReactionType,
|
|
829
|
+
type ReplyTo as ReplyTo,
|
|
830
|
+
type TextPart as TextPart,
|
|
797
831
|
type MessageRetrieveThreadResponse as MessageRetrieveThreadResponse,
|
|
798
832
|
type MessageDeleteParams as MessageDeleteParams,
|
|
799
833
|
type MessageAddReactionParams as MessageAddReactionParams,
|
|
@@ -802,16 +836,38 @@ export declare namespace Linq {
|
|
|
802
836
|
|
|
803
837
|
export {
|
|
804
838
|
Attachments as Attachments,
|
|
839
|
+
type SupportedContentType as SupportedContentType,
|
|
805
840
|
type AttachmentCreateResponse as AttachmentCreateResponse,
|
|
806
841
|
type AttachmentRetrieveResponse as AttachmentRetrieveResponse,
|
|
807
842
|
type AttachmentCreateParams as AttachmentCreateParams,
|
|
808
843
|
};
|
|
809
844
|
|
|
845
|
+
export { Phonenumbers as Phonenumbers, type PhonenumberListResponse as PhonenumberListResponse };
|
|
846
|
+
|
|
847
|
+
export { PhoneNumbers as PhoneNumbers, type PhoneNumberListResponse as PhoneNumberListResponse };
|
|
848
|
+
|
|
849
|
+
export {
|
|
850
|
+
WebhookEvents as WebhookEvents,
|
|
851
|
+
type WebhookEventType as WebhookEventType,
|
|
852
|
+
type WebhookEventListResponse as WebhookEventListResponse,
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
export {
|
|
856
|
+
WebhookSubscriptions as WebhookSubscriptions,
|
|
857
|
+
type WebhookSubscription as WebhookSubscription,
|
|
858
|
+
type WebhookSubscriptionCreateResponse as WebhookSubscriptionCreateResponse,
|
|
859
|
+
type WebhookSubscriptionListResponse as WebhookSubscriptionListResponse,
|
|
860
|
+
type WebhookSubscriptionCreateParams as WebhookSubscriptionCreateParams,
|
|
861
|
+
type WebhookSubscriptionUpdateParams as WebhookSubscriptionUpdateParams,
|
|
862
|
+
};
|
|
863
|
+
|
|
810
864
|
export {
|
|
811
|
-
|
|
812
|
-
type
|
|
813
|
-
type
|
|
865
|
+
Capability as Capability,
|
|
866
|
+
type CapabilityCheckImessageResponse as CapabilityCheckImessageResponse,
|
|
867
|
+
type CapabilityCheckRcsResponse as CapabilityCheckRcsResponse,
|
|
868
|
+
type CapabilityCheckImessageParams as CapabilityCheckImessageParams,
|
|
869
|
+
type CapabilityCheckRcsParams as CapabilityCheckRcsParams,
|
|
814
870
|
};
|
|
815
871
|
|
|
816
|
-
export
|
|
872
|
+
export type ServiceType = API.ServiceType;
|
|
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 => {
|