@clioplaylists/clio 0.1.7 → 0.1.9

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 (129) hide show
  1. package/dist/api/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.d.ts +3 -0
  2. package/dist/api/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.js +70 -0
  3. package/dist/api/health.js +10 -3
  4. package/dist/api/index.d.ts +1 -0
  5. package/dist/api/index.js +40 -2
  6. package/dist/api/oauth.d.ts +3 -0
  7. package/dist/api/oauth.js +63 -0
  8. package/dist/api/util.d.ts +1 -0
  9. package/dist/api/util.js +11 -6
  10. package/dist/api/well-known.d.ts +3 -0
  11. package/dist/api/well-known.js +35 -0
  12. package/dist/auth-verifier.d.ts +17 -4
  13. package/dist/auth-verifier.js +171 -165
  14. package/dist/client.js +15 -8
  15. package/dist/config.d.ts +23 -0
  16. package/dist/config.js +87 -7
  17. package/dist/context.d.ts +14 -0
  18. package/dist/context.js +17 -1
  19. package/dist/dataplane/client/hosts.d.ts +21 -0
  20. package/dist/dataplane/client/hosts.js +29 -0
  21. package/dist/dataplane/client/index.d.ts +13 -0
  22. package/dist/dataplane/client/index.js +120 -0
  23. package/dist/dataplane/client/util.d.ts +20 -0
  24. package/dist/dataplane/client/util.js +92 -0
  25. package/dist/dataplane/index.js +18 -2
  26. package/dist/dataplane/server/background.d.ts +1 -1
  27. package/dist/dataplane/server/background.js +12 -5
  28. package/dist/dataplane/server/db/database-schema.d.ts +5 -1
  29. package/dist/dataplane/server/db/database-schema.js +2 -1
  30. package/dist/dataplane/server/db/db.js +60 -20
  31. package/dist/dataplane/server/db/index.js +17 -1
  32. package/dist/dataplane/server/db/migrations/20250515T045948368Z-init.d.ts +3 -0
  33. package/dist/dataplane/server/db/migrations/20250515T045948368Z-init.js +170 -0
  34. package/dist/dataplane/server/db/migrations/20260119T210000000Z-song-recommendation.d.ts +3 -0
  35. package/dist/dataplane/server/db/migrations/20260119T210000000Z-song-recommendation.js +36 -0
  36. package/dist/dataplane/server/db/migrations/20260119T220000000Z-oauth.d.ts +3 -0
  37. package/dist/dataplane/server/db/migrations/20260119T220000000Z-oauth.js +25 -0
  38. package/dist/dataplane/server/db/migrations/index.d.ts +3 -2
  39. package/dist/dataplane/server/db/migrations/index.js +39 -2
  40. package/dist/dataplane/server/db/migrations/provider.js +5 -1
  41. package/dist/dataplane/server/db/pagination.d.ts +1 -1
  42. package/dist/dataplane/server/db/pagination.js +38 -25
  43. package/dist/dataplane/server/db/tables/actor-sync.d.ts +2 -2
  44. package/dist/dataplane/server/db/tables/actor-sync.js +4 -1
  45. package/dist/dataplane/server/db/tables/actor.d.ts +3 -3
  46. package/dist/dataplane/server/db/tables/actor.js +4 -1
  47. package/dist/dataplane/server/db/tables/artist-list-item.d.ts +2 -2
  48. package/dist/dataplane/server/db/tables/artist-list-item.js +4 -1
  49. package/dist/dataplane/server/db/tables/artist.js +4 -1
  50. package/dist/dataplane/server/db/tables/oauth-session.d.ts +9 -0
  51. package/dist/dataplane/server/db/tables/oauth-session.js +4 -0
  52. package/dist/dataplane/server/db/tables/oauth-state.d.ts +10 -0
  53. package/dist/dataplane/server/db/tables/oauth-state.js +4 -0
  54. package/dist/dataplane/server/db/tables/playlist-idea.d.ts +3 -3
  55. package/dist/dataplane/server/db/tables/playlist-idea.js +4 -1
  56. package/dist/dataplane/server/db/tables/playlist-item.js +4 -1
  57. package/dist/dataplane/server/db/tables/playlist.d.ts +1 -0
  58. package/dist/dataplane/server/db/tables/playlist.js +4 -1
  59. package/dist/dataplane/server/db/tables/profile.d.ts +5 -5
  60. package/dist/dataplane/server/db/tables/profile.js +4 -1
  61. package/dist/dataplane/server/db/tables/record.d.ts +1 -1
  62. package/dist/dataplane/server/db/tables/record.js +4 -1
  63. package/dist/dataplane/server/db/tables/song-recommendation.d.ts +17 -0
  64. package/dist/dataplane/server/db/tables/song-recommendation.js +4 -0
  65. package/dist/dataplane/server/db/tables/song.d.ts +2 -2
  66. package/dist/dataplane/server/db/tables/song.js +4 -1
  67. package/dist/dataplane/server/db/tables/subscription-cursor.d.ts +9 -0
  68. package/dist/dataplane/server/db/tables/subscription-cursor.js +4 -0
  69. package/dist/dataplane/server/db/types.js +2 -1
  70. package/dist/dataplane/server/db/util.d.ts +7 -3
  71. package/dist/dataplane/server/db/util.js +26 -18
  72. package/dist/dataplane/server/index.js +21 -13
  73. package/dist/dataplane/server/indexing/index.d.ts +2 -0
  74. package/dist/dataplane/server/indexing/index.js +82 -66
  75. package/dist/dataplane/server/indexing/plugins/playlist-idea.d.ts +1 -2
  76. package/dist/dataplane/server/indexing/plugins/playlist-idea.js +50 -41
  77. package/dist/dataplane/server/indexing/plugins/profile.js +45 -12
  78. package/dist/dataplane/server/indexing/plugins/song-recommendation.d.ts +9 -0
  79. package/dist/dataplane/server/indexing/plugins/song-recommendation.js +101 -0
  80. package/dist/dataplane/server/indexing/processor.js +12 -11
  81. package/dist/dataplane/server/routes/identity.d.ts +19 -0
  82. package/dist/dataplane/server/routes/identity.js +32 -25
  83. package/dist/dataplane/server/routes/index.js +15 -10
  84. package/dist/dataplane/server/routes/profile.js +17 -25
  85. package/dist/dataplane/server/routes/records.d.ts +18 -0
  86. package/dist/dataplane/server/routes/records.js +48 -22
  87. package/dist/dataplane/server/routes/sync.js +5 -3
  88. package/dist/dataplane/server/storage/subscription-cursor.d.ts +3 -0
  89. package/dist/dataplane/server/storage/subscription-cursor.js +25 -0
  90. package/dist/dataplane/server/subscription.d.ts +6 -3
  91. package/dist/dataplane/server/subscription.js +73 -63
  92. package/dist/error.js +9 -5
  93. package/dist/index.d.ts +8 -3
  94. package/dist/index.js +96 -27
  95. package/dist/lexicons/index.d.ts +3 -210
  96. package/dist/lexicons/index.js +26 -403
  97. package/dist/lexicons/lexicons.d.ts +409 -8107
  98. package/dist/lexicons/lexicons.js +134 -4276
  99. package/dist/lexicons/types/com/atproto/repo/strongRef.d.ts +4 -4
  100. package/dist/lexicons/types/com/atproto/repo/strongRef.js +13 -9
  101. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.d.ts +10 -8
  102. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.js +13 -9
  103. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.d.ts +20 -11
  104. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.js +29 -14
  105. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.d.ts +36 -0
  106. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.js +6 -0
  107. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.d.ts +11 -14
  108. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.js +20 -23
  109. package/dist/lexicons/types/com/clioplaylists/alpha/feed/recommendedPlaylist.d.ts +18 -0
  110. package/dist/lexicons/types/com/clioplaylists/alpha/feed/recommendedPlaylist.js +15 -0
  111. package/dist/lexicons/types/com/clioplaylists/alpha/feed/songRecommendation.d.ts +18 -0
  112. package/dist/lexicons/types/com/clioplaylists/alpha/feed/songRecommendation.js +15 -0
  113. package/dist/lexicons/util.d.ts +33 -2
  114. package/dist/lexicons/util.js +32 -4
  115. package/dist/logger.js +16 -10
  116. package/dist/oauth/client.d.ts +14 -0
  117. package/dist/oauth/client.js +126 -0
  118. package/dist/oauth/pds-agent.d.ts +3 -0
  119. package/dist/oauth/pds-agent.js +15 -0
  120. package/dist/rpc/clio_connect.d.ts +101 -11
  121. package/dist/rpc/clio_connect.js +138 -45
  122. package/dist/rpc/clio_pb.d.ts +448 -30
  123. package/dist/rpc/clio_pb.js +967 -272
  124. package/dist/start.js +9 -1
  125. package/dist/util/retry.js +10 -9
  126. package/dist/util/uris.js +6 -3
  127. package/dist/util.d.ts +0 -1
  128. package/dist/util.js +61 -20
  129. package/package.json +26 -5
package/dist/start.js CHANGED
@@ -1,13 +1,21 @@
1
1
  'use strict';
2
+ const assert = require('node:assert');
2
3
  const { ClioAppView } = require('./index');
3
4
  const { ServerConfig } = require('./config');
5
+ const { Secp256k1Keypair } = require('@atproto/crypto');
4
6
  const main = async () => {
7
+ const env = getEnv();
5
8
  const config = ServerConfig.readEnv();
6
- const clio = ClioAppView.create({ config });
9
+ assert(env.serviceSigningKey, 'must set BSKY_SERVICE_SIGNING_KEY');
10
+ const signingKey = await Secp256k1Keypair.import(env.serviceSigningKey);
11
+ const clio = ClioAppView.create({ config, signingKey });
7
12
  await clio.start();
8
13
  const shutdown = async () => {
9
14
  await clio.destroy();
10
15
  };
11
16
  process.on('SIGTERM', shutdown);
12
17
  };
18
+ const getEnv = () => ({
19
+ serviceSigningKey: process.env.BSKY_SERVICE_SIGNING_KEY || undefined,
20
+ });
13
21
  main();
@@ -1,13 +1,14 @@
1
- import { createRetryable } from '@atproto/common';
2
- import { ResponseType, XRPCError } from '@atproto/xrpc';
3
- export const RETRYABLE_HTTP_STATUS_CODES = new Set([
4
- 408, 425, 429, 500, 502, 503, 504, 522, 524,
5
- ]);
6
- export const retryXrpc = createRetryable((err) => {
7
- if (err instanceof XRPCError) {
8
- if (err.status === ResponseType.Unknown)
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.retryXrpc = exports.RETRYABLE_HTTP_STATUS_CODES = void 0;
4
+ const common_1 = require("@atproto/common");
5
+ const xrpc_1 = require("@atproto/xrpc");
6
+ exports.RETRYABLE_HTTP_STATUS_CODES = new Set([408, 425, 429, 500, 502, 503, 504, 522, 524]);
7
+ exports.retryXrpc = (0, common_1.createRetryable)((err) => {
8
+ if (err instanceof xrpc_1.XRPCError) {
9
+ if (err.status === xrpc_1.ResponseType.Unknown)
9
10
  return true;
10
- return RETRYABLE_HTTP_STATUS_CODES.has(err.status);
11
+ return exports.RETRYABLE_HTTP_STATUS_CODES.has(err.status);
11
12
  }
12
13
  return false;
13
14
  });
package/dist/util/uris.js CHANGED
@@ -1,4 +1,7 @@
1
- import { AtUri } from '@atproto/syntax';
2
- export function uriToDid(uri) {
3
- return new AtUri(uri).hostname;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uriToDid = uriToDid;
4
+ const syntax_1 = require("@atproto/syntax");
5
+ function uriToDid(uri) {
6
+ return new syntax_1.AtUri(uri).hostname;
4
7
  }
package/dist/util.d.ts CHANGED
@@ -7,7 +7,6 @@ export type ParsedLabelers = {
7
7
  export type RecordInfo<T> = {
8
8
  record: T;
9
9
  cid: string;
10
- sortedAt: Date;
11
10
  indexedAt: Date;
12
11
  takedownRef: string | undefined;
13
12
  };
package/dist/util.js CHANGED
@@ -1,24 +1,61 @@
1
- import { jsonToLex } from '@atproto/lexicon';
2
- import { CID } from 'multiformats/cid';
3
- import * as ui8 from 'uint8arrays';
4
- import { lexicons } from './lexicons/lexicons';
5
- export const defaultLabelerHeader = (dids) => {
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.safeTakedownRef = exports.parseCid = exports.parseJsonBytes = exports.parseRecordBytes = exports.parseRecord = exports.formatLabelerHeader = exports.defaultLabelerHeader = void 0;
37
+ const lexicon_1 = require("@atproto/lexicon");
38
+ const cid_1 = require("multiformats/cid");
39
+ const ui8 = __importStar(require("uint8arrays"));
40
+ const lexicons_1 = require("./lexicons/lexicons");
41
+ const defaultLabelerHeader = (dids) => {
6
42
  return {
7
43
  dids,
8
44
  redact: new Set(dids),
9
45
  };
10
46
  };
11
- export const formatLabelerHeader = (parsed) => {
12
- const parts = parsed.dids.map((did) => parsed.redact.has(did) ? `${did};redact` : did);
47
+ exports.defaultLabelerHeader = defaultLabelerHeader;
48
+ const formatLabelerHeader = (parsed) => {
49
+ const parts = parsed.dids.map((did) => (parsed.redact.has(did) ? `${did};redact` : did));
13
50
  return parts.join(',');
14
51
  };
15
- export const parseRecord = (entry, includeTakedowns) => {
52
+ exports.formatLabelerHeader = formatLabelerHeader;
53
+ const parseRecord = (entry, includeTakedowns) => {
16
54
  if (!includeTakedowns && entry.takenDown) {
17
55
  return undefined;
18
56
  }
19
- const record = parseRecordBytes(entry.record);
57
+ const record = (0, exports.parseRecordBytes)(entry.record);
20
58
  const cid = entry.cid;
21
- const sortedAt = entry.sortedAt?.toDate() ?? new Date(0);
22
59
  const indexedAt = entry.indexedAt?.toDate() ?? new Date(0);
23
60
  if (!record || !cid)
24
61
  return;
@@ -28,18 +65,18 @@ export const parseRecord = (entry, includeTakedowns) => {
28
65
  return {
29
66
  record,
30
67
  cid,
31
- sortedAt,
32
68
  indexedAt,
33
- takedownRef: safeTakedownRef(entry),
69
+ takedownRef: (0, exports.safeTakedownRef)(entry),
34
70
  };
35
71
  };
72
+ exports.parseRecord = parseRecord;
36
73
  const isValidRecord = (json) => {
37
- const lexRecord = jsonToLex(json);
74
+ const lexRecord = (0, lexicon_1.jsonToLex)(json);
38
75
  if (typeof lexRecord?.['$type'] !== 'string') {
39
76
  return false;
40
77
  }
41
78
  try {
42
- lexicons.assertValidRecord(lexRecord['$type'], lexRecord);
79
+ lexicons_1.lexicons.assertValidRecord(lexRecord['$type'], lexRecord);
43
80
  return true;
44
81
  }
45
82
  catch {
@@ -47,26 +84,29 @@ const isValidRecord = (json) => {
47
84
  }
48
85
  };
49
86
  // @NOTE not parsed into lex format, so will not match lexicon record types on CID and blob values.
50
- export const parseRecordBytes = (bytes) => {
51
- return parseJsonBytes(bytes);
87
+ const parseRecordBytes = (bytes) => {
88
+ return (0, exports.parseJsonBytes)(bytes);
52
89
  };
53
- export const parseJsonBytes = (bytes) => {
90
+ exports.parseRecordBytes = parseRecordBytes;
91
+ const parseJsonBytes = (bytes) => {
54
92
  if (!bytes || bytes.byteLength === 0)
55
93
  return;
56
94
  const parsed = JSON.parse(ui8.toString(bytes, 'utf8'));
57
95
  return parsed ?? undefined;
58
96
  };
59
- export const parseCid = (cidStr) => {
97
+ exports.parseJsonBytes = parseJsonBytes;
98
+ const parseCid = (cidStr) => {
60
99
  if (!cidStr || cidStr.length === 0)
61
100
  return;
62
101
  try {
63
- return CID.parse(cidStr);
102
+ return cid_1.CID.parse(cidStr);
64
103
  }
65
104
  catch {
66
105
  return;
67
106
  }
68
107
  };
69
- export const safeTakedownRef = (obj) => {
108
+ exports.parseCid = parseCid;
109
+ const safeTakedownRef = (obj) => {
70
110
  if (!obj)
71
111
  return;
72
112
  if (obj.takedownRef)
@@ -74,3 +114,4 @@ export const safeTakedownRef = (obj) => {
74
114
  if (obj.takenDown)
75
115
  return 'BSKY-TAKEDOWN-UNKNOWN';
76
116
  };
117
+ exports.safeTakedownRef = safeTakedownRef;
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@clioplaylists/clio",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Appview server for the Clio application",
5
5
  "main": "dist/start.js",
6
6
  "types": "dist/index.d.ts",
7
- "files": [ "dist" ],
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "scripts": {
9
- "build": "tsc --project ./tsconfig.json && cp .env ./dist",
11
+ "build": "tsc --project ./tsconfig.json && (test -f .env && cp .env ./dist || true)",
10
12
  "start": "node dist/start.js",
11
13
  "dev": "nodemon -r tsconfig-paths/register src/index.ts",
12
14
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -29,11 +31,15 @@
29
31
  },
30
32
  "homepage": "https://github.com/Hoid/clio#readme",
31
33
  "dependencies": {
34
+ "@atproto-labs/xrpc-utils": "^0.0.14",
32
35
  "@atproto/api": "^0.13.35",
33
36
  "@atproto/common": "^0.4.4",
37
+ "@atproto/common-web": "^0.4.0",
34
38
  "@atproto/crypto": "^0.4.4",
39
+ "@atproto/did": "^0.1.5",
35
40
  "@atproto/identity": "^0.4.6",
36
41
  "@atproto/lexicon": "^0.4.6",
42
+ "@atproto-labs/simple-store": "^0.2.0",
37
43
  "@atproto/repo": "^0.5.5",
38
44
  "@atproto/sync": "^0.1.13",
39
45
  "@atproto/syntax": "^0.3.2",
@@ -44,22 +50,37 @@
44
50
  "@connectrpc/connect-node": "^1.1.4",
45
51
  "@connectrpc/connect-web": "^1.1.4",
46
52
  "@types/cors": "^2.8.17",
53
+ "@atproto/oauth-client-node": "^0.3.8",
54
+ "@atproto/oauth-client": "^0.5.13",
55
+ "cors": "^2.8.5",
47
56
  "dotenv": "^16.4.7",
48
57
  "express": "^4.21.1",
58
+ "http-errors": "^2.0.0",
59
+ "http-terminator": "^3.2.0",
60
+ "jose": "^5.2.0",
61
+ "key-encoder": "^2.0.3",
62
+ "kysely": "^0.28.5",
63
+ "multiformats": "^9.9.0",
64
+ "p-queue": "^8.1.0",
65
+ "pino": "^8.21.0",
66
+ "pino-http": "^8.6.1",
49
67
  "pg": "^8.13.3",
50
68
  "structured-headers": "^2.0.0",
51
69
  "tsconfig-paths": "^4.2.0",
70
+ "typed-emitter": "^2.1.0",
52
71
  "uint8arrays": "^3.0.0",
72
+ "undici": "^6.19.8",
53
73
  "ws": "^8.18.0"
54
74
  },
55
75
  "devDependencies": {
56
- "@atproto/lex-cli": "^0.5.7",
76
+ "@atproto/lex-cli": "^0.8.1",
57
77
  "@atproto/pds": "^0.4.34",
58
78
  "@atproto/xrpc": "^0.6.4",
59
79
  "@bufbuild/buf": "^1.50.0",
60
80
  "@bufbuild/protoc-gen-es": "^1.5.0",
61
81
  "@connectrpc/protoc-gen-connect-es": "^1.1.4",
62
- "@types/express": "^5.0.0",
82
+ "@types/express": "^4.17.21",
83
+ "@types/http-errors": "^2.0.4",
63
84
  "@types/node": "^22.10.1",
64
85
  "@types/pg": "^8.11.11",
65
86
  "@types/ws": "^8.5.13",