Fix TypeScript compilation issues in packages
- Add explicit type annotations for isolatedDeclarations - Export Database type alias from db-schema - Fix import paths and add proper type exports - Update common schemas with better exports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
import { oc } from "@orpc/contract";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
signupInputSchema,
|
||||
verifyEmailInputSchema,
|
||||
loginRequestInputSchema,
|
||||
loginRequestOutputSchema,
|
||||
loginPasswordInputSchema,
|
||||
loginStatusOutputSchema,
|
||||
forgotPasswordInputSchema,
|
||||
resetPasswordInputSchema,
|
||||
} from "./schemas/auth.js";
|
||||
import {
|
||||
userProfileSchema,
|
||||
setupProfileInputSchema,
|
||||
updateProfileInputSchema,
|
||||
setPasswordInputSchema,
|
||||
passkeyOutputSchema,
|
||||
sessionOutputSchema,
|
||||
deviceOutputSchema,
|
||||
trustDeviceInputSchema,
|
||||
} from "./schemas/user.js";
|
||||
import {
|
||||
createOrgInputSchema,
|
||||
orgOutputSchema,
|
||||
orgMemberOutputSchema,
|
||||
updateMemberRoleInputSchema,
|
||||
createInviteInputSchema,
|
||||
orgInviteOutputSchema,
|
||||
orgSiteOutputSchema,
|
||||
} from "./schemas/org.js";
|
||||
import {
|
||||
adminAddSiteInputSchema,
|
||||
adminCreateOrgInputSchema,
|
||||
adminCreateUserInputSchema,
|
||||
adminUpdateUserInputSchema,
|
||||
adminAddSiteInputSchema,
|
||||
} from "./schemas/admin.js";
|
||||
import {
|
||||
forgotPasswordInputSchema,
|
||||
loginPasswordInputSchema,
|
||||
loginRequestInputSchema,
|
||||
loginRequestOutputSchema,
|
||||
loginStatusOutputSchema,
|
||||
resetPasswordInputSchema,
|
||||
signupInputSchema,
|
||||
verifyEmailInputSchema,
|
||||
} from "./schemas/auth.js";
|
||||
import { emailSchema, slugSchema } from "./schemas/common.js";
|
||||
import {
|
||||
createInviteInputSchema,
|
||||
createOrgInputSchema,
|
||||
orgInviteOutputSchema,
|
||||
orgMemberOutputSchema,
|
||||
orgOutputSchema,
|
||||
orgSiteOutputSchema,
|
||||
updateMemberRoleInputSchema,
|
||||
} from "./schemas/org.js";
|
||||
import {
|
||||
deviceOutputSchema,
|
||||
passkeyOutputSchema,
|
||||
sessionOutputSchema,
|
||||
setPasswordInputSchema,
|
||||
setupProfileInputSchema,
|
||||
trustDeviceInputSchema,
|
||||
updateProfileInputSchema,
|
||||
userProfileSchema,
|
||||
} from "./schemas/user.js";
|
||||
|
||||
/**
|
||||
* oRPC API Contract for the Publisher Dashboard
|
||||
@@ -73,28 +73,28 @@ export const contract = oc.router({
|
||||
z.object({
|
||||
challengeId: z.number(),
|
||||
options: z.any(), // PublicKeyCredentialCreationOptionsJSON
|
||||
})
|
||||
}),
|
||||
),
|
||||
verifyRegistration: oc
|
||||
.input(
|
||||
z.object({
|
||||
challengeId: z.number(),
|
||||
response: z.any(), // RegistrationResponseJSON
|
||||
})
|
||||
}),
|
||||
)
|
||||
.output(z.void()),
|
||||
createAuthenticationOptions: oc.output(
|
||||
z.object({
|
||||
challengeId: z.number(),
|
||||
options: z.any(), // PublicKeyCredentialRequestOptionsJSON
|
||||
})
|
||||
}),
|
||||
),
|
||||
verifyAuthentication: oc
|
||||
.input(
|
||||
z.object({
|
||||
challengeId: z.number(),
|
||||
response: z.any(), // AuthenticationResponseJSON
|
||||
})
|
||||
}),
|
||||
)
|
||||
.output(z.void()),
|
||||
}),
|
||||
@@ -110,27 +110,31 @@ export const contract = oc.router({
|
||||
// Authentication settings
|
||||
setPassword: oc.input(setPasswordInputSchema).output(z.void()),
|
||||
listPasskeys: oc.output(z.array(passkeyOutputSchema)),
|
||||
createPasskey: oc
|
||||
.input(z.object({ name: z.string() }))
|
||||
.output(
|
||||
createPasskey: oc.input(z.object({ name: z.string() })).output(
|
||||
z.object({
|
||||
challengeId: z.number(),
|
||||
options: z.any(), // PublicKeyCredentialCreationOptionsJSON
|
||||
})
|
||||
}),
|
||||
),
|
||||
renamePasskey: oc
|
||||
.input(z.object({ passkeyId: z.number(), name: z.string() }))
|
||||
.output(z.void()),
|
||||
deletePasskey: oc.input(z.object({ passkeyId: z.number() })).output(z.void()),
|
||||
deletePasskey: oc
|
||||
.input(z.object({ passkeyId: z.number() }))
|
||||
.output(z.void()),
|
||||
|
||||
// Sessions & devices
|
||||
listSessions: oc.output(z.array(sessionOutputSchema)),
|
||||
revokeSession: oc.input(z.object({ sessionId: z.number() })).output(z.void()),
|
||||
revokeSession: oc
|
||||
.input(z.object({ sessionId: z.number() }))
|
||||
.output(z.void()),
|
||||
revokeAllSessions: oc.output(z.void()),
|
||||
getDeviceInfo: oc.output(deviceOutputSchema),
|
||||
trustDevice: oc.input(trustDeviceInputSchema).output(z.void()),
|
||||
listTrustedDevices: oc.output(z.array(deviceOutputSchema)),
|
||||
untrustDevice: oc.input(z.object({ deviceId: z.number() })).output(z.void()),
|
||||
untrustDevice: oc
|
||||
.input(z.object({ deviceId: z.number() }))
|
||||
.output(z.void()),
|
||||
revokeAllTrustedDevices: oc.output(z.void()),
|
||||
}),
|
||||
|
||||
@@ -147,7 +151,7 @@ export const contract = oc.router({
|
||||
slug: slugSchema,
|
||||
displayName: z.string().optional(),
|
||||
logoUrl: z.string().optional(),
|
||||
})
|
||||
}),
|
||||
)
|
||||
.output(z.void()),
|
||||
delete: oc.input(z.object({ slug: slugSchema })).output(z.void()),
|
||||
@@ -198,7 +202,7 @@ export const contract = oc.router({
|
||||
slug: slugSchema,
|
||||
displayName: z.string().optional(),
|
||||
logoUrl: z.string().optional(),
|
||||
})
|
||||
}),
|
||||
)
|
||||
.output(z.void()),
|
||||
delete: oc.input(z.object({ slug: slugSchema })).output(z.void()),
|
||||
@@ -222,7 +226,9 @@ export const contract = oc.router({
|
||||
|
||||
// Admin auth management
|
||||
auth: oc.router({
|
||||
completeLogin: oc.input(z.object({ email: emailSchema })).output(z.void()),
|
||||
completeLogin: oc
|
||||
.input(z.object({ email: emailSchema }))
|
||||
.output(z.void()),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Export the contract
|
||||
export { contract } from "./contract.js";
|
||||
|
||||
export * from "./schemas/admin.js";
|
||||
export * from "./schemas/auth.js";
|
||||
// Export all schemas
|
||||
export * from "./schemas/common.js";
|
||||
export * from "./schemas/auth.js";
|
||||
export * from "./schemas/user.js";
|
||||
export * from "./schemas/org.js";
|
||||
export * from "./schemas/admin.js";
|
||||
export * from "./schemas/user.js";
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { parsePhoneNumberWithError, isValidPhoneNumber } from "libphonenumber-js";
|
||||
import {
|
||||
isValidPhoneNumber,
|
||||
parsePhoneNumberWithError,
|
||||
} from "libphonenumber-js";
|
||||
import { z } from "zod";
|
||||
|
||||
/**
|
||||
* Email schema - validates email format and transforms to lowercase
|
||||
*/
|
||||
export const emailSchema = z.string().email().toLowerCase() satisfies z.ZodTypeAny;
|
||||
export const emailSchema = z
|
||||
.string()
|
||||
.email()
|
||||
.toLowerCase() satisfies z.ZodTypeAny;
|
||||
|
||||
/**
|
||||
* Slug schema for org slugs
|
||||
@@ -15,7 +21,8 @@ export const slugSchema = z
|
||||
.min(2)
|
||||
.max(63)
|
||||
.regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/, {
|
||||
message: "Slug must be lowercase alphanumeric with hyphens (not at start/end)",
|
||||
message:
|
||||
"Slug must be lowercase alphanumeric with hyphens (not at start/end)",
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,7 +33,9 @@ export const phoneSchema = z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => {
|
||||
if (!val) return undefined;
|
||||
if (!val) {
|
||||
return undefined;
|
||||
}
|
||||
const phone = parsePhoneNumberWithError(val);
|
||||
return phone.format("E.164"); // +14155551234
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* @module @reviq/db-schema
|
||||
*/
|
||||
|
||||
export * from "./types.js";
|
||||
|
||||
// Re-export DB as Database for convenience
|
||||
export type { DB as Database } from "./types.js";
|
||||
export * from "./types.js";
|
||||
|
||||
@@ -16,9 +16,9 @@ export type Json = JsonValue;
|
||||
|
||||
export type JsonArray = JsonValue[];
|
||||
|
||||
export type JsonObject = {
|
||||
export interface JsonObject {
|
||||
[x: string]: JsonValue | undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export type JsonPrimitive = boolean | number | string | null;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* @module @reviq/db
|
||||
*/
|
||||
|
||||
import { Kysely, PostgresDialect } from "kysely";
|
||||
import type { Database } from "@reviq/db-schema";
|
||||
import { Kysely, PostgresDialect } from "kysely";
|
||||
import pg from "pg";
|
||||
|
||||
const { Pool } = pg;
|
||||
@@ -17,11 +17,11 @@ const { Pool } = pg;
|
||||
* @returns Kysely database instance
|
||||
*/
|
||||
export const createDb = (
|
||||
connectionString: string = process.env.DATABASE_URL || ""
|
||||
connectionString: string = process.env.DATABASE_URL || "",
|
||||
): Kysely<Database> => {
|
||||
if (!connectionString) {
|
||||
throw new Error(
|
||||
"Database connection string is required. Set DATABASE_URL environment variable."
|
||||
"Database connection string is required. Set DATABASE_URL environment variable.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* @module @reviq/db
|
||||
*/
|
||||
|
||||
import type { Kysely } from "kysely";
|
||||
import type { Database } from "@reviq/db-schema";
|
||||
import type { Kysely } from "kysely";
|
||||
import { createDb } from "./client.js";
|
||||
|
||||
/**
|
||||
@@ -15,12 +15,11 @@ import { createDb } from "./client.js";
|
||||
*/
|
||||
export const db: Kysely<Database> = createDb();
|
||||
|
||||
/**
|
||||
* Export createDb for creating custom database instances
|
||||
*/
|
||||
export { createDb } from "./client.js";
|
||||
|
||||
/**
|
||||
* Re-export database types from db-schema
|
||||
*/
|
||||
export type { Database } from "@reviq/db-schema";
|
||||
/**
|
||||
* Export createDb for creating custom database instances
|
||||
*/
|
||||
export { createDb } from "./client.js";
|
||||
|
||||
Reference in New Issue
Block a user