@objectstack/metadata 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +23 -0
- package/dist/index.d.mts +306 -0
- package/dist/index.d.ts +305 -16
- package/dist/index.js +1078 -15
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1040 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +7 -7
- package/tsconfig.json +1 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/loaders/filesystem-loader.d.ts +0 -42
- package/dist/loaders/filesystem-loader.d.ts.map +0 -1
- package/dist/loaders/filesystem-loader.js +0 -342
- package/dist/loaders/loader-interface.d.ts +0 -60
- package/dist/loaders/loader-interface.d.ts.map +0 -1
- package/dist/loaders/loader-interface.js +0 -6
- package/dist/loaders/memory-loader.d.ts +0 -19
- package/dist/loaders/memory-loader.d.ts.map +0 -1
- package/dist/loaders/memory-loader.js +0 -71
- package/dist/loaders/remote-loader.d.ts +0 -22
- package/dist/loaders/remote-loader.d.ts.map +0 -1
- package/dist/loaders/remote-loader.js +0 -103
- package/dist/metadata-manager.d.ts +0 -71
- package/dist/metadata-manager.d.ts.map +0 -1
- package/dist/metadata-manager.js +0 -211
- package/dist/migration/executor.d.ts +0 -9
- package/dist/migration/executor.d.ts.map +0 -1
- package/dist/migration/executor.js +0 -49
- package/dist/migration/index.d.ts +0 -2
- package/dist/migration/index.d.ts.map +0 -1
- package/dist/migration/index.js +0 -1
- package/dist/node-metadata-manager.d.ts +0 -26
- package/dist/node-metadata-manager.d.ts.map +0 -1
- package/dist/node-metadata-manager.js +0 -98
- package/dist/node.d.ts +0 -8
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -7
- package/dist/plugin.d.ts +0 -15
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -71
- package/dist/serializers/json-serializer.d.ts +0 -20
- package/dist/serializers/json-serializer.d.ts.map +0 -1
- package/dist/serializers/json-serializer.js +0 -53
- package/dist/serializers/serializer-interface.d.ts +0 -57
- package/dist/serializers/serializer-interface.d.ts.map +0 -1
- package/dist/serializers/serializer-interface.js +0 -6
- package/dist/serializers/serializers.test.d.ts +0 -2
- package/dist/serializers/serializers.test.d.ts.map +0 -1
- package/dist/serializers/serializers.test.js +0 -62
- package/dist/serializers/typescript-serializer.d.ts +0 -18
- package/dist/serializers/typescript-serializer.d.ts.map +0 -1
- package/dist/serializers/typescript-serializer.js +0 -103
- package/dist/serializers/yaml-serializer.d.ts +0 -16
- package/dist/serializers/yaml-serializer.d.ts.map +0 -1
- package/dist/serializers/yaml-serializer.js +0 -35
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
> @objectstack/metadata@1.0.6 build /home/runner/work/spec/spec/packages/metadata
|
|
3
|
+
> tsup --config ../../tsup.config.ts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/spec/spec/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2020
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[34mCJS[39m Build start
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m28.54 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m60.57 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 79ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.js [22m[32m30.34 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m61.88 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 88ms
|
|
19
|
+
[34mDTS[39m Build start
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 9382ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m9.91 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m9.91 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @objectstack/metadata
|
|
2
2
|
|
|
3
|
+
## 1.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a7f7b9d]
|
|
8
|
+
- @objectstack/spec@1.0.6
|
|
9
|
+
- @objectstack/core@1.0.6
|
|
10
|
+
- @objectstack/types@1.0.6
|
|
11
|
+
|
|
12
|
+
## 1.0.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- b1d24bd: refactor: migrate build system from tsc to tsup for faster builds
|
|
17
|
+
- Replaced `tsc` with `tsup` (using esbuild) across all packages
|
|
18
|
+
- Added shared `tsup.config.ts` in workspace root
|
|
19
|
+
- Added `tsup` as workspace dev dependency
|
|
20
|
+
- significantly improved build performance
|
|
21
|
+
- Updated dependencies [b1d24bd]
|
|
22
|
+
- @objectstack/core@1.0.5
|
|
23
|
+
- @objectstack/types@1.0.5
|
|
24
|
+
- @objectstack/spec@1.0.5
|
|
25
|
+
|
|
3
26
|
## 1.0.4
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { MetadataFormat, MetadataLoaderContract, MetadataLoadOptions, MetadataLoadResult, MetadataStats, MetadataSaveOptions, MetadataSaveResult, MetadataWatchEvent, MetadataManagerConfig } from '@objectstack/spec/system';
|
|
2
|
+
export { MetadataCollectionInfo, MetadataExportOptions, MetadataFormat, MetadataImportOptions, MetadataLoadOptions, MetadataLoadResult, MetadataLoaderContract, MetadataManagerConfig, MetadataSaveOptions, MetadataSaveResult, MetadataStats, MetadataWatchEvent } from '@objectstack/spec/system';
|
|
3
|
+
import { Logger, Plugin, PluginContext } from '@objectstack/core';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { System } from '@objectstack/spec';
|
|
6
|
+
import { ISchemaDriver } from '@objectstack/spec/contracts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Metadata Serializer Interface
|
|
10
|
+
*
|
|
11
|
+
* Defines the contract for serializing/deserializing metadata
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Serialization options
|
|
16
|
+
*/
|
|
17
|
+
interface SerializeOptions {
|
|
18
|
+
/** Prettify output (formatted with indentation) */
|
|
19
|
+
prettify?: boolean;
|
|
20
|
+
/** Indentation size (spaces) */
|
|
21
|
+
indent?: number;
|
|
22
|
+
/** Sort object keys alphabetically */
|
|
23
|
+
sortKeys?: boolean;
|
|
24
|
+
/** Include default values in output */
|
|
25
|
+
includeDefaults?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Abstract interface for metadata serializers
|
|
29
|
+
* Implementations handle different formats (JSON, YAML, TypeScript, etc.)
|
|
30
|
+
*/
|
|
31
|
+
interface MetadataSerializer {
|
|
32
|
+
/**
|
|
33
|
+
* Serialize object to string
|
|
34
|
+
* @param item The item to serialize
|
|
35
|
+
* @param options Serialization options
|
|
36
|
+
* @returns Serialized string
|
|
37
|
+
*/
|
|
38
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Deserialize string to object
|
|
41
|
+
* @param content The content to deserialize
|
|
42
|
+
* @param schema Optional Zod schema for validation
|
|
43
|
+
* @returns Deserialized object
|
|
44
|
+
*/
|
|
45
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
46
|
+
/**
|
|
47
|
+
* Get file extension for this format
|
|
48
|
+
* @returns File extension (e.g., '.json', '.yaml')
|
|
49
|
+
*/
|
|
50
|
+
getExtension(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Check if this serializer can handle the format
|
|
53
|
+
* @param format The format to check
|
|
54
|
+
* @returns True if can handle
|
|
55
|
+
*/
|
|
56
|
+
canHandle(format: MetadataFormat): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get the format this serializer handles
|
|
59
|
+
* @returns The metadata format
|
|
60
|
+
*/
|
|
61
|
+
getFormat(): MetadataFormat;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Metadata Loader Interface
|
|
66
|
+
*
|
|
67
|
+
* Defines the contract for loading metadata from various sources
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Abstract interface for metadata loaders
|
|
72
|
+
* Implementations can load from filesystem, HTTP, S3, databases, etc.
|
|
73
|
+
*/
|
|
74
|
+
interface MetadataLoader {
|
|
75
|
+
/**
|
|
76
|
+
* Loader contract information
|
|
77
|
+
*/
|
|
78
|
+
readonly contract: MetadataLoaderContract;
|
|
79
|
+
/**
|
|
80
|
+
* Load a single metadata item
|
|
81
|
+
* @param type The metadata type (e.g., 'object', 'view', 'app')
|
|
82
|
+
* @param name The item name/identifier
|
|
83
|
+
* @param options Load options
|
|
84
|
+
* @returns Load result with data or null if not found
|
|
85
|
+
*/
|
|
86
|
+
load(type: string, name: string, options?: MetadataLoadOptions): Promise<MetadataLoadResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Load multiple items matching patterns
|
|
89
|
+
* @param type The metadata type
|
|
90
|
+
* @param options Load options with patterns
|
|
91
|
+
* @returns Array of loaded items
|
|
92
|
+
*/
|
|
93
|
+
loadMany<T = any>(type: string, options?: MetadataLoadOptions): Promise<T[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Check if item exists
|
|
96
|
+
* @param type The metadata type
|
|
97
|
+
* @param name The item name
|
|
98
|
+
* @returns True if exists
|
|
99
|
+
*/
|
|
100
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Get item metadata (without loading full content)
|
|
103
|
+
* @param type The metadata type
|
|
104
|
+
* @param name The item name
|
|
105
|
+
* @returns Metadata statistics
|
|
106
|
+
*/
|
|
107
|
+
stat(type: string, name: string): Promise<MetadataStats | null>;
|
|
108
|
+
/**
|
|
109
|
+
* List all items of a type
|
|
110
|
+
* @param type The metadata type
|
|
111
|
+
* @returns Array of item names
|
|
112
|
+
*/
|
|
113
|
+
list(type: string): Promise<string[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Save metadata item
|
|
116
|
+
* @param type The metadata type
|
|
117
|
+
* @param name The item name
|
|
118
|
+
* @param data The data to save
|
|
119
|
+
* @param options Save options
|
|
120
|
+
*/
|
|
121
|
+
save?(type: string, name: string, data: any, options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Metadata Manager
|
|
126
|
+
*
|
|
127
|
+
* Main orchestrator for metadata loading, saving, and persistence.
|
|
128
|
+
* Browser-compatible (Pure).
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Watch callback function
|
|
133
|
+
*/
|
|
134
|
+
type WatchCallback = (event: MetadataWatchEvent) => void | Promise<void>;
|
|
135
|
+
interface MetadataManagerOptions extends MetadataManagerConfig {
|
|
136
|
+
loaders?: MetadataLoader[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Main metadata manager class
|
|
140
|
+
*/
|
|
141
|
+
declare class MetadataManager {
|
|
142
|
+
private loaders;
|
|
143
|
+
protected serializers: Map<MetadataFormat, MetadataSerializer>;
|
|
144
|
+
protected logger: Logger;
|
|
145
|
+
protected watchCallbacks: Map<string, Set<WatchCallback>>;
|
|
146
|
+
protected config: MetadataManagerOptions;
|
|
147
|
+
constructor(config: MetadataManagerOptions);
|
|
148
|
+
/**
|
|
149
|
+
* Register a new metadata loader (data source)
|
|
150
|
+
*/
|
|
151
|
+
registerLoader(loader: MetadataLoader): void;
|
|
152
|
+
/**
|
|
153
|
+
* Load a single metadata item
|
|
154
|
+
* Iterates through registered loaders until found
|
|
155
|
+
*/
|
|
156
|
+
load<T = any>(type: string, name: string, options?: MetadataLoadOptions): Promise<T | null>;
|
|
157
|
+
/**
|
|
158
|
+
* Load multiple metadata items
|
|
159
|
+
* Aggregates results from all loaders
|
|
160
|
+
*/
|
|
161
|
+
loadMany<T = any>(type: string, options?: MetadataLoadOptions): Promise<T[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Save metadata to disk
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* Save metadata item
|
|
167
|
+
*/
|
|
168
|
+
save<T = any>(type: string, name: string, data: T, options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
169
|
+
/**
|
|
170
|
+
* Check if metadata item exists
|
|
171
|
+
*/
|
|
172
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
173
|
+
/**
|
|
174
|
+
* List all items of a type
|
|
175
|
+
*/
|
|
176
|
+
list(type: string): Promise<string[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Watch for metadata changes
|
|
179
|
+
*/
|
|
180
|
+
watch(type: string, callback: WatchCallback): void;
|
|
181
|
+
/**
|
|
182
|
+
* Unwatch metadata changes
|
|
183
|
+
*/
|
|
184
|
+
unwatch(type: string, callback: WatchCallback): void;
|
|
185
|
+
/**
|
|
186
|
+
* Stop all watching
|
|
187
|
+
*/
|
|
188
|
+
stopWatching(): Promise<void>;
|
|
189
|
+
protected notifyWatchers(type: string, event: MetadataWatchEvent): void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface MetadataPluginOptions {
|
|
193
|
+
rootDir?: string;
|
|
194
|
+
watch?: boolean;
|
|
195
|
+
}
|
|
196
|
+
declare class MetadataPlugin implements Plugin {
|
|
197
|
+
name: string;
|
|
198
|
+
version: string;
|
|
199
|
+
private manager;
|
|
200
|
+
private options;
|
|
201
|
+
constructor(options?: MetadataPluginOptions);
|
|
202
|
+
init: (ctx: PluginContext) => Promise<void>;
|
|
203
|
+
start: (ctx: PluginContext) => Promise<void>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Memory Metadata Loader
|
|
208
|
+
*
|
|
209
|
+
* Stores metadata in memory only. Changes are lost when process restarts.
|
|
210
|
+
* Useful for testing, temporary overrides, or "dirty" edits.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
declare class MemoryLoader implements MetadataLoader {
|
|
214
|
+
readonly contract: MetadataLoaderContract;
|
|
215
|
+
private storage;
|
|
216
|
+
load(type: string, name: string, _options?: MetadataLoadOptions): Promise<MetadataLoadResult>;
|
|
217
|
+
loadMany<T = any>(type: string, _options?: MetadataLoadOptions): Promise<T[]>;
|
|
218
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
219
|
+
stat(type: string, name: string): Promise<MetadataStats | null>;
|
|
220
|
+
list(type: string): Promise<string[]>;
|
|
221
|
+
save(type: string, name: string, data: any, _options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Remote Metadata Loader
|
|
226
|
+
*
|
|
227
|
+
* Loads metadata from an HTTP API.
|
|
228
|
+
* This loader is stateless and delegates storage to the remote server.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
declare class RemoteLoader implements MetadataLoader {
|
|
232
|
+
private baseUrl;
|
|
233
|
+
private authToken?;
|
|
234
|
+
readonly contract: MetadataLoaderContract;
|
|
235
|
+
constructor(baseUrl: string, authToken?: string | undefined);
|
|
236
|
+
private get headers();
|
|
237
|
+
load(type: string, name: string, _options?: MetadataLoadOptions): Promise<MetadataLoadResult>;
|
|
238
|
+
loadMany<T = any>(type: string, _options?: MetadataLoadOptions): Promise<T[]>;
|
|
239
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
240
|
+
stat(type: string, name: string): Promise<MetadataStats | null>;
|
|
241
|
+
list(type: string): Promise<string[]>;
|
|
242
|
+
save(type: string, name: string, data: any, _options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* JSON Metadata Serializer
|
|
247
|
+
*
|
|
248
|
+
* Handles JSON format serialization and deserialization
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
declare class JSONSerializer implements MetadataSerializer {
|
|
252
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
253
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
254
|
+
getExtension(): string;
|
|
255
|
+
canHandle(format: MetadataFormat): boolean;
|
|
256
|
+
getFormat(): MetadataFormat;
|
|
257
|
+
/**
|
|
258
|
+
* Recursively sort object keys
|
|
259
|
+
*/
|
|
260
|
+
private sortObjectKeys;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* YAML Metadata Serializer
|
|
265
|
+
*
|
|
266
|
+
* Handles YAML format serialization and deserialization
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
declare class YAMLSerializer implements MetadataSerializer {
|
|
270
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
271
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
272
|
+
getExtension(): string;
|
|
273
|
+
canHandle(format: MetadataFormat): boolean;
|
|
274
|
+
getFormat(): MetadataFormat;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class MigrationExecutor {
|
|
278
|
+
private driver;
|
|
279
|
+
constructor(driver: ISchemaDriver);
|
|
280
|
+
executeChangeSet(changeSet: System.ChangeSet): Promise<void>;
|
|
281
|
+
private executeOperation;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
type index_MigrationExecutor = MigrationExecutor;
|
|
285
|
+
declare const index_MigrationExecutor: typeof MigrationExecutor;
|
|
286
|
+
declare namespace index {
|
|
287
|
+
export { index_MigrationExecutor as MigrationExecutor };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* TypeScript/JavaScript Metadata Serializer
|
|
292
|
+
*
|
|
293
|
+
* Handles TypeScript/JavaScript module format serialization and deserialization
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
declare class TypeScriptSerializer implements MetadataSerializer {
|
|
297
|
+
private format;
|
|
298
|
+
constructor(format?: 'typescript' | 'javascript');
|
|
299
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
300
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
301
|
+
getExtension(): string;
|
|
302
|
+
canHandle(format: MetadataFormat): boolean;
|
|
303
|
+
getFormat(): MetadataFormat;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export { JSONSerializer, MemoryLoader, type MetadataLoader, MetadataManager, type MetadataManagerOptions, MetadataPlugin, type MetadataSerializer, index as Migration, RemoteLoader, type SerializeOptions, TypeScriptSerializer, type WatchCallback, YAMLSerializer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,306 @@
|
|
|
1
|
+
import { MetadataFormat, MetadataLoaderContract, MetadataLoadOptions, MetadataLoadResult, MetadataStats, MetadataSaveOptions, MetadataSaveResult, MetadataWatchEvent, MetadataManagerConfig } from '@objectstack/spec/system';
|
|
2
|
+
export { MetadataCollectionInfo, MetadataExportOptions, MetadataFormat, MetadataImportOptions, MetadataLoadOptions, MetadataLoadResult, MetadataLoaderContract, MetadataManagerConfig, MetadataSaveOptions, MetadataSaveResult, MetadataStats, MetadataWatchEvent } from '@objectstack/spec/system';
|
|
3
|
+
import { Logger, Plugin, PluginContext } from '@objectstack/core';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { System } from '@objectstack/spec';
|
|
6
|
+
import { ISchemaDriver } from '@objectstack/spec/contracts';
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
* Metadata Serializer Interface
|
|
10
|
+
*
|
|
11
|
+
* Defines the contract for serializing/deserializing metadata
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Serialization options
|
|
16
|
+
*/
|
|
17
|
+
interface SerializeOptions {
|
|
18
|
+
/** Prettify output (formatted with indentation) */
|
|
19
|
+
prettify?: boolean;
|
|
20
|
+
/** Indentation size (spaces) */
|
|
21
|
+
indent?: number;
|
|
22
|
+
/** Sort object keys alphabetically */
|
|
23
|
+
sortKeys?: boolean;
|
|
24
|
+
/** Include default values in output */
|
|
25
|
+
includeDefaults?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Abstract interface for metadata serializers
|
|
29
|
+
* Implementations handle different formats (JSON, YAML, TypeScript, etc.)
|
|
30
|
+
*/
|
|
31
|
+
interface MetadataSerializer {
|
|
32
|
+
/**
|
|
33
|
+
* Serialize object to string
|
|
34
|
+
* @param item The item to serialize
|
|
35
|
+
* @param options Serialization options
|
|
36
|
+
* @returns Serialized string
|
|
37
|
+
*/
|
|
38
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Deserialize string to object
|
|
41
|
+
* @param content The content to deserialize
|
|
42
|
+
* @param schema Optional Zod schema for validation
|
|
43
|
+
* @returns Deserialized object
|
|
44
|
+
*/
|
|
45
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
46
|
+
/**
|
|
47
|
+
* Get file extension for this format
|
|
48
|
+
* @returns File extension (e.g., '.json', '.yaml')
|
|
49
|
+
*/
|
|
50
|
+
getExtension(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Check if this serializer can handle the format
|
|
53
|
+
* @param format The format to check
|
|
54
|
+
* @returns True if can handle
|
|
55
|
+
*/
|
|
56
|
+
canHandle(format: MetadataFormat): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get the format this serializer handles
|
|
59
|
+
* @returns The metadata format
|
|
60
|
+
*/
|
|
61
|
+
getFormat(): MetadataFormat;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Metadata Loader Interface
|
|
66
|
+
*
|
|
67
|
+
* Defines the contract for loading metadata from various sources
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Abstract interface for metadata loaders
|
|
72
|
+
* Implementations can load from filesystem, HTTP, S3, databases, etc.
|
|
73
|
+
*/
|
|
74
|
+
interface MetadataLoader {
|
|
75
|
+
/**
|
|
76
|
+
* Loader contract information
|
|
77
|
+
*/
|
|
78
|
+
readonly contract: MetadataLoaderContract;
|
|
79
|
+
/**
|
|
80
|
+
* Load a single metadata item
|
|
81
|
+
* @param type The metadata type (e.g., 'object', 'view', 'app')
|
|
82
|
+
* @param name The item name/identifier
|
|
83
|
+
* @param options Load options
|
|
84
|
+
* @returns Load result with data or null if not found
|
|
85
|
+
*/
|
|
86
|
+
load(type: string, name: string, options?: MetadataLoadOptions): Promise<MetadataLoadResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Load multiple items matching patterns
|
|
89
|
+
* @param type The metadata type
|
|
90
|
+
* @param options Load options with patterns
|
|
91
|
+
* @returns Array of loaded items
|
|
92
|
+
*/
|
|
93
|
+
loadMany<T = any>(type: string, options?: MetadataLoadOptions): Promise<T[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Check if item exists
|
|
96
|
+
* @param type The metadata type
|
|
97
|
+
* @param name The item name
|
|
98
|
+
* @returns True if exists
|
|
99
|
+
*/
|
|
100
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Get item metadata (without loading full content)
|
|
103
|
+
* @param type The metadata type
|
|
104
|
+
* @param name The item name
|
|
105
|
+
* @returns Metadata statistics
|
|
106
|
+
*/
|
|
107
|
+
stat(type: string, name: string): Promise<MetadataStats | null>;
|
|
108
|
+
/**
|
|
109
|
+
* List all items of a type
|
|
110
|
+
* @param type The metadata type
|
|
111
|
+
* @returns Array of item names
|
|
112
|
+
*/
|
|
113
|
+
list(type: string): Promise<string[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Save metadata item
|
|
116
|
+
* @param type The metadata type
|
|
117
|
+
* @param name The item name
|
|
118
|
+
* @param data The data to save
|
|
119
|
+
* @param options Save options
|
|
120
|
+
*/
|
|
121
|
+
save?(type: string, name: string, data: any, options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Metadata Manager
|
|
126
|
+
*
|
|
127
|
+
* Main orchestrator for metadata loading, saving, and persistence.
|
|
128
|
+
* Browser-compatible (Pure).
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Watch callback function
|
|
133
|
+
*/
|
|
134
|
+
type WatchCallback = (event: MetadataWatchEvent) => void | Promise<void>;
|
|
135
|
+
interface MetadataManagerOptions extends MetadataManagerConfig {
|
|
136
|
+
loaders?: MetadataLoader[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Main metadata manager class
|
|
140
|
+
*/
|
|
141
|
+
declare class MetadataManager {
|
|
142
|
+
private loaders;
|
|
143
|
+
protected serializers: Map<MetadataFormat, MetadataSerializer>;
|
|
144
|
+
protected logger: Logger;
|
|
145
|
+
protected watchCallbacks: Map<string, Set<WatchCallback>>;
|
|
146
|
+
protected config: MetadataManagerOptions;
|
|
147
|
+
constructor(config: MetadataManagerOptions);
|
|
148
|
+
/**
|
|
149
|
+
* Register a new metadata loader (data source)
|
|
150
|
+
*/
|
|
151
|
+
registerLoader(loader: MetadataLoader): void;
|
|
152
|
+
/**
|
|
153
|
+
* Load a single metadata item
|
|
154
|
+
* Iterates through registered loaders until found
|
|
155
|
+
*/
|
|
156
|
+
load<T = any>(type: string, name: string, options?: MetadataLoadOptions): Promise<T | null>;
|
|
157
|
+
/**
|
|
158
|
+
* Load multiple metadata items
|
|
159
|
+
* Aggregates results from all loaders
|
|
160
|
+
*/
|
|
161
|
+
loadMany<T = any>(type: string, options?: MetadataLoadOptions): Promise<T[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Save metadata to disk
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* Save metadata item
|
|
167
|
+
*/
|
|
168
|
+
save<T = any>(type: string, name: string, data: T, options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
169
|
+
/**
|
|
170
|
+
* Check if metadata item exists
|
|
171
|
+
*/
|
|
172
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
173
|
+
/**
|
|
174
|
+
* List all items of a type
|
|
175
|
+
*/
|
|
176
|
+
list(type: string): Promise<string[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Watch for metadata changes
|
|
179
|
+
*/
|
|
180
|
+
watch(type: string, callback: WatchCallback): void;
|
|
181
|
+
/**
|
|
182
|
+
* Unwatch metadata changes
|
|
183
|
+
*/
|
|
184
|
+
unwatch(type: string, callback: WatchCallback): void;
|
|
185
|
+
/**
|
|
186
|
+
* Stop all watching
|
|
187
|
+
*/
|
|
188
|
+
stopWatching(): Promise<void>;
|
|
189
|
+
protected notifyWatchers(type: string, event: MetadataWatchEvent): void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface MetadataPluginOptions {
|
|
193
|
+
rootDir?: string;
|
|
194
|
+
watch?: boolean;
|
|
195
|
+
}
|
|
196
|
+
declare class MetadataPlugin implements Plugin {
|
|
197
|
+
name: string;
|
|
198
|
+
version: string;
|
|
199
|
+
private manager;
|
|
200
|
+
private options;
|
|
201
|
+
constructor(options?: MetadataPluginOptions);
|
|
202
|
+
init: (ctx: PluginContext) => Promise<void>;
|
|
203
|
+
start: (ctx: PluginContext) => Promise<void>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Memory Metadata Loader
|
|
208
|
+
*
|
|
209
|
+
* Stores metadata in memory only. Changes are lost when process restarts.
|
|
210
|
+
* Useful for testing, temporary overrides, or "dirty" edits.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
declare class MemoryLoader implements MetadataLoader {
|
|
214
|
+
readonly contract: MetadataLoaderContract;
|
|
215
|
+
private storage;
|
|
216
|
+
load(type: string, name: string, _options?: MetadataLoadOptions): Promise<MetadataLoadResult>;
|
|
217
|
+
loadMany<T = any>(type: string, _options?: MetadataLoadOptions): Promise<T[]>;
|
|
218
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
219
|
+
stat(type: string, name: string): Promise<MetadataStats | null>;
|
|
220
|
+
list(type: string): Promise<string[]>;
|
|
221
|
+
save(type: string, name: string, data: any, _options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Remote Metadata Loader
|
|
226
|
+
*
|
|
227
|
+
* Loads metadata from an HTTP API.
|
|
228
|
+
* This loader is stateless and delegates storage to the remote server.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
declare class RemoteLoader implements MetadataLoader {
|
|
232
|
+
private baseUrl;
|
|
233
|
+
private authToken?;
|
|
234
|
+
readonly contract: MetadataLoaderContract;
|
|
235
|
+
constructor(baseUrl: string, authToken?: string | undefined);
|
|
236
|
+
private get headers();
|
|
237
|
+
load(type: string, name: string, _options?: MetadataLoadOptions): Promise<MetadataLoadResult>;
|
|
238
|
+
loadMany<T = any>(type: string, _options?: MetadataLoadOptions): Promise<T[]>;
|
|
239
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
240
|
+
stat(type: string, name: string): Promise<MetadataStats | null>;
|
|
241
|
+
list(type: string): Promise<string[]>;
|
|
242
|
+
save(type: string, name: string, data: any, _options?: MetadataSaveOptions): Promise<MetadataSaveResult>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* JSON Metadata Serializer
|
|
247
|
+
*
|
|
248
|
+
* Handles JSON format serialization and deserialization
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
declare class JSONSerializer implements MetadataSerializer {
|
|
252
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
253
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
254
|
+
getExtension(): string;
|
|
255
|
+
canHandle(format: MetadataFormat): boolean;
|
|
256
|
+
getFormat(): MetadataFormat;
|
|
257
|
+
/**
|
|
258
|
+
* Recursively sort object keys
|
|
259
|
+
*/
|
|
260
|
+
private sortObjectKeys;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* YAML Metadata Serializer
|
|
265
|
+
*
|
|
266
|
+
* Handles YAML format serialization and deserialization
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
declare class YAMLSerializer implements MetadataSerializer {
|
|
270
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
271
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
272
|
+
getExtension(): string;
|
|
273
|
+
canHandle(format: MetadataFormat): boolean;
|
|
274
|
+
getFormat(): MetadataFormat;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class MigrationExecutor {
|
|
278
|
+
private driver;
|
|
279
|
+
constructor(driver: ISchemaDriver);
|
|
280
|
+
executeChangeSet(changeSet: System.ChangeSet): Promise<void>;
|
|
281
|
+
private executeOperation;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
type index_MigrationExecutor = MigrationExecutor;
|
|
285
|
+
declare const index_MigrationExecutor: typeof MigrationExecutor;
|
|
286
|
+
declare namespace index {
|
|
287
|
+
export { index_MigrationExecutor as MigrationExecutor };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* TypeScript/JavaScript Metadata Serializer
|
|
292
|
+
*
|
|
293
|
+
* Handles TypeScript/JavaScript module format serialization and deserialization
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
declare class TypeScriptSerializer implements MetadataSerializer {
|
|
297
|
+
private format;
|
|
298
|
+
constructor(format?: 'typescript' | 'javascript');
|
|
299
|
+
serialize<T>(item: T, options?: SerializeOptions): string;
|
|
300
|
+
deserialize<T>(content: string, schema?: z.ZodSchema): T;
|
|
301
|
+
getExtension(): string;
|
|
302
|
+
canHandle(format: MetadataFormat): boolean;
|
|
303
|
+
getFormat(): MetadataFormat;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export { JSONSerializer, MemoryLoader, type MetadataLoader, MetadataManager, type MetadataManagerOptions, MetadataPlugin, type MetadataSerializer, index as Migration, RemoteLoader, type SerializeOptions, TypeScriptSerializer, type WatchCallback, YAMLSerializer };
|