@narrative.io/data-collaboration-sdk-ts 0.11.0 → 0.11.1
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/build/base-api.d.ts +1 -0
- package/build/base-api.js +21 -7
- package/build/uploads/index.js +10 -1
- package/package.json +1 -1
package/build/base-api.d.ts
CHANGED
package/build/base-api.js
CHANGED
|
@@ -15,20 +15,21 @@ export class BaseApi {
|
|
|
15
15
|
* @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod').
|
|
16
16
|
*/
|
|
17
17
|
constructor(config) {
|
|
18
|
-
this.verbose = config.verbose ?? false;
|
|
19
18
|
this.apiKey = config.apiKey;
|
|
20
19
|
this.environment = config.environment ?? "prod";
|
|
20
|
+
this.verbose = (config.verbose ?? false) || this.environment === "dev";
|
|
21
21
|
this.headers = config.headers ?? {};
|
|
22
22
|
this.base_api = mande(`${this.getBaseUrl()}`, {
|
|
23
23
|
headers: this.constructHeaders(),
|
|
24
24
|
});
|
|
25
|
+
this.drawLogo();
|
|
25
26
|
if (this.verbose) {
|
|
26
|
-
console.
|
|
27
|
-
console.
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
30
|
-
console.
|
|
31
|
-
console.
|
|
27
|
+
console.info(`Using environment: ${this.environment}`);
|
|
28
|
+
console.info(`Using API key: ${this.apiKey ?? "undefined"}`);
|
|
29
|
+
console.info(`Using headers: ${JSON.stringify(this.constructHeaders())}`);
|
|
30
|
+
console.info(`Using base URL: ${this.getBaseUrl()}`);
|
|
31
|
+
console.info(`Using base API: ${JSON.stringify(this.base_api)}`);
|
|
32
|
+
console.info(`This is us: ${JSON.stringify(this)}`);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
@@ -169,4 +170,17 @@ export class BaseApi {
|
|
|
169
170
|
}
|
|
170
171
|
return queryParameters.length > 0 ? `?${queryParameters.join("&")}` : "";
|
|
171
172
|
}
|
|
173
|
+
drawLogo() {
|
|
174
|
+
console.log(" ___ ___ ___ ___ ___ ___ ");
|
|
175
|
+
console.log(" /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ ___ /\\__\\ ");
|
|
176
|
+
console.log(" \\:\\ \\ /::\\ \\ /::\\ \\ /::\\ \\ /::\\ \\ ___ ___ /\\ \\ /:/ _/_ ");
|
|
177
|
+
console.log(" \\:\\ \\ /:/\\:\\ \\ /:/\\:\\__\\ /:/\\:\\__\\ /:/\\:\\ \\ /\\__\\ /\\__\\ \\:\\ \\ /:/ /\\__\\ ");
|
|
178
|
+
console.log(" _____\\:\\ \\ /:/ /::\\ \\ /:/ /:/ / /:/ /:/ / /:/ /::\\ \\ /:/ / /:/__/ \\:\\ \\ /:/ /:/ _/_ ");
|
|
179
|
+
console.log(" /::::::::\\__\\ /:/_/:/\\:\\__\\ /:/_/:/__/___ /:/_/:/__/___ /:/_/:/\\:\\__\\ /:/__/ /::\\ \\ ___ \\:\\__\\ /:/_/:/ /\\__\\");
|
|
180
|
+
console.log(" \\:\\~~\\~~\\/__/ \\:\\/:/ \\/__/ \\:\\/:::::/ / \\:\\/:::::/ / \\:\\/:/ \\/__/ /::\\ \\ \\/\\:\\ \\__ /\\ \\ |:| | \\:\\/:/ /:/ /");
|
|
181
|
+
console.log(" \\:\\ \\ \\::/__/ \\::/~~/~~~~ \\::/~~/~~~~ \\::/__/ /:/\\:\\ \\ ~~\\:\\/\\__\\ \\:\\ \\|:| | \\::/_/:/ / ");
|
|
182
|
+
console.log(" \\:\\ \\ \\:\\ \\ \\:\\~~\\ \\:\\~~\\ \\:\\ \\ \\/__\\:\\ \\ \\::/ / \\:\\__|:|__| \\:\\/:/ / ");
|
|
183
|
+
console.log(" \\:\\__\\ \\:\\__\\ \\:\\__\\ \\:\\__\\ \\:\\__\\ \\:\\__\\ /:/ / \\::::/__/ \\::/ / ");
|
|
184
|
+
console.log(" \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ ~~~~ \\/__/ ");
|
|
185
|
+
}
|
|
172
186
|
}
|
package/build/uploads/index.js
CHANGED
|
@@ -44,11 +44,19 @@ class UploadsApi extends BaseApi {
|
|
|
44
44
|
* @returns {Promise<boolean>} A promise that resolves to true if the file is successfully uploaded.
|
|
45
45
|
*/
|
|
46
46
|
async uploadFileToS3(file, uploadInfo) {
|
|
47
|
+
if (this.verbose) {
|
|
48
|
+
console.info(`Uploading file to S3: ${file.name}`);
|
|
49
|
+
console.info(`Upload URL: ${uploadInfo.url}`);
|
|
50
|
+
console.info(`Upload path: ${uploadInfo.path}`);
|
|
51
|
+
console.info(`Upload expiry: ${uploadInfo.expiry}`);
|
|
52
|
+
console.info(`Upload file type: ${file.type}`);
|
|
53
|
+
console.info(`Upload file size: ${file.size}`);
|
|
54
|
+
}
|
|
47
55
|
if (uploadInfo.expiry < new Date().toISOString()) {
|
|
48
56
|
throw new Error("Upload URL has expired");
|
|
49
57
|
}
|
|
50
58
|
try {
|
|
51
|
-
const response = await fetch(uploadInfo.
|
|
59
|
+
const response = await fetch(uploadInfo.url, {
|
|
52
60
|
method: "PUT",
|
|
53
61
|
body: file,
|
|
54
62
|
headers: {
|
|
@@ -64,6 +72,7 @@ class UploadsApi extends BaseApi {
|
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
catch (error) {
|
|
75
|
+
console.error("Upload failed:", error);
|
|
67
76
|
return false;
|
|
68
77
|
}
|
|
69
78
|
}
|