@mobilerun/sdk 5.2.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/client.d.mts +13 -7
- package/client.d.mts.map +1 -1
- package/client.d.ts +13 -7
- package/client.d.ts.map +1 -1
- package/client.js +9 -3
- package/client.js.map +1 -1
- package/client.mjs +9 -3
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +33 -0
- package/core/streaming.d.mts.map +1 -0
- package/core/streaming.d.ts +33 -0
- package/core/streaming.d.ts.map +1 -0
- package/core/streaming.js +263 -0
- package/core/streaming.js.map +1 -0
- package/core/streaming.mjs +258 -0
- package/core/streaming.mjs.map +1 -0
- package/internal/decoders/line.d.mts +17 -0
- package/internal/decoders/line.d.mts.map +1 -0
- package/internal/decoders/line.d.ts +17 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +113 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +108 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +10 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +10 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +2 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +2 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/tslib.js +18 -18
- package/package.json +11 -1
- package/resources/apps.d.mts +2 -2
- package/resources/apps.d.mts.map +1 -1
- package/resources/apps.d.ts +2 -2
- package/resources/apps.d.ts.map +1 -1
- package/resources/assistant/assistant.d.mts +10 -0
- package/resources/assistant/assistant.d.mts.map +1 -0
- package/resources/assistant/assistant.d.ts +10 -0
- package/resources/assistant/assistant.d.ts.map +1 -0
- package/resources/assistant/assistant.js +17 -0
- package/resources/assistant/assistant.js.map +1 -0
- package/resources/assistant/assistant.mjs +12 -0
- package/resources/assistant/assistant.mjs.map +1 -0
- package/resources/assistant/conversations.d.mts +295 -0
- package/resources/assistant/conversations.d.mts.map +1 -0
- package/resources/assistant/conversations.d.ts +295 -0
- package/resources/assistant/conversations.d.ts.map +1 -0
- package/resources/assistant/conversations.js +109 -0
- package/resources/assistant/conversations.js.map +1 -0
- package/resources/assistant/conversations.mjs +105 -0
- package/resources/assistant/conversations.mjs.map +1 -0
- package/resources/assistant/index.d.mts +3 -0
- package/resources/assistant/index.d.mts.map +1 -0
- package/resources/assistant/index.d.ts +3 -0
- package/resources/assistant/index.d.ts.map +1 -0
- package/resources/assistant/index.js +9 -0
- package/resources/assistant/index.js.map +1 -0
- package/resources/assistant/index.mjs +4 -0
- package/resources/assistant/index.mjs.map +1 -0
- package/resources/assistant.d.mts +2 -0
- package/resources/assistant.d.mts.map +1 -0
- package/resources/assistant.d.ts +2 -0
- package/resources/assistant.d.ts.map +1 -0
- package/resources/assistant.js +6 -0
- package/resources/assistant.js.map +1 -0
- package/resources/assistant.mjs +3 -0
- package/resources/assistant.mjs.map +1 -0
- package/resources/devices/clipboard.d.mts +40 -0
- package/resources/devices/clipboard.d.mts.map +1 -0
- package/resources/devices/clipboard.d.ts +40 -0
- package/resources/devices/clipboard.d.ts.map +1 -0
- package/resources/devices/clipboard.js +50 -0
- package/resources/devices/clipboard.js.map +1 -0
- package/resources/devices/clipboard.mjs +46 -0
- package/resources/devices/clipboard.mjs.map +1 -0
- package/resources/devices/devices.d.mts +5 -0
- package/resources/devices/devices.d.mts.map +1 -1
- package/resources/devices/devices.d.ts +5 -0
- package/resources/devices/devices.d.ts.map +1 -1
- package/resources/devices/devices.js +4 -0
- package/resources/devices/devices.js.map +1 -1
- package/resources/devices/devices.mjs +4 -0
- package/resources/devices/devices.mjs.map +1 -1
- package/resources/devices/index.d.mts +1 -0
- package/resources/devices/index.d.mts.map +1 -1
- package/resources/devices/index.d.ts +1 -0
- package/resources/devices/index.d.ts.map +1 -1
- package/resources/devices/index.js +3 -1
- package/resources/devices/index.js.map +1 -1
- package/resources/devices/index.mjs +1 -0
- package/resources/devices/index.mjs.map +1 -1
- package/resources/esims/esims.d.mts +45 -45
- package/resources/esims/esims.d.mts.map +1 -1
- package/resources/esims/esims.d.ts +45 -45
- package/resources/esims/esims.d.ts.map +1 -1
- package/resources/esims/esims.js +3 -3
- package/resources/esims/esims.js.map +1 -1
- package/resources/esims/esims.mjs +3 -3
- package/resources/esims/esims.mjs.map +1 -1
- package/resources/esims/index.d.mts +1 -1
- package/resources/esims/index.d.mts.map +1 -1
- package/resources/esims/index.d.ts +1 -1
- package/resources/esims/index.d.ts.map +1 -1
- package/resources/esims/index.js.map +1 -1
- package/resources/esims/index.mjs.map +1 -1
- package/resources/esims/messages.d.mts +15 -20
- package/resources/esims/messages.d.mts.map +1 -1
- package/resources/esims/messages.d.ts +15 -20
- package/resources/esims/messages.d.ts.map +1 -1
- package/resources/files.d.mts +126 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +126 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +68 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +64 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +5 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +5 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +7 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -1
- package/resources/index.mjs.map +1 -1
- package/resources/mailboxes/index.d.mts +3 -0
- package/resources/mailboxes/index.d.mts.map +1 -0
- package/resources/mailboxes/index.d.ts +3 -0
- package/resources/mailboxes/index.d.ts.map +1 -0
- package/resources/mailboxes/index.js +9 -0
- package/resources/mailboxes/index.js.map +1 -0
- package/resources/mailboxes/index.mjs +4 -0
- package/resources/mailboxes/index.mjs.map +1 -0
- package/resources/mailboxes/mailboxes.d.mts +366 -0
- package/resources/mailboxes/mailboxes.d.mts.map +1 -0
- package/resources/mailboxes/mailboxes.d.ts +366 -0
- package/resources/mailboxes/mailboxes.d.ts.map +1 -0
- package/resources/mailboxes/mailboxes.js +146 -0
- package/resources/mailboxes/mailboxes.js.map +1 -0
- package/resources/mailboxes/mailboxes.mjs +141 -0
- package/resources/mailboxes/mailboxes.mjs.map +1 -0
- package/resources/mailboxes/messages.d.mts +82 -0
- package/resources/mailboxes/messages.d.mts.map +1 -0
- package/resources/mailboxes/messages.d.ts +82 -0
- package/resources/mailboxes/messages.d.ts.map +1 -0
- package/resources/mailboxes/messages.js +39 -0
- package/resources/mailboxes/messages.js.map +1 -0
- package/resources/mailboxes/messages.mjs +35 -0
- package/resources/mailboxes/messages.mjs.map +1 -0
- package/resources/mailboxes.d.mts +2 -0
- package/resources/mailboxes.d.mts.map +1 -0
- package/resources/mailboxes.d.ts +2 -0
- package/resources/mailboxes.d.ts.map +1 -0
- package/resources/mailboxes.js +6 -0
- package/resources/mailboxes.js.map +1 -0
- package/resources/mailboxes.mjs +3 -0
- package/resources/mailboxes.mjs.map +1 -0
- package/resources/messages/conversations.d.mts +18 -23
- package/resources/messages/conversations.d.mts.map +1 -1
- package/resources/messages/conversations.d.ts +18 -23
- package/resources/messages/conversations.d.ts.map +1 -1
- package/resources/messages/messages.d.mts +15 -20
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +15 -20
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/models.d.mts +20 -5
- package/resources/models.d.mts.map +1 -1
- package/resources/models.d.ts +20 -5
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +1 -1
- package/resources/models.mjs +1 -1
- package/resources/numbers/index.d.mts +1 -1
- package/resources/numbers/index.d.mts.map +1 -1
- package/resources/numbers/index.d.ts +1 -1
- package/resources/numbers/index.d.ts.map +1 -1
- package/resources/numbers/index.js.map +1 -1
- package/resources/numbers/index.mjs.map +1 -1
- package/resources/numbers/messages.d.mts +15 -27
- package/resources/numbers/messages.d.mts.map +1 -1
- package/resources/numbers/messages.d.ts +15 -27
- package/resources/numbers/messages.d.ts.map +1 -1
- package/resources/numbers/messages.js.map +1 -1
- package/resources/numbers/messages.mjs.map +1 -1
- package/resources/numbers/numbers.d.mts +70 -22
- package/resources/numbers/numbers.d.mts.map +1 -1
- package/resources/numbers/numbers.d.ts +70 -22
- package/resources/numbers/numbers.d.ts.map +1 -1
- package/resources/numbers/numbers.js +17 -0
- package/resources/numbers/numbers.js.map +1 -1
- package/resources/numbers/numbers.mjs +17 -0
- package/resources/numbers/numbers.mjs.map +1 -1
- package/resources/store/apps.d.mts +2 -2
- package/resources/store/apps.d.mts.map +1 -1
- package/resources/store/apps.d.ts +2 -2
- package/resources/store/apps.d.ts.map +1 -1
- package/resources/workflows/events.d.mts +1 -0
- package/resources/workflows/events.d.mts.map +1 -1
- package/resources/workflows/events.d.ts +1 -0
- package/resources/workflows/events.d.ts.map +1 -1
- package/resources/workflows/executions.d.mts +21 -0
- package/resources/workflows/executions.d.mts.map +1 -1
- package/resources/workflows/executions.d.ts +21 -0
- package/resources/workflows/executions.d.ts.map +1 -1
- package/resources/workflows/flows/flows.d.mts +8 -0
- package/resources/workflows/flows/flows.d.mts.map +1 -1
- package/resources/workflows/flows/flows.d.ts +8 -0
- package/resources/workflows/flows/flows.d.ts.map +1 -1
- package/resources/workflows/flows/flows.js.map +1 -1
- package/resources/workflows/flows/flows.mjs.map +1 -1
- package/src/client.ts +74 -4
- package/src/core/streaming.ts +315 -0
- package/src/internal/decoders/line.ts +135 -0
- package/src/internal/parse.ts +14 -0
- package/src/internal/request-options.ts +2 -0
- package/src/resources/apps.ts +2 -2
- package/src/resources/assistant/assistant.ts +59 -0
- package/src/resources/assistant/conversations.ts +524 -0
- package/src/resources/assistant/index.ts +26 -0
- package/src/resources/assistant.ts +3 -0
- package/src/resources/devices/clipboard.ts +87 -0
- package/src/resources/devices/devices.ts +13 -0
- package/src/resources/devices/index.ts +6 -0
- package/src/resources/esims/esims.ts +63 -57
- package/src/resources/esims/index.ts +1 -0
- package/src/resources/esims/messages.ts +24 -30
- package/src/resources/files.ts +225 -0
- package/src/resources/index.ts +33 -1
- package/src/resources/mailboxes/index.ts +26 -0
- package/src/resources/mailboxes/mailboxes.ts +618 -0
- package/src/resources/mailboxes/messages.ts +134 -0
- package/src/resources/mailboxes.ts +3 -0
- package/src/resources/messages/conversations.ts +28 -34
- package/src/resources/messages/messages.ts +24 -30
- package/src/resources/models.ts +22 -7
- package/src/resources/numbers/index.ts +2 -0
- package/src/resources/numbers/messages.ts +24 -43
- package/src/resources/numbers/numbers.ts +97 -21
- package/src/resources/store/apps.ts +2 -2
- package/src/resources/workflows/events.ts +2 -0
- package/src/resources/workflows/executions.ts +27 -0
- package/src/resources/workflows/flows/flows.ts +16 -0
- package/src/streaming.ts +2 -0
- package/src/version.ts +1 -1
- package/streaming.d.mts +3 -0
- package/streaming.d.mts.map +1 -0
- package/streaming.d.ts +3 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +6 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +3 -0
- package/streaming.mjs.map +1 -0
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/agents.d.mts +0 -27
- package/resources/agents.d.mts.map +0 -1
- package/resources/agents.d.ts +0 -27
- package/resources/agents.d.ts.map +0 -1
- package/resources/agents.js +0 -15
- package/resources/agents.js.map +0 -1
- package/resources/agents.mjs +0 -11
- package/resources/agents.mjs.map +0 -1
- package/src/resources/agents.ts +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.mjs","sourceRoot":"","sources":["../../../src/resources/workflows/flows/flows.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAErD,OAAO,KAAK,UAAU,sBAAkB;AACxC,O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IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,UAAU,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,MAAc,EAAE,OAAwB;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,UAAU,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;CACF;AAsuBD,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC"}
|
package/src/client.ts
CHANGED
|
@@ -17,7 +17,6 @@ import * as Errors from './core/error';
|
|
|
17
17
|
import * as Uploads from './core/uploads';
|
|
18
18
|
import * as API from './resources/index';
|
|
19
19
|
import { APIPromise } from './core/api-promise';
|
|
20
|
-
import { AgentListResponse, Agents } from './resources/agents';
|
|
21
20
|
import {
|
|
22
21
|
AppConfirmUploadResponse,
|
|
23
22
|
AppCreateSignedUploadURLParams,
|
|
@@ -44,6 +43,18 @@ import {
|
|
|
44
43
|
CarrierUpdateResponse,
|
|
45
44
|
Carriers,
|
|
46
45
|
} from './resources/carriers';
|
|
46
|
+
import {
|
|
47
|
+
FileCancelPendingResponse,
|
|
48
|
+
FileConfirmResponse,
|
|
49
|
+
FileDeleteResponse,
|
|
50
|
+
FileListParams,
|
|
51
|
+
FileListResponse,
|
|
52
|
+
FileUpdateParams,
|
|
53
|
+
FileUpdateResponse,
|
|
54
|
+
FileUploadURLParams,
|
|
55
|
+
FileUploadURLResponse,
|
|
56
|
+
Files,
|
|
57
|
+
} from './resources/files';
|
|
47
58
|
import { ModelListResponse, Models } from './resources/models';
|
|
48
59
|
import {
|
|
49
60
|
NotificationCatalogResponse,
|
|
@@ -82,6 +93,7 @@ import {
|
|
|
82
93
|
AppEventRetrieveResponse,
|
|
83
94
|
AppEvents,
|
|
84
95
|
} from './resources/app-events/app-events';
|
|
96
|
+
import { Assistant } from './resources/assistant/assistant';
|
|
85
97
|
import { Connect } from './resources/connect/connect';
|
|
86
98
|
import {
|
|
87
99
|
CredentialListParams,
|
|
@@ -117,11 +129,29 @@ import {
|
|
|
117
129
|
EsimListParams,
|
|
118
130
|
EsimListResponse,
|
|
119
131
|
EsimRetrieveResponse,
|
|
132
|
+
EsimSelectorParams,
|
|
120
133
|
EsimSelectorResponse,
|
|
121
134
|
EsimUpdateParams,
|
|
122
135
|
EsimUpdateResponse,
|
|
123
136
|
Esims,
|
|
124
137
|
} from './resources/esims/esims';
|
|
138
|
+
import {
|
|
139
|
+
MailboxCapacityResponse,
|
|
140
|
+
MailboxCreateParams,
|
|
141
|
+
MailboxCreateResponse,
|
|
142
|
+
MailboxDeleteResponse,
|
|
143
|
+
MailboxListParams,
|
|
144
|
+
MailboxListResponse,
|
|
145
|
+
MailboxOtpParams,
|
|
146
|
+
MailboxOtpResponse,
|
|
147
|
+
MailboxRestartParams,
|
|
148
|
+
MailboxRestartResponse,
|
|
149
|
+
MailboxRetrieveResponse,
|
|
150
|
+
MailboxUncancelResponse,
|
|
151
|
+
MailboxUpdateParams,
|
|
152
|
+
MailboxUpdateResponse,
|
|
153
|
+
Mailboxes,
|
|
154
|
+
} from './resources/mailboxes/mailboxes';
|
|
125
155
|
import { MessageListParams, MessageListResponse, Messages } from './resources/messages/messages';
|
|
126
156
|
import {
|
|
127
157
|
NumberCountriesResponse,
|
|
@@ -132,6 +162,8 @@ import {
|
|
|
132
162
|
NumberListResponse,
|
|
133
163
|
NumberPurposesResponse,
|
|
134
164
|
NumberRetrieveResponse,
|
|
165
|
+
NumberUpdateParams,
|
|
166
|
+
NumberUpdateResponse,
|
|
135
167
|
Numbers,
|
|
136
168
|
} from './resources/numbers/numbers';
|
|
137
169
|
import { Store, StoreCategoriesResponse } from './resources/store/store';
|
|
@@ -904,7 +936,9 @@ export class Mobilerun {
|
|
|
904
936
|
tasks: API.Tasks = new API.Tasks(this);
|
|
905
937
|
workflows: API.Workflows = new API.Workflows(this);
|
|
906
938
|
webhooks: API.Webhooks = new API.Webhooks(this);
|
|
907
|
-
|
|
939
|
+
mailboxes: API.Mailboxes = new API.Mailboxes(this);
|
|
940
|
+
files: API.Files = new API.Files(this);
|
|
941
|
+
assistant: API.Assistant = new API.Assistant(this);
|
|
908
942
|
appEvents: API.AppEvents = new API.AppEvents(this);
|
|
909
943
|
notifications: API.Notifications = new API.Notifications(this);
|
|
910
944
|
esims: API.Esims = new API.Esims(this);
|
|
@@ -924,7 +958,9 @@ Mobilerun.Connect = Connect;
|
|
|
924
958
|
Mobilerun.Tasks = Tasks;
|
|
925
959
|
Mobilerun.Workflows = Workflows;
|
|
926
960
|
Mobilerun.Webhooks = Webhooks;
|
|
927
|
-
Mobilerun.
|
|
961
|
+
Mobilerun.Mailboxes = Mailboxes;
|
|
962
|
+
Mobilerun.Files = Files;
|
|
963
|
+
Mobilerun.Assistant = Assistant;
|
|
928
964
|
Mobilerun.AppEvents = AppEvents;
|
|
929
965
|
Mobilerun.Notifications = Notifications;
|
|
930
966
|
Mobilerun.Esims = Esims;
|
|
@@ -1048,7 +1084,38 @@ export declare namespace Mobilerun {
|
|
|
1048
1084
|
type WebhookListParams as WebhookListParams,
|
|
1049
1085
|
};
|
|
1050
1086
|
|
|
1051
|
-
export {
|
|
1087
|
+
export {
|
|
1088
|
+
Mailboxes as Mailboxes,
|
|
1089
|
+
type MailboxCreateResponse as MailboxCreateResponse,
|
|
1090
|
+
type MailboxRetrieveResponse as MailboxRetrieveResponse,
|
|
1091
|
+
type MailboxUpdateResponse as MailboxUpdateResponse,
|
|
1092
|
+
type MailboxListResponse as MailboxListResponse,
|
|
1093
|
+
type MailboxDeleteResponse as MailboxDeleteResponse,
|
|
1094
|
+
type MailboxCapacityResponse as MailboxCapacityResponse,
|
|
1095
|
+
type MailboxOtpResponse as MailboxOtpResponse,
|
|
1096
|
+
type MailboxRestartResponse as MailboxRestartResponse,
|
|
1097
|
+
type MailboxUncancelResponse as MailboxUncancelResponse,
|
|
1098
|
+
type MailboxCreateParams as MailboxCreateParams,
|
|
1099
|
+
type MailboxUpdateParams as MailboxUpdateParams,
|
|
1100
|
+
type MailboxListParams as MailboxListParams,
|
|
1101
|
+
type MailboxOtpParams as MailboxOtpParams,
|
|
1102
|
+
type MailboxRestartParams as MailboxRestartParams,
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
export {
|
|
1106
|
+
Files as Files,
|
|
1107
|
+
type FileUpdateResponse as FileUpdateResponse,
|
|
1108
|
+
type FileListResponse as FileListResponse,
|
|
1109
|
+
type FileDeleteResponse as FileDeleteResponse,
|
|
1110
|
+
type FileCancelPendingResponse as FileCancelPendingResponse,
|
|
1111
|
+
type FileConfirmResponse as FileConfirmResponse,
|
|
1112
|
+
type FileUploadURLResponse as FileUploadURLResponse,
|
|
1113
|
+
type FileUpdateParams as FileUpdateParams,
|
|
1114
|
+
type FileListParams as FileListParams,
|
|
1115
|
+
type FileUploadURLParams as FileUploadURLParams,
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
export { Assistant as Assistant };
|
|
1052
1119
|
|
|
1053
1120
|
export {
|
|
1054
1121
|
AppEvents as AppEvents,
|
|
@@ -1082,6 +1149,7 @@ export declare namespace Mobilerun {
|
|
|
1082
1149
|
type EsimListParams as EsimListParams,
|
|
1083
1150
|
type EsimImportParams as EsimImportParams,
|
|
1084
1151
|
type EsimInstallParams as EsimInstallParams,
|
|
1152
|
+
type EsimSelectorParams as EsimSelectorParams,
|
|
1085
1153
|
};
|
|
1086
1154
|
|
|
1087
1155
|
export {
|
|
@@ -1094,11 +1162,13 @@ export declare namespace Mobilerun {
|
|
|
1094
1162
|
Numbers as Numbers,
|
|
1095
1163
|
type NumberCreateResponse as NumberCreateResponse,
|
|
1096
1164
|
type NumberRetrieveResponse as NumberRetrieveResponse,
|
|
1165
|
+
type NumberUpdateResponse as NumberUpdateResponse,
|
|
1097
1166
|
type NumberListResponse as NumberListResponse,
|
|
1098
1167
|
type NumberDeleteResponse as NumberDeleteResponse,
|
|
1099
1168
|
type NumberCountriesResponse as NumberCountriesResponse,
|
|
1100
1169
|
type NumberPurposesResponse as NumberPurposesResponse,
|
|
1101
1170
|
type NumberCreateParams as NumberCreateParams,
|
|
1171
|
+
type NumberUpdateParams as NumberUpdateParams,
|
|
1102
1172
|
type NumberListParams as NumberListParams,
|
|
1103
1173
|
};
|
|
1104
1174
|
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { MobilerunError } from './error';
|
|
2
|
+
import { type ReadableStream } from '../internal/shim-types';
|
|
3
|
+
import { makeReadableStream } from '../internal/shims';
|
|
4
|
+
import { findDoubleNewlineIndex, LineDecoder } from '../internal/decoders/line';
|
|
5
|
+
import { ReadableStreamToAsyncIterable } from '../internal/shims';
|
|
6
|
+
import { isAbortError } from '../internal/errors';
|
|
7
|
+
import { encodeUTF8 } from '../internal/utils/bytes';
|
|
8
|
+
import { loggerFor } from '../internal/utils/log';
|
|
9
|
+
import type { Mobilerun } from '../client';
|
|
10
|
+
|
|
11
|
+
type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
|
|
12
|
+
|
|
13
|
+
export type ServerSentEvent = {
|
|
14
|
+
event: string | null;
|
|
15
|
+
data: string;
|
|
16
|
+
raw: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class Stream<Item> implements AsyncIterable<Item> {
|
|
20
|
+
controller: AbortController;
|
|
21
|
+
#client: Mobilerun | undefined;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
private iterator: () => AsyncIterator<Item>,
|
|
25
|
+
controller: AbortController,
|
|
26
|
+
client?: Mobilerun,
|
|
27
|
+
) {
|
|
28
|
+
this.controller = controller;
|
|
29
|
+
this.#client = client;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static fromSSEResponse<Item>(
|
|
33
|
+
response: Response,
|
|
34
|
+
controller: AbortController,
|
|
35
|
+
client?: Mobilerun,
|
|
36
|
+
): Stream<Item> {
|
|
37
|
+
let consumed = false;
|
|
38
|
+
const logger = client ? loggerFor(client) : console;
|
|
39
|
+
|
|
40
|
+
async function* iterator(): AsyncIterator<Item, any, undefined> {
|
|
41
|
+
if (consumed) {
|
|
42
|
+
throw new MobilerunError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
43
|
+
}
|
|
44
|
+
consumed = true;
|
|
45
|
+
let done = false;
|
|
46
|
+
try {
|
|
47
|
+
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
48
|
+
try {
|
|
49
|
+
yield JSON.parse(sse.data) as Item;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
52
|
+
logger.error(`From chunk:`, sse.raw);
|
|
53
|
+
throw e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
done = true;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
59
|
+
if (isAbortError(e)) return;
|
|
60
|
+
throw e;
|
|
61
|
+
} finally {
|
|
62
|
+
// If the user `break`s, abort the ongoing request.
|
|
63
|
+
if (!done) controller.abort();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return new Stream(iterator, controller, client);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
72
|
+
* where each item is a JSON value.
|
|
73
|
+
*/
|
|
74
|
+
static fromReadableStream<Item>(
|
|
75
|
+
readableStream: ReadableStream,
|
|
76
|
+
controller: AbortController,
|
|
77
|
+
client?: Mobilerun,
|
|
78
|
+
): Stream<Item> {
|
|
79
|
+
let consumed = false;
|
|
80
|
+
|
|
81
|
+
async function* iterLines(): AsyncGenerator<string, void, unknown> {
|
|
82
|
+
const lineDecoder = new LineDecoder();
|
|
83
|
+
|
|
84
|
+
const iter = ReadableStreamToAsyncIterable<Bytes>(readableStream);
|
|
85
|
+
for await (const chunk of iter) {
|
|
86
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
87
|
+
yield line;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (const line of lineDecoder.flush()) {
|
|
92
|
+
yield line;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function* iterator(): AsyncIterator<Item, any, undefined> {
|
|
97
|
+
if (consumed) {
|
|
98
|
+
throw new MobilerunError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
99
|
+
}
|
|
100
|
+
consumed = true;
|
|
101
|
+
let done = false;
|
|
102
|
+
try {
|
|
103
|
+
for await (const line of iterLines()) {
|
|
104
|
+
if (done) continue;
|
|
105
|
+
if (line) yield JSON.parse(line) as Item;
|
|
106
|
+
}
|
|
107
|
+
done = true;
|
|
108
|
+
} catch (e) {
|
|
109
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
110
|
+
if (isAbortError(e)) return;
|
|
111
|
+
throw e;
|
|
112
|
+
} finally {
|
|
113
|
+
// If the user `break`s, abort the ongoing request.
|
|
114
|
+
if (!done) controller.abort();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return new Stream(iterator, controller, client);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
[Symbol.asyncIterator](): AsyncIterator<Item> {
|
|
122
|
+
return this.iterator();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Splits the stream into two streams which can be
|
|
127
|
+
* independently read from at different speeds.
|
|
128
|
+
*/
|
|
129
|
+
tee(): [Stream<Item>, Stream<Item>] {
|
|
130
|
+
const left: Array<Promise<IteratorResult<Item>>> = [];
|
|
131
|
+
const right: Array<Promise<IteratorResult<Item>>> = [];
|
|
132
|
+
const iterator = this.iterator();
|
|
133
|
+
|
|
134
|
+
const teeIterator = (queue: Array<Promise<IteratorResult<Item>>>): AsyncIterator<Item> => {
|
|
135
|
+
return {
|
|
136
|
+
next: () => {
|
|
137
|
+
if (queue.length === 0) {
|
|
138
|
+
const result = iterator.next();
|
|
139
|
+
left.push(result);
|
|
140
|
+
right.push(result);
|
|
141
|
+
}
|
|
142
|
+
return queue.shift()!;
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return [
|
|
148
|
+
new Stream(() => teeIterator(left), this.controller, this.#client),
|
|
149
|
+
new Stream(() => teeIterator(right), this.controller, this.#client),
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
155
|
+
* JSON stringified values in the stream
|
|
156
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
157
|
+
*/
|
|
158
|
+
toReadableStream(): ReadableStream {
|
|
159
|
+
const self = this;
|
|
160
|
+
let iter: AsyncIterator<Item>;
|
|
161
|
+
|
|
162
|
+
return makeReadableStream({
|
|
163
|
+
async start() {
|
|
164
|
+
iter = self[Symbol.asyncIterator]();
|
|
165
|
+
},
|
|
166
|
+
async pull(ctrl: any) {
|
|
167
|
+
try {
|
|
168
|
+
const { value, done } = await iter.next();
|
|
169
|
+
if (done) return ctrl.close();
|
|
170
|
+
|
|
171
|
+
const bytes = encodeUTF8(JSON.stringify(value) + '\n');
|
|
172
|
+
|
|
173
|
+
ctrl.enqueue(bytes);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
ctrl.error(err);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
async cancel() {
|
|
179
|
+
await iter.return?.();
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export async function* _iterSSEMessages(
|
|
186
|
+
response: Response,
|
|
187
|
+
controller: AbortController,
|
|
188
|
+
): AsyncGenerator<ServerSentEvent, void, unknown> {
|
|
189
|
+
if (!response.body) {
|
|
190
|
+
controller.abort();
|
|
191
|
+
if (
|
|
192
|
+
typeof (globalThis as any).navigator !== 'undefined' &&
|
|
193
|
+
(globalThis as any).navigator.product === 'ReactNative'
|
|
194
|
+
) {
|
|
195
|
+
throw new MobilerunError(
|
|
196
|
+
`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
throw new MobilerunError(`Attempted to iterate over a response with no body`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const sseDecoder = new SSEDecoder();
|
|
203
|
+
const lineDecoder = new LineDecoder();
|
|
204
|
+
|
|
205
|
+
const iter = ReadableStreamToAsyncIterable<Bytes>(response.body);
|
|
206
|
+
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
207
|
+
for (const line of lineDecoder.decode(sseChunk)) {
|
|
208
|
+
const sse = sseDecoder.decode(line);
|
|
209
|
+
if (sse) yield sse;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
for (const line of lineDecoder.flush()) {
|
|
214
|
+
const sse = sseDecoder.decode(line);
|
|
215
|
+
if (sse) yield sse;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Given an async iterable iterator, iterates over it and yields full
|
|
221
|
+
* SSE chunks, i.e. yields when a double new-line is encountered.
|
|
222
|
+
*/
|
|
223
|
+
async function* iterSSEChunks(iterator: AsyncIterableIterator<Bytes>): AsyncGenerator<Uint8Array> {
|
|
224
|
+
let data = new Uint8Array();
|
|
225
|
+
|
|
226
|
+
for await (const chunk of iterator) {
|
|
227
|
+
if (chunk == null) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const binaryChunk =
|
|
232
|
+
chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
233
|
+
: typeof chunk === 'string' ? encodeUTF8(chunk)
|
|
234
|
+
: chunk;
|
|
235
|
+
|
|
236
|
+
let newData = new Uint8Array(data.length + binaryChunk.length);
|
|
237
|
+
newData.set(data);
|
|
238
|
+
newData.set(binaryChunk, data.length);
|
|
239
|
+
data = newData;
|
|
240
|
+
|
|
241
|
+
let patternIndex;
|
|
242
|
+
while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
|
|
243
|
+
yield data.slice(0, patternIndex);
|
|
244
|
+
data = data.slice(patternIndex);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (data.length > 0) {
|
|
249
|
+
yield data;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
class SSEDecoder {
|
|
254
|
+
private data: string[];
|
|
255
|
+
private event: string | null;
|
|
256
|
+
private chunks: string[];
|
|
257
|
+
|
|
258
|
+
constructor() {
|
|
259
|
+
this.event = null;
|
|
260
|
+
this.data = [];
|
|
261
|
+
this.chunks = [];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
decode(line: string) {
|
|
265
|
+
if (line.endsWith('\r')) {
|
|
266
|
+
line = line.substring(0, line.length - 1);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!line) {
|
|
270
|
+
// empty line and we didn't previously encounter any messages
|
|
271
|
+
if (!this.event && !this.data.length) return null;
|
|
272
|
+
|
|
273
|
+
const sse: ServerSentEvent = {
|
|
274
|
+
event: this.event,
|
|
275
|
+
data: this.data.join('\n'),
|
|
276
|
+
raw: this.chunks,
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
this.event = null;
|
|
280
|
+
this.data = [];
|
|
281
|
+
this.chunks = [];
|
|
282
|
+
|
|
283
|
+
return sse;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.chunks.push(line);
|
|
287
|
+
|
|
288
|
+
if (line.startsWith(':')) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
293
|
+
|
|
294
|
+
if (value.startsWith(' ')) {
|
|
295
|
+
value = value.substring(1);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (fieldname === 'event') {
|
|
299
|
+
this.event = value;
|
|
300
|
+
} else if (fieldname === 'data') {
|
|
301
|
+
this.data.push(value);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function partition(str: string, delimiter: string): [string, string, string] {
|
|
309
|
+
const index = str.indexOf(delimiter);
|
|
310
|
+
if (index !== -1) {
|
|
311
|
+
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return [str, '', ''];
|
|
315
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { concatBytes, decodeUTF8, encodeUTF8 } from '../utils/bytes';
|
|
2
|
+
|
|
3
|
+
export type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
7
|
+
* reading lines from text.
|
|
8
|
+
*
|
|
9
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
10
|
+
*/
|
|
11
|
+
export class LineDecoder {
|
|
12
|
+
// prettier-ignore
|
|
13
|
+
static NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
14
|
+
static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
15
|
+
|
|
16
|
+
#buffer: Uint8Array;
|
|
17
|
+
#carriageReturnIndex: number | null;
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
this.#buffer = new Uint8Array();
|
|
21
|
+
this.#carriageReturnIndex = null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
decode(chunk: Bytes): string[] {
|
|
25
|
+
if (chunk == null) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const binaryChunk =
|
|
30
|
+
chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
31
|
+
: typeof chunk === 'string' ? encodeUTF8(chunk)
|
|
32
|
+
: chunk;
|
|
33
|
+
|
|
34
|
+
this.#buffer = concatBytes([this.#buffer, binaryChunk]);
|
|
35
|
+
|
|
36
|
+
const lines: string[] = [];
|
|
37
|
+
let patternIndex;
|
|
38
|
+
while ((patternIndex = findNewlineIndex(this.#buffer, this.#carriageReturnIndex)) != null) {
|
|
39
|
+
if (patternIndex.carriage && this.#carriageReturnIndex == null) {
|
|
40
|
+
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
41
|
+
this.#carriageReturnIndex = patternIndex.index;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// we got double \r or \rtext\n
|
|
46
|
+
if (
|
|
47
|
+
this.#carriageReturnIndex != null &&
|
|
48
|
+
(patternIndex.index !== this.#carriageReturnIndex + 1 || patternIndex.carriage)
|
|
49
|
+
) {
|
|
50
|
+
lines.push(decodeUTF8(this.#buffer.subarray(0, this.#carriageReturnIndex - 1)));
|
|
51
|
+
this.#buffer = this.#buffer.subarray(this.#carriageReturnIndex);
|
|
52
|
+
this.#carriageReturnIndex = null;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const endIndex =
|
|
57
|
+
this.#carriageReturnIndex !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
58
|
+
|
|
59
|
+
const line = decodeUTF8(this.#buffer.subarray(0, endIndex));
|
|
60
|
+
lines.push(line);
|
|
61
|
+
|
|
62
|
+
this.#buffer = this.#buffer.subarray(patternIndex.index);
|
|
63
|
+
this.#carriageReturnIndex = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
flush(): string[] {
|
|
70
|
+
if (!this.#buffer.length) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
return this.decode('\n');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* This function searches the buffer for the end patterns, (\r or \n)
|
|
79
|
+
* and returns an object with the index preceding the matched newline and the
|
|
80
|
+
* index after the newline char. `null` is returned if no new line is found.
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function findNewlineIndex(
|
|
87
|
+
buffer: Uint8Array,
|
|
88
|
+
startIndex: number | null,
|
|
89
|
+
): { preceding: number; index: number; carriage: boolean } | null {
|
|
90
|
+
const newline = 0x0a; // \n
|
|
91
|
+
const carriage = 0x0d; // \r
|
|
92
|
+
|
|
93
|
+
for (let i = startIndex ?? 0; i < buffer.length; i++) {
|
|
94
|
+
if (buffer[i] === newline) {
|
|
95
|
+
return { preceding: i, index: i + 1, carriage: false };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (buffer[i] === carriage) {
|
|
99
|
+
return { preceding: i, index: i + 1, carriage: true };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function findDoubleNewlineIndex(buffer: Uint8Array): number {
|
|
107
|
+
// This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
|
|
108
|
+
// and returns the index right after the first occurrence of any pattern,
|
|
109
|
+
// or -1 if none of the patterns are found.
|
|
110
|
+
const newline = 0x0a; // \n
|
|
111
|
+
const carriage = 0x0d; // \r
|
|
112
|
+
|
|
113
|
+
for (let i = 0; i < buffer.length - 1; i++) {
|
|
114
|
+
if (buffer[i] === newline && buffer[i + 1] === newline) {
|
|
115
|
+
// \n\n
|
|
116
|
+
return i + 2;
|
|
117
|
+
}
|
|
118
|
+
if (buffer[i] === carriage && buffer[i + 1] === carriage) {
|
|
119
|
+
// \r\r
|
|
120
|
+
return i + 2;
|
|
121
|
+
}
|
|
122
|
+
if (
|
|
123
|
+
buffer[i] === carriage &&
|
|
124
|
+
buffer[i + 1] === newline &&
|
|
125
|
+
i + 3 < buffer.length &&
|
|
126
|
+
buffer[i + 2] === carriage &&
|
|
127
|
+
buffer[i + 3] === newline
|
|
128
|
+
) {
|
|
129
|
+
// \r\n\r\n
|
|
130
|
+
return i + 4;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
package/src/internal/parse.ts
CHANGED
|
@@ -1,6 +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 { Stream } from '../core/streaming';
|
|
4
5
|
import { type Mobilerun } from '../client';
|
|
5
6
|
import { formatRequestDetails, loggerFor } from './utils/log';
|
|
6
7
|
|
|
@@ -16,6 +17,19 @@ export type APIResponseProps = {
|
|
|
16
17
|
export async function defaultParseResponse<T>(client: Mobilerun, props: APIResponseProps): Promise<T> {
|
|
17
18
|
const { response, requestLogID, retryOfRequestLogID, startTime } = props;
|
|
18
19
|
const body = await (async () => {
|
|
20
|
+
if (props.options.stream) {
|
|
21
|
+
loggerFor(client).debug('response', response.status, response.url, response.headers, response.body);
|
|
22
|
+
|
|
23
|
+
// Note: there is an invariant here that isn't represented in the type system
|
|
24
|
+
// that if you set `stream: true` the response type must also be `Stream<T>`
|
|
25
|
+
|
|
26
|
+
if (props.options.__streamClass) {
|
|
27
|
+
return props.options.__streamClass.fromSSEResponse(response, props.controller, client) as any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return Stream.fromSSEResponse(response, props.controller, client) as any;
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
// fetch refuses to read the body when the status code is 204.
|
|
20
34
|
if (response.status === 204) {
|
|
21
35
|
return null as T;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { NullableHeaders } from './headers';
|
|
4
4
|
|
|
5
5
|
import type { BodyInit } from './builtin-types';
|
|
6
|
+
import { Stream } from '../core/streaming';
|
|
6
7
|
import type { HTTPMethod, MergedRequestInit } from './types';
|
|
7
8
|
import { type HeadersLike } from './headers';
|
|
8
9
|
|
|
@@ -76,6 +77,7 @@ export type RequestOptions = {
|
|
|
76
77
|
defaultBaseURL?: string | undefined;
|
|
77
78
|
|
|
78
79
|
__binaryResponse?: boolean | undefined;
|
|
80
|
+
__streamClass?: typeof Stream;
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
|
package/src/resources/apps.ts
CHANGED
|
@@ -471,7 +471,7 @@ export namespace AppListResponse {
|
|
|
471
471
|
|
|
472
472
|
sizeBytes: number | null;
|
|
473
473
|
|
|
474
|
-
source: 'user' | 'system' | 'portal' | 'store';
|
|
474
|
+
source: 'user' | 'system' | 'portal' | 'store' | 'catalog';
|
|
475
475
|
|
|
476
476
|
status: 'queued' | 'available' | 'failed';
|
|
477
477
|
|
|
@@ -802,7 +802,7 @@ export namespace AppListVersionsResponse {
|
|
|
802
802
|
|
|
803
803
|
sizeBytes: number | null;
|
|
804
804
|
|
|
805
|
-
source: 'user' | 'system' | 'portal' | 'store';
|
|
805
|
+
source: 'user' | 'system' | 'portal' | 'store' | 'catalog';
|
|
806
806
|
|
|
807
807
|
status: 'queued' | 'available' | 'failed';
|
|
808
808
|
|