@onedoc/client
Advanced tools
Comparing version 0.1.24 to 0.1.25
@@ -13,5 +13,8 @@ interface PathString { | ||
test?: boolean; | ||
assets?: PathString[] | PathBuffer[]; | ||
save?: boolean; | ||
/** | ||
* Number of seconds to cache the file in the CDN for. | ||
*/ | ||
expiresIn?: number; | ||
assets?: PathString[] | PathBuffer[]; | ||
} | ||
@@ -25,5 +28,14 @@ declare class Onedoc { | ||
file: any; | ||
error: string; | ||
info: { | ||
status: number; | ||
}; | ||
link?: undefined; | ||
} | { | ||
file: any; | ||
link: any; | ||
error: string; | ||
info: {}; | ||
info: { | ||
status?: undefined; | ||
}; | ||
} | { | ||
@@ -33,3 +45,5 @@ file: ArrayBuffer; | ||
error: any; | ||
info: {}; | ||
info: { | ||
status?: undefined; | ||
}; | ||
} | { | ||
@@ -39,3 +53,5 @@ file: any; | ||
error: any; | ||
info: {}; | ||
info: { | ||
status?: undefined; | ||
}; | ||
}>; | ||
@@ -42,0 +58,0 @@ } |
@@ -148,2 +148,11 @@ var __defProp = Object.defineProperty; | ||
}); | ||
if (information.status !== 200) { | ||
return { | ||
file: null, | ||
error: (await information.json()).error || "An unknown error has occurred", | ||
info: { | ||
status: information.status | ||
} | ||
}; | ||
} | ||
const response = await information.json(); | ||
@@ -161,6 +170,11 @@ const signedURLs = response.signedUrls; | ||
const styleSheets = (_b = document.assets) == null ? void 0 : _b.filter((asset2) => asset2.path.includes(".css")).map((asset2) => asset2.path); | ||
const html = htmlBuilder.build(document.html, styleSheets, test); | ||
const html = htmlBuilder.build( | ||
document.html, | ||
styleSheets, | ||
test | ||
); | ||
await uploadToSignedUrl(e.signedUrl, e.path, e.token, html); | ||
} | ||
}); | ||
console.log(response); | ||
const doc = await fetch(this.buildUrl("/api/docs/generate"), { | ||
@@ -167,0 +181,0 @@ method: "POST", |
{ | ||
"name": "@onedoc/client", | ||
"version": "0.1.24", | ||
"version": "0.1.25", | ||
"description": "Onedoc client for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -17,6 +17,9 @@ import { HtmlBuilder } from "./htmlBuilder"; | ||
title?: string; | ||
test?:boolean; | ||
save?:boolean; | ||
expiresIn?:number; | ||
test?: boolean; | ||
assets?: PathString[] | PathBuffer[]; | ||
save?: boolean; | ||
/** | ||
* Number of seconds to cache the file in the CDN for. | ||
*/ | ||
expiresIn?: number; | ||
//| ExternalLink | ||
@@ -109,4 +112,3 @@ } | ||
async render(document: DocumentInput ) { | ||
async render(document: DocumentInput) { | ||
const assets = [ | ||
@@ -116,9 +118,9 @@ ...(document.assets || []), | ||
path: "/index.html", | ||
content: document.html | ||
content: document.html, | ||
}, | ||
]; | ||
const test : boolean = document.test ? document.test : true; | ||
const save : boolean = document.save ? document.save : false; | ||
const expiresIn:number = document.expiresIn ? document.expiresIn : 1; | ||
const test: boolean = document.test ? document.test : true; | ||
const save: boolean = document.save ? document.save : false; | ||
const expiresIn: number = document.expiresIn ? document.expiresIn : 1; | ||
@@ -133,6 +135,17 @@ // Fetch the /api/docs/initiate API endpoint | ||
body: JSON.stringify({ | ||
assets | ||
assets, | ||
}), | ||
}); | ||
if (information.status !== 200) { | ||
return { | ||
file: null, | ||
error: ((await information.json()).error || | ||
"An unknown error has occurred") as string, | ||
info: { | ||
status: information.status, | ||
}, | ||
}; | ||
} | ||
// Show the response body | ||
@@ -159,3 +172,7 @@ const response = await information.json(); | ||
const html: string = htmlBuilder.build(document.html, styleSheets, test); | ||
const html: string = htmlBuilder.build( | ||
document.html, | ||
styleSheets, | ||
test | ||
); | ||
@@ -166,2 +183,4 @@ await uploadToSignedUrl(e.signedUrl, e.path, e.token, html); | ||
console.log(response); | ||
const doc = await fetch(this.buildUrl("/api/docs/generate"), { | ||
@@ -176,5 +195,5 @@ method: "POST", | ||
name: "test", | ||
test :test, | ||
test: test, | ||
save: save, | ||
expiresIn: expiresIn | ||
expiresIn: expiresIn, | ||
}), | ||
@@ -194,3 +213,3 @@ }); | ||
if (!save){ | ||
if (!save) { | ||
return { | ||
@@ -202,3 +221,4 @@ file: await doc.arrayBuffer(), | ||
}; | ||
}{ | ||
} | ||
{ | ||
return { | ||
@@ -209,7 +229,16 @@ file: null, | ||
info: {}, | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
/** | ||
* "raw": "{\"statusCode\":500,\"error\":\"internal\",\"originalError\":{\"length\":135,\"name\":\"error\",\"severity\":\"ERROR\",\"code\":\"22P02\",\"file\":\"uuid.c\",\"line\":\"133\",\"routine\":\"string_to_uuid\"},\"details\":\"insert into \\\"objects\\\" (\\\"bucket_id\\\", \\\"metadata\\\", \\\"name\\\", \\\"owner\\\", \\\"owner_id\\\", \\\"version\\\") values ($1, DEFAULT, $2, DEFAULT, DEFAULT, $3) - invalid input syntax for type uuid: \\\"pdf-70924304-2a67-4f75-99de-7e53bdbd7251\\\"\"}", | ||
*/ | ||
/** allow_owned_buckets | ||
* ( SELECT (EXISTS ( SELECT 1 | ||
FROM buckets | ||
WHERE ((buckets.id = (objects.bucket_id)::uuid) AND (buckets.api_key_id = (((current_setting('request.headers'::text, true))::json ->> 'x-api-key'::text))::uuid)))) AS "exists") | ||
*/ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
67331
765