@griffin-app/griffin-cli 1.0.23 → 1.0.24

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.
@@ -32,6 +32,7 @@ export async function applyDiff(diff, sdk, options) {
32
32
  }
33
33
  }
34
34
  catch (error) {
35
+ console.log(error);
35
36
  terminal.error(error.message);
36
37
  errors.push({
37
38
  action,
@@ -77,12 +78,13 @@ async function applyUpdate(action, sdk, applied) {
77
78
  //const variables = await loadVariables(environment);
78
79
  //const resolvedMonitor = resolveMonitor(monitor, projectId, environment, variables);
79
80
  // Use the remote monitor's ID for the update
80
- await sdk.putMonitorById({
81
+ const result = await sdk.putMonitorById({
81
82
  path: {
82
83
  id: action.remoteMonitor.id,
83
84
  },
84
85
  body: resolvedMonitor,
85
86
  });
87
+ console.log(JSON.stringify(result.data, null, 2));
86
88
  applied.push({
87
89
  type: "update",
88
90
  monitorName: action.remoteMonitor.name,
package/dist/core/diff.js CHANGED
@@ -196,12 +196,7 @@ function formatFieldValue(value) {
196
196
  if ("every" in value && "unit" in value) {
197
197
  return `every ${value.every} ${value.unit.toLowerCase()}`;
198
198
  }
199
- // For other objects, show a compact representation
200
- const keys = Object.keys(value);
201
- if (keys.length <= 2) {
202
- return JSON.stringify(value);
203
- }
204
- return `{${keys.length} fields}`;
199
+ return JSON.stringify(value);
205
200
  }
206
201
  return String(value);
207
202
  }
@@ -214,6 +214,66 @@ function compareEdges(localEdges, remoteEdges) {
214
214
  }
215
215
  return changes;
216
216
  }
217
+ /** Pattern for hub-assigned platform integration names (e.g. platform-email). */
218
+ const PLATFORM_INTEGRATION_PREFIX = "platform-";
219
+ /**
220
+ * Normalize notifications for diff: treat hub-assigned platform integration
221
+ * names (platform-${channelType}) as equivalent to missing integration so the
222
+ * DSL need not specify them.
223
+ */
224
+ function normalizeNotificationsForDiff(notifications) {
225
+ if (!notifications || notifications.length === 0)
226
+ return undefined;
227
+ return notifications.map((n) => {
228
+ const integration = n.integration;
229
+ if (integration && integration.startsWith(PLATFORM_INTEGRATION_PREFIX)) {
230
+ const channelType = n.routing?.channelType;
231
+ const platformName = PLATFORM_INTEGRATION_PREFIX + (channelType ?? "");
232
+ if (integration === platformName) {
233
+ const copy = { ...n };
234
+ delete copy.integration;
235
+ return copy;
236
+ }
237
+ }
238
+ return n;
239
+ });
240
+ }
241
+ /** Sort key from trigger + routing only so matching entries line up when comparing. */
242
+ function notificationSortKey(n) {
243
+ return objectHash({ trigger: n.trigger, routing: n.routing });
244
+ }
245
+ /**
246
+ * Sort notifications by (trigger, routing) so comparison is order-independent
247
+ * and matching entries align. Uses only trigger+routing so integration doesn't affect order.
248
+ */
249
+ function sortNotificationsForDiff(notifications) {
250
+ if (!notifications || notifications.length === 0)
251
+ return undefined;
252
+ return [...notifications].sort((a, b) => {
253
+ const ka = notificationSortKey(a);
254
+ const kb = notificationSortKey(b);
255
+ return ka < kb ? -1 : ka > kb ? 1 : 0;
256
+ });
257
+ }
258
+ /**
259
+ * Semantic equality for notification arrays: same set of (trigger, routing), and
260
+ * when local omits integration we treat remote's integration as a match (hub may assign a name).
261
+ */
262
+ function notificationsEqual(local, remote) {
263
+ if (!local && !remote)
264
+ return true;
265
+ if (!local || !remote || local.length !== remote.length)
266
+ return false;
267
+ for (let i = 0; i < local.length; i++) {
268
+ const a = local[i];
269
+ const b = remote[i];
270
+ if (!deepEqual(a.trigger, b.trigger) || !deepEqual(a.routing, b.routing))
271
+ return false;
272
+ if (a.integration !== undefined && a.integration !== b.integration)
273
+ return false;
274
+ }
275
+ return true;
276
+ }
217
277
  /**
218
278
  * Compare top-level fields: frequency, version, locations
219
279
  */
@@ -247,14 +307,17 @@ function compareTopLevel(local, remote) {
247
307
  newValue: localLocations,
248
308
  });
249
309
  }
250
- // Compare notifications (normalize empty array to undefined)
251
- const localNotifications = local.notifications && local.notifications.length > 0
310
+ // Compare notifications (normalize empty array to undefined).
311
+ // Ignore hub-assigned platform integration names (platform-${channelType}) so they
312
+ // don't cause a diff when the DSL omits integration.
313
+ // Sort so order is irrelevant — the backend does not impose ordering.
314
+ const localNotifications = sortNotificationsForDiff(normalizeNotificationsForDiff(local.notifications && local.notifications.length > 0
252
315
  ? local.notifications
253
- : undefined;
254
- const remoteNotifications = remote.notifications && remote.notifications.length > 0
316
+ : undefined));
317
+ const remoteNotifications = sortNotificationsForDiff(normalizeNotificationsForDiff(remote.notifications && remote.notifications.length > 0
255
318
  ? remote.notifications
256
- : undefined;
257
- if (!deepEqual(localNotifications, remoteNotifications)) {
319
+ : undefined));
320
+ if (!notificationsEqual(localNotifications, remoteNotifications)) {
258
321
  changes.push({
259
322
  field: "notifications",
260
323
  oldValue: remoteNotifications,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@griffin-app/griffin-cli",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "CLI tool for running and managing griffin API tests",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",