@omnitronix/rng-client-core 1.0.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 (34) hide show
  1. package/README.md +309 -0
  2. package/dist/core/rng-client-core.d.ts +13 -0
  3. package/dist/core/rng-client-core.d.ts.map +1 -0
  4. package/dist/core/rng-client-core.js +33 -0
  5. package/dist/core/rng-client-core.js.map +1 -0
  6. package/dist/http/http-client.types.d.ts +28 -0
  7. package/dist/http/http-client.types.d.ts.map +1 -0
  8. package/dist/http/http-client.types.js +3 -0
  9. package/dist/http/http-client.types.js.map +1 -0
  10. package/dist/http/http-rng-client.d.ts +11 -0
  11. package/dist/http/http-rng-client.d.ts.map +1 -0
  12. package/dist/http/http-rng-client.js +44 -0
  13. package/dist/http/http-rng-client.js.map +1 -0
  14. package/dist/http/rest-client.d.ts +30 -0
  15. package/dist/http/rest-client.d.ts.map +1 -0
  16. package/dist/http/rest-client.js +84 -0
  17. package/dist/http/rest-client.js.map +1 -0
  18. package/dist/http/rng-client.interface.d.ts +8 -0
  19. package/dist/http/rng-client.interface.d.ts.map +1 -0
  20. package/dist/http/rng-client.interface.js +3 -0
  21. package/dist/http/rng-client.interface.js.map +1 -0
  22. package/dist/index.d.ts +3 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +7 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/interfaces/client-interfaces.d.ts +4 -0
  27. package/dist/interfaces/client-interfaces.d.ts.map +1 -0
  28. package/dist/interfaces/client-interfaces.js +3 -0
  29. package/dist/interfaces/client-interfaces.js.map +1 -0
  30. package/dist/rng-client.d.ts +58 -0
  31. package/dist/rng-client.d.ts.map +1 -0
  32. package/dist/rng-client.js +89 -0
  33. package/dist/rng-client.js.map +1 -0
  34. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,309 @@
1
+ # RNG Client Core
2
+
3
+ HTTP client library for random number generation with the Omnitronix RNG service.
4
+
5
+ ## Features
6
+
7
+ - **HTTP Communication**: Direct HTTP communication with RNG service
8
+ - **Single & Batch Operations**: Generate single numbers or batches
9
+ - **Float Support**: Dedicated endpoints for float generation
10
+ - **TypeScript Support**: Full type safety and IntelliSense
11
+ - **Error Handling**: Robust error handling with detailed messages
12
+ - **Easy Integration**: Simple configuration with just server URL
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @omnitronix/rng-client-core
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### Basic Usage
23
+
24
+ ```typescript
25
+ import { RngClient } from "@omnitronix/rng-client-core";
26
+
27
+ // Create RNG client instance
28
+ const rngClient = new RngClient({
29
+ serverUrl: "http://localhost:3001",
30
+ });
31
+
32
+ // Get single random integer
33
+ const singleResult = await rngClient.getSingleNumber(1, 100);
34
+ console.log("Random number:", singleResult.result); // e.g., 42
35
+ console.log("Seed used:", singleResult.seed);
36
+ console.log("Generated at:", singleResult.createdAt);
37
+
38
+ // Get single random float
39
+ const floatResult = await rngClient.getSingleFloat();
40
+ console.log("Random float:", floatResult.result); // e.g., 0.75
41
+
42
+ // Get batch of integers
43
+ const batchResult = await rngClient.getBatchNumbers(1, 100, 10);
44
+ console.log("Batch numbers:", batchResult.result); // [42, 15, 78, ...]
45
+
46
+ // Get batch of floats
47
+ const batchFloats = await rngClient.getBatchFloats(5);
48
+ console.log("Batch floats:", batchFloats.result); // [0.75, 0.23, 0.91, ...]
49
+
50
+ // Alternative method names
51
+ const randomNumber = await rngClient.getRandomNumber(1, 100);
52
+ const randomFloat = await rngClient.getRandomFloat();
53
+ ```
54
+
55
+ ### Configuration
56
+
57
+ ```typescript
58
+ import { RngClient, RngClientConfig } from "@omnitronix/rng-client-core";
59
+
60
+ const config: RngClientConfig = {
61
+ serverUrl: "https://rng.example.com:3001", // RNG service URL
62
+ // Optional parameters for future use:
63
+ // bufferSize: 10000,
64
+ // refillThreshold: 0.2,
65
+ // connectionTimeout: 5000,
66
+ // retryAttempts: 3,
67
+ // retryDelay: 1000
68
+ };
69
+
70
+ const rngClient = new RngClient(config);
71
+ ```
72
+
73
+ ### Error Handling
74
+
75
+ ```typescript
76
+ try {
77
+ const result = await rngClient.generateSingle(1, 100);
78
+ console.log("Success:", result.result);
79
+ } catch (error) {
80
+ if (error.message.includes("HTTP error! status: 500")) {
81
+ console.error("RNG service is down");
82
+ } else if (error.message.includes("HTTP error! status: 400")) {
83
+ console.error("Invalid request parameters");
84
+ } else {
85
+ console.error("Unexpected error:", error.message);
86
+ }
87
+ }
88
+ ```
89
+
90
+ ## API Reference
91
+
92
+ ### RngClient
93
+
94
+ Main class for client-side random number generation.
95
+
96
+ #### Constructor
97
+
98
+ ```typescript
99
+ constructor(config: RngClientConfig)
100
+ ```
101
+
102
+ - `config.serverUrl`: RNG service URL (required)
103
+ - `config.bufferSize`: Optional buffer size for future use
104
+ - `config.refillThreshold`: Optional refill threshold for future use
105
+ - `config.connectionTimeout`: Optional connection timeout
106
+ - `config.retryAttempts`: Optional retry attempts
107
+ - `config.retryDelay`: Optional retry delay
108
+
109
+ #### Methods
110
+
111
+ ##### `getSingleNumber(min: number, max: number, seed?: number): Promise<RngSingleResponse>`
112
+
113
+ Get a single random number.
114
+
115
+ - `min`: Minimum value (inclusive)
116
+ - `max`: Maximum value (inclusive)
117
+ - `seed`: Optional seed for deterministic generation
118
+ - **Returns**: Promise with `RngSingleResponse`
119
+
120
+ ##### `getBatchNumbers(min: number, max: number, count: number, seed?: number): Promise<RngBatchResponse>`
121
+
122
+ Get a batch of random numbers.
123
+
124
+ - `min`: Minimum value (inclusive)
125
+ - `max`: Maximum value (inclusive)
126
+ - `count`: Number of values to generate
127
+ - `seed`: Optional seed for deterministic generation
128
+ - **Returns**: Promise with `RngBatchResponse`
129
+
130
+ ##### `getSingleFloat(seed?: number): Promise<RngSingleResponse>`
131
+
132
+ Get a single random float.
133
+
134
+ - `seed`: Optional seed for deterministic generation
135
+ - **Returns**: Promise with `RngSingleResponse`
136
+
137
+ ##### `getBatchFloats(count: number, seed?: number): Promise<RngBatchResponse>`
138
+
139
+ Get a batch of random floats.
140
+
141
+ - `count`: Number of values to generate
142
+ - `seed`: Optional seed for deterministic generation
143
+ - **Returns**: Promise with `RngBatchResponse`
144
+
145
+ ##### `getRandomNumber(min: number, max: number, seed?: number): Promise<RngSingleResponse>`
146
+
147
+ Get a random number.
148
+
149
+ - `min`: Minimum value (inclusive)
150
+ - `max`: Maximum value (inclusive)
151
+ - `seed`: Optional seed for deterministic generation
152
+ - **Returns**: Promise with `RngSingleResponse`
153
+
154
+ ##### `getRandomFloat(seed?: number): Promise<RngSingleResponse>`
155
+
156
+ Get a random float.
157
+
158
+ - `seed`: Optional seed for deterministic generation
159
+ - **Returns**: Promise with `RngSingleResponse`
160
+
161
+ ### Response Types
162
+
163
+ #### RngSingleResponse
164
+
165
+ ```typescript
166
+ interface RngSingleResponse {
167
+ readonly id: string; // Unique identifier
168
+ readonly seed: number; // Seed used for generation
169
+ readonly result: number; // Generated value
170
+ readonly min: number; // Minimum value
171
+ readonly max: number; // Maximum value
172
+ readonly createdAt: string; // Generation timestamp (ISO string)
173
+ readonly sessionId?: string; // Optional session ID
174
+ }
175
+ ```
176
+
177
+ #### RngBatchResponse
178
+
179
+ ```typescript
180
+ interface RngBatchResponse {
181
+ readonly id: string; // Unique identifier
182
+ readonly seed: number; // Seed used for generation
183
+ readonly result: number[]; // Generated values array
184
+ readonly min: number; // Minimum value
185
+ readonly max: number; // Maximum value
186
+ readonly createdAt: string; // Generation timestamp (ISO string)
187
+ readonly sessionId?: string; // Optional session ID
188
+ }
189
+ ```
190
+
191
+ ## Integration Examples
192
+
193
+ ### Express.js Application
194
+
195
+ ```typescript
196
+ import express from "express";
197
+ import { RngClient } from "@omnitronix/rng-client-core";
198
+
199
+ const app = express();
200
+ const rngClient = new RngClient({
201
+ serverUrl: process.env.RNG_SERVER_URL || "http://localhost:3001",
202
+ });
203
+
204
+ app.get("/api/random", async (req, res) => {
205
+ try {
206
+ const result = await rngClient.getSingleNumber(1, 100);
207
+ res.json({ randomNumber: result.result });
208
+ } catch (error) {
209
+ res.status(500).json({ error: "Failed to generate random number" });
210
+ }
211
+ });
212
+
213
+ app.listen(3000);
214
+ ```
215
+
216
+ ### NestJS Service
217
+
218
+ ```typescript
219
+ import { Injectable } from "@nestjs/common";
220
+ import { RngClient } from "@omnitronix/rng-client-core";
221
+
222
+ @Injectable()
223
+ export class GameService {
224
+ private readonly rngClient: RngClient;
225
+
226
+ constructor() {
227
+ this.rngClient = new RngClient({
228
+ serverUrl: process.env.RNG_SERVER_URL,
229
+ });
230
+ }
231
+
232
+ async rollDice(): Promise<number> {
233
+ const result = await this.rngClient.getSingleNumber(1, 6);
234
+ return result.result;
235
+ }
236
+
237
+ async generateLootTable(): Promise<number[]> {
238
+ const result = await this.rngClient.getBatchNumbers(1, 100, 10);
239
+ return result.result;
240
+ }
241
+ }
242
+ ```
243
+
244
+ ### React Hook
245
+
246
+ ```typescript
247
+ import { useState, useCallback } from "react";
248
+ import { RngClient } from "@omnitronix/rng-client-core";
249
+
250
+ export const useRng = (serverUrl: string) => {
251
+ const [rngClient] = useState(() => new RngClient({ serverUrl }));
252
+ const [loading, setLoading] = useState(false);
253
+
254
+ const generateRandom = useCallback(
255
+ async (min: number, max: number) => {
256
+ setLoading(true);
257
+ try {
258
+ const result = await rngClient.getSingleNumber(min, max);
259
+ return result.result;
260
+ } finally {
261
+ setLoading(false);
262
+ }
263
+ },
264
+ [rngClient]
265
+ );
266
+
267
+ return { generateRandom, loading };
268
+ };
269
+ ```
270
+
271
+ ## Environment Configuration
272
+
273
+ ### Development
274
+
275
+ ```env
276
+ RNG_SERVER_URL=http://localhost:3001
277
+ ```
278
+
279
+ ### Production
280
+
281
+ ```env
282
+ RNG_SERVER_URL=https://rng.production.com:3001
283
+ ```
284
+
285
+ ### Docker
286
+
287
+ ```yaml
288
+ version: "3.8"
289
+ services:
290
+ app:
291
+ build: .
292
+ environment:
293
+ - RNG_SERVER_URL=http://rng-service:3001
294
+ depends_on:
295
+ - rng-service
296
+ ```
297
+
298
+ ## Error Handling
299
+
300
+ The client handles various error scenarios:
301
+
302
+ - **Connection Errors**: Network issues, service unavailable
303
+ - **HTTP Errors**: 4xx/5xx status codes with detailed messages
304
+ - **Validation Errors**: Invalid parameters (400 Bad Request)
305
+ - **Server Errors**: Internal server errors (500 Internal Server Error)
306
+
307
+ ## License
308
+
309
+ Proprietary - Omnitronix Internal Use Only
@@ -0,0 +1,13 @@
1
+ import { RngClientConfig } from "../interfaces/client-interfaces";
2
+ import { RngBatchRequest, RngBatchResponse, RngSingleRequest, RngSingleResponse } from "../http/http-client.types";
3
+ export declare class RngClientCore {
4
+ private readonly config;
5
+ private readonly rngClient;
6
+ constructor(config: RngClientConfig);
7
+ getRandomNumber(request: RngSingleRequest): Promise<RngSingleResponse>;
8
+ getRandomFloat(): Promise<RngSingleResponse>;
9
+ getSingleFloat(seed?: number): Promise<RngSingleResponse>;
10
+ getBatchFloats(count: number, seed?: number): Promise<RngBatchResponse>;
11
+ getBatchNumbers(data: RngBatchRequest): Promise<RngBatchResponse>;
12
+ }
13
+ //# sourceMappingURL=rng-client-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng-client-core.d.ts","sourceRoot":"","sources":["../../src/core/rng-client-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;gBAEnC,MAAM,EAAE,eAAe;IAKtB,eAAe,CAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAIhB,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAM5C,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUzD,cAAc,CACzB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IAIf,eAAe,CAC1B,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,gBAAgB,CAAC;CAG7B"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RngClientCore = void 0;
4
+ const http_rng_client_1 = require("../http/http-rng-client");
5
+ class RngClientCore {
6
+ constructor(config) {
7
+ this.config = config;
8
+ this.rngClient = new http_rng_client_1.HttpRngClient(this.config.serverUrl);
9
+ }
10
+ async getRandomNumber(request) {
11
+ return this.rngClient.getSingleNumber(request);
12
+ }
13
+ async getRandomFloat() {
14
+ const response = await this.rngClient.getSingleFloat();
15
+ return response;
16
+ }
17
+ async getSingleFloat(seed) {
18
+ const response = await this.rngClient.getSingleNumber({
19
+ min: 0,
20
+ max: 1,
21
+ seed,
22
+ });
23
+ return response;
24
+ }
25
+ async getBatchFloats(count, seed) {
26
+ return this.rngClient.getBatchFloats(count, seed);
27
+ }
28
+ async getBatchNumbers(data) {
29
+ return this.rngClient.getBatchNumbers(data);
30
+ }
31
+ }
32
+ exports.RngClientCore = RngClientCore;
33
+ //# sourceMappingURL=rng-client-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng-client-core.js","sourceRoot":"","sources":["../../src/core/rng-client-core.ts"],"names":[],"mappings":";;;AAEA,6DAAwD;AAQxD,MAAa,aAAa;IAIxB,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,+BAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAEM,KAAK,CAAC,eAAe,CAC1B,OAAyB;QAEzB,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;QAEvD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAa;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;YACpD,GAAG,EAAE,CAAC;YACN,GAAG,EAAE,CAAC;YACN,IAAI;SACL,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,cAAc,CACzB,KAAa,EACb,IAAa;QAEb,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC1B,IAAqB;QAErB,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF;AA3CD,sCA2CC"}
@@ -0,0 +1,28 @@
1
+ export interface RngSingleRequest {
2
+ min: number;
3
+ max: number;
4
+ seed?: number;
5
+ }
6
+ export interface RngBatchRequest {
7
+ min: number;
8
+ max: number;
9
+ count: number;
10
+ seed?: number;
11
+ }
12
+ export interface RngSingleResponse {
13
+ id: string;
14
+ seed: number;
15
+ result: number;
16
+ min: number;
17
+ max: number;
18
+ createdAt: string;
19
+ }
20
+ export interface RngBatchResponse {
21
+ id: string;
22
+ seed: number;
23
+ result: number[];
24
+ min: number;
25
+ max: number;
26
+ createdAt: string;
27
+ }
28
+ //# sourceMappingURL=http-client.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.types.d.ts","sourceRoot":"","sources":["../../src/http/http-client.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=http-client.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.types.js","sourceRoot":"","sources":["../../src/http/http-client.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { RngClientInterface } from "./rng-client.interface";
2
+ import { RngBatchRequest, RngBatchResponse, RngSingleRequest, RngSingleResponse } from "./http-client.types";
3
+ import { RestClient } from "./rest-client";
4
+ export declare class HttpRngClient extends RestClient implements RngClientInterface {
5
+ constructor(baseUrl: string);
6
+ getSingleNumber(request: RngSingleRequest): Promise<RngSingleResponse>;
7
+ getBatchNumbers(request: RngBatchRequest): Promise<RngBatchResponse>;
8
+ getSingleFloat(seed?: number): Promise<RngSingleResponse>;
9
+ getBatchFloats(count: number, seed?: number): Promise<RngBatchResponse>;
10
+ }
11
+ //# sourceMappingURL=http-rng-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-rng-client.d.ts","sourceRoot":"","sources":["../../src/http/http-rng-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBAAa,aAAc,SAAQ,UAAW,YAAW,kBAAkB;gBAC7D,OAAO,EAAE,MAAM;IAIrB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAetE,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAepE,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAczD,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;CAc7B"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpRngClient = void 0;
4
+ const rest_client_1 = require("./rest-client");
5
+ class HttpRngClient extends rest_client_1.RestClient {
6
+ constructor(baseUrl) {
7
+ super(baseUrl);
8
+ }
9
+ async getSingleNumber(request) {
10
+ const response = await this.post("/api/rng/single", request);
11
+ if (!response.success) {
12
+ throw new Error(`HTTP error! status: ${response.statusCode}, message: ${response.message}`);
13
+ }
14
+ return response.data;
15
+ }
16
+ async getBatchNumbers(request) {
17
+ const response = await this.post("/api/rng/batch", request);
18
+ if (!response.success) {
19
+ throw new Error(`HTTP error! status: ${response.statusCode}, message: ${response.message}`);
20
+ }
21
+ return response.data;
22
+ }
23
+ async getSingleFloat(seed) {
24
+ const response = await this.post("/api/rng/float", {
25
+ seed,
26
+ });
27
+ if (!response.success) {
28
+ throw new Error(`HTTP error! status: ${response.statusCode}, message: ${response.message}`);
29
+ }
30
+ return response.data;
31
+ }
32
+ async getBatchFloats(count, seed) {
33
+ const response = await this.post("/api/rng/batch/float", {
34
+ count,
35
+ seed,
36
+ });
37
+ if (!response.success) {
38
+ throw new Error(`HTTP error! status: ${response.statusCode}, message: ${response.message}`);
39
+ }
40
+ return response.data;
41
+ }
42
+ }
43
+ exports.HttpRngClient = HttpRngClient;
44
+ //# sourceMappingURL=http-rng-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-rng-client.js","sourceRoot":"","sources":["../../src/http/http-rng-client.ts"],"names":[],"mappings":";;;AAOA,+CAA2C;AAE3C,MAAa,aAAc,SAAQ,wBAAU;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAyB;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAC9B,iBAAiB,EACjB,OAAO,CACR,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,CAAC,UAAU,cAAc,QAAQ,CAAC,OAAO,EAAE,CAC3E,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAwB;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAC9B,gBAAgB,EAChB,OAAO,CACR,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,CAAC,UAAU,cAAc,QAAQ,CAAC,OAAO,EAAE,CAC3E,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAa;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAoB,gBAAgB,EAAE;YACpE,IAAI;SACL,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,CAAC,UAAU,cAAc,QAAQ,CAAC,OAAO,EAAE,CAC3E,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,KAAa,EACb,IAAa;QAEb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAmB,sBAAsB,EAAE;YACzE,KAAK;YACL,IAAI;SACL,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,CAAC,UAAU,cAAc,QAAQ,CAAC,OAAO,EAAE,CAC3E,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAlED,sCAkEC"}
@@ -0,0 +1,30 @@
1
+ export interface ApiErrorData {
2
+ internalCode?: number;
3
+ message?: string;
4
+ }
5
+ export interface ApiSuccessResponse<T> {
6
+ success: true;
7
+ data: T;
8
+ }
9
+ export interface ApiErrorResponse<E = null> {
10
+ success: false;
11
+ error: string;
12
+ message: string;
13
+ statusCode: number;
14
+ internalCode?: number;
15
+ data?: E;
16
+ }
17
+ export type ApiResponse<T, E = null> = ApiSuccessResponse<T> | ApiErrorResponse<E>;
18
+ export declare class RestClient {
19
+ private httpClient;
20
+ constructor(baseUrl: string);
21
+ private isApiErrorData;
22
+ private mapSuccessResponse;
23
+ private mapErrorResponse;
24
+ private handleRequest;
25
+ get<T, E = null>(url: string, params?: object): Promise<ApiResponse<T, E>>;
26
+ post<T, E = null>(url: string, data?: object): Promise<ApiResponse<T, E>>;
27
+ put<T, E = null>(url: string, data?: object): Promise<ApiResponse<T, E>>;
28
+ delete<T, E = null>(url: string): Promise<ApiResponse<T, E>>;
29
+ }
30
+ //# sourceMappingURL=rest-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-client.d.ts","sourceRoot":"","sources":["../../src/http/rest-client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,IAAI;IACxC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,CAAC,CAAC;CACV;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,IAC/B,kBAAkB,CAAC,CAAC,CAAC,GACrB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAExB,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAgB;gBAEtB,OAAO,EAAE,MAAM;IAU3B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,gBAAgB;YAwCV,aAAa;IAWd,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAC1B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAIhB,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAC3B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAIhB,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAC1B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAIhB,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAG1E"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RestClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class RestClient {
9
+ constructor(baseUrl) {
10
+ this.httpClient = axios_1.default.create({
11
+ baseURL: baseUrl,
12
+ timeout: 5000,
13
+ headers: {
14
+ "Content-Type": "application/json",
15
+ },
16
+ });
17
+ }
18
+ isApiErrorData(data) {
19
+ return data && typeof data === "object" && "internalCode" in data;
20
+ }
21
+ mapSuccessResponse(data) {
22
+ return { success: true, data };
23
+ }
24
+ mapErrorResponse(error) {
25
+ if (axios_1.default.isAxiosError(error)) {
26
+ const axiosError = error;
27
+ const status = axiosError.response?.status || 500;
28
+ const data = axiosError.response?.data ?? {};
29
+ if (this.isApiErrorData(data)) {
30
+ return {
31
+ success: false,
32
+ error: "ApiError",
33
+ message: data.message ?? "An unexpected error occurred.",
34
+ statusCode: status,
35
+ internalCode: data.internalCode,
36
+ data: data,
37
+ };
38
+ }
39
+ return {
40
+ success: false,
41
+ error: "UnknownError",
42
+ message: "An unexpected error occurred.",
43
+ statusCode: status,
44
+ };
45
+ }
46
+ else if (error instanceof Error) {
47
+ return {
48
+ success: false,
49
+ error: "UnexpectedError",
50
+ message: error.message || "An unknown error occurred.",
51
+ statusCode: 500,
52
+ };
53
+ }
54
+ return {
55
+ success: false,
56
+ error: "UnknownError",
57
+ message: "An unknown error occurred.",
58
+ statusCode: 500,
59
+ };
60
+ }
61
+ async handleRequest(request) {
62
+ try {
63
+ const response = await request;
64
+ return this.mapSuccessResponse(response.data);
65
+ }
66
+ catch (error) {
67
+ return this.mapErrorResponse(error);
68
+ }
69
+ }
70
+ async get(url, params) {
71
+ return this.handleRequest(this.httpClient.get(url, { params }));
72
+ }
73
+ async post(url, data) {
74
+ return this.handleRequest(this.httpClient.post(url, data));
75
+ }
76
+ async put(url, data) {
77
+ return this.handleRequest(this.httpClient.put(url, data));
78
+ }
79
+ async delete(url) {
80
+ return this.handleRequest(this.httpClient.delete(url));
81
+ }
82
+ }
83
+ exports.RestClient = RestClient;
84
+ //# sourceMappingURL=rest-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-client.js","sourceRoot":"","sources":["../../src/http/rest-client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ import { RngBatchRequest, RngBatchResponse, RngSingleRequest, RngSingleResponse } from "./http-client.types";
2
+ export interface RngClientInterface {
3
+ getSingleNumber(request: RngSingleRequest): Promise<RngSingleResponse>;
4
+ getBatchNumbers(request: RngBatchRequest): Promise<RngBatchResponse>;
5
+ getSingleFloat(seed?: number): Promise<RngSingleResponse>;
6
+ getBatchFloats(count: number, seed?: number): Promise<RngBatchResponse>;
7
+ }
8
+ //# sourceMappingURL=rng-client.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng-client.interface.d.ts","sourceRoot":"","sources":["../../src/http/rng-client.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvE,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACrE,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1D,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=rng-client.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng-client.interface.js","sourceRoot":"","sources":["../../src/http/rng-client.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { RngClient } from "./rng-client";
2
+ export type { RngClientConfig } from "./interfaces/client-interfaces";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RngClient = void 0;
4
+ // Main API
5
+ var rng_client_1 = require("./rng-client");
6
+ Object.defineProperty(exports, "RngClient", { enumerable: true, get: function () { return rng_client_1.RngClient; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,2CAAyC;AAAhC,uGAAA,SAAS,OAAA"}
@@ -0,0 +1,4 @@
1
+ export interface RngClientConfig {
2
+ readonly serverUrl: string;
3
+ }
4
+ //# sourceMappingURL=client-interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces/client-interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=client-interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/client-interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ import { RngClientConfig } from "./interfaces/client-interfaces";
2
+ import { RngSingleResponse, RngBatchResponse } from "./http/http-client.types";
3
+ /**
4
+ * RNG Client - High-level API for client-side random number generation
5
+ *
6
+ * This is the main entry point for client-side RNG operations.
7
+ * It provides a simple interface for generating random numbers
8
+ * via HTTP communication with the RNG service.
9
+ */
10
+ export declare class RngClient {
11
+ private readonly clientCore;
12
+ constructor(config: RngClientConfig);
13
+ /**
14
+ * Get a single random number
15
+ * @param min Minimum value (inclusive)
16
+ * @param max Maximum value (inclusive)
17
+ * @param seed Optional seed for deterministic generation
18
+ * @returns Random integer result
19
+ */
20
+ getSingleNumber(min: number, max: number, seed?: number): Promise<number>;
21
+ /**
22
+ * Get a batch of random numbers
23
+ * @param min Minimum value (inclusive)
24
+ * @param max Maximum value (inclusive)
25
+ * @param count Number of values to generate
26
+ * @param seed Optional seed for deterministic generation
27
+ * @returns Batch of random integers
28
+ */
29
+ getBatchNumbers(min: number, max: number, count: number, seed?: number): Promise<number[]>;
30
+ /**
31
+ * Get a single random float
32
+ * @param seed Optional seed for deterministic generation
33
+ * @returns Random float result
34
+ */
35
+ getSingleFloat(seed?: number): Promise<RngSingleResponse>;
36
+ /**
37
+ * Get a batch of random floats
38
+ * @param count Number of values to generate
39
+ * @param seed Optional seed for deterministic generation
40
+ * @returns Batch of random floats
41
+ */
42
+ getBatchFloats(count: number, seed?: number): Promise<RngBatchResponse>;
43
+ /**
44
+ * Get a random number
45
+ * @param min Minimum value (inclusive)
46
+ * @param max Maximum value (inclusive)
47
+ * @param seed Optional seed for deterministic generation
48
+ * @returns Random integer result
49
+ */
50
+ getRandomNumber(min: number, max: number, seed?: number): Promise<RngSingleResponse>;
51
+ /**
52
+ * Get a random float
53
+ * @param seed Optional seed for deterministic generation
54
+ * @returns Random float result
55
+ */
56
+ getRandomFloat(seed?: number): Promise<RngSingleResponse>;
57
+ }
58
+ //# sourceMappingURL=rng-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng-client.d.ts","sourceRoot":"","sources":["../src/rng-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE/E;;;;;;GAMG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;gBAE/B,MAAM,EAAE,eAAe;IAInC;;;;;;OAMG;IACG,eAAe,CACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC;IAUlB;;;;;;;OAOG;IACG,eAAe,CACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC;IAWpB;;;;OAIG;IACG,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI/D;;;;;OAKG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;;;;OAMG;IACG,eAAe,CACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,iBAAiB,CAAC;IAQ7B;;;;OAIG;IACG,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAGhE"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RngClient = void 0;
4
+ const rng_client_core_1 = require("./core/rng-client-core");
5
+ /**
6
+ * RNG Client - High-level API for client-side random number generation
7
+ *
8
+ * This is the main entry point for client-side RNG operations.
9
+ * It provides a simple interface for generating random numbers
10
+ * via HTTP communication with the RNG service.
11
+ */
12
+ class RngClient {
13
+ constructor(config) {
14
+ this.clientCore = new rng_client_core_1.RngClientCore(config);
15
+ }
16
+ /**
17
+ * Get a single random number
18
+ * @param min Minimum value (inclusive)
19
+ * @param max Maximum value (inclusive)
20
+ * @param seed Optional seed for deterministic generation
21
+ * @returns Random integer result
22
+ */
23
+ async getSingleNumber(min, max, seed) {
24
+ const response = await this.clientCore.getRandomNumber({
25
+ min,
26
+ max,
27
+ seed,
28
+ });
29
+ return response.result;
30
+ }
31
+ /**
32
+ * Get a batch of random numbers
33
+ * @param min Minimum value (inclusive)
34
+ * @param max Maximum value (inclusive)
35
+ * @param count Number of values to generate
36
+ * @param seed Optional seed for deterministic generation
37
+ * @returns Batch of random integers
38
+ */
39
+ async getBatchNumbers(min, max, count, seed) {
40
+ const response = await this.clientCore.getBatchNumbers({
41
+ min,
42
+ max,
43
+ count,
44
+ seed,
45
+ });
46
+ return response.result;
47
+ }
48
+ /**
49
+ * Get a single random float
50
+ * @param seed Optional seed for deterministic generation
51
+ * @returns Random float result
52
+ */
53
+ async getSingleFloat(seed) {
54
+ return this.clientCore.getSingleFloat(seed);
55
+ }
56
+ /**
57
+ * Get a batch of random floats
58
+ * @param count Number of values to generate
59
+ * @param seed Optional seed for deterministic generation
60
+ * @returns Batch of random floats
61
+ */
62
+ async getBatchFloats(count, seed) {
63
+ return this.clientCore.getBatchFloats(count, seed);
64
+ }
65
+ /**
66
+ * Get a random number
67
+ * @param min Minimum value (inclusive)
68
+ * @param max Maximum value (inclusive)
69
+ * @param seed Optional seed for deterministic generation
70
+ * @returns Random integer result
71
+ */
72
+ async getRandomNumber(min, max, seed) {
73
+ return this.clientCore.getRandomNumber({
74
+ min,
75
+ max,
76
+ seed,
77
+ });
78
+ }
79
+ /**
80
+ * Get a random float
81
+ * @param seed Optional seed for deterministic generation
82
+ * @returns Random float result
83
+ */
84
+ async getRandomFloat(seed) {
85
+ return this.clientCore.getRandomFloat();
86
+ }
87
+ }
88
+ exports.RngClient = RngClient;
89
+ //# sourceMappingURL=rng-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng-client.js","sourceRoot":"","sources":["../src/rng-client.ts"],"names":[],"mappings":";;;AAAA,4DAAuD;AAIvD;;;;;;GAMG;AACH,MAAa,SAAS;IAGpB,YAAY,MAAuB;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,+BAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CACnB,GAAW,EACX,GAAW,EACX,IAAa;QAEb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;YACrD,GAAG;YACH,GAAG;YACH,IAAI;SACL,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CACnB,GAAW,EACX,GAAW,EACX,KAAa,EACb,IAAa;QAEb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;YACrD,GAAG;YACH,GAAG;YACH,KAAK;YACL,IAAI;SACL,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,IAAa;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAClB,KAAa,EACb,IAAa;QAEb,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CACnB,GAAW,EACX,GAAW,EACX,IAAa;QAEb,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;YACrC,GAAG;YACH,GAAG;YACH,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,IAAa;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;CACF;AArGD,8BAqGC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@omnitronix/rng-client-core",
3
+ "version": "1.0.0",
4
+ "description": "Simple HTTP client for random number generation",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "dev": "tsc --watch",
10
+ "clean": "rm -rf dist",
11
+ "lint": "eslint src/**/*.ts",
12
+ "lint:fix": "eslint src/**/*.ts --fix",
13
+ "test": "jest",
14
+ "test:watch": "jest --watch",
15
+ "test:coverage": "jest --coverage",
16
+ "prepublishOnly": "npm run clean && npm run build"
17
+ },
18
+ "keywords": [
19
+ "rng",
20
+ "random",
21
+ "gaming",
22
+ "client",
23
+ "http",
24
+ "performance"
25
+ ],
26
+ "author": "Omnitronix",
27
+ "license": "UNLICENSED",
28
+ "dependencies": {
29
+ "axios": "^1.12.2"
30
+ },
31
+ "devDependencies": {
32
+ "@types/jest": "^29.5.0",
33
+ "@types/node": "^20.0.0",
34
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
35
+ "@typescript-eslint/parser": "^6.0.0",
36
+ "eslint": "^8.0.0",
37
+ "jest": "^29.5.0",
38
+ "ts-jest": "^29.1.0",
39
+ "typescript": "^5.0.0"
40
+ },
41
+ "files": [
42
+ "dist/**/*",
43
+ "README.md"
44
+ ],
45
+ "publishConfig": {
46
+ "registry": "https://registry.npmjs.org/"
47
+ }
48
+ }