@c15t/backend 1.0.0 → 1.1.0-canary.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 +33 -39
- package/.turbo/turbo-fmt.log +7 -0
- package/.turbo/turbo-test.log +531 -0
- package/README.md +19 -7
- package/coverage/coverage-final.json +84 -0
- package/coverage/coverage-summary.json +85 -0
- package/coverage/html/backend/index.html +116 -0
- package/coverage/html/backend/rslib.config.ts.html +415 -0
- package/coverage/html/backend/src/contracts/consent/index.html +161 -0
- package/coverage/html/backend/src/contracts/consent/index.ts.html +112 -0
- package/coverage/html/backend/src/contracts/consent/post.contract.ts.html +559 -0
- package/coverage/html/backend/src/contracts/consent/show-banner.contract.ts.html +220 -0
- package/coverage/html/backend/src/contracts/consent/verify.contract.ts.html +463 -0
- package/coverage/html/backend/src/contracts/index.html +116 -0
- package/coverage/html/backend/src/contracts/index.ts.html +139 -0
- package/coverage/html/backend/src/contracts/meta/index.html +131 -0
- package/coverage/html/backend/src/contracts/meta/index.ts.html +100 -0
- package/coverage/html/backend/src/contracts/meta/status.contract.ts.html +196 -0
- package/coverage/html/backend/src/contracts/shared/index.html +116 -0
- package/coverage/html/backend/src/contracts/shared/jurisdiction.schema.ts.html +175 -0
- package/coverage/html/backend/src/core.ts.html +1624 -0
- package/coverage/html/backend/src/handlers/consent/index.html +161 -0
- package/coverage/html/backend/src/handlers/consent/index.ts.html +112 -0
- package/coverage/html/backend/src/handlers/consent/post.handler.ts.html +889 -0
- package/coverage/html/backend/src/handlers/consent/show-banner.handler.ts.html +535 -0
- package/coverage/html/backend/src/handlers/consent/verify.handler.ts.html +1000 -0
- package/coverage/html/backend/src/handlers/meta/index.html +131 -0
- package/coverage/html/backend/src/handlers/meta/index.ts.html +100 -0
- package/coverage/html/backend/src/handlers/meta/status.handler.ts.html +226 -0
- package/coverage/html/backend/src/index.html +161 -0
- package/coverage/html/backend/src/init.ts.html +1018 -0
- package/coverage/html/backend/src/pkgs/api-router/hooks/index.html +116 -0
- package/coverage/html/backend/src/pkgs/api-router/hooks/processor.ts.html +544 -0
- package/coverage/html/backend/src/pkgs/api-router/index.html +116 -0
- package/coverage/html/backend/src/pkgs/api-router/telemetry.ts.html +334 -0
- package/coverage/html/backend/src/pkgs/api-router/utils/cors.ts.html +304 -0
- package/coverage/html/backend/src/pkgs/api-router/utils/index.html +131 -0
- package/coverage/html/backend/src/pkgs/api-router/utils/ip.ts.html +361 -0
- package/coverage/html/backend/src/pkgs/data-model/fields/field-factory.ts.html +709 -0
- package/coverage/html/backend/src/pkgs/data-model/fields/id-generator.ts.html +256 -0
- package/coverage/html/backend/src/pkgs/data-model/fields/index.html +161 -0
- package/coverage/html/backend/src/pkgs/data-model/fields/superjson-utils.ts.html +136 -0
- package/coverage/html/backend/src/pkgs/data-model/fields/zod-fields.ts.html +496 -0
- package/coverage/html/backend/src/pkgs/data-model/hooks/create-hooks.ts.html +349 -0
- package/coverage/html/backend/src/pkgs/data-model/hooks/index.html +176 -0
- package/coverage/html/backend/src/pkgs/data-model/hooks/update-hooks.ts.html +358 -0
- package/coverage/html/backend/src/pkgs/data-model/hooks/update-many-hooks.ts.html +613 -0
- package/coverage/html/backend/src/pkgs/data-model/hooks/utils.ts.html +538 -0
- package/coverage/html/backend/src/pkgs/data-model/hooks/with-hooks-factory.ts.html +289 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapter-factory.ts.html +289 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.ts.html +2203 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/drizzle-adapter/index.html +116 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/index.html +116 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/dialect.ts.html +670 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/index.html +131 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.ts.html +3634 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/tests/index.html +116 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.ts.html +1417 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/memory-adapter/index.html +116 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.ts.html +2071 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/prisma-adapter/index.html +116 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.ts.html +1834 -0
- package/coverage/html/backend/src/pkgs/db-adapters/adapters/test.ts.html +316 -0
- package/coverage/html/backend/src/pkgs/db-adapters/index.html +131 -0
- package/coverage/html/backend/src/pkgs/db-adapters/utils.ts.html +238 -0
- package/coverage/html/backend/src/pkgs/migrations/get-migration.ts.html +343 -0
- package/coverage/html/backend/src/pkgs/migrations/get-schema/get-schema.ts.html +217 -0
- package/coverage/html/backend/src/pkgs/migrations/get-schema/index.html +146 -0
- package/coverage/html/backend/src/pkgs/migrations/get-schema/process-fields.ts.html +280 -0
- package/coverage/html/backend/src/pkgs/migrations/get-schema/process-tables.ts.html +289 -0
- package/coverage/html/backend/src/pkgs/migrations/index.html +176 -0
- package/coverage/html/backend/src/pkgs/migrations/migration-builders.ts.html +595 -0
- package/coverage/html/backend/src/pkgs/migrations/migration-execution.ts.html +301 -0
- package/coverage/html/backend/src/pkgs/migrations/schema-comparison.ts.html +694 -0
- package/coverage/html/backend/src/pkgs/migrations/type-mapping.ts.html +817 -0
- package/coverage/html/backend/src/pkgs/results/core/error-class.ts.html +976 -0
- package/coverage/html/backend/src/pkgs/results/core/error-codes.ts.html +703 -0
- package/coverage/html/backend/src/pkgs/results/core/index.html +146 -0
- package/coverage/html/backend/src/pkgs/results/core/tracing.ts.html +280 -0
- package/coverage/html/backend/src/pkgs/results/create-telemetry-options.ts.html +271 -0
- package/coverage/html/backend/src/pkgs/results/index.html +131 -0
- package/coverage/html/backend/src/pkgs/results/orpc-error-handler.ts.html +496 -0
- package/coverage/html/backend/src/pkgs/results/results/index.html +131 -0
- package/coverage/html/backend/src/pkgs/results/results/recovery-utils.ts.html +628 -0
- package/coverage/html/backend/src/pkgs/results/results/result-helpers.ts.html +1234 -0
- package/coverage/html/backend/src/pkgs/utils/env.ts.html +337 -0
- package/coverage/html/backend/src/pkgs/utils/index.html +146 -0
- package/coverage/html/backend/src/pkgs/utils/logger.ts.html +199 -0
- package/coverage/html/backend/src/pkgs/utils/url.ts.html +400 -0
- package/coverage/html/backend/src/router.ts.html +109 -0
- package/coverage/html/backend/src/schema/audit-log/index.html +146 -0
- package/coverage/html/backend/src/schema/audit-log/registry.ts.html +436 -0
- package/coverage/html/backend/src/schema/audit-log/schema.ts.html +223 -0
- package/coverage/html/backend/src/schema/audit-log/table.ts.html +640 -0
- package/coverage/html/backend/src/schema/consent/index.html +146 -0
- package/coverage/html/backend/src/schema/consent/registry.ts.html +616 -0
- package/coverage/html/backend/src/schema/consent/schema.ts.html +238 -0
- package/coverage/html/backend/src/schema/consent/table.ts.html +748 -0
- package/coverage/html/backend/src/schema/consent-policy/index.html +146 -0
- package/coverage/html/backend/src/schema/consent-policy/registry.ts.html +1063 -0
- package/coverage/html/backend/src/schema/consent-policy/schema.ts.html +265 -0
- package/coverage/html/backend/src/schema/consent-policy/table.ts.html +535 -0
- package/coverage/html/backend/src/schema/consent-purpose/index.html +146 -0
- package/coverage/html/backend/src/schema/consent-purpose/registry.ts.html +589 -0
- package/coverage/html/backend/src/schema/consent-purpose/schema.ts.html +259 -0
- package/coverage/html/backend/src/schema/consent-purpose/table.ts.html +547 -0
- package/coverage/html/backend/src/schema/consent-record/index.html +131 -0
- package/coverage/html/backend/src/schema/consent-record/schema.ts.html +211 -0
- package/coverage/html/backend/src/schema/consent-record/table.ts.html +457 -0
- package/coverage/html/backend/src/schema/create-registry.ts.html +148 -0
- package/coverage/html/backend/src/schema/definition.ts.html +685 -0
- package/coverage/html/backend/src/schema/domain/index.html +146 -0
- package/coverage/html/backend/src/schema/domain/registry.ts.html +973 -0
- package/coverage/html/backend/src/schema/domain/schema.ts.html +214 -0
- package/coverage/html/backend/src/schema/domain/table.ts.html +496 -0
- package/coverage/html/backend/src/schema/index.html +146 -0
- package/coverage/html/backend/src/schema/schemas.ts.html +166 -0
- package/coverage/html/backend/src/schema/subject/index.html +146 -0
- package/coverage/html/backend/src/schema/subject/registry.ts.html +973 -0
- package/coverage/html/backend/src/schema/subject/schema.ts.html +208 -0
- package/coverage/html/backend/src/schema/subject/table.ts.html +499 -0
- package/coverage/html/backend/src/server.ts.html +475 -0
- package/coverage/html/backend/src/testing/contract-testing.ts.html +1348 -0
- package/coverage/html/backend/src/testing/index.html +116 -0
- package/coverage/html/base.css +224 -0
- package/coverage/html/block-navigation.js +87 -0
- package/coverage/html/favicon.png +0 -0
- package/coverage/html/index.html +626 -0
- package/coverage/html/prettify.css +1 -0
- package/coverage/html/prettify.js +2 -0
- package/coverage/html/sort-arrow-sprite.png +0 -0
- package/coverage/html/sorter.js +196 -0
- package/dist/contracts/consent/index.d.ts +401 -0
- package/dist/contracts/consent/index.d.ts.map +1 -0
- package/dist/contracts/consent/index.test.d.ts +2 -0
- package/dist/contracts/consent/index.test.d.ts.map +1 -0
- package/dist/contracts/consent/post.contract.d.ts +212 -0
- package/dist/contracts/consent/post.contract.d.ts.map +1 -0
- package/dist/contracts/consent/post.contract.test.d.ts +2 -0
- package/dist/contracts/consent/post.contract.test.d.ts.map +1 -0
- package/dist/contracts/consent/show-banner.contract.d.ts +45 -0
- package/dist/contracts/consent/show-banner.contract.d.ts.map +1 -0
- package/dist/contracts/consent/show-banner.contract.test.d.ts +2 -0
- package/dist/contracts/consent/show-banner.contract.test.d.ts.map +1 -0
- package/dist/contracts/consent/verify.contract.d.ts +147 -0
- package/dist/contracts/consent/verify.contract.d.ts.map +1 -0
- package/dist/contracts/consent/verify.contract.test.d.ts +2 -0
- package/dist/contracts/consent/verify.contract.test.d.ts.map +1 -0
- package/dist/contracts/index.d.ts +963 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/meta/index.d.ts +78 -0
- package/dist/contracts/meta/index.d.ts.map +1 -0
- package/dist/contracts/meta/index.test.d.ts +2 -0
- package/dist/contracts/meta/index.test.d.ts.map +1 -0
- package/dist/contracts/meta/status.contract.d.ts +77 -0
- package/dist/contracts/meta/status.contract.d.ts.map +1 -0
- package/dist/contracts/meta/status.contract.test.d.ts +2 -0
- package/dist/contracts/meta/status.contract.test.d.ts.map +1 -0
- package/dist/contracts/shared/jurisdiction.schema.d.ts +24 -0
- package/dist/contracts/shared/jurisdiction.schema.d.ts.map +1 -0
- package/dist/core.cjs +3584 -0
- package/dist/core.d.ts +533 -78
- package/dist/core.d.ts.map +1 -1
- package/dist/{index.js → core.js} +1164 -1292
- package/dist/handlers/consent/index.d.ts +401 -0
- package/dist/handlers/consent/index.d.ts.map +1 -0
- package/dist/handlers/consent/post.handler.d.ts +234 -0
- package/dist/handlers/consent/post.handler.d.ts.map +1 -0
- package/dist/handlers/consent/show-banner.handler.d.ts +57 -0
- package/dist/handlers/consent/show-banner.handler.d.ts.map +1 -0
- package/dist/handlers/consent/show-banner.handler.test.d.ts +2 -0
- package/dist/handlers/consent/show-banner.handler.test.d.ts.map +1 -0
- package/dist/handlers/consent/verify.handler.d.ts +169 -0
- package/dist/handlers/consent/verify.handler.d.ts.map +1 -0
- package/dist/handlers/meta/index.d.ts +78 -0
- package/dist/handlers/meta/index.d.ts.map +1 -0
- package/dist/handlers/meta/status.handler.d.ts +76 -0
- package/dist/handlers/meta/status.handler.d.ts.map +1 -0
- package/dist/init.d.ts +0 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/pkgs/api-router/hooks/processor.d.ts.map +1 -1
- package/dist/pkgs/api-router/types/router-props.d.ts +1 -1
- package/dist/pkgs/api-router/types/router-props.d.ts.map +1 -1
- package/dist/pkgs/api-router/utils/cors.d.ts +1 -1
- package/dist/pkgs/api-router/utils/cors.d.ts.map +1 -1
- package/dist/pkgs/data-model/fields/field-types.d.ts +1 -1
- package/dist/pkgs/data-model/fields/zod-fields.d.ts +32 -32
- package/dist/pkgs/data-model/index.cjs +1433 -1799
- package/dist/pkgs/data-model/index.js +20 -385
- package/dist/pkgs/data-model/schema/index.cjs +1402 -1768
- package/dist/pkgs/data-model/schema/index.js +20 -385
- package/dist/pkgs/db-adapters/adapter-factory.d.ts +2 -2
- package/dist/pkgs/db-adapters/adapter-factory.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.d.ts +4 -7
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.cjs +19 -151
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.js +19 -151
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/dialect.d.ts +1 -3
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/dialect.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.cjs +17 -149
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.js +17 -149
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.d.ts +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts +2 -2
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/types.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/types.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.cjs +17 -149
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.js +17 -149
- package/dist/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.d.ts +0 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.cjs +19 -151
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.js +19 -151
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.d.ts +0 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/index.cjs +31 -153
- package/dist/pkgs/db-adapters/index.js +31 -153
- package/dist/pkgs/migrations/get-schema/get-schema.d.ts +2 -2
- package/dist/pkgs/migrations/get-schema/index.d.ts +1 -1
- package/dist/pkgs/migrations/index.cjs +30 -153
- package/dist/pkgs/migrations/index.js +30 -153
- package/dist/pkgs/migrations/schema-comparison.d.ts.map +1 -1
- package/dist/pkgs/results/core/error-class.d.ts +23 -21
- package/dist/pkgs/results/core/error-class.d.ts.map +1 -1
- package/dist/pkgs/results/index.cjs +17 -150
- package/dist/pkgs/results/index.d.ts +0 -3
- package/dist/pkgs/results/index.d.ts.map +1 -1
- package/dist/pkgs/results/index.js +17 -138
- package/dist/pkgs/results/orpc-error-handler.d.ts +65 -0
- package/dist/pkgs/results/orpc-error-handler.d.ts.map +1 -0
- package/dist/pkgs/results/types.d.ts +7 -7
- package/dist/pkgs/results/types.d.ts.map +1 -1
- package/dist/pkgs/types/context.d.ts +15 -8
- package/dist/pkgs/types/context.d.ts.map +1 -1
- package/dist/pkgs/types/endpoints.d.ts +3 -4
- package/dist/pkgs/types/endpoints.d.ts.map +1 -1
- package/dist/pkgs/types/options.d.ts +2 -4
- package/dist/pkgs/types/options.d.ts.map +1 -1
- package/dist/pkgs/types/plugins.d.ts +2 -3
- package/dist/pkgs/types/plugins.d.ts.map +1 -1
- package/dist/pkgs/utils/index.d.ts +1 -0
- package/dist/pkgs/utils/index.d.ts.map +1 -1
- package/dist/pkgs/utils/logger.d.ts +16 -0
- package/dist/pkgs/utils/logger.d.ts.map +1 -0
- package/dist/router.cjs +1213 -0
- package/dist/router.d.ts +480 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +1169 -0
- package/dist/schema/audit-log/table.d.ts +1 -1
- package/dist/schema/consent/table.d.ts +1 -1
- package/dist/schema/consent-policy/registry.d.ts +12 -12
- package/dist/schema/consent-policy/schema.d.ts +6 -6
- package/dist/schema/consent-policy/table.d.ts +7 -7
- package/dist/schema/consent-purpose/registry.d.ts +6 -6
- package/dist/schema/consent-purpose/schema.d.ts +6 -6
- package/dist/schema/consent-purpose/table.d.ts +7 -7
- package/dist/schema/consent-record/table.d.ts +1 -1
- package/dist/schema/create-registry.d.ts +32 -32
- package/dist/schema/definition.d.ts +19 -19
- package/dist/schema/domain/registry.d.ts +10 -10
- package/dist/schema/domain/schema.d.ts +5 -5
- package/dist/schema/domain/table.d.ts +6 -6
- package/dist/schema/index.cjs +1409 -1775
- package/dist/schema/index.js +20 -385
- package/dist/schema/schemas.d.ts +19 -19
- package/dist/schema/subject/registry.d.ts +4 -4
- package/dist/schema/subject/schema.d.ts +2 -2
- package/dist/schema/subject/table.d.ts +3 -3
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/testing/contract-testing.d.ts +37 -0
- package/dist/testing/contract-testing.d.ts.map +1 -0
- package/dist/types/context.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/options.d.ts +33 -3
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +3 -4
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +20 -28
- package/rslib.config.ts +2 -5
- package/src/contracts/consent/index.test.ts +5 -0
- package/src/contracts/consent/index.ts +9 -0
- package/src/contracts/consent/post.contract.test.ts +526 -0
- package/src/contracts/consent/post.contract.ts +160 -0
- package/src/contracts/consent/show-banner.contract.test.ts +214 -0
- package/src/contracts/consent/show-banner.contract.ts +45 -0
- package/src/contracts/consent/verify.contract.test.ts +185 -0
- package/src/contracts/consent/verify.contract.ts +126 -0
- package/src/contracts/index.ts +18 -0
- package/src/contracts/meta/index.test.ts +5 -0
- package/src/contracts/meta/index.ts +5 -0
- package/src/contracts/meta/status.contract.test.ts +338 -0
- package/src/contracts/meta/status.contract.ts +37 -0
- package/src/contracts/shared/jurisdiction.schema.ts +30 -0
- package/src/core.ts +451 -161
- package/src/handlers/consent/index.ts +9 -0
- package/src/handlers/consent/post.handler.ts +273 -0
- package/src/handlers/consent/show-banner.handler.test.ts +148 -0
- package/src/handlers/consent/show-banner.handler.ts +150 -0
- package/src/handlers/consent/verify.handler.ts +305 -0
- package/src/handlers/meta/index.ts +5 -0
- package/src/handlers/meta/status.handler.ts +47 -0
- package/src/init.ts +8 -26
- package/src/pkgs/api-router/hooks/__tests__/processor.test.ts +6 -0
- package/src/pkgs/api-router/hooks/processor.ts +2 -0
- package/src/pkgs/api-router/types/router-props.ts +1 -1
- package/src/pkgs/api-router/utils/cors.ts +1 -1
- package/src/pkgs/data-model/fields/field-types.ts +1 -1
- package/src/pkgs/data-model/fields/id-generator.ts +1 -1
- package/src/pkgs/db-adapters/README.md +3 -3
- package/src/pkgs/db-adapters/adapter-factory.ts +8 -4
- package/src/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.ts +13 -16
- package/src/pkgs/db-adapters/adapters/kysely-adapter/dialect.ts +1 -3
- package/src/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.ts +0 -1
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.ts +1 -1
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.ts +1 -1
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.ts +2 -2
- package/src/pkgs/db-adapters/adapters/kysely-adapter/types.ts +0 -2
- package/src/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.ts +0 -1
- package/src/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.ts +0 -1
- package/src/pkgs/migrations/get-migration.ts +3 -3
- package/src/pkgs/migrations/get-schema/get-schema.ts +2 -2
- package/src/pkgs/migrations/get-schema/index.ts +1 -1
- package/src/pkgs/migrations/migration-builders.ts +2 -2
- package/src/pkgs/migrations/migration-execution.ts +2 -2
- package/src/pkgs/migrations/schema-comparison.ts +5 -4
- package/src/pkgs/results/__tests__/error-class.test.ts +8 -7
- package/src/pkgs/results/core/error-class.ts +31 -43
- package/src/pkgs/results/index.ts +0 -10
- package/src/pkgs/results/orpc-error-handler.ts +137 -0
- package/src/pkgs/results/types.ts +8 -7
- package/src/pkgs/types/context.ts +18 -9
- package/src/pkgs/types/endpoints.ts +3 -5
- package/src/pkgs/types/options.ts +2 -4
- package/src/pkgs/types/plugins.ts +2 -3
- package/src/pkgs/utils/index.ts +1 -0
- package/src/pkgs/utils/logger.ts +38 -0
- package/src/router.ts +8 -0
- package/src/schema/audit-log/table.ts +1 -1
- package/src/schema/consent/table.ts +1 -1
- package/src/schema/consent-policy/table.ts +1 -1
- package/src/schema/consent-purpose/table.ts +1 -1
- package/src/schema/consent-record/table.ts +1 -1
- package/src/schema/definition.ts +2 -2
- package/src/schema/domain/table.ts +1 -1
- package/src/schema/subject/table.ts +1 -1
- package/src/server.ts +130 -0
- package/src/testing/contract-testing.ts +437 -0
- package/src/types/context.ts +1 -1
- package/src/types/index.ts +2 -2
- package/src/types/options.ts +38 -3
- package/src/types/plugins.ts +3 -4
- package/dist/index.cjs +0 -3706
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/init.test.d.ts +0 -2
- package/dist/init.test.d.ts.map +0 -1
- package/dist/integrations/cloudflare.cjs +0 -312
- package/dist/integrations/cloudflare.d.ts +0 -32
- package/dist/integrations/cloudflare.d.ts.map +0 -1
- package/dist/integrations/cloudflare.js +0 -278
- package/dist/integrations/next.cjs +0 -276
- package/dist/integrations/next.d.ts +0 -68
- package/dist/integrations/next.d.ts.map +0 -1
- package/dist/integrations/next.js +0 -239
- package/dist/integrations/node.cjs +0 -257
- package/dist/integrations/node.d.ts +0 -29
- package/dist/integrations/node.d.ts.map +0 -1
- package/dist/integrations/node.js +0 -223
- package/dist/pkgs/api-router/index.d.ts +0 -9
- package/dist/pkgs/api-router/index.d.ts.map +0 -1
- package/dist/pkgs/api-router/utils/define-route.d.ts +0 -87
- package/dist/pkgs/api-router/utils/define-route.d.ts.map +0 -1
- package/dist/pkgs/logger/__tests__/console-formatter.test.d.ts +0 -2
- package/dist/pkgs/logger/__tests__/console-formatter.test.d.ts.map +0 -1
- package/dist/pkgs/logger/__tests__/integration.test.d.ts +0 -2
- package/dist/pkgs/logger/__tests__/integration.test.d.ts.map +0 -1
- package/dist/pkgs/logger/__tests__/log-levels.test.d.ts +0 -2
- package/dist/pkgs/logger/__tests__/log-levels.test.d.ts.map +0 -1
- package/dist/pkgs/logger/__tests__/logger-factory.test.d.ts +0 -2
- package/dist/pkgs/logger/__tests__/logger-factory.test.d.ts.map +0 -1
- package/dist/pkgs/logger/__tests__/result-logging.test.d.ts +0 -2
- package/dist/pkgs/logger/__tests__/result-logging.test.d.ts.map +0 -1
- package/dist/pkgs/logger/__tests__/types.test.d.ts +0 -2
- package/dist/pkgs/logger/__tests__/types.test.d.ts.map +0 -1
- package/dist/pkgs/logger/console-formatter.d.ts +0 -56
- package/dist/pkgs/logger/console-formatter.d.ts.map +0 -1
- package/dist/pkgs/logger/index.cjs +0 -240
- package/dist/pkgs/logger/index.d.ts +0 -35
- package/dist/pkgs/logger/index.d.ts.map +0 -1
- package/dist/pkgs/logger/index.js +0 -185
- package/dist/pkgs/logger/log-levels.d.ts +0 -29
- package/dist/pkgs/logger/log-levels.d.ts.map +0 -1
- package/dist/pkgs/logger/logger-factory.d.ts +0 -42
- package/dist/pkgs/logger/logger-factory.d.ts.map +0 -1
- package/dist/pkgs/logger/result-logging.d.ts +0 -71
- package/dist/pkgs/logger/result-logging.d.ts.map +0 -1
- package/dist/pkgs/logger/telemetry.d.ts +0 -14
- package/dist/pkgs/logger/telemetry.d.ts.map +0 -1
- package/dist/pkgs/logger/types.d.ts +0 -121
- package/dist/pkgs/logger/types.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/retrieval-pipeline.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/retrieval-pipeline.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/validation-pipeline.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/validation-pipeline.test.d.ts.map +0 -1
- package/dist/pkgs/results/h3-integration.d.ts +0 -52
- package/dist/pkgs/results/h3-integration.d.ts.map +0 -1
- package/dist/pkgs/results/pipeline/retrieval-pipeline.d.ts +0 -101
- package/dist/pkgs/results/pipeline/retrieval-pipeline.d.ts.map +0 -1
- package/dist/pkgs/results/pipeline/validation-pipeline.d.ts +0 -89
- package/dist/pkgs/results/pipeline/validation-pipeline.d.ts.map +0 -1
- package/dist/response-types.d.ts +0 -19
- package/dist/response-types.d.ts.map +0 -1
- package/dist/routes/__test__/index.test.d.ts +0 -17
- package/dist/routes/__test__/index.test.d.ts.map +0 -1
- package/dist/routes/__test__/set-consent.test.d.ts +0 -2
- package/dist/routes/__test__/set-consent.test.d.ts.map +0 -1
- package/dist/routes/__test__/show-consent-banner.test.d.ts +0 -2
- package/dist/routes/__test__/show-consent-banner.test.d.ts.map +0 -1
- package/dist/routes/__test__/status.test.d.ts +0 -2
- package/dist/routes/__test__/status.test.d.ts.map +0 -1
- package/dist/routes/__test__/verify-consent.test.d.ts +0 -2
- package/dist/routes/__test__/verify-consent.test.d.ts.map +0 -1
- package/dist/routes/index.d.ts +0 -3
- package/dist/routes/index.d.ts.map +0 -1
- package/dist/routes/set-consent.d.ts +0 -89
- package/dist/routes/set-consent.d.ts.map +0 -1
- package/dist/routes/show-consent-banner.d.ts +0 -15
- package/dist/routes/show-consent-banner.d.ts.map +0 -1
- package/dist/routes/status.d.ts +0 -44
- package/dist/routes/status.d.ts.map +0 -1
- package/dist/routes/types.d.ts +0 -7
- package/dist/routes/types.d.ts.map +0 -1
- package/dist/routes/verify-consent.d.ts +0 -38
- package/dist/routes/verify-consent.d.ts.map +0 -1
- package/src/docs/ADVANCED_JSON_HANDLING.md +0 -99
- package/src/docs/neverthrow.md +0 -171
- package/src/index.ts +0 -34
- package/src/init.test.ts +0 -236
- package/src/integrations/cloudflare.ts +0 -269
- package/src/integrations/next.ts +0 -204
- package/src/integrations/node.ts +0 -141
- package/src/pkgs/api-router/index.ts +0 -148
- package/src/pkgs/api-router/types/h3.d.ts +0 -42
- package/src/pkgs/api-router/utils/define-route.ts +0 -410
- package/src/pkgs/logger/README.md +0 -213
- package/src/pkgs/logger/__tests__/console-formatter.test.ts +0 -67
- package/src/pkgs/logger/__tests__/integration.test.ts +0 -184
- package/src/pkgs/logger/__tests__/log-levels.test.ts +0 -77
- package/src/pkgs/logger/__tests__/logger-factory.test.ts +0 -156
- package/src/pkgs/logger/__tests__/result-logging.test.ts +0 -209
- package/src/pkgs/logger/__tests__/types.test.ts +0 -94
- package/src/pkgs/logger/console-formatter.ts +0 -75
- package/src/pkgs/logger/doc.md +0 -569
- package/src/pkgs/logger/index.ts +0 -59
- package/src/pkgs/logger/log-levels.ts +0 -46
- package/src/pkgs/logger/logger-factory.ts +0 -121
- package/src/pkgs/logger/result-logging.ts +0 -134
- package/src/pkgs/logger/telemetry.ts +0 -96
- package/src/pkgs/logger/types.ts +0 -138
- package/src/pkgs/results/__tests__/retrieval-pipeline.test.ts +0 -157
- package/src/pkgs/results/__tests__/validation-pipeline.test.ts +0 -151
- package/src/pkgs/results/h3-integration.ts +0 -142
- package/src/pkgs/results/pipeline/retrieval-pipeline.ts +0 -188
- package/src/pkgs/results/pipeline/validation-pipeline.ts +0 -164
- package/src/plugins/.keep +0 -0
- package/src/response-types.ts +0 -29
- package/src/routes/__test__/index.test.ts +0 -112
- package/src/routes/__test__/set-consent.test.ts +0 -242
- package/src/routes/__test__/show-consent-banner.test.ts +0 -98
- package/src/routes/__test__/status.test.ts +0 -64
- package/src/routes/__test__/verify-consent.test.ts +0 -266
- package/src/routes/index.ts +0 -12
- package/src/routes/set-consent.ts +0 -249
- package/src/routes/show-consent-banner.ts +0 -131
- package/src/routes/status.ts +0 -61
- package/src/routes/types.ts +0 -7
- package/src/routes/verify-consent.ts +0 -206
|
@@ -32,15 +32,15 @@ export interface DB {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Creates a transformer for converting between
|
|
35
|
+
* Creates a transformer for converting between c15t data models and Drizzle schema
|
|
36
36
|
*
|
|
37
37
|
* This function creates an object with utility methods for converting data between
|
|
38
|
-
* the
|
|
38
|
+
* the c15t internal representation and the Drizzle ORM schema representation.
|
|
39
39
|
*
|
|
40
40
|
* @internal This function is primarily used internally by the drizzleAdapter
|
|
41
41
|
* @param db - The Drizzle database instance
|
|
42
42
|
* @param config - Configuration options for the Drizzle adapter
|
|
43
|
-
* @param options -
|
|
43
|
+
* @param options - c15t options
|
|
44
44
|
* @returns An object containing entity transformation utilities
|
|
45
45
|
* @throws {DoubleTieError} If the schema is not found or if a model or field doesn't exist
|
|
46
46
|
*/
|
|
@@ -56,7 +56,7 @@ const createEntityTransformer = (
|
|
|
56
56
|
*
|
|
57
57
|
* @internal
|
|
58
58
|
* @param model - The model name
|
|
59
|
-
* @param field - The field name in the
|
|
59
|
+
* @param field - The field name in the c15t model
|
|
60
60
|
* @returns The corresponding field name in the database schema
|
|
61
61
|
*/
|
|
62
62
|
function getField(model: string, field: string) {
|
|
@@ -127,11 +127,11 @@ const createEntityTransformer = (
|
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* Converts
|
|
130
|
+
* Converts c15t where clauses to Drizzle ORM conditions
|
|
131
131
|
*
|
|
132
132
|
* @internal
|
|
133
133
|
* @typeParam EntityType - The type of entity being queried
|
|
134
|
-
* @param where - Array of where conditions from
|
|
134
|
+
* @param where - Array of where conditions from c15t
|
|
135
135
|
* @param model - The model name
|
|
136
136
|
* @returns Array of Drizzle ORM conditions
|
|
137
137
|
* @throws {DoubleTieError} If a field doesn't exist or if the operator value is invalid
|
|
@@ -245,7 +245,7 @@ const createEntityTransformer = (
|
|
|
245
245
|
return {
|
|
246
246
|
getSchema,
|
|
247
247
|
/**
|
|
248
|
-
* Transforms input data from
|
|
248
|
+
* Transforms input data from c15t format to Drizzle format
|
|
249
249
|
*
|
|
250
250
|
* @internal
|
|
251
251
|
* @param data - The data to transform
|
|
@@ -285,13 +285,13 @@ const createEntityTransformer = (
|
|
|
285
285
|
return transformedData;
|
|
286
286
|
},
|
|
287
287
|
/**
|
|
288
|
-
* Transforms output data from Drizzle format to
|
|
288
|
+
* Transforms output data from Drizzle format to c15t format
|
|
289
289
|
*
|
|
290
290
|
* @internal
|
|
291
291
|
* @param data - The data to transform
|
|
292
292
|
* @param model - The model name
|
|
293
293
|
* @param select - Optional array of fields to select
|
|
294
|
-
* @returns Transformed data for
|
|
294
|
+
* @returns Transformed data for c15t or null if no data
|
|
295
295
|
*/
|
|
296
296
|
transformOutput(
|
|
297
297
|
data: Record<string, unknown>,
|
|
@@ -462,14 +462,14 @@ function checkMissingFields(
|
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
/**
|
|
465
|
-
* Creates a
|
|
465
|
+
* Creates a c15t adapter for Drizzle ORM
|
|
466
466
|
*
|
|
467
|
-
* This factory function creates an adapter that allows
|
|
467
|
+
* This factory function creates an adapter that allows c15t to use Drizzle ORM
|
|
468
468
|
* as its database layer. It supports PostgreSQL, MySQL, and SQLite.
|
|
469
469
|
*
|
|
470
470
|
* @param db - The Drizzle database instance
|
|
471
471
|
* @param config - Configuration options for the Drizzle adapter
|
|
472
|
-
* @returns A
|
|
472
|
+
* @returns A c15t adapter factory function
|
|
473
473
|
*
|
|
474
474
|
* @example
|
|
475
475
|
* ```typescript
|
|
@@ -483,15 +483,13 @@ function checkMissingFields(
|
|
|
483
483
|
* const connection = postgres('postgresql://user:password@localhost:5432/db');
|
|
484
484
|
* const db = drizzle(connection, { schema });
|
|
485
485
|
*
|
|
486
|
-
* // Create the
|
|
486
|
+
* // Create the c15t instance with Drizzle adapter
|
|
487
487
|
* const c15t = c15tInstance({
|
|
488
488
|
* storage: drizzleAdapter(db, {
|
|
489
489
|
* provider: 'pg',
|
|
490
490
|
* schema, // Pass your Drizzle schema
|
|
491
491
|
* usePlural: true
|
|
492
492
|
* }),
|
|
493
|
-
* // Other C15T options...
|
|
494
|
-
* secret: process.env.SECRET
|
|
495
493
|
* });
|
|
496
494
|
*
|
|
497
495
|
* // Use in your application
|
|
@@ -517,7 +515,6 @@ function checkMissingFields(
|
|
|
517
515
|
* storage: drizzleAdapter(db, {
|
|
518
516
|
* provider: 'mysql'
|
|
519
517
|
* }),
|
|
520
|
-
* secret: process.env.SECRET
|
|
521
518
|
* });
|
|
522
519
|
* ```
|
|
523
520
|
*/
|
|
@@ -78,7 +78,7 @@ function getDatabaseType(
|
|
|
78
78
|
* - Raw database connections (SQLite, MySQL, PostgreSQL)
|
|
79
79
|
* - Kysely dialect instances
|
|
80
80
|
*
|
|
81
|
-
* @param config - The
|
|
81
|
+
* @param config - The c15t configuration options containing database settings
|
|
82
82
|
* @returns An object containing the initialized Kysely instance and database type
|
|
83
83
|
*
|
|
84
84
|
* @example
|
|
@@ -103,7 +103,6 @@ function getDatabaseType(
|
|
|
103
103
|
*
|
|
104
104
|
* // Use in c15t configuration
|
|
105
105
|
* const c15t = c15tInstance({
|
|
106
|
-
* secret: process.env.SECRET_KEY,
|
|
107
106
|
* database: { db, type: 'postgres' } // Pre-configured Kysely instance
|
|
108
107
|
* });
|
|
109
108
|
* ```
|
|
@@ -124,7 +123,6 @@ function getDatabaseType(
|
|
|
124
123
|
*
|
|
125
124
|
* // Pass the pool directly to c15t
|
|
126
125
|
* const c15t = c15tInstance({
|
|
127
|
-
* secret: process.env.SECRET_KEY,
|
|
128
126
|
* database: pool // The adapter will detect it's a Postgres pool
|
|
129
127
|
* });
|
|
130
128
|
* ```
|
|
@@ -3,8 +3,8 @@ import { Kysely } from 'kysely';
|
|
|
3
3
|
import { KyselyPGlite } from 'kysely-pglite';
|
|
4
4
|
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
|
5
5
|
|
|
6
|
+
import { logger } from '@doubletie/logger';
|
|
6
7
|
import type { Adapter } from '~/pkgs/db-adapters';
|
|
7
|
-
import { logger } from '~/pkgs/logger';
|
|
8
8
|
import { getMigrations } from '~/pkgs/migrations';
|
|
9
9
|
import { type KyselyDatabaseType, kyselyAdapter } from '../index';
|
|
10
10
|
import type { Database } from '../types';
|
|
@@ -2,8 +2,8 @@ import { LibsqlDialect } from '@libsql/kysely-libsql';
|
|
|
2
2
|
import { Kysely, sql } from 'kysely';
|
|
3
3
|
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
|
4
4
|
|
|
5
|
+
import { logger } from '@doubletie/logger';
|
|
5
6
|
import type { Adapter } from '~/pkgs/db-adapters';
|
|
6
|
-
import { logger } from '~/pkgs/logger';
|
|
7
7
|
import { getMigrations } from '~/pkgs/migrations';
|
|
8
8
|
import { type KyselyDatabaseType, kyselyAdapter } from '../index';
|
|
9
9
|
import type { Database } from '../types';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Kysely, type Migration, sql } from 'kysely';
|
|
2
2
|
import { beforeEach, expect, test } from 'vitest';
|
|
3
3
|
|
|
4
|
+
import type { Logger } from '@doubletie/logger';
|
|
4
5
|
import type { Adapter } from '~/pkgs/db-adapters';
|
|
5
|
-
import type { Logger } from '~/pkgs/logger';
|
|
6
6
|
import type { C15TOptions } from '~/types';
|
|
7
7
|
import type { KyselyDatabaseType } from '../index';
|
|
8
8
|
import type { Database } from '../types';
|
|
@@ -36,7 +36,7 @@ export const expectedTables = [
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Helper to create
|
|
39
|
+
* Helper to create c15t options for a database
|
|
40
40
|
*/
|
|
41
41
|
export function createOptions(dbConfig: DbConfig): C15TOptions {
|
|
42
42
|
return {
|
|
@@ -159,7 +159,6 @@ export type SQLiteDatabaseConfig = SQLiteDatabase;
|
|
|
159
159
|
* // Use in c15t configuration
|
|
160
160
|
* const c15t = c15tInstance({
|
|
161
161
|
* storage: kyselyAdapter(dialectConfig),
|
|
162
|
-
* secret: process.env.SECRET_KEY
|
|
163
162
|
* });
|
|
164
163
|
* ```
|
|
165
164
|
*/
|
|
@@ -232,7 +231,6 @@ export interface DialectConfig {
|
|
|
232
231
|
* // Pass to c15t configuration
|
|
233
232
|
* const c15t = c15tInstance({
|
|
234
233
|
* storage: kyselyAdapter(config),
|
|
235
|
-
* secret: process.env.SECRET_KEY
|
|
236
234
|
* });
|
|
237
235
|
* ```
|
|
238
236
|
*/
|
|
@@ -330,7 +330,6 @@ const createEntityTransformer = (options: C15TOptions) => {
|
|
|
330
330
|
* // Create the c15t instance with memory adapter
|
|
331
331
|
* const c15t = c15tInstance({
|
|
332
332
|
* storage: memoryAdapter(db),
|
|
333
|
-
* secret: process.env.SECRET_KEY
|
|
334
333
|
* });
|
|
335
334
|
*
|
|
336
335
|
* // The database will be populated as records are created
|
|
@@ -319,7 +319,6 @@ const createEntityTransformer = (
|
|
|
319
319
|
* // Create the c15t instance with Prisma adapter
|
|
320
320
|
* const c15t = c15tInstance({
|
|
321
321
|
* storage: prismaAdapter(prisma, { provider: 'postgresql' }),
|
|
322
|
-
* secret: process.env.SECRET_KEY
|
|
323
322
|
* });
|
|
324
323
|
*
|
|
325
324
|
* // Use in your application
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createKyselyAdapter } from '~/pkgs/db-adapters';
|
|
2
|
-
import {
|
|
2
|
+
import { getLogger } from '~/pkgs/utils/logger';
|
|
3
3
|
import type { C15TOptions } from '~/types';
|
|
4
4
|
import { buildColumnAddMigrations } from './migration-builders';
|
|
5
5
|
import { buildTableCreateMigrations } from './migration-builders';
|
|
@@ -12,7 +12,7 @@ import type { MigrationResult } from './types';
|
|
|
12
12
|
* This is the main entry point for the migration system. It orchestrates
|
|
13
13
|
* the entire process from connecting to the database to generating migrations.
|
|
14
14
|
*
|
|
15
|
-
* @param config -
|
|
15
|
+
* @param config - c15t configuration containing database connection and schema details
|
|
16
16
|
*
|
|
17
17
|
* @returns MigrationResult containing:
|
|
18
18
|
* - toBeCreated: Tables that need to be created
|
|
@@ -37,7 +37,7 @@ import type { MigrationResult } from './types';
|
|
|
37
37
|
export async function getMigrations(
|
|
38
38
|
config: C15TOptions
|
|
39
39
|
): Promise<MigrationResult> {
|
|
40
|
-
const logger =
|
|
40
|
+
const logger = getLogger(config.logger);
|
|
41
41
|
|
|
42
42
|
// Initialize database connection
|
|
43
43
|
let { kysely: db, databaseType: dbType } = await createKyselyAdapter(config);
|
|
@@ -4,13 +4,13 @@ import { processTablesIntoSchema } from './process-tables';
|
|
|
4
4
|
import type { SchemaDefinition } from './types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Generates a complete database schema from the
|
|
7
|
+
* Generates a complete database schema from the c15t configuration
|
|
8
8
|
*
|
|
9
9
|
* This function serves as the main entry point for schema generation.
|
|
10
10
|
* It retrieves table definitions from the consent module and processes
|
|
11
11
|
* them into a structured schema representation.
|
|
12
12
|
*
|
|
13
|
-
* @param config - The complete
|
|
13
|
+
* @param config - The complete c15t configuration
|
|
14
14
|
* @returns A structured schema definition with fields and table properties
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Schema Generation Module
|
|
3
3
|
*
|
|
4
4
|
* This module handles the generation and processing of database schemas
|
|
5
|
-
* based on the
|
|
5
|
+
* based on the c15t configuration. It transforms table definitions into
|
|
6
6
|
* a structured schema representation that can be used for database operations.
|
|
7
7
|
*
|
|
8
8
|
* Example usage:
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
Database,
|
|
4
4
|
KyselyDatabaseType,
|
|
5
5
|
} from '~/pkgs/db-adapters/adapters/kysely-adapter/types';
|
|
6
|
-
import {
|
|
6
|
+
import { getLogger } from '~/pkgs/utils/logger';
|
|
7
7
|
import type { C15TOptions } from '~/types';
|
|
8
8
|
import { getType } from './type-mapping';
|
|
9
9
|
import type { ColumnsToAdd, MigrationOperation, TableToCreate } from './types';
|
|
@@ -83,7 +83,7 @@ export function buildTableCreateMigrations(
|
|
|
83
83
|
toBeCreated: TableToCreate[],
|
|
84
84
|
dbType: KyselyDatabaseType
|
|
85
85
|
): MigrationOperation[] {
|
|
86
|
-
const logger =
|
|
86
|
+
const logger = getLogger();
|
|
87
87
|
const migrations: MigrationOperation[] = [];
|
|
88
88
|
|
|
89
89
|
// Process each table that needs to be created
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLogger } from '~/pkgs/utils/logger';
|
|
2
2
|
import type { MigrationOperation } from './types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ import type { MigrationOperation } from './types';
|
|
|
8
8
|
* @returns Object with runMigrations and compileMigrations functions
|
|
9
9
|
*/
|
|
10
10
|
export function createMigrationExecutors(migrations: MigrationOperation[]) {
|
|
11
|
-
const logger =
|
|
11
|
+
const logger = getLogger();
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Executes all migration operations against the database
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { LoggerOptions } from '@doubletie/logger';
|
|
1
2
|
import type { TableMetadata } from 'kysely';
|
|
2
3
|
import type { Field } from '~/pkgs/data-model';
|
|
3
4
|
import type { KyselyDatabaseType } from '~/pkgs/db-adapters/adapters/kysely-adapter/types';
|
|
4
|
-
import {
|
|
5
|
+
import { getLogger } from '~/pkgs/utils/logger';
|
|
5
6
|
import type { C15TOptions } from '~/types';
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
import { getSchema } from './get-schema';
|
|
8
9
|
import { matchType } from './type-mapping';
|
|
9
10
|
import type {
|
|
@@ -44,7 +45,7 @@ export function analyzeSchemaChanges(
|
|
|
44
45
|
dbType: KyselyDatabaseType
|
|
45
46
|
): { toBeCreated: TableToCreate[]; toBeAdded: ColumnsToAdd[] } {
|
|
46
47
|
const betterAuthSchema = getSchema(config);
|
|
47
|
-
const logger =
|
|
48
|
+
const logger = getLogger(config.logger as LoggerOptions);
|
|
48
49
|
const toBeCreated: TableToCreate[] = [];
|
|
49
50
|
const toBeAdded: ColumnsToAdd[] = [];
|
|
50
51
|
|
|
@@ -160,7 +161,7 @@ function handleExistingTable(
|
|
|
160
161
|
table: TableMetadata,
|
|
161
162
|
toBeAdded: ColumnsToAdd[],
|
|
162
163
|
dbType: KyselyDatabaseType,
|
|
163
|
-
logger: ReturnType<typeof
|
|
164
|
+
logger: ReturnType<typeof getLogger>
|
|
164
165
|
): void {
|
|
165
166
|
// Collection of fields that need to be added to the existing table
|
|
166
167
|
const toBeAddedFields: Record<string, Field> = {};
|
|
@@ -59,7 +59,7 @@ describe('DoubleTieError', () => {
|
|
|
59
59
|
expect(error.message).toContain('HTTP error 404');
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
it('should extract error details from response data',
|
|
62
|
+
it('should extract error details from response data', () => {
|
|
63
63
|
const responseData = {
|
|
64
64
|
message: 'Resource not found',
|
|
65
65
|
code: ERROR_CODES.NOT_FOUND,
|
|
@@ -101,7 +101,7 @@ describe('DoubleTieError', () => {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
describe('toJSON', () => {
|
|
104
|
-
it('should serialize error to JSON with
|
|
104
|
+
it('should serialize error to JSON with oRPC compatible structure', () => {
|
|
105
105
|
const error = new DoubleTieError('Test error', {
|
|
106
106
|
code: ERROR_CODES.BAD_REQUEST,
|
|
107
107
|
status: 400,
|
|
@@ -111,11 +111,12 @@ describe('DoubleTieError', () => {
|
|
|
111
111
|
|
|
112
112
|
const errorJson = error.toJSON();
|
|
113
113
|
|
|
114
|
-
expect(errorJson.
|
|
114
|
+
expect(errorJson.status).toBe(400);
|
|
115
115
|
expect(errorJson.message).toBe('Test error');
|
|
116
|
-
expect(errorJson.
|
|
117
|
-
expect(errorJson.data
|
|
118
|
-
expect(errorJson.data
|
|
116
|
+
expect(errorJson.code).toBe(ERROR_CODES.BAD_REQUEST);
|
|
117
|
+
expect(errorJson.data.category).toBe(ERROR_CATEGORIES.VALIDATION);
|
|
118
|
+
expect(errorJson.data.meta).toEqual({ field: 'username' });
|
|
119
|
+
expect(errorJson.defined).toBe(true);
|
|
119
120
|
});
|
|
120
121
|
|
|
121
122
|
it('should include validation error message when present', () => {
|
|
@@ -128,7 +129,7 @@ describe('DoubleTieError', () => {
|
|
|
128
129
|
const errorJson = error.toJSON();
|
|
129
130
|
|
|
130
131
|
expect(errorJson.message).toBe('Field X is required');
|
|
131
|
-
expect(errorJson.data
|
|
132
|
+
expect(errorJson.data.originalMessage).toBe('Validation failed');
|
|
132
133
|
});
|
|
133
134
|
});
|
|
134
135
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ORPCError } from '@orpc/server';
|
|
2
2
|
import type { DoubleTieErrorOptions, ErrorMessageType } from '../types';
|
|
3
3
|
import { ERROR_CATEGORIES, ERROR_CODES } from './error-codes';
|
|
4
4
|
import { withSpan } from './tracing';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Custom error class for DoubleTie errors that extends
|
|
7
|
+
* Custom error class for DoubleTie errors that extends ORPCError.
|
|
8
8
|
*
|
|
9
|
-
* This class directly extends
|
|
9
|
+
* This class directly extends ORPCError to provide seamless integration with oRPC
|
|
10
10
|
* while adding application-specific error properties and context.
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
@@ -32,18 +32,7 @@ import { withSpan } from './tracing';
|
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
export class DoubleTieError extends
|
|
36
|
-
code: ErrorMessageType;
|
|
37
|
-
category?: string;
|
|
38
|
-
meta?: Record<string, unknown>;
|
|
39
|
-
originalMessage?: string;
|
|
40
|
-
}> {
|
|
41
|
-
/**
|
|
42
|
-
* Error code as defined in ERROR_CODES or custom error codes.
|
|
43
|
-
* Used to uniquely identify the error type.
|
|
44
|
-
*/
|
|
45
|
-
readonly code: ErrorMessageType;
|
|
46
|
-
|
|
35
|
+
export class DoubleTieError extends ORPCError<string, Record<string, unknown>> {
|
|
47
36
|
/**
|
|
48
37
|
* Error category that groups related errors.
|
|
49
38
|
* Defaults to 'unexpected' if not specified.
|
|
@@ -58,6 +47,11 @@ export class DoubleTieError extends H3Error<{
|
|
|
58
47
|
*/
|
|
59
48
|
readonly meta: Record<string, unknown>;
|
|
60
49
|
|
|
50
|
+
/**
|
|
51
|
+
* HTTP status code for the error
|
|
52
|
+
*/
|
|
53
|
+
readonly statusCode: number;
|
|
54
|
+
|
|
61
55
|
/**
|
|
62
56
|
* Creates a new DoubleTieError instance.
|
|
63
57
|
*
|
|
@@ -89,26 +83,25 @@ export class DoubleTieError extends H3Error<{
|
|
|
89
83
|
meta: {},
|
|
90
84
|
}
|
|
91
85
|
) {
|
|
92
|
-
|
|
86
|
+
// Call ORPCError constructor with code and options
|
|
87
|
+
super(options.code ?? ERROR_CODES.UNKNOWN_ERROR, {
|
|
88
|
+
message,
|
|
89
|
+
cause: options.cause,
|
|
90
|
+
data: options.meta ?? {},
|
|
91
|
+
});
|
|
93
92
|
|
|
94
|
-
//
|
|
95
|
-
this.name =
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
// Set name explicitly
|
|
94
|
+
this.name = 'DoubleTieError';
|
|
95
|
+
|
|
96
|
+
// Initialize additional properties
|
|
98
97
|
this.category = options.category ?? ERROR_CATEGORIES.UNEXPECTED;
|
|
99
98
|
this.meta = options.meta ?? {};
|
|
100
|
-
|
|
101
|
-
// Set H3Error data property with our structured data
|
|
102
|
-
this.data = {
|
|
103
|
-
code: this.code,
|
|
104
|
-
category: this.category,
|
|
105
|
-
meta: this.meta,
|
|
106
|
-
};
|
|
99
|
+
this.statusCode = options.status ?? 500;
|
|
107
100
|
|
|
108
101
|
// Add tracing after initialization
|
|
109
102
|
withSpan('create_doubletie_error', async (span) => {
|
|
110
103
|
span.setAttributes({
|
|
111
|
-
'error.name': this.name,
|
|
104
|
+
'error.name': this.constructor.name,
|
|
112
105
|
'error.message': message,
|
|
113
106
|
'error.code': this.code,
|
|
114
107
|
'error.status': this.statusCode,
|
|
@@ -143,17 +136,10 @@ export class DoubleTieError extends H3Error<{
|
|
|
143
136
|
}
|
|
144
137
|
|
|
145
138
|
/**
|
|
146
|
-
* Convert the error to a JSON-serializable object.
|
|
139
|
+
* Convert the error to a JSON-serializable object matching oRPC's error format.
|
|
140
|
+
* Override of the parent ORPCError toJSON method.
|
|
147
141
|
*/
|
|
148
|
-
toJSON()
|
|
149
|
-
H3Error<{
|
|
150
|
-
code: string;
|
|
151
|
-
category?: string;
|
|
152
|
-
meta?: Record<string, unknown>;
|
|
153
|
-
originalMessage?: string;
|
|
154
|
-
}>,
|
|
155
|
-
'message' | 'data' | 'statusCode' | 'statusMessage'
|
|
156
|
-
> {
|
|
142
|
+
toJSON() {
|
|
157
143
|
// Extract validation error details if present
|
|
158
144
|
const validationErrorMessage = this.meta?.validationErrors
|
|
159
145
|
? String(this.meta.validationErrors)
|
|
@@ -167,13 +153,15 @@ export class DoubleTieError extends H3Error<{
|
|
|
167
153
|
.filter((line) => line && !line.includes('Error: '))
|
|
168
154
|
: [];
|
|
169
155
|
|
|
170
|
-
// Create the result object with proper structure matching
|
|
156
|
+
// Create the result object with proper structure matching oRPC error format
|
|
171
157
|
return {
|
|
172
|
-
|
|
158
|
+
code: this.code,
|
|
173
159
|
message: validationErrorMessage || this.message,
|
|
174
|
-
|
|
160
|
+
// oRPC expects a status field rather than statusCode
|
|
161
|
+
status: this.statusCode,
|
|
162
|
+
// Required field in ORPCErrorJSON
|
|
163
|
+
defined: true,
|
|
175
164
|
data: {
|
|
176
|
-
code: this.code,
|
|
177
165
|
category: this.category,
|
|
178
166
|
meta: this.meta,
|
|
179
167
|
...(process.env.NODE_ENV === 'production' ? {} : { stack: stackTrace }),
|
|
@@ -268,7 +256,7 @@ export class DoubleTieError extends H3Error<{
|
|
|
268
256
|
const ErrorSubclass = class extends DoubleTieError {
|
|
269
257
|
constructor(message: string, options: DoubleTieErrorOptions) {
|
|
270
258
|
super(message, options);
|
|
271
|
-
this
|
|
259
|
+
Object.defineProperty(this, 'name', { value: name });
|
|
272
260
|
}
|
|
273
261
|
};
|
|
274
262
|
|
|
@@ -113,16 +113,6 @@ export {
|
|
|
113
113
|
withFallbackForCategory,
|
|
114
114
|
} from './results/recovery-utils';
|
|
115
115
|
|
|
116
|
-
// Export pipeline utilities
|
|
117
|
-
export { validationPipeline } from './pipeline/validation-pipeline';
|
|
118
|
-
export { retrievalPipeline } from './pipeline/retrieval-pipeline';
|
|
119
|
-
|
|
120
|
-
// Export H3.js integration helpers
|
|
121
|
-
export {
|
|
122
|
-
createH3ErrorHandler,
|
|
123
|
-
withH3ErrorHandling,
|
|
124
|
-
} from './h3-integration';
|
|
125
|
-
|
|
126
116
|
// Export telemetry options
|
|
127
117
|
export {
|
|
128
118
|
createTelemetryOptions,
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ORPCError } from '@orpc/server';
|
|
2
|
+
import { DoubleTieError } from './core/error-class';
|
|
3
|
+
import { ERROR_CODES } from './core/error-codes';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates an oRPC error handler middleware that properly handles DoubleTieError instances
|
|
7
|
+
*
|
|
8
|
+
* This utility ensures consistent error handling across your oRPC application and
|
|
9
|
+
* properly converts DoubleTieError objects to oRPC-compatible error responses.
|
|
10
|
+
*
|
|
11
|
+
* @returns An oRPC request handler middleware for error handling
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createORPCErrorHandler } from '@doubletie/results';
|
|
16
|
+
* import { OpenAPIHandler } from '@orpc/server';
|
|
17
|
+
*
|
|
18
|
+
* const handler = new OpenAPIHandler(router);
|
|
19
|
+
*
|
|
20
|
+
* // Register the error handler middleware
|
|
21
|
+
* handler.use(createORPCErrorHandler());
|
|
22
|
+
*
|
|
23
|
+
* // Your routes...
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function createORPCErrorHandler() {
|
|
27
|
+
return (
|
|
28
|
+
request: Request,
|
|
29
|
+
context: { logger?: { error: (message: string, data?: object) => void } }
|
|
30
|
+
) => {
|
|
31
|
+
// Add error handler to context
|
|
32
|
+
return {
|
|
33
|
+
context: {
|
|
34
|
+
_onError: (error: unknown) => {
|
|
35
|
+
context.logger?.error('Error in oRPC error handler', { error });
|
|
36
|
+
|
|
37
|
+
// Handle DoubleTieError instances
|
|
38
|
+
if (error instanceof DoubleTieError) {
|
|
39
|
+
context.logger?.error('Handling DoubleTieError', {
|
|
40
|
+
code: error.code,
|
|
41
|
+
message: error.message,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Convert DoubleTieError to ORPCError
|
|
45
|
+
throw new ORPCError(error.code, {
|
|
46
|
+
message: error.message,
|
|
47
|
+
cause: error.cause instanceof Error ? error.cause : undefined,
|
|
48
|
+
data: error.meta,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// For other errors, create a new ORPCError
|
|
53
|
+
context.logger?.error('Handling generic error', { error });
|
|
54
|
+
throw new ORPCError(ERROR_CODES.INTERNAL_SERVER_ERROR, {
|
|
55
|
+
message: error instanceof Error ? error.message : String(error),
|
|
56
|
+
cause: error instanceof Error ? error : undefined,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Wraps an oRPC handler with error handling for DoubleTieError
|
|
66
|
+
*
|
|
67
|
+
* @param handler - The handler function to wrap
|
|
68
|
+
* @returns A wrapped handler that automatically handles DoubleTieError instances
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { withORPCErrorHandling } from '@doubletie/results';
|
|
73
|
+
* import { os } from '@orpc/server';
|
|
74
|
+
*
|
|
75
|
+
* const getUserHandler = os.handler(async ({ input }) => {
|
|
76
|
+
* // Your handler code that might throw DoubleTieError
|
|
77
|
+
* throw new DoubleTieError('User not found', {
|
|
78
|
+
* code: ERROR_CODES.NOT_FOUND,
|
|
79
|
+
* status: 404
|
|
80
|
+
* });
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* // Wrap the handler with error handling
|
|
84
|
+
* const safeGetUserHandler = withORPCErrorHandling(getUserHandler);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function withORPCErrorHandling<TInput, TOutput>(
|
|
88
|
+
handler: (
|
|
89
|
+
input: TInput,
|
|
90
|
+
context: {
|
|
91
|
+
logger?: { error: (message: string, data?: object) => void };
|
|
92
|
+
_onError?: (error: unknown) => unknown;
|
|
93
|
+
}
|
|
94
|
+
) => Promise<TOutput> | TOutput
|
|
95
|
+
) {
|
|
96
|
+
return async (
|
|
97
|
+
input: TInput,
|
|
98
|
+
context: {
|
|
99
|
+
logger?: { error: (message: string, data?: object) => void };
|
|
100
|
+
_onError?: (error: unknown) => unknown;
|
|
101
|
+
}
|
|
102
|
+
) => {
|
|
103
|
+
try {
|
|
104
|
+
return await handler(input, context);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
context.logger?.error('Error caught in withORPCErrorHandling', {
|
|
107
|
+
error,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Handle DoubleTieError instances
|
|
111
|
+
if (error instanceof DoubleTieError) {
|
|
112
|
+
context.logger?.error('Handling DoubleTieError in wrapper', {
|
|
113
|
+
code: error.code,
|
|
114
|
+
message: error.message,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Convert DoubleTieError to ORPCError
|
|
118
|
+
throw new ORPCError(error.code, {
|
|
119
|
+
message: error.message,
|
|
120
|
+
cause: error.cause instanceof Error ? error.cause : undefined,
|
|
121
|
+
data: error.meta,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Use the context error handler if available
|
|
126
|
+
if (context._onError && typeof context._onError === 'function') {
|
|
127
|
+
return context._onError(error);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Create and throw a new ORPCError
|
|
131
|
+
throw new ORPCError(ERROR_CODES.INTERNAL_SERVER_ERROR, {
|
|
132
|
+
message: error instanceof Error ? error.message : String(error),
|
|
133
|
+
cause: error instanceof Error ? error : undefined,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|