@naturalcycles/nodejs-lib 12.72.0 → 12.73.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.
@@ -29,7 +29,22 @@ export declare const SLUG_PATTERN: RegExp;
29
29
  * "Slug" - a valid URL, filename, etc.
30
30
  */
31
31
  export declare const slugSchema: import("./string.extensions").ExtendedStringSchema;
32
+ /**
33
+ * Between years 1970 and 2050
34
+ */
32
35
  export declare const unixTimestampSchema: import("./number.extensions").ExtendedNumberSchema;
36
+ /**
37
+ * Between years 2000 and 2050
38
+ */
39
+ export declare const unixTimestamp2000Schema: import("./number.extensions").ExtendedNumberSchema;
40
+ /**
41
+ * Between years 1970 and 2050
42
+ */
43
+ export declare const unixTimestampMillisSchema: import("./number.extensions").ExtendedNumberSchema;
44
+ /**
45
+ * Between years 2000 and 2050
46
+ */
47
+ export declare const unixTimestampMillis2000Schema: import("./number.extensions").ExtendedNumberSchema;
33
48
  export declare const verSchema: import("./number.extensions").ExtendedNumberSchema;
34
49
  /**
35
50
  * Be careful, by default emailSchema does TLD validation. To disable it - use `stringSchema.email({tld: false}).lowercase()`
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.savedDBEntitySchema = exports.baseDBEntitySchema = exports.ipAddressSchema = exports.utcOffsetSchema = exports.userAgentSchema = exports.semVerSchema = exports.SEM_VER_PATTERN = exports.emailSchema = exports.verSchema = exports.unixTimestampSchema = exports.slugSchema = exports.SLUG_PATTERN = exports.idSchema = exports.anyObjectSchema = exports.anySchema = exports.oneOfSchema = exports.objectSchema = exports.arraySchema = exports.urlSchema = exports.binarySchema = exports.dateStringSchema = exports.percentageSchema = exports.integerSchema = exports.numberSchema = exports.stringSchema = exports.booleanDefaultToFalseSchema = exports.booleanSchema = void 0;
3
+ exports.savedDBEntitySchema = exports.baseDBEntitySchema = exports.ipAddressSchema = exports.utcOffsetSchema = exports.userAgentSchema = exports.semVerSchema = exports.SEM_VER_PATTERN = exports.emailSchema = exports.verSchema = exports.unixTimestampMillis2000Schema = exports.unixTimestampMillisSchema = exports.unixTimestamp2000Schema = exports.unixTimestampSchema = exports.slugSchema = exports.SLUG_PATTERN = exports.idSchema = exports.anyObjectSchema = exports.anySchema = exports.oneOfSchema = exports.objectSchema = exports.arraySchema = exports.urlSchema = exports.binarySchema = exports.dateStringSchema = exports.percentageSchema = exports.integerSchema = exports.numberSchema = exports.stringSchema = exports.booleanDefaultToFalseSchema = exports.booleanSchema = void 0;
4
4
  const joi_extensions_1 = require("./joi.extensions");
5
5
  exports.booleanSchema = joi_extensions_1.Joi.boolean();
6
6
  exports.booleanDefaultToFalseSchema = joi_extensions_1.Joi.boolean().default(false);
@@ -40,8 +40,30 @@ exports.SLUG_PATTERN = /^[a-z0-9-]*$/;
40
40
  * "Slug" - a valid URL, filename, etc.
41
41
  */
42
42
  exports.slugSchema = exports.stringSchema.regex(/^[a-z0-9-]{1,255}$/);
43
- // 16725225600 is 2500-01-01
44
- exports.unixTimestampSchema = exports.numberSchema.integer().min(0).max(16725225600);
43
+ const TS_2500 = 16725225600; // 2500-01-01
44
+ const TS_2000 = 946684800; // 2000-01-01
45
+ /**
46
+ * Between years 1970 and 2050
47
+ */
48
+ exports.unixTimestampSchema = exports.numberSchema.integer().min(0).max(TS_2500);
49
+ /**
50
+ * Between years 2000 and 2050
51
+ */
52
+ exports.unixTimestamp2000Schema = exports.numberSchema.integer().min(0).min(TS_2000).max(TS_2500);
53
+ /**
54
+ * Between years 1970 and 2050
55
+ */
56
+ exports.unixTimestampMillisSchema = exports.numberSchema
57
+ .integer()
58
+ .min(0)
59
+ .max(TS_2500 * 1000);
60
+ /**
61
+ * Between years 2000 and 2050
62
+ */
63
+ exports.unixTimestampMillis2000Schema = exports.numberSchema
64
+ .integer()
65
+ .min(TS_2000 * 1000)
66
+ .max(TS_2500 * 1000);
45
67
  // 2
46
68
  exports.verSchema = exports.numberSchema.optional().integer().min(1).max(100);
47
69
  /**
@@ -64,11 +86,11 @@ exports.utcOffsetSchema = exports.numberSchema
64
86
  exports.ipAddressSchema = exports.stringSchema.ip();
65
87
  exports.baseDBEntitySchema = objectSchema({
66
88
  id: exports.stringSchema.optional(),
67
- created: exports.unixTimestampSchema.optional(),
68
- updated: exports.unixTimestampSchema.optional(),
89
+ created: exports.unixTimestamp2000Schema.optional(),
90
+ updated: exports.unixTimestamp2000Schema.optional(),
69
91
  });
70
92
  exports.savedDBEntitySchema = objectSchema({
71
93
  id: exports.stringSchema,
72
- created: exports.unixTimestampSchema,
73
- updated: exports.unixTimestampSchema,
94
+ created: exports.unixTimestamp2000Schema,
95
+ updated: exports.unixTimestamp2000Schema,
74
96
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.72.0",
3
+ "version": "12.73.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -57,8 +57,31 @@ export const SLUG_PATTERN = /^[a-z0-9-]*$/
57
57
  */
58
58
  export const slugSchema = stringSchema.regex(/^[a-z0-9-]{1,255}$/)
59
59
 
60
- // 16725225600 is 2500-01-01
61
- export const unixTimestampSchema = numberSchema.integer().min(0).max(16725225600)
60
+ const TS_2500 = 16725225600 // 2500-01-01
61
+ const TS_2000 = 946684800 // 2000-01-01
62
+
63
+ /**
64
+ * Between years 1970 and 2050
65
+ */
66
+ export const unixTimestampSchema = numberSchema.integer().min(0).max(TS_2500)
67
+ /**
68
+ * Between years 2000 and 2050
69
+ */
70
+ export const unixTimestamp2000Schema = numberSchema.integer().min(0).min(TS_2000).max(TS_2500)
71
+ /**
72
+ * Between years 1970 and 2050
73
+ */
74
+ export const unixTimestampMillisSchema = numberSchema
75
+ .integer()
76
+ .min(0)
77
+ .max(TS_2500 * 1000)
78
+ /**
79
+ * Between years 2000 and 2050
80
+ */
81
+ export const unixTimestampMillis2000Schema = numberSchema
82
+ .integer()
83
+ .min(TS_2000 * 1000)
84
+ .max(TS_2500 * 1000)
62
85
 
63
86
  // 2
64
87
  export const verSchema = numberSchema.optional().integer().min(1).max(100)
@@ -88,12 +111,12 @@ export const ipAddressSchema = stringSchema.ip()
88
111
 
89
112
  export const baseDBEntitySchema = objectSchema<BaseDBEntity>({
90
113
  id: stringSchema.optional(),
91
- created: unixTimestampSchema.optional(),
92
- updated: unixTimestampSchema.optional(),
114
+ created: unixTimestamp2000Schema.optional(),
115
+ updated: unixTimestamp2000Schema.optional(),
93
116
  })
94
117
 
95
118
  export const savedDBEntitySchema = objectSchema<SavedDBEntity>({
96
119
  id: stringSchema,
97
- created: unixTimestampSchema,
98
- updated: unixTimestampSchema,
120
+ created: unixTimestamp2000Schema,
121
+ updated: unixTimestamp2000Schema,
99
122
  })