@clairejs/server 3.19.4 → 3.19.6
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/README.md
CHANGED
|
@@ -11,8 +11,8 @@ export declare class ModelRepository<T extends AbstractModel> extends AbstractRe
|
|
|
11
11
|
private getNestedQueries;
|
|
12
12
|
private getUploadHandler;
|
|
13
13
|
private getRequestQueryConditionFromQuery;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
uriHandling(records: Partial<T>[]): Promise<() => Promise<void>>;
|
|
15
|
+
beforeReturning(records: Partial<T>[]): Promise<void>;
|
|
16
16
|
createMany({ principal, body, tx, logger, }: {
|
|
17
17
|
principal?: IPrincipal;
|
|
18
18
|
body: CreateManyRequestBody<T>;
|
|
@@ -121,7 +121,7 @@ export class ModelRepository extends AbstractRepository {
|
|
|
121
121
|
const modified = [];
|
|
122
122
|
const fileUploadHandler = await this.getUploadHandler();
|
|
123
123
|
const operations = [];
|
|
124
|
-
const uriHandler = async (tmpUri, index, uriMapper, locale
|
|
124
|
+
const uriHandler = async (tmpUri, index, uriMapper, locale) => {
|
|
125
125
|
const newUri = uriMapper(tmpUri, index, locale);
|
|
126
126
|
if (!newUri) {
|
|
127
127
|
return;
|
|
@@ -129,23 +129,27 @@ export class ModelRepository extends AbstractRepository {
|
|
|
129
129
|
//-- move from currentUri to newUri
|
|
130
130
|
await fileUploadHandler.copyFile(tmpUri, newUri);
|
|
131
131
|
//-- update record value and not persist yet
|
|
132
|
-
newUriCb(newUri);
|
|
132
|
+
// newUriCb(newUri);
|
|
133
|
+
return newUri;
|
|
133
134
|
};
|
|
134
135
|
if (fileUploadHandler) {
|
|
135
136
|
for (const field of this.modelMetadata.fields) {
|
|
136
137
|
for (const record of records) {
|
|
137
138
|
if (field.uriMapper && record[field.name]) {
|
|
138
139
|
const mapper = field.uriMapper;
|
|
139
|
-
const
|
|
140
|
+
const tmpUris = field.vectorProps
|
|
140
141
|
? record[field.name]
|
|
141
142
|
: [record[field.name]];
|
|
142
|
-
if (!
|
|
143
|
+
if (!tmpUris.length) {
|
|
143
144
|
continue;
|
|
144
145
|
}
|
|
145
146
|
if (!field.mimeProps?.keepOnRemove) {
|
|
146
|
-
modified.push(...
|
|
147
|
+
modified.push(...tmpUris);
|
|
147
148
|
}
|
|
148
|
-
operations.push(
|
|
149
|
+
operations.push((async () => {
|
|
150
|
+
const urls = await Promise.all(tmpUris.map((uri, index) => uriHandler(uri, index, mapper, getSystemLocale())));
|
|
151
|
+
record[field.name] = field.vectorProps ? urls : urls[0];
|
|
152
|
+
})());
|
|
149
153
|
}
|
|
150
154
|
else if (field.multiLocaleColumn) {
|
|
151
155
|
const targetField = this.modelMetadata.fields.find((f) => f.name === field.multiLocaleColumn);
|
|
@@ -163,7 +167,12 @@ export class ModelRepository extends AbstractRepository {
|
|
|
163
167
|
if (!targetField.mimeProps?.keepOnRemove) {
|
|
164
168
|
modified.push(...localeUri[1]);
|
|
165
169
|
}
|
|
166
|
-
operations.push(
|
|
170
|
+
operations.push((async () => {
|
|
171
|
+
const urls = await Promise.all(localeUri[1].map((uri, index) => uriHandler(uri, index, mapper, localeUri[0])));
|
|
172
|
+
record[field.name][localeUri[0]] = targetField.vectorProps
|
|
173
|
+
? urls
|
|
174
|
+
: urls[0];
|
|
175
|
+
})());
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
178
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clairejs/server",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.6",
|
|
4
4
|
"description": "Claire server NodeJs framework written in Typescript.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@clairejs/core": "^3.8.2",
|
|
38
|
-
"@clairejs/orm": "^3.15.
|
|
38
|
+
"@clairejs/orm": "^3.15.10"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/cookie-parser": "^1.4.3",
|