@@ -163,16 +163,20 @@ Templates define the structure and type of generated data:
163163// Shorthand templates
164164TemplateJson .gen (' str' ); // Random string
165165TemplateJson .gen (' int' ); // Random integer
166+ TemplateJson .gen (' int64' ); // Random 64-bit integer (bigint)
166167TemplateJson .gen (' float' ); // Random float
167168TemplateJson .gen (' num' ); // Random number (int or float)
168169TemplateJson .gen (' bool' ); // Random boolean
170+ TemplateJson .gen (' bin' ); // Random binary data (Uint8Array)
169171TemplateJson .gen (' nil' ); // null value
170172
171173// Type-specific templates
172174TemplateJson .gen ([' str' , tokenPattern ]); // String with pattern
173175TemplateJson .gen ([' int' , min , max ]); // Integer in range
176+ TemplateJson .gen ([' int64' , min , max ]); // 64-bit integer in range (bigint)
174177TemplateJson .gen ([' float' , min , max ]); // Float in range
175178TemplateJson .gen ([' bool' , fixedValue ]); // Fixed or random boolean
179+ TemplateJson .gen ([' bin' , min , max , omin , omax ]); // Binary with length and octet range
176180TemplateJson .gen ([' lit' , anyValue ]); // Literal value (cloned)
177181```
178182
@@ -191,11 +195,71 @@ const age = TemplateJson.gen(['int', 18, 100]);
191195const price = TemplateJson .gen ([' float' , 0.01 , 999.99 ]);
192196const score = TemplateJson .gen ([' num' , 0 , 100 ]);
193197
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+
194207// Fixed values
195208const isActive = TemplateJson .gen ([' bool' , true ]);
196209const userId = TemplateJson .gen ([' lit' , ' user_12345' ]);
197210```
198211
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+
199263##### Array Templates
200264
201265``` typescript
@@ -535,6 +599,16 @@ const mockApiResponse = TemplateJson.gen(['obj', [
535599 [' value' , [' float' , 0 , 1000 ]]
536600 ]]]]
537601]]);
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+ ]]);
538612```
539613
540614### Load Testing
@@ -575,6 +649,11 @@ const serviceConfig = TemplateJson.gen(['obj', [
575649 [' ttl' , [' int' , 60 , 3600 ]],
576650 [' max_size' , [' int' , 100 , 10000 ]]
577651 ]]],
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+ ]]],
578657 [' features' , [' map' ,
579658 [' pick' , ' feature_a' , ' feature_b' , ' feature_c' , ' feature_d' ],
580659 ' bool' ,
0 commit comments