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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hotstaq",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.21",
|
|
4
4
|
"description": "A friendly web framework that fits nicely into devops and CI/CD pipelines.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hotstaq": "./bin/hotstaq"
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@influxdata/influxdb-client": "^1.20.0",
|
|
33
33
|
"chai": "^4.3.4",
|
|
34
|
-
"dotenv": "^16.0.2",
|
|
35
34
|
"commander": "^6.2.1",
|
|
35
|
+
"dotenv": "^16.0.2",
|
|
36
36
|
"express": "^4.17.1",
|
|
37
37
|
"form-data": "^4.0.0",
|
|
38
38
|
"formidable": "^2.0.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"mocha": "^9.1.3",
|
|
43
43
|
"mysql2": "^2.3.3",
|
|
44
44
|
"node-fetch": "^2.6.7",
|
|
45
|
-
"selenium-webdriver": "^4.
|
|
45
|
+
"selenium-webdriver": "^4.4.0",
|
|
46
46
|
"uuid": "^8.3.2",
|
|
47
47
|
"validate-npm-package-name": "^3.0.0",
|
|
48
48
|
"yaml": "^1.10.2"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/mocha": "^7.0.2",
|
|
58
58
|
"@types/node": "^14.17.32",
|
|
59
59
|
"@types/node-fetch": "^2.6.1",
|
|
60
|
-
"@types/selenium-webdriver": "^4.
|
|
60
|
+
"@types/selenium-webdriver": "^4.1.5",
|
|
61
61
|
"@types/uuid": "^8.3.4",
|
|
62
62
|
"@types/validate-npm-package-name": "^3.0.3",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
package/selenium-start.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
|
-
VERSION
|
|
3
|
+
VERSION=${1:-"latest"}
|
|
4
4
|
|
|
5
5
|
docker rm -f selenium-hotstaq-tests 2>/dev/null || true
|
|
6
6
|
|
|
7
|
-
docker run --name selenium-hotstaq-tests -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:$VERSION
|
|
7
|
+
docker run --name selenium-hotstaq-tests -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:$VERSION
|
|
@@ -38,4 +38,18 @@ export interface HotDBConnectionInterface
|
|
|
38
38
|
* The database to use.
|
|
39
39
|
*/
|
|
40
40
|
database?: string;
|
|
41
|
+
/**
|
|
42
|
+
* If set to true, multiple statements will be enabled. WARNING: This can cause
|
|
43
|
+
* security issues. Additionally this currently only support HotDBMySQL which uses
|
|
44
|
+
* mysql2.
|
|
45
|
+
*/
|
|
46
|
+
multipleStatements?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The connection object to pass to the .
|
|
49
|
+
*
|
|
50
|
+
* For example, when using HotDBMySQL, if you place the object for mysql.PoolOptions
|
|
51
|
+
* that object will be used instead. If using HotDBInflux, you place the object for
|
|
52
|
+
* ClientOptions here, that will be used instead.
|
|
53
|
+
*/
|
|
54
|
+
connectionObjectOverride?: any;
|
|
41
55
|
}
|
package/src/HotStaq.ts
CHANGED
|
@@ -50,6 +50,9 @@ export class HotDBInflux extends HotDB<InfluxDB, void, InfluxSchema>
|
|
|
50
50
|
|
|
51
51
|
try
|
|
52
52
|
{
|
|
53
|
+
if (connectionInfo.connectionObjectOverride != null)
|
|
54
|
+
influxConnection = connectionInfo.connectionObjectOverride;
|
|
55
|
+
|
|
53
56
|
this.connectionStatus = ConnectionStatus.Connecting;
|
|
54
57
|
this.db = new InfluxDB (influxConnection);
|
|
55
58
|
|
|
@@ -39,16 +39,27 @@ export class HotDBMySQL extends HotDB<mysql.Pool, MySQLResults, MySQLSchema>
|
|
|
39
39
|
if (process.env["DATABASE_CONNECTIONS_LIMIT"] != null)
|
|
40
40
|
this.connectionLimit = parseInt (process.env["DATABASE_CONNECTIONS_LIMIT"]);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
let multipleStatements: boolean = false;
|
|
43
|
+
|
|
44
|
+
if (connectionInfo.multipleStatements != null)
|
|
45
|
+
multipleStatements = connectionInfo.multipleStatements;
|
|
46
|
+
|
|
47
|
+
let connectionObj: mysql.PoolOptions = {
|
|
44
48
|
host: connectionInfo.server,
|
|
45
49
|
user: connectionInfo.username,
|
|
46
50
|
password: connectionInfo.password,
|
|
47
51
|
port: connectionInfo.port,
|
|
48
52
|
database: connectionInfo.database,
|
|
49
53
|
waitForConnections: true,
|
|
50
|
-
connectionLimit: this.connectionLimit
|
|
51
|
-
|
|
54
|
+
connectionLimit: this.connectionLimit,
|
|
55
|
+
multipleStatements: multipleStatements
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (connectionInfo.connectionObjectOverride != null)
|
|
59
|
+
connectionObj = connectionInfo.connectionObjectOverride;
|
|
60
|
+
|
|
61
|
+
this.connectionStatus = ConnectionStatus.Connecting;
|
|
62
|
+
this.db = mysql.createPool (connectionObj);
|
|
52
63
|
this.connectionStatus = ConnectionStatus.Connected;
|
|
53
64
|
resolve ([true]);
|
|
54
65
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppAPI.d.ts","sourceRoot":"","sources":["../src/AppAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAEiB,MAAM,SAAS,CAAC;AAGtE;;GAEG;AACH,qBAAa,MAAO,SAAQ,MAAM;gBAEpB,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,SAAS,GAAG,SAAgB,EAAE,EAAE,GAAE,GAAU;CAsBtF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.AppAPI = void 0;
|
|
55
|
+
var hotstaq_1 = require("hotstaq");
|
|
56
|
+
var DataRoute_1 = require("./DataRoute");
|
|
57
|
+
/**
|
|
58
|
+
* The App's API and routes.
|
|
59
|
+
*/
|
|
60
|
+
var AppAPI = /** @class */ (function (_super) {
|
|
61
|
+
__extends(AppAPI, _super);
|
|
62
|
+
function AppAPI(baseUrl, connection, db) {
|
|
63
|
+
if (connection === void 0) { connection = null; }
|
|
64
|
+
if (db === void 0) { db = null; }
|
|
65
|
+
var _this = _super.call(this, baseUrl, connection, db) || this;
|
|
66
|
+
_this.onPreRegister = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
if (connection.type !== hotstaq_1.HotServerType.Generate) {
|
|
69
|
+
this.setDBSchema(new hotstaq_1.MySQLSchema(process.env["DATABASE_SCHEMA"]));
|
|
70
|
+
}
|
|
71
|
+
return [2 /*return*/, (true)];
|
|
72
|
+
});
|
|
73
|
+
}); };
|
|
74
|
+
_this.onPostRegister = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
// Sync database tables here.
|
|
77
|
+
return [2 /*return*/, (true)];
|
|
78
|
+
});
|
|
79
|
+
}); };
|
|
80
|
+
_this.addRoute(new DataRoute_1.DataRoute(_this));
|
|
81
|
+
return _this;
|
|
82
|
+
}
|
|
83
|
+
return AppAPI;
|
|
84
|
+
}(hotstaq_1.HotAPI));
|
|
85
|
+
exports.AppAPI = AppAPI;
|
|
86
|
+
//# sourceMappingURL=AppAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppAPI.js","sourceRoot":"","sources":["../src/AppAPI.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAEsE;AACtE,yCAAwC;AAExC;;GAEG;AACH;IAA4B,0BAAM;IAEjC,gBAAa,OAAe,EAAE,UAAwC,EAAE,EAAc;QAAxD,2BAAA,EAAA,iBAAwC;QAAE,mBAAA,EAAA,SAAc;QAAtF,YAEC,kBAAM,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,SAmB9B;QAjBA,KAAI,CAAC,aAAa,GAAG;;gBAEnB,IAAI,UAAU,CAAC,IAAI,KAAK,uBAAa,CAAC,QAAQ,EAC9C;oBACC,IAAI,CAAC,WAAW,CAAE,IAAI,qBAAW,CAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;iBACpE;gBAED,sBAAO,CAAC,IAAI,CAAC,EAAC;;aACd,CAAC;QACH,KAAI,CAAC,cAAc,GAAG;;gBAEpB,6BAA6B;gBAE7B,sBAAO,CAAC,IAAI,CAAC,EAAC;;aACd,CAAC;QAEH,KAAI,CAAC,QAAQ,CAAE,IAAI,qBAAS,CAAE,KAAI,CAAC,CAAC,CAAC;;IACtC,CAAC;IACF,aAAC;AAAD,CAAC,AAxBD,CAA4B,gBAAM,GAwBjC;AAxBY,wBAAM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HotRoute, HotDBMySQL } from "hotstaq";
|
|
2
|
+
import { AppAPI } from "./AppAPI";
|
|
3
|
+
/**
|
|
4
|
+
* Data route.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DataRoute extends HotRoute {
|
|
7
|
+
/**
|
|
8
|
+
* The database connection.
|
|
9
|
+
*/
|
|
10
|
+
db: HotDBMySQL;
|
|
11
|
+
constructor(api: AppAPI);
|
|
12
|
+
/**
|
|
13
|
+
* Add some data.
|
|
14
|
+
*/
|
|
15
|
+
protected add(req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* List some data.
|
|
18
|
+
*/
|
|
19
|
+
protected list(req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any): Promise<any>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=DataRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataRoute.d.ts","sourceRoot":"","sources":["../src/DataRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,UAAU,EAE8C,MAAM,SAAS,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,qBAAa,SAAU,SAAQ,QAAQ;IAEtC;;OAEG;IACH,EAAE,EAAE,UAAU,CAAC;gBAEF,GAAG,EAAE,MAAM;IAkGxB;;OAEG;cACa,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA2BzG;;OAEG;cACa,IAAI,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CA0C1G"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.DataRoute = void 0;
|
|
55
|
+
var hotstaq_1 = require("hotstaq");
|
|
56
|
+
/**
|
|
57
|
+
* Data route.
|
|
58
|
+
*/
|
|
59
|
+
var DataRoute = /** @class */ (function (_super) {
|
|
60
|
+
__extends(DataRoute, _super);
|
|
61
|
+
function DataRoute(api) {
|
|
62
|
+
var _this = _super.call(this, api.connection, "data") || this;
|
|
63
|
+
_this.onRegister = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
if (!(api.connection.type !== hotstaq_1.HotServerType.Generate)) return [3 /*break*/, 2];
|
|
68
|
+
this.db = this.connection.api.db;
|
|
69
|
+
if (this.db.connectionStatus !== hotstaq_1.ConnectionStatus.Connected)
|
|
70
|
+
return [2 /*return*/, (true)];
|
|
71
|
+
// Create and sync any tables here. The following is simply an example:
|
|
72
|
+
return [4 /*yield*/, this.db.query("create table if not exists users (\n\t\t\t\t\t\t\t\tid BINARY(36) NOT NULL DEFAULT UUID(),\n\t\t\t\t\t\t\t\tname VARCHAR(256) DEFAULT '',\n\t\t\t\t\t\t\t\temail VARCHAR(256) DEFAULT '',\n\t\t\t\t\t\t\t\tpassword VARCHAR(256) DEFAULT '',\n\t\t\t\t\t\t\t\tverified INT(1) DEFAULT '0',\n\t\t\t\t\t\t\t\tregistered DATETIME DEFAULT NOW(),\n\t\t\t\t\t\t\t\tenabled INT(1) DEFAULT '1',\n\t\t\t\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t\t\t)")];
|
|
73
|
+
case 1:
|
|
74
|
+
// Create and sync any tables here. The following is simply an example:
|
|
75
|
+
_a.sent();
|
|
76
|
+
_a.label = 2;
|
|
77
|
+
case 2: return [2 /*return*/, (true)];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); };
|
|
81
|
+
_this.addMethod({
|
|
82
|
+
"name": "add",
|
|
83
|
+
"onServerExecute": _this.add,
|
|
84
|
+
"parameters": {
|
|
85
|
+
"schema": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"required": true,
|
|
88
|
+
"description": "The schema to add data to."
|
|
89
|
+
},
|
|
90
|
+
"fields": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"required": true,
|
|
93
|
+
"description": "The fields and their values to add to the database."
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"description": "Add results to the database.",
|
|
97
|
+
"returns": "Returns true if successful.",
|
|
98
|
+
"testCases": [
|
|
99
|
+
"HiTest",
|
|
100
|
+
function (driver) { return __awaiter(_this, void 0, void 0, function () {
|
|
101
|
+
var resp;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0: return [4 /*yield*/, api.data.add()];
|
|
105
|
+
case 1:
|
|
106
|
+
resp = _a.sent();
|
|
107
|
+
driver.assert(resp === "hello", "The message \"hello\" was not returned!");
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); }
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
_this.addMethod({
|
|
115
|
+
"name": "list",
|
|
116
|
+
"onServerExecute": _this.list,
|
|
117
|
+
"parameters": {
|
|
118
|
+
"schema": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"required": true,
|
|
121
|
+
"description": "The schema to access."
|
|
122
|
+
},
|
|
123
|
+
"fields": {
|
|
124
|
+
"type": "array",
|
|
125
|
+
"required": true,
|
|
126
|
+
"description": "The list of fields in the schema to access."
|
|
127
|
+
},
|
|
128
|
+
"offset": {
|
|
129
|
+
"type": "int",
|
|
130
|
+
"required": false,
|
|
131
|
+
"description": "The offset."
|
|
132
|
+
},
|
|
133
|
+
"limit": {
|
|
134
|
+
"type": "int",
|
|
135
|
+
"required": false,
|
|
136
|
+
"description": "The max number of results to return. Default is 20."
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"description": "List results from a schema.",
|
|
140
|
+
"returns": "Returns the results from the schema.",
|
|
141
|
+
"testCases": [
|
|
142
|
+
"HiTest",
|
|
143
|
+
function (driver) { return __awaiter(_this, void 0, void 0, function () {
|
|
144
|
+
var resp;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0: return [4 /*yield*/, api.data.list()];
|
|
148
|
+
case 1:
|
|
149
|
+
resp = _a.sent();
|
|
150
|
+
driver.assert(resp === "hello", "The message \"hello\" was not returned!");
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}); }
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
return _this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Add some data.
|
|
161
|
+
*/
|
|
162
|
+
DataRoute.prototype.add = function (req, res, authorizedValue, jsonObj, queryObj) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
var schema, fields, insertQuery, insertArray, key, field, value, result;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
schema = hotstaq_1.HotStaq.getParam("schema", jsonObj);
|
|
169
|
+
fields = hotstaq_1.HotStaq.getParam("fields", jsonObj);
|
|
170
|
+
insertQuery = "";
|
|
171
|
+
insertArray = [schema];
|
|
172
|
+
for (key in fields) {
|
|
173
|
+
field = key;
|
|
174
|
+
value = fields[key];
|
|
175
|
+
insertQuery += field + " = ?, ";
|
|
176
|
+
insertArray.push(value);
|
|
177
|
+
}
|
|
178
|
+
if (insertArray.length > 1)
|
|
179
|
+
insertQuery = insertQuery.substring(0, (insertQuery.length - 2));
|
|
180
|
+
return [4 /*yield*/, this.db.query("insert into ?? set " + insertQuery + ";", insertArray)];
|
|
181
|
+
case 1:
|
|
182
|
+
result = _a.sent();
|
|
183
|
+
if (result.error != null)
|
|
184
|
+
throw new Error(result.error);
|
|
185
|
+
return [2 /*return*/, (true)];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* List some data.
|
|
192
|
+
*/
|
|
193
|
+
DataRoute.prototype.list = function (req, res, authorizedValue, jsonObj, queryObj) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var schema, fields, offset, limit, queryStr, values, key, fieldElement, value, strtemp, result, results;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
schema = hotstaq_1.HotStaq.getParam("schema", jsonObj);
|
|
200
|
+
fields = hotstaq_1.HotStaq.getParamDefault("fields", jsonObj, {});
|
|
201
|
+
offset = hotstaq_1.HotStaq.getParamDefault("offset", jsonObj, 0);
|
|
202
|
+
limit = hotstaq_1.HotStaq.getParamDefault("limit", jsonObj, 20);
|
|
203
|
+
queryStr = "select * from ??";
|
|
204
|
+
values = [schema];
|
|
205
|
+
for (key in fields) {
|
|
206
|
+
fieldElement = fields[key];
|
|
207
|
+
value = fieldElement.value;
|
|
208
|
+
if (values.length === 1)
|
|
209
|
+
queryStr += " where ";
|
|
210
|
+
queryStr += "?? = ? AND ";
|
|
211
|
+
values.push(key);
|
|
212
|
+
values.push(value);
|
|
213
|
+
}
|
|
214
|
+
if (values.length > 1)
|
|
215
|
+
queryStr = queryStr.substring(0, (queryStr.length - 5));
|
|
216
|
+
values.push(offset);
|
|
217
|
+
values.push(limit);
|
|
218
|
+
strtemp = this.db.db.format(queryStr, values);
|
|
219
|
+
this.logger.verbose(strtemp);
|
|
220
|
+
return [4 /*yield*/, this.db.query(queryStr, values)];
|
|
221
|
+
case 1:
|
|
222
|
+
result = _a.sent();
|
|
223
|
+
if (result.error != null)
|
|
224
|
+
throw result.error;
|
|
225
|
+
this.logger.verbose(JSON.stringify(result));
|
|
226
|
+
results = result.results;
|
|
227
|
+
return [2 /*return*/, (results)];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
return DataRoute;
|
|
233
|
+
}(hotstaq_1.HotRoute));
|
|
234
|
+
exports.DataRoute = DataRoute;
|
|
235
|
+
//# sourceMappingURL=DataRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataRoute.js","sourceRoot":"","sources":["../src/DataRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAEuG;AAGvG;;GAEG;AACH;IAA+B,6BAAQ;IAOtC,mBAAa,GAAW;QAAxB,YAEC,kBAAO,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,SA8F9B;QA5FA,KAAI,CAAC,UAAU,GAAG;;;;6BAEZ,CAAA,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,uBAAa,CAAC,QAAQ,CAAA,EAA9C,wBAA8C;wBAEjD,IAAI,CAAC,EAAE,GAAgB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAG,CAAC;wBAE/C,IAAI,IAAI,CAAC,EAAE,CAAC,gBAAgB,KAAK,0BAAgB,CAAC,SAAS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wBAE1D,MAAM,CAAC,IAAI,CAAE,MAAM,CAAC,CAAC;wBACrB,MAAM,CAAC,IAAI,CAAE,KAAK,CAAC,CAAC;wBAEhB,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;wBACnD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAE,OAAO,CAAC,CAAC;wBACjB,qBAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CAAE,QAAQ,EAAE,MAAM,CAAC,EAAA;;wBAA/C,MAAM,GAAG,SAAsC;wBAEnD,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI;4BACvB,MAAM,MAAM,CAAC,KAAK,CAAC;wBAEpB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAE,IAAI,CAAC,SAAS,CAAE,MAAM,CAAC,CAAC,CAAC;wBAC1C,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;wBAEvB,sBAAO,CAAC,OAAO,CAAC,EAAC;;;;KACvB;IACF,gBAAC;AAAD,CAAC,AApLD,CAA+B,kBAAQ,GAoLtC;AApLY,8BAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebExport.d.ts","sourceRoot":"","sources":["../src/WebExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACC,MAAM,EACZ,SAAS,EACT,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataRoute = exports.AppAPI = void 0;
|
|
4
|
+
var AppAPI_1 = require("./AppAPI");
|
|
5
|
+
Object.defineProperty(exports, "AppAPI", { enumerable: true, get: function () { return AppAPI_1.AppAPI; } });
|
|
6
|
+
var DataRoute_1 = require("./DataRoute");
|
|
7
|
+
Object.defineProperty(exports, "DataRoute", { enumerable: true, get: function () { return DataRoute_1.DataRoute; } });
|
|
8
|
+
//# sourceMappingURL=WebExport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebExport.js","sourceRoot":"","sources":["../src/WebExport.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAI1B,uFAJC,eAAM,OAID;AAHd,yCAAwC;AAItC,0FAJO,qBAAS,OAIP"}
|