@bunizao/contracts 0.22.0 → 0.23.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/dist/desk.d.ts +78 -0
- package/dist/desk.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -0
- package/dist/routes.d.ts +7 -0
- package/dist/routes.js +13 -1
- package/package.json +6 -1
package/dist/desk.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Mac power state as the reporter sees it. */
|
|
2
|
+
export declare const DESK_MAC_STATES: readonly ['on', 'locked', 'sleeping', 'paused'];
|
|
3
|
+
export type DeskMacState = (typeof DESK_MAC_STATES)[number];
|
|
4
|
+
/**
|
|
5
|
+
* An app on the desk. `label` is at most 24 letters, digits, spaces and dots;
|
|
6
|
+
* site-api turns anything else into "something else". `icon` is the
|
|
7
|
+
* lowercase hex sha256 of a PNG (at most 128 px a side) already uploaded to
|
|
8
|
+
* deskIconPath(icon), or null.
|
|
9
|
+
*/
|
|
10
|
+
export interface DeskApp {
|
|
11
|
+
label: string;
|
|
12
|
+
icon: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** Report body version the reporter sends; site-api rejects any other. */
|
|
15
|
+
export declare const DESK_REPORT_VERSION = 1;
|
|
16
|
+
/**
|
|
17
|
+
* Body of the owner-only, HMAC-signed POST to DESK_REPORT_PATH. The server
|
|
18
|
+
* ignores a report whose sentAt is not newer than the stored one, and
|
|
19
|
+
* computes expiry from its own clock plus ttl.
|
|
20
|
+
*/
|
|
21
|
+
export interface DeskReport {
|
|
22
|
+
v: typeof DESK_REPORT_VERSION;
|
|
23
|
+
/** Reporter clock, epoch milliseconds. Only used for ordering. */
|
|
24
|
+
sentAt: number;
|
|
25
|
+
mac: DeskMacState;
|
|
26
|
+
/** Seconds since the last keyboard or pointer input. */
|
|
27
|
+
idleSeconds: number;
|
|
28
|
+
/** True while an app holds a display-sleep assertion (video, a call). */
|
|
29
|
+
screenHeld: boolean;
|
|
30
|
+
/** Apps in use, most active first; `other` for an unlisted one. Never window titles or bundle ids. */
|
|
31
|
+
apps: DeskApp[];
|
|
32
|
+
/** IANA zone of the Mac, e.g. Australia/Melbourne. */
|
|
33
|
+
timeZone: string;
|
|
34
|
+
/** Seconds this report stays valid without a successor. */
|
|
35
|
+
ttl: number;
|
|
36
|
+
}
|
|
37
|
+
export declare const DESK_PRESENCE_STATES: readonly ['awake', 'idle', 'asleep', 'offline'];
|
|
38
|
+
export type DeskPresenceState = (typeof DESK_PRESENCE_STATES)[number];
|
|
39
|
+
export declare const DESK_SKIES: readonly ['clear', 'cloudy', 'fog', 'drizzle', 'rain', 'snow', 'storm'];
|
|
40
|
+
export type Sky = (typeof DESK_SKIES)[number];
|
|
41
|
+
export interface DeskPresence {
|
|
42
|
+
state: DeskPresenceState;
|
|
43
|
+
/** Empty unless awake or idle; an unlisted app reads "something else" with no icon. */
|
|
44
|
+
apps: DeskApp[];
|
|
45
|
+
/** Seconds of lease left when computed; null when offline or asleep. */
|
|
46
|
+
validFor: number | null;
|
|
47
|
+
}
|
|
48
|
+
export interface DeskPlace {
|
|
49
|
+
/** IANA zone the clock shows; the last pushed zone, or the default. */
|
|
50
|
+
timeZone: string;
|
|
51
|
+
/** City named by the zone; null when the zone names none (e.g. UTC). */
|
|
52
|
+
city: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface DeskWeather {
|
|
55
|
+
/** Degrees Celsius, rounded. */
|
|
56
|
+
temperature: number;
|
|
57
|
+
sky: Sky;
|
|
58
|
+
/** Daylight at the place right now. */
|
|
59
|
+
day: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Response of GET DESK_PATH. Fields are only ever added. */
|
|
62
|
+
export interface DeskNow {
|
|
63
|
+
presence: DeskPresence;
|
|
64
|
+
place: DeskPlace;
|
|
65
|
+
/** Null when the weather source is unavailable. */
|
|
66
|
+
weather: DeskWeather | null;
|
|
67
|
+
}
|
|
68
|
+
/** Close code the live socket uses when it is full; poll instead. */
|
|
69
|
+
export declare const DESK_LIVE_FULL_CLOSE_CODE = 1013;
|
|
70
|
+
/**
|
|
71
|
+
* Message the live socket at DESK_LIVE_PATH sends on connect and whenever
|
|
72
|
+
* presence or place changes. Weather is not pushed; read it from DESK_PATH.
|
|
73
|
+
* The socket answers the text `ping` with `pong`. Fields are only ever added.
|
|
74
|
+
*/
|
|
75
|
+
export interface DeskLive {
|
|
76
|
+
presence: DeskPresence;
|
|
77
|
+
place: DeskPlace;
|
|
78
|
+
}
|
package/dist/desk.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/desk.ts
|
|
2
|
+
var DESK_MAC_STATES = ["on", "locked", "sleeping", "paused"];
|
|
3
|
+
var DESK_REPORT_VERSION = 1;
|
|
4
|
+
var DESK_PRESENCE_STATES = ["awake", "idle", "asleep", "offline"];
|
|
5
|
+
var DESK_SKIES = ["clear", "cloudy", "fog", "drizzle", "rain", "snow", "storm"];
|
|
6
|
+
var DESK_LIVE_FULL_CLOSE_CODE = 1013;
|
|
7
|
+
export {
|
|
8
|
+
DESK_LIVE_FULL_CLOSE_CODE,
|
|
9
|
+
DESK_MAC_STATES,
|
|
10
|
+
DESK_PRESENCE_STATES,
|
|
11
|
+
DESK_REPORT_VERSION,
|
|
12
|
+
DESK_SKIES
|
|
13
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -145,6 +145,12 @@ function parsePostLocaleTag(tagName) {
|
|
|
145
145
|
}
|
|
146
146
|
return canonicalSlug ? { locale, canonicalSlug } : { locale };
|
|
147
147
|
}
|
|
148
|
+
// src/desk.ts
|
|
149
|
+
var DESK_MAC_STATES = ["on", "locked", "sleeping", "paused"];
|
|
150
|
+
var DESK_REPORT_VERSION = 1;
|
|
151
|
+
var DESK_PRESENCE_STATES = ["awake", "idle", "asleep", "offline"];
|
|
152
|
+
var DESK_SKIES = ["clear", "cloudy", "fog", "drizzle", "rain", "snow", "storm"];
|
|
153
|
+
var DESK_LIVE_FULL_CLOSE_CODE = 1013;
|
|
148
154
|
// src/messages.ts
|
|
149
155
|
var MESSAGE_LOCALES = ["zh", "en"];
|
|
150
156
|
var MESSAGE_MIN_BODY_LENGTH = 2;
|
|
@@ -205,6 +211,13 @@ var MOOD_SEARCH_PATH = "/v2/mood/search";
|
|
|
205
211
|
var MOOD_IMAGE_PROXY_BASE_PATH = "/v2/images";
|
|
206
212
|
var MOOD_MEDIA_PROXY_BASE_PATH = "/v2/media";
|
|
207
213
|
var LISTENING_PATH = "/v2/listening";
|
|
214
|
+
var DESK_PATH = "/v2/desk";
|
|
215
|
+
var DESK_LIVE_PATH = "/v2/desk/live";
|
|
216
|
+
var DESK_REPORT_PATH = "/v2/desk/report";
|
|
217
|
+
var DESK_ICONS_PATH = "/v2/desk/icons";
|
|
218
|
+
function deskIconPath(hash) {
|
|
219
|
+
return `${DESK_ICONS_PATH}/${hash}`;
|
|
220
|
+
}
|
|
208
221
|
var INSTAGRAM_PROFILE_PATH = "/v2/instagram";
|
|
209
222
|
var INSTAGRAM_AVATAR_PATH = "/v2/instagram/avatar";
|
|
210
223
|
var COMMENTS_PATH = "/v2/comments";
|
|
@@ -317,6 +330,15 @@ export {
|
|
|
317
330
|
CONTENT_DOCUMENT_SOURCES,
|
|
318
331
|
DEFAULT_COMMENT_POLICY,
|
|
319
332
|
DEFAULT_REACTION_EMOJI,
|
|
333
|
+
DESK_ICONS_PATH,
|
|
334
|
+
DESK_LIVE_FULL_CLOSE_CODE,
|
|
335
|
+
DESK_LIVE_PATH,
|
|
336
|
+
DESK_MAC_STATES,
|
|
337
|
+
DESK_PATH,
|
|
338
|
+
DESK_PRESENCE_STATES,
|
|
339
|
+
DESK_REPORT_PATH,
|
|
340
|
+
DESK_REPORT_VERSION,
|
|
341
|
+
DESK_SKIES,
|
|
320
342
|
EVENT_STATUSES,
|
|
321
343
|
GHOST_WEBHOOK_PATH,
|
|
322
344
|
HEALTH_PATH,
|
|
@@ -407,6 +429,7 @@ export {
|
|
|
407
429
|
avatarClass,
|
|
408
430
|
commentAnchorToken,
|
|
409
431
|
commentPolicyFromTags,
|
|
432
|
+
deskIconPath,
|
|
410
433
|
isAvatarSeed,
|
|
411
434
|
parsePostLocaleTag,
|
|
412
435
|
seedInClass,
|
package/dist/routes.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export declare const MOOD_SEARCH_PATH: '/v2/mood/search';
|
|
|
12
12
|
export declare const MOOD_IMAGE_PROXY_BASE_PATH: '/v2/images';
|
|
13
13
|
export declare const MOOD_MEDIA_PROXY_BASE_PATH: '/v2/media';
|
|
14
14
|
export declare const LISTENING_PATH: '/v2/listening';
|
|
15
|
+
export declare const DESK_PATH: '/v2/desk';
|
|
16
|
+
/** WebSocket upgrade; the server pushes DeskLive messages. */
|
|
17
|
+
export declare const DESK_LIVE_PATH: '/v2/desk/live';
|
|
18
|
+
export declare const DESK_REPORT_PATH: '/v2/desk/report';
|
|
19
|
+
/** PUT (owner-signed) and GET an app icon PNG by its sha256: `${DESK_ICONS_PATH}/<hash>`. */
|
|
20
|
+
export declare const DESK_ICONS_PATH: '/v2/desk/icons';
|
|
21
|
+
export declare function deskIconPath(hash: string): string;
|
|
15
22
|
export declare const INSTAGRAM_PROFILE_PATH: '/v2/instagram';
|
|
16
23
|
export declare const INSTAGRAM_AVATAR_PATH: '/v2/instagram/avatar';
|
|
17
24
|
export declare const COMMENTS_PATH: '/v2/comments';
|
package/dist/routes.js
CHANGED
|
@@ -13,6 +13,13 @@ var MOOD_SEARCH_PATH = "/v2/mood/search";
|
|
|
13
13
|
var MOOD_IMAGE_PROXY_BASE_PATH = "/v2/images";
|
|
14
14
|
var MOOD_MEDIA_PROXY_BASE_PATH = "/v2/media";
|
|
15
15
|
var LISTENING_PATH = "/v2/listening";
|
|
16
|
+
var DESK_PATH = "/v2/desk";
|
|
17
|
+
var DESK_LIVE_PATH = "/v2/desk/live";
|
|
18
|
+
var DESK_REPORT_PATH = "/v2/desk/report";
|
|
19
|
+
var DESK_ICONS_PATH = "/v2/desk/icons";
|
|
20
|
+
function deskIconPath(hash) {
|
|
21
|
+
return `${DESK_ICONS_PATH}/${hash}`;
|
|
22
|
+
}
|
|
16
23
|
var INSTAGRAM_PROFILE_PATH = "/v2/instagram";
|
|
17
24
|
var INSTAGRAM_AVATAR_PATH = "/v2/instagram/avatar";
|
|
18
25
|
var COMMENTS_PATH = "/v2/comments";
|
|
@@ -45,6 +52,10 @@ export {
|
|
|
45
52
|
API_PREFIX,
|
|
46
53
|
COMMENTS_PATH,
|
|
47
54
|
COMMENT_PATH_PREFIX,
|
|
55
|
+
DESK_ICONS_PATH,
|
|
56
|
+
DESK_LIVE_PATH,
|
|
57
|
+
DESK_PATH,
|
|
58
|
+
DESK_REPORT_PATH,
|
|
48
59
|
GHOST_WEBHOOK_PATH,
|
|
49
60
|
HEALTH_PATH,
|
|
50
61
|
INSTAGRAM_AVATAR_PATH,
|
|
@@ -81,5 +92,6 @@ export {
|
|
|
81
92
|
READER_PREFERENCES_PATH,
|
|
82
93
|
READER_RESEND_PATH,
|
|
83
94
|
READER_VERIFY_PATH,
|
|
84
|
-
TELEGRAM_WEBHOOK_PATH
|
|
95
|
+
TELEGRAM_WEBHOOK_PATH,
|
|
96
|
+
deskIconPath
|
|
85
97
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunizao/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Shared TypeScript contracts for buxx.me services and clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,6 +48,11 @@
|
|
|
48
48
|
"import": "./dist/content.js",
|
|
49
49
|
"default": "./dist/content.js"
|
|
50
50
|
},
|
|
51
|
+
"./desk": {
|
|
52
|
+
"types": "./dist/desk.d.ts",
|
|
53
|
+
"import": "./dist/desk.js",
|
|
54
|
+
"default": "./dist/desk.js"
|
|
55
|
+
},
|
|
51
56
|
"./instagram": {
|
|
52
57
|
"types": "./dist/instagram.d.ts",
|
|
53
58
|
"import": "./dist/instagram.js",
|