@things-factory/contact 6.0.0-zeta.26

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 (105) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/bootstrap.ts +1 -0
  4. package/client/index.ts +0 -0
  5. package/client/pages/contact/contact-importer.ts +97 -0
  6. package/client/pages/contact/contact-list-page.ts +348 -0
  7. package/client/route.ts +7 -0
  8. package/client/tsconfig.json +11 -0
  9. package/dist-client/actions/main.d.ts +1 -0
  10. package/dist-client/actions/main.js +2 -0
  11. package/dist-client/actions/main.js.map +1 -0
  12. package/dist-client/bootstrap.d.ts +1 -0
  13. package/dist-client/bootstrap.js +2 -0
  14. package/dist-client/bootstrap.js.map +1 -0
  15. package/dist-client/components/contact-editor.d.ts +3 -0
  16. package/dist-client/components/contact-editor.js +4 -0
  17. package/dist-client/components/contact-editor.js.map +1 -0
  18. package/dist-client/index.d.ts +0 -0
  19. package/dist-client/index.js +2 -0
  20. package/dist-client/index.js.map +1 -0
  21. package/dist-client/pages/address/address-importer.d.ts +22 -0
  22. package/dist-client/pages/address/address-importer.js +100 -0
  23. package/dist-client/pages/address/address-importer.js.map +1 -0
  24. package/dist-client/pages/address/address-list-page.d.ts +62 -0
  25. package/dist-client/pages/address/address-list-page.js +326 -0
  26. package/dist-client/pages/address/address-list-page.js.map +1 -0
  27. package/dist-client/pages/contact/contact-importer.d.ts +22 -0
  28. package/dist-client/pages/contact/contact-importer.js +100 -0
  29. package/dist-client/pages/contact/contact-importer.js.map +1 -0
  30. package/dist-client/pages/contact/contact-list-page.d.ts +62 -0
  31. package/dist-client/pages/contact/contact-list-page.js +326 -0
  32. package/dist-client/pages/contact/contact-list-page.js.map +1 -0
  33. package/dist-client/pages/contact-item/contact-item-importer.d.ts +22 -0
  34. package/dist-client/pages/contact-item/contact-item-importer.js +100 -0
  35. package/dist-client/pages/contact-item/contact-item-importer.js.map +1 -0
  36. package/dist-client/pages/contact-item/contact-item-list-page.d.ts +62 -0
  37. package/dist-client/pages/contact-item/contact-item-list-page.js +326 -0
  38. package/dist-client/pages/contact-item/contact-item-list-page.js.map +1 -0
  39. package/dist-client/pages/email/email-importer.d.ts +22 -0
  40. package/dist-client/pages/email/email-importer.js +100 -0
  41. package/dist-client/pages/email/email-importer.js.map +1 -0
  42. package/dist-client/pages/email/email-list-page.d.ts +62 -0
  43. package/dist-client/pages/email/email-list-page.js +326 -0
  44. package/dist-client/pages/email/email-list-page.js.map +1 -0
  45. package/dist-client/pages/main.d.ts +1 -0
  46. package/dist-client/pages/main.js +27 -0
  47. package/dist-client/pages/main.js.map +1 -0
  48. package/dist-client/pages/phone/phone-importer.d.ts +22 -0
  49. package/dist-client/pages/phone/phone-importer.js +100 -0
  50. package/dist-client/pages/phone/phone-importer.js.map +1 -0
  51. package/dist-client/pages/phone/phone-list-page.d.ts +62 -0
  52. package/dist-client/pages/phone/phone-list-page.js +326 -0
  53. package/dist-client/pages/phone/phone-list-page.js.map +1 -0
  54. package/dist-client/reducers/main.d.ts +6 -0
  55. package/dist-client/reducers/main.js +14 -0
  56. package/dist-client/reducers/main.js.map +1 -0
  57. package/dist-client/route.d.ts +1 -0
  58. package/dist-client/route.js +8 -0
  59. package/dist-client/route.js.map +1 -0
  60. package/dist-client/tsconfig.tsbuildinfo +1 -0
  61. package/dist-server/controllers/index.js +1 -0
  62. package/dist-server/controllers/index.js.map +1 -0
  63. package/dist-server/index.js +7 -0
  64. package/dist-server/index.js.map +1 -0
  65. package/dist-server/middlewares/index.js +8 -0
  66. package/dist-server/middlewares/index.js.map +1 -0
  67. package/dist-server/migrations/index.js +12 -0
  68. package/dist-server/migrations/index.js.map +1 -0
  69. package/dist-server/routes.js +25 -0
  70. package/dist-server/routes.js.map +1 -0
  71. package/dist-server/service/contact/contact-item.js +44 -0
  72. package/dist-server/service/contact/contact-item.js.map +1 -0
  73. package/dist-server/service/contact/contact-mutation.js +168 -0
  74. package/dist-server/service/contact/contact-mutation.js.map +1 -0
  75. package/dist-server/service/contact/contact-query.js +94 -0
  76. package/dist-server/service/contact/contact-query.js.map +1 -0
  77. package/dist-server/service/contact/contact-type.js +50 -0
  78. package/dist-server/service/contact/contact-type.js.map +1 -0
  79. package/dist-server/service/contact/contact.js +96 -0
  80. package/dist-server/service/contact/contact.js.map +1 -0
  81. package/dist-server/service/contact/index.js +10 -0
  82. package/dist-server/service/contact/index.js.map +1 -0
  83. package/dist-server/service/index.js +23 -0
  84. package/dist-server/service/index.js.map +1 -0
  85. package/dist-server/tsconfig.tsbuildinfo +1 -0
  86. package/helps/contact/contact.md +160 -0
  87. package/package.json +37 -0
  88. package/server/controllers/index.ts +0 -0
  89. package/server/index.ts +4 -0
  90. package/server/middlewares/index.ts +3 -0
  91. package/server/migrations/index.ts +9 -0
  92. package/server/routes.ts +28 -0
  93. package/server/service/contact/contact-item.ts +31 -0
  94. package/server/service/contact/contact-mutation.ts +195 -0
  95. package/server/service/contact/contact-query.ts +59 -0
  96. package/server/service/contact/contact-type.ts +35 -0
  97. package/server/service/contact/contact.ts +89 -0
  98. package/server/service/contact/index.ts +7 -0
  99. package/server/service/index.ts +22 -0
  100. package/server/tsconfig.json +10 -0
  101. package/things-factory.config.js +8 -0
  102. package/translations/en.json +1 -0
  103. package/translations/ko.json +1 -0
  104. package/translations/ms.json +1 -0
  105. package/translations/zh.json +1 -0
@@ -0,0 +1,160 @@
1
+ # Contact
2
+
3
+ Paragraphs are separated by a blank line.
4
+
5
+ 2nd paragraph. _Italic_, **bold**, and `monospace`. Itemized lists
6
+ look like:
7
+
8
+ - this one
9
+ - that one
10
+ - the other one
11
+
12
+ Note that --- not considering the asterisk --- the actual text
13
+ content starts at 4-columns in.
14
+
15
+ > Block quotes are
16
+ > written like so.
17
+ >
18
+ > They can span multiple paragraphs,
19
+ > if you like.
20
+
21
+ Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
22
+ in chapters 12--14"). Three dots ... will be converted to an ellipsis.
23
+ Unicode is supported. ☺
24
+
25
+ ## An h2 header
26
+
27
+ Here's a numbered list:
28
+
29
+ 1. first item
30
+ 2. second item
31
+ 3. third item
32
+
33
+ Note again how the actual text starts at 4 columns in (4 characters
34
+ from the left side). Here's a code sample:
35
+
36
+ # Let me re-iterate ...
37
+
38
+ for i in 1 .. 10 { do-something(i) }
39
+
40
+ As you probably guessed, indented 4 spaces. By the way, instead of
41
+ indenting the block, you can use delimited blocks, if you like:
42
+
43
+ ```
44
+ define foobar() {
45
+ print "Welcome to flavor country!";
46
+ }
47
+ ```
48
+
49
+ (which makes copying & pasting easier). You can optionally mark the
50
+ delimited block for Pandoc to syntax highlight it:
51
+
52
+ ```python
53
+ import time
54
+ # Quick, count to ten!
55
+ for i in range(10):
56
+ # (but not *too* quick)
57
+ time.sleep(0.5)
58
+ print(i)
59
+ ```
60
+
61
+ ### An h3 header
62
+
63
+ Now a nested list:
64
+
65
+ 1. First, get these ingredients:
66
+
67
+ - carrots
68
+ - celery
69
+ - lentils
70
+
71
+ 2. Boil some water.
72
+
73
+ 3. Dump everything in the pot and follow
74
+ this algorithm:
75
+
76
+ find wooden spoon
77
+ uncover pot
78
+ stir
79
+ cover pot
80
+ balance wooden spoon precariously on pot handle
81
+ wait 10 minutes
82
+ goto first step (or shut off burner when done)
83
+
84
+ Do not bump wooden spoon or it will fall.
85
+
86
+ Notice again how text always lines up on 4-space indents (including
87
+ that last line which continues item 3 above).
88
+
89
+ Here's a link to [a website](http://foo.bar), to a [local
90
+ doc](local-doc.html), and to a [section heading in the current
91
+ doc](#an-h2-header). Here's a footnote [^1].
92
+
93
+ [^1]: Some footnote text.
94
+
95
+ Tables can look like this:
96
+
97
+ Name Size Material Color
98
+
99
+ ---
100
+
101
+ All Business 9 leather brown
102
+ Roundabout 10 hemp canvas natural
103
+ Cinderella 11 glass transparent
104
+
105
+ Table: Shoes sizes, materials, and colors.
106
+
107
+ (The above is the caption for the table.) Pandoc also supports
108
+ multi-line tables:
109
+
110
+ ---
111
+
112
+ Keyword Text
113
+
114
+ ---
115
+
116
+ red Sunsets, apples, and
117
+ other red or reddish
118
+ things.
119
+
120
+ green Leaves, grass, frogs
121
+ and other things it's
122
+ not easy being.
123
+
124
+ ---
125
+
126
+ A horizontal rule follows.
127
+
128
+ ---
129
+
130
+ Here's a definition list:
131
+
132
+ apples
133
+ : Good for making applesauce.
134
+
135
+ oranges
136
+ : Citrus!
137
+
138
+ tomatoes
139
+ : There's no "e" in tomatoe.
140
+
141
+ Again, text is indented 4 spaces. (Put a blank line between each
142
+ term and its definition to spread things out more.)
143
+
144
+ Here's a "line block" (note how whitespace is honored):
145
+
146
+ | Line one
147
+ | Line too
148
+ | Line tree
149
+
150
+ and images can be specified like so:
151
+
152
+ ![example image](example-image.jpg 'An exemplary image')
153
+
154
+ Inline math equation: $\omega = d\phi / dt$. Display
155
+ math should get its own line like so:
156
+
157
+ $$I = \int \rho R^{2} dV$$
158
+
159
+ And note that you can backslash-escape any punctuation characters
160
+ which you wish to be displayed literally, ex.: \`foo\`, \*bar\*, etc.
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@things-factory/contact",
3
+ "version": "6.0.0-zeta.26",
4
+ "main": "dist-server/index.js",
5
+ "browser": "dist-client/index.js",
6
+ "things-factory": true,
7
+ "license": "MIT",
8
+ "author": "heartyoh <heartyoh@hatiolab.com>",
9
+ "description": "Module that provide services for maintaining contact information",
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "@things-factory:registry": "https://registry.npmjs.org"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hatiolab/things-factory.git",
17
+ "directory": "packages/contact"
18
+ },
19
+ "scripts": {
20
+ "build": "npm run build:server && npm run build:client",
21
+ "build:client": "npx tsc --p ./client/tsconfig.json",
22
+ "build:server": "npx tsc --p ./server/tsconfig.json",
23
+ "clean:client": "npx rimraf dist-client",
24
+ "clean:server": "npx rimraf dist-server",
25
+ "clean": "npm run clean:server && npm run clean:client",
26
+ "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
27
+ },
28
+ "dependencies": {
29
+ "@operato/contact": "^1.0.0",
30
+ "@operato/graphql": "^1.0.0",
31
+ "@operato/shell": "^1.0.0",
32
+ "@things-factory/attachment-base": "^6.0.0-zeta.20",
33
+ "@things-factory/auth-base": "^6.0.0-zeta.20",
34
+ "@things-factory/shell": "^6.0.0-zeta.20"
35
+ },
36
+ "gitHead": "9ab942f1cb40dbe717e01b1b57bbacc8501a65ca"
37
+ }
File without changes
@@ -0,0 +1,4 @@
1
+ export * from './migrations'
2
+ export * from './middlewares'
3
+
4
+ import './routes'
@@ -0,0 +1,3 @@
1
+ export function initMiddlewares(app) {
2
+ /* can add middlewares into app */
3
+ }
@@ -0,0 +1,9 @@
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
+ })
@@ -0,0 +1,28 @@
1
+ const debug = require('debug')('things-factory:contact:routes')
2
+
3
+ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
4
+ /*
5
+ * can add global public routes to application (auth not required, tenancy not required)
6
+ *
7
+ * ex) routes.get('/path', async(context, next) => {})
8
+ * ex) routes.post('/path', async(context, next) => {})
9
+ */
10
+ })
11
+
12
+ process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
13
+ /*
14
+ * can add global private routes to application (auth required, tenancy not required)
15
+ */
16
+ })
17
+
18
+ process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
19
+ /*
20
+ * can add domain public routes to application (auth not required, tenancy required)
21
+ */
22
+ })
23
+
24
+ process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
25
+ /*
26
+ * can add domain private routes to application (auth required, tenancy required)
27
+ */
28
+ })
@@ -0,0 +1,31 @@
1
+ import { Column, Entity, PrimaryGeneratedColumn, ManyToOne, RelationId } from 'typeorm'
2
+ import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
3
+
4
+ import { Contact, ContactField } from './contact'
5
+
6
+ @Entity()
7
+ @ObjectType({ description: 'Entity for ContactItem' })
8
+ export class ContactItem {
9
+ @PrimaryGeneratedColumn('uuid')
10
+ @Field(type => ID)
11
+ readonly id: string
12
+
13
+ @Column()
14
+ @Field()
15
+ label: string
16
+
17
+ @Column()
18
+ @Field()
19
+ type: ContactField
20
+
21
+ @Column()
22
+ @Field()
23
+ value: string
24
+
25
+ @ManyToOne(type => Contact, contact => contact.items)
26
+ @Field()
27
+ contact: Contact
28
+
29
+ @RelationId((item: ContactItem) => item.contact)
30
+ contactId: string
31
+ }
@@ -0,0 +1,195 @@
1
+ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
5
+
6
+ import { Contact } from './contact'
7
+ import { NewContact, ContactPatch } from './contact-type'
8
+
9
+ @Resolver(Contact)
10
+ export class ContactMutation {
11
+ @Directive('@transaction')
12
+ @Mutation(returns => Contact, { description: 'To create new Contact' })
13
+ async createContact(@Arg('contact') contact: NewContact, @Ctx() context: ResolverContext): Promise<Contact> {
14
+ const { domain, user, tx } = context.state
15
+
16
+ const result = await tx.getRepository(Contact).save({
17
+ ...contact,
18
+ domain,
19
+ creator: user,
20
+ updater: user
21
+ })
22
+
23
+ if (contact.thumbnail) {
24
+ await createAttachment(
25
+ null,
26
+ {
27
+ attachment: {
28
+ file: contact.thumbnail,
29
+ refType: Contact.name,
30
+ refBy: result.id
31
+ }
32
+ },
33
+ context
34
+ )
35
+ }
36
+
37
+ return result
38
+ }
39
+
40
+ @Directive('@transaction')
41
+ @Mutation(returns => Contact, { description: 'To modify Contact information' })
42
+ async updateContact(
43
+ @Arg('id') id: string,
44
+ @Arg('patch') patch: ContactPatch,
45
+ @Ctx() context: ResolverContext
46
+ ): Promise<Contact> {
47
+ const { domain, user, tx } = context.state
48
+
49
+ const repository = tx.getRepository(Contact)
50
+ const contact = await repository.findOne({
51
+ where: { domain: { id: domain.id }, id }
52
+ })
53
+
54
+ const result = await repository.save({
55
+ ...contact,
56
+ ...patch,
57
+ updater: user
58
+ })
59
+
60
+ if (patch.thumbnail) {
61
+ await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
62
+ await createAttachment(
63
+ null,
64
+ {
65
+ attachment: {
66
+ file: patch.thumbnail,
67
+ refType: Contact.name,
68
+ refBy: result.id
69
+ }
70
+ },
71
+ context
72
+ )
73
+ }
74
+
75
+ return result
76
+ }
77
+
78
+ @Directive('@transaction')
79
+ @Mutation(returns => [Contact], { description: "To modify multiple Contacts' information" })
80
+ async updateMultipleContact(
81
+ @Arg('patches', type => [ContactPatch]) patches: ContactPatch[],
82
+ @Ctx() context: ResolverContext
83
+ ): Promise<Contact[]> {
84
+ const { domain, user, tx } = context.state
85
+
86
+ let results = []
87
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
88
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
89
+ const contactRepo = tx.getRepository(Contact)
90
+
91
+ if (_createRecords.length > 0) {
92
+ for (let i = 0; i < _createRecords.length; i++) {
93
+ const newRecord = _createRecords[i]
94
+
95
+ const result = await contactRepo.save({
96
+ ...newRecord,
97
+ domain,
98
+ creator: user,
99
+ updater: user
100
+ })
101
+
102
+ if (newRecord.thumbnail) {
103
+ await createAttachment(
104
+ null,
105
+ {
106
+ attachment: {
107
+ file: newRecord.thumbnail,
108
+ refType: Contact.name,
109
+ refBy: result.id
110
+ }
111
+ },
112
+ context
113
+ )
114
+ }
115
+
116
+ results.push({ ...result, cuFlag: '+' })
117
+ }
118
+ }
119
+
120
+ if (_updateRecords.length > 0) {
121
+ for (let i = 0; i < _updateRecords.length; i++) {
122
+ const updateRecord = _updateRecords[i]
123
+ const contact = await contactRepo.findOneBy({ id: updateRecord.id })
124
+
125
+ const result = await contactRepo.save({
126
+ ...contact,
127
+ ...updateRecord,
128
+ updater: user
129
+ })
130
+
131
+ if (updateRecord.thumbnail) {
132
+ await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
133
+ await createAttachment(
134
+ null,
135
+ {
136
+ attachment: {
137
+ file: updateRecord.thumbnail,
138
+ refType: Contact.name,
139
+ refBy: result.id
140
+ }
141
+ },
142
+ context
143
+ )
144
+ }
145
+
146
+ results.push({ ...result, cuFlag: 'M' })
147
+ }
148
+ }
149
+
150
+ return results
151
+ }
152
+
153
+ @Directive('@transaction')
154
+ @Mutation(returns => Boolean, { description: 'To delete Contact' })
155
+ async deleteContact(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
156
+ const { domain, tx } = context.state
157
+
158
+ await tx.getRepository(Contact).delete({ domain: { id: domain.id }, id })
159
+ await deleteAttachmentsByRef(null, { refBys: [id] }, context)
160
+
161
+ return true
162
+ }
163
+
164
+ @Directive('@transaction')
165
+ @Mutation(returns => Boolean, { description: 'To delete multiple Contacts' })
166
+ async deleteContacts(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
167
+ const { domain, tx } = context.state
168
+
169
+ await tx.getRepository(Contact).delete({
170
+ domain: { id: domain.id },
171
+ id: In(ids)
172
+ })
173
+
174
+ await deleteAttachmentsByRef(null, { refBys: ids }, context)
175
+
176
+ return true
177
+ }
178
+
179
+ @Directive('@transaction')
180
+ @Mutation(returns => Boolean, { description: 'To import multiple Contacts' })
181
+ async importContacts(
182
+ @Arg('contacts', type => [ContactPatch]) contacts: ContactPatch[],
183
+ @Ctx() context: ResolverContext
184
+ ): Promise<boolean> {
185
+ const { domain, tx } = context.state
186
+
187
+ await Promise.all(
188
+ contacts.map(async (contact: ContactPatch) => {
189
+ const createdContact: Contact = await tx.getRepository(Contact).save({ domain, ...contact })
190
+ })
191
+ )
192
+
193
+ return true
194
+ }
195
+ }
@@ -0,0 +1,59 @@
1
+ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
3
+ import { User } from '@things-factory/auth-base'
4
+ import { Contact } from './contact'
5
+ import { ContactItem } from './contact-item'
6
+ import { ContactList } from './contact-type'
7
+
8
+ @Resolver(Contact)
9
+ export class ContactQuery {
10
+ @Query(returns => Contact!, { nullable: true, description: 'To fetch a Contact' })
11
+ async contact(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Contact> {
12
+ const { domain } = context.state
13
+
14
+ return await getRepository(Contact).findOne({
15
+ where: { domain: { id: domain.id }, id }
16
+ })
17
+ }
18
+
19
+ @Query(returns => ContactList, { description: 'To fetch multiple Contacts' })
20
+ async contacts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ContactList> {
21
+ const { domain } = context.state
22
+
23
+ const queryBuilder = getQueryBuilderFromListParams({
24
+ domain,
25
+ params,
26
+ repository: await getRepository(ContactItem),
27
+ searchables: ['value']
28
+ })
29
+
30
+ /**
31
+ * Contact의 domain이 해당되는 범위에서 ContactItem의 value를 검색한다.
32
+ * 그런 후에 distinct 한 contact 들을 리턴한다.
33
+ */
34
+
35
+ const [items, total] = await queryBuilder.getManyAndCount()
36
+
37
+ return { items, total }
38
+ }
39
+
40
+ @FieldResolver(type => [ContactItem])
41
+ async items(@Root() contact: Contact): Promise<ContactItem[]> {
42
+ return await getRepository(ContactItem).findBy({ contact: { id: contact.id } })
43
+ }
44
+
45
+ @FieldResolver(type => Domain)
46
+ async domain(@Root() contact: Contact): Promise<Domain> {
47
+ return await getRepository(Domain).findOneBy({ id: contact.domainId })
48
+ }
49
+
50
+ @FieldResolver(type => User)
51
+ async updater(@Root() contact: Contact): Promise<User> {
52
+ return await getRepository(User).findOneBy({ id: contact.updaterId })
53
+ }
54
+
55
+ @FieldResolver(type => User)
56
+ async creator(@Root() contact: Contact): Promise<User> {
57
+ return await getRepository(User).findOneBy({ id: contact.creatorId })
58
+ }
59
+ }
@@ -0,0 +1,35 @@
1
+ import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
2
+ import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
3
+ import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
4
+
5
+ import { ObjectRef, ScalarObject } from '@things-factory/shell'
6
+
7
+ import { Contact } from './contact'
8
+ import { ContactItem } from './contact-item'
9
+
10
+ @InputType()
11
+ export class NewContact {
12
+ @Field(type => GraphQLUpload, { nullable: true })
13
+ thumbnail?: FileUpload
14
+ }
15
+
16
+ @InputType()
17
+ export class ContactPatch {
18
+ @Field(type => ID, { nullable: true })
19
+ id?: string
20
+
21
+ @Field(type => GraphQLUpload, { nullable: true })
22
+ thumbnail?: FileUpload
23
+
24
+ @Field({ nullable: true })
25
+ cuFlag?: string
26
+ }
27
+
28
+ @ObjectType()
29
+ export class ContactList {
30
+ @Field(type => [Contact])
31
+ items: Contact[]
32
+
33
+ @Field(type => Int)
34
+ total: number
35
+ }
@@ -0,0 +1,89 @@
1
+ import {
2
+ CreateDateColumn,
3
+ UpdateDateColumn,
4
+ DeleteDateColumn,
5
+ Entity,
6
+ Index,
7
+ Column,
8
+ RelationId,
9
+ ManyToOne,
10
+ OneToMany,
11
+ PrimaryGeneratedColumn
12
+ } from 'typeorm'
13
+ import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
14
+
15
+ import { Domain } from '@things-factory/shell'
16
+ import { User } from '@things-factory/auth-base'
17
+
18
+ import { ContactItem } from './contact-item'
19
+
20
+ export enum ContactField {
21
+ Name = 'name',
22
+ JobTitle = 'job-title',
23
+ Phone = 'phone',
24
+ Address = 'address',
25
+ Email = 'email',
26
+ Birthday = 'birthday',
27
+ Profile = 'profile',
28
+ Picture = 'picture',
29
+ Department = 'department',
30
+ Company = 'company',
31
+ Homepage = 'homepage'
32
+ }
33
+
34
+ registerEnumType(ContactField, {
35
+ name: 'ContactField',
36
+ description: 'field enumeration of a contact'
37
+ })
38
+
39
+ @Entity()
40
+ @ObjectType({ description: 'Entity for Contact' })
41
+ export class Contact {
42
+ @PrimaryGeneratedColumn('uuid')
43
+ @Field(type => ID)
44
+ readonly id: string
45
+
46
+ @ManyToOne(type => Domain)
47
+ @Field({ nullable: true })
48
+ domain?: Domain
49
+
50
+ @RelationId((contact: Contact) => contact.domain)
51
+ domainId?: string
52
+
53
+ @Column({ nullable: true })
54
+ @Field({ nullable: true })
55
+ note?: string
56
+
57
+ @OneToMany(type => ContactItem, contactItem => contactItem.contact)
58
+ @Field(type => [ContactItem])
59
+ items?: ContactItem[]
60
+
61
+ @CreateDateColumn()
62
+ @Field({ nullable: true })
63
+ createdAt?: Date
64
+
65
+ @UpdateDateColumn()
66
+ @Field({ nullable: true })
67
+ updatedAt?: Date
68
+
69
+ @DeleteDateColumn()
70
+ @Field({ nullable: true })
71
+ deletedAt?: Date
72
+
73
+ @ManyToOne(type => User, { nullable: true })
74
+ @Field({ nullable: true })
75
+ creator?: User
76
+
77
+ @RelationId((contact: Contact) => contact.creator)
78
+ creatorId?: string
79
+
80
+ @ManyToOne(type => User, { nullable: true })
81
+ @Field({ nullable: true })
82
+ updater?: User
83
+
84
+ @RelationId((contact: Contact) => contact.updater)
85
+ updaterId?: string
86
+
87
+ @Field(type => String, { nullable: true })
88
+ thumbnail?: string
89
+ }
@@ -0,0 +1,7 @@
1
+ import { Contact } from './contact'
2
+ import { ContactItem } from './contact-item'
3
+ import { ContactQuery } from './contact-query'
4
+ import { ContactMutation } from './contact-mutation'
5
+
6
+ export const entities = [Contact, ContactItem]
7
+ export const resolvers = [ContactQuery, ContactMutation]
@@ -0,0 +1,22 @@
1
+ /* EXPORT ENTITY TYPES */
2
+ export * from './contact/contact-item'
3
+ export * from './contact/contact'
4
+
5
+ /* IMPORT ENTITIES AND RESOLVERS */
6
+ import { entities as ContactEntities, resolvers as ContactResolvers } from './contact'
7
+
8
+ export const entities = [
9
+ /* ENTITIES */
10
+ ...ContactEntities
11
+ ]
12
+
13
+ export const subscribers = [
14
+ /* SUBSCRIBERS */
15
+ ]
16
+
17
+ export const schema = {
18
+ resolverClasses: [
19
+ /* RESOLVER CLASSES */
20
+ ...ContactResolvers
21
+ ]
22
+ }