mobiletto-orm-typedef-gen 2.3.17 → 2.3.19
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.
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{{{header}}}{{/if}}{{/if}}
|
|
4
4
|
|
|
5
5
|
import { H3Event } from "h3";
|
|
6
|
-
import { MobilettoOrmValidationErrors } from "mobiletto-orm-typedef";
|
|
6
|
+
import { MobilettoOrmNotFoundError, MobilettoOrmValidationErrors } from "mobiletto-orm-typedef";
|
|
7
7
|
import { {{Name}}Type, {{Name}}TypeDef } from "{{typeDefPackage}}";
|
|
8
8
|
|
|
9
9
|
export default defineEventHandler(async (event: H3Event) => {
|
|
@@ -35,7 +35,14 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
35
35
|
throw validationError({global: ["validation"]});
|
|
36
36
|
}
|
|
37
37
|
}{{/if}}
|
|
38
|
-
|
|
38
|
+
{{#if typeDef.singleton}}try {
|
|
39
|
+
return await {{name}}Repo.update(obj);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e instanceof MobilettoOrmNotFoundError) {
|
|
42
|
+
return await {{name}}Repo.create(obj);
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}{{else}}return await {{name}}Repo.update(obj);{{/if}}
|
|
39
46
|
}{{#if typeDef.apiConfig.update.permission.admin}}
|
|
40
47
|
});{{else}}{{#if typeDef.apiConfig.update.permission.owner}}
|
|
41
48
|
});{{else}}{{#if typeDef.apiConfig.update.permission.session}}
|
|
@@ -398,11 +398,11 @@
|
|
|
398
398
|
{{#if typeDef.refTypes}}const refSearches: Promise<{{RefType}}[]>[] = [];{{#each typeDef.refTypes}}
|
|
399
399
|
refSearches.push({{refType}}Store.search());{{/each}}
|
|
400
400
|
await Promise.all(refSearches);
|
|
401
|
-
{{/if}}{{#if typeDef.singleton}}return {{name}}Store.lookup(findSingleton{{Name}}ServerErrors);{{/if}}
|
|
401
|
+
{{/if}}{{#if typeDef.singleton}}return await {{name}}Store.lookup(findSingleton{{Name}}ServerErrors);{{/if}}
|
|
402
402
|
};{{#if typeDef.singleton}}
|
|
403
403
|
initRefs()
|
|
404
404
|
.then(obj => showEditOrm(obj))
|
|
405
|
-
.catch(
|
|
405
|
+
.catch(_e => showAddOrm());
|
|
406
406
|
{{else}}
|
|
407
407
|
|
|
408
408
|
{{name}}Store.search(){{#if typeDef.refTypes}}.then(() => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{{{header}}}{{/if}}{{/if}}
|
|
4
4
|
|
|
5
5
|
import { H3Event } from "h3";
|
|
6
|
-
import { MobilettoOrmValidationErrors } from "mobiletto-orm-typedef";
|
|
6
|
+
import { MobilettoOrmNotFoundError, MobilettoOrmValidationErrors } from "mobiletto-orm-typedef";
|
|
7
7
|
import { {{Name}}Type, {{Name}}TypeDef } from "{{typeDefPackage}}";
|
|
8
8
|
|
|
9
9
|
export default defineEventHandler(async (event: H3Event) => {
|
|
@@ -35,7 +35,14 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
35
35
|
throw validationError({global: ["validation"]});
|
|
36
36
|
}
|
|
37
37
|
}{{/if}}
|
|
38
|
-
|
|
38
|
+
{{#if typeDef.singleton}}try {
|
|
39
|
+
return await {{name}}Repo.update(obj);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e instanceof MobilettoOrmNotFoundError) {
|
|
42
|
+
return await {{name}}Repo.create(obj);
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}{{else}}return await {{name}}Repo.update(obj);{{/if}}
|
|
39
46
|
}{{#if typeDef.apiConfig.update.permission.admin}}
|
|
40
47
|
});{{else}}{{#if typeDef.apiConfig.update.permission.owner}}
|
|
41
48
|
});{{else}}{{#if typeDef.apiConfig.update.permission.session}}
|
|
@@ -398,11 +398,11 @@
|
|
|
398
398
|
{{#if typeDef.refTypes}}const refSearches: Promise<{{RefType}}[]>[] = [];{{#each typeDef.refTypes}}
|
|
399
399
|
refSearches.push({{refType}}Store.search());{{/each}}
|
|
400
400
|
await Promise.all(refSearches);
|
|
401
|
-
{{/if}}{{#if typeDef.singleton}}return {{name}}Store.lookup(findSingleton{{Name}}ServerErrors);{{/if}}
|
|
401
|
+
{{/if}}{{#if typeDef.singleton}}return await {{name}}Store.lookup(findSingleton{{Name}}ServerErrors);{{/if}}
|
|
402
402
|
};{{#if typeDef.singleton}}
|
|
403
403
|
initRefs()
|
|
404
404
|
.then(obj => showEditOrm(obj))
|
|
405
|
-
.catch(
|
|
405
|
+
.catch(_e => showAddOrm());
|
|
406
406
|
{{else}}
|
|
407
407
|
|
|
408
408
|
{{name}}Store.search(){{#if typeDef.refTypes}}.then(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobiletto-orm-typedef-gen",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "generate various files based on mobiletto-orm-typedef definitions",
|
|
6
6
|
"keywords": [
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"eslint-config-prettier": "^8.8.0",
|
|
54
54
|
"handlebars": "^4.7.7",
|
|
55
55
|
"hokey-runtime": "^1.0.4",
|
|
56
|
-
"mobiletto-orm-typedef": "^2.3.
|
|
56
|
+
"mobiletto-orm-typedef": "^2.3.23",
|
|
57
57
|
"mocha": "^10.2.0",
|
|
58
58
|
"prettier": "^3.0.0",
|
|
59
59
|
"tslint-config-prettier": "^1.18.0",
|