@c15t/backend 2.0.0-rc.2 → 2.0.0-rc.4

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 (46) hide show
  1. package/.turbo/turbo-build.log +13 -13
  2. package/CHANGELOG.md +14 -0
  3. package/dist/cache.cjs +4 -4
  4. package/dist/cache.js +4 -4
  5. package/dist/core.cjs +30 -27
  6. package/dist/core.d.ts.map +1 -1
  7. package/dist/core.js +28 -25
  8. package/dist/define-config.d.ts +17 -4
  9. package/dist/define-config.d.ts.map +1 -1
  10. package/dist/handlers/init/translations.d.ts +1 -3
  11. package/dist/handlers/init/translations.d.ts.map +1 -1
  12. package/dist/init.d.ts +4 -6
  13. package/dist/init.d.ts.map +1 -1
  14. package/dist/middleware/openapi/config.d.ts.map +1 -1
  15. package/dist/router.cjs +21 -20
  16. package/dist/router.js +19 -18
  17. package/dist/types/index.d.ts +241 -165
  18. package/dist/types/index.d.ts.map +1 -1
  19. package/dist/utils/create-telemetry-options.d.ts +1 -1
  20. package/dist/utils/create-telemetry-options.d.ts.map +1 -1
  21. package/dist/utils/instrumentation.d.ts.map +1 -1
  22. package/dist/version.d.ts +1 -1
  23. package/package.json +7 -7
  24. package/rslib.config.ts +1 -1
  25. package/src/core.ts +2 -1
  26. package/src/define-config.ts +17 -3
  27. package/src/handlers/init/geo.ts +2 -2
  28. package/src/handlers/init/index.test.ts +3 -3
  29. package/src/handlers/init/translations.test.ts +1 -1
  30. package/src/handlers/init/translations.ts +3 -6
  31. package/src/init.test.ts +3 -7
  32. package/src/init.ts +9 -8
  33. package/src/middleware/openapi/config.ts +2 -2
  34. package/src/middleware/process-ip/index.test.ts +2 -4
  35. package/src/middleware/process-ip/index.ts +1 -1
  36. package/src/routes/init.ts +10 -10
  37. package/src/types/index.ts +268 -174
  38. package/src/utils/create-telemetry-options.test.ts +14 -30
  39. package/src/utils/create-telemetry-options.ts +5 -5
  40. package/src/utils/instrumentation.test.ts +3 -5
  41. package/src/utils/instrumentation.ts +1 -3
  42. package/src/utils/metrics.test.ts +11 -23
  43. package/src/utils/telemetry-pii.test.ts +3 -5
  44. package/src/version.ts +1 -1
  45. /package/dist/{types.cjs → types/index.cjs} +0 -0
  46. /package/dist/{types.js → types/index.js} +0 -0
@@ -5,12 +5,12 @@ $ genversion --esm --semi src/version.ts
5
5
  Rslib v0.18.3
6
6
 
7
7
  info build started...
8
- ready built in 0.34 s (esm)
9
- ready built in 0.35 s (cjs)
10
- start generating declaration files... (cjs)
8
+ ready built in 0.51 s (esm)
9
+ ready built in 0.55 s (cjs)
11
10
  start generating declaration files... (esm)
12
- ready declaration files generated in 6.29 s (esm)
13
- ready declaration files generated in 6.33 s (cjs)
11
+ start generating declaration files... (cjs)
12
+ ready declaration files generated in 13.4 s (esm)
13
+ ready declaration files generated in 14.2 s (cjs)
14
14
 
15
15
  File (esm) Size 
16
16
  dist/db/adapters.js 0.00 kB
@@ -20,14 +20,14 @@ ready declaration files generated in 6.33 s (cjs)
20
20
  dist/db/adapters/kysely.js 0.08 kB
21
21
  dist/db/adapters/drizzle.js 0.09 kB
22
22
  dist/db/adapters/typeorm.js 0.09 kB
23
- dist/types.js 0.11 kB
23
+ dist/types/index.js 0.11 kB
24
24
  dist/db/migrator.js 0.96 kB
25
25
  dist/db/schema.js 11.0 kB
26
26
  dist/cache.js 17.4 kB
27
- dist/router.js 54.8 kB
28
- dist/core.js 98.6 kB
27
+ dist/router.js 54.7 kB
28
+ dist/core.js 98.5 kB
29
29
 
30
- Total: 183.3 kB
30
+ Total: 183.1 kB
31
31
 
32
32
 
33
33
  File (cjs) Size 
@@ -36,14 +36,14 @@ ready declaration files generated in 6.33 s (cjs)
36
36
  dist/db/adapters/mongo.cjs 1.3 kB
37
37
  dist/db/adapters/kysely.cjs 1.3 kB
38
38
  dist/db/adapters/prisma.cjs 1.3 kB
39
- dist/types.cjs 1.3 kB
39
+ dist/types/index.cjs 1.3 kB
40
40
  dist/db/adapters/drizzle.cjs 1.3 kB
41
41
  dist/db/adapters/typeorm.cjs 1.3 kB
42
42
  dist/db/migrator.cjs 2.1 kB
43
43
  dist/db/schema.cjs 19.0 kB
44
44
  dist/cache.cjs 20.0 kB
45
- dist/router.cjs 58.9 kB
46
- dist/core.cjs 119.1 kB
45
+ dist/router.cjs 58.8 kB
46
+ dist/core.cjs 119.0 kB
47
47
 
48
- Total: 228.8 kB
48
+ Total: 228.5 kB
49
49
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @c15t/backend
2
2
 
3
+ ## 2.0.0-rc.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 4c8435c: refactor(backend): flatten backend API entrypoints and improve TypeScript DX
8
+ - Updated dependencies [06ee724]
9
+ - @c15t/translations@2.0.0-rc.4
10
+
11
+ ## 2.0.0-rc.3
12
+
13
+ ### Patch Changes
14
+
15
+ - 0a18fb6: feat(backend): add base '/' root endpoint for better DX
16
+
3
17
  ## 2.0.0-rc.2
4
18
 
5
19
  ### Patch Changes
package/dist/cache.cjs CHANGED
@@ -139,18 +139,18 @@ function extractErrorMessage(error) {
139
139
  let cachedConfig = null;
140
140
  let cachedDefaultAttributes = {};
141
141
  function create_telemetry_options_isTelemetryEnabled(options) {
142
- if (options) return options.advanced?.telemetry?.enabled === true;
142
+ if (options) return options.telemetry?.enabled === true;
143
143
  return cachedConfig?.enabled === true;
144
144
  }
145
145
  const create_telemetry_options_getTracer = (options)=>{
146
146
  if (!create_telemetry_options_isTelemetryEnabled(options)) return api_namespaceObject.trace.getTracer('c15t-noop');
147
- const tracer = options?.advanced?.telemetry?.tracer ?? cachedConfig?.tracer;
147
+ const tracer = options?.telemetry?.tracer ?? cachedConfig?.tracer;
148
148
  if (tracer) return tracer;
149
149
  return api_namespaceObject.trace.getTracer(options?.appName ?? 'c15t');
150
150
  };
151
151
  const getMeter = (options)=>{
152
152
  if (!create_telemetry_options_isTelemetryEnabled(options)) return api_namespaceObject.metrics.getMeter('c15t-noop');
153
- const meter = options?.advanced?.telemetry?.meter ?? cachedConfig?.meter;
153
+ const meter = options?.telemetry?.meter ?? cachedConfig?.meter;
154
154
  if (meter) return meter;
155
155
  return api_namespaceObject.metrics.getMeter(options?.appName ?? 'c15t');
156
156
  };
@@ -180,7 +180,7 @@ async function executeWithSpan(span, operation) {
180
180
  }
181
181
  }
182
182
  function resolveDefaultAttributes(options) {
183
- return options?.advanced?.telemetry?.defaultAttributes || getDefaultAttributes();
183
+ return options?.telemetry?.defaultAttributes || getDefaultAttributes();
184
184
  }
185
185
  async function withExternalSpan(attributes, operation, options) {
186
186
  if (!create_telemetry_options_isTelemetryEnabled(options)) return operation();
package/dist/cache.js CHANGED
@@ -101,18 +101,18 @@ function extractErrorMessage(error) {
101
101
  let cachedConfig = null;
102
102
  let cachedDefaultAttributes = {};
103
103
  function create_telemetry_options_isTelemetryEnabled(options) {
104
- if (options) return options.advanced?.telemetry?.enabled === true;
104
+ if (options) return options.telemetry?.enabled === true;
105
105
  return cachedConfig?.enabled === true;
106
106
  }
107
107
  const create_telemetry_options_getTracer = (options)=>{
108
108
  if (!create_telemetry_options_isTelemetryEnabled(options)) return api_trace.getTracer('c15t-noop');
109
- const tracer = options?.advanced?.telemetry?.tracer ?? cachedConfig?.tracer;
109
+ const tracer = options?.telemetry?.tracer ?? cachedConfig?.tracer;
110
110
  if (tracer) return tracer;
111
111
  return api_trace.getTracer(options?.appName ?? 'c15t');
112
112
  };
113
113
  const getMeter = (options)=>{
114
114
  if (!create_telemetry_options_isTelemetryEnabled(options)) return metrics.getMeter('c15t-noop');
115
- const meter = options?.advanced?.telemetry?.meter ?? cachedConfig?.meter;
115
+ const meter = options?.telemetry?.meter ?? cachedConfig?.meter;
116
116
  if (meter) return meter;
117
117
  return metrics.getMeter(options?.appName ?? 'c15t');
118
118
  };
@@ -142,7 +142,7 @@ async function executeWithSpan(span, operation) {
142
142
  }
143
143
  }
144
144
  function resolveDefaultAttributes(options) {
145
- return options?.advanced?.telemetry?.defaultAttributes || getDefaultAttributes();
145
+ return options?.telemetry?.defaultAttributes || getDefaultAttributes();
146
146
  }
147
147
  async function withExternalSpan(attributes, operation, options) {
148
148
  if (!create_telemetry_options_isTelemetryEnabled(options)) return operation();
package/dist/core.cjs CHANGED
@@ -454,10 +454,10 @@ var __webpack_exports__ = {};
454
454
  };
455
455
  }
456
456
  const createOpenAPIConfig = (options)=>({
457
- enabled: options.advanced?.openapi?.enabled !== false,
457
+ enabled: options.openapi?.enabled !== false,
458
458
  specPath: '/spec.json',
459
459
  docsPath: '/docs',
460
- ...options.advanced?.openapi || {}
460
+ ...options.openapi || {}
461
461
  });
462
462
  const DEFAULT_IP_HEADERS = [
463
463
  'x-client-ip',
@@ -552,7 +552,7 @@ var __webpack_exports__ = {};
552
552
  return ip;
553
553
  }
554
554
  function getIpAddress(req, options) {
555
- const ipAddressConfig = options.advanced?.ipAddress;
555
+ const ipAddressConfig = options.ipAddress;
556
556
  if (ipAddressConfig?.tracking === false) return null;
557
557
  const ipHeaders = ipAddressConfig?.ipAddressHeaders || DEFAULT_IP_HEADERS;
558
558
  const headers = req instanceof Request ? req.headers : req;
@@ -568,7 +568,7 @@ var __webpack_exports__ = {};
568
568
  }
569
569
  return null;
570
570
  }
571
- const version_version = '2.0.0-rc.2';
571
+ const version_version = '2.0.0-rc.4';
572
572
  function extractErrorMessage(error) {
573
573
  if (error instanceof AggregateError && error.errors?.length > 0) {
574
574
  const inner = error.errors.map((e)=>e instanceof Error ? e.message : String(e)).join('; ');
@@ -597,18 +597,18 @@ var __webpack_exports__ = {};
597
597
  return config;
598
598
  }
599
599
  function isTelemetryEnabled(options) {
600
- if (options) return options.advanced?.telemetry?.enabled === true;
600
+ if (options) return options.telemetry?.enabled === true;
601
601
  return cachedConfig?.enabled === true;
602
602
  }
603
603
  const getTracer = (options)=>{
604
604
  if (!isTelemetryEnabled(options)) return api_namespaceObject.trace.getTracer('c15t-noop');
605
- const tracer = options?.advanced?.telemetry?.tracer ?? cachedConfig?.tracer;
605
+ const tracer = options?.telemetry?.tracer ?? cachedConfig?.tracer;
606
606
  if (tracer) return tracer;
607
607
  return api_namespaceObject.trace.getTracer(options?.appName ?? 'c15t');
608
608
  };
609
609
  const getMeter = (options)=>{
610
610
  if (!isTelemetryEnabled(options)) return api_namespaceObject.metrics.getMeter('c15t-noop');
611
- const meter = options?.advanced?.telemetry?.meter ?? cachedConfig?.meter;
611
+ const meter = options?.telemetry?.meter ?? cachedConfig?.meter;
612
612
  if (meter) return meter;
613
613
  return api_namespaceObject.metrics.getMeter(options?.appName ?? 'c15t');
614
614
  };
@@ -618,7 +618,7 @@ var __webpack_exports__ = {};
618
618
  const createRequestSpan = (method, path, options)=>{
619
619
  if (!isTelemetryEnabled(options)) return null;
620
620
  const tracer = getTracer(options);
621
- const defaultAttrs = options?.advanced?.telemetry?.defaultAttributes || getDefaultAttributes();
621
+ const defaultAttrs = options?.telemetry?.defaultAttributes || getDefaultAttributes();
622
622
  const span = tracer.startSpan(`${method} ${path}`, {
623
623
  attributes: {
624
624
  'http.method': method,
@@ -660,7 +660,7 @@ var __webpack_exports__ = {};
660
660
  }
661
661
  }
662
662
  function resolveDefaultAttributes(options) {
663
- return options?.advanced?.telemetry?.defaultAttributes || getDefaultAttributes();
663
+ return options?.telemetry?.defaultAttributes || getDefaultAttributes();
664
664
  }
665
665
  async function withDatabaseSpan(attributes, operation, options) {
666
666
  if (!isTelemetryEnabled(options)) return operation();
@@ -1321,7 +1321,7 @@ var __webpack_exports__ = {};
1321
1321
  ...options.logger,
1322
1322
  appName: String(appName)
1323
1323
  });
1324
- const telemetryOptions = createTelemetryOptions(String(appName), options.advanced?.telemetry, options.tenantId);
1324
+ const telemetryOptions = createTelemetryOptions(String(appName), options.telemetry, options.tenantId);
1325
1325
  if (isTelemetryEnabled(options)) logger.debug('Telemetry is enabled', {
1326
1326
  hasTracer: !!telemetryOptions?.tracer,
1327
1327
  hasMeter: !!telemetryOptions?.meter,
@@ -1332,8 +1332,9 @@ var __webpack_exports__ = {};
1332
1332
  const client = db.client(options.adapter);
1333
1333
  const rawOrm = client.orm('2.0.0');
1334
1334
  const orm = options.tenantId ? withTenantScope(rawOrm, options.tenantId) : rawOrm;
1335
+ const { ipAddress: _ipAddressConfig, ...baseOptions } = options;
1335
1336
  const context = {
1336
- ...options,
1337
+ ...baseOptions,
1337
1338
  appName,
1338
1339
  logger,
1339
1340
  db: orm,
@@ -1833,7 +1834,7 @@ var __webpack_exports__ = {};
1833
1834
  return jurisdiction;
1834
1835
  }
1835
1836
  async function getLocation(request, options) {
1836
- if (options.advanced?.disableGeoLocation) return {
1837
+ if (options.disableGeoLocation) return {
1837
1838
  countryCode: null,
1838
1839
  regionCode: null
1839
1840
  };
@@ -1844,15 +1845,16 @@ var __webpack_exports__ = {};
1844
1845
  };
1845
1846
  }
1846
1847
  function getJurisdiction(location, options) {
1847
- if (options.advanced?.disableGeoLocation) return 'GDPR';
1848
+ if (options.disableGeoLocation) return 'GDPR';
1848
1849
  return checkJurisdiction(location.countryCode, location.regionCode);
1849
1850
  }
1850
1851
  const translations_namespaceObject = require("@c15t/translations");
1852
+ const all_namespaceObject = require("@c15t/translations/all");
1851
1853
  function isSupportedBaseLanguage(lang) {
1852
- return lang in translations_namespaceObject.baseTranslations;
1854
+ return lang in all_namespaceObject.baseTranslations;
1853
1855
  }
1854
1856
  function translations_getTranslationsData(acceptLanguage, customTranslations) {
1855
- const supportedDefaultLanguages = Object.keys(translations_namespaceObject.baseTranslations);
1857
+ const supportedDefaultLanguages = Object.keys(all_namespaceObject.baseTranslations);
1856
1858
  const supportedCustomLanguages = Object.keys(customTranslations || {});
1857
1859
  const supportedLanguages = [
1858
1860
  ...supportedDefaultLanguages,
@@ -1862,7 +1864,7 @@ var __webpack_exports__ = {};
1862
1864
  header: acceptLanguage,
1863
1865
  fallback: 'en'
1864
1866
  });
1865
- const base = isSupportedBaseLanguage(preferredLanguage) ? translations_namespaceObject.baseTranslations[preferredLanguage] : translations_namespaceObject.baseTranslations.en;
1867
+ const base = isSupportedBaseLanguage(preferredLanguage) ? all_namespaceObject.baseTranslations[preferredLanguage] : all_namespaceObject.baseTranslations.en;
1866
1868
  const custom = supportedCustomLanguages.includes(preferredLanguage) ? customTranslations?.[preferredLanguage] : {};
1867
1869
  const translations = custom ? (0, translations_namespaceObject.deepMergeTranslations)(base, custom) : base;
1868
1870
  return {
@@ -1901,20 +1903,20 @@ Use for geo-targeted consent banners and regional compliance.`,
1901
1903
  const acceptLanguage = request.headers.get('accept-language') || 'en';
1902
1904
  const location = await getLocation(request, options);
1903
1905
  const jurisdiction = getJurisdiction(location, options);
1904
- const translationsResult = translations_getTranslationsData(acceptLanguage, options.advanced?.customTranslations);
1906
+ const translationsResult = translations_getTranslationsData(acceptLanguage, options.customTranslations);
1905
1907
  let gvl = null;
1906
- if (options.advanced?.iab?.enabled) {
1908
+ if (options.iab?.enabled) {
1907
1909
  const language = translationsResult.language.split('-')[0] || 'en';
1908
1910
  const gvlResolver = createGVLResolver({
1909
1911
  appName: options.appName || 'c15t',
1910
- bundled: options.advanced.iab.bundled,
1911
- cacheAdapter: options.advanced.cache?.adapter,
1912
- vendorIds: options.advanced.iab.vendorIds,
1913
- endpoint: options.advanced.iab.endpoint
1912
+ bundled: options.iab.bundled,
1913
+ cacheAdapter: options.cache?.adapter,
1914
+ vendorIds: options.iab.vendorIds,
1915
+ endpoint: options.iab.endpoint
1914
1916
  });
1915
1917
  gvl = await gvlResolver.get(language);
1916
1918
  }
1917
- const customVendors = options.advanced?.iab?.customVendors;
1919
+ const customVendors = options.iab?.customVendors;
1918
1920
  const gpc = '1' === request.headers.get('sec-gpc');
1919
1921
  getMetrics()?.recordInit({
1920
1922
  jurisdiction,
@@ -1926,11 +1928,11 @@ Use for geo-targeted consent banners and regional compliance.`,
1926
1928
  jurisdiction,
1927
1929
  location,
1928
1930
  translations: translationsResult,
1929
- branding: options.advanced?.branding || 'c15t',
1931
+ branding: options.branding || 'c15t',
1930
1932
  gvl,
1931
1933
  customVendors,
1932
- ...options.advanced?.iab?.cmpId != null && {
1933
- cmpId: options.advanced.iab.cmpId
1934
+ ...options.iab?.cmpId != null && {
1935
+ cmpId: options.iab.cmpId
1934
1936
  }
1935
1937
  });
1936
1938
  });
@@ -2602,7 +2604,7 @@ Use for health checks, load balancer probes, and debugging. Performs a lightweig
2602
2604
  app.use('*', async (c, next)=>{
2603
2605
  const request = c.req.raw;
2604
2606
  const startTime = Date.now();
2605
- const apiKeyAuthenticated = validateRequestAuth(request.headers, options.advanced?.apiKeys);
2607
+ const apiKeyAuthenticated = validateRequestAuth(request.headers, options.apiKeys);
2606
2608
  const enrichedContext = {
2607
2609
  ...context,
2608
2610
  ipAddress: getIpAddress(request, options),
@@ -2681,6 +2683,7 @@ Use for health checks, load balancer probes, and debugging. Performs a lightweig
2681
2683
  app.route('/subjects', createSubjectRoutes());
2682
2684
  app.route('/consents', createConsentRoutes());
2683
2685
  app.route('/status', createStatusRoute());
2686
+ app.route('/', createStatusRoute());
2684
2687
  app.onError((err, c)=>{
2685
2688
  const ctx = c.get('c15tContext');
2686
2689
  const log = ctx?.logger || logger;
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAgBxD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjD;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;IAEtB;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;IAEb;;;;OAIG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,SAAS,EAAE,MAAM,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,WAAW,KAAG,YAoQnD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAgBxD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjD;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;IAEtB;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;IAEb;;;;OAIG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,SAAS,EAAE,MAAM,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,WAAW,KAAG,YAqQnD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/dist/core.js CHANGED
@@ -9,7 +9,8 @@ import base_x from "base-x";
9
9
  import { fumadb } from "fumadb";
10
10
  import { column, idColumn, schema, table as schema_table } from "fumadb/schema";
11
11
  import { checkConsentOutputSchema, checkConsentQuerySchema, getSubjectInputSchema, getSubjectOutputSchema, initOutputSchema, listSubjectsOutputSchema, listSubjectsQuerySchema, patchSubjectOutputSchema, postSubjectInputSchema, postSubjectOutputSchema, statusOutputSchema, subjectIdSchema } from "@c15t/schema";
12
- import { baseTranslations, deepMergeTranslations, selectLanguage } from "@c15t/translations";
12
+ import { deepMergeTranslations, selectLanguage } from "@c15t/translations";
13
+ import { baseTranslations } from "@c15t/translations/all";
13
14
  import { object, optional, string } from "valibot";
14
15
  function extractBearerToken(authHeader) {
15
16
  if (!authHeader) return null;
@@ -136,12 +137,12 @@ function createCORSOptions(trustedOrigins) {
136
137
  ]
137
138
  };
138
139
  }
139
- const version_version = '2.0.0-rc.2';
140
+ const version_version = '2.0.0-rc.4';
140
141
  const config_createOpenAPIConfig = (options)=>({
141
- enabled: options.advanced?.openapi?.enabled !== false,
142
+ enabled: options.openapi?.enabled !== false,
142
143
  specPath: '/spec.json',
143
144
  docsPath: '/docs',
144
- ...options.advanced?.openapi || {}
145
+ ...options.openapi || {}
145
146
  });
146
147
  const DEFAULT_IP_HEADERS = [
147
148
  'x-client-ip',
@@ -236,7 +237,7 @@ function maskIpAddress(ip) {
236
237
  return ip;
237
238
  }
238
239
  function getIpAddress(req, options) {
239
- const ipAddressConfig = options.advanced?.ipAddress;
240
+ const ipAddressConfig = options.ipAddress;
240
241
  if (ipAddressConfig?.tracking === false) return null;
241
242
  const ipHeaders = ipAddressConfig?.ipAddressHeaders || DEFAULT_IP_HEADERS;
242
243
  const headers = req instanceof Request ? req.headers : req;
@@ -280,18 +281,18 @@ function createTelemetryOptions(appName = 'c15t', telemetryConfig, tenantId) {
280
281
  return config;
281
282
  }
282
283
  function isTelemetryEnabled(options) {
283
- if (options) return options.advanced?.telemetry?.enabled === true;
284
+ if (options) return options.telemetry?.enabled === true;
284
285
  return cachedConfig?.enabled === true;
285
286
  }
286
287
  const getTracer = (options)=>{
287
288
  if (!isTelemetryEnabled(options)) return trace.getTracer('c15t-noop');
288
- const tracer = options?.advanced?.telemetry?.tracer ?? cachedConfig?.tracer;
289
+ const tracer = options?.telemetry?.tracer ?? cachedConfig?.tracer;
289
290
  if (tracer) return tracer;
290
291
  return trace.getTracer(options?.appName ?? 'c15t');
291
292
  };
292
293
  const getMeter = (options)=>{
293
294
  if (!isTelemetryEnabled(options)) return api_metrics.getMeter('c15t-noop');
294
- const meter = options?.advanced?.telemetry?.meter ?? cachedConfig?.meter;
295
+ const meter = options?.telemetry?.meter ?? cachedConfig?.meter;
295
296
  if (meter) return meter;
296
297
  return api_metrics.getMeter(options?.appName ?? 'c15t');
297
298
  };
@@ -301,7 +302,7 @@ function getDefaultAttributes() {
301
302
  const createRequestSpan = (method, path, options)=>{
302
303
  if (!isTelemetryEnabled(options)) return null;
303
304
  const tracer = getTracer(options);
304
- const defaultAttrs = options?.advanced?.telemetry?.defaultAttributes || getDefaultAttributes();
305
+ const defaultAttrs = options?.telemetry?.defaultAttributes || getDefaultAttributes();
305
306
  const span = tracer.startSpan(`${method} ${path}`, {
306
307
  attributes: {
307
308
  'http.method': method,
@@ -343,7 +344,7 @@ async function executeWithSpan(span, operation) {
343
344
  }
344
345
  }
345
346
  function resolveDefaultAttributes(options) {
346
- return options?.advanced?.telemetry?.defaultAttributes || getDefaultAttributes();
347
+ return options?.telemetry?.defaultAttributes || getDefaultAttributes();
347
348
  }
348
349
  async function withDatabaseSpan(attributes, operation, options) {
349
350
  if (!isTelemetryEnabled(options)) return operation();
@@ -1256,7 +1257,7 @@ const init = (options)=>{
1256
1257
  ...options.logger,
1257
1258
  appName: String(appName)
1258
1259
  });
1259
- const telemetryOptions = createTelemetryOptions(String(appName), options.advanced?.telemetry, options.tenantId);
1260
+ const telemetryOptions = createTelemetryOptions(String(appName), options.telemetry, options.tenantId);
1260
1261
  if (isTelemetryEnabled(options)) logger.debug('Telemetry is enabled', {
1261
1262
  hasTracer: !!telemetryOptions?.tracer,
1262
1263
  hasMeter: !!telemetryOptions?.meter,
@@ -1267,8 +1268,9 @@ const init = (options)=>{
1267
1268
  const client = db.client(options.adapter);
1268
1269
  const rawOrm = client.orm('2.0.0');
1269
1270
  const orm = options.tenantId ? withTenantScope(rawOrm, options.tenantId) : rawOrm;
1271
+ const { ipAddress: _ipAddressConfig, ...baseOptions } = options;
1270
1272
  const context = {
1271
- ...options,
1273
+ ...baseOptions,
1272
1274
  appName,
1273
1275
  logger,
1274
1276
  db: orm,
@@ -1767,7 +1769,7 @@ function checkJurisdiction(countryCode, regionCode) {
1767
1769
  return jurisdiction;
1768
1770
  }
1769
1771
  async function getLocation(request, options) {
1770
- if (options.advanced?.disableGeoLocation) return {
1772
+ if (options.disableGeoLocation) return {
1771
1773
  countryCode: null,
1772
1774
  regionCode: null
1773
1775
  };
@@ -1778,7 +1780,7 @@ async function getLocation(request, options) {
1778
1780
  };
1779
1781
  }
1780
1782
  function getJurisdiction(location, options) {
1781
- if (options.advanced?.disableGeoLocation) return 'GDPR';
1783
+ if (options.disableGeoLocation) return 'GDPR';
1782
1784
  return checkJurisdiction(location.countryCode, location.regionCode);
1783
1785
  }
1784
1786
  function isSupportedBaseLanguage(lang) {
@@ -1834,20 +1836,20 @@ Use for geo-targeted consent banners and regional compliance.`,
1834
1836
  const acceptLanguage = request.headers.get('accept-language') || 'en';
1835
1837
  const location = await getLocation(request, options);
1836
1838
  const jurisdiction = getJurisdiction(location, options);
1837
- const translationsResult = translations_getTranslationsData(acceptLanguage, options.advanced?.customTranslations);
1839
+ const translationsResult = translations_getTranslationsData(acceptLanguage, options.customTranslations);
1838
1840
  let gvl = null;
1839
- if (options.advanced?.iab?.enabled) {
1841
+ if (options.iab?.enabled) {
1840
1842
  const language = translationsResult.language.split('-')[0] || 'en';
1841
1843
  const gvlResolver = createGVLResolver({
1842
1844
  appName: options.appName || 'c15t',
1843
- bundled: options.advanced.iab.bundled,
1844
- cacheAdapter: options.advanced.cache?.adapter,
1845
- vendorIds: options.advanced.iab.vendorIds,
1846
- endpoint: options.advanced.iab.endpoint
1845
+ bundled: options.iab.bundled,
1846
+ cacheAdapter: options.cache?.adapter,
1847
+ vendorIds: options.iab.vendorIds,
1848
+ endpoint: options.iab.endpoint
1847
1849
  });
1848
1850
  gvl = await gvlResolver.get(language);
1849
1851
  }
1850
- const customVendors = options.advanced?.iab?.customVendors;
1852
+ const customVendors = options.iab?.customVendors;
1851
1853
  const gpc = '1' === request.headers.get('sec-gpc');
1852
1854
  getMetrics()?.recordInit({
1853
1855
  jurisdiction,
@@ -1859,11 +1861,11 @@ Use for geo-targeted consent banners and regional compliance.`,
1859
1861
  jurisdiction,
1860
1862
  location,
1861
1863
  translations: translationsResult,
1862
- branding: options.advanced?.branding || 'c15t',
1864
+ branding: options.branding || 'c15t',
1863
1865
  gvl,
1864
1866
  customVendors,
1865
- ...options.advanced?.iab?.cmpId != null && {
1866
- cmpId: options.advanced.iab.cmpId
1867
+ ...options.iab?.cmpId != null && {
1868
+ cmpId: options.iab.cmpId
1867
1869
  }
1868
1870
  });
1869
1871
  });
@@ -2534,7 +2536,7 @@ const c15tInstance = (options)=>{
2534
2536
  app.use('*', async (c, next)=>{
2535
2537
  const request = c.req.raw;
2536
2538
  const startTime = Date.now();
2537
- const apiKeyAuthenticated = validateRequestAuth(request.headers, options.advanced?.apiKeys);
2539
+ const apiKeyAuthenticated = validateRequestAuth(request.headers, options.apiKeys);
2538
2540
  const enrichedContext = {
2539
2541
  ...context,
2540
2542
  ipAddress: getIpAddress(request, options),
@@ -2613,6 +2615,7 @@ const c15tInstance = (options)=>{
2613
2615
  app.route('/subjects', createSubjectRoutes());
2614
2616
  app.route('/consents', createConsentRoutes());
2615
2617
  app.route('/status', createStatusRoute());
2618
+ app.route('/', createStatusRoute());
2616
2619
  app.onError((err, c)=>{
2617
2620
  const ctx = c.get('c15tContext');
2618
2621
  const log = ctx?.logger || logger;
@@ -1,5 +1,18 @@
1
- import type { DatabaseOptions } from './types';
2
- export interface DatabaseConfig extends DatabaseOptions {
3
- }
4
- export declare const defineConfig: (config: DatabaseConfig) => DatabaseConfig;
1
+ import type { C15TOptions } from './types';
2
+ /**
3
+ * c15t backend config accepted by `defineConfig`.
4
+ *
5
+ * Keep this as an intersection with `C15TOptions` (instead of `Omit`) so
6
+ * TypeScript preserves property-level JSDoc in editor completions.
7
+ */
8
+ export type C15TConfig = C15TOptions & {
9
+ /**
10
+ * Logger config is managed internally and is not supported via config files.
11
+ */
12
+ logger?: never;
13
+ };
14
+ /**
15
+ * Helper for typed backend configuration in `c15t-backend.config.ts`.
16
+ */
17
+ export declare const defineConfig: (config: C15TConfig) => C15TConfig;
5
18
  //# sourceMappingURL=define-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAe,SAAQ,eAAe;CAAG;AAE1D,eAAO,MAAM,YAAY,GAAI,QAAQ,cAAc,mBAAW,CAAC"}
1
+ {"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,UAAU,eAAW,CAAC"}
@@ -18,9 +18,7 @@ export declare function getTranslationsData(acceptLanguage: string | null, custo
18
18
  * @returns An object containing the final translations and the determined language.
19
19
  */
20
20
  export declare function getTranslations(acceptLanguage: string, options: {
21
- advanced?: {
22
- customTranslations?: Record<string, Partial<Translations>>;
23
- };
21
+ customTranslations?: Record<string, Partial<Translations>>;
24
22
  }): Promise<{
25
23
  translations: CompleteTranslations;
26
24
  language: string;
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/handlers/init/translations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAC;AAQ5B;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;kBA0B3B,oBAAoB;;EAGnD;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE;IACR,QAAQ,CAAC,EAAE;QAAE,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;KAAE,CAAC;CAC1E;kBAhB8B,oBAAoB;;GAsBnD"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/handlers/init/translations.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAC;AAS5B;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;kBA0B3B,oBAAoB;;EAGnD;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE;IACR,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;CAC3D;kBAhB8B,oBAAoB;;GAmBnD"}
package/dist/init.d.ts CHANGED
@@ -16,12 +16,10 @@ import type { C15TContext, C15TOptions } from './types';
16
16
  *
17
17
  * // Then pass telemetry config
18
18
  * const instance = c15tInstance({
19
- * advanced: {
20
- * telemetry: {
21
- * enabled: true,
22
- * tracer: trace.getTracer('my-app'),
23
- * meter: metrics.getMeter('my-app'),
24
- * },
19
+ * telemetry: {
20
+ * enabled: true,
21
+ * tracer: trace.getTracer('my-app'),
22
+ * meter: metrics.getMeter('my-app'),
25
23
  * },
26
24
  * });
27
25
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAUxD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,IAAI,GAAI,SAAS,WAAW,KAAG,WAiD3C,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAUxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,IAAI,GAAI,SAAS,WAAW,KAAG,WAoD3C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/middleware/openapi/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW;;;;;YAqB+1C,CAAC;iBAAa,CAAC;mBAAqB,CAAC;uBAAyB,CAAC;;eAA0B,CAAC;;uBAAkC,CAAC;;gBAAwB,CAAC;;;CAd5iD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,GAAI,SAAS,WAAW;;;;;;;;;;;;CAQ9D,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/middleware/openapi/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW;;;;;YAqBs7B,CAAC;iBAAY,CAAC;mBAAoB,CAAC;uBAAwB,CAAC;;eAAwB,CAAC;;uBAAkC,CAAC;;gBAAuB,CAAC;;;CAd7nC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,GAAI,SAAS,WAAW;;;;;;;;;;;;CAQ9D,CAAC"}