@obniz/obniz-now-sdk 0.1.10 → 0.1.11

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 CHANGED
@@ -4,7 +4,7 @@ TypeScript/JavaScript SDK for Obniz Now API
4
4
 
5
5
  ## Installation
6
6
  ```bash
7
- npm install @obniz/obniz-now-sdk-js
7
+ npm install @obniz/obniz-now-sdk
8
8
  ```
9
9
 
10
10
  ## Authentication
@@ -13,7 +13,7 @@ The SDK supports authentication using an API token (Bearer token). You can obtai
13
13
 
14
14
  ### Using API Token
15
15
  ```typescript
16
- import { ObnizNow } from '@obniz/sdk';
16
+ import { ObnizNow } from '@obniz/obniz-now-sdk';
17
17
 
18
18
  const client = new ObnizNow({
19
19
  token: 'your-api-token-here'
@@ -32,7 +32,7 @@ const client = new ObnizNow({
32
32
  ### List Machines
33
33
 
34
34
  ```typescript
35
- import { ObnizNow } from '@obniz/obniz-now-sdk-js';
35
+ import { ObnizNow } from '@obniz/obniz-now-sdk';
36
36
 
37
37
  const client = new ObnizNow({ token: process.env.OBNIZ_TOKEN });
38
38
 
@@ -76,7 +76,7 @@ console.log(`Found ${events.count} events`);
76
76
  All API errors are automatically converted to `ObnizNowApiError` with parsed response data.
77
77
 
78
78
  ```typescript
79
- import { ObnizNow, ObnizNowApiError } from '@obniz/obniz-now-sdk-js';
79
+ import { ObnizNow, ObnizNowApiError } from '@obniz/obniz-now-sdk';
80
80
 
81
81
  try {
82
82
  const machine = await client.machine.getMachine({ machineId: 'invalid-id' });
@@ -100,28 +100,41 @@ try {
100
100
  ### ⚠️ Security Warning
101
101
  **Never expose your API token in client-side code!** Use one of these safe approaches:
102
102
 
103
- ### Option 1: Cookie-based Authentication (Recommended)
103
+ ### Option 1: Cookie-based Authentication (Recommended for custom pages)
104
104
  ```typescript
105
- // In your Svelte component
106
- import { ObnizNow } from '@obniz/obniz-now-sdk-js';
105
+ import { ObnizNow } from '@obniz/obniz-now-sdk';
107
106
 
108
107
  const client = new ObnizNow({
108
+ baseUrl: window.location.origin,
109
109
  cookies: {
110
- token: getCookie('token'),
111
- accountId: getCookie('account_id'),
110
+ // In browsers, existing same-origin cookies are sent by fetch(credentials: "include").
111
+ // These values are used only by non-browser runtimes where Cookie headers can be set.
112
+ token: '',
113
+ accountId: '',
112
114
  },
113
115
  });
114
116
 
115
- function getCookie(name: string): string {
116
- const value = `; ${document.cookie}`;
117
- const parts = value.split(`; ${name}=`);
118
- if (parts.length === 2) return parts.pop()?.split(';').shift() || '';
119
- return '';
120
- }
117
+ const machines = await client.machines.listMachines({ limit: 20 });
121
118
  ```
122
119
 
123
120
  Your backend should set httpOnly cookies after user authentication.
124
121
 
122
+ For plain custom page HTML, import the browser bundle from a CDN or from a file hosted with the page:
123
+
124
+ ```html
125
+ <script type="module">
126
+ import { ObnizNow } from "https://cdn.jsdelivr.net/npm/@obniz/obniz-now-sdk@0.1.11/dist/index.mjs";
127
+
128
+ const client = new ObnizNow({
129
+ baseUrl: window.location.origin,
130
+ cookies: { token: "", accountId: "" },
131
+ });
132
+
133
+ const response = await client.machines.listMachines({ limit: 10, offset: 0 });
134
+ console.log(response.items);
135
+ </script>
136
+ ```
137
+
125
138
  ### Option 2: Backend Proxy
126
139
  ```typescript
127
140
  // Frontend - call your backend API
@@ -138,7 +151,7 @@ app.get('/api/obniz/machines', async (req, res) => {
138
151
  ### SvelteKit Server-Side Example
139
152
  ```typescript
140
153
  // src/routes/+page.server.ts
141
- import { ObnizNow } from '@obniz/sdk';
154
+ import { ObnizNow } from '@obniz/obniz-now-sdk';
142
155
 
143
156
  export async function load() {
144
157
  const client = new ObnizNow({ token: process.env.OBNIZ_TOKEN });
@@ -177,6 +190,12 @@ See the examples/ directory for more detailed examples:
177
190
 
178
191
  `advanced-error-handling.ts` - Error inspection and debugging
179
192
 
193
+ ## API Categories
194
+
195
+ The `ObnizNow` client exposes generated API groups including:
196
+
197
+ `account`, `analytics`, `auditLogs`, `connectionModels`, `connections`, `converters`, `customizes`, `events`, `firmware`, `groups`, `inboundConnections`, `inboundSources`, `integrations`, `intelligences`, `invitations`, `issues`, `machine`, `machines`, `notificationHistory`, `notifications`, `obniz`, `reports`, `session`, `threads`, `units`, and `users`.
198
+
180
199
  ### Run any example:
181
200
  ```bash
182
201
  npx tsx examples/basic-usage.ts
@@ -189,4 +208,4 @@ Node.js >= 18.0.0
189
208
  Website:
190
209
  https://iot.obniz.com
191
210
 
192
- API documentation: https://now.obniz.com/api/1/docs/
211
+ API documentation: https://now.obniz.com/api/1/docs/
@@ -1,4 +1,4 @@
1
- import { AnalyticsApi, ConnectionModelsApi, ConnectionsApi, EventsApi, GroupsApi, InboundConnectionsApi, InboundSourcesApi, IntegrationsApi, IntelligencesApi, IssuesApi, MachineApi, MachinesApi, NotificationsApi, ReportsApi, ThreadsApi, UnitsApi } from "./sdk-core";
1
+ import { AccountApi, AnalyticsApi, AuditLogsApi, ConnectionModelsApi, ConnectionsApi, ConvertersApi, CustomizesApi, EventsApi, FirmwareApi, GroupsApi, InboundConnectionsApi, InboundSourcesApi, IntegrationsApi, IntelligencesApi, InvitationsApi, IssuesApi, MachineApi, MachinesApi, NotificationHistoryApi, NotificationsApi, ObnizApi, ReportsApi, SessionApi, ThreadsApi, UnitsApi, UsersApi } from "./sdk-core";
2
2
  export interface CookieAuthOptions {
3
3
  token: string;
4
4
  accountId: string;
@@ -52,14 +52,24 @@ export type ObnizNowOptions = (BaseOptions & WithoutCookies) | (BaseOptions & Wi
52
52
  * ```
53
53
  */
54
54
  export declare class ObnizNow {
55
+ /** Account API - Manage current account settings, members, API keys, plan, entitlements, usages, and secrets */
56
+ readonly account: AccountApi;
55
57
  /** Analytics API - Execute and retrieve analytics results */
56
58
  readonly analytics: AnalyticsApi;
59
+ /** Audit Logs API - Access account audit log entries */
60
+ readonly auditLogs: AuditLogsApi;
57
61
  /** Connection Models API - Manage connection model configurations */
58
62
  readonly connectionModels: ConnectionModelsApi;
59
63
  /** Connections API - Manage machine connections */
60
64
  readonly connections: ConnectionsApi;
65
+ /** Converters API - Data format conversions */
66
+ readonly converters: ConvertersApi;
67
+ /** Customizes API - Resolve account, machine, group, and asset customizations */
68
+ readonly customizes: CustomizesApi;
61
69
  /** Events API - Access event data and history */
62
70
  readonly events: EventsApi;
71
+ /** Firmware API - Inspect and update device firmware */
72
+ readonly firmware: FirmwareApi;
63
73
  /** Groups API - Organize machines into groups */
64
74
  readonly groups: GroupsApi;
65
75
  /** Inbound Connections API - Manage inbound data connections */
@@ -70,20 +80,30 @@ export declare class ObnizNow {
70
80
  readonly integrations: IntegrationsApi;
71
81
  /** Intelligences API - AI and intelligence features */
72
82
  readonly intelligences: IntelligencesApi;
83
+ /** Invitations API - Manage account invitations */
84
+ readonly invitations: InvitationsApi;
73
85
  /** Issues API - Track and manage issues */
74
86
  readonly issues: IssuesApi;
75
87
  /** Machine API - Single machine operations */
76
88
  readonly machine: MachineApi;
77
89
  /** Machines API - Machine management and operations */
78
90
  readonly machines: MachinesApi;
91
+ /** Notification History API - Access notification delivery history */
92
+ readonly notificationHistory: NotificationHistoryApi;
79
93
  /** Notifications API - Manage notification settings */
80
94
  readonly notifications: NotificationsApi;
95
+ /** Obniz API - Access obniz device metadata */
96
+ readonly obniz: ObnizApi;
81
97
  /** Reports API - Generate and retrieve reports */
82
98
  readonly reports: ReportsApi;
99
+ /** Session API - Browser session account selection and UI configuration */
100
+ readonly session: SessionApi;
83
101
  /** Threads API - Discussion threads and communications */
84
102
  readonly threads: ThreadsApi;
85
103
  /** Units API - Unit data and state management */
86
104
  readonly units: UnitsApi;
105
+ /** Users API - Manage current user and profile pictures */
106
+ readonly users: UsersApi;
87
107
  /**
88
108
  * Creates a new ObnizNow SDK client instance
89
109
  *
@@ -101,4 +121,4 @@ export declare class ObnizNow {
101
121
  */
102
122
  constructor(options: ObnizNowOptions);
103
123
  }
104
- export {};
124
+ export * from "./sdk-core";
package/dist/index.d.ts CHANGED
@@ -1 +1,5 @@
1
- export * from "./ObnizNow";
1
+ export { ObnizNow } from "./ObnizNow";
2
+ export type { ObnizNowOptions, ObnizNowTokenOptions, ObnizNowCookiesOptions, } from "./ObnizNow";
3
+ export { ObnizNowApiError } from "./ObnizNowApiError";
4
+ import * as Core from "./sdk-core/index";
5
+ export { Core as Models };