@nextlyhq/adapter-drizzle 0.0.2-alpha.7 → 0.0.2-alpha.71
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.
- package/README.md +25 -1
- package/dist/adapter-BypoOEEN.d.cts +1166 -0
- package/dist/adapter-CSP-Ek-L.d.ts +1166 -0
- package/dist/index-BYb6cDli.d.ts +1168 -0
- package/dist/index-C4HJsfwA.d.cts +1168 -0
- package/dist/index.cjs +2302 -1085
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -9
- package/dist/index.d.ts +5 -9
- package/dist/index.mjs +2301 -1083
- package/dist/index.mjs.map +1 -1
- package/dist/migrations.cjs +345 -146
- package/dist/migrations.cjs.map +1 -1
- package/dist/migrations.d.cts +93 -109
- package/dist/migrations.d.ts +93 -109
- package/dist/migrations.mjs +344 -144
- package/dist/migrations.mjs.map +1 -1
- package/dist/schema/index.cjs +21 -6
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +5 -116
- package/dist/schema/index.d.ts +5 -116
- package/dist/schema/index.mjs +20 -4
- package/dist/schema/index.mjs.map +1 -1
- package/dist/schema-Bkkr3JMC.d.cts +264 -0
- package/dist/schema-Bkkr3JMC.d.ts +264 -0
- package/dist/schema-name.cjs +42 -0
- package/dist/schema-name.cjs.map +1 -0
- package/dist/schema-name.d.cts +12 -0
- package/dist/schema-name.d.ts +12 -0
- package/dist/schema-name.mjs +40 -0
- package/dist/schema-name.mjs.map +1 -0
- package/dist/text-match.cjs +50 -0
- package/dist/text-match.cjs.map +1 -0
- package/dist/text-match.d.cts +32 -0
- package/dist/text-match.d.ts +32 -0
- package/dist/text-match.mjs +48 -0
- package/dist/text-match.mjs.map +1 -0
- package/dist/types/index.cjs +8 -24
- package/dist/types/index.d.cts +3 -210
- package/dist/types/index.d.ts +3 -210
- package/dist/types/index.mjs +1 -21
- package/dist/types-CNyA1oIm.cjs +185 -0
- package/dist/types-CNyA1oIm.cjs.map +1 -0
- package/dist/types-CaF_5jNk.mjs +150 -0
- package/dist/types-CaF_5jNk.mjs.map +1 -0
- package/dist/version-check.cjs +119 -127
- package/dist/version-check.cjs.map +1 -1
- package/dist/version-check.d.cts +54 -39
- package/dist/version-check.d.ts +54 -39
- package/dist/version-check.mjs +117 -125
- package/dist/version-check.mjs.map +1 -1
- package/package.json +23 -17
- package/dist/adapter-BxJVtttb.d.ts +0 -592
- package/dist/adapter-nvlxFkF-.d.cts +0 -592
- package/dist/core-CVO7WYDj.d.cts +0 -74
- package/dist/core-CVO7WYDj.d.ts +0 -74
- package/dist/error-um1d_3Uo.d.cts +0 -105
- package/dist/error-um1d_3Uo.d.ts +0 -105
- package/dist/migration-BbO5meEV.d.cts +0 -622
- package/dist/migration-Qe70wDOC.d.ts +0 -622
- package/dist/schema-BDn8WfSL.d.cts +0 -200
- package/dist/schema-BIQ0YQZ_.d.ts +0 -200
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.mjs.map +0 -1
package/dist/schema/index.cjs
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
// src/schema/index.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Schema utilities version.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This version tracks the schema utilities module independently
|
|
8
|
+
* from the main adapter package version.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const SCHEMA_VERSION = "0.1.0";
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether schema builder utilities are available.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Currently `false` - schema builder utilities will be implemented
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
const SCHEMA_BUILDER_AVAILABLE = false;
|
|
7
22
|
exports.SCHEMA_BUILDER_AVAILABLE = SCHEMA_BUILDER_AVAILABLE;
|
|
8
23
|
exports.SCHEMA_VERSION = SCHEMA_VERSION;
|
|
9
|
-
|
|
24
|
+
|
|
10
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/schema/index.ts"],"sourcesContent":["/**\n * Schema utilities for @nextly/adapter-drizzle\n *\n * @remarks\n * This module re-exports schema-related types from the `/types` subpath\n *\n * ## Current Exports\n *\n * - **Schema Type Definitions:** {@link TableDefinition}, {@link ColumnDefinition}, {@link IndexDefinition}, {@link TableConstraint}\n * - **Schema Operation Types:** {@link CreateTableOptions}, {@link DropTableOptions}, {@link AlterTableOptions}, {@link AlterTableOperation}\n * - **Core Types:** {@link SqlParam}\n *\n * ## Coming in Phase 4\n *\n * - Schema builder utilities\n * - Schema generator functions\n * - Dialect-specific schema mapping\n * - Unified schema definitions\n *\n * ## Usage Examples\n *\n * ### Defining a Table Schema\n *\n * ```typescript\n * import type { TableDefinition } from \"@nextly/adapter-drizzle/schema\";\n *\n * const usersTable: TableDefinition = {\n * name: \"users\",\n * columns: [\n * { name: \"id\", type: \"uuid\", primaryKey: true },\n * { name: \"email\", type: \"varchar(255)\", unique: true },\n * { name: \"name\", type: \"varchar(255)\", nullable: true },\n * {\n * name: \"created_at\",\n * type: \"timestamp\",\n * default: { sql: \"CURRENT_TIMESTAMP\" },\n * },\n * ],\n * indexes: [\n * { name: \"users_email_idx\", columns: [\"email\"], unique: true },\n * ],\n * };\n * ```\n *\n * ### Creating a Table with Adapter\n *\n * ```typescript\n * import type { DrizzleAdapter } from \"@nextly/adapter-drizzle\";\n * import type { TableDefinition } from \"@nextly/adapter-drizzle/schema\";\n *\n * async function createUsersTable(adapter: DrizzleAdapter) {\n * const tableDefinition: TableDefinition = {\n * // ... table definition\n * };\n *\n * await adapter.createTable(tableDefinition, { ifNotExists: true });\n * }\n * ```\n *\n * ### Altering a Table\n *\n * ```typescript\n * import type {\n * AlterTableOperation,\n * ColumnDefinition,\n * } from \"@nextly/adapter-drizzle/schema\";\n *\n * const operations: AlterTableOperation[] = [\n * {\n * kind: \"add_column\",\n * column: { name: \"age\", type: \"int\", nullable: true },\n * },\n * {\n * kind: \"rename_column\",\n * from: \"name\",\n * to: \"full_name\",\n * },\n * ];\n *\n * await adapter.alterTable(\"users\", operations);\n * ```\n *\n * @packageDocumentation\n */\n\n// ============================================================\n// Schema Type Re-exports\n// ============================================================\n\n/**\n * Column definition for schema operations.\n *\n * @remarks\n * Defines the structure of a database column in a database-agnostic way.\n * Adapters translate these definitions to dialect-specific DDL.\n *\n * @example\n * ```typescript\n * const idColumn: ColumnDefinition = {\n * name: \"id\",\n * type: \"uuid\",\n * primaryKey: true,\n * };\n *\n * const emailColumn: ColumnDefinition = {\n * name: \"email\",\n * type: \"varchar(255)\",\n * unique: true,\n * };\n * ```\n *\n * @public\n */\nexport type { ColumnDefinition } from \"../types/schema\";\n\n/**\n * Index definition for schema operations.\n *\n * @remarks\n * Defines database indexes for performance optimization.\n *\n * @example\n * ```typescript\n * const emailIndex: IndexDefinition = {\n * name: \"users_email_idx\",\n * columns: [\"email\"],\n * unique: true,\n * };\n * ```\n *\n * @public\n */\nexport type { IndexDefinition } from \"../types/schema\";\n\n/**\n * Table constraint definition.\n *\n * @example\n * ```typescript\n * const checkConstraint: TableConstraint = {\n * name: \"check_age_positive\",\n * type: \"check\",\n * expression: \"age >= 0\",\n * };\n * ```\n *\n * @public\n */\nexport type { TableConstraint } from \"../types/schema\";\n\n/**\n * Complete table definition.\n *\n * @remarks\n * Defines the complete structure of a database table including columns,\n * indexes, and constraints.\n *\n * @example\n * ```typescript\n * const postsTable: TableDefinition = {\n * name: \"posts\",\n * columns: [\n * { name: \"id\", type: \"uuid\", primaryKey: true },\n * { name: \"title\", type: \"varchar(255)\" },\n * { name: \"content\", type: \"text\" },\n * { name: \"published\", type: \"boolean\", default: false },\n * ],\n * indexes: [\n * { name: \"posts_title_idx\", columns: [\"title\"] },\n * ],\n * };\n * ```\n *\n * @public\n */\nexport type { TableDefinition } from \"../types/schema\";\n\n/**\n * Options for table creation.\n *\n * @example\n * ```typescript\n * const options: CreateTableOptions = {\n * ifNotExists: true,\n * temporary: false,\n * };\n *\n * await adapter.createTable(tableDefinition, options);\n * ```\n *\n * @public\n */\nexport type { CreateTableOptions } from \"../types/schema\";\n\n/**\n * Options for table dropping.\n *\n * @example\n * ```typescript\n * const options: DropTableOptions = {\n * ifExists: true,\n * cascade: true,\n * };\n *\n * await adapter.dropTable(\"old_table\", options);\n * ```\n *\n * @public\n */\nexport type { DropTableOptions } from \"../types/schema\";\n\n/**\n * Options for table alteration.\n *\n * @public\n */\nexport type { AlterTableOptions } from \"../types/schema\";\n\n/**\n * Table alteration operations.\n *\n * @remarks\n * Defines the types of operations that can be performed when altering a table.\n *\n * @example\n * ```typescript\n * const operations: AlterTableOperation[] = [\n * {\n * kind: \"add_column\",\n * column: { name: \"status\", type: \"varchar(20)\", default: \"draft\" },\n * },\n * {\n * kind: \"drop_column\",\n * columnName: \"old_field\",\n * },\n * {\n * kind: \"add_constraint\",\n * constraint: {\n * name: \"check_status\",\n * type: \"check\",\n * expression: \"status IN ('draft', 'published')\",\n * },\n * },\n * ];\n *\n * await adapter.alterTable(\"posts\", operations);\n * ```\n *\n * @public\n */\nexport type { AlterTableOperation } from \"../types/schema\";\n\n// ============================================================\n// Core Type Re-exports\n// ============================================================\n\n/**\n * SQL parameter type (for use in column defaults, etc.).\n *\n * @remarks\n * Represents values that can be safely passed as SQL parameters.\n *\n * @public\n */\nexport type { SqlParam } from \"../types/core\";\n\n// ============================================================\n// Module Metadata\n// ============================================================\n\n/**\n * Schema utilities version.\n *\n * @remarks\n * This version tracks the schema utilities module independently\n * from the main adapter package version.\n *\n * @internal\n */\nexport const SCHEMA_VERSION = \"0.1.0\" as const;\n\n/**\n * Indicates whether schema builder utilities are available.\n *\n * @remarks\n * Currently `false` - schema builder utilities will be implemented\n *\n * @internal\n */\nexport const SCHEMA_BUILDER_AVAILABLE = false as const;\n"],"mappings":";;;;;;;;;;;AAuRA,MAAa,iBAAiB;;;;;;;;;AAU9B,MAAa,2BAA2B"}
|
package/dist/schema/index.d.cts
CHANGED
|
@@ -1,115 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { a as SqlParam } from '../core-CVO7WYDj.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Schema utilities for @nextly/adapter-drizzle
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* This module re-exports schema-related types from the `/types` subpath
|
|
9
|
-
*
|
|
10
|
-
* ## Current Exports
|
|
11
|
-
*
|
|
12
|
-
* - **Schema Type Definitions:** {@link TableDefinition}, {@link ColumnDefinition}, {@link IndexDefinition}, {@link TableConstraint}
|
|
13
|
-
* - **Schema Operation Types:** {@link CreateTableOptions}, {@link DropTableOptions}, {@link AlterTableOptions}, {@link AlterTableOperation}
|
|
14
|
-
* - **Core Types:** {@link SqlParam}
|
|
15
|
-
*
|
|
16
|
-
* ## Coming in Phase 4
|
|
17
|
-
*
|
|
18
|
-
* - Schema builder utilities
|
|
19
|
-
* - Schema generator functions
|
|
20
|
-
* - Dialect-specific schema mapping
|
|
21
|
-
* - Unified schema definitions
|
|
22
|
-
*
|
|
23
|
-
* ## Usage Examples
|
|
24
|
-
*
|
|
25
|
-
* ### Defining a Table Schema
|
|
26
|
-
*
|
|
27
|
-
* ```typescript
|
|
28
|
-
* import type { TableDefinition } from "@nextly/adapter-drizzle/schema";
|
|
29
|
-
*
|
|
30
|
-
* const usersTable: TableDefinition = {
|
|
31
|
-
* name: "users",
|
|
32
|
-
* columns: [
|
|
33
|
-
* { name: "id", type: "uuid", primaryKey: true },
|
|
34
|
-
* { name: "email", type: "varchar(255)", unique: true },
|
|
35
|
-
* { name: "name", type: "varchar(255)", nullable: true },
|
|
36
|
-
* {
|
|
37
|
-
* name: "created_at",
|
|
38
|
-
* type: "timestamp",
|
|
39
|
-
* default: { sql: "CURRENT_TIMESTAMP" },
|
|
40
|
-
* },
|
|
41
|
-
* ],
|
|
42
|
-
* indexes: [
|
|
43
|
-
* { name: "users_email_idx", columns: ["email"], unique: true },
|
|
44
|
-
* ],
|
|
45
|
-
* };
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* ### Creating a Table with Adapter
|
|
49
|
-
*
|
|
50
|
-
* ```typescript
|
|
51
|
-
* import type { DrizzleAdapter } from "@nextly/adapter-drizzle";
|
|
52
|
-
* import type { TableDefinition } from "@nextly/adapter-drizzle/schema";
|
|
53
|
-
*
|
|
54
|
-
* async function createUsersTable(adapter: DrizzleAdapter) {
|
|
55
|
-
* const tableDefinition: TableDefinition = {
|
|
56
|
-
* // ... table definition
|
|
57
|
-
* };
|
|
58
|
-
*
|
|
59
|
-
* await adapter.createTable(tableDefinition, { ifNotExists: true });
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* ### Altering a Table
|
|
64
|
-
*
|
|
65
|
-
* ```typescript
|
|
66
|
-
* import type {
|
|
67
|
-
* AlterTableOperation,
|
|
68
|
-
* ColumnDefinition,
|
|
69
|
-
* } from "@nextly/adapter-drizzle/schema";
|
|
70
|
-
*
|
|
71
|
-
* const operations: AlterTableOperation[] = [
|
|
72
|
-
* {
|
|
73
|
-
* kind: "add_column",
|
|
74
|
-
* column: { name: "age", type: "int", nullable: true },
|
|
75
|
-
* },
|
|
76
|
-
* {
|
|
77
|
-
* kind: "rename_column",
|
|
78
|
-
* from: "name",
|
|
79
|
-
* to: "full_name",
|
|
80
|
-
* },
|
|
81
|
-
* ];
|
|
82
|
-
*
|
|
83
|
-
* await adapter.alterTable("users", operations);
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @packageDocumentation
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
|
-
* Column definition for schema operations.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* Defines the structure of a database column in a database-agnostic way.
|
|
93
|
-
* Adapters translate these definitions to dialect-specific DDL.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* const idColumn: ColumnDefinition = {
|
|
98
|
-
* name: "id",
|
|
99
|
-
* type: "uuid",
|
|
100
|
-
* primaryKey: true,
|
|
101
|
-
* };
|
|
102
|
-
*
|
|
103
|
-
* const emailColumn: ColumnDefinition = {
|
|
104
|
-
* name: "email",
|
|
105
|
-
* type: "varchar(255)",
|
|
106
|
-
* unique: true,
|
|
107
|
-
* };
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
|
|
1
|
+
import { a as DropTableOptions, c as TableDefinition, f as SqlParam, i as CreateTableOptions, n as AlterTableOptions, o as IndexDefinition, r as ColumnDefinition, s as TableConstraint, t as AlterTableOperation } from "../schema-Bkkr3JMC.cjs";
|
|
113
2
|
/**
|
|
114
3
|
* Schema utilities version.
|
|
115
4
|
*
|
|
@@ -119,7 +8,7 @@ export { a as SqlParam } from '../core-CVO7WYDj.cjs';
|
|
|
119
8
|
*
|
|
120
9
|
* @internal
|
|
121
10
|
*/
|
|
122
|
-
declare const SCHEMA_VERSION: "0.1.0";
|
|
11
|
+
export declare const SCHEMA_VERSION: "0.1.0";
|
|
123
12
|
/**
|
|
124
13
|
* Indicates whether schema builder utilities are available.
|
|
125
14
|
*
|
|
@@ -128,6 +17,6 @@ declare const SCHEMA_VERSION: "0.1.0";
|
|
|
128
17
|
*
|
|
129
18
|
* @internal
|
|
130
19
|
*/
|
|
131
|
-
declare const SCHEMA_BUILDER_AVAILABLE: false;
|
|
132
|
-
|
|
133
|
-
|
|
20
|
+
export declare const SCHEMA_BUILDER_AVAILABLE: false;
|
|
21
|
+
export type { AlterTableOperation, AlterTableOptions, ColumnDefinition, CreateTableOptions, DropTableOptions, IndexDefinition, SqlParam, TableConstraint, TableDefinition };
|
|
22
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,115 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { a as SqlParam } from '../core-CVO7WYDj.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Schema utilities for @nextly/adapter-drizzle
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* This module re-exports schema-related types from the `/types` subpath
|
|
9
|
-
*
|
|
10
|
-
* ## Current Exports
|
|
11
|
-
*
|
|
12
|
-
* - **Schema Type Definitions:** {@link TableDefinition}, {@link ColumnDefinition}, {@link IndexDefinition}, {@link TableConstraint}
|
|
13
|
-
* - **Schema Operation Types:** {@link CreateTableOptions}, {@link DropTableOptions}, {@link AlterTableOptions}, {@link AlterTableOperation}
|
|
14
|
-
* - **Core Types:** {@link SqlParam}
|
|
15
|
-
*
|
|
16
|
-
* ## Coming in Phase 4
|
|
17
|
-
*
|
|
18
|
-
* - Schema builder utilities
|
|
19
|
-
* - Schema generator functions
|
|
20
|
-
* - Dialect-specific schema mapping
|
|
21
|
-
* - Unified schema definitions
|
|
22
|
-
*
|
|
23
|
-
* ## Usage Examples
|
|
24
|
-
*
|
|
25
|
-
* ### Defining a Table Schema
|
|
26
|
-
*
|
|
27
|
-
* ```typescript
|
|
28
|
-
* import type { TableDefinition } from "@nextly/adapter-drizzle/schema";
|
|
29
|
-
*
|
|
30
|
-
* const usersTable: TableDefinition = {
|
|
31
|
-
* name: "users",
|
|
32
|
-
* columns: [
|
|
33
|
-
* { name: "id", type: "uuid", primaryKey: true },
|
|
34
|
-
* { name: "email", type: "varchar(255)", unique: true },
|
|
35
|
-
* { name: "name", type: "varchar(255)", nullable: true },
|
|
36
|
-
* {
|
|
37
|
-
* name: "created_at",
|
|
38
|
-
* type: "timestamp",
|
|
39
|
-
* default: { sql: "CURRENT_TIMESTAMP" },
|
|
40
|
-
* },
|
|
41
|
-
* ],
|
|
42
|
-
* indexes: [
|
|
43
|
-
* { name: "users_email_idx", columns: ["email"], unique: true },
|
|
44
|
-
* ],
|
|
45
|
-
* };
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* ### Creating a Table with Adapter
|
|
49
|
-
*
|
|
50
|
-
* ```typescript
|
|
51
|
-
* import type { DrizzleAdapter } from "@nextly/adapter-drizzle";
|
|
52
|
-
* import type { TableDefinition } from "@nextly/adapter-drizzle/schema";
|
|
53
|
-
*
|
|
54
|
-
* async function createUsersTable(adapter: DrizzleAdapter) {
|
|
55
|
-
* const tableDefinition: TableDefinition = {
|
|
56
|
-
* // ... table definition
|
|
57
|
-
* };
|
|
58
|
-
*
|
|
59
|
-
* await adapter.createTable(tableDefinition, { ifNotExists: true });
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* ### Altering a Table
|
|
64
|
-
*
|
|
65
|
-
* ```typescript
|
|
66
|
-
* import type {
|
|
67
|
-
* AlterTableOperation,
|
|
68
|
-
* ColumnDefinition,
|
|
69
|
-
* } from "@nextly/adapter-drizzle/schema";
|
|
70
|
-
*
|
|
71
|
-
* const operations: AlterTableOperation[] = [
|
|
72
|
-
* {
|
|
73
|
-
* kind: "add_column",
|
|
74
|
-
* column: { name: "age", type: "int", nullable: true },
|
|
75
|
-
* },
|
|
76
|
-
* {
|
|
77
|
-
* kind: "rename_column",
|
|
78
|
-
* from: "name",
|
|
79
|
-
* to: "full_name",
|
|
80
|
-
* },
|
|
81
|
-
* ];
|
|
82
|
-
*
|
|
83
|
-
* await adapter.alterTable("users", operations);
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @packageDocumentation
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
|
-
* Column definition for schema operations.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* Defines the structure of a database column in a database-agnostic way.
|
|
93
|
-
* Adapters translate these definitions to dialect-specific DDL.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* const idColumn: ColumnDefinition = {
|
|
98
|
-
* name: "id",
|
|
99
|
-
* type: "uuid",
|
|
100
|
-
* primaryKey: true,
|
|
101
|
-
* };
|
|
102
|
-
*
|
|
103
|
-
* const emailColumn: ColumnDefinition = {
|
|
104
|
-
* name: "email",
|
|
105
|
-
* type: "varchar(255)",
|
|
106
|
-
* unique: true,
|
|
107
|
-
* };
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
|
|
1
|
+
import { a as DropTableOptions, c as TableDefinition, f as SqlParam, i as CreateTableOptions, n as AlterTableOptions, o as IndexDefinition, r as ColumnDefinition, s as TableConstraint, t as AlterTableOperation } from "../schema-Bkkr3JMC.js";
|
|
113
2
|
/**
|
|
114
3
|
* Schema utilities version.
|
|
115
4
|
*
|
|
@@ -119,7 +8,7 @@ export { a as SqlParam } from '../core-CVO7WYDj.js';
|
|
|
119
8
|
*
|
|
120
9
|
* @internal
|
|
121
10
|
*/
|
|
122
|
-
declare const SCHEMA_VERSION: "0.1.0";
|
|
11
|
+
export declare const SCHEMA_VERSION: "0.1.0";
|
|
123
12
|
/**
|
|
124
13
|
* Indicates whether schema builder utilities are available.
|
|
125
14
|
*
|
|
@@ -128,6 +17,6 @@ declare const SCHEMA_VERSION: "0.1.0";
|
|
|
128
17
|
*
|
|
129
18
|
* @internal
|
|
130
19
|
*/
|
|
131
|
-
declare const SCHEMA_BUILDER_AVAILABLE: false;
|
|
132
|
-
|
|
133
|
-
|
|
20
|
+
export declare const SCHEMA_BUILDER_AVAILABLE: false;
|
|
21
|
+
export type { AlterTableOperation, AlterTableOptions, ColumnDefinition, CreateTableOptions, DropTableOptions, IndexDefinition, SqlParam, TableConstraint, TableDefinition };
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/schema/index.mjs
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
// src/schema/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Schema utilities version.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This version tracks the schema utilities module independently
|
|
7
|
+
* from the main adapter package version.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
const SCHEMA_VERSION = "0.1.0";
|
|
12
|
+
/**
|
|
13
|
+
* Indicates whether schema builder utilities are available.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Currently `false` - schema builder utilities will be implemented
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
const SCHEMA_BUILDER_AVAILABLE = false;
|
|
5
21
|
export { SCHEMA_BUILDER_AVAILABLE, SCHEMA_VERSION };
|
|
6
|
-
|
|
22
|
+
|
|
7
23
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/schema/index.ts"],"sourcesContent":["/**\n * Schema utilities for @nextly/adapter-drizzle\n *\n * @remarks\n * This module re-exports schema-related types from the `/types` subpath\n *\n * ## Current Exports\n *\n * - **Schema Type Definitions:** {@link TableDefinition}, {@link ColumnDefinition}, {@link IndexDefinition}, {@link TableConstraint}\n * - **Schema Operation Types:** {@link CreateTableOptions}, {@link DropTableOptions}, {@link AlterTableOptions}, {@link AlterTableOperation}\n * - **Core Types:** {@link SqlParam}\n *\n * ## Coming in Phase 4\n *\n * - Schema builder utilities\n * - Schema generator functions\n * - Dialect-specific schema mapping\n * - Unified schema definitions\n *\n * ## Usage Examples\n *\n * ### Defining a Table Schema\n *\n * ```typescript\n * import type { TableDefinition } from \"@nextly/adapter-drizzle/schema\";\n *\n * const usersTable: TableDefinition = {\n * name: \"users\",\n * columns: [\n * { name: \"id\", type: \"uuid\", primaryKey: true },\n * { name: \"email\", type: \"varchar(255)\", unique: true },\n * { name: \"name\", type: \"varchar(255)\", nullable: true },\n * {\n * name: \"created_at\",\n * type: \"timestamp\",\n * default: { sql: \"CURRENT_TIMESTAMP\" },\n * },\n * ],\n * indexes: [\n * { name: \"users_email_idx\", columns: [\"email\"], unique: true },\n * ],\n * };\n * ```\n *\n * ### Creating a Table with Adapter\n *\n * ```typescript\n * import type { DrizzleAdapter } from \"@nextly/adapter-drizzle\";\n * import type { TableDefinition } from \"@nextly/adapter-drizzle/schema\";\n *\n * async function createUsersTable(adapter: DrizzleAdapter) {\n * const tableDefinition: TableDefinition = {\n * // ... table definition\n * };\n *\n * await adapter.createTable(tableDefinition, { ifNotExists: true });\n * }\n * ```\n *\n * ### Altering a Table\n *\n * ```typescript\n * import type {\n * AlterTableOperation,\n * ColumnDefinition,\n * } from \"@nextly/adapter-drizzle/schema\";\n *\n * const operations: AlterTableOperation[] = [\n * {\n * kind: \"add_column\",\n * column: { name: \"age\", type: \"int\", nullable: true },\n * },\n * {\n * kind: \"rename_column\",\n * from: \"name\",\n * to: \"full_name\",\n * },\n * ];\n *\n * await adapter.alterTable(\"users\", operations);\n * ```\n *\n * @packageDocumentation\n */\n\n// ============================================================\n// Schema Type Re-exports\n// ============================================================\n\n/**\n * Column definition for schema operations.\n *\n * @remarks\n * Defines the structure of a database column in a database-agnostic way.\n * Adapters translate these definitions to dialect-specific DDL.\n *\n * @example\n * ```typescript\n * const idColumn: ColumnDefinition = {\n * name: \"id\",\n * type: \"uuid\",\n * primaryKey: true,\n * };\n *\n * const emailColumn: ColumnDefinition = {\n * name: \"email\",\n * type: \"varchar(255)\",\n * unique: true,\n * };\n * ```\n *\n * @public\n */\nexport type { ColumnDefinition } from \"../types/schema\";\n\n/**\n * Index definition for schema operations.\n *\n * @remarks\n * Defines database indexes for performance optimization.\n *\n * @example\n * ```typescript\n * const emailIndex: IndexDefinition = {\n * name: \"users_email_idx\",\n * columns: [\"email\"],\n * unique: true,\n * };\n * ```\n *\n * @public\n */\nexport type { IndexDefinition } from \"../types/schema\";\n\n/**\n * Table constraint definition.\n *\n * @example\n * ```typescript\n * const checkConstraint: TableConstraint = {\n * name: \"check_age_positive\",\n * type: \"check\",\n * expression: \"age >= 0\",\n * };\n * ```\n *\n * @public\n */\nexport type { TableConstraint } from \"../types/schema\";\n\n/**\n * Complete table definition.\n *\n * @remarks\n * Defines the complete structure of a database table including columns,\n * indexes, and constraints.\n *\n * @example\n * ```typescript\n * const postsTable: TableDefinition = {\n * name: \"posts\",\n * columns: [\n * { name: \"id\", type: \"uuid\", primaryKey: true },\n * { name: \"title\", type: \"varchar(255)\" },\n * { name: \"content\", type: \"text\" },\n * { name: \"published\", type: \"boolean\", default: false },\n * ],\n * indexes: [\n * { name: \"posts_title_idx\", columns: [\"title\"] },\n * ],\n * };\n * ```\n *\n * @public\n */\nexport type { TableDefinition } from \"../types/schema\";\n\n/**\n * Options for table creation.\n *\n * @example\n * ```typescript\n * const options: CreateTableOptions = {\n * ifNotExists: true,\n * temporary: false,\n * };\n *\n * await adapter.createTable(tableDefinition, options);\n * ```\n *\n * @public\n */\nexport type { CreateTableOptions } from \"../types/schema\";\n\n/**\n * Options for table dropping.\n *\n * @example\n * ```typescript\n * const options: DropTableOptions = {\n * ifExists: true,\n * cascade: true,\n * };\n *\n * await adapter.dropTable(\"old_table\", options);\n * ```\n *\n * @public\n */\nexport type { DropTableOptions } from \"../types/schema\";\n\n/**\n * Options for table alteration.\n *\n * @public\n */\nexport type { AlterTableOptions } from \"../types/schema\";\n\n/**\n * Table alteration operations.\n *\n * @remarks\n * Defines the types of operations that can be performed when altering a table.\n *\n * @example\n * ```typescript\n * const operations: AlterTableOperation[] = [\n * {\n * kind: \"add_column\",\n * column: { name: \"status\", type: \"varchar(20)\", default: \"draft\" },\n * },\n * {\n * kind: \"drop_column\",\n * columnName: \"old_field\",\n * },\n * {\n * kind: \"add_constraint\",\n * constraint: {\n * name: \"check_status\",\n * type: \"check\",\n * expression: \"status IN ('draft', 'published')\",\n * },\n * },\n * ];\n *\n * await adapter.alterTable(\"posts\", operations);\n * ```\n *\n * @public\n */\nexport type { AlterTableOperation } from \"../types/schema\";\n\n// ============================================================\n// Core Type Re-exports\n// ============================================================\n\n/**\n * SQL parameter type (for use in column defaults, etc.).\n *\n * @remarks\n * Represents values that can be safely passed as SQL parameters.\n *\n * @public\n */\nexport type { SqlParam } from \"../types/core\";\n\n// ============================================================\n// Module Metadata\n// ============================================================\n\n/**\n * Schema utilities version.\n *\n * @remarks\n * This version tracks the schema utilities module independently\n * from the main adapter package version.\n *\n * @internal\n */\nexport const SCHEMA_VERSION = \"0.1.0\" as const;\n\n/**\n * Indicates whether schema builder utilities are available.\n *\n * @remarks\n * Currently `false` - schema builder utilities will be implemented\n *\n * @internal\n */\nexport const SCHEMA_BUILDER_AVAILABLE = false as const;\n"],"mappings":";;;;;;;;;;AAuRA,MAAa,iBAAiB;;;;;;;;;AAU9B,MAAa,2BAA2B"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the Nextly database adapter system.
|
|
3
|
+
*
|
|
4
|
+
* These types are the foundation for all database operations and are designed
|
|
5
|
+
* to be database-agnostic while supporting dialect-specific features.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Supported database dialects.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* These are the database systems that Nextly officially supports through
|
|
14
|
+
* dedicated adapter packages.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
type SupportedDialect = "postgresql" | "mysql" | "sqlite";
|
|
19
|
+
/**
|
|
20
|
+
* SQL parameter types that are safe to use across all database dialects.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* - `undefined` is included for optional parameters
|
|
24
|
+
* - `Date` objects will be converted to appropriate format per dialect
|
|
25
|
+
* - `null` represents SQL NULL
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
type SqlParam = string | number | boolean | Date | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* JSON value types that can be stored in JSON/JSONB columns.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Represents the valid JSON value types as defined by the JSON specification.
|
|
35
|
+
* This is a recursive type to support nested objects and arrays.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
40
|
+
[key: string]: JsonValue;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* JSON object type for structured data.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Useful for typed JSON column data where the structure is known.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
type JsonObject = {
|
|
51
|
+
[key: string]: JsonValue;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* JSON array type.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
type JsonArray = JsonValue[];
|
|
59
|
+
/**
|
|
60
|
+
* Interface for resolving table names to Drizzle table objects.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* When a TableResolver is set on the adapter via `setTableResolver()`,
|
|
64
|
+
* CRUD methods will use Drizzle's query API instead of raw SQL string building.
|
|
65
|
+
* The nextly SchemaRegistry implements this interface.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
interface TableResolver {
|
|
70
|
+
/** Look up a Drizzle table object by table name. Returns null if not found. */
|
|
71
|
+
getTable(tableName: string): unknown;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Column definition for schema operations.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* Defines the structure of a database column in a database-agnostic way.
|
|
78
|
+
* Adapters translate these definitions to dialect-specific DDL.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
interface ColumnDefinition {
|
|
83
|
+
/** Column name */
|
|
84
|
+
name: string;
|
|
85
|
+
/**
|
|
86
|
+
* Column data type.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Common types across databases:
|
|
90
|
+
* - Text: varchar(n), text, char(n)
|
|
91
|
+
* - Numbers: int, bigint, decimal, numeric
|
|
92
|
+
* - Boolean: boolean
|
|
93
|
+
* - Date/Time: timestamp, date, time
|
|
94
|
+
* - JSON: json, jsonb (PostgreSQL)
|
|
95
|
+
* - UUID: uuid (PostgreSQL), char(36) (MySQL/SQLite)
|
|
96
|
+
*
|
|
97
|
+
* Adapters handle dialect-specific type mapping.
|
|
98
|
+
*/
|
|
99
|
+
type: string;
|
|
100
|
+
/** Allow NULL values (default: true) */
|
|
101
|
+
nullable?: boolean;
|
|
102
|
+
/** Primary key column */
|
|
103
|
+
primaryKey?: boolean;
|
|
104
|
+
/** Unique constraint */
|
|
105
|
+
unique?: boolean;
|
|
106
|
+
/** Default value (literal or SQL expression) */
|
|
107
|
+
default?: SqlParam | {
|
|
108
|
+
sql: string;
|
|
109
|
+
};
|
|
110
|
+
/** Foreign key reference */
|
|
111
|
+
references?: {
|
|
112
|
+
/** Referenced table name */
|
|
113
|
+
table: string;
|
|
114
|
+
/** Referenced column name */
|
|
115
|
+
column: string;
|
|
116
|
+
/** Action on DELETE */
|
|
117
|
+
onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
118
|
+
/** Action on UPDATE */
|
|
119
|
+
onUpdate?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
120
|
+
};
|
|
121
|
+
/** Check constraint expression */
|
|
122
|
+
check?: string;
|
|
123
|
+
/** Generated column definition (computed column) */
|
|
124
|
+
generated?: {
|
|
125
|
+
/** SQL expression to generate the value */
|
|
126
|
+
as: string;
|
|
127
|
+
/** Store the value (true) or compute on-the-fly (false) */
|
|
128
|
+
stored?: boolean;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Index definition for schema operations.
|
|
133
|
+
*
|
|
134
|
+
* @remarks
|
|
135
|
+
* Defines database indexes for performance optimization.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
interface IndexDefinition {
|
|
140
|
+
/** Index name */
|
|
141
|
+
name: string;
|
|
142
|
+
/** Columns included in the index */
|
|
143
|
+
columns: string[];
|
|
144
|
+
/** Unique index (enforces uniqueness) */
|
|
145
|
+
unique?: boolean;
|
|
146
|
+
/** Partial index condition (WHERE clause) */
|
|
147
|
+
where?: string;
|
|
148
|
+
/** Index type (database-specific) */
|
|
149
|
+
using?: "btree" | "hash" | "gin" | "gist" | "brin";
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Table constraint definition.
|
|
153
|
+
*
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
interface TableConstraint {
|
|
157
|
+
/** Constraint name */
|
|
158
|
+
name: string;
|
|
159
|
+
/** Constraint type */
|
|
160
|
+
type: "unique" | "check" | "foreign_key" | "primary_key";
|
|
161
|
+
/** Columns involved in the constraint */
|
|
162
|
+
columns?: string[];
|
|
163
|
+
/** Check constraint expression */
|
|
164
|
+
expression?: string;
|
|
165
|
+
/** Foreign key reference (for foreign_key type) */
|
|
166
|
+
references?: {
|
|
167
|
+
/** Referenced table name */
|
|
168
|
+
table: string;
|
|
169
|
+
/** Referenced columns */
|
|
170
|
+
columns: string[];
|
|
171
|
+
/** Action on DELETE */
|
|
172
|
+
onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
173
|
+
/** Action on UPDATE */
|
|
174
|
+
onUpdate?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Complete table definition.
|
|
179
|
+
*
|
|
180
|
+
* @remarks
|
|
181
|
+
* Defines the complete structure of a database table including columns,
|
|
182
|
+
* indexes, and constraints.
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
interface TableDefinition {
|
|
187
|
+
/** Table name */
|
|
188
|
+
name: string;
|
|
189
|
+
/** Column definitions */
|
|
190
|
+
columns: ColumnDefinition[];
|
|
191
|
+
/** Composite primary key (if not defined at column level) */
|
|
192
|
+
primaryKey?: string[];
|
|
193
|
+
/** Index definitions */
|
|
194
|
+
indexes?: IndexDefinition[];
|
|
195
|
+
/** Table-level constraints */
|
|
196
|
+
constraints?: TableConstraint[];
|
|
197
|
+
/** Table comment/description */
|
|
198
|
+
comment?: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Options for table creation.
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
interface CreateTableOptions {
|
|
206
|
+
/** Don't throw error if table exists */
|
|
207
|
+
ifNotExists?: boolean;
|
|
208
|
+
/** Temporary table (session-scoped) */
|
|
209
|
+
temporary?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Options for table dropping.
|
|
213
|
+
*
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
interface DropTableOptions {
|
|
217
|
+
/** Don't throw error if table doesn't exist */
|
|
218
|
+
ifExists?: boolean;
|
|
219
|
+
/** Drop dependent objects (CASCADE) */
|
|
220
|
+
cascade?: boolean;
|
|
221
|
+
/** Restrict drop if dependencies exist (default) */
|
|
222
|
+
restrict?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Options for table alteration.
|
|
226
|
+
*
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
interface AlterTableOptions {
|
|
230
|
+
/** Validation mode for constraints */
|
|
231
|
+
validate?: boolean;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Table alteration operations.
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* Defines the types of operations that can be performed when altering a table.
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
type AlterTableOperation = {
|
|
242
|
+
kind: "add_column";
|
|
243
|
+
column: ColumnDefinition;
|
|
244
|
+
} | {
|
|
245
|
+
kind: "drop_column";
|
|
246
|
+
columnName: string;
|
|
247
|
+
cascade?: boolean;
|
|
248
|
+
} | {
|
|
249
|
+
kind: "rename_column";
|
|
250
|
+
from: string;
|
|
251
|
+
to: string;
|
|
252
|
+
} | {
|
|
253
|
+
kind: "modify_column";
|
|
254
|
+
column: ColumnDefinition;
|
|
255
|
+
} | {
|
|
256
|
+
kind: "add_constraint";
|
|
257
|
+
constraint: TableConstraint;
|
|
258
|
+
} | {
|
|
259
|
+
kind: "drop_constraint";
|
|
260
|
+
constraintName: string;
|
|
261
|
+
cascade?: boolean;
|
|
262
|
+
};
|
|
263
|
+
export { DropTableOptions as a, TableDefinition as c, JsonValue as d, SqlParam as f, CreateTableOptions as i, JsonArray as l, TableResolver as m, AlterTableOptions as n, IndexDefinition as o, SupportedDialect as p, ColumnDefinition as r, TableConstraint as s, AlterTableOperation as t, JsonObject as u };
|
|
264
|
+
//# sourceMappingURL=schema-Bkkr3JMC.d.cts.map
|