@ldsg/object-field 0.3.31 → 0.3.33

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.
@@ -3,22 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const field_type_1 = require("@ldsg/field-type");
4
4
  const handler_1 = require("@ldsg/handler");
5
5
  const resource_1 = require("../resource");
6
- test('object field', () => {
6
+ test("object field", () => {
7
7
  new handler_1.HandlerResource(field_type_1.stringFieldTypeHandlerResourceRecord);
8
8
  new field_type_1.FieldTypeResource(field_type_1.stringFieldTypeResourceRecord);
9
9
  const objectFieldResource = new resource_1.ObjectFieldResource({
10
- id: 'object-field',
11
- kind: 'object_field',
12
- parentId: 'application',
10
+ id: "object-field",
11
+ kind: "object_field",
12
+ parentId: "application",
13
13
  settings: {
14
- title: '测试字段',
15
- description: '',
16
- name: 'test',
14
+ title: "测试字段",
15
+ description: "",
16
+ slug: "test",
17
17
  fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
18
18
  properties: {
19
- max: '10'
20
- }
21
- }
19
+ max: "10",
20
+ },
21
+ },
22
22
  });
23
23
  const getFieldInfoRes = objectFieldResource.getFieldInfo();
24
24
  expect(getFieldInfoRes).toMatchSnapshot();
@@ -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":"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;;;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,0CAE5D,CAAC"}
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;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,CAAC"}
package/dist/constants.js CHANGED
@@ -6,8 +6,8 @@ exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINI
6
6
  * 实例化资源处理程序普通资源配置
7
7
  */
8
8
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
9
- title: '对象字段实例化资源处理程序',
10
- description: ''
9
+ title: "对象字段实例化资源处理程序",
10
+ description: "",
11
11
  };
12
12
  /**
13
13
  * Instantiate Resource Handler Specific Resource Settings
@@ -18,14 +18,14 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
18
18
  code: `export * from "@ldsg/object-field";`,
19
19
  dependencies: [
20
20
  {
21
- name: '@ldsg/object-field'
22
- }
23
- ]
21
+ name: "@ldsg/object-field",
22
+ },
23
+ ],
24
24
  };
25
25
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
26
- title: '对象字段资源定义',
27
- description: ''
26
+ title: "对象字段资源定义",
27
+ description: "",
28
28
  };
29
29
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
30
- kind: 'object_field'
30
+ kind: "object_field",
31
31
  };
package/dist/handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Handler, HandlerExtendedResourceSettings } from '@ldsg/handler';
2
- import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
- import { ObjectFieldResource } from './resource';
4
- import { ObjectFieldSpecificResourceSettings } from './types';
1
+ import { Handler, HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
3
+ import { ObjectFieldResource } from "./resource";
4
+ import { ObjectFieldSpecificResourceSettings } from "./types";
5
5
  export declare const handler: Handler<InstantiateResourceParams<HandlerExtendedResourceSettings<ObjectFieldSpecificResourceSettings>>, InstantiateResourceRes<ObjectFieldResource>>;
6
6
  //# sourceMappingURL=handler.d.ts.map
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,6 +1,6 @@
1
- import { HandlerExtendedResourceSettings } from '@ldsg/handler';
2
- import { InstantiateResource } from '@ldsg/resource';
3
- import { ObjectFieldResource } from './resource';
4
- import { ObjectFieldSpecificResourceSettings } from './types';
1
+ import { HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResource } from "@ldsg/resource";
3
+ import { ObjectFieldResource } from "./resource";
4
+ import { ObjectFieldSpecificResourceSettings } from "./types";
5
5
  export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<ObjectFieldSpecificResourceSettings>, ObjectFieldResource>;
6
6
  //# 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.ObjectFieldResource(resourceConstructorParams);
8
8
  const res = {
9
- resource
9
+ resource,
10
10
  };
11
11
  return res;
12
12
  };
@@ -1,6 +1,6 @@
1
- import { GetFieldInfo } from '@ldsg/object';
2
- import { Resource } from '@ldsg/resource';
3
- import { ObjectFieldSpecificResourceSettings } from './types';
1
+ import { GetFieldInfo } from "@ldsg/object";
2
+ import { Resource } from "@ldsg/resource";
3
+ import { ObjectFieldSpecificResourceSettings } from "./types";
4
4
  export declare class ObjectFieldResource extends Resource<ObjectFieldSpecificResourceSettings> {
5
5
  getFieldInfo: GetFieldInfo;
6
6
  }
@@ -1 +1 @@
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,CAkDxB;CACH"}
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;AAE1C,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,mCAAmC,CAAC;IACpF,YAAY,EAAE,YAAY,CAuDxB;CACH"}
package/dist/resource.js CHANGED
@@ -1,29 +1,36 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ObjectFieldResource = void 0;
4
7
  const field_type_1 = require("@ldsg/field-type");
5
8
  const resource_1 = require("@ldsg/resource");
9
+ const lodash_1 = __importDefault(require("lodash"));
6
10
  class ObjectFieldResource extends resource_1.Resource {
7
11
  constructor() {
8
12
  super(...arguments);
9
13
  this.getFieldInfo = (params) => {
10
- const { id, settings: { title, description, name, properties }, getResourcesFromSettings, getFilteredResources } = this;
14
+ const { id, settings: { title, description, slug, properties }, getResourcesFromSettings, getFilteredResources, } = this;
15
+ const name = lodash_1.default.camelCase(slug);
16
+ const resolvedDbKey = lodash_1.default.snakeCase(slug);
11
17
  const { fieldTypeResource } = getResourcesFromSettings();
12
18
  const { fieldTypeInfo } = fieldTypeResource.getFieldTypeInfo({
13
19
  ...params,
14
- fieldProperties: properties
20
+ fieldProperties: properties,
15
21
  });
16
22
  const fieldInfo = {
17
23
  id,
18
24
  title,
19
25
  description,
20
26
  name,
21
- typeInfo: fieldTypeInfo
27
+ dbKey: resolvedDbKey,
28
+ typeInfo: fieldTypeInfo,
22
29
  };
23
30
  const commonType = fieldTypeInfo.platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
24
- if ((commonType === null || commonType === void 0 ? void 0 : commonType.type) === 'object' || (commonType === null || commonType === void 0 ? void 0 : commonType.type) === 'array') {
31
+ if ((commonType === null || commonType === void 0 ? void 0 : commonType.type) === "object" || (commonType === null || commonType === void 0 ? void 0 : commonType.type) === "array") {
25
32
  const { resources } = getFilteredResources({
26
- parentId: this.id
33
+ parentId: this.id,
27
34
  });
28
35
  if (resources.length > 0) {
29
36
  const nestedFieldInfoList = [];
@@ -38,7 +45,7 @@ class ObjectFieldResource extends resource_1.Resource {
38
45
  }
39
46
  }
40
47
  const res = {
41
- fieldInfo
48
+ fieldInfo,
42
49
  };
43
50
  return res;
44
51
  };
@@ -1,2 +1,2 @@
1
- export * from './specific-resource-settings';
1
+ export * from "./specific-resource-settings";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,11 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const ObjectFieldSpecificResourceSettingsSchema: z.ZodObject<{
3
- name: z.ZodString;
3
+ slug: z.ZodString;
4
4
  fieldTypeResourceId: z.ZodString;
5
5
  properties: z.ZodAny;
6
6
  }, z.core.$catchall<z.ZodAny>>;
7
7
  export declare const SpecificResourceSettingsSchema: z.ZodObject<{
8
- name: z.ZodString;
8
+ slug: z.ZodString;
9
9
  fieldTypeResourceId: z.ZodString;
10
10
  properties: z.ZodAny;
11
11
  }, z.core.$catchall<z.ZodAny>>;
@@ -1 +1 @@
1
- {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,yCAAyC;;;;8BAiBlC,CAAC;AAErB,eAAO,MAAM,8BAA8B;;;;8BAA4C,CAAC;AACxF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAC"}
1
+ {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,yCAAyC;;;;8BAkBlC,CAAC;AAErB,eAAO,MAAM,8BAA8B;;;;8BAA4C,CAAC;AACxF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,yCAAyC,CACjD,CAAC"}
@@ -5,9 +5,10 @@ const zod_1 = require("zod");
5
5
  exports.ObjectFieldSpecificResourceSettingsSchema = zod_1.z
6
6
  .object({
7
7
  /**
8
- * Field Name
8
+ * Stable identifier (kebab-case, e.g. "user-id")
9
+ * Primary source for deriving name and dbKey.
9
10
  */
10
- name: zod_1.z.string(),
11
+ slug: zod_1.z.string(),
11
12
  /**
12
13
  * Field Type Resource ID
13
14
  */
@@ -15,7 +16,7 @@ exports.ObjectFieldSpecificResourceSettingsSchema = zod_1.z
15
16
  /**
16
17
  * Field Properties
17
18
  */
18
- properties: zod_1.z.any()
19
+ properties: zod_1.z.any(),
19
20
  })
20
21
  .catchall(zod_1.z.any());
21
22
  exports.SpecificResourceSettingsSchema = exports.ObjectFieldSpecificResourceSettingsSchema;
package/package.json CHANGED
@@ -1,38 +1,42 @@
1
1
  {
2
2
  "name": "@ldsg/object-field",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "author": "wanxger",
8
- "main": "dist/index.js",
9
- "types": "dist",
10
8
  "files": [
11
9
  "dist/"
12
10
  ],
11
+ "main": "dist/index.js",
12
+ "types": "dist",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
13
16
  "dependencies": {
17
+ "lodash": "^4.17.21",
14
18
  "zod": "^4.1.11",
15
- "@ldsg/handler": "0.3.31",
16
- "@ldsg/field-type": "0.3.31",
17
- "@ldsg/resource-definition": "0.3.31",
18
- "@ldsg/resource": "0.3.31"
19
+ "@ldsg/field-type": "0.3.33",
20
+ "@ldsg/handler": "0.3.33",
21
+ "@ldsg/resource": "0.3.33",
22
+ "@ldsg/resource-definition": "0.3.33"
19
23
  },
20
24
  "devDependencies": {
21
25
  "@types/jest": "^29.5.2",
26
+ "@types/lodash": "^4.14.202",
22
27
  "jest": "^29.5.0",
23
28
  "supertest": "^6.3.4",
24
29
  "ts-jest": "^29.1.5",
25
30
  "ts-node": "^10.9.2",
26
31
  "typescript": "^5.8.3",
27
- "@ldsg/object": "0.3.31",
28
- "@ldsg/types": "0.3.31"
29
- },
30
- "publishConfig": {
31
- "access": "public"
32
+ "@ldsg/object": "0.3.33",
33
+ "@ldsg/types": "0.3.33"
32
34
  },
33
35
  "scripts": {
34
36
  "build": "tsc --project tsconfig.build.json",
35
37
  "clean": "rm -rf dist",
38
+ "format": "oxfmt --write src/",
39
+ "lint": "oxlint src/",
36
40
  "test": "jest"
37
41
  }
38
42
  }