@ainyc/canonry 4.11.0 → 4.12.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.
@@ -12,7 +12,7 @@ import {
12
12
  queryGenerateRequestSchema,
13
13
  runTriggerRequestSchema,
14
14
  scheduleUpsertRequestSchema
15
- } from "./chunk-WWU65YPN.js";
15
+ } from "./chunk-YDGT5CAY.js";
16
16
 
17
17
  // src/config.ts
18
18
  import fs from "fs";
@@ -753,6 +753,21 @@ var ApiClient = class {
753
753
  const qs = params ? "?" + new URLSearchParams(params).toString() : "";
754
754
  return this.request("GET", `/projects/${encodeURIComponent(project)}/ga/session-history${qs}`);
755
755
  }
756
+ // Traffic — server-side ingestion
757
+ async trafficConnectCloudRun(project, body) {
758
+ return this.request(
759
+ "POST",
760
+ `/projects/${encodeURIComponent(project)}/traffic/connect/cloud-run`,
761
+ body
762
+ );
763
+ }
764
+ async trafficSync(project, sourceId, body) {
765
+ return this.request(
766
+ "POST",
767
+ `/projects/${encodeURIComponent(project)}/traffic/sources/${encodeURIComponent(sourceId)}/sync`,
768
+ body ?? {}
769
+ );
770
+ }
756
771
  async wordpressConnect(project, body) {
757
772
  return this.request("POST", `/projects/${encodeURIComponent(project)}/wordpress/connect`, body);
758
773
  }
@@ -87,7 +87,8 @@ var runKindSchema = z2.enum([
87
87
  "ga-sync",
88
88
  "bing-inspect",
89
89
  "bing-inspect-sitemap",
90
- "backlink-extract"
90
+ "backlink-extract",
91
+ "traffic-sync"
91
92
  ]);
92
93
  var RunKinds = runKindSchema.enum;
93
94
  var runTriggerSchema = z2.enum(["manual", "scheduled", "config-apply"]);
@@ -1209,11 +1210,22 @@ var ga4AiReferralDtoSchema = z12.object({
1209
1210
  medium: z12.string(),
1210
1211
  sessions: z12.number(),
1211
1212
  users: z12.number(),
1213
+ /**
1214
+ * The winning attribution dimension for this (source, medium) tuple — the
1215
+ * one with the highest session count. GA4 emits one row per dimension
1216
+ * (session, first_user, manual_utm), but they're overlapping lenses on the
1217
+ * same visit; only the dominant dimension is surfaced here so the table is
1218
+ * not inflated.
1219
+ */
1212
1220
  sourceDimension: ga4SourceDimensionSchema
1213
1221
  });
1214
1222
  var ga4AiReferralLandingPageDtoSchema = z12.object({
1215
1223
  source: z12.string(),
1216
1224
  medium: z12.string(),
1225
+ /**
1226
+ * The winning attribution dimension for this (source, medium, landingPage)
1227
+ * tuple — the one with the highest session count.
1228
+ */
1217
1229
  sourceDimension: ga4SourceDimensionSchema,
1218
1230
  landingPage: z12.string(),
1219
1231
  sessions: z12.number(),
@@ -2173,6 +2185,52 @@ var normalizedTrafficPullPageSchema = z20.object({
2173
2185
  nextPageToken: z20.string().optional(),
2174
2186
  filter: z20.string()
2175
2187
  });
2188
+ var trafficSourceStatusSchema = z20.enum(["connected", "paused", "error", "archived"]);
2189
+ var TrafficSourceStatuses = trafficSourceStatusSchema.enum;
2190
+ var trafficSourceAuthModeSchema = z20.enum(["oauth", "service-account"]);
2191
+ var TrafficSourceAuthModes = trafficSourceAuthModeSchema.enum;
2192
+ var cloudRunSourceConfigSchema = z20.object({
2193
+ gcpProjectId: z20.string().min(1),
2194
+ serviceName: z20.string().nullable().optional(),
2195
+ location: z20.string().nullable().optional(),
2196
+ authMode: trafficSourceAuthModeSchema
2197
+ });
2198
+ var trafficSourceDtoSchema = z20.object({
2199
+ id: z20.string(),
2200
+ projectId: z20.string(),
2201
+ sourceType: trafficSourceTypeSchema,
2202
+ displayName: z20.string(),
2203
+ status: trafficSourceStatusSchema,
2204
+ lastSyncedAt: z20.string().nullable(),
2205
+ lastCursor: z20.string().nullable(),
2206
+ lastError: z20.string().nullable(),
2207
+ archivedAt: z20.string().nullable(),
2208
+ config: z20.record(z20.string(), z20.unknown()),
2209
+ createdAt: z20.string(),
2210
+ updatedAt: z20.string()
2211
+ });
2212
+ var trafficConnectCloudRunRequestSchema = z20.object({
2213
+ gcpProjectId: z20.string().min(1),
2214
+ serviceName: z20.string().min(1).optional(),
2215
+ location: z20.string().min(1).optional(),
2216
+ displayName: z20.string().min(1).optional(),
2217
+ /** Service-account JSON content (string). When omitted, defaults to OAuth via `canonry google connect <project> --type ga4` flow. */
2218
+ keyJson: z20.string().optional()
2219
+ });
2220
+ var trafficSyncResponseSchema = z20.object({
2221
+ sourceId: z20.string(),
2222
+ runId: z20.string(),
2223
+ syncedAt: z20.string(),
2224
+ pulledEvents: z20.number().int().nonnegative(),
2225
+ crawlerHits: z20.number().int().nonnegative(),
2226
+ aiReferralHits: z20.number().int().nonnegative(),
2227
+ unknownHits: z20.number().int().nonnegative(),
2228
+ crawlerBucketRows: z20.number().int().nonnegative(),
2229
+ aiReferralBucketRows: z20.number().int().nonnegative(),
2230
+ sampleRows: z20.number().int().nonnegative(),
2231
+ windowStart: z20.string(),
2232
+ windowEnd: z20.string()
2233
+ });
2176
2234
 
2177
2235
  export {
2178
2236
  __export,
@@ -2263,5 +2321,10 @@ export {
2263
2321
  dedupeReportOpportunities,
2264
2322
  CodingAgents,
2265
2323
  skillsClientSchema,
2266
- SkillsClients
2324
+ SkillsClients,
2325
+ TrafficSourceTypes,
2326
+ TrafficEvidenceKinds,
2327
+ TrafficEventConfidences,
2328
+ TrafficSourceStatuses,
2329
+ TrafficSourceAuthModes
2267
2330
  };