@resourcexjs/core 0.0.3 → 0.2.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 +75 -14
- package/dist/index.d.ts +202 -26
- package/dist/index.js +286 -39
- package/dist/index.js.map +12 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,19 +30,56 @@ import { resolve } from "@resourcexjs/core";
|
|
|
30
30
|
|
|
31
31
|
const resource = await resolve("arp:text:https://example.com/file.txt");
|
|
32
32
|
// { type: "text", content: "...", meta: { ... } }
|
|
33
|
+
|
|
34
|
+
const binary = await resolve("arp:binary:file://./image.png");
|
|
35
|
+
// { type: "binary", content: Buffer, meta: { ... } }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Deposit Resources
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { deposit } from "@resourcexjs/core";
|
|
42
|
+
|
|
43
|
+
await deposit("arp:text:file://./data/config.txt", "hello world");
|
|
44
|
+
await deposit("arp:binary:file://./data/image.png", buffer);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Check Existence & Delete
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { resourceExists, resourceDelete } from "@resourcexjs/core";
|
|
51
|
+
|
|
52
|
+
const exists = await resourceExists("arp:text:file://./data/config.txt");
|
|
53
|
+
await resourceDelete("arp:text:file://./data/config.txt");
|
|
33
54
|
```
|
|
34
55
|
|
|
35
56
|
### Custom Transport Handler
|
|
36
57
|
|
|
58
|
+
Transport provides I/O primitives (read/write/list/exists/delete):
|
|
59
|
+
|
|
37
60
|
```typescript
|
|
38
61
|
import { registerTransportHandler, type TransportHandler } from "@resourcexjs/core";
|
|
39
62
|
|
|
40
63
|
const s3Handler: TransportHandler = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
name: "s3",
|
|
65
|
+
capabilities: {
|
|
66
|
+
canRead: true,
|
|
67
|
+
canWrite: true,
|
|
68
|
+
canList: true,
|
|
69
|
+
canDelete: true,
|
|
70
|
+
canStat: false,
|
|
71
|
+
},
|
|
72
|
+
async read(location: string): Promise<Buffer> {
|
|
73
|
+
// read from S3...
|
|
44
74
|
return buffer;
|
|
45
75
|
},
|
|
76
|
+
async write(location: string, content: Buffer): Promise<void> {
|
|
77
|
+
// write to S3...
|
|
78
|
+
},
|
|
79
|
+
async list(location: string): Promise<string[]> {
|
|
80
|
+
// list S3 objects...
|
|
81
|
+
return keys;
|
|
82
|
+
},
|
|
46
83
|
};
|
|
47
84
|
|
|
48
85
|
registerTransportHandler(s3Handler);
|
|
@@ -50,20 +87,33 @@ registerTransportHandler(s3Handler);
|
|
|
50
87
|
|
|
51
88
|
### Custom Semantic Handler
|
|
52
89
|
|
|
90
|
+
Semantic orchestrates Transport primitives to handle resource logic:
|
|
91
|
+
|
|
53
92
|
```typescript
|
|
54
93
|
import { registerSemanticHandler, type SemanticHandler, type Resource } from "@resourcexjs/core";
|
|
55
94
|
|
|
56
95
|
const jsonHandler: SemanticHandler = {
|
|
57
|
-
|
|
58
|
-
|
|
96
|
+
name: "json",
|
|
97
|
+
async resolve(transport, location, context): Promise<Resource> {
|
|
98
|
+
const buffer = await transport.read(location);
|
|
59
99
|
return {
|
|
60
100
|
type: "json",
|
|
61
|
-
content: JSON.parse(
|
|
101
|
+
content: JSON.parse(buffer.toString("utf-8")),
|
|
62
102
|
meta: {
|
|
63
|
-
|
|
103
|
+
url: context.url,
|
|
104
|
+
semantic: context.semantic,
|
|
105
|
+
transport: context.transport,
|
|
106
|
+
location: context.location,
|
|
107
|
+
size: buffer.length,
|
|
108
|
+
resolvedAt: context.timestamp.toISOString(),
|
|
64
109
|
},
|
|
65
110
|
};
|
|
66
111
|
},
|
|
112
|
+
async deposit(transport, location, data, context): Promise<void> {
|
|
113
|
+
if (!transport.write) throw new Error("Transport does not support write");
|
|
114
|
+
const buffer = Buffer.from(JSON.stringify(data), "utf-8");
|
|
115
|
+
await transport.write(location, buffer);
|
|
116
|
+
},
|
|
67
117
|
};
|
|
68
118
|
|
|
69
119
|
registerSemanticHandler(jsonHandler);
|
|
@@ -75,22 +125,27 @@ registerSemanticHandler(jsonHandler);
|
|
|
75
125
|
|
|
76
126
|
- `parseARP(url)` - Parse ARP URL string
|
|
77
127
|
- `resolve(url)` - Resolve ARP URL to resource
|
|
78
|
-
- `
|
|
128
|
+
- `deposit(url, data)` - Deposit data to ARP URL
|
|
129
|
+
- `resourceExists(url)` - Check if resource exists
|
|
130
|
+
- `resourceDelete(url)` - Delete resource
|
|
131
|
+
- `getTransportHandler(name)` - Get registered transport handler
|
|
79
132
|
- `registerTransportHandler(handler)` - Register custom transport
|
|
80
|
-
- `getSemanticHandler(
|
|
133
|
+
- `getSemanticHandler(name)` - Get registered semantic handler
|
|
81
134
|
- `registerSemanticHandler(handler)` - Register custom semantic
|
|
135
|
+
- `createResourceRegistry()` - Create a resource definition registry
|
|
82
136
|
|
|
83
137
|
### Built-in Handlers
|
|
84
138
|
|
|
85
139
|
**Transport:**
|
|
86
140
|
|
|
87
|
-
- `httpsHandler` - HTTPS protocol
|
|
88
|
-
- `httpHandler` - HTTP protocol
|
|
89
|
-
- `fileHandler` - Local file system
|
|
141
|
+
- `httpsHandler` - HTTPS protocol (read-only)
|
|
142
|
+
- `httpHandler` - HTTP protocol (read-only)
|
|
143
|
+
- `fileHandler` - Local file system (read/write/list/delete)
|
|
90
144
|
|
|
91
145
|
**Semantic:**
|
|
92
146
|
|
|
93
|
-
- `textHandler` - Plain text
|
|
147
|
+
- `textHandler` - Plain text (UTF-8 encoding)
|
|
148
|
+
- `binaryHandler` - Raw binary (Buffer passthrough)
|
|
94
149
|
|
|
95
150
|
### Error Classes
|
|
96
151
|
|
|
@@ -110,10 +165,16 @@ import type {
|
|
|
110
165
|
ParsedARP,
|
|
111
166
|
Resource,
|
|
112
167
|
ResourceMeta,
|
|
113
|
-
|
|
168
|
+
SemanticContext,
|
|
114
169
|
TransportHandler,
|
|
170
|
+
TransportCapabilities,
|
|
171
|
+
ResourceStat,
|
|
115
172
|
SemanticHandler,
|
|
116
173
|
TextResource,
|
|
174
|
+
BinaryResource,
|
|
175
|
+
BinaryInput,
|
|
176
|
+
ResourceDefinition,
|
|
177
|
+
ResourceRegistry,
|
|
117
178
|
} from "@resourcexjs/core";
|
|
118
179
|
```
|
|
119
180
|
|
package/dist/index.d.ts
CHANGED
|
@@ -43,46 +43,109 @@ interface ParsedARP {
|
|
|
43
43
|
declare function parseARP(url: string): ParsedARP;
|
|
44
44
|
/**
|
|
45
45
|
* Transport Handler Interface
|
|
46
|
-
* Responsible for
|
|
46
|
+
* Responsible for I/O primitives - read, write, list, exists, delete
|
|
47
|
+
* Transport only handles WHERE and HOW to access bytes, not WHAT they mean
|
|
48
|
+
*/
|
|
49
|
+
/**
|
|
50
|
+
* Transport capabilities declaration
|
|
51
|
+
*/
|
|
52
|
+
interface TransportCapabilities {
|
|
53
|
+
readonly canRead: boolean;
|
|
54
|
+
readonly canWrite: boolean;
|
|
55
|
+
readonly canList: boolean;
|
|
56
|
+
readonly canDelete: boolean;
|
|
57
|
+
readonly canStat: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resource stat information
|
|
61
|
+
*/
|
|
62
|
+
interface ResourceStat {
|
|
63
|
+
size: number;
|
|
64
|
+
modifiedAt?: Date;
|
|
65
|
+
isDirectory?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Transport Handler - provides I/O primitives
|
|
47
69
|
*/
|
|
48
70
|
interface TransportHandler {
|
|
49
71
|
/**
|
|
50
|
-
* Transport
|
|
72
|
+
* Transport name (e.g., "https", "file", "s3")
|
|
51
73
|
*/
|
|
52
|
-
readonly
|
|
74
|
+
readonly name: string;
|
|
53
75
|
/**
|
|
54
|
-
*
|
|
76
|
+
* Transport capabilities
|
|
77
|
+
*/
|
|
78
|
+
readonly capabilities: TransportCapabilities;
|
|
79
|
+
/**
|
|
80
|
+
* Read content from location
|
|
55
81
|
* @param location - The location string after ://
|
|
56
82
|
* @returns Raw content as Buffer
|
|
57
83
|
*/
|
|
58
|
-
|
|
84
|
+
read(location: string): Promise<Buffer>;
|
|
85
|
+
/**
|
|
86
|
+
* Write content to location
|
|
87
|
+
* @param location - The location string after ://
|
|
88
|
+
* @param content - Content to write
|
|
89
|
+
*/
|
|
90
|
+
write?(location: string, content: Buffer): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* List entries at location (for directory-like transports)
|
|
93
|
+
* @param location - The location string after ://
|
|
94
|
+
* @returns Array of entry names
|
|
95
|
+
*/
|
|
96
|
+
list?(location: string): Promise<string[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Create directory at location
|
|
99
|
+
* @param location - The location string after ://
|
|
100
|
+
*/
|
|
101
|
+
mkdir?(location: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Check if resource exists at location
|
|
104
|
+
* @param location - The location string after ://
|
|
105
|
+
*/
|
|
106
|
+
exists?(location: string): Promise<boolean>;
|
|
107
|
+
/**
|
|
108
|
+
* Get resource stat information
|
|
109
|
+
* @param location - The location string after ://
|
|
110
|
+
*/
|
|
111
|
+
stat?(location: string): Promise<ResourceStat>;
|
|
112
|
+
/**
|
|
113
|
+
* Delete resource at location
|
|
114
|
+
* @param location - The location string after ://
|
|
115
|
+
*/
|
|
116
|
+
delete?(location: string): Promise<void>;
|
|
59
117
|
}
|
|
60
118
|
declare class HttpTransportHandler implements TransportHandler {
|
|
61
|
-
readonly
|
|
119
|
+
readonly name: string;
|
|
62
120
|
private readonly protocol;
|
|
121
|
+
readonly capabilities: TransportCapabilities;
|
|
63
122
|
constructor(protocol?: "http" | "https");
|
|
64
|
-
|
|
123
|
+
read(location: string): Promise<Buffer>;
|
|
65
124
|
}
|
|
66
125
|
declare const httpsHandler: HttpTransportHandler;
|
|
67
126
|
declare const httpHandler: HttpTransportHandler;
|
|
68
127
|
declare class FileTransportHandler implements TransportHandler {
|
|
69
|
-
readonly
|
|
70
|
-
|
|
128
|
+
readonly name = "file";
|
|
129
|
+
readonly capabilities: TransportCapabilities;
|
|
130
|
+
private resolvePath;
|
|
131
|
+
read(location: string): Promise<Buffer>;
|
|
132
|
+
write(location: string, content: Buffer): Promise<void>;
|
|
133
|
+
list(location: string): Promise<string[]>;
|
|
134
|
+
mkdir(location: string): Promise<void>;
|
|
135
|
+
exists(location: string): Promise<boolean>;
|
|
136
|
+
stat(location: string): Promise<ResourceStat>;
|
|
137
|
+
delete(location: string): Promise<void>;
|
|
71
138
|
}
|
|
72
139
|
declare const fileHandler: FileTransportHandler;
|
|
73
140
|
/**
|
|
74
|
-
* Get transport handler by
|
|
141
|
+
* Get transport handler by name
|
|
75
142
|
*/
|
|
76
|
-
declare function getTransportHandler(
|
|
143
|
+
declare function getTransportHandler(name: string): TransportHandler;
|
|
77
144
|
/**
|
|
78
145
|
* Register a custom transport handler
|
|
79
146
|
*/
|
|
80
147
|
declare function registerTransportHandler(handler: TransportHandler): void;
|
|
81
148
|
/**
|
|
82
|
-
* Semantic Handler Interface
|
|
83
|
-
* Responsible for parsing raw content into AI-usable format
|
|
84
|
-
*/
|
|
85
|
-
/**
|
|
86
149
|
* Resource metadata
|
|
87
150
|
*/
|
|
88
151
|
interface ResourceMeta {
|
|
@@ -93,17 +156,17 @@ interface ResourceMeta {
|
|
|
93
156
|
size: number;
|
|
94
157
|
encoding?: string;
|
|
95
158
|
mimeType?: string;
|
|
96
|
-
|
|
159
|
+
resolvedAt: string;
|
|
97
160
|
}
|
|
98
161
|
/**
|
|
99
162
|
* Context passed to semantic handler
|
|
100
163
|
*/
|
|
101
|
-
interface
|
|
164
|
+
interface SemanticContext {
|
|
102
165
|
url: string;
|
|
103
166
|
semantic: string;
|
|
104
167
|
transport: string;
|
|
105
168
|
location: string;
|
|
106
|
-
|
|
169
|
+
timestamp: Date;
|
|
107
170
|
}
|
|
108
171
|
/**
|
|
109
172
|
* Base resource interface
|
|
@@ -115,27 +178,81 @@ interface Resource<T = unknown> {
|
|
|
115
178
|
}
|
|
116
179
|
/**
|
|
117
180
|
* Semantic handler interface
|
|
181
|
+
* Semantic orchestrates Transport primitives to resolve/deposit resources
|
|
118
182
|
*/
|
|
119
183
|
interface SemanticHandler<T = unknown> {
|
|
120
|
-
readonly type: string;
|
|
121
184
|
/**
|
|
122
|
-
*
|
|
185
|
+
* Semantic name (e.g., "text", "json", "package")
|
|
186
|
+
*/
|
|
187
|
+
readonly name: string;
|
|
188
|
+
/**
|
|
189
|
+
* Resolve resource from location
|
|
190
|
+
* Semantic controls how to use transport primitives to fetch and parse resource
|
|
191
|
+
*
|
|
192
|
+
* @param transport - Transport handler for I/O operations
|
|
193
|
+
* @param location - Resource location
|
|
194
|
+
* @param context - Semantic context
|
|
195
|
+
*/
|
|
196
|
+
resolve(transport: TransportHandler, location: string, context: SemanticContext): Promise<Resource<T>>;
|
|
197
|
+
/**
|
|
198
|
+
* Deposit resource to location
|
|
199
|
+
* Semantic controls how to serialize data and use transport primitives to store
|
|
200
|
+
*
|
|
201
|
+
* @param transport - Transport handler for I/O operations
|
|
202
|
+
* @param location - Resource location
|
|
203
|
+
* @param data - Data to deposit
|
|
204
|
+
* @param context - Semantic context
|
|
123
205
|
*/
|
|
124
|
-
|
|
206
|
+
deposit?(transport: TransportHandler, location: string, data: T, context: SemanticContext): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Check if resource exists at location
|
|
209
|
+
*
|
|
210
|
+
* @param transport - Transport handler for I/O operations
|
|
211
|
+
* @param location - Resource location
|
|
212
|
+
* @param context - Semantic context
|
|
213
|
+
*/
|
|
214
|
+
exists?(transport: TransportHandler, location: string, context: SemanticContext): Promise<boolean>;
|
|
215
|
+
/**
|
|
216
|
+
* Delete resource at location
|
|
217
|
+
*
|
|
218
|
+
* @param transport - Transport handler for I/O operations
|
|
219
|
+
* @param location - Resource location
|
|
220
|
+
* @param context - Semantic context
|
|
221
|
+
*/
|
|
222
|
+
delete?(transport: TransportHandler, location: string, context: SemanticContext): Promise<void>;
|
|
125
223
|
}
|
|
126
224
|
interface TextResource extends Resource<string> {
|
|
127
225
|
type: "text";
|
|
128
226
|
content: string;
|
|
129
227
|
}
|
|
130
228
|
declare class TextSemanticHandler implements SemanticHandler<string> {
|
|
131
|
-
readonly
|
|
132
|
-
|
|
229
|
+
readonly name = "text";
|
|
230
|
+
resolve(transport: TransportHandler, location: string, context: SemanticContext): Promise<TextResource>;
|
|
231
|
+
deposit(transport: TransportHandler, location: string, data: string, _context: SemanticContext): Promise<void>;
|
|
232
|
+
exists(transport: TransportHandler, location: string, _context: SemanticContext): Promise<boolean>;
|
|
233
|
+
delete(transport: TransportHandler, location: string, _context: SemanticContext): Promise<void>;
|
|
133
234
|
}
|
|
134
235
|
declare const textHandler: TextSemanticHandler;
|
|
236
|
+
interface BinaryResource extends Resource<Buffer> {
|
|
237
|
+
type: "binary";
|
|
238
|
+
content: Buffer;
|
|
239
|
+
}
|
|
135
240
|
/**
|
|
136
|
-
*
|
|
241
|
+
* Supported binary input types for deposit
|
|
137
242
|
*/
|
|
138
|
-
|
|
243
|
+
type BinaryInput = Buffer | Uint8Array | ArrayBuffer | number[];
|
|
244
|
+
declare class BinarySemanticHandler implements SemanticHandler<Buffer> {
|
|
245
|
+
readonly name = "binary";
|
|
246
|
+
resolve(transport: TransportHandler, location: string, context: SemanticContext): Promise<BinaryResource>;
|
|
247
|
+
deposit(transport: TransportHandler, location: string, data: BinaryInput, _context: SemanticContext): Promise<void>;
|
|
248
|
+
exists(transport: TransportHandler, location: string, _context: SemanticContext): Promise<boolean>;
|
|
249
|
+
delete(transport: TransportHandler, location: string, _context: SemanticContext): Promise<void>;
|
|
250
|
+
}
|
|
251
|
+
declare const binaryHandler: BinarySemanticHandler;
|
|
252
|
+
/**
|
|
253
|
+
* Get semantic handler by name
|
|
254
|
+
*/
|
|
255
|
+
declare function getSemanticHandler(name: string): SemanticHandler;
|
|
139
256
|
/**
|
|
140
257
|
* Register a custom semantic handler
|
|
141
258
|
*/
|
|
@@ -148,5 +265,64 @@ declare function registerSemanticHandler(handler: SemanticHandler): void;
|
|
|
148
265
|
* // { type: "text", content: "...", meta: { ... } }
|
|
149
266
|
*/
|
|
150
267
|
declare function resolve(url: string): Promise<Resource>;
|
|
268
|
+
/**
|
|
269
|
+
* Deposit data to an ARP URL
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* await deposit("arp:text:file://./data/config.txt", "hello world");
|
|
273
|
+
*/
|
|
274
|
+
declare function deposit(url: string, data: unknown): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Check if resource exists at ARP URL
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* const exists = await resourceExists("arp:text:file://./data/config.txt");
|
|
280
|
+
*/
|
|
281
|
+
declare function resourceExists(url: string): Promise<boolean>;
|
|
282
|
+
/**
|
|
283
|
+
* Delete resource at ARP URL
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* await resourceDelete("arp:text:file://./data/config.txt");
|
|
287
|
+
*/
|
|
288
|
+
declare function resourceDelete(url: string): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Resource Definition Types
|
|
291
|
+
*/
|
|
292
|
+
/**
|
|
293
|
+
* Definition of a custom resource (shortcut for ARP URL)
|
|
294
|
+
*/
|
|
295
|
+
interface ResourceDefinition {
|
|
296
|
+
/** Unique name for the resource (used in URL: name://location) */
|
|
297
|
+
readonly name: string;
|
|
298
|
+
/** Semantic type (e.g., "text", "json", "binary") */
|
|
299
|
+
readonly semantic: string;
|
|
300
|
+
/** Transport type (e.g., "file", "https") */
|
|
301
|
+
readonly transport: string;
|
|
302
|
+
/** Base path prepended to location (optional) */
|
|
303
|
+
readonly basePath?: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Create a new resource registry (isolated instance)
|
|
307
|
+
*/
|
|
308
|
+
declare function createResourceRegistry(): {
|
|
309
|
+
/**
|
|
310
|
+
* Register a resource definition
|
|
311
|
+
*/
|
|
312
|
+
register(definition: ResourceDefinition): void
|
|
313
|
+
/**
|
|
314
|
+
* Get a resource definition by name
|
|
315
|
+
*/
|
|
316
|
+
get(name: string): ResourceDefinition | undefined
|
|
317
|
+
/**
|
|
318
|
+
* Check if a resource is registered
|
|
319
|
+
*/
|
|
320
|
+
has(name: string): boolean
|
|
321
|
+
/**
|
|
322
|
+
* Clear all registered resources
|
|
323
|
+
*/
|
|
324
|
+
clear(): void
|
|
325
|
+
};
|
|
326
|
+
type ResourceRegistry = ReturnType<typeof createResourceRegistry>;
|
|
151
327
|
declare const VERSION: string;
|
|
152
|
-
export { textHandler, resolve, registerTransportHandler, registerSemanticHandler, parseARP, httpsHandler, httpHandler, getTransportHandler, getSemanticHandler, fileHandler, VERSION, TransportHandler, TransportError, TextResource, SemanticHandler, SemanticError, ResourceXError, ResourceMeta, Resource, ParsedARP, ParseError,
|
|
328
|
+
export { textHandler, resourceExists, resourceDelete, resolve, registerTransportHandler, registerSemanticHandler, parseARP, httpsHandler, httpHandler, getTransportHandler, getSemanticHandler, fileHandler, deposit, createResourceRegistry, binaryHandler, VERSION, TransportHandler, TransportError, TransportCapabilities, TextResource, SemanticHandler, SemanticError, SemanticContext, ResourceXError, ResourceStat, ResourceRegistry, ResourceMeta, ResourceDefinition, Resource, ParsedARP, ParseError, BinaryResource, BinaryInput };
|
package/dist/index.js
CHANGED
|
@@ -63,18 +63,25 @@ function parseARP(url) {
|
|
|
63
63
|
}
|
|
64
64
|
// src/transport/http.ts
|
|
65
65
|
class HttpTransportHandler {
|
|
66
|
-
|
|
66
|
+
name;
|
|
67
67
|
protocol;
|
|
68
|
+
capabilities = {
|
|
69
|
+
canRead: true,
|
|
70
|
+
canWrite: false,
|
|
71
|
+
canList: false,
|
|
72
|
+
canDelete: false,
|
|
73
|
+
canStat: false
|
|
74
|
+
};
|
|
68
75
|
constructor(protocol = "https") {
|
|
69
76
|
this.protocol = protocol;
|
|
70
|
-
this.
|
|
77
|
+
this.name = protocol;
|
|
71
78
|
}
|
|
72
|
-
async
|
|
79
|
+
async read(location) {
|
|
73
80
|
const url = `${this.protocol}://${location}`;
|
|
74
81
|
try {
|
|
75
82
|
const response = await fetch(url);
|
|
76
83
|
if (!response.ok) {
|
|
77
|
-
throw new TransportError(`HTTP ${response.status}: ${response.statusText} - ${url}`, this.
|
|
84
|
+
throw new TransportError(`HTTP ${response.status}: ${response.statusText} - ${url}`, this.name);
|
|
78
85
|
}
|
|
79
86
|
const arrayBuffer = await response.arrayBuffer();
|
|
80
87
|
return Buffer.from(arrayBuffer);
|
|
@@ -82,24 +89,106 @@ class HttpTransportHandler {
|
|
|
82
89
|
if (error instanceof TransportError) {
|
|
83
90
|
throw error;
|
|
84
91
|
}
|
|
85
|
-
throw new TransportError(`Network error: ${url}`, this.
|
|
92
|
+
throw new TransportError(`Network error: ${url}`, this.name, {
|
|
93
|
+
cause: error
|
|
94
|
+
});
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
98
|
var httpsHandler = new HttpTransportHandler("https");
|
|
90
99
|
var httpHandler = new HttpTransportHandler("http");
|
|
91
100
|
// src/transport/file.ts
|
|
92
|
-
import { readFile } from "node:fs/promises";
|
|
93
|
-
import { resolve } from "node:path";
|
|
101
|
+
import { readFile, writeFile, readdir, mkdir, rm, access, stat as fsStat } from "node:fs/promises";
|
|
102
|
+
import { resolve, dirname } from "node:path";
|
|
94
103
|
class FileTransportHandler {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
name = "file";
|
|
105
|
+
capabilities = {
|
|
106
|
+
canRead: true,
|
|
107
|
+
canWrite: true,
|
|
108
|
+
canList: true,
|
|
109
|
+
canDelete: true,
|
|
110
|
+
canStat: true
|
|
111
|
+
};
|
|
112
|
+
resolvePath(location) {
|
|
113
|
+
return resolve(process.cwd(), location);
|
|
114
|
+
}
|
|
115
|
+
async read(location) {
|
|
116
|
+
const filePath = this.resolvePath(location);
|
|
98
117
|
try {
|
|
99
118
|
return await readFile(filePath);
|
|
100
119
|
} catch (error) {
|
|
101
120
|
const err = error;
|
|
102
|
-
throw new TransportError(`File read error: ${err.code} - ${filePath}`, this.
|
|
121
|
+
throw new TransportError(`File read error: ${err.code} - ${filePath}`, this.name, {
|
|
122
|
+
cause: err
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async write(location, content) {
|
|
127
|
+
const filePath = this.resolvePath(location);
|
|
128
|
+
try {
|
|
129
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
130
|
+
await writeFile(filePath, content);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
const err = error;
|
|
133
|
+
throw new TransportError(`File write error: ${err.code} - ${filePath}`, this.name, {
|
|
134
|
+
cause: err
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async list(location) {
|
|
139
|
+
const dirPath = this.resolvePath(location);
|
|
140
|
+
try {
|
|
141
|
+
return await readdir(dirPath);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const err = error;
|
|
144
|
+
throw new TransportError(`Directory list error: ${err.code} - ${dirPath}`, this.name, {
|
|
145
|
+
cause: err
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async mkdir(location) {
|
|
150
|
+
const dirPath = this.resolvePath(location);
|
|
151
|
+
try {
|
|
152
|
+
await mkdir(dirPath, { recursive: true });
|
|
153
|
+
} catch (error) {
|
|
154
|
+
const err = error;
|
|
155
|
+
throw new TransportError(`Directory create error: ${err.code} - ${dirPath}`, this.name, {
|
|
156
|
+
cause: err
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async exists(location) {
|
|
161
|
+
const filePath = this.resolvePath(location);
|
|
162
|
+
try {
|
|
163
|
+
await access(filePath);
|
|
164
|
+
return true;
|
|
165
|
+
} catch {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async stat(location) {
|
|
170
|
+
const filePath = this.resolvePath(location);
|
|
171
|
+
try {
|
|
172
|
+
const stats = await fsStat(filePath);
|
|
173
|
+
return {
|
|
174
|
+
size: stats.size,
|
|
175
|
+
modifiedAt: stats.mtime,
|
|
176
|
+
isDirectory: stats.isDirectory()
|
|
177
|
+
};
|
|
178
|
+
} catch (error) {
|
|
179
|
+
const err = error;
|
|
180
|
+
throw new TransportError(`File stat error: ${err.code} - ${filePath}`, this.name, {
|
|
181
|
+
cause: err
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async delete(location) {
|
|
186
|
+
const filePath = this.resolvePath(location);
|
|
187
|
+
try {
|
|
188
|
+
await rm(filePath, { recursive: true });
|
|
189
|
+
} catch (error) {
|
|
190
|
+
const err = error;
|
|
191
|
+
throw new TransportError(`File delete error: ${err.code} - ${filePath}`, this.name, {
|
|
103
192
|
cause: err
|
|
104
193
|
});
|
|
105
194
|
}
|
|
@@ -112,30 +201,31 @@ var handlers = new Map([
|
|
|
112
201
|
["http", httpHandler],
|
|
113
202
|
["file", fileHandler]
|
|
114
203
|
]);
|
|
115
|
-
function getTransportHandler(
|
|
116
|
-
const handler = handlers.get(
|
|
204
|
+
function getTransportHandler(name) {
|
|
205
|
+
const handler = handlers.get(name);
|
|
117
206
|
if (!handler) {
|
|
118
|
-
throw new TransportError(`Unsupported transport type: ${
|
|
207
|
+
throw new TransportError(`Unsupported transport type: ${name}`, name);
|
|
119
208
|
}
|
|
120
209
|
return handler;
|
|
121
210
|
}
|
|
122
211
|
function registerTransportHandler(handler) {
|
|
123
|
-
handlers.set(handler.
|
|
212
|
+
handlers.set(handler.name, handler);
|
|
124
213
|
}
|
|
125
214
|
// src/semantic/text.ts
|
|
126
215
|
class TextSemanticHandler {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
216
|
+
name = "text";
|
|
217
|
+
async resolve(transport, location, context) {
|
|
218
|
+
const buffer = await transport.read(location);
|
|
219
|
+
const text = buffer.toString("utf-8");
|
|
130
220
|
const meta = {
|
|
131
221
|
url: context.url,
|
|
132
222
|
semantic: context.semantic,
|
|
133
223
|
transport: context.transport,
|
|
134
224
|
location: context.location,
|
|
135
|
-
size:
|
|
225
|
+
size: buffer.length,
|
|
136
226
|
encoding: "utf-8",
|
|
137
227
|
mimeType: "text/plain",
|
|
138
|
-
|
|
228
|
+
resolvedAt: context.timestamp.toISOString()
|
|
139
229
|
};
|
|
140
230
|
return {
|
|
141
231
|
type: "text",
|
|
@@ -143,41 +233,195 @@ class TextSemanticHandler {
|
|
|
143
233
|
meta
|
|
144
234
|
};
|
|
145
235
|
}
|
|
236
|
+
async deposit(transport, location, data, _context) {
|
|
237
|
+
if (!transport.write) {
|
|
238
|
+
throw new SemanticError(`Transport "${transport.name}" does not support write operation`, this.name);
|
|
239
|
+
}
|
|
240
|
+
const buffer = Buffer.from(data, "utf-8");
|
|
241
|
+
await transport.write(location, buffer);
|
|
242
|
+
}
|
|
243
|
+
async exists(transport, location, _context) {
|
|
244
|
+
if (transport.exists) {
|
|
245
|
+
return transport.exists(location);
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
await transport.read(location);
|
|
249
|
+
return true;
|
|
250
|
+
} catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async delete(transport, location, _context) {
|
|
255
|
+
if (!transport.delete) {
|
|
256
|
+
throw new SemanticError(`Transport "${transport.name}" does not support delete operation`, this.name);
|
|
257
|
+
}
|
|
258
|
+
await transport.delete(location);
|
|
259
|
+
}
|
|
146
260
|
}
|
|
147
261
|
var textHandler = new TextSemanticHandler;
|
|
262
|
+
// src/semantic/binary.ts
|
|
263
|
+
function toBuffer(data) {
|
|
264
|
+
if (Buffer.isBuffer(data)) {
|
|
265
|
+
return data;
|
|
266
|
+
}
|
|
267
|
+
if (data instanceof Uint8Array) {
|
|
268
|
+
return Buffer.from(data);
|
|
269
|
+
}
|
|
270
|
+
if (data instanceof ArrayBuffer) {
|
|
271
|
+
return Buffer.from(data);
|
|
272
|
+
}
|
|
273
|
+
if (Array.isArray(data)) {
|
|
274
|
+
return Buffer.from(data);
|
|
275
|
+
}
|
|
276
|
+
throw new SemanticError(`Unsupported binary input type`, "binary");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
class BinarySemanticHandler {
|
|
280
|
+
name = "binary";
|
|
281
|
+
async resolve(transport, location, context) {
|
|
282
|
+
const buffer = await transport.read(location);
|
|
283
|
+
const meta = {
|
|
284
|
+
url: context.url,
|
|
285
|
+
semantic: context.semantic,
|
|
286
|
+
transport: context.transport,
|
|
287
|
+
location: context.location,
|
|
288
|
+
size: buffer.length,
|
|
289
|
+
resolvedAt: context.timestamp.toISOString()
|
|
290
|
+
};
|
|
291
|
+
return {
|
|
292
|
+
type: "binary",
|
|
293
|
+
content: buffer,
|
|
294
|
+
meta
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
async deposit(transport, location, data, _context) {
|
|
298
|
+
if (!transport.write) {
|
|
299
|
+
throw new SemanticError(`Transport "${transport.name}" does not support write operation`, this.name);
|
|
300
|
+
}
|
|
301
|
+
const buffer = toBuffer(data);
|
|
302
|
+
await transport.write(location, buffer);
|
|
303
|
+
}
|
|
304
|
+
async exists(transport, location, _context) {
|
|
305
|
+
if (transport.exists) {
|
|
306
|
+
return transport.exists(location);
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
await transport.read(location);
|
|
310
|
+
return true;
|
|
311
|
+
} catch {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async delete(transport, location, _context) {
|
|
316
|
+
if (!transport.delete) {
|
|
317
|
+
throw new SemanticError(`Transport "${transport.name}" does not support delete operation`, this.name);
|
|
318
|
+
}
|
|
319
|
+
await transport.delete(location);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
var binaryHandler = new BinarySemanticHandler;
|
|
148
323
|
// src/semantic/index.ts
|
|
149
|
-
var handlers2 = new Map([
|
|
150
|
-
|
|
151
|
-
|
|
324
|
+
var handlers2 = new Map([
|
|
325
|
+
["text", textHandler],
|
|
326
|
+
["binary", binaryHandler]
|
|
327
|
+
]);
|
|
328
|
+
function getSemanticHandler(name) {
|
|
329
|
+
const handler = handlers2.get(name);
|
|
152
330
|
if (!handler) {
|
|
153
|
-
throw new SemanticError(`Unsupported semantic type: ${
|
|
331
|
+
throw new SemanticError(`Unsupported semantic type: ${name}`, name);
|
|
154
332
|
}
|
|
155
333
|
return handler;
|
|
156
334
|
}
|
|
157
335
|
function registerSemanticHandler(handler) {
|
|
158
|
-
handlers2.set(handler.
|
|
336
|
+
handlers2.set(handler.name, handler);
|
|
159
337
|
}
|
|
160
338
|
// src/resolve.ts
|
|
339
|
+
function createContext(url, semantic, transport, location) {
|
|
340
|
+
return {
|
|
341
|
+
url,
|
|
342
|
+
semantic,
|
|
343
|
+
transport,
|
|
344
|
+
location,
|
|
345
|
+
timestamp: new Date
|
|
346
|
+
};
|
|
347
|
+
}
|
|
161
348
|
async function resolve2(url) {
|
|
162
|
-
const fetchedAt = new Date;
|
|
163
349
|
const parsed = parseARP(url);
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
350
|
+
const transport = getTransportHandler(parsed.transport);
|
|
351
|
+
const semantic = getSemanticHandler(parsed.semantic);
|
|
352
|
+
const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);
|
|
353
|
+
return semantic.resolve(transport, parsed.location, context);
|
|
354
|
+
}
|
|
355
|
+
async function deposit(url, data) {
|
|
356
|
+
const parsed = parseARP(url);
|
|
357
|
+
const transport = getTransportHandler(parsed.transport);
|
|
358
|
+
const semantic = getSemanticHandler(parsed.semantic);
|
|
359
|
+
if (!semantic.deposit) {
|
|
360
|
+
throw new SemanticError(`Semantic "${semantic.name}" does not support deposit operation`, parsed.semantic);
|
|
361
|
+
}
|
|
362
|
+
const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);
|
|
363
|
+
await semantic.deposit(transport, parsed.location, data, context);
|
|
364
|
+
}
|
|
365
|
+
async function resourceExists(url) {
|
|
366
|
+
const parsed = parseARP(url);
|
|
367
|
+
const transport = getTransportHandler(parsed.transport);
|
|
368
|
+
const semantic = getSemanticHandler(parsed.semantic);
|
|
369
|
+
const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);
|
|
370
|
+
if (semantic.exists) {
|
|
371
|
+
return semantic.exists(transport, parsed.location, context);
|
|
372
|
+
}
|
|
373
|
+
if (transport.exists) {
|
|
374
|
+
return transport.exists(parsed.location);
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
await transport.read(parsed.location);
|
|
378
|
+
return true;
|
|
379
|
+
} catch {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async function resourceDelete(url) {
|
|
384
|
+
const parsed = parseARP(url);
|
|
385
|
+
const transport = getTransportHandler(parsed.transport);
|
|
386
|
+
const semantic = getSemanticHandler(parsed.semantic);
|
|
387
|
+
const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);
|
|
388
|
+
if (semantic.delete) {
|
|
389
|
+
return semantic.delete(transport, parsed.location, context);
|
|
390
|
+
}
|
|
391
|
+
if (!transport.delete) {
|
|
392
|
+
throw new SemanticError(`Neither semantic "${semantic.name}" nor transport "${transport.name}" supports delete operation`, parsed.semantic);
|
|
393
|
+
}
|
|
394
|
+
await transport.delete(parsed.location);
|
|
395
|
+
}
|
|
396
|
+
// src/resource/registry.ts
|
|
397
|
+
function createResourceRegistry() {
|
|
398
|
+
const registry = new Map;
|
|
399
|
+
return {
|
|
400
|
+
register(definition) {
|
|
401
|
+
if (!/^[a-z][a-z0-9-]*$/.test(definition.name)) {
|
|
402
|
+
throw new ParseError(`Invalid resource name: "${definition.name}". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`, definition.name);
|
|
403
|
+
}
|
|
404
|
+
getSemanticHandler(definition.semantic);
|
|
405
|
+
getTransportHandler(definition.transport);
|
|
406
|
+
registry.set(definition.name, definition);
|
|
407
|
+
},
|
|
408
|
+
get(name) {
|
|
409
|
+
return registry.get(name);
|
|
410
|
+
},
|
|
411
|
+
has(name) {
|
|
412
|
+
return registry.has(name);
|
|
413
|
+
},
|
|
414
|
+
clear() {
|
|
415
|
+
registry.clear();
|
|
416
|
+
}
|
|
173
417
|
};
|
|
174
|
-
return semanticHandler.parse(content, context);
|
|
175
418
|
}
|
|
176
|
-
|
|
177
419
|
// src/index.ts
|
|
178
|
-
var VERSION = "0.0
|
|
420
|
+
var VERSION = "0.2.0";
|
|
179
421
|
export {
|
|
180
422
|
textHandler,
|
|
423
|
+
resourceExists,
|
|
424
|
+
resourceDelete,
|
|
181
425
|
resolve2 as resolve,
|
|
182
426
|
registerTransportHandler,
|
|
183
427
|
registerSemanticHandler,
|
|
@@ -187,6 +431,9 @@ export {
|
|
|
187
431
|
getTransportHandler,
|
|
188
432
|
getSemanticHandler,
|
|
189
433
|
fileHandler,
|
|
434
|
+
deposit,
|
|
435
|
+
createResourceRegistry,
|
|
436
|
+
binaryHandler,
|
|
190
437
|
VERSION,
|
|
191
438
|
TransportError,
|
|
192
439
|
SemanticError,
|
|
@@ -194,4 +441,4 @@ export {
|
|
|
194
441
|
ParseError
|
|
195
442
|
};
|
|
196
443
|
|
|
197
|
-
//# debugId=
|
|
444
|
+
//# debugId=2B754A97DA9C772F64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/errors.ts", "../src/parser.ts", "../src/transport/http.ts", "../src/transport/file.ts", "../src/transport/index.ts", "../src/semantic/text.ts", "../src/semantic/index.ts", "../src/resolve.ts", "../src/index.ts"],
|
|
3
|
+
"sources": ["../src/errors.ts", "../src/parser.ts", "../src/transport/http.ts", "../src/transport/file.ts", "../src/transport/index.ts", "../src/semantic/text.ts", "../src/semantic/binary.ts", "../src/semantic/index.ts", "../src/resolve.ts", "../src/resource/registry.ts", "../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * ResourceX Error Types\n */\n\n/**\n * Base error class for all ResourceX errors\n */\nexport class ResourceXError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"ResourceXError\";\n }\n}\n\n/**\n * Error thrown when ARP URL parsing fails\n */\nexport class ParseError extends ResourceXError {\n constructor(\n message: string,\n public readonly url?: string\n ) {\n super(message);\n this.name = \"ParseError\";\n }\n}\n\n/**\n * Error thrown when transport layer fails\n */\nexport class TransportError extends ResourceXError {\n constructor(\n message: string,\n public readonly transport?: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = \"TransportError\";\n }\n}\n\n/**\n * Error thrown when semantic layer fails\n */\nexport class SemanticError extends ResourceXError {\n constructor(\n message: string,\n public readonly semantic?: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = \"SemanticError\";\n }\n}\n",
|
|
6
6
|
"/**\n * ARP URL Parser\n * Format: arp:{semantic}:{transport}://{location}\n */\n\nimport { ParseError } from \"./errors.js\";\n\nexport interface ParsedARP {\n semantic: string;\n transport: string;\n location: string;\n}\n\n/**\n * Parse an ARP URL into its components\n *\n * @example\n * parseARP(\"arp:text:https://example.com/file.txt\")\n * // { semantic: \"text\", transport: \"https\", location: \"example.com/file.txt\" }\n */\nexport function parseARP(url: string): ParsedARP {\n // 1. Check protocol prefix\n if (!url.startsWith(\"arp:\")) {\n throw new ParseError(`Invalid ARP URL: must start with \"arp:\"`, url);\n }\n\n const content = url.substring(4); // Remove \"arp:\"\n\n // 2. Find :// separator\n const separatorIndex = content.indexOf(\"://\");\n if (separatorIndex === -1) {\n throw new ParseError(`Invalid ARP URL: missing \"://\"`, url);\n }\n\n const typePart = content.substring(0, separatorIndex);\n const location = content.substring(separatorIndex + 3);\n\n // 3. Split type part by :\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\n const semantic = typePart.substring(0, colonIndex);\n const transport = typePart.substring(colonIndex + 1);\n\n // 4. Validate non-empty\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\n return { semantic, transport, location };\n}\n",
|
|
7
|
-
"/**\n * HTTP/HTTPS Transport Handler\n */\n\nimport { TransportError } from \"../errors.js\";\nimport type { TransportHandler } from \"./types.js\";\n\nexport class HttpTransportHandler implements TransportHandler {\n readonly
|
|
8
|
-
"/**\n * File Transport Handler\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { TransportError } from \"../errors.js\";\nimport type { TransportHandler } from \"./types.js\";\n\nexport class FileTransportHandler implements TransportHandler {\n readonly
|
|
9
|
-
"/**\n * Transport Handlers Registry\n */\n\nimport { TransportError } from \"../errors.js\";\n\nexport type { TransportHandler } from \"./types.js\";\nexport { HttpTransportHandler, httpsHandler, httpHandler } from \"./http.js\";\nexport { FileTransportHandler, fileHandler } from \"./file.js\";\n\nimport type { TransportHandler } from \"./types.js\";\nimport { httpsHandler, httpHandler } from \"./http.js\";\nimport { fileHandler } from \"./file.js\";\n\nconst handlers = new Map<string, TransportHandler>([\n [\"https\", httpsHandler],\n [\"http\", httpHandler],\n [\"file\", fileHandler],\n]);\n\n/**\n * Get transport handler by
|
|
10
|
-
"/**\n * Text Semantic Handler\n * Handles plain text resources\n */\n\nimport type { Resource, SemanticHandler,
|
|
11
|
-
"/**\n * Semantic
|
|
12
|
-
"/**\n *
|
|
13
|
-
"/**\n *
|
|
7
|
+
"/**\n * HTTP/HTTPS Transport Handler\n * Provides read-only I/O primitives for HTTP resources\n */\n\nimport { TransportError } from \"../errors.js\";\nimport type { TransportHandler, TransportCapabilities } from \"./types.js\";\n\nexport class HttpTransportHandler implements TransportHandler {\n readonly name: string;\n private readonly protocol: \"http\" | \"https\";\n\n readonly capabilities: TransportCapabilities = {\n canRead: true,\n canWrite: false,\n canList: false,\n canDelete: false,\n canStat: false,\n };\n\n constructor(protocol: \"http\" | \"https\" = \"https\") {\n this.protocol = protocol;\n this.name = protocol;\n }\n\n async read(location: string): Promise<Buffer> {\n const url = `${this.protocol}://${location}`;\n\n try {\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new TransportError(\n `HTTP ${response.status}: ${response.statusText} - ${url}`,\n this.name\n );\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n } catch (error) {\n if (error instanceof TransportError) {\n throw error;\n }\n throw new TransportError(`Network error: ${url}`, this.name, {\n cause: error as Error,\n });\n }\n }\n\n // HTTP transport is read-only, write/list/delete are not implemented\n}\n\nexport const httpsHandler: HttpTransportHandler = new HttpTransportHandler(\"https\");\nexport const httpHandler: HttpTransportHandler = new HttpTransportHandler(\"http\");\n",
|
|
8
|
+
"/**\n * File Transport Handler\n * Provides I/O primitives for local filesystem\n */\n\nimport { readFile, writeFile, readdir, mkdir, rm, access, stat as fsStat } from \"node:fs/promises\";\nimport { resolve, dirname } from \"node:path\";\nimport { TransportError } from \"../errors.js\";\nimport type { TransportHandler, TransportCapabilities, ResourceStat } from \"./types.js\";\n\nexport class FileTransportHandler implements TransportHandler {\n readonly name = \"file\";\n\n readonly capabilities: TransportCapabilities = {\n canRead: true,\n canWrite: true,\n canList: true,\n canDelete: true,\n canStat: true,\n };\n\n private resolvePath(location: string): string {\n return resolve(process.cwd(), location);\n }\n\n async read(location: string): Promise<Buffer> {\n const filePath = this.resolvePath(location);\n\n try {\n return await readFile(filePath);\n } catch (error) {\n const err = error as Error & { code?: string };\n throw new TransportError(`File read error: ${err.code} - ${filePath}`, this.name, {\n cause: err,\n });\n }\n }\n\n async write(location: string, content: Buffer): Promise<void> {\n const filePath = this.resolvePath(location);\n\n try {\n // Ensure directory exists\n await mkdir(dirname(filePath), { recursive: true });\n await writeFile(filePath, content);\n } catch (error) {\n const err = error as Error & { code?: string };\n throw new TransportError(`File write error: ${err.code} - ${filePath}`, this.name, {\n cause: err,\n });\n }\n }\n\n async list(location: string): Promise<string[]> {\n const dirPath = this.resolvePath(location);\n\n try {\n return await readdir(dirPath);\n } catch (error) {\n const err = error as Error & { code?: string };\n throw new TransportError(`Directory list error: ${err.code} - ${dirPath}`, this.name, {\n cause: err,\n });\n }\n }\n\n async mkdir(location: string): Promise<void> {\n const dirPath = this.resolvePath(location);\n\n try {\n await mkdir(dirPath, { recursive: true });\n } catch (error) {\n const err = error as Error & { code?: string };\n throw new TransportError(`Directory create error: ${err.code} - ${dirPath}`, this.name, {\n cause: err,\n });\n }\n }\n\n async exists(location: string): Promise<boolean> {\n const filePath = this.resolvePath(location);\n\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n }\n\n async stat(location: string): Promise<ResourceStat> {\n const filePath = this.resolvePath(location);\n\n try {\n const stats = await fsStat(filePath);\n return {\n size: stats.size,\n modifiedAt: stats.mtime,\n isDirectory: stats.isDirectory(),\n };\n } catch (error) {\n const err = error as Error & { code?: string };\n throw new TransportError(`File stat error: ${err.code} - ${filePath}`, this.name, {\n cause: err,\n });\n }\n }\n\n async delete(location: string): Promise<void> {\n const filePath = this.resolvePath(location);\n\n try {\n await rm(filePath, { recursive: true });\n } catch (error) {\n const err = error as Error & { code?: string };\n throw new TransportError(`File delete error: ${err.code} - ${filePath}`, this.name, {\n cause: err,\n });\n }\n }\n}\n\nexport const fileHandler: FileTransportHandler = new FileTransportHandler();\n",
|
|
9
|
+
"/**\n * Transport Handlers Registry\n */\n\nimport { TransportError } from \"../errors.js\";\n\nexport type { TransportHandler, TransportCapabilities, ResourceStat } from \"./types.js\";\nexport { HttpTransportHandler, httpsHandler, httpHandler } from \"./http.js\";\nexport { FileTransportHandler, fileHandler } from \"./file.js\";\n\nimport type { TransportHandler } from \"./types.js\";\nimport { httpsHandler, httpHandler } from \"./http.js\";\nimport { fileHandler } from \"./file.js\";\n\nconst handlers = new Map<string, TransportHandler>([\n [\"https\", httpsHandler],\n [\"http\", httpHandler],\n [\"file\", fileHandler],\n]);\n\n/**\n * Get transport handler by name\n */\nexport function getTransportHandler(name: string): TransportHandler {\n const handler = handlers.get(name);\n if (!handler) {\n throw new TransportError(`Unsupported transport type: ${name}`, name);\n }\n return handler;\n}\n\n/**\n * Register a custom transport handler\n */\nexport function registerTransportHandler(handler: TransportHandler): void {\n handlers.set(handler.name, handler);\n}\n",
|
|
10
|
+
"/**\n * Text Semantic Handler\n * Handles plain text resources\n */\n\nimport { SemanticError } from \"../errors.js\";\nimport type { TransportHandler } from \"../transport/types.js\";\nimport type { Resource, SemanticHandler, SemanticContext, ResourceMeta } from \"./types.js\";\n\nexport interface TextResource extends Resource<string> {\n type: \"text\";\n content: string;\n}\n\nexport class TextSemanticHandler implements SemanticHandler<string> {\n readonly name = \"text\";\n\n async resolve(\n transport: TransportHandler,\n location: string,\n context: SemanticContext\n ): Promise<TextResource> {\n const buffer = await transport.read(location);\n const text = buffer.toString(\"utf-8\");\n\n const meta: ResourceMeta = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: buffer.length,\n encoding: \"utf-8\",\n mimeType: \"text/plain\",\n resolvedAt: context.timestamp.toISOString(),\n };\n\n return {\n type: \"text\",\n content: text,\n meta,\n };\n }\n\n async deposit(\n transport: TransportHandler,\n location: string,\n data: string,\n _context: SemanticContext\n ): Promise<void> {\n if (!transport.write) {\n throw new SemanticError(\n `Transport \"${transport.name}\" does not support write operation`,\n this.name\n );\n }\n\n const buffer = Buffer.from(data, \"utf-8\");\n await transport.write(location, buffer);\n }\n\n async exists(\n transport: TransportHandler,\n location: string,\n _context: SemanticContext\n ): Promise<boolean> {\n if (transport.exists) {\n return transport.exists(location);\n }\n\n // Fallback: try to read\n try {\n await transport.read(location);\n return true;\n } catch {\n return false;\n }\n }\n\n async delete(\n transport: TransportHandler,\n location: string,\n _context: SemanticContext\n ): Promise<void> {\n if (!transport.delete) {\n throw new SemanticError(\n `Transport \"${transport.name}\" does not support delete operation`,\n this.name\n );\n }\n\n await transport.delete(location);\n }\n}\n\nexport const textHandler: TextSemanticHandler = new TextSemanticHandler();\n",
|
|
11
|
+
"/**\n * Binary Semantic Handler\n * Handles raw binary resources without any transformation\n */\n\nimport { SemanticError } from \"../errors.js\";\nimport type { TransportHandler } from \"../transport/types.js\";\nimport type { Resource, SemanticHandler, SemanticContext, ResourceMeta } from \"./types.js\";\n\nexport interface BinaryResource extends Resource<Buffer> {\n type: \"binary\";\n content: Buffer;\n}\n\n/**\n * Supported binary input types for deposit\n */\nexport type BinaryInput = Buffer | Uint8Array | ArrayBuffer | number[];\n\n/**\n * Convert various binary input types to Buffer\n */\nfunction toBuffer(data: BinaryInput): Buffer {\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\nexport class BinarySemanticHandler implements SemanticHandler<Buffer> {\n readonly name = \"binary\";\n\n async resolve(\n transport: TransportHandler,\n location: string,\n context: SemanticContext\n ): Promise<BinaryResource> {\n const buffer = await transport.read(location);\n\n const meta: ResourceMeta = {\n url: context.url,\n semantic: context.semantic,\n transport: context.transport,\n location: context.location,\n size: buffer.length,\n resolvedAt: context.timestamp.toISOString(),\n };\n\n return {\n type: \"binary\",\n content: buffer,\n meta,\n };\n }\n\n async deposit(\n transport: TransportHandler,\n location: string,\n data: BinaryInput,\n _context: SemanticContext\n ): Promise<void> {\n if (!transport.write) {\n throw new SemanticError(\n `Transport \"${transport.name}\" does not support write operation`,\n this.name\n );\n }\n\n const buffer = toBuffer(data);\n await transport.write(location, buffer);\n }\n\n async exists(\n transport: TransportHandler,\n location: string,\n _context: SemanticContext\n ): Promise<boolean> {\n if (transport.exists) {\n return transport.exists(location);\n }\n\n // Fallback: try to read\n try {\n await transport.read(location);\n return true;\n } catch {\n return false;\n }\n }\n\n async delete(\n transport: TransportHandler,\n location: string,\n _context: SemanticContext\n ): Promise<void> {\n if (!transport.delete) {\n throw new SemanticError(\n `Transport \"${transport.name}\" does not support delete operation`,\n this.name\n );\n }\n\n await transport.delete(location);\n }\n}\n\nexport const binaryHandler: BinarySemanticHandler = new BinarySemanticHandler();\n",
|
|
12
|
+
"/**\n * Semantic Handlers Registry\n */\n\nimport { SemanticError } from \"../errors.js\";\n\nexport type { Resource, SemanticHandler, ResourceMeta, SemanticContext } from \"./types.js\";\nexport type { TextResource } from \"./text.js\";\nexport type { BinaryResource, BinaryInput } from \"./binary.js\";\nexport { TextSemanticHandler, textHandler } from \"./text.js\";\nexport { BinarySemanticHandler, binaryHandler } from \"./binary.js\";\n\nimport type { SemanticHandler } from \"./types.js\";\nimport { textHandler } from \"./text.js\";\nimport { binaryHandler } from \"./binary.js\";\n\nconst handlers = new Map<string, SemanticHandler>([\n [\"text\", textHandler],\n [\"binary\", binaryHandler],\n]);\n\n/**\n * Get semantic handler by name\n */\nexport function getSemanticHandler(name: string): SemanticHandler {\n const handler = handlers.get(name);\n if (!handler) {\n throw new SemanticError(`Unsupported semantic type: ${name}`, name);\n }\n return handler;\n}\n\n/**\n * Register a custom semantic handler\n */\nexport function registerSemanticHandler(handler: SemanticHandler): void {\n handlers.set(handler.name, handler);\n}\n",
|
|
13
|
+
"/**\n * Resource Operations\n * End-to-end flows for resolve/deposit/exists/delete\n *\n * New Architecture:\n * - Transport provides I/O primitives (read/write/list/exists/delete)\n * - Semantic orchestrates Transport primitives to handle resource semantics\n * - This module coordinates Transport + Semantic based on parsed URL\n */\n\nimport { parseARP } from \"./parser.js\";\nimport { getTransportHandler } from \"./transport/index.js\";\nimport { getSemanticHandler, type Resource, type SemanticContext } from \"./semantic/index.js\";\nimport { SemanticError } from \"./errors.js\";\n\n/**\n * Create semantic context from parsed URL\n */\nfunction createContext(\n url: string,\n semantic: string,\n transport: string,\n location: string\n): SemanticContext {\n return {\n url,\n semantic,\n transport,\n location,\n timestamp: new Date(),\n };\n}\n\n/**\n * Resolve an ARP URL to a resource\n *\n * @example\n * const resource = await resolve(\"arp:text:https://example.com/file.txt\");\n * // { type: \"text\", content: \"...\", meta: { ... } }\n */\nexport async function resolve(url: string): Promise<Resource> {\n const parsed = parseARP(url);\n\n const transport = getTransportHandler(parsed.transport);\n const semantic = getSemanticHandler(parsed.semantic);\n\n const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);\n\n // Semantic controls the resolve flow\n return semantic.resolve(transport, parsed.location, context);\n}\n\n/**\n * Deposit data to an ARP URL\n *\n * @example\n * await deposit(\"arp:text:file://./data/config.txt\", \"hello world\");\n */\nexport async function deposit(url: string, data: unknown): Promise<void> {\n const parsed = parseARP(url);\n\n const transport = getTransportHandler(parsed.transport);\n const semantic = getSemanticHandler(parsed.semantic);\n\n if (!semantic.deposit) {\n throw new SemanticError(\n `Semantic \"${semantic.name}\" does not support deposit operation`,\n parsed.semantic\n );\n }\n\n const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);\n\n // Semantic controls the deposit flow\n await semantic.deposit(transport, parsed.location, data, context);\n}\n\n/**\n * Check if resource exists at ARP URL\n *\n * @example\n * const exists = await resourceExists(\"arp:text:file://./data/config.txt\");\n */\nexport async function resourceExists(url: string): Promise<boolean> {\n const parsed = parseARP(url);\n\n const transport = getTransportHandler(parsed.transport);\n const semantic = getSemanticHandler(parsed.semantic);\n\n const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);\n\n if (semantic.exists) {\n return semantic.exists(transport, parsed.location, context);\n }\n\n // Fallback to transport exists if semantic doesn't implement it\n if (transport.exists) {\n return transport.exists(parsed.location);\n }\n\n // Fallback: try to read\n try {\n await transport.read(parsed.location);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Delete resource at ARP URL\n *\n * @example\n * await resourceDelete(\"arp:text:file://./data/config.txt\");\n */\nexport async function resourceDelete(url: string): Promise<void> {\n const parsed = parseARP(url);\n\n const transport = getTransportHandler(parsed.transport);\n const semantic = getSemanticHandler(parsed.semantic);\n\n const context = createContext(url, parsed.semantic, parsed.transport, parsed.location);\n\n if (semantic.delete) {\n return semantic.delete(transport, parsed.location, context);\n }\n\n // Fallback to transport delete\n if (!transport.delete) {\n throw new SemanticError(\n `Neither semantic \"${semantic.name}\" nor transport \"${transport.name}\" supports delete operation`,\n parsed.semantic\n );\n }\n\n await transport.delete(parsed.location);\n}\n",
|
|
14
|
+
"/**\n * Resource Registry\n */\n\nimport { ParseError } from \"../errors.js\";\nimport { getSemanticHandler } from \"../semantic/index.js\";\nimport { getTransportHandler } from \"../transport/index.js\";\nimport type { ResourceDefinition } from \"./types.js\";\n\n/**\n * Create a new resource registry (isolated instance)\n */\nexport function createResourceRegistry() {\n const registry = new Map<string, ResourceDefinition>();\n\n return {\n /**\n * Register a resource definition\n */\n register(definition: ResourceDefinition): void {\n // Validate name format\n if (!/^[a-z][a-z0-9-]*$/.test(definition.name)) {\n throw new ParseError(\n `Invalid resource name: \"${definition.name}\". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`,\n definition.name\n );\n }\n\n // Validate semantic exists\n getSemanticHandler(definition.semantic);\n\n // Validate transport exists\n getTransportHandler(definition.transport);\n\n registry.set(definition.name, definition);\n },\n\n /**\n * Get a resource definition by name\n */\n get(name: string): ResourceDefinition | undefined {\n return registry.get(name);\n },\n\n /**\n * Check if a resource is registered\n */\n has(name: string): boolean {\n return registry.has(name);\n },\n\n /**\n * Clear all registered resources\n */\n clear(): void {\n registry.clear();\n },\n };\n}\n\nexport type ResourceRegistry = ReturnType<typeof createResourceRegistry>;\n",
|
|
15
|
+
"/**\n * @resourcexjs/core\n * ARP (Agent Resource Protocol) implementation\n */\n\ndeclare const __VERSION__: string;\nexport const VERSION: string = __VERSION__;\n\n// Errors\nexport { ResourceXError, ParseError, TransportError, SemanticError } from \"./errors.js\";\n\n// Parser\nexport { parseARP, type ParsedARP } from \"./parser.js\";\n\n// Transport\nexport {\n type TransportHandler,\n type TransportCapabilities,\n type ResourceStat,\n getTransportHandler,\n registerTransportHandler,\n httpsHandler,\n httpHandler,\n fileHandler,\n} from \"./transport/index.js\";\n\n// Semantic\nexport {\n type Resource,\n type SemanticHandler,\n type ResourceMeta,\n type SemanticContext,\n type TextResource,\n type BinaryResource,\n type BinaryInput,\n getSemanticHandler,\n registerSemanticHandler,\n textHandler,\n binaryHandler,\n} from \"./semantic/index.js\";\n\n// Resource Operations\nexport { resolve, deposit, resourceExists, resourceDelete } from \"./resolve.js\";\n\n// Resource Definition\nexport {\n type ResourceDefinition,\n type ResourceRegistry,\n createResourceRegistry,\n} from \"./resource/index.js\";\n"
|
|
14
16
|
],
|
|
15
|
-
"mappings": ";AAOO,MAAM,uBAAuB,MAAM;AAAA,EACxC,WAAW,CAAC,SAAiB,SAAwB;AAAA,IACnD,MAAM,SAAS,OAAO;AAAA,IACtB,KAAK,OAAO;AAAA;AAEhB;AAAA;AAKO,MAAM,mBAAmB,eAAe;AAAA,EAG3B;AAAA,EAFlB,WAAW,CACT,SACgB,KAChB;AAAA,IACA,MAAM,OAAO;AAAA,IAFG;AAAA,IAGhB,KAAK,OAAO;AAAA;AAEhB;AAAA;AAKO,MAAM,uBAAuB,eAAe;AAAA,EAG/B;AAAA,EAFlB,WAAW,CACT,SACgB,WAChB,SACA;AAAA,IACA,MAAM,SAAS,OAAO;AAAA,IAHN;AAAA,IAIhB,KAAK,OAAO;AAAA;AAEhB;AAAA;AAKO,MAAM,sBAAsB,eAAe;AAAA,EAG9B;AAAA,EAFlB,WAAW,CACT,SACgB,UAChB,SACA;AAAA,IACA,MAAM,SAAS,OAAO;AAAA,IAHN;AAAA,IAIhB,KAAK,OAAO;AAAA;AAEhB;;ACjCO,SAA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