@simitgroup/simpleapp-generator 1.6.6-i-alpha → 1.6.6-k-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 +7 -0
- package/dist/buildinschemas/docnoformat.js +6 -6
- package/dist/buildinschemas/docnoformat.js.map +1 -1
- package/dist/buildinschemas/documentevent.js +1 -1
- package/dist/buildinschemas/documentevent.js.map +1 -1
- package/dist/buildinschemas/organization.js +1 -1
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/buildinschemas/tenant.js +1 -1
- package/dist/buildinschemas/tenant.js.map +1 -1
- package/dist/buildinschemas/user.js +2 -2
- package/dist/buildinschemas/user.js.map +1 -1
- package/dist/buildinschemas/webhook.d.ts.map +1 -1
- package/dist/buildinschemas/webhook.js +1 -0
- package/dist/buildinschemas/webhook.js.map +1 -1
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +30 -3
- package/dist/framework.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +21 -20
- package/dist/generate.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/processors/jrxmlbuilder.js +3 -3
- package/dist/processors/jrxmlbuilder.js.map +1 -1
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
- package/dist/processors/jsonschemabuilder.js +17 -10
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/type.d.ts +1 -1
- package/dist/type.d.ts.map +1 -1
- package/package.json +2 -3
- package/reset-install.sh +3 -0
- package/src/buildinschemas/docnoformat.ts +6 -6
- package/src/buildinschemas/documentevent.ts +1 -1
- package/src/buildinschemas/organization.ts +1 -1
- package/src/buildinschemas/tenant.ts +1 -1
- package/src/buildinschemas/user.ts +2 -2
- package/src/buildinschemas/webhook.ts +1 -0
- package/src/framework.ts +33 -5
- package/src/generate.ts +22 -20
- package/src/processors/jrxmlbuilder.ts +3 -3
- package/src/processors/jsonschemabuilder.ts +27 -14
- package/src/type.ts +1 -1
- package/templates/basic/nest/controller.ts.eta +6 -5
- package/templates/basic/nest/resolver.ts.eta +4 -2
- package/templates/basic/nest/service.ts.eta +5 -2
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +3 -3
- package/templates/nest/.gitignore.eta +4 -5
- package/templates/nest/src/{app.module.ts.eta → app.module.ts._eta} +2 -2
- package/templates/nest/src/{main.ts.eta → main.ts._eta} +2 -2
- package/templates/nest/src/printapi/printapi.service.ts.eta +7 -8
- package/templates/nest/src/simpleapp/.gitignore.eta +1 -1
- package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +2 -2
- package/templates/nest/src/simpleapp/generate/commons/customkeycloa.guard.ts.eta +14 -12
- package/templates/nest/src/simpleapp/generate/commons/customkeycloak.guard.ts.eta +36 -42
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +6 -3
- package/templates/nest/src/simpleapp/generate/commons/encryption.static.ts.eta +56 -61
- package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +65 -88
- package/templates/nest/src/simpleapp/generate/commons/robotuser.service.ts.eta +10 -9
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +10 -3
- package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +71 -77
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +439 -293
- package/templates/nest/src/simpleapp/generate/processors/autoinc.processor.ts.eta +20 -5
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +423 -38
- package/templates/nest/src/simpleapp/profile/{profile.controller.ts.eta → profile.controller.ts._eta} +2 -2
- package/templates/nest/src/simpleapp/profile/{profile.service.ts.eta → profile.service.ts._eta} +2 -2
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +15 -4
- package/templates/nuxt/assets/css/style.css._eta +74 -28
- package/templates/nuxt/components/button/ButtonMultiple.vue._eta +1 -1
- package/templates/nuxt/components/calendar/{CalendarByResource.vue.eta → CalendarByResource.vue._eta} +2 -2
- package/templates/nuxt/components/calendar/{CalendarInput.vue.eta → CalendarInput.vue._eta} +3 -3
- package/templates/nuxt/components/calendar/{CalendarSmall.vue.eta → CalendarSmall.vue._eta} +13 -7
- package/templates/nuxt/components/debug/{DebugDocumentData.vue.eta → DebugDocumentData.vue._eta} +4 -5
- package/templates/nuxt/components/form/{FormDocnoformat.vue.eta → FormDocnoformat.vue._eta} +2 -1
- package/templates/nuxt/components/form/user/{FormUserPermission.vue.eta → FormUserPermission.vue._eta} +6 -0
- package/templates/nuxt/components/header/{HeaderBreadcrumb.vue.eta → HeaderBreadcrumb.vue._eta} +5 -5
- package/templates/nuxt/components/header/button/{HeaderButtonProfile.vue.eta → HeaderButtonProfile.vue._eta} +2 -2
- package/templates/nuxt/components/header/button/task/{HeaderButtonTaskList.vue.eta → HeaderButtonTaskList.vue._eta} +4 -4
- package/templates/nuxt/components/image/ImageAvatar.vue.eta +56 -0
- package/templates/nuxt/components/image/{ImageOrganization.vue.eta.vue → ImageOrganization.vue.eta} +15 -9
- package/templates/nuxt/components/image/{ImageToBase64Uploader.vue.eta.vue → ImageToBase64Uploader.vue.eta} +28 -18
- package/templates/nuxt/components/list/{ListDocumentTable.vue.eta → ListDocumentTable.vue._eta} +3 -3
- package/templates/nuxt/components/list/{ListItem.vue.eta → ListItem.vue._eta} +2 -2
- package/templates/nuxt/components/list/{ListMessages.vue.eta → ListMessages.vue._eta} +8 -2
- package/templates/nuxt/components/list/{ListView.vue.eta → ListView.vue._eta} +2 -2
- package/templates/nuxt/components/overlay/{OverlayPanelWithToolBar.vue.eta → OverlayPanelWithToolBar.vue._eta} +5 -5
- package/templates/nuxt/components/overlay/{OverlaySideBarCrud.vue.eta → OverlaySideBarCrud.vue._eta} +4 -4
- package/templates/nuxt/components/overlay/{OverlayViewer.vue.eta → OverlayViewer.vue._eta} +2 -2
- package/templates/nuxt/components/page/{PageDocList.vue.eta → PageDocList.vue._eta} +5 -5
- package/templates/nuxt/components/renderer/RendererDateAge.vue.eta +19 -0
- package/templates/nuxt/components/renderer/{RendererDateTime.vue.eta → RendererDateTime.vue._eta} +2 -2
- package/templates/nuxt/components/renderer/{RendererDocHistories.vue.eta → RendererDocHistories.vue._eta} +6 -0
- package/templates/nuxt/components/renderer/{RendererForeignKey.vue.eta → RendererForeignKey.vue._eta} +2 -2
- package/templates/nuxt/components/renderer/{RendererLink.vue.eta → RendererLink.vue._eta} +2 -2
- package/templates/nuxt/components/renderer/{RendererTime.vue.eta → RendererTime.vue._eta} +2 -2
- package/templates/nuxt/components/renderer/{RendererViewer.vue.eta → RendererViewer.vue._eta} +2 -2
- package/templates/nuxt/components/select/{SelectTemplate.vue.eta → SelectTemplate.vue._eta} +2 -2
- package/templates/nuxt/components/session/{SessionBlock.vue.eta → SessionBlock.vue._eta} +2 -2
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +55 -55
- package/templates/nuxt/components/simpleApp/SimpleAppCalendarInput.vue.eta +13 -11
- package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +6 -3
- package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +33 -28
- package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +19 -28
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +113 -105
- package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +3 -3
- package/templates/nuxt/components/simpleApp/SimpleAppJsonSchemaForm.vue.eta +3 -16
- package/templates/nuxt/components/simpleApp/SimpleAppUserPicker.vue.eta +10 -12
- package/templates/nuxt/components/table/{TableDocuments.vue.eta → TableDocuments.vue._eta} +2 -2
- package/templates/nuxt/components/user/{UserButtonPermissionInfo.vue.eta → UserButtonPermissionInfo.vue._eta} +4 -4
- package/templates/nuxt/components/user/{UserInvitation.vue.eta → UserInvitation.vue._eta} +2 -2
- package/templates/nuxt/components/user/{UserProfileListItem.vue.eta → UserProfileListItem.vue._eta} +2 -2
- package/templates/nuxt/components/user/{UserTenantPicker.vue.eta → UserTenantPicker.vue._eta} +2 -2
- package/templates/nuxt/composables/getOpenApi.generate.ts.eta +11 -3
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +1 -1
- package/templates/nuxt/composables/graphquery.generate.ts.eta +1 -1
- package/templates/nuxt/composables/recently.generate.ts.eta +0 -1
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +5 -2
- package/templates/nuxt/nuxt.config.ts._eta +6 -5
- package/templates/nuxt/pages/[xorg]/docnoformat/[id].vue.eta +0 -1
- package/templates/nuxt/pages/[xorg]/{docnoformat.vue.eta → docnoformat.vue._eta} +1 -0
- package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +13 -9
- package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +10 -12
- package/templates/nuxt/pages/[xorg]/{user.vue.eta → user.vue._eta} +2 -2
- package/templates/nuxt/pages/index.vue._eta +1 -1
- package/templates/nuxt/pages/{profile.vue.eta → profile.vue._eta} +2 -2
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +6 -0
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +89 -12
- package/templates/nuxt/plugins/40.pusher.ts.eta +8 -5
- package/templates/nuxt/presets/lara/accordion/index.js +79 -0
- package/templates/nuxt/presets/lara/accordioncontent/index.js +3 -0
- package/templates/nuxt/presets/lara/accordionheader/index.js +11 -0
- package/templates/nuxt/presets/lara/accordionpanel/index.js +18 -0
- package/templates/nuxt/presets/lara/autocomplete/index.js +208 -0
- package/templates/nuxt/presets/lara/avatar/index.js +43 -0
- package/templates/nuxt/presets/lara/avatargroup/index.js +5 -0
- package/templates/nuxt/presets/lara/badge/index.js +47 -0
- package/templates/nuxt/presets/lara/badgedirective/index.js +43 -0
- package/templates/nuxt/presets/lara/blockui/index.js +4 -0
- package/templates/nuxt/presets/lara/breadcrumb/index.js +64 -0
- package/templates/nuxt/presets/lara/button/index.js +238 -0
- package/templates/nuxt/presets/lara/buttongroup/index.js +12 -0
- package/templates/nuxt/presets/lara/card/index.js +37 -0
- package/templates/nuxt/presets/lara/carousel/index.js +103 -0
- package/templates/nuxt/presets/lara/cascadeselect/index.js +199 -0
- package/templates/nuxt/presets/lara/checkbox/index.js +104 -0
- package/templates/nuxt/presets/lara/chip/index.js +42 -0
- package/templates/nuxt/presets/lara/colorpicker/index.js +123 -0
- package/templates/nuxt/presets/lara/confirmdialog/index.js +3 -0
- package/templates/nuxt/presets/lara/confirmpopup/index.js +56 -0
- package/templates/nuxt/presets/lara/contextmenu/index.js +126 -0
- package/templates/nuxt/presets/lara/datatable/index.js +403 -0
- package/templates/nuxt/presets/lara/dataview/index.js +28 -0
- package/templates/nuxt/presets/lara/datepicker/index.js +435 -0
- package/templates/nuxt/presets/lara/deferred/index.js +3 -0
- package/templates/nuxt/presets/lara/dialog/index.js +148 -0
- package/templates/nuxt/presets/lara/divider/index.js +67 -0
- package/templates/nuxt/presets/lara/dock/index.js +86 -0
- package/templates/nuxt/presets/lara/drawer/index.js +149 -0
- package/templates/nuxt/presets/lara/fieldset/index.js +84 -0
- package/templates/nuxt/presets/lara/fileupload/index.js +95 -0
- package/templates/nuxt/presets/lara/floatlabel/index.js +26 -0
- package/templates/nuxt/presets/lara/galleria/index.js +308 -0
- package/templates/nuxt/presets/lara/global.js +90 -0
- package/templates/nuxt/presets/lara/iconfield/index.js +27 -0
- package/templates/nuxt/presets/lara/image/index.js +206 -0
- package/templates/nuxt/presets/lara/index.js +234 -0
- package/templates/nuxt/presets/lara/inplace/index.js +27 -0
- package/templates/nuxt/presets/lara/inputgroup/index.js +5 -0
- package/templates/nuxt/presets/lara/inputgroupaddon/index.js +28 -0
- package/templates/nuxt/presets/lara/inputmask/index.js +39 -0
- package/templates/nuxt/presets/lara/inputnumber/index.js +167 -0
- package/templates/nuxt/presets/lara/inputotp/index.js +10 -0
- package/templates/nuxt/presets/lara/inputswitch/index.js +80 -0
- package/templates/nuxt/presets/lara/inputtext/index.js +54 -0
- package/templates/nuxt/presets/lara/knob/index.js +44 -0
- package/templates/nuxt/presets/lara/listbox/index.js +117 -0
- package/templates/nuxt/presets/lara/megamenu/index.js +198 -0
- package/templates/nuxt/presets/lara/menu/index.js +96 -0
- package/templates/nuxt/presets/lara/menubar/index.js +176 -0
- package/templates/nuxt/presets/lara/message/index.js +92 -0
- package/templates/nuxt/presets/lara/metergroup/index.js +96 -0
- package/templates/nuxt/presets/lara/multiselect/index.js +201 -0
- package/templates/nuxt/presets/lara/orderlist/index.js +13 -0
- package/templates/nuxt/presets/lara/organizationchart/index.js +137 -0
- package/templates/nuxt/presets/lara/overlaybadge/index.js +18 -0
- package/templates/nuxt/presets/lara/paginator/index.js +178 -0
- package/templates/nuxt/presets/lara/panel/index.js +91 -0
- package/templates/nuxt/presets/lara/panelmenu/index.js +127 -0
- package/templates/nuxt/presets/lara/password/index.js +72 -0
- package/templates/nuxt/presets/lara/picklist/index.js +52 -0
- package/templates/nuxt/presets/lara/popover/index.js +31 -0
- package/templates/nuxt/presets/lara/progressbar/index.js +55 -0
- package/templates/nuxt/presets/lara/progressspinner/index.js +51 -0
- package/templates/nuxt/presets/lara/radiobutton/index.js +104 -0
- package/templates/nuxt/presets/lara/rating/index.js +63 -0
- package/templates/nuxt/presets/lara/ripple/index.js +6 -0
- package/templates/nuxt/presets/lara/scrollpanel/index.js +77 -0
- package/templates/nuxt/presets/lara/scrolltop/index.js +26 -0
- package/templates/nuxt/presets/lara/select/index.js +240 -0
- package/templates/nuxt/presets/lara/selectbutton/index.js +16 -0
- package/templates/nuxt/presets/lara/skeleton/index.js +16 -0
- package/templates/nuxt/presets/lara/slider/index.js +137 -0
- package/templates/nuxt/presets/lara/speeddial/index.js +57 -0
- package/templates/nuxt/presets/lara/splitbutton/index.js +19 -0
- package/templates/nuxt/presets/lara/splitter/index.js +61 -0
- package/templates/nuxt/presets/lara/splitterpanel/index.js +5 -0
- package/templates/nuxt/presets/lara/step/index.js +62 -0
- package/templates/nuxt/presets/lara/stepitem/index.js +11 -0
- package/templates/nuxt/presets/lara/steplist/index.js +3 -0
- package/templates/nuxt/presets/lara/steppanels/index.js +3 -0
- package/templates/nuxt/presets/lara/stepper/index.js +13 -0
- package/templates/nuxt/presets/lara/steps/index.js +111 -0
- package/templates/nuxt/presets/lara/tab/index.js +42 -0
- package/templates/nuxt/presets/lara/tablist/index.js +8 -0
- package/templates/nuxt/presets/lara/tabmenu/index.js +73 -0
- package/templates/nuxt/presets/lara/tabpanel/index.js +3 -0
- package/templates/nuxt/presets/lara/tabpanels/index.js +3 -0
- package/templates/nuxt/presets/lara/tabs/index.js +5 -0
- package/templates/nuxt/presets/lara/tabview/index.js +156 -0
- package/templates/nuxt/presets/lara/tag/index.js +38 -0
- package/templates/nuxt/presets/lara/terminal/index.js +60 -0
- package/templates/nuxt/presets/lara/textarea/index.js +39 -0
- package/templates/nuxt/presets/lara/tieredmenu/index.js +121 -0
- package/templates/nuxt/presets/lara/timeline/index.js +81 -0
- package/templates/nuxt/presets/lara/toast/index.js +102 -0
- package/templates/nuxt/presets/lara/togglebutton/index.js +45 -0
- package/templates/nuxt/presets/lara/toggleswitch/index.js +80 -0
- package/templates/nuxt/presets/lara/toolbar/index.js +28 -0
- package/templates/nuxt/presets/lara/tooltip/index.js +46 -0
- package/templates/nuxt/presets/lara/tree/index.js +101 -0
- package/templates/nuxt/presets/lara/treeselect/index.js +102 -0
- package/templates/nuxt/presets/lara/treetable/index.js +305 -0
- package/templates/nuxt/providers/my-provider.ts.eta +1 -1
- package/templates/nuxt/server/api/profile/[...].ts.eta +4 -3
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +10 -20
- package/templates/nuxt/tailwind.config.ts._eta +4 -15
- package/templates/nuxt/types/schema.ts.eta +1 -1
- package/templates/nuxt/types/user.ts.eta +6 -1
- package/templates/project/jsonschemas/appintegration.json_eta +227 -0
- package/templates/project/sharelibs/validate.ts.eta +23 -0
- package/templates/nuxt/components/image/ImageAvatar.vue.eta._vue +0 -57
|
@@ -112,7 +112,8 @@ export const readJsonSchemaBuilder = async (docname: string,orijsondata:JSONSche
|
|
|
112
112
|
jsondata['required'] ?? [],
|
|
113
113
|
'$',
|
|
114
114
|
schemaconfigs,
|
|
115
|
-
allmodels
|
|
115
|
+
allmodels,
|
|
116
|
+
""
|
|
116
117
|
);
|
|
117
118
|
return allmodels
|
|
118
119
|
};
|
|
@@ -135,18 +136,19 @@ const genSchema = async (
|
|
|
135
136
|
jsondata: JsonSchemaProperties,
|
|
136
137
|
requiredlist: string[] | undefined,parentpath:string,
|
|
137
138
|
schemaconfigs:SchemaConfig,
|
|
138
|
-
allmodels: ChildModels
|
|
139
|
+
allmodels: ChildModels,
|
|
140
|
+
parentFlatStr: string, // ex: docnoformat.branch
|
|
139
141
|
): Promise<SchemaModel> => {
|
|
140
|
-
|
|
141
142
|
if(!allfields.includes(docname)){
|
|
142
143
|
allfields.push(docname)
|
|
143
144
|
}
|
|
144
145
|
const newmodel: SchemaModel = {};
|
|
145
|
-
|
|
146
|
+
|
|
146
147
|
Object.keys(jsondata).forEach(async (key) => {
|
|
147
148
|
if(!allfields.includes(key)){
|
|
148
149
|
allfields.push(key)
|
|
149
150
|
}
|
|
151
|
+
|
|
150
152
|
//below is Object.assign use for force datatype compatibility
|
|
151
153
|
const obj:JSONSchema7={}
|
|
152
154
|
Object.assign(obj,jsondata[key]);
|
|
@@ -158,7 +160,11 @@ const genSchema = async (
|
|
|
158
160
|
isrequired=true
|
|
159
161
|
}
|
|
160
162
|
const newName: string = _.upperFirst(docname) + _.upperFirst(key);
|
|
161
|
-
|
|
163
|
+
// const flatHierarchyStr: string = docname + '.' + key;
|
|
164
|
+
let flatHierarchyStr = parentFlatStr + "." + key;
|
|
165
|
+
if(parentFlatStr == ''){
|
|
166
|
+
flatHierarchyStr = docname+ '.' + key;
|
|
167
|
+
}
|
|
162
168
|
|
|
163
169
|
// if(obj[X_AUTOCOMPLETE_FIELD]){
|
|
164
170
|
// docSetting.autocompleteFields.push(key)
|
|
@@ -177,11 +183,17 @@ const genSchema = async (
|
|
|
177
183
|
// newmodel[key] = 'Object';
|
|
178
184
|
// }
|
|
179
185
|
// else
|
|
186
|
+
|
|
187
|
+
|
|
180
188
|
if(obj[FOREIGNKEY_PROPERTY]){
|
|
189
|
+
|
|
181
190
|
const masterdatacollection = obj[FOREIGNKEY_PROPERTY]
|
|
182
|
-
const clientdatacollection = docname.toLowerCase()
|
|
191
|
+
// const clientdatacollection = docname.toLowerCase()
|
|
192
|
+
const clientdatacollection = parentFlatStr.split(".")[0] || docname.toLowerCase();
|
|
183
193
|
const foreignkeyidentity= (obj.type=='object')? `${key}._id` : key
|
|
184
|
-
const foreignkeypath = (obj.type=='object')
|
|
194
|
+
const foreignkeypath = (obj.type=='object') ? `${parentpath}.${key}._id` : (obj.type =='array') ? `${parentpath}.${key}[*]._id` : `${parentpath}.${key}`
|
|
195
|
+
|
|
196
|
+
const foreignkeyidentityNew = foreignkeypath.replace("$.", "").replace("[*]", "")
|
|
185
197
|
|
|
186
198
|
//current document foreignkeys
|
|
187
199
|
if(schemaconfigs.foreignKeys[masterdatacollection]){
|
|
@@ -193,20 +205,21 @@ const genSchema = async (
|
|
|
193
205
|
//centralize foreignkeys catalogue
|
|
194
206
|
if(!allforeignkeys[masterdatacollection]){
|
|
195
207
|
let tmp:TypeForeignKey = {} as TypeForeignKey
|
|
196
|
-
tmp[clientdatacollection]=[
|
|
208
|
+
tmp[clientdatacollection]=[foreignkeyidentityNew]
|
|
197
209
|
allforeignkeys[masterdatacollection] = tmp
|
|
198
210
|
}
|
|
199
211
|
else if(!allforeignkeys[masterdatacollection][clientdatacollection]){
|
|
200
|
-
|
|
212
|
+
|
|
213
|
+
allforeignkeys[masterdatacollection][clientdatacollection]=[foreignkeyidentityNew]
|
|
201
214
|
}else{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
215
|
+
// console.log(masterdatacollection, 3);
|
|
216
|
+
allforeignkeys[masterdatacollection][clientdatacollection].push(foreignkeyidentityNew)
|
|
217
|
+
}
|
|
205
218
|
}
|
|
206
219
|
|
|
207
220
|
if (obj.type == 'object') {
|
|
208
221
|
// console.log("line 175",key,obj.type,obj.properties)
|
|
209
|
-
await genSchema(newName, obj.type, obj.properties, obj.required,`${parentpath}.${key}`,schemaconfigs,allmodels);
|
|
222
|
+
await genSchema(newName, obj.type, obj.properties, obj.required,`${parentpath}.${key}`,schemaconfigs,allmodels, flatHierarchyStr);
|
|
210
223
|
newmodel[key] = newName;
|
|
211
224
|
} else if (obj.type == 'array' && obj.items && objectitem?.type == 'object') {
|
|
212
225
|
const childprops = objectitem?.properties
|
|
@@ -226,7 +239,7 @@ const genSchema = async (
|
|
|
226
239
|
childprops['_id']={type:'string'}
|
|
227
240
|
}
|
|
228
241
|
// console.log("line 195")
|
|
229
|
-
await genSchema(newName, obj.type, objectitem?.properties, obj.items['required'],`${parentpath}.${key}[*]`,schemaconfigs,allmodels);
|
|
242
|
+
await genSchema(newName, obj.type, objectitem?.properties, obj.items['required'],`${parentpath}.${key}[*]`,schemaconfigs,allmodels, flatHierarchyStr);
|
|
230
243
|
newmodel[key] = [newName];
|
|
231
244
|
} else if (obj.type == 'array' && objectitem?.type != 'object') {
|
|
232
245
|
//array need submodel
|
package/src/type.ts
CHANGED
|
@@ -36,8 +36,9 @@ import {AppUser} from '../commons/decorators/appuser.decorator'
|
|
|
36
36
|
import {UserContext} from '../commons/user.context'
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
<% const getFieldType =(proptype, typename)=>{
|
|
39
|
+
<% const getFieldType =(proptype, typename,actionname)=>{
|
|
40
40
|
const systemtypes = ['Boolean','boolean','string','String','number','Number','object','Object','integer','Integer']
|
|
41
|
+
if(!typename) throw actionname +" undefine schema";
|
|
41
42
|
let tmptypename = typename.replace('[','').replace(']','')
|
|
42
43
|
|
|
43
44
|
if(systemtypes.includes(tmptypename)){
|
|
@@ -192,12 +193,12 @@ export class <%= it.typename %>Controller extends SimpleAppAbstractController<
|
|
|
192
193
|
<%}%>
|
|
193
194
|
<% if(['post','put','patch'].includes(api.method)){ %>
|
|
194
195
|
@ApiBody({ description: 'Request Body',
|
|
195
|
-
type: <%= getFieldType('schema',api.schema)%>
|
|
196
|
+
type: <%= getFieldType('schema',api.schema,api.action)%>
|
|
196
197
|
|
|
197
198
|
})
|
|
198
199
|
<%}%>
|
|
199
200
|
@ApiResponse({status: 200,description: '<%=api.description%>'
|
|
200
|
-
,type: <%= getFieldType('schema',api.responseType)%>
|
|
201
|
+
,type: <%= getFieldType('schema',api.responseType,api.action)%>
|
|
201
202
|
})
|
|
202
203
|
@ApiOperation({ operationId: 'run<%=capitalizeFirstLetter(api.action)%>' })
|
|
203
204
|
<% if(api.queryPara && api.queryPara.length>0) {%>
|
|
@@ -208,7 +209,7 @@ export class <%= it.typename %>Controller extends SimpleAppAbstractController<
|
|
|
208
209
|
async <%=capitalizeFirstLetter(api.action) %>(
|
|
209
210
|
@AppUser() appuser: UserContext,
|
|
210
211
|
<%if(['post','put','patch'].includes(api.method.toLowerCase())){%>
|
|
211
|
-
@Body() data:<%= getFieldType('type',api.schema)%>,
|
|
212
|
+
@Body() data:<%= getFieldType('type',api.schema,api.action)%>,
|
|
212
213
|
//@Body() data:any,
|
|
213
214
|
<%}%>
|
|
214
215
|
<% if(api.entryPoint && api.entryPoint.includes(':')) {%>
|
|
@@ -230,7 +231,7 @@ export class <%= it.typename %>Controller extends SimpleAppAbstractController<
|
|
|
230
231
|
){
|
|
231
232
|
|
|
232
233
|
|
|
233
|
-
const res:<%= getFieldType('type',api.responseType)%> = await this.service.run<%=capitalizeFirstLetter(api.action)%>(appuser,<% if(api.entryPoint && api.entryPoint.includes(':')) {%>
|
|
234
|
+
const res:<%= getFieldType('type',api.responseType,api.action)%> = await this.service.run<%=capitalizeFirstLetter(api.action)%>(appuser,<% if(api.entryPoint && api.entryPoint.includes(':')) {%>
|
|
234
235
|
<%let subpath = api.entryPoint.split('/')%>
|
|
235
236
|
<% for(let a=0;a<subpath.length;a++){%>
|
|
236
237
|
<%const partstr = subpath[a]%>
|
|
@@ -14,8 +14,10 @@ import { Role } from '../commons/roles/roles.enum';
|
|
|
14
14
|
|
|
15
15
|
import { Request } from '@nestjs/common';
|
|
16
16
|
|
|
17
|
-
<% const getFieldType =(proptype, typename)=>{
|
|
17
|
+
<% const getFieldType =(proptype, typename,actionname)=>{
|
|
18
18
|
const systemtypes = ['Boolean','boolean','string','String','number','Number','object','Object','integer','Integer']
|
|
19
|
+
if(!typename) throw actionname +" undefine schema";
|
|
20
|
+
|
|
19
21
|
let tmptypename = typename.replace('[','').replace(']','')
|
|
20
22
|
|
|
21
23
|
if(systemtypes.includes(tmptypename)){
|
|
@@ -89,7 +91,7 @@ export class <%= it.typename %>Resolver {
|
|
|
89
91
|
<%}%>
|
|
90
92
|
)
|
|
91
93
|
<%}%>
|
|
92
|
-
@Query(()=> <%= getFieldType('schema',api.responseType)%>)
|
|
94
|
+
@Query(()=> <%= getFieldType('schema',api.responseType,api.action)%>)
|
|
93
95
|
|
|
94
96
|
|
|
95
97
|
|
|
@@ -13,8 +13,11 @@ import { <%= it.typename %>Processor } from '../generate/processors/<%= it.docty
|
|
|
13
13
|
//import { <%= it.typename %>,<%= it.typename %>Hooks} from '../generate/types';
|
|
14
14
|
import * as types from '../generate/types';
|
|
15
15
|
export { <%= it.typename %>} from '../generate/types';
|
|
16
|
-
<% const getFieldType =(proptype, typename)=>{
|
|
16
|
+
<% const getFieldType =(proptype, typename,actionname)=>{
|
|
17
17
|
const systemtypes = ['Boolean','boolean','string','String','number','Number','object','Object','integer','Integer']
|
|
18
|
+
console.log("run service typename----",typename)
|
|
19
|
+
if(!typename) throw actionname +" undefine schema";
|
|
20
|
+
|
|
18
21
|
let tmptypename = typename.replace('[','').replace(']','')
|
|
19
22
|
|
|
20
23
|
if(systemtypes.includes(tmptypename)){
|
|
@@ -69,7 +72,7 @@ export class <%= it.typename %>Service extends <%= it.typename %>Processor {
|
|
|
69
72
|
<%}%>
|
|
70
73
|
|
|
71
74
|
<%if(['post','put','patch'].includes(api.method.toLowerCase())){%>
|
|
72
|
-
data:<%= getFieldType('schema',api.schema)%>,
|
|
75
|
+
data:<%= getFieldType('schema',api.schema,api.action)%>,
|
|
73
76
|
<%}%>
|
|
74
77
|
|
|
75
78
|
){
|
|
@@ -265,7 +265,7 @@ export class <%= capitalizeFirstLetter(it.name)%>Client extends SimpleAppClient<
|
|
|
265
265
|
/***************************** begin document status code*****************************************/
|
|
266
266
|
<%for(let i=0;i<it.docStatusSettings.length;i++){%>
|
|
267
267
|
<% let setting = it.docStatusSettings[i] %>
|
|
268
|
-
async setStatus<%=capitalizeFirstLetter(setting.status)%>(id:string='',data
|
|
268
|
+
async setStatus<%=capitalizeFirstLetter(setting.status)%>(id:string='',data:openapi.<%= it.typename%>,runValidate:boolean=false) {
|
|
269
269
|
const {$event} =useNuxtApp()
|
|
270
270
|
if(runValidate){
|
|
271
271
|
const errors = this.validateFailed();
|
|
@@ -292,9 +292,9 @@ export class <%= capitalizeFirstLetter(it.name)%>Client extends SimpleAppClient<
|
|
|
292
292
|
documentName:this.getDocName(),
|
|
293
293
|
summary:t('setStatus<%=capitalizeFirstLetter(setting.status)%>Failed'),
|
|
294
294
|
status:NotificationStatus.error,
|
|
295
|
-
data:errors.response.data.
|
|
295
|
+
data:errors.response.data.statusMessage
|
|
296
296
|
})
|
|
297
|
-
console.error('error:<%=capitalizeFirstLetter(setting.status)%>',errors.response.data.
|
|
297
|
+
console.error('error:<%=capitalizeFirstLetter(setting.status)%>',errors.response.data.statusMessage)
|
|
298
298
|
return Promise.reject(errors)
|
|
299
299
|
})
|
|
300
300
|
}
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
# compiled output
|
|
7
7
|
/dist
|
|
8
8
|
/node_modules
|
|
9
|
-
/
|
|
10
|
-
/src/app.
|
|
11
|
-
/src/app.
|
|
12
|
-
/src/
|
|
13
|
-
/src/main.ts
|
|
9
|
+
# /src/app.module.ts
|
|
10
|
+
# /src/app.service.ts
|
|
11
|
+
# /src/app.controller.ts
|
|
12
|
+
# /src/main.ts
|
|
14
13
|
# Logs
|
|
15
14
|
logs
|
|
16
15
|
*.log
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator.
|
|
3
|
-
*
|
|
2
|
+
* This file was automatically generated by simpleapp generator. It is changable.
|
|
3
|
+
* --remove-this-line-to-prevent-override--
|
|
4
4
|
* last change 2024-03-17
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator.
|
|
3
|
-
*
|
|
2
|
+
* This file was automatically generated by simpleapp generator. It is changable.
|
|
3
|
+
* --remove-this-line-to-prevent-override--
|
|
4
4
|
* last change 2023-10-28
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
9
|
-
import * as api from './api';
|
|
10
9
|
import { UserContext } from 'src/simpleapp/generate/commons/user.context';
|
|
10
|
+
import * as api from './api';
|
|
11
11
|
|
|
12
12
|
@Injectable()
|
|
13
13
|
export class PrintApiService {
|
|
@@ -25,18 +25,17 @@ export class PrintApiService {
|
|
|
25
25
|
}
|
|
26
26
|
async getBase64Pdf(appuser: UserContext, formatid: string, id: string) {
|
|
27
27
|
const printapi = new api.DefaultApi(this.getConfig(appuser), undefined);
|
|
28
|
-
try{
|
|
29
|
-
const result:any = await printapi.runPdfBase64(formatid, id, {
|
|
28
|
+
try {
|
|
29
|
+
const result: any = await printapi.runPdfBase64(formatid, id, {
|
|
30
30
|
headers: {
|
|
31
|
-
'x-org': appuser.
|
|
31
|
+
'x-org': appuser.getXOrg(),
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const pdfresult: string = result.data;
|
|
36
|
-
return pdfresult;
|
|
37
|
-
}catch(e){
|
|
38
|
-
throw new InternalServerErrorException('print-service servicer error')
|
|
36
|
+
return pdfresult;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new InternalServerErrorException('print-service servicer error');
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
}
|
|
42
41
|
}
|
|
@@ -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
|
|
@@ -47,6 +47,6 @@ export class AuditTrail {
|
|
|
47
47
|
eventType: string,
|
|
48
48
|
data: any[],
|
|
49
49
|
) {
|
|
50
|
-
console.log('add many event', documentName, eventType);
|
|
50
|
+
// console.log('add many event', documentName, eventType);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -10,20 +10,22 @@ import { ResourceGuard } from 'nest-keycloak-connect';
|
|
|
10
10
|
|
|
11
11
|
@Injectable()
|
|
12
12
|
export class CustomKeycloakGuard implements CanActivate {
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(
|
|
14
|
+
private reflector: Reflector,
|
|
15
|
+
private resourceGuard: ResourceGuard,
|
|
16
|
+
) {}
|
|
14
17
|
|
|
15
18
|
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
16
19
|
const request = context.switchToHttp().getRequest();
|
|
17
|
-
|
|
18
20
|
|
|
19
|
-
//graphql no http request, exclude from capability of x-
|
|
20
|
-
if(request?.headers){
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
//graphql no http request, exclude from capability of x-apikey
|
|
22
|
+
if (request?.headers) {
|
|
23
|
+
const apiKey = request.headers['x-apikey'];
|
|
24
|
+
const apiSecret = request.headers['x-apisecret'];
|
|
25
|
+
// validate apikey and apisecret at middleware level, reach here mean approved as robot
|
|
26
|
+
if (apiKey && apiSecret) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
// If API key is not present, fall back to Keycloak authentication
|
|
@@ -35,9 +37,9 @@ export class CustomKeycloakGuard implements CanActivate {
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
private validateApiKey(apiKey: string, apiSecret: string): boolean {
|
|
40
|
+
private validateApiKey(apiKey: string, apiSecret: string): boolean {
|
|
39
41
|
// Implement your API key and secret validation logic here
|
|
40
42
|
// This is just a simple example
|
|
41
43
|
return apiKey === 'your-valid-api-key' && apiSecret === 'your-valid-api-secret';
|
|
42
44
|
}
|
|
43
|
-
}
|
|
45
|
+
}
|
|
@@ -4,48 +4,42 @@
|
|
|
4
4
|
* last change 2024-06-21
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const apiKey = request.headers['x-api-key'];
|
|
29
|
-
const apiSecret = request.headers['x-api-secret'];
|
|
30
|
-
// validate apikey and apisecret at middleware level, reach here mean approved as robot
|
|
31
|
-
if (apiKey && apiSecret) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// If API key is not present, fall back to Keycloak authentication
|
|
37
|
-
try {
|
|
38
|
-
const canActivate = await this.resourceGuard.canActivate(context);
|
|
39
|
-
return canActivate as boolean;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
throw new UnauthorizedException('Invalid API key or Keycloak token');
|
|
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(
|
|
14
|
+
private reflector: Reflector,
|
|
15
|
+
private resourceGuard: ResourceGuard,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
19
|
+
const request = context.switchToHttp().getRequest();
|
|
20
|
+
|
|
21
|
+
//graphql no http request, exclude from capability of x-apikey
|
|
22
|
+
if (request?.headers) {
|
|
23
|
+
const apiKey = request.headers['x-apikey'];
|
|
24
|
+
const apiSecret = request.headers['x-apisecret'];
|
|
25
|
+
// validate apikey and apisecret at middleware level, reach here mean approved as robot
|
|
26
|
+
if (apiKey && apiSecret) {
|
|
27
|
+
return true;
|
|
42
28
|
}
|
|
43
29
|
}
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
|
|
31
|
+
// If API key is not present, fall back to Keycloak authentication
|
|
32
|
+
try {
|
|
33
|
+
const canActivate = await this.resourceGuard.canActivate(context);
|
|
34
|
+
return canActivate as boolean;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new UnauthorizedException('Invalid API key or Keycloak token');
|
|
37
|
+
}
|
|
50
38
|
}
|
|
51
|
-
|
|
39
|
+
|
|
40
|
+
// private validateApiKey(apiKey: string, apiSecret: string): boolean {
|
|
41
|
+
// // Implement your API key and secret validation logic here
|
|
42
|
+
// // This is just a simple example
|
|
43
|
+
// return apiKey === 'your-valid-api-key' && apiSecret === 'your-valid-api-secret';
|
|
44
|
+
// }
|
|
45
|
+
}
|
|
@@ -47,12 +47,15 @@ export class DocNumberFormatGenerator {
|
|
|
47
47
|
id: string = '',
|
|
48
48
|
) => {
|
|
49
49
|
doctype = doctype.toUpperCase();
|
|
50
|
-
|
|
50
|
+
const filter = { docNoType: doctype, active: true };
|
|
51
51
|
if (id) {
|
|
52
52
|
filter['_id'] = id;
|
|
53
53
|
}
|
|
54
|
+
//
|
|
54
55
|
Object.assign(filter, appuser.getBranchFilter());
|
|
55
|
-
const result = await this.docformat
|
|
56
|
+
const result = await this.docformat
|
|
57
|
+
.find(filter)
|
|
58
|
+
.session(appuser.getDBSession());
|
|
56
59
|
//search(appuser, filter);
|
|
57
60
|
if (result && result.length > 0) {
|
|
58
61
|
const d: Docnoformat = result[0];
|
|
@@ -79,7 +82,7 @@ export class DocNumberFormatGenerator {
|
|
|
79
82
|
}
|
|
80
83
|
} else {
|
|
81
84
|
throw new BadRequestException(
|
|
82
|
-
`
|
|
85
|
+
`No active document number found for ${doctype}. Please update in Settings > Document Numbering Format`,
|
|
83
86
|
);
|
|
84
87
|
}
|
|
85
88
|
};
|
|
@@ -3,76 +3,71 @@
|
|
|
3
3
|
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
4
|
* last change 2023-10-31
|
|
5
5
|
* Author: Ks Tan
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* this class developed for implement field level encryption, however it still half way and keep here for future enhancement
|
|
8
8
|
* it doesn't effect anything at the moment
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Injectable } from '@nestjs/common';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createCipheriv,
|
|
14
|
+
createDecipheriv,
|
|
15
|
+
randomBytes,
|
|
16
|
+
scrypt,
|
|
17
|
+
Cipher,
|
|
18
|
+
Decipher,
|
|
19
|
+
} from 'crypto';
|
|
13
20
|
import { promisify } from 'util';
|
|
14
21
|
|
|
22
|
+
export class Encryption {
|
|
23
|
+
private static instance: Encryption;
|
|
24
|
+
private algorithm = 'aes-256-ctr';
|
|
25
|
+
private iv = randomBytes(16);
|
|
26
|
+
private password = String(process.env.ENRYPTION_KEY);
|
|
15
27
|
|
|
28
|
+
private key: Buffer;
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private key :Buffer
|
|
24
|
-
|
|
25
|
-
constructor(){
|
|
26
|
-
this.init();
|
|
27
|
-
}
|
|
28
|
-
public static getInstance(): Encryption {
|
|
29
|
-
if (!Encryption.instance) {
|
|
30
|
-
Encryption.instance = new Encryption();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return Encryption.instance;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
async init (){
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
console.log("Initialized encryption class")
|
|
30
|
+
constructor() {
|
|
31
|
+
this.init();
|
|
32
|
+
}
|
|
33
|
+
public static getInstance(): Encryption {
|
|
34
|
+
if (!Encryption.instance) {
|
|
35
|
+
Encryption.instance = new Encryption();
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
38
|
+
return Encryption.instance;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async init() {
|
|
42
|
+
// console.log('Initialized encryption class');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getKey = async (salt) => {
|
|
46
|
+
const key = (await promisify(scrypt)(this.password, salt, 32)) as Buffer;
|
|
47
|
+
return key;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
encrypt = async (value: string) => {
|
|
51
|
+
const salt = 'salt';
|
|
52
|
+
const key = await this.getKey(salt);
|
|
53
|
+
const cipher = createCipheriv(this.algorithm, key, this.iv);
|
|
54
|
+
// console.log('Encrypting text ', value, cipher);
|
|
55
|
+
const encryptedText = Buffer.concat([
|
|
56
|
+
cipher.update(value),
|
|
57
|
+
cipher.final(),
|
|
58
|
+
]).toString('hex');
|
|
59
|
+
// console.log('encryptedText', encryptedText);
|
|
60
|
+
return encryptedText;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
decrypt = async (value: string, salt: string) => {
|
|
64
|
+
const key = await this.getKey(salt);
|
|
65
|
+
const decipher = createDecipheriv('aes-256-ctr', key, this.iv);
|
|
66
|
+
const buf = Buffer.from(value);
|
|
67
|
+
const decryptedText = Buffer.concat([
|
|
68
|
+
decipher.update(buf),
|
|
69
|
+
decipher.final(),
|
|
70
|
+
]).toString('hex');
|
|
71
|
+
return decryptedText;
|
|
72
|
+
};
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|