@naturalcycles/js-lib 14.161.0 → 14.161.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.
@@ -1,3 +1,3 @@
1
- import type { SavedDBEntity } from '../types';
2
- export declare const baseDBEntityJsonSchema: import("./jsonSchemaBuilder").JsonSchemaObjectBuilder<Partial<SavedDBEntity<string>>>;
1
+ import type { BaseDBEntity, SavedDBEntity } from '../types';
2
+ export declare const baseDBEntityJsonSchema: import("./jsonSchemaBuilder").JsonSchemaObjectBuilder<BaseDBEntity<string>>;
3
3
  export declare const savedDBEntityJsonSchema: import("./jsonSchemaBuilder").JsonSchemaObjectBuilder<SavedDBEntity<string>>;
package/dist/types.d.ts CHANGED
@@ -47,7 +47,17 @@ export interface SavedDBEntity<ID extends string | number = string> {
47
47
  * hence `id`, `created` and `updated` fields CAN BE undefined (yet).
48
48
  * When it's known to be saved - `SavedDBEntity` interface can be used instead.
49
49
  */
50
- export type BaseDBEntity<ID extends string | number = string> = Partial<SavedDBEntity<ID>>;
50
+ export interface BaseDBEntity<ID extends string | number = string> {
51
+ id?: ID;
52
+ /**
53
+ * unixTimestamp of when the entity was first created (in the DB).
54
+ */
55
+ created?: UnixTimestampNumber;
56
+ /**
57
+ * unixTimestamp of when the entity was last updated (in the DB).
58
+ */
59
+ updated?: UnixTimestampNumber;
60
+ }
51
61
  export type Saved<T extends Partial<ObjectWithId>> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']>> : T;
52
62
  export type Unsaved<T extends Partial<ObjectWithId>> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity<NonNullable<T['id']>> : T;
53
63
  export type UnsavedId<T extends Partial<ObjectWithId>> = Omit<T, 'id'> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.161.0",
3
+ "version": "14.161.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
package/src/types.ts CHANGED
@@ -60,7 +60,19 @@ export interface SavedDBEntity<ID extends string | number = string> {
60
60
  * hence `id`, `created` and `updated` fields CAN BE undefined (yet).
61
61
  * When it's known to be saved - `SavedDBEntity` interface can be used instead.
62
62
  */
63
- export type BaseDBEntity<ID extends string | number = string> = Partial<SavedDBEntity<ID>>
63
+ export interface BaseDBEntity<ID extends string | number = string> {
64
+ id?: ID
65
+
66
+ /**
67
+ * unixTimestamp of when the entity was first created (in the DB).
68
+ */
69
+ created?: UnixTimestampNumber
70
+
71
+ /**
72
+ * unixTimestamp of when the entity was last updated (in the DB).
73
+ */
74
+ updated?: UnixTimestampNumber
75
+ }
64
76
 
65
77
  export type Saved<T extends Partial<ObjectWithId>> = T extends AnyObject
66
78
  ? Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']>>