webs-sdk 0.2.7 → 0.2.9
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.
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
interface MetadataResult {
|
|
2
|
+
status: string;
|
|
3
|
+
data?: any;
|
|
4
|
+
error?: string;
|
|
5
|
+
errorKey?: string;
|
|
6
|
+
}
|
|
1
7
|
export declare class Andromeda {
|
|
8
|
+
private backendBaseUrl;
|
|
9
|
+
constructor();
|
|
10
|
+
private init;
|
|
11
|
+
getWebsiteMetadatabyHostname(hostname: string): Promise<MetadataResult | void>;
|
|
2
12
|
}
|
|
3
13
|
export default Andromeda;
|
|
4
14
|
//# sourceMappingURL=andromeda.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"andromeda.d.ts","sourceRoot":"","sources":["../../src/libraries/andromeda.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"andromeda.d.ts","sourceRoot":"","sources":["../../src/libraries/andromeda.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,SAAS;IAClB,OAAO,CAAC,cAAc,CAAS;;YAOjB,IAAI;IAIZ,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CA+DvF;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,7 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Andromeda = void 0;
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
4
8
|
class Andromeda {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.backendBaseUrl = config_1.default.backendBaseUrl;
|
|
11
|
+
this.init();
|
|
12
|
+
}
|
|
13
|
+
async init() {
|
|
14
|
+
console.debug("Andromeda init");
|
|
15
|
+
}
|
|
16
|
+
async getWebsiteMetadatabyHostname(hostname) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
console.debug("Andromeda getWebsiteMetadatabyHostname called with hostname:", hostname);
|
|
19
|
+
if (!hostname) {
|
|
20
|
+
console.warn("hostname es requerido");
|
|
21
|
+
return {
|
|
22
|
+
status: 'error',
|
|
23
|
+
errorKey: 'invalidData',
|
|
24
|
+
error: 'Required fields: hostname'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const formData = new URLSearchParams();
|
|
29
|
+
formData.append('hostname', hostname);
|
|
30
|
+
const response = await fetch(`${this.backendBaseUrl}/content/andromeda/get-website-metadata-by-hostname`, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
34
|
+
},
|
|
35
|
+
body: formData
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
39
|
+
}
|
|
40
|
+
const result = await response.json();
|
|
41
|
+
console.log("getWebsiteMetadatabyHostname response:", JSON.stringify(result, null, 2));
|
|
42
|
+
if (!((_a = result.data) === null || _a === void 0 ? void 0 : _a.web_id)) {
|
|
43
|
+
if (((_c = (_b = result.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) && ((_e = (_d = result.data) === null || _d === void 0 ? void 0 : _d.error) === null || _e === void 0 ? void 0 : _e.desc)) {
|
|
44
|
+
return {
|
|
45
|
+
status: 'error',
|
|
46
|
+
errorKey: result.data.error.code,
|
|
47
|
+
error: result.data.error.desc
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
status: 'error',
|
|
52
|
+
errorKey: 'no-website-data',
|
|
53
|
+
error: 'No website data found in server response'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
status: 'success',
|
|
58
|
+
data: result.data
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return {
|
|
63
|
+
status: 'error',
|
|
64
|
+
errorKey: 'server-error',
|
|
65
|
+
error: "Server communication error"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
5
69
|
}
|
|
6
70
|
exports.Andromeda = Andromeda;
|
|
7
71
|
exports.default = Andromeda;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"andromeda.js","sourceRoot":"","sources":["../../src/libraries/andromeda.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"andromeda.js","sourceRoot":"","sources":["../../src/libraries/andromeda.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA+B;AAS/B,MAAa,SAAS;IAGlB;QACI,IAAI,CAAC,cAAc,GAAG,gBAAM,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,IAAI;QACd,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,QAAgB;;QAC/C,OAAO,CAAC,KAAK,CAAC,8DAA8D,EAAE,QAAQ,CAAC,CAAC;QAExF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACtC,OAAO;gBACH,MAAM,EAAE,OAAO;gBACf,QAAQ,EAAE,aAAa;gBACvB,KAAK,EAAE,2BAA2B;aACrC,CAAC;QACN,CAAC;QAEA,IAAI,CAAC;YACF,MAAM,QAAQ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CAAA;QAEL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,MAAM,EAAE,OAAO;gBACf,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,4BAA4B;aACtC,CAAA;QACL,CAAC;IAEL,CAAC;CACJ;AA3ED,8BA2EC;AAED,kBAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ declare module "webs-sdk" {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
interface AuthManager {
|
|
90
|
-
auto_login(cfg_sessionid: string): Promise<any>;
|
|
90
|
+
auto_login(cfg_sessionid: string, website_id: string): Promise<any>;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
interface I18nManager {
|
|
@@ -153,7 +153,7 @@ declare module "webs-sdk" {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
interface Andromeda {
|
|
156
|
-
|
|
156
|
+
getWebsiteMetadatabyHostname(hostname: string): Promise<MetadataResult | void>;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
interface ContentManager {
|