@graph8/sdk 0.14.0 → 0.15.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/react.js CHANGED
@@ -865,6 +865,8 @@ var KNOWN_WEBHOOK_EVENTS = [
865
865
  "engagement.email_bounced",
866
866
  "engagement.email_skipped",
867
867
  "engagement.call_dispatched",
868
+ "engagement.call_connected",
869
+ "engagement.call_graded",
868
870
  "engagement.sms_sent",
869
871
  "engagement.sms_replied",
870
872
  "engagement.whatsapp_sent",
@@ -875,7 +877,12 @@ var KNOWN_WEBHOOK_EVENTS = [
875
877
  "engagement.linkedin_connection_accepted",
876
878
  "meeting.booked",
877
879
  "meeting.cancelled",
878
- "meeting.rescheduled"
880
+ "meeting.rescheduled",
881
+ "deal.won",
882
+ "crm.record.created",
883
+ "crm.record.updated",
884
+ "crm.record.archived",
885
+ "crm.record.restored"
879
886
  ];
880
887
  var WebhookSignatureError = class extends Error {
881
888
  constructor(message) {
@@ -1558,8 +1565,32 @@ var createObjectsClient = (apiKey, apiUrl) => {
1558
1565
  const encode = (value) => encodeURIComponent(value);
1559
1566
  return {
1560
1567
  /** List the custom object types in your workspace. */
1561
- async list() {
1562
- return request(baseUrl, "/api/v1/objects", apiKey);
1568
+ async list(params = {}) {
1569
+ const query = params.include_archived ? "?include_archived=true" : "";
1570
+ return request(baseUrl, `/api/v1/objects${query}`, apiKey);
1571
+ },
1572
+ /** Create a native custom object. Requires objects:manage and Admin access. */
1573
+ async create(input) {
1574
+ const resp = await request(baseUrl, "/api/v1/objects", apiKey, {
1575
+ method: "POST",
1576
+ body: input
1577
+ });
1578
+ return resp.data;
1579
+ },
1580
+ /** Rename, archive or restore an object while preserving its slug and data. */
1581
+ async update(objectSlug, input) {
1582
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}`, apiKey, {
1583
+ method: "PATCH",
1584
+ body: input
1585
+ });
1586
+ return resp.data;
1587
+ },
1588
+ /** Archive the object without deleting records; restore with update({ is_archived: false }). */
1589
+ async archive(objectSlug) {
1590
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}`, apiKey, {
1591
+ method: "DELETE"
1592
+ });
1593
+ return resp.data;
1563
1594
  },
1564
1595
  /** Fetch one object type by slug. */
1565
1596
  async get(objectSlug) {
@@ -1571,10 +1602,35 @@ var createObjectsClient = (apiKey, apiUrl) => {
1571
1602
  return resp.data ?? resp;
1572
1603
  },
1573
1604
  /** The object's attributes — the schema its records must satisfy. */
1574
- async listAttributes(objectSlug) {
1575
- return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1605
+ async listAttributes(objectSlug, params = {}) {
1606
+ const query = params.include_archived ? "?include_archived=true" : "";
1607
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes${query}`, apiKey);
1576
1608
  },
1577
- /** Paginated records with their current values. Archived records are excluded. */
1609
+ /** Create a field using the same schema rules as the customer UI. */
1610
+ async createAttribute(objectSlug, input) {
1611
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey, {
1612
+ method: "POST",
1613
+ body: input
1614
+ });
1615
+ return resp.data;
1616
+ },
1617
+ /** Edit or restore a field; its type and slug are immutable. */
1618
+ async updateAttribute(objectSlug, attributeSlug, input) {
1619
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes/${encode(attributeSlug)}`, apiKey, {
1620
+ method: "PATCH",
1621
+ body: input
1622
+ });
1623
+ return resp.data;
1624
+ },
1625
+ /** Archive without deleting values; restore with updateAttribute({ is_archived: false }). */
1626
+ async archiveAttribute(objectSlug, attributeSlug) {
1627
+ const resp = await request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes/${encode(attributeSlug)}`, apiKey, {
1628
+ method: "DELETE"
1629
+ });
1630
+ return resp.data;
1631
+ },
1632
+ /** Paginated custom records or canonical deals with current values and revisions.
1633
+ * Deal totals and related references respect current record access. */
1578
1634
  async listRecords(objectSlug, params = {}) {
1579
1635
  const query = {};
1580
1636
  if (params.page != null) query.page = params.page;
@@ -1598,7 +1654,24 @@ var createObjectsClient = (apiKey, apiUrl) => {
1598
1654
  );
1599
1655
  return resp.data ?? resp;
1600
1656
  },
1601
- /** Fetch one record with its currently active values. */
1657
+ /** Match a unique single-value key, creating or updating while preserving omitted fields. */
1658
+ async upsertRecord(objectSlug, matchingAttribute, values, options = {}) {
1659
+ const resp = await request(
1660
+ baseUrl,
1661
+ `/api/v1/objects/${encode(objectSlug)}/records/upsert`,
1662
+ apiKey,
1663
+ { method: "POST", body: {
1664
+ matching_attribute: matchingAttribute,
1665
+ values,
1666
+ ...options.expectedRevision !== void 0 ? { expected_revision: options.expectedRevision } : {}
1667
+ } }
1668
+ );
1669
+ return resp.data;
1670
+ },
1671
+ /** Fetch one custom record, canonical contact/company, or deal by its stable graph8 ID.
1672
+ * Deals retain their UUIDs and expose company, primary-contact and contact_ids references only
1673
+ * when permitted. Generic deal mutations are not yet supported.
1674
+ */
1602
1675
  async getRecord(objectSlug, recordId) {
1603
1676
  const resp = await request(
1604
1677
  baseUrl,
@@ -1612,15 +1685,24 @@ var createObjectsClient = (apiKey, apiUrl) => {
1612
1685
  * required attributes you omit are left alone rather than reported missing.
1613
1686
  * Sending an explicit `null` CLEARS that attribute.
1614
1687
  *
1615
- * Values are versioned rather than overwritten, so the previous value stays
1616
- * readable through `history`.
1688
+ * Custom values retain generations through `history`. Canonical contacts and
1689
+ * companies require expectedRevision from a fresh read and expose recorded
1690
+ * mutations through `changes`. They do not yet support appendValues/removeValues.
1617
1691
  */
1618
1692
  async updateRecord(objectSlug, recordId, values, options) {
1619
1693
  const resp = await request(
1620
1694
  baseUrl,
1621
1695
  `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1622
1696
  apiKey,
1623
- { method: "PATCH", body: { values, ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision } } }
1697
+ {
1698
+ method: "PATCH",
1699
+ body: {
1700
+ values,
1701
+ ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision },
1702
+ ...options?.appendValues === void 0 ? {} : { append_values: options.appendValues },
1703
+ ...options?.removeValues === void 0 ? {} : { remove_values: options.removeValues }
1704
+ }
1705
+ }
1624
1706
  );
1625
1707
  return resp.data ?? resp;
1626
1708
  },
@@ -1659,6 +1741,19 @@ var createObjectsClient = (apiKey, apiUrl) => {
1659
1741
  { query: limit != null ? { limit } : void 0 }
1660
1742
  );
1661
1743
  return resp.data ?? resp;
1744
+ },
1745
+ /** Recorded custom-record or canonical contact/company mutations. Pass next_cursor to continue.
1746
+ * Canonical history respects current access/privacy; archived records and older
1747
+ * unrecorded writes are not reconstructed. Store unavailability returns 503.
1748
+ */
1749
+ async changes(objectSlug, recordId, options = {}) {
1750
+ const resp = await request(
1751
+ baseUrl,
1752
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/changes`,
1753
+ apiKey,
1754
+ { query: options }
1755
+ );
1756
+ return resp.data ?? resp;
1662
1757
  }
1663
1758
  };
1664
1759
  };