@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.
- package/README.md +141 -0
- package/dist/cjs/attribute-helpers.js +43 -0
- package/dist/cjs/attribute-helpers.js.map +1 -0
- package/dist/cjs/client.js +150 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.js +75 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/filters/index.js +320 -0
- package/dist/cjs/filters/index.js.map +1 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/resources/leads.js +156 -0
- package/dist/cjs/resources/leads.js.map +1 -0
- package/dist/cjs/resources/notes.js +50 -0
- package/dist/cjs/resources/notes.js.map +1 -0
- package/dist/cjs/resources/scoring.js +63 -0
- package/dist/cjs/resources/scoring.js.map +1 -0
- package/dist/cjs/resources/webhooks.js +41 -0
- package/dist/cjs/resources/webhooks.js.map +1 -0
- package/dist/cjs/types.js +13 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.js +179 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/attribute-helpers.js +36 -0
- package/dist/esm/attribute-helpers.js.map +1 -0
- package/dist/esm/client.js +159 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +72 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/filters/index.js +304 -0
- package/dist/esm/filters/index.js.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/resources/leads.js +153 -0
- package/dist/esm/resources/leads.js.map +1 -0
- package/dist/esm/resources/notes.js +47 -0
- package/dist/esm/resources/notes.js.map +1 -0
- package/dist/esm/resources/scoring.js +60 -0
- package/dist/esm/resources/scoring.js.map +1 -0
- package/dist/esm/resources/webhooks.js +38 -0
- package/dist/esm/resources/webhooks.js.map +1 -0
- package/dist/esm/types.js +10 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.js +168 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/attribute-helpers.d.ts +27 -0
- package/dist/types/attribute-helpers.d.ts.map +1 -0
- package/dist/types/client.d.ts +64 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.ts +44 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/filters/index.d.ts +173 -0
- package/dist/types/filters/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/resources/leads.d.ts +67 -0
- package/dist/types/resources/leads.d.ts.map +1 -0
- package/dist/types/resources/notes.d.ts +31 -0
- package/dist/types/resources/notes.d.ts.map +1 -0
- package/dist/types/resources/scoring.d.ts +35 -0
- package/dist/types/resources/scoring.d.ts.map +1 -0
- package/dist/types/resources/webhooks.d.ts +25 -0
- package/dist/types/resources/webhooks.d.ts.map +1 -0
- package/dist/types/types.d.ts +409 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +49 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.or = exports.attr = exports.location = exports.tags = exports.reviewCount = exports.rating = exports.website = exports.phone = exports.email = exports.source = exports.category = exports.state = exports.country = exports.city = exports.name = exports.OrBuilder = exports.AttrFilter = exports.LocationFilter = exports.TagsFilter = exports.NumberFilter = exports.TextFilter = void 0;
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Internal helpers
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
function makeFilter(logic, operator, field, value = "") {
|
|
8
|
+
return {
|
|
9
|
+
logic,
|
|
10
|
+
operator,
|
|
11
|
+
field,
|
|
12
|
+
value,
|
|
13
|
+
toString() {
|
|
14
|
+
return value !== ""
|
|
15
|
+
? `${this.logic}.${this.operator}.${this.field}.${this.value}`
|
|
16
|
+
: `${this.logic}.${this.operator}.${this.field}`;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Text filter builder
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Builder for text field filters.
|
|
25
|
+
*/
|
|
26
|
+
class TextFilter {
|
|
27
|
+
constructor(field, logic) {
|
|
28
|
+
this.field = field;
|
|
29
|
+
this.logic = logic;
|
|
30
|
+
}
|
|
31
|
+
/** Field equals value (case insensitive) */
|
|
32
|
+
eq(value) {
|
|
33
|
+
return makeFilter(this.logic, "eq", this.field, value);
|
|
34
|
+
}
|
|
35
|
+
/** Field not equals value */
|
|
36
|
+
neq(value) {
|
|
37
|
+
return makeFilter(this.logic, "neq", this.field, value);
|
|
38
|
+
}
|
|
39
|
+
/** Field contains substring */
|
|
40
|
+
contains(value) {
|
|
41
|
+
return makeFilter(this.logic, "contains", this.field, value);
|
|
42
|
+
}
|
|
43
|
+
/** Field does not contain substring */
|
|
44
|
+
notContains(value) {
|
|
45
|
+
return makeFilter(this.logic, "not_contains", this.field, value);
|
|
46
|
+
}
|
|
47
|
+
/** Field is null or empty */
|
|
48
|
+
isEmpty() {
|
|
49
|
+
return makeFilter(this.logic, "is_empty", this.field);
|
|
50
|
+
}
|
|
51
|
+
/** Field has a value */
|
|
52
|
+
isNotEmpty() {
|
|
53
|
+
return makeFilter(this.logic, "is_not_empty", this.field);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TextFilter = TextFilter;
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// Number filter builder
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
/**
|
|
61
|
+
* Builder for numeric field filters.
|
|
62
|
+
*/
|
|
63
|
+
class NumberFilter {
|
|
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
|
+
exports.NumberFilter = NumberFilter;
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// Tags filter builder
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
/**
|
|
98
|
+
* Builder for the `tags` array field.
|
|
99
|
+
*/
|
|
100
|
+
class TagsFilter {
|
|
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
|
+
exports.TagsFilter = TagsFilter;
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
// Location filter builder
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
/**
|
|
126
|
+
* Builder for the `location` (latitude + longitude) field.
|
|
127
|
+
*/
|
|
128
|
+
class LocationFilter {
|
|
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
|
+
exports.LocationFilter = LocationFilter;
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
// Custom attribute filter builder
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
/**
|
|
155
|
+
* Builder for dynamic attribute filters (`attr:<name>`).
|
|
156
|
+
*/
|
|
157
|
+
class AttrFilter {
|
|
158
|
+
constructor(name, logic) {
|
|
159
|
+
this.logic = logic;
|
|
160
|
+
this.field = `attr:${name}`;
|
|
161
|
+
}
|
|
162
|
+
/** Attribute equals text value (case insensitive) */
|
|
163
|
+
eq(value) {
|
|
164
|
+
return makeFilter(this.logic, "eq", this.field, value);
|
|
165
|
+
}
|
|
166
|
+
/** Attribute not equals text value */
|
|
167
|
+
neq(value) {
|
|
168
|
+
return makeFilter(this.logic, "neq", this.field, value);
|
|
169
|
+
}
|
|
170
|
+
/** Attribute contains substring */
|
|
171
|
+
contains(value) {
|
|
172
|
+
return makeFilter(this.logic, "contains", this.field, value);
|
|
173
|
+
}
|
|
174
|
+
/** Attribute equals numeric value */
|
|
175
|
+
eqNumber(value) {
|
|
176
|
+
return makeFilter(this.logic, "eq", this.field, String(value));
|
|
177
|
+
}
|
|
178
|
+
/** Attribute greater than value */
|
|
179
|
+
gt(value) {
|
|
180
|
+
return makeFilter(this.logic, "gt", this.field, String(value));
|
|
181
|
+
}
|
|
182
|
+
/** Attribute greater than or equal to value */
|
|
183
|
+
gte(value) {
|
|
184
|
+
return makeFilter(this.logic, "gte", this.field, String(value));
|
|
185
|
+
}
|
|
186
|
+
/** Attribute less than value */
|
|
187
|
+
lt(value) {
|
|
188
|
+
return makeFilter(this.logic, "lt", this.field, String(value));
|
|
189
|
+
}
|
|
190
|
+
/** Attribute less than or equal to value */
|
|
191
|
+
lte(value) {
|
|
192
|
+
return makeFilter(this.logic, "lte", this.field, String(value));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.AttrFilter = AttrFilter;
|
|
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
|
+
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
|
+
exports.OrBuilder = OrBuilder;
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
// Top-level factory functions (AND logic by default)
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
/** Filter on the lead `name` field (AND logic) */
|
|
269
|
+
const name = () => new TextFilter("name", "and");
|
|
270
|
+
exports.name = name;
|
|
271
|
+
/** Filter on the `city` field (AND logic) */
|
|
272
|
+
const city = () => new TextFilter("city", "and");
|
|
273
|
+
exports.city = city;
|
|
274
|
+
/** Filter on the `country` field (AND logic) */
|
|
275
|
+
const country = () => new TextFilter("country", "and");
|
|
276
|
+
exports.country = country;
|
|
277
|
+
/** Filter on the `state` field (AND logic) */
|
|
278
|
+
const state = () => new TextFilter("state", "and");
|
|
279
|
+
exports.state = state;
|
|
280
|
+
/** Filter on the `category` field (AND logic) */
|
|
281
|
+
const category = () => new TextFilter("category", "and");
|
|
282
|
+
exports.category = category;
|
|
283
|
+
/** Filter on the `source` field (AND logic) */
|
|
284
|
+
const source = () => new TextFilter("source", "and");
|
|
285
|
+
exports.source = source;
|
|
286
|
+
/** Filter on the `email` field (AND logic) */
|
|
287
|
+
const email = () => new TextFilter("email", "and");
|
|
288
|
+
exports.email = email;
|
|
289
|
+
/** Filter on the `phone` field (AND logic) */
|
|
290
|
+
const phone = () => new TextFilter("phone", "and");
|
|
291
|
+
exports.phone = phone;
|
|
292
|
+
/** Filter on the `website` field (AND logic) */
|
|
293
|
+
const website = () => new TextFilter("website", "and");
|
|
294
|
+
exports.website = website;
|
|
295
|
+
/** Filter on the `rating` field (AND logic) */
|
|
296
|
+
const rating = () => new NumberFilter("rating", "and");
|
|
297
|
+
exports.rating = rating;
|
|
298
|
+
/** Filter on the `review_count` field (AND logic) */
|
|
299
|
+
const reviewCount = () => new NumberFilter("review_count", "and");
|
|
300
|
+
exports.reviewCount = reviewCount;
|
|
301
|
+
/** Filter on the `tags` array field (AND logic) */
|
|
302
|
+
const tags = () => new TagsFilter("and");
|
|
303
|
+
exports.tags = tags;
|
|
304
|
+
/** Filter on the `location` (coordinates) field (AND logic) */
|
|
305
|
+
const location = () => new LocationFilter("and");
|
|
306
|
+
exports.location = location;
|
|
307
|
+
/**
|
|
308
|
+
* Filter on a custom dynamic attribute (AND logic).
|
|
309
|
+
* @param name - Attribute name (e.g. "industry")
|
|
310
|
+
*/
|
|
311
|
+
const attr = (name) => new AttrFilter(name, "and");
|
|
312
|
+
exports.attr = attr;
|
|
313
|
+
/**
|
|
314
|
+
* Start an OR-logic filter chain.
|
|
315
|
+
* @example
|
|
316
|
+
* or().city().eq("Paris")
|
|
317
|
+
*/
|
|
318
|
+
const or = () => new OrBuilder();
|
|
319
|
+
exports.or = or;
|
|
320
|
+
//# 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,MAAa,UAAU;IACrB,YACmB,KAAa,EACb,KAAmB;QADnB,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAAc;IACnC,CAAC;IAEJ,4CAA4C;IAC5C,EAAE,CAAC,KAAa;QACd,O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;AAAzD,QAAA,KAAK,SAAoD;AAEtE,gDAAgD;AACzC,MAAM,OAAO,GAAG,GAAe,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAA7D,QAAA,OAAO,WAAsD;AAE1E,+CAA+C;AACxC,MAAM,MAAM,GAAG,GAAiB,EAAE,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAA/D,QAAA,MAAM,UAAyD;AAE5E,qDAAqD;AAC9C,MAAM,WAAW,GAAG,GAAiB,EAAE,CAAC,IAAI,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAA1E,QAAA,WAAW,eAA+D;AAEvF,mDAAmD;AAC5C,MAAM,IAAI,GAAG,GAAe,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAA/C,QAAA,IAAI,QAA2C;AAE5D,+DAA+D;AACxD,MAAM,QAAQ,GAAG,GAAmB,EAAE,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;AAA3D,QAAA,QAAQ,YAAmD;AAExE;;;GAGG;AACI,MAAM,IAAI,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAAjE,QAAA,IAAI,QAA6D;AAE9E;;;;GAIG;AACI,MAAM,EAAE,GAAG,GAAc,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;AAAtC,QAAA,EAAE,MAAoC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @klozeo/sdk — Official TypeScript SDK for the Klozeo API.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { Klozeo, ExportFormat } from "@klozeo/sdk";
|
|
8
|
+
* import { city, rating, or } from "@klozeo/sdk/filters";
|
|
9
|
+
*
|
|
10
|
+
* const client = new Klozeo("sk_live_your_api_key");
|
|
11
|
+
*
|
|
12
|
+
* const page = await client.leads.list({
|
|
13
|
+
* filters: [city().eq("Berlin"), rating().gte(4.0)],
|
|
14
|
+
* sortBy: "rating",
|
|
15
|
+
* sortOrder: "desc",
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.objectAttr = exports.listAttr = exports.boolAttr = exports.numberAttr = exports.textAttr = exports.BadRequestError = exports.RateLimitedError = exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.KlozeoError = exports.ExportFormat = exports.Klozeo = void 0;
|
|
21
|
+
// Main client
|
|
22
|
+
var client_1 = require("./client");
|
|
23
|
+
Object.defineProperty(exports, "Klozeo", { enumerable: true, get: function () { return client_1.Klozeo; } });
|
|
24
|
+
// Enum (value, not just type)
|
|
25
|
+
var types_1 = require("./types");
|
|
26
|
+
Object.defineProperty(exports, "ExportFormat", { enumerable: true, get: function () { return types_1.ExportFormat; } });
|
|
27
|
+
// Error classes
|
|
28
|
+
var errors_1 = require("./errors");
|
|
29
|
+
Object.defineProperty(exports, "KlozeoError", { enumerable: true, get: function () { return errors_1.KlozeoError; } });
|
|
30
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_1.NotFoundError; } });
|
|
31
|
+
Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return errors_1.UnauthorizedError; } });
|
|
32
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return errors_1.ForbiddenError; } });
|
|
33
|
+
Object.defineProperty(exports, "RateLimitedError", { enumerable: true, get: function () { return errors_1.RateLimitedError; } });
|
|
34
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return errors_1.BadRequestError; } });
|
|
35
|
+
// Attribute helpers
|
|
36
|
+
var attribute_helpers_1 = require("./attribute-helpers");
|
|
37
|
+
Object.defineProperty(exports, "textAttr", { enumerable: true, get: function () { return attribute_helpers_1.textAttr; } });
|
|
38
|
+
Object.defineProperty(exports, "numberAttr", { enumerable: true, get: function () { return attribute_helpers_1.numberAttr; } });
|
|
39
|
+
Object.defineProperty(exports, "boolAttr", { enumerable: true, get: function () { return attribute_helpers_1.boolAttr; } });
|
|
40
|
+
Object.defineProperty(exports, "listAttr", { enumerable: true, get: function () { return attribute_helpers_1.listAttr; } });
|
|
41
|
+
Object.defineProperty(exports, "objectAttr", { enumerable: true, get: function () { return attribute_helpers_1.objectAttr; } });
|
|
42
|
+
//# 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,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAqCf,8BAA8B;AAC9B,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AAErB,gBAAgB;AAChB,mCAOkB;AANhB,qGAAA,WAAW,OAAA;AACX,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AACd,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AAGjB,oBAAoB;AACpB,yDAM6B;AAL3B,6GAAA,QAAQ,OAAA;AACR,+GAAA,UAAU,OAAA;AACV,6GAAA,QAAQ,OAAA;AACR,6GAAA,QAAQ,OAAA;AACR,+GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeadsResource = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Resource class for all lead-related API operations.
|
|
7
|
+
*/
|
|
8
|
+
class LeadsResource {
|
|
9
|
+
constructor(http) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a new lead. Returns a `CreateResponse` that includes the ID
|
|
14
|
+
* and indicates whether an existing lead was merged (deduplication).
|
|
15
|
+
*/
|
|
16
|
+
async create(input) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const raw = await this.http.request("POST", "/leads", {
|
|
19
|
+
body: (0, utils_1.serializeLeadInput)(input),
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
id: raw.id,
|
|
23
|
+
message: raw.message,
|
|
24
|
+
createdAt: raw.created_at,
|
|
25
|
+
duplicate: raw.duplicate,
|
|
26
|
+
potentialDuplicateId: raw.potential_duplicate_id,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve a single lead by ID.
|
|
31
|
+
*/
|
|
32
|
+
async get(id) {
|
|
33
|
+
const raw = await this.http.request("GET", `/leads/${encodeURIComponent(id)}`);
|
|
34
|
+
return (0, utils_1.deserializeLead)(raw);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Update a lead. Only the supplied fields are changed.
|
|
38
|
+
* Returns the full updated lead object.
|
|
39
|
+
*/
|
|
40
|
+
async update(id, input) {
|
|
41
|
+
const raw = await this.http.request("PUT", `/leads/${encodeURIComponent(id)}`, {
|
|
42
|
+
body: (0, utils_1.serializeLeadInput)(input),
|
|
43
|
+
});
|
|
44
|
+
return (0, utils_1.deserializeLead)(raw);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Delete a lead permanently. Resolves when the deletion succeeds (204).
|
|
48
|
+
*/
|
|
49
|
+
async delete(id) {
|
|
50
|
+
await this.http.request("DELETE", `/leads/${encodeURIComponent(id)}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* List leads with optional filters, sorting, and cursor pagination.
|
|
54
|
+
*/
|
|
55
|
+
async list(opts = {}) {
|
|
56
|
+
const params = new URLSearchParams();
|
|
57
|
+
(0, utils_1.buildQueryParams)(params, opts);
|
|
58
|
+
const raw = await this.http.request("GET", `/leads?${params.toString()}`);
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
const r = raw;
|
|
61
|
+
return {
|
|
62
|
+
leads: (r.leads ?? []).map(utils_1.deserializeLead),
|
|
63
|
+
nextCursor: r.next_cursor,
|
|
64
|
+
hasMore: r.has_more ?? false,
|
|
65
|
+
count: r.count ?? 0,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Async iterator that automatically fetches all pages.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* for await (const lead of client.leads.iterate({ filters: [city().eq("Berlin")] })) {
|
|
73
|
+
* console.log(lead.name);
|
|
74
|
+
* }
|
|
75
|
+
*/
|
|
76
|
+
async *iterate(opts = {}) {
|
|
77
|
+
let cursor;
|
|
78
|
+
do {
|
|
79
|
+
const listOpts = { ...opts };
|
|
80
|
+
if (cursor !== undefined)
|
|
81
|
+
listOpts.cursor = cursor;
|
|
82
|
+
const page = await this.list(listOpts);
|
|
83
|
+
for (const lead of page.leads) {
|
|
84
|
+
yield lead;
|
|
85
|
+
}
|
|
86
|
+
cursor = page.hasMore ? page.nextCursor : undefined;
|
|
87
|
+
} while (cursor !== undefined);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Export leads as CSV, JSON, or XLSX. Returns a `Blob`.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Browser
|
|
94
|
+
* const blob = await client.leads.export(ExportFormat.CSV);
|
|
95
|
+
* const url = URL.createObjectURL(blob);
|
|
96
|
+
*
|
|
97
|
+
* // Node.js
|
|
98
|
+
* const blob = await client.leads.export(ExportFormat.CSV);
|
|
99
|
+
* writeFileSync("leads.csv", Buffer.from(await blob.arrayBuffer()));
|
|
100
|
+
*/
|
|
101
|
+
async export(format, opts = {}) {
|
|
102
|
+
const params = new URLSearchParams();
|
|
103
|
+
(0, utils_1.buildQueryParams)(params, { ...opts, format });
|
|
104
|
+
return this.http.requestBlob("GET", `/leads/export?${params.toString()}`);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create up to 100 leads in a single request.
|
|
108
|
+
* Returns per-item results including successes and failures.
|
|
109
|
+
*/
|
|
110
|
+
async batchCreate(leads) {
|
|
111
|
+
const body = { leads: leads.map((l) => (0, utils_1.serializeLeadInput)(l)) };
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
const raw = await this.http.request("POST", "/leads/batch", { body });
|
|
114
|
+
return {
|
|
115
|
+
created: (raw.created ?? []).map(
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
(item) => ({ index: item.index, id: item.id, createdAt: item.created_at })),
|
|
118
|
+
errors: raw.errors ?? [],
|
|
119
|
+
total: raw.total ?? leads.length,
|
|
120
|
+
success: raw.success ?? 0,
|
|
121
|
+
failed: raw.failed ?? 0,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Apply the same partial update to up to 100 leads.
|
|
126
|
+
*/
|
|
127
|
+
async batchUpdate(input) {
|
|
128
|
+
const body = {
|
|
129
|
+
ids: input.ids,
|
|
130
|
+
data: (0, utils_1.serializeLeadInput)(input.data),
|
|
131
|
+
};
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
const raw = await this.http.request("PUT", "/leads/batch", { body });
|
|
134
|
+
return {
|
|
135
|
+
results: raw.results ?? [],
|
|
136
|
+
total: raw.total ?? input.ids.length,
|
|
137
|
+
success: raw.success ?? 0,
|
|
138
|
+
failed: raw.failed ?? 0,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Delete up to 100 leads in a single request.
|
|
143
|
+
*/
|
|
144
|
+
async batchDelete(ids) {
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
const raw = await this.http.request("DELETE", "/leads/batch", { body: { ids } });
|
|
147
|
+
return {
|
|
148
|
+
results: raw.results ?? [],
|
|
149
|
+
total: raw.total ?? ids.length,
|
|
150
|
+
success: raw.success ?? 0,
|
|
151
|
+
failed: raw.failed ?? 0,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.LeadsResource = LeadsResource;
|
|
156
|
+
//# sourceMappingURL=leads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leads.js","sourceRoot":"","sources":["../../../src/resources/leads.ts"],"names":[],"mappings":";;;AAaA,oCAIkB;AAGlB;;GAEG;AACH,MAAa,aAAa;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB;QACjC,8DAA8D;QAC9D,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE;YACzD,IAAI,EAAE,IAAA,0BAAkB,EAAC,KAA2C,CAAC;SACtE,CAAC,CAAC;QACH,OAAO;YACL,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,oBAAoB,EAAE,GAAG,CAAC,sBAAsB;SACjD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/E,OAAO,IAAA,uBAAe,EAAC,GAA8B,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,K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AAE,GAAG,CAAC,OAAO,IAAI,CAAC;YACzB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC;SACxB,CAAC;IACJ,CAAC;CACF;AA7JD,sCA6JC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotesResource = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Resource class for lead note operations.
|
|
7
|
+
*/
|
|
8
|
+
class NotesResource {
|
|
9
|
+
constructor(http) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List all notes for a lead.
|
|
14
|
+
*/
|
|
15
|
+
async list(leadId) {
|
|
16
|
+
const raw = await this.http.request("GET", `/leads/${encodeURIComponent(leadId)}/notes`);
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const r = raw;
|
|
19
|
+
return {
|
|
20
|
+
notes: (r.notes ?? []).map(utils_1.deserializeNote),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a note on a lead.
|
|
25
|
+
* @param leadId - ID of the lead to attach the note to
|
|
26
|
+
* @param content - Note content text
|
|
27
|
+
*/
|
|
28
|
+
async create(leadId, content) {
|
|
29
|
+
const raw = await this.http.request("POST", `/leads/${encodeURIComponent(leadId)}/notes`, { body: { content } });
|
|
30
|
+
return (0, utils_1.deserializeNote)(raw);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Update the content of an existing note.
|
|
34
|
+
* @param noteId - ID of the note to update (format: "note_...")
|
|
35
|
+
* @param content - New content
|
|
36
|
+
*/
|
|
37
|
+
async update(noteId, content) {
|
|
38
|
+
const raw = await this.http.request("PUT", `/notes/${encodeURIComponent(noteId)}`, { body: { content } });
|
|
39
|
+
return (0, utils_1.deserializeNote)(raw);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Delete a note permanently. Resolves when deletion succeeds (204).
|
|
43
|
+
* @param noteId - ID of the note to delete (format: "note_...")
|
|
44
|
+
*/
|
|
45
|
+
async delete(noteId) {
|
|
46
|
+
await this.http.request("DELETE", `/notes/${encodeURIComponent(noteId)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.NotesResource = NotesResource;
|
|
50
|
+
//# sourceMappingURL=notes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.js","sourceRoot":"","sources":["../../../src/resources/notes.ts"],"names":[],"mappings":";;;AACA,oCAA2C;AAG3C;;GAEG;AACH,MAAa,aAAa;IACxB,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,uBAAe,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,IAAA,uBAAe,EAAC,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,IAAA,uBAAe,EAAC,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;AArDD,sCAqDC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScoringResource = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Resource class for scoring rule and lead score operations.
|
|
7
|
+
*/
|
|
8
|
+
class ScoringResource {
|
|
9
|
+
constructor(http) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List all scoring rules for this account.
|
|
14
|
+
*/
|
|
15
|
+
async listRules() {
|
|
16
|
+
const raw = await this.http.request("GET", "/scoring-rules");
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const r = raw;
|
|
19
|
+
return {
|
|
20
|
+
rules: (r.rules ?? []).map(utils_1.deserializeScoringRule),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a new scoring rule.
|
|
25
|
+
*/
|
|
26
|
+
async createRule(input) {
|
|
27
|
+
const raw = await this.http.request("POST", "/scoring-rules", { body: input });
|
|
28
|
+
return (0, utils_1.deserializeScoringRule)(raw);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve a single scoring rule by ID.
|
|
32
|
+
*/
|
|
33
|
+
async getRule(id) {
|
|
34
|
+
const raw = await this.http.request("GET", `/scoring-rules/${encodeURIComponent(id)}`);
|
|
35
|
+
return (0, utils_1.deserializeScoringRule)(raw);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Update a scoring rule. Only the supplied fields are changed.
|
|
39
|
+
*/
|
|
40
|
+
async updateRule(id, input) {
|
|
41
|
+
await this.http.request("PUT", `/scoring-rules/${encodeURIComponent(id)}`, {
|
|
42
|
+
body: input,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Delete a scoring rule.
|
|
47
|
+
*/
|
|
48
|
+
async deleteRule(id) {
|
|
49
|
+
await this.http.request("DELETE", `/scoring-rules/${encodeURIComponent(id)}`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Recalculate and persist the score for a single lead.
|
|
53
|
+
* Returns the new score value.
|
|
54
|
+
*/
|
|
55
|
+
async recalculate(leadId) {
|
|
56
|
+
const raw = await this.http.request("POST", `/leads/${encodeURIComponent(leadId)}/score`);
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
const r = raw;
|
|
59
|
+
return { id: r.id, score: r.score };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ScoringResource = ScoringResource;
|
|
63
|
+
//# sourceMappingURL=scoring.js.map
|