@ldsg/application 0.3.9 → 0.3.17

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.
@@ -1,5 +1,5 @@
1
- import { Resource } from "@ldsg/resource";
2
- import { ExtendExpressApp } from "../resource";
1
+ import { Resource } from '@ldsg/resource';
2
+ import { ExtendExpressApp } from '../resource';
3
3
  export declare class AResource extends Resource {
4
4
  extendExpressApp: ExtendExpressApp;
5
5
  }
@@ -12,35 +12,35 @@ class AResource extends resource_1.Resource {
12
12
  super(...arguments);
13
13
  this.extendExpressApp = (params) => {
14
14
  const { app } = params;
15
- app.get("/", (req, res) => {
16
- res.send("Hello, World!");
15
+ app.get('/', (req, res) => {
16
+ res.send('Hello, World!');
17
17
  });
18
18
  };
19
19
  }
20
20
  }
21
21
  exports.AResource = AResource;
22
- test("application", async () => {
22
+ test('application', async () => {
23
23
  const application = new resource_2.ApplicationResource({
24
- id: "test-application",
25
- kind: "application",
26
- parentId: "ROOT",
24
+ id: 'test-application',
25
+ kind: 'application',
26
+ parentId: 'ROOT',
27
27
  settings: {
28
- title: "测试应用",
29
- description: "",
30
- name: "",
31
- },
28
+ title: '测试应用',
29
+ description: '',
30
+ name: ''
31
+ }
32
32
  });
33
33
  new AResource({
34
- id: "test-a",
35
- kind: "a",
36
- parentId: "test-application",
34
+ id: 'test-a',
35
+ kind: 'a',
36
+ parentId: 'test-application',
37
37
  settings: {
38
- title: "",
39
- description: "",
40
- },
38
+ title: '',
39
+ description: ''
40
+ }
41
41
  });
42
42
  const app = application.createExpressApp();
43
- const response = await (0, supertest_1.default)(app).get("/");
43
+ const response = await (0, supertest_1.default)(app).get('/');
44
44
  expect(response.statusCode).toBe(200);
45
- expect(response.text).toBe("Hello, World!");
45
+ expect(response.text).toBe('Hello, World!');
46
46
  });
@@ -1,6 +1,6 @@
1
- import { HandlerSpecificResourceSettings } from "@ldsg/handler";
2
- import { ResourceDefinitionSpecificResourceSettings } from "@ldsg/resource-definition";
3
- import { GeneralResourceSettings } from "@ldsg/types";
1
+ import { HandlerSpecificResourceSettings } from '@ldsg/handler';
2
+ import { ResourceDefinitionSpecificResourceSettings } from '@ldsg/resource-definition';
3
+ import { GeneralResourceSettings } from '@ldsg/types';
4
4
  /**
5
5
  * Instantiate Resource Handler General Resource Settings
6
6
  * 实例化资源处理程序普通资源配置
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAIlE,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBACtB,CAAC;AAEvC,eAAO,MAAM,8CAA8C,EAAE,0CAI1D,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAOrE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG5D,CAAC"}
package/dist/constants.js CHANGED
@@ -7,8 +7,8 @@ const constants_1 = require("@ldsg/constants");
7
7
  * 实例化资源处理程序普通资源配置
8
8
  */
9
9
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
10
- title: "应用实例化资源处理程序",
11
- description: "",
10
+ title: '应用实例化资源处理程序',
11
+ description: ''
12
12
  };
13
13
  /**
14
14
  * Instantiate Resource Handler Specific Resource Settings
@@ -19,12 +19,15 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
19
19
  code: `export * from "@ldsg/application";`,
20
20
  dependencies: [
21
21
  {
22
- name: "@ldsg/application",
23
- },
24
- ],
22
+ name: '@ldsg/application'
23
+ }
24
+ ]
25
+ };
26
+ exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
27
+ title: '应用资源定义',
28
+ description: ''
25
29
  };
26
- exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = { title: "应用资源定义", description: "" };
27
30
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
28
- kind: "application",
29
- parentKind: constants_1.ROOT_RESOURCE_KIND,
31
+ kind: 'application',
32
+ parentKind: constants_1.ROOT_RESOURCE_KIND
30
33
  };
package/dist/handler.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { Handler } from "@ldsg/handler";
2
- import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
3
- import { ApplicationResource } from "./resource";
4
- import { ApplicationSpecificResourceSettings } from "./types";
5
- export declare const handler: Handler<[
6
- InstantiateResourceParams<ApplicationSpecificResourceSettings>
7
- ], InstantiateResourceRes<ApplicationResource>>;
1
+ import { Handler } from '@ldsg/handler';
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
+ import { ApplicationResource } from './resource';
4
+ import { ApplicationSpecificResourceSettings } from './types';
5
+ export declare const handler: Handler<InstantiateResourceParams<ApplicationSpecificResourceSettings>, InstantiateResourceRes<ApplicationResource>>;
8
6
  //# sourceMappingURL=handler.d.ts.map
@@ -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,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
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B,yBAAyB,CAAC,mCAAmC,CAAC,EAC9D,sBAAsB,CAAC,mBAAmB,CAAC,CACtB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./constants";
2
- export * from "./handler";
3
- export * from "./instantiate-resource";
4
- export * from "./resource";
5
- export * from "./types";
1
+ export * from './constants';
2
+ export * from './handler';
3
+ export * from './instantiate-resource';
4
+ export * from './resource';
5
+ export * from './types';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import { InstantiateResource } from "@ldsg/resource";
2
- import { ApplicationResource } from "./resource";
3
- import { ApplicationSpecificResourceSettings } from "./types";
1
+ import { InstantiateResource } from '@ldsg/resource';
2
+ import { ApplicationResource } from './resource';
3
+ import { ApplicationSpecificResourceSettings } from './types';
4
4
  export declare const instantiateResource: InstantiateResource<ApplicationSpecificResourceSettings, ApplicationResource>;
5
5
  //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -6,7 +6,7 @@ const instantiateResource = (params) => {
6
6
  const { resourceConstructorParams } = params;
7
7
  const resource = new resource_1.ApplicationResource(resourceConstructorParams);
8
8
  const res = {
9
- resource,
9
+ resource
10
10
  };
11
11
  return res;
12
12
  };
@@ -1,6 +1,6 @@
1
- import { Resource } from "@ldsg/resource";
2
- import { Express } from "express";
3
- import { ApplicationSpecificResourceSettings } from "./types";
1
+ import { Resource } from '@ldsg/resource';
2
+ import { Express } from 'express';
3
+ import { ApplicationSpecificResourceSettings } from './types';
4
4
  type CreateExpressApp = () => Express;
5
5
  interface ExtendExpressAppParams {
6
6
  app: Express;
@@ -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,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC;AAEtC,UAAU,sBAAsB;IAC9B,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAC;AAExE,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,mCAAmC,CAAC;IACpF,gBAAgB,EAAE,gBAAgB,CAQhC;IAEF,gBAAgB,EAAE,gBAAgB,CAchC;CACH"}
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;AAEtC,UAAU,sBAAsB;IAC9B,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAC;AAExE,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,mCAAmC,CAAC;IACpF,gBAAgB,EAAE,gBAAgB,CAahC;IAEF,gBAAgB,EAAE,gBAAgB,CAchC;CACH"}
package/dist/resource.js CHANGED
@@ -11,15 +11,19 @@ class ApplicationResource extends resource_1.Resource {
11
11
  super(...arguments);
12
12
  this.createExpressApp = () => {
13
13
  const app = (0, express_1.default)();
14
+ // 中间件:解析 application/x-www-form-urlencoded
15
+ app.use(express_1.default.urlencoded({ extended: true }));
16
+ // 中间件:解析 application/json
17
+ app.use(express_1.default.json());
14
18
  this.extendExpressApp({
15
- app,
19
+ app
16
20
  });
17
21
  return app;
18
22
  };
19
23
  this.extendExpressApp = (params) => {
20
24
  const { id, getFilteredResources } = this;
21
25
  const getFilteredResourcesRes = getFilteredResources({
22
- parentId: id,
26
+ parentId: id
23
27
  });
24
28
  const { resources } = getFilteredResourcesRes;
25
29
  resources.forEach((resource) => {
@@ -1,2 +1,2 @@
1
- export * from "./specific-resource-settings";
1
+ export * from './specific-resource-settings';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { SpecificResourceSettings } from "@ldsg/types";
1
+ import { SpecificResourceSettings } from '@ldsg/types';
2
2
  export interface ApplicationSpecificResourceSettings extends SpecificResourceSettings {
3
3
  /**
4
4
  * Application Name
@@ -1 +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"}
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,mCAAoC,SAAQ,wBAAwB;IACnF;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
package/package.json CHANGED
@@ -1,33 +1,40 @@
1
1
  {
2
2
  "name": "@ldsg/application",
3
- "version": "0.3.9",
3
+ "version": "0.3.17",
4
4
  "description": "",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "author": "wanxger",
5
8
  "main": "dist/index.js",
9
+ "types": "dist",
6
10
  "files": [
7
11
  "dist/"
8
12
  ],
9
- "types": "dist",
10
- "keywords": [],
11
- "author": "wanxger",
12
- "license": "MIT",
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
13
  "dependencies": {
17
14
  "express": "^4.18.2",
18
- "@ldsg/resource": "0.3.9",
19
- "@ldsg/resource-definition": "0.3.9",
20
- "@ldsg/handler": "0.3.9",
21
- "@ldsg/types": "0.3.9"
15
+ "@ldsg/constants": "0.3.17",
16
+ "@ldsg/handler": "0.3.17",
17
+ "@ldsg/resource": "0.3.17",
18
+ "@ldsg/resource-definition": "0.3.17",
19
+ "@ldsg/types": "0.3.17"
22
20
  },
23
21
  "devDependencies": {
24
22
  "@types/express": "^4.17.17",
23
+ "@types/jest": "^29.5.2",
25
24
  "@types/node": "^20.13.0",
26
25
  "@types/supertest": "^6.0.0",
27
- "supertest": "^6.3.4"
26
+ "jest": "^29.5.0",
27
+ "supertest": "^6.3.4",
28
+ "ts-jest": "^29.1.5",
29
+ "ts-node": "^10.9.2",
30
+ "typescript": "^5.8.3"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
28
34
  },
29
35
  "scripts": {
30
36
  "build": "tsc --project tsconfig.build.json",
31
- "clean": "rm -rf dist"
37
+ "clean": "rm -rf dist",
38
+ "test": "jest"
32
39
  }
33
40
  }