@atproto/pds 0.3.16 → 0.3.17

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.
@@ -1,66 +1,57 @@
1
- import { makeAlgos } from '@atproto/bsky'
2
- import AtpAgent, { AtUri, AppBskyFeedNS } from '@atproto/api'
1
+ import AtpAgent, { AtUri } from '@atproto/api'
3
2
  import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
3
  import basicSeed from '../seeds/basic'
5
4
  import { forSnapshot } from '../_util'
5
+ import { InvalidRequestError } from '@atproto/xrpc-server'
6
6
 
7
7
  describe('feedgen proxy view', () => {
8
8
  let network: TestNetwork
9
9
  let agent: AtpAgent
10
10
  let sc: SeedClient
11
11
 
12
- const origGetFeedGenerator = AppBskyFeedNS.prototype.getFeedGenerator
13
- const feedUri = AtUri.make(
14
- 'did:example:feed-publisher',
15
- 'app.bsky.feed.generator',
16
- 'mutuals',
17
- )
12
+ let feedUri: AtUri
18
13
 
19
14
  beforeAll(async () => {
20
15
  network = await TestNetwork.create({
21
16
  dbPostgresSchema: 'proxy_feedgen',
22
- bsky: { algos: makeAlgos(feedUri.host) },
23
17
  })
24
18
  agent = network.pds.getClient()
25
19
  sc = network.getSeedClient()
26
20
  await basicSeed(sc, { addModLabels: true })
21
+
22
+ feedUri = AtUri.make(sc.dids.alice, 'app.bsky.feed.generator', 'mutuals')
23
+
24
+ const feedGen = await network.createFeedGen({
25
+ [feedUri.toString()]: ({ params }) => {
26
+ if (params.feed !== feedUri.toString()) {
27
+ throw new InvalidRequestError('Unknown feed')
28
+ }
29
+ return {
30
+ encoding: 'application/json',
31
+ body: {
32
+ feed: [
33
+ { post: sc.posts[sc.dids.alice][0].ref.uriStr },
34
+ { post: sc.posts[sc.dids.carol][0].ref.uriStr },
35
+ ],
36
+ },
37
+ }
38
+ },
39
+ })
40
+
27
41
  // publish feed
28
- const feed = await agent.api.app.bsky.feed.generator.create(
42
+ await agent.api.app.bsky.feed.generator.create(
29
43
  { repo: sc.dids.alice, rkey: feedUri.rkey },
30
44
  {
31
- did: network.bsky.ctx.cfg.feedGenDid ?? '',
32
- displayName: 'Mutuals',
45
+ did: feedGen.did,
46
+ displayName: 'Test feed',
33
47
  createdAt: new Date().toISOString(),
34
48
  },
35
49
  sc.getHeaders(sc.dids.alice),
36
50
  )
37
51
  await network.processAll()
38
- // mock getFeedGenerator() for use by pds's getFeed since we don't have a proper feedGenDid or feed publisher
39
- AppBskyFeedNS.prototype.getFeedGenerator = async function (params, opts) {
40
- if (params?.feed === feedUri.toString()) {
41
- return {
42
- success: true,
43
- data: {
44
- isOnline: true,
45
- isValid: true,
46
- view: {
47
- cid: feed.cid,
48
- uri: feed.uri,
49
- did: network.bsky.ctx.cfg.feedGenDid ?? '',
50
- creator: { did: sc.dids.alice, handle: 'alice.test' },
51
- displayName: 'Mutuals',
52
- indexedAt: new Date().toISOString(),
53
- },
54
- },
55
- headers: {},
56
- }
57
- }
58
- return origGetFeedGenerator.call(this, params, opts)
59
- }
60
52
  })
61
53
 
62
54
  afterAll(async () => {
63
- AppBskyFeedNS.prototype.getFeedGenerator = origGetFeedGenerator
64
55
  await network.close()
65
56
  })
66
57
 
@@ -1,35 +0,0 @@
1
- import express from 'express';
2
- import { HandlerAuth } from '@atproto/xrpc-server';
3
- import * as AppBskyFeedDefs from '../feed/defs';
4
- export interface QueryParams {
5
- limit: number;
6
- cursor?: string;
7
- }
8
- export type InputSchema = undefined;
9
- export interface OutputSchema {
10
- cursor?: string;
11
- feed: AppBskyFeedDefs.SkeletonFeedPost[];
12
- [k: string]: unknown;
13
- }
14
- export type HandlerInput = undefined;
15
- export interface HandlerSuccess {
16
- encoding: 'application/json';
17
- body: OutputSchema;
18
- headers?: {
19
- [key: string]: string;
20
- };
21
- }
22
- export interface HandlerError {
23
- status: number;
24
- message?: string;
25
- error?: 'UnknownFeed';
26
- }
27
- export type HandlerOutput = HandlerError | HandlerSuccess;
28
- export type HandlerReqCtx<HA extends HandlerAuth = never> = {
29
- auth: HA;
30
- params: QueryParams;
31
- input: HandlerInput;
32
- req: express.Request;
33
- res: express.Response;
34
- };
35
- export type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -1,49 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import express from 'express'
5
- import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
- import { lexicons } from '../../../../lexicons'
7
- import { isObj, hasProp } from '../../../../util'
8
- import { CID } from 'multiformats/cid'
9
- import { HandlerAuth } from '@atproto/xrpc-server'
10
- import * as AppBskyFeedDefs from '../feed/defs'
11
-
12
- export interface QueryParams {
13
- limit: number
14
- cursor?: string
15
- }
16
-
17
- export type InputSchema = undefined
18
-
19
- export interface OutputSchema {
20
- cursor?: string
21
- feed: AppBskyFeedDefs.SkeletonFeedPost[]
22
- [k: string]: unknown
23
- }
24
-
25
- export type HandlerInput = undefined
26
-
27
- export interface HandlerSuccess {
28
- encoding: 'application/json'
29
- body: OutputSchema
30
- headers?: { [key: string]: string }
31
- }
32
-
33
- export interface HandlerError {
34
- status: number
35
- message?: string
36
- error?: 'UnknownFeed'
37
- }
38
-
39
- export type HandlerOutput = HandlerError | HandlerSuccess
40
- export type HandlerReqCtx<HA extends HandlerAuth = never> = {
41
- auth: HA
42
- params: QueryParams
43
- input: HandlerInput
44
- req: express.Request
45
- res: express.Response
46
- }
47
- export type Handler<HA extends HandlerAuth = never> = (
48
- ctx: HandlerReqCtx<HA>,
49
- ) => Promise<HandlerOutput> | HandlerOutput