@objectstack/metadata 3.3.0 → 4.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.
Files changed (38) hide show
  1. package/dist/index.cjs +2197 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.js +42 -82
  4. package/dist/index.js.map +1 -1
  5. package/dist/node.cjs +2201 -0
  6. package/dist/node.cjs.map +1 -0
  7. package/dist/node.d.cts +65 -0
  8. package/dist/node.d.ts +65 -0
  9. package/dist/{index.mjs → node.js} +3 -1
  10. package/package.json +22 -17
  11. package/.turbo/turbo-build.log +0 -22
  12. package/CHANGELOG.md +0 -504
  13. package/ROADMAP.md +0 -224
  14. package/src/index.ts +0 -68
  15. package/src/loaders/database-loader.test.ts +0 -559
  16. package/src/loaders/database-loader.ts +0 -352
  17. package/src/loaders/filesystem-loader.ts +0 -420
  18. package/src/loaders/loader-interface.ts +0 -89
  19. package/src/loaders/memory-loader.ts +0 -103
  20. package/src/loaders/remote-loader.ts +0 -140
  21. package/src/metadata-manager.ts +0 -1168
  22. package/src/metadata-service.test.ts +0 -965
  23. package/src/metadata.test.ts +0 -431
  24. package/src/migration/executor.ts +0 -54
  25. package/src/migration/index.ts +0 -3
  26. package/src/node-metadata-manager.ts +0 -126
  27. package/src/node.ts +0 -11
  28. package/src/objects/sys-metadata.object.ts +0 -188
  29. package/src/plugin.ts +0 -102
  30. package/src/serializers/json-serializer.ts +0 -73
  31. package/src/serializers/serializer-interface.ts +0 -65
  32. package/src/serializers/serializers.test.ts +0 -74
  33. package/src/serializers/typescript-serializer.ts +0 -127
  34. package/src/serializers/yaml-serializer.ts +0 -49
  35. package/tsconfig.json +0 -9
  36. package/vitest.config.ts +0 -23
  37. /package/dist/{index.d.mts → index.d.cts} +0 -0
  38. /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
- }