@graph8/sdk 0.12.2 → 0.13.1

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
@@ -1741,6 +1741,309 @@ declare const createDealsClient: (apiKey: string, apiUrl?: string) => {
1741
1741
  }>;
1742
1742
  };
1743
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
+ /** Apply a non-null default to omitted create fields, never PATCH. Absent on older servers. */
1771
+ is_default_value_enabled?: boolean;
1772
+ /** Configured default; validated like an explicit value when enabled. */
1773
+ default_value?: unknown;
1774
+ /** Type-specific configuration, e.g. the allowed options for a `select`. */
1775
+ config: Record<string, unknown>;
1776
+ }
1777
+ /** One record, with its currently active attribute values. */
1778
+ interface CustomObjectRecord {
1779
+ id: string;
1780
+ object_slug: string;
1781
+ /**
1782
+ * Values keyed by attribute slug. Untyped by necessity — the valid keys come
1783
+ * from YOUR attribute definitions at runtime, so call `listAttributes` for the
1784
+ * schema. Saying `any` here would imply the shape was considered and found to
1785
+ * be free.
1786
+ */
1787
+ values: Record<string, unknown>;
1788
+ is_archived: boolean;
1789
+ /** Revision for conditional updates; absent on older servers. */
1790
+ revision?: number;
1791
+ created_at: string | null;
1792
+ updated_at: string | null;
1793
+ }
1794
+ /** One generation of one attribute's value. */
1795
+ interface CustomObjectHistoryEntry {
1796
+ attribute: string;
1797
+ value: unknown;
1798
+ active_from: string | null;
1799
+ /** Null means this value is still in force. */
1800
+ active_until: string | null;
1801
+ actor_id: string | null;
1802
+ }
1803
+ interface CustomObjectHistory {
1804
+ record_id: string;
1805
+ entries: CustomObjectHistoryEntry[];
1806
+ }
1807
+ interface ListRecordsParams {
1808
+ page?: number;
1809
+ /** 1-200, default 50. */
1810
+ limit?: number;
1811
+ /** Opaque cursor from a prior response. Takes precedence over `page`. */
1812
+ cursor?: string;
1813
+ }
1814
+ /**
1815
+ * Pagination envelope for record listings.
1816
+ *
1817
+ * Named distinctly rather than `PaginationMeta`: `deals.ts` and `quotes.ts` each
1818
+ * already declare their own structurally identical `PaginationMeta`, and one of
1819
+ * them is re-exported from `index.ts` — so a third with that name is a
1820
+ * `TS2300: Duplicate identifier` at the package's export site. Consolidating the
1821
+ * three into one shared type is worth doing and is not this change.
1822
+ */
1823
+ interface ObjectPagination {
1824
+ page: number;
1825
+ limit: number;
1826
+ total: number;
1827
+ has_next: boolean;
1828
+ next_cursor: string | null;
1829
+ }
1830
+ /**
1831
+ * Custom Objects API — your own record types, their schema, and their records (M6-3).
1832
+ * Requires an API key (server-side). On the hardened HTTP core: throws a typed
1833
+ * `G8Error` on failure and retries transient errors.
1834
+ *
1835
+ * Access requires an authenticated credential with the applicable object scope.
1836
+ *
1837
+ * HOW THIS DIFFERS FROM `g8.fields`. A FIELD adds a column to an existing
1838
+ * contact or company. A CUSTOM OBJECT is a whole new record type with its own
1839
+ * attributes and its own records. Use fields to extend a contact; use custom
1840
+ * objects to model an invoice, a shipment, or a subscription.
1841
+ *
1842
+ * THREE BEHAVIOURS WORTH KNOWING BEFORE YOU WRITE
1843
+ *
1844
+ * 1. An unknown field is REJECTED (422), not ignored. A typo does not silently
1845
+ * lose your data, and the response lists every problem at once so a payload
1846
+ * with three mistakes takes one round trip to fix.
1847
+ * 2. `update` is a PARTIAL write. Attributes you omit are left alone; sending
1848
+ * an explicit `null` clears an optional attribute. Required attributes
1849
+ * cannot be cleared with `null` or an empty multivalue list (422).
1850
+ * 3. `archive` does not destroy anything. The record leaves listings, stays
1851
+ * readable by id, and keeps its history.
1852
+ *
1853
+ * Record references must resolve to an active record of `config.target_object`
1854
+ * within the same organization and app. Unavailable targets return a 422 with
1855
+ * `invalid_reference` in the field error's `reason`, without disclosing whether
1856
+ * a target exists outside the caller's scope.
1857
+ *
1858
+ * Backed by:
1859
+ * GET /api/v1/objects
1860
+ * GET /api/v1/objects/{slug}
1861
+ * GET /api/v1/objects/{slug}/attributes
1862
+ * GET /api/v1/objects/{slug}/records
1863
+ * POST /api/v1/objects/{slug}/records
1864
+ * GET /api/v1/objects/{slug}/records/{id}
1865
+ * PATCH /api/v1/objects/{slug}/records/{id}
1866
+ * DELETE /api/v1/objects/{slug}/records/{id}
1867
+ * GET /api/v1/objects/{slug}/records/{id}/history
1868
+ */
1869
+ declare const createObjectsClient: (apiKey: string, apiUrl?: string) => {
1870
+ /** List the custom object types in your workspace. */
1871
+ list(): Promise<{
1872
+ data: CustomObject[];
1873
+ }>;
1874
+ /** Fetch one object type by slug. */
1875
+ get(objectSlug: string): Promise<CustomObject>;
1876
+ /** The object's attributes — the schema its records must satisfy. */
1877
+ listAttributes(objectSlug: string): Promise<{
1878
+ data: CustomObjectAttribute[];
1879
+ }>;
1880
+ /** Paginated records with their current values. Archived records are excluded. */
1881
+ listRecords(objectSlug: string, params?: ListRecordsParams): Promise<{
1882
+ data: CustomObjectRecord[];
1883
+ pagination?: ObjectPagination;
1884
+ }>;
1885
+ /**
1886
+ * Create a record. Every field is validated against the object's attributes;
1887
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1888
+ * unique attribute is a 409.
1889
+ */
1890
+ createRecord(objectSlug: string, values: Record<string, unknown>): Promise<CustomObjectRecord>;
1891
+ /** Fetch one record with its currently active values. */
1892
+ getRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
1893
+ /**
1894
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1895
+ * required attributes you omit are left alone rather than reported missing.
1896
+ * Sending an explicit `null` CLEARS that attribute.
1897
+ *
1898
+ * Values are versioned rather than overwritten, so the previous value stays
1899
+ * readable through `history`.
1900
+ */
1901
+ updateRecord(objectSlug: string, recordId: string, values: Record<string, unknown>, options?: {
1902
+ expectedRevision?: number;
1903
+ }): Promise<CustomObjectRecord>;
1904
+ /**
1905
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1906
+ * history and associations. Nothing is destroyed.
1907
+ */
1908
+ archiveRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
1909
+ /** Restore archived values under current constraints. Conflicts leave the record archived. */
1910
+ restoreRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
1911
+ /**
1912
+ * A record's value timeline, newest first. An entry whose `active_until` is
1913
+ * null is the value currently in force.
1914
+ */
1915
+ history(objectSlug: string, recordId: string, limit?: number): Promise<CustomObjectHistory>;
1916
+ };
1917
+
1918
+ /**
1919
+ * App lifecycle. `draft` serves no traffic; `published` is live; `suspended` is a
1920
+ * platform action and cannot be set through this client; `archived` is retired.
1921
+ *
1922
+ * `active` is the pre-D12c spelling of `published` and is still accepted on write
1923
+ * by the backend, so an older caller keeps working. Prefer `published`.
1924
+ */
1925
+ type AppStatus = "draft" | "published" | "suspended" | "archived";
1926
+ /** An app you build on graph8, which your customers install into their workspace. */
1927
+ interface App {
1928
+ app_id: string;
1929
+ builder_org_id: string;
1930
+ /** Stable identifier, unique within your organization — not globally. */
1931
+ slug: string;
1932
+ name: string;
1933
+ status: string;
1934
+ /** https-only origins a BROWSER app token may be presented from. */
1935
+ registered_origins: string[];
1936
+ default_hostname: string | null;
1937
+ created_at: string | null;
1938
+ archived_at: string | null;
1939
+ }
1940
+ /** One client organization's installation of your app. */
1941
+ interface AppInstallation {
1942
+ install_id: string;
1943
+ app_id: string;
1944
+ client_org_id: string;
1945
+ status: string;
1946
+ consented_scopes: string[];
1947
+ created_at: string | null;
1948
+ revoked_at: string | null;
1949
+ }
1950
+ /** Credits your app consumed in one calendar month. */
1951
+ interface AppUsageSummary {
1952
+ app_id: string;
1953
+ /** Calendar month, `YYYY-MM`. */
1954
+ period: string;
1955
+ total_credits: number;
1956
+ event_count: number;
1957
+ /**
1958
+ * Credits per CLIENT org — whose data was touched, not who paid. You pay for
1959
+ * all of them, so a breakdown keyed on the payer would collapse into one row.
1960
+ */
1961
+ per_client_credits: Record<string, number>;
1962
+ }
1963
+ /** A hard credit cap. `null` from `getLimit` means uncapped. */
1964
+ interface AppLimit {
1965
+ app_id: string;
1966
+ window: string;
1967
+ credit_cap: number;
1968
+ created_at: string | null;
1969
+ }
1970
+ interface AppCreateParams {
1971
+ name: string;
1972
+ /** Unique within your organization. Lowercased on write. */
1973
+ slug: string;
1974
+ /**
1975
+ * https-only origins a browser app token may be presented from. An `http://`
1976
+ * origin is rejected at registration — a bearer token sent over plain http is
1977
+ * a token disclosed to the network.
1978
+ */
1979
+ registered_origins?: string[];
1980
+ }
1981
+ /**
1982
+ * Apps API — manage the apps you build on graph8 (M6). Requires an API key
1983
+ * (server-side). On the hardened HTTP core: throws a typed `G8Error` on failure
1984
+ * and retries transient errors.
1985
+ *
1986
+ * PREVIEW AND GATED. Every endpoint returns 403 `builder_not_allowlisted` unless
1987
+ * the platform is enabled AND your organization is on the builder allowlist.
1988
+ * Both are off by default, so a call fails fast and loudly rather than returning
1989
+ * an empty list that looks like "you have no apps".
1990
+ *
1991
+ * A note on 404s: an app id belonging to ANOTHER organization returns 404, not
1992
+ * 403 — the two are deliberately indistinguishable so app ids cannot be
1993
+ * enumerated by guessing.
1994
+ *
1995
+ * Backed by:
1996
+ * GET /api/v1/apps — list your apps
1997
+ * POST /api/v1/apps — create one (starts in `draft`)
1998
+ * GET /api/v1/apps/{app_id} — fetch one
1999
+ * POST /api/v1/apps/{app_id}/status — move it through its lifecycle
2000
+ * GET /api/v1/apps/{app_id}/installs — who installed it, and their consent
2001
+ * GET /api/v1/apps/{app_id}/usage — credits consumed in a month
2002
+ * GET /api/v1/apps/{app_id}/limit — the hard cap, or null
2003
+ */
2004
+ declare const createAppsClient: (apiKey: string, apiUrl?: string) => {
2005
+ /** List your organization's apps, newest first. */
2006
+ list(): Promise<{
2007
+ data: App[];
2008
+ }>;
2009
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
2010
+ get(appId: string): Promise<App>;
2011
+ /**
2012
+ * Create an app. It starts in `draft` and serves no traffic until published.
2013
+ * Throws `G8Error` (409) when the slug is already taken in your org.
2014
+ */
2015
+ create(params: AppCreateParams): Promise<App>;
2016
+ /**
2017
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
2018
+ *
2019
+ * `suspended` is excluded from the parameter type on purpose: it is the
2020
+ * platform's kill switch for an abusive app, the backend refuses it with a
2021
+ * 403, and a builder who could set it could also unset it.
2022
+ */
2023
+ setStatus(appId: string, status: Exclude<AppStatus, "suspended">): Promise<App>;
2024
+ /**
2025
+ * The client organizations that installed this app, and their consent state.
2026
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
2027
+ * tenant, this is where you see why.
2028
+ */
2029
+ listInstalls(appId: string): Promise<{
2030
+ data: AppInstallation[];
2031
+ }>;
2032
+ /**
2033
+ * Credits this app consumed in a calendar month, broken down per client org.
2034
+ * Defaults to the current month. A month with no usage returns zeroes, not a
2035
+ * 404 — "nothing happened" is an answer.
2036
+ */
2037
+ usage(appId: string, period?: string): Promise<AppUsageSummary>;
2038
+ /**
2039
+ * This app's hard credit cap, or `null` when it is uncapped.
2040
+ *
2041
+ * `null` is the real answer, not an empty object: there is no "unlimited"
2042
+ * sentinel, so an accidental zero can never read as "no limit".
2043
+ */
2044
+ getLimit(appId: string): Promise<AppLimit | null>;
2045
+ };
2046
+
1744
2047
  /** A field (column) definition on contacts or companies — base or custom. */
1745
2048
  interface Field {
1746
2049
  id: number | null;
@@ -3195,6 +3498,8 @@ declare const useG8: () => {
3195
3498
  _notes: ReturnType<typeof createNotesClient> | null;
3196
3499
  _tasks: ReturnType<typeof createTasksClient> | null;
3197
3500
  _fields: ReturnType<typeof createFieldsClient> | null;
3501
+ _apps: ReturnType<typeof createAppsClient> | null;
3502
+ _objects: ReturnType<typeof createObjectsClient> | null;
3198
3503
  _deals: ReturnType<typeof createDealsClient> | null;
3199
3504
  _inbox: ReturnType<typeof createInboxClient> | null;
3200
3505
  _quotes: ReturnType<typeof createQuotesClient> | null;
@@ -3454,6 +3759,40 @@ declare const useG8: () => {
3454
3759
  };
3455
3760
  }>;
3456
3761
  };
3762
+ get apps(): {
3763
+ list(): Promise<{
3764
+ data: App[];
3765
+ }>;
3766
+ get(appId: string): Promise<App>;
3767
+ create(params: AppCreateParams): Promise<App>;
3768
+ setStatus(appId: string, status: Exclude<AppStatus, "suspended">): Promise<App>;
3769
+ listInstalls(appId: string): Promise<{
3770
+ data: AppInstallation[];
3771
+ }>;
3772
+ usage(appId: string, period?: string): Promise<AppUsageSummary>;
3773
+ getLimit(appId: string): Promise<AppLimit | null>;
3774
+ };
3775
+ get objects(): {
3776
+ list(): Promise<{
3777
+ data: CustomObject[];
3778
+ }>;
3779
+ get(objectSlug: string): Promise<CustomObject>;
3780
+ listAttributes(objectSlug: string): Promise<{
3781
+ data: CustomObjectAttribute[];
3782
+ }>;
3783
+ listRecords(objectSlug: string, params?: ListRecordsParams): Promise<{
3784
+ data: CustomObjectRecord[];
3785
+ pagination?: ObjectPagination;
3786
+ }>;
3787
+ createRecord(objectSlug: string, values: Record<string, unknown>): Promise<CustomObjectRecord>;
3788
+ getRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
3789
+ updateRecord(objectSlug: string, recordId: string, values: Record<string, unknown>, options?: {
3790
+ expectedRevision?: number;
3791
+ }): Promise<CustomObjectRecord>;
3792
+ archiveRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
3793
+ restoreRecord(objectSlug: string, recordId: string): Promise<CustomObjectRecord>;
3794
+ history(objectSlug: string, recordId: string, limit?: number): Promise<CustomObjectHistory>;
3795
+ };
3457
3796
  get deals(): {
3458
3797
  pipelines(): Promise<{
3459
3798
  data: Pipeline[];