@resourcexjs/registry 2.2.0 → 2.4.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/README.md +240 -264
- package/dist/index.d.ts +245 -284
- package/dist/index.js +16794 -25105
- package/dist/index.js.map +15 -129
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,84 +1,6 @@
|
|
|
1
|
+
import { RXR as RXR3, RXL as RXL3 } from "@resourcexjs/core";
|
|
2
|
+
import { BundledType, ResolvedResource, IsolatorType } from "@resourcexjs/type";
|
|
1
3
|
import { RXR, RXL } from "@resourcexjs/core";
|
|
2
|
-
import { ResourceType, ResolvedResource } from "@resourcexjs/type";
|
|
3
|
-
/**
|
|
4
|
-
* Local registry configuration.
|
|
5
|
-
* Uses filesystem for storage.
|
|
6
|
-
*/
|
|
7
|
-
interface LocalRegistryConfig {
|
|
8
|
-
/**
|
|
9
|
-
* Local storage path. Defaults to ~/.resourcex
|
|
10
|
-
*/
|
|
11
|
-
path?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Supported resource types.
|
|
14
|
-
* If not provided, defaults to built-in types (text, json, binary).
|
|
15
|
-
*/
|
|
16
|
-
types?: ResourceType[];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Remote registry configuration.
|
|
20
|
-
* Uses HTTP API for access.
|
|
21
|
-
*/
|
|
22
|
-
interface RemoteRegistryConfig {
|
|
23
|
-
/**
|
|
24
|
-
* Remote registry API endpoint.
|
|
25
|
-
* Example: "https://registry.deepractice.ai/v1"
|
|
26
|
-
*/
|
|
27
|
-
endpoint: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Git registry configuration.
|
|
31
|
-
* Uses git clone to fetch registry content.
|
|
32
|
-
*/
|
|
33
|
-
interface GitRegistryConfig {
|
|
34
|
-
type: "git";
|
|
35
|
-
/** Git repository URL (SSH format: git@github.com:owner/repo.git) */
|
|
36
|
-
url: string;
|
|
37
|
-
/** Git ref (branch, tag, or commit). Default: "main" */
|
|
38
|
-
ref?: string;
|
|
39
|
-
/** Base path in repo for resources. Default: ".resourcex" */
|
|
40
|
-
basePath?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Trusted domain for this registry.
|
|
43
|
-
* If set, only resources with this domain in manifest are allowed.
|
|
44
|
-
* Required for security - prevents untrusted registries from claiming any domain.
|
|
45
|
-
*/
|
|
46
|
-
domain?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Well-known discovery response format.
|
|
50
|
-
* Used by discoverRegistry() to find registry for a domain.
|
|
51
|
-
*/
|
|
52
|
-
interface WellKnownResponse {
|
|
53
|
-
version: string;
|
|
54
|
-
/**
|
|
55
|
-
* List of registry URLs (git or http).
|
|
56
|
-
* First one is primary, rest are fallbacks (for future use).
|
|
57
|
-
*/
|
|
58
|
-
registries: string[];
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Result from discoverRegistry().
|
|
62
|
-
* Contains domain and its authorized registries.
|
|
63
|
-
*/
|
|
64
|
-
interface DiscoveryResult {
|
|
65
|
-
/** The domain that was discovered */
|
|
66
|
-
domain: string;
|
|
67
|
-
/** Authorized registry URLs for this domain */
|
|
68
|
-
registries: string[];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Registry configuration - local, remote, or git.
|
|
72
|
-
*/
|
|
73
|
-
type RegistryConfig = LocalRegistryConfig | RemoteRegistryConfig | GitRegistryConfig;
|
|
74
|
-
/**
|
|
75
|
-
* Type guard to check if config is for remote registry.
|
|
76
|
-
*/
|
|
77
|
-
declare function isRemoteConfig(config?: RegistryConfig): config is RemoteRegistryConfig;
|
|
78
|
-
/**
|
|
79
|
-
* Type guard to check if config is for git registry.
|
|
80
|
-
*/
|
|
81
|
-
declare function isGitConfig(config?: RegistryConfig): config is GitRegistryConfig;
|
|
82
4
|
/**
|
|
83
5
|
* Search options for querying resources.
|
|
84
6
|
*/
|
|
@@ -97,291 +19,332 @@ interface SearchOptions {
|
|
|
97
19
|
offset?: number;
|
|
98
20
|
}
|
|
99
21
|
/**
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Target configuration for publishing resources.
|
|
110
|
-
*/
|
|
111
|
-
interface PublishTarget {
|
|
112
|
-
type: "http" | "git";
|
|
113
|
-
/** HTTP endpoint (for type: "http") */
|
|
114
|
-
endpoint?: string;
|
|
115
|
-
/** Git repository URL (for type: "git") */
|
|
116
|
-
url?: string;
|
|
117
|
-
/** Git ref - branch/tag (for type: "git"). Default: "main" */
|
|
118
|
-
ref?: string;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Options for publishing resources to remote registry.
|
|
122
|
-
*/
|
|
123
|
-
interface PublishOptions {
|
|
124
|
-
/**
|
|
125
|
-
* Target registry configuration.
|
|
126
|
-
*/
|
|
127
|
-
to: PublishTarget;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Registry interface for resource storage and retrieval.
|
|
22
|
+
* Storage interface - pure storage abstraction.
|
|
23
|
+
* Handles CRUD operations for resources.
|
|
24
|
+
*
|
|
25
|
+
* Different implementations:
|
|
26
|
+
* - LocalStorage: filesystem, read-write
|
|
27
|
+
* - GitStorage: git clone, read-only
|
|
28
|
+
* - HttpStorage: HTTP API, typically read-only
|
|
131
29
|
*/
|
|
132
|
-
interface
|
|
133
|
-
/**
|
|
134
|
-
* Add support for a custom resource type.
|
|
135
|
-
* @param type - The resource type to support
|
|
136
|
-
*/
|
|
137
|
-
supportType(type: ResourceType): void;
|
|
138
|
-
/**
|
|
139
|
-
* Link a development directory to local registry.
|
|
140
|
-
* Creates a symlink so changes are reflected immediately.
|
|
141
|
-
* @param path - Path to resource directory (must contain resource.json)
|
|
142
|
-
*/
|
|
143
|
-
link(path: string): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Add resource to local registry.
|
|
146
|
-
* Copies resource content to local storage.
|
|
147
|
-
* @param source - Resource directory path or RXR object
|
|
148
|
-
*/
|
|
149
|
-
add(source: string | RXR): Promise<void>;
|
|
30
|
+
interface Storage {
|
|
150
31
|
/**
|
|
151
|
-
*
|
|
152
|
-
* Discovers remote registry via well-known and caches locally.
|
|
153
|
-
* @param locator - Resource locator (must include domain)
|
|
154
|
-
* @param options - Pull options
|
|
32
|
+
* Storage type identifier.
|
|
155
33
|
*/
|
|
156
|
-
|
|
34
|
+
readonly type: string;
|
|
157
35
|
/**
|
|
158
|
-
*
|
|
159
|
-
* @
|
|
160
|
-
* @param options - Publish target configuration (required)
|
|
161
|
-
*/
|
|
162
|
-
publish(source: string | RXR, options: PublishOptions): Promise<void>;
|
|
163
|
-
/**
|
|
164
|
-
* Get raw resource by locator string.
|
|
165
|
-
* Returns the RXR (locator + manifest + content) without resolving.
|
|
166
|
-
* Use this when you need access to raw resource content.
|
|
36
|
+
* Get resource by locator.
|
|
37
|
+
* @throws RegistryError if not found
|
|
167
38
|
*/
|
|
168
39
|
get(locator: string): Promise<RXR>;
|
|
169
40
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* Checks local first, then fetches from remote if not found.
|
|
41
|
+
* Store a resource.
|
|
42
|
+
* @throws RegistryError if storage is read-only
|
|
173
43
|
*/
|
|
174
|
-
|
|
175
|
-
TArgs = void,
|
|
176
|
-
TResult = unknown
|
|
177
|
-
>(locator: string): Promise<ResolvedResource<TArgs, TResult>>;
|
|
44
|
+
put(rxr: RXR): Promise<void>;
|
|
178
45
|
/**
|
|
179
46
|
* Check if resource exists.
|
|
180
47
|
*/
|
|
181
48
|
exists(locator: string): Promise<boolean>;
|
|
182
49
|
/**
|
|
183
|
-
* Delete resource
|
|
50
|
+
* Delete a resource.
|
|
51
|
+
* @throws RegistryError if storage is read-only
|
|
184
52
|
*/
|
|
185
53
|
delete(locator: string): Promise<void>;
|
|
186
54
|
/**
|
|
187
|
-
* Search for resources
|
|
188
|
-
* @param options - Search options (query, limit, offset)
|
|
189
|
-
* @returns Array of matching resource locators
|
|
55
|
+
* Search for resources.
|
|
190
56
|
*/
|
|
191
57
|
search(options?: SearchOptions): Promise<RXL[]>;
|
|
192
58
|
}
|
|
193
|
-
import {
|
|
59
|
+
import { RXR as RXR2, RXL as RXL2 } from "@resourcexjs/core";
|
|
194
60
|
/**
|
|
195
|
-
*
|
|
61
|
+
* LocalStorage configuration.
|
|
196
62
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
63
|
+
interface LocalStorageConfig {
|
|
64
|
+
/**
|
|
65
|
+
* Base path for storage. Defaults to ~/.resourcex
|
|
66
|
+
*/
|
|
67
|
+
path?: string;
|
|
199
68
|
}
|
|
200
|
-
import { RXR as RXR2, RXL as RXL2 } from "@resourcexjs/core";
|
|
201
|
-
import { ResourceType as ResourceType2, ResolvedResource as ResolvedResource2 } from "@resourcexjs/type";
|
|
202
69
|
/**
|
|
203
|
-
* Local filesystem
|
|
70
|
+
* Local filesystem storage implementation.
|
|
204
71
|
* Uses ARP file transport for I/O operations.
|
|
72
|
+
*
|
|
73
|
+
* Storage structure:
|
|
74
|
+
* - {basePath}/{domain}/{path}/{name}.{type}/{version}/
|
|
75
|
+
* - manifest.json
|
|
76
|
+
* - archive.tar.gz
|
|
77
|
+
*
|
|
78
|
+
* For localhost/no-domain resources:
|
|
79
|
+
* - {basePath}/localhost/{name}.{type}/{version}/
|
|
205
80
|
*/
|
|
206
|
-
declare class
|
|
81
|
+
declare class LocalStorage implements Storage {
|
|
82
|
+
readonly type = "local";
|
|
207
83
|
private readonly basePath;
|
|
208
|
-
private readonly typeHandler;
|
|
209
84
|
private readonly arp;
|
|
210
|
-
constructor(config?:
|
|
211
|
-
supportType(type: ResourceType2): void;
|
|
85
|
+
constructor(config?: LocalStorageConfig);
|
|
212
86
|
/**
|
|
213
87
|
* Create ARP URL for a file path.
|
|
214
88
|
*/
|
|
215
89
|
private toArpUrl;
|
|
216
90
|
/**
|
|
217
91
|
* Build filesystem path for a resource.
|
|
218
|
-
*
|
|
219
|
-
* Storage structure:
|
|
220
|
-
* - local: {basePath}/local/{name}.{type}/{version}
|
|
221
|
-
* - cache: {basePath}/cache/{domain}/{path}/{name}.{type}/{version}
|
|
222
|
-
*
|
|
223
|
-
* @param locator - Resource locator
|
|
224
|
-
* @param area - Storage area ("local" or "cache")
|
|
92
|
+
* Path: {basePath}/{domain}/{path}/{name}.{type}/{version}
|
|
225
93
|
*/
|
|
226
94
|
private buildPath;
|
|
227
95
|
/**
|
|
228
|
-
* Determine if a locator refers to a local-only resource (no domain or localhost).
|
|
229
|
-
*/
|
|
230
|
-
private isLocalOnlyLocator;
|
|
231
|
-
/**
|
|
232
96
|
* Check if a resource exists at a specific path.
|
|
97
|
+
* Handles both regular storage (manifest.json) and symlinked dev directories (resource.json).
|
|
233
98
|
*/
|
|
234
99
|
private existsAt;
|
|
235
100
|
/**
|
|
236
|
-
* Find which area a resource exists in.
|
|
237
|
-
* Returns the area ("local" or "cache") or null if not found.
|
|
238
|
-
*/
|
|
239
|
-
private findArea;
|
|
240
|
-
/**
|
|
241
101
|
* Check if a path is a symlink.
|
|
242
102
|
*/
|
|
243
103
|
private isSymlink;
|
|
244
104
|
/**
|
|
245
105
|
* Load resource from a specific path.
|
|
246
|
-
* If path is a symlink, loads from the linked directory
|
|
106
|
+
* If path is a symlink, loads from the linked directory.
|
|
247
107
|
*/
|
|
248
108
|
private loadFrom;
|
|
249
|
-
link(path: string): Promise<void>;
|
|
250
|
-
add(source: string | RXR2): Promise<void>;
|
|
251
|
-
pull(_locator: string, _options?: PullOptions): Promise<void>;
|
|
252
|
-
publish(_source: string | RXR2, _options: PublishOptions): Promise<void>;
|
|
253
109
|
get(locator: string): Promise<RXR2>;
|
|
254
|
-
|
|
255
|
-
TArgs = void,
|
|
256
|
-
TResult = unknown
|
|
257
|
-
>(locator: string): Promise<ResolvedResource2<TArgs, TResult>>;
|
|
110
|
+
put(rxr: RXR2): Promise<void>;
|
|
258
111
|
exists(locator: string): Promise<boolean>;
|
|
259
112
|
delete(locator: string): Promise<void>;
|
|
260
113
|
search(options?: SearchOptions): Promise<RXL2[]>;
|
|
261
114
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
115
|
+
* Link a development directory.
|
|
116
|
+
* Creates a symlink so changes are reflected immediately.
|
|
264
117
|
*/
|
|
265
|
-
|
|
118
|
+
link(path: string): Promise<void>;
|
|
266
119
|
/**
|
|
267
|
-
* Parse
|
|
120
|
+
* Parse entry path to RXL.
|
|
268
121
|
* Entry format: {domain}/{path}/{name}.{type}/{version}/manifest.json
|
|
269
122
|
*/
|
|
270
|
-
private
|
|
123
|
+
private parseEntryToRXL;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Registry configuration.
|
|
127
|
+
*/
|
|
128
|
+
interface RegistryConfig {
|
|
271
129
|
/**
|
|
272
|
-
*
|
|
130
|
+
* Storage backend. Defaults to LocalStorage.
|
|
273
131
|
*/
|
|
274
|
-
|
|
132
|
+
storage?: Storage;
|
|
133
|
+
/**
|
|
134
|
+
* Mirror URL for remote fetch (client mode).
|
|
135
|
+
* If configured, tries mirror before well-known discovery.
|
|
136
|
+
*/
|
|
137
|
+
mirror?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Additional custom resource types to support.
|
|
140
|
+
* Built-in types (text, json, binary) are always included by default.
|
|
141
|
+
*/
|
|
142
|
+
types?: BundledType[];
|
|
143
|
+
/**
|
|
144
|
+
* Isolator type for resolver execution (SandboX).
|
|
145
|
+
* - "none": No isolation, fastest (~10ms), for development
|
|
146
|
+
* - "srt": OS-level isolation (~50ms), secure local dev
|
|
147
|
+
* - "cloudflare": Container isolation (~100ms), local Docker or edge
|
|
148
|
+
* - "e2b": MicroVM isolation (~150ms), production (planned)
|
|
149
|
+
*/
|
|
150
|
+
isolator?: IsolatorType;
|
|
275
151
|
}
|
|
276
|
-
import { RXR as RXR3, RXL as RXL3 } from "@resourcexjs/core";
|
|
277
|
-
import { ResourceType as ResourceType3, ResolvedResource as ResolvedResource3 } from "@resourcexjs/type";
|
|
278
152
|
/**
|
|
279
|
-
*
|
|
280
|
-
* Uses HTTP API for resource access.
|
|
153
|
+
* Registry interface for resource management.
|
|
281
154
|
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
supportType(type:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
155
|
+
interface Registry {
|
|
156
|
+
/**
|
|
157
|
+
* Add support for a custom resource type.
|
|
158
|
+
*/
|
|
159
|
+
supportType(type: BundledType): void;
|
|
160
|
+
/**
|
|
161
|
+
* Link a development directory.
|
|
162
|
+
* Creates a symlink so changes are reflected immediately.
|
|
163
|
+
* Only supported by LocalStorage.
|
|
164
|
+
*/
|
|
165
|
+
link(path: string): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Add resource to storage.
|
|
168
|
+
* @param source - Resource directory path or RXR object
|
|
169
|
+
*/
|
|
170
|
+
add(source: string | RXR3): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Get raw resource by locator.
|
|
173
|
+
*
|
|
174
|
+
* Flow:
|
|
175
|
+
* - localhost: Only queries local storage
|
|
176
|
+
* - Other domains: Local cache -> [Mirror] -> Source (well-known)
|
|
177
|
+
*/
|
|
291
178
|
get(locator: string): Promise<RXR3>;
|
|
179
|
+
/**
|
|
180
|
+
* Resolve resource by locator.
|
|
181
|
+
* Returns ResolvedResource with execute function.
|
|
182
|
+
*/
|
|
292
183
|
resolve<
|
|
293
184
|
TArgs = void,
|
|
294
185
|
TResult = unknown
|
|
295
|
-
>(locator: string): Promise<
|
|
186
|
+
>(locator: string): Promise<ResolvedResource<TArgs, TResult>>;
|
|
187
|
+
/**
|
|
188
|
+
* Check if resource exists.
|
|
189
|
+
*/
|
|
296
190
|
exists(locator: string): Promise<boolean>;
|
|
297
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Delete resource from storage.
|
|
193
|
+
*/
|
|
194
|
+
delete(locator: string): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Search for resources.
|
|
197
|
+
*/
|
|
298
198
|
search(options?: SearchOptions): Promise<RXL3[]>;
|
|
299
199
|
}
|
|
300
200
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
201
|
+
* Default Registry implementation.
|
|
202
|
+
*
|
|
203
|
+
* Combines Storage (for CRUD) with TypeHandlerChain (for type resolution).
|
|
204
|
+
* Supports remote fetch for non-localhost domains.
|
|
304
205
|
*/
|
|
305
|
-
declare
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
declare class GitRegistry implements Registry {
|
|
309
|
-
private readonly url;
|
|
310
|
-
private readonly ref;
|
|
311
|
-
private readonly basePath;
|
|
312
|
-
private readonly cacheDir;
|
|
206
|
+
declare class DefaultRegistry implements Registry {
|
|
207
|
+
private readonly storage;
|
|
208
|
+
private readonly mirror?;
|
|
313
209
|
private readonly typeHandler;
|
|
314
|
-
private readonly
|
|
315
|
-
private readonly
|
|
316
|
-
constructor(config
|
|
210
|
+
private readonly executor;
|
|
211
|
+
private readonly discoveryCache;
|
|
212
|
+
constructor(config?: RegistryConfig);
|
|
213
|
+
supportType(type: BundledType): void;
|
|
214
|
+
link(path: string): Promise<void>;
|
|
215
|
+
add(source: string | RXR3): Promise<void>;
|
|
216
|
+
get(locator: string): Promise<RXR3>;
|
|
217
|
+
resolve<
|
|
218
|
+
TArgs = void,
|
|
219
|
+
TResult = unknown
|
|
220
|
+
>(locator: string): Promise<ResolvedResource<TArgs, TResult>>;
|
|
221
|
+
exists(locator: string): Promise<boolean>;
|
|
222
|
+
delete(locator: string): Promise<void>;
|
|
223
|
+
search(options?: SearchOptions): Promise<RXL3[]>;
|
|
317
224
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
225
|
+
* Fetch resource from remote.
|
|
226
|
+
* Flow: Mirror (if configured) -> Source (well-known)
|
|
320
227
|
*/
|
|
321
|
-
private
|
|
322
|
-
supportType(type: ResourceType4): void;
|
|
228
|
+
private fetchRemote;
|
|
323
229
|
/**
|
|
324
|
-
*
|
|
230
|
+
* Discover registry endpoint for a domain via well-known.
|
|
325
231
|
*/
|
|
326
|
-
private
|
|
232
|
+
private discoverEndpoint;
|
|
327
233
|
/**
|
|
328
|
-
*
|
|
329
|
-
* For local paths, just verify the .git directory exists.
|
|
330
|
-
* For remote URLs, includes retry logic for transient network errors.
|
|
234
|
+
* Fetch resource from a specific endpoint via HTTP API.
|
|
331
235
|
*/
|
|
332
|
-
private
|
|
236
|
+
private fetchFromEndpoint;
|
|
237
|
+
}
|
|
238
|
+
import { BundledType as BundledType2, IsolatorType as IsolatorType2 } from "@resourcexjs/type";
|
|
239
|
+
/**
|
|
240
|
+
* Client registry configuration.
|
|
241
|
+
* Uses LocalStorage as cache, optionally fetches from remote via mirror or well-known.
|
|
242
|
+
*/
|
|
243
|
+
interface ClientRegistryConfig {
|
|
333
244
|
/**
|
|
334
|
-
*
|
|
245
|
+
* Local cache path. Defaults to ~/.resourcex
|
|
335
246
|
*/
|
|
336
|
-
|
|
247
|
+
path?: string;
|
|
337
248
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
249
|
+
* Mirror URL for remote fetch.
|
|
250
|
+
* If configured, tries mirror before well-known discovery.
|
|
340
251
|
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
252
|
+
mirror?: string;
|
|
253
|
+
/**
|
|
254
|
+
* Additional custom resource types.
|
|
255
|
+
* Built-in types (text, json, binary) are always included.
|
|
256
|
+
*/
|
|
257
|
+
types?: BundledType2[];
|
|
258
|
+
/**
|
|
259
|
+
* Isolator type for resolver execution.
|
|
260
|
+
* Defaults to "none".
|
|
261
|
+
*/
|
|
262
|
+
isolator?: IsolatorType2;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Server registry configuration.
|
|
266
|
+
* Uses custom Storage implementation.
|
|
267
|
+
*/
|
|
268
|
+
interface ServerRegistryConfig {
|
|
269
|
+
/**
|
|
270
|
+
* Custom storage implementation.
|
|
271
|
+
* Example: new LocalStorage({ path: "..." })
|
|
272
|
+
*/
|
|
273
|
+
storage: Storage;
|
|
274
|
+
/**
|
|
275
|
+
* Additional custom resource types.
|
|
276
|
+
* Built-in types (text, json, binary) are always included.
|
|
277
|
+
*/
|
|
278
|
+
types?: BundledType2[];
|
|
279
|
+
/**
|
|
280
|
+
* Isolator type for resolver execution.
|
|
281
|
+
* Defaults to "none".
|
|
282
|
+
*/
|
|
283
|
+
isolator?: IsolatorType2;
|
|
355
284
|
}
|
|
356
285
|
/**
|
|
286
|
+
* All supported registry configurations.
|
|
287
|
+
*/
|
|
288
|
+
type CreateRegistryConfig = ClientRegistryConfig | ServerRegistryConfig;
|
|
289
|
+
/**
|
|
357
290
|
* Create a registry instance.
|
|
358
291
|
*
|
|
359
|
-
*
|
|
360
|
-
* wrapped with DomainValidation middleware for security.
|
|
292
|
+
* Built-in types (text, json, binary) are always included by default.
|
|
361
293
|
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* - GitRegistryConfig: Creates GitRegistry (git clone-based)
|
|
294
|
+
* Two modes:
|
|
295
|
+
* 1. Client mode (default): Uses LocalStorage as cache, fetches from remote when cache miss
|
|
296
|
+
* 2. Server mode: Uses custom Storage implementation
|
|
366
297
|
*
|
|
367
298
|
* @example
|
|
368
|
-
* //
|
|
299
|
+
* // Simple usage - builtin types included
|
|
369
300
|
* const registry = createRegistry();
|
|
370
|
-
* const registry2 = createRegistry({ path: "./custom-path" });
|
|
371
301
|
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
302
|
+
* @example
|
|
303
|
+
* // With custom types
|
|
304
|
+
* const registry = createRegistry({ types: [myPromptType] });
|
|
374
305
|
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
306
|
+
* @example
|
|
307
|
+
* // With isolator (SandboX)
|
|
308
|
+
* const registry = createRegistry({
|
|
309
|
+
* isolator: "srt", // or "none", "cloudflare", "e2b"
|
|
310
|
+
* });
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* // Server mode - custom storage
|
|
314
|
+
* const registry = createRegistry({
|
|
315
|
+
* storage: new LocalStorage({ path: "./data" }),
|
|
380
316
|
* });
|
|
381
317
|
*/
|
|
382
|
-
declare function createRegistry(config?:
|
|
383
|
-
|
|
384
|
-
|
|
318
|
+
declare function createRegistry(config?: CreateRegistryConfig): Registry;
|
|
319
|
+
/**
|
|
320
|
+
* Well-known discovery response format.
|
|
321
|
+
*/
|
|
322
|
+
interface WellKnownResponse {
|
|
323
|
+
version?: string;
|
|
324
|
+
registries: string[];
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Result from discoverRegistry().
|
|
328
|
+
*/
|
|
329
|
+
interface DiscoveryResult {
|
|
330
|
+
domain: string;
|
|
331
|
+
registries: string[];
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Discover registry for a domain using well-known.
|
|
335
|
+
* @param domain - The domain to discover (e.g., "deepractice.ai")
|
|
336
|
+
* @returns Discovery result with domain and authorized registries
|
|
337
|
+
*/
|
|
338
|
+
declare function discoverRegistry(domain: string): Promise<DiscoveryResult>;
|
|
339
|
+
import { ResourceXError } from "@resourcexjs/core";
|
|
340
|
+
/**
|
|
341
|
+
* Registry-specific error.
|
|
342
|
+
*/
|
|
343
|
+
declare class RegistryError extends ResourceXError {
|
|
344
|
+
constructor(message: string, options?: ErrorOptions);
|
|
345
|
+
}
|
|
346
|
+
import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
|
|
347
|
+
import { BundledType as BundledType3, ResolvedResource as ResolvedResource2 } from "@resourcexjs/type";
|
|
385
348
|
/**
|
|
386
349
|
* Base class for Registry middleware.
|
|
387
350
|
* Delegates all operations to the inner registry.
|
|
@@ -390,22 +353,20 @@ import { ResourceType as ResourceType5, ResolvedResource as ResolvedResource5 }
|
|
|
390
353
|
declare abstract class RegistryMiddleware implements Registry {
|
|
391
354
|
protected readonly inner: Registry;
|
|
392
355
|
constructor(inner: Registry);
|
|
393
|
-
supportType(type:
|
|
356
|
+
supportType(type: BundledType3): void;
|
|
394
357
|
link(path: string): Promise<void>;
|
|
395
|
-
add(source: string |
|
|
396
|
-
|
|
397
|
-
publish(source: string | RXR5, options: PublishOptions): Promise<void>;
|
|
398
|
-
get(locator: string): Promise<RXR5>;
|
|
358
|
+
add(source: string | RXR4): Promise<void>;
|
|
359
|
+
get(locator: string): Promise<RXR4>;
|
|
399
360
|
resolve<
|
|
400
361
|
TArgs = void,
|
|
401
362
|
TResult = unknown
|
|
402
|
-
>(locator: string): Promise<
|
|
363
|
+
>(locator: string): Promise<ResolvedResource2<TArgs, TResult>>;
|
|
403
364
|
exists(locator: string): Promise<boolean>;
|
|
404
365
|
delete(locator: string): Promise<void>;
|
|
405
|
-
search(options?: SearchOptions): Promise<
|
|
366
|
+
search(options?: SearchOptions): Promise<RXL4[]>;
|
|
406
367
|
}
|
|
407
|
-
import { RXR as
|
|
408
|
-
import { ResolvedResource as
|
|
368
|
+
import { RXR as RXR5 } from "@resourcexjs/core";
|
|
369
|
+
import { ResolvedResource as ResolvedResource3 } from "@resourcexjs/type";
|
|
409
370
|
/**
|
|
410
371
|
* Domain validation middleware.
|
|
411
372
|
* Ensures all resources from this registry match the trusted domain.
|
|
@@ -420,14 +381,14 @@ declare class DomainValidation extends RegistryMiddleware {
|
|
|
420
381
|
/**
|
|
421
382
|
* Get resource and validate domain.
|
|
422
383
|
*/
|
|
423
|
-
get(locator: string): Promise<
|
|
384
|
+
get(locator: string): Promise<RXR5>;
|
|
424
385
|
/**
|
|
425
386
|
* Resolve resource and validate domain.
|
|
426
387
|
*/
|
|
427
388
|
resolve<
|
|
428
389
|
TArgs = void,
|
|
429
390
|
TResult = unknown
|
|
430
|
-
>(locator: string): Promise<
|
|
391
|
+
>(locator: string): Promise<ResolvedResource3<TArgs, TResult>>;
|
|
431
392
|
}
|
|
432
393
|
/**
|
|
433
394
|
* Factory function to create domain validation middleware.
|
|
@@ -436,4 +397,4 @@ declare class DomainValidation extends RegistryMiddleware {
|
|
|
436
397
|
* const registry = withDomainValidation(gitRegistry, "deepractice.ai");
|
|
437
398
|
*/
|
|
438
399
|
declare function withDomainValidation(registry: Registry, trustedDomain: string): Registry;
|
|
439
|
-
export { withDomainValidation,
|
|
400
|
+
export { withDomainValidation, discoverRegistry, createRegistry, WellKnownResponse, Storage, ServerRegistryConfig, SearchOptions, RegistryMiddleware, RegistryError, RegistryConfig, Registry, LocalStorageConfig, LocalStorage, DomainValidation, DiscoveryResult, DefaultRegistry, CreateRegistryConfig, ClientRegistryConfig };
|