@novence/sdk 0.2.0 → 0.2.2
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/dist/cjs/index.d.ts +44 -1
- package/dist/cjs/index.js +41 -8
- package/dist/esm/index.d.ts +44 -1
- package/dist/esm/index.js +39 -7
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
export declare const DEFAULT_BASE_URL = "https://api.novence.ai";
|
|
3
3
|
/** True for a Novence client from any copy of this module. */
|
|
4
4
|
export declare function isNovenceClient(value: unknown): value is Novence;
|
|
5
|
+
/**
|
|
6
|
+
* Thrown for any non-2xx API response. `status` lets callers distinguish 401
|
|
7
|
+
* from 402 from 429 without matching on message text.
|
|
8
|
+
*/
|
|
9
|
+
export declare class NovenceError extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
constructor(message: string, status: number);
|
|
12
|
+
}
|
|
5
13
|
export interface NovenceOptions {
|
|
6
14
|
apiKey: string;
|
|
7
15
|
baseUrl?: string;
|
|
@@ -103,6 +111,22 @@ export interface FormSubmission {
|
|
|
103
111
|
payload: Record<string, unknown>;
|
|
104
112
|
createdAt: string;
|
|
105
113
|
}
|
|
114
|
+
export interface ApiKey {
|
|
115
|
+
id: string;
|
|
116
|
+
/** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
|
|
117
|
+
keyPrefix: string;
|
|
118
|
+
/** "account", "project", or "member:{email}". */
|
|
119
|
+
name: string;
|
|
120
|
+
projectId: string | null;
|
|
121
|
+
/** Account keys have a null projectId. */
|
|
122
|
+
scope: "account" | "project";
|
|
123
|
+
permissions?: Record<string, boolean>;
|
|
124
|
+
lastUsedAt?: string | null;
|
|
125
|
+
revokedAt?: string | null;
|
|
126
|
+
createdAt?: string;
|
|
127
|
+
/** True for the key this client is authenticating with. */
|
|
128
|
+
current: boolean;
|
|
129
|
+
}
|
|
106
130
|
export interface Quotas {
|
|
107
131
|
projects: number;
|
|
108
132
|
storageGb: number;
|
|
@@ -365,7 +389,26 @@ export declare class Novence {
|
|
|
365
389
|
}>;
|
|
366
390
|
};
|
|
367
391
|
apiKeys: {
|
|
368
|
-
|
|
392
|
+
/**
|
|
393
|
+
* List keys on the account. Never includes the key or its hash — match on
|
|
394
|
+
* `keyPrefix`, and check `current` before revoking.
|
|
395
|
+
*/
|
|
396
|
+
list: (opts?: {
|
|
397
|
+
projectId?: string;
|
|
398
|
+
includeRevoked?: boolean;
|
|
399
|
+
}) => Promise<{
|
|
400
|
+
keys: ApiKey[];
|
|
401
|
+
}>;
|
|
402
|
+
/**
|
|
403
|
+
* Revoke a key. Idempotent.
|
|
404
|
+
*
|
|
405
|
+
* Rejects with 409 when `id` is the key this client authenticates with;
|
|
406
|
+
* pass `force` to override, after which recovery needs `reissueApiKey`
|
|
407
|
+
* with an email OTP.
|
|
408
|
+
*/
|
|
409
|
+
revoke: (id: string, opts?: {
|
|
410
|
+
force?: boolean;
|
|
411
|
+
}) => Promise<{
|
|
369
412
|
id: string;
|
|
370
413
|
revoked: boolean;
|
|
371
414
|
}>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Novence = exports.DEFAULT_BASE_URL = void 0;
|
|
3
|
+
exports.Novence = exports.NovenceError = exports.DEFAULT_BASE_URL = void 0;
|
|
4
4
|
exports.isNovenceClient = isNovenceClient;
|
|
5
5
|
exports.bootstrapAccount = bootstrapAccount;
|
|
6
6
|
exports.verifyEmail = verifyEmail;
|
|
@@ -35,6 +35,19 @@ function isNovenceClient(value) {
|
|
|
35
35
|
value !== null &&
|
|
36
36
|
value[CLIENT_BRAND] === true);
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown for any non-2xx API response. `status` lets callers distinguish 401
|
|
40
|
+
* from 402 from 429 without matching on message text.
|
|
41
|
+
*/
|
|
42
|
+
class NovenceError extends Error {
|
|
43
|
+
status;
|
|
44
|
+
constructor(message, status) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "NovenceError";
|
|
47
|
+
this.status = status;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.NovenceError = NovenceError;
|
|
38
51
|
const MIME_BY_EXT = {
|
|
39
52
|
".html": "text/html; charset=utf-8",
|
|
40
53
|
".css": "text/css; charset=utf-8",
|
|
@@ -82,7 +95,7 @@ class Novence {
|
|
|
82
95
|
});
|
|
83
96
|
const data = (await res.json());
|
|
84
97
|
if (!res.ok) {
|
|
85
|
-
throw new
|
|
98
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
86
99
|
}
|
|
87
100
|
return data;
|
|
88
101
|
}
|
|
@@ -124,7 +137,7 @@ class Novence {
|
|
|
124
137
|
body: new Blob([copy], { type }),
|
|
125
138
|
});
|
|
126
139
|
if (!put.ok)
|
|
127
|
-
throw new
|
|
140
|
+
throw new NovenceError(`Upload failed for ${path}`, put.status);
|
|
128
141
|
return this.files.confirm(projectId, path, type);
|
|
129
142
|
},
|
|
130
143
|
/** Node-only: upload every allowed file under `dir` with root-relative site paths. */
|
|
@@ -216,7 +229,27 @@ class Novence {
|
|
|
216
229
|
revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
|
|
217
230
|
};
|
|
218
231
|
apiKeys = {
|
|
219
|
-
|
|
232
|
+
/**
|
|
233
|
+
* List keys on the account. Never includes the key or its hash — match on
|
|
234
|
+
* `keyPrefix`, and check `current` before revoking.
|
|
235
|
+
*/
|
|
236
|
+
list: (opts = {}) => {
|
|
237
|
+
const q = new URLSearchParams();
|
|
238
|
+
if (opts.projectId)
|
|
239
|
+
q.set("projectId", opts.projectId);
|
|
240
|
+
if (opts.includeRevoked)
|
|
241
|
+
q.set("includeRevoked", "true");
|
|
242
|
+
const qs = q.toString();
|
|
243
|
+
return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
* Revoke a key. Idempotent.
|
|
247
|
+
*
|
|
248
|
+
* Rejects with 409 when `id` is the key this client authenticates with;
|
|
249
|
+
* pass `force` to override, after which recovery needs `reissueApiKey`
|
|
250
|
+
* with an email OTP.
|
|
251
|
+
*/
|
|
252
|
+
revoke: (id, opts = {}) => this.request("DELETE", `/v1/api-keys/${id}${opts.force ? "?force=true" : ""}`),
|
|
220
253
|
};
|
|
221
254
|
}
|
|
222
255
|
exports.Novence = Novence;
|
|
@@ -228,7 +261,7 @@ async function bootstrapAccount(email, baseUrl) {
|
|
|
228
261
|
});
|
|
229
262
|
const data = (await res.json());
|
|
230
263
|
if (!res.ok)
|
|
231
|
-
throw new
|
|
264
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
232
265
|
return data;
|
|
233
266
|
}
|
|
234
267
|
async function verifyEmail(email, code, baseUrl) {
|
|
@@ -239,7 +272,7 @@ async function verifyEmail(email, code, baseUrl) {
|
|
|
239
272
|
});
|
|
240
273
|
const data = (await res.json());
|
|
241
274
|
if (!res.ok)
|
|
242
|
-
throw new
|
|
275
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
243
276
|
return data;
|
|
244
277
|
}
|
|
245
278
|
async function resendVerification(email, baseUrl) {
|
|
@@ -250,7 +283,7 @@ async function resendVerification(email, baseUrl) {
|
|
|
250
283
|
});
|
|
251
284
|
const data = (await res.json());
|
|
252
285
|
if (!res.ok)
|
|
253
|
-
throw new
|
|
286
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
254
287
|
return data;
|
|
255
288
|
}
|
|
256
289
|
/** Recover a lost account API key with email OTP (after resend-verification). */
|
|
@@ -262,6 +295,6 @@ async function reissueApiKey(email, code, baseUrl) {
|
|
|
262
295
|
});
|
|
263
296
|
const data = (await res.json());
|
|
264
297
|
if (!res.ok)
|
|
265
|
-
throw new
|
|
298
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
266
299
|
return data;
|
|
267
300
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
export declare const DEFAULT_BASE_URL = "https://api.novence.ai";
|
|
3
3
|
/** True for a Novence client from any copy of this module. */
|
|
4
4
|
export declare function isNovenceClient(value: unknown): value is Novence;
|
|
5
|
+
/**
|
|
6
|
+
* Thrown for any non-2xx API response. `status` lets callers distinguish 401
|
|
7
|
+
* from 402 from 429 without matching on message text.
|
|
8
|
+
*/
|
|
9
|
+
export declare class NovenceError extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
constructor(message: string, status: number);
|
|
12
|
+
}
|
|
5
13
|
export interface NovenceOptions {
|
|
6
14
|
apiKey: string;
|
|
7
15
|
baseUrl?: string;
|
|
@@ -103,6 +111,22 @@ export interface FormSubmission {
|
|
|
103
111
|
payload: Record<string, unknown>;
|
|
104
112
|
createdAt: string;
|
|
105
113
|
}
|
|
114
|
+
export interface ApiKey {
|
|
115
|
+
id: string;
|
|
116
|
+
/** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
|
|
117
|
+
keyPrefix: string;
|
|
118
|
+
/** "account", "project", or "member:{email}". */
|
|
119
|
+
name: string;
|
|
120
|
+
projectId: string | null;
|
|
121
|
+
/** Account keys have a null projectId. */
|
|
122
|
+
scope: "account" | "project";
|
|
123
|
+
permissions?: Record<string, boolean>;
|
|
124
|
+
lastUsedAt?: string | null;
|
|
125
|
+
revokedAt?: string | null;
|
|
126
|
+
createdAt?: string;
|
|
127
|
+
/** True for the key this client is authenticating with. */
|
|
128
|
+
current: boolean;
|
|
129
|
+
}
|
|
106
130
|
export interface Quotas {
|
|
107
131
|
projects: number;
|
|
108
132
|
storageGb: number;
|
|
@@ -365,7 +389,26 @@ export declare class Novence {
|
|
|
365
389
|
}>;
|
|
366
390
|
};
|
|
367
391
|
apiKeys: {
|
|
368
|
-
|
|
392
|
+
/**
|
|
393
|
+
* List keys on the account. Never includes the key or its hash — match on
|
|
394
|
+
* `keyPrefix`, and check `current` before revoking.
|
|
395
|
+
*/
|
|
396
|
+
list: (opts?: {
|
|
397
|
+
projectId?: string;
|
|
398
|
+
includeRevoked?: boolean;
|
|
399
|
+
}) => Promise<{
|
|
400
|
+
keys: ApiKey[];
|
|
401
|
+
}>;
|
|
402
|
+
/**
|
|
403
|
+
* Revoke a key. Idempotent.
|
|
404
|
+
*
|
|
405
|
+
* Rejects with 409 when `id` is the key this client authenticates with;
|
|
406
|
+
* pass `force` to override, after which recovery needs `reissueApiKey`
|
|
407
|
+
* with an email OTP.
|
|
408
|
+
*/
|
|
409
|
+
revoke: (id: string, opts?: {
|
|
410
|
+
force?: boolean;
|
|
411
|
+
}) => Promise<{
|
|
369
412
|
id: string;
|
|
370
413
|
revoked: boolean;
|
|
371
414
|
}>;
|
package/dist/esm/index.js
CHANGED
|
@@ -27,6 +27,18 @@ export function isNovenceClient(value) {
|
|
|
27
27
|
value !== null &&
|
|
28
28
|
value[CLIENT_BRAND] === true);
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Thrown for any non-2xx API response. `status` lets callers distinguish 401
|
|
32
|
+
* from 402 from 429 without matching on message text.
|
|
33
|
+
*/
|
|
34
|
+
export class NovenceError extends Error {
|
|
35
|
+
status;
|
|
36
|
+
constructor(message, status) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.name = "NovenceError";
|
|
39
|
+
this.status = status;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
30
42
|
const MIME_BY_EXT = {
|
|
31
43
|
".html": "text/html; charset=utf-8",
|
|
32
44
|
".css": "text/css; charset=utf-8",
|
|
@@ -74,7 +86,7 @@ export class Novence {
|
|
|
74
86
|
});
|
|
75
87
|
const data = (await res.json());
|
|
76
88
|
if (!res.ok) {
|
|
77
|
-
throw new
|
|
89
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
78
90
|
}
|
|
79
91
|
return data;
|
|
80
92
|
}
|
|
@@ -116,7 +128,7 @@ export class Novence {
|
|
|
116
128
|
body: new Blob([copy], { type }),
|
|
117
129
|
});
|
|
118
130
|
if (!put.ok)
|
|
119
|
-
throw new
|
|
131
|
+
throw new NovenceError(`Upload failed for ${path}`, put.status);
|
|
120
132
|
return this.files.confirm(projectId, path, type);
|
|
121
133
|
},
|
|
122
134
|
/** Node-only: upload every allowed file under `dir` with root-relative site paths. */
|
|
@@ -208,7 +220,27 @@ export class Novence {
|
|
|
208
220
|
revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
|
|
209
221
|
};
|
|
210
222
|
apiKeys = {
|
|
211
|
-
|
|
223
|
+
/**
|
|
224
|
+
* List keys on the account. Never includes the key or its hash — match on
|
|
225
|
+
* `keyPrefix`, and check `current` before revoking.
|
|
226
|
+
*/
|
|
227
|
+
list: (opts = {}) => {
|
|
228
|
+
const q = new URLSearchParams();
|
|
229
|
+
if (opts.projectId)
|
|
230
|
+
q.set("projectId", opts.projectId);
|
|
231
|
+
if (opts.includeRevoked)
|
|
232
|
+
q.set("includeRevoked", "true");
|
|
233
|
+
const qs = q.toString();
|
|
234
|
+
return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
|
|
235
|
+
},
|
|
236
|
+
/**
|
|
237
|
+
* Revoke a key. Idempotent.
|
|
238
|
+
*
|
|
239
|
+
* Rejects with 409 when `id` is the key this client authenticates with;
|
|
240
|
+
* pass `force` to override, after which recovery needs `reissueApiKey`
|
|
241
|
+
* with an email OTP.
|
|
242
|
+
*/
|
|
243
|
+
revoke: (id, opts = {}) => this.request("DELETE", `/v1/api-keys/${id}${opts.force ? "?force=true" : ""}`),
|
|
212
244
|
};
|
|
213
245
|
}
|
|
214
246
|
export async function bootstrapAccount(email, baseUrl) {
|
|
@@ -219,7 +251,7 @@ export async function bootstrapAccount(email, baseUrl) {
|
|
|
219
251
|
});
|
|
220
252
|
const data = (await res.json());
|
|
221
253
|
if (!res.ok)
|
|
222
|
-
throw new
|
|
254
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
223
255
|
return data;
|
|
224
256
|
}
|
|
225
257
|
export async function verifyEmail(email, code, baseUrl) {
|
|
@@ -230,7 +262,7 @@ export async function verifyEmail(email, code, baseUrl) {
|
|
|
230
262
|
});
|
|
231
263
|
const data = (await res.json());
|
|
232
264
|
if (!res.ok)
|
|
233
|
-
throw new
|
|
265
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
234
266
|
return data;
|
|
235
267
|
}
|
|
236
268
|
export async function resendVerification(email, baseUrl) {
|
|
@@ -241,7 +273,7 @@ export async function resendVerification(email, baseUrl) {
|
|
|
241
273
|
});
|
|
242
274
|
const data = (await res.json());
|
|
243
275
|
if (!res.ok)
|
|
244
|
-
throw new
|
|
276
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
245
277
|
return data;
|
|
246
278
|
}
|
|
247
279
|
/** Recover a lost account API key with email OTP (after resend-verification). */
|
|
@@ -253,6 +285,6 @@ export async function reissueApiKey(email, code, baseUrl) {
|
|
|
253
285
|
});
|
|
254
286
|
const data = (await res.json());
|
|
255
287
|
if (!res.ok)
|
|
256
|
-
throw new
|
|
288
|
+
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
257
289
|
return data;
|
|
258
290
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novence/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Official TypeScript SDK for Novence \u2014 static site hosting for AI agents. Create projects, upload files, run quality checks, deploy to the edge.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|