@gravity-rail/sdk 0.53.0 → 0.55.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 +89 -37
- package/dist/{chat-interaction-CklXa8iQ.d.cts → chat-interaction-CZnqOfut.d.ts} +1212 -69
- package/dist/{chat-interaction-Dei_j8Sd.d.ts → chat-interaction-DZCWRbDi.d.cts} +1212 -69
- package/dist/{chunk-6F4YJJKQ.js → chunk-BF4MOZZO.js} +339 -7
- package/dist/chunk-BF4MOZZO.js.map +1 -0
- package/dist/{chunk-MMDSZ25F.js → chunk-HXVJF54M.js} +1 -1
- package/dist/chunk-HXVJF54M.js.map +1 -0
- package/dist/helpers.d.cts +4 -4
- package/dist/helpers.d.ts +4 -4
- package/dist/index.cjs +344 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +363 -9
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +6 -5
- package/dist/internal.d.ts +6 -5
- package/dist/internal.js +33 -5
- package/dist/internal.js.map +1 -1
- package/dist/{member-import-Do6D2g14.d.ts → member-import-D1QvZiy5.d.ts} +1 -1
- package/dist/{member-import-BtTWfQ46.d.cts → member-import-DzuvKnMC.d.cts} +1 -1
- package/dist/{path-DKPLfZj4.d.ts → path-C6Ujx-3w.d.cts} +51 -53
- package/dist/{path-D1ZCbboc.d.cts → path-YfkJBAbf.d.ts} +51 -53
- package/dist/realtime.cjs +26 -0
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +17 -0
- package/dist/realtime.d.ts +17 -0
- package/dist/realtime.js +26 -0
- package/dist/realtime.js.map +1 -1
- package/dist/schemas.d.cts +2 -2
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.js +1 -1
- package/dist/{tasks-JweebIce.d.cts → tasks-BdYhYUpU.d.cts} +92 -26
- package/dist/{tasks-JweebIce.d.ts → tasks-BdYhYUpU.d.ts} +92 -26
- package/package.json +1 -1
- package/dist/chunk-6F4YJJKQ.js.map +0 -1
- package/dist/chunk-MMDSZ25F.js.map +0 -1
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ Every Gravity Rail workspace is a self-contained environment with isolated data,
|
|
|
135
135
|
| **Events** | Trigger-based automation with [CEL expressions](https://github.com/google/cel-spec) |
|
|
136
136
|
| **Calendars** | Scheduling, availability, event types, Google Calendar sync, and iCal feeds |
|
|
137
137
|
| **Files** | Folder hierarchy with semantic search, role-based sharing, and public access |
|
|
138
|
-
| **Sites** | Customer-facing portals with custom domains,
|
|
138
|
+
| **Sites** | Customer-facing portals with custom domains, managed pages, and source applications |
|
|
139
139
|
| **Communications** | Phone numbers, SMS, email inboxes, and notification rules |
|
|
140
140
|
| **Org Domains** | Register org-owned domains, verify ownership, verify email MX/DKIM/SPF, and verify site CNAMEs |
|
|
141
141
|
| **Toolkits** | Custom tools, MCP server integrations, and AI model configuration |
|
|
@@ -203,33 +203,38 @@ await client.createChatFilter(workspaceId, { name: 'Unresolved', conditions: { n
|
|
|
203
203
|
|
|
204
204
|
### Structured Data Collection
|
|
205
205
|
|
|
206
|
+
Forms are `DataType` schemas in the API. Create a Form in your Workspace, then
|
|
207
|
+
read its schema by slug or ID. This server-side example expects an existing
|
|
208
|
+
`loads` Form with the field slugs `reference` and `status`; use your own slugs:
|
|
209
|
+
|
|
206
210
|
```typescript
|
|
207
|
-
|
|
208
|
-
const dataType = await client.createDataType(workspaceId, {
|
|
209
|
-
name: 'Contact Form',
|
|
210
|
-
slug: 'contact-form',
|
|
211
|
-
is_collection: true,
|
|
212
|
-
fields: [
|
|
213
|
-
{ name: 'Full Name', field_type: 'text', required: true },
|
|
214
|
-
{ name: 'Email', field_type: 'email', required: true },
|
|
215
|
-
{ name: 'Priority', field_type: 'dropdown', options: ['Low', 'Medium', 'High'] },
|
|
216
|
-
{ name: 'Score', field_type: 'formula', formula: 'Priority == "High" ? 100 : 50' },
|
|
217
|
-
],
|
|
218
|
-
});
|
|
211
|
+
import { GravityRailClient } from '@gravity-rail/sdk';
|
|
219
212
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
const client = new GravityRailClient(
|
|
214
|
+
process.env.GRAVITY_RAIL_TOKEN!,
|
|
215
|
+
'https://api.gravityrail.com',
|
|
216
|
+
);
|
|
217
|
+
const workspace = client.workspace(process.env.GRAVITY_RAIL_WORKSPACE_UUID!);
|
|
218
|
+
const form = await workspace.getDataTypeBySlug('loads');
|
|
219
|
+
const record = await workspace.createDataRecord(form.id, {
|
|
220
|
+
dataTypeId: form.id,
|
|
221
|
+
fieldValues: { reference: 'LOAD-001', status: 'queued' },
|
|
223
222
|
});
|
|
223
|
+
const page = await workspace.getDataRecords(form.id, { page: 1, pageSize: 20 });
|
|
224
|
+
// Read page.items; request another page when needed.
|
|
224
225
|
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
match_field: 'Email',
|
|
229
|
-
field_values: { 'Email': 'alice@example.com', 'Priority': 'Medium' },
|
|
226
|
+
// Upsert uses a stable external ID, not a field name.
|
|
227
|
+
await workspace.upsertDataRecord(form.id, 'dispatch-load-002', {
|
|
228
|
+
fieldValues: { reference: 'LOAD-002', status: 'queued' },
|
|
230
229
|
});
|
|
231
230
|
```
|
|
232
231
|
|
|
232
|
+
Field values use **field slugs**, not display names. Read, write, row, and field
|
|
233
|
+
permissions still apply. Writes can return a value-free receipt when read access
|
|
234
|
+
is absent; use an authorized record read to display stored values. For app-side
|
|
235
|
+
loading, editing, and navigation, use the
|
|
236
|
+
[React Forms and records example](https://docs.gravityrail.com/developer/libraries/react#quick-start).
|
|
237
|
+
|
|
233
238
|
### Communication Channels
|
|
234
239
|
|
|
235
240
|
```typescript
|
|
@@ -365,28 +370,75 @@ const operators = await client.getLiveOperators(workspaceId);
|
|
|
365
370
|
|
|
366
371
|
### Sites & Portals
|
|
367
372
|
|
|
368
|
-
Site
|
|
369
|
-
|
|
370
|
-
|
|
373
|
+
Choose Site visibility, the roles that can sign in, and record access separately.
|
|
374
|
+
Create a private source Site with no record scope opt-ins, then set its role
|
|
375
|
+
audience. This example runs on your server; replace the environment variables
|
|
376
|
+
with your OAuth token, workspace UUID, and the **Member Role UUID** from that
|
|
377
|
+
workspace (not its numeric ID):
|
|
371
378
|
|
|
372
379
|
```typescript
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
import { AccessLevel, GravityRailClient } from '@gravity-rail/sdk';
|
|
381
|
+
|
|
382
|
+
const client = new GravityRailClient(
|
|
383
|
+
process.env.GRAVITY_RAIL_TOKEN!,
|
|
384
|
+
'https://api.gravityrail.com'
|
|
385
|
+
);
|
|
386
|
+
const workspace = client.workspace(process.env.GRAVITY_RAIL_WORKSPACE_UUID!);
|
|
387
|
+
const memberRoleUuid = process.env.GRAVITY_RAIL_MEMBER_ROLE_UUID!;
|
|
388
|
+
const site = await workspace.createSite({
|
|
389
|
+
name: 'Operations',
|
|
390
|
+
theme: 'source-site',
|
|
391
|
+
isPublic: false,
|
|
392
|
+
allowSignup: false,
|
|
393
|
+
allowedScopes: [],
|
|
378
394
|
});
|
|
379
395
|
|
|
380
|
-
await
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
396
|
+
await workspace.updateSiteSharing(site.id, {
|
|
397
|
+
access: AccessLevel.PRIVATE,
|
|
398
|
+
shareable: false,
|
|
399
|
+
grants: [],
|
|
400
|
+
audience: [memberRoleUuid],
|
|
384
401
|
});
|
|
385
402
|
|
|
386
|
-
//
|
|
387
|
-
await
|
|
403
|
+
// A Site admin enables only the operations this app needs.
|
|
404
|
+
await workspace.updateSite(site.id, {
|
|
405
|
+
allowedScopes: ['records:read', 'records:write'],
|
|
406
|
+
});
|
|
388
407
|
```
|
|
389
408
|
|
|
409
|
+
The empty grants above apply to a **new** Site. To change an existing Site, read
|
|
410
|
+
`getSiteSharing(site.id)` first and preserve the access, shareability, grants,
|
|
411
|
+
and audience entries you are not changing. The update replaces the submitted
|
|
412
|
+
sharing lists.
|
|
413
|
+
|
|
414
|
+
| Setting | What it controls |
|
|
415
|
+
| ------------------------------------ | ----------------------------------------------------------------------------------------- |
|
|
416
|
+
| `isPublic` | Whether visitors can open the Site; public visibility does not make records public. |
|
|
417
|
+
| Sharing `audience` | The Member Role UUIDs whose Members can sign in through the Site. |
|
|
418
|
+
| `allowedScopes` | Record read, write, or admin operations allowed through a Site session. Defaults to `[]`. |
|
|
419
|
+
| `allowSignup` / `signupMemberRoleId` | Whether new Members may join and the numeric role ID assigned to them. |
|
|
420
|
+
|
|
421
|
+
A Site session is still limited by the Member's current role and Form, record,
|
|
422
|
+
and field permissions. Read and write opt-ins are independent. Existing own-Form
|
|
423
|
+
submission permissions still apply. `records:admin` is an explicit opt-in for
|
|
424
|
+
record administration, including deletion; enable it only for an app that needs
|
|
425
|
+
it and Members whose roles already permit it. A workspace UUID supplies context,
|
|
426
|
+
not authentication. A 403 needs a permission check, not a broader allowlist.
|
|
427
|
+
|
|
428
|
+
Record writes may return a successful value-free receipt (`fieldValues` is
|
|
429
|
+
empty and Member identifiers are null) when the caller cannot read stored
|
|
430
|
+
values. Load values with a permitted record read after saving. Customer sign-in
|
|
431
|
+
policies remain separate from record scopes.
|
|
432
|
+
|
|
433
|
+
Managed themes use `workspace.createPage` with `title`, `slug`, and
|
|
434
|
+
`contentMarkdown` for pages. Source Sites define application routes in their
|
|
435
|
+
React code; creating a managed Page does not register a React route. For a
|
|
436
|
+
verified custom domain, use
|
|
437
|
+
`customDomain` in `createSite` or `updateSite`, following the
|
|
438
|
+
[Site domain setup](https://docs.gravityrail.com/user-guide/build/sites#custom-domains).
|
|
439
|
+
The [React guide](https://docs.gravityrail.com/developer/libraries/react#quick-start)
|
|
440
|
+
shows real page and record paths, Forms, data loading, and persistent navigation.
|
|
441
|
+
|
|
390
442
|
### Workspace Management
|
|
391
443
|
|
|
392
444
|
Workspace and organization directories return `{ items, page, pageSize, total, totalPages }`. Read
|
|
@@ -593,7 +645,7 @@ try {
|
|
|
593
645
|
const task = await client.getTask(workspaceId, taskId);
|
|
594
646
|
} catch (error) {
|
|
595
647
|
if (error instanceof ApiError) {
|
|
596
|
-
console.error(
|
|
648
|
+
console.error('Gravity Rail request failed', error.statusCode);
|
|
597
649
|
// 403 → check API key scopes
|
|
598
650
|
// 404 → verify workspace and entity IDs
|
|
599
651
|
// 429 → rate limited, back off
|
|
@@ -612,7 +664,7 @@ configured for that use.
|
|
|
612
664
|
## Related
|
|
613
665
|
|
|
614
666
|
- [`@gravity-rail/cli`](https://www.npmjs.com/package/@gravity-rail/cli) — Command-line interface for interactive workspace management
|
|
615
|
-
- [Developer Docs](https://
|
|
667
|
+
- [Developer Docs](https://docs.gravityrail.com) — Full API reference and guides
|
|
616
668
|
|
|
617
669
|
## License
|
|
618
670
|
|