@vibiz/app 0.3.21 → 0.3.23

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.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  * const { url } = await vibiz.files.upload(bytes, { name: 'avatar.png' });
10
10
  * await vibiz.contacts.upsert({ email, first_name, lists: ['Users'] }); // newsletters, onboarding
11
11
  * await vibiz.contacts.track(email, 'upgraded', { plan: 'pro' }); // starts automations
12
+ * const { url } = await vibiz.user(userId).social.connect({ platform: 'threads', return_url });
12
13
  *
13
14
  * The key (`VIBIZ_APP_KEY`, `vz_app_…`) belongs to one project and one
14
15
  * environment. It is a server secret: this client refuses to run in a
@@ -394,6 +395,86 @@ export interface PhoneCall {
394
395
  price_usd: number;
395
396
  created_at: string;
396
397
  }
398
+ /** A platform a user can connect (docs: social). */
399
+ export type SocialPlatform = 'instagram' | 'facebook' | 'tiktok' | 'linkedin' | 'x' | 'youtube' | 'pinterest' | 'threads' | 'bluesky' | 'reddit' | 'google_business' | 'telegram';
400
+ /** One of your user's own social accounts (`vibiz.user(id).social`). */
401
+ export interface SocialUserAccount {
402
+ object: 'social_account';
403
+ id: string;
404
+ project_id: string;
405
+ environment: 'production' | 'development';
406
+ platform: SocialPlatform;
407
+ kind: 'social';
408
+ status: 'connected' | 'needs_reconnect' | 'disconnected';
409
+ username: string | null;
410
+ display_name: string | null;
411
+ avatar_url: string | null;
412
+ profile_url: string | null;
413
+ details: Record<string, unknown>;
414
+ connected_at: string;
415
+ /** Your user's id, as you sent it. */
416
+ user_id: string;
417
+ }
418
+ /** Where to send your user to connect an account (`social.connect`). */
419
+ export interface SocialConnectLink {
420
+ object: 'social_connect_link';
421
+ platform: SocialPlatform;
422
+ environment: 'production' | 'development';
423
+ /**
424
+ * Production: a thelastapi link (one hour, single use) that goes straight to the
425
+ * platform's sign-in, then back to your `return_url` with `?account_id=…&status=connected`
426
+ * (or `status=failed&error=…`). Development: your `return_url` with the test account already.
427
+ */
428
+ url: string;
429
+ expires_at: string;
430
+ /** Development only: the test account, made at once. */
431
+ account?: SocialUserAccount;
432
+ }
433
+ export interface SocialUserPostInput {
434
+ text?: string;
435
+ /** Your user's own account ids (`sacc_…`), 1–20. */
436
+ account_ids: string[];
437
+ /** Any public https URL, or one from `social.upload`. */
438
+ media?: Array<{
439
+ url: string;
440
+ type?: 'image' | 'video' | 'gif' | 'document';
441
+ }>;
442
+ /** Per-platform options, keyed by platform (`youtube: { title }`) or by account id. */
443
+ options?: Record<string, Record<string, unknown>>;
444
+ /** ISO time, at least a minute and at most a year ahead; leave out to publish now. */
445
+ schedule_at?: string | null;
446
+ timezone?: string | null;
447
+ draft?: boolean;
448
+ }
449
+ export interface SocialUserPost {
450
+ object: 'social_post';
451
+ id: string;
452
+ project_id: string;
453
+ environment: 'production' | 'development';
454
+ status: 'draft' | 'scheduled' | 'publishing' | 'published' | 'partial' | 'failed' | 'cancelled';
455
+ text: string;
456
+ media: Array<{
457
+ type: 'image' | 'video' | 'gif' | 'document';
458
+ url: string;
459
+ }>;
460
+ targets: Array<{
461
+ account_id: string;
462
+ platform: SocialPlatform;
463
+ username: string | null;
464
+ status: 'pending' | 'publishing' | 'published' | 'failed' | 'cancelled';
465
+ url: string | null;
466
+ error: string | null;
467
+ published_at: string | null;
468
+ options: Record<string, unknown>;
469
+ }>;
470
+ scheduled_for: string | null;
471
+ timezone: string | null;
472
+ published_at: string | null;
473
+ approval: null;
474
+ created_at: string;
475
+ updated_at: string;
476
+ user_id: string;
477
+ }
397
478
  export declare class VibizApp {
398
479
  private readonly options;
399
480
  private loaded;
@@ -457,6 +538,16 @@ export declare class VibizApp {
457
538
  from: string;
458
539
  status: string;
459
540
  }>>;
541
+ /**
542
+ * Whether each mailbox exists, asked of its own mail server (up to 100):
543
+ * `valid`, `invalid` (a send bounces), `catch_all` or `unknown` (never block on it).
544
+ */
545
+ verify: (emails: string[]) => Promise<ActionResult<{
546
+ results: Array<{
547
+ email: string;
548
+ status: "valid" | "invalid" | "catch_all" | "unknown";
549
+ }>;
550
+ }>>;
460
551
  };
461
552
  /**
462
553
  * The project's phone number (docs: phone): text and call from it, read what
@@ -641,6 +732,65 @@ export declare class VibizApp {
641
732
  deleted: true;
642
733
  }>;
643
734
  };
735
+ /**
736
+ * Your users' own social accounts (docs: social ▸ "Social for your app's
737
+ * users"), on `vibiz.user(id)`: they connect Threads, Bluesky, Instagram…
738
+ * with no thelastapi sign-in, and post or schedule to them with no owner
739
+ * approval. Each user sees only their own accounts and posts. A development
740
+ * key connects test accounts at once and posts nowhere.
741
+ */
742
+ get social(): {
743
+ /** A link for your user to connect an account; `return_url` must be on your app's own address. */
744
+ connect: (input: {
745
+ platform: SocialPlatform;
746
+ return_url: string;
747
+ }) => Promise<SocialConnectLink>;
748
+ accounts: () => Promise<{
749
+ object: "list";
750
+ data: SocialUserAccount[];
751
+ has_more: boolean;
752
+ }>;
753
+ disconnect: (accountId: string) => Promise<SocialUserAccount>;
754
+ /** `post(input)` publishes, schedules or drafts; `post(id)` reads one back. */
755
+ post: {
756
+ (input: SocialUserPostInput): Promise<SocialUserPost>;
757
+ (id: string): Promise<SocialUserPost>;
758
+ };
759
+ get: (id: string) => Promise<SocialUserPost>;
760
+ posts: (opts?: {
761
+ status?: SocialUserPost["status"] | SocialUserPost["status"][];
762
+ account?: string;
763
+ platform?: SocialPlatform;
764
+ from?: string;
765
+ to?: string;
766
+ cursor?: string;
767
+ limit?: number;
768
+ }) => Promise<{
769
+ object: "list";
770
+ data: SocialUserPost[];
771
+ has_more: boolean;
772
+ next_cursor: string | null;
773
+ }>;
774
+ /** Publish a draft now, or at `schedule_at`. */
775
+ publish: (id: string, opts?: {
776
+ schedule_at?: string | null;
777
+ timezone?: string | null;
778
+ }) => Promise<SocialUserPost>;
779
+ /** Cancel a draft or a scheduled post (a published one stays on the platforms). */
780
+ cancel: (id: string) => Promise<SocialUserPost>;
781
+ /** Upload an image or video (at most 512 MB) → `{url}` to put in `media`. */
782
+ upload: (file: Uint8Array | Blob, opts: {
783
+ name: string;
784
+ contentType?: string;
785
+ }) => Promise<{
786
+ object: "social_media";
787
+ url: string;
788
+ type: "image" | "video" | "gif" | "document";
789
+ content_type: string;
790
+ size: number;
791
+ environment: "production" | "development";
792
+ }>;
793
+ };
644
794
  /**
645
795
  * The project's contacts (docs: email ▸ Contacts): who gets its newsletters and
646
796
  * automations. Add users at signup, keep their properties current, and track
package/dist/index.js CHANGED
@@ -305,7 +305,12 @@ var VibizApp = class _VibizApp {
305
305
  }
306
306
  /** Email from the project's own address (needs the `email` resource). */
307
307
  email = {
308
- send: (input) => this.actions.run("email.send", input)
308
+ send: (input) => this.actions.run("email.send", input),
309
+ /**
310
+ * Whether each mailbox exists, asked of its own mail server (up to 100):
311
+ * `valid`, `invalid` (a send bounces), `catch_all` or `unknown` (never block on it).
312
+ */
313
+ verify: (emails) => this.actions.run("email.verify", { emails })
309
314
  };
310
315
  /**
311
316
  * The project's phone number (docs: phone): text and call from it, read what
@@ -465,6 +470,64 @@ var VibizApp = class _VibizApp {
465
470
  { method: "DELETE" }
466
471
  )
467
472
  };
473
+ /**
474
+ * Your users' own social accounts (docs: social ▸ "Social for your app's
475
+ * users"), on `vibiz.user(id)`: they connect Threads, Bluesky, Instagram…
476
+ * with no thelastapi sign-in, and post or schedule to them with no owner
477
+ * approval. Each user sees only their own accounts and posts. A development
478
+ * key connects test accounts at once and posts nowhere.
479
+ */
480
+ get social() {
481
+ const user = this.options.user;
482
+ const base = () => {
483
+ if (!user) {
484
+ throw new VibizAppError(
485
+ 400,
486
+ "invalid_request",
487
+ "Social acts for one of your users: call it on vibiz.user(userId).social."
488
+ );
489
+ }
490
+ return `/app/social/users/${encodeURIComponent(user)}`;
491
+ };
492
+ const getPost = (id) => this.request(`${base()}/posts/${encodeURIComponent(id)}`);
493
+ const createPost = (input) => this.request(`${base()}/posts`, { body: input });
494
+ function post(arg) {
495
+ return typeof arg === "string" ? getPost(arg) : createPost(arg);
496
+ }
497
+ return {
498
+ /** A link for your user to connect an account; `return_url` must be on your app's own address. */
499
+ connect: (input) => this.request(`${base()}/connect`, { body: input }),
500
+ accounts: () => this.request(
501
+ `${base()}/accounts`
502
+ ),
503
+ disconnect: (accountId) => this.request(`${base()}/accounts/${encodeURIComponent(accountId)}`, {
504
+ method: "DELETE"
505
+ }),
506
+ /** `post(input)` publishes, schedules or drafts; `post(id)` reads one back. */
507
+ post,
508
+ get: getPost,
509
+ posts: (opts = {}) => this.request(
510
+ `${base()}/posts${query({ ...opts, status: Array.isArray(opts.status) ? opts.status.join(",") : opts.status })}`
511
+ ),
512
+ /** Publish a draft now, or at `schedule_at`. */
513
+ publish: (id, opts = {}) => this.request(`${base()}/posts/${encodeURIComponent(id)}/publish`, {
514
+ body: opts
515
+ }),
516
+ /** Cancel a draft or a scheduled post (a published one stays on the platforms). */
517
+ cancel: (id) => this.request(`${base()}/posts/${encodeURIComponent(id)}/cancel`, {
518
+ body: {}
519
+ }),
520
+ /** Upload an image or video (at most 512 MB) → `{url}` to put in `media`. */
521
+ upload: async (file, opts) => {
522
+ const raw = file instanceof Uint8Array ? file : new Uint8Array(await file.arrayBuffer());
523
+ const contentType = opts.contentType ?? (file instanceof Blob && file.type ? file.type : void 0);
524
+ return this.request(`${base()}/media${query({ filename: opts.name })}`, {
525
+ raw,
526
+ ...contentType ? { contentType } : {}
527
+ });
528
+ }
529
+ };
530
+ }
468
531
  /**
469
532
  * The project's contacts (docs: email ▸ Contacts): who gets its newsletters and
470
533
  * automations. Add users at signup, keep their properties current, and track
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibiz/app",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "One key for your app: env, AI, email, actions and events from thelastapi.",
5
5
  "keywords": [
6
6
  "vibiz",