@jambonz/sdk 0.1.32 → 0.2.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.
Files changed (117) hide show
  1. package/dist/client/index.cjs +6 -0
  2. package/dist/client/index.cjs.map +1 -1
  3. package/dist/client/index.js +6 -0
  4. package/dist/client/index.js.map +1 -1
  5. package/dist/index.cjs +41 -85
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +43 -87
  10. package/dist/index.js.map +1 -1
  11. package/dist/{verb-builder-BCjmdgUX.d.cts → verb-builder-B6zPuGd1.d.cts} +1 -1
  12. package/dist/{verb-builder-tayDQ0fe.d.ts → verb-builder-B7RIVi0t.d.ts} +1 -1
  13. package/dist/webhook/index.cjs +35 -85
  14. package/dist/webhook/index.cjs.map +1 -1
  15. package/dist/webhook/index.d.cts +1 -1
  16. package/dist/webhook/index.d.ts +1 -1
  17. package/dist/webhook/index.js +37 -87
  18. package/dist/webhook/index.js.map +1 -1
  19. package/dist/websocket/index.cjs +35 -85
  20. package/dist/websocket/index.cjs.map +1 -1
  21. package/dist/websocket/index.d.cts +1 -1
  22. package/dist/websocket/index.d.ts +1 -1
  23. package/dist/websocket/index.js +37 -87
  24. package/dist/websocket/index.js.map +1 -1
  25. package/package.json +4 -4
  26. package/schema/callbacks/amd.schema.json +0 -50
  27. package/schema/callbacks/base.schema.json +0 -29
  28. package/schema/callbacks/call-status.schema.json +0 -22
  29. package/schema/callbacks/conference-status.schema.json +0 -24
  30. package/schema/callbacks/conference-wait.schema.json +0 -11
  31. package/schema/callbacks/conference.schema.json +0 -11
  32. package/schema/callbacks/dequeue.schema.json +0 -19
  33. package/schema/callbacks/dial-dtmf.schema.json +0 -18
  34. package/schema/callbacks/dial-hold.schema.json +0 -22
  35. package/schema/callbacks/dial-refer.schema.json +0 -28
  36. package/schema/callbacks/dial.schema.json +0 -31
  37. package/schema/callbacks/enqueue-wait.schema.json +0 -17
  38. package/schema/callbacks/enqueue.schema.json +0 -27
  39. package/schema/callbacks/gather-partial.schema.json +0 -54
  40. package/schema/callbacks/gather.schema.json +0 -60
  41. package/schema/callbacks/listen.schema.json +0 -21
  42. package/schema/callbacks/llm.schema.json +0 -30
  43. package/schema/callbacks/message.schema.json +0 -35
  44. package/schema/callbacks/pipeline-turn.schema.json +0 -109
  45. package/schema/callbacks/play.schema.json +0 -36
  46. package/schema/callbacks/session-new.schema.json +0 -143
  47. package/schema/callbacks/session-reconnect.schema.json +0 -9
  48. package/schema/callbacks/session-redirect.schema.json +0 -38
  49. package/schema/callbacks/sip-refer-event.schema.json +0 -20
  50. package/schema/callbacks/sip-refer.schema.json +0 -22
  51. package/schema/callbacks/sip-request.schema.json +0 -27
  52. package/schema/callbacks/transcribe-translation.schema.json +0 -24
  53. package/schema/callbacks/transcribe.schema.json +0 -46
  54. package/schema/callbacks/tts-streaming-event.schema.json +0 -77
  55. package/schema/callbacks/verb-status.schema.json +0 -57
  56. package/schema/components/actionHook.schema.json +0 -36
  57. package/schema/components/actionHookDelayAction.schema.json +0 -37
  58. package/schema/components/amd.schema.json +0 -68
  59. package/schema/components/auth.schema.json +0 -18
  60. package/schema/components/bidirectionalAudio.schema.json +0 -22
  61. package/schema/components/fillerNoise.schema.json +0 -25
  62. package/schema/components/llm-base.schema.json +0 -94
  63. package/schema/components/recognizer-assemblyAiOptions.schema.json +0 -66
  64. package/schema/components/recognizer-awsOptions.schema.json +0 -52
  65. package/schema/components/recognizer-azureOptions.schema.json +0 -32
  66. package/schema/components/recognizer-cobaltOptions.schema.json +0 -34
  67. package/schema/components/recognizer-customOptions.schema.json +0 -27
  68. package/schema/components/recognizer-deepgramOptions.schema.json +0 -147
  69. package/schema/components/recognizer-elevenlabsOptions.schema.json +0 -39
  70. package/schema/components/recognizer-gladiaOptions.schema.json +0 -8
  71. package/schema/components/recognizer-googleOptions.schema.json +0 -35
  72. package/schema/components/recognizer-houndifyOptions.schema.json +0 -53
  73. package/schema/components/recognizer-ibmOptions.schema.json +0 -54
  74. package/schema/components/recognizer-nuanceOptions.schema.json +0 -150
  75. package/schema/components/recognizer-nvidiaOptions.schema.json +0 -39
  76. package/schema/components/recognizer-openaiOptions.schema.json +0 -59
  77. package/schema/components/recognizer-sonioxOptions.schema.json +0 -46
  78. package/schema/components/recognizer-speechmaticsOptions.schema.json +0 -100
  79. package/schema/components/recognizer-verbioOptions.schema.json +0 -46
  80. package/schema/components/recognizer.schema.json +0 -216
  81. package/schema/components/synthesizer.schema.json +0 -82
  82. package/schema/components/target.schema.json +0 -105
  83. package/schema/components/vad.schema.json +0 -48
  84. package/schema/jambonz-app.schema.json +0 -112
  85. package/schema/verbs/alert.schema.json +0 -34
  86. package/schema/verbs/answer.schema.json +0 -22
  87. package/schema/verbs/conference.schema.json +0 -107
  88. package/schema/verbs/config.schema.json +0 -218
  89. package/schema/verbs/deepgram_s2s.schema.json +0 -81
  90. package/schema/verbs/dequeue.schema.json +0 -51
  91. package/schema/verbs/dial.schema.json +0 -187
  92. package/schema/verbs/dialogflow.schema.json +0 -148
  93. package/schema/verbs/dtmf.schema.json +0 -49
  94. package/schema/verbs/dub.schema.json +0 -103
  95. package/schema/verbs/elevenlabs_s2s.schema.json +0 -81
  96. package/schema/verbs/enqueue.schema.json +0 -53
  97. package/schema/verbs/gather.schema.json +0 -188
  98. package/schema/verbs/google_s2s.schema.json +0 -42
  99. package/schema/verbs/hangup.schema.json +0 -36
  100. package/schema/verbs/leave.schema.json +0 -22
  101. package/schema/verbs/listen.schema.json +0 -127
  102. package/schema/verbs/llm.schema.json +0 -44
  103. package/schema/verbs/message.schema.json +0 -82
  104. package/schema/verbs/openai_s2s.schema.json +0 -42
  105. package/schema/verbs/pause.schema.json +0 -36
  106. package/schema/verbs/pipeline.schema.json +0 -240
  107. package/schema/verbs/play.schema.json +0 -96
  108. package/schema/verbs/redirect.schema.json +0 -34
  109. package/schema/verbs/s2s.schema.json +0 -39
  110. package/schema/verbs/say.schema.json +0 -107
  111. package/schema/verbs/sip-decline.schema.json +0 -58
  112. package/schema/verbs/sip-refer.schema.json +0 -58
  113. package/schema/verbs/sip-request.schema.json +0 -54
  114. package/schema/verbs/stream.schema.json +0 -103
  115. package/schema/verbs/tag.schema.json +0 -41
  116. package/schema/verbs/transcribe.schema.json +0 -57
  117. package/schema/verbs/ultravox_s2s.schema.json +0 -41
package/dist/index.js CHANGED
@@ -1,101 +1,49 @@
1
1
  import Ajv from 'ajv';
2
- import { readFileSync } from 'fs';
3
- import { dirname, resolve } from 'path';
2
+ import { existsSync, readdirSync, readFileSync } from 'fs';
3
+ import { resolve, dirname, basename } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
+ import { createRequire } from 'module';
5
6
  import { createHmac, timingSafeEqual } from 'crypto';
6
7
  import http from 'http';
7
8
  import { WebSocketServer } from 'ws';
8
9
  import { EventEmitter } from 'events';
9
10
 
10
11
  // src/validator.ts
11
- var COMPONENT_SCHEMAS = [
12
- "auth",
13
- "actionHook",
14
- "actionHookDelayAction",
15
- "amd",
16
- "bidirectionalAudio",
17
- "fillerNoise",
18
- "recognizer",
19
- "recognizer-assemblyAiOptions",
20
- "recognizer-awsOptions",
21
- "recognizer-azureOptions",
22
- "recognizer-cobaltOptions",
23
- "recognizer-customOptions",
24
- "recognizer-deepgramOptions",
25
- "recognizer-elevenlabsOptions",
26
- "recognizer-gladiaOptions",
27
- "recognizer-googleOptions",
28
- "recognizer-houndifyOptions",
29
- "recognizer-ibmOptions",
30
- "recognizer-nuanceOptions",
31
- "recognizer-nvidiaOptions",
32
- "recognizer-openaiOptions",
33
- "recognizer-sonioxOptions",
34
- "recognizer-speechmaticsOptions",
35
- "recognizer-verbioOptions",
36
- "llm-base",
37
- "synthesizer",
38
- "target",
39
- "vad"
40
- ];
41
- var VERB_SCHEMAS = [
42
- "answer",
43
- "alert",
44
- "config",
45
- "say",
46
- "play",
47
- "gather",
48
- "dial",
49
- "listen",
50
- "stream",
51
- "llm",
52
- "s2s",
53
- "openai_s2s",
54
- "google_s2s",
55
- "elevenlabs_s2s",
56
- "deepgram_s2s",
57
- "ultravox_s2s",
58
- "dialogflow",
59
- "pipeline",
60
- "conference",
61
- "transcribe",
62
- "enqueue",
63
- "dequeue",
64
- "dtmf",
65
- "dub",
66
- "hangup",
67
- "leave",
68
- "message",
69
- "pause",
70
- "redirect",
71
- "tag",
72
- "sip-decline",
73
- "sip-request",
74
- "sip-refer"
75
- ];
76
- function loadSchema(schemaDir, relativePath) {
77
- const fullPath = resolve(schemaDir, relativePath);
78
- return JSON.parse(readFileSync(fullPath, "utf-8"));
79
- }
80
12
  function findSchemaDir() {
13
+ try {
14
+ const req = createRequire(import.meta.url);
15
+ const schemaIndex = req.resolve("@jambonz/schema");
16
+ const dir2 = resolve(schemaIndex, "..");
17
+ if (existsSync(resolve(dir2, "jambonz-app.schema.json"))) {
18
+ return dir2;
19
+ }
20
+ } catch {
21
+ }
81
22
  const currentDir = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
82
- const candidates = [
83
- resolve(currentDir, "../../schema"),
84
- // from typescript/src/
85
- resolve(currentDir, "../schema")
86
- // from dist/ (tsup bundles to package-root/dist/)
87
- ];
88
- for (const candidate of candidates) {
89
- try {
90
- readFileSync(resolve(candidate, "jambonz-app.schema.json"), "utf-8");
23
+ let dir = currentDir;
24
+ for (let i = 0; i < 10; i++) {
25
+ const candidate = resolve(dir, "node_modules", "@jambonz", "schema");
26
+ if (existsSync(resolve(candidate, "jambonz-app.schema.json"))) {
91
27
  return candidate;
92
- } catch {
93
28
  }
29
+ const parent = dirname(dir);
30
+ if (parent === dir) break;
31
+ dir = parent;
94
32
  }
95
33
  throw new Error(
96
- "Could not find jambonz schema directory. Ensure the schema/ directory is present alongside the typescript/ directory."
34
+ "Could not find @jambonz/schema package. Ensure it is installed as a dependency."
97
35
  );
98
36
  }
37
+ function discoverSchemas(dir) {
38
+ try {
39
+ return readdirSync(dir).filter((f) => f.endsWith(".schema.json")).map((f) => basename(f, ".schema.json"));
40
+ } catch {
41
+ return [];
42
+ }
43
+ }
44
+ function loadSchema(filePath) {
45
+ return JSON.parse(readFileSync(filePath, "utf-8"));
46
+ }
99
47
  var JambonzValidator = class {
100
48
  validateApp;
101
49
  ajv;
@@ -107,15 +55,17 @@ var JambonzValidator = class {
107
55
  validateSchema: false,
108
56
  logger: false
109
57
  });
110
- for (const name of COMPONENT_SCHEMAS) {
111
- const schema = loadSchema(dir, `components/${name}.schema.json`);
58
+ const componentsDir = resolve(dir, "components");
59
+ for (const name of discoverSchemas(componentsDir)) {
60
+ const schema = loadSchema(resolve(componentsDir, `${name}.schema.json`));
112
61
  this.ajv.addSchema(schema);
113
62
  }
114
- for (const name of VERB_SCHEMAS) {
115
- const schema = loadSchema(dir, `verbs/${name}.schema.json`);
63
+ const verbsDir = resolve(dir, "verbs");
64
+ for (const name of discoverSchemas(verbsDir)) {
65
+ const schema = loadSchema(resolve(verbsDir, `${name}.schema.json`));
116
66
  this.ajv.addSchema(schema);
117
67
  }
118
- const appSchema = loadSchema(dir, "jambonz-app.schema.json");
68
+ const appSchema = loadSchema(resolve(dir, "jambonz-app.schema.json"));
119
69
  this.validateApp = this.ajv.compile(appSchema);
120
70
  }
121
71
  /** Validate a complete verb array (a jambonz application). */
@@ -1306,6 +1256,8 @@ var CallsResource = class {
1306
1256
  this.http = http2;
1307
1257
  this.accountSid = accountSid;
1308
1258
  }
1259
+ http;
1260
+ accountSid;
1309
1261
  /** Create a new outbound call. */
1310
1262
  async create(opts) {
1311
1263
  const result = await this.http.post(
@@ -1382,6 +1334,8 @@ var ConferencesResource = class {
1382
1334
  this.http = http2;
1383
1335
  this.accountSid = accountSid;
1384
1336
  }
1337
+ http;
1338
+ accountSid;
1385
1339
  /** List active conferences. */
1386
1340
  async list() {
1387
1341
  return this.http.get(
@@ -1394,6 +1348,8 @@ var QueuesResource = class {
1394
1348
  this.http = http2;
1395
1349
  this.accountSid = accountSid;
1396
1350
  }
1351
+ http;
1352
+ accountSid;
1397
1353
  /** List active queues. */
1398
1354
  async list(search) {
1399
1355
  const qs = search ? `?search=${encodeURIComponent(search)}` : "";