@netifyjs/netify 0.0.0-stage → 1.0.0-alpha.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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -2
  3. package/package.json +65 -4
  4. package/src/bootstrap/client/index.ts +191 -0
  5. package/src/bootstrap/dispatcher/index.ts +204 -0
  6. package/src/bootstrap/index.ts +22 -0
  7. package/src/bootstrap/reconnect/index.ts +334 -0
  8. package/src/bootstrap/server/index.ts +284 -0
  9. package/src/buffer/bits/index.ts +2 -0
  10. package/src/buffer/bits/reader/index.ts +64 -0
  11. package/src/buffer/bits/writer/index.ts +79 -0
  12. package/src/buffer/index.ts +1375 -0
  13. package/src/buffer/pool/index.ts +46 -0
  14. package/src/buffer/quantizer/index.ts +101 -0
  15. package/src/channel/attribute/index.ts +89 -0
  16. package/src/channel/context/index.ts +621 -0
  17. package/src/channel/group/index.ts +256 -0
  18. package/src/channel/handler/duplex/index.ts +105 -0
  19. package/src/channel/handler/inbound/index.ts +78 -0
  20. package/src/channel/handler/index.ts +135 -0
  21. package/src/channel/handler/outbound/index.ts +33 -0
  22. package/src/channel/index.ts +619 -0
  23. package/src/channel/initializer/index.ts +77 -0
  24. package/src/channel/outbound/index.ts +611 -0
  25. package/src/channel/pipeline/head/index.ts +100 -0
  26. package/src/channel/pipeline/index.ts +414 -0
  27. package/src/channel/pipeline/tail/index.ts +45 -0
  28. package/src/channel/pipeline/tracker/index.ts +120 -0
  29. package/src/channel/queue/index.ts +203 -0
  30. package/src/channel/resolved/index.ts +34 -0
  31. package/src/channel/server/index.ts +164 -0
  32. package/src/channel/shutdown/index.ts +25 -0
  33. package/src/channel/simple/index.ts +38 -0
  34. package/src/channel/transport/index.ts +74 -0
  35. package/src/channel/transport/socket/index.ts +80 -0
  36. package/src/cluster/index.ts +360 -0
  37. package/src/codec/binary/index.ts +102 -0
  38. package/src/codec/decoder/index.ts +479 -0
  39. package/src/codec/delimiter/index.ts +189 -0
  40. package/src/codec/encoder/index.ts +48 -0
  41. package/src/codec/error/index.ts +33 -0
  42. package/src/codec/fixed/index.ts +45 -0
  43. package/src/codec/http/aggregator/index.ts +236 -0
  44. package/src/codec/http/client/index.ts +120 -0
  45. package/src/codec/http/decoder/index.ts +4 -0
  46. package/src/codec/http/decoder/object/index.ts +644 -0
  47. package/src/codec/http/decoder/request/index.ts +49 -0
  48. package/src/codec/http/decoder/response/index.ts +59 -0
  49. package/src/codec/http/encoder/index.ts +3 -0
  50. package/src/codec/http/encoder/object/index.ts +196 -0
  51. package/src/codec/http/encoder/request/index.ts +24 -0
  52. package/src/codec/http/encoder/response/index.ts +26 -0
  53. package/src/codec/http/headers/index.ts +287 -0
  54. package/src/codec/http/index.ts +33 -0
  55. package/src/codec/http/message/content/index.ts +36 -0
  56. package/src/codec/http/message/full/index.ts +10 -0
  57. package/src/codec/http/message/full/request/index.ts +45 -0
  58. package/src/codec/http/message/full/response/index.ts +43 -0
  59. package/src/codec/http/message/head/index.ts +79 -0
  60. package/src/codec/http/message/index.ts +16 -0
  61. package/src/codec/http/message/last/index.ts +27 -0
  62. package/src/codec/http/message/request/index.ts +39 -0
  63. package/src/codec/http/message/response/index.ts +31 -0
  64. package/src/codec/http/method/index.ts +101 -0
  65. package/src/codec/http/server/index.ts +81 -0
  66. package/src/codec/http/status/index.ts +170 -0
  67. package/src/codec/http/version/index.ts +70 -0
  68. package/src/codec/index.ts +83 -0
  69. package/src/codec/length/index.ts +330 -0
  70. package/src/codec/line/index.ts +45 -0
  71. package/src/codec/message/decoder/index.ts +84 -0
  72. package/src/codec/message/encoder/index.ts +56 -0
  73. package/src/codec/message/index.ts +2 -0
  74. package/src/codec/msgpack/index.ts +51 -0
  75. package/src/codec/prepender/index.ts +296 -0
  76. package/src/codec/protobuf/index.ts +57 -0
  77. package/src/codec/string/decoder/index.ts +47 -0
  78. package/src/codec/string/encoder/index.ts +26 -0
  79. package/src/codec/string/index.ts +2 -0
  80. package/src/codec/websocket/client/index.ts +235 -0
  81. package/src/codec/websocket/decoder/index.ts +371 -0
  82. package/src/codec/websocket/encoder/index.ts +170 -0
  83. package/src/codec/websocket/error/index.ts +42 -0
  84. package/src/codec/websocket/frame/base/index.ts +55 -0
  85. package/src/codec/websocket/frame/binary/index.ts +24 -0
  86. package/src/codec/websocket/frame/close/index.ts +82 -0
  87. package/src/codec/websocket/frame/continuation/index.ts +31 -0
  88. package/src/codec/websocket/frame/index.ts +10 -0
  89. package/src/codec/websocket/frame/opcode/index.ts +35 -0
  90. package/src/codec/websocket/frame/ping/index.ts +24 -0
  91. package/src/codec/websocket/frame/pong/index.ts +24 -0
  92. package/src/codec/websocket/frame/text/index.ts +31 -0
  93. package/src/codec/websocket/handshake/index.ts +38 -0
  94. package/src/codec/websocket/index.ts +25 -0
  95. package/src/codec/websocket/key/index.ts +41 -0
  96. package/src/codec/websocket/protocol/index.ts +147 -0
  97. package/src/codec/websocket/server/index.ts +233 -0
  98. package/src/codec/websocket/status/index.ts +97 -0
  99. package/src/codec/websocket/upgrade/index.ts +116 -0
  100. package/src/datagram/bootstrap/index.ts +269 -0
  101. package/src/datagram/channel/index.ts +103 -0
  102. package/src/datagram/index.ts +10 -0
  103. package/src/datagram/packet/index.ts +72 -0
  104. package/src/datagram/transport/index.ts +239 -0
  105. package/src/handler/flush/index.ts +187 -0
  106. package/src/handler/idle/index.ts +295 -0
  107. package/src/handler/index.ts +22 -0
  108. package/src/handler/logging/index.ts +195 -0
  109. package/src/handler/metrics/index.ts +300 -0
  110. package/src/handler/offload/index.ts +141 -0
  111. package/src/handler/timeout/error/index.ts +29 -0
  112. package/src/handler/timeout/index.ts +3 -0
  113. package/src/handler/timeout/read/index.ts +44 -0
  114. package/src/handler/timeout/write/index.ts +89 -0
  115. package/src/handler/traffic/index.ts +259 -0
  116. package/src/index.ts +258 -0
  117. package/src/logger/index.ts +47 -0
  118. package/src/reliable/bootstrap/index.ts +154 -0
  119. package/src/reliable/cipher/index.ts +227 -0
  120. package/src/reliable/cookie/index.ts +78 -0
  121. package/src/reliable/handler/index.ts +1202 -0
  122. package/src/reliable/handshake/index.ts +144 -0
  123. package/src/reliable/index.ts +38 -0
  124. package/src/reliable/lane/index.ts +420 -0
  125. package/src/reliable/message/index.ts +102 -0
  126. package/src/reliable/packet/index.ts +117 -0
  127. package/src/reliable/peer/index.ts +929 -0
  128. package/src/reliable/registry/index.ts +107 -0
  129. package/src/serve/bootstrap/index.ts +606 -0
  130. package/src/serve/channel/index.ts +246 -0
  131. package/src/serve/index.ts +17 -0
  132. package/src/serve/outbox/index.ts +292 -0
  133. package/src/serve/transport/index.ts +96 -0
  134. package/src/serve/writer/index.ts +119 -0
  135. package/src/shard/envelope/index.ts +44 -0
  136. package/src/shard/index.ts +10 -0
  137. package/src/shard/link/index.ts +743 -0
  138. package/src/shard/map/index.ts +91 -0
  139. package/src/worker/group/index.ts +175 -0
  140. package/src/worker/index.ts +10 -0
  141. package/src/worker/pool/index.ts +235 -0
  142. package/src/worker/service/index.ts +55 -0
@@ -0,0 +1,51 @@
1
+ import { BinaryCodec } from '../binary/index.ts'
2
+
3
+ /**
4
+ * The part of a msgpackr Packr, or a similar packer, that the codec needs
5
+ */
6
+ export type MessagePacker = {
7
+ /**
8
+ * Turns a value into MessagePack bytes
9
+ * @param value anything MessagePack can hold
10
+ */
11
+ pack(value: never): Uint8Array
12
+
13
+ /**
14
+ * Reads a value back
15
+ * @param bytes one encoded value
16
+ */
17
+ unpack(bytes: Uint8Array): unknown
18
+ }
19
+
20
+ /**
21
+ * MessagePack over netify, msgpackr's Packr with records on is the fast choice
22
+ * @class
23
+ */
24
+ export class MessagePackCodec<T> extends BinaryCodec<T> {
25
+ /**
26
+ * Builds the codec around a packer
27
+ * @param packer usually new Packr({ useRecords: true })
28
+ * @param accepts picks the outbound messages to encode
29
+ */
30
+ public constructor(
31
+ packer: MessagePacker,
32
+ accepts: (message: unknown) => message is T,
33
+ ) {
34
+ super({
35
+ /**
36
+ * Packs the whole message
37
+ * @param message what's being sent
38
+ */
39
+ encode: (message: T): Uint8Array => packer.pack(message as never),
40
+ /**
41
+ * Unpacks straight off the frame, trusting the type you gave the codec
42
+ * @param bytes one frame
43
+ */
44
+ decode: (bytes: Uint8Array): T => packer.unpack(bytes) as T,
45
+ /**
46
+ * Which writes are ours
47
+ */
48
+ accepts,
49
+ })
50
+ }
51
+ }
@@ -0,0 +1,296 @@
1
+ import { ByteBuf, type Endian } from '../../buffer/index.ts'
2
+ import type { HandlerContext } from '../../channel/context/index.ts'
3
+ import { resolved } from '../../channel/resolved/index.ts'
4
+ import { MessageToByteEncoder } from '../encoder/index.ts'
5
+ import { EncoderError } from '../error/index.ts'
6
+ import type { LengthFieldLength } from '../length/index.ts'
7
+
8
+ /**
9
+ * Settings for LengthFieldPrepender
10
+ */
11
+ export type PrependerOptions = {
12
+ /**
13
+ * How many bytes the length takes up
14
+ */
15
+ readonly lengthFieldLength: LengthFieldLength
16
+
17
+ /**
18
+ * Added to the body length before it's written
19
+ */
20
+ readonly lengthAdjustment?: number
21
+
22
+ /**
23
+ * Counts the length field's own bytes in the length too
24
+ */
25
+ readonly lengthIncludesLengthFieldLength?: boolean
26
+
27
+ /**
28
+ * Big endian unless told otherwise
29
+ */
30
+ readonly endian?: Endian
31
+ }
32
+
33
+ /**
34
+ * Puts a length prefix in front of each outbound buffer
35
+ * @class
36
+ */
37
+ export class LengthFieldPrepender extends MessageToByteEncoder<
38
+ ByteBuf | Uint8Array
39
+ > {
40
+ /**
41
+ * Bodies this big are cheaper to send as a second write than to copy
42
+ */
43
+ public static readonly splitAt: number = 1024
44
+
45
+ /**
46
+ * Width of the prefix in bytes
47
+ */
48
+ private readonly lengthFieldLength: LengthFieldLength
49
+
50
+ /**
51
+ * Added to the body length
52
+ */
53
+ private readonly lengthAdjustment: number
54
+
55
+ /**
56
+ * Adds the prefix width to the length when set
57
+ */
58
+ private readonly includesField: boolean
59
+
60
+ /**
61
+ * Endianness used for the prefix
62
+ */
63
+ private readonly endian: Endian
64
+
65
+ /**
66
+ * Added to the body size to get the length field
67
+ */
68
+ private readonly extra: number
69
+
70
+ /**
71
+ * Biggest length the field can hold
72
+ */
73
+ private readonly maxLength: number
74
+
75
+ /**
76
+ * Sets up a prepender for this field layout
77
+ * @param options prefix width and adjustments
78
+ */
79
+ public constructor(options: PrependerOptions) {
80
+ super()
81
+
82
+ if (![1, 2, 3, 4, 8].includes(options.lengthFieldLength)) {
83
+ throw new RangeError('Length field size is invalid')
84
+ }
85
+
86
+ this.lengthFieldLength = options.lengthFieldLength
87
+ this.lengthAdjustment = options.lengthAdjustment ?? 0
88
+ this.includesField = options.lengthIncludesLengthFieldLength ?? false
89
+ this.endian = options.endian ?? 'big'
90
+ this.extra =
91
+ this.lengthAdjustment + (this.includesField ? this.lengthFieldLength : 0)
92
+ this.maxLength = Math.min(
93
+ 2 ** (this.lengthFieldLength * 8) - 1,
94
+ Number.MAX_SAFE_INTEGER,
95
+ )
96
+ }
97
+
98
+ /**
99
+ * Takes ByteBufs and plain Uint8Arrays
100
+ * @param message the outbound message
101
+ */
102
+ protected accepts(message: unknown): message is ByteBuf | Uint8Array {
103
+ return message instanceof ByteBuf || message instanceof Uint8Array
104
+ }
105
+
106
+ /**
107
+ * Big bodies go out as two writes so they're never copied here, small ones get one buffer
108
+ * @param context where bytes go
109
+ * @param message whatever is being written
110
+ */
111
+ public override write(
112
+ context: HandlerContext,
113
+ message: unknown,
114
+ ): Promise<void> {
115
+ if (!this.accepts(message)) return context.write(message)
116
+
117
+ const size =
118
+ message instanceof ByteBuf ? message.readableBytes : message.length
119
+ if (size < LengthFieldPrepender.splitAt) {
120
+ if (context.pipeline.syncing && context.writesToSocket) {
121
+ const staged = this.stage(context, message, size)
122
+ if (staged !== null) return staged
123
+ }
124
+
125
+ return super.write(context, message)
126
+ }
127
+
128
+ const body = message instanceof ByteBuf ? message.toUint8Array() : message
129
+ const header = ByteBuf.allocate(this.lengthFieldLength)
130
+ try {
131
+ this.writeLength(header, this.lengthOf(size))
132
+ } catch (error) {
133
+ return Promise.reject(
134
+ error instanceof EncoderError
135
+ ? error
136
+ : new EncoderError('Encoding failed', { cause: error }),
137
+ )
138
+ }
139
+
140
+ void context.write(header)
141
+ return context.write(body)
142
+ }
143
+
144
+ /**
145
+ * Stages small writes straight into the outbound buffer, false for the rest
146
+ * @param context where bytes go
147
+ * @param message whatever is being written
148
+ */
149
+ public writeSync(context: HandlerContext, message: unknown): boolean {
150
+ if (!this.accepts(message) || !context.writesToSocket) return false
151
+
152
+ const size =
153
+ message instanceof ByteBuf ? message.readableBytes : message.length
154
+ return (
155
+ size < LengthFieldPrepender.splitAt &&
156
+ this.stage(context, message, size) !== null
157
+ )
158
+ }
159
+
160
+ /**
161
+ * Builds a new buffer with the prefix followed by the body
162
+ * @param context unused here
163
+ * @param message the body to wrap
164
+ */
165
+ protected encode(
166
+ context: HandlerContext,
167
+ message: ByteBuf | Uint8Array,
168
+ ): ByteBuf {
169
+ const size =
170
+ message instanceof ByteBuf ? message.readableBytes : message.length
171
+
172
+ const out = ByteBuf.allocate(this.lengthFieldLength + size)
173
+ this.writeLength(out, this.lengthOf(size))
174
+ if (message instanceof ByteBuf) {
175
+ out.writeBytes(message, message.readerIndex, size)
176
+ } else {
177
+ out.writeBytes(message)
178
+ }
179
+
180
+ return out
181
+ }
182
+
183
+ /**
184
+ * Writes the prefix and body straight into the outbound buffer, or null when it can't
185
+ * @param context where the write is going
186
+ * @param message the body
187
+ * @param size bytes in the body
188
+ */
189
+ private stage(
190
+ context: HandlerContext,
191
+ message: ByteBuf | Uint8Array,
192
+ size: number,
193
+ ): Promise<void> | null {
194
+ const length = size + this.extra
195
+ if (length < 0 || length > this.maxLength) return null
196
+
197
+ const channel = context.channel
198
+ const field = this.lengthFieldLength
199
+ const offset = channel.reserve(field + size)
200
+ if (offset < 0) return null
201
+
202
+ const target = channel.stagingBuffer
203
+ if (field === 4 && this.endian === 'big') {
204
+ target[offset] = length >>> 24
205
+ target[offset + 1] = (length >>> 16) & 0xff
206
+ target[offset + 2] = (length >>> 8) & 0xff
207
+ target[offset + 3] = length & 0xff
208
+ } else if (field === 2 && this.endian === 'big') {
209
+ target[offset] = length >>> 8
210
+ target[offset + 1] = length & 0xff
211
+ } else {
212
+ LengthFieldPrepender.putLength(target, offset, field, length, this.endian)
213
+ }
214
+
215
+ if (message instanceof ByteBuf) {
216
+ ByteBuf.copyBytes(
217
+ message.array,
218
+ message.arrayOffset + message.readerIndex,
219
+ target,
220
+ offset + field,
221
+ size,
222
+ )
223
+ } else {
224
+ ByteBuf.copyBytes(message, 0, target, offset + field, size)
225
+ }
226
+
227
+ channel.commitStaged()
228
+ return resolved
229
+ }
230
+
231
+ /**
232
+ * Writes a length of any field size and byte order
233
+ * @param target where to write
234
+ * @param offset where it starts
235
+ * @param field bytes in the field
236
+ * @param length the value
237
+ * @param endian byte order
238
+ */
239
+ private static putLength(
240
+ target: Uint8Array,
241
+ offset: number,
242
+ field: number,
243
+ length: number,
244
+ endian: Endian,
245
+ ): void {
246
+ let rest = length
247
+ for (let index = 0; index < field; index++) {
248
+ const at = endian === 'big' ? offset + field - 1 - index : offset + index
249
+ target[at] = rest % 256
250
+ rest = Math.floor(rest / 256)
251
+ }
252
+ }
253
+
254
+ /**
255
+ * What the length field should say for this body
256
+ * @param size bytes in the body
257
+ */
258
+ private lengthOf(size: number): number {
259
+ return (
260
+ size +
261
+ this.lengthAdjustment +
262
+ (this.includesField ? this.lengthFieldLength : 0)
263
+ )
264
+ }
265
+
266
+ /**
267
+ * Writes the prefix, refusing lengths that won't fit the field
268
+ * @param out buffer the prefix goes into
269
+ * @param length value after adjustments
270
+ */
271
+ private writeLength(out: ByteBuf, length: number): void {
272
+ const limit = 2 ** (this.lengthFieldLength * 8) - 1
273
+ if (length < 0) throw new EncoderError('Length is negative')
274
+ if (length > Math.min(limit, Number.MAX_SAFE_INTEGER)) {
275
+ throw new EncoderError('Length is too large')
276
+ }
277
+
278
+ switch (this.lengthFieldLength) {
279
+ case 1:
280
+ out.writeUint8(length)
281
+ break
282
+ case 2:
283
+ out.writeUint16(length, this.endian)
284
+ break
285
+ case 3:
286
+ out.writeUint24(length, this.endian)
287
+ break
288
+ case 4:
289
+ out.writeUint32(length, this.endian)
290
+ break
291
+ case 8:
292
+ out.writeUint64(BigInt(length), this.endian)
293
+ break
294
+ }
295
+ }
296
+ }
@@ -0,0 +1,57 @@
1
+ import { BinaryCodec } from '../binary/index.ts'
2
+
3
+ /**
4
+ * The part of a protobufjs Type, or a pbjs generated class, that the codec needs
5
+ */
6
+ export type ProtobufType = {
7
+ /**
8
+ * Starts encoding a message
9
+ * @param message the message object
10
+ */
11
+ encode(message: never): {
12
+ /**
13
+ * Ends encoding and gives the bytes
14
+ */
15
+ finish(): Uint8Array
16
+ }
17
+
18
+ /**
19
+ * Reads a message from bytes
20
+ * @param bytes one encoded message
21
+ */
22
+ decode(bytes: Uint8Array): unknown
23
+ }
24
+
25
+ /**
26
+ * Protocol Buffers over netify, works with protobufjs and its generated code
27
+ * @class
28
+ */
29
+ export class ProtobufCodec<T> extends BinaryCodec<T> {
30
+ /**
31
+ * Builds the codec around a message type
32
+ * @param type protobufjs Type or generated class
33
+ * @param accepts picks the outbound messages to encode
34
+ */
35
+ public constructor(
36
+ type: ProtobufType,
37
+ accepts: (message: unknown) => message is T,
38
+ ) {
39
+ super({
40
+ /**
41
+ * protobufjs builds a writer, finish gives the bytes
42
+ * @param message what's being sent
43
+ */
44
+ encode: (message: T): Uint8Array =>
45
+ type.encode(message as never).finish(),
46
+ /**
47
+ * Decodes straight off the frame, trusting the type you gave the codec
48
+ * @param bytes one frame
49
+ */
50
+ decode: (bytes: Uint8Array): T => type.decode(bytes) as T,
51
+ /**
52
+ * Which writes are ours
53
+ */
54
+ accepts,
55
+ })
56
+ }
57
+ }
@@ -0,0 +1,47 @@
1
+ import { ByteBuf } from '../../../buffer/index.ts'
2
+ import type { HandlerContext } from '../../../channel/context/index.ts'
3
+ import { MessageToMessageDecoder } from '../../message/decoder/index.ts'
4
+ import type { Encoding } from 'bun'
5
+
6
+ /**
7
+ * Turns each inbound buffer into a string
8
+ * @class
9
+ */
10
+ export class StringDecoder extends MessageToMessageDecoder<ByteBuf, string> {
11
+ /**
12
+ * Reused for every buffer
13
+ */
14
+ private readonly decoder: TextDecoder
15
+
16
+ /**
17
+ * Sets up a decoder for the given text encoding
18
+ * @param encoding any label TextDecoder knows, UTF-8 by default
19
+ */
20
+ public constructor(encoding: Encoding = 'utf-8') {
21
+ super()
22
+
23
+ this.decoder = new TextDecoder(encoding)
24
+ }
25
+
26
+ /**
27
+ * Only ByteBufs get decoded
28
+ * @param message the inbound message
29
+ */
30
+ protected accepts(message: unknown): message is ByteBuf {
31
+ return message instanceof ByteBuf
32
+ }
33
+
34
+ /**
35
+ * Decodes the whole buffer in one go
36
+ * @param context unused here
37
+ * @param message bytes to read as text
38
+ * @param out gets exactly one string
39
+ */
40
+ protected decode(
41
+ context: HandlerContext,
42
+ message: ByteBuf,
43
+ out: string[],
44
+ ): void {
45
+ out.push(this.decoder.decode(message.toUint8Array()))
46
+ }
47
+ }
@@ -0,0 +1,26 @@
1
+ import { ByteBuf } from '../../../buffer/index.ts'
2
+ import type { HandlerContext } from '../../../channel/context/index.ts'
3
+ import { MessageToByteEncoder } from '../../encoder/index.ts'
4
+
5
+ /**
6
+ * Writes strings out as UTF-8
7
+ * @class
8
+ */
9
+ export class StringEncoder extends MessageToByteEncoder<string> {
10
+ /**
11
+ * Only strings are ours to encode
12
+ * @param message the outbound message
13
+ */
14
+ protected accepts(message: unknown): message is string {
15
+ return typeof message === 'string'
16
+ }
17
+
18
+ /**
19
+ * UTF-8 encodes it into a fresh buffer
20
+ * @param context unused here
21
+ * @param message text to send
22
+ */
23
+ protected encode(context: HandlerContext, message: string): ByteBuf {
24
+ return ByteBuf.fromString(message)
25
+ }
26
+ }
@@ -0,0 +1,2 @@
1
+ export { StringDecoder } from './decoder/index.ts'
2
+ export { StringEncoder } from './encoder/index.ts'