sproutkit-code 0.5.0 → 0.5.1

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 (2) hide show
  1. package/dist/index.js +32 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -80617,33 +80617,43 @@ var require_places = __commonJS({
80617
80617
  return Math.max(0, Math.round(score));
80618
80618
  }
80619
80619
  var COST_PER_REQUEST_GBP = 0.025;
80620
- async function searchPlaces(args) {
80621
- const results = [];
80622
- const seen = /* @__PURE__ */ new Set();
80623
- for (const type of args.types) {
80624
- if (results.length >= args.maxResults)
80625
- break;
80626
- const body = {
80627
- textQuery: `${type} in ${args.city}`,
80628
- maxResultCount: 20
80620
+ async function searchOneType(args) {
80621
+ const body = {
80622
+ textQuery: `${args.type} in ${args.city}`,
80623
+ maxResultCount: 20
80624
+ };
80625
+ if (args.center && args.radiusMeters) {
80626
+ body.locationBias = {
80627
+ circle: {
80628
+ center: { latitude: args.center.lat, longitude: args.center.lng },
80629
+ radius: args.radiusMeters
80630
+ }
80629
80631
  };
80630
- if (args.center && args.radiusMeters) {
80631
- body.locationBias = {
80632
- circle: {
80633
- center: { latitude: args.center.lat, longitude: args.center.lng },
80634
- radius: args.radiusMeters
80635
- }
80636
- };
80637
- }
80632
+ }
80633
+ try {
80638
80634
  const r = await axios_1.default.post("https://places.googleapis.com/v1/places:searchText", body, {
80639
80635
  headers: {
80640
80636
  "X-Goog-Api-Key": args.apiKey,
80641
80637
  "X-Goog-FieldMask": "places.id,places.displayName,places.formattedAddress,places.nationalPhoneNumber,places.websiteUri,places.rating,places.userRatingCount,places.location,places.priceLevel,places.businessStatus,places.regularOpeningHours"
80642
80638
  }
80643
80639
  });
80644
- for (const p of r.data.places ?? []) {
80645
- if (results.length >= args.maxResults)
80646
- break;
80640
+ return { type: args.type, places: r.data.places ?? [] };
80641
+ } catch {
80642
+ return { type: args.type, places: [] };
80643
+ }
80644
+ }
80645
+ async function searchPlaces(args) {
80646
+ const batches = await Promise.all(args.types.map((type) => searchOneType({
80647
+ apiKey: args.apiKey,
80648
+ city: args.city,
80649
+ type,
80650
+ center: args.center,
80651
+ radiusMeters: args.radiusMeters
80652
+ })));
80653
+ const results = [];
80654
+ const seen = /* @__PURE__ */ new Set();
80655
+ for (const { type, places } of batches) {
80656
+ for (const p of places) {
80647
80657
  if (seen.has(p.id))
80648
80658
  continue;
80649
80659
  seen.add(p.id);
@@ -80687,7 +80697,7 @@ var require_places = __commonJS({
80687
80697
  }
80688
80698
  }
80689
80699
  results.sort((a, b) => b.score - a.score);
80690
- return results;
80700
+ return results.slice(0, args.maxResults);
80691
80701
  }
80692
80702
  function haversineMeters(lat1, lon1, lat2, lon2) {
80693
80703
  const R = 6371e3;
@@ -82272,7 +82282,7 @@ var require_package = __commonJS({
82272
82282
  "package.json"(exports2, module2) {
82273
82283
  module2.exports = {
82274
82284
  name: "sproutkit-code",
82275
- version: "0.5.0",
82285
+ version: "0.5.1",
82276
82286
  description: "Sproutkit in your terminal \u2014 find leads, build sites, run outreach, all via chat.",
82277
82287
  bin: {
82278
82288
  sproutkit: "./dist/index.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sproutkit-code",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Sproutkit in your terminal — find leads, build sites, run outreach, all via chat.",
5
5
  "bin": {
6
6
  "sproutkit": "./dist/index.js"