@superdoc/sdk 2.23.0-next.13 → 2.23.0-next.15

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.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var documentEvidence = require('../runtime/document-evidence.cjs');
4
+ var guards = require('../guards.cjs');
4
5
  var errors = require('../runtime/errors.cjs');
5
6
  var docSnapshot = require('./doc-snapshot.cjs');
6
7
  var operationCatalog = require('./operation-catalog.cjs');
@@ -226,9 +227,11 @@ class ExecutionContext {
226
227
  ]
227
228
  : [args, options]);
228
229
  this.executedOperations.push({ operationId, result });
229
- if (result?.success === false)
230
+ if (guards.isRecord(result) && result.success === false)
230
231
  throw new errors.SuperDocCliError('Document operation did not apply.', {
231
- code: result.failure?.code ?? 'APPLY_FAILED',
232
+ code: guards.isRecord(result.failure) && typeof result.failure.code === 'string'
233
+ ? result.failure.code
234
+ : 'APPLY_FAILED',
232
235
  details: result,
233
236
  });
234
237
  if (documentEvidence.supportsDocumentFacts(this.source)) {
@@ -1,4 +1,5 @@
1
1
  import { getDocumentRevisionReader, supportsDocumentFacts, requiresSummaryCounts, forwardDocumentEvidence, getMutationRevision, } from '../runtime/document-evidence.js';
2
+ import { isRecord } from '../guards.js';
2
3
  import { SuperDocCliError } from '../runtime/errors.js';
3
4
  import { buildDocumentSnapshot, buildMutationSnapshot, buildExecutionSummary, resolveSnapshotSelector, } from './doc-snapshot.js';
4
5
  import { getOperationCatalogEntry } from './operation-catalog.js';
@@ -223,9 +224,11 @@ export class ExecutionContext {
223
224
  ]
224
225
  : [args, options]);
225
226
  this.executedOperations.push({ operationId, result });
226
- if (result?.success === false)
227
+ if (isRecord(result) && result.success === false)
227
228
  throw new SuperDocCliError('Document operation did not apply.', {
228
- code: result.failure?.code ?? 'APPLY_FAILED',
229
+ code: isRecord(result.failure) && typeof result.failure.code === 'string'
230
+ ? result.failure.code
231
+ : 'APPLY_FAILED',
229
232
  details: result,
230
233
  });
231
234
  if (supportsDocumentFacts(this.source)) {