@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,304 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Internal helpers
3
+ // ---------------------------------------------------------------------------
4
+ function makeFilter(logic, operator, field, value = "") {
5
+ return {
6
+ logic,
7
+ operator,
8
+ field,
9
+ value,
10
+ toString() {
11
+ return value !== ""
12
+ ? `${this.logic}.${this.operator}.${this.field}.${this.value}`
13
+ : `${this.logic}.${this.operator}.${this.field}`;
14
+ },
15
+ };
16
+ }
17
+ // ---------------------------------------------------------------------------
18
+ // Text filter builder
19
+ // ---------------------------------------------------------------------------
20
+ /**
21
+ * Builder for text field filters.
22
+ */
23
+ export class TextFilter {
24
+ field;
25
+ logic;
26
+ constructor(field, logic) {
27
+ this.field = field;
28
+ this.logic = logic;
29
+ }
30
+ /** Field equals value (case insensitive) */
31
+ eq(value) {
32
+ return makeFilter(this.logic, "eq", this.field, value);
33
+ }
34
+ /** Field not equals value */
35
+ neq(value) {
36
+ return makeFilter(this.logic, "neq", this.field, value);
37
+ }
38
+ /** Field contains substring */
39
+ contains(value) {
40
+ return makeFilter(this.logic, "contains", this.field, value);
41
+ }
42
+ /** Field does not contain substring */
43
+ notContains(value) {
44
+ return makeFilter(this.logic, "not_contains", this.field, value);
45
+ }
46
+ /** Field is null or empty */
47
+ isEmpty() {
48
+ return makeFilter(this.logic, "is_empty", this.field);
49
+ }
50
+ /** Field has a value */
51
+ isNotEmpty() {
52
+ return makeFilter(this.logic, "is_not_empty", this.field);
53
+ }
54
+ }
55
+ // ---------------------------------------------------------------------------
56
+ // Number filter builder
57
+ // ---------------------------------------------------------------------------
58
+ /**
59
+ * Builder for numeric field filters.
60
+ */
61
+ export class NumberFilter {
62
+ field;
63
+ logic;
64
+ constructor(field, logic) {
65
+ this.field = field;
66
+ this.logic = logic;
67
+ }
68
+ /** Field equals value */
69
+ eq(value) {
70
+ return makeFilter(this.logic, "eq", this.field, String(value));
71
+ }
72
+ /** Field not equals value */
73
+ neq(value) {
74
+ return makeFilter(this.logic, "neq", this.field, String(value));
75
+ }
76
+ /** Field greater than value */
77
+ gt(value) {
78
+ return makeFilter(this.logic, "gt", this.field, String(value));
79
+ }
80
+ /** Field greater than or equal to value */
81
+ gte(value) {
82
+ return makeFilter(this.logic, "gte", this.field, String(value));
83
+ }
84
+ /** Field less than value */
85
+ lt(value) {
86
+ return makeFilter(this.logic, "lt", this.field, String(value));
87
+ }
88
+ /** Field less than or equal to value */
89
+ lte(value) {
90
+ return makeFilter(this.logic, "lte", this.field, String(value));
91
+ }
92
+ }
93
+ // ---------------------------------------------------------------------------
94
+ // Tags filter builder
95
+ // ---------------------------------------------------------------------------
96
+ /**
97
+ * Builder for the `tags` array field.
98
+ */
99
+ export class TagsFilter {
100
+ logic;
101
+ constructor(logic) {
102
+ this.logic = logic;
103
+ }
104
+ /** Tags array contains value */
105
+ contains(value) {
106
+ return makeFilter(this.logic, "array_contains", "tags", value);
107
+ }
108
+ /** Tags array does not contain value */
109
+ notContains(value) {
110
+ return makeFilter(this.logic, "array_not_contains", "tags", value);
111
+ }
112
+ /** Tags array is empty */
113
+ isEmpty() {
114
+ return makeFilter(this.logic, "array_empty", "tags");
115
+ }
116
+ /** Tags array has items */
117
+ isNotEmpty() {
118
+ return makeFilter(this.logic, "array_not_empty", "tags");
119
+ }
120
+ }
121
+ // ---------------------------------------------------------------------------
122
+ // Location filter builder
123
+ // ---------------------------------------------------------------------------
124
+ /**
125
+ * Builder for the `location` (latitude + longitude) field.
126
+ */
127
+ export class LocationFilter {
128
+ logic;
129
+ constructor(logic) {
130
+ this.logic = logic;
131
+ }
132
+ /**
133
+ * Within `km` kilometres of the given coordinates.
134
+ * @param lat - Latitude
135
+ * @param lng - Longitude
136
+ * @param km - Radius in kilometres
137
+ */
138
+ withinRadius(lat, lng, km) {
139
+ return makeFilter(this.logic, "within_radius", "location", `${lat},${lng},${km}`);
140
+ }
141
+ /** Location coordinates are set */
142
+ isSet() {
143
+ return makeFilter(this.logic, "is_set", "location");
144
+ }
145
+ /** Location coordinates are not set */
146
+ isNotSet() {
147
+ return makeFilter(this.logic, "is_not_set", "location");
148
+ }
149
+ }
150
+ // ---------------------------------------------------------------------------
151
+ // Custom attribute filter builder
152
+ // ---------------------------------------------------------------------------
153
+ /**
154
+ * Builder for dynamic attribute filters (`attr:<name>`).
155
+ */
156
+ export class AttrFilter {
157
+ logic;
158
+ field;
159
+ constructor(name, logic) {
160
+ this.logic = logic;
161
+ this.field = `attr:${name}`;
162
+ }
163
+ /** Attribute equals text value (case insensitive) */
164
+ eq(value) {
165
+ return makeFilter(this.logic, "eq", this.field, value);
166
+ }
167
+ /** Attribute not equals text value */
168
+ neq(value) {
169
+ return makeFilter(this.logic, "neq", this.field, value);
170
+ }
171
+ /** Attribute contains substring */
172
+ contains(value) {
173
+ return makeFilter(this.logic, "contains", this.field, value);
174
+ }
175
+ /** Attribute equals numeric value */
176
+ eqNumber(value) {
177
+ return makeFilter(this.logic, "eq", this.field, String(value));
178
+ }
179
+ /** Attribute greater than value */
180
+ gt(value) {
181
+ return makeFilter(this.logic, "gt", this.field, String(value));
182
+ }
183
+ /** Attribute greater than or equal to value */
184
+ gte(value) {
185
+ return makeFilter(this.logic, "gte", this.field, String(value));
186
+ }
187
+ /** Attribute less than value */
188
+ lt(value) {
189
+ return makeFilter(this.logic, "lt", this.field, String(value));
190
+ }
191
+ /** Attribute less than or equal to value */
192
+ lte(value) {
193
+ return makeFilter(this.logic, "lte", this.field, String(value));
194
+ }
195
+ }
196
+ // ---------------------------------------------------------------------------
197
+ // OR builder
198
+ // ---------------------------------------------------------------------------
199
+ /**
200
+ * OR logic builder. Produces the same filter factories as the top-level
201
+ * functions but with logic = "or".
202
+ *
203
+ * @example
204
+ * or().city().eq("Paris") // → "or.eq.city.Paris"
205
+ */
206
+ export class OrBuilder {
207
+ /** OR filter on the `name` field */
208
+ name() {
209
+ return new TextFilter("name", "or");
210
+ }
211
+ /** OR filter on the `city` field */
212
+ city() {
213
+ return new TextFilter("city", "or");
214
+ }
215
+ /** OR filter on the `country` field */
216
+ country() {
217
+ return new TextFilter("country", "or");
218
+ }
219
+ /** OR filter on the `state` field */
220
+ state() {
221
+ return new TextFilter("state", "or");
222
+ }
223
+ /** OR filter on the `category` field */
224
+ category() {
225
+ return new TextFilter("category", "or");
226
+ }
227
+ /** OR filter on the `source` field */
228
+ source() {
229
+ return new TextFilter("source", "or");
230
+ }
231
+ /** OR filter on the `email` field */
232
+ email() {
233
+ return new TextFilter("email", "or");
234
+ }
235
+ /** OR filter on the `phone` field */
236
+ phone() {
237
+ return new TextFilter("phone", "or");
238
+ }
239
+ /** OR filter on the `website` field */
240
+ website() {
241
+ return new TextFilter("website", "or");
242
+ }
243
+ /** OR filter on the `rating` field */
244
+ rating() {
245
+ return new NumberFilter("rating", "or");
246
+ }
247
+ /** OR filter on the `review_count` field */
248
+ reviewCount() {
249
+ return new NumberFilter("review_count", "or");
250
+ }
251
+ /** OR filter on the `tags` array field */
252
+ tags() {
253
+ return new TagsFilter("or");
254
+ }
255
+ /** OR filter on the `location` field */
256
+ location() {
257
+ return new LocationFilter("or");
258
+ }
259
+ /** OR filter on a custom attribute */
260
+ attr(name) {
261
+ return new AttrFilter(name, "or");
262
+ }
263
+ }
264
+ // ---------------------------------------------------------------------------
265
+ // Top-level factory functions (AND logic by default)
266
+ // ---------------------------------------------------------------------------
267
+ /** Filter on the lead `name` field (AND logic) */
268
+ export const name = () => new TextFilter("name", "and");
269
+ /** Filter on the `city` field (AND logic) */
270
+ export const city = () => new TextFilter("city", "and");
271
+ /** Filter on the `country` field (AND logic) */
272
+ export const country = () => new TextFilter("country", "and");
273
+ /** Filter on the `state` field (AND logic) */
274
+ export const state = () => new TextFilter("state", "and");
275
+ /** Filter on the `category` field (AND logic) */
276
+ export const category = () => new TextFilter("category", "and");
277
+ /** Filter on the `source` field (AND logic) */
278
+ export const source = () => new TextFilter("source", "and");
279
+ /** Filter on the `email` field (AND logic) */
280
+ export const email = () => new TextFilter("email", "and");
281
+ /** Filter on the `phone` field (AND logic) */
282
+ export const phone = () => new TextFilter("phone", "and");
283
+ /** Filter on the `website` field (AND logic) */
284
+ export const website = () => new TextFilter("website", "and");
285
+ /** Filter on the `rating` field (AND logic) */
286
+ export const rating = () => new NumberFilter("rating", "and");
287
+ /** Filter on the `review_count` field (AND logic) */
288
+ export const reviewCount = () => new NumberFilter("review_count", "and");
289
+ /** Filter on the `tags` array field (AND logic) */
290
+ export const tags = () => new TagsFilter("and");
291
+ /** Filter on the `location` (coordinates) field (AND logic) */
292
+ export const location = () => new LocationFilter("and");
293
+ /**
294
+ * Filter on a custom dynamic attribute (AND logic).
295
+ * @param name - Attribute name (e.g. "industry")
296
+ */
297
+ export const attr = (name) => new AttrFilter(name, "and");
298
+ /**
299
+ * Start an OR-logic filter chain.
300
+ * @example
301
+ * or().city().eq("Paris")
302
+ */
303
+ export const or = () => new OrBuilder();
304
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/filters/index.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,SAAS,UAAU,CACjB,KAAmB,EACnB,QAAgB,EAChB,KAAa,EACb,KAAK,GAAG,EAAE;IAEV,OAAO;QACL,KAAK;QACL,QAAQ;QACR,KAAK;QACL,KAAK;QACL,QAAQ;YACN,OAAO,KAAK,KAAK,EAAE;gBACjB,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC9D,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACrD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;GAEG;AACH,MAAM,OAAO,UAAU;IAEF;IACA;IAFnB,YACmB,KAAa,EACb,KAAmB;QADnB,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAAc;IACnC,CAAC;IAEJ,4CAA4C;IAC5C,EAAE,CAAC,KAAa;QACd,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAED,6BAA6B;IAC7B,GAAG,CAAC,KAAa;QACf,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EA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B,EAAE,CAAC,IAAI,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAEvF,mDAAmD;AACnD,MAAM,CAAC,MAAM,IAAI,GAAG,GAAe,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAE5D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAmB,EAAE,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,GAAc,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC"}
@@ -0,0 +1,26 @@
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
+ // Main client
19
+ export { Klozeo } from "./client.js";
20
+ // Enum (value, not just type)
21
+ export { ExportFormat } from "./types.js";
22
+ // Error classes
23
+ export { KlozeoError, NotFoundError, UnauthorizedError, ForbiddenError, RateLimitedError, BadRequestError, } from "./errors.js";
24
+ // Attribute helpers
25
+ export { textAttr, numberAttr, boolAttr, listAttr, objectAttr, } from "./attribute-helpers.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc;AACd,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAqClC,8BAA8B;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,gBAAgB;AAChB,OAAO,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,oBAAoB;AACpB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,153 @@
1
+ import { buildQueryParams, deserializeLead, serializeLeadInput, } from "../utils.js";
2
+ /**
3
+ * Resource class for all lead-related API operations.
4
+ */
5
+ export class LeadsResource {
6
+ http;
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * Create a new lead. Returns a `CreateResponse` that includes the ID
12
+ * and indicates whether an existing lead was merged (deduplication).
13
+ */
14
+ async create(input) {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const raw = await this.http.request("POST", "/leads", {
17
+ body: serializeLeadInput(input),
18
+ });
19
+ return {
20
+ id: raw.id,
21
+ message: raw.message,
22
+ createdAt: raw.created_at,
23
+ duplicate: raw.duplicate,
24
+ potentialDuplicateId: raw.potential_duplicate_id,
25
+ };
26
+ }
27
+ /**
28
+ * Retrieve a single lead by ID.
29
+ */
30
+ async get(id) {
31
+ const raw = await this.http.request("GET", `/leads/${encodeURIComponent(id)}`);
32
+ return deserializeLead(raw);
33
+ }
34
+ /**
35
+ * Update a lead. Only the supplied fields are changed.
36
+ * Returns the full updated lead object.
37
+ */
38
+ async update(id, input) {
39
+ const raw = await this.http.request("PUT", `/leads/${encodeURIComponent(id)}`, {
40
+ body: serializeLeadInput(input),
41
+ });
42
+ return deserializeLead(raw);
43
+ }
44
+ /**
45
+ * Delete a lead permanently. Resolves when the deletion succeeds (204).
46
+ */
47
+ async delete(id) {
48
+ await this.http.request("DELETE", `/leads/${encodeURIComponent(id)}`);
49
+ }
50
+ /**
51
+ * List leads with optional filters, sorting, and cursor pagination.
52
+ */
53
+ async list(opts = {}) {
54
+ const params = new URLSearchParams();
55
+ buildQueryParams(params, opts);
56
+ const raw = await this.http.request("GET", `/leads?${params.toString()}`);
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ const r = raw;
59
+ return {
60
+ leads: (r.leads ?? []).map(deserializeLead),
61
+ nextCursor: r.next_cursor,
62
+ hasMore: r.has_more ?? false,
63
+ count: r.count ?? 0,
64
+ };
65
+ }
66
+ /**
67
+ * Async iterator that automatically fetches all pages.
68
+ *
69
+ * @example
70
+ * for await (const lead of client.leads.iterate({ filters: [city().eq("Berlin")] })) {
71
+ * console.log(lead.name);
72
+ * }
73
+ */
74
+ async *iterate(opts = {}) {
75
+ let cursor;
76
+ do {
77
+ const listOpts = { ...opts };
78
+ if (cursor !== undefined)
79
+ listOpts.cursor = cursor;
80
+ const page = await this.list(listOpts);
81
+ for (const lead of page.leads) {
82
+ yield lead;
83
+ }
84
+ cursor = page.hasMore ? page.nextCursor : undefined;
85
+ } while (cursor !== undefined);
86
+ }
87
+ /**
88
+ * Export leads as CSV, JSON, or XLSX. Returns a `Blob`.
89
+ *
90
+ * @example
91
+ * // Browser
92
+ * const blob = await client.leads.export(ExportFormat.CSV);
93
+ * const url = URL.createObjectURL(blob);
94
+ *
95
+ * // Node.js
96
+ * const blob = await client.leads.export(ExportFormat.CSV);
97
+ * writeFileSync("leads.csv", Buffer.from(await blob.arrayBuffer()));
98
+ */
99
+ async export(format, opts = {}) {
100
+ const params = new URLSearchParams();
101
+ buildQueryParams(params, { ...opts, format });
102
+ return this.http.requestBlob("GET", `/leads/export?${params.toString()}`);
103
+ }
104
+ /**
105
+ * Create up to 100 leads in a single request.
106
+ * Returns per-item results including successes and failures.
107
+ */
108
+ async batchCreate(leads) {
109
+ const body = { leads: leads.map((l) => serializeLeadInput(l)) };
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ const raw = await this.http.request("POST", "/leads/batch", { body });
112
+ return {
113
+ created: (raw.created ?? []).map(
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+ (item) => ({ index: item.index, id: item.id, createdAt: item.created_at })),
116
+ errors: raw.errors ?? [],
117
+ total: raw.total ?? leads.length,
118
+ success: raw.success ?? 0,
119
+ failed: raw.failed ?? 0,
120
+ };
121
+ }
122
+ /**
123
+ * Apply the same partial update to up to 100 leads.
124
+ */
125
+ async batchUpdate(input) {
126
+ const body = {
127
+ ids: input.ids,
128
+ data: serializeLeadInput(input.data),
129
+ };
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ const raw = await this.http.request("PUT", "/leads/batch", { body });
132
+ return {
133
+ results: raw.results ?? [],
134
+ total: raw.total ?? input.ids.length,
135
+ success: raw.success ?? 0,
136
+ failed: raw.failed ?? 0,
137
+ };
138
+ }
139
+ /**
140
+ * Delete up to 100 leads in a single request.
141
+ */
142
+ async batchDelete(ids) {
143
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
144
+ const raw = await this.http.request("DELETE", "/leads/batch", { body: { ids } });
145
+ return {
146
+ results: raw.results ?? [],
147
+ total: raw.total ?? ids.length,
148
+ success: raw.success ?? 0,
149
+ failed: raw.failed ?? 0,
150
+ };
151
+ }
152
+ }
153
+ //# sourceMappingURL=leads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leads.js","sourceRoot":"","sources":["../../../src/resources/leads.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAGlB;;GAEG;AACH,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB;QACjC,8DAA8D;QAC9D,MAAM,GAAG,GAAQ,MAAM,I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AAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;YAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM;YACpC,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC;YACzB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC;SACxB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,GAAa;QAC7B,8DAA8D;QAC9D,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACtF,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;YAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM;YAC9B,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC;YACzB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC;SACxB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ import { deserializeNote } from "../utils.js";
2
+ /**
3
+ * Resource class for lead note operations.
4
+ */
5
+ export class NotesResource {
6
+ http;
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * List all notes for a lead.
12
+ */
13
+ async list(leadId) {
14
+ const raw = await this.http.request("GET", `/leads/${encodeURIComponent(leadId)}/notes`);
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const r = raw;
17
+ return {
18
+ notes: (r.notes ?? []).map(deserializeNote),
19
+ };
20
+ }
21
+ /**
22
+ * Create a note on a lead.
23
+ * @param leadId - ID of the lead to attach the note to
24
+ * @param content - Note content text
25
+ */
26
+ async create(leadId, content) {
27
+ const raw = await this.http.request("POST", `/leads/${encodeURIComponent(leadId)}/notes`, { body: { content } });
28
+ return deserializeNote(raw);
29
+ }
30
+ /**
31
+ * Update the content of an existing note.
32
+ * @param noteId - ID of the note to update (format: "note_...")
33
+ * @param content - New content
34
+ */
35
+ async update(noteId, content) {
36
+ const raw = await this.http.request("PUT", `/notes/${encodeURIComponent(noteId)}`, { body: { content } });
37
+ return deserializeNote(raw);
38
+ }
39
+ /**
40
+ * Delete a note permanently. Resolves when deletion succeeds (204).
41
+ * @param noteId - ID of the note to delete (format: "note_...")
42
+ */
43
+ async delete(noteId) {
44
+ await this.http.request("DELETE", `/notes/${encodeURIComponent(noteId)}`);
45
+ }
46
+ }
47
+ //# sourceMappingURL=notes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notes.js","sourceRoot":"","sources":["../../../src/resources/notes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;;GAEG;AACH,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACjC,KAAK,EACL,UAAU,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAC7C,CAAC;QACF,8DAA8D;QAC9D,MAAM,CAAC,GAAG,GAAU,CAAC;QACrB,OAAO;YACL,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC;SAC5C,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,OAAe;QAC1C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACjC,MAAM,EACN,UAAU,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAC5C,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,CACtB,CAAC;QACF,OAAO,eAAe,CAAC,GAA8B,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,OAAe;QAC1C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACjC,KAAK,EACL,UAAU,kBAAkB,CAAC,MAAM,CAAC,EAAE,EACtC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,CACtB,CAAC;QACF,OAAO,eAAe,CAAC,GAA8B,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF"}
@@ -0,0 +1,60 @@
1
+ import { deserializeScoringRule } from "../utils.js";
2
+ /**
3
+ * Resource class for scoring rule and lead score operations.
4
+ */
5
+ export class ScoringResource {
6
+ http;
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * List all scoring rules for this account.
12
+ */
13
+ async listRules() {
14
+ const raw = await this.http.request("GET", "/scoring-rules");
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const r = raw;
17
+ return {
18
+ rules: (r.rules ?? []).map(deserializeScoringRule),
19
+ };
20
+ }
21
+ /**
22
+ * Create a new scoring rule.
23
+ */
24
+ async createRule(input) {
25
+ const raw = await this.http.request("POST", "/scoring-rules", { body: input });
26
+ return deserializeScoringRule(raw);
27
+ }
28
+ /**
29
+ * Retrieve a single scoring rule by ID.
30
+ */
31
+ async getRule(id) {
32
+ const raw = await this.http.request("GET", `/scoring-rules/${encodeURIComponent(id)}`);
33
+ return deserializeScoringRule(raw);
34
+ }
35
+ /**
36
+ * Update a scoring rule. Only the supplied fields are changed.
37
+ */
38
+ async updateRule(id, input) {
39
+ await this.http.request("PUT", `/scoring-rules/${encodeURIComponent(id)}`, {
40
+ body: input,
41
+ });
42
+ }
43
+ /**
44
+ * Delete a scoring rule.
45
+ */
46
+ async deleteRule(id) {
47
+ await this.http.request("DELETE", `/scoring-rules/${encodeURIComponent(id)}`);
48
+ }
49
+ /**
50
+ * Recalculate and persist the score for a single lead.
51
+ * Returns the new score value.
52
+ */
53
+ async recalculate(leadId) {
54
+ const raw = await this.http.request("POST", `/leads/${encodeURIComponent(leadId)}/score`);
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ const r = raw;
57
+ return { id: r.id, score: r.score };
58
+ }
59
+ }
60
+ //# sourceMappingURL=scoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../../src/resources/scoring.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD;;GAEG;AACH,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAC7D,8DAA8D;QAC9D,MAAM,CAAC,GAAG,GAAU,CAAC;QACrB,OAAO;YACL,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC;SACnD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,KAA6B;QAC5C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,OAAO,sBAAsB,CAAC,GAA8B,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,kBAAkB,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACvF,OAAO,sBAAsB,CAAC,GAA8B,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,EAAU,EAAE,KAA6B;QACxD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,kBAAkB,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE;YACzE,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,kBAAkB,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,MAAc;QAC9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACjC,MAAM,EACN,UAAU,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAC7C,CAAC;QACF,8DAA8D;QAC9D,MAAM,CAAC,GAAG,GAAU,CAAC;QACrB,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ import { deserializeWebhook } from "../utils.js";
2
+ /**
3
+ * Resource class for webhook subscription operations.
4
+ */
5
+ export class WebhooksResource {
6
+ http;
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * List all webhooks for this account.
12
+ */
13
+ async list() {
14
+ const raw = await this.http.request("GET", "/webhooks");
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const r = raw;
17
+ return {
18
+ webhooks: (r.webhooks ?? []).map(deserializeWebhook),
19
+ };
20
+ }
21
+ /**
22
+ * Create a new webhook subscription.
23
+ * The `secret` field (if provided) is used only for payload signing and
24
+ * is never returned by the API.
25
+ */
26
+ async create(input) {
27
+ const raw = await this.http.request("POST", "/webhooks", { body: input });
28
+ return deserializeWebhook(raw);
29
+ }
30
+ /**
31
+ * Delete a webhook subscription permanently.
32
+ * @param id - UUID of the webhook to delete
33
+ */
34
+ async delete(id) {
35
+ await this.http.request("DELETE", `/webhooks/${encodeURIComponent(id)}`);
36
+ }
37
+ }
38
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACxD,8DAA8D;QAC9D,MAAM,CAAC,GAAG,GAAU,CAAC;QACrB,OAAO;YACL,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC;SACrD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,KAAyB;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1E,OAAO,kBAAkB,CAAC,GAA8B,CAAC,CAAC;IAC5D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF"}