@remix-run/data-table 0.0.0 → 0.1.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +298 -2
  3. package/dist/index.d.ts +11 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +5 -0
  6. package/dist/lib/adapter.d.ts +180 -0
  7. package/dist/lib/adapter.d.ts.map +1 -0
  8. package/dist/lib/adapter.js +1 -0
  9. package/dist/lib/database.d.ts +361 -0
  10. package/dist/lib/database.d.ts.map +1 -0
  11. package/dist/lib/database.js +1368 -0
  12. package/dist/lib/errors.d.ts +50 -0
  13. package/dist/lib/errors.d.ts.map +1 -0
  14. package/dist/lib/errors.js +67 -0
  15. package/dist/lib/inflection.d.ts +3 -0
  16. package/dist/lib/inflection.d.ts.map +1 -0
  17. package/dist/lib/inflection.js +56 -0
  18. package/dist/lib/operators.d.ts +151 -0
  19. package/dist/lib/operators.d.ts.map +1 -0
  20. package/dist/lib/operators.js +218 -0
  21. package/dist/lib/references.d.ts +42 -0
  22. package/dist/lib/references.d.ts.map +1 -0
  23. package/dist/lib/references.js +33 -0
  24. package/dist/lib/sql.d.ts +28 -0
  25. package/dist/lib/sql.d.ts.map +1 -0
  26. package/dist/lib/sql.js +51 -0
  27. package/dist/lib/table.d.ts +254 -0
  28. package/dist/lib/table.d.ts.map +1 -0
  29. package/dist/lib/table.js +496 -0
  30. package/dist/lib/types.d.ts +4 -0
  31. package/dist/lib/types.d.ts.map +1 -0
  32. package/dist/lib/types.js +1 -0
  33. package/package.json +41 -7
  34. package/src/index.ts +115 -0
  35. package/src/lib/adapter.ts +209 -0
  36. package/src/lib/database.ts +2458 -0
  37. package/src/lib/errors.ts +109 -0
  38. package/src/lib/inflection.ts +69 -0
  39. package/src/lib/operators.ts +433 -0
  40. package/src/lib/references.ts +79 -0
  41. package/src/lib/sql.ts +67 -0
  42. package/src/lib/table.ts +981 -0
  43. package/src/lib/types.ts +3 -0
@@ -0,0 +1,496 @@
1
+ import { createSchema, parseSafe } from '@remix-run/data-schema';
2
+ import { inferForeignKey } from "./inflection.js";
3
+ import { normalizeWhereInput } from "./operators.js";
4
+ import { columnMetadataKey, normalizeColumnInput, tableMetadataKey } from "./references.js";
5
+ /**
6
+ * Symbol key used to store non-enumerable table metadata.
7
+ */
8
+ export { columnMetadataKey, tableMetadataKey } from "./references.js";
9
+ /**
10
+ * Creates a plain table reference snapshot from a table instance.
11
+ * @param table Source table instance.
12
+ * @returns Table metadata snapshot.
13
+ */
14
+ export function getTableReference(table) {
15
+ let metadata = table[tableMetadataKey];
16
+ return {
17
+ kind: 'table',
18
+ name: metadata.name,
19
+ columns: metadata.columns,
20
+ primaryKey: metadata.primaryKey,
21
+ timestamps: metadata.timestamps,
22
+ };
23
+ }
24
+ /**
25
+ * Returns a table's SQL name.
26
+ * @param table Source table instance.
27
+ * @returns Table SQL name.
28
+ */
29
+ export function getTableName(table) {
30
+ return table[tableMetadataKey].name;
31
+ }
32
+ /**
33
+ * Returns a table's schema map.
34
+ * @param table Source table instance.
35
+ * @returns Table schema map.
36
+ */
37
+ export function getTableColumns(table) {
38
+ return table[tableMetadataKey].columns;
39
+ }
40
+ /**
41
+ * Returns a table's primary key columns.
42
+ * @param table Source table instance.
43
+ * @returns Primary key columns.
44
+ */
45
+ export function getTablePrimaryKey(table) {
46
+ return table[tableMetadataKey].primaryKey;
47
+ }
48
+ /**
49
+ * Returns a table's resolved timestamp configuration.
50
+ * @param table Source table instance.
51
+ * @returns Timestamp configuration or `null`.
52
+ */
53
+ export function getTableTimestamps(table) {
54
+ return table[tableMetadataKey].timestamps;
55
+ }
56
+ let defaultTimestampConfig = {
57
+ createdAt: 'created_at',
58
+ updatedAt: 'updated_at',
59
+ };
60
+ function prefixIssuePath(issue, key) {
61
+ let issuePath = issue.path ?? [];
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)) {
69
+ return {
70
+ issues: [{ message: 'Expected object' }],
71
+ };
72
+ }
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
+ return {
105
+ value: result.value,
106
+ };
107
+ }
108
+ /**
109
+ * Creates a table object with symbol-backed metadata and direct column references.
110
+ * @param options Table declaration options.
111
+ * @returns A frozen table object.
112
+ */
113
+ export function createTable(options) {
114
+ let tableName = options.name;
115
+ 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
+ let resolvedPrimaryKey = normalizePrimaryKey(tableName, columns, options.primaryKey);
120
+ let timestampConfig = normalizeTimestampConfig(options.timestamps);
121
+ let table = Object.create(null);
122
+ Object.defineProperty(table, tableMetadataKey, {
123
+ value: Object.freeze({
124
+ name: tableName,
125
+ columns,
126
+ primaryKey: resolvedPrimaryKey,
127
+ timestamps: timestampConfig,
128
+ }),
129
+ enumerable: false,
130
+ writable: false,
131
+ configurable: false,
132
+ });
133
+ Object.defineProperty(table, '~standard', {
134
+ value: Object.freeze({
135
+ version: 1,
136
+ vendor: 'data-table',
137
+ validate(value, parseOptions) {
138
+ return validatePartialRowInput(tableName, columns, value, parseOptions);
139
+ },
140
+ }),
141
+ enumerable: false,
142
+ writable: false,
143
+ configurable: false,
144
+ });
145
+ for (let columnName in columns) {
146
+ if (!Object.prototype.hasOwnProperty.call(columns, columnName)) {
147
+ continue;
148
+ }
149
+ let schema = columns[columnName];
150
+ let column = createColumnReference(tableName, columnName, schema);
151
+ Object.defineProperty(table, columnName, {
152
+ value: column,
153
+ enumerable: true,
154
+ writable: false,
155
+ configurable: false,
156
+ });
157
+ }
158
+ return Object.freeze(table);
159
+ }
160
+ function createColumnReference(tableName, columnName, schema) {
161
+ return Object.freeze({
162
+ kind: 'column',
163
+ [columnMetadataKey]: Object.freeze({
164
+ tableName,
165
+ columnName,
166
+ qualifiedName: tableName + '.' + columnName,
167
+ schema,
168
+ }),
169
+ });
170
+ }
171
+ /**
172
+ * Defines a one-to-many relation from `source` to `target`.
173
+ * @param source Source table.
174
+ * @param target Target table.
175
+ * @param relationOptions Relation key configuration.
176
+ * @returns A relation descriptor.
177
+ */
178
+ export function hasMany(source, target, relationOptions) {
179
+ let sourceKey = normalizeKeySelector(source, relationOptions?.targetKey, 'targetKey', getTablePrimaryKey(source));
180
+ let targetKey = normalizeKeySelector(target, relationOptions?.foreignKey, 'foreignKey', [
181
+ inferForeignKey(getTableName(source)),
182
+ ]);
183
+ assertKeyLengths(getTableName(source), getTableName(target), sourceKey, targetKey);
184
+ return createRelation({
185
+ relationKind: 'hasMany',
186
+ cardinality: 'many',
187
+ sourceTable: source,
188
+ targetTable: target,
189
+ sourceKey,
190
+ targetKey,
191
+ });
192
+ }
193
+ /**
194
+ * Defines a one-to-one relation from `source` to `target` where the foreign key lives on `target`.
195
+ * @param source Source table.
196
+ * @param target Target table.
197
+ * @param relationOptions Relation key configuration.
198
+ * @returns A relation descriptor.
199
+ */
200
+ export function hasOne(source, target, relationOptions) {
201
+ let sourceKey = normalizeKeySelector(source, relationOptions?.targetKey, 'targetKey', getTablePrimaryKey(source));
202
+ let targetKey = normalizeKeySelector(target, relationOptions?.foreignKey, 'foreignKey', [
203
+ inferForeignKey(getTableName(source)),
204
+ ]);
205
+ assertKeyLengths(getTableName(source), getTableName(target), sourceKey, targetKey);
206
+ return createRelation({
207
+ relationKind: 'hasOne',
208
+ cardinality: 'one',
209
+ sourceTable: source,
210
+ targetTable: target,
211
+ sourceKey,
212
+ targetKey,
213
+ });
214
+ }
215
+ /**
216
+ * Defines a one-to-one relation from `source` to `target`.
217
+ * @param source Source table.
218
+ * @param target Target table.
219
+ * @param relationOptions Relation key configuration.
220
+ * @returns A relation descriptor.
221
+ */
222
+ export function belongsTo(source, target, relationOptions) {
223
+ let sourceKey = normalizeKeySelector(source, relationOptions?.foreignKey, 'foreignKey', [
224
+ inferForeignKey(getTableName(target)),
225
+ ]);
226
+ let targetKey = normalizeKeySelector(target, relationOptions?.targetKey, 'targetKey', getTablePrimaryKey(target));
227
+ assertKeyLengths(getTableName(source), getTableName(target), sourceKey, targetKey);
228
+ return createRelation({
229
+ relationKind: 'belongsTo',
230
+ cardinality: 'one',
231
+ sourceTable: source,
232
+ targetTable: target,
233
+ sourceKey,
234
+ targetKey,
235
+ });
236
+ }
237
+ /**
238
+ * Defines a one-to-many relation from `source` to `target` through an intermediate relation.
239
+ * @param source Source table.
240
+ * @param target Target table.
241
+ * @param relationOptions Through relation configuration.
242
+ * @returns A relation descriptor.
243
+ */
244
+ export function hasManyThrough(source, target, relationOptions) {
245
+ let throughRelation = relationOptions.through;
246
+ if (throughRelation.sourceTable !== source) {
247
+ throw new Error('hasManyThrough expects a through relation whose source table matches ' +
248
+ getTableName(source));
249
+ }
250
+ let throughTargetKey = normalizeKeysForTable(throughRelation.targetTable, relationOptions.throughTargetKey, 'throughTargetKey', getTablePrimaryKey(throughRelation.targetTable));
251
+ let throughForeignKey = normalizeKeySelector(target, relationOptions.throughForeignKey, 'throughForeignKey', [inferForeignKey(getTableName(throughRelation.targetTable))]);
252
+ assertKeyLengths(getTableName(throughRelation.targetTable), getTableName(target), throughTargetKey, throughForeignKey);
253
+ return createRelation({
254
+ relationKind: 'hasManyThrough',
255
+ cardinality: 'many',
256
+ sourceTable: source,
257
+ targetTable: target,
258
+ sourceKey: [...throughRelation.sourceKey],
259
+ targetKey: [...throughRelation.targetKey],
260
+ through: {
261
+ relation: throughRelation,
262
+ throughSourceKey: throughTargetKey,
263
+ throughTargetKey: throughForeignKey,
264
+ },
265
+ });
266
+ }
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
+ /**
286
+ * Convenience helper for standard snake_case timestamp columns.
287
+ * @param schema Schema used for both timestamp columns.
288
+ * @returns Column schema map for `created_at`/`updated_at`.
289
+ */
290
+ export function timestamps(schema = defaultTimestampSchema) {
291
+ return {
292
+ created_at: schema,
293
+ updated_at: schema,
294
+ };
295
+ }
296
+ /**
297
+ * Normalizes a primary-key input into an object keyed by primary-key columns.
298
+ * @param table Source table.
299
+ * @param value Primary-key input value.
300
+ * @returns Primary-key object.
301
+ */
302
+ export function getPrimaryKeyObject(table, value) {
303
+ let keys = getTablePrimaryKey(table);
304
+ if (keys.length === 1 && (typeof value !== 'object' || value === null || Array.isArray(value))) {
305
+ let key = keys[0];
306
+ return { [key]: value };
307
+ }
308
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
309
+ throw new Error('Composite primary keys require an object value');
310
+ }
311
+ let objectValue = value;
312
+ let output = {};
313
+ for (let key of keys) {
314
+ if (!(key in objectValue)) {
315
+ throw new Error('Missing key "' + key + '" for primary key lookup on "' + getTableName(table) + '"');
316
+ }
317
+ ;
318
+ output[key] = objectValue[key];
319
+ }
320
+ return output;
321
+ }
322
+ /**
323
+ * Builds a stable key for a row tuple.
324
+ * @param row Source row.
325
+ * @param columns Columns included in the tuple.
326
+ * @returns Stable tuple key.
327
+ */
328
+ export function getCompositeKey(row, columns) {
329
+ let values = columns.map((column) => stableSerialize(row[column]));
330
+ return values.join('::');
331
+ }
332
+ /**
333
+ * Serializes values into stable string representations for key generation.
334
+ * @param value Value to serialize.
335
+ * @returns Stable serialized value.
336
+ */
337
+ export function stableSerialize(value) {
338
+ if (value === null) {
339
+ return 'null';
340
+ }
341
+ if (value === undefined) {
342
+ return 'undefined';
343
+ }
344
+ if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
345
+ return String(value);
346
+ }
347
+ if (typeof value === 'string') {
348
+ return JSON.stringify(value);
349
+ }
350
+ if (value instanceof Date) {
351
+ return 'date:' + value.toISOString();
352
+ }
353
+ return JSON.stringify(value);
354
+ }
355
+ function normalizePrimaryKey(tableName, columns, primaryKey) {
356
+ if (primaryKey === undefined) {
357
+ if (!Object.prototype.hasOwnProperty.call(columns, 'id')) {
358
+ throw new Error('Table "' + tableName + '" must define an "id" column or an explicit primaryKey');
359
+ }
360
+ return ['id'];
361
+ }
362
+ let keys = Array.isArray(primaryKey) ? [...primaryKey] : [primaryKey];
363
+ if (keys.length === 0) {
364
+ throw new Error('Table "' + tableName + '" primaryKey must contain at least one column');
365
+ }
366
+ for (let key of keys) {
367
+ if (!Object.prototype.hasOwnProperty.call(columns, key)) {
368
+ throw new Error('Table "' + tableName + '" primaryKey column "' + key + '" does not exist');
369
+ }
370
+ }
371
+ return keys;
372
+ }
373
+ function normalizeKeySelector(table, selector, optionName, defaultValue) {
374
+ return normalizeKeysForTable(table, selector, optionName, defaultValue);
375
+ }
376
+ function normalizeKeysForTable(table, selector, optionName, defaultValue) {
377
+ if (selector === undefined) {
378
+ return [...defaultValue];
379
+ }
380
+ let keys = Array.isArray(selector) ? [...selector] : [selector];
381
+ if (keys.length === 0) {
382
+ throw new Error('Option "' + optionName + '" for table "' + getTableName(table) + '" must not be empty');
383
+ }
384
+ let columns = getTableColumns(table);
385
+ for (let key of keys) {
386
+ if (!Object.prototype.hasOwnProperty.call(columns, key)) {
387
+ throw new Error('Unknown column "' +
388
+ key +
389
+ '" in option "' +
390
+ optionName +
391
+ '" for table "' +
392
+ getTableName(table) +
393
+ '"');
394
+ }
395
+ }
396
+ return keys;
397
+ }
398
+ function normalizeTimestampConfig(options) {
399
+ if (!options) {
400
+ return null;
401
+ }
402
+ if (options === true) {
403
+ return { ...defaultTimestampConfig };
404
+ }
405
+ return {
406
+ createdAt: options.createdAt ?? defaultTimestampConfig.createdAt,
407
+ updatedAt: options.updatedAt ?? defaultTimestampConfig.updatedAt,
408
+ };
409
+ }
410
+ function assertKeyLengths(sourceTableName, targetTableName, sourceKey, targetKey) {
411
+ if (sourceKey.length !== targetKey.length) {
412
+ throw new Error('Relation key mismatch between "' +
413
+ sourceTableName +
414
+ '" (' +
415
+ sourceKey.join(', ') +
416
+ ') and "' +
417
+ targetTableName +
418
+ '" (' +
419
+ targetKey.join(', ') +
420
+ ')');
421
+ }
422
+ }
423
+ function createRelation(options) {
424
+ let baseModifiers = {
425
+ where: options.modifiers?.where ? [...options.modifiers.where] : [],
426
+ orderBy: options.modifiers?.orderBy ? [...options.modifiers.orderBy] : [],
427
+ limit: options.modifiers?.limit,
428
+ offset: options.modifiers?.offset,
429
+ with: options.modifiers?.with ? { ...options.modifiers.with } : {},
430
+ };
431
+ let relation = {
432
+ kind: 'relation',
433
+ relationKind: options.relationKind,
434
+ sourceTable: options.sourceTable,
435
+ targetTable: options.targetTable,
436
+ cardinality: options.cardinality,
437
+ sourceKey: [...options.sourceKey],
438
+ targetKey: [...options.targetKey],
439
+ through: options.through,
440
+ modifiers: baseModifiers,
441
+ where(input) {
442
+ let predicate = normalizeWhereInput(input);
443
+ return cloneRelation(relation, {
444
+ where: [...relation.modifiers.where, predicate],
445
+ });
446
+ },
447
+ orderBy(column, direction = 'asc') {
448
+ return cloneRelation(relation, {
449
+ orderBy: [
450
+ ...relation.modifiers.orderBy,
451
+ {
452
+ column: normalizeColumnInput(column),
453
+ direction,
454
+ },
455
+ ],
456
+ });
457
+ },
458
+ limit(value) {
459
+ return cloneRelation(relation, {
460
+ limit: value,
461
+ });
462
+ },
463
+ offset(value) {
464
+ return cloneRelation(relation, {
465
+ offset: value,
466
+ });
467
+ },
468
+ with(relations) {
469
+ return cloneRelation(relation, {
470
+ with: {
471
+ ...relation.modifiers.with,
472
+ ...relations,
473
+ },
474
+ });
475
+ },
476
+ };
477
+ return relation;
478
+ }
479
+ function cloneRelation(relation, patch) {
480
+ return createRelation({
481
+ relationKind: relation.relationKind,
482
+ cardinality: relation.cardinality,
483
+ sourceTable: relation.sourceTable,
484
+ targetTable: relation.targetTable,
485
+ sourceKey: relation.sourceKey,
486
+ targetKey: relation.targetKey,
487
+ through: relation.through,
488
+ modifiers: {
489
+ where: patch.where ?? relation.modifiers.where,
490
+ orderBy: patch.orderBy ?? relation.modifiers.orderBy,
491
+ limit: patch.limit ?? relation.modifiers.limit,
492
+ offset: patch.offset ?? relation.modifiers.offset,
493
+ with: patch.with ?? relation.modifiers.with,
494
+ },
495
+ });
496
+ }
@@ -0,0 +1,4 @@
1
+ export type Pretty<value> = {
2
+ [key in keyof value]: value[key];
3
+ } & {};
4
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,KAAK,IAAI;KACzB,GAAG,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;CACjC,GAAG,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@remix-run/data-table",
3
- "version": "0.0.0",
4
- "private": false,
5
- "description": "Placeholder package for future Remix data-table APIs",
3
+ "version": "0.1.0",
4
+ "description": "A typed, relational query toolkit for Remix",
5
+ "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -10,11 +10,45 @@
10
10
  "directory": "packages/data-table"
11
11
  },
12
12
  "homepage": "https://github.com/remix-run/remix/tree/main/packages/data-table#readme",
13
+ "files": [
14
+ "LICENSE",
15
+ "README.md",
16
+ "dist",
17
+ "src",
18
+ "!src/**/*.test.ts"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "devDependencies": {
30
+ "@types/better-sqlite3": "^7.6.13",
31
+ "@types/node": "^24.6.0",
32
+ "@typescript/native-preview": "7.0.0-dev.20251125.1",
33
+ "better-sqlite3": "^12.4.1",
34
+ "@remix-run/data-schema": "0.1.0"
35
+ },
36
+ "dependencies": {
37
+ "@remix-run/data-schema": "^0.1.0"
38
+ },
13
39
  "keywords": [
14
40
  "remix",
15
- "placeholder"
41
+ "orm",
42
+ "sql",
43
+ "database",
44
+ "query-builder",
45
+ "relational"
16
46
  ],
17
- "publishConfig": {
18
- "access": "public"
47
+ "scripts": {
48
+ "build": "tsgo -p tsconfig.build.json",
49
+ "clean": "git clean -fdX",
50
+ "test": "node --disable-warning=ExperimentalWarning --test",
51
+ "test:coverage": "node --disable-warning=ExperimentalWarning --experimental-test-coverage --test-coverage-include='src/lib/operators.ts' --test-coverage-include='src/lib/references.ts' --test-coverage-include='src/lib/inflection.ts' --test-coverage-include='src/lib/sql.ts' --test-coverage-include='src/lib/errors.ts' --test-coverage-lines=90 --test-coverage-branches=90 --test-coverage-functions=90 --test ./src/lib/operators.test.ts ./src/lib/references.test.ts ./src/lib/inflection.test.ts ./src/lib/sql.test.ts ./src/lib/errors.test.ts",
52
+ "typecheck": "tsgo --noEmit"
19
53
  }
20
- }
54
+ }
package/src/index.ts ADDED
@@ -0,0 +1,115 @@
1
+ export type {
2
+ AdapterCapabilityOverrides,
3
+ AdapterCapabilities,
4
+ AdapterExecuteRequest,
5
+ AdapterResult,
6
+ AdapterStatement,
7
+ DatabaseAdapter,
8
+ TransactionOptions,
9
+ TransactionToken,
10
+ } from './lib/adapter.ts'
11
+
12
+ export {
13
+ DataTableAdapterError,
14
+ DataTableConstraintError,
15
+ DataTableError,
16
+ DataTableQueryError,
17
+ DataTableValidationError,
18
+ } from './lib/errors.ts'
19
+
20
+ export type {
21
+ AnyRelation,
22
+ AnyColumn,
23
+ AnyTable,
24
+ BelongsToOptions,
25
+ ColumnReference,
26
+ ColumnReferenceForQualifiedName,
27
+ ColumnSchemas,
28
+ HasManyOptions,
29
+ HasManyThroughOptions,
30
+ HasOneOptions,
31
+ KeySelector,
32
+ OrderByClause,
33
+ OrderDirection,
34
+ PrimaryKeyInput,
35
+ Relation,
36
+ RelationCardinality,
37
+ RelationKind,
38
+ RelationMapForTable,
39
+ Table,
40
+ TableColumnInput,
41
+ TableColumnName,
42
+ TableColumns,
43
+ TableName,
44
+ TablePrimaryKey,
45
+ TableReference,
46
+ TableRow,
47
+ TableRowWith,
48
+ TimestampConfig,
49
+ TimestampOptions,
50
+ } from './lib/table.ts'
51
+ export {
52
+ belongsTo,
53
+ columnMetadataKey,
54
+ createTable,
55
+ getTableColumns,
56
+ getTableName,
57
+ getTablePrimaryKey,
58
+ getTableReference,
59
+ getTableTimestamps,
60
+ hasMany,
61
+ hasManyThrough,
62
+ hasOne,
63
+ tableMetadataKey,
64
+ timestampSchema,
65
+ timestamps,
66
+ } from './lib/table.ts'
67
+
68
+ export type { Predicate, WhereInput, WhereObject } from './lib/operators.ts'
69
+ export {
70
+ and,
71
+ between,
72
+ eq,
73
+ gt,
74
+ gte,
75
+ ilike,
76
+ inList,
77
+ isNull,
78
+ like,
79
+ lt,
80
+ lte,
81
+ ne,
82
+ notInList,
83
+ notNull,
84
+ or,
85
+ } from './lib/operators.ts'
86
+
87
+ export type { SqlStatement } from './lib/sql.ts'
88
+ export { rawSql, sql } from './lib/sql.ts'
89
+
90
+ export type {
91
+ CountOptions,
92
+ CreateManyResultOptions,
93
+ CreateManyRowsOptions,
94
+ CreateResultOptions,
95
+ CreateRowOptions,
96
+ Database,
97
+ DeleteManyOptions,
98
+ FindManyOptions,
99
+ FindOneOptions,
100
+ OrderByInput,
101
+ OrderByTuple,
102
+ QueryBuilderFor,
103
+ QueryColumnTypesForTable,
104
+ QueryForTable,
105
+ QueryMethod,
106
+ QueryTableInput,
107
+ SingleTableColumn,
108
+ SingleTableWhere,
109
+ UpdateManyOptions,
110
+ UpdateOptions,
111
+ WriteResult,
112
+ WriteRowResult,
113
+ WriteRowsResult,
114
+ } from './lib/database.ts'
115
+ export { createDatabase, QueryBuilder } from './lib/database.ts'