Skip to content

Commit b58af94

Browse files
deepracticexsclaude
andcommitted
feat(storex): add create() method with default type "object"
Create resources directly from files without touching core primitives. Default type "object" = pure storage, no AI resolution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 67ad483 commit b58af94

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

.changeset/storex-create-method.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"storexjs": minor
3+
---
4+
5+
feat: add create() method for creating resources from files
6+
7+
Default type is "object" — pure storage, not for AI resolution.

packages/storex/src/StoreX.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import type { RXAStore, RXM, RXMStore, RXR, StoredRXM } from "@resourcexjs/core";
12-
import { CASRegistry, parse } from "@resourcexjs/core";
12+
import { archive, CASRegistry, manifest, parse, resource } from "@resourcexjs/core";
1313

1414
/**
1515
* File metadata returned by list operations.
@@ -112,6 +112,32 @@ export class StoreX {
112112
return this.cas.has(rxi);
113113
}
114114

115+
/**
116+
* Create a new resource from files.
117+
*
118+
* @param opts.name - Resource name
119+
* @param opts.tag - Version tag (default: "latest")
120+
* @param opts.type - Resource type (default: "object" — pure storage, not for AI resolution)
121+
* @param opts.description - Optional description
122+
* @param opts.files - Files: relative path → content
123+
*/
124+
async create(opts: {
125+
name: string;
126+
files: Record<string, Buffer>;
127+
tag?: string;
128+
type?: string;
129+
description?: string;
130+
}): Promise<RXM> {
131+
const rxm = manifest({
132+
name: opts.name,
133+
type: opts.type ?? "object",
134+
tag: opts.tag ?? "latest",
135+
description: opts.description,
136+
});
137+
const rxa = await archive(opts.files);
138+
return this.cas.put(resource(rxm, rxa));
139+
}
140+
115141
/**
116142
* Store a complete resource (RXR).
117143
* Used for initial resource creation from in-memory files.

0 commit comments

Comments
 (0)