resourcexjs 2.9.0 → 2.11.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 +12 -11
- package/dist/arp.js +2 -2
- package/dist/arp.js.map +2 -2
- package/dist/index.d.ts +19 -6
- package/dist/index.js +83 -74
- package/dist/index.js.map +5 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -34,14 +34,15 @@ console.log(content);
|
|
|
34
34
|
|
|
35
35
|
## Core Concepts
|
|
36
36
|
|
|
37
|
-
ResourceX uses
|
|
37
|
+
ResourceX uses five core primitives:
|
|
38
38
|
|
|
39
39
|
| Primitive | Description |
|
|
40
40
|
| --------- | --------------------------------------------------- |
|
|
41
|
-
| **
|
|
41
|
+
| **RXI** | Resource Identifier - structured `{ registry?, path?, name, tag }` |
|
|
42
|
+
| **RXL** | Resource Locator - unified locator string (RXI string, path, or URL) |
|
|
42
43
|
| **RXM** | Resource Manifest - metadata (name, type, version) |
|
|
43
44
|
| **RXA** | Resource Archive - content container (tar.gz) |
|
|
44
|
-
| **RXR** | Resource - complete object (
|
|
45
|
+
| **RXR** | Resource - complete object (RXI + RXM + RXA) |
|
|
45
46
|
|
|
46
47
|
### Locator Format
|
|
47
48
|
|
|
@@ -189,7 +190,7 @@ await rx.remove("hello:1.0.0");
|
|
|
189
190
|
|
|
190
191
|
#### rx.resolve(locator)
|
|
191
192
|
|
|
192
|
-
Load and prepare a resource for execution from RXL locator.
|
|
193
|
+
Load and prepare a resource for execution from an RXL locator string.
|
|
193
194
|
|
|
194
195
|
```typescript
|
|
195
196
|
const executable = await rx.resolve<string>("hello:1.0.0");
|
|
@@ -305,13 +306,13 @@ For advanced use cases, you can work with core primitives directly:
|
|
|
305
306
|
```typescript
|
|
306
307
|
import { parse, format, manifest, archive, resource, extract, wrap } from "resourcexjs";
|
|
307
308
|
|
|
308
|
-
// Parse locator string to
|
|
309
|
-
const
|
|
310
|
-
console.log(
|
|
311
|
-
console.log(
|
|
309
|
+
// Parse locator string to RXI
|
|
310
|
+
const rxi = parse("hello:1.0.0");
|
|
311
|
+
console.log(rxi.name); // "hello"
|
|
312
|
+
console.log(rxi.tag); // "1.0.0"
|
|
312
313
|
|
|
313
|
-
// Format
|
|
314
|
-
const str = format(
|
|
314
|
+
// Format RXI back to string
|
|
315
|
+
const str = format(rxi); // "hello:1.0.0"
|
|
315
316
|
|
|
316
317
|
// Create manifest from definition
|
|
317
318
|
const rxm = manifest({
|
|
@@ -447,7 +448,7 @@ Error hierarchy:
|
|
|
447
448
|
|
|
448
449
|
```
|
|
449
450
|
ResourceXError (base)
|
|
450
|
-
├── LocatorError #
|
|
451
|
+
├── LocatorError # RXI parsing errors
|
|
451
452
|
├── ManifestError # RXM validation errors
|
|
452
453
|
├── ContentError # RXA operations errors
|
|
453
454
|
└── DefinitionError # RXD validation errors
|
package/dist/arp.js
CHANGED
|
@@ -526,7 +526,7 @@ class ARP {
|
|
|
526
526
|
function createARP(config) {
|
|
527
527
|
return new ARP(config);
|
|
528
528
|
}
|
|
529
|
-
var VERSION = "2.
|
|
529
|
+
var VERSION = "2.11.0";
|
|
530
530
|
export {
|
|
531
531
|
textSemantic,
|
|
532
532
|
httpsTransport,
|
|
@@ -546,4 +546,4 @@ export {
|
|
|
546
546
|
ARP
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
-
//# debugId=
|
|
549
|
+
//# debugId=6F64DDE965E4BA0D64756E2164756E21
|
package/dist/arp.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../arp/dist/index.js"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// src/errors.ts\nclass ARPError extends Error {\n constructor(message, options) {\n super(message, options);\n this.name = \"ARPError\";\n }\n}\n\nclass ParseError extends ARPError {\n url;\n constructor(message, url) {\n super(message);\n this.url = url;\n this.name = \"ParseError\";\n }\n}\n\nclass TransportError extends ARPError {\n transport;\n constructor(message, transport, options) {\n super(message, options);\n this.transport = transport;\n this.name = \"TransportError\";\n }\n}\n\nclass SemanticError extends ARPError {\n semantic;\n constructor(message, semantic, options) {\n super(message, options);\n this.semantic = semantic;\n this.name = \"SemanticError\";\n }\n}\n\n// src/ARL.ts\nclass ARL {\n semantic;\n transport;\n location;\n resolver;\n constructor(semantic, transport, location, resolver) {\n this.semantic = semantic;\n this.transport = transport;\n this.location = location;\n this.resolver = resolver;\n }\n createContext(params) {\n return {\n url: this.toString(),\n semantic: this.semantic,\n transport: this.transport,\n location: this.location,\n timestamp: new Date,\n params\n };\n }\n async resolve(params) {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext(params);\n return semantic.resolve(transport, this.location, context);\n }\n async deposit(data, params) {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext(params);\n if (!semantic.deposit) {\n throw new SemanticError(`Semantic \"${semantic.name}\" does not support deposit operation`, this.semantic);\n }\n await semantic.deposit(transport, this.location, data, context);\n }\n async exists() {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext();\n if (semantic.exists) {\n return semantic.exists(transport, this.location, context);\n }\n return transport.exists(this.location);\n }\n async delete() {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext();\n if (semantic.delete) {\n return semantic.delete(transport, this.location, context);\n }\n await transport.delete(this.location);\n }\n async list(options) {\n const transport = this.resolver.getTransportHandler(this.transport);\n if (!transport.list) {\n throw new TransportError(`Transport \"${transport.name}\" does not support list operation`, this.transport);\n }\n return transport.list(this.location, options);\n }\n async mkdir() {\n const transport = this.resolver.getTransportHandler(this.transport);\n if (!transport.mkdir) {\n throw new TransportError(`Transport \"${transport.name}\" does not support mkdir operation`, this.transport);\n }\n await transport.mkdir(this.location);\n }\n toString() {\n return `arp:${this.semantic}:${this.transport}://${this.location}`;\n }\n}\n\n// src/semantic/binary.ts\nfunction toBuffer(data) {\n if (Buffer.isBuffer(data)) {\n return data;\n }\n if (data instanceof Uint8Array) {\n return Buffer.from(data);\n }\n if (data instanceof ArrayBuffer) {\n return Buffer.from(data);\n }\n if (Array.isArray(data)) {\n return Buffer.from(data);\n }\n throw new SemanticError(`Unsupported binary input type`, \"binary\");\n}\n\nclass BinarySemanticHandler {\n name = \"binary\";\n async resolve(transport, location, context) {\n const result = await transport.get(location, context.params);\n const meta = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: result.metadata?.size ?? result.content.length,\n resolvedAt: context.timestamp.toISOString(),\n type: result.metadata?.type\n };\n return {\n type: \"binary\",\n content: result.content,\n meta\n };\n }\n async deposit(transport, location, data, context) {\n const buffer = toBuffer(data);\n try {\n await transport.set(location, buffer, context.params);\n } catch (error) {\n throw new SemanticError(`Failed to deposit binary to \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n async exists(transport, location, _context) {\n return transport.exists(location);\n }\n async delete(transport, location, _context) {\n try {\n await transport.delete(location);\n } catch (error) {\n throw new SemanticError(`Failed to delete \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n}\nvar binarySemantic = new BinarySemanticHandler;\n// src/semantic/text.ts\nclass TextSemanticHandler {\n name = \"text\";\n async resolve(transport, location, context) {\n const result = await transport.get(location, context.params);\n if (result.metadata?.type === \"directory\") {\n const meta2 = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: result.content.length,\n encoding: \"utf-8\",\n mimeType: \"application/json\",\n resolvedAt: context.timestamp.toISOString(),\n type: \"directory\"\n };\n return {\n type: \"text\",\n content: result.content.toString(\"utf-8\"),\n meta: meta2\n };\n }\n const text = result.content.toString(\"utf-8\");\n const meta = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: result.metadata?.size ?? result.content.length,\n encoding: \"utf-8\",\n mimeType: \"text/plain\",\n resolvedAt: context.timestamp.toISOString(),\n type: \"file\"\n };\n return {\n type: \"text\",\n content: text,\n meta\n };\n }\n async deposit(transport, location, data, context) {\n const buffer = Buffer.from(data, \"utf-8\");\n try {\n await transport.set(location, buffer, context.params);\n } catch (error) {\n throw new SemanticError(`Failed to deposit text to \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n async exists(transport, location, _context) {\n return transport.exists(location);\n }\n async delete(transport, location, _context) {\n try {\n await transport.delete(location);\n } catch (error) {\n throw new SemanticError(`Failed to delete \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n}\nvar textSemantic = new TextSemanticHandler;\n// src/transport/file.ts\nimport { access, mkdir, readdir, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nclass FileTransportHandler {\n name = \"file\";\n resolvePath(location) {\n return resolve(process.cwd(), location);\n }\n async get(location, params) {\n const filePath = this.resolvePath(location);\n try {\n const stats = await stat(filePath);\n if (stats.isDirectory()) {\n return this.getDirectory(filePath, stats, params);\n } else {\n return this.getFile(filePath, stats);\n }\n } catch (error) {\n const err = error;\n throw new TransportError(`File get error: ${err.code} - ${filePath}`, this.name, {\n cause: err\n });\n }\n }\n async getFile(filePath, stats) {\n const content = await readFile(filePath);\n return {\n content,\n metadata: {\n type: \"file\",\n size: Number(stats.size),\n modifiedAt: stats.mtime\n }\n };\n }\n async getDirectory(dirPath, stats, params) {\n const recursive = params?.recursive === \"true\";\n const pattern = params?.pattern;\n let entries;\n if (recursive) {\n entries = await this.listRecursive(dirPath, dirPath);\n } else {\n entries = await readdir(dirPath);\n }\n if (pattern) {\n entries = this.filterByPattern(entries, pattern);\n }\n const content = Buffer.from(JSON.stringify(entries));\n return {\n content,\n metadata: {\n type: \"directory\",\n modifiedAt: stats.mtime\n }\n };\n }\n async listRecursive(basePath, currentPath) {\n const entries = await readdir(currentPath, { withFileTypes: true });\n const results = [];\n for (const entry of entries) {\n const fullPath = join(currentPath, entry.name);\n const relativePath = fullPath.substring(basePath.length + 1);\n if (entry.isDirectory()) {\n const subEntries = await this.listRecursive(basePath, fullPath);\n results.push(...subEntries);\n } else {\n results.push(relativePath);\n }\n }\n return results;\n }\n filterByPattern(entries, pattern) {\n const regexPattern = pattern.replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\").replace(/\\?/g, \".\");\n const regex = new RegExp(`^${regexPattern}$`);\n return entries.filter((entry) => {\n const filename = entry.split(\"/\").pop() || entry;\n return regex.test(filename);\n });\n }\n async set(location, content, _params) {\n const filePath = this.resolvePath(location);\n try {\n await mkdir(dirname(filePath), { recursive: true });\n await writeFile(filePath, content);\n } catch (error) {\n const err = error;\n throw new TransportError(`File set error: ${err.code} - ${filePath}`, this.name, {\n cause: err\n });\n }\n }\n async exists(location) {\n const filePath = this.resolvePath(location);\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n }\n async delete(location) {\n const filePath = this.resolvePath(location);\n try {\n await rm(filePath, { recursive: true });\n } catch (error) {\n const err = error;\n if (err.code === \"ENOENT\") {\n return;\n }\n throw new TransportError(`File delete error: ${err.code} - ${filePath}`, this.name, {\n cause: err\n });\n }\n }\n async list(location, options) {\n const dirPath = this.resolvePath(location);\n try {\n let entries;\n if (options?.recursive) {\n entries = await this.listRecursive(dirPath, dirPath);\n } else {\n entries = await readdir(dirPath);\n }\n if (options?.pattern) {\n entries = this.filterByPattern(entries, options.pattern);\n }\n return entries;\n } catch (error) {\n const err = error;\n throw new TransportError(`File list error: ${err.code} - ${dirPath}`, this.name, {\n cause: err\n });\n }\n }\n async mkdir(location) {\n const dirPath = this.resolvePath(location);\n try {\n await mkdir(dirPath, { recursive: true });\n } catch (error) {\n const err = error;\n throw new TransportError(`File mkdir error: ${err.code} - ${dirPath}`, this.name, {\n cause: err\n });\n }\n }\n}\nvar fileTransport = new FileTransportHandler;\n// src/transport/http.ts\nclass HttpTransportHandler {\n name;\n protocol;\n constructor(protocol = \"https\") {\n this.protocol = protocol;\n this.name = protocol;\n }\n async get(location, params) {\n const url = this.buildUrl(location, params);\n try {\n const response = await fetch(url);\n if (!response.ok) {\n throw new TransportError(`HTTP ${response.status}: ${response.statusText} - ${url}`, this.name);\n }\n const arrayBuffer = await response.arrayBuffer();\n const content = Buffer.from(arrayBuffer);\n const contentType = response.headers.get(\"content-type\");\n const contentLength = response.headers.get(\"content-length\");\n const lastModified = response.headers.get(\"last-modified\");\n return {\n content,\n metadata: {\n type: \"file\",\n size: contentLength ? parseInt(contentLength, 10) : content.length,\n modifiedAt: lastModified ? new Date(lastModified) : undefined,\n contentType\n }\n };\n } catch (error) {\n if (error instanceof TransportError) {\n throw error;\n }\n throw new TransportError(`Network error: ${url}`, this.name, {\n cause: error\n });\n }\n }\n buildUrl(location, params) {\n const url = new URL(`${this.protocol}://${location}`);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n url.searchParams.set(key, value);\n }\n }\n return url.toString();\n }\n async set(_location, _content, _params) {\n throw new TransportError(\"HTTP transport is read-only, set not supported\", this.name);\n }\n async exists(location) {\n const url = `${this.protocol}://${location}`;\n try {\n const response = await fetch(url, { method: \"HEAD\" });\n return response.ok;\n } catch {\n return false;\n }\n }\n async delete(_location) {\n throw new TransportError(\"HTTP transport is read-only, delete not supported\", this.name);\n }\n}\nvar httpsTransport = new HttpTransportHandler(\"https\");\nvar httpTransport = new HttpTransportHandler(\"http\");\n// src/ARP.ts\nclass ARP {\n transports;\n semantics;\n constructor(config = {}) {\n this.transports = new Map;\n this.semantics = new Map;\n const defaultTransports = [fileTransport, httpTransport, httpsTransport];\n const defaultSemantics = [textSemantic, binarySemantic];\n for (const handler of defaultTransports) {\n this.transports.set(handler.name, handler);\n }\n for (const handler of defaultSemantics) {\n this.semantics.set(handler.name, handler);\n }\n if (config.transports) {\n for (const handler of config.transports) {\n this.transports.set(handler.name, handler);\n }\n }\n if (config.semantics) {\n for (const handler of config.semantics) {\n this.semantics.set(handler.name, handler);\n }\n }\n }\n registerTransport(handler) {\n this.transports.set(handler.name, handler);\n }\n registerSemantic(handler) {\n this.semantics.set(handler.name, handler);\n }\n getTransportHandler(name) {\n const handler = this.transports.get(name);\n if (!handler) {\n throw new TransportError(`Unsupported transport type: ${name}`, name);\n }\n return handler;\n }\n getSemanticHandler(name) {\n const handler = this.semantics.get(name);\n if (!handler) {\n throw new SemanticError(`Unsupported semantic type: ${name}`, name);\n }\n return handler;\n }\n parse(url) {\n if (!url.startsWith(\"arp:\")) {\n throw new ParseError(`Invalid ARP URL: must start with \"arp:\"`, url);\n }\n const content = url.substring(4);\n const separatorIndex = content.indexOf(\"://\");\n if (separatorIndex === -1) {\n throw new ParseError(`Invalid ARP URL: missing \"://\"`, url);\n }\n const typePart = content.substring(0, separatorIndex);\n const location = content.substring(separatorIndex + 3);\n const colonIndex = typePart.indexOf(\":\");\n if (colonIndex === -1) {\n throw new ParseError(`Invalid ARP URL: must have exactly 2 types (semantic:transport)`, url);\n }\n const semantic = typePart.substring(0, colonIndex);\n const transport = typePart.substring(colonIndex + 1);\n if (!semantic) {\n throw new ParseError(`Invalid ARP URL: semantic type cannot be empty`, url);\n }\n if (!transport) {\n throw new ParseError(`Invalid ARP URL: transport type cannot be empty`, url);\n }\n if (!location) {\n throw new ParseError(`Invalid ARP URL: location cannot be empty`, url);\n }\n this.getTransportHandler(transport);\n this.getSemanticHandler(semantic);\n return new ARL(semantic, transport, location, this);\n }\n}\nfunction createARP(config) {\n return new ARP(config);\n}\n\n// src/index.ts\nvar VERSION = \"2.9.0\";\nexport {\n textSemantic,\n httpsTransport,\n httpTransport,\n fileTransport,\n createARP,\n binarySemantic,\n VERSION,\n TransportError,\n TextSemanticHandler,\n SemanticError,\n ParseError,\n HttpTransportHandler,\n FileTransportHandler,\n BinarySemanticHandler,\n ARPError,\n ARP\n};\n\n//# debugId=197EBCEB7581CB0E64756E2164756E21\n"
|
|
5
|
+
"// src/errors.ts\nclass ARPError extends Error {\n constructor(message, options) {\n super(message, options);\n this.name = \"ARPError\";\n }\n}\n\nclass ParseError extends ARPError {\n url;\n constructor(message, url) {\n super(message);\n this.url = url;\n this.name = \"ParseError\";\n }\n}\n\nclass TransportError extends ARPError {\n transport;\n constructor(message, transport, options) {\n super(message, options);\n this.transport = transport;\n this.name = \"TransportError\";\n }\n}\n\nclass SemanticError extends ARPError {\n semantic;\n constructor(message, semantic, options) {\n super(message, options);\n this.semantic = semantic;\n this.name = \"SemanticError\";\n }\n}\n\n// src/ARL.ts\nclass ARL {\n semantic;\n transport;\n location;\n resolver;\n constructor(semantic, transport, location, resolver) {\n this.semantic = semantic;\n this.transport = transport;\n this.location = location;\n this.resolver = resolver;\n }\n createContext(params) {\n return {\n url: this.toString(),\n semantic: this.semantic,\n transport: this.transport,\n location: this.location,\n timestamp: new Date,\n params\n };\n }\n async resolve(params) {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext(params);\n return semantic.resolve(transport, this.location, context);\n }\n async deposit(data, params) {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext(params);\n if (!semantic.deposit) {\n throw new SemanticError(`Semantic \"${semantic.name}\" does not support deposit operation`, this.semantic);\n }\n await semantic.deposit(transport, this.location, data, context);\n }\n async exists() {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext();\n if (semantic.exists) {\n return semantic.exists(transport, this.location, context);\n }\n return transport.exists(this.location);\n }\n async delete() {\n const transport = this.resolver.getTransportHandler(this.transport);\n const semantic = this.resolver.getSemanticHandler(this.semantic);\n const context = this.createContext();\n if (semantic.delete) {\n return semantic.delete(transport, this.location, context);\n }\n await transport.delete(this.location);\n }\n async list(options) {\n const transport = this.resolver.getTransportHandler(this.transport);\n if (!transport.list) {\n throw new TransportError(`Transport \"${transport.name}\" does not support list operation`, this.transport);\n }\n return transport.list(this.location, options);\n }\n async mkdir() {\n const transport = this.resolver.getTransportHandler(this.transport);\n if (!transport.mkdir) {\n throw new TransportError(`Transport \"${transport.name}\" does not support mkdir operation`, this.transport);\n }\n await transport.mkdir(this.location);\n }\n toString() {\n return `arp:${this.semantic}:${this.transport}://${this.location}`;\n }\n}\n\n// src/semantic/binary.ts\nfunction toBuffer(data) {\n if (Buffer.isBuffer(data)) {\n return data;\n }\n if (data instanceof Uint8Array) {\n return Buffer.from(data);\n }\n if (data instanceof ArrayBuffer) {\n return Buffer.from(data);\n }\n if (Array.isArray(data)) {\n return Buffer.from(data);\n }\n throw new SemanticError(`Unsupported binary input type`, \"binary\");\n}\n\nclass BinarySemanticHandler {\n name = \"binary\";\n async resolve(transport, location, context) {\n const result = await transport.get(location, context.params);\n const meta = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: result.metadata?.size ?? result.content.length,\n resolvedAt: context.timestamp.toISOString(),\n type: result.metadata?.type\n };\n return {\n type: \"binary\",\n content: result.content,\n meta\n };\n }\n async deposit(transport, location, data, context) {\n const buffer = toBuffer(data);\n try {\n await transport.set(location, buffer, context.params);\n } catch (error) {\n throw new SemanticError(`Failed to deposit binary to \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n async exists(transport, location, _context) {\n return transport.exists(location);\n }\n async delete(transport, location, _context) {\n try {\n await transport.delete(location);\n } catch (error) {\n throw new SemanticError(`Failed to delete \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n}\nvar binarySemantic = new BinarySemanticHandler;\n// src/semantic/text.ts\nclass TextSemanticHandler {\n name = \"text\";\n async resolve(transport, location, context) {\n const result = await transport.get(location, context.params);\n if (result.metadata?.type === \"directory\") {\n const meta2 = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: result.content.length,\n encoding: \"utf-8\",\n mimeType: \"application/json\",\n resolvedAt: context.timestamp.toISOString(),\n type: \"directory\"\n };\n return {\n type: \"text\",\n content: result.content.toString(\"utf-8\"),\n meta: meta2\n };\n }\n const text = result.content.toString(\"utf-8\");\n const meta = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: result.metadata?.size ?? result.content.length,\n encoding: \"utf-8\",\n mimeType: \"text/plain\",\n resolvedAt: context.timestamp.toISOString(),\n type: \"file\"\n };\n return {\n type: \"text\",\n content: text,\n meta\n };\n }\n async deposit(transport, location, data, context) {\n const buffer = Buffer.from(data, \"utf-8\");\n try {\n await transport.set(location, buffer, context.params);\n } catch (error) {\n throw new SemanticError(`Failed to deposit text to \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n async exists(transport, location, _context) {\n return transport.exists(location);\n }\n async delete(transport, location, _context) {\n try {\n await transport.delete(location);\n } catch (error) {\n throw new SemanticError(`Failed to delete \"${location}\": ${error.message}`, this.name, { cause: error });\n }\n }\n}\nvar textSemantic = new TextSemanticHandler;\n// src/transport/file.ts\nimport { access, mkdir, readdir, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nclass FileTransportHandler {\n name = \"file\";\n resolvePath(location) {\n return resolve(process.cwd(), location);\n }\n async get(location, params) {\n const filePath = this.resolvePath(location);\n try {\n const stats = await stat(filePath);\n if (stats.isDirectory()) {\n return this.getDirectory(filePath, stats, params);\n } else {\n return this.getFile(filePath, stats);\n }\n } catch (error) {\n const err = error;\n throw new TransportError(`File get error: ${err.code} - ${filePath}`, this.name, {\n cause: err\n });\n }\n }\n async getFile(filePath, stats) {\n const content = await readFile(filePath);\n return {\n content,\n metadata: {\n type: \"file\",\n size: Number(stats.size),\n modifiedAt: stats.mtime\n }\n };\n }\n async getDirectory(dirPath, stats, params) {\n const recursive = params?.recursive === \"true\";\n const pattern = params?.pattern;\n let entries;\n if (recursive) {\n entries = await this.listRecursive(dirPath, dirPath);\n } else {\n entries = await readdir(dirPath);\n }\n if (pattern) {\n entries = this.filterByPattern(entries, pattern);\n }\n const content = Buffer.from(JSON.stringify(entries));\n return {\n content,\n metadata: {\n type: \"directory\",\n modifiedAt: stats.mtime\n }\n };\n }\n async listRecursive(basePath, currentPath) {\n const entries = await readdir(currentPath, { withFileTypes: true });\n const results = [];\n for (const entry of entries) {\n const fullPath = join(currentPath, entry.name);\n const relativePath = fullPath.substring(basePath.length + 1);\n if (entry.isDirectory()) {\n const subEntries = await this.listRecursive(basePath, fullPath);\n results.push(...subEntries);\n } else {\n results.push(relativePath);\n }\n }\n return results;\n }\n filterByPattern(entries, pattern) {\n const regexPattern = pattern.replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\").replace(/\\?/g, \".\");\n const regex = new RegExp(`^${regexPattern}$`);\n return entries.filter((entry) => {\n const filename = entry.split(\"/\").pop() || entry;\n return regex.test(filename);\n });\n }\n async set(location, content, _params) {\n const filePath = this.resolvePath(location);\n try {\n await mkdir(dirname(filePath), { recursive: true });\n await writeFile(filePath, content);\n } catch (error) {\n const err = error;\n throw new TransportError(`File set error: ${err.code} - ${filePath}`, this.name, {\n cause: err\n });\n }\n }\n async exists(location) {\n const filePath = this.resolvePath(location);\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n }\n async delete(location) {\n const filePath = this.resolvePath(location);\n try {\n await rm(filePath, { recursive: true });\n } catch (error) {\n const err = error;\n if (err.code === \"ENOENT\") {\n return;\n }\n throw new TransportError(`File delete error: ${err.code} - ${filePath}`, this.name, {\n cause: err\n });\n }\n }\n async list(location, options) {\n const dirPath = this.resolvePath(location);\n try {\n let entries;\n if (options?.recursive) {\n entries = await this.listRecursive(dirPath, dirPath);\n } else {\n entries = await readdir(dirPath);\n }\n if (options?.pattern) {\n entries = this.filterByPattern(entries, options.pattern);\n }\n return entries;\n } catch (error) {\n const err = error;\n throw new TransportError(`File list error: ${err.code} - ${dirPath}`, this.name, {\n cause: err\n });\n }\n }\n async mkdir(location) {\n const dirPath = this.resolvePath(location);\n try {\n await mkdir(dirPath, { recursive: true });\n } catch (error) {\n const err = error;\n throw new TransportError(`File mkdir error: ${err.code} - ${dirPath}`, this.name, {\n cause: err\n });\n }\n }\n}\nvar fileTransport = new FileTransportHandler;\n// src/transport/http.ts\nclass HttpTransportHandler {\n name;\n protocol;\n constructor(protocol = \"https\") {\n this.protocol = protocol;\n this.name = protocol;\n }\n async get(location, params) {\n const url = this.buildUrl(location, params);\n try {\n const response = await fetch(url);\n if (!response.ok) {\n throw new TransportError(`HTTP ${response.status}: ${response.statusText} - ${url}`, this.name);\n }\n const arrayBuffer = await response.arrayBuffer();\n const content = Buffer.from(arrayBuffer);\n const contentType = response.headers.get(\"content-type\");\n const contentLength = response.headers.get(\"content-length\");\n const lastModified = response.headers.get(\"last-modified\");\n return {\n content,\n metadata: {\n type: \"file\",\n size: contentLength ? parseInt(contentLength, 10) : content.length,\n modifiedAt: lastModified ? new Date(lastModified) : undefined,\n contentType\n }\n };\n } catch (error) {\n if (error instanceof TransportError) {\n throw error;\n }\n throw new TransportError(`Network error: ${url}`, this.name, {\n cause: error\n });\n }\n }\n buildUrl(location, params) {\n const url = new URL(`${this.protocol}://${location}`);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n url.searchParams.set(key, value);\n }\n }\n return url.toString();\n }\n async set(_location, _content, _params) {\n throw new TransportError(\"HTTP transport is read-only, set not supported\", this.name);\n }\n async exists(location) {\n const url = `${this.protocol}://${location}`;\n try {\n const response = await fetch(url, { method: \"HEAD\" });\n return response.ok;\n } catch {\n return false;\n }\n }\n async delete(_location) {\n throw new TransportError(\"HTTP transport is read-only, delete not supported\", this.name);\n }\n}\nvar httpsTransport = new HttpTransportHandler(\"https\");\nvar httpTransport = new HttpTransportHandler(\"http\");\n// src/ARP.ts\nclass ARP {\n transports;\n semantics;\n constructor(config = {}) {\n this.transports = new Map;\n this.semantics = new Map;\n const defaultTransports = [fileTransport, httpTransport, httpsTransport];\n const defaultSemantics = [textSemantic, binarySemantic];\n for (const handler of defaultTransports) {\n this.transports.set(handler.name, handler);\n }\n for (const handler of defaultSemantics) {\n this.semantics.set(handler.name, handler);\n }\n if (config.transports) {\n for (const handler of config.transports) {\n this.transports.set(handler.name, handler);\n }\n }\n if (config.semantics) {\n for (const handler of config.semantics) {\n this.semantics.set(handler.name, handler);\n }\n }\n }\n registerTransport(handler) {\n this.transports.set(handler.name, handler);\n }\n registerSemantic(handler) {\n this.semantics.set(handler.name, handler);\n }\n getTransportHandler(name) {\n const handler = this.transports.get(name);\n if (!handler) {\n throw new TransportError(`Unsupported transport type: ${name}`, name);\n }\n return handler;\n }\n getSemanticHandler(name) {\n const handler = this.semantics.get(name);\n if (!handler) {\n throw new SemanticError(`Unsupported semantic type: ${name}`, name);\n }\n return handler;\n }\n parse(url) {\n if (!url.startsWith(\"arp:\")) {\n throw new ParseError(`Invalid ARP URL: must start with \"arp:\"`, url);\n }\n const content = url.substring(4);\n const separatorIndex = content.indexOf(\"://\");\n if (separatorIndex === -1) {\n throw new ParseError(`Invalid ARP URL: missing \"://\"`, url);\n }\n const typePart = content.substring(0, separatorIndex);\n const location = content.substring(separatorIndex + 3);\n const colonIndex = typePart.indexOf(\":\");\n if (colonIndex === -1) {\n throw new ParseError(`Invalid ARP URL: must have exactly 2 types (semantic:transport)`, url);\n }\n const semantic = typePart.substring(0, colonIndex);\n const transport = typePart.substring(colonIndex + 1);\n if (!semantic) {\n throw new ParseError(`Invalid ARP URL: semantic type cannot be empty`, url);\n }\n if (!transport) {\n throw new ParseError(`Invalid ARP URL: transport type cannot be empty`, url);\n }\n if (!location) {\n throw new ParseError(`Invalid ARP URL: location cannot be empty`, url);\n }\n this.getTransportHandler(transport);\n this.getSemanticHandler(semantic);\n return new ARL(semantic, transport, location, this);\n }\n}\nfunction createARP(config) {\n return new ARP(config);\n}\n\n// src/index.ts\nvar VERSION = \"2.11.0\";\nexport {\n textSemantic,\n httpsTransport,\n httpTransport,\n fileTransport,\n createARP,\n binarySemantic,\n VERSION,\n TransportError,\n TextSemanticHandler,\n SemanticError,\n ParseError,\n HttpTransportHandler,\n FileTransportHandler,\n BinarySemanticHandler,\n ARP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AkC,GAAG;AAAA,IAC5D;AAAA,IACA,MAAM,WAAW,QAAQ,UAAU,GAAG,cAAc;AAAA,IACpD,MAAM,WAAW,QAAQ,UAAU,iBAAiB,CAAC;AAAA,IACrD,MAAM,aAAa,SAAS,QAAQ,GAAG;AAAA,IACvC,IAAI,eAAe,IAAI;AAAA,MACrB,MAAM,IAAI,WAAW,mEAAmE,GAAG;AAAA,IAC7F;AAAA,IACA,MAAM,WAAW,SAAS,UAAU,GAAG,UAAU;AAAA,IACjD,MAAM,YAAY,SAAS,UAAU,aAAa,CAAC;AAAA,IACnD,IAAI,CAAC,UAAU;AAAA,MACb,MAAM,IAAI,WAAW,kDAAkD,GAAG;AAAA,IAC5E;AAAA,IACA,IAAI,CAAC,WAAW;AAAA,MACd,MAAM,IAAI,WAAW,mDAAmD,GAAG;AAAA,IAC7E;AAAA,IACA,IAAI,CAAC,UAAU;AAAA,MACb,MAAM,IAAI,WAAW,6CAA6C,GAAG;AAAA,IACvE;AAAA,IACA,KAAK,oBAAoB,SAAS;AAAA,IAClC,KAAK,mBAAmB,QAAQ;AAAA,IAChC,OAAO,IAAI,IAAI,UAAU,WAAW,UAAU,IAAI;AAAA;AAEtD;AACA,SAAS,SAAS,CAAC,QAAQ;AAAA,EACzB,OAAO,IAAI,IAAI,MAAM;AAAA;AAIvB,IAAI,UAAU;",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "6F64DDE965E4BA0D64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BundledType as BundledType2, FileEntry, FileTree, IsolatorType as IsolatorType2, ProviderConfig, ProviderStores, ResolveSourceConfig, ResourceXProvider as ResourceXProvider2, RXA, RXD, RXL, RXM, RXMArchive as RXMArchive2, RXMDefinition as RXMDefinition2, RXMSource as RXMSource2, RXR, RXS, SourceLoader, TypeDetectionResult, TypeDetector as TypeDetector2 } from "@resourcexjs/core";
|
|
1
|
+
import { BundledType as BundledType2, FileEntry, FileTree, IsolatorType as IsolatorType2, ProviderConfig, ProviderStores, ResolveSourceConfig, ResourceXProvider as ResourceXProvider2, RXA, RXD, RXI, RXL as RXL2, RXM, RXMArchive as RXMArchive2, RXMDefinition as RXMDefinition2, RXMSource as RXMSource2, RXR, RXS, SourceLoader, TypeDetectionResult, TypeDetector as TypeDetector2 } from "@resourcexjs/core";
|
|
2
2
|
import { archive, bundleResourceType, extract, FolderSourceLoader, format, GitHubSourceLoader, generateDefinition, manifest, parse, RegistryError, ResourceJsonDetector, ResourceTypeError, resolveSource, resource, SkillDetector, SourceLoaderChain, TypeDetectorChain, wrap } from "@resourcexjs/core";
|
|
3
3
|
import { ResourceXProvider } from "@resourcexjs/core";
|
|
4
4
|
/**
|
|
@@ -30,7 +30,7 @@ declare function hasProvider(): boolean;
|
|
|
30
30
|
* Clear the provider (for testing).
|
|
31
31
|
*/
|
|
32
32
|
declare function clearProvider(): void;
|
|
33
|
-
import { BundledType, IsolatorType, RXMArchive, RXMDefinition, RXMSource, TypeDetector } from "@resourcexjs/core";
|
|
33
|
+
import { BundledType, IsolatorType, RXL, RXMArchive, RXMDefinition, RXMSource, TypeDetector } from "@resourcexjs/core";
|
|
34
34
|
/**
|
|
35
35
|
* ResourceX configuration.
|
|
36
36
|
*/
|
|
@@ -71,6 +71,16 @@ interface Resource {
|
|
|
71
71
|
source: RXMSource;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
+
* Options for push/pull operations.
|
|
75
|
+
*/
|
|
76
|
+
interface RegistryOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Registry URL override for this operation.
|
|
79
|
+
* Takes precedence over the default registry.
|
|
80
|
+
*/
|
|
81
|
+
registry?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
74
84
|
* ResourceX interface - unified API for resource management.
|
|
75
85
|
*/
|
|
76
86
|
interface ResourceX {
|
|
@@ -79,10 +89,10 @@ interface ResourceX {
|
|
|
79
89
|
info(locator: string): Promise<Resource>;
|
|
80
90
|
remove(locator: string): Promise<void>;
|
|
81
91
|
resolve<T = unknown>(locator: string, args?: unknown): Promise<T>;
|
|
82
|
-
ingest<T = unknown>(
|
|
92
|
+
ingest<T = unknown>(locator: RXL, args?: unknown): Promise<T>;
|
|
83
93
|
search(query?: string): Promise<string[]>;
|
|
84
|
-
push(locator: string): Promise<void>;
|
|
85
|
-
pull(locator: string): Promise<void>;
|
|
94
|
+
push(locator: string, options?: RegistryOptions): Promise<void>;
|
|
95
|
+
pull(locator: string, options?: RegistryOptions): Promise<void>;
|
|
86
96
|
clearCache(registry?: string): Promise<void>;
|
|
87
97
|
supportType(type: BundledType): void;
|
|
88
98
|
}
|
|
@@ -91,7 +101,10 @@ interface ResourceX {
|
|
|
91
101
|
*
|
|
92
102
|
* Requires a provider to be set first via setProvider() or by importing
|
|
93
103
|
* a platform entry point like 'resourcexjs/node'.
|
|
104
|
+
*
|
|
105
|
+
* When registry is not explicitly provided, the provider's getDefaults()
|
|
106
|
+
* is consulted for environment variables and config file defaults.
|
|
94
107
|
*/
|
|
95
108
|
declare function createResourceX(config?: ResourceXConfig): ResourceX;
|
|
96
109
|
declare const VERSION: string;
|
|
97
|
-
export { wrap, setProvider, resource, resolveSource, parse, manifest, hasProvider, getProvider, generateDefinition, format, extract, createResourceX, clearProvider, bundleResourceType, archive, VERSION, TypeDetectorChain, TypeDetector2 as TypeDetector, TypeDetectionResult, SourceLoaderChain, SourceLoader, SkillDetector, ResourceXProvider2 as ResourceXProvider, ResourceXConfig, ResourceX, ResourceTypeError, ResourceJsonDetector, Resource, ResolveSourceConfig, RegistryError, RXS, RXR, RXMSource2 as RXMSource, RXMDefinition2 as RXMDefinition, RXMArchive2 as RXMArchive, RXM, RXL, RXD, RXA, ProviderStores, ProviderConfig, IsolatorType2 as IsolatorType, GitHubSourceLoader, FolderSourceLoader, FileTree, FileEntry, BundledType2 as BundledType };
|
|
110
|
+
export { wrap, setProvider, resource, resolveSource, parse, manifest, hasProvider, getProvider, generateDefinition, format, extract, createResourceX, clearProvider, bundleResourceType, archive, VERSION, TypeDetectorChain, TypeDetector2 as TypeDetector, TypeDetectionResult, SourceLoaderChain, SourceLoader, SkillDetector, ResourceXProvider2 as ResourceXProvider, ResourceXConfig, ResourceX, ResourceTypeError, ResourceJsonDetector, Resource, ResolveSourceConfig, RegistryOptions, RegistryError, RXS, RXR, RXMSource2 as RXMSource, RXMDefinition2 as RXMDefinition, RXMArchive2 as RXMArchive, RXM, RXL2 as RXL, RXI, RXD, RXA, ProviderStores, ProviderConfig, IsolatorType2 as IsolatorType, GitHubSourceLoader, FolderSourceLoader, FileTree, FileEntry, BundledType2 as BundledType };
|
package/dist/index.js
CHANGED
|
@@ -4709,17 +4709,17 @@ async function extract(rxa) {
|
|
|
4709
4709
|
}
|
|
4710
4710
|
return files2;
|
|
4711
4711
|
}
|
|
4712
|
-
function format(
|
|
4712
|
+
function format(rxi) {
|
|
4713
4713
|
let result = "";
|
|
4714
|
-
if (
|
|
4715
|
-
result += `${
|
|
4714
|
+
if (rxi.registry) {
|
|
4715
|
+
result += `${rxi.registry}/`;
|
|
4716
4716
|
}
|
|
4717
|
-
if (
|
|
4718
|
-
result += `${
|
|
4717
|
+
if (rxi.path) {
|
|
4718
|
+
result += `${rxi.path}/`;
|
|
4719
4719
|
}
|
|
4720
|
-
result +=
|
|
4721
|
-
if (
|
|
4722
|
-
result += `:${
|
|
4720
|
+
result += rxi.name;
|
|
4721
|
+
if (rxi.tag && rxi.tag !== "latest") {
|
|
4722
|
+
result += `:${rxi.tag}`;
|
|
4723
4723
|
}
|
|
4724
4724
|
return result;
|
|
4725
4725
|
}
|
|
@@ -4846,9 +4846,9 @@ function parse5(locator) {
|
|
|
4846
4846
|
};
|
|
4847
4847
|
}
|
|
4848
4848
|
function resource(rxm, rxa) {
|
|
4849
|
-
const
|
|
4849
|
+
const rxi = locate(rxm);
|
|
4850
4850
|
return {
|
|
4851
|
-
|
|
4851
|
+
identifier: rxi,
|
|
4852
4852
|
manifest: rxm,
|
|
4853
4853
|
archive: rxa
|
|
4854
4854
|
};
|
|
@@ -5237,17 +5237,17 @@ class RegistryMiddleware {
|
|
|
5237
5237
|
constructor(inner) {
|
|
5238
5238
|
this.inner = inner;
|
|
5239
5239
|
}
|
|
5240
|
-
get(
|
|
5241
|
-
return this.inner.get(
|
|
5240
|
+
get(rxi) {
|
|
5241
|
+
return this.inner.get(rxi);
|
|
5242
5242
|
}
|
|
5243
5243
|
put(rxr2) {
|
|
5244
5244
|
return this.inner.put(rxr2);
|
|
5245
5245
|
}
|
|
5246
|
-
has(
|
|
5247
|
-
return this.inner.has(
|
|
5246
|
+
has(rxi) {
|
|
5247
|
+
return this.inner.has(rxi);
|
|
5248
5248
|
}
|
|
5249
|
-
remove(
|
|
5250
|
-
return this.inner.remove(
|
|
5249
|
+
remove(rxi) {
|
|
5250
|
+
return this.inner.remove(rxi);
|
|
5251
5251
|
}
|
|
5252
5252
|
list(options) {
|
|
5253
5253
|
return this.inner.list(options);
|
|
@@ -5275,11 +5275,11 @@ class CASRegistry {
|
|
|
5275
5275
|
}
|
|
5276
5276
|
return tag;
|
|
5277
5277
|
}
|
|
5278
|
-
async get(
|
|
5279
|
-
const tag = await this.resolveTag(
|
|
5280
|
-
const storedRxm = await this.rxmStore.get(
|
|
5278
|
+
async get(rxi) {
|
|
5279
|
+
const tag = await this.resolveTag(rxi.name, rxi.tag ?? "latest", rxi.registry);
|
|
5280
|
+
const storedRxm = await this.rxmStore.get(rxi.name, tag, rxi.registry);
|
|
5281
5281
|
if (!storedRxm) {
|
|
5282
|
-
throw new RegistryError(`Resource not found: ${format(
|
|
5282
|
+
throw new RegistryError(`Resource not found: ${format(rxi)}`);
|
|
5283
5283
|
}
|
|
5284
5284
|
const files2 = {};
|
|
5285
5285
|
for (const [filename, digest] of Object.entries(storedRxm.files)) {
|
|
@@ -5329,13 +5329,13 @@ class CASRegistry {
|
|
|
5329
5329
|
await this.rxmStore.put(storedRxm);
|
|
5330
5330
|
await this.rxmStore.setLatest(rxr2.manifest.definition.name, rxr2.manifest.definition.tag, rxr2.manifest.definition.registry);
|
|
5331
5331
|
}
|
|
5332
|
-
async has(
|
|
5333
|
-
const tag = await this.resolveTag(
|
|
5334
|
-
return this.rxmStore.has(
|
|
5332
|
+
async has(rxi) {
|
|
5333
|
+
const tag = await this.resolveTag(rxi.name, rxi.tag ?? "latest", rxi.registry);
|
|
5334
|
+
return this.rxmStore.has(rxi.name, tag, rxi.registry);
|
|
5335
5335
|
}
|
|
5336
|
-
async remove(
|
|
5337
|
-
const tag =
|
|
5338
|
-
await this.rxmStore.delete(
|
|
5336
|
+
async remove(rxi) {
|
|
5337
|
+
const tag = rxi.tag ?? "latest";
|
|
5338
|
+
await this.rxmStore.delete(rxi.name, tag, rxi.registry);
|
|
5339
5339
|
}
|
|
5340
5340
|
async list(options) {
|
|
5341
5341
|
const { query, limit, offset = 0 } = options ?? {};
|
|
@@ -5397,14 +5397,14 @@ class LinkedRegistry {
|
|
|
5397
5397
|
constructor(basePath) {
|
|
5398
5398
|
this.basePath = basePath;
|
|
5399
5399
|
}
|
|
5400
|
-
buildLinkPath(
|
|
5401
|
-
const registry2 =
|
|
5402
|
-
const tag =
|
|
5400
|
+
buildLinkPath(rxi) {
|
|
5401
|
+
const registry2 = rxi.registry ?? "localhost";
|
|
5402
|
+
const tag = rxi.tag ?? "latest";
|
|
5403
5403
|
let linkPath = join3(this.basePath, registry2);
|
|
5404
|
-
if (
|
|
5405
|
-
linkPath = join3(linkPath,
|
|
5404
|
+
if (rxi.path) {
|
|
5405
|
+
linkPath = join3(linkPath, rxi.path);
|
|
5406
5406
|
}
|
|
5407
|
-
return join3(linkPath,
|
|
5407
|
+
return join3(linkPath, rxi.name, tag);
|
|
5408
5408
|
}
|
|
5409
5409
|
async isSymlink(path) {
|
|
5410
5410
|
try {
|
|
@@ -5414,10 +5414,10 @@ class LinkedRegistry {
|
|
|
5414
5414
|
return false;
|
|
5415
5415
|
}
|
|
5416
5416
|
}
|
|
5417
|
-
async get(
|
|
5418
|
-
const linkPath = this.buildLinkPath(
|
|
5417
|
+
async get(rxi) {
|
|
5418
|
+
const linkPath = this.buildLinkPath(rxi);
|
|
5419
5419
|
if (!await this.isSymlink(linkPath)) {
|
|
5420
|
-
throw new RegistryError(`Linked resource not found: ${format(
|
|
5420
|
+
throw new RegistryError(`Linked resource not found: ${format(rxi)}`);
|
|
5421
5421
|
}
|
|
5422
5422
|
const targetPath = await readlink(linkPath);
|
|
5423
5423
|
return loadResource(targetPath);
|
|
@@ -5425,29 +5425,29 @@ class LinkedRegistry {
|
|
|
5425
5425
|
async put(_rxr) {
|
|
5426
5426
|
throw new RegistryError("LinkedRegistry does not support put(). Use link() instead.");
|
|
5427
5427
|
}
|
|
5428
|
-
async has(
|
|
5429
|
-
const linkPath = this.buildLinkPath(
|
|
5428
|
+
async has(rxi) {
|
|
5429
|
+
const linkPath = this.buildLinkPath(rxi);
|
|
5430
5430
|
return this.isSymlink(linkPath);
|
|
5431
5431
|
}
|
|
5432
|
-
async remove(
|
|
5433
|
-
const linkPath = this.buildLinkPath(
|
|
5432
|
+
async remove(rxi) {
|
|
5433
|
+
const linkPath = this.buildLinkPath(rxi);
|
|
5434
5434
|
if (await this.isSymlink(linkPath)) {
|
|
5435
5435
|
await rm(linkPath);
|
|
5436
5436
|
}
|
|
5437
5437
|
}
|
|
5438
5438
|
async list(options) {
|
|
5439
5439
|
const { query, limit, offset = 0 } = options ?? {};
|
|
5440
|
-
const
|
|
5440
|
+
const identifiers = [];
|
|
5441
5441
|
try {
|
|
5442
|
-
await this.scanSymlinks(this.basePath, "",
|
|
5442
|
+
await this.scanSymlinks(this.basePath, "", identifiers);
|
|
5443
5443
|
} catch {
|
|
5444
5444
|
return [];
|
|
5445
5445
|
}
|
|
5446
|
-
let filtered =
|
|
5446
|
+
let filtered = identifiers;
|
|
5447
5447
|
if (query) {
|
|
5448
5448
|
const lowerQuery = query.toLowerCase();
|
|
5449
|
-
filtered =
|
|
5450
|
-
const searchText = `${
|
|
5449
|
+
filtered = identifiers.filter((rxi) => {
|
|
5450
|
+
const searchText = `${rxi.registry ?? ""} ${rxi.path ?? ""} ${rxi.name}`.toLowerCase();
|
|
5451
5451
|
return searchText.includes(lowerQuery);
|
|
5452
5452
|
});
|
|
5453
5453
|
}
|
|
@@ -5459,7 +5459,7 @@ class LinkedRegistry {
|
|
|
5459
5459
|
}
|
|
5460
5460
|
async link(devPath) {
|
|
5461
5461
|
const rxr2 = await loadResource(devPath);
|
|
5462
|
-
const linkPath = this.buildLinkPath(rxr2.
|
|
5462
|
+
const linkPath = this.buildLinkPath(rxr2.identifier);
|
|
5463
5463
|
try {
|
|
5464
5464
|
const stats = await lstat(linkPath);
|
|
5465
5465
|
if (stats.isSymbolicLink() || stats.isDirectory()) {
|
|
@@ -5470,12 +5470,12 @@ class LinkedRegistry {
|
|
|
5470
5470
|
await mkdir(parentPath, { recursive: true });
|
|
5471
5471
|
const absolutePath = resolvePath(devPath);
|
|
5472
5472
|
await symlink(absolutePath, linkPath);
|
|
5473
|
-
return rxr2.
|
|
5473
|
+
return rxr2.identifier;
|
|
5474
5474
|
}
|
|
5475
|
-
async unlink(
|
|
5476
|
-
return this.remove(
|
|
5475
|
+
async unlink(rxi) {
|
|
5476
|
+
return this.remove(rxi);
|
|
5477
5477
|
}
|
|
5478
|
-
async scanSymlinks(dirPath, relativePath,
|
|
5478
|
+
async scanSymlinks(dirPath, relativePath, identifiers) {
|
|
5479
5479
|
let entries;
|
|
5480
5480
|
try {
|
|
5481
5481
|
entries = await readdir3(dirPath);
|
|
@@ -5488,17 +5488,17 @@ class LinkedRegistry {
|
|
|
5488
5488
|
try {
|
|
5489
5489
|
const stats = await lstat(fullPath);
|
|
5490
5490
|
if (stats.isSymbolicLink()) {
|
|
5491
|
-
const
|
|
5492
|
-
if (
|
|
5493
|
-
|
|
5491
|
+
const rxi = this.parsePathToRXI(relPath);
|
|
5492
|
+
if (rxi) {
|
|
5493
|
+
identifiers.push(rxi);
|
|
5494
5494
|
}
|
|
5495
5495
|
} else if (stats.isDirectory()) {
|
|
5496
|
-
await this.scanSymlinks(fullPath, relPath,
|
|
5496
|
+
await this.scanSymlinks(fullPath, relPath, identifiers);
|
|
5497
5497
|
}
|
|
5498
5498
|
} catch {}
|
|
5499
5499
|
}
|
|
5500
5500
|
}
|
|
5501
|
-
|
|
5501
|
+
parsePathToRXI(relPath) {
|
|
5502
5502
|
const parts = relPath.split("/");
|
|
5503
5503
|
if (parts.length < 3) {
|
|
5504
5504
|
return null;
|
|
@@ -15488,8 +15488,8 @@ var init_dist = __esm(() => {
|
|
|
15488
15488
|
throw new RegistryError(`Untrusted registry: resource claims "${rxr2.manifest.definition.registry}" but registry only trusts "${this.trustedRegistry}"`);
|
|
15489
15489
|
}
|
|
15490
15490
|
}
|
|
15491
|
-
async get(
|
|
15492
|
-
const rxr2 = await this.inner.get(
|
|
15491
|
+
async get(rxi) {
|
|
15492
|
+
const rxr2 = await this.inner.get(rxi);
|
|
15493
15493
|
this.validateRegistry(rxr2);
|
|
15494
15494
|
return rxr2;
|
|
15495
15495
|
}
|
|
@@ -31175,7 +31175,7 @@ class DefaultResourceX {
|
|
|
31175
31175
|
}
|
|
31176
31176
|
toResource(rxr2) {
|
|
31177
31177
|
return {
|
|
31178
|
-
locator: format(rxr2.
|
|
31178
|
+
locator: format(rxr2.identifier),
|
|
31179
31179
|
definition: rxr2.manifest.definition,
|
|
31180
31180
|
archive: rxr2.manifest.archive,
|
|
31181
31181
|
source: rxr2.manifest.source
|
|
@@ -31213,7 +31213,7 @@ class DefaultResourceX {
|
|
|
31213
31213
|
const fileTree = buildFileTree(filesRecord2);
|
|
31214
31214
|
const preview = extractPreview(filesRecord2);
|
|
31215
31215
|
return {
|
|
31216
|
-
locator: format(rxr2.
|
|
31216
|
+
locator: format(rxr2.identifier),
|
|
31217
31217
|
definition: rxr2.manifest.definition,
|
|
31218
31218
|
archive: rxr2.manifest.archive,
|
|
31219
31219
|
source: {
|
|
@@ -31230,13 +31230,13 @@ class DefaultResourceX {
|
|
|
31230
31230
|
const executable = await this.prepareExecutable(locator);
|
|
31231
31231
|
return executable.execute(args2);
|
|
31232
31232
|
}
|
|
31233
|
-
async ingest(
|
|
31234
|
-
const isSource = await this.canLoadSource(
|
|
31233
|
+
async ingest(locator, args2) {
|
|
31234
|
+
const isSource = await this.canLoadSource(locator);
|
|
31235
31235
|
if (isSource) {
|
|
31236
|
-
const resource2 = await this.add(
|
|
31236
|
+
const resource2 = await this.add(locator);
|
|
31237
31237
|
return this.resolve(resource2.locator, args2);
|
|
31238
31238
|
}
|
|
31239
|
-
return this.resolve(
|
|
31239
|
+
return this.resolve(locator, args2);
|
|
31240
31240
|
}
|
|
31241
31241
|
async canLoadSource(source) {
|
|
31242
31242
|
return this.loaderChain.canLoad(source);
|
|
@@ -31280,20 +31280,22 @@ class DefaultResourceX {
|
|
|
31280
31280
|
const results = await this.cas.list(query ? { query } : undefined);
|
|
31281
31281
|
return results.map((rxl) => format(rxl));
|
|
31282
31282
|
}
|
|
31283
|
-
async push(locator) {
|
|
31284
|
-
|
|
31283
|
+
async push(locator, options) {
|
|
31284
|
+
const registry2 = options?.registry ?? this.registryUrl;
|
|
31285
|
+
if (!registry2) {
|
|
31285
31286
|
throw new RegistryError("Registry URL not configured. Set 'registry' in config.");
|
|
31286
31287
|
}
|
|
31287
31288
|
const rxl = parse5(locator);
|
|
31288
31289
|
const rxr2 = await this.cas.get(rxl);
|
|
31289
|
-
await this.publishToRegistry(rxr2);
|
|
31290
|
+
await this.publishToRegistry(rxr2, registry2);
|
|
31290
31291
|
}
|
|
31291
|
-
async pull(locator) {
|
|
31292
|
-
|
|
31292
|
+
async pull(locator, options) {
|
|
31293
|
+
const registry2 = options?.registry ?? this.registryUrl;
|
|
31294
|
+
if (!registry2) {
|
|
31293
31295
|
throw new RegistryError("Registry URL not configured. Set 'registry' in config.");
|
|
31294
31296
|
}
|
|
31295
|
-
const normalizedRegistry = normalizeRegistryUrl(
|
|
31296
|
-
const rxr2 = await this.fetchFromRegistry(locator,
|
|
31297
|
+
const normalizedRegistry = normalizeRegistryUrl(registry2);
|
|
31298
|
+
const rxr2 = await this.fetchFromRegistry(locator, registry2, normalizedRegistry);
|
|
31297
31299
|
await this.cas.put(rxr2);
|
|
31298
31300
|
}
|
|
31299
31301
|
async clearCache(registry2) {
|
|
@@ -31311,11 +31313,11 @@ class DefaultResourceX {
|
|
|
31311
31313
|
const rxr2 = await this.cas.get(rxl);
|
|
31312
31314
|
return rxr2.archive.buffer();
|
|
31313
31315
|
}
|
|
31314
|
-
async publishToRegistry(rxr2) {
|
|
31315
|
-
const baseUrl =
|
|
31316
|
+
async publishToRegistry(rxr2, registryUrl) {
|
|
31317
|
+
const baseUrl = registryUrl.replace(/\/$/, "");
|
|
31316
31318
|
const publishUrl = `${baseUrl}/api/v1/publish`;
|
|
31317
31319
|
const formData = new FormData;
|
|
31318
|
-
formData.append("locator", format(rxr2.
|
|
31320
|
+
formData.append("locator", format(rxr2.identifier));
|
|
31319
31321
|
formData.append("manifest", new Blob([
|
|
31320
31322
|
JSON.stringify({
|
|
31321
31323
|
registry: rxr2.manifest.definition.registry,
|
|
@@ -31425,11 +31427,18 @@ function createResourceX2(config3) {
|
|
|
31425
31427
|
if (!hasProvider()) {
|
|
31426
31428
|
throw new Error('No ResourceX provider configured. Import a platform entry point (e.g., "resourcexjs/node") or call setProvider() first.');
|
|
31427
31429
|
}
|
|
31430
|
+
if (config3?.registry === undefined) {
|
|
31431
|
+
const provider = getProvider();
|
|
31432
|
+
const defaults = provider.getDefaults?.({ path: config3?.path });
|
|
31433
|
+
if (defaults?.registry) {
|
|
31434
|
+
config3 = { ...config3, registry: defaults.registry };
|
|
31435
|
+
}
|
|
31436
|
+
}
|
|
31428
31437
|
return new DefaultResourceX(config3);
|
|
31429
31438
|
}
|
|
31430
31439
|
|
|
31431
31440
|
// src/index.ts
|
|
31432
|
-
var VERSION = "2.
|
|
31441
|
+
var VERSION = "2.11.0";
|
|
31433
31442
|
export {
|
|
31434
31443
|
wrap,
|
|
31435
31444
|
setProvider,
|
|
@@ -31457,4 +31466,4 @@ export {
|
|
|
31457
31466
|
FolderSourceLoader
|
|
31458
31467
|
};
|
|
31459
31468
|
|
|
31460
|
-
//# debugId=
|
|
31469
|
+
//# debugId=E9B6F26CD736E0DF64756E2164756E21
|