@clioplaylists/clio 0.1.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.
Files changed (170) hide show
  1. package/dist/.env +7 -0
  2. package/dist/api/com/clioplaylists/alpha/actor/getProfile.js +37 -0
  3. package/dist/api/com/clioplaylists/alpha/feed/getSongs.js +37 -0
  4. package/dist/api/health.js +32 -0
  5. package/dist/api/index.js +43 -0
  6. package/dist/api/util.js +17 -0
  7. package/dist/auth-verifier.js +473 -0
  8. package/dist/client.js +40 -0
  9. package/dist/config.js +65 -0
  10. package/dist/context.js +19 -0
  11. package/dist/dataplane/bsync/index.js +150 -0
  12. package/dist/dataplane/client.js +165 -0
  13. package/dist/dataplane/index.js +18 -0
  14. package/dist/dataplane/server/background.js +51 -0
  15. package/dist/dataplane/server/db/database-schema.js +2 -0
  16. package/dist/dataplane/server/db/db.js +228 -0
  17. package/dist/dataplane/server/db/index.js +17 -0
  18. package/dist/dataplane/server/db/migrations/20230309T045948368Z-init.js +117 -0
  19. package/dist/dataplane/server/db/migrations/20230420T211446071Z-did-cache.js +15 -0
  20. package/dist/dataplane/server/db/migrations/index.js +41 -0
  21. package/dist/dataplane/server/db/migrations/provider.js +31 -0
  22. package/dist/dataplane/server/db/pagination.js +144 -0
  23. package/dist/dataplane/server/db/tables/actor-sync.js +4 -0
  24. package/dist/dataplane/server/db/tables/actor.js +4 -0
  25. package/dist/dataplane/server/db/tables/artist-list-item.js +4 -0
  26. package/dist/dataplane/server/db/tables/artist.js +4 -0
  27. package/dist/dataplane/server/db/tables/playlist-idea.js +4 -0
  28. package/dist/dataplane/server/db/tables/playlist-item.js +4 -0
  29. package/dist/dataplane/server/db/tables/playlist.js +4 -0
  30. package/dist/dataplane/server/db/tables/profile.js +4 -0
  31. package/dist/dataplane/server/db/tables/record.js +4 -0
  32. package/dist/dataplane/server/db/tables/song.js +4 -0
  33. package/dist/dataplane/server/db/types.js +2 -0
  34. package/dist/dataplane/server/db/util.js +48 -0
  35. package/dist/dataplane/server/index.js +52 -0
  36. package/dist/dataplane/server/indexing/index.js +321 -0
  37. package/dist/dataplane/server/indexing/plugins/playlist-idea.js +163 -0
  38. package/dist/dataplane/server/indexing/plugins/profile.js +81 -0
  39. package/dist/dataplane/server/indexing/processor.js +90 -0
  40. package/dist/dataplane/server/routes/blocks.js +95 -0
  41. package/dist/dataplane/server/routes/feed-gens.js +56 -0
  42. package/dist/dataplane/server/routes/feeds.js +128 -0
  43. package/dist/dataplane/server/routes/follows.js +122 -0
  44. package/dist/dataplane/server/routes/identity.js +56 -0
  45. package/dist/dataplane/server/routes/index.js +19 -0
  46. package/dist/dataplane/server/routes/interactions.js +111 -0
  47. package/dist/dataplane/server/routes/labels.js +73 -0
  48. package/dist/dataplane/server/routes/likes.js +76 -0
  49. package/dist/dataplane/server/routes/lists.js +77 -0
  50. package/dist/dataplane/server/routes/moderation.js +92 -0
  51. package/dist/dataplane/server/routes/mutes.js +166 -0
  52. package/dist/dataplane/server/routes/notifs.js +137 -0
  53. package/dist/dataplane/server/routes/posts.js +19 -0
  54. package/dist/dataplane/server/routes/profile.js +61 -0
  55. package/dist/dataplane/server/routes/quotes.js +26 -0
  56. package/dist/dataplane/server/routes/records.js +88 -0
  57. package/dist/dataplane/server/routes/relationships.js +157 -0
  58. package/dist/dataplane/server/routes/reposts.js +59 -0
  59. package/dist/dataplane/server/routes/search.js +70 -0
  60. package/dist/dataplane/server/routes/starter-packs.js +24 -0
  61. package/dist/dataplane/server/routes/suggestions.js +134 -0
  62. package/dist/dataplane/server/routes/sync.js +14 -0
  63. package/dist/dataplane/server/routes/threads.js +31 -0
  64. package/dist/dataplane/server/subscription.js +114 -0
  65. package/dist/dataplane/server/util.js +117 -0
  66. package/dist/error.js +14 -0
  67. package/dist/index.js +115 -0
  68. package/dist/lexicons/index.js +638 -0
  69. package/dist/lexicons/lexicons.js +4551 -0
  70. package/dist/lexicons/types/com/atproto/admin/defs.js +54 -0
  71. package/dist/lexicons/types/com/atproto/admin/deleteAccount.js +2 -0
  72. package/dist/lexicons/types/com/atproto/admin/disableAccountInvites.js +2 -0
  73. package/dist/lexicons/types/com/atproto/admin/disableInviteCodes.js +2 -0
  74. package/dist/lexicons/types/com/atproto/admin/enableAccountInvites.js +2 -0
  75. package/dist/lexicons/types/com/atproto/admin/getAccountInfo.js +2 -0
  76. package/dist/lexicons/types/com/atproto/admin/getAccountInfos.js +2 -0
  77. package/dist/lexicons/types/com/atproto/admin/getInviteCodes.js +2 -0
  78. package/dist/lexicons/types/com/atproto/admin/getSubjectStatus.js +2 -0
  79. package/dist/lexicons/types/com/atproto/admin/searchAccounts.js +2 -0
  80. package/dist/lexicons/types/com/atproto/admin/sendEmail.js +2 -0
  81. package/dist/lexicons/types/com/atproto/admin/updateAccountEmail.js +2 -0
  82. package/dist/lexicons/types/com/atproto/admin/updateAccountHandle.js +2 -0
  83. package/dist/lexicons/types/com/atproto/admin/updateAccountPassword.js +2 -0
  84. package/dist/lexicons/types/com/atproto/admin/updateSubjectStatus.js +2 -0
  85. package/dist/lexicons/types/com/atproto/identity/defs.js +14 -0
  86. package/dist/lexicons/types/com/atproto/identity/getRecommendedDidCredentials.js +2 -0
  87. package/dist/lexicons/types/com/atproto/identity/refreshIdentity.js +2 -0
  88. package/dist/lexicons/types/com/atproto/identity/requestPlcOperationSignature.js +2 -0
  89. package/dist/lexicons/types/com/atproto/identity/resolveDid.js +2 -0
  90. package/dist/lexicons/types/com/atproto/identity/resolveHandle.js +2 -0
  91. package/dist/lexicons/types/com/atproto/identity/resolveIdentity.js +2 -0
  92. package/dist/lexicons/types/com/atproto/identity/signPlcOperation.js +2 -0
  93. package/dist/lexicons/types/com/atproto/identity/submitPlcOperation.js +2 -0
  94. package/dist/lexicons/types/com/atproto/identity/updateHandle.js +2 -0
  95. package/dist/lexicons/types/com/atproto/label/defs.js +54 -0
  96. package/dist/lexicons/types/com/atproto/label/queryLabels.js +2 -0
  97. package/dist/lexicons/types/com/atproto/label/subscribeLabels.js +24 -0
  98. package/dist/lexicons/types/com/atproto/lexicon/schema.js +15 -0
  99. package/dist/lexicons/types/com/atproto/moderation/createReport.js +2 -0
  100. package/dist/lexicons/types/com/atproto/moderation/defs.js +20 -0
  101. package/dist/lexicons/types/com/atproto/repo/applyWrites.js +64 -0
  102. package/dist/lexicons/types/com/atproto/repo/createRecord.js +2 -0
  103. package/dist/lexicons/types/com/atproto/repo/defs.js +14 -0
  104. package/dist/lexicons/types/com/atproto/repo/deleteRecord.js +2 -0
  105. package/dist/lexicons/types/com/atproto/repo/describeRepo.js +2 -0
  106. package/dist/lexicons/types/com/atproto/repo/getRecord.js +2 -0
  107. package/dist/lexicons/types/com/atproto/repo/importRepo.js +2 -0
  108. package/dist/lexicons/types/com/atproto/repo/listMissingBlobs.js +14 -0
  109. package/dist/lexicons/types/com/atproto/repo/listRecords.js +14 -0
  110. package/dist/lexicons/types/com/atproto/repo/putRecord.js +2 -0
  111. package/dist/lexicons/types/com/atproto/repo/strongRef.js +15 -0
  112. package/dist/lexicons/types/com/atproto/repo/uploadBlob.js +2 -0
  113. package/dist/lexicons/types/com/atproto/server/activateAccount.js +2 -0
  114. package/dist/lexicons/types/com/atproto/server/checkAccountStatus.js +2 -0
  115. package/dist/lexicons/types/com/atproto/server/confirmEmail.js +2 -0
  116. package/dist/lexicons/types/com/atproto/server/createAccount.js +2 -0
  117. package/dist/lexicons/types/com/atproto/server/createAppPassword.js +14 -0
  118. package/dist/lexicons/types/com/atproto/server/createInviteCode.js +2 -0
  119. package/dist/lexicons/types/com/atproto/server/createInviteCodes.js +14 -0
  120. package/dist/lexicons/types/com/atproto/server/createSession.js +2 -0
  121. package/dist/lexicons/types/com/atproto/server/deactivateAccount.js +2 -0
  122. package/dist/lexicons/types/com/atproto/server/defs.js +24 -0
  123. package/dist/lexicons/types/com/atproto/server/deleteAccount.js +2 -0
  124. package/dist/lexicons/types/com/atproto/server/deleteSession.js +2 -0
  125. package/dist/lexicons/types/com/atproto/server/describeServer.js +24 -0
  126. package/dist/lexicons/types/com/atproto/server/getAccountInviteCodes.js +2 -0
  127. package/dist/lexicons/types/com/atproto/server/getServiceAuth.js +2 -0
  128. package/dist/lexicons/types/com/atproto/server/getSession.js +2 -0
  129. package/dist/lexicons/types/com/atproto/server/listAppPasswords.js +14 -0
  130. package/dist/lexicons/types/com/atproto/server/refreshSession.js +2 -0
  131. package/dist/lexicons/types/com/atproto/server/requestAccountDelete.js +2 -0
  132. package/dist/lexicons/types/com/atproto/server/requestEmailConfirmation.js +2 -0
  133. package/dist/lexicons/types/com/atproto/server/requestEmailUpdate.js +2 -0
  134. package/dist/lexicons/types/com/atproto/server/requestPasswordReset.js +2 -0
  135. package/dist/lexicons/types/com/atproto/server/reserveSigningKey.js +2 -0
  136. package/dist/lexicons/types/com/atproto/server/resetPassword.js +2 -0
  137. package/dist/lexicons/types/com/atproto/server/revokeAppPassword.js +2 -0
  138. package/dist/lexicons/types/com/atproto/server/updateEmail.js +2 -0
  139. package/dist/lexicons/types/com/atproto/sync/getBlob.js +2 -0
  140. package/dist/lexicons/types/com/atproto/sync/getBlocks.js +2 -0
  141. package/dist/lexicons/types/com/atproto/sync/getCheckout.js +2 -0
  142. package/dist/lexicons/types/com/atproto/sync/getHead.js +2 -0
  143. package/dist/lexicons/types/com/atproto/sync/getLatestCommit.js +2 -0
  144. package/dist/lexicons/types/com/atproto/sync/getRecord.js +2 -0
  145. package/dist/lexicons/types/com/atproto/sync/getRepo.js +2 -0
  146. package/dist/lexicons/types/com/atproto/sync/getRepoStatus.js +2 -0
  147. package/dist/lexicons/types/com/atproto/sync/listBlobs.js +2 -0
  148. package/dist/lexicons/types/com/atproto/sync/listRepos.js +14 -0
  149. package/dist/lexicons/types/com/atproto/sync/listReposByCollection.js +14 -0
  150. package/dist/lexicons/types/com/atproto/sync/notifyOfUpdate.js +2 -0
  151. package/dist/lexicons/types/com/atproto/sync/requestCrawl.js +2 -0
  152. package/dist/lexicons/types/com/atproto/sync/subscribeRepos.js +64 -0
  153. package/dist/lexicons/types/com/atproto/temp/addReservedHandle.js +2 -0
  154. package/dist/lexicons/types/com/atproto/temp/checkSignupQueue.js +2 -0
  155. package/dist/lexicons/types/com/atproto/temp/fetchLabels.js +2 -0
  156. package/dist/lexicons/types/com/atproto/temp/requestPhoneVerification.js +2 -0
  157. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.js +15 -0
  158. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.js +24 -0
  159. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getSongs.js +2 -0
  160. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.js +35 -0
  161. package/dist/lexicons/types/com/clioplaylists/alpha/feed/song.js +25 -0
  162. package/dist/lexicons/util.js +13 -0
  163. package/dist/logger.js +26 -0
  164. package/dist/rpc/clio_connect.js +110 -0
  165. package/dist/rpc/clio_pb.js +1365 -0
  166. package/dist/start.js +13 -0
  167. package/dist/util/retry.js +16 -0
  168. package/dist/util/uris.js +7 -0
  169. package/dist/util.js +119 -0
  170. package/package.json +73 -0
package/dist/start.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+ const { ClioAppView } = require('./index');
3
+ const { ServerConfig } = require('./config');
4
+ const main = async () => {
5
+ const config = ServerConfig.readEnv();
6
+ const clio = ClioAppView.create({ config });
7
+ await clio.start();
8
+ const shutdown = async () => {
9
+ await clio.destroy();
10
+ };
11
+ process.on('SIGTERM', shutdown);
12
+ };
13
+ main();
@@ -0,0 +1,16 @@
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([
7
+ 408, 425, 429, 500, 502, 503, 504, 522, 524,
8
+ ]);
9
+ exports.retryXrpc = (0, common_1.createRetryable)((err) => {
10
+ if (err instanceof xrpc_1.XRPCError) {
11
+ if (err.status === xrpc_1.ResponseType.Unknown)
12
+ return true;
13
+ return exports.RETRYABLE_HTTP_STATUS_CODES.has(err.status);
14
+ }
15
+ return false;
16
+ });
@@ -0,0 +1,7 @@
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;
7
+ }
package/dist/util.js ADDED
@@ -0,0 +1,119 @@
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) => {
42
+ return {
43
+ dids,
44
+ redact: new Set(dids),
45
+ };
46
+ };
47
+ exports.defaultLabelerHeader = defaultLabelerHeader;
48
+ const formatLabelerHeader = (parsed) => {
49
+ const parts = parsed.dids.map((did) => parsed.redact.has(did) ? `${did};redact` : did);
50
+ return parts.join(',');
51
+ };
52
+ exports.formatLabelerHeader = formatLabelerHeader;
53
+ const parseRecord = (entry, includeTakedowns) => {
54
+ if (!includeTakedowns && entry.takenDown) {
55
+ return undefined;
56
+ }
57
+ const record = (0, exports.parseRecordBytes)(entry.record);
58
+ const cid = entry.cid;
59
+ const sortedAt = entry.sortedAt?.toDate() ?? new Date(0);
60
+ const indexedAt = entry.indexedAt?.toDate() ?? new Date(0);
61
+ if (!record || !cid)
62
+ return;
63
+ if (!isValidRecord(record)) {
64
+ return;
65
+ }
66
+ return {
67
+ record,
68
+ cid,
69
+ sortedAt,
70
+ indexedAt,
71
+ takedownRef: (0, exports.safeTakedownRef)(entry),
72
+ };
73
+ };
74
+ exports.parseRecord = parseRecord;
75
+ const isValidRecord = (json) => {
76
+ const lexRecord = (0, lexicon_1.jsonToLex)(json);
77
+ if (typeof lexRecord?.['$type'] !== 'string') {
78
+ return false;
79
+ }
80
+ try {
81
+ lexicons_1.lexicons.assertValidRecord(lexRecord['$type'], lexRecord);
82
+ return true;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ };
88
+ // @NOTE not parsed into lex format, so will not match lexicon record types on CID and blob values.
89
+ const parseRecordBytes = (bytes) => {
90
+ return (0, exports.parseJsonBytes)(bytes);
91
+ };
92
+ exports.parseRecordBytes = parseRecordBytes;
93
+ const parseJsonBytes = (bytes) => {
94
+ if (!bytes || bytes.byteLength === 0)
95
+ return;
96
+ const parsed = JSON.parse(ui8.toString(bytes, 'utf8'));
97
+ return parsed ?? undefined;
98
+ };
99
+ exports.parseJsonBytes = parseJsonBytes;
100
+ const parseCid = (cidStr) => {
101
+ if (!cidStr || cidStr.length === 0)
102
+ return;
103
+ try {
104
+ return cid_1.CID.parse(cidStr);
105
+ }
106
+ catch {
107
+ return;
108
+ }
109
+ };
110
+ exports.parseCid = parseCid;
111
+ const safeTakedownRef = (obj) => {
112
+ if (!obj)
113
+ return;
114
+ if (obj.takedownRef)
115
+ return obj.takedownRef;
116
+ if (obj.takenDown)
117
+ return 'BSKY-TAKEDOWN-UNKNOWN';
118
+ };
119
+ exports.safeTakedownRef = safeTakedownRef;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@clioplaylists/clio",
3
+ "version": "0.1.0",
4
+ "description": "Appview server for the Clio application",
5
+ "main": "dist/start.js",
6
+ "scripts": {
7
+ "build": "tsc --project ./tsconfig.json && cp .env ./dist",
8
+ "start": "node dist/start.js",
9
+ "dev": "nodemon -r tsconfig-paths/register src/index.ts",
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "lex:gen": "lex gen-server --yes ./src/lexicons ../../lexicons/com/clioplaylists/alpha/*/* ../../lexicons/com/atproto/*/*",
12
+ "buf:gen": "buf generate ./src/rpc",
13
+ "pretty": "prettier --write .",
14
+ "pretty:check": "prettier --check ."
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Hoid/clio.git"
19
+ },
20
+ "keywords": [
21
+ "clio"
22
+ ],
23
+ "author": "Ezra Boeth",
24
+ "license": "AGPL-3.0-or-later",
25
+ "bugs": {
26
+ "url": "https://github.com/Hoid/clio/issues"
27
+ },
28
+ "homepage": "https://github.com/Hoid/clio#readme",
29
+ "files": [ "./dist" ],
30
+ "dependencies": {
31
+ "@atproto/api": "^0.13.35",
32
+ "@atproto/common": "^0.4.4",
33
+ "@atproto/crypto": "^0.4.4",
34
+ "@atproto/identity": "^0.4.6",
35
+ "@atproto/lexicon": "^0.4.6",
36
+ "@atproto/repo": "^0.5.5",
37
+ "@atproto/sync": "^0.1.13",
38
+ "@atproto/syntax": "^0.3.2",
39
+ "@atproto/xrpc-server": "^0.7.10",
40
+ "@bufbuild/protobuf": "^1.5.0",
41
+ "@connectrpc/connect": "^1.1.4",
42
+ "@connectrpc/connect-express": "^1.6.1",
43
+ "@connectrpc/connect-node": "^1.1.4",
44
+ "@connectrpc/connect-web": "^1.1.4",
45
+ "@types/cors": "^2.8.17",
46
+ "dotenv": "^16.4.7",
47
+ "express": "^4.21.1",
48
+ "pg": "^8.13.3",
49
+ "structured-headers": "^2.0.0",
50
+ "tsconfig-paths": "^4.2.0",
51
+ "uint8arrays": "^3.0.0",
52
+ "ws": "^8.18.0"
53
+ },
54
+ "devDependencies": {
55
+ "@atproto/lex-cli": "^0.5.7",
56
+ "@atproto/pds": "^0.4.34",
57
+ "@atproto/xrpc": "^0.6.4",
58
+ "@bufbuild/buf": "^1.50.0",
59
+ "@bufbuild/protoc-gen-es": "^1.5.0",
60
+ "@connectrpc/protoc-gen-connect-es": "^1.1.4",
61
+ "@types/express": "^5.0.0",
62
+ "@types/node": "^22.10.1",
63
+ "@types/pg": "^8.11.11",
64
+ "@types/ws": "^8.5.13",
65
+ "concurrently": "^9.1.0",
66
+ "nodemon": "^3.1.7",
67
+ "prettier": "^3.5.3",
68
+ "prettier-plugin-organize-imports": "^4.1.0",
69
+ "ts-node": "^10.9.2",
70
+ "tsc-alias": "^1.8.10",
71
+ "typescript": "^5.7.2"
72
+ }
73
+ }