@naturalcycles/js-lib 14.99.4 → 14.102.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/datetime/localDate.d.ts +2 -2
- package/dist/datetime/localTime.d.ts +6 -2
- package/dist/datetime/localTime.js +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/json-schema/jsonSchemaBuilder.d.ts +3 -0
- package/dist/json-schema/jsonSchemaBuilder.js +7 -2
- package/dist/json-schema/jsonSchemas.js +4 -4
- package/dist/types.d.ts +6 -0
- package/dist-esm/datetime/localTime.js +6 -0
- package/dist-esm/json-schema/jsonSchemaBuilder.js +7 -2
- package/dist-esm/json-schema/jsonSchemas.js +4 -4
- package/package.json +1 -1
- package/src/datetime/localDate.ts +7 -2
- package/src/datetime/localTime.ts +14 -2
- package/src/index.ts +2 -0
- package/src/json-schema/jsonSchemaBuilder.ts +7 -2
- package/src/json-schema/jsonSchemas.ts +4 -4
- package/src/types.ts +7 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsoDateString, IsoDateTimeString, UnixTimestampNumber } from '../types';
|
|
1
|
+
import { IsoDateString, IsoDateTimeString, UnixTimestampMillisNumber, UnixTimestampNumber } from '../types';
|
|
2
2
|
import { LocalTime } from './localTime';
|
|
3
3
|
export declare type LocalDateUnit = LocalDateUnitStrict | 'week';
|
|
4
4
|
export declare type LocalDateUnitStrict = 'year' | 'month' | 'day';
|
|
@@ -89,7 +89,7 @@ export declare class LocalDate {
|
|
|
89
89
|
toString(): IsoDateString;
|
|
90
90
|
toStringCompact(): string;
|
|
91
91
|
unix(): UnixTimestampNumber;
|
|
92
|
-
unixMillis():
|
|
92
|
+
unixMillis(): UnixTimestampMillisNumber;
|
|
93
93
|
toJSON(): IsoDateString;
|
|
94
94
|
format(fmt: LocalDateFormatter): string;
|
|
95
95
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsoDateString, IsoDateTimeString, UnixTimestampNumber } from '../types';
|
|
1
|
+
import { IsoDateString, IsoDateTimeString, UnixTimestampMillisNumber, UnixTimestampNumber } from '../types';
|
|
2
2
|
import { Inclusiveness, LocalDate } from './localDate';
|
|
3
3
|
export declare type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
4
4
|
export declare enum ISODayOfWeek {
|
|
@@ -31,6 +31,10 @@ export declare class LocalTime {
|
|
|
31
31
|
* Input can already be a LocalDate - it is returned as-is in that case.
|
|
32
32
|
*/
|
|
33
33
|
static of(d: LocalTimeConfig): LocalTime;
|
|
34
|
+
/**
|
|
35
|
+
* Create LocalTime from unixTimestamp in milliseconds (not in seconds).
|
|
36
|
+
*/
|
|
37
|
+
static ofMillis(millis: UnixTimestampMillisNumber): LocalTime;
|
|
34
38
|
/**
|
|
35
39
|
* Returns null if invalid
|
|
36
40
|
*/
|
|
@@ -93,7 +97,7 @@ export declare class LocalTime {
|
|
|
93
97
|
getDate(): Date;
|
|
94
98
|
clone(): LocalTime;
|
|
95
99
|
unix(): UnixTimestampNumber;
|
|
96
|
-
unixMillis():
|
|
100
|
+
unixMillis(): UnixTimestampMillisNumber;
|
|
97
101
|
valueOf(): UnixTimestampNumber;
|
|
98
102
|
toLocalDate(): LocalDate;
|
|
99
103
|
toPretty(seconds?: boolean): IsoDateTimeString;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export * from './string/string.util';
|
|
|
51
51
|
import { JsonStringifyFunction, StringifyAnyOptions, _stringifyAny } from './string/stringifyAny';
|
|
52
52
|
export * from './time/time.util';
|
|
53
53
|
import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable, ReadonlyDeep, Simplify } from './typeFest';
|
|
54
|
-
import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, UnsavedId, BatchResult, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestampNumber, UnixTimestamp, Integer, ValueOf, ValuesOf, AbortableMapper, AbortableAsyncPredicate, AbortableAsyncMapper, AbortablePredicate, END, SKIP, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues } from './types';
|
|
54
|
+
import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, UnsavedId, BatchResult, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestampNumber, UnixTimestampMillisNumber, UnixTimestamp, Integer, ValueOf, ValuesOf, AbortableMapper, AbortableAsyncPredicate, AbortableAsyncMapper, AbortablePredicate, END, SKIP, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues } from './types';
|
|
55
55
|
export * from './unit/size.util';
|
|
56
56
|
import { is } from './vendor/is';
|
|
57
57
|
import { CommonLogLevel, CommonLogFunction, CommonLogger, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, CommonLogWithLevelFunction, commonLoggerCreate } from './log/commonLogger';
|
|
@@ -68,5 +68,5 @@ import { LocalDateConfig, LocalDateFormatter, LocalDateUnit, LocalDateUnitStrict
|
|
|
68
68
|
import { LocalTimeConfig, LocalTimeFormatter, LocalTimeUnit, LocalTimeComponents, ISODayOfWeek } from './datetime/localTime';
|
|
69
69
|
import { DateIntervalConfig, DateIntervalString } from './datetime/dateInterval';
|
|
70
70
|
import { TimeIntervalConfig, TimeIntervalString } from './datetime/timeInterval';
|
|
71
|
-
export type { DateIntervalConfig, DateIntervalString, TimeIntervalConfig, TimeIntervalString, LocalDateConfig, LocalDateFormatter, LocalDateUnit, LocalDateUnitStrict, Inclusiveness, LocalTimeConfig, LocalTimeFormatter, LocalTimeUnit, ISODayOfWeek, LocalTimeComponents, AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, AsyncMemoCache, PromiseDecoratorCfg, PromiseDecoratorResp, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Admin401ErrorData, Admin403ErrorData, StringMap, PromiseMap, AnyObject, AnyFunction, ValuesOf, ValueOf, KeyValueTuple, ObjectMapper, ObjectPredicate, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, Reviver, PMapOptions, Mapper, AsyncMapper, Predicate, AsyncPredicate, BatchResult, DeferredPromise, PRetryOptions, PTimeoutOptions, TryCatchOptions, StringifyAnyOptions, JsonStringifyFunction, Merge, ReadonlyDeep, Promisable, Simplify, ConditionalPick, ConditionalExcept, Class, UnixTimestampNumber, UnixTimestamp, Integer, BaseDBEntity, SavedDBEntity, Saved, Unsaved, UnsavedId, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
|
|
71
|
+
export type { DateIntervalConfig, DateIntervalString, TimeIntervalConfig, TimeIntervalString, LocalDateConfig, LocalDateFormatter, LocalDateUnit, LocalDateUnitStrict, Inclusiveness, LocalTimeConfig, LocalTimeFormatter, LocalTimeUnit, ISODayOfWeek, LocalTimeComponents, AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, AsyncMemoCache, PromiseDecoratorCfg, PromiseDecoratorResp, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Admin401ErrorData, Admin403ErrorData, StringMap, PromiseMap, AnyObject, AnyFunction, ValuesOf, ValueOf, KeyValueTuple, ObjectMapper, ObjectPredicate, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, Reviver, PMapOptions, Mapper, AsyncMapper, Predicate, AsyncPredicate, BatchResult, DeferredPromise, PRetryOptions, PTimeoutOptions, TryCatchOptions, StringifyAnyOptions, JsonStringifyFunction, Merge, ReadonlyDeep, Promisable, Simplify, ConditionalPick, ConditionalExcept, Class, UnixTimestampNumber, UnixTimestampMillisNumber, UnixTimestamp, Integer, BaseDBEntity, SavedDBEntity, Saved, Unsaved, UnsavedId, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
|
|
72
72
|
export { is, _createPromiseDecorator, _stringMapValues, _stringMapEntries, _objectKeys, pMap, _passthroughMapper, _passUndefinedMapper, _passthroughPredicate, _passNothingPredicate, _noop, ErrorMode, pDefer, AggregatedError, pRetry, pRetryFn, pTimeout, pTimeoutFn, _tryCatch, _TryCatch, _stringifyAny, jsonSchema, JsonSchemaAnyBuilder, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, commonLoggerCreate, PQueue, END, SKIP, };
|
|
@@ -19,6 +19,7 @@ export declare const jsonSchema: {
|
|
|
19
19
|
number(): JsonSchemaNumberBuilder;
|
|
20
20
|
integer(): JsonSchemaNumberBuilder;
|
|
21
21
|
unixTimestamp(): JsonSchemaNumberBuilder;
|
|
22
|
+
unixTimestamp2000(): JsonSchemaNumberBuilder;
|
|
22
23
|
string(): JsonSchemaStringBuilder;
|
|
23
24
|
dateString(): JsonSchemaStringBuilder;
|
|
24
25
|
object<T_4 extends AnyObject>(props: { [k in keyof T_4]: JsonSchemaAnyBuilder<T_4[k], JsonSchema<T_4[k]>>; }): JsonSchemaObjectBuilder<T_4>;
|
|
@@ -72,7 +73,9 @@ export declare class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder<number
|
|
|
72
73
|
float: () => this;
|
|
73
74
|
double: () => this;
|
|
74
75
|
unixTimestamp: () => this;
|
|
76
|
+
unixTimestamp2000: () => this;
|
|
75
77
|
unixTimestampMillis: () => this;
|
|
78
|
+
unixTimestampMillis2000: () => this;
|
|
76
79
|
utcOffset: () => this;
|
|
77
80
|
utcOffsetHours: () => this;
|
|
78
81
|
}
|
|
@@ -50,6 +50,9 @@ exports.jsonSchema = {
|
|
|
50
50
|
unixTimestamp() {
|
|
51
51
|
return new JsonSchemaNumberBuilder().unixTimestamp();
|
|
52
52
|
},
|
|
53
|
+
unixTimestamp2000() {
|
|
54
|
+
return new JsonSchemaNumberBuilder().unixTimestamp2000();
|
|
55
|
+
},
|
|
53
56
|
// string types
|
|
54
57
|
string() {
|
|
55
58
|
return new JsonSchemaStringBuilder();
|
|
@@ -167,7 +170,9 @@ class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder {
|
|
|
167
170
|
this.float = () => this.format('float');
|
|
168
171
|
this.double = () => this.format('double');
|
|
169
172
|
this.unixTimestamp = () => this.format('unixTimestamp');
|
|
173
|
+
this.unixTimestamp2000 = () => this.format('unixTimestamp2000');
|
|
170
174
|
this.unixTimestampMillis = () => this.format('unixTimestampMillis');
|
|
175
|
+
this.unixTimestampMillis2000 = () => this.format('unixTimestampMillis2000');
|
|
171
176
|
this.utcOffset = () => this.format('utcOffset');
|
|
172
177
|
this.utcOffsetHours = () => this.format('utcOffsetHours');
|
|
173
178
|
}
|
|
@@ -309,8 +314,8 @@ class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
|
|
|
309
314
|
baseDBEntity(idType = 'string') {
|
|
310
315
|
Object.assign(this.schema.properties, {
|
|
311
316
|
id: { type: idType },
|
|
312
|
-
created: { type: 'number', format: '
|
|
313
|
-
updated: { type: 'number', format: '
|
|
317
|
+
created: { type: 'number', format: 'unixTimestamp2000' },
|
|
318
|
+
updated: { type: 'number', format: 'unixTimestamp2000' },
|
|
314
319
|
});
|
|
315
320
|
return this;
|
|
316
321
|
}
|
|
@@ -4,11 +4,11 @@ exports.savedDBEntityJsonSchema = exports.baseDBEntityJsonSchema = void 0;
|
|
|
4
4
|
const jsonSchemaBuilder_1 = require("./jsonSchemaBuilder");
|
|
5
5
|
exports.baseDBEntityJsonSchema = jsonSchemaBuilder_1.jsonSchema.object({
|
|
6
6
|
id: jsonSchemaBuilder_1.jsonSchema.string().optional(),
|
|
7
|
-
created: jsonSchemaBuilder_1.jsonSchema.
|
|
8
|
-
updated: jsonSchemaBuilder_1.jsonSchema.
|
|
7
|
+
created: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000().optional(),
|
|
8
|
+
updated: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000().optional(),
|
|
9
9
|
});
|
|
10
10
|
exports.savedDBEntityJsonSchema = jsonSchemaBuilder_1.jsonSchema.object({
|
|
11
11
|
id: jsonSchemaBuilder_1.jsonSchema.string(),
|
|
12
|
-
created: jsonSchemaBuilder_1.jsonSchema.
|
|
13
|
-
updated: jsonSchemaBuilder_1.jsonSchema.
|
|
12
|
+
created: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000(),
|
|
13
|
+
updated: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000(),
|
|
14
14
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -154,6 +154,12 @@ export declare type IsoDateTimeString = string;
|
|
|
154
154
|
* @example 1628945450
|
|
155
155
|
*/
|
|
156
156
|
export declare type UnixTimestampNumber = number;
|
|
157
|
+
/**
|
|
158
|
+
* Interface explicitly states that the value is a "Unix timestamp in **milleseconds**" (not seconds)
|
|
159
|
+
*
|
|
160
|
+
* @example 1628945450000
|
|
161
|
+
*/
|
|
162
|
+
export declare type UnixTimestampMillisNumber = number;
|
|
157
163
|
/**
|
|
158
164
|
* @deprecated use UnixTimestampNumber
|
|
159
165
|
*/
|
|
@@ -36,6 +36,12 @@ export class LocalTime {
|
|
|
36
36
|
}
|
|
37
37
|
return t;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Create LocalTime from unixTimestamp in milliseconds (not in seconds).
|
|
41
|
+
*/
|
|
42
|
+
static ofMillis(millis) {
|
|
43
|
+
return LocalTime.of(new Date(millis));
|
|
44
|
+
}
|
|
39
45
|
/**
|
|
40
46
|
* Returns null if invalid
|
|
41
47
|
*/
|
|
@@ -47,6 +47,9 @@ export const jsonSchema = {
|
|
|
47
47
|
unixTimestamp() {
|
|
48
48
|
return new JsonSchemaNumberBuilder().unixTimestamp();
|
|
49
49
|
},
|
|
50
|
+
unixTimestamp2000() {
|
|
51
|
+
return new JsonSchemaNumberBuilder().unixTimestamp2000();
|
|
52
|
+
},
|
|
50
53
|
// string types
|
|
51
54
|
string() {
|
|
52
55
|
return new JsonSchemaStringBuilder();
|
|
@@ -163,7 +166,9 @@ export class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder {
|
|
|
163
166
|
this.float = () => this.format('float');
|
|
164
167
|
this.double = () => this.format('double');
|
|
165
168
|
this.unixTimestamp = () => this.format('unixTimestamp');
|
|
169
|
+
this.unixTimestamp2000 = () => this.format('unixTimestamp2000');
|
|
166
170
|
this.unixTimestampMillis = () => this.format('unixTimestampMillis');
|
|
171
|
+
this.unixTimestampMillis2000 = () => this.format('unixTimestampMillis2000');
|
|
167
172
|
this.utcOffset = () => this.format('utcOffset');
|
|
168
173
|
this.utcOffsetHours = () => this.format('utcOffsetHours');
|
|
169
174
|
}
|
|
@@ -304,8 +309,8 @@ export class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
|
|
|
304
309
|
baseDBEntity(idType = 'string') {
|
|
305
310
|
Object.assign(this.schema.properties, {
|
|
306
311
|
id: { type: idType },
|
|
307
|
-
created: { type: 'number', format: '
|
|
308
|
-
updated: { type: 'number', format: '
|
|
312
|
+
created: { type: 'number', format: 'unixTimestamp2000' },
|
|
313
|
+
updated: { type: 'number', format: 'unixTimestamp2000' },
|
|
309
314
|
});
|
|
310
315
|
return this;
|
|
311
316
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsonSchema } from './jsonSchemaBuilder';
|
|
2
2
|
export const baseDBEntityJsonSchema = jsonSchema.object({
|
|
3
3
|
id: jsonSchema.string().optional(),
|
|
4
|
-
created: jsonSchema.
|
|
5
|
-
updated: jsonSchema.
|
|
4
|
+
created: jsonSchema.unixTimestamp2000().optional(),
|
|
5
|
+
updated: jsonSchema.unixTimestamp2000().optional(),
|
|
6
6
|
});
|
|
7
7
|
export const savedDBEntityJsonSchema = jsonSchema.object({
|
|
8
8
|
id: jsonSchema.string(),
|
|
9
|
-
created: jsonSchema.
|
|
10
|
-
updated: jsonSchema.
|
|
9
|
+
created: jsonSchema.unixTimestamp2000(),
|
|
10
|
+
updated: jsonSchema.unixTimestamp2000(),
|
|
11
11
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { _assert } from '../error/assert'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
IsoDateString,
|
|
4
|
+
IsoDateTimeString,
|
|
5
|
+
UnixTimestampMillisNumber,
|
|
6
|
+
UnixTimestampNumber,
|
|
7
|
+
} from '../types'
|
|
3
8
|
import { LocalTime } from './localTime'
|
|
4
9
|
|
|
5
10
|
export type LocalDateUnit = LocalDateUnitStrict | 'week'
|
|
@@ -477,7 +482,7 @@ export class LocalDate {
|
|
|
477
482
|
return Math.floor(this.toDate().valueOf() / 1000)
|
|
478
483
|
}
|
|
479
484
|
|
|
480
|
-
unixMillis():
|
|
485
|
+
unixMillis(): UnixTimestampMillisNumber {
|
|
481
486
|
return this.toDate().valueOf()
|
|
482
487
|
}
|
|
483
488
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { _assert } from '../error/assert'
|
|
2
2
|
import { _ms } from '../time/time.util'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IsoDateString,
|
|
5
|
+
IsoDateTimeString,
|
|
6
|
+
UnixTimestampMillisNumber,
|
|
7
|
+
UnixTimestampNumber,
|
|
8
|
+
} from '../types'
|
|
4
9
|
import { Inclusiveness, LocalDate } from './localDate'
|
|
5
10
|
|
|
6
11
|
export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second'
|
|
@@ -56,6 +61,13 @@ export class LocalTime {
|
|
|
56
61
|
return t
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Create LocalTime from unixTimestamp in milliseconds (not in seconds).
|
|
66
|
+
*/
|
|
67
|
+
static ofMillis(millis: UnixTimestampMillisNumber): LocalTime {
|
|
68
|
+
return LocalTime.of(new Date(millis))
|
|
69
|
+
}
|
|
70
|
+
|
|
59
71
|
/**
|
|
60
72
|
* Returns null if invalid
|
|
61
73
|
*/
|
|
@@ -471,7 +483,7 @@ export class LocalTime {
|
|
|
471
483
|
return Math.floor(this.$date.valueOf() / 1000)
|
|
472
484
|
}
|
|
473
485
|
|
|
474
|
-
unixMillis():
|
|
486
|
+
unixMillis(): UnixTimestampMillisNumber {
|
|
475
487
|
return this.$date.valueOf()
|
|
476
488
|
}
|
|
477
489
|
|
package/src/index.ts
CHANGED
|
@@ -120,6 +120,7 @@ import {
|
|
|
120
120
|
SavedDBEntity,
|
|
121
121
|
StringMap,
|
|
122
122
|
UnixTimestampNumber,
|
|
123
|
+
UnixTimestampMillisNumber,
|
|
123
124
|
UnixTimestamp,
|
|
124
125
|
Integer,
|
|
125
126
|
ValueOf,
|
|
@@ -243,6 +244,7 @@ export type {
|
|
|
243
244
|
ConditionalExcept,
|
|
244
245
|
Class,
|
|
245
246
|
UnixTimestampNumber,
|
|
247
|
+
UnixTimestampMillisNumber,
|
|
246
248
|
UnixTimestamp,
|
|
247
249
|
Integer,
|
|
248
250
|
BaseDBEntity,
|
|
@@ -78,6 +78,9 @@ export const jsonSchema = {
|
|
|
78
78
|
unixTimestamp() {
|
|
79
79
|
return new JsonSchemaNumberBuilder().unixTimestamp()
|
|
80
80
|
},
|
|
81
|
+
unixTimestamp2000() {
|
|
82
|
+
return new JsonSchemaNumberBuilder().unixTimestamp2000()
|
|
83
|
+
},
|
|
81
84
|
// string types
|
|
82
85
|
string() {
|
|
83
86
|
return new JsonSchemaStringBuilder()
|
|
@@ -246,7 +249,9 @@ export class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder<number, JsonSc
|
|
|
246
249
|
float = () => this.format('float')
|
|
247
250
|
double = () => this.format('double')
|
|
248
251
|
unixTimestamp = () => this.format('unixTimestamp')
|
|
252
|
+
unixTimestamp2000 = () => this.format('unixTimestamp2000')
|
|
249
253
|
unixTimestampMillis = () => this.format('unixTimestampMillis')
|
|
254
|
+
unixTimestampMillis2000 = () => this.format('unixTimestampMillis2000')
|
|
250
255
|
utcOffset = () => this.format('utcOffset')
|
|
251
256
|
utcOffsetHours = () => this.format('utcOffsetHours')
|
|
252
257
|
}
|
|
@@ -370,8 +375,8 @@ export class JsonSchemaObjectBuilder<T extends AnyObject> extends JsonSchemaAnyB
|
|
|
370
375
|
): JsonSchemaObjectBuilder<T & BaseDBEntity<ID>> {
|
|
371
376
|
Object.assign(this.schema.properties, {
|
|
372
377
|
id: { type: idType },
|
|
373
|
-
created: { type: 'number', format: '
|
|
374
|
-
updated: { type: 'number', format: '
|
|
378
|
+
created: { type: 'number', format: 'unixTimestamp2000' },
|
|
379
|
+
updated: { type: 'number', format: 'unixTimestamp2000' },
|
|
375
380
|
})
|
|
376
381
|
|
|
377
382
|
return this
|
|
@@ -3,12 +3,12 @@ import { jsonSchema } from './jsonSchemaBuilder'
|
|
|
3
3
|
|
|
4
4
|
export const baseDBEntityJsonSchema = jsonSchema.object<BaseDBEntity>({
|
|
5
5
|
id: jsonSchema.string().optional(),
|
|
6
|
-
created: jsonSchema.
|
|
7
|
-
updated: jsonSchema.
|
|
6
|
+
created: jsonSchema.unixTimestamp2000().optional(),
|
|
7
|
+
updated: jsonSchema.unixTimestamp2000().optional(),
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
|
|
11
11
|
id: jsonSchema.string(),
|
|
12
|
-
created: jsonSchema.
|
|
13
|
-
updated: jsonSchema.
|
|
12
|
+
created: jsonSchema.unixTimestamp2000(),
|
|
13
|
+
updated: jsonSchema.unixTimestamp2000(),
|
|
14
14
|
})
|
package/src/types.ts
CHANGED
|
@@ -213,6 +213,13 @@ export type IsoDateTimeString = string
|
|
|
213
213
|
*/
|
|
214
214
|
export type UnixTimestampNumber = number
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Interface explicitly states that the value is a "Unix timestamp in **milleseconds**" (not seconds)
|
|
218
|
+
*
|
|
219
|
+
* @example 1628945450000
|
|
220
|
+
*/
|
|
221
|
+
export type UnixTimestampMillisNumber = number
|
|
222
|
+
|
|
216
223
|
/**
|
|
217
224
|
* @deprecated use UnixTimestampNumber
|
|
218
225
|
*/
|