@astrojs/db 0.8.5 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import type { ColumnsConfig, DBConfigInput, TableConfig } from '../core/types.js';
2
+ export type { LibSQLDatabase } from 'drizzle-orm/libsql';
2
3
  export declare const column: {
3
4
  number: <T extends ({
4
5
  name?: string | undefined;
@@ -144,5 +145,7 @@ export declare function defineTable<TColumns extends ColumnsConfig>(userConfig:
144
145
  export declare function defineDb(userConfig: DBConfigInput): {
145
146
  tables?: unknown;
146
147
  };
147
- export { NOW, TRUE, FALSE } from './index.js';
148
+ export declare const NOW: import("drizzle-orm").SQL<unknown>;
149
+ export declare const TRUE: import("drizzle-orm").SQL<unknown>;
150
+ export declare const FALSE: import("drizzle-orm").SQL<unknown>;
148
151
  export { sql, eq, gt, gte, lt, lte, ne, isNull, isNotNull, inArray, notInArray, exists, notExists, between, notBetween, like, notIlike, not, asc, desc, and, or, } from 'drizzle-orm';
@@ -1,8 +1,11 @@
1
1
  import { existsSync } from "node:fs";
2
+ import { LibsqlError } from "@libsql/client";
3
+ import { green } from "kleur/colors";
2
4
  import {
5
+ EXEC_DEFAULT_EXPORT_ERROR,
6
+ EXEC_ERROR,
3
7
  FILE_NOT_FOUND_ERROR,
4
- MISSING_EXECUTE_PATH_ERROR,
5
- SEED_DEFAULT_EXPORT_ERROR
8
+ MISSING_EXECUTE_PATH_ERROR
6
9
  } from "../../../errors.js";
7
10
  import {
8
11
  getLocalVirtualModContents,
@@ -44,10 +47,18 @@ async function cmd({
44
47
  const { code } = await bundleFile({ virtualModContents, root: astroConfig.root, fileUrl });
45
48
  const mod = await importBundledFile({ code, root: astroConfig.root });
46
49
  if (typeof mod.default !== "function") {
47
- console.error(SEED_DEFAULT_EXPORT_ERROR);
50
+ console.error(EXEC_DEFAULT_EXPORT_ERROR);
48
51
  process.exit(1);
49
52
  }
50
- await mod.default();
53
+ try {
54
+ await mod.default();
55
+ console.info(`${green("\u2714")} File run successfully.`);
56
+ } catch (e) {
57
+ if (e instanceof LibsqlError) {
58
+ throw new Error(EXEC_ERROR(e.message));
59
+ }
60
+ throw e;
61
+ }
51
62
  }
52
63
  export {
53
64
  cmd
@@ -27,7 +27,7 @@ function printHelp({
27
27
  message.push(
28
28
  linebreak(),
29
29
  ` ${bgGreen(black(` ${commandName} `))} ${green(
30
- `v${"0.8.5"}`
30
+ `v${"0.8.7"}`
31
31
  )} ${headline}`
32
32
  );
33
33
  }
@@ -6,7 +6,9 @@ export declare const RENAME_COLUMN_ERROR: (oldSelector: string, newSelector: str
6
6
  export declare const FILE_NOT_FOUND_ERROR: (path: string) => string;
7
7
  export declare const SHELL_QUERY_MISSING_ERROR: string;
8
8
  export declare const SEED_ERROR: (error: string) => string;
9
+ export declare const EXEC_ERROR: (error: string) => string;
9
10
  export declare const SEED_DEFAULT_EXPORT_ERROR: (fileName: string) => string;
11
+ export declare const EXEC_DEFAULT_EXPORT_ERROR: (fileName: string) => string;
10
12
  export declare const REFERENCE_DNE_ERROR: (columnName: string) => string;
11
13
  export declare const FOREIGN_KEY_DNE_ERROR: (tableName: string) => string;
12
14
  export declare const FOREIGN_KEY_REFERENCES_LENGTH_ERROR: (tableName: string) => string;
@@ -34,10 +34,16 @@ const SEED_ERROR = (error) => {
34
34
 
35
35
  ${error}`;
36
36
  };
37
- const SEED_DEFAULT_EXPORT_ERROR = (fileName) => {
38
- return red("Error while seeding database:") + `
37
+ const EXEC_ERROR = (error) => {
38
+ return `${red(`Error while executing file:`)}
39
39
 
40
- Missing default function export in ${bold(fileName)}`;
40
+ ${error}`;
41
+ };
42
+ const SEED_DEFAULT_EXPORT_ERROR = (fileName) => {
43
+ return SEED_ERROR(`Missing default function export in ${bold(fileName)}`);
44
+ };
45
+ const EXEC_DEFAULT_EXPORT_ERROR = (fileName) => {
46
+ return EXEC_ERROR(`Missing default function export in ${bold(fileName)}`);
41
47
  };
42
48
  const REFERENCE_DNE_ERROR = (columnName) => {
43
49
  return `Column ${bold(
@@ -65,6 +71,8 @@ const INTEGRATION_TABLE_CONFLICT_ERROR = (integrationName, tableName, isUserConf
65
71
  Another integration already added a table named ${bold(tableName)}`;
66
72
  };
67
73
  export {
74
+ EXEC_DEFAULT_EXPORT_ERROR,
75
+ EXEC_ERROR,
68
76
  FILE_NOT_FOUND_ERROR,
69
77
  FOREIGN_KEY_DNE_ERROR,
70
78
  FOREIGN_KEY_REFERENCES_EMPTY_ERROR,
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from "fs";
2
2
  import { dirname } from "path";
3
3
  import { fileURLToPath } from "url";
4
- import { mkdir, rm, writeFile } from "fs/promises";
4
+ import { mkdir, writeFile } from "fs/promises";
5
5
  import { blue, yellow } from "kleur/colors";
6
6
  import parseArgs from "yargs-parser";
7
7
  import { CONFIG_FILE_NAMES, DB_PATH } from "../consts.js";
@@ -9,7 +9,7 @@ import { resolveDbConfig } from "../load-file.js";
9
9
  import { getManagedAppTokenOrExit } from "../tokens.js";
10
10
  import { getDbDirectoryUrl } from "../utils.js";
11
11
  import { fileURLIntegration } from "./file-url.js";
12
- import { typegen } from "./typegen.js";
12
+ import { typegenInternal } from "./typegen.js";
13
13
  import { vitePluginDb } from "./vite-plugin-db.js";
14
14
  import { vitePluginInjectEnvTs } from "./vite-plugin-inject-env-ts.js";
15
15
  function astroDBIntegration() {
@@ -76,7 +76,7 @@ function astroDBIntegration() {
76
76
  await mkdir(dirname(fileURLToPath(localDbUrl)), { recursive: true });
77
77
  await writeFile(localDbUrl, "");
78
78
  }
79
- await typegen({ tables: tables.get() ?? {}, root: config.root });
79
+ await typegenInternal({ tables: tables.get() ?? {}, root: config.root });
80
80
  },
81
81
  "astro:server:start": async ({ logger }) => {
82
82
  setTimeout(() => {
@@ -1,5 +1,7 @@
1
+ import type { AstroConfig } from 'astro';
1
2
  import type { DBTables } from '../types.js';
2
- export declare function typegen({ tables, root }: {
3
+ export declare function typegen(astroConfig: Pick<AstroConfig, 'root' | 'integrations'>): Promise<void>;
4
+ export declare function typegenInternal({ tables, root }: {
3
5
  tables: DBTables;
4
6
  root: URL;
5
7
  }): Promise<void>;
@@ -1,12 +1,14 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { mkdir, writeFile } from "node:fs/promises";
3
3
  import { DB_TYPES_FILE, RUNTIME_IMPORT } from "../consts.js";
4
- async function typegen({ tables, root }) {
5
- const content = `// This file is generated by \`studio sync\`
4
+ import { resolveDbConfig } from "../load-file.js";
5
+ async function typegen(astroConfig) {
6
+ const { dbConfig } = await resolveDbConfig(astroConfig);
7
+ await typegenInternal({ tables: dbConfig.tables, root: astroConfig.root });
8
+ }
9
+ async function typegenInternal({ tables, root }) {
10
+ const content = `// This file is generated by Astro DB
6
11
  declare module 'astro:db' {
7
- export const db: import(${RUNTIME_IMPORT}).SqliteDB;
8
- export const dbUrl: string;
9
-
10
12
  ${Object.entries(tables).map(([name, collection]) => generateTableType(name, collection)).join("\n")}
11
13
  }
12
14
  `;
@@ -26,5 +28,6 @@ function generateTableType(name, collection) {
26
28
  return tableType;
27
29
  }
28
30
  export {
29
- typegen
31
+ typegen,
32
+ typegenInternal
30
33
  };
@@ -2,7 +2,7 @@ import type { AstroConfig } from 'astro';
2
2
  /**
3
3
  * Load a user’s `astro:db` configuration file and additional configuration files provided by integrations.
4
4
  */
5
- export declare function resolveDbConfig({ root, integrations }: AstroConfig): Promise<{
5
+ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfig, 'root' | 'integrations'>): Promise<{
6
6
  /** Resolved `astro:db` config, including tables added by integrations. */
7
7
  dbConfig: {
8
8
  tables: Record<string, {
@@ -11,7 +11,10 @@ import { dbConfigSchema } from "./schemas.js";
11
11
  import {} from "./types.js";
12
12
  import { getDbDirectoryUrl } from "./utils.js";
13
13
  const isDbIntegration = (integration) => "astro:db:setup" in integration.hooks;
14
- async function resolveDbConfig({ root, integrations }) {
14
+ async function resolveDbConfig({
15
+ root,
16
+ integrations
17
+ }) {
15
18
  const { mod, dependencies } = await loadUserConfigFile(root);
16
19
  const userDbConfig = dbConfigSchema.parse(mod?.default ?? {}, { errorMap });
17
20
  const dbConfig = { tables: userDbConfig.tables ?? {} };
@@ -24,8 +24,18 @@ class ManagedRemoteAppToken {
24
24
  session;
25
25
  projectId;
26
26
  ttl;
27
+ expires;
27
28
  renewTimer;
28
29
  static async create(sessionToken, projectId) {
30
+ const { token: shortLivedAppToken, ttl } = await this.createToken(sessionToken, projectId);
31
+ return new ManagedRemoteAppToken({
32
+ token: shortLivedAppToken,
33
+ session: sessionToken,
34
+ projectId,
35
+ ttl
36
+ });
37
+ }
38
+ static async createToken(sessionToken, projectId) {
29
39
  const spinner = ora("Connecting to remote database...").start();
30
40
  const response = await safeFetch(
31
41
  new URL(`${getAstroStudioUrl()}/auth/cli/token-create`),
@@ -42,13 +52,8 @@ class ManagedRemoteAppToken {
42
52
  );
43
53
  await new Promise((resolve) => setTimeout(resolve, 2e3));
44
54
  spinner.succeed(green("Connected to remote database."));
45
- const { token: shortLivedAppToken, ttl } = await response.json();
46
- return new ManagedRemoteAppToken({
47
- token: shortLivedAppToken,
48
- session: sessionToken,
49
- projectId,
50
- ttl
51
- });
55
+ const { token, ttl } = await response.json();
56
+ return { token, ttl };
52
57
  }
53
58
  constructor(options) {
54
59
  this.token = options.token;
@@ -56,6 +61,7 @@ class ManagedRemoteAppToken {
56
61
  this.projectId = options.projectId;
57
62
  this.ttl = options.ttl;
58
63
  this.renewTimer = setTimeout(() => this.renew(), 1e3 * 60 * 5 / 2);
64
+ this.expires = getExpiresFromTtl(this.ttl);
59
65
  }
60
66
  async fetch(url, body) {
61
67
  return safeFetch(
@@ -73,23 +79,41 @@ class ManagedRemoteAppToken {
73
79
  }
74
80
  );
75
81
  }
82
+ tokenIsValid() {
83
+ return /* @__PURE__ */ new Date() > this.expires;
84
+ }
85
+ createRenewTimer() {
86
+ return setTimeout(() => this.renew(), 1e3 * 60 * this.ttl / 2);
87
+ }
76
88
  async renew() {
77
89
  clearTimeout(this.renewTimer);
78
90
  delete this.renewTimer;
79
- try {
91
+ if (this.tokenIsValid()) {
80
92
  const response = await this.fetch("/auth/cli/token-renew", {
81
93
  token: this.token,
82
94
  projectId: this.projectId
83
95
  });
84
96
  if (response.status === 200) {
85
- this.renewTimer = setTimeout(() => this.renew(), 1e3 * 60 * this.ttl / 2);
97
+ this.expires = getExpiresFromTtl(this.ttl);
98
+ this.renewTimer = this.createRenewTimer();
86
99
  } else {
87
100
  throw new Error(`Unexpected response: ${response.status} ${response.statusText}`);
88
101
  }
89
- } catch (error) {
90
- const retryIn = 60 * this.ttl / 10;
91
- console.error(`Failed to renew token. Retrying in ${retryIn} seconds.`, error?.message);
92
- this.renewTimer = setTimeout(() => this.renew(), retryIn * 1e3);
102
+ } else {
103
+ try {
104
+ const { token, ttl } = await ManagedRemoteAppToken.createToken(
105
+ this.session,
106
+ this.projectId
107
+ );
108
+ this.token = token;
109
+ this.ttl = ttl;
110
+ this.expires = getExpiresFromTtl(ttl);
111
+ this.renewTimer = this.createRenewTimer();
112
+ } catch {
113
+ throw new Error(
114
+ `Token has expired and attempts to renew it have failed, please try again.`
115
+ );
116
+ }
93
117
  }
94
118
  }
95
119
  async destroy() {
@@ -140,6 +164,9 @@ async function getManagedAppTokenOrExit(token) {
140
164
  }
141
165
  return ManagedRemoteAppToken.create(sessionToken, projectId);
142
166
  }
167
+ function getExpiresFromTtl(ttl) {
168
+ return new Date(Date.now() + ttl * 60 * 1e3);
169
+ }
143
170
  export {
144
171
  PROJECT_ID_FILE,
145
172
  SESSION_LOGIN_FILE,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export type { ResolvedCollectionConfig, TableConfig } from './core/types.js';
2
2
  export { cli } from './core/cli/index.js';
3
3
  export { integration as default } from './core/integration/index.js';
4
+ export { typegen } from './core/integration/typegen.js';
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { cli } from "./core/cli/index.js";
2
2
  import { integration } from "./core/integration/index.js";
3
+ import { typegen } from "./core/integration/typegen.js";
3
4
  export {
4
5
  cli,
5
- integration as default
6
+ integration as default,
7
+ typegen
6
8
  };
@@ -1,3 +1,4 @@
1
+ import { sql as _sql } from "drizzle-orm";
1
2
  function createColumn(type, schema) {
2
3
  return {
3
4
  type,
@@ -30,7 +31,9 @@ function defineTable(userConfig) {
30
31
  function defineDb(userConfig) {
31
32
  return userConfig;
32
33
  }
33
- import { NOW, TRUE, FALSE } from "./index.js";
34
+ const NOW = _sql`CURRENT_TIMESTAMP`;
35
+ const TRUE = _sql`TRUE`;
36
+ const FALSE = _sql`FALSE`;
34
37
  import {
35
38
  sql,
36
39
  eq,
@@ -1,15 +1,9 @@
1
- import { type ColumnDataType, sql } from 'drizzle-orm';
2
- import type { LibSQLDatabase } from 'drizzle-orm/libsql';
1
+ import { type ColumnDataType } from 'drizzle-orm';
3
2
  import { type DBColumn, type DBTable } from '../core/types.js';
4
- export { sql };
5
- export type SqliteDB = LibSQLDatabase;
6
3
  export type { Table } from './types.js';
7
4
  export { createRemoteDatabaseClient, createLocalDatabaseClient } from './db-client.js';
8
5
  export { seedLocal } from './seed-local.js';
9
6
  export declare function hasPrimaryKey(column: DBColumn): boolean;
10
- export declare const NOW: import("drizzle-orm").SQL<unknown>;
11
- export declare const TRUE: import("drizzle-orm").SQL<unknown>;
12
- export declare const FALSE: import("drizzle-orm").SQL<unknown>;
13
7
  export declare function asDrizzleTable(name: string, table: DBTable): import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
14
8
  name: string;
15
9
  schema: undefined;
@@ -13,9 +13,6 @@ import { seedLocal } from "./seed-local.js";
13
13
  function hasPrimaryKey(column) {
14
14
  return "primaryKey" in column.schema && !!column.schema.primaryKey;
15
15
  }
16
- const NOW = sql`CURRENT_TIMESTAMP`;
17
- const TRUE = sql`TRUE`;
18
- const FALSE = sql`FALSE`;
19
16
  const dateType = customType({
20
17
  dataType() {
21
18
  return "text";
@@ -114,13 +111,9 @@ function handleSerializedSQL(def) {
114
111
  return def;
115
112
  }
116
113
  export {
117
- FALSE,
118
- NOW,
119
- TRUE,
120
114
  asDrizzleTable,
121
115
  createLocalDatabaseClient,
122
116
  createRemoteDatabaseClient,
123
117
  hasPrimaryKey,
124
- seedLocal,
125
- sql
118
+ seedLocal
126
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -80,8 +80,8 @@
80
80
  "mocha": "^10.2.0",
81
81
  "typescript": "^5.2.2",
82
82
  "vite": "^5.1.4",
83
- "astro-scripts": "0.0.14",
84
- "astro": "4.5.4"
83
+ "astro": "4.5.6",
84
+ "astro-scripts": "0.0.14"
85
85
  },
86
86
  "scripts": {
87
87
  "types:config": "tsc -p ./tsconfig.config-types.json",
package/virtual.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  declare module 'astro:db' {
2
2
  type RuntimeConfig = typeof import('./dist/_internal/runtime/config.js');
3
3
 
4
+ export const db: import('./dist/_internal/runtime/config.js').LibSQLDatabase;
5
+ export const dbUrl: string;
6
+
4
7
  export const sql: RuntimeConfig['sql'];
5
8
  export const NOW: RuntimeConfig['NOW'];
6
9
  export const TRUE: RuntimeConfig['TRUE'];
@@ -1,14 +0,0 @@
1
- export declare const MISSING_SESSION_ID_ERROR: string;
2
- export declare const MISSING_PROJECT_ID_ERROR: string;
3
- export declare const MISSING_EXECUTE_PATH_ERROR: string;
4
- export declare const RENAME_TABLE_ERROR: (oldTable: string, newTable: string) => string;
5
- export declare const RENAME_COLUMN_ERROR: (oldSelector: string, newSelector: string) => string;
6
- export declare const FILE_NOT_FOUND_ERROR: (path: string) => string;
7
- export declare const SHELL_QUERY_MISSING_ERROR: string;
8
- export declare const SEED_ERROR: (error: string) => string;
9
- export declare const SEED_DEFAULT_EXPORT_ERROR: (fileName: string) => string;
10
- export declare const REFERENCE_DNE_ERROR: (columnName: string) => string;
11
- export declare const FOREIGN_KEY_DNE_ERROR: (tableName: string) => string;
12
- export declare const FOREIGN_KEY_REFERENCES_LENGTH_ERROR: (tableName: string) => string;
13
- export declare const FOREIGN_KEY_REFERENCES_EMPTY_ERROR: (tableName: string) => string;
14
- export declare const INTEGRATION_TABLE_CONFLICT_ERROR: (integrationName: string, tableName: string, isUserConflict: boolean) => string;
@@ -1,5 +0,0 @@
1
- import type { LibSQLDatabase } from 'drizzle-orm/libsql';
2
- export declare function createLocalDatabaseClient({ dbUrl }: {
3
- dbUrl: string;
4
- }): LibSQLDatabase;
5
- export declare function createRemoteDatabaseClient(appToken: string, remoteDbURL: string): import("drizzle-orm/sqlite-proxy").SqliteRemoteDatabase<Record<string, never>>;
@@ -1,31 +0,0 @@
1
- import { type ColumnDataType, sql } from 'drizzle-orm';
2
- import type { LibSQLDatabase } from 'drizzle-orm/libsql';
3
- import { type DBColumn, type DBTable } from '../core/types.js';
4
- export { sql };
5
- export type SqliteDB = LibSQLDatabase;
6
- export type { Table } from './types.js';
7
- export { createRemoteDatabaseClient, createLocalDatabaseClient } from './db-client.js';
8
- export { seedLocal } from './seed-local.js';
9
- export declare function hasPrimaryKey(column: DBColumn): boolean;
10
- export declare const NOW: import("drizzle-orm").SQL<unknown>;
11
- export declare const TRUE: import("drizzle-orm").SQL<unknown>;
12
- export declare const FALSE: import("drizzle-orm").SQL<unknown>;
13
- export declare function asDrizzleTable(name: string, table: DBTable): import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
14
- name: string;
15
- schema: undefined;
16
- columns: {
17
- [x: string]: import("drizzle-orm/sqlite-core").SQLiteColumn<{
18
- name: string;
19
- tableName: string;
20
- dataType: ColumnDataType;
21
- columnType: string;
22
- data: unknown;
23
- driverParam: unknown;
24
- notNull: false;
25
- hasDefault: false;
26
- enumValues: string[] | undefined;
27
- baseColumn: never;
28
- }, object>;
29
- };
30
- dialect: "sqlite";
31
- }>;
@@ -1,71 +0,0 @@
1
- import type { BooleanColumn, ColumnType, DBColumn, DBTable, DateColumn, JsonColumn, NumberColumn, TextColumn } from '../core/types.js';
2
- export declare const SEED_DEV_FILE_NAME: string[];
3
- export declare function getDropTableIfExistsQuery(tableName: string): string;
4
- export declare function getCreateTableQuery(tableName: string, table: DBTable): string;
5
- export declare function getCreateIndexQueries(tableName: string, table: Pick<DBTable, 'indexes'>): string[];
6
- export declare function getCreateForeignKeyQueries(tableName: string, table: DBTable): string[];
7
- export declare function schemaTypeToSqlType(type: ColumnType): 'text' | 'integer';
8
- export declare function getModifiers(columnName: string, column: DBColumn): string;
9
- export declare function getReferencesConfig(column: DBColumn): {
10
- type: "number";
11
- schema: ({
12
- unique: boolean;
13
- deprecated: boolean;
14
- name?: string | undefined;
15
- label?: string | undefined;
16
- collection?: string | undefined;
17
- } & {
18
- optional: boolean;
19
- primaryKey: false;
20
- default?: number | import("./types.js").SerializedSQL | undefined;
21
- } & {
22
- references?: any | undefined;
23
- }) | ({
24
- unique: boolean;
25
- deprecated: boolean;
26
- name?: string | undefined;
27
- label?: string | undefined;
28
- collection?: string | undefined;
29
- } & {
30
- primaryKey: true;
31
- optional?: false | undefined;
32
- default?: undefined;
33
- } & {
34
- references?: any | undefined;
35
- });
36
- } | {
37
- type: "text";
38
- schema: ({
39
- unique: boolean;
40
- deprecated: boolean;
41
- name?: string | undefined;
42
- label?: string | undefined;
43
- collection?: string | undefined;
44
- default?: string | import("./types.js").SerializedSQL | undefined;
45
- multiline?: boolean | undefined;
46
- } & {
47
- optional: boolean;
48
- primaryKey: false;
49
- } & {
50
- references?: any | undefined;
51
- }) | ({
52
- unique: boolean;
53
- deprecated: boolean;
54
- name?: string | undefined;
55
- label?: string | undefined;
56
- collection?: string | undefined;
57
- default?: string | import("./types.js").SerializedSQL | undefined;
58
- multiline?: boolean | undefined;
59
- } & {
60
- primaryKey: true;
61
- optional?: false | undefined;
62
- } & {
63
- references?: any | undefined;
64
- });
65
- } | undefined;
66
- type WithDefaultDefined<T extends DBColumn> = T & {
67
- schema: Required<Pick<T['schema'], 'default'>>;
68
- };
69
- type DBColumnWithDefault = WithDefaultDefined<TextColumn> | WithDefaultDefined<DateColumn> | WithDefaultDefined<NumberColumn> | WithDefaultDefined<BooleanColumn> | WithDefaultDefined<JsonColumn>;
70
- export declare function hasDefault(column: DBColumn): column is DBColumnWithDefault;
71
- export {};
@@ -1,10 +0,0 @@
1
- import type { LibSQLDatabase } from 'drizzle-orm/libsql';
2
- import { type DBTables } from '../core/types.js';
3
- export declare function seedLocal({ db, tables, userSeedGlob, integrationSeedFunctions, }: {
4
- db: LibSQLDatabase;
5
- tables: DBTables;
6
- userSeedGlob: Record<string, {
7
- default?: () => Promise<void>;
8
- }>;
9
- integrationSeedFunctions: Array<() => Promise<void>>;
10
- }): Promise<void>;
@@ -1,4 +0,0 @@
1
- /**
2
- * Small wrapper around fetch that throws an error if the response is not OK. Allows for custom error handling as well through the onNotOK callback.
3
- */
4
- export declare function safeFetch(url: Parameters<typeof fetch>[0], options?: Parameters<typeof fetch>[1], onNotOK?: (response: Response) => void | Promise<void>): Promise<Response>;