@factorialco/api-client 1.1.1 → 1.3.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 +50 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sdk.d.ts +1103 -1405
- package/dist/cjs/sdk.d.ts.map +1 -1
- package/dist/cjs/sdk.js +1129 -1435
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/cjs/webhooks.d.ts +404 -0
- package/dist/cjs/webhooks.d.ts.map +1 -0
- package/dist/cjs/webhooks.js +161 -0
- package/dist/cjs/webhooks.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sdk.d.ts +1103 -1405
- package/dist/esm/sdk.d.ts.map +1 -1
- package/dist/esm/sdk.js +1122 -1427
- package/dist/esm/sdk.js.map +1 -1
- package/dist/esm/webhooks.d.ts +404 -0
- package/dist/esm/webhooks.d.ts.map +1 -0
- package/dist/esm/webhooks.js +158 -0
- package/dist/esm/webhooks.js.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -172,6 +172,56 @@ try {
|
|
|
172
172
|
You can opt out per client (restoring the `{ data, error }` return shape) with
|
|
173
173
|
`new FactorialClient({ ..., throwOnError: false })`.
|
|
174
174
|
|
|
175
|
+
## Webhooks
|
|
176
|
+
|
|
177
|
+
Manage subscriptions through the client, and type your handler payloads with the
|
|
178
|
+
generated webhook catalog (re-exported from the package root).
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import {
|
|
182
|
+
FactorialClient,
|
|
183
|
+
WEBHOOK_CATALOG,
|
|
184
|
+
} from "@factorialco/api-client";
|
|
185
|
+
import type {
|
|
186
|
+
AtsApplicationCreateWebhook,
|
|
187
|
+
WebhookSubscriptionType,
|
|
188
|
+
WebhookPayloadMap,
|
|
189
|
+
} from "@factorialco/api-client";
|
|
190
|
+
|
|
191
|
+
const client = new FactorialClient({ apiKey: process.env.FACTORIAL_API_KEY });
|
|
192
|
+
|
|
193
|
+
// Subscribe to an event. The `challenge` is a secret you choose; Factorial echoes
|
|
194
|
+
// it back in the `x-factorial-wh-challenge` header on every delivery so you can
|
|
195
|
+
// verify the request really came from Factorial.
|
|
196
|
+
await client.apiPublic.webhookSubscriptions.create({
|
|
197
|
+
subscription_type: "ats/application/create",
|
|
198
|
+
target_url: "https://example.com/webhooks/factorial",
|
|
199
|
+
company_id: 55,
|
|
200
|
+
challenge: "a-random-secret-you-generate",
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// Type a handler directly…
|
|
204
|
+
function onApplicationCreated(payload: AtsApplicationCreateWebhook) {
|
|
205
|
+
console.log(payload.id);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// …or dispatch on the runtime subscription_type with full type safety
|
|
209
|
+
function handle<T extends WebhookSubscriptionType>(type: T, payload: WebhookPayloadMap[T]) {
|
|
210
|
+
/* payload is narrowed to the right type for `type` */
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Discover every event at runtime
|
|
214
|
+
console.log(WEBHOOK_CATALOG.length, "webhook events available");
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Factorial delivers the resource object at the **top level** of the POST body (no
|
|
218
|
+
`{ type, data }` envelope). A full event→payload reference and an SDK usage guide
|
|
219
|
+
for coding agents are available as a skill:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npx skills add https://github.com/factorialco/factorial-api-sdks --skill factorial-api-sdks
|
|
223
|
+
```
|
|
224
|
+
|
|
175
225
|
## Custom base URL
|
|
176
226
|
|
|
177
227
|
```ts
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { FactorialClient } from "./sdk.js";
|
|
|
2
2
|
export type { FactorialClientConfig } from "./sdk.js";
|
|
3
3
|
export type { PagedMeta, PaginateOptions } from "./pagination.js";
|
|
4
4
|
export * from "./generated/types.gen.js";
|
|
5
|
+
export * from "./webhooks.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClE,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClE,cAAc,0BAA0B,CAAC;AAGzC,cAAc,eAAe,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,4 +21,7 @@ exports.FactorialClient = void 0;
|
|
|
21
21
|
var sdk_js_1 = require("./sdk.js");
|
|
22
22
|
Object.defineProperty(exports, "FactorialClient", { enumerable: true, get: function () { return sdk_js_1.FactorialClient; } });
|
|
23
23
|
__exportStar(require("./generated/types.gen.js"), exports);
|
|
24
|
+
// Typed webhook catalog: per-event payload aliases, WebhookSubscriptionType,
|
|
25
|
+
// WebhookPayloadMap, and the runtime WEBHOOK_CATALOG.
|
|
26
|
+
__exportStar(require("./webhooks.js"), exports);
|
|
24
27
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAkD;AAClD,yCAAyC;AACzC,+DAA+D;AAC/D,mCAA2C;AAAlC,yGAAA,eAAe,OAAA;AAGxB,2DAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAkD;AAClD,yCAAyC;AACzC,+DAA+D;AAC/D,mCAA2C;AAAlC,yGAAA,eAAe,OAAA;AAGxB,2DAAyC;AACzC,6EAA6E;AAC7E,sDAAsD;AACtD,gDAA8B"}
|