@resourcexjs/registry 2.2.0 → 2.3.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/index.d.ts +69 -112
- package/dist/index.js +573 -127
- package/dist/index.js.map +13 -12
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,44 @@ interface GitRegistryConfig {
|
|
|
46
46
|
domain?: string;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
+
* GitHub registry configuration (internal).
|
|
50
|
+
* Uses GitHub's archive API to download tarball (faster than git clone).
|
|
51
|
+
*/
|
|
52
|
+
interface GitHubRegistryConfig {
|
|
53
|
+
type: "github";
|
|
54
|
+
/** GitHub repository URL (format: https://github.com/owner/repo) */
|
|
55
|
+
url: string;
|
|
56
|
+
/** Git ref (branch, tag, or commit). Default: "main" */
|
|
57
|
+
ref?: string;
|
|
58
|
+
/** Base path in repo for resources. Default: ".resourcex" */
|
|
59
|
+
basePath?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Trusted domain for this registry.
|
|
62
|
+
* If set, only resources with this domain in manifest are allowed.
|
|
63
|
+
*/
|
|
64
|
+
domain?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* URL-based registry configuration.
|
|
68
|
+
* Auto-detects registry type based on URL format:
|
|
69
|
+
* - https://github.com/... → GitHubRegistry (tarball download)
|
|
70
|
+
* - git@... or *.git → GitRegistry (git clone)
|
|
71
|
+
* - https://... (other) → RemoteRegistry (HTTP API)
|
|
72
|
+
*/
|
|
73
|
+
interface UrlRegistryConfig {
|
|
74
|
+
/** Registry URL - type is auto-detected */
|
|
75
|
+
url: string;
|
|
76
|
+
/** Git ref (branch, tag, or commit). Default: "main" */
|
|
77
|
+
ref?: string;
|
|
78
|
+
/** Base path in repo for resources. Default: ".resourcex" */
|
|
79
|
+
basePath?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Trusted domain for this registry.
|
|
82
|
+
* Required for remote URLs (security).
|
|
83
|
+
*/
|
|
84
|
+
domain?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
49
87
|
* Well-known discovery response format.
|
|
50
88
|
* Used by discoverRegistry() to find registry for a domain.
|
|
51
89
|
*/
|
|
@@ -68,17 +106,9 @@ interface DiscoveryResult {
|
|
|
68
106
|
registries: string[];
|
|
69
107
|
}
|
|
70
108
|
/**
|
|
71
|
-
* Registry configuration - local, remote, or
|
|
109
|
+
* Registry configuration - local, remote, git, github, or URL-based.
|
|
72
110
|
*/
|
|
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;
|
|
111
|
+
type RegistryConfig = LocalRegistryConfig | RemoteRegistryConfig | GitRegistryConfig | GitHubRegistryConfig | UrlRegistryConfig;
|
|
82
112
|
/**
|
|
83
113
|
* Search options for querying resources.
|
|
84
114
|
*/
|
|
@@ -273,115 +303,42 @@ declare class LocalRegistry implements Registry {
|
|
|
273
303
|
*/
|
|
274
304
|
private parseNameType;
|
|
275
305
|
}
|
|
276
|
-
import { RXR as RXR3, RXL as RXL3 } from "@resourcexjs/core";
|
|
277
|
-
import { ResourceType as ResourceType3, ResolvedResource as ResolvedResource3 } from "@resourcexjs/type";
|
|
278
|
-
/**
|
|
279
|
-
* Remote registry implementation.
|
|
280
|
-
* Uses HTTP API for resource access.
|
|
281
|
-
*/
|
|
282
|
-
declare class RemoteRegistry implements Registry {
|
|
283
|
-
private readonly endpoint;
|
|
284
|
-
private readonly typeHandler;
|
|
285
|
-
constructor(config: RemoteRegistryConfig);
|
|
286
|
-
supportType(type: ResourceType3): void;
|
|
287
|
-
link(_path: string): Promise<void>;
|
|
288
|
-
add(_source: string | RXR3): Promise<void>;
|
|
289
|
-
pull(_locator: string, _options?: PullOptions): Promise<void>;
|
|
290
|
-
publish(_source: string | RXR3, _options: PublishOptions): Promise<void>;
|
|
291
|
-
get(locator: string): Promise<RXR3>;
|
|
292
|
-
resolve<
|
|
293
|
-
TArgs = void,
|
|
294
|
-
TResult = unknown
|
|
295
|
-
>(locator: string): Promise<ResolvedResource3<TArgs, TResult>>;
|
|
296
|
-
exists(locator: string): Promise<boolean>;
|
|
297
|
-
delete(_locator: string): Promise<void>;
|
|
298
|
-
search(options?: SearchOptions): Promise<RXL3[]>;
|
|
299
|
-
}
|
|
300
306
|
/**
|
|
301
307
|
* Discover registry for a domain using well-known.
|
|
302
308
|
* @param domain - The domain to discover (e.g., "deepractice.ai")
|
|
303
309
|
* @returns Discovery result with domain and authorized registries
|
|
304
310
|
*/
|
|
305
311
|
declare function discoverRegistry(domain: string): Promise<DiscoveryResult>;
|
|
306
|
-
import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
|
|
307
|
-
import { ResourceType as ResourceType4, ResolvedResource as ResolvedResource4 } from "@resourcexjs/type";
|
|
308
|
-
declare class GitRegistry implements Registry {
|
|
309
|
-
private readonly url;
|
|
310
|
-
private readonly ref;
|
|
311
|
-
private readonly basePath;
|
|
312
|
-
private readonly cacheDir;
|
|
313
|
-
private readonly typeHandler;
|
|
314
|
-
private readonly arp;
|
|
315
|
-
private readonly isLocal;
|
|
316
|
-
constructor(config: GitRegistryConfig);
|
|
317
|
-
/**
|
|
318
|
-
* Build cache directory name from git URL.
|
|
319
|
-
* git@github.com:Deepractice/Registry.git → github.com-Deepractice-Registry
|
|
320
|
-
*/
|
|
321
|
-
private buildCacheDir;
|
|
322
|
-
supportType(type: ResourceType4): void;
|
|
323
|
-
/**
|
|
324
|
-
* Create ARP URL for a file path.
|
|
325
|
-
*/
|
|
326
|
-
private toArpUrl;
|
|
327
|
-
/**
|
|
328
|
-
* Ensure the repository is cloned and up to date.
|
|
329
|
-
* For local paths, just verify the .git directory exists.
|
|
330
|
-
* For remote URLs, includes retry logic for transient network errors.
|
|
331
|
-
*/
|
|
332
|
-
private ensureCloned;
|
|
333
|
-
/**
|
|
334
|
-
* Get the default branch name (main or master).
|
|
335
|
-
*/
|
|
336
|
-
private getDefaultBranch;
|
|
337
|
-
/**
|
|
338
|
-
* Build filesystem path for a resource in the cloned repo.
|
|
339
|
-
* Path structure: {cacheDir}/{basePath}/{domain}/{path}/{name}.{type}/{version}
|
|
340
|
-
*/
|
|
341
|
-
private buildResourcePath;
|
|
342
|
-
get(locator: string): Promise<RXR4>;
|
|
343
|
-
resolve<
|
|
344
|
-
TArgs = void,
|
|
345
|
-
TResult = unknown
|
|
346
|
-
>(locator: string): Promise<ResolvedResource4<TArgs, TResult>>;
|
|
347
|
-
exists(locator: string): Promise<boolean>;
|
|
348
|
-
search(options?: SearchOptions): Promise<RXL4[]>;
|
|
349
|
-
private parseEntryToRXL;
|
|
350
|
-
link(_path: string): Promise<void>;
|
|
351
|
-
add(_source: string | RXR4): Promise<void>;
|
|
352
|
-
pull(_locator: string, _options?: PullOptions): Promise<void>;
|
|
353
|
-
publish(_source: string | RXR4, _options: PublishOptions): Promise<void>;
|
|
354
|
-
delete(_locator: string): Promise<void>;
|
|
355
|
-
}
|
|
356
312
|
/**
|
|
357
313
|
* Create a registry instance.
|
|
358
314
|
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* - GitRegistryConfig: Creates GitRegistry (git clone-based)
|
|
315
|
+
* Supports multiple configuration styles:
|
|
316
|
+
* - No config: LocalRegistry (filesystem-based)
|
|
317
|
+
* - `{ url, domain }`: Auto-detects type based on URL format
|
|
318
|
+
* - `{ endpoint }`: RemoteRegistry (HTTP API)
|
|
319
|
+
* - `{ type: "git", url }`: GitRegistry (git clone)
|
|
320
|
+
* - `{ type: "github", url }`: GitHubRegistry (tarball download)
|
|
366
321
|
*
|
|
367
322
|
* @example
|
|
368
323
|
* // Local registry (default)
|
|
369
324
|
* const registry = createRegistry();
|
|
370
|
-
* const registry2 = createRegistry({ path: "./custom-path" });
|
|
371
325
|
*
|
|
372
|
-
* //
|
|
373
|
-
* const
|
|
326
|
+
* // URL-based (auto-detect type)
|
|
327
|
+
* const registry2 = createRegistry({
|
|
328
|
+
* url: "https://github.com/Deepractice/Registry",
|
|
329
|
+
* domain: "deepractice.dev",
|
|
330
|
+
* });
|
|
374
331
|
*
|
|
375
|
-
* //
|
|
376
|
-
* const
|
|
377
|
-
*
|
|
378
|
-
* url:
|
|
379
|
-
* domain:
|
|
332
|
+
* // With discovery
|
|
333
|
+
* const discovery = await discoverRegistry("deepractice.dev");
|
|
334
|
+
* const registry3 = createRegistry({
|
|
335
|
+
* url: discovery.registries[0],
|
|
336
|
+
* domain: discovery.domain,
|
|
380
337
|
* });
|
|
381
338
|
*/
|
|
382
339
|
declare function createRegistry(config?: RegistryConfig): Registry;
|
|
383
|
-
import { RXR as
|
|
384
|
-
import { ResourceType as
|
|
340
|
+
import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
|
|
341
|
+
import { ResourceType as ResourceType4, ResolvedResource as ResolvedResource4 } from "@resourcexjs/type";
|
|
385
342
|
/**
|
|
386
343
|
* Base class for Registry middleware.
|
|
387
344
|
* Delegates all operations to the inner registry.
|
|
@@ -390,22 +347,22 @@ import { ResourceType as ResourceType5, ResolvedResource as ResolvedResource5 }
|
|
|
390
347
|
declare abstract class RegistryMiddleware implements Registry {
|
|
391
348
|
protected readonly inner: Registry;
|
|
392
349
|
constructor(inner: Registry);
|
|
393
|
-
supportType(type:
|
|
350
|
+
supportType(type: ResourceType4): void;
|
|
394
351
|
link(path: string): Promise<void>;
|
|
395
|
-
add(source: string |
|
|
352
|
+
add(source: string | RXR4): Promise<void>;
|
|
396
353
|
pull(locator: string, options?: PullOptions): Promise<void>;
|
|
397
|
-
publish(source: string |
|
|
398
|
-
get(locator: string): Promise<
|
|
354
|
+
publish(source: string | RXR4, options: PublishOptions): Promise<void>;
|
|
355
|
+
get(locator: string): Promise<RXR4>;
|
|
399
356
|
resolve<
|
|
400
357
|
TArgs = void,
|
|
401
358
|
TResult = unknown
|
|
402
|
-
>(locator: string): Promise<
|
|
359
|
+
>(locator: string): Promise<ResolvedResource4<TArgs, TResult>>;
|
|
403
360
|
exists(locator: string): Promise<boolean>;
|
|
404
361
|
delete(locator: string): Promise<void>;
|
|
405
|
-
search(options?: SearchOptions): Promise<
|
|
362
|
+
search(options?: SearchOptions): Promise<RXL4[]>;
|
|
406
363
|
}
|
|
407
|
-
import { RXR as
|
|
408
|
-
import { ResolvedResource as
|
|
364
|
+
import { RXR as RXR5 } from "@resourcexjs/core";
|
|
365
|
+
import { ResolvedResource as ResolvedResource5 } from "@resourcexjs/type";
|
|
409
366
|
/**
|
|
410
367
|
* Domain validation middleware.
|
|
411
368
|
* Ensures all resources from this registry match the trusted domain.
|
|
@@ -420,14 +377,14 @@ declare class DomainValidation extends RegistryMiddleware {
|
|
|
420
377
|
/**
|
|
421
378
|
* Get resource and validate domain.
|
|
422
379
|
*/
|
|
423
|
-
get(locator: string): Promise<
|
|
380
|
+
get(locator: string): Promise<RXR5>;
|
|
424
381
|
/**
|
|
425
382
|
* Resolve resource and validate domain.
|
|
426
383
|
*/
|
|
427
384
|
resolve<
|
|
428
385
|
TArgs = void,
|
|
429
386
|
TResult = unknown
|
|
430
|
-
>(locator: string): Promise<
|
|
387
|
+
>(locator: string): Promise<ResolvedResource5<TArgs, TResult>>;
|
|
431
388
|
}
|
|
432
389
|
/**
|
|
433
390
|
* Factory function to create domain validation middleware.
|
|
@@ -436,4 +393,4 @@ declare class DomainValidation extends RegistryMiddleware {
|
|
|
436
393
|
* const registry = withDomainValidation(gitRegistry, "deepractice.ai");
|
|
437
394
|
*/
|
|
438
395
|
declare function withDomainValidation(registry: Registry, trustedDomain: string): Registry;
|
|
439
|
-
export { withDomainValidation,
|
|
396
|
+
export { withDomainValidation, discoverRegistry, createRegistry, WellKnownResponse, UrlRegistryConfig, SearchOptions, RemoteRegistryConfig, RegistryMiddleware, RegistryError, RegistryConfig, Registry, PullOptions, PublishTarget, PublishOptions, LocalRegistryConfig, LocalRegistry, DomainValidation, DiscoveryResult };
|