digitaltwin-core 0.14.3 → 1.0.1
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/README.md +218 -1
- package/dist/auth/apisix_parser.d.ts +56 -56
- package/dist/auth/apisix_parser.d.ts.map +1 -1
- package/dist/auth/apisix_parser.js +72 -86
- package/dist/auth/apisix_parser.js.map +1 -1
- package/dist/auth/auth_provider.d.ts +118 -0
- package/dist/auth/auth_provider.d.ts.map +1 -0
- package/dist/auth/auth_provider.js +8 -0
- package/dist/auth/auth_provider.js.map +1 -0
- package/dist/auth/auth_provider_factory.d.ts +91 -0
- package/dist/auth/auth_provider_factory.d.ts.map +1 -0
- package/dist/auth/auth_provider_factory.js +146 -0
- package/dist/auth/auth_provider_factory.js.map +1 -0
- package/dist/auth/index.d.ts +4 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/providers/gateway_auth_provider.d.ts +78 -0
- package/dist/auth/providers/gateway_auth_provider.d.ts.map +1 -0
- package/dist/auth/providers/gateway_auth_provider.js +109 -0
- package/dist/auth/providers/gateway_auth_provider.js.map +1 -0
- package/dist/auth/providers/index.d.ts +4 -0
- package/dist/auth/providers/index.d.ts.map +1 -0
- package/dist/auth/providers/index.js +4 -0
- package/dist/auth/providers/index.js.map +1 -0
- package/dist/auth/providers/jwt_auth_provider.d.ts +91 -0
- package/dist/auth/providers/jwt_auth_provider.d.ts.map +1 -0
- package/dist/auth/providers/jwt_auth_provider.js +204 -0
- package/dist/auth/providers/jwt_auth_provider.js.map +1 -0
- package/dist/auth/providers/no_auth_provider.d.ts +61 -0
- package/dist/auth/providers/no_auth_provider.d.ts.map +1 -0
- package/dist/auth/providers/no_auth_provider.js +76 -0
- package/dist/auth/providers/no_auth_provider.js.map +1 -0
- package/dist/auth/types.d.ts +5 -3
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/components/assets_manager.d.ts +1 -1
- package/dist/components/assets_manager.d.ts.map +1 -1
- package/dist/components/assets_manager.js +54 -48
- package/dist/components/assets_manager.js.map +1 -1
- package/dist/components/collector.d.ts.map +1 -1
- package/dist/components/collector.js +30 -18
- package/dist/components/collector.js.map +1 -1
- package/dist/components/custom_table_manager.d.ts.map +1 -1
- package/dist/components/custom_table_manager.js +36 -65
- package/dist/components/custom_table_manager.js.map +1 -1
- package/dist/components/global_assets_handler.d.ts +4 -2
- package/dist/components/global_assets_handler.d.ts.map +1 -1
- package/dist/components/global_assets_handler.js.map +1 -1
- package/dist/components/harvester.d.ts.map +1 -1
- package/dist/components/harvester.js +46 -33
- package/dist/components/harvester.js.map +1 -1
- package/dist/components/interfaces.d.ts +3 -2
- package/dist/components/interfaces.d.ts.map +1 -1
- package/dist/components/map_manager.d.ts.map +1 -1
- package/dist/components/map_manager.js.map +1 -1
- package/dist/components/tileset_manager.d.ts +2 -1
- package/dist/components/tileset_manager.d.ts.map +1 -1
- package/dist/components/tileset_manager.js +20 -15
- package/dist/components/tileset_manager.js.map +1 -1
- package/dist/database/adapters/knex_database_adapter.d.ts +6 -1
- package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -1
- package/dist/database/adapters/knex_database_adapter.js +118 -36
- package/dist/database/adapters/knex_database_adapter.js.map +1 -1
- package/dist/database/database_adapter.d.ts +13 -1
- package/dist/database/database_adapter.d.ts.map +1 -1
- package/dist/database/database_adapter.js.map +1 -1
- package/dist/engine/component_types.d.ts +95 -0
- package/dist/engine/component_types.d.ts.map +1 -0
- package/dist/engine/component_types.js +93 -0
- package/dist/engine/component_types.js.map +1 -0
- package/dist/engine/digital_twin_engine.d.ts +121 -6
- package/dist/engine/digital_twin_engine.d.ts.map +1 -1
- package/dist/engine/digital_twin_engine.js +402 -74
- package/dist/engine/digital_twin_engine.js.map +1 -1
- package/dist/engine/endpoints.d.ts.map +1 -1
- package/dist/engine/endpoints.js +35 -3
- package/dist/engine/endpoints.js.map +1 -1
- package/dist/engine/error_handler.d.ts +20 -0
- package/dist/engine/error_handler.d.ts.map +1 -0
- package/dist/engine/error_handler.js +69 -0
- package/dist/engine/error_handler.js.map +1 -0
- package/dist/engine/events.d.ts +1 -1
- package/dist/engine/events.d.ts.map +1 -1
- package/dist/engine/events.js.map +1 -1
- package/dist/engine/health.d.ts +112 -0
- package/dist/engine/health.d.ts.map +1 -0
- package/dist/engine/health.js +190 -0
- package/dist/engine/health.js.map +1 -0
- package/dist/engine/initializer.d.ts.map +1 -1
- package/dist/engine/initializer.js +6 -4
- package/dist/engine/initializer.js.map +1 -1
- package/dist/engine/scheduler.d.ts.map +1 -1
- package/dist/engine/scheduler.js +17 -9
- package/dist/engine/scheduler.js.map +1 -1
- package/dist/engine/upload_processor.d.ts.map +1 -1
- package/dist/engine/upload_processor.js +24 -12
- package/dist/engine/upload_processor.js.map +1 -1
- package/dist/errors/index.d.ts +94 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +149 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/loader/component_loader.d.ts +128 -0
- package/dist/loader/component_loader.d.ts.map +1 -0
- package/dist/loader/component_loader.js +330 -0
- package/dist/loader/component_loader.js.map +1 -0
- package/dist/loader/index.d.ts +19 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +19 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/storage/adapters/local_storage_service.d.ts +6 -0
- package/dist/storage/adapters/local_storage_service.d.ts.map +1 -1
- package/dist/storage/adapters/local_storage_service.js +26 -4
- package/dist/storage/adapters/local_storage_service.js.map +1 -1
- package/dist/storage/adapters/ovh_storage_service.d.ts.map +1 -1
- package/dist/storage/adapters/ovh_storage_service.js +5 -6
- package/dist/storage/adapters/ovh_storage_service.js.map +1 -1
- package/dist/storage/storage_factory.d.ts.map +1 -1
- package/dist/storage/storage_factory.js +4 -1
- package/dist/storage/storage_factory.js.map +1 -1
- package/dist/storage/storage_service.d.ts.map +1 -1
- package/dist/storage/storage_service.js +6 -2
- package/dist/storage/storage_service.js.map +1 -1
- package/dist/types/http.d.ts +156 -0
- package/dist/types/http.d.ts.map +1 -0
- package/dist/types/http.js +8 -0
- package/dist/types/http.js.map +1 -0
- package/dist/utils/graceful_shutdown.d.ts +44 -0
- package/dist/utils/graceful_shutdown.d.ts.map +1 -0
- package/dist/utils/graceful_shutdown.js +79 -0
- package/dist/utils/graceful_shutdown.js.map +1 -0
- package/dist/utils/http_responses.d.ts +20 -0
- package/dist/utils/http_responses.d.ts.map +1 -1
- package/dist/utils/http_responses.js +28 -2
- package/dist/utils/http_responses.js.map +1 -1
- package/dist/utils/logger.d.ts +8 -8
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +8 -8
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/safe_async.d.ts +50 -0
- package/dist/utils/safe_async.d.ts.map +1 -0
- package/dist/utils/safe_async.js +90 -0
- package/dist/utils/safe_async.js.map +1 -0
- package/dist/validation/index.d.ts +3 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +7 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/schemas.d.ts +273 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +82 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/validation/validate.d.ts +49 -0
- package/dist/validation/validate.d.ts.map +1 -0
- package/dist/validation/validate.js +110 -0
- package/dist/validation/validate.js.map +1 -0
- package/package.json +14 -8
package/dist/utils/logger.js
CHANGED
|
@@ -48,44 +48,44 @@ export class Logger {
|
|
|
48
48
|
* Logs debug information for development and troubleshooting.
|
|
49
49
|
*
|
|
50
50
|
* @param {string} message - Debug message
|
|
51
|
-
* @param {
|
|
51
|
+
* @param {unknown} data - Optional additional data to log
|
|
52
52
|
*/
|
|
53
53
|
debug(message, data) {
|
|
54
54
|
if (this.level <= LogLevel.DEBUG) {
|
|
55
|
-
console.log(`[${this.componentName}] DEBUG: ${message}`, data
|
|
55
|
+
console.log(`[${this.componentName}] DEBUG: ${message}`, data ?? '');
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Logs informational messages about normal operation.
|
|
60
60
|
*
|
|
61
61
|
* @param {string} message - Information message
|
|
62
|
-
* @param {
|
|
62
|
+
* @param {unknown} data - Optional additional data to log
|
|
63
63
|
*/
|
|
64
64
|
info(message, data) {
|
|
65
65
|
if (this.level <= LogLevel.INFO) {
|
|
66
|
-
console.log(`[${this.componentName}] ${message}`, data
|
|
66
|
+
console.log(`[${this.componentName}] ${message}`, data ?? '');
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Logs warning messages about potential issues.
|
|
71
71
|
*
|
|
72
72
|
* @param {string} message - Warning message
|
|
73
|
-
* @param {
|
|
73
|
+
* @param {unknown} data - Optional additional data to log
|
|
74
74
|
*/
|
|
75
75
|
warn(message, data) {
|
|
76
76
|
if (this.level <= LogLevel.WARN) {
|
|
77
|
-
console.warn(`[${this.componentName}] WARN: ${message}`, data
|
|
77
|
+
console.warn(`[${this.componentName}] WARN: ${message}`, data ?? '');
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Logs error messages about failures and exceptions.
|
|
82
82
|
*
|
|
83
83
|
* @param {string} message - Error message
|
|
84
|
-
* @param {
|
|
84
|
+
* @param {Error | unknown} error - Optional error object or additional data
|
|
85
85
|
*/
|
|
86
86
|
error(message, error) {
|
|
87
87
|
if (this.level <= LogLevel.ERROR) {
|
|
88
|
-
console.error(`[${this.componentName}] ERROR: ${message}`, error
|
|
88
|
+
console.error(`[${this.componentName}] ERROR: ${message}`, error ?? '');
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
package/dist/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAChB,yEAAyE;IACzE,yCAAS,CAAA;IACT,wDAAwD;IACxD,uCAAQ,CAAA;IACR,uEAAuE;IACvE,uCAAQ,CAAA;IACR,0DAA0D;IAC1D,yCAAS,CAAA;IACT,sCAAsC;IACtC,2CAAU,CAAA;AACd,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,MAAM;IACf;;;;;OAKG;IACH,YACqB,aAAqB,EACrB,QAAkB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI;QADlF,kBAAa,GAAb,aAAa,CAAQ;QACrB,UAAK,GAAL,KAAK,CAA6E;IACpG,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,OAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAChB,yEAAyE;IACzE,yCAAS,CAAA;IACT,wDAAwD;IACxD,uCAAQ,CAAA;IACR,uEAAuE;IACvE,uCAAQ,CAAA;IACR,0DAA0D;IAC1D,yCAAS,CAAA;IACT,sCAAsC;IACtC,2CAAU,CAAA;AACd,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,MAAM;IACf;;;;;OAKG;IACH,YACqB,aAAqB,EACrB,QAAkB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ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
|
+
import { Logger } from './logger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Executes an async operation with error logging
|
|
8
|
+
* For cleanup operations where errors should not block execution
|
|
9
|
+
*
|
|
10
|
+
* @param operation - The async function to execute
|
|
11
|
+
* @param context - Description of the operation for logging
|
|
12
|
+
* @param logger - Optional logger instance
|
|
13
|
+
* @returns The result of the operation, or undefined if it failed
|
|
14
|
+
*/
|
|
15
|
+
export declare function safeAsync<T>(operation: () => Promise<T>, context: string, logger?: Logger): Promise<T | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Executes an async operation and returns a Result tuple
|
|
18
|
+
* Useful when you need to know if the operation failed but continue execution
|
|
19
|
+
*
|
|
20
|
+
* @param operation - The async function to execute
|
|
21
|
+
* @returns [result, undefined] on success, [undefined, error] on failure
|
|
22
|
+
*/
|
|
23
|
+
export declare function tryAsync<T>(operation: () => Promise<T>): Promise<[T, undefined] | [undefined, Error]>;
|
|
24
|
+
/**
|
|
25
|
+
* Executes multiple cleanup operations in parallel, logging any failures
|
|
26
|
+
* All operations will be attempted even if some fail
|
|
27
|
+
*
|
|
28
|
+
* @param operations - Array of cleanup operations with context
|
|
29
|
+
* @param logger - Optional logger instance
|
|
30
|
+
*/
|
|
31
|
+
export declare function safeCleanup(operations: Array<{
|
|
32
|
+
operation: () => Promise<unknown>;
|
|
33
|
+
context: string;
|
|
34
|
+
}>, logger?: Logger): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Retries an async operation with exponential backoff
|
|
37
|
+
*
|
|
38
|
+
* @param operation - The async function to execute
|
|
39
|
+
* @param options - Retry options
|
|
40
|
+
* @returns The result of the operation
|
|
41
|
+
* @throws The last error if all retries fail
|
|
42
|
+
*/
|
|
43
|
+
export declare function retryAsync<T>(operation: () => Promise<T>, options?: {
|
|
44
|
+
maxRetries?: number;
|
|
45
|
+
initialDelayMs?: number;
|
|
46
|
+
maxDelayMs?: number;
|
|
47
|
+
context?: string;
|
|
48
|
+
logger?: Logger;
|
|
49
|
+
}): Promise<T>;
|
|
50
|
+
//# sourceMappingURL=safe_async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe_async.d.ts","sourceRoot":"","sources":["../../src/utils/safe_async.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAIpC;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CASxB;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAQ3G;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC7B,UAAU,EAAE,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACzE,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAC9B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,GAAE;IACL,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CACb,GACP,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for safe async operations
|
|
3
|
+
* Provides error handling for non-critical operations like cleanup
|
|
4
|
+
*/
|
|
5
|
+
import { Logger } from './logger.js';
|
|
6
|
+
const defaultLogger = new Logger('SafeAsync');
|
|
7
|
+
/**
|
|
8
|
+
* Executes an async operation with error logging
|
|
9
|
+
* For cleanup operations where errors should not block execution
|
|
10
|
+
*
|
|
11
|
+
* @param operation - The async function to execute
|
|
12
|
+
* @param context - Description of the operation for logging
|
|
13
|
+
* @param logger - Optional logger instance
|
|
14
|
+
* @returns The result of the operation, or undefined if it failed
|
|
15
|
+
*/
|
|
16
|
+
export async function safeAsync(operation, context, logger) {
|
|
17
|
+
try {
|
|
18
|
+
return await operation();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const log = logger ?? defaultLogger;
|
|
22
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23
|
+
log.warn(`Non-critical error in ${context}: ${message}`);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Executes an async operation and returns a Result tuple
|
|
29
|
+
* Useful when you need to know if the operation failed but continue execution
|
|
30
|
+
*
|
|
31
|
+
* @param operation - The async function to execute
|
|
32
|
+
* @returns [result, undefined] on success, [undefined, error] on failure
|
|
33
|
+
*/
|
|
34
|
+
export async function tryAsync(operation) {
|
|
35
|
+
try {
|
|
36
|
+
const result = await operation();
|
|
37
|
+
return [result, undefined];
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
41
|
+
return [undefined, err];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Executes multiple cleanup operations in parallel, logging any failures
|
|
46
|
+
* All operations will be attempted even if some fail
|
|
47
|
+
*
|
|
48
|
+
* @param operations - Array of cleanup operations with context
|
|
49
|
+
* @param logger - Optional logger instance
|
|
50
|
+
*/
|
|
51
|
+
export async function safeCleanup(operations, logger) {
|
|
52
|
+
const log = logger ?? defaultLogger;
|
|
53
|
+
const results = await Promise.allSettled(operations.map(({ operation, context }) => operation().catch(error => {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
log.warn(`Cleanup failed for ${context}: ${message}`);
|
|
56
|
+
throw error;
|
|
57
|
+
})));
|
|
58
|
+
const failures = results.filter(r => r.status === 'rejected').length;
|
|
59
|
+
if (failures > 0) {
|
|
60
|
+
log.warn(`${failures}/${operations.length} cleanup operations failed`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Retries an async operation with exponential backoff
|
|
65
|
+
*
|
|
66
|
+
* @param operation - The async function to execute
|
|
67
|
+
* @param options - Retry options
|
|
68
|
+
* @returns The result of the operation
|
|
69
|
+
* @throws The last error if all retries fail
|
|
70
|
+
*/
|
|
71
|
+
export async function retryAsync(operation, options = {}) {
|
|
72
|
+
const { maxRetries = 3, initialDelayMs = 100, maxDelayMs = 5000, context = 'operation', logger } = options;
|
|
73
|
+
const log = logger ?? defaultLogger;
|
|
74
|
+
let lastError;
|
|
75
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
76
|
+
try {
|
|
77
|
+
return await operation();
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
81
|
+
if (attempt < maxRetries) {
|
|
82
|
+
const delay = Math.min(initialDelayMs * Math.pow(2, attempt), maxDelayMs);
|
|
83
|
+
log.warn(`${context} failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms: ${lastError.message}`);
|
|
84
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
throw lastError;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=safe_async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;YAErE,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;gBACvB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,CAAA;gBACzE,GAAG,CAAC,IAAI,CACJ,GAAG,OAAO,oBAAoB,OAAO,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC,kBAAkB,KAAK,OAAO,SAAS,CAAC,OAAO,EAAE,CAC/G,CAAA;gBACD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;YAC5D,CAAC;QACL,CAAC;IACL,CAAC;IAED,MAAM,SAAS,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { paginationSchema, idParamSchema, assetUploadSchema, assetUpdateSchema, assetBatchUploadSchema, customRecordCreateSchema, customRecordUpdateSchema, dateRangeQuerySchema, validatePagination, validateIdParam, validateAssetUpload, validateAssetUpdate, validateAssetBatchUpload, validateCustomRecordCreate, validateCustomRecordUpdate, validateDateRangeQuery } from './schemas.js';
|
|
2
|
+
export { validateData, safeValidate, validateQuery, validateParams, vine } from './validate.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EAEpB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACzB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Validation schemas
|
|
2
|
+
export { paginationSchema, idParamSchema, assetUploadSchema, assetUpdateSchema, assetBatchUploadSchema, customRecordCreateSchema, customRecordUpdateSchema, dateRangeQuerySchema,
|
|
3
|
+
// Pre-compiled validators
|
|
4
|
+
validatePagination, validateIdParam, validateAssetUpload, validateAssetUpdate, validateAssetBatchUpload, validateCustomRecordCreate, validateCustomRecordUpdate, validateDateRangeQuery } from './schemas.js';
|
|
5
|
+
// Validation helpers
|
|
6
|
+
export { validateData, safeValidate, validateQuery, validateParams, vine } from './validate.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACH,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB;AACpB,0BAA0B;AAC1B,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACzB,MAAM,cAAc,CAAA;AAErB,qBAAqB;AACrB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination query parameters schema
|
|
3
|
+
*/
|
|
4
|
+
export declare const paginationSchema: import("@vinejs/vine").VineObject<{
|
|
5
|
+
limit: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineNumber>;
|
|
6
|
+
offset: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineNumber>;
|
|
7
|
+
}, {
|
|
8
|
+
limit?: string | number | null | undefined;
|
|
9
|
+
offset?: string | number | null | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
limit?: number | undefined;
|
|
12
|
+
offset?: number | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
offset?: number | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* ID parameter schema
|
|
19
|
+
*/
|
|
20
|
+
export declare const idParamSchema: import("@vinejs/vine").VineObject<{
|
|
21
|
+
id: import("@vinejs/vine").VineNumber;
|
|
22
|
+
}, {
|
|
23
|
+
id: string | number;
|
|
24
|
+
}, {
|
|
25
|
+
id: number;
|
|
26
|
+
}, {
|
|
27
|
+
id: number;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Asset upload body schema
|
|
31
|
+
*/
|
|
32
|
+
export declare const assetUploadSchema: import("@vinejs/vine").VineObject<{
|
|
33
|
+
description: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
34
|
+
source: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
35
|
+
is_public: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineBoolean>;
|
|
36
|
+
}, {
|
|
37
|
+
description?: string | null | undefined;
|
|
38
|
+
source?: string | null | undefined;
|
|
39
|
+
is_public?: string | number | boolean | null | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
description?: string | undefined;
|
|
42
|
+
source?: string | undefined;
|
|
43
|
+
is_public?: boolean | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
source?: string | undefined;
|
|
47
|
+
isPublic?: boolean | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Asset update body schema
|
|
51
|
+
*/
|
|
52
|
+
export declare const assetUpdateSchema: import("@vinejs/vine").VineObject<{
|
|
53
|
+
description: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
54
|
+
source: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
55
|
+
is_public: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineBoolean>;
|
|
56
|
+
}, {
|
|
57
|
+
description?: string | null | undefined;
|
|
58
|
+
source?: string | null | undefined;
|
|
59
|
+
is_public?: string | number | boolean | null | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
description?: string | undefined;
|
|
62
|
+
source?: string | undefined;
|
|
63
|
+
is_public?: boolean | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
description?: string | undefined;
|
|
66
|
+
source?: string | undefined;
|
|
67
|
+
isPublic?: boolean | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Batch upload body schema
|
|
71
|
+
*/
|
|
72
|
+
export declare const assetBatchUploadSchema: import("@vinejs/vine").VineObject<{
|
|
73
|
+
assets: import("@vinejs/vine").OptionalModifier<import("@vinejs/vine").VineArray<import("@vinejs/vine").VineObject<{
|
|
74
|
+
description: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
75
|
+
source: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
76
|
+
is_public: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineBoolean>;
|
|
77
|
+
}, {
|
|
78
|
+
description?: string | null | undefined;
|
|
79
|
+
source?: string | null | undefined;
|
|
80
|
+
is_public?: string | number | boolean | null | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
description?: string | undefined;
|
|
83
|
+
source?: string | undefined;
|
|
84
|
+
is_public?: boolean | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
description?: string | undefined;
|
|
87
|
+
source?: string | undefined;
|
|
88
|
+
isPublic?: boolean | undefined;
|
|
89
|
+
}>>>;
|
|
90
|
+
}, {
|
|
91
|
+
assets?: {
|
|
92
|
+
description?: string | null | undefined;
|
|
93
|
+
source?: string | null | undefined;
|
|
94
|
+
is_public?: string | number | boolean | null | undefined;
|
|
95
|
+
}[] | null | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
assets?: {
|
|
98
|
+
description?: string | undefined;
|
|
99
|
+
source?: string | undefined;
|
|
100
|
+
is_public?: boolean | undefined;
|
|
101
|
+
}[] | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
assets?: {
|
|
104
|
+
description?: string | undefined;
|
|
105
|
+
source?: string | undefined;
|
|
106
|
+
isPublic?: boolean | undefined;
|
|
107
|
+
}[] | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Custom record create schema (allows passthrough for dynamic fields)
|
|
111
|
+
*/
|
|
112
|
+
export declare const customRecordCreateSchema: import("@vinejs/vine").VineObject<{}, {} & {
|
|
113
|
+
[K: string]: unknown;
|
|
114
|
+
}, {} & {
|
|
115
|
+
[K: string]: unknown;
|
|
116
|
+
}, {} & {
|
|
117
|
+
[K: string]: unknown;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Custom record update schema
|
|
121
|
+
*/
|
|
122
|
+
export declare const customRecordUpdateSchema: import("@vinejs/vine").VineObject<{}, {} & {
|
|
123
|
+
[K: string]: unknown;
|
|
124
|
+
}, {} & {
|
|
125
|
+
[K: string]: unknown;
|
|
126
|
+
}, {} & {
|
|
127
|
+
[K: string]: unknown;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Date range query schema
|
|
131
|
+
*/
|
|
132
|
+
export declare const dateRangeQuerySchema: import("@vinejs/vine").VineObject<{
|
|
133
|
+
startDate: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
134
|
+
endDate: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
135
|
+
limit: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineNumber>;
|
|
136
|
+
}, {
|
|
137
|
+
startDate?: string | null | undefined;
|
|
138
|
+
endDate?: string | null | undefined;
|
|
139
|
+
limit?: string | number | null | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
startDate?: string | undefined;
|
|
142
|
+
endDate?: string | undefined;
|
|
143
|
+
limit?: number | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
startDate?: string | undefined;
|
|
146
|
+
endDate?: string | undefined;
|
|
147
|
+
limit?: number | undefined;
|
|
148
|
+
}>;
|
|
149
|
+
export declare const validatePagination: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{
|
|
150
|
+
limit: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineNumber>;
|
|
151
|
+
offset: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineNumber>;
|
|
152
|
+
}, {
|
|
153
|
+
limit?: string | number | null | undefined;
|
|
154
|
+
offset?: string | number | null | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
limit?: number | undefined;
|
|
157
|
+
offset?: number | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
limit?: number | undefined;
|
|
160
|
+
offset?: number | undefined;
|
|
161
|
+
}>, Record<string, any> | undefined>;
|
|
162
|
+
export declare const validateIdParam: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{
|
|
163
|
+
id: import("@vinejs/vine").VineNumber;
|
|
164
|
+
}, {
|
|
165
|
+
id: string | number;
|
|
166
|
+
}, {
|
|
167
|
+
id: number;
|
|
168
|
+
}, {
|
|
169
|
+
id: number;
|
|
170
|
+
}>, Record<string, any> | undefined>;
|
|
171
|
+
export declare const validateAssetUpload: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{
|
|
172
|
+
description: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
173
|
+
source: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
174
|
+
is_public: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineBoolean>;
|
|
175
|
+
}, {
|
|
176
|
+
description?: string | null | undefined;
|
|
177
|
+
source?: string | null | undefined;
|
|
178
|
+
is_public?: string | number | boolean | null | undefined;
|
|
179
|
+
}, {
|
|
180
|
+
description?: string | undefined;
|
|
181
|
+
source?: string | undefined;
|
|
182
|
+
is_public?: boolean | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
description?: string | undefined;
|
|
185
|
+
source?: string | undefined;
|
|
186
|
+
isPublic?: boolean | undefined;
|
|
187
|
+
}>, Record<string, any> | undefined>;
|
|
188
|
+
export declare const validateAssetUpdate: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{
|
|
189
|
+
description: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
190
|
+
source: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
191
|
+
is_public: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineBoolean>;
|
|
192
|
+
}, {
|
|
193
|
+
description?: string | null | undefined;
|
|
194
|
+
source?: string | null | undefined;
|
|
195
|
+
is_public?: string | number | boolean | null | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
description?: string | undefined;
|
|
198
|
+
source?: string | undefined;
|
|
199
|
+
is_public?: boolean | undefined;
|
|
200
|
+
}, {
|
|
201
|
+
description?: string | undefined;
|
|
202
|
+
source?: string | undefined;
|
|
203
|
+
isPublic?: boolean | undefined;
|
|
204
|
+
}>, Record<string, any> | undefined>;
|
|
205
|
+
export declare const validateAssetBatchUpload: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{
|
|
206
|
+
assets: import("@vinejs/vine").OptionalModifier<import("@vinejs/vine").VineArray<import("@vinejs/vine").VineObject<{
|
|
207
|
+
description: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
208
|
+
source: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
209
|
+
is_public: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineBoolean>;
|
|
210
|
+
}, {
|
|
211
|
+
description?: string | null | undefined;
|
|
212
|
+
source?: string | null | undefined;
|
|
213
|
+
is_public?: string | number | boolean | null | undefined;
|
|
214
|
+
}, {
|
|
215
|
+
description?: string | undefined;
|
|
216
|
+
source?: string | undefined;
|
|
217
|
+
is_public?: boolean | undefined;
|
|
218
|
+
}, {
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
source?: string | undefined;
|
|
221
|
+
isPublic?: boolean | undefined;
|
|
222
|
+
}>>>;
|
|
223
|
+
}, {
|
|
224
|
+
assets?: {
|
|
225
|
+
description?: string | null | undefined;
|
|
226
|
+
source?: string | null | undefined;
|
|
227
|
+
is_public?: string | number | boolean | null | undefined;
|
|
228
|
+
}[] | null | undefined;
|
|
229
|
+
}, {
|
|
230
|
+
assets?: {
|
|
231
|
+
description?: string | undefined;
|
|
232
|
+
source?: string | undefined;
|
|
233
|
+
is_public?: boolean | undefined;
|
|
234
|
+
}[] | undefined;
|
|
235
|
+
}, {
|
|
236
|
+
assets?: {
|
|
237
|
+
description?: string | undefined;
|
|
238
|
+
source?: string | undefined;
|
|
239
|
+
isPublic?: boolean | undefined;
|
|
240
|
+
}[] | undefined;
|
|
241
|
+
}>, Record<string, any> | undefined>;
|
|
242
|
+
export declare const validateCustomRecordCreate: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{}, {} & {
|
|
243
|
+
[K: string]: unknown;
|
|
244
|
+
}, {} & {
|
|
245
|
+
[K: string]: unknown;
|
|
246
|
+
}, {} & {
|
|
247
|
+
[K: string]: unknown;
|
|
248
|
+
}>, Record<string, any> | undefined>;
|
|
249
|
+
export declare const validateCustomRecordUpdate: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{}, {} & {
|
|
250
|
+
[K: string]: unknown;
|
|
251
|
+
}, {} & {
|
|
252
|
+
[K: string]: unknown;
|
|
253
|
+
}, {} & {
|
|
254
|
+
[K: string]: unknown;
|
|
255
|
+
}>, Record<string, any> | undefined>;
|
|
256
|
+
export declare const validateDateRangeQuery: import("@vinejs/vine").VineValidator<import("@vinejs/vine").VineObject<{
|
|
257
|
+
startDate: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
258
|
+
endDate: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineString>;
|
|
259
|
+
limit: import("@vinejs/vine/schema/base/literal").OptionalModifier<import("@vinejs/vine").VineNumber>;
|
|
260
|
+
}, {
|
|
261
|
+
startDate?: string | null | undefined;
|
|
262
|
+
endDate?: string | null | undefined;
|
|
263
|
+
limit?: string | number | null | undefined;
|
|
264
|
+
}, {
|
|
265
|
+
startDate?: string | undefined;
|
|
266
|
+
endDate?: string | undefined;
|
|
267
|
+
limit?: number | undefined;
|
|
268
|
+
}, {
|
|
269
|
+
startDate?: string | undefined;
|
|
270
|
+
endDate?: string | undefined;
|
|
271
|
+
limit?: number | undefined;
|
|
272
|
+
}>, Record<string, any> | undefined>;
|
|
273
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/validation/schemas.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAG3B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;EAExB,CAAA;AAMF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;EAI5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;EAI5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUjC,CAAA;AAMF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAA2C,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAA2C,CAAA;AAMhF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;EAI/B,CAAA;AAMF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;oCAAiC,CAAA;AAChE,eAAO,MAAM,eAAe;;;;;;;;oCAA8B,CAAA;AAC1D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;oCAAkC,CAAA;AAClE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;oCAAkC,CAAA;AAClE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAAuC,CAAA;AAC5E,eAAO,MAAM,0BAA0B;;;;;;oCAAyC,CAAA;AAChF,eAAO,MAAM,0BAA0B;;;;;;oCAAyC,CAAA;AAChF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;oCAAqC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import vine from '@vinejs/vine';
|
|
2
|
+
// ============================================
|
|
3
|
+
// Common schemas
|
|
4
|
+
// ============================================
|
|
5
|
+
/**
|
|
6
|
+
* Pagination query parameters schema
|
|
7
|
+
*/
|
|
8
|
+
export const paginationSchema = vine.object({
|
|
9
|
+
limit: vine.number().positive().max(1000).optional(),
|
|
10
|
+
offset: vine.number().min(0).optional()
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* ID parameter schema
|
|
14
|
+
*/
|
|
15
|
+
export const idParamSchema = vine.object({
|
|
16
|
+
id: vine.number().positive()
|
|
17
|
+
});
|
|
18
|
+
// ============================================
|
|
19
|
+
// Assets Manager schemas
|
|
20
|
+
// ============================================
|
|
21
|
+
/**
|
|
22
|
+
* Asset upload body schema
|
|
23
|
+
*/
|
|
24
|
+
export const assetUploadSchema = vine.object({
|
|
25
|
+
description: vine.string().maxLength(1000).optional(),
|
|
26
|
+
source: vine.string().url().optional(),
|
|
27
|
+
is_public: vine.boolean().optional()
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Asset update body schema
|
|
31
|
+
*/
|
|
32
|
+
export const assetUpdateSchema = vine.object({
|
|
33
|
+
description: vine.string().maxLength(1000).optional(),
|
|
34
|
+
source: vine.string().url().optional(),
|
|
35
|
+
is_public: vine.boolean().optional()
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Batch upload body schema
|
|
39
|
+
*/
|
|
40
|
+
export const assetBatchUploadSchema = vine.object({
|
|
41
|
+
assets: vine
|
|
42
|
+
.array(vine.object({
|
|
43
|
+
description: vine.string().maxLength(1000).optional(),
|
|
44
|
+
source: vine.string().url().optional(),
|
|
45
|
+
is_public: vine.boolean().optional()
|
|
46
|
+
}))
|
|
47
|
+
.optional()
|
|
48
|
+
});
|
|
49
|
+
// ============================================
|
|
50
|
+
// Custom Table Manager schemas
|
|
51
|
+
// ============================================
|
|
52
|
+
/**
|
|
53
|
+
* Custom record create schema (allows passthrough for dynamic fields)
|
|
54
|
+
*/
|
|
55
|
+
export const customRecordCreateSchema = vine.object({}).allowUnknownProperties();
|
|
56
|
+
/**
|
|
57
|
+
* Custom record update schema
|
|
58
|
+
*/
|
|
59
|
+
export const customRecordUpdateSchema = vine.object({}).allowUnknownProperties();
|
|
60
|
+
// ============================================
|
|
61
|
+
// Query parameter schemas
|
|
62
|
+
// ============================================
|
|
63
|
+
/**
|
|
64
|
+
* Date range query schema
|
|
65
|
+
*/
|
|
66
|
+
export const dateRangeQuerySchema = vine.object({
|
|
67
|
+
startDate: vine.string().optional(),
|
|
68
|
+
endDate: vine.string().optional(),
|
|
69
|
+
limit: vine.number().positive().max(1000).optional()
|
|
70
|
+
});
|
|
71
|
+
// ============================================
|
|
72
|
+
// Compiled validators (for performance)
|
|
73
|
+
// ============================================
|
|
74
|
+
export const validatePagination = vine.compile(paginationSchema);
|
|
75
|
+
export const validateIdParam = vine.compile(idParamSchema);
|
|
76
|
+
export const validateAssetUpload = vine.compile(assetUploadSchema);
|
|
77
|
+
export const validateAssetUpdate = vine.compile(assetUpdateSchema);
|
|
78
|
+
export const validateAssetBatchUpload = vine.compile(assetBatchUploadSchema);
|
|
79
|
+
export const validateCustomRecordCreate = vine.compile(customRecordCreateSchema);
|
|
80
|
+
export const validateCustomRecordUpdate = vine.compile(customRecordUpdateSchema);
|
|
81
|
+
export const validateDateRangeQuery = vine.compile(dateRangeQuerySchema);
|
|
82
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/validation/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,cAAc,CAAA;AAE/B,+CAA+C;AAC/C,iBAAiB;AACjB,+CAA+C;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAA;AAEF,+CAA+C;AAC/C,yBAAyB;AACzB,+CAA+C;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA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
|
|
3
|
+
validate: (data: unknown) => Promise<unknown>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Validates data using a pre-compiled VineJS validator.
|
|
7
|
+
* @param validator - Compiled VineJS validator
|
|
8
|
+
* @param data - Data to validate
|
|
9
|
+
* @param context - Optional context for error messages
|
|
10
|
+
* @returns Validated and typed data
|
|
11
|
+
* @throws ValidationError if validation fails
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateData<T>(validator: AnyValidator, data: unknown, context?: string): Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Validates data and returns result without throwing.
|
|
16
|
+
* Useful for optional validation or when you want to handle errors manually.
|
|
17
|
+
* @param validator - Compiled VineJS validator
|
|
18
|
+
* @param data - Data to validate
|
|
19
|
+
* @returns Object with success status, data (if valid), or errors (if invalid)
|
|
20
|
+
*/
|
|
21
|
+
export declare function safeValidate<T>(validator: AnyValidator, data: unknown): Promise<{
|
|
22
|
+
success: true;
|
|
23
|
+
data: T;
|
|
24
|
+
} | {
|
|
25
|
+
success: false;
|
|
26
|
+
errors: Array<{
|
|
27
|
+
field: string;
|
|
28
|
+
message: string;
|
|
29
|
+
}>;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Validates query parameters, coercing string values to appropriate types.
|
|
33
|
+
* Query params from Express are always strings, so we need to convert them.
|
|
34
|
+
* @param validator - Compiled VineJS validator
|
|
35
|
+
* @param query - Query object from Express request
|
|
36
|
+
* @param context - Optional context for error messages
|
|
37
|
+
* @returns Validated and typed query parameters
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateQuery<T>(validator: AnyValidator, query: Record<string, unknown>, context?: string): Promise<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Validates path parameters (e.g., :id in routes).
|
|
42
|
+
* @param validator - Compiled VineJS validator
|
|
43
|
+
* @param params - Params object from Express request
|
|
44
|
+
* @param context - Optional context for error messages
|
|
45
|
+
* @returns Validated and typed parameters
|
|
46
|
+
*/
|
|
47
|
+
export declare function validateParams<T>(validator: AnyValidator, params: Record<string, string>, context?: string): Promise<T>;
|
|
48
|
+
export { vine };
|
|
49
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validation/validate.ts"],"names":[],"mappings":"AAAA,OAAO,IAAgB,MAAM,cAAc,CAAA;AAG3C,KAAK,YAAY,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,CAAA;AAErE;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB1G;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAChC,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,OAAO,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAU7G;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACjC,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC,CA6BZ;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAClC,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE,M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