mikro-orm-temporal 1.1.0 → 1.2.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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./duration-type.js";
2
+ export * from "./instant-type.js";
2
3
  export * from "./offset-date-time-type.js";
3
4
  export * from "./plain-date-time-type.js";
4
5
  export * from "./plain-date-type.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./duration-type.js";
2
+ export * from "./instant-type.js";
2
3
  export * from "./offset-date-time-type.js";
3
4
  export * from "./plain-date-time-type.js";
4
5
  export * from "./plain-date-type.js";
@@ -0,0 +1,8 @@
1
+ import { type EntityProperty, type Platform, Type } from "@mikro-orm/core";
2
+ export declare class InstantType extends Type<Temporal.Instant | null, string | null> {
3
+ convertToDatabaseValue(value: Temporal.Instant | null, platform: Platform): string | null;
4
+ convertToJSValue(value: Date | string | null, platform: Platform): Temporal.Instant | null;
5
+ compareAsType(): string;
6
+ toJSON(value: Temporal.Instant | null): string | null;
7
+ getColumnType(prop: EntityProperty, platform: Platform): string;
8
+ }
@@ -0,0 +1,44 @@
1
+ import { Type } from "@mikro-orm/core";
2
+ import { isMsSql, isMySql } from "./utils.js";
3
+ export class InstantType extends Type {
4
+ convertToDatabaseValue(value, platform) {
5
+ if (value === null) {
6
+ return null;
7
+ }
8
+ if (isMySql(platform)) {
9
+ // Convert to MySQL format
10
+ return value.toZonedDateTimeISO("UTC").toPlainDateTime().toString().replace("T", " ");
11
+ }
12
+ return value.toString();
13
+ }
14
+ convertToJSValue(value, platform) {
15
+ /* node:coverage disable */
16
+ if (value === null) {
17
+ return null;
18
+ }
19
+ /* node:coverage enable */
20
+ if (typeof value === "string") {
21
+ if (isMySql(platform)) {
22
+ // Convert to ISO format
23
+ return Temporal.Instant.from(`${value.replace(" ", "T")}Z`);
24
+ }
25
+ return Temporal.Instant.from(value);
26
+ }
27
+ return Temporal.Instant.fromEpochMilliseconds(value.getTime());
28
+ }
29
+ compareAsType() {
30
+ return "date";
31
+ }
32
+ /* node:coverage disable */
33
+ toJSON(value) {
34
+ return value ? value.toString() : null;
35
+ }
36
+ /* node:coverage enable */
37
+ getColumnType(prop, platform) {
38
+ if (isMsSql(platform)) {
39
+ // MSSQL has a true single-purpose column type for timestamps with offset.
40
+ return "DATETIMEOFFSET";
41
+ }
42
+ return platform.getDateTimeTypeDeclarationSQL({ length: prop.length });
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikro-orm-temporal",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Temporal types for Mikro ORM",
5
5
  "type": "module",
6
6
  "author": "Ben Scholzen 'DASPRiD'",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "https://github.com/dasprid/mikro-orm-temporal.git"
26
+ "url": "git+https://github.com/DASPRiD/mikro-orm-temporal.git"
27
27
  },
28
28
  "files": [
29
29
  "dist/**/*"
@@ -44,28 +44,28 @@
44
44
  "check": "biome check . --write"
45
45
  },
46
46
  "devDependencies": {
47
- "@biomejs/biome": "2.0.0",
48
- "@commitlint/cli": "^19.8.1",
49
- "@commitlint/config-conventional": "^19.8.1",
50
- "@mikro-orm/better-sqlite": "^6.4.16",
51
- "@mikro-orm/core": "^6.4.16",
52
- "@mikro-orm/mariadb": "^6.4.16",
53
- "@mikro-orm/mssql": "^6.4.16",
54
- "@mikro-orm/mysql": "^6.4.16",
55
- "@mikro-orm/postgresql": "^6.4.16",
47
+ "@biomejs/biome": "2.2.7",
48
+ "@commitlint/cli": "^20.1.0",
49
+ "@commitlint/config-conventional": "^20.0.0",
50
+ "@mikro-orm/better-sqlite": "^6.5.9",
51
+ "@mikro-orm/core": "^6.5.9",
52
+ "@mikro-orm/mariadb": "^6.5.9",
53
+ "@mikro-orm/mssql": "^6.5.9",
54
+ "@mikro-orm/mysql": "^6.5.9",
55
+ "@mikro-orm/postgresql": "^6.5.9",
56
56
  "@tsconfig/node22": "^22.0.2",
57
- "@types/node": "^24.0.3",
57
+ "@types/node": "^24.9.1",
58
58
  "c8": "^10.1.3",
59
- "lefthook": "^1.11.14",
59
+ "lefthook": "^2.0.0",
60
60
  "temporal-polyfill": "^0.3.0",
61
61
  "temporal-spec": "^0.3.0",
62
- "tsx": "^4.20.3",
63
- "typescript": "^5.8.3"
62
+ "tsx": "^4.20.6",
63
+ "typescript": "^5.9.3"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@mikro-orm/core": "^6.0.5"
67
67
  },
68
- "packageManager": "pnpm@10.6.5+sha512.cdf928fca20832cd59ec53826492b7dc25dc524d4370b6b4adbf65803d32efaa6c1c88147c0ae4e8d579a6c9eec715757b50d4fa35eea179d868eada4ed043af",
68
+ "packageManager": "pnpm@10.19.0+sha512.c9fc7236e92adf5c8af42fd5bf1612df99c2ceb62f27047032f4720b33f8eacdde311865e91c411f2774f618d82f320808ecb51718bfa82c060c4ba7c76a32b8",
69
69
  "pnpm": {
70
70
  "onlyBuiltDependencies": [
71
71
  "better-sqlite3",