@vennyx/solicrm 0.1.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 Vennyx A.Ş.
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,137 @@
1
+ # @vennyx/solicrm
2
+
3
+ Official TypeScript SDK for the [SoliCRM](https://solicrm.com) API — typed access to
4
+ contacts, companies, deals, pipelines, activities, tasks, notes, saved views and
5
+ cross-resource search.
6
+
7
+ Every request/response type is derived from the **same zod schemas the server uses**, so
8
+ the SDK cannot drift from the API. Types are bundled into this package; you do not need
9
+ any additional `@types/*`.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install @vennyx/solicrm
15
+ # or
16
+ bun add @vennyx/solicrm
17
+ ```
18
+
19
+ Requires Node.js ≥ 18 (or Bun). ESM only — this package has no CommonJS build.
20
+
21
+ ### TypeScript setup
22
+
23
+ The bundled `dist/index.d.ts` is self-contained, but it references the standard `fetch`
24
+ globals (`Response`, `RequestInit`, `AbortSignal`), so your `tsconfig.json` needs either
25
+ `"types": ["node"]` or `"lib": [..., "DOM"]`. Both `moduleResolution: "nodenext"` and
26
+ `"bundler"` are verified to resolve this package with zero errors.
27
+
28
+ ## Quick start
29
+
30
+ ```ts
31
+ import { SolicrmClient } from '@vennyx/solicrm'
32
+
33
+ const solicrm = new SolicrmClient({
34
+ apiKey: process.env.SOLICRM_API_KEY!, // "scrm_..." — created in the SoliCRM dashboard
35
+ tenantId: process.env.SOLICRM_TENANT_ID!, // the tenant the key belongs to
36
+ // baseUrl: 'https://api.solicrm.com' // default
37
+ })
38
+
39
+ const page = await solicrm.contacts.list({
40
+ limit: 25,
41
+ sort: { field: 'created_at', direction: 'desc' }, // keys come from FIELD_CATALOG
42
+ filters: { status: 'active' },
43
+ })
44
+ for (const contact of page.items) {
45
+ console.log(contact.id, contact.firstName, contact.lastName, contact.status)
46
+ }
47
+
48
+ const created = await solicrm.contacts.create({
49
+ firstName: 'Ada',
50
+ lastName: 'Lovelace',
51
+ status: 'lead',
52
+ })
53
+ await solicrm.contacts.update(created.id, { jobTitle: 'Analyst' })
54
+ ```
55
+
56
+ ### Resources
57
+
58
+ `contacts`, `companies`, `deals`, `pipelines`, `activities`, `tasks`, `notes`, `views`
59
+ (saved views) and `search` (cross-resource). Escape hatch for anything not modelled yet:
60
+ `solicrm.http.requestJson(method, path, schema, options)` / `solicrm.http.requestVoid(...)`.
61
+
62
+ ## Keyset pagination
63
+
64
+ List endpoints are cursor based (`items` / `hasMore` / `nextCursor`). Each resource has a
65
+ `listAll()` generator that walks every page, and the underlying `paginateAll` helper is
66
+ exported for custom endpoints. Both **fail loudly** instead of silently truncating when the
67
+ server reports `hasMore: true` with a `null` cursor, or repeats a cursor:
68
+
69
+ ```ts
70
+ for await (const deal of solicrm.deals.listAll({ limit: 100 })) {
71
+ console.log(deal.id, deal.amount) // amount is a string — see "Money and dates"
72
+ }
73
+ ```
74
+
75
+ ```ts
76
+ import { paginateAll } from '@vennyx/solicrm'
77
+
78
+ for await (const item of paginateAll((q) => solicrm.contacts.list(q), { limit: 100 })) {
79
+ console.log(item.id)
80
+ }
81
+ ```
82
+
83
+ ## Errors
84
+
85
+ | Class | Meaning |
86
+ | --- | --- |
87
+ | `SolicrmError` | Client-side misuse (missing `apiKey`, unknown sort field, aborted request) |
88
+ | `SolicrmApiError` | Server returned a non-2xx status — `.status`, `.message`, `.body` |
89
+ | `SolicrmResponseError` | Server returned 2xx but the body did not match the contract schema |
90
+
91
+ `SolicrmApiError.message` carries the server's message **verbatim, in Turkish** (SoliCRM's
92
+ API speaks Turkish to end users). `.body` is the raw parsed body, so richer envelopes
93
+ survive intact — the plan-limit response of `contacts.create`, for example, is
94
+ `{ code, limit, planCode }` with **no** `error` field at all:
95
+
96
+ ```ts
97
+ import { readContactLimitReached, SolicrmApiError } from '@vennyx/solicrm'
98
+
99
+ try {
100
+ await solicrm.contacts.create({ firstName: 'Grace', lastName: 'Hopper', status: 'lead' })
101
+ } catch (error) {
102
+ if (error instanceof SolicrmApiError && error.status === 402) {
103
+ const limit = readContactLimitReached(error.body)
104
+ console.log(limit?.code, limit?.limit, limit?.planCode)
105
+ }
106
+ }
107
+ ```
108
+
109
+ ## Money and dates
110
+
111
+ Money fields (`amount`, `annualRevenue`) are `numeric(18,2)` columns and the API returns
112
+ them as **strings**; timestamps are ISO 8601 **strings**. The SDK passes both through
113
+ untouched and performs no arithmetic — it never calls `parseFloat`/`Number`. Pick your own
114
+ decimal and date libraries (SoliCRM itself uses `bignumber.js` and `luxon`).
115
+
116
+ ## Custom `fetch` and retries
117
+
118
+ ```ts
119
+ const solicrm = new SolicrmClient({
120
+ apiKey,
121
+ tenantId,
122
+ fetch: myInstrumentedFetch,
123
+ retry: { maxAttempts: 3 },
124
+ })
125
+ ```
126
+
127
+ Retries use exponential backoff with half jitter and only apply to retryable statuses.
128
+ `Authorization` cannot be overridden through `headers`.
129
+
130
+ ## Related
131
+
132
+ - [`@vennyx/solicrm-mcp`](https://www.npmjs.com/package/@vennyx/solicrm-mcp) — MCP server
133
+ that exposes the same operations as tools for AI agents.
134
+
135
+ ## License
136
+
137
+ MIT © Vennyx A.Ş.