@graph8/sdk 0.12.0 → 0.13.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.d.mts CHANGED
@@ -580,6 +580,29 @@ interface IntentCompany {
580
580
  visit_count: number;
581
581
  last_seen: string | null;
582
582
  }
583
+ /** One company row from `intent.urlCompanies()`. Richer than {@link IntentCompany},
584
+ * which describes the keyword-companies surface. */
585
+ interface IntentUrlCompany {
586
+ company_id: number | null;
587
+ name: string | null;
588
+ domain: string | null;
589
+ industry: string | null;
590
+ employee_count: number | null;
591
+ logo_url: string | null;
592
+ audience: string;
593
+ visit_count: number;
594
+ contacts_seen: number;
595
+ last_seen: string | null;
596
+ }
597
+ /** Response of `intent.urlCompanies()`. This endpoint returns a bare aggregate,
598
+ * not the `{ data }` envelope the rest of the Developer API uses. */
599
+ interface IntentUrlCompaniesResponse {
600
+ url: string;
601
+ total_companies: number;
602
+ b2b_count: number;
603
+ b2c_count: number;
604
+ companies: IntentUrlCompany[];
605
+ }
583
606
  interface IntentContact {
584
607
  contact_id: number | null;
585
608
  email: string | null;
@@ -614,7 +637,7 @@ interface IntentStats {
614
637
  * POST /api/v1/intent/pages/visitors
615
638
  * POST /api/v1/intent/pages/contacts
616
639
  * POST /api/v1/intent/pages/visitor-counts
617
- * POST /intent-search/url-companies (note: bare host, no /api/v1 prefix)
640
+ * POST /api/v1/intent/url-companies
618
641
  */
619
642
  declare const createIntentClient: (apiKey: string, apiUrl?: string) => {
620
643
  /** Org-level intent stats (totals over the last 30 days). */
@@ -697,16 +720,24 @@ declare const createIntentClient: (apiKey: string, apiUrl?: string) => {
697
720
  /**
698
721
  * Find companies whose users visited a specific URL (intent search).
699
722
  *
700
- * Note: this endpoint lives at the bare host (no `/api/v1` prefix), unlike the rest
701
- * of the intent surface we call it directly here instead of through the shared `post()` helper.
723
+ * Previously posted to the bare-host `/intent-search/url-companies`, bypassing
724
+ * the shared `post()` helper. That route is JWT-only, so this method could
725
+ * never actually work with an API key. It now goes through
726
+ * `/api/v1/intent/url-companies` like the rest of the intent surface (g8 issue
727
+ * #16536).
728
+ *
729
+ * Returns a bare aggregate, NOT the `{ data }` envelope — the previous
730
+ * `{ data: IntentCompany[] }` signature never matched what the API sends.
731
+ *
732
+ * `date_from` / `date_to` are accepted for backwards compatibility but have
733
+ * never been read by this endpoint; use `days` to set the lookback window.
702
734
  */
703
735
  urlCompanies(url: string, params?: {
704
736
  limit?: number;
737
+ days?: number;
705
738
  date_from?: string;
706
739
  date_to?: string;
707
- }): Promise<{
708
- data: IntentCompany[];
709
- }>;
740
+ }): Promise<IntentUrlCompaniesResponse>;
710
741
  };
711
742
 
712
743
  type SkillType = "llm" | "api";
@@ -1555,14 +1586,28 @@ interface DealCreateParams {
1555
1586
  */
1556
1587
  company_id?: number;
1557
1588
  description?: string;
1589
+ /**
1590
+ * Monetary value. Required (HTTP 400, marker `amount_required_for_won_stage`)
1591
+ * when creating directly in a Closed Won stage; 0 is a valid amount.
1592
+ */
1558
1593
  amount?: number;
1559
1594
  /** Default: "USD". */
1560
1595
  currency?: string;
1561
- /** Stage ID from the org's pipelines. Defaults to first stage of default pipeline if omitted. */
1596
+ /**
1597
+ * Stage ID from the org's pipelines. Must exist and belong to `pipeline_id`
1598
+ * when both are sent (HTTP 422 otherwise). Defaults to the default
1599
+ * pipeline's first non-closed stage if omitted. Creating directly in a
1600
+ * closed stage triggers the closed-stage rules (HTTP 400 with marker
1601
+ * `close_date_required_for_won_stage` / `close_date_required_for_lost_stage`
1602
+ * / `amount_required_for_won_stage` / `owner_required_for_closed_stage`).
1603
+ */
1562
1604
  stage_id?: string;
1563
- /** Pipeline ID. Defaults to org's default pipeline if omitted. */
1605
+ /** Pipeline ID. Must exist (HTTP 422 otherwise). Defaults to org's default pipeline if omitted. */
1564
1606
  pipeline_id?: string;
1565
- /** ISO 8601 close date. */
1607
+ /**
1608
+ * ISO 8601 close date. Required when creating directly in a Closed Won or
1609
+ * Closed Lost stage; past dates are allowed (backdating is supported).
1610
+ */
1566
1611
  close_date?: string;
1567
1612
  /**
1568
1613
  * Set true to create a deal even if one already exists for the company.
@@ -1575,10 +1620,28 @@ interface DealUpdateParams {
1575
1620
  description?: string;
1576
1621
  amount?: number;
1577
1622
  currency?: string;
1623
+ /**
1624
+ * New stage ID. Must be an existing stage in the deal's pipeline (HTTP 422
1625
+ * otherwise). Moving a deal INTO a Closed Won stage requires an effective
1626
+ * close_date AND amount; Closed Lost requires an effective close_date;
1627
+ * either requires an owner ("effective" = the value in this call, else the
1628
+ * deal's existing value). Violations return HTTP 400 with a marker-prefixed
1629
+ * detail: `close_date_required_for_won_stage`,
1630
+ * `close_date_required_for_lost_stage`, `amount_required_for_won_stage`,
1631
+ * `owner_required_for_closed_stage`. Re-submitting the deal's current stage
1632
+ * is never gated.
1633
+ */
1578
1634
  stage_id?: string;
1579
- /** ISO 8601 close date. */
1580
- close_date?: string;
1581
- /** Reassign the deal owner (user id or email). Pass null to clear. */
1635
+ /**
1636
+ * ISO 8601 close date. Explicit null clears it, except on a deal sitting in
1637
+ * a closed stage (HTTP 400, closed-stage markers above).
1638
+ */
1639
+ close_date?: string | null;
1640
+ /**
1641
+ * Reassign the deal owner (user id or email). Pass null to clear, except on
1642
+ * a deal sitting in a closed stage (HTTP 400, marker
1643
+ * `owner_required_for_closed_stage`).
1644
+ */
1582
1645
  owner_id?: string | null;
1583
1646
  /**
1584
1647
  * mashup_contact_ids to link. Must belong to the deal's company (if the deal
@@ -1678,6 +1741,296 @@ declare const createDealsClient: (apiKey: string, apiUrl?: string) => {
1678
1741
  }>;
1679
1742
  };
1680
1743
 
1744
+ /** A custom object type in your workspace — a record type you define. */
1745
+ interface CustomObject {
1746
+ /** Stable API slug, e.g. `invoices`. */
1747
+ slug: string;
1748
+ singular_noun: string;
1749
+ plural_noun: string;
1750
+ /** True for object types graph8 ships; system objects cannot be deleted. */
1751
+ is_system: boolean;
1752
+ is_archived: boolean;
1753
+ }
1754
+ /**
1755
+ * One attribute on a custom object, and the rules its values must satisfy.
1756
+ *
1757
+ * `attribute_type` is one of 16 supported types and decides how a value is
1758
+ * validated and canonicalized: `text`, `number`, `currency`, `date`,
1759
+ * `timestamp`, `checkbox`, `select`, `status`, `email_address`, `phone_number`,
1760
+ * `domain`, `location`, `personal_name`, `record_reference`, `rating`,
1761
+ * `actor_reference`.
1762
+ */
1763
+ interface CustomObjectAttribute {
1764
+ slug: string;
1765
+ attribute_type: string;
1766
+ is_required: boolean;
1767
+ /** No two ACTIVE records may hold the same value. A collision returns 409. */
1768
+ is_unique: boolean;
1769
+ is_multiselect: boolean;
1770
+ /** Type-specific configuration, e.g. the allowed options for a `select`. */
1771
+ config: Record<string, unknown>;
1772
+ }
1773
+ /** One record, with its currently active attribute values. */
1774
+ interface CustomObjectRecord {
1775
+ id: string;
1776
+ object_slug: string;
1777
+ /**
1778
+ * Values keyed by attribute slug. Untyped by necessity — the valid keys come
1779
+ * from YOUR attribute definitions at runtime, so call `listAttributes` for the
1780
+ * schema. Saying `any` here would imply the shape was considered and found to
1781
+ * be free.
1782
+ */
1783
+ values: Record<string, unknown>;
1784
+ is_archived: boolean;
1785
+ created_at: string | null;
1786
+ updated_at: string | null;
1787
+ }
1788
+ /** One generation of one attribute's value. */
1789
+ interface CustomObjectHistoryEntry {
1790
+ attribute: string;
1791
+ value: unknown;
1792
+ active_from: string | null;
1793
+ /** Null means this value is still in force. */
1794
+ active_until: string | null;
1795
+ actor_id: string | null;
1796
+ }
1797
+ interface CustomObjectHistory {
1798
+ record_id: string;
1799
+ entries: CustomObjectHistoryEntry[];
1800
+ }
1801
+ interface ListRecordsParams {
1802
+ page?: number;
1803
+ /** 1-200, default 50. */
1804
+ limit?: number;
1805
+ /** Opaque cursor from a prior response. Takes precedence over `page`. */
1806
+ cursor?: string;
1807
+ }
1808
+ /**
1809
+ * Pagination envelope for record listings.
1810
+ *
1811
+ * Named distinctly rather than `PaginationMeta`: `deals.ts` and `quotes.ts` each
1812
+ * already declare their own structurally identical `PaginationMeta`, and one of
1813
+ * them is re-exported from `index.ts` — so a third with that name is a
1814
+ * `TS2300: Duplicate identifier` at the package's export site. Consolidating the
1815
+ * three into one shared type is worth doing and is not this change.
1816
+ */
1817
+ interface ObjectPagination {
1818
+ page: number;
1819
+ limit: number;
1820
+ total: number;
1821
+ has_next: boolean;
1822
+ next_cursor: string | null;
1823
+ }
1824
+ /**
1825
+ * Custom Objects API — your own record types, their schema, and their records (M6-3).
1826
+ * Requires an API key (server-side). On the hardened HTTP core: throws a typed
1827
+ * `G8Error` on failure and retries transient errors.
1828
+ *
1829
+ * PREVIEW AND GATED. Every endpoint returns 403 `app_not_enabled` until the
1830
+ * custom-objects surface is switched on for the platform. It is off by default,
1831
+ * so a call fails fast rather than returning an empty list that reads as "you
1832
+ * have no objects".
1833
+ *
1834
+ * HOW THIS DIFFERS FROM `g8.fields`. A FIELD adds a column to an existing
1835
+ * contact or company. A CUSTOM OBJECT is a whole new record type with its own
1836
+ * attributes and its own records. Use fields to extend a contact; use custom
1837
+ * objects to model an invoice, a shipment, or a subscription.
1838
+ *
1839
+ * THREE BEHAVIOURS WORTH KNOWING BEFORE YOU WRITE
1840
+ *
1841
+ * 1. An unknown field is REJECTED (422), not ignored. A typo does not silently
1842
+ * lose your data, and the response lists every problem at once so a payload
1843
+ * with three mistakes takes one round trip to fix.
1844
+ * 2. `update` is a PARTIAL write. Attributes you omit are left alone; sending
1845
+ * an explicit `null` CLEARS one. The two are deliberately different.
1846
+ * 3. `archive` does not destroy anything. The record leaves listings, stays
1847
+ * readable by id, and keeps its history.
1848
+ *
1849
+ * Backed by:
1850
+ * GET /api/v1/objects
1851
+ * GET /api/v1/objects/{slug}
1852
+ * GET /api/v1/objects/{slug}/attributes
1853
+ * GET /api/v1/objects/{slug}/records
1854
+ * POST /api/v1/objects/{slug}/records
1855
+ * GET /api/v1/objects/{slug}/records/{id}
1856
+ * PATCH /api/v1/objects/{slug}/records/{id}
1857
+ * DELETE /api/v1/objects/{slug}/records/{id}
1858
+ * GET /api/v1/objects/{slug}/records/{id}/history
1859
+ */
1860
+ declare const createObjectsClient: (apiKey: string, apiUrl?: string) => {
1861
+ /** List the custom object types in your workspace. */
1862
+ list(): Promise<{
1863
+ data: CustomObject[];
1864
+ }>;
1865
+ /** Fetch one object type by slug. */
1866
+ get(objectSlug: string): Promise<CustomObject>;
1867
+ /** The object's attributes — the schema its records must satisfy. */
1868
+ listAttributes(objectSlug: string): Promise<{
1869
+ data: CustomObjectAttribute[];
1870
+ }>;
1871
+ /** Paginated records with their current values. Archived records are excluded. */
1872
+ listRecords(objectSlug: string, params?: ListRecordsParams): Promise<{
1873
+ data: CustomObjectRecord[];
1874
+ pagination?: ObjectPagination;
1875
+ }>;
1876
+ /**
1877
+ * Create a record. Every field is validated against the object's attributes;
1878
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1879
+ * unique attribute is a 409.
1880
+ */
1881
+ createRecord(objectSlug: string, values: Record<string, unknown>): Promise<CustomObjectRecord>;
1882
+ /** Fetch one record with its currently active values. */
1883
+ getRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
1884
+ /**
1885
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1886
+ * required attributes you omit are left alone rather than reported missing.
1887
+ * Sending an explicit `null` CLEARS that attribute.
1888
+ *
1889
+ * Values are versioned rather than overwritten, so the previous value stays
1890
+ * readable through `history`.
1891
+ */
1892
+ updateRecord(objectSlug: string, recordId: string, values: Record<string, unknown>): Promise<CustomObjectRecord>;
1893
+ /**
1894
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1895
+ * history and associations. Nothing is destroyed.
1896
+ */
1897
+ archiveRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
1898
+ /**
1899
+ * A record's value timeline, newest first. An entry whose `active_until` is
1900
+ * null is the value currently in force.
1901
+ */
1902
+ history(objectSlug: string, recordId: string, limit?: number): Promise<CustomObjectHistory>;
1903
+ };
1904
+
1905
+ /**
1906
+ * App lifecycle. `draft` serves no traffic; `published` is live; `suspended` is a
1907
+ * platform action and cannot be set through this client; `archived` is retired.
1908
+ *
1909
+ * `active` is the pre-D12c spelling of `published` and is still accepted on write
1910
+ * by the backend, so an older caller keeps working. Prefer `published`.
1911
+ */
1912
+ type AppStatus = "draft" | "published" | "suspended" | "archived";
1913
+ /** An app you build on graph8, which your customers install into their workspace. */
1914
+ interface App {
1915
+ app_id: string;
1916
+ builder_org_id: string;
1917
+ /** Stable identifier, unique within your organization — not globally. */
1918
+ slug: string;
1919
+ name: string;
1920
+ status: string;
1921
+ /** https-only origins a BROWSER app token may be presented from. */
1922
+ registered_origins: string[];
1923
+ default_hostname: string | null;
1924
+ created_at: string | null;
1925
+ archived_at: string | null;
1926
+ }
1927
+ /** One client organization's installation of your app. */
1928
+ interface AppInstallation {
1929
+ install_id: string;
1930
+ app_id: string;
1931
+ client_org_id: string;
1932
+ status: string;
1933
+ consented_scopes: string[];
1934
+ created_at: string | null;
1935
+ revoked_at: string | null;
1936
+ }
1937
+ /** Credits your app consumed in one calendar month. */
1938
+ interface AppUsageSummary {
1939
+ app_id: string;
1940
+ /** Calendar month, `YYYY-MM`. */
1941
+ period: string;
1942
+ total_credits: number;
1943
+ event_count: number;
1944
+ /**
1945
+ * Credits per CLIENT org — whose data was touched, not who paid. You pay for
1946
+ * all of them, so a breakdown keyed on the payer would collapse into one row.
1947
+ */
1948
+ per_client_credits: Record<string, number>;
1949
+ }
1950
+ /** A hard credit cap. `null` from `getLimit` means uncapped. */
1951
+ interface AppLimit {
1952
+ app_id: string;
1953
+ window: string;
1954
+ credit_cap: number;
1955
+ created_at: string | null;
1956
+ }
1957
+ interface AppCreateParams {
1958
+ name: string;
1959
+ /** Unique within your organization. Lowercased on write. */
1960
+ slug: string;
1961
+ /**
1962
+ * https-only origins a browser app token may be presented from. An `http://`
1963
+ * origin is rejected at registration — a bearer token sent over plain http is
1964
+ * a token disclosed to the network.
1965
+ */
1966
+ registered_origins?: string[];
1967
+ }
1968
+ /**
1969
+ * Apps API — manage the apps you build on graph8 (M6). Requires an API key
1970
+ * (server-side). On the hardened HTTP core: throws a typed `G8Error` on failure
1971
+ * and retries transient errors.
1972
+ *
1973
+ * PREVIEW AND GATED. Every endpoint returns 403 `builder_not_allowlisted` unless
1974
+ * the platform is enabled AND your organization is on the builder allowlist.
1975
+ * Both are off by default, so a call fails fast and loudly rather than returning
1976
+ * an empty list that looks like "you have no apps".
1977
+ *
1978
+ * A note on 404s: an app id belonging to ANOTHER organization returns 404, not
1979
+ * 403 — the two are deliberately indistinguishable so app ids cannot be
1980
+ * enumerated by guessing.
1981
+ *
1982
+ * Backed by:
1983
+ * GET /api/v1/apps — list your apps
1984
+ * POST /api/v1/apps — create one (starts in `draft`)
1985
+ * GET /api/v1/apps/{app_id} — fetch one
1986
+ * POST /api/v1/apps/{app_id}/status — move it through its lifecycle
1987
+ * GET /api/v1/apps/{app_id}/installs — who installed it, and their consent
1988
+ * GET /api/v1/apps/{app_id}/usage — credits consumed in a month
1989
+ * GET /api/v1/apps/{app_id}/limit — the hard cap, or null
1990
+ */
1991
+ declare const createAppsClient: (apiKey: string, apiUrl?: string) => {
1992
+ /** List your organization's apps, newest first. */
1993
+ list(): Promise<{
1994
+ data: App[];
1995
+ }>;
1996
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1997
+ get(appId: string): Promise<App>;
1998
+ /**
1999
+ * Create an app. It starts in `draft` and serves no traffic until published.
2000
+ * Throws `G8Error` (409) when the slug is already taken in your org.
2001
+ */
2002
+ create(params: AppCreateParams): Promise<App>;
2003
+ /**
2004
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
2005
+ *
2006
+ * `suspended` is excluded from the parameter type on purpose: it is the
2007
+ * platform's kill switch for an abusive app, the backend refuses it with a
2008
+ * 403, and a builder who could set it could also unset it.
2009
+ */
2010
+ setStatus(appId: string, status: Exclude<AppStatus, "suspended">): Promise<App>;
2011
+ /**
2012
+ * The client organizations that installed this app, and their consent state.
2013
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
2014
+ * tenant, this is where you see why.
2015
+ */
2016
+ listInstalls(appId: string): Promise<{
2017
+ data: AppInstallation[];
2018
+ }>;
2019
+ /**
2020
+ * Credits this app consumed in a calendar month, broken down per client org.
2021
+ * Defaults to the current month. A month with no usage returns zeroes, not a
2022
+ * 404 — "nothing happened" is an answer.
2023
+ */
2024
+ usage(appId: string, period?: string): Promise<AppUsageSummary>;
2025
+ /**
2026
+ * This app's hard credit cap, or `null` when it is uncapped.
2027
+ *
2028
+ * `null` is the real answer, not an empty object: there is no "unlimited"
2029
+ * sentinel, so an accidental zero can never read as "no limit".
2030
+ */
2031
+ getLimit(appId: string): Promise<AppLimit | null>;
2032
+ };
2033
+
1681
2034
  /** A field (column) definition on contacts or companies — base or custom. */
1682
2035
  interface Field {
1683
2036
  id: number | null;
@@ -3132,6 +3485,8 @@ declare const useG8: () => {
3132
3485
  _notes: ReturnType<typeof createNotesClient> | null;
3133
3486
  _tasks: ReturnType<typeof createTasksClient> | null;
3134
3487
  _fields: ReturnType<typeof createFieldsClient> | null;
3488
+ _apps: ReturnType<typeof createAppsClient> | null;
3489
+ _objects: ReturnType<typeof createObjectsClient> | null;
3135
3490
  _deals: ReturnType<typeof createDealsClient> | null;
3136
3491
  _inbox: ReturnType<typeof createInboxClient> | null;
3137
3492
  _quotes: ReturnType<typeof createQuotesClient> | null;
@@ -3391,6 +3746,37 @@ declare const useG8: () => {
3391
3746
  };
3392
3747
  }>;
3393
3748
  };
3749
+ get apps(): {
3750
+ list(): Promise<{
3751
+ data: App[];
3752
+ }>;
3753
+ get(appId: string): Promise<App>;
3754
+ create(params: AppCreateParams): Promise<App>;
3755
+ setStatus(appId: string, status: Exclude<AppStatus, "suspended">): Promise<App>;
3756
+ listInstalls(appId: string): Promise<{
3757
+ data: AppInstallation[];
3758
+ }>;
3759
+ usage(appId: string, period?: string): Promise<AppUsageSummary>;
3760
+ getLimit(appId: string): Promise<AppLimit | null>;
3761
+ };
3762
+ get objects(): {
3763
+ list(): Promise<{
3764
+ data: CustomObject[];
3765
+ }>;
3766
+ get(objectSlug: string): Promise<CustomObject>;
3767
+ listAttributes(objectSlug: string): Promise<{
3768
+ data: CustomObjectAttribute[];
3769
+ }>;
3770
+ listRecords(objectSlug: string, params?: ListRecordsParams): Promise<{
3771
+ data: CustomObjectRecord[];
3772
+ pagination?: ObjectPagination;
3773
+ }>;
3774
+ createRecord(objectSlug: string, values: Record<string, unknown>): Promise<CustomObjectRecord>;
3775
+ getRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
3776
+ updateRecord(objectSlug: string, recordId: string, values: Record<string, unknown>): Promise<CustomObjectRecord>;
3777
+ archiveRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
3778
+ history(objectSlug: string, recordId: string, limit?: number): Promise<CustomObjectHistory>;
3779
+ };
3394
3780
  get deals(): {
3395
3781
  pipelines(): Promise<{
3396
3782
  data: Pipeline[];
@@ -3719,11 +4105,10 @@ declare const useG8: () => {
3719
4105
  }>;
3720
4106
  urlCompanies(url: string, params?: {
3721
4107
  limit?: number;
4108
+ days?: number;
3722
4109
  date_from?: string;
3723
4110
  date_to?: string;
3724
- }): Promise<{
3725
- data: IntentCompany[];
3726
- }>;
4111
+ }): Promise<IntentUrlCompaniesResponse>;
3727
4112
  };
3728
4113
  get studio(): {
3729
4114
  globalContext(params?: {