@objectstack/service-feed 3.0.7

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/index.cjs ADDED
@@ -0,0 +1,517 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ FeedItem: () => FeedItem,
24
+ FeedReaction: () => FeedReaction,
25
+ FeedServicePlugin: () => FeedServicePlugin,
26
+ InMemoryFeedAdapter: () => InMemoryFeedAdapter,
27
+ RecordSubscription: () => RecordSubscription
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/in-memory-feed-adapter.ts
32
+ var InMemoryFeedAdapter = class {
33
+ constructor(options = {}) {
34
+ this.items = /* @__PURE__ */ new Map();
35
+ this.counter = 0;
36
+ this.subscriptions = /* @__PURE__ */ new Map();
37
+ this.maxItems = options.maxItems ?? 0;
38
+ }
39
+ async listFeed(options) {
40
+ let items = Array.from(this.items.values()).filter(
41
+ (item) => item.object === options.object && item.recordId === options.recordId
42
+ );
43
+ if (options.filter && options.filter !== "all") {
44
+ items = items.filter((item) => {
45
+ switch (options.filter) {
46
+ case "comments_only":
47
+ return item.type === "comment";
48
+ case "changes_only":
49
+ return item.type === "field_change";
50
+ case "tasks_only":
51
+ return item.type === "task";
52
+ default:
53
+ return true;
54
+ }
55
+ });
56
+ }
57
+ items.sort((a, b) => {
58
+ const timeDiff = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
59
+ if (timeDiff !== 0) return timeDiff;
60
+ return b.id < a.id ? -1 : b.id > a.id ? 1 : 0;
61
+ });
62
+ const total = items.length;
63
+ const limit = options.limit ?? 20;
64
+ let startIndex = 0;
65
+ if (options.cursor) {
66
+ const cursorIndex = items.findIndex((item) => item.id === options.cursor);
67
+ if (cursorIndex >= 0) {
68
+ startIndex = cursorIndex + 1;
69
+ }
70
+ }
71
+ const page = items.slice(startIndex, startIndex + limit);
72
+ const hasMore = startIndex + limit < total;
73
+ return {
74
+ items: page,
75
+ total,
76
+ nextCursor: hasMore && page.length > 0 ? page[page.length - 1].id : void 0,
77
+ hasMore
78
+ };
79
+ }
80
+ async createFeedItem(input) {
81
+ if (this.maxItems > 0 && this.items.size >= this.maxItems) {
82
+ throw new Error(
83
+ `Maximum feed item limit reached (${this.maxItems}). Delete existing items before adding new ones.`
84
+ );
85
+ }
86
+ const id = `feed_${++this.counter}`;
87
+ const now = (/* @__PURE__ */ new Date()).toISOString();
88
+ if (input.parentId) {
89
+ const parent = this.items.get(input.parentId);
90
+ if (!parent) {
91
+ throw new Error(`Parent feed item not found: ${input.parentId}`);
92
+ }
93
+ const updatedParent = {
94
+ ...parent,
95
+ replyCount: (parent.replyCount ?? 0) + 1,
96
+ updatedAt: now
97
+ };
98
+ this.items.set(parent.id, updatedParent);
99
+ }
100
+ const item = {
101
+ id,
102
+ type: input.type,
103
+ object: input.object,
104
+ recordId: input.recordId,
105
+ actor: {
106
+ type: input.actor.type,
107
+ id: input.actor.id,
108
+ ...input.actor.name ? { name: input.actor.name } : {},
109
+ ...input.actor.avatarUrl ? { avatarUrl: input.actor.avatarUrl } : {}
110
+ },
111
+ ...input.body !== void 0 ? { body: input.body } : {},
112
+ ...input.mentions ? { mentions: input.mentions } : {},
113
+ ...input.changes ? { changes: input.changes } : {},
114
+ ...input.parentId ? { parentId: input.parentId } : {},
115
+ visibility: input.visibility ?? "public",
116
+ replyCount: 0,
117
+ isEdited: false,
118
+ createdAt: now
119
+ };
120
+ this.items.set(id, item);
121
+ return item;
122
+ }
123
+ async updateFeedItem(feedId, input) {
124
+ const existing = this.items.get(feedId);
125
+ if (!existing) {
126
+ throw new Error(`Feed item not found: ${feedId}`);
127
+ }
128
+ const now = (/* @__PURE__ */ new Date()).toISOString();
129
+ const updated = {
130
+ ...existing,
131
+ ...input.body !== void 0 ? { body: input.body } : {},
132
+ ...input.mentions !== void 0 ? { mentions: input.mentions } : {},
133
+ ...input.visibility !== void 0 ? { visibility: input.visibility } : {},
134
+ updatedAt: now,
135
+ editedAt: now,
136
+ isEdited: true
137
+ };
138
+ this.items.set(feedId, updated);
139
+ return updated;
140
+ }
141
+ async deleteFeedItem(feedId) {
142
+ const item = this.items.get(feedId);
143
+ if (!item) {
144
+ throw new Error(`Feed item not found: ${feedId}`);
145
+ }
146
+ if (item.parentId) {
147
+ const parent = this.items.get(item.parentId);
148
+ if (parent) {
149
+ const updatedParent = {
150
+ ...parent,
151
+ replyCount: Math.max(0, (parent.replyCount ?? 0) - 1)
152
+ };
153
+ this.items.set(parent.id, updatedParent);
154
+ }
155
+ }
156
+ this.items.delete(feedId);
157
+ }
158
+ async getFeedItem(feedId) {
159
+ return this.items.get(feedId) ?? null;
160
+ }
161
+ async addReaction(feedId, emoji, userId) {
162
+ const item = this.items.get(feedId);
163
+ if (!item) {
164
+ throw new Error(`Feed item not found: ${feedId}`);
165
+ }
166
+ const reactions = [...item.reactions ?? []];
167
+ const existing = reactions.find((r) => r.emoji === emoji);
168
+ if (existing) {
169
+ if (existing.userIds.includes(userId)) {
170
+ throw new Error(`Reaction already exists: ${emoji} by ${userId}`);
171
+ }
172
+ existing.userIds = [...existing.userIds, userId];
173
+ existing.count = existing.userIds.length;
174
+ } else {
175
+ reactions.push({ emoji, userIds: [userId], count: 1 });
176
+ }
177
+ const updated = { ...item, reactions };
178
+ this.items.set(feedId, updated);
179
+ return reactions;
180
+ }
181
+ async removeReaction(feedId, emoji, userId) {
182
+ const item = this.items.get(feedId);
183
+ if (!item) {
184
+ throw new Error(`Feed item not found: ${feedId}`);
185
+ }
186
+ let reactions = [...item.reactions ?? []];
187
+ const existing = reactions.find((r) => r.emoji === emoji);
188
+ if (!existing || !existing.userIds.includes(userId)) {
189
+ throw new Error(`Reaction not found: ${emoji} by ${userId}`);
190
+ }
191
+ existing.userIds = existing.userIds.filter((id) => id !== userId);
192
+ existing.count = existing.userIds.length;
193
+ reactions = reactions.filter((r) => r.count > 0);
194
+ const updated = { ...item, reactions };
195
+ this.items.set(feedId, updated);
196
+ return reactions;
197
+ }
198
+ async subscribe(input) {
199
+ const key = this.subscriptionKey(input.object, input.recordId, input.userId);
200
+ const existing = this.findSubscription(input.object, input.recordId, input.userId);
201
+ if (existing) {
202
+ const updated = {
203
+ ...existing,
204
+ events: input.events ?? existing.events,
205
+ channels: input.channels ?? existing.channels,
206
+ active: true
207
+ };
208
+ this.subscriptions.set(key, updated);
209
+ return updated;
210
+ }
211
+ const now = (/* @__PURE__ */ new Date()).toISOString();
212
+ const subscription = {
213
+ object: input.object,
214
+ recordId: input.recordId,
215
+ userId: input.userId,
216
+ events: input.events ?? ["all"],
217
+ channels: input.channels ?? ["in_app"],
218
+ active: true,
219
+ createdAt: now
220
+ };
221
+ this.subscriptions.set(key, subscription);
222
+ return subscription;
223
+ }
224
+ async unsubscribe(object, recordId, userId) {
225
+ const key = this.subscriptionKey(object, recordId, userId);
226
+ return this.subscriptions.delete(key);
227
+ }
228
+ async getSubscription(object, recordId, userId) {
229
+ return this.findSubscription(object, recordId, userId);
230
+ }
231
+ /**
232
+ * Get the total number of feed items stored.
233
+ */
234
+ getItemCount() {
235
+ return this.items.size;
236
+ }
237
+ /**
238
+ * Get the total number of subscriptions stored.
239
+ */
240
+ getSubscriptionCount() {
241
+ return this.subscriptions.size;
242
+ }
243
+ subscriptionKey(object, recordId, userId) {
244
+ return `${object}:${recordId}:${userId}`;
245
+ }
246
+ findSubscription(object, recordId, userId) {
247
+ const key = this.subscriptionKey(object, recordId, userId);
248
+ return this.subscriptions.get(key) ?? null;
249
+ }
250
+ };
251
+
252
+ // src/feed-service-plugin.ts
253
+ var FeedServicePlugin = class {
254
+ constructor(options = {}) {
255
+ this.name = "com.objectstack.service.feed";
256
+ this.version = "1.0.0";
257
+ this.type = "standard";
258
+ this.options = { adapter: "memory", ...options };
259
+ }
260
+ async init(ctx) {
261
+ const feed = new InMemoryFeedAdapter(this.options.memory);
262
+ ctx.registerService("feed", feed);
263
+ ctx.logger.info("FeedServicePlugin: registered in-memory feed adapter");
264
+ }
265
+ };
266
+
267
+ // src/objects/feed-item.object.ts
268
+ var import_data = require("@objectstack/spec/data");
269
+ var FeedItem = import_data.ObjectSchema.create({
270
+ name: "sys_feed_item",
271
+ label: "Feed Item",
272
+ pluralLabel: "Feed Items",
273
+ icon: "message-square",
274
+ description: "Unified activity timeline entries (comments, field changes, tasks, events)",
275
+ titleFormat: "{type}: {body}",
276
+ compactLayout: ["type", "object", "record_id", "created_at"],
277
+ fields: {
278
+ id: import_data.Field.text({
279
+ label: "Feed Item ID",
280
+ required: true,
281
+ readonly: true
282
+ }),
283
+ type: import_data.Field.select({
284
+ label: "Type",
285
+ required: true,
286
+ options: [
287
+ { label: "Comment", value: "comment" },
288
+ { label: "Field Change", value: "field_change" },
289
+ { label: "Task", value: "task" },
290
+ { label: "Event", value: "event" },
291
+ { label: "Email", value: "email" },
292
+ { label: "Call", value: "call" },
293
+ { label: "Note", value: "note" },
294
+ { label: "File", value: "file" },
295
+ { label: "Record Create", value: "record_create" },
296
+ { label: "Record Delete", value: "record_delete" },
297
+ { label: "Approval", value: "approval" },
298
+ { label: "Sharing", value: "sharing" },
299
+ { label: "System", value: "system" }
300
+ ]
301
+ }),
302
+ object: import_data.Field.text({
303
+ label: "Object Name",
304
+ required: true,
305
+ searchable: true
306
+ }),
307
+ record_id: import_data.Field.text({
308
+ label: "Record ID",
309
+ required: true,
310
+ searchable: true
311
+ }),
312
+ actor_type: import_data.Field.select({
313
+ label: "Actor Type",
314
+ required: true,
315
+ options: [
316
+ { label: "User", value: "user" },
317
+ { label: "System", value: "system" },
318
+ { label: "Service", value: "service" },
319
+ { label: "Automation", value: "automation" }
320
+ ]
321
+ }),
322
+ actor_id: import_data.Field.text({
323
+ label: "Actor ID",
324
+ required: true
325
+ }),
326
+ actor_name: import_data.Field.text({
327
+ label: "Actor Name"
328
+ }),
329
+ actor_avatar_url: import_data.Field.url({
330
+ label: "Actor Avatar URL"
331
+ }),
332
+ body: import_data.Field.textarea({
333
+ label: "Body",
334
+ description: "Rich text body (Markdown supported)"
335
+ }),
336
+ mentions: import_data.Field.textarea({
337
+ label: "Mentions",
338
+ description: "Array of @mention objects (JSON)"
339
+ }),
340
+ changes: import_data.Field.textarea({
341
+ label: "Field Changes",
342
+ description: "Array of field change entries (JSON)"
343
+ }),
344
+ reactions: import_data.Field.textarea({
345
+ label: "Reactions",
346
+ description: "Array of emoji reaction objects (JSON)"
347
+ }),
348
+ parent_id: import_data.Field.text({
349
+ label: "Parent Feed Item ID",
350
+ description: "For threaded replies"
351
+ }),
352
+ reply_count: import_data.Field.number({
353
+ label: "Reply Count",
354
+ defaultValue: 0
355
+ }),
356
+ visibility: import_data.Field.select({
357
+ label: "Visibility",
358
+ defaultValue: "public",
359
+ options: [
360
+ { label: "Public", value: "public" },
361
+ { label: "Internal", value: "internal" },
362
+ { label: "Private", value: "private" }
363
+ ]
364
+ }),
365
+ is_edited: import_data.Field.boolean({
366
+ label: "Is Edited",
367
+ defaultValue: false
368
+ }),
369
+ edited_at: import_data.Field.datetime({
370
+ label: "Edited At"
371
+ }),
372
+ created_at: import_data.Field.datetime({
373
+ label: "Created At",
374
+ defaultValue: "NOW()",
375
+ readonly: true
376
+ }),
377
+ updated_at: import_data.Field.datetime({
378
+ label: "Updated At",
379
+ defaultValue: "NOW()",
380
+ readonly: true
381
+ })
382
+ },
383
+ indexes: [
384
+ { fields: ["object", "record_id"], unique: false },
385
+ { fields: ["actor_id"], unique: false },
386
+ { fields: ["parent_id"], unique: false },
387
+ { fields: ["created_at"], unique: false }
388
+ ],
389
+ enable: {
390
+ trackHistory: false,
391
+ searchable: true,
392
+ apiEnabled: true,
393
+ apiMethods: ["get", "list", "create", "update", "delete"],
394
+ trash: false,
395
+ mru: false
396
+ }
397
+ });
398
+
399
+ // src/objects/feed-reaction.object.ts
400
+ var import_data2 = require("@objectstack/spec/data");
401
+ var FeedReaction = import_data2.ObjectSchema.create({
402
+ name: "sys_feed_reaction",
403
+ label: "Feed Reaction",
404
+ pluralLabel: "Feed Reactions",
405
+ icon: "smile",
406
+ description: "Emoji reactions on feed items",
407
+ titleFormat: "{emoji} by {user_id}",
408
+ compactLayout: ["feed_item_id", "emoji", "user_id"],
409
+ fields: {
410
+ id: import_data2.Field.text({
411
+ label: "Reaction ID",
412
+ required: true,
413
+ readonly: true
414
+ }),
415
+ feed_item_id: import_data2.Field.text({
416
+ label: "Feed Item ID",
417
+ required: true
418
+ }),
419
+ emoji: import_data2.Field.text({
420
+ label: "Emoji",
421
+ required: true,
422
+ description: 'Emoji character or shortcode (e.g., "\u{1F44D}", ":thumbsup:")'
423
+ }),
424
+ user_id: import_data2.Field.text({
425
+ label: "User ID",
426
+ required: true
427
+ }),
428
+ created_at: import_data2.Field.datetime({
429
+ label: "Created At",
430
+ defaultValue: "NOW()",
431
+ readonly: true
432
+ })
433
+ },
434
+ indexes: [
435
+ { fields: ["feed_item_id", "emoji", "user_id"], unique: true },
436
+ { fields: ["feed_item_id"], unique: false },
437
+ { fields: ["user_id"], unique: false }
438
+ ],
439
+ enable: {
440
+ trackHistory: false,
441
+ searchable: false,
442
+ apiEnabled: true,
443
+ apiMethods: ["get", "list", "create", "delete"],
444
+ trash: false,
445
+ mru: false
446
+ }
447
+ });
448
+
449
+ // src/objects/record-subscription.object.ts
450
+ var import_data3 = require("@objectstack/spec/data");
451
+ var RecordSubscription = import_data3.ObjectSchema.create({
452
+ name: "sys_record_subscription",
453
+ label: "Record Subscription",
454
+ pluralLabel: "Record Subscriptions",
455
+ icon: "bell",
456
+ description: "Record-level notification subscriptions for feed events",
457
+ titleFormat: "{object}/{record_id} \u2014 {user_id}",
458
+ compactLayout: ["object", "record_id", "user_id", "active"],
459
+ fields: {
460
+ id: import_data3.Field.text({
461
+ label: "Subscription ID",
462
+ required: true,
463
+ readonly: true
464
+ }),
465
+ object: import_data3.Field.text({
466
+ label: "Object Name",
467
+ required: true
468
+ }),
469
+ record_id: import_data3.Field.text({
470
+ label: "Record ID",
471
+ required: true
472
+ }),
473
+ user_id: import_data3.Field.text({
474
+ label: "User ID",
475
+ required: true
476
+ }),
477
+ events: import_data3.Field.textarea({
478
+ label: "Subscribed Events",
479
+ description: "Array of event types: comment, mention, field_change, task, approval, all (JSON)"
480
+ }),
481
+ channels: import_data3.Field.textarea({
482
+ label: "Notification Channels",
483
+ description: "Array of channels: in_app, email, push, slack (JSON)"
484
+ }),
485
+ active: import_data3.Field.boolean({
486
+ label: "Active",
487
+ defaultValue: true
488
+ }),
489
+ created_at: import_data3.Field.datetime({
490
+ label: "Created At",
491
+ defaultValue: "NOW()",
492
+ readonly: true
493
+ })
494
+ },
495
+ indexes: [
496
+ { fields: ["object", "record_id", "user_id"], unique: true },
497
+ { fields: ["user_id"], unique: false },
498
+ { fields: ["object", "record_id"], unique: false }
499
+ ],
500
+ enable: {
501
+ trackHistory: false,
502
+ searchable: false,
503
+ apiEnabled: true,
504
+ apiMethods: ["get", "list", "create", "update", "delete"],
505
+ trash: false,
506
+ mru: false
507
+ }
508
+ });
509
+ // Annotate the CommonJS export names for ESM import in node:
510
+ 0 && (module.exports = {
511
+ FeedItem,
512
+ FeedReaction,
513
+ FeedServicePlugin,
514
+ InMemoryFeedAdapter,
515
+ RecordSubscription
516
+ });
517
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/in-memory-feed-adapter.ts","../src/feed-service-plugin.ts","../src/objects/feed-item.object.ts","../src/objects/feed-reaction.object.ts","../src/objects/record-subscription.object.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nexport { FeedServicePlugin } from './feed-service-plugin.js';\nexport type { FeedServicePluginOptions } from './feed-service-plugin.js';\nexport { InMemoryFeedAdapter } from './in-memory-feed-adapter.js';\nexport type { InMemoryFeedAdapterOptions } from './in-memory-feed-adapter.js';\n\n// Feed Service Objects (metadata definitions)\nexport { FeedItem, FeedReaction, RecordSubscription } from './objects/index.js';\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type {\n IFeedService,\n CreateFeedItemInput,\n UpdateFeedItemInput,\n ListFeedOptions,\n FeedListResult,\n SubscribeInput,\n} from '@objectstack/spec/contracts';\nimport type { FeedItem, Reaction } from '@objectstack/spec/data';\nimport type { RecordSubscription } from '@objectstack/spec/data';\n\n/**\n * Configuration options for InMemoryFeedAdapter.\n */\nexport interface InMemoryFeedAdapterOptions {\n /** Maximum number of feed items to store (0 = unlimited) */\n maxItems?: number;\n}\n\n/**\n * In-memory Feed/Chatter adapter implementing IFeedService.\n *\n * Uses Map-backed stores for feed items, reactions, and subscriptions.\n * Supports feed CRUD, emoji reactions, threaded replies, and record subscriptions.\n *\n * Suitable for single-process environments, development, and testing.\n * For production deployments, use a database-backed adapter.\n *\n * @example\n * ```ts\n * const feed = new InMemoryFeedAdapter();\n *\n * const item = await feed.createFeedItem({\n * object: 'account',\n * recordId: 'rec_123',\n * type: 'comment',\n * actor: { type: 'user', id: 'user_1', name: 'Alice' },\n * body: 'Great progress!',\n * });\n *\n * const list = await feed.listFeed({ object: 'account', recordId: 'rec_123' });\n * ```\n */\nexport class InMemoryFeedAdapter implements IFeedService {\n private readonly items = new Map<string, FeedItem>();\n private counter = 0;\n private readonly subscriptions = new Map<string, RecordSubscription>();\n private readonly maxItems: number;\n\n constructor(options: InMemoryFeedAdapterOptions = {}) {\n this.maxItems = options.maxItems ?? 0;\n }\n\n async listFeed(options: ListFeedOptions): Promise<FeedListResult> {\n let items = Array.from(this.items.values()).filter(\n (item) => item.object === options.object && item.recordId === options.recordId,\n );\n\n // Apply filter\n if (options.filter && options.filter !== 'all') {\n items = items.filter((item) => {\n switch (options.filter) {\n case 'comments_only':\n return item.type === 'comment';\n case 'changes_only':\n return item.type === 'field_change';\n case 'tasks_only':\n return item.type === 'task';\n default:\n return true;\n }\n });\n }\n\n // Sort reverse chronological (stable: break ties by ID descending)\n items.sort((a, b) => {\n const timeDiff = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();\n if (timeDiff !== 0) return timeDiff;\n return b.id < a.id ? -1 : b.id > a.id ? 1 : 0;\n });\n\n const total = items.length;\n const limit = options.limit ?? 20;\n\n // Cursor-based pagination\n let startIndex = 0;\n if (options.cursor) {\n const cursorIndex = items.findIndex((item) => item.id === options.cursor);\n if (cursorIndex >= 0) {\n startIndex = cursorIndex + 1;\n }\n }\n\n const page = items.slice(startIndex, startIndex + limit);\n const hasMore = startIndex + limit < total;\n\n return {\n items: page,\n total,\n nextCursor: hasMore && page.length > 0 ? page[page.length - 1].id : undefined,\n hasMore,\n };\n }\n\n async createFeedItem(input: CreateFeedItemInput): Promise<FeedItem> {\n if (this.maxItems > 0 && this.items.size >= this.maxItems) {\n throw new Error(\n `Maximum feed item limit reached (${this.maxItems}). ` +\n 'Delete existing items before adding new ones.',\n );\n }\n\n const id = `feed_${++this.counter}`;\n const now = new Date().toISOString();\n\n // Increment parent reply count if threading\n if (input.parentId) {\n const parent = this.items.get(input.parentId);\n if (!parent) {\n throw new Error(`Parent feed item not found: ${input.parentId}`);\n }\n const updatedParent: FeedItem = {\n ...parent,\n replyCount: (parent.replyCount ?? 0) + 1,\n updatedAt: now,\n };\n this.items.set(parent.id, updatedParent);\n }\n\n const item: FeedItem = {\n id,\n type: input.type as FeedItem['type'],\n object: input.object,\n recordId: input.recordId,\n actor: {\n type: input.actor.type,\n id: input.actor.id,\n ...(input.actor.name ? { name: input.actor.name } : {}),\n ...(input.actor.avatarUrl ? { avatarUrl: input.actor.avatarUrl } : {}),\n },\n ...(input.body !== undefined ? { body: input.body } : {}),\n ...(input.mentions ? { mentions: input.mentions } : {}),\n ...(input.changes ? { changes: input.changes } : {}),\n ...(input.parentId ? { parentId: input.parentId } : {}),\n visibility: input.visibility ?? 'public',\n replyCount: 0,\n isEdited: false,\n createdAt: now,\n };\n\n this.items.set(id, item);\n return item;\n }\n\n async updateFeedItem(feedId: string, input: UpdateFeedItemInput): Promise<FeedItem> {\n const existing = this.items.get(feedId);\n if (!existing) {\n throw new Error(`Feed item not found: ${feedId}`);\n }\n\n const now = new Date().toISOString();\n const updated: FeedItem = {\n ...existing,\n ...(input.body !== undefined ? { body: input.body } : {}),\n ...(input.mentions !== undefined ? { mentions: input.mentions } : {}),\n ...(input.visibility !== undefined ? { visibility: input.visibility } : {}),\n updatedAt: now,\n editedAt: now,\n isEdited: true,\n };\n\n this.items.set(feedId, updated);\n return updated;\n }\n\n async deleteFeedItem(feedId: string): Promise<void> {\n const item = this.items.get(feedId);\n if (!item) {\n throw new Error(`Feed item not found: ${feedId}`);\n }\n\n // Decrement parent reply count if threaded\n if (item.parentId) {\n const parent = this.items.get(item.parentId);\n if (parent) {\n const updatedParent: FeedItem = {\n ...parent,\n replyCount: Math.max(0, (parent.replyCount ?? 0) - 1),\n };\n this.items.set(parent.id, updatedParent);\n }\n }\n\n this.items.delete(feedId);\n }\n\n async getFeedItem(feedId: string): Promise<FeedItem | null> {\n return this.items.get(feedId) ?? null;\n }\n\n async addReaction(feedId: string, emoji: string, userId: string): Promise<Reaction[]> {\n const item = this.items.get(feedId);\n if (!item) {\n throw new Error(`Feed item not found: ${feedId}`);\n }\n\n const reactions = [...(item.reactions ?? [])];\n const existing = reactions.find((r) => r.emoji === emoji);\n\n if (existing) {\n if (existing.userIds.includes(userId)) {\n throw new Error(`Reaction already exists: ${emoji} by ${userId}`);\n }\n existing.userIds = [...existing.userIds, userId];\n existing.count = existing.userIds.length;\n } else {\n reactions.push({ emoji, userIds: [userId], count: 1 });\n }\n\n const updated: FeedItem = { ...item, reactions };\n this.items.set(feedId, updated);\n return reactions;\n }\n\n async removeReaction(feedId: string, emoji: string, userId: string): Promise<Reaction[]> {\n const item = this.items.get(feedId);\n if (!item) {\n throw new Error(`Feed item not found: ${feedId}`);\n }\n\n let reactions = [...(item.reactions ?? [])];\n const existing = reactions.find((r) => r.emoji === emoji);\n\n if (!existing || !existing.userIds.includes(userId)) {\n throw new Error(`Reaction not found: ${emoji} by ${userId}`);\n }\n\n existing.userIds = existing.userIds.filter((id) => id !== userId);\n existing.count = existing.userIds.length;\n\n // Remove reaction entry if no users left\n reactions = reactions.filter((r) => r.count > 0);\n\n const updated: FeedItem = { ...item, reactions };\n this.items.set(feedId, updated);\n return reactions;\n }\n\n async subscribe(input: SubscribeInput): Promise<RecordSubscription> {\n const key = this.subscriptionKey(input.object, input.recordId, input.userId);\n const existing = this.findSubscription(input.object, input.recordId, input.userId);\n\n if (existing) {\n // Update existing subscription\n const updated: RecordSubscription = {\n ...existing,\n events: input.events ?? existing.events,\n channels: input.channels ?? existing.channels,\n active: true,\n };\n this.subscriptions.set(key, updated);\n return updated;\n }\n\n const now = new Date().toISOString();\n const subscription: RecordSubscription = {\n object: input.object,\n recordId: input.recordId,\n userId: input.userId,\n events: input.events ?? ['all'],\n channels: input.channels ?? ['in_app'],\n active: true,\n createdAt: now,\n };\n\n this.subscriptions.set(key, subscription);\n return subscription;\n }\n\n async unsubscribe(object: string, recordId: string, userId: string): Promise<boolean> {\n const key = this.subscriptionKey(object, recordId, userId);\n return this.subscriptions.delete(key);\n }\n\n async getSubscription(\n object: string,\n recordId: string,\n userId: string,\n ): Promise<RecordSubscription | null> {\n return this.findSubscription(object, recordId, userId);\n }\n\n /**\n * Get the total number of feed items stored.\n */\n getItemCount(): number {\n return this.items.size;\n }\n\n /**\n * Get the total number of subscriptions stored.\n */\n getSubscriptionCount(): number {\n return this.subscriptions.size;\n }\n\n private subscriptionKey(object: string, recordId: string, userId: string): string {\n return `${object}:${recordId}:${userId}`;\n }\n\n private findSubscription(\n object: string,\n recordId: string,\n userId: string,\n ): RecordSubscription | null {\n const key = this.subscriptionKey(object, recordId, userId);\n return this.subscriptions.get(key) ?? null;\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { InMemoryFeedAdapter } from './in-memory-feed-adapter.js';\nimport type { InMemoryFeedAdapterOptions } from './in-memory-feed-adapter.js';\n\n/**\n * Configuration options for the FeedServicePlugin.\n */\nexport interface FeedServicePluginOptions {\n /** Feed adapter type (default: 'memory') */\n adapter?: 'memory';\n /** Options for the in-memory adapter */\n memory?: InMemoryFeedAdapterOptions;\n}\n\n/**\n * FeedServicePlugin — Production IFeedService implementation.\n *\n * Registers a Feed/Chatter service with the kernel during the init phase.\n * Currently supports in-memory storage for single-process environments.\n *\n * @example\n * ```ts\n * import { ObjectKernel } from '@objectstack/core';\n * import { FeedServicePlugin } from '@objectstack/service-feed';\n *\n * const kernel = new ObjectKernel();\n * kernel.use(new FeedServicePlugin());\n * await kernel.bootstrap();\n *\n * const feed = kernel.getService('feed');\n * const item = await feed.createFeedItem({\n * object: 'account',\n * recordId: 'rec_123',\n * type: 'comment',\n * actor: { type: 'user', id: 'user_1', name: 'Alice' },\n * body: 'Great progress!',\n * });\n * ```\n */\nexport class FeedServicePlugin implements Plugin {\n name = 'com.objectstack.service.feed';\n version = '1.0.0';\n type = 'standard';\n\n private readonly options: FeedServicePluginOptions;\n\n constructor(options: FeedServicePluginOptions = {}) {\n this.options = { adapter: 'memory', ...options };\n }\n\n async init(ctx: PluginContext): Promise<void> {\n const feed = new InMemoryFeedAdapter(this.options.memory);\n ctx.registerService('feed', feed);\n ctx.logger.info('FeedServicePlugin: registered in-memory feed adapter');\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { ObjectSchema, Field } from '@objectstack/spec/data';\n\n/**\n * Feed Item Object\n *\n * System object for storing feed/chatter items including comments,\n * field changes, tasks, events, and system activities.\n *\n * Belongs to `service-feed` package per \"protocol + service ownership\" pattern.\n */\nexport const FeedItem = ObjectSchema.create({\n name: 'sys_feed_item',\n label: 'Feed Item',\n pluralLabel: 'Feed Items',\n icon: 'message-square',\n description: 'Unified activity timeline entries (comments, field changes, tasks, events)',\n titleFormat: '{type}: {body}',\n compactLayout: ['type', 'object', 'record_id', 'created_at'],\n\n fields: {\n id: Field.text({\n label: 'Feed Item ID',\n required: true,\n readonly: true,\n }),\n\n type: Field.select({\n label: 'Type',\n required: true,\n options: [\n { label: 'Comment', value: 'comment' },\n { label: 'Field Change', value: 'field_change' },\n { label: 'Task', value: 'task' },\n { label: 'Event', value: 'event' },\n { label: 'Email', value: 'email' },\n { label: 'Call', value: 'call' },\n { label: 'Note', value: 'note' },\n { label: 'File', value: 'file' },\n { label: 'Record Create', value: 'record_create' },\n { label: 'Record Delete', value: 'record_delete' },\n { label: 'Approval', value: 'approval' },\n { label: 'Sharing', value: 'sharing' },\n { label: 'System', value: 'system' },\n ],\n }),\n\n object: Field.text({\n label: 'Object Name',\n required: true,\n searchable: true,\n }),\n\n record_id: Field.text({\n label: 'Record ID',\n required: true,\n searchable: true,\n }),\n\n actor_type: Field.select({\n label: 'Actor Type',\n required: true,\n options: [\n { label: 'User', value: 'user' },\n { label: 'System', value: 'system' },\n { label: 'Service', value: 'service' },\n { label: 'Automation', value: 'automation' },\n ],\n }),\n\n actor_id: Field.text({\n label: 'Actor ID',\n required: true,\n }),\n\n actor_name: Field.text({\n label: 'Actor Name',\n }),\n\n actor_avatar_url: Field.url({\n label: 'Actor Avatar URL',\n }),\n\n body: Field.textarea({\n label: 'Body',\n description: 'Rich text body (Markdown supported)',\n }),\n\n mentions: Field.textarea({\n label: 'Mentions',\n description: 'Array of @mention objects (JSON)',\n }),\n\n changes: Field.textarea({\n label: 'Field Changes',\n description: 'Array of field change entries (JSON)',\n }),\n\n reactions: Field.textarea({\n label: 'Reactions',\n description: 'Array of emoji reaction objects (JSON)',\n }),\n\n parent_id: Field.text({\n label: 'Parent Feed Item ID',\n description: 'For threaded replies',\n }),\n\n reply_count: Field.number({\n label: 'Reply Count',\n defaultValue: 0,\n }),\n\n visibility: Field.select({\n label: 'Visibility',\n defaultValue: 'public',\n options: [\n { label: 'Public', value: 'public' },\n { label: 'Internal', value: 'internal' },\n { label: 'Private', value: 'private' },\n ],\n }),\n\n is_edited: Field.boolean({\n label: 'Is Edited',\n defaultValue: false,\n }),\n\n edited_at: Field.datetime({\n label: 'Edited At',\n }),\n\n created_at: Field.datetime({\n label: 'Created At',\n defaultValue: 'NOW()',\n readonly: true,\n }),\n\n updated_at: Field.datetime({\n label: 'Updated At',\n defaultValue: 'NOW()',\n readonly: true,\n }),\n },\n\n indexes: [\n { fields: ['object', 'record_id'], unique: false },\n { fields: ['actor_id'], unique: false },\n { fields: ['parent_id'], unique: false },\n { fields: ['created_at'], unique: false },\n ],\n\n enable: {\n trackHistory: false,\n searchable: true,\n apiEnabled: true,\n apiMethods: ['get', 'list', 'create', 'update', 'delete'],\n trash: false,\n mru: false,\n },\n});\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { ObjectSchema, Field } from '@objectstack/spec/data';\n\n/**\n * Feed Reaction Object\n *\n * System object for storing individual emoji reactions on feed items.\n * Each row represents one user's reaction on one feed item.\n *\n * Belongs to `service-feed` package per \"protocol + service ownership\" pattern.\n */\nexport const FeedReaction = ObjectSchema.create({\n name: 'sys_feed_reaction',\n label: 'Feed Reaction',\n pluralLabel: 'Feed Reactions',\n icon: 'smile',\n description: 'Emoji reactions on feed items',\n titleFormat: '{emoji} by {user_id}',\n compactLayout: ['feed_item_id', 'emoji', 'user_id'],\n\n fields: {\n id: Field.text({\n label: 'Reaction ID',\n required: true,\n readonly: true,\n }),\n\n feed_item_id: Field.text({\n label: 'Feed Item ID',\n required: true,\n }),\n\n emoji: Field.text({\n label: 'Emoji',\n required: true,\n description: 'Emoji character or shortcode (e.g., \"👍\", \":thumbsup:\")',\n }),\n\n user_id: Field.text({\n label: 'User ID',\n required: true,\n }),\n\n created_at: Field.datetime({\n label: 'Created At',\n defaultValue: 'NOW()',\n readonly: true,\n }),\n },\n\n indexes: [\n { fields: ['feed_item_id', 'emoji', 'user_id'], unique: true },\n { fields: ['feed_item_id'], unique: false },\n { fields: ['user_id'], unique: false },\n ],\n\n enable: {\n trackHistory: false,\n searchable: false,\n apiEnabled: true,\n apiMethods: ['get', 'list', 'create', 'delete'],\n trash: false,\n mru: false,\n },\n});\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { ObjectSchema, Field } from '@objectstack/spec/data';\n\n/**\n * Record Subscription Object\n *\n * System object for storing record-level notification subscriptions.\n * Enables Airtable-style bell icon for record change notifications.\n *\n * Belongs to `service-feed` package per \"protocol + service ownership\" pattern.\n */\nexport const RecordSubscription = ObjectSchema.create({\n name: 'sys_record_subscription',\n label: 'Record Subscription',\n pluralLabel: 'Record Subscriptions',\n icon: 'bell',\n description: 'Record-level notification subscriptions for feed events',\n titleFormat: '{object}/{record_id} — {user_id}',\n compactLayout: ['object', 'record_id', 'user_id', 'active'],\n\n fields: {\n id: Field.text({\n label: 'Subscription ID',\n required: true,\n readonly: true,\n }),\n\n object: Field.text({\n label: 'Object Name',\n required: true,\n }),\n\n record_id: Field.text({\n label: 'Record ID',\n required: true,\n }),\n\n user_id: Field.text({\n label: 'User ID',\n required: true,\n }),\n\n events: Field.textarea({\n label: 'Subscribed Events',\n description: 'Array of event types: comment, mention, field_change, task, approval, all (JSON)',\n }),\n\n channels: Field.textarea({\n label: 'Notification Channels',\n description: 'Array of channels: in_app, email, push, slack (JSON)',\n }),\n\n active: Field.boolean({\n label: 'Active',\n defaultValue: true,\n }),\n\n created_at: Field.datetime({\n label: 'Created At',\n defaultValue: 'NOW()',\n readonly: true,\n }),\n },\n\n indexes: [\n { fields: ['object', 'record_id', 'user_id'], unique: true },\n { fields: ['user_id'], unique: false },\n { fields: ['object', 'record_id'], unique: false },\n ],\n\n enable: {\n trackHistory: false,\n searchable: false,\n apiEnabled: true,\n apiMethods: ['get', 'list', 'create', 'update', 'delete'],\n trash: false,\n mru: false,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6CO,IAAM,sBAAN,MAAkD;AAAA,EAMvD,YAAY,UAAsC,CAAC,GAAG;AALtD,SAAiB,QAAQ,oBAAI,IAAsB;AACnD,SAAQ,UAAU;AAClB,SAAiB,gBAAgB,oBAAI,IAAgC;AAInE,SAAK,WAAW,QAAQ,YAAY;AAAA,EACtC;AAAA,EAEA,MAAM,SAAS,SAAmD;AAChE,QAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,OAAO,CAAC,EAAE;AAAA,MAC1C,CAAC,SAAS,KAAK,WAAW,QAAQ,UAAU,KAAK,aAAa,QAAQ;AAAA,IACxE;AAGA,QAAI,QAAQ,UAAU,QAAQ,WAAW,OAAO;AAC9C,cAAQ,MAAM,OAAO,CAAC,SAAS;AAC7B,gBAAQ,QAAQ,QAAQ;AAAA,UACtB,KAAK;AACH,mBAAO,KAAK,SAAS;AAAA,UACvB,KAAK;AACH,mBAAO,KAAK,SAAS;AAAA,UACvB,KAAK;AACH,mBAAO,KAAK,SAAS;AAAA,UACvB;AACE,mBAAO;AAAA,QACX;AAAA,MACF,CAAC;AAAA,IACH;AAGA,UAAM,KAAK,CAAC,GAAG,MAAM;AACnB,YAAM,WAAW,IAAI,KAAK,EAAE,SAAS,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,SAAS,EAAE,QAAQ;AACjF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