@brigadasos/nadeshiko-sdk 1.4.2-dev.a13aba0 → 1.4.3-dev.09dcbc3
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 +34 -10
- package/dist/index.cjs +65 -47
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -47
- package/dist/index.js.map +4 -4
- package/dist/internal/media.gen.d.ts +1 -1
- package/dist/internal/media.gen.d.ts.map +1 -1
- package/dist/internal/user.gen.d.ts +1 -1
- package/dist/internal/user.gen.d.ts.map +1 -1
- package/dist/nadeshiko.gen.d.ts +24 -14
- package/dist/nadeshiko.gen.d.ts.map +1 -1
- package/dist/sdk.gen.d.ts +23 -12
- package/dist/sdk.gen.d.ts.map +1 -1
- package/dist/types.gen.d.ts +134 -55
- package/dist/types.gen.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,14 +14,16 @@ Install the internal build (includes internal endpoints) via the `internal` dist
|
|
|
14
14
|
bun add @brigadasos/nadeshiko-sdk@internal
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Authentication
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### API key (server-to-server)
|
|
20
|
+
|
|
21
|
+
Use an API key for endpoints that don't require a user session. The key is sent as `Authorization: Bearer <apiKey>`.
|
|
20
22
|
|
|
21
23
|
```typescript
|
|
22
|
-
import {
|
|
24
|
+
import { createNadeshikoClient, searchSegments } from '@brigadasos/nadeshiko-sdk';
|
|
23
25
|
|
|
24
|
-
const client =
|
|
26
|
+
const client = createNadeshikoClient({
|
|
25
27
|
apiKey: process.env.NADESHIKO_API_KEY!,
|
|
26
28
|
baseUrl: 'PRODUCTION',
|
|
27
29
|
});
|
|
@@ -30,22 +32,44 @@ const result = await searchSegments({
|
|
|
30
32
|
client,
|
|
31
33
|
body: { query: '彼女' },
|
|
32
34
|
});
|
|
35
|
+
```
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
### Session token (user-authenticated endpoints)
|
|
38
|
+
|
|
39
|
+
Endpoints under `/v1/user/*` and `/v1/collections/*` require a user session. Pass a `sessionToken` getter that returns the value of the `nadeshiko.session_token` cookie — called fresh on every request.
|
|
40
|
+
|
|
41
|
+
**Nuxt / Nitro server routes:**
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// server/utils/nadeshiko.ts
|
|
45
|
+
import { createNadeshikoClient } from '@brigadasos/nadeshiko-sdk';
|
|
46
|
+
import type { H3Event } from 'h3';
|
|
47
|
+
|
|
48
|
+
export function useNadeshikoClient(event: H3Event) {
|
|
49
|
+
return createNadeshikoClient({
|
|
50
|
+
sessionToken: () => getCookie(event, 'nadeshiko.session_token'),
|
|
51
|
+
});
|
|
38
52
|
}
|
|
39
53
|
```
|
|
40
54
|
|
|
55
|
+
```typescript
|
|
56
|
+
// server/api/preferences.get.ts
|
|
57
|
+
export default defineEventHandler(async (event) => {
|
|
58
|
+
const client = useNadeshikoClient(event);
|
|
59
|
+
return client.getUserPreferences();
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Browser (no configuration needed):** the default `sessionToken` getter reads `nadeshiko.session_token` from `document.cookie` automatically.
|
|
64
|
+
|
|
41
65
|
### Error handling
|
|
42
66
|
|
|
43
67
|
Every response returns a discriminated union with either `data` or `error`. The `error` object follows the [RFC 7807](https://tools.ietf.org/html/rfc7807) Problem Details format, so you always get a machine-readable `code` and a human-readable `detail`.
|
|
44
68
|
|
|
45
69
|
```typescript
|
|
46
|
-
import {
|
|
70
|
+
import { createNadeshikoClient, searchSegments } from '@brigadasos/nadeshiko-sdk';
|
|
47
71
|
|
|
48
|
-
const client =
|
|
72
|
+
const client = createNadeshikoClient({
|
|
49
73
|
apiKey: process.env.NADESHIKO_API_KEY!,
|
|
50
74
|
baseUrl: 'PRODUCTION',
|
|
51
75
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -30,10 +30,10 @@ var __export = (target, all) => {
|
|
|
30
30
|
var exports_dev = {};
|
|
31
31
|
__export(exports_dev, {
|
|
32
32
|
user: () => exports_user_gen,
|
|
33
|
+
updateUserPreferences: () => updateUserPreferences,
|
|
33
34
|
updateSeriesMedia: () => updateSeriesMedia,
|
|
34
35
|
updateSeries: () => updateSeries,
|
|
35
36
|
updateSegment: () => updateSegment,
|
|
36
|
-
updatePreferences: () => updatePreferences,
|
|
37
37
|
updateMedia: () => updateMedia,
|
|
38
38
|
updateEpisode: () => updateEpisode,
|
|
39
39
|
updateCollectionSegment: () => updateCollectionSegment,
|
|
@@ -49,11 +49,12 @@ __export(exports_dev, {
|
|
|
49
49
|
removeMediaFromSeries: () => removeMediaFromSeries,
|
|
50
50
|
purgeAdminQueueFailed: () => purgeAdminQueueFailed,
|
|
51
51
|
media: () => exports_media_gen,
|
|
52
|
+
listUserReports: () => listUserReports,
|
|
53
|
+
listUserLabs: () => listUserLabs,
|
|
54
|
+
listUserActivity: () => listUserActivity,
|
|
52
55
|
listSeries: () => listSeries,
|
|
53
56
|
listSegments: () => listSegments,
|
|
54
|
-
listReports: () => listReports,
|
|
55
57
|
listMedia: () => listMedia,
|
|
56
|
-
listLabs: () => listLabs,
|
|
57
58
|
listEpisodes: () => listEpisodes,
|
|
58
59
|
listCollections: () => listCollections,
|
|
59
60
|
listAdminReviewRuns: () => listAdminReviewRuns,
|
|
@@ -62,15 +63,16 @@ __export(exports_dev, {
|
|
|
62
63
|
listAdminReports: () => listAdminReports,
|
|
63
64
|
listAdminQueueStats: () => listAdminQueueStats,
|
|
64
65
|
listAdminQueueFailed: () => listAdminQueueFailed,
|
|
65
|
-
|
|
66
|
+
getUserQuota: () => getUserQuota,
|
|
67
|
+
getUserPreferences: () => getUserPreferences,
|
|
68
|
+
getUserActivityStats: () => getUserActivityStats,
|
|
69
|
+
getUserActivityHeatmap: () => getUserActivityHeatmap,
|
|
66
70
|
getSeries: () => getSeries,
|
|
67
71
|
getSeiyuu: () => getSeiyuu,
|
|
68
72
|
getSegmentContext: () => getSegmentContext,
|
|
69
73
|
getSegmentByUuid: () => getSegmentByUuid,
|
|
70
74
|
getSegment: () => getSegment,
|
|
71
75
|
getSearchStats: () => getSearchStats,
|
|
72
|
-
getQuota: () => getQuota,
|
|
73
|
-
getPreferences: () => getPreferences,
|
|
74
76
|
getMedia: () => getMedia,
|
|
75
77
|
getEpisode: () => getEpisode,
|
|
76
78
|
getCollection: () => getCollection,
|
|
@@ -79,26 +81,24 @@ __export(exports_dev, {
|
|
|
79
81
|
getAdminQueue: () => getAdminQueue,
|
|
80
82
|
getAdminHealth: () => getAdminHealth,
|
|
81
83
|
getAdminDashboard: () => getAdminDashboard,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
exportData: () => exportData,
|
|
84
|
+
exportUserData: () => exportUserData,
|
|
85
|
+
deleteUserActivity: () => deleteUserActivity,
|
|
85
86
|
deleteSeries: () => deleteSeries,
|
|
86
87
|
deleteSegment: () => deleteSegment,
|
|
87
88
|
deleteMedia: () => deleteMedia,
|
|
88
89
|
deleteEpisode: () => deleteEpisode,
|
|
89
90
|
deleteCollection: () => deleteCollection,
|
|
90
91
|
deleteAdminReviewAllowlistEntry: () => deleteAdminReviewAllowlistEntry,
|
|
91
|
-
|
|
92
|
+
createUserReport: () => createUserReport,
|
|
92
93
|
createSeries: () => createSeries,
|
|
93
94
|
createSegment: () => createSegment,
|
|
94
|
-
createReport: () => createReport,
|
|
95
95
|
createNadeshikoClient: () => createNadeshikoClient,
|
|
96
96
|
createMedia: () => createMedia,
|
|
97
97
|
createEpisode: () => createEpisode,
|
|
98
98
|
createCollection: () => createCollection,
|
|
99
|
-
createClient: () => createClient2,
|
|
100
99
|
createAdminReviewAllowlistEntry: () => createAdminReviewAllowlistEntry,
|
|
101
100
|
client: () => client,
|
|
101
|
+
autocompleteMedia: () => autocompleteMedia,
|
|
102
102
|
admin: () => exports_admin_gen,
|
|
103
103
|
addSegmentToCollection: () => addSegmentToCollection,
|
|
104
104
|
addMediaToSeries: () => addMediaToSeries
|
|
@@ -961,6 +961,11 @@ var createMedia = (options) => (options.client ?? client).post({
|
|
|
961
961
|
...options.headers
|
|
962
962
|
}
|
|
963
963
|
});
|
|
964
|
+
var autocompleteMedia = (options) => (options.client ?? client).get({
|
|
965
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
966
|
+
url: "/v1/media/autocomplete",
|
|
967
|
+
...options
|
|
968
|
+
});
|
|
964
969
|
var deleteMedia = (options) => (options.client ?? client).delete({
|
|
965
970
|
security: [{ scheme: "bearer", type: "http" }],
|
|
966
971
|
url: "/v1/media/{id}",
|
|
@@ -1130,7 +1135,7 @@ var getSeiyuu = (options) => (options.client ?? client).get({
|
|
|
1130
1135
|
url: "/v1/media/seiyuu/{id}",
|
|
1131
1136
|
...options
|
|
1132
1137
|
});
|
|
1133
|
-
var
|
|
1138
|
+
var getUserQuota = (options) => (options?.client ?? client).get({
|
|
1134
1139
|
security: [{
|
|
1135
1140
|
in: "cookie",
|
|
1136
1141
|
name: "nadeshiko.session_token",
|
|
@@ -1139,7 +1144,7 @@ var getQuota = (options) => (options?.client ?? client).get({
|
|
|
1139
1144
|
url: "/v1/user/quota",
|
|
1140
1145
|
...options
|
|
1141
1146
|
});
|
|
1142
|
-
var
|
|
1147
|
+
var listUserReports = (options) => (options?.client ?? client).get({
|
|
1143
1148
|
security: [{
|
|
1144
1149
|
in: "cookie",
|
|
1145
1150
|
name: "nadeshiko.session_token",
|
|
@@ -1148,7 +1153,7 @@ var listReports = (options) => (options?.client ?? client).get({
|
|
|
1148
1153
|
url: "/v1/user/reports",
|
|
1149
1154
|
...options
|
|
1150
1155
|
});
|
|
1151
|
-
var
|
|
1156
|
+
var createUserReport = (options) => (options.client ?? client).post({
|
|
1152
1157
|
security: [{
|
|
1153
1158
|
in: "cookie",
|
|
1154
1159
|
name: "nadeshiko.session_token",
|
|
@@ -1161,7 +1166,7 @@ var createReport = (options) => (options.client ?? client).post({
|
|
|
1161
1166
|
...options.headers
|
|
1162
1167
|
}
|
|
1163
1168
|
});
|
|
1164
|
-
var
|
|
1169
|
+
var getUserPreferences = (options) => (options?.client ?? client).get({
|
|
1165
1170
|
security: [{
|
|
1166
1171
|
in: "cookie",
|
|
1167
1172
|
name: "nadeshiko.session_token",
|
|
@@ -1170,7 +1175,7 @@ var getPreferences = (options) => (options?.client ?? client).get({
|
|
|
1170
1175
|
url: "/v1/user/preferences",
|
|
1171
1176
|
...options
|
|
1172
1177
|
});
|
|
1173
|
-
var
|
|
1178
|
+
var updateUserPreferences = (options) => (options.client ?? client).patch({
|
|
1174
1179
|
security: [{
|
|
1175
1180
|
in: "cookie",
|
|
1176
1181
|
name: "nadeshiko.session_token",
|
|
@@ -1183,7 +1188,7 @@ var updatePreferences = (options) => (options.client ?? client).patch({
|
|
|
1183
1188
|
...options.headers
|
|
1184
1189
|
}
|
|
1185
1190
|
});
|
|
1186
|
-
var
|
|
1191
|
+
var deleteUserActivity = (options) => (options?.client ?? client).delete({
|
|
1187
1192
|
security: [{
|
|
1188
1193
|
in: "cookie",
|
|
1189
1194
|
name: "nadeshiko.session_token",
|
|
@@ -1192,7 +1197,7 @@ var deleteActivity = (options) => (options?.client ?? client).delete({
|
|
|
1192
1197
|
url: "/v1/user/activity",
|
|
1193
1198
|
...options
|
|
1194
1199
|
});
|
|
1195
|
-
var
|
|
1200
|
+
var listUserActivity = (options) => (options?.client ?? client).get({
|
|
1196
1201
|
security: [{
|
|
1197
1202
|
in: "cookie",
|
|
1198
1203
|
name: "nadeshiko.session_token",
|
|
@@ -1201,7 +1206,7 @@ var listActivity = (options) => (options?.client ?? client).get({
|
|
|
1201
1206
|
url: "/v1/user/activity",
|
|
1202
1207
|
...options
|
|
1203
1208
|
});
|
|
1204
|
-
var
|
|
1209
|
+
var getUserActivityHeatmap = (options) => (options?.client ?? client).get({
|
|
1205
1210
|
security: [{
|
|
1206
1211
|
in: "cookie",
|
|
1207
1212
|
name: "nadeshiko.session_token",
|
|
@@ -1210,7 +1215,7 @@ var getActivityHeatmap = (options) => (options?.client ?? client).get({
|
|
|
1210
1215
|
url: "/v1/user/activity/heatmap",
|
|
1211
1216
|
...options
|
|
1212
1217
|
});
|
|
1213
|
-
var
|
|
1218
|
+
var getUserActivityStats = (options) => (options?.client ?? client).get({
|
|
1214
1219
|
security: [{
|
|
1215
1220
|
in: "cookie",
|
|
1216
1221
|
name: "nadeshiko.session_token",
|
|
@@ -1219,7 +1224,7 @@ var getActivityStats = (options) => (options?.client ?? client).get({
|
|
|
1219
1224
|
url: "/v1/user/activity/stats",
|
|
1220
1225
|
...options
|
|
1221
1226
|
});
|
|
1222
|
-
var
|
|
1227
|
+
var exportUserData = (options) => (options?.client ?? client).get({
|
|
1223
1228
|
security: [{
|
|
1224
1229
|
in: "cookie",
|
|
1225
1230
|
name: "nadeshiko.session_token",
|
|
@@ -1228,7 +1233,7 @@ var exportData = (options) => (options?.client ?? client).get({
|
|
|
1228
1233
|
url: "/v1/user/export",
|
|
1229
1234
|
...options
|
|
1230
1235
|
});
|
|
1231
|
-
var
|
|
1236
|
+
var listUserLabs = (options) => (options?.client ?? client).get({
|
|
1232
1237
|
security: [{
|
|
1233
1238
|
in: "cookie",
|
|
1234
1239
|
name: "nadeshiko.session_token",
|
|
@@ -1437,11 +1442,23 @@ var environments = {
|
|
|
1437
1442
|
DEVELOPMENT: "https://api.dev.brigadasos.xyz/api",
|
|
1438
1443
|
PRODUCTION: "https://api.brigadasos.xyz/api"
|
|
1439
1444
|
};
|
|
1445
|
+
var defaultSessionTokenGetter = () => {
|
|
1446
|
+
if (typeof document === "undefined")
|
|
1447
|
+
return;
|
|
1448
|
+
const match = document.cookie.match(/(?:^|;\s*)nadeshiko\.session_token=([^;]*)/);
|
|
1449
|
+
return match ? decodeURIComponent(match[1]) : undefined;
|
|
1450
|
+
};
|
|
1440
1451
|
function createNadeshikoClient(config) {
|
|
1441
1452
|
const baseUrl = config.baseUrl ? config.baseUrl in environments ? environments[config.baseUrl] : config.baseUrl : environments.PRODUCTION;
|
|
1453
|
+
const getSessionToken = config.sessionToken ?? defaultSessionTokenGetter;
|
|
1442
1454
|
const clientInstance = createClient(createConfig({
|
|
1443
1455
|
baseUrl,
|
|
1444
|
-
|
|
1456
|
+
auth: (auth) => {
|
|
1457
|
+
if (auth.in === "cookie") {
|
|
1458
|
+
return getSessionToken();
|
|
1459
|
+
}
|
|
1460
|
+
return config.apiKey;
|
|
1461
|
+
}
|
|
1445
1462
|
}));
|
|
1446
1463
|
return {
|
|
1447
1464
|
client: clientInstance,
|
|
@@ -1459,7 +1476,7 @@ function createNadeshikoClient(config) {
|
|
|
1459
1476
|
getSeries: (options) => getSeries({ ...options, client: clientInstance }),
|
|
1460
1477
|
getCharacter: (options) => getCharacter({ ...options, client: clientInstance }),
|
|
1461
1478
|
getSeiyuu: (options) => getSeiyuu({ ...options, client: clientInstance }),
|
|
1462
|
-
|
|
1479
|
+
getUserQuota: (options) => getUserQuota({ ...options, client: clientInstance }),
|
|
1463
1480
|
listCollections: (options) => listCollections({ ...options, client: clientInstance }),
|
|
1464
1481
|
createCollection: (options) => createCollection({ ...options, client: clientInstance }),
|
|
1465
1482
|
getCollection: (options) => getCollection({ ...options, client: clientInstance }),
|
|
@@ -1485,6 +1502,7 @@ function createNadeshikoClient(config) {
|
|
|
1485
1502
|
createAdminReviewAllowlistEntry: (options) => createAdminReviewAllowlistEntry({ ...options, client: clientInstance }),
|
|
1486
1503
|
deleteAdminReviewAllowlistEntry: (options) => deleteAdminReviewAllowlistEntry({ ...options, client: clientInstance }),
|
|
1487
1504
|
createMedia: (options) => createMedia({ ...options, client: clientInstance }),
|
|
1505
|
+
autocompleteMedia: (options) => autocompleteMedia({ ...options, client: clientInstance }),
|
|
1488
1506
|
updateMedia: (options) => updateMedia({ ...options, client: clientInstance }),
|
|
1489
1507
|
deleteMedia: (options) => deleteMedia({ ...options, client: clientInstance }),
|
|
1490
1508
|
createEpisode: (options) => createEpisode({ ...options, client: clientInstance }),
|
|
@@ -1500,21 +1518,20 @@ function createNadeshikoClient(config) {
|
|
|
1500
1518
|
addMediaToSeries: (options) => addMediaToSeries({ ...options, client: clientInstance }),
|
|
1501
1519
|
updateSeriesMedia: (options) => updateSeriesMedia({ ...options, client: clientInstance }),
|
|
1502
1520
|
removeMediaFromSeries: (options) => removeMediaFromSeries({ ...options, client: clientInstance }),
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1521
|
+
createUserReport: (options) => createUserReport({ ...options, client: clientInstance }),
|
|
1522
|
+
listUserReports: (options) => listUserReports({ ...options, client: clientInstance }),
|
|
1523
|
+
getUserPreferences: (options) => getUserPreferences({ ...options, client: clientInstance }),
|
|
1524
|
+
updateUserPreferences: (options) => updateUserPreferences({ ...options, client: clientInstance }),
|
|
1525
|
+
listUserActivity: (options) => listUserActivity({ ...options, client: clientInstance }),
|
|
1526
|
+
deleteUserActivity: (options) => deleteUserActivity({ ...options, client: clientInstance }),
|
|
1527
|
+
getUserActivityHeatmap: (options) => getUserActivityHeatmap({ ...options, client: clientInstance }),
|
|
1528
|
+
getUserActivityStats: (options) => getUserActivityStats({ ...options, client: clientInstance }),
|
|
1529
|
+
exportUserData: (options) => exportUserData({ ...options, client: clientInstance }),
|
|
1530
|
+
listUserLabs: (options) => listUserLabs({ ...options, client: clientInstance }),
|
|
1513
1531
|
getAdminDashboard: (options) => getAdminDashboard({ ...options, client: clientInstance }),
|
|
1514
1532
|
getAdminHealth: (options) => getAdminHealth({ ...options, client: clientInstance })
|
|
1515
1533
|
};
|
|
1516
1534
|
}
|
|
1517
|
-
var createClient2 = createNadeshikoClient;
|
|
1518
1535
|
// generated/dev/internal/media.gen.ts
|
|
1519
1536
|
var exports_media_gen = {};
|
|
1520
1537
|
__export(exports_media_gen, {
|
|
@@ -1533,21 +1550,22 @@ __export(exports_media_gen, {
|
|
|
1533
1550
|
createSegment: () => createSegment,
|
|
1534
1551
|
createMedia: () => createMedia,
|
|
1535
1552
|
createEpisode: () => createEpisode,
|
|
1553
|
+
autocompleteMedia: () => autocompleteMedia,
|
|
1536
1554
|
addMediaToSeries: () => addMediaToSeries
|
|
1537
1555
|
});
|
|
1538
1556
|
// generated/dev/internal/user.gen.ts
|
|
1539
1557
|
var exports_user_gen = {};
|
|
1540
1558
|
__export(exports_user_gen, {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1559
|
+
updateUserPreferences: () => updateUserPreferences,
|
|
1560
|
+
listUserReports: () => listUserReports,
|
|
1561
|
+
listUserLabs: () => listUserLabs,
|
|
1562
|
+
listUserActivity: () => listUserActivity,
|
|
1563
|
+
getUserPreferences: () => getUserPreferences,
|
|
1564
|
+
getUserActivityStats: () => getUserActivityStats,
|
|
1565
|
+
getUserActivityHeatmap: () => getUserActivityHeatmap,
|
|
1566
|
+
exportUserData: () => exportUserData,
|
|
1567
|
+
deleteUserActivity: () => deleteUserActivity,
|
|
1568
|
+
createUserReport: () => createUserReport
|
|
1551
1569
|
});
|
|
1552
1570
|
// generated/dev/internal/admin.gen.ts
|
|
1553
1571
|
var exports_admin_gen = {};
|
|
@@ -1556,5 +1574,5 @@ __export(exports_admin_gen, {
|
|
|
1556
1574
|
getAdminDashboard: () => getAdminDashboard
|
|
1557
1575
|
});
|
|
1558
1576
|
|
|
1559
|
-
//# debugId=
|
|
1577
|
+
//# debugId=4B0EFE7CA1477FC664756E2164756E21
|
|
1560
1578
|
//# sourceMappingURL=index.js.map
|