@naturalcycles/js-lib 14.205.0 → 14.205.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', 'created', 'updated']);
320
+ return this.addRequired(['id']);
321
321
  }
322
322
  extend(s2) {
323
323
  const builder = new JsonSchemaObjectBuilder();
@@ -4,8 +4,8 @@ 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(),
8
- updated: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000(),
7
+ created: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000().optional(),
8
+ updated: jsonSchemaBuilder_1.jsonSchema.unixTimestamp2000().optional(),
9
9
  });
10
10
  // export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
11
11
  // id: jsonSchema.string(),
package/dist/types.d.ts CHANGED
@@ -40,14 +40,21 @@ 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;
48
+ };
49
+ export type Saved<T> = T & {
50
+ created: UnixTimestampNumber;
47
51
  updated: UnixTimestampNumber;
48
52
  };
49
- export type Saved<T> = T & BaseDBEntity;
50
- export type Unsaved<T> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & Partial<BaseDBEntity> : T;
53
+ export type Unsaved<T> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & {
54
+ id?: string;
55
+ created?: UnixTimestampNumber;
56
+ updated?: UnixTimestampNumber;
57
+ } : T;
51
58
  export type UnsavedId<T> = Omit<T, 'id'> & {
52
59
  id?: string;
53
60
  };
@@ -26,14 +26,14 @@ export declare const zIdBase64Url: z.ZodString;
26
26
  export declare const zSlug: z.ZodString;
27
27
  export declare const zBaseDBEntity: z.ZodObject<{
28
28
  id: z.ZodString;
29
- created: z.ZodNumber;
30
- updated: z.ZodNumber;
29
+ created: z.ZodOptional<z.ZodNumber>;
30
+ updated: z.ZodOptional<z.ZodNumber>;
31
31
  }, "strip", z.ZodTypeAny, {
32
32
  id: string;
33
- created: number;
34
- updated: number;
33
+ created?: number | undefined;
34
+ updated?: number | undefined;
35
35
  }, {
36
36
  id: string;
37
- created: number;
38
- updated: number;
37
+ created?: number | undefined;
38
+ updated?: number | undefined;
39
39
  }>;
@@ -87,8 +87,8 @@ exports.zSlug = zod_1.z
87
87
  exports.zBaseDBEntity = zod_1.z
88
88
  .object({
89
89
  id: zod_1.z.string(),
90
- created: exports.zUnixTimestamp2000,
91
- updated: exports.zUnixTimestamp2000,
90
+ created: exports.zUnixTimestamp2000.optional(),
91
+ updated: exports.zUnixTimestamp2000.optional(),
92
92
  })
93
93
  .describe('BaseDBEntity');
94
94
  // export const zSavedDBEntity = zBaseDBEntity.required().describe('SavedDBEntity')
@@ -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', 'created', 'updated']);
315
+ return this.addRequired(['id']);
316
316
  }
317
317
  extend(s2) {
318
318
  const builder = new JsonSchemaObjectBuilder();
@@ -1,8 +1,8 @@
1
1
  import { jsonSchema } from './jsonSchemaBuilder';
2
2
  export const baseDBEntityJsonSchema = jsonSchema.object({
3
3
  id: jsonSchema.string(),
4
- created: jsonSchema.unixTimestamp2000(),
5
- updated: jsonSchema.unixTimestamp2000(),
4
+ created: jsonSchema.unixTimestamp2000().optional(),
5
+ updated: jsonSchema.unixTimestamp2000().optional(),
6
6
  });
7
7
  // export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
8
8
  // id: jsonSchema.string(),
@@ -84,8 +84,8 @@ export const zSlug = z
84
84
  export const zBaseDBEntity = z
85
85
  .object({
86
86
  id: z.string(),
87
- created: zUnixTimestamp2000,
88
- updated: zUnixTimestamp2000,
87
+ created: zUnixTimestamp2000.optional(),
88
+ updated: zUnixTimestamp2000.optional(),
89
89
  })
90
90
  .describe('BaseDBEntity');
91
91
  // export const zSavedDBEntity = zBaseDBEntity.required().describe('SavedDBEntity')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.205.0",
3
+ "version": "14.205.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', 'created', 'updated']) as any
377
+ return this.addRequired(['id']) as any
378
378
  }
379
379
 
380
380
  extend<T2 extends AnyObject>(s2: JsonSchemaObjectBuilder<T2>): JsonSchemaObjectBuilder<T & T2> {
@@ -3,8 +3,8 @@ import { jsonSchema } from './jsonSchemaBuilder'
3
3
 
4
4
  export const baseDBEntityJsonSchema = jsonSchema.object<BaseDBEntity>({
5
5
  id: jsonSchema.string(),
6
- created: jsonSchema.unixTimestamp2000(),
7
- updated: jsonSchema.unixTimestamp2000(),
6
+ created: jsonSchema.unixTimestamp2000().optional(),
7
+ updated: jsonSchema.unixTimestamp2000().optional(),
8
8
  })
9
9
 
10
10
  // export const savedDBEntityJsonSchema = jsonSchema.object<SavedDBEntity>({
package/src/types.ts CHANGED
@@ -53,18 +53,25 @@ 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
- export type Saved<T> = T & BaseDBEntity
64
+ export type Saved<T> = T & {
65
+ created: UnixTimestampNumber
66
+ updated: UnixTimestampNumber
67
+ }
65
68
 
66
69
  export type Unsaved<T> = T extends AnyObject
67
- ? Omit<T, 'id' | 'created' | 'updated'> & Partial<BaseDBEntity>
70
+ ? Omit<T, 'id' | 'created' | 'updated'> & {
71
+ id?: string
72
+ created?: UnixTimestampNumber
73
+ updated?: UnixTimestampNumber
74
+ }
68
75
  : T
69
76
 
70
77
  export type UnsavedId<T> = Omit<T, 'id'> & {
@@ -94,8 +94,8 @@ export const zSlug = z
94
94
  export const zBaseDBEntity = z
95
95
  .object({
96
96
  id: z.string(),
97
- created: zUnixTimestamp2000,
98
- updated: zUnixTimestamp2000,
97
+ created: zUnixTimestamp2000.optional(),
98
+ updated: zUnixTimestamp2000.optional(),
99
99
  })
100
100
  .describe('BaseDBEntity')
101
101