@kernhq/module-inventory 0.2.0 → 0.4.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 (198) hide show
  1. package/README.md +106 -25
  2. package/dist/contract/capabilities.d.ts +4 -4
  3. package/dist/contract/capabilities.d.ts.map +1 -1
  4. package/dist/contract/capabilities.js +51 -9
  5. package/dist/contract/capabilities.js.map +1 -1
  6. package/dist/contract/events.d.ts +43 -0
  7. package/dist/contract/events.d.ts.map +1 -1
  8. package/dist/contract/events.js +40 -0
  9. package/dist/contract/events.js.map +1 -1
  10. package/dist/contract/index.d.ts +1 -0
  11. package/dist/contract/index.d.ts.map +1 -1
  12. package/dist/contract/index.js +1 -0
  13. package/dist/contract/index.js.map +1 -1
  14. package/dist/contract/models.d.ts +345 -0
  15. package/dist/contract/models.d.ts.map +1 -1
  16. package/dist/contract/models.js +245 -0
  17. package/dist/contract/models.js.map +1 -1
  18. package/dist/contract/notifications.d.ts +24 -0
  19. package/dist/contract/notifications.d.ts.map +1 -0
  20. package/dist/contract/notifications.js +72 -0
  21. package/dist/contract/notifications.js.map +1 -0
  22. package/dist/contract/permissions.d.ts +52 -2
  23. package/dist/contract/permissions.d.ts.map +1 -1
  24. package/dist/contract/permissions.js +55 -2
  25. package/dist/contract/permissions.js.map +1 -1
  26. package/dist/contract/router.d.ts +1108 -0
  27. package/dist/contract/router.d.ts.map +1 -1
  28. package/dist/contract/router.js +253 -1
  29. package/dist/contract/router.js.map +1 -1
  30. package/dist/contract/settings.d.ts +2 -0
  31. package/dist/contract/settings.d.ts.map +1 -1
  32. package/dist/contract/settings.js +24 -4
  33. package/dist/contract/settings.js.map +1 -1
  34. package/dist/server/index.d.ts +8 -4
  35. package/dist/server/index.d.ts.map +1 -1
  36. package/dist/server/index.js +289 -5
  37. package/dist/server/index.js.map +1 -1
  38. package/dist/server/jobs.d.ts +48 -0
  39. package/dist/server/jobs.d.ts.map +1 -0
  40. package/dist/server/jobs.js +358 -0
  41. package/dist/server/jobs.js.map +1 -0
  42. package/dist/server/router.d.ts +1392 -0
  43. package/dist/server/router.d.ts.map +1 -1
  44. package/dist/server/router.js +385 -7
  45. package/dist/server/router.js.map +1 -1
  46. package/dist/server/schema.d.ts +134 -1
  47. package/dist/server/schema.d.ts.map +1 -1
  48. package/dist/server/schema.js +169 -4
  49. package/dist/server/schema.js.map +1 -1
  50. package/dist/server/services/assets.d.ts +69 -3
  51. package/dist/server/services/assets.d.ts.map +1 -1
  52. package/dist/server/services/assets.js +199 -31
  53. package/dist/server/services/assets.js.map +1 -1
  54. package/dist/server/services/attachments.d.ts +80 -0
  55. package/dist/server/services/attachments.d.ts.map +1 -0
  56. package/dist/server/services/attachments.js +182 -0
  57. package/dist/server/services/attachments.js.map +1 -0
  58. package/dist/server/services/audience.d.ts +15 -0
  59. package/dist/server/services/audience.d.ts.map +1 -0
  60. package/dist/server/services/audience.js +64 -0
  61. package/dist/server/services/audience.js.map +1 -0
  62. package/dist/server/services/categories.d.ts +157 -0
  63. package/dist/server/services/categories.d.ts.map +1 -0
  64. package/dist/server/services/categories.js +309 -0
  65. package/dist/server/services/categories.js.map +1 -0
  66. package/dist/server/services/cursor.d.ts +68 -0
  67. package/dist/server/services/cursor.d.ts.map +1 -0
  68. package/dist/server/services/cursor.js +39 -0
  69. package/dist/server/services/cursor.js.map +1 -0
  70. package/dist/server/services/custody.d.ts +175 -0
  71. package/dist/server/services/custody.d.ts.map +1 -0
  72. package/dist/server/services/custody.js +367 -0
  73. package/dist/server/services/custody.js.map +1 -0
  74. package/dist/server/services/db-errors.d.ts +7 -0
  75. package/dist/server/services/db-errors.d.ts.map +1 -0
  76. package/dist/server/services/db-errors.js +32 -0
  77. package/dist/server/services/db-errors.js.map +1 -0
  78. package/dist/server/services/index.d.ts +16 -0
  79. package/dist/server/services/index.d.ts.map +1 -1
  80. package/dist/server/services/index.js +25 -1
  81. package/dist/server/services/index.js.map +1 -1
  82. package/dist/server/services/members.d.ts +27 -0
  83. package/dist/server/services/members.d.ts.map +1 -0
  84. package/dist/server/services/members.js +39 -0
  85. package/dist/server/services/members.js.map +1 -0
  86. package/dist/server/services/notify.d.ts +43 -1
  87. package/dist/server/services/notify.d.ts.map +1 -1
  88. package/dist/server/services/notify.js +47 -5
  89. package/dist/server/services/notify.js.map +1 -1
  90. package/dist/server/services/offboarding.d.ts +70 -0
  91. package/dist/server/services/offboarding.d.ts.map +1 -0
  92. package/dist/server/services/offboarding.js +116 -0
  93. package/dist/server/services/offboarding.js.map +1 -0
  94. package/dist/server/services/repairs.d.ts +204 -0
  95. package/dist/server/services/repairs.d.ts.map +1 -0
  96. package/dist/server/services/repairs.js +476 -0
  97. package/dist/server/services/repairs.js.map +1 -0
  98. package/dist/server/services/search.d.ts +85 -0
  99. package/dist/server/services/search.d.ts.map +1 -0
  100. package/dist/server/services/search.js +142 -0
  101. package/dist/server/services/search.js.map +1 -0
  102. package/dist/server/services/stats.d.ts +42 -0
  103. package/dist/server/services/stats.d.ts.map +1 -0
  104. package/dist/server/services/stats.js +80 -0
  105. package/dist/server/services/stats.js.map +1 -0
  106. package/dist/server/services/status.d.ts +102 -0
  107. package/dist/server/services/status.d.ts.map +1 -0
  108. package/dist/server/services/status.js +71 -0
  109. package/dist/server/services/status.js.map +1 -0
  110. package/migrations/0002_custody_and_categories.sql +23 -0
  111. package/migrations/0003_repairs.sql +23 -0
  112. package/migrations/0004_platform_surfaces.sql +51 -0
  113. package/migrations/0005_repair_dates.sql +35 -0
  114. package/migrations/0006_workspace_registry_read.sql +50 -0
  115. package/migrations/0007_history_sequence.sql +83 -0
  116. package/migrations/0008_category_order_unique.sql +71 -0
  117. package/migrations/meta/0002_snapshot.json +1054 -0
  118. package/migrations/meta/0003_snapshot.json +1070 -0
  119. package/migrations/meta/0004_snapshot.json +1130 -0
  120. package/migrations/meta/0005_snapshot.json +1135 -0
  121. package/migrations/meta/_journal.json +49 -0
  122. package/package.json +2 -1
  123. package/src/client/api-instance.ts +27 -2
  124. package/src/client/bidi.test.ts +148 -0
  125. package/src/client/bidi.ts +85 -0
  126. package/src/client/components/AssetDetailPanel.svelte +614 -0
  127. package/src/client/components/AssetFormDialog.svelte +71 -22
  128. package/src/client/components/AssetPhoto.svelte +178 -0
  129. package/src/client/components/AttachmentsSection.svelte +327 -0
  130. package/src/client/components/CustodyDialog.svelte +201 -0
  131. package/src/client/components/RepairDialog.svelte +271 -0
  132. package/src/client/components/RepairsSection.svelte +318 -0
  133. package/src/client/components/Timeline.svelte +347 -0
  134. package/src/client/components/TimelineText.svelte +124 -0
  135. package/src/client/core-api.ts +71 -0
  136. package/src/client/custody.test.ts +31 -0
  137. package/src/client/custody.ts +34 -0
  138. package/src/client/errors.test.ts +395 -0
  139. package/src/client/errors.ts +229 -0
  140. package/src/client/links.test.ts +74 -0
  141. package/src/client/links.ts +44 -0
  142. package/src/client/members.test.ts +132 -0
  143. package/src/client/members.ts +116 -0
  144. package/src/client/messages.test.ts +127 -0
  145. package/src/client/messages.ts +1106 -18
  146. package/src/client/mock.test.ts +465 -1
  147. package/src/client/mock.ts +1105 -79
  148. package/src/client/module.ts +73 -1
  149. package/src/client/pages/AssetsPage.svelte +317 -45
  150. package/src/client/permissions.ts +7 -0
  151. package/src/client/price.test.ts +151 -3
  152. package/src/client/price.ts +155 -11
  153. package/src/client/query.ts +36 -0
  154. package/src/client/reorder.test.ts +100 -0
  155. package/src/client/reorder.ts +79 -0
  156. package/src/client/repairs.test.ts +38 -0
  157. package/src/client/repairs.ts +38 -0
  158. package/src/client/sequence.test.ts +248 -0
  159. package/src/client/sequence.ts +185 -0
  160. package/src/client/settings/CategoriesSettings.svelte +746 -0
  161. package/src/client/settings/GeneralSettings.svelte +0 -0
  162. package/src/client/status.ts +29 -0
  163. package/src/client/timeline.test.ts +175 -0
  164. package/src/client/timeline.ts +206 -0
  165. package/src/client/widgets/OverviewWidget.svelte +127 -26
  166. package/src/client/widgets/RepairsWidget.svelte +124 -0
  167. package/src/contract/capabilities.ts +53 -9
  168. package/src/contract/events.ts +49 -0
  169. package/src/contract/index.ts +1 -0
  170. package/src/contract/models.ts +270 -0
  171. package/src/contract/notifications.ts +73 -0
  172. package/src/contract/permissions.ts +55 -2
  173. package/src/contract/router.ts +284 -1
  174. package/src/contract/settings.ts +24 -4
  175. package/src/module.test.ts +217 -4
  176. package/src/server/index.ts +311 -4
  177. package/src/server/inventory.int.test.ts +4109 -19
  178. package/src/server/jobs.ts +444 -0
  179. package/src/server/migrations.test.ts +253 -2
  180. package/src/server/router.ts +486 -6
  181. package/src/server/schema.ts +171 -3
  182. package/src/server/services/assets.ts +214 -54
  183. package/src/server/services/attachments.ts +215 -0
  184. package/src/server/services/audience.ts +77 -0
  185. package/src/server/services/categories.ts +337 -0
  186. package/src/server/services/cursor.ts +104 -0
  187. package/src/server/services/custody.ts +471 -0
  188. package/src/server/services/db-errors.ts +42 -0
  189. package/src/server/services/index.ts +34 -1
  190. package/src/server/services/members.ts +54 -0
  191. package/src/server/services/notify.ts +52 -7
  192. package/src/server/services/offboarding.ts +150 -0
  193. package/src/server/services/repairs.ts +567 -0
  194. package/src/server/services/search.ts +166 -0
  195. package/src/server/services/stats.ts +88 -0
  196. package/src/server/services/status.test.ts +34 -0
  197. package/src/server/services/status.ts +143 -0
  198. package/src/client/settings/core-api.ts +0 -32
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/contract/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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from './models.js';
3
+ import { Asset, AssetCreateInput, AssetHistoryEntry, AssetPatchInput, AssetSort, AssetStatus, Attachment, Category, CategoryInput, CustodyPeriod, CustodyResult, InventoryStats, MAX_LIVE_CATEGORIES, RepairInput, RepairListItem, RepairPatchInput, RepairResult, ws, } from './models.js';
4
4
  const t = ['inventory'];
5
+ /** A handover note is optional everywhere and shaped the same everywhere. */
6
+ const custodyNote = z.string().max(500).nullish();
5
7
  export const inventoryContract = {
6
8
  assets: {
7
9
  list: baseContract
@@ -37,6 +39,256 @@ export const inventoryContract = {
37
39
  .route({ method: 'POST', path: '/assets/{assetId}/archive', tags: t })
38
40
  .input(ws.extend({ assetId: z.uuid(), archived: z.boolean().default(true) }))
39
41
  .output(Asset),
42
+ /**
43
+ * The asset's own timeline, newest first.
44
+ *
45
+ * Paged with the same keyset discipline `assets.list` uses and the same cursor codec, because a
46
+ * second bookmark format is a second set of the three bugs the first one had. The bookmark is a
47
+ * row id; the ordering is by id, which for a uuidv7 is the clock and, unlike `created_at`, is
48
+ * unique — two entries written in one transaction (a create and its first custody row) share a
49
+ * timestamp and a page boundary between them would repeat or drop one.
50
+ *
51
+ * Reads on `inventory.asset.view`. See `permissions.ts` for why custody is not gated separately.
52
+ */
53
+ history: baseContract
54
+ .route({ method: 'GET', path: '/assets/{assetId}/history', tags: t })
55
+ .input(ws.extend({ assetId: z.uuid(), ...PageInput.shape }))
56
+ .output(page(AssetHistoryEntry)),
57
+ },
58
+ /**
59
+ * Who is holding what.
60
+ *
61
+ * Four verbs rather than one, because "hand it to somebody" and "hand it on to somebody else" are
62
+ * different questions with different failure modes: assigning something already out is a mistake
63
+ * worth refusing, and transferring something nobody holds is a different mistake. One procedure
64
+ * taking `userId | null` would answer both by silently doing whatever the row happened to allow.
65
+ */
66
+ custody: {
67
+ /** Hand a free item to a member. Refuses if somebody already has it — that is `transfer`. */
68
+ assign: baseContract
69
+ .route({ method: 'POST', path: '/assets/{assetId}/custody', tags: t })
70
+ .input(ws.extend({ assetId: z.uuid(), userId: z.uuid(), note: custodyNote }))
71
+ .output(CustodyResult),
72
+ /** Take it back. Closes the open period and puts the asset back in stock. */
73
+ return: baseContract
74
+ .route({ method: 'POST', path: '/assets/{assetId}/custody/return', tags: t })
75
+ .input(ws.extend({ assetId: z.uuid(), note: custodyNote }))
76
+ .output(CustodyResult),
77
+ /**
78
+ * Hand it straight on: one transaction, not a return followed by an assign.
79
+ *
80
+ * Two calls would leave the asset `in_stock` with no custodian in between — visible to anybody
81
+ * reading the list at that moment, and permanently visible in the timeline as a return that
82
+ * nobody performed.
83
+ */
84
+ transfer: baseContract
85
+ .route({ method: 'POST', path: '/assets/{assetId}/custody/transfer', tags: t })
86
+ .input(ws.extend({ assetId: z.uuid(), userId: z.uuid(), note: custodyNote }))
87
+ .output(CustodyResult),
88
+ /**
89
+ * Every period for one asset, newest first — "who had this laptop before me".
90
+ *
91
+ * An array rather than a page, like HR's `employment.history`: the rows are bounded by how many
92
+ * times one item changed hands, which is tens over its life. `limit` caps it rather than
93
+ * paging, so the answer is never unbounded and the caller never has a cursor to keep.
94
+ */
95
+ history: baseContract
96
+ .route({ method: 'GET', path: '/assets/{assetId}/custody', tags: t })
97
+ .input(ws.extend({ assetId: z.uuid(), limit: z.number().int().min(1).max(200).default(100) }))
98
+ .output(z.array(CustodyPeriod)),
99
+ /**
100
+ * What one person is holding right now.
101
+ *
102
+ * Answered from `assets.custodian_user_id` — denormalised inside the same transaction that
103
+ * writes the period, and indexed — rather than from an open-period join, so the offboarding
104
+ * question ("what does Ada still have?") is one indexed read.
105
+ */
106
+ byUser: baseContract
107
+ .route({ method: 'GET', path: '/custody/by-user/{userId}', tags: t })
108
+ .input(ws.extend({ userId: z.uuid(), ...PageInput.shape }))
109
+ .output(page(Asset)),
110
+ },
111
+ /**
112
+ * How a workspace groups what it owns.
113
+ *
114
+ * Not paged: a workspace has tens of categories, and every one of them has to be in the picker
115
+ * anyway. A cursor here would be a page boundary in a dropdown.
116
+ */
117
+ categories: {
118
+ list: baseContract
119
+ .route({ method: 'GET', path: '/categories', tags: t })
120
+ .input(ws.extend({ archived: z.boolean().default(false) }))
121
+ .output(z.array(Category)),
122
+ create: baseContract
123
+ .route({ method: 'POST', path: '/categories', tags: t })
124
+ .input(ws.extend(CategoryInput.shape))
125
+ .output(Category),
126
+ update: baseContract
127
+ .route({ method: 'PATCH', path: '/categories/{categoryId}', tags: t })
128
+ .input(ws.extend({ categoryId: z.uuid(), ...CategoryInput.partial().shape }))
129
+ .output(Category),
130
+ /**
131
+ * Archive, not delete — and the same procedure restores.
132
+ *
133
+ * `assets.category_id` carries no foreign key, so a delete would leave every asset filed under
134
+ * it pointing at nothing: a blank column, and a timeline entry that recorded the move losing
135
+ * the name it recorded. Archiving is reversible and destroys nothing.
136
+ */
137
+ archive: baseContract
138
+ .route({ method: 'POST', path: '/categories/{categoryId}/archive', tags: t })
139
+ .input(ws.extend({ categoryId: z.uuid(), archived: z.boolean().default(true) }))
140
+ .output(Category),
141
+ /**
142
+ * The whole sequence, in the order somebody put it in — the only thing that writes `order`.
143
+ *
144
+ * **The ids, not positions.** A position number is a database column with a form around it: two
145
+ * categories can hold the same one, nobody thinks about their filing as integers, and the screen
146
+ * that asked for one had to explain how ties break. A list of ids says exactly what the person
147
+ * did, whatever they did it with — a drag, or the move-up and move-down buttons beside it.
148
+ *
149
+ * **It must name every live category the workspace has, exactly once.** A partial list is not
150
+ * treated as "leave the rest alone": somebody added a category in another tab while this page
151
+ * was open, and the ordering in hand no longer describes the workspace. Renumbering what it does
152
+ * name would drop the new one somewhere nobody chose, silently — so the whole call is refused
153
+ * with `inventory.category.order_stale` and the page reloads and asks again. Naming an archived
154
+ * category is the same mistake from the other side and gets the same answer; an id from another
155
+ * workspace is `NOT_FOUND`, exactly as `update` and `archive` answer for one.
156
+ *
157
+ * Answers the live sequence as it now stands, so a caller needs no second read.
158
+ *
159
+ * **The bound is `MAX_LIVE_CATEGORIES`, and it is the same number `create` refuses at.** A bound
160
+ * on this array with nothing enforcing it elsewhere is a silent ceiling: a workspace could grow
161
+ * past it one category at a time and then find that the only procedure that can order them is
162
+ * the one it can no longer call. Held to the same number at the point of creation, the array can
163
+ * always name every live category a workspace is allowed to have.
164
+ */
165
+ reorder: baseContract
166
+ .route({ method: 'POST', path: '/categories/reorder', tags: t })
167
+ .input(ws.extend({ categoryIds: z.array(z.uuid()).min(1).max(MAX_LIVE_CATEGORIES) }))
168
+ .output(z.array(Category)),
169
+ },
170
+ /**
171
+ * What went away to be fixed.
172
+ *
173
+ * **Behind the `repairs` capability**, which is this module's first switchable one — so every
174
+ * procedure here answers **404** rather than 403 in a workspace that has it off. 403 would say
175
+ * "this exists and you may not have it", which is false for a company that does not record
176
+ * repairs, and it would contradict a panel that has already hidden the tab.
177
+ *
178
+ * Writing takes `inventory.repair.manage`; reading rides `inventory.asset.view`, for the reason
179
+ * custody does — "where is the projector" is the question the register exists to answer.
180
+ */
181
+ repairs: {
182
+ /**
183
+ * One asset's repairs, or the whole workspace's — the same procedure, because they are the same
184
+ * query with one filter and a second one would be a second thing to keep in step.
185
+ *
186
+ * `open: true` is the "what is away right now" question a dashboard card asks, and it is a
187
+ * filter rather than a procedure of its own for the same reason.
188
+ *
189
+ * Paged, unlike `custody.history`: one asset's repairs are bounded by how often it breaks, but
190
+ * a workspace's are not. Ordered newest-logged first, by row id — a uuidv7 already carries the
191
+ * clock and is unique, where `sent_on` is a date two repairs logged the same day share.
192
+ */
193
+ list: baseContract
194
+ .route({ method: 'GET', path: '/repairs', tags: t })
195
+ .input(ws.extend({
196
+ ...PageInput.shape,
197
+ assetId: z.uuid().optional(),
198
+ /** `true` for still away, `false` for finished, absent for both. */
199
+ open: z.boolean().optional(),
200
+ }))
201
+ .output(page(RepairListItem)),
202
+ /**
203
+ * Send it away. Refuses when the item is already at a repairer — one open repair per asset, and
204
+ * `inventory_repairs_one_open_uq` is what makes that true in the database rather than merely
205
+ * likely in the service.
206
+ *
207
+ * `sentOn` is optional and defaults to today **on the server**: a browser clock is not a fact
208
+ * this module is willing to record, and the same reasoning already keeps asset tags server-side.
209
+ */
210
+ create: baseContract
211
+ .route({ method: 'POST', path: '/assets/{assetId}/repairs', tags: t })
212
+ .input(ws.extend({ assetId: z.uuid(), ...RepairInput.shape }))
213
+ .output(RepairResult),
214
+ /**
215
+ * Correct what was recorded — a vendor, a cost that arrived with the invoice a week later.
216
+ *
217
+ * Deliberately cannot set `returnedOn`: that one column decides whether the asset reads as
218
+ * `under_repair`, so exactly one procedure moves it and the derived status has one door rather
219
+ * than two.
220
+ */
221
+ update: baseContract
222
+ .route({ method: 'PATCH', path: '/repairs/{repairId}', tags: t })
223
+ .input(ws.extend({ repairId: z.uuid(), ...RepairPatchInput.shape }))
224
+ .output(RepairResult),
225
+ /**
226
+ * It came back. Closes the repair and puts the asset back to `assigned` if somebody still holds
227
+ * it, or `in_stock` if nobody does — never blindly to `in_stock`, which would quietly release
228
+ * whoever is answerable for it.
229
+ *
230
+ * Takes the cost, because that is when the invoice usually arrives.
231
+ */
232
+ complete: baseContract
233
+ .route({ method: 'POST', path: '/repairs/{repairId}/complete', tags: t })
234
+ .input(ws.extend({
235
+ repairId: z.uuid(),
236
+ returnedOn: z.iso.date().optional(),
237
+ costMinor: z.number().int().min(0).nullish(),
238
+ currency: z.string().length(3).nullish(),
239
+ }))
240
+ .output(RepairResult),
241
+ },
242
+ /**
243
+ * Receipts, warranties, manuals — and the asset's photo, which is an `Asset` field rather than one
244
+ * of these.
245
+ *
246
+ * **Behind the `attachments` capability**, so these answer 404 in a workspace that has it off.
247
+ *
248
+ * **A module does not upload.** The browser sends the bytes to core's file service and hands this
249
+ * module the id core gave it; `add` records that this asset has that file. Nothing here streams,
250
+ * signs or stores anything, and `remove` detaches rather than deleting core's file — the same
251
+ * bytes may be attached elsewhere, and a module has no standing to destroy another module's row.
252
+ */
253
+ attachments: {
254
+ /**
255
+ * Every file on one asset, its repairs' included, each carrying its own `repairId`.
256
+ *
257
+ * Not paged and not filtered by repair: one asset's files are bounded and entirely loaded, so
258
+ * the panel groups them in the browser. That is the one case where filtering client-side is
259
+ * right, and it is the opposite of what `assets.list` may do.
260
+ */
261
+ list: baseContract
262
+ .route({ method: 'GET', path: '/assets/{assetId}/attachments', tags: t })
263
+ .input(ws.extend({ assetId: z.uuid() }))
264
+ .output(z.array(Attachment)),
265
+ /** Attach files core already holds. `repairId` files them under one repair instead of the asset. */
266
+ add: baseContract
267
+ .route({ method: 'POST', path: '/assets/{assetId}/attachments', tags: t })
268
+ .input(ws.extend({
269
+ assetId: z.uuid(),
270
+ fileIds: z.array(z.uuid()).min(1).max(20),
271
+ repairId: z.uuid().nullish(),
272
+ }))
273
+ .output(z.array(Attachment)),
274
+ /** Answers with the id it detached, so a client can drop exactly that row without re-reading. */
275
+ remove: baseContract
276
+ .route({ method: 'DELETE', path: '/attachments/{attachmentId}', tags: t })
277
+ .input(ws.extend({ attachmentId: z.uuid() }))
278
+ .output(z.object({ id: z.uuid() })),
279
+ },
280
+ /**
281
+ * The register in numbers.
282
+ *
283
+ * One procedure rather than a `total` on `assets.list`, because they answer different questions:
284
+ * a list's total describes the filter you asked for, and this describes the workspace. The assets
285
+ * page needs both — "showing 50 of 214" is two numbers from two places.
286
+ *
287
+ * Not behind a capability: it counts assets, which is `core`. `outForRepair` comes back null
288
+ * rather than 0 where `repairs` is off — see `InventoryStats`.
289
+ */
290
+ stats: {
291
+ summary: baseContract.route({ method: 'GET', path: '/stats', tags: t }).input(ws).output(InventoryStats),
40
292
  },
41
293
  };
42
294
  //# sourceMappingURL=router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/contract/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW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G;IACH,KAAK,EAAE;QACL,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;KACzG;CACF,CAAA"}
@@ -13,6 +13,8 @@ import { z } from 'zod';
13
13
  export declare const InventorySettings: z.ZodObject<{
14
14
  assetCodePrefix: z.ZodDefault<z.ZodString>;
15
15
  assetCodePad: z.ZodDefault<z.ZodNumber>;
16
+ warrantyNoticeDays: z.ZodDefault<z.ZodNumber>;
17
+ repairOverdueDays: z.ZodDefault<z.ZodNumber>;
16
18
  }, z.core.$strip>;
17
19
  export type InventorySettings = z.infer<typeof InventorySettings>;
18
20
  //# sourceMappingURL=settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/contract/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;;;iBAe5B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/contract/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;;;;;iBAmC5B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -21,9 +21,29 @@ export const InventorySettings = z.object({
21
21
  */
22
22
  assetCodePrefix: z.string().max(8).default('INV-'),
23
23
  assetCodePad: z.number().int().min(1).max(10).default(4),
24
- // `warrantyNoticeDays` used to sit here, describing a warranty sweep that has never existed —
25
- // no job, no subscription, nothing reading the number. A setting nothing enforces is the same
26
- // lie as a capability nothing checks: it teaches an administrator that the settings page does
27
- // not mean anything. It comes back with the sweep.
24
+ /**
25
+ * How far ahead of a warranty running out somebody is told.
26
+ *
27
+ * This spent a release describing a sweep that did not exist no job, no subscription, nothing
28
+ * reading the number — and was taken out for it. It is back because `warranty-sweep` reads it
29
+ * every morning: a live asset whose `warranty_until` falls inside this many days earns exactly
30
+ * one notice, marked on the row so the next morning does not send it again.
31
+ *
32
+ * A month by default, which is about how long it takes to decide whether to extend a warranty or
33
+ * budget for a replacement. Capped at a year: further out than that is not a notice, it is a
34
+ * report.
35
+ */
36
+ warrantyNoticeDays: z.number().int().min(1).max(365).default(30),
37
+ /**
38
+ * How long an item may be at a repairer before somebody is asked to chase it.
39
+ *
40
+ * Read by `repair-overdue`, which tells the person who logged the repair — and whoever is still
41
+ * holding the item — once, and then leaves them alone. Two weeks by default: long enough that an
42
+ * ordinary screen replacement never trips it, short enough that a laptop nobody chased does.
43
+ *
44
+ * A workspace with the `repairs` capability off never meets this: the sweep asks first, and a
45
+ * setting whose feature is switched off changes nothing rather than firing quietly.
46
+ */
47
+ repairOverdueDays: z.number().int().min(1).max(365).default(14),
28
48
  });
29
49
  //# sourceMappingURL=settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/contract/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAClD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,8FAA8F;IAC9F,8FAA8F;IAC9F,8FAA8F;IAC9F,mDAAmD;CACpD,CAAC,CAAA"}
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/contract/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAClD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD;;;;;;;;;;;OAWG;IACH,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAChE;;;;;;;;;OASG;IACH,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAChE,CAAC,CAAA"}
@@ -1,6 +1,10 @@
1
- export declare const inventoryModule: import("@kernhq/kernel").ServerModule<import("zod").ZodObject<{
2
- assetCodePrefix: import("zod").ZodDefault<import("zod").ZodString>;
3
- assetCodePad: import("zod").ZodDefault<import("zod").ZodNumber>;
4
- }, import("zod/v4/core").$strip>>;
1
+ import { z } from 'zod';
2
+ export declare const inventoryModule: import("@kernhq/kernel").ServerModule<z.ZodObject<{
3
+ assetCodePrefix: z.ZodDefault<z.ZodString>;
4
+ assetCodePad: z.ZodDefault<z.ZodNumber>;
5
+ warrantyNoticeDays: z.ZodDefault<z.ZodNumber>;
6
+ repairOverdueDays: z.ZodDefault<z.ZodNumber>;
7
+ }, z.core.$strip>>;
5
8
  export default inventoryModule;
9
+ export type InventoryModule = typeof inventoryModule;
6
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe;;;iCAqB1B,CAAA;AACF,eAAe,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA8CvB,eAAO,MAAM,eAAe;;;;;kBAiR1B,CAAA;AAgBF,eAAe,eAAe,CAAA;AAC9B,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAA"}