From 68ac199c90fc8a5500e85d7d9dd8bf7a27bf2352 Mon Sep 17 00:00:00 2001 From: Ashlynne Mitchell Date: Thu, 22 May 2025 17:54:31 +1000 Subject: [PATCH] feat: add package for messing around with inserting records manually --- bun.lock | 27 +++++++++++++- packages/test/.gitignore | 36 +++++++++++++++++++ packages/test/README.md | 15 ++++++++ packages/test/index.ts | 71 +++++++++++++++++++++++++++++++++++++ packages/test/package.json | 18 ++++++++++ packages/test/tsconfig.json | 28 +++++++++++++++ 6 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 packages/test/.gitignore create mode 100644 packages/test/README.md create mode 100644 packages/test/index.ts create mode 100644 packages/test/package.json create mode 100644 packages/test/tsconfig.json diff --git a/bun.lock b/bun.lock index 29e8de0..789ea5f 100644 --- a/bun.lock +++ b/bun.lock @@ -42,9 +42,24 @@ "packages/lexicons": { "name": "@comet/lexicons", "dependencies": { - "@atcute/lex-cli": "^2.0.2", "@atcute/lexicons": "^1.0.3", }, + "devDependencies": { + "@atcute/lex-cli": "^2.0.2", + "@types/bun": "latest", + }, + "peerDependencies": { + "typescript": "^5", + }, + }, + "packages/test": { + "name": "test", + "dependencies": { + "@atcute/atproto": "^3.0.2", + "@atcute/bluesky": "^3.0.2", + "@atcute/client": "^4.0.2", + "@comet/lexicons": "workspace:", + }, "devDependencies": { "@types/bun": "latest", }, @@ -56,6 +71,14 @@ "packages": { "@ampproject/remapping": ["@ampproject/remapping@2.3.0", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw=="], + "@atcute/atproto": ["@atcute/atproto@3.0.2", "", { "dependencies": { "@atcute/lexicons": "^1.0.2" } }, "sha512-p37GqTmrxc1XaxtX8JsePEuomL+PtDeGdy0lcBm+HisD03ZZTia7MouxUpnYezX0l926fFaDc9tllIBtX9iSsQ=="], + + "@atcute/bluesky": ["@atcute/bluesky@3.0.2", "", { "dependencies": { "@atcute/atproto": "^3.0.2", "@atcute/lexicons": "^1.0.2" } }, "sha512-xDRu/8Rlu3uTG/Mf625vUvKiFvy3hdCE371pXSJpHofivNZxi+MburdmYgOsBWZstNMo4vTBUviWaLJpL23rFg=="], + + "@atcute/client": ["@atcute/client@4.0.2", "", { "dependencies": { "@atcute/identity": "^1.0.2", "@atcute/lexicons": "^1.0.2" } }, "sha512-AOs6DEm59I0+wt8JOEOjKQLtBYZMML9p40pxaEWqP/ukAlhYUfLc9Geby5CMBmh7TchQCMCSHQzrY/lDs026Bw=="], + + "@atcute/identity": ["@atcute/identity@1.0.2", "", { "dependencies": { "@atcute/lexicons": "^1.0.2", "@badrap/valita": "^0.4.4" } }, "sha512-SrDPHuEarEHj9bx7NfYn7DYG6kIgJIMRU581iOCIaVaiZ1WhE9D8QxTxeYG/rbGNSa85E891ECp1sQcKiBN0kg=="], + "@atcute/lex-cli": ["@atcute/lex-cli@2.0.2", "", { "dependencies": { "@atcute/lexicon-doc": "^1.0.1", "@badrap/valita": "^0.4.4", "@externdefs/collider": "^0.3.0", "picocolors": "^1.1.1", "prettier": "^3.5.3" }, "bin": { "lex-cli": "cli.mjs" } }, "sha512-GdudG2F4FKgFLdE7pB+aj2JOprCHkjlYtG1/rJriHKUZ5CPPfhd8A/+xMXaf9qoNqtyK4L7G3GYpd2PnS9bF8Q=="], "@atcute/lexicon-doc": ["@atcute/lexicon-doc@1.0.1", "", { "dependencies": { "@badrap/valita": "^0.4.4" } }, "sha512-BcuCN8aPXP1QfVAy6B6SXDiNMD0Whqsp4QhFShVpOdGjZIRbSxlRaTkY1rT3peNZy5zi1U5y1LlqGdoXa79wVg=="], @@ -586,6 +609,8 @@ "tar": ["tar@7.4.3", "", { "dependencies": { "@isaacs/fs-minipass": "^4.0.0", "chownr": "^3.0.0", "minipass": "^7.1.2", "minizlib": "^3.0.1", "mkdirp": "^3.0.1", "yallist": "^5.0.0" } }, "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw=="], + "test": ["test@workspace:packages/test"], + "tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], diff --git a/packages/test/.gitignore b/packages/test/.gitignore new file mode 100644 index 0000000..88f3428 --- /dev/null +++ b/packages/test/.gitignore @@ -0,0 +1,36 @@ +# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store + +*.opus \ No newline at end of file diff --git a/packages/test/README.md b/packages/test/README.md new file mode 100644 index 0000000..4a65cfc --- /dev/null +++ b/packages/test/README.md @@ -0,0 +1,15 @@ +# test + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.2.8. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/packages/test/index.ts b/packages/test/index.ts new file mode 100644 index 0000000..0ff07e7 --- /dev/null +++ b/packages/test/index.ts @@ -0,0 +1,71 @@ +import { Client, CredentialManager, ok } from "@atcute/client"; + +import type {} from "@atcute/bluesky"; +import type {} from "@atcute/atproto"; +import { ShCometV0FeedPlaylist, ShCometV0FeedTrack } from "@comet/lexicons"; + +// const manager = new CredentialManager({ service: "https://pds.ovy.sh" }); +const manager = new CredentialManager({ service: "https://bsky.social" }); +const rpc = new Client({ handler: manager }); + +await manager.login({ + identifier: Bun.env.COMET_TEST_IDENT!, + password: Bun.env.COMET_TEST_PASSWORD!, +}); + +// const inputAudio = Bun.file("./test-track.opus"); +// const { blob: audio } = await ok( +// rpc.post("com.atproto.repo.uploadBlob", { input: inputAudio }), +// ); + +// const audio = { +// $type: "blob", +// ref: { +// $link: "bafkreifiu63dr52dxzrurnspha5xvzlzqkho3hdzdhu6zvthrrvdpd6yve", +// }, +// mimeType: "audio/opus", +// size: 3349806, +// } as const; + +// const track: ShCometV0FeedTrack.Main = { +// $type: "sh.comet.v0.feed.track", +// audio, +// title: "Testing Track 5", +// createdAt: new Date().toJSON(), +// }; + +// const response = await ok( +// rpc.post("com.atproto.repo.createRecord", { +// input: { +// collection: track.$type, +// repo: manager.session!.did, +// record: track, +// }, +// }), +// ); + +const playlist: ShCometV0FeedPlaylist.Main = { + $type: "sh.comet.v0.feed.playlist", + tracks: [ + "at://did:plc:jrrhosrfzgjf6v4oydav6ftb/sh.comet.v0.feed.track/3lpq2gsib2s2e", + "at://did:plc:jrrhosrfzgjf6v4oydav6ftb/sh.comet.v0.feed.track/3lpq2muqtnu2w", + "at://did:plc:jrrhosrfzgjf6v4oydav6ftb/sh.comet.v0.feed.track/3lpq2njjm6p2y", + "at://did:plc:jrrhosrfzgjf6v4oydav6ftb/sh.comet.v0.feed.track/3lpq2nrehj52o", + "at://did:plc:jrrhosrfzgjf6v4oydav6ftb/sh.comet.v0.feed.track/3lpq2nnacyg23", + ], + title: "Testing Playlist", + type: "sh.comet.v0.feed.playlist#playlist", + createdAt: new Date().toJSON(), +}; + +const response = await ok( + rpc.post("com.atproto.repo.createRecord", { + input: { + collection: playlist.$type, + repo: manager.session!.did, + record: playlist, + }, + }), +); + +console.log(response); diff --git a/packages/test/package.json b/packages/test/package.json new file mode 100644 index 0000000..a2fd72c --- /dev/null +++ b/packages/test/package.json @@ -0,0 +1,18 @@ +{ + "name": "test", + "module": "index.ts", + "type": "module", + "private": true, + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5" + }, + "dependencies": { + "@atcute/atproto": "^3.0.2", + "@atcute/bluesky": "^3.0.2", + "@atcute/client": "^4.0.2", + "@comet/lexicons": "workspace:*" + } +} diff --git a/packages/test/tsconfig.json b/packages/test/tsconfig.json new file mode 100644 index 0000000..9c62f74 --- /dev/null +++ b/packages/test/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + // Environment setup & latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} -- 2.51.2