@stack0/sdk 0.5.9 → 0.5.12

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/dist/index.js CHANGED
@@ -420,6 +420,69 @@ var Events = class {
420
420
  }
421
421
  };
422
422
 
423
+ // src/mail/mailboxes.ts
424
+ var Mailboxes = class {
425
+ constructor(http) {
426
+ this.http = http;
427
+ }
428
+ /**
429
+ * Create a new mailbox
430
+ */
431
+ async create(request) {
432
+ return this.http.post("/mail/mailboxes", request);
433
+ }
434
+ /**
435
+ * Get a mailbox by ID
436
+ */
437
+ async get(id) {
438
+ return this.http.get(`/mail/mailboxes/${id}`);
439
+ }
440
+ /**
441
+ * List mailboxes with optional filters
442
+ */
443
+ async list(request) {
444
+ const params = new URLSearchParams();
445
+ if (request?.projectSlug) params.set("projectSlug", request.projectSlug);
446
+ if (request?.environment) params.set("environment", request.environment);
447
+ if (request?.domain) params.set("domain", request.domain);
448
+ if (request?.status) params.set("status", request.status);
449
+ if (request?.limit) params.set("limit", String(request.limit));
450
+ if (request?.cursor) params.set("cursor", request.cursor);
451
+ const qs = params.toString();
452
+ return this.http.get(`/mail/mailboxes${qs ? `?${qs}` : ""}`);
453
+ }
454
+ /**
455
+ * Update a mailbox
456
+ */
457
+ async update(request) {
458
+ const { id, ...data } = request;
459
+ return this.http.patch(`/mail/mailboxes/${id}`, data);
460
+ }
461
+ /**
462
+ * Delete a mailbox
463
+ */
464
+ async delete(id) {
465
+ return this.http.delete(`/mail/mailboxes/${id}`);
466
+ }
467
+ /**
468
+ * List inbound messages across mailboxes
469
+ */
470
+ async listMessages(request) {
471
+ const params = new URLSearchParams();
472
+ if (request?.mailboxId) params.set("mailboxId", request.mailboxId);
473
+ if (request?.limit) params.set("limit", String(request.limit));
474
+ if (request?.cursor) params.set("cursor", request.cursor);
475
+ const qs = params.toString();
476
+ return this.http.get(`/mail/mailboxes/messages${qs ? `?${qs}` : ""}`);
477
+ }
478
+ /**
479
+ * Get an inbound message by ID
480
+ */
481
+ async getMessage(id) {
482
+ return this.http.get(`/mail/mailboxes/messages/${id}`);
483
+ }
484
+ };
485
+
423
486
  // src/mail/sequences.ts
424
487
  var Sequences = class {
425
488
  constructor(http) {
@@ -702,6 +765,8 @@ var Mail = class {
702
765
  sequences;
703
766
  /** Track and manage custom events */
704
767
  events;
768
+ /** Manage agent mailboxes */
769
+ mailboxes;
705
770
  constructor(config) {
706
771
  this.http = new HttpClient(config);
707
772
  this.domains = new Domains(this.http);
@@ -711,6 +776,7 @@ var Mail = class {
711
776
  this.campaigns = new Campaigns(this.http);
712
777
  this.sequences = new Sequences(this.http);
713
778
  this.events = new Events(this.http);
779
+ this.mailboxes = new Mailboxes(this.http);
714
780
  }
715
781
  // ============================================================================
716
782
  // TRANSACTIONAL EMAILS
@@ -3603,6 +3669,232 @@ var Webdata = class {
3603
3669
  }
3604
3670
  };
3605
3671
 
3672
+ // src/crawl/client.ts
3673
+ var Crawl$ = class {
3674
+ http;
3675
+ constructor(config) {
3676
+ this.http = new HttpClient(config);
3677
+ }
3678
+ /**
3679
+ * Start a crawl.
3680
+ *
3681
+ * @example
3682
+ * ```typescript
3683
+ * const { id } = await stack0.crawl.start({
3684
+ * url: 'https://docs.example.com',
3685
+ * maxDepth: 3,
3686
+ * maxPages: 200,
3687
+ * formats: ['markdown', 'links'],
3688
+ * });
3689
+ * ```
3690
+ */
3691
+ async start(request) {
3692
+ return this.http.post("/webdata/crawl", request);
3693
+ }
3694
+ /**
3695
+ * Get a crawl by ID. Pass `includePages: true` to include the scraped pages.
3696
+ */
3697
+ async get(request) {
3698
+ const params = new URLSearchParams();
3699
+ if (request.environment) params.set("environment", request.environment);
3700
+ if (request.projectId) params.set("projectId", request.projectId);
3701
+ if (request.includePages) params.set("includePages", "true");
3702
+ const query = params.toString();
3703
+ return this.http.get(`/webdata/crawl/${request.id}${query ? `?${query}` : ""}`);
3704
+ }
3705
+ async list(request = {}) {
3706
+ const params = new URLSearchParams();
3707
+ if (request.environment) params.set("environment", request.environment);
3708
+ if (request.projectId) params.set("projectId", request.projectId);
3709
+ if (request.status) params.set("status", request.status);
3710
+ if (request.url) params.set("url", request.url);
3711
+ if (request.limit) params.set("limit", String(request.limit));
3712
+ if (request.cursor) params.set("cursor", request.cursor);
3713
+ const query = params.toString();
3714
+ return this.http.get(`/webdata/crawl${query ? `?${query}` : ""}`);
3715
+ }
3716
+ async listPages(request) {
3717
+ const params = new URLSearchParams();
3718
+ if (request.environment) params.set("environment", request.environment);
3719
+ if (request.projectId) params.set("projectId", request.projectId);
3720
+ if (request.limit) params.set("limit", String(request.limit));
3721
+ if (request.cursor) params.set("cursor", request.cursor);
3722
+ const query = params.toString();
3723
+ return this.http.get(
3724
+ `/webdata/crawl/${request.crawlId}/pages${query ? `?${query}` : ""}`
3725
+ );
3726
+ }
3727
+ async cancel(request) {
3728
+ return this.http.post(`/webdata/crawl/${request.id}/cancel`, {
3729
+ environment: request.environment,
3730
+ projectId: request.projectId
3731
+ });
3732
+ }
3733
+ async delete(request) {
3734
+ const params = new URLSearchParams();
3735
+ if (request.environment) params.set("environment", request.environment);
3736
+ if (request.projectId) params.set("projectId", request.projectId);
3737
+ const query = params.toString();
3738
+ return this.http.deleteWithBody(
3739
+ `/webdata/crawl/${request.id}${query ? `?${query}` : ""}`,
3740
+ request
3741
+ );
3742
+ }
3743
+ /**
3744
+ * Start a crawl and poll until it completes. Returns the full Crawl record
3745
+ * with pages included.
3746
+ */
3747
+ async startAndWait(request, options = {}) {
3748
+ const { pollInterval = 2e3, timeout = 6e5, includePages = true } = options;
3749
+ const { id } = await this.start(request);
3750
+ const start = Date.now();
3751
+ while (Date.now() - start < timeout) {
3752
+ const crawl = await this.get({
3753
+ id,
3754
+ environment: request.environment,
3755
+ projectId: request.projectId,
3756
+ includePages
3757
+ });
3758
+ if (crawl.status === "completed" || crawl.status === "failed" || crawl.status === "cancelled") {
3759
+ if (crawl.status === "failed") throw new Error(crawl.error || "Crawl failed");
3760
+ return crawl;
3761
+ }
3762
+ await new Promise((r) => setTimeout(r, pollInterval));
3763
+ }
3764
+ throw new Error("Crawl timed out");
3765
+ }
3766
+ };
3767
+
3768
+ // src/map/client.ts
3769
+ var Map$ = class {
3770
+ http;
3771
+ constructor(config) {
3772
+ this.http = new HttpClient(config);
3773
+ }
3774
+ /**
3775
+ * Start a map job.
3776
+ *
3777
+ * @example
3778
+ * ```typescript
3779
+ * const { id } = await stack0.map.create({
3780
+ * url: 'https://docs.example.com',
3781
+ * search: 'api',
3782
+ * limit: 1000,
3783
+ * });
3784
+ * ```
3785
+ */
3786
+ async create(request) {
3787
+ return this.http.post("/webdata/map", request);
3788
+ }
3789
+ async get(request) {
3790
+ const params = new URLSearchParams();
3791
+ if (request.environment) params.set("environment", request.environment);
3792
+ if (request.projectId) params.set("projectId", request.projectId);
3793
+ const query = params.toString();
3794
+ return this.http.get(`/webdata/map/${request.id}${query ? `?${query}` : ""}`);
3795
+ }
3796
+ async list(request = {}) {
3797
+ const params = new URLSearchParams();
3798
+ if (request.environment) params.set("environment", request.environment);
3799
+ if (request.projectId) params.set("projectId", request.projectId);
3800
+ if (request.status) params.set("status", request.status);
3801
+ if (request.limit) params.set("limit", String(request.limit));
3802
+ if (request.cursor) params.set("cursor", request.cursor);
3803
+ const query = params.toString();
3804
+ return this.http.get(`/webdata/map${query ? `?${query}` : ""}`);
3805
+ }
3806
+ async delete(request) {
3807
+ const params = new URLSearchParams();
3808
+ if (request.environment) params.set("environment", request.environment);
3809
+ if (request.projectId) params.set("projectId", request.projectId);
3810
+ const query = params.toString();
3811
+ return this.http.deleteWithBody(
3812
+ `/webdata/map/${request.id}${query ? `?${query}` : ""}`,
3813
+ request
3814
+ );
3815
+ }
3816
+ /**
3817
+ * Create a map job and poll until it completes. Maps usually finish in
3818
+ * seconds, so default timeout is generous.
3819
+ */
3820
+ async createAndWait(request, options = {}) {
3821
+ const { pollInterval = 1e3, timeout = 12e4 } = options;
3822
+ const { id } = await this.create(request);
3823
+ const start = Date.now();
3824
+ while (Date.now() - start < timeout) {
3825
+ const result = await this.get({ id, environment: request.environment, projectId: request.projectId });
3826
+ if (result.status === "completed" || result.status === "failed") {
3827
+ if (result.status === "failed") throw new Error(result.error || "Map failed");
3828
+ return result;
3829
+ }
3830
+ await new Promise((r) => setTimeout(r, pollInterval));
3831
+ }
3832
+ throw new Error("Map timed out");
3833
+ }
3834
+ };
3835
+
3836
+ // src/documents/client.ts
3837
+ var Documents = class {
3838
+ http;
3839
+ constructor(config) {
3840
+ this.http = new HttpClient(config);
3841
+ }
3842
+ /**
3843
+ * Parse a document from a URL or a previously-uploaded file URL.
3844
+ *
3845
+ * @example
3846
+ * ```typescript
3847
+ * const { id } = await stack0.documents.parse({
3848
+ * url: 'https://example.com/whitepaper.pdf',
3849
+ * });
3850
+ * ```
3851
+ */
3852
+ async parse(request) {
3853
+ return this.http.post("/webdata/documents", request);
3854
+ }
3855
+ async get(request) {
3856
+ const params = new URLSearchParams();
3857
+ if (request.environment) params.set("environment", request.environment);
3858
+ if (request.projectId) params.set("projectId", request.projectId);
3859
+ const q = params.toString();
3860
+ return this.http.get(`/webdata/documents/${request.id}${q ? `?${q}` : ""}`);
3861
+ }
3862
+ async list(request = {}) {
3863
+ const params = new URLSearchParams();
3864
+ if (request.environment) params.set("environment", request.environment);
3865
+ if (request.projectId) params.set("projectId", request.projectId);
3866
+ if (request.status) params.set("status", request.status);
3867
+ if (request.limit) params.set("limit", String(request.limit));
3868
+ if (request.cursor) params.set("cursor", request.cursor);
3869
+ const q = params.toString();
3870
+ return this.http.get(`/webdata/documents${q ? `?${q}` : ""}`);
3871
+ }
3872
+ async delete(request) {
3873
+ const params = new URLSearchParams();
3874
+ if (request.environment) params.set("environment", request.environment);
3875
+ if (request.projectId) params.set("projectId", request.projectId);
3876
+ const q = params.toString();
3877
+ return this.http.deleteWithBody(
3878
+ `/webdata/documents/${request.id}${q ? `?${q}` : ""}`,
3879
+ request
3880
+ );
3881
+ }
3882
+ async parseAndWait(request, options = {}) {
3883
+ const { pollInterval = 2e3, timeout = 18e4 } = options;
3884
+ const { id } = await this.parse(request);
3885
+ const start = Date.now();
3886
+ while (Date.now() - start < timeout) {
3887
+ const doc = await this.get({ id, environment: request.environment, projectId: request.projectId });
3888
+ if (doc.status === "completed" || doc.status === "failed") {
3889
+ if (doc.status === "failed") throw new Error(doc.error || "Document parsing failed");
3890
+ return doc;
3891
+ }
3892
+ await new Promise((r) => setTimeout(r, pollInterval));
3893
+ }
3894
+ throw new Error("Document parsing timed out");
3895
+ }
3896
+ };
3897
+
3606
3898
  // src/integrations/client.ts
3607
3899
  var CRM = class {
3608
3900
  http;
@@ -3826,18 +4118,104 @@ var Productivity = class {
3826
4118
  return this.http.delete(`/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`);
3827
4119
  }
3828
4120
  };
4121
+ var CalendarClient = class {
4122
+ http;
4123
+ constructor(http) {
4124
+ this.http = http;
4125
+ }
4126
+ async listCalendars(connectionId, options) {
4127
+ const params = new URLSearchParams({ connectionId });
4128
+ if (options?.cursor) params.set("cursor", options.cursor);
4129
+ if (options?.limit) params.set("limit", String(options.limit));
4130
+ return this.http.get(`/integrations/calendar/calendars?${params}`);
4131
+ }
4132
+ async listEvents(connectionId, calendarId, options) {
4133
+ const params = new URLSearchParams({ connectionId, calendarId });
4134
+ if (options?.cursor) params.set("cursor", options.cursor);
4135
+ if (options?.limit) params.set("limit", String(options.limit));
4136
+ if (options?.timeMin) params.set("timeMin", options.timeMin.toISOString());
4137
+ if (options?.timeMax) params.set("timeMax", options.timeMax.toISOString());
4138
+ if (options?.query) params.set("query", options.query);
4139
+ return this.http.get(`/integrations/calendar/events?${params}`);
4140
+ }
4141
+ async getEvent(connectionId, calendarId, eventId) {
4142
+ return this.http.get(
4143
+ `/integrations/calendar/events/${eventId}?connectionId=${connectionId}&calendarId=${calendarId}`
4144
+ );
4145
+ }
4146
+ async createEvent(connectionId, calendarId, data) {
4147
+ return this.http.post("/integrations/calendar/events", { connectionId, calendarId, data });
4148
+ }
4149
+ async updateEvent(connectionId, calendarId, eventId, data) {
4150
+ return this.http.patch(`/integrations/calendar/events/${eventId}`, { connectionId, calendarId, data });
4151
+ }
4152
+ async deleteEvent(connectionId, calendarId, eventId) {
4153
+ return this.http.delete(
4154
+ `/integrations/calendar/events/${eventId}?connectionId=${connectionId}&calendarId=${calendarId}`
4155
+ );
4156
+ }
4157
+ };
4158
+ var Mail2 = class {
4159
+ http;
4160
+ constructor(http) {
4161
+ this.http = http;
4162
+ }
4163
+ async listMessages(connectionId, options) {
4164
+ const params = new URLSearchParams({ connectionId });
4165
+ if (options?.cursor) params.set("cursor", options.cursor);
4166
+ if (options?.limit) params.set("limit", String(options.limit));
4167
+ if (options?.query) params.set("query", options.query);
4168
+ if (options?.labelIds) {
4169
+ for (const labelId of options.labelIds) {
4170
+ params.append("labelIds", labelId);
4171
+ }
4172
+ }
4173
+ return this.http.get(`/integrations/email/messages?${params}`);
4174
+ }
4175
+ async getMessage(connectionId, messageId) {
4176
+ return this.http.get(`/integrations/email/messages/${messageId}?connectionId=${connectionId}`);
4177
+ }
4178
+ async sendMessage(connectionId, data) {
4179
+ return this.http.post("/integrations/email/messages/send", { connectionId, data });
4180
+ }
4181
+ async listThreads(connectionId, options) {
4182
+ const params = new URLSearchParams({ connectionId });
4183
+ if (options?.cursor) params.set("cursor", options.cursor);
4184
+ if (options?.limit) params.set("limit", String(options.limit));
4185
+ if (options?.query) params.set("query", options.query);
4186
+ if (options?.labelIds) {
4187
+ for (const labelId of options.labelIds) {
4188
+ params.append("labelIds", labelId);
4189
+ }
4190
+ }
4191
+ return this.http.get(`/integrations/email/threads?${params}`);
4192
+ }
4193
+ async getThread(connectionId, threadId) {
4194
+ return this.http.get(`/integrations/email/threads/${threadId}?connectionId=${connectionId}`);
4195
+ }
4196
+ async listLabels(connectionId) {
4197
+ const result = await this.http.get(
4198
+ `/integrations/email/labels?connectionId=${connectionId}`
4199
+ );
4200
+ return result.labels;
4201
+ }
4202
+ };
3829
4203
  var Integrations = class {
3830
4204
  http;
3831
4205
  crm;
3832
4206
  storage;
3833
4207
  communication;
3834
4208
  productivity;
4209
+ calendar;
4210
+ mail;
3835
4211
  constructor(config) {
3836
4212
  this.http = new HttpClient(config);
3837
4213
  this.crm = new CRM(this.http);
3838
4214
  this.storage = new Storage(this.http);
3839
4215
  this.communication = new Communication(this.http);
3840
4216
  this.productivity = new Productivity(this.http);
4217
+ this.calendar = new CalendarClient(this.http);
4218
+ this.mail = new Mail2(this.http);
3841
4219
  }
3842
4220
  // ============================================================================
3843
4221
  // CONNECTORS
@@ -3875,6 +4253,7 @@ var Integrations = class {
3875
4253
  if (request?.environment) params.set("environment", request.environment);
3876
4254
  if (request?.connectorSlug) params.set("connectorSlug", request.connectorSlug);
3877
4255
  if (request?.status) params.set("status", request.status);
4256
+ if (request?.endUserId) params.set("endUserId", request.endUserId);
3878
4257
  if (request?.limit) params.set("limit", request.limit.toString());
3879
4258
  const queryString = params.toString();
3880
4259
  const response = await this.http.get(
@@ -3908,6 +4287,22 @@ var Integrations = class {
3908
4287
  async initiateOAuth(request) {
3909
4288
  return this.http.post("/integrations/connections/oauth/initiate", request);
3910
4289
  }
4290
+ /**
4291
+ * Create a connection session for an end user
4292
+ *
4293
+ * @example
4294
+ * ```typescript
4295
+ * const { authUrl, sessionId } = await integrations.createConnectionSession({
4296
+ * endUserId: 'user_123',
4297
+ * connectorSlug: 'google-calendar',
4298
+ * redirectUrl: 'https://yourapp.com/oauth/callback',
4299
+ * });
4300
+ * // Redirect user to authUrl
4301
+ * ```
4302
+ */
4303
+ async createConnectionSession(request) {
4304
+ return this.http.post("/integrations/connections/session", request);
4305
+ }
3911
4306
  /**
3912
4307
  * Complete OAuth flow with callback data
3913
4308
  *
@@ -5371,10 +5766,14 @@ var Memory = class {
5371
5766
 
5372
5767
  // src/index.ts
5373
5768
  var Stack0 = class {
5769
+ http;
5374
5770
  mail;
5375
5771
  cdn;
5376
5772
  screenshots;
5377
5773
  extraction;
5774
+ crawl;
5775
+ map;
5776
+ documents;
5378
5777
  integrations;
5379
5778
  marketing;
5380
5779
  workflows;
@@ -5388,16 +5787,42 @@ var Stack0 = class {
5388
5787
  apiKey: config.apiKey,
5389
5788
  baseUrl: config.baseUrl
5390
5789
  };
5790
+ this.http = new HttpClient(clientConfig);
5391
5791
  this.mail = new Mail(clientConfig);
5392
5792
  this.cdn = new CDN(clientConfig, config.cdnUrl);
5393
5793
  this.screenshots = new Screenshots(clientConfig);
5394
5794
  this.extraction = new Extraction(clientConfig);
5795
+ this.crawl = new Crawl$(clientConfig);
5796
+ this.map = new Map$(clientConfig);
5797
+ this.documents = new Documents(clientConfig);
5395
5798
  this.integrations = new Integrations(clientConfig);
5396
5799
  this.marketing = new Marketing(clientConfig);
5397
5800
  this.workflows = new Workflows(clientConfig);
5398
5801
  this.memory = new Memory(clientConfig);
5399
5802
  this.webdata = new Webdata(clientConfig);
5400
5803
  }
5804
+ // ============================================================================
5805
+ // PROJECTS
5806
+ // ============================================================================
5807
+ async listProjects() {
5808
+ return this.http.get("/projects");
5809
+ }
5810
+ async getProject(id) {
5811
+ return this.http.get(`/projects/${id}`);
5812
+ }
5813
+ async getProjectBySlug(slug) {
5814
+ return this.http.get(`/projects/by-slug/${slug}`);
5815
+ }
5816
+ async createProject(request) {
5817
+ return this.http.post("/projects", request);
5818
+ }
5819
+ async updateProject(request) {
5820
+ const { id, ...data } = request;
5821
+ return this.http.patch(`/projects/${id}`, data);
5822
+ }
5823
+ async deleteProject(id) {
5824
+ return this.http.delete(`/projects/${id}`);
5825
+ }
5401
5826
  };
5402
5827
  var src_default = Stack0;
5403
5828
 
@@ -5405,11 +5830,17 @@ exports.Audiences = Audiences;
5405
5830
  exports.CDN = CDN;
5406
5831
  exports.Campaigns = Campaigns;
5407
5832
  exports.Contacts = Contacts;
5833
+ exports.Crawl = Crawl$;
5834
+ exports.Crawl$ = Crawl$;
5835
+ exports.Documents = Documents;
5408
5836
  exports.Domains = Domains;
5409
5837
  exports.Events = Events;
5410
5838
  exports.Extraction = Extraction;
5411
5839
  exports.Integrations = Integrations;
5412
5840
  exports.Mail = Mail;
5841
+ exports.Mailboxes = Mailboxes;
5842
+ exports.Map = Map$;
5843
+ exports.Map$ = Map$;
5413
5844
  exports.Marketing = Marketing;
5414
5845
  exports.Memory = Memory;
5415
5846
  exports.MemoryAgents = MemoryAgents;