Skip to content

Commit a3d764a

Browse files
author
settings-as-code-release
committed
docs(library): construct GithubApi with its options object
main now takes { token, io?, baseUrl?, apiVersion? }; the positional form compiled against the old signature and left the client unauthenticated.
1 parent 1a5a15a commit a3d764a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎docs/reference/library.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The package exports three paths: the entry (`.`), the committed settings.yml JSO
2121

2222
## The API by group
2323

24-
Every name below is exported from the entry, [src/index.ts](https://github.com/Vivswan/github-settings-as-code/blob/main/src/index.ts). Each group has one short example; the types beside each name are in the bundled declarations.
24+
Every name below is exported from the entry, [src/index.ts](https://github.com/Vivswan/github-settings-as-code/blob/main/src/index.ts). Each group has one short example; the types beside each name are in the bundled declarations. The examples continue from one another: `result` is the Validate group's validated document, `client` the Client group's `GithubApi`, and `config` in the Io example a `SingleConfig` (the action's parsed inputs).
2525

2626
### Validate and merge
2727

@@ -51,12 +51,12 @@ console.log(parsed.success, SECTION_KEYS.length, schema.$schema);
5151

5252
### Client
5353

54-
`GithubApi` is the REST and GraphQL client the action uses (retries, throttling, the pinned `DEFAULT_API_VERSION`, trace redaction); `GithubClient` is the interface a test double implements. `isPermissionError` and `isRateLimitError` classify an `ApiError`.
54+
`GithubApi` is the REST and GraphQL client the action uses (retries, throttling, the pinned `DEFAULT_API_VERSION`, trace redaction); it takes an options object whose only required field is `token` (`io`, `baseUrl`, and `apiVersion` are optional). `GithubClient` is the interface a test double implements. `isPermissionError` and `isRateLimitError` classify an `ApiError`.
5555

5656
```ts
57-
import { GithubApi, silentIo } from "@vivswan/github-settings-as-code";
57+
import { GithubApi } from "@vivswan/github-settings-as-code";
5858

59-
const client = new GithubApi(process.env.GITHUB_TOKEN ?? "", silentIo());
59+
const client = new GithubApi({ token: process.env.GITHUB_TOKEN ?? "" });
6060
```
6161

6262
### Check and apply
@@ -83,7 +83,7 @@ console.log(report.result, report.outcomes.map((o) => `${o.key}: ${o.status}`),
8383
The run flows the action wraps: `runSingle` (one repository from a local file), `runMulti` (repos-dir, discovery, defaults file), `runMerge` (fold files into one), with `concludeRun` and `failRun` turning a finished run into outputs and an exit code. `SingleConfig`, `MultiConfig`, and `MergeConfig` are the inputs the action parses into.
8484

8585
```ts
86-
import { runMerge } from "@vivswan/github-settings-as-code";
86+
import { runMerge, silentIo } from "@vivswan/github-settings-as-code";
8787

8888
const exitCode = runMerge(
8989
{ settingsFiles: ["base.yml", "team.yml"], mergedFile: "merged.yml", layering: "merge" },

0 commit comments

Comments
 (0)