@brigadasos/nadeshiko-sdk 1.5.0-dev.9402be1 → 1.5.0-dev.c2b9767
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 +17 -14
- package/dist/index.cjs +91 -30
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +91 -30
- package/dist/index.js.map +4 -4
- package/dist/nadeshiko.gen.d.ts +5 -3
- package/dist/nadeshiko.gen.d.ts.map +1 -1
- package/dist/sdk.gen.d.ts +4 -4
- package/dist/sdk.gen.d.ts.map +1 -1
- package/dist/types.gen.d.ts +17 -25
- package/dist/types.gen.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ TypeScript SDK for the [Nadeshiko API](https://nadeshiko.co).
|
|
|
8
8
|
bun add @brigadasos/nadeshiko-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Install the internal build (includes internal endpoints) via the `internal` dist-tag:
|
|
11
|
+
Install the internal build (includes internal + session-authenticated endpoints) via the `internal` dist-tag:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
bun add @brigadasos/nadeshiko-sdk@internal
|
|
@@ -21,20 +21,23 @@ bun add @brigadasos/nadeshiko-sdk@internal
|
|
|
21
21
|
Use an API key for endpoints that don't require a user session. The key is sent as `Authorization: Bearer <apiKey>`.
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
|
-
import { createNadeshikoClient,
|
|
24
|
+
import { createNadeshikoClient, search } from '@brigadasos/nadeshiko-sdk';
|
|
25
25
|
|
|
26
26
|
const client = createNadeshikoClient({
|
|
27
27
|
apiKey: process.env.NADESHIKO_API_KEY!,
|
|
28
28
|
baseUrl: 'PRODUCTION',
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const result = await
|
|
31
|
+
const result = await search({
|
|
32
32
|
client,
|
|
33
|
-
body: { query: '彼女' },
|
|
33
|
+
body: { query: { search: '彼女' } },
|
|
34
34
|
});
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
### Session token (user-authenticated endpoints)
|
|
37
|
+
### Session token (user-authenticated endpoints, internal build only)
|
|
38
|
+
|
|
39
|
+
The default public package intentionally exposes API-key-capable endpoints only.
|
|
40
|
+
For session-authenticated endpoints (for example `/v1/user/*` and `/v1/collections/*`), use the internal build.
|
|
38
41
|
|
|
39
42
|
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
43
|
|
|
@@ -60,23 +63,23 @@ export default defineEventHandler(async (event) => {
|
|
|
60
63
|
});
|
|
61
64
|
```
|
|
62
65
|
|
|
63
|
-
**Browser
|
|
66
|
+
**Browser note:** if your session cookie is `HttpOnly`, use same-origin proxy routes and let the browser attach cookies automatically. Prefer server-side session handling for internal endpoints.
|
|
64
67
|
|
|
65
68
|
### Error handling
|
|
66
69
|
|
|
67
70
|
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`.
|
|
68
71
|
|
|
69
72
|
```typescript
|
|
70
|
-
import { createNadeshikoClient,
|
|
73
|
+
import { createNadeshikoClient, search } from '@brigadasos/nadeshiko-sdk';
|
|
71
74
|
|
|
72
75
|
const client = createNadeshikoClient({
|
|
73
76
|
apiKey: process.env.NADESHIKO_API_KEY!,
|
|
74
77
|
baseUrl: 'PRODUCTION',
|
|
75
78
|
});
|
|
76
79
|
|
|
77
|
-
const result = await
|
|
80
|
+
const result = await search({
|
|
78
81
|
client,
|
|
79
|
-
body: { query: '食べる' },
|
|
82
|
+
body: { query: { search: '食べる' } },
|
|
80
83
|
});
|
|
81
84
|
|
|
82
85
|
if (result.error) {
|
|
@@ -134,8 +137,8 @@ if (result.error) {
|
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
// result.data is fully typed as SearchResponse
|
|
137
|
-
for (const
|
|
138
|
-
console.log(
|
|
140
|
+
for (const segment of result.data.segments ?? []) {
|
|
141
|
+
console.log(segment.content.ja.content);
|
|
139
142
|
}
|
|
140
143
|
```
|
|
141
144
|
|
|
@@ -145,13 +148,13 @@ If you prefer exceptions over checking `.error`, pass `throwOnError: true`. The
|
|
|
145
148
|
|
|
146
149
|
```typescript
|
|
147
150
|
try {
|
|
148
|
-
const { data } = await
|
|
151
|
+
const { data } = await search({
|
|
149
152
|
client,
|
|
150
153
|
throwOnError: true,
|
|
151
|
-
body: { query: '彼女' },
|
|
154
|
+
body: { query: { search: '彼女' } },
|
|
152
155
|
});
|
|
153
156
|
|
|
154
|
-
console.log(data.
|
|
157
|
+
console.log(data.segments);
|
|
155
158
|
} catch (error) {
|
|
156
159
|
console.error('Request failed:', error);
|
|
157
160
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -972,7 +972,11 @@ var autocompleteMedia = (options) => (options.client ?? client).get({
|
|
|
972
972
|
...options
|
|
973
973
|
});
|
|
974
974
|
var getSegmentByUuid = (options) => (options.client ?? client).get({
|
|
975
|
-
security: [{ scheme: "bearer", type: "http" }
|
|
975
|
+
security: [{ scheme: "bearer", type: "http" }, {
|
|
976
|
+
in: "cookie",
|
|
977
|
+
name: "nadeshiko.session_token",
|
|
978
|
+
type: "apiKey"
|
|
979
|
+
}],
|
|
976
980
|
url: "/v1/media/segments/{uuid}",
|
|
977
981
|
...options
|
|
978
982
|
});
|
|
@@ -990,7 +994,11 @@ var updateSegmentByUuid = (options) => (options.client ?? client).patch({
|
|
|
990
994
|
}
|
|
991
995
|
});
|
|
992
996
|
var getSegmentContext = (options) => (options.client ?? client).get({
|
|
993
|
-
security: [{ scheme: "bearer", type: "http" }
|
|
997
|
+
security: [{ scheme: "bearer", type: "http" }, {
|
|
998
|
+
in: "cookie",
|
|
999
|
+
name: "nadeshiko.session_token",
|
|
1000
|
+
type: "apiKey"
|
|
1001
|
+
}],
|
|
994
1002
|
url: "/v1/media/segments/{uuid}/context",
|
|
995
1003
|
...options
|
|
996
1004
|
});
|
|
@@ -1399,17 +1407,29 @@ var getCollectionStats = (options) => (options.client ?? client).get({
|
|
|
1399
1407
|
...options
|
|
1400
1408
|
});
|
|
1401
1409
|
var getAdminDashboard = (options) => (options?.client ?? client).get({
|
|
1402
|
-
security: [{
|
|
1410
|
+
security: [{
|
|
1411
|
+
in: "cookie",
|
|
1412
|
+
name: "nadeshiko.session_token",
|
|
1413
|
+
type: "apiKey"
|
|
1414
|
+
}],
|
|
1403
1415
|
url: "/v1/admin/dashboard",
|
|
1404
1416
|
...options
|
|
1405
1417
|
});
|
|
1406
1418
|
var getAdminHealth = (options) => (options?.client ?? client).get({
|
|
1407
|
-
security: [{
|
|
1419
|
+
security: [{
|
|
1420
|
+
in: "cookie",
|
|
1421
|
+
name: "nadeshiko.session_token",
|
|
1422
|
+
type: "apiKey"
|
|
1423
|
+
}],
|
|
1408
1424
|
url: "/v1/admin/health",
|
|
1409
1425
|
...options
|
|
1410
1426
|
});
|
|
1411
1427
|
var triggerReindex = (options) => (options?.client ?? client).post({
|
|
1412
|
-
security: [{
|
|
1428
|
+
security: [{
|
|
1429
|
+
in: "cookie",
|
|
1430
|
+
name: "nadeshiko.session_token",
|
|
1431
|
+
type: "apiKey"
|
|
1432
|
+
}],
|
|
1413
1433
|
url: "/v1/admin/reindex",
|
|
1414
1434
|
...options,
|
|
1415
1435
|
headers: {
|
|
@@ -1418,45 +1438,52 @@ var triggerReindex = (options) => (options?.client ?? client).post({
|
|
|
1418
1438
|
}
|
|
1419
1439
|
});
|
|
1420
1440
|
var listAdminQueueStats = (options) => (options?.client ?? client).get({
|
|
1421
|
-
security: [{
|
|
1441
|
+
security: [{
|
|
1442
|
+
in: "cookie",
|
|
1443
|
+
name: "nadeshiko.session_token",
|
|
1444
|
+
type: "apiKey"
|
|
1445
|
+
}],
|
|
1422
1446
|
url: "/v1/admin/queues/stats",
|
|
1423
1447
|
...options
|
|
1424
1448
|
});
|
|
1425
1449
|
var getAdminQueue = (options) => (options.client ?? client).get({
|
|
1426
|
-
security: [{
|
|
1450
|
+
security: [{
|
|
1451
|
+
in: "cookie",
|
|
1452
|
+
name: "nadeshiko.session_token",
|
|
1453
|
+
type: "apiKey"
|
|
1454
|
+
}],
|
|
1427
1455
|
url: "/v1/admin/queues/{queueName}",
|
|
1428
1456
|
...options
|
|
1429
1457
|
});
|
|
1430
1458
|
var listAdminQueueFailed = (options) => (options.client ?? client).get({
|
|
1431
|
-
security: [{
|
|
1459
|
+
security: [{
|
|
1460
|
+
in: "cookie",
|
|
1461
|
+
name: "nadeshiko.session_token",
|
|
1462
|
+
type: "apiKey"
|
|
1463
|
+
}],
|
|
1432
1464
|
url: "/v1/admin/queues/{queueName}/failed",
|
|
1433
1465
|
...options
|
|
1434
1466
|
});
|
|
1435
1467
|
var retryAdminQueueFailed = (options) => (options.client ?? client).post({
|
|
1436
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1437
|
-
url: "/v1/admin/queues/{queueName}/retry",
|
|
1438
|
-
...options
|
|
1439
|
-
});
|
|
1440
|
-
var purgeAdminQueueFailed = (options) => (options.client ?? client).delete({
|
|
1441
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1442
|
-
url: "/v1/admin/queues/{queueName}/purge",
|
|
1443
|
-
...options
|
|
1444
|
-
});
|
|
1445
|
-
var clearAdminImpersonation = (options) => (options?.client ?? client).delete({
|
|
1446
1468
|
security: [{
|
|
1447
1469
|
in: "cookie",
|
|
1448
1470
|
name: "nadeshiko.session_token",
|
|
1449
1471
|
type: "apiKey"
|
|
1450
1472
|
}],
|
|
1451
|
-
url: "/v1/admin/
|
|
1473
|
+
url: "/v1/admin/queues/{queueName}/retry",
|
|
1452
1474
|
...options
|
|
1453
1475
|
});
|
|
1454
|
-
var
|
|
1476
|
+
var purgeAdminQueueFailed = (options) => (options.client ?? client).delete({
|
|
1455
1477
|
security: [{
|
|
1456
1478
|
in: "cookie",
|
|
1457
1479
|
name: "nadeshiko.session_token",
|
|
1458
1480
|
type: "apiKey"
|
|
1459
1481
|
}],
|
|
1482
|
+
url: "/v1/admin/queues/{queueName}/purge",
|
|
1483
|
+
...options
|
|
1484
|
+
});
|
|
1485
|
+
var clearAdminImpersonation = (options) => (options?.client ?? client).delete({ url: "/v1/admin/impersonation", ...options });
|
|
1486
|
+
var impersonateAdminUser = (options) => (options.client ?? client).post({
|
|
1460
1487
|
url: "/v1/admin/impersonation",
|
|
1461
1488
|
...options,
|
|
1462
1489
|
headers: {
|
|
@@ -1465,12 +1492,20 @@ var impersonateAdminUser = (options) => (options.client ?? client).post({
|
|
|
1465
1492
|
}
|
|
1466
1493
|
});
|
|
1467
1494
|
var listAdminReports = (options) => (options?.client ?? client).get({
|
|
1468
|
-
security: [{
|
|
1495
|
+
security: [{
|
|
1496
|
+
in: "cookie",
|
|
1497
|
+
name: "nadeshiko.session_token",
|
|
1498
|
+
type: "apiKey"
|
|
1499
|
+
}],
|
|
1469
1500
|
url: "/v1/admin/reports",
|
|
1470
1501
|
...options
|
|
1471
1502
|
});
|
|
1472
1503
|
var updateAdminReport = (options) => (options.client ?? client).patch({
|
|
1473
|
-
security: [{
|
|
1504
|
+
security: [{
|
|
1505
|
+
in: "cookie",
|
|
1506
|
+
name: "nadeshiko.session_token",
|
|
1507
|
+
type: "apiKey"
|
|
1508
|
+
}],
|
|
1474
1509
|
url: "/v1/admin/reports/{id}",
|
|
1475
1510
|
...options,
|
|
1476
1511
|
headers: {
|
|
@@ -1479,12 +1514,20 @@ var updateAdminReport = (options) => (options.client ?? client).patch({
|
|
|
1479
1514
|
}
|
|
1480
1515
|
});
|
|
1481
1516
|
var listAdminMediaAudits = (options) => (options?.client ?? client).get({
|
|
1482
|
-
security: [{
|
|
1517
|
+
security: [{
|
|
1518
|
+
in: "cookie",
|
|
1519
|
+
name: "nadeshiko.session_token",
|
|
1520
|
+
type: "apiKey"
|
|
1521
|
+
}],
|
|
1483
1522
|
url: "/v1/admin/media/audits",
|
|
1484
1523
|
...options
|
|
1485
1524
|
});
|
|
1486
1525
|
var updateAdminMediaAudit = (options) => (options.client ?? client).patch({
|
|
1487
|
-
security: [{
|
|
1526
|
+
security: [{
|
|
1527
|
+
in: "cookie",
|
|
1528
|
+
name: "nadeshiko.session_token",
|
|
1529
|
+
type: "apiKey"
|
|
1530
|
+
}],
|
|
1488
1531
|
url: "/v1/admin/media/audits/{name}",
|
|
1489
1532
|
...options,
|
|
1490
1533
|
headers: {
|
|
@@ -1493,17 +1536,29 @@ var updateAdminMediaAudit = (options) => (options.client ?? client).patch({
|
|
|
1493
1536
|
}
|
|
1494
1537
|
});
|
|
1495
1538
|
var runAdminMediaAudit = (options) => (options.client ?? client).post({
|
|
1496
|
-
security: [{
|
|
1539
|
+
security: [{
|
|
1540
|
+
in: "cookie",
|
|
1541
|
+
name: "nadeshiko.session_token",
|
|
1542
|
+
type: "apiKey"
|
|
1543
|
+
}],
|
|
1497
1544
|
url: "/v1/admin/media/audits/{name}/run",
|
|
1498
1545
|
...options
|
|
1499
1546
|
});
|
|
1500
1547
|
var listAdminMediaAuditRuns = (options) => (options?.client ?? client).get({
|
|
1501
|
-
security: [{
|
|
1548
|
+
security: [{
|
|
1549
|
+
in: "cookie",
|
|
1550
|
+
name: "nadeshiko.session_token",
|
|
1551
|
+
type: "apiKey"
|
|
1552
|
+
}],
|
|
1502
1553
|
url: "/v1/admin/media/audits/runs",
|
|
1503
1554
|
...options
|
|
1504
1555
|
});
|
|
1505
1556
|
var getAdminMediaAuditRun = (options) => (options.client ?? client).get({
|
|
1506
|
-
security: [{
|
|
1557
|
+
security: [{
|
|
1558
|
+
in: "cookie",
|
|
1559
|
+
name: "nadeshiko.session_token",
|
|
1560
|
+
type: "apiKey"
|
|
1561
|
+
}],
|
|
1507
1562
|
url: "/v1/admin/media/audits/runs/{id}",
|
|
1508
1563
|
...options
|
|
1509
1564
|
});
|
|
@@ -1520,7 +1575,13 @@ var defaultSessionTokenGetter = () => {
|
|
|
1520
1575
|
return match ? decodeURIComponent(match[1]) : undefined;
|
|
1521
1576
|
};
|
|
1522
1577
|
function createNadeshikoClient(config) {
|
|
1523
|
-
const baseUrl = config.baseUrl ? config.baseUrl in environments ? environments[config.baseUrl] : config.baseUrl
|
|
1578
|
+
const baseUrl = config.baseUrl === undefined ? environments.PRODUCTION : (config.baseUrl in environments) ? environments[config.baseUrl] : config.baseUrl;
|
|
1579
|
+
const getApiKey = async () => {
|
|
1580
|
+
if (typeof config.apiKey === "function") {
|
|
1581
|
+
return await config.apiKey();
|
|
1582
|
+
}
|
|
1583
|
+
return config.apiKey;
|
|
1584
|
+
};
|
|
1524
1585
|
const getSessionToken = config.sessionToken ?? defaultSessionTokenGetter;
|
|
1525
1586
|
const clientInstance = createClient(createConfig({
|
|
1526
1587
|
baseUrl,
|
|
@@ -1528,7 +1589,7 @@ function createNadeshikoClient(config) {
|
|
|
1528
1589
|
if (auth.in === "cookie") {
|
|
1529
1590
|
return getSessionToken();
|
|
1530
1591
|
}
|
|
1531
|
-
return
|
|
1592
|
+
return getApiKey();
|
|
1532
1593
|
}
|
|
1533
1594
|
}));
|
|
1534
1595
|
return {
|
|
@@ -1686,5 +1747,5 @@ __export(exports_admin_gen, {
|
|
|
1686
1747
|
clearAdminImpersonation: () => clearAdminImpersonation
|
|
1687
1748
|
});
|
|
1688
1749
|
|
|
1689
|
-
//# debugId=
|
|
1750
|
+
//# debugId=C46407DD30C813FE64756E2164756E21
|
|
1690
1751
|
//# sourceMappingURL=index.js.map
|