@things-factory/tutorial-base 8.0.38 → 9.0.0-9.0.0-beta.59.0

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 (34) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +4 -4
  3. package/server/entities/index.ts +0 -5
  4. package/server/entities/tutorial-role.ts +0 -48
  5. package/server/entities/tutorial.ts +0 -57
  6. package/server/graphql/index.ts +0 -7
  7. package/server/graphql/resolvers/index.ts +0 -6
  8. package/server/graphql/resolvers/tutorial/delete-tutorials.ts +0 -14
  9. package/server/graphql/resolvers/tutorial/index.ts +0 -15
  10. package/server/graphql/resolvers/tutorial/tutorial.ts +0 -14
  11. package/server/graphql/resolvers/tutorial/tutorials.ts +0 -38
  12. package/server/graphql/resolvers/tutorial/update-multiple-tutorial.ts +0 -44
  13. package/server/graphql/resolvers/tutorial-role/index.ts +0 -16
  14. package/server/graphql/resolvers/tutorial-role/list-by-roles.ts +0 -21
  15. package/server/graphql/resolvers/tutorial-role/tutorial-role-assignments.ts +0 -26
  16. package/server/graphql/resolvers/tutorial-role/tutorial-role.ts +0 -14
  17. package/server/graphql/resolvers/tutorial-role/tutorial-roles.ts +0 -14
  18. package/server/graphql/resolvers/tutorial-role/update-role-tutorial.ts +0 -47
  19. package/server/graphql/types/index.ts +0 -8
  20. package/server/graphql/types/tutorial/index.ts +0 -22
  21. package/server/graphql/types/tutorial/new-tutorial.ts +0 -13
  22. package/server/graphql/types/tutorial/tutorial-list.ts +0 -8
  23. package/server/graphql/types/tutorial/tutorial-patch.ts +0 -15
  24. package/server/graphql/types/tutorial/tutorial.ts +0 -19
  25. package/server/graphql/types/tutorial-role/index.ts +0 -22
  26. package/server/graphql/types/tutorial-role/new-tutorial-role.ts +0 -9
  27. package/server/graphql/types/tutorial-role/role-list.ts +0 -8
  28. package/server/graphql/types/tutorial-role/role-tutorial.ts +0 -11
  29. package/server/graphql/types/tutorial-role/tutorial-role-list.ts +0 -8
  30. package/server/graphql/types/tutorial-role/tutorial-role-patch.ts +0 -11
  31. package/server/graphql/types/tutorial-role/tutorial-role.ts +0 -17
  32. package/server/index.ts +0 -3
  33. package/server/migrations/index.ts +0 -9
  34. package/server/routes.ts +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/tutorial-base",
3
- "version": "8.0.38",
3
+ "version": "9.0.0-9.0.0-beta.59.0",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,8 +24,8 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/auth-base": "^8.0.38",
28
- "@things-factory/shell": "^8.0.38"
27
+ "@things-factory/auth-base": "^9.0.0-9.0.0-beta.59.0",
28
+ "@things-factory/shell": "^9.0.0-9.0.0-beta.59.0"
29
29
  },
30
- "gitHead": "613db8b1fa9fd156294f113518348247ae61a2db"
30
+ "gitHead": "cf6ee84b991f469a4e71198b0e6314b45e9e10b8"
31
31
  }
@@ -1,5 +0,0 @@
1
- import { Tutorial } from './tutorial'
2
- import { TutorialRole } from './tutorial-role'
3
-
4
- export const entities = [Tutorial, TutorialRole]
5
- export { Tutorial, TutorialRole }
@@ -1,48 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- Entity,
5
- Index,
6
- Column,
7
- OneToMany,
8
- ManyToOne,
9
- PrimaryGeneratedColumn
10
- } from 'typeorm'
11
- import { Domain } from '@things-factory/shell'
12
- import { User, Role } from '@things-factory/auth-base'
13
- import { Tutorial } from '.'
14
-
15
- @Entity()
16
- @Index('ix_tutorial-role_0', (tutorialRole: TutorialRole) => [tutorialRole.domain, tutorialRole.name], { unique: true })
17
- export class TutorialRole {
18
- @PrimaryGeneratedColumn('uuid')
19
- id: string
20
-
21
- @ManyToOne(type => Domain)
22
- domain: Domain
23
-
24
- @Column()
25
- name: string
26
-
27
- @ManyToOne(type => Role)
28
- role: Role
29
-
30
- @ManyToOne(type => Tutorial)
31
- tutorial: Tutorial
32
-
33
- @CreateDateColumn()
34
- createdAt: Date
35
-
36
- @UpdateDateColumn()
37
- updatedAt: Date
38
-
39
- @ManyToOne(type => User, {
40
- nullable: true
41
- })
42
- creator: User
43
-
44
- @ManyToOne(type => User, {
45
- nullable: true
46
- })
47
- updater: User
48
- }
@@ -1,57 +0,0 @@
1
- import { CreateDateColumn, UpdateDateColumn, Entity, Index, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
2
- import { Domain } from '@things-factory/shell'
3
- import { User, Role } from '@things-factory/auth-base'
4
-
5
- @Entity()
6
- @Index('ix_tutorial_0', (tutorial: Tutorial) => [tutorial.domain, tutorial.name], { unique: true })
7
- export class Tutorial {
8
- @PrimaryGeneratedColumn('uuid')
9
- id: string
10
-
11
- @ManyToOne(type => Domain)
12
- domain: Domain
13
-
14
- @Column()
15
- name: string
16
-
17
- @Column({
18
- nullable: true
19
- })
20
- description: string
21
-
22
- @Column({
23
- nullable: true
24
- })
25
- resourceUrl: string
26
-
27
- @Column({
28
- nullable: true
29
- })
30
- value: string
31
-
32
- @Column({
33
- nullable: true
34
- })
35
- duration: string
36
-
37
- @Column('int', {
38
- nullable: true
39
- })
40
- rank: number
41
-
42
- @CreateDateColumn()
43
- createdAt: Date
44
-
45
- @UpdateDateColumn()
46
- updatedAt: Date
47
-
48
- @ManyToOne(type => User, {
49
- nullable: true
50
- })
51
- creator: User
52
-
53
- @ManyToOne(type => User, {
54
- nullable: true
55
- })
56
- updater: User
57
- }
@@ -1,7 +0,0 @@
1
- import * as typeDefs from './types'
2
- import * as resolvers from './resolvers'
3
-
4
- export const schema = {
5
- typeDefs,
6
- resolvers
7
- }
@@ -1,6 +0,0 @@
1
- import * as Tutorial from './tutorial'
2
- import * as TutorialRole from './tutorial-role'
3
-
4
- export const queries = [Tutorial.Query, TutorialRole.Query]
5
-
6
- export const mutations = [Tutorial.Mutation, TutorialRole.Mutation]
@@ -1,14 +0,0 @@
1
- import { In } from 'typeorm'
2
-
3
- import { Tutorial } from '../../../entities'
4
-
5
- export const deleteTutorials = {
6
- async deleteTutorials(_: any, { ids }, context: ResolverContext) {
7
- const { tx, domain } = context.state
8
- await tx.getRepository(Tutorial).delete({
9
- domain: { id: domain.id },
10
- id: In(ids)
11
- })
12
- return true
13
- }
14
- }
@@ -1,15 +0,0 @@
1
- import { tutorialResolver } from './tutorial'
2
- import { tutorialsResolver } from './tutorials'
3
-
4
- import { updateMultipleTutorial } from './update-multiple-tutorial'
5
- import { deleteTutorials } from './delete-tutorials'
6
-
7
- export const Query = {
8
- ...tutorialsResolver,
9
- ...tutorialResolver
10
- }
11
-
12
- export const Mutation = {
13
- ...updateMultipleTutorial,
14
- ...deleteTutorials
15
- }
@@ -1,14 +0,0 @@
1
- import { getRepository } from '@things-factory/shell'
2
-
3
- import { Tutorial } from '../../../entities'
4
-
5
- export const tutorialResolver = {
6
- async tutorial(_: any, { name }, context: ResolverContext) {
7
- const { domain } = context.state
8
-
9
- return await getRepository(Tutorial).findOne({
10
- where: { domain: { id: domain.id }, name },
11
- relations: ['domain', 'creator', 'updater']
12
- })
13
- }
14
- }
@@ -1,38 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm'
2
-
3
- import { Role } from '@things-factory/auth-base'
4
- import { convertListParams, getRepository, ListParam } from '@things-factory/shell'
5
-
6
- import { Tutorial, TutorialRole } from '../../../entities'
7
-
8
- export const tutorialsResolver = {
9
- async tutorials(_: any, params: ListParam, context: ResolverContext) {
10
- const convertedParams = convertListParams(params)
11
- const [items, total] = await getRepository(Tutorial).findAndCount({
12
- ...convertedParams,
13
- relations: ['domain', 'creator', 'updater']
14
- })
15
- return { items, total }
16
- },
17
-
18
- async tutorialsWithRoles(_: any, { roleNames }, context: ResolverContext) {
19
- let filter: string[] = roleNames.split(',')
20
- const qb: SelectQueryBuilder<Tutorial> = getRepository(Tutorial)
21
- .createQueryBuilder('tutorial')
22
- .select('tutorial.id', 'id')
23
- .addSelect('tutorial.name', 'name')
24
- .addSelect('tutorial.description', 'description')
25
- .addSelect('tutorial.resourceUrl', 'resourceUrl')
26
- .addSelect('tutorial.value', 'value')
27
- .addSelect('tutorial.duration', 'duration')
28
- .addSelect('tutorial.rank', 'rank')
29
- .innerJoin(TutorialRole, 'tr', 'tr.tutorial_id = tutorial.id')
30
- .innerJoin(Role, 'role', 'role.id = tr.role_id')
31
- .where('UPPER(role.name) IN (:...input)', { input: filter })
32
- .groupBy('tutorial.id')
33
- .orderBy('tutorial.rank')
34
-
35
- let data = await qb.getRawMany()
36
- return data
37
- }
38
- }
@@ -1,44 +0,0 @@
1
- import { Tutorial } from '../../../entities'
2
-
3
- export const updateMultipleTutorial = {
4
- async updateMultipleTutorial(_: any, { patches }, context: ResolverContext) {
5
- const { tx, domain, user } = context.state
6
-
7
- let results = []
8
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
9
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
10
- const tutorialRepo = tx.getRepository(Tutorial)
11
-
12
- if (_createRecords.length > 0) {
13
- for (let i = 0; i < _createRecords.length; i++) {
14
- const newRecord = _createRecords[i]
15
-
16
- const result = await tutorialRepo.save({
17
- ...newRecord,
18
- domain,
19
- creator: user,
20
- updater: user
21
- })
22
-
23
- results.push({ ...result, cuFlag: '+' })
24
- }
25
- }
26
-
27
- if (_updateRecords.length > 0) {
28
- for (let i = 0; i < _updateRecords.length; i++) {
29
- const newRecord = _updateRecords[i]
30
- const tutorial = await tutorialRepo.findOneBy({ id: newRecord.id })
31
-
32
- const result = await tutorialRepo.save({
33
- ...tutorial,
34
- ...newRecord,
35
- updater: user
36
- })
37
-
38
- results.push({ ...result, cuFlag: 'M' })
39
- }
40
- }
41
-
42
- return results
43
- }
44
- }
@@ -1,16 +0,0 @@
1
- import { tutorialRoleResolver } from './tutorial-role'
2
- import { tutorialRolesResolver } from './tutorial-roles'
3
- import { tutorialRoleAssignmentsResolver } from './tutorial-role-assignments'
4
- import { listByRolesResolver } from './list-by-roles'
5
- import { updateRoleTutorial } from './update-role-tutorial'
6
-
7
- export const Query = {
8
- ...tutorialRolesResolver,
9
- ...tutorialRoleResolver,
10
- ...tutorialRoleAssignmentsResolver,
11
- ...listByRolesResolver
12
- }
13
-
14
- export const Mutation = {
15
- ...updateRoleTutorial
16
- }
@@ -1,21 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm'
2
-
3
- import { Role } from '@things-factory/auth-base'
4
- import { getRepository, ListParam } from '@things-factory/shell'
5
-
6
- import { TutorialRole } from '../../../entities'
7
-
8
- export const listByRolesResolver = {
9
- async listByRoles(_: any, params: ListParam, context: ResolverContext) {
10
- const qb: SelectQueryBuilder<TutorialRole> = getRepository(TutorialRole)
11
- .createQueryBuilder('tr')
12
- .select('tr.role_id', 'id')
13
- .addSelect('r.name', 'name')
14
- .innerJoin(Role, 'r', 'r.id = tr.role_id')
15
- .groupBy('tr.role_id')
16
- .addGroupBy('r.name')
17
-
18
- let data = await qb.getRawMany()
19
- return data
20
- }
21
- }
@@ -1,26 +0,0 @@
1
- import { Role } from '@things-factory/auth-base'
2
- import { getRepository } from '@things-factory/shell'
3
-
4
- import { TutorialRole } from '../../../entities'
5
-
6
- export const tutorialRoleAssignmentsResolver = {
7
- async tutorialRoleAssignments(_: any, { tutorialId }, context: ResolverContext) {
8
- const tutorialRole = await getRepository(TutorialRole).find({
9
- where: {
10
- tutorial: tutorialId
11
- },
12
- relations: ['role', 'tutorial', 'domain']
13
- })
14
-
15
- let items: any[], total: number
16
- ;[items, total] = await getRepository(Role).findAndCount({
17
- relations: ['domain', 'creator', 'updater']
18
- })
19
-
20
- items.map(item => {
21
- item.assigned = !!tutorialRole.some(tutorialRole => tutorialRole.role.id === item.id)
22
- })
23
-
24
- return { items, total }
25
- }
26
- }
@@ -1,14 +0,0 @@
1
- import { getRepository } from '@things-factory/shell'
2
-
3
- import { TutorialRole } from '../../../entities'
4
-
5
- export const tutorialRoleResolver = {
6
- async tutorialRole(_: any, { name }, context: ResolverContext) {
7
- const { domain } = context.state
8
-
9
- return await getRepository(TutorialRole).findOne({
10
- where: { domain: { id: domain.id }, name },
11
- relations: ['domain', 'creator', 'updater']
12
- })
13
- }
14
- }
@@ -1,14 +0,0 @@
1
- import { convertListParams, getRepository, ListParam } from '@things-factory/shell'
2
-
3
- import { TutorialRole } from '../../../entities'
4
-
5
- export const tutorialRolesResolver = {
6
- async tutorialRoles(_: any, params: ListParam, context: ResolverContext) {
7
- const convertedParams = convertListParams(params)
8
- const [items, total] = await getRepository(TutorialRole).findAndCount({
9
- ...convertedParams,
10
- relations: ['domain', 'creator', 'updater']
11
- })
12
- return { items, total }
13
- }
14
- }
@@ -1,47 +0,0 @@
1
- import { Role } from '@things-factory/auth-base'
2
-
3
- import { Tutorial, TutorialRole } from '../../../entities'
4
-
5
- const crypto = require('crypto')
6
-
7
- export const updateRoleTutorial = {
8
- async updateRoleTutorial(_: any, { tutorialId, tutorialRoles }, context: ResolverContext) {
9
- try {
10
- const { tx, domain } = context.state
11
-
12
- const tutorial: Tutorial = await tx.getRepository(Tutorial).findOne({
13
- where: { id: tutorialId }
14
- })
15
- if (!tutorial) throw new Error('Tutorial not exist')
16
-
17
- // 1. Delete every tutorial roles related with current tutorial.
18
- await tx.getRepository(TutorialRole).delete({ id: tutorial.id })
19
-
20
- // 2. Append new role into tutorial roles.
21
- tutorialRoles.forEach(async (tutorialRole: TutorialRole) => {
22
- await tx.getRepository(TutorialRole).insert({
23
- name: crypto.randomUUID(),
24
- domain,
25
- tutorial: tutorialId,
26
- role: await tx.getRepository(Role).findOneBy({ id: tutorialRole.role.id })
27
- })
28
- })
29
-
30
- const tutorials = await tx.getRepository(Tutorial).find()
31
- const rolesTutorial = await tx
32
- .getRepository(TutorialRole)
33
- .find({ where: { id: tutorial.id }, relations: ['tutorial'] })
34
- return tutorials.map((tutorial: Tutorial) => {
35
- return {
36
- name: tutorial.name,
37
- domain,
38
- tutorial: tutorial.id,
39
- assigned:
40
- rolesTutorial.filter((tutorialRole: TutorialRole) => tutorialRole.tutorial.id === tutorial.id).length > 0
41
- }
42
- })
43
- } catch (e) {
44
- throw e
45
- }
46
- }
47
- }
@@ -1,8 +0,0 @@
1
- import * as Tutorial from './tutorial'
2
- import * as TutorialRole from './tutorial-role'
3
-
4
- export const queries = [Tutorial.Query, TutorialRole.Query]
5
-
6
- export const mutations = [Tutorial.Mutation, TutorialRole.Mutation]
7
-
8
- export const types = [...Tutorial.Types, ...TutorialRole.Types]
@@ -1,22 +0,0 @@
1
- import { Tutorial } from './tutorial'
2
- import { NewTutorial } from './new-tutorial'
3
- import { TutorialPatch } from './tutorial-patch'
4
- import { TutorialList } from './tutorial-list'
5
-
6
- export const Mutation = `
7
- updateMultipleTutorial (
8
- patches: [TutorialPatch]!
9
- ): [Tutorial] @transaction
10
-
11
- deleteTutorials (
12
- ids: [String]!
13
- ): Boolean @transaction
14
- `
15
-
16
- export const Query = `
17
- tutorials(filters: [Filter], pagination: Pagination, sortings: [Sorting]): TutorialList
18
- tutorialsWithRoles(roleNames: String!): [Tutorial]
19
- tutorial(name: String!): Tutorial
20
- `
21
-
22
- export const Types = [Tutorial, NewTutorial, TutorialPatch, TutorialList]
@@ -1,13 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const NewTutorial = gql`
4
- input NewTutorial {
5
- name: String!
6
- description: String
7
- resourceUrl: String
8
- value: String
9
- duration: String
10
- rank: Int
11
- roles: [ObjectRef]
12
- }
13
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const TutorialList = gql`
4
- type TutorialList {
5
- items: [Tutorial]
6
- total: Int
7
- }
8
- `
@@ -1,15 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const TutorialPatch = gql`
4
- input TutorialPatch {
5
- id: String
6
- name: String
7
- description: String
8
- resourceUrl: String
9
- value: String
10
- duration: String
11
- rank: Int
12
- roles: [ObjectRef]
13
- cuFlag: String
14
- }
15
- `
@@ -1,19 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const Tutorial = gql`
4
- type Tutorial {
5
- id: String
6
- name: String
7
- domain: Domain
8
- description: String
9
- resourceUrl: String
10
- value: String
11
- duration: String
12
- rank: Int
13
- roles: [Role]
14
- updater: User
15
- creator: User
16
- updatedAt: String
17
- createdAt: String
18
- }
19
- `
@@ -1,22 +0,0 @@
1
- import { TutorialRole } from './tutorial-role'
2
- import { NewTutorialRole } from './new-tutorial-role'
3
- import { TutorialRolePatch } from './tutorial-role-patch'
4
- import { TutorialRoleList } from './tutorial-role-list'
5
- import { RoleList } from './role-list'
6
- import { RoleTutorial } from './role-tutorial'
7
-
8
- export const Mutation = `
9
- updateRoleTutorial (
10
- tutorialId: String!
11
- tutorialRoles: [TutorialRolePatch]!
12
- ): [RoleTutorial] @privilege(category: "tutorial", privilege: "mutation") @transaction
13
- `
14
-
15
- export const Query = `
16
- tutorialRoles(filters: [Filter], pagination: Pagination, sortings: [Sorting]): TutorialRoleList
17
- tutorialRole(name: String!): TutorialRole
18
- tutorialRoleAssignments(tutorialId: String!): TutorialRoleList
19
- listByRoles(filters: [Filter]): [RoleTutorial]
20
- `
21
-
22
- export const Types = [TutorialRole, NewTutorialRole, TutorialRolePatch, TutorialRoleList, RoleList, RoleTutorial]
@@ -1,9 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const NewTutorialRole = gql`
4
- input NewTutorialRole {
5
- name: String!
6
- tutorial: ObjectRef!
7
- roles: [ObjectRef]!
8
- }
9
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const RoleList = gql`
4
- type RoleList {
5
- items: [Role]
6
- total: Int
7
- }
8
- `
@@ -1,11 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const RoleTutorial = gql`
4
- type RoleTutorial {
5
- id: String
6
- name: String
7
- role: Role
8
- tutorial: Tutorial
9
- assigned: Boolean
10
- }
11
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const TutorialRoleList = gql`
4
- type TutorialRoleList {
5
- items: [TutorialRole]
6
- total: Int
7
- }
8
- `
@@ -1,11 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const TutorialRolePatch = gql`
4
- input TutorialRolePatch {
5
- id: String
6
- name: String
7
- role: ObjectRef
8
- tutorial: ObjectRef
9
- cuFlag: String
10
- }
11
- `
@@ -1,17 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const TutorialRole = gql`
4
- type TutorialRole {
5
- id: String
6
- name: String
7
- domain: Domain
8
- role: Role
9
- tutorial: Tutorial
10
- description: String
11
- assigned: Boolean
12
- updater: User
13
- creator: User
14
- updatedAt: String
15
- createdAt: String
16
- }
17
- `
package/server/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './entities'
2
- export * from './migrations'
3
- export * from './graphql'
@@ -1,9 +0,0 @@
1
- const glob = require('glob')
2
- const path = require('path')
3
-
4
- export var migrations = []
5
-
6
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
7
- if (file.indexOf('index.js') !== -1) return
8
- migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
9
- })
package/server/routes.ts DELETED
@@ -1,21 +0,0 @@
1
- process.on('bootstrap-module-history-fallback' as any, (app, fallbackOption) => {
2
- /*
3
- * fallback white list를 추가할 수 있다
4
- *
5
- * ex)
6
- * var paths = [
7
- * 'aaa',
8
- * 'bbb'
9
- * ]
10
- * fallbackOption.whiteList.push(`^\/(${paths.join('|')})($|[/?#])`)
11
- */
12
- })
13
-
14
- process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {
15
- /*
16
- * koa application에 routes 를 추가할 수 있다.
17
- *
18
- * ex) routes.get('/path', async(context, next) => {})
19
- * ex) routes.post('/path', async(context, next) => {})
20
- */
21
- })