@cloudbase/framework-plugin-low-code 1.0.3-beta.10 → 1.0.3-beta.11

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 +1,28 @@
1
+ import { IWebRuntimeAppData } from 'src/weapps-core';
2
+ export declare const CLOUD_FUNCTION_TYPE = "cloud-function";
3
+ export declare const EXTERNAL_FUNCTION_TYPE = "http";
4
+ export declare const DATABASE_TYPE = "database";
5
+ export declare function getDatasourceResourceName(datasrouce: any, mode: any): string;
6
+ export declare function getAppDatasourceResourceName(appId: any, datasrouce: any, mode: any): string;
7
+ export declare function getDatasourceDatabaseName(dsConfig: any, mode: any): string | null;
8
+ export declare function mergeDependencies(...pkgs: any[]): {};
9
+ export declare function lowercaseKey(obj: any, deep?: boolean): any;
10
+ export declare function standardizeDataSource(ds: any): any;
11
+ export declare function getDatasourceProfiles(datasources: any): any;
12
+ export declare function getDataVarProfiles(appData: IWebRuntimeAppData): {
13
+ $global: any[];
14
+ };
15
+ export declare function getDatasetProfiles(mainAppData: {
16
+ dataset?: any;
17
+ rootPath?: string;
18
+ pageInstanceList?: {
19
+ dataset?: any;
20
+ }[];
21
+ }, apps?: {
22
+ dataset?: any;
23
+ rootPath?: string;
24
+ pageInstanceList?: {
25
+ dataset?: any;
26
+ }[];
27
+ }[]): {};
1
28
  //# sourceMappingURL=dataSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataSource.d.ts","sourceRoot":"","sources":["../../src/utils/dataSource.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"dataSource.d.ts","sourceRoot":"","sources":["../../src/utils/dataSource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAC;AAMpE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,aAAa,aAAa,CAAC;AAMxC,wBAAgB,yBAAyB,CAAC,UAAU,KAAA,EAAE,IAAI,KAAA,UAGzD;AAED,wBAAgB,4BAA4B,CAAC,KAAK,KAAA,EAAE,UAAU,KAAA,EAAE,IAAI,KAAA,UAGnE;AAMD,wBAAgB,yBAAyB,CAAC,QAAQ,KAAA,EAAE,IAAI,KAAA,iBAIvD;AAMD,wBAAgB,iBAAiB,CAAC,GAAG,IAAI,OAAA,MAexC;AAmBD,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,GAAG,CAU1D;AAOD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,GAAG,OA6C5C;AAOD,wBAAgB,qBAAqB,CAAC,WAAW,KAAA,OAehD;AAOD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB;;EAU7D;AAiCD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACxC,EACD,IAAI,CAAC,EAAE;IACL,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACxC,EAAE,MAiBJ"}
@@ -1 +1,171 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getDatasetProfiles = exports.getDataVarProfiles = exports.getDatasourceProfiles = exports.standardizeDataSource = exports.lowercaseKey = exports.mergeDependencies = exports.getDatasourceDatabaseName = exports.getAppDatasourceResourceName = exports.getDatasourceResourceName = exports.DATABASE_TYPE = exports.EXTERNAL_FUNCTION_TYPE = exports.CLOUD_FUNCTION_TYPE = void 0;
7
+ const merge_package_json_1 = __importDefault(require("merge-package-json"));
8
+ const types_1 = require("../types");
9
+ const expression_1 = require("@cloudbase/cals/lib/parser/expression");
10
+ const util_1 = require("../builder/mp/util");
11
+ const config_1 = require("../builder/config");
12
+ exports.CLOUD_FUNCTION_TYPE = 'cloud-function';
13
+ exports.EXTERNAL_FUNCTION_TYPE = 'http';
14
+ exports.DATABASE_TYPE = 'database';
15
+ function getDatasourceResourceName(datasrouce, mode) {
16
+ let suffix = mode === types_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
17
+ return `lcap-${datasrouce.id}-${datasrouce.name}${suffix}`;
18
+ }
19
+ exports.getDatasourceResourceName = getDatasourceResourceName;
20
+ function getAppDatasourceResourceName(appId, datasrouce, mode) {
21
+ let suffix = mode === types_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
22
+ return `lcap-${datasrouce.id}-${datasrouce.name}-${appId}${suffix}`;
23
+ }
24
+ exports.getAppDatasourceResourceName = getAppDatasourceResourceName;
25
+ function getDatasourceDatabaseName(dsConfig, mode) {
26
+ return dsConfig.type === exports.DATABASE_TYPE
27
+ ? getDatasourceResourceName(dsConfig, mode)
28
+ : null;
29
+ }
30
+ exports.getDatasourceDatabaseName = getDatasourceDatabaseName;
31
+ function mergeDependencies(...pkgs) {
32
+ let result = { dependencies: {} };
33
+ result = pkgs.reduce((acc, pkg) => {
34
+ var _a;
35
+ const formated = getDependencies(pkg);
36
+ for (let key in formated.dependencies) {
37
+ formated.dependencies[key] =
38
+ formated.dependencies[key] === '*' && ((_a = acc === null || acc === void 0 ? void 0 : acc.dependencies) === null || _a === void 0 ? void 0 : _a[key]) === '*'
39
+ ? 'latest'
40
+ : formated.dependencies[key];
41
+ }
42
+ const merged = (0, merge_package_json_1.default)(formated, acc);
43
+ return JSON.parse(merged);
44
+ }, result);
45
+ return result.dependencies;
46
+ }
47
+ exports.mergeDependencies = mergeDependencies;
48
+ function getDependencies(pkg) {
49
+ if (pkg.dependencies && typeof pkg.dependencies === 'object') {
50
+ return {
51
+ dependencies: pkg.dependencies,
52
+ };
53
+ }
54
+ return {
55
+ dependencies: pkg,
56
+ };
57
+ }
58
+ function lowercaseKey(obj, deep) {
59
+ if (!obj || typeof obj !== 'object')
60
+ return obj;
61
+ if (Array.isArray(obj))
62
+ return obj.map((item) => lowercaseKey(item, deep));
63
+ const result = {};
64
+ return Object.keys(obj).reduce((acc, key) => {
65
+ const smallCase = key.charAt(0).toLowerCase() + key.slice(1);
66
+ const val = obj[key];
67
+ acc[smallCase] = deep ? lowercaseKey(val, deep) : val;
68
+ return acc;
69
+ }, result);
70
+ }
71
+ exports.lowercaseKey = lowercaseKey;
72
+ function standardizeDataSource(ds) {
73
+ const transformed = lowercaseKey(ds, true);
74
+ try {
75
+ const { schema } = ds;
76
+ if (typeof transformed.schema === 'string') {
77
+ transformed.schema = JSON.parse(transformed.schema);
78
+ }
79
+ if (!transformed.schema || typeof transformed.schema !== 'object') {
80
+ transformed.schema = {};
81
+ }
82
+ }
83
+ catch (error) {
84
+ transformed.schema = {};
85
+ }
86
+ try {
87
+ const { methods } = ds;
88
+ if (typeof transformed.methods === 'string') {
89
+ transformed.methods = JSON.parse(transformed.methods);
90
+ }
91
+ if (!Array.isArray(transformed.methods)) {
92
+ transformed.methods = [];
93
+ }
94
+ }
95
+ catch (error) {
96
+ transformed.methods = [];
97
+ }
98
+ return transformed;
99
+ }
100
+ exports.standardizeDataSource = standardizeDataSource;
101
+ function getDatasourceProfiles(datasources) {
102
+ return ((datasources === null || datasources === void 0 ? void 0 : datasources.map((item) => {
103
+ const ds = standardizeDataSource(item);
104
+ return {
105
+ id: ds.id,
106
+ title: ds.title,
107
+ name: ds.name,
108
+ type: ds.type,
109
+ childDataSourceNames: ds.childDataSourceNames,
110
+ schema: ds.schema,
111
+ methods: ds.methods,
112
+ };
113
+ })) || []);
114
+ }
115
+ exports.getDatasourceProfiles = getDatasourceProfiles;
116
+ function getDataVarProfiles(appData) {
117
+ const result = {
118
+ $global: (appData.vars && appData.vars.data) || [],
119
+ };
120
+ appData.pageInstanceList.forEach((pageInstance) => {
121
+ let p = pageInstance;
122
+ result[p.id] = (p.vars && p.vars.data) || [];
123
+ });
124
+ return result;
125
+ }
126
+ exports.getDataVarProfiles = getDataVarProfiles;
127
+ function _generateDynamicDataset(dataset) {
128
+ var _a;
129
+ let { state } = dataset;
130
+ if (state) {
131
+ for (let key in state) {
132
+ let config = state[key];
133
+ if (config.varType === 'datasource' && ((_a = config.initMethod) === null || _a === void 0 ? void 0 : _a.params)) {
134
+ let params = config.initMethod.params;
135
+ if (params) {
136
+ let processed = {};
137
+ for (let paramKey in params) {
138
+ let bind = params[paramKey];
139
+ if (!bind.type || bind.type === expression_1.PropBindType.static) {
140
+ let value = bind.value;
141
+ processed[paramKey] = `${config_1.REPLACE_SIGN}(app, $page) => (${typeof value === 'string' ? `'${value}'` : JSON.stringify(value)})${config_1.REPLACE_SIGN}`;
142
+ }
143
+ else {
144
+ let jsExp = (0, util_1.generateDataBind)(bind);
145
+ processed[paramKey] = `${config_1.REPLACE_SIGN}(app, $page) => (\n${jsExp || 'undefined'}\n)${config_1.REPLACE_SIGN}`;
146
+ }
147
+ }
148
+ config.initMethod.params = processed;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ return dataset;
154
+ }
155
+ function getDatasetProfiles(mainAppData, apps) {
156
+ const result = {};
157
+ if (mainAppData.dataset) {
158
+ result['$global'] = _generateDynamicDataset(mainAppData.dataset);
159
+ }
160
+ (apps || []).forEach((app) => {
161
+ var _a;
162
+ (_a = app.pageInstanceList) === null || _a === void 0 ? void 0 : _a.forEach((pageInstance) => {
163
+ let p = pageInstance;
164
+ if (p.dataset) {
165
+ result[app.rootPath ? `${app.rootPath}/${p.id}` : p.id] = _generateDynamicDataset(p.dataset);
166
+ }
167
+ });
168
+ });
169
+ return result;
170
+ }
171
+ exports.getDatasetProfiles = getDatasetProfiles;
@@ -6,7 +6,7 @@ export declare function originJsonToFileList(appData: IWeAppData): (import("../t
6
6
  code: string;
7
7
  pageId: string;
8
8
  })[];
9
- export declare function getExtByType(type: CodeType): ".js" | ".json" | ".less";
9
+ export declare function getExtByType(type: CodeType): ".less" | ".js" | ".json";
10
10
  export declare function HACK_FIX_LOWCODE_IN(code?: string): string;
11
11
  export declare function HACK_FIX_LOWCODE_OUT(code?: string): string;
12
12
  //# sourceMappingURL=file.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "1.0.3-beta.10",
3
+ "version": "1.0.3-beta.11",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -37,12 +37,12 @@
37
37
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@cloudbase/cals": "^0.4.1",
40
+ "@cloudbase/cals": "^0.4.2",
41
41
  "@cloudbase/framework-core": "^1.8.16",
42
42
  "@cloudbase/framework-plugin-auth": "^1.8.16",
43
43
  "@cloudbase/framework-plugin-mp": "1.9.5-beta.0",
44
44
  "@cloudbase/framework-plugin-website": "^1.8.17",
45
- "@cloudbase/lowcode-builder": "^1.0.20",
45
+ "@cloudbase/lowcode-builder": "^1.0.21",
46
46
  "@formily/react-schema-renderer": "1.1.7",
47
47
  "archiver": "^4.0.1",
48
48
  "compressing": "^1.4.0",