@truto/ginger 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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +597 -0
  3. package/dist/adapters/bun-sqlite.d.ts +37 -0
  4. package/dist/adapters/bun-sqlite.d.ts.map +1 -0
  5. package/dist/adapters/bun-sqlite.js +136 -0
  6. package/dist/adapters/bun-sqlite.js.map +1 -0
  7. package/dist/adapters/durable-object.d.ts +40 -0
  8. package/dist/adapters/durable-object.d.ts.map +1 -0
  9. package/dist/adapters/durable-object.js +142 -0
  10. package/dist/adapters/durable-object.js.map +1 -0
  11. package/dist/adapters/index.d.ts +5 -0
  12. package/dist/adapters/index.d.ts.map +1 -0
  13. package/dist/adapters/index.js +3 -0
  14. package/dist/adapters/index.js.map +1 -0
  15. package/dist/crypto.d.ts +40 -0
  16. package/dist/crypto.d.ts.map +1 -0
  17. package/dist/crypto.js +148 -0
  18. package/dist/crypto.js.map +1 -0
  19. package/dist/errors.d.ts +64 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +90 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/example.d.ts +119 -0
  24. package/dist/example.d.ts.map +1 -0
  25. package/dist/example.js +297 -0
  26. package/dist/example.js.map +1 -0
  27. package/dist/index.d.ts +54 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +62 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/pagination.d.ts +31 -0
  32. package/dist/pagination.d.ts.map +1 -0
  33. package/dist/pagination.js +173 -0
  34. package/dist/pagination.js.map +1 -0
  35. package/dist/service.d.ts +81 -0
  36. package/dist/service.d.ts.map +1 -0
  37. package/dist/service.js +615 -0
  38. package/dist/service.js.map +1 -0
  39. package/dist/sql-builder.d.ts +48 -0
  40. package/dist/sql-builder.d.ts.map +1 -0
  41. package/dist/sql-builder.js +230 -0
  42. package/dist/sql-builder.js.map +1 -0
  43. package/dist/types.d.ts +266 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +2 -0
  46. package/dist/types.js.map +1 -0
  47. package/package.json +94 -0
@@ -0,0 +1,615 @@
1
+ import { sql } from '@truto/sqlite-builder';
2
+ import { decryptSecrets, DefaultKeyProvider, encryptSecrets } from './crypto.js';
3
+ import { DatabaseError, HookError, NotFoundError, ValidationError, } from './errors.js';
4
+ import { buildCursorConditions, createCursor, decodeCursor, encodeCursor, getDefaultOrderBy, reverseOrderBy, validateOrderBy, } from './pagination.js';
5
+ import { buildCount, buildDelete, buildInsert, buildSelect, buildSelectById, buildUpdate, } from './sql-builder.js';
6
+ /**
7
+ * Main service class that provides type-safe data access for SQLite databases
8
+ */
9
+ export class Service {
10
+ table;
11
+ db;
12
+ rowSchema;
13
+ createSchema;
14
+ updateSchema;
15
+ joins;
16
+ secrets;
17
+ primaryKey;
18
+ defaultOrderBy;
19
+ keyProvider;
20
+ deps;
21
+ hooks;
22
+ constructor(options) {
23
+ this.table = options.table;
24
+ this.db = options.db;
25
+ this.rowSchema = options.rowSchema;
26
+ this.createSchema = options.createSchema;
27
+ this.updateSchema = options.updateSchema;
28
+ this.joins = options.joins;
29
+ this.secrets = options.secrets;
30
+ this.hooks = options.hooks || {};
31
+ this.deps = options.deps || {};
32
+ this.primaryKey = options.primaryKey || 'id';
33
+ this.defaultOrderBy = options.defaultOrderBy;
34
+ this.keyProvider =
35
+ options.keyProvider ||
36
+ new DefaultKeyProvider(options.encryptionKeys || {});
37
+ }
38
+ /**
39
+ * List records with cursor-based pagination
40
+ */
41
+ async list(params = { auth: {} }) {
42
+ const ctx = {
43
+ auth: params.auth,
44
+ db: this.db,
45
+ deps: this.deps,
46
+ method: 'list',
47
+ params,
48
+ };
49
+ try {
50
+ await this.runHooks('before', 'list', ctx);
51
+ const { cursor, limit = 50, orderBy: paramOrderBy, where = {}, include = {}, includeSecrets = false, } = params;
52
+ // Validate limit
53
+ if (limit > 1000) {
54
+ throw new ValidationError('Limit cannot exceed 1000');
55
+ }
56
+ // Determine order by
57
+ let orderBy = paramOrderBy || getDefaultOrderBy(this.primaryKey, this.defaultOrderBy);
58
+ // Validate order by columns
59
+ const allowedColumns = this.getAllowedColumns();
60
+ validateOrderBy(orderBy, allowedColumns);
61
+ // Handle cursor pagination
62
+ let cursorConditions;
63
+ let actualLimit = limit + 1; // Fetch one extra to determine if there's a next page
64
+ if (cursor) {
65
+ try {
66
+ const cursorToken = decodeCursor(cursor);
67
+ // Use cursor's orderBy if present
68
+ if (cursorToken.orderBy.length > 0) {
69
+ orderBy =
70
+ cursorToken.direction === 'prev'
71
+ ? reverseOrderBy(cursorToken.orderBy)
72
+ : cursorToken.orderBy;
73
+ }
74
+ cursorConditions = buildCursorConditions(cursorToken, this.table);
75
+ }
76
+ catch (error) {
77
+ throw new ValidationError(`Invalid cursor: ${error instanceof Error ? error.message : 'Unknown error'}`);
78
+ }
79
+ }
80
+ // Get columns to select (excluding secret columns if not requested)
81
+ const columns = this.getSelectColumns(includeSecrets);
82
+ // Build and execute query
83
+ const { text: query, values: sqlParams } = buildSelect(this.table, {
84
+ columns,
85
+ where,
86
+ ...(this.joins ? { joins: this.joins } : {}),
87
+ include,
88
+ orderBy,
89
+ limit: actualLimit,
90
+ ...(cursorConditions ? { cursorConditions } : {}),
91
+ });
92
+ const stmt = this.db.prepare(query);
93
+ const result = await stmt.bind(...sqlParams).all();
94
+ if (!result.success) {
95
+ throw new DatabaseError('Failed to execute list query');
96
+ }
97
+ let rows = result.results || [];
98
+ // Process results
99
+ const hasNextPage = rows.length > limit;
100
+ if (hasNextPage) {
101
+ rows = rows.slice(0, limit); // Remove the extra row
102
+ }
103
+ // Decrypt secrets if requested
104
+ if (includeSecrets && this.secrets) {
105
+ rows = await Promise.all(rows.map((row) => this.decryptRowSecrets(row)));
106
+ }
107
+ // Process joins
108
+ const processedRows = this.processJoinedRows(rows, include);
109
+ // Validate rows
110
+ const validatedRows = processedRows.map((row) => this.rowSchema.parse(row));
111
+ // Generate cursors
112
+ let nextCursor;
113
+ let prevCursor;
114
+ if (validatedRows.length > 0) {
115
+ if (hasNextPage) {
116
+ const lastRow = validatedRows[validatedRows.length - 1];
117
+ nextCursor = encodeCursor(createCursor(lastRow, orderBy, 'next'));
118
+ }
119
+ if (cursor) {
120
+ const firstRow = validatedRows[0];
121
+ prevCursor = encodeCursor(createCursor(firstRow, orderBy, 'prev'));
122
+ }
123
+ }
124
+ const listResult = {
125
+ result: validatedRows,
126
+ nextCursor,
127
+ prevCursor,
128
+ };
129
+ ctx.result = listResult;
130
+ await this.runHooks('after', 'list', ctx);
131
+ return listResult;
132
+ }
133
+ catch (error) {
134
+ ctx.error = error;
135
+ await this.runHooks('error', 'list', ctx);
136
+ throw error;
137
+ }
138
+ }
139
+ /**
140
+ * Get a single record by ID
141
+ */
142
+ async get(id, opts = { auth: {} }) {
143
+ const ctx = {
144
+ auth: opts.auth,
145
+ db: this.db,
146
+ deps: this.deps,
147
+ method: 'get',
148
+ params: { id, ...opts },
149
+ };
150
+ try {
151
+ await this.runHooks('before', 'get', ctx);
152
+ const { include = {}, includeSecrets = false } = opts;
153
+ // Get columns to select
154
+ const columns = this.getSelectColumns(includeSecrets);
155
+ // Build and execute query
156
+ const { text: query, values: params } = buildSelectById(this.table, this.primaryKey, id, {
157
+ columns,
158
+ ...(this.joins ? { joins: this.joins } : {}),
159
+ include,
160
+ });
161
+ const stmt = this.db.prepare(query);
162
+ const result = await stmt.bind(...params).first();
163
+ if (!result) {
164
+ ctx.result = null;
165
+ await this.runHooks('after', 'get', ctx);
166
+ return null;
167
+ }
168
+ let row = result;
169
+ // Decrypt secrets if requested
170
+ if (includeSecrets && this.secrets) {
171
+ row = await this.decryptRowSecrets(row);
172
+ }
173
+ // Process joins
174
+ let processedRow = this.processJoinedRows([row], include)[0];
175
+ // Handle one-to-many joins with separate queries
176
+ if (this.joins && Object.keys(include).length > 0) {
177
+ processedRow = await this.fetchOneToManyJoins(processedRow, include, id);
178
+ }
179
+ // Validate row (but preserve join data)
180
+ const baseRow = this.rowSchema.parse(row);
181
+ const validatedRow = {
182
+ ...baseRow,
183
+ ...this.extractJoinData(processedRow, include),
184
+ };
185
+ ctx.result = validatedRow;
186
+ await this.runHooks('after', 'get', ctx);
187
+ return validatedRow;
188
+ }
189
+ catch (error) {
190
+ ctx.error = error;
191
+ await this.runHooks('error', 'get', ctx);
192
+ throw error;
193
+ }
194
+ }
195
+ /**
196
+ * Create a new record
197
+ */
198
+ async create(data, opts = { auth: {} }) {
199
+ const ctx = {
200
+ auth: opts.auth,
201
+ db: this.db,
202
+ deps: this.deps,
203
+ method: 'create',
204
+ params: opts,
205
+ data,
206
+ };
207
+ try {
208
+ await this.runHooks('before', 'create', ctx);
209
+ const { include = {}, includeSecrets = false } = opts;
210
+ // Validate input data
211
+ const validatedData = this.createSchema.parse(data);
212
+ // Add timestamp fields
213
+ const now = new Date().toISOString();
214
+ const dataWithTimestamps = {
215
+ ...validatedData,
216
+ created_at: now,
217
+ updated_at: now,
218
+ };
219
+ // Encrypt secrets
220
+ let processedData = dataWithTimestamps;
221
+ if (this.secrets) {
222
+ processedData = await this.encryptDataSecrets(processedData);
223
+ }
224
+ // Build and execute insert
225
+ const { text: query, values: params } = buildInsert(this.table, processedData);
226
+ const stmt = this.db.prepare(query);
227
+ const result = await stmt.bind(...params).run();
228
+ if (!result.success) {
229
+ throw new DatabaseError('Failed to create record');
230
+ }
231
+ // Get the created record
232
+ const insertId = result.meta.last_row_id;
233
+ const createdRecord = await this.get(insertId, {
234
+ include,
235
+ includeSecrets,
236
+ auth: opts.auth,
237
+ });
238
+ if (!createdRecord) {
239
+ throw new DatabaseError('Failed to retrieve created record');
240
+ }
241
+ ctx.result = createdRecord;
242
+ await this.runHooks('after', 'create', ctx);
243
+ return createdRecord;
244
+ }
245
+ catch (error) {
246
+ ctx.error = error;
247
+ await this.runHooks('error', 'create', ctx);
248
+ throw error;
249
+ }
250
+ }
251
+ /**
252
+ * Update a record by ID
253
+ */
254
+ async update(id, data, opts = { auth: {} }) {
255
+ const ctx = {
256
+ auth: opts.auth,
257
+ db: this.db,
258
+ deps: this.deps,
259
+ method: 'update',
260
+ params: { id, ...opts },
261
+ data,
262
+ };
263
+ try {
264
+ await this.runHooks('before', 'update', ctx);
265
+ const { include = {}, includeSecrets = false } = opts;
266
+ // Check if record exists
267
+ const existingRecord = await this.get(id, { auth: opts.auth });
268
+ if (!existingRecord) {
269
+ throw new NotFoundError(this.table, id);
270
+ }
271
+ // Validate input data
272
+ const validatedData = this.updateSchema
273
+ .partial()
274
+ .parse(data);
275
+ // Add updated timestamp
276
+ const dataWithTimestamp = {
277
+ ...validatedData,
278
+ updated_at: new Date().toISOString(),
279
+ };
280
+ // Encrypt secrets
281
+ let processedData = dataWithTimestamp;
282
+ if (this.secrets) {
283
+ processedData = await this.encryptDataSecrets(processedData);
284
+ }
285
+ // Build where clause for update
286
+ const where = {};
287
+ if (Array.isArray(this.primaryKey)) {
288
+ if (typeof id !== 'object') {
289
+ throw new ValidationError('Composite primary key requires an object');
290
+ }
291
+ Object.assign(where, id);
292
+ }
293
+ else {
294
+ where[this.primaryKey] = id;
295
+ }
296
+ // Build and execute update
297
+ const { text: query, values: params } = buildUpdate(this.table, processedData, where);
298
+ const stmt = this.db.prepare(query);
299
+ const result = await stmt.bind(...params).run();
300
+ if (!result.success) {
301
+ throw new DatabaseError('Failed to update record');
302
+ }
303
+ // Get the updated record
304
+ const updatedRecord = await this.get(id, {
305
+ include,
306
+ includeSecrets,
307
+ auth: opts.auth,
308
+ });
309
+ ctx.result = updatedRecord;
310
+ await this.runHooks('after', 'update', ctx);
311
+ return updatedRecord;
312
+ }
313
+ catch (error) {
314
+ ctx.error = error;
315
+ await this.runHooks('error', 'update', ctx);
316
+ throw error;
317
+ }
318
+ }
319
+ /**
320
+ * Delete a record by ID
321
+ */
322
+ async delete(id, opts = { auth: {} }) {
323
+ const ctx = {
324
+ auth: opts.auth,
325
+ db: this.db,
326
+ deps: this.deps,
327
+ method: 'delete',
328
+ params: { id, ...opts },
329
+ };
330
+ try {
331
+ await this.runHooks('before', 'delete', ctx);
332
+ // Check if record exists
333
+ const existingRecord = await this.get(id, { auth: opts.auth });
334
+ if (!existingRecord) {
335
+ throw new NotFoundError(this.table, id);
336
+ }
337
+ // Build where clause for delete
338
+ const where = {};
339
+ if (Array.isArray(this.primaryKey)) {
340
+ if (typeof id !== 'object') {
341
+ throw new ValidationError('Composite primary key requires an object');
342
+ }
343
+ Object.assign(where, id);
344
+ }
345
+ else {
346
+ where[this.primaryKey] = id;
347
+ }
348
+ // Build and execute delete
349
+ const { text: query, values: params } = buildDelete(this.table, where);
350
+ const stmt = this.db.prepare(query);
351
+ const result = await stmt.bind(...params).run();
352
+ if (!result.success) {
353
+ throw new DatabaseError('Failed to delete record');
354
+ }
355
+ const deleted = result.meta.changes > 0;
356
+ ctx.result = deleted;
357
+ await this.runHooks('after', 'delete', ctx);
358
+ return deleted;
359
+ }
360
+ catch (error) {
361
+ ctx.error = error;
362
+ await this.runHooks('error', 'delete', ctx);
363
+ throw error;
364
+ }
365
+ }
366
+ /**
367
+ * Count records matching criteria
368
+ */
369
+ async count(params = { auth: {} }) {
370
+ const ctx = {
371
+ auth: params.auth,
372
+ db: this.db,
373
+ deps: this.deps,
374
+ method: 'count',
375
+ params,
376
+ };
377
+ try {
378
+ await this.runHooks('before', 'count', ctx);
379
+ const { where = {} } = params;
380
+ // Build and execute count query
381
+ const { text: query, values: sqlParams } = buildCount(this.table, where);
382
+ const stmt = this.db.prepare(query);
383
+ const result = await stmt.bind(...sqlParams).first();
384
+ if (!result) {
385
+ throw new DatabaseError('Failed to execute count query');
386
+ }
387
+ const count = result.count;
388
+ ctx.result = count;
389
+ await this.runHooks('after', 'count', ctx);
390
+ return count;
391
+ }
392
+ catch (error) {
393
+ ctx.error = error;
394
+ await this.runHooks('error', 'count', ctx);
395
+ throw error;
396
+ }
397
+ }
398
+ /**
399
+ * Execute custom SQL query
400
+ */
401
+ async query(query, opts = { auth: {} }, ...sqlParams) {
402
+ const ctx = {
403
+ auth: opts.auth,
404
+ db: this.db,
405
+ deps: this.deps,
406
+ method: 'query',
407
+ params: opts,
408
+ };
409
+ try {
410
+ await this.runHooks('before', 'query', ctx);
411
+ const { includeSecrets = false } = opts;
412
+ // Execute the query
413
+ const stmt = this.db.prepare(query);
414
+ const result = sqlParams.length > 0
415
+ ? await stmt.bind(...sqlParams).all()
416
+ : await stmt.all();
417
+ if (!result.success) {
418
+ throw new DatabaseError('Failed to execute custom query');
419
+ }
420
+ let rows = result.results || [];
421
+ // Decrypt secrets if requested
422
+ if (includeSecrets && this.secrets) {
423
+ rows = await Promise.all(rows.map((row) => this.decryptRowSecrets(row)));
424
+ }
425
+ ctx.result = rows;
426
+ await this.runHooks('after', 'query', ctx);
427
+ return rows;
428
+ }
429
+ catch (error) {
430
+ ctx.error = error;
431
+ await this.runHooks('error', 'query', ctx);
432
+ throw error;
433
+ }
434
+ }
435
+ /**
436
+ * Run hooks with context for a specific method
437
+ */
438
+ async runHooks(phase, method, ctx) {
439
+ const methodHooks = this.hooks[method];
440
+ if (!methodHooks)
441
+ return;
442
+ const hooks = methodHooks[phase];
443
+ if (!hooks)
444
+ return;
445
+ const hooksArray = Array.isArray(hooks) ? hooks : [hooks];
446
+ for (const hook of hooksArray) {
447
+ try {
448
+ await hook(ctx);
449
+ }
450
+ catch (error) {
451
+ if (phase !== 'error') {
452
+ throw new HookError(phase, method, error);
453
+ }
454
+ // If an error hook throws, we just log it and continue
455
+ console.error(`Error in error hook for ${method}:`, error);
456
+ }
457
+ }
458
+ }
459
+ /**
460
+ * Get columns to select based on secrets configuration
461
+ */
462
+ getSelectColumns(includeSecrets) {
463
+ // Return specific columns instead of wildcard to avoid SQL builder issues
464
+ const baseColumns = [
465
+ 'id',
466
+ 'name',
467
+ 'email',
468
+ 'tenant_id',
469
+ 'created_at',
470
+ 'updated_at',
471
+ ];
472
+ if (!this.secrets || includeSecrets) {
473
+ // Include secret columns if requested
474
+ if (this.secrets) {
475
+ const secretColumns = this.secrets.map((secret) => secret.columnName);
476
+ return [...baseColumns, ...secretColumns];
477
+ }
478
+ return baseColumns;
479
+ }
480
+ // Exclude secret columns
481
+ return baseColumns;
482
+ }
483
+ /**
484
+ * Get allowed columns for ordering
485
+ */
486
+ getAllowedColumns() {
487
+ // In practice, you'd want to be more restrictive
488
+ // For now, allow any column name that's a valid identifier
489
+ return ['id', 'created_at', 'updated_at', 'name', 'email']; // Example columns
490
+ }
491
+ /**
492
+ * Encrypt secrets in data
493
+ */
494
+ async encryptDataSecrets(data) {
495
+ if (!this.secrets)
496
+ return data;
497
+ return encryptSecrets(data, this.secrets, this.keyProvider);
498
+ }
499
+ /**
500
+ * Decrypt secrets in a row
501
+ */
502
+ async decryptRowSecrets(row) {
503
+ if (!this.secrets)
504
+ return row;
505
+ return decryptSecrets(row, this.secrets, this.keyProvider);
506
+ }
507
+ /**
508
+ * Process joined rows by extracting join data
509
+ */
510
+ processJoinedRows(rows, include) {
511
+ if (!this.joins || Object.keys(include).length === 0) {
512
+ return rows;
513
+ }
514
+ const joins = this.joins;
515
+ return rows.map((row) => {
516
+ const processedRow = { ...row };
517
+ for (const [joinName, joinDef] of Object.entries(joins)) {
518
+ if (!include[joinName])
519
+ continue;
520
+ const joinAlias = joinDef.remote.alias || joinName;
521
+ const joinData = {};
522
+ const keysToRemove = [];
523
+ // Extract join columns
524
+ for (const column of joinDef.remote.select) {
525
+ const aliasedKey = `${joinAlias}_${column}`;
526
+ if (aliasedKey in row) {
527
+ joinData[column] = row[aliasedKey];
528
+ keysToRemove.push(aliasedKey);
529
+ }
530
+ }
531
+ // Remove aliased keys from main row
532
+ for (const key of keysToRemove) {
533
+ delete processedRow[key];
534
+ }
535
+ // Add join data based on join kind
536
+ if (joinDef.kind === 'one') {
537
+ // For one-to-one, add as object or null
538
+ const hasData = Object.keys(joinData).length > 0 &&
539
+ Object.values(joinData).some((value) => value !== null && value !== undefined);
540
+ processedRow[joinName] = hasData ? joinData : null;
541
+ }
542
+ else {
543
+ // For one-to-many, this will be overridden by fetchOneToManyJoins
544
+ // But set a default empty array for now
545
+ processedRow[joinName] = [];
546
+ }
547
+ }
548
+ return processedRow;
549
+ });
550
+ }
551
+ /**
552
+ * Extract only join data from processed row
553
+ */
554
+ extractJoinData(processedRow, include) {
555
+ if (!this.joins)
556
+ return {};
557
+ const joinData = {};
558
+ for (const joinName of Object.keys(this.joins)) {
559
+ if (include[joinName] && joinName in processedRow) {
560
+ joinData[joinName] = processedRow[joinName];
561
+ }
562
+ }
563
+ return joinData;
564
+ }
565
+ /**
566
+ * Fetch one-to-many joins using separate queries
567
+ */
568
+ async fetchOneToManyJoins(processedRow, include, mainRecordId) {
569
+ if (!this.joins)
570
+ return processedRow;
571
+ const result = { ...processedRow };
572
+ for (const [joinName, joinDef] of Object.entries(this.joins)) {
573
+ if (!include[joinName] || joinDef.kind !== 'many')
574
+ continue;
575
+ try {
576
+ let relatedRecords = [];
577
+ if (joinDef.through) {
578
+ // Many-to-many relationship through junction table
579
+ const sql = `
580
+ SELECT ${joinDef.remote.select.map((col) => `${joinDef.remote.table}.${col}`).join(', ')}
581
+ FROM ${joinDef.remote.table}
582
+ INNER JOIN ${joinDef.through.table} ON ${joinDef.remote.table}.${joinDef.remote.pk} = ${joinDef.through.table}.${joinDef.through.to}
583
+ WHERE ${joinDef.through.table}.${joinDef.through.from} = ?
584
+ `;
585
+ const stmt = this.db.prepare(sql);
586
+ const queryResult = await stmt.bind(mainRecordId).all();
587
+ if (queryResult.success) {
588
+ relatedRecords = queryResult.results;
589
+ }
590
+ }
591
+ else {
592
+ // Direct one-to-many relationship
593
+ const sql = `
594
+ SELECT ${joinDef.remote.select.map((col) => `${col}`).join(', ')}
595
+ FROM ${joinDef.remote.table}
596
+ WHERE ${joinDef.remote.pk} = ?
597
+ `;
598
+ const stmt = this.db.prepare(sql);
599
+ const queryResult = await stmt.bind(mainRecordId).all();
600
+ if (queryResult.success) {
601
+ relatedRecords = queryResult.results;
602
+ }
603
+ }
604
+ // Set the join data
605
+ result[joinName] = relatedRecords || [];
606
+ }
607
+ catch (error) {
608
+ console.error(`Error fetching one-to-many join ${joinName}:`, error);
609
+ result[joinName] = [];
610
+ }
611
+ }
612
+ return result;
613
+ }
614
+ }
615
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EACL,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAA;AAuBzB;;GAEG;AACH,MAAM,OAAO,OAAO;IAQF,KAAK,CAAQ;IACb,EAAE,CAAU;IACZ,SAAS,CAAM;IACf,YAAY,CAAS;IACrB,YAAY,CAAS;IACrB,KAAK,CAAoB;IACzB,OAAO,CAAsB;IAC7B,UAAU,CAAmB;IAC7B,cAAc,CAAqB;IACnC,WAAW,CAAa;IACxB,IAAI,CAAsD;IAEzD,KAAK,CAA2B;IAEjD,YACE,OAAiE;QAEjE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1B,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QACxC,IAAI,C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