fix(graphql): keep query ids fresh
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
### Changed
|
||||
- `mentions`: no hardcoded user; defaults to authenticated user or accepts `--user @handle`.
|
||||
- GraphQL query ID updater: correctly pairs `operationName` ↔ `queryId` (CreateTweet/CreateRetweet/etc).
|
||||
- `build:dist`: copies `src/lib/query-ids.json` into `dist/lib/query-ids.json` (keeps `dist/` in sync).
|
||||
|
||||
## 0.1.1 — 2025-12-26
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build": "pnpm run build:dist && pnpm run build:binary",
|
||||
"build:dist": "tsc",
|
||||
"build:dist": "tsc && node scripts/copy-dist-assets.js",
|
||||
"build:binary": "BIRD_VERSION=$(node -p \"require('./package.json').version\") BIRD_GIT_SHA=$(git rev-parse --short=8 HEAD 2>/dev/null || true) bun build --compile --minify --env=BIRD_* src/index.ts --outfile bird",
|
||||
"dev": "tsx src/index.ts",
|
||||
"bird": "pnpm run build:dist && node dist/index.js",
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
|
||||
const root = resolve(import.meta.dirname, '..');
|
||||
const files = [
|
||||
{
|
||||
from: resolve(root, 'src/lib/query-ids.json'),
|
||||
to: resolve(root, 'dist/lib/query-ids.json'),
|
||||
},
|
||||
];
|
||||
|
||||
for (const file of files) {
|
||||
mkdirSync(dirname(file.to), { recursive: true });
|
||||
writeFileSync(file.to, readFileSync(file.from));
|
||||
}
|
||||
|
||||
@@ -28,6 +28,18 @@ const BUNDLE_URL_REGEX =
|
||||
/https:\/\/abs\.twimg\.com\/responsive-web\/client-web(?:-legacy)?\/[A-Za-z0-9.-]+\.js/g;
|
||||
|
||||
const OPERATION_PATTERNS = [
|
||||
// Modern bundles export operations like:
|
||||
// e.exports={queryId:"...",operationName:"CreateTweet",operationType:"mutation",...}
|
||||
{
|
||||
regex: /e\.exports=\{queryId\s*:\s*["']([^"']+)["']\s*,\s*operationName\s*:\s*["']([^"']+)["']/gs,
|
||||
operationGroup: 2,
|
||||
queryIdGroup: 1,
|
||||
},
|
||||
{
|
||||
regex: /e\.exports=\{operationName\s*:\s*["']([^"']+)["']\s*,\s*queryId\s*:\s*["']([^"']+)["']/gs,
|
||||
operationGroup: 1,
|
||||
queryIdGroup: 2,
|
||||
},
|
||||
{
|
||||
regex: /operationName\s*[:=]\s*["']([^"']+)["'](.{0,4000}?)queryId\s*[:=]\s*["']([^"']+)["']/gs,
|
||||
operationGroup: 1,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"CreateTweet": "2BA2DIWTRVxHgKc4Xh2uKQ",
|
||||
"CreateRetweet": "Uf3io9zVp1DsYxrmL5FJ7g",
|
||||
"FavoriteTweet": "kuFUYP9eV1FPoEy4N-pi7w",
|
||||
"CreateTweet": "Uf3io9zVp1DsYxrmL5FJ7g",
|
||||
"CreateRetweet": "LFho5rIi4xcKO90p9jwG7A",
|
||||
"FavoriteTweet": "lI07N6Otwv1PhnEgXILM7A",
|
||||
"TweetDetail": "97JF30KziU00483E_8elBA",
|
||||
"SearchTimeline": "5h0kNbk3ii97rmfY6CdgAA"
|
||||
"SearchTimeline": "M1jEez78PEfVfbQLvlWMvQ"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user