rawsql-ts 0.20.0 → 0.21.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 (83) hide show
  1. package/README.md +12 -13
  2. package/dist/esm/index.d.ts +1 -11
  3. package/dist/esm/index.js +1 -11
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/index.min.js +3 -39
  6. package/dist/esm/index.min.js.map +3 -3
  7. package/dist/esm/transformers/DynamicQueryBuilder.d.ts +4 -27
  8. package/dist/esm/transformers/DynamicQueryBuilder.js +10 -27
  9. package/dist/esm/transformers/DynamicQueryBuilder.js.map +1 -1
  10. package/dist/esm/transformers/SSSQLFilterBuilder.js +2 -1
  11. package/dist/esm/transformers/SSSQLFilterBuilder.js.map +1 -1
  12. package/dist/esm/utils/SchemaManager.d.ts +3 -19
  13. package/dist/esm/utils/SchemaManager.js +2 -62
  14. package/dist/esm/utils/SchemaManager.js.map +1 -1
  15. package/dist/index.js +2 -18
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.min.js +3 -39
  18. package/dist/index.min.js.map +3 -3
  19. package/dist/src/index.d.ts +1 -11
  20. package/dist/src/transformers/DynamicQueryBuilder.d.ts +4 -27
  21. package/dist/src/utils/SchemaManager.d.ts +3 -19
  22. package/dist/transformers/DynamicQueryBuilder.js +10 -27
  23. package/dist/transformers/DynamicQueryBuilder.js.map +1 -1
  24. package/dist/transformers/SSSQLFilterBuilder.js +2 -1
  25. package/dist/transformers/SSSQLFilterBuilder.js.map +1 -1
  26. package/dist/tsconfig.browser.tsbuildinfo +1 -1
  27. package/dist/utils/SchemaManager.js +2 -63
  28. package/dist/utils/SchemaManager.js.map +1 -1
  29. package/package.json +10 -2
  30. package/dist/esm/transformers/EnhancedJsonMapping.d.ts +0 -194
  31. package/dist/esm/transformers/EnhancedJsonMapping.js +0 -217
  32. package/dist/esm/transformers/EnhancedJsonMapping.js.map +0 -1
  33. package/dist/esm/transformers/JsonMappingConverter.d.ts +0 -200
  34. package/dist/esm/transformers/JsonMappingConverter.js +0 -388
  35. package/dist/esm/transformers/JsonMappingConverter.js.map +0 -1
  36. package/dist/esm/transformers/JsonMappingUnifier.d.ts +0 -100
  37. package/dist/esm/transformers/JsonMappingUnifier.js +0 -207
  38. package/dist/esm/transformers/JsonMappingUnifier.js.map +0 -1
  39. package/dist/esm/transformers/ModelDrivenJsonMapping.d.ts +0 -62
  40. package/dist/esm/transformers/ModelDrivenJsonMapping.js +0 -115
  41. package/dist/esm/transformers/ModelDrivenJsonMapping.js.map +0 -1
  42. package/dist/esm/transformers/PostgresArrayEntityCteBuilder.d.ts +0 -138
  43. package/dist/esm/transformers/PostgresArrayEntityCteBuilder.js +0 -454
  44. package/dist/esm/transformers/PostgresArrayEntityCteBuilder.js.map +0 -1
  45. package/dist/esm/transformers/PostgresJsonQueryBuilder.d.ts +0 -88
  46. package/dist/esm/transformers/PostgresJsonQueryBuilder.js +0 -241
  47. package/dist/esm/transformers/PostgresJsonQueryBuilder.js.map +0 -1
  48. package/dist/esm/transformers/PostgresObjectEntityCteBuilder.d.ts +0 -165
  49. package/dist/esm/transformers/PostgresObjectEntityCteBuilder.js +0 -343
  50. package/dist/esm/transformers/PostgresObjectEntityCteBuilder.js.map +0 -1
  51. package/dist/esm/transformers/TypeTransformationPostProcessor.d.ts +0 -108
  52. package/dist/esm/transformers/TypeTransformationPostProcessor.js +0 -354
  53. package/dist/esm/transformers/TypeTransformationPostProcessor.js.map +0 -1
  54. package/dist/esm/utils/JsonSchemaValidator.d.ts +0 -81
  55. package/dist/esm/utils/JsonSchemaValidator.js +0 -211
  56. package/dist/esm/utils/JsonSchemaValidator.js.map +0 -1
  57. package/dist/src/transformers/EnhancedJsonMapping.d.ts +0 -194
  58. package/dist/src/transformers/JsonMappingConverter.d.ts +0 -200
  59. package/dist/src/transformers/JsonMappingUnifier.d.ts +0 -100
  60. package/dist/src/transformers/ModelDrivenJsonMapping.d.ts +0 -62
  61. package/dist/src/transformers/PostgresArrayEntityCteBuilder.d.ts +0 -138
  62. package/dist/src/transformers/PostgresJsonQueryBuilder.d.ts +0 -88
  63. package/dist/src/transformers/PostgresObjectEntityCteBuilder.d.ts +0 -165
  64. package/dist/src/transformers/TypeTransformationPostProcessor.d.ts +0 -108
  65. package/dist/src/utils/JsonSchemaValidator.d.ts +0 -81
  66. package/dist/transformers/EnhancedJsonMapping.js +0 -223
  67. package/dist/transformers/EnhancedJsonMapping.js.map +0 -1
  68. package/dist/transformers/JsonMappingConverter.js +0 -392
  69. package/dist/transformers/JsonMappingConverter.js.map +0 -1
  70. package/dist/transformers/JsonMappingUnifier.js +0 -216
  71. package/dist/transformers/JsonMappingUnifier.js.map +0 -1
  72. package/dist/transformers/ModelDrivenJsonMapping.js +0 -122
  73. package/dist/transformers/ModelDrivenJsonMapping.js.map +0 -1
  74. package/dist/transformers/PostgresArrayEntityCteBuilder.js +0 -458
  75. package/dist/transformers/PostgresArrayEntityCteBuilder.js.map +0 -1
  76. package/dist/transformers/PostgresJsonQueryBuilder.js +0 -245
  77. package/dist/transformers/PostgresJsonQueryBuilder.js.map +0 -1
  78. package/dist/transformers/PostgresObjectEntityCteBuilder.js +0 -347
  79. package/dist/transformers/PostgresObjectEntityCteBuilder.js.map +0 -1
  80. package/dist/transformers/TypeTransformationPostProcessor.js +0 -363
  81. package/dist/transformers/TypeTransformationPostProcessor.js.map +0 -1
  82. package/dist/utils/JsonSchemaValidator.js +0 -215
  83. package/dist/utils/JsonSchemaValidator.js.map +0 -1
@@ -1,388 +0,0 @@
1
- /**
2
- * Unified JSON mapping converter that handles all supported formats
3
- * and provides a single interface for mapping transformations.
4
- */
5
- import { convertModelDrivenMapping } from './ModelDrivenJsonMapping';
6
- import { toLegacyMapping, extractTypeProtection } from './EnhancedJsonMapping';
7
- /**
8
- * Type guard to check if input is valid JSON mapping input
9
- */
10
- function isValidMappingInput(input) {
11
- return input !== null &&
12
- input !== undefined &&
13
- typeof input === 'object';
14
- }
15
- /**
16
- * Enhanced format conversion strategy.
17
- */
18
- class EnhancedFormatStrategy {
19
- detect(input) {
20
- if (!isValidMappingInput(input)) {
21
- return false;
22
- }
23
- const candidate = input;
24
- if (!candidate ||
25
- typeof candidate.rootName !== 'string' ||
26
- !candidate.rootEntity ||
27
- !Array.isArray(candidate.nestedEntities)) {
28
- return false;
29
- }
30
- // Check if it has enhanced features
31
- if (candidate.typeInfo || candidate.typeProtection || candidate.metadata) {
32
- return true;
33
- }
34
- // Check if any column uses enhanced format (object with 'column' property)
35
- const hasEnhancedColumns = (columns) => {
36
- if (!columns || typeof columns !== 'object')
37
- return false;
38
- return Object.values(columns).some(col => typeof col === 'object' && col !== null && 'column' in col);
39
- };
40
- if (hasEnhancedColumns(candidate.rootEntity.columns)) {
41
- return true;
42
- }
43
- return candidate.nestedEntities.some((entity) => entity && typeof entity === 'object' &&
44
- hasEnhancedColumns(entity.columns));
45
- }
46
- convert(input) {
47
- var _a, _b;
48
- return {
49
- format: 'enhanced',
50
- mapping: toLegacyMapping(input),
51
- typeProtection: extractTypeProtection(input),
52
- originalInput: input,
53
- metadata: {
54
- typeInfo: input.typeInfo,
55
- version: (_a = input.metadata) === null || _a === void 0 ? void 0 : _a.version,
56
- description: (_b = input.metadata) === null || _b === void 0 ? void 0 : _b.description
57
- }
58
- };
59
- }
60
- }
61
- /**
62
- * Model-driven format conversion strategy.
63
- */
64
- class ModelDrivenFormatStrategy {
65
- detect(input) {
66
- if (!isValidMappingInput(input)) {
67
- return false;
68
- }
69
- const candidate = input;
70
- return candidate &&
71
- candidate.typeInfo &&
72
- candidate.structure &&
73
- typeof candidate.typeInfo.interface === 'string';
74
- }
75
- convert(input) {
76
- // Use the existing convertModelDrivenMapping function to avoid code duplication
77
- const converted = convertModelDrivenMapping(input);
78
- return {
79
- format: 'model-driven',
80
- mapping: converted.jsonMapping,
81
- typeProtection: converted.typeProtection,
82
- originalInput: input,
83
- metadata: {
84
- typeInfo: input.typeInfo
85
- }
86
- };
87
- }
88
- }
89
- /**
90
- * Legacy format conversion strategy.
91
- */
92
- class LegacyFormatStrategy {
93
- detect(input) {
94
- if (!isValidMappingInput(input)) {
95
- return false;
96
- }
97
- const candidate = input;
98
- if (!candidate ||
99
- typeof candidate.rootName !== 'string' ||
100
- !candidate.rootEntity ||
101
- typeof candidate.rootEntity.columns !== 'object' ||
102
- candidate.typeInfo || candidate.typeProtection || candidate.metadata) {
103
- return false;
104
- }
105
- // Check if any column uses enhanced format (object with 'column' property)
106
- const hasEnhancedColumns = (columns) => {
107
- if (!columns || typeof columns !== 'object')
108
- return false;
109
- return Object.values(columns).some(col => typeof col === 'object' && col !== null && 'column' in col);
110
- };
111
- // If it has enhanced columns, it's not legacy format
112
- if (hasEnhancedColumns(candidate.rootEntity.columns)) {
113
- return false;
114
- }
115
- if (candidate.nestedEntities && Array.isArray(candidate.nestedEntities)) {
116
- const hasEnhancedNested = candidate.nestedEntities.some((entity) => entity && typeof entity === 'object' && hasEnhancedColumns(entity.columns));
117
- if (hasEnhancedNested) {
118
- return false;
119
- }
120
- }
121
- return true;
122
- }
123
- convert(input) {
124
- return {
125
- format: 'legacy',
126
- mapping: input,
127
- typeProtection: { protectedStringFields: [] },
128
- originalInput: input
129
- };
130
- }
131
- }
132
- /**
133
- * Unified JSON mapping converter that handles all supported formats using the Strategy pattern.
134
- *
135
- * This converter automatically detects the input format and applies the appropriate conversion
136
- * strategy to transform any supported JSON mapping format into a standardized result.
137
- *
138
- * **Supported Formats:**
139
- * - **Enhanced**: Rich format with metadata, type protection, and advanced column configurations
140
- * - **Model-Driven**: TypeScript interface-based mapping with structured field definitions
141
- * - **Legacy**: Simple format compatible with PostgresJsonQueryBuilder
142
- *
143
- * **Usage:**
144
- * ```typescript
145
- * const converter = new JsonMappingConverter();
146
- * const result = converter.convert(someMapping);
147
- * const legacyMapping = converter.toLegacyMapping(someMapping);
148
- * ```
149
- *
150
- * @public
151
- */
152
- export class JsonMappingConverter {
153
- /**
154
- * Creates a new JsonMappingConverter with all supported strategies.
155
- *
156
- * Strategies are checked in order of specificity:
157
- * 1. Enhanced format (most feature-rich)
158
- * 2. Model-driven format (TypeScript-based)
159
- * 3. Legacy format (fallback)
160
- */
161
- constructor() {
162
- this.strategies = [
163
- new EnhancedFormatStrategy(),
164
- new ModelDrivenFormatStrategy(),
165
- new LegacyFormatStrategy()
166
- ];
167
- }
168
- /**
169
- * Detects the format of the input mapping without performing conversion.
170
- *
171
- * This method uses the same strategy pattern as conversion but only returns
172
- * the detected format type for inspection purposes.
173
- *
174
- * @param input - The JSON mapping to analyze
175
- * @returns The detected mapping format type
176
- *
177
- * @throws {Error} When input format is not supported by any strategy
178
- *
179
- * @example
180
- * ```typescript
181
- * const format = converter.detectFormat(myMapping);
182
- * console.log(`Detected format: ${format}`); // "enhanced", "model-driven", or "legacy"
183
- * ```
184
- */
185
- detectFormat(input) {
186
- for (const strategy of this.strategies) {
187
- if (strategy.detect(input)) {
188
- const result = strategy.convert(input);
189
- return result.format;
190
- }
191
- }
192
- throw new Error('Unsupported JSON mapping format');
193
- }
194
- /**
195
- * Converts any supported JSON mapping format to a comprehensive result with metadata.
196
- *
197
- * This is the primary conversion method that performs format detection and transformation
198
- * in a single operation. The result includes the legacy mapping, type protection configuration,
199
- * and metadata about the conversion process.
200
- *
201
- * @param input - The JSON mapping in any supported format (Enhanced, Model-Driven, or Legacy)
202
- * @returns Complete conversion result with mapping, metadata, and type protection
203
- *
204
- * @throws {Error} When the input format is not recognized by any strategy
205
- *
206
- * @example
207
- * ```typescript
208
- * const result = converter.convert(enhancedMapping);
209
- * console.log(`Format: ${result.format}`);
210
- * console.log(`Type protection: ${result.typeProtection.protectedStringFields.length} fields`);
211
- *
212
- * // Use the converted mapping
213
- * const queryBuilder = new PostgresJsonQueryBuilder(result.mapping);
214
- * ```
215
- *
216
- * @see {@link toLegacyMapping} For simple mapping extraction
217
- * @see {@link getTypeProtection} For type protection only
218
- */
219
- convert(input) {
220
- for (const strategy of this.strategies) {
221
- if (strategy.detect(input)) {
222
- return strategy.convert(input);
223
- }
224
- }
225
- throw new Error('Unsupported JSON mapping format: Unable to detect a compatible strategy for the provided input');
226
- }
227
- /**
228
- * Extracts only the legacy JsonMapping for direct use with PostgresJsonQueryBuilder.
229
- *
230
- * This convenience method performs the full conversion but returns only the mapping portion,
231
- * discarding metadata and type protection information. Use this when you only need
232
- * the mapping for query building and don't require additional metadata.
233
- *
234
- * @param input - The JSON mapping in any supported format
235
- * @returns Legacy-format JsonMapping ready for PostgresJsonQueryBuilder
236
- *
237
- * @throws {Error} When the input format is not supported
238
- *
239
- * @example
240
- * ```typescript
241
- * const legacyMapping = converter.toLegacyMapping(modelDrivenMapping);
242
- * const queryBuilder = new PostgresJsonQueryBuilder(legacyMapping);
243
- * const query = queryBuilder.build(selectQuery);
244
- * ```
245
- *
246
- * @see {@link convert} For full conversion with metadata
247
- */
248
- toLegacyMapping(input) {
249
- return this.convert(input).mapping;
250
- }
251
- /**
252
- * Extracts type protection configuration for runtime type checking.
253
- *
254
- * Type protection helps identify fields that should be treated as strings
255
- * to prevent injection attacks or type coercion issues. This is particularly
256
- * useful when working with user input or external data sources.
257
- *
258
- * @param input - The JSON mapping in any supported format
259
- * @returns Type protection configuration with protected field definitions
260
- *
261
- * @throws {Error} When the input format is not supported
262
- *
263
- * @example
264
- * ```typescript
265
- * const typeProtection = converter.getTypeProtection(enhancedMapping);
266
- *
267
- * // Apply type protection during data processing
268
- * for (const field of typeProtection.protectedStringFields) {
269
- * if (typeof data[field] !== 'string') {
270
- * data[field] = String(data[field]);
271
- * }
272
- * }
273
- * ```
274
- */
275
- getTypeProtection(input) {
276
- return this.convert(input).typeProtection;
277
- }
278
- /**
279
- * Validates that the input mapping is well-formed and can be successfully converted.
280
- *
281
- * This method performs comprehensive validation without attempting conversion,
282
- * returning an array of error messages for any issues found. An empty array
283
- * indicates the mapping is valid and ready for conversion.
284
- *
285
- * **Validation Checks:**
286
- * - Basic structure validation (object type, required fields)
287
- * - Format-specific validation (Enhanced, Model-Driven, Legacy)
288
- * - Column configuration validation
289
- * - Type protection configuration validation
290
- *
291
- * @param input - The JSON mapping to validate
292
- * @returns Array of validation error messages (empty if valid)
293
- *
294
- * @example
295
- * ```typescript
296
- * const errors = converter.validate(suspiciousMapping);
297
- * if (errors.length > 0) {
298
- * console.error('Validation failed:', errors);
299
- * throw new Error(`Invalid mapping: ${errors.join(', ')}`);
300
- * }
301
- *
302
- * // Safe to convert
303
- * const result = converter.convert(suspiciousMapping);
304
- * ```
305
- *
306
- * @see {@link convert} Performs conversion after implicit validation
307
- */
308
- validate(input) {
309
- const errors = [];
310
- // Pre-validation checks
311
- if (!input || typeof input !== 'object') {
312
- errors.push('Input must be an object');
313
- return errors;
314
- }
315
- // Check for rootName before attempting conversion
316
- if (!('rootName' in input) || !input.rootName) {
317
- errors.push('rootName is required');
318
- }
319
- try {
320
- const result = this.convert(input);
321
- // Basic validation
322
- if (!result.mapping.rootName) {
323
- errors.push('rootName is required');
324
- }
325
- if (!result.mapping.rootEntity) {
326
- errors.push('rootEntity is required');
327
- }
328
- else {
329
- if (!result.mapping.rootEntity.id) {
330
- errors.push('rootEntity.id is required');
331
- }
332
- if (!result.mapping.rootEntity.columns) {
333
- errors.push('rootEntity.columns is required');
334
- }
335
- }
336
- // Validate nested entities
337
- if (result.mapping.nestedEntities) {
338
- for (const entity of result.mapping.nestedEntities) {
339
- if (!entity.id) {
340
- errors.push(`Nested entity missing id: ${entity.propertyName}`);
341
- }
342
- if (!entity.parentId) {
343
- errors.push(`Nested entity missing parentId: ${entity.id}`);
344
- }
345
- if (!entity.propertyName) {
346
- errors.push(`Nested entity missing propertyName: ${entity.id}`);
347
- }
348
- }
349
- }
350
- }
351
- catch (error) {
352
- // Only add conversion error if we haven't already found specific errors
353
- if (errors.length === 0) {
354
- errors.push(`Conversion failed: ${error instanceof Error ? error.message : String(error)}`);
355
- }
356
- }
357
- return errors;
358
- }
359
- /**
360
- * Creates a new enhanced mapping from legacy mapping.
361
- */
362
- upgradeToEnhanced(legacy, typeInfo) {
363
- return {
364
- rootName: legacy.rootName,
365
- rootEntity: {
366
- id: legacy.rootEntity.id,
367
- name: legacy.rootEntity.name,
368
- columns: legacy.rootEntity.columns
369
- },
370
- nestedEntities: legacy.nestedEntities.map(entity => ({
371
- id: entity.id,
372
- name: entity.name,
373
- parentId: entity.parentId,
374
- propertyName: entity.propertyName,
375
- relationshipType: entity.relationshipType || 'object',
376
- columns: entity.columns
377
- })),
378
- resultFormat: legacy.resultFormat,
379
- emptyResult: legacy.emptyResult,
380
- typeInfo,
381
- metadata: {
382
- version: '1.0',
383
- description: 'Upgraded from legacy format'
384
- }
385
- };
386
- }
387
- }
388
- //# sourceMappingURL=JsonMappingConverter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JsonMappingConverter.js","sourceRoot":"","sources":["../../../src/transformers/JsonMappingConverter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAA0B,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAgE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AA+C7I;;GAEG;AACH,SAAS,mBAAmB,CAAC,KAAc;IACvC,OAAO,KAAK,KAAK,IAAI;QACd,KAAK,KAAK,SAAS;QACnB,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,sBAAsB;IACxB,MAAM,CAAC,KAAc;QACjB,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,MAAM,SAAS,GAAG,KAAY,CAAC;QAC/B,IAAI,CAAC,SAAS;YACV,OAAO,SAAS,CAAC,QAAQ,KAAK,QAAQ;YACtC,CAAC,SAAS,CAAC,UAAU;YACrB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,oCAAoC;QACp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- * @deprecated Use JsonMappingConverter instead. This module is kept for backward compatibility.
5
- * This module provides backward compatibility while encouraging migration to the model-driven format.
6
- * It automatically detects the input format and normalizes to a consistent internal representation.
7
- */
8
- import { JsonMapping } from './PostgresJsonQueryBuilder';
9
- import { ModelDrivenJsonMapping } from './ModelDrivenJsonMapping';
10
- /**
11
- * Unified mapping format that can handle both legacy and model-driven inputs.
12
- */
13
- export interface UnifiedMappingInput {
14
- typeInfo?: {
15
- interface: string;
16
- importPath: string;
17
- };
18
- structure?: any;
19
- protectedStringFields?: string[];
20
- rootName?: string;
21
- rootEntity?: any;
22
- nestedEntities?: any[];
23
- columns?: any;
24
- relationships?: any;
25
- }
26
- /**
27
- * Result of mapping format detection and conversion.
28
- */
29
- export interface MappingProcessResult {
30
- format: 'model-driven' | 'unified' | 'legacy';
31
- jsonMapping: JsonMapping;
32
- originalInput: UnifiedMappingInput;
33
- metadata?: {
34
- typeInfo?: {
35
- interface: string;
36
- importPath: string;
37
- };
38
- protectedStringFields?: string[];
39
- typeProtection?: any;
40
- };
41
- }
42
- /**
43
- * Detects the format of a JSON mapping configuration.
44
- *
45
- * @param input - The mapping configuration to analyze
46
- * @returns The detected format type
47
- */
48
- export declare function detectMappingFormat(input: UnifiedMappingInput): 'model-driven' | 'unified' | 'legacy';
49
- /**
50
- * Main processor that unifies all JSON mapping formats into a consistent JsonMapping.
51
- *
52
- * @deprecated Use JsonMappingConverter.convert() instead.
53
- *
54
- * Features:
55
- * - Automatic format detection
56
- * - Backward compatibility with all existing formats
57
- * - Metadata preservation for advanced features
58
- * - Zero external dependencies
59
- *
60
- * @param input - Any supported JSON mapping format
61
- * @returns Unified processing result with JsonMapping and metadata
62
- */
63
- export declare function processJsonMapping(input: UnifiedMappingInput): MappingProcessResult;
64
- /**
65
- * Convenience function for direct JsonMapping extraction.
66
- *
67
- * @deprecated Use JsonMappingConverter.toLegacyMapping() instead.
68
- *
69
- * @param input - Any supported JSON mapping format
70
- * @returns JsonMapping ready for use with PostgresJsonQueryBuilder
71
- */
72
- export declare function unifyJsonMapping(input: UnifiedMappingInput): JsonMapping;
73
- /**
74
- * Type guard to check if input uses model-driven format.
75
- *
76
- * @param input - Mapping input to check
77
- * @returns True if input is model-driven format
78
- */
79
- export declare function isModelDrivenFormat(input: UnifiedMappingInput): input is ModelDrivenJsonMapping;
80
- /**
81
- * Type guard to check if input uses unified format.
82
- *
83
- * @param input - Mapping input to check
84
- * @returns True if input is unified format
85
- */
86
- export declare function isUnifiedFormat(input: UnifiedMappingInput): boolean;
87
- /**
88
- * Type guard to check if input uses legacy format.
89
- *
90
- * @param input - Mapping input to check
91
- * @returns True if input is legacy format
92
- */
93
- export declare function isLegacyFormat(input: UnifiedMappingInput): boolean;
94
- /**
95
- * Migration helper that suggests upgrading to model-driven format.
96
- *
97
- * @param input - Current mapping configuration
98
- * @returns Suggestions for migration (if applicable)
99
- */
100
- export declare function suggestModelDrivenMigration(input: UnifiedMappingInput): string[];