@resourcexjs/registry 2.0.0 → 2.1.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 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
  */
@@ -300,23 +301,27 @@ declare class GitRegistry implements Registry {
300
301
  private readonly basePath;
301
302
  private readonly cacheDir;
302
303
  private readonly typeHandler;
303
- private readonly trustedDomain?;
304
+ private readonly arp;
304
305
  constructor(config: GitRegistryConfig);
305
306
  /**
306
- * Check if URL is a remote git URL (not local path).
307
- */
308
- private isRemoteUrl;
309
- /**
310
307
  * Build cache directory name from git URL.
311
308
  * git@github.com:Deepractice/Registry.git → github.com-Deepractice-Registry
312
309
  */
313
310
  private buildCacheDir;
314
311
  supportType(type: ResourceType4): void;
315
312
  /**
313
+ * Create ARP URL for a file path.
314
+ */
315
+ private toArpUrl;
316
+ /**
316
317
  * Ensure the repository is cloned and up to date.
317
318
  */
318
319
  private ensureCloned;
319
320
  /**
321
+ * Get the default branch name (main or master).
322
+ */
323
+ private getDefaultBranch;
324
+ /**
320
325
  * Execute git command in the cache directory.
321
326
  */
322
327
  private gitExec;
@@ -332,7 +337,6 @@ declare class GitRegistry implements Registry {
332
337
  >(locator: string): Promise<ResolvedResource4<TArgs, TResult>>;
333
338
  exists(locator: string): Promise<boolean>;
334
339
  search(options?: SearchOptions): Promise<RXL4[]>;
335
- private listRecursive;
336
340
  private parseEntryToRXL;
337
341
  pull(_locator: string, _options?: PullOptions): Promise<void>;
338
342
  publish(_resource: RXR4, _options: PublishOptions): Promise<void>;
@@ -342,6 +346,9 @@ declare class GitRegistry implements Registry {
342
346
  /**
343
347
  * Create a registry instance.
344
348
  *
349
+ * When a `domain` is provided in GitRegistryConfig, the registry is automatically
350
+ * wrapped with DomainValidation middleware for security.
351
+ *
345
352
  * @param config - Registry configuration
346
353
  * - No config or LocalRegistryConfig: Creates LocalRegistry (filesystem-based)
347
354
  * - RemoteRegistryConfig: Creates RemoteRegistry (HTTP-based)
@@ -355,11 +362,67 @@ declare class GitRegistry implements Registry {
355
362
  * // Remote registry
356
363
  * const registry3 = createRegistry({ endpoint: "https://registry.deepractice.ai/v1" });
357
364
  *
358
- * // Git registry
365
+ * // Git registry (requires domain for remote URLs)
359
366
  * const registry4 = createRegistry({
360
367
  * type: "git",
361
368
  * url: "git@github.com:Deepractice/Registry.git",
369
+ * domain: "deepractice.ai", // Auto-wrapped with DomainValidation
362
370
  * });
363
371
  */
364
372
  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 };
373
+ import { RXR as RXR5, RXL as RXL5 } from "@resourcexjs/core";
374
+ import { ResourceType as ResourceType5, ResolvedResource as ResolvedResource5 } from "@resourcexjs/type";
375
+ /**
376
+ * Base class for Registry middleware.
377
+ * Delegates all operations to the inner registry.
378
+ * Override specific methods to add custom behavior.
379
+ */
380
+ declare abstract class RegistryMiddleware implements Registry {
381
+ protected readonly inner: Registry;
382
+ constructor(inner: Registry);
383
+ supportType(type: ResourceType5): void;
384
+ pull(locator: string, options?: PullOptions): Promise<void>;
385
+ publish(resource: RXR5, options: PublishOptions): Promise<void>;
386
+ link(resource: RXR5): Promise<void>;
387
+ get(locator: string): Promise<RXR5>;
388
+ resolve<
389
+ TArgs = void,
390
+ TResult = unknown
391
+ >(locator: string): Promise<ResolvedResource5<TArgs, TResult>>;
392
+ exists(locator: string): Promise<boolean>;
393
+ delete(locator: string): Promise<void>;
394
+ search(options?: SearchOptions): Promise<RXL5[]>;
395
+ }
396
+ import { RXR as RXR6 } from "@resourcexjs/core";
397
+ import { ResolvedResource as ResolvedResource6 } from "@resourcexjs/type";
398
+ /**
399
+ * Domain validation middleware.
400
+ * Ensures all resources from this registry match the trusted domain.
401
+ */
402
+ declare class DomainValidation extends RegistryMiddleware {
403
+ private readonly trustedDomain;
404
+ constructor(inner: Registry, trustedDomain: string);
405
+ /**
406
+ * Validate that manifest domain matches trusted domain.
407
+ */
408
+ private validateDomain;
409
+ /**
410
+ * Get resource and validate domain.
411
+ */
412
+ get(locator: string): Promise<RXR6>;
413
+ /**
414
+ * Resolve resource and validate domain.
415
+ */
416
+ resolve<
417
+ TArgs = void,
418
+ TResult = unknown
419
+ >(locator: string): Promise<ResolvedResource6<TArgs, TResult>>;
420
+ }
421
+ /**
422
+ * Factory function to create domain validation middleware.
423
+ *
424
+ * @example
425
+ * const registry = withDomainValidation(gitRegistry, "deepractice.ai");
426
+ */
427
+ declare function withDomainValidation(registry: Registry, trustedDomain: string): Registry;
428
+ export { withDomainValidation, isRemoteConfig, isGitConfig, discoverRegistry, createRegistry, WellKnownResponse, SearchOptions, RemoteRegistryConfig, RemoteRegistry, RegistryMiddleware, RegistryError, RegistryConfig, Registry, PullOptions, PublishTarget, PublishOptions, LocalRegistryConfig, LocalRegistry, GitRegistryConfig, GitRegistry, DomainValidation, DiscoveryResult };