orita-sdk 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alkilo-do
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/README.md ADDED
@@ -0,0 +1,406 @@
1
+ # orita-sdk (Node.js / TypeScript)
2
+
3
+ [![npm version](https://img.shields.io/npm/v/orita-sdk.svg)](https://www.npmjs.com/package/orita-sdk)
4
+ [![Node.js 18+](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
7
+
8
+ **The scheduling infrastructure for AI agents — official Node.js / TypeScript SDK**
9
+
10
+ [Orita](https://orita.online) is the scheduling layer purpose-built for AI agents. Connect your LLM to real calendar availability in minutes — no external dependencies, full TypeScript types.
11
+
12
+ → **Docs & API keys:** [orita.online/developers](https://orita.online/developers)
13
+ → **Python SDK:** [github.com/Alkilo-do/orita-python](https://github.com/Alkilo-do/orita-python)
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install orita-sdk
21
+ # or
22
+ yarn add orita-sdk
23
+ # or
24
+ pnpm add orita-sdk
25
+ ```
26
+
27
+ > **Requirements:** Node.js 18+ (uses native `fetch`). No external runtime dependencies.
28
+
29
+ ---
30
+
31
+ ## Quickstart
32
+
33
+ ```typescript
34
+ import { OritaClient } from 'orita-sdk';
35
+
36
+ const orita = new OritaClient({ apiKey: process.env.ORITA_API_KEY! });
37
+
38
+ // Get available slots
39
+ const { slots } = await orita.getSlots('event-type-id', '2026-08-01');
40
+
41
+ // Book appointment
42
+ const booking = await orita.book({
43
+ eventTypeId: 'event-type-id',
44
+ date: '2026-08-01',
45
+ time: slots[0].value,
46
+ clientName: 'Ana',
47
+ clientLastname: 'López',
48
+ clientEmail: 'ana@example.com',
49
+ });
50
+
51
+ console.log(booking.id); // "book_xyz789"
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Authentication
57
+
58
+ Get your API key at [orita.online/developers](https://orita.online/developers). All API keys start with `orita_`.
59
+
60
+ ```typescript
61
+ import { OritaClient } from 'orita-sdk';
62
+
63
+ const orita = new OritaClient({
64
+ apiKey: 'orita_your_key_here',
65
+ // Optional: override base URL for staging/self-hosted
66
+ // baseUrl: 'https://staging.orita.online/api/v1',
67
+ });
68
+ ```
69
+
70
+ ---
71
+
72
+ ## API Reference
73
+
74
+ ### `getEventTypes() → Promise<EventType[]>`
75
+
76
+ List all active event types for your account.
77
+
78
+ ```typescript
79
+ const eventTypes = await orita.getEventTypes();
80
+ // [{ id: "evt_abc123", title: "Initial Consultation", duration: 30, ... }]
81
+
82
+ const eventTypeId = eventTypes[0].id;
83
+ ```
84
+
85
+ ---
86
+
87
+ ### `getSlots(eventTypeId, date) → Promise<{ slots: Slot[]; date: string; eventTypeId: string }>`
88
+
89
+ Get available time slots for a given event type on a specific date.
90
+
91
+ | Parameter | Type | Description |
92
+ |-----------|------|-------------|
93
+ | `eventTypeId` | `string` | Event type ID from `getEventTypes()` |
94
+ | `date` | `string` | Date in `YYYY-MM-DD` format |
95
+
96
+ ```typescript
97
+ const { slots } = await orita.getSlots('evt_abc123', '2026-08-01');
98
+ // [{ label: "09:00 AM", value: "09:00" }, { label: "09:30 AM", value: "09:30" }, ...]
99
+ ```
100
+
101
+ ---
102
+
103
+ ### `book(params) → Promise<Booking>`
104
+
105
+ Book an appointment. Returns the created booking object.
106
+
107
+ | Parameter | Type | Required | Description |
108
+ |-----------|------|----------|-------------|
109
+ | `eventTypeId` | `string` | ✅ | Event type ID |
110
+ | `date` | `string` | ✅ | Date in `YYYY-MM-DD` |
111
+ | `time` | `string` | ✅ | Time in `HH:MM` (from `getSlots()`) |
112
+ | `clientName` | `string` | ✅ | Client first name |
113
+ | `clientLastname` | `string` | ✅ | Client last name |
114
+ | `clientEmail` | `string` | ✅ | Client email |
115
+ | `clientPhone` | `string` | ❌ | Client phone number |
116
+ | `clientTimezone` | `string` | ❌ | IANA timezone (e.g. `America/New_York`) |
117
+ | `notes` | `string` | ❌ | Additional notes for the professional |
118
+
119
+ ```typescript
120
+ const booking = await orita.book({
121
+ eventTypeId: 'evt_abc123',
122
+ date: '2026-08-01',
123
+ time: '10:00',
124
+ clientName: 'Carlos',
125
+ clientLastname: 'García',
126
+ clientEmail: 'carlos@example.com',
127
+ clientTimezone: 'America/Bogota',
128
+ notes: 'First appointment — prefers video call',
129
+ });
130
+ // { id: "book_xyz789", status: "confirmed", date: "2026-08-01", ... }
131
+ ```
132
+
133
+ ---
134
+
135
+ ### `getBookings(params?) → Promise<Booking[]>`
136
+
137
+ List your bookings with optional filtering.
138
+
139
+ ```typescript
140
+ const confirmed = await orita.getBookings({ status: 'confirmed' });
141
+ const all = await orita.getBookings({ page: 2, limit: 50 });
142
+ ```
143
+
144
+ ---
145
+
146
+ ### `getBooking(bookingId) → Promise<Booking>`
147
+
148
+ Retrieve a single booking by ID.
149
+
150
+ ```typescript
151
+ const booking = await orita.getBooking('book_xyz789');
152
+ console.log(booking.status); // "confirmed"
153
+ ```
154
+
155
+ ---
156
+
157
+ ### `cancelBooking(bookingId, reason?) → Promise<Booking>`
158
+
159
+ Cancel a booking by ID.
160
+
161
+ ```typescript
162
+ const result = await orita.cancelBooking('book_xyz789', 'Client requested reschedule');
163
+ console.log(result.status); // "cancelled"
164
+ ```
165
+
166
+ ---
167
+
168
+ ### `getProfile(username) → Promise<Profile>`
169
+
170
+ Fetch the **public** Capability Manifest for any professional by username. **No API key required.**
171
+
172
+ ```typescript
173
+ const manifest = await orita.getProfile('dra-martinez');
174
+ console.log(manifest.eventTypes);
175
+ ```
176
+
177
+ ---
178
+
179
+ ### `getMyProfile() → Promise<Profile>`
180
+
181
+ Get your own Capability Manifest. Requires authentication.
182
+
183
+ ```typescript
184
+ const profile = await orita.getMyProfile();
185
+ console.log(profile.username);
186
+ ```
187
+
188
+ ---
189
+
190
+ ### `updateProfile(fields) → Promise<Profile>`
191
+
192
+ Update your profile fields.
193
+
194
+ ```typescript
195
+ const updated = await orita.updateProfile({
196
+ bio: 'AI-native therapist',
197
+ timezone: 'Europe/Madrid',
198
+ });
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Error Handling
204
+
205
+ ```typescript
206
+ import {
207
+ OritaClient,
208
+ OritaAuthError,
209
+ OritaNotFoundError,
210
+ OritaSlotUnavailableError,
211
+ OritaError,
212
+ } from 'orita-sdk';
213
+
214
+ const orita = new OritaClient({ apiKey: process.env.ORITA_API_KEY! });
215
+
216
+ try {
217
+ const booking = await orita.book({
218
+ eventTypeId: 'evt_abc123',
219
+ date: '2026-08-01',
220
+ time: '10:00',
221
+ clientName: 'Ana',
222
+ clientLastname: 'López',
223
+ clientEmail: 'ana@example.com',
224
+ });
225
+ } catch (err) {
226
+ if (err instanceof OritaAuthError) {
227
+ console.error('Invalid API key');
228
+ } else if (err instanceof OritaSlotUnavailableError) {
229
+ console.error('That slot was just taken — fetch slots again');
230
+ } else if (err instanceof OritaNotFoundError) {
231
+ console.error('Event type not found');
232
+ } else if (err instanceof OritaError) {
233
+ console.error(`API error (${err.statusCode}): ${err.message}`);
234
+ }
235
+ }
236
+ ```
237
+
238
+ | Exception | HTTP Status | When |
239
+ |-----------|-------------|------|
240
+ | `OritaAuthError` | 401 | Invalid or missing API key |
241
+ | `OritaNotFoundError` | 404 | Resource not found |
242
+ | `OritaSlotUnavailableError` | 409 | Slot already taken |
243
+ | `OritaError` | Other 4xx/5xx | Generic API error |
244
+
245
+ ---
246
+
247
+ ## Framework Integrations
248
+
249
+ ### OpenAI Agents SDK (tool use)
250
+
251
+ ```typescript
252
+ import OpenAI from 'openai';
253
+ import { OritaClient } from 'orita-sdk';
254
+
255
+ const orita = new OritaClient({ apiKey: process.env.ORITA_API_KEY! });
256
+ const ai = new OpenAI();
257
+
258
+ const tools: OpenAI.Chat.Completions.ChatCompletionTool[] = [
259
+ {
260
+ type: 'function',
261
+ function: {
262
+ name: 'get_available_slots',
263
+ description: 'Get available appointment slots for a date',
264
+ parameters: {
265
+ type: 'object',
266
+ properties: {
267
+ eventTypeId: { type: 'string' },
268
+ date: { type: 'string', description: 'YYYY-MM-DD' },
269
+ },
270
+ required: ['eventTypeId', 'date'],
271
+ },
272
+ },
273
+ },
274
+ ];
275
+
276
+ async function handleToolCall(name: string, args: Record<string, string>) {
277
+ if (name === 'get_available_slots') {
278
+ const { slots } = await orita.getSlots(args.eventTypeId, args.date);
279
+ return JSON.stringify(slots);
280
+ }
281
+ }
282
+ ```
283
+
284
+ ### Vercel AI SDK
285
+
286
+ ```typescript
287
+ import { tool } from 'ai';
288
+ import { z } from 'zod';
289
+ import { OritaClient } from 'orita-sdk';
290
+
291
+ const orita = new OritaClient({ apiKey: process.env.ORITA_API_KEY! });
292
+
293
+ const getSlotsT = tool({
294
+ description: 'Get available appointment slots for a given date',
295
+ parameters: z.object({
296
+ eventTypeId: z.string(),
297
+ date: z.string().describe('YYYY-MM-DD'),
298
+ }),
299
+ execute: async ({ eventTypeId, date }) => {
300
+ const { slots } = await orita.getSlots(eventTypeId, date);
301
+ return slots;
302
+ },
303
+ });
304
+
305
+ const bookAppointment = tool({
306
+ description: 'Book an appointment for a client',
307
+ parameters: z.object({
308
+ eventTypeId: z.string(),
309
+ date: z.string(),
310
+ time: z.string(),
311
+ clientName: z.string(),
312
+ clientLastname: z.string(),
313
+ clientEmail: z.string().email(),
314
+ }),
315
+ execute: async (params) => {
316
+ return orita.book(params);
317
+ },
318
+ });
319
+ ```
320
+
321
+ ### LangChain.js
322
+
323
+ ```typescript
324
+ import { tool } from '@langchain/core/tools';
325
+ import { z } from 'zod';
326
+ import { OritaClient } from 'orita-sdk';
327
+
328
+ const orita = new OritaClient({ apiKey: process.env.ORITA_API_KEY! });
329
+
330
+ const getSlotsLc = tool(
331
+ async ({ eventTypeId, date }) => {
332
+ const { slots } = await orita.getSlots(eventTypeId, date);
333
+ return slots.map((s) => `${s.label} (${s.value})`).join('\n');
334
+ },
335
+ {
336
+ name: 'get_available_slots',
337
+ description: 'Get available appointment slots for a date (YYYY-MM-DD).',
338
+ schema: z.object({
339
+ eventTypeId: z.string(),
340
+ date: z.string(),
341
+ }),
342
+ },
343
+ );
344
+ ```
345
+
346
+ ---
347
+
348
+ ## Full Example: Book from Available Slots
349
+
350
+ ```typescript
351
+ import { OritaClient } from 'orita-sdk';
352
+
353
+ const orita = new OritaClient({ apiKey: process.env.ORITA_API_KEY! });
354
+
355
+ // 1. Get event types
356
+ const eventTypes = await orita.getEventTypes();
357
+ const eventTypeId = eventTypes[0].id;
358
+
359
+ // 2. Get tomorrow's slots
360
+ const tomorrow = new Date();
361
+ tomorrow.setDate(tomorrow.getDate() + 1);
362
+ const date = tomorrow.toISOString().split('T')[0]; // "YYYY-MM-DD"
363
+
364
+ const { slots } = await orita.getSlots(eventTypeId, date);
365
+
366
+ // 3. Book the first available
367
+ if (slots.length > 0) {
368
+ const booking = await orita.book({
369
+ eventTypeId,
370
+ date,
371
+ time: slots[0].value,
372
+ clientName: 'Juan',
373
+ clientLastname: 'García',
374
+ clientEmail: 'juan@example.com',
375
+ });
376
+ console.log(`✅ Booked: ${booking.id}`);
377
+ } else {
378
+ console.log('No availability tomorrow');
379
+ }
380
+ ```
381
+
382
+ ---
383
+
384
+ ## CommonJS support
385
+
386
+ The package ships both ESM and CJS bundles.
387
+
388
+ ```javascript
389
+ // CommonJS
390
+ const { OritaClient } = require('orita-sdk');
391
+ ```
392
+
393
+ ---
394
+
395
+ ## Links
396
+
397
+ - 🌐 **Website:** [orita.online](https://orita.online)
398
+ - 📚 **Developer docs:** [orita.online/developers](https://orita.online/developers)
399
+ - 🐍 **Python SDK:** [github.com/Alkilo-do/orita-python](https://github.com/Alkilo-do/orita-python) — `pip install orita-sdk`
400
+ - 🐛 **Issues:** [github.com/Alkilo-do/orita-node/issues](https://github.com/Alkilo-do/orita-node/issues)
401
+
402
+ ---
403
+
404
+ ## License
405
+
406
+ MIT © [Alkilo-do](https://github.com/Alkilo-do)