@resourcexjs/registry 2.0.0 → 2.1.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.d.ts CHANGED
@@ -188,20 +188,25 @@ import { ResourceXError } from "@resourcexjs/core";
188
188
  * Registry-specific error.
189
189
  */
190
190
  declare class RegistryError extends ResourceXError {
191
- constructor(message: string);
191
+ constructor(message: string, options?: ErrorOptions);
192
192
  }
193
193
  import { RXR as RXR2, RXL as RXL2 } from "@resourcexjs/core";
194
194
  import { ResourceType as ResourceType2, ResolvedResource as ResolvedResource2 } from "@resourcexjs/type";
195
195
  /**
196
196
  * Local filesystem-based registry implementation.
197
- * Uses Node.js fs module directly for storage operations.
197
+ * Uses ARP file transport for I/O operations.
198
198
  */
199
199
  declare class LocalRegistry implements Registry {
200
200
  private readonly basePath;
201
201
  private readonly typeHandler;
202
+ private readonly arp;
202
203
  constructor(config?: LocalRegistryConfig);
203
204
  supportType(type: ResourceType2): void;
204
205
  /**
206
+ * Create ARP URL for a file path.
207
+ */
208
+ private toArpUrl;
209
+ /**
205
210
  * Build filesystem path for a resource.
206
211
  *
207
212
  * Storage structure:
@@ -241,10 +246,6 @@ declare class LocalRegistry implements Registry {
241
246
  delete(locator: string): Promise<void>;
242
247
  search(options?: SearchOptions): Promise<RXL2[]>;
243
248
  /**
244
- * Recursively list all files in a directory.
245
- */
246
- private listRecursive;
247
- /**
248
249
  * Parse a local entry path to RXL.
249
250
  * Entry format: {name}.{type}/{version}/manifest.json
250
251
  */
@@ -290,36 +291,35 @@ declare class RemoteRegistry implements Registry {
290
291
  declare function discoverRegistry(domain: string): Promise<DiscoveryResult>;
291
292
  import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
292
293
  import { ResourceType as ResourceType4, ResolvedResource as ResolvedResource4 } from "@resourcexjs/type";
293
- /**
294
- * Git-based registry implementation.
295
- * Clones a git repository and reads resources from it.
296
- */
297
294
  declare class GitRegistry implements Registry {
298
295
  private readonly url;
299
296
  private readonly ref;
300
297
  private readonly basePath;
301
298
  private readonly cacheDir;
302
299
  private readonly typeHandler;
303
- private readonly trustedDomain?;
300
+ private readonly arp;
301
+ private readonly isLocal;
304
302
  constructor(config: GitRegistryConfig);
305
303
  /**
306
- * Check if URL is a remote git URL (not local path).
307
- */
308
- private isRemoteUrl;
309
- /**
310
304
  * Build cache directory name from git URL.
311
305
  * git@github.com:Deepractice/Registry.git → github.com-Deepractice-Registry
312
306
  */
313
307
  private buildCacheDir;
314
308
  supportType(type: ResourceType4): void;
315
309
  /**
310
+ * Create ARP URL for a file path.
311
+ */
312
+ private toArpUrl;
313
+ /**
316
314
  * Ensure the repository is cloned and up to date.
315
+ * For local paths, just verify the .git directory exists.
316
+ * For remote URLs, includes retry logic for transient network errors.
317
317
  */
318
318
  private ensureCloned;
319
319
  /**
320
- * Execute git command in the cache directory.
320
+ * Get the default branch name (main or master).
321
321
  */
322
- private gitExec;
322
+ private getDefaultBranch;
323
323
  /**
324
324
  * Build filesystem path for a resource in the cloned repo.
325
325
  * Path structure: {cacheDir}/{basePath}/{domain}/{path}/{name}.{type}/{version}
@@ -332,7 +332,6 @@ declare class GitRegistry implements Registry {
332
332
  >(locator: string): Promise<ResolvedResource4<TArgs, TResult>>;
333
333
  exists(locator: string): Promise<boolean>;
334
334
  search(options?: SearchOptions): Promise<RXL4[]>;
335
- private listRecursive;
336
335
  private parseEntryToRXL;
337
336
  pull(_locator: string, _options?: PullOptions): Promise<void>;
338
337
  publish(_resource: RXR4, _options: PublishOptions): Promise<void>;
@@ -342,6 +341,9 @@ declare class GitRegistry implements Registry {
342
341
  /**
343
342
  * Create a registry instance.
344
343
  *
344
+ * When a `domain` is provided in GitRegistryConfig, the registry is automatically
345
+ * wrapped with DomainValidation middleware for security.
346
+ *
345
347
  * @param config - Registry configuration
346
348
  * - No config or LocalRegistryConfig: Creates LocalRegistry (filesystem-based)
347
349
  * - RemoteRegistryConfig: Creates RemoteRegistry (HTTP-based)
@@ -355,11 +357,67 @@ declare class GitRegistry implements Registry {
355
357
  * // Remote registry
356
358
  * const registry3 = createRegistry({ endpoint: "https://registry.deepractice.ai/v1" });
357
359
  *
358
- * // Git registry
360
+ * // Git registry (requires domain for remote URLs)
359
361
  * const registry4 = createRegistry({
360
362
  * type: "git",
361
363
  * url: "git@github.com:Deepractice/Registry.git",
364
+ * domain: "deepractice.ai", // Auto-wrapped with DomainValidation
362
365
  * });
363
366
  */
364
367
  declare function createRegistry(config?: RegistryConfig): Registry;
365
- export { isRemoteConfig, isGitConfig, discoverRegistry, createRegistry, WellKnownResponse, SearchOptions, RemoteRegistryConfig, RemoteRegistry, RegistryError, RegistryConfig, Registry, PullOptions, PublishTarget, PublishOptions, LocalRegistryConfig, LocalRegistry, GitRegistryConfig, GitRegistry, DiscoveryResult };
368
+ import { RXR as RXR5, RXL as RXL5 } from "@resourcexjs/core";
369
+ import { ResourceType as ResourceType5, ResolvedResource as ResolvedResource5 } from "@resourcexjs/type";
370
+ /**
371
+ * Base class for Registry middleware.
372
+ * Delegates all operations to the inner registry.
373
+ * Override specific methods to add custom behavior.
374
+ */
375
+ declare abstract class RegistryMiddleware implements Registry {
376
+ protected readonly inner: Registry;
377
+ constructor(inner: Registry);
378
+ supportType(type: ResourceType5): void;
379
+ pull(locator: string, options?: PullOptions): Promise<void>;
380
+ publish(resource: RXR5, options: PublishOptions): Promise<void>;
381
+ link(resource: RXR5): Promise<void>;
382
+ get(locator: string): Promise<RXR5>;
383
+ resolve<
384
+ TArgs = void,
385
+ TResult = unknown
386
+ >(locator: string): Promise<ResolvedResource5<TArgs, TResult>>;
387
+ exists(locator: string): Promise<boolean>;
388
+ delete(locator: string): Promise<void>;
389
+ search(options?: SearchOptions): Promise<RXL5[]>;
390
+ }
391
+ import { RXR as RXR6 } from "@resourcexjs/core";
392
+ import { ResolvedResource as ResolvedResource6 } from "@resourcexjs/type";
393
+ /**
394
+ * Domain validation middleware.
395
+ * Ensures all resources from this registry match the trusted domain.
396
+ */
397
+ declare class DomainValidation extends RegistryMiddleware {
398
+ private readonly trustedDomain;
399
+ constructor(inner: Registry, trustedDomain: string);
400
+ /**
401
+ * Validate that manifest domain matches trusted domain.
402
+ */
403
+ private validateDomain;
404
+ /**
405
+ * Get resource and validate domain.
406
+ */
407
+ get(locator: string): Promise<RXR6>;
408
+ /**
409
+ * Resolve resource and validate domain.
410
+ */
411
+ resolve<
412
+ TArgs = void,
413
+ TResult = unknown
414
+ >(locator: string): Promise<ResolvedResource6<TArgs, TResult>>;
415
+ }
416
+ /**
417
+ * Factory function to create domain validation middleware.
418
+ *
419
+ * @example
420
+ * const registry = withDomainValidation(gitRegistry, "deepractice.ai");
421
+ */
422
+ declare function withDomainValidation(registry: Registry, trustedDomain: string): Registry;
423
+ export { withDomainValidation, isRemoteConfig, isGitConfig, discoverRegistry, createRegistry, WellKnownResponse, SearchOptions, RemoteRegistryConfig, RemoteRegistry, RegistryMiddleware, RegistryError, RegistryConfig, Registry, PullOptions, PublishTarget, PublishOptions, LocalRegistryConfig, LocalRegistry, GitRegistryConfig, GitRegistry, DomainValidation, DiscoveryResult };