@zooid/types 0.0.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +21 -0
  3. package/src/index.ts +140 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zooid-ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@zooid/types",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "types": "./src/index.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./src/index.ts"
9
+ }
10
+ },
11
+ "files": [
12
+ "src"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Ori Ben",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/zooid-ai/zooid",
19
+ "directory": "packages/types"
20
+ }
21
+ }
package/src/index.ts ADDED
@@ -0,0 +1,140 @@
1
+ /**
2
+ * A published event as returned by the API.
3
+ *
4
+ * Events are the core unit of data in Zooid. Each event belongs to a channel
5
+ * and is identified by a time-ordered ULID.
6
+ */
7
+ export interface ZooidEvent {
8
+ /** Time-ordered ULID that uniquely identifies this event. */
9
+ id: string;
10
+ /** The channel this event was published to. */
11
+ channel_id: string;
12
+ /** ID of the publisher that created this event, or `null` for admin publishes. */
13
+ publisher_id: string | null;
14
+ /** Optional event type string for filtering (e.g. `"trade"`, `"alert"`). */
15
+ type: string | null;
16
+ /** JSON-serialized event payload (max 64 KB). */
17
+ data: string;
18
+ /** ISO 8601 timestamp when the event was created. */
19
+ created_at: string;
20
+ }
21
+
22
+ /**
23
+ * Cursor-paginated poll response.
24
+ *
25
+ * Returned by `GET /api/v1/channels/:id/events`. Use `cursor` in subsequent
26
+ * requests to fetch the next page.
27
+ */
28
+ export interface PollResult {
29
+ /** Array of events in this page, ordered by ID ascending. */
30
+ events: ZooidEvent[];
31
+ /** Opaque cursor for the next page, or `null` if no more events. */
32
+ cursor: string | null;
33
+ /** `true` if there are additional events beyond this page. */
34
+ has_more: boolean;
35
+ }
36
+
37
+ /**
38
+ * Public channel listing returned by `GET /api/v1/channels`.
39
+ *
40
+ * Includes aggregate stats (event count, publishers) alongside
41
+ * the channel's configuration.
42
+ */
43
+ export interface ChannelListItem {
44
+ /** URL-safe slug identifier (lowercase + hyphens, 3-64 chars). */
45
+ id: string;
46
+ /** Human-readable display name. */
47
+ name: string;
48
+ /** Optional description of the channel's purpose. */
49
+ description: string | null;
50
+ /** Arbitrary tags for categorization. */
51
+ tags: string[];
52
+ /** Whether the channel is publicly accessible without a token. */
53
+ is_public: boolean;
54
+ /** Optional JSON Schema that published events must conform to. */
55
+ schema: Record<string, unknown> | null;
56
+ /** When `true`, events are rejected if they don't match `schema`. */
57
+ strict: boolean;
58
+ /** Total number of events currently stored in this channel. */
59
+ event_count: number;
60
+ /** ISO 8601 timestamp of the most recent event, or `null` if empty. */
61
+ last_event_at: string | null;
62
+ /** Names of publishers registered on this channel. */
63
+ publishers: string[];
64
+ }
65
+
66
+ /**
67
+ * A registered webhook subscription.
68
+ *
69
+ * Webhooks receive POST requests for each new event published
70
+ * to the subscribed channel.
71
+ */
72
+ export interface Webhook {
73
+ /** ULID identifier for this webhook registration. */
74
+ id: string;
75
+ /** Channel this webhook is subscribed to. */
76
+ channel_id: string;
77
+ /** URL that receives event POST requests. */
78
+ url: string;
79
+ /** JSON-encoded array of event types to filter, or `null` for all events. */
80
+ event_types: string | null;
81
+ /** ISO 8601 timestamp when this webhook expires. */
82
+ expires_at: string;
83
+ /** ISO 8601 timestamp when this webhook was created. */
84
+ created_at: string;
85
+ }
86
+
87
+ /**
88
+ * Server discovery metadata from `GET /.well-known/zooid.json`.
89
+ *
90
+ * Contains the information needed by agents to discover and verify
91
+ * a Zooid server: its public signing key, supported delivery mechanisms,
92
+ * and recommended poll interval.
93
+ */
94
+ export interface ServerDiscovery {
95
+ /** Zooid protocol version (semver). */
96
+ version: string;
97
+ /** Base64-encoded Ed25519 public key for webhook signature verification. */
98
+ public_key: string;
99
+ /** Key encoding format (e.g. `"raw"`). */
100
+ public_key_format: string;
101
+ /** Signing algorithm (e.g. `"Ed25519"`). */
102
+ algorithm: string;
103
+ /** Unique identifier for this server instance. */
104
+ server_id: string;
105
+ /** Recommended poll interval in seconds. */
106
+ poll_interval: number;
107
+ /** Supported delivery mechanisms (e.g. `["polling", "webhooks", "rss"]`). */
108
+ delivery: string[];
109
+ }
110
+
111
+ /**
112
+ * Editable server identity from `GET /api/v1/server` and `PUT /api/v1/server`.
113
+ *
114
+ * Human-readable metadata about who operates this Zooid instance.
115
+ * Editable by admins.
116
+ */
117
+ export interface ServerIdentity {
118
+ /** Display name for this server. */
119
+ name: string;
120
+ /** Optional description of this server's purpose. */
121
+ description: string | null;
122
+ /** Arbitrary tags for categorization. */
123
+ tags: string[];
124
+ /** Name of the server operator. */
125
+ owner: string | null;
126
+ /** Company or organization name. */
127
+ company: string | null;
128
+ /** Contact email address. */
129
+ email: string | null;
130
+ /** ISO 8601 timestamp of the last update. */
131
+ updated_at: string;
132
+ }
133
+
134
+ // Deprecated aliases for backward compatibility
135
+
136
+ /** @deprecated Use {@link ServerDiscovery} instead. */
137
+ export type ServerMetadata = ServerDiscovery;
138
+
139
+ /** @deprecated Use {@link ServerIdentity} instead. */
140
+ export type ServerMeta = ServerIdentity;