@ignex/nova 0.1.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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +313 -0
  3. package/docs/architecture.md +146 -0
  4. package/docs/publishing.md +119 -0
  5. package/docs/wire-format.md +170 -0
  6. package/index.ts +61 -0
  7. package/package.json +89 -0
  8. package/prebuilds/linux-x64/libignex_ffi.so +0 -0
  9. package/public/client.ts +23 -0
  10. package/public/nats.ts +19 -0
  11. package/public/server.ts +35 -0
  12. package/rust/Cargo.toml +19 -0
  13. package/rust/src/ffi.rs +135 -0
  14. package/rust/src/generated/backend.rs +2817 -0
  15. package/rust/src/generated/mod.rs +2 -0
  16. package/rust/src/lib.rs +9 -0
  17. package/rust/src/transcode/generated.rs +1352 -0
  18. package/rust/src/transcode/mod.rs +2 -0
  19. package/src/bridge/nats.ts +269 -0
  20. package/src/bridge/subjects.ts +30 -0
  21. package/src/core/auth.ts +56 -0
  22. package/src/core/backpressure.ts +39 -0
  23. package/src/core/client-heartbeat.ts +27 -0
  24. package/src/core/client-reconnect.ts +35 -0
  25. package/src/core/client-state.ts +76 -0
  26. package/src/core/client-wire.ts +72 -0
  27. package/src/core/client.ts +176 -0
  28. package/src/core/groups.ts +52 -0
  29. package/src/core/int64-guard.ts +44 -0
  30. package/src/core/metrics.ts +105 -0
  31. package/src/core/outbound.ts +76 -0
  32. package/src/core/replay.ts +31 -0
  33. package/src/core/ring.ts +85 -0
  34. package/src/core/rooms.ts +44 -0
  35. package/src/core/routing.ts +94 -0
  36. package/src/core/server.ts +294 -0
  37. package/src/core/state.ts +179 -0
  38. package/src/generated/direct-ser.ts +495 -0
  39. package/src/generated/fbs/backend.fbs +139 -0
  40. package/src/generated/registry.ts +341 -0
  41. package/src/generated/rust/backend_generated.rs +2817 -0
  42. package/src/generated/ts/backend.ts +25 -0
  43. package/src/generated/ts/big-val.ts +106 -0
  44. package/src/generated/ts/complex.ts +303 -0
  45. package/src/generated/ts/customer.ts +137 -0
  46. package/src/generated/ts/hello.ts +123 -0
  47. package/src/generated/ts/join-group.ts +78 -0
  48. package/src/generated/ts/leave-group.ts +78 -0
  49. package/src/generated/ts/order-billing.ts +137 -0
  50. package/src/generated/ts/order-line.ts +144 -0
  51. package/src/generated/ts/order.ts +236 -0
  52. package/src/generated/ts/ping.ts +74 -0
  53. package/src/generated/ts/pong.ts +74 -0
  54. package/src/generated/ts/portfolio-position.ts +120 -0
  55. package/src/generated/ts/portfolio-snapshot.ts +170 -0
  56. package/src/generated/ts/quote.ts +148 -0
  57. package/src/generated/ts/side.ts +8 -0
  58. package/src/generated/ts/snapshot-request.ts +78 -0
  59. package/src/generated/ts/subscribe.ts +78 -0
  60. package/src/generated/ts/tags.ts +9 -0
  61. package/src/generated/ts/trade.ts +135 -0
  62. package/src/generated/ts/unsubscribe.ts +78 -0
  63. package/src/generated/ts/welcome.ts +112 -0
  64. package/src/generated/ts-ser.ts +465 -0
  65. package/src/generated/wire-registry.json +20 -0
  66. package/src/native/codec.ts +35 -0
  67. package/src/native/ffi.ts +214 -0
  68. package/src/native/loader.ts +55 -0
  69. package/src/schema/index.ts +217 -0
  70. package/src/server.ts +87 -0
  71. package/src/transport/byte-buffer-pool.ts +63 -0
  72. package/src/transport/scratch.ts +48 -0
  73. package/src/transport/stats.ts +44 -0
  74. package/src/transport/transport.ts +106 -0
@@ -0,0 +1,78 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4
+
5
+ import * as flatbuffers from 'flatbuffers';
6
+
7
+
8
+
9
+ export class JoinGroup implements flatbuffers.IUnpackableObject<JoinGroupT> {
10
+ bb: flatbuffers.ByteBuffer|null = null;
11
+ bb_pos = 0;
12
+ __init(i:number, bb:flatbuffers.ByteBuffer):JoinGroup {
13
+ this.bb_pos = i;
14
+ this.bb = bb;
15
+ return this;
16
+ }
17
+
18
+ static getRootAsJoinGroup(bb:flatbuffers.ByteBuffer, obj?:JoinGroup):JoinGroup {
19
+ return (obj || new JoinGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
20
+ }
21
+
22
+ static getSizePrefixedRootAsJoinGroup(bb:flatbuffers.ByteBuffer, obj?:JoinGroup):JoinGroup {
23
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
24
+ return (obj || new JoinGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
25
+ }
26
+
27
+ group():string|null
28
+ group(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
29
+ group(optionalEncoding?:any):string|Uint8Array|null {
30
+ const offset = this.bb!.__offset(this.bb_pos, 4);
31
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
32
+ }
33
+
34
+ static startJoinGroup(builder:flatbuffers.Builder) {
35
+ builder.startObject(1);
36
+ }
37
+
38
+ static addGroup(builder:flatbuffers.Builder, groupOffset:flatbuffers.Offset) {
39
+ builder.addFieldOffset(0, groupOffset, 0);
40
+ }
41
+
42
+ static endJoinGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
43
+ const offset = builder.endObject();
44
+ return offset;
45
+ }
46
+
47
+ static createJoinGroup(builder:flatbuffers.Builder, groupOffset:flatbuffers.Offset):flatbuffers.Offset {
48
+ JoinGroup.startJoinGroup(builder);
49
+ JoinGroup.addGroup(builder, groupOffset);
50
+ return JoinGroup.endJoinGroup(builder);
51
+ }
52
+
53
+ unpack(): JoinGroupT {
54
+ return new JoinGroupT(
55
+ this.group()
56
+ );
57
+ }
58
+
59
+
60
+ unpackTo(_o: JoinGroupT): void {
61
+ _o.group = this.group();
62
+ }
63
+ }
64
+
65
+ export class JoinGroupT implements flatbuffers.IGeneratedObject {
66
+ constructor(
67
+ public group: string|Uint8Array|null = null
68
+ ){}
69
+
70
+
71
+ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
72
+ const group = (this.group !== null ? builder.createString(this.group!) : 0);
73
+
74
+ return JoinGroup.createJoinGroup(builder,
75
+ group
76
+ );
77
+ }
78
+ }
@@ -0,0 +1,78 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4
+
5
+ import * as flatbuffers from 'flatbuffers';
6
+
7
+
8
+
9
+ export class LeaveGroup implements flatbuffers.IUnpackableObject<LeaveGroupT> {
10
+ bb: flatbuffers.ByteBuffer|null = null;
11
+ bb_pos = 0;
12
+ __init(i:number, bb:flatbuffers.ByteBuffer):LeaveGroup {
13
+ this.bb_pos = i;
14
+ this.bb = bb;
15
+ return this;
16
+ }
17
+
18
+ static getRootAsLeaveGroup(bb:flatbuffers.ByteBuffer, obj?:LeaveGroup):LeaveGroup {
19
+ return (obj || new LeaveGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
20
+ }
21
+
22
+ static getSizePrefixedRootAsLeaveGroup(bb:flatbuffers.ByteBuffer, obj?:LeaveGroup):LeaveGroup {
23
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
24
+ return (obj || new LeaveGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
25
+ }
26
+
27
+ group():string|null
28
+ group(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
29
+ group(optionalEncoding?:any):string|Uint8Array|null {
30
+ const offset = this.bb!.__offset(this.bb_pos, 4);
31
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
32
+ }
33
+
34
+ static startLeaveGroup(builder:flatbuffers.Builder) {
35
+ builder.startObject(1);
36
+ }
37
+
38
+ static addGroup(builder:flatbuffers.Builder, groupOffset:flatbuffers.Offset) {
39
+ builder.addFieldOffset(0, groupOffset, 0);
40
+ }
41
+
42
+ static endLeaveGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
43
+ const offset = builder.endObject();
44
+ return offset;
45
+ }
46
+
47
+ static createLeaveGroup(builder:flatbuffers.Builder, groupOffset:flatbuffers.Offset):flatbuffers.Offset {
48
+ LeaveGroup.startLeaveGroup(builder);
49
+ LeaveGroup.addGroup(builder, groupOffset);
50
+ return LeaveGroup.endLeaveGroup(builder);
51
+ }
52
+
53
+ unpack(): LeaveGroupT {
54
+ return new LeaveGroupT(
55
+ this.group()
56
+ );
57
+ }
58
+
59
+
60
+ unpackTo(_o: LeaveGroupT): void {
61
+ _o.group = this.group();
62
+ }
63
+ }
64
+
65
+ export class LeaveGroupT implements flatbuffers.IGeneratedObject {
66
+ constructor(
67
+ public group: string|Uint8Array|null = null
68
+ ){}
69
+
70
+
71
+ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
72
+ const group = (this.group !== null ? builder.createString(this.group!) : 0);
73
+
74
+ return LeaveGroup.createLeaveGroup(builder,
75
+ group
76
+ );
77
+ }
78
+ }
@@ -0,0 +1,137 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4
+
5
+ import * as flatbuffers from 'flatbuffers';
6
+
7
+
8
+
9
+ export class OrderBilling implements flatbuffers.IUnpackableObject<OrderBillingT> {
10
+ bb: flatbuffers.ByteBuffer|null = null;
11
+ bb_pos = 0;
12
+ __init(i:number, bb:flatbuffers.ByteBuffer):OrderBilling {
13
+ this.bb_pos = i;
14
+ this.bb = bb;
15
+ return this;
16
+ }
17
+
18
+ static getRootAsOrderBilling(bb:flatbuffers.ByteBuffer, obj?:OrderBilling):OrderBilling {
19
+ return (obj || new OrderBilling()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
20
+ }
21
+
22
+ static getSizePrefixedRootAsOrderBilling(bb:flatbuffers.ByteBuffer, obj?:OrderBilling):OrderBilling {
23
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
24
+ return (obj || new OrderBilling()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
25
+ }
26
+
27
+ id():string|null
28
+ id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
29
+ id(optionalEncoding?:any):string|Uint8Array|null {
30
+ const offset = this.bb!.__offset(this.bb_pos, 4);
31
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
32
+ }
33
+
34
+ name():string|null
35
+ name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
36
+ name(optionalEncoding?:any):string|Uint8Array|null {
37
+ const offset = this.bb!.__offset(this.bb_pos, 6);
38
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
39
+ }
40
+
41
+ vip():boolean {
42
+ const offset = this.bb!.__offset(this.bb_pos, 8);
43
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
44
+ }
45
+
46
+ loyaltyPoints():bigint {
47
+ const offset = this.bb!.__offset(this.bb_pos, 10);
48
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
49
+ }
50
+
51
+ rating():number {
52
+ const offset = this.bb!.__offset(this.bb_pos, 12);
53
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
54
+ }
55
+
56
+ static startOrderBilling(builder:flatbuffers.Builder) {
57
+ builder.startObject(5);
58
+ }
59
+
60
+ static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
61
+ builder.addFieldOffset(0, idOffset, 0);
62
+ }
63
+
64
+ static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
65
+ builder.addFieldOffset(1, nameOffset, 0);
66
+ }
67
+
68
+ static addVip(builder:flatbuffers.Builder, vip:boolean) {
69
+ builder.addFieldInt8(2, +vip, +false);
70
+ }
71
+
72
+ static addLoyaltyPoints(builder:flatbuffers.Builder, loyaltyPoints:bigint) {
73
+ builder.addFieldInt64(3, loyaltyPoints, BigInt('0'));
74
+ }
75
+
76
+ static addRating(builder:flatbuffers.Builder, rating:number) {
77
+ builder.addFieldFloat64(4, rating, 0.0);
78
+ }
79
+
80
+ static endOrderBilling(builder:flatbuffers.Builder):flatbuffers.Offset {
81
+ const offset = builder.endObject();
82
+ return offset;
83
+ }
84
+
85
+ static createOrderBilling(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, nameOffset:flatbuffers.Offset, vip:boolean, loyaltyPoints:bigint, rating:number):flatbuffers.Offset {
86
+ OrderBilling.startOrderBilling(builder);
87
+ OrderBilling.addId(builder, idOffset);
88
+ OrderBilling.addName(builder, nameOffset);
89
+ OrderBilling.addVip(builder, vip);
90
+ OrderBilling.addLoyaltyPoints(builder, loyaltyPoints);
91
+ OrderBilling.addRating(builder, rating);
92
+ return OrderBilling.endOrderBilling(builder);
93
+ }
94
+
95
+ unpack(): OrderBillingT {
96
+ return new OrderBillingT(
97
+ this.id(),
98
+ this.name(),
99
+ this.vip(),
100
+ this.loyaltyPoints(),
101
+ this.rating()
102
+ );
103
+ }
104
+
105
+
106
+ unpackTo(_o: OrderBillingT): void {
107
+ _o.id = this.id();
108
+ _o.name = this.name();
109
+ _o.vip = this.vip();
110
+ _o.loyaltyPoints = this.loyaltyPoints();
111
+ _o.rating = this.rating();
112
+ }
113
+ }
114
+
115
+ export class OrderBillingT implements flatbuffers.IGeneratedObject {
116
+ constructor(
117
+ public id: string|Uint8Array|null = null,
118
+ public name: string|Uint8Array|null = null,
119
+ public vip: boolean = false,
120
+ public loyaltyPoints: bigint = BigInt('0'),
121
+ public rating: number = 0.0
122
+ ){}
123
+
124
+
125
+ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
126
+ const id = (this.id !== null ? builder.createString(this.id!) : 0);
127
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
128
+
129
+ return OrderBilling.createOrderBilling(builder,
130
+ id,
131
+ name,
132
+ this.vip,
133
+ this.loyaltyPoints,
134
+ this.rating
135
+ );
136
+ }
137
+ }
@@ -0,0 +1,144 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4
+
5
+ import * as flatbuffers from 'flatbuffers';
6
+
7
+ import { Tags } from './tags.js';
8
+
9
+
10
+ export class OrderLine implements flatbuffers.IUnpackableObject<OrderLineT> {
11
+ bb: flatbuffers.ByteBuffer|null = null;
12
+ bb_pos = 0;
13
+ __init(i:number, bb:flatbuffers.ByteBuffer):OrderLine {
14
+ this.bb_pos = i;
15
+ this.bb = bb;
16
+ return this;
17
+ }
18
+
19
+ static getRootAsOrderLine(bb:flatbuffers.ByteBuffer, obj?:OrderLine):OrderLine {
20
+ return (obj || new OrderLine()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21
+ }
22
+
23
+ static getSizePrefixedRootAsOrderLine(bb:flatbuffers.ByteBuffer, obj?:OrderLine):OrderLine {
24
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25
+ return (obj || new OrderLine()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26
+ }
27
+
28
+ sku():string|null
29
+ sku(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30
+ sku(optionalEncoding?:any):string|Uint8Array|null {
31
+ const offset = this.bb!.__offset(this.bb_pos, 4);
32
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33
+ }
34
+
35
+ qty():bigint {
36
+ const offset = this.bb!.__offset(this.bb_pos, 6);
37
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
38
+ }
39
+
40
+ unitPrice():number {
41
+ const offset = this.bb!.__offset(this.bb_pos, 8);
42
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
43
+ }
44
+
45
+ tags(index: number):Tags|null {
46
+ const offset = this.bb!.__offset(this.bb_pos, 10);
47
+ return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
48
+ }
49
+
50
+ tagsLength():number {
51
+ const offset = this.bb!.__offset(this.bb_pos, 10);
52
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
53
+ }
54
+
55
+ tagsArray():Int32Array|null {
56
+ const offset = this.bb!.__offset(this.bb_pos, 10);
57
+ return offset ? new Int32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
58
+ }
59
+
60
+ static startOrderLine(builder:flatbuffers.Builder) {
61
+ builder.startObject(4);
62
+ }
63
+
64
+ static addSku(builder:flatbuffers.Builder, skuOffset:flatbuffers.Offset) {
65
+ builder.addFieldOffset(0, skuOffset, 0);
66
+ }
67
+
68
+ static addQty(builder:flatbuffers.Builder, qty:bigint) {
69
+ builder.addFieldInt64(1, qty, BigInt('0'));
70
+ }
71
+
72
+ static addUnitPrice(builder:flatbuffers.Builder, unitPrice:number) {
73
+ builder.addFieldFloat64(2, unitPrice, 0.0);
74
+ }
75
+
76
+ static addTags(builder:flatbuffers.Builder, tagsOffset:flatbuffers.Offset) {
77
+ builder.addFieldOffset(3, tagsOffset, 0);
78
+ }
79
+
80
+ static createTagsVector(builder:flatbuffers.Builder, data:Tags[]):flatbuffers.Offset {
81
+ builder.startVector(4, data.length, 4);
82
+ for (let i = data.length - 1; i >= 0; i--) {
83
+ builder.addInt32(data[i]!);
84
+ }
85
+ return builder.endVector();
86
+ }
87
+
88
+ static startTagsVector(builder:flatbuffers.Builder, numElems:number) {
89
+ builder.startVector(4, numElems, 4);
90
+ }
91
+
92
+ static endOrderLine(builder:flatbuffers.Builder):flatbuffers.Offset {
93
+ const offset = builder.endObject();
94
+ return offset;
95
+ }
96
+
97
+ static createOrderLine(builder:flatbuffers.Builder, skuOffset:flatbuffers.Offset, qty:bigint, unitPrice:number, tagsOffset:flatbuffers.Offset):flatbuffers.Offset {
98
+ OrderLine.startOrderLine(builder);
99
+ OrderLine.addSku(builder, skuOffset);
100
+ OrderLine.addQty(builder, qty);
101
+ OrderLine.addUnitPrice(builder, unitPrice);
102
+ OrderLine.addTags(builder, tagsOffset);
103
+ return OrderLine.endOrderLine(builder);
104
+ }
105
+
106
+ unpack(): OrderLineT {
107
+ return new OrderLineT(
108
+ this.sku(),
109
+ this.qty(),
110
+ this.unitPrice(),
111
+ this.bb!.createScalarList<Tags>(this.tags.bind(this), this.tagsLength())
112
+ );
113
+ }
114
+
115
+
116
+ unpackTo(_o: OrderLineT): void {
117
+ _o.sku = this.sku();
118
+ _o.qty = this.qty();
119
+ _o.unitPrice = this.unitPrice();
120
+ _o.tags = this.bb!.createScalarList<Tags>(this.tags.bind(this), this.tagsLength());
121
+ }
122
+ }
123
+
124
+ export class OrderLineT implements flatbuffers.IGeneratedObject {
125
+ constructor(
126
+ public sku: string|Uint8Array|null = null,
127
+ public qty: bigint = BigInt('0'),
128
+ public unitPrice: number = 0.0,
129
+ public tags: (Tags)[] = []
130
+ ){}
131
+
132
+
133
+ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
134
+ const sku = (this.sku !== null ? builder.createString(this.sku!) : 0);
135
+ const tags = OrderLine.createTagsVector(builder, this.tags);
136
+
137
+ return OrderLine.createOrderLine(builder,
138
+ sku,
139
+ this.qty,
140
+ this.unitPrice,
141
+ tags
142
+ );
143
+ }
144
+ }
@@ -0,0 +1,236 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4
+
5
+ import * as flatbuffers from 'flatbuffers';
6
+
7
+ import { Customer, CustomerT } from './customer.js';
8
+ import { OrderBilling, OrderBillingT } from './order-billing.js';
9
+ import { OrderLine, OrderLineT } from './order-line.js';
10
+
11
+
12
+ export class Order implements flatbuffers.IUnpackableObject<OrderT> {
13
+ bb: flatbuffers.ByteBuffer|null = null;
14
+ bb_pos = 0;
15
+ __init(i:number, bb:flatbuffers.ByteBuffer):Order {
16
+ this.bb_pos = i;
17
+ this.bb = bb;
18
+ return this;
19
+ }
20
+
21
+ static getRootAsOrder(bb:flatbuffers.ByteBuffer, obj?:Order):Order {
22
+ return (obj || new Order()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23
+ }
24
+
25
+ static getSizePrefixedRootAsOrder(bb:flatbuffers.ByteBuffer, obj?:Order):Order {
26
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
27
+ return (obj || new Order()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
28
+ }
29
+
30
+ orderId():string|null
31
+ orderId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
32
+ orderId(optionalEncoding?:any):string|Uint8Array|null {
33
+ const offset = this.bb!.__offset(this.bb_pos, 4);
34
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
35
+ }
36
+
37
+ customer(obj?:Customer):Customer|null {
38
+ const offset = this.bb!.__offset(this.bb_pos, 6);
39
+ return offset ? (obj || new Customer()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
40
+ }
41
+
42
+ lines(index: number, obj?:OrderLine):OrderLine|null {
43
+ const offset = this.bb!.__offset(this.bb_pos, 8);
44
+ return offset ? (obj || new OrderLine()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
45
+ }
46
+
47
+ linesLength():number {
48
+ const offset = this.bb!.__offset(this.bb_pos, 8);
49
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
50
+ }
51
+
52
+ notes(index: number):string
53
+ notes(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
54
+ notes(index: number,optionalEncoding?:any):string|Uint8Array|null {
55
+ const offset = this.bb!.__offset(this.bb_pos, 10);
56
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
57
+ }
58
+
59
+ notesLength():number {
60
+ const offset = this.bb!.__offset(this.bb_pos, 10);
61
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
62
+ }
63
+
64
+ discounts(index: number):number|null {
65
+ const offset = this.bb!.__offset(this.bb_pos, 12);
66
+ return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
67
+ }
68
+
69
+ discountsLength():number {
70
+ const offset = this.bb!.__offset(this.bb_pos, 12);
71
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
72
+ }
73
+
74
+ discountsArray():Float64Array|null {
75
+ const offset = this.bb!.__offset(this.bb_pos, 12);
76
+ return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
77
+ }
78
+
79
+ active():boolean {
80
+ const offset = this.bb!.__offset(this.bb_pos, 14);
81
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
82
+ }
83
+
84
+ createdAt():bigint {
85
+ const offset = this.bb!.__offset(this.bb_pos, 16);
86
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
87
+ }
88
+
89
+ billing(obj?:OrderBilling):OrderBilling|null {
90
+ const offset = this.bb!.__offset(this.bb_pos, 18);
91
+ return offset ? (obj || new OrderBilling()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
92
+ }
93
+
94
+ static startOrder(builder:flatbuffers.Builder) {
95
+ builder.startObject(8);
96
+ }
97
+
98
+ static addOrderId(builder:flatbuffers.Builder, orderIdOffset:flatbuffers.Offset) {
99
+ builder.addFieldOffset(0, orderIdOffset, 0);
100
+ }
101
+
102
+ static addCustomer(builder:flatbuffers.Builder, customerOffset:flatbuffers.Offset) {
103
+ builder.addFieldOffset(1, customerOffset, 0);
104
+ }
105
+
106
+ static addLines(builder:flatbuffers.Builder, linesOffset:flatbuffers.Offset) {
107
+ builder.addFieldOffset(2, linesOffset, 0);
108
+ }
109
+
110
+ static createLinesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
111
+ builder.startVector(4, data.length, 4);
112
+ for (let i = data.length - 1; i >= 0; i--) {
113
+ builder.addOffset(data[i]!);
114
+ }
115
+ return builder.endVector();
116
+ }
117
+
118
+ static startLinesVector(builder:flatbuffers.Builder, numElems:number) {
119
+ builder.startVector(4, numElems, 4);
120
+ }
121
+
122
+ static addNotes(builder:flatbuffers.Builder, notesOffset:flatbuffers.Offset) {
123
+ builder.addFieldOffset(3, notesOffset, 0);
124
+ }
125
+
126
+ static createNotesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
127
+ builder.startVector(4, data.length, 4);
128
+ for (let i = data.length - 1; i >= 0; i--) {
129
+ builder.addOffset(data[i]!);
130
+ }
131
+ return builder.endVector();
132
+ }
133
+
134
+ static startNotesVector(builder:flatbuffers.Builder, numElems:number) {
135
+ builder.startVector(4, numElems, 4);
136
+ }
137
+
138
+ static addDiscounts(builder:flatbuffers.Builder, discountsOffset:flatbuffers.Offset) {
139
+ builder.addFieldOffset(4, discountsOffset, 0);
140
+ }
141
+
142
+ static createDiscountsVector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
143
+ /**
144
+ * @deprecated This Uint8Array overload will be removed in the future.
145
+ */
146
+ static createDiscountsVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
147
+ static createDiscountsVector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
148
+ builder.startVector(8, data.length, 8);
149
+ for (let i = data.length - 1; i >= 0; i--) {
150
+ builder.addFloat64(data[i]!);
151
+ }
152
+ return builder.endVector();
153
+ }
154
+
155
+ static startDiscountsVector(builder:flatbuffers.Builder, numElems:number) {
156
+ builder.startVector(8, numElems, 8);
157
+ }
158
+
159
+ static addActive(builder:flatbuffers.Builder, active:boolean) {
160
+ builder.addFieldInt8(5, +active, +false);
161
+ }
162
+
163
+ static addCreatedAt(builder:flatbuffers.Builder, createdAt:bigint) {
164
+ builder.addFieldInt64(6, createdAt, BigInt('0'));
165
+ }
166
+
167
+ static addBilling(builder:flatbuffers.Builder, billingOffset:flatbuffers.Offset) {
168
+ builder.addFieldOffset(7, billingOffset, 0);
169
+ }
170
+
171
+ static endOrder(builder:flatbuffers.Builder):flatbuffers.Offset {
172
+ const offset = builder.endObject();
173
+ return offset;
174
+ }
175
+
176
+
177
+ unpack(): OrderT {
178
+ return new OrderT(
179
+ this.orderId(),
180
+ (this.customer() !== null ? this.customer()!.unpack() : null),
181
+ this.bb!.createObjList<OrderLine, OrderLineT>(this.lines.bind(this), this.linesLength()),
182
+ this.bb!.createScalarList<string>(this.notes.bind(this), this.notesLength()),
183
+ this.bb!.createScalarList<number>(this.discounts.bind(this), this.discountsLength()),
184
+ this.active(),
185
+ this.createdAt(),
186
+ (this.billing() !== null ? this.billing()!.unpack() : null)
187
+ );
188
+ }
189
+
190
+
191
+ unpackTo(_o: OrderT): void {
192
+ _o.orderId = this.orderId();
193
+ _o.customer = (this.customer() !== null ? this.customer()!.unpack() : null);
194
+ _o.lines = this.bb!.createObjList<OrderLine, OrderLineT>(this.lines.bind(this), this.linesLength());
195
+ _o.notes = this.bb!.createScalarList<string>(this.notes.bind(this), this.notesLength());
196
+ _o.discounts = this.bb!.createScalarList<number>(this.discounts.bind(this), this.discountsLength());
197
+ _o.active = this.active();
198
+ _o.createdAt = this.createdAt();
199
+ _o.billing = (this.billing() !== null ? this.billing()!.unpack() : null);
200
+ }
201
+ }
202
+
203
+ export class OrderT implements flatbuffers.IGeneratedObject {
204
+ constructor(
205
+ public orderId: string|Uint8Array|null = null,
206
+ public customer: CustomerT|null = null,
207
+ public lines: (OrderLineT)[] = [],
208
+ public notes: (string)[] = [],
209
+ public discounts: (number)[] = [],
210
+ public active: boolean = false,
211
+ public createdAt: bigint = BigInt('0'),
212
+ public billing: OrderBillingT|null = null
213
+ ){}
214
+
215
+
216
+ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
217
+ const orderId = (this.orderId !== null ? builder.createString(this.orderId!) : 0);
218
+ const customer = (this.customer !== null ? this.customer!.pack(builder) : 0);
219
+ const lines = Order.createLinesVector(builder, builder.createObjectOffsetList(this.lines));
220
+ const notes = Order.createNotesVector(builder, builder.createObjectOffsetList(this.notes));
221
+ const discounts = Order.createDiscountsVector(builder, this.discounts);
222
+ const billing = (this.billing !== null ? this.billing!.pack(builder) : 0);
223
+
224
+ Order.startOrder(builder);
225
+ Order.addOrderId(builder, orderId);
226
+ Order.addCustomer(builder, customer);
227
+ Order.addLines(builder, lines);
228
+ Order.addNotes(builder, notes);
229
+ Order.addDiscounts(builder, discounts);
230
+ Order.addActive(builder, this.active);
231
+ Order.addCreatedAt(builder, this.createdAt);
232
+ Order.addBilling(builder, billing);
233
+
234
+ return Order.endOrder(builder);
235
+ }
236
+ }