@carbonorm/carbonnode 2.0.10 → 2.0.12
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/package.json
CHANGED
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
Modify{{/REACT_IMPORT}}
|
|
14
14
|
} from "@carbonorm/carbonnode";{{#REACT_IMPORT}}
|
|
15
15
|
import {AxiosResponse} from "axios";{{/REACT_IMPORT}}
|
|
16
|
-
import {C6, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, {{TABLE_NAME_SHORT}}, RestTableNames} from "./C6";{{#REACT_IMPORT}}
|
|
16
|
+
import {C6, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, {{TABLE_NAME_SHORT}}, RestTableNames} from "./C6";{{#if REACT_IMPORT}}
|
|
17
17
|
import {deleteRestfulObjectArrays, updateRestfulObjectArrays} from "@carbonorm/carbonreact";
|
|
18
|
-
{{REACT_IMPORT}};{{/
|
|
18
|
+
{{REACT_IMPORT}};{{/if}}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
{{{TABLE_DEFINITION}}}
|
|
@@ -35,26 +35,26 @@ const Get = restRequest<GetCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_C
|
|
|
35
35
|
request.success ??= 'Successfully received {{TABLE_NAME_SHORT}}!'
|
|
36
36
|
request.error ??= 'An unknown issue occurred creating the {{TABLE_NAME_SHORT}}!'
|
|
37
37
|
return request
|
|
38
|
-
},{{#REACT_IMPORT}}
|
|
38
|
+
},{{#if REACT_IMPORT}}
|
|
39
39
|
responseCallback: (response, _request) => {
|
|
40
40
|
const responseData = response?.data?.rest;
|
|
41
|
-
{{
|
|
42
|
-
}{{/
|
|
41
|
+
{{CARBON_REACT_INSTANCE}}.updateRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>(Array.isArray(responseData) ? responseData : [responseData], "{{TABLE_NAME_SHORT}}", C6.{{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
42
|
+
}{{/if}}
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
type PutCustomAndRequiredFields = {}
|
|
46
46
|
|
|
47
47
|
type PutRequestTableOverrides = {}
|
|
48
48
|
|
|
49
|
-
{{#REACT_IMPORT}}
|
|
49
|
+
{{#if REACT_IMPORT}}
|
|
50
50
|
export function putState(response : AxiosResponse<iPutC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
|
|
51
|
-
{{
|
|
52
|
-
|
|
51
|
+
{{CARBON_REACT_INSTANCE}}.updateRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>([
|
|
52
|
+
removeInvalidKeys<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>({
|
|
53
53
|
...request,
|
|
54
54
|
...response?.data?.rest,
|
|
55
55
|
}, C6.TABLES)
|
|
56
56
|
], "{{TABLE_NAME_SHORT}}", {{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
57
|
-
}{{/
|
|
57
|
+
}{{/if}}
|
|
58
58
|
|
|
59
59
|
const Put = restRequest<PutCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PutRequestTableOverrides, iPutC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestTableNames>({
|
|
60
60
|
C6: C6,
|
|
@@ -65,15 +65,15 @@ const Put = restRequest<PutCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_C
|
|
|
65
65
|
request.success ??= 'Successfully updated {{TABLE_NAME_SHORT}} data!'
|
|
66
66
|
request.error ??= 'An unknown issue occurred updating the {{TABLE_NAME_SHORT}} data!'
|
|
67
67
|
return request
|
|
68
|
-
},{{#REACT_IMPORT}}
|
|
69
|
-
responseCallback: putState{{TABLE_NAME_SHORT_PASCAL_CASE}}{{/
|
|
68
|
+
},{{#if REACT_IMPORT}}
|
|
69
|
+
responseCallback: putState{{TABLE_NAME_SHORT_PASCAL_CASE}}{{/if}}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
type PostCustomAndRequiredFields = {}
|
|
73
73
|
|
|
74
74
|
type PostRequestTableOverrides = {}
|
|
75
75
|
|
|
76
|
-
{{#REACT_IMPORT}}export function postState(response : AxiosResponse<iPostC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
|
|
76
|
+
{{#if REACT_IMPORT}}export function postState(response : AxiosResponse<iPostC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
|
|
77
77
|
if ('number' === typeof id || 'string' === typeof id) {
|
|
78
78
|
if (1 !== {{TABLE_NAME_SHORT}}.PRIMARY_SHORT.length) {
|
|
79
79
|
console.error("C6 received unexpected result's given the primary key length");
|
|
@@ -81,7 +81,7 @@ type PostRequestTableOverrides = {}
|
|
|
81
81
|
request[{{TABLE_NAME_SHORT}}.PRIMARY_SHORT[0]] = id
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
{{
|
|
84
|
+
{{CARBON_REACT_INSTANCE}}.updateRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>(
|
|
85
85
|
undefined !== request.dataInsertMultipleRows
|
|
86
86
|
? request.dataInsertMultipleRows.map((request, index) => {
|
|
87
87
|
return removeInvalidKeys<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>({
|
|
@@ -98,11 +98,10 @@ type PostRequestTableOverrides = {}
|
|
|
98
98
|
"{{TABLE_NAME_SHORT}}",
|
|
99
99
|
{{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[]
|
|
100
100
|
)
|
|
101
|
-
}{{/
|
|
101
|
+
}{{/if}}
|
|
102
102
|
|
|
103
103
|
const Post = restRequest<PostCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PostRequestTableOverrides, iPostC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestTableNames>({
|
|
104
|
-
C6: C6,
|
|
105
|
-
instance: {{CARBON_REACT_INSTANCE}}{{/REACT_IMPORT}}
|
|
104
|
+
C6: C6,
|
|
106
105
|
restURL: {{{REST_URL_EXPRESSION}}},
|
|
107
106
|
tableName: {{TABLE_NAME_SHORT}}.TABLE_NAME,
|
|
108
107
|
requestMethod: POST,
|
|
@@ -110,23 +109,22 @@ const Post = restRequest<PostCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL
|
|
|
110
109
|
request.success ??= 'Successfully created the {{TABLE_NAME_SHORT}} data!'
|
|
111
110
|
request.error ??= 'An unknown issue occurred creating the {{TABLE_NAME_SHORT}} data!'
|
|
112
111
|
return request
|
|
113
|
-
},{{#REACT_IMPORT}}
|
|
114
|
-
responseCallback: postState{{TABLE_NAME_SHORT_PASCAL_CASE}}{{/
|
|
112
|
+
},{{#if REACT_IMPORT}}
|
|
113
|
+
responseCallback: postState{{TABLE_NAME_SHORT_PASCAL_CASE}}{{/if}}
|
|
115
114
|
});
|
|
116
115
|
|
|
117
116
|
type DeleteCustomAndRequiredFields = {}
|
|
118
117
|
|
|
119
118
|
type DeleteRequestTableOverrides = {}
|
|
120
119
|
|
|
121
|
-
{{#REACT_IMPORT}}export function deleteState(_response : AxiosResponse<iDeleteC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
|
|
122
|
-
{{
|
|
120
|
+
{{#if REACT_IMPORT}}export function deleteState(_response : AxiosResponse<iDeleteC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
|
|
121
|
+
{{CARBON_REACT_INSTANCE}}.deleteRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>([
|
|
123
122
|
request
|
|
124
123
|
], "{{TABLE_NAME_SHORT}}", {{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
125
|
-
}{{/
|
|
124
|
+
}{{/if}}
|
|
126
125
|
|
|
127
126
|
const Delete = restRequest<DeleteCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, DeleteRequestTableOverrides, iDeleteC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestTableNames>({
|
|
128
|
-
C6: C6,
|
|
129
|
-
instance: {{CARBON_REACT_INSTANCE}}{{/REACT_IMPORT}}
|
|
127
|
+
C6: C6,
|
|
130
128
|
restURL: {{{REST_URL_EXPRESSION}}},
|
|
131
129
|
tableName: {{TABLE_NAME_SHORT}}.TABLE_NAME,
|
|
132
130
|
requestMethod: DELETE,
|
|
@@ -134,8 +132,8 @@ const Delete = restRequest<DeleteCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PA
|
|
|
134
132
|
request.success ??= 'Successfully removed the {{TABLE_NAME_SHORT}} data!'
|
|
135
133
|
request.error ??= 'An unknown issue occurred removing the {{TABLE_NAME_SHORT}} data!'
|
|
136
134
|
return request
|
|
137
|
-
},{{#REACT_IMPORT}}
|
|
138
|
-
responseCallback: deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}}{{/
|
|
135
|
+
},{{#if REACT_IMPORT}}
|
|
136
|
+
responseCallback: deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}}{{/if}}
|
|
139
137
|
});
|
|
140
138
|
|
|
141
139
|
const {{TABLE_NAME_SHORT_PASCAL_CASE}} = {
|
|
@@ -203,9 +203,9 @@ var parseSQLToTypeScript = function (sql) {
|
|
|
203
203
|
}
|
|
204
204
|
var REACT_IMPORT = false, CARBON_REACT_INSTANCE = false;
|
|
205
205
|
if (argMap['--react'] || false) {
|
|
206
|
-
var reactArgSplit = argMap['--react'];
|
|
207
|
-
if (reactArgSplit.length !== 2
|
|
208
|
-
console.error("React requires two arguments, the import and the carbon react instance statement. Example: --react 'import CustomCarbonReactApplication from \"src/CustomCarbonReactApplication\"; CustomCarbonReactApplication
|
|
206
|
+
var reactArgSplit = argMap['--react'].split(';');
|
|
207
|
+
if (reactArgSplit.length !== 2) {
|
|
208
|
+
console.error("React requires two arguments, the import and the carbon react instance statement. Example: --react 'import CustomCarbonReactApplication from \"src/CustomCarbonReactApplication.tsx\"; CustomCarbonReactApplication'");
|
|
209
209
|
process.exit(1);
|
|
210
210
|
}
|
|
211
211
|
_c = __read(reactArgSplit, 2), REACT_IMPORT = _c[0], CARBON_REACT_INSTANCE = _c[1];
|
|
@@ -271,10 +271,10 @@ const parseSQLToTypeScript = (sql: string) => {
|
|
|
271
271
|
|
|
272
272
|
if (argMap['--react'] || false) {
|
|
273
273
|
|
|
274
|
-
const reactArgSplit = argMap['--react'];
|
|
274
|
+
const reactArgSplit = argMap['--react'].split(';')
|
|
275
275
|
|
|
276
|
-
if (reactArgSplit.length !== 2
|
|
277
|
-
console.error("React requires two arguments, the import and the carbon react instance statement. Example: --react 'import CustomCarbonReactApplication from \"src/CustomCarbonReactApplication\"; CustomCarbonReactApplication
|
|
276
|
+
if (reactArgSplit.length !== 2) {
|
|
277
|
+
console.error("React requires two arguments, the import and the carbon react instance statement. Example: --react 'import CustomCarbonReactApplication from \"src/CustomCarbonReactApplication.tsx\"; CustomCarbonReactApplication'");
|
|
278
278
|
process.exit(1);
|
|
279
279
|
}
|
|
280
280
|
|