@things-factory/shell 8.0.0-beta.1 → 8.0.0-beta.2

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 (55) hide show
  1. package/package.json +6 -6
  2. package/server/graphql-local-client.ts +0 -59
  3. package/server/index.ts +0 -13
  4. package/server/initializers/database.ts +0 -96
  5. package/server/initializers/naming-strategy.ts +0 -14
  6. package/server/middlewares/domain-middleware.ts +0 -60
  7. package/server/middlewares/index.ts +0 -43
  8. package/server/migrations/1000000000000-SeedDomain.ts +0 -37
  9. package/server/migrations/index.ts +0 -9
  10. package/server/pubsub-log-transport.ts +0 -59
  11. package/server/pubsub.ts +0 -84
  12. package/server/routers/domain-router.ts +0 -13
  13. package/server/routers/global-router.ts +0 -76
  14. package/server/routers/graphql-router.ts +0 -3
  15. package/server/routers/index.ts +0 -3
  16. package/server/schema.ts +0 -163
  17. package/server/server-dev.ts +0 -305
  18. package/server/server.ts +0 -296
  19. package/server/service/attribute-set/attribute-set-item-type.ts +0 -65
  20. package/server/service/attribute-set/attribute-set-mutation.ts +0 -125
  21. package/server/service/attribute-set/attribute-set-query.ts +0 -36
  22. package/server/service/attribute-set/attribute-set-type.ts +0 -46
  23. package/server/service/attribute-set/attribute-set.ts +0 -35
  24. package/server/service/attribute-set/index.ts +0 -6
  25. package/server/service/common-types/index.ts +0 -6
  26. package/server/service/common-types/list-param.ts +0 -61
  27. package/server/service/common-types/log.ts +0 -17
  28. package/server/service/common-types/object-ref.ts +0 -13
  29. package/server/service/common-types/scalar-any.ts +0 -44
  30. package/server/service/common-types/scalar-date.ts +0 -22
  31. package/server/service/common-types/scalar-object.ts +0 -15
  32. package/server/service/directive-transaction/index.ts +0 -1
  33. package/server/service/directive-transaction/transaction.ts +0 -40
  34. package/server/service/domain/domain-mutation.ts +0 -120
  35. package/server/service/domain/domain-query.ts +0 -48
  36. package/server/service/domain/domain-types.ts +0 -63
  37. package/server/service/domain/domain.ts +0 -147
  38. package/server/service/domain/index.ts +0 -6
  39. package/server/service/index.ts +0 -32
  40. package/server/service/subscription-data/data-resolver.ts +0 -37
  41. package/server/service/subscription-data/data-types.ts +0 -16
  42. package/server/service/subscription-data/index.ts +0 -4
  43. package/server/typeorm/encrypt-transform.ts +0 -70
  44. package/server/typeorm/get-data-encryption-key.ts +0 -13
  45. package/server/typeorm/json5-transform.ts +0 -26
  46. package/server/typeorm/round-transform.ts +0 -20
  47. package/server/utils/condition-builder.ts +0 -145
  48. package/server/utils/get-domain.ts +0 -226
  49. package/server/utils/get-query-builder-from-list-params.ts +0 -469
  50. package/server/utils/get-times-for-period.ts +0 -60
  51. package/server/utils/index.ts +0 -8
  52. package/server/utils/list-param-adjuster.ts +0 -21
  53. package/server/utils/list-params-converter.ts +0 -200
  54. package/server/utils/list-query-builder.ts +0 -120
  55. package/server/utils/publish-progress.ts +0 -23
@@ -1,200 +0,0 @@
1
- import { Between, Equal, FindOperator, ILike, In, IsNull, Like, Not, Raw } from 'typeorm'
2
-
3
- import { Filter, ListParam, Pagination, Sorting } from '../service/common-types'
4
- import { Domain } from '../service/domain/domain'
5
- import { adjustFilters } from './list-param-adjuster'
6
-
7
- const OPERATION_FUNCTION_MAP: { [operator: string]: (value: any) => FindOperator<any> } = {
8
- search: value => ILike(value),
9
- eq: value => Equal(value),
10
- noteq: value => Not(Equal(value)),
11
- like: value => Like(value),
12
- i_like: value => ILike(value),
13
- nlike: value => Not(Like(value)),
14
- i_nlike: value => Not(ILike(value)),
15
- lt: value => Raw(alias => `${alias} < ${typeof value === 'string' ? "'" + value + "'" : value}`),
16
- gt: value => Raw(alias => `${alias} > ${typeof value === 'string' ? "'" + value + "'" : value}`),
17
- lte: value => Raw(alias => `${alias} <= ${typeof value === 'string' ? "'" + value + "'" : value}`),
18
- gte: value => Raw(alias => `${alias} >= ${typeof value === 'string' ? "'" + value + "'" : value}`),
19
- in: value => In(value),
20
- notin: value => Not(In(value)),
21
- is_null: () => IsNull(),
22
- is_not_null: () => Not(IsNull()),
23
- is_false: () => Raw(alias => `${alias} IS FALSE`),
24
- in_true: () => Raw(alias => `${alias} IS TRUE`),
25
- is_not_true: () => Raw(alias => `${alias} IS NOT TRUE`),
26
- is_present: () => Raw(alias => `${alias} IS PRESENT`),
27
- is_blank: () => Raw(alias => `${alias} IS BLANK`),
28
- is_empty_num_id: () => Raw(alias => `${alias} IS EMPTY NUMERIC ID`),
29
- between: value => Between(value[0], value[1])
30
- }
31
-
32
- /**
33
- * Get the TypeORM FindOperator function for a given filter.
34
- * @param {Filter} filter - The filter object containing operator and value.
35
- * @returns {FindOperator<any>} - The corresponding FindOperator function.
36
- */
37
- function getOperatorFunction({ operator, value }: Filter): FindOperator<any> {
38
- return OPERATION_FUNCTION_MAP[operator](value)
39
- }
40
-
41
- /**
42
- * Create pagination parameters for a TypeORM query.
43
- * @param {Pagination} pagination - The pagination object.
44
- * @returns {{ skip?: number; take?: number }} - The pagination parameters.
45
- */
46
- function makePaginationParams(pagination: Pagination): { skip?: number; take?: number } {
47
- var result = {} as { skip?: number; take?: number }
48
- if (pagination) {
49
- var { page = 0, limit = 0 } = pagination
50
- var skip = 0
51
- var take = 0
52
-
53
- if (limit > 0) {
54
- skip = Math.max(page - 1, 0) * limit
55
- take = limit
56
- Object.assign(result, {
57
- skip,
58
- take
59
- })
60
- }
61
- }
62
-
63
- return result
64
- }
65
-
66
- /**
67
- * Create sorting parameters for a TypeORM query.
68
- * @param {Sorting[]} sortings - The array of sorting objects.
69
- * @returns {{ order?: { [name: string]: 'DESC' | 'ASC' } }} - The sorting parameters.
70
- */
71
- function makeSortingParams(sortings: Sorting[]): { order?: { [name: string]: 'DESC' | 'ASC' } } {
72
- var result = {} as { order?: { [name: string]: 'DESC' | 'ASC' } }
73
- if (sortings) {
74
- var order = {} as { [name: string]: 'DESC' | 'ASC' }
75
- sortings.forEach(s => {
76
- order[s.name] = s.desc ? 'DESC' : 'ASC'
77
- })
78
-
79
- Object.assign(result, {
80
- order
81
- })
82
- }
83
-
84
- return result
85
- }
86
-
87
- /**
88
- * Create filter parameters for a TypeORM query.
89
- * @param {Filter[]} filters - The array of filter objects.
90
- * @param {string[]} searchables - The array of searchable field names.
91
- * @returns {{ where: { [name: string]: FindOperator<any> } | { [name: string]: FindOperator<any> }[] }} - The filter parameters.
92
- */
93
- function makeFilterParams(
94
- filters: Filter[],
95
- searchables?: string[]
96
- ): {
97
- where: { [name: string]: FindOperator<any> } | { [name: string]: FindOperator<any> }[]
98
- } {
99
- /* for where AND clauses */
100
- const columnFilters =
101
- filters?.filter(filter => {
102
- if (filter.operator === 'search') {
103
- return false
104
- }
105
- if (filter.operator.toLowerCase().includes('like') && (!searchables || !searchables.includes(filter.name))) {
106
- return false
107
- }
108
- return true
109
- }) || []
110
-
111
- const searchFilters =
112
- searchables instanceof Array
113
- ? filters?.filter(filter => {
114
- if (filter.operator !== 'search') {
115
- return false
116
- }
117
- if (!searchables.includes(filter.name)) {
118
- console.warn('"searchables" setting is required for like searches with a heavy database query load', filter.name)
119
- return false
120
- }
121
- return true
122
- }) || []
123
- : []
124
-
125
- const columnWhere = columnFilters.reduce((where, f) => {
126
- where[f.name] = getOperatorFunction(f)
127
- return where
128
- }, {} as { [name: string]: FindOperator<any> })
129
-
130
- if (searchFilters.length === 0) {
131
- return {
132
- where: columnWhere
133
- }
134
- }
135
-
136
- /* for fulltext searching ... OR-AND composition */
137
- const searchWheres = searchFilters.map(f => {
138
- return {
139
- [f.name]: getOperatorFunction(f),
140
- ...columnWhere
141
- }
142
- })
143
-
144
- return {
145
- where: searchWheres
146
- }
147
- }
148
-
149
- /**
150
- * Convert ListParam object to TypeORM query parameters.
151
- * @param {ListParam} params - The ListParam object containing pagination, sorting, and filtering options.
152
- * @param {string | { domain?: string | Domain; searchables?: string[] }} options - Optional domain and searchables parameters.
153
- * @returns {{ where?: { [name: string]: FindOperator<any> }; order?: { [name: string]: 'DESC' | 'ASC' }; skip?: number; take?: number }} - The TypeORM query parameters.
154
- */
155
- export function convertListParams(
156
- params: ListParam,
157
- options?:
158
- | string
159
- | {
160
- domain?: string | Domain
161
- searchables?: string[]
162
- }
163
- ): {
164
- where?: { [name: string]: FindOperator<any> }
165
- order?: {
166
- [name: string]: 'DESC' | 'ASC'
167
- }
168
- skip?: number
169
- take?: number
170
- } {
171
- var domainId: string | undefined
172
-
173
- if (options) {
174
- if (typeof options === 'string' /* for 하위 호환성 */) {
175
- var domainId = options
176
- } else {
177
- var { domain, searchables } = options
178
- var domainId = typeof domain === 'string' ? domain : domain?.id
179
- }
180
- }
181
-
182
- var { pagination, filters = [], sortings } = params
183
- var result = {}
184
-
185
- if (domainId) {
186
- filters = adjustFilters(filters, [
187
- {
188
- name: 'domain',
189
- operator: 'eq',
190
- value: domainId
191
- }
192
- ])
193
- }
194
-
195
- if (pagination) Object.assign(result, makePaginationParams(pagination))
196
- if (sortings) Object.assign(result, makeSortingParams(sortings))
197
- if (filters) Object.assign(result, makeFilterParams(filters, searchables))
198
-
199
- return result
200
- }
@@ -1,120 +0,0 @@
1
- import { Brackets } from 'typeorm'
2
-
3
- import { buildCondition } from './condition-builder'
4
- import { Filter, ListParam, InheritedValueType } from '../service/common-types/list-param'
5
-
6
- /**
7
- * @deprecated This function is recommended to be replaced with the `getQueryBuilderFromListParams` function.
8
- *
9
- * Builds a TypeORM query using the provided parameters to filter, paginate, and sort the data.
10
- *
11
- * @param {QueryBuilder} queryBuilder - The TypeORM query builder to build the query on.
12
- * @param {ListParam} params - The list parameters to apply to the query.
13
- * @param {Object} context - The context object, typically containing information about the user's domain.
14
- * @param {boolean|Object} options - Additional options for the query builder.
15
- * @param {boolean} options.domainRef - Indicates whether to include domain reference in the query.
16
- * @param {string[]} options.searchables - An array of searchable field names.
17
- */
18
- export const buildQuery = function (
19
- queryBuilder: any,
20
- params: ListParam,
21
- context: any,
22
- options?:
23
- | boolean
24
- | {
25
- domainRef?: boolean
26
- searchables?: string[]
27
- }
28
- ) {
29
- /* default value of domainRef is 'true' */
30
- var domainRef = typeof options === 'boolean' ? options : true
31
-
32
- /* for backwards compatibility of function spec */
33
- if (typeof options === 'object') {
34
- var { domainRef = true, searchables } = options
35
- }
36
-
37
- const columnFilters: Filter[] =
38
- params.filters?.filter(filter => {
39
- if (filter.operator === 'search') {
40
- return false
41
- }
42
- if (filter.operator.toLowerCase().includes('like') && (!searchables || !searchables.includes(filter.name))) {
43
- console.warn('"searchables" setting is required for like searches with a heavy database query load', filter.name)
44
- return false
45
- }
46
- return true
47
- }) || []
48
-
49
- const searchFilters =
50
- searchables instanceof Array
51
- ? params.filters?.filter(filter => {
52
- if (filter.operator !== 'search') {
53
- return false
54
- }
55
- if (!searchables.includes(filter.name)) {
56
- console.warn('"searchables" setting is required for like searches with a heavy database query load', filter.name)
57
- return false
58
- }
59
- return true
60
- }) || []
61
- : []
62
-
63
- const pagination = params.pagination
64
- const sortings = params.sortings
65
- const domain = context?.state.domain
66
-
67
- if (columnFilters && columnFilters.length > 0) {
68
- columnFilters.forEach(filter => {
69
- const condition = buildCondition(queryBuilder.alias, filter.name, filter.operator, filter.value, filter.relation, Object.keys(queryBuilder.getParameters()).length)
70
-
71
- if (condition?.clause) queryBuilder.andWhere(condition.clause)
72
- if (condition?.parameters) queryBuilder.setParameters(condition.parameters)
73
- })
74
- }
75
-
76
- if (searchFilters.length > 0) {
77
- queryBuilder.andWhere(
78
- new Brackets(qb => {
79
- searchFilters.forEach((filter, index) => {
80
- const clause = `${queryBuilder.alias}.${filter.name} LIKE :${filter.name}`
81
- const parameters = { [filter.name]: filter.value }
82
-
83
- index === 0 ? qb.where(clause, parameters) : qb.orWhere(clause, parameters)
84
- })
85
- })
86
- )
87
- }
88
-
89
- if (domainRef) {
90
- const inherited = params?.inherited || InheritedValueType.None
91
-
92
- if (!inherited || inherited == InheritedValueType.None) {
93
- queryBuilder.andWhere(`${queryBuilder.alias}.domain = :domain`, { domain: domain.id })
94
- } else if (inherited == InheritedValueType.Include) {
95
- queryBuilder.andWhere(`${queryBuilder.alias}.domain In(:...domains)`, {
96
- domains: [domain.id, domain.parentId].filter(Boolean)
97
- })
98
- } else if (inherited == InheritedValueType.Only) {
99
- queryBuilder.andWhere(`${queryBuilder.alias}.domain = :domain`, { domain: domain.parentId || 'Impossible' })
100
- } else {
101
- queryBuilder.andWhere(`${queryBuilder.alias}.domain = :domain`, { domain: 'Impossible' })
102
- }
103
- }
104
-
105
- if (pagination && pagination.page > 0 && pagination.limit > 0) {
106
- queryBuilder.skip(pagination.limit * (pagination.page - 1))
107
- queryBuilder.take(pagination.limit)
108
- }
109
-
110
- if (sortings && sortings.length > 0) {
111
- sortings.forEach((sorting, index) => {
112
- const sortField = sorting.name.split('.').length > 1 ? sorting.name : `${queryBuilder.alias}.${sorting.name}`
113
- if (index === 0) {
114
- queryBuilder.orderBy(sortField, sorting.desc ? 'DESC' : 'ASC')
115
- } else {
116
- queryBuilder.addOrderBy(sortField, sorting.desc ? 'DESC' : 'ASC')
117
- }
118
- })
119
- }
120
- }
@@ -1,23 +0,0 @@
1
- import { pubsub } from '../pubsub'
2
-
3
- /**
4
- * Publishes a progress update message to the 'data' channel in the Pub/Sub system.
5
- *
6
- * @param {Object} param - The progress update parameters.
7
- * @param {string} param.domain - The domain or category of the progress update.
8
- * @param {string} param.tag - The tag or identifier for the progress update.
9
- * @param {number} param.progress - The progress value indicating the completion percentage.
10
- * @param {string} param.message - A message or description of the progress update.
11
- */
12
- export function publishProgress({ domain, tag, progress, message }) {
13
- pubsub.publish('data', {
14
- data: {
15
- domain,
16
- tag,
17
- data: {
18
- progress,
19
- message
20
- }
21
- }
22
- })
23
- }