@things-factory/meta-ui 8.0.6 → 9.0.0-beta.12

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 (116) hide show
  1. package/dist-client/tsconfig.tsbuildinfo +1 -1
  2. package/dist-client/utils/service-util.d.ts +2 -2
  3. package/dist-client/utils/service-util.js +4 -4
  4. package/dist-client/utils/service-util.js.map +1 -1
  5. package/dist-server/service/index.d.ts +2 -2
  6. package/dist-server/tsconfig.tsbuildinfo +1 -1
  7. package/package.json +24 -24
  8. package/client/bootstrap.ts +0 -170
  9. package/client/component/filter/filter-form-meta-code-select.ts +0 -102
  10. package/client/component/filter/filter-form-meta-object-select.ts +0 -107
  11. package/client/component/filter/filter-grist-meta-code-select.ts +0 -97
  12. package/client/component/filter/filter-grist-meta-object-select.ts +0 -102
  13. package/client/component/grist/editor/grist-editor-code-input.js +0 -96
  14. package/client/component/grist/editor/grist-editor-meta-code-selector.js +0 -157
  15. package/client/component/grist/editor/grist-editor-meta-object-selector.js +0 -122
  16. package/client/component/grist/renderer/grist-renderer-code-input.js +0 -20
  17. package/client/component/grist/renderer/grist-renderer-meta-code-selector.js +0 -28
  18. package/client/component/grist/renderer/grist-renderer-meta-object-selector.js +0 -25
  19. package/client/component/popup/code-input-editor-popup.js +0 -111
  20. package/client/component/popup/file-upload-popup.js +0 -129
  21. package/client/component/popup/meta-object-selector-popup.ts +0 -356
  22. package/client/component/popup/record-based-code-editor-popup.ts +0 -141
  23. package/client/dynamic-menus.ts +0 -38
  24. package/client/index.ts +0 -18
  25. package/client/load-components.ts +0 -17
  26. package/client/mixin/meta-base-mixin.js +0 -323
  27. package/client/mixin/meta-basic-grist-mixin.js +0 -283
  28. package/client/mixin/meta-button-mixin.js +0 -116
  29. package/client/mixin/meta-form-mixin.js +0 -435
  30. package/client/mixin/meta-grist-tab-mixin.js +0 -335
  31. package/client/mixin/meta-main-tab-mixin.js +0 -267
  32. package/client/mixin/meta-master-detail-mixin.js +0 -395
  33. package/client/mixin/meta-service-mixin.js +0 -306
  34. package/client/mixin/meta-tab-detail-mixin.js +0 -283
  35. package/client/mixin/meta-tab-mixin.js +0 -190
  36. package/client/pages/activity/meta-activity-define-page.js +0 -422
  37. package/client/pages/activity/meta-activity-list-page.js +0 -262
  38. package/client/pages/activity/meta-activity-viewer-element.js +0 -35
  39. package/client/pages/activity/meta-activity-writer-element.js +0 -48
  40. package/client/pages/activity/meta-activiy-mixin.js +0 -79
  41. package/client/pages/button-role/button-role-detail.js +0 -50
  42. package/client/pages/button-role/button-role-page.js +0 -25
  43. package/client/pages/doc-number/doc-number-page.js +0 -24
  44. package/client/pages/doc-number/next-doc-number-popup.js +0 -25
  45. package/client/pages/entity/config-entity.js +0 -955
  46. package/client/pages/entity/main-menu-selector.js +0 -245
  47. package/client/pages/history/history-copy-list-popup.js +0 -145
  48. package/client/pages/history/history-json-list-popup.js +0 -159
  49. package/client/pages/menu/dynamic-menu-template.js +0 -92
  50. package/client/pages/menu/dynamic-menu.ts +0 -744
  51. package/client/pages/menu/export-menu-popup.js +0 -468
  52. package/client/pages/meta-form-element.js +0 -9
  53. package/client/pages/meta-grist-element.js +0 -12
  54. package/client/pages/meta-grist-page.js +0 -16
  55. package/client/pages/meta-grist-tab-element.js +0 -16
  56. package/client/pages/meta-grist-tab-page.js +0 -16
  57. package/client/pages/meta-main-tab-element.js +0 -12
  58. package/client/pages/meta-main-tab-page.js +0 -16
  59. package/client/pages/meta-master-detail-element.js +0 -12
  60. package/client/pages/meta-master-detail-page.js +0 -16
  61. package/client/pages/meta-tab-detail-element.js +0 -12
  62. package/client/pages/meta-tab-detail-page.js +0 -16
  63. package/client/pages/meta-tab-element.js +0 -15
  64. package/client/pages/printer-device/printer-device-page.js +0 -24
  65. package/client/pages/template/doc-template-page.js +0 -24
  66. package/client/pages/template/template-file-page.js +0 -24
  67. package/client/pages/terms/config-terminology.js +0 -214
  68. package/client/pages/work-code/work-code-detail-popup.js +0 -16
  69. package/client/pages/work-code/work-code-page.js +0 -23
  70. package/client/route.ts +0 -36
  71. package/client/tsconfig.json +0 -13
  72. package/client/utils/grist-default-value.js +0 -36
  73. package/client/utils/meta-api.js +0 -811
  74. package/client/utils/meta-crypto.js +0 -52
  75. package/client/utils/meta-ui-util.js +0 -3304
  76. package/client/utils/rest-service-util.js +0 -328
  77. package/client/utils/service-util.js +0 -1327
  78. package/client/utils/terms-util.ts +0 -119
  79. package/client/utils/ui-util.js +0 -338
  80. package/client/utils/value-util.js +0 -234
  81. package/server/activity/CommonActivity.ts +0 -68
  82. package/server/index.ts +0 -3
  83. package/server/routes.ts +0 -61
  84. package/server/service/button-role/button-role-mutation.ts +0 -105
  85. package/server/service/button-role/button-role-query.ts +0 -53
  86. package/server/service/button-role/button-role-type.ts +0 -39
  87. package/server/service/button-role/button-role.ts +0 -61
  88. package/server/service/button-role/index.ts +0 -7
  89. package/server/service/dynamic-menu/dynamic-menu-query.ts +0 -270
  90. package/server/service/dynamic-menu/dynamic-menu-type.ts +0 -74
  91. package/server/service/dynamic-menu/index.ts +0 -3
  92. package/server/service/entity-event-subscriber/entity-event-subscriber.ts +0 -80
  93. package/server/service/entity-event-subscriber/index.ts +0 -3
  94. package/server/service/index.ts +0 -41
  95. package/server/service/menu-button-auth/index.ts +0 -7
  96. package/server/service/menu-button-auth/menu-button-auth-mutation.ts +0 -133
  97. package/server/service/menu-button-auth/menu-button-auth-query.ts +0 -138
  98. package/server/service/menu-button-auth/menu-button-auth-type.ts +0 -63
  99. package/server/service/menu-button-auth/menu-button-auth.ts +0 -92
  100. package/server/service/meta-activity/index.ts +0 -5
  101. package/server/service/meta-activity/meta-activity-mutation.ts +0 -191
  102. package/server/service/meta-activity/meta-activity-query.ts +0 -43
  103. package/server/service/meta-activity/meta-activity-type.ts +0 -56
  104. package/server/service/set-translations/index.ts +0 -3
  105. package/server/service/set-translations/set-translation-resolver.ts +0 -63
  106. package/server/service/work-code/index.ts +0 -6
  107. package/server/service/work-code/work-code-mutation.ts +0 -147
  108. package/server/service/work-code/work-code-query.ts +0 -67
  109. package/server/service/work-code/work-code-type.ts +0 -60
  110. package/server/service/work-code/work-code.ts +0 -83
  111. package/server/service/work-code-detail/index.ts +0 -6
  112. package/server/service/work-code-detail/work-code-detail-mutation.ts +0 -149
  113. package/server/service/work-code-detail/work-code-detail-query.ts +0 -59
  114. package/server/service/work-code-detail/work-code-detail-type.ts +0 -50
  115. package/server/service/work-code-detail/work-code-detail.ts +0 -82
  116. package/server/tsconfig.json +0 -9
@@ -1,68 +0,0 @@
1
- import { ActivityInstance, /* post, */ UpdateActivityInstanceStateAddendum } from '@things-factory/worklist'
2
- import { Scenario } from '@things-factory/integration-base'
3
- import { getRepository, GraphqlLocalClient } from '@things-factory/shell'
4
-
5
- import gql from 'graphql-tag'
6
-
7
- export async function callback(
8
- activityInstance: ActivityInstance,
9
- addendum: UpdateActivityInstanceStateAddendum,
10
- context: ResolverContext
11
- ) {
12
- const { domain } = context.state
13
- const { causedBy } = addendum || {}
14
-
15
- let instanceName = ''
16
- let scenarioName = `${activityInstance.activity.name}-activity-callback`
17
-
18
- if ((await existsScenario(domain, scenarioName)) == false) {
19
- return
20
- }
21
-
22
- let variables = {
23
- activityInstance,
24
- causedBy
25
- /* post */
26
- }
27
-
28
- await runScenario(context, instanceName, scenarioName, variables)
29
- }
30
-
31
- async function existsScenario(domain: any, scenarioName: string): Promise<Boolean> {
32
- var repository = getRepository(Scenario)
33
- var scenario = await repository.findOne({
34
- where: { domain: { id: domain.id }, name: scenarioName },
35
- relations: ['domain', 'steps', 'creator', 'updater']
36
- })
37
-
38
- if (!scenario) {
39
- return false
40
- }
41
- return true
42
- }
43
-
44
- async function runScenario(context: any, instanceName: String, scenarioName: String, variables: any): Promise<void> {
45
- // await ScenarioInstanceMutation.runScenario(instanceName,scenarioName,variables,context);
46
- var client = GraphqlLocalClient.client
47
-
48
- await client.mutate({
49
- mutation: gql`
50
- mutation ($instanceName: String, $scenarioName: String!, $variables: Object) {
51
- runScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {
52
- instanceName
53
- scenarioName
54
- state
55
- result
56
- message
57
- timestamp
58
- }
59
- }
60
- `,
61
- variables: {
62
- instanceName,
63
- scenarioName,
64
- variables
65
- },
66
- context
67
- })
68
- }
package/server/index.ts DELETED
@@ -1,3 +0,0 @@
1
- import './routes'
2
-
3
- export * from './service'
package/server/routes.ts DELETED
@@ -1,61 +0,0 @@
1
- import { ActivityInstallations, Activity, ActivityStatus } from '@things-factory/worklist'
2
- import { getRepository } from '@things-factory/shell'
3
- import { callback } from './activity/CommonActivity'
4
- const path = require('path')
5
- const { appRootPath } = require('@things-factory/env')
6
- const AppPackage = require(path.resolve(appRootPath, 'package.json'))
7
-
8
- process.on('bootstrap-module-global-public-route' as any, async (app: any, globalPublicRouter) => {
9
- /*
10
- * can add global public routes to application (auth not required, tenancy not required)
11
- *
12
- * ex) routes.get('/path', async(context, next) => {})
13
- * ex) routes.post('/path', async(context, next) => {})
14
- */
15
-
16
- const releaseActivityTemplates: Activity[] = await getRepository(Activity).find({
17
- where: { state: ActivityStatus.Released }
18
- })
19
-
20
- ;(releaseActivityTemplates || []).forEach(activity => {
21
- if (activity.model && activity.model.some(x => x.name == 'relation-menu')) {
22
- ActivityInstallations.installActivityTemplate({
23
- name: `${activity.name}`,
24
- release: AppPackage.version,
25
- description: activity.description,
26
- provider: AppPackage.provider,
27
- // category: activity.category,
28
- activityType: activity.activityType,
29
- priority: activity.priority,
30
- // searchKeys: [],
31
- // startable: true,
32
- startingType: activity.startingType,
33
- model: activity.model,
34
- uiType: activity.uiType,
35
- uiSource: activity.uiSource,
36
- viewType: activity.viewType,
37
- viewSource: activity.viewSource,
38
- activity: activity,
39
- callback
40
- })
41
- }
42
- })
43
- })
44
-
45
- process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
46
- /*
47
- * can add global private routes to application (auth required, tenancy not required)
48
- */
49
- })
50
-
51
- process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
52
- /*
53
- * can add domain public routes to application (auth not required, tenancy required)
54
- */
55
- })
56
-
57
- process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
58
- /*
59
- * can add domain private routes to application (auth required, tenancy required)
60
- */
61
- })
@@ -1,105 +0,0 @@
1
- import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
- import { ButtonRole } from './button-role'
3
- import { NewButtonRole, ButtonRolePatch } from './button-role-type'
4
-
5
- @Resolver(ButtonRole)
6
- export class ButtonRoleMutation {
7
- @Directive('@transaction')
8
- @Mutation(returns => ButtonRole, { description: 'To create new ButtonRole' })
9
- async createButtonRole(@Arg('buttonRole') buttonRole: NewButtonRole, @Ctx() context: any): Promise<ButtonRole> {
10
- const { domain, user, tx } = context.state
11
-
12
- return await tx.getRepository(ButtonRole).save({
13
- ...buttonRole,
14
- domain,
15
- creator: user,
16
- updater: user
17
- })
18
- }
19
-
20
- @Directive('@transaction')
21
- @Mutation(returns => ButtonRole, { description: 'To modify ButtonRole information' })
22
- async updateButtonRole(@Arg('id') id: string, @Arg('patch') patch: ButtonRolePatch, @Ctx() context: any): Promise<ButtonRole> {
23
- const { domain, user, tx } = context.state
24
-
25
- const repository = tx.getRepository(ButtonRole)
26
- const buttonRole = await repository.findOne({
27
- where: { domain: { id: domain.id }, id },
28
- relations: ['domain', 'updater', 'creator']
29
- })
30
-
31
- return await repository.save({
32
- ...buttonRole,
33
- ...patch,
34
- updater: user
35
- })
36
- }
37
-
38
- @Directive('@transaction')
39
- @Mutation(returns => [ButtonRole], { description: "To modify multiple buttonRoles' information" })
40
- async updateMultipleButtonRole(@Arg('patches', type => [ButtonRolePatch]) patches: ButtonRolePatch[], @Ctx() context: any): Promise<ButtonRole[]> {
41
- const { domain, user, tx } = context.state
42
-
43
- let results = []
44
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
45
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
46
- const buttonRoleRepo = tx.getRepository(ButtonRole)
47
-
48
- if (_createRecords.length > 0) {
49
- for (let i = 0; i < _createRecords.length; i++) {
50
- const newRecord = _createRecords[i]
51
-
52
- const result = await buttonRoleRepo.save({
53
- ...newRecord,
54
- domain,
55
- creator: user,
56
- updater: user
57
- })
58
-
59
- results.push({ ...result, cuFlag: '+' })
60
- }
61
- }
62
-
63
- if (_updateRecords.length > 0) {
64
- for (let i = 0; i < _updateRecords.length; i++) {
65
- const updRecord = _updateRecords[i]
66
- const buttonRole = await buttonRoleRepo.findOne({
67
- where: { domain: { id: domain.id }, id: updRecord.id },
68
- relations: ['domain', 'updater', 'creator']
69
- })
70
-
71
- const result = await buttonRoleRepo.save({
72
- ...buttonRole,
73
- ...updRecord,
74
- updater: user
75
- })
76
-
77
- results.push({ ...result, cuFlag: 'M' })
78
- }
79
- }
80
-
81
- return results
82
- }
83
-
84
- @Directive('@transaction')
85
- @Mutation(returns => Boolean, { description: 'To delete ButtonRole' })
86
- async deleteButtonRole(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
87
- const { domain, tx, user } = context.state
88
- await tx.getRepository(ButtonRole).remove({ domain, id, updater: user })
89
- return true
90
- }
91
-
92
- @Directive('@transaction')
93
- @Mutation(returns => Boolean, { description: 'To delete multiple ButtonRoles' })
94
- async deleteButtonRoles(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
95
- const { domain, tx, user } = context.state
96
-
97
- let delEntitis = ids.map(id => {
98
- return { domain, id, updater: user }
99
- })
100
-
101
- await tx.getRepository(ButtonRole).remove(delEntitis)
102
-
103
- return true
104
- }
105
- }
@@ -1,53 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
- import {
3
- Domain,
4
- ListParam,
5
- convertListParams,
6
- getRepository,
7
- getQueryBuilderFromListParams
8
- } from '@things-factory/shell'
9
- import { User } from '@things-factory/auth-base'
10
- import { ButtonRole } from './button-role'
11
- import { ButtonRoleList } from './button-role-type'
12
-
13
- @Resolver(ButtonRole)
14
- export class ButtonRoleQuery {
15
- @Query(returns => ButtonRole, { description: 'To fetch a ButtonRole' })
16
- async buttonRole(@Arg('id') id: string, @Ctx() context: any): Promise<ButtonRole> {
17
- const { domain } = context.state
18
- return await getRepository(ButtonRole).findOne({
19
- where: { domain: { id: domain.id }, id }
20
- })
21
- }
22
-
23
- @Query(returns => ButtonRoleList, { description: 'To fetch a multiple ButtonRole' })
24
- async buttonRoles(@Args(type => ListParam) params: ListParam, @Ctx() context: any): Promise<ButtonRoleList> {
25
- const { domain } = context.state
26
-
27
- const queryBuilder = getQueryBuilderFromListParams({
28
- domain,
29
- params,
30
- repository: await getRepository(ButtonRole),
31
- searchables: ['name', 'description']
32
- })
33
-
34
- const [items, total] = await queryBuilder.getManyAndCount()
35
-
36
- return { items, total }
37
- }
38
-
39
- @FieldResolver(type => Domain)
40
- async domain(@Root() buttonRole: ButtonRole): Promise<Domain> {
41
- return await getRepository(Domain).findOneBy({ id: buttonRole.domainId })
42
- }
43
-
44
- @FieldResolver(type => User)
45
- async updater(@Root() buttonRole: ButtonRole): Promise<User> {
46
- return await getRepository(User).findOneBy({ id: buttonRole.updaterId })
47
- }
48
-
49
- @FieldResolver(type => User)
50
- async creator(@Root() buttonRole: ButtonRole): Promise<User> {
51
- return await getRepository(User).findOneBy({ id: buttonRole.creatorId })
52
- }
53
- }
@@ -1,39 +0,0 @@
1
-
2
- import { ObjectType, Field, InputType, Int, ID, Float, registerEnumType } from 'type-graphql'
3
- import { ObjectRef } from '@things-factory/shell'
4
-
5
- import { ButtonRole } from './button-role'
6
-
7
- @InputType()
8
- export class NewButtonRole {
9
-
10
- @Field({ nullable: false })
11
- name: string
12
-
13
- @Field({ nullable: true })
14
- description?: string
15
- }
16
-
17
- @InputType()
18
- export class ButtonRolePatch {
19
- @Field(type => ID, { nullable: true })
20
- id?: string
21
-
22
- @Field({ nullable: true })
23
- name?: string
24
-
25
- @Field({ nullable: true })
26
- description?: string
27
-
28
- @Field()
29
- cuFlag: string
30
- }
31
-
32
- @ObjectType()
33
- export class ButtonRoleList {
34
- @Field(type => [ButtonRole])
35
- items: ButtonRole[]
36
-
37
- @Field(type => Int)
38
- total: number
39
- }
@@ -1,61 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- Entity,
5
- Index,
6
- Column,
7
- RelationId,
8
- ManyToOne,
9
- OneToMany,
10
- PrimaryGeneratedColumn
11
- } from 'typeorm'
12
- import { ObjectType, Field, Int, ID, Float, registerEnumType } from 'type-graphql'
13
-
14
- import { Domain } from '@things-factory/shell'
15
- import { User } from '@things-factory/auth-base'
16
-
17
- @Entity('button_roles')
18
- @Index('ix_button_role_0', (buttonRole: ButtonRole) => [buttonRole.domain, buttonRole.name], { unique: true })
19
- @ObjectType({ description: 'Entity for ButtonRole' })
20
- export class ButtonRole {
21
- @PrimaryGeneratedColumn('uuid')
22
- @Field(type => ID)
23
- readonly id: string
24
-
25
- @Column({ name: 'name', type: 'character varying', length: 100, nullable: false })
26
- @Field({ nullable: false })
27
- name: string
28
-
29
- @Column({ name: 'description', type: 'character varying', length: 255, nullable: true })
30
- @Field({ nullable: true })
31
- description: string
32
-
33
- @ManyToOne(type => Domain)
34
- @Field(type => Domain, { nullable: false })
35
- domain: Domain
36
-
37
- @RelationId((buttonRole: ButtonRole) => buttonRole.domain)
38
- domainId: string
39
-
40
- @CreateDateColumn()
41
- @Field({ nullable: true })
42
- createdAt?: Date
43
-
44
- @UpdateDateColumn()
45
- @Field({ nullable: true })
46
- updatedAt?: Date
47
-
48
- @ManyToOne(type => User, { createForeignKeyConstraints: false, nullable: true })
49
- @Field(type => User, { nullable: true })
50
- creator?: User
51
-
52
- @RelationId((buttonRole: ButtonRole) => buttonRole.creator)
53
- creatorId?: string
54
-
55
- @ManyToOne(type => User, { createForeignKeyConstraints: false, nullable: true })
56
- @Field(type => User, { nullable: true })
57
- updater?: User
58
-
59
- @RelationId((buttonRole: ButtonRole) => buttonRole.updater)
60
- updaterId?: string
61
- }
@@ -1,7 +0,0 @@
1
-
2
- import { ButtonRole } from './button-role'
3
- import { ButtonRoleQuery } from './button-role-query'
4
- import { ButtonRoleMutation } from './button-role-mutation'
5
-
6
- export const entities = [ButtonRole]
7
- export const resolvers = [ButtonRoleQuery, ButtonRoleMutation]
@@ -1,270 +0,0 @@
1
- import { Resolver, FieldResolver, Root, Query, Args, Ctx, Arg } from 'type-graphql'
2
- import { ListParam, getRepository, getQueryBuilderFromListParams } from '@things-factory/shell'
3
- import { Menu } from '@things-factory/menu-base'
4
-
5
- import { DynamicMenuList, ExportMenuInfo } from './dynamic-menu-type'
6
-
7
- import { Entity, EntityColumn } from '@things-factory/resource-base'
8
-
9
- import crypto from 'crypto'
10
- const { camelCase, startCase, snakeCase, kebabCase, upperFirst } = require('lodash')
11
-
12
- @Resolver(Menu)
13
- export class DynamicMenuQuery {
14
- @Query(returns => ExportMenuInfo, { description: 'To fetch a export menu data' })
15
- async exportMenuInfo(@Arg('id') id: string, @Ctx() context: any): Promise<ExportMenuInfo> {
16
- const { domain } = context.state
17
-
18
- // 메뉴
19
- const menu: Menu = await getRepository(Menu).findOneBy({ id: id, domain: { id: domain.id } })
20
- const parentMenu: Menu = await getRepository(Menu).findOneBy({ id: menu.parentId, domain: { id: domain.id } })
21
-
22
- // entity
23
- let entityName = upperFirst(camelCase(menu.routing))
24
- const entity: Entity = await getRepository(Entity).findOneBy({ domain: { id: domain.id }, name: entityName })
25
-
26
- // entity Columns
27
- const entityColumns: EntityColumn[] = await getRepository(EntityColumn).findBy({
28
- domain: { id: domain.id },
29
- entity: { id: entity.id }
30
- })
31
-
32
- let entityMeta = getRepository(entityName).metadata
33
-
34
- const indices = entityMeta.indices.map(x => {
35
- return {
36
- name: x.name,
37
- isUnique: x.isUnique,
38
- columns: x.columns.map(y => {
39
- return y.databaseName.toUpperCase()
40
- })
41
- }
42
- })
43
-
44
- const columns = entityMeta.columns
45
- .map(x => {
46
- return {
47
- name: x.databaseName,
48
- isNullable: x.isNullable,
49
- length: x.type == 'numeric' ? [x.precision, x.scale].join(',') : x.length,
50
- type: x.type.toString(),
51
- default: typeof x.default === 'function' ? undefined : x.default
52
- }
53
- })
54
- .filter(x => ['data_revision_no', 'deleted_at'].includes(x.name) == false)
55
-
56
- return {
57
- id,
58
- menu,
59
- entity,
60
- entityColumns,
61
- indices,
62
- columns,
63
- parentMenu
64
- }
65
- }
66
-
67
- @Query(returns => DynamicMenuList, { description: 'To fetch multiple dynamicMenus' })
68
- async dynamicMenus(@Args(type => ListParam) params: ListParam, @Ctx() context: any): Promise<DynamicMenuList> {
69
- const { domain } = context.state
70
-
71
- let templateCodeIdx = params.filters?.findIndex(x => x.name == 'templateCode')
72
- let templateCode = undefined
73
-
74
- if (templateCodeIdx > -1) {
75
- templateCode = params.filters[templateCodeIdx].value
76
- params.filters = params.filters.filter(x => x.name != 'templateCode')
77
- }
78
-
79
- let templateTextIdx = params.filters?.findIndex(x => x.name == 'templateText')
80
- let templateText = undefined
81
-
82
- if (templateTextIdx > -1) {
83
- templateText = params.filters[templateTextIdx].value
84
- params.filters = params.filters.filter(x => x.name != 'templateText')
85
- }
86
-
87
- if (templateText) {
88
- params.pagination.limit = 0
89
- params.pagination.page = 0
90
- }
91
-
92
- let groupSearch =
93
- params.filters?.findIndex(x => x.name == 'parentId' && x.operator == 'is_null') > -1 ? true : false
94
-
95
- const queryBuilder = getQueryBuilderFromListParams({
96
- domain,
97
- params,
98
- repository: await getRepository(Menu),
99
- searchables: ['name', 'description', 'routing']
100
- })
101
-
102
- let [items, total] = await queryBuilder.getManyAndCount()
103
- let result: DynamicMenuList = { items: items, total: total }
104
-
105
- let self = this
106
-
107
- if (templateText) {
108
- if (groupSearch === true) {
109
- for (let idx = 0; idx < result.items.length; idx++) {
110
- result.items[idx].children = await getRepository(Menu).findBy({ parent: { id: result.items[idx].id } })
111
- }
112
- }
113
-
114
- items = items.filter(function (item: Menu) {
115
- return self.checkTemplateByContainsText(
116
- templateCode,
117
- templateText,
118
- groupSearch === true ? item.children : item.template
119
- )
120
- })
121
- }
122
-
123
- return {
124
- items,
125
- total
126
- }
127
- }
128
-
129
- checkTemplate(code: string, text: string, template: string) {
130
- if (!template) return false
131
-
132
- let templateString: any = ''
133
- let templateJsonStr = this.dec(template)
134
- let templateJson = JSON.parse(templateJsonStr)
135
-
136
- if (code === 'col-name') {
137
- templateString = templateJson['grid_column'].map(x => {
138
- return x.name
139
- })
140
- } else if (code === 'object-custom') {
141
- templateString = JSON.stringify(
142
- templateJson['grid_column']
143
- .filter(
144
- x =>
145
- ['meta-object-selector', 'object', 'resource-object'].includes(x.type) &&
146
- x.object_opt &&
147
- !x.object_opt.menu
148
- )
149
- .map(x => {
150
- return x.object_opt
151
- })
152
- )
153
- } else if (code === 'object-menu') {
154
- templateString = JSON.stringify(
155
- templateJson['grid_column']
156
- .filter(
157
- x =>
158
- ['meta-object-selector', 'object', 'resource-object'].includes(x.type) &&
159
- x.object_opt &&
160
- x.object_opt.menu
161
- )
162
- .map(x => {
163
- return x.object_opt.menu
164
- })
165
- )
166
- } else if (code === 'code-custom') {
167
- templateString = JSON.stringify(
168
- templateJson['grid_column']
169
- .filter(
170
- x => ['meta-code-selector', 'resource-code-selector'].includes(x.type) && x.object_opt && !x.object_opt.menu
171
- )
172
- .map(x => {
173
- return x.object_opt
174
- })
175
- )
176
- } else if (code === 'code-menu') {
177
- templateString = JSON.stringify(
178
- templateJson['grid_column']
179
- .filter(
180
- x => ['meta-code-selector', 'resource-code-selector'].includes(x.type) && x.object_opt && x.object_opt.menu
181
- )
182
- .map(x => {
183
- return x.object_opt.menu
184
- })
185
- )
186
- } else if (code === 'selector-entity') {
187
- templateString = JSON.stringify(
188
- templateJson['grid_column']
189
- .filter(x => x.type == 'select' && x.select_opt && x.select_opt.type == 'entity')
190
- .map(x => {
191
- return x.select_opt
192
- })
193
- )
194
- } else if (code === 'selector-code') {
195
- templateString = JSON.stringify(
196
- templateJson['grid_column']
197
- .filter(x => x.type == 'select' && x.select_opt && x.select_opt.type == 'code')
198
- .map(x => {
199
- return x.select_opt.name
200
- })
201
- )
202
- } else if (code === 'selector-scenario') {
203
- templateString = JSON.stringify(
204
- templateJson['grid_column']
205
- .filter(x => x.type == 'select' && x.select_opt && x.select_opt.type == 'scenario')
206
- .map(x => {
207
- return x.select_opt.name
208
- })
209
- )
210
- } else {
211
- templateString = templateJsonStr
212
- }
213
-
214
- return templateString.includes(text)
215
- }
216
-
217
- checkTemplateByContainsText(code: string, text: string, template: any) {
218
- if (Array.isArray(template)) {
219
- for (let idx = 0; idx < template.length; idx++) {
220
- let contains = this.checkTemplate(code, text, template[idx].template)
221
-
222
- if (contains == true) {
223
- return true
224
- }
225
- }
226
-
227
- return false
228
- } else {
229
- return this.checkTemplate(code, text, template)
230
- }
231
- }
232
-
233
- dec(template: string): string {
234
- let decResults = []
235
- let encTemps = template.split('h1z0q9i9x7q6')
236
- let filters = [
237
- 'aes-256-ecb',
238
- 'aes-256-cbc',
239
- 'aes-256-cfb',
240
- 'aes-256-cfb8',
241
- 'aes-256-cfb1',
242
- 'aes-256-ofb',
243
- 'aes-256-ctr',
244
- 'aes256'
245
- ]
246
- let salt = encTemps[0]
247
- let hexKey = Buffer.from(salt, 'hex')
248
- let ivBase = salt.substring(0, 16)
249
- let iv = ['', ivBase, ivBase, ivBase, ivBase, ivBase, ivBase, ivBase]
250
- let filterIdx = 0
251
-
252
- encTemps = encTemps.splice(1)
253
-
254
- for (var i = 0; i < encTemps.length; i++, filterIdx++) {
255
- if (filterIdx == filters.length) filterIdx = 0
256
-
257
- let decipher = crypto.createDecipheriv(filters[filterIdx], hexKey, iv[filterIdx])
258
- let decrypted = decipher.update(encTemps[i], 'hex', 'utf8')
259
- decrypted += decipher.final('utf8')
260
-
261
- decResults.push(decrypted)
262
- }
263
- return JSON.parse(decResults.join(''))
264
- }
265
-
266
- @FieldResolver(type => Menu)
267
- async parent(@Root() menu: Menu): Promise<Menu> {
268
- return await getRepository(Menu).findOneBy({ id: menu.parentId })
269
- }
270
- }