@stonecrop/stonecrop 0.12.2 → 0.12.3

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.
@@ -334,9 +334,9 @@ export class Stonecrop {
334
334
  if (!resolved) {
335
335
  throw new Error(`Doctype not found: ${typeof doctype === 'string' ? doctype : doctype.slug}`);
336
336
  }
337
- const record = await this._client.getRecord(resolved, recordId);
338
- if (record) {
339
- this.addRecord(resolved, recordId, record);
337
+ const result = await this._client.getRecord(resolved, recordId);
338
+ if (result?.record) {
339
+ this.addRecord(resolved, recordId, result.record);
340
340
  }
341
341
  }
342
342
  /**
@@ -499,10 +499,10 @@ export class Stonecrop {
499
499
  throw createCodedError('No data client configured. Call setClient() with a DataClient implementation ' +
500
500
  '(e.g., StonecropClient from @stonecrop/graphql-client) before fetching records.', 'CLIENT_REQUIRED');
501
501
  }
502
- const record = await this._client.getRecord({ name: doctype.doctype }, recordId, {
502
+ const result = await this._client.getRecord({ name: doctype.doctype }, recordId, {
503
503
  includeNested: options?.includeNested ?? true,
504
504
  });
505
- if (!record) {
505
+ if (!result?.record) {
506
506
  throw createCodedError(`Record not found: ${doctype.doctype} ${recordId}`, 'RECORD_NOT_FOUND');
507
507
  }
508
508
  // Store each scalar field at its own HST path, descendants at link-level path
@@ -513,7 +513,7 @@ export class Stonecrop {
513
513
  if (!existingData) {
514
514
  this.hstStore.set(`${slug}.${recordId}`, {}, 'system');
515
515
  }
516
- for (const [key, value] of Object.entries(record)) {
516
+ for (const [key, value] of Object.entries(result.record)) {
517
517
  this.hstStore.set(`${slug}.${recordId}.${key}`, value, 'system');
518
518
  }
519
519
  }
package/dist/stonecrop.js CHANGED
@@ -1539,7 +1539,7 @@ class At {
1539
1539
  if (!n)
1540
1540
  throw new Error(`Doctype not found: ${typeof t == "string" ? t : t.slug}`);
1541
1541
  const i = await this._client.getRecord(n, r);
1542
- i && this.addRecord(n, r, i);
1542
+ i?.record && this.addRecord(n, r, i.record);
1543
1543
  }
1544
1544
  /**
1545
1545
  * Dispatch an action to the server via the configured data client.
@@ -1665,11 +1665,11 @@ class At {
1665
1665
  const o = await this._client.getRecord({ name: r.doctype }, n, {
1666
1666
  includeNested: i?.includeNested ?? !0
1667
1667
  });
1668
- if (!o)
1668
+ if (!o?.record)
1669
1669
  throw en(`Record not found: ${r.doctype} ${n}`, "RECORD_NOT_FOUND");
1670
1670
  const s = r.slug;
1671
1671
  this.ensureDoctypeExists(s), this.hstStore.get(`${s}.${n}`) || this.hstStore.set(`${s}.${n}`, {}, "system");
1672
- for (const [u, c] of Object.entries(o))
1672
+ for (const [u, c] of Object.entries(o.record))
1673
1673
  this.hstStore.set(`${s}.${n}.${u}`, c, "system");
1674
1674
  }
1675
1675
  /**