@gscdump/contracts 3.1.0 → 3.2.0

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.
@@ -3,6 +3,7 @@ import "./version.mjs";
3
3
  import { HTTP_V1_ERROR_CODES, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse } from "./http-core.mjs";
4
4
  import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, REALTIME_V1_EVENT_SEMANTICS, createRealtimeV1Schemas } from "./realtime.mjs";
5
5
  import { GSCDUMP_V1_ANALYTICS_DIMENSIONS, createGscdumpV1BrowserSchemas } from "./browser.mjs";
6
+ import { gscdumpV1OperationRoute, gscdumpV1Surface } from "./route-catalog.mjs";
6
7
  import { z } from "zod";
7
8
  function errorEnvelopeSchemas(codes, publicRequestId) {
8
9
  const errorDetails = z.record(z.string(), z.json());
@@ -696,14 +697,10 @@ function createGscdumpV1Protocol() {
696
697
  "contract_violation"
697
698
  ];
698
699
  const partner = defineHttpSurface({
699
- name: "partner",
700
- prefix: "/api/partner/v1",
701
- version: "1.0",
700
+ ...gscdumpV1Surface("partner"),
702
701
  operations: {
703
702
  getUserLifecycle: defineHttpOperation({
704
- id: "partner.users.lifecycle.get",
705
- method: "GET",
706
- path: "/users/{userId}/lifecycle",
703
+ ...gscdumpV1OperationRoute("partner.users.lifecycle.get"),
707
704
  visibility: "public",
708
705
  semantics: {
709
706
  kind: "query",
@@ -772,9 +769,7 @@ function createGscdumpV1Protocol() {
772
769
  }
773
770
  }),
774
771
  listAvailableSites: defineHttpOperation({
775
- id: "partner.users.sites.available.list",
776
- method: "GET",
777
- path: "/users/{userId}/available-sites",
772
+ ...gscdumpV1OperationRoute("partner.users.sites.available.list"),
778
773
  visibility: "public",
779
774
  semantics: {
780
775
  kind: "query",
@@ -835,9 +830,7 @@ function createGscdumpV1Protocol() {
835
830
  }
836
831
  }),
837
832
  createSite: defineHttpOperation({
838
- id: "partner.users.sites.create",
839
- method: "POST",
840
- path: "/users/{userId}/sites",
833
+ ...gscdumpV1OperationRoute("partner.users.sites.create"),
841
834
  visibility: "public",
842
835
  semantics: {
843
836
  kind: "mutation",
@@ -901,9 +894,7 @@ function createGscdumpV1Protocol() {
901
894
  }
902
895
  }),
903
896
  createUser: defineHttpOperation({
904
- id: "partner.users.create",
905
- method: "POST",
906
- path: "/users",
897
+ ...gscdumpV1OperationRoute("partner.users.create"),
907
898
  visibility: "public",
908
899
  semantics: {
909
900
  kind: "mutation",
@@ -963,9 +954,7 @@ function createGscdumpV1Protocol() {
963
954
  }
964
955
  }),
965
956
  updateUserTokens: defineHttpOperation({
966
- id: "partner.users.tokens.update",
967
- method: "PATCH",
968
- path: "/users/{userId}/tokens",
957
+ ...gscdumpV1OperationRoute("partner.users.tokens.update"),
969
958
  visibility: "public",
970
959
  semantics: {
971
960
  kind: "mutation",
@@ -1030,9 +1019,7 @@ function createGscdumpV1Protocol() {
1030
1019
  }
1031
1020
  }),
1032
1021
  getSiteIndexing: defineHttpOperation({
1033
- id: "partner.sites.indexing.get",
1034
- method: "GET",
1035
- path: "/sites/{siteId}/indexing",
1022
+ ...gscdumpV1OperationRoute("partner.sites.indexing.get"),
1036
1023
  visibility: "public",
1037
1024
  semantics: {
1038
1025
  kind: "query",
@@ -1123,9 +1110,7 @@ function createGscdumpV1Protocol() {
1123
1110
  }
1124
1111
  }),
1125
1112
  listSiteIndexingUrls: defineHttpOperation({
1126
- id: "partner.sites.indexing.urls.list",
1127
- method: "GET",
1128
- path: "/sites/{siteId}/indexing/urls",
1113
+ ...gscdumpV1OperationRoute("partner.sites.indexing.urls.list"),
1129
1114
  visibility: "public",
1130
1115
  semantics: {
1131
1116
  kind: "query",
@@ -1199,9 +1184,7 @@ function createGscdumpV1Protocol() {
1199
1184
  }
1200
1185
  }),
1201
1186
  listSiteBingIndexingEvidence: defineHttpOperation({
1202
- id: "partner.sites.indexing.bing.evidence.list",
1203
- method: "GET",
1204
- path: "/sites/{siteId}/indexing/bing/evidence",
1187
+ ...gscdumpV1OperationRoute("partner.sites.indexing.bing.evidence.list"),
1205
1188
  visibility: "public",
1206
1189
  semantics: {
1207
1190
  kind: "query",
@@ -1272,9 +1255,7 @@ function createGscdumpV1Protocol() {
1272
1255
  }
1273
1256
  }),
1274
1257
  listSiteIndexingTransitions: defineHttpOperation({
1275
- id: "partner.sites.indexing.transitions.list",
1276
- method: "GET",
1277
- path: "/sites/{siteId}/indexing/transitions",
1258
+ ...gscdumpV1OperationRoute("partner.sites.indexing.transitions.list"),
1278
1259
  visibility: "public",
1279
1260
  semantics: {
1280
1261
  kind: "query",
@@ -1355,9 +1336,7 @@ function createGscdumpV1Protocol() {
1355
1336
  }
1356
1337
  }),
1357
1338
  getSiteIndexingDiagnostics: defineHttpOperation({
1358
- id: "partner.sites.indexing.diagnostics.get",
1359
- method: "GET",
1360
- path: "/sites/{siteId}/indexing/diagnostics",
1339
+ ...gscdumpV1OperationRoute("partner.sites.indexing.diagnostics.get"),
1361
1340
  visibility: "public",
1362
1341
  semantics: {
1363
1342
  kind: "query",
@@ -1423,9 +1402,7 @@ function createGscdumpV1Protocol() {
1423
1402
  }
1424
1403
  }),
1425
1404
  getSiteSitemaps: defineHttpOperation({
1426
- id: "partner.sites.sitemaps.get",
1427
- method: "GET",
1428
- path: "/sites/{siteId}/sitemaps",
1405
+ ...gscdumpV1OperationRoute("partner.sites.sitemaps.get"),
1429
1406
  visibility: "public",
1430
1407
  semantics: {
1431
1408
  kind: "query",
@@ -1494,9 +1471,7 @@ function createGscdumpV1Protocol() {
1494
1471
  }
1495
1472
  }),
1496
1473
  getSiteSitemapChanges: defineHttpOperation({
1497
- id: "partner.sites.sitemaps.changes.get",
1498
- method: "GET",
1499
- path: "/sites/{siteId}/sitemaps/changes",
1474
+ ...gscdumpV1OperationRoute("partner.sites.sitemaps.changes.get"),
1500
1475
  visibility: "public",
1501
1476
  semantics: {
1502
1477
  kind: "query",
@@ -1569,9 +1544,7 @@ function createGscdumpV1Protocol() {
1569
1544
  }
1570
1545
  }),
1571
1546
  getSiteAnalysis: defineHttpOperation({
1572
- id: "partner.sites.analysis.get",
1573
- method: "GET",
1574
- path: "/sites/{siteId}/analysis",
1547
+ ...gscdumpV1OperationRoute("partner.sites.analysis.get"),
1575
1548
  visibility: "public",
1576
1549
  semantics: {
1577
1550
  kind: "query",
@@ -1644,9 +1617,7 @@ function createGscdumpV1Protocol() {
1644
1617
  }
1645
1618
  }),
1646
1619
  getSiteAnalysisBundle: defineHttpOperation({
1647
- id: "partner.sites.analysis.bundle.get",
1648
- method: "GET",
1649
- path: "/sites/{siteId}/analysis/bundle",
1620
+ ...gscdumpV1OperationRoute("partner.sites.analysis.bundle.get"),
1650
1621
  visibility: "public",
1651
1622
  semantics: {
1652
1623
  kind: "query",
@@ -1717,9 +1688,7 @@ function createGscdumpV1Protocol() {
1717
1688
  }
1718
1689
  }),
1719
1690
  deleteSite: defineHttpOperation({
1720
- id: "partner.sites.delete",
1721
- method: "DELETE",
1722
- path: "/sites/{siteId}",
1691
+ ...gscdumpV1OperationRoute("partner.sites.delete"),
1723
1692
  visibility: "public",
1724
1693
  semantics: {
1725
1694
  kind: "mutation",
@@ -1784,9 +1753,7 @@ function createGscdumpV1Protocol() {
1784
1753
  }
1785
1754
  }),
1786
1755
  getCanonicalMismatches: defineHttpOperation({
1787
- id: "partner.sites.canonical.mismatches.get",
1788
- method: "GET",
1789
- path: "/sites/{siteId}/canonical-mismatches",
1756
+ ...gscdumpV1OperationRoute("partner.sites.canonical.mismatches.get"),
1790
1757
  visibility: "public",
1791
1758
  semantics: {
1792
1759
  kind: "query",
@@ -1850,9 +1817,7 @@ function createGscdumpV1Protocol() {
1850
1817
  }
1851
1818
  }),
1852
1819
  inspectSiteUrls: defineHttpOperation({
1853
- id: "partner.sites.indexing.inspect.create",
1854
- method: "POST",
1855
- path: "/sites/{siteId}/indexing/inspect",
1820
+ ...gscdumpV1OperationRoute("partner.sites.indexing.inspect.create"),
1856
1821
  visibility: "public",
1857
1822
  semantics: {
1858
1823
  kind: "mutation",
@@ -1923,9 +1888,7 @@ function createGscdumpV1Protocol() {
1923
1888
  }
1924
1889
  }),
1925
1890
  recoverSitePermission: defineHttpOperation({
1926
- id: "partner.sites.permission.recover",
1927
- method: "POST",
1928
- path: "/sites/{siteId}/permission/recover",
1891
+ ...gscdumpV1OperationRoute("partner.sites.permission.recover"),
1929
1892
  visibility: "public",
1930
1893
  semantics: {
1931
1894
  kind: "mutation",
@@ -1991,9 +1954,7 @@ function createGscdumpV1Protocol() {
1991
1954
  }
1992
1955
  }),
1993
1956
  queryKeywordSparklines: defineHttpOperation({
1994
- id: "partner.sites.keyword.sparklines.query",
1995
- method: "POST",
1996
- path: "/sites/{siteId}/keyword-sparklines",
1957
+ ...gscdumpV1OperationRoute("partner.sites.keyword.sparklines.query"),
1997
1958
  visibility: "public",
1998
1959
  semantics: {
1999
1960
  kind: "query",
@@ -2059,9 +2020,7 @@ function createGscdumpV1Protocol() {
2059
2020
  }
2060
2021
  }),
2061
2022
  getQueryTrend: defineHttpOperation({
2062
- id: "partner.sites.query.trend.get",
2063
- method: "GET",
2064
- path: "/sites/{siteId}/query-trend",
2023
+ ...gscdumpV1OperationRoute("partner.sites.query.trend.get"),
2065
2024
  visibility: "public",
2066
2025
  semantics: {
2067
2026
  kind: "query",
@@ -2129,9 +2088,7 @@ function createGscdumpV1Protocol() {
2129
2088
  }
2130
2089
  }),
2131
2090
  getPageTrend: defineHttpOperation({
2132
- id: "partner.sites.page.trend.get",
2133
- method: "GET",
2134
- path: "/sites/{siteId}/page-trend",
2091
+ ...gscdumpV1OperationRoute("partner.sites.page.trend.get"),
2135
2092
  visibility: "public",
2136
2093
  semantics: {
2137
2094
  kind: "query",
@@ -2199,9 +2156,7 @@ function createGscdumpV1Protocol() {
2199
2156
  }
2200
2157
  }),
2201
2158
  getContentVelocity: defineHttpOperation({
2202
- id: "partner.sites.content.velocity.get",
2203
- method: "GET",
2204
- path: "/sites/{siteId}/content-velocity",
2159
+ ...gscdumpV1OperationRoute("partner.sites.content.velocity.get"),
2205
2160
  visibility: "public",
2206
2161
  semantics: {
2207
2162
  kind: "query",
@@ -2270,9 +2225,7 @@ function createGscdumpV1Protocol() {
2270
2225
  }
2271
2226
  }),
2272
2227
  getCtrCurve: defineHttpOperation({
2273
- id: "partner.sites.ctr.curve.get",
2274
- method: "GET",
2275
- path: "/sites/{siteId}/ctr-curve",
2228
+ ...gscdumpV1OperationRoute("partner.sites.ctr.curve.get"),
2276
2229
  visibility: "public",
2277
2230
  semantics: {
2278
2231
  kind: "query",
@@ -2341,9 +2294,7 @@ function createGscdumpV1Protocol() {
2341
2294
  }
2342
2295
  }),
2343
2296
  getDarkTraffic: defineHttpOperation({
2344
- id: "partner.sites.dark.traffic.get",
2345
- method: "GET",
2346
- path: "/sites/{siteId}/dark-traffic",
2297
+ ...gscdumpV1OperationRoute("partner.sites.dark.traffic.get"),
2347
2298
  visibility: "public",
2348
2299
  semantics: {
2349
2300
  kind: "query",
@@ -2418,9 +2369,7 @@ function createGscdumpV1Protocol() {
2418
2369
  }
2419
2370
  }),
2420
2371
  getDeviceGap: defineHttpOperation({
2421
- id: "partner.sites.device.gap.get",
2422
- method: "GET",
2423
- path: "/sites/{siteId}/device-gap",
2372
+ ...gscdumpV1OperationRoute("partner.sites.device.gap.get"),
2424
2373
  visibility: "public",
2425
2374
  semantics: {
2426
2375
  kind: "query",
@@ -2488,9 +2437,7 @@ function createGscdumpV1Protocol() {
2488
2437
  }
2489
2438
  }),
2490
2439
  getKeywordBreadth: defineHttpOperation({
2491
- id: "partner.sites.keyword.breadth.get",
2492
- method: "GET",
2493
- path: "/sites/{siteId}/keyword-breadth",
2440
+ ...gscdumpV1OperationRoute("partner.sites.keyword.breadth.get"),
2494
2441
  visibility: "public",
2495
2442
  semantics: {
2496
2443
  kind: "query",
@@ -2565,9 +2512,7 @@ function createGscdumpV1Protocol() {
2565
2512
  }
2566
2513
  }),
2567
2514
  getPositionDistribution: defineHttpOperation({
2568
- id: "partner.sites.position.distribution.get",
2569
- method: "GET",
2570
- path: "/sites/{siteId}/position-distribution",
2515
+ ...gscdumpV1OperationRoute("partner.sites.position.distribution.get"),
2571
2516
  visibility: "public",
2572
2517
  semantics: {
2573
2518
  kind: "query",
@@ -2634,9 +2579,7 @@ function createGscdumpV1Protocol() {
2634
2579
  }
2635
2580
  }),
2636
2581
  getTopAssociation: defineHttpOperation({
2637
- id: "partner.sites.top.association.get",
2638
- method: "GET",
2639
- path: "/sites/{siteId}/top-association",
2582
+ ...gscdumpV1OperationRoute("partner.sites.top.association.get"),
2640
2583
  visibility: "public",
2641
2584
  semantics: {
2642
2585
  kind: "query",
@@ -2699,9 +2642,7 @@ function createGscdumpV1Protocol() {
2699
2642
  }
2700
2643
  }),
2701
2644
  getIndexPercent: defineHttpOperation({
2702
- id: "partner.sites.index.percent.get",
2703
- method: "GET",
2704
- path: "/sites/{siteId}/index-percent",
2645
+ ...gscdumpV1OperationRoute("partner.sites.index.percent.get"),
2705
2646
  visibility: "public",
2706
2647
  semantics: {
2707
2648
  kind: "query",
@@ -2782,9 +2723,7 @@ function createGscdumpV1Protocol() {
2782
2723
  }
2783
2724
  }),
2784
2725
  createSitemapAction: defineHttpOperation({
2785
- id: "partner.sites.sitemaps.action.create",
2786
- method: "POST",
2787
- path: "/sites/{siteId}/sitemaps/actions",
2726
+ ...gscdumpV1OperationRoute("partner.sites.sitemaps.action.create"),
2788
2727
  visibility: "public",
2789
2728
  semantics: {
2790
2729
  kind: "mutation",
@@ -2850,9 +2789,7 @@ function createGscdumpV1Protocol() {
2850
2789
  }
2851
2790
  }),
2852
2791
  querySitemapMembership: defineHttpOperation({
2853
- id: "partner.sites.sitemaps.membership.query",
2854
- method: "POST",
2855
- path: "/sites/{siteId}/sitemaps/membership",
2792
+ ...gscdumpV1OperationRoute("partner.sites.sitemaps.membership.query"),
2856
2793
  visibility: "public",
2857
2794
  semantics: {
2858
2795
  kind: "query",
@@ -2922,9 +2859,7 @@ function createGscdumpV1Protocol() {
2922
2859
  }
2923
2860
  }),
2924
2861
  listSitemapUrls: defineHttpOperation({
2925
- id: "partner.sites.sitemaps.urls.get",
2926
- method: "GET",
2927
- path: "/sites/{siteId}/sitemaps/urls",
2862
+ ...gscdumpV1OperationRoute("partner.sites.sitemaps.urls.get"),
2928
2863
  visibility: "public",
2929
2864
  semantics: {
2930
2865
  kind: "query",
@@ -2996,9 +2931,7 @@ function createGscdumpV1Protocol() {
2996
2931
  }
2997
2932
  }),
2998
2933
  getSitemapExport: defineHttpOperation({
2999
- id: "partner.sites.sitemaps.export.get",
3000
- method: "GET",
3001
- path: "/sites/{siteId}/sitemaps/export",
2934
+ ...gscdumpV1OperationRoute("partner.sites.sitemaps.export.get"),
3002
2935
  visibility: "public",
3003
2936
  semantics: {
3004
2937
  kind: "query",
@@ -3066,9 +2999,7 @@ function createGscdumpV1Protocol() {
3066
2999
  }
3067
3000
  }),
3068
3001
  createTeam: defineHttpOperation({
3069
- id: "partner.teams.create",
3070
- method: "POST",
3071
- path: "/teams",
3002
+ ...gscdumpV1OperationRoute("partner.teams.create"),
3072
3003
  visibility: "public",
3073
3004
  semantics: {
3074
3005
  kind: "mutation",
@@ -3130,9 +3061,7 @@ function createGscdumpV1Protocol() {
3130
3061
  }
3131
3062
  }),
3132
3063
  renameTeam: defineHttpOperation({
3133
- id: "partner.teams.rename",
3134
- method: "PATCH",
3135
- path: "/teams/{teamId}",
3064
+ ...gscdumpV1OperationRoute("partner.teams.rename"),
3136
3065
  visibility: "public",
3137
3066
  semantics: {
3138
3067
  kind: "mutation",
@@ -3193,9 +3122,7 @@ function createGscdumpV1Protocol() {
3193
3122
  }
3194
3123
  }),
3195
3124
  deleteTeam: defineHttpOperation({
3196
- id: "partner.teams.delete",
3197
- method: "DELETE",
3198
- path: "/teams/{teamId}",
3125
+ ...gscdumpV1OperationRoute("partner.teams.delete"),
3199
3126
  visibility: "public",
3200
3127
  semantics: {
3201
3128
  kind: "mutation",
@@ -3250,9 +3177,7 @@ function createGscdumpV1Protocol() {
3250
3177
  }
3251
3178
  }),
3252
3179
  listTeamMembers: defineHttpOperation({
3253
- id: "partner.teams.members.list",
3254
- method: "GET",
3255
- path: "/teams/{teamId}/members",
3180
+ ...gscdumpV1OperationRoute("partner.teams.members.list"),
3256
3181
  visibility: "public",
3257
3182
  semantics: {
3258
3183
  kind: "query",
@@ -3304,9 +3229,7 @@ function createGscdumpV1Protocol() {
3304
3229
  }
3305
3230
  }),
3306
3231
  addTeamMember: defineHttpOperation({
3307
- id: "partner.teams.members.add",
3308
- method: "POST",
3309
- path: "/teams/{teamId}/members",
3232
+ ...gscdumpV1OperationRoute("partner.teams.members.add"),
3310
3233
  visibility: "public",
3311
3234
  semantics: {
3312
3235
  kind: "mutation",
@@ -3370,9 +3293,7 @@ function createGscdumpV1Protocol() {
3370
3293
  }
3371
3294
  }),
3372
3295
  updateTeamMemberRole: defineHttpOperation({
3373
- id: "partner.teams.members.role.update",
3374
- method: "PATCH",
3375
- path: "/teams/{teamId}/members/{userId}",
3296
+ ...gscdumpV1OperationRoute("partner.teams.members.role.update"),
3376
3297
  visibility: "public",
3377
3298
  semantics: {
3378
3299
  kind: "mutation",
@@ -3445,9 +3366,7 @@ function createGscdumpV1Protocol() {
3445
3366
  }
3446
3367
  }),
3447
3368
  removeTeamMember: defineHttpOperation({
3448
- id: "partner.teams.members.remove",
3449
- method: "DELETE",
3450
- path: "/teams/{teamId}/members/{userId}",
3369
+ ...gscdumpV1OperationRoute("partner.teams.members.remove"),
3451
3370
  visibility: "public",
3452
3371
  semantics: {
3453
3372
  kind: "mutation",
@@ -3514,9 +3433,7 @@ function createGscdumpV1Protocol() {
3514
3433
  }
3515
3434
  }),
3516
3435
  updateSiteTeam: defineHttpOperation({
3517
- id: "partner.sites.team.update",
3518
- method: "PATCH",
3519
- path: "/sites/{siteId}/team",
3436
+ ...gscdumpV1OperationRoute("partner.sites.team.update"),
3520
3437
  visibility: "public",
3521
3438
  semantics: {
3522
3439
  kind: "mutation",
@@ -3577,9 +3494,7 @@ function createGscdumpV1Protocol() {
3577
3494
  }
3578
3495
  }),
3579
3496
  getTeamCatalog: defineHttpOperation({
3580
- id: "partner.teams.catalog.get",
3581
- method: "GET",
3582
- path: "/teams/{teamId}/catalog",
3497
+ ...gscdumpV1OperationRoute("partner.teams.catalog.get"),
3583
3498
  visibility: "public",
3584
3499
  semantics: {
3585
3500
  kind: "query",
@@ -3641,9 +3556,7 @@ function createGscdumpV1Protocol() {
3641
3556
  }
3642
3557
  }),
3643
3558
  bindTeamCatalog: defineHttpOperation({
3644
- id: "partner.teams.catalog.bind",
3645
- method: "POST",
3646
- path: "/teams/{teamId}/catalog",
3559
+ ...gscdumpV1OperationRoute("partner.teams.catalog.bind"),
3647
3560
  visibility: "public",
3648
3561
  semantics: {
3649
3562
  kind: "mutation",
@@ -3713,9 +3626,7 @@ function createGscdumpV1Protocol() {
3713
3626
  }
3714
3627
  }),
3715
3628
  getSiteIntIdCrosswalk: defineHttpOperation({
3716
- id: "partner.users.sites.crosswalk.get",
3717
- method: "GET",
3718
- path: "/users/{userId}/sites/crosswalk",
3629
+ ...gscdumpV1OperationRoute("partner.users.sites.crosswalk.get"),
3719
3630
  visibility: "public",
3720
3631
  semantics: {
3721
3632
  kind: "query",
@@ -3776,9 +3687,7 @@ function createGscdumpV1Protocol() {
3776
3687
  }
3777
3688
  }),
3778
3689
  deleteUser: defineHttpOperation({
3779
- id: "partner.users.delete",
3780
- method: "DELETE",
3781
- path: "/users/{userId}",
3690
+ ...gscdumpV1OperationRoute("partner.users.delete"),
3782
3691
  visibility: "public",
3783
3692
  semantics: {
3784
3693
  kind: "mutation",
@@ -3841,9 +3750,7 @@ function createGscdumpV1Protocol() {
3841
3750
  }
3842
3751
  }),
3843
3752
  createVerificationToken: defineHttpOperation({
3844
- id: "partner.users.verification.token.create",
3845
- method: "POST",
3846
- path: "/users/{userId}/verification-token",
3753
+ ...gscdumpV1OperationRoute("partner.users.verification.token.create"),
3847
3754
  visibility: "public",
3848
3755
  semantics: {
3849
3756
  kind: "query",
@@ -3921,9 +3828,7 @@ function createGscdumpV1Protocol() {
3921
3828
  }
3922
3829
  }),
3923
3830
  addAndVerifySite: defineHttpOperation({
3924
- id: "partner.users.sites.verify.create",
3925
- method: "POST",
3926
- path: "/users/{userId}/sites/verify",
3831
+ ...gscdumpV1OperationRoute("partner.users.sites.verify.create"),
3927
3832
  visibility: "public",
3928
3833
  semantics: {
3929
3834
  kind: "mutation",
@@ -3998,14 +3903,10 @@ function createGscdumpV1Protocol() {
3998
3903
  }
3999
3904
  });
4000
3905
  const analytics = defineHttpSurface({
4001
- name: "analytics",
4002
- prefix: "/api/analytics/v1",
4003
- version: "1.0",
3906
+ ...gscdumpV1Surface("analytics"),
4004
3907
  operations: {
4005
3908
  queryRows: defineHttpOperation({
4006
- id: "analytics.rows.query",
4007
- method: "POST",
4008
- path: "/sites/{siteId}/rows",
3909
+ ...gscdumpV1OperationRoute("analytics.rows.query"),
4009
3910
  visibility: "public",
4010
3911
  semantics: {
4011
3912
  kind: "query",
@@ -4070,9 +3971,7 @@ function createGscdumpV1Protocol() {
4070
3971
  }
4071
3972
  }),
4072
3973
  queryReport: defineHttpOperation({
4073
- id: "analytics.reports.query",
4074
- method: "POST",
4075
- path: "/sites/{siteId}/reports",
3974
+ ...gscdumpV1OperationRoute("analytics.reports.query"),
4076
3975
  visibility: "public",
4077
3976
  semantics: {
4078
3977
  kind: "query",
@@ -4152,9 +4051,7 @@ function createGscdumpV1Protocol() {
4152
4051
  }
4153
4052
  }),
4154
4053
  queryReportDetail: defineHttpOperation({
4155
- id: "analytics.reports.detail.query",
4156
- method: "POST",
4157
- path: "/sites/{siteId}/reports/detail",
4054
+ ...gscdumpV1OperationRoute("analytics.reports.detail.query"),
4158
4055
  visibility: "public",
4159
4056
  semantics: {
4160
4057
  kind: "query",
@@ -4235,14 +4132,10 @@ function createGscdumpV1Protocol() {
4235
4132
  }
4236
4133
  });
4237
4134
  const realtime = defineHttpSurface({
4238
- name: "realtime",
4239
- prefix: "/api/realtime/v1",
4240
- version: "1.0",
4135
+ ...gscdumpV1Surface("realtime"),
4241
4136
  operations: {
4242
4137
  getStreamHead: defineHttpOperation({
4243
- id: "realtime.stream.head.get",
4244
- method: "GET",
4245
- path: "/stream/head",
4138
+ ...gscdumpV1OperationRoute("realtime.stream.head.get"),
4246
4139
  visibility: "public",
4247
4140
  semantics: {
4248
4141
  kind: "query",
@@ -4297,9 +4190,7 @@ function createGscdumpV1Protocol() {
4297
4190
  }
4298
4191
  }),
4299
4192
  createTicket: defineHttpOperation({
4300
- id: "realtime.tickets.create",
4301
- method: "POST",
4302
- path: "/tickets",
4193
+ ...gscdumpV1OperationRoute("realtime.tickets.create"),
4303
4194
  visibility: "public",
4304
4195
  semantics: {
4305
4196
  kind: "mutation",
@@ -0,0 +1,7 @@
1
+ function serializeHttpV1PathSegment(operationId, name, value) {
2
+ if (typeof value !== "string" && typeof value !== "number") throw new TypeError(`${operationId}: path parameter ${name} must serialize as a string or number`);
3
+ const serialized = String(value);
4
+ if (serialized.length === 0 || serialized === "." || serialized === "..") throw new TypeError(`${operationId}: path parameter ${name} cannot serialize as an empty or dot segment`);
5
+ return encodeURIComponent(serialized);
6
+ }
7
+ export { serializeHttpV1PathSegment };
@@ -0,0 +1,19 @@
1
+ import { UnknownHttpV1OperationError, isUnknownHttpV1OperationError } from "./http-operation-error.mjs";
2
+ import { HttpV1RouteSurfaceName } from "./route-surfaces.mjs";
3
+ import { GSCDUMP_V1_ROUTE_CATALOG, GscdumpV1Route, GscdumpV1RouteOperationId, HttpV1RouteMethod } from "./route-catalog.mjs";
4
+ type PathParameterNames<TTemplate extends string> = TTemplate extends `${string}{${infer TName}}${infer TRest}` ? TName | PathParameterNames<TRest> : never;
5
+ type GscdumpV1PathParams<TId extends GscdumpV1RouteOperationId> = [PathParameterNames<GscdumpV1Route<TId>['template']>] extends [never] ? undefined : { [TName in PathParameterNames<GscdumpV1Route<TId>['template']>]: string | number; };
6
+ type GscdumpV1PathArguments<TId extends GscdumpV1RouteOperationId> = GscdumpV1PathParams<TId> extends undefined ? [params?: undefined] : [params: GscdumpV1PathParams<TId>];
7
+ interface GscdumpV1PathsOptions {
8
+ /** Root replacing the contract's `/api` segment. */
9
+ apiRoot?: string;
10
+ }
11
+ type GscdumpV1PathOperation<TId extends GscdumpV1RouteOperationId = GscdumpV1RouteOperationId> = GscdumpV1Route<TId> & {
12
+ prefix: typeof GSCDUMP_V1_ROUTE_CATALOG.surfaces[GscdumpV1Route<TId>['surface']]['prefix'];
13
+ };
14
+ interface GscdumpV1Paths {
15
+ operation: <const TId extends GscdumpV1RouteOperationId>(id: TId) => GscdumpV1PathOperation<TId>;
16
+ path: <const TId extends GscdumpV1RouteOperationId>(id: TId, ...args: GscdumpV1PathArguments<TId>) => string;
17
+ }
18
+ declare function createGscdumpV1Paths(options?: GscdumpV1PathsOptions): GscdumpV1Paths;
19
+ export { GscdumpV1PathArguments, GscdumpV1PathOperation, GscdumpV1PathParams, GscdumpV1Paths, GscdumpV1PathsOptions, type GscdumpV1Route, type GscdumpV1RouteOperationId, type HttpV1RouteMethod, type HttpV1RouteSurfaceName, type UnknownHttpV1OperationError, createGscdumpV1Paths, isUnknownHttpV1OperationError };
@@ -0,0 +1,39 @@
1
+ import { isUnknownHttpV1OperationError } from "./http-operation-error.mjs";
2
+ import { serializeHttpV1PathSegment } from "./path-segment.mjs";
3
+ import { GSCDUMP_V1_ROUTE_CATALOG, getGscdumpV1Route } from "./route-catalog.mjs";
4
+ function normalizeApiRoot(apiRoot) {
5
+ const root = apiRoot ?? "/api";
6
+ if (!root.startsWith("/") || root.startsWith("//") || root.includes("?") || root.includes("#")) throw new TypeError("HTTP v1 apiRoot must be an absolute path without a query string or fragment");
7
+ return root === "/" ? "" : root.replace(/\/+$/, "");
8
+ }
9
+ function createGscdumpV1Paths(options = {}) {
10
+ const apiRoot = normalizeApiRoot(options.apiRoot);
11
+ function operation(id) {
12
+ const route = getGscdumpV1Route(id);
13
+ return {
14
+ ...route,
15
+ prefix: GSCDUMP_V1_ROUTE_CATALOG.surfaces[route.surface].prefix
16
+ };
17
+ }
18
+ return {
19
+ operation,
20
+ path: (id, ...args) => {
21
+ const route = operation(id);
22
+ const names = [...route.template.matchAll(/\{([^{}]+)\}/g)].map((match) => match[1]);
23
+ const params = args[0];
24
+ if (names.length === 0) {
25
+ if (params !== void 0) throw new TypeError(`${id}: this operation has no path parameters`);
26
+ return `${apiRoot}${route.prefix.slice(4)}${route.template}`;
27
+ }
28
+ if (params === void 0 || params === null || typeof params !== "object" || Array.isArray(params)) throw new TypeError(`${id}: path parameters are required`);
29
+ const unknownName = Object.keys(params).find((name) => !names.includes(name));
30
+ if (unknownName) throw new TypeError(`${id}: unknown path parameter ${unknownName}`);
31
+ const relativePath = route.template.replace(/\{([^{}]+)\}/g, (_match, name) => {
32
+ if (!Object.hasOwn(params, name)) throw new TypeError(`${id}: path parameter ${name} is required`);
33
+ return serializeHttpV1PathSegment(id, name, params[name]);
34
+ });
35
+ return `${apiRoot}${route.prefix.slice(4)}${relativePath}`;
36
+ }
37
+ };
38
+ }
39
+ export { createGscdumpV1Paths, isUnknownHttpV1OperationError };