@graph8/sdk 0.7.2 → 0.12.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/README.md +67 -39
- package/dist/index.d.mts +416 -164
- package/dist/index.d.ts +416 -164
- package/dist/index.js +291 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +284 -178
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +186 -156
- package/dist/react.d.ts +186 -156
- package/dist/react.js +115 -178
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +115 -178
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ const { data: listContacts } = await g8.lists.contacts(list.id);
|
|
|
70
70
|
// Enrich a person
|
|
71
71
|
const person = await g8.enrich.person({ email: 'jane@acme.com' });
|
|
72
72
|
|
|
73
|
-
// Search
|
|
73
|
+
// Search 700M+ contacts
|
|
74
74
|
const leads = await g8.enrich.search([
|
|
75
75
|
{ field: 'seniority_level', operator: 'any_of', value: ['VP', 'Director'] },
|
|
76
76
|
{ field: 'company_industry', operator: 'contains', value: ['SaaS'] },
|
|
@@ -88,14 +88,6 @@ await g8.campaigns.launch(campaign.id);
|
|
|
88
88
|
const signals = await g8.signals.company('acme.com');
|
|
89
89
|
// { score: 87, intent: 'high', signals: ['pricing_page_3x', 'case_study'] }
|
|
90
90
|
|
|
91
|
-
// Voice AI
|
|
92
|
-
const call = await g8.voice.start({ agent: 'sales-discovery', contactId: 123 });
|
|
93
|
-
const analysis = await g8.voice.analysis(call.id);
|
|
94
|
-
|
|
95
|
-
// Landing pages
|
|
96
|
-
const page = await g8.pages.clone('https://competitor.com/pricing');
|
|
97
|
-
const { url } = await g8.pages.publish(page.id);
|
|
98
|
-
|
|
99
91
|
// Webhook events (push model — verify each delivery server-side)
|
|
100
92
|
app.post('/webhooks/graph8', (req, res) => {
|
|
101
93
|
const event = g8.webhooks.constructEvent(
|
|
@@ -116,10 +108,25 @@ app.post('/webhooks/graph8', (req, res) => {
|
|
|
116
108
|
import { G8Provider, useG8 } from '@graph8/sdk/react';
|
|
117
109
|
|
|
118
110
|
// Layout
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
export const Layout = ({ children }: { children: React.ReactNode }) => (
|
|
112
|
+
<G8Provider writeKey="YOUR_WRITE_KEY">{children}</G8Provider>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Any component. `useG8()` exposes the tracking calls, the progressive-form
|
|
116
|
+
// helpers, and the raw client — reach the rest of the surface through `g8`.
|
|
117
|
+
export const CTA = () => {
|
|
118
|
+
const { track, identify, page, reset, forms, g8 } = useG8();
|
|
119
|
+
return (
|
|
120
|
+
<button
|
|
121
|
+
onClick={() => {
|
|
122
|
+
track('cta_click', { placement: 'hero' });
|
|
123
|
+
g8.copilot.open({ greeting: 'How can I help?' });
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
Talk to us
|
|
127
|
+
</button>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
123
130
|
```
|
|
124
131
|
|
|
125
132
|
## Full API Reference
|
|
@@ -213,7 +220,7 @@ const { track, identify, visitors, copilot, calendar } = useG8();
|
|
|
213
220
|
| `g8.enrich.person(params)` | Look up a person (1 credit) |
|
|
214
221
|
| `g8.enrich.company(params)` | Look up a company (1 credit) |
|
|
215
222
|
| `g8.enrich.verifyEmail(email)` | Verify email (1 credit) |
|
|
216
|
-
| `g8.enrich.search(filters)` | Search
|
|
223
|
+
| `g8.enrich.search(filters)` | Search 700M+ contacts |
|
|
217
224
|
|
|
218
225
|
### Sequences (API key)
|
|
219
226
|
|
|
@@ -229,7 +236,6 @@ const { track, identify, visitors, copilot, calendar } = useG8();
|
|
|
229
236
|
| `g8.campaigns.list()` | List campaigns |
|
|
230
237
|
| `g8.campaigns.create(config)` | Create campaign |
|
|
231
238
|
| `g8.campaigns.launch(id)` | Launch campaign |
|
|
232
|
-
| `g8.campaigns.stats(id)` | Get campaign stats |
|
|
233
239
|
|
|
234
240
|
### Signals (write key or API key)
|
|
235
241
|
|
|
@@ -238,41 +244,63 @@ const { track, identify, visitors, copilot, calendar } = useG8();
|
|
|
238
244
|
| `g8.signals.company(domain)` | Get intent signals |
|
|
239
245
|
| `g8.signals.stream(domains, cb)` | Stream signals (polls 30s) |
|
|
240
246
|
|
|
241
|
-
###
|
|
247
|
+
### Webhooks (API key)
|
|
242
248
|
|
|
243
249
|
| Method | Description |
|
|
244
250
|
|--------|-------------|
|
|
245
|
-
| `g8.
|
|
251
|
+
| `g8.webhooks.constructEvent(body, sig, ts, secret, opts?)` | Verify a delivery's HMAC signature and return the parsed event (throws `WebhookSignatureError`) |
|
|
252
|
+
| `g8.webhooks.knownEvents` | The known event-type catalog |
|
|
246
253
|
|
|
247
|
-
|
|
254
|
+
## App Platform
|
|
248
255
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
256
|
+
Hosted apps do not carry a permanent org API key. Instead they **exchange** a
|
|
257
|
+
longer-lived credential for a short-lived graph8 app token, and the client
|
|
258
|
+
mints, refreshes, and attaches it for you. Both clients expose a token-bound
|
|
259
|
+
`request()` that reaches the existing Developer API resources with the app
|
|
260
|
+
token.
|
|
254
261
|
|
|
255
|
-
###
|
|
262
|
+
### Browser (PropelAuth token exchange)
|
|
256
263
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
```typescript
|
|
265
|
+
import { createGraph8AppClient } from '@graph8/sdk';
|
|
266
|
+
|
|
267
|
+
// Exchange the signed-in user's PropelAuth token for a short-lived graph8 app
|
|
268
|
+
// token. The client refreshes it on/near expiry and attaches
|
|
269
|
+
// `Authorization: Bearer <app-token>` to every call — no API key in the browser.
|
|
270
|
+
const appClient = createGraph8AppClient({
|
|
271
|
+
appId: 'dapp_your_app',
|
|
272
|
+
tenantOrgId: 'org_customer',
|
|
273
|
+
scopes: ['objects:read'],
|
|
274
|
+
getPropelAuthToken: () => localStorage.getItem('propelauth_token') ?? '',
|
|
275
|
+
});
|
|
261
276
|
|
|
262
|
-
|
|
277
|
+
// Reach the existing resources with the app token via request():
|
|
278
|
+
const { data: contacts } = await appClient.request<{ data: unknown[] }>(
|
|
279
|
+
'/api/v1/contacts',
|
|
280
|
+
{ query: { limit: 10 } },
|
|
281
|
+
);
|
|
282
|
+
```
|
|
263
283
|
|
|
264
|
-
|
|
265
|
-
|--------|-------------|
|
|
266
|
-
| `g8.pages.clone(url)` | Clone from URL |
|
|
267
|
-
| `g8.pages.create(config)` | Create from template |
|
|
268
|
-
| `g8.pages.publish(id)` | Publish to CDN |
|
|
284
|
+
### Backend (service credentials)
|
|
269
285
|
|
|
270
|
-
|
|
286
|
+
```typescript
|
|
287
|
+
import { createGraph8ServiceClient } from '@graph8/sdk';
|
|
288
|
+
|
|
289
|
+
// Exchange service client-credentials for a service token. Every call is pinned
|
|
290
|
+
// to the one consented tenant via the `X-Target-Org-Id` header the client adds.
|
|
291
|
+
const service = createGraph8ServiceClient({
|
|
292
|
+
clientId: process.env.G8_APP_CLIENT_ID,
|
|
293
|
+
clientSecret: process.env.G8_APP_CLIENT_SECRET,
|
|
294
|
+
tenantOrgId: 'org_customer',
|
|
295
|
+
scopes: ['objects:read', 'objects:write'],
|
|
296
|
+
});
|
|
271
297
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
298
|
+
const { data: rows } = await service.request<{ data: unknown[] }>('/api/v1/contacts');
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
> The typed `apps` (control-plane) and `objects` (custom-object CRUD) resource
|
|
302
|
+
> modules are deferred until their backend routes ship (M6-3 / M6-5). Until then,
|
|
303
|
+
> reach the Developer API through the token-bound `request()` shown above.
|
|
276
304
|
|
|
277
305
|
## Auth Modes
|
|
278
306
|
|