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