@resourcexjs/type 1.0.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 +297 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.js +316 -0
- package/dist/index.js.map +13 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# @resourcexjs/type
|
|
2
|
+
|
|
3
|
+
Type system for ResourceX with global singleton TypeHandlerChain.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @resourcexjs/type
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The `@resourcexjs/type` package provides the type system for ResourceX, managing how different resource types are serialized, deserialized, and resolved.
|
|
14
|
+
|
|
15
|
+
### Key Concepts
|
|
16
|
+
|
|
17
|
+
- **ResourceType**: Defines how a resource type is handled (serialization, deserialization, resolution)
|
|
18
|
+
- **TypeHandlerChain**: Global singleton managing all registered types
|
|
19
|
+
- **Builtin Types**: Text, JSON, and Binary types are automatically registered
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Using Builtin Types
|
|
24
|
+
|
|
25
|
+
Builtin types are automatically available:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { globalTypeHandlerChain } from "@resourcexjs/type";
|
|
29
|
+
|
|
30
|
+
// Check if type is supported
|
|
31
|
+
globalTypeHandlerChain.canHandle("text"); // true
|
|
32
|
+
globalTypeHandlerChain.canHandle("json"); // true
|
|
33
|
+
globalTypeHandlerChain.canHandle("binary"); // true
|
|
34
|
+
|
|
35
|
+
// Builtin aliases
|
|
36
|
+
globalTypeHandlerChain.canHandle("txt"); // true (alias for text)
|
|
37
|
+
globalTypeHandlerChain.canHandle("config"); // true (alias for json)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Registering Custom Types
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { globalTypeHandlerChain } from "@resourcexjs/type";
|
|
44
|
+
import type { ResourceType } from "@resourcexjs/type";
|
|
45
|
+
|
|
46
|
+
// Define custom type
|
|
47
|
+
const promptType: ResourceType<string> = {
|
|
48
|
+
name: "prompt",
|
|
49
|
+
aliases: ["deepractice-prompt"],
|
|
50
|
+
description: "AI Prompt template",
|
|
51
|
+
serializer: {
|
|
52
|
+
async serialize(rxr) {
|
|
53
|
+
const text = await rxr.content.text();
|
|
54
|
+
return Buffer.from(text, "utf-8");
|
|
55
|
+
},
|
|
56
|
+
async deserialize(data, manifest) {
|
|
57
|
+
// ... implementation
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
resolver: {
|
|
61
|
+
async resolve(rxr) {
|
|
62
|
+
return rxr.content.text();
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Register globally
|
|
68
|
+
globalTypeHandlerChain.register(promptType);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Query Supported Types
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { globalTypeHandlerChain } from "@resourcexjs/type";
|
|
75
|
+
|
|
76
|
+
// Get all supported types (including aliases)
|
|
77
|
+
const types = globalTypeHandlerChain.getSupportedTypes();
|
|
78
|
+
// ["text", "txt", "plaintext", "json", "config", "manifest", "binary", "bin", "blob", "raw"]
|
|
79
|
+
|
|
80
|
+
// Get handler for specific type
|
|
81
|
+
const handler = globalTypeHandlerChain.getHandler("text");
|
|
82
|
+
console.log(handler?.name); // "text"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Serialize/Deserialize
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { globalTypeHandlerChain } from "@resourcexjs/type";
|
|
89
|
+
import { createRXM, createRXC, parseRXL } from "@resourcexjs/core";
|
|
90
|
+
|
|
91
|
+
// Serialize RXR to Buffer
|
|
92
|
+
const manifest = createRXM({
|
|
93
|
+
domain: "localhost",
|
|
94
|
+
name: "test",
|
|
95
|
+
type: "text",
|
|
96
|
+
version: "1.0.0",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const rxr = {
|
|
100
|
+
locator: parseRXL(manifest.toLocator()),
|
|
101
|
+
manifest,
|
|
102
|
+
content: createRXC("Hello, World!"),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const buffer = await globalTypeHandlerChain.serialize(rxr);
|
|
106
|
+
// Buffer containing "Hello, World!"
|
|
107
|
+
|
|
108
|
+
// Deserialize Buffer to RXR
|
|
109
|
+
const restored = await globalTypeHandlerChain.deserialize(buffer, manifest);
|
|
110
|
+
console.log(await restored.content.text()); // "Hello, World!"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Resolve Content
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { globalTypeHandlerChain } from "@resourcexjs/type";
|
|
117
|
+
|
|
118
|
+
// Resolve RXR to usable object
|
|
119
|
+
const text = await globalTypeHandlerChain.resolve<string>(rxr);
|
|
120
|
+
console.log(text); // "Hello, World!"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## API Reference
|
|
124
|
+
|
|
125
|
+
### `globalTypeHandlerChain`
|
|
126
|
+
|
|
127
|
+
Global singleton instance of TypeHandlerChain.
|
|
128
|
+
|
|
129
|
+
#### Methods
|
|
130
|
+
|
|
131
|
+
##### `register(type: ResourceType): void`
|
|
132
|
+
|
|
133
|
+
Register an extension type.
|
|
134
|
+
|
|
135
|
+
**Throws**: `ResourceTypeError` if type name or alias already exists.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
globalTypeHandlerChain.register(customType);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
##### `canHandle(typeName: string): boolean`
|
|
142
|
+
|
|
143
|
+
Check if a type is supported.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
globalTypeHandlerChain.canHandle("text"); // true
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
##### `getHandler(typeName: string): ResourceType | undefined`
|
|
150
|
+
|
|
151
|
+
Get handler for a type.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const handler = globalTypeHandlerChain.getHandler("text");
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
##### `getSupportedTypes(): string[]`
|
|
158
|
+
|
|
159
|
+
Get all supported type names (including aliases).
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const types = globalTypeHandlerChain.getSupportedTypes();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
##### `serialize(rxr: RXR): Promise<Buffer>`
|
|
166
|
+
|
|
167
|
+
Serialize RXR to Buffer using appropriate type handler.
|
|
168
|
+
|
|
169
|
+
**Throws**: `ResourceTypeError` if type not supported.
|
|
170
|
+
|
|
171
|
+
##### `deserialize(data: Buffer, manifest: RXM): Promise<RXR>`
|
|
172
|
+
|
|
173
|
+
Deserialize Buffer to RXR using appropriate type handler.
|
|
174
|
+
|
|
175
|
+
**Throws**: `ResourceTypeError` if type not supported.
|
|
176
|
+
|
|
177
|
+
##### `resolve<T>(rxr: RXR): Promise<T>`
|
|
178
|
+
|
|
179
|
+
Resolve RXR content to usable object using appropriate type handler.
|
|
180
|
+
|
|
181
|
+
**Throws**: `ResourceTypeError` if type not supported.
|
|
182
|
+
|
|
183
|
+
##### `clearExtensions(): void`
|
|
184
|
+
|
|
185
|
+
Clear all extension types (for testing). Builtin types remain.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
globalTypeHandlerChain.clearExtensions();
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Builtin Types
|
|
192
|
+
|
|
193
|
+
### Text Type
|
|
194
|
+
|
|
195
|
+
- **Name**: `text`
|
|
196
|
+
- **Aliases**: `txt`, `plaintext`
|
|
197
|
+
- **Storage**: UTF-8 encoded string
|
|
198
|
+
- **Resolves to**: `string`
|
|
199
|
+
|
|
200
|
+
### JSON Type
|
|
201
|
+
|
|
202
|
+
- **Name**: `json`
|
|
203
|
+
- **Aliases**: `config`, `manifest`
|
|
204
|
+
- **Storage**: Formatted JSON string
|
|
205
|
+
- **Resolves to**: `unknown` (parsed object)
|
|
206
|
+
|
|
207
|
+
### Binary Type
|
|
208
|
+
|
|
209
|
+
- **Name**: `binary`
|
|
210
|
+
- **Aliases**: `bin`, `blob`, `raw`
|
|
211
|
+
- **Storage**: Raw bytes
|
|
212
|
+
- **Resolves to**: `Buffer`
|
|
213
|
+
|
|
214
|
+
## Type System Architecture
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
┌─────────────────────────────────────────┐
|
|
218
|
+
│ globalTypeHandlerChain (Singleton) │
|
|
219
|
+
│ │
|
|
220
|
+
│ Builtin: text, json, binary │
|
|
221
|
+
│ Extensions: custom types... │
|
|
222
|
+
└─────────────────────────────────────────┘
|
|
223
|
+
↑
|
|
224
|
+
│
|
|
225
|
+
All packages use
|
|
226
|
+
global singleton
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Creating Custom Types
|
|
230
|
+
|
|
231
|
+
### Example: Prompt Type
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
import type { ResourceType } from "@resourcexjs/type";
|
|
235
|
+
import { createRXC, parseRXL } from "@resourcexjs/core";
|
|
236
|
+
|
|
237
|
+
export const promptType: ResourceType<string> = {
|
|
238
|
+
name: "prompt",
|
|
239
|
+
aliases: ["deepractice-prompt"],
|
|
240
|
+
description: "AI Prompt template with variable substitution",
|
|
241
|
+
|
|
242
|
+
serializer: {
|
|
243
|
+
async serialize(rxr) {
|
|
244
|
+
const text = await rxr.content.text();
|
|
245
|
+
return Buffer.from(text, "utf-8");
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
async deserialize(data, manifest) {
|
|
249
|
+
const text = data.toString("utf-8");
|
|
250
|
+
return {
|
|
251
|
+
locator: parseRXL(manifest.toLocator()),
|
|
252
|
+
manifest,
|
|
253
|
+
content: createRXC(text),
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
resolver: {
|
|
259
|
+
async resolve(rxr) {
|
|
260
|
+
// Custom resolution logic
|
|
261
|
+
const template = await rxr.content.text();
|
|
262
|
+
return template;
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Error Handling
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { ResourceTypeError } from "@resourcexjs/type";
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
await globalTypeHandlerChain.serialize(rxr);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (error instanceof ResourceTypeError) {
|
|
277
|
+
console.error("Type error:", error.message);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Testing
|
|
283
|
+
|
|
284
|
+
When testing, use `clearExtensions()` to reset extension types:
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
import { afterEach } from "bun:test";
|
|
288
|
+
import { globalTypeHandlerChain } from "@resourcexjs/type";
|
|
289
|
+
|
|
290
|
+
afterEach(() => {
|
|
291
|
+
globalTypeHandlerChain.clearExtensions();
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { RXR, RXM } from "@resourcexjs/core";
|
|
2
|
+
/**
|
|
3
|
+
* ResourceSerializer - Handles RXR serialization/deserialization for storage.
|
|
4
|
+
*/
|
|
5
|
+
interface ResourceSerializer {
|
|
6
|
+
/**
|
|
7
|
+
* Serialize RXR to storage format.
|
|
8
|
+
*/
|
|
9
|
+
serialize(rxr: RXR): Promise<Buffer>;
|
|
10
|
+
/**
|
|
11
|
+
* Deserialize storage data to RXR.
|
|
12
|
+
*/
|
|
13
|
+
deserialize(data: Buffer, manifest: RXM): Promise<RXR>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ResourceResolver - Transforms RXR into usable object.
|
|
17
|
+
*/
|
|
18
|
+
interface ResourceResolver<T = unknown> {
|
|
19
|
+
/**
|
|
20
|
+
* Resolve RXR content into a usable object.
|
|
21
|
+
*/
|
|
22
|
+
resolve(rxr: RXR): Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* ResourceType - Defines how a resource type is handled.
|
|
26
|
+
*/
|
|
27
|
+
interface ResourceType<T = unknown> {
|
|
28
|
+
/**
|
|
29
|
+
* Type name (e.g., "text", "json", "binary").
|
|
30
|
+
*/
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* Alternative names for this type (e.g., ["txt", "plaintext"]).
|
|
34
|
+
*/
|
|
35
|
+
aliases?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Human-readable description.
|
|
38
|
+
*/
|
|
39
|
+
description: string;
|
|
40
|
+
/**
|
|
41
|
+
* Serializer for storage operations.
|
|
42
|
+
*/
|
|
43
|
+
serializer: ResourceSerializer;
|
|
44
|
+
/**
|
|
45
|
+
* Resolver to transform RXR into usable object.
|
|
46
|
+
*/
|
|
47
|
+
resolver: ResourceResolver<T>;
|
|
48
|
+
}
|
|
49
|
+
import { ResourceXError } from "@resourcexjs/core";
|
|
50
|
+
/**
|
|
51
|
+
* Resource type related error.
|
|
52
|
+
*/
|
|
53
|
+
declare class ResourceTypeError extends ResourceXError {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Text resource type
|
|
58
|
+
*/
|
|
59
|
+
declare const textType: ResourceType<string>;
|
|
60
|
+
/**
|
|
61
|
+
* JSON resource type
|
|
62
|
+
*/
|
|
63
|
+
declare const jsonType: ResourceType<unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Binary resource type
|
|
66
|
+
*/
|
|
67
|
+
declare const binaryType: ResourceType<Buffer>;
|
|
68
|
+
/**
|
|
69
|
+
* All built-in types
|
|
70
|
+
*/
|
|
71
|
+
declare const builtinTypes: ResourceType[];
|
|
72
|
+
import { RXR as RXR2, RXM as RXM2 } from "@resourcexjs/core";
|
|
73
|
+
/**
|
|
74
|
+
* TypeHandlerChain - Global singleton for type handling.
|
|
75
|
+
* Manages type registration and delegates serialization/deserialization.
|
|
76
|
+
*/
|
|
77
|
+
declare class TypeHandlerChain {
|
|
78
|
+
private static instance;
|
|
79
|
+
private handlers;
|
|
80
|
+
private constructor();
|
|
81
|
+
/**
|
|
82
|
+
* Get the global singleton instance.
|
|
83
|
+
*/
|
|
84
|
+
static getInstance(): TypeHandlerChain;
|
|
85
|
+
/**
|
|
86
|
+
* Register a builtin type (private, called during initialization).
|
|
87
|
+
*/
|
|
88
|
+
private registerBuiltin;
|
|
89
|
+
/**
|
|
90
|
+
* Register an extension type (public, for user-defined types).
|
|
91
|
+
* @throws ResourceTypeError if type is already registered
|
|
92
|
+
*/
|
|
93
|
+
register(type: ResourceType): void;
|
|
94
|
+
/**
|
|
95
|
+
* Check if a type is supported.
|
|
96
|
+
*/
|
|
97
|
+
canHandle(typeName: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Get handler for a type.
|
|
100
|
+
*/
|
|
101
|
+
getHandler(typeName: string): ResourceType | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Get all supported type names (including aliases).
|
|
104
|
+
*/
|
|
105
|
+
getSupportedTypes(): string[];
|
|
106
|
+
/**
|
|
107
|
+
* Serialize RXR content using the appropriate type handler.
|
|
108
|
+
* @throws ResourceTypeError if type is not supported
|
|
109
|
+
*/
|
|
110
|
+
serialize(rxr: RXR2): Promise<Buffer>;
|
|
111
|
+
/**
|
|
112
|
+
* Deserialize content into RXR using the appropriate type handler.
|
|
113
|
+
* @throws ResourceTypeError if type is not supported
|
|
114
|
+
*/
|
|
115
|
+
deserialize(data: Buffer, manifest: RXM2): Promise<RXR2>;
|
|
116
|
+
/**
|
|
117
|
+
* Resolve RXR content into usable object using the appropriate type handler.
|
|
118
|
+
* @throws ResourceTypeError if type is not supported
|
|
119
|
+
*/
|
|
120
|
+
resolve<T = unknown>(rxr: RXR2): Promise<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Clear all extension types (for testing).
|
|
123
|
+
* Keeps builtin types intact.
|
|
124
|
+
*/
|
|
125
|
+
clearExtensions(): void;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Global singleton instance of TypeHandlerChain.
|
|
129
|
+
* All type registration and handling goes through this instance.
|
|
130
|
+
*/
|
|
131
|
+
declare const globalTypeHandlerChain: TypeHandlerChain;
|
|
132
|
+
export { textType, jsonType, globalTypeHandlerChain, builtinTypes, binaryType, TypeHandlerChain, ResourceTypeError, ResourceType, ResourceSerializer, ResourceResolver };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// ../core/dist/index.js
|
|
2
|
+
class ResourceXError extends Error {
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.name = "ResourceXError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
class ContentError extends ResourceXError {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "ContentError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class RXLImpl {
|
|
16
|
+
domain;
|
|
17
|
+
path;
|
|
18
|
+
name;
|
|
19
|
+
type;
|
|
20
|
+
version;
|
|
21
|
+
constructor(parts) {
|
|
22
|
+
this.domain = parts.domain;
|
|
23
|
+
this.path = parts.path;
|
|
24
|
+
this.name = parts.name;
|
|
25
|
+
this.type = parts.type;
|
|
26
|
+
this.version = parts.version;
|
|
27
|
+
}
|
|
28
|
+
toString() {
|
|
29
|
+
let result = "";
|
|
30
|
+
if (this.domain) {
|
|
31
|
+
result += this.domain + "/";
|
|
32
|
+
if (this.path) {
|
|
33
|
+
result += this.path + "/";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
result += this.name;
|
|
37
|
+
if (this.type) {
|
|
38
|
+
result += "." + this.type;
|
|
39
|
+
}
|
|
40
|
+
if (this.version) {
|
|
41
|
+
result += "@" + this.version;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function isDomain(str) {
|
|
47
|
+
if (str === "localhost")
|
|
48
|
+
return true;
|
|
49
|
+
return str.includes(".");
|
|
50
|
+
}
|
|
51
|
+
function parseRXL(locator) {
|
|
52
|
+
let remaining = locator;
|
|
53
|
+
let version;
|
|
54
|
+
let type;
|
|
55
|
+
let domain;
|
|
56
|
+
let path;
|
|
57
|
+
let name;
|
|
58
|
+
const atIndex = remaining.indexOf("@");
|
|
59
|
+
if (atIndex !== -1) {
|
|
60
|
+
version = remaining.slice(atIndex + 1);
|
|
61
|
+
remaining = remaining.slice(0, atIndex);
|
|
62
|
+
}
|
|
63
|
+
const segments = remaining.split("/");
|
|
64
|
+
if (segments.length > 1 && isDomain(segments[0])) {
|
|
65
|
+
domain = segments[0];
|
|
66
|
+
const lastSegment = segments[segments.length - 1];
|
|
67
|
+
if (segments.length > 2) {
|
|
68
|
+
path = segments.slice(1, -1).join("/");
|
|
69
|
+
}
|
|
70
|
+
remaining = lastSegment;
|
|
71
|
+
} else {
|
|
72
|
+
remaining = segments.join("/");
|
|
73
|
+
}
|
|
74
|
+
const dotIndex = remaining.lastIndexOf(".");
|
|
75
|
+
if (dotIndex !== -1) {
|
|
76
|
+
type = remaining.slice(dotIndex + 1);
|
|
77
|
+
name = remaining.slice(0, dotIndex);
|
|
78
|
+
} else {
|
|
79
|
+
name = remaining;
|
|
80
|
+
}
|
|
81
|
+
return new RXLImpl({ domain, path, name, type, version });
|
|
82
|
+
}
|
|
83
|
+
class RXCImpl {
|
|
84
|
+
_stream;
|
|
85
|
+
_consumed = false;
|
|
86
|
+
constructor(stream) {
|
|
87
|
+
this._stream = stream;
|
|
88
|
+
}
|
|
89
|
+
get stream() {
|
|
90
|
+
if (this._consumed) {
|
|
91
|
+
throw new ContentError("Content has already been consumed");
|
|
92
|
+
}
|
|
93
|
+
this._consumed = true;
|
|
94
|
+
return this._stream;
|
|
95
|
+
}
|
|
96
|
+
async text() {
|
|
97
|
+
const buffer = await this.buffer();
|
|
98
|
+
return buffer.toString("utf-8");
|
|
99
|
+
}
|
|
100
|
+
async buffer() {
|
|
101
|
+
if (this._consumed) {
|
|
102
|
+
throw new ContentError("Content has already been consumed");
|
|
103
|
+
}
|
|
104
|
+
this._consumed = true;
|
|
105
|
+
const reader = this._stream.getReader();
|
|
106
|
+
const chunks = [];
|
|
107
|
+
while (true) {
|
|
108
|
+
const { done, value } = await reader.read();
|
|
109
|
+
if (done)
|
|
110
|
+
break;
|
|
111
|
+
chunks.push(value);
|
|
112
|
+
}
|
|
113
|
+
return Buffer.concat(chunks);
|
|
114
|
+
}
|
|
115
|
+
async json() {
|
|
116
|
+
const text = await this.text();
|
|
117
|
+
return JSON.parse(text);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function createRXC(data) {
|
|
121
|
+
let stream;
|
|
122
|
+
if (typeof data === "string") {
|
|
123
|
+
const encoded = new TextEncoder().encode(data);
|
|
124
|
+
stream = new ReadableStream({
|
|
125
|
+
start(controller) {
|
|
126
|
+
controller.enqueue(encoded);
|
|
127
|
+
controller.close();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
} else if (Buffer.isBuffer(data)) {
|
|
131
|
+
stream = new ReadableStream({
|
|
132
|
+
start(controller) {
|
|
133
|
+
controller.enqueue(new Uint8Array(data));
|
|
134
|
+
controller.close();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
stream = data;
|
|
139
|
+
}
|
|
140
|
+
return new RXCImpl(stream);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/errors.ts
|
|
144
|
+
class ResourceTypeError extends ResourceXError {
|
|
145
|
+
constructor(message) {
|
|
146
|
+
super(message);
|
|
147
|
+
this.name = "ResourceTypeError";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// src/builtinTypes.ts
|
|
151
|
+
var textSerializer = {
|
|
152
|
+
async serialize(rxr) {
|
|
153
|
+
const text = await rxr.content.text();
|
|
154
|
+
return Buffer.from(text, "utf-8");
|
|
155
|
+
},
|
|
156
|
+
async deserialize(data, manifest) {
|
|
157
|
+
const text = data.toString("utf-8");
|
|
158
|
+
return {
|
|
159
|
+
locator: parseRXL(manifest.toLocator()),
|
|
160
|
+
manifest,
|
|
161
|
+
content: createRXC(text)
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var textResolver = {
|
|
166
|
+
async resolve(rxr) {
|
|
167
|
+
return rxr.content.text();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var textType = {
|
|
171
|
+
name: "text",
|
|
172
|
+
aliases: ["txt", "plaintext"],
|
|
173
|
+
description: "Plain text content",
|
|
174
|
+
serializer: textSerializer,
|
|
175
|
+
resolver: textResolver
|
|
176
|
+
};
|
|
177
|
+
var jsonSerializer = {
|
|
178
|
+
async serialize(rxr) {
|
|
179
|
+
const json = await rxr.content.json();
|
|
180
|
+
return Buffer.from(JSON.stringify(json, null, 2), "utf-8");
|
|
181
|
+
},
|
|
182
|
+
async deserialize(data, manifest) {
|
|
183
|
+
const text = data.toString("utf-8");
|
|
184
|
+
return {
|
|
185
|
+
locator: parseRXL(manifest.toLocator()),
|
|
186
|
+
manifest,
|
|
187
|
+
content: createRXC(text)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var jsonResolver = {
|
|
192
|
+
async resolve(rxr) {
|
|
193
|
+
return rxr.content.json();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
var jsonType = {
|
|
197
|
+
name: "json",
|
|
198
|
+
aliases: ["config", "manifest"],
|
|
199
|
+
description: "JSON content",
|
|
200
|
+
serializer: jsonSerializer,
|
|
201
|
+
resolver: jsonResolver
|
|
202
|
+
};
|
|
203
|
+
var binarySerializer = {
|
|
204
|
+
async serialize(rxr) {
|
|
205
|
+
return rxr.content.buffer();
|
|
206
|
+
},
|
|
207
|
+
async deserialize(data, manifest) {
|
|
208
|
+
return {
|
|
209
|
+
locator: parseRXL(manifest.toLocator()),
|
|
210
|
+
manifest,
|
|
211
|
+
content: createRXC(data)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var binaryResolver = {
|
|
216
|
+
async resolve(rxr) {
|
|
217
|
+
return rxr.content.buffer();
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var binaryType = {
|
|
221
|
+
name: "binary",
|
|
222
|
+
aliases: ["bin", "blob", "raw"],
|
|
223
|
+
description: "Binary content",
|
|
224
|
+
serializer: binarySerializer,
|
|
225
|
+
resolver: binaryResolver
|
|
226
|
+
};
|
|
227
|
+
var builtinTypes = [textType, jsonType, binaryType];
|
|
228
|
+
// src/TypeHandlerChain.ts
|
|
229
|
+
class TypeHandlerChain {
|
|
230
|
+
static instance;
|
|
231
|
+
handlers = new Map;
|
|
232
|
+
constructor() {
|
|
233
|
+
for (const type of builtinTypes) {
|
|
234
|
+
this.registerBuiltin(type);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
static getInstance() {
|
|
238
|
+
if (!TypeHandlerChain.instance) {
|
|
239
|
+
TypeHandlerChain.instance = new TypeHandlerChain;
|
|
240
|
+
}
|
|
241
|
+
return TypeHandlerChain.instance;
|
|
242
|
+
}
|
|
243
|
+
registerBuiltin(type) {
|
|
244
|
+
this.handlers.set(type.name, type);
|
|
245
|
+
if (type.aliases) {
|
|
246
|
+
for (const alias of type.aliases) {
|
|
247
|
+
this.handlers.set(alias, type);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
register(type) {
|
|
252
|
+
if (this.handlers.has(type.name)) {
|
|
253
|
+
throw new ResourceTypeError(`Type '${type.name}' is already registered`);
|
|
254
|
+
}
|
|
255
|
+
this.handlers.set(type.name, type);
|
|
256
|
+
if (type.aliases) {
|
|
257
|
+
for (const alias of type.aliases) {
|
|
258
|
+
if (this.handlers.has(alias)) {
|
|
259
|
+
throw new ResourceTypeError(`Alias '${alias}' conflicts with existing type or alias`);
|
|
260
|
+
}
|
|
261
|
+
this.handlers.set(alias, type);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
canHandle(typeName) {
|
|
266
|
+
return this.handlers.has(typeName);
|
|
267
|
+
}
|
|
268
|
+
getHandler(typeName) {
|
|
269
|
+
return this.handlers.get(typeName);
|
|
270
|
+
}
|
|
271
|
+
getSupportedTypes() {
|
|
272
|
+
return Array.from(this.handlers.keys());
|
|
273
|
+
}
|
|
274
|
+
async serialize(rxr) {
|
|
275
|
+
const typeName = rxr.manifest.type;
|
|
276
|
+
const handler = this.handlers.get(typeName);
|
|
277
|
+
if (!handler) {
|
|
278
|
+
throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
|
|
279
|
+
}
|
|
280
|
+
return handler.serializer.serialize(rxr);
|
|
281
|
+
}
|
|
282
|
+
async deserialize(data, manifest) {
|
|
283
|
+
const typeName = manifest.type;
|
|
284
|
+
const handler = this.handlers.get(typeName);
|
|
285
|
+
if (!handler) {
|
|
286
|
+
throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
|
|
287
|
+
}
|
|
288
|
+
return handler.serializer.deserialize(data, manifest);
|
|
289
|
+
}
|
|
290
|
+
async resolve(rxr) {
|
|
291
|
+
const typeName = rxr.manifest.type;
|
|
292
|
+
const handler = this.handlers.get(typeName);
|
|
293
|
+
if (!handler) {
|
|
294
|
+
throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
|
|
295
|
+
}
|
|
296
|
+
return handler.resolver.resolve(rxr);
|
|
297
|
+
}
|
|
298
|
+
clearExtensions() {
|
|
299
|
+
this.handlers.clear();
|
|
300
|
+
for (const type of builtinTypes) {
|
|
301
|
+
this.registerBuiltin(type);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
var globalTypeHandlerChain = TypeHandlerChain.getInstance();
|
|
306
|
+
export {
|
|
307
|
+
textType,
|
|
308
|
+
jsonType,
|
|
309
|
+
globalTypeHandlerChain,
|
|
310
|
+
builtinTypes,
|
|
311
|
+
binaryType,
|
|
312
|
+
TypeHandlerChain,
|
|
313
|
+
ResourceTypeError
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
//# debugId=ED28E038CDB29DF864756E2164756E21
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../core/dist/index.js", "../src/errors.ts", "../src/builtinTypes.ts", "../src/TypeHandlerChain.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// src/errors.ts\nclass ResourceXError extends Error {\n constructor(message, options) {\n super(message, options);\n this.name = \"ResourceXError\";\n }\n}\n\nclass LocatorError extends ResourceXError {\n locator;\n constructor(message, locator) {\n super(message);\n this.locator = locator;\n this.name = \"LocatorError\";\n }\n}\n\nclass ManifestError extends ResourceXError {\n constructor(message) {\n super(message);\n this.name = \"ManifestError\";\n }\n}\n\nclass ContentError extends ResourceXError {\n constructor(message) {\n super(message);\n this.name = \"ContentError\";\n }\n}\n// src/locator/parseRXL.ts\nclass RXLImpl {\n domain;\n path;\n name;\n type;\n version;\n constructor(parts) {\n this.domain = parts.domain;\n this.path = parts.path;\n this.name = parts.name;\n this.type = parts.type;\n this.version = parts.version;\n }\n toString() {\n let result = \"\";\n if (this.domain) {\n result += this.domain + \"/\";\n if (this.path) {\n result += this.path + \"/\";\n }\n }\n result += this.name;\n if (this.type) {\n result += \".\" + this.type;\n }\n if (this.version) {\n result += \"@\" + this.version;\n }\n return result;\n }\n}\nfunction isDomain(str) {\n if (str === \"localhost\")\n return true;\n return str.includes(\".\");\n}\nfunction parseRXL(locator) {\n let remaining = locator;\n let version;\n let type;\n let domain;\n let path;\n let name;\n const atIndex = remaining.indexOf(\"@\");\n if (atIndex !== -1) {\n version = remaining.slice(atIndex + 1);\n remaining = remaining.slice(0, atIndex);\n }\n const segments = remaining.split(\"/\");\n if (segments.length > 1 && isDomain(segments[0])) {\n domain = segments[0];\n const lastSegment = segments[segments.length - 1];\n if (segments.length > 2) {\n path = segments.slice(1, -1).join(\"/\");\n }\n remaining = lastSegment;\n } else {\n remaining = segments.join(\"/\");\n }\n const dotIndex = remaining.lastIndexOf(\".\");\n if (dotIndex !== -1) {\n type = remaining.slice(dotIndex + 1);\n name = remaining.slice(0, dotIndex);\n } else {\n name = remaining;\n }\n return new RXLImpl({ domain, path, name, type, version });\n}\n// src/manifest/createRXM.ts\nclass RXMImpl {\n domain;\n path;\n name;\n type;\n version;\n constructor(data) {\n this.domain = data.domain;\n this.path = data.path;\n this.name = data.name;\n this.type = data.type;\n this.version = data.version;\n }\n toLocator() {\n let result = this.domain + \"/\";\n if (this.path) {\n result += this.path + \"/\";\n }\n result += this.name;\n result += \".\" + this.type;\n result += \"@\" + this.version;\n return result;\n }\n toJSON() {\n const json = {\n domain: this.domain,\n name: this.name,\n type: this.type,\n version: this.version\n };\n if (this.path !== undefined) {\n json.path = this.path;\n }\n return json;\n }\n}\nfunction createRXM(data) {\n if (!data.domain) {\n throw new ManifestError(\"domain is required\");\n }\n if (!data.name) {\n throw new ManifestError(\"name is required\");\n }\n if (!data.type) {\n throw new ManifestError(\"type is required\");\n }\n if (!data.version) {\n throw new ManifestError(\"version is required\");\n }\n return new RXMImpl({\n domain: data.domain,\n path: data.path,\n name: data.name,\n type: data.type,\n version: data.version\n });\n}\n// src/content/createRXC.ts\nclass RXCImpl {\n _stream;\n _consumed = false;\n constructor(stream) {\n this._stream = stream;\n }\n get stream() {\n if (this._consumed) {\n throw new ContentError(\"Content has already been consumed\");\n }\n this._consumed = true;\n return this._stream;\n }\n async text() {\n const buffer = await this.buffer();\n return buffer.toString(\"utf-8\");\n }\n async buffer() {\n if (this._consumed) {\n throw new ContentError(\"Content has already been consumed\");\n }\n this._consumed = true;\n const reader = this._stream.getReader();\n const chunks = [];\n while (true) {\n const { done, value } = await reader.read();\n if (done)\n break;\n chunks.push(value);\n }\n return Buffer.concat(chunks);\n }\n async json() {\n const text = await this.text();\n return JSON.parse(text);\n }\n}\nfunction createRXC(data) {\n let stream;\n if (typeof data === \"string\") {\n const encoded = new TextEncoder().encode(data);\n stream = new ReadableStream({\n start(controller) {\n controller.enqueue(encoded);\n controller.close();\n }\n });\n } else if (Buffer.isBuffer(data)) {\n stream = new ReadableStream({\n start(controller) {\n controller.enqueue(new Uint8Array(data));\n controller.close();\n }\n });\n } else {\n stream = data;\n }\n return new RXCImpl(stream);\n}\n// src/content/loadRXC.ts\nimport { createReadStream } from \"node:fs\";\nimport { Readable } from \"node:stream\";\nasync function loadRXC(source) {\n if (source.startsWith(\"http://\") || source.startsWith(\"https://\")) {\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(`Failed to fetch ${source}: ${response.statusText}`);\n }\n if (!response.body) {\n throw new Error(`No body in response from ${source}`);\n }\n return createRXC(response.body);\n }\n const nodeStream = createReadStream(source);\n const webStream = Readable.toWeb(nodeStream);\n return createRXC(webStream);\n}\nexport {\n parseRXL,\n loadRXC,\n createRXM,\n createRXC,\n ResourceXError,\n ManifestError,\n LocatorError,\n ContentError\n};\n\n//# debugId=2AAEFC45892A016E64756E2164756E21\n",
|
|
6
|
+
"import { ResourceXError } from \"@resourcexjs/core\";\n\n/**\n * Resource type related error.\n */\nexport class ResourceTypeError extends ResourceXError {\n constructor(message: string) {\n super(message);\n this.name = \"ResourceTypeError\";\n }\n}\n",
|
|
7
|
+
"import type { ResourceType, ResourceSerializer, ResourceResolver } from \"./types.js\";\nimport type { RXR, RXM } from \"@resourcexjs/core\";\nimport { createRXC, parseRXL } from \"@resourcexjs/core\";\n\n/**\n * Text serializer - stores content as UTF-8 text\n */\nconst textSerializer: ResourceSerializer = {\n async serialize(rxr: RXR): Promise<Buffer> {\n const text = await rxr.content.text();\n return Buffer.from(text, \"utf-8\");\n },\n\n async deserialize(data: Buffer, manifest: RXM): Promise<RXR> {\n const text = data.toString(\"utf-8\");\n return {\n locator: parseRXL(manifest.toLocator()),\n manifest,\n content: createRXC(text),\n };\n },\n};\n\n/**\n * Text resolver - returns content as string\n */\nconst textResolver: ResourceResolver<string> = {\n async resolve(rxr: RXR): Promise<string> {\n return rxr.content.text();\n },\n};\n\n/**\n * Text resource type\n */\nexport const textType: ResourceType<string> = {\n name: \"text\",\n aliases: [\"txt\", \"plaintext\"],\n description: \"Plain text content\",\n serializer: textSerializer,\n resolver: textResolver,\n};\n\n/**\n * JSON serializer - stores content as JSON string\n */\nconst jsonSerializer: ResourceSerializer = {\n async serialize(rxr: RXR): Promise<Buffer> {\n const json = await rxr.content.json();\n return Buffer.from(JSON.stringify(json, null, 2), \"utf-8\");\n },\n\n async deserialize(data: Buffer, manifest: RXM): Promise<RXR> {\n const text = data.toString(\"utf-8\");\n return {\n locator: parseRXL(manifest.toLocator()),\n manifest,\n content: createRXC(text),\n };\n },\n};\n\n/**\n * JSON resolver - returns content as parsed object\n */\nconst jsonResolver: ResourceResolver<unknown> = {\n async resolve(rxr: RXR): Promise<unknown> {\n return rxr.content.json();\n },\n};\n\n/**\n * JSON resource type\n */\nexport const jsonType: ResourceType<unknown> = {\n name: \"json\",\n aliases: [\"config\", \"manifest\"],\n description: \"JSON content\",\n serializer: jsonSerializer,\n resolver: jsonResolver,\n};\n\n/**\n * Binary serializer - stores content as raw bytes\n */\nconst binarySerializer: ResourceSerializer = {\n async serialize(rxr: RXR): Promise<Buffer> {\n return rxr.content.buffer();\n },\n\n async deserialize(data: Buffer, manifest: RXM): Promise<RXR> {\n return {\n locator: parseRXL(manifest.toLocator()),\n manifest,\n content: createRXC(data),\n };\n },\n};\n\n/**\n * Binary resolver - returns content as Buffer\n */\nconst binaryResolver: ResourceResolver<Buffer> = {\n async resolve(rxr: RXR): Promise<Buffer> {\n return rxr.content.buffer();\n },\n};\n\n/**\n * Binary resource type\n */\nexport const binaryType: ResourceType<Buffer> = {\n name: \"binary\",\n aliases: [\"bin\", \"blob\", \"raw\"],\n description: \"Binary content\",\n serializer: binarySerializer,\n resolver: binaryResolver,\n};\n\n/**\n * All built-in types\n */\nexport const builtinTypes: ResourceType[] = [textType, jsonType, binaryType];\n",
|
|
8
|
+
"import type { ResourceType } from \"./types.js\";\nimport type { RXR, RXM } from \"@resourcexjs/core\";\nimport { ResourceTypeError } from \"./errors.js\";\nimport { builtinTypes } from \"./builtinTypes.js\";\n\n/**\n * TypeHandlerChain - Global singleton for type handling.\n * Manages type registration and delegates serialization/deserialization.\n */\nexport class TypeHandlerChain {\n private static instance: TypeHandlerChain;\n private handlers: Map<string, ResourceType> = new Map();\n\n private constructor() {\n // Auto-register builtin types\n for (const type of builtinTypes) {\n this.registerBuiltin(type);\n }\n }\n\n /**\n * Get the global singleton instance.\n */\n static getInstance(): TypeHandlerChain {\n if (!TypeHandlerChain.instance) {\n TypeHandlerChain.instance = new TypeHandlerChain();\n }\n return TypeHandlerChain.instance;\n }\n\n /**\n * Register a builtin type (private, called during initialization).\n */\n private registerBuiltin(type: ResourceType): void {\n this.handlers.set(type.name, type);\n if (type.aliases) {\n for (const alias of type.aliases) {\n this.handlers.set(alias, type);\n }\n }\n }\n\n /**\n * Register an extension type (public, for user-defined types).\n * @throws ResourceTypeError if type is already registered\n */\n register(type: ResourceType): void {\n if (this.handlers.has(type.name)) {\n throw new ResourceTypeError(`Type '${type.name}' is already registered`);\n }\n this.handlers.set(type.name, type);\n if (type.aliases) {\n for (const alias of type.aliases) {\n if (this.handlers.has(alias)) {\n throw new ResourceTypeError(`Alias '${alias}' conflicts with existing type or alias`);\n }\n this.handlers.set(alias, type);\n }\n }\n }\n\n /**\n * Check if a type is supported.\n */\n canHandle(typeName: string): boolean {\n return this.handlers.has(typeName);\n }\n\n /**\n * Get handler for a type.\n */\n getHandler(typeName: string): ResourceType | undefined {\n return this.handlers.get(typeName);\n }\n\n /**\n * Get all supported type names (including aliases).\n */\n getSupportedTypes(): string[] {\n return Array.from(this.handlers.keys());\n }\n\n /**\n * Serialize RXR content using the appropriate type handler.\n * @throws ResourceTypeError if type is not supported\n */\n async serialize(rxr: RXR): Promise<Buffer> {\n const typeName = rxr.manifest.type;\n const handler = this.handlers.get(typeName);\n\n if (!handler) {\n throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);\n }\n\n return handler.serializer.serialize(rxr);\n }\n\n /**\n * Deserialize content into RXR using the appropriate type handler.\n * @throws ResourceTypeError if type is not supported\n */\n async deserialize(data: Buffer, manifest: RXM): Promise<RXR> {\n const typeName = manifest.type;\n const handler = this.handlers.get(typeName);\n\n if (!handler) {\n throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);\n }\n\n return handler.serializer.deserialize(data, manifest);\n }\n\n /**\n * Resolve RXR content into usable object using the appropriate type handler.\n * @throws ResourceTypeError if type is not supported\n */\n async resolve<T = unknown>(rxr: RXR): Promise<T> {\n const typeName = rxr.manifest.type;\n const handler = this.handlers.get(typeName);\n\n if (!handler) {\n throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);\n }\n\n return handler.resolver.resolve(rxr) as Promise<T>;\n }\n\n /**\n * Clear all extension types (for testing).\n * Keeps builtin types intact.\n */\n clearExtensions(): void {\n this.handlers.clear();\n for (const type of builtinTypes) {\n this.registerBuiltin(type);\n }\n }\n}\n\n/**\n * Global singleton instance of TypeHandlerChain.\n * All type registration and handling goes through this instance.\n */\nexport const globalTypeHandlerChain: TypeHandlerChain = TypeHandlerChain.getInstance();\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";AACA,MAAM,uBAAuB,MAAM;AAAA,EACjC,WAAW,CAAC,SAAS,SAAS;AAAA,IAC5B,MAAM,SAAS,OAAO;AAAA,IACtB,KAAK,OAAO;AA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CDB29DF864756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@resourcexjs/type",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ResourceX Type System - Type handlers and serialization",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"resourcex",
|
|
7
|
+
"resource",
|
|
8
|
+
"type",
|
|
9
|
+
"serialization"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Deepractice/ResourceX.git",
|
|
14
|
+
"directory": "packages/type"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.0.0"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "bun run build.ts",
|
|
35
|
+
"test": "bun test",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@resourcexjs/core": "^1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|