@things-factory/warehouse-base 4.1.29 → 4.1.34

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 (40) hide show
  1. package/dist-server/constants/inventory.js +8 -2
  2. package/dist-server/constants/inventory.js.map +1 -1
  3. package/dist-server/service/index.js +5 -0
  4. package/dist-server/service/index.js.map +1 -1
  5. package/dist-server/service/inventory-item/index.js +9 -0
  6. package/dist-server/service/inventory-item/index.js.map +1 -0
  7. package/dist-server/service/inventory-item/inventory-item-mutation.js +207 -0
  8. package/dist-server/service/inventory-item/inventory-item-mutation.js.map +1 -0
  9. package/dist-server/service/inventory-item/inventory-item-query.js +150 -0
  10. package/dist-server/service/inventory-item/inventory-item-query.js.map +1 -0
  11. package/dist-server/service/inventory-item/inventory-item-type.js +115 -0
  12. package/dist-server/service/inventory-item/inventory-item-type.js.map +1 -0
  13. package/dist-server/service/inventory-item/inventory-item.js +124 -0
  14. package/dist-server/service/inventory-item/inventory-item.js.map +1 -0
  15. package/dist-server/service/inventory-product/index.js +9 -0
  16. package/dist-server/service/inventory-product/index.js.map +1 -0
  17. package/dist-server/service/inventory-product/inventory-product-mutation.js +120 -0
  18. package/dist-server/service/inventory-product/inventory-product-mutation.js.map +1 -0
  19. package/dist-server/service/inventory-product/inventory-product-query.js +87 -0
  20. package/dist-server/service/inventory-product/inventory-product-query.js.map +1 -0
  21. package/dist-server/service/inventory-product/inventory-product-type.js +95 -0
  22. package/dist-server/service/inventory-product/inventory-product-type.js.map +1 -0
  23. package/dist-server/service/inventory-product/inventory-product.js +107 -0
  24. package/dist-server/service/inventory-product/inventory-product.js.map +1 -0
  25. package/dist-server/utils/inventory-no-generator.js +3 -0
  26. package/dist-server/utils/inventory-no-generator.js.map +1 -1
  27. package/package.json +5 -5
  28. package/server/constants/inventory.ts +8 -1
  29. package/server/service/index.ts +5 -0
  30. package/server/service/inventory-item/index.ts +6 -0
  31. package/server/service/inventory-item/inventory-item-mutation.ts +210 -0
  32. package/server/service/inventory-item/inventory-item-query.ts +118 -0
  33. package/server/service/inventory-item/inventory-item-type.ts +74 -0
  34. package/server/service/inventory-item/inventory-item.ts +99 -0
  35. package/server/service/inventory-product/index.ts +6 -0
  36. package/server/service/inventory-product/inventory-product-mutation.ts +112 -0
  37. package/server/service/inventory-product/inventory-product-query.ts +43 -0
  38. package/server/service/inventory-product/inventory-product-type.ts +59 -0
  39. package/server/service/inventory-product/inventory-product.ts +88 -0
  40. package/server/utils/inventory-no-generator.ts +4 -0
@@ -0,0 +1,43 @@
1
+ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { getRepository } from 'typeorm'
3
+ import { Domain, ListParam, convertListParams } from '@things-factory/shell'
4
+ import { User } from '@things-factory/auth-base'
5
+ import { InventoryProduct } from './inventory-product'
6
+ import { InventoryProductList } from './inventory-product-type'
7
+
8
+ @Resolver(InventoryProduct)
9
+ export class InventoryProductQuery {
10
+ @Query(returns => InventoryProduct, { description: 'To fetch a InventoryProduct' })
11
+ async inventoryProduct(@Arg('id') id: string, @Ctx() context: any): Promise<InventoryProduct> {
12
+ const { domain } = context.state
13
+
14
+ return await getRepository(InventoryProduct).findOne({
15
+ where: { domain, id }
16
+ })
17
+ }
18
+
19
+ @Query(returns => InventoryProductList, { description: 'To fetch multiple InventoryProducts' })
20
+ async inventoryProducts(@Args() params: ListParam, @Ctx() context: any): Promise<InventoryProductList> {
21
+ const { domain } = context.state
22
+
23
+ const convertedParams = convertListParams(params, domain.id)
24
+ const [items, total] = await getRepository(InventoryProduct).findAndCount(convertedParams)
25
+
26
+ return { items, total }
27
+ }
28
+
29
+ @FieldResolver(type => Domain)
30
+ async domain(@Root() inventoryProduct: InventoryProduct): Promise<Domain> {
31
+ return await getRepository(Domain).findOne(inventoryProduct.domainId)
32
+ }
33
+
34
+ @FieldResolver(type => User)
35
+ async updater(@Root() inventoryProduct: InventoryProduct): Promise<User> {
36
+ return await getRepository(User).findOne(inventoryProduct.updaterId)
37
+ }
38
+
39
+ @FieldResolver(type => User)
40
+ async creator(@Root() inventoryProduct: InventoryProduct): Promise<User> {
41
+ return await getRepository(User).findOne(inventoryProduct.creatorId)
42
+ }
43
+ }
@@ -0,0 +1,59 @@
1
+ import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
+
3
+ import { ObjectRef } from '@things-factory/shell'
4
+
5
+ import { InventoryProduct } from './inventory-product'
6
+
7
+ @InputType()
8
+ export class NewInventoryProduct {
9
+ @Field()
10
+ name: string
11
+
12
+ @Field({ nullable: true })
13
+ serialNumber?: string
14
+
15
+ @Field({ nullable: true })
16
+ status?: string
17
+
18
+ @Field(type => ObjectRef, { nullable: true })
19
+ product?: ObjectRef
20
+
21
+ @Field({ nullable: true })
22
+ arrivalNoticeId?: string
23
+
24
+ @Field({ nullable: true })
25
+ releaseGoodId?: string
26
+ }
27
+
28
+ @InputType()
29
+ export class InventoryProductPatch {
30
+ @Field(type => ID, { nullable: true })
31
+ id?: string
32
+
33
+ @Field({ nullable: true })
34
+ name?: string
35
+
36
+ @Field({ nullable: true })
37
+ serialNumber?: string
38
+
39
+ @Field({ nullable: true })
40
+ status?: string
41
+
42
+ @Field({ nullable: true })
43
+ arrivalNoticeId?: string
44
+
45
+ @Field({ nullable: true })
46
+ releaseGoodId?: string
47
+
48
+ @Field()
49
+ cuFlag: string
50
+ }
51
+
52
+ @ObjectType()
53
+ export class InventoryProductList {
54
+ @Field(type => [InventoryProduct])
55
+ items: InventoryProduct[]
56
+
57
+ @Field(type => Int)
58
+ total: number
59
+ }
@@ -0,0 +1,88 @@
1
+ import { Field, ID, ObjectType } from 'type-graphql'
2
+ import {
3
+ Column,
4
+ CreateDateColumn,
5
+ Entity,
6
+ Index,
7
+ ManyToOne,
8
+ PrimaryGeneratedColumn,
9
+ RelationId,
10
+ UpdateDateColumn
11
+ } from 'typeorm'
12
+
13
+ import { User } from '@things-factory/auth-base'
14
+ import { Product } from '@things-factory/product-base'
15
+ import { Domain } from '@things-factory/shell'
16
+
17
+ @Entity()
18
+ @Index(
19
+ 'ix_inventory_product_0',
20
+ (inventoryProduct: InventoryProduct) => [inventoryProduct.domain, inventoryProduct.name],
21
+ { unique: true }
22
+ )
23
+ @ObjectType({ description: 'Entity for InventoryProduct' })
24
+ export class InventoryProduct {
25
+ @PrimaryGeneratedColumn('uuid')
26
+ @Field(type => ID)
27
+ readonly id: string
28
+
29
+ @ManyToOne(type => Domain)
30
+ @Field({ nullable: true })
31
+ domain?: Domain
32
+
33
+ @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.domain)
34
+ domainId?: string
35
+
36
+ @Column()
37
+ @Field()
38
+ name: string
39
+
40
+ @Column({ nullable: true })
41
+ @Field({ nullable: true })
42
+ serialNumber?: string
43
+
44
+ @Column({ nullable: true })
45
+ @Field({ nullable: true })
46
+ status?: string
47
+
48
+ @Column({ nullable: true })
49
+ @Field({ nullable: true })
50
+ arrivalNoticeId: string
51
+
52
+ @Column({ nullable: true })
53
+ @Field({ nullable: true })
54
+ releaseGoodId: string
55
+
56
+ @ManyToOne(type => Product)
57
+ @Field({ nullable: true })
58
+ product?: Product
59
+
60
+ @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.product)
61
+ productId?: string
62
+
63
+ @CreateDateColumn()
64
+ @Field({ nullable: true })
65
+ createdAt?: Date
66
+
67
+ @UpdateDateColumn()
68
+ @Field({ nullable: true })
69
+ updatedAt?: Date
70
+
71
+ @ManyToOne(type => User, {
72
+ nullable: true
73
+ })
74
+ @Field({ nullable: true })
75
+ creator?: User
76
+
77
+ @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.creator)
78
+ creatorId?: string
79
+
80
+ @ManyToOne(type => User, {
81
+ nullable: true
82
+ })
83
+ @Field({ nullable: true })
84
+ updater?: User
85
+
86
+ @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.creator)
87
+ updaterId?: string
88
+ }
@@ -8,4 +8,8 @@ export class InventoryNoGenerator {
8
8
  static inventoryHistoryName() {
9
9
  return uuid()
10
10
  }
11
+
12
+ static inventoryItemName() {
13
+ return uuid()
14
+ }
11
15
  }