lazo-sdk 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 +21 -0
- package/README.md +20 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +40 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Salamander
|
|
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,20 @@
|
|
|
1
|
+
# lazo-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [Lazo](../lazo-3) CRM API.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { LazoClient } from "lazo-sdk";
|
|
7
|
+
|
|
8
|
+
const lazo = new LazoClient({
|
|
9
|
+
apiToken: process.env.LAZO_API_TOKEN!, // starts with `lazo_`
|
|
10
|
+
baseUrl: "https://app.lazo.digital",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const contact = await lazo.createRecord("contacts", {
|
|
14
|
+
name: "Ada Lovelace",
|
|
15
|
+
email: "ada@example.com",
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`createRecord(resource, data)` → `POST /api/{resource}`. Throws `LazoError`
|
|
20
|
+
(with `.status`) on non-2xx responses.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Lazo CRM SDK — phase 1: create records via the Lazo API. */
|
|
2
|
+
export interface LazoClientOptions {
|
|
3
|
+
/** API token from Lazo (starts with `lazo_`). */
|
|
4
|
+
apiToken: string;
|
|
5
|
+
/** Base URL of the Lazo instance, e.g. https://app.lazo.com */
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class LazoError extends Error {
|
|
9
|
+
status: number;
|
|
10
|
+
constructor(status: number, message: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class LazoClient {
|
|
13
|
+
private readonly apiToken;
|
|
14
|
+
private readonly baseUrl;
|
|
15
|
+
constructor(options: LazoClientOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Create a record for the given resource (e.g. "contacts", "deals").
|
|
18
|
+
* Maps to POST /api/{resource} on the Lazo API.
|
|
19
|
+
*/
|
|
20
|
+
createRecord<T = Record<string, unknown>>(resource: string, data: Record<string, unknown>): Promise<T>;
|
|
21
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Lazo CRM SDK — phase 1: create records via the Lazo API. */
|
|
2
|
+
export class LazoError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
constructor(status, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.name = "LazoError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class LazoClient {
|
|
11
|
+
apiToken;
|
|
12
|
+
baseUrl;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
if (!options.apiToken)
|
|
15
|
+
throw new Error("apiToken is required");
|
|
16
|
+
if (!options.baseUrl)
|
|
17
|
+
throw new Error("baseUrl is required");
|
|
18
|
+
this.apiToken = options.apiToken;
|
|
19
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a record for the given resource (e.g. "contacts", "deals").
|
|
23
|
+
* Maps to POST /api/{resource} on the Lazo API.
|
|
24
|
+
*/
|
|
25
|
+
async createRecord(resource, data) {
|
|
26
|
+
const res = await fetch(`${this.baseUrl}/api/${resource}`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
},
|
|
32
|
+
body: JSON.stringify(data),
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
const body = await res.json().catch(() => ({}));
|
|
36
|
+
throw new LazoError(res.status, body.error ?? res.statusText);
|
|
37
|
+
}
|
|
38
|
+
return res.json();
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lazo-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Lazo CRM API",
|
|
5
|
+
"author": "Juan Daniel <juan.sanchez@stallionstudios.net>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/StallionStudios/lazo-sdk"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/StallionStudios/lazo-sdk/issues"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"test": "node --import tsx --test test/*.test.ts"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"tsx": "^4.0.0",
|
|
24
|
+
"typescript": "^5.4.0"
|
|
25
|
+
}
|
|
26
|
+
}
|