@wildo-ai/zod-decorators 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/__mocks__/mime.d.ts +12 -0
- package/dist/esm/__mocks__/mime.d.ts.map +1 -0
- package/dist/esm/__mocks__/mime.js +75 -0
- package/dist/esm/__mocks__/mime.js.map +1 -0
- package/dist/esm/commons.d.ts +26 -0
- package/dist/esm/commons.d.ts.map +1 -0
- package/dist/esm/commons.js +41 -0
- package/dist/esm/commons.js.map +1 -0
- package/dist/esm/currencies.shared.schemas.d.ts +208 -0
- package/dist/esm/currencies.shared.schemas.d.ts.map +1 -0
- package/dist/esm/currencies.shared.schemas.js +228 -0
- package/dist/esm/currencies.shared.schemas.js.map +1 -0
- package/dist/esm/files/agent-file-formats.d.ts +99 -0
- package/dist/esm/files/agent-file-formats.d.ts.map +1 -0
- package/dist/esm/files/agent-file-formats.js +163 -0
- package/dist/esm/files/agent-file-formats.js.map +1 -0
- package/dist/esm/files/extension-nature-map.d.ts +12 -0
- package/dist/esm/files/extension-nature-map.d.ts.map +1 -0
- package/dist/esm/files/extension-nature-map.js +63 -0
- package/dist/esm/files/extension-nature-map.js.map +1 -0
- package/dist/esm/files/file-extensions.enum.d.ts +58 -0
- package/dist/esm/files/file-extensions.enum.d.ts.map +1 -0
- package/dist/esm/files/file-extensions.enum.js +65 -0
- package/dist/esm/files/file-extensions.enum.js.map +1 -0
- package/dist/esm/files/mime-registry.d.ts +72 -0
- package/dist/esm/files/mime-registry.d.ts.map +1 -0
- package/dist/esm/files/mime-registry.js +174 -0
- package/dist/esm/files/mime-registry.js.map +1 -0
- package/dist/esm/files/unified-registry.d.ts +112 -0
- package/dist/esm/files/unified-registry.d.ts.map +1 -0
- package/dist/esm/files/unified-registry.js +190 -0
- package/dist/esm/files/unified-registry.js.map +1 -0
- package/dist/esm/index.d.ts +29 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +36 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/testing/decorated-test-schemas.d.ts +27 -0
- package/dist/esm/testing/decorated-test-schemas.d.ts.map +1 -0
- package/dist/esm/testing/decorated-test-schemas.js +26 -0
- package/dist/esm/testing/decorated-test-schemas.js.map +1 -0
- package/dist/esm/testing.d.ts +6 -0
- package/dist/esm/testing.d.ts.map +1 -0
- package/dist/esm/testing.js +6 -0
- package/dist/esm/testing.js.map +1 -0
- package/dist/esm/zod-bigdecimal.d.ts +193 -0
- package/dist/esm/zod-bigdecimal.d.ts.map +1 -0
- package/dist/esm/zod-bigdecimal.js +274 -0
- package/dist/esm/zod-bigdecimal.js.map +1 -0
- package/dist/esm/zod-code.d.ts +95 -0
- package/dist/esm/zod-code.d.ts.map +1 -0
- package/dist/esm/zod-code.js +160 -0
- package/dist/esm/zod-code.js.map +1 -0
- package/dist/esm/zod-color.d.ts +8 -0
- package/dist/esm/zod-color.d.ts.map +1 -0
- package/dist/esm/zod-color.js +88 -0
- package/dist/esm/zod-color.js.map +1 -0
- package/dist/esm/zod-decorators.types.d.ts +2207 -0
- package/dist/esm/zod-decorators.types.d.ts.map +1 -0
- package/dist/esm/zod-decorators.types.js +771 -0
- package/dist/esm/zod-decorators.types.js.map +1 -0
- package/dist/esm/zod-duration.d.ts +128 -0
- package/dist/esm/zod-duration.d.ts.map +1 -0
- package/dist/esm/zod-duration.js +174 -0
- package/dist/esm/zod-duration.js.map +1 -0
- package/dist/esm/zod-file.d.ts +219 -0
- package/dist/esm/zod-file.d.ts.map +1 -0
- package/dist/esm/zod-file.js +469 -0
- package/dist/esm/zod-file.js.map +1 -0
- package/dist/esm/zod-money.d.ts +223 -0
- package/dist/esm/zod-money.d.ts.map +1 -0
- package/dist/esm/zod-money.js +293 -0
- package/dist/esm/zod-money.js.map +1 -0
- package/dist/esm/zod-phone.d.ts +75 -0
- package/dist/esm/zod-phone.d.ts.map +1 -0
- package/dist/esm/zod-phone.js +116 -0
- package/dist/esm/zod-phone.js.map +1 -0
- package/dist/esm/zod-range.d.ts +87 -0
- package/dist/esm/zod-range.d.ts.map +1 -0
- package/dist/esm/zod-range.js +138 -0
- package/dist/esm/zod-range.js.map +1 -0
- package/dist/esm/zod-utils.shared.d.ts +783 -0
- package/dist/esm/zod-utils.shared.d.ts.map +1 -0
- package/dist/esm/zod-utils.shared.js +2647 -0
- package/dist/esm/zod-utils.shared.js.map +1 -0
- package/dist/esm/zod-versioned.d.ts +150 -0
- package/dist/esm/zod-versioned.d.ts.map +1 -0
- package/dist/esm/zod-versioned.js +172 -0
- package/dist/esm/zod-versioned.js.map +1 -0
- package/dist/esm/zod.module-override.d.ts +413 -0
- package/dist/esm/zod.module-override.d.ts.map +1 -0
- package/dist/esm/zod.module-override.js +1093 -0
- package/dist/esm/zod.module-override.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File MIME Type Registry
|
|
3
|
+
*
|
|
4
|
+
* Core registry for general file types (images, videos, documents, etc.).
|
|
5
|
+
* Uses the `mime` library for authoritative extension ↔ MIME type mapping.
|
|
6
|
+
*/
|
|
7
|
+
import mime from 'mime';
|
|
8
|
+
import { ExtensionToNatureMap } from './extension-nature-map.js';
|
|
9
|
+
/**
|
|
10
|
+
* Extension normalization map.
|
|
11
|
+
* Maps common extension variations to canonical format names.
|
|
12
|
+
* Examples: 'jpg' → 'jpeg', 'jfif' → 'jpeg', 'm4a' → 'aac'
|
|
13
|
+
*/
|
|
14
|
+
const EXTENSION_NORMALIZATION_MAP = {
|
|
15
|
+
// Image formats
|
|
16
|
+
'jpg': 'jpeg',
|
|
17
|
+
'jpeg': 'jpeg',
|
|
18
|
+
'jfif': 'jpeg',
|
|
19
|
+
'png': 'png',
|
|
20
|
+
'gif': 'gif',
|
|
21
|
+
'webp': 'webp',
|
|
22
|
+
'svg': 'svg',
|
|
23
|
+
// Video formats
|
|
24
|
+
'mp4': 'mp4',
|
|
25
|
+
'webm': 'webm',
|
|
26
|
+
'mov': 'mov',
|
|
27
|
+
// Audio formats
|
|
28
|
+
'mp3': 'mp3',
|
|
29
|
+
'wav': 'wav',
|
|
30
|
+
'ogg': 'ogg',
|
|
31
|
+
'aac': 'aac',
|
|
32
|
+
'm4a': 'aac',
|
|
33
|
+
'm4b': 'aac',
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Custom MIME type mappings for formats not well-supported by mime library.
|
|
37
|
+
*/
|
|
38
|
+
const CUSTOM_MIME_MAPPINGS = {
|
|
39
|
+
// Add custom mappings here if needed
|
|
40
|
+
// Example: 'custom': 'application/x-custom',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Core registry for general file types.
|
|
44
|
+
*/
|
|
45
|
+
export class FileMimeTypeRegistry {
|
|
46
|
+
/**
|
|
47
|
+
* Get MIME type from extension (using mime library + custom mappings).
|
|
48
|
+
*
|
|
49
|
+
* @param extension - File extension (without dot, case-insensitive)
|
|
50
|
+
* @returns MIME type string or undefined if not found
|
|
51
|
+
*/
|
|
52
|
+
static getMimeType(extension) {
|
|
53
|
+
if (!extension)
|
|
54
|
+
return undefined;
|
|
55
|
+
const normalizedExt = extension.toLowerCase().trim();
|
|
56
|
+
// Check custom mappings first
|
|
57
|
+
if (CUSTOM_MIME_MAPPINGS[normalizedExt]) {
|
|
58
|
+
return CUSTOM_MIME_MAPPINGS[normalizedExt];
|
|
59
|
+
}
|
|
60
|
+
// Use mime library
|
|
61
|
+
const mimeType = mime.getType(normalizedExt);
|
|
62
|
+
return mimeType || undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get all extensions for a MIME type.
|
|
66
|
+
*
|
|
67
|
+
* @param mimeType - MIME type string
|
|
68
|
+
* @returns Array of extensions (without dots)
|
|
69
|
+
*/
|
|
70
|
+
static getExtensions(mimeType) {
|
|
71
|
+
if (!mimeType)
|
|
72
|
+
return [];
|
|
73
|
+
const extensions = mime.getExtension(mimeType);
|
|
74
|
+
if (!extensions)
|
|
75
|
+
return [];
|
|
76
|
+
// mime.getExtension returns a single extension, but we want all possible extensions
|
|
77
|
+
// For now, return the primary extension. Full reverse mapping would require mime-db
|
|
78
|
+
return [extensions];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Normalize extension to canonical format name.
|
|
82
|
+
* Maps common extension variations to standard format names.
|
|
83
|
+
* Examples: 'jpg' → 'jpeg', 'jfif' → 'jpeg', 'm4a' → 'aac'
|
|
84
|
+
*
|
|
85
|
+
* @param extension - File extension (without dot)
|
|
86
|
+
* @returns Normalized format name
|
|
87
|
+
*/
|
|
88
|
+
static normalizeExtension(extension) {
|
|
89
|
+
if (!extension)
|
|
90
|
+
return extension;
|
|
91
|
+
const normalizedExt = extension.toLowerCase().trim();
|
|
92
|
+
return EXTENSION_NORMALIZATION_MAP[normalizedExt] || normalizedExt;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get FileNature from extension.
|
|
96
|
+
*
|
|
97
|
+
* @param extension - File extension (without dot)
|
|
98
|
+
* @returns FileNature or undefined if not found
|
|
99
|
+
*/
|
|
100
|
+
static getNatureFromExtension(extension) {
|
|
101
|
+
if (!extension)
|
|
102
|
+
return undefined;
|
|
103
|
+
const normalizedExt = extension.toLowerCase().trim();
|
|
104
|
+
return ExtensionToNatureMap[normalizedExt];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get FileNature from MIME type.
|
|
108
|
+
*
|
|
109
|
+
* @param mimeType - MIME type string
|
|
110
|
+
* @returns FileNature or undefined if not found
|
|
111
|
+
*/
|
|
112
|
+
static getNatureFromMimeType(mimeType) {
|
|
113
|
+
if (!mimeType)
|
|
114
|
+
return undefined;
|
|
115
|
+
// Get primary extension from MIME type
|
|
116
|
+
const extension = mime.getExtension(mimeType);
|
|
117
|
+
if (!extension)
|
|
118
|
+
return undefined;
|
|
119
|
+
return this.getNatureFromExtension(extension);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validate that extension matches MIME type.
|
|
123
|
+
*
|
|
124
|
+
* @param extension - File extension (without dot)
|
|
125
|
+
* @param mimeType - MIME type string
|
|
126
|
+
* @returns true if extension matches MIME type, false otherwise
|
|
127
|
+
*/
|
|
128
|
+
static validateExtensionMimeMatch(extension, mimeType) {
|
|
129
|
+
if (!extension || !mimeType)
|
|
130
|
+
return false;
|
|
131
|
+
const expectedMimeType = this.getMimeType(extension);
|
|
132
|
+
if (!expectedMimeType)
|
|
133
|
+
return false;
|
|
134
|
+
// Exact match
|
|
135
|
+
if (expectedMimeType === mimeType)
|
|
136
|
+
return true;
|
|
137
|
+
// Check for wildcard match (e.g., image/*)
|
|
138
|
+
const [expectedType] = expectedMimeType.split('/');
|
|
139
|
+
const [actualType] = mimeType.split('/');
|
|
140
|
+
if (expectedType === actualType && mimeType.endsWith('/*')) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get extensions for a FileNature.
|
|
147
|
+
*
|
|
148
|
+
* @param nature - FileNature enum value
|
|
149
|
+
* @returns Array of extensions (without dots)
|
|
150
|
+
*/
|
|
151
|
+
static getExtensionsForNature(nature) {
|
|
152
|
+
return Object.entries(ExtensionToNatureMap)
|
|
153
|
+
.filter(([_, n]) => n === nature)
|
|
154
|
+
.map(([ext]) => ext);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get MIME types for a FileNature.
|
|
158
|
+
*
|
|
159
|
+
* @param nature - FileNature enum value
|
|
160
|
+
* @returns Array of MIME type strings
|
|
161
|
+
*/
|
|
162
|
+
static getMimeTypesForNature(nature) {
|
|
163
|
+
const extensions = this.getExtensionsForNature(nature);
|
|
164
|
+
const mimeTypes = new Set();
|
|
165
|
+
for (const ext of extensions) {
|
|
166
|
+
const mimeType = this.getMimeType(ext);
|
|
167
|
+
if (mimeType) {
|
|
168
|
+
mimeTypes.add(mimeType);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return Array.from(mimeTypes);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=mime-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime-registry.js","sourceRoot":"","sources":["../../../src/files/mime-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,2BAA2B,GAA2B;IAC1D,gBAAgB;IAChB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;IACZ,gBAAgB;IAChB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;IACZ,gBAAgB;IAChB,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAA2B;AACnD,qCAAqC;AACrC,6CAA6C;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,SAAiB;QAClC,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAC;QAEjC,MAAM,aAAa,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAErD,8BAA8B;QAC9B,IAAI,oBAAoB,CAAC,aAAa,CAAC,EAAE,CAAC;YACxC,OAAO,oBAAoB,CAAC,aAAa,CAAC,CAAC;QA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,CAAC;YACvC,IAAI,QAAQ,EAAE,CAAC;gBACb,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified File Format Registry
|
|
3
|
+
*
|
|
4
|
+
* Unified registry that handles both general files and agent/blueprint formats.
|
|
5
|
+
* Provides a single API for all file format operations.
|
|
6
|
+
*/
|
|
7
|
+
import { FileNature } from '../zod-decorators.types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Result type for format type detection.
|
|
10
|
+
* format is a string compatible with AppsBlueprint_FileFormat enum.
|
|
11
|
+
*/
|
|
12
|
+
export type FormatTypeResult = {
|
|
13
|
+
type: 'nature';
|
|
14
|
+
nature: FileNature;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'agent';
|
|
17
|
+
format: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Unified registry for all file formats (general + agent).
|
|
21
|
+
*/
|
|
22
|
+
export declare class UnifiedFileFormatRegistry {
|
|
23
|
+
/**
|
|
24
|
+
* Extract file extension from filename (without dot, lowercase).
|
|
25
|
+
*
|
|
26
|
+
* @param filename - Full filename or path
|
|
27
|
+
* @returns File extension (without dot) or empty string if not found
|
|
28
|
+
*/
|
|
29
|
+
static getFileExtension(filename: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get MIME type from extension (works for both general files and agent formats).
|
|
32
|
+
*
|
|
33
|
+
* @param extension - File extension (without dot)
|
|
34
|
+
* @returns MIME type string or undefined if not found
|
|
35
|
+
*/
|
|
36
|
+
static getMimeType(extension: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get all extensions for a MIME type.
|
|
39
|
+
* Works for both general files and agent formats.
|
|
40
|
+
*
|
|
41
|
+
* @param mimeType - MIME type string
|
|
42
|
+
* @returns Array of extensions (without dots)
|
|
43
|
+
*/
|
|
44
|
+
static getExtensions(mimeType: string): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Get format type (FileNature or AppsBlueprint_FileFormat) from extension.
|
|
47
|
+
*
|
|
48
|
+
* @param extension - File extension (without dot)
|
|
49
|
+
* @returns FormatTypeResult indicating whether it's a nature or agent format
|
|
50
|
+
*/
|
|
51
|
+
static getFormatType(extension: string): FormatTypeResult;
|
|
52
|
+
/**
|
|
53
|
+
* Get format type from extension (alias for getFormatType for consistency).
|
|
54
|
+
*
|
|
55
|
+
* @param extension - File extension (without dot)
|
|
56
|
+
* @returns FormatTypeResult indicating whether it's a nature or agent format
|
|
57
|
+
*/
|
|
58
|
+
static getFormatTypeFromExtension(extension: string): FormatTypeResult;
|
|
59
|
+
/**
|
|
60
|
+
* Get format type from MIME type.
|
|
61
|
+
*
|
|
62
|
+
* @param mimeType - MIME type string
|
|
63
|
+
* @returns FormatTypeResult indicating whether it's a nature or agent format
|
|
64
|
+
*/
|
|
65
|
+
static getFormatTypeFromMimeType(mimeType: string): FormatTypeResult;
|
|
66
|
+
/**
|
|
67
|
+
* Check if file is an agent/blueprint format.
|
|
68
|
+
*
|
|
69
|
+
* @param extension - File extension (without dot)
|
|
70
|
+
* @returns true if extension is an agent format
|
|
71
|
+
*/
|
|
72
|
+
static isAgentFormat(extension: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Check if MIME type is an agent/blueprint format.
|
|
75
|
+
*
|
|
76
|
+
* @param mimeType - MIME type string
|
|
77
|
+
* @returns true if MIME type is an agent format
|
|
78
|
+
*/
|
|
79
|
+
static isAgentMimeType(mimeType: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Validate that extension matches MIME type.
|
|
82
|
+
* Works for both general files and agent formats.
|
|
83
|
+
*
|
|
84
|
+
* @param extension - File extension (without dot)
|
|
85
|
+
* @param mimeType - MIME type string
|
|
86
|
+
* @returns true if extension matches MIME type
|
|
87
|
+
*/
|
|
88
|
+
static validateExtensionMimeMatch(extension: string, mimeType: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Normalize extension to canonical format name.
|
|
91
|
+
* Works for both general files and agent formats.
|
|
92
|
+
*
|
|
93
|
+
* @param extension - File extension (without dot)
|
|
94
|
+
* @returns Normalized format name
|
|
95
|
+
*/
|
|
96
|
+
static normalizeExtension(extension: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Get all extensions for a FileNature.
|
|
99
|
+
*
|
|
100
|
+
* @param nature - FileNature enum value
|
|
101
|
+
* @returns Array of extensions (without dots)
|
|
102
|
+
*/
|
|
103
|
+
static getExtensionsForNature(nature: FileNature): string[];
|
|
104
|
+
/**
|
|
105
|
+
* Get all MIME types for a FileNature.
|
|
106
|
+
*
|
|
107
|
+
* @param nature - FileNature enum value
|
|
108
|
+
* @returns Array of MIME type strings
|
|
109
|
+
*/
|
|
110
|
+
static getMimeTypesForNature(nature: FileNature): string[];
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=unified-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-registry.d.ts","sourceRoot":"","sources":["../../../src/files/unified-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjC,SAAS,CAAC;AAEd;;GAEG;AACH,qBAAa,yBAAyB;IACpC;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAOjD;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAazD;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAchD;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAkBzD;;;;;OAKG;IACH,MAAM,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAItE;;;;;OAKG;IACH,MAAM,CAAC,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAkBpE;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIhD;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIjD;;;;;;;OAOG;IACH,MAAM,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAc/E;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAcpD;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE;IAI3D;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE;CAG3D"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified File Format Registry
|
|
3
|
+
*
|
|
4
|
+
* Unified registry that handles both general files and agent/blueprint formats.
|
|
5
|
+
* Provides a single API for all file format operations.
|
|
6
|
+
*/
|
|
7
|
+
import { FileMimeTypeRegistry } from './mime-registry.js';
|
|
8
|
+
import { AgentFileFormatRegistry } from './agent-file-formats.js';
|
|
9
|
+
/**
|
|
10
|
+
* Unified registry for all file formats (general + agent).
|
|
11
|
+
*/
|
|
12
|
+
export class UnifiedFileFormatRegistry {
|
|
13
|
+
/**
|
|
14
|
+
* Extract file extension from filename (without dot, lowercase).
|
|
15
|
+
*
|
|
16
|
+
* @param filename - Full filename or path
|
|
17
|
+
* @returns File extension (without dot) or empty string if not found
|
|
18
|
+
*/
|
|
19
|
+
static getFileExtension(filename) {
|
|
20
|
+
if (!filename)
|
|
21
|
+
return '';
|
|
22
|
+
const lastDot = filename.lastIndexOf('.');
|
|
23
|
+
if (lastDot === -1 || lastDot === filename.length - 1)
|
|
24
|
+
return '';
|
|
25
|
+
return filename.substring(lastDot + 1).toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get MIME type from extension (works for both general files and agent formats).
|
|
29
|
+
*
|
|
30
|
+
* @param extension - File extension (without dot)
|
|
31
|
+
* @returns MIME type string or undefined if not found
|
|
32
|
+
*/
|
|
33
|
+
static getMimeType(extension) {
|
|
34
|
+
if (!extension)
|
|
35
|
+
return undefined;
|
|
36
|
+
// Check agent formats first (more specific)
|
|
37
|
+
const agentFormat = AgentFileFormatRegistry.getFormatFromExtension(extension);
|
|
38
|
+
if (agentFormat) {
|
|
39
|
+
return AgentFileFormatRegistry.getMimeType(agentFormat);
|
|
40
|
+
}
|
|
41
|
+
// Fall back to general file registry
|
|
42
|
+
return FileMimeTypeRegistry.getMimeType(extension);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get all extensions for a MIME type.
|
|
46
|
+
* Works for both general files and agent formats.
|
|
47
|
+
*
|
|
48
|
+
* @param mimeType - MIME type string
|
|
49
|
+
* @returns Array of extensions (without dots)
|
|
50
|
+
*/
|
|
51
|
+
static getExtensions(mimeType) {
|
|
52
|
+
if (!mimeType)
|
|
53
|
+
return [];
|
|
54
|
+
// Check agent formats first
|
|
55
|
+
const agentFormat = AgentFileFormatRegistry.getFormatFromMimeType(mimeType);
|
|
56
|
+
if (agentFormat) {
|
|
57
|
+
const ext = AgentFileFormatRegistry.getExtension(agentFormat);
|
|
58
|
+
return ext ? [ext] : [];
|
|
59
|
+
}
|
|
60
|
+
// Fall back to general file registry
|
|
61
|
+
return FileMimeTypeRegistry.getExtensions(mimeType);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get format type (FileNature or AppsBlueprint_FileFormat) from extension.
|
|
65
|
+
*
|
|
66
|
+
* @param extension - File extension (without dot)
|
|
67
|
+
* @returns FormatTypeResult indicating whether it's a nature or agent format
|
|
68
|
+
*/
|
|
69
|
+
static getFormatType(extension) {
|
|
70
|
+
if (!extension)
|
|
71
|
+
return undefined;
|
|
72
|
+
// Check agent formats first (more specific)
|
|
73
|
+
const agentFormat = AgentFileFormatRegistry.getFormatFromExtension(extension);
|
|
74
|
+
if (agentFormat) {
|
|
75
|
+
return { type: 'agent', format: agentFormat };
|
|
76
|
+
}
|
|
77
|
+
// Check general file nature
|
|
78
|
+
const nature = FileMimeTypeRegistry.getNatureFromExtension(extension);
|
|
79
|
+
if (nature) {
|
|
80
|
+
return { type: 'nature', nature };
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get format type from extension (alias for getFormatType for consistency).
|
|
86
|
+
*
|
|
87
|
+
* @param extension - File extension (without dot)
|
|
88
|
+
* @returns FormatTypeResult indicating whether it's a nature or agent format
|
|
89
|
+
*/
|
|
90
|
+
static getFormatTypeFromExtension(extension) {
|
|
91
|
+
return this.getFormatType(extension);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get format type from MIME type.
|
|
95
|
+
*
|
|
96
|
+
* @param mimeType - MIME type string
|
|
97
|
+
* @returns FormatTypeResult indicating whether it's a nature or agent format
|
|
98
|
+
*/
|
|
99
|
+
static getFormatTypeFromMimeType(mimeType) {
|
|
100
|
+
if (!mimeType)
|
|
101
|
+
return undefined;
|
|
102
|
+
// Check agent formats first (more specific)
|
|
103
|
+
const agentFormat = AgentFileFormatRegistry.getFormatFromMimeType(mimeType);
|
|
104
|
+
if (agentFormat) {
|
|
105
|
+
return { type: 'agent', format: agentFormat };
|
|
106
|
+
}
|
|
107
|
+
// Check general file nature
|
|
108
|
+
const nature = FileMimeTypeRegistry.getNatureFromMimeType(mimeType);
|
|
109
|
+
if (nature) {
|
|
110
|
+
return { type: 'nature', nature };
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if file is an agent/blueprint format.
|
|
116
|
+
*
|
|
117
|
+
* @param extension - File extension (without dot)
|
|
118
|
+
* @returns true if extension is an agent format
|
|
119
|
+
*/
|
|
120
|
+
static isAgentFormat(extension) {
|
|
121
|
+
return AgentFileFormatRegistry.isAgentFormat(extension);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if MIME type is an agent/blueprint format.
|
|
125
|
+
*
|
|
126
|
+
* @param mimeType - MIME type string
|
|
127
|
+
* @returns true if MIME type is an agent format
|
|
128
|
+
*/
|
|
129
|
+
static isAgentMimeType(mimeType) {
|
|
130
|
+
return AgentFileFormatRegistry.isAgentMimeType(mimeType);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Validate that extension matches MIME type.
|
|
134
|
+
* Works for both general files and agent formats.
|
|
135
|
+
*
|
|
136
|
+
* @param extension - File extension (without dot)
|
|
137
|
+
* @param mimeType - MIME type string
|
|
138
|
+
* @returns true if extension matches MIME type
|
|
139
|
+
*/
|
|
140
|
+
static validateExtensionMimeMatch(extension, mimeType) {
|
|
141
|
+
if (!extension || !mimeType)
|
|
142
|
+
return false;
|
|
143
|
+
// Check agent formats first
|
|
144
|
+
const agentFormat = AgentFileFormatRegistry.getFormatFromExtension(extension);
|
|
145
|
+
if (agentFormat) {
|
|
146
|
+
const expectedMime = AgentFileFormatRegistry.getMimeType(agentFormat);
|
|
147
|
+
return expectedMime === mimeType;
|
|
148
|
+
}
|
|
149
|
+
// Fall back to general file validation
|
|
150
|
+
return FileMimeTypeRegistry.validateExtensionMimeMatch(extension, mimeType);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Normalize extension to canonical format name.
|
|
154
|
+
* Works for both general files and agent formats.
|
|
155
|
+
*
|
|
156
|
+
* @param extension - File extension (without dot)
|
|
157
|
+
* @returns Normalized format name
|
|
158
|
+
*/
|
|
159
|
+
static normalizeExtension(extension) {
|
|
160
|
+
if (!extension)
|
|
161
|
+
return extension;
|
|
162
|
+
// Check if it's an agent format
|
|
163
|
+
const agentFormat = AgentFileFormatRegistry.getFormatFromExtension(extension);
|
|
164
|
+
if (agentFormat) {
|
|
165
|
+
// For agent formats, return the format name directly
|
|
166
|
+
return agentFormat;
|
|
167
|
+
}
|
|
168
|
+
// Use general file normalization
|
|
169
|
+
return FileMimeTypeRegistry.normalizeExtension(extension);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get all extensions for a FileNature.
|
|
173
|
+
*
|
|
174
|
+
* @param nature - FileNature enum value
|
|
175
|
+
* @returns Array of extensions (without dots)
|
|
176
|
+
*/
|
|
177
|
+
static getExtensionsForNature(nature) {
|
|
178
|
+
return FileMimeTypeRegistry.getExtensionsForNature(nature);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get all MIME types for a FileNature.
|
|
182
|
+
*
|
|
183
|
+
* @param nature - FileNature enum value
|
|
184
|
+
* @returns Array of MIME type strings
|
|
185
|
+
*/
|
|
186
|
+
static getMimeTypesForNature(nature) {
|
|
187
|
+
return FileMimeTypeRegistry.getMimeTypesForNature(nature);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=unified-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-registry.js","sourceRoot":"","sources":["../../../src/files/unified-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAW/D;;GAEG;AACH,MAAM,OAAO,yBAA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B,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare function initZodDecorators(zodInstance?: typeof z): typeof z;
|
|
3
|
+
export * from './commons.js';
|
|
4
|
+
export * from './zod-color.js';
|
|
5
|
+
export * from './zod-range.js';
|
|
6
|
+
export * from './zod-money.js';
|
|
7
|
+
export * from './zod-bigdecimal.js';
|
|
8
|
+
export * from './zod-duration.js';
|
|
9
|
+
export * from './zod-phone.js';
|
|
10
|
+
export * from './zod-code.js';
|
|
11
|
+
export * from './zod-file.js';
|
|
12
|
+
export * from './zod-versioned.js';
|
|
13
|
+
export * from './currencies.shared.schemas.js';
|
|
14
|
+
export * from './zod-utils.shared.js';
|
|
15
|
+
export * from './zod-decorators.types.js';
|
|
16
|
+
export * from './zod.module-override.js';
|
|
17
|
+
export * from './files/file-extensions.enum.js';
|
|
18
|
+
export * from './files/extension-nature-map.js';
|
|
19
|
+
export * from './files/mime-registry.js';
|
|
20
|
+
export * from './files/agent-file-formats.js';
|
|
21
|
+
export * from './files/unified-registry.js';
|
|
22
|
+
/**
|
|
23
|
+
* Initialize Zod decorators for the current Zod instance.
|
|
24
|
+
* Safe to call multiple times - will only apply decorators once.
|
|
25
|
+
*
|
|
26
|
+
* This function should be called early in your application startup,
|
|
27
|
+
* especially when using custom-shared-lib or custom-backend-lib packages.
|
|
28
|
+
*/
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,wBAAgB,iBAAiB,CAAC,WAAW,GAAE,OAAO,CAAK,GAAG,OAAO,CAAC,CAErE;AAED,cAAc,WAAW,CAAC;AAE1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAIzC;;;;;;GAMG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ensureZodDecoratorsLoaded } from './zod.module-override.js';
|
|
3
|
+
// CRITICAL: Apply decorators immediately when this module is imported.
|
|
4
|
+
// This ensures z.string().isUnique() etc. work without needing to call initZodDecorators().
|
|
5
|
+
// The bundler may tree-shake the call in zod.module-override.ts, so we duplicate it here.
|
|
6
|
+
ensureZodDecoratorsLoaded(z);
|
|
7
|
+
export function initZodDecorators(zodInstance = z) {
|
|
8
|
+
return ensureZodDecoratorsLoaded(zodInstance);
|
|
9
|
+
}
|
|
10
|
+
export * from './commons.js';
|
|
11
|
+
export * from './zod-color.js';
|
|
12
|
+
export * from './zod-range.js';
|
|
13
|
+
export * from './zod-money.js';
|
|
14
|
+
export * from './zod-bigdecimal.js';
|
|
15
|
+
export * from './zod-duration.js';
|
|
16
|
+
export * from './zod-phone.js';
|
|
17
|
+
export * from './zod-code.js';
|
|
18
|
+
export * from './zod-file.js';
|
|
19
|
+
export * from './zod-versioned.js';
|
|
20
|
+
export * from './currencies.shared.schemas.js';
|
|
21
|
+
export * from './zod-utils.shared.js';
|
|
22
|
+
export * from './zod-decorators.types.js';
|
|
23
|
+
export * from './zod.module-override.js';
|
|
24
|
+
export * from './files/file-extensions.enum.js';
|
|
25
|
+
export * from './files/extension-nature-map.js';
|
|
26
|
+
export * from './files/mime-registry.js';
|
|
27
|
+
export * from './files/agent-file-formats.js';
|
|
28
|
+
export * from './files/unified-registry.js';
|
|
29
|
+
/**
|
|
30
|
+
* Initialize Zod decorators for the current Zod instance.
|
|
31
|
+
* Safe to call multiple times - will only apply decorators once.
|
|
32
|
+
*
|
|
33
|
+
* This function should be called early in your application startup,
|
|
34
|
+
* especially when using custom-shared-lib or custom-backend-lib packages.
|
|
35
|
+
*/
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,uEAAuE;AACvE,4FAA4F;AAC5F,0FAA0F;AAC1F,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,UAAU,iBAAiB,CAAC,cAAwB,CAAC;IACzD,OAAO,yBAAyB,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,cAAc,WAAW,CAAC;AAE1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAIzC;;;;;;GAMG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical decorated Zod shapes for cross-layer tests (engine packages, apps).
|
|
3
|
+
*
|
|
4
|
+
* Importing this file runs `ensureZodDecoratorsLoaded(z)` for the current `zod` instance,
|
|
5
|
+
* then builds schemas using chainable decorators (same pattern as package tests).
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Minimal “resource row” with primary key, summary, FK, and backend-only fields.
|
|
10
|
+
*/
|
|
11
|
+
export declare const decoratedTestEntitySchema: z.ZodObject<{
|
|
12
|
+
_id: import("../index.js").DecoratedPrimitiveZodType<z.ZodString>;
|
|
13
|
+
title: import("../index.js").DecoratedPrimitiveZodType<z.ZodString>;
|
|
14
|
+
ownerId: import("../index.js").DecoratedPrimitiveZodType<z.ZodString>;
|
|
15
|
+
internalNote: import("../index.js").DecoratedPrimitiveZodType<z.ZodString>;
|
|
16
|
+
}, z.core.$strip, core.$ZodObjectExtra>;
|
|
17
|
+
/**
|
|
18
|
+
* Variant-style row with a discriminator enum + summary field.
|
|
19
|
+
*/
|
|
20
|
+
export declare const decoratedTestVariantSchema: z.ZodObject<{
|
|
21
|
+
kind: import("../index.js").DecoratedPrimitiveZodType<z.ZodEnum<{
|
|
22
|
+
B: "B";
|
|
23
|
+
A: "A";
|
|
24
|
+
}>>;
|
|
25
|
+
label: import("../index.js").DecoratedPrimitiveZodType<z.ZodString>;
|
|
26
|
+
}, z.core.$strip, core.$ZodObjectExtra>;
|
|
27
|
+
//# sourceMappingURL=decorated-test-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-test-schemas.d.ts","sourceRoot":"","sources":["../../../src/testing/decorated-test-schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;uCAKpC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;uCAGrC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical decorated Zod shapes for cross-layer tests (engine packages, apps).
|
|
3
|
+
*
|
|
4
|
+
* Importing this file runs `ensureZodDecoratorsLoaded(z)` for the current `zod` instance,
|
|
5
|
+
* then builds schemas using chainable decorators (same pattern as package tests).
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { ensureZodDecoratorsLoaded } from '../zod.module-override.js';
|
|
9
|
+
ensureZodDecoratorsLoaded(z);
|
|
10
|
+
/**
|
|
11
|
+
* Minimal “resource row” with primary key, summary, FK, and backend-only fields.
|
|
12
|
+
*/
|
|
13
|
+
export const decoratedTestEntitySchema = z.object({
|
|
14
|
+
_id: z.string().isPrimaryKey(),
|
|
15
|
+
title: z.string().isSummaryField(),
|
|
16
|
+
ownerId: z.string().isForeignKey(),
|
|
17
|
+
internalNote: z.string().isBackendOnly(),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Variant-style row with a discriminator enum + summary field.
|
|
21
|
+
*/
|
|
22
|
+
export const decoratedTestVariantSchema = z.object({
|
|
23
|
+
kind: z.enum(['A', 'B']).isDiscriminator(),
|
|
24
|
+
label: z.string().isSummaryField(),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=decorated-test-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-test-schemas.js","sourceRoot":"","sources":["../../../src/testing/decorated-test-schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,cAAc,EAAE;IAClC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE;IAClC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;CACzC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,eAAe,EAAE;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,cAAc,EAAE;CACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/testing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/testing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,kCAAkC,CAAC"}
|