@kite-sa/sdk 0.7.0 → 0.9.2

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.
@@ -1,5 +1,10 @@
1
+ export interface AggregateLayerExportFilters {
2
+ city?: string[];
3
+ }
1
4
  export type CoverageFlag = "full" | "notary_only" | "incomplete";
2
5
  export declare const CoverageFlagValues: readonly ["full", "notary_only", "incomplete"];
6
+ export type DealSource = "moj_open_data" | "moj_notary" | "real_estate_registry";
7
+ export declare const DealSourceValues: readonly ["moj_open_data", "moj_notary", "real_estate_registry"];
3
8
  export interface Error {
4
9
  error: {
5
10
  type: "invalid_request" | "authentication_error" | "permission_error" | "not_found" | "method_not_allowed" | "conflict" | "rate_limit_error" | "api_error";
@@ -13,7 +18,7 @@ export interface Error {
13
18
  }
14
19
  export interface Export {
15
20
  id: string;
16
- dataset: "listings" | "listing_changes" | "registered_transactions" | "registered_rents";
21
+ dataset: "listings" | "listing_changes" | "registered_transactions" | "registered_rents" | "aggregate_layers";
17
22
  format: "ndjson" | "csv";
18
23
  compression: "gzip" | "none";
19
24
  status: "queued" | "running" | "completed" | "failed" | "expired";
@@ -67,6 +72,9 @@ export type ExportRequest = {
67
72
  filters?: RentExportFilters;
68
73
  format?: "ndjson" | "csv";
69
74
  compression?: "gzip" | "none";
75
+ } | {
76
+ dataset: "aggregate_layers";
77
+ filters?: AggregateLayerExportFilters;
70
78
  };
71
79
  export interface Listing {
72
80
  id: number;
@@ -120,12 +128,21 @@ export interface Listing {
120
128
  lng: number | null;
121
129
  street_width_m: number | null;
122
130
  };
131
+ plot: ListingPlot | null;
123
132
  compound_name: string | null;
124
133
  project_id: number | null;
125
134
  images: string[];
126
135
  image_count: number;
127
136
  advertiser: {
128
137
  type: string | null;
138
+ name: string | null;
139
+ name_en: string | null;
140
+ company: string | null;
141
+ logo: string | null;
142
+ fal_number: string | null;
143
+ cr: string | null;
144
+ ad_license: string | null;
145
+ contact_available: boolean;
129
146
  };
130
147
  verified_by_source: boolean | null;
131
148
  source: {
@@ -173,6 +190,53 @@ export interface ListingExportFilters {
173
190
  furnished?: boolean;
174
191
  updated_since?: string;
175
192
  }
193
+ export interface ListingPlot {
194
+ zoning: "residential" | "commercial" | "mixed" | "industrial" | "agricultural" | "public" | "other" | null;
195
+ is_corner: boolean | null;
196
+ frontage_count: number | null;
197
+ facing: "north" | "east" | "south" | "west"[];
198
+ street_width_m: number | null;
199
+ street_width_source: "official" | "measured" | null;
200
+ plot_area_sqm: number | null;
201
+ buildable_area_sqm: number | null;
202
+ buildable_far: number | null;
203
+ price_per_buildable_sqm_sar: number | null;
204
+ urban_growth_phase: string | null;
205
+ urban_growth_year: number | null;
206
+ white_land_fee: {
207
+ band: number | null;
208
+ rate_pct: number | null;
209
+ as_of: string | null;
210
+ } | null;
211
+ last_registered_sale: {
212
+ month: string;
213
+ price_sar: number;
214
+ price_per_sqm_sar: number | null;
215
+ area_sqm: number | null;
216
+ registry: "MOJ" | "Real Estate Registry";
217
+ areas_agree: boolean | null;
218
+ ask_to_last_sale_ratio: number | null;
219
+ months_since: number;
220
+ } | null;
221
+ registered_sale_while_listed: {
222
+ month: string;
223
+ price_sar: number;
224
+ registry: "MOJ" | "Real Estate Registry";
225
+ ask_at_sale_sar: number | null;
226
+ areas_agree: boolean;
227
+ deal_to_ask_ratio: number | null;
228
+ weeks_to_sell: number | null;
229
+ } | null;
230
+ registered_sales_count: number;
231
+ match: {
232
+ method: "plan_parcel_and_pin" | "plan_parcel_and_district";
233
+ confidence: number;
234
+ };
235
+ }
236
+ export type NeighborhoodTown = {
237
+ name_en: string;
238
+ name_ar: string;
239
+ } | null;
176
240
  export interface Pagination {
177
241
  limit: number;
178
242
  next_cursor: string | null;
@@ -188,17 +252,21 @@ export interface RentExportFilters {
188
252
  export interface Transaction {
189
253
  id: string;
190
254
  month: string;
191
- source_quarter: string;
255
+ source: DealSource;
256
+ source_quarter: string | null;
192
257
  city: string;
193
258
  city_name_ar: string | null;
194
259
  district_name_ar: string | null;
195
260
  neighborhood: TransactionNeighborhood | null;
196
261
  land_use: "residential" | "commercial" | "agricultural" | "industrial" | "mixed_use" | "other";
197
262
  land_use_ar: string | null;
263
+ land_use_basis: "moj_class" | "zoning";
264
+ property_type: "vacant_land" | "agricultural_land" | "apartment" | "floor" | "villa" | "house" | "residential_building" | "mixed_use_building" | "commercial" | "other" | null;
198
265
  area_sqm: number | null;
199
266
  price_sar: number;
200
267
  price_per_sqm_sar: number | null;
201
268
  property_count: number | null;
269
+ token_price: boolean;
202
270
  }
203
271
  export interface TransactionAttribution {
204
272
  notice: string;
@@ -220,6 +288,12 @@ export interface TransactionAttribution {
220
288
  url: string;
221
289
  }[];
222
290
  modifications: string;
291
+ other_sources: {
292
+ source: "moj_notary" | "real_estate_registry";
293
+ publisher: string;
294
+ title_en: string;
295
+ note: string;
296
+ }[];
223
297
  }
224
298
  export interface TransactionCoverage {
225
299
  city: string;
@@ -228,12 +302,15 @@ export interface TransactionCoverage {
228
302
  latest_quarter: string | null;
229
303
  complete_through_quarter: string | null;
230
304
  notary_only_from_quarter: string | null;
305
+ registry_sample_from_quarter: string | null;
231
306
  excluded_quarters: {
232
307
  quarter: string;
233
308
  reason: string;
234
309
  }[];
235
310
  notes: string[];
236
311
  }
312
+ export type TransactionCoverageFlag = "full" | "notary_only" | "incomplete" | "registry_sample";
313
+ export declare const TransactionCoverageFlagValues: readonly ["full", "notary_only", "incomplete", "registry_sample"];
237
314
  export interface TransactionExportFilters {
238
315
  city?: string[];
239
316
  land_use?: "residential" | "commercial" | "agricultural" | "industrial" | "mixed_use" | "other"[];
@@ -244,4 +321,97 @@ export interface TransactionNeighborhood {
244
321
  id: number;
245
322
  name_ar: string;
246
323
  name_en: string;
324
+ town: NeighborhoodTown;
325
+ }
326
+ export interface WebhookListingCreatedEvent {
327
+ id: string;
328
+ type: "listing.created";
329
+ created: string;
330
+ data: WebhookListingData;
331
+ test?: true;
332
+ }
333
+ export interface WebhookListingData {
334
+ listing_id: number;
335
+ city: string | null;
336
+ neighborhood_en: string | null;
337
+ neighborhood_ar: string | null;
338
+ listing_type: string | null;
339
+ listing_category: string | null;
340
+ property_type: string | null;
341
+ price_yearly_sar: number | null;
342
+ price_as_posted_sar: number | null;
343
+ rent_frequency: string | null;
344
+ bedrooms: number | null;
345
+ bathrooms: number | null;
346
+ area_sqm: number | null;
347
+ lat: number | null;
348
+ lng: number | null;
349
+ url: string;
350
+ }
351
+ export interface WebhookListingDelistedEvent {
352
+ id: string;
353
+ type: "listing.delisted";
354
+ created: string;
355
+ data: WebhookListingData;
356
+ test?: true;
357
+ }
358
+ export interface WebhookListingPriceChangedEvent {
359
+ id: string;
360
+ type: "listing.price_changed";
361
+ created: string;
362
+ data: WebhookPriceChangedListingData;
363
+ test?: true;
364
+ }
365
+ export interface WebhookListingRelistedEvent {
366
+ id: string;
367
+ type: "listing.relisted";
368
+ created: string;
369
+ data: WebhookListingData;
370
+ test?: true;
371
+ }
372
+ export interface WebhookListingUpdatedEvent {
373
+ id: string;
374
+ type: "listing.updated";
375
+ created: string;
376
+ data: WebhookUpdatedListingData;
377
+ test?: true;
378
+ }
379
+ export interface WebhookPriceChangedListingData {
380
+ listing_id: number;
381
+ city: string | null;
382
+ neighborhood_en: string | null;
383
+ neighborhood_ar: string | null;
384
+ listing_type: string | null;
385
+ listing_category: string | null;
386
+ property_type: string | null;
387
+ price_yearly_sar: number | null;
388
+ price_as_posted_sar: number | null;
389
+ rent_frequency: string | null;
390
+ bedrooms: number | null;
391
+ bathrooms: number | null;
392
+ area_sqm: number | null;
393
+ lat: number | null;
394
+ lng: number | null;
395
+ url: string;
396
+ previous_price_yearly_sar: number | null;
397
+ }
398
+ export interface WebhookUpdatedListingData {
399
+ listing_id: number;
400
+ city: string | null;
401
+ neighborhood_en: string | null;
402
+ neighborhood_ar: string | null;
403
+ listing_type: string | null;
404
+ listing_category: string | null;
405
+ property_type: string | null;
406
+ price_yearly_sar: number | null;
407
+ price_as_posted_sar: number | null;
408
+ rent_frequency: string | null;
409
+ bedrooms: number | null;
410
+ bathrooms: number | null;
411
+ area_sqm: number | null;
412
+ lat: number | null;
413
+ lng: number | null;
414
+ url: string;
415
+ changed_fields: string[];
416
+ previous_attributes: Record<string, unknown>;
247
417
  }
@@ -1,2 +1,9 @@
1
1
  // This file is auto-generated by openapi-zod-ts - do not edit
2
2
  export const CoverageFlagValues = ["full", "notary_only", "incomplete"];
3
+ export const DealSourceValues = ["moj_open_data", "moj_notary", "real_estate_registry"];
4
+ export const TransactionCoverageFlagValues = [
5
+ "full",
6
+ "notary_only",
7
+ "incomplete",
8
+ "registry_sample",
9
+ ];
package/dist/openapi.d.ts CHANGED
@@ -70,7 +70,7 @@ export interface operations {
70
70
  };
71
71
  "listings.search": {
72
72
  parameters: {
73
- query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").listingsSearch>[0]>>, "city" | "listing_type" | "listing_category" | "property_type" | "neighborhood_id" | "beds" | "beds_min" | "beds_max" | "bathrooms_min" | "price_min" | "price_max" | "area_min" | "area_max" | "furnished" | "source" | "bbox" | "updated_since" | "bathrooms" | "bathrooms_max" | "livings_min" | "neighborhood_id_exclude" | "q" | "amenities" | "amenities_exclude" | "photo_features" | "floor" | "source_exclude" | "max_age" | "verified" | "advertiser_type" | "compound" | "in_compound" | "rent_frequency" | "days_on_market_min" | "days_on_market_max" | "sort" | "limit" | "cursor">;
73
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").listingsSearch>[0]>>, "city" | "listing_type" | "listing_category" | "property_type" | "neighborhood_id" | "beds" | "beds_min" | "beds_max" | "bathrooms_min" | "price_min" | "price_max" | "area_min" | "area_max" | "furnished" | "source" | "bbox" | "updated_since" | "bathrooms" | "bathrooms_max" | "livings_min" | "neighborhood_id_exclude" | "q" | "amenities" | "amenities_exclude" | "photo_features" | "floor" | "source_exclude" | "max_age" | "verified" | "advertiser_type" | "compound" | "in_compound" | "rent_frequency" | "days_on_market_min" | "days_on_market_max" | "zoning" | "corner" | "street_width_min" | "white_land_fee" | "last_sale_within_months" | "ask_to_last_sale_max" | "plot_sold" | "sort" | "limit" | "cursor" | "updated_after_id">;
74
74
  };
75
75
  responses: {
76
76
  200: {
@@ -82,7 +82,7 @@ export interface operations {
82
82
  };
83
83
  "listings.count": {
84
84
  parameters: {
85
- query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").listingsCount>[0]>>, "city" | "listing_type" | "listing_category" | "property_type" | "neighborhood_id" | "beds" | "beds_min" | "beds_max" | "bathrooms_min" | "price_min" | "price_max" | "area_min" | "area_max" | "furnished" | "source" | "bbox" | "updated_since" | "bathrooms" | "bathrooms_max" | "livings_min" | "neighborhood_id_exclude" | "q" | "amenities" | "amenities_exclude" | "photo_features" | "floor" | "source_exclude" | "max_age" | "verified" | "advertiser_type" | "compound" | "in_compound" | "rent_frequency" | "days_on_market_min" | "days_on_market_max">;
85
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").listingsCount>[0]>>, "city" | "listing_type" | "listing_category" | "property_type" | "neighborhood_id" | "beds" | "beds_min" | "beds_max" | "bathrooms_min" | "price_min" | "price_max" | "area_min" | "area_max" | "furnished" | "source" | "bbox" | "updated_since" | "bathrooms" | "bathrooms_max" | "livings_min" | "neighborhood_id_exclude" | "q" | "amenities" | "amenities_exclude" | "photo_features" | "floor" | "source_exclude" | "max_age" | "verified" | "advertiser_type" | "compound" | "in_compound" | "rent_frequency" | "days_on_market_min" | "days_on_market_max" | "zoning" | "corner" | "street_width_min" | "white_land_fee" | "last_sale_within_months" | "ask_to_last_sale_max" | "plot_sold">;
86
86
  };
87
87
  responses: {
88
88
  200: {
@@ -124,6 +124,16 @@ export interface operations {
124
124
  };
125
125
  };
126
126
  };
127
+ "listings.contact": {
128
+ parameters: Record<never, never>;
129
+ responses: {
130
+ 200: {
131
+ content: {
132
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").listingsContact>>;
133
+ };
134
+ };
135
+ };
136
+ };
127
137
  "market.summary": {
128
138
  parameters: {
129
139
  query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketSummary>[0]>>, "city" | "listing_type" | "listing_category" | "property_type" | "beds" | "neighborhood_id">;
@@ -208,6 +218,42 @@ export interface operations {
208
218
  };
209
219
  };
210
220
  };
221
+ "market.land_resale": {
222
+ parameters: {
223
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketLandResale>[0]>>, "city" | "neighborhood_id" | "group_by" | "kind" | "min_sample_size">;
224
+ };
225
+ responses: {
226
+ 200: {
227
+ content: {
228
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").marketLandResale>>;
229
+ };
230
+ };
231
+ };
232
+ };
233
+ "market.ask_to_deal": {
234
+ parameters: {
235
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketAskToDeal>[0]>>, "city" | "neighborhood_id" | "group_by" | "kind" | "min_sample_size">;
236
+ };
237
+ responses: {
238
+ 200: {
239
+ content: {
240
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").marketAskToDeal>>;
241
+ };
242
+ };
243
+ };
244
+ };
245
+ "market.area_context": {
246
+ parameters: {
247
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketAreaContext>[0]>>, "lat" | "lng" | "radius_m" | "city" | "neighborhood_id">;
248
+ };
249
+ responses: {
250
+ 200: {
251
+ content: {
252
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").marketAreaContext>>;
253
+ };
254
+ };
255
+ };
256
+ };
211
257
  "official.registered_rents": {
212
258
  parameters: {
213
259
  query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").officialRegisteredRents>[0]>>, "city" | "neighborhood_id" | "property_type" | "period" | "min_sample_size">;
@@ -324,9 +370,33 @@ export interface operations {
324
370
  };
325
371
  };
326
372
  };
373
+ "analytics.advertisers": {
374
+ parameters: {
375
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").analyticsAdvertisers>[0]>>, "city" | "listing_type" | "listing_category" | "property_type" | "neighborhood_id" | "beds" | "beds_min" | "beds_max" | "bathrooms_min" | "price_min" | "price_max" | "area_min" | "area_max" | "furnished" | "source" | "bbox" | "updated_since" | "bathrooms" | "bathrooms_max" | "livings_min" | "neighborhood_id_exclude" | "q" | "amenities" | "amenities_exclude" | "photo_features" | "floor" | "source_exclude" | "max_age" | "verified" | "advertiser_type" | "compound" | "in_compound" | "rent_frequency" | "days_on_market_min" | "days_on_market_max" | "zoning" | "corner" | "street_width_min" | "white_land_fee" | "last_sale_within_months" | "ask_to_last_sale_max" | "plot_sold" | "above_median_pct" | "min_listings" | "sort" | "limit" | "cursor">;
376
+ };
377
+ responses: {
378
+ 200: {
379
+ content: {
380
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").analyticsAdvertisers>>;
381
+ };
382
+ };
383
+ };
384
+ };
385
+ "valuations.asking_range": {
386
+ parameters: {
387
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").valuationsAskingRange>[0]>>, "city" | "neighborhood_id" | "lat" | "lng" | "property_type" | "listing_type" | "bedrooms" | "area_sqm" | "furnished" | "age_years" | "floor" | "claimed_price">;
388
+ };
389
+ responses: {
390
+ 200: {
391
+ content: {
392
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").valuationsAskingRange>>;
393
+ };
394
+ };
395
+ };
396
+ };
327
397
  "transactions.search": {
328
398
  parameters: {
329
- query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").transactionsSearch>[0]>>, "city" | "neighborhood_id" | "land_use" | "month_from" | "month_to" | "price_min" | "price_max" | "area_min" | "area_max" | "price_per_sqm_min" | "price_per_sqm_max" | "sort" | "limit" | "cursor">;
399
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").transactionsSearch>[0]>>, "city" | "neighborhood_id" | "land_use" | "source" | "property_type" | "market_sales_only" | "month_from" | "month_to" | "price_min" | "price_max" | "area_min" | "area_max" | "price_per_sqm_min" | "price_per_sqm_max" | "sort" | "limit" | "cursor">;
330
400
  };
331
401
  responses: {
332
402
  200: {
@@ -338,7 +408,7 @@ export interface operations {
338
408
  };
339
409
  "market.transactions": {
340
410
  parameters: {
341
- query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketTransactions>[0]>>, "city" | "neighborhood_id" | "group_by" | "land_use" | "quarter_from" | "quarter_to" | "min_sample_size">;
411
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketTransactions>[0]>>, "city" | "neighborhood_id" | "group_by" | "land_use" | "property_type" | "quarter_from" | "quarter_to" | "min_sample_size" | "include_token_prices">;
342
412
  };
343
413
  responses: {
344
414
  200: {
@@ -350,7 +420,7 @@ export interface operations {
350
420
  };
351
421
  "market.land_prices": {
352
422
  parameters: {
353
- query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketLandPrices>[0]>>, "city" | "neighborhood_id" | "group_by" | "land_use" | "quarter_from" | "quarter_to" | "min_sample_size">;
423
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketLandPrices>[0]>>, "city" | "neighborhood_id" | "group_by" | "land_use" | "quarter_from" | "quarter_to" | "min_sample_size" | "include_token_prices">;
354
424
  };
355
425
  responses: {
356
426
  200: {
@@ -362,7 +432,7 @@ export interface operations {
362
432
  };
363
433
  "projects.search": {
364
434
  parameters: {
365
- query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").projectsSearch>[0]>>, "city" | "neighborhood_id" | "developer" | "status" | "project_type" | "listing_category" | "features" | "banks" | "q" | "price_min" | "price_max" | "sort" | "limit" | "cursor">;
435
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").projectsSearch>[0]>>, "city" | "neighborhood_id" | "developer" | "status" | "project_type" | "listing_category" | "features" | "banks" | "q" | "price_min" | "price_max" | "handover_from" | "handover_to" | "licensed" | "sort" | "limit" | "cursor">;
366
436
  };
367
437
  responses: {
368
438
  200: {
@@ -430,6 +500,30 @@ export interface operations {
430
500
  };
431
501
  };
432
502
  };
503
+ "projects.absorption": {
504
+ parameters: {
505
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").projectsAbsorption>[1]>>, "listing_type" | "from" | "to">;
506
+ };
507
+ responses: {
508
+ 200: {
509
+ content: {
510
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").projectsAbsorption>>;
511
+ };
512
+ };
513
+ };
514
+ };
515
+ "market.absorption": {
516
+ parameters: {
517
+ query?: Pick<SnakeKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").marketAbsorption>[0]>>, "city" | "neighborhood_id" | "developer" | "property_type" | "project_type" | "listing_type" | "group_by" | "from" | "to" | "min_sample_size">;
518
+ };
519
+ responses: {
520
+ 200: {
521
+ content: {
522
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").marketAbsorption>>;
523
+ };
524
+ };
525
+ };
526
+ };
433
527
  "exports.create": {
434
528
  parameters: {
435
529
  header?: Pick<HeaderKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").exportsCreate>[1]>>, "Idempotency-Key">;
@@ -683,5 +777,22 @@ export interface operations {
683
777
  };
684
778
  };
685
779
  };
780
+ "organization.webhooks.test": {
781
+ parameters: {
782
+ header?: Pick<HeaderKeys<NonNullable<Parameters<typeof import("./openapi-zod/client.js").organizationWebhooksTest>[2]>>, "Idempotency-Key">;
783
+ };
784
+ requestBody: {
785
+ content: {
786
+ "application/json": Parameters<typeof import("./openapi-zod/client.js").organizationWebhooksTest>[1];
787
+ };
788
+ };
789
+ responses: {
790
+ 200: {
791
+ content: {
792
+ "application/json": Awaited<ReturnType<typeof import("./openapi-zod/client.js").organizationWebhooksTest>>;
793
+ };
794
+ };
795
+ };
796
+ };
686
797
  }
687
798
  export {};
@@ -1,4 +1,4 @@
1
- /** The shape every cursor-paginated list endpoint returns. */
1
+ /** The standard array-shaped list response. */
2
2
  export interface Page<T> {
3
3
  data: T[];
4
4
  pagination: {
@@ -6,6 +6,13 @@ export interface Page<T> {
6
6
  next_cursor?: string | null;
7
7
  };
8
8
  }
9
+ /** Advertiser pages carry market totals alongside their advertiser rows. */
10
+ export type CursorPage<T> = Page<T> | {
11
+ data: {
12
+ advertisers: T[];
13
+ };
14
+ pagination: Page<T>["pagination"];
15
+ };
9
16
  /**
10
17
  * Yields every item of a cursor-paginated endpoint, fetching the next page only
11
18
  * when the previous one is consumed. `fetchPage` receives `params` plus the
@@ -13,6 +20,6 @@ export interface Page<T> {
13
20
  *
14
21
  * paginate((p) => kite.projects.units(42, p), { beds: 2 })
15
22
  */
16
- export declare function paginate<P extends {
23
+ export declare function paginate<const P extends object, T>(fetchPage: (params: P & {
17
24
  cursor?: string;
18
- }, T>(fetchPage: (params: P) => Promise<Page<T>>, params: Omit<P, "cursor">): AsyncGenerator<T>;
25
+ }) => Promise<CursorPage<T>>, params: P): AsyncGenerator<T>;
package/dist/paginate.js CHANGED
@@ -9,7 +9,7 @@ export async function* paginate(fetchPage, params) {
9
9
  let cursor;
10
10
  do {
11
11
  const page = await fetchPage({ ...params, cursor });
12
- yield* page.data;
12
+ yield* Array.isArray(page.data) ? page.data : page.data.advertisers;
13
13
  cursor = page.pagination.has_more ? (page.pagination.next_cursor ?? undefined) : undefined;
14
14
  } while (cursor);
15
15
  }
@@ -1,3 +1,10 @@
1
+ import type { WebhookListingCreatedEvent, WebhookListingDelistedEvent, WebhookListingPriceChangedEvent, WebhookListingRelistedEvent, WebhookListingUpdatedEvent } from "./openapi-zod/models.js";
2
+ export type { WebhookListingCreatedEvent, WebhookListingData, WebhookListingDelistedEvent, WebhookListingPriceChangedEvent, WebhookListingRelistedEvent, WebhookListingUpdatedEvent, WebhookPriceChangedListingData, WebhookUpdatedListingData, } from "./openapi-zod/models.js";
3
+ /** Any event Kite delivers, discriminated on `type`. */
4
+ export type WebhookEvent = WebhookListingCreatedEvent | WebhookListingPriceChangedEvent | WebhookListingUpdatedEvent | WebhookListingDelistedEvent | WebhookListingRelistedEvent;
5
+ export type WebhookEventType = WebhookEvent["type"];
6
+ /** Every event type this version of the SDK knows. */
7
+ export declare const WEBHOOK_EVENT_TYPES: readonly ["listing.created", "listing.price_changed", "listing.updated", "listing.delisted", "listing.relisted"];
1
8
  /**
2
9
  * Header Kite signs each webhook delivery with. Deliveries also carry the
3
10
  * deprecated `Darak-Signature` with the same value; either verifies.
@@ -29,3 +36,22 @@ export interface VerifyOptions {
29
36
  * main entry stays runtime-neutral.
30
37
  */
31
38
  export declare function verifyWebhookSignature(header: string | null | undefined, body: string, secret: string | readonly string[], options?: VerifyOptions): VerifyResult;
39
+ /**
40
+ * Thrown by `parseWebhookEvent`. `reason` is for your logs; never send it back
41
+ * to the caller.
42
+ */
43
+ export declare class WebhookError extends Error {
44
+ readonly reason: NonNullable<VerifyResult["reason"]> | "invalid_json" | "unknown_type";
45
+ constructor(reason: NonNullable<VerifyResult["reason"]> | "invalid_json" | "unknown_type", message: string);
46
+ }
47
+ /**
48
+ * Verifies a delivery with `verifyWebhookSignature` and returns its event,
49
+ * typed by `type`. Throws `WebhookError` when the signature doesn't verify,
50
+ * the body isn't a JSON event, or `type` is one this SDK doesn't know (a newer
51
+ * event type: answer 2xx and ignore it, or upgrade). Pass the raw body, before
52
+ * any JSON parsing.
53
+ *
54
+ * Test events carry `test: true`. Deliveries are at least once: deduplicate on
55
+ * `event.id`, which is also the `Kite-Event-Id` header.
56
+ */
57
+ export declare function parseWebhookEvent(header: string | null | undefined, body: string, secret: string | readonly string[], options?: VerifyOptions): WebhookEvent;
package/dist/webhooks.js CHANGED
@@ -1,4 +1,12 @@
1
1
  import { createHmac, timingSafeEqual } from "node:crypto";
2
+ /** Every event type this version of the SDK knows. */
3
+ export const WEBHOOK_EVENT_TYPES = [
4
+ "listing.created",
5
+ "listing.price_changed",
6
+ "listing.updated",
7
+ "listing.delisted",
8
+ "listing.relisted",
9
+ ];
2
10
  /**
3
11
  * Header Kite signs each webhook delivery with. Deliveries also carry the
4
12
  * deprecated `Darak-Signature` with the same value; either verifies.
@@ -47,3 +55,52 @@ export function verifyWebhookSignature(header, body, secret, options = {}) {
47
55
  });
48
56
  return matches ? { valid: true } : { valid: false, reason: "no_match" };
49
57
  }
58
+ /**
59
+ * Thrown by `parseWebhookEvent`. `reason` is for your logs; never send it back
60
+ * to the caller.
61
+ */
62
+ export class WebhookError extends Error {
63
+ reason;
64
+ constructor(reason, message) {
65
+ super(message);
66
+ this.reason = reason;
67
+ this.name = "WebhookError";
68
+ }
69
+ }
70
+ /**
71
+ * Verifies a delivery with `verifyWebhookSignature` and returns its event,
72
+ * typed by `type`. Throws `WebhookError` when the signature doesn't verify,
73
+ * the body isn't a JSON event, or `type` is one this SDK doesn't know (a newer
74
+ * event type: answer 2xx and ignore it, or upgrade). Pass the raw body, before
75
+ * any JSON parsing.
76
+ *
77
+ * Test events carry `test: true`. Deliveries are at least once: deduplicate on
78
+ * `event.id`, which is also the `Kite-Event-Id` header.
79
+ */
80
+ export function parseWebhookEvent(header, body, secret, options = {}) {
81
+ const result = verifyWebhookSignature(header, body, secret, options);
82
+ if (!result.valid) {
83
+ const reason = result.reason ?? "no_match";
84
+ throw new WebhookError(reason, `Invalid webhook signature (${reason}).`);
85
+ }
86
+ let event;
87
+ try {
88
+ event = JSON.parse(body);
89
+ }
90
+ catch {
91
+ throw new WebhookError("invalid_json", "Webhook body is not valid JSON.");
92
+ }
93
+ if (!event ||
94
+ typeof event !== "object" ||
95
+ Array.isArray(event) ||
96
+ !("data" in event) ||
97
+ !event.data ||
98
+ typeof event.data !== "object") {
99
+ throw new WebhookError("invalid_json", "Webhook body is not an event object.");
100
+ }
101
+ const type = event.type;
102
+ if (!WEBHOOK_EVENT_TYPES.includes(type)) {
103
+ throw new WebhookError("unknown_type", `Unknown webhook event type: ${String(type)}.`);
104
+ }
105
+ return event;
106
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kite-sa/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.9.2",
4
4
  "description": "Official JavaScript/TypeScript client for the Kite API: Saudi real-estate listings and market data.",
5
5
  "license": "MIT",
6
6
  "type": "module",