Repository navigation
feat(gsc): submit sitemaps behind --allow-write (v0.2.1) - #14
Merged
Merged
Conversation
Expose gsc.sitemaps.submit (PUT sitemaps/{feedpath}) as the first write capability.
- Parse --allow-write for gsc api call and run the shared effect gate in the
read-provider path before dry-run, credentials, or dispatch; denials return
EFFECT_NOT_ALLOWED with details.reason missing_allow_write.
- Request the webmasters scope only for write capabilities; reads keep
webmasters.readonly.
- Treat a 2xx empty body as success and publish a deterministic receipt
(siteUrl, feedpath, httpStatus); a 403 explains that a Restricted user lacks
write permission.
- Regenerate the GSC manifest, inventory, and docs from the reviewed policy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the first write capability to gkit:
gsc.sitemaps.submit(Search ConsolePUT /webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}, operationIdsitemaps.submit), and releases it as v0.2.1.sitemaps.submitmoves from inventory to executable witheffects: ["write"]; input isfeedpath(required, absolute http(s) URL, maxLength 2048 likesitemaps.get) and optionalsiteUrl(profile default),additionalProperties: false. Manifest, inventory, and docs regenerated withgenerate:gsc.--allow-writeis now wired end to end. Before this changegsc api callrejected--allow-writeas an unknown flag and the read-provider path hard-failed any non-read effect, so the gate ineffects.tswas unreachable. Nowargs.tsparses--allow-writeforgsconly, andexecute-read-provider.tsrunsevaluateEffectsafter profile selection and before dry-run, secret resolution, token derivation, artifact reservation, or dispatch. A denial returnsEFFECT_NOT_ALLOWEDwithdetails.reason: "missing_allow_write",outcome: not_dispatched, and no request is sent. Same as the DataForSEO spend gate,--dry-runalso needs the flag.webmasters.readonly, which would 403 on every submit. Write capabilities now requesthttps://www.googleapis.com/auth/webmasters. Reads keep the read-only scope.sitemaps.submit, any 2xx (Google returns 200/204 with an empty body) skips JSON parsing. The artifact is a deterministic receipt (artifactFormat: gkit-gsc-sitemap-submit-receipt) with sorted keys and no timestamps:{feedpath, httpStatus, operation, provider, siteUrl, submitted: true}.AUTH_FAILED, 429 →RATE_LIMITED, 408/5xx →UNKNOWN_OUTCOME, elsePROVIDER_ERROR). A 403 on submit returns a message saying the service account lacks write permission (a Restricted user cannot submit sitemaps; grant Full/Owner), plusdetails.requiredPermissionLevel: "siteFullUser".Tests
src/execute-gsc.test.ts(new): the gate denies both the live run and the dry-run without--allow-write, with no fetch, no token derivation, and no artifact. A dry-run with--allow-writeplans aPUT. A live 204 callsderiveAccessToken(..., "write"), sends aPUTto the encoded URL, and writes the receipt artifact without leaking the token. A Restricted-user 403 maps toAUTH_FAILEDwith the permission message. Reads still use thereadscope.src/providers/gsc.test.ts: checks thePUTmethod, the double-encodedsiteUrl/feedpathpath (including?/&), that no body or content-type is sent, and the exact receipt bytes for empty 200 and 204. Also covers 403 details, a non-HTTP feedpath rejected before dispatch, and the existing mapping for 401/429/503/400.src/cli.test.ts: real argv → gate in a subprocess with a throwingfetch(denial), then--allow-write --dry-run→PUTplan.src/args.test.ts:--allow-writeis parsed forgscand rejected for bing/hubspot/dataforseo.scripts/generate-contract-provider.test.ts: GSC capability count 5 → 6.Local:
check-types,test(207 + site snapshot),eval,verify:package(gkit-0.2.1.tgz), and everygenerate:*:checkall pass. No real Google calls were made.Release
packages/gkit/package.json0.2.0 → 0.2.1. Merging triggersRelease gkit.