terrier-engine 4.60.1 → 4.61.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.
@@ -198,7 +198,7 @@ async function getDistributions(dive: DdDive): Promise<DdDiveDistribution[]> {
198
198
  */
199
199
  async function softDeleteDistribution(dist: DdDiveDistribution) {
200
200
  dist._state = 2
201
- return await Db().update('dd_dive_distribution', dist)
201
+ return await Db().partialUpdate('dd_dive_distribution', dist.id, {_state: 2})
202
202
  }
203
203
 
204
204
 
@@ -1,4 +1,4 @@
1
- // This file was automatically generated on 2025-04-25 14:11:58 -0500, DO NOT EDIT IT MANUALLY!
1
+ // This file was automatically generated on 2025-10-29 09:38:49 -0500, DO NOT EDIT IT MANUALLY!
2
2
 
3
3
  import { Query } from "../queries/queries"
4
4
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.60.1",
7
+ "version": "4.61.0",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -11,7 +11,13 @@ log.level = 'debug'
11
11
  */
12
12
  type ModelTypeMap = {
13
13
  [name: string]: any
14
- }
14
+ };
15
+
16
+ /**
17
+ * A version of a record where all fields are optional and can be null, while preserving the key set.
18
+ * Includes an optional `id` for convenience with upserts/updates.
19
+ */
20
+ type PartialRecord<T> = { [K in keyof T]?: T[K] | null } & { id?: string }
15
21
 
16
22
  type ModelIncludesMap<M extends ModelTypeMap> = Record<keyof M, any>
17
23
 
@@ -246,6 +252,21 @@ export default class DbClient<PM extends ModelTypeMap, UM extends ModelTypeMap,
246
252
  return await Api.post<DbUpsertResponse<PM,T>>(url, body)
247
253
  }
248
254
 
255
+ /**
256
+ * Updates the given record without requiring the entire record.
257
+ * @param modelType the camel_case name of the model
258
+ * @param id the id of the record
259
+ * @param record the record to update
260
+ * @param includes relations to include in the returned record
261
+ */
262
+ async partialUpdate<T extends keyof PM & string>(modelType: T, id: string, record: PartialRecord<UM[T]>, includes: Includes<PM,T,I> = {}): Promise<DbUpsertResponse<PM,T> & ApiResponse> {
263
+ const url = `/db/model/${modelType}/upsert.json`
264
+ record.id = id
265
+ const body = {record, includes}
266
+ log.debug(`Partially updating ${modelType} ${id} at ${url} with body`, body)
267
+ return await Api.post<DbUpsertResponse<PM,T>>(url, body)
268
+ }
269
+
249
270
  /**
250
271
  * Update the given record and assume it will succeed.
251
272
  * This call should be wrapped in a try/catch.