@things-factory/asset 0.0.0-stage → 10.1.229

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 (122) hide show
  1. package/dist-client/components/asset-documents.d.ts +22 -0
  2. package/dist-client/components/asset-documents.js +190 -0
  3. package/dist-client/components/asset-documents.js.map +1 -0
  4. package/dist-client/grid.d.ts +13 -0
  5. package/dist-client/grid.js +56 -0
  6. package/dist-client/grid.js.map +1 -0
  7. package/dist-client/index.d.ts +1 -0
  8. package/dist-client/index.js +2 -0
  9. package/dist-client/index.js.map +1 -0
  10. package/dist-client/pages/asset-list.d.ts +53 -0
  11. package/dist-client/pages/asset-list.js +171 -0
  12. package/dist-client/pages/asset-list.js.map +1 -0
  13. package/dist-client/pages/asset-reconciliation.d.ts +25 -0
  14. package/dist-client/pages/asset-reconciliation.js +165 -0
  15. package/dist-client/pages/asset-reconciliation.js.map +1 -0
  16. package/dist-client/pages/investee-page.d.ts +47 -0
  17. package/dist-client/pages/investee-page.js +322 -0
  18. package/dist-client/pages/investee-page.js.map +1 -0
  19. package/dist-client/pages/investment-list.d.ts +53 -0
  20. package/dist-client/pages/investment-list.js +131 -0
  21. package/dist-client/pages/investment-list.js.map +1 -0
  22. package/dist-client/route.d.ts +1 -0
  23. package/dist-client/route.js +18 -0
  24. package/dist-client/route.js.map +1 -0
  25. package/dist-client/tsconfig.tsbuildinfo +1 -0
  26. package/dist-client/words.d.ts +25 -0
  27. package/dist-client/words.js +23 -0
  28. package/dist-client/words.js.map +1 -0
  29. package/dist-server/attachment-reader.d.ts +3 -0
  30. package/dist-server/attachment-reader.js +20 -0
  31. package/dist-server/attachment-reader.js.map +1 -0
  32. package/dist-server/index.d.ts +1 -0
  33. package/dist-server/index.js +11 -0
  34. package/dist-server/index.js.map +1 -0
  35. package/dist-server/role-tasks.d.ts +2 -0
  36. package/dist-server/role-tasks.js +13 -0
  37. package/dist-server/role-tasks.js.map +1 -0
  38. package/dist-server/service/asset/asset-mutation.d.ts +5 -0
  39. package/dist-server/service/asset/asset-mutation.js +31 -0
  40. package/dist-server/service/asset/asset-mutation.js.map +1 -0
  41. package/dist-server/service/asset/asset-query.d.ts +19 -0
  42. package/dist-server/service/asset/asset-query.js +108 -0
  43. package/dist-server/service/asset/asset-query.js.map +1 -0
  44. package/dist-server/service/asset/asset-rules.d.ts +87 -0
  45. package/dist-server/service/asset/asset-rules.js +148 -0
  46. package/dist-server/service/asset/asset-rules.js.map +1 -0
  47. package/dist-server/service/asset/asset-service.d.ts +23 -0
  48. package/dist-server/service/asset/asset-service.js +84 -0
  49. package/dist-server/service/asset/asset-service.js.map +1 -0
  50. package/dist-server/service/asset/asset-type.d.ts +48 -0
  51. package/dist-server/service/asset/asset-type.js +182 -0
  52. package/dist-server/service/asset/asset-type.js.map +1 -0
  53. package/dist-server/service/asset/asset.d.ts +38 -0
  54. package/dist-server/service/asset/asset.js +159 -0
  55. package/dist-server/service/asset/asset.js.map +1 -0
  56. package/dist-server/service/asset/index.d.ts +6 -0
  57. package/dist-server/service/asset/index.js +10 -0
  58. package/dist-server/service/asset/index.js.map +1 -0
  59. package/dist-server/service/asset-document/asset-document-resolver.d.ts +32 -0
  60. package/dist-server/service/asset-document/asset-document-resolver.js +94 -0
  61. package/dist-server/service/asset-document/asset-document-resolver.js.map +1 -0
  62. package/dist-server/service/asset-document/asset-document-service.d.ts +34 -0
  63. package/dist-server/service/asset-document/asset-document-service.js +79 -0
  64. package/dist-server/service/asset-document/asset-document-service.js.map +1 -0
  65. package/dist-server/service/asset-document/index.d.ts +4 -0
  66. package/dist-server/service/asset-document/index.js +8 -0
  67. package/dist-server/service/asset-document/index.js.map +1 -0
  68. package/dist-server/service/checks.d.ts +12 -0
  69. package/dist-server/service/checks.js +27 -0
  70. package/dist-server/service/checks.js.map +1 -0
  71. package/dist-server/service/index.d.ts +18 -0
  72. package/dist-server/service/index.js +40 -0
  73. package/dist-server/service/index.js.map +1 -0
  74. package/dist-server/service/investment/index.d.ts +11 -0
  75. package/dist-server/service/investment/index.js +15 -0
  76. package/dist-server/service/investment/index.js.map +1 -0
  77. package/dist-server/service/investment/investee.d.ts +33 -0
  78. package/dist-server/service/investment/investee.js +135 -0
  79. package/dist-server/service/investment/investee.js.map +1 -0
  80. package/dist-server/service/investment/investment-board-seat.d.ts +25 -0
  81. package/dist-server/service/investment/investment-board-seat.js +98 -0
  82. package/dist-server/service/investment/investment-board-seat.js.map +1 -0
  83. package/dist-server/service/investment/investment-filing.d.ts +29 -0
  84. package/dist-server/service/investment/investment-filing.js +113 -0
  85. package/dist-server/service/investment/investment-filing.js.map +1 -0
  86. package/dist-server/service/investment/investment-holding.d.ts +31 -0
  87. package/dist-server/service/investment/investment-holding.js +127 -0
  88. package/dist-server/service/investment/investment-holding.js.map +1 -0
  89. package/dist-server/service/investment/investment-mutation.d.ts +15 -0
  90. package/dist-server/service/investment/investment-mutation.js +112 -0
  91. package/dist-server/service/investment/investment-mutation.js.map +1 -0
  92. package/dist-server/service/investment/investment-query.d.ts +33 -0
  93. package/dist-server/service/investment/investment-query.js +192 -0
  94. package/dist-server/service/investment/investment-query.js.map +1 -0
  95. package/dist-server/service/investment/investment-report.d.ts +37 -0
  96. package/dist-server/service/investment/investment-report.js +152 -0
  97. package/dist-server/service/investment/investment-report.js.map +1 -0
  98. package/dist-server/service/investment/investment-request.d.ts +31 -0
  99. package/dist-server/service/investment/investment-request.js +123 -0
  100. package/dist-server/service/investment/investment-request.js.map +1 -0
  101. package/dist-server/service/investment/investment-rules.d.ts +81 -0
  102. package/dist-server/service/investment/investment-rules.js +121 -0
  103. package/dist-server/service/investment/investment-rules.js.map +1 -0
  104. package/dist-server/service/investment/investment-service.d.ts +34 -0
  105. package/dist-server/service/investment/investment-service.js +280 -0
  106. package/dist-server/service/investment/investment-service.js.map +1 -0
  107. package/dist-server/service/investment/investment-type.d.ts +85 -0
  108. package/dist-server/service/investment/investment-type.js +324 -0
  109. package/dist-server/service/investment/investment-type.js.map +1 -0
  110. package/dist-server/service/patches.d.ts +24 -0
  111. package/dist-server/service/patches.js +63 -0
  112. package/dist-server/service/patches.js.map +1 -0
  113. package/dist-server/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +49 -4
  115. package/things-factory.config.js +11 -0
  116. package/translations/en.json +187 -0
  117. package/translations/es.json +187 -0
  118. package/translations/ja.json +187 -0
  119. package/translations/ko.json +187 -0
  120. package/translations/ms.json +187 -0
  121. package/translations/zh.json +187 -0
  122. package/README.md +0 -3
@@ -0,0 +1,48 @@
1
+ import { Asset } from './asset';
2
+ import { AssetKind, AssetStatus, DepreciationMethod } from './asset-rules';
3
+ export declare class AssetPatch {
4
+ id?: string;
5
+ cuFlag?: string;
6
+ name?: string;
7
+ kind?: AssetKind;
8
+ statementCode?: string;
9
+ acquiredOn?: string;
10
+ cost?: number;
11
+ residualValue?: number;
12
+ method?: DepreciationMethod;
13
+ usefulLifeYears?: number;
14
+ declineRate?: number;
15
+ depreciationStartOn?: string;
16
+ status?: AssetStatus;
17
+ disposedOn?: string;
18
+ location?: string;
19
+ keeper?: string;
20
+ source?: string;
21
+ project?: string;
22
+ description?: string;
23
+ }
24
+ export declare class AssetList {
25
+ items: Asset[];
26
+ total: number;
27
+ }
28
+ export declare class AssetYear {
29
+ fiscalYear: number;
30
+ expense: number;
31
+ accumulated: number;
32
+ bookValue: number;
33
+ }
34
+ export declare class AssetReconciliationRow {
35
+ code: string;
36
+ name: string;
37
+ assets: number;
38
+ registerCost: number;
39
+ registerAccumulated: number;
40
+ statementCost?: number;
41
+ statementAccumulated?: number;
42
+ differs: boolean;
43
+ }
44
+ export declare class AssetReconciliation {
45
+ fiscalYear: number;
46
+ filed: boolean;
47
+ rows: AssetReconciliationRow[];
48
+ }
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssetReconciliation = exports.AssetReconciliationRow = exports.AssetYear = exports.AssetList = exports.AssetPatch = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const asset_1 = require("./asset");
7
+ const asset_rules_1 = require("./asset-rules");
8
+ let AssetPatch = class AssetPatch {
9
+ };
10
+ exports.AssetPatch = AssetPatch;
11
+ tslib_1.__decorate([
12
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'The asset; empty for a new one' }),
13
+ tslib_1.__metadata("design:type", String)
14
+ ], AssetPatch.prototype, "id", void 0);
15
+ tslib_1.__decorate([
16
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Grid flag: + new, M changed, - deleted' }),
17
+ tslib_1.__metadata("design:type", String)
18
+ ], AssetPatch.prototype, "cuFlag", void 0);
19
+ tslib_1.__decorate([
20
+ (0, type_graphql_1.Field)({ nullable: true, description: 'What the asset is called' }),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], AssetPatch.prototype, "name", void 0);
23
+ tslib_1.__decorate([
24
+ (0, type_graphql_1.Field)(type => asset_rules_1.AssetKind, { nullable: true, description: 'What kind of asset it is' }),
25
+ tslib_1.__metadata("design:type", String)
26
+ ], AssetPatch.prototype, "kind", void 0);
27
+ tslib_1.__decorate([
28
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The line of the filed balance sheet; the kind gives it when empty' }),
29
+ tslib_1.__metadata("design:type", String)
30
+ ], AssetPatch.prototype, "statementCode", void 0);
31
+ tslib_1.__decorate([
32
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it was acquired - YYYY-MM-DD' }),
33
+ tslib_1.__metadata("design:type", String)
34
+ ], AssetPatch.prototype, "acquiredOn", void 0);
35
+ tslib_1.__decorate([
36
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'What it cost, in won' }),
37
+ tslib_1.__metadata("design:type", Number)
38
+ ], AssetPatch.prototype, "cost", void 0);
39
+ tslib_1.__decorate([
40
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The value left at the end of its useful life, in won' }),
41
+ tslib_1.__metadata("design:type", Number)
42
+ ], AssetPatch.prototype, "residualValue", void 0);
43
+ tslib_1.__decorate([
44
+ (0, type_graphql_1.Field)(type => asset_rules_1.DepreciationMethod, { nullable: true, description: 'How it is depreciated; the kind gives it when empty' }),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], AssetPatch.prototype, "method", void 0);
47
+ tslib_1.__decorate([
48
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Useful life in years' }),
49
+ tslib_1.__metadata("design:type", Number)
50
+ ], AssetPatch.prototype, "usefulLifeYears", void 0);
51
+ tslib_1.__decorate([
52
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Yearly rate of declining-balance depreciation' }),
53
+ tslib_1.__metadata("design:type", Number)
54
+ ], AssetPatch.prototype, "declineRate", void 0);
55
+ tslib_1.__decorate([
56
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day depreciation starts - YYYY-MM-DD' }),
57
+ tslib_1.__metadata("design:type", String)
58
+ ], AssetPatch.prototype, "depreciationStartOn", void 0);
59
+ tslib_1.__decorate([
60
+ (0, type_graphql_1.Field)(type => asset_rules_1.AssetStatus, { nullable: true, description: 'In use, disposed of or scrapped' }),
61
+ tslib_1.__metadata("design:type", String)
62
+ ], AssetPatch.prototype, "status", void 0);
63
+ tslib_1.__decorate([
64
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it was disposed of or scrapped - YYYY-MM-DD' }),
65
+ tslib_1.__metadata("design:type", String)
66
+ ], AssetPatch.prototype, "disposedOn", void 0);
67
+ tslib_1.__decorate([
68
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Where it is' }),
69
+ tslib_1.__metadata("design:type", String)
70
+ ], AssetPatch.prototype, "location", void 0);
71
+ tslib_1.__decorate([
72
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Who looks after it' }),
73
+ tslib_1.__metadata("design:type", String)
74
+ ], AssetPatch.prototype, "keeper", void 0);
75
+ tslib_1.__decorate([
76
+ (0, type_graphql_1.Field)({ nullable: true, description: 'What it was acquired by, in words' }),
77
+ tslib_1.__metadata("design:type", String)
78
+ ], AssetPatch.prototype, "source", void 0);
79
+ tslib_1.__decorate([
80
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The development project it came from' }),
81
+ tslib_1.__metadata("design:type", String)
82
+ ], AssetPatch.prototype, "project", void 0);
83
+ tslib_1.__decorate([
84
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
85
+ tslib_1.__metadata("design:type", String)
86
+ ], AssetPatch.prototype, "description", void 0);
87
+ exports.AssetPatch = AssetPatch = tslib_1.__decorate([
88
+ (0, type_graphql_1.InputType)({ description: 'A row of the asset register grid (cuFlag + for new, M for changed, - for deleted)' })
89
+ ], AssetPatch);
90
+ let AssetList = class AssetList {
91
+ };
92
+ exports.AssetList = AssetList;
93
+ tslib_1.__decorate([
94
+ (0, type_graphql_1.Field)(type => [asset_1.Asset], { description: 'Assets on the page' }),
95
+ tslib_1.__metadata("design:type", Array)
96
+ ], AssetList.prototype, "items", void 0);
97
+ tslib_1.__decorate([
98
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Number of assets matching the list parameters' }),
99
+ tslib_1.__metadata("design:type", Number)
100
+ ], AssetList.prototype, "total", void 0);
101
+ exports.AssetList = AssetList = tslib_1.__decorate([
102
+ (0, type_graphql_1.ObjectType)({ description: 'A page of assets' })
103
+ ], AssetList);
104
+ let AssetYear = class AssetYear {
105
+ };
106
+ exports.AssetYear = AssetYear;
107
+ tslib_1.__decorate([
108
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The fiscal year, January to December' }),
109
+ tslib_1.__metadata("design:type", Number)
110
+ ], AssetYear.prototype, "fiscalYear", void 0);
111
+ tslib_1.__decorate([
112
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Depreciation of the year' }),
113
+ tslib_1.__metadata("design:type", Number)
114
+ ], AssetYear.prototype, "expense", void 0);
115
+ tslib_1.__decorate([
116
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Accumulated depreciation at the end of the year' }),
117
+ tslib_1.__metadata("design:type", Number)
118
+ ], AssetYear.prototype, "accumulated", void 0);
119
+ tslib_1.__decorate([
120
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Cost less accumulated depreciation at the end of the year' }),
121
+ tslib_1.__metadata("design:type", Number)
122
+ ], AssetYear.prototype, "bookValue", void 0);
123
+ exports.AssetYear = AssetYear = tslib_1.__decorate([
124
+ (0, type_graphql_1.ObjectType)({ description: "An asset's depreciation for a fiscal year, computed from the register" })
125
+ ], AssetYear);
126
+ let AssetReconciliationRow = class AssetReconciliationRow {
127
+ };
128
+ exports.AssetReconciliationRow = AssetReconciliationRow;
129
+ tslib_1.__decorate([
130
+ (0, type_graphql_1.Field)({ description: 'The line code of the standard balance sheet' }),
131
+ tslib_1.__metadata("design:type", String)
132
+ ], AssetReconciliationRow.prototype, "code", void 0);
133
+ tslib_1.__decorate([
134
+ (0, type_graphql_1.Field)({ description: 'The name the filed statement gives the line' }),
135
+ tslib_1.__metadata("design:type", String)
136
+ ], AssetReconciliationRow.prototype, "name", void 0);
137
+ tslib_1.__decorate([
138
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'How many assets of the register are on the line at the end of the year' }),
139
+ tslib_1.__metadata("design:type", Number)
140
+ ], AssetReconciliationRow.prototype, "assets", void 0);
141
+ tslib_1.__decorate([
142
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Their cost' }),
143
+ tslib_1.__metadata("design:type", Number)
144
+ ], AssetReconciliationRow.prototype, "registerCost", void 0);
145
+ tslib_1.__decorate([
146
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Their accumulated depreciation, computed' }),
147
+ tslib_1.__metadata("design:type", Number)
148
+ ], AssetReconciliationRow.prototype, "registerAccumulated", void 0);
149
+ tslib_1.__decorate([
150
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The amount the filed statement carries' }),
151
+ tslib_1.__metadata("design:type", Number)
152
+ ], AssetReconciliationRow.prototype, "statementCost", void 0);
153
+ tslib_1.__decorate([
154
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The accumulated depreciation the filed statement carries' }),
155
+ tslib_1.__metadata("design:type", Number)
156
+ ], AssetReconciliationRow.prototype, "statementAccumulated", void 0);
157
+ tslib_1.__decorate([
158
+ (0, type_graphql_1.Field)({ description: 'Whether the register and the filed statement differ' }),
159
+ tslib_1.__metadata("design:type", Boolean)
160
+ ], AssetReconciliationRow.prototype, "differs", void 0);
161
+ exports.AssetReconciliationRow = AssetReconciliationRow = tslib_1.__decorate([
162
+ (0, type_graphql_1.ObjectType)({ description: 'A line of the filed balance sheet beside the register' })
163
+ ], AssetReconciliationRow);
164
+ let AssetReconciliation = class AssetReconciliation {
165
+ };
166
+ exports.AssetReconciliation = AssetReconciliation;
167
+ tslib_1.__decorate([
168
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The fiscal year' }),
169
+ tslib_1.__metadata("design:type", Number)
170
+ ], AssetReconciliation.prototype, "fiscalYear", void 0);
171
+ tslib_1.__decorate([
172
+ (0, type_graphql_1.Field)({ description: 'Whether a balance sheet is filed for the year' }),
173
+ tslib_1.__metadata("design:type", Boolean)
174
+ ], AssetReconciliation.prototype, "filed", void 0);
175
+ tslib_1.__decorate([
176
+ (0, type_graphql_1.Field)(type => [AssetReconciliationRow], { description: 'Line by line' }),
177
+ tslib_1.__metadata("design:type", Array)
178
+ ], AssetReconciliation.prototype, "rows", void 0);
179
+ exports.AssetReconciliation = AssetReconciliation = tslib_1.__decorate([
180
+ (0, type_graphql_1.ObjectType)({ description: 'The register beside the filed balance sheet of a fiscal year' })
181
+ ], AssetReconciliation);
182
+ //# sourceMappingURL=asset-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-type.js","sourceRoot":"","sources":["../../../server/service/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AE,CAAC,CAAC,sBAAsB,CAAC,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;;iDAA+B;8BAH7F,mBAAmB;IAD/B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;GAC/E,mBAAmB,CAI/B","sourcesContent":["import { Field, Float, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Asset } from './asset'\nimport { AssetKind, AssetStatus, DepreciationMethod } from './asset-rules'\n\n@InputType({ description: 'A row of the asset register grid (cuFlag + for new, M for changed, - for deleted)' })\nexport class AssetPatch {\n @Field(type => ID, { nullable: true, description: 'The asset; empty for a new one' }) id?: string\n @Field({ nullable: true, description: 'Grid flag: + new, M changed, - deleted' }) cuFlag?: string\n @Field({ nullable: true, description: 'What the asset is called' }) name?: string\n @Field(type => AssetKind, { nullable: true, description: 'What kind of asset it is' }) kind?: AssetKind\n @Field({ nullable: true, description: 'The line of the filed balance sheet; the kind gives it when empty' }) statementCode?: string\n @Field({ nullable: true, description: 'The day it was acquired - YYYY-MM-DD' }) acquiredOn?: string\n @Field(type => Float, { nullable: true, description: 'What it cost, in won' }) cost?: number\n @Field(type => Float, { nullable: true, description: 'The value left at the end of its useful life, in won' }) residualValue?: number\n @Field(type => DepreciationMethod, { nullable: true, description: 'How it is depreciated; the kind gives it when empty' }) method?: DepreciationMethod\n @Field(type => Float, { nullable: true, description: 'Useful life in years' }) usefulLifeYears?: number\n @Field(type => Float, { nullable: true, description: 'Yearly rate of declining-balance depreciation' }) declineRate?: number\n @Field({ nullable: true, description: 'The day depreciation starts - YYYY-MM-DD' }) depreciationStartOn?: string\n @Field(type => AssetStatus, { nullable: true, description: 'In use, disposed of or scrapped' }) status?: AssetStatus\n @Field({ nullable: true, description: 'The day it was disposed of or scrapped - YYYY-MM-DD' }) disposedOn?: string\n @Field({ nullable: true, description: 'Where it is' }) location?: string\n @Field({ nullable: true, description: 'Who looks after it' }) keeper?: string\n @Field({ nullable: true, description: 'What it was acquired by, in words' }) source?: string\n @Field({ nullable: true, description: 'The development project it came from' }) project?: string\n @Field({ nullable: true, description: 'Notes' }) description?: string\n}\n\n@ObjectType({ description: 'A page of assets' })\nexport class AssetList {\n @Field(type => [Asset], { description: 'Assets on the page' }) items: Asset[]\n @Field(type => Int, { description: 'Number of assets matching the list parameters' }) total: number\n}\n\n@ObjectType({ description: \"An asset's depreciation for a fiscal year, computed from the register\" })\nexport class AssetYear {\n @Field(type => Int, { description: 'The fiscal year, January to December' }) fiscalYear: number\n @Field(type => Float, { description: 'Depreciation of the year' }) expense: number\n @Field(type => Float, { description: 'Accumulated depreciation at the end of the year' }) accumulated: number\n @Field(type => Float, { description: 'Cost less accumulated depreciation at the end of the year' }) bookValue: number\n}\n\n@ObjectType({ description: 'A line of the filed balance sheet beside the register' })\nexport class AssetReconciliationRow {\n @Field({ description: 'The line code of the standard balance sheet' }) code: string\n @Field({ description: 'The name the filed statement gives the line' }) name: string\n @Field(type => Int, { description: 'How many assets of the register are on the line at the end of the year' }) assets: number\n @Field(type => Float, { description: 'Their cost' }) registerCost: number\n @Field(type => Float, { description: 'Their accumulated depreciation, computed' }) registerAccumulated: number\n @Field(type => Float, { nullable: true, description: 'The amount the filed statement carries' }) statementCost?: number\n @Field(type => Float, { nullable: true, description: 'The accumulated depreciation the filed statement carries' }) statementAccumulated?: number\n @Field({ description: 'Whether the register and the filed statement differ' }) differs: boolean\n}\n\n@ObjectType({ description: 'The register beside the filed balance sheet of a fiscal year' })\nexport class AssetReconciliation {\n @Field(type => Int, { description: 'The fiscal year' }) fiscalYear: number\n @Field({ description: 'Whether a balance sheet is filed for the year' }) filed: boolean\n @Field(type => [AssetReconciliationRow], { description: 'Line by line' }) rows: AssetReconciliationRow[]\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { User } from '@things-factory/auth-base';
2
+ import { Domain } from '@things-factory/shell';
3
+ import { AssetKind, AssetStatus, DepreciationMethod } from './asset-rules';
4
+ /**
5
+ * A tangible or intangible asset of the domain - what it is, when and for how much it was acquired, how it is
6
+ * depreciated and whether it is still in use (ADR-0175 decisions 3-4). The depreciation of a year is computed from these,
7
+ * never stored. The books are the accountant's; the register is set beside them, not written into them.
8
+ */
9
+ export declare class Asset {
10
+ readonly id: string;
11
+ domain?: Domain;
12
+ domainId?: string;
13
+ name: string;
14
+ kind: AssetKind;
15
+ statementCode?: string;
16
+ acquiredOn: string;
17
+ cost: number;
18
+ residualValue: number;
19
+ method: DepreciationMethod;
20
+ usefulLifeYears?: number;
21
+ declineRate?: number;
22
+ depreciationStartOn?: string;
23
+ status: AssetStatus;
24
+ disposedOn?: string;
25
+ location?: string;
26
+ keeper?: string;
27
+ source?: string;
28
+ project?: string;
29
+ description?: string;
30
+ documents?: number;
31
+ createdAt?: Date;
32
+ updatedAt?: Date;
33
+ deletedAt?: Date;
34
+ creator?: User;
35
+ creatorId?: string;
36
+ updater?: User;
37
+ updaterId?: string;
38
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Asset = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const auth_base_1 = require("@things-factory/auth-base");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const type_graphql_1 = require("type-graphql");
8
+ const typeorm_1 = require("typeorm");
9
+ const asset_rules_1 = require("./asset-rules");
10
+ /**
11
+ * A tangible or intangible asset of the domain - what it is, when and for how much it was acquired, how it is
12
+ * depreciated and whether it is still in use (ADR-0175 decisions 3-4). The depreciation of a year is computed from these,
13
+ * never stored. The books are the accountant's; the register is set beside them, not written into them.
14
+ */
15
+ let Asset = class Asset {
16
+ };
17
+ exports.Asset = Asset;
18
+ tslib_1.__decorate([
19
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
20
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier of the asset' }),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], Asset.prototype, "id", void 0);
23
+ tslib_1.__decorate([
24
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
25
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain the asset belongs to' }),
26
+ tslib_1.__metadata("design:type", shell_1.Domain)
27
+ ], Asset.prototype, "domain", void 0);
28
+ tslib_1.__decorate([
29
+ (0, typeorm_1.RelationId)((asset) => asset.domain),
30
+ tslib_1.__metadata("design:type", String)
31
+ ], Asset.prototype, "domainId", void 0);
32
+ tslib_1.__decorate([
33
+ (0, typeorm_1.Column)(),
34
+ (0, type_graphql_1.Field)({ description: 'What the asset is called' }),
35
+ tslib_1.__metadata("design:type", String)
36
+ ], Asset.prototype, "name", void 0);
37
+ tslib_1.__decorate([
38
+ (0, typeorm_1.Column)(),
39
+ (0, type_graphql_1.Field)(type => asset_rules_1.AssetKind, { description: 'What kind of asset it is' }),
40
+ tslib_1.__metadata("design:type", String)
41
+ ], Asset.prototype, "kind", void 0);
42
+ tslib_1.__decorate([
43
+ (0, typeorm_1.Column)({ nullable: true }),
44
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The line of the filed balance sheet it belongs to; the kind gives it when empty' }),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], Asset.prototype, "statementCode", void 0);
47
+ tslib_1.__decorate([
48
+ (0, typeorm_1.Column)(),
49
+ (0, type_graphql_1.Field)({ description: 'The day it was acquired - YYYY-MM-DD' }),
50
+ tslib_1.__metadata("design:type", String)
51
+ ], Asset.prototype, "acquiredOn", void 0);
52
+ tslib_1.__decorate([
53
+ (0, typeorm_1.Column)({ ...(0, shell_1.moneyColumn)(), default: 0 }),
54
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'What it cost to acquire, in won' }),
55
+ tslib_1.__metadata("design:type", Number)
56
+ ], Asset.prototype, "cost", void 0);
57
+ tslib_1.__decorate([
58
+ (0, typeorm_1.Column)({ ...(0, shell_1.moneyColumn)(), default: 0 }),
59
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'The value left at the end of its useful life, in won' }),
60
+ tslib_1.__metadata("design:type", Number)
61
+ ], Asset.prototype, "residualValue", void 0);
62
+ tslib_1.__decorate([
63
+ (0, typeorm_1.Column)({ default: asset_rules_1.DepreciationMethod.STRAIGHT_LINE }),
64
+ (0, type_graphql_1.Field)(type => asset_rules_1.DepreciationMethod, { description: 'How it is depreciated' }),
65
+ tslib_1.__metadata("design:type", String)
66
+ ], Asset.prototype, "method", void 0);
67
+ tslib_1.__decorate([
68
+ (0, typeorm_1.Column)({ type: 'float', nullable: true }),
69
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Useful life in years, as the books use it' }),
70
+ tslib_1.__metadata("design:type", Number)
71
+ ], Asset.prototype, "usefulLifeYears", void 0);
72
+ tslib_1.__decorate([
73
+ (0, typeorm_1.Column)({ type: 'float', nullable: true }),
74
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The yearly rate of declining-balance depreciation, as the books use it (0.451 for 45.1%)' }),
75
+ tslib_1.__metadata("design:type", Number)
76
+ ], Asset.prototype, "declineRate", void 0);
77
+ tslib_1.__decorate([
78
+ (0, typeorm_1.Column)({ nullable: true }),
79
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day depreciation starts - YYYY-MM-DD; the day it was acquired when empty' }),
80
+ tslib_1.__metadata("design:type", String)
81
+ ], Asset.prototype, "depreciationStartOn", void 0);
82
+ tslib_1.__decorate([
83
+ (0, typeorm_1.Column)({ default: asset_rules_1.AssetStatus.IN_USE }),
84
+ (0, type_graphql_1.Field)(type => asset_rules_1.AssetStatus, { description: 'In use, disposed of or scrapped' }),
85
+ tslib_1.__metadata("design:type", String)
86
+ ], Asset.prototype, "status", void 0);
87
+ tslib_1.__decorate([
88
+ (0, typeorm_1.Column)({ nullable: true }),
89
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it was disposed of or scrapped - YYYY-MM-DD' }),
90
+ tslib_1.__metadata("design:type", String)
91
+ ], Asset.prototype, "disposedOn", void 0);
92
+ tslib_1.__decorate([
93
+ (0, typeorm_1.Column)({ nullable: true }),
94
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Where it is' }),
95
+ tslib_1.__metadata("design:type", String)
96
+ ], Asset.prototype, "location", void 0);
97
+ tslib_1.__decorate([
98
+ (0, typeorm_1.Column)({ nullable: true }),
99
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Who looks after it' }),
100
+ tslib_1.__metadata("design:type", String)
101
+ ], Asset.prototype, "keeper", void 0);
102
+ tslib_1.__decorate([
103
+ (0, typeorm_1.Column)({ nullable: true }),
104
+ (0, type_graphql_1.Field)({ nullable: true, description: 'What it was acquired by - the contract, the invoice, the payment - in words' }),
105
+ tslib_1.__metadata("design:type", String)
106
+ ], Asset.prototype, "source", void 0);
107
+ tslib_1.__decorate([
108
+ (0, typeorm_1.Column)({ nullable: true }),
109
+ (0, type_graphql_1.Field)({ nullable: true, description: 'For development cost: the development project it came from' }),
110
+ tslib_1.__metadata("design:type", String)
111
+ ], Asset.prototype, "project", void 0);
112
+ tslib_1.__decorate([
113
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
114
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
115
+ tslib_1.__metadata("design:type", String)
116
+ ], Asset.prototype, "description", void 0);
117
+ tslib_1.__decorate([
118
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'How many documents are attached - filled by the list query' }),
119
+ tslib_1.__metadata("design:type", Number)
120
+ ], Asset.prototype, "documents", void 0);
121
+ tslib_1.__decorate([
122
+ (0, typeorm_1.CreateDateColumn)(),
123
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the asset was registered' }),
124
+ tslib_1.__metadata("design:type", Date)
125
+ ], Asset.prototype, "createdAt", void 0);
126
+ tslib_1.__decorate([
127
+ (0, typeorm_1.UpdateDateColumn)(),
128
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the asset last changed' }),
129
+ tslib_1.__metadata("design:type", Date)
130
+ ], Asset.prototype, "updatedAt", void 0);
131
+ tslib_1.__decorate([
132
+ (0, typeorm_1.DeleteDateColumn)(),
133
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the asset was deleted' }),
134
+ tslib_1.__metadata("design:type", Date)
135
+ ], Asset.prototype, "deletedAt", void 0);
136
+ tslib_1.__decorate([
137
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
138
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who registered it' }),
139
+ tslib_1.__metadata("design:type", auth_base_1.User)
140
+ ], Asset.prototype, "creator", void 0);
141
+ tslib_1.__decorate([
142
+ (0, typeorm_1.RelationId)((asset) => asset.creator),
143
+ tslib_1.__metadata("design:type", String)
144
+ ], Asset.prototype, "creatorId", void 0);
145
+ tslib_1.__decorate([
146
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
147
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it' }),
148
+ tslib_1.__metadata("design:type", auth_base_1.User)
149
+ ], Asset.prototype, "updater", void 0);
150
+ tslib_1.__decorate([
151
+ (0, typeorm_1.RelationId)((asset) => asset.updater),
152
+ tslib_1.__metadata("design:type", String)
153
+ ], Asset.prototype, "updaterId", void 0);
154
+ exports.Asset = Asset = tslib_1.__decorate([
155
+ (0, typeorm_1.Entity)(),
156
+ (0, typeorm_1.Index)('ix_asset_0', (asset) => [asset.domain, asset.kind]),
157
+ (0, type_graphql_1.ObjectType)({ description: 'Entity for Asset — a tangible or intangible asset of the domain and how it is depreciated' })
158
+ ], Asset);
159
+ //# sourceMappingURL=asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.js","sourceRoot":"","sources":["../../../server/service/asset/asset.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,iDAA2D;AAC3D,+CAAgE;AAChE,qCAAoJ;AAEpJ,+CAA0E;AAE1E;;;;GAIG;AAII,IAAM,K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C;IACjE,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2FAA2F,EAAE,CAAC;GAC5G,KAAK,CA4GjB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { AssetKind, AssetStatus, DepreciationMethod } from './asset-rules'\n\n/**\n * A tangible or intangible asset of the domain - what it is, when and for how much it was acquired, how it is\n * depreciated and whether it is still in use (ADR-0175 decisions 3-4). The depreciation of a year is computed from these,\n * never stored. The books are the accountant's; the register is set beside them, not written into them.\n */\n@Entity()\n@Index('ix_asset_0', (asset: Asset) => [asset.domain, asset.kind])\n@ObjectType({ description: 'Entity for Asset — a tangible or intangible asset of the domain and how it is depreciated' })\nexport class Asset {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier of the asset' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the asset belongs to' })\n domain?: Domain\n\n @RelationId((asset: Asset) => asset.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'What the asset is called' })\n name: string\n\n @Column()\n @Field(type => AssetKind, { description: 'What kind of asset it is' })\n kind: AssetKind\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The line of the filed balance sheet it belongs to; the kind gives it when empty' })\n statementCode?: string\n\n @Column()\n @Field({ description: 'The day it was acquired - YYYY-MM-DD' })\n acquiredOn: string\n\n @Column({ ...moneyColumn(), default: 0 })\n @Field(type => Float, { description: 'What it cost to acquire, in won' })\n cost: number\n\n @Column({ ...moneyColumn(), default: 0 })\n @Field(type => Float, { description: 'The value left at the end of its useful life, in won' })\n residualValue: number\n\n @Column({ default: DepreciationMethod.STRAIGHT_LINE })\n @Field(type => DepreciationMethod, { description: 'How it is depreciated' })\n method: DepreciationMethod\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Useful life in years, as the books use it' })\n usefulLifeYears?: number\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'The yearly rate of declining-balance depreciation, as the books use it (0.451 for 45.1%)' })\n declineRate?: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The day depreciation starts - YYYY-MM-DD; the day it was acquired when empty' })\n depreciationStartOn?: string\n\n @Column({ default: AssetStatus.IN_USE })\n @Field(type => AssetStatus, { description: 'In use, disposed of or scrapped' })\n status: AssetStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The day it was disposed of or scrapped - YYYY-MM-DD' })\n disposedOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Where it is' })\n location?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Who looks after it' })\n keeper?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'What it was acquired by - the contract, the invoice, the payment - in words' })\n source?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'For development cost: the development project it came from' })\n project?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n description?: string\n\n @Field(type => Int, { nullable: true, description: 'How many documents are attached - filled by the list query' })\n documents?: number\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the asset was registered' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the asset last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the asset was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who registered it' })\n creator?: User\n\n @RelationId((asset: Asset) => asset.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((asset: Asset) => asset.updater)\n updaterId?: string\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { Asset } from './asset';
2
+ import { AssetMutation } from './asset-mutation';
3
+ import { AssetQuery } from './asset-query';
4
+ export declare const entities: (typeof Asset)[];
5
+ export declare const resolvers: (typeof AssetMutation | typeof AssetQuery)[];
6
+ export declare const subscribers: any[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscribers = exports.resolvers = exports.entities = void 0;
4
+ const asset_1 = require("./asset");
5
+ const asset_mutation_1 = require("./asset-mutation");
6
+ const asset_query_1 = require("./asset-query");
7
+ exports.entities = [asset_1.Asset];
8
+ exports.resolvers = [asset_query_1.AssetQuery, asset_mutation_1.AssetMutation];
9
+ exports.subscribers = [];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/asset/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,qDAAgD;AAChD,+CAA0C;AAE7B,QAAA,QAAQ,GAAG,CAAC,aAAK,CAAC,CAAA;AAClB,QAAA,SAAS,GAAG,CAAC,wBAAU,EAAE,8BAAa,CAAC,CAAA;AACvC,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { Asset } from './asset'\nimport { AssetMutation } from './asset-mutation'\nimport { AssetQuery } from './asset-query'\n\nexport const entities = [Asset]\nexport const resolvers = [AssetQuery, AssetMutation]\nexport const subscribers = []\n"]}
@@ -0,0 +1,32 @@
1
+ import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
2
+ import { AssetDocumentOwner } from './asset-document-service';
3
+ export declare class AssetDocument {
4
+ id: string;
5
+ name: string;
6
+ mimetype?: string;
7
+ size?: number;
8
+ fullpath: string;
9
+ createdAt?: Date;
10
+ creator?: string;
11
+ }
12
+ export declare class AssetDocumentResolver {
13
+ assetDocuments(owner: AssetDocumentOwner, id: string, context: ResolverContext): Promise<{
14
+ id: string;
15
+ name: string;
16
+ mimetype: string;
17
+ size: number;
18
+ fullpath: string;
19
+ createdAt: Date;
20
+ creator: string | undefined;
21
+ }[]>;
22
+ attachAssetDocuments(owner: AssetDocumentOwner, id: string, files: FileUpload[], context: ResolverContext): Promise<{
23
+ id: string;
24
+ name: string;
25
+ mimetype: string;
26
+ size: number;
27
+ fullpath: string;
28
+ createdAt: Date;
29
+ creator: string | undefined;
30
+ }[]>;
31
+ removeAssetDocument(id: string, context: ResolverContext): Promise<boolean>;
32
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssetDocumentResolver = exports.AssetDocument = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
6
+ const shell_1 = require("@things-factory/shell");
7
+ const attachment_base_1 = require("@things-factory/attachment-base");
8
+ const type_graphql_1 = require("type-graphql");
9
+ const asset_document_service_1 = require("./asset-document-service");
10
+ let AssetDocument = class AssetDocument {
11
+ };
12
+ exports.AssetDocument = AssetDocument;
13
+ tslib_1.__decorate([
14
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'The attachment' }),
15
+ tslib_1.__metadata("design:type", String)
16
+ ], AssetDocument.prototype, "id", void 0);
17
+ tslib_1.__decorate([
18
+ (0, type_graphql_1.Field)({ description: 'The file name' }),
19
+ tslib_1.__metadata("design:type", String)
20
+ ], AssetDocument.prototype, "name", void 0);
21
+ tslib_1.__decorate([
22
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The media type' }),
23
+ tslib_1.__metadata("design:type", String)
24
+ ], AssetDocument.prototype, "mimetype", void 0);
25
+ tslib_1.__decorate([
26
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Size in bytes' }),
27
+ tslib_1.__metadata("design:type", Number)
28
+ ], AssetDocument.prototype, "size", void 0);
29
+ tslib_1.__decorate([
30
+ (0, type_graphql_1.Field)({ description: 'Where the file is served' }),
31
+ tslib_1.__metadata("design:type", String)
32
+ ], AssetDocument.prototype, "fullpath", void 0);
33
+ tslib_1.__decorate([
34
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it was attached' }),
35
+ tslib_1.__metadata("design:type", Date)
36
+ ], AssetDocument.prototype, "createdAt", void 0);
37
+ tslib_1.__decorate([
38
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Who attached it' }),
39
+ tslib_1.__metadata("design:type", String)
40
+ ], AssetDocument.prototype, "creator", void 0);
41
+ exports.AssetDocument = AssetDocument = tslib_1.__decorate([
42
+ (0, type_graphql_1.ObjectType)({ description: 'A document of the asset register - a contract, a certificate, a report, a signed copy' })
43
+ ], AssetDocument);
44
+ let AssetDocumentResolver = class AssetDocumentResolver {
45
+ assetDocuments(owner, id, context) {
46
+ return (0, asset_document_service_1.assetDocuments)((0, shell_1.getRepository)(attachment_base_1.Attachment).manager, context.state.domain, owner, id);
47
+ }
48
+ attachAssetDocuments(owner, id, files, context) {
49
+ const { domain, tx } = context.state;
50
+ return (0, asset_document_service_1.attachAssetDocuments)(tx, domain, owner, id, files, context);
51
+ }
52
+ removeAssetDocument(id, context) {
53
+ const { domain, user, tx } = context.state;
54
+ return (0, asset_document_service_1.removeAssetDocument)(tx, domain, user, id);
55
+ }
56
+ };
57
+ exports.AssetDocumentResolver = AssetDocumentResolver;
58
+ tslib_1.__decorate([
59
+ (0, type_graphql_1.Directive)('@privilege(category: "asset", privilege: "query", domainOwnerGranted: true)'),
60
+ (0, type_graphql_1.Query)(returns => [AssetDocument], { description: "A row's documents, the latest first" }),
61
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('owner', type => asset_document_service_1.AssetDocumentOwner)),
62
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('id')),
63
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
64
+ tslib_1.__metadata("design:type", Function),
65
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
66
+ tslib_1.__metadata("design:returntype", void 0)
67
+ ], AssetDocumentResolver.prototype, "assetDocuments", null);
68
+ tslib_1.__decorate([
69
+ (0, type_graphql_1.Directive)('@transaction'),
70
+ (0, type_graphql_1.Directive)('@privilege(category: "asset", privilege: "mutation", domainOwnerGranted: true)'),
71
+ (0, type_graphql_1.Mutation)(returns => [AssetDocument], { description: 'Attach files to a row - each kept beside the ones before' }),
72
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('owner', type => asset_document_service_1.AssetDocumentOwner)),
73
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('id')),
74
+ tslib_1.__param(2, (0, type_graphql_1.Arg)('files', type => [GraphQLUpload_js_1.default])),
75
+ tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
76
+ tslib_1.__metadata("design:type", Function),
77
+ tslib_1.__metadata("design:paramtypes", [String, String, Array, Object]),
78
+ tslib_1.__metadata("design:returntype", void 0)
79
+ ], AssetDocumentResolver.prototype, "attachAssetDocuments", null);
80
+ tslib_1.__decorate([
81
+ (0, type_graphql_1.Directive)('@transaction'),
82
+ (0, type_graphql_1.Directive)('@privilege(category: "asset", privilege: "mutation", domainOwnerGranted: true)'),
83
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Take a document off its row - the file is kept, not deleted' }),
84
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
85
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
86
+ tslib_1.__metadata("design:type", Function),
87
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
88
+ tslib_1.__metadata("design:returntype", void 0)
89
+ ], AssetDocumentResolver.prototype, "removeAssetDocument", null);
90
+ exports.AssetDocumentResolver = AssetDocumentResolver = tslib_1.__decorate([
91
+ (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
92
+ (0, type_graphql_1.Resolver)()
93
+ ], AssetDocumentResolver);
94
+ //# sourceMappingURL=asset-document-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-document-resolver.js","sour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BAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,0BAAa,CAAC,CAAC,CAAA;IACrC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAIP;AAKD;IAHC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,gFAAgF,CAAC;IAC3F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC;IACxF,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAGhD;gCA1BU,qBAAqB;IAFjC,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,GAAE;GACE,qBAAqB,CA2BjC","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { getRepository, SpeakRefusals } from '@things-factory/shell'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Arg, Ctx, Directive, Field, Float, ID, Mutation, ObjectType, Query, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { assetDocuments, AssetDocumentOwner, attachAssetDocuments, removeAssetDocument } from './asset-document-service'\n\n@ObjectType({ description: 'A document of the asset register - a contract, a certificate, a report, a signed copy' })\nexport class AssetDocument {\n @Field(type => ID, { description: 'The attachment' }) id: string\n @Field({ description: 'The file name' }) name: string\n @Field({ nullable: true, description: 'The media type' }) mimetype?: string\n @Field(type => Float, { nullable: true, description: 'Size in bytes' }) size?: number\n @Field({ description: 'Where the file is served' }) fullpath: string\n @Field({ nullable: true, description: 'When it was attached' }) createdAt?: Date\n @Field({ nullable: true, description: 'Who attached it' }) creator?: string\n}\n\n@UseMiddleware(SpeakRefusals)\n@Resolver()\nexport class AssetDocumentResolver {\n @Directive('@privilege(category: \"asset\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [AssetDocument], { description: \"A row's documents, the latest first\" })\n assetDocuments(@Arg('owner', type => AssetDocumentOwner) owner: AssetDocumentOwner, @Arg('id') id: string, @Ctx() context: ResolverContext) {\n return assetDocuments(getRepository(Attachment).manager, context.state.domain, owner, id)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"asset\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [AssetDocument], { description: 'Attach files to a row - each kept beside the ones before' })\n attachAssetDocuments(\n @Arg('owner', type => AssetDocumentOwner) owner: AssetDocumentOwner,\n @Arg('id') id: string,\n @Arg('files', type => [GraphQLUpload]) files: FileUpload[],\n @Ctx() context: ResolverContext\n ) {\n const { domain, tx } = context.state\n return attachAssetDocuments(tx, domain, owner, id, files, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"asset\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'Take a document off its row - the file is kept, not deleted' })\n removeAssetDocument(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { domain, user, tx } = context.state\n return removeAssetDocument(tx, domain, user, id)\n }\n}\n"]}