@simitgroup/simpleapp-generator 1.6.4-e-alpha → 1.6.4-g-alpha
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/ReleaseNote.md +13 -0
- package/dist/buildinschemas/index.d.ts +0 -1
- package/dist/buildinschemas/index.d.ts.map +1 -1
- package/dist/buildinschemas/index.js +1 -3
- package/dist/buildinschemas/index.js.map +1 -1
- package/dist/buildinschemas/systemmessage.js +3 -3
- package/dist/buildinschemas/systemmessage.js.map +1 -1
- package/dist/buildinschemas/user.d.ts.map +1 -1
- package/dist/buildinschemas/user.js +7 -0
- package/dist/buildinschemas/user.js.map +1 -1
- package/dist/buildinschemas/webhook.d.ts.map +1 -1
- package/dist/buildinschemas/webhook.js +20 -5
- package/dist/buildinschemas/webhook.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/index.ts +0 -1
- package/src/buildinschemas/systemmessage.ts +3 -3
- package/src/buildinschemas/user.ts +7 -0
- package/src/buildinschemas/webhook.ts +21 -7
- package/templates/basic/nest/controller.ts.eta +3 -3
- package/templates/nest/.env._eta +7 -0
- package/templates/nest/src/app.module.ts.eta +12 -5
- package/templates/nest/src/main.ts.eta +30 -0
- package/templates/nest/src/simpleapp/generate/apischemas/simpleapp.apischema.ts.eta +32 -12
- package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +31 -26
- package/templates/nest/src/simpleapp/generate/commons/customkeycloa.guard.ts.eta +43 -0
- package/templates/nest/src/simpleapp/generate/commons/dicts/documents.ts.eta +2 -1
- package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +31 -5
- package/templates/nest/src/simpleapp/generate/commons/robotuser.service.ts.eta +15 -17
- package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +161 -29
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +17 -2
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +4 -6
- package/templates/nest/src/simpleapp/generate/processors/webhook.processor.ts.eta +224 -0
- package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +113 -110
- package/templates/nuxt/components/image/ImageAvatar.vue.eta._vue +47 -13
- package/templates/nuxt/components/image/ImageToBase64Uploader.vue.eta.vue +5 -5
- package/templates/nuxt/components/renderer/RendererDocHistories.vue.eta +8 -5
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +25 -18
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +13 -9
- package/templates/nuxt/pages/profile.vue.eta +3 -1
- package/templates/nuxt/server/api/profile/[...].ts.eta +11 -2
- package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +3 -1
- package/templates/nuxt/types/others.ts.eta +1 -0
- package/templates/nuxt/types/simpleappinput.ts.eta +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/buildinschemas/webhookhistory.ts +0 -42
package/ReleaseNote.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
[1.6.5g]
|
|
2
|
+
1. change simpleapp document controller use document name instead of document type
|
|
3
|
+
2. allow use header x-apikey(match env X_APIKEY), x-apisecret (match env X_APISECRET), to by pass access token. which will use robotuser in user context
|
|
4
|
+
3. add support of x-guest-accesstoken (submit by external user source, like parent/student app), it store into usercontext as guestinfo, since appuser = robotuser
|
|
5
|
+
4. Fix document search properties to restrict (required field and sorts)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[1.6.5f]
|
|
9
|
+
1. added webhook db
|
|
10
|
+
2. support audit trail
|
|
11
|
+
3. support upload avatar to cloudapi
|
|
12
|
+
4. added html input for simpleapp
|
|
13
|
+
|
|
1
14
|
[1.2.0]
|
|
2
15
|
1. lot of house keeping
|
|
3
16
|
2. frontend more stable login using keycloak
|
|
@@ -7,6 +7,5 @@ export { docnoformat } from './docnoformat';
|
|
|
7
7
|
export { systemmessage } from './systemmessage';
|
|
8
8
|
export { keyvaluepair } from './keyvaluepair';
|
|
9
9
|
export { webhook } from './webhook';
|
|
10
|
-
export { webhookhistory } from './webhookhistory';
|
|
11
10
|
export { documentevent } from './documentevent';
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.documentevent = exports.
|
|
3
|
+
exports.documentevent = exports.webhook = exports.keyvaluepair = exports.systemmessage = exports.docnoformat = exports.autoincreament = exports.permission = exports.branch = exports.organization = exports.tenant = void 0;
|
|
4
4
|
var tenant_1 = require("./tenant");
|
|
5
5
|
Object.defineProperty(exports, "tenant", { enumerable: true, get: function () { return tenant_1.tenant; } });
|
|
6
6
|
var organization_1 = require("./organization");
|
|
@@ -20,8 +20,6 @@ var keyvaluepair_1 = require("./keyvaluepair");
|
|
|
20
20
|
Object.defineProperty(exports, "keyvaluepair", { enumerable: true, get: function () { return keyvaluepair_1.keyvaluepair; } });
|
|
21
21
|
var webhook_1 = require("./webhook");
|
|
22
22
|
Object.defineProperty(exports, "webhook", { enumerable: true, get: function () { return webhook_1.webhook; } });
|
|
23
|
-
var webhookhistory_1 = require("./webhookhistory");
|
|
24
|
-
Object.defineProperty(exports, "webhookhistory", { enumerable: true, get: function () { return webhookhistory_1.webhookhistory; } });
|
|
25
23
|
var documentevent_1 = require("./documentevent");
|
|
26
24
|
Object.defineProperty(exports, "documentevent", { enumerable: true, get: function () { return documentevent_1.documentevent; } });
|
|
27
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildinschemas/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAAvB,gGAAA,MAAM,OAAA;AACd,+CAA2C;AAAnC,4GAAA,YAAY,OAAA;AACpB,mCAA+B;AAAvB,gGAAA,MAAM,OAAA;AACd,2CAAuC;AAA/B,wGAAA,UAAU,OAAA;AAClB,8BAA8B;AAC9B,mDAA+C;AAAvC,gHAAA,cAAc,OAAA;AACtB,6CAAyC;AAAjC,0GAAA,WAAW,OAAA;AACnB,iDAA6C;AAArC,8GAAA,aAAa,OAAA;AACrB,+CAA2C;AAAnC,4GAAA,YAAY,OAAA;AACpB,qCAAiC;AAAzB,kGAAA,OAAO,OAAA;AACf,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildinschemas/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAAvB,gGAAA,MAAM,OAAA;AACd,+CAA2C;AAAnC,4GAAA,YAAY,OAAA;AACpB,mCAA+B;AAAvB,gGAAA,MAAM,OAAA;AACd,2CAAuC;AAA/B,wGAAA,UAAU,OAAA;AAClB,8BAA8B;AAC9B,mDAA+C;AAAvC,gHAAA,cAAc,OAAA;AACtB,6CAAyC;AAAjC,0GAAA,WAAW,OAAA;AACnB,iDAA6C;AAArC,8GAAA,aAAa,OAAA;AACrB,+CAA2C;AAAnC,4GAAA,YAAY,OAAA;AACpB,qCAAiC;AAAzB,kGAAA,OAAO,OAAA;AACf,iDAA6C;AAArC,8GAAA,aAAa,OAAA"}
|
|
@@ -28,15 +28,15 @@ exports.systemmessage = {
|
|
|
28
28
|
"orgId": { "type": "integer", "default": 1 },
|
|
29
29
|
"branchId": { "type": "integer", "default": 1 },
|
|
30
30
|
"uid": { "type": "string", "format": "uuid" },
|
|
31
|
+
"messageType": { "type": "string", minLength: 3 },
|
|
31
32
|
"messageTitle": {
|
|
32
33
|
"type": "string",
|
|
33
34
|
"minLength": 3
|
|
34
35
|
},
|
|
35
36
|
"read": { "type": "boolean", "default": false },
|
|
36
|
-
"
|
|
37
|
-
"description": {
|
|
37
|
+
"body": {
|
|
38
38
|
"type": "string",
|
|
39
|
-
"format": "
|
|
39
|
+
"format": "html"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemmessage.js","sourceRoot":"","sources":["../../src/buildinschemas/systemmessage.ts"],"names":[],"mappings":";;;AAAA,kCAA4D;AAE/C,QAAA,aAAa,GAC1B;IACI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EAAE,QAAQ;YAChB,QAAQ,EAAE,MAAM;SACjB;KACF;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAA2B,MAAM,SAAS,CAAA;AAE5D,eAAO,MAAM,IAAI,EAAC,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAA2B,MAAM,SAAS,CAAA;AAE5D,eAAO,MAAM,IAAI,EAAC,UA4DjB,CAAA"}
|
|
@@ -47,6 +47,13 @@ exports.user = {
|
|
|
47
47
|
},
|
|
48
48
|
fullName: { type: "string", minLength: 3 },
|
|
49
49
|
email: { type: "string", minLength: 10, format: "email" },
|
|
50
|
+
mobileNo: {
|
|
51
|
+
type: "string",
|
|
52
|
+
anyOf: [
|
|
53
|
+
{ "const": "" },
|
|
54
|
+
{ "format": "tel", "examples": ["0123456789"] }
|
|
55
|
+
]
|
|
56
|
+
},
|
|
50
57
|
active: { type: "boolean", default: true },
|
|
51
58
|
description: { type: "string" },
|
|
52
59
|
lastActivity: { type: "string", description: "capture ISO8601 last api call" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/buildinschemas/user.ts"],"names":[],"mappings":";;;AAAA,kCAA4D;AAE/C,QAAA,IAAI,GAAa;IAC1B,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAC;QACjB,YAAY,EAAC,MAAM;QACnB,YAAY,EAAC,MAAM;QACnB,QAAQ,EAAC,MAAM;QACf,iBAAiB,EAAC,IAAI;QACtB,aAAa,EAAC,oBAAa,CAAC,MAAM;QAClC,SAAS,EAAC,OAAO;QACjB,aAAa,EAAC,UAAU;QACxB,aAAa,EAAC,CAAC,WAAW,CAAC;QAC3B,4BAA4B,EAAC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QAAQ,EAAC;QAC5B,YAAY,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,WAAW,EAAC,+BAA+B,EAAC;QAC1E,cAAc,EAAE;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,UAAU,CAAC,EAAE;SACtD;KACF;CACN,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAA2B,MAAM,SAAS,CAAA;AAE5D,eAAO,MAAM,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAA2B,MAAM,SAAS,CAAA;AAE5D,eAAO,MAAM,OAAO,EAAC,UA4DpB,CAAA"}
|
|
@@ -8,10 +8,10 @@ exports.webhook = {
|
|
|
8
8
|
documentType: 'webhook',
|
|
9
9
|
documentName: 'webhook',
|
|
10
10
|
isolationType: type_1.IsolationType.tenant,
|
|
11
|
-
uniqueKey: '
|
|
12
|
-
documentTitle: '
|
|
11
|
+
uniqueKey: 'title',
|
|
12
|
+
documentTitle: 'title'
|
|
13
13
|
},
|
|
14
|
-
required: ["
|
|
14
|
+
required: ["title", "url"],
|
|
15
15
|
properties: {
|
|
16
16
|
_id: { type: 'string' },
|
|
17
17
|
created: { type: 'string' },
|
|
@@ -21,8 +21,10 @@ exports.webhook = {
|
|
|
21
21
|
tenantId: { type: 'integer', default: 1, minimum: 0 },
|
|
22
22
|
orgId: { type: 'integer', default: 1, minimum: 0 },
|
|
23
23
|
branchId: { type: 'integer', default: 1, minimum: 0 },
|
|
24
|
-
|
|
24
|
+
title: { type: "string", minLength: 3, },
|
|
25
25
|
url: { type: "string", format: 'uri' },
|
|
26
|
+
serverSubscriptionId: { type: "string" },
|
|
27
|
+
serverSubscriptionSecret: { type: "string" },
|
|
26
28
|
requestMethod: {
|
|
27
29
|
type: "string",
|
|
28
30
|
enum: ['post', 'get', 'patch', 'put', 'delete', 'head'],
|
|
@@ -32,6 +34,13 @@ exports.webhook = {
|
|
|
32
34
|
enum: ['none', 'basic'],
|
|
33
35
|
description: "apikey authentication use none + headers props"
|
|
34
36
|
},
|
|
37
|
+
basicAuth: {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
user: { type: "string" },
|
|
41
|
+
password: { type: "string" }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
35
44
|
headers: {
|
|
36
45
|
type: "array",
|
|
37
46
|
items: {
|
|
@@ -45,7 +54,13 @@ exports.webhook = {
|
|
|
45
54
|
},
|
|
46
55
|
description: { type: "string", format: "text" },
|
|
47
56
|
active: { type: "boolean", default: true },
|
|
48
|
-
|
|
57
|
+
eventTypes: {
|
|
58
|
+
type: "array",
|
|
59
|
+
minItems: 1,
|
|
60
|
+
items: {
|
|
61
|
+
type: "string"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
49
64
|
}
|
|
50
65
|
};
|
|
51
66
|
//# sourceMappingURL=webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/buildinschemas/webhook.ts"],"names":[],"mappings":";;;AAAA,kCAA4D;AAE/C,QAAA,OAAO,GAAc;IAC9B,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAC;QACnB,YAAY,EAAC,SAAS;QACtB,YAAY,EAAC,SAAS;QACtB,aAAa,EAAC,oBAAa,CAAC,MAAM;QAClC,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/buildinschemas/webhook.ts"],"names":[],"mappings":";;;AAAA,kCAA4D;AAE/C,QAAA,OAAO,GAAc;IAC9B,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAC;QACnB,YAA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EAAC,gDAAgD;SAC7D;QACD,SAAS,EAAC;YACR,IAAI,EAAC,QAAQ;YACb,UAAU,EAAC;gBACT,IAAI,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC;gBACpB,QAAQ,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC;aACzB;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,OAAO;YACb,KAAK,EAAC;gBACJ,IAAI,EAAC,QAAQ;gBACb,WAAW,EAAC,cAAc;gBAC1B,UAAU,EAAC;oBACT,IAAI,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC;oBACpB,KAAK,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC;iBACtB;aACF;SACF;QAED,WAAW,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,EAAC,MAAM,EAAC;QAC3C,MAAM,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAC,IAAI,EAAC;QACvC,UAAU,EAAC;YACT,IAAI,EAAC,OAAO;YACZ,QAAQ,EAAC,CAAC;YACV,KAAK,EAAC;gBACJ,IAAI,EAAC,QAAQ;aACd;SAAC;KACL;CACJ,CAAA"}
|
package/package.json
CHANGED
|
@@ -8,5 +8,4 @@ export {docnoformat} from './docnoformat'
|
|
|
8
8
|
export {systemmessage} from './systemmessage'
|
|
9
9
|
export {keyvaluepair} from './keyvaluepair'
|
|
10
10
|
export {webhook} from './webhook'
|
|
11
|
-
export {webhookhistory } from './webhookhistory'
|
|
12
11
|
export {documentevent} from './documentevent'
|
|
@@ -27,15 +27,15 @@ export const systemmessage:SchemaType =
|
|
|
27
27
|
"orgId": { "type": "integer", "default": 1 },
|
|
28
28
|
"branchId": { "type": "integer", "default": 1 },
|
|
29
29
|
"uid": { "type": "string","format":"uuid" },
|
|
30
|
+
"messageType":{"type":"string",minLength:3},
|
|
30
31
|
"messageTitle": {
|
|
31
32
|
"type": "string",
|
|
32
33
|
"minLength": 3
|
|
33
34
|
},
|
|
34
35
|
"read": { "type": "boolean", "default": false},
|
|
35
|
-
"
|
|
36
|
-
"description": {
|
|
36
|
+
"body": {
|
|
37
37
|
"type": "string",
|
|
38
|
-
"format": "
|
|
38
|
+
"format": "html"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -45,6 +45,13 @@ export const user:SchemaType ={
|
|
|
45
45
|
},
|
|
46
46
|
fullName: {type: "string",minLength:3},
|
|
47
47
|
email: {type: "string",minLength:10,format: "email"},
|
|
48
|
+
mobileNo: {
|
|
49
|
+
type: "string",
|
|
50
|
+
anyOf:[
|
|
51
|
+
{"const":""},
|
|
52
|
+
{"format": "tel","examples": ["0123456789"]}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
48
55
|
active: {type: "boolean",default:true},
|
|
49
56
|
description: {type:"string"},
|
|
50
57
|
lastActivity: {type: "string",description:"capture ISO8601 last api call"},
|
|
@@ -6,10 +6,10 @@ export const webhook:SchemaType = {
|
|
|
6
6
|
documentType:'webhook',
|
|
7
7
|
documentName:'webhook',
|
|
8
8
|
isolationType:IsolationType.tenant,
|
|
9
|
-
uniqueKey:'
|
|
10
|
-
documentTitle:'
|
|
9
|
+
uniqueKey:'title',
|
|
10
|
+
documentTitle:'title'
|
|
11
11
|
},
|
|
12
|
-
required:["
|
|
12
|
+
required:["title","url"],
|
|
13
13
|
properties: {
|
|
14
14
|
_id:{type:'string'},
|
|
15
15
|
created:{type:'string'},
|
|
@@ -19,8 +19,10 @@ export const webhook:SchemaType = {
|
|
|
19
19
|
tenantId: {type:'integer',default:1,minimum:0 },
|
|
20
20
|
orgId: {type:'integer',default:1,minimum:0 },
|
|
21
21
|
branchId: {type:'integer',default:1,minimum:0 },
|
|
22
|
-
|
|
23
|
-
url: {type: "string", format:'uri'},
|
|
22
|
+
title:{type:"string",minLength:3,},
|
|
23
|
+
url: {type: "string", format:'uri'},
|
|
24
|
+
serverSubscriptionId :{type:"string"},
|
|
25
|
+
serverSubscriptionSecret :{type:"string"},
|
|
24
26
|
requestMethod:{
|
|
25
27
|
type: "string",
|
|
26
28
|
enum:['post','get','patch','put','delete','head'],
|
|
@@ -29,7 +31,14 @@ export const webhook:SchemaType = {
|
|
|
29
31
|
type:"string",
|
|
30
32
|
enum:['none','basic'],
|
|
31
33
|
description:"apikey authentication use none + headers props"
|
|
32
|
-
},
|
|
34
|
+
},
|
|
35
|
+
basicAuth:{
|
|
36
|
+
type:"object",
|
|
37
|
+
properties:{
|
|
38
|
+
user:{type:"string"},
|
|
39
|
+
password:{type:"string"}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
33
42
|
headers: {
|
|
34
43
|
type: "array",
|
|
35
44
|
items:{
|
|
@@ -44,7 +53,12 @@ export const webhook:SchemaType = {
|
|
|
44
53
|
|
|
45
54
|
description: {type: "string",format:"text"},
|
|
46
55
|
active: {type: "boolean", default:true},
|
|
47
|
-
|
|
56
|
+
eventTypes:{
|
|
57
|
+
type:"array",
|
|
58
|
+
minItems:1,
|
|
59
|
+
items:{
|
|
60
|
+
type:"string"
|
|
61
|
+
}}
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
64
|
|
|
@@ -56,9 +56,9 @@ import {UserContext} from '../commons/user.context'
|
|
|
56
56
|
}
|
|
57
57
|
%>
|
|
58
58
|
<% let superadmindoctype = ['tenant','globaluser'] %>
|
|
59
|
-
const
|
|
60
|
-
@ApiTags(
|
|
61
|
-
@Controller(
|
|
59
|
+
const apiname = '<%= it.typename %>'.toUpperCase();
|
|
60
|
+
@ApiTags(apiname)
|
|
61
|
+
@Controller(apiname.toLowerCase())
|
|
62
62
|
export class <%= it.typename %>Controller extends SimpleAppAbstractController<
|
|
63
63
|
<%= it.typename %>Service,
|
|
64
64
|
schemas.<%= it.typename%>,
|
package/templates/nest/.env._eta
CHANGED
|
@@ -13,6 +13,8 @@ HTTP_PORT=<%=it.configs.backendPort%>
|
|
|
13
13
|
|
|
14
14
|
BPMN_PATH=./src/simpleapp/workflows/bpmn/
|
|
15
15
|
|
|
16
|
+
X_APIKEY=
|
|
17
|
+
X_APISECRET=
|
|
16
18
|
|
|
17
19
|
OAUTH2_BASEURL=<%=it.configs.oauthSetting ? it.configs.oauthSetting.oauthBaseUrl : ''%>
|
|
18
20
|
|
|
@@ -31,6 +33,11 @@ AUTH_SECRET_KEY=<%=it.configs.oauthSetting ? it.configs.oauthSetting.oauthAuthSe
|
|
|
31
33
|
BACKEND_URL=http://localhost:<%=it.configs.backendPort%>
|
|
32
34
|
|
|
33
35
|
|
|
36
|
+
WEBHOOK_SERVER_URL=
|
|
37
|
+
WEBHOOK_SERVER_APP_ID=
|
|
38
|
+
WEBHOOK_SERVER_APIKEY=
|
|
39
|
+
|
|
40
|
+
|
|
34
41
|
ADMIN_EMAIL=
|
|
35
42
|
TEST_OAUTH2_USERNAME=
|
|
36
43
|
TEST_OAUTH2_PASSWORD=
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
RoleGuard,
|
|
26
26
|
PolicyEnforcementMode,
|
|
27
27
|
} from 'nest-keycloak-connect';
|
|
28
|
+
import { CustomKeycloakGuard } from './simpleapp/generate/commons/customkeycloak.guard';
|
|
28
29
|
import {RolesGuard} from './simpleapp/generate/commons/roles/roles.guard'
|
|
29
30
|
import { ConfigModule } from '@nestjs/config';
|
|
30
31
|
import { ServeStaticModule } from '@nestjs/serve-static';
|
|
@@ -92,11 +93,17 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
|
|
|
92
93
|
]),
|
|
93
94
|
],
|
|
94
95
|
controllers: [AppController],
|
|
95
|
-
providers: [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
providers: [
|
|
97
|
+
AppService,
|
|
98
|
+
CustomKeycloakGuard,
|
|
99
|
+
ResourceGuard,
|
|
100
|
+
AppResolver,
|
|
101
|
+
{
|
|
102
|
+
provide: APP_INTERCEPTOR,
|
|
103
|
+
useClass: ResponseInterceptor,
|
|
104
|
+
},
|
|
105
|
+
{provide: APP_GUARD,useClass: CustomKeycloakGuard,},
|
|
106
|
+
// {provide: APP_GUARD,useClass: AuthGuard,},
|
|
100
107
|
{provide: APP_GUARD,useClass: ResourceGuard,},
|
|
101
108
|
{provide: APP_GUARD,useClass: RolesGuard,}
|
|
102
109
|
],
|
|
@@ -49,9 +49,39 @@ async function bootstrap() {
|
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
'oauth2',
|
|
52
|
+
).
|
|
53
|
+
addApiKey(
|
|
54
|
+
{
|
|
55
|
+
in: 'header',
|
|
56
|
+
name: 'x-apikey',
|
|
57
|
+
type: 'apiKey',
|
|
58
|
+
description: 'optional only use for specal case',
|
|
59
|
+
},
|
|
60
|
+
'x-apikey',
|
|
61
|
+
).addApiKey(
|
|
62
|
+
{
|
|
63
|
+
in: 'header',
|
|
64
|
+
name: 'x-apisecret',
|
|
65
|
+
type: 'apiKey',
|
|
66
|
+
description: 'optional only use for specal case',
|
|
67
|
+
},
|
|
68
|
+
'x-apisecret',
|
|
69
|
+
)
|
|
70
|
+
.addApiKey(
|
|
71
|
+
{
|
|
72
|
+
in: 'header',
|
|
73
|
+
name: 'x-guest-accesstoken',
|
|
74
|
+
type: 'apiKey',
|
|
75
|
+
description: 'optional only use for specal case',
|
|
76
|
+
},
|
|
77
|
+
'x-guest-accesstoken',
|
|
52
78
|
)
|
|
79
|
+
|
|
53
80
|
.addSecurityRequirements('x-org')
|
|
54
81
|
.addSecurityRequirements('oauth2')
|
|
82
|
+
.addSecurityRequirements('x-apikey')
|
|
83
|
+
.addSecurityRequirements('x-apisecret')
|
|
84
|
+
.addSecurityRequirements('x-guest-accesstoken')
|
|
55
85
|
.build();
|
|
56
86
|
const document = SwaggerModule.createDocument(app, config);
|
|
57
87
|
SwaggerModule.setup('api', app, document, {
|
|
@@ -7,16 +7,36 @@
|
|
|
7
7
|
|
|
8
8
|
import { ApiProperty } from '@nestjs/swagger';
|
|
9
9
|
export class ApiKeyValuePair {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
@ApiProperty({
|
|
11
|
+
type: Object,
|
|
12
|
+
required: false,
|
|
13
|
+
examples: ['{"field1":"1"}'],
|
|
14
|
+
default: '',
|
|
15
|
+
})
|
|
16
|
+
field1: any;
|
|
17
|
+
}
|
|
18
|
+
export class ApiSearchBody {
|
|
19
|
+
@ApiProperty({
|
|
20
|
+
type: Object,
|
|
21
|
+
required: false,
|
|
22
|
+
examples: ['{"field1":"1"}'],
|
|
23
|
+
default: { field1: 'ok', field2: true },
|
|
24
|
+
})
|
|
25
|
+
filter?: Object;
|
|
26
|
+
@ApiProperty({
|
|
27
|
+
type: [String],
|
|
28
|
+
required: false,
|
|
29
|
+
examples: ['["field1","field2"]'],
|
|
30
|
+
default: ['field1', 'field2'],
|
|
31
|
+
})
|
|
32
|
+
fields?: string[];
|
|
33
|
+
@ApiProperty({
|
|
34
|
+
type: () => [[String]],
|
|
35
|
+
required: false,
|
|
36
|
+
examples: ['[[ "field1", "asc" ]]'],
|
|
37
|
+
default: [['field1', 'asc']],
|
|
38
|
+
})
|
|
39
|
+
sorts?: string[][];
|
|
40
|
+
@ApiProperty({ type: () => Object, required: false })
|
|
41
|
+
lookup: Object;
|
|
12
42
|
}
|
|
13
|
-
export class ApiSearchBody{
|
|
14
|
-
@ApiProperty({ "type":Object, "required":false, "examples":['{"field1":"1"}'] ,"default":{"field1":"ok","field2":true,}} )
|
|
15
|
-
filter: Object;
|
|
16
|
-
@ApiProperty({"type":[Object],"required":true,"examples":['["field1","field2"]'],"default":["field1","field2"]} )
|
|
17
|
-
fields: [Object];
|
|
18
|
-
@ApiProperty({"type":()=>[Object],"required":true,"examples":['[[ "field1", "asc" ]]'],"default":[[ 'field1', 'asc' ]]} )
|
|
19
|
-
sorts: [Object];
|
|
20
|
-
@ApiProperty({type: () => Object,required: false,})
|
|
21
|
-
lookup: Object
|
|
22
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* This file was automatically generated by simpleapp generator. Every
|
|
3
3
|
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
4
|
* last change 2023-10-28
|
|
@@ -12,36 +12,41 @@ import * as types from 'src/simpleapp/generate/types';
|
|
|
12
12
|
|
|
13
13
|
@Injectable()
|
|
14
14
|
export class AuditTrail {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
constructor(
|
|
16
|
+
@InjectModel('Documentevent') private doc: Model<types.Documentevent>,
|
|
17
|
+
) {}
|
|
19
18
|
|
|
20
19
|
// addEvent(data: any) {
|
|
21
20
|
// console.log('Add event into db:', data);
|
|
22
21
|
// }
|
|
23
|
-
async addEvent(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
async addEvent(
|
|
23
|
+
appuser: UserContext,
|
|
24
|
+
documentName: string,
|
|
25
|
+
id: string,
|
|
26
|
+
eventType: string,
|
|
27
|
+
data: any,
|
|
28
|
+
) {
|
|
29
|
+
const eventdata: types.Documentevent = {
|
|
30
|
+
_id: crypto.randomUUID(),
|
|
31
|
+
documentName: documentName,
|
|
32
|
+
documentId: id,
|
|
33
|
+
eventType: eventType,
|
|
34
|
+
eventdata: data,
|
|
35
|
+
};
|
|
36
|
+
Object.assign(eventdata, appuser.getCreateFilter());
|
|
37
|
+
// console.log('add event', documentName, id, eventType);
|
|
38
|
+
// console.log('Add event into db:', eventdata);
|
|
39
|
+
const newdoc = new this.doc(eventdata);
|
|
40
|
+
const dbsession = appuser.getDBSession();
|
|
41
|
+
const result = await newdoc.save({ session: dbsession });
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
async addManyEvents(
|
|
45
|
-
|
|
44
|
+
async addManyEvents(
|
|
45
|
+
appuser: UserContext,
|
|
46
|
+
documentName: string,
|
|
47
|
+
eventType: string,
|
|
48
|
+
data: any[],
|
|
49
|
+
) {
|
|
50
|
+
console.log('add many event', documentName, eventType);
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-04-17
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { Injectable, CanActivate, ExecutionContext, UnauthorizedException } from '@nestjs/common';
|
|
8
|
+
import { Reflector } from '@nestjs/core';
|
|
9
|
+
import { ResourceGuard } from 'nest-keycloak-connect';
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class CustomKeycloakGuard implements CanActivate {
|
|
13
|
+
constructor(private reflector: Reflector, private resourceGuard: ResourceGuard) {}
|
|
14
|
+
|
|
15
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
16
|
+
const request = context.switchToHttp().getRequest();
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
//graphql no http request, exclude from capability of x-apikey
|
|
20
|
+
if(request?.headers){
|
|
21
|
+
const apiKey = request.headers['x-apikey'];
|
|
22
|
+
const apiSecret = request.headers['x-apisecret'];
|
|
23
|
+
// validate apikey and apisecret at middleware level, reach here mean approved as robot
|
|
24
|
+
if (apiKey && apiSecret ) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// If API key is not present, fall back to Keycloak authentication
|
|
30
|
+
try {
|
|
31
|
+
const canActivate = await this.resourceGuard.canActivate(context);
|
|
32
|
+
return canActivate as boolean;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw new UnauthorizedException('Invalid API key or Keycloak token');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private validateApiKey(apiKey: string, apiSecret: string): boolean {
|
|
39
|
+
// Implement your API key and secret validation logic here
|
|
40
|
+
// This is just a simple example
|
|
41
|
+
return apiKey === 'your-valid-api-key' && apiSecret === 'your-valid-api-secret';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -15,7 +15,8 @@ export const alldocuments:any[] = [
|
|
|
15
15
|
isolationType:'<%=conf['isolationType']%>',
|
|
16
16
|
documentDate:'<%=conf['documentDate']??""%>',
|
|
17
17
|
docNumber:<%=conf['generateDocumentNumber']??false%>,
|
|
18
|
-
docNoPattern: '<%=conf['docNoPattern']%>'
|
|
18
|
+
docNoPattern: '<%=conf['docNoPattern']%>',
|
|
19
|
+
webhook:<%~ JSON.stringify(conf['webhook'])%>
|
|
19
20
|
},
|
|
20
21
|
<%}%>
|
|
21
22
|
]
|
|
@@ -56,9 +56,9 @@ export class TenantMiddleware implements NestMiddleware {
|
|
|
56
56
|
|
|
57
57
|
if (req.baseUrl == '/graphql') {
|
|
58
58
|
let tokenstr: string = req.headers['authorization'] ?? '';
|
|
59
|
-
tokenstr = tokenstr.replace('Bearer ', '');
|
|
60
|
-
const xorg = req.headers['x-org'] ?? this.defaultxorg;
|
|
61
|
-
if (tokenstr) {
|
|
59
|
+
tokenstr = tokenstr.replace('Bearer ', '');
|
|
60
|
+
const xorg = req.headers['x-org'] ?? this.defaultxorg;
|
|
61
|
+
if (tokenstr) {
|
|
62
62
|
await u.setCurrentUserInfo(tokenstr, xorg);
|
|
63
63
|
}
|
|
64
64
|
req['sessionuser'] = u;
|
|
@@ -66,6 +66,33 @@ export class TenantMiddleware implements NestMiddleware {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
this.logger.debug(`running TenantMiddleware for ${req.baseUrl}`);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
//if APIKEY defined, and there is api key and secret supplied. use robot user
|
|
72
|
+
if(process.env.X_APIKEY &&req.headers['x-apikey'] && req.headers['x-apisecret']){
|
|
73
|
+
|
|
74
|
+
if(req.headers['x-apikey']==process.env.X_APIKEY &&
|
|
75
|
+
req.headers['x-apisecret']==process.env.X_APISECRET){
|
|
76
|
+
|
|
77
|
+
u.setAsStaticUser(
|
|
78
|
+
'00000000-0000-0000-0000-000000000000',
|
|
79
|
+
'robot',
|
|
80
|
+
'Robot',
|
|
81
|
+
'robot@a.org',
|
|
82
|
+
req.headers['x-org']?? this.defaultxorg
|
|
83
|
+
);
|
|
84
|
+
if(req.headers['x-guest-accesstoken']) {
|
|
85
|
+
u.setGuestToken(<string>req.headers['x-guest-accesstoken']);
|
|
86
|
+
}
|
|
87
|
+
req['sessionuser'] = u;
|
|
88
|
+
next();
|
|
89
|
+
return;
|
|
90
|
+
}else{
|
|
91
|
+
this.logger.log('invalid api key/scret');
|
|
92
|
+
throw new BadRequestException('invalid api key/scret');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
69
96
|
if (!req.headers['authorization']) {
|
|
70
97
|
this.logger.log('undefine bearer token');
|
|
71
98
|
return res.status(401).send('Undefine bearer token');
|
|
@@ -84,8 +111,7 @@ export class TenantMiddleware implements NestMiddleware {
|
|
|
84
111
|
let tokenstr: string = req.headers['authorization'];
|
|
85
112
|
tokenstr = tokenstr.replace('Bearer ', '');
|
|
86
113
|
|
|
87
|
-
const xorg = req.headers['x-org'] ?? this.defaultxorg;
|
|
88
|
-
|
|
114
|
+
const xorg = req.headers['x-org'] ?? this.defaultxorg;
|
|
89
115
|
await u.setCurrentUserInfo(tokenstr, xorg);
|
|
90
116
|
if (u.getId() == '' && this.requireXorg(req.baseUrl)) {
|
|
91
117
|
this.logger.log('access deny of no user:', req.baseUrl);
|