@anticeil/sdk 0.0.0-stage → 1.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/README.md CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ # @anticeil/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official TypeScript & JavaScript client library for **Anticeil Chat**, Voice, Activities, and Bot Platform.
4
+
5
+ ## Features
6
+ - **Real-time WebSocket Gateway:** Listen for incoming messages, typing notifications, and presence events.
7
+ - **REST API Client:** Channels, colonies, messages, reactions, permissions, and webhook dispatching.
8
+ - **Embedded Activities:** Programmatically trigger collaborative Excalidraw whiteboards, YouTube Watch Together, and Chess.
9
+ - **Strict TypeScript Types:** Complete typing for colonies, channels, messages, users, and payloads.
10
+
11
+ ## Installation
12
+ ```bash
13
+ npm install @anticeil/sdk
14
+ ```
15
+
16
+ ## Quick Start
17
+ ```typescript
18
+ import { AnticeilClient } from '@anticeil/sdk';
19
+
20
+ const client = new AnticeilClient({
21
+ baseUrl: 'https://app.anticeil.com',
22
+ apiKey: process.env.ANTICEIL_API_KEY,
23
+ autoConnect: true,
24
+ });
25
+
26
+ client.on('message', async (msg) => {
27
+ if (msg.content === '!ping') {
28
+ await client.sendMessage(msg.channelId, 'Pong! 🏓', { replyToId: msg.id });
29
+ }
30
+ });
31
+ ```
32
+
33
+ ## License
34
+ MIT
@@ -0,0 +1,278 @@
1
+ interface AnticeilConfig {
2
+ token?: string;
3
+ apiKey?: string;
4
+ baseUrl?: string;
5
+ socketUrl?: string;
6
+ autoConnect?: boolean;
7
+ }
8
+ interface Colony {
9
+ id: string;
10
+ name: string;
11
+ icon?: string;
12
+ description?: string;
13
+ category?: string;
14
+ ownerId?: string;
15
+ visibility?: 'public' | 'private';
16
+ accessSettings?: ColonyAccessSettings;
17
+ memberCount?: number;
18
+ createdAt?: string;
19
+ }
20
+ interface ColonyAccessSettings {
21
+ joinMethod: 'invite_only' | 'apply' | 'discoverable';
22
+ ageRestricted?: boolean;
23
+ rulesEnabled?: boolean;
24
+ rules?: string[];
25
+ screeningQuestions?: Array<{
26
+ id: string;
27
+ question: string;
28
+ required?: boolean;
29
+ }>;
30
+ }
31
+ interface Channel {
32
+ id: string;
33
+ colonyId: string;
34
+ name: string;
35
+ type: 'text' | 'voice' | 'announcement' | 'kanban' | 'forum' | 'activity';
36
+ topic?: string;
37
+ isPrivate?: boolean;
38
+ categoryId?: string;
39
+ position?: number;
40
+ }
41
+ interface Thread {
42
+ id: string;
43
+ channelId: string;
44
+ name: string;
45
+ messageId?: string;
46
+ createdAt?: string;
47
+ }
48
+ interface User {
49
+ id: string;
50
+ name: string;
51
+ username?: string;
52
+ email?: string;
53
+ avatar?: string;
54
+ role?: string;
55
+ status?: 'online' | 'idle' | 'dnd' | 'offline';
56
+ isBot?: boolean;
57
+ }
58
+ interface Message {
59
+ id: string;
60
+ channelId: string;
61
+ colonyId?: string;
62
+ content: string;
63
+ senderId: string;
64
+ senderName: string;
65
+ senderAvatar?: string;
66
+ senderRole?: string;
67
+ attachments?: any[];
68
+ replyToId?: string;
69
+ createdAt: string;
70
+ }
71
+ interface SendMessageOptions {
72
+ content: string;
73
+ attachments?: any[];
74
+ replyToId?: string;
75
+ }
76
+ interface Role {
77
+ id: string;
78
+ name: string;
79
+ color?: string;
80
+ permissions?: string[];
81
+ }
82
+ interface KanbanTask {
83
+ id: string;
84
+ title: string;
85
+ description?: string;
86
+ columnId: 'todo' | 'in_progress' | 'review' | 'done';
87
+ priority: 'low' | 'medium' | 'high' | 'urgent';
88
+ colonyId?: string;
89
+ channelId?: string;
90
+ assigneeName?: string;
91
+ dueDate?: string;
92
+ createdAt?: string;
93
+ }
94
+ interface CalendarEvent {
95
+ id: string;
96
+ title: string;
97
+ description?: string;
98
+ startTime: string;
99
+ endTime?: string;
100
+ colonyId?: string;
101
+ location?: string;
102
+ }
103
+ interface AppCatalogItem {
104
+ id: string;
105
+ title: string;
106
+ description?: string;
107
+ category?: string;
108
+ developer?: string;
109
+ launchUrl?: string;
110
+ }
111
+ interface QuestItem {
112
+ id: string;
113
+ title: string;
114
+ description?: string;
115
+ reward?: string;
116
+ isActive?: boolean;
117
+ }
118
+ interface WebhookPayload {
119
+ username?: string;
120
+ avatarUrl?: string;
121
+ avatar_url?: string;
122
+ content?: string;
123
+ embeds?: Array<{
124
+ title?: string;
125
+ description?: string;
126
+ color?: string;
127
+ fields?: Array<{
128
+ name: string;
129
+ value: string;
130
+ inline?: boolean;
131
+ }>;
132
+ }>;
133
+ attachments?: any[];
134
+ }
135
+ interface ActivityLaunchOptions {
136
+ channelId: string;
137
+ type?: string;
138
+ activityId?: string;
139
+ title?: string;
140
+ data?: Record<string, any>;
141
+ }
142
+
143
+ type EventHandler<T = any> = (data: T) => void;
144
+ declare class AnticeilClient {
145
+ private config;
146
+ private socket;
147
+ private eventHandlers;
148
+ constructor(config?: AnticeilConfig);
149
+ connect(): void;
150
+ disconnect(): void;
151
+ on<T = any>(event: string, handler: EventHandler<T>): this;
152
+ off<T = any>(event: string, handler: EventHandler<T>): this;
153
+ private emitInternal;
154
+ private request;
155
+ colonies: {
156
+ list: () => Promise<Colony[]>;
157
+ get: (colonyId: string) => Promise<Colony>;
158
+ create: (data: {
159
+ name: string;
160
+ description?: string;
161
+ category?: string;
162
+ }) => Promise<Colony>;
163
+ update: (colonyId: string, updates: Partial<Colony>) => Promise<Colony>;
164
+ delete: (colonyId: string) => Promise<{
165
+ success: boolean;
166
+ }>;
167
+ setPrivacy: (colonyId: string, joinMethod: "invite_only" | "apply" | "discoverable", options?: {
168
+ rulesEnabled?: boolean;
169
+ screeningQuestions?: Array<{
170
+ id: string;
171
+ question: string;
172
+ required?: boolean;
173
+ }>;
174
+ }) => Promise<Colony>;
175
+ getInsights: (colonyId: string) => Promise<Record<string, any>>;
176
+ };
177
+ channels: {
178
+ get: (channelId: string) => Promise<Channel>;
179
+ list: (colonyId: string) => Promise<Channel[]>;
180
+ create: (colonyId: string, data: Partial<Channel>) => Promise<Channel>;
181
+ update: (channelId: string, updates: Partial<Channel>) => Promise<Channel>;
182
+ delete: (channelId: string) => Promise<{
183
+ success: boolean;
184
+ }>;
185
+ };
186
+ messages: {
187
+ send: (channelId: string, options: string | SendMessageOptions) => Promise<Message>;
188
+ list: (channelId: string, limit?: number) => Promise<Message[]>;
189
+ delete: (channelId: string, messageId: string) => Promise<{
190
+ success: boolean;
191
+ }>;
192
+ toggleReaction: (messageId: string, emoji: string) => Promise<{
193
+ success: boolean;
194
+ }>;
195
+ togglePin: (messageId: string, channelId?: string) => Promise<{
196
+ success: boolean;
197
+ }>;
198
+ };
199
+ threads: {
200
+ list: (channelId: string) => Promise<Thread[]>;
201
+ create: (channelId: string, data: {
202
+ name: string;
203
+ messageId?: string;
204
+ }) => Promise<Thread>;
205
+ };
206
+ friends: {
207
+ list: () => Promise<any[]>;
208
+ sendRequest: (target: string) => Promise<{
209
+ success: boolean;
210
+ }>;
211
+ listMessageRequests: () => Promise<any[]>;
212
+ respondMessageRequest: (requestId: string, action: "accept" | "ignore" | "spam") => Promise<{
213
+ success: boolean;
214
+ }>;
215
+ };
216
+ members: {
217
+ list: (colonyId?: string) => Promise<User[]>;
218
+ listRoles: (colonyId: string) => Promise<Role[]>;
219
+ updateRole: (colonyId: string, userId: string, roleId: string) => Promise<{
220
+ success: boolean;
221
+ }>;
222
+ ban: (colonyId: string, userId: string, reason?: string) => Promise<{
223
+ success: boolean;
224
+ }>;
225
+ unban: (colonyId: string, userId: string) => Promise<{
226
+ success: boolean;
227
+ }>;
228
+ getAuditLogs: (colonyId: string) => Promise<any[]>;
229
+ };
230
+ tasks: {
231
+ list: (filters?: {
232
+ colonyId?: string;
233
+ channelId?: string;
234
+ }) => Promise<KanbanTask[]>;
235
+ create: (data: Partial<KanbanTask> & {
236
+ title: string;
237
+ }) => Promise<KanbanTask>;
238
+ update: (taskId: string, updates: Partial<KanbanTask>) => Promise<KanbanTask>;
239
+ delete: (taskId: string) => Promise<{
240
+ success: boolean;
241
+ }>;
242
+ };
243
+ events: {
244
+ list: (colonyId?: string) => Promise<CalendarEvent[]>;
245
+ create: (data: Omit<CalendarEvent, "id">) => Promise<CalendarEvent>;
246
+ update: (eventId: string, updates: Partial<CalendarEvent>) => Promise<CalendarEvent>;
247
+ delete: (eventId: string) => Promise<{
248
+ success: boolean;
249
+ }>;
250
+ };
251
+ apps: {
252
+ list: () => Promise<AppCatalogItem[]>;
253
+ install: (colonyId: string, appId: string) => Promise<{
254
+ success: boolean;
255
+ }>;
256
+ };
257
+ activities: {
258
+ launch: (options: ActivityLaunchOptions) => Promise<{
259
+ success: boolean;
260
+ activityUrl?: string;
261
+ }>;
262
+ };
263
+ quests: {
264
+ list: () => Promise<QuestItem[]>;
265
+ create: (data: Omit<QuestItem, "id">) => Promise<QuestItem>;
266
+ update: (questId: string, updates: Partial<QuestItem>) => Promise<QuestItem>;
267
+ delete: (questId: string) => Promise<{
268
+ success: boolean;
269
+ }>;
270
+ };
271
+ webhooks: {
272
+ send: (webhookUrl: string, payload: WebhookPayload) => Promise<{
273
+ success: boolean;
274
+ }>;
275
+ };
276
+ }
277
+
278
+ export { type ActivityLaunchOptions, AnticeilClient, type AnticeilConfig, type AppCatalogItem, type CalendarEvent, type Channel, type Colony, type ColonyAccessSettings, type KanbanTask, type Message, type QuestItem, type Role, type SendMessageOptions, type Thread, type User, type WebhookPayload };
@@ -0,0 +1,278 @@
1
+ interface AnticeilConfig {
2
+ token?: string;
3
+ apiKey?: string;
4
+ baseUrl?: string;
5
+ socketUrl?: string;
6
+ autoConnect?: boolean;
7
+ }
8
+ interface Colony {
9
+ id: string;
10
+ name: string;
11
+ icon?: string;
12
+ description?: string;
13
+ category?: string;
14
+ ownerId?: string;
15
+ visibility?: 'public' | 'private';
16
+ accessSettings?: ColonyAccessSettings;
17
+ memberCount?: number;
18
+ createdAt?: string;
19
+ }
20
+ interface ColonyAccessSettings {
21
+ joinMethod: 'invite_only' | 'apply' | 'discoverable';
22
+ ageRestricted?: boolean;
23
+ rulesEnabled?: boolean;
24
+ rules?: string[];
25
+ screeningQuestions?: Array<{
26
+ id: string;
27
+ question: string;
28
+ required?: boolean;
29
+ }>;
30
+ }
31
+ interface Channel {
32
+ id: string;
33
+ colonyId: string;
34
+ name: string;
35
+ type: 'text' | 'voice' | 'announcement' | 'kanban' | 'forum' | 'activity';
36
+ topic?: string;
37
+ isPrivate?: boolean;
38
+ categoryId?: string;
39
+ position?: number;
40
+ }
41
+ interface Thread {
42
+ id: string;
43
+ channelId: string;
44
+ name: string;
45
+ messageId?: string;
46
+ createdAt?: string;
47
+ }
48
+ interface User {
49
+ id: string;
50
+ name: string;
51
+ username?: string;
52
+ email?: string;
53
+ avatar?: string;
54
+ role?: string;
55
+ status?: 'online' | 'idle' | 'dnd' | 'offline';
56
+ isBot?: boolean;
57
+ }
58
+ interface Message {
59
+ id: string;
60
+ channelId: string;
61
+ colonyId?: string;
62
+ content: string;
63
+ senderId: string;
64
+ senderName: string;
65
+ senderAvatar?: string;
66
+ senderRole?: string;
67
+ attachments?: any[];
68
+ replyToId?: string;
69
+ createdAt: string;
70
+ }
71
+ interface SendMessageOptions {
72
+ content: string;
73
+ attachments?: any[];
74
+ replyToId?: string;
75
+ }
76
+ interface Role {
77
+ id: string;
78
+ name: string;
79
+ color?: string;
80
+ permissions?: string[];
81
+ }
82
+ interface KanbanTask {
83
+ id: string;
84
+ title: string;
85
+ description?: string;
86
+ columnId: 'todo' | 'in_progress' | 'review' | 'done';
87
+ priority: 'low' | 'medium' | 'high' | 'urgent';
88
+ colonyId?: string;
89
+ channelId?: string;
90
+ assigneeName?: string;
91
+ dueDate?: string;
92
+ createdAt?: string;
93
+ }
94
+ interface CalendarEvent {
95
+ id: string;
96
+ title: string;
97
+ description?: string;
98
+ startTime: string;
99
+ endTime?: string;
100
+ colonyId?: string;
101
+ location?: string;
102
+ }
103
+ interface AppCatalogItem {
104
+ id: string;
105
+ title: string;
106
+ description?: string;
107
+ category?: string;
108
+ developer?: string;
109
+ launchUrl?: string;
110
+ }
111
+ interface QuestItem {
112
+ id: string;
113
+ title: string;
114
+ description?: string;
115
+ reward?: string;
116
+ isActive?: boolean;
117
+ }
118
+ interface WebhookPayload {
119
+ username?: string;
120
+ avatarUrl?: string;
121
+ avatar_url?: string;
122
+ content?: string;
123
+ embeds?: Array<{
124
+ title?: string;
125
+ description?: string;
126
+ color?: string;
127
+ fields?: Array<{
128
+ name: string;
129
+ value: string;
130
+ inline?: boolean;
131
+ }>;
132
+ }>;
133
+ attachments?: any[];
134
+ }
135
+ interface ActivityLaunchOptions {
136
+ channelId: string;
137
+ type?: string;
138
+ activityId?: string;
139
+ title?: string;
140
+ data?: Record<string, any>;
141
+ }
142
+
143
+ type EventHandler<T = any> = (data: T) => void;
144
+ declare class AnticeilClient {
145
+ private config;
146
+ private socket;
147
+ private eventHandlers;
148
+ constructor(config?: AnticeilConfig);
149
+ connect(): void;
150
+ disconnect(): void;
151
+ on<T = any>(event: string, handler: EventHandler<T>): this;
152
+ off<T = any>(event: string, handler: EventHandler<T>): this;
153
+ private emitInternal;
154
+ private request;
155
+ colonies: {
156
+ list: () => Promise<Colony[]>;
157
+ get: (colonyId: string) => Promise<Colony>;
158
+ create: (data: {
159
+ name: string;
160
+ description?: string;
161
+ category?: string;
162
+ }) => Promise<Colony>;
163
+ update: (colonyId: string, updates: Partial<Colony>) => Promise<Colony>;
164
+ delete: (colonyId: string) => Promise<{
165
+ success: boolean;
166
+ }>;
167
+ setPrivacy: (colonyId: string, joinMethod: "invite_only" | "apply" | "discoverable", options?: {
168
+ rulesEnabled?: boolean;
169
+ screeningQuestions?: Array<{
170
+ id: string;
171
+ question: string;
172
+ required?: boolean;
173
+ }>;
174
+ }) => Promise<Colony>;
175
+ getInsights: (colonyId: string) => Promise<Record<string, any>>;
176
+ };
177
+ channels: {
178
+ get: (channelId: string) => Promise<Channel>;
179
+ list: (colonyId: string) => Promise<Channel[]>;
180
+ create: (colonyId: string, data: Partial<Channel>) => Promise<Channel>;
181
+ update: (channelId: string, updates: Partial<Channel>) => Promise<Channel>;
182
+ delete: (channelId: string) => Promise<{
183
+ success: boolean;
184
+ }>;
185
+ };
186
+ messages: {
187
+ send: (channelId: string, options: string | SendMessageOptions) => Promise<Message>;
188
+ list: (channelId: string, limit?: number) => Promise<Message[]>;
189
+ delete: (channelId: string, messageId: string) => Promise<{
190
+ success: boolean;
191
+ }>;
192
+ toggleReaction: (messageId: string, emoji: string) => Promise<{
193
+ success: boolean;
194
+ }>;
195
+ togglePin: (messageId: string, channelId?: string) => Promise<{
196
+ success: boolean;
197
+ }>;
198
+ };
199
+ threads: {
200
+ list: (channelId: string) => Promise<Thread[]>;
201
+ create: (channelId: string, data: {
202
+ name: string;
203
+ messageId?: string;
204
+ }) => Promise<Thread>;
205
+ };
206
+ friends: {
207
+ list: () => Promise<any[]>;
208
+ sendRequest: (target: string) => Promise<{
209
+ success: boolean;
210
+ }>;
211
+ listMessageRequests: () => Promise<any[]>;
212
+ respondMessageRequest: (requestId: string, action: "accept" | "ignore" | "spam") => Promise<{
213
+ success: boolean;
214
+ }>;
215
+ };
216
+ members: {
217
+ list: (colonyId?: string) => Promise<User[]>;
218
+ listRoles: (colonyId: string) => Promise<Role[]>;
219
+ updateRole: (colonyId: string, userId: string, roleId: string) => Promise<{
220
+ success: boolean;
221
+ }>;
222
+ ban: (colonyId: string, userId: string, reason?: string) => Promise<{
223
+ success: boolean;
224
+ }>;
225
+ unban: (colonyId: string, userId: string) => Promise<{
226
+ success: boolean;
227
+ }>;
228
+ getAuditLogs: (colonyId: string) => Promise<any[]>;
229
+ };
230
+ tasks: {
231
+ list: (filters?: {
232
+ colonyId?: string;
233
+ channelId?: string;
234
+ }) => Promise<KanbanTask[]>;
235
+ create: (data: Partial<KanbanTask> & {
236
+ title: string;
237
+ }) => Promise<KanbanTask>;
238
+ update: (taskId: string, updates: Partial<KanbanTask>) => Promise<KanbanTask>;
239
+ delete: (taskId: string) => Promise<{
240
+ success: boolean;
241
+ }>;
242
+ };
243
+ events: {
244
+ list: (colonyId?: string) => Promise<CalendarEvent[]>;
245
+ create: (data: Omit<CalendarEvent, "id">) => Promise<CalendarEvent>;
246
+ update: (eventId: string, updates: Partial<CalendarEvent>) => Promise<CalendarEvent>;
247
+ delete: (eventId: string) => Promise<{
248
+ success: boolean;
249
+ }>;
250
+ };
251
+ apps: {
252
+ list: () => Promise<AppCatalogItem[]>;
253
+ install: (colonyId: string, appId: string) => Promise<{
254
+ success: boolean;
255
+ }>;
256
+ };
257
+ activities: {
258
+ launch: (options: ActivityLaunchOptions) => Promise<{
259
+ success: boolean;
260
+ activityUrl?: string;
261
+ }>;
262
+ };
263
+ quests: {
264
+ list: () => Promise<QuestItem[]>;
265
+ create: (data: Omit<QuestItem, "id">) => Promise<QuestItem>;
266
+ update: (questId: string, updates: Partial<QuestItem>) => Promise<QuestItem>;
267
+ delete: (questId: string) => Promise<{
268
+ success: boolean;
269
+ }>;
270
+ };
271
+ webhooks: {
272
+ send: (webhookUrl: string, payload: WebhookPayload) => Promise<{
273
+ success: boolean;
274
+ }>;
275
+ };
276
+ }
277
+
278
+ export { type ActivityLaunchOptions, AnticeilClient, type AnticeilConfig, type AppCatalogItem, type CalendarEvent, type Channel, type Colony, type ColonyAccessSettings, type KanbanTask, type Message, type QuestItem, type Role, type SendMessageOptions, type Thread, type User, type WebhookPayload };
package/dist/index.js ADDED
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AnticeilClient: () => AnticeilClient
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/client.ts
28
+ var import_socket = require("socket.io-client");
29
+ var AnticeilClient = class {
30
+ config;
31
+ socket = null;
32
+ eventHandlers = /* @__PURE__ */ new Map();
33
+ constructor(config = {}) {
34
+ this.config = {
35
+ token: config.token || "",
36
+ apiKey: config.apiKey || "",
37
+ baseUrl: (config.baseUrl || "https://app.anticeil.com").replace(/\/+$/, ""),
38
+ socketUrl: (config.socketUrl || config.baseUrl || "https://app.anticeil.com").replace(/\/+$/, ""),
39
+ autoConnect: config.autoConnect ?? false
40
+ };
41
+ if (this.config.autoConnect) {
42
+ this.connect();
43
+ }
44
+ }
45
+ connect() {
46
+ if (this.socket?.connected) return;
47
+ this.socket = (0, import_socket.io)(this.config.socketUrl, {
48
+ path: "/api/socket.io",
49
+ transports: ["websocket"],
50
+ auth: {
51
+ token: this.config.token || this.config.apiKey
52
+ }
53
+ });
54
+ this.socket.on("connect", () => {
55
+ this.emitInternal("connect", { id: this.socket?.id });
56
+ });
57
+ this.socket.on("disconnect", (reason) => {
58
+ this.emitInternal("disconnect", { reason });
59
+ });
60
+ this.socket.on("message_created", (raw) => {
61
+ const msg = {
62
+ id: raw.id || `msg_${Date.now()}`,
63
+ channelId: raw.channelId,
64
+ colonyId: raw.colonyId,
65
+ content: raw.content || "",
66
+ senderId: raw.senderId || raw.userId,
67
+ senderName: raw.senderName || raw.userName || "Anonymous",
68
+ senderAvatar: raw.senderAvatar || raw.userAvatar,
69
+ senderRole: raw.senderRole,
70
+ attachments: raw.attachments || [],
71
+ replyToId: raw.replyToId,
72
+ createdAt: raw.createdAt || (/* @__PURE__ */ new Date()).toISOString()
73
+ };
74
+ this.emitInternal("message", msg);
75
+ });
76
+ this.socket.on("user_typing", (data) => {
77
+ this.emitInternal("typing", data);
78
+ });
79
+ this.socket.on("presence_update", (data) => {
80
+ this.emitInternal("presence", data);
81
+ });
82
+ }
83
+ disconnect() {
84
+ if (this.socket) {
85
+ this.socket.disconnect();
86
+ this.socket = null;
87
+ }
88
+ }
89
+ on(event, handler) {
90
+ if (!this.eventHandlers.has(event)) {
91
+ this.eventHandlers.set(event, /* @__PURE__ */ new Set());
92
+ }
93
+ this.eventHandlers.get(event).add(handler);
94
+ return this;
95
+ }
96
+ off(event, handler) {
97
+ this.eventHandlers.get(event)?.delete(handler);
98
+ return this;
99
+ }
100
+ emitInternal(event, data) {
101
+ this.eventHandlers.get(event)?.forEach((handler) => {
102
+ try {
103
+ handler(data);
104
+ } catch (err) {
105
+ console.error(`[AnticeilClient] Error in '${event}' event listener:`, err);
106
+ }
107
+ });
108
+ }
109
+ async request(endpoint, options = {}) {
110
+ const path = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
111
+ const url = `${this.config.baseUrl}${path}`;
112
+ const headers = new Headers(options.headers);
113
+ if (this.config.token) {
114
+ headers.set("Authorization", `Bearer ${this.config.token}`);
115
+ } else if (this.config.apiKey) {
116
+ headers.set("Authorization", `Bearer ${this.config.apiKey}`);
117
+ headers.set("X-Anticeil-Api-Key", this.config.apiKey);
118
+ }
119
+ if (!headers.has("Content-Type")) {
120
+ headers.set("Content-Type", "application/json");
121
+ }
122
+ const res = await fetch(url, { ...options, headers });
123
+ if (!res.ok) {
124
+ const errorText = await res.text().catch(() => res.statusText);
125
+ throw new Error(`Anticeil API Error [${res.status}] ${path}: ${errorText}`);
126
+ }
127
+ const text = await res.text();
128
+ if (!text) return {};
129
+ try {
130
+ return JSON.parse(text);
131
+ } catch {
132
+ return text;
133
+ }
134
+ }
135
+ // ==========================================
136
+ // 1. COLONIES API
137
+ // ==========================================
138
+ colonies = {
139
+ list: async () => this.request("/api/colonies"),
140
+ get: async (colonyId) => this.request(`/api/colonies/${colonyId}`),
141
+ create: async (data) => this.request("/api/v1/community/hubs", {
142
+ method: "POST",
143
+ body: JSON.stringify(data)
144
+ }),
145
+ update: async (colonyId, updates) => this.request(`/api/colonies/${colonyId}`, {
146
+ method: "PATCH",
147
+ body: JSON.stringify(updates)
148
+ }),
149
+ delete: async (colonyId) => this.request(`/api/v1/community/hubs/${colonyId}`, {
150
+ method: "DELETE"
151
+ }),
152
+ setPrivacy: async (colonyId, joinMethod, options = {}) => this.request(`/api/colonies/${colonyId}/access`, {
153
+ method: "PUT",
154
+ body: JSON.stringify({
155
+ joinMethod,
156
+ visibility: joinMethod === "discoverable" ? "public" : "private",
157
+ ...options
158
+ })
159
+ }),
160
+ getInsights: async (colonyId) => this.request(`/api/v1/colonies/${colonyId}/insights`)
161
+ };
162
+ // ==========================================
163
+ // 2. CHANNELS API
164
+ // ==========================================
165
+ channels = {
166
+ get: async (channelId) => this.request(`/api/channels/${channelId}`),
167
+ list: async (colonyId) => this.request(`/api/colonies/${colonyId}/channels`),
168
+ create: async (colonyId, data) => this.request(`/api/colonies/${colonyId}/channels`, {
169
+ method: "POST",
170
+ body: JSON.stringify(data)
171
+ }),
172
+ update: async (channelId, updates) => this.request(`/api/v1/community/channels/${channelId}`, {
173
+ method: "PUT",
174
+ body: JSON.stringify(updates)
175
+ }),
176
+ delete: async (channelId) => this.request(`/api/v1/community/channels/${channelId}`, {
177
+ method: "DELETE"
178
+ })
179
+ };
180
+ // ==========================================
181
+ // 3. MESSAGES & REACTIONS API
182
+ // ==========================================
183
+ messages = {
184
+ send: async (channelId, options) => {
185
+ const payload = typeof options === "string" ? { content: options } : options;
186
+ if (this.socket?.connected) {
187
+ this.socket.emit("send_message", { channelId, ...payload });
188
+ }
189
+ return this.request(`/api/channels/${channelId}/messages`, {
190
+ method: "POST",
191
+ body: JSON.stringify(payload)
192
+ });
193
+ },
194
+ list: async (channelId, limit = 50) => this.request(`/api/channels/${channelId}/messages?limit=${limit}`),
195
+ delete: async (channelId, messageId) => this.request(`/api/channels/${channelId}/messages/${messageId}`, {
196
+ method: "DELETE"
197
+ }),
198
+ toggleReaction: async (messageId, emoji) => this.request(`/api/v1/community/messages/${messageId}/reactions`, {
199
+ method: "POST",
200
+ body: JSON.stringify({ emoji })
201
+ }),
202
+ togglePin: async (messageId, channelId) => this.request(`/api/v1/community/messages/${messageId}/pin`, {
203
+ method: "POST",
204
+ body: JSON.stringify({ channelId })
205
+ })
206
+ };
207
+ // ==========================================
208
+ // 4. THREADS API
209
+ // ==========================================
210
+ threads = {
211
+ list: async (channelId) => this.request(`/api/v1/community/channels/${channelId}/threads`),
212
+ create: async (channelId, data) => this.request(`/api/v1/community/channels/${channelId}/threads`, {
213
+ method: "POST",
214
+ body: JSON.stringify(data)
215
+ })
216
+ };
217
+ // ==========================================
218
+ // 5. FRIENDS & MESSAGE REQUESTS API
219
+ // ==========================================
220
+ friends = {
221
+ list: async () => this.request("/api/v1/community/friends"),
222
+ sendRequest: async (target) => this.request("/api/v1/community/friends/request", {
223
+ method: "POST",
224
+ body: JSON.stringify({ username: target, target })
225
+ }),
226
+ listMessageRequests: async () => this.request("/api/v1/community/message-requests"),
227
+ respondMessageRequest: async (requestId, action) => this.request(`/api/v1/community/message-requests/${requestId}/${action}`, {
228
+ method: "POST",
229
+ body: JSON.stringify({})
230
+ })
231
+ };
232
+ // ==========================================
233
+ // 6. MEMBERS, ROLES & MODERATION API
234
+ // ==========================================
235
+ members = {
236
+ list: async (colonyId) => this.request(
237
+ colonyId ? `/api/v1/community/members?colonyId=${encodeURIComponent(colonyId)}` : "/api/v1/community/members"
238
+ ),
239
+ listRoles: async (colonyId) => this.request(`/api/v1/community/hubs/${colonyId}/roles`),
240
+ updateRole: async (colonyId, userId, roleId) => this.request(`/api/v1/community/hubs/${colonyId}/members/${userId}/role`, {
241
+ method: "PUT",
242
+ body: JSON.stringify({ roleId })
243
+ }),
244
+ ban: async (colonyId, userId, reason) => this.request(`/api/v1/colonies/${colonyId}/bans`, {
245
+ method: "POST",
246
+ body: JSON.stringify({ userId, reason })
247
+ }),
248
+ unban: async (colonyId, userId) => this.request(`/api/v1/colonies/${colonyId}/bans/${userId}`, {
249
+ method: "DELETE"
250
+ }),
251
+ getAuditLogs: async (colonyId) => this.request(`/api/v1/colonies/${colonyId}/audit-logs`)
252
+ };
253
+ // ==========================================
254
+ // 7. TASKS / KANBAN ASSIGNMENTS API
255
+ // ==========================================
256
+ tasks = {
257
+ list: async (filters) => {
258
+ const params = new URLSearchParams();
259
+ if (filters?.colonyId) params.set("colonyId", filters.colonyId);
260
+ if (filters?.channelId) params.set("channelId", filters.channelId);
261
+ const qs = params.toString();
262
+ return this.request(`/api/v1/community/assignments${qs ? `?${qs}` : ""}`);
263
+ },
264
+ create: async (data) => this.request("/api/v1/community/assignments", {
265
+ method: "POST",
266
+ body: JSON.stringify({ columnId: "todo", priority: "medium", ...data })
267
+ }),
268
+ update: async (taskId, updates) => this.request(`/api/v1/community/assignments/${taskId}`, {
269
+ method: "PUT",
270
+ body: JSON.stringify(updates)
271
+ }),
272
+ delete: async (taskId) => this.request(`/api/v1/community/assignments/${taskId}`, {
273
+ method: "DELETE"
274
+ })
275
+ };
276
+ // ==========================================
277
+ // 8. CALENDAR & COLONY EVENTS API
278
+ // ==========================================
279
+ events = {
280
+ list: async (colonyId) => this.request(
281
+ colonyId ? `/api/v1/community/calendar/events?colonyId=${encodeURIComponent(colonyId)}` : "/api/v1/community/calendar/events"
282
+ ),
283
+ create: async (data) => this.request("/api/v1/community/calendar/events", {
284
+ method: "POST",
285
+ body: JSON.stringify(data)
286
+ }),
287
+ update: async (eventId, updates) => this.request(`/api/v1/community/calendar/events/${eventId}`, {
288
+ method: "PUT",
289
+ body: JSON.stringify(updates)
290
+ }),
291
+ delete: async (eventId) => this.request(`/api/v1/community/calendar/events/${eventId}`, {
292
+ method: "DELETE"
293
+ })
294
+ };
295
+ // ==========================================
296
+ // 9. APPS, ACTIVITIES & QUESTS API
297
+ // ==========================================
298
+ apps = {
299
+ list: async () => this.request("/api/v1/community/activities/catalog"),
300
+ install: async (colonyId, appId) => this.request(`/api/v1/colonies/${colonyId}/apps/${appId}/install`, {
301
+ method: "POST",
302
+ body: JSON.stringify({})
303
+ })
304
+ };
305
+ activities = {
306
+ launch: async (options) => {
307
+ if (this.socket?.connected) {
308
+ this.socket.emit("launch_activity", options);
309
+ }
310
+ return this.request(
311
+ `/api/channels/${options.channelId}/activity`,
312
+ {
313
+ method: "POST",
314
+ body: JSON.stringify(options)
315
+ }
316
+ );
317
+ }
318
+ };
319
+ quests = {
320
+ list: async () => this.request("/api/v1/community/quests"),
321
+ create: async (data) => this.request("/api/v1/community/quests", {
322
+ method: "POST",
323
+ body: JSON.stringify(data)
324
+ }),
325
+ update: async (questId, updates) => this.request(`/api/v1/community/quests/${questId}`, {
326
+ method: "PUT",
327
+ body: JSON.stringify(updates)
328
+ }),
329
+ delete: async (questId) => this.request(`/api/v1/community/quests/${questId}`, {
330
+ method: "DELETE"
331
+ })
332
+ };
333
+ // ==========================================
334
+ // 10. WEBHOOKS API
335
+ // ==========================================
336
+ webhooks = {
337
+ send: async (webhookUrl, payload) => {
338
+ const res = await fetch(webhookUrl, {
339
+ method: "POST",
340
+ headers: { "Content-Type": "application/json" },
341
+ body: JSON.stringify(payload)
342
+ });
343
+ if (!res.ok) {
344
+ throw new Error(`Webhook Error [${res.status}]: ${await res.text()}`);
345
+ }
346
+ return { success: true };
347
+ }
348
+ };
349
+ };
350
+ // Annotate the CommonJS export names for ESM import in node:
351
+ 0 && (module.exports = {
352
+ AnticeilClient
353
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,326 @@
1
+ // src/client.ts
2
+ import { io } from "socket.io-client";
3
+ var AnticeilClient = class {
4
+ config;
5
+ socket = null;
6
+ eventHandlers = /* @__PURE__ */ new Map();
7
+ constructor(config = {}) {
8
+ this.config = {
9
+ token: config.token || "",
10
+ apiKey: config.apiKey || "",
11
+ baseUrl: (config.baseUrl || "https://app.anticeil.com").replace(/\/+$/, ""),
12
+ socketUrl: (config.socketUrl || config.baseUrl || "https://app.anticeil.com").replace(/\/+$/, ""),
13
+ autoConnect: config.autoConnect ?? false
14
+ };
15
+ if (this.config.autoConnect) {
16
+ this.connect();
17
+ }
18
+ }
19
+ connect() {
20
+ if (this.socket?.connected) return;
21
+ this.socket = io(this.config.socketUrl, {
22
+ path: "/api/socket.io",
23
+ transports: ["websocket"],
24
+ auth: {
25
+ token: this.config.token || this.config.apiKey
26
+ }
27
+ });
28
+ this.socket.on("connect", () => {
29
+ this.emitInternal("connect", { id: this.socket?.id });
30
+ });
31
+ this.socket.on("disconnect", (reason) => {
32
+ this.emitInternal("disconnect", { reason });
33
+ });
34
+ this.socket.on("message_created", (raw) => {
35
+ const msg = {
36
+ id: raw.id || `msg_${Date.now()}`,
37
+ channelId: raw.channelId,
38
+ colonyId: raw.colonyId,
39
+ content: raw.content || "",
40
+ senderId: raw.senderId || raw.userId,
41
+ senderName: raw.senderName || raw.userName || "Anonymous",
42
+ senderAvatar: raw.senderAvatar || raw.userAvatar,
43
+ senderRole: raw.senderRole,
44
+ attachments: raw.attachments || [],
45
+ replyToId: raw.replyToId,
46
+ createdAt: raw.createdAt || (/* @__PURE__ */ new Date()).toISOString()
47
+ };
48
+ this.emitInternal("message", msg);
49
+ });
50
+ this.socket.on("user_typing", (data) => {
51
+ this.emitInternal("typing", data);
52
+ });
53
+ this.socket.on("presence_update", (data) => {
54
+ this.emitInternal("presence", data);
55
+ });
56
+ }
57
+ disconnect() {
58
+ if (this.socket) {
59
+ this.socket.disconnect();
60
+ this.socket = null;
61
+ }
62
+ }
63
+ on(event, handler) {
64
+ if (!this.eventHandlers.has(event)) {
65
+ this.eventHandlers.set(event, /* @__PURE__ */ new Set());
66
+ }
67
+ this.eventHandlers.get(event).add(handler);
68
+ return this;
69
+ }
70
+ off(event, handler) {
71
+ this.eventHandlers.get(event)?.delete(handler);
72
+ return this;
73
+ }
74
+ emitInternal(event, data) {
75
+ this.eventHandlers.get(event)?.forEach((handler) => {
76
+ try {
77
+ handler(data);
78
+ } catch (err) {
79
+ console.error(`[AnticeilClient] Error in '${event}' event listener:`, err);
80
+ }
81
+ });
82
+ }
83
+ async request(endpoint, options = {}) {
84
+ const path = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
85
+ const url = `${this.config.baseUrl}${path}`;
86
+ const headers = new Headers(options.headers);
87
+ if (this.config.token) {
88
+ headers.set("Authorization", `Bearer ${this.config.token}`);
89
+ } else if (this.config.apiKey) {
90
+ headers.set("Authorization", `Bearer ${this.config.apiKey}`);
91
+ headers.set("X-Anticeil-Api-Key", this.config.apiKey);
92
+ }
93
+ if (!headers.has("Content-Type")) {
94
+ headers.set("Content-Type", "application/json");
95
+ }
96
+ const res = await fetch(url, { ...options, headers });
97
+ if (!res.ok) {
98
+ const errorText = await res.text().catch(() => res.statusText);
99
+ throw new Error(`Anticeil API Error [${res.status}] ${path}: ${errorText}`);
100
+ }
101
+ const text = await res.text();
102
+ if (!text) return {};
103
+ try {
104
+ return JSON.parse(text);
105
+ } catch {
106
+ return text;
107
+ }
108
+ }
109
+ // ==========================================
110
+ // 1. COLONIES API
111
+ // ==========================================
112
+ colonies = {
113
+ list: async () => this.request("/api/colonies"),
114
+ get: async (colonyId) => this.request(`/api/colonies/${colonyId}`),
115
+ create: async (data) => this.request("/api/v1/community/hubs", {
116
+ method: "POST",
117
+ body: JSON.stringify(data)
118
+ }),
119
+ update: async (colonyId, updates) => this.request(`/api/colonies/${colonyId}`, {
120
+ method: "PATCH",
121
+ body: JSON.stringify(updates)
122
+ }),
123
+ delete: async (colonyId) => this.request(`/api/v1/community/hubs/${colonyId}`, {
124
+ method: "DELETE"
125
+ }),
126
+ setPrivacy: async (colonyId, joinMethod, options = {}) => this.request(`/api/colonies/${colonyId}/access`, {
127
+ method: "PUT",
128
+ body: JSON.stringify({
129
+ joinMethod,
130
+ visibility: joinMethod === "discoverable" ? "public" : "private",
131
+ ...options
132
+ })
133
+ }),
134
+ getInsights: async (colonyId) => this.request(`/api/v1/colonies/${colonyId}/insights`)
135
+ };
136
+ // ==========================================
137
+ // 2. CHANNELS API
138
+ // ==========================================
139
+ channels = {
140
+ get: async (channelId) => this.request(`/api/channels/${channelId}`),
141
+ list: async (colonyId) => this.request(`/api/colonies/${colonyId}/channels`),
142
+ create: async (colonyId, data) => this.request(`/api/colonies/${colonyId}/channels`, {
143
+ method: "POST",
144
+ body: JSON.stringify(data)
145
+ }),
146
+ update: async (channelId, updates) => this.request(`/api/v1/community/channels/${channelId}`, {
147
+ method: "PUT",
148
+ body: JSON.stringify(updates)
149
+ }),
150
+ delete: async (channelId) => this.request(`/api/v1/community/channels/${channelId}`, {
151
+ method: "DELETE"
152
+ })
153
+ };
154
+ // ==========================================
155
+ // 3. MESSAGES & REACTIONS API
156
+ // ==========================================
157
+ messages = {
158
+ send: async (channelId, options) => {
159
+ const payload = typeof options === "string" ? { content: options } : options;
160
+ if (this.socket?.connected) {
161
+ this.socket.emit("send_message", { channelId, ...payload });
162
+ }
163
+ return this.request(`/api/channels/${channelId}/messages`, {
164
+ method: "POST",
165
+ body: JSON.stringify(payload)
166
+ });
167
+ },
168
+ list: async (channelId, limit = 50) => this.request(`/api/channels/${channelId}/messages?limit=${limit}`),
169
+ delete: async (channelId, messageId) => this.request(`/api/channels/${channelId}/messages/${messageId}`, {
170
+ method: "DELETE"
171
+ }),
172
+ toggleReaction: async (messageId, emoji) => this.request(`/api/v1/community/messages/${messageId}/reactions`, {
173
+ method: "POST",
174
+ body: JSON.stringify({ emoji })
175
+ }),
176
+ togglePin: async (messageId, channelId) => this.request(`/api/v1/community/messages/${messageId}/pin`, {
177
+ method: "POST",
178
+ body: JSON.stringify({ channelId })
179
+ })
180
+ };
181
+ // ==========================================
182
+ // 4. THREADS API
183
+ // ==========================================
184
+ threads = {
185
+ list: async (channelId) => this.request(`/api/v1/community/channels/${channelId}/threads`),
186
+ create: async (channelId, data) => this.request(`/api/v1/community/channels/${channelId}/threads`, {
187
+ method: "POST",
188
+ body: JSON.stringify(data)
189
+ })
190
+ };
191
+ // ==========================================
192
+ // 5. FRIENDS & MESSAGE REQUESTS API
193
+ // ==========================================
194
+ friends = {
195
+ list: async () => this.request("/api/v1/community/friends"),
196
+ sendRequest: async (target) => this.request("/api/v1/community/friends/request", {
197
+ method: "POST",
198
+ body: JSON.stringify({ username: target, target })
199
+ }),
200
+ listMessageRequests: async () => this.request("/api/v1/community/message-requests"),
201
+ respondMessageRequest: async (requestId, action) => this.request(`/api/v1/community/message-requests/${requestId}/${action}`, {
202
+ method: "POST",
203
+ body: JSON.stringify({})
204
+ })
205
+ };
206
+ // ==========================================
207
+ // 6. MEMBERS, ROLES & MODERATION API
208
+ // ==========================================
209
+ members = {
210
+ list: async (colonyId) => this.request(
211
+ colonyId ? `/api/v1/community/members?colonyId=${encodeURIComponent(colonyId)}` : "/api/v1/community/members"
212
+ ),
213
+ listRoles: async (colonyId) => this.request(`/api/v1/community/hubs/${colonyId}/roles`),
214
+ updateRole: async (colonyId, userId, roleId) => this.request(`/api/v1/community/hubs/${colonyId}/members/${userId}/role`, {
215
+ method: "PUT",
216
+ body: JSON.stringify({ roleId })
217
+ }),
218
+ ban: async (colonyId, userId, reason) => this.request(`/api/v1/colonies/${colonyId}/bans`, {
219
+ method: "POST",
220
+ body: JSON.stringify({ userId, reason })
221
+ }),
222
+ unban: async (colonyId, userId) => this.request(`/api/v1/colonies/${colonyId}/bans/${userId}`, {
223
+ method: "DELETE"
224
+ }),
225
+ getAuditLogs: async (colonyId) => this.request(`/api/v1/colonies/${colonyId}/audit-logs`)
226
+ };
227
+ // ==========================================
228
+ // 7. TASKS / KANBAN ASSIGNMENTS API
229
+ // ==========================================
230
+ tasks = {
231
+ list: async (filters) => {
232
+ const params = new URLSearchParams();
233
+ if (filters?.colonyId) params.set("colonyId", filters.colonyId);
234
+ if (filters?.channelId) params.set("channelId", filters.channelId);
235
+ const qs = params.toString();
236
+ return this.request(`/api/v1/community/assignments${qs ? `?${qs}` : ""}`);
237
+ },
238
+ create: async (data) => this.request("/api/v1/community/assignments", {
239
+ method: "POST",
240
+ body: JSON.stringify({ columnId: "todo", priority: "medium", ...data })
241
+ }),
242
+ update: async (taskId, updates) => this.request(`/api/v1/community/assignments/${taskId}`, {
243
+ method: "PUT",
244
+ body: JSON.stringify(updates)
245
+ }),
246
+ delete: async (taskId) => this.request(`/api/v1/community/assignments/${taskId}`, {
247
+ method: "DELETE"
248
+ })
249
+ };
250
+ // ==========================================
251
+ // 8. CALENDAR & COLONY EVENTS API
252
+ // ==========================================
253
+ events = {
254
+ list: async (colonyId) => this.request(
255
+ colonyId ? `/api/v1/community/calendar/events?colonyId=${encodeURIComponent(colonyId)}` : "/api/v1/community/calendar/events"
256
+ ),
257
+ create: async (data) => this.request("/api/v1/community/calendar/events", {
258
+ method: "POST",
259
+ body: JSON.stringify(data)
260
+ }),
261
+ update: async (eventId, updates) => this.request(`/api/v1/community/calendar/events/${eventId}`, {
262
+ method: "PUT",
263
+ body: JSON.stringify(updates)
264
+ }),
265
+ delete: async (eventId) => this.request(`/api/v1/community/calendar/events/${eventId}`, {
266
+ method: "DELETE"
267
+ })
268
+ };
269
+ // ==========================================
270
+ // 9. APPS, ACTIVITIES & QUESTS API
271
+ // ==========================================
272
+ apps = {
273
+ list: async () => this.request("/api/v1/community/activities/catalog"),
274
+ install: async (colonyId, appId) => this.request(`/api/v1/colonies/${colonyId}/apps/${appId}/install`, {
275
+ method: "POST",
276
+ body: JSON.stringify({})
277
+ })
278
+ };
279
+ activities = {
280
+ launch: async (options) => {
281
+ if (this.socket?.connected) {
282
+ this.socket.emit("launch_activity", options);
283
+ }
284
+ return this.request(
285
+ `/api/channels/${options.channelId}/activity`,
286
+ {
287
+ method: "POST",
288
+ body: JSON.stringify(options)
289
+ }
290
+ );
291
+ }
292
+ };
293
+ quests = {
294
+ list: async () => this.request("/api/v1/community/quests"),
295
+ create: async (data) => this.request("/api/v1/community/quests", {
296
+ method: "POST",
297
+ body: JSON.stringify(data)
298
+ }),
299
+ update: async (questId, updates) => this.request(`/api/v1/community/quests/${questId}`, {
300
+ method: "PUT",
301
+ body: JSON.stringify(updates)
302
+ }),
303
+ delete: async (questId) => this.request(`/api/v1/community/quests/${questId}`, {
304
+ method: "DELETE"
305
+ })
306
+ };
307
+ // ==========================================
308
+ // 10. WEBHOOKS API
309
+ // ==========================================
310
+ webhooks = {
311
+ send: async (webhookUrl, payload) => {
312
+ const res = await fetch(webhookUrl, {
313
+ method: "POST",
314
+ headers: { "Content-Type": "application/json" },
315
+ body: JSON.stringify(payload)
316
+ });
317
+ if (!res.ok) {
318
+ throw new Error(`Webhook Error [${res.status}]: ${await res.text()}`);
319
+ }
320
+ return { success: true };
321
+ }
322
+ };
323
+ };
324
+ export {
325
+ AnticeilClient
326
+ };
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@anticeil/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Official TypeScript & JavaScript SDK for Anticeil Chat, Voice, Activities, and Bot Platform",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "test": "node --test test/sdk.test.mjs",
20
+ "build": "tsup src/index.ts --format cjs,esm --dts",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "keywords": [
24
+ "anticeil",
25
+ "chat",
26
+ "webrtc",
27
+ "bot",
28
+ "sdk",
29
+ "realtime",
30
+ "websocket"
31
+ ],
32
+ "author": "Anticeil Team <dev@anticeil.com>",
33
+ "license": "MIT",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "dependencies": {
38
+ "socket.io-client": "^4.8.1"
39
+ },
40
+ "devDependencies": {
41
+ "tsup": "^8.3.6",
42
+ "typescript": "^5.7.3"
43
+ }
44
+ }