@zeyos/client 0.1.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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +458 -0
- package/agents/README.md +66 -0
- package/agents/shared/business-app-benchmarks.md +111 -0
- package/agents/shared/zeyos-entity-map.md +142 -0
- package/agents/shared/zeyos-entity-reference.md +570 -0
- package/agents/shared/zeyos-query-patterns.md +89 -0
- package/agents/zeyos-account-intelligence/SKILL.md +34 -0
- package/agents/zeyos-account-intelligence/agents/openai.yaml +4 -0
- package/agents/zeyos-account-intelligence/references/workflows.md +84 -0
- package/agents/zeyos-billing-insights/SKILL.md +41 -0
- package/agents/zeyos-billing-insights/agents/openai.yaml +4 -0
- package/agents/zeyos-billing-insights/references/workflows.md +106 -0
- package/agents/zeyos-campaign-and-outreach/SKILL.md +44 -0
- package/agents/zeyos-campaign-and-outreach/agents/openai.yaml +4 -0
- package/agents/zeyos-campaign-and-outreach/references/workflows.md +100 -0
- package/agents/zeyos-collaboration-and-activity/SKILL.md +37 -0
- package/agents/zeyos-collaboration-and-activity/agents/openai.yaml +4 -0
- package/agents/zeyos-collaboration-and-activity/references/workflows.md +104 -0
- package/agents/zeyos-collections-and-dunning/SKILL.md +46 -0
- package/agents/zeyos-collections-and-dunning/agents/openai.yaml +4 -0
- package/agents/zeyos-collections-and-dunning/references/workflows.md +132 -0
- package/agents/zeyos-commerce-and-inventory/SKILL.md +38 -0
- package/agents/zeyos-commerce-and-inventory/agents/openai.yaml +4 -0
- package/agents/zeyos-commerce-and-inventory/references/workflows.md +101 -0
- package/agents/zeyos-mail-operations/SKILL.md +35 -0
- package/agents/zeyos-mail-operations/agents/openai.yaml +4 -0
- package/agents/zeyos-mail-operations/references/workflows.md +110 -0
- package/agents/zeyos-notes-and-sops/SKILL.md +31 -0
- package/agents/zeyos-notes-and-sops/agents/openai.yaml +4 -0
- package/agents/zeyos-notes-and-sops/references/workflows.md +85 -0
- package/agents/zeyos-platform-and-schema/SKILL.md +37 -0
- package/agents/zeyos-platform-and-schema/agents/openai.yaml +4 -0
- package/agents/zeyos-platform-and-schema/references/workflows.md +97 -0
- package/agents/zeyos-work-management/SKILL.md +45 -0
- package/agents/zeyos-work-management/agents/openai.yaml +4 -0
- package/agents/zeyos-work-management/references/workflows.md +148 -0
- package/docs/01-api-reference/01-data-retrieval.md +601 -0
- package/docs/01-api-reference/02-authentication.md +288 -0
- package/docs/01-api-reference/03-resources.md +270 -0
- package/docs/01-api-reference/04-schema.md +539 -0
- package/docs/01-api-reference/_category_.json +9 -0
- package/docs/02-javascript-client/01-getting-started.md +146 -0
- package/docs/02-javascript-client/02-authentication.md +287 -0
- package/docs/02-javascript-client/03-making-requests.md +572 -0
- package/docs/02-javascript-client/04-practical-guide.md +348 -0
- package/docs/02-javascript-client/_category_.json +9 -0
- package/docs/03-cli/01-getting-started.md +219 -0
- package/docs/03-cli/02-commands.md +407 -0
- package/docs/03-cli/03-configuration.md +220 -0
- package/docs/03-cli/_category_.json +9 -0
- package/docs/04-agent-workflows/00-coding-agents.md +35 -0
- package/docs/04-agent-workflows/01-agent-quickstart.md +147 -0
- package/docs/04-agent-workflows/02-agent-recipes.md +109 -0
- package/docs/04-agent-workflows/03-cli-coverage-and-escalation.md +65 -0
- package/docs/04-agent-workflows/_category_.json +9 -0
- package/docs/04-sample-apps/01-kanban.md +89 -0
- package/docs/04-sample-apps/02-crm.md +81 -0
- package/docs/04-sample-apps/03-dashboard.md +80 -0
- package/docs/04-sample-apps/_category_.json +9 -0
- package/docs/05-tutorials/00-application-developers.md +43 -0
- package/docs/05-tutorials/01-integration-architecture.md +60 -0
- package/docs/05-tutorials/02-build-your-own-zeyos-frontend.md +517 -0
- package/docs/05-tutorials/03-server-side-integrations.md +185 -0
- package/docs/05-tutorials/_category_.json +9 -0
- package/docs/intro.md +197 -0
- package/openapi/api.json +24308 -0
- package/openapi/auth.json +415 -0
- package/openapi/dbref.json +56223 -0
- package/openapi/oauth2.json +781 -0
- package/openapi/sdk.json +949 -0
- package/openapi/views.txt +642 -0
- package/package.json +49 -0
- package/samples/crm/README.md +28 -0
- package/samples/crm/index.html +327 -0
- package/samples/crm/js/api.js +208 -0
- package/samples/crm/js/auth.js +61 -0
- package/samples/crm/js/main.js +545 -0
- package/samples/crm/js/state.js +90 -0
- package/samples/crm/js/ui.js +51 -0
- package/samples/dashboard/README.md +28 -0
- package/samples/dashboard/index.html +280 -0
- package/samples/dashboard/js/api.js +197 -0
- package/samples/dashboard/js/auth.js +59 -0
- package/samples/dashboard/js/main.js +382 -0
- package/samples/dashboard/js/state.js +81 -0
- package/samples/dashboard/js/ui.js +48 -0
- package/samples/kanban/README.md +28 -0
- package/samples/kanban/index.html +263 -0
- package/samples/kanban/js/api.js +152 -0
- package/samples/kanban/js/auth.js +59 -0
- package/samples/kanban/js/constants.js +40 -0
- package/samples/kanban/js/kanban.js +246 -0
- package/samples/kanban/js/main.js +362 -0
- package/samples/kanban/js/modals.js +474 -0
- package/samples/kanban/js/settings.js +82 -0
- package/samples/kanban/js/state.js +118 -0
- package/samples/kanban/js/ui.js +49 -0
- package/scripts/generate-client.mjs +344 -0
- package/src/generated/operations.js +9772 -0
- package/src/generated/schema.js +8982 -0
- package/src/index.js +85 -0
- package/src/runtime/client.js +1208 -0
- package/src/runtime/error.js +29 -0
- package/src/runtime/http.js +174 -0
- package/src/runtime/request-shape.js +35 -0
- package/src/runtime/schema.js +206 -0
- package/src/runtime/suggest.js +74 -0
- package/src/runtime/token-store.js +105 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
sidebar_label: Server-Side Integrations
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Server-Side Integrations
|
|
7
|
+
|
|
8
|
+
This guide covers the recommended backend pattern for ZeyOS: keep OAuth tokens on the server, refresh them automatically, and isolate business sync logic behind small job functions.
|
|
9
|
+
|
|
10
|
+
## When to Use This Pattern
|
|
11
|
+
|
|
12
|
+
Use a server-side integration when you are building:
|
|
13
|
+
|
|
14
|
+
- scheduled sync jobs
|
|
15
|
+
- background workers
|
|
16
|
+
- webhook handlers
|
|
17
|
+
- internal APIs that proxy or enrich ZeyOS data
|
|
18
|
+
- automation services that should not depend on a live browser session
|
|
19
|
+
|
|
20
|
+
## 1. Create a Persistent Token Store
|
|
21
|
+
|
|
22
|
+
The client only requires a `get()` and `set()` pair. Back it with a database, secrets manager, or a local JSON file during development.
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
26
|
+
|
|
27
|
+
class JsonFileTokenStore {
|
|
28
|
+
constructor(path) {
|
|
29
|
+
this.path = path;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async get() {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(await readFile(this.path, 'utf8'));
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async set(tokenSet) {
|
|
41
|
+
if (!tokenSet) {
|
|
42
|
+
await writeFile(this.path, 'null\n');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
await writeFile(this.path, JSON.stringify(tokenSet, null, 2) + '\n');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 2. Build the Client
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { createZeyosClient } from '@zeyos/client';
|
|
54
|
+
|
|
55
|
+
const tokenStore = new JsonFileTokenStore('./tokens.json');
|
|
56
|
+
|
|
57
|
+
const client = createZeyosClient({
|
|
58
|
+
platform: 'https://cloud.zeyos.com/demo/',
|
|
59
|
+
auth: {
|
|
60
|
+
mode: 'oauth',
|
|
61
|
+
oauth: {
|
|
62
|
+
clientId: process.env.ZEYOS_CLIENT_ID,
|
|
63
|
+
clientSecret: process.env.ZEYOS_CLIENT_SECRET,
|
|
64
|
+
tokenStore,
|
|
65
|
+
autoRefresh: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
With `autoRefresh: true`, the client refreshes expired access tokens before retrying a request. Your token store must persist the refreshed token set.
|
|
72
|
+
|
|
73
|
+
## 3. Write Small Sync Functions
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
import { normalizeListResult } from '@zeyos/client';
|
|
77
|
+
|
|
78
|
+
export async function fetchActiveTickets(limit = 100) {
|
|
79
|
+
const result = await client.api.listTickets({
|
|
80
|
+
fields: ['ID', 'ticketnum', 'name', 'status', 'priority', 'lastmodified'],
|
|
81
|
+
filters: { visibility: 0, status: 4 },
|
|
82
|
+
sort: ['-lastmodified'],
|
|
83
|
+
limit,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return normalizeListResult(result).data;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Keep each sync unit focused: one resource, one query shape, one return shape.
|
|
91
|
+
|
|
92
|
+
## 4. Use `client.request()` for Advanced Cases
|
|
93
|
+
|
|
94
|
+
Use the generated methods first. Drop to `client.request()` when you need a custom path or an operation outside your current helper layer.
|
|
95
|
+
|
|
96
|
+
By operation ID:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
const response = await client.request({
|
|
100
|
+
service: 'api',
|
|
101
|
+
operationId: 'listTickets',
|
|
102
|
+
body: {
|
|
103
|
+
filters: { visibility: 0, priority: 4 },
|
|
104
|
+
limit: 25,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
By explicit path and method:
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
const response = await client.request({
|
|
113
|
+
service: 'api',
|
|
114
|
+
method: 'POST',
|
|
115
|
+
path: '/tickets/',
|
|
116
|
+
body: {
|
|
117
|
+
filters: { visibility: 0, status: 4 },
|
|
118
|
+
limit: 25,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 5. Handle Errors Explicitly
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
import { ZeyosApiError } from '@zeyos/client';
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
await client.api.updateTicket({
|
|
130
|
+
ID: 42,
|
|
131
|
+
body: { status: 7 },
|
|
132
|
+
});
|
|
133
|
+
} catch (err) {
|
|
134
|
+
if (err instanceof ZeyosApiError) {
|
|
135
|
+
console.error(err.status, err.operationId, err.url);
|
|
136
|
+
console.error(err.body);
|
|
137
|
+
}
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Use structured error handling to separate:
|
|
143
|
+
|
|
144
|
+
- authentication failures
|
|
145
|
+
- missing records
|
|
146
|
+
- validation errors
|
|
147
|
+
- retryable upstream failures
|
|
148
|
+
|
|
149
|
+
## 6. Schedule Background Work
|
|
150
|
+
|
|
151
|
+
A typical cron-style sync job:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
export async function runTicketSync() {
|
|
155
|
+
const tickets = await fetchActiveTickets(250);
|
|
156
|
+
|
|
157
|
+
for (const ticket of tickets) {
|
|
158
|
+
// Map ZeyOS data into your downstream system here
|
|
159
|
+
console.log(ticket.ID, ticket.name);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
await runTicketSync();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Recommended job design:
|
|
167
|
+
|
|
168
|
+
- use explicit field lists
|
|
169
|
+
- use explicit sort order
|
|
170
|
+
- checkpoint on `lastmodified` or another stable field
|
|
171
|
+
- log request failures with resource identifiers
|
|
172
|
+
- keep delete behavior explicit and reviewable
|
|
173
|
+
|
|
174
|
+
## 7. Know the Limits
|
|
175
|
+
|
|
176
|
+
- Prefer `filters` in client code.
|
|
177
|
+
- Include `visibility: 0` for normal operational queries.
|
|
178
|
+
- Use explicit `body` objects for update operations that pass `ID`.
|
|
179
|
+
- Treat count-enabled responses defensively and normalize them in one place inside your backend.
|
|
180
|
+
|
|
181
|
+
## Next Steps
|
|
182
|
+
|
|
183
|
+
- [Integration Architecture](./01-integration-architecture.md)
|
|
184
|
+
- [Making Requests](../02-javascript-client/03-making-requests.md)
|
|
185
|
+
- [Authentication](../02-javascript-client/02-authentication.md)
|
package/docs/intro.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
sidebar_label: Introduction
|
|
4
|
+
slug: /
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# ZeyOS for Agents and Applications
|
|
8
|
+
|
|
9
|
+
ZeyOS is a business platform that unifies CRM, project management, ticketing, invoicing, and related operational data behind a single API surface. For external integrations, you should think of ZeyOS as the central provider for business data and business logic that feeds coding agents, connected applications, internal tools, and automation services.
|
|
10
|
+
|
|
11
|
+
These docs are organized around two entry paths:
|
|
12
|
+
|
|
13
|
+
- **[Coding Agents](./04-agent-workflows/00-coding-agents.md)** for CLI-first automation and operational tooling
|
|
14
|
+
- **[Application Developers](./05-tutorials/00-application-developers.md)** for browser UIs, server-side integrations, and connected apps
|
|
15
|
+
|
|
16
|
+
:::info Scope
|
|
17
|
+
This documentation set currently focuses on **external integrations**. It covers the CLI, the JavaScript client, raw REST/OpenAPI usage, and reusable sample application patterns. It does not document authoring native ZeyOS platform artifacts.
|
|
18
|
+
:::
|
|
19
|
+
|
|
20
|
+
## How Are You Integrating?
|
|
21
|
+
|
|
22
|
+
| Interface | Best for | Start here |
|
|
23
|
+
|-----------|----------|------------|
|
|
24
|
+
| **CLI** (`zeyos`) | Coding agents, shell automation, operational CRUD on curated resources | [Coding Agents](./04-agent-workflows/00-coding-agents.md) |
|
|
25
|
+
| **JavaScript Client** (`@zeyos/client`) | Browser apps, Node services, scheduled jobs, full generated API coverage | [Application Developers](./05-tutorials/00-application-developers.md) |
|
|
26
|
+
| **REST/OpenAPI** | Non-JavaScript runtimes, SDK generation, custom HTTP clients | [API Reference](./01-api-reference/03-resources.md) |
|
|
27
|
+
|
|
28
|
+
### Coverage Boundary
|
|
29
|
+
|
|
30
|
+
- The **CLI** is the default interface for coding agents, but it intentionally exposes a curated registry of common resources. Use `zeyos resources` to see the supported set.
|
|
31
|
+
- The **JavaScript client** covers the broader generated API surface and is the recommended escalation path when the CLI registry is not enough.
|
|
32
|
+
- The **raw API reference** remains the lowest-level source of truth for endpoints, query language, and schema details.
|
|
33
|
+
|
|
34
|
+
## API Base URL
|
|
35
|
+
|
|
36
|
+
Every ZeyOS instance exposes its REST API at a predictable base URL:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
https://cloud.zeyos.com/{INSTANCE}/api/v1/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Replace `{INSTANCE}` with your ZeyOS instance identifier (e.g. `demo`, `acme-corp`).
|
|
43
|
+
|
|
44
|
+
## Authentication
|
|
45
|
+
|
|
46
|
+
All API requests require authentication. ZeyOS supports two authentication methods:
|
|
47
|
+
|
|
48
|
+
- **OAuth 2.0 Bearer Tokens** -- The recommended approach for server-side integrations, scheduled jobs, CLI tools, and browser apps that receive tokens from a trusted flow. Obtain tokens through the ZeyOS OAuth2 endpoint at `https://cloud.zeyos.com/{INSTANCE}/oauth2/v1/`.
|
|
49
|
+
- **Session Cookies** -- For browser-based applications where the user is already logged into ZeyOS. The browser sends the `ZEYOSID` session cookie automatically.
|
|
50
|
+
|
|
51
|
+
Include a bearer token in the `Authorization` header for all API requests:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Authorization: Bearer YOUR_ACCESS_TOKEN
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
See the [Authentication](./01-api-reference/02-authentication.md) guide for full details on the OAuth 2.0 Authorization Code flow, token refresh, token revocation, and session-based authentication.
|
|
58
|
+
|
|
59
|
+
## Return Values and Error Handling
|
|
60
|
+
|
|
61
|
+
The ZeyOS REST API returns JSON data along with an HTTP status code indicating the outcome of a request.
|
|
62
|
+
|
|
63
|
+
- **HTTP 200** or **201** indicates a successful response. The result is a **JSON object**.
|
|
64
|
+
- **HTTP 400** or greater indicates an error. The response is a **text message** describing the problem.
|
|
65
|
+
|
|
66
|
+
We recommend treating any HTTP status code greater than or equal to 400 as an error.
|
|
67
|
+
|
|
68
|
+
## HTTP Methods
|
|
69
|
+
|
|
70
|
+
The API uses the following HTTP methods, which differ from typical REST conventions in some cases:
|
|
71
|
+
|
|
72
|
+
| Operation | HTTP Method | Description |
|
|
73
|
+
|-----------|-------------|-------------|
|
|
74
|
+
| **List** | `POST` | Retrieve a filtered list of records (query parameters are sent in the request body) |
|
|
75
|
+
| **Get** | `GET` | Retrieve a single record by ID |
|
|
76
|
+
| **Create** | `PUT` | Create a new record |
|
|
77
|
+
| **Update** | `PATCH` | Partially update an existing record |
|
|
78
|
+
| **Delete** | `DELETE` | Delete a record by ID |
|
|
79
|
+
| **Exists** | `HEAD` | Check if a record exists (returns no body) |
|
|
80
|
+
|
|
81
|
+
:::info
|
|
82
|
+
**List** operations use `POST` rather than `GET` because the query language (filters, field selection, sorting) can produce payloads that exceed URL length limits. Sending the query in the request body ensures complex queries work reliably.
|
|
83
|
+
:::
|
|
84
|
+
|
|
85
|
+
## Integration Conventions
|
|
86
|
+
|
|
87
|
+
Across the CLI, JavaScript client, and sample applications, the same operational rules apply:
|
|
88
|
+
|
|
89
|
+
- Prefer `filters` in JavaScript client code for compatibility across scalar and foreign-key fields.
|
|
90
|
+
- Include `visibility: 0` unless you intentionally want archived or deleted records.
|
|
91
|
+
- Use an explicit `body` object for updates that also pass a path parameter such as `ID`.
|
|
92
|
+
- Treat `extdata` and `expand` as separate features:
|
|
93
|
+
- `extdata` includes custom fields
|
|
94
|
+
- `expand` inlines JSON or binary columns
|
|
95
|
+
- Treat count-enabled list responses defensively. Different endpoints or client layers may return either a count wrapper or a list wrapper with count metadata.
|
|
96
|
+
|
|
97
|
+
## Data Retrieval
|
|
98
|
+
|
|
99
|
+
The API provides a flexible query language for retrieving data from any resource endpoint. List requests accept a JSON body with the following capabilities:
|
|
100
|
+
|
|
101
|
+
- **Field selection** -- Request only the columns you need, including fields from related records via dot notation (e.g. `contact.city`, `assigneduser.name`).
|
|
102
|
+
- **Filters** -- Restrict results using equality checks, comparison operators (`<`, `>`, `IN`, etc.), string matching (`~`, `~~`, etc.), and composite logic (`AND`, `OR`, `NOT`).
|
|
103
|
+
- **Full-text search** -- Search across a resource's indexed text fields with the `query` parameter.
|
|
104
|
+
- **Sorting** -- Order results by one or more fields, ascending (`+`) or descending (`-`).
|
|
105
|
+
- **Pagination** -- Control result size with `limit` and `offset`. Use `count: true` to retrieve the total number of matching records.
|
|
106
|
+
- **Extended data** -- Include custom/extended data fields by passing `extdata: 1` as a request parameter.
|
|
107
|
+
- **Expand** -- Use the `expand` parameter to include JSON or binary column data that is omitted from list responses by default (e.g. `binfile` on messages, `items` on transactions).
|
|
108
|
+
|
|
109
|
+
See the [Data Retrieval](./01-api-reference/01-data-retrieval.md) guide for the complete query language reference with examples.
|
|
110
|
+
|
|
111
|
+
## Developer Tools
|
|
112
|
+
|
|
113
|
+
This project includes tools to help you work with the ZeyOS REST API:
|
|
114
|
+
|
|
115
|
+
| Tool | Description | Docs |
|
|
116
|
+
|------|-------------|------|
|
|
117
|
+
| **JavaScript Client** (`@zeyos/client`) | A dependency-light, auto-generated client library with generated methods for every API operation, OAuth 2.0 helpers, and automatic token refresh. Works in browsers and Node.js 18+. | [Getting Started](./02-javascript-client/01-getting-started.md) |
|
|
118
|
+
| **CLI** | A command-line interface for scripting and automation against your ZeyOS instance. Supports filtering, sorting, pagination, and multiple output formats. | [Getting Started](./03-cli/01-getting-started.md) |
|
|
119
|
+
| **Agent Workflows** | CLI-first guidance for coding agents, JSON-first recipes, and escalation rules when the CLI registry is not enough. | [Coding Agents](./04-agent-workflows/00-coding-agents.md) |
|
|
120
|
+
| **Application Developers** | Architecture, browser UI patterns, and server-side integration guidance for connected applications. | [Application Developers](./05-tutorials/00-application-developers.md) |
|
|
121
|
+
| **Practical Guide** | A field-tested collection of implementation patterns, gotchas, and best practices learned from building real applications against the ZeyOS API. | [Practical Guide](./02-javascript-client/04-practical-guide.md) |
|
|
122
|
+
| **Schema Reference** | Field names, types, enum values, and GIN-indexed fields for the 20 most commonly used ZeyOS resources. | [Schema Reference](./01-api-reference/04-schema.md) |
|
|
123
|
+
|
|
124
|
+
## Sample Applications
|
|
125
|
+
|
|
126
|
+
Three ready-to-run sample applications demonstrate different integration patterns:
|
|
127
|
+
|
|
128
|
+
| Sample | What it demonstrates | Docs |
|
|
129
|
+
|--------|---------------------|------|
|
|
130
|
+
| **Kanban Board** | Drag-and-drop ticket management, optimistic UI updates, status changes via PATCH, task tables, project/account filtering | [Kanban](./04-sample-apps/01-kanban.md) |
|
|
131
|
+
| **CRM Account List** | Dot-notation joins, field aliasing, full-text search, sortable columns, pagination, modal editing | [CRM](./04-sample-apps/02-crm.md) |
|
|
132
|
+
| **Dashboard** | KPI cards with `count: true`, parallel API queries, status distribution charts, overdue calculations, read-only patterns | [Dashboard](./04-sample-apps/03-dashboard.md) |
|
|
133
|
+
|
|
134
|
+
## Prerequisites
|
|
135
|
+
|
|
136
|
+
- **A ZeyOS instance** -- You need access to a ZeyOS cloud instance. Your instance URL follows the pattern `https://cloud.zeyos.com/{INSTANCE}/`.
|
|
137
|
+
- **Node.js 18+** -- Required for the JavaScript client.
|
|
138
|
+
- **Node.js 18.3+** -- Required for the CLI package.
|
|
139
|
+
|
|
140
|
+
## Quick Example
|
|
141
|
+
|
|
142
|
+
List the 10 most recently modified open tickets using `curl`:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
curl -X POST "https://cloud.zeyos.com/demo/api/v1/tickets" \
|
|
146
|
+
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
|
147
|
+
-H "Content-Type: application/json" \
|
|
148
|
+
-d '{
|
|
149
|
+
"fields": ["ID", "name", "status", "priority", "duedate"],
|
|
150
|
+
"filter": {"visibility": 0},
|
|
151
|
+
"sort": ["-lastmodified"],
|
|
152
|
+
"limit": 10
|
|
153
|
+
}'
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The same request using the JavaScript client:
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
import { createZeyosClient, MemoryTokenStore } from '@zeyos/client';
|
|
160
|
+
|
|
161
|
+
const client = createZeyosClient({
|
|
162
|
+
platform: 'https://cloud.zeyos.com/demo/',
|
|
163
|
+
auth: {
|
|
164
|
+
mode: 'oauth',
|
|
165
|
+
oauth: {
|
|
166
|
+
tokenStore: new MemoryTokenStore({
|
|
167
|
+
accessToken: 'YOUR_ACCESS_TOKEN',
|
|
168
|
+
}),
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const tickets = await client.api.listTickets({
|
|
174
|
+
fields: ['ID', 'name', 'status', 'priority', 'duedate'],
|
|
175
|
+
filters: { visibility: 0 },
|
|
176
|
+
sort: ['-lastmodified'],
|
|
177
|
+
limit: 10,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
console.log(tickets);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
For long-lived OAuth sessions in trusted code, add `clientId`, `clientSecret`, and a refresh-capable token store. For browser-only apps, prefer session mode or a backend token broker instead of shipping client credentials.
|
|
184
|
+
|
|
185
|
+
:::tip
|
|
186
|
+
You can also use **session authentication** when running inside a browser where the user is already logged into ZeyOS. Set `auth.mode` to `'session'` and the client will use browser cookies automatically. See the [Authentication](./01-api-reference/02-authentication.md) guide for details.
|
|
187
|
+
:::
|
|
188
|
+
|
|
189
|
+
## Next Steps
|
|
190
|
+
|
|
191
|
+
- **[Coding Agents](./04-agent-workflows/00-coding-agents.md)** -- CLI-first workflows, JSON output patterns, and escalation guidance
|
|
192
|
+
- **[Application Developers](./05-tutorials/00-application-developers.md)** -- browser and server-side integration paths
|
|
193
|
+
- **[Getting Started](./02-javascript-client/01-getting-started.md)** -- Install the JavaScript client and make your first API call
|
|
194
|
+
- **[Making Requests](./02-javascript-client/03-making-requests.md)** -- CRUD operations, filtering, sorting, pagination, and error handling
|
|
195
|
+
- **[Practical Guide](./02-javascript-client/04-practical-guide.md)** -- Patterns and gotchas from real-world implementations
|
|
196
|
+
- **[Schema Reference](./01-api-reference/04-schema.md)** -- Field definitions and enum values for all major resources
|
|
197
|
+
- **[Browser UI Playbook](./05-tutorials/02-build-your-own-zeyos-frontend.md)** -- Step-by-step browser integration guide
|