@novence/sdk 0.2.4 → 0.2.6
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 +1 -1
- package/dist/cjs/index.d.ts +74 -3
- package/dist/cjs/index.js +45 -8
- package/dist/esm/index.d.ts +74 -3
- package/dist/esm/index.js +45 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ call at a different control plane — useful when running the API locally.
|
|
|
118
118
|
|
|
119
119
|
| Namespace | Methods |
|
|
120
120
|
| --- | --- |
|
|
121
|
-
| `client.projects` | `create` · `list` · `get` · `update` · `usage` · `analytics` |
|
|
121
|
+
| `client.projects` | `create` · `list` · `get` · `update` · `usage` · `analytics` · `brief` · `putBrief` · `events` |
|
|
122
122
|
| `client.files` | `uploadDir` · `uploadBuffer` · `getUploadUrl` · `getUploadUrlsBatch` · `confirm` · `confirmBatch` |
|
|
123
123
|
| `client.deployments` | `create` · `latest` |
|
|
124
124
|
| `client.domains` | `configure` · `status` |
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface Project {
|
|
|
32
32
|
customDomain?: string | null;
|
|
33
33
|
customDomainStatus?: string;
|
|
34
34
|
analyticsEnabled?: boolean;
|
|
35
|
+
shareGateEmails?: string[];
|
|
36
|
+
siteMcp?: "off" | "read" | "forms";
|
|
37
|
+
dataEditEmails?: string[];
|
|
38
|
+
dataEditNames?: string[];
|
|
39
|
+
dataEditPath?: string;
|
|
35
40
|
createdAt?: string;
|
|
36
41
|
updatedAt?: string;
|
|
37
42
|
}
|
|
@@ -180,6 +185,14 @@ export interface Analytics {
|
|
|
180
185
|
pageviews: number;
|
|
181
186
|
}>;
|
|
182
187
|
}
|
|
188
|
+
export interface SiteDataResult {
|
|
189
|
+
name: string;
|
|
190
|
+
path: string;
|
|
191
|
+
bytes: number;
|
|
192
|
+
json?: unknown;
|
|
193
|
+
url: string;
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
}
|
|
183
196
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
184
197
|
export interface DomainConfigureResult {
|
|
185
198
|
hosts?: string[];
|
|
@@ -191,6 +204,7 @@ export interface DomainConfigureResult {
|
|
|
191
204
|
maxRecords?: number;
|
|
192
205
|
cnameTarget?: string;
|
|
193
206
|
records?: Array<Record<string, unknown>>;
|
|
207
|
+
apexOptions?: Array<Record<string, unknown>>;
|
|
194
208
|
[key: string]: unknown;
|
|
195
209
|
};
|
|
196
210
|
[key: string]: unknown;
|
|
@@ -198,7 +212,14 @@ export interface DomainConfigureResult {
|
|
|
198
212
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
199
213
|
export interface DomainStatus {
|
|
200
214
|
hostname?: string | null;
|
|
215
|
+
customDomain?: string | null;
|
|
216
|
+
customDomainStatus?: string;
|
|
201
217
|
status?: string;
|
|
218
|
+
dns?: {
|
|
219
|
+
www?: "ok" | "missing" | "skipped";
|
|
220
|
+
apex?: "present" | "missing" | "skipped";
|
|
221
|
+
next?: string | null;
|
|
222
|
+
};
|
|
202
223
|
[key: string]: unknown;
|
|
203
224
|
}
|
|
204
225
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
@@ -247,6 +268,11 @@ export declare class Novence {
|
|
|
247
268
|
description?: string;
|
|
248
269
|
checkThresholds?: Record<string, unknown>;
|
|
249
270
|
analyticsEnabled?: boolean;
|
|
271
|
+
shareGateEmails?: string[];
|
|
272
|
+
siteMcp?: "off" | "read" | "forms";
|
|
273
|
+
dataEditEmails?: string[];
|
|
274
|
+
dataEditNames?: string[];
|
|
275
|
+
dataEditPath?: string;
|
|
250
276
|
}) => Promise<{
|
|
251
277
|
project: Project;
|
|
252
278
|
}>;
|
|
@@ -263,6 +289,30 @@ export declare class Novence {
|
|
|
263
289
|
from?: string;
|
|
264
290
|
to?: string;
|
|
265
291
|
}) => Promise<Analytics>;
|
|
292
|
+
brief: (id: string) => Promise<{
|
|
293
|
+
projectId: string;
|
|
294
|
+
brief: string | null;
|
|
295
|
+
updatedAt: string | null;
|
|
296
|
+
}>;
|
|
297
|
+
putBrief: (id: string, brief: string) => Promise<{
|
|
298
|
+
projectId: string;
|
|
299
|
+
brief: string | null;
|
|
300
|
+
updatedAt: string | null;
|
|
301
|
+
}>;
|
|
302
|
+
events: (id: string, opts?: {
|
|
303
|
+
since?: string;
|
|
304
|
+
limit?: number;
|
|
305
|
+
}) => Promise<{
|
|
306
|
+
projectId: string;
|
|
307
|
+
since: string;
|
|
308
|
+
limit: number;
|
|
309
|
+
events: Array<{
|
|
310
|
+
id: string;
|
|
311
|
+
type: string;
|
|
312
|
+
payload: Record<string, unknown>;
|
|
313
|
+
createdAt: string;
|
|
314
|
+
}>;
|
|
315
|
+
}>;
|
|
266
316
|
};
|
|
267
317
|
files: {
|
|
268
318
|
getUploadUrl: (projectId: string, path: string, contentType?: string) => Promise<UploadPresign>;
|
|
@@ -313,9 +363,16 @@ export declare class Novence {
|
|
|
313
363
|
force?: boolean;
|
|
314
364
|
}): Promise<PublishHtmlResult>;
|
|
315
365
|
domains: {
|
|
316
|
-
configure: (projectId: string, hostname: string
|
|
366
|
+
configure: (projectId: string, hostname: string, input?: {
|
|
367
|
+
primary?: "www" | "apex";
|
|
368
|
+
redirect?: boolean;
|
|
369
|
+
}) => Promise<DomainConfigureResult>;
|
|
317
370
|
status: (projectId: string) => Promise<DomainStatus>;
|
|
318
371
|
};
|
|
372
|
+
data: {
|
|
373
|
+
put: (projectId: string, name: string, json: unknown) => Promise<SiteDataResult>;
|
|
374
|
+
get: (projectId: string, name: string) => Promise<SiteDataResult>;
|
|
375
|
+
};
|
|
319
376
|
forms: {
|
|
320
377
|
create: (projectId: string, input: {
|
|
321
378
|
name: string;
|
|
@@ -436,14 +493,28 @@ export declare class Novence {
|
|
|
436
493
|
}>;
|
|
437
494
|
};
|
|
438
495
|
}
|
|
439
|
-
export
|
|
496
|
+
export interface SignupAttributionInput {
|
|
497
|
+
method?: "web" | "mcp" | "cli" | "sdk" | "api";
|
|
498
|
+
client?: string;
|
|
499
|
+
source?: string;
|
|
500
|
+
medium?: string;
|
|
501
|
+
campaign?: string;
|
|
502
|
+
content?: string;
|
|
503
|
+
term?: string;
|
|
504
|
+
gclid?: string;
|
|
505
|
+
referrer?: string;
|
|
506
|
+
landing?: string;
|
|
507
|
+
gaClientId?: string;
|
|
508
|
+
gaSessionId?: string;
|
|
509
|
+
}
|
|
510
|
+
export declare function bootstrapAccount(email: string, baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
440
511
|
accountId: string;
|
|
441
512
|
apiKey: string;
|
|
442
513
|
plan: string;
|
|
443
514
|
emailVerificationRequired?: boolean;
|
|
444
515
|
verificationCode?: string;
|
|
445
516
|
}>;
|
|
446
|
-
export declare function createDemoAccount(baseUrl?: string): Promise<{
|
|
517
|
+
export declare function createDemoAccount(baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
447
518
|
accountId: string;
|
|
448
519
|
apiKey: string;
|
|
449
520
|
plan: string;
|
package/dist/cjs/index.js
CHANGED
|
@@ -116,6 +116,17 @@ class Novence {
|
|
|
116
116
|
const qs = q.toString();
|
|
117
117
|
return this.request("GET", `/v1/projects/${id}/analytics${qs ? `?${qs}` : ""}`);
|
|
118
118
|
},
|
|
119
|
+
brief: (id) => this.request("GET", `/v1/projects/${id}/brief`),
|
|
120
|
+
putBrief: (id, brief) => this.request("PUT", `/v1/projects/${id}/brief`, { brief }),
|
|
121
|
+
events: (id, opts) => {
|
|
122
|
+
const q = new URLSearchParams();
|
|
123
|
+
if (opts?.since)
|
|
124
|
+
q.set("since", opts.since);
|
|
125
|
+
if (opts?.limit !== undefined)
|
|
126
|
+
q.set("limit", String(opts.limit));
|
|
127
|
+
const qs = q.toString();
|
|
128
|
+
return this.request("GET", `/v1/projects/${id}/events${qs ? `?${qs}` : ""}`);
|
|
129
|
+
},
|
|
119
130
|
};
|
|
120
131
|
files = {
|
|
121
132
|
getUploadUrl: (projectId, path, contentType) => this.request("POST", `/v1/projects/${projectId}/uploads`, {
|
|
@@ -160,7 +171,9 @@ class Novence {
|
|
|
160
171
|
const uploaded = [];
|
|
161
172
|
for (const full of walk(dir)) {
|
|
162
173
|
const rel = "/" + (0, node_path_1.relative)(dir, full).split("\\").join("/");
|
|
163
|
-
const contentType =
|
|
174
|
+
const contentType = rel === "/_redirects" || rel === "/_redirects.txt"
|
|
175
|
+
? "text/plain; charset=utf-8"
|
|
176
|
+
: MIME_BY_EXT[(0, node_path_1.extname)(full).toLowerCase()];
|
|
164
177
|
if (!contentType)
|
|
165
178
|
continue;
|
|
166
179
|
const body = (0, node_fs_1.readFileSync)(full);
|
|
@@ -190,11 +203,16 @@ class Novence {
|
|
|
190
203
|
});
|
|
191
204
|
}
|
|
192
205
|
domains = {
|
|
193
|
-
configure: (projectId, hostname) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
206
|
+
configure: (projectId, hostname, input) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
194
207
|
hostname,
|
|
208
|
+
...input,
|
|
195
209
|
}),
|
|
196
210
|
status: (projectId) => this.request("GET", `/v1/projects/${projectId}/domains`),
|
|
197
211
|
};
|
|
212
|
+
data = {
|
|
213
|
+
put: (projectId, name, json) => this.request("PUT", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`, json),
|
|
214
|
+
get: (projectId, name) => this.request("GET", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`),
|
|
215
|
+
};
|
|
198
216
|
forms = {
|
|
199
217
|
create: (projectId, input) => this.request("POST", `/v1/projects/${projectId}/forms`, input),
|
|
200
218
|
list: (projectId) => this.request("GET", `/v1/projects/${projectId}/forms`),
|
|
@@ -270,24 +288,43 @@ class Novence {
|
|
|
270
288
|
};
|
|
271
289
|
}
|
|
272
290
|
exports.Novence = Novence;
|
|
273
|
-
|
|
291
|
+
function withMethod(attribution, method) {
|
|
292
|
+
return { ...attribution, method: attribution?.method ?? method };
|
|
293
|
+
}
|
|
294
|
+
/** Gateway 502s are HTML. Parsing them as JSON hides the status. */
|
|
295
|
+
async function readErrorBody(res) {
|
|
296
|
+
const text = await res.text();
|
|
297
|
+
if (!text)
|
|
298
|
+
return {};
|
|
299
|
+
try {
|
|
300
|
+
const parsed = JSON.parse(text);
|
|
301
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
302
|
+
return parsed;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
return {};
|
|
307
|
+
}
|
|
308
|
+
return {};
|
|
309
|
+
}
|
|
310
|
+
async function bootstrapAccount(email, baseUrl, attribution) {
|
|
274
311
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/bootstrap`, {
|
|
275
312
|
method: "POST",
|
|
276
313
|
headers: { "Content-Type": "application/json" },
|
|
277
|
-
body: JSON.stringify({ email }),
|
|
314
|
+
body: JSON.stringify({ email, attribution: withMethod(attribution, "sdk") }),
|
|
278
315
|
});
|
|
279
|
-
const data = (await res
|
|
316
|
+
const data = (await readErrorBody(res));
|
|
280
317
|
if (!res.ok)
|
|
281
318
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
282
319
|
return data;
|
|
283
320
|
}
|
|
284
|
-
async function createDemoAccount(baseUrl) {
|
|
321
|
+
async function createDemoAccount(baseUrl, attribution) {
|
|
285
322
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/demo`, {
|
|
286
323
|
method: "POST",
|
|
287
324
|
headers: { "Content-Type": "application/json" },
|
|
288
|
-
body: JSON.stringify({}),
|
|
325
|
+
body: JSON.stringify({ attribution: withMethod(attribution, "sdk") }),
|
|
289
326
|
});
|
|
290
|
-
const data = (await res
|
|
327
|
+
const data = (await readErrorBody(res));
|
|
291
328
|
if (!res.ok)
|
|
292
329
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
293
330
|
return data;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface Project {
|
|
|
32
32
|
customDomain?: string | null;
|
|
33
33
|
customDomainStatus?: string;
|
|
34
34
|
analyticsEnabled?: boolean;
|
|
35
|
+
shareGateEmails?: string[];
|
|
36
|
+
siteMcp?: "off" | "read" | "forms";
|
|
37
|
+
dataEditEmails?: string[];
|
|
38
|
+
dataEditNames?: string[];
|
|
39
|
+
dataEditPath?: string;
|
|
35
40
|
createdAt?: string;
|
|
36
41
|
updatedAt?: string;
|
|
37
42
|
}
|
|
@@ -180,6 +185,14 @@ export interface Analytics {
|
|
|
180
185
|
pageviews: number;
|
|
181
186
|
}>;
|
|
182
187
|
}
|
|
188
|
+
export interface SiteDataResult {
|
|
189
|
+
name: string;
|
|
190
|
+
path: string;
|
|
191
|
+
bytes: number;
|
|
192
|
+
json?: unknown;
|
|
193
|
+
url: string;
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
}
|
|
183
196
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
184
197
|
export interface DomainConfigureResult {
|
|
185
198
|
hosts?: string[];
|
|
@@ -191,6 +204,7 @@ export interface DomainConfigureResult {
|
|
|
191
204
|
maxRecords?: number;
|
|
192
205
|
cnameTarget?: string;
|
|
193
206
|
records?: Array<Record<string, unknown>>;
|
|
207
|
+
apexOptions?: Array<Record<string, unknown>>;
|
|
194
208
|
[key: string]: unknown;
|
|
195
209
|
};
|
|
196
210
|
[key: string]: unknown;
|
|
@@ -198,7 +212,14 @@ export interface DomainConfigureResult {
|
|
|
198
212
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
199
213
|
export interface DomainStatus {
|
|
200
214
|
hostname?: string | null;
|
|
215
|
+
customDomain?: string | null;
|
|
216
|
+
customDomainStatus?: string;
|
|
201
217
|
status?: string;
|
|
218
|
+
dns?: {
|
|
219
|
+
www?: "ok" | "missing" | "skipped";
|
|
220
|
+
apex?: "present" | "missing" | "skipped";
|
|
221
|
+
next?: string | null;
|
|
222
|
+
};
|
|
202
223
|
[key: string]: unknown;
|
|
203
224
|
}
|
|
204
225
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
@@ -247,6 +268,11 @@ export declare class Novence {
|
|
|
247
268
|
description?: string;
|
|
248
269
|
checkThresholds?: Record<string, unknown>;
|
|
249
270
|
analyticsEnabled?: boolean;
|
|
271
|
+
shareGateEmails?: string[];
|
|
272
|
+
siteMcp?: "off" | "read" | "forms";
|
|
273
|
+
dataEditEmails?: string[];
|
|
274
|
+
dataEditNames?: string[];
|
|
275
|
+
dataEditPath?: string;
|
|
250
276
|
}) => Promise<{
|
|
251
277
|
project: Project;
|
|
252
278
|
}>;
|
|
@@ -263,6 +289,30 @@ export declare class Novence {
|
|
|
263
289
|
from?: string;
|
|
264
290
|
to?: string;
|
|
265
291
|
}) => Promise<Analytics>;
|
|
292
|
+
brief: (id: string) => Promise<{
|
|
293
|
+
projectId: string;
|
|
294
|
+
brief: string | null;
|
|
295
|
+
updatedAt: string | null;
|
|
296
|
+
}>;
|
|
297
|
+
putBrief: (id: string, brief: string) => Promise<{
|
|
298
|
+
projectId: string;
|
|
299
|
+
brief: string | null;
|
|
300
|
+
updatedAt: string | null;
|
|
301
|
+
}>;
|
|
302
|
+
events: (id: string, opts?: {
|
|
303
|
+
since?: string;
|
|
304
|
+
limit?: number;
|
|
305
|
+
}) => Promise<{
|
|
306
|
+
projectId: string;
|
|
307
|
+
since: string;
|
|
308
|
+
limit: number;
|
|
309
|
+
events: Array<{
|
|
310
|
+
id: string;
|
|
311
|
+
type: string;
|
|
312
|
+
payload: Record<string, unknown>;
|
|
313
|
+
createdAt: string;
|
|
314
|
+
}>;
|
|
315
|
+
}>;
|
|
266
316
|
};
|
|
267
317
|
files: {
|
|
268
318
|
getUploadUrl: (projectId: string, path: string, contentType?: string) => Promise<UploadPresign>;
|
|
@@ -313,9 +363,16 @@ export declare class Novence {
|
|
|
313
363
|
force?: boolean;
|
|
314
364
|
}): Promise<PublishHtmlResult>;
|
|
315
365
|
domains: {
|
|
316
|
-
configure: (projectId: string, hostname: string
|
|
366
|
+
configure: (projectId: string, hostname: string, input?: {
|
|
367
|
+
primary?: "www" | "apex";
|
|
368
|
+
redirect?: boolean;
|
|
369
|
+
}) => Promise<DomainConfigureResult>;
|
|
317
370
|
status: (projectId: string) => Promise<DomainStatus>;
|
|
318
371
|
};
|
|
372
|
+
data: {
|
|
373
|
+
put: (projectId: string, name: string, json: unknown) => Promise<SiteDataResult>;
|
|
374
|
+
get: (projectId: string, name: string) => Promise<SiteDataResult>;
|
|
375
|
+
};
|
|
319
376
|
forms: {
|
|
320
377
|
create: (projectId: string, input: {
|
|
321
378
|
name: string;
|
|
@@ -436,14 +493,28 @@ export declare class Novence {
|
|
|
436
493
|
}>;
|
|
437
494
|
};
|
|
438
495
|
}
|
|
439
|
-
export
|
|
496
|
+
export interface SignupAttributionInput {
|
|
497
|
+
method?: "web" | "mcp" | "cli" | "sdk" | "api";
|
|
498
|
+
client?: string;
|
|
499
|
+
source?: string;
|
|
500
|
+
medium?: string;
|
|
501
|
+
campaign?: string;
|
|
502
|
+
content?: string;
|
|
503
|
+
term?: string;
|
|
504
|
+
gclid?: string;
|
|
505
|
+
referrer?: string;
|
|
506
|
+
landing?: string;
|
|
507
|
+
gaClientId?: string;
|
|
508
|
+
gaSessionId?: string;
|
|
509
|
+
}
|
|
510
|
+
export declare function bootstrapAccount(email: string, baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
440
511
|
accountId: string;
|
|
441
512
|
apiKey: string;
|
|
442
513
|
plan: string;
|
|
443
514
|
emailVerificationRequired?: boolean;
|
|
444
515
|
verificationCode?: string;
|
|
445
516
|
}>;
|
|
446
|
-
export declare function createDemoAccount(baseUrl?: string): Promise<{
|
|
517
|
+
export declare function createDemoAccount(baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
447
518
|
accountId: string;
|
|
448
519
|
apiKey: string;
|
|
449
520
|
plan: string;
|
package/dist/esm/index.js
CHANGED
|
@@ -105,6 +105,17 @@ export class Novence {
|
|
|
105
105
|
const qs = q.toString();
|
|
106
106
|
return this.request("GET", `/v1/projects/${id}/analytics${qs ? `?${qs}` : ""}`);
|
|
107
107
|
},
|
|
108
|
+
brief: (id) => this.request("GET", `/v1/projects/${id}/brief`),
|
|
109
|
+
putBrief: (id, brief) => this.request("PUT", `/v1/projects/${id}/brief`, { brief }),
|
|
110
|
+
events: (id, opts) => {
|
|
111
|
+
const q = new URLSearchParams();
|
|
112
|
+
if (opts?.since)
|
|
113
|
+
q.set("since", opts.since);
|
|
114
|
+
if (opts?.limit !== undefined)
|
|
115
|
+
q.set("limit", String(opts.limit));
|
|
116
|
+
const qs = q.toString();
|
|
117
|
+
return this.request("GET", `/v1/projects/${id}/events${qs ? `?${qs}` : ""}`);
|
|
118
|
+
},
|
|
108
119
|
};
|
|
109
120
|
files = {
|
|
110
121
|
getUploadUrl: (projectId, path, contentType) => this.request("POST", `/v1/projects/${projectId}/uploads`, {
|
|
@@ -149,7 +160,9 @@ export class Novence {
|
|
|
149
160
|
const uploaded = [];
|
|
150
161
|
for (const full of walk(dir)) {
|
|
151
162
|
const rel = "/" + relative(dir, full).split("\\").join("/");
|
|
152
|
-
const contentType =
|
|
163
|
+
const contentType = rel === "/_redirects" || rel === "/_redirects.txt"
|
|
164
|
+
? "text/plain; charset=utf-8"
|
|
165
|
+
: MIME_BY_EXT[extname(full).toLowerCase()];
|
|
153
166
|
if (!contentType)
|
|
154
167
|
continue;
|
|
155
168
|
const body = readFileSync(full);
|
|
@@ -179,11 +192,16 @@ export class Novence {
|
|
|
179
192
|
});
|
|
180
193
|
}
|
|
181
194
|
domains = {
|
|
182
|
-
configure: (projectId, hostname) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
195
|
+
configure: (projectId, hostname, input) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
183
196
|
hostname,
|
|
197
|
+
...input,
|
|
184
198
|
}),
|
|
185
199
|
status: (projectId) => this.request("GET", `/v1/projects/${projectId}/domains`),
|
|
186
200
|
};
|
|
201
|
+
data = {
|
|
202
|
+
put: (projectId, name, json) => this.request("PUT", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`, json),
|
|
203
|
+
get: (projectId, name) => this.request("GET", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`),
|
|
204
|
+
};
|
|
187
205
|
forms = {
|
|
188
206
|
create: (projectId, input) => this.request("POST", `/v1/projects/${projectId}/forms`, input),
|
|
189
207
|
list: (projectId) => this.request("GET", `/v1/projects/${projectId}/forms`),
|
|
@@ -258,24 +276,43 @@ export class Novence {
|
|
|
258
276
|
revoke: (id, opts = {}) => this.request("DELETE", `/v1/api-keys/${id}${opts.force ? "?force=true" : ""}`),
|
|
259
277
|
};
|
|
260
278
|
}
|
|
261
|
-
|
|
279
|
+
function withMethod(attribution, method) {
|
|
280
|
+
return { ...attribution, method: attribution?.method ?? method };
|
|
281
|
+
}
|
|
282
|
+
/** Gateway 502s are HTML. Parsing them as JSON hides the status. */
|
|
283
|
+
async function readErrorBody(res) {
|
|
284
|
+
const text = await res.text();
|
|
285
|
+
if (!text)
|
|
286
|
+
return {};
|
|
287
|
+
try {
|
|
288
|
+
const parsed = JSON.parse(text);
|
|
289
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
290
|
+
return parsed;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
return {};
|
|
295
|
+
}
|
|
296
|
+
return {};
|
|
297
|
+
}
|
|
298
|
+
export async function bootstrapAccount(email, baseUrl, attribution) {
|
|
262
299
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/bootstrap`, {
|
|
263
300
|
method: "POST",
|
|
264
301
|
headers: { "Content-Type": "application/json" },
|
|
265
|
-
body: JSON.stringify({ email }),
|
|
302
|
+
body: JSON.stringify({ email, attribution: withMethod(attribution, "sdk") }),
|
|
266
303
|
});
|
|
267
|
-
const data = (await res
|
|
304
|
+
const data = (await readErrorBody(res));
|
|
268
305
|
if (!res.ok)
|
|
269
306
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
270
307
|
return data;
|
|
271
308
|
}
|
|
272
|
-
export async function createDemoAccount(baseUrl) {
|
|
309
|
+
export async function createDemoAccount(baseUrl, attribution) {
|
|
273
310
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/demo`, {
|
|
274
311
|
method: "POST",
|
|
275
312
|
headers: { "Content-Type": "application/json" },
|
|
276
|
-
body: JSON.stringify({}),
|
|
313
|
+
body: JSON.stringify({ attribution: withMethod(attribution, "sdk") }),
|
|
277
314
|
});
|
|
278
|
-
const data = (await res
|
|
315
|
+
const data = (await readErrorBody(res));
|
|
279
316
|
if (!res.ok)
|
|
280
317
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
281
318
|
return data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novence/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Official TypeScript SDK for Novence — 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",
|