correctly generate nanoid IDs in default clauses
This commit is contained in:
parent
404532012e
commit
3f28680a44
@ -59,7 +59,7 @@ export const AiModelSchema = new Schema<IAiModel>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const AiProviderSchema = new Schema<IAiProvider>({
|
export const AiProviderSchema = new Schema<IAiProvider>({
|
||||||
_id: { type: String, required: true, default: nanoid, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
name: { type: String, required: true },
|
name: { type: String, required: true },
|
||||||
apiType: { type: String, enum: ["ollama", "openai"], required: true },
|
apiType: { type: String, enum: ["ollama", "openai"], required: true },
|
||||||
baseUrl: { type: String, required: true },
|
baseUrl: { type: String, required: true },
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export interface IApiClientLog {
|
|||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
export const ApiClientLogSchema = new Schema<IApiClientLog>({
|
export const ApiClientLogSchema = new Schema<IApiClientLog>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
client: { type: String, required: true, index: 1, ref: "ApiClient" },
|
client: { type: String, required: true, index: 1, ref: "ApiClient" },
|
||||||
createdAt: {
|
createdAt: {
|
||||||
type: Date,
|
type: Date,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export interface IApiClient {
|
|||||||
secret: string;
|
secret: string;
|
||||||
}
|
}
|
||||||
const ApiClientSchema = new Schema<IApiClient>({
|
const ApiClientSchema = new Schema<IApiClient>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, required: true },
|
createdAt: { type: Date, required: true },
|
||||||
updatedAt: { type: Date, required: true },
|
updatedAt: { type: Date, required: true },
|
||||||
status: {
|
status: {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export const ChatSessionPinSchema = new Schema<IChatSessionPin>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ChatSessionSchema = new Schema<IChatSession>({
|
export const ChatSessionSchema = new Schema<IChatSession>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, default: Date.now, required: true },
|
createdAt: { type: Date, default: Date.now, required: true },
|
||||||
lastMessageAt: { type: Date },
|
lastMessageAt: { type: Date },
|
||||||
user: { type: String, required: true, index: 1, ref: "User" },
|
user: { type: String, required: true, index: 1, ref: "User" },
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
IChatTurn,
|
IChatTurn,
|
||||||
IChatTurnStats,
|
IChatTurnStats,
|
||||||
} from "@gadget/api";
|
} from "@gadget/api";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export const ChatTurnPromptsSchema = new Schema<IChatTurnPrompts>({
|
export const ChatTurnPromptsSchema = new Schema<IChatTurnPrompts>({
|
||||||
user: { type: String, required: true },
|
user: { type: String, required: true },
|
||||||
@ -44,6 +45,7 @@ export const ChatSubagentProcessSchema = new Schema<IChatSubagentProcess>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ChatTurnSchema = new Schema<IChatTurn>({
|
export const ChatTurnSchema = new Schema<IChatTurn>({
|
||||||
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, default: Date.now, required: true },
|
createdAt: { type: Date, default: Date.now, required: true },
|
||||||
user: { type: String, required: true, ref: "User" },
|
user: { type: String, required: true, ref: "User" },
|
||||||
project: { type: String, required: false, ref: "Project" },
|
project: { type: String, required: false, ref: "Project" },
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
import { Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
|
|
||||||
import { GadgetId, IUser } from "@gadget/api";
|
import { GadgetId, IUser } from "@gadget/api";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export interface ICsrfToken {
|
export interface ICsrfToken {
|
||||||
_id: GadgetId;
|
_id: GadgetId;
|
||||||
@ -22,6 +23,7 @@ export interface ICsrfToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CsrfTokenSchema = new Schema<ICsrfToken>({
|
const CsrfTokenSchema = new Schema<ICsrfToken>({
|
||||||
|
_id: { type: String, default: () => nanoid() },
|
||||||
created: {
|
created: {
|
||||||
type: Date,
|
type: Date,
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import { Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
import { IDroneMonitor, IMemoryMonitor } from "@gadget/api";
|
import { IDroneMonitor, IMemoryMonitor } from "@gadget/api";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export const MemoryMonitorSchema = new Schema<IMemoryMonitor>({
|
export const MemoryMonitorSchema = new Schema<IMemoryMonitor>({
|
||||||
count: { type: Number, default: 0, required: true },
|
count: { type: Number, default: 0, required: true },
|
||||||
@ -11,6 +12,7 @@ export const MemoryMonitorSchema = new Schema<IMemoryMonitor>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const DroneMonitorSchema = new Schema<IDroneMonitor>({
|
export const DroneMonitorSchema = new Schema<IDroneMonitor>({
|
||||||
|
_id: { type: String, default: () => nanoid() },
|
||||||
registration: { type: String, required: true, index: 1 },
|
registration: { type: String, required: true, index: 1 },
|
||||||
timestamp: { type: Date, required: true, index: -1 },
|
timestamp: { type: Date, required: true, index: -1 },
|
||||||
memory: {
|
memory: {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { DroneStatus, IDroneRegistration } from "@gadget/api";
|
|||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export const DroneRegistrationSchema = new Schema<IDroneRegistration>({
|
export const DroneRegistrationSchema = new Schema<IDroneRegistration>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, required: true },
|
createdAt: { type: Date, required: true },
|
||||||
updatedAt: { type: Date, required: false },
|
updatedAt: { type: Date, required: false },
|
||||||
user: { type: String, ref: "User", required: true },
|
user: { type: String, ref: "User", required: true },
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export interface IEmailLog {
|
|||||||
messageId: string;
|
messageId: string;
|
||||||
}
|
}
|
||||||
export const EmailLogSchema = new Schema<IEmailLog>({
|
export const EmailLogSchema = new Schema<IEmailLog>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
created: { type: Date, default: Date.now, required: true, index: -1 },
|
created: { type: Date, default: Date.now, required: true, index: -1 },
|
||||||
from: { type: String, required: true },
|
from: { type: String, required: true },
|
||||||
to: { type: String, required: true },
|
to: { type: String, required: true },
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import { Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
import { GadgetId, IUser } from "@gadget/api";
|
import { GadgetId, IUser } from "@gadget/api";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export enum EmailVerificationStatus {
|
export enum EmailVerificationStatus {
|
||||||
Pending = "pending",
|
Pending = "pending",
|
||||||
@ -12,12 +13,14 @@ export enum EmailVerificationStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IEmailVerification {
|
export interface IEmailVerification {
|
||||||
|
_id: GadgetId;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
user: IUser | GadgetId;
|
user: IUser | GadgetId;
|
||||||
code: string;
|
code: string;
|
||||||
status: EmailVerificationStatus;
|
status: EmailVerificationStatus;
|
||||||
}
|
}
|
||||||
export const EmailVerificationSchema = new Schema<IEmailVerification>({
|
export const EmailVerificationSchema = new Schema<IEmailVerification>({
|
||||||
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, required: true, default: Date.now },
|
createdAt: { type: Date, required: true, default: Date.now },
|
||||||
user: { type: String, required: true, index: 1, ref: "User" },
|
user: { type: String, required: true, index: 1, ref: "User" },
|
||||||
code: { type: String, required: true, unique: true },
|
code: { type: String, required: true, unique: true },
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { nanoid } from "nanoid";
|
|||||||
import { IIdeSession } from "@gadget/api";
|
import { IIdeSession } from "@gadget/api";
|
||||||
|
|
||||||
const IdeSessionSchema = new Schema<IIdeSession>({
|
const IdeSessionSchema = new Schema<IIdeSession>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, default: Date.now, required: true },
|
createdAt: { type: Date, default: Date.now, required: true },
|
||||||
user: { type: String, required: true, ref: "User" },
|
user: { type: String, required: true, ref: "User" },
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,8 +5,10 @@
|
|||||||
import { Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
|
|
||||||
import { ProjectStatus, IProject } from "@gadget/api";
|
import { ProjectStatus, IProject } from "@gadget/api";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export const ProjectSchema = new Schema<IProject>({
|
export const ProjectSchema = new Schema<IProject>({
|
||||||
|
_id: { type: String, default: () => nanoid() },
|
||||||
createdAt: { type: Date, default: Date.now, required: true },
|
createdAt: { type: Date, default: Date.now, required: true },
|
||||||
user: { type: String, required: true, index: 1, ref: "User" },
|
user: { type: String, required: true, index: 1, ref: "User" },
|
||||||
status: { type: String, enum: ProjectStatus, required: true },
|
status: { type: String, enum: ProjectStatus, required: true },
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export const UserFlagsSchema = new Schema<IUserFlags>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const UserSchema = new Schema<IUser>({
|
export const UserSchema = new Schema<IUser>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
email: { type: String, required: true },
|
email: { type: String, required: true },
|
||||||
email_lc: { type: String, required: true, lowercase: true, unique: true },
|
email_lc: { type: String, required: true, lowercase: true, unique: true },
|
||||||
passwordSalt: { type: String, required: true, select: false },
|
passwordSalt: { type: String, required: true, select: false },
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export interface IWebToken {
|
|||||||
token: string;
|
token: string;
|
||||||
}
|
}
|
||||||
export const WebTokenSchema = new Schema<IWebToken>({
|
export const WebTokenSchema = new Schema<IWebToken>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
created: { type: Date, required: true, index: 1 },
|
created: { type: Date, required: true, index: 1 },
|
||||||
expires: { type: Date, required: true, index: -1 },
|
expires: { type: Date, required: true, index: -1 },
|
||||||
user: { type: String, required: true, ref: "User" },
|
user: { type: String, required: true, ref: "User" },
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export interface IWebVisit {
|
|||||||
metroCode?: number;
|
metroCode?: number;
|
||||||
}
|
}
|
||||||
export const WebVisitSchema = new Schema<IWebVisit>({
|
export const WebVisitSchema = new Schema<IWebVisit>({
|
||||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
_id: { type: String, default: () => nanoid() },
|
||||||
created: { type: Date, default: Date.now },
|
created: { type: Date, default: Date.now },
|
||||||
url: { type: String, required: true },
|
url: { type: String, required: true },
|
||||||
user: { type: String, index: 1, ref: "User" },
|
user: { type: String, index: 1, ref: "User" },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user