hotstaq 0.6.1 → 0.6.21
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/src/HotComponentElement.d.ts +28 -0
- package/build/src/HotComponentElement.d.ts.map +1 -0
- package/build/src/HotComponentElement.js +382 -0
- package/build/src/HotComponentElement.js.map +1 -0
- package/build/src/HotDBConnectionInterface.d.ts +14 -0
- package/build/src/HotDBConnectionInterface.d.ts.map +1 -1
- package/build/src/HotStaq.d.ts.map +1 -1
- package/build/src/HotStaq.js +1 -1
- package/build/src/HotStaq.js.map +1 -1
- package/build/src/schemas/HotDBInflux.d.ts.map +1 -1
- package/build/src/schemas/HotDBInflux.js +2 -0
- package/build/src/schemas/HotDBInflux.js.map +1 -1
- package/build/src/schemas/HotDBMySQL.d.ts.map +1 -1
- package/build/src/schemas/HotDBMySQL.js +11 -4
- package/build/src/schemas/HotDBMySQL.js.map +1 -1
- package/build-web/HotSiteTest.yaml +93 -0
- package/build-web/HotStaq.js +2 -2
- package/build-web/HotStaq.min.js +125 -0
- package/build-web/HotStaqTests_HelloWorldAPI.js +395 -0
- package/package.json +4 -4
- package/selenium-start.sh +2 -2
- package/src/HotDBConnectionInterface.ts +14 -0
- package/src/HotStaq.ts +1 -1
- package/src/schemas/HotDBInflux.ts +3 -0
- package/src/schemas/HotDBMySQL.ts +15 -4
- package/staq-apps/@hotstaq/admin-panel/build/AppAPI.d.ts +8 -0
- package/staq-apps/@hotstaq/admin-panel/build/AppAPI.d.ts.map +1 -0
- package/staq-apps/@hotstaq/admin-panel/build/AppAPI.js +86 -0
- package/staq-apps/@hotstaq/admin-panel/build/AppAPI.js.map +1 -0
- package/staq-apps/@hotstaq/admin-panel/build/DataRoute.d.ts +21 -0
- package/staq-apps/@hotstaq/admin-panel/build/DataRoute.d.ts.map +1 -0
- package/staq-apps/@hotstaq/admin-panel/build/DataRoute.js +235 -0
- package/staq-apps/@hotstaq/admin-panel/build/DataRoute.js.map +1 -0
- package/staq-apps/@hotstaq/admin-panel/build/WebExport.d.ts +4 -0
- package/staq-apps/@hotstaq/admin-panel/build/WebExport.d.ts.map +1 -0
- package/staq-apps/@hotstaq/admin-panel/build/WebExport.js +8 -0
- package/staq-apps/@hotstaq/admin-panel/build/WebExport.js.map +1 -0
- package/staq-apps/@hotstaq/admin-panel/public/js/HotStaq.js +4610 -0
- package/staq-apps/@hotstaq/admin-panel/public/js/HotStaq.min.js +4785 -0
- package/core.246.!root!.npm!_npx!eebfe7380786cc7c!node_modules!google-closure-compiler-linux!compiler +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';var HotStaqWeb;
|
|
2
|
+
(()=>{function da(D){var u=ea[D];if(void 0!==u)return u.exports;u=ea[D]={exports:{}};return ha[D].call(u.exports,u,u.exports,da),u.exports}var ha={230:D=>{D.exports="object"==typeof self?self.FormData:window.FormData},646:function(D){D.exports=function(){function u(q){for(var p=1;p<arguments.length;p++){var C=arguments[p],x;for(x in C)q[x]=C[x]}return q}return function x(p,C){function d(g,m,h){if("undefined"!=typeof document){"number"==typeof(h=u({},C,h)).expires&&(h.expires=new Date(Date.now()+864E5*
|
|
3
|
+
h.expires));h.expires&&(h.expires=h.expires.toUTCString());g=encodeURIComponent(g).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="",b;for(b in h)h[b]&&(c+="; "+b,!0!==h[b]&&(c+="="+h[b].split(";")[0]));return document.cookie=g+"="+p.write(m,g)+c}}return Object.create({set:d,get:function(g){if("undefined"!=typeof document&&(!arguments.length||g)){for(var m=document.cookie?document.cookie.split("; "):[],h={},c=0;c<m.length;c++){var b=m[c].split("="),l=b.slice(1).join("=");
|
|
4
|
+
try{var k=decodeURIComponent(b[0]);if(h[k]=p.read(l,k),g===k)break}catch(n){}}return g?h[g]:h}},remove:function(g,m){d(g,"",u({},m,{expires:-1}))},withAttributes:function(g){return x(this.converter,u({},this.attributes,g))},withConverter:function(g){return x(u({},this.converter,g),this.attributes)}},{attributes:{value:Object.freeze(C)},converter:{value:Object.freeze(p)}})}({read:function(p){return'"'===p[0]&&(p=p.slice(1,-1)),p.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(p){return encodeURIComponent(p).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
5
|
+
decodeURIComponent)}},{path:"/"})}()},300:(D,u)=>{var q=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==q)return q;throw Error("unable to locate global object");}();(D.exports=u=q.fetch)&&(u.default=q.fetch.bind(q));u.Headers=q.Headers;u.Request=q.Request;u.Response=q.Response},507:function(D,u,q){var p=this&&this.__awaiter||function(c,b,l,k){return new (l||(l=Promise))(function(n,r){function t(z){try{y(k.next(z))}catch(E){r(E)}}function I(z){try{y(k.throw(z))}catch(E){r(E)}}
|
|
6
|
+
function y(z){var E;z.done?n(z.value):(E=z.value,E instanceof l?E:new l(function(M){M(E)})).then(t,I)}y((k=k.apply(c,b||[])).next())})},C=this&&this.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(u,"__esModule",{value:!0});u.Hot=u.DeveloperMode=void 0;const x=q(732),d=q(243);D=q(967);const g=C(q(646)),m=C(q(300));!function(c){c[c.Production=0]="Production";c[c.Development=1]="Development"}(q=u.DeveloperMode||(u.DeveloperMode={}));class h{static include(c,
|
|
7
|
+
b=null){return p(this,void 0,void 0,function*(){if(!0===d.HotStaq.isWeb&&"string"==typeof c){const l=c.toLowerCase();-1<l.indexOf(".hott")&&0>l.indexOf("nahfam")&&(c+="?hstqserve=nahfam")}h.echo(yield h.getFile(c,b))})}static includeJS(c){return p(this,void 0,void 0,function*(){const b=yield(yield h.httpRequest(c)).text();!0===d.HotStaq.isWeb?eval.apply(window,[b]):eval(b)})}static runFile(c,b=null){return p(this,void 0,void 0,function*(){var l=h.CurrentPage.processor.getFile(c);l.page=this.CurrentPage;
|
|
8
|
+
l=yield l.process(b);h.echo(l)})}static getFile(c,b=null){return p(this,void 0,void 0,function*(){let l=null;return"string"==typeof c?(l=new x.HotFile,!0===d.HotStaq.isWeb?l.url=c:l.localFile=c):l=c,yield l.load(),l.page=this.CurrentPage,yield l.process(b)})}static apiCall(c,b=null,l="POST",k={}){return p(this,void 0,void 0,function*(){let n=null;if(null==h.CurrentPage)throw Error("Current page is null!");if(null==h.CurrentPage.processor)throw Error("Current page's processor is null!");if(null==h.CurrentPage.processor.api)throw Error("Current page's processor api is null! Did you forget to set the API name or URL?");
|
|
9
|
+
return null!=h.CurrentPage.processor.api&&(n=yield h.CurrentPage.processor.api.makeCall(c,b,l,k)),n})}static jsonRequest(c,b=null,l="POST"){return p(this,void 0,void 0,function*(){try{let k={method:l,headers:{Accept:"application/json","Content-Type":"application/json"}};"POST"===l&&(k.body=JSON.stringify(b));let n=yield(0,m.default)(c,k);if(!1===n.ok)throw Error(`${n.status}: ${n.statusText}`);return yield n.json()}catch(k){return JSON.stringify({error:`${k.message} - Could not fetch ${c}`})}})}static httpRequest(c,
|
|
10
|
+
b){return p(this,void 0,void 0,function*(){return yield(0,m.default)(c,b)})}static echo(c){h.Output+=c}static displayCSS(){for(let c=0;c<h.CSS.length;c++){let b=h.cssStr;b=b.replace(/%CSS_FILE%/g,h.CSS[c]);h.echo(b)}}static displayJSFiles(){for(let c=0;c<h.JSFiles.length;c++){let b=h.jsFileStr;b=b.replace(/%JS_FILE%/g,h.JSFiles[c]);h.echo(b)}}static displayJSScripts(){for(let c=0;c<h.JSScripts.length;c++){let b=h.jsScriptsStr;b=b.replace(/%JS_CODE%/g,h.JSScripts[c]);h.echo(b)}}}u.Hot=h;h.CurrentPage=
|
|
11
|
+
null;h.Arguments=null;h.DeveloperMode=q;h.HotTestElement=D.HotTestElement;h.Mode=q.Production;h.API=null;h.TesterAPI=null;h.Output="";h.Data={};h.Cookies=g.default;h.PublicKeys={};h.cssStr='<link rel = "stylesheet" href = "%CSS_FILE%" />';h.CSS=[];h.JSFiles=[];h.JSScripts=[];h.jsFileStr='<script type = "text/javascript" src = "%JS_FILE%">\x3c/script>';h.jsScriptsStr='<script type = "text/javascript">%JS_CODE%\x3c/script>'},233:function(D,u,q){var p=this&&this.__awaiter||function(c,b,l,k){return new (l||
|
|
12
|
+
(l=Promise))(function(n,r){function t(z){try{y(k.next(z))}catch(E){r(E)}}function I(z){try{y(k.throw(z))}catch(E){r(E)}}function y(z){var E;z.done?n(z.value):(E=z.value,E instanceof l?E:new l(function(M){M(E)})).then(t,I)}y((k=k.apply(c,b||[])).next())})};D=this&&this.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(u,"__esModule",{value:!0});u.HotAPI=u.EventExecutionType=void 0;const C=D(q(300)),x=D(q(230)),d=q(810),g=q(761),m=q(70);var h;!function(c){c[c.HotRoute=
|
|
13
|
+
0]="HotRoute";c[c.HotMethod=1]="HotMethod";c[c.HotAPI=2]="HotAPI"}(h=u.EventExecutionType||(u.EventExecutionType={}));u.HotAPI=class{constructor(c,b=null,l=null){this.connection=b;this.description="";this.baseUrl=c;this.createFunctions=!0;this.executeEventsUsing=h.HotRoute;this.db=l;this.userAuth=this.authCredentials=null;this.routes={};this.onPostRegister=this.onPreRegister=null}setDBSchema(c){if(null==this.connection.api)throw Error("No API has been set!");if(null==this.connection.api.db)throw Error(`No database has been set for API base url ${this.connection.api.baseUrl}`);
|
|
14
|
+
this.connection.api.db.schema=c}getDB(){if(null==this.connection.api.db)throw Error(`No database has been set for API base url ${this.connection.api.baseUrl}`);return this.connection.api.db}getDBSchema(){if(null==this.connection.api.db)throw Error(`No database has been set for API base url ${this.connection.api.baseUrl}`);return this.connection.api.db.schema}addRoute(c,b=null,l=null){let k="";if(c instanceof g.HotRoute?(k=c.route,this.routes[c.route]=c):(k=c,null==this.routes[k]&&(this.routes[k]=
|
|
15
|
+
new g.HotRoute(this.connection,k)),b instanceof m.HotRouteMethod?this.routes[k].addMethod(b):this.routes[k].addMethod(new m.HotRouteMethod(this.routes[k],b,l))),this.routes[k].connection=this.connection,!0===this.createFunctions){c=this[k];null==c&&(c={});for(b=0;b<this.routes[k].methods.length;b++){let n=this.routes[k],r=this.routes[k].methods[b];c[r.name]=(t,I)=>{let y=r.type,z="";""!==n.version&&(z+=`/${n.version}`);""!==n.route&&(z+=`/${n.route}`);""!==r.name&&(z+=`/${r.name}`);let E=null;if(null!=
|
|
16
|
+
this.authCredentials&&(E=this.authCredentials),null!=r.authCredentials?E=r.authCredentials:null!=r.route.authCredentials&&(E=r.route.authCredentials),null==E&&"undefined"!=typeof Hot&&null!=Hot&&null!=Hot.API&&null!=Hot.API[n.route]&&null!=Hot.API[n.route].authCredentials&&(E=Hot.API[n.route].authCredentials),null!=E)for(let M in E){let H=E[M];null==t[M]&&(t[M]=H)}return this.makeCall.apply(this,[z,t,y,I])}}this[k]=c}}registerRoute(c){return p(this,void 0,void 0,function*(){this.connection instanceof
|
|
17
|
+
d.HotServer&&(yield this.connection.registerRoute(c))})}registerRoutes(){return p(this,void 0,void 0,function*(){for(let c in this.routes)yield this.registerRoute(this.routes[c])})}makeCall(c,b,l="POST",k={}){return p(this,void 0,void 0,function*(){let n=this.baseUrl;if(l=l.toUpperCase(),"/"===n[n.length-1]&&(n=n.substr(0,n.length-1)),"/"!==c[0]&&(n+="/"),n+=c,0<Object.keys(k).length){if("POST"!==l)throw Error("To upload files, you must set the httpMethod to POST.");var r=new x.default;for(let I in k)r.append(I,
|
|
18
|
+
k[I]);r=yield(yield(0,C.default)(n,{method:"POST",body:r})).json();return null==b.hotstaq&&(b.hotstaq={}),null==b.hotstaq.uploads&&(b.hotstaq.uploads={}),b.hotstaq.uploads.uploadId=r.hotstaq.uploads.uploadId,yield this.makeCall(c,b,l)}let t={method:l,headers:{Accept:"application/json","Content-Type":"application/json"}};return"GET"!==l&&"HEAD"!==l&&(t.body=JSON.stringify(b)),new Promise((I,y)=>{(0,C.default)(n,t).then(z=>p(this,void 0,void 0,function*(){let E=yield z.json();I(E)})).catch(z=>{throw Error(`${n}: ${z.message}`);
|
|
19
|
+
})})})}}},957:(D,u,q)=>{Object.defineProperty(u,"__esModule",{value:!0});u.HotClient=void 0;const p=q(810);u.HotClient=class{constructor(C){this.processor=C;this.testerAPI=this.api=null;this.type=p.HotServerType.HTTP;this.logger=C.logger}}},260:function(D,u,q){var p=this&&this.__awaiter||function(x,d,g,m){return new (g||(g=Promise))(function(h,c){function b(n){try{k(m.next(n))}catch(r){c(r)}}function l(n){try{k(m.throw(n))}catch(r){c(r)}}function k(n){var r;n.done?h(n.value):(r=n.value,r instanceof
|
|
20
|
+
g?r:new g(function(t){t(r)})).then(b,l)}k((m=m.apply(x,d||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0});u.HotComponent=void 0;const C=q(243);u.HotComponent=class{constructor(x,d=null){x instanceof C.HotStaq||null==x?(this.processor=x,this.htmlElements=[],this.name="",this.tag="",this.api=null,this.elementOptions=void 0,this.observedAttributes=[],this.type="",this.value=null,this.inner=null,this.events={}):(this.processor=x.processor,this.htmlElements=x.htmlElements||[],this.name=
|
|
21
|
+
x.name||"",this.tag=x.tag||this.name,this.api=x.api||null,this.elementOptions=x.elementOptions||void 0,this.observedAttributes=x.observedAttributes||[],this.type=x.type||"",this.value=x.value||null,this.inner=x.inner||null,this.events={});null!=d&&(this.api=d)}onCreated(x){return p(this,void 0,void 0,function*(){return x})}}},732:function(D,u,q){var p=this&&this.__createBinding||(Object.create?function(b,l,k,n){void 0===n&&(n=k);Object.defineProperty(b,n,{enumerable:!0,get:function(){return l[k]}})}:
|
|
22
|
+
function(b,l,k,n){void 0===n&&(n=k);b[n]=l[k]}),C=this&&this.__setModuleDefault||(Object.create?function(b,l){Object.defineProperty(b,"default",{enumerable:!0,value:l})}:function(b,l){b.default=l});D=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var l={};if(null!=b)for(var k in b)"default"!==k&&Object.prototype.hasOwnProperty.call(b,k)&&p(l,b,k);return C(l,b),l};var x=this&&this.__awaiter||function(b,l,k,n){return new (k||(k=Promise))(function(r,t){function I(E){try{z(n.next(E))}catch(M){t(M)}}
|
|
23
|
+
function y(E){try{z(n.throw(E))}catch(M){t(M)}}function z(E){var M;E.done?r(E.value):(M=E.value,M instanceof k?M:new k(function(H){H(M)})).then(I,y)}z((n=n.apply(b,l||[])).next())})},d=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(u,"__esModule",{value:!0});u.HotFile=void 0;const g=D(q(351)),m=d(q(300)),h=q(507);class c{constructor(b={}){this.page=b.page||null;this.name=b.name||"";this.url=b.url||"";this.localFile=b.localFile||"";this.content=
|
|
24
|
+
b.content||"";this.throwAllErrors=b.throwAllErrors||!1}setContent(b){this.content=b}getContent(){return this.content}static httpGet(b){return x(this,void 0,void 0,function*(){try{let l=yield(0,m.default)(b);if(!1===l.ok)throw Error(`${l.status}: ${l.statusText}`);return yield l.text()}catch(l){return JSON.stringify({error:`${l.message} - Could not fetch ${b}`})}})}loadUrl(){return x(this,void 0,void 0,function*(){return this.content=yield c.httpGet(this.url),this.content})}loadLocalFile(){return x(this,
|
|
25
|
+
void 0,void 0,function*(){return new Promise((b,l)=>{g.readFile(this.localFile,(k,n)=>{if(null!=k)throw k;this.content=n.toString();b(this.content)})})})}load(){return x(this,void 0,void 0,function*(){let b="";return""!==this.url&&(b=yield this.loadUrl()),""!==this.localFile&&(b=yield this.loadLocalFile()),b})}static processContent(b,l,k,n,r=2,t=2){let I=l.exec(b),y=0,z="";for(;null!=I;){let E=l.lastIndex+t,M=b.substr(y,I.index-r-y);y=E;z+=n(M);z+=k(I[0]);I=l.exec(b)}return z+=n(b.substr(y)),z}static processNestedContent(b,
|
|
26
|
+
l,k,n,r,t,I=2,y=1){let z=b.indexOf(l),E=0;var M=b.indexOf(n,z);let H="";for(;-1<z;){var a=b.indexOf(k,z);let f=0;if(""!==n){let e=b.lastIndexOf(n,a-y);for(;-1<e&&e!==M;)e=b.lastIndexOf(n,e-y),f++}if(0<f){for(a=M=b.indexOf(k,a+y);-1<M&&0<f&&!(0>a)&&!(b.lastIndexOf(l,a-y)>M);)M=a,a=b.indexOf(k,M+y),f--;a=M}H+=t(b.substr(E,z-E));H+=r(b.substr(z+I,a-(z+I)));z=b.indexOf(l,a+y);M=b.indexOf(n,z);E=a+y}return H+=t(b.substr(E)),H}static parseContent(b,l,k=null){null==k&&(k={outputCommands:!0,allowStringify:!0});
|
|
27
|
+
let n="JSON.stringify (",r=")";return!1===k.allowStringify&&(n="",r=""),c.processContent(b,RegExp("(?=\\<\\*)([\\s\\S]*?)(?=\\*\\>)","g"),t=>`${t.substr(2)}`,t=>{if(""===t)return"";t=c.processNestedContent(t,"!{","}","{",y=>`*&&%*%@#@!${y}*&!#%@!@*!`,y=>y);t=c.processNestedContent(t,"STR{","}","{",y=>{let z="";return z=!0===k.outputCommands?`*&&%*%@#@!echoOutput (JSON.stringify(${y}), ${l});*&!#%@!@*!`:`*&&%*%@#@!${n}${y}${r}, ${l});*&!#%@!@*!`,z},y=>y,4,1);t=c.processNestedContent(t,"${","}","{",
|
|
28
|
+
y=>{let z="";return!0===k.outputCommands?(z=`*&&%*%@#@!try { Hot.echo (${y}); }catch (ex){Hot.echo ("");}*&!#%@!@*!`,!0===l&&(z=`*&&%*%@#@!Hot.echo (${y});*&!#%@!@*!`)):z=`*&&%*%@#@!${y}*&!#%@!@*!`,z},y=>y);let I="";h.Hot.Mode===h.DeveloperMode.Production&&(I=c.processNestedContent(t,"?(",")","(",y=>"",y=>y));h.Hot.Mode===h.DeveloperMode.Development&&(I=c.processNestedContent(t,"?(",")","(",y=>{var z="";try{JSON.parse(y),z=!0===k.allowStringify?JSON.stringify(y):`${y}`}catch(E){z=`${y}`}if(!0===k.outputCommands)y=
|
|
29
|
+
`*&&%*%@#@!{\nconst testElm = createTestElement (${z});\nHot.echo (\`data-test-object-name = "\${testElm.name}" data-test-object-func = "\${testElm.func}" data-test-object-value = "\${testElm.value}"\`);\n}*&!#%@!@*!\n`;else{y=z;z=null;try{let E=y;if("string"==typeof y&&(E=JSON.parse(y)),"string"==typeof E&&(z=new h.Hot.HotTestElement(E)),E instanceof Array&&(z=new h.Hot.HotTestElement(E[0],E[1],E[2])),null!=E.name&&(z=new h.Hot.HotTestElement(E)),null!=h.Hot.CurrentPage.testElements[z.name])throw Error(`Test element ${z.name} already exists!`);
|
|
30
|
+
}catch(E){throw Error(`Error processing test element ${y} in ${h.Hot.CurrentPage.name}. Error: ${E.message}`);}y=z;y=`*&&%*%@#@!data-test-object-name = "${y.name}" data-test-object-func = "${y.func}" data-test-object-value = "${y.value}"*&!#%@!@*!`}return y},y=>y));t=c.processNestedContent(I,"*&&%*%@#@!","*&!#%@!@*!","*&&%*%@#@!",y=>y,y=>{y=!0===k.allowStringify?JSON.stringify(y):y;let z="";return z=!0===k.outputCommands?`echoOutput (${y}, ${l});\n`:y,z},10,10);return t=t.replace(/\*&&%\*%@#@!/g,
|
|
31
|
+
""),t=t.replace(/\*&!#%@!@\*!/g,""),t},0)}process(b=null){return x(this,void 0,void 0,function*(){var l=this.content;h.Hot.Mode=this.page.processor.mode;h.Hot.Arguments=b;h.Hot.CurrentPage=this.page;h.Hot.PublicKeys=this.page.processor.publicKeys;h.Hot.API=this.page.getAPI();h.Hot.TesterAPI=this.page.getTesterAPI();l=c.parseContent(l,this.throwAllErrors);let k=null;try{let r="\n\t\t\tvar Hot = arguments[0];\n\t\t\tvar PassedHotFile = arguments[1];\n\n\t\t\t";if("string"==typeof b)throw Error("The passing arguments cannot be a string!");
|
|
32
|
+
for(var n in b){let t="";t=`var ${n} = ${JSON.stringify(b[n])};\n`;r+=t}r+='\n\n\t\t\tfunction echoOutput (content, throwErrors)\n\t\t\t{\n\t\t\t\tif (throwErrors == null)\n\t\t\t\t\tthrowErrors = true;\n\n\t\t\t\tif (throwErrors === true)\n\t\t\t\t{\n\t\t\t\t\tHot.echo (content);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tHot.echo (content);\n\t\t\t\t}\n\t\t\t\tcatch (ex)\n\t\t\t\t{\n\t\t\t\t\tHot.echo ("");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction createTestElement (foundStr)\n\t\t\t{\n\t\t\t\tlet testElm = null;\n\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tlet obj = foundStr;\n\n\t\t\t\t\tif (typeof (foundStr) === "string")\n\t\t\t\t\t\tobj = JSON.parse (foundStr);\n\n\t\t\t\t\tif (typeof (obj) === "string")\n\t\t\t\t\t\ttestElm = new Hot.HotTestElement (obj);\n\n\t\t\t\t\tif (obj instanceof Array)\n\t\t\t\t\t\ttestElm = new Hot.HotTestElement (obj[0], obj[1], obj[2]);\n\n\t\t\t\t\tif (obj["name"] != null)\n\t\t\t\t\t\ttestElm = new Hot.HotTestElement (obj);\n\n\t\t\t\t\tif (Hot.CurrentPage.testElements[testElm.name] != null)\n\t\t\t\t\t\tthrow new Error (`Test element ${testElm.name} already exists!`);\n\n\t\t\t\t\tHot.CurrentPage.addTestElement (testElm);\n\t\t\t\t}\n\t\t\t\tcatch (ex)\n\t\t\t\t{\n\t\t\t\t\tthrow new Error (\n\t\t\t`Error processing test element ${foundStr} in ${Hot.CurrentPage.name}. Error: ${ex.message}`\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (testElm);\n\t\t\t}\n\n\t\t\tasync function runContent (CurrentHotFile)\n\t\t\t{\n';
|
|
33
|
+
r+=l;r+="\n\t\t\t}\n\n\t\t\treturn (runContent (PassedHotFile).then (() =>\n\t\t\t{\n\t\t\t\treturn ({\n\t\t\t\t\t\thot: Hot,\n\t\t\t\t\t\toutput: Hot.Output,\n\t\t\t\t\t\tdata: JSON.stringify (Hot.Data)\n\t\t\t\t\t});\n\t\t\t}));";k=yield(new Function(r)).apply(this,[h.Hot,this])}catch(r){throw SyntaxError,r;}h.Hot.Data=k.hot.Data;n=k.output;return h.Hot.Output="",n})}}u.HotFile=c},802:(D,u)=>{var q;Object.defineProperty(u,"__esModule",{value:!0});u.HotLog=u.HotLogLevel=void 0;(function(p){p[p.Info=
|
|
34
|
+
0]="Info";p[p.Warning=1]="Warning";p[p.Error=2]="Error";p[p.Verbose=3]="Verbose";p[p.All=4]="All";p[p.None=5]="None"})(q=u.HotLogLevel||(u.HotLogLevel={}));u.HotLog=class{constructor(p=q.All){this.logLevel=p}log(p,C){this.logLevel===q.Verbose&&(p===q.Error&&this.error(C),p===q.Warning&&this.warning(C),p!==q.Info&&p!==q.Verbose||this.info(C));this.logLevel===q.All&&(p===q.Error&&this.error(C),p===q.Warning&&this.warning(C),p===q.Info&&this.info(C));this.logLevel===q.Error&&p===q.Error&&this.error(C);
|
|
35
|
+
this.logLevel===q.Warning&&p===q.Warning&&this.warning(C);this.logLevel===q.Info&&p===q.Info&&this.info(C)}verbose(p){this.logLevel===q.Verbose&&console.info(p)}info(p){this.logLevel!==q.All&&this.logLevel!==q.Verbose&&this.logLevel!==q.Info||console.info(p)}warning(p){this.logLevel!==q.All&&this.logLevel!==q.Verbose&&this.logLevel!==q.Warning||console.warn(p)}error(p){if(this.logLevel===q.All||this.logLevel===q.Verbose||this.logLevel===q.Error){let C="";"string"==typeof p?C=p:(null!=p.message&&(C=
|
|
36
|
+
p.message),null!=p.stack&&(C=p.stack));console.error(C)}}}},136:function(D,u,q){var p=this&&this.__awaiter||function(d,g,m,h){return new (m||(m=Promise))(function(c,b){function l(r){try{n(h.next(r))}catch(t){b(t)}}function k(r){try{n(h.throw(r))}catch(t){b(t)}}function n(r){var t;r.done?c(r.value):(t=r.value,t instanceof m?t:new m(function(I){I(t)})).then(l,k)}n((h=h.apply(d,g||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0});u.HotPage=void 0;const C=q(507),x=q(243);u.HotPage=class{constructor(d){d instanceof
|
|
37
|
+
x.HotStaq?(this.processor=d,this.name="",this.testerName="",this.testerMap="",this.route="",this.files=[],this.testElements={},this.testPaths={}):(this.processor=d.processor,this.name=d.name||"",this.testerName=d.testerName||"",this.testerMap=d.testerMap||"",this.route=d.route||"",this.files=d.files||[],this.testElements=d.testElements||{},this.testPaths=d.testPaths||{})}addFile(d){return p(this,void 0,void 0,function*(){d.page=this;this.files.push(d)})}getAPI(){return this.processor.api}getTesterAPI(){return this.processor.testerAPI}load(d){return p(this,
|
|
38
|
+
void 0,void 0,function*(){for(let g=0;g<this.files.length;g++)yield this.files[g].load()})}process(d=null){return p(this,void 0,void 0,function*(){let g="";for(let m=0;m<this.files.length;m++){let h=this.files[m];C.Hot.Output="";h.page=this;g+=yield h.process(d)}return g})}addTestElement(d){if(null!=this.testElements[d.name])throw Error(`Test element ${d.name} already exists!`);this.testElements[d.name]=d}getTestElement(d){if(null==this.testElements[d])throw Error(`Test element ${d} doest not exist!`);
|
|
39
|
+
return this.testElements[d]}createTestPath(d,g){if(null!=this.testPaths[d])throw Error(`Test path ${d} already exists!`);this.testPaths[d]=g}}},761:(D,u,q)=>{Object.defineProperty(u,"__esModule",{value:!0});u.HotRoute=void 0;const p=q(70);class C{constructor(x,d,g=[]){this.onAuthorizeUser=this.onPostRegister=this.onRegister=this.onPreRegister=null;this.connection=x;this.logger=null;null!=this.connection&&null!=this.connection.processor&&(this.logger=this.connection.processor.logger);this.route=d;
|
|
40
|
+
this.description="";this.version="v1";this.prefix="";this.authCredentials=null;this.methods=g;this.errors={not_authorized:C.createError("Not authorized."),no_server_execute_function:C.createError("Missing server execute function.")}}static createError(x){return{error:x}}addMethod(x,d=null,g=p.HTTPMethod.POST,m=null){"string"==typeof x&&(x=new p.HotRouteMethod(this,x,d,g,null,null,null,m));x instanceof p.HotRouteMethod||(null==x.route&&(x.route=this),x=new p.HotRouteMethod(x));this.methods.push(x)}getMethod(x){let d=
|
|
41
|
+
null;for(let g=0;g<this.methods.length;g++){let m=this.methods[g];if(m.name===x){d=m;break}}return d}}u.HotRoute=C},70:(D,u,q)=>{Object.defineProperty(u,"__esModule",{value:!0});u.HotRouteMethod=u.HTTPMethod=void 0;const p=q(507),C=q(761),x=q(810);var d;!function(g){g.GET="get";g.POST="post";g.FILE_UPLOAD="file_upload_then_post_json"}(d=u.HTTPMethod||(u.HTTPMethod={}));u.HotRouteMethod=class{constructor(g,m="",h=null,c=d.POST,b=null,l=null,k=null,n=null){let r;if(g instanceof C.HotRoute)r=g;else{if(r=
|
|
42
|
+
g.route,null!=g.type&&(c=g.type),null!=g.name&&(m=g.name),null!=g.description&&(this.description=g.description),null!=g.returns&&("string"==typeof g.returns?this.returns={type:"string",required:!0,description:g.returns}:this.returns=g.returns),null!=g.parameters){this.parameters={};for(let t in g.parameters){let I=g.parameters[t];"string"==typeof I?this.parameters[t]={type:I,required:!1,description:""}:(null==I.type&&(I.type="string"),this.parameters[t]=I)}}null!=g.authCredentials&&(k=g.authCredentials);
|
|
43
|
+
null!=g.onServerExecute&&(h=g.onServerExecute);null!=g.onServerAuthorize&&(b=g.onServerAuthorize);null!=g.onRegister&&(l=g.onRegister);null!=g.onPostRegister&&(this.onPostRegister=g.onPostRegister);null!=g.onServerExecute&&(this.onServerExecute=g.onServerExecute);null!=g.onClientExecute&&(this.onClientExecute=g.onClientExecute);null!=g.testCases&&(n=g.testCases)}if(""===m)throw Error("All route methods must have a name!");if(this.route=r,this.name=m,this.type=c,this.isRegistered=!1,this.executeSetup=
|
|
44
|
+
!1,this.authCredentials=k,this.onServerAuthorize=b,this.onRegister=l,this.testCases={},this.route.connection.processor.mode===p.DeveloperMode.Development&&null!=n)if(n instanceof Array)for(g=0;g<n.length;g++)m=n[g],"string"==typeof m?(this.addTestCase(m,n[g+1]),g++):this.addTestCase(m);else for(let t in n)this.addTestCase(n[t]);this.route.connection instanceof x.HotServer&&(this.onServerExecute=h)}addTestCase(g,m=null){if("string"==typeof g)return void(this.testCases[g]={name:g,func:m});if("function"==
|
|
45
|
+
typeof g)return m=Object.keys(this.testCases).length,m=`${this.route.route}/${this.name} test case ${m}`,void(this.testCases[m]={name:m,func:g});this.testCases[g.name]=g}}},810:function(D,u,q){var p=this&&this.__awaiter||function(d,g,m,h){return new (m||(m=Promise))(function(c,b){function l(r){try{n(h.next(r))}catch(t){b(t)}}function k(r){try{n(h.throw(r))}catch(t){b(t)}}function n(r){var t;r.done?c(r.value):(t=r.value,t instanceof m?t:new m(function(I){I(t)})).then(l,k)}n((h=h.apply(d,g||[])).next())})};
|
|
46
|
+
Object.defineProperty(u,"__esModule",{value:!0});u.HotServer=u.HotServerType=void 0;const C=q(243);var x;!function(d){d[d.HTTP=0]="HTTP";d[d.WebSockets=1]="WebSockets";d[d.Generate=2]="Generate"}(x=u.HotServerType||(u.HotServerType={}));u.HotServer=class{constructor(d){d instanceof C.HotStaq?(this.processor=d,this.serverType="Server",this.api=null,this.listenAddress="0.0.0.0",this.ports={http:80,https:443},this.ssl={cert:"",key:"",ca:""},this.redirectHTTPtoHTTPS=!0,this.type=x.HTTP,this.logger=d.logger,
|
|
47
|
+
this.secrets={}):(this.processor=d.processor,this.serverType=d.serverType||"Server",this.api=d.api||null,this.listenAddress=d.listenAddress||"0.0.0.0",this.ports=d.ports||{http:80,https:443},this.ssl=d.ssl||{cert:"",key:"",ca:""},this.redirectHTTPtoHTTPS=null==d.redirectHTTPtoHTTPS||d.redirectHTTPtoHTTPS,this.type=d.type||x.HTTP,this.logger=d.logger,this.secrets=d.secrets||{})}setAPI(d){return p(this,void 0,void 0,function*(){this.api=this.processor.api=d})}}},243:function(D,u,q){var p=this&&this.__createBinding||
|
|
48
|
+
(Object.create?function(a,f,e,w){void 0===w&&(w=e);Object.defineProperty(a,w,{enumerable:!0,get:function(){return f[e]}})}:function(a,f,e,w){void 0===w&&(w=e);a[w]=f[e]}),C=this&&this.__setModuleDefault||(Object.create?function(a,f){Object.defineProperty(a,"default",{enumerable:!0,value:f})}:function(a,f){a.default=f});D=this&&this.__importStar||function(a){if(a&&a.__esModule)return a;var f={};if(null!=a)for(var e in a)"default"!==e&&Object.prototype.hasOwnProperty.call(a,e)&&p(f,a,e);return C(f,
|
|
49
|
+
a),f};var x=this&&this.__awaiter||function(a,f,e,w){return new (e||(e=Promise))(function(v,F){function A(G){try{K(w.next(G))}catch(B){F(B)}}function J(G){try{K(w.throw(G))}catch(B){F(B)}}function K(G){var B;G.done?v(G.value):(B=G.value,B instanceof e?B:new e(function(L){L(B)})).then(A,J)}K((w=w.apply(a,f||[])).next())})},d=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(u,"__esModule",{value:!0});u.HotStaq=void 0;const g=D(q(351)),m=D(q(606)),h=
|
|
50
|
+
d(q(300)),c=d(q(651)),b=q(136),l=q(732),k=q(260),n=q(802),r=q(507),t=q(957),I=q(414),y=q(985);var z=null,E=null,M=null;class H{constructor(a={}){this.api=a.api||null;this.testerAPI=a.testerAPI||null;this.mode=a.mode||r.DeveloperMode.Production;this.pages=a.pages||{};this.components=a.components||{};this.files=a.files||{};this.hotSite=a.hotSite||null;this.apiContent="\n\t\t\t{\n\t\t\t\tvar %api_name% = %api_exported_name%.%api_name%;\n\t\t\t\tvar newHotClient = new HotClient (processor);\n\t\t\t\tvar newapi = new %api_name% (%base_url%, newHotClient);\n\t\t\t\tnewHotClient.api = newapi;\n\t\t\t\tprocessor.api = newapi;\n\t\t\t}";
|
|
51
|
+
this.testerApiContent="\n\t\t\tvar HotTesterAPI = HotStaqWeb.HotTesterAPI;\n\t\t\tvar newHotTesterClient = new HotClient (processor);\n\t\t\tvar newtesterapi = new HotTesterAPI (%base_tester_url%, newHotTesterClient);\n\t\t\tnewHotTesterClient.testerAPI = newtesterapi;\n\t\t\tprocessor.testerAPI = newtesterapi;";this.pageContent='<!DOCTYPE html>\n<html>\n\n<head>\n\t<title>%title%</title>\n\n\t<script type = "text/javascript" src = "%hotstaq_js_src%">\x3c/script>\n\t<script type = "text/javascript">\n\t\twindow.HotStaq = HotStaqWeb.HotStaq;\n\t\twindow.HotClient = HotStaqWeb.HotClient;\n\t\twindow.HotAPI = HotStaqWeb.HotAPI;\n\t\twindow.Hot = HotStaqWeb.Hot;\n\t\x3c/script>\n\n%apis_to_load%\n\n\t<script type = "text/javascript">\n\t\tfunction hotstaq_startApp ()\n\t\t{\n\t\t\tlet tempMode = 0;\n\n\t\t\tif (window["Hot"] != null)\n\t\t\t\ttempMode = Hot.Mode;\n\n\t\t\t%load_hot_site%\n\n\t\t\tvar processor = new HotStaq ();\n\t\t\tvar promises = [];\n\t\t\t%developer_mode%\n\n\t\t\t%api_code%\n\n\t\t\t%public_secrets%\n\t\t\t%tester_api%\n\t\t\t%load_files%\n\n\t\t\tprocessor.mode = tempMode;\n\n\t\t\tPromise.all (promises).then (function ()\n\t\t\t\t{\n\t\t\t\t\tHotStaq.displayUrl ({\n\t\t\t\t\t\t\turl: "%url%",\n\t\t\t\t\t\t\tname: "%title%",\n\t\t\t\t\t\t\tprocessor: processor,\n\t\t\t\t\t\t\targs: %args%,\n\t\t\t\t\t\t\ttesterName: %tester_name%,\n\t\t\t\t\t\t\ttesterMap: %tester_map%,\n\t\t\t\t\t\t\ttesterAPIBaseUrl: %tester_api_base_url%,\n\t\t\t\t\t\t\ttesterLaunchpadUrl: %tester_launchpad_url%\n\t\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\thotstaq_startApp ();\n\t\x3c/script>\n</head>\n\n<body>\n</body>\n\n</html>';
|
|
52
|
+
this.logger=new n.HotLog(n.HotLogLevel.None);this.publicKeys={};this.testers={}}static parseBoolean(a){if("true"===(a=a.toLowerCase()))return!0;if("false"===a)return!1;if("yes"===a)return!0;if("no"===a)return!1;if("yep"===a)return!0;if("nah"===a)return!1;try{if(0!=parseInt(a))return!0}catch(f){}return!1}static getParam(a,f,e=!0,w=!0){f=f[a];if(null==f&&!0===e&&!0===w)throw Error(`Missing required parameter ${a}.`);if("string"==typeof f&&!0===e&&""===f&&!0===w)throw Error(`Missing required parameter ${a}.`);
|
|
53
|
+
return f}static getParamDefault(a,f,e){a=f[a];return null==a||"string"==typeof a&&""===a?e:a}static executeError(a){if(null!=H.errors[a]){var f=H.errors[a].redirectToUrl;if(null!=f&&""!==f)return void(window.location.href=f);f=H.errors[a].func;null!=f&&f(a)}}static wait(a){return x(this,void 0,void 0,function*(){return yield new Promise((f,e)=>{setTimeout(()=>{f()},a)})})}addPage(a){this.pages[a.name]=a}getPage(a){return this.pages[a]}addFile(a){let f=a.name;""===f&&(f=a.localFile);""===f&&(f=a.url);
|
|
54
|
+
this.files[f]=a}getFile(a){if(null==this.files[a])throw Error(`Unable to find file ${a}`);return this.files[a]}static keepContext(a,f,e){return function(){var w=Array.prototype.slice.call(arguments);return null!=e&&w.push(e),null==f?a.apply(this,w):a.apply(f,w)}}addComponent(a,f=null,e){let w=this.api;null!=f&&(w=f);f=new a(this,w);if(null!=this.components[f.tag])throw Error(`Component ${f.tag} already exists!`);this.components[f.tag]={componentType:a,processor:this,api:w};this.registerComponent(f.tag,
|
|
55
|
+
e)}static fixHTML(a){var f=a.replace(/ \/>/g,">").replace(/(<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr).*?>)/g,"$1</$2>"),e=(new DOMParser).parseFromString(`<xml>${f}</xml>`,"text/xml");f="";0<e.documentElement.children.length&&(e=e.documentElement.children[0].tagName.toLowerCase(),"tr"===e&&(a=`<table>${a}</table>`,f="tbody"),"th"===e&&(a=`<table>${a}</table>`,f=e));return{fixedStr:a,querySelector:f}}registerComponent(a,f){if(null==a||""===a)throw Error("All components must have a tag!");
|
|
56
|
+
if(void 0===customElements.get(a)){var e=this.components;customElements.define(a,class extends HTMLElement{constructor(){super();let w=e[a];this.component=new w.componentType(w.processor,w.api)}looseParseFromString(w,v){v=v.replace(/ \/>/g,">").replace(/(<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr).*?>)/g,"$1</$2>");v=w.parseFromString("<xml>"+v+"</xml>","text/xml");w=w.parseFromString("","text/html");for(let F of Array.from(v.documentElement.children))w.body.appendChild(F);
|
|
57
|
+
for(let F of Array.from(w.querySelectorAll("area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr")))F.outerHTML="<"+F.outerHTML.slice(1).split("<")[0];return w}get observedAttributes(){return this.component.observedAttributes}connectedCallback(){return x(this,void 0,void 0,function*(){if(this.hotComponent=this.component,this.component.htmlElements=[this],this.component.inner=this.innerHTML,null!=this.component.handleAttributes)yield this.component.handleAttributes(this.attributes);
|
|
58
|
+
else for(var w=0;w<this.attributes.length;w++){var v=this.attributes[w],F=v.name.toLowerCase();v=v.value;if("id"===F&&(this.component.name=v),"name"===F&&(this.component.name=v),"value"===F&&(this.component.value=v),-1<F.indexOf("hot-"))F=F.substring(4),this.component[F]=v}if(null==this.component.onPreOutput||!1!==(yield this.component.onPreOutput()))for(F=yield this.component.output(),null!=this.component.onPostOutput&&(F=yield this.component.onPostOutput(F)),w=[],"string"==typeof F?w.push({html:F}):
|
|
59
|
+
w=F instanceof Array?F:[F],F=0;F<w.length;F++){v=w[F];var A=v.html,J="";null!=v.addFunctionsTo&&(J=v.addFunctionsTo);A=l.HotFile.parseContent(A,!0,{outputCommands:!1});null!=this.component.onParsed&&(A=yield this.component.onParsed(A));A=null!=this.component.onFixHTML?yield this.component.onFixHTML(A):H.fixHTML(A);var K=null;if(K=null!=this.component.onParseDOM?yield this.component.onParseDOM(A.fixedStr):(new DOMParser).parseFromString(A.fixedStr,"text/html"),1>K.body.children.length)throw Error(`No component output from ${this.component.name}`);
|
|
60
|
+
if(1<K.body.children.length){var G=!0;for(var B=0;B<K.body.children.length;B++){var L=K.body.children[B];if(L instanceof HTMLElement&&"parsererror"===L.tagName.toLowerCase()){G=!1;break}}if(!0===G)throw Error(`Only a single html element can come from component ${this.component.name}, multiple elements were detected.`);}K=""===A.querySelector?K.body.children[0]:K.querySelector(A.querySelector);A=[];for(G=this.children.length-1;-1<G;G--)A.push(this.removeChild(this.children[G]));this.replaceWith(K);
|
|
61
|
+
null!=this.component.click&&(K.onclick=this.component.click.bind(this.component));for(let O in this.component.events)G=this.component.events[O],K.addEventListener(G.type,G.func,G.options);G=Object.getOwnPropertyNames(this.component.constructor.prototype);for(B=0;B<G.length;B++)if(L=G[B],"constructor"!==L&&"function"==typeof this.component[L]){let O=!0;for(let N in k.HotComponent.prototype)if(L===N){O=!1;break}!0===O&&(K[L]=H.keepContext(this.component[L],this.component),""!==J)&&(document.querySelector(J)[L]=
|
|
62
|
+
H.keepContext(this.component[L],this.component))}null!=this.component.onPrePlace&&(K=yield this.component.onPrePlace(K));J=yield this.component.onCreated(K);if(null!=this.component.onParentPlace&&(J.onParentPlace=this.component.onParentPlace),J.hotComponent=this.component,this.component.htmlElements.push(J),null!=v.parentSelector)K=document.querySelector(v.parentSelector),J.parentElement.removeChild(J),K.appendChild(J),null!=J.onParentPlace&&(yield J.hotComponent.onParentPlace(K,J));if(null!=v.placeHereParent)for(K=
|
|
63
|
+
J.parentNode,G=0;10>G&&null!=K&&!(K instanceof HTMLHtmlElement);){B=K.querySelectorAll(`hot-place-here[name="${v.placeHereParent}"]`);if(0<B.length){v=B[0];J.parentNode.removeChild(J);v.appendChild(J);null!=J.onParentPlace&&(yield J.hotComponent.onParentPlace(v,J));break}if(1>B.length&&(B=K.querySelectorAll(`[hot-place-here="${v.placeHereParent}"]`),0<B.length)){v=B[0];J.parentNode.removeChild(J);v.appendChild(J);null!=J.onParentPlace&&(yield J.hotComponent.onParentPlace(v,J));break}K=K.parentNode;
|
|
64
|
+
G++}for(v=0;v<A.length;v++)K=A[v],J.appendChild(K),null!=K.onParentPlace&&(yield K.hotComponent.onParentPlace(J,K));null!=this.component.onPostPlace&&(yield this.component.onPostPlace(J.parentNode,J))}})}},f)}}static addHtml(a,f){let e=null;if(e="string"==typeof a?document.querySelector(a):a,null==e)throw Error(`Unable to find parent ${a}!`);a=null;if("string"==typeof f){f=H.fixHTML(f);a=(new DOMParser).parseFromString(f.fixedStr,"text/html");f=""===f.querySelector?a.body.children:a.querySelector(f.querySelector).children;
|
|
65
|
+
a=[];for(let w=0;w<f.length;w++)a.push(e.appendChild(f[w]));return a}return a=e.appendChild(f),a}static checkHotSiteName(a,f=!1){let e=(0,c.default)(a);if(null!=e.errors&&0<e.errors.length&&!0===f)throw Error(`HotSite ${a} has an invalid name! The name cannot be empty and must have a valid NPM module name.`);return!0}static replaceKey(a,f,e){return a.replace(new RegExp(`\\$\\{${f}\\}`,"g"),e)}static getValueFromHotSiteObj(a,f){let e=null;if(null!=a){for(let w=0;w<f.length;w++){let v=f[w];if(null==
|
|
66
|
+
a[v]){a=null;break}a=a[v]}null!=a&&(e=a)}return e}processHotSite(){return x(this,void 0,void 0,function*(){H.checkHotSiteName(this.hotSite.name,!0);var a=this.hotSite.routes;let f="http://127.0.0.1:8182",e=null,w=null;if(!1===H.isWeb&&this.mode===r.DeveloperMode.Development&&null!=this.hotSite.testing){var v=B=>{let L=!0;null!=B.createNewTester&&(L=B.createNewTester);let O="Tester";if(null!=B.tester&&(O=B.tester),null!=B.testerName&&(O=B.testerName),!0===L?(z=Object(function(){var N=Error("Cannot find module './HotTesterMocha'");
|
|
67
|
+
throw N.code="MODULE_NOT_FOUND",N;}()),E=Object(function(){var N=Error("Cannot find module './HotTesterMochaSelenium'");throw N.code="MODULE_NOT_FOUND",N;}()),M=Object(function(){var N=Error("Cannot find module './HotTestSeleniumDriver'");throw N.code="MODULE_NOT_FOUND",N;}()),""===B.testerAPIUrl&&(f=B.testerAPIUrl),"HotTestSeleniumDriver"===B.driver&&(w=new M),"HotTesterMocha"===B.tester&&(e=new z(this,O,f,w)),"HotTesterMochaSelenium"===B.tester&&(e=new E(this,O,f))):e=this.testers[O],null==e.driver)throw Error(`Tester ${O} does not have a driver set!`);
|
|
68
|
+
null!=B.commandDelay&&(e.driver.commandDelay=B.commandDelay)};null!=this.hotSite.testing.web&&v(this.hotSite.testing.web);null!=this.hotSite.testing.api&&v(this.hotSite.testing.api)}if(null!=a)for(var F in a){v=a[F];var A=new l.HotFile(v);A=new b.HotPage({processor:this,name:v.name||"",route:F,files:[A]});if(null!=e&&this.mode===r.DeveloperMode.Development){let B=v.name,L=null;if(null!=v.map){if("string"==typeof v.map){if(null==e.testMaps[v.map])throw Error(`Test map ${v.map} does not exist!`);e.testMaps[B]=
|
|
69
|
+
e.testMaps[v.map]}else{L=new y.HotTestMap;let O=null;if(v.map instanceof Array){O=[];for(let N=0;N<v.map.length;N++)O.push(new y.HotTestDestination(v.map[N]))}else{O={};for(var J in v.map)O[J]=new y.HotTestDestination(v.map[J])}L.destinations=O}e.testMaps[B]=L}null!=v.destinationOrder&&(e.testMaps[B].destinationOrder=v.destinationOrder)}this.addPage(A)}if(null!=this.hotSite.apis)for(var K in this.hotSite.apis)if(a=this.hotSite.apis[K],null!=a.map&&!1===H.isWeb&&this.mode===r.DeveloperMode.Development){F=
|
|
70
|
+
K;J=new y.HotTestMap;J.destinations=[];for(v=0;v<a.map.length;v++)J.destinations.push(new y.HotTestDestination(a.map[v]));if(null==e)throw Error("A tester was not created first! You must specify one in the CLI or in HotSite.json.");e.testMaps[F]=J}if(!0===H.isWeb)for(var G in this.hotSite.components)K=yield(0,h.default)(this.hotSite.components[G].url),K=eval(K),this.addComponent(K);null==this.hotSite.routes&&(this.hotSite.routes={});G=!1;null!=this.hotSite.disableFileLoading&&(G=this.hotSite.disableFileLoading);
|
|
71
|
+
!1===G?yield this.loadHotFiles(this.hotSite.files):this.logger.verbose("Hotsite has file loading disabled...");null!=e&&this.addTester(e)})}loadHotSite(a){return x(this,void 0,void 0,function*(){var f="";!0===H.isWeb?(this.logger.info(`Downloading HotSite ${a}`),f=yield(0,h.default)(a),this.logger.info(`Downloaded site ${a}`),f=f.text()):(a=m.normalize(a),this.logger.info(`Accessing HotSite ${a}`),f=yield new Promise((e,w)=>{g.readFile(a,(v,F)=>{if(null!=v)throw v;v=F.toString();this.logger.info(`Accessed site ${a}`);
|
|
72
|
+
e(v)})}));this.hotSite=JSON.parse(f);this.hotSite.hotsitePath=a})}loadHotFiles(a,f=!1){return x(this,void 0,void 0,function*(){this.logger.verbose("Loading Hott files...");for(let w in a){var e=a[w];let v;H.isWeb;v=new l.HotFile({name:w});null!=e.url&&(v.url=e.url);!1===H.isWeb&&null!=e.localFile&&(v.localFile=e.localFile);let F=!0;if(null!=e.content&&(v.content=e.content,F=!1),!0===f&&(F=!0),!0===F)e="",""!==v.url&&(e=v.url),""!==v.localFile&&(e=v.localFile),this.logger.verbose(`Loading Hott file: ${e}`),
|
|
73
|
+
yield v.load(),this.logger.verbose(`Finished loading Hott file: ${e}`);this.addFile(v)}this.logger.verbose("Finished loading Hott files...")})}generateContent(a,f="",e="./",w="./js/HotStaq.min.js",v=!0,F=null){let A="",J="",K="";if(null!=this.hotSite){if(null!=this.hotSite.server.globalApi&&""!==this.hotSite.server.globalApi){var G=this.hotSite.apis[this.hotSite.server.globalApi];if(null==G)this.logger.warning(`API with name ${this.hotSite.server.globalApi} doesn't exist!`);else{var B=!0;if(null==
|
|
74
|
+
G.jsapi&&(B=!1,this.logger.warning(`API with name ${this.hotSite.server.globalApi} doesn't have a jsapi set. Will not send js content to client.`)),null==G.libraryName&&(B=!1,this.logger.warning(`API with name ${this.hotSite.server.globalApi} doesn't have a libraryName set. Will not send js content to client.`)),null==G.apiName&&(B=!1,this.logger.warning(`API with name ${this.hotSite.server.globalApi} doesn't have a apiName set. Will not send js content to client.`)),!0===B){A+=`\t<script type = "text/javascript" src = "${G.jsapi}"><\/script>\n`;
|
|
75
|
+
B='""';null!=G.url&&(B=`"${G.url}"`);null!=this.api&&(B=`"${this.api.baseUrl}"`);var L=this.apiContent;L=L.replace(/%api_name%/g,G.apiName);L=L.replace(/%api_exported_name%/g,G.libraryName);L=L.replace(/%base_url%/g,B);J+=L}}}if(null!=this.hotSite.apis&&(B=this.hotSite.routes[a],null!=B&&null!=B.api)){G=this.hotSite.apis[B.api];if(null==G)throw Error(`Unable to find API ${B.api}`);L=!0;if(null==G.jsapi&&(L=!1,this.logger.warning(`API with name ${B.api} doesn't have a jsapi set. Will not send js content to client.`)),
|
|
76
|
+
null==G.libraryName&&(L=!1,this.logger.warning(`API with name ${B.api} doesn't have a libraryName set. Will not send js content to client.`)),null==G.apiName&&(L=!1,this.logger.warning(`API with name ${B.api} doesn't have a apiName set. Will not send js content to client.`)),!0===L)A+=`\t<script type = "text/javascript" src = "${G.jsapi}"><\/script>\n`,B='""',null!=G.url&&(B=`"${G.url}"`),null!=this.api&&(B=`"${this.api.baseUrl}"`),L=this.apiContent,L=L.replace(/%api_name%/g,G.apiName),L=L.replace(/%api_exported_name%/g,
|
|
77
|
+
G.libraryName),L=L.replace(/%base_url%/g,B),J+=L}if(null!=this.hotSite.server&&null!=this.hotSite.server.jsSrcPath&&(w=this.hotSite.server.jsSrcPath),null!=this.hotSite.publicKeys)for(var O in this.hotSite.publicKeys){let N;G=this.hotSite.publicKeys[O];if("string"==typeof G)N=JSON.stringify(G);else if(!1===H.isWeb){if(null!=this.api){if(null==this.api.connection)throw Error("Cannot pass secrets from the API if there's no connection!");B=this.api.connection;null!=G.passSecretFromAPI&&(N=JSON.stringify(B.secrets[O]))}null!=
|
|
78
|
+
G.env&&(N=JSON.stringify(process.env[G.env]))}K+=`processor.publicKeys["${O}"] = ${N};\n`}}O=this.pageContent;return O=(N=>{let Y="",X="";this.mode===r.DeveloperMode.Development&&(Y="tempMode = HotStaqWeb.DeveloperMode.Development;",null!=this.hotSite&&null!=this.hotSite.testing&&null!=this.hotSite.testing.web&&(X=this.testerApiContent,null==this.hotSite.testing.web.testerAPIUrl&&(this.hotSite.testing.web.testerAPIUrl="http://127.0.0.1:8182"),X=X.replace(/%base_tester_url%/g,`"${this.hotSite.testing.web.testerAPIUrl}"`)));
|
|
79
|
+
let S="";if(0<Object.keys(this.files).length){S+="var files = {};\n\n";for(var T in this.files){var Q=this.files[T],P=`"${Q.url}"`,R="";""!==Q.content&&(Q=JSON.stringify(Q.content),Q=Q.replace(RegExp("\\<script","gmi"),'<scr" + "ipt'),Q=Q.replace(RegExp("\\<\\/script","gmi"),'</scr" + "ipt'),R=`, "content": ${Q}`);S+=`\t\t\tfiles["${T}"] = { "url": ${P}${R} };\n`}S+="\t\t\tpromises.push (processor.loadHotFiles (files));\n"}N=N.replace(/%title%/g,f);!0===v&&(N=N.replace(/%args%/g,"Hot.Arguments"));
|
|
80
|
+
null!=F&&(N=N.replace(/%args%/g,JSON.stringify(F)));T=a;Q=P="";R="Tester";return null!=this.hotSite&&(null!=this.hotSite.testing&&null!=this.hotSite.testing.web&&(null!=this.hotSite.testing.web.tester&&(R=this.hotSite.testing.web.tester),null!=this.hotSite.testing.web.testerName&&(R=this.hotSite.testing.web.testerName),null!=this.hotSite.testing.web.testerAPIUrl&&(P=this.hotSite.testing.web.testerAPIUrl),null!=this.hotSite.testing.web.launchpadUrl&&(Q=this.hotSite.testing.web.launchpadUrl)),null!=
|
|
81
|
+
this.hotSite.routes&&null!=this.hotSite.routes[a])&&(T=this.hotSite.routes[a].name),N.replace(/%hotstaq_js_src%/g,w).replace(/%developer_mode%/g,Y).replace(/%tester_api%/g,X).replace(/%apis_to_load%/g,A).replace(/%load_hot_site%/g,"").replace(/%load_files%/g,S).replace(/%api_code%/g,J).replace(/%public_secrets%/g,K).replace(/%url%/g,e).replace(/%tester_name%/g,`"${R}"`).replace(/%tester_map%/g,`"${T}"`).replace(/%tester_api_base_url%/g,`"${P}"`).replace(/%tester_launchpad_url%/g,`"${Q}"`)})(O),O}createExpressRoutes(a,
|
|
82
|
+
f="./js/HotStaq.min.js"){for(let e in this.pages){let w=this.pages[e];const v=this.generateContent(w.route,w.name,w.files[0].url,f);a.get(w.route,(F,A)=>{A.send(v)})}}addTester(a){this.testers[a.name]=a}getWebTestingMaps(){if(null==this.hotSite)throw Error("No HotSite was loaded!");if(null==this.hotSite.testing)throw Error("The HotSite does not have a testing object!");if(null==this.hotSite.testing.web)throw Error("The HotSite does not have a testing web object!");if(null==this.hotSite.testing.web.maps)throw Error("The HotSite testing object does not have any maps!");
|
|
83
|
+
return this.hotSite.testing.web.maps}getAPITestingMaps(){if(null==this.hotSite)throw Error("No HotSite was loaded!");if(null==this.hotSite.testing)throw Error("The HotSite does not have a testing object!");if(null==this.hotSite.testing.api)throw Error("The HotSite does not have a testing api object!");if(null==this.hotSite.testing.api.maps)throw Error("The HotSite testing object does not have any maps!");return this.hotSite.testing.api.maps}getRouteKeyFromName(a){let f="";if(null!=this.hotSite&&null!=
|
|
84
|
+
this.hotSite.routes)for(let e in this.hotSite.routes)if(this.hotSite.routes[e].name===a){f=e;break}return f}getRouteFromName(a){let f=null;a=this.getRouteKeyFromName(a);return""!==a&&(f=this.hotSite.routes[a]),f}executeTests(a,f){return x(this,void 0,void 0,function*(){let e=this.testers[a];if(null==e)throw Error(`Unable to execute tests. Tester ${a} does not exist!`);return e.execute(f)})}executeAllWebTests(a){return x(this,void 0,void 0,function*(){let f=this.getWebTestingMaps();if(null==this.testers[a])throw Error(`Unable to execute tests. Tester ${a} does not exist!`);
|
|
85
|
+
for(let e=0;e<f.length;e++)yield this.executeTests(a,f[e])})}executeAllAPITests(a){return x(this,void 0,void 0,function*(){let f=this.getAPITestingMaps();if(null==this.testers[a])throw Error(`Unable to execute tests. Tester ${a} does not exist!`);for(let e=0;e<f.length;e++)yield this.executeTests(a,f[e])})}process(a,f=null){return x(this,void 0,void 0,function*(){return yield this.getPage(a).process(f)})}static processLocalFile(a,f=a,e=null){return x(this,void 0,void 0,function*(){let w=new H;var v=
|
|
86
|
+
new l.HotFile({localFile:a});yield v.load();v=new b.HotPage({processor:w,name:f,files:[v]});return w.addPage(v),yield w.process(f,e)})}static processUrl(a){return x(this,void 0,void 0,function*(){var f=new l.HotFile({url:a.url});yield f.load();f=new b.HotPage({processor:a.processor,name:a.name,files:[f],testerName:a.testerName,testerMap:a.testerMap});return a.processor.addPage(f),yield a.processor.process(a.name,a.args)})}static processContent(a){return x(this,void 0,void 0,function*(){var f=new l.HotFile({content:a.content});
|
|
87
|
+
yield f.load();f=new b.HotPage({processor:a.processor,name:a.name,files:[f]});return a.processor.addPage(f),yield a.processor.process(a.name,a.args)})}static onReady(a){"complete"===document.readyState||"interactive"===document.readyState?a():window.addEventListener("load",a)}static useOutput(a){return x(this,void 0,void 0,function*(){var f=(new DOMParser).parseFromString(a,"text/html");document.getElementsByTagName("html")[0].innerHTML=f.getElementsByTagName("html")[0].innerHTML;f=document.getElementsByTagName("script");
|
|
88
|
+
if(0<f.length){let e=[];for(let w=0;w<f.length;w++)e.push(f[w]);for(let w=0;w<e.length;w++){let v=document.createElement("script");e[w].parentNode.appendChild(v);e[w].parentNode.removeChild(e[w]);yield new Promise((F,A)=>{v.onload=()=>{F()};A=!1;null!=e[w].getAttribute("src")&&""!==e[w].getAttribute("src")&&(v.setAttribute("src",e[w].getAttribute("src")),A=!0);null!=e[w].getAttribute("type")&&""!==e[w].getAttribute("type")&&v.setAttribute("type",e[w].getAttribute("type"));v.innerHTML=e[w].innerHTML;
|
|
89
|
+
!1===A&&F()})}}})}static waitForTesters(){return x(this,void 0,void 0,function*(){for(;!1===H.isReadyForTesting;)yield H.wait(10);null!=H.onReadyForTesting&&(yield H.onReadyForTesting())})}static setupTesters(a,f){if(a.mode===r.DeveloperMode.Development&&null==a.testerAPI){null==f.testerAPIBaseUrl&&(f.testerAPIBaseUrl="");""===f.testerAPIBaseUrl&&(f.testerAPIBaseUrl="http://127.0.0.1:8182");let e=new t.HotClient(a);f=new I.HotTesterAPI(f.testerAPIBaseUrl,e);f.connection.api=f;a.testerAPI=f}}static setupClientTesters(a){let f=
|
|
90
|
+
"";return a.mode===r.DeveloperMode.Development&&(f+='<script type = "text/javascript">\nfunction hotstaq_isDocumentReady ()\n{\nif (window["Hot"] != null)\n{\nif (Hot.Mode === HotStaqWeb.DeveloperMode.Development)\n{\nlet func = function ()\n\t{\n\t\tif (Hot.TesterAPI != null)\n\t\t{\n\t\t\tlet testPaths = {};\n\t\t\tlet testElements = JSON.stringify (Hot.CurrentPage.testElements);\n\t\t\tlet testMaps = JSON.stringify (Hot.CurrentPage.testMaps);\n\n\t\t\tfor (let key in Hot.CurrentPage.testPaths)\n\t\t\t{\n\t\t\t\tlet testPath = Hot.CurrentPage.testPaths[key];\n\n\t\t\t\ttestPaths[key] = testPath.toString ();\n\t\t\t}\n\n\t\t\tlet testPathsStr = JSON.stringify (testPaths);\n\n\t\t\tHot.TesterAPI.tester.pageLoaded ({\n\t\t\t\t\ttesterName: Hot.CurrentPage.testerName,\n\t\t\t\t\ttesterMap: Hot.CurrentPage.testerMap,\n\t\t\t\t\tpageName: Hot.CurrentPage.name,\n\t\t\t\t\ttestElements: testElements,\n\t\t\t\t\ttestPaths: testPathsStr\n\t\t\t\t}).then (function (resp)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (resp.error != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (resp.error !== "")\n\t\t\t\t\t\t\t\tthrow new Error (resp.error);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tHotStaqWeb.HotStaq.isReadyForTesting = true;\n\t\t\t\t\t});\n\t\t}\n\t};\n\nif ((document.readyState === "complete") || (document.readyState === "interactive"))\n\tfunc ();\nelse\n\tdocument.addEventListener ("DOMContentLoaded", func);\n}\n}\n}\n\nhotstaq_isDocumentReady ();\n\x3c/script>'),
|
|
91
|
+
f}static displayUrl(a,f=null,e=null,w=null){return x(this,void 0,void 0,function*(){return new Promise((v,F)=>{H.onReady(()=>x(this,void 0,void 0,function*(){var A={url:""};A.name=null==f?"string"==typeof a?a:a.name:f;""===A.name&&(A.name="string"==typeof a?a:a.name);"string"==typeof a?A.url=a:(A.url=a.url,null==e&&null!=a.processor&&(e=a.processor),null==w&&null!=a.args&&(w=a.args),null!=a.testerMap&&(A.testerMap=a.testerMap),null!=a.testerName&&(A.testerName=a.testerName),null!=a.testerAPIBaseUrl&&
|
|
92
|
+
(A.testerAPIBaseUrl=a.testerAPIBaseUrl));null==e&&(e=new H);H.setupTesters(e,A);A.processor=e;A.args=w;0>A.url.indexOf("hstqserve")&&(A.url+="?hstqserve=nahfam");A=yield H.processUrl(A);A+=H.setupClientTesters(e);yield H.useOutput(A);v(e)}))})})}static displayContent(a,f=null,e=null,w=null){return x(this,void 0,void 0,function*(){return new Promise((v,F)=>{H.onReady(()=>x(this,void 0,void 0,function*(){var A={content:""};A.name=null==f?"string"==typeof a?"":a.name:f;""===A.name&&(A.name="string"==
|
|
93
|
+
typeof a?"":a.name);"string"==typeof a?A.content=a:(A.content=a.content,null==e&&null!=a.processor&&(e=a.processor),null==w&&null!=a.args&&(w=a.args),null!=a.testerMap&&(A.testerMap=a.testerMap),null!=a.testerName&&(A.testerName=a.testerName),null!=a.testerAPIBaseUrl&&(A.testerAPIBaseUrl=a.testerAPIBaseUrl));null==e&&(e=new H);H.setupTesters(e,A);A.processor=e;A.args=w;A=yield H.processContent(A);yield H.useOutput(A);v(e)}))})})}}if(u.HotStaq=H,H.version="0.6.21",H.isWeb=!1,H.isReadyForTesting=!1,
|
|
94
|
+
H.onReadyForTesting=null,H.errors={},"undefined"!=typeof document)window.ethereum22=window.ethereum,window.addEventListener("load",function(){let a=document.getElementsByTagName("hotstaq");if(H.isWeb=!0,void 0!==HotStaqWeb&&(window.HotStaq=HotStaqWeb.HotStaq,window.HotClient=HotStaqWeb.HotClient,window.HotAPI=HotStaqWeb.HotAPI,window.Hot=HotStaqWeb.Hot,window.HotComponent=HotStaqWeb.HotComponent),0<a.length){let f=a[0];setTimeout(function(){return x(this,void 0,void 0,function*(){var e=(Z,fa)=>{for(let ba=
|
|
95
|
+
0;ba<fa.length;ba++){let aa=fa[ba];if(null!=Z.getAttribute(aa))return Z.getAttribute(aa);if(null!=Z.getAttribute(`data-${aa}`))return Z.getAttribute(`data-${aa}`)}};let w=e(f,["load-page","loadPage","src"])||"";var v=e(f,["router"])||"",F=e(f,["name"])||"default";let A=e(f,["args"])||null;var J=e(f,["api-library","apiLibrary"])||null;let K=e(f,["api-name","apiName"])||null,G=e(f,["api-url","apiUrl"])||null;var B=e(f,["tester-name","testerName"])||"HotTesterMochaSelenium",L=e(f,["tester-map","testerMap"])||
|
|
96
|
+
null;let O=e(f,["tester-api-base-url","testerApiBaseUrl"])||null,N=e(f,["tester-launchpad-url","testerLaunchpadUrl"])||null,Y=!1,X=!1;var S=f.innerHTML||"",T={},Q=[];null!=e(f,["src"])&&(w=e(f,["src"]));null!=e(f,["passRawUrl"])&&(X=!0);null!=e(f,["dont-reuse-processor","dontReuseProcessor"])&&(Y=!0);var P=document.getElementsByTagName("hotstaq-error");for(var R=0;R<P.length;R++){var U=P[R],V=e(U,["status"]);U=e(U,["unsupported-browser-redirect"]);null!=U?H.errors.unsupportedBrowser={redirectToUrl:U}:
|
|
97
|
+
H.errors[`${V}`]={redirectToUrl:U}}try{eval("async () => {}")}catch(Z){H.executeError("unsupportedBrowser")}if(""!==v)for(V=document.getElementsByTagName("hotstaq-router"),U=0;U<V.length;U++){R=V[U];var ca=e(R,["name"]);P=e(R,["serve-local","serveLocally"]);if(ca===v){for(v=0;v<R.childNodes.length;v++){var W=R.childNodes[v];W instanceof HTMLElement&&"ROUTE"===W.tagName.toUpperCase()&&(V=e(W,["path"]),U=e(W,["redirect"]),ca=e(W,["base"]),W=e(W,["src"]),-1<V.indexOf("*")&&Q.push(V),T[V]={redirect:U||
|
|
98
|
+
void 0,base:ca||void 0,src:W||void 0})}e=window.location.pathname;null!=P&&(P=P.toLowerCase(),"true"===P||"yes"===P||"1"===P)&&(P=e.lastIndexOf("/"),-1<P&&(e=e.substring(P)));if(0<Q.length)for(P=0;P<Q.length;P++)if(R=Q[P],v=R.replace("*",""),-1<e.indexOf(v)){e=R;break}if(null!=T[e]){if(null!=T[e].redirect)return void(window.location.href=T[e].redirect);null!=T[e].src&&(w=T[e].src)}break}}A=null!=A?JSON.parse(A):r.Hot.Arguments;T=!1;""!==S&&""!==S.replace(/\s/g,"")&&(T=!0);Q=0;null!=window.Hot&&(Q=
|
|
99
|
+
r.Hot.Mode);S=null;!1===Y&&void 0!==r.Hot&&null!=r.Hot.CurrentPage&&null!=r.Hot.CurrentPage.processor&&(S=r.Hot.CurrentPage.processor);null==S&&(S=new H);S.mode=Q;F={name:F,processor:S,args:A};if(""!==w&&(!1===X&&0>w.indexOf("hstqserve")&&(w+="?hstqserve=nahfam"),F.url=w),null!=L&&(F.testerMap=L,F.testerName=B),null!=B&&(F.testerName=B),null!=O&&(F.testerAPIBaseUrl=O),null!=N&&(F.testerLaunchpadUrl=N),null!=K){B=new t.HotClient(S);if(""===G)throw Error("api-url was not set!");L=window;null!=J&&(L=
|
|
100
|
+
window[J]);J=new L[K](G,B);J.connection.api=J;S.api=J}if(!1===T){if(""===w)throw Error("The hotstaq tag must have a src, HTML contents inside it, or a router set.");H.displayUrl(F)}else H.displayContent(F)})},50)}})},628:function(D,u,q){var p=this&&this.__awaiter||function(d,g,m,h){return new (m||(m=Promise))(function(c,b){function l(r){try{n(h.next(r))}catch(t){b(t)}}function k(r){try{n(h.throw(r))}catch(t){b(t)}}function n(r){var t;r.done?c(r.value):(t=r.value,t instanceof m?t:new m(function(I){I(t)})).then(l,
|
|
101
|
+
k)}n((h=h.apply(d,g||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0});u.HotTestDriver=void 0;const C=q(243),x=q(967);u.HotTestDriver=class{constructor(d,g=null){this.processor=d;this.page=g;this.commandDelay=20;this.persistentData={}}parseTestObject(d){let g=d.indexOf("*");var m="";-1<g&&(d=d.replace(/\*/,""),m="*");m=`[data-test-object-name${m}='${d}']`;return g=d.indexOf(">"),-1<g&&(m=d.replace(/>/,"")),m}wait(d){return p(this,void 0,void 0,function*(){return yield new Promise((g,
|
|
102
|
+
m)=>{setTimeout(()=>{g()},d)})})}print(d){return p(this,void 0,void 0,function*(){process.stdout.write(d)})}println(d){return p(this,void 0,void 0,function*(){yield this.print(`${d}\n`)})}assert(d,g=""){return p(this,void 0,void 0,function*(){if(!d)throw Error(g);})}run(d){return p(this,void 0,void 0,function*(){let g=[];for(let h=0;h<d.length;h++){var m=d[h];let c=null,b="",l="";if("string"==typeof m){if(c=this.page.testElements[m],null==c)throw Error(`HotTestDriver: Unable to find test element ${m}`);
|
|
103
|
+
b=c.func;l=c.value}if(m instanceof Array){let k=m[0];c=this.page.testElements[k];null==c?(c=new x.HotTestElement(k),b=m[1],l=m[2]):(b=c.func,l=c.value,1<m.length&&(b=m[1]),2<m.length&&(l=m[2]))}c.func=b;c.value=l;m=yield this.runCommand(c);yield C.HotStaq.wait(this.commandDelay);g.push(m)}return g})}}},967:(D,u)=>{Object.defineProperty(u,"__esModule",{value:!0});u.HotTestElement=u.HotTestElementOptions=void 0;u.HotTestElementOptions=class{constructor(q={}){this.mustBeVisible=q.mustBeVisible||!0;this.ignoreMissingElementError=
|
|
104
|
+
q.ignoreMissingElementError||!1}};u.HotTestElement=class{constructor(q,p="",C=null){"string"==typeof q?(this.name=q,this.func=p,this.value=C):(this.name=q.name,this.func=q.func||p,this.value=q.value||C)}}},985:(D,u)=>{Object.defineProperty(u,"__esModule",{value:!0});u.HotTestMap=u.HotTestDestination=void 0;class q{constructor(p="",C=!0){"string"==typeof p?(this.destination=p,this.autoStart=C):p instanceof q?(this.destination=p.destination,this.autoStart=p.autoStart):(this.destination=p.path,this.autoStart=
|
|
105
|
+
p.autoStart)}}u.HotTestDestination=q;u.HotTestMap=class{constructor(p=[],C={},x=[]){if(p instanceof Array){this.destinations=[];for(var d=0;d<p.length;d++)this.destinations.push(new q(p[d]))}else for(d in this.destinations={},p)this.destinations[d]=new q(p[d]);this.destinationOrder=x;this.pages=C}}},677:function(D,u,q){var p=this&&this.__awaiter||function(d,g,m,h){return new (m||(m=Promise))(function(c,b){function l(r){try{n(h.next(r))}catch(t){b(t)}}function k(r){try{n(h.throw(r))}catch(t){b(t)}}
|
|
106
|
+
function n(r){var t;r.done?c(r.value):(t=r.value,t instanceof m?t:new m(function(I){I(t)})).then(l,k)}n((h=h.apply(d,g||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0});u.HotTester=void 0;const C=q(243);class x{constructor(d,g,m,h,c={}){this.processor=d;this.name=g;this.baseUrl=m;this.testMaps=c;this.driver=h;this.hasBeenDestroyed=this.hasBeenSetup=this.finishedLoading=!1}waitForData(){return p(this,void 0,void 0,function*(){for(;!1===this.finishedLoading;)yield C.HotStaq.wait(10)})}getTestPage(d){return this.testMaps[d.mapName].pages[d.page]}getTestPath(d,
|
|
107
|
+
g){return this.testMaps[d.mapName].pages[d.page].testPaths[g]}static interpretDestination(d,g){d={mapName:d,page:"",api:"",paths:[]};g=g.destination.split(/\->/g);var m=g[0];if(2>m.length||"/"===m[0]&&"/"===m[1])return null;let h=(c,b)=>{let l=c.indexOf(b),k="";return-1<l&&(k=c.substr(l+b.length),k=k.trim()),k};d.page=h(m,"page:");d.api=h(m,"api:");for(m=1;m<g.length;m++){let c=g[m],b={cmd:"",dest:"",path:""};c=c.trim();b.dest=h(c,"dest:");b.cmd=h(c,"cmd:");b.path=h(c,"path:");""==b.dest&&""==b.cmd&&
|
|
108
|
+
""==b.path&&(b.path=c);d.paths.push(b)}return d}executeTestAPIPath(d,g,m,h=!1,c=!1){return p(this,void 0,void 0,function*(){var b=!0;if(null==g)throw Error(`Trying to access null method on destination map ${d.mapName}.`);!1===h&&null!=this.onTestAPIPathStart&&(b=yield this.onTestAPIPathStart(d,g,m,c));let l=null;if(!0===b){b=g.testCases[m];if(null==b)throw Error(`HotTester: Test case object ${m} does not exist!`);l=yield b.func(this.driver)}return!1===h&&null!=this.onTestAPIPathEnd&&(yield this.onTestAPIPathEnd(d,
|
|
109
|
+
g,m,l,c)),l})}executeTestAPIPaths(d){return p(this,void 0,void 0,function*(){let g=[];if(null==this.testMaps[d.mapName])throw Error(`HotTester: Map ${d.mapName} does not exist!`);if(null==this.processor.api)throw Error("HotTester: Associated processor does not have an API!");let m=this.processor.api.routes[d.api];if(null==m)throw Error(`HotTester: API does not have route ${d.api}!`);for(let c=0;c<d.paths.length;c+=2){var h=d.paths[c].path;let b=m.getMethod(h),l=d.paths[c+1].path;if(null==b)throw Error(`Unable to find method related to path ${h} in map ${d.mapName}`);
|
|
110
|
+
h=yield this.executeTestAPIPath(d,b,l);g.push(h)}return g})}executeTestPagePath(d,g,m=!1,h=!1){return p(this,void 0,void 0,function*(){let c=!0;var b=this.testMaps[d.mapName];if(null==b)throw Error(`HotTester: Map ${d.mapName} does not exist!`);var l=b.pages[d.page];if(null==l)throw Error(`HotTester: Page ${d.page} does not exist!`);this.driver.page=l;b=g.path;let k=l.testPaths[b];!1===m&&null!=this.onTestPagePathStart&&(c=yield this.onTestPagePathStart(d,l,g,h));l=null;if(!0===c){if(null==k)throw Error(`HotTester: Test path ${b} does not have a function!`);
|
|
111
|
+
l=yield k(this.driver)}return!1===m&&null!=this.onTestPagePathEnd&&(yield this.onTestPagePathEnd(d,k,l,h)),l})}executeCommand(d,g,m,h){return p(this,void 0,void 0,function*(){let c=(n,r,t)=>{n=!1;m.cmd===r&&(n=!0);t=m.cmd.indexOf("(");return-1<t&&m.cmd.substr(0,t)===r&&(n=!0),n},b=n=>{let r=[];var t=n.match(/(?=\()(.*?)(?=\))/g);null!=t&&(t=t[0],t=t.substr(2,t.length),r.push(t));if(1>r.length)throw Error(`HotTester: Command ${n} requires arguments, but none were supplied.`);return r},l=null,k=[];
|
|
112
|
+
if(!0===c(m.cmd,"waitForTesterAPIData")&&(l=n=>p(this,void 0,void 0,function*(){this.finishedLoading=!1;yield this.waitForData()})),!0===c(m.cmd,"wait")&&(k=b(m.cmd),l=n=>p(this,void 0,void 0,function*(){let r=parseInt(n[0]);yield C.HotStaq.wait(r)})),!0===c(m.cmd,"url")&&(k=b(m.cmd),l=n=>p(this,void 0,void 0,function*(){yield this.driver.navigateToUrl(n[0])})),!0===c(m.cmd,"print")&&(k=b(m.cmd),l=n=>p(this,void 0,void 0,function*(){yield this.driver.print(n[0])})),!0===c(m.cmd,"println")&&(k=b(m.cmd),
|
|
113
|
+
l=n=>p(this,void 0,void 0,function*(){yield this.driver.println(n[0])})),!0===c(m.cmd,"waitForTestObject")&&(k=b(m.cmd),l=n=>p(this,void 0,void 0,function*(){let r=JSON.parse(n[0]);yield this.driver.waitForTestElement(r)})),null==l)throw Error(`HotTester: Command ${m.cmd} does not exist!`);yield this.onCommand(d,g,m,h,k,l)})}executeTestPagePaths(d,g=!1){return p(this,void 0,void 0,function*(){let m=[],h=this.testMaps[d.mapName];if(null==h)throw Error(`HotTester: Map ${d.mapName} does not exist!`);
|
|
114
|
+
for(let c=0;c<d.paths.length;c++){let b=d.paths[c],l=null,k=h.pages[d.page];if(null==k)throw Error(`HotTester: Page ${d.page} does not exist!`);if(""!==b.dest){if(h.destinations instanceof Array)throw Error(`HotTester: When using type 'dest' in a destination string, all destinations in map ${d.mapName} must be named.`);let n=x.interpretDestination(d.mapName,h.destinations[b.dest]);null!=n&&(l=yield this.executeTestPagePaths(n))}""!==b.cmd&&(yield this.executeCommand(d,k,b,b.cmd));""!==b.path&&(l=
|
|
115
|
+
yield this.executeTestPagePath(d,b,!1,g));m.push(l)}return m})}execute(d){return p(this,void 0,void 0,function*(){let g=this.testMaps[d];if(null==g)throw Error(`HotTester: Map ${d} does not exist!`);var m=this.processor.getRouteKeyFromName(d);let h="";""!==m&&(h=`${this.baseUrl}${m}`);m=(n,r="")=>p(this,void 0,void 0,function*(){if(!1!==n.autoStart){var t=x.interpretDestination(d,n),I=!1,y=!0;""!==t.page&&(I=!0);null!=this.setup&&!1===this.hasBeenSetup&&(yield this.setup(I,h,r),this.hasBeenSetup=
|
|
116
|
+
!0,this.hasBeenDestroyed=!1);null!=this.onTestStart&&(y=yield this.onTestStart(t,h,r));!0===y&&(""!==t.page&&(yield this.executeTestPagePaths(t)),""!==t.api&&(yield this.executeTestAPIPaths(t)));null!=this.onTestEnd&&(yield this.onTestEnd(t));null!=this.destroy&&!1===this.hasBeenDestroyed&&(yield this.destroy(),this.hasBeenDestroyed=!0,this.hasBeenSetup=!1)}});if(g.destinations instanceof Array)for(var c=0;c<g.destinations.length;c++)yield m(g.destinations[c]);else if(0<g.destinationOrder.length){var b=
|
|
117
|
+
[];for(var l=0;l<g.destinationOrder.length;l++){var k=g.destinationOrder[l];let n=g.destinations[k];if(null==n)throw Error(`HotTester: Destination ${k} does not exist!`);b.push(k);yield m(n,k)}for(c in g.destinations){l=!0;for(k=0;k<b.length;k++)if(b[k]===c){l=!1;break}!0===l&&(yield m(g.destinations[c],c))}}else for(b in g.destinations)yield m(g.destinations[b],b)})}}u.HotTester=x},414:function(D,u,q){var p=this&&this.__awaiter||function(m,h,c,b){return new (c||(c=Promise))(function(l,k){function n(I){try{t(b.next(I))}catch(y){k(y)}}
|
|
118
|
+
function r(I){try{t(b.throw(I))}catch(y){k(y)}}function t(I){var y;I.done?l(I.value):(y=I.value,y instanceof c?y:new c(function(z){z(y)})).then(n,r)}t((b=b.apply(m,h||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0});u.HotTesterAPI=void 0;const C=q(233),x=q(761),d=q(70);class g extends C.HotAPI{constructor(m,h=null,c=null){super(m,h,c);this.executeEventsUsing=C.EventExecutionType.HotAPI;m=new x.HotRoute(h,"tester");m.addMethod({name:"pageLoaded",onServerExecute:this.pageLoaded,parameters:{testerName:{required:!0,
|
|
119
|
+
type:"string",description:"The name of the tester executing the test."},testerMap:{required:!0,type:"string",description:"The tester map executing the test."},pageName:{required:!0,type:"string",description:"The name of the page executing the test."},testElements:{required:!0,type:"array",description:"The test elements on the page."},testPaths:{required:!0,type:"array",description:"The test paths on the page."}},returns:"Returns true as an acknowledgement."});m.addMethod({name:"executeTests",onServerExecute:this.executeTests,
|
|
120
|
+
parameters:{testerName:{required:!0,type:"string",description:"The name of the tester executing the test."},testerMap:{required:!0,type:"object",description:"The tester map to execute."}},returns:"Returns true when tests are complete."});m.addMethod({name:"heartbeat",type:d.HTTPMethod.GET,onServerExecute:this.heartbeat,returns:"Returns true as an acknowledgement."});this.addRoute(m)}pageLoaded(m,h,c,b,l){return p(this,void 0,void 0,function*(){let k={testerName:b.testerName,testerMap:b.testerMap,
|
|
121
|
+
pageName:b.pageName,testElements:b.testElements,testPathsStrs:b.testPaths};for(var n in k){var r=!1;if(null==k[n]&&(r=!0),""!=k.testerName&&""!==k.testerMap&&""!==k.testElements&&""!==k.testPathsStrs||(r=!0),!0===r)throw Error(`TesterAPI: Object ${n} was not passed.`);}k.testElements=JSON.parse(k.testElements);k.testPathsStrs=JSON.parse(k.testPathsStrs);n={};for(var t in k.testPathsStrs)r=eval(k.testPathsStrs[t]),n[t]=r;t=this.connection.processor.testers[k.testerName];if(null==t)throw Error(`TesterAPI: Tester ${k.testerMap} does not exist!`);
|
|
122
|
+
r=t.testMaps[k.testerMap];if(null==r)throw Error(`TesterAPI: Tester map ${k.testerMap} does not exist!`);return r.pages[k.pageName]={testElements:{},testPaths:{}},r.pages[k.pageName].testElements=k.testElements,r.pages[k.pageName].testPaths=n,t.finishedLoading=!0,null!=t.onFinishedLoading&&(yield t.onFinishedLoading()),!0})}executeTests(m,h,c,b,l){return p(this,void 0,void 0,function*(){let k=b.testerName,n=b.testerMap;if(null==k||null==n)throw Error("TesterAPI: Not all required json objects were passed.");
|
|
123
|
+
if(""===k||""===n)throw Error("TesterAPI: Not all required json objects were passed.");let r=this.connection;return null!=r.executeTests&&(yield r.executeTests(k,n)),!0})}heartbeat(m,h,c,b,l){return p(this,void 0,void 0,function*(){return!0})}}u.HotTesterAPI=g},859:(D,u,q)=>{Object.defineProperty(u,"__esModule",{value:!0});u=q(243);const p=q(507),C=q(260),x=q(732),d=q(802),g=q(136),m=q(233),h=q(761),c=q(70),b=q(810),l=q(957),k=q(628),n=q(967),r=q(677),t=q(414);q=q(985);u.HotStaq.isWeb=!0;D.exports.HotStaq=
|
|
124
|
+
u.HotStaq;D.exports.Hot=p.Hot;D.exports.DeveloperMode=p.DeveloperMode;D.exports.HotComponent=C.HotComponent;D.exports.HotAPI=m.HotAPI;D.exports.EventExecutionType=m.EventExecutionType;D.exports.HotFile=x.HotFile;D.exports.HotLog=d.HotLog;D.exports.HotLogLevel=d.HotLogLevel;D.exports.HotPage=g.HotPage;D.exports.HotRoute=h.HotRoute;D.exports.HotRouteMethod=c.HotRouteMethod;D.exports.HTTPMethod=c.HTTPMethod;D.exports.HotServer=b.HotServer;D.exports.HotServerType=b.HotServerType;D.exports.HotClient=l.HotClient;
|
|
125
|
+
D.exports.HotTester=r.HotTester;D.exports.HotTesterAPI=t.HotTesterAPI;D.exports.HotTestMap=q.HotTestMap;D.exports.HotTestDestination=q.HotTestDestination;D.exports.HotTestElement=n.HotTestElement;D.exports.HotTestElementOptions=n.HotTestElementOptions;D.exports.HotTestDriver=k.HotTestDriver},651:D=>{D.exports={}},351:()=>{},606:()=>{}},ea={};HotStaqWeb=da(859)})();
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
if (typeof (HotStaqTests) === "undefined")
|
|
2
|
+
HotStaqTests = {};
|
|
3
|
+
|
|
4
|
+
var HotAPIGlobal = undefined;
|
|
5
|
+
|
|
6
|
+
if (typeof (HotAPI) !== "undefined")
|
|
7
|
+
HotAPIGlobal = HotAPI;
|
|
8
|
+
|
|
9
|
+
if (typeof (window) !== "undefined")
|
|
10
|
+
{
|
|
11
|
+
if (typeof (window.HotAPI) !== "undefined")
|
|
12
|
+
HotAPIGlobal = window.HotAPI;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get the authorization header string.
|
|
17
|
+
*/
|
|
18
|
+
function HotStaqGetAuthorizationHeaderString ()
|
|
19
|
+
{
|
|
20
|
+
const auth = null;
|
|
21
|
+
|
|
22
|
+
if (this.authorization != null)
|
|
23
|
+
{
|
|
24
|
+
if (this.authorization.toAuthorizationHeaderString != null)
|
|
25
|
+
auth = this.authorization.toAuthorizationHeaderString ();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (auth == null)
|
|
29
|
+
{
|
|
30
|
+
if (Hot != null)
|
|
31
|
+
{
|
|
32
|
+
if (Hot.API != null)
|
|
33
|
+
{
|
|
34
|
+
if (Hot.API.authCredentials != null)
|
|
35
|
+
{
|
|
36
|
+
if (Hot.API.authCredentials.toAuthorizationHeaderString != null)
|
|
37
|
+
auth = Hot.API.authCredentials.toAuthorizationHeaderString ();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (auth);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Process a JSON object, and get it ready to make a request.
|
|
48
|
+
*/
|
|
49
|
+
function HotStaqProcessJSONObject (jsonObj)
|
|
50
|
+
{
|
|
51
|
+
if (jsonObj != null)
|
|
52
|
+
{
|
|
53
|
+
if (Hot != null)
|
|
54
|
+
{
|
|
55
|
+
if (Hot.API != null)
|
|
56
|
+
{
|
|
57
|
+
if (Hot.API.authCredentials != null)
|
|
58
|
+
{
|
|
59
|
+
for (let key in Hot.API.authCredentials)
|
|
60
|
+
{
|
|
61
|
+
if (jsonObj[key] == null)
|
|
62
|
+
jsonObj[key] = Hot.API.authCredentials[key];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (jsonObj);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Make a request to the server.
|
|
74
|
+
*/
|
|
75
|
+
function HotStaqPostJSONObject (methodType, url, jsonObj, auth)
|
|
76
|
+
{
|
|
77
|
+
let headers = {
|
|
78
|
+
"Accept": "application/json",
|
|
79
|
+
"Content-Type": "application/json"
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (auth != null)
|
|
83
|
+
headers["Authorization"] = auth;
|
|
84
|
+
|
|
85
|
+
let promise = fetch (url, {
|
|
86
|
+
"method": methodType,
|
|
87
|
+
"headers": headers,
|
|
88
|
+
body: JSON.stringify (jsonObj)
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return (promise);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The hello_world API route.
|
|
96
|
+
*/
|
|
97
|
+
class hello_world
|
|
98
|
+
{
|
|
99
|
+
constructor (baseUrl, connection, db)
|
|
100
|
+
{
|
|
101
|
+
if (baseUrl == null)
|
|
102
|
+
baseUrl = "http://127.0.0.1:3123";
|
|
103
|
+
|
|
104
|
+
if (connection === undefined)
|
|
105
|
+
connection = null;
|
|
106
|
+
|
|
107
|
+
if (db === undefined)
|
|
108
|
+
db = null;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The base url to make calls to.
|
|
112
|
+
*/
|
|
113
|
+
this.baseUrl = baseUrl;
|
|
114
|
+
/**
|
|
115
|
+
* The connection to the server/client.
|
|
116
|
+
*/
|
|
117
|
+
this.connection = connection;
|
|
118
|
+
/**
|
|
119
|
+
* The authorization used to connect to the server.
|
|
120
|
+
*/
|
|
121
|
+
this.authorization = null;
|
|
122
|
+
/**
|
|
123
|
+
* The database connection, if any.
|
|
124
|
+
*/
|
|
125
|
+
this.db = db;
|
|
126
|
+
|
|
127
|
+
if (connection != null)
|
|
128
|
+
{
|
|
129
|
+
if (connection.api != null)
|
|
130
|
+
{
|
|
131
|
+
if (connection.api.authCredentials != null)
|
|
132
|
+
this.authorization = connection.api.authCredentials;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The JSON object to send to the server.
|
|
139
|
+
*
|
|
140
|
+
* @typedef {Object} HELLO_WORLD_HELLO_JSON_OBJECT_TYPE
|
|
141
|
+
* @property {string} message The message to send to the server. Can be: hi, hello
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The hello method.
|
|
146
|
+
*
|
|
147
|
+
* @param {HELLO_WORLD_HELLO_JSON_OBJECT_TYPE} jsonObj
|
|
148
|
+
*
|
|
149
|
+
* @returns {string} The server says Hello World!
|
|
150
|
+
*/
|
|
151
|
+
hello (jsonObj)
|
|
152
|
+
{
|
|
153
|
+
var promise = new Promise ((resolve, reject) =>
|
|
154
|
+
{
|
|
155
|
+
const url = `${this.baseUrl}/v1/hello_world/hello`;
|
|
156
|
+
const auth = null;
|
|
157
|
+
|
|
158
|
+
if (this.authorization != null)
|
|
159
|
+
{
|
|
160
|
+
if (this.authorization.toAuthorizationHeaderString != null)
|
|
161
|
+
auth = this.authorization.toAuthorizationHeaderString ();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
jsonObj = HotStaqProcessJSONObject (jsonObj);
|
|
166
|
+
HotStaqPostJSONObject ("POST", url, jsonObj, auth).then (
|
|
167
|
+
function (response)
|
|
168
|
+
{
|
|
169
|
+
var result = response.json ();
|
|
170
|
+
|
|
171
|
+
resolve (result);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
return (promise);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The is_up method.
|
|
180
|
+
*/
|
|
181
|
+
is_up (jsonObj)
|
|
182
|
+
{
|
|
183
|
+
var promise = new Promise ((resolve, reject) =>
|
|
184
|
+
{
|
|
185
|
+
const url = `${this.baseUrl}/v1/hello_world/is_up`;
|
|
186
|
+
const auth = null;
|
|
187
|
+
|
|
188
|
+
if (this.authorization != null)
|
|
189
|
+
{
|
|
190
|
+
if (this.authorization.toAuthorizationHeaderString != null)
|
|
191
|
+
auth = this.authorization.toAuthorizationHeaderString ();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
jsonObj = HotStaqProcessJSONObject (jsonObj);
|
|
196
|
+
HotStaqPostJSONObject ("GET", url, jsonObj, auth).then (
|
|
197
|
+
function (response)
|
|
198
|
+
{
|
|
199
|
+
var result = response.json ();
|
|
200
|
+
|
|
201
|
+
resolve (result);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return (promise);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The file_upload method.
|
|
210
|
+
*/
|
|
211
|
+
file_upload (jsonObj)
|
|
212
|
+
{
|
|
213
|
+
var promise = new Promise ((resolve, reject) =>
|
|
214
|
+
{
|
|
215
|
+
const url = `${this.baseUrl}/v1/hello_world/file_upload`;
|
|
216
|
+
const auth = null;
|
|
217
|
+
|
|
218
|
+
if (this.authorization != null)
|
|
219
|
+
{
|
|
220
|
+
if (this.authorization.toAuthorizationHeaderString != null)
|
|
221
|
+
auth = this.authorization.toAuthorizationHeaderString ();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
let uploadHeaders = {
|
|
226
|
+
"Content-Type": "multipart/form-data"
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
if (auth != null)
|
|
230
|
+
uploadHeaders["Authorization"] = auth;
|
|
231
|
+
|
|
232
|
+
fetch (url, {
|
|
233
|
+
"method": "POST",
|
|
234
|
+
"headers": uploadHeaders,
|
|
235
|
+
body: JSON.stringify (jsonObj)
|
|
236
|
+
}).then (() =>
|
|
237
|
+
{
|
|
238
|
+
|
|
239
|
+
jsonObj = HotStaqProcessJSONObject (jsonObj);
|
|
240
|
+
HotStaqPostJSONObject ("POST", url, jsonObj, auth).then (
|
|
241
|
+
function (response)
|
|
242
|
+
{
|
|
243
|
+
var result = response.json ();
|
|
244
|
+
|
|
245
|
+
resolve (result);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
return (promise);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The test_response method.
|
|
256
|
+
*/
|
|
257
|
+
test_response (jsonObj)
|
|
258
|
+
{
|
|
259
|
+
var promise = new Promise ((resolve, reject) =>
|
|
260
|
+
{
|
|
261
|
+
const url = `${this.baseUrl}/v1/hello_world/test_response`;
|
|
262
|
+
const auth = null;
|
|
263
|
+
|
|
264
|
+
if (this.authorization != null)
|
|
265
|
+
{
|
|
266
|
+
if (this.authorization.toAuthorizationHeaderString != null)
|
|
267
|
+
auth = this.authorization.toAuthorizationHeaderString ();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
jsonObj = HotStaqProcessJSONObject (jsonObj);
|
|
272
|
+
HotStaqPostJSONObject ("POST", url, jsonObj, auth).then (
|
|
273
|
+
function (response)
|
|
274
|
+
{
|
|
275
|
+
var result = response.json ();
|
|
276
|
+
|
|
277
|
+
resolve (result);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return (promise);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The hello_world_second API route.
|
|
288
|
+
*/
|
|
289
|
+
class hello_world_second
|
|
290
|
+
{
|
|
291
|
+
constructor (baseUrl, connection, db)
|
|
292
|
+
{
|
|
293
|
+
if (baseUrl == null)
|
|
294
|
+
baseUrl = "http://127.0.0.1:3123";
|
|
295
|
+
|
|
296
|
+
if (connection === undefined)
|
|
297
|
+
connection = null;
|
|
298
|
+
|
|
299
|
+
if (db === undefined)
|
|
300
|
+
db = null;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* The base url to make calls to.
|
|
304
|
+
*/
|
|
305
|
+
this.baseUrl = baseUrl;
|
|
306
|
+
/**
|
|
307
|
+
* The connection to the server/client.
|
|
308
|
+
*/
|
|
309
|
+
this.connection = connection;
|
|
310
|
+
/**
|
|
311
|
+
* The authorization used to connect to the server.
|
|
312
|
+
*/
|
|
313
|
+
this.authorization = null;
|
|
314
|
+
/**
|
|
315
|
+
* The database connection, if any.
|
|
316
|
+
*/
|
|
317
|
+
this.db = db;
|
|
318
|
+
|
|
319
|
+
if (connection != null)
|
|
320
|
+
{
|
|
321
|
+
if (connection.api != null)
|
|
322
|
+
{
|
|
323
|
+
if (connection.api.authCredentials != null)
|
|
324
|
+
this.authorization = connection.api.authCredentials;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The JSON object to send to the server.
|
|
331
|
+
*
|
|
332
|
+
* @typedef {Object} HELLO_WORLD_SECOND_HELLO_AGAIN_JSON_OBJECT_TYPE
|
|
333
|
+
* @property {string} type The type of message to send.
|
|
334
|
+
* @property {string} value The message to send.
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* The JSON object returned from the server.
|
|
339
|
+
*
|
|
340
|
+
* @typedef {Object} HELLO_WORLD_SECOND_HELLO_AGAIN_JSON_RETURN_TYPE
|
|
341
|
+
* @property {string} type The type of message to send.
|
|
342
|
+
* @property {string} value The message to send.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The hello_again method.
|
|
347
|
+
*
|
|
348
|
+
* @param {HELLO_WORLD_SECOND_HELLO_AGAIN_JSON_OBJECT_TYPE} jsonObj
|
|
349
|
+
*
|
|
350
|
+
* @returns {HELLO_WORLD_SECOND_HELLO_AGAIN_JSON_RETURN_TYPE} The message to send to the server again. Can be: hi, hello
|
|
351
|
+
*/
|
|
352
|
+
hello_again (jsonObj)
|
|
353
|
+
{
|
|
354
|
+
var promise = new Promise ((resolve, reject) =>
|
|
355
|
+
{
|
|
356
|
+
const url = `${this.baseUrl}/v1/hello_world_second/hello_again`;
|
|
357
|
+
const auth = null;
|
|
358
|
+
|
|
359
|
+
if (this.authorization != null)
|
|
360
|
+
{
|
|
361
|
+
if (this.authorization.toAuthorizationHeaderString != null)
|
|
362
|
+
auth = this.authorization.toAuthorizationHeaderString ();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
jsonObj = HotStaqProcessJSONObject (jsonObj);
|
|
367
|
+
HotStaqPostJSONObject ("POST", url, jsonObj, auth).then (
|
|
368
|
+
function (response)
|
|
369
|
+
{
|
|
370
|
+
var result = response.json ();
|
|
371
|
+
|
|
372
|
+
resolve (result);
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
return (promise);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (typeof (HotStaqTests.HelloWorldAPI) === "undefined")
|
|
381
|
+
{
|
|
382
|
+
if (typeof (HotAPIGlobal) !== "undefined")
|
|
383
|
+
{
|
|
384
|
+
HotStaqTests.HelloWorldAPI = class extends HotAPIGlobal
|
|
385
|
+
{
|
|
386
|
+
constructor (baseUrl, connection, db)
|
|
387
|
+
{
|
|
388
|
+
super (baseUrl, connection, db);
|
|
389
|
+
|
|
390
|
+
this.hello_world = new hello_world (baseUrl, connection, db);
|
|
391
|
+
this.hello_world_second = new hello_world_second (baseUrl, connection, db);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|