mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-28 21:08:52 -07:00
use schema in native-utils
This commit is contained in:
parent
bc209143e6
commit
3af4a86254
4 changed files with 11 additions and 34 deletions
|
@ -23,8 +23,8 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@napi-rs/cli": "^2.15.0",
|
"@napi-rs/cli": "2.15.0",
|
||||||
"ava": "^5.1.1"
|
"ava": "5.1.1"
|
||||||
},
|
},
|
||||||
"ava": {
|
"ava": {
|
||||||
"timeout": "3m"
|
"timeout": "3m"
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
"test": "ava",
|
"test": "ava",
|
||||||
"universal": "napi universal",
|
"universal": "napi universal",
|
||||||
"version": "napi version",
|
"version": "napi version",
|
||||||
"cargo:unit": "cargo test --workspace unit_test",
|
"cargo:unit": "cargo test unit_test",
|
||||||
"cargo:integration": "cargo test --workspace int_test -- --test-threads=1"
|
"cargo:integration": "cargo test --no-default-features int_test -- --test-threads=1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"migrate": "typeorm migration:run -d ormconfig.js",
|
"migrate": "typeorm migration:run -d ormconfig.js",
|
||||||
"revertmigration": "typeorm migration:revert -d ormconfig.js",
|
"revertmigration": "typeorm migration:revert -d ormconfig.js",
|
||||||
"check:connect": "node ./check_connect.js",
|
"check:connect": "node ./check_connect.js",
|
||||||
"build": "napi build --platform --release --cargo-cwd native-utils ./native-utils/built/ && pnpm swc src -d built -D",
|
"build": "pnpm swc src -d built -D",
|
||||||
"watch": "pnpm swc src -d built -D -w",
|
"watch": "pnpm swc src -d built -D -w",
|
||||||
"lint": "pnpm rome check \"src/**/*.ts\"",
|
"lint": "pnpm rome check \"src/**/*.ts\"",
|
||||||
"mocha": "cross-env NODE_ENV=test TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha",
|
"mocha": "cross-env NODE_ENV=test TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha",
|
||||||
|
|
|
@ -1,36 +1,12 @@
|
||||||
import { db } from "@/db/postgre.js";
|
import { db } from "@/db/postgre.js";
|
||||||
import { Antenna } from "@/models/entities/antenna.js";
|
import { Antenna } from "@/models/entities/antenna.js";
|
||||||
import type { Packed } from "@/misc/schema.js";
|
import { AntennaSchema } from "native-utils/built/index.js";
|
||||||
import { AntennaNotes, UserGroupJoinings } from "../index.js";
|
|
||||||
|
|
||||||
export const AntennaRepository = db.getRepository(Antenna).extend({
|
export const AntennaRepository = db.getRepository(Antenna).extend({
|
||||||
async pack(src: Antenna["id"] | Antenna): Promise<Packed<"Antenna">> {
|
async pack(src: Antenna["id"] | Antenna): Promise<AntennaSchema> {
|
||||||
const antenna =
|
const id =
|
||||||
typeof src === "object" ? src : await this.findOneByOrFail({ id: src });
|
typeof src === "object" ? src.id : src;
|
||||||
|
|
||||||
const hasUnreadNote =
|
return await AntennaSchema.packById(id);
|
||||||
(await AntennaNotes.findOneBy({ antennaId: antenna.id, read: false })) !=
|
|
||||||
null;
|
|
||||||
const userGroupJoining = antenna.userGroupJoiningId
|
|
||||||
? await UserGroupJoinings.findOneBy({ id: antenna.userGroupJoiningId })
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: antenna.id,
|
|
||||||
createdAt: antenna.createdAt.toISOString(),
|
|
||||||
name: antenna.name,
|
|
||||||
keywords: antenna.keywords,
|
|
||||||
excludeKeywords: antenna.excludeKeywords,
|
|
||||||
src: antenna.src,
|
|
||||||
userListId: antenna.userListId,
|
|
||||||
userGroupId: userGroupJoining ? userGroupJoining.userGroupId : null,
|
|
||||||
users: antenna.users,
|
|
||||||
instances: antenna.instances,
|
|
||||||
caseSensitive: antenna.caseSensitive,
|
|
||||||
notify: antenna.notify,
|
|
||||||
withReplies: antenna.withReplies,
|
|
||||||
withFile: antenna.withFile,
|
|
||||||
hasUnreadNote,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
packages:
|
packages:
|
||||||
- 'packages/backend'
|
- 'packages/backend'
|
||||||
|
- 'packages/backend/native-utils'
|
||||||
- 'packages/client'
|
- 'packages/client'
|
||||||
- 'packages/sw'
|
- 'packages/sw'
|
||||||
- 'packages/calckey-js'
|
- 'packages/calckey-js'
|
||||||
|
|
Loading…
Reference in a new issue