@rws-framework/db 1.0.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.
@@ -0,0 +1,35 @@
1
+ export class FieldsHelper {
2
+ private constructor(){
3
+ throw new Error(`Class ${this.constructor.name} cannot be instanced.`)
4
+ }
5
+
6
+ static getAllClassFields(target: any): string[] {
7
+ // Get instance properties
8
+ const instanceFields = Object.getOwnPropertyNames(target.prototype);
9
+
10
+ // Get static properties
11
+ const staticFields = Object.getOwnPropertyNames(target);
12
+
13
+ // Get decorated properties using Reflect metadata if available
14
+ const decoratedFields = Reflect.getMetadataKeys(target.prototype) || [];
15
+
16
+ // Combine all fields and remove duplicates and methods
17
+ const allFields = new Set([
18
+ ...instanceFields,
19
+ ...staticFields,
20
+ ...decoratedFields
21
+ ]);
22
+
23
+ // Filter out constructor and methods
24
+ return Array.from(allFields).filter(field => {
25
+ // Remove constructor
26
+ if (field === 'constructor') return false;
27
+
28
+ // Remove methods
29
+ const descriptor = Object.getOwnPropertyDescriptor(target.prototype, field);
30
+ if (descriptor && typeof descriptor.value === 'function') return false;
31
+
32
+ return true;
33
+ });
34
+ };
35
+ }
package/src/index.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { DBService } from "./services/DBService";
2
+ import { RWSModel, OpModelType } from "./models/_model";
3
+ import TimeSeriesModel from './models/TimeSeriesModel';
4
+ import { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts } from './decorators';
5
+
6
+ import { DbHelper } from './helper/DbHelper';
7
+ import { FieldsHelper } from './helper/FieldsHelper';
8
+
9
+ import type { FindByType } from './types/FindParams';
10
+ import type { ITimeSeries } from './types/ITimeSeries';
11
+ import type { IDbConfigHandler } from './types/DbConfigHandler';
12
+ import type { IRWSModel } from './types/IRWSModel';
13
+
14
+
15
+ export {
16
+ OpModelType,
17
+ RWSModel,
18
+ IRWSModel,
19
+ IMetaOpts,
20
+
21
+ DBService,
22
+
23
+ FindByType,
24
+ TimeSeriesModel,
25
+ ITimeSeries,
26
+
27
+ IDbConfigHandler,
28
+
29
+ InverseRelation, Relation, TrackType, InverseTimeSeries,
30
+
31
+ DbHelper,
32
+ FieldsHelper
33
+ };
@@ -0,0 +1,18 @@
1
+ import { RWSModel, TrackType } from './_model';
2
+
3
+ export default class TimeSeriesModel<ChildClass> extends RWSModel<TimeSeriesModel<ChildClass>>{
4
+ @TrackType(Number) value: number;
5
+
6
+ @TrackType(Date) timestamp: Date;
7
+
8
+ @TrackType(Object)
9
+ params: any;
10
+
11
+ constructor(data?: any) {
12
+ super(data);
13
+
14
+ if(!this.timestamp) {
15
+ this.timestamp = new Date();
16
+ }
17
+ }
18
+ }