@griffin-app/griffin-cli 1.0.23 → 1.0.25
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/dist/commands/hub/integrations.d.ts +1 -1
- package/dist/core/apply.js +3 -1
- package/dist/core/diff.js +1 -6
- package/dist/core/discovery.d.ts +1 -1
- package/dist/core/discovery.js +1 -1
- package/dist/core/monitor-diff.js +70 -7
- package/dist/core/monitor-helpers.d.ts +2 -1
- package/dist/core/secrets.d.ts +1 -1
- package/dist/core/secrets.js +1 -1
- package/dist/monitor-runner.d.ts +1 -1
- package/dist/monitor-runner.js +2 -2
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IntegrationCategory, Provider } from "@griffin-app/griffin-
|
|
1
|
+
import type { IntegrationCategory, Provider } from "@griffin-app/griffin-core/types";
|
|
2
2
|
import type { IntegrationConfig, ProviderDefinition } from "@griffin-app/griffin-hub-sdk";
|
|
3
3
|
export interface IntegrationsListOptions {
|
|
4
4
|
category?: IntegrationCategory;
|
package/dist/core/apply.js
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
package/dist/core/discovery.d.ts
CHANGED
package/dist/core/discovery.js
CHANGED
|
@@ -2,7 +2,7 @@ import "tsx";
|
|
|
2
2
|
import { glob } from "glob";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { MonitorDSLSchema } from "@griffin-app/griffin-
|
|
5
|
+
import { MonitorDSLSchema } from "@griffin-app/griffin-core/schema";
|
|
6
6
|
import { Value } from "typebox/value";
|
|
7
7
|
/**
|
|
8
8
|
* Discover and load test monitor files from the filesystem
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import objectHash from "object-hash";
|
|
2
|
-
import { NodeType } from "@griffin-app/griffin-
|
|
2
|
+
import { NodeType } from "@griffin-app/griffin-core/schema";
|
|
3
3
|
/**
|
|
4
4
|
* Compare two test monitors and return granular changes.
|
|
5
5
|
* Local monitor should be resolved (variables replaced with actual values).
|
|
@@ -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
|
-
|
|
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 (!
|
|
319
|
+
: undefined));
|
|
320
|
+
if (!notificationsEqual(localNotifications, remoteNotifications)) {
|
|
258
321
|
changes.push({
|
|
259
322
|
field: "notifications",
|
|
260
323
|
oldValue: remoteNotifications,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GriffinHubSdk, MonitorV1 } from "@griffin-app/griffin-hub-sdk";
|
|
2
2
|
import type { StateFile } from "../schemas/state.js";
|
|
3
3
|
import { type DiscoveryResult } from "./discovery.js";
|
|
4
|
+
import { MonitorDSL } from "@griffin-app/griffin-core/types";
|
|
4
5
|
/**
|
|
5
6
|
* Discover local monitors using state-configured patterns.
|
|
6
7
|
* Shows spinner, handles errors, and returns the discovery result.
|
|
@@ -15,5 +16,5 @@ export declare function fetchRemoteMonitors(sdk: GriffinHubSdk, projectId: strin
|
|
|
15
16
|
* Load variables and resolve local monitors for a given project and environment.
|
|
16
17
|
*/
|
|
17
18
|
export declare function resolveLocalMonitors(monitors: {
|
|
18
|
-
monitor:
|
|
19
|
+
monitor: MonitorDSL;
|
|
19
20
|
}[], projectId: string, envName: string): Promise<Omit<MonitorV1, "id">[]>;
|
package/dist/core/secrets.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Secrets configuration for CLI local runs.
|
|
3
3
|
* Reads configuration from environment variables to construct a secret provider.
|
|
4
4
|
*/
|
|
5
|
-
import { type SecretProvider, type SecretProviderConfig } from "@griffin-app/griffin-
|
|
5
|
+
import { type SecretProvider, type SecretProviderConfig } from "@griffin-app/griffin-executor";
|
|
6
6
|
/**
|
|
7
7
|
* Read secrets provider configuration from environment variables.
|
|
8
8
|
*
|
package/dist/core/secrets.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Secrets configuration for CLI local runs.
|
|
3
3
|
* Reads configuration from environment variables to construct a secret provider.
|
|
4
4
|
*/
|
|
5
|
-
import { createSecretProvider, } from "@griffin-app/griffin-
|
|
5
|
+
import { createSecretProvider, } from "@griffin-app/griffin-executor";
|
|
6
6
|
/**
|
|
7
7
|
* Environment variable prefixes for secrets configuration.
|
|
8
8
|
*/
|
package/dist/monitor-runner.d.ts
CHANGED
package/dist/monitor-runner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "tsx";
|
|
2
2
|
import { Value } from "typebox/value";
|
|
3
|
-
import { executeMonitorV1, AxiosAdapter, } from "@griffin-app/griffin-
|
|
4
|
-
import { MonitorDSLSchema } from "@griffin-app/griffin-
|
|
3
|
+
import { executeMonitorV1, AxiosAdapter, } from "@griffin-app/griffin-executor";
|
|
4
|
+
import { MonitorDSLSchema } from "@griffin-app/griffin-core/schema";
|
|
5
5
|
import { randomUUID } from "crypto";
|
|
6
6
|
import { loadVariables } from "./core/variables.js";
|
|
7
7
|
import { getProjectId } from "./core/state.js";
|
package/dist/resolve.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MonitorV1 } from "@griffin-app/griffin-hub-sdk";
|
|
2
|
-
import { MonitorDSL } from "@griffin-app/griffin-
|
|
2
|
+
import { MonitorDSL } from "@griffin-app/griffin-core";
|
|
3
3
|
export declare function resolveMonitor(monitor: MonitorDSL, projectId: string, envName: string, variables: Record<string, string>): Omit<MonitorV1, "id">;
|
package/dist/resolve.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { migrateToLatest, CURRENT_MONITOR_VERSION, } from "@griffin-app/griffin-
|
|
1
|
+
import { migrateToLatest, CURRENT_MONITOR_VERSION, } from "@griffin-app/griffin-core";
|
|
2
2
|
import { resolveVariablesInMonitor } from "./core/variables.js";
|
|
3
3
|
export function resolveMonitor(monitor, projectId, envName, variables) {
|
|
4
4
|
// Migrate DSL monitor to latest version before resolving
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffin-app/griffin-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "CLI tool for running and managing griffin API tests",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@griffin-app/griffin-hub-sdk": "1.0.25",
|
|
28
|
-
"@griffin-app/griffin-
|
|
29
|
-
"@griffin-app/griffin-
|
|
28
|
+
"@griffin-app/griffin-executor": "0.1.0",
|
|
29
|
+
"@griffin-app/griffin-core": "0.1.0",
|
|
30
30
|
"better-auth": "^1.4.17",
|
|
31
31
|
"cli-table3": "^0.6.5",
|
|
32
32
|
"commander": "^12.1.0",
|