@on-belay/sdk 2.2.0 → 2.2.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.
- package/README.md +110 -12
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Build a fieldset that runs on the [On Belay](https://app.onbelay.ai) governance
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@on-belay/sdk)
|
|
6
6
|
|
|
7
|
-
`@on-belay/sdk
|
|
7
|
+
`@on-belay/sdk` is the HTTP-only contract between the On Belay platform and an external fieldset (a Node service you write and host). The platform calls your service over a signed webhook on a schedule; you call the platform back through `/api/sdk/*` to reach connected integrations on behalf of enrolled orgs. No platform internals are imported. No customer credentials live in your code. Node 20+, one runtime dependency (`jose`).
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -17,6 +17,8 @@ Build a fieldset that runs on the [On Belay](https://app.onbelay.ai) governance
|
|
|
17
17
|
5. [Quickstart — Hello World](#5-quickstart--hello-world)
|
|
18
18
|
6. [The webhook handler](#6-the-webhook-handler)
|
|
19
19
|
7. [SDK API reference](#7-sdk-api-reference)
|
|
20
|
+
- [Typed integration helpers](#typed-integration-helpers)
|
|
21
|
+
- [logAction](#logaction)
|
|
20
22
|
8. [Webhook payload contract](#8-webhook-payload-contract)
|
|
21
23
|
9. [Embedded UI / dashboard tokens](#9-embedded-ui--dashboard-tokens)
|
|
22
24
|
10. [Migration from 1.0.0](#10-migration-from-100)
|
|
@@ -30,7 +32,7 @@ Build a fieldset that runs on the [On Belay](https://app.onbelay.ai) governance
|
|
|
30
32
|
## 1. Install
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
|
-
npm install @on-belay/sdk@^2.
|
|
35
|
+
npm install @on-belay/sdk@^2.2.0
|
|
34
36
|
```
|
|
35
37
|
|
|
36
38
|
Minimal usage — a complete signed-webhook receiver in five lines:
|
|
@@ -106,7 +108,7 @@ Optional: `NEON_CONNECTION_STRING` (per-enrollment, injected when an org has a N
|
|
|
106
108
|
|
|
107
109
|
## 5. Quickstart — Hello World
|
|
108
110
|
|
|
109
|
-
A fully working sample fieldset lives at [`packages/fieldset-hello-world/`](../fieldset-hello-world/). It is the canonical
|
|
111
|
+
A fully working sample fieldset lives at [`packages/fieldset-hello-world/`](../fieldset-hello-world/). It is the canonical reference fieldset — start there. The summary:
|
|
110
112
|
|
|
111
113
|
```bash
|
|
112
114
|
# 1. Clone the scaffold (or fork the Hello World fieldset).
|
|
@@ -261,6 +263,62 @@ Every HTTP-bound function shares one network contract:
|
|
|
261
263
|
|
|
262
264
|
All `/api/sdk/*` success bodies are wrapped on the wire as `{ "data": T }`; errors are `{ "error": { "code", "message" } }`. **The SDK unwraps the envelope for you** — the return types below are the unwrapped `T`. If you bypass the SDK with `curl`, expect the wrapped wire shape.
|
|
263
265
|
|
|
266
|
+
### Typed integration helpers
|
|
267
|
+
|
|
268
|
+
*Added in 2.1.0.* The package ships **75 integration modules** — auto-generated typed wrappers over `executeProxyCall`, one per connected integration (`shopify`, `hubspot`, `klaviyo`, `linear`, …). Each helper has the `operationKey` and upstream path baked in, and returns the same `Promise<ProxyResult<T>>` with the **identical retry and error contract** described above. They are a typed convenience layer, not a new transport.
|
|
269
|
+
|
|
270
|
+
Operations are **namespaced, never bare exports.** Many integrations share operation names (`listOrders`, `listCustomers`), so the SDK exports one namespace object per integration rather than colliding top-level functions. There are three ways to reach a helper:
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
import { shopify, createShopifySubClient, OnbelayClient } from "@on-belay/sdk"
|
|
274
|
+
|
|
275
|
+
// 1. Namespace object — pass orgId + integrationSlug on every call.
|
|
276
|
+
const a = await shopify.listOrders<MyOrder[]>(orgId, "shopify", {
|
|
277
|
+
queryParams: { status: "any" },
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
// 2. Sub-client factory — bind orgId + slug + config once.
|
|
281
|
+
const sc = createShopifySubClient(orgId, "shopify", { fieldsetSlug: "my-fieldset" })
|
|
282
|
+
const b = await sc.listOrders<MyOrder[]>({ queryParams: { status: "any" } })
|
|
283
|
+
|
|
284
|
+
// 3. Via OnbelayClient — the accessor returns the same bound sub-client.
|
|
285
|
+
const client = new OnbelayClient({ fieldsetSlug: "my-fieldset" })
|
|
286
|
+
const c = await client.shopify(orgId).listOrders<MyOrder[]>()
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Helpers that target a single resource take the id as a positional argument. `getLocation` is a **Shopify integration helper** (not a top-level SDK function) — it looks up one location:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
// Namespace form:
|
|
293
|
+
const loc = await shopify.getLocation<{ location: ShopifyLocation }>(
|
|
294
|
+
orgId,
|
|
295
|
+
"shopify",
|
|
296
|
+
locationId,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
// OnbelayClient form — orgId is already bound by the accessor:
|
|
300
|
+
const loc2 = await client.shopify(orgId).getLocation<{ location: ShopifyLocation }>(
|
|
301
|
+
locationId,
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
if (loc.ok) console.log(loc.data.location.name)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
GraphQL integrations (Linear, Monday) expose helpers that post `{ query, variables }` to `/graphql` — pass the GraphQL document through `options.body`:
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
import { linear } from "@on-belay/sdk"
|
|
311
|
+
|
|
312
|
+
const issues = await linear.listIssues<{ issues: { nodes: unknown[] } }>(orgId, {
|
|
313
|
+
body: {
|
|
314
|
+
query: "query { issues(first: 20) { nodes { id title } } }",
|
|
315
|
+
variables: {},
|
|
316
|
+
},
|
|
317
|
+
})
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
> A typed helper is exactly as permitted as the raw `executeProxyCall` it wraps. It does **not** bypass proxy permission gates — the org must have the integration connected, and the helper's `operationKey` (e.g. `get_location`) must be declared in your fieldset's `requiredOperations`. Calling a helper for an operation you have not declared still returns `403 operation_not_permitted`.
|
|
321
|
+
|
|
264
322
|
### `OnbelayConfig`
|
|
265
323
|
|
|
266
324
|
```ts
|
|
@@ -351,7 +409,7 @@ interface OrgContext {
|
|
|
351
409
|
interface ConnectedIntegration {
|
|
352
410
|
slug: string
|
|
353
411
|
status: "active" | "error" | "pending"
|
|
354
|
-
/** Server-allowlisted public config.
|
|
412
|
+
/** Server-allowlisted public config. shopify → { shopDomain }, others → {}. */
|
|
355
413
|
extraConfig: Record<string, string | null>
|
|
356
414
|
}
|
|
357
415
|
```
|
|
@@ -425,7 +483,7 @@ function recordPublish(
|
|
|
425
483
|
|
|
426
484
|
interface PublishResult {
|
|
427
485
|
count: number // new running count after this publish
|
|
428
|
-
freeAllowance: number // 10 by default
|
|
486
|
+
freeAllowance: number // 10 by default
|
|
429
487
|
billable: boolean // true once count > freeAllowance
|
|
430
488
|
}
|
|
431
489
|
```
|
|
@@ -440,7 +498,7 @@ const result = await recordPublish(orgId, "product_brief", {
|
|
|
440
498
|
console.log(`${result.count}/${result.freeAllowance} — billable: ${result.billable}`)
|
|
441
499
|
```
|
|
442
500
|
|
|
443
|
-
> **No `idempotencyKey
|
|
501
|
+
> **No `idempotencyKey`.** The atomic upsert on `(orgId, fieldsetId, contentType)` is the only concurrency guarantee. Strict per-key idempotency requires a `BillingIdempotency` table that is deferred to a future release. Until then, dedupe on `payload.runId` in your handler before calling `recordPublish` so retries don't double-bill.
|
|
444
502
|
|
|
445
503
|
### `isEnrolled`
|
|
446
504
|
|
|
@@ -467,6 +525,34 @@ const orgs = await getEnrolledOrgs({ fieldsetSlug: "my-fieldset" })
|
|
|
467
525
|
// → ["clk_abc123", "clk_def456"]
|
|
468
526
|
```
|
|
469
527
|
|
|
528
|
+
### `logAction`
|
|
529
|
+
|
|
530
|
+
```ts
|
|
531
|
+
function logAction(
|
|
532
|
+
orgId: string,
|
|
533
|
+
action: string,
|
|
534
|
+
metadata?: Record<string, unknown>,
|
|
535
|
+
config?: OnbelayConfig,
|
|
536
|
+
): Promise<{ ok: boolean }>
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
*Added in 2.2.0.* `POST /api/sdk/orgs/:orgId/audit`. Writes a governance-visible `AuditLog` row for an org-scoped action your fieldset took. `action` must match `/^[a-z0-9_-]+$/` and be at most 128 characters; the platform stores it namespaced as `external_fieldset_<action>`. The `orgId`, your fieldset id, and the timestamp are taken from the verified Bearer token — never from the request body — so the row cannot be spoofed to another org or fieldset.
|
|
540
|
+
|
|
541
|
+
> **`logAction` is audit-only — it is NEVER billed.** It does not touch any publish counter. Use `recordPublish` when content goes live and should count toward billing; use `logAction` to record everything else worth an audit trail (a sync started, an org skipped, a threshold crossed).
|
|
542
|
+
|
|
543
|
+
Throws `OnbelayProtocolError` on a 4xx (e.g. `invalid_action` when `action` fails the pattern or length check). Throws `OnbelayTransportError` on transport failure or a platform 5xx after the single retry.
|
|
544
|
+
|
|
545
|
+
```ts
|
|
546
|
+
const result = await logAction(orgId, "daily_sync_completed", {
|
|
547
|
+
productsScanned: 142,
|
|
548
|
+
runId: payload.runId,
|
|
549
|
+
})
|
|
550
|
+
// Stored as AuditLog action "external_fieldset_daily_sync_completed".
|
|
551
|
+
console.log(result.ok) // → true
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Also available as an `OnbelayClient` method — `client.logAction(orgId, action, metadata?)`.
|
|
555
|
+
|
|
470
556
|
### `validateWebhookSignature`
|
|
471
557
|
|
|
472
558
|
```ts
|
|
@@ -575,12 +661,20 @@ class OnbelayClient {
|
|
|
575
661
|
contentType: string,
|
|
576
662
|
metadata?: Record<string, unknown>,
|
|
577
663
|
): Promise<PublishResult>
|
|
664
|
+
logAction(
|
|
665
|
+
orgId: string,
|
|
666
|
+
action: string,
|
|
667
|
+
metadata?: Record<string, unknown>,
|
|
668
|
+
): Promise<{ ok: boolean }>
|
|
578
669
|
isEnrolled(orgId: string): Promise<boolean>
|
|
579
670
|
getEnrolledOrgs(): Promise<string[]>
|
|
671
|
+
|
|
672
|
+
shopify(orgId: string, integrationSlug?: "shopify" | "shopify_temp"): ShopifySubClient
|
|
673
|
+
// + one accessor per integration (hubspot, klaviyo, linear, …)
|
|
580
674
|
}
|
|
581
675
|
```
|
|
582
676
|
|
|
583
|
-
Convenience class that holds an `OnbelayConfig` and exposes the
|
|
677
|
+
Convenience class that holds an `OnbelayConfig` and exposes the eight HTTP-bound functions as instance methods, plus one bound sub-client accessor per integration (see [Typed integration helpers](#typed-integration-helpers)). Pure ergonomic wrapper — every method delegates to the equivalent free function or sub-client factory with the bound config. Constructor throws if `fieldsetSlug` is missing.
|
|
584
678
|
|
|
585
679
|
```ts
|
|
586
680
|
import { OnbelayClient } from "@on-belay/sdk"
|
|
@@ -617,7 +711,7 @@ class OnbelayProtocolError extends Error {
|
|
|
617
711
|
}
|
|
618
712
|
```
|
|
619
713
|
|
|
620
|
-
Thrown by HTTP-bound functions that return raw values (`getOrgContext`, `getFieldsetConfig`, `setFieldsetConfig`, `recordPublish`, `isEnrolled`, `getEnrolledOrgs`) when the platform returns a 4xx. **`executeProxyCall` does NOT throw this** — it returns the typed `ProxyResult` envelope so you can branch without a `try/catch`.
|
|
714
|
+
Thrown by HTTP-bound functions that return raw values (`getOrgContext`, `getFieldsetConfig`, `setFieldsetConfig`, `recordPublish`, `logAction`, `isEnrolled`, `getEnrolledOrgs`) when the platform returns a 4xx. **`executeProxyCall` does NOT throw this** — it returns the typed `ProxyResult` envelope so you can branch without a `try/catch`.
|
|
621
715
|
|
|
622
716
|
### Public types
|
|
623
717
|
|
|
@@ -632,6 +726,8 @@ The full type surface re-exported from the package root:
|
|
|
632
726
|
| `EnrolledOrg` | Forward-compatible richer enrollment shape (the function returns `string[]`; this is exposed for typed downstream usage). |
|
|
633
727
|
| `ContentType` | Free-form string alias used by `recordPublish`. |
|
|
634
728
|
| `PublishResult` | `recordPublish` return shape. |
|
|
729
|
+
| `LogActionResult` | `logAction` return shape (`{ ok: boolean }`). |
|
|
730
|
+
| `ShopifySlug` | `"shopify" \| "shopify_temp"` — accepted by the Shopify integration helpers. |
|
|
635
731
|
| `WebhookPayload` | Inbound webhook body. See [§8](#8-webhook-payload-contract). |
|
|
636
732
|
| `WebhookHandlerOptions`, `WebhookHandlerContext`, `WebhookResult` | `createOnbelayWebhookHandler` shapes. |
|
|
637
733
|
| `WebhookVerifyOptions` | Options for `validateWebhookSignature` / handler. |
|
|
@@ -673,7 +769,7 @@ X-Onbelay-Timestamp: <ISO 8601, equal to payload.timestamp>
|
|
|
673
769
|
|---|---|---|
|
|
674
770
|
| `orgId` | yes | The enrolled org this run targets. |
|
|
675
771
|
| `fieldsetSlug` | yes | Your fieldset slug. The handler verifies this matches `options.fieldsetSlug`. |
|
|
676
|
-
| `triggerType` | yes | `scheduled` (daily 8am UTC) or `manual` (owner clicked "Trigger run"). The other three values are reserved for future platform features; the SDK type accepts them but the platform does not currently emit them
|
|
772
|
+
| `triggerType` | yes | `scheduled` (daily 8am UTC) or `manual` (owner clicked "Trigger run"). The other three values are reserved for future platform features; the SDK type accepts them but the platform does not currently emit them. |
|
|
677
773
|
| `timestamp` | yes | ISO 8601. Used together with `maxAgeSeconds` for replay protection. |
|
|
678
774
|
| `runId` | yes | Deterministic: `ofs_<orgFieldsetId>-<YYYYMMDD>-<triggerType>`. Inngest retries on non-200 reuse the same `runId` — dedupe on this and you trivially survive retries. |
|
|
679
775
|
| `neonConnectionString` | optional | Present only when this org has a Neon branch provisioned. Read/write on your branch only. |
|
|
@@ -774,6 +870,8 @@ A worked example lives in [`packages/fieldset-hello-world/src/app/dashboard/page
|
|
|
774
870
|
|
|
775
871
|
## 10. Migration from 1.0.0
|
|
776
872
|
|
|
873
|
+
> **Upgrading from 2.0.0 or later? No code changes.** 2.1.0 (typed integration helpers) and 2.2.0 (`logAction`) are purely additive over 2.0.0 — no exports were removed and no existing signature changed. Upgrading from any 2.x release to 2.2.0 is a no-code `npm install @on-belay/sdk@2.2.0`. The steps below apply **only** to services still on 1.0.0.
|
|
874
|
+
|
|
777
875
|
`@on-belay/sdk@2.0.0` is a complete rewrite. The 1.0.0 SDK depended on platform internals and could not be installed cleanly outside the On Belay monorepo. 2.0.0 is HTTP-only, framework-agnostic, and has exactly one runtime dependency (`jose`).
|
|
778
876
|
|
|
779
877
|
### Removed exports
|
|
@@ -791,14 +889,14 @@ These exports do not exist in 2.0.0 — importing them fails at install or compi
|
|
|
791
889
|
|
|
792
890
|
### Other breaking changes
|
|
793
891
|
|
|
794
|
-
- **`recordPublish` no longer accepts `idempotencyKey`** (Decision B; coming back in
|
|
892
|
+
- **`recordPublish` no longer accepts `idempotencyKey`** (Decision B; coming back in a future release with a `BillingIdempotency` table). Dedupe on `payload.runId` in your handler instead.
|
|
795
893
|
- **`executeProxyCall` signature changed.** New positional arguments: `(orgId, integrationSlug, operationKey, path, options?, config?)`. The `fieldsetSlug` argument is gone — the SDK reads it from `OnbelayConfig`.
|
|
796
894
|
- **The fieldset token is no longer included in the webhook payload.** Read it from `process.env.ONBELAY_FIELDSET_TOKEN`. The SDK does this by default.
|
|
797
895
|
- **`ONBELAY_PROXY_URL` is base URL only** — `https://app.onbelay.ai`. The SDK appends paths internally. The 1.0.0 value ended in `/api/sdk/proxy`; the platform team runs a backfill script for existing services on cutover.
|
|
798
896
|
|
|
799
897
|
### Migration checklist
|
|
800
898
|
|
|
801
|
-
1. `npm install @on-belay/sdk@2.
|
|
899
|
+
1. `npm install @on-belay/sdk@2.2.0`
|
|
802
900
|
2. Delete imports of the removed exports listed above.
|
|
803
901
|
3. Replace your scheduler/runner setup with `createOnbelayWebhookHandler` from §6.
|
|
804
902
|
4. Update `executeProxyCall` call sites for the new positional signature.
|
|
@@ -821,7 +919,7 @@ These exports do not exist in 2.0.0 — importing them fails at install or compi
|
|
|
821
919
|
| Proxy returns `403 integration_not_connected` | The org has not connected the upstream integration. Skip gracefully — do not throw. The org admin will reconnect on their schedule. |
|
|
822
920
|
| Proxy returns `403 org_not_enrolled` | This org is not enrolled in your fieldset, or enrollment was paused. Check `OrgFieldset.status = "active"`. |
|
|
823
921
|
| Proxy returns `403 fieldset_inactive` | The platform owner deactivated your fieldset (kill switch). Contact On Belay support. |
|
|
824
|
-
| Proxy returns `429 rate_limited` | You exceeded the per-token bucket: 60 proxy calls / 60 s, 30 writes / 60 s, 120 reads / 60 s. Wait 60 seconds before retrying — the bucket refills every 60 s. (
|
|
922
|
+
| Proxy returns `429 rate_limited` | You exceeded the per-token bucket: 60 proxy calls / 60 s, 30 writes / 60 s, 120 reads / 60 s. Wait 60 seconds before retrying — the bucket refills every 60 s. (The SDK does not surface the `Retry-After` header on `ProxyResult`; a future patch will.) |
|
|
825
923
|
| `OnbelayTransportError` with `attempts === 2` | Platform retried once on a 502/503/504 and the second attempt also failed. Catch in your handler, log to Sentry, and let the next scheduled run pick up the work. |
|
|
826
924
|
| `OnbelayTransportError` with `status === 500` | Platform-side bug, not transient. Not retried. Open a support ticket with the run id. |
|
|
827
925
|
| Inngest is retrying my webhook 3× for the same `runId` | Your handler returned 5xx or timed out (>30 s). Implement idempotency on `runId` so retries are cheap, and offload long work to a background queue while returning 200 quickly. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @on-belay/sdk
|
|
2
|
+
* @on-belay/sdk — Public types
|
|
3
3
|
*
|
|
4
4
|
* All types used by external fieldset authors are exported from here. The
|
|
5
5
|
* surface matches `docs/onbelay-platform/specs/external-fieldset-sdk-v2-spec.md`
|
|
@@ -175,7 +175,7 @@ interface DashboardTokenPayload {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
|
-
* @on-belay/sdk
|
|
178
|
+
* @on-belay/sdk — executeProxyCall + shared HTTP transport
|
|
179
179
|
*
|
|
180
180
|
* `executeProxyCall` is the only sanctioned way for an external fieldset to call
|
|
181
181
|
* a third-party API. Every call is dispatched as
|
|
@@ -211,7 +211,7 @@ declare function executeProxyCall<T = unknown>(orgId: string, integrationSlug: s
|
|
|
211
211
|
}, config?: OnbelayConfig): Promise<ProxyResult<T>>;
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
|
-
* @on-belay/sdk
|
|
214
|
+
* @on-belay/sdk — getOrgContext
|
|
215
215
|
*
|
|
216
216
|
* Returns the calling fieldset's view of one enrolled org — orgName +
|
|
217
217
|
* connected integrations + server-allowlisted `extraConfig`. Encrypted
|
|
@@ -230,7 +230,7 @@ declare function executeProxyCall<T = unknown>(orgId: string, integrationSlug: s
|
|
|
230
230
|
declare function getOrgContext(orgId: string, config?: OnbelayConfig): Promise<OrgContext>;
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
|
-
* @on-belay/sdk
|
|
233
|
+
* @on-belay/sdk — getFieldsetConfig / setFieldsetConfig
|
|
234
234
|
*
|
|
235
235
|
* Read/write the **fieldset namespace** of `OrgFieldset.config` JSON for one
|
|
236
236
|
* enrolled org. The `admin` namespace (used by org admins for config the
|
|
@@ -274,7 +274,7 @@ declare function getFieldsetConfig<T = Record<string, unknown>>(orgId: string, c
|
|
|
274
274
|
declare function setFieldsetConfig<T = Record<string, unknown>>(orgId: string, patch: Partial<T>, config?: OnbelayConfig): Promise<void>;
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
* @on-belay/sdk
|
|
277
|
+
* @on-belay/sdk — isEnrolled / getEnrolledOrgs
|
|
278
278
|
*
|
|
279
279
|
* Enrollment-state queries scoped to the calling fieldset (the token
|
|
280
280
|
* identifies the fieldset; clients cannot list other fieldsets' enrollments).
|
|
@@ -308,7 +308,7 @@ declare function isEnrolled(orgId: string, config?: OnbelayConfig): Promise<bool
|
|
|
308
308
|
declare function getEnrolledOrgs(config?: OnbelayConfig): Promise<string[]>;
|
|
309
309
|
|
|
310
310
|
/**
|
|
311
|
-
* @on-belay/sdk
|
|
311
|
+
* @on-belay/sdk — recordPublish
|
|
312
312
|
*
|
|
313
313
|
* Increments the org's PublishCounter for this fieldset and content type.
|
|
314
314
|
* v2.0.0 does NOT support an idempotency key (Decision B in spec §15) — the
|
|
@@ -354,7 +354,7 @@ interface LogActionResult {
|
|
|
354
354
|
declare function logAction(orgId: string, action: string, metadata?: Record<string, unknown>, config?: OnbelayConfig): Promise<LogActionResult>;
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
* @on-belay/sdk
|
|
357
|
+
* @on-belay/sdk — validateWebhookSignature
|
|
358
358
|
*
|
|
359
359
|
* Self-contained HMAC-SHA256 webhook signature verification.
|
|
360
360
|
*
|
|
@@ -391,7 +391,7 @@ declare function logAction(orgId: string, action: string, metadata?: Record<stri
|
|
|
391
391
|
declare function validateWebhookSignature(rawBody: string | Buffer, signatureHeader: string, secret: string, timestamp?: string, options?: WebhookVerifyOptions): boolean;
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
|
-
* @on-belay/sdk
|
|
394
|
+
* @on-belay/sdk — validateDashboardToken
|
|
395
395
|
*
|
|
396
396
|
* Browser- and Node-compatible JWT verification using `jose`. Validates a
|
|
397
397
|
* dashboard context token issued by the On Belay platform when an org admin
|
|
@@ -420,7 +420,7 @@ declare function validateDashboardToken(token: string, secret: string): Promise<
|
|
|
420
420
|
} | null>;
|
|
421
421
|
|
|
422
422
|
/**
|
|
423
|
-
* @on-belay/sdk
|
|
423
|
+
* @on-belay/sdk — createOnbelayWebhookHandler
|
|
424
424
|
*
|
|
425
425
|
* Framework-agnostic webhook handler factory. The returned function takes a
|
|
426
426
|
* raw body string + headers map and returns `{ status, body, headers }` so it
|
|
@@ -9842,7 +9842,7 @@ declare const zendesk: {
|
|
|
9842
9842
|
};
|
|
9843
9843
|
|
|
9844
9844
|
/**
|
|
9845
|
-
* @on-belay/sdk
|
|
9845
|
+
* @on-belay/sdk — OnbelayClient
|
|
9846
9846
|
*
|
|
9847
9847
|
* Convenience class that holds an `OnbelayConfig` and exposes the SDK's
|
|
9848
9848
|
* HTTP-bound functions as instance methods. Pure ergonomic wrapper — every
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @on-belay/sdk
|
|
2
|
+
* @on-belay/sdk — Public types
|
|
3
3
|
*
|
|
4
4
|
* All types used by external fieldset authors are exported from here. The
|
|
5
5
|
* surface matches `docs/onbelay-platform/specs/external-fieldset-sdk-v2-spec.md`
|
|
@@ -175,7 +175,7 @@ interface DashboardTokenPayload {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
|
-
* @on-belay/sdk
|
|
178
|
+
* @on-belay/sdk — executeProxyCall + shared HTTP transport
|
|
179
179
|
*
|
|
180
180
|
* `executeProxyCall` is the only sanctioned way for an external fieldset to call
|
|
181
181
|
* a third-party API. Every call is dispatched as
|
|
@@ -211,7 +211,7 @@ declare function executeProxyCall<T = unknown>(orgId: string, integrationSlug: s
|
|
|
211
211
|
}, config?: OnbelayConfig): Promise<ProxyResult<T>>;
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
|
-
* @on-belay/sdk
|
|
214
|
+
* @on-belay/sdk — getOrgContext
|
|
215
215
|
*
|
|
216
216
|
* Returns the calling fieldset's view of one enrolled org — orgName +
|
|
217
217
|
* connected integrations + server-allowlisted `extraConfig`. Encrypted
|
|
@@ -230,7 +230,7 @@ declare function executeProxyCall<T = unknown>(orgId: string, integrationSlug: s
|
|
|
230
230
|
declare function getOrgContext(orgId: string, config?: OnbelayConfig): Promise<OrgContext>;
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
|
-
* @on-belay/sdk
|
|
233
|
+
* @on-belay/sdk — getFieldsetConfig / setFieldsetConfig
|
|
234
234
|
*
|
|
235
235
|
* Read/write the **fieldset namespace** of `OrgFieldset.config` JSON for one
|
|
236
236
|
* enrolled org. The `admin` namespace (used by org admins for config the
|
|
@@ -274,7 +274,7 @@ declare function getFieldsetConfig<T = Record<string, unknown>>(orgId: string, c
|
|
|
274
274
|
declare function setFieldsetConfig<T = Record<string, unknown>>(orgId: string, patch: Partial<T>, config?: OnbelayConfig): Promise<void>;
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
* @on-belay/sdk
|
|
277
|
+
* @on-belay/sdk — isEnrolled / getEnrolledOrgs
|
|
278
278
|
*
|
|
279
279
|
* Enrollment-state queries scoped to the calling fieldset (the token
|
|
280
280
|
* identifies the fieldset; clients cannot list other fieldsets' enrollments).
|
|
@@ -308,7 +308,7 @@ declare function isEnrolled(orgId: string, config?: OnbelayConfig): Promise<bool
|
|
|
308
308
|
declare function getEnrolledOrgs(config?: OnbelayConfig): Promise<string[]>;
|
|
309
309
|
|
|
310
310
|
/**
|
|
311
|
-
* @on-belay/sdk
|
|
311
|
+
* @on-belay/sdk — recordPublish
|
|
312
312
|
*
|
|
313
313
|
* Increments the org's PublishCounter for this fieldset and content type.
|
|
314
314
|
* v2.0.0 does NOT support an idempotency key (Decision B in spec §15) — the
|
|
@@ -354,7 +354,7 @@ interface LogActionResult {
|
|
|
354
354
|
declare function logAction(orgId: string, action: string, metadata?: Record<string, unknown>, config?: OnbelayConfig): Promise<LogActionResult>;
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
* @on-belay/sdk
|
|
357
|
+
* @on-belay/sdk — validateWebhookSignature
|
|
358
358
|
*
|
|
359
359
|
* Self-contained HMAC-SHA256 webhook signature verification.
|
|
360
360
|
*
|
|
@@ -391,7 +391,7 @@ declare function logAction(orgId: string, action: string, metadata?: Record<stri
|
|
|
391
391
|
declare function validateWebhookSignature(rawBody: string | Buffer, signatureHeader: string, secret: string, timestamp?: string, options?: WebhookVerifyOptions): boolean;
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
|
-
* @on-belay/sdk
|
|
394
|
+
* @on-belay/sdk — validateDashboardToken
|
|
395
395
|
*
|
|
396
396
|
* Browser- and Node-compatible JWT verification using `jose`. Validates a
|
|
397
397
|
* dashboard context token issued by the On Belay platform when an org admin
|
|
@@ -420,7 +420,7 @@ declare function validateDashboardToken(token: string, secret: string): Promise<
|
|
|
420
420
|
} | null>;
|
|
421
421
|
|
|
422
422
|
/**
|
|
423
|
-
* @on-belay/sdk
|
|
423
|
+
* @on-belay/sdk — createOnbelayWebhookHandler
|
|
424
424
|
*
|
|
425
425
|
* Framework-agnostic webhook handler factory. The returned function takes a
|
|
426
426
|
* raw body string + headers map and returns `{ status, body, headers }` so it
|
|
@@ -9842,7 +9842,7 @@ declare const zendesk: {
|
|
|
9842
9842
|
};
|
|
9843
9843
|
|
|
9844
9844
|
/**
|
|
9845
|
-
* @on-belay/sdk
|
|
9845
|
+
* @on-belay/sdk — OnbelayClient
|
|
9846
9846
|
*
|
|
9847
9847
|
* Convenience class that holds an `OnbelayConfig` and exposes the SDK's
|
|
9848
9848
|
* HTTP-bound functions as instance methods. Pure ergonomic wrapper — every
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@on-belay/sdk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"description": "On Belay fieldset SDK — HTTP-only contract between the platform and external fieldsets
|
|
8
|
+
"description": "On Belay fieldset SDK — HTTP-only contract between the platform and external fieldsets.",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"module": "./dist/index.mjs",
|
|
11
11
|
"types": "./dist/index.d.ts",
|