space-data-module-sdk 0.1.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 +139 -0
- package/bin/space-data-module.js +230 -0
- package/package.json +40 -0
- package/schemas/PluginManifest.fbs +144 -0
- package/schemas/TypedArenaBuffer.fbs +78 -0
- package/src/auth/canonicalize.js +72 -0
- package/src/auth/index.js +10 -0
- package/src/auth/permissions.js +190 -0
- package/src/compiler/compileModule.js +237 -0
- package/src/compiler/index.js +7 -0
- package/src/compliance/index.js +56 -0
- package/src/compliance/pluginCompliance.js +574 -0
- package/src/embeddedManifest.js +124 -0
- package/src/generated/orbpro/manifest/accepted-type-set.d.ts +45 -0
- package/src/generated/orbpro/manifest/accepted-type-set.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/accepted-type-set.js +100 -0
- package/src/generated/orbpro/manifest/accepted-type-set.js.map +1 -0
- package/src/generated/orbpro/manifest/accepted-type-set.ts +200 -0
- package/src/generated/orbpro/manifest/build-artifact.d.ts +41 -0
- package/src/generated/orbpro/manifest/build-artifact.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/build-artifact.js +105 -0
- package/src/generated/orbpro/manifest/build-artifact.js.map +1 -0
- package/src/generated/orbpro/manifest/build-artifact.ts +193 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts +17 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/capability-kind.js +20 -0
- package/src/generated/orbpro/manifest/capability-kind.js.map +1 -0
- package/src/generated/orbpro/manifest/capability-kind.ts +20 -0
- package/src/generated/orbpro/manifest/drain-policy.d.ts +9 -0
- package/src/generated/orbpro/manifest/drain-policy.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/drain-policy.js +12 -0
- package/src/generated/orbpro/manifest/drain-policy.js.map +1 -0
- package/src/generated/orbpro/manifest/drain-policy.ts +12 -0
- package/src/generated/orbpro/manifest/host-capability.d.ts +36 -0
- package/src/generated/orbpro/manifest/host-capability.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/host-capability.js +91 -0
- package/src/generated/orbpro/manifest/host-capability.js.map +1 -0
- package/src/generated/orbpro/manifest/host-capability.ts +161 -0
- package/src/generated/orbpro/manifest/method-manifest.d.ts +53 -0
- package/src/generated/orbpro/manifest/method-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/method-manifest.js +154 -0
- package/src/generated/orbpro/manifest/method-manifest.js.map +1 -0
- package/src/generated/orbpro/manifest/method-manifest.ts +306 -0
- package/src/generated/orbpro/manifest/plugin-family.d.ts +17 -0
- package/src/generated/orbpro/manifest/plugin-family.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/plugin-family.js +20 -0
- package/src/generated/orbpro/manifest/plugin-family.js.map +1 -0
- package/src/generated/orbpro/manifest/plugin-family.ts +20 -0
- package/src/generated/orbpro/manifest/plugin-manifest.d.ts +85 -0
- package/src/generated/orbpro/manifest/plugin-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/plugin-manifest.js +268 -0
- package/src/generated/orbpro/manifest/plugin-manifest.js.map +1 -0
- package/src/generated/orbpro/manifest/plugin-manifest.ts +562 -0
- package/src/generated/orbpro/manifest/port-manifest.d.ts +70 -0
- package/src/generated/orbpro/manifest/port-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/port-manifest.js +150 -0
- package/src/generated/orbpro/manifest/port-manifest.js.map +1 -0
- package/src/generated/orbpro/manifest/port-manifest.ts +284 -0
- package/src/generated/orbpro/manifest/protocol-spec.d.ts +41 -0
- package/src/generated/orbpro/manifest/protocol-spec.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/protocol-spec.js +105 -0
- package/src/generated/orbpro/manifest/protocol-spec.js.map +1 -0
- package/src/generated/orbpro/manifest/protocol-spec.ts +205 -0
- package/src/generated/orbpro/manifest/timer-spec.d.ts +40 -0
- package/src/generated/orbpro/manifest/timer-spec.d.ts.map +1 -0
- package/src/generated/orbpro/manifest/timer-spec.js +104 -0
- package/src/generated/orbpro/manifest/timer-spec.js.map +1 -0
- package/src/generated/orbpro/manifest/timer-spec.ts +195 -0
- package/src/generated/orbpro/manifest.js +14 -0
- package/src/generated/orbpro/stream/buffer-mutability.d.ts +9 -0
- package/src/generated/orbpro/stream/buffer-mutability.d.ts.map +1 -0
- package/src/generated/orbpro/stream/buffer-mutability.js +12 -0
- package/src/generated/orbpro/stream/buffer-mutability.js.map +1 -0
- package/src/generated/orbpro/stream/buffer-mutability.ts +12 -0
- package/src/generated/orbpro/stream/buffer-ownership.d.ts +10 -0
- package/src/generated/orbpro/stream/buffer-ownership.d.ts.map +1 -0
- package/src/generated/orbpro/stream/buffer-ownership.js +13 -0
- package/src/generated/orbpro/stream/buffer-ownership.js.map +1 -0
- package/src/generated/orbpro/stream/buffer-ownership.ts +13 -0
- package/src/generated/orbpro/stream/flat-buffer-type-ref.d.ts +51 -0
- package/src/generated/orbpro/stream/flat-buffer-type-ref.d.ts.map +1 -0
- package/src/generated/orbpro/stream/flat-buffer-type-ref.js +115 -0
- package/src/generated/orbpro/stream/flat-buffer-type-ref.js.map +1 -0
- package/src/generated/orbpro/stream/flat-buffer-type-ref.ts +222 -0
- package/src/generated/orbpro/stream/typed-arena-buffer.d.ts +100 -0
- package/src/generated/orbpro/stream/typed-arena-buffer.d.ts.map +1 -0
- package/src/generated/orbpro/stream/typed-arena-buffer.js +215 -0
- package/src/generated/orbpro/stream/typed-arena-buffer.js.map +1 -0
- package/src/generated/orbpro/stream/typed-arena-buffer.ts +344 -0
- package/src/index.js +8 -0
- package/src/manifest/codec.js +40 -0
- package/src/manifest/index.js +9 -0
- package/src/manifest/normalize.js +275 -0
- package/src/runtime/bufferLike.js +28 -0
- package/src/runtime/constants.js +34 -0
- package/src/standards/index.js +153 -0
- package/src/standards/sharedCatalog.js +196 -0
- package/src/transport/index.js +8 -0
- package/src/transport/pki.js +140 -0
- package/src/utils/crypto.js +8 -0
- package/src/utils/encoding.js +54 -0
- package/src/utils/wasmCrypto.js +70 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AcceptedTypeSetT,
|
|
3
|
+
BuildArtifactT,
|
|
4
|
+
CapabilityKind,
|
|
5
|
+
DrainPolicy as ManifestDrainPolicy,
|
|
6
|
+
HostCapabilityT,
|
|
7
|
+
MethodManifestT,
|
|
8
|
+
PluginFamily,
|
|
9
|
+
PluginManifestT,
|
|
10
|
+
PortManifestT,
|
|
11
|
+
ProtocolSpecT,
|
|
12
|
+
TimerSpecT,
|
|
13
|
+
} from "../generated/orbpro/manifest.js";
|
|
14
|
+
import { FlatBufferTypeRefT } from "../generated/orbpro/stream/flat-buffer-type-ref.js";
|
|
15
|
+
|
|
16
|
+
const pluginFamilyByName = Object.freeze({
|
|
17
|
+
sensor: PluginFamily.SENSOR,
|
|
18
|
+
propagator: PluginFamily.PROPAGATOR,
|
|
19
|
+
renderer: PluginFamily.RENDERER,
|
|
20
|
+
analysis: PluginFamily.ANALYSIS,
|
|
21
|
+
data_source: PluginFamily.DATA_SOURCE,
|
|
22
|
+
datasource: PluginFamily.DATA_SOURCE,
|
|
23
|
+
comms: PluginFamily.COMMS,
|
|
24
|
+
shader: PluginFamily.SHADER,
|
|
25
|
+
sdf: PluginFamily.SDF,
|
|
26
|
+
infrastructure: PluginFamily.INFRASTRUCTURE,
|
|
27
|
+
flow: PluginFamily.FLOW,
|
|
28
|
+
bridge: PluginFamily.BRIDGE,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const drainPolicyByName = Object.freeze({
|
|
32
|
+
"single-shot": ManifestDrainPolicy.SINGLE_SHOT,
|
|
33
|
+
"drain-until-yield": ManifestDrainPolicy.DRAIN_UNTIL_YIELD,
|
|
34
|
+
"drain-to-empty": ManifestDrainPolicy.DRAIN_TO_EMPTY,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const capabilityKindByName = Object.freeze({
|
|
38
|
+
clock: CapabilityKind.CLOCK,
|
|
39
|
+
random: CapabilityKind.RANDOM,
|
|
40
|
+
logging: CapabilityKind.LOGGING,
|
|
41
|
+
timers: CapabilityKind.TIMERS,
|
|
42
|
+
pubsub: CapabilityKind.PUBSUB,
|
|
43
|
+
protocol_dial: CapabilityKind.PROTOCOL_DIAL,
|
|
44
|
+
protocol_handle: CapabilityKind.PROTOCOL_HANDLE,
|
|
45
|
+
storage_query: CapabilityKind.STORAGE_QUERY,
|
|
46
|
+
scene_access: CapabilityKind.SCENE_ACCESS,
|
|
47
|
+
entity_access: CapabilityKind.ENTITY_ACCESS,
|
|
48
|
+
render_hooks: CapabilityKind.RENDER_HOOKS,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function normalizeSchemaHash(value) {
|
|
52
|
+
if (!value) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
return value.map((byte) => Number(byte) & 0xff);
|
|
57
|
+
}
|
|
58
|
+
const normalized = String(value).trim().replace(/^0x/i, "");
|
|
59
|
+
if (normalized.length === 0 || normalized.length % 2 !== 0) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const bytes = [];
|
|
63
|
+
for (let index = 0; index < normalized.length; index += 2) {
|
|
64
|
+
bytes.push(parseInt(normalized.slice(index, index + 2), 16));
|
|
65
|
+
}
|
|
66
|
+
return bytes;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function normalizePluginFamily(value) {
|
|
70
|
+
if (typeof value === "number") {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
const normalized = String(value ?? "analysis")
|
|
74
|
+
.trim()
|
|
75
|
+
.toLowerCase();
|
|
76
|
+
return pluginFamilyByName[normalized] ?? PluginFamily.ANALYSIS;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function normalizeDrainPolicy(value) {
|
|
80
|
+
if (typeof value === "number") {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
const normalized = String(value ?? "drain-until-yield")
|
|
84
|
+
.trim()
|
|
85
|
+
.toLowerCase();
|
|
86
|
+
return (
|
|
87
|
+
drainPolicyByName[normalized] ?? ManifestDrainPolicy.DRAIN_UNTIL_YIELD
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function normalizeCapabilityKind(value) {
|
|
92
|
+
if (typeof value === "number") {
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
const normalized = String(value ?? "")
|
|
96
|
+
.trim()
|
|
97
|
+
.toLowerCase();
|
|
98
|
+
return capabilityKindByName[normalized] ?? null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function toFlatBufferTypeRefT(value = {}) {
|
|
102
|
+
if (value instanceof FlatBufferTypeRefT) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
return new FlatBufferTypeRefT(
|
|
106
|
+
value.schemaName ?? null,
|
|
107
|
+
value.fileIdentifier ?? null,
|
|
108
|
+
normalizeSchemaHash(value.schemaHash),
|
|
109
|
+
value.acceptsAnyFlatbuffer === true,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function toAcceptedTypeSetT(value = {}) {
|
|
114
|
+
if (value instanceof AcceptedTypeSetT) {
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
return new AcceptedTypeSetT(
|
|
118
|
+
value.setId ?? null,
|
|
119
|
+
Array.isArray(value.allowedTypes)
|
|
120
|
+
? value.allowedTypes.map((entry) => toFlatBufferTypeRefT(entry))
|
|
121
|
+
: [],
|
|
122
|
+
value.description ?? null,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function toPortManifestT(value = {}) {
|
|
127
|
+
if (value instanceof PortManifestT) {
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
return new PortManifestT(
|
|
131
|
+
value.portId ?? null,
|
|
132
|
+
value.displayName ?? null,
|
|
133
|
+
Array.isArray(value.acceptedTypeSets)
|
|
134
|
+
? value.acceptedTypeSets.map((entry) => toAcceptedTypeSetT(entry))
|
|
135
|
+
: [],
|
|
136
|
+
Number(value.minStreams ?? 1),
|
|
137
|
+
Number(value.maxStreams ?? 1),
|
|
138
|
+
value.required !== false,
|
|
139
|
+
value.description ?? null,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function toMethodManifestT(value = {}) {
|
|
144
|
+
if (value instanceof MethodManifestT) {
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
return new MethodManifestT(
|
|
148
|
+
value.methodId ?? null,
|
|
149
|
+
value.displayName ?? null,
|
|
150
|
+
Array.isArray(value.inputPorts)
|
|
151
|
+
? value.inputPorts.map((entry) => toPortManifestT(entry))
|
|
152
|
+
: [],
|
|
153
|
+
Array.isArray(value.outputPorts)
|
|
154
|
+
? value.outputPorts.map((entry) => toPortManifestT(entry))
|
|
155
|
+
: [],
|
|
156
|
+
Number(value.maxBatch ?? 1),
|
|
157
|
+
normalizeDrainPolicy(value.drainPolicy),
|
|
158
|
+
value.description ?? null,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function toBuildArtifactT(value = {}) {
|
|
163
|
+
if (value instanceof BuildArtifactT) {
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
return new BuildArtifactT(
|
|
167
|
+
value.artifactId ?? null,
|
|
168
|
+
value.kind ?? null,
|
|
169
|
+
value.path ?? null,
|
|
170
|
+
value.target ?? null,
|
|
171
|
+
value.entrySymbol ?? null,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function toTimerSpecT(value = {}) {
|
|
176
|
+
if (value instanceof TimerSpecT) {
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
return new TimerSpecT(
|
|
180
|
+
value.timerId ?? null,
|
|
181
|
+
value.methodId ?? null,
|
|
182
|
+
value.inputPortId ?? null,
|
|
183
|
+
BigInt(value.defaultIntervalMs ?? 0),
|
|
184
|
+
value.description ?? null,
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function toProtocolSpecT(value = {}) {
|
|
189
|
+
if (value instanceof ProtocolSpecT) {
|
|
190
|
+
return value;
|
|
191
|
+
}
|
|
192
|
+
return new ProtocolSpecT(
|
|
193
|
+
value.protocolId ?? null,
|
|
194
|
+
value.methodId ?? null,
|
|
195
|
+
value.inputPortId ?? null,
|
|
196
|
+
value.outputPortId ?? null,
|
|
197
|
+
value.description ?? null,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function toHostCapabilityT(value, warnings) {
|
|
202
|
+
if (value instanceof HostCapabilityT) {
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
if (typeof value === "string") {
|
|
206
|
+
const capability = normalizeCapabilityKind(value);
|
|
207
|
+
if (capability === null) {
|
|
208
|
+
warnings.push(
|
|
209
|
+
`Capability "${value}" is not representable in the current embedded FlatBuffer manifest schema and was omitted.`,
|
|
210
|
+
);
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return new HostCapabilityT(capability, null, true, null);
|
|
214
|
+
}
|
|
215
|
+
const capability = normalizeCapabilityKind(value?.capability);
|
|
216
|
+
if (capability === null) {
|
|
217
|
+
warnings.push(
|
|
218
|
+
`Capability "${value?.capability ?? "unknown"}" is not representable in the current embedded FlatBuffer manifest schema and was omitted.`,
|
|
219
|
+
);
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
return new HostCapabilityT(
|
|
223
|
+
capability,
|
|
224
|
+
value?.scope ?? null,
|
|
225
|
+
value?.required !== false,
|
|
226
|
+
value?.description ?? null,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function toEmbeddedPluginManifest(input = {}) {
|
|
231
|
+
if (input instanceof PluginManifestT) {
|
|
232
|
+
return { manifest: input, warnings: [] };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const warnings = [];
|
|
236
|
+
if (Array.isArray(input.externalInterfaces) && input.externalInterfaces.length > 0) {
|
|
237
|
+
warnings.push(
|
|
238
|
+
"externalInterfaces are not yet representable in the embedded FlatBuffer manifest schema and were omitted from the compiled artifact.",
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const capabilities = Array.isArray(input.capabilities)
|
|
243
|
+
? input.capabilities
|
|
244
|
+
.map((entry) => toHostCapabilityT(entry, warnings))
|
|
245
|
+
.filter(Boolean)
|
|
246
|
+
: [];
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
manifest: new PluginManifestT(
|
|
250
|
+
input.pluginId ?? null,
|
|
251
|
+
input.name ?? null,
|
|
252
|
+
input.version ?? null,
|
|
253
|
+
normalizePluginFamily(input.pluginFamily),
|
|
254
|
+
Array.isArray(input.methods)
|
|
255
|
+
? input.methods.map((entry) => toMethodManifestT(entry))
|
|
256
|
+
: [],
|
|
257
|
+
capabilities,
|
|
258
|
+
Array.isArray(input.timers)
|
|
259
|
+
? input.timers.map((entry) => toTimerSpecT(entry))
|
|
260
|
+
: [],
|
|
261
|
+
Array.isArray(input.protocols)
|
|
262
|
+
? input.protocols.map((entry) => toProtocolSpecT(entry))
|
|
263
|
+
: [],
|
|
264
|
+
Array.isArray(input.schemasUsed)
|
|
265
|
+
? input.schemasUsed.map((entry) => toFlatBufferTypeRefT(entry))
|
|
266
|
+
: [],
|
|
267
|
+
Array.isArray(input.buildArtifacts)
|
|
268
|
+
? input.buildArtifacts.map((entry) => toBuildArtifactT(entry))
|
|
269
|
+
: [],
|
|
270
|
+
Number(input.abiVersion ?? 1),
|
|
271
|
+
),
|
|
272
|
+
warnings,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function getObjectTag(value) {
|
|
2
|
+
return Object.prototype.toString.call(value);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isArrayBufferLike(value) {
|
|
6
|
+
if (!value || typeof value !== "object") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const tag = getObjectTag(value);
|
|
10
|
+
return tag === "[object ArrayBuffer]" || tag === "[object SharedArrayBuffer]";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function hasByteAddressableBuffer(value) {
|
|
14
|
+
return isArrayBufferLike(value?.buffer);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function toUint8Array(value) {
|
|
18
|
+
if (value instanceof Uint8Array) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
if (ArrayBuffer.isView(value)) {
|
|
22
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
23
|
+
}
|
|
24
|
+
if (isArrayBufferLike(value)) {
|
|
25
|
+
return new Uint8Array(value);
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const DrainPolicy = Object.freeze({
|
|
2
|
+
SINGLE_SHOT: "single-shot",
|
|
3
|
+
DRAIN_UNTIL_YIELD: "drain-until-yield",
|
|
4
|
+
DRAIN_TO_EMPTY: "drain-to-empty",
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const ExternalInterfaceDirection = Object.freeze({
|
|
8
|
+
INPUT: "input",
|
|
9
|
+
OUTPUT: "output",
|
|
10
|
+
BIDIRECTIONAL: "bidirectional",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const ExternalInterfaceKind = Object.freeze({
|
|
14
|
+
CLOCK: "clock",
|
|
15
|
+
RANDOM: "random",
|
|
16
|
+
TIMER: "timer",
|
|
17
|
+
PUBSUB: "pubsub",
|
|
18
|
+
PROTOCOL: "protocol",
|
|
19
|
+
HTTP: "http",
|
|
20
|
+
FILESYSTEM: "filesystem",
|
|
21
|
+
PIPE: "pipe",
|
|
22
|
+
NETWORK: "network",
|
|
23
|
+
DATABASE: "database",
|
|
24
|
+
LOCAL_RUNTIME: "local-runtime",
|
|
25
|
+
HOST_SERVICE: "host-service",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DefaultManifestExports = Object.freeze({
|
|
29
|
+
pluginBytesSymbol: "plugin_get_manifest_flatbuffer",
|
|
30
|
+
pluginSizeSymbol: "plugin_get_manifest_flatbuffer_size",
|
|
31
|
+
flowBytesSymbol: "flow_get_manifest_flatbuffer",
|
|
32
|
+
flowSizeSymbol: "flow_get_manifest_flatbuffer_size",
|
|
33
|
+
});
|
|
34
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
|
|
5
|
+
import { sharedModuleCatalog } from "./sharedCatalog.js";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
let standardsCatalogPromise = null;
|
|
9
|
+
let knownTypeCatalogPromise = null;
|
|
10
|
+
|
|
11
|
+
function normalizeSchemaStem(value) {
|
|
12
|
+
const trimmed = String(value ?? "")
|
|
13
|
+
.trim()
|
|
14
|
+
.replace(/\\/g, "/")
|
|
15
|
+
.split("/")
|
|
16
|
+
.pop();
|
|
17
|
+
if (!trimmed) {
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
const withoutExtension = /\.(bfbs|fbs|json)$/i.test(trimmed)
|
|
21
|
+
? trimmed.replace(/\.[^.]+$/, "")
|
|
22
|
+
: trimmed;
|
|
23
|
+
return withoutExtension.split(".").pop().toUpperCase();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizeFileIdentifier(value) {
|
|
27
|
+
return String(value ?? "")
|
|
28
|
+
.trim()
|
|
29
|
+
.replace(/^\$/, "")
|
|
30
|
+
.toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function parseStandardsEntry([schemaCode, entry]) {
|
|
34
|
+
const idl = String(entry?.IDL ?? "");
|
|
35
|
+
const fileIdentifierMatch = idl.match(/file_identifier\s+"([^"]+)"/i);
|
|
36
|
+
const hashMatch = idl.match(/\/\/ Hash:\s*([a-f0-9]+)/i);
|
|
37
|
+
const versionMatch = idl.match(/\/\/ Version:\s*([^\n]+)/i);
|
|
38
|
+
return {
|
|
39
|
+
schemaCode: schemaCode.toUpperCase(),
|
|
40
|
+
schemaName: `${schemaCode.toUpperCase()}.fbs`,
|
|
41
|
+
fileIdentifier: fileIdentifierMatch
|
|
42
|
+
? normalizeFileIdentifier(fileIdentifierMatch[1])
|
|
43
|
+
: null,
|
|
44
|
+
hash: hashMatch ? hashMatch[1].toLowerCase() : null,
|
|
45
|
+
version: versionMatch ? versionMatch[1].trim() : null,
|
|
46
|
+
files: Array.isArray(entry?.files) ? entry.files : [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function loadStandardsCatalog() {
|
|
51
|
+
if (!standardsCatalogPromise) {
|
|
52
|
+
standardsCatalogPromise = (async () => {
|
|
53
|
+
const packageEntry = require.resolve("spacedatastandards.org");
|
|
54
|
+
const packageRoot = path.dirname(packageEntry);
|
|
55
|
+
const manifestPath = path.join(packageRoot, "dist", "manifest.json");
|
|
56
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
57
|
+
return Object.entries(manifest?.STANDARDS ?? {})
|
|
58
|
+
.map(parseStandardsEntry)
|
|
59
|
+
.sort((left, right) => left.schemaCode.localeCompare(right.schemaCode));
|
|
60
|
+
})();
|
|
61
|
+
}
|
|
62
|
+
return standardsCatalogPromise;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function loadKnownTypeCatalog() {
|
|
66
|
+
if (!knownTypeCatalogPromise) {
|
|
67
|
+
knownTypeCatalogPromise = loadStandardsCatalog().then((catalog) => [
|
|
68
|
+
...catalog,
|
|
69
|
+
...sharedModuleCatalog,
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
return knownTypeCatalogPromise;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function resolveStandardsTypeRef(typeRef, catalog = []) {
|
|
76
|
+
const schemaStem = normalizeSchemaStem(typeRef?.schemaName);
|
|
77
|
+
const fileIdentifier = normalizeFileIdentifier(typeRef?.fileIdentifier);
|
|
78
|
+
if (!schemaStem && !fileIdentifier) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return (
|
|
82
|
+
catalog.find((entry) => {
|
|
83
|
+
if (schemaStem && entry.schemaCode === schemaStem) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (fileIdentifier && entry.fileIdentifier === fileIdentifier) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}) ?? null
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function collectTypeRefs(manifest) {
|
|
95
|
+
const refs = [];
|
|
96
|
+
for (const method of Array.isArray(manifest?.methods) ? manifest.methods : []) {
|
|
97
|
+
for (const portsKey of ["inputPorts", "outputPorts"]) {
|
|
98
|
+
for (const port of Array.isArray(method?.[portsKey]) ? method[portsKey] : []) {
|
|
99
|
+
for (const typeSet of Array.isArray(port?.acceptedTypeSets)
|
|
100
|
+
? port.acceptedTypeSets
|
|
101
|
+
: []) {
|
|
102
|
+
for (const allowedType of Array.isArray(typeSet?.allowedTypes)
|
|
103
|
+
? typeSet.allowedTypes
|
|
104
|
+
: []) {
|
|
105
|
+
refs.push({
|
|
106
|
+
source: `${method?.methodId ?? "method"}.${port?.portId ?? "port"}`,
|
|
107
|
+
typeRef: allowedType,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const typeRef of Array.isArray(manifest?.schemasUsed)
|
|
115
|
+
? manifest.schemasUsed
|
|
116
|
+
: []) {
|
|
117
|
+
refs.push({
|
|
118
|
+
source: "schemasUsed",
|
|
119
|
+
typeRef,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return refs;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function validateManifestAgainstStandardsCatalog(
|
|
126
|
+
manifest,
|
|
127
|
+
options = {},
|
|
128
|
+
) {
|
|
129
|
+
const catalog = options.catalog ?? (await loadKnownTypeCatalog());
|
|
130
|
+
const sourceName = options.sourceName ?? "manifest";
|
|
131
|
+
const issues = [];
|
|
132
|
+
for (const { source, typeRef } of collectTypeRefs(manifest)) {
|
|
133
|
+
if (typeRef?.acceptsAnyFlatbuffer === true) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const resolved = resolveStandardsTypeRef(typeRef, catalog);
|
|
137
|
+
if (!resolved) {
|
|
138
|
+
issues.push({
|
|
139
|
+
severity: "warning",
|
|
140
|
+
code: "unresolved-standards-type",
|
|
141
|
+
message:
|
|
142
|
+
`Type reference from ${source} does not resolve to a known ` +
|
|
143
|
+
"shared-module or `spacedatastandards.org` schema by schemaName " +
|
|
144
|
+
"or fileIdentifier.",
|
|
145
|
+
location: `${sourceName}.${source}`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
catalog,
|
|
151
|
+
issues,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
const sharedModuleCatalogEntries = [
|
|
2
|
+
{
|
|
3
|
+
schemaCode: "TIMERTICK",
|
|
4
|
+
schemaName: "TimerTick.fbs",
|
|
5
|
+
fileIdentifier: "TICK",
|
|
6
|
+
source: "shared-module-runtime",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
schemaCode: "HTTPREQUEST",
|
|
10
|
+
schemaName: "HttpRequest.fbs",
|
|
11
|
+
fileIdentifier: "HREQ",
|
|
12
|
+
source: "shared-module-runtime",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
schemaCode: "HTTPRESPONSE",
|
|
16
|
+
schemaName: "HttpResponse.fbs",
|
|
17
|
+
fileIdentifier: "HRSP",
|
|
18
|
+
source: "shared-module-runtime",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
schemaCode: "DETACHEDSIGNATURE",
|
|
22
|
+
schemaName: "DetachedSignature.fbs",
|
|
23
|
+
fileIdentifier: "SIGD",
|
|
24
|
+
source: "shared-module-security",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
schemaCode: "FIELDPROTECTIONREQUEST",
|
|
28
|
+
schemaName: "FieldProtectionRequest.fbs",
|
|
29
|
+
fileIdentifier: "FPRQ",
|
|
30
|
+
source: "shared-module-security",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
schemaCode: "FIELDSELECTIONBUNDLE",
|
|
34
|
+
schemaName: "FieldSelectionBundle.fbs",
|
|
35
|
+
fileIdentifier: "FSLB",
|
|
36
|
+
source: "shared-module-security",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
schemaCode: "ENCRYPTEDFIELDSET",
|
|
40
|
+
schemaName: "EncryptedFieldSet.fbs",
|
|
41
|
+
fileIdentifier: "EFLD",
|
|
42
|
+
source: "shared-module-security",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
schemaCode: "ANCHORRADIUSQUERY",
|
|
46
|
+
schemaName: "AnchorRadiusQuery.fbs",
|
|
47
|
+
fileIdentifier: "ARQY",
|
|
48
|
+
source: "shared-module-data",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
schemaCode: "OBSERVATIONBATCH",
|
|
52
|
+
schemaName: "ObservationBatch.fbs",
|
|
53
|
+
fileIdentifier: "OBSV",
|
|
54
|
+
source: "shared-module-data",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
schemaCode: "ASSOCIATIONBATCH",
|
|
58
|
+
schemaName: "AssociationBatch.fbs",
|
|
59
|
+
fileIdentifier: "ASSC",
|
|
60
|
+
source: "shared-module-data",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
schemaCode: "SAMPLEDORBIT",
|
|
64
|
+
schemaName: "SampledOrbit.fbs",
|
|
65
|
+
fileIdentifier: "SAMP",
|
|
66
|
+
source: "shared-module-data",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
schemaCode: "SENSORINPUT",
|
|
70
|
+
schemaName: "SensorInput.fbs",
|
|
71
|
+
fileIdentifier: "SENS",
|
|
72
|
+
source: "shared-module-data",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
schemaCode: "SENSORRESULT",
|
|
76
|
+
schemaName: "SensorResult.fbs",
|
|
77
|
+
fileIdentifier: "SRES",
|
|
78
|
+
source: "shared-module-data",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
schemaCode: "STATEVECTOR",
|
|
82
|
+
schemaName: "StateVector.fbs",
|
|
83
|
+
fileIdentifier: "STVC",
|
|
84
|
+
source: "shared-module-data",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
schemaCode: "STOREDRECORDREF",
|
|
88
|
+
schemaName: "StoredRecordRef.fbs",
|
|
89
|
+
fileIdentifier: "STRF",
|
|
90
|
+
source: "shared-module-data",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
schemaCode: "ALIGNEDRECORDBATCH",
|
|
94
|
+
schemaName: "AlignedRecordBatch.fbs",
|
|
95
|
+
fileIdentifier: "RECS",
|
|
96
|
+
source: "shared-module-data",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
schemaCode: "SQLQUERYREQUEST",
|
|
100
|
+
schemaName: "SqlQueryRequest.fbs",
|
|
101
|
+
fileIdentifier: "SQLQ",
|
|
102
|
+
source: "shared-module-data",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
schemaCode: "SQLQUERYRESULT",
|
|
106
|
+
schemaName: "SqlQueryResult.fbs",
|
|
107
|
+
fileIdentifier: "SQLR",
|
|
108
|
+
source: "shared-module-data",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
schemaCode: "PROTECTEDCATALOGENTRY",
|
|
112
|
+
schemaName: "ProtectedCatalogEntry.fbs",
|
|
113
|
+
fileIdentifier: "PRTC",
|
|
114
|
+
source: "shared-module-data",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
schemaCode: "PROXIMITYSELECTION",
|
|
118
|
+
schemaName: "ProximitySelection.fbs",
|
|
119
|
+
fileIdentifier: "PRXY",
|
|
120
|
+
source: "shared-module-data",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
schemaCode: "CIDREF",
|
|
124
|
+
schemaName: "CidRef.fbs",
|
|
125
|
+
fileIdentifier: "CIDR",
|
|
126
|
+
source: "shared-module-data",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
schemaCode: "UDPDATAGRAM",
|
|
130
|
+
schemaName: "UdpDatagram.fbs",
|
|
131
|
+
fileIdentifier: "UDPG",
|
|
132
|
+
source: "shared-module-runtime",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
schemaCode: "STATEREQUEST",
|
|
136
|
+
schemaName: "StateRequest.fbs",
|
|
137
|
+
fileIdentifier: "SREQ",
|
|
138
|
+
source: "shared-module-runtime",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
schemaCode: "GRAPHDEFINITION",
|
|
142
|
+
schemaName: "GraphDefinition.fbs",
|
|
143
|
+
fileIdentifier: "FGDF",
|
|
144
|
+
source: "orbpro-legacy",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
schemaCode: "WEIGHTEDEDGELIST",
|
|
148
|
+
schemaName: "WeightedEdgeList.fbs",
|
|
149
|
+
fileIdentifier: "FELT",
|
|
150
|
+
source: "orbpro-legacy",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
schemaCode: "CSRGRAPH",
|
|
154
|
+
schemaName: "CSRGraph.fbs",
|
|
155
|
+
fileIdentifier: "FCSR",
|
|
156
|
+
source: "orbpro-legacy",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
schemaCode: "SHORTESTPATHREQUEST",
|
|
160
|
+
schemaName: "ShortestPathRequest.fbs",
|
|
161
|
+
fileIdentifier: "FSPR",
|
|
162
|
+
source: "orbpro-legacy",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
schemaCode: "SHORTESTPATHRESULT",
|
|
166
|
+
schemaName: "ShortestPathResult.fbs",
|
|
167
|
+
fileIdentifier: "FSPS",
|
|
168
|
+
source: "orbpro-legacy",
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
schemaCode: "PATHREQUEST",
|
|
172
|
+
schemaName: "PathRequest.fbs",
|
|
173
|
+
fileIdentifier: "FPTR",
|
|
174
|
+
source: "orbpro-legacy",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
schemaCode: "PATHRESULT",
|
|
178
|
+
schemaName: "PathResult.fbs",
|
|
179
|
+
fileIdentifier: "FPTH",
|
|
180
|
+
source: "orbpro-legacy",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
schemaCode: "CATALOGQUERYREQUEST",
|
|
184
|
+
schemaName: "CatalogQueryRequest.fbs",
|
|
185
|
+
fileIdentifier: "CQRQ",
|
|
186
|
+
source: "orbpro-legacy",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
schemaCode: "CATALOGQUERYRESULT",
|
|
190
|
+
schemaName: "CatalogQueryResult.fbs",
|
|
191
|
+
fileIdentifier: "CQRS",
|
|
192
|
+
source: "orbpro-legacy",
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
|
|
196
|
+
export const sharedModuleCatalog = Object.freeze(sharedModuleCatalogEntries);
|