@c15t/backend 1.2.0-canary.13 → 1.2.0-canary.2
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 +20 -22
- package/.turbo/turbo-fmt.log +4 -4
- 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 +2 -2
- package/dist/contracts/consent/post.contract.d.ts +2 -2
- package/dist/contracts/consent/post.contract.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +5 -5
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/core.cjs +244 -388
- package/dist/core.d.ts +5 -3
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +244 -388
- package/dist/handlers/consent/index.d.ts +2 -2
- package/dist/handlers/consent/post.handler.d.ts +2 -2
- package/dist/handlers/consent/show-banner.handler.d.ts.map +1 -1
- package/dist/pkgs/api-router/utils/core.test.d.ts +2 -0
- package/dist/pkgs/api-router/utils/core.test.d.ts.map +1 -0
- package/dist/pkgs/api-router/utils/cors.d.ts +14 -0
- package/dist/pkgs/api-router/utils/cors.d.ts.map +1 -0
- package/dist/pkgs/data-model/fields/zod-fields.d.ts +32 -32
- package/dist/pkgs/data-model/index.cjs +39 -59
- package/dist/pkgs/data-model/index.js +39 -59
- package/dist/pkgs/data-model/schema/index.cjs +39 -59
- package/dist/pkgs/data-model/schema/index.js +39 -59
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.cjs +1 -0
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.js +1 -0
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.cjs +1 -0
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.js +1 -0
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.cjs +1 -0
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.js +1 -0
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.cjs +1 -0
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.js +1 -0
- package/dist/pkgs/db-adapters/index.cjs +1 -0
- package/dist/pkgs/db-adapters/index.js +1 -0
- package/dist/pkgs/migrations/index.cjs +1 -0
- package/dist/pkgs/migrations/index.js +1 -0
- package/dist/router.cjs +5 -3
- package/dist/router.d.ts +2 -2
- package/dist/router.js +5 -3
- package/dist/schema/consent-policy/registry.d.ts +4 -4
- package/dist/schema/consent-policy/registry.d.ts.map +1 -1
- package/dist/schema/consent-policy/schema.d.ts +2 -2
- package/dist/schema/consent-policy/table.d.ts +2 -2
- package/dist/schema/consent-purpose/registry.d.ts +2 -2
- package/dist/schema/consent-purpose/schema.d.ts +2 -2
- package/dist/schema/consent-purpose/table.d.ts +2 -2
- package/dist/schema/create-registry.d.ts +6 -6
- package/dist/schema/create-registry.d.ts.map +1 -1
- package/dist/schema/definition.d.ts +4 -4
- package/dist/schema/index.cjs +39 -59
- package/dist/schema/index.js +39 -59
- package/dist/schema/schemas.d.ts +4 -4
- package/package.json +2 -8
- package/rslib.config.ts +0 -1
- package/src/contracts/consent/post.contract.ts +6 -1
- package/src/contracts/index.ts +0 -2
- package/src/core.ts +195 -96
- package/src/handlers/consent/show-banner.handler.test.ts +1 -1
- package/src/handlers/consent/show-banner.handler.ts +2 -1
- package/src/{middleware/cors/is-origin-trusted.test.ts → pkgs/api-router/utils/core.test.ts} +1 -1
- package/src/pkgs/api-router/utils/cors.ts +73 -0
- package/src/schema/consent-policy/registry.ts +50 -76
- package/src/server.ts +5 -1
- package/dist/__tests__/server.test.d.ts +0 -2
- package/dist/__tests__/server.test.d.ts.map +0 -1
- package/dist/contracts.cjs +0 -708
- package/dist/contracts.js +0 -661
- package/dist/middleware/cors/cors.d.ts +0 -37
- package/dist/middleware/cors/cors.d.ts.map +0 -1
- package/dist/middleware/cors/cors.test.d.ts +0 -2
- package/dist/middleware/cors/cors.test.d.ts.map +0 -1
- package/dist/middleware/cors/index.d.ts +0 -30
- package/dist/middleware/cors/index.d.ts.map +0 -1
- package/dist/middleware/cors/is-origin-trusted.d.ts +0 -49
- package/dist/middleware/cors/is-origin-trusted.d.ts.map +0 -1
- package/dist/middleware/cors/is-origin-trusted.test.d.ts +0 -2
- package/dist/middleware/cors/is-origin-trusted.test.d.ts.map +0 -1
- package/dist/middleware/cors/process-cors.d.ts +0 -31
- package/dist/middleware/cors/process-cors.d.ts.map +0 -1
- package/dist/middleware/openapi/config.d.ts +0 -28
- package/dist/middleware/openapi/config.d.ts.map +0 -1
- package/dist/middleware/openapi/handlers.d.ts +0 -29
- package/dist/middleware/openapi/handlers.d.ts.map +0 -1
- package/dist/middleware/openapi/index.d.ts +0 -11
- package/dist/middleware/openapi/index.d.ts.map +0 -1
- package/src/__tests__/server.test.ts +0 -96
- package/src/middleware/cors/cors.test.ts +0 -419
- package/src/middleware/cors/cors.ts +0 -192
- package/src/middleware/cors/index.ts +0 -30
- package/src/middleware/cors/is-origin-trusted.ts +0 -126
- package/src/middleware/cors/process-cors.ts +0 -91
- package/src/middleware/openapi/config.ts +0 -28
- package/src/middleware/openapi/handlers.ts +0 -132
- package/src/middleware/openapi/index.ts +0 -11
|
@@ -83,8 +83,8 @@ export declare const consentHandlers: {
|
|
|
83
83
|
metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
84
84
|
givenAt: import("zod").ZodDate;
|
|
85
85
|
}, "strip", import("zod").ZodTypeAny, {
|
|
86
|
-
status: string;
|
|
87
86
|
type: "cookie_banner" | "privacy_policy" | "dpa" | "terms_and_conditions" | "marketing_communications" | "age_verification" | "other";
|
|
87
|
+
status: string;
|
|
88
88
|
id: string;
|
|
89
89
|
domain: string;
|
|
90
90
|
domainId: string;
|
|
@@ -94,8 +94,8 @@ export declare const consentHandlers: {
|
|
|
94
94
|
metadata?: Record<string, unknown> | undefined;
|
|
95
95
|
externalSubjectId?: string | undefined;
|
|
96
96
|
}, {
|
|
97
|
-
status: string;
|
|
98
97
|
type: "cookie_banner" | "privacy_policy" | "dpa" | "terms_and_conditions" | "marketing_communications" | "age_verification" | "other";
|
|
98
|
+
status: string;
|
|
99
99
|
id: string;
|
|
100
100
|
domain: string;
|
|
101
101
|
domainId: string;
|
|
@@ -105,8 +105,8 @@ export declare const postConsent: import("@orpc/server").ImplementedProcedure<Re
|
|
|
105
105
|
metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
106
106
|
givenAt: import("zod").ZodDate;
|
|
107
107
|
}, "strip", import("zod").ZodTypeAny, {
|
|
108
|
-
status: string;
|
|
109
108
|
type: "cookie_banner" | "privacy_policy" | "dpa" | "terms_and_conditions" | "marketing_communications" | "age_verification" | "other";
|
|
109
|
+
status: string;
|
|
110
110
|
id: string;
|
|
111
111
|
domain: string;
|
|
112
112
|
domainId: string;
|
|
@@ -116,8 +116,8 @@ export declare const postConsent: import("@orpc/server").ImplementedProcedure<Re
|
|
|
116
116
|
metadata?: Record<string, unknown> | undefined;
|
|
117
117
|
externalSubjectId?: string | undefined;
|
|
118
118
|
}, {
|
|
119
|
-
status: string;
|
|
120
119
|
type: "cookie_banner" | "privacy_policy" | "dpa" | "terms_and_conditions" | "marketing_communications" | "age_verification" | "other";
|
|
120
|
+
status: string;
|
|
121
121
|
id: string;
|
|
122
122
|
domain: string;
|
|
123
123
|
domainId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show-banner.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/consent/show-banner.handler.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CAmD7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;;;;
|
|
1
|
+
{"version":3,"file":"show-banner.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/consent/show-banner.handler.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CAmD7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;;;;EAgF3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.test.d.ts","sourceRoot":"","sources":["../../../../src/pkgs/api-router/utils/core.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Logger } from '@doubletie/logger';
|
|
2
|
+
/**
|
|
3
|
+
* Regex to strip protocol, trailing slashes, and port numbers from URLs
|
|
4
|
+
*/
|
|
5
|
+
export declare const STRIP_REGEX: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* Validates if a given origin matches a trusted domain pattern
|
|
8
|
+
*
|
|
9
|
+
* @param origin - The origin to validate
|
|
10
|
+
* @param trustedDomains - Array of trusted domain patterns (can include wildcard)
|
|
11
|
+
* @returns boolean indicating if the origin is trusted
|
|
12
|
+
*/
|
|
13
|
+
export declare function isOriginTrusted(origin: string, trustedDomains: string[], logger?: Logger): boolean;
|
|
14
|
+
//# sourceMappingURL=cors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../../../src/pkgs/api-router/utils/cors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,QAA4C,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EAAE,EACxB,MAAM,CAAC,EAAE,MAAM,GACb,OAAO,CAsDT"}
|
|
@@ -31,11 +31,14 @@ export declare const stringFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
31
31
|
pattern: z.ZodOptional<z.ZodString>;
|
|
32
32
|
}>, "strip", z.ZodTypeAny, {
|
|
33
33
|
bigint: boolean;
|
|
34
|
+
type: "string";
|
|
34
35
|
required: boolean;
|
|
35
36
|
returned: boolean;
|
|
36
37
|
input: boolean;
|
|
37
|
-
type: "string";
|
|
38
38
|
sortable: boolean;
|
|
39
|
+
maxLength?: number | undefined;
|
|
40
|
+
minLength?: number | undefined;
|
|
41
|
+
pattern?: string | undefined;
|
|
39
42
|
defaultValue?: any;
|
|
40
43
|
transform?: {
|
|
41
44
|
input?: ((args_0: any, ...args: unknown[]) => any) | undefined;
|
|
@@ -45,12 +48,12 @@ export declare const stringFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
45
48
|
unique?: boolean | undefined;
|
|
46
49
|
indexed?: boolean | undefined;
|
|
47
50
|
fieldName?: string | undefined;
|
|
48
|
-
minLength?: number | undefined;
|
|
49
|
-
maxLength?: number | undefined;
|
|
50
|
-
pattern?: string | undefined;
|
|
51
51
|
}, {
|
|
52
52
|
type: "string";
|
|
53
53
|
bigint?: boolean | undefined;
|
|
54
|
+
maxLength?: number | undefined;
|
|
55
|
+
minLength?: number | undefined;
|
|
56
|
+
pattern?: string | undefined;
|
|
54
57
|
required?: boolean | undefined;
|
|
55
58
|
returned?: boolean | undefined;
|
|
56
59
|
input?: boolean | undefined;
|
|
@@ -64,9 +67,6 @@ export declare const stringFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
64
67
|
indexed?: boolean | undefined;
|
|
65
68
|
sortable?: boolean | undefined;
|
|
66
69
|
fieldName?: string | undefined;
|
|
67
|
-
minLength?: number | undefined;
|
|
68
|
-
maxLength?: number | undefined;
|
|
69
|
-
pattern?: string | undefined;
|
|
70
70
|
}>;
|
|
71
71
|
/**
|
|
72
72
|
* Zod schema for number field configuration
|
|
@@ -98,10 +98,10 @@ export declare const numberFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
98
98
|
max: z.ZodOptional<z.ZodNumber>;
|
|
99
99
|
}>, "strip", z.ZodTypeAny, {
|
|
100
100
|
bigint: boolean;
|
|
101
|
+
type: "number";
|
|
101
102
|
required: boolean;
|
|
102
103
|
returned: boolean;
|
|
103
104
|
input: boolean;
|
|
104
|
-
type: "number";
|
|
105
105
|
sortable: boolean;
|
|
106
106
|
defaultValue?: any;
|
|
107
107
|
transform?: {
|
|
@@ -161,10 +161,10 @@ export declare const booleanFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
161
161
|
type: z.ZodLiteral<"boolean">;
|
|
162
162
|
}>, "strip", z.ZodTypeAny, {
|
|
163
163
|
bigint: boolean;
|
|
164
|
+
type: "boolean";
|
|
164
165
|
required: boolean;
|
|
165
166
|
returned: boolean;
|
|
166
167
|
input: boolean;
|
|
167
|
-
type: "boolean";
|
|
168
168
|
sortable: boolean;
|
|
169
169
|
defaultValue?: any;
|
|
170
170
|
transform?: {
|
|
@@ -224,12 +224,13 @@ export declare const dateFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
224
224
|
format: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
225
225
|
}>, "strip", z.ZodTypeAny, {
|
|
226
226
|
bigint: boolean;
|
|
227
|
+
type: "date";
|
|
227
228
|
required: boolean;
|
|
228
229
|
returned: boolean;
|
|
229
230
|
input: boolean;
|
|
230
|
-
type: "date";
|
|
231
231
|
sortable: boolean;
|
|
232
232
|
dateOnly: boolean;
|
|
233
|
+
format?: Record<string, unknown> | undefined;
|
|
233
234
|
defaultValue?: any;
|
|
234
235
|
transform?: {
|
|
235
236
|
input?: ((args_0: any, ...args: unknown[]) => any) | undefined;
|
|
@@ -241,10 +242,10 @@ export declare const dateFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
241
242
|
fieldName?: string | undefined;
|
|
242
243
|
minDate?: Date | undefined;
|
|
243
244
|
maxDate?: Date | undefined;
|
|
244
|
-
format?: Record<string, unknown> | undefined;
|
|
245
245
|
}, {
|
|
246
246
|
type: "date";
|
|
247
247
|
bigint?: boolean | undefined;
|
|
248
|
+
format?: Record<string, unknown> | undefined;
|
|
248
249
|
required?: boolean | undefined;
|
|
249
250
|
returned?: boolean | undefined;
|
|
250
251
|
input?: boolean | undefined;
|
|
@@ -261,7 +262,6 @@ export declare const dateFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
261
262
|
minDate?: Date | undefined;
|
|
262
263
|
maxDate?: Date | undefined;
|
|
263
264
|
dateOnly?: boolean | undefined;
|
|
264
|
-
format?: Record<string, unknown> | undefined;
|
|
265
265
|
}>;
|
|
266
266
|
/**
|
|
267
267
|
* Zod schema for timezone field configuration
|
|
@@ -294,10 +294,10 @@ export declare const timezoneFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
294
294
|
restrictToSuggestedValues: z.ZodDefault<z.ZodBoolean>;
|
|
295
295
|
}>, "strip", z.ZodTypeAny, {
|
|
296
296
|
bigint: boolean;
|
|
297
|
+
type: "timezone";
|
|
297
298
|
required: boolean;
|
|
298
299
|
returned: boolean;
|
|
299
300
|
input: boolean;
|
|
300
|
-
type: "timezone";
|
|
301
301
|
sortable: boolean;
|
|
302
302
|
validateTimezone: boolean;
|
|
303
303
|
restrictToSuggestedValues: boolean;
|
|
@@ -360,10 +360,10 @@ export declare const jsonFieldSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
360
360
|
validateJson: z.ZodDefault<z.ZodBoolean>;
|
|
361
361
|
}>, "strip", z.ZodTypeAny, {
|
|
362
362
|
bigint: boolean;
|
|
363
|
+
type: "json";
|
|
363
364
|
required: boolean;
|
|
364
365
|
returned: boolean;
|
|
365
366
|
input: boolean;
|
|
366
|
-
type: "json";
|
|
367
367
|
sortable: boolean;
|
|
368
368
|
validateJson: boolean;
|
|
369
369
|
defaultValue?: any;
|
|
@@ -421,10 +421,10 @@ export declare const stringArrayFieldSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
421
421
|
type: z.ZodLiteral<"string[]">;
|
|
422
422
|
}>, "strip", z.ZodTypeAny, {
|
|
423
423
|
bigint: boolean;
|
|
424
|
+
type: "string[]";
|
|
424
425
|
required: boolean;
|
|
425
426
|
returned: boolean;
|
|
426
427
|
input: boolean;
|
|
427
|
-
type: "string[]";
|
|
428
428
|
sortable: boolean;
|
|
429
429
|
defaultValue?: any;
|
|
430
430
|
transform?: {
|
|
@@ -480,10 +480,10 @@ export declare const numberArrayFieldSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
480
480
|
type: z.ZodLiteral<"number[]">;
|
|
481
481
|
}>, "strip", z.ZodTypeAny, {
|
|
482
482
|
bigint: boolean;
|
|
483
|
+
type: "number[]";
|
|
483
484
|
required: boolean;
|
|
484
485
|
returned: boolean;
|
|
485
486
|
input: boolean;
|
|
486
|
-
type: "number[]";
|
|
487
487
|
sortable: boolean;
|
|
488
488
|
defaultValue?: any;
|
|
489
489
|
transform?: {
|
|
@@ -542,11 +542,14 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
542
542
|
pattern: z.ZodOptional<z.ZodString>;
|
|
543
543
|
}>, "strip", z.ZodTypeAny, {
|
|
544
544
|
bigint: boolean;
|
|
545
|
+
type: "string";
|
|
545
546
|
required: boolean;
|
|
546
547
|
returned: boolean;
|
|
547
548
|
input: boolean;
|
|
548
|
-
type: "string";
|
|
549
549
|
sortable: boolean;
|
|
550
|
+
maxLength?: number | undefined;
|
|
551
|
+
minLength?: number | undefined;
|
|
552
|
+
pattern?: string | undefined;
|
|
550
553
|
defaultValue?: any;
|
|
551
554
|
transform?: {
|
|
552
555
|
input?: ((args_0: any, ...args: unknown[]) => any) | undefined;
|
|
@@ -556,12 +559,12 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
556
559
|
unique?: boolean | undefined;
|
|
557
560
|
indexed?: boolean | undefined;
|
|
558
561
|
fieldName?: string | undefined;
|
|
559
|
-
minLength?: number | undefined;
|
|
560
|
-
maxLength?: number | undefined;
|
|
561
|
-
pattern?: string | undefined;
|
|
562
562
|
}, {
|
|
563
563
|
type: "string";
|
|
564
564
|
bigint?: boolean | undefined;
|
|
565
|
+
maxLength?: number | undefined;
|
|
566
|
+
minLength?: number | undefined;
|
|
567
|
+
pattern?: string | undefined;
|
|
565
568
|
required?: boolean | undefined;
|
|
566
569
|
returned?: boolean | undefined;
|
|
567
570
|
input?: boolean | undefined;
|
|
@@ -575,9 +578,6 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
575
578
|
indexed?: boolean | undefined;
|
|
576
579
|
sortable?: boolean | undefined;
|
|
577
580
|
fieldName?: string | undefined;
|
|
578
|
-
minLength?: number | undefined;
|
|
579
|
-
maxLength?: number | undefined;
|
|
580
|
-
pattern?: string | undefined;
|
|
581
581
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
582
582
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
583
583
|
returned: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -605,10 +605,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
605
605
|
max: z.ZodOptional<z.ZodNumber>;
|
|
606
606
|
}>, "strip", z.ZodTypeAny, {
|
|
607
607
|
bigint: boolean;
|
|
608
|
+
type: "number";
|
|
608
609
|
required: boolean;
|
|
609
610
|
returned: boolean;
|
|
610
611
|
input: boolean;
|
|
611
|
-
type: "number";
|
|
612
612
|
sortable: boolean;
|
|
613
613
|
defaultValue?: any;
|
|
614
614
|
transform?: {
|
|
@@ -664,10 +664,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
664
664
|
type: z.ZodLiteral<"boolean">;
|
|
665
665
|
}>, "strip", z.ZodTypeAny, {
|
|
666
666
|
bigint: boolean;
|
|
667
|
+
type: "boolean";
|
|
667
668
|
required: boolean;
|
|
668
669
|
returned: boolean;
|
|
669
670
|
input: boolean;
|
|
670
|
-
type: "boolean";
|
|
671
671
|
sortable: boolean;
|
|
672
672
|
defaultValue?: any;
|
|
673
673
|
transform?: {
|
|
@@ -723,12 +723,13 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
723
723
|
format: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
724
724
|
}>, "strip", z.ZodTypeAny, {
|
|
725
725
|
bigint: boolean;
|
|
726
|
+
type: "date";
|
|
726
727
|
required: boolean;
|
|
727
728
|
returned: boolean;
|
|
728
729
|
input: boolean;
|
|
729
|
-
type: "date";
|
|
730
730
|
sortable: boolean;
|
|
731
731
|
dateOnly: boolean;
|
|
732
|
+
format?: Record<string, unknown> | undefined;
|
|
732
733
|
defaultValue?: any;
|
|
733
734
|
transform?: {
|
|
734
735
|
input?: ((args_0: any, ...args: unknown[]) => any) | undefined;
|
|
@@ -740,10 +741,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
740
741
|
fieldName?: string | undefined;
|
|
741
742
|
minDate?: Date | undefined;
|
|
742
743
|
maxDate?: Date | undefined;
|
|
743
|
-
format?: Record<string, unknown> | undefined;
|
|
744
744
|
}, {
|
|
745
745
|
type: "date";
|
|
746
746
|
bigint?: boolean | undefined;
|
|
747
|
+
format?: Record<string, unknown> | undefined;
|
|
747
748
|
required?: boolean | undefined;
|
|
748
749
|
returned?: boolean | undefined;
|
|
749
750
|
input?: boolean | undefined;
|
|
@@ -760,7 +761,6 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
760
761
|
minDate?: Date | undefined;
|
|
761
762
|
maxDate?: Date | undefined;
|
|
762
763
|
dateOnly?: boolean | undefined;
|
|
763
|
-
format?: Record<string, unknown> | undefined;
|
|
764
764
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
765
765
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
766
766
|
returned: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -789,10 +789,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
789
789
|
restrictToSuggestedValues: z.ZodDefault<z.ZodBoolean>;
|
|
790
790
|
}>, "strip", z.ZodTypeAny, {
|
|
791
791
|
bigint: boolean;
|
|
792
|
+
type: "timezone";
|
|
792
793
|
required: boolean;
|
|
793
794
|
returned: boolean;
|
|
794
795
|
input: boolean;
|
|
795
|
-
type: "timezone";
|
|
796
796
|
sortable: boolean;
|
|
797
797
|
validateTimezone: boolean;
|
|
798
798
|
restrictToSuggestedValues: boolean;
|
|
@@ -851,10 +851,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
851
851
|
validateJson: z.ZodDefault<z.ZodBoolean>;
|
|
852
852
|
}>, "strip", z.ZodTypeAny, {
|
|
853
853
|
bigint: boolean;
|
|
854
|
+
type: "json";
|
|
854
855
|
required: boolean;
|
|
855
856
|
returned: boolean;
|
|
856
857
|
input: boolean;
|
|
857
|
-
type: "json";
|
|
858
858
|
sortable: boolean;
|
|
859
859
|
validateJson: boolean;
|
|
860
860
|
defaultValue?: any;
|
|
@@ -908,10 +908,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
908
908
|
type: z.ZodLiteral<"string[]">;
|
|
909
909
|
}>, "strip", z.ZodTypeAny, {
|
|
910
910
|
bigint: boolean;
|
|
911
|
+
type: "string[]";
|
|
911
912
|
required: boolean;
|
|
912
913
|
returned: boolean;
|
|
913
914
|
input: boolean;
|
|
914
|
-
type: "string[]";
|
|
915
915
|
sortable: boolean;
|
|
916
916
|
defaultValue?: any;
|
|
917
917
|
transform?: {
|
|
@@ -963,10 +963,10 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z
|
|
|
963
963
|
type: z.ZodLiteral<"number[]">;
|
|
964
964
|
}>, "strip", z.ZodTypeAny, {
|
|
965
965
|
bigint: boolean;
|
|
966
|
+
type: "number[]";
|
|
966
967
|
required: boolean;
|
|
967
968
|
returned: boolean;
|
|
968
969
|
input: boolean;
|
|
969
|
-
type: "number[]";
|
|
970
970
|
sortable: boolean;
|
|
971
971
|
defaultValue?: any;
|
|
972
972
|
transform?: {
|
|
@@ -1287,21 +1287,10 @@ function consentRegistry({ adapter, ...ctx }) {
|
|
|
1287
1287
|
};
|
|
1288
1288
|
return registry;
|
|
1289
1289
|
}
|
|
1290
|
-
|
|
1290
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
1291
|
+
function generatePolicyPlaceholder(name, date) {
|
|
1291
1292
|
const content = `[PLACEHOLDER] This is an automatically generated version of the ${name} policy.\n\nThis placeholder content should be replaced with actual policy terms before being presented to users.\n\nGenerated on: ${date.toISOString()}`;
|
|
1292
|
-
|
|
1293
|
-
try {
|
|
1294
|
-
const encoder = new TextEncoder();
|
|
1295
|
-
const data = encoder.encode(content);
|
|
1296
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
1297
|
-
contentHash = Array.from(new Uint8Array(hashBuffer)).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
1298
|
-
} catch (error) {
|
|
1299
|
-
throw new error_class_DoubleTieError('Failed to generate policy content hash', {
|
|
1300
|
-
code: error_codes_ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
1301
|
-
status: 500,
|
|
1302
|
-
cause: error instanceof Error ? error : new Error(String(error))
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1293
|
+
const contentHash = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(content).digest('hex');
|
|
1305
1294
|
return {
|
|
1306
1295
|
content,
|
|
1307
1296
|
contentHash
|
|
@@ -1361,53 +1350,44 @@ function policyRegistry({ adapter, ...ctx }) {
|
|
|
1361
1350
|
});
|
|
1362
1351
|
return policy ? validateEntityOutput('consentPolicy', policy, ctx.options) : null;
|
|
1363
1352
|
},
|
|
1364
|
-
findOrCreatePolicy: async (type)=>
|
|
1353
|
+
findOrCreatePolicy: async (type)=>adapter.transaction({
|
|
1365
1354
|
callback: async (txAdapter)=>{
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
value: type
|
|
1382
|
-
}
|
|
1383
|
-
],
|
|
1384
|
-
sortBy: {
|
|
1385
|
-
field: 'effectiveDate',
|
|
1386
|
-
direction: 'desc'
|
|
1355
|
+
const now = new Date();
|
|
1356
|
+
const txRegistry = policyRegistry({
|
|
1357
|
+
adapter: txAdapter,
|
|
1358
|
+
...ctx
|
|
1359
|
+
});
|
|
1360
|
+
const rawLatestPolicy = await txAdapter.findOne({
|
|
1361
|
+
model: 'consentPolicy',
|
|
1362
|
+
where: [
|
|
1363
|
+
{
|
|
1364
|
+
field: 'isActive',
|
|
1365
|
+
value: true
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
field: 'type',
|
|
1369
|
+
value: type
|
|
1387
1370
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
cause: error instanceof Error ? error : new Error(String(error))
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1371
|
+
],
|
|
1372
|
+
sortBy: {
|
|
1373
|
+
field: 'effectiveDate',
|
|
1374
|
+
direction: 'desc'
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
const latestPolicy = rawLatestPolicy ? validateEntityOutput('consentPolicy', rawLatestPolicy, ctx.options) : null;
|
|
1378
|
+
if (latestPolicy) return latestPolicy;
|
|
1379
|
+
const { content: defaultContent, contentHash } = generatePolicyPlaceholder(type, now);
|
|
1380
|
+
return txRegistry.createConsentPolicy({
|
|
1381
|
+
version: '1.0.0',
|
|
1382
|
+
type,
|
|
1383
|
+
name: type,
|
|
1384
|
+
effectiveDate: now,
|
|
1385
|
+
content: defaultContent,
|
|
1386
|
+
contentHash,
|
|
1387
|
+
isActive: true,
|
|
1388
|
+
updatedAt: now,
|
|
1389
|
+
expirationDate: null
|
|
1390
|
+
});
|
|
1411
1391
|
}
|
|
1412
1392
|
})
|
|
1413
1393
|
};
|
|
@@ -4,6 +4,7 @@ import "neverthrow";
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__orpc_server_0dae8408__ from "@orpc/server";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__ from "@opentelemetry/api";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__doubletie_logger_91c58a8f__ from "@doubletie/logger";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
7
8
|
const COMMON_TIMEZONES = {
|
|
8
9
|
UTC: 'UTC',
|
|
9
10
|
GMT: 'GMT',
|
|
@@ -1219,21 +1220,9 @@ function consentRegistry({ adapter, ...ctx }) {
|
|
|
1219
1220
|
};
|
|
1220
1221
|
return registry;
|
|
1221
1222
|
}
|
|
1222
|
-
|
|
1223
|
+
function generatePolicyPlaceholder(name, date) {
|
|
1223
1224
|
const content = `[PLACEHOLDER] This is an automatically generated version of the ${name} policy.\n\nThis placeholder content should be replaced with actual policy terms before being presented to users.\n\nGenerated on: ${date.toISOString()}`;
|
|
1224
|
-
|
|
1225
|
-
try {
|
|
1226
|
-
const encoder = new TextEncoder();
|
|
1227
|
-
const data = encoder.encode(content);
|
|
1228
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
1229
|
-
contentHash = Array.from(new Uint8Array(hashBuffer)).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
1230
|
-
} catch (error) {
|
|
1231
|
-
throw new error_class_DoubleTieError('Failed to generate policy content hash', {
|
|
1232
|
-
code: error_codes_ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
1233
|
-
status: 500,
|
|
1234
|
-
cause: error instanceof Error ? error : new Error(String(error))
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1225
|
+
const contentHash = (0, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.createHash)('sha256').update(content).digest('hex');
|
|
1237
1226
|
return {
|
|
1238
1227
|
content,
|
|
1239
1228
|
contentHash
|
|
@@ -1293,53 +1282,44 @@ function policyRegistry({ adapter, ...ctx }) {
|
|
|
1293
1282
|
});
|
|
1294
1283
|
return policy ? validateEntityOutput('consentPolicy', policy, ctx.options) : null;
|
|
1295
1284
|
},
|
|
1296
|
-
findOrCreatePolicy: async (type)=>
|
|
1285
|
+
findOrCreatePolicy: async (type)=>adapter.transaction({
|
|
1297
1286
|
callback: async (txAdapter)=>{
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
value: type
|
|
1314
|
-
}
|
|
1315
|
-
],
|
|
1316
|
-
sortBy: {
|
|
1317
|
-
field: 'effectiveDate',
|
|
1318
|
-
direction: 'desc'
|
|
1287
|
+
const now = new Date();
|
|
1288
|
+
const txRegistry = policyRegistry({
|
|
1289
|
+
adapter: txAdapter,
|
|
1290
|
+
...ctx
|
|
1291
|
+
});
|
|
1292
|
+
const rawLatestPolicy = await txAdapter.findOne({
|
|
1293
|
+
model: 'consentPolicy',
|
|
1294
|
+
where: [
|
|
1295
|
+
{
|
|
1296
|
+
field: 'isActive',
|
|
1297
|
+
value: true
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
field: 'type',
|
|
1301
|
+
value: type
|
|
1319
1302
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
cause: error instanceof Error ? error : new Error(String(error))
|
|
1341
|
-
});
|
|
1342
|
-
}
|
|
1303
|
+
],
|
|
1304
|
+
sortBy: {
|
|
1305
|
+
field: 'effectiveDate',
|
|
1306
|
+
direction: 'desc'
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
const latestPolicy = rawLatestPolicy ? validateEntityOutput('consentPolicy', rawLatestPolicy, ctx.options) : null;
|
|
1310
|
+
if (latestPolicy) return latestPolicy;
|
|
1311
|
+
const { content: defaultContent, contentHash } = generatePolicyPlaceholder(type, now);
|
|
1312
|
+
return txRegistry.createConsentPolicy({
|
|
1313
|
+
version: '1.0.0',
|
|
1314
|
+
type,
|
|
1315
|
+
name: type,
|
|
1316
|
+
effectiveDate: now,
|
|
1317
|
+
content: defaultContent,
|
|
1318
|
+
contentHash,
|
|
1319
|
+
isActive: true,
|
|
1320
|
+
updatedAt: now,
|
|
1321
|
+
expirationDate: null
|
|
1322
|
+
});
|
|
1343
1323
|
}
|
|
1344
1324
|
})
|
|
1345
1325
|
};
|