@ldsg/application 0.1.0-alpha.17 → 0.1.0-alpha.18
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/README.md +1 -1
- package/dist/handler.d.ts +2 -2
- package/dist/handler.d.ts.map +1 -1
- package/dist/instantiate-resource.d.ts +2 -2
- package/dist/instantiate-resource.d.ts.map +1 -1
- package/dist/resource.d.ts +10 -3
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +30 -4
- package/dist/resource.spec.js +4 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/specific-resource-settings.d.ts +8 -0
- package/dist/types/specific-resource-settings.d.ts.map +1 -0
- package/package.json +7 -6
- package/dist/types/resource-settings.d.ts +0 -4
- package/dist/types/resource-settings.d.ts.map +0 -1
- /package/dist/types/{resource-settings.js → specific-resource-settings.js} +0 -0
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# Application Resource
|
|
1
|
+
# LDSG Application Resource
|
package/dist/handler.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Handler } from "@ldsg/handler";
|
|
2
2
|
import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
|
|
3
3
|
import { ApplicationResource } from "./resource";
|
|
4
|
-
import {
|
|
4
|
+
import { ApplicationSpecificResourceSettings } from "./types";
|
|
5
5
|
export declare const handler: Handler<[
|
|
6
|
-
InstantiateResourceParams<
|
|
6
|
+
InstantiateResourceParams<ApplicationSpecificResourceSettings>
|
|
7
7
|
], InstantiateResourceRes<ApplicationResource>>;
|
|
8
8
|
//# sourceMappingURL=handler.d.ts.map
|
package/dist/handler.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B;IAAC,yBAAyB,CAAC,mCAAmC,CAAC;CAAC,EAChE,sBAAsB,CAAC,mBAAmB,CAAC,CACtB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstantiateResource } from "@ldsg/resource";
|
|
2
2
|
import { ApplicationResource } from "./resource";
|
|
3
|
-
import {
|
|
4
|
-
export declare const instantiateResource: InstantiateResource<
|
|
3
|
+
import { ApplicationSpecificResourceSettings } from "./types";
|
|
4
|
+
export declare const instantiateResource: InstantiateResource<ApplicationSpecificResourceSettings, ApplicationResource>;
|
|
5
5
|
//# sourceMappingURL=instantiate-resource.d.ts.map
|
|
@@ -1 +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,
|
|
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,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CACnD,mCAAmC,EACnC,mBAAmB,CAWpB,CAAC"}
|
package/dist/resource.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { Resource } from "@ldsg/resource";
|
|
2
2
|
import { Express } from "express";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { ApplicationSpecificResourceSettings } from "./types";
|
|
4
|
+
type CreateExpressApp = () => Promise<Express>;
|
|
5
|
+
interface ExtendExpressAppParams {
|
|
6
|
+
app: Express;
|
|
6
7
|
}
|
|
8
|
+
export type ExtendExpressApp = (params: ExtendExpressAppParams) => Promise<void>;
|
|
9
|
+
export declare class ApplicationResource extends Resource<ApplicationSpecificResourceSettings> {
|
|
10
|
+
createExpressApp: CreateExpressApp;
|
|
11
|
+
extendExpressApp: ExtendExpressApp;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
7
14
|
//# sourceMappingURL=resource.d.ts.map
|
package/dist/resource.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/C,UAAU,sBAAsB;IAC9B,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG,CAC7B,MAAM,EAAE,sBAAsB,KAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,mCAAmC,CAAC;IACpF,gBAAgB,EAAE,gBAAgB,CAQhC;IAEF,gBAAgB,EAAE,gBAAgB,CA2BhC;CACH"}
|
package/dist/resource.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -9,13 +18,30 @@ const express_1 = __importDefault(require("express"));
|
|
|
9
18
|
class ApplicationResource extends resource_1.Resource {
|
|
10
19
|
constructor() {
|
|
11
20
|
super(...arguments);
|
|
12
|
-
this.
|
|
21
|
+
this.createExpressApp = () => __awaiter(this, void 0, void 0, function* () {
|
|
13
22
|
const app = (0, express_1.default)();
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
yield this.extendExpressApp({
|
|
24
|
+
app,
|
|
16
25
|
});
|
|
17
26
|
return app;
|
|
18
|
-
};
|
|
27
|
+
});
|
|
28
|
+
this.extendExpressApp = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const { app } = params;
|
|
30
|
+
const { id, settings: { name }, getFilteredResources, } = this;
|
|
31
|
+
app.get("/", (req, res) => {
|
|
32
|
+
res.send(`Hello, ${name !== null && name !== void 0 ? name : "World"}!`);
|
|
33
|
+
});
|
|
34
|
+
const getFilteredResourcesRes = getFilteredResources({
|
|
35
|
+
parentId: id,
|
|
36
|
+
});
|
|
37
|
+
const { resources } = getFilteredResourcesRes;
|
|
38
|
+
resources.forEach((resource) => {
|
|
39
|
+
if ("extendExpressApp" in resource &&
|
|
40
|
+
typeof resource.extendExpressApp === "function") {
|
|
41
|
+
resource.extendExpressApp(params);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
19
45
|
}
|
|
20
46
|
}
|
|
21
47
|
exports.ApplicationResource = ApplicationResource;
|
package/dist/resource.spec.js
CHANGED
|
@@ -16,16 +16,17 @@ const supertest_1 = __importDefault(require("supertest"));
|
|
|
16
16
|
const resource_1 = require("./resource");
|
|
17
17
|
test("application", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const application = new resource_1.ApplicationResource({
|
|
19
|
-
id: "
|
|
19
|
+
id: "application",
|
|
20
20
|
kind: "APPLICATION",
|
|
21
21
|
parentId: "ROOT",
|
|
22
22
|
settings: {
|
|
23
23
|
title: "应用",
|
|
24
24
|
description: "应用根资源",
|
|
25
|
+
name: "测试应用",
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
|
-
const app = application.
|
|
28
|
+
const app = yield application.createExpressApp();
|
|
28
29
|
const response = yield (0, supertest_1.default)(app).get("/");
|
|
29
30
|
expect(response.statusCode).toBe(200);
|
|
30
|
-
expect(response.text).toBe("Hello,
|
|
31
|
+
expect(response.text).toBe("Hello, 测试应用!");
|
|
31
32
|
}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./resource-settings";
|
|
1
|
+
export * from "./specific-resource-settings";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./resource-settings"), exports);
|
|
17
|
+
__exportStar(require("./specific-resource-settings"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,mCACf,SAAQ,wBAAwB;IAChC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/application",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"express": "^4.18.2",
|
|
18
|
-
"@ldsg/
|
|
19
|
-
"@ldsg/resource
|
|
20
|
-
"@ldsg/
|
|
21
|
-
"@ldsg/
|
|
18
|
+
"@ldsg/handler": "0.1.0-alpha.18",
|
|
19
|
+
"@ldsg/resource": "0.1.0-alpha.18",
|
|
20
|
+
"@ldsg/resource-definition": "0.1.0-alpha.18",
|
|
21
|
+
"@ldsg/types": "0.1.0-alpha.18"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/express": "^4.17.17",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"supertest": "^6.3.4"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "
|
|
30
|
+
"build": "pnpm clean && tsc --project tsconfig.build.json",
|
|
31
|
+
"clean": "rm -rf dist"
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB;CAAG"}
|
|
File without changes
|