# GoGosling automation kit Node 22 or later. Download the files and run them; there are no packages to install. Use existing QA sessions, career API keys and diagnostic read keys. These helpers coordinate those APIs without adding another inference SDK or sharing credentials between products. The owner API is intended for trusted scripts and application backends, not a browser bundle. ## Download ```sh mkdir -p gosling-api/examples cd gosling-api curl --fail --show-error --silent https://api.gogosling.ca/clients/gosling-client.mjs -o gosling-client.mjs curl --fail --show-error --silent https://api.gogosling.ca/clients/gosling-client.d.mts -o gosling-client.d.mts curl --fail --show-error --silent https://api.gogosling.ca/clients/examples/sync-career.mjs -o examples/sync-career.mjs curl --fail --show-error --silent https://api.gogosling.ca/clients/examples/check-release-errors.mjs -o examples/check-release-errors.mjs curl --fail --show-error --silent https://api.gogosling.ca/clients/README.md -o README.md node examples/sync-career.mjs --help node examples/check-release-errors.mjs --help ``` Keep this layout so the examples can import their helper: ```text gosling-api/ gosling-client.mjs gosling-client.d.mts README.md examples/ sync-career.mjs check-release-errors.mjs ``` ## Configuration Supply credentials through your existing secret manager or process environment. The examples do not load `.env` files or accept secrets as command-line arguments. Do not embed keys in a URL or a webpage. | Variable | Used by | Meaning | | --- | --- | --- | | `GOSLING_API_BASE_URL` | Both examples | Optional; defaults to `https://api.gogosling.ca/v1`. Include `/v1`; HTTPS, without credentials, query or fragment. | | `GOSLING_CAREER_API_KEY` | Career sync | Existing owner key. `career:read` for a plan; `career:write` for `--apply`. Write includes read. | | `GOSLING_DIAGNOSTICS_READ_KEY` | Release check | Existing diagnostic **read** key for the selected product. An upload key cannot query logs. | | `GOSLING_QA_TOKEN` | Custom script below | Existing QA Bearer session. The examples above do not require it. | The library takes values explicitly rather than reading process environment: ```js import { createGoslingClient, GoslingApiError } from './gosling-client.mjs'; const api = createGoslingClient({ baseUrl: process.env.GOSLING_API_BASE_URL, credentials: { qa: process.env.GOSLING_QA_TOKEN, career: process.env.GOSLING_CAREER_API_KEY, }, }); // Include only families you have configured. Omit absent credential properties. const [account, career] = await Promise.all([ api.qa.account(), api.career.record({ sections: 'experience,projects', lang: 'en' }), ]); console.log({ quotaRemaining: account.data.quota.remaining, careerSections: career.data.meta.collections }); ``` Use `api.baseUrl` with your existing inference SDK and its separate inference caller key. Select the career facts or QA metadata you want to send before explicitly invoking that SDK. This kit never sends those records to a model. QA context listings contain document metadata, not source text; they cannot be used as retrieved evidence for the contents of a page or file. ## Sync one career entry Save `entry.json`: ```json { "collection": "projects", "id": "release-monitor", "entry": { "name": { "en": "Release monitor", "zh": null }, "kind": "independent", "summary": { "en": "Checks new error events for a software release.", "zh": null } } } ``` ```sh node examples/sync-career.mjs --file entry.json node examples/sync-career.mjs --file entry.json --apply ``` The first command reads the current entry and prints a plan without changing it. The second reads again and applies a change. Existing entries use `PUT` with the version in `If-Match`; new entries use `POST` with the supplied ID, so a concurrent creation returns a conflict. A `409` stops the run for review; writes are never retried automatically. Replacements contain the complete desired entry: omitted fields are removed. For precise no-op comparison, start from the canonical JSON returned by `api.career.entry()`; the server also accepts shorthand text fields and normalizes them when writing. The file is limited to 64 KiB. One entry is changed at a time, and nothing is deleted. Archived entries must be restored separately. The singleton `profile` must already exist before this example can sync it; its creation API has upsert semantics rather than a conflict-safe create. Output contains IDs, operation, version and request ID, not the entry's private text. ## Check new errors after a release ```sh node examples/check-release-errors.mjs \ --product your-product --release 1.2.3 \ --environment production --checkpoint ./release-1.2.3-errors.json \ --fail-on-error ``` Run this command again, or invoke it from your existing scheduler. It reads events after the last successful checkpoint and prints counts for each page. The first run starts at `after=0`, covering matching events still retained by the service. `--environment` and `--fail-on-error` are optional. Exit codes are `0` for success, `1` for configuration/transport/API failure, and `2` when the run succeeded but observed error/fatal events with `--fail-on-error` enabled. `has_more` controls pagination. `next_after` remains a valid checkpoint even on an empty final page. The script outputs each page successfully before replacing its checkpoint atomically with mode `0600`. Use a single worker per checkpoint; the file is bound to its API base, product, release and environment. Changing a filter requires a different checkpoint. The parent directory must already exist. An interruption between output and checkpoint persistence can repeat a page; consumers needing deduplication should use `(product, event.event_id)`. Checkpoints belong to one database history. After a restore or migration that changes that history, reset the checkpoint and deduplicate retained events. Checkpoints do not extend the service's retention period or recover expired records. ## Library methods Every method returns `{ data, status, family, requestId, retryAfterMs }`. `data` retains the service's original JSON envelope. Page methods yield this same object once per page; they never collect the full history in memory. | Method | Purpose | | --- | --- | | `catalogue()` | Public API discovery; sends no credential. | | `qa.login({login, password})` | Explicit login; saves the returned QA token in memory only. | | `qa.setToken(token)` / `qa.logout()` | Replace or clear the local QA session; logout revokes the server session. | | `qa.account()` | Account, quota and sessions, including `session_id` and `current`. | | `qa.revokeSession(sessionId)` | Revoke a selected session. Revoking the current one clears the local QA token and requires another login. | | `qa.context(params)` / `qa.contextPages(params)` | Context metadata; `limit`, `type`, `before`. | | `career.record(params)` | JSON record; `sections`, `lang`, `include`. | | `career.entry(collection, id)` | One entry with its version metadata. | | `career.create(collection, entry)` | Explicit create. The profile resource is an upsert; prefer versioned replacement of an existing profile. | | `career.replace(collection, id, entry, {ifMatch})` | Full replacement; a positive version is required. | | `career.history(params)` / `career.historyPages(params)` | Historical changes with `limit`, `before`; a history view, not a resumable commit feed. | | `diagnostics.events(params)` / `diagnostics.eventPages(params)` | Log filters; `before` for history or `after` for incremental polling. Do not combine them. | Pass `{ signal: abortController.signal }` as the final options argument to cancel a request. Page options also accept `maxPages` (default 100, maximum 10,000). The constructor accepts `timeoutMs` (default 15,000, range 1–120,000) and `maxResponseBytes` (default 2 MiB, range 1 KiB–8 MiB). Timeout covers the response body too. HTTP is available only for loopback tests with `allowHttpLoopback: true`. `GoslingApiError` exposes `code`, `family`, `status`, `requestId` and `retryAfterMs`. Its message omits response bodies and credential values. On a 429 or 503, schedule a later attempt after `retryAfterMs`; the kit performs no background retries, including for reads. Redirects are refused. There is no arbitrary-URL request method, custom authorization-header override or cookie jar. Validation uses synthetic fetch responses and temporary local fixtures. It covers family isolation, safe routing, cancellation, bounded bodies, cursors, session revocation, conflict-safe writes and failed checkpoint consumers; no production accounts, model calls or stored user records are involved.