@siteoshq/cli 1.7.0 → 1.8.1

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/cli.js CHANGED
@@ -17,7 +17,7 @@ __export(cookie_verification_exports, {
17
17
  verificationTarget: () => verificationTarget,
18
18
  verifyCookieWebsite: () => verifyCookieWebsite
19
19
  });
20
- import { z as z14 } from "zod";
20
+ import { z as z15 } from "zod";
21
21
  function verificationTarget(websiteUrl, candidate) {
22
22
  const website = new URL(websiteUrl);
23
23
  const target = new URL(candidate ?? websiteUrl, website);
@@ -362,73 +362,73 @@ var Names, Service, Envelope, State, VerificationInstallation;
362
362
  var init_cookie_verification = __esm({
363
363
  "src/services/cookie-verification.ts"() {
364
364
  "use strict";
365
- Names = z14.object({
366
- exact: z14.array(z14.string()),
367
- prefixes: z14.array(z14.string())
368
- });
369
- Service = z14.object({
370
- key: z14.string(),
371
- purposeKey: z14.string(),
372
- lifecycle: z14.object({
373
- scriptOrigins: z14.array(z14.string()),
374
- iframeOrigins: z14.array(z14.string()),
375
- pixelOrigins: z14.array(z14.string()),
365
+ Names = z15.object({
366
+ exact: z15.array(z15.string()),
367
+ prefixes: z15.array(z15.string())
368
+ });
369
+ Service = z15.object({
370
+ key: z15.string(),
371
+ purposeKey: z15.string(),
372
+ lifecycle: z15.object({
373
+ scriptOrigins: z15.array(z15.string()),
374
+ iframeOrigins: z15.array(z15.string()),
375
+ pixelOrigins: z15.array(z15.string()),
376
376
  firstPartyCookies: Names,
377
377
  localStorage: Names
378
378
  }).optional()
379
379
  });
380
- Envelope = z14.object({
381
- publicKey: z14.string(),
382
- revision: z14.number(),
383
- ruleKey: z14.string(),
384
- profileKey: z14.string(),
385
- trustedSignals: z14.object({
386
- region: z14.object({
387
- countryCode: z14.string().nullable(),
388
- subdivisionCode: z14.string().nullable()
380
+ Envelope = z15.object({
381
+ publicKey: z15.string(),
382
+ revision: z15.number(),
383
+ ruleKey: z15.string(),
384
+ profileKey: z15.string(),
385
+ trustedSignals: z15.object({
386
+ region: z15.object({
387
+ countryCode: z15.string().nullable(),
388
+ subdivisionCode: z15.string().nullable()
389
389
  }).optional()
390
390
  }).optional(),
391
- config: z14.object({
392
- services: z14.array(Service),
393
- categories: z14.array(z14.object({ key: z14.string(), required: z14.boolean() })),
394
- integrations: z14.object({ googleConsentMode: z14.string() })
391
+ config: z15.object({
392
+ services: z15.array(Service),
393
+ categories: z15.array(z15.object({ key: z15.string(), required: z15.boolean() })),
394
+ integrations: z15.object({ googleConsentMode: z15.string() })
395
395
  })
396
396
  });
397
- State = z14.object({
398
- runtimeVersion: z14.string(),
399
- preview: z14.boolean(),
400
- resolved: z14.object({
401
- publicKey: z14.string(),
402
- revision: z14.number(),
403
- ruleKey: z14.string(),
404
- profileKey: z14.string()
397
+ State = z15.object({
398
+ runtimeVersion: z15.string(),
399
+ preview: z15.boolean(),
400
+ resolved: z15.object({
401
+ publicKey: z15.string(),
402
+ revision: z15.number(),
403
+ ruleKey: z15.string(),
404
+ profileKey: z15.string()
405
405
  }).nullable(),
406
- consent: z14.object({
407
- categories: z14.array(z14.string()),
408
- decision: z14.string(),
409
- globalPrivacyControl: z14.boolean(),
410
- privacyChoices: z14.object({
411
- saleOrShareOptOut: z14.boolean(),
412
- targetedAdvertisingOptOut: z14.boolean()
406
+ consent: z15.object({
407
+ categories: z15.array(z15.string()),
408
+ decision: z15.string(),
409
+ globalPrivacyControl: z15.boolean(),
410
+ privacyChoices: z15.object({
411
+ saleOrShareOptOut: z15.boolean(),
412
+ targetedAdvertisingOptOut: z15.boolean()
413
413
  })
414
414
  }),
415
- services: z14.array(
416
- z14.object({
417
- key: z14.string(),
418
- allowed: z14.boolean(),
419
- footprintPresent: z14.boolean()
415
+ services: z15.array(
416
+ z15.object({
417
+ key: z15.string(),
418
+ allowed: z15.boolean(),
419
+ footprintPresent: z15.boolean()
420
420
  })
421
421
  )
422
422
  });
423
- VerificationInstallation = z14.object({
424
- publicKey: z14.string(),
425
- currentPublishedRevision: z14.number().int().positive(),
426
- delivery: z14.object({
427
- runtimeUrl: z14.string().url(),
428
- configUrl: z14.string().url(),
429
- analyticsUrl: z14.string().url().nullable(),
430
- receiptsUrl: z14.string().url(),
431
- handshakeUrl: z14.string().url()
423
+ VerificationInstallation = z15.object({
424
+ publicKey: z15.string(),
425
+ currentPublishedRevision: z15.number().int().positive(),
426
+ delivery: z15.object({
427
+ runtimeUrl: z15.string().url(),
428
+ configUrl: z15.string().url(),
429
+ analyticsUrl: z15.string().url().nullable(),
430
+ receiptsUrl: z15.string().url(),
431
+ handshakeUrl: z15.string().url()
432
432
  })
433
433
  });
434
434
  }
@@ -3816,10 +3816,10 @@ async function runSubmissionsCommand(options) {
3816
3816
  return usageError2(
3817
3817
  "Use new, read, archived or spam for --status and --expected-status."
3818
3818
  );
3819
- const filters = new URLSearchParams();
3819
+ const filters2 = new URLSearchParams();
3820
3820
  for (const key of ["query", "status", "from", "to", "limit", "cursor"]) {
3821
3821
  const item = value(key);
3822
- if (item) filters.set(key, item);
3822
+ if (item) filters2.set(key, item);
3823
3823
  }
3824
3824
  const limit = Number(value("limit") ?? 50);
3825
3825
  if (!Number.isInteger(limit) || limit < 1 || limit > 100)
@@ -3856,7 +3856,7 @@ async function runSubmissionsCommand(options) {
3856
3856
  environmentId: environment.id,
3857
3857
  formId
3858
3858
  };
3859
- const response = action === "list" ? await context.client.listSubmissions({ ...input, filters }) : action === "read" ? await context.client.readSubmission({
3859
+ const response = action === "list" ? await context.client.listSubmissions({ ...input, filters: filters2 }) : action === "read" ? await context.client.readSubmission({
3860
3860
  ...input,
3861
3861
  submissionId
3862
3862
  }) : await context.client.updateSubmissionStatus({
@@ -9479,7 +9479,111 @@ async function runEnvironmentCommand3(options) {
9479
9479
  import { readFile as readFile16, stat } from "fs/promises";
9480
9480
  import path28 from "path";
9481
9481
  import { parseArgs as parseArgs3 } from "util";
9482
- import { z as z15 } from "zod";
9482
+ import { z as z16 } from "zod";
9483
+
9484
+ // src/services/trace-explorer-command.ts
9485
+ import { z as z14 } from "zod";
9486
+ var filters = [
9487
+ "environment",
9488
+ "provider",
9489
+ "event",
9490
+ "property",
9491
+ "page-view",
9492
+ "search",
9493
+ "state",
9494
+ "rule",
9495
+ "kind",
9496
+ "period",
9497
+ "cursor"
9498
+ ];
9499
+ var TRACE_EXPLORER_FLAGS = {
9500
+ destinations: filters,
9501
+ events: filters,
9502
+ properties: filters,
9503
+ issues: filters,
9504
+ observations: filters,
9505
+ "issue show": ["environment", "id", "cursor"],
9506
+ "observation show": ["environment", "batch-id", "event-id"]
9507
+ };
9508
+ var FilterValues = z14.object({
9509
+ provider: z14.enum([
9510
+ "siteos_analytics",
9511
+ "ga4",
9512
+ "google_ads",
9513
+ "hubspot",
9514
+ "meta",
9515
+ "custom"
9516
+ ]).optional(),
9517
+ event: z14.string().min(1).max(160).optional(),
9518
+ property: z14.string().min(1).max(160).optional(),
9519
+ "page-view": z14.string().uuid().optional(),
9520
+ search: z14.string().max(160).optional(),
9521
+ state: z14.enum([
9522
+ "all",
9523
+ "active",
9524
+ "snoozed",
9525
+ "resolved",
9526
+ "new",
9527
+ "issues",
9528
+ "tracked",
9529
+ "ignored"
9530
+ ]).optional(),
9531
+ rule: z14.string().min(1).max(80).optional(),
9532
+ kind: z14.enum([
9533
+ "data_layer",
9534
+ "fetch",
9535
+ "xhr",
9536
+ "beacon",
9537
+ "resource",
9538
+ "consent",
9539
+ "heartbeat",
9540
+ "runtime_diagnostic"
9541
+ ]).optional(),
9542
+ period: z14.enum(["24h", "7d"]).optional(),
9543
+ cursor: z14.string().min(1).max(4096).optional()
9544
+ });
9545
+ function traceExplorerSuffix(route, values) {
9546
+ if (!TRACE_EXPLORER_FLAGS[route]) return null;
9547
+ const query = new URLSearchParams();
9548
+ if (route === "issue show" || route === "observation show") {
9549
+ const keys = route === "issue show" ? ["id"] : ["batch-id", "event-id"];
9550
+ for (const key of keys) {
9551
+ if (!z14.string().uuid().safeParse(values[key]).success)
9552
+ throw new Error(`Use --${key} with the UUID returned by Trace.`);
9553
+ }
9554
+ if (values.cursor !== void 0) {
9555
+ if (!z14.string().uuid().safeParse(values.cursor).success)
9556
+ throw new Error(
9557
+ "Use --cursor with the nextCursor returned by this issue."
9558
+ );
9559
+ query.set("cursor", values.cursor);
9560
+ }
9561
+ const suffix = route === "issue show" ? `/issues/${encodeURIComponent(values.id)}` : `/observations/${encodeURIComponent(values["batch-id"])}/${encodeURIComponent(values["event-id"])}`;
9562
+ return `${suffix}${query.size ? `?${query}` : ""}`;
9563
+ }
9564
+ const parsed = FilterValues.safeParse(values);
9565
+ if (!parsed.success) {
9566
+ const flag = parsed.error.issues[0]?.path[0];
9567
+ throw new Error(
9568
+ `Invalid --${String(flag)} filter. Run \`siteos trace --help\`.`
9569
+ );
9570
+ }
9571
+ for (const [key, value] of Object.entries(parsed.data)) {
9572
+ if (value !== void 0)
9573
+ query.set(key === "page-view" ? "pageView" : key, value);
9574
+ }
9575
+ return `/${route}${query.size ? `?${query}` : ""}`;
9576
+ }
9577
+ function tracePublicationVersion(value) {
9578
+ if (value === void 0) return void 0;
9579
+ if (!/^[1-9]\d*$/u.test(value) || !Number.isSafeInteger(Number(value)))
9580
+ throw new Error(
9581
+ "Use --expected-draft-version with a positive integer from the reviewed plan."
9582
+ );
9583
+ return Number(value);
9584
+ }
9585
+
9586
+ // src/services/service-command.ts
9483
9587
  var SERVICE_HELP = {
9484
9588
  cookie: `Manage Cookie for the selected SiteOS Project.
9485
9589
 
@@ -9506,12 +9610,27 @@ Usage:
9506
9610
  siteos trace status [--json]
9507
9611
  siteos trace environments [--json]
9508
9612
  siteos trace report [--environment <slug>] [--json]
9613
+ siteos trace destinations [--environment <slug>] [--period <24h|7d>] [--cursor <cursor>] [--json]
9614
+ siteos trace events [--environment <slug>] [--provider <provider>] [--event <name>] [--search <text>] [--state <all|new|issues|tracked|ignored>] [--period <24h|7d>] [--cursor <cursor>] [--json]
9615
+ siteos trace properties [--environment <slug>] [--provider <provider>] [--event <name>] [--property <name>] [--search <text>] [--period <24h|7d>] [--cursor <cursor>] [--json]
9616
+ siteos trace issues [--environment <slug>] [--provider <provider>] [--event <name>] [--state <all|active|snoozed|resolved|new>] [--rule <rule>] [--search <text>] [--period <24h|7d>] [--cursor <cursor>] [--json]
9617
+ siteos trace observations [--environment <slug>] [--provider <provider>] [--event <name>] [--kind <kind>] [--page-view <uuid>] [--search <text>] [--period <24h|7d>] [--cursor <cursor>] [--json]
9618
+ siteos trace issue show --id <uuid> [--environment <slug>] [--cursor <finding-cursor>] [--json]
9619
+ siteos trace observation show --batch-id <uuid> --event-id <uuid> [--environment <slug>] [--json]
9509
9620
  siteos trace installation <show|ensure|save|publish> [--environment <slug>] [--input <draft.json>] [--json]
9510
9621
  siteos trace tracking-plan <show|ensure|save|publish> [--environment <slug>] [--input <plan.json>] [--json]
9622
+ siteos trace tracking-plan publish --expected-draft-version <number> [--environment <slug>] [--json]
9511
9623
 
9512
9624
  Start with siteos project use, then siteos project connect trace.
9513
9625
  Commands use the selected Project environment. Save requires --input with expectedDraftVersion.
9514
- Ensure creates a draft; publish activates the reviewed configuration.`,
9626
+ Ensure creates a draft; publish activates the reviewed configuration.
9627
+ Use --expected-draft-version when publishing a reviewed tracking plan; a conflict needs a fresh review.
9628
+ Explorer commands require the matching Trace server. They read one page and return nextCursor.
9629
+ Reuse the same filters with that cursor; omit it to start a fresh time window.
9630
+ Providers: siteos_analytics, ga4, google_ads, hubspot, meta, custom (data layer source).
9631
+ Kinds: data_layer, fetch, xhr, beacon, resource, consent, heartbeat, runtime_diagnostic.
9632
+ Lists also accept --provider, --event, --property, --page-view, --search, --state, --rule and --kind.
9633
+ Destinations are observed analytics services; a data layer event alone does not prove delivery.`,
9515
9634
  integrations: `Manage shared Organization connections and notification destinations.
9516
9635
 
9517
9636
  Usage:
@@ -9544,7 +9663,20 @@ async function runServiceCommand(service, options) {
9544
9663
  subdivision: { type: "string" },
9545
9664
  source: { type: "string" },
9546
9665
  url: { type: "string" },
9547
- browser: { type: "string" }
9666
+ browser: { type: "string" },
9667
+ provider: { type: "string" },
9668
+ event: { type: "string" },
9669
+ property: { type: "string" },
9670
+ "page-view": { type: "string" },
9671
+ search: { type: "string" },
9672
+ state: { type: "string" },
9673
+ rule: { type: "string" },
9674
+ kind: { type: "string" },
9675
+ period: { type: "string" },
9676
+ id: { type: "string" },
9677
+ "batch-id": { type: "string" },
9678
+ "event-id": { type: "string" },
9679
+ "expected-draft-version": { type: "string" }
9548
9680
  }
9549
9681
  });
9550
9682
  const [action, subaction] = positionals;
@@ -9567,6 +9699,7 @@ async function runServiceCommand(service, options) {
9567
9699
  status: [],
9568
9700
  environments: [],
9569
9701
  report: ["environment"],
9702
+ ...TRACE_EXPLORER_FLAGS,
9570
9703
  ...Object.fromEntries(
9571
9704
  ["installation", "tracking-plan"].flatMap(
9572
9705
  (section) => ["show", "ensure", "save", "publish"].map((operation) => [
@@ -9574,7 +9707,8 @@ async function runServiceCommand(service, options) {
9574
9707
  operation === "save" ? ["environment", "input"] : ["environment"]
9575
9708
  ])
9576
9709
  )
9577
- )
9710
+ ),
9711
+ "tracking-plan publish": ["environment", "expected-draft-version"]
9578
9712
  },
9579
9713
  integrations: {
9580
9714
  status: [],
@@ -9598,6 +9732,10 @@ async function runServiceCommand(service, options) {
9598
9732
  throw new Error(
9599
9733
  "Destination creation requires --channel <provider-channel-id>."
9600
9734
  );
9735
+ const explorerSuffix = service === "trace" ? traceExplorerSuffix(route, values) : null;
9736
+ const expectedDraftVersion = tracePublicationVersion(
9737
+ values["expected-draft-version"]
9738
+ );
9601
9739
  const runtime = commonProjectRuntime(options);
9602
9740
  const common = service === "integrations" ? null : await commonServiceContext(
9603
9741
  options,
@@ -9637,8 +9775,8 @@ async function runServiceCommand(service, options) {
9637
9775
  );
9638
9776
  const result2 = await response.json();
9639
9777
  if (!response.ok) {
9640
- const error = z15.object({
9641
- error: z15.object({ code: z15.string(), message: z15.string().max(500) })
9778
+ const error = z16.object({
9779
+ error: z16.object({ code: z16.string(), message: z16.string().max(500) })
9642
9780
  }).safeParse(result2);
9643
9781
  throw new SiteOSAuthApiError({
9644
9782
  code: error.success ? error.data.error.code : "SERVICE_REQUEST_FAILED",
@@ -9670,9 +9808,9 @@ async function runServiceCommand(service, options) {
9670
9808
  await inputFile(),
9671
9809
  "cookie:workspace:read"
9672
9810
  );
9673
- const validation = z15.object({
9674
- valid: z15.boolean(),
9675
- draftVersionMatches: z15.boolean().optional()
9811
+ const validation = z16.object({
9812
+ valid: z16.boolean(),
9813
+ draftVersionMatches: z16.boolean().optional()
9676
9814
  }).parse(result);
9677
9815
  if (!validation.valid || validation.draftVersionMatches === false)
9678
9816
  return { exitCode: 2, stdout: JSON.stringify(result, null, 2) };
@@ -9711,11 +9849,11 @@ async function runServiceCommand(service, options) {
9711
9849
  } else if (action === "installation")
9712
9850
  result = await request(`${site}/installation`);
9713
9851
  else if (action === "draft" && subaction === "get" && positionals.length === 2) {
9714
- const response = z15.object({
9715
- name: z15.string(),
9716
- hostname: z15.string(),
9717
- draftVersion: z15.number(),
9718
- draft: z15.unknown()
9852
+ const response = z16.object({
9853
+ name: z16.string(),
9854
+ hostname: z16.string(),
9855
+ draftVersion: z16.number(),
9856
+ draft: z16.unknown()
9719
9857
  }).parse(await request(site));
9720
9858
  result = {
9721
9859
  name: response.name,
@@ -9746,10 +9884,10 @@ async function runServiceCommand(service, options) {
9746
9884
  result = await request(site);
9747
9885
  else if (action === "environments" && positionals.length === 1)
9748
9886
  result = await request(`${site}/environments`);
9749
- else if (action === "report" || action === "installation" || action === "tracking-plan") {
9750
- const response = z15.object({
9751
- environments: z15.array(
9752
- z15.object({ id: z15.string(), slug: z15.string() })
9887
+ else if (action === "report" || action === "installation" || action === "tracking-plan" || explorerSuffix !== null) {
9888
+ const response = z16.object({
9889
+ environments: z16.array(
9890
+ z16.object({ id: z16.string(), slug: z16.string() })
9753
9891
  )
9754
9892
  }).parse(await request(`${site}/environments`));
9755
9893
  const environment = common.overview.project.environments.find(
@@ -9773,12 +9911,14 @@ async function runServiceCommand(service, options) {
9773
9911
  "Choose an environment from `siteos trace environments`."
9774
9912
  );
9775
9913
  const base = `/environments/${encodeURIComponent(matches[0].id)}`;
9776
- if (action === "report" && positionals.length === 1) {
9777
- const detail = z15.object({
9778
- site: z15.object({
9779
- id: z15.literal(common.resourceId),
9780
- environments: z15.array(
9781
- z15.object({ id: z15.string(), evidence: z15.unknown() })
9914
+ if (explorerSuffix !== null) {
9915
+ result = await request(`${base}${explorerSuffix}`);
9916
+ } else if (action === "report" && positionals.length === 1) {
9917
+ const detail = z16.object({
9918
+ site: z16.object({
9919
+ id: z16.literal(common.resourceId),
9920
+ environments: z16.array(
9921
+ z16.object({ id: z16.string(), evidence: z16.unknown() })
9782
9922
  )
9783
9923
  })
9784
9924
  }).parse(await request(site));
@@ -9800,7 +9940,7 @@ async function runServiceCommand(service, options) {
9800
9940
  result = await request(
9801
9941
  `${base}/${action}/${subaction}`,
9802
9942
  "POST",
9803
- {},
9943
+ expectedDraftVersion === void 0 ? {} : { expectedDraftVersion },
9804
9944
  subaction === "publish" ? "trace:publication:write" : void 0
9805
9945
  );
9806
9946
  else
@@ -9836,7 +9976,7 @@ async function runServiceCommand(service, options) {
9836
9976
  } catch (cause) {
9837
9977
  return {
9838
9978
  exitCode: cause instanceof SiteOSAuthApiError ? 1 : 2,
9839
- stderr: cause instanceof SiteOSAuthApiError || !(cause instanceof z15.ZodError) && cause instanceof Error ? cause.message : "The service returned an invalid response."
9979
+ stderr: cause instanceof SiteOSAuthApiError || !(cause instanceof z16.ZodError) && cause instanceof Error ? cause.message : "The service returned an invalid response."
9840
9980
  };
9841
9981
  }
9842
9982
  }
@@ -9845,7 +9985,7 @@ async function runServiceCommand(service, options) {
9845
9985
  import { readFile as readFile17, stat as stat2 } from "fs/promises";
9846
9986
  import path29 from "path";
9847
9987
  import { parseArgs as parseArgs4 } from "util";
9848
- import { z as z16 } from "zod";
9988
+ import { z as z17 } from "zod";
9849
9989
  var ANALYTICS_HELP = `Set up website Analytics in the selected Project environment.
9850
9990
 
9851
9991
  Usage:
@@ -9876,27 +10016,27 @@ Settings require an owner/admin, the current revision and at least one change.
9876
10016
  Catalog files are bounded JSON using the documented event/campaign/goal/funnel contracts.
9877
10017
  Monitoring preparation creates a Trace draft only; publication remains a separate operation.
9878
10018
  Analytics is Unlimited during early access. No synthetic events are sent by these commands.`;
9879
- var EventInput = z16.object({
9880
- name: z16.string().regex(/^[a-z][a-z0-9_]{0,63}$/u).refine((v) => v !== "pageview" && !v.startsWith("cookie_")),
9881
- label: z16.string().trim().min(1).max(80),
9882
- properties: z16.record(
9883
- z16.string().regex(/^[a-z][a-z0-9_]{0,39}$/u),
9884
- z16.array(
9885
- z16.string().min(1).max(80).regex(/^[a-zA-Z0-9 _./:-]+$/u)
10019
+ var EventInput = z17.object({
10020
+ name: z17.string().regex(/^[a-z][a-z0-9_]{0,63}$/u).refine((v) => v !== "pageview" && !v.startsWith("cookie_")),
10021
+ label: z17.string().trim().min(1).max(80),
10022
+ properties: z17.record(
10023
+ z17.string().regex(/^[a-z][a-z0-9_]{0,39}$/u),
10024
+ z17.array(
10025
+ z17.string().min(1).max(80).regex(/^[a-zA-Z0-9 _./:-]+$/u)
9886
10026
  ).min(1).max(20)
9887
10027
  ).refine((v) => Object.keys(v).length <= 8)
9888
10028
  }).strict();
9889
- var Resource = z16.object({
9890
- id: z16.string(),
9891
- organizationId: z16.string(),
9892
- name: z16.string(),
9893
- slug: z16.string(),
9894
- origin: z16.string().url(),
9895
- publicKey: z16.string(),
9896
- revision: z16.number().int().positive(),
9897
- enabled: z16.boolean(),
9898
- cookieEvents: z16.boolean(),
9899
- minimalRealtime: z16.boolean()
10029
+ var Resource = z17.object({
10030
+ id: z17.string(),
10031
+ organizationId: z17.string(),
10032
+ name: z17.string(),
10033
+ slug: z17.string(),
10034
+ origin: z17.string().url(),
10035
+ publicKey: z17.string(),
10036
+ revision: z17.number().int().positive(),
10037
+ enabled: z17.boolean(),
10038
+ cookieEvents: z17.boolean(),
10039
+ minimalRealtime: z17.boolean()
9900
10040
  });
9901
10041
  var readKeys = [
9902
10042
  "days",
@@ -10022,7 +10162,7 @@ async function runAnalyticsCommand(options) {
10022
10162
  throw new Error("Use --days 1, 7 or 28.");
10023
10163
  if (values.country && !/^(?:[A-Z]{2}|unknown)$/u.test(values.country))
10024
10164
  throw new Error("Use an uppercase ISO country code or unknown.");
10025
- if (values.campaign) z16.string().uuid().parse(values.campaign);
10165
+ if (values.campaign) z17.string().uuid().parse(values.campaign);
10026
10166
  const setting = route === "settings set", creating = positionals[1] === "create", archive = positionals[1] === "archive";
10027
10167
  let body;
10028
10168
  if (setting) {
@@ -10058,9 +10198,9 @@ async function runAnalyticsCommand(options) {
10058
10198
  } catch {
10059
10199
  throw new Error("The definition must contain valid JSON.");
10060
10200
  }
10061
- body = z16.record(z16.unknown()).parse(definition);
10201
+ body = z17.record(z17.unknown()).parse(definition);
10062
10202
  if (action === "events") body = EventInput.parse(body);
10063
- } else if (archive) body = { id: z16.string().uuid().parse(positionals[2]) };
10203
+ } else if (archive) body = { id: z17.string().uuid().parse(positionals[2]) };
10064
10204
  const context = await commonServiceContext(
10065
10205
  options,
10066
10206
  "analytics",
@@ -10101,8 +10241,8 @@ async function runAnalyticsCommand(options) {
10101
10241
  );
10102
10242
  const value = await response.json();
10103
10243
  if (!response.ok) {
10104
- const error = z16.object({
10105
- error: z16.object({ code: z16.string(), message: z16.string().max(500) })
10244
+ const error = z17.object({
10245
+ error: z17.object({ code: z17.string(), message: z17.string().max(500) })
10106
10246
  }).safeParse(value);
10107
10247
  throw new SiteOSAuthApiError({
10108
10248
  code: error.success ? error.data.error.code : "ANALYTICS_REQUEST_FAILED",
@@ -10110,9 +10250,9 @@ async function runAnalyticsCommand(options) {
10110
10250
  status: response.status
10111
10251
  });
10112
10252
  }
10113
- const record = z16.object({
10114
- contractVersion: z16.literal(1),
10115
- resourceId: z16.literal(context.resourceId)
10253
+ const record = z17.object({
10254
+ contractVersion: z17.literal(1),
10255
+ resourceId: z17.literal(context.resourceId)
10116
10256
  }).passthrough().parse(value);
10117
10257
  let output;
10118
10258
  if (setting) {
@@ -10131,16 +10271,16 @@ async function runAnalyticsCommand(options) {
10131
10271
  throw new Error("The saved event does not match this definition.");
10132
10272
  } else
10133
10273
  output = {
10134
- id: z16.string().uuid().parse(record.id),
10274
+ id: z17.string().uuid().parse(record.id),
10135
10275
  ...pick(
10136
10276
  record,
10137
10277
  action === "campaigns" ? ["label", "source", "medium", "campaign"] : action === "goals" ? ["label", "match"] : ["label", "steps"]
10138
10278
  )
10139
10279
  };
10140
10280
  } else if (archive)
10141
- output = { archived: z16.literal(true).parse(record.archived) };
10281
+ output = { archived: z17.literal(true).parse(record.archived) };
10142
10282
  else if (route === "monitoring prepare")
10143
- output = { state: z16.literal("prepared").parse(record.state) };
10283
+ output = { state: z17.literal("prepared").parse(record.state) };
10144
10284
  else if (action === "realtime") output = pick(record, liveKeys);
10145
10285
  else {
10146
10286
  const resource = Resource.parse(record.resource);
@@ -10152,8 +10292,8 @@ async function runAnalyticsCommand(options) {
10152
10292
  output = {
10153
10293
  resource,
10154
10294
  lastReceivedAt: record.lastReceivedAt,
10155
- consentSource: z16.object({
10156
- consentSource: z16.enum([
10295
+ consentSource: z17.object({
10296
+ consentSource: z17.enum([
10157
10297
  "cookie",
10158
10298
  "external",
10159
10299
  "waiting_for_cookie",
@@ -10165,11 +10305,11 @@ async function runAnalyticsCommand(options) {
10165
10305
  else if (action === "installation")
10166
10306
  output = {
10167
10307
  resource,
10168
- installation: z16.string().parse(record.installation),
10308
+ installation: z17.string().parse(record.installation),
10169
10309
  configuration: record.configuration
10170
10310
  };
10171
10311
  else if (action === "events") {
10172
- const definitions = z16.array(EventInput).parse(record.definitions);
10312
+ const definitions = z17.array(EventInput).parse(record.definitions);
10173
10313
  if (route === "events snippet") {
10174
10314
  const definition = definitions.find((d) => d.name === positionals[2]);
10175
10315
  if (!definition)
@@ -10183,13 +10323,13 @@ async function runAnalyticsCommand(options) {
10183
10323
  };
10184
10324
  } else output = { definitions, eventCounts: record.eventCounts };
10185
10325
  } else
10186
- output = action === "report" ? pick(record, readKeys) : { [action]: z16.array(z16.unknown()).parse(record[action]) };
10326
+ output = action === "report" ? pick(record, readKeys) : { [action]: z17.array(z17.unknown()).parse(record[action]) };
10187
10327
  }
10188
10328
  return { exitCode: 0, stdout: JSON.stringify(output, null, 2) };
10189
10329
  } catch (cause) {
10190
10330
  const error = cause instanceof SiteOSAuthApiError ? { code: cause.code, message: cause.message } : {
10191
10331
  code: "ANALYTICS_COMMAND_FAILED",
10192
- message: cause instanceof z16.ZodError ? "The Analytics input or response does not match the supported contract." : cause instanceof Error ? cause.message : "The Analytics command failed."
10332
+ message: cause instanceof z17.ZodError ? "The Analytics input or response does not match the supported contract." : cause instanceof Error ? cause.message : "The Analytics command failed."
10193
10333
  };
10194
10334
  return {
10195
10335
  exitCode: cause instanceof SiteOSAuthApiError ? 1 : 2,
@@ -10202,7 +10342,7 @@ async function runAnalyticsCommand(options) {
10202
10342
  import { writeFile as writeFile9 } from "fs/promises";
10203
10343
  import path31 from "path";
10204
10344
  import { parseArgs as parseArgs6 } from "util";
10205
- import { z as z18 } from "zod";
10345
+ import { z as z19 } from "zod";
10206
10346
 
10207
10347
  // src/services/seo-performance-command.ts
10208
10348
  import { randomUUID as randomUUID6 } from "crypto";
@@ -10210,7 +10350,7 @@ import { writeFile as writeFile8 } from "fs/promises";
10210
10350
  import path30 from "path";
10211
10351
  import { setTimeout as setTimeout2 } from "timers/promises";
10212
10352
  import { parseArgs as parseArgs5 } from "util";
10213
- import { z as z17 } from "zod";
10353
+ import { z as z18 } from "zod";
10214
10354
  var PERFORMANCE_HELP = `
10215
10355
  siteos seo performance run --audit <id> --url <url> [--url <url>...] [--device <mobile|desktop>] [--idempotency-key <key>] [--environment <slug>] [--json]
10216
10356
  siteos seo performance list [--device <mobile|desktop>] [--environment <slug>] [--json]
@@ -10298,12 +10438,12 @@ async function runSeoPerformanceCommand(options) {
10298
10438
  const runtime = commonProjectRuntime(options);
10299
10439
  const writing = ["run", "cancel"].includes(action);
10300
10440
  const scope = writing ? "seo:audits:write" : "seo:workspace:read";
10301
- const batchSchema = z17.object({
10302
- id: z17.string(),
10303
- resourceId: z17.literal(context.resourceId),
10304
- organizationId: z17.literal(context.overview.project.organizationId),
10305
- sourceAuditId: z17.string(),
10306
- state: z17.enum([
10441
+ const batchSchema = z18.object({
10442
+ id: z18.string(),
10443
+ resourceId: z18.literal(context.resourceId),
10444
+ organizationId: z18.literal(context.overview.project.organizationId),
10445
+ sourceAuditId: z18.string(),
10446
+ state: z18.enum([
10307
10447
  "queued",
10308
10448
  "running",
10309
10449
  "completed",
@@ -10311,8 +10451,8 @@ async function runSeoPerformanceCommand(options) {
10311
10451
  "failed",
10312
10452
  "cancelled"
10313
10453
  ]),
10314
- device: z17.enum(["mobile", "desktop"]),
10315
- urls: z17.array(z17.string()).min(1).max(10)
10454
+ device: z18.enum(["mobile", "desktop"]),
10455
+ urls: z18.array(z18.string()).min(1).max(10)
10316
10456
  }).passthrough();
10317
10457
  const query = new URLSearchParams();
10318
10458
  if (values.device) query.set("device", values.device);
@@ -10360,10 +10500,10 @@ async function runSeoPerformanceCommand(options) {
10360
10500
  );
10361
10501
  const text = await response.text();
10362
10502
  if (values.format === "json") {
10363
- const parsed = z17.object({
10364
- contractVersion: z17.literal(1),
10503
+ const parsed = z18.object({
10504
+ contractVersion: z18.literal(1),
10365
10505
  batch: batchSchema,
10366
- pages: z17.array(z17.unknown())
10506
+ pages: z18.array(z18.unknown())
10367
10507
  }).parse(JSON.parse(text));
10368
10508
  if (parsed.batch.id !== id)
10369
10509
  throw new Error(
@@ -10386,8 +10526,8 @@ async function runSeoPerformanceCommand(options) {
10386
10526
  }
10387
10527
  const data = await response.json();
10388
10528
  if (!response.ok) {
10389
- const error = z17.object({
10390
- error: z17.object({ code: z17.string(), message: z17.string().max(500) })
10529
+ const error = z18.object({
10530
+ error: z18.object({ code: z18.string(), message: z18.string().max(500) })
10391
10531
  }).safeParse(data);
10392
10532
  throw new SiteOSAuthApiError({
10393
10533
  code: error.success ? error.data.error.code : "SEO_REQUEST_FAILED",
@@ -10395,8 +10535,8 @@ async function runSeoPerformanceCommand(options) {
10395
10535
  status: response.status
10396
10536
  });
10397
10537
  }
10398
- const record = z17.object({ contractVersion: z17.literal(1) }).passthrough().parse(data);
10399
- if (action === "cancel") z17.literal(true).parse(record.cancelled);
10538
+ const record = z18.object({ contractVersion: z18.literal(1) }).passthrough().parse(data);
10539
+ if (action === "cancel") z18.literal(true).parse(record.cancelled);
10400
10540
  else if (action === "run") {
10401
10541
  const accepted = batchSchema.parse(record.batch);
10402
10542
  const normalize = (url) => {
@@ -10409,8 +10549,8 @@ async function runSeoPerformanceCommand(options) {
10409
10549
  "The queued check does not match the requested source, device and URLs."
10410
10550
  );
10411
10551
  } else {
10412
- z17.literal(context.resourceId).parse(record.resourceId);
10413
- z17.array(batchSchema).parse(record.batches);
10552
+ z18.literal(context.resourceId).parse(record.resourceId);
10553
+ z18.array(batchSchema).parse(record.batches);
10414
10554
  const selected = batchSchema.nullable().parse(record.batch);
10415
10555
  if (id && selected?.id !== id)
10416
10556
  throw new Error(
@@ -10437,7 +10577,7 @@ async function runSeoPerformanceCommand(options) {
10437
10577
  } catch (cause) {
10438
10578
  const error = {
10439
10579
  code: cause instanceof SiteOSAuthApiError ? cause.code : "SEO_COMMAND_FAILED",
10440
- message: cause instanceof z17.ZodError ? "The SEO service returned an invalid response." : cause instanceof Error ? cause.message : "The performance command failed."
10580
+ message: cause instanceof z18.ZodError ? "The SEO service returned an invalid response." : cause instanceof Error ? cause.message : "The performance command failed."
10441
10581
  };
10442
10582
  return {
10443
10583
  exitCode: cause instanceof SiteOSAuthApiError ? 1 : 2,
@@ -10703,15 +10843,15 @@ async function runSeoCommand(options) {
10703
10843
  );
10704
10844
  const text = await response.text();
10705
10845
  if (values.format === "json")
10706
- z18.object({
10707
- contractVersion: z18.literal(1),
10708
- audit: z18.object({
10709
- id: z18.literal(values.audit),
10710
- resourceId: z18.literal(context.resourceId)
10846
+ z19.object({
10847
+ contractVersion: z19.literal(1),
10848
+ audit: z19.object({
10849
+ id: z19.literal(values.audit),
10850
+ resourceId: z19.literal(context.resourceId)
10711
10851
  }),
10712
- kind: z18.literal(values.kind),
10713
- totalRows: z18.literal(rows),
10714
- rows: z18.array(z18.unknown()).length(rows)
10852
+ kind: z19.literal(values.kind),
10853
+ totalRows: z19.literal(rows),
10854
+ rows: z19.array(z19.unknown()).length(rows)
10715
10855
  }).parse(JSON.parse(text));
10716
10856
  const output = path31.resolve(options.cwd ?? process.cwd(), values.output);
10717
10857
  await writeFile9(output, text, { flag: "wx", mode: 384 });
@@ -10732,8 +10872,8 @@ async function runSeoCommand(options) {
10732
10872
  }
10733
10873
  const data = await response.json();
10734
10874
  if (!response.ok) {
10735
- const result = z18.object({
10736
- error: z18.object({ code: z18.string(), message: z18.string().max(500) })
10875
+ const result = z19.object({
10876
+ error: z19.object({ code: z19.string(), message: z19.string().max(500) })
10737
10877
  }).safeParse(data);
10738
10878
  throw new SiteOSAuthApiError({
10739
10879
  code: result.success ? result.data.error.code : "SEO_REQUEST_FAILED",
@@ -10741,34 +10881,34 @@ async function runSeoCommand(options) {
10741
10881
  status: response.status
10742
10882
  });
10743
10883
  }
10744
- const record = z18.object({ contractVersion: z18.literal(1) }).passthrough().parse(data);
10884
+ const record = z19.object({ contractVersion: z19.literal(1) }).passthrough().parse(data);
10745
10885
  if (automation) {
10746
- z18.literal(context.resourceId).parse(record.resourceId);
10747
- const schedule = z18.object({
10748
- enabled: z18.boolean(),
10749
- weekday: z18.number().int().min(1).max(7),
10750
- time: z18.string(),
10751
- timeZone: z18.string(),
10752
- revision: z18.number().int().min(0),
10753
- nextRunAt: z18.string().nullable()
10886
+ z19.literal(context.resourceId).parse(record.resourceId);
10887
+ const schedule = z19.object({
10888
+ enabled: z19.boolean(),
10889
+ weekday: z19.number().int().min(1).max(7),
10890
+ time: z19.string(),
10891
+ timeZone: z19.string(),
10892
+ revision: z19.number().int().min(0),
10893
+ nextRunAt: z19.string().nullable()
10754
10894
  });
10755
- const notificationRoute = z18.object({
10756
- enabled: z18.boolean(),
10757
- minimumSeverity: z18.enum(["error", "warning"]),
10758
- includeFailures: z18.boolean(),
10759
- revision: z18.number().int().min(0),
10760
- destinationId: z18.string().nullable()
10895
+ const notificationRoute = z19.object({
10896
+ enabled: z19.boolean(),
10897
+ minimumSeverity: z19.enum(["error", "warning"]),
10898
+ includeFailures: z19.boolean(),
10899
+ revision: z19.number().int().min(0),
10900
+ destinationId: z19.string().nullable()
10761
10901
  });
10762
10902
  if (retryNotification) {
10763
- z18.literal(true).parse(record.retryQueued);
10764
- z18.literal(positionals[2]).parse(record.notificationId);
10903
+ z19.literal(true).parse(record.retryQueued);
10904
+ z19.literal(positionals[2]).parse(record.notificationId);
10765
10905
  } else if (route === "notifications destinations")
10766
- z18.object({
10767
- candidates: z18.array(
10768
- z18.object({
10769
- candidateId: z18.string(),
10770
- label: z18.string(),
10771
- availability: z18.literal("available")
10906
+ z19.object({
10907
+ candidates: z19.array(
10908
+ z19.object({
10909
+ candidateId: z19.string(),
10910
+ label: z19.string(),
10911
+ availability: z19.literal("available")
10772
10912
  })
10773
10913
  )
10774
10914
  }).parse(record);
@@ -10781,46 +10921,46 @@ async function runSeoCommand(options) {
10781
10921
  notificationRoute.parse(record.route);
10782
10922
  }
10783
10923
  } else if (!writing) {
10784
- const validated = z18.object({
10785
- resource: z18.object({
10786
- id: z18.literal(context.resourceId),
10787
- organizationId: z18.literal(context.overview.project.organizationId)
10924
+ const validated = z19.object({
10925
+ resource: z19.object({
10926
+ id: z19.literal(context.resourceId),
10927
+ organizationId: z19.literal(context.overview.project.organizationId)
10788
10928
  }),
10789
- audits: z18.array(z18.object({ id: z18.string() }).passthrough()),
10790
- audit: z18.object({
10791
- id: z18.string(),
10792
- resourceId: z18.literal(context.resourceId)
10929
+ audits: z19.array(z19.object({ id: z19.string() }).passthrough()),
10930
+ audit: z19.object({
10931
+ id: z19.string(),
10932
+ resourceId: z19.literal(context.resourceId)
10793
10933
  }).passthrough().nullable(),
10794
- pages: z18.array(z18.unknown()),
10795
- issues: z18.array(z18.unknown()),
10796
- changes: z18.array(z18.unknown()),
10797
- totalChanges: z18.number(),
10798
- dispositions: z18.array(z18.unknown())
10934
+ pages: z19.array(z19.unknown()),
10935
+ issues: z19.array(z19.unknown()),
10936
+ changes: z19.array(z19.unknown()),
10937
+ totalChanges: z19.number(),
10938
+ dispositions: z19.array(z19.unknown())
10799
10939
  }).passthrough().parse(record);
10800
10940
  const selected = query.get("audit");
10801
10941
  if (selected && validated.audit?.id !== selected)
10802
10942
  throw new Error("The SEO response does not match the requested audit.");
10803
10943
  } else if (record.audit)
10804
- z18.object({
10805
- id: z18.string(),
10806
- resourceId: z18.literal(context.resourceId),
10807
- organizationId: z18.literal(context.overview.project.organizationId),
10808
- state: z18.literal("queued")
10944
+ z19.object({
10945
+ id: z19.string(),
10946
+ resourceId: z19.literal(context.resourceId),
10947
+ organizationId: z19.literal(context.overview.project.organizationId),
10948
+ state: z19.literal("queued")
10809
10949
  }).parse(record.audit);
10810
- else if (route === "audit cancel") z18.literal(true).parse(record.cancelled);
10950
+ else if (route === "audit cancel") z19.literal(true).parse(record.cancelled);
10811
10951
  else if (action === "issue")
10812
- z18.object({
10813
- url: z18.literal(values.url),
10814
- ruleId: z18.literal(values.rule),
10815
- ignored: z18.literal(positionals[1] === "ignore"),
10816
- revision: z18.literal(Number(values.revision) + 1)
10952
+ z19.object({
10953
+ url: z19.literal(values.url),
10954
+ ruleId: z19.literal(values.rule),
10955
+ ignored: z19.literal(positionals[1] === "ignore"),
10956
+ revision: z19.literal(Number(values.revision) + 1)
10817
10957
  }).parse(record.disposition);
10818
10958
  else throw new Error("The SEO service returned an invalid response.");
10819
10959
  return { exitCode: 0, stdout: JSON.stringify(record, null, 2) };
10820
10960
  } catch (cause) {
10821
10961
  const error = {
10822
10962
  code: cause instanceof SiteOSAuthApiError ? cause.code : "SEO_COMMAND_FAILED",
10823
- message: cause instanceof z18.ZodError ? "The SEO service returned an invalid response." : cause instanceof Error ? cause.message : "The SEO command failed."
10963
+ message: cause instanceof z19.ZodError ? "The SEO service returned an invalid response." : cause instanceof Error ? cause.message : "The SEO command failed."
10824
10964
  };
10825
10965
  return {
10826
10966
  exitCode: cause instanceof SiteOSAuthApiError ? 1 : 2,