@talkpilot/core-db 1.3.85 → 1.3.86

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.
Files changed (72) hide show
  1. package/README.md +1 -0
  2. package/dist/municipal/muniIssues/index.d.ts +3 -2
  3. package/dist/municipal/muniIssues/index.d.ts.map +1 -1
  4. package/dist/municipal/muniIssues/index.js +4 -1
  5. package/dist/municipal/muniIssues/index.js.map +1 -1
  6. package/dist/municipal/muniIssues/muniIssues.constants.d.ts +2 -0
  7. package/dist/municipal/muniIssues/muniIssues.constants.d.ts.map +1 -1
  8. package/dist/municipal/muniIssues/muniIssues.constants.js +8 -1
  9. package/dist/municipal/muniIssues/muniIssues.constants.js.map +1 -1
  10. package/dist/municipal/muniIssues/muniIssues.getters.d.ts +4 -1
  11. package/dist/municipal/muniIssues/muniIssues.getters.d.ts.map +1 -1
  12. package/dist/municipal/muniIssues/muniIssues.getters.js +35 -1
  13. package/dist/municipal/muniIssues/muniIssues.getters.js.map +1 -1
  14. package/dist/municipal/muniIssues/muniIssues.schema.d.ts.map +1 -1
  15. package/dist/municipal/muniIssues/muniIssues.schema.js +17 -0
  16. package/dist/municipal/muniIssues/muniIssues.schema.js.map +1 -1
  17. package/dist/municipal/muniIssues/muniIssues.setters.d.ts +3 -1
  18. package/dist/municipal/muniIssues/muniIssues.setters.d.ts.map +1 -1
  19. package/dist/municipal/muniIssues/muniIssues.setters.js +46 -2
  20. package/dist/municipal/muniIssues/muniIssues.setters.js.map +1 -1
  21. package/dist/municipal/muniIssues/muniIssues.types.d.ts +22 -2
  22. package/dist/municipal/muniIssues/muniIssues.types.d.ts.map +1 -1
  23. package/dist/municipal/muniIssues/muniIssues.utils.d.ts +3 -0
  24. package/dist/municipal/muniIssues/muniIssues.utils.d.ts.map +1 -0
  25. package/dist/municipal/muniIssues/muniIssues.utils.js +6 -0
  26. package/dist/municipal/muniIssues/muniIssues.utils.js.map +1 -0
  27. package/dist/talkpilot/contextNotes/contextNotes.getters.d.ts +1 -7
  28. package/dist/talkpilot/contextNotes/contextNotes.getters.d.ts.map +1 -1
  29. package/dist/talkpilot/contextNotes/contextNotes.getters.js +1 -37
  30. package/dist/talkpilot/contextNotes/contextNotes.getters.js.map +1 -1
  31. package/dist/talkpilot/contextNotes/contextNotes.types.d.ts +0 -6
  32. package/dist/talkpilot/contextNotes/contextNotes.types.d.ts.map +1 -1
  33. package/dist/talkpilot/flows/flows.schema.d.ts +9 -0
  34. package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
  35. package/dist/talkpilot/flows/flows.schema.js +7 -0
  36. package/dist/talkpilot/flows/flows.schema.js.map +1 -1
  37. package/dist/talkpilot/flows/flows.types.d.ts +3 -0
  38. package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
  39. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +4 -0
  40. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +1 -0
  41. package/dist/talkpilot/subscriptions/subscriptions.utils.js +20 -0
  42. package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +1 -0
  43. package/package.json +1 -1
  44. package/src/municipal/muniIssues/__tests__/muniIssues.getters.spec.ts +87 -0
  45. package/src/municipal/muniIssues/__tests__/muniIssues.setters.spec.ts +126 -1
  46. package/src/municipal/muniIssues/__tests__/muniIssues.setup.spec.ts +1 -0
  47. package/src/municipal/muniIssues/__tests__/muniIssues.utils.spec.ts +17 -0
  48. package/src/municipal/muniIssues/index.ts +7 -0
  49. package/src/municipal/muniIssues/muniIssues.constants.ts +9 -0
  50. package/src/municipal/muniIssues/muniIssues.getters.ts +51 -2
  51. package/src/municipal/muniIssues/muniIssues.schema.ts +19 -0
  52. package/src/municipal/muniIssues/muniIssues.setters.ts +66 -3
  53. package/src/municipal/muniIssues/muniIssues.types.ts +34 -4
  54. package/src/municipal/muniIssues/muniIssues.utils.ts +6 -0
  55. package/src/talkpilot/contextNotes/__tests__/contextNotes.getters.spec.ts +0 -141
  56. package/src/talkpilot/contextNotes/contextNotes.getters.ts +1 -75
  57. package/src/talkpilot/contextNotes/contextNotes.types.ts +0 -7
  58. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +11 -0
  59. package/src/talkpilot/flows/flows.schema.ts +7 -0
  60. package/src/talkpilot/flows/flows.types.ts +1 -0
  61. package/dist/configuration/gptLive.seed.d.ts +0 -2
  62. package/dist/configuration/gptLive.seed.d.ts.map +0 -1
  63. package/dist/configuration/gptLive.seed.js +0 -59
  64. package/dist/configuration/gptLive.seed.js.map +0 -1
  65. package/dist/talkpilot/clients/clients.quota.constants.d.ts +0 -2
  66. package/dist/talkpilot/clients/clients.quota.constants.d.ts.map +0 -1
  67. package/dist/talkpilot/clients/clients.quota.constants.js +0 -5
  68. package/dist/talkpilot/clients/clients.quota.constants.js.map +0 -1
  69. package/dist/talkpilot/clients/clients.quota.utils.d.ts +0 -8
  70. package/dist/talkpilot/clients/clients.quota.utils.d.ts.map +0 -1
  71. package/dist/talkpilot/clients/clients.quota.utils.js +0 -45
  72. package/dist/talkpilot/clients/clients.quota.utils.js.map +0 -1
@@ -6,9 +6,6 @@ import {
6
6
  setContextNoteEntries,
7
7
  setContextNoteConfig,
8
8
  deleteContextNoteEntry,
9
- appendContextNoteEntry,
10
- updateContextNoteEntryFields,
11
- pullContextNoteEntry,
12
9
  } from "../contextNotes.getters";
13
10
  import { ObjectId } from "../../index";
14
11
  import {
@@ -206,144 +203,6 @@ describe("contextNotes getters", () => {
206
203
  expect(saved?.notes[0]._id.toString()).toBe(noteToKeep._id.toString());
207
204
  });
208
205
 
209
- it("should append one note without replacing the others", async () => {
210
- const kept = createContextNoteEntry({ title: "kept" });
211
- const doc = buildContextNote({ notes: [kept] });
212
- await createContextNote(doc);
213
- const now = new Date("2026-10-18T12:00:00.000Z");
214
-
215
- const added = await appendContextNoteEntry(
216
- doc.clientId,
217
- doc.product,
218
- {
219
- title: "added",
220
- content: "new content",
221
- activeFrom: now,
222
- expiresAt: null,
223
- },
224
- now,
225
- );
226
-
227
- const saved = await getContextNotesCollection().findOne({
228
- clientId: doc.clientId,
229
- product: doc.product,
230
- });
231
- expect(saved?.notes).toHaveLength(2);
232
- expect(saved?.notes[0]._id.toString()).toBe(kept._id.toString());
233
- expect(saved?.notes[1].title).toBe("added");
234
- expect(added._id.toString()).toBe(saved?.notes[1]._id.toString());
235
- expect(added.createdAt).toEqual(now);
236
- });
237
-
238
- it("should create the document when appending the first note", async () => {
239
- const clientId = new ObjectId().toString();
240
- const now = new Date("2026-10-18T12:00:00.000Z");
241
-
242
- const added = await appendContextNoteEntry(
243
- clientId,
244
- "Municipal",
245
- {
246
- title: "first",
247
- content: "content",
248
- activeFrom: now,
249
- expiresAt: null,
250
- },
251
- now,
252
- );
253
-
254
- const saved = await getContextNotes(clientId, "Municipal");
255
- expect(saved).toHaveLength(1);
256
- expect(saved[0].notes).toHaveLength(1);
257
- expect(saved[0].notes[0]._id.toString()).toBe(added._id.toString());
258
- });
259
-
260
- it("should update one note and leave the others unchanged", async () => {
261
- const kept = createContextNoteEntry({ title: "kept" });
262
- const target = createContextNoteEntry({ title: "before" });
263
- const doc = buildContextNote({ notes: [kept, target] });
264
- await createContextNote(doc);
265
- const now = new Date("2026-10-18T13:00:00.000Z");
266
- const activeFrom = new Date("2026-10-01T00:00:00.000Z");
267
-
268
- const updated = await updateContextNoteEntryFields(
269
- doc.clientId,
270
- doc.product,
271
- target._id,
272
- {
273
- title: "after",
274
- content: "changed",
275
- activeFrom,
276
- expiresAt: null,
277
- },
278
- now,
279
- );
280
-
281
- const saved = await getContextNotesCollection().findOne({
282
- clientId: doc.clientId,
283
- product: doc.product,
284
- });
285
- expect(updated?.title).toBe("after");
286
- expect(updated?.updatedAt).toEqual(now);
287
- expect(saved?.notes).toHaveLength(2);
288
- expect(saved?.notes[0].title).toBe("kept");
289
- expect(saved?.notes[1].title).toBe("after");
290
- expect(saved?.notes[1].content).toBe("changed");
291
- expect(saved?.notes[1].createdAt).toEqual(target.createdAt);
292
- });
293
-
294
- it("should return null when updating a missing note", async () => {
295
- const doc = buildContextNote({ notes: [createContextNoteEntry()] });
296
- await createContextNote(doc);
297
-
298
- const updated = await updateContextNoteEntryFields(
299
- doc.clientId,
300
- doc.product,
301
- new ObjectId(),
302
- {
303
- title: "missing",
304
- content: "missing",
305
- activeFrom: new Date(),
306
- expiresAt: null,
307
- },
308
- );
309
-
310
- expect(updated).toBeNull();
311
- });
312
-
313
- it("should pull one note and leave the others", async () => {
314
- const kept = createContextNoteEntry();
315
- const removed = createContextNoteEntry();
316
- const doc = buildContextNote({ notes: [kept, removed] });
317
- await createContextNote(doc);
318
-
319
- const pulled = await pullContextNoteEntry(
320
- doc.clientId,
321
- doc.product,
322
- removed._id,
323
- );
324
-
325
- const saved = await getContextNotesCollection().findOne({
326
- clientId: doc.clientId,
327
- product: doc.product,
328
- });
329
- expect(pulled).toBe(true);
330
- expect(saved?.notes).toHaveLength(1);
331
- expect(saved?.notes[0]._id.toString()).toBe(kept._id.toString());
332
- });
333
-
334
- it("should return false when pulling a missing note", async () => {
335
- const doc = buildContextNote({ notes: [createContextNoteEntry()] });
336
- await createContextNote(doc);
337
-
338
- const pulled = await pullContextNoteEntry(
339
- doc.clientId,
340
- doc.product,
341
- new ObjectId(),
342
- );
343
-
344
- expect(pulled).toBe(false);
345
- });
346
-
347
206
  it("should return false when deleteContextNoteEntry targets a non-existent note", async () => {
348
207
  const doc = buildContextNote({ notes: [] });
349
208
  const id = await createContextNote(doc);
@@ -1,10 +1,6 @@
1
1
  import { Collection, ObjectId, WithId } from "mongodb";
2
2
  import { getDb } from "../index";
3
- import type {
4
- ContextNote,
5
- ContextNoteEntry,
6
- ContextNoteEntryWrite,
7
- } from "./contextNotes.types";
3
+ import type { ContextNote, ContextNoteEntry } from "./contextNotes.types";
8
4
 
9
5
  export const getContextNotesCollection = (): Collection<ContextNote> => {
10
6
  return getDb().collection<ContextNote>("contextNotes");
@@ -75,76 +71,6 @@ export const setContextNoteConfig = async (
75
71
  return result.matchedCount > 0;
76
72
  };
77
73
 
78
- const findNoteEntryById = (
79
- doc: WithId<ContextNote> | null,
80
- noteId: ObjectId,
81
- ): ContextNoteEntry | null =>
82
- doc?.notes.find((note) => note._id.equals(noteId)) ?? null;
83
-
84
- /** Appends one note. Other notes on the document are left untouched. */
85
- export const appendContextNoteEntry = async (
86
- clientId: string,
87
- product: string,
88
- entry: ContextNoteEntryWrite,
89
- now: Date = new Date(),
90
- ): Promise<ContextNoteEntry> => {
91
- const note: ContextNoteEntry = {
92
- _id: new ObjectId(),
93
- title: entry.title,
94
- content: entry.content,
95
- activeFrom: entry.activeFrom,
96
- expiresAt: entry.expiresAt,
97
- createdAt: now,
98
- updatedAt: now,
99
- };
100
-
101
- const saved = await getContextNotesCollection().findOneAndUpdate(
102
- { clientId, product },
103
- { $push: { notes: note } },
104
- { upsert: true, returnDocument: "after" },
105
- );
106
-
107
- return findNoteEntryById(saved, note._id) ?? note;
108
- };
109
-
110
- /** Replaces one note's fields. Other notes on the document are left untouched. */
111
- export const updateContextNoteEntryFields = async (
112
- clientId: string,
113
- product: string,
114
- noteId: ObjectId,
115
- entry: ContextNoteEntryWrite,
116
- now: Date = new Date(),
117
- ): Promise<ContextNoteEntry | null> => {
118
- const saved = await getContextNotesCollection().findOneAndUpdate(
119
- { clientId, product, "notes._id": noteId },
120
- {
121
- $set: {
122
- "notes.$.title": entry.title,
123
- "notes.$.content": entry.content,
124
- "notes.$.activeFrom": entry.activeFrom,
125
- "notes.$.expiresAt": entry.expiresAt,
126
- "notes.$.updatedAt": now,
127
- },
128
- },
129
- { returnDocument: "after" },
130
- );
131
-
132
- return findNoteEntryById(saved, noteId);
133
- };
134
-
135
- /** Removes one note by id. Other notes on the document are left untouched. */
136
- export const pullContextNoteEntry = async (
137
- clientId: string,
138
- product: string,
139
- noteId: ObjectId,
140
- ): Promise<boolean> => {
141
- const result = await getContextNotesCollection().updateOne(
142
- { clientId, product, "notes._id": noteId },
143
- { $pull: { notes: { _id: noteId } } },
144
- );
145
- return result.modifiedCount > 0;
146
- };
147
-
148
74
  /** Removes a single note entry from a document by its _id. */
149
75
  export const deleteContextNoteEntry = async (
150
76
  id: ObjectId,
@@ -10,13 +10,6 @@ export type ContextNoteEntry = {
10
10
  updatedAt: Date;
11
11
  };
12
12
 
13
- export type ContextNoteEntryWrite = {
14
- title: string;
15
- content: string;
16
- activeFrom: Date;
17
- expiresAt: Date | null;
18
- };
19
-
20
13
  export type ContextNote = {
21
14
  _id: ObjectId;
22
15
  clientId: string;
@@ -3,6 +3,17 @@ import { getDb } from "../../index";
3
3
  import { flowMongoSchema } from "../flows.schema";
4
4
 
5
5
  describe("flowMongoSchema", () => {
6
+ it("defines keypadInput as an optional object", () => {
7
+ const schema: any = flowMongoSchema;
8
+
9
+ expect(schema.properties).toHaveProperty("keypadInput");
10
+ expect(schema.properties.keypadInput.bsonType).toEqual(["object", "null"]);
11
+ expect(schema.properties.keypadInput.properties.enabled.bsonType).toBe(
12
+ "bool",
13
+ );
14
+ expect(schema.required).not.toContain("keypadInput");
15
+ });
16
+
6
17
  it("defines disableGenericPrompt as optional bool", () => {
7
18
  const schema: any = flowMongoSchema;
8
19
 
@@ -13,6 +13,13 @@ export const flowMongoSchema = {
13
13
  systemInstructions: { bsonType: "string" },
14
14
  initialSentence: { bsonType: "string" },
15
15
  disableGenericPrompt: { bsonType: "bool" },
16
+ keypadInput: {
17
+ bsonType: ["object", "null"],
18
+ properties: {
19
+ enabled: { bsonType: "bool" },
20
+ },
21
+ additionalProperties: false,
22
+ },
16
23
  voice: { bsonType: ["string", "null"] },
17
24
  conversationSettings: {
18
25
  bsonType: ["object", "null"],
@@ -181,6 +181,7 @@ export type Flow = {
181
181
  freeTextContent?: string;
182
182
  isFreeText?: boolean;
183
183
  disableGenericPrompt?: boolean;
184
+ keypadInput?: { enabled?: boolean } | null;
184
185
  _id?: ObjectId;
185
186
 
186
187
  flowName: string;
@@ -1,2 +0,0 @@
1
- export declare function seedGptLiveDocuments(): Promise<void>;
2
- //# sourceMappingURL=gptLive.seed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gptLive.seed.d.ts","sourceRoot":"","sources":["../../src/configuration/gptLive.seed.ts"],"names":[],"mappings":"AA2BA,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAyC1D"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.seedGptLiveDocuments = seedGptLiveDocuments;
4
- const mongodb_1 = require("mongodb");
5
- const models_getters_1 = require("./models/models.getters");
6
- const prompts_getters_1 = require("./prompts/prompts.getters");
7
- const GPT_LIVE_MODEL_ID = "gpt-live-1";
8
- const VOICE_PROMPT = "gptLiveVoiceInstructions";
9
- const BACKEND_PROMPT = "gptLiveBackendInstructions";
10
- const VOICE_INSTRUCTIONS = [
11
- "You are a phone agent on a live call. Speak naturally and briefly.",
12
- "{{flowInstructions}}",
13
- "Backchannel: {{backchannelPolicy}}",
14
- "Interruptions: {{interruptionPolicy}}",
15
- "Delegation: {{delegationPolicy}}",
16
- "When the flow is finished, say one short closing line and then stop talking.",
17
- ].join("\n");
18
- const BACKEND_INSTRUCTIONS = [
19
- "You are the reasoning backend for a phone agent. Use the tools to do the work.",
20
- "Return only what the tools returned. Never invent a result, a ticket number, or a confirmation.",
21
- "{{flowInstructions}}",
22
- "{{backchannelPolicy}}",
23
- "{{interruptionPolicy}}",
24
- "{{delegationPolicy}}",
25
- ].join("\n");
26
- async function seedGptLiveDocuments() {
27
- const now = new Date();
28
- await (0, models_getters_1.getModelsCollection)().updateOne({ modelId: GPT_LIVE_MODEL_ID, type: "realtime" }, {
29
- $setOnInsert: {
30
- _id: new mongodb_1.ObjectId(),
31
- modelId: GPT_LIVE_MODEL_ID,
32
- name: "GPT-Live 1",
33
- description: "Turnless full-duplex voice",
34
- type: "realtime",
35
- provider: "openai-live",
36
- available: true,
37
- features: { supportsAudio: true },
38
- configDefaults: { backendModel: "gpt-5.6-luna" },
39
- createdAt: now,
40
- updatedAt: now,
41
- },
42
- }, { upsert: true });
43
- for (const prompt of [
44
- { name: VOICE_PROMPT, content: VOICE_INSTRUCTIONS },
45
- { name: BACKEND_PROMPT, content: BACKEND_INSTRUCTIONS },
46
- ]) {
47
- await (0, prompts_getters_1.getPromptsCollection)().updateOne({ name: prompt.name }, {
48
- $setOnInsert: {
49
- _id: new mongodb_1.ObjectId(),
50
- name: prompt.name,
51
- content: prompt.content,
52
- productName: "municipal",
53
- createdAt: now,
54
- updatedAt: now,
55
- },
56
- }, { upsert: true });
57
- }
58
- }
59
- //# sourceMappingURL=gptLive.seed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gptLive.seed.js","sourceRoot":"","sources":["../../src/configuration/gptLive.seed.ts"],"names":[],"mappings":";;AA2BA,oDAyCC;AApED,qCAA2C;AAC3C,4DAA8D;AAC9D,+DAAiE;AAGjE,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAChD,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,MAAM,kBAAkB,GAAG;IACzB,oEAAoE;IACpE,sBAAsB;IACtB,oCAAoC;IACpC,uCAAuC;IACvC,kCAAkC;IAClC,8EAA8E;CAC/E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,oBAAoB,GAAG;IAC3B,gFAAgF;IAChF,iGAAiG;IACjG,sBAAsB;IACtB,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;CACvB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEN,KAAK,UAAU,oBAAoB;IACxC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,IAAA,oCAAmB,GAAE,CAAC,SAAS,CACnC,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAsB,EACpE;QACE,YAAY,EAAE;YACZ,GAAG,EAAE,IAAI,kBAAQ,EAAE;YACnB,OAAO,EAAE,iBAAiB;YAC1B,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,4BAA4B;YACzC,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,aAAa;YACvB,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;YACjC,cAAc,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE;YAChD,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;SACQ;KACzB,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI;QACnB,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,EAAE;QACnD,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB,EAAE;KACxD,EAAE,CAAC;QACF,MAAM,IAAA,sCAAoB,GAAE,CAAC,SAAS,CACpC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EACrB;YACE,YAAY,EAAE;gBACZ,GAAG,EAAE,IAAI,kBAAQ,EAAE;gBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,WAAW,EAAE,WAAW;gBACxB,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE,GAAG;aACf;SACF,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const FULL_QUOTA_THRESHOLD = 100;
2
- //# sourceMappingURL=clients.quota.constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.constants.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,MAAM,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FULL_QUOTA_THRESHOLD = void 0;
4
- exports.FULL_QUOTA_THRESHOLD = 100;
5
- //# sourceMappingURL=clients.quota.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.constants.js","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,GAAG,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { ClientQuotaNotifications, ClientQuotaState, ClientQuotaStatus, QuotaThresholdAlert } from "./clients.quota.types";
2
- export declare const computeClientQuotaStatus: (quota: ClientQuotaState | null) => ClientQuotaStatus;
3
- export declare const getQuotaAlerts: (quota?: ClientQuotaState) => QuotaThresholdAlert[];
4
- export declare const findFullQuotaAlertIndex: (alerts: QuotaThresholdAlert[]) => number;
5
- export declare const getFullQuotaAlert: (quota?: ClientQuotaState) => QuotaThresholdAlert | undefined;
6
- export declare const isFullQuotaAlert: (thresholdPct: number) => boolean;
7
- export declare const toClientQuotaNotifications: (quota: ClientQuotaState | null) => ClientQuotaNotifications;
8
- //# sourceMappingURL=clients.quota.utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.utils.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,wBAAwB,GACnC,OAAO,gBAAgB,GAAG,IAAI,KAC7B,iBAiBF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,KAAG,mBAAmB,EAClC,CAAC;AAE5C,eAAO,MAAM,uBAAuB,GAAI,QAAQ,mBAAmB,EAAE,KAAG,MACP,CAAC;AAElE,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,gBAAgB,KACvB,mBAAmB,GAAG,SAIxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,KAAG,OAClB,CAAC;AAEvC,eAAO,MAAM,0BAA0B,GACrC,OAAO,gBAAgB,GAAG,IAAI,KAC7B,wBASD,CAAC"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toClientQuotaNotifications = exports.isFullQuotaAlert = exports.getFullQuotaAlert = exports.findFullQuotaAlertIndex = exports.getQuotaAlerts = exports.computeClientQuotaStatus = void 0;
4
- const clients_quota_constants_1 = require("./clients.quota.constants");
5
- const computeUsagePct = (usedQuota, totalQuota) => totalQuota > 0 ? Math.round((usedQuota / totalQuota) * 100) : 0;
6
- const isPastExpiration = (expiresAt) => expiresAt ? Date.now() > new Date(expiresAt).getTime() : false;
7
- const computeClientQuotaStatus = (quota) => {
8
- if (!quota) {
9
- return { hasQuota: false };
10
- }
11
- const totalQuota = quota.totalQuota;
12
- const usedQuota = quota.usedQuota ?? 0;
13
- return {
14
- hasQuota: true,
15
- totalQuota,
16
- usedQuota,
17
- pct: computeUsagePct(usedQuota, totalQuota),
18
- expiresAt: quota.expiresAt ? new Date(quota.expiresAt).toISOString() : null,
19
- isExceeded: usedQuota >= totalQuota,
20
- isExpired: isPastExpiration(quota.expiresAt),
21
- };
22
- };
23
- exports.computeClientQuotaStatus = computeClientQuotaStatus;
24
- const getQuotaAlerts = (quota) => quota?.alerts?.length ? quota.alerts : [];
25
- exports.getQuotaAlerts = getQuotaAlerts;
26
- const findFullQuotaAlertIndex = (alerts) => alerts.findIndex((a) => a.thresholdPct >= clients_quota_constants_1.FULL_QUOTA_THRESHOLD);
27
- exports.findFullQuotaAlertIndex = findFullQuotaAlertIndex;
28
- const getFullQuotaAlert = (quota) => {
29
- const alerts = (0, exports.getQuotaAlerts)(quota);
30
- const index = (0, exports.findFullQuotaAlertIndex)(alerts);
31
- return index >= 0 ? alerts[index] : undefined;
32
- };
33
- exports.getFullQuotaAlert = getFullQuotaAlert;
34
- const isFullQuotaAlert = (thresholdPct) => thresholdPct >= clients_quota_constants_1.FULL_QUOTA_THRESHOLD;
35
- exports.isFullQuotaAlert = isFullQuotaAlert;
36
- const toClientQuotaNotifications = (quota) => ({
37
- alerts: (0, exports.getQuotaAlerts)(quota ?? undefined).map(({ thresholdPct, recipientEmails, thresholdSent }) => ({
38
- thresholdPct,
39
- recipientEmails: recipientEmails ?? [],
40
- ...(thresholdSent ? { thresholdSent: true } : {}),
41
- })),
42
- ...(quota?.expiredSent ? { expiredSent: true } : {}),
43
- });
44
- exports.toClientQuotaNotifications = toClientQuotaNotifications;
45
- //# sourceMappingURL=clients.quota.utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.utils.js","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.utils.ts"],"names":[],"mappings":"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"}