@impro.social/impro-plugin 0.0.22 → 0.0.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.
Files changed (3) hide show
  1. package/main.d.ts +28 -0
  2. package/main.js +20 -0
  3. package/package.json +1 -1
package/main.d.ts CHANGED
@@ -26,6 +26,8 @@ export function flattenForScan(tokens: RichTextToken[]): FlattenedTokens;
26
26
  * Paginated response from `getKnownFollowers`: `{ followers, cursor }`.
27
27
  * @typedef {Record<string, unknown>} RepoRecord
28
28
  * A raw repo record: `{ uri, cid, value }`.
29
+ * @typedef {{ did: string, collection: string, rkey: string }} BacklinkRecord
30
+ * A record that links to a queried subject.
29
31
  * @typedef {Record<string, unknown>} FeedItem
30
32
  * A `app.bsky.feed.defs#feedViewPost` (post + reply/repost context).
31
33
  * @typedef {{ $type: string } & Record<string, unknown>} RichTextFacetFeature
@@ -194,6 +196,24 @@ export class PluginData {
194
196
  * @returns {Promise<RepoRecord>}
195
197
  */
196
198
  getRecord(repo: string, collection: string, rkey: string): Promise<RepoRecord>;
199
+ /**
200
+ * Get records that link to `subject`, from a backlink
201
+ * index of public records.
202
+ *
203
+ * `subject` is an AT-URI or a DID; `source` names the linking field as
204
+ * `<collection>:<dot.path.to.field>` (e.g.
205
+ * `"app.bsky.graph.listitem:list"`). The host paginates for you, up to
206
+ * `limit` records (max 1000 per call — page by making further calls
207
+ * with a narrower subject).
208
+ *
209
+ * @param {{ subject: string, source: string, limit?: number }} params
210
+ * @returns {Promise<BacklinkRecord[]>}
211
+ */
212
+ getBacklinks({ subject, source, limit }: {
213
+ subject: string;
214
+ source: string;
215
+ limit?: number;
216
+ }): Promise<BacklinkRecord[]>;
197
217
  }
198
218
  /**
199
219
  * The plugin's handle to the running impro app. Exposed as `this.app` on a
@@ -1140,6 +1160,14 @@ export type KnownFollowersResponse = Record<string, unknown>;
1140
1160
  * A raw repo record: `{ uri, cid, value }`.
1141
1161
  */
1142
1162
  export type RepoRecord = Record<string, unknown>;
1163
+ /**
1164
+ * A record that links to a queried subject.
1165
+ */
1166
+ export type BacklinkRecord = {
1167
+ did: string;
1168
+ collection: string;
1169
+ rkey: string;
1170
+ };
1143
1171
  /**
1144
1172
  * A `app.bsky.feed.defs#feedViewPost` (post + reply/repost context).
1145
1173
  */
package/main.js CHANGED
@@ -9,6 +9,8 @@
9
9
  * Paginated response from `getKnownFollowers`: `{ followers, cursor }`.
10
10
  * @typedef {Record<string, unknown>} RepoRecord
11
11
  * A raw repo record: `{ uri, cid, value }`.
12
+ * @typedef {{ did: string, collection: string, rkey: string }} BacklinkRecord
13
+ * A record that links to a queried subject.
12
14
  * @typedef {Record<string, unknown>} FeedItem
13
15
  * A `app.bsky.feed.defs#feedViewPost` (post + reply/repost context).
14
16
  * @typedef {{ $type: string } & Record<string, unknown>} RichTextFacetFeature
@@ -337,6 +339,24 @@ export class PluginData {
337
339
  hostCall("getRecord", { repo, collection, rkey })
338
340
  );
339
341
  }
342
+ /**
343
+ * Get records that link to `subject`, from a backlink
344
+ * index of public records.
345
+ *
346
+ * `subject` is an AT-URI or a DID; `source` names the linking field as
347
+ * `<collection>:<dot.path.to.field>` (e.g.
348
+ * `"app.bsky.graph.listitem:list"`). The host paginates for you, up to
349
+ * `limit` records (max 1000 per call — page by making further calls
350
+ * with a narrower subject).
351
+ *
352
+ * @param {{ subject: string, source: string, limit?: number }} params
353
+ * @returns {Promise<BacklinkRecord[]>}
354
+ */
355
+ getBacklinks({ subject, source, limit = 100 }) {
356
+ return /** @type {Promise<BacklinkRecord[]>} */ (
357
+ hostCall("getBacklinks", { subject, source, limit })
358
+ );
359
+ }
340
360
  }
341
361
 
342
362
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impro.social/impro-plugin",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "main": "main.js",
6
6
  "types": "./main.d.ts",