armisa-models
Version:
models of armisa!
194 lines (193 loc) • 9.16 kB
JavaScript
;
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _a, _AmisaManager_amisaManagerSetting, _AmisaManager_temp, _AmisaManager_init, _AmisaManager_getPort, _AmisaManager_projectKey, _AmisaManager_getBaseUrl, _AmisaManager_getUrl, _AmisaManager_pathMaager, _AmisaManager_mainInit, _AmisaManager_isStringOfLength, _AmisaManager_myString, _AmisaManager_ConfigureProtoType;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AmisaManager = exports.testPortAddress = exports.testUrlAddress = void 0;
const amisa_paths_1 = require("amisa-paths");
const MainStateManager_1 = require("../MainStateManager");
exports.testUrlAddress = '80.210.62.172';
exports.testPortAddress = '3303';
class AmisaManager {
static get setting() {
return __classPrivateFieldGet(this, _a, "f", _AmisaManager_amisaManagerSetting)[this.token];
}
static ConfigureServices(baseUrlHttpType, baseUrl, baseUrlPort, projectKey, c) {
__classPrivateFieldGet(this, _a, "f", _AmisaManager_mainInit).call(this);
const getUrl = __classPrivateFieldGet(this, _a, "f", _AmisaManager_getUrl).call(this, baseUrlHttpType, baseUrl, baseUrlPort);
const getProjectKey = __classPrivateFieldGet(this, _a, "f", _AmisaManager_projectKey).call(this, projectKey);
const getPathManager = __classPrivateFieldGet(this, _a, "f", _AmisaManager_pathMaager).call(this, c);
__classPrivateFieldGet(this, _a, "f", _AmisaManager_temp).initializeServices(getUrl, getProjectKey, getPathManager);
}
;
}
exports.AmisaManager = AmisaManager;
_a = AmisaManager, _AmisaManager_ConfigureProtoType = function _AmisaManager_ConfigureProtoType() {
if (String.prototype.assignLength === undefined) {
Object.defineProperty(String.prototype, 'assignLength', {
value: (min, max) => {
var self = this;
self['min'] = min;
self['max'] = max;
},
enumerable: false,
});
}
if (Object.prototype.getProp === undefined) {
Object.defineProperty(Object.prototype, 'getProp', {
value: function (prop) {
var key, self = this;
if (typeof prop !== 'string') {
console.error(prop, 'is not a apt value', self);
}
for (key in self) {
if (key.toLowerCase() == prop.toLowerCase()) {
return self[key];
}
}
},
//this keeps jquery happy
enumerable: false,
});
}
if (Object.prototype.setProp === undefined) {
Object.defineProperty(Object.prototype, 'setProp', {
value: function (prop, value) {
var key, self = this;
if (typeof prop !== 'string') {
console.error(prop, 'is not a apt value to set', self);
}
for (key in self) {
if (key.toLowerCase() == prop.toLowerCase()) {
self[key] = value;
}
}
},
//this keeps jquery happy
enumerable: false,
});
}
if (Object.prototype.getPropValue === undefined) {
Object.defineProperty(Object.prototype, 'getPropValue', {
value: function (prop, defaultValue) {
var key, self = this;
if (typeof prop !== 'string' || prop === '') {
console.error(prop, 'is not a apt value', self);
return undefined;
}
if (!self) {
console.error(prop, 'is not a apt object', self);
return undefined;
}
for (key in self) {
if (key.toLowerCase() == prop.toLowerCase() && self[key]) {
return self[key];
}
}
return defaultValue;
},
//this keeps jquery happy
enumerable: false,
});
}
if (Object.prototype.getPropsValue === undefined) {
Object.defineProperty(Object.prototype, 'getPropsValue', {
value: function (prop1, prop2, defaultValue) {
var key, self = this;
if (!self) {
console.error(prop1, prop2, 'is not a apt object', self);
return undefined;
}
if (typeof prop1 !== 'string' || prop1 === '') {
console.error(prop1, 'is not a apt value', self);
return undefined;
}
else if (typeof prop2 !== 'string' || prop2 === '') {
console.error(prop2, 'is not a apt value', self);
return undefined;
}
for (key in self) {
if (key.toLowerCase() == prop1.toLowerCase() && self[key]) {
return self[key];
}
}
for (key in self) {
if (key.toLowerCase() == prop2.toLowerCase() && self[key]) {
return self[key];
}
}
return defaultValue;
},
//this keeps jquery happy
enumerable: false,
});
}
};
_AmisaManager_amisaManagerSetting = { value: void 0 };
AmisaManager.token = Symbol.for('a');
_AmisaManager_temp = { value: void 0 };
_AmisaManager_init = { value: () => {
Object.defineProperty(Object.prototype, _a.token, {
enumerable: false,
configurable: false,
get: () => { return __classPrivateFieldGet(_a, _a, "f", _AmisaManager_temp); },
});
} };
_AmisaManager_getPort = { value: (port) => {
if (port) {
return `:${port}`;
}
return '';
} };
_AmisaManager_projectKey = { value: (projectKey) => {
if (!projectKey) {
throw Error('project key not initialize');
}
return projectKey;
} };
_AmisaManager_getBaseUrl = { value: (url) => {
if (url || url.length < 3) {
return `${url.replace('/', '').replace(':', '')}`;
}
throw Error('url not initialize');
} };
_AmisaManager_getUrl = { value: (baseUrlHttpType, baseUrl, baseUrlPort) => {
const baseUrlFinal = `${baseUrlHttpType}://${__classPrivateFieldGet(_a, _a, "f", _AmisaManager_getBaseUrl).call(_a, baseUrl)}${__classPrivateFieldGet(_a, _a, "f", _AmisaManager_getPort).call(_a, baseUrlPort)}`;
if (!baseUrlFinal || baseUrlFinal.length < 6) {
throw Error('base url not initialize');
}
return baseUrlFinal;
} };
_AmisaManager_pathMaager = { value: (c) => {
const pathManager = new amisa_paths_1.Paths();
c(pathManager);
return pathManager;
} };
_AmisaManager_mainInit = { value: () => {
__classPrivateFieldSet(_a, _a, {}, "f", _AmisaManager_amisaManagerSetting);
__classPrivateFieldSet(_a, _a, new MainStateManager_1.MainStateManager(), "f", _AmisaManager_temp);
if (Object.prototype[AmisaManager.token] === undefined) {
__classPrivateFieldGet(_a, _a, "f", _AmisaManager_init).call(_a);
}
__classPrivateFieldGet(_a, _a, "m", _AmisaManager_ConfigureProtoType).call(_a);
} };
_AmisaManager_isStringOfLength = { value: (str, min, max) => str.length >= min && str.length <= max };
_AmisaManager_myString = { value: (input, min, max) => {
if (typeof input !== 'string') {
throw new Error('invalid input');
}
if (!__classPrivateFieldGet(_a, _a, "f", _AmisaManager_isStringOfLength).call(_a, input, min, max)) {
throw new Error('invalid input');
}
return input;
} };
exports.default = AmisaManager;