rayforce-wasm 0.1.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.
@@ -0,0 +1,493 @@
1
+ /**
2
+ * RayforceDB JavaScript SDK Type Definitions
3
+ * @module rayforce
4
+ */
5
+
6
+ // ============================================================================
7
+ // Type Constants
8
+ // ============================================================================
9
+
10
+ export declare const Types: {
11
+ readonly LIST: 0;
12
+ readonly B8: 1;
13
+ readonly U8: 2;
14
+ readonly I16: 3;
15
+ readonly I32: 4;
16
+ readonly I64: 5;
17
+ readonly SYMBOL: 6;
18
+ readonly DATE: 7;
19
+ readonly TIME: 8;
20
+ readonly TIMESTAMP: 9;
21
+ readonly F64: 10;
22
+ readonly GUID: 11;
23
+ readonly C8: 12;
24
+ readonly TABLE: 98;
25
+ readonly DICT: 99;
26
+ readonly LAMBDA: 100;
27
+ readonly NULL: 126;
28
+ readonly ERR: 127;
29
+ };
30
+
31
+ export type TypeCode = typeof Types[keyof typeof Types];
32
+
33
+ // ============================================================================
34
+ // Base Classes
35
+ // ============================================================================
36
+
37
+ /**
38
+ * Base class for all Rayforce objects
39
+ */
40
+ export declare class RayObject {
41
+ /** Raw WASM pointer */
42
+ readonly ptr: number;
43
+
44
+ /** Type code (negative for atoms, positive for vectors) */
45
+ readonly type: number;
46
+
47
+ /** Absolute type code */
48
+ readonly absType: number;
49
+
50
+ /** True if this is an atom (scalar) */
51
+ readonly isAtom: boolean;
52
+
53
+ /** True if this is a vector */
54
+ readonly isVector: boolean;
55
+
56
+ /** True if this is null */
57
+ readonly isNull: boolean;
58
+
59
+ /** True if this is an error */
60
+ readonly isError: boolean;
61
+
62
+ /** Length (1 for atoms) */
63
+ readonly length: number;
64
+
65
+ /** Reference count */
66
+ readonly refCount: number;
67
+
68
+ /** Clone this object */
69
+ clone(): RayObject;
70
+
71
+ /** Format to string */
72
+ toString(): string;
73
+
74
+ /** Convert to JavaScript value */
75
+ toJS(): any;
76
+
77
+ /** Free this object's memory */
78
+ drop(): void;
79
+
80
+ /** Release ownership (don't drop on GC) */
81
+ release(): number;
82
+ }
83
+
84
+ // ============================================================================
85
+ // Scalar Types
86
+ // ============================================================================
87
+
88
+ export declare class B8 extends RayObject {
89
+ readonly value: boolean;
90
+ toJS(): boolean;
91
+ }
92
+
93
+ export declare class U8 extends RayObject {
94
+ readonly value: number;
95
+ toJS(): number;
96
+ }
97
+
98
+ export declare class C8 extends RayObject {
99
+ readonly value: string;
100
+ toJS(): string;
101
+ }
102
+
103
+ export declare class I16 extends RayObject {
104
+ readonly value: number;
105
+ toJS(): number;
106
+ }
107
+
108
+ export declare class I32 extends RayObject {
109
+ readonly value: number;
110
+ toJS(): number;
111
+ }
112
+
113
+ export declare class I64 extends RayObject {
114
+ readonly value: number;
115
+ toJS(): number;
116
+ }
117
+
118
+ export declare class F64 extends RayObject {
119
+ readonly value: number;
120
+ toJS(): number;
121
+ }
122
+
123
+ export declare class RayDate extends RayObject {
124
+ /** Days since 2000-01-01 */
125
+ readonly value: number;
126
+ toJS(): Date;
127
+ }
128
+
129
+ export declare class RayTime extends RayObject {
130
+ /** Milliseconds since midnight */
131
+ readonly value: number;
132
+ toJS(): { hours: number; minutes: number; seconds: number; milliseconds: number };
133
+ }
134
+
135
+ export declare class RayTimestamp extends RayObject {
136
+ /** Nanoseconds since 2000-01-01 */
137
+ readonly value: number;
138
+ toJS(): Date;
139
+ }
140
+
141
+ export declare class Symbol extends RayObject {
142
+ /** Interned symbol ID */
143
+ readonly id: number;
144
+ /** String value */
145
+ readonly value: string;
146
+ toJS(): string;
147
+ }
148
+
149
+ export declare class GUID extends RayObject {
150
+ toJS(): string;
151
+ }
152
+
153
+ export declare class RayNull extends RayObject {
154
+ toJS(): null;
155
+ }
156
+
157
+ export declare class RayError extends RayObject {
158
+ readonly message: string;
159
+ toJS(): never;
160
+ }
161
+
162
+ // ============================================================================
163
+ // Container Types
164
+ // ============================================================================
165
+
166
+ /**
167
+ * Vector with zero-copy TypedArray access
168
+ */
169
+ export declare class Vector<T extends TypedArray = TypedArray> extends RayObject {
170
+ /** Element type code */
171
+ readonly elementType: number;
172
+
173
+ /**
174
+ * Zero-copy TypedArray view over the vector data.
175
+ * WARNING: This view is only valid while the Vector exists.
176
+ */
177
+ readonly typedArray: T;
178
+
179
+ /** Get element at index */
180
+ at(idx: number): T extends BigInt64Array ? bigint : number;
181
+
182
+ /** Set element at index */
183
+ set(idx: number, value: T extends BigInt64Array ? bigint : number): void;
184
+
185
+ /** Convert to JS array (copies data) */
186
+ toJS(): Array<T extends BigInt64Array ? number | bigint : number>;
187
+
188
+ [Symbol.iterator](): Iterator<T extends BigInt64Array ? bigint : number>;
189
+ }
190
+
191
+ /**
192
+ * String (character vector)
193
+ */
194
+ export declare class RayString extends Vector<Uint8Array> {
195
+ readonly value: string;
196
+ toJS(): string;
197
+ }
198
+
199
+ /**
200
+ * List (mixed-type container)
201
+ */
202
+ export declare class List extends RayObject {
203
+ /** Get element at index */
204
+ at(idx: number): RayObject;
205
+
206
+ /** Set element at index */
207
+ set(idx: number, value: RayObject | any): void;
208
+
209
+ /** Push element to end */
210
+ push(value: RayObject | any): void;
211
+
212
+ /** Convert to JS array */
213
+ toJS(): any[];
214
+
215
+ [Symbol.iterator](): Iterator<RayObject>;
216
+ }
217
+
218
+ /**
219
+ * Dict (key-value mapping)
220
+ */
221
+ export declare class Dict extends RayObject {
222
+ /** Get keys as symbol vector */
223
+ keys(): Vector<BigInt64Array>;
224
+
225
+ /** Get values as list */
226
+ values(): List;
227
+
228
+ /** Get value by key */
229
+ get(key: string | Symbol): RayObject;
230
+
231
+ /** Check if key exists */
232
+ has(key: string): boolean;
233
+
234
+ /** Convert to JS object */
235
+ toJS(): Record<string, any>;
236
+
237
+ [Symbol.iterator](): Iterator<[string, RayObject]>;
238
+ }
239
+
240
+ /**
241
+ * Table
242
+ */
243
+ export declare class Table extends RayObject {
244
+ /** Get column names vector */
245
+ columns(): Vector<BigInt64Array>;
246
+
247
+ /** Get column names as string array */
248
+ columnNames(): string[];
249
+
250
+ /** Get all values as list of vectors */
251
+ values(): List;
252
+
253
+ /** Get column by name */
254
+ col(name: string): Vector;
255
+
256
+ /** Get row by index */
257
+ row(idx: number): Dict;
258
+
259
+ /** Row count */
260
+ readonly rowCount: number;
261
+
262
+ /** Create select query */
263
+ select(...cols: string[]): SelectQuery;
264
+
265
+ /** Create where clause */
266
+ where(condition: Expr): SelectQuery;
267
+
268
+ /** Insert data */
269
+ insert(data: Record<string, any> | any[]): Table;
270
+
271
+ /** Convert to column object */
272
+ toJS(): Record<string, any[]>;
273
+
274
+ /** Convert to array of row objects */
275
+ toRows(): Record<string, any>[];
276
+ }
277
+
278
+ /**
279
+ * Lambda (function)
280
+ */
281
+ export declare class Lambda extends RayObject {
282
+ /** Call the lambda with arguments */
283
+ call(...args: any[]): RayObject;
284
+ }
285
+
286
+ // ============================================================================
287
+ // Expression Builder
288
+ // ============================================================================
289
+
290
+ /**
291
+ * Expression builder for query conditions
292
+ */
293
+ export declare class Expr {
294
+ /** Create a column reference */
295
+ static col(sdk: RayforceSDK, name: string): Expr;
296
+
297
+ // Comparisons
298
+ eq(value: any): Expr;
299
+ ne(value: any): Expr;
300
+ lt(value: any): Expr;
301
+ le(value: any): Expr;
302
+ gt(value: any): Expr;
303
+ ge(value: any): Expr;
304
+
305
+ // Logical
306
+ and(other: Expr): Expr;
307
+ or(other: Expr): Expr;
308
+ not(): Expr;
309
+
310
+ // Aggregations
311
+ sum(): Expr;
312
+ avg(): Expr;
313
+ min(): Expr;
314
+ max(): Expr;
315
+ count(): Expr;
316
+ first(): Expr;
317
+ last(): Expr;
318
+ distinct(): Expr;
319
+
320
+ toString(): string;
321
+ }
322
+
323
+ /**
324
+ * SELECT query builder
325
+ */
326
+ export declare class SelectQuery {
327
+ /** Specify columns to select */
328
+ select(...cols: string[]): SelectQuery;
329
+
330
+ /** Add computed column */
331
+ withColumn(name: string, expr: Expr): SelectQuery;
332
+
333
+ /** Add WHERE condition */
334
+ where(condition: Expr): SelectQuery;
335
+
336
+ /** Add GROUP BY columns */
337
+ groupBy(...cols: string[]): SelectQuery;
338
+
339
+ /** Column reference helper */
340
+ col(name: string): Expr;
341
+
342
+ /** Execute the query */
343
+ execute(): Table;
344
+ }
345
+
346
+ // ============================================================================
347
+ // SDK Class
348
+ // ============================================================================
349
+
350
+ type TypedArray =
351
+ | Int8Array
352
+ | Uint8Array
353
+ | Int16Array
354
+ | Int32Array
355
+ | BigInt64Array
356
+ | Float64Array;
357
+
358
+ /**
359
+ * Main RayforceDB SDK class
360
+ */
361
+ export declare class RayforceSDK {
362
+ constructor(wasmModule: any);
363
+
364
+ /** RayforceDB version string */
365
+ readonly version: string;
366
+
367
+ // ==========================================================================
368
+ // Core Methods
369
+ // ==========================================================================
370
+
371
+ /**
372
+ * Evaluate a Rayfall expression
373
+ * @param code - The expression to evaluate
374
+ * @param sourceName - Optional source name for error tracking
375
+ */
376
+ eval(code: string, sourceName?: string): RayObject;
377
+
378
+ /**
379
+ * Format any RayObject to string
380
+ */
381
+ format(obj: RayObject | number): string;
382
+
383
+ // ==========================================================================
384
+ // Constructors
385
+ // ==========================================================================
386
+
387
+ /** Create a boolean value */
388
+ b8(value: boolean): B8;
389
+
390
+ /** Create an unsigned byte value */
391
+ u8(value: number): U8;
392
+
393
+ /** Create a character value */
394
+ c8(value: string): C8;
395
+
396
+ /** Create a 16-bit integer */
397
+ i16(value: number): I16;
398
+
399
+ /** Create a 32-bit integer */
400
+ i32(value: number): I32;
401
+
402
+ /** Create a 64-bit integer */
403
+ i64(value: number | bigint): I64;
404
+
405
+ /** Create a 64-bit float */
406
+ f64(value: number): F64;
407
+
408
+ /** Create a date */
409
+ date(value: number | Date): RayDate;
410
+
411
+ /** Create a time */
412
+ time(value: number | Date): RayTime;
413
+
414
+ /** Create a timestamp */
415
+ timestamp(value: number | bigint | Date): RayTimestamp;
416
+
417
+ /** Create a symbol (interned string) */
418
+ symbol(value: string): Symbol;
419
+
420
+ /** Create a string */
421
+ string(value: string): RayString;
422
+
423
+ /**
424
+ * Create a vector of specified type
425
+ * @param type - Type code from Types
426
+ * @param lengthOrData - Length or array of values
427
+ */
428
+ vector<T extends TypeCode>(type: T, lengthOrData: number | any[]): Vector;
429
+
430
+ /**
431
+ * Create a list (mixed-type container)
432
+ * @param items - Optional array of items
433
+ */
434
+ list(items?: any[]): List;
435
+
436
+ /**
437
+ * Create a dict (key-value mapping)
438
+ * @param obj - JS object to convert
439
+ */
440
+ dict(obj: Record<string, any>): Dict;
441
+
442
+ /**
443
+ * Create a table from column definitions
444
+ * @param columns - Object with column names as keys and arrays as values
445
+ */
446
+ table(columns: Record<string, any[]>): Table;
447
+
448
+ // ==========================================================================
449
+ // Utility Methods
450
+ // ==========================================================================
451
+
452
+ /**
453
+ * Set a global variable
454
+ */
455
+ set(name: string, value: RayObject | any): void;
456
+
457
+ /**
458
+ * Get a global variable
459
+ */
460
+ get(name: string): RayObject;
461
+
462
+ /**
463
+ * Get type name string
464
+ */
465
+ typeName(typeCode: number): string;
466
+
467
+ /**
468
+ * Create column expression
469
+ */
470
+ col(name: string): Expr;
471
+ }
472
+
473
+ // ============================================================================
474
+ // Factory Function
475
+ // ============================================================================
476
+
477
+ /**
478
+ * Creates a new RayforceDB SDK instance
479
+ * @param wasmModule - The initialized Emscripten WASM module
480
+ */
481
+ export declare function createRayforceSDK(wasmModule: any): RayforceSDK;
482
+
483
+ // ============================================================================
484
+ // Default Export
485
+ // ============================================================================
486
+
487
+ declare const _default: {
488
+ createRayforceSDK: typeof createRayforceSDK;
489
+ Types: typeof Types;
490
+ Expr: typeof Expr;
491
+ };
492
+
493
+ export default _default;