@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,35 @@
1
+ import type { ScoringRule, ScoringRuleListResult, CreateScoringRuleInput, UpdateScoringRuleInput, RecalculateScoreResult } from "../types";
2
+ import type { HttpClient } from "../client";
3
+ /**
4
+ * Resource class for scoring rule and lead score operations.
5
+ */
6
+ export declare class ScoringResource {
7
+ private readonly http;
8
+ constructor(http: HttpClient);
9
+ /**
10
+ * List all scoring rules for this account.
11
+ */
12
+ listRules(): Promise<ScoringRuleListResult>;
13
+ /**
14
+ * Create a new scoring rule.
15
+ */
16
+ createRule(input: CreateScoringRuleInput): Promise<ScoringRule>;
17
+ /**
18
+ * Retrieve a single scoring rule by ID.
19
+ */
20
+ getRule(id: string): Promise<ScoringRule>;
21
+ /**
22
+ * Update a scoring rule. Only the supplied fields are changed.
23
+ */
24
+ updateRule(id: string, input: UpdateScoringRuleInput): Promise<void>;
25
+ /**
26
+ * Delete a scoring rule.
27
+ */
28
+ deleteRule(id: string): Promise<void>;
29
+ /**
30
+ * Recalculate and persist the score for a single lead.
31
+ * Returns the new score value.
32
+ */
33
+ recalculate(leadId: string): Promise<RecalculateScoreResult>;
34
+ }
35
+ //# sourceMappingURL=scoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../../src/resources/scoring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,qBAAqB,CAAC;IASjD;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC;IAKrE;;OAEG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAK/C;;OAEG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1E;;OAEG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;CASnE"}
@@ -0,0 +1,25 @@
1
+ import type { Webhook, WebhookListResult, CreateWebhookInput } from "../types";
2
+ import type { HttpClient } from "../client";
3
+ /**
4
+ * Resource class for webhook subscription operations.
5
+ */
6
+ export declare class WebhooksResource {
7
+ private readonly http;
8
+ constructor(http: HttpClient);
9
+ /**
10
+ * List all webhooks for this account.
11
+ */
12
+ list(): Promise<WebhookListResult>;
13
+ /**
14
+ * Create a new webhook subscription.
15
+ * The `secret` field (if provided) is used only for payload signing and
16
+ * is never returned by the API.
17
+ */
18
+ create(input: CreateWebhookInput): Promise<Webhook>;
19
+ /**
20
+ * Delete a webhook subscription permanently.
21
+ * @param id - UUID of the webhook to delete
22
+ */
23
+ delete(id: string): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IASxC;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAKzD;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -0,0 +1,409 @@
1
+ /**
2
+ * Attribute value types supported by the API.
3
+ */
4
+ export type AttributeValue = string | number | boolean | string[] | Record<string, unknown>;
5
+ /**
6
+ * Supported attribute types.
7
+ */
8
+ export type AttributeType = "text" | "number" | "bool" | "list" | "object";
9
+ /**
10
+ * A dynamic attribute attached to a lead.
11
+ */
12
+ export interface Attribute {
13
+ /** Unique identifier (returned by API) */
14
+ id?: string;
15
+ /** Attribute name */
16
+ name: string;
17
+ /** Attribute type */
18
+ type: AttributeType;
19
+ /** Attribute value */
20
+ value: AttributeValue;
21
+ }
22
+ /**
23
+ * A compiled filter ready to be serialized to a query string.
24
+ */
25
+ export interface CompiledFilter {
26
+ /** Filter logic: "and" or "or" */
27
+ logic: "and" | "or";
28
+ /** Filter operator (e.g. "eq", "gte", "array_contains") */
29
+ operator: string;
30
+ /** Field name (e.g. "city", "rating", "attr:industry") */
31
+ field: string;
32
+ /** Filter value (empty string for no-value operators like "is_empty") */
33
+ value: string;
34
+ /** Serialize to "logic.operator.field.value" */
35
+ toString(): string;
36
+ }
37
+ /**
38
+ * Sortable field names accepted by the API.
39
+ */
40
+ export type SortField = "name" | "city" | "country" | "state" | "category" | "source" | "email" | "phone" | "website" | "rating" | "review_count" | "created_at" | "updated_at" | "last_interaction_at" | `attr:${string}`;
41
+ /**
42
+ * Export format options.
43
+ */
44
+ export declare enum ExportFormat {
45
+ CSV = "csv",
46
+ JSON = "json",
47
+ XLSX = "xlsx"
48
+ }
49
+ /**
50
+ * A lead object as returned by the API.
51
+ */
52
+ export interface Lead {
53
+ /** Unique lead identifier (format: "cl_...") */
54
+ id: string;
55
+ /** Lead name */
56
+ name: string;
57
+ /** Lead source */
58
+ source: string;
59
+ /** Calculated score (0–100) */
60
+ score: number;
61
+ /** Unix timestamp of creation */
62
+ createdAt: number;
63
+ /** Unix timestamp of last structural update */
64
+ updatedAt: number;
65
+ /** Unix timestamp of last interaction or push */
66
+ lastInteractionAt: number;
67
+ /** Description */
68
+ description?: string;
69
+ /** Street address */
70
+ address?: string;
71
+ /** City */
72
+ city?: string;
73
+ /** State / province */
74
+ state?: string;
75
+ /** Country */
76
+ country?: string;
77
+ /** Postal code */
78
+ postalCode?: string;
79
+ /** Latitude */
80
+ latitude?: number;
81
+ /** Longitude */
82
+ longitude?: number;
83
+ /** Phone number */
84
+ phone?: string;
85
+ /** Email address */
86
+ email?: string;
87
+ /** Website URL */
88
+ website?: string;
89
+ /** Star rating (0–5) */
90
+ rating?: number;
91
+ /** Review count */
92
+ reviewCount?: number;
93
+ /** Category */
94
+ category?: string;
95
+ /** Tags array */
96
+ tags?: string[];
97
+ /** External source identifier */
98
+ sourceId?: string;
99
+ /** Logo URL */
100
+ logoUrl?: string;
101
+ /** Dynamic attributes */
102
+ attributes?: Attribute[];
103
+ }
104
+ /**
105
+ * Input for creating a new lead.
106
+ */
107
+ export interface CreateLeadInput {
108
+ /** Lead name (required) */
109
+ name: string;
110
+ /** Lead source (required) */
111
+ source: string;
112
+ /** Description */
113
+ description?: string;
114
+ /** Street address */
115
+ address?: string;
116
+ /** City */
117
+ city?: string;
118
+ /** State / province */
119
+ state?: string;
120
+ /** Country */
121
+ country?: string;
122
+ /** Postal code */
123
+ postalCode?: string;
124
+ /** Latitude */
125
+ latitude?: number;
126
+ /** Longitude */
127
+ longitude?: number;
128
+ /** Phone number */
129
+ phone?: string;
130
+ /** Email address */
131
+ email?: string;
132
+ /** Website URL */
133
+ website?: string;
134
+ /** Star rating (0–5) */
135
+ rating?: number;
136
+ /** Review count */
137
+ reviewCount?: number;
138
+ /** Category */
139
+ category?: string;
140
+ /** Tags array */
141
+ tags?: string[];
142
+ /** External source identifier */
143
+ sourceId?: string;
144
+ /** Logo URL */
145
+ logoUrl?: string;
146
+ /** Dynamic attributes */
147
+ attributes?: Attribute[];
148
+ }
149
+ /**
150
+ * Input for updating an existing lead. All fields are optional.
151
+ */
152
+ export type UpdateLeadInput = Partial<Omit<CreateLeadInput, "name" | "source">> & {
153
+ name?: string;
154
+ source?: string;
155
+ };
156
+ /**
157
+ * Response from a create-lead request.
158
+ */
159
+ export interface CreateResponse {
160
+ /** ID of the created or merged lead */
161
+ id: string;
162
+ /** Human-readable message */
163
+ message: string;
164
+ /** Unix timestamp of creation */
165
+ createdAt: number;
166
+ /** True if an existing lead was merged (deduplication hit) */
167
+ duplicate?: boolean;
168
+ /** ID of a potential low-confidence duplicate */
169
+ potentialDuplicateId?: string;
170
+ }
171
+ /**
172
+ * A page of leads returned by the list endpoint.
173
+ */
174
+ export interface LeadPage {
175
+ /** Leads in this page */
176
+ leads: Lead[];
177
+ /** Opaque cursor to fetch the next page (pass as `cursor` in the next call) */
178
+ nextCursor?: string;
179
+ /** True if more pages exist */
180
+ hasMore: boolean;
181
+ /** Number of leads in this page */
182
+ count: number;
183
+ }
184
+ /**
185
+ * Options for listing leads.
186
+ */
187
+ export interface ListOptions {
188
+ /** Filters to apply (AND / OR logic per filter) */
189
+ filters?: CompiledFilter[];
190
+ /** Field to sort by */
191
+ sortBy?: SortField;
192
+ /** Sort direction */
193
+ sortOrder?: "asc" | "desc";
194
+ /** Maximum number of results per page (default 50, max 1000) */
195
+ limit?: number;
196
+ /** Pagination cursor from a previous response */
197
+ cursor?: string;
198
+ }
199
+ /**
200
+ * Options for exporting leads.
201
+ */
202
+ export interface ExportOptions {
203
+ /** Filters to apply */
204
+ filters?: CompiledFilter[];
205
+ /** Field to sort by */
206
+ sortBy?: SortField;
207
+ /** Sort direction */
208
+ sortOrder?: "asc" | "desc";
209
+ }
210
+ /**
211
+ * One item in a batch-create result.
212
+ */
213
+ export interface BatchCreatedItem {
214
+ /** Zero-based index in the input array */
215
+ index: number;
216
+ /** Created lead ID */
217
+ id: string;
218
+ /** Unix timestamp */
219
+ createdAt: number;
220
+ }
221
+ /**
222
+ * One error in a batch-create result.
223
+ */
224
+ export interface BatchErrorItem {
225
+ /** Zero-based index in the input array */
226
+ index: number;
227
+ /** Error description */
228
+ message: string;
229
+ }
230
+ /**
231
+ * Response from a batch-create request.
232
+ */
233
+ export interface BatchCreateResult {
234
+ /** Successfully created items */
235
+ created: BatchCreatedItem[];
236
+ /** Failed items */
237
+ errors: BatchErrorItem[];
238
+ /** Total number of inputs */
239
+ total: number;
240
+ /** Number of successes */
241
+ success: number;
242
+ /** Number of failures */
243
+ failed: number;
244
+ }
245
+ /**
246
+ * One item in a batch-update or batch-delete result.
247
+ */
248
+ export interface BatchResultItem {
249
+ /** Zero-based index in the input array */
250
+ index: number;
251
+ /** Lead ID */
252
+ id: string;
253
+ /** True if the operation succeeded */
254
+ success: boolean;
255
+ /** Error description (only present when success is false) */
256
+ message?: string;
257
+ }
258
+ /**
259
+ * Response from a batch-update or batch-delete request.
260
+ */
261
+ export interface BatchResult {
262
+ /** Per-item results */
263
+ results: BatchResultItem[];
264
+ /** Total number of inputs */
265
+ total: number;
266
+ /** Number of successes */
267
+ success: number;
268
+ /** Number of failures */
269
+ failed: number;
270
+ }
271
+ /**
272
+ * Input for a batch-update request.
273
+ */
274
+ export interface BatchUpdateInput {
275
+ /** IDs of leads to update */
276
+ ids: string[];
277
+ /** Partial update to apply to all specified leads */
278
+ data: UpdateLeadInput;
279
+ }
280
+ /**
281
+ * A note attached to a lead.
282
+ */
283
+ export interface Note {
284
+ /** Unique note identifier (format: "note_...") */
285
+ id: string;
286
+ /** ID of the parent lead */
287
+ leadId: string;
288
+ /** Note content */
289
+ content: string;
290
+ /** Unix timestamp of creation */
291
+ createdAt: number;
292
+ /** Unix timestamp of last update */
293
+ updatedAt: number;
294
+ }
295
+ /**
296
+ * Response from a list-notes request.
297
+ */
298
+ export interface NoteListResult {
299
+ /** Notes for the lead */
300
+ notes: Note[];
301
+ }
302
+ /**
303
+ * A scoring rule object.
304
+ */
305
+ export interface ScoringRule {
306
+ /** Unique rule identifier */
307
+ id: string;
308
+ /** Rule name */
309
+ name: string;
310
+ /** Expression evaluated per lead */
311
+ expression: string;
312
+ /** Priority (lower = higher priority) */
313
+ priority: number;
314
+ /** Unix timestamp of creation */
315
+ createdAt: number;
316
+ /** Unix timestamp of last update */
317
+ updatedAt: number;
318
+ }
319
+ /**
320
+ * Input for creating a scoring rule.
321
+ */
322
+ export interface CreateScoringRuleInput {
323
+ /** Rule name */
324
+ name: string;
325
+ /** Scoring expression */
326
+ expression: string;
327
+ /** Priority (lower = higher priority, defaults to 0) */
328
+ priority?: number;
329
+ }
330
+ /**
331
+ * Input for updating a scoring rule. All fields are optional.
332
+ */
333
+ export type UpdateScoringRuleInput = Partial<CreateScoringRuleInput>;
334
+ /**
335
+ * Response from a list-scoring-rules request.
336
+ */
337
+ export interface ScoringRuleListResult {
338
+ /** All scoring rules for this account */
339
+ rules: ScoringRule[];
340
+ }
341
+ /**
342
+ * Response from a recalculate-score request.
343
+ */
344
+ export interface RecalculateScoreResult {
345
+ /** Lead ID */
346
+ id: string;
347
+ /** New calculated score */
348
+ score: number;
349
+ }
350
+ /**
351
+ * Supported webhook event types.
352
+ */
353
+ export type WebhookEvent = "lead.created" | "lead.updated" | "lead.deleted";
354
+ /**
355
+ * A webhook subscription object.
356
+ */
357
+ export interface Webhook {
358
+ /** Unique webhook identifier */
359
+ id: string;
360
+ /** Destination URL */
361
+ url: string;
362
+ /** Subscribed event types */
363
+ events: WebhookEvent[];
364
+ /** Whether the webhook is active */
365
+ active: boolean;
366
+ /** ISO timestamp of creation */
367
+ createdAt: string;
368
+ }
369
+ /**
370
+ * Input for creating a webhook.
371
+ */
372
+ export interface CreateWebhookInput {
373
+ /** Destination URL (required) */
374
+ url: string;
375
+ /** Event types to subscribe to */
376
+ events?: WebhookEvent[];
377
+ /** Optional signing secret */
378
+ secret?: string;
379
+ }
380
+ /**
381
+ * Response from a list-webhooks request.
382
+ */
383
+ export interface WebhookListResult {
384
+ /** All webhooks for this account */
385
+ webhooks: Webhook[];
386
+ }
387
+ /**
388
+ * Options for the Klozeo client.
389
+ */
390
+ export interface KlozeoOptions {
391
+ /** Override the API base URL (default: "https://app.klozeo.com/api/v1") */
392
+ baseUrl?: string;
393
+ /** Per-request timeout in milliseconds (default: 30000) */
394
+ timeout?: number;
395
+ /** Maximum number of retries on 429 / 5xx (default: 3) */
396
+ maxRetries?: number;
397
+ /** Custom fetch implementation (defaults to global fetch) */
398
+ fetch?: typeof fetch;
399
+ }
400
+ /**
401
+ * Rate limit state updated from response headers.
402
+ */
403
+ export interface RateLimitState {
404
+ /** Maximum requests per window */
405
+ limit: number;
406
+ /** Remaining requests in the current window */
407
+ remaining: number;
408
+ }
409
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,EAAE,GACR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,IAAI,EAAE,aAAa,CAAC;IACpB,sBAAsB;IACtB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,SAAS,GACT,OAAO,GACP,UAAU,GACV,QAAQ,GACR,OAAO,GACP,OAAO,GACP,SAAS,GACT,QAAQ,GACR,cAAc,GACd,YAAY,GACZ,YAAY,GACZ,qBAAqB,GACrB,QAAQ,MAAM,EAAE,CAAC;AAErB;;GAEG;AACH,oBAAY,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AY,EAAE,CAAC;IACvB,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,49 @@
1
+ import type { CompiledFilter, SortField } from "./types";
2
+ import { KlozeoError } from "./errors";
3
+ /**
4
+ * Append filter, sort, and pagination params to a URLSearchParams instance.
5
+ */
6
+ export declare function buildQueryParams(params: URLSearchParams, opts: {
7
+ filters?: CompiledFilter[];
8
+ sortBy?: SortField;
9
+ sortOrder?: "asc" | "desc";
10
+ limit?: number;
11
+ cursor?: string;
12
+ format?: string;
13
+ }): void;
14
+ /**
15
+ * Parse an API error response body and produce a typed KlozeoError.
16
+ */
17
+ export declare function parseError(response: Response): Promise<KlozeoError>;
18
+ /**
19
+ * Sleep for the given number of milliseconds.
20
+ */
21
+ export declare function sleep(ms: number): Promise<void>;
22
+ /**
23
+ * Compute exponential back-off delay with jitter.
24
+ * @param attempt - Zero-based attempt index.
25
+ * @param baseMs - Base delay in milliseconds (default 500).
26
+ */
27
+ export declare function backoffDelay(attempt: number, baseMs?: number): number;
28
+ /**
29
+ * Convert a snake_case API lead object to a camelCase Lead.
30
+ */
31
+ export declare function deserializeLead(raw: Record<string, any>): import("./types.js").Lead;
32
+ /**
33
+ * Convert a camelCase CreateLeadInput / UpdateLeadInput to the snake_case
34
+ * body expected by the API.
35
+ */
36
+ export declare function serializeLeadInput(input: Record<string, any>): Record<string, any>;
37
+ /**
38
+ * Deserialize a raw note object from the API.
39
+ */
40
+ export declare function deserializeNote(raw: Record<string, any>): import("./types.js").Note;
41
+ /**
42
+ * Deserialize a raw scoring rule from the API.
43
+ */
44
+ export declare function deserializeScoringRule(raw: Record<string, any>): import("./types.js").ScoringRule;
45
+ /**
46
+ * Deserialize a raw webhook from the API.
47
+ */
48
+ export declare function deserializeWebhook(raw: Record<string, any>): import("./types.js").Webhook;
49
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EACL,WAAW,EAMZ,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE;IACJ,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,IAAI,CAqBN;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,WAAW,CAAC,CA4BtB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,MAAM,CAMlE;AAED;;GAEG;AAEH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,YAAY,EAAE,IAAI,CA4BnF;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAalF;AAED;;GAEG;AAEH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,YAAY,EAAE,IAAI,CAQnF;AAED;;GAEG;AAEH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,YAAY,EAAE,WAAW,CASjG;AAED;;GAEG;AAEH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,YAAY,EAAE,OAAO,CAQzF"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@klozeo/sdk",
3
+ "version": "0.1.0",
4
+ "description": "Official TypeScript SDK for the Klozeo API",
5
+ "license": "MIT",
6
+ "author": "Klozeo <hello@klozeo.com>",
7
+ "homepage": "https://github.com/lbframe/sdk-typescript",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/lbframe/sdk-typescript"
11
+ },
12
+ "keywords": [
13
+ "klozeo",
14
+ "sdk",
15
+ "leads",
16
+ "crm",
17
+ "api"
18
+ ],
19
+ "type": "module",
20
+ "main": "./dist/cjs/index.js",
21
+ "module": "./dist/esm/index.js",
22
+ "types": "./dist/types/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./dist/esm/index.js",
26
+ "require": "./dist/cjs/index.js",
27
+ "types": "./dist/types/index.d.ts"
28
+ },
29
+ "./filters": {
30
+ "import": "./dist/esm/filters/index.js",
31
+ "require": "./dist/cjs/filters/index.js",
32
+ "types": "./dist/types/filters/index.d.ts"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md"
38
+ ],
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node scripts/postbuild.mjs",
41
+ "build:esm": "tsc -p tsconfig.json",
42
+ "build:cjs": "tsc -p tsconfig.cjs.json",
43
+ "lint": "tsc --noEmit -p tsconfig.json",
44
+ "clean": "rm -rf dist"
45
+ },
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "devDependencies": {
50
+ "typescript": "^5.4.0"
51
+ }
52
+ }