@simitgroup/simpleapp-generator 1.6.4-e-alpha → 1.6.4-f-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.
Files changed (36) hide show
  1. package/dist/buildinschemas/index.d.ts +0 -1
  2. package/dist/buildinschemas/index.d.ts.map +1 -1
  3. package/dist/buildinschemas/index.js +1 -3
  4. package/dist/buildinschemas/index.js.map +1 -1
  5. package/dist/buildinschemas/systemmessage.js +3 -3
  6. package/dist/buildinschemas/systemmessage.js.map +1 -1
  7. package/dist/buildinschemas/user.d.ts.map +1 -1
  8. package/dist/buildinschemas/user.js +7 -0
  9. package/dist/buildinschemas/user.js.map +1 -1
  10. package/dist/buildinschemas/webhook.d.ts.map +1 -1
  11. package/dist/buildinschemas/webhook.js +20 -5
  12. package/dist/buildinschemas/webhook.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/buildinschemas/index.ts +0 -1
  15. package/src/buildinschemas/systemmessage.ts +3 -3
  16. package/src/buildinschemas/user.ts +7 -0
  17. package/src/buildinschemas/webhook.ts +21 -7
  18. package/templates/nest/.env._eta +5 -0
  19. package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +31 -26
  20. package/templates/nest/src/simpleapp/generate/commons/dicts/documents.ts.eta +2 -1
  21. package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +161 -29
  22. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +4 -6
  23. package/templates/nest/src/simpleapp/generate/processors/webhook.processor.ts.eta +224 -0
  24. package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +113 -110
  25. package/templates/nuxt/components/image/ImageAvatar.vue.eta._vue +47 -13
  26. package/templates/nuxt/components/image/ImageToBase64Uploader.vue.eta.vue +5 -5
  27. package/templates/nuxt/components/renderer/RendererDocHistories.vue.eta +8 -5
  28. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +25 -18
  29. package/templates/nuxt/composables/stringHelper.generate.ts.eta +13 -9
  30. package/templates/nuxt/pages/profile.vue.eta +3 -1
  31. package/templates/nuxt/server/api/profile/[...].ts.eta +11 -2
  32. package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +3 -1
  33. package/templates/nuxt/types/others.ts.eta +1 -0
  34. package/templates/nuxt/types/simpleappinput.ts.eta +2 -1
  35. package/tsconfig.tsbuildinfo +1 -1
  36. package/src/buildinschemas/webhookhistory.ts +0 -42
@@ -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,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA"}
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.webhookhistory = exports.webhook = exports.keyvaluepair = exports.systemmessage = exports.docnoformat = exports.autoincreament = exports.permission = exports.branch = exports.organization = exports.tenant = void 0;
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,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,iDAA6C;AAArC,8GAAA,aAAa,OAAA"}
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
- "url": { "type": "string" },
37
- "description": {
37
+ "body": {
38
38
  "type": "string",
39
- "format": "text"
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,MAAM,EAAE,QAAQ;IAChB,oBAAoB,EAAE;QACpB,cAAc,EAAE,QAAQ;QACxB,cAAc,EAAE,eAAe;QAC/B,eAAe,EAAE,oBAAa,CAAC,MAAM;QACrC,eAAe,EAAE,cAAc;QAC/B,cAAc,EAAC,CAAC;gBACd,QAAQ,EAAC,SAAS;gBAClB,YAAY,EAAC,UAAU;gBACvB,cAAc,EAAC,CAAC,MAAM,CAAC;gBACvB,cAAc,EAAC,eAAe;gBAC9B,QAAQ,EAAC,kBAAW,CAAC,GAAG;gBACxB,aAAa,EAAC,mCAAmC;aAClD,CAAE;KACJ;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAC,QAAQ,EAAC,MAAM,EAAE;QAC3C,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC/B,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC/B,WAAW,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QACjC,WAAW,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QACjC,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE;QAC/C,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE;QAC5C,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,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AAE;QAC/C,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE;QAC5C,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE;QAC/C,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAC,QAAQ,EAAC,MAAM,EAAE;QAC3C,aAAa,EAAC,EAAC,MAAM,EAAC,QAAQ,EAAC,SAAS,EAAC,CAAC,EAAC;QAC3C,cAAc,EAAE;YACd,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,CAAC;SACf;QACD,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAC;QAC9C,MAAM,EAAE;YACN,MAAM,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,UAqDjB,CAAA"}
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/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AQ,EAAC,SAAS,EAAC,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC;QACpD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,KAAK,EAAC;gBACJ,EAAC,OAAO,EAAC,EAAE,EAAC;gBACZ,EAAC,QAAQ,EAAE,KAAK,EAAC,UAAU,EAAE,CAAC,YAAY,CAAC,EAAC;aAC7C;SACF;QACD,MAAM,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC,OAAO,EAAC,IAAI,EAAC;QACtC,WAAW,EAAE,EAAC,IAAI,EAAC,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,UA8CpB,CAAA"}
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: 'documentName',
12
- documentTitle: 'documentName'
11
+ uniqueKey: 'title',
12
+ documentTitle: 'title'
13
13
  },
14
- required: ["documentName", "url"],
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
- documentName: { type: "string", minLength: 3, },
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
- setting: { type: "string", format: "text" }
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,cAAc;QACxB,aAAa,EAAC,cAAc;KAC7B;IACD,QAAQ,EAAC,CAAC,cAAc,EAAC,KAAK,CAAC;IAC/B,UAAU,EAAE;QACV,GAAG,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC;QACnB,OAA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AAI,EAAC,QAAQ,EAAC;QACrC,wBAAwB,EAAE,EAAC,IAAI,EAAC,QAAQ,EAAC;QACzC,aAAa,EAAC;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAC,CAAC,MAAM,EAAC,KAAK,EAAC,OAAO,EAAC,KAAK,EAAC,QAAQ,EAAC,MAAM,CAAC;SAClD;QACD,cAAc,EAAC;YACb,IAAI,EAAC,QAAQ;YACb,IAAI,EAAC,CAAC,MAAM,EAAC,OAAO,CAAC;YACrB,WAAW,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "1.6.4e-alpha",
3
+ "version": "1.6.4f-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
- "url":{ "type": "string"},
36
- "description": {
36
+ "body": {
37
37
  "type": "string",
38
- "format": "text"
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:'documentName',
10
- documentTitle:'documentName'
9
+ uniqueKey:'title',
10
+ documentTitle:'title'
11
11
  },
12
- required:["documentName","url"],
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
- documentName:{type:"string",minLength:3,},
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
- setting:{type:"string",format:"text"}
56
+ eventTypes:{
57
+ type:"array",
58
+ minItems:1,
59
+ items:{
60
+ type:"string"
61
+ }}
48
62
  }
49
63
  }
50
64
 
@@ -31,6 +31,11 @@ AUTH_SECRET_KEY=<%=it.configs.oauthSetting ? it.configs.oauthSetting.oauthAuthSe
31
31
  BACKEND_URL=http://localhost:<%=it.configs.backendPort%>
32
32
 
33
33
 
34
+ WEBHOOK_SERVER_URL=
35
+ WEBHOOK_SERVER_APP_ID=
36
+ WEBHOOK_SERVER_APIKEY=
37
+
38
+
34
39
  ADMIN_EMAIL=
35
40
  TEST_OAUTH2_USERNAME=
36
41
  TEST_OAUTH2_PASSWORD=
@@ -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
- constructor( @InjectModel('Documentevent') private doc: Model<types.Documentevent>) {}
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(appuser:UserContext,documentName:string,id:string,eventType:string,data:any){
24
-
25
-
26
-
27
- const eventdata:types.Documentevent = {
28
- _id:crypto.randomUUID(),
29
- documentName:documentName,
30
- documentId:id,
31
- eventType:eventType,
32
- eventdata:data
33
- }
34
- Object.assign(eventdata, appuser.getCreateFilter());
35
- console.log('add event',documentName,id,eventType)
36
- console.log('Add event into db:', eventdata);
37
- const newdoc = new this.doc(eventdata);
38
- const dbsession = appuser.getDBSession();
39
- const result = await newdoc.save({ session: dbsession });
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(appuser:UserContext,documentName:string,eventType:string,data:any[]){
45
- console.log('add many event',documentName,eventType)
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
  }
@@ -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
  ]
@@ -11,16 +11,27 @@ import {
11
11
  Webhook,
12
12
  WebhookService,
13
13
  } from 'src/simpleapp/services/webhook.service';
14
- import {
15
- Webhookhistory,
16
- WebhookhistoryService,
17
- } from 'src/simpleapp/services/webhookhistory.service';
14
+ import {alldocuments} from 'src/simpleapp/generate/commons/dicts/documents'
15
+
18
16
  @Injectable()
19
17
  export class RunWebhookService {
18
+ private webhookApiKey = process.env.WEBHOOK_SERVER_APIKEY
19
+ private webhookAppId=process.env.WEBHOOK_SERVER_APP_ID
20
+ private webhookurl = process.env.WEBHOOK_SERVER_URL;
21
+ private webhookprefix = process.env.PROJECT_CODE+'.'
22
+ private webhookeventurl = `${process.env.WEBHOOK_SERVER_URL}/event/`;
23
+ private webhookeventtypeurl = `${process.env.WEBHOOK_SERVER_URL}/event_types/`;
24
+ private webhooksync:boolean = process.env.WEBHOOKER_SYNC_EVENTTYPE=='true'
25
+
26
+
27
+
20
28
  public constructor(
21
- private webhookService: WebhookService,
22
- private webhookhistoryService: WebhookhistoryService,
23
- ) {}
29
+ private webhookService: WebhookService,
30
+ ) {
31
+ if(this.webhooksync) this.syncEventTypes()
32
+ }
33
+
34
+
24
35
  @OnEvent('webhook')
25
36
  async loadWebhook(
26
37
  appuser: UserContext,
@@ -28,42 +39,163 @@ export class RunWebhookService {
28
39
  actionName: string,
29
40
  data?: any,
30
41
  ) {
31
- let subscribeall = false;
32
- const webhooks = await this.webhookService.search(appuser, {
33
- documentName: documentName,
34
- active: true,
35
- });
36
- if (webhooks.length == 0) return;
37
42
 
38
- const webhook = webhooks[0];
39
- let subscribes: string[] = [];
40
- if (webhook.setting == '' || webhook.setting === undefined) {
41
- subscribeall = true;
42
- } else {
43
- subscribes = JSON.parse(webhook.setting);
43
+ //no webhook server implemented
44
+ if(!this.webhookApiKey) return true
45
+
46
+
47
+ const filter = {
48
+ eventTypes: documentName + '.' + actionName ,
49
+ active: true,
44
50
  }
51
+ console.log("Load webhook",documentName,actionName,filter)
52
+ const webhooks = await this.webhookService.search(appuser, filter);
53
+ console.log("Loaded webhook",webhooks)
54
+ if (webhooks.length == 0) return;
45
55
 
46
- if (subscribeall || subscribes.includes(actionName)) {
47
- await this.runWebHook(appuser, webhook, data);
56
+ for (let i = 0; i < webhooks.length; i++) {
57
+ const webhook = webhooks[i];
58
+ try {
59
+ const res = await this.runWebHook(
60
+ appuser,
61
+ webhook,
62
+ documentName,
63
+ actionName,
64
+ data,
65
+ );
66
+ } catch (e) {
67
+ return e;
68
+ }
48
69
  }
49
70
  }
50
71
 
51
- async runWebHook(appuser: UserContext, webhook: Webhook, data: any) {
52
- const webhookurl = webhook.url;
53
- const headers = { 'x-from': process.env.PROJECT_NAME };
72
+ async runWebHook(
73
+ appuser: UserContext,
74
+ webhook: Webhook,
75
+ documentName: string,
76
+ actionName: string,
77
+ data: any,
78
+ ) {
79
+
80
+ const headers = {};
81
+
82
+ console.log("Run webhook ",documentName,actionName)
54
83
  if (Array.isArray(webhook.headers)) {
55
84
  webhook.headers.forEach((h) => {
56
85
  headers[h.name] = h.value;
57
86
  });
58
87
  }
88
+ headers['accept'] = 'application/json';
89
+ headers['content-type'] = 'application/json';
90
+ headers['Authorization'] = this.webhookApiKey;
91
+ const eventname = `${this.webhookprefix}${documentName}.${actionName}`
59
92
  const options = {
60
- method: webhook.requestMethod,
61
- body: JSON.stringify(data),
93
+ method: webhook.requestMethod.toUpperCase(),
62
94
  headers: headers,
95
+ body: JSON.stringify({
96
+ labels: {
97
+ tenantId: appuser.getTenantId().toString(),
98
+ },
99
+ metadata: {
100
+ src: process.env.PROJECT_NAME,
101
+ user: appuser.getFullname(),
102
+ },
103
+ application_id: this.webhookAppId,
104
+ event_type: eventname,
105
+ event_id: crypto.randomUUID(),
106
+ occurred_at: new Date().toISOString(),
107
+ payload: JSON.stringify(data),
108
+ payload_content_type: 'application/json',
109
+ }),
110
+ };
111
+ try {
112
+ console.log("webhook request ",this.webhookeventurl,options)
113
+ const req = await fetch(this.webhookeventurl, options);
114
+ const statusCode = req.status;
115
+ if(statusCode>=300){
116
+ throw new InternalServerErrorException(`create event ${eventname} failed to webhook server`)
117
+ }
118
+
119
+ // const body = req.body;
120
+ } catch (e) {
121
+ return e
122
+ }
123
+ }
124
+
125
+
126
+
127
+ async syncEventTypes(){
128
+ const options = {
129
+ method: 'GET',
130
+ headers: {
131
+ accept: 'application/json',
132
+ Authorization: this.webhookApiKey
133
+ }};
134
+ // {
135
+ // "service_name": "billing",
136
+ // "resource_type_name": "invoice",
137
+ // "verb_name": "documentno",
138
+ // "event_type_name": "billing.invoice.documentno"
139
+ // },
140
+ try{
141
+
142
+
143
+ const res = await fetch(
144
+ `${this.webhookeventtypeurl}?application_id=${this.webhookAppId}`,
145
+ options)
146
+
147
+ const locallist = this.getSchemaEventTypes()
148
+ const eventlist = (await res.json()).map(item=>item.event_type_name)
149
+
150
+ for(let i=0; i<locallist.length;i++){
151
+ const item = locallist[i]
152
+ if(!eventlist.includes(item)){
153
+ //create remote event type
154
+ await this.createEventType(item)
155
+ }
156
+ }
157
+
158
+
159
+ }catch(e){
160
+ throw new InternalServerErrorException(e)
161
+ }
162
+
163
+
164
+ }
165
+
166
+
167
+ async createEventType(eventname:string){
168
+ const para = eventname.split('.')
169
+ const options = {
170
+ method: 'POST',
171
+ headers: {
172
+ accept: 'application/json',
173
+ 'content-type': 'application/json',
174
+ Authorization: this.webhookApiKey
175
+ },
176
+ body: JSON.stringify({
177
+ application_id: this.webhookAppId,
178
+ resource_type: para[0],
179
+ service: para[1],
180
+ verb: para[2]
181
+ })
63
182
  };
64
183
 
65
- const req = await fetch(webhookurl, options);
66
- const statusCode = req.status;
67
- const body = req.body;
184
+ await fetch(this.webhookeventtypeurl, options)
185
+ // .then(response => response.json())
186
+ // .then(response => console.log(response))
187
+ // .catch(err => console.error(err));
188
+ }
189
+ getSchemaEventTypes(){
190
+ const alleventtypes:string[] = []
191
+ alldocuments.filter(item=>Array.isArray(item.webhook))
192
+ .forEach(item=>{
193
+ item.webhook.forEach(h=>{
194
+ alleventtypes.push(
195
+ `${this.webhookprefix}${item.docName.toLowerCase()}.${h}`)
196
+ })
197
+ })
198
+ return alleventtypes
199
+
68
200
  }
69
201
  }
@@ -367,7 +367,6 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
367
367
  dbsession.startTransaction();
368
368
  }
369
369
 
370
-
371
370
  this.logger.debug(
372
371
  'this.withDocNumberFormat :' +
373
372
  this.withDocNumberFormat +
@@ -379,7 +378,6 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
379
378
  await this.genNewDocNo(appuser, data);
380
379
  }
381
380
 
382
-
383
381
  let isolationFilter: any = { ...appuser.getCreateFilter() };
384
382
  isolationFilter = this.polishIsolationFilter(isolationFilter, data);
385
383
 
@@ -623,14 +621,14 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
623
621
  `You submit older version data "v${data.__v}"" but latest version = "v${existingdata.__v}"`,
624
622
  );
625
623
  }
626
- this.logger.debug('warn1', existingdata);
624
+ // this.logger.debug('warn1', existingdata);
627
625
  data.__v = existingdata.__v + 1;
628
626
  // if (!existingdata) {
629
627
  // throw new NotFoundException(`${id} not found`, 'not found');
630
628
  // }
631
- this.logger.debug('warn2');
629
+ // this.logger.debug('warn2');
632
630
  if (this.hooks.beforeUpdate)
633
- await this.hooks.beforeUpdate(appuser, id, data, existingdata);
631
+ await this.hooks.beforeUpdate(appuser, id, existingdata,data);
634
632
 
635
633
  const dbsession = appuser.getDBSession();
636
634
  if (dbsession && !dbsession.inTransaction()) {
@@ -693,7 +691,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
693
691
  data.__v = existingdata.__v + 1;
694
692
 
695
693
  if (this.hooks.beforeUpdate)
696
- await this.hooks.beforeUpdate(appuser, id, data, existingdata);
694
+ await this.hooks.beforeUpdate(appuser, id,existingdata, data);
697
695
 
698
696
  const dbsession = appuser.getDBSession();
699
697
  if (dbsession && !dbsession.inTransaction()) {