@things-factory/code-base 7.0.0-alpha.8 → 7.0.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 (50) hide show
  1. package/client/{codes-getter.js → codes-getter.ts} +4 -5
  2. package/dist-client/codes-getter.d.ts +2 -0
  3. package/dist-client/codes-getter.js +52 -0
  4. package/dist-client/codes-getter.js.map +1 -0
  5. package/dist-client/index.d.ts +1 -0
  6. package/dist-client/index.js +2 -0
  7. package/dist-client/index.js.map +1 -0
  8. package/dist-client/tsconfig.tsbuildinfo +1 -0
  9. package/dist-server/index.d.ts +1 -0
  10. package/dist-server/index.js +0 -1
  11. package/dist-server/index.js.map +1 -1
  12. package/dist-server/service/common-code/common-code-mutation.d.ts +10 -0
  13. package/dist-server/service/common-code/common-code-mutation.js +2 -2
  14. package/dist-server/service/common-code/common-code-mutation.js.map +1 -1
  15. package/dist-server/service/common-code/common-code-query.d.ts +14 -0
  16. package/dist-server/service/common-code/common-code-query.js +4 -3
  17. package/dist-server/service/common-code/common-code-query.js.map +1 -1
  18. package/dist-server/service/common-code/common-code-type.d.ts +17 -0
  19. package/dist-server/service/common-code/common-code-type.js +6 -6
  20. package/dist-server/service/common-code/common-code-type.js.map +1 -1
  21. package/dist-server/service/common-code/common-code.d.ts +17 -0
  22. package/dist-server/service/common-code/common-code.js +6 -6
  23. package/dist-server/service/common-code/common-code.js.map +1 -1
  24. package/dist-server/service/common-code/index.d.ts +5 -0
  25. package/dist-server/service/common-code-detail/common-code-detail-mutation.d.ts +10 -0
  26. package/dist-server/service/common-code-detail/common-code-detail-mutation.js +2 -2
  27. package/dist-server/service/common-code-detail/common-code-detail-mutation.js.map +1 -1
  28. package/dist-server/service/common-code-detail/common-code-detail-query.d.ts +14 -0
  29. package/dist-server/service/common-code-detail/common-code-detail-query.js +17 -4
  30. package/dist-server/service/common-code-detail/common-code-detail-query.js.map +1 -1
  31. package/dist-server/service/common-code-detail/common-code-detail-type.d.ts +22 -0
  32. package/dist-server/service/common-code-detail/common-code-detail-type.js +14 -6
  33. package/dist-server/service/common-code-detail/common-code-detail-type.js.map +1 -1
  34. package/dist-server/service/common-code-detail/common-code-detail.d.ts +20 -0
  35. package/dist-server/service/common-code-detail/common-code-detail.js +13 -14
  36. package/dist-server/service/common-code-detail/common-code-detail.js.map +1 -1
  37. package/dist-server/service/common-code-detail/index.d.ts +5 -0
  38. package/dist-server/service/index.d.ts +6 -0
  39. package/dist-server/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +13 -8
  41. package/server/index.ts +0 -1
  42. package/server/service/common-code/common-code-query.ts +5 -1
  43. package/server/service/common-code/common-code.ts +4 -4
  44. package/server/service/common-code-detail/common-code-detail-query.ts +13 -2
  45. package/server/service/common-code-detail/common-code-detail-type.ts +7 -1
  46. package/server/service/common-code-detail/common-code-detail.ts +12 -14
  47. package/dist-server/migrations/index.js +0 -12
  48. package/dist-server/migrations/index.js.map +0 -1
  49. package/server/migrations/index.ts +0 -9
  50. /package/client/{index.js → index.ts} +0 -0
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@things-factory/code-base",
3
- "version": "7.0.0-alpha.8",
3
+ "version": "7.0.0",
4
4
  "main": "dist-server/index.js",
5
- "browser": "client/index.js",
5
+ "browser": "dist-client/index.js",
6
6
  "things-factory": true,
7
7
  "author": "",
8
8
  "description": "Server-side module for handling common code management.",
@@ -17,14 +17,19 @@
17
17
  "directory": "packages/code-base"
18
18
  },
19
19
  "scripts": {
20
- "build": "tsc --p tsconfig.json",
21
- "build:server": "npm run clean:server && tsc",
22
- "clean:server": "rm -rf dist-server",
23
- "clean": "npm run clean:server",
20
+ "build": "npm run build:server && npm run build:client",
21
+ "copy:files": "copyfiles -e \"./client/**/*.{ts,js,json}\" -u 1 \"./client/**/*\" dist-client",
22
+ "build:client": "npm run copy:files && npx tsc --p ./client/tsconfig.json",
23
+ "build:server": "npx tsc --p ./server/tsconfig.json",
24
+ "clean:client": "npx rimraf dist-client",
25
+ "clean:server": "npx rimraf dist-server",
26
+ "clean": "npm run clean:server && npm run clean:client",
24
27
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
28
  },
26
29
  "dependencies": {
27
- "@things-factory/auth-base": "^7.0.0-alpha.8"
30
+ "@operato/graphql": "^7.0.0",
31
+ "@things-factory/auth-base": "^7.0.0",
32
+ "@things-factory/shell": "^7.0.0"
28
33
  },
29
- "gitHead": "b4981ea2721e7eaf4dbd618b6c77316ebc000ee5"
34
+ "gitHead": "00f3917ca132679e3571f3f4fd16f4caf84f488e"
30
35
  }
package/server/index.ts CHANGED
@@ -1,2 +1 @@
1
- export * from './migrations'
2
1
  export * from './service'
@@ -19,7 +19,10 @@ export class CommonCodeQuery {
19
19
  }
20
20
 
21
21
  @Query(returns => CommonCodeList, { description: 'To fetch multiple CommonCodes' })
22
- async commonCodes(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<CommonCodeList> {
22
+ async commonCodes(
23
+ @Args(type => ListParam) params: ListParam,
24
+ @Ctx() context: ResolverContext
25
+ ): Promise<CommonCodeList> {
23
26
  const { domain } = context.state
24
27
 
25
28
  const queryBuilder = getQueryBuilderFromListParams({
@@ -34,6 +37,7 @@ export class CommonCodeQuery {
34
37
  return { items, total }
35
38
  }
36
39
 
40
+ /* TODO move to operato-wms module */
37
41
  @Query(returns => CommonCode, { description: "To fetch specific domain's CommonCodes by given name" })
38
42
  async partnerCommonCode(
39
43
  @Arg('name') name: string,
@@ -18,7 +18,7 @@ import { CommonCodeDetail } from '../common-code-detail/common-code-detail'
18
18
 
19
19
  @Entity()
20
20
  @Index('ix_common_code_0', (commonCode: CommonCode) => [commonCode.domain, commonCode.name], { unique: true })
21
- @Index('ix_common_code_1', (commonCode: CommonCode) => [commonCode.domain])
21
+ @Index('ix_common_code_1', (commonCode: CommonCode) => [commonCode.domain]) /* TOBE-REMOVED */
22
22
  @ObjectType({ description: 'Entity for CommonCode' })
23
23
  export class CommonCode {
24
24
  @PrimaryGeneratedColumn('uuid')
@@ -26,7 +26,7 @@ export class CommonCode {
26
26
  readonly id: string
27
27
 
28
28
  @ManyToOne(type => Domain)
29
- @Field({ nullable: true })
29
+ @Field(type => Domain)
30
30
  domain?: Domain
31
31
 
32
32
  @RelationId((commonCode: CommonCode) => commonCode.domain)
@@ -56,7 +56,7 @@ export class CommonCode {
56
56
  @ManyToOne(type => User, {
57
57
  nullable: true
58
58
  })
59
- @Field({ nullable: true })
59
+ @Field(type => User, { nullable: true })
60
60
  creator?: User
61
61
 
62
62
  @RelationId((commonCode: CommonCode) => commonCode.creator)
@@ -65,7 +65,7 @@ export class CommonCode {
65
65
  @ManyToOne(type => User, {
66
66
  nullable: true
67
67
  })
68
- @Field({ nullable: true })
68
+ @Field(type => User, { nullable: true })
69
69
  updater?: User
70
70
 
71
71
  @RelationId((commonCode: CommonCode) => commonCode.updater)
@@ -19,7 +19,10 @@ export class CommonCodeDetailQuery {
19
19
  }
20
20
 
21
21
  @Query(returns => CommonCodeDetailList, { description: 'To fetch multiple CommonCodeDetails' })
22
- async commonCodeDetails(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<CommonCodeDetailList> {
22
+ async commonCodeDetails(
23
+ @Args(type => ListParam) params: ListParam,
24
+ @Ctx() context: ResolverContext
25
+ ): Promise<CommonCodeDetailList> {
23
26
  const { domain } = context.state
24
27
 
25
28
  const queryBuilder = getQueryBuilderFromListParams({
@@ -35,11 +38,19 @@ export class CommonCodeDetailQuery {
35
38
  return { items, total }
36
39
  }
37
40
 
38
- @FieldResolver(type => CommonCode)
41
+ @FieldResolver(type => String)
39
42
  async commonCode(commonCodeDetail): Promise<CommonCode> {
40
43
  return await getRepository(CommonCode).findOneBy({ id: commonCodeDetail.commonCodeId })
41
44
  }
42
45
 
46
+ @FieldResolver(type => Domain)
47
+ async description(@Root() commonCodeDetail: CommonCodeDetail, @Ctx() context: ResolverContext): Promise<String> {
48
+ const { lng } = context.state
49
+ const { labels, description } = commonCodeDetail
50
+
51
+ return (lng && labels && labels[lng]) || description
52
+ }
53
+
43
54
  @FieldResolver(type => Domain)
44
55
  async domain(@Root() commonCodeDetail: CommonCodeDetail): Promise<Domain> {
45
56
  return await getRepository(Domain).findOneBy({ id: commonCodeDetail.domainId })
@@ -1,6 +1,6 @@
1
1
  import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
2
 
3
- import { ObjectRef } from '@things-factory/shell'
3
+ import { ObjectRef, ScalarObject } from '@things-factory/shell'
4
4
 
5
5
  import { CommonCodeDetail } from './common-code-detail'
6
6
 
@@ -12,6 +12,9 @@ export class NewCommonCodeDetail {
12
12
  @Field({ nullable: true })
13
13
  description?: string
14
14
 
15
+ @Field(type => ScalarObject, { nullable: true })
16
+ labels?: any // { [lng: string]: string }
17
+
15
18
  @Field(type => ObjectRef!)
16
19
  commonCode: ObjectRef
17
20
 
@@ -30,6 +33,9 @@ export class CommonCodeDetailPatch {
30
33
  @Field({ nullable: true })
31
34
  description?: string
32
35
 
36
+ @Field(type => ScalarObject, { nullable: true })
37
+ labels?: any // { [lng: string]: string }
38
+
33
39
  @Field(type => ObjectRef!)
34
40
  commonCode: ObjectRef
35
41
 
@@ -1,4 +1,4 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
1
+ import { Field, ID, InputType, ObjectType } from 'type-graphql'
2
2
  import {
3
3
  Column,
4
4
  CreateDateColumn,
@@ -11,7 +11,7 @@ import {
11
11
  } from 'typeorm'
12
12
 
13
13
  import { User } from '@things-factory/auth-base'
14
- import { Domain } from '@things-factory/shell'
14
+ import { Domain, ScalarObject } from '@things-factory/shell'
15
15
 
16
16
  import { CommonCode } from '../common-code/common-code'
17
17
 
@@ -33,7 +33,7 @@ export class CommonCodeDetail {
33
33
  readonly id: string
34
34
 
35
35
  @ManyToOne(type => Domain)
36
- @Field({ nullable: true })
36
+ @Field(type => Domain)
37
37
  domain?: Domain
38
38
 
39
39
  @RelationId((commonCodeDetail: CommonCodeDetail) => commonCodeDetail.domain)
@@ -50,12 +50,14 @@ export class CommonCodeDetail {
50
50
  @Field()
51
51
  name: string
52
52
 
53
- @Column({
54
- nullable: true
55
- })
53
+ @Column({ nullable: true })
56
54
  @Field({ nullable: true })
57
55
  description?: string
58
56
 
57
+ @Column('simple-json', { nullable: true })
58
+ @Field(type => ScalarObject, { nullable: true })
59
+ labels?: any // { [lng: string]: string }
60
+
59
61
  @Column()
60
62
  @Field({ nullable: true })
61
63
  rank: number
@@ -68,19 +70,15 @@ export class CommonCodeDetail {
68
70
  @Field({ nullable: true })
69
71
  updatedAt?: Date
70
72
 
71
- @ManyToOne(type => User, {
72
- nullable: true
73
- })
74
- @Field({ nullable: true })
73
+ @ManyToOne(type => User, { nullable: true })
74
+ @Field(type => User, { nullable: true })
75
75
  creator?: User
76
76
 
77
77
  @RelationId((commonCodeDetail: CommonCodeDetail) => commonCodeDetail.creator)
78
78
  creatorId?: string
79
79
 
80
- @ManyToOne(type => User, {
81
- nullable: true
82
- })
83
- @Field({ nullable: true })
80
+ @ManyToOne(type => User, { nullable: true })
81
+ @Field(type => User, { nullable: true })
84
82
  updater?: User
85
83
 
86
84
  @RelationId((commonCodeDetail: CommonCodeDetail) => commonCodeDetail.updater)
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrations = void 0;
4
- const glob = require('glob');
5
- const path = require('path');
6
- exports.migrations = [];
7
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
8
- if (file.indexOf('index.js') !== -1)
9
- return;
10
- exports.migrations = exports.migrations.concat(Object.values(require(path.resolve(file))) || []);
11
- });
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA","sourcesContent":["const glob = require('glob')\nconst path = require('path')\n\nexport var migrations = []\n\nglob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {\n if (file.indexOf('index.js') !== -1) return\n migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])\n})\n"]}
@@ -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
- })
File without changes