@ankinize/sdk 0.1.0 → 1.1.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.
- package/README.md +4 -5
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +3 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -5,10 +5,7 @@ The official TypeScript SDK for the Ankinize REST API: one typed function per en
|
|
|
5
5
|
```ts
|
|
6
6
|
import { client, createNote, listDecks } from "@ankinize/sdk";
|
|
7
7
|
|
|
8
|
-
client.setConfig({
|
|
9
|
-
baseUrl: "https://your-ankinize.example",
|
|
10
|
-
auth: process.env.ANKINIZE_API_KEY,
|
|
11
|
-
});
|
|
8
|
+
client.setConfig({ auth: process.env.ANKINIZE_API_KEY });
|
|
12
9
|
|
|
13
10
|
const { decks } = await listDecks();
|
|
14
11
|
await createNote({
|
|
@@ -18,6 +15,8 @@ await createNote({
|
|
|
18
15
|
});
|
|
19
16
|
```
|
|
20
17
|
|
|
18
|
+
Requests go to `https://ankinize.com` by default, so only the API key is needed. `baseUrl` is optional: set it if you run your own server (`client.setConfig({ baseUrl: "https://anki.example.com", auth })`), or for a single call (`listDecks({ baseUrl })`).
|
|
19
|
+
|
|
21
20
|
A note names its note type and deck (`notetypeName`, `deckName`, compared ignoring case) and gives `fields` as an object keyed by each field's name in camelCase (`Back Extra` is `backExtra`). Send `notetypeId` or `deckId` instead when you have the id: exactly one of `notetypeName` and `notetypeId`, and at most one of `deckName` and `deckId`. A key is a field's name cut into words at spaces, punctuation and lower-to-upper changes, the first word in lower case: `The field` is `theField`, `ab_x` is `abX`, `URLText` is `urlText`. A field's exact name works as a key too, and each note type lists its keys in `getNoteType`. Reading a note (`getNote`, `listNotes`) gives `fields` in the same shape, and `updateNote` takes the same object with only the fields that change.
|
|
22
21
|
|
|
23
22
|
Parameters are camelCase everywhere. To make a write safe to retry, pass `idempotencyKey`; the SDK sends it as the `Idempotency-Key` header the API reads.
|
|
@@ -29,7 +28,7 @@ Out of the box the names are plain strings. To have the compiler check them, gen
|
|
|
29
28
|
```ts
|
|
30
29
|
import { client, generateTypes } from "@ankinize/sdk";
|
|
31
30
|
|
|
32
|
-
client.setConfig({
|
|
31
|
+
client.setConfig({ auth });
|
|
33
32
|
await Bun.write("ankinize.d.ts", await generateTypes());
|
|
34
33
|
```
|
|
35
34
|
|
package/dist/runtime.d.ts
CHANGED
|
@@ -16,4 +16,6 @@ export declare class AnkinizeError extends Error {
|
|
|
16
16
|
/** The raw answer, for headers such as `Retry-After`. Its body is already read. */
|
|
17
17
|
response: Response);
|
|
18
18
|
}
|
|
19
|
+
/** Where the SDK sends requests until `baseUrl` says otherwise (self-hosting sets it). */
|
|
20
|
+
export declare const DEFAULT_BASE_URL = "https://ankinize.com";
|
|
19
21
|
export declare const createClientConfig: CreateClientConfig;
|
package/dist/runtime.js
CHANGED
|
@@ -51,7 +51,10 @@ const apiFetch = async (input, init) => {
|
|
|
51
51
|
throw await toError(response);
|
|
52
52
|
return asBytes(response);
|
|
53
53
|
};
|
|
54
|
+
/** Where the SDK sends requests until `baseUrl` says otherwise (self-hosting sets it). */
|
|
55
|
+
export const DEFAULT_BASE_URL = "https://ankinize.com";
|
|
54
56
|
export const createClientConfig = (config) => ({
|
|
55
57
|
...config,
|
|
58
|
+
baseUrl: DEFAULT_BASE_URL,
|
|
56
59
|
fetch: apiFetch,
|
|
57
60
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankinize/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Official TypeScript SDK for the Ankinize REST API. Plain fetch, no runtime dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/0x0501/Ankinize.git",
|
|
9
|
+
"directory": "packages/sdk"
|
|
10
|
+
},
|
|
6
11
|
"publishConfig": {
|
|
7
12
|
"access": "public"
|
|
8
13
|
},
|