@clioplaylists/clio 0.1.6 → 0.1.8

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 (155) hide show
  1. package/dist/.env +7 -0
  2. package/dist/api/health.js +3 -10
  3. package/dist/api/index.js +2 -39
  4. package/dist/api/util.js +6 -10
  5. package/dist/api/well-known.d.ts +3 -0
  6. package/dist/api/well-known.js +31 -0
  7. package/dist/auth-verifier.js +165 -273
  8. package/dist/client.js +8 -15
  9. package/dist/config.d.ts +2 -0
  10. package/dist/config.js +17 -23
  11. package/dist/context.d.ts +3 -0
  12. package/dist/context.js +6 -10
  13. package/dist/dataplane/client/hosts.d.ts +21 -0
  14. package/dist/dataplane/client/hosts.js +25 -0
  15. package/dist/dataplane/client/index.d.ts +11 -0
  16. package/dist/dataplane/client/index.js +97 -0
  17. package/dist/dataplane/client.js +25 -70
  18. package/dist/dataplane/index.js +2 -18
  19. package/dist/dataplane/server/background.js +8 -29
  20. package/dist/dataplane/server/db/database-schema.js +1 -2
  21. package/dist/dataplane/server/db/db.js +27 -103
  22. package/dist/dataplane/server/db/index.js +1 -17
  23. package/dist/dataplane/server/db/migrations/20230309T045948368Z-init.js +7 -11
  24. package/dist/dataplane/server/db/migrations/20230420T211446071Z-did-cache.js +2 -6
  25. package/dist/dataplane/server/db/migrations/index.js +2 -38
  26. package/dist/dataplane/server/db/migrations/provider.js +5 -17
  27. package/dist/dataplane/server/db/pagination.js +21 -37
  28. package/dist/dataplane/server/db/tables/actor-sync.js +1 -4
  29. package/dist/dataplane/server/db/tables/actor.js +1 -4
  30. package/dist/dataplane/server/db/tables/artist-list-item.js +1 -4
  31. package/dist/dataplane/server/db/tables/artist.js +1 -4
  32. package/dist/dataplane/server/db/tables/playlist-idea.js +1 -4
  33. package/dist/dataplane/server/db/tables/playlist-item.js +1 -4
  34. package/dist/dataplane/server/db/tables/playlist.js +1 -4
  35. package/dist/dataplane/server/db/tables/profile.js +1 -4
  36. package/dist/dataplane/server/db/tables/record.js +1 -4
  37. package/dist/dataplane/server/db/tables/song.js +1 -4
  38. package/dist/dataplane/server/db/types.js +1 -2
  39. package/dist/dataplane/server/db/util.js +18 -26
  40. package/dist/dataplane/server/index.js +17 -33
  41. package/dist/dataplane/server/indexing/index.js +39 -89
  42. package/dist/dataplane/server/indexing/plugins/playlist-idea.js +7 -44
  43. package/dist/dataplane/server/indexing/plugins/profile.js +5 -42
  44. package/dist/dataplane/server/indexing/processor.js +11 -29
  45. package/dist/dataplane/server/routes/identity.js +11 -13
  46. package/dist/dataplane/server/routes/index.js +10 -15
  47. package/dist/dataplane/server/routes/profile.js +9 -11
  48. package/dist/dataplane/server/routes/records.js +14 -51
  49. package/dist/dataplane/server/routes/sync.js +1 -3
  50. package/dist/dataplane/server/subscription.js +19 -47
  51. package/dist/error.js +5 -9
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.js +36 -90
  54. package/dist/lexicons/index.js +52 -227
  55. package/dist/lexicons/lexicons.js +5 -8
  56. package/dist/lexicons/types/com/atproto/admin/defs.js +27 -39
  57. package/dist/lexicons/types/com/atproto/admin/deleteAccount.js +1 -2
  58. package/dist/lexicons/types/com/atproto/admin/disableAccountInvites.js +1 -2
  59. package/dist/lexicons/types/com/atproto/admin/disableInviteCodes.js +1 -2
  60. package/dist/lexicons/types/com/atproto/admin/enableAccountInvites.js +1 -2
  61. package/dist/lexicons/types/com/atproto/admin/getAccountInfo.js +1 -2
  62. package/dist/lexicons/types/com/atproto/admin/getAccountInfos.js +1 -2
  63. package/dist/lexicons/types/com/atproto/admin/getInviteCodes.js +1 -2
  64. package/dist/lexicons/types/com/atproto/admin/getSubjectStatus.js +1 -2
  65. package/dist/lexicons/types/com/atproto/admin/searchAccounts.js +1 -2
  66. package/dist/lexicons/types/com/atproto/admin/sendEmail.js +1 -2
  67. package/dist/lexicons/types/com/atproto/admin/updateAccountEmail.js +1 -2
  68. package/dist/lexicons/types/com/atproto/admin/updateAccountHandle.js +1 -2
  69. package/dist/lexicons/types/com/atproto/admin/updateAccountPassword.js +1 -2
  70. package/dist/lexicons/types/com/atproto/admin/updateSubjectStatus.js +1 -2
  71. package/dist/lexicons/types/com/atproto/identity/defs.js +7 -11
  72. package/dist/lexicons/types/com/atproto/identity/getRecommendedDidCredentials.js +1 -2
  73. package/dist/lexicons/types/com/atproto/identity/refreshIdentity.js +1 -2
  74. package/dist/lexicons/types/com/atproto/identity/requestPlcOperationSignature.js +1 -2
  75. package/dist/lexicons/types/com/atproto/identity/resolveDid.js +1 -2
  76. package/dist/lexicons/types/com/atproto/identity/resolveHandle.js +1 -2
  77. package/dist/lexicons/types/com/atproto/identity/resolveIdentity.js +1 -2
  78. package/dist/lexicons/types/com/atproto/identity/signPlcOperation.js +1 -2
  79. package/dist/lexicons/types/com/atproto/identity/submitPlcOperation.js +1 -2
  80. package/dist/lexicons/types/com/atproto/identity/updateHandle.js +1 -2
  81. package/dist/lexicons/types/com/atproto/label/defs.js +27 -39
  82. package/dist/lexicons/types/com/atproto/label/queryLabels.js +1 -2
  83. package/dist/lexicons/types/com/atproto/label/subscribeLabels.js +12 -18
  84. package/dist/lexicons/types/com/atproto/lexicon/schema.js +7 -11
  85. package/dist/lexicons/types/com/atproto/moderation/createReport.js +1 -2
  86. package/dist/lexicons/types/com/atproto/moderation/defs.js +7 -10
  87. package/dist/lexicons/types/com/atproto/repo/applyWrites.js +32 -46
  88. package/dist/lexicons/types/com/atproto/repo/createRecord.js +1 -2
  89. package/dist/lexicons/types/com/atproto/repo/defs.js +7 -11
  90. package/dist/lexicons/types/com/atproto/repo/deleteRecord.js +1 -2
  91. package/dist/lexicons/types/com/atproto/repo/describeRepo.js +1 -2
  92. package/dist/lexicons/types/com/atproto/repo/getRecord.js +1 -2
  93. package/dist/lexicons/types/com/atproto/repo/importRepo.js +1 -2
  94. package/dist/lexicons/types/com/atproto/repo/listMissingBlobs.js +7 -11
  95. package/dist/lexicons/types/com/atproto/repo/listRecords.js +7 -11
  96. package/dist/lexicons/types/com/atproto/repo/putRecord.js +1 -2
  97. package/dist/lexicons/types/com/atproto/repo/strongRef.js +7 -11
  98. package/dist/lexicons/types/com/atproto/repo/uploadBlob.js +1 -2
  99. package/dist/lexicons/types/com/atproto/server/activateAccount.js +1 -2
  100. package/dist/lexicons/types/com/atproto/server/checkAccountStatus.js +1 -2
  101. package/dist/lexicons/types/com/atproto/server/confirmEmail.js +1 -2
  102. package/dist/lexicons/types/com/atproto/server/createAccount.js +1 -2
  103. package/dist/lexicons/types/com/atproto/server/createAppPassword.js +7 -11
  104. package/dist/lexicons/types/com/atproto/server/createInviteCode.js +1 -2
  105. package/dist/lexicons/types/com/atproto/server/createInviteCodes.js +7 -11
  106. package/dist/lexicons/types/com/atproto/server/createSession.js +1 -2
  107. package/dist/lexicons/types/com/atproto/server/deactivateAccount.js +1 -2
  108. package/dist/lexicons/types/com/atproto/server/defs.js +12 -18
  109. package/dist/lexicons/types/com/atproto/server/deleteAccount.js +1 -2
  110. package/dist/lexicons/types/com/atproto/server/deleteSession.js +1 -2
  111. package/dist/lexicons/types/com/atproto/server/describeServer.js +12 -18
  112. package/dist/lexicons/types/com/atproto/server/getAccountInviteCodes.js +1 -2
  113. package/dist/lexicons/types/com/atproto/server/getServiceAuth.js +1 -2
  114. package/dist/lexicons/types/com/atproto/server/getSession.js +1 -2
  115. package/dist/lexicons/types/com/atproto/server/listAppPasswords.js +7 -11
  116. package/dist/lexicons/types/com/atproto/server/refreshSession.js +1 -2
  117. package/dist/lexicons/types/com/atproto/server/requestAccountDelete.js +1 -2
  118. package/dist/lexicons/types/com/atproto/server/requestEmailConfirmation.js +1 -2
  119. package/dist/lexicons/types/com/atproto/server/requestEmailUpdate.js +1 -2
  120. package/dist/lexicons/types/com/atproto/server/requestPasswordReset.js +1 -2
  121. package/dist/lexicons/types/com/atproto/server/reserveSigningKey.js +1 -2
  122. package/dist/lexicons/types/com/atproto/server/resetPassword.js +1 -2
  123. package/dist/lexicons/types/com/atproto/server/revokeAppPassword.js +1 -2
  124. package/dist/lexicons/types/com/atproto/server/updateEmail.js +1 -2
  125. package/dist/lexicons/types/com/atproto/sync/getBlob.js +1 -2
  126. package/dist/lexicons/types/com/atproto/sync/getBlocks.js +1 -2
  127. package/dist/lexicons/types/com/atproto/sync/getCheckout.js +1 -2
  128. package/dist/lexicons/types/com/atproto/sync/getHead.js +1 -2
  129. package/dist/lexicons/types/com/atproto/sync/getLatestCommit.js +1 -2
  130. package/dist/lexicons/types/com/atproto/sync/getRecord.js +1 -2
  131. package/dist/lexicons/types/com/atproto/sync/getRepo.js +1 -2
  132. package/dist/lexicons/types/com/atproto/sync/getRepoStatus.js +1 -2
  133. package/dist/lexicons/types/com/atproto/sync/listBlobs.js +1 -2
  134. package/dist/lexicons/types/com/atproto/sync/listRepos.js +7 -11
  135. package/dist/lexicons/types/com/atproto/sync/listReposByCollection.js +7 -11
  136. package/dist/lexicons/types/com/atproto/sync/notifyOfUpdate.js +1 -2
  137. package/dist/lexicons/types/com/atproto/sync/requestCrawl.js +1 -2
  138. package/dist/lexicons/types/com/atproto/sync/subscribeRepos.js +32 -46
  139. package/dist/lexicons/types/com/atproto/temp/addReservedHandle.js +1 -2
  140. package/dist/lexicons/types/com/atproto/temp/checkSignupQueue.js +1 -2
  141. package/dist/lexicons/types/com/atproto/temp/fetchLabels.js +1 -2
  142. package/dist/lexicons/types/com/atproto/temp/requestPhoneVerification.js +1 -2
  143. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.js +7 -11
  144. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.js +12 -18
  145. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getSongs.js +1 -2
  146. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.js +17 -25
  147. package/dist/lexicons/util.js +2 -6
  148. package/dist/logger.js +10 -16
  149. package/dist/rpc/clio_connect.js +30 -33
  150. package/dist/rpc/clio_pb.js +402 -956
  151. package/dist/start.js +9 -1
  152. package/dist/util/retry.js +7 -10
  153. package/dist/util/uris.js +3 -6
  154. package/dist/util.js +17 -60
  155. package/package.json +4 -4
@@ -1,39 +1,24 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DataPlaneServer = exports.RepoSubscription = void 0;
7
- const identity_1 = require("@atproto/identity");
8
- const connect_express_1 = require("@connectrpc/connect-express");
9
- const express_1 = __importDefault(require("express"));
10
- const node_events_1 = __importDefault(require("node:events"));
11
- const routes_1 = __importDefault(require("./routes"));
12
- var subscription_1 = require("./subscription");
13
- Object.defineProperty(exports, "RepoSubscription", { enumerable: true, get: function () { return subscription_1.RepoSubscription; } });
14
- class DataPlaneServer {
1
+ import { IdResolver, MemoryCache } from '@atproto/identity';
2
+ import { expressConnectMiddleware } from '@connectrpc/connect-express';
3
+ import express from 'express';
4
+ import events from 'node:events';
5
+ import createRoutes from './routes';
6
+ export { RepoSubscription } from './subscription';
7
+ export class DataPlaneServer {
8
+ server;
9
+ idResolver;
15
10
  constructor(server, idResolver) {
16
- Object.defineProperty(this, "server", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: server
21
- });
22
- Object.defineProperty(this, "idResolver", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: idResolver
27
- });
11
+ this.server = server;
12
+ this.idResolver = idResolver;
28
13
  }
29
14
  static async create(db, port, plcUrl) {
30
- const app = (0, express_1.default)();
31
- const didCache = new identity_1.MemoryCache();
32
- const idResolver = new identity_1.IdResolver({ plcUrl, didCache });
33
- const routes = (0, routes_1.default)(db, idResolver);
34
- app.use((0, connect_express_1.expressConnectMiddleware)({ routes }));
15
+ const app = express();
16
+ const didCache = new MemoryCache();
17
+ const idResolver = new IdResolver({ plcUrl, didCache });
18
+ const routes = createRoutes(db, idResolver);
19
+ app.use(expressConnectMiddleware({ routes }));
35
20
  const server = app.listen(port);
36
- await node_events_1.default.once(server, 'listening');
21
+ await events.once(server, 'listening');
37
22
  return new DataPlaneServer(server, idResolver);
38
23
  }
39
24
  async destroy() {
@@ -49,4 +34,3 @@ class DataPlaneServer {
49
34
  });
50
35
  }
51
36
  }
52
- exports.DataPlaneServer = DataPlaneServer;
@@ -1,71 +1,22 @@
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.IndexingService = void 0;
37
- const api_1 = require("@atproto/api");
38
- const common_1 = require("@atproto/common");
39
- const identity_1 = require("@atproto/identity");
40
- const lexicon_1 = require("@atproto/lexicon");
41
- const repo_1 = require("@atproto/repo");
42
- const syntax_1 = require("@atproto/syntax");
43
- const kysely_1 = require("kysely");
44
- const cid_1 = require("multiformats/cid");
45
- const logger_1 = require("../../../logger");
46
- const retry_1 = require("../../../util/retry");
47
- const PlaylistIdea = __importStar(require("./plugins/playlist-idea"));
48
- const Profile = __importStar(require("./plugins/profile"));
49
- class IndexingService {
1
+ import { Agent, ComAtprotoSyncGetLatestCommit } from '@atproto/api';
2
+ import { DAY, HOUR } from '@atproto/common';
3
+ import { getPds } from '@atproto/identity';
4
+ import { ValidationError } from '@atproto/lexicon';
5
+ import { WriteOpAction, getAndParseRecord, readCarWithRoot, verifyRepo, } from '@atproto/repo';
6
+ import { AtUri } from '@atproto/syntax';
7
+ import { sql } from 'kysely';
8
+ import { CID } from 'multiformats/cid';
9
+ import { httpLogger } from '../../../logger';
10
+ import { retryXrpc } from '../../../util/retry';
11
+ import * as PlaylistIdea from './plugins/playlist-idea';
12
+ import * as Profile from './plugins/profile';
13
+ export class IndexingService {
14
+ db;
15
+ idResolver;
16
+ records;
50
17
  constructor(db, idResolver) {
51
- Object.defineProperty(this, "db", {
52
- enumerable: true,
53
- configurable: true,
54
- writable: true,
55
- value: db
56
- });
57
- Object.defineProperty(this, "idResolver", {
58
- enumerable: true,
59
- configurable: true,
60
- writable: true,
61
- value: idResolver
62
- });
63
- Object.defineProperty(this, "records", {
64
- enumerable: true,
65
- configurable: true,
66
- writable: true,
67
- value: void 0
68
- });
18
+ this.db = db;
19
+ this.idResolver = idResolver;
69
20
  this.records = {
70
21
  playlistIdea: PlaylistIdea.makePlugin(this.db),
71
22
  profile: Profile.makePlugin(this.db),
@@ -82,7 +33,7 @@ class IndexingService {
82
33
  const indexer = indexingTx.findIndexerForCollection(uri.collection);
83
34
  if (!indexer)
84
35
  return;
85
- if (action === repo_1.WriteOpAction.Create) {
36
+ if (action === WriteOpAction.Create) {
86
37
  await indexer.insertRecord(uri, cid, obj, timestamp);
87
38
  }
88
39
  else {
@@ -140,10 +91,10 @@ class IndexingService {
140
91
  this.db.assertNotTransaction();
141
92
  const now = new Date().toISOString();
142
93
  const { pds, signingKey } = await this.idResolver.did.resolveAtprotoData(did, true);
143
- const agent = new api_1.Agent(pds);
144
- const { data: car } = await (0, retry_1.retryXrpc)(() => agent.com.atproto.sync.getRepo({ did }));
145
- const { root, blocks } = await (0, repo_1.readCarWithRoot)(car);
146
- const verifiedRepo = await (0, repo_1.verifyRepo)(blocks, root, did, signingKey);
94
+ const agent = new Agent(pds);
95
+ const { data: car } = await retryXrpc(() => agent.com.atproto.sync.getRepo({ did }));
96
+ const { root, blocks } = await readCarWithRoot(car);
97
+ const verifiedRepo = await verifyRepo(blocks, root, did, signingKey);
147
98
  const currRecords = await this.getCurrentRecords(did);
148
99
  const repoRecords = formatCheckout(did, verifiedRepo);
149
100
  const diff = findDiffFromCheckout(currRecords, repoRecords);
@@ -154,16 +105,16 @@ class IndexingService {
154
105
  await this.deleteRecord(uri);
155
106
  }
156
107
  else {
157
- const parsed = await (0, repo_1.getAndParseRecord)(blocks, cid);
158
- await this.indexRecord(uri, cid, parsed.record, op.op === 'create' ? repo_1.WriteOpAction.Create : repo_1.WriteOpAction.Update, now);
108
+ const parsed = await getAndParseRecord(blocks, cid);
109
+ await this.indexRecord(uri, cid, parsed.record, op.op === 'create' ? WriteOpAction.Create : WriteOpAction.Update, now);
159
110
  }
160
111
  }
161
112
  catch (err) {
162
- if (err instanceof lexicon_1.ValidationError) {
163
- logger_1.httpLogger.warn({ did, commit, uri: uri.toString(), cid: cid.toString() }, 'skipping indexing of invalid record');
113
+ if (err instanceof ValidationError) {
114
+ httpLogger.warn({ did, commit, uri: uri.toString(), cid: cid.toString() }, 'skipping indexing of invalid record');
164
115
  }
165
116
  else {
166
- logger_1.httpLogger.error({ err, did, commit, uri: uri.toString(), cid: cid.toString() }, 'skipping indexing due to error processing record');
117
+ httpLogger.error({ err, did, commit, uri: uri.toString(), cid: cid.toString() }, 'skipping indexing due to error processing record');
167
118
  }
168
119
  }
169
120
  }));
@@ -197,8 +148,8 @@ class IndexingService {
197
148
  .onConflict((oc) => {
198
149
  const excluded = (col) => ref(`excluded.${col}`);
199
150
  return oc.column('did').doUpdateSet({
200
- commitCid: (0, kysely_1.sql) `${excluded('commitCid')}`,
201
- repoRev: (0, kysely_1.sql) `${excluded('repoRev')}`,
151
+ commitCid: sql `${excluded('commitCid')}`,
152
+ repoRev: sql `${excluded('repoRev')}`,
202
153
  });
203
154
  })
204
155
  .execute();
@@ -211,8 +162,8 @@ class IndexingService {
211
162
  .execute();
212
163
  return res.reduce((acc, cur) => {
213
164
  acc[cur.uri] = {
214
- uri: new syntax_1.AtUri(cur.uri),
215
- cid: cid_1.CID.parse(cur.cid),
165
+ uri: new AtUri(cur.uri),
166
+ cid: CID.parse(cur.cid),
216
167
  };
217
168
  return acc;
218
169
  }, {});
@@ -231,16 +182,16 @@ class IndexingService {
231
182
  }
232
183
  async getActorIsHosted(did) {
233
184
  const doc = await this.idResolver.did.resolve(did, true);
234
- const pds = doc && (0, identity_1.getPds)(doc);
185
+ const pds = doc && getPds(doc);
235
186
  if (!pds)
236
187
  return false;
237
- const agent = new api_1.Agent(pds);
188
+ const agent = new Agent(pds);
238
189
  try {
239
- await (0, retry_1.retryXrpc)(() => agent.com.atproto.sync.getLatestCommit({ did }));
190
+ await retryXrpc(() => agent.com.atproto.sync.getLatestCommit({ did }));
240
191
  return true;
241
192
  }
242
193
  catch (err) {
243
- if (err instanceof api_1.ComAtprotoSyncGetLatestCommit.RepoNotFoundError) {
194
+ if (err instanceof ComAtprotoSyncGetLatestCommit.RepoNotFoundError) {
244
195
  return false;
245
196
  }
246
197
  return null;
@@ -272,7 +223,6 @@ class IndexingService {
272
223
  .execute();
273
224
  }
274
225
  }
275
- exports.IndexingService = IndexingService;
276
226
  const findDiffFromCheckout = (curr, checkout) => {
277
227
  const ops = [];
278
228
  for (const uri of Object.keys(checkout)) {
@@ -299,7 +249,7 @@ const findDiffFromCheckout = (curr, checkout) => {
299
249
  const formatCheckout = (did, verifiedRepo) => {
300
250
  const records = {};
301
251
  for (const create of verifiedRepo.creates) {
302
- const uri = syntax_1.AtUri.make(did, create.collection, create.rkey);
252
+ const uri = AtUri.make(did, create.collection, create.rkey);
303
253
  records[uri.toString()] = {
304
254
  uri,
305
255
  cid: create.cid,
@@ -312,10 +262,10 @@ const needsHandleReindex = (actor, timestamp) => {
312
262
  return true;
313
263
  const timeDiff = new Date(timestamp).getTime() - new Date(actor.indexed_at).getTime();
314
264
  // revalidate daily
315
- if (timeDiff > common_1.DAY)
265
+ if (timeDiff > DAY)
316
266
  return true;
317
267
  // revalidate more aggressively for invalidated handles
318
- if (actor.handle === null && timeDiff > common_1.HOUR)
268
+ if (actor.handle === null && timeDiff > HOUR)
319
269
  return true;
320
270
  return false;
321
271
  };
@@ -1,42 +1,6 @@
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.makePlugin = void 0;
37
- const syntax_1 = require("@atproto/syntax");
38
- const lex = __importStar(require("../../../../lexicons/lexicons"));
39
- const processor_1 = require("../processor");
1
+ import { normalizeDatetimeAlways } from '@atproto/syntax';
2
+ import * as lex from '../../../../lexicons/lexicons';
3
+ import { RecordProcessor } from '../processor';
40
4
  const lexId = lex.ids.ComClioplaylistsAlphaFeedPlaylistIdea;
41
5
  const insertFn = async (db, uri, cid, obj, timestamp) => {
42
6
  const masterPlaylist = obj.masterPlaylist;
@@ -98,7 +62,7 @@ const insertFn = async (db, uri, cid, obj, timestamp) => {
98
62
  owner_did: obj.ownerDid,
99
63
  master_playlist_id: masterPlaylistId,
100
64
  recommended_playlist_id: recommendedPlaylistId,
101
- created_at: (0, syntax_1.normalizeDatetimeAlways)(obj.createdAt),
65
+ created_at: normalizeDatetimeAlways(obj.createdAt),
102
66
  };
103
67
  const [insertedPlaylistIdea] = await Promise.all([
104
68
  db
@@ -151,13 +115,12 @@ const deleteFn = async (db, uri) => {
151
115
  }
152
116
  : null;
153
117
  };
154
- const makePlugin = (db) => {
155
- return new processor_1.RecordProcessor(db, {
118
+ export const makePlugin = (db) => {
119
+ return new RecordProcessor(db, {
156
120
  lexId,
157
121
  insertFn,
158
122
  findDuplicate,
159
123
  deleteFn,
160
124
  });
161
125
  };
162
- exports.makePlugin = makePlugin;
163
- exports.default = exports.makePlugin;
126
+ export default makePlugin;
@@ -1,41 +1,5 @@
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.makePlugin = void 0;
37
- const lex = __importStar(require("../../../../lexicons/lexicons"));
38
- const processor_1 = require("../processor");
1
+ import * as lex from '../../../../lexicons/lexicons';
2
+ import { RecordProcessor } from '../processor';
39
3
  const lexId = lex.ids.ComClioplaylistsAlphaActorProfile;
40
4
  const insertFn = async (db, uri, cid, obj, timestamp) => {
41
5
  if (uri.rkey !== 'self')
@@ -69,13 +33,12 @@ const deleteFn = async (db, uri) => {
69
33
  .executeTakeFirst();
70
34
  return deleted || null;
71
35
  };
72
- const makePlugin = (db) => {
73
- return new processor_1.RecordProcessor(db, {
36
+ export const makePlugin = (db) => {
37
+ return new RecordProcessor(db, {
74
38
  lexId,
75
39
  insertFn,
76
40
  findDuplicate,
77
41
  deleteFn,
78
42
  });
79
43
  };
80
- exports.makePlugin = makePlugin;
81
- exports.default = exports.makePlugin;
44
+ export default makePlugin;
@@ -1,28 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecordProcessor = void 0;
4
- const lexicon_1 = require("@atproto/lexicon");
5
- const lexicons_1 = require("../../../lexicons/lexicons");
6
- class RecordProcessor {
1
+ import { stringifyLex } from '@atproto/lexicon';
2
+ import { lexicons } from '../../../lexicons/lexicons';
3
+ export class RecordProcessor {
4
+ params;
5
+ collection;
6
+ db;
7
7
  constructor(appDb, params) {
8
- Object.defineProperty(this, "params", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: params
13
- });
14
- Object.defineProperty(this, "collection", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: void 0
19
- });
20
- Object.defineProperty(this, "db", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: void 0
25
- });
8
+ this.params = params;
26
9
  this.db = appDb.db;
27
10
  this.collection = this.params.lexId;
28
11
  }
@@ -36,7 +19,7 @@ class RecordProcessor {
36
19
  }
37
20
  }
38
21
  assertValidRecord(obj) {
39
- lexicons_1.lexicons.assertValidRecord(this.params.lexId, obj);
22
+ lexicons.assertValidRecord(this.params.lexId, obj);
40
23
  }
41
24
  async insertRecord(uri, cid, obj, timestamp) {
42
25
  this.assertValidRecord(obj);
@@ -46,7 +29,7 @@ class RecordProcessor {
46
29
  uri: uri.toString(),
47
30
  cid: cid.toString(),
48
31
  did: uri.host,
49
- json: (0, lexicon_1.stringifyLex)(obj),
32
+ json: stringifyLex(obj),
50
33
  indexed_at: timestamp,
51
34
  })
52
35
  .onConflict((oc) => oc.doNothing())
@@ -64,7 +47,7 @@ class RecordProcessor {
64
47
  .where('uri', '=', uri.toString())
65
48
  .set({
66
49
  cid: cid.toString(),
67
- json: (0, lexicon_1.stringifyLex)(obj),
50
+ json: stringifyLex(obj),
68
51
  indexed_at: timestamp,
69
52
  })
70
53
  .execute();
@@ -86,5 +69,4 @@ class RecordProcessor {
86
69
  await this.params.deleteFn(this.db, uri);
87
70
  }
88
71
  }
89
- exports.RecordProcessor = RecordProcessor;
90
- exports.default = RecordProcessor;
72
+ export default RecordProcessor;
@@ -1,24 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const identity_1 = require("@atproto/identity");
4
- const protobuf_1 = require("@bufbuild/protobuf");
5
- const connect_1 = require("@connectrpc/connect");
6
- exports.default = (_db, idResolver) => ({
1
+ import { getDid, getHandle } from '@atproto/identity';
2
+ import { Timestamp } from '@bufbuild/protobuf';
3
+ import { Code, ConnectError } from '@connectrpc/connect';
4
+ export default (_db, idResolver) => ({
7
5
  async getIdentityByDid(req) {
8
6
  const doc = await idResolver.did.resolve(req.did);
9
7
  if (!doc) {
10
- throw new connect_1.ConnectError('identity not found', connect_1.Code.NotFound);
8
+ throw new ConnectError('identity not found', Code.NotFound);
11
9
  }
12
10
  return getResultFromDoc(doc);
13
11
  },
14
12
  async getIdentityByHandle(req) {
15
13
  const did = await idResolver.handle.resolve(req.handle);
16
14
  if (!did) {
17
- throw new connect_1.ConnectError('identity not found', connect_1.Code.NotFound);
15
+ throw new ConnectError('identity not found', Code.NotFound);
18
16
  }
19
17
  const doc = await idResolver.did.resolve(did);
20
- if (!doc || did !== (0, identity_1.getDid)(doc)) {
21
- throw new connect_1.ConnectError('identity not found', connect_1.Code.NotFound);
18
+ if (!doc || did !== getDid(doc)) {
19
+ throw new ConnectError('identity not found', Code.NotFound);
22
20
  }
23
21
  return getResultFromDoc(doc);
24
22
  },
@@ -47,10 +45,10 @@ const getResultFromDoc = (doc) => {
47
45
  };
48
46
  });
49
47
  return {
50
- did: (0, identity_1.getDid)(doc),
51
- handle: (0, identity_1.getHandle)(doc),
48
+ did: getDid(doc),
49
+ handle: getHandle(doc),
52
50
  keys: Buffer.from(JSON.stringify(keys)),
53
51
  services: Buffer.from(JSON.stringify(services)),
54
- updated: protobuf_1.Timestamp.fromDate(new Date()),
52
+ updated: Timestamp.fromDate(new Date()),
55
53
  };
56
54
  };
@@ -1,18 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const clio_connect_1 = require("../../../rpc/clio_connect");
7
- const identity_1 = __importDefault(require("./identity"));
8
- const profile_1 = __importDefault(require("./profile"));
9
- const records_1 = __importDefault(require("./records"));
10
- const sync_1 = __importDefault(require("./sync"));
11
- exports.default = (db, idResolver) => (router) => router.service(clio_connect_1.ClioService, {
12
- ...(0, identity_1.default)(db, idResolver),
13
- ...(0, profile_1.default)(db),
14
- ...(0, records_1.default)(db),
15
- ...(0, sync_1.default)(db),
1
+ import { ClioService } from '../../../rpc/clio_connect';
2
+ import identity from './identity';
3
+ import profile from './profile';
4
+ import records from './records';
5
+ import sync from './sync';
6
+ export default (db, idResolver) => (router) => router.service(ClioService, {
7
+ ...identity(db, idResolver),
8
+ ...profile(db),
9
+ ...records(db),
10
+ ...sync(db),
16
11
  async healthCheck() {
17
12
  return {};
18
13
  },
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const common_1 = require("@atproto/common");
4
- const util_1 = require("../../../util");
5
- const records_1 = require("./records");
6
- exports.default = (db) => ({
1
+ import { keyBy } from '@atproto/common';
2
+ import { parseRecordBytes } from '../../../util';
3
+ import { getRecords } from './records';
4
+ export default (db) => ({
7
5
  async getActors(req) {
8
6
  const { dids } = req;
9
7
  if (dids.length === 0) {
@@ -13,13 +11,13 @@ exports.default = (db) => ({
13
11
  const chatDeclarationUris = dids.map((did) => `at://${did}/chat.bsky.actor.declaration/self`);
14
12
  const [handlesRes, profiles, chatDeclarations] = await Promise.all([
15
13
  db.db.selectFrom('actor').selectAll().execute(),
16
- (0, records_1.getRecords)(db)({ uris: profileUris }),
17
- (0, records_1.getRecords)(db)({ uris: chatDeclarationUris }),
14
+ getRecords(db)({ uris: profileUris }),
15
+ getRecords(db)({ uris: chatDeclarationUris }),
18
16
  ]);
19
- const byDid = (0, common_1.keyBy)(handlesRes, 'did');
17
+ const byDid = keyBy(handlesRes, 'did');
20
18
  const actors = dids.map((did, i) => {
21
19
  const row = byDid.get(did);
22
- const chatDeclaration = (0, util_1.parseRecordBytes)(chatDeclarations.records[i].record);
20
+ const chatDeclaration = parseRecordBytes(chatDeclarations.records[i].record);
23
21
  return {
24
22
  exists: !!row,
25
23
  handle: row?.handle ?? undefined,
@@ -46,7 +44,7 @@ exports.default = (db) => ({
46
44
  .where('handle', 'in', handles)
47
45
  .selectAll()
48
46
  .execute();
49
- const byHandle = (0, common_1.keyBy)(res, 'handle');
47
+ const byHandle = keyBy(res, 'handle');
50
48
  const dids = handles.map((handle) => byHandle.get(handle)?.did ?? '');
51
49
  return { dids };
52
50
  },