@klozeo/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.
Files changed (69) hide show
  1. package/README.md +141 -0
  2. package/dist/cjs/attribute-helpers.js +43 -0
  3. package/dist/cjs/attribute-helpers.js.map +1 -0
  4. package/dist/cjs/client.js +150 -0
  5. package/dist/cjs/client.js.map +1 -0
  6. package/dist/cjs/errors.js +75 -0
  7. package/dist/cjs/errors.js.map +1 -0
  8. package/dist/cjs/filters/index.js +320 -0
  9. package/dist/cjs/filters/index.js.map +1 -0
  10. package/dist/cjs/index.js +42 -0
  11. package/dist/cjs/index.js.map +1 -0
  12. package/dist/cjs/package.json +3 -0
  13. package/dist/cjs/resources/leads.js +156 -0
  14. package/dist/cjs/resources/leads.js.map +1 -0
  15. package/dist/cjs/resources/notes.js +50 -0
  16. package/dist/cjs/resources/notes.js.map +1 -0
  17. package/dist/cjs/resources/scoring.js +63 -0
  18. package/dist/cjs/resources/scoring.js.map +1 -0
  19. package/dist/cjs/resources/webhooks.js +41 -0
  20. package/dist/cjs/resources/webhooks.js.map +1 -0
  21. package/dist/cjs/types.js +13 -0
  22. package/dist/cjs/types.js.map +1 -0
  23. package/dist/cjs/utils.js +179 -0
  24. package/dist/cjs/utils.js.map +1 -0
  25. package/dist/esm/attribute-helpers.js +36 -0
  26. package/dist/esm/attribute-helpers.js.map +1 -0
  27. package/dist/esm/client.js +159 -0
  28. package/dist/esm/client.js.map +1 -0
  29. package/dist/esm/errors.js +72 -0
  30. package/dist/esm/errors.js.map +1 -0
  31. package/dist/esm/filters/index.js +304 -0
  32. package/dist/esm/filters/index.js.map +1 -0
  33. package/dist/esm/index.js +26 -0
  34. package/dist/esm/index.js.map +1 -0
  35. package/dist/esm/resources/leads.js +153 -0
  36. package/dist/esm/resources/leads.js.map +1 -0
  37. package/dist/esm/resources/notes.js +47 -0
  38. package/dist/esm/resources/notes.js.map +1 -0
  39. package/dist/esm/resources/scoring.js +60 -0
  40. package/dist/esm/resources/scoring.js.map +1 -0
  41. package/dist/esm/resources/webhooks.js +38 -0
  42. package/dist/esm/resources/webhooks.js.map +1 -0
  43. package/dist/esm/types.js +10 -0
  44. package/dist/esm/types.js.map +1 -0
  45. package/dist/esm/utils.js +168 -0
  46. package/dist/esm/utils.js.map +1 -0
  47. package/dist/types/attribute-helpers.d.ts +27 -0
  48. package/dist/types/attribute-helpers.d.ts.map +1 -0
  49. package/dist/types/client.d.ts +64 -0
  50. package/dist/types/client.d.ts.map +1 -0
  51. package/dist/types/errors.d.ts +44 -0
  52. package/dist/types/errors.d.ts.map +1 -0
  53. package/dist/types/filters/index.d.ts +173 -0
  54. package/dist/types/filters/index.d.ts.map +1 -0
  55. package/dist/types/index.d.ts +23 -0
  56. package/dist/types/index.d.ts.map +1 -0
  57. package/dist/types/resources/leads.d.ts +67 -0
  58. package/dist/types/resources/leads.d.ts.map +1 -0
  59. package/dist/types/resources/notes.d.ts +31 -0
  60. package/dist/types/resources/notes.d.ts.map +1 -0
  61. package/dist/types/resources/scoring.d.ts +35 -0
  62. package/dist/types/resources/scoring.d.ts.map +1 -0
  63. package/dist/types/resources/webhooks.d.ts +25 -0
  64. package/dist/types/resources/webhooks.d.ts.map +1 -0
  65. package/dist/types/types.d.ts +409 -0
  66. package/dist/types/types.d.ts.map +1 -0
  67. package/dist/types/utils.d.ts +49 -0
  68. package/dist/types/utils.d.ts.map +1 -0
  69. package/package.json +52 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Export format options.
3
+ */
4
+ export var ExportFormat;
5
+ (function (ExportFormat) {
6
+ ExportFormat["CSV"] = "csv";
7
+ ExportFormat["JSON"] = "json";
8
+ ExportFormat["XLSX"] = "xlsx";
9
+ })(ExportFormat || (ExportFormat = {}));
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAiEA;;GAEG;AACH,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;IACb,6BAAa,CAAA;AACf,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB"}
@@ -0,0 +1,168 @@
1
+ import { KlozeoError, NotFoundError, UnauthorizedError, ForbiddenError, RateLimitedError, BadRequestError, } from "./errors.js";
2
+ /**
3
+ * Append filter, sort, and pagination params to a URLSearchParams instance.
4
+ */
5
+ export function buildQueryParams(params, opts) {
6
+ if (opts.filters) {
7
+ for (const f of opts.filters) {
8
+ params.append("filter", f.toString());
9
+ }
10
+ }
11
+ if (opts.sortBy !== undefined) {
12
+ params.set("sort_by", opts.sortBy);
13
+ }
14
+ if (opts.sortOrder !== undefined) {
15
+ params.set("sort_order", opts.sortOrder.toUpperCase());
16
+ }
17
+ if (opts.limit !== undefined) {
18
+ params.set("limit", String(opts.limit));
19
+ }
20
+ if (opts.cursor !== undefined) {
21
+ params.set("cursor", opts.cursor);
22
+ }
23
+ if (opts.format !== undefined) {
24
+ params.set("format", opts.format);
25
+ }
26
+ }
27
+ /**
28
+ * Parse an API error response body and produce a typed KlozeoError.
29
+ */
30
+ export async function parseError(response) {
31
+ const retryAfterHeader = response.headers.get("Retry-After");
32
+ const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : 60;
33
+ let body = {};
34
+ try {
35
+ body = await response.json();
36
+ }
37
+ catch {
38
+ // non-JSON body — use status text
39
+ }
40
+ const message = body.message ?? body.error ?? response.statusText ?? "Unknown error";
41
+ const code = body.code ?? body.error ?? "unknown";
42
+ switch (response.status) {
43
+ case 400:
44
+ return new BadRequestError(message, code);
45
+ case 401:
46
+ return new UnauthorizedError(message, code);
47
+ case 403:
48
+ return new ForbiddenError(message, code);
49
+ case 404:
50
+ return new NotFoundError(message, code);
51
+ case 429:
52
+ return new RateLimitedError(message, retryAfter, code);
53
+ default:
54
+ return new KlozeoError(message, response.status, code);
55
+ }
56
+ }
57
+ /**
58
+ * Sleep for the given number of milliseconds.
59
+ */
60
+ export function sleep(ms) {
61
+ return new Promise((resolve) => setTimeout(resolve, ms));
62
+ }
63
+ /**
64
+ * Compute exponential back-off delay with jitter.
65
+ * @param attempt - Zero-based attempt index.
66
+ * @param baseMs - Base delay in milliseconds (default 500).
67
+ */
68
+ export function backoffDelay(attempt, baseMs = 500) {
69
+ const exp = Math.min(attempt, 8); // cap exponent
70
+ const delay = baseMs * Math.pow(2, exp);
71
+ // add ±20% jitter
72
+ const jitter = delay * 0.2 * (Math.random() * 2 - 1);
73
+ return Math.round(delay + jitter);
74
+ }
75
+ /**
76
+ * Convert a snake_case API lead object to a camelCase Lead.
77
+ */
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ export function deserializeLead(raw) {
80
+ return {
81
+ id: raw.id,
82
+ name: raw.name,
83
+ source: raw.source,
84
+ score: raw.score ?? 0,
85
+ createdAt: raw.created_at,
86
+ updatedAt: raw.updated_at,
87
+ lastInteractionAt: raw.last_interaction_at,
88
+ description: raw.description,
89
+ address: raw.address,
90
+ city: raw.city,
91
+ state: raw.state,
92
+ country: raw.country,
93
+ postalCode: raw.postal_code,
94
+ latitude: raw.latitude,
95
+ longitude: raw.longitude,
96
+ phone: raw.phone,
97
+ email: raw.email,
98
+ website: raw.website,
99
+ rating: raw.rating,
100
+ reviewCount: raw.review_count,
101
+ category: raw.category,
102
+ tags: raw.tags,
103
+ sourceId: raw.source_id,
104
+ logoUrl: raw.logo_url,
105
+ attributes: raw.attributes,
106
+ };
107
+ }
108
+ /**
109
+ * Convert a camelCase CreateLeadInput / UpdateLeadInput to the snake_case
110
+ * body expected by the API.
111
+ */
112
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
+ export function serializeLeadInput(input) {
114
+ const out = {};
115
+ const map = {
116
+ postalCode: "postal_code",
117
+ reviewCount: "review_count",
118
+ sourceId: "source_id",
119
+ logoUrl: "logo_url",
120
+ };
121
+ for (const [k, v] of Object.entries(input)) {
122
+ if (v === undefined)
123
+ continue;
124
+ out[map[k] ?? k] = v;
125
+ }
126
+ return out;
127
+ }
128
+ /**
129
+ * Deserialize a raw note object from the API.
130
+ */
131
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
132
+ export function deserializeNote(raw) {
133
+ return {
134
+ id: raw.id,
135
+ leadId: raw.lead_id,
136
+ content: raw.content,
137
+ createdAt: raw.created_at,
138
+ updatedAt: raw.updated_at,
139
+ };
140
+ }
141
+ /**
142
+ * Deserialize a raw scoring rule from the API.
143
+ */
144
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
+ export function deserializeScoringRule(raw) {
146
+ return {
147
+ id: raw.id,
148
+ name: raw.name,
149
+ expression: raw.expression,
150
+ priority: raw.priority ?? 0,
151
+ createdAt: raw.created_at,
152
+ updatedAt: raw.updated_at,
153
+ };
154
+ }
155
+ /**
156
+ * Deserialize a raw webhook from the API.
157
+ */
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
+ export function deserializeWebhook(raw) {
160
+ return {
161
+ id: raw.id,
162
+ url: raw.url,
163
+ events: raw.events ?? [],
164
+ active: raw.active ?? true,
165
+ createdAt: raw.created_at,
166
+ };
167
+ }
168
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAuB,EACvB,IAOC;IAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,IAAI,I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AAM,IAAI,IAAI;QAC1B,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Attribute } from "./types";
2
+ /**
3
+ * Create a text attribute.
4
+ * @example textAttr("industry", "Software")
5
+ */
6
+ export declare function textAttr(name: string, value: string): Attribute;
7
+ /**
8
+ * Create a numeric attribute.
9
+ * @example numberAttr("employees", 500)
10
+ */
11
+ export declare function numberAttr(name: string, value: number): Attribute;
12
+ /**
13
+ * Create a boolean attribute.
14
+ * @example boolAttr("verified", true)
15
+ */
16
+ export declare function boolAttr(name: string, value: boolean): Attribute;
17
+ /**
18
+ * Create a list attribute.
19
+ * @example listAttr("products", ["CRM", "ERP"])
20
+ */
21
+ export declare function listAttr(name: string, value: string[]): Attribute;
22
+ /**
23
+ * Create an object attribute.
24
+ * @example objectAttr("social", { linkedin: "https://linkedin.com/company/acme" })
25
+ */
26
+ export declare function objectAttr(name: string, value: Record<string, unknown>): Attribute;
27
+ //# sourceMappingURL=attribute-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-helpers.d.ts","sourceRoot":"","sources":["../../src/attribute-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAE/D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAEjE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,CAEhE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAEjE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAElF"}
@@ -0,0 +1,64 @@
1
+ import type { KlozeoOptions, RateLimitState } from "./types";
2
+ import { LeadsResource } from "./resources/leads";
3
+ import { NotesResource } from "./resources/notes";
4
+ import { ScoringResource } from "./resources/scoring";
5
+ import { WebhooksResource } from "./resources/webhooks";
6
+ /**
7
+ * Internal HTTP client interface used by resource classes.
8
+ * @internal
9
+ */
10
+ export interface HttpClient {
11
+ request(method: string, path: string, opts?: {
12
+ body?: unknown;
13
+ }): Promise<unknown>;
14
+ requestBlob(method: string, path: string): Promise<Blob>;
15
+ }
16
+ /**
17
+ * Main Klozeo API client.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { Klozeo } from "@klozeo/sdk";
22
+ *
23
+ * const client = new Klozeo("sk_live_your_api_key");
24
+ * const lead = await client.leads.get("cl_...");
25
+ * ```
26
+ */
27
+ export declare class Klozeo implements HttpClient {
28
+ /** Leads resource — CRUD, batch, pagination, export */
29
+ readonly leads: LeadsResource;
30
+ /** Notes resource — create, list, update, delete */
31
+ readonly notes: NotesResource;
32
+ /** Scoring resource — rules management and score recalculation */
33
+ readonly scoring: ScoringResource;
34
+ /** Webhooks resource — create, list, delete */
35
+ readonly webhooks: WebhooksResource;
36
+ private readonly apiKey;
37
+ private readonly baseUrl;
38
+ private readonly timeout;
39
+ private readonly maxRetries;
40
+ private readonly fetchImpl;
41
+ private _rateLimitState;
42
+ constructor(apiKey: string, options?: KlozeoOptions);
43
+ /**
44
+ * Returns the last observed rate-limit state from response headers,
45
+ * or `null` if no request has been made yet.
46
+ */
47
+ rateLimitState(): RateLimitState | null;
48
+ /**
49
+ * Make a JSON API request with automatic retry on 429 / 5xx.
50
+ * @internal
51
+ */
52
+ request(method: string, path: string, opts?: {
53
+ body?: unknown;
54
+ }): Promise<unknown>;
55
+ /**
56
+ * Make a request that returns a Blob (used by the export endpoint).
57
+ * @internal
58
+ */
59
+ requestBlob(method: string, path: string): Promise<Blob>;
60
+ private _executeWithRetry;
61
+ private _fetchWithTimeout;
62
+ private _updateRateLimitState;
63
+ }
64
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,CACL,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GACxB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;GAUG;AACH,qBAAa,MAAO,YAAW,UAAU;IACvC,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,eAAe,CAA+B;gBAE1C,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;IAgBnD;;;OAGG;IACH,cAAc,IAAI,cAAc,GAAG,IAAI;IAQvC;;;OAGG;IACG,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GAC5B,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAgBhD,iBAAiB;YAkDjB,iBAAiB;IAkB/B,OAAO,CAAC,qBAAqB;CAW9B"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Base error class for all Klozeo API errors.
3
+ */
4
+ export declare class KlozeoError extends Error {
5
+ /** HTTP status code */
6
+ readonly statusCode: number;
7
+ /** API error code (e.g. "not_found", "rate_limit_exceeded") */
8
+ readonly code: string;
9
+ constructor(message: string, statusCode: number, code: string);
10
+ }
11
+ /**
12
+ * Thrown when the API returns 404 Not Found.
13
+ */
14
+ export declare class NotFoundError extends KlozeoError {
15
+ constructor(message: string, code?: string);
16
+ }
17
+ /**
18
+ * Thrown when the API returns 401 Unauthorized (missing or invalid API key).
19
+ */
20
+ export declare class UnauthorizedError extends KlozeoError {
21
+ constructor(message: string, code?: string);
22
+ }
23
+ /**
24
+ * Thrown when the API returns 403 Forbidden (e.g. leads limit reached).
25
+ */
26
+ export declare class ForbiddenError extends KlozeoError {
27
+ constructor(message: string, code?: string);
28
+ }
29
+ /**
30
+ * Thrown when the API returns 429 Too Many Requests.
31
+ * Check `retryAfter` (seconds) before retrying.
32
+ */
33
+ export declare class RateLimitedError extends KlozeoError {
34
+ /** Number of seconds to wait before retrying */
35
+ readonly retryAfter: number;
36
+ constructor(message: string, retryAfter: number, code?: string);
37
+ }
38
+ /**
39
+ * Thrown when the API returns 400 Bad Request.
40
+ */
41
+ export declare class BadRequestError extends KlozeoError {
42
+ constructor(message: string, code?: string);
43
+ }
44
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,uBAAuB;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAQ9D;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAc;CAKhD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAiB;CAKnD;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAc;CAKhD;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,SAAwB;CAM9E;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAgB;CAKlD"}
@@ -0,0 +1,173 @@
1
+ import type { CompiledFilter } from "../types";
2
+ /**
3
+ * Builder for text field filters.
4
+ */
5
+ export declare class TextFilter {
6
+ private readonly field;
7
+ private readonly logic;
8
+ constructor(field: string, logic: "and" | "or");
9
+ /** Field equals value (case insensitive) */
10
+ eq(value: string): CompiledFilter;
11
+ /** Field not equals value */
12
+ neq(value: string): CompiledFilter;
13
+ /** Field contains substring */
14
+ contains(value: string): CompiledFilter;
15
+ /** Field does not contain substring */
16
+ notContains(value: string): CompiledFilter;
17
+ /** Field is null or empty */
18
+ isEmpty(): CompiledFilter;
19
+ /** Field has a value */
20
+ isNotEmpty(): CompiledFilter;
21
+ }
22
+ /**
23
+ * Builder for numeric field filters.
24
+ */
25
+ export declare class NumberFilter {
26
+ private readonly field;
27
+ private readonly logic;
28
+ constructor(field: string, logic: "and" | "or");
29
+ /** Field equals value */
30
+ eq(value: number): CompiledFilter;
31
+ /** Field not equals value */
32
+ neq(value: number): CompiledFilter;
33
+ /** Field greater than value */
34
+ gt(value: number): CompiledFilter;
35
+ /** Field greater than or equal to value */
36
+ gte(value: number): CompiledFilter;
37
+ /** Field less than value */
38
+ lt(value: number): CompiledFilter;
39
+ /** Field less than or equal to value */
40
+ lte(value: number): CompiledFilter;
41
+ }
42
+ /**
43
+ * Builder for the `tags` array field.
44
+ */
45
+ export declare class TagsFilter {
46
+ private readonly logic;
47
+ constructor(logic: "and" | "or");
48
+ /** Tags array contains value */
49
+ contains(value: string): CompiledFilter;
50
+ /** Tags array does not contain value */
51
+ notContains(value: string): CompiledFilter;
52
+ /** Tags array is empty */
53
+ isEmpty(): CompiledFilter;
54
+ /** Tags array has items */
55
+ isNotEmpty(): CompiledFilter;
56
+ }
57
+ /**
58
+ * Builder for the `location` (latitude + longitude) field.
59
+ */
60
+ export declare class LocationFilter {
61
+ private readonly logic;
62
+ constructor(logic: "and" | "or");
63
+ /**
64
+ * Within `km` kilometres of the given coordinates.
65
+ * @param lat - Latitude
66
+ * @param lng - Longitude
67
+ * @param km - Radius in kilometres
68
+ */
69
+ withinRadius(lat: number, lng: number, km: number): CompiledFilter;
70
+ /** Location coordinates are set */
71
+ isSet(): CompiledFilter;
72
+ /** Location coordinates are not set */
73
+ isNotSet(): CompiledFilter;
74
+ }
75
+ /**
76
+ * Builder for dynamic attribute filters (`attr:<name>`).
77
+ */
78
+ export declare class AttrFilter {
79
+ private readonly logic;
80
+ private readonly field;
81
+ constructor(name: string, logic: "and" | "or");
82
+ /** Attribute equals text value (case insensitive) */
83
+ eq(value: string): CompiledFilter;
84
+ /** Attribute not equals text value */
85
+ neq(value: string): CompiledFilter;
86
+ /** Attribute contains substring */
87
+ contains(value: string): CompiledFilter;
88
+ /** Attribute equals numeric value */
89
+ eqNumber(value: number): CompiledFilter;
90
+ /** Attribute greater than value */
91
+ gt(value: number): CompiledFilter;
92
+ /** Attribute greater than or equal to value */
93
+ gte(value: number): CompiledFilter;
94
+ /** Attribute less than value */
95
+ lt(value: number): CompiledFilter;
96
+ /** Attribute less than or equal to value */
97
+ lte(value: number): CompiledFilter;
98
+ }
99
+ /**
100
+ * OR logic builder. Produces the same filter factories as the top-level
101
+ * functions but with logic = "or".
102
+ *
103
+ * @example
104
+ * or().city().eq("Paris") // → "or.eq.city.Paris"
105
+ */
106
+ export declare class OrBuilder {
107
+ /** OR filter on the `name` field */
108
+ name(): TextFilter;
109
+ /** OR filter on the `city` field */
110
+ city(): TextFilter;
111
+ /** OR filter on the `country` field */
112
+ country(): TextFilter;
113
+ /** OR filter on the `state` field */
114
+ state(): TextFilter;
115
+ /** OR filter on the `category` field */
116
+ category(): TextFilter;
117
+ /** OR filter on the `source` field */
118
+ source(): TextFilter;
119
+ /** OR filter on the `email` field */
120
+ email(): TextFilter;
121
+ /** OR filter on the `phone` field */
122
+ phone(): TextFilter;
123
+ /** OR filter on the `website` field */
124
+ website(): TextFilter;
125
+ /** OR filter on the `rating` field */
126
+ rating(): NumberFilter;
127
+ /** OR filter on the `review_count` field */
128
+ reviewCount(): NumberFilter;
129
+ /** OR filter on the `tags` array field */
130
+ tags(): TagsFilter;
131
+ /** OR filter on the `location` field */
132
+ location(): LocationFilter;
133
+ /** OR filter on a custom attribute */
134
+ attr(name: string): AttrFilter;
135
+ }
136
+ /** Filter on the lead `name` field (AND logic) */
137
+ export declare const name: () => TextFilter;
138
+ /** Filter on the `city` field (AND logic) */
139
+ export declare const city: () => TextFilter;
140
+ /** Filter on the `country` field (AND logic) */
141
+ export declare const country: () => TextFilter;
142
+ /** Filter on the `state` field (AND logic) */
143
+ export declare const state: () => TextFilter;
144
+ /** Filter on the `category` field (AND logic) */
145
+ export declare const category: () => TextFilter;
146
+ /** Filter on the `source` field (AND logic) */
147
+ export declare const source: () => TextFilter;
148
+ /** Filter on the `email` field (AND logic) */
149
+ export declare const email: () => TextFilter;
150
+ /** Filter on the `phone` field (AND logic) */
151
+ export declare const phone: () => TextFilter;
152
+ /** Filter on the `website` field (AND logic) */
153
+ export declare const website: () => TextFilter;
154
+ /** Filter on the `rating` field (AND logic) */
155
+ export declare const rating: () => NumberFilter;
156
+ /** Filter on the `review_count` field (AND logic) */
157
+ export declare const reviewCount: () => NumberFilter;
158
+ /** Filter on the `tags` array field (AND logic) */
159
+ export declare const tags: () => TagsFilter;
160
+ /** Filter on the `location` (coordinates) field (AND logic) */
161
+ export declare const location: () => LocationFilter;
162
+ /**
163
+ * Filter on a custom dynamic attribute (AND logic).
164
+ * @param name - Attribute name (e.g. "industry")
165
+ */
166
+ export declare const attr: (name: string) => AttrFilter;
167
+ /**
168
+ * Start an OR-logic filter chain.
169
+ * @example
170
+ * or().city().eq("Paris")
171
+ */
172
+ export declare const or: () => OrBuilder;
173
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/filters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA6B/C;;GAEG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,KAAK,EAAE,MAAM,EACb,KAAK,EA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AAM,MAAM,KAAG,UAAyC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,EAAE,QAAO,SAA4B,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @klozeo/sdk — Official TypeScript SDK for the Klozeo API.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { Klozeo, ExportFormat } from "@klozeo/sdk";
7
+ * import { city, rating, or } from "@klozeo/sdk/filters";
8
+ *
9
+ * const client = new Klozeo("sk_live_your_api_key");
10
+ *
11
+ * const page = await client.leads.list({
12
+ * filters: [city().eq("Berlin"), rating().gte(4.0)],
13
+ * sortBy: "rating",
14
+ * sortOrder: "desc",
15
+ * });
16
+ * ```
17
+ */
18
+ export { Klozeo } from "./client";
19
+ export type { Attribute, AttributeType, AttributeValue, CompiledFilter, SortField, Lead, CreateLeadInput, UpdateLeadInput, CreateResponse, LeadPage, ListOptions, ExportOptions, BatchCreatedItem, BatchErrorItem, BatchCreateResult, BatchResultItem, BatchResult, BatchUpdateInput, Note, NoteListResult, ScoringRule, CreateScoringRuleInput, UpdateScoringRuleInput, ScoringRuleListResult, RecalculateScoreResult, WebhookEvent, Webhook, CreateWebhookInput, WebhookListResult, KlozeoOptions, RateLimitState, } from "./types";
20
+ export { ExportFormat } from "./types";
21
+ export { KlozeoError, NotFoundError, UnauthorizedError, ForbiddenError, RateLimitedError, BadRequestError, } from "./errors";
22
+ export { textAttr, numberAttr, boolAttr, listAttr, objectAttr, } from "./attribute-helpers";
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,cAAc,EACd,SAAS,EACT,IAAI,EACJ,eAAe,EACf,eAAe,EACf,cAAc,EACd,QAAQ,EACR,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,IAAI,EACJ,cAAc,EACd,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,OAAO,EACP,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { Lead, CreateLeadInput, UpdateLeadInput, CreateResponse, LeadPage, ListOptions, ExportOptions, ExportFormat, BatchCreateResult, BatchResult, BatchUpdateInput } from "../types";
2
+ import type { HttpClient } from "../client";
3
+ /**
4
+ * Resource class for all lead-related API operations.
5
+ */
6
+ export declare class LeadsResource {
7
+ private readonly http;
8
+ constructor(http: HttpClient);
9
+ /**
10
+ * Create a new lead. Returns a `CreateResponse` that includes the ID
11
+ * and indicates whether an existing lead was merged (deduplication).
12
+ */
13
+ create(input: CreateLeadInput): Promise<CreateResponse>;
14
+ /**
15
+ * Retrieve a single lead by ID.
16
+ */
17
+ get(id: string): Promise<Lead>;
18
+ /**
19
+ * Update a lead. Only the supplied fields are changed.
20
+ * Returns the full updated lead object.
21
+ */
22
+ update(id: string, input: UpdateLeadInput): Promise<Lead>;
23
+ /**
24
+ * Delete a lead permanently. Resolves when the deletion succeeds (204).
25
+ */
26
+ delete(id: string): Promise<void>;
27
+ /**
28
+ * List leads with optional filters, sorting, and cursor pagination.
29
+ */
30
+ list(opts?: ListOptions): Promise<LeadPage>;
31
+ /**
32
+ * Async iterator that automatically fetches all pages.
33
+ *
34
+ * @example
35
+ * for await (const lead of client.leads.iterate({ filters: [city().eq("Berlin")] })) {
36
+ * console.log(lead.name);
37
+ * }
38
+ */
39
+ iterate(opts?: Omit<ListOptions, "cursor">): AsyncGenerator<Lead>;
40
+ /**
41
+ * Export leads as CSV, JSON, or XLSX. Returns a `Blob`.
42
+ *
43
+ * @example
44
+ * // Browser
45
+ * const blob = await client.leads.export(ExportFormat.CSV);
46
+ * const url = URL.createObjectURL(blob);
47
+ *
48
+ * // Node.js
49
+ * const blob = await client.leads.export(ExportFormat.CSV);
50
+ * writeFileSync("leads.csv", Buffer.from(await blob.arrayBuffer()));
51
+ */
52
+ export(format: ExportFormat, opts?: ExportOptions): Promise<Blob>;
53
+ /**
54
+ * Create up to 100 leads in a single request.
55
+ * Returns per-item results including successes and failures.
56
+ */
57
+ batchCreate(leads: CreateLeadInput[]): Promise<BatchCreateResult>;
58
+ /**
59
+ * Apply the same partial update to up to 100 leads.
60
+ */
61
+ batchUpdate(input: BatchUpdateInput): Promise<BatchResult>;
62
+ /**
63
+ * Delete up to 100 leads in a single request.
64
+ */
65
+ batchDelete(ids: string[]): Promise<BatchResult>;
66
+ }
67
+ //# sourceMappingURL=leads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leads.d.ts","sourceRoot":"","sources":["../../../src/resources/leads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,eAAe,EACf,eAAe,EACf,cAAc,EACd,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAMlB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAc7D;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpC;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/D;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;OAEG;IACG,IAAI,CAAC,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAerD;;;;;;;OAOG;IACI,OAAO,CACZ,IAAI,GAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAM,GACrC,cAAc,CAAC,IAAI,CAAC;IAavB;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3E;;;OAGG;IACG,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgBvE;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAehE;;OAEG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;CAUvD"}
@@ -0,0 +1,31 @@
1
+ import type { Note, NoteListResult } from "../types";
2
+ import type { HttpClient } from "../client";
3
+ /**
4
+ * Resource class for lead note operations.
5
+ */
6
+ export declare class NotesResource {
7
+ private readonly http;
8
+ constructor(http: HttpClient);
9
+ /**
10
+ * List all notes for a lead.
11
+ */
12
+ list(leadId: string): Promise<NoteListResult>;
13
+ /**
14
+ * Create a note on a lead.
15
+ * @param leadId - ID of the lead to attach the note to
16
+ * @param content - Note content text
17
+ */
18
+ create(leadId: string, content: string): Promise<Note>;
19
+ /**
20
+ * Update the content of an existing note.
21
+ * @param noteId - ID of the note to update (format: "note_...")
22
+ * @param content - New content
23
+ */
24
+ update(noteId: string, content: string): Promise<Note>;
25
+ /**
26
+ * Delete a note permanently. Resolves when deletion succeeds (204).
27
+ * @param noteId - ID of the note to delete (format: "note_...")
28
+ */
29
+ delete(noteId: string): Promise<void>;
30
+ }
31
+ //# sourceMappingURL=notes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notes.d.ts","sourceRoot":"","sources":["../../../src/resources/notes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAYnD;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5C"}