@@ -163,16 +163,20 @@ Templates define the structure and type of generated data:
163
163
// Shorthand templates
164
164
TemplateJson .gen (' str' ); // Random string
165
165
TemplateJson .gen (' int' ); // Random integer
166
+ TemplateJson .gen (' int64' ); // Random 64-bit integer (bigint)
166
167
TemplateJson .gen (' float' ); // Random float
167
168
TemplateJson .gen (' num' ); // Random number (int or float)
168
169
TemplateJson .gen (' bool' ); // Random boolean
170
+ TemplateJson .gen (' bin' ); // Random binary data (Uint8Array)
169
171
TemplateJson .gen (' nil' ); // null value
170
172
171
173
// Type-specific templates
172
174
TemplateJson .gen ([' str' , tokenPattern ]); // String with pattern
173
175
TemplateJson .gen ([' int' , min , max ]); // Integer in range
176
+ TemplateJson .gen ([' int64' , min , max ]); // 64-bit integer in range (bigint)
174
177
TemplateJson .gen ([' float' , min , max ]); // Float in range
175
178
TemplateJson .gen ([' bool' , fixedValue ]); // Fixed or random boolean
179
+ TemplateJson .gen ([' bin' , min , max , omin , omax ]); // Binary with length and octet range
176
180
TemplateJson .gen ([' lit' , anyValue ]); // Literal value (cloned)
177
181
```
178
182
@@ -191,11 +195,71 @@ const age = TemplateJson.gen(['int', 18, 100]);
191
195
const price = TemplateJson .gen ([' float' , 0.01 , 999.99 ]);
192
196
const score = TemplateJson .gen ([' num' , 0 , 100 ]);
193
197
198
+ // 64-bit integers (bigint)
199
+ const largeId = TemplateJson .gen ([' int64' , BigInt (' 1000000000000' ), BigInt (' 9999999999999' )]);
200
+ const timestamp = TemplateJson .gen ([' int64' , BigInt (' 1640000000000' ), BigInt (' 1700000000000' )]);
201
+
202
+ // Binary data (Uint8Array)
203
+ const hash = TemplateJson .gen ([' bin' , 32 , 32 ]); // 32-byte hash
204
+ const key = TemplateJson .gen ([' bin' , 16 , 16 , 0 , 255 ]); // 16-byte key with full octet range
205
+ const randomBytes = TemplateJson .gen ([' bin' , 1 , 10 ]); // 1-10 random bytes
206
+
194
207
// Fixed values
195
208
const isActive = TemplateJson .gen ([' bool' , true ]);
196
209
const userId = TemplateJson .gen ([' lit' , ' user_12345' ]);
197
210
```
198
211
212
+ ##### 64-bit Integer Templates
213
+
214
+ Generate large integers using JavaScript's bigint type:
215
+
216
+ ``` typescript
217
+ // Basic 64-bit integer
218
+ const id = TemplateJson .gen (' int64' ); // Random bigint in safe range
219
+
220
+ // 64-bit integer with range
221
+ const timestamp = TemplateJson .gen ([' int64' ,
222
+ BigInt (' 1640000000000' ), // Min value
223
+ BigInt (' 1700000000000' ) // Max value
224
+ ]);
225
+
226
+ // Large database IDs
227
+ const dbId = TemplateJson .gen ([' int64' ,
228
+ BigInt (' 1000000000000000000' ),
229
+ BigInt (' 9999999999999999999' )
230
+ ]);
231
+
232
+ // Fixed bigint value
233
+ const constant = TemplateJson .gen ([' int64' , BigInt (' 42' ), BigInt (' 42' )]);
234
+ ```
235
+
236
+ ##### Binary Data Templates
237
+
238
+ Generate binary data as Uint8Array:
239
+
240
+ ``` typescript
241
+ // Basic binary data (0-5 bytes)
242
+ const data = TemplateJson .gen (' bin' );
243
+
244
+ // Binary with specific length range
245
+ const hash = TemplateJson .gen ([' bin' , 32 , 32 ]); // Exactly 32 bytes
246
+ const key = TemplateJson .gen ([' bin' , 16 , 64 ]); // 16-64 bytes
247
+
248
+ // Binary with octet value constraints
249
+ const restrictedData = TemplateJson .gen ([' bin' ,
250
+ 8 , // Min length: 8 bytes
251
+ 16 , // Max length: 16 bytes
252
+ 32 , // Min octet value: 32
253
+ 126 // Max octet value: 126 (printable ASCII range)
254
+ ]);
255
+
256
+ // Cryptographic examples
257
+ const aesKey = TemplateJson .gen ([' bin' , 32 , 32 ]); // 256-bit AES key
258
+ const iv = TemplateJson .gen ([' bin' , 16 , 16 ]); // 128-bit IV
259
+ const salt = TemplateJson .gen ([' bin' , 16 , 32 ]); // 16-32 byte salt
260
+ const signature = TemplateJson .gen ([' bin' , 64 , 64 , 0 , 255 ]); // 64-byte signature
261
+ ```
262
+
199
263
##### Array Templates
200
264
201
265
``` typescript
@@ -535,6 +599,16 @@ const mockApiResponse = TemplateJson.gen(['obj', [
535
599
[' value' , [' float' , 0 , 1000 ]]
536
600
]]]]
537
601
]]);
602
+
603
+ // Generate cryptographic test data
604
+ const cryptoData = TemplateJson .gen ([' obj' , [
605
+ [' userId' , [' int64' , BigInt (' 1000000000000' ), BigInt (' 9999999999999' )]],
606
+ [' sessionId' , [' str' , [' list' , ' sess_' , [' repeat' , 32 , 32 , [' pick' , ... ' 0123456789abcdef' .split (' ' )]]]]],
607
+ [' publicKey' , [' bin' , 32 , 32 ]], // 256-bit public key
608
+ [' signature' , [' bin' , 64 , 64 ]], // 512-bit signature
609
+ [' nonce' , [' bin' , 16 , 16 ]], // 128-bit nonce
610
+ [' timestamp' , [' int64' , BigInt (Date .now ()), BigInt (Date .now () + 86400000 )]]
611
+ ]]);
538
612
```
539
613
540
614
### Load Testing
@@ -575,6 +649,11 @@ const serviceConfig = TemplateJson.gen(['obj', [
575
649
[' ttl' , [' int' , 60 , 3600 ]],
576
650
[' max_size' , [' int' , 100 , 10000 ]]
577
651
]]],
652
+ [' security' , [' obj' , [
653
+ [' api_key' , [' bin' , 32 , 32 ]], // 256-bit API key
654
+ [' session_timeout' , [' int64' , BigInt (' 3600' ), BigInt (' 86400' )]], // 1 hour to 1 day in seconds
655
+ [' max_request_size' , [' int64' , BigInt (' 1048576' ), BigInt (' 104857600' )]] // 1MB to 100MB
656
+ ]]],
578
657
[' features' , [' map' ,
579
658
[' pick' , ' feature_a' , ' feature_b' , ' feature_c' , ' feature_d' ],
580
659
' bool' ,
0 commit comments