@openpeepshq/core 0.5.1 → 0.5.2

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.
@@ -14,13 +14,14 @@ export type CrawlableMeta = {
14
14
  authorName?: string;
15
15
  };
16
16
  /**
17
- * Metadata plus whether the route could render at all, so the server can answer
18
- * 404 for a content path that will never show anything to a crawler instead of
19
- * a 200 community shell.
17
+ * Metadata for a content page when resolvable and anonymously readable; `null`
18
+ * when the entity is missing or unreadable (an anonymous fetch must not be
19
+ * able to tell those two apart — that would leak which ids exist). Renderers
20
+ * answer every content route with a 200 shell and let `noindex` carry the
21
+ * "not for crawlers" signal instead of a status code.
20
22
  */
21
23
  export type SpaMeta = {
22
24
  meta: CrawlableMeta | null;
23
- notFound: boolean;
24
25
  };
25
26
  export { seoRoute, type SeoRoute, type SeoRouteKind } from './route';
26
27
  /** Publicly readable pages, newest first. Events are posts and have no route of
@@ -35,10 +36,11 @@ export declare const crawlableEntries: ({ indexProfiles, }: {
35
36
  indexProfiles: boolean;
36
37
  }) => Promise<CrawlableEntry[]>;
37
38
  /**
38
- * Metadata for a content route, plus whether it can render at all, so a shared
39
- * post is not described to every crawler as the community homepage and an
40
- * unknown id is not served as a 200. Negatives are cached as well: a bot
41
- * probing unknown ids should not turn each request into a query. Profile
39
+ * Metadata for a content route, or null when the entity is missing or not
40
+ * anonymously readable, so a shared post is not described to every crawler as
41
+ * the community homepage. Missing and unreadable resolve to the same null so an
42
+ * anonymous fetcher cannot distinguish them. Negatives are cached as well: a
43
+ * bot probing unknown ids should not turn each request into a query. Profile
42
44
  * metadata additionally requires the `indexProfiles` flag.
43
45
  */
44
46
  export declare const spaMetaForPath: (pathname: string, { indexProfiles }: {
package/dist/seo/index.js CHANGED
@@ -12,10 +12,10 @@ export { seoRoute } from './route.js';
12
12
  * cap is what keeps a crawler sweep from turning into a full content scan.
13
13
  */
14
14
  const PER_KIND_LIMIT = 1_000;
15
- // Versioned because the cached shape gained `notFound` and later the
16
- // JSON-LD fields: an old entry must never be read as the new one during a
17
- // rolling restart.
18
- const META_CACHE_PREFIX = 'seo:meta:v3:';
15
+ // Versioned because the semantics changed: `null` no longer implies a route
16
+ // that cannot render, so an old entry must never be read as the new one during
17
+ // a rolling restart.
18
+ const META_CACHE_PREFIX = 'seo:meta:v5:';
19
19
  const META_TTL_SECONDS = 5 * 60;
20
20
  /**
21
21
  * An anonymous visitor: no profile, no scopes. That is the whole access rule.
@@ -69,14 +69,14 @@ export const crawlableEntries = async ({ indexProfiles, }) => {
69
69
  const resolveMeta = async (pathname, indexProfiles) => {
70
70
  const route = seoRoute(pathname, { indexProfiles });
71
71
  if (!route)
72
- return { meta: null, notFound: false };
72
+ return { meta: null };
73
73
  if (route.kind === 'post') {
74
74
  const post = await findPost(route.handle);
75
75
  // findPost has no visibility gate of its own — `toFilteredPostsList` applies
76
76
  // it for lists — so the read rule is re-applied here rather than trusted.
77
77
  if (!post ||
78
78
  !(await canReadPost(await capabilitiesConfig(), ANONYMOUS)(post)))
79
- return { meta: null, notFound: true };
79
+ return { meta: null };
80
80
  const body = 'content' in post.data
81
81
  ? post.data.content
82
82
  : 'name' in post.data
@@ -95,7 +95,6 @@ const resolveMeta = async (pathname, indexProfiles) => {
95
95
  authorName: post.profile?.displayName ||
96
96
  (post.profile?.handle ? `@${post.profile.handle}` : undefined),
97
97
  },
98
- notFound: false,
99
98
  };
100
99
  }
101
100
  if (route.kind === 'group') {
@@ -103,32 +102,31 @@ const resolveMeta = async (pathname, indexProfiles) => {
103
102
  // Groups have no visibility column; this mirrors
104
103
  // `groupFilters.publiclyReadable()`, which reads the same capability.
105
104
  if (!group?.capabilities?.none?.add?.includes('core-groups-read'))
106
- return { meta: null, notFound: true };
105
+ return { meta: null };
107
106
  const groupTitle = group.displayName || `@${group.handle}`;
108
107
  return {
109
108
  meta: {
110
109
  title: groupTitle,
111
110
  description: excerpt(group.description, groupTitle),
112
111
  },
113
- notFound: false,
114
112
  };
115
113
  }
116
114
  const profile = await findProfileByHandle(route.handle);
117
115
  if (!profile)
118
- return { meta: null, notFound: true };
116
+ return { meta: null };
119
117
  return {
120
118
  meta: {
121
119
  title: profile.displayName || `@${profile.handle}`,
122
120
  description: excerpt(profile.bio, `@${profile.handle}`),
123
121
  },
124
- notFound: false,
125
122
  };
126
123
  };
127
124
  /**
128
- * Metadata for a content route, plus whether it can render at all, so a shared
129
- * post is not described to every crawler as the community homepage and an
130
- * unknown id is not served as a 200. Negatives are cached as well: a bot
131
- * probing unknown ids should not turn each request into a query. Profile
125
+ * Metadata for a content route, or null when the entity is missing or not
126
+ * anonymously readable, so a shared post is not described to every crawler as
127
+ * the community homepage. Missing and unreadable resolve to the same null so an
128
+ * anonymous fetcher cannot distinguish them. Negatives are cached as well: a
129
+ * bot probing unknown ids should not turn each request into a query. Profile
132
130
  * metadata additionally requires the `indexProfiles` flag.
133
131
  */
134
132
  export const spaMetaForPath = async (pathname, { indexProfiles }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "dependencies": {
@@ -37,10 +37,10 @@
37
37
  "type-fest": "^4.31.0",
38
38
  "uuidv7": "^1.0.2",
39
39
  "web-push": "^3.6.7",
40
- "@openpeepshq/common": "0.6.1",
41
- "@openpeepshq/i18n": "^0.7.0",
40
+ "@openpeepshq/fetch-client": "^0.2.1",
41
+ "@openpeepshq/common": "0.6.3",
42
42
  "@openpeepshq/geocoder": "^0.1.2",
43
- "@openpeepshq/fetch-client": "^0.2.1"
43
+ "@openpeepshq/i18n": "^0.7.0"
44
44
  },
45
45
  "main": "dist/index.js",
46
46
  "types": "dist/index.d.ts",
@@ -66,7 +66,7 @@
66
66
  "@typescript-eslint/eslint-plugin": "^8.72.0",
67
67
  "@typescript-eslint/parser": "^8.72.0",
68
68
  "concurrently": "^9.2.5",
69
- "drizzle-kit": "^0.31.1",
69
+ "drizzle-kit": "^0.31.11",
70
70
  "eslint": "^10.14.0",
71
71
  "eslint-config-prettier": "^9.1.0",
72
72
  "google-auth-library": "^10.7.0",