@dench.com/cli 3.11.34-staging.773 → 3.11.36-staging.805

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 (3) hide show
  1. package/crm.ts +24 -2
  2. package/meetings.ts +3 -1
  3. package/package.json +1 -1
package/crm.ts CHANGED
@@ -532,17 +532,31 @@ export function countResultStatuses(results: unknown[]): {
532
532
  created: number;
533
533
  alreadyExisted: number;
534
534
  updated: number;
535
+ errors: number;
535
536
  } {
536
537
  let created = 0;
537
538
  let alreadyExisted = 0;
538
539
  let updated = 0;
540
+ let errors = 0;
539
541
  for (const result of results) {
540
542
  const status = isJsonRecord(result) ? result.status : undefined;
541
543
  if (status === "already_existed") alreadyExisted += 1;
542
544
  else if (status === "updated") updated += 1;
545
+ else if (status === "error") errors += 1;
543
546
  else created += 1;
544
547
  }
545
- return { created, alreadyExisted, updated };
548
+ return { created, alreadyExisted, updated, errors };
549
+ }
550
+
551
+ /** "Row N: reason" for every row `batch.apply` skipped (DEN-349). */
552
+ export function importRowErrors(results: unknown[]): string[] {
553
+ return results.flatMap((result) =>
554
+ isJsonRecord(result) &&
555
+ result.status === "error" &&
556
+ typeof result.error === "string"
557
+ ? [result.error]
558
+ : [],
559
+ );
546
560
  }
547
561
 
548
562
  function parseUpdateManyRows(items: unknown[]): Array<{
@@ -672,6 +686,7 @@ export async function applyBatchOpsInChunks(
672
686
  allowUnknown = false,
673
687
  onConflict?: CrmOnConflictPolicy,
674
688
  withReferences = false,
689
+ collectRowErrors = false,
675
690
  ): Promise<{
676
691
  chunks: number;
677
692
  results: unknown[];
@@ -689,6 +704,7 @@ export async function applyBatchOpsInChunks(
689
704
  ...(chunkKey ? { idempotencyKey: chunkKey } : {}),
690
705
  ...(allowUnknown ? { allowUnknown: true } : {}),
691
706
  ...(onConflict ? { onConflict } : {}),
707
+ ...(collectRowErrors ? { collectRowErrors: true } : {}),
692
708
  })) as
693
709
  | { results?: unknown[]; references?: WorkspaceReference[] }
694
710
  | null
@@ -3893,21 +3909,27 @@ async function runImportCommand(ctx: CrmCliContext): Promise<void> {
3893
3909
  }));
3894
3910
  // batch.apply matches the selected CRM field when supplied; otherwise
3895
3911
  // seedKey protects exact reruns. The shared helper handles chunking.
3912
+ // A bad row is reported by its row number and skipped; the good rows are
3913
+ // still created (DEN-349).
3896
3914
  const { results } = await applyBatchOpsInChunks(
3897
3915
  ctx,
3898
3916
  ops,
3899
3917
  undefined,
3900
3918
  false,
3901
3919
  onConflict,
3920
+ false,
3921
+ true,
3902
3922
  );
3903
3923
  const counts = countResultStatuses(results);
3924
+ const rowErrors = importRowErrors(results);
3904
3925
  out(ctx, {
3905
3926
  objectName,
3906
3927
  sourceRowsParsed: rows.length,
3907
3928
  imported: counts.created,
3908
3929
  skipped: counts.alreadyExisted,
3909
3930
  updated: counts.updated,
3910
- errors: 0,
3931
+ errors: counts.errors,
3932
+ ...(rowErrors.length > 0 ? { rowErrors } : {}),
3911
3933
  onConflict,
3912
3934
  ...(dedupeColumn ? { dedupeKey: dedupeColumn } : {}),
3913
3935
  });
package/meetings.ts CHANGED
@@ -223,7 +223,9 @@ async function runShare(ctx: CrmCliContext): Promise<void> {
223
223
  const result = (await callMutation(ctx, api.sharing.set, {
224
224
  meetingEntryId,
225
225
  shared: toWorkspace,
226
- })) as { sharedWithWorkspace: boolean };
226
+ })) as { sharedWithWorkspace: boolean } | null;
227
+ // The server answers `null` for a meeting this caller cannot read.
228
+ if (!result) throw new CrmCliError(`Meeting not found: ${meetingEntryId}`);
227
229
  if (ctx.jsonOutput) {
228
230
  out(ctx, result);
229
231
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dench.com/cli",
3
- "version": "3.11.34-staging.773",
3
+ "version": "3.11.36-staging.805",
4
4
  "description": "Dench agent workspace CLI.",
5
5
  "type": "module",
6
6
  "bin": {