@contractspec/lib.contracts-spec 2.4.0 → 2.5.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 (40) hide show
  1. package/dist/integrations/index.js +379 -53
  2. package/dist/integrations/providers/deepgram.d.ts +3 -0
  3. package/dist/integrations/providers/deepgram.js +129 -0
  4. package/dist/integrations/providers/elevenlabs.js +6 -3
  5. package/dist/integrations/providers/fal-image.d.ts +3 -0
  6. package/dist/integrations/providers/fal-image.js +122 -0
  7. package/dist/integrations/providers/fal.js +2 -2
  8. package/dist/integrations/providers/gradium.js +2 -2
  9. package/dist/integrations/providers/image.d.ts +85 -0
  10. package/dist/integrations/providers/image.js +46 -0
  11. package/dist/integrations/providers/index.d.ts +6 -0
  12. package/dist/integrations/providers/index.js +380 -54
  13. package/dist/integrations/providers/openai-image.d.ts +3 -0
  14. package/dist/integrations/providers/openai-image.js +126 -0
  15. package/dist/integrations/providers/openai-realtime.d.ts +3 -0
  16. package/dist/integrations/providers/openai-realtime.js +127 -0
  17. package/dist/integrations/providers/registry.js +192 -33
  18. package/dist/integrations/providers/voice-video-sync.d.ts +29 -0
  19. package/dist/integrations/providers/voice-video-sync.js +1 -0
  20. package/dist/integrations/providers/voice.d.ts +149 -12
  21. package/dist/integrations/spec.d.ts +1 -1
  22. package/dist/node/integrations/index.js +379 -53
  23. package/dist/node/integrations/providers/deepgram.js +129 -0
  24. package/dist/node/integrations/providers/elevenlabs.js +6 -3
  25. package/dist/node/integrations/providers/fal-image.js +122 -0
  26. package/dist/node/integrations/providers/fal.js +2 -2
  27. package/dist/node/integrations/providers/gradium.js +2 -2
  28. package/dist/node/integrations/providers/image.js +46 -0
  29. package/dist/node/integrations/providers/index.js +380 -54
  30. package/dist/node/integrations/providers/openai-image.js +126 -0
  31. package/dist/node/integrations/providers/openai-realtime.js +127 -0
  32. package/dist/node/integrations/providers/registry.js +192 -33
  33. package/dist/node/integrations/providers/voice-video-sync.js +0 -0
  34. package/dist/node/translations/i18n-factory.js +229 -0
  35. package/dist/node/translations/index.js +64 -4
  36. package/dist/translations/i18n-factory.d.ts +90 -0
  37. package/dist/translations/i18n-factory.js +229 -0
  38. package/dist/translations/index.d.ts +1 -0
  39. package/dist/translations/index.js +64 -4
  40. package/package.json +88 -4
@@ -28,9 +28,6 @@ var __export = (target, all) => {
28
28
  };
29
29
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
30
  var __require = import.meta.require;
31
- // src/translations/spec.ts
32
- var defineTranslation = (spec) => spec;
33
-
34
31
  // src/translations/registry.ts
35
32
  class TranslationRegistry {
36
33
  specs = new Map;
@@ -168,6 +165,63 @@ class TranslationRegistry {
168
165
  }
169
166
  }
170
167
 
168
+ // src/translations/i18n-factory.ts
169
+ var DEFAULT_LOCALE = "en";
170
+ var SUPPORTED_LOCALES = ["en", "fr", "es"];
171
+ function resolveLocale(optionsLocale, runtimeLocale) {
172
+ const raw = runtimeLocale ?? optionsLocale ?? DEFAULT_LOCALE;
173
+ if (isSupportedLocale(raw))
174
+ return raw;
175
+ const base = raw.split("-")[0];
176
+ if (base && isSupportedLocale(base))
177
+ return base;
178
+ return DEFAULT_LOCALE;
179
+ }
180
+ function isSupportedLocale(locale) {
181
+ return SUPPORTED_LOCALES.includes(locale);
182
+ }
183
+ function interpolate(template, params) {
184
+ if (!params)
185
+ return template;
186
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
187
+ if (key in params)
188
+ return String(params[key]);
189
+ return match;
190
+ });
191
+ }
192
+ function createI18nFactory(config) {
193
+ let sharedRegistry = null;
194
+ function getRegistry() {
195
+ if (!sharedRegistry) {
196
+ sharedRegistry = new TranslationRegistry(config.catalogs);
197
+ }
198
+ return sharedRegistry;
199
+ }
200
+ const factory = {
201
+ create(optionsLocale, runtimeLocale) {
202
+ const locale = resolveLocale(optionsLocale, runtimeLocale);
203
+ const registry = getRegistry();
204
+ return {
205
+ locale,
206
+ t(key, params) {
207
+ const raw = registry.getValue(config.specKey, key, locale, key);
208
+ return interpolate(raw, params);
209
+ }
210
+ };
211
+ },
212
+ getDefault() {
213
+ return factory.create(DEFAULT_LOCALE);
214
+ },
215
+ resetRegistry() {
216
+ sharedRegistry = null;
217
+ }
218
+ };
219
+ return factory;
220
+ }
221
+
222
+ // src/translations/spec.ts
223
+ var defineTranslation = (spec) => spec;
224
+
171
225
  // src/translations/validation.ts
172
226
  function validateTranslationSpec(spec) {
173
227
  const issues = [];
@@ -524,10 +578,16 @@ export {
524
578
  validateTranslationSpec,
525
579
  validateTranslationRegistry,
526
580
  validateICUFormat,
581
+ resolveLocale,
582
+ isSupportedLocale,
583
+ interpolate,
527
584
  findMissingTranslations,
528
585
  findAllMissingTranslations,
529
586
  defineTranslation,
587
+ createI18nFactory,
530
588
  assertTranslationSpecValid,
531
589
  TranslationValidationError,
532
- TranslationRegistry
590
+ TranslationRegistry,
591
+ SUPPORTED_LOCALES,
592
+ DEFAULT_LOCALE
533
593
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/lib.contracts-spec",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Spec definitions and registries for ContractSpec",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@blocknote/core": "^0.46.1",
32
- "@contractspec/lib.schema": "2.4.0",
32
+ "@contractspec/lib.schema": "2.5.0",
33
33
  "compare-versions": "^6.1.1",
34
34
  "turndown": "^7.2.2",
35
35
  "zod": "^4.3.5"
@@ -38,8 +38,8 @@
38
38
  "react": "^19.2.4"
39
39
  },
40
40
  "devDependencies": {
41
- "@contractspec/tool.bun": "2.4.0",
42
- "@contractspec/tool.typescript": "2.4.0",
41
+ "@contractspec/tool.bun": "2.5.0",
42
+ "@contractspec/tool.typescript": "2.5.0",
43
43
  "@types/turndown": "^5.0.6",
44
44
  "typescript": "^5.9.3"
45
45
  },
@@ -1014,6 +1014,12 @@
1014
1014
  "node": "./dist/node/integrations/providers/database.js",
1015
1015
  "default": "./dist/integrations/providers/database.js"
1016
1016
  },
1017
+ "./integrations/providers/deepgram": {
1018
+ "types": "./dist/integrations/providers/deepgram.d.ts",
1019
+ "bun": "./dist/integrations/providers/deepgram.js",
1020
+ "node": "./dist/node/integrations/providers/deepgram.js",
1021
+ "default": "./dist/integrations/providers/deepgram.js"
1022
+ },
1017
1023
  "./integrations/providers/elevenlabs": {
1018
1024
  "types": "./dist/integrations/providers/elevenlabs.d.ts",
1019
1025
  "bun": "./dist/integrations/providers/elevenlabs.js",
@@ -1038,6 +1044,12 @@
1038
1044
  "node": "./dist/node/integrations/providers/fal.js",
1039
1045
  "default": "./dist/integrations/providers/fal.js"
1040
1046
  },
1047
+ "./integrations/providers/fal-image": {
1048
+ "types": "./dist/integrations/providers/fal-image.d.ts",
1049
+ "bun": "./dist/integrations/providers/fal-image.js",
1050
+ "node": "./dist/node/integrations/providers/fal-image.js",
1051
+ "default": "./dist/integrations/providers/fal-image.js"
1052
+ },
1041
1053
  "./integrations/providers/fathom": {
1042
1054
  "types": "./dist/integrations/providers/fathom.d.ts",
1043
1055
  "bun": "./dist/integrations/providers/fathom.js",
@@ -1080,6 +1092,12 @@
1080
1092
  "node": "./dist/node/integrations/providers/granola.js",
1081
1093
  "default": "./dist/integrations/providers/granola.js"
1082
1094
  },
1095
+ "./integrations/providers/image": {
1096
+ "types": "./dist/integrations/providers/image.d.ts",
1097
+ "bun": "./dist/integrations/providers/image.js",
1098
+ "node": "./dist/node/integrations/providers/image.js",
1099
+ "default": "./dist/integrations/providers/image.js"
1100
+ },
1083
1101
  "./integrations/providers/index": {
1084
1102
  "types": "./dist/integrations/providers/index.d.ts",
1085
1103
  "bun": "./dist/integrations/providers/index.js",
@@ -1122,6 +1140,18 @@
1122
1140
  "node": "./dist/node/integrations/providers/notion.js",
1123
1141
  "default": "./dist/integrations/providers/notion.js"
1124
1142
  },
1143
+ "./integrations/providers/openai-image": {
1144
+ "types": "./dist/integrations/providers/openai-image.d.ts",
1145
+ "bun": "./dist/integrations/providers/openai-image.js",
1146
+ "node": "./dist/node/integrations/providers/openai-image.js",
1147
+ "default": "./dist/integrations/providers/openai-image.js"
1148
+ },
1149
+ "./integrations/providers/openai-realtime": {
1150
+ "types": "./dist/integrations/providers/openai-realtime.d.ts",
1151
+ "bun": "./dist/integrations/providers/openai-realtime.js",
1152
+ "node": "./dist/node/integrations/providers/openai-realtime.js",
1153
+ "default": "./dist/integrations/providers/openai-realtime.js"
1154
+ },
1125
1155
  "./integrations/providers/openbanking": {
1126
1156
  "types": "./dist/integrations/providers/openbanking.d.ts",
1127
1157
  "bun": "./dist/integrations/providers/openbanking.js",
@@ -1230,6 +1260,12 @@
1230
1260
  "node": "./dist/node/integrations/providers/voice.js",
1231
1261
  "default": "./dist/integrations/providers/voice.js"
1232
1262
  },
1263
+ "./integrations/providers/voice-video-sync": {
1264
+ "types": "./dist/integrations/providers/voice-video-sync.d.ts",
1265
+ "bun": "./dist/integrations/providers/voice-video-sync.js",
1266
+ "node": "./dist/node/integrations/providers/voice-video-sync.js",
1267
+ "default": "./dist/integrations/providers/voice-video-sync.js"
1268
+ },
1233
1269
  "./integrations/runtime": {
1234
1270
  "types": "./dist/integrations/runtime.d.ts",
1235
1271
  "bun": "./dist/integrations/runtime.js",
@@ -2046,6 +2082,12 @@
2046
2082
  "node": "./dist/node/translations/catalog.js",
2047
2083
  "default": "./dist/translations/catalog.js"
2048
2084
  },
2085
+ "./translations/i18n-factory": {
2086
+ "types": "./dist/translations/i18n-factory.d.ts",
2087
+ "bun": "./dist/translations/i18n-factory.js",
2088
+ "node": "./dist/node/translations/i18n-factory.js",
2089
+ "default": "./dist/translations/i18n-factory.js"
2090
+ },
2049
2091
  "./translations/index": {
2050
2092
  "types": "./dist/translations/index.d.ts",
2051
2093
  "bun": "./dist/translations/index.js",
@@ -3203,6 +3245,12 @@
3203
3245
  "node": "./dist/node/integrations/providers/database.js",
3204
3246
  "default": "./dist/integrations/providers/database.js"
3205
3247
  },
3248
+ "./integrations/providers/deepgram": {
3249
+ "types": "./dist/integrations/providers/deepgram.d.ts",
3250
+ "bun": "./dist/integrations/providers/deepgram.js",
3251
+ "node": "./dist/node/integrations/providers/deepgram.js",
3252
+ "default": "./dist/integrations/providers/deepgram.js"
3253
+ },
3206
3254
  "./integrations/providers/elevenlabs": {
3207
3255
  "types": "./dist/integrations/providers/elevenlabs.d.ts",
3208
3256
  "bun": "./dist/integrations/providers/elevenlabs.js",
@@ -3227,6 +3275,12 @@
3227
3275
  "node": "./dist/node/integrations/providers/fal.js",
3228
3276
  "default": "./dist/integrations/providers/fal.js"
3229
3277
  },
3278
+ "./integrations/providers/fal-image": {
3279
+ "types": "./dist/integrations/providers/fal-image.d.ts",
3280
+ "bun": "./dist/integrations/providers/fal-image.js",
3281
+ "node": "./dist/node/integrations/providers/fal-image.js",
3282
+ "default": "./dist/integrations/providers/fal-image.js"
3283
+ },
3230
3284
  "./integrations/providers/fathom": {
3231
3285
  "types": "./dist/integrations/providers/fathom.d.ts",
3232
3286
  "bun": "./dist/integrations/providers/fathom.js",
@@ -3269,6 +3323,12 @@
3269
3323
  "node": "./dist/node/integrations/providers/granola.js",
3270
3324
  "default": "./dist/integrations/providers/granola.js"
3271
3325
  },
3326
+ "./integrations/providers/image": {
3327
+ "types": "./dist/integrations/providers/image.d.ts",
3328
+ "bun": "./dist/integrations/providers/image.js",
3329
+ "node": "./dist/node/integrations/providers/image.js",
3330
+ "default": "./dist/integrations/providers/image.js"
3331
+ },
3272
3332
  "./integrations/providers/index": {
3273
3333
  "types": "./dist/integrations/providers/index.d.ts",
3274
3334
  "bun": "./dist/integrations/providers/index.js",
@@ -3311,6 +3371,18 @@
3311
3371
  "node": "./dist/node/integrations/providers/notion.js",
3312
3372
  "default": "./dist/integrations/providers/notion.js"
3313
3373
  },
3374
+ "./integrations/providers/openai-image": {
3375
+ "types": "./dist/integrations/providers/openai-image.d.ts",
3376
+ "bun": "./dist/integrations/providers/openai-image.js",
3377
+ "node": "./dist/node/integrations/providers/openai-image.js",
3378
+ "default": "./dist/integrations/providers/openai-image.js"
3379
+ },
3380
+ "./integrations/providers/openai-realtime": {
3381
+ "types": "./dist/integrations/providers/openai-realtime.d.ts",
3382
+ "bun": "./dist/integrations/providers/openai-realtime.js",
3383
+ "node": "./dist/node/integrations/providers/openai-realtime.js",
3384
+ "default": "./dist/integrations/providers/openai-realtime.js"
3385
+ },
3314
3386
  "./integrations/providers/openbanking": {
3315
3387
  "types": "./dist/integrations/providers/openbanking.d.ts",
3316
3388
  "bun": "./dist/integrations/providers/openbanking.js",
@@ -3419,6 +3491,12 @@
3419
3491
  "node": "./dist/node/integrations/providers/voice.js",
3420
3492
  "default": "./dist/integrations/providers/voice.js"
3421
3493
  },
3494
+ "./integrations/providers/voice-video-sync": {
3495
+ "types": "./dist/integrations/providers/voice-video-sync.d.ts",
3496
+ "bun": "./dist/integrations/providers/voice-video-sync.js",
3497
+ "node": "./dist/node/integrations/providers/voice-video-sync.js",
3498
+ "default": "./dist/integrations/providers/voice-video-sync.js"
3499
+ },
3422
3500
  "./integrations/runtime": {
3423
3501
  "types": "./dist/integrations/runtime.d.ts",
3424
3502
  "bun": "./dist/integrations/runtime.js",
@@ -4235,6 +4313,12 @@
4235
4313
  "node": "./dist/node/translations/catalog.js",
4236
4314
  "default": "./dist/translations/catalog.js"
4237
4315
  },
4316
+ "./translations/i18n-factory": {
4317
+ "types": "./dist/translations/i18n-factory.d.ts",
4318
+ "bun": "./dist/translations/i18n-factory.js",
4319
+ "node": "./dist/node/translations/i18n-factory.js",
4320
+ "default": "./dist/translations/i18n-factory.js"
4321
+ },
4238
4322
  "./translations/index": {
4239
4323
  "types": "./dist/translations/index.d.ts",
4240
4324
  "bun": "./dist/translations/index.js",