Update & format
This commit is contained in:
40
packages/backend/convex/_generated/api.d.ts
vendored
40
packages/backend/convex/_generated/api.d.ts
vendored
@@ -12,18 +12,18 @@ import type {
|
||||
ApiFromModules,
|
||||
FilterApi,
|
||||
FunctionReference,
|
||||
} from "convex/server";
|
||||
import type * as auth from "../auth.js";
|
||||
import type * as crons from "../crons.js";
|
||||
import type * as custom_auth_index from "../custom/auth/index.js";
|
||||
import type * as custom_auth_password_reset from "../custom/auth/password/reset.js";
|
||||
import type * as custom_auth_password_validate from "../custom/auth/password/validate.js";
|
||||
import type * as custom_auth_providers_entra from "../custom/auth/providers/entra.js";
|
||||
import type * as custom_auth_providers_password from "../custom/auth/providers/password.js";
|
||||
import type * as custom_auth_providers_usesend from "../custom/auth/providers/usesend.js";
|
||||
import type * as files from "../files.js";
|
||||
import type * as http from "../http.js";
|
||||
import type * as statuses from "../statuses.js";
|
||||
} from 'convex/server';
|
||||
import type * as auth from '../auth.js';
|
||||
import type * as crons from '../crons.js';
|
||||
import type * as custom_auth_index from '../custom/auth/index.js';
|
||||
import type * as custom_auth_password_reset from '../custom/auth/password/reset.js';
|
||||
import type * as custom_auth_password_validate from '../custom/auth/password/validate.js';
|
||||
import type * as custom_auth_providers_entra from '../custom/auth/providers/entra.js';
|
||||
import type * as custom_auth_providers_password from '../custom/auth/providers/password.js';
|
||||
import type * as custom_auth_providers_usesend from '../custom/auth/providers/usesend.js';
|
||||
import type * as files from '../files.js';
|
||||
import type * as http from '../http.js';
|
||||
import type * as statuses from '../statuses.js';
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's API.
|
||||
@@ -36,21 +36,21 @@ import type * as statuses from "../statuses.js";
|
||||
declare const fullApi: ApiFromModules<{
|
||||
auth: typeof auth;
|
||||
crons: typeof crons;
|
||||
"custom/auth/index": typeof custom_auth_index;
|
||||
"custom/auth/password/reset": typeof custom_auth_password_reset;
|
||||
"custom/auth/password/validate": typeof custom_auth_password_validate;
|
||||
"custom/auth/providers/entra": typeof custom_auth_providers_entra;
|
||||
"custom/auth/providers/password": typeof custom_auth_providers_password;
|
||||
"custom/auth/providers/usesend": typeof custom_auth_providers_usesend;
|
||||
'custom/auth/index': typeof custom_auth_index;
|
||||
'custom/auth/password/reset': typeof custom_auth_password_reset;
|
||||
'custom/auth/password/validate': typeof custom_auth_password_validate;
|
||||
'custom/auth/providers/entra': typeof custom_auth_providers_entra;
|
||||
'custom/auth/providers/password': typeof custom_auth_providers_password;
|
||||
'custom/auth/providers/usesend': typeof custom_auth_providers_usesend;
|
||||
files: typeof files;
|
||||
http: typeof http;
|
||||
statuses: typeof statuses;
|
||||
}>;
|
||||
export declare const api: FilterApi<
|
||||
typeof fullApi,
|
||||
FunctionReference<any, "public">
|
||||
FunctionReference<any, 'public'>
|
||||
>;
|
||||
export declare const internal: FilterApi<
|
||||
typeof fullApi,
|
||||
FunctionReference<any, "internal">
|
||||
FunctionReference<any, 'internal'>
|
||||
>;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { anyApi } from "convex/server";
|
||||
import { anyApi } from 'convex/server';
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's API.
|
||||
|
@@ -13,9 +13,9 @@ import type {
|
||||
DocumentByName,
|
||||
TableNamesInDataModel,
|
||||
SystemTableNames,
|
||||
} from "convex/server";
|
||||
import type { GenericId } from "convex/values";
|
||||
import schema from "../schema.js";
|
||||
} from 'convex/server';
|
||||
import type { GenericId } from 'convex/values';
|
||||
import schema from '../schema.js';
|
||||
|
||||
/**
|
||||
* The names of all of your Convex tables.
|
||||
|
16
packages/backend/convex/_generated/server.d.ts
vendored
16
packages/backend/convex/_generated/server.d.ts
vendored
@@ -18,8 +18,8 @@ import {
|
||||
GenericQueryCtx,
|
||||
GenericDatabaseReader,
|
||||
GenericDatabaseWriter,
|
||||
} from "convex/server";
|
||||
import type { DataModel } from "./dataModel.js";
|
||||
} from 'convex/server';
|
||||
import type { DataModel } from './dataModel.js';
|
||||
|
||||
/**
|
||||
* Define a query in this Convex app's public API.
|
||||
@@ -29,7 +29,7 @@ import type { DataModel } from "./dataModel.js";
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const query: QueryBuilder<DataModel, "public">;
|
||||
export declare const query: QueryBuilder<DataModel, 'public'>;
|
||||
|
||||
/**
|
||||
* Define a query that is only accessible from other Convex functions (but not from the client).
|
||||
@@ -39,7 +39,7 @@ export declare const query: QueryBuilder<DataModel, "public">;
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
||||
export declare const internalQuery: QueryBuilder<DataModel, 'internal'>;
|
||||
|
||||
/**
|
||||
* Define a mutation in this Convex app's public API.
|
||||
@@ -49,7 +49,7 @@ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const mutation: MutationBuilder<DataModel, "public">;
|
||||
export declare const mutation: MutationBuilder<DataModel, 'public'>;
|
||||
|
||||
/**
|
||||
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
||||
@@ -59,7 +59,7 @@ export declare const mutation: MutationBuilder<DataModel, "public">;
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
||||
export declare const internalMutation: MutationBuilder<DataModel, 'internal'>;
|
||||
|
||||
/**
|
||||
* Define an action in this Convex app's public API.
|
||||
@@ -72,7 +72,7 @@ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
||||
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const action: ActionBuilder<DataModel, "public">;
|
||||
export declare const action: ActionBuilder<DataModel, 'public'>;
|
||||
|
||||
/**
|
||||
* Define an action that is only accessible from other Convex functions (but not from the client).
|
||||
@@ -80,7 +80,7 @@ export declare const action: ActionBuilder<DataModel, "public">;
|
||||
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
||||
export declare const internalAction: ActionBuilder<DataModel, 'internal'>;
|
||||
|
||||
/**
|
||||
* Define an HTTP action.
|
||||
|
@@ -16,7 +16,7 @@ import {
|
||||
internalActionGeneric,
|
||||
internalMutationGeneric,
|
||||
internalQueryGeneric,
|
||||
} from "convex/server";
|
||||
} from 'convex/server';
|
||||
|
||||
/**
|
||||
* Define a query in this Convex app's public API.
|
||||
|
@@ -176,4 +176,3 @@ export const updateUserPassword = action({
|
||||
return { success: true };
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -19,10 +19,12 @@ export const UsesendOTPPasswordReset = Usesend({
|
||||
const useSend = new UseSend(provider.apiKey, 'https://usesend.gbrown.org');
|
||||
const { error } = await useSend.emails.send({
|
||||
to: [email],
|
||||
from: provider.from ?? 'TechTracker Admin <admin@mail.techtracker.gbrown.org>',
|
||||
from:
|
||||
provider.from ??
|
||||
'TechTracker Admin <admin@mail.techtracker.gbrown.org>',
|
||||
subject: `Reset your password - TechTracker`,
|
||||
text: `Your password reset code is ${token}`,
|
||||
});
|
||||
if (error) throw new Error("Usesend error: " + error.message)
|
||||
if (error) throw new Error('Usesend error: ' + error.message);
|
||||
},
|
||||
});
|
||||
|
@@ -4,52 +4,57 @@ import { UseSend } from 'usesend-js';
|
||||
/** @todo Document this */
|
||||
export const Usesend = (config: EmailUserConfig): EmailConfig => {
|
||||
return {
|
||||
id: "usesend",
|
||||
type: "email",
|
||||
name: "Usesend",
|
||||
from: "TechTracker Admin <admin@mail.techtracker.gbrown.org>",
|
||||
id: 'usesend',
|
||||
type: 'email',
|
||||
name: 'Usesend',
|
||||
from: 'TechTracker Admin <admin@mail.techtracker.gbrown.org>',
|
||||
maxAge: 24 * 60 * 60,
|
||||
async sendVerificationRequest(params) {
|
||||
const { identifier: to, provider, url, theme } = params
|
||||
const { host } = new URL(url)
|
||||
const useSend = new UseSend(provider.apiKey, 'https://usesend.gbrown.org')
|
||||
const { identifier: to, provider, url, theme } = params;
|
||||
const { host } = new URL(url);
|
||||
const useSend = new UseSend(
|
||||
provider.apiKey,
|
||||
'https://usesend.gbrown.org',
|
||||
);
|
||||
const { error } = await useSend.emails.send({
|
||||
to,
|
||||
from: provider.from ?? 'TechTracker Admin <admin@mail.techtracker.gbrown.org>',
|
||||
from:
|
||||
provider.from ??
|
||||
'TechTracker Admin <admin@mail.techtracker.gbrown.org>',
|
||||
subject: `Sign in to ${host}`,
|
||||
html: html({ url, host, theme }),
|
||||
text: text({ url, host })
|
||||
text: text({ url, host }),
|
||||
});
|
||||
if (error) throw new Error("Usesend error: " + error.message)
|
||||
if (error) throw new Error('Usesend error: ' + error.message);
|
||||
},
|
||||
options: config,
|
||||
};
|
||||
};
|
||||
|
||||
type Theme = {
|
||||
colorScheme?: "auto" | "dark" | "light"
|
||||
logo?: string
|
||||
brandColor?: string
|
||||
buttonText?: string
|
||||
type Theme = {
|
||||
colorScheme?: 'auto' | 'dark' | 'light';
|
||||
logo?: string;
|
||||
brandColor?: string;
|
||||
buttonText?: string;
|
||||
};
|
||||
|
||||
const text = ({ url, host }: { url: string; host: string }) => {
|
||||
return `Sign in to ${host}\n${url}\n\n`
|
||||
return `Sign in to ${host}\n${url}\n\n`;
|
||||
};
|
||||
|
||||
const html = (params: { url: string; host: string; theme: Theme }) => {
|
||||
const { url, host, theme } = params;
|
||||
|
||||
const escapedHost = host.replace(/\./g, "​.");
|
||||
const escapedHost = host.replace(/\./g, '​.');
|
||||
|
||||
const brandColor = theme.brandColor || "#346df1";
|
||||
const brandColor = theme.brandColor || '#346df1';
|
||||
|
||||
const buttonText = theme.buttonText || "#fff";
|
||||
const buttonText = theme.buttonText || '#fff';
|
||||
|
||||
const color = {
|
||||
background: "#f9f9f9",
|
||||
text: "#444",
|
||||
mainBackground: "#fff",
|
||||
background: '#f9f9f9',
|
||||
text: '#444',
|
||||
mainBackground: '#fff',
|
||||
buttonBackground: brandColor,
|
||||
buttonBorder: brandColor,
|
||||
buttonText,
|
||||
@@ -85,5 +90,5 @@ const html = (params: { url: string; host: string; theme: Theme }) => {
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
`
|
||||
`;
|
||||
};
|
||||
|
@@ -12,7 +12,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@oslojs/crypto": "^1.0.1",
|
||||
"convex": "^1.27.1",
|
||||
"convex": "^1.27.3",
|
||||
"usesend-js": "^1.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Reference in New Issue
Block a user