@things-factory/ai-assistant 10.1.270 → 10.1.271

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/ai-assistant",
3
- "version": "10.1.270",
3
+ "version": "10.1.271",
4
4
  "main": "dist-server/index.js",
5
5
  "things-factory": true,
6
6
  "author": "heartyoh",
@@ -36,13 +36,13 @@
36
36
  "@operato/shell": "^10.29.69",
37
37
  "@operato/styles": "^10.0.0",
38
38
  "@operato/utils": "^10.29.76",
39
- "@things-factory/ai-client-base": "^10.1.270",
39
+ "@things-factory/ai-client-base": "^10.1.271",
40
40
  "@things-factory/apptool-base": "^10.1.270",
41
- "@things-factory/attachment-base": "^10.1.270",
42
- "@things-factory/auth-base": "^10.1.270",
41
+ "@things-factory/attachment-base": "^10.1.271",
42
+ "@things-factory/auth-base": "^10.1.271",
43
43
  "@things-factory/env": "^10.1.149",
44
44
  "@things-factory/help": "^10.1.270",
45
- "@things-factory/setting-base": "^10.1.270",
45
+ "@things-factory/setting-base": "^10.1.271",
46
46
  "@things-factory/shell": "^10.1.270",
47
47
  "dompurify": "^3.0.0",
48
48
  "exceljs": "4.2.0",
@@ -59,5 +59,5 @@
59
59
  "copyfiles": "^2.4.1",
60
60
  "rimraf": "^5.0.0"
61
61
  },
62
- "gitHead": "9fb23e57702302f1a6c6572d9f0f37ef6f12b446"
62
+ "gitHead": "843bc2608d8c89348ced871777535966758927db"
63
63
  }
@@ -395,7 +395,7 @@ export class AssistantChatResolver {
395
395
  visibility: (session as any).visibility
396
396
  })
397
397
  /* 편지가 못 갔다고 방에 들어온 사실이 취소되지는 않는다(`sendInviteNotification`). */
398
- await sendInviteNotification((context.state as any)?.notify, invite.invited, user, (session as any)?.name, undefined, requestTranslator(context))
398
+ await sendInviteNotification((context.state as any)?.sendNotice, invite.invited, user, (session as any)?.name, undefined, requestTranslator(context))
399
399
 
400
400
  publishChatMessage({ domainId: domain.id, sessionId: session.id, message: saved } as any)
401
401
  publishSessionActivity({
@@ -41,8 +41,8 @@ let enteredAs: string[]
41
41
  const doors = new ChatSessionResolver()
42
42
  const entry = new EntryProposalResolver()
43
43
 
44
- /** A request as that person - the state a door reads. `notify` keeps what an invite sends. */
45
- const as = (user: any) => ({ state: { domain, user, notify: async (payload: any) => notices.push(payload) } }) as any
44
+ /** A request as that person - the state a door reads. `sendNotice` (notification) keeps what an invite sends. */
45
+ const as = (user: any) => ({ state: { domain, user, sendNotice: (notice: any) => notices.push({ receivers: notice.receivers.map((one: any) => one.id), body: notice.words('ko').body }) } }) as any
46
46
 
47
47
  beforeAll(async () => {
48
48
  db = new TypeOrmDataSource({
@@ -131,7 +131,7 @@ describe('a group conversation', () => {
131
131
 
132
132
  it('★ the owner brings someone in - they are told, and from then on they read and write', async () => {
133
133
  expect(await doors.inviteToAISession(session.id, [guest.id], as(owner))).toEqual([guest.id])
134
- expect(notices.map(n => n.mode)).toEqual(['foreground', 'background'])
134
+ expect(notices).toHaveLength(1)
135
135
  expect(notices[0].receivers).toEqual([guest.id])
136
136
  expect(notices[0].body).toContain('pricing')
137
137
 
@@ -163,7 +163,7 @@ describe('a group conversation', () => {
163
163
  it("the owner's mention seats, as the invite does", async () => {
164
164
  await doors.sayToRoom(session.id, `see @guest{userId:${guest.id}}`, undefined, as(owner))
165
165
  expect(await roomHears(guest)).toBe(true)
166
- expect(notices.map(n => n.receivers)).toEqual([[guest.id], [guest.id]])
166
+ expect(notices.map(n => n.receivers)).toEqual([[guest.id]])
167
167
  })
168
168
 
169
169
  it('a person outside the domain is not seated', async () => {
@@ -44,23 +44,23 @@ describe('an invite outside a board', () => {
44
44
  })
45
45
  })
46
46
 
47
- describe('sendInviteNotification — the list and the push', () => {
48
- test('★ the invite reaches the app\'s notification list (foreground) and the push (background)', async () => {
47
+ describe('sendInviteNotification — one kept notice', () => {
48
+ test('★ the invite is one notice to the people seated, kept by notification, at the board when there is one', async () => {
49
49
  const sent: any[] = []
50
- await sendInviteNotification(async (payload: any) => void sent.push(payload), ['u1'], { name: 'Kim' }, 'pricing')
51
- expect(sent.map(one => one.mode)).toEqual(['foreground', 'background'])
52
- expect(sent.every(one => one.receivers.join() === 'u1' && one.body.includes('pricing'))).toBe(true)
50
+ await sendInviteNotification(notice => void sent.push(notice), ['u1', 'u2'], { name: 'Kim' }, 'pricing', 'board-7')
51
+ expect(sent).toHaveLength(1)
52
+ expect(sent[0]).toMatchObject({ type: 'board-collab-invite', receivers: [{ id: 'u1' }, { id: 'u2' }], address: 'board-modeller/board-7' })
53
+ expect(sent[0].words('ko')).toMatchObject({ subject: 'Board collaboration invite', summary: 'Kim invited you to collaborate on a board.' })
53
54
  })
54
55
 
55
- test('a failed way does not stop the other, and nobody to tell sends nothing', async () => {
56
- const sent: any[] = []
57
- await sendInviteNotification(async (payload: any) => {
58
- if (payload.mode === 'foreground') throw new Error('down')
59
- sent.push(payload)
56
+ test('a notice that fails does not undo the seat, and nobody to tell sends nothing', async () => {
57
+ await sendInviteNotification(() => {
58
+ throw new Error('down')
60
59
  }, ['u1'], null)
61
- expect(sent.map(one => one.mode)).toEqual(['background'])
62
- await sendInviteNotification(async () => { throw new Error('never') }, [], null)
60
+ const sent: any[] = []
61
+ await sendInviteNotification(notice => void sent.push(notice), [], null)
63
62
  await sendInviteNotification(undefined, ['u1'], null)
63
+ expect(sent).toEqual([])
64
64
  })
65
65
  })
66
66
 
@@ -76,15 +76,24 @@ export function buildInviteNotification(
76
76
  }
77
77
  }
78
78
 
79
+ /** notification's `sendNotice` (ADR-0164 amendment 1) - the request state carries it when notification is loaded. */
80
+ export type SendNotice = (notice: {
81
+ type: string
82
+ receivers: { id: string }[]
83
+ words: (lng: string) => { subject: string; summary: string; body: string; action: string; note: string }
84
+ address: string
85
+ label: string
86
+ }) => unknown
87
+
79
88
  /**
80
- * Tell the people just seated - in the app's notification list while they are in it (`foreground`, published to
81
- * them live) and by web push when they are not (`background`). The notifier takes one way per call, so it is
82
- * called once for each; the list was the one place an invite never reached (2026-10-24: only push was sent).
89
+ * Tell the people just seated - kept for each of them, so their inbox has it on every device, live to the screens they
90
+ * have open and by web push (notification's `sendNotice`). Until 2026-11-11 the invite went as a live signal and a
91
+ * push only: one not looking at the app when invited never saw it in the inbox.
83
92
  *
84
93
  * A letter that does not arrive does not undo the seat - the roster is the record, the notice only tells of it.
85
94
  */
86
95
  export async function sendInviteNotification(
87
- notify: ((payload: InviteNotification) => Promise<unknown> | unknown) | undefined,
96
+ sendNotice: SendNotice | undefined,
88
97
  userIds: string[],
89
98
  inviter: Inviter | undefined | null,
90
99
  sessionName?: string | null,
@@ -93,12 +102,17 @@ export async function sendInviteNotification(
93
102
  t?: InviteTranslate
94
103
  ): Promise<void> {
95
104
  const payload = buildInviteNotification(userIds, boardId, inviter, sessionName, t)
96
- if (!payload || !notify) return
97
- for (const mode of ['foreground', 'background'] as const) {
98
- try {
99
- await notify({ ...payload, mode })
100
- } catch {
101
- /* the other way may still reach them */
102
- }
105
+ if (!payload || typeof sendNotice !== 'function') return
106
+ try {
107
+ await sendNotice({
108
+ type: payload.type,
109
+ receivers: payload.receivers.map(id => ({ id })),
110
+ /* the inviting request's language - the people of one domain read one (see above) */
111
+ words: () => ({ subject: payload.title, summary: payload.body, body: payload.body, action: payload.title, note: '' }),
112
+ address: payload.url ?? '',
113
+ label: `${payload.type} to ${payload.receivers.length}`
114
+ })
115
+ } catch {
116
+ /* the seat stands */
103
117
  }
104
118
  }
@@ -41,7 +41,7 @@ const inboxReads = new WeakMap<object, Map<string, Promise<any[]>>>()
41
41
 
42
42
  /** 초대 알림 — 발송은 호스트의 기전을 그대로 쓴다(`sendInviteNotification`, 문 셋이 같은 한 곳). */
43
43
  async function notifyInvited(context: any, invited: string[], inviter: any, sessionName?: string): Promise<void> {
44
- await sendInviteNotification(context.state?.notify, invited, inviter, sessionName, undefined, requestTranslator(context))
44
+ await sendInviteNotification((context.state as any)?.sendNotice, invited, inviter, sessionName, undefined, requestTranslator(context))
45
45
  }
46
46
 
47
47
  /**