@tsed/schema 8.32.2 → 8.34.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.
@@ -1,4 +1,4 @@
1
- import { ancestorOf, ancestorsOf, classOf, isArray, isClass, isFunction, isObject, isPlainObject, isPrimitiveClass, nameOf, uniq } from "@tsed/core";
1
+ import { ancestorOf, ancestorsOf, classOf, isArray, isClass, isFunction, isObject, isPlainObject, isPrimitiveClass, isTemporal, nameOf, uniq } from "@tsed/core";
2
2
  import { Hooks } from "@tsed/hooks";
3
3
  import { VendorKeys } from "../constants/VendorKeys.js";
4
4
  import { enumsRegistry } from "../registries/enumRegistries.js";
@@ -291,7 +291,7 @@ export class JsonSchema extends Map {
291
291
  if (item && classOf(item) !== Object && isClass(item)) {
292
292
  return JsonEntityStore.from(item).schema;
293
293
  }
294
- if (isPrimitiveClass(item) || item === Date || item === null) {
294
+ if (isPrimitiveClass(item) || item === Date || isTemporal(item) || item === null) {
295
295
  return new JsonSchema({ type: item });
296
296
  }
297
297
  return new JsonSchema(item);
@@ -1199,7 +1199,15 @@ export class JsonSchema extends Map {
1199
1199
  }
1200
1200
  break;
1201
1201
  default:
1202
- if (isClass(type) || isFunction(type)) {
1202
+ if (isTemporal(type)) {
1203
+ // Temporal.* types serialize to an ISO-8601 string, like Date.
1204
+ super.set("type", getJsonType(type));
1205
+ this.target(type);
1206
+ if (!this.has("properties")) {
1207
+ super.set("properties", {});
1208
+ }
1209
+ }
1210
+ else if (isClass(type) || isFunction(type)) {
1203
1211
  super.set("type", undefined);
1204
1212
  this.target(type);
1205
1213
  if (!this.has("properties")) {
@@ -1452,7 +1460,7 @@ export class JsonSchema extends Map {
1452
1460
  if (isObject(item)) {
1453
1461
  return JsonSchema.from(item);
1454
1462
  }
1455
- if (isPrimitiveClass(item) || item === Date || item === null) {
1463
+ if (isPrimitiveClass(item) || item === Date || isTemporal(item) || item === null) {
1456
1464
  return JsonSchema.from({ type: item });
1457
1465
  }
1458
1466
  return item;
@@ -1,4 +1,4 @@
1
- import { isArray, isBuffer, isDate, isPrimitiveOrPrimitiveClass, primitiveOf } from "@tsed/core";
1
+ import { isArray, isBuffer, isDate, isPrimitiveOrPrimitiveClass, isTemporal, primitiveOf } from "@tsed/core";
2
2
  /**
3
3
  * @ignore
4
4
  */
@@ -28,7 +28,7 @@ export function getJsonType(value) {
28
28
  if (value === Set) {
29
29
  return "array";
30
30
  }
31
- if (isDate(value) || isBuffer(value)) {
31
+ if (isDate(value) || isBuffer(value) || isTemporal(value)) {
32
32
  return "string";
33
33
  }
34
34
  return "object";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/schema",
3
3
  "description": "JsonSchema module for Ts.ED Framework",
4
4
  "type": "module",
5
- "version": "8.32.2",
5
+ "version": "8.34.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -34,7 +34,7 @@
34
34
  "tsed"
35
35
  ],
36
36
  "dependencies": {
37
- "@tsed/openspec": "8.32.2",
37
+ "@tsed/openspec": "8.34.0",
38
38
  "change-case": "^5.4.4",
39
39
  "json-schema": "0.4.0",
40
40
  "picomatch": "4.0.4",
@@ -43,17 +43,18 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@apidevtools/swagger-parser": "10.1.0",
46
- "@tsed/barrels": "8.32.2",
47
- "@tsed/core": "8.32.2",
48
- "@tsed/hooks": "8.32.2",
49
- "@tsed/openspec": "8.32.2",
50
- "@tsed/typescript": "8.32.2",
46
+ "@tsed/barrels": "8.34.0",
47
+ "@tsed/core": "8.34.0",
48
+ "@tsed/hooks": "8.34.0",
49
+ "@tsed/openspec": "8.34.0",
50
+ "@tsed/typescript": "8.34.0",
51
51
  "@types/fs-extra": "11.0.4",
52
52
  "@types/json-schema": "7.0.15",
53
53
  "@types/picomatch": "3.0.2",
54
54
  "@types/statuses": "2.0.5",
55
55
  "ajv": "^8.17.1",
56
56
  "eslint": "9.12.0",
57
+ "temporal-polyfill": "1.0.1",
57
58
  "typescript": "6.0.2",
58
59
  "vitest": "4.1.4"
59
60
  },
@@ -0,0 +1,6 @@
1
+ import {Temporal} from "temporal-polyfill";
2
+
3
+ // Provide the global `Temporal` on runtimes that don't ship it natively yet (e.g. Node < 24),
4
+ // so the Temporal schema specs run in CI instead of throwing. Native `Temporal` (Node >= 24/26)
5
+ // takes precedence and the polyfill is a no-op there.
6
+ (globalThis as {Temporal?: unknown}).Temporal ??= Temporal;