@ldsg/object 0.3.32 → 0.3.34
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/dist/__tests__/unit.js +11 -6
- package/dist/resource.d.ts +6 -0
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +4 -1
- package/dist/types/get-field-info.d.ts +8 -2
- package/dist/types/get-field-info.d.ts.map +1 -1
- package/dist/types/specific-resource-settings.d.ts +2 -2
- package/dist/types/specific-resource-settings.js +2 -2
- package/package.json +12 -12
package/dist/__tests__/unit.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
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
|
const constants_1 = require("@ldsg/constants");
|
|
4
7
|
const field_type_1 = require("@ldsg/field-type");
|
|
5
8
|
const handler_1 = require("@ldsg/handler");
|
|
6
9
|
const resource_1 = require("@ldsg/resource");
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
11
|
const resource_2 = require("../resource");
|
|
8
12
|
class MockObjectFieldResource extends resource_1.Resource {
|
|
9
13
|
constructor() {
|
|
10
14
|
super(...arguments);
|
|
11
15
|
this.getFieldInfo = (params) => {
|
|
12
|
-
const { id, settings: { title, description,
|
|
16
|
+
const { id, settings: { title, description, slug, properties }, getResourcesFromSettings, } = this;
|
|
13
17
|
const { fieldTypeResource } = getResourcesFromSettings();
|
|
14
18
|
const { fieldTypeInfo } = fieldTypeResource.getFieldTypeInfo({
|
|
15
19
|
...params,
|
|
@@ -19,7 +23,8 @@ class MockObjectFieldResource extends resource_1.Resource {
|
|
|
19
23
|
id,
|
|
20
24
|
title,
|
|
21
25
|
description,
|
|
22
|
-
name,
|
|
26
|
+
name: lodash_1.default.camelCase(slug),
|
|
27
|
+
dbKey: lodash_1.default.snakeCase(slug),
|
|
23
28
|
typeInfo: fieldTypeInfo,
|
|
24
29
|
};
|
|
25
30
|
const res = {
|
|
@@ -39,7 +44,7 @@ test("object", () => {
|
|
|
39
44
|
settings: {
|
|
40
45
|
title: "测试对象",
|
|
41
46
|
description: "",
|
|
42
|
-
|
|
47
|
+
slug: "test",
|
|
43
48
|
},
|
|
44
49
|
});
|
|
45
50
|
new MockObjectFieldResource({
|
|
@@ -49,7 +54,7 @@ test("object", () => {
|
|
|
49
54
|
settings: {
|
|
50
55
|
title: "测试对象测试1对象字段",
|
|
51
56
|
description: "",
|
|
52
|
-
|
|
57
|
+
slug: "test1",
|
|
53
58
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
54
59
|
properties: {
|
|
55
60
|
max: "10",
|
|
@@ -63,7 +68,7 @@ test("object", () => {
|
|
|
63
68
|
settings: {
|
|
64
69
|
title: "测试对象测试2对象字段",
|
|
65
70
|
description: "",
|
|
66
|
-
|
|
71
|
+
slug: "test2",
|
|
67
72
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
68
73
|
properties: {
|
|
69
74
|
max: "10",
|
|
@@ -77,7 +82,7 @@ test("object", () => {
|
|
|
77
82
|
settings: {
|
|
78
83
|
title: "测试对象测试3对象字段",
|
|
79
84
|
description: "",
|
|
80
|
-
|
|
85
|
+
slug: "test3",
|
|
81
86
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
82
87
|
properties: {
|
|
83
88
|
max: "10",
|
package/dist/resource.d.ts
CHANGED
|
@@ -5,8 +5,14 @@ import { FieldInfo, ObjectSpecificResourceSettings } from "./types";
|
|
|
5
5
|
export interface ObjectInfo extends GeneralResourceSettings {
|
|
6
6
|
/**
|
|
7
7
|
* Object Name
|
|
8
|
+
* camel case
|
|
8
9
|
*/
|
|
9
10
|
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Object Type Name
|
|
13
|
+
* pascal case
|
|
14
|
+
*/
|
|
15
|
+
objectTypeName: string;
|
|
10
16
|
/**
|
|
11
17
|
* Field Info List
|
|
12
18
|
*/
|
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,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAgB,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAElF,MAAM,WAAW,UAAW,SAAQ,uBAAuB;IACzD
|
|
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,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAgB,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAElF,MAAM,WAAW,UAAW,SAAQ,uBAAuB;IACzD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,KAAK,aAAa,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,gBAAgB,CAAC;AAEpE,qBAAa,cAAe,SAAQ,QAAQ,CAAC,8BAA8B,CAAC;IAC1E,aAAa,EAAE,aAAa,CAsC1B;CACH"}
|
package/dist/resource.js
CHANGED
|
@@ -10,7 +10,9 @@ class ObjectResource extends resource_1.Resource {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.getObjectInfo = (params) => {
|
|
13
|
-
const { id, settings: { title, description,
|
|
13
|
+
const { id, settings: { title, description, slug }, getFilteredResources, } = this;
|
|
14
|
+
const name = lodash_1.default.camelCase(slug);
|
|
15
|
+
const objectTypeName = lodash_1.default.upperFirst(lodash_1.default.camelCase(slug));
|
|
14
16
|
const { resources } = getFilteredResources({
|
|
15
17
|
parentId: id,
|
|
16
18
|
});
|
|
@@ -25,6 +27,7 @@ class ObjectResource extends resource_1.Resource {
|
|
|
25
27
|
title,
|
|
26
28
|
description,
|
|
27
29
|
name,
|
|
30
|
+
objectTypeName,
|
|
28
31
|
fieldInfoList,
|
|
29
32
|
};
|
|
30
33
|
const res = {
|
|
@@ -6,9 +6,15 @@ export interface FieldInfo extends GeneralResourceSettings {
|
|
|
6
6
|
*/
|
|
7
7
|
id: string;
|
|
8
8
|
/**
|
|
9
|
-
* Field
|
|
9
|
+
* Field name (camelCase, e.g. "userId")
|
|
10
|
+
* Used as the GraphQL field name / Mongoose alias.
|
|
10
11
|
*/
|
|
11
12
|
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Database field key (snake_case, e.g. "user_id")
|
|
15
|
+
* Used as the MongoDB document field key.
|
|
16
|
+
*/
|
|
17
|
+
dbKey: string;
|
|
12
18
|
/**
|
|
13
19
|
* Field Type Info
|
|
14
20
|
*/
|
|
@@ -21,6 +27,6 @@ export interface FieldInfo extends GeneralResourceSettings {
|
|
|
21
27
|
interface GetFieldInfoRes {
|
|
22
28
|
fieldInfo: FieldInfo;
|
|
23
29
|
}
|
|
24
|
-
export type GetFieldInfo = (params?: PlatformsParams) => GetFieldInfoRes;
|
|
30
|
+
export type GetFieldInfo = (params?: PlatformsParams) => GetFieldInfoRes | undefined;
|
|
25
31
|
export {};
|
|
26
32
|
//# sourceMappingURL=get-field-info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-field-info.d.ts","sourceRoot":"","sources":["../../src/types/get-field-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,SAAU,SAAQ,uBAAuB;IACxD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX
|
|
1
|
+
{"version":3,"file":"get-field-info.d.ts","sourceRoot":"","sources":["../../src/types/get-field-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,SAAU,SAAQ,uBAAuB;IACxD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,aAAa,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;CAC7B;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,eAAe,GAAG,SAAS,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const ObjectSpecificResourceSettingsSchema: z.ZodObject<{
|
|
3
|
-
|
|
3
|
+
slug: z.ZodString;
|
|
4
4
|
}, z.core.$catchall<z.ZodAny>>;
|
|
5
5
|
export declare const SpecificResourceSettingsSchema: z.ZodObject<{
|
|
6
|
-
|
|
6
|
+
slug: z.ZodString;
|
|
7
7
|
}, z.core.$catchall<z.ZodAny>>;
|
|
8
8
|
export type ObjectSpecificResourceSettings = z.infer<typeof ObjectSpecificResourceSettingsSchema>;
|
|
9
9
|
//# sourceMappingURL=specific-resource-settings.d.ts.map
|
|
@@ -5,9 +5,9 @@ const zod_1 = require("zod");
|
|
|
5
5
|
exports.ObjectSpecificResourceSettingsSchema = zod_1.z
|
|
6
6
|
.object({
|
|
7
7
|
/**
|
|
8
|
-
* Object
|
|
8
|
+
* Object Slug
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
slug: zod_1.z.string(),
|
|
11
11
|
})
|
|
12
12
|
.catchall(zod_1.z.any());
|
|
13
13
|
exports.SpecificResourceSettingsSchema = exports.ObjectSpecificResourceSettingsSchema;
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/object",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.34",
|
|
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": {
|
|
14
17
|
"lodash": "^4.17.21",
|
|
15
18
|
"zod": "^4.1.11",
|
|
16
|
-
"@ldsg/
|
|
17
|
-
"@ldsg/
|
|
18
|
-
"@ldsg/
|
|
19
|
-
"@ldsg/resource": "0.3.
|
|
19
|
+
"@ldsg/constants": "0.3.34",
|
|
20
|
+
"@ldsg/handler": "0.3.34",
|
|
21
|
+
"@ldsg/resource": "0.3.34",
|
|
22
|
+
"@ldsg/resource-definition": "0.3.34"
|
|
20
23
|
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@types/jest": "^29.5.2",
|
|
@@ -28,11 +31,8 @@
|
|
|
28
31
|
"ts-jest": "^29.1.5",
|
|
29
32
|
"ts-node": "^10.9.2",
|
|
30
33
|
"typescript": "^5.8.3",
|
|
31
|
-
"@ldsg/field-type": "0.3.
|
|
32
|
-
"@ldsg/types": "0.3.
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public"
|
|
34
|
+
"@ldsg/field-type": "0.3.34",
|
|
35
|
+
"@ldsg/types": "0.3.34"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc --project tsconfig.build.json",
|