skedyul 1.0.16 → 1.0.17

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.
package/dist/.build-stamp CHANGED
@@ -1 +1 @@
1
- 1773386250590
1
+ 1773409162804
@@ -414,6 +414,44 @@ export declare const instance: {
414
414
  error: string;
415
415
  }>;
416
416
  }>;
417
+ /**
418
+ * Upsert multiple instances of an internal model in a single batch operation.
419
+ *
420
+ * Creates instances if they don't exist, updates them if they do (based on matchField).
421
+ * This is more efficient than calling upsert() multiple times as it reduces
422
+ * API overhead and executes all upserts in a single transaction.
423
+ *
424
+ * The API token determines the context (app installation is embedded in sk_wkp_ tokens).
425
+ *
426
+ * @param modelHandle - The model handle from provision config
427
+ * @param items - Array of data objects to upsert as instances
428
+ * @param matchField - The field handle to match existing instances (e.g., 'vetnostics_id')
429
+ * @returns Object containing upserted instances with mode and any errors that occurred
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * const { results, errors } = await instance.upsertMany('panel_result', [
434
+ * { vetnostics_id: '25-54966975/622/glucose', test_name: 'Glucose', value_string: '5.2' },
435
+ * { vetnostics_id: '25-54966975/622/creatinine', test_name: 'Creatinine', value_string: '80' },
436
+ * ], 'vetnostics_id')
437
+ *
438
+ * if (errors.length > 0) {
439
+ * console.log('Some items failed:', errors)
440
+ * }
441
+ * const created = results.filter(r => r.mode === 'created')
442
+ * const updated = results.filter(r => r.mode === 'updated')
443
+ * console.log('Created:', created.length, 'Updated:', updated.length)
444
+ * ```
445
+ */
446
+ upsertMany(modelHandle: string, items: Record<string, unknown>[], matchField: string): Promise<{
447
+ results: Array<InstanceData & {
448
+ mode: "created" | "updated";
449
+ }>;
450
+ errors: Array<{
451
+ index: number;
452
+ error: string;
453
+ }>;
454
+ }>;
417
455
  /**
418
456
  * Check if a model is configured (linked) for the current app installation.
419
457
  *
@@ -438,6 +438,43 @@ exports.instance = {
438
438
  });
439
439
  return data;
440
440
  },
441
+ /**
442
+ * Upsert multiple instances of an internal model in a single batch operation.
443
+ *
444
+ * Creates instances if they don't exist, updates them if they do (based on matchField).
445
+ * This is more efficient than calling upsert() multiple times as it reduces
446
+ * API overhead and executes all upserts in a single transaction.
447
+ *
448
+ * The API token determines the context (app installation is embedded in sk_wkp_ tokens).
449
+ *
450
+ * @param modelHandle - The model handle from provision config
451
+ * @param items - Array of data objects to upsert as instances
452
+ * @param matchField - The field handle to match existing instances (e.g., 'vetnostics_id')
453
+ * @returns Object containing upserted instances with mode and any errors that occurred
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * const { results, errors } = await instance.upsertMany('panel_result', [
458
+ * { vetnostics_id: '25-54966975/622/glucose', test_name: 'Glucose', value_string: '5.2' },
459
+ * { vetnostics_id: '25-54966975/622/creatinine', test_name: 'Creatinine', value_string: '80' },
460
+ * ], 'vetnostics_id')
461
+ *
462
+ * if (errors.length > 0) {
463
+ * console.log('Some items failed:', errors)
464
+ * }
465
+ * const created = results.filter(r => r.mode === 'created')
466
+ * const updated = results.filter(r => r.mode === 'updated')
467
+ * console.log('Created:', created.length, 'Updated:', updated.length)
468
+ * ```
469
+ */
470
+ async upsertMany(modelHandle, items, matchField) {
471
+ const { data } = await callCore('instance.upsertMany', {
472
+ modelHandle,
473
+ items,
474
+ matchField,
475
+ });
476
+ return data;
477
+ },
441
478
  /**
442
479
  * Check if a model is configured (linked) for the current app installation.
443
480
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",