@carbonorm/carbonnode 2.0.11 → 2.0.13
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
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
|
-
}{{/
|
|
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{{
|
|
68
|
+
},{{#if REACT_IMPORT}}
|
|
69
|
+
responseCallback: putState{{/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");
|
|
@@ -98,7 +98,7 @@ 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
104
|
C6: C6,
|
|
@@ -109,19 +109,19 @@ const Post = restRequest<PostCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL
|
|
|
109
109
|
request.success ??= 'Successfully created the {{TABLE_NAME_SHORT}} data!'
|
|
110
110
|
request.error ??= 'An unknown issue occurred creating the {{TABLE_NAME_SHORT}} data!'
|
|
111
111
|
return request
|
|
112
|
-
},{{#REACT_IMPORT}}
|
|
113
|
-
responseCallback: postState{{
|
|
112
|
+
},{{#if REACT_IMPORT}}
|
|
113
|
+
responseCallback: postState{{/if}}
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
type DeleteCustomAndRequiredFields = {}
|
|
117
117
|
|
|
118
118
|
type DeleteRequestTableOverrides = {}
|
|
119
119
|
|
|
120
|
-
{{#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) {
|
|
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
121
|
{{CARBON_REACT_INSTANCE}}.deleteRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>([
|
|
122
122
|
request
|
|
123
123
|
], "{{TABLE_NAME_SHORT}}", {{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
124
|
-
}{{/
|
|
124
|
+
}{{/if}}
|
|
125
125
|
|
|
126
126
|
const Delete = restRequest<DeleteCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, DeleteRequestTableOverrides, iDeleteC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestTableNames>({
|
|
127
127
|
C6: C6,
|
|
@@ -132,8 +132,8 @@ const Delete = restRequest<DeleteCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PA
|
|
|
132
132
|
request.success ??= 'Successfully removed the {{TABLE_NAME_SHORT}} data!'
|
|
133
133
|
request.error ??= 'An unknown issue occurred removing the {{TABLE_NAME_SHORT}} data!'
|
|
134
134
|
return request
|
|
135
|
-
},{{#REACT_IMPORT}}
|
|
136
|
-
responseCallback: deleteState{{
|
|
135
|
+
},{{#if REACT_IMPORT}}
|
|
136
|
+
responseCallback: deleteState{{/if}}
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
const {{TABLE_NAME_SHORT_PASCAL_CASE}} = {
|