@f3liz/rescript-misskey-api 0.6.1 → 0.6.3
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/lib/es6/src/Cherrypick.mjs +4 -1
- package/lib/es6/src/Misskey.mjs +4 -1
- package/lib/ts/Misskey.js +2 -0
- package/package.json +2 -2
- package/src/Cherrypick.res +9 -1
- package/src/Misskey.res +19 -15
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as S from "sury/lib/es6/src/S.mjs";
|
|
3
4
|
import * as Misskey from "./Misskey.mjs";
|
|
4
5
|
import * as KokonectLinkWrapper from "./generated/kokonect-link/KokonectLinkWrapper.mjs";
|
|
5
6
|
|
|
7
|
+
S.enableJson();
|
|
8
|
+
|
|
6
9
|
function wrapperConnect(client) {
|
|
7
10
|
return KokonectLinkWrapper.connect(client.origin, client.token, client.fetchFn, undefined);
|
|
8
11
|
}
|
|
@@ -49,4 +52,4 @@ export {
|
|
|
49
52
|
wrapperConnect,
|
|
50
53
|
$$default as default,
|
|
51
54
|
}
|
|
52
|
-
/*
|
|
55
|
+
/* Not a pure module */
|
package/lib/es6/src/Misskey.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as S from "sury/lib/es6/src/S.mjs";
|
|
3
4
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
4
5
|
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
6
|
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
@@ -11,6 +12,8 @@ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js
|
|
|
11
12
|
import * as StreamConnection from "./stream/StreamConnection.mjs";
|
|
12
13
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
13
14
|
|
|
15
|
+
S.enableJson();
|
|
16
|
+
|
|
14
17
|
let FetchBindings = {};
|
|
15
18
|
|
|
16
19
|
function defaultFetch(origin, token) {
|
|
@@ -671,4 +674,4 @@ export {
|
|
|
671
674
|
isAPIError,
|
|
672
675
|
$$default as default,
|
|
673
676
|
}
|
|
674
|
-
/*
|
|
677
|
+
/* Not a pure module */
|
package/lib/ts/Misskey.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Misskey.ts - High-level TypeScript wrapper for Misskey API
|
|
2
2
|
import { MisskeyClient, Notes as NotesApi, Reactions as ReactionsApi, Antennas as AntennasApi } from './generated/misskey-io/wrapper/index';
|
|
3
|
+
import * as S from "sury";
|
|
4
|
+
S.enableJson();
|
|
3
5
|
// Re-export generated client for advanced usage
|
|
4
6
|
export { MisskeyClient };
|
|
5
7
|
export * from './generated/misskey-io/wrapper/index';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@f3liz/rescript-misskey-api",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "ReScript bindings for Misskey API using OpenAPI code generation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"misskey",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"sury": "11.0.0-alpha.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@f3liz/rescript-autogen-openapi": "^0.5.
|
|
45
|
+
"@f3liz/rescript-autogen-openapi": "^0.5.1",
|
|
46
46
|
"rescript": "^12.1.0",
|
|
47
47
|
"typescript": "^5.9.3"
|
|
48
48
|
},
|
package/src/Cherrypick.res
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
// Cherrypick shares the same API conventions as Misskey, so all
|
|
16
16
|
// the high-level APIs (Notes, Stream, Emojis, etc.) work identically.
|
|
17
17
|
|
|
18
|
+
// Enable JSON schema for Sury
|
|
19
|
+
S.enableJson()
|
|
20
|
+
|
|
18
21
|
// Use the same types
|
|
19
22
|
type t = Misskey.t
|
|
20
23
|
type fetchFn = Misskey.fetchFn
|
|
@@ -53,7 +56,12 @@ let isAPIError = Misskey.isAPIError
|
|
|
53
56
|
/// Create a wrapper client for use with the generated KokonectLinkWrapper.
|
|
54
57
|
/// This bridges the high-level Cherrypick.t client to the generated wrapper's client type.
|
|
55
58
|
let wrapperConnect = (client: t): KokonectLinkWrapper.client => {
|
|
56
|
-
KokonectLinkWrapper.connect(
|
|
59
|
+
KokonectLinkWrapper.connect(
|
|
60
|
+
~baseUrl=client.origin,
|
|
61
|
+
~token=?client.token,
|
|
62
|
+
~fetch=client.fetchFn,
|
|
63
|
+
(),
|
|
64
|
+
)
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
let default = connect
|
package/src/Misskey.res
CHANGED
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
// Fetch Bindings
|
|
23
23
|
// ============================================================================
|
|
24
24
|
|
|
25
|
+
// Enable JSON schema for Sury
|
|
26
|
+
S.enableJson()
|
|
27
|
+
|
|
25
28
|
module FetchBindings = {
|
|
26
29
|
type response
|
|
27
30
|
|
|
@@ -92,7 +95,9 @@ let defaultFetch = (~origin: string, ~token: option<string>) => {
|
|
|
92
95
|
if FetchBindings.ok(response) {
|
|
93
96
|
response->FetchBindings.json
|
|
94
97
|
} else {
|
|
95
|
-
let msg = `API error: ${FetchBindings.status(
|
|
98
|
+
let msg = `API error: ${FetchBindings.status(
|
|
99
|
+
response,
|
|
100
|
+
)->Int.toString} ${FetchBindings.statusText(response)}`
|
|
96
101
|
Promise.reject(JsExn(JsError.make(msg)->Obj.magic))
|
|
97
102
|
}
|
|
98
103
|
})
|
|
@@ -260,7 +265,9 @@ module Notes = {
|
|
|
260
265
|
untilId->Option.forEach(v => params->Dict.set("untilId", v->JSON.Encode.string))
|
|
261
266
|
|
|
262
267
|
extraParams->Option.forEach(extra => {
|
|
263
|
-
extra
|
|
268
|
+
extra
|
|
269
|
+
->Dict.toArray
|
|
270
|
+
->Array.forEach(((key, value)) => {
|
|
264
271
|
params->Dict.set(key, value)
|
|
265
272
|
})
|
|
266
273
|
})
|
|
@@ -407,8 +414,7 @@ module Emojis = {
|
|
|
407
414
|
|
|
408
415
|
/// Get list of custom emojis from instance.
|
|
409
416
|
let list = (client: t): promise<result<array<customEmoji>, string>> => {
|
|
410
|
-
request(client, "emojis", ())
|
|
411
|
-
->Promise.then(result => {
|
|
417
|
+
request(client, "emojis", ())->Promise.then(result => {
|
|
412
418
|
switch result {
|
|
413
419
|
| Ok(json) =>
|
|
414
420
|
switch json->JSON.Decode.object {
|
|
@@ -432,8 +438,7 @@ module Emojis = {
|
|
|
432
438
|
module CustomTimelines = {
|
|
433
439
|
/// Fetch user's antennas.
|
|
434
440
|
let antennas = (client: t): promise<result<array<JSON.t>, string>> => {
|
|
435
|
-
request(client, "antennas/list", ())
|
|
436
|
-
->Promise.then(result => {
|
|
441
|
+
request(client, "antennas/list", ())->Promise.then(result => {
|
|
437
442
|
switch result {
|
|
438
443
|
| Ok(json) =>
|
|
439
444
|
switch json->JSON.Decode.array {
|
|
@@ -447,8 +452,7 @@ module CustomTimelines = {
|
|
|
447
452
|
|
|
448
453
|
/// Fetch user's lists.
|
|
449
454
|
let lists = (client: t): promise<result<array<JSON.t>, string>> => {
|
|
450
|
-
request(client, "users/lists/list", ())
|
|
451
|
-
->Promise.then(result => {
|
|
455
|
+
request(client, "users/lists/list", ())->Promise.then(result => {
|
|
452
456
|
switch result {
|
|
453
457
|
| Ok(json) =>
|
|
454
458
|
switch json->JSON.Decode.array {
|
|
@@ -462,8 +466,7 @@ module CustomTimelines = {
|
|
|
462
466
|
|
|
463
467
|
/// Fetch user's followed channels.
|
|
464
468
|
let channels = (client: t): promise<result<array<JSON.t>, string>> => {
|
|
465
|
-
request(client, "channels/followed", ())
|
|
466
|
-
->Promise.then(result => {
|
|
469
|
+
request(client, "channels/followed", ())->Promise.then(result => {
|
|
467
470
|
switch result {
|
|
468
471
|
| Ok(json) =>
|
|
469
472
|
switch json->JSON.Decode.array {
|
|
@@ -639,13 +642,14 @@ module MiAuth = {
|
|
|
639
642
|
let headers = Dict.make()
|
|
640
643
|
headers->Dict.set("Content-Type", "application/json")
|
|
641
644
|
|
|
642
|
-
let response = await FetchBindings.fetch(
|
|
643
|
-
url,
|
|
644
|
-
{method: "POST", headers, body: Some("{}")},
|
|
645
|
-
)
|
|
645
|
+
let response = await FetchBindings.fetch(url, {method: "POST", headers, body: Some("{}")})
|
|
646
646
|
|
|
647
647
|
if !FetchBindings.ok(response) {
|
|
648
|
-
Error(
|
|
648
|
+
Error(
|
|
649
|
+
`HTTP error: ${FetchBindings.status(response)->Int.toString} ${FetchBindings.statusText(
|
|
650
|
+
response,
|
|
651
|
+
)}`,
|
|
652
|
+
)
|
|
649
653
|
} else {
|
|
650
654
|
let json = await response->FetchBindings.json
|
|
651
655
|
switch json->JSON.Decode.object {
|