@c15t/backend 1.0.5 → 1.2.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 +3 -3
- package/.turbo/turbo-test.log +531 -0
- 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 -76
- package/dist/core.d.ts.map +1 -1
- package/dist/{index.js → core.js} +1163 -1286
- 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.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 -4
- 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 -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/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/memory-adapter/index.cjs +17 -149
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.js +17 -149
- 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/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 -4
- 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 -3
- 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 -2
- 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 +22 -30
- 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 -159
- 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 -5
- 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 -13
- package/src/pkgs/db-adapters/adapters/kysely-adapter/dialect.ts +1 -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/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 -4
- package/src/pkgs/types/endpoints.ts +3 -5
- package/src/pkgs/types/options.ts +2 -3
- 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 -2
- package/src/types/plugins.ts +3 -4
- package/dist/index.cjs +0 -3701
- 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 -219
- 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
|
@@ -163,7 +163,7 @@ external_zod_namespaceObject.z.discriminatedUnion('type', [
|
|
|
163
163
|
numberArrayFieldSchema
|
|
164
164
|
]);
|
|
165
165
|
require("neverthrow");
|
|
166
|
-
const
|
|
166
|
+
const server_namespaceObject = require("@orpc/server");
|
|
167
167
|
const error_codes_ERROR_CODES = Object.freeze({
|
|
168
168
|
NOT_FOUND: 'Resource not found',
|
|
169
169
|
BAD_REQUEST: 'Bad request',
|
|
@@ -195,9 +195,9 @@ const ERROR_CATEGORIES = Object.freeze({
|
|
|
195
195
|
UNEXPECTED: 'unexpected'
|
|
196
196
|
});
|
|
197
197
|
const api_namespaceObject = require("@opentelemetry/api");
|
|
198
|
-
const
|
|
198
|
+
const tracer = api_namespaceObject.trace.getTracer('@doubletie/results');
|
|
199
199
|
async function tracing_withSpan(name, fn, attributes = {}) {
|
|
200
|
-
return await
|
|
200
|
+
return await tracer.startActiveSpan(name, async (span)=>{
|
|
201
201
|
try {
|
|
202
202
|
span.setAttributes(attributes);
|
|
203
203
|
const result = await fn(span);
|
|
@@ -230,10 +230,10 @@ async function tracing_withSpan(name, fn, attributes = {}) {
|
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
-
class error_class_DoubleTieError extends
|
|
234
|
-
code;
|
|
233
|
+
class error_class_DoubleTieError extends server_namespaceObject.ORPCError {
|
|
235
234
|
category;
|
|
236
235
|
meta;
|
|
236
|
+
statusCode;
|
|
237
237
|
constructor(message, options = {
|
|
238
238
|
code: error_codes_ERROR_CODES.UNKNOWN_ERROR,
|
|
239
239
|
status: 500,
|
|
@@ -241,22 +241,18 @@ class error_class_DoubleTieError extends external_h3_namespaceObject.H3Error {
|
|
|
241
241
|
cause: void 0,
|
|
242
242
|
meta: {}
|
|
243
243
|
}){
|
|
244
|
-
super(
|
|
245
|
-
|
|
244
|
+
super(options.code ?? error_codes_ERROR_CODES.UNKNOWN_ERROR, {
|
|
245
|
+
message,
|
|
246
|
+
cause: options.cause,
|
|
247
|
+
data: options.meta ?? {}
|
|
246
248
|
});
|
|
247
|
-
this.name =
|
|
248
|
-
this.code = options.code ?? error_codes_ERROR_CODES.UNKNOWN_ERROR;
|
|
249
|
-
this.statusCode = options.status ?? 500;
|
|
249
|
+
this.name = 'DoubleTieError';
|
|
250
250
|
this.category = options.category ?? ERROR_CATEGORIES.UNEXPECTED;
|
|
251
251
|
this.meta = options.meta ?? {};
|
|
252
|
-
this.
|
|
253
|
-
code: this.code,
|
|
254
|
-
category: this.category,
|
|
255
|
-
meta: this.meta
|
|
256
|
-
};
|
|
252
|
+
this.statusCode = options.status ?? 500;
|
|
257
253
|
tracing_withSpan('create_doubletie_error', async (span)=>{
|
|
258
254
|
span.setAttributes({
|
|
259
|
-
'error.name': this.name,
|
|
255
|
+
'error.name': this.constructor.name,
|
|
260
256
|
'error.message': message,
|
|
261
257
|
'error.code': this.code,
|
|
262
258
|
'error.status': this.statusCode,
|
|
@@ -276,11 +272,11 @@ class error_class_DoubleTieError extends external_h3_namespaceObject.H3Error {
|
|
|
276
272
|
const validationErrorMessage = this.meta?.validationErrors ? String(this.meta.validationErrors) : void 0;
|
|
277
273
|
const stackTrace = this.stack ? this.stack.split('\n').map((line)=>line.trim()).filter((line)=>line && !line.includes('Error: ')) : [];
|
|
278
274
|
return {
|
|
279
|
-
|
|
275
|
+
code: this.code,
|
|
280
276
|
message: validationErrorMessage || this.message,
|
|
281
|
-
|
|
277
|
+
status: this.statusCode,
|
|
278
|
+
defined: true,
|
|
282
279
|
data: {
|
|
283
|
-
code: this.code,
|
|
284
280
|
category: this.category,
|
|
285
281
|
meta: this.meta,
|
|
286
282
|
...'production' === process.env.NODE_ENV ? {} : {
|
|
@@ -331,7 +327,9 @@ class error_class_DoubleTieError extends external_h3_namespaceObject.H3Error {
|
|
|
331
327
|
const ErrorSubclass = class extends error_class_DoubleTieError {
|
|
332
328
|
constructor(message, options){
|
|
333
329
|
super(message, options);
|
|
334
|
-
this
|
|
330
|
+
Object.defineProperty(this, 'name', {
|
|
331
|
+
value: name
|
|
332
|
+
});
|
|
335
333
|
}
|
|
336
334
|
};
|
|
337
335
|
Object.defineProperty(ErrorSubclass, 'name', {
|
|
@@ -348,137 +346,7 @@ class error_class_DoubleTieError extends external_h3_namespaceObject.H3Error {
|
|
|
348
346
|
return formattedMessage;
|
|
349
347
|
}
|
|
350
348
|
}
|
|
351
|
-
const
|
|
352
|
-
reset: '\x1b[0m',
|
|
353
|
-
bright: '\x1b[1m',
|
|
354
|
-
dim: '\x1b[2m',
|
|
355
|
-
underscore: '\x1b[4m',
|
|
356
|
-
blink: '\x1b[5m',
|
|
357
|
-
reverse: '\x1b[7m',
|
|
358
|
-
hidden: '\x1b[8m',
|
|
359
|
-
fg: {
|
|
360
|
-
black: '\x1b[30m',
|
|
361
|
-
red: '\x1b[31m',
|
|
362
|
-
green: '\x1b[32m',
|
|
363
|
-
yellow: '\x1b[33m',
|
|
364
|
-
blue: '\x1b[34m',
|
|
365
|
-
magenta: '\x1b[35m',
|
|
366
|
-
cyan: '\x1b[36m',
|
|
367
|
-
white: '\x1b[37m'
|
|
368
|
-
},
|
|
369
|
-
bg: {
|
|
370
|
-
black: '\x1b[40m',
|
|
371
|
-
red: '\x1b[41m',
|
|
372
|
-
green: '\x1b[42m',
|
|
373
|
-
yellow: '\x1b[43m',
|
|
374
|
-
blue: '\x1b[44m',
|
|
375
|
-
magenta: '\x1b[45m',
|
|
376
|
-
cyan: '\x1b[46m',
|
|
377
|
-
white: '\x1b[47m'
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
const levelColors = {
|
|
381
|
-
info: colors.fg.blue,
|
|
382
|
-
success: colors.fg.green,
|
|
383
|
-
warn: colors.fg.yellow,
|
|
384
|
-
error: colors.fg.red,
|
|
385
|
-
debug: colors.fg.magenta
|
|
386
|
-
};
|
|
387
|
-
const formatMessage = (level, message, appName = 'c15t')=>{
|
|
388
|
-
const timestamp = new Date().toISOString();
|
|
389
|
-
return `${colors.dim}${timestamp}${colors.reset} ${levelColors[level]}${level.toUpperCase()}${colors.reset} ${colors.bright}[${appName}]:${colors.reset} ${message}`;
|
|
390
|
-
};
|
|
391
|
-
const levels = [
|
|
392
|
-
'error',
|
|
393
|
-
'warn',
|
|
394
|
-
'info',
|
|
395
|
-
'success',
|
|
396
|
-
'debug'
|
|
397
|
-
];
|
|
398
|
-
function shouldPublishLog(currentLogLevel, logLevel) {
|
|
399
|
-
const currentLevelIndex = levels.indexOf(currentLogLevel);
|
|
400
|
-
const messageLevelIndex = levels.indexOf(logLevel);
|
|
401
|
-
if ('debug' === currentLogLevel) return 'debug' === logLevel;
|
|
402
|
-
return messageLevelIndex <= currentLevelIndex;
|
|
403
|
-
}
|
|
404
|
-
const LOGGER_TRACER_NAME = '@doubletie/logger';
|
|
405
|
-
const LOG_LEVEL_TO_SPAN_STATUS = {
|
|
406
|
-
error: api_namespaceObject.SpanStatusCode.ERROR,
|
|
407
|
-
warn: api_namespaceObject.SpanStatusCode.OK,
|
|
408
|
-
info: api_namespaceObject.SpanStatusCode.OK,
|
|
409
|
-
success: api_namespaceObject.SpanStatusCode.OK,
|
|
410
|
-
debug: api_namespaceObject.SpanStatusCode.OK
|
|
411
|
-
};
|
|
412
|
-
const telemetry_getTracer = (options)=>{
|
|
413
|
-
if (options?.telemetry?.tracer) return options.telemetry.tracer;
|
|
414
|
-
return api_namespaceObject.trace.getTracer(LOGGER_TRACER_NAME);
|
|
415
|
-
};
|
|
416
|
-
const createLogSpan = (level, message, args = [], options)=>{
|
|
417
|
-
if (options?.telemetry?.disabled) return null;
|
|
418
|
-
const tracer = telemetry_getTracer(options);
|
|
419
|
-
const span = tracer.startSpan('log_entry', {
|
|
420
|
-
attributes: {
|
|
421
|
-
'log.level': level,
|
|
422
|
-
'log.message': message,
|
|
423
|
-
'log.has_args': args.length > 0,
|
|
424
|
-
...options?.telemetry?.defaultAttributes || {}
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
if (args.length > 0 && 'object' == typeof args[0] && null !== args[0]) {
|
|
428
|
-
const data = args[0];
|
|
429
|
-
for (const [key, value] of Object.entries(data))if (null != value) span.setAttribute(`log.data.${key}`, String(value));
|
|
430
|
-
}
|
|
431
|
-
span.setStatus({
|
|
432
|
-
code: LOG_LEVEL_TO_SPAN_STATUS[level],
|
|
433
|
-
message: 'error' === level || 'warn' === level ? message : void 0
|
|
434
|
-
});
|
|
435
|
-
return span;
|
|
436
|
-
};
|
|
437
|
-
const withLogSpan = async (level, message, args, operation, options)=>{
|
|
438
|
-
const span = createLogSpan(level, message, args, options);
|
|
439
|
-
if (!span) return operation();
|
|
440
|
-
try {
|
|
441
|
-
const result = await operation();
|
|
442
|
-
return result;
|
|
443
|
-
} catch (error) {
|
|
444
|
-
span.setStatus({
|
|
445
|
-
code: api_namespaceObject.SpanStatusCode.ERROR,
|
|
446
|
-
message: error instanceof Error ? error.message : String(error)
|
|
447
|
-
});
|
|
448
|
-
throw error;
|
|
449
|
-
} finally{
|
|
450
|
-
span.end();
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
const createLogger = (options)=>{
|
|
454
|
-
if (options && 'object' == typeof options && levels.every((level)=>'function' == typeof options[level])) return options;
|
|
455
|
-
const loggerOptions = options;
|
|
456
|
-
const enabled = loggerOptions?.disabled !== true;
|
|
457
|
-
const logLevel = loggerOptions?.level ?? 'error';
|
|
458
|
-
const appName = loggerOptions?.appName ?? 'c15t';
|
|
459
|
-
const logFunc = async (level, message, args = [])=>{
|
|
460
|
-
if (!enabled || !shouldPublishLog(logLevel, level)) return;
|
|
461
|
-
await withLogSpan(level, message, args, async ()=>{
|
|
462
|
-
const formattedMessage = formatMessage(level, message, appName);
|
|
463
|
-
if (!loggerOptions || 'function' != typeof loggerOptions.log) {
|
|
464
|
-
if ('error' === level) console.error(formattedMessage, ...args);
|
|
465
|
-
else if ('warn' === level) console.warn(formattedMessage, ...args);
|
|
466
|
-
else if ('info' === level) console.log(formattedMessage, ...args);
|
|
467
|
-
else if ('debug' === level) console.debug(formattedMessage, ...args);
|
|
468
|
-
else if ('success' === level) console.log(formattedMessage, ...args);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
loggerOptions.log('success' === level ? 'info' : level, message, ...args);
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
return Object.fromEntries(levels.map((level)=>[
|
|
475
|
-
level,
|
|
476
|
-
(...[message, ...args])=>logFunc(level, message, args).catch((error)=>{
|
|
477
|
-
console.error('Logger error:', error);
|
|
478
|
-
})
|
|
479
|
-
]));
|
|
480
|
-
};
|
|
481
|
-
createLogger();
|
|
349
|
+
const logger_namespaceObject = require("@doubletie/logger");
|
|
482
350
|
const schema_auditLogSchema = external_zod_namespaceObject.z.object({
|
|
483
351
|
id: external_zod_namespaceObject.z.string(),
|
|
484
352
|
entityType: external_zod_namespaceObject.z.string(),
|
|
@@ -1788,9 +1656,19 @@ const createKyselyAdapter = async (config)=>{
|
|
|
1788
1656
|
databaseType
|
|
1789
1657
|
};
|
|
1790
1658
|
};
|
|
1659
|
+
let globalLogger;
|
|
1660
|
+
function getLogger(options) {
|
|
1661
|
+
if (!globalLogger) globalLogger = (0, logger_namespaceObject.createLogger)({
|
|
1662
|
+
level: 'info',
|
|
1663
|
+
appName: 'c15t',
|
|
1664
|
+
...options
|
|
1665
|
+
});
|
|
1666
|
+
return globalLogger;
|
|
1667
|
+
}
|
|
1791
1668
|
async function getAdapter(options) {
|
|
1792
|
-
const logger =
|
|
1793
|
-
appName: 'c15t'
|
|
1669
|
+
const logger = getLogger({
|
|
1670
|
+
appName: options.appName ?? 'c15t',
|
|
1671
|
+
...options.logger
|
|
1794
1672
|
});
|
|
1795
1673
|
if (!options.database) {
|
|
1796
1674
|
const tables = getConsentTables(options);
|
|
@@ -2,8 +2,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_superjson__ from "superjson";
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_base_x_aeb88370__ from "base-x";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_zod__ from "zod";
|
|
4
4
|
import "neverthrow";
|
|
5
|
-
import * as
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__orpc_server_0dae8408__ from "@orpc/server";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__ from "@opentelemetry/api";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__doubletie_logger_91c58a8f__ from "@doubletie/logger";
|
|
7
8
|
import "node:crypto";
|
|
8
9
|
import * as __WEBPACK_EXTERNAL_MODULE_drizzle_orm_51e552b8__ from "drizzle-orm";
|
|
9
10
|
import * as __WEBPACK_EXTERNAL_MODULE_kysely__ from "kysely";
|
|
@@ -153,9 +154,9 @@ const ERROR_CATEGORIES = Object.freeze({
|
|
|
153
154
|
CONFIGURATION: 'configuration',
|
|
154
155
|
UNEXPECTED: 'unexpected'
|
|
155
156
|
});
|
|
156
|
-
const
|
|
157
|
+
const tracer = __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.trace.getTracer('@doubletie/results');
|
|
157
158
|
async function tracing_withSpan(name, fn, attributes = {}) {
|
|
158
|
-
return await
|
|
159
|
+
return await tracer.startActiveSpan(name, async (span)=>{
|
|
159
160
|
try {
|
|
160
161
|
span.setAttributes(attributes);
|
|
161
162
|
const result = await fn(span);
|
|
@@ -188,10 +189,10 @@ async function tracing_withSpan(name, fn, attributes = {}) {
|
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
191
|
}
|
|
191
|
-
class error_class_DoubleTieError extends
|
|
192
|
-
code;
|
|
192
|
+
class error_class_DoubleTieError extends __WEBPACK_EXTERNAL_MODULE__orpc_server_0dae8408__.ORPCError {
|
|
193
193
|
category;
|
|
194
194
|
meta;
|
|
195
|
+
statusCode;
|
|
195
196
|
constructor(message, options = {
|
|
196
197
|
code: error_codes_ERROR_CODES.UNKNOWN_ERROR,
|
|
197
198
|
status: 500,
|
|
@@ -199,22 +200,18 @@ class error_class_DoubleTieError extends __WEBPACK_EXTERNAL_MODULE_h3__.H3Error
|
|
|
199
200
|
cause: void 0,
|
|
200
201
|
meta: {}
|
|
201
202
|
}){
|
|
202
|
-
super(
|
|
203
|
-
|
|
203
|
+
super(options.code ?? error_codes_ERROR_CODES.UNKNOWN_ERROR, {
|
|
204
|
+
message,
|
|
205
|
+
cause: options.cause,
|
|
206
|
+
data: options.meta ?? {}
|
|
204
207
|
});
|
|
205
|
-
this.name =
|
|
206
|
-
this.code = options.code ?? error_codes_ERROR_CODES.UNKNOWN_ERROR;
|
|
207
|
-
this.statusCode = options.status ?? 500;
|
|
208
|
+
this.name = 'DoubleTieError';
|
|
208
209
|
this.category = options.category ?? ERROR_CATEGORIES.UNEXPECTED;
|
|
209
210
|
this.meta = options.meta ?? {};
|
|
210
|
-
this.
|
|
211
|
-
code: this.code,
|
|
212
|
-
category: this.category,
|
|
213
|
-
meta: this.meta
|
|
214
|
-
};
|
|
211
|
+
this.statusCode = options.status ?? 500;
|
|
215
212
|
tracing_withSpan('create_doubletie_error', async (span)=>{
|
|
216
213
|
span.setAttributes({
|
|
217
|
-
'error.name': this.name,
|
|
214
|
+
'error.name': this.constructor.name,
|
|
218
215
|
'error.message': message,
|
|
219
216
|
'error.code': this.code,
|
|
220
217
|
'error.status': this.statusCode,
|
|
@@ -234,11 +231,11 @@ class error_class_DoubleTieError extends __WEBPACK_EXTERNAL_MODULE_h3__.H3Error
|
|
|
234
231
|
const validationErrorMessage = this.meta?.validationErrors ? String(this.meta.validationErrors) : void 0;
|
|
235
232
|
const stackTrace = this.stack ? this.stack.split('\n').map((line)=>line.trim()).filter((line)=>line && !line.includes('Error: ')) : [];
|
|
236
233
|
return {
|
|
237
|
-
|
|
234
|
+
code: this.code,
|
|
238
235
|
message: validationErrorMessage || this.message,
|
|
239
|
-
|
|
236
|
+
status: this.statusCode,
|
|
237
|
+
defined: true,
|
|
240
238
|
data: {
|
|
241
|
-
code: this.code,
|
|
242
239
|
category: this.category,
|
|
243
240
|
meta: this.meta,
|
|
244
241
|
...'production' === process.env.NODE_ENV ? {} : {
|
|
@@ -289,7 +286,9 @@ class error_class_DoubleTieError extends __WEBPACK_EXTERNAL_MODULE_h3__.H3Error
|
|
|
289
286
|
const ErrorSubclass = class extends error_class_DoubleTieError {
|
|
290
287
|
constructor(message, options){
|
|
291
288
|
super(message, options);
|
|
292
|
-
this
|
|
289
|
+
Object.defineProperty(this, 'name', {
|
|
290
|
+
value: name
|
|
291
|
+
});
|
|
293
292
|
}
|
|
294
293
|
};
|
|
295
294
|
Object.defineProperty(ErrorSubclass, 'name', {
|
|
@@ -306,137 +305,6 @@ class error_class_DoubleTieError extends __WEBPACK_EXTERNAL_MODULE_h3__.H3Error
|
|
|
306
305
|
return formattedMessage;
|
|
307
306
|
}
|
|
308
307
|
}
|
|
309
|
-
const levels = [
|
|
310
|
-
'error',
|
|
311
|
-
'warn',
|
|
312
|
-
'info',
|
|
313
|
-
'success',
|
|
314
|
-
'debug'
|
|
315
|
-
];
|
|
316
|
-
function shouldPublishLog(currentLogLevel, logLevel) {
|
|
317
|
-
const currentLevelIndex = levels.indexOf(currentLogLevel);
|
|
318
|
-
const messageLevelIndex = levels.indexOf(logLevel);
|
|
319
|
-
if ('debug' === currentLogLevel) return 'debug' === logLevel;
|
|
320
|
-
return messageLevelIndex <= currentLevelIndex;
|
|
321
|
-
}
|
|
322
|
-
const colors = {
|
|
323
|
-
reset: '\x1b[0m',
|
|
324
|
-
bright: '\x1b[1m',
|
|
325
|
-
dim: '\x1b[2m',
|
|
326
|
-
underscore: '\x1b[4m',
|
|
327
|
-
blink: '\x1b[5m',
|
|
328
|
-
reverse: '\x1b[7m',
|
|
329
|
-
hidden: '\x1b[8m',
|
|
330
|
-
fg: {
|
|
331
|
-
black: '\x1b[30m',
|
|
332
|
-
red: '\x1b[31m',
|
|
333
|
-
green: '\x1b[32m',
|
|
334
|
-
yellow: '\x1b[33m',
|
|
335
|
-
blue: '\x1b[34m',
|
|
336
|
-
magenta: '\x1b[35m',
|
|
337
|
-
cyan: '\x1b[36m',
|
|
338
|
-
white: '\x1b[37m'
|
|
339
|
-
},
|
|
340
|
-
bg: {
|
|
341
|
-
black: '\x1b[40m',
|
|
342
|
-
red: '\x1b[41m',
|
|
343
|
-
green: '\x1b[42m',
|
|
344
|
-
yellow: '\x1b[43m',
|
|
345
|
-
blue: '\x1b[44m',
|
|
346
|
-
magenta: '\x1b[45m',
|
|
347
|
-
cyan: '\x1b[46m',
|
|
348
|
-
white: '\x1b[47m'
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
const levelColors = {
|
|
352
|
-
info: colors.fg.blue,
|
|
353
|
-
success: colors.fg.green,
|
|
354
|
-
warn: colors.fg.yellow,
|
|
355
|
-
error: colors.fg.red,
|
|
356
|
-
debug: colors.fg.magenta
|
|
357
|
-
};
|
|
358
|
-
const formatMessage = (level, message, appName = 'c15t')=>{
|
|
359
|
-
const timestamp = new Date().toISOString();
|
|
360
|
-
return `${colors.dim}${timestamp}${colors.reset} ${levelColors[level]}${level.toUpperCase()}${colors.reset} ${colors.bright}[${appName}]:${colors.reset} ${message}`;
|
|
361
|
-
};
|
|
362
|
-
const LOGGER_TRACER_NAME = '@doubletie/logger';
|
|
363
|
-
const LOG_LEVEL_TO_SPAN_STATUS = {
|
|
364
|
-
error: __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.SpanStatusCode.ERROR,
|
|
365
|
-
warn: __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.SpanStatusCode.OK,
|
|
366
|
-
info: __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.SpanStatusCode.OK,
|
|
367
|
-
success: __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.SpanStatusCode.OK,
|
|
368
|
-
debug: __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.SpanStatusCode.OK
|
|
369
|
-
};
|
|
370
|
-
const telemetry_getTracer = (options)=>{
|
|
371
|
-
if (options?.telemetry?.tracer) return options.telemetry.tracer;
|
|
372
|
-
return __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.trace.getTracer(LOGGER_TRACER_NAME);
|
|
373
|
-
};
|
|
374
|
-
const createLogSpan = (level, message, args = [], options)=>{
|
|
375
|
-
if (options?.telemetry?.disabled) return null;
|
|
376
|
-
const tracer = telemetry_getTracer(options);
|
|
377
|
-
const span = tracer.startSpan('log_entry', {
|
|
378
|
-
attributes: {
|
|
379
|
-
'log.level': level,
|
|
380
|
-
'log.message': message,
|
|
381
|
-
'log.has_args': args.length > 0,
|
|
382
|
-
...options?.telemetry?.defaultAttributes || {}
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
if (args.length > 0 && 'object' == typeof args[0] && null !== args[0]) {
|
|
386
|
-
const data = args[0];
|
|
387
|
-
for (const [key, value] of Object.entries(data))if (null != value) span.setAttribute(`log.data.${key}`, String(value));
|
|
388
|
-
}
|
|
389
|
-
span.setStatus({
|
|
390
|
-
code: LOG_LEVEL_TO_SPAN_STATUS[level],
|
|
391
|
-
message: 'error' === level || 'warn' === level ? message : void 0
|
|
392
|
-
});
|
|
393
|
-
return span;
|
|
394
|
-
};
|
|
395
|
-
const withLogSpan = async (level, message, args, operation, options)=>{
|
|
396
|
-
const span = createLogSpan(level, message, args, options);
|
|
397
|
-
if (!span) return operation();
|
|
398
|
-
try {
|
|
399
|
-
const result = await operation();
|
|
400
|
-
return result;
|
|
401
|
-
} catch (error) {
|
|
402
|
-
span.setStatus({
|
|
403
|
-
code: __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__.SpanStatusCode.ERROR,
|
|
404
|
-
message: error instanceof Error ? error.message : String(error)
|
|
405
|
-
});
|
|
406
|
-
throw error;
|
|
407
|
-
} finally{
|
|
408
|
-
span.end();
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
const createLogger = (options)=>{
|
|
412
|
-
if (options && 'object' == typeof options && levels.every((level)=>'function' == typeof options[level])) return options;
|
|
413
|
-
const loggerOptions = options;
|
|
414
|
-
const enabled = loggerOptions?.disabled !== true;
|
|
415
|
-
const logLevel = loggerOptions?.level ?? 'error';
|
|
416
|
-
const appName = loggerOptions?.appName ?? 'c15t';
|
|
417
|
-
const logFunc = async (level, message, args = [])=>{
|
|
418
|
-
if (!enabled || !shouldPublishLog(logLevel, level)) return;
|
|
419
|
-
await withLogSpan(level, message, args, async ()=>{
|
|
420
|
-
const formattedMessage = formatMessage(level, message, appName);
|
|
421
|
-
if (!loggerOptions || 'function' != typeof loggerOptions.log) {
|
|
422
|
-
if ('error' === level) console.error(formattedMessage, ...args);
|
|
423
|
-
else if ('warn' === level) console.warn(formattedMessage, ...args);
|
|
424
|
-
else if ('info' === level) console.log(formattedMessage, ...args);
|
|
425
|
-
else if ('debug' === level) console.debug(formattedMessage, ...args);
|
|
426
|
-
else if ('success' === level) console.log(formattedMessage, ...args);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
loggerOptions.log('success' === level ? 'info' : level, message, ...args);
|
|
430
|
-
});
|
|
431
|
-
};
|
|
432
|
-
return Object.fromEntries(levels.map((level)=>[
|
|
433
|
-
level,
|
|
434
|
-
(...[message, ...args])=>logFunc(level, message, args).catch((error)=>{
|
|
435
|
-
console.error('Logger error:', error);
|
|
436
|
-
})
|
|
437
|
-
]));
|
|
438
|
-
};
|
|
439
|
-
createLogger();
|
|
440
308
|
const schema_auditLogSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
441
309
|
id: __WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
442
310
|
entityType: __WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
@@ -1743,9 +1611,19 @@ const createKyselyAdapter = async (config)=>{
|
|
|
1743
1611
|
databaseType
|
|
1744
1612
|
};
|
|
1745
1613
|
};
|
|
1614
|
+
let globalLogger;
|
|
1615
|
+
function getLogger(options) {
|
|
1616
|
+
if (!globalLogger) globalLogger = (0, __WEBPACK_EXTERNAL_MODULE__doubletie_logger_91c58a8f__.createLogger)({
|
|
1617
|
+
level: 'info',
|
|
1618
|
+
appName: 'c15t',
|
|
1619
|
+
...options
|
|
1620
|
+
});
|
|
1621
|
+
return globalLogger;
|
|
1622
|
+
}
|
|
1746
1623
|
async function getAdapter(options) {
|
|
1747
|
-
const logger =
|
|
1748
|
-
appName: 'c15t'
|
|
1624
|
+
const logger = getLogger({
|
|
1625
|
+
appName: options.appName ?? 'c15t',
|
|
1626
|
+
...options.logger
|
|
1749
1627
|
});
|
|
1750
1628
|
if (!options.database) {
|
|
1751
1629
|
const tables = getConsentTables(options);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { C15TOptions } from '../../../types';
|
|
2
2
|
import type { SchemaDefinition } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Generates a complete database schema from the
|
|
4
|
+
* Generates a complete database schema from the c15t configuration
|
|
5
5
|
*
|
|
6
6
|
* This function serves as the main entry point for schema generation.
|
|
7
7
|
* It retrieves table definitions from the consent module and processes
|
|
8
8
|
* them into a structured schema representation.
|
|
9
9
|
*
|
|
10
|
-
* @param config - The complete
|
|
10
|
+
* @param config - The complete c15t configuration
|
|
11
11
|
* @returns A structured schema definition with fields and table properties
|
|
12
12
|
*
|
|
13
13
|
* @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:
|