@astrojs/db 0.11.7 → 0.12.0

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,3 @@
1
- import type { AstroIntegration } from 'astro';
2
1
  import type { z } from 'zod';
3
2
  import type { MaybeArray, booleanColumnSchema, columnSchema, columnsSchema, dateColumnSchema, dbConfigSchema, indexSchema, jsonColumnSchema, numberColumnOptsSchema, numberColumnSchema, referenceableColumnSchema, resolvedIndexSchema, tableSchema, textColumnOptsSchema, textColumnSchema } from './schemas.js';
4
3
  export type ResolvedIndexes = z.output<typeof dbConfigSchema>['tables'][string]['indexes'];
@@ -46,14 +45,16 @@ interface LegacyIndexConfig<TColumns extends ColumnsConfig> extends z.input<type
46
45
  }
47
46
  export type NumberColumnOpts = z.input<typeof numberColumnOptsSchema>;
48
47
  export type TextColumnOpts = z.input<typeof textColumnOptsSchema>;
49
- export type AstroDbIntegration = AstroIntegration & {
50
- hooks: {
51
- 'astro:db:setup'?: (options: {
52
- extendDb: (options: {
53
- configEntrypoint?: URL | string;
54
- seedEntrypoint?: URL | string;
55
- }) => void;
56
- }) => void | Promise<void>;
57
- };
58
- };
48
+ declare global {
49
+ namespace Astro {
50
+ interface IntegrationHooks {
51
+ 'astro:db:setup'?: (options: {
52
+ extendDb: (options: {
53
+ configEntrypoint?: URL | string;
54
+ seedEntrypoint?: URL | string;
55
+ }) => void;
56
+ }) => void | Promise<void>;
57
+ }
58
+ }
59
+ }
59
60
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { AstroConfig, AstroIntegration } from 'astro';
2
- import type { AstroDbIntegration } from './types.js';
2
+ import './types.js';
3
3
  export type VitePlugin = Required<AstroConfig['vite']>['plugins'][number];
4
4
  export declare function getAstroEnv(envMode?: string): Record<`ASTRO_${string}`, string>;
5
5
  export declare function getRemoteDatabaseUrl(): string;
6
6
  export declare function getDbDirectoryUrl(root: URL | string): URL;
7
- export declare function defineDbIntegration(integration: AstroDbIntegration): AstroIntegration;
7
+ export declare function defineDbIntegration(integration: AstroIntegration): AstroIntegration;
8
8
  export type Result<T> = {
9
9
  success: true;
10
10
  data: T;
@@ -27,7 +27,7 @@ function printHelp({
27
27
  message.push(
28
28
  linebreak(),
29
29
  ` ${bgGreen(black(` ${commandName} `))} ${green(
30
- `v${"0.11.7"}`
30
+ `v${"0.12.0"}`
31
31
  )} ${headline}`
32
32
  );
33
33
  }
@@ -1,4 +1,5 @@
1
1
  import type { AstroConfig } from 'astro';
2
+ import './types.js';
2
3
  /**
3
4
  * Load a user’s `astro:db` configuration file and additional configuration files provided by integrations.
4
5
  */
@@ -8,9 +8,8 @@ import { INTEGRATION_TABLE_CONFLICT_ERROR } from "./errors.js";
8
8
  import { errorMap } from "./integration/error-map.js";
9
9
  import { getConfigVirtualModContents } from "./integration/vite-plugin-db.js";
10
10
  import { dbConfigSchema } from "./schemas.js";
11
- import {} from "./types.js";
11
+ import "./types.js";
12
12
  import { getAstroEnv, getDbDirectoryUrl } from "./utils.js";
13
- const isDbIntegration = (integration) => "astro:db:setup" in integration.hooks;
14
13
  async function resolveDbConfig({
15
14
  root,
16
15
  integrations
@@ -21,7 +20,6 @@ async function resolveDbConfig({
21
20
  const integrationDbConfigPaths = [];
22
21
  const integrationSeedPaths = [];
23
22
  for (const integration of integrations) {
24
- if (!isDbIntegration(integration)) continue;
25
23
  const { name, hooks } = integration;
26
24
  if (hooks["astro:db:setup"]) {
27
25
  hooks["astro:db:setup"]({
@@ -1,4 +1,3 @@
1
- import type { AstroIntegration } from 'astro';
2
1
  import type { z } from 'zod';
3
2
  import type { MaybeArray, booleanColumnSchema, columnSchema, columnsSchema, dateColumnSchema, dbConfigSchema, indexSchema, jsonColumnSchema, numberColumnOptsSchema, numberColumnSchema, referenceableColumnSchema, resolvedIndexSchema, tableSchema, textColumnOptsSchema, textColumnSchema } from './schemas.js';
4
3
  export type ResolvedIndexes = z.output<typeof dbConfigSchema>['tables'][string]['indexes'];
@@ -46,14 +45,16 @@ interface LegacyIndexConfig<TColumns extends ColumnsConfig> extends z.input<type
46
45
  }
47
46
  export type NumberColumnOpts = z.input<typeof numberColumnOptsSchema>;
48
47
  export type TextColumnOpts = z.input<typeof textColumnOptsSchema>;
49
- export type AstroDbIntegration = AstroIntegration & {
50
- hooks: {
51
- 'astro:db:setup'?: (options: {
52
- extendDb: (options: {
53
- configEntrypoint?: URL | string;
54
- seedEntrypoint?: URL | string;
55
- }) => void;
56
- }) => void | Promise<void>;
57
- };
58
- };
48
+ declare global {
49
+ namespace Astro {
50
+ interface IntegrationHooks {
51
+ 'astro:db:setup'?: (options: {
52
+ extendDb: (options: {
53
+ configEntrypoint?: URL | string;
54
+ seedEntrypoint?: URL | string;
55
+ }) => void;
56
+ }) => void | Promise<void>;
57
+ }
58
+ }
59
+ }
59
60
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { AstroConfig, AstroIntegration } from 'astro';
2
- import type { AstroDbIntegration } from './types.js';
2
+ import './types.js';
3
3
  export type VitePlugin = Required<AstroConfig['vite']>['plugins'][number];
4
4
  export declare function getAstroEnv(envMode?: string): Record<`ASTRO_${string}`, string>;
5
5
  export declare function getRemoteDatabaseUrl(): string;
6
6
  export declare function getDbDirectoryUrl(root: URL | string): URL;
7
- export declare function defineDbIntegration(integration: AstroDbIntegration): AstroIntegration;
7
+ export declare function defineDbIntegration(integration: AstroIntegration): AstroIntegration;
8
8
  export type Result<T> = {
9
9
  success: true;
10
10
  data: T;
@@ -1,5 +1,6 @@
1
1
  import { getAstroStudioEnv } from "@astrojs/studio";
2
2
  import { loadEnv } from "vite";
3
+ import "./types.js";
3
4
  function getAstroEnv(envMode = "") {
4
5
  const env = loadEnv(envMode, process.cwd(), "ASTRO_");
5
6
  return env;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.11.7",
3
+ "version": "0.12.0",
4
4
  "description": "Add libSQL and Astro Studio support to your Astro site",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -62,7 +62,7 @@
62
62
  "astro-integration"
63
63
  ],
64
64
  "dependencies": {
65
- "@libsql/client": "^0.6.2",
65
+ "@libsql/client": "^0.7.0",
66
66
  "async-listen": "^3.0.1",
67
67
  "ci-info": "^4.0.0",
68
68
  "deep-diff": "^1.0.2",
@@ -85,9 +85,9 @@
85
85
  "@types/prompts": "^2.4.9",
86
86
  "@types/yargs-parser": "^21.0.3",
87
87
  "cheerio": "1.0.0-rc.12",
88
- "typescript": "^5.5.2",
89
- "vite": "^5.3.1",
90
- "astro": "4.11.2",
88
+ "typescript": "^5.5.3",
89
+ "vite": "^5.3.4",
90
+ "astro": "4.12.0",
91
91
  "astro-scripts": "0.0.14"
92
92
  },
93
93
  "scripts": {