kaafil-js 0.1.0-beta.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 Kaafil
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,37 @@
1
+ # kaafil-js
2
+
3
+ `kaafil-js` — the **headless** JavaScript/TypeScript SDK for the Kaafil v2 engine.
4
+
5
+ One npm package: auth/session handling plus every data operation the engine exposes, and the offline engine behind them — local cache, a write-ahead outbox of pending mutations each carrying a fixed idempotency key and drained FIFO-per-trip, delta sync against the authoritative server clock, and conflict classification (transient / conflict / fatal) driven by the engine's error catalog.
6
+
7
+ **Headless by design.** The SDK ships no UI components; the integrating CRM owns every pixel, under its own brand.
8
+
9
+ Request/response types are **codegen'd from the engine's published `openapi.json`** with a CI drift-check. The offline machinery is hand-authored.
10
+
11
+ ## Examples
12
+
13
+ Runnable, public reference examples live in
14
+ **[`kaafil/kaafil-js-examples`](https://github.com/kaafil/kaafil-js-examples)** (MIT). Two halves, one per
15
+ entry point:
16
+
17
+ - **`server/simulate.ts`** — the CRM-backend half, under Node. The full lifecycle, every step narrated and
18
+ asserted with a meaningful exit code: trip ingest, manifest push, manager assignment, waiting for the
19
+ asynchronous journey build, the four-axis capability read, and the typed errors worth branching on.
20
+ - **`browser/`** — the on-ground manager's half, vanilla TypeScript on Vite (no framework, so the SDK calls
21
+ are what you see). Opens a session from a server-minted token pair and proves the credential boundary.
22
+
23
+ That repo is not a sample left to rot: its Node half runs inside the engine's own smoke gate against a live
24
+ stack, so a change that breaks the published example fails the same gate that breaks this package.
25
+
26
+ **One prerequisite the examples spell out, because missing it looks like a broken SDK:** a browser consumer's
27
+ origin must be allowlisted on the engine (`CORS_ORIGIN`). A blocked request fails `fetch` with no status and
28
+ no body — the browser withholds the response by design — so this SDK can only report it as a transport
29
+ failure and cannot confirm the cause.
30
+
31
+ ## Contracts
32
+
33
+ Every contract lives in **[`kaafil-product-docs`](https://github.com/kaafil/kaafil-product-docs)** (private) — start with `architecture/08-sdk.md` (SDK design, init, auth, method surface), then `architecture/06-offline-first.md` (cache + outbox + sync), `architecture/03-auth-and-tokens.md` (manager session tokens and share tokens — API keys are server-only and never reach a browser) and `architecture/10-conventions.md §7` (the master error catalog, including how the outbox classifies each code). This README never restates a contract; it points at one.
34
+
35
+ ## Working here
36
+
37
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md) — branch and PR rules, conventional commits, and the memory-trail requirements.