@carbonorm/carbonnode 1.2.5 → 1.2.7
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/api/interfaces/ormInterfaces.d.ts +7 -5
- package/package.json +1 -1
- package/scripts/assets/handlebars/Table.test.tsx.handlebars +3 -3
- package/scripts/assets/handlebars/WsLiveUpdates.tsx.handlebars +22 -0
- package/scripts/generateRestBindings.cjs +2 -0
- package/scripts/generateRestBindings.ts +4 -0
- package/src/api/interfaces/ormInterfaces.ts +5 -5
|
@@ -26,6 +26,13 @@ export type tC6Tables = {
|
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
+
export type tWsLiveUpdate = {
|
|
30
|
+
[key: string]: {
|
|
31
|
+
PUT: Function;
|
|
32
|
+
POST: Function;
|
|
33
|
+
DELETE: Function;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
29
36
|
export interface C6RestfulModel<RestShortTableNames extends string = string> {
|
|
30
37
|
TABLE_NAME: RestShortTableNames;
|
|
31
38
|
PRIMARY: string[];
|
|
@@ -41,9 +48,4 @@ export interface C6RestfulModel<RestShortTableNames extends string = string> {
|
|
|
41
48
|
TABLE_REFERENCED_BY: {
|
|
42
49
|
[columnName: string]: iConstraint[];
|
|
43
50
|
};
|
|
44
|
-
REST_STATE_OPERATIONS: {
|
|
45
|
-
PUT: Function;
|
|
46
|
-
POST: Function;
|
|
47
|
-
DELETE: Function;
|
|
48
|
-
};
|
|
49
51
|
}
|
package/package.json
CHANGED
|
@@ -14,9 +14,9 @@ const fillString = 'string' + randomString + randomInt;
|
|
|
14
14
|
**/
|
|
15
15
|
|
|
16
16
|
const Test_Data: i{{TABLE_NAME_SHORT_PASCAL_CASE}} = {
|
|
17
|
-
{{#each TYPE_VALIDATION}}
|
|
18
|
-
{{
|
|
19
|
-
{{/each}}
|
|
17
|
+
{{#each TYPE_VALIDATION}}{{#SKIP_COLUMN_IN_POST}}
|
|
18
|
+
{{COLUMN_NAME}}: {{#TYPESCRIPT_TYPE_IS_STRING}}fillString{{#MAX_LENGTH}}.substring(0, {{MAX_LENGTH}}){{/MAX_LENGTH}}{{/TYPESCRIPT_TYPE_IS_STRING}}{{#TYPESCRIPT_TYPE_IS_NUMBER}}randomInt{{/TYPESCRIPT_TYPE_IS_NUMBER}},
|
|
19
|
+
{{/SKIP_COLUMN_IN_POST}}{{/each}}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export default Test_Data;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tWsLiveUpdate
|
|
3
|
+
} from "@carbonorm/carbonnode";
|
|
4
|
+
|
|
5
|
+
{{#TABLES}}
|
|
6
|
+
import { putState{{TABLE_NAME_SHORT_PASCAL_CASE}}, postState{{TABLE_NAME_SHORT_PASCAL_CASE}}, deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}} } from "./{{TABLE_NAME_SHORT_PASCAL_CASE}}";
|
|
7
|
+
{{/TABLES}}
|
|
8
|
+
|
|
9
|
+
const wsLiveUpdates: tWsLiveUpdate = {
|
|
10
|
+
{{#TABLES}}
|
|
11
|
+
{{TABLE_NAME_SHORT}}: {
|
|
12
|
+
PUT: putState{{TABLE_NAME_SHORT_PASCAL_CASE}},
|
|
13
|
+
POST: postState{{TABLE_NAME_SHORT_PASCAL_CASE}},
|
|
14
|
+
DELETE: deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}},
|
|
15
|
+
},
|
|
16
|
+
{{/TABLES}}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export default wsLiveUpdates;
|
|
21
|
+
|
|
22
|
+
|
|
@@ -290,6 +290,8 @@ fs.writeFileSync(path.join(process.cwd(), 'C6MySqlDump.json'), JSON.stringify(ta
|
|
|
290
290
|
// import this file src/assets/handlebars/C6.tsx.handlebars for a mustache template
|
|
291
291
|
var c6Template = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/C6.tsx.handlebars'), 'utf-8');
|
|
292
292
|
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, 'C6.tsx'), Handlebars.compile(c6Template)(tableData));
|
|
293
|
+
var wsLiveUpdatesTemplate = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/WsLiveUpdates.tsx.handlebars'), 'utf-8');
|
|
294
|
+
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, 'WsLiveUpdates.tsx'), Handlebars.compile(wsLiveUpdatesTemplate)(tableData));
|
|
293
295
|
var template = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/Table.tsx.handlebars'), 'utf-8');
|
|
294
296
|
var testTemplate = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/Table.test.tsx.handlebars'), 'utf-8');
|
|
295
297
|
Object.values(tableData.TABLES).map(function (tableData, key) {
|
|
@@ -381,6 +381,10 @@ const c6Template = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/C6
|
|
|
381
381
|
|
|
382
382
|
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, 'C6.tsx'), Handlebars.compile(c6Template)(tableData));
|
|
383
383
|
|
|
384
|
+
const wsLiveUpdatesTemplate = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/WsLiveUpdates.tsx.handlebars'), 'utf-8');
|
|
385
|
+
|
|
386
|
+
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, 'WsLiveUpdates.tsx'), Handlebars.compile(wsLiveUpdatesTemplate)(tableData));
|
|
387
|
+
|
|
384
388
|
const template = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/Table.tsx.handlebars'), 'utf-8');
|
|
385
389
|
|
|
386
390
|
const testTemplate = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/Table.test.tsx.handlebars'), 'utf-8');
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
export interface stringMap {
|
|
3
2
|
[key: string]: string;
|
|
4
3
|
}
|
|
@@ -30,14 +29,15 @@ export interface iConstraint {
|
|
|
30
29
|
|
|
31
30
|
export type tC6Tables = { [key: string]: (C6RestfulModel & { [key: string]: any }) }
|
|
32
31
|
|
|
32
|
+
export type tWsLiveUpdate = { [key: string]: { PUT: Function, POST: Function, DELETE: Function } };
|
|
33
|
+
|
|
33
34
|
export interface C6RestfulModel<RestShortTableNames extends string = string> {
|
|
34
35
|
TABLE_NAME: RestShortTableNames,
|
|
35
36
|
PRIMARY: string[],
|
|
36
37
|
PRIMARY_SHORT: string[],
|
|
37
38
|
COLUMNS: stringMap,
|
|
38
39
|
REGEX_VALIDATION: RegExpMap,
|
|
39
|
-
TYPE_VALIDATION: {[key: string]: iTypeValidation},
|
|
40
|
-
TABLE_REFERENCES: {[columnName: string]: iConstraint[]},
|
|
41
|
-
TABLE_REFERENCED_BY: {[columnName: string]: iConstraint[]},
|
|
42
|
-
REST_STATE_OPERATIONS: { PUT: Function, POST: Function, DELETE: Function },
|
|
40
|
+
TYPE_VALIDATION: { [key: string]: iTypeValidation },
|
|
41
|
+
TABLE_REFERENCES: { [columnName: string]: iConstraint[] },
|
|
42
|
+
TABLE_REFERENCED_BY: { [columnName: string]: iConstraint[] },
|
|
43
43
|
}
|