@objectstack/metadata 3.2.9 → 3.3.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/dist/index.cjs +2197 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +42 -82
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +2201 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +65 -0
- package/dist/node.d.ts +65 -0
- package/dist/{index.mjs → node.js} +3 -1
- package/package.json +18 -13
- package/.turbo/turbo-build.log +0 -22
- package/CHANGELOG.md +0 -496
- package/ROADMAP.md +0 -224
- package/src/index.ts +0 -68
- package/src/loaders/database-loader.test.ts +0 -559
- package/src/loaders/database-loader.ts +0 -352
- package/src/loaders/filesystem-loader.ts +0 -420
- package/src/loaders/loader-interface.ts +0 -89
- package/src/loaders/memory-loader.ts +0 -103
- package/src/loaders/remote-loader.ts +0 -140
- package/src/metadata-manager.ts +0 -1168
- package/src/metadata-service.test.ts +0 -965
- package/src/metadata.test.ts +0 -431
- package/src/migration/executor.ts +0 -54
- package/src/migration/index.ts +0 -3
- package/src/node-metadata-manager.ts +0 -126
- package/src/node.ts +0 -11
- package/src/objects/sys-metadata.object.ts +0 -188
- package/src/plugin.ts +0 -102
- package/src/serializers/json-serializer.ts +0 -73
- package/src/serializers/serializer-interface.ts +0 -65
- package/src/serializers/serializers.test.ts +0 -74
- package/src/serializers/typescript-serializer.ts +0 -127
- package/src/serializers/yaml-serializer.ts +0 -49
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -23
- /package/dist/{index.d.mts → index.d.cts} +0 -0
- /package/dist/{index.mjs.map → node.js.map} +0 -0
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Remote Metadata Loader
|
|
5
|
-
*
|
|
6
|
-
* Loads metadata from an HTTP API.
|
|
7
|
-
* This loader is stateless and delegates storage to the remote server.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type {
|
|
11
|
-
MetadataLoadOptions,
|
|
12
|
-
MetadataLoadResult,
|
|
13
|
-
MetadataStats,
|
|
14
|
-
MetadataLoaderContract,
|
|
15
|
-
MetadataSaveOptions,
|
|
16
|
-
MetadataSaveResult,
|
|
17
|
-
} from '@objectstack/spec/system';
|
|
18
|
-
import type { MetadataLoader } from './loader-interface.js';
|
|
19
|
-
|
|
20
|
-
export class RemoteLoader implements MetadataLoader {
|
|
21
|
-
readonly contract: MetadataLoaderContract = {
|
|
22
|
-
name: 'remote',
|
|
23
|
-
protocol: 'http:',
|
|
24
|
-
capabilities: {
|
|
25
|
-
read: true,
|
|
26
|
-
write: true,
|
|
27
|
-
watch: false, // Could implement SSE/WebSocket in future
|
|
28
|
-
list: true,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
constructor(private baseUrl: string, private authToken?: string) {}
|
|
33
|
-
|
|
34
|
-
private get headers() {
|
|
35
|
-
return {
|
|
36
|
-
'Content-Type': 'application/json',
|
|
37
|
-
...(this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {}),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async load(
|
|
42
|
-
type: string,
|
|
43
|
-
name: string,
|
|
44
|
-
_options?: MetadataLoadOptions
|
|
45
|
-
): Promise<MetadataLoadResult> {
|
|
46
|
-
try {
|
|
47
|
-
const response = await fetch(`${this.baseUrl}/${type}/${name}`, {
|
|
48
|
-
method: 'GET',
|
|
49
|
-
headers: this.headers,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (response.status === 404) {
|
|
53
|
-
return { data: null };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!response.ok) {
|
|
57
|
-
throw new Error(`Remote load failed: ${response.statusText}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const data = await response.json();
|
|
61
|
-
return {
|
|
62
|
-
data,
|
|
63
|
-
source: this.baseUrl,
|
|
64
|
-
format: 'json',
|
|
65
|
-
loadTime: 0,
|
|
66
|
-
};
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error(`RemoteLoader error loading ${type}/${name}`, error);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async loadMany<T = any>(
|
|
74
|
-
type: string,
|
|
75
|
-
_options?: MetadataLoadOptions
|
|
76
|
-
): Promise<T[]> {
|
|
77
|
-
const response = await fetch(`${this.baseUrl}/${type}`, {
|
|
78
|
-
method: 'GET',
|
|
79
|
-
headers: this.headers,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
if (!response.ok) {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (await response.json()) as T[];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async exists(type: string, name: string): Promise<boolean> {
|
|
90
|
-
const response = await fetch(`${this.baseUrl}/${type}/${name}`, {
|
|
91
|
-
method: 'HEAD',
|
|
92
|
-
headers: this.headers,
|
|
93
|
-
});
|
|
94
|
-
return response.ok;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async stat(type: string, name: string): Promise<MetadataStats | null> {
|
|
98
|
-
// Basic implementation using HEAD
|
|
99
|
-
const response = await fetch(`${this.baseUrl}/${type}/${name}`, {
|
|
100
|
-
method: 'HEAD',
|
|
101
|
-
headers: this.headers,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
if (!response.ok) return null;
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
size: Number(response.headers.get('content-length') || 0),
|
|
108
|
-
mtime: new Date(response.headers.get('last-modified') || Date.now()).toISOString(),
|
|
109
|
-
format: 'json',
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async list(type: string): Promise<string[]> {
|
|
114
|
-
const items = await this.loadMany<{ name: string }>(type);
|
|
115
|
-
return items.map(i => i.name);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async save(
|
|
119
|
-
type: string,
|
|
120
|
-
name: string,
|
|
121
|
-
data: any,
|
|
122
|
-
_options?: MetadataSaveOptions
|
|
123
|
-
): Promise<MetadataSaveResult> {
|
|
124
|
-
const response = await fetch(`${this.baseUrl}/${type}/${name}`, {
|
|
125
|
-
method: 'PUT',
|
|
126
|
-
headers: this.headers,
|
|
127
|
-
body: JSON.stringify(data),
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (!response.ok) {
|
|
131
|
-
throw new Error(`Remote save failed: ${response.statusText}`);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
success: true,
|
|
136
|
-
path: `${this.baseUrl}/${type}/${name}`,
|
|
137
|
-
saveTime: 0,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|