@ldsg/application 0.1.0-alpha.4
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/LICENSE +22 -0
- package/README.md +1 -0
- package/dist/handler-resource-settings.d.ts +8 -0
- package/dist/handler-resource-settings.d.ts.map +1 -0
- package/dist/handler-resource-settings.js +18 -0
- package/dist/handler.d.ts +8 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/instantiate-resource.d.ts +5 -0
- package/dist/instantiate-resource.d.ts.map +1 -0
- package/dist/instantiate-resource.js +13 -0
- package/dist/resource-definition-resource-settings.d.ts +3 -0
- package/dist/resource-definition-resource-settings.d.ts.map +1 -0
- package/dist/resource-definition-resource-settings.js +9 -0
- package/dist/resource.d.ts +8 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +28 -0
- package/dist/resource.spec.d.ts +2 -0
- package/dist/resource.spec.d.ts.map +1 -0
- package/dist/resource.spec.js +31 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/resource-settings.d.ts +4 -0
- package/dist/types/resource-settings.d.ts.map +1 -0
- package/dist/types/resource-settings.js +2 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Application Resource
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HandlerResourceSettings } from "@ldsg/handler";
|
|
2
|
+
/**
|
|
3
|
+
* Current Kind Resource Handler Resource Settings
|
|
4
|
+
* 此类型资源的子级处理程序资源的配置
|
|
5
|
+
* 如无或为 undefined,则说明无需子级处理程序。
|
|
6
|
+
*/
|
|
7
|
+
export declare const handlerResourceSettings: HandlerResourceSettings;
|
|
8
|
+
//# sourceMappingURL=handler-resource-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-resource-settings.d.ts","sourceRoot":"","sources":["../src/handler-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBASrC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handlerResourceSettings = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Current Kind Resource Handler Resource Settings
|
|
6
|
+
* 此类型资源的子级处理程序资源的配置
|
|
7
|
+
* 如无或为 undefined,则说明无需子级处理程序。
|
|
8
|
+
*/
|
|
9
|
+
exports.handlerResourceSettings = {
|
|
10
|
+
title: "应用类型资源处理程序",
|
|
11
|
+
description: "",
|
|
12
|
+
code: `export * from "@ldsg/application";`,
|
|
13
|
+
dependencies: [
|
|
14
|
+
{
|
|
15
|
+
name: "@ldsg/application",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Handler } from "@ldsg/handler";
|
|
2
|
+
import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
|
|
3
|
+
import { ApplicationResource } from "./resource";
|
|
4
|
+
import { ApplicationResourceSettings } from "./types";
|
|
5
|
+
export declare const handler: Handler<[
|
|
6
|
+
InstantiateResourceParams<ApplicationResourceSettings>
|
|
7
|
+
], InstantiateResourceRes<ApplicationResource>>;
|
|
8
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAEtD,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B;IAAC,yBAAyB,CAAC,2BAA2B,CAAC;CAAC,EACxD,sBAAsB,CAAC,mBAAmB,CAAC,CACtB,CAAC"}
|
package/dist/handler.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./handler";
|
|
2
|
+
export * from "./handler-resource-settings";
|
|
3
|
+
export * from "./instantiate-resource";
|
|
4
|
+
export * from "./resource";
|
|
5
|
+
export * from "./resource-definition-resource-settings";
|
|
6
|
+
export * from "./types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,yCAAyC,CAAC;AACxD,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./handler"), exports);
|
|
18
|
+
__exportStar(require("./handler-resource-settings"), exports);
|
|
19
|
+
__exportStar(require("./instantiate-resource"), exports);
|
|
20
|
+
__exportStar(require("./resource"), exports);
|
|
21
|
+
__exportStar(require("./resource-definition-resource-settings"), exports);
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InstantiateResource } from "@ldsg/resource";
|
|
2
|
+
import { ApplicationResource } from "./resource";
|
|
3
|
+
import { ApplicationResourceSettings } from "./types";
|
|
4
|
+
export declare const instantiateResource: InstantiateResource<ApplicationResourceSettings, ApplicationResource>;
|
|
5
|
+
//# sourceMappingURL=instantiate-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantiate-resource.d.ts","sourceRoot":"","sources":["../src/instantiate-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAEtD,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CACnD,2BAA2B,EAC3B,mBAAmB,CAWpB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instantiateResource = void 0;
|
|
4
|
+
const resource_1 = require("./resource");
|
|
5
|
+
const instantiateResource = (params) => {
|
|
6
|
+
const { resourceConstructorParams } = params;
|
|
7
|
+
const resource = new resource_1.ApplicationResource(resourceConstructorParams);
|
|
8
|
+
const res = {
|
|
9
|
+
resource,
|
|
10
|
+
};
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
exports.instantiateResource = instantiateResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-definition-resource-settings.d.ts","sourceRoot":"","sources":["../src/resource-definition-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAC;AAEpE,eAAO,MAAM,kCAAkC,EAAE,kCAM9C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resourceDefinitionResourceSettings = void 0;
|
|
4
|
+
exports.resourceDefinitionResourceSettings = {
|
|
5
|
+
title: "应用类型资源定义",
|
|
6
|
+
description: "",
|
|
7
|
+
kind: "APPLICATION",
|
|
8
|
+
subKinds: [],
|
|
9
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Resource } from "@ldsg/resource";
|
|
2
|
+
import { Express } from "express";
|
|
3
|
+
import { ApplicationResourceSettings } from "./types";
|
|
4
|
+
export declare class ApplicationResource extends Resource<ApplicationResourceSettings> {
|
|
5
|
+
createApp: () => Express;
|
|
6
|
+
start: () => void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAEtD,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,2BAA2B,CAAC;IAC5E,SAAS,EAAE,MAAM,OAAO,CAQtB;IAEF,KAAK,aAQH;CACH"}
|
package/dist/resource.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApplicationResource = void 0;
|
|
7
|
+
const resource_1 = require("@ldsg/resource");
|
|
8
|
+
const express_1 = __importDefault(require("express"));
|
|
9
|
+
class ApplicationResource extends resource_1.Resource {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.createApp = () => {
|
|
13
|
+
const app = (0, express_1.default)();
|
|
14
|
+
app.get("/", (req, res) => {
|
|
15
|
+
res.send("Hello, World!");
|
|
16
|
+
});
|
|
17
|
+
return app;
|
|
18
|
+
};
|
|
19
|
+
this.start = () => {
|
|
20
|
+
const app = this.createApp();
|
|
21
|
+
const port = process.env.PORT || 3000;
|
|
22
|
+
app.listen(port, () => {
|
|
23
|
+
console.log(`app listening on port ${port}`);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ApplicationResource = ApplicationResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.spec.d.ts","sourceRoot":"","sources":["../src/resource.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const supertest_1 = __importDefault(require("supertest"));
|
|
16
|
+
const resource_1 = require("./resource");
|
|
17
|
+
test("application", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const application = new resource_1.ApplicationResource({
|
|
19
|
+
id: "APPLICATION",
|
|
20
|
+
kind: "APPLICATION",
|
|
21
|
+
parentId: "ROOT",
|
|
22
|
+
settings: {
|
|
23
|
+
title: "应用",
|
|
24
|
+
description: "应用根资源",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const app = application.createApp();
|
|
28
|
+
const response = yield (0, supertest_1.default)(app).get("/");
|
|
29
|
+
expect(response.statusCode).toBe(200);
|
|
30
|
+
expect(response.text).toBe("Hello, World!");
|
|
31
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./resource-settings"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,WAAW,2BACf,SAAQ,QAAQ,CAAC,gBAAgB;CAAG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ldsg/application",
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/"
|
|
8
|
+
],
|
|
9
|
+
"types": "dist",
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "wanxger",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"express": "^4.18.2",
|
|
18
|
+
"@ldsg/handler": "0.1.0-alpha.4",
|
|
19
|
+
"@ldsg/resource": "0.1.0-alpha.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/express": "^4.17.17",
|
|
23
|
+
"@types/node": "^20.13.0",
|
|
24
|
+
"@types/supertest": "^6.0.0",
|
|
25
|
+
"supertest": "^6.3.4"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json"
|
|
29
|
+
}
|
|
30
|
+
}
|