@tstdl/base 0.92.65 → 0.92.66
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/orm/server/data-types/index.d.ts +2 -0
- package/orm/server/data-types/index.js +2 -0
- package/orm/server/data-types/numeric-date.d.ts +10 -0
- package/orm/server/data-types/numeric-date.js +15 -0
- package/orm/server/data-types/timestamp.d.ts +10 -0
- package/orm/server/data-types/timestamp.js +12 -0
- package/orm/server/drizzle/schema-converter.js +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ConvertCustomConfig, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
2
|
+
type Config = {
|
|
3
|
+
data: number;
|
|
4
|
+
driverData: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const numericDate: {
|
|
7
|
+
(): PgCustomColumnBuilder<ConvertCustomConfig<"", Config>>;
|
|
8
|
+
<TName extends string>(dbName: TName): PgCustomColumnBuilder<ConvertCustomConfig<TName, Config>>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { customType } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { dateToNumericDate, numericDateToDate } from '../../../utils/date-time.js';
|
|
3
|
+
export const numericDate = customType({
|
|
4
|
+
dataType() {
|
|
5
|
+
return 'date';
|
|
6
|
+
},
|
|
7
|
+
toDriver(value) {
|
|
8
|
+
const { year, month, day } = numericDateToDate(value);
|
|
9
|
+
return new Date(year, month - 1, day).toISOString();
|
|
10
|
+
},
|
|
11
|
+
fromDriver(value) {
|
|
12
|
+
const date = new Date(value);
|
|
13
|
+
return dateToNumericDate(date);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ConvertCustomConfig, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
2
|
+
type Config = {
|
|
3
|
+
data: number;
|
|
4
|
+
driverData: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const timestamp: {
|
|
7
|
+
(): PgCustomColumnBuilder<ConvertCustomConfig<"", Config>>;
|
|
8
|
+
<TName extends string>(dbName: TName): PgCustomColumnBuilder<ConvertCustomConfig<TName, Config>>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { customType } from 'drizzle-orm/pg-core';
|
|
2
|
+
export const timestamp = customType({
|
|
3
|
+
dataType() {
|
|
4
|
+
return 'timestamp with time zone';
|
|
5
|
+
},
|
|
6
|
+
toDriver(value) {
|
|
7
|
+
return new Date(value).toISOString();
|
|
8
|
+
},
|
|
9
|
+
fromDriver(value) {
|
|
10
|
+
return new Date(value).getTime();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toCamelCase, toSnakeCase } from 'drizzle-orm/casing';
|
|
2
|
-
import { boolean,
|
|
2
|
+
import { boolean, doublePrecision, index, integer, jsonb, pgSchema, text, unique, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
3
3
|
import { MultiKeyMap } from '../../../data-structures/multi-key-map.js';
|
|
4
4
|
import { tryGetEnumName } from '../../../enumeration/enumeration.js';
|
|
5
5
|
import { NotSupportedError } from '../../../errors/not-supported.error.js';
|
|
@@ -17,7 +17,7 @@ import { JsonSchema } from '../../schemas/json.js';
|
|
|
17
17
|
import { NumericDateSchema } from '../../schemas/numeric-date.js';
|
|
18
18
|
import { TimestampSchema } from '../../schemas/timestamp.js';
|
|
19
19
|
import { UuidSchema } from '../../schemas/uuid.js';
|
|
20
|
-
import { bytea } from '../data-types/
|
|
20
|
+
import { bytea, numericDate, timestamp } from '../data-types/index.js';
|
|
21
21
|
import { decryptBytes, encryptBytes } from '../encryption.js';
|
|
22
22
|
const getDbSchema = memoizeSingle(pgSchema);
|
|
23
23
|
export const getDrizzleTableFromType = memoize(_getDrizzleTableFromType);
|
|
@@ -166,10 +166,10 @@ function getPostgresBaseColumn(columnName, dbSchema, schema, context) {
|
|
|
166
166
|
return column;
|
|
167
167
|
}
|
|
168
168
|
if (schema instanceof TimestampSchema) {
|
|
169
|
-
return timestamp(columnName
|
|
169
|
+
return timestamp(columnName);
|
|
170
170
|
}
|
|
171
171
|
if (schema instanceof NumericDateSchema) {
|
|
172
|
-
return
|
|
172
|
+
return numericDate(columnName);
|
|
173
173
|
}
|
|
174
174
|
if (schema instanceof NumberSchema) {
|
|
175
175
|
return schema.integer
|