@resourcexjs/core 2.18.0 → 2.19.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 +26 -143
- package/dist/index.js +105 -363
- package/dist/index.js.map +13 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -434,52 +434,6 @@ interface SourceLoader {
|
|
|
434
434
|
load(source: string): Promise<RXS>;
|
|
435
435
|
}
|
|
436
436
|
/**
|
|
437
|
-
* Default ResourceLoader implementation for loading resources from folders.
|
|
438
|
-
*
|
|
439
|
-
* Expected folder structure:
|
|
440
|
-
* ```
|
|
441
|
-
* folder/
|
|
442
|
-
* ├── resource.json # Resource metadata (required)
|
|
443
|
-
* └── ... # Any other files/directories (content)
|
|
444
|
-
* ```
|
|
445
|
-
*
|
|
446
|
-
* resource.json format:
|
|
447
|
-
* ```json
|
|
448
|
-
* {
|
|
449
|
-
* "name": "resource-name", // required
|
|
450
|
-
* "type": "text", // required
|
|
451
|
-
* "tag": "1.0.0", // optional, defaults to "latest"
|
|
452
|
-
* "registry": "localhost", // optional
|
|
453
|
-
* "path": "optional/path" // optional
|
|
454
|
-
* }
|
|
455
|
-
* ```
|
|
456
|
-
*
|
|
457
|
-
* All files in the folder (except resource.json) will be packaged into the RXA.
|
|
458
|
-
*/
|
|
459
|
-
declare class FolderLoader implements ResourceLoader {
|
|
460
|
-
canLoad(source: string): Promise<boolean>;
|
|
461
|
-
load(folderPath: string): Promise<RXR>;
|
|
462
|
-
/**
|
|
463
|
-
* Recursively read all files in a folder, returning a map of relative paths to buffers.
|
|
464
|
-
*/
|
|
465
|
-
private readFolderFiles;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* FolderSourceLoader - Loads raw files from a folder into RXS.
|
|
469
|
-
*
|
|
470
|
-
* Unlike FolderLoader (which requires resource.json and produces RXR),
|
|
471
|
-
* FolderSourceLoader loads ALL files from a folder without interpreting them.
|
|
472
|
-
* Type detection happens downstream via TypeDetectorChain.
|
|
473
|
-
*/
|
|
474
|
-
declare class FolderSourceLoader implements SourceLoader {
|
|
475
|
-
canLoad(source: string): Promise<boolean>;
|
|
476
|
-
load(source: string): Promise<RXS>;
|
|
477
|
-
/**
|
|
478
|
-
* Recursively read all files in a folder.
|
|
479
|
-
*/
|
|
480
|
-
private readFolderFiles;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
437
|
* GitHubSourceLoader - Loads raw files from a GitHub directory into RXS.
|
|
484
438
|
*
|
|
485
439
|
* Fetches files via the GitHub Contents API (no authentication required
|
|
@@ -502,60 +456,50 @@ declare class GitHubSourceLoader implements SourceLoader {
|
|
|
502
456
|
*/
|
|
503
457
|
interface LoadResourceConfig {
|
|
504
458
|
/**
|
|
505
|
-
*
|
|
459
|
+
* Loader to use. Required — environment-specific loaders are provided by the provider.
|
|
460
|
+
* For Node.js/Bun: use FolderLoader from @resourcexjs/node-provider.
|
|
506
461
|
*/
|
|
507
|
-
loader
|
|
462
|
+
loader: ResourceLoader;
|
|
508
463
|
}
|
|
509
464
|
/**
|
|
510
465
|
* Load a resource from a given source using a ResourceLoader.
|
|
511
466
|
*
|
|
512
|
-
* By default, uses FolderLoader which expects:
|
|
513
|
-
* ```
|
|
514
|
-
* folder/
|
|
515
|
-
* ├── resource.json # Resource metadata
|
|
516
|
-
* └── content # Resource content
|
|
517
|
-
* ```
|
|
518
|
-
*
|
|
519
|
-
* You can provide a custom loader via config.loader to support other formats
|
|
520
|
-
* (e.g., zip, tar.gz, URLs).
|
|
521
|
-
*
|
|
522
467
|
* @param source - Source path or identifier
|
|
523
|
-
* @param config -
|
|
468
|
+
* @param config - Configuration with loader
|
|
524
469
|
* @returns Complete RXR object ready for registry.link()
|
|
525
470
|
* @throws ResourceXError if the source cannot be loaded
|
|
526
471
|
*
|
|
527
472
|
* @example
|
|
528
473
|
* ```typescript
|
|
529
|
-
*
|
|
530
|
-
* const rxr = await loadResource("./my-resource");
|
|
531
|
-
* await registry.link(rxr);
|
|
474
|
+
* import { FolderLoader } from "@resourcexjs/node-provider";
|
|
532
475
|
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
* loader: new ZipLoader()
|
|
476
|
+
* const rxr = await loadResource("./my-resource", {
|
|
477
|
+
* loader: new FolderLoader()
|
|
536
478
|
* });
|
|
537
479
|
* ```
|
|
538
480
|
*/
|
|
539
|
-
declare function loadResource(source: string, config
|
|
481
|
+
declare function loadResource(source: string, config: LoadResourceConfig): Promise<RXR>;
|
|
540
482
|
/**
|
|
541
483
|
* SourceLoaderChain - Chain of source loaders.
|
|
542
484
|
*
|
|
543
485
|
* Follows the same pattern as TypeDetectorChain:
|
|
544
|
-
* - Static create() factory with built-in loaders
|
|
486
|
+
* - Static create() factory with built-in environment-agnostic loaders
|
|
545
487
|
* - Extensible via register()
|
|
546
488
|
* - First match wins
|
|
547
489
|
*
|
|
548
|
-
*
|
|
549
|
-
* 1.
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
490
|
+
* Built-in loaders (environment-agnostic):
|
|
491
|
+
* 1. GitHubSourceLoader (GitHub URLs via fetch)
|
|
492
|
+
*
|
|
493
|
+
* Provider-registered loaders (environment-specific):
|
|
494
|
+
* - FolderSourceLoader (local directories) — via node-provider
|
|
495
|
+
* - NpmSourceLoader (npm: prefixed packages) — via node-provider
|
|
553
496
|
*/
|
|
554
497
|
declare class SourceLoaderChain {
|
|
555
498
|
private readonly loaders;
|
|
556
499
|
private constructor();
|
|
557
500
|
/**
|
|
558
|
-
* Create a new SourceLoaderChain with built-in loaders.
|
|
501
|
+
* Create a new SourceLoaderChain with built-in environment-agnostic loaders.
|
|
502
|
+
* Environment-specific loaders (folder, npm) are registered by the provider.
|
|
559
503
|
*/
|
|
560
504
|
static create(): SourceLoaderChain;
|
|
561
505
|
/**
|
|
@@ -794,9 +738,10 @@ interface ResourceXProvider {
|
|
|
794
738
|
*/
|
|
795
739
|
createStores(config: ProviderConfig): ProviderStores;
|
|
796
740
|
/**
|
|
797
|
-
* Create source
|
|
741
|
+
* Create source loaders for auto-detection pipeline (optional).
|
|
742
|
+
* Returns environment-specific loaders to register on the chain.
|
|
798
743
|
*/
|
|
799
|
-
|
|
744
|
+
createSourceLoaders?(config: ProviderConfig): SourceLoader[];
|
|
800
745
|
/**
|
|
801
746
|
* Resolve platform-specific defaults (optional).
|
|
802
747
|
*
|
|
@@ -936,59 +881,6 @@ declare class CASRegistry implements Registry {
|
|
|
936
881
|
putBlob(data: Buffer): Promise<string>;
|
|
937
882
|
}
|
|
938
883
|
/**
|
|
939
|
-
* LinkedRegistry - Registry for development symlinks.
|
|
940
|
-
*
|
|
941
|
-
* Creates symlinks to development directories so changes are reflected immediately.
|
|
942
|
-
* Unlike HostedRegistry/MirrorRegistry, it doesn't use Storage layer directly.
|
|
943
|
-
* Instead, it manages symlinks in a base directory.
|
|
944
|
-
*
|
|
945
|
-
* Storage structure:
|
|
946
|
-
* {basePath}/{registry}/{path}/{name}/{tag} → /path/to/dev/folder
|
|
947
|
-
*/
|
|
948
|
-
declare class LinkedRegistry implements Registry {
|
|
949
|
-
private readonly basePath;
|
|
950
|
-
constructor(basePath: string);
|
|
951
|
-
/**
|
|
952
|
-
* Build symlink path for a resource.
|
|
953
|
-
*/
|
|
954
|
-
private buildLinkPath;
|
|
955
|
-
/**
|
|
956
|
-
* Check if a path is a symlink.
|
|
957
|
-
*/
|
|
958
|
-
private isSymlink;
|
|
959
|
-
get(rxi: RXI): Promise<RXR>;
|
|
960
|
-
/**
|
|
961
|
-
* Put is not typically used for LinkedRegistry.
|
|
962
|
-
* Use link() instead to create symlinks.
|
|
963
|
-
*/
|
|
964
|
-
put(_rxr: RXR): Promise<RXM>;
|
|
965
|
-
has(rxi: RXI): Promise<boolean>;
|
|
966
|
-
remove(rxi: RXI): Promise<void>;
|
|
967
|
-
list(options?: SearchOptions): Promise<RXI[]>;
|
|
968
|
-
/**
|
|
969
|
-
* Link a development directory.
|
|
970
|
-
* Creates a symlink so changes are reflected immediately.
|
|
971
|
-
*
|
|
972
|
-
* @param devPath - Path to development directory (must contain resource.json)
|
|
973
|
-
* @returns The RXI of the linked resource
|
|
974
|
-
*/
|
|
975
|
-
link(devPath: string): Promise<RXI>;
|
|
976
|
-
/**
|
|
977
|
-
* Unlink a development directory.
|
|
978
|
-
* Alias for remove().
|
|
979
|
-
*/
|
|
980
|
-
unlink(rxi: RXI): Promise<void>;
|
|
981
|
-
/**
|
|
982
|
-
* Recursively scan for symlinks.
|
|
983
|
-
*/
|
|
984
|
-
private scanSymlinks;
|
|
985
|
-
/**
|
|
986
|
-
* Parse relative path to RXI.
|
|
987
|
-
* Path format: {registry}/{path}/{name}/{tag}
|
|
988
|
-
*/
|
|
989
|
-
private parsePathToRXI;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
884
|
* Base class for Registry middleware.
|
|
993
885
|
* Delegates all operations to the inner registry.
|
|
994
886
|
* Override specific methods to add custom behavior.
|
|
@@ -1028,10 +920,14 @@ declare function withRegistryValidation(registry: Registry, trustedRegistry: str
|
|
|
1028
920
|
declare const DomainValidation: typeof RegistryValidation;
|
|
1029
921
|
declare const withDomainValidation: typeof withRegistryValidation;
|
|
1030
922
|
/**
|
|
923
|
+
* Digest utilities for Content-Addressable Storage.
|
|
924
|
+
* Uses Web Crypto API for environment-agnostic SHA-256 hashing.
|
|
925
|
+
*/
|
|
926
|
+
/**
|
|
1031
927
|
* Compute SHA-256 digest of data.
|
|
1032
928
|
* Returns string in format "sha256:{hex}"
|
|
1033
929
|
*/
|
|
1034
|
-
declare function computeDigest(data: Buffer): string
|
|
930
|
+
declare function computeDigest(data: Buffer): Promise<string>;
|
|
1035
931
|
/**
|
|
1036
932
|
* Validate digest format.
|
|
1037
933
|
*/
|
|
@@ -1255,19 +1151,6 @@ declare const prototypeType: BundledType;
|
|
|
1255
1151
|
*/
|
|
1256
1152
|
declare const builtinTypes: BundledType[];
|
|
1257
1153
|
/**
|
|
1258
|
-
* Bundle a resource type from a source file.
|
|
1259
|
-
*
|
|
1260
|
-
* @param sourcePath - Path to the .type.ts file
|
|
1261
|
-
* @param basePath - Base path for resolving relative paths (defaults to cwd)
|
|
1262
|
-
* @returns BundledType ready for registry
|
|
1263
|
-
*
|
|
1264
|
-
* @example
|
|
1265
|
-
* ```typescript
|
|
1266
|
-
* const promptType = await bundleResourceType("./prompt.type.ts");
|
|
1267
|
-
* ```
|
|
1268
|
-
*/
|
|
1269
|
-
declare function bundleResourceType(sourcePath: string, basePath?: string): Promise<BundledType>;
|
|
1270
|
-
/**
|
|
1271
1154
|
* Resource type related error.
|
|
1272
1155
|
*/
|
|
1273
1156
|
declare class ResourceTypeError extends ResourceXError {
|
|
@@ -1323,4 +1206,4 @@ declare class TypeHandlerChain {
|
|
|
1323
1206
|
*/
|
|
1324
1207
|
clear(): void;
|
|
1325
1208
|
}
|
|
1326
|
-
export { wrap, withDomainValidation, textType, skillType, resource, resolveSource, prototypeType, parse, manifest, locate, loadResource, jsonType, isValidDigest, generateDefinition, format, extract, discoverRegistry, define, computeDigest,
|
|
1209
|
+
export { wrap, withDomainValidation, textType, skillType, resource, resolveSource, prototypeType, parse, manifest, locate, loadResource, jsonType, isValidDigest, generateDefinition, format, extract, discoverRegistry, define, computeDigest, builtinTypes, binaryType, archive, WellKnownResponse, TypeHandlerChain, TypeDetectorChain, TypeDetector, TypeDetectionResult, StoredRXM, SourceLoaderChain, SourceLoader, SkillDetector, SearchOptions, ResourceXProvider, ResourceXError, ResourceTypeError, ResourceType, ResourceResolver, ResourceLoader, ResourceJsonDetector, ResolvedResource, ResolveSourceConfig, ResolveContext, RegistryMiddleware, RegistryError, RegistryEntry, Registry, RXS, RXR, RXMStore, RXMSource, RXMSearchOptions, RXMDefinition, RXMArchive, RXM, RXL, RXI, RXD, RXAStore, RXA, ProviderStores, ProviderDefaults, ProviderConfig, PrototypeDetector, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, JSONSchemaProperty, JSONSchema, IsolatorType, GitHubSourceLoader, FileTree, FileEntry, DomainValidation, DiscoveryResult, DefinitionError, CustomExecutor, ContentError, CASRegistry, BundledType };
|