space-data-module-sdk 0.7.0 → 0.8.1
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 +16 -23
- package/bin/space-data-module.js +5 -3
- package/package.json +2 -2
- package/schemas/spacedatastandards/PLG.fbs +191 -0
- package/src/AGENTS.md +1 -1
- package/src/bundle/AGENTS.md +6 -5
- package/src/bundle/codec.js +163 -48
- package/src/bundle/constants.js +1 -1
- package/src/bundle/wasm.js +53 -32
- package/src/compiler/compileModule.js +9 -1
- package/src/compliance/index.js +4 -0
- package/src/compliance/pluginCompliance.js +158 -2
- package/src/embeddedManifest.js +25 -5
- package/src/generated/orbpro/invoke/plugin-invoke-request.js +2 -2
- package/src/generated/orbpro/invoke/plugin-invoke-response.js +2 -2
- package/src/generated/orbpro/stream/flat-buffer-type-ref.js +2 -2
- package/src/generated/orbpro/stream/typed-arena-buffer.js +2 -2
- package/src/generated/spacedatastandards/plg/entry-function.js +86 -0
- package/src/generated/spacedatastandards/plg/entry-function.ts +119 -0
- package/src/generated/spacedatastandards/plg/index.js +16 -0
- package/src/generated/spacedatastandards/plg/index.ts +11 -0
- package/src/generated/spacedatastandards/plg/plg.js +657 -0
- package/src/generated/spacedatastandards/plg/plg.ts +924 -0
- package/src/generated/spacedatastandards/plg/plugin-capability.js +66 -0
- package/src/generated/spacedatastandards/plg/plugin-capability.ts +84 -0
- package/src/generated/spacedatastandards/plg/plugin-category.js +15 -0
- package/src/generated/spacedatastandards/plg/plugin-category.ts +53 -0
- package/src/generated/spacedatastandards/plg/plugin-dependency.js +63 -0
- package/src/generated/spacedatastandards/plg/plugin-dependency.ts +86 -0
- package/src/generated/spacedatastandards/plg/publication-state.js +9 -0
- package/src/generated/spacedatastandards/plg/publication-state.ts +23 -0
- package/src/generated/spacedatastandards/plg/purchase-tier.js +9 -0
- package/src/generated/spacedatastandards/plg/purchase-tier.ts +23 -0
- package/src/index.d.ts +1 -1
- package/src/invoke/codec.js +1 -1
- package/src/manifest/browser.js +7 -0
- package/src/manifest/index.js +7 -0
- package/src/manifest/legacyToPlg.js +249 -0
- package/src/manifest/plgCodec.js +826 -0
- package/src/standards/sharedCatalog.js +132 -0
- package/src/transport/records.js +34 -3
- package/src/vendor/flatbuffers/LICENSE +202 -0
- package/src/vendor/flatbuffers/builder.js +534 -0
- package/src/vendor/flatbuffers/byte-buffer.js +253 -0
- package/src/vendor/flatbuffers/constants.js +4 -0
- package/src/vendor/flatbuffers/encoding.js +5 -0
- package/src/vendor/flatbuffers/flatbuffers.js +5 -0
- package/src/vendor/flatbuffers/utils.js +4 -0
- package/schemas/ModuleBundle.fbs +0 -108
- package/src/generated/orbpro/module/canonicalization-rule.d.ts +0 -48
- package/src/generated/orbpro/module/canonicalization-rule.js +0 -95
- package/src/generated/orbpro/module/canonicalization-rule.ts +0 -142
- package/src/generated/orbpro/module/module-bundle-entry-role.d.ts +0 -11
- package/src/generated/orbpro/module/module-bundle-entry-role.js +0 -14
- package/src/generated/orbpro/module/module-bundle-entry-role.ts +0 -15
- package/src/generated/orbpro/module/module-bundle-entry.d.ts +0 -97
- package/src/generated/orbpro/module/module-bundle-entry.js +0 -219
- package/src/generated/orbpro/module/module-bundle-entry.ts +0 -287
- package/src/generated/orbpro/module/module-bundle.d.ts +0 -86
- package/src/generated/orbpro/module/module-bundle.js +0 -213
- package/src/generated/orbpro/module/module-bundle.ts +0 -277
- package/src/generated/orbpro/module/module-payload-encoding.d.ts +0 -9
- package/src/generated/orbpro/module/module-payload-encoding.js +0 -12
- package/src/generated/orbpro/module/module-payload-encoding.ts +0 -13
- package/src/generated/orbpro/module.d.ts +0 -5
- package/src/generated/orbpro/module.js +0 -7
- package/src/generated/orbpro/module.ts +0 -9
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a legacy PluginManifest-shaped JS object (the internal "PMAN"
|
|
3
|
+
* schema used prior to SDK 0.8.x) to an object accepted by
|
|
4
|
+
* `encodePlgManifest`.
|
|
5
|
+
*
|
|
6
|
+
* This lets plugin-manifest.json files authored against the old schema
|
|
7
|
+
* continue to work while the embedded manifest bytes switch to the
|
|
8
|
+
* canonical spacedatastandards.org PLG schema.
|
|
9
|
+
*
|
|
10
|
+
* Lossy mappings:
|
|
11
|
+
* - plugin_family → plugin_type (best-effort; families without a PLG
|
|
12
|
+
* counterpart fall back to `Analysis`).
|
|
13
|
+
* - methods[].input_ports/output_ports → EntryFunction.input_schemas /
|
|
14
|
+
* output_schema (first accepted type per port).
|
|
15
|
+
* - drain_policy, max_batch, port cardinalities, timers, protocols,
|
|
16
|
+
* invoke_surfaces, runtime_targets, build_artifacts are dropped;
|
|
17
|
+
* these are runtime-host concerns that live out-of-band under PLG.
|
|
18
|
+
* - schemas_used → required_schemas (type name only).
|
|
19
|
+
* - capabilities[] preserved; each entry becomes a
|
|
20
|
+
* PluginCapability {name, required}. (The "scope" on legacy entries is
|
|
21
|
+
* folded into the capability name as `kind#scope` if present.)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { CapabilityKind } from "../generated/orbpro/manifest/capability-kind.js";
|
|
25
|
+
|
|
26
|
+
const FAMILY_TO_PLUGIN_TYPE = Object.freeze({
|
|
27
|
+
sensor: "sensor",
|
|
28
|
+
propagator: "propagator",
|
|
29
|
+
renderer: "renderer",
|
|
30
|
+
analysis: "analysis",
|
|
31
|
+
data_source: "datasource",
|
|
32
|
+
datasource: "datasource",
|
|
33
|
+
comms: "comms",
|
|
34
|
+
shader: "shader",
|
|
35
|
+
sdf: "shader",
|
|
36
|
+
infrastructure: "analysis",
|
|
37
|
+
flow: "analysis",
|
|
38
|
+
bridge: "analysis",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function normalizePluginTypeFromFamily(family) {
|
|
42
|
+
if (typeof family !== "string") {
|
|
43
|
+
return "analysis";
|
|
44
|
+
}
|
|
45
|
+
const key = family.trim().toLowerCase().replace(/-/g, "_");
|
|
46
|
+
return FAMILY_TO_PLUGIN_TYPE[key] ?? "analysis";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function normalizeCapabilityName(value) {
|
|
50
|
+
if (typeof value === "string") {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
if (typeof value === "number" && typeof CapabilityKind[value] === "string") {
|
|
54
|
+
return CapabilityKind[value].toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function firstTypeName(port) {
|
|
60
|
+
if (!port || typeof port !== "object") {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const sets = port.acceptedTypeSets ?? port.accepted_type_sets;
|
|
64
|
+
if (!Array.isArray(sets)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
for (const set of sets) {
|
|
68
|
+
const allowed = set?.allowedTypes ?? set?.allowed_types;
|
|
69
|
+
if (!Array.isArray(allowed)) continue;
|
|
70
|
+
for (const entry of allowed) {
|
|
71
|
+
if (typeof entry === "string" && entry.length > 0) {
|
|
72
|
+
return entry;
|
|
73
|
+
}
|
|
74
|
+
if (entry && typeof entry === "object") {
|
|
75
|
+
const name = entry.name ?? entry.typeName ?? entry.type_name;
|
|
76
|
+
if (typeof name === "string" && name.length > 0) {
|
|
77
|
+
return name;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Fallback: if allowedTypes is empty, use the set_id as a schema hint.
|
|
82
|
+
const setId = set?.setId ?? set?.set_id;
|
|
83
|
+
if (typeof setId === "string" && setId.length > 0) {
|
|
84
|
+
return setId;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function toEntryFunction(method) {
|
|
91
|
+
const name = method?.methodId ?? method?.method_id ?? method?.name;
|
|
92
|
+
if (typeof name !== "string" || name.length === 0) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const inputPorts = method?.inputPorts ?? method?.input_ports ?? [];
|
|
96
|
+
const outputPorts = method?.outputPorts ?? method?.output_ports ?? [];
|
|
97
|
+
const inputSchemas = Array.isArray(inputPorts)
|
|
98
|
+
? inputPorts.map((port) => firstTypeName(port)).filter(Boolean)
|
|
99
|
+
: [];
|
|
100
|
+
const outputSchema = Array.isArray(outputPorts)
|
|
101
|
+
? firstTypeName(outputPorts[0])
|
|
102
|
+
: null;
|
|
103
|
+
const description =
|
|
104
|
+
typeof method?.description === "string" ? method.description : undefined;
|
|
105
|
+
return {
|
|
106
|
+
name,
|
|
107
|
+
description,
|
|
108
|
+
inputSchemas,
|
|
109
|
+
outputSchema: outputSchema || undefined,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function toPluginCapability(capability) {
|
|
114
|
+
if (typeof capability === "string") {
|
|
115
|
+
return { name: capability, required: true };
|
|
116
|
+
}
|
|
117
|
+
if (!capability || typeof capability !== "object") {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const kind =
|
|
121
|
+
normalizeCapabilityName(capability.capability) ??
|
|
122
|
+
normalizeCapabilityName(capability.kind) ??
|
|
123
|
+
normalizeCapabilityName(capability.name);
|
|
124
|
+
if (!kind) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const scope =
|
|
128
|
+
typeof capability.scope === "string" && capability.scope.trim().length > 0
|
|
129
|
+
? capability.scope.trim()
|
|
130
|
+
: null;
|
|
131
|
+
const name = scope ? `${kind}#${scope}` : kind;
|
|
132
|
+
const required = capability.required !== false;
|
|
133
|
+
const version =
|
|
134
|
+
typeof capability.version === "string" ? capability.version : undefined;
|
|
135
|
+
return { name, version, required };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function toRequiredSchemas(schemasUsed) {
|
|
139
|
+
if (!Array.isArray(schemasUsed)) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
const names = [];
|
|
143
|
+
for (const entry of schemasUsed) {
|
|
144
|
+
if (typeof entry === "string" && entry.length > 0) {
|
|
145
|
+
names.push(entry);
|
|
146
|
+
} else if (entry && typeof entry === "object") {
|
|
147
|
+
const name = entry.name ?? entry.typeName ?? entry.type_name;
|
|
148
|
+
if (typeof name === "string" && name.length > 0) {
|
|
149
|
+
names.push(name);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// De-duplicate while preserving order.
|
|
154
|
+
return Array.from(new Set(names));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Convert a legacy PluginManifest-shaped input to a PLG-shaped object.
|
|
159
|
+
* If the input already looks like a PLG object (has entryFunctions OR
|
|
160
|
+
* pluginType, and no `methods`), it is returned as-is with camelCase
|
|
161
|
+
* normalization.
|
|
162
|
+
*/
|
|
163
|
+
export function legacyManifestToPlg(input = {}) {
|
|
164
|
+
if (!input || typeof input !== "object") {
|
|
165
|
+
throw new TypeError("legacyManifestToPlg expects a plain object.");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const hasLegacyMethods = Array.isArray(input.methods);
|
|
169
|
+
const hasPlgEntries = Array.isArray(input.entryFunctions);
|
|
170
|
+
|
|
171
|
+
const pluginType = hasLegacyMethods
|
|
172
|
+
? normalizePluginTypeFromFamily(input.pluginFamily ?? input.plugin_family)
|
|
173
|
+
: typeof input.pluginType === "string"
|
|
174
|
+
? input.pluginType
|
|
175
|
+
: typeof input.plugin_type === "string"
|
|
176
|
+
? input.plugin_type
|
|
177
|
+
: normalizePluginTypeFromFamily(input.pluginFamily);
|
|
178
|
+
|
|
179
|
+
const entryFunctions = hasPlgEntries
|
|
180
|
+
? input.entryFunctions
|
|
181
|
+
: hasLegacyMethods
|
|
182
|
+
? input.methods.map((method) => toEntryFunction(method)).filter(Boolean)
|
|
183
|
+
: [];
|
|
184
|
+
|
|
185
|
+
const requiredSchemas = Array.isArray(input.requiredSchemas)
|
|
186
|
+
? input.requiredSchemas
|
|
187
|
+
: toRequiredSchemas(input.schemasUsed ?? input.schemas_used);
|
|
188
|
+
|
|
189
|
+
const capabilities = Array.isArray(input.capabilities)
|
|
190
|
+
? input.capabilities.map((cap) => toPluginCapability(cap)).filter(Boolean)
|
|
191
|
+
: [];
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
pluginId: input.pluginId ?? input.plugin_id ?? input.PLUGIN_ID,
|
|
195
|
+
name: input.name ?? input.NAME,
|
|
196
|
+
version: input.version ?? input.VERSION,
|
|
197
|
+
description: input.description ?? input.DESCRIPTION,
|
|
198
|
+
tagline: input.tagline ?? input.TAGLINE,
|
|
199
|
+
pluginType,
|
|
200
|
+
publisherName: input.publisherName ?? input.publisher_name,
|
|
201
|
+
publisherHandle: input.publisherHandle ?? input.publisher_handle,
|
|
202
|
+
publisherUrl: input.publisherUrl ?? input.publisher_url,
|
|
203
|
+
supportUrl: input.supportUrl ?? input.support_url,
|
|
204
|
+
tags: Array.isArray(input.tags) ? input.tags : [],
|
|
205
|
+
features: Array.isArray(input.features) ? input.features : [],
|
|
206
|
+
screenshotUrls: Array.isArray(input.screenshotUrls)
|
|
207
|
+
? input.screenshotUrls
|
|
208
|
+
: [],
|
|
209
|
+
bannerUrl: input.bannerUrl ?? input.banner_url,
|
|
210
|
+
abiVersion: Number(input.abiVersion ?? input.abi_version ?? 1),
|
|
211
|
+
wasmHash: input.wasmHash ?? input.wasm_hash,
|
|
212
|
+
wasmSize: input.wasmSize ?? input.wasm_size,
|
|
213
|
+
wasmCid: input.wasmCid ?? input.wasm_cid,
|
|
214
|
+
entryFunctions,
|
|
215
|
+
requiredSchemas,
|
|
216
|
+
dependencies: Array.isArray(input.dependencies) ? input.dependencies : [],
|
|
217
|
+
capabilities,
|
|
218
|
+
providerPeerId: input.providerPeerId ?? input.provider_peer_id,
|
|
219
|
+
providerEpmCid: input.providerEpmCid ?? input.provider_epm_cid,
|
|
220
|
+
encrypted: input.encrypted === true,
|
|
221
|
+
requiredScope: input.requiredScope ?? input.required_scope,
|
|
222
|
+
keyId: input.keyId ?? input.key_id,
|
|
223
|
+
allowedDomains: Array.isArray(input.allowedDomains)
|
|
224
|
+
? input.allowedDomains
|
|
225
|
+
: [],
|
|
226
|
+
maxGrantTimeoutMs: input.maxGrantTimeoutMs ?? input.max_grant_timeout_ms,
|
|
227
|
+
minPermissions: Array.isArray(input.minPermissions)
|
|
228
|
+
? input.minPermissions
|
|
229
|
+
: Array.isArray(input.runtimeTargets)
|
|
230
|
+
? input.runtimeTargets
|
|
231
|
+
: [],
|
|
232
|
+
createdAt: input.createdAt ?? input.created_at,
|
|
233
|
+
updatedAt: input.updatedAt ?? input.updated_at,
|
|
234
|
+
documentationUrl: input.documentationUrl ?? input.documentation_url,
|
|
235
|
+
changelogUrl: input.changelogUrl ?? input.changelog_url,
|
|
236
|
+
iconUrl: input.iconUrl ?? input.icon_url,
|
|
237
|
+
license: input.license ?? input.LICENSE,
|
|
238
|
+
paymentModel: input.paymentModel ?? input.payment_model ?? "free",
|
|
239
|
+
priceUsdCents: Number(input.priceUsdCents ?? input.price_usd_cents ?? 0),
|
|
240
|
+
subscriptionPeriodDays: Number(
|
|
241
|
+
input.subscriptionPeriodDays ?? input.subscription_period_days ?? 0,
|
|
242
|
+
),
|
|
243
|
+
acceptedPaymentMethods: Array.isArray(input.acceptedPaymentMethods)
|
|
244
|
+
? input.acceptedPaymentMethods
|
|
245
|
+
: [],
|
|
246
|
+
listingStatus: input.listingStatus ?? input.listing_status ?? "public",
|
|
247
|
+
signature: input.signature ?? input.SIGNATURE,
|
|
248
|
+
};
|
|
249
|
+
}
|