Initial commit: New MoreminiMore website with fresh design
This commit is contained in:
4
node_modules/@astrojs/db/dist/runtime/errors.d.ts
generated
vendored
Normal file
4
node_modules/@astrojs/db/dist/runtime/errors.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare const FOREIGN_KEY_DNE_ERROR: (tableName: string) => string;
|
||||
export declare const FOREIGN_KEY_REFERENCES_LENGTH_ERROR: (tableName: string) => string;
|
||||
export declare const FOREIGN_KEY_REFERENCES_EMPTY_ERROR: (tableName: string) => string;
|
||||
export declare const REFERENCE_DNE_ERROR: (columnName: string) => string;
|
||||
27
node_modules/@astrojs/db/dist/runtime/errors.js
generated
vendored
Normal file
27
node_modules/@astrojs/db/dist/runtime/errors.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import colors from "piccolore";
|
||||
const FOREIGN_KEY_DNE_ERROR = (tableName) => {
|
||||
return `Table ${colors.bold(
|
||||
tableName
|
||||
)} references a table that does not exist. Did you apply the referenced table to the \`tables\` object in your db config?`;
|
||||
};
|
||||
const FOREIGN_KEY_REFERENCES_LENGTH_ERROR = (tableName) => {
|
||||
return `Foreign key on ${colors.bold(
|
||||
tableName
|
||||
)} is misconfigured. \`columns\` and \`references\` must be the same length.`;
|
||||
};
|
||||
const FOREIGN_KEY_REFERENCES_EMPTY_ERROR = (tableName) => {
|
||||
return `Foreign key on ${colors.bold(
|
||||
tableName
|
||||
)} is misconfigured. \`references\` array cannot be empty.`;
|
||||
};
|
||||
const REFERENCE_DNE_ERROR = (columnName) => {
|
||||
return `Column ${colors.bold(
|
||||
columnName
|
||||
)} references a table that does not exist. Did you apply the referenced table to the \`tables\` object in your db config?`;
|
||||
};
|
||||
export {
|
||||
FOREIGN_KEY_DNE_ERROR,
|
||||
FOREIGN_KEY_REFERENCES_EMPTY_ERROR,
|
||||
FOREIGN_KEY_REFERENCES_LENGTH_ERROR,
|
||||
REFERENCE_DNE_ERROR
|
||||
};
|
||||
31
node_modules/@astrojs/db/dist/runtime/index.d.ts
generated
vendored
Normal file
31
node_modules/@astrojs/db/dist/runtime/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { type ColumnDataType } from 'drizzle-orm';
|
||||
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
|
||||
import type { DBTable } from '../core/types.js';
|
||||
export type Database = LibSQLDatabase;
|
||||
export type { Table } from './types.js';
|
||||
export { hasPrimaryKey } from './utils.js';
|
||||
export declare function asDrizzleTable(name: string, table: DBTable): import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
||||
name: string;
|
||||
schema: undefined;
|
||||
columns: {
|
||||
[x: string]: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
||||
name: string;
|
||||
tableName: string;
|
||||
dataType: ColumnDataType;
|
||||
columnType: string;
|
||||
data: unknown;
|
||||
driverParam: unknown;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: string[] | undefined;
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
};
|
||||
dialect: "sqlite";
|
||||
}>;
|
||||
export declare function normalizeDatabaseUrl(envDbUrl: string | undefined, defaultDbUrl: string): string;
|
||||
121
node_modules/@astrojs/db/dist/runtime/index.js
generated
vendored
Normal file
121
node_modules/@astrojs/db/dist/runtime/index.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import {
|
||||
customType,
|
||||
index,
|
||||
integer,
|
||||
sqliteTable,
|
||||
text
|
||||
} from "drizzle-orm/sqlite-core";
|
||||
import { isSerializedSQL } from "./types.js";
|
||||
import { hasPrimaryKey, pathToFileURL } from "./utils.js";
|
||||
import { hasPrimaryKey as hasPrimaryKey2 } from "./utils.js";
|
||||
const isISODateString = (str) => /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str);
|
||||
const dateType = customType({
|
||||
dataType() {
|
||||
return "text";
|
||||
},
|
||||
toDriver(value) {
|
||||
return value.toISOString();
|
||||
},
|
||||
fromDriver(value) {
|
||||
if (!isISODateString(value)) {
|
||||
value += "Z";
|
||||
}
|
||||
return new Date(value);
|
||||
}
|
||||
});
|
||||
const jsonType = customType({
|
||||
dataType() {
|
||||
return "text";
|
||||
},
|
||||
toDriver(value) {
|
||||
return JSON.stringify(value);
|
||||
},
|
||||
fromDriver(value) {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
});
|
||||
function asDrizzleTable(name, table) {
|
||||
const columns = {};
|
||||
if (!Object.entries(table.columns).some(([, column]) => hasPrimaryKey(column))) {
|
||||
columns["_id"] = integer("_id").primaryKey();
|
||||
}
|
||||
for (const [columnName, column] of Object.entries(table.columns)) {
|
||||
columns[columnName] = columnMapper(columnName, column);
|
||||
}
|
||||
const drizzleTable = sqliteTable(name, columns, (ormTable) => {
|
||||
const indexes = [];
|
||||
for (const [indexName, indexProps] of Object.entries(table.indexes ?? {})) {
|
||||
const onColNames = Array.isArray(indexProps.on) ? indexProps.on : [indexProps.on];
|
||||
const onCols = onColNames.map((colName) => ormTable[colName]);
|
||||
if (!atLeastOne(onCols)) continue;
|
||||
indexes.push(index(indexName).on(...onCols));
|
||||
}
|
||||
return indexes;
|
||||
});
|
||||
return drizzleTable;
|
||||
}
|
||||
function atLeastOne(arr) {
|
||||
return arr.length > 0;
|
||||
}
|
||||
function columnMapper(columnName, column) {
|
||||
let c;
|
||||
switch (column.type) {
|
||||
case "text": {
|
||||
c = text(columnName, { enum: column.schema.enum });
|
||||
if (column.schema.default !== void 0)
|
||||
c = c.default(handleSerializedSQL(column.schema.default));
|
||||
if (column.schema.primaryKey === true) c = c.primaryKey();
|
||||
break;
|
||||
}
|
||||
case "number": {
|
||||
c = integer(columnName);
|
||||
if (column.schema.default !== void 0)
|
||||
c = c.default(handleSerializedSQL(column.schema.default));
|
||||
if (column.schema.primaryKey === true) c = c.primaryKey();
|
||||
break;
|
||||
}
|
||||
case "boolean": {
|
||||
c = integer(columnName, { mode: "boolean" });
|
||||
if (column.schema.default !== void 0)
|
||||
c = c.default(handleSerializedSQL(column.schema.default));
|
||||
break;
|
||||
}
|
||||
case "json":
|
||||
c = jsonType(columnName);
|
||||
if (column.schema.default !== void 0) c = c.default(column.schema.default);
|
||||
break;
|
||||
case "date": {
|
||||
c = dateType(columnName);
|
||||
if (column.schema.default !== void 0) {
|
||||
const def = handleSerializedSQL(column.schema.default);
|
||||
c = c.default(typeof def === "string" ? new Date(def) : def);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!column.schema.optional) c = c.notNull();
|
||||
if (column.schema.unique) c = c.unique();
|
||||
return c;
|
||||
}
|
||||
function handleSerializedSQL(def) {
|
||||
if (isSerializedSQL(def)) {
|
||||
return sql.raw(def.sql);
|
||||
}
|
||||
return def;
|
||||
}
|
||||
function normalizeDatabaseUrl(envDbUrl, defaultDbUrl) {
|
||||
if (envDbUrl) {
|
||||
if (envDbUrl.startsWith("file://")) {
|
||||
return envDbUrl;
|
||||
}
|
||||
return new URL(envDbUrl, pathToFileURL(process.cwd()) + "/").toString();
|
||||
} else {
|
||||
return defaultDbUrl;
|
||||
}
|
||||
}
|
||||
export {
|
||||
asDrizzleTable,
|
||||
hasPrimaryKey2 as hasPrimaryKey,
|
||||
normalizeDatabaseUrl
|
||||
};
|
||||
92
node_modules/@astrojs/db/dist/runtime/types.d.ts
generated
vendored
Normal file
92
node_modules/@astrojs/db/dist/runtime/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
|
||||
import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
|
||||
import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
|
||||
type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault' | 'hasRuntimeDefault' | 'isPrimaryKey'>;
|
||||
type AstroText<T extends GeneratedConfig<'string'>, E extends readonly [string, ...string[]] | string> = SQLiteColumn<T & {
|
||||
data: E extends readonly (infer U)[] ? U : string;
|
||||
dataType: 'string';
|
||||
columnType: 'SQLiteText';
|
||||
driverParam: string;
|
||||
enumValues: E extends [string, ...string[]] ? E : never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
||||
data: Date;
|
||||
dataType: 'custom';
|
||||
columnType: 'SQLiteCustomColumn';
|
||||
driverParam: string;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn<T & {
|
||||
data: boolean;
|
||||
dataType: 'boolean';
|
||||
columnType: 'SQLiteBoolean';
|
||||
driverParam: number;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn<T & {
|
||||
data: number;
|
||||
dataType: 'number';
|
||||
columnType: 'SQLiteInteger';
|
||||
driverParam: number;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
||||
data: unknown;
|
||||
dataType: 'custom';
|
||||
columnType: 'SQLiteCustomColumn';
|
||||
driverParam: string;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type Column<T extends DBColumn['type'], E extends readonly [string, ...string[]] | string, S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S, E> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
|
||||
export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
|
||||
name: TTableName;
|
||||
schema: undefined;
|
||||
dialect: 'sqlite';
|
||||
columns: {
|
||||
[K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
|
||||
enum: infer E;
|
||||
} ? E extends readonly [string, ...string[]] ? E : string : string, {
|
||||
tableName: TTableName;
|
||||
name: K;
|
||||
isPrimaryKey: TColumns[K]['schema'] extends {
|
||||
primaryKey: true;
|
||||
} ? true : false;
|
||||
hasDefault: TColumns[K]['schema'] extends {
|
||||
default: NonNullable<unknown>;
|
||||
} ? true : TColumns[K]['schema'] extends {
|
||||
primaryKey: true;
|
||||
} ? true : false;
|
||||
hasRuntimeDefault: TColumns[K]['schema'] extends {
|
||||
default: NonNullable<unknown>;
|
||||
} ? true : false;
|
||||
notNull: TColumns[K]['schema']['optional'] extends true ? false : true;
|
||||
}>;
|
||||
};
|
||||
}>;
|
||||
export declare const SERIALIZED_SQL_KEY = "__serializedSQL";
|
||||
export type SerializedSQL = {
|
||||
[SERIALIZED_SQL_KEY]: true;
|
||||
sql: string;
|
||||
};
|
||||
export declare function isSerializedSQL(value: any): value is SerializedSQL;
|
||||
export {};
|
||||
8
node_modules/@astrojs/db/dist/runtime/types.js
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/runtime/types.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
const SERIALIZED_SQL_KEY = "__serializedSQL";
|
||||
function isSerializedSQL(value) {
|
||||
return typeof value === "object" && value !== null && SERIALIZED_SQL_KEY in value;
|
||||
}
|
||||
export {
|
||||
SERIALIZED_SQL_KEY,
|
||||
isSerializedSQL
|
||||
};
|
||||
9
node_modules/@astrojs/db/dist/runtime/utils.d.ts
generated
vendored
Normal file
9
node_modules/@astrojs/db/dist/runtime/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { LibsqlError } from '@libsql/client';
|
||||
import { AstroError } from 'astro/errors';
|
||||
import type { DBColumn } from '../core/types.js';
|
||||
export declare function hasPrimaryKey(column: DBColumn): boolean;
|
||||
export declare class AstroDbError extends AstroError {
|
||||
name: string;
|
||||
}
|
||||
export declare function isDbError(err: unknown): err is LibsqlError;
|
||||
export declare function pathToFileURL(path: string): URL;
|
||||
35
node_modules/@astrojs/db/dist/runtime/utils.js
generated
vendored
Normal file
35
node_modules/@astrojs/db/dist/runtime/utils.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { LibsqlError } from "@libsql/client";
|
||||
import { AstroError } from "astro/errors";
|
||||
function hasPrimaryKey(column) {
|
||||
return "primaryKey" in column.schema && !!column.schema.primaryKey;
|
||||
}
|
||||
const isWindows = process?.platform === "win32";
|
||||
class AstroDbError extends AstroError {
|
||||
name = "Astro DB Error";
|
||||
}
|
||||
function isDbError(err) {
|
||||
return err instanceof LibsqlError || err instanceof Error && err.libsqlError === true;
|
||||
}
|
||||
function slash(path) {
|
||||
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
||||
if (isExtendedLengthPath) {
|
||||
return path;
|
||||
}
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
function pathToFileURL(path) {
|
||||
if (isWindows) {
|
||||
let slashed = slash(path);
|
||||
if (!slashed.startsWith("/")) {
|
||||
slashed = "/" + slashed;
|
||||
}
|
||||
return new URL("file://" + slashed);
|
||||
}
|
||||
return new URL("file://" + path);
|
||||
}
|
||||
export {
|
||||
AstroDbError,
|
||||
hasPrimaryKey,
|
||||
isDbError,
|
||||
pathToFileURL
|
||||
};
|
||||
112
node_modules/@astrojs/db/dist/runtime/virtual.js
generated
vendored
Normal file
112
node_modules/@astrojs/db/dist/runtime/virtual.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
import { sql as _sql } from "drizzle-orm";
|
||||
function createColumn(type, schema) {
|
||||
return {
|
||||
type,
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
schema
|
||||
};
|
||||
}
|
||||
const column = {
|
||||
number: (opts = {}) => {
|
||||
return createColumn("number", opts);
|
||||
},
|
||||
boolean: (opts = {}) => {
|
||||
return createColumn("boolean", opts);
|
||||
},
|
||||
text: (opts = {}) => {
|
||||
return createColumn("text", opts);
|
||||
},
|
||||
date(opts = {}) {
|
||||
return createColumn("date", opts);
|
||||
},
|
||||
json(opts = {}) {
|
||||
return createColumn("json", opts);
|
||||
}
|
||||
};
|
||||
function defineTable(userConfig) {
|
||||
return userConfig;
|
||||
}
|
||||
function defineDb(userConfig) {
|
||||
return userConfig;
|
||||
}
|
||||
const NOW = _sql`CURRENT_TIMESTAMP`;
|
||||
const TRUE = _sql`TRUE`;
|
||||
const FALSE = _sql`FALSE`;
|
||||
import {
|
||||
and,
|
||||
asc,
|
||||
avg,
|
||||
avgDistinct,
|
||||
between,
|
||||
count,
|
||||
countDistinct,
|
||||
desc,
|
||||
eq,
|
||||
exists,
|
||||
gt,
|
||||
gte,
|
||||
ilike,
|
||||
inArray,
|
||||
isNotNull,
|
||||
isNull,
|
||||
like,
|
||||
lt,
|
||||
lte,
|
||||
max,
|
||||
min,
|
||||
ne,
|
||||
not,
|
||||
notBetween,
|
||||
notExists,
|
||||
notIlike,
|
||||
notInArray,
|
||||
or,
|
||||
sql,
|
||||
sum,
|
||||
sumDistinct
|
||||
} from "drizzle-orm";
|
||||
import { alias } from "drizzle-orm/sqlite-core";
|
||||
import { isDbError } from "./utils.js";
|
||||
export {
|
||||
FALSE,
|
||||
NOW,
|
||||
TRUE,
|
||||
alias,
|
||||
and,
|
||||
asc,
|
||||
avg,
|
||||
avgDistinct,
|
||||
between,
|
||||
column,
|
||||
count,
|
||||
countDistinct,
|
||||
defineDb,
|
||||
defineTable,
|
||||
desc,
|
||||
eq,
|
||||
exists,
|
||||
gt,
|
||||
gte,
|
||||
ilike,
|
||||
inArray,
|
||||
isDbError,
|
||||
isNotNull,
|
||||
isNull,
|
||||
like,
|
||||
lt,
|
||||
lte,
|
||||
max,
|
||||
min,
|
||||
ne,
|
||||
not,
|
||||
notBetween,
|
||||
notExists,
|
||||
notIlike,
|
||||
notInArray,
|
||||
or,
|
||||
sql,
|
||||
sum,
|
||||
sumDistinct
|
||||
};
|
||||
Reference in New Issue
Block a user