negirau 0.2.0 → 0.3.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 +8 -5
- package/dist/index.d.mts +5 -9
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# negirau
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/js/negirau)
|
|
4
|
+
[](https://www.npmjs.com/package/negirau)
|
|
5
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
|
+
[](https://github.com/sincekmori/negirau/actions/workflows/ci.yml)
|
|
7
|
+
|
|
3
8
|
Typed TypeScript client for the [Negirau](https://negirau.com) public API (read-only, anonymous, CORS-open).
|
|
4
9
|
|
|
5
10
|
Hand-written around resource namespaces, a typed error hierarchy, and retries with exponential backoff — dependency-free, and kept honest by contract tests: they load the service's build-time-generated `openapi.json` and prove that every operation is covered, that requests only use spec-declared parameters, and that spec-conformant payloads satisfy the exported types.
|
|
@@ -18,17 +23,15 @@ import { Negirau } from "negirau";
|
|
|
18
23
|
|
|
19
24
|
const client = new Negirau();
|
|
20
25
|
|
|
21
|
-
const found = await client.subjects.list({ q: "
|
|
26
|
+
const found = await client.subjects.list({ q: "library", limit: 5 }); // free-text name search
|
|
22
27
|
for (const subject of found.subjects) {
|
|
23
28
|
console.log(subject.id, subject.name);
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
const nearby = await client.subjects.listNear(35.64, 139.65, { radius: 3000 });
|
|
27
32
|
|
|
28
|
-
const reactions = await client.subjects.reactions.retrieve("0e6f9b3a-6b1e-4b8a-9a6a-1c2d3e4f5a6b"
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
console.log(reactions.total); // a display value: exact up to 100, "100+" beyond
|
|
33
|
+
const reactions = await client.subjects.reactions.retrieve("0e6f9b3a-6b1e-4b8a-9a6a-1c2d3e4f5a6b");
|
|
34
|
+
console.log(reactions.total); // the all-time display value: exact up to 100, "100+" beyond
|
|
32
35
|
```
|
|
33
36
|
|
|
34
37
|
Errors and retries:
|
package/dist/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ interface TransportOptions {
|
|
|
10
10
|
/** Public response types, contract-tested against the spec (tests/contract.test.ts). */
|
|
11
11
|
/** Display value — the only count representation the API ever exposes: exact up to 100, "100+" beyond. */
|
|
12
12
|
type DisplayValue = string;
|
|
13
|
-
/** A recipient of appreciation — a name, optionally with a location
|
|
13
|
+
/** A recipient of appreciation — a name, optionally with a location. */
|
|
14
14
|
interface Subject {
|
|
15
15
|
/** Public identifier; the page URL is https://negirau.com/subjects/{id}. */
|
|
16
16
|
id: string;
|
|
@@ -34,11 +34,9 @@ interface SubjectListParams {
|
|
|
34
34
|
limit?: number;
|
|
35
35
|
cursor?: string;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
37
|
+
/** All-time reaction display values for one subject. */
|
|
38
38
|
interface ReactionsSummary {
|
|
39
39
|
id: string;
|
|
40
|
-
/** The aggregation period as requested ('2026-W33', '2026-08', '2026', or 'all'). */
|
|
41
|
-
period: string;
|
|
42
40
|
total: DisplayValue;
|
|
43
41
|
by_type: Record<string, DisplayValue>;
|
|
44
42
|
}
|
|
@@ -48,10 +46,8 @@ interface ReactionsSummary {
|
|
|
48
46
|
declare class Reactions {
|
|
49
47
|
#private;
|
|
50
48
|
constructor(transport: TransportOptions);
|
|
51
|
-
/**
|
|
52
|
-
retrieve(id: string
|
|
53
|
-
period?: string;
|
|
54
|
-
}): Promise<ReactionsSummary>;
|
|
49
|
+
/** All-time reaction display values for a subject. */
|
|
50
|
+
retrieve(id: string): Promise<ReactionsSummary>;
|
|
55
51
|
}
|
|
56
52
|
/** The recipients of appreciation. */
|
|
57
53
|
declare class Subjects {
|
|
@@ -118,7 +114,7 @@ interface NegirauOptions {
|
|
|
118
114
|
* ```ts
|
|
119
115
|
* import { Negirau } from "negirau";
|
|
120
116
|
* const client = new Negirau();
|
|
121
|
-
* const page = await client.subjects.list({ q: "
|
|
117
|
+
* const page = await client.subjects.list({ q: "library" });
|
|
122
118
|
* ```
|
|
123
119
|
*/
|
|
124
120
|
declare class Negirau {
|
package/dist/index.mjs
CHANGED
|
@@ -110,9 +110,9 @@ var Reactions = class {
|
|
|
110
110
|
constructor(transport) {
|
|
111
111
|
this.#transport = transport;
|
|
112
112
|
}
|
|
113
|
-
/**
|
|
114
|
-
retrieve(id
|
|
115
|
-
return get(this.#transport, `/subjects/${encodeURIComponent(id)}/reactions
|
|
113
|
+
/** All-time reaction display values for a subject. */
|
|
114
|
+
retrieve(id) {
|
|
115
|
+
return get(this.#transport, `/subjects/${encodeURIComponent(id)}/reactions`);
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
/** The recipients of appreciation. */
|
|
@@ -161,7 +161,7 @@ var Subjects = class {
|
|
|
161
161
|
* ```ts
|
|
162
162
|
* import { Negirau } from "negirau";
|
|
163
163
|
* const client = new Negirau();
|
|
164
|
-
* const page = await client.subjects.list({ q: "
|
|
164
|
+
* const page = await client.subjects.list({ q: "library" });
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
var Negirau = class {
|