@oneuptime/common 7.0.4597 → 7.0.4604
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.
- package/Models/DatabaseModels/Alert.ts +1 -1
- package/Models/DatabaseModels/ApiKey.ts +1 -3
- package/Models/DatabaseModels/ApiKeyPermission.ts +2 -2
- package/Models/DatabaseModels/GlobalConfig.ts +1 -1
- package/Models/DatabaseModels/Incident.ts +3 -5
- package/Models/DatabaseModels/Monitor.ts +5 -5
- package/Models/DatabaseModels/Project.ts +1 -2
- package/Models/DatabaseModels/ProjectCallSMSConfig.ts +1 -1
- package/Models/DatabaseModels/ProjectSmtpConfig.ts +2 -2
- package/Models/DatabaseModels/ProjectSso.ts +2 -2
- package/Models/DatabaseModels/PromoCode.ts +5 -1
- package/Models/DatabaseModels/ResellerPlan.ts +1 -1
- package/Models/DatabaseModels/StatusPageAnnouncement.ts +2 -2
- package/Models/DatabaseModels/StatusPageSso.ts +4 -4
- package/Models/DatabaseModels/TeamPermission.ts +2 -2
- package/Models/DatabaseModels/TelemetryException.ts +1 -1
- package/Models/DatabaseModels/User.ts +6 -2
- package/Models/DatabaseModels/UserNotificationSetting.ts +4 -4
- package/Server/API/ResellerPlanAPI.ts +1 -1
- package/Server/Services/AlertService.ts +2 -2
- package/Server/Services/DatabaseService.ts +1 -4
- package/Server/Services/IncidentService.ts +4 -4
- package/Server/Services/ScheduledMaintenanceService.ts +7 -7
- package/Server/Types/AnalyticsDatabase/ModelPermission.ts +0 -1
- package/Server/Types/Database/Permissions/ColumnPermission.ts +14 -14
- package/Tests/UI/Components/MarkdownEditor.test.tsx +4 -4
- package/Types/Text.ts +9 -9
- package/Types/Workspace/NotificationRules/BaseNotificationRule.ts +2 -2
- package/Utils/Schema/AnalyticsModelSchema.ts +202 -90
- package/Utils/Schema/ModelSchema.ts +235 -144
- package/build/dist/Models/DatabaseModels/ApiKey.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProjectCallSMSConfig.js +1 -1
- package/build/dist/Models/DatabaseModels/PromoCode.js +5 -1
- package/build/dist/Models/DatabaseModels/PromoCode.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ResellerPlan.js +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryException.js +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -1
- package/build/dist/Models/DatabaseModels/User.js +5 -1
- package/build/dist/Models/DatabaseModels/User.js.map +1 -1
- package/build/dist/Server/API/ResellerPlanAPI.js +1 -1
- package/build/dist/Server/API/ResellerPlanAPI.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +2 -2
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +1 -2
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +4 -4
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +7 -7
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
- package/build/dist/Tests/UI/Components/MarkdownEditor.test.js +4 -4
- package/build/dist/Tests/UI/Components/MarkdownEditor.test.js.map +1 -1
- package/build/dist/Types/Text.js +8 -8
- package/build/dist/Types/Text.js.map +1 -1
- package/build/dist/Utils/Schema/AnalyticsModelSchema.js +12 -4
- package/build/dist/Utils/Schema/AnalyticsModelSchema.js.map +1 -1
- package/build/dist/Utils/Schema/ModelSchema.js +49 -22
- package/build/dist/Utils/Schema/ModelSchema.js.map +1 -1
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ export class AnalyticsModelSchema extends BaseSchema {
|
|
|
16
16
|
private static addDefaultToOpenApi(
|
|
17
17
|
openApiConfig: any,
|
|
18
18
|
column: AnalyticsTableColumn,
|
|
19
|
-
) {
|
|
19
|
+
): any {
|
|
20
20
|
if (column.defaultValue !== undefined && column.defaultValue !== null) {
|
|
21
21
|
return { ...openApiConfig, default: column.defaultValue };
|
|
22
22
|
}
|
|
@@ -50,74 +50,135 @@ export class AnalyticsModelSchema extends BaseSchema {
|
|
|
50
50
|
let zodType: ZodTypes.ZodTypeAny;
|
|
51
51
|
|
|
52
52
|
if (column.type === TableColumnType.ObjectID) {
|
|
53
|
-
zodType = z.string().openapi(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
zodType = z.string().openapi(
|
|
54
|
+
this.addDefaultToOpenApi(
|
|
55
|
+
{
|
|
56
|
+
type: "string",
|
|
57
|
+
example: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
58
|
+
},
|
|
59
|
+
column,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
57
62
|
} else if (column.type === TableColumnType.Date) {
|
|
58
|
-
zodType = z.date().openapi(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
zodType = z.date().openapi(
|
|
64
|
+
this.addDefaultToOpenApi(
|
|
65
|
+
{
|
|
66
|
+
type: "string",
|
|
67
|
+
format: "date-time",
|
|
68
|
+
example: "2023-01-15T12:30:00.000Z",
|
|
69
|
+
},
|
|
70
|
+
column,
|
|
71
|
+
),
|
|
72
|
+
);
|
|
63
73
|
} else if (column.type === TableColumnType.Text) {
|
|
64
|
-
zodType = z.string().openapi(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
zodType = z.string().openapi(
|
|
75
|
+
this.addDefaultToOpenApi(
|
|
76
|
+
{
|
|
77
|
+
type: "string",
|
|
78
|
+
example: "Example text value",
|
|
79
|
+
},
|
|
80
|
+
column,
|
|
81
|
+
),
|
|
82
|
+
);
|
|
68
83
|
} else if (column.type === TableColumnType.Number) {
|
|
69
|
-
zodType = z
|
|
84
|
+
zodType = z
|
|
85
|
+
.number()
|
|
86
|
+
.openapi(
|
|
87
|
+
this.addDefaultToOpenApi({ type: "number", example: 42 }, column),
|
|
88
|
+
);
|
|
70
89
|
} else if (column.type === TableColumnType.LongNumber) {
|
|
71
|
-
zodType = z.number().openapi(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
zodType = z.number().openapi(
|
|
91
|
+
this.addDefaultToOpenApi(
|
|
92
|
+
{
|
|
93
|
+
type: "number",
|
|
94
|
+
example: 1000000,
|
|
95
|
+
},
|
|
96
|
+
column,
|
|
97
|
+
),
|
|
98
|
+
);
|
|
75
99
|
} else if (column.type === TableColumnType.Boolean) {
|
|
76
|
-
zodType = z
|
|
100
|
+
zodType = z
|
|
101
|
+
.boolean()
|
|
102
|
+
.openapi(
|
|
103
|
+
this.addDefaultToOpenApi(
|
|
104
|
+
{ type: "boolean", example: true },
|
|
105
|
+
column,
|
|
106
|
+
),
|
|
107
|
+
);
|
|
77
108
|
} else if (column.type === TableColumnType.JSON) {
|
|
78
|
-
zodType = z.any().openapi(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
109
|
+
zodType = z.any().openapi(
|
|
110
|
+
this.addDefaultToOpenApi(
|
|
111
|
+
{
|
|
112
|
+
type: "object",
|
|
113
|
+
example: { key: "value", nested: { data: 123 } },
|
|
114
|
+
},
|
|
115
|
+
column,
|
|
116
|
+
),
|
|
117
|
+
);
|
|
82
118
|
} else if (column.type === TableColumnType.JSONArray) {
|
|
83
|
-
zodType = z.array(z.any()).openapi(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
119
|
+
zodType = z.array(z.any()).openapi(
|
|
120
|
+
this.addDefaultToOpenApi(
|
|
121
|
+
{
|
|
122
|
+
type: "array",
|
|
123
|
+
items: {
|
|
124
|
+
type: "object",
|
|
125
|
+
},
|
|
126
|
+
example: [{ key: "value" }, { key2: "value2" }],
|
|
127
|
+
},
|
|
128
|
+
column,
|
|
129
|
+
),
|
|
130
|
+
);
|
|
90
131
|
} else if (column.type === TableColumnType.Decimal) {
|
|
91
|
-
zodType = z.number().openapi(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
132
|
+
zodType = z.number().openapi(
|
|
133
|
+
this.addDefaultToOpenApi(
|
|
134
|
+
{
|
|
135
|
+
type: "number",
|
|
136
|
+
example: 123.45,
|
|
137
|
+
},
|
|
138
|
+
column,
|
|
139
|
+
),
|
|
140
|
+
);
|
|
95
141
|
} else if (column.type === TableColumnType.ArrayNumber) {
|
|
96
|
-
zodType = z.array(z.number()).openapi(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
142
|
+
zodType = z.array(z.number()).openapi(
|
|
143
|
+
this.addDefaultToOpenApi(
|
|
144
|
+
{
|
|
145
|
+
type: "array",
|
|
146
|
+
items: {
|
|
147
|
+
type: "number",
|
|
148
|
+
},
|
|
149
|
+
example: [1, 2, 3, 4, 5],
|
|
150
|
+
},
|
|
151
|
+
column,
|
|
152
|
+
),
|
|
153
|
+
);
|
|
103
154
|
} else if (column.type === TableColumnType.ArrayText) {
|
|
104
|
-
zodType = z.array(z.string()).openapi(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
155
|
+
zodType = z.array(z.string()).openapi(
|
|
156
|
+
this.addDefaultToOpenApi(
|
|
157
|
+
{
|
|
158
|
+
type: "array",
|
|
159
|
+
items: {
|
|
160
|
+
type: "string",
|
|
161
|
+
},
|
|
162
|
+
example: ["item1", "item2", "item3"],
|
|
163
|
+
},
|
|
164
|
+
column,
|
|
165
|
+
),
|
|
166
|
+
);
|
|
111
167
|
} else if (column.type === TableColumnType.IP) {
|
|
112
168
|
zodType = IP.getSchema();
|
|
113
169
|
} else if (column.type === TableColumnType.Port) {
|
|
114
170
|
zodType = Port.getSchema();
|
|
115
171
|
} else {
|
|
116
172
|
// Default fallback
|
|
117
|
-
zodType = z.any().openapi(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
173
|
+
zodType = z.any().openapi(
|
|
174
|
+
this.addDefaultToOpenApi(
|
|
175
|
+
{
|
|
176
|
+
type: "string",
|
|
177
|
+
example: "example_value",
|
|
178
|
+
},
|
|
179
|
+
column,
|
|
180
|
+
),
|
|
181
|
+
);
|
|
121
182
|
}
|
|
122
183
|
|
|
123
184
|
// Apply default value if it exists
|
|
@@ -151,56 +212,107 @@ export class AnalyticsModelSchema extends BaseSchema {
|
|
|
151
212
|
case TableColumnType.Date:
|
|
152
213
|
return OneUptimeDate.getSchema();
|
|
153
214
|
case TableColumnType.Text:
|
|
154
|
-
return z.string().openapi(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
215
|
+
return z.string().openapi(
|
|
216
|
+
this.addDefaultToOpenApi(
|
|
217
|
+
{
|
|
218
|
+
type: "string",
|
|
219
|
+
example: "Example text",
|
|
220
|
+
},
|
|
221
|
+
column,
|
|
222
|
+
),
|
|
223
|
+
);
|
|
158
224
|
case TableColumnType.Number:
|
|
159
|
-
return z
|
|
225
|
+
return z
|
|
226
|
+
.number()
|
|
227
|
+
.openapi(
|
|
228
|
+
this.addDefaultToOpenApi({ type: "number", example: 42 }, column),
|
|
229
|
+
);
|
|
160
230
|
case TableColumnType.LongNumber:
|
|
161
|
-
return z.number().openapi(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
231
|
+
return z.number().openapi(
|
|
232
|
+
this.addDefaultToOpenApi(
|
|
233
|
+
{
|
|
234
|
+
type: "number",
|
|
235
|
+
example: 1000000,
|
|
236
|
+
},
|
|
237
|
+
column,
|
|
238
|
+
),
|
|
239
|
+
);
|
|
165
240
|
case TableColumnType.Boolean:
|
|
166
|
-
return z
|
|
241
|
+
return z
|
|
242
|
+
.boolean()
|
|
243
|
+
.openapi(
|
|
244
|
+
this.addDefaultToOpenApi(
|
|
245
|
+
{ type: "boolean", example: true },
|
|
246
|
+
column,
|
|
247
|
+
),
|
|
248
|
+
);
|
|
167
249
|
case TableColumnType.JSON:
|
|
168
|
-
return z.any().openapi(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
250
|
+
return z.any().openapi(
|
|
251
|
+
this.addDefaultToOpenApi(
|
|
252
|
+
{
|
|
253
|
+
type: "object",
|
|
254
|
+
example: { key: "value" },
|
|
255
|
+
},
|
|
256
|
+
column,
|
|
257
|
+
),
|
|
258
|
+
);
|
|
172
259
|
case TableColumnType.JSONArray:
|
|
173
|
-
return z.array(z.any()).openapi(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
260
|
+
return z.array(z.any()).openapi(
|
|
261
|
+
this.addDefaultToOpenApi(
|
|
262
|
+
{
|
|
263
|
+
type: "array",
|
|
264
|
+
items: { type: "object" },
|
|
265
|
+
example: [{ key: "value" }],
|
|
266
|
+
},
|
|
267
|
+
column,
|
|
268
|
+
),
|
|
269
|
+
);
|
|
178
270
|
case TableColumnType.Decimal:
|
|
179
|
-
return z.number().openapi(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
271
|
+
return z.number().openapi(
|
|
272
|
+
this.addDefaultToOpenApi(
|
|
273
|
+
{
|
|
274
|
+
type: "number",
|
|
275
|
+
example: 123.45,
|
|
276
|
+
},
|
|
277
|
+
column,
|
|
278
|
+
),
|
|
279
|
+
);
|
|
183
280
|
case TableColumnType.ArrayNumber:
|
|
184
|
-
return z.array(z.number()).openapi(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
281
|
+
return z.array(z.number()).openapi(
|
|
282
|
+
this.addDefaultToOpenApi(
|
|
283
|
+
{
|
|
284
|
+
type: "array",
|
|
285
|
+
items: { type: "number" },
|
|
286
|
+
example: [1, 2, 3],
|
|
287
|
+
},
|
|
288
|
+
column,
|
|
289
|
+
),
|
|
290
|
+
);
|
|
189
291
|
case TableColumnType.ArrayText:
|
|
190
|
-
return z.array(z.string()).openapi(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
292
|
+
return z.array(z.string()).openapi(
|
|
293
|
+
this.addDefaultToOpenApi(
|
|
294
|
+
{
|
|
295
|
+
type: "array",
|
|
296
|
+
items: { type: "string" },
|
|
297
|
+
example: ["item1", "item2"],
|
|
298
|
+
},
|
|
299
|
+
column,
|
|
300
|
+
),
|
|
301
|
+
);
|
|
195
302
|
case TableColumnType.IP:
|
|
196
303
|
return IP.getSchema();
|
|
197
304
|
case TableColumnType.Port:
|
|
198
305
|
return Port.getSchema();
|
|
199
306
|
default:
|
|
200
|
-
return z.any().openapi(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
307
|
+
return z.any().openapi(
|
|
308
|
+
this.addDefaultToOpenApi(
|
|
309
|
+
{
|
|
310
|
+
type: "string",
|
|
311
|
+
example: "example_value",
|
|
312
|
+
},
|
|
313
|
+
column,
|
|
314
|
+
),
|
|
315
|
+
);
|
|
204
316
|
}
|
|
205
317
|
}
|
|
206
318
|
|