Merge branch 'zod-alias' into 'main'

zod import alias

See merge request soapbox-pub/ditto!177
This commit is contained in:
Alex Gleason 2024-04-23 20:07:45 +00:00
commit 6c74ce9c12
24 changed files with 52 additions and 24 deletions

View File

@ -19,7 +19,8 @@
"hono": "https://deno.land/x/hono@v3.10.1/mod.ts", "hono": "https://deno.land/x/hono@v3.10.1/mod.ts",
"hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts",
"kysely": "npm:kysely@^0.26.3", "kysely": "npm:kysely@^0.26.3",
"kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts" "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts",
"zod": "npm:zod@^3.23.4"
}, },
"lint": { "lint": {
"include": ["src/", "scripts/"], "include": ["src/", "scripts/"],

View File

@ -1,6 +1,7 @@
import url from 'node:url'; import url from 'node:url';
import { z } from 'zod';
import { dotenv, getPublicKey, nip19, z } from '@/deps.ts'; import { dotenv, getPublicKey, nip19 } from '@/deps.ts';
/** Load environment config from `.env` */ /** Load environment config from `.env` */
await dotenv.load({ await dotenv.load({

View File

@ -1,7 +1,9 @@
import { NostrFilter } from '@nostrify/nostrify'; import { NostrFilter } from '@nostrify/nostrify';
import { z } from 'zod';
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { nip19, z } from '@/deps.ts'; import { nip19 } from '@/deps.ts';
import { getAuthor, getFollowedPubkeys } from '@/queries.ts'; import { getAuthor, getFollowedPubkeys } from '@/queries.ts';
import { booleanParamSchema, fileSchema } from '@/schema.ts'; import { booleanParamSchema, fileSchema } from '@/schema.ts';
import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts';

View File

@ -1,6 +1,7 @@
import { z } from 'zod';
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { z } from '@/deps.ts';
import { booleanParamSchema } from '@/schema.ts'; import { booleanParamSchema } from '@/schema.ts';
import { eventsDB } from '@/storages.ts'; import { eventsDB } from '@/storages.ts';
import { renderAdminAccount } from '@/views/mastodon/admin-accounts.ts'; import { renderAdminAccount } from '@/views/mastodon/admin-accounts.ts';

View File

@ -1,5 +1,6 @@
import { z } from 'zod';
import { AppController } from '@/app.ts'; import { AppController } from '@/app.ts';
import { z } from '@/deps.ts';
import { fileSchema } from '@/schema.ts'; import { fileSchema } from '@/schema.ts';
import { parseBody } from '@/utils/api.ts'; import { parseBody } from '@/utils/api.ts';
import { renderAttachment } from '@/views/mastodon/attachments.ts'; import { renderAttachment } from '@/views/mastodon/attachments.ts';

View File

@ -1,4 +1,6 @@
import { lodash, nip19, z } from '@/deps.ts'; import { z } from 'zod';
import { lodash, nip19 } from '@/deps.ts';
import { AppController } from '@/app.ts'; import { AppController } from '@/app.ts';
import { nostrNow } from '@/utils.ts'; import { nostrNow } from '@/utils.ts';
import { parseBody } from '@/utils/api.ts'; import { parseBody } from '@/utils/api.ts';

View File

@ -1,6 +1,7 @@
import { z } from 'zod';
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { z } from '@/deps.ts';
import { configSchema, elixirTupleSchema, type PleromaConfig } from '@/schemas/pleroma-api.ts'; import { configSchema, elixirTupleSchema, type PleromaConfig } from '@/schemas/pleroma-api.ts';
import { AdminSigner } from '@/signers/AdminSigner.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts';
import { eventsDB } from '@/storages.ts'; import { eventsDB } from '@/storages.ts';

View File

@ -1,6 +1,8 @@
import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
import { z } from 'zod';
import { AppController } from '@/app.ts'; import { AppController } from '@/app.ts';
import { nip19, z } from '@/deps.ts'; import { nip19 } from '@/deps.ts';
import { booleanParamSchema } from '@/schema.ts'; import { booleanParamSchema } from '@/schema.ts';
import { nostrIdSchema } from '@/schemas/nostr.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts';
import { searchStore } from '@/storages.ts'; import { searchStore } from '@/storages.ts';

View File

@ -1,8 +1,10 @@
import { NIP05, NostrEvent, NostrFilter } from '@nostrify/nostrify'; import { NIP05, NostrEvent, NostrFilter } from '@nostrify/nostrify';
import { z } from 'zod';
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { getUnattachedMediaByIds } from '@/db/unattached-media.ts'; import { getUnattachedMediaByIds } from '@/db/unattached-media.ts';
import { ISO6391, nip19, z } from '@/deps.ts'; import { ISO6391, nip19 } from '@/deps.ts';
import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts'; import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts';
import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
import { addTag, deleteTag } from '@/tags.ts'; import { addTag, deleteTag } from '@/tags.ts';

View File

@ -1,7 +1,9 @@
import { NostrFilter } from '@nostrify/nostrify'; import { NostrFilter } from '@nostrify/nostrify';
import { z } from 'zod';
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { Debug, z } from '@/deps.ts'; import { Debug } from '@/deps.ts';
import { getFeedPubkeys } from '@/queries.ts'; import { getFeedPubkeys } from '@/queries.ts';
import { Sub } from '@/subs.ts'; import { Sub } from '@/subs.ts';
import { bech32ToPubkey } from '@/utils.ts'; import { bech32ToPubkey } from '@/utils.ts';

View File

@ -1,7 +1,8 @@
import { NostrFilter } from '@nostrify/nostrify'; import { NostrFilter } from '@nostrify/nostrify';
import { z } from 'zod';
import { type AppContext, type AppController } from '@/app.ts'; import { type AppContext, type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { z } from '@/deps.ts';
import { getFeedPubkeys } from '@/queries.ts'; import { getFeedPubkeys } from '@/queries.ts';
import { booleanParamSchema } from '@/schema.ts'; import { booleanParamSchema } from '@/schema.ts';
import { eventsDB } from '@/storages.ts'; import { eventsDB } from '@/storages.ts';

View File

@ -1,6 +1,7 @@
import { z } from 'zod';
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { z } from '@/deps.ts';
import { Time } from '@/utils.ts'; import { Time } from '@/utils.ts';
import { stripTime } from '@/utils/time.ts'; import { stripTime } from '@/utils/time.ts';
import { TrendsWorker } from '@/workers/trends.ts'; import { TrendsWorker } from '@/workers/trends.ts';

View File

@ -1,5 +1,6 @@
import { z } from 'zod';
import { AppController } from '@/app.ts'; import { AppController } from '@/app.ts';
import { z } from '@/deps.ts';
import { localNip05Lookup } from '@/utils/nip05.ts'; import { localNip05Lookup } from '@/utils/nip05.ts';
const nameSchema = z.string().min(1).regex(/^\w+$/); const nameSchema = z.string().min(1).regex(/^\w+$/);

View File

@ -1,5 +1,7 @@
import { z } from 'zod';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { nip19, z } from '@/deps.ts'; import { nip19 } from '@/deps.ts';
import { localNip05Lookup } from '@/utils/nip05.ts'; import { localNip05Lookup } from '@/utils/nip05.ts';
import type { AppContext, AppController } from '@/app.ts'; import type { AppContext, AppController } from '@/app.ts';

View File

@ -1,5 +1,4 @@
import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts'; import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts';
export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34'; export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34';
export { export {
type EventTemplate, type EventTemplate,

View File

@ -1,5 +1,7 @@
import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
import { stringifyStable, z } from '@/deps.ts'; import { z } from 'zod';
import { stringifyStable } from '@/deps.ts';
import { isReplaceableKind } from '@/kinds.ts'; import { isReplaceableKind } from '@/kinds.ts';
import { nostrIdSchema } from '@/schemas/nostr.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts';

View File

@ -1,4 +1,4 @@
import { z } from '@/deps.ts'; import { z } from 'zod';
/** Validates individual items in an array, dropping any that aren't valid. */ /** Validates individual items in an array, dropping any that aren't valid. */
function filteredArray<T extends z.ZodTypeAny>(schema: T) { function filteredArray<T extends z.ZodTypeAny>(schema: T) {

View File

@ -1,4 +1,4 @@
import { z } from '@/deps.ts'; import { z } from 'zod';
const apId = z.string().url(); const apId = z.string().url();
const recipients = z.array(z.string()).catch([]); const recipients = z.array(z.string()).catch([]);

View File

@ -1,4 +1,6 @@
import { getEventHash, verifyEvent, z } from '@/deps.ts'; import { z } from 'zod';
import { getEventHash, verifyEvent } from '@/deps.ts';
import { jsonSchema, safeUrlSchema } from '@/schema.ts'; import { jsonSchema, safeUrlSchema } from '@/schema.ts';
/** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */ /** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */

View File

@ -1,4 +1,4 @@
import { z } from '@/deps.ts'; import { z } from 'zod';
type ElixirValue = type ElixirValue =
| string | string

View File

@ -1,4 +1,4 @@
import { z } from '@/deps.ts'; import { z } from 'zod';
const linkSchema = z.object({ const linkSchema = z.object({
rel: z.string().optional(), rel: z.string().optional(),

View File

@ -1,5 +1,6 @@
import { z } from 'zod';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { z } from '@/deps.ts';
import { fetchWorker } from '@/workers/fetch.ts'; import { fetchWorker } from '@/workers/fetch.ts';
import type { Uploader } from './types.ts'; import type { Uploader } from './types.ts';

View File

@ -1,5 +1,7 @@
import { NostrEvent } from '@nostrify/nostrify'; import { NostrEvent } from '@nostrify/nostrify';
import { type EventTemplate, getEventHash, nip19, z } from '@/deps.ts'; import { z } from 'zod';
import { type EventTemplate, getEventHash, nip19 } from '@/deps.ts';
import { nostrIdSchema } from '@/schemas/nostr.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts';
/** Get the current time in Nostr format. */ /** Get the current time in Nostr format. */

View File

@ -1,8 +1,10 @@
import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
import { type Context, HTTPException } from 'hono'; import { type Context, HTTPException } from 'hono';
import { z } from 'zod';
import { type AppContext } from '@/app.ts'; import { type AppContext } from '@/app.ts';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { Debug, EventTemplate, parseFormData, type TypeFest, z } from '@/deps.ts'; import { Debug, EventTemplate, parseFormData, type TypeFest } from '@/deps.ts';
import * as pipeline from '@/pipeline.ts'; import * as pipeline from '@/pipeline.ts';
import { AdminSigner } from '@/signers/AdminSigner.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts';
import { APISigner } from '@/signers/APISigner.ts'; import { APISigner } from '@/signers/APISigner.ts';