@deephaven-enterprise/query-utils 1.20240723.195-beta → 1.20250219.122-beta

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.
@@ -1,8 +1,11 @@
1
- import type { EditableQueryInfo, TypeSpecificFields } from '@deephaven-enterprise/jsapi-types';
1
+ import type { EditableQueryInfo, PlainEditableQueryInfo, TypeSpecificFields } from '@deephaven-enterprise/jsapi-types';
2
2
  import QueryScheduler from './QueryScheduler';
3
3
  export type ScriptDraftQuery = IDraftQuery & {
4
4
  scriptLanguage: string;
5
5
  };
6
+ export interface DefaultDraftQuery extends Omit<DraftQuery, 'id' | 'defaults'> {
7
+ id?: string;
8
+ }
6
9
  /**
7
10
  * TypeScript `type` aliases have implicit index signatures, but `interface`
8
11
  * types do not. It is important that all of the types composed into `IDraftQuery`
@@ -10,11 +13,13 @@ export type ScriptDraftQuery = IDraftQuery & {
10
13
  * it causes issues upstream where `Record<string, unknown>` generics are expected.
11
14
  * e.g. `WorkspaceStorageItem<IDraftQuery>`
12
15
  */
13
- export type IDraftQuery = EditableQueryInfo & {
16
+ export type IDraftQuery = PlainEditableQueryInfo & {
14
17
  isClientSide: boolean;
15
18
  draftOwner: string;
16
19
  initializationThreads?: string;
17
20
  updateThreads?: string;
21
+ defaults?: DefaultDraftQuery;
22
+ isModified: boolean;
18
23
  };
19
24
  export type DraftQueryConstructorObject = Partial<IDraftQuery> & Pick<IDraftQuery, 'name' | 'owner' | 'draftOwner' | 'dbServerName' | 'initializationThreads' | 'updateThreads'>;
20
25
  /**
@@ -62,6 +67,7 @@ export declare class DraftQuery implements IDraftQuery {
62
67
  readonly ASSIGNMENT_POLICY_PARAMS: "assignmentPolicyParams";
63
68
  readonly INITIALIZATION_THREADS: "initializationThreads";
64
69
  readonly UPDATE_THREADS: "updateThreads";
70
+ readonly DEFAULTS: "defaults";
65
71
  }>;
66
72
  /**
67
73
  * Checks if a serial id from the server is actually a draft id
@@ -75,7 +81,7 @@ export declare class DraftQuery implements IDraftQuery {
75
81
  * @param serial a serial that contains a draft id
76
82
  */
77
83
  static serialToDraftId(serial: string): string;
78
- constructor({ isClientSide, draftOwner, serial, name, owner, type, enabled, enableGcLogs, envVars, heapSize, additionalMemory, dataMemoryRatio, jvmArgs, extraClasspaths, jvmProfile, dbServerName, scriptLanguage, scriptPath, scriptCode, scheduling, adminGroups, viewerGroups, restartUsers, timeout, workerKind, kubernetesControl, pythonControl, genericWorkerControl, typeSpecificFields, replicaCount, spareCount, assignmentPolicy, assignmentPolicyParams, initializationThreads, updateThreads, }: DraftQueryConstructorObject);
84
+ constructor({ isModified, isClientSide, draftOwner, serial, name, owner, type, enabled, enableGcLogs, envVars, heapSize, additionalMemory, dataMemoryRatio, jvmArgs, extraClasspaths, jvmProfile, dbServerName, scriptLanguage, scriptPath, scriptCode, scheduling, adminGroups, viewerGroups, restartUsers, timeout, workerKind, kubernetesControl, pythonControl, genericWorkerControl, typeSpecificFields, replicaCount, spareCount, assignmentPolicy, assignmentPolicyParams, initializationThreads, updateThreads, defaults, }: DraftQueryConstructorObject);
79
85
  id: string;
80
86
  isModified: boolean;
81
87
  isClientSide: boolean;
@@ -96,23 +102,23 @@ export declare class DraftQuery implements IDraftQuery {
96
102
  dbServerName: string;
97
103
  scriptLanguage: string | null;
98
104
  scriptPath: string | null;
99
- scriptCode: string;
105
+ scriptCode: string | null;
100
106
  scheduling: readonly string[];
101
107
  adminGroups: readonly string[];
102
108
  viewerGroups: readonly string[];
103
109
  restartUsers: number;
104
110
  timeout: number;
105
111
  scheduler: QueryScheduler;
106
- kubernetesControl?: string | null;
107
- pythonControl?: string | null;
108
- genericWorkerControl?: string | null;
112
+ kubernetesControl: string | null;
113
+ pythonControl: string | null;
114
+ genericWorkerControl: string | null;
109
115
  /**
110
116
  * Should be the name (not title) of the workerKind
111
117
  * The server gives null if it should be the default
112
118
  * Not sure if the value will be set if the PQ is from pre-vermilion and the customer upgrades
113
119
  * Treat both null and undefined as server default (not necessarily 1st option in the UI)
114
120
  */
115
- workerKind: string | null | undefined;
121
+ workerKind: string | null;
116
122
  typeSpecificFields: TypeSpecificFields | null;
117
123
  replicaCount: number;
118
124
  spareCount: number;
@@ -126,6 +132,7 @@ export declare class DraftQuery implements IDraftQuery {
126
132
  */
127
133
  initializationThreads: string;
128
134
  updateThreads: string;
135
+ defaults?: DefaultDraftQuery;
129
136
  updateSchedule(): void;
130
137
  /**
131
138
  * Creates a deep copy of this draft query.
@@ -139,7 +146,7 @@ export declare class DraftQuery implements IDraftQuery {
139
146
  *
140
147
  * @param editableQuery the Editable Query from the Server
141
148
  */
142
- saveDraftToQuery(editableQuery: Partial<EditableQueryInfo>): void;
149
+ saveDraftToQuery<T extends EditableQueryInfo>(editableQuery: Partial<T> & Pick<T, 'serial'>): T;
143
150
  /**
144
151
  * Updates the JVM args to include the thread count for initialization and update threads.
145
152
  * It is safe to call from saveDraftToQuery because the the thead counts will be set to
@@ -148,9 +155,10 @@ export declare class DraftQuery implements IDraftQuery {
148
155
  * manually in that case.
149
156
  */
150
157
  addThreadCountToJVMArgs(): void;
151
- toEditableQueryInfo(): {
152
- serial: string | null;
153
- };
158
+ /**
159
+ * Get a PlainEditableQueryInfo object populated from this DraftQuery
160
+ */
161
+ toEditableQueryInfo(): PlainEditableQueryInfo;
154
162
  toRowMap(queryTypes: Map<string, string>): Map<string, string>;
155
163
  formatIdForSerialColumn(): string;
156
164
  }
@@ -26,11 +26,11 @@ export class DraftQuery {
26
26
  // Remove the 'Draft ID: ' marking
27
27
  return serial === null || serial === void 0 ? void 0 : serial.substring(DRAFT_SERIAL_PREFIX.length);
28
28
  }
29
- constructor({ isClientSide = false, draftOwner, serial = DraftQuery.NO_SERIAL, name, owner, type = QueryType.SCRIPT, enabled = true, enableGcLogs = true, envVars = '', heapSize = 4.0, additionalMemory = 0.0, dataMemoryRatio = 0.25, jvmArgs = '', extraClasspaths = '', jvmProfile = 'Default', dbServerName, scriptLanguage = 'Groovy', scriptPath = null, scriptCode = '', scheduling, adminGroups = [], viewerGroups = [], restartUsers = DraftQuery.RESTART_MODE.ADMIN, timeout = 0, workerKind, kubernetesControl, pythonControl, genericWorkerControl, typeSpecificFields = null, replicaCount = 1, spareCount = 0, assignmentPolicy = null, assignmentPolicyParams = null, initializationThreads = undefined, updateThreads = undefined, }) {
29
+ constructor({ isModified = false, isClientSide = false, draftOwner, serial = DraftQuery.NO_SERIAL, name, owner, type = QueryType.SCRIPT, enabled = true, enableGcLogs = true, envVars = '', heapSize = 4.0, additionalMemory = 0.0, dataMemoryRatio = 0.25, jvmArgs = '', extraClasspaths = '', jvmProfile = 'Default', dbServerName, scriptLanguage = 'Groovy', scriptPath = null, scriptCode = '', scheduling, adminGroups = [], viewerGroups = [], restartUsers = DraftQuery.RESTART_MODE.ADMIN, timeout = 0, workerKind = null, kubernetesControl = null, pythonControl = null, genericWorkerControl = null, typeSpecificFields = null, replicaCount = 1, spareCount = 0, assignmentPolicy = null, assignmentPolicyParams = null, initializationThreads = undefined, updateThreads = undefined, defaults = undefined, }) {
30
30
  this.scheduling = [];
31
31
  // Meta Data
32
32
  this.id = shortid.generate();
33
- this.isModified = false;
33
+ this.isModified = isModified;
34
34
  this.isClientSide = isClientSide;
35
35
  this.draftOwner = draftOwner;
36
36
  // Query Data
@@ -76,6 +76,9 @@ export class DraftQuery {
76
76
  this.scheduling = [];
77
77
  this.scheduler = new QueryScheduler(scheduling);
78
78
  this.typeSpecificFields = typeSpecificFields;
79
+ // A new draft should have null / undefined defaults
80
+ // A copy should have defaults that need to be instantiated as a new DraftQuery
81
+ this.defaults = defaults == null ? undefined : new DraftQuery(defaults);
79
82
  }
80
83
  updateSchedule() {
81
84
  if (this.scheduler != null) {
@@ -105,38 +108,43 @@ export class DraftQuery {
105
108
  * @param editableQuery the Editable Query from the Server
106
109
  */
107
110
  saveDraftToQuery(editableQuery) {
108
- var _a, _b;
109
111
  this.addThreadCountToJVMArgs();
110
- editableQuery.name = this.name;
111
- editableQuery.owner = this.owner;
112
- editableQuery.type = this.type;
113
- editableQuery.enabled = this.enabled;
114
- editableQuery.enableGcLogs = this.enableGcLogs;
115
- editableQuery.envVars = this.envVars;
116
- editableQuery.heapSize = this.heapSize;
117
- editableQuery.dataMemoryRatio = this.dataMemoryRatio;
118
- editableQuery.additionalMemory = this.additionalMemory;
119
- editableQuery.jvmArgs = this.jvmArgs;
120
- editableQuery.extraClasspaths = this.extraClasspaths;
121
- editableQuery.jvmProfile = this.jvmProfile;
122
- editableQuery.dbServerName = this.dbServerName;
123
- editableQuery.scriptLanguage = this.scriptLanguage;
124
- editableQuery.scriptPath = (_a = this.scriptPath) !== null && _a !== void 0 ? _a : undefined;
125
- editableQuery.scriptCode = this.scriptCode;
126
- editableQuery.scheduling = this.scheduler.toStringArray();
127
- editableQuery.adminGroups = this.adminGroups;
128
- editableQuery.viewerGroups = this.viewerGroups;
129
- editableQuery.restartUsers = this.restartUsers;
130
- editableQuery.timeout = this.timeout;
131
- editableQuery.workerKind = (_b = this.workerKind) !== null && _b !== void 0 ? _b : undefined;
132
- editableQuery.kubernetesControl = this.kubernetesControl;
133
- editableQuery.pythonControl = this.pythonControl;
134
- editableQuery.genericWorkerControl = this.genericWorkerControl;
135
- editableQuery.typeSpecificFields = this.typeSpecificFields;
136
- editableQuery.replicaCount = this.replicaCount;
137
- editableQuery.spareCount = this.spareCount;
138
- editableQuery.assignmentPolicy = this.assignmentPolicy;
139
- editableQuery.assignmentPolicyParams = this.assignmentPolicyParams;
112
+ // Type check to make sure none of the required fields are missing
113
+ const completeQuery = {
114
+ serial: editableQuery.serial,
115
+ name: this.name,
116
+ owner: this.owner,
117
+ type: this.type,
118
+ enabled: this.enabled,
119
+ enableGcLogs: this.enableGcLogs,
120
+ envVars: this.envVars,
121
+ heapSize: this.heapSize,
122
+ dataMemoryRatio: this.dataMemoryRatio,
123
+ additionalMemory: this.additionalMemory,
124
+ jvmArgs: this.jvmArgs,
125
+ extraClasspaths: this.extraClasspaths,
126
+ jvmProfile: this.jvmProfile,
127
+ dbServerName: this.dbServerName,
128
+ scriptLanguage: this.scriptLanguage,
129
+ scriptPath: this.scriptPath,
130
+ scriptCode: this.scriptCode,
131
+ scheduling: this.scheduler.toStringArray(),
132
+ adminGroups: [...this.adminGroups],
133
+ viewerGroups: this.viewerGroups,
134
+ restartUsers: this.restartUsers,
135
+ timeout: this.timeout,
136
+ workerKind: this.workerKind,
137
+ kubernetesControl: this.kubernetesControl,
138
+ pythonControl: this.pythonControl,
139
+ genericWorkerControl: this.genericWorkerControl,
140
+ typeSpecificFields: this.typeSpecificFields,
141
+ replicaCount: this.replicaCount,
142
+ spareCount: this.spareCount,
143
+ assignmentPolicy: this.assignmentPolicy,
144
+ assignmentPolicyParams: this.assignmentPolicyParams,
145
+ };
146
+ Object.assign(editableQuery, completeQuery);
147
+ return editableQuery;
140
148
  }
141
149
  /**
142
150
  * Updates the JVM args to include the thread count for initialization and update threads.
@@ -149,10 +157,11 @@ export class DraftQuery {
149
157
  const { initializationThreads, updateThreads } = this;
150
158
  this.jvmArgs = WorkerThreadUtils.addArgs(this.jvmArgs, initializationThreads, updateThreads);
151
159
  }
160
+ /**
161
+ * Get a PlainEditableQueryInfo object populated from this DraftQuery
162
+ */
152
163
  toEditableQueryInfo() {
153
- const editableQuery = { serial: this.serial };
154
- this.saveDraftToQuery(editableQuery);
155
- return editableQuery;
164
+ return this.saveDraftToQuery({ serial: this.serial });
156
165
  }
157
166
  toRowMap(queryTypes) {
158
167
  var _a, _b, _c, _d, _e, _f;
@@ -226,5 +235,6 @@ DraftQuery.FIELDS = Object.freeze({
226
235
  ASSIGNMENT_POLICY_PARAMS: `assignmentPolicyParams`,
227
236
  INITIALIZATION_THREADS: 'initializationThreads',
228
237
  UPDATE_THREADS: 'updateThreads',
238
+ DEFAULTS: 'defaults',
229
239
  });
230
240
  export default DraftQuery;
@@ -324,12 +324,12 @@ QueryColumns.ASSIGNMENT_POLICY_PARAMS = {
324
324
  type: NewTableColumnTypes.STRING,
325
325
  };
326
326
  QueryColumns.ID = {
327
- name: '_Id_',
327
+ name: 'ID',
328
328
  displayName: 'Id',
329
329
  type: NewTableColumnTypes.STRING,
330
330
  };
331
331
  QueryColumns.PARENT_ID = {
332
- name: '_Parent_',
332
+ name: 'Parent',
333
333
  displayName: 'Parent Id',
334
334
  type: NewTableColumnTypes.STRING,
335
335
  };
@@ -55,7 +55,8 @@ export class QuerySchedulerValidation {
55
55
  return null;
56
56
  }
57
57
  const firstKey = errorMap.keys().next().value;
58
- if (firstKey === QueryScheduler.FIELDS.MONTHS ||
58
+ if (firstKey == null ||
59
+ firstKey === QueryScheduler.FIELDS.MONTHS ||
59
60
  firstKey === QueryScheduler.FIELDS.SCHEDULING_DISABLED) {
60
61
  return null;
61
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven-enterprise/query-utils",
3
- "version": "1.20240723.195-beta",
3
+ "version": "1.20250219.122-beta",
4
4
  "description": "Deephaven Enterprise Query Utils",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -28,6 +28,5 @@
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"
31
- },
32
- "gitHead": "d8caef87e74b302b4c767f79c1b8835c7cd42bca"
31
+ }
33
32
  }