@c15t/backend 1.8.0 → 2.0.0-rc.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.
- package/.turbo/turbo-build.log +44 -78
- package/CHANGELOG.md +13 -0
- package/dist/cache/adapters/cloudflare-kv.d.ts +46 -0
- package/dist/cache/adapters/cloudflare-kv.d.ts.map +1 -0
- package/dist/cache/adapters/index.d.ts +11 -0
- package/dist/cache/adapters/index.d.ts.map +1 -0
- package/dist/cache/adapters/memory.d.ts +47 -0
- package/dist/cache/adapters/memory.d.ts.map +1 -0
- package/dist/cache/adapters/upstash-redis.d.ts +75 -0
- package/dist/cache/adapters/upstash-redis.d.ts.map +1 -0
- package/dist/cache/gvl-resolver.d.ts +86 -0
- package/dist/cache/gvl-resolver.d.ts.map +1 -0
- package/dist/cache/index.d.ts +13 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/keys.d.ts +51 -0
- package/dist/cache/keys.d.ts.map +1 -0
- package/dist/cache/types.d.ts +61 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache.cjs +530 -0
- package/dist/cache.js +467 -0
- package/dist/core.cjs +2569 -3840
- package/dist/core.d.ts +19 -409
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2378 -3680
- package/dist/db/adapters/drizzle.cjs +36 -0
- package/dist/db/adapters/drizzle.d.ts.map +1 -0
- package/dist/db/adapters/index.d.ts.map +1 -0
- package/dist/db/adapters/kysely.cjs +36 -0
- package/dist/db/adapters/kysely.d.ts.map +1 -0
- package/dist/db/adapters/mongo.cjs +36 -0
- package/dist/db/adapters/mongo.d.ts.map +1 -0
- package/dist/db/adapters/prisma.cjs +36 -0
- package/dist/db/adapters/prisma.d.ts.map +1 -0
- package/dist/db/adapters/typeorm.cjs +36 -0
- package/dist/db/adapters/typeorm.d.ts.map +1 -0
- package/dist/db/adapters.cjs +18 -0
- package/dist/db/migrator/index.d.ts.map +1 -0
- package/dist/db/migrator.cjs +61 -0
- package/dist/db/registry/consent-policy.d.ts +23 -0
- package/dist/db/registry/consent-policy.d.ts.map +1 -0
- package/dist/db/registry/consent-purpose.d.ts +11 -0
- package/dist/db/registry/consent-purpose.d.ts.map +1 -0
- package/dist/db/registry/domain.d.ts +18 -0
- package/dist/db/registry/domain.d.ts.map +1 -0
- package/dist/db/registry/index.d.ts +57 -0
- package/dist/db/registry/index.d.ts.map +1 -0
- package/dist/db/registry/subject.d.ts +32 -0
- package/dist/db/registry/subject.d.ts.map +1 -0
- package/dist/db/registry/types.d.ts +10 -0
- package/dist/db/registry/types.d.ts.map +1 -0
- package/dist/db/registry/utils/generate-id.d.ts +25 -0
- package/dist/db/registry/utils/generate-id.d.ts.map +1 -0
- package/dist/db/registry/utils.d.ts +25 -0
- package/dist/db/registry/utils.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/audit-log.d.ts +14 -0
- package/dist/db/schema/1.0.0/audit-log.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent-policy.d.ts +13 -0
- package/dist/db/schema/1.0.0/consent-policy.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent-purpose.d.ts +13 -0
- package/dist/db/schema/1.0.0/consent-purpose.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent-record.d.ts +9 -0
- package/dist/db/schema/1.0.0/consent-record.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent.d.ts +18 -0
- package/dist/db/schema/1.0.0/consent.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/domain.d.ts +11 -0
- package/dist/db/schema/1.0.0/domain.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/index.d.ts +1506 -0
- package/dist/db/schema/1.0.0/index.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/subject.d.ts +11 -0
- package/dist/db/schema/1.0.0/subject.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/audit-log.d.ts +16 -0
- package/dist/db/schema/2.0.0/audit-log.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/consent-policy.d.ts +13 -0
- package/dist/db/schema/2.0.0/consent-policy.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/consent-purpose.d.ts +10 -0
- package/dist/db/schema/2.0.0/consent-purpose.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/consent.d.ts +24 -0
- package/dist/db/schema/2.0.0/consent.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/domain.d.ts +10 -0
- package/dist/db/schema/2.0.0/domain.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/index.d.ts +586 -0
- package/dist/db/schema/2.0.0/index.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/subject.d.ts +12 -0
- package/dist/db/schema/2.0.0/subject.d.ts.map +1 -0
- package/dist/db/schema/index.d.ts +2664 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema.cjs +359 -0
- package/dist/db/schema.js +261 -0
- package/dist/db/tenant-scope.d.ts +20 -0
- package/dist/db/tenant-scope.d.ts.map +1 -0
- package/dist/define-config.cjs +36 -0
- package/dist/define-config.d.ts.map +1 -0
- package/dist/handlers/consent/check.handler.d.ts +24 -0
- package/dist/handlers/consent/check.handler.d.ts.map +1 -0
- package/dist/handlers/consent/index.d.ts +11 -339
- package/dist/handlers/consent/index.d.ts.map +1 -1
- package/dist/handlers/init/geo.d.ts +34 -0
- package/dist/handlers/init/geo.d.ts.map +1 -0
- package/dist/handlers/init/index.d.ts +157 -0
- package/dist/handlers/init/index.d.ts.map +1 -0
- package/dist/handlers/init/translations.d.ts +28 -0
- package/dist/handlers/init/translations.d.ts.map +1 -0
- package/dist/handlers/status/index.d.ts +7 -0
- package/dist/handlers/status/index.d.ts.map +1 -0
- package/dist/handlers/status/status.handler.d.ts +26 -0
- package/dist/handlers/status/status.handler.d.ts.map +1 -0
- package/dist/handlers/subject/get.handler.d.ts +32 -0
- package/dist/handlers/subject/get.handler.d.ts.map +1 -0
- package/dist/handlers/subject/index.d.ts +10 -0
- package/dist/handlers/subject/index.d.ts.map +1 -0
- package/dist/handlers/subject/list.handler.d.ts +31 -0
- package/dist/handlers/subject/list.handler.d.ts.map +1 -0
- package/dist/handlers/subject/patch.handler.d.ts +22 -0
- package/dist/handlers/subject/patch.handler.d.ts.map +1 -0
- package/dist/handlers/subject/post.handler.d.ts +25 -0
- package/dist/handlers/subject/post.handler.d.ts.map +1 -0
- package/dist/handlers/utils/consent-enrichment.d.ts +52 -0
- package/dist/handlers/utils/consent-enrichment.d.ts.map +1 -0
- package/dist/init.d.ts +20 -26
- package/dist/init.d.ts.map +1 -1
- package/dist/middleware/auth/index.d.ts +7 -0
- package/dist/middleware/auth/index.d.ts.map +1 -0
- package/dist/middleware/auth/validate-api-key.d.ts +49 -0
- package/dist/middleware/auth/validate-api-key.d.ts.map +1 -0
- package/dist/middleware/cors/cors.d.ts +13 -17
- package/dist/middleware/cors/cors.d.ts.map +1 -1
- package/dist/middleware/cors/is-origin-trusted.d.ts.map +1 -1
- package/dist/middleware/cors/process-cors.d.ts +1 -1
- package/dist/middleware/cors/process-cors.d.ts.map +1 -1
- package/dist/middleware/openapi/config.d.ts +16 -2
- package/dist/middleware/openapi/config.d.ts.map +1 -1
- package/dist/middleware/openapi/handlers.d.ts +1 -24
- package/dist/middleware/openapi/handlers.d.ts.map +1 -1
- package/dist/middleware/openapi/index.d.ts +3 -2
- package/dist/middleware/openapi/index.d.ts.map +1 -1
- package/dist/middleware/process-ip/index.d.ts +12 -0
- package/dist/middleware/process-ip/index.d.ts.map +1 -0
- package/dist/router.cjs +1288 -1776
- package/dist/router.d.ts +9 -363
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1277 -1658
- package/dist/routes/consent.d.ts +16 -0
- package/dist/routes/consent.d.ts.map +1 -0
- package/dist/routes/index.d.ts +10 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/init.d.ts +16 -0
- package/dist/routes/init.d.ts.map +1 -0
- package/dist/routes/status.d.ts +16 -0
- package/dist/routes/status.d.ts.map +1 -0
- package/dist/routes/subject.d.ts +16 -0
- package/dist/routes/subject.d.ts.map +1 -0
- package/dist/types/api.d.ts +5 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/index.d.ts +253 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types.cjs +37 -0
- package/dist/types.js +3 -0
- package/dist/utils/create-telemetry-options.d.ts +71 -0
- package/dist/utils/create-telemetry-options.d.ts.map +1 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/extract-error-message.d.ts +9 -0
- package/dist/utils/extract-error-message.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/instrumentation.d.ts +70 -0
- package/dist/utils/instrumentation.d.ts.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/metrics.d.ts +133 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +143 -224
- package/rslib.config.ts +11 -34
- package/src/cache/adapters/cloudflare-kv.ts +71 -0
- package/src/cache/adapters/index.ts +22 -0
- package/src/cache/adapters/memory.ts +111 -0
- package/src/cache/adapters/upstash-redis.ts +113 -0
- package/src/cache/gvl-resolver.ts +289 -0
- package/src/cache/index.ts +34 -0
- package/src/cache/keys.ts +68 -0
- package/src/cache/types.ts +66 -0
- package/src/core.ts +254 -352
- package/src/db/migrator/index.ts +80 -0
- package/src/db/registry/consent-policy.test.ts +451 -0
- package/src/db/registry/consent-policy.ts +82 -0
- package/src/db/registry/consent-purpose.test.ts +428 -0
- package/src/db/registry/consent-purpose.ts +61 -0
- package/src/db/registry/domain.test.ts +445 -0
- package/src/db/registry/domain.ts +91 -0
- package/src/db/registry/index.ts +14 -0
- package/src/db/registry/subject.test.ts +388 -0
- package/src/db/registry/subject.ts +129 -0
- package/src/db/registry/types.ts +10 -0
- package/src/db/registry/utils/generate-id.test.ts +216 -0
- package/src/db/registry/utils/generate-id.ts +133 -0
- package/src/db/registry/utils.ts +133 -0
- package/src/db/schema/1.0.0/audit-log.ts +15 -0
- package/src/db/schema/1.0.0/consent-policy.ts +14 -0
- package/src/db/schema/1.0.0/consent-purpose.ts +14 -0
- package/src/db/schema/1.0.0/consent-record.ts +10 -0
- package/src/db/schema/1.0.0/consent.ts +20 -0
- package/src/db/schema/1.0.0/domain.ts +12 -0
- package/src/db/schema/1.0.0/index.ts +48 -0
- package/src/db/schema/1.0.0/subject.ts +12 -0
- package/src/db/schema/2.0.0/audit-log.ts +18 -0
- package/src/db/schema/2.0.0/consent-policy.ts +28 -0
- package/src/db/schema/2.0.0/consent-purpose.ts +12 -0
- package/src/db/schema/2.0.0/consent.ts +26 -0
- package/src/db/schema/2.0.0/domain.ts +12 -0
- package/src/db/schema/2.0.0/index.ts +47 -0
- package/src/db/schema/2.0.0/subject.ts +14 -0
- package/src/db/schema/index.ts +15 -0
- package/src/db/tenant-scope.test.ts +750 -0
- package/src/db/tenant-scope.ts +103 -0
- package/src/handlers/consent/check.handler.ts +126 -0
- package/src/handlers/consent/index.ts +11 -10
- package/src/handlers/init/geo.test.ts +317 -0
- package/src/handlers/init/geo.ts +195 -0
- package/src/handlers/init/index.test.ts +205 -0
- package/src/handlers/init/index.ts +114 -0
- package/src/handlers/init/translations.test.ts +121 -0
- package/src/handlers/init/translations.ts +72 -0
- package/src/handlers/status/index.ts +7 -0
- package/src/handlers/status/status.handler.test.ts +155 -0
- package/src/handlers/status/status.handler.ts +51 -0
- package/src/handlers/subject/get.handler.ts +93 -0
- package/src/handlers/subject/index.ts +10 -0
- package/src/handlers/subject/list.handler.ts +93 -0
- package/src/handlers/subject/patch.handler.ts +122 -0
- package/src/handlers/subject/post.handler.test.ts +294 -0
- package/src/handlers/subject/post.handler.ts +254 -0
- package/src/handlers/utils/consent-enrichment.test.ts +380 -0
- package/src/handlers/utils/consent-enrichment.ts +218 -0
- package/src/init.test.ts +126 -0
- package/src/init.ts +70 -297
- package/src/middleware/auth/index.ts +11 -0
- package/src/middleware/auth/validate-api-key.test.ts +86 -0
- package/src/middleware/auth/validate-api-key.ts +107 -0
- package/src/middleware/cors/cors.test.ts +96 -380
- package/src/middleware/cors/cors.ts +88 -97
- package/src/middleware/cors/is-origin-trusted.ts +2 -1
- package/src/middleware/cors/process-cors.ts +1 -1
- package/src/middleware/openapi/config.ts +8 -6
- package/src/middleware/openapi/handlers.ts +2 -100
- package/src/middleware/openapi/index.ts +3 -2
- package/src/middleware/process-ip/index.test.ts +195 -0
- package/src/middleware/process-ip/index.ts +199 -0
- package/src/router.ts +14 -7
- package/src/routes/consent.ts +52 -0
- package/src/routes/index.ts +10 -0
- package/src/routes/init.ts +102 -0
- package/src/routes/status.ts +46 -0
- package/src/routes/subject.ts +152 -0
- package/src/types/api.ts +17 -2
- package/src/types/index.ts +288 -23
- package/src/utils/create-telemetry-options.test.ts +302 -0
- package/src/utils/create-telemetry-options.ts +229 -0
- package/src/utils/extract-error-message.ts +21 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/instrumentation.test.ts +185 -0
- package/src/utils/instrumentation.ts +196 -0
- package/src/utils/logger.ts +41 -0
- package/src/utils/metrics.test.ts +323 -0
- package/src/utils/metrics.ts +402 -0
- package/src/utils/telemetry-pii.test.ts +325 -0
- package/src/version.ts +1 -1
- package/tsconfig.json +2 -4
- package/LICENSE.md +0 -595
- package/dist/__tests__/server.test.d.ts +0 -2
- package/dist/__tests__/server.test.d.ts.map +0 -1
- package/dist/contracts/consent/identify.contract.d.ts +0 -24
- package/dist/contracts/consent/identify.contract.d.ts.map +0 -1
- package/dist/contracts/consent/index.d.ts +0 -340
- package/dist/contracts/consent/index.d.ts.map +0 -1
- package/dist/contracts/consent/index.test.d.ts +0 -2
- package/dist/contracts/consent/index.test.d.ts.map +0 -1
- package/dist/contracts/consent/post.contract.d.ts +0 -117
- package/dist/contracts/consent/post.contract.d.ts.map +0 -1
- package/dist/contracts/consent/post.contract.test.d.ts +0 -2
- package/dist/contracts/consent/post.contract.test.d.ts.map +0 -1
- package/dist/contracts/consent/show-banner.contract.d.ts +0 -123
- package/dist/contracts/consent/show-banner.contract.d.ts.map +0 -1
- package/dist/contracts/consent/show-banner.contract.test.d.ts +0 -2
- package/dist/contracts/consent/show-banner.contract.test.d.ts.map +0 -1
- package/dist/contracts/consent/verify.contract.d.ts +0 -81
- package/dist/contracts/consent/verify.contract.d.ts.map +0 -1
- package/dist/contracts/consent/verify.contract.test.d.ts +0 -2
- package/dist/contracts/consent/verify.contract.test.d.ts.map +0 -1
- package/dist/contracts/index.d.ts +0 -731
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/meta/index.d.ts +0 -23
- package/dist/contracts/meta/index.d.ts.map +0 -1
- package/dist/contracts/meta/index.test.d.ts +0 -2
- package/dist/contracts/meta/index.test.d.ts.map +0 -1
- package/dist/contracts/meta/status.contract.d.ts +0 -22
- package/dist/contracts/meta/status.contract.d.ts.map +0 -1
- package/dist/contracts/meta/status.contract.test.d.ts +0 -2
- package/dist/contracts/meta/status.contract.test.d.ts.map +0 -1
- package/dist/contracts/shared/jurisdiction.schema.d.ts +0 -36
- package/dist/contracts/shared/jurisdiction.schema.d.ts.map +0 -1
- package/dist/contracts.cjs +0 -799
- package/dist/contracts.js +0 -636
- package/dist/handlers/consent/identify.handler.d.ts +0 -23
- package/dist/handlers/consent/identify.handler.d.ts.map +0 -1
- package/dist/handlers/consent/identify.handler.test.d.ts +0 -2
- package/dist/handlers/consent/identify.handler.test.d.ts.map +0 -1
- package/dist/handlers/consent/post.handler.d.ts +0 -139
- package/dist/handlers/consent/post.handler.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/geo.d.ts +0 -10
- package/dist/handlers/consent/show-banner/geo.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/geo.test.d.ts +0 -2
- package/dist/handlers/consent/show-banner/geo.test.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/handler.d.ts +0 -126
- package/dist/handlers/consent/show-banner/handler.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/handler.test.d.ts +0 -2
- package/dist/handlers/consent/show-banner/handler.test.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/translations.d.ts +0 -13
- package/dist/handlers/consent/show-banner/translations.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/translations.test.d.ts +0 -2
- package/dist/handlers/consent/show-banner/translations.test.d.ts.map +0 -1
- package/dist/handlers/consent/verify.handler.d.ts +0 -103
- package/dist/handlers/consent/verify.handler.d.ts.map +0 -1
- package/dist/handlers/meta/index.d.ts +0 -23
- package/dist/handlers/meta/index.d.ts.map +0 -1
- package/dist/handlers/meta/status.handler.d.ts +0 -21
- package/dist/handlers/meta/status.handler.d.ts.map +0 -1
- package/dist/middleware/cors/cors.test.d.ts +0 -2
- package/dist/middleware/cors/cors.test.d.ts.map +0 -1
- package/dist/middleware/cors/is-origin-trusted.test.d.ts +0 -2
- package/dist/middleware/cors/is-origin-trusted.test.d.ts.map +0 -1
- package/dist/pkgs/api-router/hooks/__tests__/processor.test.d.ts +0 -2
- package/dist/pkgs/api-router/hooks/__tests__/processor.test.d.ts.map +0 -1
- package/dist/pkgs/api-router/hooks/processor.d.ts +0 -87
- package/dist/pkgs/api-router/hooks/processor.d.ts.map +0 -1
- package/dist/pkgs/api-router/telemetry.d.ts +0 -15
- package/dist/pkgs/api-router/telemetry.d.ts.map +0 -1
- package/dist/pkgs/api-router/types/router-props.d.ts +0 -32
- package/dist/pkgs/api-router/types/router-props.d.ts.map +0 -1
- package/dist/pkgs/api-router/utils/ip.d.ts +0 -44
- package/dist/pkgs/api-router/utils/ip.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/field-factory.d.ts +0 -151
- package/dist/pkgs/data-model/fields/field-factory.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/field-inference.d.ts +0 -76
- package/dist/pkgs/data-model/fields/field-inference.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/field-types.d.ts +0 -182
- package/dist/pkgs/data-model/fields/field-types.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/id-generator.d.ts +0 -19
- package/dist/pkgs/data-model/fields/id-generator.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/index.cjs +0 -159
- package/dist/pkgs/data-model/fields/index.d.ts +0 -13
- package/dist/pkgs/data-model/fields/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/index.js +0 -106
- package/dist/pkgs/data-model/fields/superjson-utils.d.ts +0 -12
- package/dist/pkgs/data-model/fields/superjson-utils.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/zod-fields.d.ts +0 -331
- package/dist/pkgs/data-model/fields/zod-fields.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/create-hooks.d.ts +0 -32
- package/dist/pkgs/data-model/hooks/create-hooks.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/index.d.ts +0 -40
- package/dist/pkgs/data-model/hooks/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/types.d.ts +0 -134
- package/dist/pkgs/data-model/hooks/types.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/update-hooks.d.ts +0 -33
- package/dist/pkgs/data-model/hooks/update-hooks.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/update-many-hooks.d.ts +0 -55
- package/dist/pkgs/data-model/hooks/update-many-hooks.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/utils.d.ts +0 -62
- package/dist/pkgs/data-model/hooks/utils.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/with-hooks-factory.d.ts +0 -33
- package/dist/pkgs/data-model/hooks/with-hooks-factory.d.ts.map +0 -1
- package/dist/pkgs/data-model/index.cjs +0 -1603
- package/dist/pkgs/data-model/index.d.ts +0 -10
- package/dist/pkgs/data-model/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/index.js +0 -1469
- package/dist/pkgs/data-model/schema/index.cjs +0 -1550
- package/dist/pkgs/data-model/schema/index.d.ts +0 -8
- package/dist/pkgs/data-model/schema/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/schema/index.js +0 -1446
- package/dist/pkgs/data-model/schema/schemas.d.ts +0 -14
- package/dist/pkgs/data-model/schema/schemas.d.ts.map +0 -1
- package/dist/pkgs/data-model/schema/types.d.ts +0 -86
- package/dist/pkgs/data-model/schema/types.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapter-factory.d.ts +0 -21
- package/dist/pkgs/db-adapters/adapter-factory.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.d.ts +0 -122
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.cjs +0 -1183
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.js +0 -1139
- package/dist/pkgs/db-adapters/adapters/index.d.ts +0 -10
- package/dist/pkgs/db-adapters/adapters/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/dialect.d.ts +0 -70
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/dialect.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.cjs +0 -1296
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.d.ts +0 -4
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.js +0 -1132
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.d.ts +0 -99
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts +0 -49
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/types.d.ts +0 -278
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/types.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.cjs +0 -1076
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.js +0 -916
- package/dist/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.d.ts +0 -58
- package/dist/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.cjs +0 -1155
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.js +0 -1111
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.d.ts +0 -145
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/test.d.ts +0 -11
- package/dist/pkgs/db-adapters/adapters/test.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/index.cjs +0 -2035
- package/dist/pkgs/db-adapters/index.d.ts +0 -16
- package/dist/pkgs/db-adapters/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/index.js +0 -1972
- package/dist/pkgs/db-adapters/types.d.ts +0 -160
- package/dist/pkgs/db-adapters/types.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/utils.d.ts +0 -36
- package/dist/pkgs/db-adapters/utils.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-migration.d.ts +0 -4
- package/dist/pkgs/migrations/get-migration.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/get-schema.d.ts +0 -27
- package/dist/pkgs/migrations/get-schema/get-schema.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/index.d.ts +0 -21
- package/dist/pkgs/migrations/get-schema/index.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/process-fields.d.ts +0 -15
- package/dist/pkgs/migrations/get-schema/process-fields.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/process-tables.d.ts +0 -13
- package/dist/pkgs/migrations/get-schema/process-tables.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/types.d.ts +0 -17
- package/dist/pkgs/migrations/get-schema/types.d.ts.map +0 -1
- package/dist/pkgs/migrations/index.cjs +0 -1352
- package/dist/pkgs/migrations/index.d.ts +0 -18
- package/dist/pkgs/migrations/index.d.ts.map +0 -1
- package/dist/pkgs/migrations/index.js +0 -1171
- package/dist/pkgs/migrations/migration-builders.d.ts +0 -28
- package/dist/pkgs/migrations/migration-builders.d.ts.map +0 -1
- package/dist/pkgs/migrations/migration-execution.d.ts +0 -12
- package/dist/pkgs/migrations/migration-execution.d.ts.map +0 -1
- package/dist/pkgs/migrations/schema-comparison.d.ts +0 -35
- package/dist/pkgs/migrations/schema-comparison.d.ts.map +0 -1
- package/dist/pkgs/migrations/type-mapping.d.ts +0 -75
- package/dist/pkgs/migrations/type-mapping.d.ts.map +0 -1
- package/dist/pkgs/migrations/types.d.ts +0 -36
- package/dist/pkgs/migrations/types.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/error-class.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/error-class.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/error-codes.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/error-codes.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/neverthrow-integration.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/neverthrow-integration.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/recovery-utils.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/recovery-utils.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/result-helpers.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/result-helpers.test.d.ts.map +0 -1
- package/dist/pkgs/results/core/error-class.d.ts +0 -128
- package/dist/pkgs/results/core/error-class.d.ts.map +0 -1
- package/dist/pkgs/results/core/error-codes.d.ts +0 -178
- package/dist/pkgs/results/core/error-codes.d.ts.map +0 -1
- package/dist/pkgs/results/core/tracing.d.ts +0 -11
- package/dist/pkgs/results/core/tracing.d.ts.map +0 -1
- package/dist/pkgs/results/create-telemetry-options.d.ts +0 -31
- package/dist/pkgs/results/create-telemetry-options.d.ts.map +0 -1
- package/dist/pkgs/results/index.cjs +0 -462
- package/dist/pkgs/results/index.d.ts +0 -80
- package/dist/pkgs/results/index.d.ts.map +0 -1
- package/dist/pkgs/results/index.js +0 -377
- package/dist/pkgs/results/orpc-error-handler.d.ts +0 -65
- package/dist/pkgs/results/orpc-error-handler.d.ts.map +0 -1
- package/dist/pkgs/results/results/recovery-utils.d.ts +0 -115
- package/dist/pkgs/results/results/recovery-utils.d.ts.map +0 -1
- package/dist/pkgs/results/results/result-helpers.d.ts +0 -214
- package/dist/pkgs/results/results/result-helpers.d.ts.map +0 -1
- package/dist/pkgs/results/types.d.ts +0 -200
- package/dist/pkgs/results/types.d.ts.map +0 -1
- package/dist/pkgs/types/context.d.ts +0 -160
- package/dist/pkgs/types/context.d.ts.map +0 -1
- package/dist/pkgs/types/endpoints.d.ts +0 -30
- package/dist/pkgs/types/endpoints.d.ts.map +0 -1
- package/dist/pkgs/types/helper.d.ts +0 -55
- package/dist/pkgs/types/helper.d.ts.map +0 -1
- package/dist/pkgs/types/index.cjs +0 -18
- package/dist/pkgs/types/index.d.ts +0 -11
- package/dist/pkgs/types/index.d.ts.map +0 -1
- package/dist/pkgs/types/options.d.ts +0 -228
- package/dist/pkgs/types/options.d.ts.map +0 -1
- package/dist/pkgs/types/plugins.d.ts +0 -171
- package/dist/pkgs/types/plugins.d.ts.map +0 -1
- package/dist/pkgs/utils/env.d.ts.map +0 -1
- package/dist/pkgs/utils/index.d.ts +0 -4
- package/dist/pkgs/utils/index.d.ts.map +0 -1
- package/dist/pkgs/utils/logger.d.ts.map +0 -1
- package/dist/pkgs/utils/url.d.ts +0 -28
- package/dist/pkgs/utils/url.d.ts.map +0 -1
- package/dist/schema/audit-log/index.d.ts +0 -4
- package/dist/schema/audit-log/index.d.ts.map +0 -1
- package/dist/schema/audit-log/registry.d.ts +0 -96
- package/dist/schema/audit-log/registry.d.ts.map +0 -1
- package/dist/schema/audit-log/schema.d.ts +0 -45
- package/dist/schema/audit-log/schema.d.ts.map +0 -1
- package/dist/schema/audit-log/table.d.ts +0 -153
- package/dist/schema/audit-log/table.d.ts.map +0 -1
- package/dist/schema/audit-log/types.d.ts +0 -29
- package/dist/schema/audit-log/types.d.ts.map +0 -1
- package/dist/schema/consent/index.d.ts +0 -4
- package/dist/schema/consent/index.d.ts.map +0 -1
- package/dist/schema/consent/registry.d.ts +0 -150
- package/dist/schema/consent/registry.d.ts.map +0 -1
- package/dist/schema/consent/schema.d.ts +0 -53
- package/dist/schema/consent/schema.d.ts.map +0 -1
- package/dist/schema/consent/table.d.ts +0 -183
- package/dist/schema/consent/table.d.ts.map +0 -1
- package/dist/schema/consent/types.d.ts +0 -37
- package/dist/schema/consent/types.d.ts.map +0 -1
- package/dist/schema/consent-policy/index.d.ts +0 -4
- package/dist/schema/consent-policy/index.d.ts.map +0 -1
- package/dist/schema/consent-policy/registry.d.ts +0 -200
- package/dist/schema/consent-policy/registry.d.ts.map +0 -1
- package/dist/schema/consent-policy/schema.d.ts +0 -65
- package/dist/schema/consent-policy/schema.d.ts.map +0 -1
- package/dist/schema/consent-policy/table.d.ts +0 -142
- package/dist/schema/consent-policy/table.d.ts.map +0 -1
- package/dist/schema/consent-policy/types.d.ts +0 -29
- package/dist/schema/consent-policy/types.d.ts.map +0 -1
- package/dist/schema/consent-purpose/index.d.ts +0 -4
- package/dist/schema/consent-purpose/index.d.ts.map +0 -1
- package/dist/schema/consent-purpose/registry.d.ts +0 -138
- package/dist/schema/consent-purpose/registry.d.ts.map +0 -1
- package/dist/schema/consent-purpose/schema.d.ts +0 -57
- package/dist/schema/consent-purpose/schema.d.ts.map +0 -1
- package/dist/schema/consent-purpose/table.d.ts +0 -139
- package/dist/schema/consent-purpose/table.d.ts.map +0 -1
- package/dist/schema/consent-purpose/types.d.ts +0 -16
- package/dist/schema/consent-purpose/types.d.ts.map +0 -1
- package/dist/schema/consent-record/index.d.ts +0 -3
- package/dist/schema/consent-record/index.d.ts.map +0 -1
- package/dist/schema/consent-record/schema.d.ts +0 -41
- package/dist/schema/consent-record/schema.d.ts.map +0 -1
- package/dist/schema/consent-record/table.d.ts +0 -107
- package/dist/schema/consent-record/table.d.ts.map +0 -1
- package/dist/schema/consent-record/types.d.ts +0 -21
- package/dist/schema/consent-record/types.d.ts.map +0 -1
- package/dist/schema/create-registry.d.ts +0 -218
- package/dist/schema/create-registry.d.ts.map +0 -1
- package/dist/schema/definition.d.ts +0 -586
- package/dist/schema/definition.d.ts.map +0 -1
- package/dist/schema/domain/index.d.ts +0 -4
- package/dist/schema/domain/index.d.ts.map +0 -1
- package/dist/schema/domain/registry.d.ts +0 -222
- package/dist/schema/domain/registry.d.ts.map +0 -1
- package/dist/schema/domain/schema.d.ts +0 -42
- package/dist/schema/domain/schema.d.ts.map +0 -1
- package/dist/schema/domain/table.d.ts +0 -122
- package/dist/schema/domain/table.d.ts.map +0 -1
- package/dist/schema/domain/types.d.ts +0 -27
- package/dist/schema/domain/types.d.ts.map +0 -1
- package/dist/schema/index.cjs +0 -1565
- package/dist/schema/index.d.ts +0 -70
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -1455
- package/dist/schema/schemas.d.ts +0 -98
- package/dist/schema/schemas.d.ts.map +0 -1
- package/dist/schema/subject/index.d.ts +0 -4
- package/dist/schema/subject/index.d.ts.map +0 -1
- package/dist/schema/subject/registry.d.ts +0 -110
- package/dist/schema/subject/registry.d.ts.map +0 -1
- package/dist/schema/subject/schema.d.ts +0 -40
- package/dist/schema/subject/schema.d.ts.map +0 -1
- package/dist/schema/subject/table.d.ts +0 -120
- package/dist/schema/subject/table.d.ts.map +0 -1
- package/dist/schema/subject/types.d.ts +0 -22
- package/dist/schema/subject/types.d.ts.map +0 -1
- package/dist/schema/types.d.ts +0 -108
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/server.d.ts +0 -2
- package/dist/server.d.ts.map +0 -1
- package/dist/testing/contract-testing.d.ts +0 -38
- package/dist/testing/contract-testing.d.ts.map +0 -1
- package/dist/types/context.d.ts +0 -12
- package/dist/types/context.d.ts.map +0 -1
- package/dist/types/options.d.ts +0 -91
- package/dist/types/options.d.ts.map +0 -1
- package/dist/types/plugins.d.ts +0 -126
- package/dist/types/plugins.d.ts.map +0 -1
- package/dist/v2/contracts/consent/identify.contract.d.ts +0 -24
- package/dist/v2/contracts/consent/identify.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/index.d.ts +0 -340
- package/dist/v2/contracts/consent/index.d.ts.map +0 -1
- package/dist/v2/contracts/consent/index.test.d.ts +0 -2
- package/dist/v2/contracts/consent/index.test.d.ts.map +0 -1
- package/dist/v2/contracts/consent/post.contract.d.ts +0 -117
- package/dist/v2/contracts/consent/post.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/post.contract.test.d.ts +0 -2
- package/dist/v2/contracts/consent/post.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/consent/show-banner.contract.d.ts +0 -123
- package/dist/v2/contracts/consent/show-banner.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/show-banner.contract.test.d.ts +0 -2
- package/dist/v2/contracts/consent/show-banner.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/consent/verify.contract.d.ts +0 -81
- package/dist/v2/contracts/consent/verify.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/verify.contract.test.d.ts +0 -2
- package/dist/v2/contracts/consent/verify.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/index.cjs +0 -716
- package/dist/v2/contracts/index.d.ts +0 -723
- package/dist/v2/contracts/index.d.ts.map +0 -1
- package/dist/v2/contracts/index.js +0 -679
- package/dist/v2/contracts/meta/index.d.ts +0 -19
- package/dist/v2/contracts/meta/index.d.ts.map +0 -1
- package/dist/v2/contracts/meta/index.test.d.ts +0 -2
- package/dist/v2/contracts/meta/index.test.d.ts.map +0 -1
- package/dist/v2/contracts/meta/status.contract.d.ts +0 -18
- package/dist/v2/contracts/meta/status.contract.d.ts.map +0 -1
- package/dist/v2/contracts/meta/status.contract.test.d.ts +0 -2
- package/dist/v2/contracts/meta/status.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/shared/jurisdiction.schema.d.ts +0 -36
- package/dist/v2/contracts/shared/jurisdiction.schema.d.ts.map +0 -1
- package/dist/v2/contracts/test.utils.d.ts +0 -38
- package/dist/v2/contracts/test.utils.d.ts.map +0 -1
- package/dist/v2/core.cjs +0 -2350
- package/dist/v2/core.d.ts +0 -444
- package/dist/v2/core.d.ts.map +0 -1
- package/dist/v2/core.js +0 -2300
- package/dist/v2/db/adapters/drizzle.cjs +0 -36
- package/dist/v2/db/adapters/drizzle.d.ts.map +0 -1
- package/dist/v2/db/adapters/index.cjs +0 -18
- package/dist/v2/db/adapters/index.d.ts.map +0 -1
- package/dist/v2/db/adapters/index.js +0 -0
- package/dist/v2/db/adapters/kysely.cjs +0 -36
- package/dist/v2/db/adapters/kysely.d.ts.map +0 -1
- package/dist/v2/db/adapters/mongo.cjs +0 -36
- package/dist/v2/db/adapters/mongo.d.ts.map +0 -1
- package/dist/v2/db/adapters/prisma.cjs +0 -36
- package/dist/v2/db/adapters/prisma.d.ts.map +0 -1
- package/dist/v2/db/adapters/typeorm.cjs +0 -36
- package/dist/v2/db/adapters/typeorm.d.ts.map +0 -1
- package/dist/v2/db/migrator/index.cjs +0 -61
- package/dist/v2/db/migrator/index.d.ts.map +0 -1
- package/dist/v2/db/registry/audit-log.d.ts +0 -21
- package/dist/v2/db/registry/audit-log.d.ts.map +0 -1
- package/dist/v2/db/registry/audit-log.test.d.ts +0 -2
- package/dist/v2/db/registry/audit-log.test.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-policy.d.ts +0 -29
- package/dist/v2/db/registry/consent-policy.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-policy.test.d.ts +0 -2
- package/dist/v2/db/registry/consent-policy.test.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-purpose.d.ts +0 -16
- package/dist/v2/db/registry/consent-purpose.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-purpose.test.d.ts +0 -2
- package/dist/v2/db/registry/consent-purpose.test.d.ts.map +0 -1
- package/dist/v2/db/registry/consent.d.ts +0 -20
- package/dist/v2/db/registry/consent.d.ts.map +0 -1
- package/dist/v2/db/registry/consent.test.d.ts +0 -2
- package/dist/v2/db/registry/consent.test.d.ts.map +0 -1
- package/dist/v2/db/registry/domain.d.ts +0 -24
- package/dist/v2/db/registry/domain.d.ts.map +0 -1
- package/dist/v2/db/registry/domain.test.d.ts +0 -2
- package/dist/v2/db/registry/domain.test.d.ts.map +0 -1
- package/dist/v2/db/registry/index.d.ts +0 -103
- package/dist/v2/db/registry/index.d.ts.map +0 -1
- package/dist/v2/db/registry/subject.d.ts +0 -19
- package/dist/v2/db/registry/subject.d.ts.map +0 -1
- package/dist/v2/db/registry/subject.test.d.ts +0 -2
- package/dist/v2/db/registry/subject.test.d.ts.map +0 -1
- package/dist/v2/db/registry/types.d.ts +0 -10
- package/dist/v2/db/registry/types.d.ts.map +0 -1
- package/dist/v2/db/registry/utils/generate-id.d.ts +0 -25
- package/dist/v2/db/registry/utils/generate-id.d.ts.map +0 -1
- package/dist/v2/db/registry/utils/generate-id.test.d.ts +0 -2
- package/dist/v2/db/registry/utils/generate-id.test.d.ts.map +0 -1
- package/dist/v2/db/registry/utils.d.ts +0 -25
- package/dist/v2/db/registry/utils.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/audit-log.d.ts +0 -29
- package/dist/v2/db/schema/1.0.0/audit-log.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent-policy.d.ts +0 -45
- package/dist/v2/db/schema/1.0.0/consent-policy.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent-purpose.d.ts +0 -27
- package/dist/v2/db/schema/1.0.0/consent-purpose.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent-record.d.ts +0 -19
- package/dist/v2/db/schema/1.0.0/consent-record.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent.d.ts +0 -42
- package/dist/v2/db/schema/1.0.0/consent.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/domain.d.ts +0 -23
- package/dist/v2/db/schema/1.0.0/domain.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/index.d.ts +0 -1513
- package/dist/v2/db/schema/1.0.0/index.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/subject.d.ts +0 -23
- package/dist/v2/db/schema/1.0.0/subject.d.ts.map +0 -1
- package/dist/v2/db/schema/index.cjs +0 -326
- package/dist/v2/db/schema/index.d.ts +0 -1507
- package/dist/v2/db/schema/index.d.ts.map +0 -1
- package/dist/v2/db/schema/index.js +0 -241
- package/dist/v2/define-config.cjs +0 -36
- package/dist/v2/define-config.d.ts.map +0 -1
- package/dist/v2/handlers/consent/identify.handler.d.ts +0 -23
- package/dist/v2/handlers/consent/identify.handler.d.ts.map +0 -1
- package/dist/v2/handlers/consent/identify.handler.test.d.ts +0 -2
- package/dist/v2/handlers/consent/identify.handler.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/index.d.ts +0 -340
- package/dist/v2/handlers/consent/index.d.ts.map +0 -1
- package/dist/v2/handlers/consent/post.handler.d.ts +0 -139
- package/dist/v2/handlers/consent/post.handler.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/geo.d.ts +0 -10
- package/dist/v2/handlers/consent/show-banner/geo.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/geo.test.d.ts +0 -2
- package/dist/v2/handlers/consent/show-banner/geo.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/handler.d.ts +0 -126
- package/dist/v2/handlers/consent/show-banner/handler.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/handler.test.d.ts +0 -2
- package/dist/v2/handlers/consent/show-banner/handler.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/translations.d.ts +0 -13
- package/dist/v2/handlers/consent/show-banner/translations.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/translations.test.d.ts +0 -2
- package/dist/v2/handlers/consent/show-banner/translations.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/verify.handler.d.ts +0 -103
- package/dist/v2/handlers/consent/verify.handler.d.ts.map +0 -1
- package/dist/v2/handlers/meta/index.d.ts +0 -19
- package/dist/v2/handlers/meta/index.d.ts.map +0 -1
- package/dist/v2/handlers/meta/status.handler.d.ts +0 -17
- package/dist/v2/handlers/meta/status.handler.d.ts.map +0 -1
- package/dist/v2/init.d.ts +0 -3
- package/dist/v2/init.d.ts.map +0 -1
- package/dist/v2/init.test.d.ts +0 -2
- package/dist/v2/init.test.d.ts.map +0 -1
- package/dist/v2/middleware/cors/cors.d.ts +0 -37
- package/dist/v2/middleware/cors/cors.d.ts.map +0 -1
- package/dist/v2/middleware/cors/cors.test.d.ts +0 -2
- package/dist/v2/middleware/cors/cors.test.d.ts.map +0 -1
- package/dist/v2/middleware/cors/index.d.ts +0 -30
- package/dist/v2/middleware/cors/index.d.ts.map +0 -1
- package/dist/v2/middleware/cors/is-origin-trusted.d.ts +0 -49
- package/dist/v2/middleware/cors/is-origin-trusted.d.ts.map +0 -1
- package/dist/v2/middleware/cors/is-origin-trusted.test.d.ts +0 -2
- package/dist/v2/middleware/cors/is-origin-trusted.test.d.ts.map +0 -1
- package/dist/v2/middleware/cors/process-cors.d.ts +0 -31
- package/dist/v2/middleware/cors/process-cors.d.ts.map +0 -1
- package/dist/v2/middleware/openapi/config.d.ts +0 -28
- package/dist/v2/middleware/openapi/config.d.ts.map +0 -1
- package/dist/v2/middleware/openapi/handlers.d.ts +0 -29
- package/dist/v2/middleware/openapi/handlers.d.ts.map +0 -1
- package/dist/v2/middleware/openapi/index.d.ts +0 -11
- package/dist/v2/middleware/openapi/index.d.ts.map +0 -1
- package/dist/v2/middleware/process-ip/index.d.ts +0 -3
- package/dist/v2/middleware/process-ip/index.d.ts.map +0 -1
- package/dist/v2/router.cjs +0 -1442
- package/dist/v2/router.d.ts +0 -360
- package/dist/v2/router.d.ts.map +0 -1
- package/dist/v2/router.js +0 -1398
- package/dist/v2/types/api.d.ts +0 -27
- package/dist/v2/types/api.d.ts.map +0 -1
- package/dist/v2/types/index.cjs +0 -40
- package/dist/v2/types/index.d.ts +0 -104
- package/dist/v2/types/index.d.ts.map +0 -1
- package/dist/v2/types/index.js +0 -6
- package/dist/v2/utils/create-telemetry-options.d.ts +0 -28
- package/dist/v2/utils/create-telemetry-options.d.ts.map +0 -1
- package/dist/v2/utils/env.d.ts +0 -60
- package/dist/v2/utils/env.d.ts.map +0 -1
- package/dist/v2/utils/index.d.ts +0 -3
- package/dist/v2/utils/index.d.ts.map +0 -1
- package/dist/v2/utils/logger.d.ts +0 -16
- package/dist/v2/utils/logger.d.ts.map +0 -1
- package/src/__tests__/server.test.ts +0 -100
- package/src/contracts/consent/identify.contract.ts +0 -38
- package/src/contracts/consent/index.test.ts +0 -5
- package/src/contracts/consent/index.ts +0 -11
- package/src/contracts/consent/post.contract.test.ts +0 -521
- package/src/contracts/consent/post.contract.ts +0 -156
- package/src/contracts/consent/show-banner.contract.test.ts +0 -260
- package/src/contracts/consent/show-banner.contract.ts +0 -136
- package/src/contracts/consent/verify.contract.test.ts +0 -185
- package/src/contracts/consent/verify.contract.ts +0 -122
- package/src/contracts/index.ts +0 -20
- package/src/contracts/meta/index.test.ts +0 -5
- package/src/contracts/meta/index.ts +0 -5
- package/src/contracts/meta/status.contract.test.ts +0 -338
- package/src/contracts/meta/status.contract.ts +0 -37
- package/src/contracts/shared/jurisdiction.schema.ts +0 -30
- package/src/handlers/consent/identify.handler.test.ts +0 -473
- package/src/handlers/consent/identify.handler.ts +0 -176
- package/src/handlers/consent/post.handler.ts +0 -277
- package/src/handlers/consent/show-banner/geo.test.ts +0 -281
- package/src/handlers/consent/show-banner/geo.ts +0 -96
- package/src/handlers/consent/show-banner/handler.test.ts +0 -376
- package/src/handlers/consent/show-banner/handler.ts +0 -123
- package/src/handlers/consent/show-banner/translations.test.ts +0 -121
- package/src/handlers/consent/show-banner/translations.ts +0 -79
- package/src/handlers/consent/verify.handler.ts +0 -305
- package/src/handlers/meta/index.ts +0 -5
- package/src/handlers/meta/status.handler.ts +0 -47
- package/src/pkgs/api-router/hooks/__tests__/processor.test.ts +0 -290
- package/src/pkgs/api-router/hooks/processor.ts +0 -153
- package/src/pkgs/api-router/telemetry.ts +0 -83
- package/src/pkgs/api-router/types/router-props.ts +0 -36
- package/src/pkgs/api-router/utils/ip.ts +0 -92
- package/src/pkgs/data-model/fields/field-factory.ts +0 -208
- package/src/pkgs/data-model/fields/field-inference.ts +0 -93
- package/src/pkgs/data-model/fields/field-types.ts +0 -233
- package/src/pkgs/data-model/fields/id-generator.ts +0 -57
- package/src/pkgs/data-model/fields/index.ts +0 -37
- package/src/pkgs/data-model/fields/superjson-utils.ts +0 -17
- package/src/pkgs/data-model/fields/zod-fields.ts +0 -125
- package/src/pkgs/data-model/hooks/create-hooks.ts +0 -88
- package/src/pkgs/data-model/hooks/index.ts +0 -40
- package/src/pkgs/data-model/hooks/types.ts +0 -165
- package/src/pkgs/data-model/hooks/update-hooks.ts +0 -91
- package/src/pkgs/data-model/hooks/update-many-hooks.ts +0 -176
- package/src/pkgs/data-model/hooks/utils.ts +0 -151
- package/src/pkgs/data-model/hooks/with-hooks-factory.ts +0 -68
- package/src/pkgs/data-model/index.ts +0 -13
- package/src/pkgs/data-model/schema/index.ts +0 -19
- package/src/pkgs/data-model/schema/schemas.ts +0 -15
- package/src/pkgs/data-model/schema/types.ts +0 -105
- package/src/pkgs/db-adapters/README.md +0 -95
- package/src/pkgs/db-adapters/adapter-factory.ts +0 -68
- package/src/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.ts +0 -709
- package/src/pkgs/db-adapters/adapters/drizzle-adapter/index.ts +0 -1
- package/src/pkgs/db-adapters/adapters/index.ts +0 -10
- package/src/pkgs/db-adapters/adapters/kysely-adapter/dialect.ts +0 -195
- package/src/pkgs/db-adapters/adapters/kysely-adapter/index.ts +0 -10
- package/src/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.ts +0 -1182
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.ts +0 -214
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.ts +0 -227
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.ts +0 -439
- package/src/pkgs/db-adapters/adapters/kysely-adapter/types.ts +0 -304
- package/src/pkgs/db-adapters/adapters/memory-adapter/index.ts +0 -1
- package/src/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.ts +0 -665
- package/src/pkgs/db-adapters/adapters/prisma-adapter/index.ts +0 -1
- package/src/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.ts +0 -586
- package/src/pkgs/db-adapters/adapters/test.ts +0 -77
- package/src/pkgs/db-adapters/index.ts +0 -28
- package/src/pkgs/db-adapters/types.ts +0 -211
- package/src/pkgs/db-adapters/utils.ts +0 -51
- package/src/pkgs/migrations/README.md +0 -73
- package/src/pkgs/migrations/get-migration.ts +0 -88
- package/src/pkgs/migrations/get-schema/get-schema.ts +0 -43
- package/src/pkgs/migrations/get-schema/index.ts +0 -20
- package/src/pkgs/migrations/get-schema/process-fields.ts +0 -65
- package/src/pkgs/migrations/get-schema/process-tables.ts +0 -66
- package/src/pkgs/migrations/get-schema/types.ts +0 -18
- package/src/pkgs/migrations/index.ts +0 -30
- package/src/pkgs/migrations/migration-builders.ts +0 -170
- package/src/pkgs/migrations/migration-execution.ts +0 -72
- package/src/pkgs/migrations/schema-comparison.ts +0 -203
- package/src/pkgs/migrations/type-mapping.ts +0 -244
- package/src/pkgs/migrations/types.ts +0 -48
- package/src/pkgs/results/README.md +0 -345
- package/src/pkgs/results/__tests__/error-class.test.ts +0 -183
- package/src/pkgs/results/__tests__/error-codes.test.ts +0 -81
- package/src/pkgs/results/__tests__/neverthrow-integration.test.ts +0 -92
- package/src/pkgs/results/__tests__/recovery-utils.test.ts +0 -140
- package/src/pkgs/results/__tests__/result-helpers.test.ts +0 -206
- package/src/pkgs/results/core/error-class.ts +0 -297
- package/src/pkgs/results/core/error-codes.ts +0 -206
- package/src/pkgs/results/core/tracing.ts +0 -65
- package/src/pkgs/results/create-telemetry-options.ts +0 -62
- package/src/pkgs/results/index.ts +0 -115
- package/src/pkgs/results/orpc-error-handler.ts +0 -137
- package/src/pkgs/results/results/recovery-utils.ts +0 -181
- package/src/pkgs/results/results/result-helpers.ts +0 -383
- package/src/pkgs/results/types.ts +0 -217
- package/src/pkgs/types/context.ts +0 -178
- package/src/pkgs/types/endpoints.ts +0 -35
- package/src/pkgs/types/helper.ts +0 -57
- package/src/pkgs/types/index.ts +0 -18
- package/src/pkgs/types/options.ts +0 -252
- package/src/pkgs/types/plugins.ts +0 -191
- package/src/pkgs/utils/index.ts +0 -3
- package/src/pkgs/utils/logger.ts +0 -35
- package/src/pkgs/utils/url.ts +0 -105
- package/src/schema/audit-log/index.ts +0 -3
- package/src/schema/audit-log/registry.ts +0 -117
- package/src/schema/audit-log/schema.ts +0 -46
- package/src/schema/audit-log/table.ts +0 -185
- package/src/schema/audit-log/types.ts +0 -29
- package/src/schema/consent/index.ts +0 -3
- package/src/schema/consent/registry.ts +0 -177
- package/src/schema/consent/schema.ts +0 -51
- package/src/schema/consent/table.ts +0 -221
- package/src/schema/consent/types.ts +0 -39
- package/src/schema/consent-policy/index.ts +0 -3
- package/src/schema/consent-policy/registry.ts +0 -352
- package/src/schema/consent-policy/schema.ts +0 -60
- package/src/schema/consent-policy/table.ts +0 -150
- package/src/schema/consent-policy/types.ts +0 -29
- package/src/schema/consent-purpose/index.ts +0 -3
- package/src/schema/consent-purpose/registry.ts +0 -168
- package/src/schema/consent-purpose/schema.ts +0 -58
- package/src/schema/consent-purpose/table.ts +0 -154
- package/src/schema/consent-purpose/types.ts +0 -16
- package/src/schema/consent-record/index.ts +0 -2
- package/src/schema/consent-record/schema.ts +0 -42
- package/src/schema/consent-record/table.ts +0 -124
- package/src/schema/consent-record/types.ts +0 -21
- package/src/schema/create-registry.ts +0 -21
- package/src/schema/definition.ts +0 -200
- package/src/schema/domain/index.ts +0 -3
- package/src/schema/domain/registry.ts +0 -296
- package/src/schema/domain/schema.ts +0 -43
- package/src/schema/domain/table.ts +0 -137
- package/src/schema/domain/types.ts +0 -27
- package/src/schema/index.ts +0 -74
- package/src/schema/schemas.ts +0 -27
- package/src/schema/subject/index.ts +0 -3
- package/src/schema/subject/registry.ts +0 -298
- package/src/schema/subject/schema.ts +0 -41
- package/src/schema/subject/table.ts +0 -138
- package/src/schema/subject/types.ts +0 -22
- package/src/schema/types.ts +0 -121
- package/src/server.ts +0 -126
- package/src/testing/contract-testing.ts +0 -400
- package/src/types/context.ts +0 -16
- package/src/types/options.ts +0 -103
- package/src/types/plugins.ts +0 -154
- package/src/v2/contracts/consent/identify.contract.ts +0 -38
- package/src/v2/contracts/consent/index.test.ts +0 -5
- package/src/v2/contracts/consent/index.ts +0 -11
- package/src/v2/contracts/consent/post.contract.test.ts +0 -521
- package/src/v2/contracts/consent/post.contract.ts +0 -156
- package/src/v2/contracts/consent/show-banner.contract.test.ts +0 -252
- package/src/v2/contracts/consent/show-banner.contract.ts +0 -136
- package/src/v2/contracts/consent/verify.contract.test.ts +0 -185
- package/src/v2/contracts/consent/verify.contract.ts +0 -122
- package/src/v2/contracts/index.ts +0 -20
- package/src/v2/contracts/meta/index.test.ts +0 -5
- package/src/v2/contracts/meta/index.ts +0 -5
- package/src/v2/contracts/meta/status.contract.test.ts +0 -226
- package/src/v2/contracts/meta/status.contract.ts +0 -34
- package/src/v2/contracts/shared/jurisdiction.schema.ts +0 -30
- package/src/v2/contracts/test.utils.ts +0 -400
- package/src/v2/core.ts +0 -379
- package/src/v2/db/migrator/index.ts +0 -80
- package/src/v2/db/registry/audit-log.test.ts +0 -77
- package/src/v2/db/registry/audit-log.ts +0 -46
- package/src/v2/db/registry/consent-policy.test.ts +0 -778
- package/src/v2/db/registry/consent-policy.ts +0 -74
- package/src/v2/db/registry/consent-purpose.test.ts +0 -485
- package/src/v2/db/registry/consent-purpose.ts +0 -41
- package/src/v2/db/registry/consent.test.ts +0 -843
- package/src/v2/db/registry/consent.ts +0 -42
- package/src/v2/db/registry/domain.test.ts +0 -463
- package/src/v2/db/registry/domain.ts +0 -51
- package/src/v2/db/registry/index.ts +0 -18
- package/src/v2/db/registry/subject.test.ts +0 -497
- package/src/v2/db/registry/subject.ts +0 -103
- package/src/v2/db/registry/types.ts +0 -10
- package/src/v2/db/registry/utils/generate-id.test.ts +0 -217
- package/src/v2/db/registry/utils/generate-id.ts +0 -134
- package/src/v2/db/registry/utils.ts +0 -134
- package/src/v2/db/schema/1.0.0/audit-log.ts +0 -32
- package/src/v2/db/schema/1.0.0/consent-policy.ts +0 -41
- package/src/v2/db/schema/1.0.0/consent-purpose.ts +0 -30
- package/src/v2/db/schema/1.0.0/consent-record.ts +0 -22
- package/src/v2/db/schema/1.0.0/consent.ts +0 -38
- package/src/v2/db/schema/1.0.0/domain.ts +0 -26
- package/src/v2/db/schema/1.0.0/index.ts +0 -56
- package/src/v2/db/schema/1.0.0/subject.ts +0 -26
- package/src/v2/db/schema/index.ts +0 -9
- package/src/v2/handlers/consent/identify.handler.test.ts +0 -453
- package/src/v2/handlers/consent/identify.handler.ts +0 -125
- package/src/v2/handlers/consent/index.ts +0 -11
- package/src/v2/handlers/consent/post.handler.ts +0 -258
- package/src/v2/handlers/consent/show-banner/geo.test.ts +0 -281
- package/src/v2/handlers/consent/show-banner/geo.ts +0 -96
- package/src/v2/handlers/consent/show-banner/handler.test.ts +0 -374
- package/src/v2/handlers/consent/show-banner/handler.ts +0 -123
- package/src/v2/handlers/consent/show-banner/translations.test.ts +0 -121
- package/src/v2/handlers/consent/show-banner/translations.ts +0 -79
- package/src/v2/handlers/consent/verify.handler.ts +0 -288
- package/src/v2/handlers/meta/index.ts +0 -5
- package/src/v2/handlers/meta/status.handler.ts +0 -43
- package/src/v2/init.test.ts +0 -120
- package/src/v2/init.ts +0 -126
- package/src/v2/middleware/cors/cors.test.ts +0 -114
- package/src/v2/middleware/cors/cors.ts +0 -195
- package/src/v2/middleware/cors/index.ts +0 -30
- package/src/v2/middleware/cors/is-origin-trusted.test.ts +0 -164
- package/src/v2/middleware/cors/is-origin-trusted.ts +0 -129
- package/src/v2/middleware/cors/process-cors.ts +0 -91
- package/src/v2/middleware/openapi/config.ts +0 -27
- package/src/v2/middleware/openapi/handlers.ts +0 -132
- package/src/v2/middleware/openapi/index.ts +0 -11
- package/src/v2/middleware/process-ip/index.ts +0 -39
- package/src/v2/router.ts +0 -8
- package/src/v2/types/api.ts +0 -32
- package/src/v2/types/index.ts +0 -121
- package/src/v2/utils/create-telemetry-options.ts +0 -115
- package/src/v2/utils/env.ts +0 -84
- package/src/v2/utils/index.ts +0 -2
- package/src/v2/utils/logger.ts +0 -35
- /package/dist/{v2/db → db}/adapters/drizzle.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/drizzle.js +0 -0
- /package/dist/{v2/db → db}/adapters/index.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/kysely.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/kysely.js +0 -0
- /package/dist/{v2/db → db}/adapters/mongo.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/mongo.js +0 -0
- /package/dist/{v2/db → db}/adapters/prisma.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/prisma.js +0 -0
- /package/dist/{v2/db → db}/adapters/typeorm.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/typeorm.js +0 -0
- /package/dist/{pkgs/types/index.js → db/adapters.js} +0 -0
- /package/dist/{v2/db → db}/migrator/index.d.ts +0 -0
- /package/dist/{v2/db/migrator/index.js → db/migrator.js} +0 -0
- /package/dist/{v2/define-config.d.ts → define-config.d.ts} +0 -0
- /package/dist/{v2/define-config.js → define-config.js} +0 -0
- /package/dist/{pkgs/utils → utils}/env.d.ts +0 -0
- /package/dist/{pkgs/utils → utils}/logger.d.ts +0 -0
- /package/src/{v2/db → db}/adapters/drizzle.ts +0 -0
- /package/src/{v2/db → db}/adapters/index.ts +0 -0
- /package/src/{v2/db → db}/adapters/kysely.ts +0 -0
- /package/src/{v2/db → db}/adapters/mongo.ts +0 -0
- /package/src/{v2/db → db}/adapters/prisma.ts +0 -0
- /package/src/{v2/db → db}/adapters/typeorm.ts +0 -0
- /package/src/{v2/define-config.ts → define-config.ts} +0 -0
- /package/src/{pkgs/utils → utils}/env.ts +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { C15TOptions } from '~/types';
|
|
2
|
+
import type { JurisdictionCode } from '~/types/api';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes a header value to a string or null.
|
|
6
|
+
*/
|
|
7
|
+
function normalizeHeader(
|
|
8
|
+
value: string | string[] | null | undefined
|
|
9
|
+
): string | null {
|
|
10
|
+
if (!value) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return Array.isArray(value) ? (value[0] ?? null) : value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Gets geo-related headers from the request.
|
|
18
|
+
*/
|
|
19
|
+
function getGeoHeaders(headers: Headers) {
|
|
20
|
+
const countryCode =
|
|
21
|
+
normalizeHeader(headers.get('x-c15t-country')) ??
|
|
22
|
+
normalizeHeader(headers.get('cf-ipcountry')) ??
|
|
23
|
+
normalizeHeader(headers.get('x-vercel-ip-country')) ??
|
|
24
|
+
normalizeHeader(headers.get('x-amz-cf-ipcountry')) ??
|
|
25
|
+
normalizeHeader(headers.get('x-country-code'));
|
|
26
|
+
|
|
27
|
+
const regionCode =
|
|
28
|
+
normalizeHeader(headers.get('x-c15t-region')) ??
|
|
29
|
+
normalizeHeader(headers.get('x-vercel-ip-country-region')) ??
|
|
30
|
+
normalizeHeader(headers.get('x-region-code'));
|
|
31
|
+
|
|
32
|
+
return { countryCode, regionCode };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Determines the applicable jurisdiction based on country and region codes.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* - EU/EEA/UK map to GDPR-style regimes.
|
|
40
|
+
* - Specific countries map to their local laws (CH, BR, CA, AU, JP, KR).
|
|
41
|
+
* - CCPA is applied for certain US regions (e.g. California).
|
|
42
|
+
*/
|
|
43
|
+
export function checkJurisdiction(
|
|
44
|
+
countryCode: string | null,
|
|
45
|
+
regionCode?: string | null
|
|
46
|
+
): JurisdictionCode {
|
|
47
|
+
// Country/region sets for different jurisdictions
|
|
48
|
+
const jurisdictions = {
|
|
49
|
+
EU: new Set([
|
|
50
|
+
'AT',
|
|
51
|
+
'BE',
|
|
52
|
+
'BG',
|
|
53
|
+
'HR',
|
|
54
|
+
'CY',
|
|
55
|
+
'CZ',
|
|
56
|
+
'DK',
|
|
57
|
+
'EE',
|
|
58
|
+
'FI',
|
|
59
|
+
'FR',
|
|
60
|
+
'DE',
|
|
61
|
+
'GR',
|
|
62
|
+
'HU',
|
|
63
|
+
'IE',
|
|
64
|
+
'IT',
|
|
65
|
+
'LV',
|
|
66
|
+
'LT',
|
|
67
|
+
'LU',
|
|
68
|
+
'MT',
|
|
69
|
+
'NL',
|
|
70
|
+
'PL',
|
|
71
|
+
'PT',
|
|
72
|
+
'RO',
|
|
73
|
+
'SK',
|
|
74
|
+
'SI',
|
|
75
|
+
'ES',
|
|
76
|
+
'SE',
|
|
77
|
+
]),
|
|
78
|
+
EEA: new Set(['IS', 'NO', 'LI']),
|
|
79
|
+
UK: new Set(['GB']),
|
|
80
|
+
CH: new Set(['CH']),
|
|
81
|
+
BR: new Set(['BR']),
|
|
82
|
+
CA: new Set(['CA']),
|
|
83
|
+
AU: new Set(['AU']),
|
|
84
|
+
JP: new Set(['JP']),
|
|
85
|
+
KR: new Set(['KR']),
|
|
86
|
+
US_CCPA_REGIONS: new Set([
|
|
87
|
+
// California (CCPA/CPRA)
|
|
88
|
+
'CA',
|
|
89
|
+
]),
|
|
90
|
+
CA_QC_REGIONS: new Set([
|
|
91
|
+
// Quebec (Law 25)
|
|
92
|
+
'QC',
|
|
93
|
+
]),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Default to no jurisdiction
|
|
97
|
+
let jurisdiction: JurisdictionCode = 'NONE';
|
|
98
|
+
|
|
99
|
+
// Check country/region codes against jurisdiction sets
|
|
100
|
+
if (countryCode) {
|
|
101
|
+
// Normalize for case-insensitive comparison
|
|
102
|
+
const normalizedCountryCode = countryCode.toUpperCase();
|
|
103
|
+
// Normalize region code: handle dash-separated formats like "CA-QC" or "US-CA"
|
|
104
|
+
// by extracting the last segment as the subdivision code
|
|
105
|
+
const normalizedRegionCode =
|
|
106
|
+
regionCode && typeof regionCode === 'string'
|
|
107
|
+
? (regionCode.includes('-')
|
|
108
|
+
? regionCode.split('-').pop()!
|
|
109
|
+
: regionCode
|
|
110
|
+
).toUpperCase()
|
|
111
|
+
: null;
|
|
112
|
+
|
|
113
|
+
// CCPA-style rules: currently applied for certain US regions only
|
|
114
|
+
if (
|
|
115
|
+
normalizedCountryCode === 'US' &&
|
|
116
|
+
normalizedRegionCode &&
|
|
117
|
+
jurisdictions.US_CCPA_REGIONS.has(normalizedRegionCode)
|
|
118
|
+
) {
|
|
119
|
+
return 'CCPA';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Quebec (Law 25): opt-in consent required
|
|
123
|
+
if (
|
|
124
|
+
normalizedCountryCode === 'CA' &&
|
|
125
|
+
normalizedRegionCode &&
|
|
126
|
+
jurisdictions.CA_QC_REGIONS.has(normalizedRegionCode)
|
|
127
|
+
) {
|
|
128
|
+
return 'QC_LAW25';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const jurisdictionMap = [
|
|
132
|
+
{
|
|
133
|
+
sets: [jurisdictions.UK],
|
|
134
|
+
code: 'UK_GDPR' as const,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
sets: [jurisdictions.EU, jurisdictions.EEA],
|
|
138
|
+
code: 'GDPR' as const,
|
|
139
|
+
},
|
|
140
|
+
{ sets: [jurisdictions.CH], code: 'CH' as const },
|
|
141
|
+
{ sets: [jurisdictions.BR], code: 'BR' as const },
|
|
142
|
+
{ sets: [jurisdictions.CA], code: 'PIPEDA' as const },
|
|
143
|
+
{ sets: [jurisdictions.AU], code: 'AU' as const },
|
|
144
|
+
{ sets: [jurisdictions.JP], code: 'APPI' as const },
|
|
145
|
+
{ sets: [jurisdictions.KR], code: 'PIPA' as const },
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
// Find matching jurisdiction
|
|
149
|
+
for (const { sets, code } of jurisdictionMap) {
|
|
150
|
+
if (sets.some((set) => set.has(normalizedCountryCode))) {
|
|
151
|
+
jurisdiction = code;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return jurisdiction;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Gets the location from the request headers.
|
|
162
|
+
*
|
|
163
|
+
* @param request - The incoming request
|
|
164
|
+
* @param options - The C15T options
|
|
165
|
+
* @returns The location object with countryCode and regionCode
|
|
166
|
+
*/
|
|
167
|
+
export async function getLocation(
|
|
168
|
+
request: Request,
|
|
169
|
+
options: C15TOptions
|
|
170
|
+
): Promise<{ countryCode: string | null; regionCode: string | null }> {
|
|
171
|
+
if (options.advanced?.disableGeoLocation) {
|
|
172
|
+
return { countryCode: null, regionCode: null };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const { countryCode, regionCode } = getGeoHeaders(request.headers);
|
|
176
|
+
return { countryCode, regionCode };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Gets the jurisdiction based on location and options.
|
|
181
|
+
*
|
|
182
|
+
* @param location - The location object
|
|
183
|
+
* @param options - The C15T options
|
|
184
|
+
* @returns The jurisdiction code
|
|
185
|
+
*/
|
|
186
|
+
export function getJurisdiction(
|
|
187
|
+
location: { countryCode: string | null; regionCode: string | null },
|
|
188
|
+
options: C15TOptions
|
|
189
|
+
): JurisdictionCode {
|
|
190
|
+
if (options.advanced?.disableGeoLocation) {
|
|
191
|
+
return 'GDPR';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return checkJurisdiction(location.countryCode, location.regionCode);
|
|
195
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { baseTranslations } from '@c15t/translations';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import type { C15TOptions } from '~/types';
|
|
4
|
+
import { checkJurisdiction, getJurisdiction, getLocation } from './geo';
|
|
5
|
+
import {
|
|
6
|
+
buildResponse,
|
|
7
|
+
getHeaders,
|
|
8
|
+
getTranslationsData,
|
|
9
|
+
parseAcceptLanguage,
|
|
10
|
+
} from './index';
|
|
11
|
+
|
|
12
|
+
describe('Init Handler Utilities', () => {
|
|
13
|
+
describe('getHeaders', () => {
|
|
14
|
+
it('extracts country code from cf-ipcountry header', () => {
|
|
15
|
+
const headers = new Headers({ 'cf-ipcountry': 'DE' });
|
|
16
|
+
const result = getHeaders(headers);
|
|
17
|
+
expect(result.countryCode).toBe('DE');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('falls back to alternative country code headers', () => {
|
|
21
|
+
const headers = new Headers({ 'x-vercel-ip-country': 'FR' });
|
|
22
|
+
const result = getHeaders(headers);
|
|
23
|
+
expect(result.countryCode).toBe('FR');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('prioritizes cf-ipcountry over other headers', () => {
|
|
27
|
+
const headers = new Headers({
|
|
28
|
+
'cf-ipcountry': 'DE',
|
|
29
|
+
'x-vercel-ip-country': 'FR',
|
|
30
|
+
});
|
|
31
|
+
const result = getHeaders(headers);
|
|
32
|
+
expect(result.countryCode).toBe('DE');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('extracts region code from headers', () => {
|
|
36
|
+
const headers = new Headers({
|
|
37
|
+
'cf-ipcountry': 'US',
|
|
38
|
+
'x-vercel-ip-country-region': 'CA',
|
|
39
|
+
});
|
|
40
|
+
const result = getHeaders(headers);
|
|
41
|
+
expect(result.countryCode).toBe('US');
|
|
42
|
+
expect(result.regionCode).toBe('CA');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('handles missing headers gracefully', () => {
|
|
46
|
+
const headers = new Headers({});
|
|
47
|
+
const result = getHeaders(headers);
|
|
48
|
+
expect(result.countryCode).toBeNull();
|
|
49
|
+
expect(result.regionCode).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('handles undefined headers', () => {
|
|
53
|
+
const result = getHeaders(undefined);
|
|
54
|
+
expect(result.countryCode).toBeNull();
|
|
55
|
+
expect(result.regionCode).toBeNull();
|
|
56
|
+
expect(result.acceptLanguage).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('checkJurisdiction', () => {
|
|
61
|
+
it('returns GDPR for EU countries', () => {
|
|
62
|
+
expect(checkJurisdiction('DE', null)).toBe('GDPR');
|
|
63
|
+
expect(checkJurisdiction('FR', null)).toBe('GDPR');
|
|
64
|
+
expect(checkJurisdiction('IT', null)).toBe('GDPR');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('returns UK_GDPR for UK', () => {
|
|
68
|
+
expect(checkJurisdiction('GB', null)).toBe('UK_GDPR');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('returns CCPA for California', () => {
|
|
72
|
+
expect(checkJurisdiction('US', 'CA')).toBe('CCPA');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('returns NONE for non-regulated regions', () => {
|
|
76
|
+
expect(checkJurisdiction('US', null)).toBe('NONE');
|
|
77
|
+
expect(checkJurisdiction('US', 'TX')).toBe('NONE');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('returns PIPEDA for Canada', () => {
|
|
81
|
+
expect(checkJurisdiction('CA', null)).toBe('PIPEDA');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('returns CH for Switzerland', () => {
|
|
85
|
+
expect(checkJurisdiction('CH', null)).toBe('CH');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('handles null country code', () => {
|
|
89
|
+
expect(checkJurisdiction(null, null)).toBe('NONE');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('parseAcceptLanguage', () => {
|
|
94
|
+
it('returns en for null input', () => {
|
|
95
|
+
expect(parseAcceptLanguage(null)).toBe('en');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('parses simple language code', () => {
|
|
99
|
+
expect(parseAcceptLanguage('de')).toBe('de');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('parses language with region', () => {
|
|
103
|
+
expect(parseAcceptLanguage('de-DE')).toBe('de');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('parses Accept-Language with quality factors', () => {
|
|
107
|
+
expect(parseAcceptLanguage('de-DE,de;q=0.9,en;q=0.8')).toBe('de');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('getTranslationsData', () => {
|
|
112
|
+
it('returns en translations for null Accept-Language', () => {
|
|
113
|
+
const result = getTranslationsData(null);
|
|
114
|
+
expect(result.language).toBe('en');
|
|
115
|
+
expect(result.translations.cookieBanner.title).toBe(
|
|
116
|
+
baseTranslations.en.cookieBanner.title
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('returns de translations for de-DE', () => {
|
|
121
|
+
const result = getTranslationsData('de-DE,de;q=0.9,en;q=0.8');
|
|
122
|
+
expect(result.language).toBe('de');
|
|
123
|
+
expect(result.translations.cookieBanner.title).toBe(
|
|
124
|
+
baseTranslations.de.cookieBanner.title
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('merges custom translations', () => {
|
|
129
|
+
const customTranslations = {
|
|
130
|
+
en: { cookieBanner: { title: 'Custom Title' } },
|
|
131
|
+
};
|
|
132
|
+
const result = getTranslationsData('en-US', customTranslations);
|
|
133
|
+
expect(result.translations.cookieBanner.title).toBe('Custom Title');
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe('buildResponse', () => {
|
|
138
|
+
it('returns properly structured response', () => {
|
|
139
|
+
const result = buildResponse({
|
|
140
|
+
jurisdiction: 'GDPR',
|
|
141
|
+
location: { countryCode: 'DE', regionCode: null },
|
|
142
|
+
acceptLanguage: 'en',
|
|
143
|
+
customTranslations: undefined,
|
|
144
|
+
branding: 'c15t',
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
expect(result).toHaveProperty('jurisdiction');
|
|
148
|
+
expect(result).toHaveProperty('location');
|
|
149
|
+
expect(result).toHaveProperty('translations');
|
|
150
|
+
expect(result).toHaveProperty('branding');
|
|
151
|
+
expect(result.jurisdiction).toBe('GDPR');
|
|
152
|
+
expect(result.branding).toBe('c15t');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('getLocation', () => {
|
|
157
|
+
it('returns null location when geo is disabled', async () => {
|
|
158
|
+
const request = new Request('http://localhost', {
|
|
159
|
+
headers: { 'cf-ipcountry': 'DE' },
|
|
160
|
+
});
|
|
161
|
+
const options: C15TOptions = {
|
|
162
|
+
trustedOrigins: [],
|
|
163
|
+
adapter: {} as C15TOptions['adapter'],
|
|
164
|
+
advanced: { disableGeoLocation: true },
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const result = await getLocation(request, options);
|
|
168
|
+
expect(result.countryCode).toBeNull();
|
|
169
|
+
expect(result.regionCode).toBeNull();
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe('getJurisdiction', () => {
|
|
174
|
+
it('returns GDPR when geo is disabled', () => {
|
|
175
|
+
const options: C15TOptions = {
|
|
176
|
+
trustedOrigins: [],
|
|
177
|
+
adapter: {} as C15TOptions['adapter'],
|
|
178
|
+
advanced: { disableGeoLocation: true },
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const result = getJurisdiction(
|
|
182
|
+
{ countryCode: 'US', regionCode: null },
|
|
183
|
+
options
|
|
184
|
+
);
|
|
185
|
+
expect(result).toBe('GDPR');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('returns appropriate jurisdiction based on location', () => {
|
|
189
|
+
const options: C15TOptions = {
|
|
190
|
+
trustedOrigins: [],
|
|
191
|
+
adapter: {} as C15TOptions['adapter'],
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
expect(
|
|
195
|
+
getJurisdiction({ countryCode: 'DE', regionCode: null }, options)
|
|
196
|
+
).toBe('GDPR');
|
|
197
|
+
expect(
|
|
198
|
+
getJurisdiction({ countryCode: 'US', regionCode: 'CA' }, options)
|
|
199
|
+
).toBe('CCPA');
|
|
200
|
+
expect(
|
|
201
|
+
getJurisdiction({ countryCode: 'GB', regionCode: null }, options)
|
|
202
|
+
).toBe('UK_GDPR');
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { GlobalVendorList, NonIABVendor } from '@c15t/schema/types';
|
|
2
|
+
import type { Translations } from '@c15t/translations';
|
|
3
|
+
import type { Branding } from '~/types';
|
|
4
|
+
import type { JurisdictionCode } from '~/types/api';
|
|
5
|
+
import { getTranslationsData } from './translations';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets the headers from the context.
|
|
9
|
+
*
|
|
10
|
+
* @param headers - The headers to get the headers from.
|
|
11
|
+
* @returns The headers or null if the headers are not present.
|
|
12
|
+
*/
|
|
13
|
+
export function getHeaders(headers: Headers | undefined) {
|
|
14
|
+
if (!headers) {
|
|
15
|
+
return {
|
|
16
|
+
countryCode: null,
|
|
17
|
+
regionCode: null,
|
|
18
|
+
acceptLanguage: null,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Add this conversion to ensure headers are always string or null
|
|
23
|
+
const normalizeHeader = (
|
|
24
|
+
value: string | string[] | null | undefined
|
|
25
|
+
): string | null => {
|
|
26
|
+
if (!value) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return Array.isArray(value) ? (value[0] ?? null) : value;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const countryCode =
|
|
34
|
+
normalizeHeader(headers.get('x-c15t-country')) ??
|
|
35
|
+
normalizeHeader(headers.get('cf-ipcountry')) ??
|
|
36
|
+
normalizeHeader(headers.get('x-vercel-ip-country')) ??
|
|
37
|
+
normalizeHeader(headers.get('x-amz-cf-ipcountry')) ??
|
|
38
|
+
normalizeHeader(headers.get('x-country-code'));
|
|
39
|
+
|
|
40
|
+
const regionCode =
|
|
41
|
+
normalizeHeader(headers.get('x-c15t-region')) ??
|
|
42
|
+
normalizeHeader(headers.get('x-vercel-ip-country-region')) ??
|
|
43
|
+
normalizeHeader(headers.get('x-region-code'));
|
|
44
|
+
|
|
45
|
+
// Get preferred language from Accept-Language header
|
|
46
|
+
const acceptLanguage = normalizeHeader(headers.get('accept-language'));
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
countryCode,
|
|
50
|
+
regionCode,
|
|
51
|
+
acceptLanguage,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parse Accept-Language header to get the primary language code.
|
|
57
|
+
*
|
|
58
|
+
* @param acceptLanguage - The Accept-Language header value
|
|
59
|
+
* @returns The primary language code (e.g., "en", "de"), defaults to "en"
|
|
60
|
+
*/
|
|
61
|
+
export function parseAcceptLanguage(acceptLanguage: string | null): string {
|
|
62
|
+
if (!acceptLanguage) {
|
|
63
|
+
return 'en';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Parse "en-US,en;q=0.9,de;q=0.8" format
|
|
67
|
+
// Split by comma, take the first part, then extract language code
|
|
68
|
+
const firstLanguage = acceptLanguage.split(',')[0];
|
|
69
|
+
if (!firstLanguage) {
|
|
70
|
+
return 'en';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Remove quality factor if present (e.g., "en;q=0.9" -> "en")
|
|
74
|
+
const languageWithRegion = firstLanguage.split(';')[0]?.trim();
|
|
75
|
+
if (!languageWithRegion) {
|
|
76
|
+
return 'en';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Extract language code without region (e.g., "en-US" -> "en")
|
|
80
|
+
const languageCode = languageWithRegion.split('-')[0]?.toLowerCase();
|
|
81
|
+
|
|
82
|
+
return languageCode ?? 'en';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function buildResponse({
|
|
86
|
+
jurisdiction,
|
|
87
|
+
location,
|
|
88
|
+
acceptLanguage,
|
|
89
|
+
customTranslations,
|
|
90
|
+
branding = 'c15t',
|
|
91
|
+
gvl,
|
|
92
|
+
customVendors,
|
|
93
|
+
}: {
|
|
94
|
+
jurisdiction: JurisdictionCode;
|
|
95
|
+
location: { countryCode: string | null; regionCode: string | null };
|
|
96
|
+
acceptLanguage: string | null;
|
|
97
|
+
customTranslations: Record<string, Partial<Translations>> | undefined;
|
|
98
|
+
branding?: Branding;
|
|
99
|
+
gvl?: GlobalVendorList;
|
|
100
|
+
customVendors?: NonIABVendor[];
|
|
101
|
+
}) {
|
|
102
|
+
return {
|
|
103
|
+
jurisdiction,
|
|
104
|
+
location,
|
|
105
|
+
translations: getTranslationsData(acceptLanguage, customTranslations),
|
|
106
|
+
branding: branding,
|
|
107
|
+
gvl: gvl ?? null,
|
|
108
|
+
customVendors: customVendors ?? undefined,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { checkJurisdiction, getJurisdiction, getLocation } from './geo';
|
|
113
|
+
// Re-export translations functions
|
|
114
|
+
export { getTranslations, getTranslationsData } from './translations';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { baseTranslations } from '@c15t/translations';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { getTranslationsData } from './translations';
|
|
4
|
+
|
|
5
|
+
describe('showBanner > getTranslationsData', () => {
|
|
6
|
+
it("should return 'en' translations when Accept-Language is null", () => {
|
|
7
|
+
const { translations, language } = getTranslationsData(null);
|
|
8
|
+
expect(language).toBe('en');
|
|
9
|
+
expect(translations.cookieBanner.title).toBe(
|
|
10
|
+
baseTranslations.en.cookieBanner.title
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should return 'en' translations for unsupported language", () => {
|
|
15
|
+
const { translations, language } = getTranslationsData('xx-XX,en;q=0.9');
|
|
16
|
+
expect(language).toBe('en');
|
|
17
|
+
expect(translations.cookieBanner.title).toBe(
|
|
18
|
+
baseTranslations.en.cookieBanner.title
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should return 'de' translations for 'de-DE'", () => {
|
|
23
|
+
const { translations, language } = getTranslationsData(
|
|
24
|
+
'de-DE,de;q=0.9,en;q=0.8'
|
|
25
|
+
);
|
|
26
|
+
expect(language).toBe('de');
|
|
27
|
+
expect(translations.cookieBanner.title).toBe(
|
|
28
|
+
baseTranslations.de.cookieBanner.title
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should merge custom translations for the preferred language', () => {
|
|
33
|
+
const customTranslations = {
|
|
34
|
+
en: {
|
|
35
|
+
cookieBanner: {
|
|
36
|
+
title: 'My Custom Cookie Title',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const { translations, language } = getTranslationsData(
|
|
41
|
+
'en-US,en;q=0.9',
|
|
42
|
+
customTranslations
|
|
43
|
+
);
|
|
44
|
+
expect(language).toBe('en');
|
|
45
|
+
expect(translations.cookieBanner.title).toBe('My Custom Cookie Title');
|
|
46
|
+
// Check if other properties from base translations are still there
|
|
47
|
+
expect(translations.cookieBanner.description).toBeDefined();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should not merge custom translations for a different language', () => {
|
|
51
|
+
const customTranslations = {
|
|
52
|
+
de: {
|
|
53
|
+
cookieBanner: {
|
|
54
|
+
title: 'Meine benutzerdefinierte Cookie-Überschrift',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const { translations, language } = getTranslationsData(
|
|
59
|
+
'en-US,en;q=0.9',
|
|
60
|
+
customTranslations
|
|
61
|
+
);
|
|
62
|
+
expect(language).toBe('en');
|
|
63
|
+
expect(translations.cookieBanner.title).toBe(
|
|
64
|
+
baseTranslations.en.cookieBanner.title
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should handle partially provided custom translations', () => {
|
|
69
|
+
const customTranslations = {
|
|
70
|
+
en: {
|
|
71
|
+
cookieBanner: {
|
|
72
|
+
// Title is NOT provided, description is.
|
|
73
|
+
description: 'My custom description.',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const { translations, language } = getTranslationsData(
|
|
78
|
+
'en-US,en;q=0.9',
|
|
79
|
+
customTranslations
|
|
80
|
+
);
|
|
81
|
+
expect(language).toBe('en');
|
|
82
|
+
// Title should come from base
|
|
83
|
+
expect(translations.cookieBanner.title).toBe(
|
|
84
|
+
baseTranslations.en.cookieBanner.title
|
|
85
|
+
);
|
|
86
|
+
// Description should be from custom
|
|
87
|
+
expect(translations.cookieBanner.description).toBe(
|
|
88
|
+
'My custom description.'
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should return base translations if custom translations are empty for the language', () => {
|
|
93
|
+
const customTranslations = {
|
|
94
|
+
de: {},
|
|
95
|
+
};
|
|
96
|
+
const { translations, language } = getTranslationsData(
|
|
97
|
+
'de-DE,de;q=0.9',
|
|
98
|
+
customTranslations
|
|
99
|
+
);
|
|
100
|
+
expect(language).toBe('de');
|
|
101
|
+
expect(translations.cookieBanner.title).toBe(
|
|
102
|
+
baseTranslations.de.cookieBanner.title
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should return custom translations for unsupported base language', () => {
|
|
107
|
+
const { translations, language } = getTranslationsData('xx-XX,en;q=0.9', {
|
|
108
|
+
xx: {
|
|
109
|
+
cookieBanner: {
|
|
110
|
+
title: 'XX Title',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(language).toBe('xx');
|
|
116
|
+
expect(translations.cookieBanner.title).toBe('XX Title');
|
|
117
|
+
expect(translations.cookieBanner.description).toBe(
|
|
118
|
+
baseTranslations.en.cookieBanner.description
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
baseTranslations,
|
|
3
|
+
type CompleteTranslations,
|
|
4
|
+
deepMergeTranslations,
|
|
5
|
+
selectLanguage,
|
|
6
|
+
type Translations,
|
|
7
|
+
} from '@c15t/translations';
|
|
8
|
+
|
|
9
|
+
type SupportedBaseLanguage = keyof typeof baseTranslations;
|
|
10
|
+
|
|
11
|
+
function isSupportedBaseLanguage(lang: string): lang is SupportedBaseLanguage {
|
|
12
|
+
return lang in baseTranslations;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the translations data for a given language, merging custom translations if provided.
|
|
17
|
+
*
|
|
18
|
+
* @param acceptLanguage - The `Accept-Language` header from the request.
|
|
19
|
+
* @param customTranslations - An object containing custom translations to merge with the base translations.
|
|
20
|
+
* @returns An object containing the final translations and the determined language.
|
|
21
|
+
*/
|
|
22
|
+
export function getTranslationsData(
|
|
23
|
+
acceptLanguage: string | null,
|
|
24
|
+
customTranslations?: Record<string, Partial<Translations>>
|
|
25
|
+
) {
|
|
26
|
+
const supportedDefaultLanguages = Object.keys(baseTranslations);
|
|
27
|
+
const supportedCustomLanguages = Object.keys(customTranslations || {});
|
|
28
|
+
|
|
29
|
+
const supportedLanguages = [
|
|
30
|
+
...supportedDefaultLanguages,
|
|
31
|
+
...supportedCustomLanguages,
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const preferredLanguage = selectLanguage(supportedLanguages, {
|
|
35
|
+
header: acceptLanguage,
|
|
36
|
+
fallback: 'en',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const base = isSupportedBaseLanguage(preferredLanguage)
|
|
40
|
+
? baseTranslations[preferredLanguage]
|
|
41
|
+
: baseTranslations.en;
|
|
42
|
+
|
|
43
|
+
const custom = supportedCustomLanguages.includes(preferredLanguage)
|
|
44
|
+
? customTranslations?.[preferredLanguage]
|
|
45
|
+
: {};
|
|
46
|
+
|
|
47
|
+
const translations = custom ? deepMergeTranslations(base, custom) : base;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
translations: translations as CompleteTranslations,
|
|
51
|
+
language: preferredLanguage,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Gets the translations for a given language from options.
|
|
57
|
+
*
|
|
58
|
+
* @param acceptLanguage - The `Accept-Language` header from the request.
|
|
59
|
+
* @param options - The C15T options containing custom translations.
|
|
60
|
+
* @returns An object containing the final translations and the determined language.
|
|
61
|
+
*/
|
|
62
|
+
export async function getTranslations(
|
|
63
|
+
acceptLanguage: string,
|
|
64
|
+
options: {
|
|
65
|
+
advanced?: { customTranslations?: Record<string, Partial<Translations>> };
|
|
66
|
+
}
|
|
67
|
+
) {
|
|
68
|
+
return getTranslationsData(
|
|
69
|
+
acceptLanguage,
|
|
70
|
+
options.advanced?.customTranslations
|
|
71
|
+
);
|
|
72
|
+
}
|