@c15t/backend 2.0.0-rc.0 → 2.0.0-rc.10

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 (336) hide show
  1. package/README.md +3 -3
  2. package/dist/302.js +473 -0
  3. package/dist/583.js +540 -0
  4. package/dist/915.js +1771 -0
  5. package/dist/cache.cjs +5 -5
  6. package/dist/cache.js +4 -415
  7. package/dist/core.cjs +1356 -120
  8. package/dist/core.js +163 -1981
  9. package/dist/db/adapters/drizzle.cjs +1 -1
  10. package/dist/db/adapters/drizzle.js +1 -2
  11. package/dist/db/adapters/kysely.cjs +1 -1
  12. package/dist/db/adapters/kysely.js +1 -2
  13. package/dist/db/adapters/mongo.cjs +1 -1
  14. package/dist/db/adapters/mongo.js +1 -2
  15. package/dist/db/adapters/prisma.cjs +1 -1
  16. package/dist/db/adapters/prisma.js +1 -2
  17. package/dist/db/adapters/typeorm.cjs +1 -1
  18. package/dist/db/adapters/typeorm.js +1 -2
  19. package/dist/db/adapters.cjs +1 -1
  20. package/dist/db/migrator.cjs +1 -1
  21. package/dist/db/schema.cjs +43 -3
  22. package/dist/db/schema.js +35 -4
  23. package/dist/define-config.cjs +1 -1
  24. package/dist/edge.cjs +1106 -0
  25. package/dist/edge.js +190 -0
  26. package/dist/router.cjs +885 -123
  27. package/dist/router.js +1 -1507
  28. package/dist/{types.cjs → types/index.cjs} +1 -1
  29. package/{dist → dist-types}/cache/adapters/cloudflare-kv.d.ts +0 -1
  30. package/{dist → dist-types}/cache/adapters/index.d.ts +0 -1
  31. package/{dist → dist-types}/cache/adapters/memory.d.ts +0 -1
  32. package/{dist → dist-types}/cache/adapters/upstash-redis.d.ts +0 -1
  33. package/{dist → dist-types}/cache/gvl-resolver.d.ts +0 -1
  34. package/{dist → dist-types}/cache/index.d.ts +0 -1
  35. package/{dist → dist-types}/cache/keys.d.ts +0 -1
  36. package/{dist → dist-types}/cache/types.d.ts +0 -1
  37. package/{dist → dist-types}/core.d.ts +8 -1
  38. package/{dist → dist-types}/db/migrator/index.d.ts +0 -1
  39. package/dist-types/db/registry/consent-policy.d.ts +78 -0
  40. package/{dist → dist-types}/db/registry/consent-purpose.d.ts +0 -1
  41. package/{dist → dist-types}/db/registry/domain.d.ts +0 -1
  42. package/dist-types/db/registry/index.d.ts +118 -0
  43. package/dist-types/db/registry/runtime-policy-decision.d.ts +60 -0
  44. package/{dist → dist-types}/db/registry/subject.d.ts +0 -2
  45. package/{dist → dist-types}/db/registry/types.d.ts +1 -1
  46. package/{dist → dist-types}/db/registry/utils/generate-id.d.ts +0 -1
  47. package/{dist → dist-types}/db/registry/utils.d.ts +0 -1
  48. package/{dist → dist-types}/db/schema/1.0.0/audit-log.d.ts +0 -1
  49. package/{dist → dist-types}/db/schema/1.0.0/consent-policy.d.ts +0 -1
  50. package/{dist → dist-types}/db/schema/1.0.0/consent-purpose.d.ts +0 -1
  51. package/{dist → dist-types}/db/schema/1.0.0/consent-record.d.ts +0 -1
  52. package/{dist → dist-types}/db/schema/1.0.0/consent.d.ts +1 -2
  53. package/{dist → dist-types}/db/schema/1.0.0/domain.d.ts +0 -1
  54. package/{dist → dist-types}/db/schema/1.0.0/index.d.ts +0 -32
  55. package/{dist → dist-types}/db/schema/1.0.0/subject.d.ts +0 -2
  56. package/{dist → dist-types}/db/schema/2.0.0/audit-log.d.ts +1 -2
  57. package/{dist → dist-types}/db/schema/2.0.0/consent-policy.d.ts +3 -3
  58. package/{dist → dist-types}/db/schema/2.0.0/consent-purpose.d.ts +1 -2
  59. package/{dist → dist-types}/db/schema/2.0.0/consent.d.ts +7 -2
  60. package/{dist → dist-types}/db/schema/2.0.0/domain.d.ts +1 -2
  61. package/{dist → dist-types}/db/schema/2.0.0/index.d.ts +455 -28
  62. package/dist-types/db/schema/2.0.0/runtime-policy-decision.d.ts +23 -0
  63. package/{dist → dist-types}/db/schema/2.0.0/subject.d.ts +1 -3
  64. package/{dist → dist-types}/db/schema/index.d.ts +908 -86
  65. package/{dist → dist-types}/db/tenant-scope.d.ts +0 -1
  66. package/dist-types/define-config.d.ts +17 -0
  67. package/dist-types/edge/index.d.ts +5 -0
  68. package/dist-types/edge/init-handler.d.ts +40 -0
  69. package/dist-types/edge/resolve-consent.d.ts +80 -0
  70. package/dist-types/edge/types.d.ts +13 -0
  71. package/{dist → dist-types}/handlers/consent/check.handler.d.ts +0 -1
  72. package/{src/handlers/consent/index.ts → dist-types/handlers/consent/index.d.ts} +0 -1
  73. package/{dist → dist-types}/handlers/init/geo.d.ts +2 -3
  74. package/{dist → dist-types}/handlers/init/index.d.ts +2 -3
  75. package/dist-types/handlers/init/policy.d.ts +26 -0
  76. package/dist-types/handlers/init/resolve-init.d.ts +44 -0
  77. package/dist-types/handlers/init/translations.d.ts +48 -0
  78. package/dist-types/handlers/legal-document/current.handler.d.ts +11 -0
  79. package/dist-types/handlers/legal-document/snapshot.d.ts +39 -0
  80. package/dist-types/handlers/policy/snapshot.d.ts +99 -0
  81. package/{src/handlers/status/index.ts → dist-types/handlers/status/index.d.ts} +0 -1
  82. package/{dist → dist-types}/handlers/status/status.handler.d.ts +0 -1
  83. package/{dist → dist-types}/handlers/subject/get.handler.d.ts +3 -2
  84. package/{src/handlers/subject/index.ts → dist-types/handlers/subject/index.d.ts} +0 -1
  85. package/{dist → dist-types}/handlers/subject/list.handler.d.ts +3 -2
  86. package/{dist → dist-types}/handlers/subject/patch.handler.d.ts +0 -2
  87. package/{dist → dist-types}/handlers/subject/post.handler.d.ts +12 -1
  88. package/{dist → dist-types}/handlers/utils/consent-enrichment.d.ts +3 -1
  89. package/{dist → dist-types}/init.d.ts +4 -7
  90. package/{dist → dist-types}/middleware/auth/index.d.ts +0 -1
  91. package/{dist → dist-types}/middleware/auth/validate-api-key.d.ts +0 -1
  92. package/{dist → dist-types}/middleware/cors/cors.d.ts +0 -1
  93. package/{src/middleware/cors/index.ts → dist-types/middleware/cors/index.d.ts} +0 -1
  94. package/{dist → dist-types}/middleware/cors/is-origin-trusted.d.ts +0 -1
  95. package/{dist → dist-types}/middleware/cors/process-cors.d.ts +0 -1
  96. package/{dist → dist-types}/middleware/openapi/config.d.ts +0 -1
  97. package/{dist → dist-types}/middleware/openapi/handlers.d.ts +0 -1
  98. package/{src/middleware/openapi/index.ts → dist-types/middleware/openapi/index.d.ts} +0 -1
  99. package/{dist → dist-types}/middleware/process-ip/index.d.ts +0 -1
  100. package/dist-types/policies/builder.d.ts +127 -0
  101. package/dist-types/policies/defaults.d.ts +2 -0
  102. package/dist-types/policies/matchers.d.ts +3 -0
  103. package/{dist → dist-types}/router.d.ts +0 -1
  104. package/{dist → dist-types}/routes/consent.d.ts +0 -1
  105. package/{dist → dist-types}/routes/index.d.ts +1 -1
  106. package/{dist → dist-types}/routes/init.d.ts +0 -1
  107. package/dist-types/routes/legal-document.d.ts +7 -0
  108. package/{dist → dist-types}/routes/status.d.ts +0 -1
  109. package/{dist → dist-types}/routes/subject.d.ts +0 -1
  110. package/{dist → dist-types}/types/api.d.ts +0 -1
  111. package/dist-types/types/index.d.ts +464 -0
  112. package/dist-types/utils/background.d.ts +6 -0
  113. package/{dist → dist-types}/utils/create-telemetry-options.d.ts +1 -2
  114. package/{dist → dist-types}/utils/env.d.ts +0 -1
  115. package/{dist → dist-types}/utils/extract-error-message.d.ts +0 -1
  116. package/{dist → dist-types}/utils/instrumentation.d.ts +2 -3
  117. package/{dist → dist-types}/utils/logger.d.ts +0 -1
  118. package/{dist → dist-types}/utils/metrics.d.ts +0 -1
  119. package/dist-types/version.d.ts +1 -0
  120. package/docs/README.md +49 -0
  121. package/docs/api/configuration.md +208 -0
  122. package/docs/api/endpoints.md +211 -0
  123. package/docs/guides/caching.md +85 -0
  124. package/docs/guides/database-setup.md +128 -0
  125. package/docs/guides/edge-deployment.md +251 -0
  126. package/docs/guides/framework-integration.md +142 -0
  127. package/docs/guides/iab-tcf.md +89 -0
  128. package/docs/guides/observability.md +96 -0
  129. package/docs/guides/policy-packs.md +396 -0
  130. package/docs/quickstart.md +129 -0
  131. package/package.json +53 -39
  132. package/.turbo/turbo-build.log +0 -49
  133. package/CHANGELOG.md +0 -89
  134. package/dist/cache/adapters/cloudflare-kv.d.ts.map +0 -1
  135. package/dist/cache/adapters/index.d.ts.map +0 -1
  136. package/dist/cache/adapters/memory.d.ts.map +0 -1
  137. package/dist/cache/adapters/upstash-redis.d.ts.map +0 -1
  138. package/dist/cache/gvl-resolver.d.ts.map +0 -1
  139. package/dist/cache/index.d.ts.map +0 -1
  140. package/dist/cache/keys.d.ts.map +0 -1
  141. package/dist/cache/types.d.ts.map +0 -1
  142. package/dist/core.d.ts.map +0 -1
  143. package/dist/db/adapters/drizzle.d.ts +0 -2
  144. package/dist/db/adapters/drizzle.d.ts.map +0 -1
  145. package/dist/db/adapters/index.d.ts +0 -2
  146. package/dist/db/adapters/index.d.ts.map +0 -1
  147. package/dist/db/adapters/kysely.d.ts +0 -2
  148. package/dist/db/adapters/kysely.d.ts.map +0 -1
  149. package/dist/db/adapters/mongo.d.ts +0 -2
  150. package/dist/db/adapters/mongo.d.ts.map +0 -1
  151. package/dist/db/adapters/prisma.d.ts +0 -2
  152. package/dist/db/adapters/prisma.d.ts.map +0 -1
  153. package/dist/db/adapters/typeorm.d.ts +0 -2
  154. package/dist/db/adapters/typeorm.d.ts.map +0 -1
  155. package/dist/db/migrator/index.d.ts.map +0 -1
  156. package/dist/db/registry/consent-policy.d.ts +0 -23
  157. package/dist/db/registry/consent-policy.d.ts.map +0 -1
  158. package/dist/db/registry/consent-purpose.d.ts.map +0 -1
  159. package/dist/db/registry/domain.d.ts.map +0 -1
  160. package/dist/db/registry/index.d.ts +0 -57
  161. package/dist/db/registry/index.d.ts.map +0 -1
  162. package/dist/db/registry/subject.d.ts.map +0 -1
  163. package/dist/db/registry/types.d.ts.map +0 -1
  164. package/dist/db/registry/utils/generate-id.d.ts.map +0 -1
  165. package/dist/db/registry/utils.d.ts.map +0 -1
  166. package/dist/db/schema/1.0.0/audit-log.d.ts.map +0 -1
  167. package/dist/db/schema/1.0.0/consent-policy.d.ts.map +0 -1
  168. package/dist/db/schema/1.0.0/consent-purpose.d.ts.map +0 -1
  169. package/dist/db/schema/1.0.0/consent-record.d.ts.map +0 -1
  170. package/dist/db/schema/1.0.0/consent.d.ts.map +0 -1
  171. package/dist/db/schema/1.0.0/domain.d.ts.map +0 -1
  172. package/dist/db/schema/1.0.0/index.d.ts.map +0 -1
  173. package/dist/db/schema/1.0.0/subject.d.ts.map +0 -1
  174. package/dist/db/schema/2.0.0/audit-log.d.ts.map +0 -1
  175. package/dist/db/schema/2.0.0/consent-policy.d.ts.map +0 -1
  176. package/dist/db/schema/2.0.0/consent-purpose.d.ts.map +0 -1
  177. package/dist/db/schema/2.0.0/consent.d.ts.map +0 -1
  178. package/dist/db/schema/2.0.0/domain.d.ts.map +0 -1
  179. package/dist/db/schema/2.0.0/index.d.ts.map +0 -1
  180. package/dist/db/schema/2.0.0/subject.d.ts.map +0 -1
  181. package/dist/db/schema/index.d.ts.map +0 -1
  182. package/dist/db/tenant-scope.d.ts.map +0 -1
  183. package/dist/define-config.d.ts +0 -5
  184. package/dist/define-config.d.ts.map +0 -1
  185. package/dist/handlers/consent/check.handler.d.ts.map +0 -1
  186. package/dist/handlers/consent/index.d.ts +0 -12
  187. package/dist/handlers/consent/index.d.ts.map +0 -1
  188. package/dist/handlers/init/geo.d.ts.map +0 -1
  189. package/dist/handlers/init/index.d.ts.map +0 -1
  190. package/dist/handlers/init/translations.d.ts +0 -28
  191. package/dist/handlers/init/translations.d.ts.map +0 -1
  192. package/dist/handlers/status/index.d.ts +0 -7
  193. package/dist/handlers/status/index.d.ts.map +0 -1
  194. package/dist/handlers/status/status.handler.d.ts.map +0 -1
  195. package/dist/handlers/subject/get.handler.d.ts.map +0 -1
  196. package/dist/handlers/subject/index.d.ts +0 -10
  197. package/dist/handlers/subject/index.d.ts.map +0 -1
  198. package/dist/handlers/subject/list.handler.d.ts.map +0 -1
  199. package/dist/handlers/subject/patch.handler.d.ts.map +0 -1
  200. package/dist/handlers/subject/post.handler.d.ts.map +0 -1
  201. package/dist/handlers/utils/consent-enrichment.d.ts.map +0 -1
  202. package/dist/init.d.ts.map +0 -1
  203. package/dist/middleware/auth/index.d.ts.map +0 -1
  204. package/dist/middleware/auth/validate-api-key.d.ts.map +0 -1
  205. package/dist/middleware/cors/cors.d.ts.map +0 -1
  206. package/dist/middleware/cors/index.d.ts +0 -30
  207. package/dist/middleware/cors/index.d.ts.map +0 -1
  208. package/dist/middleware/cors/is-origin-trusted.d.ts.map +0 -1
  209. package/dist/middleware/cors/process-cors.d.ts.map +0 -1
  210. package/dist/middleware/openapi/config.d.ts.map +0 -1
  211. package/dist/middleware/openapi/handlers.d.ts.map +0 -1
  212. package/dist/middleware/openapi/index.d.ts +0 -12
  213. package/dist/middleware/openapi/index.d.ts.map +0 -1
  214. package/dist/middleware/process-ip/index.d.ts.map +0 -1
  215. package/dist/router.d.ts.map +0 -1
  216. package/dist/routes/consent.d.ts.map +0 -1
  217. package/dist/routes/index.d.ts.map +0 -1
  218. package/dist/routes/init.d.ts.map +0 -1
  219. package/dist/routes/status.d.ts.map +0 -1
  220. package/dist/routes/subject.d.ts.map +0 -1
  221. package/dist/types/api.d.ts.map +0 -1
  222. package/dist/types/index.d.ts +0 -255
  223. package/dist/types/index.d.ts.map +0 -1
  224. package/dist/utils/create-telemetry-options.d.ts.map +0 -1
  225. package/dist/utils/env.d.ts.map +0 -1
  226. package/dist/utils/extract-error-message.d.ts.map +0 -1
  227. package/dist/utils/index.d.ts +0 -4
  228. package/dist/utils/index.d.ts.map +0 -1
  229. package/dist/utils/instrumentation.d.ts.map +0 -1
  230. package/dist/utils/logger.d.ts.map +0 -1
  231. package/dist/utils/metrics.d.ts.map +0 -1
  232. package/dist/version.d.ts +0 -2
  233. package/dist/version.d.ts.map +0 -1
  234. package/knip.json +0 -31
  235. package/rslib.config.ts +0 -93
  236. package/src/cache/adapters/cloudflare-kv.ts +0 -71
  237. package/src/cache/adapters/index.ts +0 -22
  238. package/src/cache/adapters/memory.ts +0 -111
  239. package/src/cache/adapters/upstash-redis.ts +0 -113
  240. package/src/cache/gvl-resolver.ts +0 -289
  241. package/src/cache/index.ts +0 -34
  242. package/src/cache/keys.ts +0 -68
  243. package/src/cache/types.ts +0 -66
  244. package/src/core.ts +0 -368
  245. package/src/db/migrator/index.ts +0 -80
  246. package/src/db/registry/consent-policy.test.ts +0 -451
  247. package/src/db/registry/consent-policy.ts +0 -82
  248. package/src/db/registry/consent-purpose.test.ts +0 -428
  249. package/src/db/registry/consent-purpose.ts +0 -61
  250. package/src/db/registry/domain.test.ts +0 -445
  251. package/src/db/registry/domain.ts +0 -91
  252. package/src/db/registry/index.ts +0 -14
  253. package/src/db/registry/subject.test.ts +0 -388
  254. package/src/db/registry/subject.ts +0 -129
  255. package/src/db/registry/types.ts +0 -10
  256. package/src/db/registry/utils/generate-id.test.ts +0 -216
  257. package/src/db/registry/utils/generate-id.ts +0 -133
  258. package/src/db/registry/utils.ts +0 -133
  259. package/src/db/schema/1.0.0/audit-log.ts +0 -15
  260. package/src/db/schema/1.0.0/consent-policy.ts +0 -14
  261. package/src/db/schema/1.0.0/consent-purpose.ts +0 -14
  262. package/src/db/schema/1.0.0/consent-record.ts +0 -10
  263. package/src/db/schema/1.0.0/consent.ts +0 -20
  264. package/src/db/schema/1.0.0/domain.ts +0 -12
  265. package/src/db/schema/1.0.0/index.ts +0 -48
  266. package/src/db/schema/1.0.0/subject.ts +0 -12
  267. package/src/db/schema/2.0.0/audit-log.ts +0 -18
  268. package/src/db/schema/2.0.0/consent-policy.ts +0 -28
  269. package/src/db/schema/2.0.0/consent-purpose.ts +0 -12
  270. package/src/db/schema/2.0.0/consent.ts +0 -26
  271. package/src/db/schema/2.0.0/domain.ts +0 -12
  272. package/src/db/schema/2.0.0/index.ts +0 -47
  273. package/src/db/schema/2.0.0/subject.ts +0 -14
  274. package/src/db/schema/index.ts +0 -15
  275. package/src/db/tenant-scope.test.ts +0 -750
  276. package/src/db/tenant-scope.ts +0 -103
  277. package/src/define-config.ts +0 -5
  278. package/src/handlers/consent/check.handler.ts +0 -126
  279. package/src/handlers/init/geo.test.ts +0 -317
  280. package/src/handlers/init/geo.ts +0 -195
  281. package/src/handlers/init/index.test.ts +0 -205
  282. package/src/handlers/init/index.ts +0 -114
  283. package/src/handlers/init/translations.test.ts +0 -121
  284. package/src/handlers/init/translations.ts +0 -72
  285. package/src/handlers/status/status.handler.test.ts +0 -155
  286. package/src/handlers/status/status.handler.ts +0 -51
  287. package/src/handlers/subject/get.handler.ts +0 -93
  288. package/src/handlers/subject/list.handler.ts +0 -93
  289. package/src/handlers/subject/patch.handler.ts +0 -122
  290. package/src/handlers/subject/post.handler.test.ts +0 -294
  291. package/src/handlers/subject/post.handler.ts +0 -254
  292. package/src/handlers/utils/consent-enrichment.test.ts +0 -380
  293. package/src/handlers/utils/consent-enrichment.ts +0 -218
  294. package/src/init.test.ts +0 -126
  295. package/src/init.ts +0 -87
  296. package/src/middleware/auth/index.ts +0 -11
  297. package/src/middleware/auth/validate-api-key.test.ts +0 -86
  298. package/src/middleware/auth/validate-api-key.ts +0 -107
  299. package/src/middleware/cors/cors.test.ts +0 -135
  300. package/src/middleware/cors/cors.ts +0 -186
  301. package/src/middleware/cors/is-origin-trusted.test.ts +0 -164
  302. package/src/middleware/cors/is-origin-trusted.ts +0 -130
  303. package/src/middleware/cors/process-cors.ts +0 -91
  304. package/src/middleware/openapi/config.ts +0 -29
  305. package/src/middleware/openapi/handlers.ts +0 -34
  306. package/src/middleware/process-ip/index.test.ts +0 -195
  307. package/src/middleware/process-ip/index.ts +0 -199
  308. package/src/router.ts +0 -15
  309. package/src/routes/consent.ts +0 -52
  310. package/src/routes/index.ts +0 -10
  311. package/src/routes/init.ts +0 -102
  312. package/src/routes/status.ts +0 -46
  313. package/src/routes/subject.ts +0 -152
  314. package/src/types/api.ts +0 -48
  315. package/src/types/index.ts +0 -288
  316. package/src/utils/create-telemetry-options.test.ts +0 -302
  317. package/src/utils/create-telemetry-options.ts +0 -229
  318. package/src/utils/env.ts +0 -84
  319. package/src/utils/extract-error-message.ts +0 -21
  320. package/src/utils/instrumentation.test.ts +0 -185
  321. package/src/utils/instrumentation.ts +0 -196
  322. package/src/utils/logger.ts +0 -41
  323. package/src/utils/metrics.test.ts +0 -323
  324. package/src/utils/metrics.ts +0 -402
  325. package/src/utils/telemetry-pii.test.ts +0 -325
  326. package/src/version.ts +0 -2
  327. package/tsconfig.json +0 -11
  328. package/vitest.config.ts +0 -28
  329. /package/dist/{types.js → types/index.js} +0 -0
  330. /package/{src/db/adapters/drizzle.ts → dist-types/db/adapters/drizzle.d.ts} +0 -0
  331. /package/{src/db/adapters/index.ts → dist-types/db/adapters/index.d.ts} +0 -0
  332. /package/{src/db/adapters/kysely.ts → dist-types/db/adapters/kysely.d.ts} +0 -0
  333. /package/{src/db/adapters/mongo.ts → dist-types/db/adapters/mongo.d.ts} +0 -0
  334. /package/{src/db/adapters/prisma.ts → dist-types/db/adapters/prisma.d.ts} +0 -0
  335. /package/{src/db/adapters/typeorm.ts → dist-types/db/adapters/typeorm.d.ts} +0 -0
  336. /package/{src/utils/index.ts → dist-types/utils/index.d.ts} +0 -0
@@ -0,0 +1,6 @@
1
+ import type { C15TContext } from '../types';
2
+ /**
3
+ * Executes non-critical work via configured background runner when available.
4
+ * Falls back to fire-and-forget local execution.
5
+ */
6
+ export declare function runInBackground(ctx: C15TContext, task: () => Promise<void>): void;
@@ -1,6 +1,6 @@
1
1
  import { type Meter, type Span } from '@opentelemetry/api';
2
2
  import type { C15TOptions } from '../types';
3
- type TelemetryConfig = NonNullable<C15TOptions['advanced']>['telemetry'];
3
+ type TelemetryConfig = C15TOptions['telemetry'];
4
4
  /**
5
5
  * Creates telemetry configuration from provided options
6
6
  *
@@ -68,4 +68,3 @@ export declare function getTraceContext(): {
68
68
  */
69
69
  export declare const withSpanContext: <T>(span: Span, operation: () => Promise<T>) => Promise<T>;
70
70
  export {};
71
- //# sourceMappingURL=create-telemetry-options.d.ts.map
@@ -57,4 +57,3 @@ export declare const nodeENV: string;
57
57
  * ```
58
58
  */
59
59
  export declare const isTest: boolean;
60
- //# sourceMappingURL=env.d.ts.map
@@ -6,4 +6,3 @@
6
6
  * real messages.
7
7
  */
8
8
  export declare function extractErrorMessage(error: unknown): string;
9
- //# sourceMappingURL=extract-error-message.d.ts.map
@@ -3,8 +3,8 @@ import type { C15TOptions } from '../types';
3
3
  * Span attributes for database operations
4
4
  */
5
5
  export interface DatabaseSpanAttributes {
6
- /** The database operation type (find, create, update, delete) */
7
- operation: 'find' | 'create' | 'update' | 'delete' | 'findOrCreate';
6
+ /** The database operation type */
7
+ operation: 'find' | 'create' | 'update' | 'delete' | 'findOrCreate' | 'findLatest' | 'findByHash' | 'syncCurrent' | 'findOrCreateLegalDocument';
8
8
  /** The entity type being operated on */
9
9
  entity: string;
10
10
  /** Optional additional attributes */
@@ -67,4 +67,3 @@ export declare function withExternalSpan<T>(attributes: ExternalSpanAttributes,
67
67
  * @returns The result of the operation
68
68
  */
69
69
  export declare function withCacheSpan<T>(operation: 'get' | 'set' | 'delete', layer: 'bundled' | 'memory' | 'external', fn: () => Promise<T>, options?: C15TOptions): Promise<T>;
70
- //# sourceMappingURL=instrumentation.d.ts.map
@@ -13,4 +13,3 @@ export declare function getLogger(options?: LoggerOptions): ReturnType<typeof cr
13
13
  * @returns The initialized global logger instance
14
14
  */
15
15
  export declare function initLogger(options: LoggerOptions): ReturnType<typeof createLogger>;
16
- //# sourceMappingURL=logger.d.ts.map
@@ -130,4 +130,3 @@ export declare function getMetrics(options?: C15TOptions): C15TMetrics | null;
130
130
  * Reset the metrics instance (useful for testing)
131
131
  */
132
132
  export declare function resetMetrics(): void;
133
- //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ export declare const version = "2.0.0-rc.10";
package/docs/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # c15t Backend Docs
2
+
3
+ Self-hosted c15t backend docs for configuration, policy packs, APIs, and operational behavior.
4
+
5
+ If you are changing consent flows, consent UI, script loading, server-side setup, or backend configuration in an app that uses this package, start here before editing code.
6
+
7
+ ## Start Here
8
+
9
+ - [Quickstart](./quickstart.md)
10
+ - [Database Setup](./guides/database-setup.md)
11
+ - [Policy Packs](./guides/policy-packs.md)
12
+ - [Configuration](./api/configuration.md)
13
+
14
+ ## Workflow Rules
15
+
16
+ ### Database & Initial Setup
17
+
18
+ Use this when:
19
+ - configuring a self-hosted backend
20
+ - choosing adapters or initial backend wiring
21
+
22
+ Prefer:
23
+ - Start with the documented database setup guide.
24
+ - Prefer the documented adapter and setup path before custom backend wiring.
25
+
26
+ If that is not enough:
27
+ - Use the API reference when you need exact option-level behavior.
28
+
29
+ Read next:
30
+ - [Quickstart](./quickstart.md)
31
+ - [Database Setup](./guides/database-setup.md)
32
+ - [Configuration](./api/configuration.md)
33
+
34
+ ### Policy Packs & Regional Behavior
35
+
36
+ Use this when:
37
+ - configuring region-aware consent behavior
38
+ - deciding whether logic belongs in backend policy config or frontend code
39
+
40
+ Prefer:
41
+ - Prefer policy-pack and documented backend configuration over frontend-only regional logic.
42
+ - Keep consent behavior centralized in backend policy configuration where possible.
43
+
44
+ Avoid:
45
+ - Do not scatter policy decisions across client code when the backend can own them.
46
+
47
+ Read next:
48
+ - [Policy Packs](./guides/policy-packs.md)
49
+ - [Configuration](./api/configuration.md)
@@ -0,0 +1,208 @@
1
+ ---
2
+ title: Configuration Reference
3
+ description: Complete reference for all c15t backend configuration options.
4
+ ---
5
+ All options are passed to `c15tInstance()`. Only `adapter` and `trustedOrigins` are required.
6
+
7
+ ## Options
8
+
9
+ ### C15TOptions
10
+
11
+ |Property|Type|Description|Default|Required|
12
+ |:--|:--|:--|:--|:--:|
13
+ |adapter|[FumaDBAdapter](https://v2.c15t.com/docs/self-host/guides/database-setup)|The database adapter to use.|-|✅ Required|
14
+ |tenantId|string \|undefined|Tenant ID for multi-tenant deployments. When set, all database queries are automatically scoped to this tenant.|-|Optional|
15
+ |tablePrefix|[string \|undefined](https://v2.c15t.com/docs/self-host/guides/database-setup)|Optional prefix for all database table names. Useful when sharing a database with other applications to avoid naming conflicts.|-|Optional|
16
+ |appName|[string \|undefined](https://v2.c15t.com/docs/self-host/api/configuration)|Application name used as backend metadata and identity. Returned by \`/init\` (\`appName\`), used in logs, telemetry defaults (\`service.name\`), and cache key prefixing.|"c15t"|Optional|
17
+ |basePath|[string \|undefined](https://v2.c15t.com/docs/self-host/api/endpoints)|Base path prefix for all API routes (e.g. \`/api/self-host\`).|-|Optional|
18
+ |trustedOrigins|[string\[\]](https://v2.c15t.com/docs/self-host/api/configuration)|Allowed origins for CORS. Required for browser-based consent collection. Protocol is optional; matching is protocol-agnostic and normalized.|-|✅ Required|
19
+ |logger|LoggerOptions \|undefined|Logger configuration.|-|Optional|
20
+ |disableGeoLocation|boolean \|undefined|Disables the use of Geo Location to determine the jurisdiction. When enabled, the jurisdiction will be set to "GDPR" to show the strictest version of the banner as we don't know the jurisdiction in this case.|false|Optional|
21
+ |customTranslations|Record\<string, Partial\<Translations>> \|undefined|Override base translations.|-|Optional|
22
+ |i18n|I18nOptions \|undefined|Internationalization message profiles used by runtime policies.|-|Optional|
23
+ |policyPacks|[PolicyConfig \|undefined](https://v2.c15t.com/docs/self-host/guides/policy-packs)|Runtime regional policy pack resolved per request.|-|Optional|
24
+ |branding|"c15t" \|"consent" \|"none" \|"inth" \|undefined|Select which branding to show in the consent banner. Use "inth" for the INTH brand. "consent" is a deprecated alias for "inth". Use "none" to hide branding.|"c15t"|Optional|
25
+ |openapi|[OpenAPIOptions \|undefined](https://v2.c15t.com/docs/self-host/api/endpoints)|OpenAPI spec generation and documentation UI options.|-|Optional|
26
+ |telemetry|[TelemetryOptions \|undefined](https://v2.c15t.com/docs/self-host/guides/observability)|OpenTelemetry configuration for tracing and metrics. Telemetry is opt-in and disabled by default. Users must provide their own SDK setup (Node, Bun, edge, etc.).|-|Optional|
27
+ |ipAddress|[IPAddressOptions \|undefined](https://v2.c15t.com/docs/self-host/api/configuration)|IP address tracking and masking options.|-|Optional|
28
+ |cache|[CacheOptions \|undefined](https://v2.c15t.com/docs/self-host/guides/caching)|Cache configuration for external persistent storage. Used for caching GVL and other data.|-|Optional|
29
+ |apiKeys|string\[] \|undefined|API keys for authenticated endpoints. Used for server-side endpoints like GET /subjects.|-|Optional|
30
+ |iab|[IABOptions \|undefined](https://v2.c15t.com/docs/self-host/guides/iab-tcf)|IAB TCF configuration including GVL, CMP registration, and custom vendors. Disabled by default - most users don't need IAB TCF. Set enabled: true to activate IAB support.|-|Optional|
31
+ |policySnapshot|PolicySnapshotOptions \|undefined|Optional signed policy snapshots used to keep /init and /subjects consistent.|-|Optional|
32
+ |legalDocumentSnapshot|LegalDocumentSnapshotOptions \|undefined|Optional signed legal-document snapshots issued by external document renderers.|-|Optional|
33
+ |background|BackgroundOptions \|undefined|Optional background task runner for non-critical side effects.|-|Optional|
34
+
35
+ #### `adapter` FumaDBAdapter
36
+
37
+ The database adapter to use.
38
+
39
+ |Property|Type|Description|Default|Required|
40
+ |:--|:--|:--|:--|:--:|
41
+ |name|string|Name of the adapter|-|✅ Required|
42
+ |generateSchema|Object \|undefined|Generate ORM schema based on FumaDB Schema|-|Optional|
43
+ |createMigrationEngine|((this: FumaDBAdapterContext) => Migrator) \|undefined|-|-|Optional|
44
+
45
+ #### `logger` LoggerOptions
46
+
47
+ Logger configuration.
48
+
49
+ |Property|Type|Description|Default|Required|
50
+ |:--|:--|:--|:--|:--:|
51
+ |disabled|boolean \|undefined|Whether logging is disabled.|-|Optional|
52
+ |level|"info" \|"warn" \|"error" \|"debug" \|undefined|The minimum log level to publish.|-|Optional|
53
+ |log|((level: LogLevel, message: string, ...args: unknown\[]) => void) \|undefined|Custom log handler function.|-|Optional|
54
+ |appName|string \|undefined|Custom application name to display in log messages.|-|Optional|
55
+ |getTraceContext|(() => TraceContext \|null) \|undefined|Optional callback to get trace context for log correlation.|-|Optional|
56
+
57
+ #### `i18n` I18nOptions
58
+
59
+ Internationalization message profiles used by runtime policies.
60
+
61
+ |Property|Type|Description|Default|Required|
62
+ |:--|:--|:--|:--|:--:|
63
+ |messages|I18nMessageProfiles \|undefined|Named translation catalogs grouped by profile.|-|Optional|
64
+ |defaultProfile|string \|undefined|Fallback profile used when a policy does not provide \`messageProfile\`.|-|Optional|
65
+
66
+ #### `policyPacks` PolicyConfig
67
+
68
+ Runtime regional policy pack resolved per request.
69
+
70
+ |Property|Type|Description|Default|Required|
71
+ |:--|:--|:--|:--|:--:|
72
+ |id|string|-|-|✅ Required|
73
+ |match|Object \|undefined|-|-|✅ Required|
74
+ |i18n|Object \|undefined|-|-|Optional|
75
+ |consent|Object \|undefined|-|-|Optional|
76
+ |ui|Object \|undefined|-|-|Optional|
77
+ |proof|Object \|undefined|-|-|Optional|
78
+
79
+ #### `policySnapshot` PolicySnapshotOptions
80
+
81
+ Optional signed policy snapshots used to keep /init and /subjects consistent.
82
+
83
+ |Property|Type|Description|Default|Required|
84
+ |:--|:--|:--|:--|:--:|
85
+ |signingKey|string|Secret used for signing and verifying policy snapshot tokens.|-|✅ Required|
86
+ |onValidationFailure|"reject" \|"resolve\_current" \|undefined|How writes should behave when snapshot validation fails.|-|Optional|
87
+ |issuer|string \|undefined|JWT issuer claim for snapshot tokens.|-|Optional|
88
+ |audience|string \|undefined|JWT audience claim for snapshot tokens. When omitted, c15t derives a default snapshot audience and scopes it per tenant.|-|Optional|
89
+ |ttlSeconds|number \|undefined|Snapshot token lifetime in seconds.|-|Optional|
90
+
91
+ #### `legalDocumentSnapshot` LegalDocumentSnapshotOptions
92
+
93
+ Optional signed legal-document snapshots issued by external document renderers.
94
+
95
+ |Property|Type|Description|Default|Required|
96
+ |:--|:--|:--|:--|:--:|
97
+ |signingKey|string|Secret used for signing and verifying legal-document snapshot tokens.|-|✅ Required|
98
+ |issuer|string \|undefined|JWT issuer claim for legal-document snapshot tokens.|-|Optional|
99
+ |audience|string \|undefined|JWT audience claim for legal-document snapshot tokens. When omitted, c15t derives a default audience and scopes it per tenant.|-|Optional|
100
+
101
+ #### `background` BackgroundOptions
102
+
103
+ Optional background task runner for non-critical side effects.
104
+
105
+ |Property|Type|Description|Default|Required|
106
+ |:--|:--|:--|:--|:--:|
107
+ |run|(task: () => Promise\<void>) => void|Executes non-critical tasks after the response path has completed.|-|✅ Required|
108
+
109
+ ### OpenAPIOptions
110
+
111
+ |Property|Type|Description|Default|Required|
112
+ |:--|:--|:--|:--|:--:|
113
+ |enabled|boolean \|undefined|Enable/disable OpenAPI spec generation|true|Optional|
114
+ |specPath|string \|undefined|Path to serve the OpenAPI JSON spec|"/spec.json"|Optional|
115
+ |docsPath|string \|undefined|Path to serve the API documentation UI|"/docs"|Optional|
116
+ |options|Object \|undefined|OpenAPI specification options|-|Optional|
117
+ |customUiTemplate|string \|undefined|Custom template for rendering the API documentation UI If provided, this will be used instead of the default Scalar UI|-|Optional|
118
+
119
+ #### `options`
120
+
121
+ OpenAPI specification options
122
+
123
+ |Property|Type|Description|Default|Required|
124
+ |:--|:--|:--|:--|:--:|
125
+ |info|Object \|undefined|-|-|Optional|
126
+ |servers|Array\<Object> \|undefined|-|-|Optional|
127
+ |security|Record\<string, string\[]>\[] \|undefined|-|-|Optional|
128
+
129
+ ### TelemetryOptions
130
+
131
+ |Property|Type|Description|Default|Required|
132
+ |:--|:--|:--|:--|:--:|
133
+ |enabled|boolean \|undefined|Enable telemetry (tracing and metrics). Must be explicitly set to true to activate.|false|Optional|
134
+ |tracer|Tracer \|undefined|User-provided tracer instance. Users should set up their own OpenTelemetry SDK and pass the tracer here.|-|Optional|
135
+ |meter|Meter \|undefined|User-provided meter instance for metrics. Users should set up their own OpenTelemetry SDK and pass the meter here.|-|Optional|
136
+ |defaultAttributes|Record\<string, string \|number \|boolean> \|undefined|Default attributes to include on all spans and metrics.|-|Optional|
137
+
138
+ ### IPAddressOptions
139
+
140
+ |Property|Type|Description|Default|Required|
141
+ |:--|:--|:--|:--|:--:|
142
+ |tracking|boolean \|undefined|Enable/disable IP address tracking. When disabled, all IP addresses will be stored as null.|true|Optional|
143
+ |masking|boolean \|undefined|Enable/disable IP address masking to reduce PII collection.|true|Optional|
144
+ |ipAddressHeaders|string\[] \|undefined|Override the default IP address headers used to extract client IP. Headers are checked in order, first match wins.|-|Optional|
145
+
146
+ ### CacheOptions
147
+
148
+ |Property|Type|Description|Default|Required|
149
+ |:--|:--|:--|:--|:--:|
150
+ |adapter|CacheAdapter \|undefined|External cache adapter (Redis, KV, etc.). If not provided, only in-memory cache is used.|-|Optional|
151
+
152
+ ### IABOptions
153
+
154
+ |Property|Type|Description|Default|Required|
155
+ |:--|:--|:--|:--|:--:|
156
+ |enabled|true|Enable IAB TCF support. When false or not provided, /init does not include IAB payload fields. When true, /init includes IAB payload only when IAB is active for the resolved request policy (or when no policies are configured).|-|✅ Required|
157
+ |cmpId|number \|undefined|CMP ID registered with IAB Europe. This is returned to clients via the /init endpoint so they can use the correct CMP identity in TC Strings. See List of registered CMPs: https\://iabeurope.eu/cmp-list/|-|Optional|
158
+ |bundled|Object \|undefined \|null|Bundled GVL translations by language code. These are checked first before any cache or fetch.|-|Optional|
159
+ |vendorIds|number\[] \|undefined|Vendor IDs to filter when fetching non-bundled languages. Reduces payload size.|-|Optional|
160
+ |endpoint|string \|undefined|Override the default GVL endpoint.|'https\://gvl.consent.io'|Optional|
161
+ |customVendors|Array\<Object> \|undefined|Custom vendors not registered with IAB. These are synced to the frontend via the /init endpoint.|-|Optional|
162
+
163
+ ## Return Value
164
+
165
+ `c15tInstance()` returns:
166
+
167
+ ```ts
168
+ interface C15TInstance {
169
+ /** Standard Fetch API handler */
170
+ handler: (request: Request) => Promise<Response>;
171
+
172
+ /** Resolved configuration */
173
+ options: C15TOptions;
174
+
175
+ /** Internal context (database, registry, logger) */
176
+ $context: C15TContext;
177
+
178
+ /** OpenAPI spec as JSON */
179
+ getOpenAPISpec: () => Promise<Record<string, unknown>>;
180
+
181
+ /** OpenAPI docs UI as HTML string */
182
+ getDocsUI: () => string;
183
+ }
184
+ ```
185
+
186
+ ## Edge Init Options
187
+
188
+ `unstable_c15tEdgeInit()` from `@c15t/backend/edge` accepts a subset of `C15TOptions` — only the fields needed for consent policy resolution without a database. This edge runtime API is unstable in `2.0`. See the [Edge Deployment guide](/docs/self-host/guides/edge-deployment) for usage.
189
+
190
+ ### C15TEdgeOptions
191
+
192
+ |Property|Type|Description|Default|Required|
193
+ |:--|:--|:--|:--|:--:|
194
+ |C15TEdgeOptions|C15TEdgeOptions|Type alias for C15TEdgeOptions|-|✅ Required|
195
+
196
+ ## defineConfig Helper
197
+
198
+ For type-safe configuration in a separate file:
199
+
200
+ ```ts title="c15t.config.ts"
201
+ import { defineConfig } from '@c15t/backend';
202
+
203
+ export default defineConfig({
204
+ adapter: kyselyAdapter(db),
205
+ trustedOrigins: ['https://example.com'],
206
+ // full autocomplete on all options here
207
+ });
208
+ ```
@@ -0,0 +1,211 @@
1
+ ---
2
+ title: API Endpoints
3
+ description: Full reference for every c15t consent backend endpoint.
4
+ ---
5
+ All endpoints are relative to your configured `basePath` (e.g. `/api/c15t`).
6
+
7
+ > ℹ️ **Info:**
8
+ > The backend auto-generates interactive API docs at \{basePath}/docs using your OpenAPI spec. Visit this URL in a browser to explore endpoints with a visual UI.
9
+
10
+ ## GET /init
11
+
12
+ Returns the initial consent state for a client. This is the first call made by the frontend SDKs.
13
+
14
+ **Response:**
15
+
16
+ ```json
17
+ {
18
+ "jurisdiction": "GDPR",
19
+ "location": {
20
+ "countryCode": "DE",
21
+ "regionCode": "BY"
22
+ },
23
+ "translations": {
24
+ "language": "de",
25
+ "translations": { "...": "..." }
26
+ },
27
+ "branding": "c15t",
28
+ "gvl": null
29
+ }
30
+ ```
31
+
32
+ |Field|Description|
33
+ |--|--|
34
+ |`jurisdiction`|Detected regulation (`GDPR`, `UK_GDPR`, `CCPA`, etc.)|
35
+ |`location`|Geo-location from IP address|
36
+ |`translations`|Server-side translations based on `Accept-Language`|
37
+ |`branding`|Branding configuration|
38
+ |`gvl`|Global Vendor List (if IAB TCF is enabled)|
39
+
40
+ ## GET /status
41
+
42
+ Health check endpoint. Returns server version and client info.
43
+
44
+ **Response:**
45
+
46
+ ```json
47
+ {
48
+ "version": "1.8.0",
49
+ "timestamp": "2026-02-11T12:00:00.000Z",
50
+ "client": {
51
+ "ip": "192.168.1.0",
52
+ "acceptLanguage": "en-US",
53
+ "userAgent": "Mozilla/5.0 ...",
54
+ "region": { "countryCode": "US", "regionCode": "CA" }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## POST /subjects
60
+
61
+ Records a consent event. This is an append-only operation — every call creates a new consent record.
62
+
63
+ **Request:**
64
+
65
+ ```json
66
+ {
67
+ "type": "cookie_banner",
68
+ "subjectId": "sub_abc123",
69
+ "domain": "example.com",
70
+ "preferences": {
71
+ "necessary": true,
72
+ "measurement": true,
73
+ "marketing": false
74
+ },
75
+ "givenAt": 1707648000000,
76
+ "metadata": {}
77
+ }
78
+ ```
79
+
80
+ |Field|Type|Required|Description|
81
+ |--|--|--|--|
82
+ |`type`|string|Yes|`cookie_banner`, `privacy_policy`, `dpa`, `terms_and_conditions`, `marketing_communications`, `age_verification`, `other`|
83
+ |`subjectId`|string|Yes|Client-generated subject identifier|
84
+ |`domain`|string|Yes|Domain where consent was given|
85
+ |`preferences`|object|No|Consent category preferences (for `cookie_banner` type)|
86
+ |`givenAt`|number|Yes|Epoch timestamp|
87
+ |`policyId`|string|No|Associated policy ID|
88
+ |`metadata`|object|No|Arbitrary metadata|
89
+ |`externalSubjectId`|string|No|External user ID for cross-device linking|
90
+ |`identityProvider`|string|No|Identity provider name|
91
+
92
+ **Response:**
93
+
94
+ ```json
95
+ {
96
+ "subject": { "id": "sub_abc123", "...": "..." },
97
+ "consent": { "id": "con_xyz789", "type": "cookie_banner", "...": "..." }
98
+ }
99
+ ```
100
+
101
+ ## GET /subjects/:id
102
+
103
+ Retrieves consent status for a subject.
104
+
105
+ **Query Parameters:**
106
+
107
+ |Parameter|Description|
108
+ |--|--|
109
+ |`type`|Comma-separated consent types to filter (e.g. `cookie_banner,privacy_policy`)|
110
+
111
+ **Response:**
112
+
113
+ ```json
114
+ {
115
+ "subject": { "id": "sub_abc123" },
116
+ "consents": [
117
+ {
118
+ "id": "con_xyz789",
119
+ "type": "cookie_banner",
120
+ "givenAt": "2026-02-11T12:00:00.000Z",
121
+ "jurisdiction": "GDPR",
122
+ "preferences": { "necessary": true, "measurement": true }
123
+ }
124
+ ],
125
+ "isValid": true
126
+ }
127
+ ```
128
+
129
+ ## PATCH /subjects/:id
130
+
131
+ Links a subject to an external user ID for cross-device consent resolution.
132
+
133
+ **Request:**
134
+
135
+ ```json
136
+ {
137
+ "externalId": "user_12345",
138
+ "identityProvider": "auth0"
139
+ }
140
+ ```
141
+
142
+ **Response:**
143
+
144
+ ```json
145
+ {
146
+ "subject": {
147
+ "id": "sub_abc123",
148
+ "externalId": "user_12345",
149
+ "identityProvider": "auth0"
150
+ }
151
+ }
152
+ ```
153
+
154
+ ## GET /consents/check
155
+
156
+ Check consent status by external ID — useful for cross-device consent resolution.
157
+
158
+ **Query Parameters:**
159
+
160
+ |Parameter|Description|
161
+ |--|--|
162
+ |`externalId`|The external user ID to look up|
163
+ |`type`|Comma-separated consent types|
164
+
165
+ **Response:**
166
+
167
+ ```json
168
+ {
169
+ "found": true,
170
+ "consents": [
171
+ { "id": "con_xyz789", "type": "cookie_banner", "...": "..." }
172
+ ]
173
+ }
174
+ ```
175
+
176
+ ## GET /subjects (Authenticated)
177
+
178
+ List subjects by external ID. Requires an API key.
179
+
180
+ **Headers:**
181
+
182
+ ```
183
+ Authorization: Bearer sk_live_abc123
184
+ ```
185
+
186
+ **Query Parameters:**
187
+
188
+ |Parameter|Description|
189
+ |--|--|
190
+ |`externalId`|The external user ID to search|
191
+
192
+ **Response:**
193
+
194
+ ```json
195
+ {
196
+ "subjects": [
197
+ { "id": "sub_abc123", "externalId": "user_12345" }
198
+ ]
199
+ }
200
+ ```
201
+
202
+ > ℹ️ **Info:**
203
+ > This endpoint requires API key authentication. Configure API keys in the apiKeys option. The key is passed via the Authorization: Bearer header using timing-safe comparison.
204
+
205
+ ## GET /spec.json
206
+
207
+ Returns the OpenAPI 3.1 specification for the consent API.
208
+
209
+ ## GET /docs
210
+
211
+ Serves the interactive API documentation UI (Scalar).
@@ -0,0 +1,85 @@
1
+ ---
2
+ title: Caching
3
+ description: Add a caching layer to your self-hosted c15t backend for production performance.
4
+ ---
5
+ The backend includes a caching layer for frequently accessed data like GVL (Global Vendor List) lookups and custom server-side translations. By default, an in-memory cache is used — suitable for single-instance deployments. For production with multiple instances, plug in Redis or Cloudflare KV so all instances share the same cache.
6
+
7
+ ## In-Memory (Default)
8
+
9
+ No configuration needed. The default memory cache has a 5-minute TTL and is suitable for development and single-instance deployments.
10
+
11
+ ## Upstash Redis
12
+
13
+ ```ts title="c15t.ts"
14
+ import { c15tInstance } from '@c15t/backend';
15
+ import { createUpstashRedisAdapter } from '@c15t/backend/cache';
16
+
17
+ export const c15t = c15tInstance({
18
+ // ...
19
+ cache: {
20
+ adapter: createUpstashRedisAdapter({
21
+ url: process.env.UPSTASH_REDIS_REST_URL,
22
+ token: process.env.UPSTASH_REDIS_REST_TOKEN,
23
+ }),
24
+ },
25
+ });
26
+ ```
27
+
28
+ If you already have an Upstash Redis client, pass it directly:
29
+
30
+ ```ts
31
+ import { createUpstashRedisAdapterFromClient } from '@c15t/backend/cache';
32
+ import { Redis } from '@upstash/redis';
33
+
34
+ const redis = new Redis({
35
+ url: process.env.UPSTASH_REDIS_REST_URL,
36
+ token: process.env.UPSTASH_REDIS_REST_TOKEN,
37
+ });
38
+
39
+ const adapter = createUpstashRedisAdapterFromClient(redis);
40
+ ```
41
+
42
+ ## Cloudflare KV
43
+
44
+ For Cloudflare Workers deployments:
45
+
46
+ ```ts title="worker.ts"
47
+ import { c15tInstance } from '@c15t/backend';
48
+ import { createCloudflareKVAdapter } from '@c15t/backend/cache';
49
+
50
+ export default {
51
+ async fetch(request: Request, env: Env) {
52
+ const c15t = c15tInstance({
53
+ // ...
54
+ cache: {
55
+ adapter: createCloudflareKVAdapter(env.GVL_CACHE),
56
+ },
57
+ });
58
+
59
+ return c15t.handler(request);
60
+ },
61
+ };
62
+ ```
63
+
64
+ ## Custom Cache Adapter
65
+
66
+ Implement the `CacheAdapter` interface to use any cache backend:
67
+
68
+ ```ts
69
+ import type { CacheAdapter } from '@c15t/backend/cache';
70
+
71
+ const customCache: CacheAdapter = {
72
+ async get<T>(key: string): Promise<T | null> {
73
+ // retrieve from your cache
74
+ },
75
+ async set<T>(key: string, value: T, ttlMs?: number): Promise<void> {
76
+ // store in your cache
77
+ },
78
+ async delete(key: string): Promise<void> {
79
+ // remove from cache
80
+ },
81
+ async has(key: string): Promise<boolean> {
82
+ // check existence
83
+ },
84
+ };
85
+ ```