@alva-ai/toolkit 0.11.3-beta.0 → 0.12.0

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.cts CHANGED
@@ -629,6 +629,29 @@ interface PushSubscription {
629
629
  /** Playbooks whose latest release currently references this feed. */
630
630
  used_by?: PushSubscriptionUsedBy[];
631
631
  used_by_total?: number;
632
+ /**
633
+ * Row-shape discriminator: PLAYBOOK_ALERTS = a playbook-level wildcard
634
+ * (alerts for every push-enabled automation of the playbook);
635
+ * FEED_ALERT = a single feed's alert.
636
+ */
637
+ kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
638
+ /**
639
+ * Whether the caller also FOLLOWS the target playbook — the social
640
+ * relation, distinct from this alert row. Always false for FEED targets.
641
+ */
642
+ following?: boolean;
643
+ /**
644
+ * Target lifecycle: TARGET_DELETED marks a ghost row (the playbook/feed
645
+ * was deleted) — clear it with unsubscribeBatch by target id.
646
+ */
647
+ target_status?: 'ACTIVE' | 'TARGET_DELETED' | 'PAUSED' | 'UNSPECIFIED' | string;
648
+ /** Playbook identity, present for PLAYBOOK targets on list responses. */
649
+ playbook?: PushSubscriptionPlaybookInfo;
650
+ }
651
+ interface PushSubscriptionPlaybookInfo {
652
+ owner_username: string;
653
+ name: string;
654
+ display_name: string;
632
655
  }
633
656
  interface PushSubscriptionUsedBy {
634
657
  playbook_id: string;
@@ -655,6 +678,46 @@ interface PushSubscriptionListResponse {
655
678
  items: PushSubscription[];
656
679
  /** Empty when there is no next page. */
657
680
  next_cursor?: string;
681
+ /**
682
+ * Total active subscription rows independent of pagination — when
683
+ * items.length < total_count, the page is truncated; keep paginating.
684
+ */
685
+ total_count?: number;
686
+ }
687
+ interface FollowsListParams {
688
+ /** Page size, default 50, max 100 server-side. */
689
+ limit?: number;
690
+ /** Opaque cursor from the previous page's `next_cursor`. */
691
+ cursor?: string;
692
+ }
693
+ interface PlaybookFollowItem {
694
+ playbook_id: string;
695
+ owner_username: string;
696
+ name: string;
697
+ display_name: string;
698
+ followed_at_ms: number;
699
+ cursor: string;
700
+ }
701
+ interface FollowsListResponse {
702
+ items: PlaybookFollowItem[];
703
+ has_next: boolean;
704
+ next_cursor?: string;
705
+ }
706
+ interface UnsubscribeBatchParams {
707
+ /** Playbook target ids (strings — snowflake ids exceed JS safe integers). */
708
+ playbookIds?: string[];
709
+ /** Feed target ids (strings). */
710
+ feedIds?: string[];
711
+ }
712
+ interface UnsubscribeBatchResult {
713
+ id: string;
714
+ kind: 'PLAYBOOK' | 'FEED' | string;
715
+ ok: boolean;
716
+ status: 'UNSUBSCRIBED' | 'INVALID_ID' | string;
717
+ }
718
+ interface UnsubscribeBatchResponse {
719
+ results: UnsubscribeBatchResult[];
720
+ ok_count: number;
658
721
  }
659
722
  interface PlaybookFollow {
660
723
  id: string;
@@ -896,9 +959,65 @@ interface TrendingPlaybooksResponse {
896
959
  * Public playbook discovery. Backed by alva-gateway REST and mirrors the
897
960
  * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
898
961
  */
962
+ /** Compact discovery record returned by getByIds / listByOwner / get. */
963
+ interface PlaybookDiscoveryItem {
964
+ /** Numeric playbook id encoded as a string. */
965
+ id: string;
966
+ /** Owner username (empty when not resolvable). */
967
+ owner_username: string;
968
+ /** URL-safe playbook name. */
969
+ name: string;
970
+ display_name: string;
971
+ visibility: string;
972
+ /** Stable "owner/name" handle for name-addressed operations. */
973
+ ref?: string;
974
+ /** Present on listByOwner rows. */
975
+ cursor?: string;
976
+ }
977
+ interface DiscoveryByIDsResponse {
978
+ items: PlaybookDiscoveryItem[];
979
+ }
980
+ interface ListByOwnerParams {
981
+ owner: string;
982
+ /** Page size, default 50, max 100 server-side. */
983
+ limit?: number;
984
+ cursor?: string;
985
+ }
986
+ interface ListByOwnerResponse {
987
+ items: PlaybookDiscoveryItem[];
988
+ has_next: boolean;
989
+ next_cursor?: string;
990
+ }
899
991
  declare class PlaybooksResource {
900
992
  private client;
901
993
  constructor(client: AlvaClient);
994
+ /**
995
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
996
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
997
+ * playbook ids — return no row. Treat a missing id as "deleted or not
998
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
999
+ * Ids are strings (snowflake-safe). Max 100 per call.
1000
+ *
1001
+ * Auth is optional (like `trending`): with an API key, private/paid
1002
+ * visibility is evaluated for the caller; without one, only public
1003
+ * playbooks resolve. The server decides — no client-side gate.
1004
+ */
1005
+ getByIds(ids: string[]): Promise<DiscoveryByIDsResponse>;
1006
+ /**
1007
+ * List a user's playbooks by owner username (mono-meta#584 C10).
1008
+ * Visibility-gated: another user's private playbooks are omitted.
1009
+ * Auth is optional (like `trending`); without credentials only public
1010
+ * playbooks are listed.
1011
+ */
1012
+ listByOwner(params: ListByOwnerParams): Promise<ListByOwnerResponse>;
1013
+ /**
1014
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
1015
+ * not found / not visible / deleted.
1016
+ */
1017
+ get(params: {
1018
+ id?: string;
1019
+ ref?: string;
1020
+ }): Promise<PlaybookDiscoveryItem | null>;
902
1021
  /**
903
1022
  * List trending / searchable playbooks. Auth is optional: when the client
904
1023
  * has an API key it is forwarded, otherwise this uses the public surface.
@@ -1166,12 +1285,24 @@ declare class NotificationPreferencesResource {
1166
1285
  /**
1167
1286
  * Subscriptions — subscribe the caller to playbooks and feeds.
1168
1287
  *
1288
+ * Three DISTINCT concepts share the word "subscribe" in the product; this
1289
+ * resource touches the first two and never the third:
1290
+ *
1291
+ * - **follow** — the social relation ("Subscribed Playbooks" in the UI).
1292
+ * Enumerate with `follows()`.
1293
+ * - **alerts** — push/notification opt-ins (what `list()` returns).
1294
+ * - **purchase** — paid playbook access / the SaaS plan. NOT this resource.
1295
+ *
1296
+ * Operations:
1169
1297
  * - `subscribePlaybook` is a CASCADE: it follows the playbook AND enables
1170
1298
  * personal push for every push-enabled automation of its latest release,
1171
1299
  * in one call. `unsubscribePlaybook` reverses both (unfollow + disable
1172
- * all of the playbook's push alerts).
1300
+ * the playbook-level alert) and reports exactly what it changed.
1173
1301
  * - `subscribeFeed` / `unsubscribeFeed` toggle personal push for ONE feed
1174
1302
  * (a single automation's alert) without touching the playbook follow.
1303
+ * - `unsubscribeBatch` disables alerts by TARGET ID — bulk, idempotent,
1304
+ * and the only way to clear ghost rows whose target was deleted
1305
+ * (name-addressed unsubscribe 404s on deleted playbooks).
1175
1306
  *
1176
1307
  * Backed by alva-gateway REST under `/api/v1/subscriptions/...`.
1177
1308
  */
@@ -1206,6 +1337,20 @@ declare class SubscriptionsResource {
1206
1337
  * Results are cursor-paginated.
1207
1338
  */
1208
1339
  list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
1340
+ /**
1341
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
1342
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
1343
+ * deleted playbooks are filtered server-side. Cursor-paginated.
1344
+ */
1345
+ follows(params?: FollowsListParams): Promise<FollowsListResponse>;
1346
+ /**
1347
+ * Disable alerts for many playbook/feed targets BY TARGET ID in one
1348
+ * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
1349
+ * for ghost rows (deleted targets) because no name resolution happens —
1350
+ * the per-id results report `INVALID_ID` for malformed entries while
1351
+ * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
1352
+ */
1353
+ unsubscribeBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
1209
1354
  }
1210
1355
 
1211
1356
  /**
package/dist/index.d.ts CHANGED
@@ -629,6 +629,29 @@ interface PushSubscription {
629
629
  /** Playbooks whose latest release currently references this feed. */
630
630
  used_by?: PushSubscriptionUsedBy[];
631
631
  used_by_total?: number;
632
+ /**
633
+ * Row-shape discriminator: PLAYBOOK_ALERTS = a playbook-level wildcard
634
+ * (alerts for every push-enabled automation of the playbook);
635
+ * FEED_ALERT = a single feed's alert.
636
+ */
637
+ kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
638
+ /**
639
+ * Whether the caller also FOLLOWS the target playbook — the social
640
+ * relation, distinct from this alert row. Always false for FEED targets.
641
+ */
642
+ following?: boolean;
643
+ /**
644
+ * Target lifecycle: TARGET_DELETED marks a ghost row (the playbook/feed
645
+ * was deleted) — clear it with unsubscribeBatch by target id.
646
+ */
647
+ target_status?: 'ACTIVE' | 'TARGET_DELETED' | 'PAUSED' | 'UNSPECIFIED' | string;
648
+ /** Playbook identity, present for PLAYBOOK targets on list responses. */
649
+ playbook?: PushSubscriptionPlaybookInfo;
650
+ }
651
+ interface PushSubscriptionPlaybookInfo {
652
+ owner_username: string;
653
+ name: string;
654
+ display_name: string;
632
655
  }
633
656
  interface PushSubscriptionUsedBy {
634
657
  playbook_id: string;
@@ -655,6 +678,46 @@ interface PushSubscriptionListResponse {
655
678
  items: PushSubscription[];
656
679
  /** Empty when there is no next page. */
657
680
  next_cursor?: string;
681
+ /**
682
+ * Total active subscription rows independent of pagination — when
683
+ * items.length < total_count, the page is truncated; keep paginating.
684
+ */
685
+ total_count?: number;
686
+ }
687
+ interface FollowsListParams {
688
+ /** Page size, default 50, max 100 server-side. */
689
+ limit?: number;
690
+ /** Opaque cursor from the previous page's `next_cursor`. */
691
+ cursor?: string;
692
+ }
693
+ interface PlaybookFollowItem {
694
+ playbook_id: string;
695
+ owner_username: string;
696
+ name: string;
697
+ display_name: string;
698
+ followed_at_ms: number;
699
+ cursor: string;
700
+ }
701
+ interface FollowsListResponse {
702
+ items: PlaybookFollowItem[];
703
+ has_next: boolean;
704
+ next_cursor?: string;
705
+ }
706
+ interface UnsubscribeBatchParams {
707
+ /** Playbook target ids (strings — snowflake ids exceed JS safe integers). */
708
+ playbookIds?: string[];
709
+ /** Feed target ids (strings). */
710
+ feedIds?: string[];
711
+ }
712
+ interface UnsubscribeBatchResult {
713
+ id: string;
714
+ kind: 'PLAYBOOK' | 'FEED' | string;
715
+ ok: boolean;
716
+ status: 'UNSUBSCRIBED' | 'INVALID_ID' | string;
717
+ }
718
+ interface UnsubscribeBatchResponse {
719
+ results: UnsubscribeBatchResult[];
720
+ ok_count: number;
658
721
  }
659
722
  interface PlaybookFollow {
660
723
  id: string;
@@ -896,9 +959,65 @@ interface TrendingPlaybooksResponse {
896
959
  * Public playbook discovery. Backed by alva-gateway REST and mirrors the
897
960
  * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
898
961
  */
962
+ /** Compact discovery record returned by getByIds / listByOwner / get. */
963
+ interface PlaybookDiscoveryItem {
964
+ /** Numeric playbook id encoded as a string. */
965
+ id: string;
966
+ /** Owner username (empty when not resolvable). */
967
+ owner_username: string;
968
+ /** URL-safe playbook name. */
969
+ name: string;
970
+ display_name: string;
971
+ visibility: string;
972
+ /** Stable "owner/name" handle for name-addressed operations. */
973
+ ref?: string;
974
+ /** Present on listByOwner rows. */
975
+ cursor?: string;
976
+ }
977
+ interface DiscoveryByIDsResponse {
978
+ items: PlaybookDiscoveryItem[];
979
+ }
980
+ interface ListByOwnerParams {
981
+ owner: string;
982
+ /** Page size, default 50, max 100 server-side. */
983
+ limit?: number;
984
+ cursor?: string;
985
+ }
986
+ interface ListByOwnerResponse {
987
+ items: PlaybookDiscoveryItem[];
988
+ has_next: boolean;
989
+ next_cursor?: string;
990
+ }
899
991
  declare class PlaybooksResource {
900
992
  private client;
901
993
  constructor(client: AlvaClient);
994
+ /**
995
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
996
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
997
+ * playbook ids — return no row. Treat a missing id as "deleted or not
998
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
999
+ * Ids are strings (snowflake-safe). Max 100 per call.
1000
+ *
1001
+ * Auth is optional (like `trending`): with an API key, private/paid
1002
+ * visibility is evaluated for the caller; without one, only public
1003
+ * playbooks resolve. The server decides — no client-side gate.
1004
+ */
1005
+ getByIds(ids: string[]): Promise<DiscoveryByIDsResponse>;
1006
+ /**
1007
+ * List a user's playbooks by owner username (mono-meta#584 C10).
1008
+ * Visibility-gated: another user's private playbooks are omitted.
1009
+ * Auth is optional (like `trending`); without credentials only public
1010
+ * playbooks are listed.
1011
+ */
1012
+ listByOwner(params: ListByOwnerParams): Promise<ListByOwnerResponse>;
1013
+ /**
1014
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
1015
+ * not found / not visible / deleted.
1016
+ */
1017
+ get(params: {
1018
+ id?: string;
1019
+ ref?: string;
1020
+ }): Promise<PlaybookDiscoveryItem | null>;
902
1021
  /**
903
1022
  * List trending / searchable playbooks. Auth is optional: when the client
904
1023
  * has an API key it is forwarded, otherwise this uses the public surface.
@@ -1166,12 +1285,24 @@ declare class NotificationPreferencesResource {
1166
1285
  /**
1167
1286
  * Subscriptions — subscribe the caller to playbooks and feeds.
1168
1287
  *
1288
+ * Three DISTINCT concepts share the word "subscribe" in the product; this
1289
+ * resource touches the first two and never the third:
1290
+ *
1291
+ * - **follow** — the social relation ("Subscribed Playbooks" in the UI).
1292
+ * Enumerate with `follows()`.
1293
+ * - **alerts** — push/notification opt-ins (what `list()` returns).
1294
+ * - **purchase** — paid playbook access / the SaaS plan. NOT this resource.
1295
+ *
1296
+ * Operations:
1169
1297
  * - `subscribePlaybook` is a CASCADE: it follows the playbook AND enables
1170
1298
  * personal push for every push-enabled automation of its latest release,
1171
1299
  * in one call. `unsubscribePlaybook` reverses both (unfollow + disable
1172
- * all of the playbook's push alerts).
1300
+ * the playbook-level alert) and reports exactly what it changed.
1173
1301
  * - `subscribeFeed` / `unsubscribeFeed` toggle personal push for ONE feed
1174
1302
  * (a single automation's alert) without touching the playbook follow.
1303
+ * - `unsubscribeBatch` disables alerts by TARGET ID — bulk, idempotent,
1304
+ * and the only way to clear ghost rows whose target was deleted
1305
+ * (name-addressed unsubscribe 404s on deleted playbooks).
1175
1306
  *
1176
1307
  * Backed by alva-gateway REST under `/api/v1/subscriptions/...`.
1177
1308
  */
@@ -1206,6 +1337,20 @@ declare class SubscriptionsResource {
1206
1337
  * Results are cursor-paginated.
1207
1338
  */
1208
1339
  list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
1340
+ /**
1341
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
1342
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
1343
+ * deleted playbooks are filtered server-side. Cursor-paginated.
1344
+ */
1345
+ follows(params?: FollowsListParams): Promise<FollowsListResponse>;
1346
+ /**
1347
+ * Disable alerts for many playbook/feed targets BY TARGET ID in one
1348
+ * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
1349
+ * for ghost rows (deleted targets) because no name resolution happens —
1350
+ * the per-id results report `INVALID_ID` for malformed entries while
1351
+ * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
1352
+ */
1353
+ unsubscribeBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
1209
1354
  }
1210
1355
 
1211
1356
  /**
package/dist/index.js CHANGED
@@ -364,6 +364,69 @@ var PlaybooksResource = class {
364
364
  this.client = client;
365
365
  }
366
366
  client;
367
+ /**
368
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
369
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
370
+ * playbook ids — return no row. Treat a missing id as "deleted or not
371
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
372
+ * Ids are strings (snowflake-safe). Max 100 per call.
373
+ *
374
+ * Auth is optional (like `trending`): with an API key, private/paid
375
+ * visibility is evaluated for the caller; without one, only public
376
+ * playbooks resolve. The server decides — no client-side gate.
377
+ */
378
+ async getByIds(ids) {
379
+ return await this.client._request("GET", "/api/v1/playbooks", {
380
+ query: { ids: ids.join(",") }
381
+ });
382
+ }
383
+ /**
384
+ * List a user's playbooks by owner username (mono-meta#584 C10).
385
+ * Visibility-gated: another user's private playbooks are omitted.
386
+ * Auth is optional (like `trending`); without credentials only public
387
+ * playbooks are listed.
388
+ */
389
+ async listByOwner(params) {
390
+ const query = { owner: params.owner };
391
+ if (params.limit !== void 0 && params.limit > 0) {
392
+ query.limit = String(params.limit);
393
+ }
394
+ if (params.cursor) query.cursor = params.cursor;
395
+ return await this.client._request("GET", "/api/v1/playbooks", {
396
+ query
397
+ });
398
+ }
399
+ /**
400
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
401
+ * not found / not visible / deleted.
402
+ */
403
+ async get(params) {
404
+ if (params.id) {
405
+ const resp = await this.getByIds([params.id]);
406
+ return resp.items[0] ?? null;
407
+ }
408
+ if (params.ref) {
409
+ const slash = params.ref.indexOf("/");
410
+ if (slash <= 0 || slash === params.ref.length - 1) {
411
+ throw new AlvaError(
412
+ "INVALID_ARGUMENT",
413
+ `Invalid ref "${params.ref}". Expected "owner/name".`,
414
+ 400
415
+ );
416
+ }
417
+ const owner = params.ref.slice(0, slash);
418
+ const name = params.ref.slice(slash + 1);
419
+ let cursor;
420
+ for (; ; ) {
421
+ const page = await this.listByOwner({ owner, cursor, limit: 100 });
422
+ const hit = page.items.find((item) => item.name === name);
423
+ if (hit) return hit;
424
+ if (!page.has_next || !page.next_cursor) return null;
425
+ cursor = page.next_cursor;
426
+ }
427
+ }
428
+ throw new AlvaError("INVALID_ARGUMENT", "id or ref is required", 400);
429
+ }
367
430
  /**
368
431
  * List trending / searchable playbooks. Auth is optional: when the client
369
432
  * has an API key it is forwarded, otherwise this uses the public surface.
@@ -2149,6 +2212,42 @@ var SubscriptionsResource = class {
2149
2212
  query
2150
2213
  });
2151
2214
  }
2215
+ /**
2216
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
2217
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
2218
+ * deleted playbooks are filtered server-side. Cursor-paginated.
2219
+ */
2220
+ async follows(params = {}) {
2221
+ this.client._requireAuth();
2222
+ const query = {};
2223
+ if (params.limit !== void 0 && params.limit > 0) {
2224
+ query.limit = String(params.limit);
2225
+ }
2226
+ if (params.cursor) query.cursor = params.cursor;
2227
+ return this.client._request("GET", "/api/v1/me/follows", {
2228
+ query
2229
+ });
2230
+ }
2231
+ /**
2232
+ * Disable alerts for many playbook/feed targets BY TARGET ID in one
2233
+ * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
2234
+ * for ghost rows (deleted targets) because no name resolution happens —
2235
+ * the per-id results report `INVALID_ID` for malformed entries while
2236
+ * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
2237
+ */
2238
+ async unsubscribeBatch(params) {
2239
+ this.client._requireAuth();
2240
+ return this.client._request(
2241
+ "POST",
2242
+ "/api/v1/subscriptions/unsubscribe-batch",
2243
+ {
2244
+ body: {
2245
+ playbook_ids: params.playbookIds ?? [],
2246
+ feed_ids: params.feedIds ?? []
2247
+ }
2248
+ }
2249
+ );
2250
+ }
2152
2251
  };
2153
2252
 
2154
2253
  // src/resources/channelGroupSubscriptions.ts
@@ -3026,7 +3125,7 @@ var installPlaybookRuntime = (targetWindow) => {
3026
3125
  };
3027
3126
 
3028
3127
  // src/index.ts
3029
- var VERSION = true ? "0.11.3-beta.0" : "dev";
3128
+ var VERSION = true ? "0.12.0" : "dev";
3030
3129
  export {
3031
3130
  AlvaClient,
3032
3131
  AlvaError,