skedyul 0.1.76 → 0.1.78
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/dist/.build-stamp +1 -1
- package/dist/core/client.d.ts +20 -14
- package/dist/core/client.js +64 -48
- package/package.json +1 -1
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1769118652018
|
package/dist/core/client.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import type { CommunicationChannel, Workplace } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Error object in normalized API responses.
|
|
4
|
+
*/
|
|
5
|
+
export interface CoreApiError {
|
|
6
|
+
field: string | null;
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pagination info for list results.
|
|
12
|
+
*/
|
|
13
|
+
export interface InstancePagination {
|
|
14
|
+
page: number;
|
|
15
|
+
total: number;
|
|
16
|
+
hasMore: boolean;
|
|
17
|
+
limit: number;
|
|
18
|
+
}
|
|
2
19
|
type ClientConfig = {
|
|
3
20
|
/** Base URL for the Skedyul Core API (e.g., "https://app.skedyul.com/api") */
|
|
4
21
|
baseUrl: string;
|
|
@@ -82,10 +99,6 @@ export interface ReceiveMessageInput {
|
|
|
82
99
|
/** Optional remote/external message ID (e.g., Twilio MessageSid) */
|
|
83
100
|
remoteId?: string;
|
|
84
101
|
}
|
|
85
|
-
export interface ReceiveMessageResponse {
|
|
86
|
-
success: boolean;
|
|
87
|
-
messageId?: string;
|
|
88
|
-
}
|
|
89
102
|
export declare const communicationChannel: {
|
|
90
103
|
/**
|
|
91
104
|
* List communication channels with optional filters.
|
|
@@ -118,7 +131,9 @@ export declare const communicationChannel: {
|
|
|
118
131
|
* });
|
|
119
132
|
* ```
|
|
120
133
|
*/
|
|
121
|
-
receiveMessage(input: ReceiveMessageInput): Promise<
|
|
134
|
+
receiveMessage(input: ReceiveMessageInput): Promise<{
|
|
135
|
+
messageId: string;
|
|
136
|
+
}>;
|
|
122
137
|
};
|
|
123
138
|
/**
|
|
124
139
|
* Context required for instance operations.
|
|
@@ -148,15 +163,6 @@ export interface InstanceData {
|
|
|
148
163
|
_meta: InstanceMeta;
|
|
149
164
|
[fieldHandle: string]: unknown;
|
|
150
165
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Pagination info for list results.
|
|
153
|
-
*/
|
|
154
|
-
export interface InstancePagination {
|
|
155
|
-
page: number;
|
|
156
|
-
total: number;
|
|
157
|
-
hasMore: boolean;
|
|
158
|
-
limit: number;
|
|
159
|
-
}
|
|
160
166
|
/**
|
|
161
167
|
* Result from instance.list().
|
|
162
168
|
*/
|
package/dist/core/client.js
CHANGED
|
@@ -77,9 +77,10 @@ function configure(options) {
|
|
|
77
77
|
function getConfig() {
|
|
78
78
|
return getEffectiveConfig();
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Call the Core API with the normalized response envelope format.
|
|
82
|
+
* Throws if success is false, otherwise returns unwrapped data.
|
|
83
|
+
*/
|
|
83
84
|
async function callCore(method, params) {
|
|
84
85
|
const effectiveConfig = getEffectiveConfig();
|
|
85
86
|
const { baseUrl, apiToken } = effectiveConfig;
|
|
@@ -107,22 +108,34 @@ async function callCore(method, params) {
|
|
|
107
108
|
throw new Error(`Core API returned non-JSON response (${response.status}): ${text.slice(0, 100)}`);
|
|
108
109
|
}
|
|
109
110
|
const payload = (await response.json());
|
|
111
|
+
// Handle failure responses
|
|
112
|
+
if (!payload.success) {
|
|
113
|
+
const message = payload.errors
|
|
114
|
+
?.map((e) => (e.field ? `${e.field}: ${e.message}` : e.message))
|
|
115
|
+
.join('; ') || 'Unknown error';
|
|
116
|
+
throw new Error(message);
|
|
117
|
+
}
|
|
118
|
+
// Also handle HTTP errors (fallback for non-envelope errors)
|
|
110
119
|
if (!response.ok) {
|
|
111
|
-
throw new Error(
|
|
120
|
+
throw new Error(`Core API error (${response.status})`);
|
|
112
121
|
}
|
|
113
|
-
return
|
|
122
|
+
return {
|
|
123
|
+
data: payload.data,
|
|
124
|
+
errors: payload.errors ?? [],
|
|
125
|
+
pagination: payload.pagination,
|
|
126
|
+
};
|
|
114
127
|
}
|
|
115
128
|
exports.workplace = {
|
|
116
129
|
async list(args) {
|
|
117
|
-
const
|
|
130
|
+
const { data } = await callCore('workplace.list', {
|
|
118
131
|
...(args?.filter ? { filter: args.filter } : {}),
|
|
119
132
|
...(args?.limit ? { limit: args.limit } : {}),
|
|
120
|
-
})
|
|
121
|
-
return
|
|
133
|
+
});
|
|
134
|
+
return data;
|
|
122
135
|
},
|
|
123
136
|
async get(id) {
|
|
124
|
-
const
|
|
125
|
-
return
|
|
137
|
+
const { data } = await callCore('workplace.get', { id });
|
|
138
|
+
return data;
|
|
126
139
|
},
|
|
127
140
|
};
|
|
128
141
|
exports.communicationChannel = {
|
|
@@ -139,15 +152,15 @@ exports.communicationChannel = {
|
|
|
139
152
|
* ```
|
|
140
153
|
*/
|
|
141
154
|
async list(args) {
|
|
142
|
-
const
|
|
155
|
+
const { data } = await callCore('communicationChannel.list', {
|
|
143
156
|
...(args?.filter ? { filter: args.filter } : {}),
|
|
144
157
|
...(args?.limit ? { limit: args.limit } : {}),
|
|
145
|
-
})
|
|
146
|
-
return
|
|
158
|
+
});
|
|
159
|
+
return data;
|
|
147
160
|
},
|
|
148
161
|
async get(id) {
|
|
149
|
-
const
|
|
150
|
-
return
|
|
162
|
+
const { data } = await callCore('communicationChannel.get', { id });
|
|
163
|
+
return data;
|
|
151
164
|
},
|
|
152
165
|
/**
|
|
153
166
|
* Receive an inbound message on a communication channel.
|
|
@@ -167,14 +180,14 @@ exports.communicationChannel = {
|
|
|
167
180
|
* ```
|
|
168
181
|
*/
|
|
169
182
|
async receiveMessage(input) {
|
|
170
|
-
const
|
|
183
|
+
const { data } = await callCore('communicationChannel.receiveMessage', {
|
|
171
184
|
communicationChannelId: input.communicationChannelId,
|
|
172
185
|
from: input.from,
|
|
173
186
|
message: input.message,
|
|
174
187
|
contact: input.contact,
|
|
175
188
|
...(input.remoteId ? { remoteId: input.remoteId } : {}),
|
|
176
|
-
})
|
|
177
|
-
return
|
|
189
|
+
});
|
|
190
|
+
return data;
|
|
178
191
|
},
|
|
179
192
|
};
|
|
180
193
|
exports.instance = {
|
|
@@ -208,15 +221,18 @@ exports.instance = {
|
|
|
208
221
|
* ```
|
|
209
222
|
*/
|
|
210
223
|
async list(modelHandle, ctx, args) {
|
|
211
|
-
const
|
|
224
|
+
const { data, pagination } = await callCore('instance.list', {
|
|
212
225
|
modelHandle,
|
|
213
226
|
...(ctx?.appInstallationId ? { appInstallationId: ctx.appInstallationId } : {}),
|
|
214
227
|
...(ctx?.workplace?.id ? { workplaceId: ctx.workplace.id } : {}),
|
|
215
228
|
...(args?.page !== undefined ? { page: args.page } : {}),
|
|
216
229
|
...(args?.limit !== undefined ? { limit: args.limit } : {}),
|
|
217
230
|
...(args?.filter ? { filter: args.filter } : {}),
|
|
218
|
-
})
|
|
219
|
-
return
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
data,
|
|
234
|
+
pagination: pagination ?? { page: 1, total: 0, hasMore: false, limit: args?.limit ?? 50 },
|
|
235
|
+
};
|
|
220
236
|
},
|
|
221
237
|
/**
|
|
222
238
|
* Get a single instance by ID.
|
|
@@ -227,12 +243,12 @@ exports.instance = {
|
|
|
227
243
|
* ```
|
|
228
244
|
*/
|
|
229
245
|
async get(id, ctx) {
|
|
230
|
-
const
|
|
246
|
+
const { data } = await callCore('instance.get', {
|
|
231
247
|
id,
|
|
232
248
|
appInstallationId: ctx.appInstallationId,
|
|
233
249
|
workplaceId: ctx.workplace.id,
|
|
234
|
-
})
|
|
235
|
-
return
|
|
250
|
+
});
|
|
251
|
+
return data;
|
|
236
252
|
},
|
|
237
253
|
/**
|
|
238
254
|
* Create a new instance of an internal model.
|
|
@@ -246,13 +262,13 @@ exports.instance = {
|
|
|
246
262
|
* ```
|
|
247
263
|
*/
|
|
248
264
|
async create(modelHandle, data, ctx) {
|
|
249
|
-
const
|
|
265
|
+
const { data: instance } = await callCore('instance.create', {
|
|
250
266
|
modelHandle,
|
|
251
267
|
appInstallationId: ctx.appInstallationId,
|
|
252
268
|
workplaceId: ctx.workplace.id,
|
|
253
269
|
data,
|
|
254
|
-
})
|
|
255
|
-
return
|
|
270
|
+
});
|
|
271
|
+
return instance;
|
|
256
272
|
},
|
|
257
273
|
/**
|
|
258
274
|
* Update an existing instance.
|
|
@@ -266,13 +282,13 @@ exports.instance = {
|
|
|
266
282
|
* ```
|
|
267
283
|
*/
|
|
268
284
|
async update(id, data, ctx) {
|
|
269
|
-
const
|
|
285
|
+
const { data: instance } = await callCore('instance.update', {
|
|
270
286
|
id,
|
|
271
287
|
appInstallationId: ctx.appInstallationId,
|
|
272
288
|
workplaceId: ctx.workplace.id,
|
|
273
289
|
data,
|
|
274
|
-
})
|
|
275
|
-
return
|
|
290
|
+
});
|
|
291
|
+
return instance;
|
|
276
292
|
},
|
|
277
293
|
};
|
|
278
294
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -300,10 +316,10 @@ exports.token = {
|
|
|
300
316
|
* ```
|
|
301
317
|
*/
|
|
302
318
|
async exchange(appInstallationId) {
|
|
303
|
-
const
|
|
319
|
+
const { data } = await callCore('token.exchange', {
|
|
304
320
|
appInstallationId,
|
|
305
|
-
})
|
|
306
|
-
return
|
|
321
|
+
});
|
|
322
|
+
return data;
|
|
307
323
|
},
|
|
308
324
|
};
|
|
309
325
|
exports.file = {
|
|
@@ -323,10 +339,10 @@ exports.file = {
|
|
|
323
339
|
* ```
|
|
324
340
|
*/
|
|
325
341
|
async getUrl(fileId) {
|
|
326
|
-
const
|
|
342
|
+
const { data } = await callCore('file.getUrl', {
|
|
327
343
|
fileId,
|
|
328
|
-
})
|
|
329
|
-
return
|
|
344
|
+
});
|
|
345
|
+
return data;
|
|
330
346
|
},
|
|
331
347
|
};
|
|
332
348
|
exports.webhook = {
|
|
@@ -357,12 +373,12 @@ exports.webhook = {
|
|
|
357
373
|
* ```
|
|
358
374
|
*/
|
|
359
375
|
async create(name, context, options) {
|
|
360
|
-
const
|
|
376
|
+
const { data } = await callCore('webhook.create', {
|
|
361
377
|
name,
|
|
362
378
|
...(context ? { context } : {}),
|
|
363
379
|
...(options?.expiresIn ? { expiresIn: options.expiresIn } : {}),
|
|
364
|
-
})
|
|
365
|
-
return
|
|
380
|
+
});
|
|
381
|
+
return data;
|
|
366
382
|
},
|
|
367
383
|
/**
|
|
368
384
|
* Delete a webhook registration by ID.
|
|
@@ -376,10 +392,10 @@ exports.webhook = {
|
|
|
376
392
|
* ```
|
|
377
393
|
*/
|
|
378
394
|
async delete(id) {
|
|
379
|
-
const
|
|
395
|
+
const { data } = await callCore('webhook.delete', {
|
|
380
396
|
id,
|
|
381
|
-
})
|
|
382
|
-
return
|
|
397
|
+
});
|
|
398
|
+
return data;
|
|
383
399
|
},
|
|
384
400
|
/**
|
|
385
401
|
* Delete webhook registrations by handler name.
|
|
@@ -403,11 +419,11 @@ exports.webhook = {
|
|
|
403
419
|
* ```
|
|
404
420
|
*/
|
|
405
421
|
async deleteByName(name, options) {
|
|
406
|
-
const
|
|
422
|
+
const { data } = await callCore('webhook.deleteByName', {
|
|
407
423
|
name,
|
|
408
424
|
...(options?.filter ? { filter: options.filter } : {}),
|
|
409
|
-
})
|
|
410
|
-
return
|
|
425
|
+
});
|
|
426
|
+
return data;
|
|
411
427
|
},
|
|
412
428
|
/**
|
|
413
429
|
* List webhook registrations for this installation.
|
|
@@ -425,9 +441,9 @@ exports.webhook = {
|
|
|
425
441
|
* ```
|
|
426
442
|
*/
|
|
427
443
|
async list(options) {
|
|
428
|
-
const
|
|
444
|
+
const { data } = await callCore('webhook.list', {
|
|
429
445
|
...(options?.name ? { name: options.name } : {}),
|
|
430
|
-
})
|
|
431
|
-
return
|
|
446
|
+
});
|
|
447
|
+
return { webhooks: data };
|
|
432
448
|
},
|
|
433
449
|
};
|