@graph8/sdk 0.14.0 → 0.16.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.
package/dist/index.mjs CHANGED
@@ -846,6 +846,8 @@ var KNOWN_WEBHOOK_EVENTS = [
846
846
  "engagement.email_bounced",
847
847
  "engagement.email_skipped",
848
848
  "engagement.call_dispatched",
849
+ "engagement.call_connected",
850
+ "engagement.call_graded",
849
851
  "engagement.sms_sent",
850
852
  "engagement.sms_replied",
851
853
  "engagement.whatsapp_sent",
@@ -856,7 +858,12 @@ var KNOWN_WEBHOOK_EVENTS = [
856
858
  "engagement.linkedin_connection_accepted",
857
859
  "meeting.booked",
858
860
  "meeting.cancelled",
859
- "meeting.rescheduled"
861
+ "meeting.rescheduled",
862
+ "deal.won",
863
+ "crm.record.created",
864
+ "crm.record.updated",
865
+ "crm.record.archived",
866
+ "crm.record.restored"
860
867
  ];
861
868
  var WebhookSignatureError = class extends Error {
862
869
  constructor(message) {
@@ -1541,8 +1548,32 @@ var createObjectsClient = (apiKey, apiUrl) => {
1541
1548
  const encode = (value) => encodeURIComponent(value);
1542
1549
  return {
1543
1550
  /** List the custom object types in your workspace. */
1544
- async list() {
1545
- return request(baseUrl, "/api/v1/objects", apiKey);
1551
+ async list(params = {}) {
1552
+ const query = params.include_archived ? "?include_archived=true" : "";
1553
+ return request(baseUrl, `/api/v1/objects${query}`, apiKey);
1554
+ },
1555
+ /** Create a native custom object. Requires objects:manage and Admin access. */
1556
+ async create(input) {
1557
+ const resp = await request(baseUrl, "/api/v1/objects", apiKey, {
1558
+ method: "POST",
1559
+ body: input
1560
+ });
1561
+ return resp.data;
1562
+ },
1563
+ /** Rename, archive or restore an object while preserving its slug and data. */
1564
+ async update(objectSlug, input) {
1565
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}`, apiKey, {
1566
+ method: "PATCH",
1567
+ body: input
1568
+ });
1569
+ return resp.data;
1570
+ },
1571
+ /** Archive the object without deleting records; restore with update({ is_archived: false }). */
1572
+ async archive(objectSlug) {
1573
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}`, apiKey, {
1574
+ method: "DELETE"
1575
+ });
1576
+ return resp.data;
1546
1577
  },
1547
1578
  /** Fetch one object type by slug. */
1548
1579
  async get(objectSlug) {
@@ -1554,10 +1585,35 @@ var createObjectsClient = (apiKey, apiUrl) => {
1554
1585
  return resp.data ?? resp;
1555
1586
  },
1556
1587
  /** The object's attributes — the schema its records must satisfy. */
1557
- async listAttributes(objectSlug) {
1558
- return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1588
+ async listAttributes(objectSlug, params = {}) {
1589
+ const query = params.include_archived ? "?include_archived=true" : "";
1590
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes${query}`, apiKey);
1559
1591
  },
1560
- /** Paginated records with their current values. Archived records are excluded. */
1592
+ /** Create a field using the same schema rules as the customer UI. */
1593
+ async createAttribute(objectSlug, input) {
1594
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey, {
1595
+ method: "POST",
1596
+ body: input
1597
+ });
1598
+ return resp.data;
1599
+ },
1600
+ /** Edit or restore a field; its type and slug are immutable. */
1601
+ async updateAttribute(objectSlug, attributeSlug, input) {
1602
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes/${encode(attributeSlug)}`, apiKey, {
1603
+ method: "PATCH",
1604
+ body: input
1605
+ });
1606
+ return resp.data;
1607
+ },
1608
+ /** Archive without deleting values; restore with updateAttribute({ is_archived: false }). */
1609
+ async archiveAttribute(objectSlug, attributeSlug) {
1610
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes/${encode(attributeSlug)}`, apiKey, {
1611
+ method: "DELETE"
1612
+ });
1613
+ return resp.data;
1614
+ },
1615
+ /** Paginated custom records or canonical deals with current values and revisions.
1616
+ * Deal totals and related references respect current record access. */
1561
1617
  async listRecords(objectSlug, params = {}) {
1562
1618
  const query = {};
1563
1619
  if (params.page != null) query.page = params.page;
@@ -1581,7 +1637,24 @@ var createObjectsClient = (apiKey, apiUrl) => {
1581
1637
  );
1582
1638
  return resp.data ?? resp;
1583
1639
  },
1584
- /** Fetch one record with its currently active values. */
1640
+ /** Match a unique single-value key, creating or updating while preserving omitted fields. */
1641
+ async upsertRecord(objectSlug, matchingAttribute, values, options = {}) {
1642
+ const resp = await request(
1643
+ baseUrl,
1644
+ `/api/v1/objects/${encode(objectSlug)}/records/upsert`,
1645
+ apiKey,
1646
+ { method: "POST", body: {
1647
+ matching_attribute: matchingAttribute,
1648
+ values,
1649
+ ...options.expectedRevision !== void 0 ? { expected_revision: options.expectedRevision } : {}
1650
+ } }
1651
+ );
1652
+ return resp.data;
1653
+ },
1654
+ /** Fetch one custom record, canonical contact/company, or deal by its stable graph8 ID.
1655
+ * Deals retain their UUIDs and expose company, primary-contact and contact_ids references only
1656
+ * when permitted. Generic deal mutations are not yet supported.
1657
+ */
1585
1658
  async getRecord(objectSlug, recordId) {
1586
1659
  const resp = await request(
1587
1660
  baseUrl,
@@ -1595,15 +1668,24 @@ var createObjectsClient = (apiKey, apiUrl) => {
1595
1668
  * required attributes you omit are left alone rather than reported missing.
1596
1669
  * Sending an explicit `null` CLEARS that attribute.
1597
1670
  *
1598
- * Values are versioned rather than overwritten, so the previous value stays
1599
- * readable through `history`.
1671
+ * Custom values retain generations through `history`. Canonical contacts and
1672
+ * companies require expectedRevision from a fresh read and expose recorded
1673
+ * mutations through `changes`. They do not yet support appendValues/removeValues.
1600
1674
  */
1601
1675
  async updateRecord(objectSlug, recordId, values, options) {
1602
1676
  const resp = await request(
1603
1677
  baseUrl,
1604
1678
  `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1605
1679
  apiKey,
1606
- { method: "PATCH", body: { values, ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision } } }
1680
+ {
1681
+ method: "PATCH",
1682
+ body: {
1683
+ values,
1684
+ ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision },
1685
+ ...options?.appendValues === void 0 ? {} : { append_values: options.appendValues },
1686
+ ...options?.removeValues === void 0 ? {} : { remove_values: options.removeValues }
1687
+ }
1688
+ }
1607
1689
  );
1608
1690
  return resp.data ?? resp;
1609
1691
  },
@@ -1642,6 +1724,19 @@ var createObjectsClient = (apiKey, apiUrl) => {
1642
1724
  { query: limit != null ? { limit } : void 0 }
1643
1725
  );
1644
1726
  return resp.data ?? resp;
1727
+ },
1728
+ /** Recorded custom-record or canonical contact/company mutations. Pass next_cursor to continue.
1729
+ * Canonical history respects current access/privacy; archived records and older
1730
+ * unrecorded writes are not reconstructed. Store unavailability returns 503.
1731
+ */
1732
+ async changes(objectSlug, recordId, options = {}) {
1733
+ const resp = await request(
1734
+ baseUrl,
1735
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/changes`,
1736
+ apiKey,
1737
+ { query: options }
1738
+ );
1739
+ return resp.data ?? resp;
1645
1740
  }
1646
1741
  };
1647
1742
  };