nap-sdk 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,4 +2,16 @@ export declare function parseUri(uri: string): Record<string, unknown>;
2
2
  export declare function parseManifest(yamlStr: string): Record<string, unknown>;
3
3
  export declare function resolve(uri: string, repoPath?: string): Record<string, unknown>;
4
4
  export declare function version(): string;
5
+ /**
6
+ * Ingest raw media bytes into the content-addressed storage engine.
7
+ *
8
+ * The storage backend is determined by the ``NAP_STORAGE_BACKEND``
9
+ * environment variable at the Rust layer (``local`` or ``s3``).
10
+ *
11
+ * @param data - Raw bytes of the media asset (image, audio, mesh, etc.).
12
+ * @param format - File extension without a leading dot (e.g. ``"png"``,
13
+ * ``"jpg"``, ``"wav"``, ``"glb"``).
14
+ * @returns A Promise resolving to the content-addressed hash ``sha256:<hex>``.
15
+ */
16
+ export declare function ingestMedia(data: Buffer, format: string): Promise<string>;
5
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE7D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK/E;AAED,wBAAgB,OAAO,IAAI,MAAM,CAEhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE7D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK/E;AAED,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/E"}
package/dist/index.js CHANGED
@@ -16,3 +16,17 @@ export function resolve(uri, repoPath) {
16
16
  export function version() {
17
17
  return native.version();
18
18
  }
19
+ /**
20
+ * Ingest raw media bytes into the content-addressed storage engine.
21
+ *
22
+ * The storage backend is determined by the ``NAP_STORAGE_BACKEND``
23
+ * environment variable at the Rust layer (``local`` or ``s3``).
24
+ *
25
+ * @param data - Raw bytes of the media asset (image, audio, mesh, etc.).
26
+ * @param format - File extension without a leading dot (e.g. ``"png"``,
27
+ * ``"jpg"``, ``"wav"``, ``"glb"``).
28
+ * @returns A Promise resolving to the content-addressed hash ``sha256:<hex>``.
29
+ */
30
+ export async function ingestMedia(data, format) {
31
+ return native.ingestMedia(data, format);
32
+ }
package/dist/native.d.ts CHANGED
@@ -3,6 +3,7 @@ interface NativeBindings {
3
3
  parseManifest(yamlStr: string): string;
4
4
  resolve(uri: string, repoPath: string): string;
5
5
  version(): string;
6
+ ingestMedia(data: Buffer, format: string): Promise<string>;
6
7
  }
7
8
  declare const native: NativeBindings;
8
9
  export default native;
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/C,OAAO,IAAI,MAAM,CAAC;CACnB;AAGD,QAAA,MAAM,MAAM,EAA8B,cAAc,CAAC;AAEzD,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/C,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D;AAGD,QAAA,MAAM,MAAM,EAA8B,cAAc,CAAC;AAEzD,eAAe,MAAM,CAAC"}
package/index.d.ts CHANGED
@@ -7,3 +7,30 @@ export declare function parseUri(uriStr: string): string
7
7
  export declare function parseManifest(yamlStr: string): string
8
8
  export declare function resolve(uriStr: string, repoBasePath: string): string
9
9
  export declare function version(): string
10
+ /**
11
+ * Ingest raw media bytes into the content-addressed storage engine.
12
+ *
13
+ * This is an async function returning a JavaScript Promise. The storage
14
+ * backend is determined at runtime by the ``NAP_STORAGE_BACKEND``
15
+ * environment variable.
16
+ *
17
+ * ## Memory Safety (NAPI Buffer Ownership)
18
+ *
19
+ * The incoming [`Buffer`] is **copied** to an owned `Vec<u8>` **before**
20
+ * crossing the await boundary. Holding a raw pointer to a V8 `ArrayBuffer`
21
+ * across an await point is unsafe because Node's garbage collector may
22
+ * invalidate or relocate the backing store. By cloning eagerly we avoid
23
+ * use-after-free and data races.
24
+ *
25
+ * # Arguments
26
+ *
27
+ * * `data` — Raw bytes of the media asset (image, audio, mesh, etc.),
28
+ * passed as a Node.js `Buffer`.
29
+ * * `format` — File extension without a leading dot (e.g. `"png"`,
30
+ * `"jpg"`, `"wav"`, `"glb"`).
31
+ *
32
+ * # Returns
33
+ *
34
+ * A Promise resolving to the content-addressed hash `sha256:<hex>`.
35
+ */
36
+ export declare function ingestMedia(data: Buffer, format: string): Promise<string>
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nap-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "TypeScript SDK for NAP (Narrative Addressing Protocol), powered by Rust and NAPI-RS.",
5
5
  "license": "MIT",
6
6
  "repository": {