@ldsg/object-field 0.1.0-alpha.18 → 0.2.0

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/__tests__/unit.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const field_type_1 = require("@ldsg/field-type");
4
+ const handler_1 = require("@ldsg/handler");
5
+ const resource_1 = require("../resource");
6
+ const handler = (params) => {
7
+ const { fieldProperties, platform } = params;
8
+ const { max } = fieldProperties;
9
+ let res;
10
+ switch (platform) {
11
+ case "mongoose": {
12
+ res = {
13
+ type: "String",
14
+ ...(max
15
+ ? {
16
+ maxLength: max,
17
+ }
18
+ : {}),
19
+ };
20
+ break;
21
+ }
22
+ default: {
23
+ res = {};
24
+ break;
25
+ }
26
+ }
27
+ return res;
28
+ };
29
+ test("object field", () => {
30
+ new handler_1.HandlerResource(field_type_1.stringFieldTypeHandlerResourceRecord);
31
+ new field_type_1.FieldTypeResource(field_type_1.stringFieldTypeResourceRecord);
32
+ const objectFieldResource = new resource_1.ObjectFieldResource({
33
+ id: "object-field",
34
+ kind: "object_field",
35
+ parentId: "application",
36
+ settings: {
37
+ title: "测试字段",
38
+ description: "",
39
+ name: "test",
40
+ fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
41
+ properties: {
42
+ max: "10",
43
+ },
44
+ },
45
+ });
46
+ const getFieldInfoRes = objectFieldResource.getFieldInfo();
47
+ expect(getFieldInfoRes).toMatchSnapshot();
48
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,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,eAAO,MAAM,iCAAiC,EAAE,uBAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,+BAQ9C,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAClB,CAAC;AAE3C,eAAO,MAAM,8CAA8C,EAAE,0CAI1D,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,iCAAiC,EAAE,uBAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,+BAQ9C,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAClB,CAAC;AAE3C,eAAO,MAAM,8CAA8C,EAAE,0CAI1D,CAAC"}
package/dist/constants.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
4
+ const object_1 = require("@ldsg/object");
4
5
  exports.HANDLER_GENERAL_RESOURCE_SETTINGS = {
5
6
  title: "对象字段类型资源处理程序",
6
7
  description: "",
@@ -20,6 +21,6 @@ exports.HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
20
21
  };
21
22
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = { title: "对象字段类型资源定义", description: "" };
22
23
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
23
- kind: "OBJECT_FIELD",
24
- subKinds: [],
24
+ kind: "object_field",
25
+ parentKind: object_1.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS.kind,
25
26
  };
@@ -1,5 +1,7 @@
1
+ import { GetFieldInfo } from "@ldsg/object";
1
2
  import { Resource } from "@ldsg/resource";
2
3
  import { ObjectFieldSpecificResourceSettings } from "./types";
3
4
  export declare class ObjectFieldResource extends Resource<ObjectFieldSpecificResourceSettings> {
5
+ getFieldInfo: GetFieldInfo;
4
6
  }
5
7
  //# sourceMappingURL=resource.d.ts.map
@@ -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,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,mCAAmC,CAAC;CAAG"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,mCAAmC,CAAC;IACpF,YAAY,EAAE,YAAY,CA6BxB;CACH"}
package/dist/resource.js CHANGED
@@ -3,5 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectFieldResource = void 0;
4
4
  const resource_1 = require("@ldsg/resource");
5
5
  class ObjectFieldResource extends resource_1.Resource {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.getFieldInfo = (params) => {
9
+ const { id, settings: { title, description, name, properties }, getResourcesFromSettings, } = this;
10
+ const { fieldTypeResource } = getResourcesFromSettings();
11
+ const { fieldTypeInfo } = fieldTypeResource.getFieldTypeInfo({
12
+ ...params,
13
+ fieldProperties: properties,
14
+ });
15
+ const fieldInfo = {
16
+ id,
17
+ title,
18
+ description,
19
+ name,
20
+ typeInfo: fieldTypeInfo,
21
+ };
22
+ const res = {
23
+ fieldInfo,
24
+ };
25
+ return res;
26
+ };
27
+ }
6
28
  }
7
29
  exports.ObjectFieldResource = ObjectFieldResource;
@@ -1,4 +1,16 @@
1
1
  import { SpecificResourceSettings } from "@ldsg/types";
2
2
  export interface ObjectFieldSpecificResourceSettings extends SpecificResourceSettings {
3
+ /**
4
+ * Field Name
5
+ */
6
+ name: string;
7
+ /**
8
+ * Field Type Resource ID
9
+ */
10
+ fieldTypeResourceId: string;
11
+ /**
12
+ * Field Properties
13
+ */
14
+ properties: any;
3
15
  }
4
16
  //# sourceMappingURL=specific-resource-settings.d.ts.map
@@ -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;CAAG"}
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,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,UAAU,EAAE,GAAG,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldsg/object-field",
3
- "version": "0.1.0-alpha.18",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -14,16 +14,14 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "graphql-yoga": "^5.13.4",
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"
17
+ "@ldsg/handler": "0.2.0",
18
+ "@ldsg/resource": "0.2.0",
19
+ "@ldsg/resource-definition": "0.2.0"
21
20
  },
22
21
  "devDependencies": {
23
- "@types/supertest": "^6.0.0",
24
- "supertest": "^6.3.4",
25
- "@ldsg/types": "0.1.0-alpha.18",
26
- "@ldsg/application": "0.1.0-alpha.18"
22
+ "@ldsg/field-type": "0.2.0",
23
+ "@ldsg/types": "0.2.0",
24
+ "@ldsg/object": "0.2.0"
27
25
  },
28
26
  "scripts": {
29
27
  "build": "pnpm clean && tsc --project tsconfig.build.json",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=resource.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource.spec.d.ts","sourceRoot":"","sources":["../src/resource.spec.ts"],"names":[],"mappings":""}
@@ -1,45 +0,0 @@
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 application_1 = require("@ldsg/application");
16
- const supertest_1 = __importDefault(require("supertest"));
17
- const resource_1 = require("./resource");
18
- test("application", () => __awaiter(void 0, void 0, void 0, function* () {
19
- const applicationResource = new application_1.ApplicationResource({
20
- id: "application",
21
- kind: "APPLICATION",
22
- parentId: "ROOT",
23
- settings: {
24
- title: "应用",
25
- description: "应用根资源",
26
- name: "测试应用",
27
- },
28
- });
29
- new resource_1.ObjectFieldResource({
30
- id: "object-field",
31
- kind: "OBJECT_FIELD",
32
- parentId: "application",
33
- settings: {
34
- title: "",
35
- description: "",
36
- },
37
- });
38
- const app = yield applicationResource.createExpressApp();
39
- const response = yield (0, supertest_1.default)(app).get("/");
40
- expect(response.statusCode).toBe(200);
41
- expect(response.text).toBe("Hello, 测试应用!");
42
- const response2 = yield (0, supertest_1.default)(app).get("/test-objectfield");
43
- expect(response2.statusCode).toBe(200);
44
- expect(response2.text).toMatchSnapshot();
45
- }));