@ldsg/tables 0.3.38 → 0.3.41

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.
@@ -14,4 +14,8 @@ export declare const INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS: Gen
14
14
  export declare const INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS: HandlerSpecificResourceSettings;
15
15
  export declare const RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
16
16
  export declare const RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS: ResourceDefinitionSpecificResourceSettings;
17
+ /**
18
+ * 表格资源类型
19
+ */
20
+ export declare const TABLE_RESOURCE_KIND = "table";
17
21
  //# sourceMappingURL=constants.d.ts.map
@@ -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,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,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,uBAIpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAI3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAU,CAAC"}
package/dist/constants.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
3
+ exports.TABLE_RESOURCE_KIND = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
4
4
  /**
5
5
  * Instantiate Resource Handler General Resource Settings
6
6
  * 实例化资源处理程序普通资源配置
7
7
  */
8
8
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
9
+ slug: "tables-instantiate-resource-handler",
9
10
  title: "表格组实例化资源处理程序",
10
11
  description: "",
11
12
  };
@@ -23,9 +24,14 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
23
24
  ],
24
25
  };
25
26
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
27
+ slug: "tables-resource-definition",
26
28
  title: "表格组资源定义",
27
29
  description: "",
28
30
  };
29
31
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
30
32
  kind: "tables",
31
33
  };
34
+ /**
35
+ * 表格资源类型
36
+ */
37
+ exports.TABLE_RESOURCE_KIND = "table";
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAgB,SAAS,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAElF,OAAO,EAAE,cAAc,EAAuB,MAAM,gCAAgC,CAAC;AAErF,UAAU,mBAAmB;IAC3B;;OAEG;IACH,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B;AAED,KAAK,gBAAgB,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,mBAAmB,CAAC;AAE1E,qBAAa,cAAe,SAAQ,QAAQ,CAAC,8BAA8B,CAAC;IAC1E,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,gBAAgB,EAAE,gBAAgB,CAoBhC;IAEF,mBAAmB,EAAE,mBAAmB,CAgBtC;CACH"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAgB,SAAS,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAElF,OAAO,EAAE,cAAc,EAAuB,MAAM,gCAAgC,CAAC;AAGrF,UAAU,mBAAmB;IAC3B;;OAEG;IACH,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B;AAED,KAAK,gBAAgB,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,mBAAmB,CAAC;AAE1E,qBAAa,cAAe,SAAQ,QAAQ,CAAC,8BAA8B,CAAC;IAC1E,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,gBAAgB,EAAE,gBAAgB,CAiBhC;IAEF,mBAAmB,EAAE,mBAAmB,CAgBtC;CACH"}
package/dist/resource.js CHANGED
@@ -1,26 +1,21 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.TablesResource = void 0;
7
4
  const resource_1 = require("@ldsg/resource");
8
- const lodash_1 = __importDefault(require("lodash"));
9
5
  const add_query_fields_1 = require("./utils/add-query-fields");
10
6
  const handle_table_info_list_1 = require("./utils/handle-table-info-list");
7
+ const constants_1 = require("./constants");
11
8
  class TablesResource extends resource_1.Resource {
12
9
  constructor() {
13
10
  super(...arguments);
14
11
  this.getTableInfoList = (params) => {
15
12
  const { id, getFilteredResources } = this;
16
- const { resources } = getFilteredResources({
13
+ const tableInfoList = getFilteredResources({
17
14
  parentId: id,
15
+ kind: constants_1.TABLE_RESOURCE_KIND,
16
+ }).resources.map((resource) => {
17
+ return resource.getTableInfo(params);
18
18
  });
19
- const mapRes = resources.map((resource) => {
20
- var _a;
21
- return (_a = resource.getTableInfo) === null || _a === void 0 ? void 0 : _a.call(resource, params);
22
- });
23
- const tableInfoList = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
24
19
  const res = {
25
20
  tableInfoList,
26
21
  };
@@ -2,26 +2,6 @@ import { PlatformsParams } from "@ldsg/field-type";
2
2
  import { ObjectInfo } from "@ldsg/object";
3
3
  import { GeneralResourceSettings } from "@ldsg/types";
4
4
  export interface TableInfo extends GeneralResourceSettings {
5
- /**
6
- * Slug, used to derive name and collectionName
7
- * kebab case
8
- */
9
- slug: string;
10
- /**
11
- * Table Name (derived from slug if slug is provided, otherwise from settings.name)
12
- * camel case
13
- */
14
- name: string;
15
- /**
16
- * MongoDB collection name (derived from slug)
17
- * snake case
18
- */
19
- collectionName: string;
20
- /**
21
- * mongoose model name (derived from slug)
22
- * pascal case
23
- */
24
- modelName: string;
25
5
  /**
26
6
  * Object Info
27
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"get-table-info.d.ts","sourceRoot":"","sources":["../../src/types/get-table-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,SAAU,SAAQ,uBAAuB;IACxD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,SAAS,CAAC"}
1
+ {"version":3,"file":"get-table-info.d.ts","sourceRoot":"","sources":["../../src/types/get-table-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,SAAU,SAAQ,uBAAuB;IACxD;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,SAAS,CAAC"}
@@ -3,18 +3,14 @@ import { FieldInfo } from "@ldsg/object";
3
3
  * Object information with generated schemas
4
4
  */
5
5
  export interface TableObjectInfo {
6
- /**
7
- * Object name
8
- */
9
- name: string;
10
6
  /**
11
7
  * Object title
12
8
  */
13
- title?: string;
9
+ title: string;
14
10
  /**
15
11
  * Object description
16
12
  */
17
- description?: string;
13
+ description: string;
18
14
  /**
19
15
  * List of field information
20
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"query-types.d.ts","sourceRoot":"","sources":["../../src/types/query-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,aAAa,EAAE,SAAS,EAAE,CAAC;IAE3B;;OAEG;IACH,UAAU,EAAE,GAAG,CAAC;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,eAAe,CAAC;CAC7B"}
1
+ {"version":3,"file":"query-types.d.ts","sourceRoot":"","sources":["../../src/types/query-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,SAAS,EAAE,CAAC;IAE3B;;OAEG;IACH,UAAU,EAAE,GAAG,CAAC;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,eAAe,CAAC;CAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-resolvers.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/create-resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,EAAE;;;;;;qBAOnC,GAAG,QAAQ,GAAG;EAWxC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE;;;;EAQ9D"}
1
+ {"version":3,"file":"create-resolvers.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/create-resolvers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,EAAE;;;;;;qBAOnC,GAAG,QAAQ,GAAG;EAcxC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE;;;;EAQ9D"}
@@ -1,7 +1,11 @@
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.createTableResolver = createTableResolver;
4
7
  exports.createTablesResolver = createTablesResolver;
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  const map_table_info_1 = require("./map-table-info");
6
10
  /**
7
11
  * Creates a resolver definition for querying a single table by name
@@ -15,7 +19,9 @@ function createTableResolver(tableInfoList) {
15
19
  },
16
20
  resolve: async (_root, args) => {
17
21
  const { name } = args;
18
- const tableInfo = tableInfoList.find((t) => t.name === name);
22
+ const tableInfo = tableInfoList.find((tableInfo) => {
23
+ return lodash_1.default.camelCase(tableInfo.slug) === name;
24
+ });
19
25
  if (!tableInfo) {
20
26
  throw new Error(`Table not found: ${name}`);
21
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-json-schema.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/get-json-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAsCzC;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,SAAS,EAAE,GAAG,GAAG,CAkB5E"}
1
+ {"version":3,"file":"get-json-schema.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/get-json-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA2CzC;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,SAAS,EAAE,GAAG,GAAG,CAqB5E"}
@@ -1,7 +1,11 @@
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.getJsonSchemaByFieldInfoList = getJsonSchemaByFieldInfoList;
4
7
  const field_type_1 = require("@ldsg/field-type");
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  /**
6
10
  * Generates JSON Schema for a field based on its type info
7
11
  */
@@ -15,21 +19,23 @@ function getJsonSchemaForField(fieldInfo) {
15
19
  }
16
20
  // Fallback: generate basic schema based on common type
17
21
  const commonType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
22
+ const { title: fieldInfoTitle, slug } = fieldInfo;
23
+ const title = fieldInfoTitle !== null && fieldInfoTitle !== void 0 ? fieldInfoTitle : lodash_1.default.camelCase(slug);
18
24
  if (!commonType) {
19
25
  return {
20
26
  type: "string",
21
- title: fieldInfo.title || fieldInfo.name,
27
+ title,
22
28
  };
23
29
  }
24
30
  // Basic type mapping
25
31
  const typeMap = {
26
- string: { type: "string", title: fieldInfo.title || fieldInfo.name },
27
- number: { type: "number", title: fieldInfo.title || fieldInfo.name },
28
- boolean: { type: "boolean", title: fieldInfo.title || fieldInfo.name },
29
- array: { type: "array", title: fieldInfo.title || fieldInfo.name },
30
- object: { type: "object", title: fieldInfo.title || fieldInfo.name },
32
+ string: { type: "string", title },
33
+ number: { type: "number", title },
34
+ boolean: { type: "boolean", title },
35
+ array: { type: "array", title },
36
+ object: { type: "object", title },
31
37
  };
32
- return typeMap[commonType] || { type: "string", title: fieldInfo.title || fieldInfo.name };
38
+ return typeMap[commonType] || { type: "string", title };
33
39
  }
34
40
  /**
35
41
  * Generates JSON Schema for an object from its field info list
@@ -38,11 +44,12 @@ function getJsonSchemaByFieldInfoList(fieldInfoList) {
38
44
  const properties = {};
39
45
  const required = [];
40
46
  fieldInfoList.forEach((fieldInfo) => {
47
+ const fieldName = lodash_1.default.camelCase(fieldInfo.slug);
41
48
  const schema = getJsonSchemaForField(fieldInfo);
42
- properties[fieldInfo.name] = schema;
49
+ properties[fieldName] = schema;
43
50
  // Add to required if field is mandatory
44
51
  if (fieldInfo.required) {
45
- required.push(fieldInfo.name);
52
+ required.push(fieldName);
46
53
  }
47
54
  });
48
55
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"map-table-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/map-table-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGxE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,CAM1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAetE"}
1
+ {"version":3,"file":"map-table-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/map-table-info.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGxE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,CAM1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAetE"}
@@ -1,14 +1,18 @@
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.mapTableInfoToMetadata = mapTableInfoToMetadata;
4
7
  exports.mapTableInfoToDetail = mapTableInfoToDetail;
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  const get_json_schema_1 = require("./get-json-schema");
6
10
  /**
7
11
  * Maps TableInfo to TableMetadata (lightweight version without schemas)
8
12
  */
9
13
  function mapTableInfoToMetadata(tableInfo) {
10
14
  return {
11
- name: tableInfo.name,
15
+ name: lodash_1.default.camelCase(tableInfo.slug),
12
16
  title: tableInfo.title,
13
17
  description: tableInfo.description,
14
18
  };
@@ -21,7 +25,7 @@ function mapTableInfoToDetail(tableInfo) {
21
25
  // Generate JSON schema for the object
22
26
  const jsonSchema = (0, get_json_schema_1.getJsonSchemaByFieldInfoList)(objectInfo.fieldInfoList);
23
27
  return {
24
- name: tableInfo.name,
28
+ name: lodash_1.default.camelCase(tableInfo.slug),
25
29
  title: tableInfo.title,
26
30
  description: tableInfo.description,
27
31
  objectInfo: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/handle-table-info-list/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,UAAU,yBAA0B,SAAQ,oBAAoB;IAC9D,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,sBAAsB,CAAC;AAEzF,eAAO,MAAM,mBAAmB,EAAE,mBAuBjC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/handle-table-info-list/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,UAAU,yBAA0B,SAAQ,oBAAoB;IAC9D,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,sBAAsB,CAAC;AAEzF,eAAO,MAAM,mBAAmB,EAAE,mBA2BjC,CAAC"}
@@ -10,7 +10,9 @@ const handleTableInfoList = (params) => {
10
10
  const { schemaComposer, tableInfoList } = params;
11
11
  const mongooseModels = {};
12
12
  lodash_1.default.each(tableInfoList, (tableInfo) => {
13
- const { collectionName, modelName, objectInfo } = tableInfo;
13
+ const { slug, objectInfo } = tableInfo;
14
+ const collectionName = lodash_1.default.snakeCase(slug);
15
+ const modelName = lodash_1.default.upperFirst(lodash_1.default.camelCase(slug));
14
16
  const { mongooseModel } = (0, utils_1.getObjectTC)({
15
17
  modelName,
16
18
  collectionName,
@@ -1 +1 @@
1
- {"version":3,"file":"get-object-type-composer.d.ts","sourceRoot":"","sources":["../../../../src/utils/handle-table-info-list/utils/get-object-type-composer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,uCAAuC,EAExC,MAAM,0BAA0B,CAAC;AAMlC,OAAO,QAA8B,MAAM,UAAU,CAAC;AAiBtD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,kBAAkB,EAAE,uCAAuC,CACzD,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAChC,GAAG,CACJ,CAAC;CACH;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;AAoCjE,eAAO,MAAM,WAAW,EAAE,WA8GzB,CAAC"}
1
+ {"version":3,"file":"get-object-type-composer.d.ts","sourceRoot":"","sources":["../../../../src/utils/handle-table-info-list/utils/get-object-type-composer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,uCAAuC,EAExC,MAAM,0BAA0B,CAAC;AAMlC,OAAO,QAA8B,MAAM,UAAU,CAAC;AAiBtD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,kBAAkB,EAAE,uCAAuC,CACzD,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAChC,GAAG,CACJ,CAAC;CACH;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;AAyDjE,eAAO,MAAM,WAAW,EAAE,WA8GzB,CAAC"}
@@ -19,22 +19,37 @@ const countOpts = {
19
19
  };
20
20
  const buildNestedSchemaDefinition = (fieldInfoList, schemaDefinition) => {
21
21
  lodash_1.default.each(fieldInfoList, (fieldInfo) => {
22
- const { name, dbKey, typeInfo: { platformToTypeMap }, fieldInfoList: nestedFieldInfoList, } = fieldInfo;
22
+ const { slug, typeInfo: { platformToTypeMap }, fieldInfoList: nestedFieldInfoList, } = fieldInfo;
23
23
  const { COMMON, MONGOOSE } = platformToTypeMap;
24
24
  const type = MONGOOSE !== null && MONGOOSE !== void 0 ? MONGOOSE : COMMON;
25
- // `dbKey` is the MongoDB field key (snake_case)
26
- // `name` is the Mongoose alias / GraphQL field name (camelCase)
27
- const dbFieldName = dbKey;
28
- const alias = name !== dbKey ? name : undefined;
25
+ /**
26
+ * 下划线别名
27
+ */
28
+ const snakeCaseSlug = lodash_1.default.snakeCase(slug);
29
+ /**
30
+ * 驼峰别名
31
+ */
32
+ const camelCaseSlug = lodash_1.default.camelCase(slug);
33
+ /**
34
+ * 字段名
35
+ */
36
+ const fieldName = snakeCaseSlug;
37
+ /**
38
+ * 别名
39
+ */
40
+ const alias = snakeCaseSlug === camelCaseSlug ? undefined : camelCaseSlug;
29
41
  if (((type === null || type === void 0 ? void 0 : type.type) === "object" || (type === null || type === void 0 ? void 0 : type.type) === "array") && nestedFieldInfoList) {
30
42
  const subDef = {};
31
43
  buildNestedSchemaDefinition(nestedFieldInfoList, subDef);
32
44
  const subSchema = new mongoose_1.default.Schema(subDef, { _id: false });
33
45
  const value = type.type === "array" ? [subSchema] : subSchema;
34
- schemaDefinition[dbFieldName] = { type: value, ...(alias ? { alias } : {}) };
46
+ schemaDefinition[fieldName] = {
47
+ type: value,
48
+ ...(alias ? { alias } : {}),
49
+ };
35
50
  }
36
51
  else {
37
- schemaDefinition[dbFieldName] =
52
+ schemaDefinition[fieldName] =
38
53
  alias && typeof type === "function" ? { type, alias } : alias ? { ...type, alias } : type;
39
54
  }
40
55
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldsg/tables",
3
- "version": "0.3.38",
3
+ "version": "0.3.41",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -18,16 +18,16 @@
18
18
  "lodash": "^4.17.21",
19
19
  "mongoose": "^8.14.3",
20
20
  "zod": "^4.1.11",
21
- "@ldsg/object": "0.3.38",
22
- "@ldsg/handler": "0.3.38",
23
- "@ldsg/field-type": "0.3.38",
24
- "@ldsg/object-field": "0.3.38",
25
- "@ldsg/resource": "0.3.38",
26
- "@ldsg/application": "0.3.38",
27
- "@ldsg/types": "0.3.38",
28
- "@ldsg/resource-definition": "0.3.38",
29
- "@ldsg/workflow": "0.3.38",
30
- "@ldsg/graphql": "0.3.38"
21
+ "@ldsg/application": "0.3.41",
22
+ "@ldsg/field-type": "0.3.41",
23
+ "@ldsg/graphql": "0.3.41",
24
+ "@ldsg/handler": "0.3.41",
25
+ "@ldsg/object": "0.3.41",
26
+ "@ldsg/object-field": "0.3.41",
27
+ "@ldsg/resource": "0.3.41",
28
+ "@ldsg/resource-definition": "0.3.41",
29
+ "@ldsg/types": "0.3.41",
30
+ "@ldsg/workflow": "0.3.41"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/jest": "^29.5.2",