@bunizao/contracts 0.17.0 → 0.19.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/content.d.ts +1 -1
- package/dist/desk.d.ts +67 -0
- package/dist/desk.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -0
- package/dist/mood.d.ts +4 -2
- package/dist/routes.d.ts +5 -0
- package/dist/routes.js +11 -1
- package/package.json +6 -1
package/dist/content.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export interface ContentDocument {
|
|
|
91
91
|
forwardedFrom?: ForwardedFrom | null;
|
|
92
92
|
quote?: QuoteRef | null;
|
|
93
93
|
reactions?: Reaction[];
|
|
94
|
-
commentsCount?: number | string;
|
|
94
|
+
commentsCount?: number | string | null;
|
|
95
95
|
}
|
|
96
96
|
export interface MoodContentDocument extends ContentDocument {
|
|
97
97
|
source: 'mood';
|
package/dist/desk.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
package/dist/desk.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export {
|
|
7
|
+
DESK_MAC_STATES,
|
|
8
|
+
DESK_PRESENCE_STATES,
|
|
9
|
+
DESK_REPORT_VERSION,
|
|
10
|
+
DESK_SKIES
|
|
11
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -144,6 +144,11 @@ function parsePostLocaleTag(tagName) {
|
|
|
144
144
|
}
|
|
145
145
|
return canonicalSlug ? { locale, canonicalSlug } : { locale };
|
|
146
146
|
}
|
|
147
|
+
// src/desk.ts
|
|
148
|
+
var DESK_MAC_STATES = ["on", "locked", "sleeping", "paused"];
|
|
149
|
+
var DESK_REPORT_VERSION = 1;
|
|
150
|
+
var DESK_PRESENCE_STATES = ["awake", "idle", "asleep", "offline"];
|
|
151
|
+
var DESK_SKIES = ["clear", "cloudy", "fog", "drizzle", "rain", "snow", "storm"];
|
|
147
152
|
// src/messages.ts
|
|
148
153
|
var MESSAGE_LOCALES = ["zh", "en"];
|
|
149
154
|
var MESSAGE_MIN_BODY_LENGTH = 2;
|
|
@@ -172,6 +177,12 @@ var MOOD_SEARCH_PATH = "/v2/mood/search";
|
|
|
172
177
|
var MOOD_IMAGE_PROXY_BASE_PATH = "/v2/images";
|
|
173
178
|
var MOOD_MEDIA_PROXY_BASE_PATH = "/v2/media";
|
|
174
179
|
var LISTENING_PATH = "/v2/listening";
|
|
180
|
+
var DESK_PATH = "/v2/desk";
|
|
181
|
+
var DESK_REPORT_PATH = "/v2/desk/report";
|
|
182
|
+
var DESK_ICONS_PATH = "/v2/desk/icons";
|
|
183
|
+
function deskIconPath(hash) {
|
|
184
|
+
return `${DESK_ICONS_PATH}/${hash}`;
|
|
185
|
+
}
|
|
175
186
|
var INSTAGRAM_PROFILE_PATH = "/v2/instagram";
|
|
176
187
|
var INSTAGRAM_AVATAR_PATH = "/v2/instagram/avatar";
|
|
177
188
|
var COMMENTS_PATH = "/v2/comments";
|
|
@@ -284,6 +295,13 @@ export {
|
|
|
284
295
|
CONTENT_DOCUMENT_SOURCES,
|
|
285
296
|
DEFAULT_COMMENT_POLICY,
|
|
286
297
|
DEFAULT_REACTION_EMOJI,
|
|
298
|
+
DESK_ICONS_PATH,
|
|
299
|
+
DESK_MAC_STATES,
|
|
300
|
+
DESK_PATH,
|
|
301
|
+
DESK_PRESENCE_STATES,
|
|
302
|
+
DESK_REPORT_PATH,
|
|
303
|
+
DESK_REPORT_VERSION,
|
|
304
|
+
DESK_SKIES,
|
|
287
305
|
EVENT_STATUSES,
|
|
288
306
|
GHOST_WEBHOOK_PATH,
|
|
289
307
|
HEALTH_PATH,
|
|
@@ -372,6 +390,7 @@ export {
|
|
|
372
390
|
avatarClass,
|
|
373
391
|
commentAnchorToken,
|
|
374
392
|
commentPolicyFromTags,
|
|
393
|
+
deskIconPath,
|
|
375
394
|
isAvatarSeed,
|
|
376
395
|
parsePostLocaleTag,
|
|
377
396
|
seedInClass,
|
package/dist/mood.d.ts
CHANGED
|
@@ -128,7 +128,9 @@ export interface MoodFeedItem {
|
|
|
128
128
|
forwardedFrom: MoodForwardedFrom | null;
|
|
129
129
|
quote: MoodQuote | null;
|
|
130
130
|
reactions: MoodReaction[];
|
|
131
|
-
|
|
131
|
+
/** Null when unknown: the archive keeps no comment count, since comments
|
|
132
|
+
are live only (see MoodLiveCount). */
|
|
133
|
+
commentsCount: number | string | null;
|
|
132
134
|
}
|
|
133
135
|
export interface MoodData {
|
|
134
136
|
id: string;
|
|
@@ -151,7 +153,7 @@ export interface MoodData {
|
|
|
151
153
|
forwardedFrom?: ForwardedFromData | null;
|
|
152
154
|
quote?: QuoteData | null;
|
|
153
155
|
reactions?: ReactionData[];
|
|
154
|
-
commentsCount?: number | string;
|
|
156
|
+
commentsCount?: number | string | null;
|
|
155
157
|
}
|
|
156
158
|
export interface MoodFeedResponse {
|
|
157
159
|
posts: MoodFeedItem[];
|
package/dist/routes.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ 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
|
+
export declare const DESK_REPORT_PATH: '/v2/desk/report';
|
|
17
|
+
/** PUT (owner-signed) and GET an app icon PNG by its sha256: `${DESK_ICONS_PATH}/<hash>`. */
|
|
18
|
+
export declare const DESK_ICONS_PATH: '/v2/desk/icons';
|
|
19
|
+
export declare function deskIconPath(hash: string): string;
|
|
15
20
|
export declare const INSTAGRAM_PROFILE_PATH: '/v2/instagram';
|
|
16
21
|
export declare const INSTAGRAM_AVATAR_PATH: '/v2/instagram/avatar';
|
|
17
22
|
export declare const COMMENTS_PATH: '/v2/comments';
|
package/dist/routes.js
CHANGED
|
@@ -13,6 +13,12 @@ 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_REPORT_PATH = "/v2/desk/report";
|
|
18
|
+
var DESK_ICONS_PATH = "/v2/desk/icons";
|
|
19
|
+
function deskIconPath(hash) {
|
|
20
|
+
return `${DESK_ICONS_PATH}/${hash}`;
|
|
21
|
+
}
|
|
16
22
|
var INSTAGRAM_PROFILE_PATH = "/v2/instagram";
|
|
17
23
|
var INSTAGRAM_AVATAR_PATH = "/v2/instagram/avatar";
|
|
18
24
|
var COMMENTS_PATH = "/v2/comments";
|
|
@@ -45,6 +51,9 @@ export {
|
|
|
45
51
|
API_PREFIX,
|
|
46
52
|
COMMENTS_PATH,
|
|
47
53
|
COMMENT_PATH_PREFIX,
|
|
54
|
+
DESK_ICONS_PATH,
|
|
55
|
+
DESK_PATH,
|
|
56
|
+
DESK_REPORT_PATH,
|
|
48
57
|
GHOST_WEBHOOK_PATH,
|
|
49
58
|
HEALTH_PATH,
|
|
50
59
|
INSTAGRAM_AVATAR_PATH,
|
|
@@ -81,5 +90,6 @@ export {
|
|
|
81
90
|
READER_PREFERENCES_PATH,
|
|
82
91
|
READER_RESEND_PATH,
|
|
83
92
|
READER_VERIFY_PATH,
|
|
84
|
-
TELEGRAM_WEBHOOK_PATH
|
|
93
|
+
TELEGRAM_WEBHOOK_PATH,
|
|
94
|
+
deskIconPath
|
|
85
95
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunizao/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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",
|