@tellescope/sdk 1.255.2 → 1.255.3

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 (27) hide show
  1. package/lib/cjs/tests/api_tests/generate_enduser_summary.test.d.ts +6 -0
  2. package/lib/cjs/tests/api_tests/generate_enduser_summary.test.d.ts.map +1 -0
  3. package/lib/cjs/tests/api_tests/generate_enduser_summary.test.js +186 -0
  4. package/lib/cjs/tests/api_tests/generate_enduser_summary.test.js.map +1 -0
  5. package/lib/cjs/tests/api_tests/translations.test.d.ts +6 -0
  6. package/lib/cjs/tests/api_tests/translations.test.d.ts.map +1 -0
  7. package/lib/cjs/tests/api_tests/translations.test.js +148 -0
  8. package/lib/cjs/tests/api_tests/translations.test.js.map +1 -0
  9. package/lib/cjs/tests/tests.d.ts.map +1 -1
  10. package/lib/cjs/tests/tests.js +89 -85
  11. package/lib/cjs/tests/tests.js.map +1 -1
  12. package/lib/esm/tests/api_tests/generate_enduser_summary.test.d.ts +6 -0
  13. package/lib/esm/tests/api_tests/generate_enduser_summary.test.d.ts.map +1 -0
  14. package/lib/esm/tests/api_tests/generate_enduser_summary.test.js +182 -0
  15. package/lib/esm/tests/api_tests/generate_enduser_summary.test.js.map +1 -0
  16. package/lib/esm/tests/api_tests/translations.test.d.ts +6 -0
  17. package/lib/esm/tests/api_tests/translations.test.d.ts.map +1 -0
  18. package/lib/esm/tests/api_tests/translations.test.js +144 -0
  19. package/lib/esm/tests/api_tests/translations.test.js.map +1 -0
  20. package/lib/esm/tests/tests.d.ts.map +1 -1
  21. package/lib/esm/tests/tests.js +89 -85
  22. package/lib/esm/tests/tests.js.map +1 -1
  23. package/lib/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +10 -10
  25. package/src/tests/api_tests/translations.test.ts +83 -0
  26. package/src/tests/tests.ts +2 -0
  27. package/test_generated.pdf +0 -0
@@ -0,0 +1,83 @@
1
+ require('source-map-support').install();
2
+
3
+ import { Session } from "../../sdk"
4
+ import {
5
+ assert,
6
+ log_header,
7
+ } from "@tellescope/testing"
8
+ import { setup_tests } from "../setup"
9
+
10
+ const host = process.env.API_URL || 'http://localhost:8080' as const
11
+
12
+ // Modular test for the translations framework.
13
+ // Validates that a model's `translations` field (nested { field: { language: text } }) is accepted by
14
+ // schema validation, persists, and accumulates multiple languages (uses phone_calls as the MVP model).
15
+ //
16
+ // NOTE: this test deliberately does NOT invoke the AI translation endpoint (ai_conversations.send_message).
17
+ // That path consumes AI credits and belongs in an eval, not a regularly-run test. The endpoint itself is
18
+ // already covered by the AI Summary feature, and the translation-specific logic (the system-prompt
19
+ // builder in @tellescope/utilities) is a pure function verified at compile time.
20
+ export const translations_tests = async ({ sdk } : { sdk: Session, sdkNonAdmin: Session }) => {
21
+ log_header("Translations Framework Tests")
22
+
23
+ const enduser = await sdk.api.endusers.createOne({ fname: 'Translation', lname: 'Tester' })
24
+ let callId: string | undefined
25
+
26
+ try {
27
+ const call = await sdk.api.phone_calls.createOne({
28
+ enduserId: enduser.id,
29
+ inbound: true,
30
+ userId: sdk.userInfo.id,
31
+ transcription: 'Hola, por favor devuélvame la llamada cuando pueda.',
32
+ })
33
+ callId = call.id
34
+
35
+ // --- 1. translations field accepted + persisted ---
36
+ const translations = { transcription: { en: 'Hi, please call me back when you can.' } }
37
+ await sdk.api.phone_calls.updateOne(call.id, { translations }, { replaceObjectFields: true })
38
+
39
+ const updated = await sdk.api.phone_calls.getOne(call.id)
40
+ assert(
41
+ updated.translations?.transcription?.en === translations.transcription.en,
42
+ `translations not persisted: ${JSON.stringify(updated.translations)}`,
43
+ 'translations field persisted correctly',
44
+ )
45
+
46
+ // add a second language and confirm accumulation (full merged object written by convention)
47
+ const merged = {
48
+ ...updated.translations,
49
+ transcription: { ...updated.translations?.transcription, es: 'Hola de nuevo.' },
50
+ }
51
+ await sdk.api.phone_calls.updateOne(call.id, { translations: merged }, { replaceObjectFields: true })
52
+ const updated2 = await sdk.api.phone_calls.getOne(call.id)
53
+ assert(
54
+ !!updated2.translations?.transcription?.en && !!updated2.translations?.transcription?.es,
55
+ `translations did not accumulate: ${JSON.stringify(updated2.translations)}`,
56
+ 'multiple language translations accumulate under one field',
57
+ )
58
+ } finally {
59
+ if (callId) await sdk.api.phone_calls.deleteOne(callId).catch(() => {})
60
+ await sdk.api.endusers.deleteOne(enduser.id).catch(() => {})
61
+ }
62
+ }
63
+
64
+ // Allow running this test file independently
65
+ if (require.main === module) {
66
+ const sdk = new Session({ host })
67
+ const sdkNonAdmin = new Session({ host })
68
+
69
+ const runTests = async () => {
70
+ await setup_tests(sdk, sdkNonAdmin)
71
+ await translations_tests({ sdk, sdkNonAdmin })
72
+ }
73
+
74
+ runTests()
75
+ .then(() => {
76
+ console.log("✅ Translations test suite completed successfully")
77
+ process.exit(0)
78
+ })
79
+ .catch((error) => {
80
+ console.error("❌ Translations test suite failed:", error)
81
+ process.exit(1)
82
+ })
83
+ }
@@ -36,6 +36,7 @@ import {
36
36
 
37
37
  import { Session, APIQuery, EnduserSession } from "../sdk"
38
38
  import { enduser_observations_acknowledge_tests } from "./api_tests/enduser_observations_acknowledge.test"
39
+ import { translations_tests } from "./api_tests/translations.test"
39
40
  import { user_portal_settings_tests } from "./api_tests/user_portal_settings.test"
40
41
  import { integrations_redacted_tests } from "./api_tests/integrations_redacted.test"
41
42
  import { get_some_projection_tests } from "./api_tests/get_some_projection.test"
@@ -15113,6 +15114,7 @@ const ip_address_form_tests = async () => {
15113
15114
  await inbox_threads_loading_tests()
15114
15115
  await load_inbox_data_tests({ sdk, sdkNonAdmin })
15115
15116
  await enduser_observations_acknowledge_tests({ sdk, sdkNonAdmin })
15117
+ await translations_tests({ sdk, sdkNonAdmin })
15116
15118
  await create_user_notifications_trigger_tests({ sdk })
15117
15119
  await group_mms_active_tests()
15118
15120
  await auto_reply_tests()
Binary file