@openpeepshq/core 0.17.0 → 0.19.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/seo/route.js CHANGED
@@ -1,3 +1,51 @@
1
+ /**
2
+ * Pure parsing of the content routes the crawler layer recognises. Kept free of
3
+ * data-layer imports so the rules are unit-testable and so this can be loaded
4
+ * where opening a database connection would be wrong.
5
+ */
6
+ import { isHandleShapedSlug } from '@openpeepshq/common/lib';
7
+ /**
8
+ * Top-level segments that own a route in the web app and therefore can never
9
+ * be a slug path. Kept in sync with `platform/web` routes.
10
+ */
11
+ export const RESERVED_TOP_LEVEL_ROUTES = [
12
+ 'about',
13
+ 'articles',
14
+ 'auth',
15
+ 'admin',
16
+ 'code-of-conduct',
17
+ 'conversations',
18
+ 'docs',
19
+ 'events',
20
+ 'explore',
21
+ 'feeds',
22
+ 'groups',
23
+ 'home',
24
+ 'jams',
25
+ 'members',
26
+ 'notifications',
27
+ 'payment',
28
+ 'plugins',
29
+ 'posts',
30
+ 'resources',
31
+ 'settings',
32
+ 'tags',
33
+ 'test',
34
+ 'welcome',
35
+ ];
36
+ /**
37
+ * A profile handle is 1–16 characters of `[a-zA-Z0-9_-]`, so the web router's
38
+ * `/:handle` route owns every bare slug-shaped segment of length ≤ 16 (a slug
39
+ * is lowercase/digits/hyphens only, a subset of handle shape). Such a segment
40
+ * can never resolve as an instance-scoped slug — `/my-slug` loads the profile
41
+ * page for handle `my-slug`, or 404s. Longer slug-shaped segments can be no
42
+ * handle, so only those qualify as instance slugs. The plugin's availability
43
+ * check enforces the same rule at write time. The shape is shared from
44
+ * `@openpeepshq/common/lib` (single source of truth).
45
+ */
46
+ export const isHandleShaped = isHandleShapedSlug;
47
+ /** Profile sub-routes the web router owns under `/:handle/<x>`. */
48
+ export const RESERVED_PROFILE_SUBROUTES = ['followers', 'following'];
1
49
  /**
2
50
  * A trailing slash addresses the same page as the bare path; `webNavigator`
3
51
  * never emits one, so the canonical spelling has none. Tolerating it here stops
@@ -12,8 +60,41 @@ export const seoRoute = (pathname, { indexProfiles }) => {
12
60
  const group = /^\/groups\/@?([^/]+?)\/?$/.exec(pathname)?.[1];
13
61
  if (group)
14
62
  return { kind: 'group', handle: group };
15
- if (!indexProfiles)
16
- return null;
17
- const profile = /^\/@([^/]+?)\/?$/.exec(pathname)?.[1];
18
- return profile ? { kind: 'profile', handle: profile } : null;
63
+ // Only the `/@handle` profile route is gated by `indexProfiles`; article
64
+ // slugs (below) are post routes and resolve regardless, matching the sitemap.
65
+ if (indexProfiles) {
66
+ const profile = /^\/@([^/]+?)\/?$/.exec(pathname)?.[1];
67
+ if (profile)
68
+ return { kind: 'profile', handle: profile };
69
+ }
70
+ // Article slugs are post routes, not profile routes: a slug URL is a clean
71
+ // spelling of an article that `crawlableEntries()` always advertises in the
72
+ // sitemap (posts are never gated by `indexProfiles`). So slug recognition
73
+ // must run regardless of the flag — otherwise a community with profile
74
+ // indexing off would advertise `/{slug}` in its sitemap while the meta and
75
+ // canonical-redirect resolvers treat it as a non-route.
76
+ //
77
+ // Profile-scoped article slug: `/{handle}/{slug}` (or `/@handle/{slug}`).
78
+ // The handle may not be a real profile — the slug finder then resolves
79
+ // nothing, which is the same as a route that was never recognised.
80
+ const profileSlug = /^\/(?:@)?([^/]+)\/([\w-]+)\/?$/.exec(pathname);
81
+ if (profileSlug &&
82
+ !RESERVED_TOP_LEVEL_ROUTES.includes(profileSlug[1]) &&
83
+ !RESERVED_PROFILE_SUBROUTES.includes(profileSlug[2])) {
84
+ return {
85
+ kind: 'slug',
86
+ handle: profileSlug[1],
87
+ slug: profileSlug[2],
88
+ instanceScoped: false,
89
+ };
90
+ }
91
+ // Instance-scoped article slug: bare `/{slug}`. Handle-shaped segments are
92
+ // owned by the `/:handle` profile route, so only the rest qualify.
93
+ const instanceSlug = /^\/([\w-]+)\/?$/.exec(pathname)?.[1];
94
+ if (instanceSlug &&
95
+ !RESERVED_TOP_LEVEL_ROUTES.includes(instanceSlug) &&
96
+ !isHandleShaped(instanceSlug)) {
97
+ return { kind: 'slug', slug: instanceSlug, instanceScoped: true };
98
+ }
99
+ return null;
19
100
  };
@@ -8,6 +8,9 @@ export declare const serverInfo: () => Promise<{
8
8
  version: string;
9
9
  environment: string;
10
10
  publicContent: boolean;
11
+ federation: {
12
+ active: boolean;
13
+ };
11
14
  startedAt: string;
12
15
  uptimeSeconds: number;
13
16
  disk: {
@@ -44,6 +44,7 @@ export const serverInfo = () => config().then(async (coreConfig) => {
44
44
  build: process.env.BUILD?.trim() || undefined,
45
45
  environment: coreConfig.environment,
46
46
  publicContent: coreConfig.server.publicContent,
47
+ federation: { active: coreConfig.federation.active },
47
48
  startedAt: processStartedAt,
48
49
  uptimeSeconds: roundDownUptimeSeconds(Math.floor(process.uptime())),
49
50
  disk,
@@ -200,6 +200,8 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
200
200
  language?: string | undefined;
201
201
  image?: string | undefined;
202
202
  title?: string | undefined;
203
+ slug?: string | undefined;
204
+ instanceScoped?: boolean | undefined;
203
205
  } | {
204
206
  type: "resource";
205
207
  title: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/core",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
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.18.0",
41
- "@openpeepshq/fetch-client": "^0.2.1",
40
+ "@openpeepshq/common": "0.20.0",
42
41
  "@openpeepshq/geocoder": "^0.1.2",
43
- "@openpeepshq/i18n": "^0.20.0"
42
+ "@openpeepshq/fetch-client": "^0.3.0",
43
+ "@openpeepshq/i18n": "^0.29.0"
44
44
  },
45
45
  "main": "dist/index.js",
46
46
  "types": "dist/index.d.ts",
@@ -69,7 +69,6 @@
69
69
  "drizzle-kit": "^0.31.11",
70
70
  "eslint": "^10.14.0",
71
71
  "eslint-config-prettier": "^9.1.0",
72
- "google-auth-library": "^10.7.0",
73
72
  "i18next": "^26.3.4",
74
73
  "prettier": "^3.4.2",
75
74
  "tsc-alias": "^1.8.10",