terrier-engine 4.60.1 → 4.62.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.62.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.
@@ -81,6 +81,16 @@ export class PanelFragment extends ContentFragment {
81
81
  return this
82
82
  }
83
83
 
84
+ protected _customActions?: (parent: HtmlParentTag) => void
85
+
86
+ /**
87
+ * @param fun a function that renders custom content in between the primary and secondary actions
88
+ */
89
+ customActions(fun: (parent: HtmlParentTag) => void) {
90
+ this._customActions = fun
91
+ return this
92
+ }
93
+
84
94
  /**
85
95
  * Renders the panel into the given parent tag
86
96
  * @param parent
@@ -104,7 +114,7 @@ export class PanelFragment extends ContentFragment {
104
114
  this._content(content)
105
115
  }
106
116
  })
107
- panelActions(panel, this.actions, this.theme)
117
+ panelActions(panel, this.actions, this.theme, this._customActions)
108
118
  }).class(...this._classes)
109
119
  }
110
120
 
@@ -115,19 +125,34 @@ export class PanelFragment extends ContentFragment {
115
125
  * @param panel the .panel container
116
126
  * @param actions the actions
117
127
  * @param theme the theme with which to render actions
128
+ * @param customRender a custom function to render in between the primary and secondary actions
118
129
  */
119
- function panelActions(panel: PartTag, actions: PanelActions, theme: Theme) {
120
- if (actions.primary.length || actions.secondary.length) {
121
- panel.div('.panel-actions', actionsContainer => {
122
- for (const level of ['secondary', 'primary'] as const) {
123
- const levelActions = actions[level]
124
- if (!levelActions?.length) continue;
125
- actionsContainer.div(`.${level}-actions`, container => {
126
- theme.renderActions(container, levelActions, { defaultClass: level })
127
- })
128
- }
129
- })
130
- }
130
+ function panelActions(panel: PartTag, actions: PanelActions, theme: Theme, customRender?: (parent: HtmlParentTag) => void) {
131
+ if (!actions.primary.length && !actions.secondary.length && !customRender) return;
132
+ panel.div('.panel-actions', actionsContainer => {
133
+ // secondary actions
134
+ const secondaryActions = actions.secondary
135
+ if (secondaryActions.length) {
136
+ actionsContainer.div('.secondary-actions', container => {
137
+ theme.renderActions(container, secondaryActions, { defaultClass: 'secondary' })
138
+ })
139
+ }
140
+
141
+ // custom render
142
+ if (customRender) {
143
+ actionsContainer.div('.custom-actions', container => {
144
+ customRender(container)
145
+ })
146
+ }
147
+
148
+ // primary actions
149
+ const primaryActions = actions.primary
150
+ if (primaryActions.length) {
151
+ actionsContainer.div('.primary-actions', container => {
152
+ theme.renderActions(container, primaryActions, { defaultClass: 'primary' })
153
+ })
154
+ }
155
+ })
131
156
  }
132
157
 
133
158
 
package/terrier/theme.ts CHANGED
@@ -85,7 +85,7 @@ export default class Theme {
85
85
  }
86
86
 
87
87
  /**
88
- * Renders one ore more `Action`s into a parent tag.
88
+ * Renders one or more `Action`s into a parent tag.
89
89
  * @param parent the HTML element in which to render the action
90
90
  * @param actions the action or actions to render
91
91
  * @param options additional rendering options