@ainyc/canonry 3.6.4 → 4.1.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.
@@ -168,8 +168,8 @@ var groundingSourceSchema = z2.object({
168
168
  var querySnapshotDtoSchema = z2.object({
169
169
  id: z2.string(),
170
170
  runId: z2.string(),
171
- keywordId: z2.string(),
172
- keyword: z2.string().optional(),
171
+ queryId: z2.string(),
172
+ query: z2.string().optional(),
173
173
  provider: providerNameSchema,
174
174
  citationState: citationStateSchema,
175
175
  answerMentioned: z2.boolean().optional(),
@@ -191,8 +191,8 @@ var snapshotListResponseSchema = z2.object({
191
191
  total: z2.number().int().nonnegative()
192
192
  });
193
193
  var snapshotDiffRowSchema = z2.object({
194
- keywordId: z2.string().nullable(),
195
- keyword: z2.string().nullable(),
194
+ queryId: z2.string().nullable(),
195
+ query: z2.string().nullable(),
196
196
  run1State: citationStateSchema.nullable(),
197
197
  run2State: citationStateSchema.nullable(),
198
198
  run1AnswerMentioned: z2.boolean().nullable(),
@@ -311,18 +311,27 @@ var projectDtoSchema = z4.object({
311
311
  createdAt: z4.string().optional(),
312
312
  updatedAt: z4.string().optional()
313
313
  });
314
+ var queryDtoSchema = z4.object({
315
+ id: z4.string(),
316
+ query: z4.string(),
317
+ createdAt: z4.string()
318
+ });
314
319
  var keywordDtoSchema = z4.object({
315
320
  id: z4.string(),
316
321
  keyword: z4.string(),
317
322
  createdAt: z4.string()
318
323
  });
324
+ var queryBatchRequestSchema = z4.object({
325
+ queries: z4.array(z4.string().trim().min(1)).min(1)
326
+ });
319
327
  var keywordBatchRequestSchema = z4.object({
320
328
  keywords: z4.array(z4.string().trim().min(1)).min(1)
321
329
  });
322
- var keywordGenerateRequestSchema = z4.object({
330
+ var queryGenerateRequestSchema = z4.object({
323
331
  provider: providerNameSchema,
324
332
  count: z4.number().int().min(1).max(20).optional()
325
333
  });
334
+ var keywordGenerateRequestSchema = queryGenerateRequestSchema;
326
335
  var competitorDtoSchema = z4.object({
327
336
  id: z4.string(),
328
337
  domain: z4.string(),
@@ -444,13 +453,15 @@ var configGoogleSchema = z5.object({
444
453
  cron: z5.string().optional()
445
454
  }).optional()
446
455
  }).optional();
456
+ var configQueryListSchema = z5.array(z5.string().min(1));
447
457
  var configSpecSchema = z5.object({
448
458
  displayName: z5.string().min(1),
449
459
  canonicalDomain: z5.string().min(1),
450
460
  ownedDomains: z5.array(z5.string().min(1)).optional().default([]),
451
461
  country: z5.string().length(2),
452
462
  language: z5.string().min(2),
453
- keywords: z5.array(z5.string().min(1)).optional().default([]),
463
+ queries: configQueryListSchema.optional(),
464
+ keywords: configQueryListSchema.optional(),
454
465
  competitors: z5.array(z5.string().min(1)).optional().default([]),
455
466
  providers: z5.array(providerNameSchema).optional().default([]),
456
467
  locations: z5.array(locationContextSchema).optional().default([]),
@@ -460,6 +471,13 @@ var configSpecSchema = z5.object({
460
471
  google: configGoogleSchema,
461
472
  autoExtractBacklinks: z5.boolean().optional().default(false)
462
473
  }).superRefine((spec, ctx) => {
474
+ if (spec.queries !== void 0 && spec.keywords !== void 0) {
475
+ ctx.addIssue({
476
+ code: "custom",
477
+ message: "Use spec.queries; spec.keywords is accepted only as a legacy alias when spec.queries is omitted",
478
+ path: ["keywords"]
479
+ });
480
+ }
463
481
  const duplicateLabels = findDuplicateLocationLabels(spec.locations);
464
482
  if (duplicateLabels.length > 0) {
465
483
  ctx.addIssue({
@@ -482,6 +500,9 @@ var projectConfigSchema = z5.object({
482
500
  metadata: configMetadataSchema,
483
501
  spec: configSpecSchema
484
502
  });
503
+ function resolveConfigSpecQueries(spec) {
504
+ return spec.queries ?? spec.keywords ?? [];
505
+ }
485
506
 
486
507
  // ../contracts/src/errors.ts
487
508
  var AppError = class extends Error {
@@ -870,12 +891,25 @@ function isAgentProviderId(value) {
870
891
  // ../contracts/src/snapshot.ts
871
892
  import { z as z9 } from "zod";
872
893
  var snapshotAccuracySchema = z9.enum(["yes", "no", "unknown", "not-mentioned"]);
894
+ var snapshotQueryListSchema = z9.array(z9.string().min(1));
873
895
  var snapshotRequestSchema = z9.object({
874
896
  companyName: z9.string().min(1),
875
897
  domain: z9.string().min(1),
876
- phrases: z9.array(z9.string().min(1)).optional().default([]),
898
+ queries: snapshotQueryListSchema.optional(),
899
+ phrases: snapshotQueryListSchema.optional(),
877
900
  competitors: z9.array(z9.string().min(1)).optional().default([])
901
+ }).superRefine((input, ctx) => {
902
+ if (input.queries !== void 0 && input.phrases !== void 0) {
903
+ ctx.addIssue({
904
+ code: "custom",
905
+ message: "Use queries; phrases is accepted only as a legacy alias when queries is omitted",
906
+ path: ["phrases"]
907
+ });
908
+ }
878
909
  });
910
+ function resolveSnapshotRequestQueries(input) {
911
+ return input.queries ?? input.phrases ?? [];
912
+ }
879
913
  var snapshotCompetitorEntrySchema = z9.object({
880
914
  name: z9.string(),
881
915
  count: z9.number().int().nonnegative()
@@ -925,7 +959,7 @@ var snapshotProviderResultSchema = z9.object({
925
959
  error: z9.string().nullable().optional()
926
960
  });
927
961
  var snapshotQueryResultSchema = z9.object({
928
- phrase: z9.string(),
962
+ query: z9.string(),
929
963
  providerResults: z9.array(snapshotProviderResultSchema).default([])
930
964
  });
931
965
  var snapshotSummarySchema = z9.object({
@@ -944,7 +978,7 @@ var snapshotReportSchema = z9.object({
944
978
  domain: z9.string(),
945
979
  homepageUrl: z9.string(),
946
980
  generatedAt: z9.string(),
947
- phrases: z9.array(z9.string()).default([]),
981
+ queries: z9.array(z9.string()).default([]),
948
982
  competitors: z9.array(z9.string()).default([]),
949
983
  profile: snapshotProfileSchema,
950
984
  audit: snapshotAuditSchema,
@@ -1463,11 +1497,11 @@ var projectSearchSnapshotHitSchema = z15.object({
1463
1497
  kind: z15.literal("snapshot"),
1464
1498
  id: z15.string(),
1465
1499
  runId: z15.string(),
1466
- keyword: z15.string(),
1500
+ query: z15.string(),
1467
1501
  provider: z15.string(),
1468
1502
  model: z15.string().nullable(),
1469
1503
  citationState: citationStateSchema,
1470
- matchedField: z15.enum(["answerText", "citedDomains", "searchQueries", "keyword"]),
1504
+ matchedField: z15.enum(["answerText", "citedDomains", "searchQueries", "query"]),
1471
1505
  snippet: z15.string(),
1472
1506
  createdAt: z15.string()
1473
1507
  });
@@ -1478,9 +1512,9 @@ var projectSearchInsightHitSchema = z15.object({
1478
1512
  type: z15.enum(["regression", "gain", "opportunity"]),
1479
1513
  severity: z15.enum(["critical", "high", "medium", "low"]),
1480
1514
  title: z15.string(),
1481
- keyword: z15.string(),
1515
+ query: z15.string(),
1482
1516
  provider: z15.string(),
1483
- matchedField: z15.enum(["title", "keyword", "recommendation", "cause"]),
1517
+ matchedField: z15.enum(["title", "query", "recommendation", "cause"]),
1484
1518
  snippet: z15.string(),
1485
1519
  dismissed: z15.boolean(),
1486
1520
  createdAt: z15.string()
@@ -1793,16 +1827,16 @@ var citationCoverageProviderSchema = z18.object({
1793
1827
  runCreatedAt: z18.string()
1794
1828
  });
1795
1829
  var citationCoverageRowSchema = z18.object({
1796
- keywordId: z18.string(),
1797
- keyword: z18.string(),
1830
+ queryId: z18.string(),
1831
+ query: z18.string(),
1798
1832
  providers: z18.array(citationCoverageProviderSchema),
1799
1833
  citedCount: z18.number().int().nonnegative(),
1800
1834
  mentionedCount: z18.number().int().nonnegative(),
1801
1835
  totalProviders: z18.number().int().nonnegative()
1802
1836
  });
1803
1837
  var competitorGapRowSchema = z18.object({
1804
- keywordId: z18.string(),
1805
- keyword: z18.string(),
1838
+ queryId: z18.string(),
1839
+ query: z18.string(),
1806
1840
  provider: z18.string(),
1807
1841
  citingCompetitors: z18.array(z18.string()),
1808
1842
  runId: z18.string(),
@@ -1812,23 +1846,23 @@ var citationVisibilitySummarySchema = z18.object({
1812
1846
  providersConfigured: z18.number().int().nonnegative(),
1813
1847
  providersCiting: z18.number().int().nonnegative(),
1814
1848
  providersMentioning: z18.number().int().nonnegative(),
1815
- totalKeywords: z18.number().int().nonnegative(),
1816
- // Cross-tab buckets — each tracked keyword with at least one snapshot lands
1817
- // in exactly one of these. Keywords with zero snapshots are not counted in
1818
- // any bucket; (sum of buckets) ≤ totalKeywords.
1819
- keywordsCitedAndMentioned: z18.number().int().nonnegative(),
1820
- keywordsCitedOnly: z18.number().int().nonnegative(),
1821
- keywordsMentionedOnly: z18.number().int().nonnegative(),
1822
- keywordsInvisible: z18.number().int().nonnegative(),
1849
+ totalQueries: z18.number().int().nonnegative(),
1850
+ // Cross-tab buckets — each tracked query with at least one snapshot lands
1851
+ // in exactly one of these. Queries with zero snapshots are not counted in
1852
+ // any bucket; (sum of buckets) ≤ totalQueries.
1853
+ queriesCitedAndMentioned: z18.number().int().nonnegative(),
1854
+ queriesCitedOnly: z18.number().int().nonnegative(),
1855
+ queriesMentionedOnly: z18.number().int().nonnegative(),
1856
+ queriesInvisible: z18.number().int().nonnegative(),
1823
1857
  latestRunId: z18.string().nullable(),
1824
1858
  latestRunAt: z18.string().nullable()
1825
1859
  });
1826
1860
  var citationVisibilityResponseSchema = z18.object({
1827
1861
  summary: citationVisibilitySummarySchema,
1828
- byKeyword: z18.array(citationCoverageRowSchema),
1862
+ byQuery: z18.array(citationCoverageRowSchema),
1829
1863
  competitorGaps: z18.array(competitorGapRowSchema),
1830
1864
  status: z18.enum(["ready", "no-data"]),
1831
- reason: z18.enum(["no-runs-yet", "no-keywords"]).optional()
1865
+ reason: z18.enum(["no-runs-yet", "no-queries"]).optional()
1832
1866
  });
1833
1867
  function emptyCitationVisibility(reason) {
1834
1868
  return {
@@ -1836,15 +1870,15 @@ function emptyCitationVisibility(reason) {
1836
1870
  providersConfigured: 0,
1837
1871
  providersCiting: 0,
1838
1872
  providersMentioning: 0,
1839
- totalKeywords: 0,
1840
- keywordsCitedAndMentioned: 0,
1841
- keywordsCitedOnly: 0,
1842
- keywordsMentionedOnly: 0,
1843
- keywordsInvisible: 0,
1873
+ totalQueries: 0,
1874
+ queriesCitedAndMentioned: 0,
1875
+ queriesCitedOnly: 0,
1876
+ queriesMentionedOnly: 0,
1877
+ queriesInvisible: 0,
1844
1878
  latestRunId: null,
1845
1879
  latestRunAt: null
1846
1880
  },
1847
- byKeyword: [],
1881
+ byQuery: [],
1848
1882
  competitorGaps: [],
1849
1883
  status: "no-data",
1850
1884
  reason
@@ -1873,7 +1907,9 @@ export {
1873
1907
  findDuplicateLocationLabels,
1874
1908
  hasLocationLabel,
1875
1909
  projectUpsertRequestSchema,
1910
+ queryBatchRequestSchema,
1876
1911
  keywordBatchRequestSchema,
1912
+ queryGenerateRequestSchema,
1877
1913
  keywordGenerateRequestSchema,
1878
1914
  competitorBatchRequestSchema,
1879
1915
  normalizeProjectDomain,
@@ -1881,6 +1917,7 @@ export {
1881
1917
  brandLabelFromDomain,
1882
1918
  effectiveDomains,
1883
1919
  projectConfigSchema,
1920
+ resolveConfigSpecQueries,
1884
1921
  AppError,
1885
1922
  notFound,
1886
1923
  validationError,
@@ -1909,6 +1946,7 @@ export {
1909
1946
  serializeRunError,
1910
1947
  formatRunErrorOneLine,
1911
1948
  snapshotRequestSchema,
1949
+ resolveSnapshotRequestQueries,
1912
1950
  scheduleUpsertRequestSchema,
1913
1951
  parseWindow,
1914
1952
  windowCutoff,