@drzl/validation-core 3.14.0 → 3.15.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 +17 -0
- package/dist/index.cjs +113 -84519
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +6 -4
- package/package.json +11 -3
- package/dist/acorn-XYPTJ6WH.js +0 -3181
- package/dist/angular-YPOYMZ5Z.js +0 -3629
- package/dist/babel-3Y2WL4BG.js +0 -7335
- package/dist/chunk-ZZGILH5A.js +0 -24
- package/dist/estree-PS47G6OA.js +0 -4955
- package/dist/flow-7NIIFLZC.js +0 -4998
- package/dist/glimmer-HA3GA4CF.js +0 -2908
- package/dist/graphql-3AZLP5TQ.js +0 -1289
- package/dist/html-WHLWODCM.js +0 -3218
- package/dist/markdown-Q4JIPTFK.js +0 -6803
- package/dist/meriyah-PDYHQKRL.js +0 -2737
- package/dist/postcss-66ZEKHWQ.js +0 -5239
- package/dist/prettier-LT6G5PW7.js +0 -20062
- package/dist/typescript-Z6ME4ZZC.js +0 -13435
- package/dist/yaml-QEX7HYMI.js +0 -4833
package/dist/index.d.cts
CHANGED
|
@@ -475,14 +475,47 @@ declare const COLUMN_FORMATS: Record<string, string>;
|
|
|
475
475
|
* Refusing a user's emoji is the failure mode this avoids, and it is the same rule applied
|
|
476
476
|
* everywhere else here: never reject what the database accepts.
|
|
477
477
|
*
|
|
478
|
-
* `@sinclair/typebox` and ArkType cannot
|
|
479
|
-
*
|
|
478
|
+
* All four generators count code points. `@sinclair/typebox` and ArkType cannot say it in their
|
|
479
|
+
* declarative forms, so neither uses `maxLength` or `string <= n`: TypeBox intersects a registered
|
|
480
|
+
* kind onto the field and ArkType puts a Type carrying a narrow there. Both cost something,
|
|
481
|
+
* TypeBox's cap no longer serialising into a JSON Schema, and emitting a number that means a
|
|
482
|
+
* different measurement is not a better trade.
|
|
483
|
+
*
|
|
484
|
+
* MySQL's TEXT family is a byte budget rather than a character count, carried separately as
|
|
485
|
+
* `maxBytes`. Two measurements on string columns in the same database, verified against a real
|
|
486
|
+
* MySQL 8 on utf8mb4: `varchar(10)` takes ten emoji, `tinytext` takes 63 of them and refuses 64.
|
|
480
487
|
*/
|
|
481
488
|
declare const CODEPOINT_LENGTH = "[...v].length";
|
|
482
489
|
declare function isIntegerColumn(c: Column): boolean;
|
|
483
490
|
declare function insertColumns(table: Table): Column[];
|
|
491
|
+
/**
|
|
492
|
+
* Which columns belong in an update schema.
|
|
493
|
+
*
|
|
494
|
+
* A primary key identifies the row rather than changing it, and a generated column cannot be
|
|
495
|
+
* written at all. This asked only the first question, so every `generatedAlwaysAs` column landed
|
|
496
|
+
* in the patch type. Measured against real servers: all three refuse an UPDATE naming one with any
|
|
497
|
+
* value, including NULL. Postgres 428C9, MySQL 3105, SQLite "cannot UPDATE generated column". The
|
|
498
|
+
* one accepted form is `SET col = DEFAULT`, which no validator can express and no Drizzle `.set()`
|
|
499
|
+
* produces.
|
|
500
|
+
*
|
|
501
|
+
* `isGeneratedColumn` rather than `c.isGenerated`, so this and `insertColumns` cannot drift apart
|
|
502
|
+
* on what counts as generated.
|
|
503
|
+
*/
|
|
484
504
|
declare function updateColumns(table: Table): Column[];
|
|
485
505
|
declare function selectColumns(table: Table): Column[];
|
|
506
|
+
/**
|
|
507
|
+
* Pretty-print emitted code with whatever formatter the consumer already has.
|
|
508
|
+
*
|
|
509
|
+
* Both formatters are optional peers, reached at call time and never bundled. Prettier used to be
|
|
510
|
+
* bundled, because tsup resolves the specifier below statically and esbuild then inlined all of
|
|
511
|
+
* it: 11 MB per package across the three that had a copy of this function, roughly 32 MB for
|
|
512
|
+
* anyone installing @drzl/cli. It is `--external` in every build script that can reach it, and
|
|
513
|
+
* no-bundled-formatter.spec.ts builds those scripts and checks.
|
|
514
|
+
*
|
|
515
|
+
* Neither absence is an error. A consumer with no formatter gets the code as rendered, which is
|
|
516
|
+
* valid TypeScript that merely looks worse, and losing generated files at the last step would be
|
|
517
|
+
* a far worse trade than losing their whitespace.
|
|
518
|
+
*/
|
|
486
519
|
declare function formatCode(code: string, filePath: string, fmt?: FormatOptions): Promise<any>;
|
|
487
520
|
|
|
488
521
|
export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, CODEPOINT_LENGTH, COLUMN_FORMATS, type CardinalityCheck, type ColumnCheck, type ColumnSet, DEFAULT_IMPORT_EXTENSION, DEFAULT_MODE_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_TYPE_SUFFIX, type FormatOptions, IMPORT_EXTENSIONS, type ImportExtension, type LengthCheck, NAME_MODES, type NameMode, type ParsedCheck, type ResolvedAffix, type RowCheck, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, describeSet, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, renderDuplicateFinder, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
|
package/dist/index.d.ts
CHANGED
|
@@ -475,14 +475,47 @@ declare const COLUMN_FORMATS: Record<string, string>;
|
|
|
475
475
|
* Refusing a user's emoji is the failure mode this avoids, and it is the same rule applied
|
|
476
476
|
* everywhere else here: never reject what the database accepts.
|
|
477
477
|
*
|
|
478
|
-
* `@sinclair/typebox` and ArkType cannot
|
|
479
|
-
*
|
|
478
|
+
* All four generators count code points. `@sinclair/typebox` and ArkType cannot say it in their
|
|
479
|
+
* declarative forms, so neither uses `maxLength` or `string <= n`: TypeBox intersects a registered
|
|
480
|
+
* kind onto the field and ArkType puts a Type carrying a narrow there. Both cost something,
|
|
481
|
+
* TypeBox's cap no longer serialising into a JSON Schema, and emitting a number that means a
|
|
482
|
+
* different measurement is not a better trade.
|
|
483
|
+
*
|
|
484
|
+
* MySQL's TEXT family is a byte budget rather than a character count, carried separately as
|
|
485
|
+
* `maxBytes`. Two measurements on string columns in the same database, verified against a real
|
|
486
|
+
* MySQL 8 on utf8mb4: `varchar(10)` takes ten emoji, `tinytext` takes 63 of them and refuses 64.
|
|
480
487
|
*/
|
|
481
488
|
declare const CODEPOINT_LENGTH = "[...v].length";
|
|
482
489
|
declare function isIntegerColumn(c: Column): boolean;
|
|
483
490
|
declare function insertColumns(table: Table): Column[];
|
|
491
|
+
/**
|
|
492
|
+
* Which columns belong in an update schema.
|
|
493
|
+
*
|
|
494
|
+
* A primary key identifies the row rather than changing it, and a generated column cannot be
|
|
495
|
+
* written at all. This asked only the first question, so every `generatedAlwaysAs` column landed
|
|
496
|
+
* in the patch type. Measured against real servers: all three refuse an UPDATE naming one with any
|
|
497
|
+
* value, including NULL. Postgres 428C9, MySQL 3105, SQLite "cannot UPDATE generated column". The
|
|
498
|
+
* one accepted form is `SET col = DEFAULT`, which no validator can express and no Drizzle `.set()`
|
|
499
|
+
* produces.
|
|
500
|
+
*
|
|
501
|
+
* `isGeneratedColumn` rather than `c.isGenerated`, so this and `insertColumns` cannot drift apart
|
|
502
|
+
* on what counts as generated.
|
|
503
|
+
*/
|
|
484
504
|
declare function updateColumns(table: Table): Column[];
|
|
485
505
|
declare function selectColumns(table: Table): Column[];
|
|
506
|
+
/**
|
|
507
|
+
* Pretty-print emitted code with whatever formatter the consumer already has.
|
|
508
|
+
*
|
|
509
|
+
* Both formatters are optional peers, reached at call time and never bundled. Prettier used to be
|
|
510
|
+
* bundled, because tsup resolves the specifier below statically and esbuild then inlined all of
|
|
511
|
+
* it: 11 MB per package across the three that had a copy of this function, roughly 32 MB for
|
|
512
|
+
* anyone installing @drzl/cli. It is `--external` in every build script that can reach it, and
|
|
513
|
+
* no-bundled-formatter.spec.ts builds those scripts and checks.
|
|
514
|
+
*
|
|
515
|
+
* Neither absence is an error. A consumer with no formatter gets the code as rendered, which is
|
|
516
|
+
* valid TypeScript that merely looks worse, and losing generated files at the last step would be
|
|
517
|
+
* a far worse trade than losing their whitespace.
|
|
518
|
+
*/
|
|
486
519
|
declare function formatCode(code: string, filePath: string, fmt?: FormatOptions): Promise<any>;
|
|
487
520
|
|
|
488
521
|
export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, CODEPOINT_LENGTH, COLUMN_FORMATS, type CardinalityCheck, type ColumnCheck, type ColumnSet, DEFAULT_IMPORT_EXTENSION, DEFAULT_MODE_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_TYPE_SUFFIX, type FormatOptions, IMPORT_EXTENSIONS, type ImportExtension, type LengthCheck, NAME_MODES, type NameMode, type ParsedCheck, type ResolvedAffix, type RowCheck, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, describeSet, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, renderDuplicateFinder, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./chunk-ZZGILH5A.js";
|
|
2
|
-
|
|
3
1
|
// src/checks.ts
|
|
4
2
|
var COMPARISON = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*(>=|<=|<>|!=|>|<|=)\s*(.+?)\s*$/;
|
|
5
3
|
var IN_LIST = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s+IN\s*\((.+)\)\s*$/i;
|
|
@@ -447,7 +445,7 @@ function insertColumns(table) {
|
|
|
447
445
|
}
|
|
448
446
|
function updateColumns(table) {
|
|
449
447
|
const pkCols = table.primaryKey?.columns ?? [];
|
|
450
|
-
return table.columns.filter((c) => !pkCols.includes(c.name));
|
|
448
|
+
return table.columns.filter((c) => !isGeneratedColumn(c) && !pkCols.includes(c.name));
|
|
451
449
|
}
|
|
452
450
|
function selectColumns(table) {
|
|
453
451
|
return table.columns;
|
|
@@ -457,7 +455,7 @@ async function formatCode(code, filePath, fmt) {
|
|
|
457
455
|
const engine = fmt?.engine ?? "auto";
|
|
458
456
|
try {
|
|
459
457
|
if (engine === "prettier" || engine === "auto") {
|
|
460
|
-
const prettier = await import("
|
|
458
|
+
const prettier = await import("prettier");
|
|
461
459
|
const cfgRef = fmt?.configPath ?? filePath;
|
|
462
460
|
const cfg = await prettier.resolveConfig(cfgRef).catch(() => null);
|
|
463
461
|
return prettier.format(code, { ...cfg ?? {}, parser: "typescript", filepath: filePath });
|
|
@@ -472,6 +470,10 @@ async function formatCode(code, filePath, fmt) {
|
|
|
472
470
|
const res = await biome.formatContent(code, { filePath });
|
|
473
471
|
return (res && (res.content || res.formatted)) ?? code;
|
|
474
472
|
}
|
|
473
|
+
if (biome?.format) {
|
|
474
|
+
const res = await biome.format(code, { filePath });
|
|
475
|
+
return res ?? code;
|
|
476
|
+
}
|
|
475
477
|
}
|
|
476
478
|
} catch {
|
|
477
479
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drzl/validation-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@drzl/analyzer": "^1.
|
|
14
|
+
"@drzl/analyzer": "^1.15.0"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"prettier": ">=3"
|
|
18
|
+
},
|
|
19
|
+
"peerDependenciesMeta": {
|
|
20
|
+
"prettier": {
|
|
21
|
+
"optional": true
|
|
22
|
+
}
|
|
15
23
|
},
|
|
16
24
|
"devDependencies": {
|
|
17
25
|
"tsup": "^8.5.1",
|
|
@@ -35,7 +43,7 @@
|
|
|
35
43
|
"url": "https://github.com/sponsors/omar-dulaimi"
|
|
36
44
|
},
|
|
37
45
|
"scripts": {
|
|
38
|
-
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
46
|
+
"build": "tsup src/index.ts --dts --format esm,cjs --external prettier --clean",
|
|
39
47
|
"test": "vitest run --testTimeout=20000"
|
|
40
48
|
}
|
|
41
49
|
}
|