@vibeorm/schema 5.5.0 → 5.6.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.
- package/dist/collation.d.ts +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +73 -1
- package/dist/index.js.map +6 -5
- package/dist/ir.d.ts +5 -4
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which dialect renders a field's `@collation`.
|
|
3
|
+
*
|
|
4
|
+
* MySQL and PostgreSQL both have column collations, in disjoint name
|
|
5
|
+
* namespaces: every MySQL collation is `binary` or `<character set>_<suffix>`
|
|
6
|
+
* over a closed list of character sets, while PostgreSQL names are libc
|
|
7
|
+
* locales (`C`, `POSIX`, `en_US.utf8`), ICU tags (`und-x-icu`), `ucs_basic`,
|
|
8
|
+
* `pg_c_utf8` or user-created collations. A portable schema that carries a
|
|
9
|
+
* MySQL collation for its MySQL target therefore stays valid on PostgreSQL,
|
|
10
|
+
* and a PostgreSQL schema's collation reaches PostgreSQL DDL.
|
|
11
|
+
*/
|
|
12
|
+
import type { Dialect, FieldIR } from "./ir.ts";
|
|
13
|
+
/** Whether a collation name is a MySQL collation: `binary`, or `<MySQL character set>_<suffix>` (case-insensitive, as MySQL reads it). */
|
|
14
|
+
export declare function isMysqlCollationName(params: {
|
|
15
|
+
name: string;
|
|
16
|
+
}): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The collation `dialect` renders for `field`, or `undefined` where the
|
|
19
|
+
* declaration is inert: MySQL renders every `@collation`, PostgreSQL every one
|
|
20
|
+
* that is not a MySQL collation name ({@link isMysqlCollationName}), SQLite none.
|
|
21
|
+
*/
|
|
22
|
+
export declare function dialectCollation(params: {
|
|
23
|
+
field: Pick<FieldIR, "collation">;
|
|
24
|
+
dialect: Dialect;
|
|
25
|
+
}): string | undefined;
|
|
26
|
+
//# sourceMappingURL=collation.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { timeOfDayType } from "./time-of-day.ts";
|
|
|
29
29
|
export { DATE_TRUNCATION_UNITS, dateTruncationStorage } from "./date-truncation.ts";
|
|
30
30
|
export type { DateTruncationStorage, DateTruncationUnit } from "./date-truncation.ts";
|
|
31
31
|
export { isLocalDateField, isCanonicalLocalDate, localDateCheckName } from "./local-date.ts";
|
|
32
|
+
export { dialectCollation, isMysqlCollationName } from "./collation.ts";
|
|
32
33
|
export { READ_ONLY_REFUSAL_REASONS, ReadOnlyClientError, SCOPED_REFUSAL_REASONS, ScopedQueryError, VIBE_ERROR_CODES, VibeError, internalError, invalidStoredData, unsupportedCapability, } from "./errors.ts";
|
|
33
34
|
export type { ReadOnlyRefusalReason, ScopedRefusalReason, VibeErrorCode } from "./errors.ts";
|
|
34
35
|
export { decodePrismaString, encodePrismaString, exactDecimalLiteral, exactIntegerLiteral } from "./prisma-literal.ts";
|
package/dist/index.js
CHANGED
|
@@ -2463,6 +2463,71 @@ function dateTruncationStorage(params) {
|
|
|
2463
2463
|
return "timestamp";
|
|
2464
2464
|
return;
|
|
2465
2465
|
}
|
|
2466
|
+
// packages/schema/src/collation.ts
|
|
2467
|
+
var MYSQL_CHARACTER_SETS = new Set([
|
|
2468
|
+
"armscii8",
|
|
2469
|
+
"ascii",
|
|
2470
|
+
"big5",
|
|
2471
|
+
"binary",
|
|
2472
|
+
"cp1250",
|
|
2473
|
+
"cp1251",
|
|
2474
|
+
"cp1256",
|
|
2475
|
+
"cp1257",
|
|
2476
|
+
"cp850",
|
|
2477
|
+
"cp852",
|
|
2478
|
+
"cp866",
|
|
2479
|
+
"cp932",
|
|
2480
|
+
"dec8",
|
|
2481
|
+
"eucjpms",
|
|
2482
|
+
"euckr",
|
|
2483
|
+
"gb18030",
|
|
2484
|
+
"gb2312",
|
|
2485
|
+
"gbk",
|
|
2486
|
+
"geostd8",
|
|
2487
|
+
"greek",
|
|
2488
|
+
"hebrew",
|
|
2489
|
+
"hp8",
|
|
2490
|
+
"keybcs2",
|
|
2491
|
+
"koi8r",
|
|
2492
|
+
"koi8u",
|
|
2493
|
+
"latin1",
|
|
2494
|
+
"latin2",
|
|
2495
|
+
"latin5",
|
|
2496
|
+
"latin7",
|
|
2497
|
+
"macce",
|
|
2498
|
+
"macroman",
|
|
2499
|
+
"sjis",
|
|
2500
|
+
"swe7",
|
|
2501
|
+
"tis620",
|
|
2502
|
+
"ucs2",
|
|
2503
|
+
"ujis",
|
|
2504
|
+
"utf16",
|
|
2505
|
+
"utf16le",
|
|
2506
|
+
"utf32",
|
|
2507
|
+
"utf8",
|
|
2508
|
+
"utf8mb3",
|
|
2509
|
+
"utf8mb4"
|
|
2510
|
+
]);
|
|
2511
|
+
function isMysqlCollationName(params) {
|
|
2512
|
+
const name = params.name.toLowerCase();
|
|
2513
|
+
if (name === "binary")
|
|
2514
|
+
return true;
|
|
2515
|
+
const separator = name.indexOf("_");
|
|
2516
|
+
return separator > 0 && separator < name.length - 1 && MYSQL_CHARACTER_SETS.has(name.slice(0, separator));
|
|
2517
|
+
}
|
|
2518
|
+
function dialectCollation(params) {
|
|
2519
|
+
const { collation } = params.field;
|
|
2520
|
+
if (collation === undefined)
|
|
2521
|
+
return;
|
|
2522
|
+
switch (params.dialect) {
|
|
2523
|
+
case "mysql":
|
|
2524
|
+
return collation;
|
|
2525
|
+
case "postgres":
|
|
2526
|
+
return isMysqlCollationName({ name: collation }) ? undefined : collation;
|
|
2527
|
+
case "sqlite":
|
|
2528
|
+
return;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2466
2531
|
// packages/schema/src/computed.ts
|
|
2467
2532
|
function buildComputedManifest(params) {
|
|
2468
2533
|
const { computed } = params;
|
|
@@ -2854,6 +2919,9 @@ var RESERVED_ENUM_NAMES = [
|
|
|
2854
2919
|
"createClient",
|
|
2855
2920
|
"DatabaseAdapter",
|
|
2856
2921
|
"DbNow",
|
|
2922
|
+
"JoinedField",
|
|
2923
|
+
"TransactionLocalSettings",
|
|
2924
|
+
"VibeUpdateManySources",
|
|
2857
2925
|
"ClientContext",
|
|
2858
2926
|
"QueryOperation",
|
|
2859
2927
|
"QueryEvent",
|
|
@@ -2917,6 +2985,8 @@ var GENERATED_TYPE_NAMES = {
|
|
|
2917
2985
|
"UpdateInput",
|
|
2918
2986
|
"UncheckedUpdateInput",
|
|
2919
2987
|
"UpdateManyInput",
|
|
2988
|
+
"UpdateManyJoinedInput",
|
|
2989
|
+
"UpdateManyFrom",
|
|
2920
2990
|
"CountAggregateInput",
|
|
2921
2991
|
"AvgAggregateInput",
|
|
2922
2992
|
"SumAggregateInput",
|
|
@@ -4487,6 +4557,7 @@ export {
|
|
|
4487
4557
|
defaultPrimaryKeyName,
|
|
4488
4558
|
defaultRowRuleName,
|
|
4489
4559
|
defineExtension,
|
|
4560
|
+
dialectCollation,
|
|
4490
4561
|
encodePrismaString,
|
|
4491
4562
|
enumStorageOf,
|
|
4492
4563
|
exactDecimalLiteral,
|
|
@@ -4517,6 +4588,7 @@ export {
|
|
|
4517
4588
|
isExpressionIndex,
|
|
4518
4589
|
isImplicitManyToManyRelation,
|
|
4519
4590
|
isLocalDateField,
|
|
4591
|
+
isMysqlCollationName,
|
|
4520
4592
|
isPredicateFieldRef,
|
|
4521
4593
|
isReservedClientName,
|
|
4522
4594
|
isReservedDelegateName,
|
|
@@ -4570,4 +4642,4 @@ export {
|
|
|
4570
4642
|
validatorRefIssue
|
|
4571
4643
|
};
|
|
4572
4644
|
|
|
4573
|
-
//# debugId=
|
|
4645
|
+
//# debugId=908B9801B15F7FB564756E2164756E21
|