@bunizao/contracts 0.19.0 → 0.21.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.
@@ -210,7 +210,7 @@ export declare const SITE_ANALYTICS_COLLECT_ENDPOINT: '/api/analytics/collect';
210
210
  export declare const SITE_ANALYTICS_REPORT_ENDPOINT: '/api/analytics/site';
211
211
  export declare const SITE_ANALYTICS_ENGAGED_DWELL_MS = 10000;
212
212
  export declare const SITE_ANALYTICS_SESSION_IDLE_MS: number;
213
- export declare const SITE_ANALYTICS_SURFACES: readonly ['home', 'legacy', 'not_found', 'blog_index', 'blog_tags', 'blog_tag', 'blog_post', 'mood_feed', 'mood_post', 'mood_embed', 'projects', 'message', 'privacy', 'subscribe_manage', 'reader', 'docs', 'components', 'other'];
213
+ export declare const SITE_ANALYTICS_SURFACES: readonly ['home', 'legacy', 'not_found', 'blog_index', 'blog_tags', 'blog_tag', 'blog_post', 'mood_feed', 'mood_post', 'mood_embed', 'mood_year', 'projects', 'message', 'privacy', 'subscribe_manage', 'reader', 'docs', 'components', 'other'];
214
214
  export type SiteAnalyticsSurface = typeof SITE_ANALYTICS_SURFACES[number];
215
215
  export type SiteAnalyticsClickKind = 'link_internal' | 'link_outbound' | 'button' | 'panel';
216
216
  export type SiteAnalyticsTrafficClass = 'human' | 'bot' | 'owner';
package/dist/analytics.js CHANGED
@@ -25,6 +25,7 @@ var SITE_ANALYTICS_SURFACES = [
25
25
  "mood_feed",
26
26
  "mood_post",
27
27
  "mood_embed",
28
+ "mood_year",
28
29
  "projects",
29
30
  "message",
30
31
  "privacy",
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ export * from './analytics';
2
2
  export * from './admin';
3
3
  export * from './comments';
4
4
  export * from './content';
5
- export * from './desk';
6
5
  export * from './instagram';
7
6
  export * from './listening';
8
7
  export * from './messages';
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ var SITE_ANALYTICS_SURFACES = [
25
25
  "mood_feed",
26
26
  "mood_post",
27
27
  "mood_embed",
28
+ "mood_year",
28
29
  "projects",
29
30
  "message",
30
31
  "privacy",
@@ -144,11 +145,6 @@ function parsePostLocaleTag(tagName) {
144
145
  }
145
146
  return canonicalSlug ? { locale, canonicalSlug } : { locale };
146
147
  }
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"];
152
148
  // src/messages.ts
153
149
  var MESSAGE_LOCALES = ["zh", "en"];
154
150
  var MESSAGE_MIN_BODY_LENGTH = 2;
@@ -158,6 +154,26 @@ var MESSAGE_STATES = ["new", "read", "replied", "archived", "spam"];
158
154
  // src/mood.ts
159
155
  var MOOD_SENTIMENT_LABELS = ["joy", "calm", "melancholy", "anger", "anxiety", "neutral"];
160
156
  var MOOD_AI_MODELS = ["gpt-5.5", "gpt-5", "claude-sonnet-4.6"];
157
+ var MOOD_TOPICS = [
158
+ { id: "food-drink", zh: "饮食", en: "Food & Drink" },
159
+ { id: "shopping-style", zh: "消费穿搭", en: "Shopping & Style" },
160
+ { id: "money-finance", zh: "金融理财", en: "Money & Finance" },
161
+ { id: "study-school", zh: "学业", en: "Study & School" },
162
+ { id: "devices", zh: "数码设备", en: "Devices" },
163
+ { id: "apps-services", zh: "软件服务", en: "Apps & Services" },
164
+ { id: "ai", zh: "人工智能", en: "AI" },
165
+ { id: "coding", zh: "编程开发", en: "Coding & Dev" },
166
+ { id: "music", zh: "音乐", en: "Music" },
167
+ { id: "media-entertainment", zh: "影视游戏", en: "Media & Games" },
168
+ { id: "internet-culture", zh: "网络文化", en: "Internet Culture" },
169
+ { id: "friends", zh: "朋友社交", en: "Friends & Social" },
170
+ { id: "romance", zh: "恋爱情感", en: "Romance" },
171
+ { id: "self-feelings", zh: "自我心境", en: "Self & Feelings" },
172
+ { id: "reflections", zh: "感悟观点", en: "Reflections & Views" },
173
+ { id: "health-sleep", zh: "健康睡眠", en: "Health & Sleep" },
174
+ { id: "travel", zh: "出行旅行", en: "Travel & Transport" },
175
+ { id: "daily-life", zh: "日常生活", en: "Daily Life" }
176
+ ];
161
177
  var MOOD_COMMENT_ORIGINS = ["telegram", "web"];
162
178
  // src/notify.ts
163
179
  var NOTIFY_CHANNELS = ["mood", "blog", "privacy", "announcement"];
@@ -177,12 +193,6 @@ var MOOD_SEARCH_PATH = "/v2/mood/search";
177
193
  var MOOD_IMAGE_PROXY_BASE_PATH = "/v2/images";
178
194
  var MOOD_MEDIA_PROXY_BASE_PATH = "/v2/media";
179
195
  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
- }
186
196
  var INSTAGRAM_PROFILE_PATH = "/v2/instagram";
187
197
  var INSTAGRAM_AVATAR_PATH = "/v2/instagram/avatar";
188
198
  var COMMENTS_PATH = "/v2/comments";
@@ -295,13 +305,6 @@ export {
295
305
  CONTENT_DOCUMENT_SOURCES,
296
306
  DEFAULT_COMMENT_POLICY,
297
307
  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,
305
308
  EVENT_STATUSES,
306
309
  GHOST_WEBHOOK_PATH,
307
310
  HEALTH_PATH,
@@ -335,6 +338,7 @@ export {
335
338
  MOOD_PUBLIC_FEED_PATH,
336
339
  MOOD_SEARCH_PATH,
337
340
  MOOD_SENTIMENT_LABELS,
341
+ MOOD_TOPICS,
338
342
  MUSICKIT_TOKEN_PATH,
339
343
  NEWSLETTER_ANALYTICS_CLICK_ENDPOINT,
340
344
  NEWSLETTER_ANALYTICS_OPEN_ENDPOINT,
@@ -390,7 +394,6 @@ export {
390
394
  avatarClass,
391
395
  commentAnchorToken,
392
396
  commentPolicyFromTags,
393
- deskIconPath,
394
397
  isAvatarSeed,
395
398
  parsePostLocaleTag,
396
399
  seedInClass,
package/dist/mood.d.ts CHANGED
@@ -12,6 +12,82 @@ export declare const MOOD_SENTIMENT_LABELS: readonly ['joy', 'calm', 'melancholy
12
12
  export declare const MOOD_AI_MODELS: readonly ['gpt-5.5', 'gpt-5', 'claude-sonnet-4.6'];
13
13
  export type MoodSentimentLabel = (typeof MOOD_SENTIMENT_LABELS)[number];
14
14
  export type MoodAiModel = string;
15
+ /** The fixed topic list of the per-post AI pass, with display labels. An id
16
+ is stable: renaming one splits its yearly history. */
17
+ export declare const MOOD_TOPICS: readonly [{
18
+ readonly id: 'food-drink';
19
+ readonly zh: '饮食';
20
+ readonly en: 'Food & Drink';
21
+ }, {
22
+ readonly id: 'shopping-style';
23
+ readonly zh: '消费穿搭';
24
+ readonly en: 'Shopping & Style';
25
+ }, {
26
+ readonly id: 'money-finance';
27
+ readonly zh: '金融理财';
28
+ readonly en: 'Money & Finance';
29
+ }, {
30
+ readonly id: 'study-school';
31
+ readonly zh: '学业';
32
+ readonly en: 'Study & School';
33
+ }, {
34
+ readonly id: 'devices';
35
+ readonly zh: '数码设备';
36
+ readonly en: 'Devices';
37
+ }, {
38
+ readonly id: 'apps-services';
39
+ readonly zh: '软件服务';
40
+ readonly en: 'Apps & Services';
41
+ }, {
42
+ readonly id: 'ai';
43
+ readonly zh: '人工智能';
44
+ readonly en: 'AI';
45
+ }, {
46
+ readonly id: 'coding';
47
+ readonly zh: '编程开发';
48
+ readonly en: 'Coding & Dev';
49
+ }, {
50
+ readonly id: 'music';
51
+ readonly zh: '音乐';
52
+ readonly en: 'Music';
53
+ }, {
54
+ readonly id: 'media-entertainment';
55
+ readonly zh: '影视游戏';
56
+ readonly en: 'Media & Games';
57
+ }, {
58
+ readonly id: 'internet-culture';
59
+ readonly zh: '网络文化';
60
+ readonly en: 'Internet Culture';
61
+ }, {
62
+ readonly id: 'friends';
63
+ readonly zh: '朋友社交';
64
+ readonly en: 'Friends & Social';
65
+ }, {
66
+ readonly id: 'romance';
67
+ readonly zh: '恋爱情感';
68
+ readonly en: 'Romance';
69
+ }, {
70
+ readonly id: 'self-feelings';
71
+ readonly zh: '自我心境';
72
+ readonly en: 'Self & Feelings';
73
+ }, {
74
+ readonly id: 'reflections';
75
+ readonly zh: '感悟观点';
76
+ readonly en: 'Reflections & Views';
77
+ }, {
78
+ readonly id: 'health-sleep';
79
+ readonly zh: '健康睡眠';
80
+ readonly en: 'Health & Sleep';
81
+ }, {
82
+ readonly id: 'travel';
83
+ readonly zh: '出行旅行';
84
+ readonly en: 'Travel & Transport';
85
+ }, {
86
+ readonly id: 'daily-life';
87
+ readonly zh: '日常生活';
88
+ readonly en: 'Daily Life';
89
+ }];
90
+ export type MoodTopicId = (typeof MOOD_TOPICS)[number]['id'];
15
91
  export interface MoodSentiment {
16
92
  label: MoodSentimentLabel;
17
93
  score: number;
@@ -42,6 +118,42 @@ export interface MoodStatsSnapshot {
42
118
  };
43
119
  generatedAt: string;
44
120
  }
121
+ /** One local day (the owner's Melbourne clock) of the owner's own posts. */
122
+ export interface MoodYearDay {
123
+ /** YYYY-MM-DD. */
124
+ date: string;
125
+ posts: number;
126
+ /** Mean sentiment score of the day's analysed posts that carry a feeling
127
+ (score not 0), -1 (cold) to 1 (warm), two decimals; null when none does. */
128
+ temperature: number | null;
129
+ }
130
+ export interface MoodYearTopic {
131
+ /** A MoodTopicId, kept as string: a snapshot can outlive a vocabulary change. */
132
+ topic: string;
133
+ count: number;
134
+ }
135
+ export interface MoodYearWord {
136
+ word: string;
137
+ count: number;
138
+ }
139
+ /** One calendar year of the owner's own words. Forwards are left out: they
140
+ are someone else's mood. Built once a day into KV, never per request. */
141
+ export interface MoodYear {
142
+ year: number;
143
+ /** Every year with posts, ascending. */
144
+ years: number[];
145
+ posts: number;
146
+ /** Posts the AI pass has read; sentiment, topics and words cover only these. */
147
+ analyzed: number;
148
+ /** Days with at least one post, ascending; empty days are absent. */
149
+ days: MoodYearDay[];
150
+ sentiment: Record<MoodSentimentLabel, number>;
151
+ /** Most frequent first. */
152
+ topics: MoodYearTopic[];
153
+ /** Word-cloud keywords, most frequent first, at most 120. */
154
+ words: MoodYearWord[];
155
+ generatedAt: string;
156
+ }
45
157
  export interface MoodAiConfig {
46
158
  primary: MoodAiModel;
47
159
  fallback: MoodAiModel;
@@ -68,6 +180,7 @@ export interface MoodIngestHealth {
68
180
  coverage: {
69
181
  sentiment: MoodCoverageSummary;
70
182
  tags: MoodCoverageSummary;
183
+ topics: MoodCoverageSummary;
71
184
  };
72
185
  replyIntegrity: {
73
186
  edges: number;
@@ -83,6 +196,7 @@ export interface MoodSearchResult {
83
196
  datetime: string;
84
197
  snippet: string;
85
198
  tags: string[];
199
+ topics: string[];
86
200
  sentiment_label: MoodSentimentLabel | null;
87
201
  }
88
202
  export interface MoodSearchResponse {
package/dist/mood.js CHANGED
@@ -1,9 +1,30 @@
1
1
  // src/mood.ts
2
2
  var MOOD_SENTIMENT_LABELS = ["joy", "calm", "melancholy", "anger", "anxiety", "neutral"];
3
3
  var MOOD_AI_MODELS = ["gpt-5.5", "gpt-5", "claude-sonnet-4.6"];
4
+ var MOOD_TOPICS = [
5
+ { id: "food-drink", zh: "饮食", en: "Food & Drink" },
6
+ { id: "shopping-style", zh: "消费穿搭", en: "Shopping & Style" },
7
+ { id: "money-finance", zh: "金融理财", en: "Money & Finance" },
8
+ { id: "study-school", zh: "学业", en: "Study & School" },
9
+ { id: "devices", zh: "数码设备", en: "Devices" },
10
+ { id: "apps-services", zh: "软件服务", en: "Apps & Services" },
11
+ { id: "ai", zh: "人工智能", en: "AI" },
12
+ { id: "coding", zh: "编程开发", en: "Coding & Dev" },
13
+ { id: "music", zh: "音乐", en: "Music" },
14
+ { id: "media-entertainment", zh: "影视游戏", en: "Media & Games" },
15
+ { id: "internet-culture", zh: "网络文化", en: "Internet Culture" },
16
+ { id: "friends", zh: "朋友社交", en: "Friends & Social" },
17
+ { id: "romance", zh: "恋爱情感", en: "Romance" },
18
+ { id: "self-feelings", zh: "自我心境", en: "Self & Feelings" },
19
+ { id: "reflections", zh: "感悟观点", en: "Reflections & Views" },
20
+ { id: "health-sleep", zh: "健康睡眠", en: "Health & Sleep" },
21
+ { id: "travel", zh: "出行旅行", en: "Travel & Transport" },
22
+ { id: "daily-life", zh: "日常生活", en: "Daily Life" }
23
+ ];
4
24
  var MOOD_COMMENT_ORIGINS = ["telegram", "web"];
5
25
  export {
6
26
  MOOD_AI_MODELS,
7
27
  MOOD_COMMENT_ORIGINS,
8
- MOOD_SENTIMENT_LABELS
28
+ MOOD_SENTIMENT_LABELS,
29
+ MOOD_TOPICS
9
30
  };
package/dist/routes.d.ts CHANGED
@@ -12,11 +12,6 @@ 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;
20
15
  export declare const INSTAGRAM_PROFILE_PATH: '/v2/instagram';
21
16
  export declare const INSTAGRAM_AVATAR_PATH: '/v2/instagram/avatar';
22
17
  export declare const COMMENTS_PATH: '/v2/comments';
package/dist/routes.js CHANGED
@@ -13,12 +13,6 @@ 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
- }
22
16
  var INSTAGRAM_PROFILE_PATH = "/v2/instagram";
23
17
  var INSTAGRAM_AVATAR_PATH = "/v2/instagram/avatar";
24
18
  var COMMENTS_PATH = "/v2/comments";
@@ -51,9 +45,6 @@ export {
51
45
  API_PREFIX,
52
46
  COMMENTS_PATH,
53
47
  COMMENT_PATH_PREFIX,
54
- DESK_ICONS_PATH,
55
- DESK_PATH,
56
- DESK_REPORT_PATH,
57
48
  GHOST_WEBHOOK_PATH,
58
49
  HEALTH_PATH,
59
50
  INSTAGRAM_AVATAR_PATH,
@@ -90,6 +81,5 @@ export {
90
81
  READER_PREFERENCES_PATH,
91
82
  READER_RESEND_PATH,
92
83
  READER_VERIFY_PATH,
93
- TELEGRAM_WEBHOOK_PATH,
94
- deskIconPath
84
+ TELEGRAM_WEBHOOK_PATH
95
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunizao/contracts",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "Shared TypeScript contracts for buxx.me services and clients.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,11 +48,6 @@
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
- },
56
51
  "./instagram": {
57
52
  "types": "./dist/instagram.d.ts",
58
53
  "import": "./dist/instagram.js",
package/dist/desk.d.ts DELETED
@@ -1,67 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
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
- };