yoto-nodejs-client 0.0.1 → 0.0.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/README.md +523 -30
- package/bin/auth.js +36 -46
- package/bin/content.js +0 -0
- package/bin/device-model.d.ts +3 -0
- package/bin/device-model.d.ts.map +1 -0
- package/bin/device-model.js +360 -0
- package/bin/device-tui.TODO.md +125 -0
- package/bin/device-tui.d.ts +31 -0
- package/bin/device-tui.d.ts.map +1 -0
- package/bin/device-tui.js +1123 -0
- package/bin/devices.js +166 -28
- package/bin/groups.js +0 -0
- package/bin/icons.js +0 -0
- package/bin/lib/cli-helpers.d.ts +33 -1
- package/bin/lib/cli-helpers.d.ts.map +1 -1
- package/bin/lib/cli-helpers.js +5 -5
- package/bin/lib/token-helpers.d.ts +32 -0
- package/bin/lib/token-helpers.d.ts.map +1 -1
- package/bin/refresh-token.js +6 -6
- package/bin/token-info.js +3 -3
- package/index.d.ts +4 -217
- package/index.d.ts.map +1 -1
- package/index.js +11 -689
- package/lib/api-client.d.ts +576 -0
- package/lib/api-client.d.ts.map +1 -0
- package/lib/api-client.js +681 -0
- package/lib/api-endpoints/auth.d.ts +280 -4
- package/lib/api-endpoints/auth.d.ts.map +1 -1
- package/lib/api-endpoints/auth.js +224 -7
- package/lib/api-endpoints/auth.test.js +54 -2
- package/lib/api-endpoints/constants.d.ts +30 -2
- package/lib/api-endpoints/constants.d.ts.map +1 -1
- package/lib/api-endpoints/constants.js +17 -10
- package/lib/api-endpoints/content.d.ts +760 -0
- package/lib/api-endpoints/content.d.ts.map +1 -1
- package/lib/api-endpoints/content.test.js +1 -1
- package/lib/api-endpoints/devices.d.ts +917 -48
- package/lib/api-endpoints/devices.d.ts.map +1 -1
- package/lib/api-endpoints/devices.js +114 -52
- package/lib/api-endpoints/devices.test.js +1 -1
- package/lib/api-endpoints/endpoint-test-helpers.d.ts +28 -0
- package/lib/api-endpoints/endpoint-test-helpers.d.ts.map +1 -0
- package/lib/api-endpoints/family-library-groups.d.ts +187 -0
- package/lib/api-endpoints/family-library-groups.d.ts.map +1 -1
- package/lib/api-endpoints/family-library-groups.test.js +1 -1
- package/lib/api-endpoints/family.d.ts +88 -0
- package/lib/api-endpoints/family.d.ts.map +1 -1
- package/lib/api-endpoints/family.test.js +1 -1
- package/lib/api-endpoints/helpers.d.ts +37 -3
- package/lib/api-endpoints/helpers.d.ts.map +1 -1
- package/lib/api-endpoints/icons.d.ts +196 -0
- package/lib/api-endpoints/icons.d.ts.map +1 -1
- package/lib/api-endpoints/icons.test.js +1 -1
- package/lib/api-endpoints/media.d.ts +83 -0
- package/lib/api-endpoints/media.d.ts.map +1 -1
- package/lib/helpers/power-state.d.ts +53 -0
- package/lib/helpers/power-state.d.ts.map +1 -0
- package/lib/helpers/power-state.js +73 -0
- package/lib/helpers/power-state.test.js +100 -0
- package/lib/helpers/temperature.d.ts +24 -0
- package/lib/helpers/temperature.d.ts.map +1 -0
- package/lib/helpers/temperature.js +61 -0
- package/lib/helpers/temperature.test.js +58 -0
- package/lib/helpers/typed-keys.d.ts +7 -0
- package/lib/helpers/typed-keys.d.ts.map +1 -0
- package/lib/helpers/typed-keys.js +8 -0
- package/lib/mqtt/client.d.ts +610 -7
- package/lib/mqtt/client.d.ts.map +1 -1
- package/lib/mqtt/client.js +213 -31
- package/lib/mqtt/commands.d.ts +195 -0
- package/lib/mqtt/commands.d.ts.map +1 -1
- package/lib/mqtt/factory.d.ts +62 -1
- package/lib/mqtt/factory.d.ts.map +1 -1
- package/lib/mqtt/factory.js +27 -5
- package/lib/mqtt/mqtt.test.js +85 -28
- package/lib/mqtt/topics.d.ts +186 -1
- package/lib/mqtt/topics.d.ts.map +1 -1
- package/lib/mqtt/topics.js +54 -20
- package/lib/pkg.d.cts +9 -0
- package/lib/token.d.ts +106 -3
- package/lib/token.d.ts.map +1 -1
- package/lib/token.js +30 -23
- package/lib/yoto-account.d.ts +163 -0
- package/lib/yoto-account.d.ts.map +1 -0
- package/lib/yoto-account.js +340 -0
- package/lib/yoto-device.d.ts +656 -0
- package/lib/yoto-device.d.ts.map +1 -0
- package/lib/yoto-device.js +2850 -0
- package/package.json +22 -15
- package/lib/api-endpoints/test-helpers.d.ts +0 -7
- package/lib/api-endpoints/test-helpers.d.ts.map +0 -1
- /package/lib/api-endpoints/{test-helpers.js → endpoint-test-helpers.js} +0 -0
package/index.d.ts
CHANGED
|
@@ -1,218 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
responseType: "code" | "token" | "id_token" | "code token" | "code id_token" | "token id_token" | "code token id_token";
|
|
6
|
-
state: string;
|
|
7
|
-
audience?: string | undefined;
|
|
8
|
-
scope?: string | undefined;
|
|
9
|
-
nonce?: string | undefined;
|
|
10
|
-
prompt?: "none" | "login" | "consent" | "select_account" | undefined;
|
|
11
|
-
maxAge?: number | undefined;
|
|
12
|
-
codeChallenge?: string | undefined;
|
|
13
|
-
codeChallengeMethod?: "S256" | "plain" | undefined;
|
|
14
|
-
}): string;
|
|
15
|
-
static exchangeToken(params: {
|
|
16
|
-
grantType: "authorization_code" | "refresh_token" | "client_credentials" | "urn:ietf:params:oauth:grant-type:device_code";
|
|
17
|
-
code?: string | undefined;
|
|
18
|
-
redirectUri?: string | undefined;
|
|
19
|
-
refreshToken?: string | undefined;
|
|
20
|
-
clientId?: string | undefined;
|
|
21
|
-
clientSecret?: string | undefined;
|
|
22
|
-
scope?: string | undefined;
|
|
23
|
-
codeVerifier?: string | undefined;
|
|
24
|
-
deviceCode?: string | undefined;
|
|
25
|
-
audience?: string | undefined;
|
|
26
|
-
}): Promise<Auth.YotoTokenResponse>;
|
|
27
|
-
static requestDeviceCode(params: {
|
|
28
|
-
clientId: string;
|
|
29
|
-
scope?: string | undefined;
|
|
30
|
-
audience?: string | undefined;
|
|
31
|
-
}): Promise<Auth.YotoDeviceCodeResponse>;
|
|
32
|
-
constructor({ clientId, refreshToken, accessToken, onTokenRefresh, bufferSeconds, onRefreshStart, onRefreshError, onInvalid, userAgent, defaultRequestOptions }: YotoClientConstructorOptions);
|
|
33
|
-
get token(): RefreshableToken;
|
|
34
|
-
getContent({ cardId, timezone, signingType, playable, requestOptions }: {
|
|
35
|
-
cardId: string;
|
|
36
|
-
timezone?: string | undefined;
|
|
37
|
-
signingType?: "full" | "pre" | undefined;
|
|
38
|
-
playable?: boolean | undefined;
|
|
39
|
-
requestOptions?: ({
|
|
40
|
-
dispatcher?: import("undici").Dispatcher;
|
|
41
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
42
|
-
}): Promise<Content.YotoContentResponse>;
|
|
43
|
-
getUserMyoContent({ showDeleted, requestOptions }?: {
|
|
44
|
-
showDeleted?: boolean | undefined;
|
|
45
|
-
requestOptions?: ({
|
|
46
|
-
dispatcher?: import("undici").Dispatcher;
|
|
47
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
48
|
-
}): Promise<Content.YotoMyoContentResponse>;
|
|
49
|
-
createOrUpdateContent({ content, requestOptions }: {
|
|
50
|
-
content: Content.YotoCreateOrUpdateContentRequest;
|
|
51
|
-
requestOptions?: ({
|
|
52
|
-
dispatcher?: import("undici").Dispatcher;
|
|
53
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
54
|
-
}): Promise<Content.YotoCreateOrUpdateContentResponse>;
|
|
55
|
-
deleteContent({ cardId, requestOptions }: {
|
|
56
|
-
cardId: string;
|
|
57
|
-
requestOptions?: ({
|
|
58
|
-
dispatcher?: import("undici").Dispatcher;
|
|
59
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
60
|
-
}): Promise<Content.YotoDeleteContentResponse>;
|
|
61
|
-
getDevices({ requestOptions }?: {
|
|
62
|
-
requestOptions?: ({
|
|
63
|
-
dispatcher?: import("undici").Dispatcher;
|
|
64
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
65
|
-
}): Promise<Devices.YotoDevicesResponse>;
|
|
66
|
-
getDeviceStatus({ deviceId, requestOptions }: {
|
|
67
|
-
deviceId: string;
|
|
68
|
-
requestOptions?: ({
|
|
69
|
-
dispatcher?: import("undici").Dispatcher;
|
|
70
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
71
|
-
}): Promise<Devices.YotoDeviceStatusResponse>;
|
|
72
|
-
getDeviceConfig({ deviceId, requestOptions }: {
|
|
73
|
-
deviceId: string;
|
|
74
|
-
requestOptions?: ({
|
|
75
|
-
dispatcher?: import("undici").Dispatcher;
|
|
76
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
77
|
-
}): Promise<Devices.YotoDeviceConfigResponse>;
|
|
78
|
-
updateDeviceConfig({ deviceId, configUpdate, requestOptions }: {
|
|
79
|
-
deviceId: string;
|
|
80
|
-
configUpdate: Devices.YotoUpdateDeviceConfigRequest;
|
|
81
|
-
requestOptions?: ({
|
|
82
|
-
dispatcher?: import("undici").Dispatcher;
|
|
83
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
84
|
-
}): Promise<Devices.YotoUpdateDeviceConfigResponse>;
|
|
85
|
-
updateDeviceShortcuts({ deviceId, shortcutsUpdate, requestOptions }: {
|
|
86
|
-
deviceId: string;
|
|
87
|
-
shortcutsUpdate: Devices.YotoUpdateShortcutsRequest;
|
|
88
|
-
requestOptions?: ({
|
|
89
|
-
dispatcher?: import("undici").Dispatcher;
|
|
90
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
91
|
-
}): Promise<Devices.YotoUpdateShortcutsResponse>;
|
|
92
|
-
sendDeviceCommand({ deviceId, command, requestOptions }: {
|
|
93
|
-
deviceId: string;
|
|
94
|
-
command: Devices.YotoDeviceCommand;
|
|
95
|
-
requestOptions?: ({
|
|
96
|
-
dispatcher?: import("undici").Dispatcher;
|
|
97
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
98
|
-
}): Promise<Devices.YotoDeviceCommandResponse>;
|
|
99
|
-
getGroups({ requestOptions }?: {
|
|
100
|
-
requestOptions?: ({
|
|
101
|
-
dispatcher?: import("undici").Dispatcher;
|
|
102
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
103
|
-
}): Promise<FamilyLibraryGroups.YotoGroup[]>;
|
|
104
|
-
createGroup({ group, requestOptions }: {
|
|
105
|
-
group: FamilyLibraryGroups.YotoCreateGroupRequest;
|
|
106
|
-
requestOptions?: ({
|
|
107
|
-
dispatcher?: import("undici").Dispatcher;
|
|
108
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
109
|
-
}): Promise<FamilyLibraryGroups.YotoGroup>;
|
|
110
|
-
getGroup({ groupId, requestOptions }: {
|
|
111
|
-
groupId: string;
|
|
112
|
-
requestOptions?: ({
|
|
113
|
-
dispatcher?: import("undici").Dispatcher;
|
|
114
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
115
|
-
}): Promise<FamilyLibraryGroups.YotoGroup>;
|
|
116
|
-
updateGroup({ groupId, group, requestOptions }: {
|
|
117
|
-
groupId: string;
|
|
118
|
-
group: FamilyLibraryGroups.YotoUpdateGroupRequest;
|
|
119
|
-
requestOptions?: ({
|
|
120
|
-
dispatcher?: import("undici").Dispatcher;
|
|
121
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
122
|
-
}): Promise<FamilyLibraryGroups.YotoGroup>;
|
|
123
|
-
deleteGroup({ groupId, requestOptions }: {
|
|
124
|
-
groupId: string;
|
|
125
|
-
requestOptions?: ({
|
|
126
|
-
dispatcher?: import("undici").Dispatcher;
|
|
127
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
128
|
-
}): Promise<FamilyLibraryGroups.YotoDeleteGroupResponse>;
|
|
129
|
-
getFamilyImages({ requestOptions }?: {
|
|
130
|
-
requestOptions?: ({
|
|
131
|
-
dispatcher?: import("undici").Dispatcher;
|
|
132
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
133
|
-
}): Promise<Family.YotoFamilyImagesResponse>;
|
|
134
|
-
getAFamilyImage({ imageId, size, requestOptions }: {
|
|
135
|
-
imageId: string;
|
|
136
|
-
size: "640x480" | "320x320";
|
|
137
|
-
requestOptions?: ({
|
|
138
|
-
dispatcher?: import("undici").Dispatcher;
|
|
139
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
140
|
-
}): Promise<Family.YotoFamilyImageResponse>;
|
|
141
|
-
uploadAFamilyImage({ imageData, requestOptions }: {
|
|
142
|
-
imageData: Buffer;
|
|
143
|
-
requestOptions?: ({
|
|
144
|
-
dispatcher?: import("undici").Dispatcher;
|
|
145
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
146
|
-
}): Promise<Family.YotoUploadFamilyImageResponse>;
|
|
147
|
-
getPublicIcons({ requestOptions }?: {
|
|
148
|
-
requestOptions?: ({
|
|
149
|
-
dispatcher?: import("undici").Dispatcher;
|
|
150
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
151
|
-
}): Promise<Icons.YotoPublicIconsResponse>;
|
|
152
|
-
getUserIcons({ requestOptions }?: {
|
|
153
|
-
requestOptions?: ({
|
|
154
|
-
dispatcher?: import("undici").Dispatcher;
|
|
155
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
156
|
-
}): Promise<Icons.YotoUserIconsResponse>;
|
|
157
|
-
uploadIcon({ imageData, autoConvert, filename, requestOptions }: {
|
|
158
|
-
imageData: Buffer;
|
|
159
|
-
autoConvert?: boolean | undefined;
|
|
160
|
-
filename?: string | undefined;
|
|
161
|
-
requestOptions?: ({
|
|
162
|
-
dispatcher?: import("undici").Dispatcher;
|
|
163
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
164
|
-
}): Promise<Icons.YotoUploadIconResponse>;
|
|
165
|
-
getAudioUploadUrl({ sha256, filename, requestOptions }: {
|
|
166
|
-
sha256: string;
|
|
167
|
-
filename?: string | undefined;
|
|
168
|
-
requestOptions?: ({
|
|
169
|
-
dispatcher?: import("undici").Dispatcher;
|
|
170
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
171
|
-
}): Promise<Media.YotoAudioUploadUrlResponse>;
|
|
172
|
-
uploadCoverImage({ imageData, imageUrl, autoConvert, coverType, filename, requestOptions }: {
|
|
173
|
-
imageData?: Buffer<ArrayBufferLike> | undefined;
|
|
174
|
-
imageUrl?: string | undefined;
|
|
175
|
-
autoConvert?: boolean | undefined;
|
|
176
|
-
coverType?: Media.YotoCoverType | undefined;
|
|
177
|
-
filename?: string | undefined;
|
|
178
|
-
requestOptions?: ({
|
|
179
|
-
dispatcher?: import("undici").Dispatcher;
|
|
180
|
-
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
181
|
-
}): Promise<Media.YotoUploadCoverImageResponse>;
|
|
182
|
-
createMqttClient({ deviceId, options }: {
|
|
183
|
-
deviceId: string;
|
|
184
|
-
options?: {
|
|
185
|
-
autoSubscribe?: boolean | undefined;
|
|
186
|
-
} | undefined;
|
|
187
|
-
}): Promise<YotoMqttClient>;
|
|
188
|
-
#private;
|
|
189
|
-
}
|
|
190
|
-
export type RefreshSuccessEvent = {
|
|
191
|
-
clientId: string;
|
|
192
|
-
accessToken: string;
|
|
193
|
-
refreshToken: string;
|
|
194
|
-
expiresAt: number;
|
|
195
|
-
};
|
|
196
|
-
export type YotoClientConstructorOptions = {
|
|
197
|
-
clientId: string;
|
|
198
|
-
refreshToken: string;
|
|
199
|
-
accessToken: string;
|
|
200
|
-
onTokenRefresh: (event: RefreshSuccessEvent) => void | Promise<void>;
|
|
201
|
-
bufferSeconds?: number;
|
|
202
|
-
onRefreshStart?: () => void | Promise<void>;
|
|
203
|
-
onRefreshError?: (error: Error) => void | Promise<void>;
|
|
204
|
-
onInvalid?: (error: Error) => void | Promise<void>;
|
|
205
|
-
userAgent?: string;
|
|
206
|
-
defaultRequestOptions?: RequestOptions;
|
|
207
|
-
};
|
|
208
|
-
import { RefreshableToken } from './lib/token.js';
|
|
209
|
-
import * as Content from './lib/api-endpoints/content.js';
|
|
210
|
-
import * as Devices from './lib/api-endpoints/devices.js';
|
|
211
|
-
import * as FamilyLibraryGroups from './lib/api-endpoints/family-library-groups.js';
|
|
212
|
-
import * as Family from './lib/api-endpoints/family.js';
|
|
213
|
-
import * as Icons from './lib/api-endpoints/icons.js';
|
|
214
|
-
import * as Media from './lib/api-endpoints/media.js';
|
|
215
|
-
import type { YotoMqttClient } from './lib/mqtt/client.js';
|
|
216
|
-
import * as Auth from './lib/api-endpoints/auth.js';
|
|
217
|
-
import type { RequestOptions } from './lib/api-endpoints/helpers.js';
|
|
1
|
+
export { YotoClient } from "./lib/api-client.js";
|
|
2
|
+
export { YotoDeviceModel } from "./lib/yoto-device.js";
|
|
3
|
+
export { YotoAccount } from "./lib/yoto-account.js";
|
|
4
|
+
export { DEFAULT_CLIENT_ID, DEFAULT_AUDIENCE, DEFAULT_SCOPE, DEVICE_CODE_GRANT_TYPE } from "./lib/api-endpoints/constants.js";
|
|
218
5
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|