@remix-run/data-table 0.1.0 → 0.2.1
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 +307 -56
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/lib/adapter.d.ts +386 -16
- package/dist/lib/adapter.d.ts.map +1 -1
- package/dist/lib/column.d.ts +193 -0
- package/dist/lib/column.d.ts.map +1 -0
- package/dist/lib/column.js +302 -0
- package/dist/lib/database/execution-context.d.ts +10 -0
- package/dist/lib/database/execution-context.d.ts.map +1 -0
- package/dist/lib/database/execution-context.js +1 -0
- package/dist/lib/database/helpers.d.ts +26 -0
- package/dist/lib/database/helpers.d.ts.map +1 -0
- package/dist/lib/database/helpers.js +116 -0
- package/dist/lib/database/query-execution.d.ts +7 -0
- package/dist/lib/database/query-execution.d.ts.map +1 -0
- package/dist/lib/database/query-execution.js +401 -0
- package/dist/lib/database/relations.d.ts +4 -0
- package/dist/lib/database/relations.d.ts.map +1 -0
- package/dist/lib/database/relations.js +207 -0
- package/dist/lib/database/write-lifecycle.d.ts +13 -0
- package/dist/lib/database/write-lifecycle.d.ts.map +1 -0
- package/dist/lib/database/write-lifecycle.js +279 -0
- package/dist/lib/database.d.ts +141 -238
- package/dist/lib/database.d.ts.map +1 -1
- package/dist/lib/database.js +73 -1122
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +9 -0
- package/dist/lib/migrations/filename.d.ts +12 -0
- package/dist/lib/migrations/filename.d.ts.map +1 -0
- package/dist/lib/migrations/filename.js +20 -0
- package/dist/lib/migrations/helpers.d.ts +11 -0
- package/dist/lib/migrations/helpers.d.ts.map +1 -0
- package/dist/lib/migrations/helpers.js +77 -0
- package/dist/lib/migrations/journal-store.d.ts +15 -0
- package/dist/lib/migrations/journal-store.d.ts.map +1 -0
- package/dist/lib/migrations/journal-store.js +83 -0
- package/dist/lib/migrations/registry.d.ts +27 -0
- package/dist/lib/migrations/registry.d.ts.map +1 -0
- package/dist/lib/migrations/registry.js +51 -0
- package/dist/lib/migrations/runner.d.ts +20 -0
- package/dist/lib/migrations/runner.d.ts.map +1 -0
- package/dist/lib/migrations/runner.js +273 -0
- package/dist/lib/migrations/schema-api.d.ts +7 -0
- package/dist/lib/migrations/schema-api.d.ts.map +1 -0
- package/dist/lib/migrations/schema-api.js +326 -0
- package/dist/lib/migrations-node.d.ts +17 -0
- package/dist/lib/migrations-node.d.ts.map +1 -0
- package/dist/lib/migrations-node.js +65 -0
- package/dist/lib/migrations.d.ts +292 -0
- package/dist/lib/migrations.d.ts.map +1 -0
- package/dist/lib/migrations.js +38 -0
- package/dist/lib/operators.d.ts +3 -0
- package/dist/lib/operators.d.ts.map +1 -1
- package/dist/lib/query.d.ts +159 -0
- package/dist/lib/query.d.ts.map +1 -0
- package/dist/lib/query.js +401 -0
- package/dist/lib/references.d.ts +0 -1
- package/dist/lib/references.d.ts.map +1 -1
- package/dist/lib/sql-helpers.d.ts +50 -0
- package/dist/lib/sql-helpers.d.ts.map +1 -0
- package/dist/lib/sql-helpers.js +111 -0
- package/dist/lib/sql.d.ts +23 -6
- package/dist/lib/sql.d.ts.map +1 -1
- package/dist/lib/sql.js +19 -5
- package/dist/lib/table.d.ts +355 -40
- package/dist/lib/table.d.ts.map +1 -1
- package/dist/lib/table.js +113 -90
- package/dist/migrations/node.d.ts +2 -0
- package/dist/migrations/node.d.ts.map +1 -0
- package/dist/migrations/node.js +1 -0
- package/dist/migrations.d.ts +8 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +5 -0
- package/dist/operators.d.ts +3 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/operators.js +1 -0
- package/dist/sql-helpers.d.ts +3 -0
- package/dist/sql-helpers.d.ts.map +1 -0
- package/dist/sql-helpers.js +1 -0
- package/package.json +24 -10
- package/src/index.ts +93 -10
- package/src/lib/adapter.ts +469 -25
- package/src/lib/column.ts +384 -0
- package/src/lib/database/execution-context.ts +15 -0
- package/src/lib/database/helpers.ts +216 -0
- package/src/lib/database/query-execution.ts +638 -0
- package/src/lib/database/relations.ts +332 -0
- package/src/lib/database/write-lifecycle.ts +487 -0
- package/src/lib/database.ts +246 -1848
- package/src/lib/errors.ts +10 -0
- package/src/lib/migrations/filename.ts +25 -0
- package/src/lib/migrations/helpers.ts +108 -0
- package/src/lib/migrations/journal-store.ts +122 -0
- package/src/lib/migrations/registry.ts +62 -0
- package/src/lib/migrations/runner.ts +374 -0
- package/src/lib/migrations/schema-api.ts +417 -0
- package/src/lib/migrations-node.ts +71 -0
- package/src/lib/migrations.ts +328 -0
- package/src/lib/operators.ts +3 -0
- package/src/lib/query.ts +958 -0
- package/src/lib/references.ts +0 -1
- package/src/lib/sql-helpers.ts +146 -0
- package/src/lib/sql.ts +23 -6
- package/src/lib/table.ts +484 -156
- package/src/migrations/node.ts +1 -0
- package/src/migrations.ts +26 -0
- package/src/operators.ts +18 -0
- package/src/sql-helpers.ts +9 -0
package/dist/lib/table.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColumnBuilder } from "./column.js";
|
|
2
2
|
import { inferForeignKey } from "./inflection.js";
|
|
3
3
|
import { normalizeWhereInput } from "./operators.js";
|
|
4
4
|
import { columnMetadataKey, normalizeColumnInput, tableMetadataKey } from "./references.js";
|
|
@@ -30,13 +30,70 @@ export function getTableName(table) {
|
|
|
30
30
|
return table[tableMetadataKey].name;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Returns a table's
|
|
33
|
+
* Returns a table's column builder map.
|
|
34
34
|
* @param table Source table instance.
|
|
35
|
-
* @returns Table
|
|
35
|
+
* @returns Table column builder map.
|
|
36
36
|
*/
|
|
37
37
|
export function getTableColumns(table) {
|
|
38
38
|
return table[tableMetadataKey].columns;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns a table's resolved physical column definitions.
|
|
42
|
+
* @param table Source table instance.
|
|
43
|
+
* @returns Column definition map.
|
|
44
|
+
*/
|
|
45
|
+
export function getTableColumnDefinitions(table) {
|
|
46
|
+
return table[tableMetadataKey].columnDefinitions;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns a table's optional write validator.
|
|
50
|
+
* @param table Source table instance.
|
|
51
|
+
* @returns Validation function or `undefined`.
|
|
52
|
+
*/
|
|
53
|
+
export function getTableValidator(table) {
|
|
54
|
+
return table[tableMetadataKey].validate;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns a table's optional before-write lifecycle callback.
|
|
58
|
+
* @param table Source table instance.
|
|
59
|
+
* @returns Before-write callback or `undefined`.
|
|
60
|
+
*/
|
|
61
|
+
export function getTableBeforeWrite(table) {
|
|
62
|
+
return table[tableMetadataKey].beforeWrite;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns a table's optional after-write lifecycle callback.
|
|
66
|
+
* @param table Source table instance.
|
|
67
|
+
* @returns After-write callback or `undefined`.
|
|
68
|
+
*/
|
|
69
|
+
export function getTableAfterWrite(table) {
|
|
70
|
+
return table[tableMetadataKey].afterWrite;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns a table's optional before-delete lifecycle callback.
|
|
74
|
+
* @param table Source table instance.
|
|
75
|
+
* @returns Before-delete callback or `undefined`.
|
|
76
|
+
*/
|
|
77
|
+
export function getTableBeforeDelete(table) {
|
|
78
|
+
return table[tableMetadataKey].beforeDelete;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns a table's optional after-delete lifecycle callback.
|
|
82
|
+
* @param table Source table instance.
|
|
83
|
+
* @returns After-delete callback or `undefined`.
|
|
84
|
+
*/
|
|
85
|
+
export function getTableAfterDelete(table) {
|
|
86
|
+
return table[tableMetadataKey].afterDelete;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns a table's optional after-read lifecycle callback.
|
|
90
|
+
* The callback receives the current read shape, which may be a projected partial row.
|
|
91
|
+
* @param table Source table instance.
|
|
92
|
+
* @returns After-read callback or `undefined`.
|
|
93
|
+
*/
|
|
94
|
+
export function getTableAfterRead(table) {
|
|
95
|
+
return table[tableMetadataKey].afterRead;
|
|
96
|
+
}
|
|
40
97
|
/**
|
|
41
98
|
* Returns a table's primary key columns.
|
|
42
99
|
* @param table Source table instance.
|
|
@@ -53,71 +110,44 @@ export function getTablePrimaryKey(table) {
|
|
|
53
110
|
export function getTableTimestamps(table) {
|
|
54
111
|
return table[tableMetadataKey].timestamps;
|
|
55
112
|
}
|
|
56
|
-
|
|
113
|
+
const defaultTimestampConfig = {
|
|
57
114
|
createdAt: 'created_at',
|
|
58
115
|
updatedAt: 'updated_at',
|
|
59
116
|
};
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
...issue,
|
|
64
|
-
path: [key, ...issuePath],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function validatePartialRowInput(tableName, columns, value, options) {
|
|
68
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
117
|
+
export function fail(messageOrIssues, path) {
|
|
118
|
+
if (typeof messageOrIssues === 'string') {
|
|
69
119
|
return {
|
|
70
|
-
issues: [{ message:
|
|
120
|
+
issues: [{ message: messageOrIssues, path }],
|
|
71
121
|
};
|
|
72
122
|
}
|
|
73
|
-
let input = value;
|
|
74
|
-
let output = {};
|
|
75
|
-
let issues = [];
|
|
76
|
-
for (let key in input) {
|
|
77
|
-
if (!Object.prototype.hasOwnProperty.call(input, key)) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (!Object.prototype.hasOwnProperty.call(columns, key)) {
|
|
81
|
-
issues.push({
|
|
82
|
-
message: 'Unknown column "' + key + '" for table "' + tableName + '"',
|
|
83
|
-
path: [key],
|
|
84
|
-
});
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
let result = parseSafe(columns[key], input[key], options);
|
|
88
|
-
if (!result.success) {
|
|
89
|
-
issues.push(...result.issues.map((issue) => prefixIssuePath(issue, key)));
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
output[key] = result.value;
|
|
93
|
-
}
|
|
94
|
-
if (issues.length > 0) {
|
|
95
|
-
return { issues };
|
|
96
|
-
}
|
|
97
|
-
return { value: output };
|
|
98
|
-
}
|
|
99
|
-
export function validatePartialRow(table, value, options) {
|
|
100
|
-
let result = validatePartialRowInput(getTableName(table), getTableColumns(table), value, options);
|
|
101
|
-
if ('issues' in result) {
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
123
|
return {
|
|
105
|
-
|
|
124
|
+
issues: [...messageOrIssues],
|
|
106
125
|
};
|
|
107
126
|
}
|
|
108
127
|
/**
|
|
109
128
|
* Creates a table object with symbol-backed metadata and direct column references.
|
|
110
129
|
* @param options Table declaration options.
|
|
111
130
|
* @returns A frozen table object.
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* import { column as c, table } from 'remix/data-table'
|
|
134
|
+
*
|
|
135
|
+
* let users = table({
|
|
136
|
+
* name: 'users',
|
|
137
|
+
* columns: {
|
|
138
|
+
* id: c.integer(),
|
|
139
|
+
* email: c.varchar(255),
|
|
140
|
+
* },
|
|
141
|
+
* primaryKey: 'id',
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
112
144
|
*/
|
|
113
|
-
export function
|
|
145
|
+
export function table(options) {
|
|
114
146
|
let tableName = options.name;
|
|
115
147
|
let columns = options.columns;
|
|
116
|
-
if (Object.prototype.hasOwnProperty.call(columns, '~standard')) {
|
|
117
|
-
throw new Error('Column name "~standard" is reserved for table validation on "' + tableName + '"');
|
|
118
|
-
}
|
|
119
148
|
let resolvedPrimaryKey = normalizePrimaryKey(tableName, columns, options.primaryKey);
|
|
120
149
|
let timestampConfig = normalizeTimestampConfig(options.timestamps);
|
|
150
|
+
let columnDefinitions = resolveTableColumns(tableName, columns);
|
|
121
151
|
let table = Object.create(null);
|
|
122
152
|
Object.defineProperty(table, tableMetadataKey, {
|
|
123
153
|
value: Object.freeze({
|
|
@@ -125,18 +155,13 @@ export function createTable(options) {
|
|
|
125
155
|
columns,
|
|
126
156
|
primaryKey: resolvedPrimaryKey,
|
|
127
157
|
timestamps: timestampConfig,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
version: 1,
|
|
136
|
-
vendor: 'data-table',
|
|
137
|
-
validate(value, parseOptions) {
|
|
138
|
-
return validatePartialRowInput(tableName, columns, value, parseOptions);
|
|
139
|
-
},
|
|
158
|
+
columnDefinitions,
|
|
159
|
+
beforeWrite: options.beforeWrite,
|
|
160
|
+
afterWrite: options.afterWrite,
|
|
161
|
+
beforeDelete: options.beforeDelete,
|
|
162
|
+
afterDelete: options.afterDelete,
|
|
163
|
+
afterRead: options.afterRead,
|
|
164
|
+
validate: options.validate,
|
|
140
165
|
}),
|
|
141
166
|
enumerable: false,
|
|
142
167
|
writable: false,
|
|
@@ -146,8 +171,7 @@ export function createTable(options) {
|
|
|
146
171
|
if (!Object.prototype.hasOwnProperty.call(columns, columnName)) {
|
|
147
172
|
continue;
|
|
148
173
|
}
|
|
149
|
-
let
|
|
150
|
-
let column = createColumnReference(tableName, columnName, schema);
|
|
174
|
+
let column = createColumnReference(tableName, columnName);
|
|
151
175
|
Object.defineProperty(table, columnName, {
|
|
152
176
|
value: column,
|
|
153
177
|
enumerable: true,
|
|
@@ -157,17 +181,34 @@ export function createTable(options) {
|
|
|
157
181
|
}
|
|
158
182
|
return Object.freeze(table);
|
|
159
183
|
}
|
|
160
|
-
function createColumnReference(tableName, columnName
|
|
184
|
+
function createColumnReference(tableName, columnName) {
|
|
161
185
|
return Object.freeze({
|
|
162
186
|
kind: 'column',
|
|
163
187
|
[columnMetadataKey]: Object.freeze({
|
|
164
188
|
tableName,
|
|
165
189
|
columnName,
|
|
166
190
|
qualifiedName: tableName + '.' + columnName,
|
|
167
|
-
schema,
|
|
168
191
|
}),
|
|
169
192
|
});
|
|
170
193
|
}
|
|
194
|
+
function resolveTableColumns(tableName, columns) {
|
|
195
|
+
let columnDefinitions = {};
|
|
196
|
+
for (let columnName in columns) {
|
|
197
|
+
if (!Object.prototype.hasOwnProperty.call(columns, columnName)) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
let column = columns[columnName];
|
|
201
|
+
if (!(column instanceof ColumnBuilder)) {
|
|
202
|
+
throw new Error('Invalid column "' +
|
|
203
|
+
columnName +
|
|
204
|
+
'" for table "' +
|
|
205
|
+
tableName +
|
|
206
|
+
'". Expected a column(...) builder');
|
|
207
|
+
}
|
|
208
|
+
columnDefinitions[columnName] = column.build();
|
|
209
|
+
}
|
|
210
|
+
return Object.freeze(columnDefinitions);
|
|
211
|
+
}
|
|
171
212
|
/**
|
|
172
213
|
* Defines a one-to-many relation from `source` to `target`.
|
|
173
214
|
* @param source Source table.
|
|
@@ -264,33 +305,15 @@ export function hasManyThrough(source, target, relationOptions) {
|
|
|
264
305
|
},
|
|
265
306
|
});
|
|
266
307
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Creates a schema that accepts `Date`, string, and numeric timestamp inputs.
|
|
269
|
-
* @returns Timestamp schema for generated timestamp helpers.
|
|
270
|
-
*/
|
|
271
|
-
export function timestampSchema() {
|
|
272
|
-
return createSchema((value) => {
|
|
273
|
-
if (value instanceof Date) {
|
|
274
|
-
return { value };
|
|
275
|
-
}
|
|
276
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
277
|
-
return { value };
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
issues: [{ message: 'Expected Date, string, or number' }],
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
let defaultTimestampSchema = timestampSchema();
|
|
285
308
|
/**
|
|
286
309
|
* Convenience helper for standard snake_case timestamp columns.
|
|
287
|
-
* @
|
|
288
|
-
* @returns Column schema map for `created_at`/`updated_at`.
|
|
310
|
+
* @returns Column-builder map for `created_at`/`updated_at`.
|
|
289
311
|
*/
|
|
290
|
-
export function timestamps(
|
|
312
|
+
export function timestamps() {
|
|
313
|
+
let timestampColumn = () => new ColumnBuilder({ type: 'timestamp' });
|
|
291
314
|
return {
|
|
292
|
-
created_at:
|
|
293
|
-
updated_at:
|
|
315
|
+
created_at: timestampColumn(),
|
|
316
|
+
updated_at: timestampColumn(),
|
|
294
317
|
};
|
|
295
318
|
}
|
|
296
319
|
/**
|
|
@@ -355,7 +378,7 @@ export function stableSerialize(value) {
|
|
|
355
378
|
function normalizePrimaryKey(tableName, columns, primaryKey) {
|
|
356
379
|
if (primaryKey === undefined) {
|
|
357
380
|
if (!Object.prototype.hasOwnProperty.call(columns, 'id')) {
|
|
358
|
-
throw new Error('Table "' + tableName + '" must
|
|
381
|
+
throw new Error('Table "' + tableName + '" must include an "id" column or an explicit primaryKey');
|
|
359
382
|
}
|
|
360
383
|
return ['id'];
|
|
361
384
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/migrations/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadMigrations } from "../lib/migrations-node.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { AlterTableBuilder, CreateMigrationInput, Migration, MigrationContext, MigrationDescriptor, MigrationDirection, MigrationJournalRow, MigrationSchema, MigrationRegistry, MigrationRunner, MigrationRunnerOptions, MigrationStatus, MigrationStatusEntry, MigrationTransactionMode, MigrateOptions, MigrateResult, KeyColumns, TableInput, } from './lib/migrations.ts';
|
|
2
|
+
export { createMigration } from './lib/migrations.ts';
|
|
3
|
+
export type { ColumnNamespace } from './lib/column.ts';
|
|
4
|
+
export { ColumnBuilder, column } from './lib/column.ts';
|
|
5
|
+
export { createMigrationRegistry } from './lib/migrations/registry.ts';
|
|
6
|
+
export { createMigrationRunner } from './lib/migrations/runner.ts';
|
|
7
|
+
export { parseMigrationFilename } from './lib/migrations/filename.ts';
|
|
8
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createMigration } from "./lib/migrations.js";
|
|
2
|
+
export { ColumnBuilder, column } from "./lib/column.js";
|
|
3
|
+
export { createMigrationRegistry } from "./lib/migrations/registry.js";
|
|
4
|
+
export { createMigrationRunner } from "./lib/migrations/runner.js";
|
|
5
|
+
export { parseMigrationFilename } from "./lib/migrations/filename.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EACL,GAAG,EACH,OAAO,EACP,EAAE,EACF,EAAE,EACF,GAAG,EACH,KAAK,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,EAAE,EACF,GAAG,EACH,EAAE,EACF,SAAS,EACT,OAAO,EACP,EAAE,GACH,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { and, between, eq, gt, gte, ilike, inList, isNull, like, lt, lte, ne, notInList, notNull, or, } from "./lib/operators.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-helpers.d.ts","sourceRoot":"","sources":["../src/sql-helpers.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,aAAa,GACd,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { collectColumns, isDataManipulationOperation, normalizeJoinType, quoteLiteral, quotePath, quoteTableRef, } from "./lib/sql-helpers.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix-run/data-table",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "A typed, relational query toolkit for
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "A typed, relational query toolkit for JavaScript",
|
|
5
5
|
"author": "Michael Jackson <mjijackson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -24,18 +24,31 @@
|
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"default": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./migrations": {
|
|
28
|
+
"types": "./dist/migrations.d.ts",
|
|
29
|
+
"default": "./dist/migrations.js"
|
|
30
|
+
},
|
|
31
|
+
"./migrations/node": {
|
|
32
|
+
"types": "./dist/migrations/node.d.ts",
|
|
33
|
+
"default": "./dist/migrations/node.js"
|
|
34
|
+
},
|
|
35
|
+
"./operators": {
|
|
36
|
+
"types": "./dist/operators.d.ts",
|
|
37
|
+
"default": "./dist/operators.js"
|
|
38
|
+
},
|
|
39
|
+
"./sql-helpers": {
|
|
40
|
+
"types": "./dist/sql-helpers.d.ts",
|
|
41
|
+
"default": "./dist/sql-helpers.js"
|
|
42
|
+
},
|
|
27
43
|
"./package.json": "./package.json"
|
|
28
44
|
},
|
|
29
45
|
"devDependencies": {
|
|
30
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
31
46
|
"@types/node": "^24.6.0",
|
|
32
47
|
"@typescript/native-preview": "7.0.0-dev.20251125.1",
|
|
33
|
-
"
|
|
34
|
-
"@remix-run/
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@remix-run/data-schema": "^0.1.0"
|
|
48
|
+
"@remix-run/assert": "0.2.0",
|
|
49
|
+
"@remix-run/test": "0.3.0"
|
|
38
50
|
},
|
|
51
|
+
"dependencies": {},
|
|
39
52
|
"keywords": [
|
|
40
53
|
"remix",
|
|
41
54
|
"orm",
|
|
@@ -47,8 +60,9 @@
|
|
|
47
60
|
"scripts": {
|
|
48
61
|
"build": "tsgo -p tsconfig.build.json",
|
|
49
62
|
"clean": "git clean -fdX",
|
|
50
|
-
"test": "
|
|
51
|
-
"test:
|
|
63
|
+
"test": "remix-test",
|
|
64
|
+
"test:bun": "bun x --bun remix-test",
|
|
65
|
+
"test:coverage": "remix-test --coverage",
|
|
52
66
|
"typecheck": "tsgo --noEmit"
|
|
53
67
|
}
|
|
54
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,66 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
AdapterCapabilityOverrides,
|
|
3
3
|
AdapterCapabilities,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
DataManipulationRequest,
|
|
5
|
+
DataMigrationRequest,
|
|
6
|
+
AddCheckChange,
|
|
7
|
+
AddCheckOperation,
|
|
8
|
+
AddColumnChange,
|
|
9
|
+
AddForeignKeyChange,
|
|
10
|
+
AddForeignKeyOperation,
|
|
11
|
+
AddPrimaryKeyChange,
|
|
12
|
+
AddUniqueChange,
|
|
13
|
+
AlterTableChange,
|
|
14
|
+
AlterTableOperation,
|
|
15
|
+
ChangeColumnChange,
|
|
16
|
+
CheckConstraint,
|
|
17
|
+
ColumnCheck,
|
|
18
|
+
ColumnComputed,
|
|
19
|
+
ColumnDefault,
|
|
20
|
+
ColumnDefinition,
|
|
21
|
+
ColumnTypeName,
|
|
22
|
+
CountOperation,
|
|
23
|
+
CreateIndexOperation,
|
|
24
|
+
CreateTableOperation,
|
|
25
|
+
DataMigrationResult,
|
|
26
|
+
DataMigrationOperation,
|
|
27
|
+
DataManipulationResult,
|
|
28
|
+
DataManipulationOperation,
|
|
29
|
+
DeleteOperation,
|
|
7
30
|
DatabaseAdapter,
|
|
31
|
+
DropCheckChange,
|
|
32
|
+
DropCheckOperation,
|
|
33
|
+
DropColumnChange,
|
|
34
|
+
DropForeignKeyChange,
|
|
35
|
+
DropForeignKeyOperation,
|
|
36
|
+
DropIndexOperation,
|
|
37
|
+
DropPrimaryKeyChange,
|
|
38
|
+
DropTableOperation,
|
|
39
|
+
DropUniqueChange,
|
|
40
|
+
ExistsOperation,
|
|
41
|
+
ForeignKeyAction,
|
|
42
|
+
ForeignKeyConstraint,
|
|
43
|
+
IndexDefinition,
|
|
44
|
+
IndexMethod,
|
|
45
|
+
InsertManyOperation,
|
|
46
|
+
InsertOperation,
|
|
47
|
+
JoinClause,
|
|
48
|
+
JoinType,
|
|
49
|
+
PrimaryKeyConstraint,
|
|
50
|
+
RawOperation,
|
|
51
|
+
RenameColumnChange,
|
|
52
|
+
RenameIndexOperation,
|
|
53
|
+
RenameTableOperation,
|
|
54
|
+
ReturningSelection,
|
|
55
|
+
SelectColumn,
|
|
56
|
+
SelectOperation,
|
|
57
|
+
SetTableCommentChange,
|
|
58
|
+
TableRef,
|
|
8
59
|
TransactionOptions,
|
|
9
60
|
TransactionToken,
|
|
61
|
+
UniqueConstraint,
|
|
62
|
+
UpdateOperation,
|
|
63
|
+
UpsertOperation,
|
|
10
64
|
} from './lib/adapter.ts'
|
|
11
65
|
|
|
12
66
|
export {
|
|
@@ -24,7 +78,6 @@ export type {
|
|
|
24
78
|
BelongsToOptions,
|
|
25
79
|
ColumnReference,
|
|
26
80
|
ColumnReferenceForQualifiedName,
|
|
27
|
-
ColumnSchemas,
|
|
28
81
|
HasManyOptions,
|
|
29
82
|
HasManyThroughOptions,
|
|
30
83
|
HasOneOptions,
|
|
@@ -37,33 +90,64 @@ export type {
|
|
|
37
90
|
RelationKind,
|
|
38
91
|
RelationMapForTable,
|
|
39
92
|
Table,
|
|
93
|
+
TableAfterDelete,
|
|
94
|
+
TableAfterDeleteContext,
|
|
95
|
+
TableAfterRead,
|
|
96
|
+
TableAfterReadContext,
|
|
97
|
+
TableAfterReadResult,
|
|
98
|
+
TableAfterWrite,
|
|
99
|
+
TableAfterWriteContext,
|
|
100
|
+
TableBeforeDelete,
|
|
101
|
+
TableBeforeDeleteContext,
|
|
102
|
+
TableBeforeDeleteResult,
|
|
103
|
+
TableBeforeWrite,
|
|
104
|
+
TableBeforeWriteContext,
|
|
105
|
+
TableBeforeWriteResult,
|
|
40
106
|
TableColumnInput,
|
|
41
107
|
TableColumnName,
|
|
42
108
|
TableColumns,
|
|
109
|
+
TableLifecycleOperation,
|
|
43
110
|
TableName,
|
|
44
111
|
TablePrimaryKey,
|
|
45
112
|
TableReference,
|
|
46
113
|
TableRow,
|
|
47
114
|
TableRowWith,
|
|
115
|
+
TableColumnsDefinition,
|
|
116
|
+
TableValidate,
|
|
117
|
+
TableValidationContext,
|
|
118
|
+
TableWriteOperation,
|
|
119
|
+
TableValidationOperation,
|
|
120
|
+
TableValidationResult,
|
|
48
121
|
TimestampConfig,
|
|
49
122
|
TimestampOptions,
|
|
123
|
+
ValidationFailure,
|
|
124
|
+
ValidationIssue,
|
|
50
125
|
} from './lib/table.ts'
|
|
51
126
|
export {
|
|
52
127
|
belongsTo,
|
|
53
128
|
columnMetadataKey,
|
|
54
|
-
|
|
129
|
+
fail,
|
|
55
130
|
getTableColumns,
|
|
131
|
+
getTableColumnDefinitions,
|
|
132
|
+
getTableBeforeDelete,
|
|
133
|
+
getTableBeforeWrite,
|
|
134
|
+
getTableAfterDelete,
|
|
135
|
+
getTableAfterRead,
|
|
136
|
+
getTableAfterWrite,
|
|
56
137
|
getTableName,
|
|
57
138
|
getTablePrimaryKey,
|
|
58
139
|
getTableReference,
|
|
59
140
|
getTableTimestamps,
|
|
141
|
+
getTableValidator,
|
|
60
142
|
hasMany,
|
|
61
143
|
hasManyThrough,
|
|
62
144
|
hasOne,
|
|
145
|
+
table,
|
|
63
146
|
tableMetadataKey,
|
|
64
|
-
timestampSchema,
|
|
65
147
|
timestamps,
|
|
66
148
|
} from './lib/table.ts'
|
|
149
|
+
export type { ColumnNamespace } from './lib/column.ts'
|
|
150
|
+
export { ColumnBuilder, column } from './lib/column.ts'
|
|
67
151
|
|
|
68
152
|
export type { Predicate, WhereInput, WhereObject } from './lib/operators.ts'
|
|
69
153
|
export {
|
|
@@ -93,16 +177,13 @@ export type {
|
|
|
93
177
|
CreateManyRowsOptions,
|
|
94
178
|
CreateResultOptions,
|
|
95
179
|
CreateRowOptions,
|
|
96
|
-
Database,
|
|
97
180
|
DeleteManyOptions,
|
|
98
181
|
FindManyOptions,
|
|
99
182
|
FindOneOptions,
|
|
100
183
|
OrderByInput,
|
|
101
184
|
OrderByTuple,
|
|
102
|
-
QueryBuilderFor,
|
|
103
185
|
QueryColumnTypesForTable,
|
|
104
186
|
QueryForTable,
|
|
105
|
-
QueryMethod,
|
|
106
187
|
QueryTableInput,
|
|
107
188
|
SingleTableColumn,
|
|
108
189
|
SingleTableWhere,
|
|
@@ -112,4 +193,6 @@ export type {
|
|
|
112
193
|
WriteRowResult,
|
|
113
194
|
WriteRowsResult,
|
|
114
195
|
} from './lib/database.ts'
|
|
115
|
-
export { createDatabase,
|
|
196
|
+
export { createDatabase, Database } from './lib/database.ts'
|
|
197
|
+
export type { AnyQuery } from './lib/query.ts'
|
|
198
|
+
export { Query, query } from './lib/query.ts'
|