fix native import
This commit is contained in:
parent
10072d6e4d
commit
0224824a36
|
@ -70,7 +70,7 @@ cfg_if! {
|
||||||
use crate::model::repository::Repository;
|
use crate::model::repository::Repository;
|
||||||
|
|
||||||
/// For NAPI because [chrono] is not supported.
|
/// For NAPI because [chrono] is not supported.
|
||||||
#[napi]
|
#[napi(object)]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, JsonSchema, ToSchema)]
|
#[derive(Clone, Debug, PartialEq, Eq, JsonSchema, ToSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct NativeAntennaSchema {
|
pub struct NativeAntennaSchema {
|
||||||
|
@ -97,28 +97,24 @@ cfg_if! {
|
||||||
pub has_unread_note: bool,
|
pub has_unread_note: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi(string_enum)]
|
||||||
#[derive(Debug, FromStr, PartialEq, Eq, JsonSchema, ToSchema)]
|
#[derive(Debug, FromStr, PartialEq, Eq, JsonSchema, ToSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[display(style = "camelCase")]
|
|
||||||
#[display("'{}'")]
|
#[display("'{}'")]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
pub enum NativeAntennaSrc {
|
pub enum NativeAntennaSrc {
|
||||||
Home,
|
home,
|
||||||
All,
|
all,
|
||||||
Users,
|
users,
|
||||||
List,
|
list,
|
||||||
Group,
|
group,
|
||||||
Instances,
|
instances,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
impl NativeAntennaSchema {
|
pub async fn native_pack_antenna_by_id(id: String) -> napi::Result<NativeAntennaSchema> {
|
||||||
#[napi]
|
|
||||||
pub async fn pack_by_id(id: String) -> napi::Result<NativeAntennaSchema> {
|
|
||||||
antenna::Model::pack_by_id(id).await.map_err(Into::into)
|
antenna::Model::pack_by_id(id).await.map_err(Into::into)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import { nativeCreateId, nativeInitIdGenerator } from "native-utils/built";
|
import { nativeCreateId, nativeInitIdGenerator } from "native-utils/built/index.js";
|
||||||
|
|
||||||
const length = Math.min(Math.max(config.cuid?.length ?? 16, 16), 24);
|
const length = Math.min(Math.max(config.cuid?.length ?? 16, 16), 24);
|
||||||
const fingerprint = config.cuid?.fingerprint ?? "";
|
const fingerprint = config.cuid?.fingerprint ?? "";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { nativeRandomStr } from "native-utils/built";
|
import { nativeRandomStr } from "native-utils/built/index.js";
|
||||||
|
|
||||||
export function secureRndstr(length = 32, _ = true): string {
|
export function secureRndstr(length = 32, _ = true): string {
|
||||||
return nativeRandomStr(length);
|
return nativeRandomStr(length);
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
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 { AntennaSchema } from "native-utils/built/index.js";
|
import {
|
||||||
|
NativeAntennaSchema,
|
||||||
|
nativePackAntennaById,
|
||||||
|
} from "native-utils/built/index.js";
|
||||||
|
|
||||||
export const AntennaRepository = db.getRepository(Antenna).extend({
|
export const AntennaRepository = db.getRepository(Antenna).extend({
|
||||||
async pack(src: Antenna["id"] | Antenna): Promise<AntennaSchema> {
|
async pack(src: Antenna["id"] | Antenna): Promise<NativeAntennaSchema> {
|
||||||
const id =
|
const id = typeof src === "object" ? src.id : src;
|
||||||
typeof src === "object" ? src.id : src;
|
|
||||||
|
|
||||||
return await AntennaSchema.packById(id);
|
return await nativePackAntennaById(id);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue