@naturalcycles/js-lib 14.205.2 → 14.206.1

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.
@@ -317,7 +317,7 @@ class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
317
317
  created: { type: 'number', format: 'unixTimestamp2000' },
318
318
  updated: { type: 'number', format: 'unixTimestamp2000' },
319
319
  });
320
- return this.addRequired(['id']);
320
+ return this.addRequired(['id', 'created', 'updated']);
321
321
  }
322
322
  extend(s2) {
323
323
  const builder = new JsonSchemaObjectBuilder();
@@ -4,11 +4,6 @@ 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(),
7
- created: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000().optional(),
8
- updated: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000().optional(),
7
+ created: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000(),
8
+ updated: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000(),
9
9
  });
10
- // export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
11
- // id: jsonSchema.string(),
12
- // created: jsonSchema.unixTimestamp2000(),
13
- // updated: jsonSchema.unixTimestamp2000(),
14
- // })
package/dist/types.d.ts CHANGED
@@ -40,17 +40,20 @@ export type BaseDBEntity = {
40
40
  /**
41
41
  * unixTimestamp of when the entity was first created (in the DB).
42
42
  */
43
- created?: UnixTimestampNumber;
43
+ created: UnixTimestampNumber;
44
44
  /**
45
45
  * unixTimestamp of when the entity was last updated (in the DB).
46
46
  */
47
- updated?: UnixTimestampNumber;
47
+ updated: UnixTimestampNumber;
48
48
  };
49
49
  export type Saved<T> = T & {
50
50
  id: string;
51
51
  created: UnixTimestampNumber;
52
52
  updated: UnixTimestampNumber;
53
53
  };
54
+ export type SavedId<T> = T & {
55
+ id: string;
56
+ };
54
57
  export type Unsaved<T> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & {
55
58
  id?: string;
56
59
  created?: UnixTimestampNumber;
@@ -87,6 +87,7 @@ exports.zSlug = zod_1.z
87
87
  exports.zBaseDBEntity = zod_1.z
88
88
  .object({
89
89
  id: zod_1.z.string(),
90
+ // created/updated are intentionally optional here
90
91
  created: exports.zUnixTimestamp2000.optional(),
91
92
  updated: exports.zUnixTimestamp2000.optional(),
92
93
  })
@@ -312,7 +312,7 @@ export class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
312
312
  created: { type: 'number', format: 'unixTimestamp2000' },
313
313
  updated: { type: 'number', format: 'unixTimestamp2000' },
314
314
  });
315
- return this.addRequired(['id']);
315
+ return this.addRequired(['id', 'created', 'updated']);
316
316
  }
317
317
  extend(s2) {
318
318
  const builder = new JsonSchemaObjectBuilder();
@@ -1,11 +1,6 @@
1
1
  import { jsonSchema } from './jsonSchemaBuilder';
2
2
  export const baseDBEntityJsonSchema = jsonSchema.object({
3
3
  id: jsonSchema.string(),
4
- created: jsonSchema.unixTimestamp2000().optional(),
5
- updated: jsonSchema.unixTimestamp2000().optional(),
4
+ created: jsonSchema.unixTimestamp2000(),
5
+ updated: jsonSchema.unixTimestamp2000(),
6
6
  });
7
- // export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
8
- // id: jsonSchema.string(),
9
- // created: jsonSchema.unixTimestamp2000(),
10
- // updated: jsonSchema.unixTimestamp2000(),
11
- // })
@@ -84,6 +84,7 @@ export const zSlug = z
84
84
  export const zBaseDBEntity = z
85
85
  .object({
86
86
  id: z.string(),
87
+ // created/updated are intentionally optional here
87
88
  created: zUnixTimestamp2000.optional(),
88
89
  updated: zUnixTimestamp2000.optional(),
89
90
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.205.2",
3
+ "version": "14.206.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -374,7 +374,7 @@ export class JsonSchemaObjectBuilder<T extends AnyObject> extends JsonSchemaAnyB
374
374
  updated: { type: 'number', format: 'unixTimestamp2000' },
375
375
  })
376
376
 
377
- return this.addRequired(['id']) as any
377
+ return this.addRequired(['id', 'created', 'updated']) as any
378
378
  }
379
379
 
380
380
  extend<T2 extends AnyObject>(s2: JsonSchemaObjectBuilder<T2>): JsonSchemaObjectBuilder<T & T2> {
@@ -3,12 +3,6 @@ import { jsonSchema } from './jsonSchemaBuilder'
3
3
 
4
4
  export const baseDBEntityJsonSchema = jsonSchema.object<BaseDBEntity>({
5
5
  id: jsonSchema.string(),
6
- created: jsonSchema.unixTimestamp2000().optional(),
7
- updated: jsonSchema.unixTimestamp2000().optional(),
6
+ created: jsonSchema.unixTimestamp2000(),
7
+ updated: jsonSchema.unixTimestamp2000(),
8
8
  })
9
-
10
- // export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
11
- // id: jsonSchema.string(),
12
- // created: jsonSchema.unixTimestamp2000(),
13
- // updated: jsonSchema.unixTimestamp2000(),
14
- // })
package/src/types.ts CHANGED
@@ -53,12 +53,12 @@ export type BaseDBEntity = {
53
53
  /**
54
54
  * unixTimestamp of when the entity was first created (in the DB).
55
55
  */
56
- created?: UnixTimestampNumber
56
+ created: UnixTimestampNumber
57
57
 
58
58
  /**
59
59
  * unixTimestamp of when the entity was last updated (in the DB).
60
60
  */
61
- updated?: UnixTimestampNumber
61
+ updated: UnixTimestampNumber
62
62
  }
63
63
 
64
64
  export type Saved<T> = T & {
@@ -67,6 +67,10 @@ export type Saved<T> = T & {
67
67
  updated: UnixTimestampNumber
68
68
  }
69
69
 
70
+ export type SavedId<T> = T & {
71
+ id: string
72
+ }
73
+
70
74
  export type Unsaved<T> = T extends AnyObject
71
75
  ? Omit<T, 'id' | 'created' | 'updated'> & {
72
76
  id?: string
@@ -94,6 +94,7 @@ export const zSlug = z
94
94
  export const zBaseDBEntity = z
95
95
  .object({
96
96
  id: z.string(),
97
+ // created/updated are intentionally optional here
97
98
  created: zUnixTimestamp2000.optional(),
98
99
  updated: zUnixTimestamp2000.optional(),
99
100
  })