@atproto/bsky 0.0.76 → 0.0.77

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 (219) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/api/app/bsky/feed/getActorLikes.js +2 -2
  3. package/dist/api/app/bsky/feed/getActorLikes.js.map +1 -1
  4. package/dist/api/app/bsky/feed/getLikes.js +6 -6
  5. package/dist/api/app/bsky/feed/getLikes.js.map +1 -1
  6. package/dist/api/app/bsky/feed/getPosts.js +4 -4
  7. package/dist/api/app/bsky/feed/getPosts.js.map +1 -1
  8. package/dist/api/app/bsky/feed/getQuotes.d.ts +4 -0
  9. package/dist/api/app/bsky/feed/getQuotes.d.ts.map +1 -0
  10. package/dist/api/app/bsky/feed/getQuotes.js +67 -0
  11. package/dist/api/app/bsky/feed/getQuotes.js.map +1 -0
  12. package/dist/api/app/bsky/feed/getRepostedBy.js +6 -6
  13. package/dist/api/app/bsky/feed/getRepostedBy.js.map +1 -1
  14. package/dist/api/app/bsky/feed/searchPosts.js +4 -4
  15. package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
  16. package/dist/api/app/bsky/graph/getFollowers.js +8 -8
  17. package/dist/api/app/bsky/graph/getFollowers.js.map +1 -1
  18. package/dist/api/app/bsky/graph/getList.js +3 -3
  19. package/dist/api/app/bsky/graph/getList.js.map +1 -1
  20. package/dist/api/app/bsky/notification/listNotifications.d.ts.map +1 -1
  21. package/dist/api/app/bsky/notification/listNotifications.js +29 -8
  22. package/dist/api/app/bsky/notification/listNotifications.js.map +1 -1
  23. package/dist/api/index.d.ts.map +1 -1
  24. package/dist/api/index.js +2 -0
  25. package/dist/api/index.js.map +1 -1
  26. package/dist/data-plane/server/db/database-schema.d.ts +4 -2
  27. package/dist/data-plane/server/db/database-schema.d.ts.map +1 -1
  28. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.d.ts +4 -0
  29. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.d.ts.map +1 -0
  30. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.js +15 -0
  31. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.js.map +1 -0
  32. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.d.ts +4 -0
  33. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.d.ts.map +1 -0
  34. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.js +30 -0
  35. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.js.map +1 -0
  36. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.d.ts +4 -0
  37. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.d.ts.map +1 -0
  38. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.js +20 -0
  39. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.js.map +1 -0
  40. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.d.ts +4 -0
  41. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.d.ts.map +1 -0
  42. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.js +28 -0
  43. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.js.map +1 -0
  44. package/dist/data-plane/server/db/migrations/index.d.ts +4 -0
  45. package/dist/data-plane/server/db/migrations/index.d.ts.map +1 -1
  46. package/dist/data-plane/server/db/migrations/index.js +5 -1
  47. package/dist/data-plane/server/db/migrations/index.js.map +1 -1
  48. package/dist/data-plane/server/db/tables/post-agg.d.ts +1 -0
  49. package/dist/data-plane/server/db/tables/post-agg.d.ts.map +1 -1
  50. package/dist/data-plane/server/db/tables/post-gate.d.ts +14 -0
  51. package/dist/data-plane/server/db/tables/post-gate.d.ts.map +1 -0
  52. package/dist/data-plane/server/db/tables/post-gate.js +4 -0
  53. package/dist/data-plane/server/db/tables/post-gate.js.map +1 -0
  54. package/dist/data-plane/server/db/tables/post.d.ts +3 -0
  55. package/dist/data-plane/server/db/tables/post.d.ts.map +1 -1
  56. package/dist/data-plane/server/db/tables/quote.d.ts +16 -0
  57. package/dist/data-plane/server/db/tables/quote.d.ts.map +1 -0
  58. package/dist/data-plane/server/db/tables/quote.js +4 -0
  59. package/dist/data-plane/server/db/tables/quote.js.map +1 -0
  60. package/dist/data-plane/server/indexing/index.d.ts +2 -0
  61. package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
  62. package/dist/data-plane/server/indexing/index.js +6 -0
  63. package/dist/data-plane/server/indexing/index.js.map +1 -1
  64. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts +10 -0
  65. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts.map +1 -0
  66. package/dist/data-plane/server/indexing/plugins/post-gate.js +101 -0
  67. package/dist/data-plane/server/indexing/plugins/post-gate.js.map +1 -0
  68. package/dist/data-plane/server/indexing/plugins/post.d.ts +2 -0
  69. package/dist/data-plane/server/indexing/plugins/post.d.ts.map +1 -1
  70. package/dist/data-plane/server/indexing/plugins/post.js +122 -15
  71. package/dist/data-plane/server/indexing/plugins/post.js.map +1 -1
  72. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts.map +1 -1
  73. package/dist/data-plane/server/indexing/plugins/thread-gate.js +12 -0
  74. package/dist/data-plane/server/indexing/plugins/thread-gate.js.map +1 -1
  75. package/dist/data-plane/server/routes/index.d.ts.map +1 -1
  76. package/dist/data-plane/server/routes/index.js +2 -0
  77. package/dist/data-plane/server/routes/index.js.map +1 -1
  78. package/dist/data-plane/server/routes/interactions.d.ts.map +1 -1
  79. package/dist/data-plane/server/routes/interactions.js +2 -1
  80. package/dist/data-plane/server/routes/interactions.js.map +1 -1
  81. package/dist/data-plane/server/routes/quotes.d.ts +6 -0
  82. package/dist/data-plane/server/routes/quotes.d.ts.map +1 -0
  83. package/dist/data-plane/server/routes/quotes.js +27 -0
  84. package/dist/data-plane/server/routes/quotes.js.map +1 -0
  85. package/dist/data-plane/server/routes/records.d.ts.map +1 -1
  86. package/dist/data-plane/server/routes/records.js +11 -1
  87. package/dist/data-plane/server/routes/records.js.map +1 -1
  88. package/dist/data-plane/server/util.d.ts +6 -7
  89. package/dist/data-plane/server/util.d.ts.map +1 -1
  90. package/dist/data-plane/server/util.js +1 -9
  91. package/dist/data-plane/server/util.js.map +1 -1
  92. package/dist/hydration/feed.d.ts +10 -0
  93. package/dist/hydration/feed.d.ts.map +1 -1
  94. package/dist/hydration/feed.js +31 -7
  95. package/dist/hydration/feed.js.map +1 -1
  96. package/dist/hydration/hydrator.d.ts +4 -2
  97. package/dist/hydration/hydrator.d.ts.map +1 -1
  98. package/dist/hydration/hydrator.js +89 -34
  99. package/dist/hydration/hydrator.js.map +1 -1
  100. package/dist/hydration/util.d.ts +0 -1
  101. package/dist/hydration/util.d.ts.map +1 -1
  102. package/dist/hydration/util.js +1 -5
  103. package/dist/hydration/util.js.map +1 -1
  104. package/dist/lexicon/index.d.ts +2 -0
  105. package/dist/lexicon/index.d.ts.map +1 -1
  106. package/dist/lexicon/index.js +4 -0
  107. package/dist/lexicon/index.js.map +1 -1
  108. package/dist/lexicon/lexicons.d.ts +141 -0
  109. package/dist/lexicon/lexicons.d.ts.map +1 -1
  110. package/dist/lexicon/lexicons.js +142 -0
  111. package/dist/lexicon/lexicons.js.map +1 -1
  112. package/dist/lexicon/types/app/bsky/embed/record.d.ts +8 -1
  113. package/dist/lexicon/types/app/bsky/embed/record.d.ts.map +1 -1
  114. package/dist/lexicon/types/app/bsky/embed/record.js +11 -1
  115. package/dist/lexicon/types/app/bsky/embed/record.js.map +1 -1
  116. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +2 -0
  117. package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
  118. package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
  119. package/dist/lexicon/types/app/bsky/feed/getQuotes.d.ts +44 -0
  120. package/dist/lexicon/types/app/bsky/feed/getQuotes.d.ts.map +1 -0
  121. package/dist/lexicon/types/app/bsky/feed/getQuotes.js +3 -0
  122. package/dist/lexicon/types/app/bsky/feed/getQuotes.js.map +1 -0
  123. package/dist/lexicon/types/app/bsky/feed/postgate.d.ts +25 -0
  124. package/dist/lexicon/types/app/bsky/feed/postgate.d.ts.map +1 -0
  125. package/dist/lexicon/types/app/bsky/feed/postgate.js +27 -0
  126. package/dist/lexicon/types/app/bsky/feed/postgate.js.map +1 -0
  127. package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts +2 -0
  128. package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts.map +1 -1
  129. package/dist/lexicon/types/app/bsky/feed/threadgate.js.map +1 -1
  130. package/dist/proto/bsky_connect.d.ts +21 -1
  131. package/dist/proto/bsky_connect.d.ts.map +1 -1
  132. package/dist/proto/bsky_connect.js +20 -0
  133. package/dist/proto/bsky_connect.js.map +1 -1
  134. package/dist/proto/bsky_pb.d.ts +96 -0
  135. package/dist/proto/bsky_pb.d.ts.map +1 -1
  136. package/dist/proto/bsky_pb.js +306 -4
  137. package/dist/proto/bsky_pb.js.map +1 -1
  138. package/dist/util/uris.d.ts +12 -0
  139. package/dist/util/uris.d.ts.map +1 -0
  140. package/dist/util/uris.js +34 -0
  141. package/dist/util/uris.js.map +1 -0
  142. package/dist/views/index.d.ts +8 -2
  143. package/dist/views/index.d.ts.map +1 -1
  144. package/dist/views/index.js +83 -39
  145. package/dist/views/index.js.map +1 -1
  146. package/dist/views/types.d.ts +1 -1
  147. package/dist/views/types.d.ts.map +1 -1
  148. package/dist/views/types.js.map +1 -1
  149. package/dist/views/util.d.ts +11 -1
  150. package/dist/views/util.d.ts.map +1 -1
  151. package/dist/views/util.js +19 -8
  152. package/dist/views/util.js.map +1 -1
  153. package/package.json +4 -4
  154. package/proto/bsky.proto +33 -0
  155. package/src/api/app/bsky/feed/getActorLikes.ts +1 -1
  156. package/src/api/app/bsky/feed/getLikes.ts +1 -1
  157. package/src/api/app/bsky/feed/getPosts.ts +1 -1
  158. package/src/api/app/bsky/feed/getQuotes.ts +105 -0
  159. package/src/api/app/bsky/feed/getRepostedBy.ts +1 -1
  160. package/src/api/app/bsky/feed/searchPosts.ts +1 -1
  161. package/src/api/app/bsky/graph/getFollowers.ts +1 -1
  162. package/src/api/app/bsky/graph/getList.ts +1 -1
  163. package/src/api/app/bsky/notification/listNotifications.ts +32 -6
  164. package/src/api/index.ts +2 -0
  165. package/src/data-plane/server/db/database-schema.ts +7 -3
  166. package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +12 -0
  167. package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +28 -0
  168. package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +17 -0
  169. package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +25 -0
  170. package/src/data-plane/server/db/migrations/index.ts +4 -0
  171. package/src/data-plane/server/db/tables/post-agg.ts +1 -0
  172. package/src/data-plane/server/db/tables/post-gate.ts +12 -0
  173. package/src/data-plane/server/db/tables/post.ts +3 -0
  174. package/src/data-plane/server/db/tables/quote.ts +15 -0
  175. package/src/data-plane/server/indexing/index.ts +7 -0
  176. package/src/data-plane/server/indexing/plugins/post-gate.ts +104 -0
  177. package/src/data-plane/server/indexing/plugins/post.ts +151 -16
  178. package/src/data-plane/server/indexing/plugins/thread-gate.ts +12 -0
  179. package/src/data-plane/server/routes/index.ts +2 -0
  180. package/src/data-plane/server/routes/interactions.ts +2 -1
  181. package/src/data-plane/server/routes/quotes.ts +32 -0
  182. package/src/data-plane/server/routes/records.ts +11 -1
  183. package/src/data-plane/server/util.ts +0 -8
  184. package/src/hydration/feed.ts +58 -12
  185. package/src/hydration/hydrator.ts +94 -22
  186. package/src/hydration/util.ts +0 -4
  187. package/src/lexicon/index.ts +12 -0
  188. package/src/lexicon/lexicons.ts +145 -0
  189. package/src/lexicon/types/app/bsky/embed/record.ts +19 -0
  190. package/src/lexicon/types/app/bsky/feed/defs.ts +2 -0
  191. package/src/lexicon/types/app/bsky/feed/getQuotes.ts +54 -0
  192. package/src/lexicon/types/app/bsky/feed/postgate.ts +47 -0
  193. package/src/lexicon/types/app/bsky/feed/threadgate.ts +2 -0
  194. package/src/proto/bsky_connect.ts +24 -0
  195. package/src/proto/bsky_pb.ts +289 -0
  196. package/src/util/uris.ts +31 -0
  197. package/src/views/index.ts +90 -35
  198. package/src/views/types.ts +1 -0
  199. package/src/views/util.ts +37 -7
  200. package/tests/__snapshots__/feed-generation.test.ts.snap +37 -0
  201. package/tests/data-plane/__snapshots__/indexing.test.ts.snap +18 -0
  202. package/tests/data-plane/indexing.test.ts +1 -0
  203. package/tests/postgates.test.ts +186 -0
  204. package/tests/seed/feed-hidden-replies.ts +62 -0
  205. package/tests/seed/postgates.ts +56 -0
  206. package/tests/views/__snapshots__/author-feed.test.ts.snap +56 -0
  207. package/tests/views/__snapshots__/block-lists.test.ts.snap +6 -0
  208. package/tests/views/__snapshots__/blocks.test.ts.snap +10 -0
  209. package/tests/views/__snapshots__/list-feed.test.ts.snap +22 -0
  210. package/tests/views/__snapshots__/mute-lists.test.ts.snap +8 -0
  211. package/tests/views/__snapshots__/mutes.test.ts.snap +6 -0
  212. package/tests/views/__snapshots__/posts.test.ts.snap +12 -0
  213. package/tests/views/__snapshots__/quotes.test.ts.snap +399 -0
  214. package/tests/views/__snapshots__/thread.test.ts.snap +50 -0
  215. package/tests/views/__snapshots__/timeline.test.ts.snap +170 -0
  216. package/tests/views/author-feed.test.ts +3 -9
  217. package/tests/views/feed-hidden-replies.test.ts +246 -0
  218. package/tests/views/feed-view-post.test.ts +501 -0
  219. package/tests/views/quotes.test.ts +105 -0
@@ -1,7 +1,7 @@
1
1
  import { BlobRef } from '@atproto/lexicon';
2
2
  import { Record as PostRecord } from '../lexicon/types/app/bsky/feed/post';
3
3
  import { Record as GateRecord } from '../lexicon/types/app/bsky/feed/threadgate';
4
- export declare const creatorFromUri: (uri: string) => string;
4
+ import { Record as PostgateRecord } from '../lexicon/types/app/bsky/feed/postgate';
5
5
  export declare const parseThreadGate: (replierDid: string, ownerDid: string, rootPost: PostRecord | null, gate: GateRecord | null) => ParsedThreadGate;
6
6
  type ParsedThreadGate = {
7
7
  canReply?: boolean;
@@ -10,5 +10,15 @@ type ParsedThreadGate = {
10
10
  allowListUris?: string[];
11
11
  };
12
12
  export declare const cidFromBlobJson: (json: BlobRef) => string;
13
+ export declare const parsePostgate: ({ gate, viewerDid, authorDid, }: {
14
+ gate: PostgateRecord | undefined;
15
+ viewerDid: string | undefined;
16
+ authorDid: string;
17
+ }) => ParsedPostgate;
18
+ type ParsedPostgate = {
19
+ embeddingRules: {
20
+ canEmbed: boolean;
21
+ };
22
+ };
13
23
  export {};
14
24
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/views/util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EACL,MAAM,IAAI,UAAU,EAIrB,MAAM,2CAA2C,CAAA;AAGlD,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,MAE5C,CAAA;AAED,eAAO,MAAM,eAAe,eACd,MAAM,YACR,MAAM,YACN,UAAU,GAAG,IAAI,QACrB,UAAU,GAAG,IAAI,KACtB,gBAyBF,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,eAAe,SAAU,OAAO,WAS5C,CAAA"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/views/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EACL,MAAM,IAAI,UAAU,EAIrB,MAAM,2CAA2C,CAAA;AAClD,OAAO,EACL,MAAM,IAAI,cAAc,EAEzB,MAAM,yCAAyC,CAAA;AAGhD,eAAO,MAAM,eAAe,eACd,MAAM,YACR,MAAM,YACN,UAAU,GAAG,IAAI,QACrB,UAAU,GAAG,IAAI,KACtB,gBAyBF,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,eAAe,SAAU,OAAO,WAS5C,CAAA;AAED,eAAO,MAAM,aAAa,oCAIvB;IACD,IAAI,EAAE,cAAc,GAAG,SAAS,CAAA;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,cAeH,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,cAAc,EAAE;QACd,QAAQ,EAAE,OAAO,CAAA;KAClB,CAAA;CACF,CAAA"}
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cidFromBlobJson = exports.parseThreadGate = exports.creatorFromUri = void 0;
4
- const syntax_1 = require("@atproto/syntax");
3
+ exports.parsePostgate = exports.cidFromBlobJson = exports.parseThreadGate = void 0;
5
4
  const lexicon_1 = require("@atproto/lexicon");
6
5
  const threadgate_1 = require("../lexicon/types/app/bsky/feed/threadgate");
6
+ const postgate_1 = require("../lexicon/types/app/bsky/feed/postgate");
7
7
  const facet_1 = require("../lexicon/types/app/bsky/richtext/facet");
8
- const creatorFromUri = (uri) => {
9
- return new syntax_1.AtUri(uri).hostname;
10
- };
11
- exports.creatorFromUri = creatorFromUri;
12
8
  const parseThreadGate = (replierDid, ownerDid, rootPost, gate) => {
13
9
  if (replierDid === ownerDid) {
14
10
  return { canReply: true };
@@ -17,8 +13,8 @@ const parseThreadGate = (replierDid, ownerDid, rootPost, gate) => {
17
13
  if (!gate || !gate.allow) {
18
14
  return { canReply: true };
19
15
  }
20
- const allowMentions = !!gate.allow.find(threadgate_1.isMentionRule);
21
- const allowFollowing = !!gate.allow.find(threadgate_1.isFollowingRule);
16
+ const allowMentions = gate.allow.some(threadgate_1.isMentionRule);
17
+ const allowFollowing = gate.allow.some(threadgate_1.isFollowingRule);
22
18
  const allowListUris = gate.allow?.filter(threadgate_1.isListRule).map((item) => item.list);
23
19
  // check mentions first since it's quick and synchronous
24
20
  if (allowMentions) {
@@ -43,4 +39,19 @@ const cidFromBlobJson = (json) => {
43
39
  return (json['cid'] ?? '');
44
40
  };
45
41
  exports.cidFromBlobJson = cidFromBlobJson;
42
+ const parsePostgate = ({ gate, viewerDid, authorDid, }) => {
43
+ if (viewerDid === authorDid) {
44
+ return { embeddingRules: { canEmbed: true } };
45
+ }
46
+ // default state is unset, allow everyone
47
+ if (!gate || !gate.embeddingRules) {
48
+ return { embeddingRules: { canEmbed: true } };
49
+ }
50
+ const disabled = gate.embeddingRules.some(postgate_1.isDisableRule);
51
+ if (disabled) {
52
+ return { embeddingRules: { canEmbed: false } };
53
+ }
54
+ return { embeddingRules: { canEmbed: true } };
55
+ };
56
+ exports.parsePostgate = parsePostgate;
46
57
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/views/util.ts"],"names":[],"mappings":";;;AAAA,4CAAuC;AACvC,8CAA0C;AAE1C,0EAKkD;AAClD,oEAAoE;AAE7D,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,OAAO,IAAI,cAAK,CAAC,GAAG,CAAC,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,IAAI,EAAE,EAAE,CAAA;IAC/C,CAAC;IACD,yCAAyC;IACzC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAClC,OAAO,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAA;IAC/C,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAqB,CAAC,CAAA;IAChE,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAA;IAChD,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAA;AAC/C,CAAC,CAAA;AAvBY,QAAA,aAAa,iBAuBzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/bsky",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of app.bsky App View (Bluesky API)",
6
6
  "keywords": [
@@ -40,7 +40,7 @@
40
40
  "structured-headers": "^1.0.1",
41
41
  "typed-emitter": "^2.1.0",
42
42
  "uint8arrays": "3.0.0",
43
- "@atproto/api": "^0.13.1",
43
+ "@atproto/api": "^0.13.2",
44
44
  "@atproto/common": "^0.4.1",
45
45
  "@atproto/crypto": "^0.4.0",
46
46
  "@atproto/identity": "^0.4.0",
@@ -62,9 +62,9 @@
62
62
  "axios": "^0.27.2",
63
63
  "jest": "^28.1.2",
64
64
  "ts-node": "^10.8.2",
65
- "@atproto/api": "^0.13.1",
65
+ "@atproto/api": "^0.13.2",
66
66
  "@atproto/lex-cli": "^0.5.0",
67
- "@atproto/pds": "^0.4.50",
67
+ "@atproto/pds": "^0.4.52",
68
68
  "@atproto/xrpc": "^0.6.0"
69
69
  },
70
70
  "scripts": {
package/proto/bsky.proto CHANGED
@@ -79,6 +79,9 @@ message PostRecordMeta {
79
79
  bool violates_thread_gate = 1;
80
80
  bool has_media = 2;
81
81
  bool is_reply = 3;
82
+ bool violates_embedding_rules = 4;
83
+ bool has_post_gate = 5;
84
+ bool has_thread_gate = 6;
82
85
  }
83
86
 
84
87
  message GetPostRecordsRequest {
@@ -122,6 +125,14 @@ message GetThreadGateRecordsResponse {
122
125
  repeated Record records = 1;
123
126
  }
124
127
 
128
+ message GetPostGateRecordsRequest {
129
+ repeated string uris = 1;
130
+ }
131
+
132
+ message GetPostGateRecordsResponse {
133
+ repeated Record records = 1;
134
+ }
135
+
125
136
  message GetLabelerRecordsRequest {
126
137
  repeated string uris = 1;
127
138
  }
@@ -249,6 +260,23 @@ message GetActorLikesResponse {
249
260
  string cursor = 2;
250
261
  }
251
262
 
263
+ //
264
+ // Quotes
265
+ //
266
+
267
+ message GetQuotesBySubjectRequest {
268
+ RecordRef subject = 1;
269
+ int32 limit = 2;
270
+ string cursor = 3;
271
+ }
272
+
273
+ message GetQuotesBySubjectResponse {
274
+ repeated RecordRef refs = 1;
275
+ string cursor = 2;
276
+ }
277
+
278
+ // - return post uris that quote the given subject uri
279
+
252
280
  //
253
281
  // Interactions
254
282
  //
@@ -260,6 +288,7 @@ message GetInteractionCountsResponse {
260
288
  repeated int32 likes = 1;
261
289
  repeated int32 reposts = 2;
262
290
  repeated int32 replies = 3;
291
+ repeated int32 quotes = 4;
263
292
  }
264
293
 
265
294
  message GetCountsForUsersRequest {
@@ -1068,6 +1097,7 @@ service Service {
1068
1097
  rpc GetActorChatDeclarationRecords(GetActorChatDeclarationRecordsRequest) returns (GetActorChatDeclarationRecordsResponse);
1069
1098
  rpc GetRepostRecords(GetRepostRecordsRequest) returns (GetRepostRecordsResponse);
1070
1099
  rpc GetThreadGateRecords(GetThreadGateRecordsRequest) returns (GetThreadGateRecordsResponse);
1100
+ rpc GetPostGateRecords(GetPostGateRecordsRequest) returns (GetPostGateRecordsResponse);
1071
1101
  rpc GetLabelerRecords(GetLabelerRecordsRequest) returns (GetLabelerRecordsResponse);
1072
1102
  rpc GetStarterPackRecords(GetStarterPackRecordsRequest) returns (GetStarterPackRecordsResponse);
1073
1103
 
@@ -1087,6 +1117,9 @@ service Service {
1087
1117
  rpc GetRepostsByActorAndSubjects(GetRepostsByActorAndSubjectsRequest) returns (GetRepostsByActorAndSubjectsResponse);
1088
1118
  rpc GetActorReposts(GetActorRepostsRequest) returns (GetActorRepostsResponse);
1089
1119
 
1120
+ // Quotes
1121
+ rpc GetQuotesBySubject(GetQuotesBySubjectRequest) returns (GetQuotesBySubjectResponse);
1122
+
1090
1123
  // Interaction Counts
1091
1124
  rpc GetInteractionCounts(GetInteractionCountsRequest) returns (GetInteractionCountsResponse);
1092
1125
  rpc GetCountsForUsers(GetCountsForUsersRequest) returns (GetCountsForUsersResponse);
@@ -13,7 +13,7 @@ import {
13
13
  import { Views } from '../../../../views'
14
14
  import { DataPlaneClient } from '../../../../data-plane'
15
15
  import { parseString } from '../../../../hydration/util'
16
- import { creatorFromUri } from '../../../../views/util'
16
+ import { uriToDid as creatorFromUri } from '../../../../util/uris'
17
17
  import { FeedItem } from '../../../../hydration/feed'
18
18
 
19
19
  export default function (server: Server, ctx: AppContext) {
@@ -11,7 +11,7 @@ import {
11
11
  } from '../../../../hydration/hydrator'
12
12
  import { Views } from '../../../../views'
13
13
  import { parseString } from '../../../../hydration/util'
14
- import { creatorFromUri } from '../../../../views/util'
14
+ import { uriToDid as creatorFromUri } from '../../../../util/uris'
15
15
  import { clearlyBadCursor, resHeaders } from '../../../util'
16
16
  import { InvalidRequestError } from '@atproto/xrpc-server'
17
17
 
@@ -9,7 +9,7 @@ import {
9
9
  Hydrator,
10
10
  } from '../../../../hydration/hydrator'
11
11
  import { Views } from '../../../../views'
12
- import { creatorFromUri } from '../../../../views/util'
12
+ import { uriToDid as creatorFromUri } from '../../../../util/uris'
13
13
  import { resHeaders } from '../../../util'
14
14
  import { ids } from '../../../../lexicon/lexicons'
15
15
 
@@ -0,0 +1,105 @@
1
+ import { Server } from '../../../../lexicon'
2
+ import AppContext from '../../../../context'
3
+ import { createPipeline } from '../../../../pipeline'
4
+ import { clearlyBadCursor, resHeaders } from '../../../util'
5
+ import {
6
+ HydrateCtx,
7
+ HydrationState,
8
+ Hydrator,
9
+ } from '../../../../hydration/hydrator'
10
+ import { Views } from '../../../../views'
11
+ import { mapDefined } from '@atproto/common'
12
+ import { QueryParams } from '../../../../lexicon/types/app/bsky/feed/getQuotes'
13
+ import { ItemRef, parseString } from '../../../../hydration/util'
14
+
15
+ export default function (server: Server, ctx: AppContext) {
16
+ const getQuotes = createPipeline(skeleton, hydration, noBlocks, presentation)
17
+ server.app.bsky.feed.getQuotes({
18
+ auth: ctx.authVerifier.standardOptional,
19
+ handler: async ({ params, auth, req }) => {
20
+ const { viewer, includeTakedowns } = ctx.authVerifier.parseCreds(auth)
21
+ const labelers = ctx.reqLabelers(req)
22
+ const hydrateCtx = await ctx.hydrator.createContext({
23
+ labelers,
24
+ viewer,
25
+ includeTakedowns,
26
+ })
27
+ const result = await getQuotes({ ...params, hydrateCtx }, ctx)
28
+ return {
29
+ encoding: 'application/json',
30
+ body: result,
31
+ headers: resHeaders({ labelers: hydrateCtx.labelers }),
32
+ }
33
+ },
34
+ })
35
+ }
36
+
37
+ const skeleton = async (inputs: {
38
+ ctx: Context
39
+ params: Params
40
+ }): Promise<Skeleton> => {
41
+ const { ctx, params } = inputs
42
+ if (clearlyBadCursor(params.cursor)) {
43
+ return { refs: [] }
44
+ }
45
+ const quotesRes = await ctx.hydrator.dataplane.getQuotesBySubject({
46
+ subject: { uri: params.uri, cid: params.cid },
47
+ cursor: params.cursor,
48
+ limit: params.limit,
49
+ })
50
+ return {
51
+ refs: quotesRes.refs,
52
+ cursor: parseString(quotesRes.cursor),
53
+ }
54
+ }
55
+
56
+ const hydration = async (inputs: {
57
+ ctx: Context
58
+ params: Params
59
+ skeleton: Skeleton
60
+ }) => {
61
+ const { ctx, params, skeleton } = inputs
62
+ return await ctx.hydrator.hydratePosts(skeleton.refs, params.hydrateCtx)
63
+ }
64
+
65
+ const noBlocks = (inputs: {
66
+ ctx: Context
67
+ skeleton: Skeleton
68
+ hydration: HydrationState
69
+ }) => {
70
+ const { ctx, skeleton, hydration } = inputs
71
+ skeleton.refs = skeleton.refs.filter((ref) => {
72
+ return !ctx.views.viewerBlockExists(ref.uri, hydration)
73
+ })
74
+ return skeleton
75
+ }
76
+
77
+ const presentation = (inputs: {
78
+ ctx: Context
79
+ params: Params
80
+ skeleton: Skeleton
81
+ hydration: HydrationState
82
+ }) => {
83
+ const { ctx, params, skeleton, hydration } = inputs
84
+ const postViews = mapDefined(skeleton.refs, (ref) => {
85
+ return ctx.views.post(ref.uri, hydration)
86
+ })
87
+ return {
88
+ posts: postViews,
89
+ cursor: skeleton.cursor,
90
+ uri: params.uri,
91
+ cid: params.cid,
92
+ }
93
+ }
94
+
95
+ type Context = {
96
+ hydrator: Hydrator
97
+ views: Views
98
+ }
99
+
100
+ type Params = QueryParams & { hydrateCtx: HydrateCtx }
101
+
102
+ type Skeleton = {
103
+ refs: ItemRef[]
104
+ cursor?: string
105
+ }
@@ -10,7 +10,7 @@ import {
10
10
  } from '../../../../hydration/hydrator'
11
11
  import { Views } from '../../../../views'
12
12
  import { parseString } from '../../../../hydration/util'
13
- import { creatorFromUri } from '../../../../views/util'
13
+ import { uriToDid as creatorFromUri } from '../../../../util/uris'
14
14
  import { clearlyBadCursor, resHeaders } from '../../../util'
15
15
 
16
16
  export default function (server: Server, ctx: AppContext) {
@@ -14,7 +14,7 @@ import { HydrateCtx, Hydrator } from '../../../../hydration/hydrator'
14
14
  import { Views } from '../../../../views'
15
15
  import { DataPlaneClient } from '../../../../data-plane'
16
16
  import { parseString } from '../../../../hydration/util'
17
- import { creatorFromUri } from '../../../../views/util'
17
+ import { uriToDid as creatorFromUri } from '../../../../util/uris'
18
18
  import { resHeaders } from '../../../util'
19
19
 
20
20
  export default function (server: Server, ctx: AppContext) {
@@ -10,7 +10,7 @@ import {
10
10
  SkeletonFnInput,
11
11
  createPipeline,
12
12
  } from '../../../../pipeline'
13
- import { didFromUri } from '../../../../hydration/util'
13
+ import { uriToDid as didFromUri } from '../../../../util/uris'
14
14
  import {
15
15
  HydrateCtx,
16
16
  Hydrator,
@@ -19,7 +19,7 @@ import {
19
19
  import { Views } from '../../../../views'
20
20
  import { clearlyBadCursor, resHeaders } from '../../../util'
21
21
  import { ListItemInfo } from '../../../../proto/bsky_pb'
22
- import { didFromUri } from '../../../../hydration/util'
22
+ import { uriToDid as didFromUri } from '../../../../util/uris'
23
23
 
24
24
  export default function (server: Server, ctx: AppContext) {
25
25
  const getList = createPipeline(skeleton, hydration, noBlocks, presentation)
@@ -2,6 +2,7 @@ import { InvalidRequestError } from '@atproto/xrpc-server'
2
2
  import { mapDefined } from '@atproto/common'
3
3
  import { Server } from '../../../../lexicon'
4
4
  import { QueryParams } from '../../../../lexicon/types/app/bsky/notification/listNotifications'
5
+ import { isRecord as isPostRecord } from '../../../../lexicon/types/app/bsky/feed/post'
5
6
  import AppContext from '../../../../context'
6
7
  import {
7
8
  createPipeline,
@@ -13,7 +14,7 @@ import {
13
14
  import { HydrateCtx, Hydrator } from '../../../../hydration/hydrator'
14
15
  import { Views } from '../../../../views'
15
16
  import { Notification } from '../../../../proto/bsky_pb'
16
- import { didFromUri } from '../../../../hydration/util'
17
+ import { uriToDid as didFromUri } from '../../../../util/uris'
17
18
  import { clearlyBadCursor, resHeaders } from '../../../util'
18
19
 
19
20
  export default function (server: Server, ctx: AppContext) {
@@ -90,13 +91,38 @@ const hydration = async (
90
91
  const noBlockOrMutes = (
91
92
  input: RulesFnInput<Context, Params, SkeletonState>,
92
93
  ) => {
93
- const { skeleton, hydration, ctx } = input
94
+ const { skeleton, hydration, ctx, params } = input
94
95
  skeleton.notifs = skeleton.notifs.filter((item) => {
95
96
  const did = didFromUri(item.uri)
96
- return (
97
- !ctx.views.viewerBlockExists(did, hydration) &&
98
- !ctx.views.viewerMuteExists(did, hydration)
99
- )
97
+ if (
98
+ ctx.views.viewerBlockExists(did, hydration) ||
99
+ ctx.views.viewerMuteExists(did, hydration)
100
+ ) {
101
+ return false
102
+ }
103
+ // Filter out hidden replies only if the viewer owns
104
+ // the threadgate and they hid the reply.
105
+ if (item.reason === 'reply') {
106
+ const post = hydration.posts?.get(item.uri)
107
+ if (post) {
108
+ const rootPostUri = isPostRecord(post.record)
109
+ ? post.record.reply?.root.uri
110
+ : undefined
111
+ const isRootPostByViewer =
112
+ rootPostUri && didFromUri(rootPostUri) === params.hydrateCtx?.viewer
113
+ const isHiddenReply = isRootPostByViewer
114
+ ? ctx.views.replyIsHiddenByThreadgate(
115
+ item.uri,
116
+ rootPostUri,
117
+ hydration,
118
+ )
119
+ : false
120
+ if (isHiddenReply) {
121
+ return false
122
+ }
123
+ }
124
+ }
125
+ return true
100
126
  })
101
127
  return skeleton
102
128
  }
package/src/api/index.ts CHANGED
@@ -13,6 +13,7 @@ import getPostThread from './app/bsky/feed/getPostThread'
13
13
  import getPosts from './app/bsky/feed/getPosts'
14
14
  import searchPosts from './app/bsky/feed/searchPosts'
15
15
  import getActorLikes from './app/bsky/feed/getActorLikes'
16
+ import getQuotes from './app/bsky/feed/getQuotes'
16
17
  import getProfile from './app/bsky/actor/getProfile'
17
18
  import getProfiles from './app/bsky/actor/getProfiles'
18
19
  import getRepostedBy from './app/bsky/feed/getRepostedBy'
@@ -72,6 +73,7 @@ export default function (server: Server, ctx: AppContext) {
72
73
  getFeedGenerators(server, ctx)
73
74
  getLikes(server, ctx)
74
75
  getListFeed(server, ctx)
76
+ getQuotes(server, ctx)
75
77
  getPostThread(server, ctx)
76
78
  getPosts(server, ctx)
77
79
  searchPosts(server, ctx)
@@ -6,7 +6,8 @@ import * as post from './tables/post'
6
6
  import * as postEmbed from './tables/post-embed'
7
7
  import * as postAgg from './tables/post-agg'
8
8
  import * as repost from './tables/repost'
9
- import * as threadGate from './tables/thread-gate'
9
+ import * as threadgate from './tables/thread-gate'
10
+ import * as postgate from './tables/post-gate'
10
11
  import * as feedItem from './tables/feed-item'
11
12
  import * as follow from './tables/follow'
12
13
  import * as like from './tables/like'
@@ -35,6 +36,7 @@ import * as taggedSuggestion from './tables/tagged-suggestion'
35
36
  import * as blobTakedown from './tables/blob-takedown'
36
37
  import * as labeler from './tables/labeler'
37
38
  import * as starterPack from './tables/starter-pack'
39
+ import * as quote from './tables/quote'
38
40
 
39
41
  export type DatabaseSchemaType = duplicateRecord.PartialDB &
40
42
  profile.PartialDB &
@@ -43,7 +45,8 @@ export type DatabaseSchemaType = duplicateRecord.PartialDB &
43
45
  postEmbed.PartialDB &
44
46
  postAgg.PartialDB &
45
47
  repost.PartialDB &
46
- threadGate.PartialDB &
48
+ threadgate.PartialDB &
49
+ postgate.PartialDB &
47
50
  feedItem.PartialDB &
48
51
  follow.PartialDB &
49
52
  like.PartialDB &
@@ -71,7 +74,8 @@ export type DatabaseSchemaType = duplicateRecord.PartialDB &
71
74
  blobTakedown.PartialDB &
72
75
  labeler.PartialDB &
73
76
  starterPack.PartialDB &
74
- taggedSuggestion.PartialDB
77
+ taggedSuggestion.PartialDB &
78
+ quote.PartialDB
75
79
 
76
80
  export type DatabaseSchema = Kysely<DatabaseSchemaType>
77
81
 
@@ -0,0 +1,12 @@
1
+ import { Kysely } from 'kysely'
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await db.schema
5
+ .alterTable('post_agg')
6
+ .addColumn('quoteCount', 'bigint', (col) => col.notNull().defaultTo(0))
7
+ .execute()
8
+ }
9
+
10
+ export async function down(db: Kysely<unknown>): Promise<void> {
11
+ await db.schema.alterTable('post_agg').dropColumn('quoteCount').execute()
12
+ }
@@ -0,0 +1,28 @@
1
+ import { Kysely, sql } from 'kysely'
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await db.schema
5
+ .createTable('quote')
6
+ .addColumn('uri', 'varchar', (col) => col.primaryKey())
7
+ .addColumn('cid', 'varchar', (col) => col.notNull())
8
+ .addColumn('subject', 'varchar', (col) => col.notNull())
9
+ .addColumn('subjectCid', 'varchar', (col) => col.notNull())
10
+ .addColumn('createdAt', 'varchar', (col) => col.notNull())
11
+ .addColumn('indexedAt', 'varchar', (col) => col.notNull())
12
+ .addColumn('sortAt', 'varchar', (col) =>
13
+ col
14
+ .generatedAlwaysAs(sql`least("createdAt", "indexedAt")`)
15
+ .stored()
16
+ .notNull(),
17
+ )
18
+ .execute()
19
+ await db.schema
20
+ .createIndex('quote_subject_cursor_idx')
21
+ .on('quote')
22
+ .columns(['subject', 'sortAt', 'cid'])
23
+ .execute()
24
+ }
25
+
26
+ export async function down(db: Kysely<unknown>): Promise<void> {
27
+ await db.schema.dropTable('quote').execute()
28
+ }
@@ -0,0 +1,17 @@
1
+ import { Kysely } from 'kysely'
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await db.schema
5
+ .createTable('post_gate')
6
+ .addColumn('uri', 'varchar', (col) => col.primaryKey())
7
+ .addColumn('cid', 'varchar', (col) => col.notNull())
8
+ .addColumn('creator', 'varchar', (col) => col.notNull())
9
+ .addColumn('postUri', 'varchar', (col) => col.notNull().unique())
10
+ .addColumn('createdAt', 'varchar', (col) => col.notNull())
11
+ .addColumn('indexedAt', 'varchar', (col) => col.notNull())
12
+ .execute()
13
+ }
14
+
15
+ export async function down(db: Kysely<unknown>): Promise<void> {
16
+ await db.schema.dropTable('post_gate').execute()
17
+ }
@@ -0,0 +1,25 @@
1
+ import { Kysely } from 'kysely'
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await db.schema
5
+ .alterTable('post')
6
+ .addColumn('violatesEmbeddingRules', 'boolean')
7
+ .execute()
8
+ await db.schema
9
+ .alterTable('post')
10
+ .addColumn('hasThreadGate', 'boolean')
11
+ .execute()
12
+ await db.schema
13
+ .alterTable('post')
14
+ .addColumn('hasPostGate', 'boolean')
15
+ .execute()
16
+ }
17
+
18
+ export async function down(db: Kysely<unknown>): Promise<void> {
19
+ await db.schema
20
+ .alterTable('post')
21
+ .dropColumn('violatesEmbeddingRules')
22
+ .execute()
23
+ await db.schema.alterTable('post').dropColumn('hasThreadGate').execute()
24
+ await db.schema.alterTable('post').dropColumn('hasPostGate').execute()
25
+ }
@@ -38,3 +38,7 @@ export * as _20240530T170337073Z from './20240530T170337073Z-account-deactivatio
38
38
  export * as _20240606T171229898Z from './20240606T171229898Z-thread-mutes'
39
39
  export * as _20240606T222548219Z from './20240606T222548219Z-starter-packs'
40
40
  export * as _20240719T203853939Z from './20240719T203853939Z-priority-notifs'
41
+ export * as _20240723T220700077Z from './20240723T220700077Z-quotes-post-aggs'
42
+ export * as _20240723T220703655Z from './20240723T220703655Z-quotes'
43
+ export * as _20240801T193939827Z from './20240801T193939827Z-post-gate'
44
+ export * as _20240808T224251220Z from './20240808T224251220Z-post-gate-flags'
@@ -7,6 +7,7 @@ export interface PostAgg {
7
7
  likeCount: Generated<number>
8
8
  replyCount: Generated<number>
9
9
  repostCount: Generated<number>
10
+ quoteCount: Generated<number>
10
11
  }
11
12
 
12
13
  export type PartialDB = {
@@ -0,0 +1,12 @@
1
+ const tableName = 'post_gate'
2
+
3
+ export interface Postgate {
4
+ uri: string
5
+ cid: string
6
+ creator: string
7
+ postUri: string
8
+ createdAt: string
9
+ indexedAt: string
10
+ }
11
+
12
+ export type PartialDB = { [tableName]: Postgate }
@@ -15,6 +15,9 @@ export interface Post {
15
15
  tags: string[] | null
16
16
  invalidReplyRoot: boolean | null
17
17
  violatesThreadGate: boolean | null
18
+ violatesEmbeddingRules: boolean | null
19
+ hasThreadGate: boolean | null
20
+ hasPostGate: boolean | null
18
21
  createdAt: string
19
22
  indexedAt: string
20
23
  sortAt: GeneratedAlways<string>
@@ -0,0 +1,15 @@
1
+ import { GeneratedAlways } from 'kysely'
2
+
3
+ const tableName = 'quote'
4
+
5
+ export interface Quote {
6
+ uri: string
7
+ cid: string
8
+ subject: string
9
+ subjectCid: string
10
+ createdAt: string
11
+ indexedAt: string
12
+ sortAt: GeneratedAlways<string>
13
+ }
14
+
15
+ export type PartialDB = { [tableName]: Quote }