windmill-utils-internal 1.1.0 → 1.2.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.
@@ -1108,6 +1108,8 @@ export declare const getVariable: (data: GetVariableData) => CancelablePromise<G
1108
1108
  * @param data The data for the request.
1109
1109
  * @param data.workspace
1110
1110
  * @param data.path
1111
+ * @param data.allowCache allow getting a cached value for improved performance
1112
+ *
1111
1113
  * @returns string variable
1112
1114
  * @throws ApiError
1113
1115
  */
@@ -1363,6 +1365,7 @@ export declare const getResource: (data: GetResourceData) => CancelablePromise<G
1363
1365
  * @param data.workspace
1364
1366
  * @param data.path
1365
1367
  * @param data.jobId job id
1368
+ * @param data.allowCache allow getting a cached value for improved performance
1366
1369
  * @returns unknown resource value
1367
1370
  * @throws ApiError
1368
1371
  */
@@ -2360,6 +2360,8 @@ exports.getVariable = getVariable;
2360
2360
  * @param data The data for the request.
2361
2361
  * @param data.workspace
2362
2362
  * @param data.path
2363
+ * @param data.allowCache allow getting a cached value for improved performance
2364
+ *
2363
2365
  * @returns string variable
2364
2366
  * @throws ApiError
2365
2367
  */
@@ -2370,6 +2372,9 @@ const getVariableValue = (data) => {
2370
2372
  path: {
2371
2373
  workspace: data.workspace,
2372
2374
  path: data.path
2375
+ },
2376
+ query: {
2377
+ allow_cache: data.allowCache
2373
2378
  }
2374
2379
  });
2375
2380
  };
@@ -2907,6 +2912,7 @@ exports.getResource = getResource;
2907
2912
  * @param data.workspace
2908
2913
  * @param data.path
2909
2914
  * @param data.jobId job id
2915
+ * @param data.allowCache allow getting a cached value for improved performance
2910
2916
  * @returns unknown resource value
2911
2917
  * @throws ApiError
2912
2918
  */
@@ -2919,7 +2925,8 @@ const getResourceValueInterpolated = (data) => {
2919
2925
  path: data.path
2920
2926
  },
2921
2927
  query: {
2922
- job_id: data.jobId
2928
+ job_id: data.jobId,
2929
+ allow_cache: data.allowCache
2923
2930
  }
2924
2931
  });
2925
2932
  };
@@ -30,6 +30,9 @@ export type Retry = {
30
30
  seconds?: number;
31
31
  random_factor?: number;
32
32
  };
33
+ retry_if?: {
34
+ expr: string;
35
+ };
33
36
  };
34
37
  export type StopAfterIf = {
35
38
  skip_if_stopped?: boolean;
@@ -3283,6 +3286,11 @@ export type GetVariableData = {
3283
3286
  };
3284
3287
  export type GetVariableResponse = (ListableVariable);
3285
3288
  export type GetVariableValueData = {
3289
+ /**
3290
+ * allow getting a cached value for improved performance
3291
+ *
3292
+ */
3293
+ allowCache?: boolean;
3286
3294
  path: string;
3287
3295
  workspace: string;
3288
3296
  };
@@ -3563,6 +3571,10 @@ export type GetResourceData = {
3563
3571
  };
3564
3572
  export type GetResourceResponse = (Resource);
3565
3573
  export type GetResourceValueInterpolatedData = {
3574
+ /**
3575
+ * allow getting a cached value for improved performance
3576
+ */
3577
+ allowCache?: boolean;
3566
3578
  /**
3567
3579
  * job id
3568
3580
  */
@@ -11,11 +11,11 @@ export interface SchemaProperty {
11
11
  pattern?: string;
12
12
  default?: any;
13
13
  enum?: EnumType;
14
- contentEncoding?: 'base64' | 'binary';
14
+ contentEncoding?: "base64" | "binary";
15
15
  format?: string;
16
16
  items?: {
17
- type?: 'string' | 'number' | 'bytes' | 'object' | 'resource';
18
- contentEncoding?: 'base64';
17
+ type?: "string" | "number" | "bytes" | "object" | "resource";
18
+ contentEncoding?: "base64";
19
19
  enum?: string[];
20
20
  resourceType?: string;
21
21
  properties?: {
@@ -42,54 +42,3 @@ export interface SchemaProperty {
42
42
  oneOf?: SchemaProperty[];
43
43
  originalType?: string;
44
44
  }
45
- /**
46
- * Converts argument signature types to JSON schema properties.
47
- * This function handles various Windmill-specific types and converts them
48
- * to standard JSON schema format while preserving existing property metadata.
49
- *
50
- * @param t - The argument signature type definition (can be string or complex object types)
51
- * @param oldS - Existing schema property to update with new type information
52
- */
53
- export declare function argSigToJsonSchemaType(t: string | {
54
- resource: string | null;
55
- } | {
56
- list: (string | {
57
- name?: string;
58
- props?: {
59
- key: string;
60
- typ: any;
61
- }[];
62
- }) | {
63
- str: any;
64
- } | {
65
- object: {
66
- name?: string;
67
- props?: {
68
- key: string;
69
- typ: any;
70
- }[];
71
- };
72
- } | null;
73
- } | {
74
- dynselect: string;
75
- } | {
76
- dynmultiselect: string;
77
- } | {
78
- str: string[] | null;
79
- } | {
80
- object: {
81
- name?: string;
82
- props?: {
83
- key: string;
84
- typ: any;
85
- }[];
86
- };
87
- } | {
88
- oneof: {
89
- label: string;
90
- properties: {
91
- key: string;
92
- typ: any;
93
- }[];
94
- }[];
95
- }, oldS: SchemaProperty): void;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.argSigToJsonSchemaType = argSigToJsonSchemaType;
4
3
  /**
5
4
  * Converts argument signature types to JSON schema properties.
6
5
  * This function handles various Windmill-specific types and converts them
@@ -10,39 +9,39 @@ exports.argSigToJsonSchemaType = argSigToJsonSchemaType;
10
9
  * @param oldS - Existing schema property to update with new type information
11
10
  */
12
11
  function argSigToJsonSchemaType(t, oldS) {
13
- const newS = { type: '' };
14
- if (t === 'int') {
15
- newS.type = 'integer';
12
+ const newS = { type: "" };
13
+ if (t === "int") {
14
+ newS.type = "integer";
16
15
  }
17
- else if (t === 'float') {
18
- newS.type = 'number';
16
+ else if (t === "float") {
17
+ newS.type = "number";
19
18
  }
20
- else if (t === 'bool') {
21
- newS.type = 'boolean';
19
+ else if (t === "bool") {
20
+ newS.type = "boolean";
22
21
  }
23
- else if (t === 'email') {
24
- newS.type = 'string';
25
- newS.format = 'email';
22
+ else if (t === "email") {
23
+ newS.type = "string";
24
+ newS.format = "email";
26
25
  }
27
- else if (t === 'sql') {
28
- newS.type = 'string';
29
- newS.format = 'sql';
26
+ else if (t === "sql") {
27
+ newS.type = "string";
28
+ newS.format = "sql";
30
29
  }
31
- else if (t === 'yaml') {
32
- newS.type = 'string';
33
- newS.format = 'yaml';
30
+ else if (t === "yaml") {
31
+ newS.type = "string";
32
+ newS.format = "yaml";
34
33
  }
35
- else if (t === 'bytes') {
36
- newS.type = 'string';
37
- newS.contentEncoding = 'base64';
38
- newS.originalType = 'bytes';
34
+ else if (t === "bytes") {
35
+ newS.type = "string";
36
+ newS.contentEncoding = "base64";
37
+ newS.originalType = "bytes";
39
38
  }
40
- else if (t === 'datetime') {
41
- newS.type = 'string';
42
- newS.format = 'date-time';
39
+ else if (t === "datetime") {
40
+ newS.type = "string";
41
+ newS.format = "date-time";
43
42
  }
44
- else if (typeof t !== 'string' && 'oneof' in t) {
45
- newS.type = 'object';
43
+ else if (typeof t !== "string" && "oneof" in t) {
44
+ newS.type = "object";
46
45
  if (t.oneof) {
47
46
  newS.oneOf = t.oneof.map((obj) => {
48
47
  const oldObjS = oldS.oneOf?.find((o) => o?.title === obj.label) ?? undefined;
@@ -52,21 +51,21 @@ function argSigToJsonSchemaType(t, oldS) {
52
51
  properties[prop.key] = oldObjS?.properties[prop.key];
53
52
  }
54
53
  else {
55
- properties[prop.key] = { description: '', type: '' };
54
+ properties[prop.key] = { description: "", type: "" };
56
55
  }
57
56
  argSigToJsonSchemaType(prop.typ, properties[prop.key]);
58
57
  }
59
58
  return {
60
- type: 'object',
59
+ type: "object",
61
60
  title: obj.label,
62
61
  properties,
63
- order: oldObjS?.order ?? undefined
62
+ order: oldObjS?.order ?? undefined,
64
63
  };
65
64
  });
66
65
  }
67
66
  }
68
- else if (typeof t !== 'string' && `object` in t) {
69
- newS.type = 'object';
67
+ else if (typeof t !== "string" && `object` in t) {
68
+ newS.type = "object";
70
69
  if (t.object.name) {
71
70
  newS.format = `resource-${t.object.name}`;
72
71
  }
@@ -77,106 +76,116 @@ function argSigToJsonSchemaType(t, oldS) {
77
76
  properties[prop.key] = oldS.properties[prop.key];
78
77
  }
79
78
  else {
80
- properties[prop.key] = { description: '', type: '' };
79
+ properties[prop.key] = { description: "", type: "" };
81
80
  }
82
81
  argSigToJsonSchemaType(prop.typ, properties[prop.key]);
83
82
  }
84
83
  newS.properties = properties;
85
84
  }
86
85
  }
87
- else if (typeof t !== 'string' && `str` in t) {
88
- newS.type = 'string';
86
+ else if (typeof t !== "string" && `str` in t) {
87
+ newS.type = "string";
89
88
  if (t.str) {
90
- newS.originalType = 'enum';
89
+ newS.originalType = "enum";
91
90
  newS.enum = t.str;
92
91
  }
93
- else if (oldS.originalType == 'string' && oldS.enum) {
94
- newS.originalType = 'string';
92
+ else if (oldS.originalType == "string" && oldS.enum) {
93
+ newS.originalType = "string";
95
94
  newS.enum = oldS.enum;
96
95
  }
97
96
  else {
98
- newS.originalType = 'string';
97
+ newS.originalType = "string";
99
98
  newS.enum = undefined;
100
99
  }
101
100
  }
102
- else if (typeof t !== 'string' && `resource` in t) {
103
- newS.type = 'object';
101
+ else if (typeof t !== "string" && `resource` in t) {
102
+ newS.type = "object";
104
103
  newS.format = `resource-${t.resource}`;
105
104
  }
106
- else if (typeof t !== 'string' && `dynselect` in t) {
107
- newS.type = 'object';
105
+ else if (typeof t !== "string" && `dynselect` in t) {
106
+ newS.type = "object";
108
107
  newS.format = `dynselect-${t.dynselect}`;
109
108
  }
110
- else if (typeof t !== 'string' && `dynmultiselect` in t) {
111
- newS.type = 'object';
109
+ else if (typeof t !== "string" && `dynmultiselect` in t) {
110
+ newS.type = "object";
112
111
  newS.format = `dynmultiselect-${t.dynmultiselect}`;
113
112
  }
114
- else if (typeof t !== 'string' && `list` in t) {
115
- newS.type = 'array';
116
- if (t.list === 'int' || t.list === 'float') {
117
- newS.items = { type: 'number' };
118
- newS.originalType = 'number[]';
113
+ else if (typeof t !== "string" && `list` in t) {
114
+ newS.type = "array";
115
+ if (t.list === "int" || t.list === "float") {
116
+ newS.items = { type: "number" };
117
+ newS.originalType = "number[]";
119
118
  }
120
- else if (t.list === 'bytes') {
121
- newS.items = { type: 'string', contentEncoding: 'base64' };
122
- newS.originalType = 'bytes[]';
119
+ else if (t.list === "bytes") {
120
+ newS.items = { type: "string", contentEncoding: "base64" };
121
+ newS.originalType = "bytes[]";
123
122
  }
124
- else if (t.list && typeof t.list == 'object' && 'str' in t.list && t.list.str) {
125
- newS.items = { type: 'string', enum: t.list.str };
126
- newS.originalType = 'enum[]';
123
+ else if (t.list &&
124
+ typeof t.list == "object" &&
125
+ "str" in t.list &&
126
+ t.list.str) {
127
+ newS.items = { type: "string", enum: t.list.str };
128
+ newS.originalType = "enum[]";
127
129
  }
128
- else if (t.list == 'string' || (t.list && typeof t.list == 'object' && 'str' in t.list)) {
129
- newS.items = { type: 'string', enum: oldS.items?.enum };
130
- newS.originalType = 'string[]';
130
+ else if (t.list == "string" ||
131
+ (t.list && typeof t.list == "object" && "str" in t.list)) {
132
+ newS.items = { type: "string", enum: oldS.items?.enum };
133
+ newS.originalType = "string[]";
131
134
  }
132
- else if (t.list && typeof t.list == 'object' && 'resource' in t.list && t.list.resource) {
135
+ else if (t.list &&
136
+ typeof t.list == "object" &&
137
+ "resource" in t.list &&
138
+ t.list.resource) {
133
139
  newS.items = {
134
- type: 'resource',
135
- resourceType: t.list.resource
140
+ type: "resource",
141
+ resourceType: t.list.resource,
136
142
  };
137
- newS.originalType = 'resource[]';
143
+ newS.originalType = "resource[]";
138
144
  }
139
- else if (t.list && typeof t.list == 'object' && 'object' in t.list && t.list.object) {
145
+ else if (t.list &&
146
+ typeof t.list == "object" &&
147
+ "object" in t.list &&
148
+ t.list.object) {
140
149
  if (t.list.object.name) {
141
150
  newS.format = `resource-${t.list.object.name}`;
142
151
  }
143
152
  if (t.list.object.props && t.list.object.props.length > 0) {
144
153
  const properties = {};
145
154
  for (const prop of t.list.object.props) {
146
- properties[prop.key] = { description: '', type: '' };
155
+ properties[prop.key] = { description: "", type: "" };
147
156
  argSigToJsonSchemaType(prop.typ, properties[prop.key]);
148
157
  }
149
- newS.items = { type: 'object', properties: properties };
158
+ newS.items = { type: "object", properties: properties };
150
159
  }
151
160
  else {
152
- newS.items = { type: 'object' };
161
+ newS.items = { type: "object" };
153
162
  }
154
- newS.originalType = 'record[]';
163
+ newS.originalType = "record[]";
155
164
  }
156
165
  else {
157
- newS.items = { type: 'object' };
158
- newS.originalType = 'object[]';
166
+ newS.items = { type: "object" };
167
+ newS.originalType = "object[]";
159
168
  }
160
169
  }
161
170
  else {
162
- newS.type = 'object';
171
+ newS.type = "object";
163
172
  }
164
173
  const preservedFields = [
165
- 'description',
166
- 'pattern',
167
- 'min',
168
- 'max',
169
- 'currency',
170
- 'currencyLocale',
171
- 'multiselect',
172
- 'customErrorMessage',
173
- 'required',
174
- 'showExpr',
175
- 'password',
176
- 'order',
177
- 'dateFormat',
178
- 'title',
179
- 'placeholder'
174
+ "description",
175
+ "pattern",
176
+ "min",
177
+ "max",
178
+ "currency",
179
+ "currencyLocale",
180
+ "multiselect",
181
+ "customErrorMessage",
182
+ "required",
183
+ "showExpr",
184
+ "password",
185
+ "order",
186
+ "dateFormat",
187
+ "title",
188
+ "placeholder",
180
189
  ];
181
190
  preservedFields.forEach((field) => {
182
191
  // @ts-ignore
@@ -185,24 +194,34 @@ function argSigToJsonSchemaType(t, oldS) {
185
194
  newS[field] = oldS[field];
186
195
  }
187
196
  });
197
+ console.log("newS", JSON.stringify(newS, null, 2));
198
+ console.log("oldS", JSON.stringify(oldS, null, 2));
188
199
  if (oldS.type != newS.type) {
189
200
  for (const prop of Object.getOwnPropertyNames(newS)) {
190
- if (prop != 'description') {
201
+ if (prop != "description") {
191
202
  // @ts-ignore
192
203
  delete oldS[prop];
193
204
  }
194
205
  }
195
206
  }
196
- else if ((oldS.format == 'date' || oldS.format === 'date-time') && newS.format == 'string') {
207
+ else if ((oldS.format == "date" || oldS.format === "date-time") &&
208
+ newS.format == "string") {
197
209
  newS.format = oldS.format;
198
210
  }
199
- else if (newS.format == 'date-time' && oldS.format == 'date') {
200
- newS.format = 'date';
211
+ else if (newS.format == "date-time" && oldS.format == "date") {
212
+ newS.format = "date";
213
+ }
214
+ else if (newS.format == "date" || newS.format == "date-time") {
215
+ newS.format = oldS.format;
201
216
  }
202
217
  else if (oldS.items?.type != newS.items?.type) {
203
218
  delete oldS.items;
204
219
  }
205
- if (oldS.format && !newS.format) {
220
+ else if (oldS.type == "string" && oldS.format != undefined) {
221
+ newS.format = oldS.format;
222
+ }
223
+ if ((oldS.type != newS.type || newS.type != "string") &&
224
+ newS.format == undefined) {
206
225
  oldS.format = undefined;
207
226
  }
208
227
  Object.assign(oldS, newS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-utils-internal",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Internal utility functions for Windmill",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",