@clivly/core 0.7.0 → 0.7.2

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 +59 -40
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,47 +1,77 @@
1
1
  # @clivly/core
2
2
 
3
- ORM- and auth-agnostic contracts and shared domain types for [Clivly](https://clivly.com) — the CRM that lives inside your app.
3
+ Contracts and shared helpers for Clivly adapters, config validation, discovery,
4
+ and sync logic.
4
5
 
5
- This package defines the interfaces that ORM and auth adapters implement. It has no runtime dependencies.
6
+ ## Who this package is for
6
7
 
7
- ## Exports
8
+ Most application integrators should install `clivly` and import from
9
+ `clivly/sdk`.
8
10
 
9
- | Entry | Contents |
10
- |---|---|
11
- | `.` | Everything below, re-exported |
12
- | `@clivly/core/adapter` | `CRMAdapter` — the interface every ORM implementation fulfils (org-scoped; contacts, companies, deals, tasks, activities) |
13
- | `@clivly/core/auth-adapter` | `ClivlyAuthAdapter`, `authCustom()`, `MembershipResolver` — pluggable host-app identity + the `crm_members` authorization layer |
14
- | `@clivly/core/types` | Shared domain types (`Contact`, `Company`, `Deal`, `Task`, `Note`, `Activity`, inputs, filters, `CrmRole`) |
15
- | `@clivly/core/drizzle` | `discoverFromDrizzle(schema)` — derive the discovery shape from a Drizzle schema object. Requires the optional `drizzle-orm` peer dependency |
11
+ `@clivly/core` is the lower-level public package for:
12
+
13
+ - adapter authors
14
+ - tooling authors
15
+ - consumers who intentionally want the contract and utility layer directly
16
+
17
+ It has a small runtime surface centered on `zod`. `drizzle-orm` is only needed
18
+ when you use the Drizzle discovery subpath.
16
19
 
17
- ## Schema discovery (Drizzle)
20
+ ## Install
18
21
 
19
- `discoverFromDrizzle` turns your Drizzle schema into Clivly's discovery shape, so you don't hand-author table/column arrays:
22
+ ```bash
23
+ npm install @clivly/core
24
+ ```
25
+
26
+ Optional Drizzle integration:
27
+
28
+ ```bash
29
+ npm install @clivly/core drizzle-orm
30
+ ```
31
+
32
+ ## Exports
33
+
34
+ | Entry | Contents |
35
+ | --- | --- |
36
+ | `@clivly/core` | Re-exports the package surface |
37
+ | `@clivly/core/adapter` | `CRMAdapter` |
38
+ | `@clivly/core/auth-adapter` | `ClivlyAuthAdapter`, `authCustom()`, `MembershipResolver` |
39
+ | `@clivly/core/types` | Shared CRM types and inputs |
40
+ | `@clivly/core/drizzle` | `discoverFromDrizzle(schema)` |
41
+ | `@clivly/core/entity-config` | `defineClivlyConfig`, validators, canonical field metadata |
42
+ | `@clivly/core/view-compiler` | Entity-view compilation helpers |
43
+ | `@clivly/core/sync-engine` | `runSync`, `previewSync`, `reconcile`, `computeSampleWarnings` |
44
+ | `@clivly/core/entity-heuristics` | Concept and mapping inference helpers |
45
+ | `@clivly/core/mapping-score` | Scoring tiers and ambiguity helpers |
46
+ | `@clivly/core/mapping-form` | UI-to-config assembly helpers |
47
+ | `@clivly/core/mappings-config` | Persisted-mapping to entity-config conversion |
48
+
49
+ ## Drizzle schema discovery
20
50
 
21
51
  ```ts
22
52
  import { discoverFromDrizzle } from "@clivly/core/drizzle";
23
53
  import * as schema from "./db/schema";
24
54
 
25
55
  const tables = discoverFromDrizzle(schema);
26
- // → [{ name: "participants", columns: ["id", "full_name", "email", …] }, …]
27
56
  ```
28
57
 
29
- Column names are the real DB names (`full_name`), not the Drizzle keys (`fullName`). `drizzle-orm` is an **optional peer dependency** — only needed when you import this subpath.
58
+ This returns real database column names such as `full_name`, not Drizzle
59
+ property keys such as `fullName`.
30
60
 
31
- ## Usage
61
+ ## Example: adapter contract
32
62
 
33
63
  ```ts
34
- import type { CRMAdapter } from "@clivly/core";
64
+ import type { CRMAdapter } from "@clivly/core/adapter";
35
65
 
36
- // packages/drizzle implements this; Prisma/Kysely can follow.
37
66
  function useAdapter(crm: CRMAdapter) {
38
- return crm.getContacts(orgId);
67
+ return crm.getContacts("org_1");
39
68
  }
40
69
  ```
41
70
 
42
- ## The `$raw` escape hatch
71
+ ## `$raw` escape hatch
43
72
 
44
- Entity `filter`s and relationship `via`s accept a `$raw` form — an opaque SQL fragment for predicates the operators can't express (e.g. a cross-table condition):
73
+ Entity `filter`s and relationship `via`s accept a `$raw` SQL fragment for cases
74
+ the structured operators cannot express:
45
75
 
46
76
  ```ts
47
77
  defineClivlyConfig({
@@ -56,30 +86,19 @@ defineClivlyConfig({
56
86
  });
57
87
  ```
58
88
 
59
- **`$raw` is unchecked.** `validateEntitiesConfig` deliberately **skips** `$raw` filters and joins — it can't know your columns are real or your SQL is valid. Two consequences:
89
+ `$raw` is intentionally unchecked:
60
90
 
61
- - **Injection safety is on you.** Never interpolate untrusted input into a `$raw` string; treat it like handwritten SQL. Everything else in the config is escaped for you; `$raw` is not.
62
- - **Mistakes surface at sync time, not config time** — unless you dry-run it.
91
+ - never interpolate untrusted input into it
92
+ - mistakes surface when the query is exercised, not at config-parse time
63
93
 
64
- ### Dry-run with `explainEntitiesConfig`
94
+ Use `explainEntitiesConfig()` to dry-run compiled views before your first sync.
65
95
 
66
- `explainEntitiesConfig(config, run, options?)` compiles each entity's view and executes it via a runner you provide, so a broken `$raw` fragment fails **before** the first sync. It never throws — it returns one `ExplainResult` per entity:
96
+ ## More docs
67
97
 
68
- ```ts
69
- import { explainEntitiesConfig } from "@clivly/core";
70
-
71
- const results = await explainEntitiesConfig(config, (sql) =>
72
- // Run somewhere side-effect-free — e.g. a transaction you roll back.
73
- db.transaction(async (tx) => {
74
- await tx.execute(sql);
75
- throw new Rollback();
76
- }).catch(swallowRollback)
77
- );
78
-
79
- for (const r of results) {
80
- if (!r.ok) console.error(`${r.entityKey}: ${r.error}`);
81
- }
82
- ```
98
+ - Stability policy:
99
+ [STABILITY.md](https://github.com/amani-joseph/clivly.com/blob/master/STABILITY.md)
100
+ - SDK docs:
101
+ [packages/sdk/README.md](https://github.com/amani-joseph/clivly.com/blob/master/packages/sdk/README.md)
83
102
 
84
103
  ## License
85
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clivly/core",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "ORM/auth-agnostic CRM adapter contracts and shared domain types for Clivly.",
@@ -138,7 +138,7 @@
138
138
  "zod": "^4.1.13"
139
139
  },
140
140
  "peerDependencies": {
141
- "drizzle-orm": ">=0.30"
141
+ "drizzle-orm": ">=0.30 || >=1.0.0-rc.0"
142
142
  },
143
143
  "peerDependenciesMeta": {
144
144
  "drizzle-orm": {