@onabl/js 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +56 -19
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,25 +1,62 @@
1
1
  # `@onabl/js`
2
2
 
3
- Framework-agnostic core of the onabl SDK. No React, no DOM assumptions —
4
- `@onabl/react` and `@onabl/next` build on top of this.
3
+ Framework-agnostic JavaScript/TypeScript client for the onabl API. No React,
4
+ no DOM assumptions install this directly in any JS backend, or use
5
+ `@onabl/react` / `@onabl/next` for framework-specific integration.
5
6
 
6
- **Status:** skeleton only (Phase 14 §14.5.2, in progress). See
7
- `docs/SDK-DESIGN.md` for the full intended API surface before adding to this
8
- package, and `docs/INTEGRATION-LAYER-TODO.md` for current build status.
7
+ ## Install
9
8
 
10
- ## What belongs here
9
+ ```bash
10
+ npm install @onabl/js
11
+ ```
11
12
 
12
- - `createOnablClient()` — the typed API client
13
+ ## Usage
14
+
15
+ ```ts
16
+ import {createOnablClient} from "@onabl/js";
17
+
18
+ const onabl = createOnablClient({
19
+ handle: "acme", // your onabl tenant handle
20
+ secretKey: process.env.ONABL_SECRET_KEY!, // server-side only, never expose to the browser
21
+ });
22
+
23
+ const form = await onabl.forms.get();
24
+
25
+ const {quoteId, quoteUrl, token} = await onabl.submissions.create({
26
+ hours: 4,
27
+ serviceType: "design",
28
+ });
29
+ ```
30
+
31
+ `secretKey` must never reach the browser. If you're building a Next.js app,
32
+ use `@onabl/next` instead, which keeps the secret key server-side for you.
33
+
34
+ ## What's included
35
+
36
+ - `createOnablClient()` — the typed API client (forms, submissions, quotes,
37
+ invoices, storage)
13
38
  - `OnablError` and its subclasses (`OnablNotFound`, `OnablUnauthorized`,
14
- `OnablValidation`, `OnablNetwork`)
15
- - The condition evaluator and form state machine, extracted from
16
- `apps/web/components/form/MultiStepForm.tsx`
17
- - `presentQuote` / `groupLineItems`, re-exported (and bundled — see
18
- `tsup.config.ts`) from `@onabl/engine`, which is never published on its own
19
-
20
- ## Build
21
-
22
- Built with `tsup`, not plain `tsc` `@onabl/engine`'s presentation code has
23
- to be bundled into this package's output since `@onabl/engine` itself is
24
- private and never installable on its own. See the comment in
25
- `tsup.config.ts` before changing the dependency/build setup.
39
+ `OnablValidation`, `OnablNetwork`) for typed error handling
40
+ - `presentQuote` / `groupLineItems` helpers for rendering a quote's line
41
+ items and totals
42
+ - Form helpers (`getVisibleSteps`, `getAllFields`, `getInitialAnswers`,
43
+ `validateFields`) for building a custom multi-step quote form UI
44
+
45
+ ## Errors
46
+
47
+ All client calls throw a subclass of `OnablError` on failure:
48
+
49
+ ```ts
50
+ import {OnablNotFound, OnablValidation} from "@onabl/js";
51
+
52
+ try {
53
+ await onabl.quotes.get(uuid, {token});
54
+ } catch (err) {
55
+ if (err instanceof OnablNotFound) {
56
+ // handle missing quote
57
+ }
58
+ if (err instanceof OnablValidation) {
59
+ // err.fieldErrors has per-field details
60
+ }
61
+ }
62
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onabl/js",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Framework-agnostic onabl SDK core — typed API client, error classes, condition evaluator, form state machine, and quote presentation. No React, no DOM assumptions. See docs/SDK-DESIGN.md.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,13 +29,13 @@
29
29
  "tsup": "^8.0.0",
30
30
  "vitest": "^1.6.0",
31
31
  "typescript": "^5.4.0",
32
- "@onabl/eslint-config": "0.0.1",
33
32
  "@onabl/engine": "0.0.1",
33
+ "@onabl/eslint-config": "0.0.1",
34
34
  "@onabl/typescript-config": "0.0.1"
35
35
  },
36
36
  "dependencies": {
37
- "@onabl/contracts": "0.1.0",
38
- "@onabl/types": "0.1.0"
37
+ "@onabl/contracts": "0.1.2",
38
+ "@onabl/types": "0.1.1"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsup",