@coasys/hooks-helpers 0.9.1-prerelease → 0.9.1-prerelease.5
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.
- package/package.json +3 -3
- package/src/factory/SubjectRepository.ts +15 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coasys/hooks-helpers",
|
|
3
|
-
"version": "0.9.1-prerelease",
|
|
3
|
+
"version": "0.9.1-prerelease.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@coasys/ad4m": "
|
|
19
|
-
"@coasys/ad4m-connect": "
|
|
18
|
+
"@coasys/ad4m": "0.9.1-prerelease.1",
|
|
19
|
+
"@coasys/ad4m-connect": "0.9.1-prerelease.1",
|
|
20
20
|
"uuid": "*"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -73,8 +73,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
async update(id: string, data: QueryPartialEntity<SubjectClass>) {
|
|
76
|
-
await this.ensureSubject();
|
|
77
|
-
|
|
78
76
|
const instance = await this.get(id);
|
|
79
77
|
|
|
80
78
|
if (!instance) {
|
|
@@ -102,8 +100,8 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
|
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
async get(id: string): Promise<SubjectClass | null> {
|
|
105
|
-
await this.ensureSubject();
|
|
106
103
|
if (id) {
|
|
104
|
+
await this.ensureSubject();
|
|
107
105
|
const subjectProxy = await this.perspective.getSubjectProxy(
|
|
108
106
|
id,
|
|
109
107
|
this.subject
|
|
@@ -118,7 +116,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
|
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
async getData(id: string): Promise<SubjectClass | string | null> {
|
|
121
|
-
await this.ensureSubject();
|
|
122
119
|
const entry = await this.get(id);
|
|
123
120
|
if (entry) {
|
|
124
121
|
// @ts-ignore
|
|
@@ -133,28 +130,21 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
|
|
|
133
130
|
new LinkQuery({ source: entry.baseExpression })
|
|
134
131
|
);
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
.filter(([key, descriptor]) => typeof descriptor.get === "function")
|
|
138
|
-
.map(([key]) => key);
|
|
139
|
-
|
|
140
|
-
const promises = getters.map((getter) => entry[getter]);
|
|
141
|
-
return Promise.all(promises).then((values) => {
|
|
142
|
-
return getters.reduce((acc, getter, index) => {
|
|
143
|
-
let value = values[index];
|
|
144
|
-
if (this.tempSubject.prototype?.__properties[getter]?.transform) {
|
|
145
|
-
value =
|
|
146
|
-
this.tempSubject.prototype.__properties[getter].transform(value);
|
|
147
|
-
}
|
|
133
|
+
let data: any = await this.perspective.getSubjectData(this.subject, entry.baseExpression)
|
|
148
134
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
for (const key in data) {
|
|
136
|
+
if (this.tempSubject.prototype?.__properties[key]?.transform) {
|
|
137
|
+
data[key] =
|
|
138
|
+
this.tempSubject.prototype.__properties[key].transform(data[key]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
id: entry.baseExpression,
|
|
144
|
+
timestamp: links[0].timestamp,
|
|
145
|
+
author: links[0].author,
|
|
146
|
+
...data,
|
|
147
|
+
}
|
|
158
148
|
}
|
|
159
149
|
|
|
160
150
|
async getAll(source?: string, query?: QueryOptions): Promise<SubjectClass[]> {
|
|
@@ -232,8 +222,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
|
|
|
232
222
|
source?: string,
|
|
233
223
|
query?: QueryOptions
|
|
234
224
|
): Promise<SubjectClass[]> {
|
|
235
|
-
await this.ensureSubject();
|
|
236
|
-
|
|
237
225
|
const subjects = await this.getAll(source, query);
|
|
238
226
|
|
|
239
227
|
const entries = await Promise.all(
|