@c15t/backend 1.2.0-canary.8 → 1.2.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.
Files changed (167) hide show
  1. package/.turbo/turbo-build.log +53 -52
  2. package/CHANGELOG.md +7 -0
  3. package/dist/__tests__/server.test.d.ts +2 -0
  4. package/dist/__tests__/server.test.d.ts.map +1 -0
  5. package/dist/contracts/index.d.ts +1 -1
  6. package/dist/contracts/index.d.ts.map +1 -1
  7. package/dist/contracts.cjs +708 -0
  8. package/dist/contracts.js +661 -0
  9. package/dist/core.cjs +98 -47
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +98 -47
  12. package/dist/middleware/openapi/config.d.ts +1 -1
  13. package/dist/middleware/openapi/config.d.ts.map +1 -1
  14. package/dist/pkgs/data-model/index.cjs +57 -39
  15. package/dist/pkgs/data-model/index.js +57 -39
  16. package/dist/pkgs/data-model/schema/index.cjs +57 -39
  17. package/dist/pkgs/data-model/schema/index.js +57 -39
  18. package/dist/router.cjs +3 -1
  19. package/dist/router.js +3 -1
  20. package/dist/schema/consent-policy/registry.d.ts.map +1 -1
  21. package/dist/schema/create-registry.d.ts.map +1 -1
  22. package/dist/schema/index.cjs +57 -39
  23. package/dist/schema/index.js +57 -39
  24. package/package.json +9 -4
  25. package/rslib.config.ts +1 -0
  26. package/src/__tests__/server.test.ts +96 -0
  27. package/src/contracts/index.ts +2 -0
  28. package/src/core.ts +34 -1
  29. package/src/middleware/cors/cors.test.ts +0 -1
  30. package/src/middleware/openapi/config.ts +10 -7
  31. package/src/schema/consent-policy/registry.ts +74 -51
  32. package/.turbo/turbo-fmt.log +0 -7
  33. package/.turbo/turbo-test.log +0 -426
  34. package/coverage/coverage-final.json +0 -88
  35. package/coverage/coverage-summary.json +0 -89
  36. package/coverage/html/backend/index.html +0 -116
  37. package/coverage/html/backend/rslib.config.ts.html +0 -415
  38. package/coverage/html/backend/src/contracts/consent/index.html +0 -161
  39. package/coverage/html/backend/src/contracts/consent/index.ts.html +0 -112
  40. package/coverage/html/backend/src/contracts/consent/post.contract.ts.html +0 -550
  41. package/coverage/html/backend/src/contracts/consent/show-banner.contract.ts.html +0 -220
  42. package/coverage/html/backend/src/contracts/consent/verify.contract.ts.html +0 -463
  43. package/coverage/html/backend/src/contracts/index.html +0 -116
  44. package/coverage/html/backend/src/contracts/index.ts.html +0 -139
  45. package/coverage/html/backend/src/contracts/meta/index.html +0 -131
  46. package/coverage/html/backend/src/contracts/meta/index.ts.html +0 -100
  47. package/coverage/html/backend/src/contracts/meta/status.contract.ts.html +0 -196
  48. package/coverage/html/backend/src/contracts/shared/index.html +0 -116
  49. package/coverage/html/backend/src/contracts/shared/jurisdiction.schema.ts.html +0 -175
  50. package/coverage/html/backend/src/core.ts.html +0 -1342
  51. package/coverage/html/backend/src/handlers/consent/index.html +0 -161
  52. package/coverage/html/backend/src/handlers/consent/index.ts.html +0 -112
  53. package/coverage/html/backend/src/handlers/consent/post.handler.ts.html +0 -904
  54. package/coverage/html/backend/src/handlers/consent/show-banner.handler.ts.html +0 -532
  55. package/coverage/html/backend/src/handlers/consent/verify.handler.ts.html +0 -1000
  56. package/coverage/html/backend/src/handlers/meta/index.html +0 -131
  57. package/coverage/html/backend/src/handlers/meta/index.ts.html +0 -100
  58. package/coverage/html/backend/src/handlers/meta/status.handler.ts.html +0 -226
  59. package/coverage/html/backend/src/index.html +0 -161
  60. package/coverage/html/backend/src/init.ts.html +0 -1018
  61. package/coverage/html/backend/src/middleware/cors/cors.ts.html +0 -661
  62. package/coverage/html/backend/src/middleware/cors/index.html +0 -146
  63. package/coverage/html/backend/src/middleware/cors/is-origin-trusted.ts.html +0 -463
  64. package/coverage/html/backend/src/middleware/cors/process-cors.ts.html +0 -358
  65. package/coverage/html/backend/src/middleware/openapi/config.ts.html +0 -160
  66. package/coverage/html/backend/src/middleware/openapi/handlers.ts.html +0 -481
  67. package/coverage/html/backend/src/middleware/openapi/index.html +0 -131
  68. package/coverage/html/backend/src/pkgs/api-router/hooks/index.html +0 -116
  69. package/coverage/html/backend/src/pkgs/api-router/hooks/processor.ts.html +0 -544
  70. package/coverage/html/backend/src/pkgs/api-router/index.html +0 -116
  71. package/coverage/html/backend/src/pkgs/api-router/telemetry.ts.html +0 -334
  72. package/coverage/html/backend/src/pkgs/api-router/utils/index.html +0 -116
  73. package/coverage/html/backend/src/pkgs/api-router/utils/ip.ts.html +0 -361
  74. package/coverage/html/backend/src/pkgs/data-model/fields/field-factory.ts.html +0 -709
  75. package/coverage/html/backend/src/pkgs/data-model/fields/id-generator.ts.html +0 -256
  76. package/coverage/html/backend/src/pkgs/data-model/fields/index.html +0 -161
  77. package/coverage/html/backend/src/pkgs/data-model/fields/superjson-utils.ts.html +0 -136
  78. package/coverage/html/backend/src/pkgs/data-model/fields/zod-fields.ts.html +0 -496
  79. package/coverage/html/backend/src/pkgs/data-model/hooks/create-hooks.ts.html +0 -349
  80. package/coverage/html/backend/src/pkgs/data-model/hooks/index.html +0 -176
  81. package/coverage/html/backend/src/pkgs/data-model/hooks/update-hooks.ts.html +0 -358
  82. package/coverage/html/backend/src/pkgs/data-model/hooks/update-many-hooks.ts.html +0 -613
  83. package/coverage/html/backend/src/pkgs/data-model/hooks/utils.ts.html +0 -538
  84. package/coverage/html/backend/src/pkgs/data-model/hooks/with-hooks-factory.ts.html +0 -289
  85. package/coverage/html/backend/src/pkgs/db-adapters/adapter-factory.ts.html +0 -289
  86. package/coverage/html/backend/src/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.ts.html +0 -2203
  87. package/coverage/html/backend/src/pkgs/db-adapters/adapters/drizzle-adapter/index.html +0 -116
  88. package/coverage/html/backend/src/pkgs/db-adapters/adapters/index.html +0 -116
  89. package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/dialect.ts.html +0 -670
  90. package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/index.html +0 -131
  91. package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.ts.html +0 -3634
  92. package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/tests/index.html +0 -116
  93. package/coverage/html/backend/src/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.ts.html +0 -1417
  94. package/coverage/html/backend/src/pkgs/db-adapters/adapters/memory-adapter/index.html +0 -116
  95. package/coverage/html/backend/src/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.ts.html +0 -2071
  96. package/coverage/html/backend/src/pkgs/db-adapters/adapters/prisma-adapter/index.html +0 -116
  97. package/coverage/html/backend/src/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.ts.html +0 -1834
  98. package/coverage/html/backend/src/pkgs/db-adapters/adapters/test.ts.html +0 -316
  99. package/coverage/html/backend/src/pkgs/db-adapters/index.html +0 -131
  100. package/coverage/html/backend/src/pkgs/db-adapters/utils.ts.html +0 -238
  101. package/coverage/html/backend/src/pkgs/migrations/get-migration.ts.html +0 -343
  102. package/coverage/html/backend/src/pkgs/migrations/get-schema/get-schema.ts.html +0 -217
  103. package/coverage/html/backend/src/pkgs/migrations/get-schema/index.html +0 -146
  104. package/coverage/html/backend/src/pkgs/migrations/get-schema/process-fields.ts.html +0 -280
  105. package/coverage/html/backend/src/pkgs/migrations/get-schema/process-tables.ts.html +0 -289
  106. package/coverage/html/backend/src/pkgs/migrations/index.html +0 -176
  107. package/coverage/html/backend/src/pkgs/migrations/migration-builders.ts.html +0 -595
  108. package/coverage/html/backend/src/pkgs/migrations/migration-execution.ts.html +0 -301
  109. package/coverage/html/backend/src/pkgs/migrations/schema-comparison.ts.html +0 -694
  110. package/coverage/html/backend/src/pkgs/migrations/type-mapping.ts.html +0 -817
  111. package/coverage/html/backend/src/pkgs/results/core/error-class.ts.html +0 -976
  112. package/coverage/html/backend/src/pkgs/results/core/error-codes.ts.html +0 -703
  113. package/coverage/html/backend/src/pkgs/results/core/index.html +0 -146
  114. package/coverage/html/backend/src/pkgs/results/core/tracing.ts.html +0 -280
  115. package/coverage/html/backend/src/pkgs/results/create-telemetry-options.ts.html +0 -271
  116. package/coverage/html/backend/src/pkgs/results/index.html +0 -131
  117. package/coverage/html/backend/src/pkgs/results/orpc-error-handler.ts.html +0 -496
  118. package/coverage/html/backend/src/pkgs/results/results/index.html +0 -131
  119. package/coverage/html/backend/src/pkgs/results/results/recovery-utils.ts.html +0 -628
  120. package/coverage/html/backend/src/pkgs/results/results/result-helpers.ts.html +0 -1234
  121. package/coverage/html/backend/src/pkgs/utils/env.ts.html +0 -337
  122. package/coverage/html/backend/src/pkgs/utils/index.html +0 -146
  123. package/coverage/html/backend/src/pkgs/utils/logger.ts.html +0 -199
  124. package/coverage/html/backend/src/pkgs/utils/url.ts.html +0 -400
  125. package/coverage/html/backend/src/router.ts.html +0 -109
  126. package/coverage/html/backend/src/schema/audit-log/index.html +0 -146
  127. package/coverage/html/backend/src/schema/audit-log/registry.ts.html +0 -436
  128. package/coverage/html/backend/src/schema/audit-log/schema.ts.html +0 -223
  129. package/coverage/html/backend/src/schema/audit-log/table.ts.html +0 -640
  130. package/coverage/html/backend/src/schema/consent/index.html +0 -146
  131. package/coverage/html/backend/src/schema/consent/registry.ts.html +0 -616
  132. package/coverage/html/backend/src/schema/consent/schema.ts.html +0 -238
  133. package/coverage/html/backend/src/schema/consent/table.ts.html +0 -748
  134. package/coverage/html/backend/src/schema/consent-policy/index.html +0 -146
  135. package/coverage/html/backend/src/schema/consent-policy/registry.ts.html +0 -1063
  136. package/coverage/html/backend/src/schema/consent-policy/schema.ts.html +0 -265
  137. package/coverage/html/backend/src/schema/consent-policy/table.ts.html +0 -535
  138. package/coverage/html/backend/src/schema/consent-purpose/index.html +0 -146
  139. package/coverage/html/backend/src/schema/consent-purpose/registry.ts.html +0 -589
  140. package/coverage/html/backend/src/schema/consent-purpose/schema.ts.html +0 -259
  141. package/coverage/html/backend/src/schema/consent-purpose/table.ts.html +0 -547
  142. package/coverage/html/backend/src/schema/consent-record/index.html +0 -131
  143. package/coverage/html/backend/src/schema/consent-record/schema.ts.html +0 -211
  144. package/coverage/html/backend/src/schema/consent-record/table.ts.html +0 -457
  145. package/coverage/html/backend/src/schema/create-registry.ts.html +0 -148
  146. package/coverage/html/backend/src/schema/definition.ts.html +0 -685
  147. package/coverage/html/backend/src/schema/domain/index.html +0 -146
  148. package/coverage/html/backend/src/schema/domain/registry.ts.html +0 -973
  149. package/coverage/html/backend/src/schema/domain/schema.ts.html +0 -214
  150. package/coverage/html/backend/src/schema/domain/table.ts.html +0 -496
  151. package/coverage/html/backend/src/schema/index.html +0 -146
  152. package/coverage/html/backend/src/schema/schemas.ts.html +0 -166
  153. package/coverage/html/backend/src/schema/subject/index.html +0 -146
  154. package/coverage/html/backend/src/schema/subject/registry.ts.html +0 -973
  155. package/coverage/html/backend/src/schema/subject/schema.ts.html +0 -208
  156. package/coverage/html/backend/src/schema/subject/table.ts.html +0 -499
  157. package/coverage/html/backend/src/server.ts.html +0 -463
  158. package/coverage/html/backend/src/testing/contract-testing.ts.html +0 -1396
  159. package/coverage/html/backend/src/testing/index.html +0 -116
  160. package/coverage/html/base.css +0 -224
  161. package/coverage/html/block-navigation.js +0 -87
  162. package/coverage/html/favicon.png +0 -0
  163. package/coverage/html/index.html +0 -656
  164. package/coverage/html/prettify.css +0 -1
  165. package/coverage/html/prettify.js +0 -2
  166. package/coverage/html/sort-arrow-sprite.png +0 -0
  167. package/coverage/html/sorter.js +0 -196
@@ -0,0 +1,708 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ os: ()=>os,
37
+ contracts: ()=>config
38
+ });
39
+ const server_namespaceObject = require("@orpc/server");
40
+ const contract_namespaceObject = require("@orpc/contract");
41
+ const external_zod_namespaceObject = require("zod");
42
+ const external_base_x_namespaceObject = require("base-x");
43
+ var external_base_x_default = /*#__PURE__*/ __webpack_require__.n(external_base_x_namespaceObject);
44
+ external_base_x_default()('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
45
+ const fieldConfigSchema = external_zod_namespaceObject.z.object({
46
+ required: external_zod_namespaceObject.z.boolean().default(true),
47
+ returned: external_zod_namespaceObject.z.boolean().default(true),
48
+ input: external_zod_namespaceObject.z.boolean().default(true),
49
+ defaultValue: external_zod_namespaceObject.z.union([
50
+ external_zod_namespaceObject.z.any(),
51
+ external_zod_namespaceObject.z["function"]().returns(external_zod_namespaceObject.z.any())
52
+ ]).optional(),
53
+ transform: external_zod_namespaceObject.z.object({
54
+ input: external_zod_namespaceObject.z["function"]().args(external_zod_namespaceObject.z.any()).returns(external_zod_namespaceObject.z.union([
55
+ external_zod_namespaceObject.z.any(),
56
+ external_zod_namespaceObject.z.promise(external_zod_namespaceObject.z.any())
57
+ ])).optional(),
58
+ output: external_zod_namespaceObject.z["function"]().args(external_zod_namespaceObject.z.any()).returns(external_zod_namespaceObject.z.union([
59
+ external_zod_namespaceObject.z.any(),
60
+ external_zod_namespaceObject.z.promise(external_zod_namespaceObject.z.any())
61
+ ])).optional()
62
+ }).optional(),
63
+ validator: external_zod_namespaceObject.z["function"]().args(external_zod_namespaceObject.z.any()).returns(external_zod_namespaceObject.z.union([
64
+ external_zod_namespaceObject.z.string(),
65
+ external_zod_namespaceObject.z["null"]()
66
+ ])).optional(),
67
+ unique: external_zod_namespaceObject.z.boolean().optional(),
68
+ indexed: external_zod_namespaceObject.z.boolean().optional(),
69
+ sortable: external_zod_namespaceObject.z.boolean().default(true),
70
+ fieldName: external_zod_namespaceObject.z.string().optional(),
71
+ bigint: external_zod_namespaceObject.z.boolean().default(false)
72
+ });
73
+ const stringFieldSchema = fieldConfigSchema.extend({
74
+ type: external_zod_namespaceObject.z.literal('string'),
75
+ minLength: external_zod_namespaceObject.z.number().optional(),
76
+ maxLength: external_zod_namespaceObject.z.number().optional(),
77
+ pattern: external_zod_namespaceObject.z.string().optional()
78
+ });
79
+ const numberFieldSchema = fieldConfigSchema.extend({
80
+ type: external_zod_namespaceObject.z.literal('number'),
81
+ min: external_zod_namespaceObject.z.number().optional(),
82
+ max: external_zod_namespaceObject.z.number().optional()
83
+ });
84
+ const booleanFieldSchema = fieldConfigSchema.extend({
85
+ type: external_zod_namespaceObject.z.literal('boolean')
86
+ });
87
+ const dateFieldSchema = fieldConfigSchema.extend({
88
+ type: external_zod_namespaceObject.z.literal('date'),
89
+ minDate: external_zod_namespaceObject.z.date().optional(),
90
+ maxDate: external_zod_namespaceObject.z.date().optional(),
91
+ dateOnly: external_zod_namespaceObject.z.boolean().default(false),
92
+ format: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).optional()
93
+ });
94
+ const timezoneFieldSchema = fieldConfigSchema.extend({
95
+ type: external_zod_namespaceObject.z.literal('timezone'),
96
+ validateTimezone: external_zod_namespaceObject.z.boolean().default(true),
97
+ suggestedValues: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
98
+ restrictToSuggestedValues: external_zod_namespaceObject.z.boolean().default(false)
99
+ });
100
+ const jsonFieldSchema = fieldConfigSchema.extend({
101
+ type: external_zod_namespaceObject.z.literal('json'),
102
+ validateJson: external_zod_namespaceObject.z.boolean().default(true)
103
+ });
104
+ const stringArrayFieldSchema = fieldConfigSchema.extend({
105
+ type: external_zod_namespaceObject.z.literal('string[]')
106
+ });
107
+ const numberArrayFieldSchema = fieldConfigSchema.extend({
108
+ type: external_zod_namespaceObject.z.literal('number[]')
109
+ });
110
+ external_zod_namespaceObject.z.discriminatedUnion('type', [
111
+ stringFieldSchema,
112
+ numberFieldSchema,
113
+ booleanFieldSchema,
114
+ dateFieldSchema,
115
+ timezoneFieldSchema,
116
+ jsonFieldSchema,
117
+ stringArrayFieldSchema,
118
+ numberArrayFieldSchema
119
+ ]);
120
+ require("neverthrow");
121
+ const error_codes_ERROR_CODES = Object.freeze({
122
+ NOT_FOUND: 'Resource not found',
123
+ BAD_REQUEST: 'Bad request',
124
+ CONFLICT: 'Conflict with current state',
125
+ MISSING_REQUIRED_PARAMETER: 'Missing required parameter',
126
+ UNAUTHORIZED: 'Unauthorized',
127
+ FORBIDDEN: 'Forbidden',
128
+ INTERNAL_SERVER_ERROR: 'Internal server error',
129
+ INITIALIZATION_FAILED: 'Initialization failed',
130
+ DATABASE_CONNECTION_ERROR: 'Database connection error',
131
+ DATABASE_QUERY_ERROR: 'Database query error',
132
+ INVALID_CONFIGURATION: 'Invalid configuration',
133
+ REQUEST_HANDLER_ERROR: 'Request handler error',
134
+ INVALID_REQUEST: 'Invalid request',
135
+ UNKNOWN_ERROR: 'Unknown error',
136
+ NETWORK_ERROR: 'Network error',
137
+ PLUGIN_INITIALIZATION_FAILED: 'Plugin initialization failed',
138
+ API_RETRIEVAL_ERROR: 'API retrieval error',
139
+ VALIDATION_ERROR: 'Validation error',
140
+ UNEXPECTED: 'Unexpected error'
141
+ });
142
+ const ERROR_CATEGORIES = Object.freeze({
143
+ VALIDATION: 'validation',
144
+ AUTHORIZATION: 'authorization',
145
+ STORAGE: 'storage',
146
+ NETWORK: 'network',
147
+ PLUGIN: 'plugin',
148
+ CONFIGURATION: 'configuration',
149
+ UNEXPECTED: 'unexpected'
150
+ });
151
+ const api_namespaceObject = require("@opentelemetry/api");
152
+ api_namespaceObject.trace.getTracer('@doubletie/results');
153
+ class error_class_DoubleTieError extends server_namespaceObject.ORPCError {
154
+ category;
155
+ meta;
156
+ statusCode;
157
+ constructor(message, options = {
158
+ code: error_codes_ERROR_CODES.UNKNOWN_ERROR,
159
+ status: 500,
160
+ category: ERROR_CATEGORIES.UNEXPECTED,
161
+ cause: void 0,
162
+ meta: {}
163
+ }){
164
+ super(options.code ?? error_codes_ERROR_CODES.UNKNOWN_ERROR, {
165
+ message,
166
+ cause: options.cause,
167
+ data: options.meta ?? {}
168
+ });
169
+ this.name = 'DoubleTieError';
170
+ this.category = options.category ?? ERROR_CATEGORIES.UNEXPECTED;
171
+ this.meta = options.meta ?? {};
172
+ this.statusCode = options.status ?? 500;
173
+ tracing_withSpan('create_doubletie_error', async (span)=>{
174
+ span.setAttributes({
175
+ 'error.name': this.constructor.name,
176
+ 'error.message': message,
177
+ 'error.code': this.code,
178
+ 'error.status': this.statusCode,
179
+ 'error.category': this.category,
180
+ 'error.has_cause': !!this.cause,
181
+ 'error.cause_type': this.cause instanceof Error ? this.cause.constructor.name : typeof this.cause,
182
+ 'error.has_meta': !!this.meta
183
+ });
184
+ if (this.cause instanceof Error) span.recordException(this.cause);
185
+ });
186
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
187
+ }
188
+ static isDoubleTieError(error) {
189
+ return error instanceof error_class_DoubleTieError;
190
+ }
191
+ toJSON() {
192
+ const validationErrorMessage = this.meta?.validationErrors ? String(this.meta.validationErrors) : void 0;
193
+ const stackTrace = this.stack ? this.stack.split('\n').map((line)=>line.trim()).filter((line)=>line && !line.includes('Error: ')) : [];
194
+ return {
195
+ code: this.code,
196
+ message: validationErrorMessage || this.message,
197
+ status: this.statusCode,
198
+ defined: true,
199
+ data: {
200
+ category: this.category,
201
+ meta: this.meta,
202
+ ...'production' === process.env.NODE_ENV ? {} : {
203
+ stack: stackTrace
204
+ },
205
+ ...validationErrorMessage && this.message ? {
206
+ originalMessage: this.message
207
+ } : {},
208
+ ...this.cause ? {
209
+ cause: this.cause instanceof Error ? {
210
+ name: this.cause.name,
211
+ message: this.cause.message,
212
+ stack: this.cause.stack ? this.cause.stack.split('\n').map((line)=>line.trim()) : void 0
213
+ } : this.cause
214
+ } : {}
215
+ }
216
+ };
217
+ }
218
+ static fromResponse(response, data) {
219
+ let message = `HTTP error ${response.status}`;
220
+ let errorCode = `HTTP ${response.status}`;
221
+ let errorMeta = {};
222
+ if (data && 'object' == typeof data && null !== data) {
223
+ const errorObj = data;
224
+ if ('string' == typeof errorObj.message) message = errorObj.message;
225
+ if ('string' == typeof errorObj.code) errorCode = errorObj.code;
226
+ if ('object' == typeof errorObj.data && null !== errorObj.data) errorMeta = errorObj.data;
227
+ }
228
+ return new error_class_DoubleTieError(message, {
229
+ code: errorCode,
230
+ status: response.status,
231
+ meta: errorMeta
232
+ });
233
+ }
234
+ withMeta(additionalMeta) {
235
+ return new error_class_DoubleTieError(this.message, {
236
+ code: this.code,
237
+ status: this.statusCode,
238
+ category: this.category,
239
+ cause: this.cause instanceof Error ? this.cause : void 0,
240
+ meta: {
241
+ ...this.meta,
242
+ ...additionalMeta
243
+ }
244
+ });
245
+ }
246
+ static createSubclass(name) {
247
+ const ErrorSubclass = class extends error_class_DoubleTieError {
248
+ constructor(message, options){
249
+ super(message, options);
250
+ Object.defineProperty(this, 'name', {
251
+ value: name
252
+ });
253
+ }
254
+ };
255
+ Object.defineProperty(ErrorSubclass, 'name', {
256
+ value: name
257
+ });
258
+ return ErrorSubclass;
259
+ }
260
+ static formatValidationError(error) {
261
+ if (!error.meta) return error.message;
262
+ let formattedMessage = `${error.message} (${error.code})`;
263
+ if (error.meta.validationErrors) formattedMessage += `\nValidation Errors: ${JSON.stringify(error.meta.validationErrors, null, 2)}`;
264
+ const otherMeta = Object.fromEntries(Object.entries(error.meta).filter(([key])=>'validationErrors' !== key));
265
+ if (Object.keys(otherMeta).length > 0) formattedMessage += `\nAdditional Context: ${JSON.stringify(otherMeta, null, 2)}`;
266
+ return formattedMessage;
267
+ }
268
+ }
269
+ require("@doubletie/logger");
270
+ external_zod_namespaceObject.z.object({
271
+ id: external_zod_namespaceObject.z.string(),
272
+ entityType: external_zod_namespaceObject.z.string(),
273
+ entityId: external_zod_namespaceObject.z.string(),
274
+ actionType: external_zod_namespaceObject.z.string(),
275
+ subjectId: external_zod_namespaceObject.z.string().optional(),
276
+ ipAddress: external_zod_namespaceObject.z.string().optional(),
277
+ userAgent: external_zod_namespaceObject.z.string().optional(),
278
+ changes: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).optional(),
279
+ metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).optional(),
280
+ createdAt: external_zod_namespaceObject.z.date().default(()=>new Date())
281
+ });
282
+ const PolicyTypeSchema = external_zod_namespaceObject.z["enum"]([
283
+ 'cookie_banner',
284
+ 'privacy_policy',
285
+ 'dpa',
286
+ 'terms_and_conditions',
287
+ 'marketing_communications',
288
+ 'age_verification',
289
+ 'other'
290
+ ]);
291
+ external_zod_namespaceObject.z.object({
292
+ id: external_zod_namespaceObject.z.string(),
293
+ version: external_zod_namespaceObject.z.string(),
294
+ type: PolicyTypeSchema,
295
+ name: external_zod_namespaceObject.z.string(),
296
+ effectiveDate: external_zod_namespaceObject.z.date(),
297
+ expirationDate: external_zod_namespaceObject.z.date().nullable().optional(),
298
+ content: external_zod_namespaceObject.z.string(),
299
+ contentHash: external_zod_namespaceObject.z.string(),
300
+ isActive: external_zod_namespaceObject.z.boolean().default(true),
301
+ createdAt: external_zod_namespaceObject.z.date().default(()=>new Date()),
302
+ updatedAt: external_zod_namespaceObject.z.date().default(()=>new Date())
303
+ });
304
+ external_zod_namespaceObject.z.object({
305
+ id: external_zod_namespaceObject.z.string(),
306
+ code: external_zod_namespaceObject.z.string(),
307
+ name: external_zod_namespaceObject.z.string(),
308
+ description: external_zod_namespaceObject.z.string(),
309
+ isEssential: external_zod_namespaceObject.z.boolean().default(false),
310
+ dataCategory: external_zod_namespaceObject.z.string().optional(),
311
+ legalBasis: external_zod_namespaceObject.z.string().optional(),
312
+ isActive: external_zod_namespaceObject.z.boolean().default(true),
313
+ createdAt: external_zod_namespaceObject.z.date().default(()=>new Date()),
314
+ updatedAt: external_zod_namespaceObject.z.date().default(()=>new Date())
315
+ });
316
+ external_zod_namespaceObject.z.object({
317
+ id: external_zod_namespaceObject.z.string(),
318
+ subjectId: external_zod_namespaceObject.z.string(),
319
+ consentId: external_zod_namespaceObject.z.string().optional(),
320
+ actionType: external_zod_namespaceObject.z.string(),
321
+ details: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).optional(),
322
+ createdAt: external_zod_namespaceObject.z.date().default(()=>new Date()),
323
+ updatedAt: external_zod_namespaceObject.z.date().default(()=>new Date())
324
+ });
325
+ external_zod_namespaceObject.z.object({
326
+ id: external_zod_namespaceObject.z.string(),
327
+ subjectId: external_zod_namespaceObject.z.string(),
328
+ domainId: external_zod_namespaceObject.z.string(),
329
+ purposeIds: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
330
+ metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).nullable().optional(),
331
+ policyId: external_zod_namespaceObject.z.string().optional(),
332
+ ipAddress: external_zod_namespaceObject.z.string().nullable().optional(),
333
+ userAgent: external_zod_namespaceObject.z.string().nullable().optional(),
334
+ status: external_zod_namespaceObject.z["enum"]([
335
+ 'active',
336
+ 'withdrawn',
337
+ 'expired'
338
+ ]).default('active'),
339
+ withdrawalReason: external_zod_namespaceObject.z.string().nullable().optional(),
340
+ givenAt: external_zod_namespaceObject.z.date().default(()=>new Date()),
341
+ validUntil: external_zod_namespaceObject.z.date().nullable().optional(),
342
+ isActive: external_zod_namespaceObject.z.boolean().default(true)
343
+ });
344
+ external_zod_namespaceObject.z.object({
345
+ id: external_zod_namespaceObject.z.string(),
346
+ name: external_zod_namespaceObject.z.string().min(1),
347
+ description: external_zod_namespaceObject.z.string().optional(),
348
+ allowedOrigins: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional().default([]),
349
+ isVerified: external_zod_namespaceObject.z.boolean().default(true),
350
+ isActive: external_zod_namespaceObject.z.boolean().default(true),
351
+ createdAt: external_zod_namespaceObject.z.date().default(()=>new Date()),
352
+ updatedAt: external_zod_namespaceObject.z.date().default(()=>new Date())
353
+ });
354
+ external_zod_namespaceObject.z.object({
355
+ id: external_zod_namespaceObject.z.string(),
356
+ isIdentified: external_zod_namespaceObject.z.boolean().default(false),
357
+ externalId: external_zod_namespaceObject.z.string().nullable().optional(),
358
+ identityProvider: external_zod_namespaceObject.z.string().optional(),
359
+ lastIpAddress: external_zod_namespaceObject.z.string().optional(),
360
+ createdAt: external_zod_namespaceObject.z.date().default(()=>new Date()),
361
+ updatedAt: external_zod_namespaceObject.z.date().default(()=>new Date())
362
+ });
363
+ const baseConsentSchema = external_zod_namespaceObject.z.object({
364
+ subjectId: external_zod_namespaceObject.z.string().optional(),
365
+ externalSubjectId: external_zod_namespaceObject.z.string().optional(),
366
+ domain: external_zod_namespaceObject.z.string(),
367
+ type: PolicyTypeSchema,
368
+ metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).optional()
369
+ });
370
+ const cookieBannerSchema = baseConsentSchema.extend({
371
+ type: external_zod_namespaceObject.z.literal('cookie_banner'),
372
+ preferences: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.boolean())
373
+ });
374
+ const policyBasedSchema = baseConsentSchema.extend({
375
+ type: external_zod_namespaceObject.z["enum"]([
376
+ 'privacy_policy',
377
+ 'dpa',
378
+ 'terms_and_conditions'
379
+ ]),
380
+ policyId: external_zod_namespaceObject.z.string().optional(),
381
+ preferences: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.boolean()).optional()
382
+ });
383
+ const otherConsentSchema = baseConsentSchema.extend({
384
+ type: external_zod_namespaceObject.z["enum"]([
385
+ 'marketing_communications',
386
+ 'age_verification',
387
+ 'other'
388
+ ]),
389
+ preferences: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.boolean()).optional()
390
+ });
391
+ const postConsentContract = contract_namespaceObject.oc.route({
392
+ method: 'POST',
393
+ path: '/consent/set',
394
+ description: `Records a user's consent preferences and creates necessary consent records.
395
+ This endpoint handles various types of consent submissions:
396
+
397
+ 1. Cookie Banner Consent:
398
+ - Records granular cookie preferences
399
+ - Supports multiple consent purposes
400
+ - Creates audit trail for compliance
401
+
402
+ 2. Policy-Based Consent:
403
+ - Privacy Policy acceptance
404
+ - Data Processing Agreement (DPA) consent
405
+ - Terms and Conditions acceptance
406
+ - Links consent to specific policy versions
407
+
408
+ 3. Other Consent Types:
409
+ - Marketing communications preferences
410
+ - Age verification consent
411
+ - Custom consent types
412
+
413
+ The endpoint performs the following operations:
414
+ - Creates or retrieves subject records
415
+ - Validates domain and policy information
416
+ - Creates consent records with audit trails
417
+ - Records consent purposes and preferences
418
+ - Generates audit logs for compliance
419
+
420
+ Use this endpoint to record user consent and maintain a compliant consent management system.`,
421
+ tags: [
422
+ 'consent',
423
+ 'cookie-banner'
424
+ ]
425
+ }).errors({
426
+ INPUT_VALIDATION_FAILED: {
427
+ status: 422,
428
+ message: 'Invalid input parameters',
429
+ data: external_zod_namespaceObject.z.object({
430
+ formErrors: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
431
+ fieldErrors: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()))
432
+ })
433
+ },
434
+ SUBJECT_CREATION_FAILED: {
435
+ status: 400,
436
+ message: 'Failed to create or find subject',
437
+ data: external_zod_namespaceObject.z.object({
438
+ subjectId: external_zod_namespaceObject.z.string().optional(),
439
+ externalSubjectId: external_zod_namespaceObject.z.string().optional()
440
+ })
441
+ },
442
+ DOMAIN_CREATION_FAILED: {
443
+ status: 500,
444
+ message: 'Failed to create or find domain',
445
+ data: external_zod_namespaceObject.z.object({
446
+ domain: external_zod_namespaceObject.z.string()
447
+ })
448
+ },
449
+ POLICY_NOT_FOUND: {
450
+ status: 404,
451
+ message: 'Policy not found',
452
+ data: external_zod_namespaceObject.z.object({
453
+ policyId: external_zod_namespaceObject.z.string(),
454
+ type: external_zod_namespaceObject.z.string()
455
+ })
456
+ },
457
+ POLICY_INACTIVE: {
458
+ status: 409,
459
+ message: 'Policy is not active',
460
+ data: external_zod_namespaceObject.z.object({
461
+ policyId: external_zod_namespaceObject.z.string(),
462
+ type: external_zod_namespaceObject.z.string()
463
+ })
464
+ },
465
+ POLICY_CREATION_FAILED: {
466
+ status: 500,
467
+ message: 'Failed to create or find policy',
468
+ data: external_zod_namespaceObject.z.object({
469
+ type: external_zod_namespaceObject.z.string()
470
+ })
471
+ },
472
+ PURPOSE_CREATION_FAILED: {
473
+ status: 500,
474
+ message: 'Failed to create consent purpose',
475
+ data: external_zod_namespaceObject.z.object({
476
+ purposeCode: external_zod_namespaceObject.z.string()
477
+ })
478
+ },
479
+ CONSENT_CREATION_FAILED: {
480
+ status: 500,
481
+ message: 'Failed to create consent record',
482
+ data: external_zod_namespaceObject.z.object({
483
+ subjectId: external_zod_namespaceObject.z.string(),
484
+ domain: external_zod_namespaceObject.z.string()
485
+ })
486
+ }
487
+ }).input(external_zod_namespaceObject.z.discriminatedUnion('type', [
488
+ cookieBannerSchema,
489
+ policyBasedSchema,
490
+ otherConsentSchema
491
+ ])).output(external_zod_namespaceObject.z.object({
492
+ id: external_zod_namespaceObject.z.string(),
493
+ subjectId: external_zod_namespaceObject.z.string().optional(),
494
+ externalSubjectId: external_zod_namespaceObject.z.string().optional(),
495
+ domainId: external_zod_namespaceObject.z.string(),
496
+ domain: external_zod_namespaceObject.z.string(),
497
+ type: PolicyTypeSchema,
498
+ status: external_zod_namespaceObject.z.string(),
499
+ recordId: external_zod_namespaceObject.z.string(),
500
+ metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.unknown()).optional(),
501
+ givenAt: external_zod_namespaceObject.z.date()
502
+ }));
503
+ const JurisdictionCodeSchema = external_zod_namespaceObject.z["enum"]([
504
+ 'GDPR',
505
+ 'CH',
506
+ 'BR',
507
+ 'PIPEDA',
508
+ 'AU',
509
+ 'APPI',
510
+ 'PIPA',
511
+ 'NONE'
512
+ ]);
513
+ const JurisdictionInfoSchema = external_zod_namespaceObject.z.object({
514
+ code: JurisdictionCodeSchema,
515
+ message: external_zod_namespaceObject.z.string()
516
+ });
517
+ const showConsentBannerContract = contract_namespaceObject.oc.route({
518
+ method: 'GET',
519
+ path: '/show-consent-banner',
520
+ description: `Determines if a user should see a consent banner based on their location and applicable privacy regulations.
521
+ This endpoint performs the following checks:
522
+
523
+ 1. Detects the user's location using various header information:
524
+ - Cloudflare country headers
525
+ - Vercel IP country headers
526
+ - AWS CloudFront headers
527
+ - Custom country code headers
528
+
529
+ 2. Determines the applicable jurisdiction based on the location:
530
+ - GDPR (EU/EEA/UK)
531
+ - Swiss Data Protection Act
532
+ - LGPD (Brazil)
533
+ - PIPEDA (Canada)
534
+ - Australian Privacy Principles
535
+ - APPI (Japan)
536
+ - PIPA (South Korea)
537
+
538
+ 3. Returns detailed information about:
539
+ - Whether to show the consent banner
540
+ - The applicable jurisdiction and its requirements
541
+ - The user's detected location (country and region)
542
+
543
+ Use this endpoint to implement geo-targeted consent banners and ensure compliance with regional privacy regulations.`,
544
+ tags: [
545
+ 'cookie-banner'
546
+ ]
547
+ }).output(external_zod_namespaceObject.z.object({
548
+ showConsentBanner: external_zod_namespaceObject.z.boolean(),
549
+ jurisdiction: JurisdictionInfoSchema,
550
+ location: external_zod_namespaceObject.z.object({
551
+ countryCode: external_zod_namespaceObject.z.string().nullable(),
552
+ regionCode: external_zod_namespaceObject.z.string().nullable()
553
+ })
554
+ }));
555
+ const verifyConsentInputSchema = external_zod_namespaceObject.z.object({
556
+ subjectId: external_zod_namespaceObject.z.string().optional(),
557
+ externalSubjectId: external_zod_namespaceObject.z.string().optional(),
558
+ domain: external_zod_namespaceObject.z.string(),
559
+ type: PolicyTypeSchema,
560
+ policyId: external_zod_namespaceObject.z.string().optional(),
561
+ preferences: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional()
562
+ }).strict();
563
+ const verify_contract_consentSchema = external_zod_namespaceObject.z.object({
564
+ id: external_zod_namespaceObject.z.string(),
565
+ purposeIds: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string())
566
+ }).passthrough();
567
+ const verifyConsentContract = contract_namespaceObject.oc.route({
568
+ method: 'POST',
569
+ path: '/consent/verify',
570
+ description: `Verifies if a user has given valid consent for a specific policy and domain.
571
+ This endpoint performs comprehensive consent verification by:
572
+
573
+ 1. Validating the subject's identity (using subjectId or externalSubjectId)
574
+ 2. Verifying the domain's existence and validity
575
+ 3. Checking if the specified policy exists and is active
576
+ 4. Validating that all required purposes have been consented to
577
+ 5. Ensuring the consent record is current and valid
578
+
579
+ The endpoint supports different types of consent verification:
580
+ - Cookie banner consent verification
581
+ - Privacy policy consent verification
582
+ - Terms and conditions verification
583
+ - Marketing communications consent verification
584
+ - Age verification
585
+ - Custom consent types
586
+
587
+ Use this endpoint to ensure compliance with privacy regulations and to verify user consent before processing personal data.`,
588
+ tags: [
589
+ 'consent'
590
+ ]
591
+ }).errors({
592
+ INPUT_VALIDATION_FAILED: {
593
+ status: 422,
594
+ message: 'Invalid input parameters',
595
+ data: external_zod_namespaceObject.z.object({
596
+ formErrors: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
597
+ fieldErrors: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional())
598
+ })
599
+ },
600
+ SUBJECT_NOT_FOUND: {
601
+ status: 404,
602
+ message: 'Subject not found',
603
+ data: external_zod_namespaceObject.z.object({
604
+ subjectId: external_zod_namespaceObject.z.string().optional(),
605
+ externalSubjectId: external_zod_namespaceObject.z.string().optional()
606
+ })
607
+ },
608
+ DOMAIN_NOT_FOUND: {
609
+ status: 404,
610
+ message: 'Domain not found',
611
+ data: external_zod_namespaceObject.z.object({
612
+ domain: external_zod_namespaceObject.z.string()
613
+ })
614
+ },
615
+ POLICY_NOT_FOUND: {
616
+ status: 404,
617
+ message: 'Policy not found or invalid',
618
+ data: external_zod_namespaceObject.z.object({
619
+ policyId: external_zod_namespaceObject.z.string(),
620
+ type: external_zod_namespaceObject.z.string()
621
+ })
622
+ },
623
+ PURPOSES_NOT_FOUND: {
624
+ status: 404,
625
+ message: 'Could not find all specified purposes',
626
+ data: external_zod_namespaceObject.z.object({
627
+ preferences: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
628
+ foundPurposes: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string())
629
+ })
630
+ },
631
+ COOKIE_BANNER_PREFERENCES_REQUIRED: {
632
+ status: 400,
633
+ message: 'Preferences are required for cookie banner consent',
634
+ data: external_zod_namespaceObject.z.object({
635
+ type: external_zod_namespaceObject.z.literal('cookie_banner')
636
+ })
637
+ },
638
+ NO_CONSENT_FOUND: {
639
+ status: 404,
640
+ message: 'No consent found for the given policy',
641
+ data: external_zod_namespaceObject.z.object({
642
+ policyId: external_zod_namespaceObject.z.string(),
643
+ subjectId: external_zod_namespaceObject.z.string(),
644
+ domainId: external_zod_namespaceObject.z.string()
645
+ })
646
+ }
647
+ }).input(verifyConsentInputSchema).output(external_zod_namespaceObject.z.object({
648
+ isValid: external_zod_namespaceObject.z.boolean(),
649
+ reasons: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
650
+ consent: verify_contract_consentSchema.optional()
651
+ }));
652
+ const consentContracts = {
653
+ post: postConsentContract,
654
+ showBanner: showConsentBannerContract,
655
+ verify: verifyConsentContract
656
+ };
657
+ const statusContract = contract_namespaceObject.oc.route({
658
+ method: 'GET',
659
+ path: '/status',
660
+ description: `Returns the current operational status and health metrics of the service.
661
+ This endpoint provides real-time information about:
662
+ - Overall service status (ok/error)
663
+ - Current API version
664
+ - Server timestamp
665
+ - Storage system status and availability
666
+ - Client information (IP, User Agent, Region)
667
+
668
+ Use this endpoint for health checks, monitoring, and service status verification.`,
669
+ tags: [
670
+ 'meta'
671
+ ]
672
+ }).output(external_zod_namespaceObject.z.object({
673
+ status: external_zod_namespaceObject.z["enum"]([
674
+ 'ok',
675
+ 'error'
676
+ ]),
677
+ version: external_zod_namespaceObject.z.string(),
678
+ timestamp: external_zod_namespaceObject.z.date(),
679
+ storage: external_zod_namespaceObject.z.object({
680
+ type: external_zod_namespaceObject.z.string(),
681
+ available: external_zod_namespaceObject.z.boolean()
682
+ }),
683
+ client: external_zod_namespaceObject.z.object({
684
+ ip: external_zod_namespaceObject.z.string().nullable(),
685
+ userAgent: external_zod_namespaceObject.z.string().nullable(),
686
+ region: external_zod_namespaceObject.z.object({
687
+ countryCode: external_zod_namespaceObject.z.string().nullable(),
688
+ regionCode: external_zod_namespaceObject.z.string().nullable()
689
+ })
690
+ })
691
+ }));
692
+ const metaContracts = {
693
+ status: statusContract
694
+ };
695
+ const config = {
696
+ consent: consentContracts,
697
+ meta: metaContracts
698
+ };
699
+ const os = (0, server_namespaceObject.implement)(config);
700
+ exports.contracts = __webpack_exports__.contracts;
701
+ exports.os = __webpack_exports__.os;
702
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
703
+ "contracts",
704
+ "os"
705
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
706
+ Object.defineProperty(exports, '__esModule', {
707
+ value: true
708
+ });