@usenadia/node 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +119 -2
- package/dist/index.d.mts +4408 -0
- package/dist/index.d.ts +4408 -0
- package/dist/index.js +1729 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1623 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vincent Ventalon (UseNadia)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,120 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @usenadia/node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node SDK for the **UseNadia** public API (`/public/v1`) — schedule posts,
|
|
4
|
+
manage channels, and drive the Instagram comment/story → DM machinery.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm add @usenadia/node
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { Nadia, NadiaError } from '@usenadia/node';
|
|
12
|
+
|
|
13
|
+
const nadia = new Nadia(process.env.USENADIA_API_KEY!);
|
|
14
|
+
|
|
15
|
+
const channels = await nadia.integrations();
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await nadia.post({
|
|
19
|
+
type: 'schedule',
|
|
20
|
+
date: '2026-10-01T09:00:00.000Z',
|
|
21
|
+
shortLink: false,
|
|
22
|
+
tags: [],
|
|
23
|
+
posts: [
|
|
24
|
+
{
|
|
25
|
+
integration: { id: channels[0].id },
|
|
26
|
+
value: [{ content: 'Hello from the SDK', image: [] }],
|
|
27
|
+
settings: {},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (err instanceof NadiaError) {
|
|
33
|
+
console.error(err.status, err.message); // 402 "You have reached your limit"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## The content board
|
|
39
|
+
|
|
40
|
+
Every card of the board in the app is reachable: create one from anywhere
|
|
41
|
+
(a voice note, a Notion page, a DM), move it along, read its numbers once
|
|
42
|
+
it is published.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const card = await nadia.createContent({
|
|
46
|
+
title: 'Three mistakes when moving to Malta',
|
|
47
|
+
hook: 'Nobody told me about the third one.',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await nadia.moveContent(card.id, 'SCRIPT');
|
|
51
|
+
await nadia.updateContent(card.id, { script: '…' });
|
|
52
|
+
|
|
53
|
+
// Scheduled with nadia.post({ …, posts: [{ group: 'g-42', … }] }):
|
|
54
|
+
await nadia.linkContentPost(card.id, 'g-42'); // → PUBLISHED when it goes live
|
|
55
|
+
|
|
56
|
+
const numbers = await nadia.contentsPerformance(); // keyed by card id
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Columns, in order: `IDEA`, `SCRIPT`, `VALIDATED`, `TO_SHOOT`, `TO_EDIT`,
|
|
60
|
+
`TO_SCHEDULE`, `PUBLISHED`.
|
|
61
|
+
|
|
62
|
+
## How it is built
|
|
63
|
+
|
|
64
|
+
Two layers, and the split is deliberate.
|
|
65
|
+
|
|
66
|
+
- **`src/generated/`** — the transport. Generated from `openapi.public.json`
|
|
67
|
+
by [`@hey-api/openapi-ts`](https://heyapi.dev), covers every operation,
|
|
68
|
+
never edited by hand, not committed.
|
|
69
|
+
- **`src/index.ts`** — this SDK's own surface: the `Nadia` class, sane
|
|
70
|
+
defaults, typed errors, retries. Small, hand-written, reviewed.
|
|
71
|
+
|
|
72
|
+
Everything the facade does not wrap is still reachable — the generated
|
|
73
|
+
operations and types are re-exported, and `nadia.raw` is the configured
|
|
74
|
+
client:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { getChannelAnalytics } from '@usenadia/node';
|
|
78
|
+
|
|
79
|
+
await getChannelAnalytics({
|
|
80
|
+
client: nadia.raw,
|
|
81
|
+
path: { integration: channelId },
|
|
82
|
+
query: { date: '30' },
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Same call, with the facade's typed errors and retries:
|
|
86
|
+
await nadia.request((o) =>
|
|
87
|
+
getChannelAnalytics({ ...o, path: { integration: channelId }, query: { date: '30' } })
|
|
88
|
+
);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Errors
|
|
92
|
+
|
|
93
|
+
Every response with a status ≥ 400 throws a `NadiaError` carrying `status`,
|
|
94
|
+
`body` and the API's `msg`. `err.isTransient` is true for 429 and 5xx — those
|
|
95
|
+
are retried automatically (twice by default, `new Nadia(key, { retries: 0 })`
|
|
96
|
+
to turn it off).
|
|
97
|
+
|
|
98
|
+
## Coming from upstream's SDK
|
|
99
|
+
|
|
100
|
+
The class is called `Nadia` instead of upstream's name. Otherwise
|
|
101
|
+
`new Nadia(apiKey, baseUrl?)` and the five original methods (`post`,
|
|
102
|
+
`postList`, `upload`, `integrations`, `deletePost`) keep their names and
|
|
103
|
+
shapes, so existing code only changes its import. Two other differences,
|
|
104
|
+
both fixes:
|
|
105
|
+
|
|
106
|
+
- **HTTP errors are no longer swallowed.** Upstream called `.json()` without
|
|
107
|
+
looking at the status, so a 402 came back looking like a success.
|
|
108
|
+
- **`deletePost()` awaits.** Upstream returned an unawaited `fetch`.
|
|
109
|
+
|
|
110
|
+
The default base URL is `https://app.usenadia.com/api`.
|
|
111
|
+
|
|
112
|
+
## Regenerating
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pnpm run generate # from apps/sdk/node — reads ../../../openapi.public.json
|
|
116
|
+
pnpm run build
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`openapi.public.json` itself is produced by `pnpm openapi:dump` at the repo
|
|
120
|
+
root and guarded by CI. Plan: `docs/roadmap/19-sdk-public-api.md`.
|