space-data-module-sdk 0.5.14 → 0.5.15

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.
@@ -57,10 +57,154 @@ export interface ManifestHarnessPlan {
57
57
  scenarios: Array<HarnessInvokeScenario | HarnessRawScenario>;
58
58
  }
59
59
 
60
+ export interface PublicationProtectionDemoAlignedType {
61
+ methodId: string | null;
62
+ portId: string | null;
63
+ setId: string | null;
64
+ schemaName: string | null;
65
+ fileIdentifier: string | null;
66
+ rootTypeName: string | null;
67
+ byteLength: number | null;
68
+ requiredAlignment: number | null;
69
+ hasFlatbufferFallback: boolean;
70
+ }
71
+
72
+ export interface PublicationProtectionDemoSummary {
73
+ manifest: PluginManifest;
74
+ recTrailer: {
75
+ fileIdentifier: string;
76
+ version: string | null;
77
+ recordCount: number;
78
+ recordStandards: Array<string | null>;
79
+ usesStandardsFlatbuffers: boolean;
80
+ records: Array<Record<string, unknown>>;
81
+ };
82
+ alignedBinaryContract: PublicationProtectionDemoAlignedType[];
83
+ signedOnly: {
84
+ artifactId: string;
85
+ encrypted: boolean;
86
+ trailer: PublicationProtectionDemoSummary["recTrailer"];
87
+ recordStandards: Array<string | null>;
88
+ pnm: {
89
+ fileName: string | null;
90
+ fileId: string | null;
91
+ cid: string | null;
92
+ hasSignature: boolean;
93
+ signatureType: string | null;
94
+ publishTimestamp: string | null;
95
+ } | null;
96
+ enc: null;
97
+ envelope: null;
98
+ };
99
+ encryptedDelivery: {
100
+ artifactId: string;
101
+ encrypted: boolean;
102
+ trailer: PublicationProtectionDemoSummary["recTrailer"];
103
+ recordStandards: Array<string | null>;
104
+ pnm: {
105
+ fileName: string | null;
106
+ fileId: string | null;
107
+ cid: string | null;
108
+ hasSignature: boolean;
109
+ signatureType: string | null;
110
+ publishTimestamp: string | null;
111
+ } | null;
112
+ enc: {
113
+ context: string | null;
114
+ rootType: string | null;
115
+ keyExchange: string | null;
116
+ symmetric: string | null;
117
+ keyDerivation: string | null;
118
+ nonceLength: number;
119
+ ephemeralPublicKeyLength: number;
120
+ } | null;
121
+ envelope: {
122
+ scheme: string | null;
123
+ hasEncRecord: boolean;
124
+ hasPnmRecord: boolean;
125
+ } | null;
126
+ };
127
+ }
128
+
129
+ export interface PluginInvokeProcessLaunchPlan {
130
+ command: string;
131
+ args: string[];
132
+ env?: Record<string, string | undefined>;
133
+ cwd?: string;
134
+ wasmPath?: string;
135
+ }
136
+
137
+ export interface PluginInvokeProcessClient {
138
+ launchPlan: PluginInvokeProcessLaunchPlan;
139
+ invokeRaw(requestBytes: Uint8Array | ArrayBuffer | ArrayBufferView): Promise<Uint8Array>;
140
+ invoke(request: {
141
+ methodId?: string | null;
142
+ inputs?: HarnessInputFrame[];
143
+ }): Promise<{
144
+ statusCode: number;
145
+ errorCode?: string | null;
146
+ errorMessage?: string | null;
147
+ outputs: HarnessInputFrame[];
148
+ }>;
149
+ destroy(): Promise<void>;
150
+ }
151
+
152
+ export interface ModuleHarnessRuntimeDescriptor {
153
+ kind?: "process" | "wasmedge";
154
+ launchPlan?: PluginInvokeProcessLaunchPlan;
155
+ command?: string;
156
+ args?: string[];
157
+ env?: Record<string, string | undefined>;
158
+ cwd?: string;
159
+ wasmPath?: string;
160
+ wasmEdgeBinary?: string;
161
+ wasmEdgeRunnerBinary?: string;
162
+ enableThreads?: boolean;
163
+ }
164
+
165
+ export interface ModuleHarness {
166
+ runtime: ModuleHarnessRuntimeDescriptor & { kind: "process" | "wasmedge" };
167
+ launchPlan: PluginInvokeProcessLaunchPlan;
168
+ invokeRaw(requestBytes: Uint8Array | ArrayBuffer | ArrayBufferView): Promise<Uint8Array>;
169
+ invoke(request: {
170
+ methodId?: string | null;
171
+ inputs?: HarnessInputFrame[];
172
+ }): Promise<{
173
+ statusCode: number;
174
+ errorCode?: string | null;
175
+ errorMessage?: string | null;
176
+ outputs: HarnessInputFrame[];
177
+ }>;
178
+ destroy(): Promise<void>;
179
+ }
180
+
181
+ export interface WasmEdgeRunnerBuildPlan {
182
+ runnerSourcePath: string;
183
+ requestedIncludeDir: string;
184
+ wasmedgeIncludeDir: string;
185
+ wasmedgeLibDir: string;
186
+ wasmedgeSharedLibraryPath: string;
187
+ outputPath: string;
188
+ compilerCommand: string;
189
+ compilerArgs: string[];
190
+ }
191
+
60
192
  export function describeCapabilityRuntimeSurface(
61
193
  capability: string,
62
194
  ): CapabilityRuntimeSurface;
63
195
 
196
+ export function createPublicationProtectionDemoManifest(): PluginManifest;
197
+
198
+ export function createPublicationProtectionDemoSummary(options?: {
199
+ manifest?: PluginManifest;
200
+ wasmBytes?: Uint8Array;
201
+ mnemonic?: string | null;
202
+ recipient?: {
203
+ publicKeyHex: string;
204
+ privateKeyHex: string;
205
+ };
206
+ }): Promise<PublicationProtectionDemoSummary>;
207
+
64
208
  export function generateManifestHarnessPlan(options: {
65
209
  manifest: PluginManifest;
66
210
  includeOptionalInputs?: boolean;
@@ -84,3 +228,49 @@ export function materializeHarnessScenario(
84
228
  };
85
229
 
86
230
  export function serializeHarnessPlan(plan: ManifestHarnessPlan): unknown;
231
+
232
+ export function buildWasmEdgeSpawnEnv(
233
+ baseEnv?: Record<string, string | undefined>,
234
+ ): Record<string, string | undefined>;
235
+
236
+ export function resolveWasmEdgePluginLaunchPlan(options: {
237
+ wasmPath: string;
238
+ wasmEdgeBinary?: string;
239
+ wasmEdgeRunnerBinary?: string;
240
+ enableThreads?: boolean;
241
+ invokeArgs?: string[];
242
+ env?: Record<string, string | undefined>;
243
+ }): PluginInvokeProcessLaunchPlan;
244
+
245
+ export function createPluginInvokeProcessClient(options: {
246
+ launchPlan?: PluginInvokeProcessLaunchPlan;
247
+ command?: string;
248
+ args?: string[];
249
+ env?: Record<string, string | undefined>;
250
+ cwd?: string;
251
+ }): Promise<PluginInvokeProcessClient>;
252
+
253
+ export function resolveModuleHarnessLaunchPlan(options: {
254
+ runtime?: ModuleHarnessRuntimeDescriptor;
255
+ } | ModuleHarnessRuntimeDescriptor): PluginInvokeProcessLaunchPlan;
256
+
257
+ export function createModuleHarness(options: {
258
+ runtime?: ModuleHarnessRuntimeDescriptor;
259
+ } | ModuleHarnessRuntimeDescriptor): Promise<ModuleHarness>;
260
+
261
+ export function resolveWasmEdgeRunnerSourcePath(): string;
262
+
263
+ export function resolveWasmEdgeRunnerBuildPlan(options: {
264
+ outputPath: string;
265
+ wasmedgeIncludeDir?: string;
266
+ wasmedgeLibDir?: string;
267
+ output?: string;
268
+ }): WasmEdgeRunnerBuildPlan;
269
+
270
+ export function buildWasmEdgeEmscriptenPthreadRunner(options: {
271
+ outputPath: string;
272
+ wasmedgeIncludeDir?: string;
273
+ wasmedgeLibDir?: string;
274
+ output?: string;
275
+ cwd?: string;
276
+ }): Promise<string>;
@@ -1,6 +1,26 @@
1
+ import { Buffer } from "node:buffer";
2
+
1
3
  import { encodePluginInvokeRequest } from "../invoke/codec.js";
2
4
  import { normalizeInvokeSurfaces } from "../invoke/index.js";
3
5
  import { selectPreferredPayloadTypeRef } from "../manifest/typeRefs.js";
6
+ export {
7
+ createPublicationProtectionDemoManifest,
8
+ createPublicationProtectionDemoSummary,
9
+ } from "./publicationProtectionDemo.js";
10
+ export {
11
+ buildWasmEdgeSpawnEnv,
12
+ createPluginInvokeProcessClient,
13
+ resolveWasmEdgePluginLaunchPlan,
14
+ } from "./processInvoke.js";
15
+ export {
16
+ buildWasmEdgeEmscriptenPthreadRunner,
17
+ resolveWasmEdgeRunnerBuildPlan,
18
+ resolveWasmEdgeRunnerSourcePath,
19
+ } from "./buildWasmEdgeRunner.js";
20
+ export {
21
+ createModuleHarness,
22
+ resolveModuleHarnessLaunchPlan,
23
+ } from "./moduleHarness.js";
4
24
 
5
25
  const CapabilitySurfaceMatrix = Object.freeze({
6
26
  logging: Object.freeze({
@@ -0,0 +1,62 @@
1
+ import {
2
+ createPluginInvokeProcessClient,
3
+ resolveWasmEdgePluginLaunchPlan,
4
+ } from "./processInvoke.js";
5
+
6
+ function normalizeRuntimeDescriptor(options = {}) {
7
+ if (options.runtime && typeof options.runtime === "object") {
8
+ return options.runtime;
9
+ }
10
+ return options;
11
+ }
12
+
13
+ export function resolveModuleHarnessLaunchPlan(options = {}) {
14
+ const runtime = normalizeRuntimeDescriptor(options);
15
+ if (runtime.launchPlan && typeof runtime.launchPlan === "object") {
16
+ return runtime.launchPlan;
17
+ }
18
+
19
+ const kind = String(runtime.kind ?? "process").trim().toLowerCase();
20
+ if (kind === "wasmedge") {
21
+ return resolveWasmEdgePluginLaunchPlan(runtime);
22
+ }
23
+ if (kind === "process") {
24
+ if (typeof runtime.command !== "string" || runtime.command.trim().length === 0) {
25
+ throw new Error(
26
+ "resolveModuleHarnessLaunchPlan requires runtime.command for process runtimes.",
27
+ );
28
+ }
29
+ return {
30
+ command: runtime.command,
31
+ args: Array.isArray(runtime.args) ? runtime.args : [],
32
+ env: runtime.env,
33
+ cwd: runtime.cwd,
34
+ };
35
+ }
36
+
37
+ throw new Error(`Unsupported module harness runtime kind: ${kind}`);
38
+ }
39
+
40
+ export async function createModuleHarness(options = {}) {
41
+ const runtime = normalizeRuntimeDescriptor(options);
42
+ const kind = String(runtime.kind ?? "process").trim().toLowerCase();
43
+ const launchPlan = resolveModuleHarnessLaunchPlan(options);
44
+ const processClient = await createPluginInvokeProcessClient({ launchPlan });
45
+
46
+ return {
47
+ runtime: {
48
+ ...runtime,
49
+ kind,
50
+ },
51
+ launchPlan,
52
+ invokeRaw(requestBytes) {
53
+ return processClient.invokeRaw(requestBytes);
54
+ },
55
+ invoke(request) {
56
+ return processClient.invoke(request);
57
+ },
58
+ destroy() {
59
+ return processClient.destroy();
60
+ },
61
+ };
62
+ }