@graph8/sdk 0.12.2 → 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/index.d.mts +330 -3
- package/dist/index.d.ts +330 -3
- package/dist/index.js +232 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +232 -32
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +323 -0
- package/dist/react.d.ts +323 -0
- package/dist/react.js +232 -32
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +232 -32
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.d.mts
CHANGED
|
@@ -1741,6 +1741,296 @@ 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
|
+
/** 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
|
+
|
|
1744
2034
|
/** A field (column) definition on contacts or companies — base or custom. */
|
|
1745
2035
|
interface Field {
|
|
1746
2036
|
id: number | null;
|
|
@@ -3195,6 +3485,8 @@ declare const useG8: () => {
|
|
|
3195
3485
|
_notes: ReturnType<typeof createNotesClient> | null;
|
|
3196
3486
|
_tasks: ReturnType<typeof createTasksClient> | null;
|
|
3197
3487
|
_fields: ReturnType<typeof createFieldsClient> | null;
|
|
3488
|
+
_apps: ReturnType<typeof createAppsClient> | null;
|
|
3489
|
+
_objects: ReturnType<typeof createObjectsClient> | null;
|
|
3198
3490
|
_deals: ReturnType<typeof createDealsClient> | null;
|
|
3199
3491
|
_inbox: ReturnType<typeof createInboxClient> | null;
|
|
3200
3492
|
_quotes: ReturnType<typeof createQuotesClient> | null;
|
|
@@ -3454,6 +3746,37 @@ declare const useG8: () => {
|
|
|
3454
3746
|
};
|
|
3455
3747
|
}>;
|
|
3456
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
|
+
};
|
|
3457
3780
|
get deals(): {
|
|
3458
3781
|
pipelines(): Promise<{
|
|
3459
3782
|
data: Pipeline[];
|
package/dist/react.d.ts
CHANGED
|
@@ -1741,6 +1741,296 @@ 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
|
+
/** 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
|
+
|
|
1744
2034
|
/** A field (column) definition on contacts or companies — base or custom. */
|
|
1745
2035
|
interface Field {
|
|
1746
2036
|
id: number | null;
|
|
@@ -3195,6 +3485,8 @@ declare const useG8: () => {
|
|
|
3195
3485
|
_notes: ReturnType<typeof createNotesClient> | null;
|
|
3196
3486
|
_tasks: ReturnType<typeof createTasksClient> | null;
|
|
3197
3487
|
_fields: ReturnType<typeof createFieldsClient> | null;
|
|
3488
|
+
_apps: ReturnType<typeof createAppsClient> | null;
|
|
3489
|
+
_objects: ReturnType<typeof createObjectsClient> | null;
|
|
3198
3490
|
_deals: ReturnType<typeof createDealsClient> | null;
|
|
3199
3491
|
_inbox: ReturnType<typeof createInboxClient> | null;
|
|
3200
3492
|
_quotes: ReturnType<typeof createQuotesClient> | null;
|
|
@@ -3454,6 +3746,37 @@ declare const useG8: () => {
|
|
|
3454
3746
|
};
|
|
3455
3747
|
}>;
|
|
3456
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
|
+
};
|
|
3457
3780
|
get deals(): {
|
|
3458
3781
|
pipelines(): Promise<{
|
|
3459
3782
|
data: Pipeline[];
|