hd-wallet-wasm 2.0.20 → 2.0.26

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.
@@ -0,0 +1,567 @@
1
+ import * as flatbuffers from 'flatbuffers';
2
+
3
+ function normalizeString(value, fallback = null) {
4
+ if (value === null || value === undefined) {
5
+ return fallback;
6
+ }
7
+ const normalized = String(value).trim();
8
+ return normalized.length > 0 ? normalized : fallback;
9
+ }
10
+
11
+ function normalizeArray(value) {
12
+ return Array.isArray(value) ? value : [];
13
+ }
14
+
15
+ function normalizeBytes(value) {
16
+ if (value instanceof Uint8Array) {
17
+ return new Uint8Array(value);
18
+ }
19
+ if (ArrayBuffer.isView(value)) {
20
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
21
+ }
22
+ if (value instanceof ArrayBuffer) {
23
+ return new Uint8Array(value);
24
+ }
25
+ return new Uint8Array();
26
+ }
27
+
28
+ function sortObjectKeys(value) {
29
+ if (Array.isArray(value)) {
30
+ return value.map(sortObjectKeys);
31
+ }
32
+ if (value && typeof value === 'object' && !(value instanceof Uint8Array)) {
33
+ return Object.fromEntries(
34
+ Object.keys(value)
35
+ .sort()
36
+ .map((key) => [key, sortObjectKeys(value[key])])
37
+ );
38
+ }
39
+ return value;
40
+ }
41
+
42
+ function encodeProperties(value) {
43
+ const normalized =
44
+ value && typeof value === 'object' && !ArrayBuffer.isView(value)
45
+ ? sortObjectKeys(value)
46
+ : {};
47
+ return JSON.stringify(normalized);
48
+ }
49
+
50
+ function decodeProperties(value) {
51
+ if (!value) {
52
+ return {};
53
+ }
54
+ return JSON.parse(value);
55
+ }
56
+
57
+ function normalizeTypeRef(typeRef = {}) {
58
+ return {
59
+ schemaName: normalizeString(typeRef.schemaName ?? typeRef.schema_name, null),
60
+ fileIdentifier: normalizeString(
61
+ typeRef.fileIdentifier ?? typeRef.file_identifier,
62
+ null
63
+ ),
64
+ schemaHash: Array.from(
65
+ normalizeBytes(typeRef.schemaHash ?? typeRef.schema_hash)
66
+ ),
67
+ acceptsAnyFlatbuffer:
68
+ typeRef.acceptsAnyFlatbuffer ?? typeRef.accepts_any_flatbuffer ?? false,
69
+ };
70
+ }
71
+
72
+ function normalizeAcceptedTypeSet(typeSet = {}) {
73
+ return {
74
+ setId: normalizeString(typeSet.setId ?? typeSet.set_id, ''),
75
+ allowedTypes: normalizeArray(
76
+ typeSet.allowedTypes ?? typeSet.allowed_types
77
+ ).map(normalizeTypeRef),
78
+ description: normalizeString(typeSet.description, null),
79
+ };
80
+ }
81
+
82
+ function normalizePort(port = {}) {
83
+ return {
84
+ portId: normalizeString(port.portId ?? port.port_id, ''),
85
+ displayName: normalizeString(port.displayName ?? port.display_name, null),
86
+ acceptedTypeSets: normalizeArray(
87
+ port.acceptedTypeSets ?? port.accepted_type_sets
88
+ ).map(normalizeAcceptedTypeSet),
89
+ minStreams: Math.max(0, Number(port.minStreams ?? port.min_streams ?? 1)),
90
+ maxStreams: Math.max(0, Number(port.maxStreams ?? port.max_streams ?? 1)),
91
+ required: port.required !== false,
92
+ description: normalizeString(port.description, null),
93
+ };
94
+ }
95
+
96
+ function normalizeMethod(method = {}) {
97
+ return {
98
+ methodId: normalizeString(method.methodId ?? method.method_id, ''),
99
+ displayName: normalizeString(
100
+ method.displayName ?? method.display_name,
101
+ null
102
+ ),
103
+ inputPorts: normalizeArray(method.inputPorts ?? method.input_ports).map(
104
+ normalizePort
105
+ ),
106
+ outputPorts: normalizeArray(method.outputPorts ?? method.output_ports).map(
107
+ normalizePort
108
+ ),
109
+ maxBatch: Math.max(1, Number(method.maxBatch ?? method.max_batch ?? 1)),
110
+ drainPolicy:
111
+ normalizeString(method.drainPolicy ?? method.drain_policy, null) ??
112
+ 'drain-until-yield',
113
+ description: normalizeString(method.description, null),
114
+ };
115
+ }
116
+
117
+ function normalizeCapability(capability) {
118
+ if (typeof capability === 'string') {
119
+ return {
120
+ capabilityId: normalizeString(capability, ''),
121
+ required: true,
122
+ description: null,
123
+ };
124
+ }
125
+ return {
126
+ capabilityId: normalizeString(
127
+ capability?.capabilityId ?? capability?.capability_id,
128
+ ''
129
+ ),
130
+ required: capability?.required !== false,
131
+ description: normalizeString(capability?.description, null),
132
+ };
133
+ }
134
+
135
+ function normalizeExternalInterface(externalInterface = {}) {
136
+ return {
137
+ interfaceId: normalizeString(
138
+ externalInterface.interfaceId ?? externalInterface.interface_id,
139
+ ''
140
+ ),
141
+ kind: normalizeString(externalInterface.kind, null),
142
+ direction: normalizeString(externalInterface.direction, null),
143
+ capability: normalizeString(externalInterface.capability, null),
144
+ resource: normalizeString(externalInterface.resource, null),
145
+ protocolId: normalizeString(
146
+ externalInterface.protocolId ?? externalInterface.protocol_id,
147
+ null
148
+ ),
149
+ topic: normalizeString(externalInterface.topic, null),
150
+ path: normalizeString(externalInterface.path, null),
151
+ required: externalInterface.required !== false,
152
+ acceptedTypes: normalizeArray(
153
+ externalInterface.acceptedTypes ?? externalInterface.accepted_types
154
+ ).map(normalizeTypeRef),
155
+ description: normalizeString(externalInterface.description, null),
156
+ properties:
157
+ externalInterface.properties &&
158
+ typeof externalInterface.properties === 'object'
159
+ ? sortObjectKeys(externalInterface.properties)
160
+ : {},
161
+ };
162
+ }
163
+
164
+ function normalizeBuildArtifact(artifact = {}) {
165
+ return {
166
+ artifactId: normalizeString(artifact.artifactId ?? artifact.artifact_id, ''),
167
+ kind: normalizeString(artifact.kind, null),
168
+ path: normalizeString(artifact.path, ''),
169
+ target: normalizeString(artifact.target, null),
170
+ entrySymbol: normalizeString(
171
+ artifact.entrySymbol ?? artifact.entry_symbol,
172
+ null
173
+ ),
174
+ };
175
+ }
176
+
177
+ export function normalizeSdnPluginManifest(manifest = {}) {
178
+ return {
179
+ pluginId: normalizeString(manifest.pluginId ?? manifest.plugin_id, ''),
180
+ name: normalizeString(manifest.name, null),
181
+ version: normalizeString(manifest.version, null),
182
+ pluginFamily: normalizeString(
183
+ manifest.pluginFamily ?? manifest.plugin_family,
184
+ null
185
+ ),
186
+ description: normalizeString(manifest.description, null),
187
+ methods: normalizeArray(manifest.methods).map(normalizeMethod),
188
+ capabilities: normalizeArray(manifest.capabilities).map(normalizeCapability),
189
+ externalInterfaces: normalizeArray(
190
+ manifest.externalInterfaces ?? manifest.external_interfaces
191
+ ).map(normalizeExternalInterface),
192
+ schemasUsed: normalizeArray(
193
+ manifest.schemasUsed ?? manifest.schemas_used
194
+ ).map(normalizeTypeRef),
195
+ buildArtifacts: normalizeArray(
196
+ manifest.buildArtifacts ?? manifest.build_artifacts
197
+ ).map(normalizeBuildArtifact),
198
+ abiVersion: Math.max(1, Number(manifest.abiVersion ?? manifest.abi_version ?? 1)),
199
+ };
200
+ }
201
+
202
+ function createString(builder, value) {
203
+ return value ? builder.createString(value) : 0;
204
+ }
205
+
206
+ function createOffsetsVector(builder, offsets) {
207
+ builder.startVector(4, offsets.length, 4);
208
+ for (let index = offsets.length - 1; index >= 0; index -= 1) {
209
+ builder.addOffset(offsets[index]);
210
+ }
211
+ return builder.endVector();
212
+ }
213
+
214
+ function createTypeRef(builder, typeRef) {
215
+ const schemaNameOffset = createString(builder, typeRef.schemaName);
216
+ const fileIdentifierOffset = createString(builder, typeRef.fileIdentifier);
217
+ const schemaHashOffset =
218
+ typeRef.schemaHash.length > 0
219
+ ? builder.createByteVector(Uint8Array.from(typeRef.schemaHash))
220
+ : 0;
221
+
222
+ builder.startObject(4);
223
+ builder.addFieldOffset(0, schemaNameOffset, 0);
224
+ builder.addFieldOffset(1, fileIdentifierOffset, 0);
225
+ builder.addFieldOffset(2, schemaHashOffset, 0);
226
+ builder.addFieldInt8(3, typeRef.acceptsAnyFlatbuffer ? 1 : 0, 0);
227
+ return builder.endObject();
228
+ }
229
+
230
+ function createAcceptedTypeSet(builder, typeSet) {
231
+ const setIdOffset = createString(builder, typeSet.setId);
232
+ const allowedTypeOffsets = typeSet.allowedTypes.map((value) =>
233
+ createTypeRef(builder, value)
234
+ );
235
+ const allowedTypesOffset =
236
+ allowedTypeOffsets.length > 0
237
+ ? createOffsetsVector(builder, allowedTypeOffsets)
238
+ : 0;
239
+ const descriptionOffset = createString(builder, typeSet.description);
240
+
241
+ builder.startObject(3);
242
+ builder.addFieldOffset(0, setIdOffset, 0);
243
+ builder.addFieldOffset(1, allowedTypesOffset, 0);
244
+ builder.addFieldOffset(2, descriptionOffset, 0);
245
+ return builder.endObject();
246
+ }
247
+
248
+ function createPort(builder, port) {
249
+ const portIdOffset = createString(builder, port.portId);
250
+ const displayNameOffset = createString(builder, port.displayName);
251
+ const acceptedTypeSetOffsets = port.acceptedTypeSets.map((value) =>
252
+ createAcceptedTypeSet(builder, value)
253
+ );
254
+ const acceptedTypeSetsOffset =
255
+ acceptedTypeSetOffsets.length > 0
256
+ ? createOffsetsVector(builder, acceptedTypeSetOffsets)
257
+ : 0;
258
+ const descriptionOffset = createString(builder, port.description);
259
+
260
+ builder.startObject(7);
261
+ builder.addFieldOffset(0, portIdOffset, 0);
262
+ builder.addFieldOffset(1, displayNameOffset, 0);
263
+ builder.addFieldOffset(2, acceptedTypeSetsOffset, 0);
264
+ builder.addFieldInt16(3, port.minStreams, 1);
265
+ builder.addFieldInt16(4, port.maxStreams, 1);
266
+ builder.addFieldInt8(5, port.required ? 1 : 0, 1);
267
+ builder.addFieldOffset(6, descriptionOffset, 0);
268
+ return builder.endObject();
269
+ }
270
+
271
+ function createMethod(builder, method) {
272
+ const methodIdOffset = createString(builder, method.methodId);
273
+ const displayNameOffset = createString(builder, method.displayName);
274
+ const inputPortOffsets = method.inputPorts.map((value) =>
275
+ createPort(builder, value)
276
+ );
277
+ const inputPortsOffset =
278
+ inputPortOffsets.length > 0 ? createOffsetsVector(builder, inputPortOffsets) : 0;
279
+ const outputPortOffsets = method.outputPorts.map((value) =>
280
+ createPort(builder, value)
281
+ );
282
+ const outputPortsOffset =
283
+ outputPortOffsets.length > 0
284
+ ? createOffsetsVector(builder, outputPortOffsets)
285
+ : 0;
286
+ const drainPolicyOffset = createString(builder, method.drainPolicy);
287
+ const descriptionOffset = createString(builder, method.description);
288
+
289
+ builder.startObject(7);
290
+ builder.addFieldOffset(0, methodIdOffset, 0);
291
+ builder.addFieldOffset(1, displayNameOffset, 0);
292
+ builder.addFieldOffset(2, inputPortsOffset, 0);
293
+ builder.addFieldOffset(3, outputPortsOffset, 0);
294
+ builder.addFieldInt32(4, method.maxBatch, 1);
295
+ builder.addFieldOffset(5, drainPolicyOffset, 0);
296
+ builder.addFieldOffset(6, descriptionOffset, 0);
297
+ return builder.endObject();
298
+ }
299
+
300
+ function createCapability(builder, capability) {
301
+ const capabilityIdOffset = createString(builder, capability.capabilityId);
302
+ const descriptionOffset = createString(builder, capability.description);
303
+
304
+ builder.startObject(3);
305
+ builder.addFieldOffset(0, capabilityIdOffset, 0);
306
+ builder.addFieldInt8(1, capability.required ? 1 : 0, 1);
307
+ builder.addFieldOffset(2, descriptionOffset, 0);
308
+ return builder.endObject();
309
+ }
310
+
311
+ function createExternalInterface(builder, externalInterface) {
312
+ const interfaceIdOffset = createString(builder, externalInterface.interfaceId);
313
+ const kindOffset = createString(builder, externalInterface.kind);
314
+ const directionOffset = createString(builder, externalInterface.direction);
315
+ const capabilityOffset = createString(builder, externalInterface.capability);
316
+ const resourceOffset = createString(builder, externalInterface.resource);
317
+ const protocolIdOffset = createString(builder, externalInterface.protocolId);
318
+ const topicOffset = createString(builder, externalInterface.topic);
319
+ const pathOffset = createString(builder, externalInterface.path);
320
+ const acceptedTypeOffsets = externalInterface.acceptedTypes.map((value) =>
321
+ createTypeRef(builder, value)
322
+ );
323
+ const acceptedTypesOffset =
324
+ acceptedTypeOffsets.length > 0
325
+ ? createOffsetsVector(builder, acceptedTypeOffsets)
326
+ : 0;
327
+ const descriptionOffset = createString(builder, externalInterface.description);
328
+ const propertiesOffset = createString(
329
+ builder,
330
+ encodeProperties(externalInterface.properties)
331
+ );
332
+
333
+ builder.startObject(12);
334
+ builder.addFieldOffset(0, interfaceIdOffset, 0);
335
+ builder.addFieldOffset(1, kindOffset, 0);
336
+ builder.addFieldOffset(2, directionOffset, 0);
337
+ builder.addFieldOffset(3, capabilityOffset, 0);
338
+ builder.addFieldOffset(4, resourceOffset, 0);
339
+ builder.addFieldOffset(5, protocolIdOffset, 0);
340
+ builder.addFieldOffset(6, topicOffset, 0);
341
+ builder.addFieldOffset(7, pathOffset, 0);
342
+ builder.addFieldInt8(8, externalInterface.required ? 1 : 0, 1);
343
+ builder.addFieldOffset(9, acceptedTypesOffset, 0);
344
+ builder.addFieldOffset(10, descriptionOffset, 0);
345
+ builder.addFieldOffset(11, propertiesOffset, 0);
346
+ return builder.endObject();
347
+ }
348
+
349
+ function createBuildArtifact(builder, artifact) {
350
+ const artifactIdOffset = createString(builder, artifact.artifactId);
351
+ const kindOffset = createString(builder, artifact.kind);
352
+ const pathOffset = createString(builder, artifact.path);
353
+ const targetOffset = createString(builder, artifact.target);
354
+ const entrySymbolOffset = createString(builder, artifact.entrySymbol);
355
+
356
+ builder.startObject(5);
357
+ builder.addFieldOffset(0, artifactIdOffset, 0);
358
+ builder.addFieldOffset(1, kindOffset, 0);
359
+ builder.addFieldOffset(2, pathOffset, 0);
360
+ builder.addFieldOffset(3, targetOffset, 0);
361
+ builder.addFieldOffset(4, entrySymbolOffset, 0);
362
+ return builder.endObject();
363
+ }
364
+
365
+ export function encodeSdnPluginManifest(manifest) {
366
+ const normalized = normalizeSdnPluginManifest(manifest);
367
+ const builder = new flatbuffers.Builder(2048);
368
+
369
+ const pluginIdOffset = createString(builder, normalized.pluginId);
370
+ const nameOffset = createString(builder, normalized.name);
371
+ const versionOffset = createString(builder, normalized.version);
372
+ const pluginFamilyOffset = createString(builder, normalized.pluginFamily);
373
+ const descriptionOffset = createString(builder, normalized.description);
374
+ const methodOffsets = normalized.methods.map((value) => createMethod(builder, value));
375
+ const methodsOffset =
376
+ methodOffsets.length > 0 ? createOffsetsVector(builder, methodOffsets) : 0;
377
+ const capabilityOffsets = normalized.capabilities.map((value) =>
378
+ createCapability(builder, value)
379
+ );
380
+ const capabilitiesOffset =
381
+ capabilityOffsets.length > 0
382
+ ? createOffsetsVector(builder, capabilityOffsets)
383
+ : 0;
384
+ const externalInterfaceOffsets = normalized.externalInterfaces.map((value) =>
385
+ createExternalInterface(builder, value)
386
+ );
387
+ const externalInterfacesOffset =
388
+ externalInterfaceOffsets.length > 0
389
+ ? createOffsetsVector(builder, externalInterfaceOffsets)
390
+ : 0;
391
+ const schemaOffsets = normalized.schemasUsed.map((value) =>
392
+ createTypeRef(builder, value)
393
+ );
394
+ const schemasUsedOffset =
395
+ schemaOffsets.length > 0 ? createOffsetsVector(builder, schemaOffsets) : 0;
396
+ const artifactOffsets = normalized.buildArtifacts.map((value) =>
397
+ createBuildArtifact(builder, value)
398
+ );
399
+ const buildArtifactsOffset =
400
+ artifactOffsets.length > 0
401
+ ? createOffsetsVector(builder, artifactOffsets)
402
+ : 0;
403
+
404
+ builder.startObject(11);
405
+ builder.addFieldOffset(0, pluginIdOffset, 0);
406
+ builder.addFieldOffset(1, nameOffset, 0);
407
+ builder.addFieldOffset(2, versionOffset, 0);
408
+ builder.addFieldOffset(3, pluginFamilyOffset, 0);
409
+ builder.addFieldOffset(4, descriptionOffset, 0);
410
+ builder.addFieldOffset(5, methodsOffset, 0);
411
+ builder.addFieldOffset(6, capabilitiesOffset, 0);
412
+ builder.addFieldOffset(7, externalInterfacesOffset, 0);
413
+ builder.addFieldOffset(8, schemasUsedOffset, 0);
414
+ builder.addFieldOffset(9, buildArtifactsOffset, 0);
415
+ builder.addFieldInt32(10, normalized.abiVersion, 1);
416
+ const root = builder.endObject();
417
+ builder.requiredField(root, 4);
418
+ builder.finish(root, 'PMAN');
419
+ return builder.asUint8Array();
420
+ }
421
+
422
+ function toByteBuffer(data) {
423
+ if (data instanceof flatbuffers.ByteBuffer) {
424
+ return data;
425
+ }
426
+ const bytes = normalizeBytes(data);
427
+ if (bytes.length === 0) {
428
+ throw new TypeError(
429
+ 'Expected ByteBuffer, Uint8Array, ArrayBufferView, or ArrayBuffer.'
430
+ );
431
+ }
432
+ return new flatbuffers.ByteBuffer(bytes);
433
+ }
434
+
435
+ function fieldOffset(fieldIndex) {
436
+ return 4 + fieldIndex * 2;
437
+ }
438
+
439
+ function readStringField(bb, tablePosition, fieldIndex) {
440
+ const offset = bb.__offset(tablePosition, fieldOffset(fieldIndex));
441
+ return offset ? bb.__string(tablePosition + offset) : null;
442
+ }
443
+
444
+ function readBoolField(bb, tablePosition, fieldIndex, fallback) {
445
+ const offset = bb.__offset(tablePosition, fieldOffset(fieldIndex));
446
+ return offset ? bb.readInt8(tablePosition + offset) !== 0 : fallback;
447
+ }
448
+
449
+ function readUint16Field(bb, tablePosition, fieldIndex, fallback) {
450
+ const offset = bb.__offset(tablePosition, fieldOffset(fieldIndex));
451
+ return offset ? bb.readUint16(tablePosition + offset) : fallback;
452
+ }
453
+
454
+ function readUint32Field(bb, tablePosition, fieldIndex, fallback) {
455
+ const offset = bb.__offset(tablePosition, fieldOffset(fieldIndex));
456
+ return offset ? bb.readUint32(tablePosition + offset) : fallback;
457
+ }
458
+
459
+ function readByteVectorField(bb, tablePosition, fieldIndex) {
460
+ const offset = bb.__offset(tablePosition, fieldOffset(fieldIndex));
461
+ if (!offset) {
462
+ return [];
463
+ }
464
+ const start = bb.__vector(tablePosition + offset);
465
+ const length = bb.__vector_len(tablePosition + offset);
466
+ return Array.from(bb.bytes().slice(start, start + length));
467
+ }
468
+
469
+ function readTableVector(bb, tablePosition, fieldIndex, readItem) {
470
+ const offset = bb.__offset(tablePosition, fieldOffset(fieldIndex));
471
+ if (!offset) {
472
+ return [];
473
+ }
474
+ const start = bb.__vector(tablePosition + offset);
475
+ const length = bb.__vector_len(tablePosition + offset);
476
+ const values = [];
477
+ for (let index = 0; index < length; index += 1) {
478
+ values.push(readItem(bb.__indirect(start + index * 4)));
479
+ }
480
+ return values;
481
+ }
482
+
483
+ export function decodeSdnPluginManifest(data) {
484
+ const bb = toByteBuffer(data);
485
+ if (!bb.__has_identifier('PMAN')) {
486
+ throw new Error('SDN plugin manifest buffer identifier mismatch.');
487
+ }
488
+
489
+ const root = bb.readInt32(bb.position()) + bb.position();
490
+
491
+ const readTypeRef = (tablePosition) => ({
492
+ schemaName: readStringField(bb, tablePosition, 0),
493
+ fileIdentifier: readStringField(bb, tablePosition, 1),
494
+ schemaHash: readByteVectorField(bb, tablePosition, 2),
495
+ acceptsAnyFlatbuffer: readBoolField(bb, tablePosition, 3, false),
496
+ });
497
+
498
+ const readAcceptedTypeSet = (tablePosition) => ({
499
+ setId: readStringField(bb, tablePosition, 0) ?? '',
500
+ allowedTypes: readTableVector(bb, tablePosition, 1, readTypeRef),
501
+ description: readStringField(bb, tablePosition, 2),
502
+ });
503
+
504
+ const readPort = (tablePosition) => ({
505
+ portId: readStringField(bb, tablePosition, 0) ?? '',
506
+ displayName: readStringField(bb, tablePosition, 1),
507
+ acceptedTypeSets: readTableVector(bb, tablePosition, 2, readAcceptedTypeSet),
508
+ minStreams: readUint16Field(bb, tablePosition, 3, 1),
509
+ maxStreams: readUint16Field(bb, tablePosition, 4, 1),
510
+ required: readBoolField(bb, tablePosition, 5, true),
511
+ description: readStringField(bb, tablePosition, 6),
512
+ });
513
+
514
+ const readMethod = (tablePosition) => ({
515
+ methodId: readStringField(bb, tablePosition, 0) ?? '',
516
+ displayName: readStringField(bb, tablePosition, 1),
517
+ inputPorts: readTableVector(bb, tablePosition, 2, readPort),
518
+ outputPorts: readTableVector(bb, tablePosition, 3, readPort),
519
+ maxBatch: readUint32Field(bb, tablePosition, 4, 1),
520
+ drainPolicy:
521
+ readStringField(bb, tablePosition, 5) ?? 'drain-until-yield',
522
+ description: readStringField(bb, tablePosition, 6),
523
+ });
524
+
525
+ const readCapability = (tablePosition) => ({
526
+ capabilityId: readStringField(bb, tablePosition, 0) ?? '',
527
+ required: readBoolField(bb, tablePosition, 1, true),
528
+ description: readStringField(bb, tablePosition, 2),
529
+ });
530
+
531
+ const readExternalInterface = (tablePosition) => ({
532
+ interfaceId: readStringField(bb, tablePosition, 0) ?? '',
533
+ kind: readStringField(bb, tablePosition, 1),
534
+ direction: readStringField(bb, tablePosition, 2),
535
+ capability: readStringField(bb, tablePosition, 3),
536
+ resource: readStringField(bb, tablePosition, 4),
537
+ protocolId: readStringField(bb, tablePosition, 5),
538
+ topic: readStringField(bb, tablePosition, 6),
539
+ path: readStringField(bb, tablePosition, 7),
540
+ required: readBoolField(bb, tablePosition, 8, true),
541
+ acceptedTypes: readTableVector(bb, tablePosition, 9, readTypeRef),
542
+ description: readStringField(bb, tablePosition, 10),
543
+ properties: decodeProperties(readStringField(bb, tablePosition, 11)),
544
+ });
545
+
546
+ const readBuildArtifact = (tablePosition) => ({
547
+ artifactId: readStringField(bb, tablePosition, 0) ?? '',
548
+ kind: readStringField(bb, tablePosition, 1),
549
+ path: readStringField(bb, tablePosition, 2) ?? '',
550
+ target: readStringField(bb, tablePosition, 3),
551
+ entrySymbol: readStringField(bb, tablePosition, 4),
552
+ });
553
+
554
+ return {
555
+ pluginId: readStringField(bb, root, 0) ?? '',
556
+ name: readStringField(bb, root, 1),
557
+ version: readStringField(bb, root, 2),
558
+ pluginFamily: readStringField(bb, root, 3),
559
+ description: readStringField(bb, root, 4),
560
+ methods: readTableVector(bb, root, 5, readMethod),
561
+ capabilities: readTableVector(bb, root, 6, readCapability),
562
+ externalInterfaces: readTableVector(bb, root, 7, readExternalInterface),
563
+ schemasUsed: readTableVector(bb, root, 8, readTypeRef),
564
+ buildArtifacts: readTableVector(bb, root, 9, readBuildArtifact),
565
+ abiVersion: readUint32Field(bb, root, 10, 1),
566
+ };
567
+ }