@astrojs/db 0.9.7 → 0.9.9

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.
@@ -2,7 +2,8 @@ import { LibsqlError } from "@libsql/client";
2
2
  import { sql } from "drizzle-orm";
3
3
  import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
4
4
  import {} from "../core/types.js";
5
- import { SEED_DEFAULT_EXPORT_ERROR, SEED_ERROR } from "./errors.js";
5
+ import { AstroDbError } from "../utils.js";
6
+ import { SEED_DEFAULT_EXPORT_ERROR } from "./errors.js";
6
7
  import { getCreateIndexQueries, getCreateTableQuery } from "./queries.js";
7
8
  const sqlite = new SQLiteAsyncDialect();
8
9
  async function seedLocal({
@@ -18,7 +19,7 @@ async function seedLocal({
18
19
  if (seedFilePath) {
19
20
  const mod = userSeedGlob[seedFilePath];
20
21
  if (!mod.default)
21
- throw new Error(SEED_DEFAULT_EXPORT_ERROR(seedFilePath));
22
+ throw new AstroDbError(SEED_DEFAULT_EXPORT_ERROR(seedFilePath));
22
23
  seedFunctions.push(mod.default);
23
24
  }
24
25
  for (const seedFn of integrationSeedFunctions) {
@@ -29,7 +30,8 @@ async function seedLocal({
29
30
  await seed();
30
31
  } catch (e) {
31
32
  if (e instanceof LibsqlError) {
32
- throw new Error(SEED_ERROR(e.message));
33
+ throw new AstroDbError(`Failed to seed database:
34
+ ${e.message}`);
33
35
  }
34
36
  throw e;
35
37
  }
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,6 @@
1
+ import { AstroError } from 'astro/errors';
1
2
  export { defineDbIntegration } from './core/utils.js';
2
3
  export { asDrizzleTable } from './runtime/index.js';
4
+ export declare class AstroDbError extends AstroError {
5
+ name: string;
6
+ }
package/dist/utils.js CHANGED
@@ -1,6 +1,11 @@
1
+ import { AstroError } from "astro/errors";
1
2
  import { defineDbIntegration } from "./core/utils.js";
2
3
  import { asDrizzleTable } from "./runtime/index.js";
4
+ class AstroDbError extends AstroError {
5
+ name = "Astro DB Error";
6
+ }
3
7
  export {
8
+ AstroDbError,
4
9
  asDrizzleTable,
5
10
  defineDbIntegration
6
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -81,7 +81,7 @@
81
81
  "mocha": "^10.2.0",
82
82
  "typescript": "^5.2.2",
83
83
  "vite": "^5.1.4",
84
- "astro": "4.5.10",
84
+ "astro": "4.5.13",
85
85
  "astro-scripts": "0.0.14"
86
86
  },
87
87
  "scripts": {