@carbonorm/carbonnode 1.2.0 → 1.2.2
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 +5 -0
- package/dist/api/rest/C6.d.ts +323 -0
- package/package.json +1 -1
- package/scripts/assets/handlebars/C6.tsx.handlebars +9 -0
- package/scripts/assets/handlebars/Table.tsx.handlebars +94 -63
- package/scripts/generateRestBindings.cjs +2 -2
- package/scripts/generateRestBindings.ts +2 -2
- package/src/api/interfaces/ormInterfaces.ts +2 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { C6RestfulModel } from "@carbonorm/carbonnode";
|
|
2
|
+
export type RestTableNames = 'carbon_carbons' | 'carbon_comments' | 'carbon_documentation' | 'carbon_feature_group_references' | 'carbon_features' | 'carbon_group_references' | 'carbon_groups' | 'carbon_history_logs' | 'carbon_location_references' | 'carbon_locations' | 'carbon_photos' | 'carbon_reports' | 'carbon_user_followers' | 'carbon_user_groups' | 'carbon_user_messages' | 'carbon_user_sessions' | 'carbon_user_tasks' | 'carbon_users' | 'carbon_wp_commentmeta' | 'carbon_wp_comments' | 'carbon_wp_links' | 'carbon_wp_options' | 'carbon_wp_postmeta' | 'carbon_wp_posts' | 'carbon_wp_term_relationships' | 'carbon_wp_term_taxonomy' | 'carbon_wp_termmeta' | 'carbon_wp_terms' | 'carbon_wp_usermeta' | 'carbon_wp_users';
|
|
3
|
+
export type RestShortTableNames = 'carbons' | 'comments' | 'documentation' | 'feature_group_references' | 'features' | 'group_references' | 'groups' | 'history_logs' | 'location_references' | 'locations' | 'photos' | 'reports' | 'user_followers' | 'user_groups' | 'user_messages' | 'user_sessions' | 'user_tasks' | 'users' | 'wp_commentmeta' | 'wp_comments' | 'wp_links' | 'wp_options' | 'wp_postmeta' | 'wp_posts' | 'wp_term_relationships' | 'wp_term_taxonomy' | 'wp_termmeta' | 'wp_terms' | 'wp_usermeta' | 'wp_users';
|
|
4
|
+
export interface iCarbons {
|
|
5
|
+
'entity_pk'?: string;
|
|
6
|
+
}
|
|
7
|
+
interface iDefineCarbons {
|
|
8
|
+
'ENTITY_PK': string;
|
|
9
|
+
}
|
|
10
|
+
export declare const carbons: C6RestfulModel & iDefineCarbons;
|
|
11
|
+
export interface iComments {
|
|
12
|
+
'parent_id'?: string;
|
|
13
|
+
}
|
|
14
|
+
interface iDefineComments {
|
|
15
|
+
'PARENT_ID': string;
|
|
16
|
+
}
|
|
17
|
+
export declare const comments: C6RestfulModel & iDefineComments;
|
|
18
|
+
export interface iDocumentation {
|
|
19
|
+
'documentation_uri'?: string;
|
|
20
|
+
}
|
|
21
|
+
interface iDefineDocumentation {
|
|
22
|
+
'DOCUMENTATION_URI': string;
|
|
23
|
+
}
|
|
24
|
+
export declare const documentation: C6RestfulModel & iDefineDocumentation;
|
|
25
|
+
export interface iFeature_Group_References {
|
|
26
|
+
'feature_entity_id'?: string;
|
|
27
|
+
}
|
|
28
|
+
interface iDefineFeature_Group_References {
|
|
29
|
+
'FEATURE_ENTITY_ID': string;
|
|
30
|
+
}
|
|
31
|
+
export declare const feature_group_references: C6RestfulModel & iDefineFeature_Group_References;
|
|
32
|
+
export interface iFeatures {
|
|
33
|
+
'feature_entity_id'?: string;
|
|
34
|
+
}
|
|
35
|
+
interface iDefineFeatures {
|
|
36
|
+
'FEATURE_ENTITY_ID': string;
|
|
37
|
+
}
|
|
38
|
+
export declare const features: C6RestfulModel & iDefineFeatures;
|
|
39
|
+
export interface iGroup_References {
|
|
40
|
+
'group_id'?: string;
|
|
41
|
+
}
|
|
42
|
+
interface iDefineGroup_References {
|
|
43
|
+
'GROUP_ID': string;
|
|
44
|
+
}
|
|
45
|
+
export declare const group_references: C6RestfulModel & iDefineGroup_References;
|
|
46
|
+
export interface iGroups {
|
|
47
|
+
'group_name'?: string;
|
|
48
|
+
}
|
|
49
|
+
interface iDefineGroups {
|
|
50
|
+
'GROUP_NAME': string;
|
|
51
|
+
}
|
|
52
|
+
export declare const groups: C6RestfulModel & iDefineGroups;
|
|
53
|
+
export interface iHistory_Logs {
|
|
54
|
+
'history_uuid'?: string;
|
|
55
|
+
}
|
|
56
|
+
interface iDefineHistory_Logs {
|
|
57
|
+
'HISTORY_UUID': string;
|
|
58
|
+
}
|
|
59
|
+
export declare const history_logs: C6RestfulModel & iDefineHistory_Logs;
|
|
60
|
+
export interface iLocation_References {
|
|
61
|
+
'entity_reference'?: string;
|
|
62
|
+
}
|
|
63
|
+
interface iDefineLocation_References {
|
|
64
|
+
'ENTITY_REFERENCE': string;
|
|
65
|
+
}
|
|
66
|
+
export declare const location_references: C6RestfulModel & iDefineLocation_References;
|
|
67
|
+
export interface iLocations {
|
|
68
|
+
'entity_id'?: string;
|
|
69
|
+
}
|
|
70
|
+
interface iDefineLocations {
|
|
71
|
+
'ENTITY_ID': string;
|
|
72
|
+
}
|
|
73
|
+
export declare const locations: C6RestfulModel & iDefineLocations;
|
|
74
|
+
export interface iPhotos {
|
|
75
|
+
'parent_id'?: string;
|
|
76
|
+
}
|
|
77
|
+
interface iDefinePhotos {
|
|
78
|
+
'PARENT_ID': string;
|
|
79
|
+
}
|
|
80
|
+
export declare const photos: C6RestfulModel & iDefinePhotos;
|
|
81
|
+
export interface iReports {
|
|
82
|
+
'log_level'?: string;
|
|
83
|
+
}
|
|
84
|
+
interface iDefineReports {
|
|
85
|
+
'LOG_LEVEL': string;
|
|
86
|
+
}
|
|
87
|
+
export declare const reports: C6RestfulModel & iDefineReports;
|
|
88
|
+
export interface iUser_Followers {
|
|
89
|
+
'follower_table_id'?: string;
|
|
90
|
+
}
|
|
91
|
+
interface iDefineUser_Followers {
|
|
92
|
+
'FOLLOWER_TABLE_ID': string;
|
|
93
|
+
}
|
|
94
|
+
export declare const user_followers: C6RestfulModel & iDefineUser_Followers;
|
|
95
|
+
export interface iUser_Groups {
|
|
96
|
+
'group_id'?: string;
|
|
97
|
+
}
|
|
98
|
+
interface iDefineUser_Groups {
|
|
99
|
+
'GROUP_ID': string;
|
|
100
|
+
}
|
|
101
|
+
export declare const user_groups: C6RestfulModel & iDefineUser_Groups;
|
|
102
|
+
export interface iUser_Messages {
|
|
103
|
+
'message_id'?: string;
|
|
104
|
+
}
|
|
105
|
+
interface iDefineUser_Messages {
|
|
106
|
+
'MESSAGE_ID': string;
|
|
107
|
+
}
|
|
108
|
+
export declare const user_messages: C6RestfulModel & iDefineUser_Messages;
|
|
109
|
+
export interface iUser_Sessions {
|
|
110
|
+
'user_id'?: string;
|
|
111
|
+
}
|
|
112
|
+
interface iDefineUser_Sessions {
|
|
113
|
+
'USER_ID': string;
|
|
114
|
+
}
|
|
115
|
+
export declare const user_sessions: C6RestfulModel & iDefineUser_Sessions;
|
|
116
|
+
export interface iUser_Tasks {
|
|
117
|
+
'task_id'?: string;
|
|
118
|
+
}
|
|
119
|
+
interface iDefineUser_Tasks {
|
|
120
|
+
'TASK_ID': string;
|
|
121
|
+
}
|
|
122
|
+
export declare const user_tasks: C6RestfulModel & iDefineUser_Tasks;
|
|
123
|
+
export interface iUsers {
|
|
124
|
+
'user_username'?: string;
|
|
125
|
+
}
|
|
126
|
+
interface iDefineUsers {
|
|
127
|
+
'USER_USERNAME': string;
|
|
128
|
+
}
|
|
129
|
+
export declare const users: C6RestfulModel & iDefineUsers;
|
|
130
|
+
export interface iWp_Commentmeta {
|
|
131
|
+
'meta_id'?: number;
|
|
132
|
+
}
|
|
133
|
+
interface iDefineWp_Commentmeta {
|
|
134
|
+
'META_ID': string;
|
|
135
|
+
}
|
|
136
|
+
export declare const wp_commentmeta: C6RestfulModel & iDefineWp_Commentmeta;
|
|
137
|
+
export interface iWp_Comments {
|
|
138
|
+
'comment_ID'?: number;
|
|
139
|
+
}
|
|
140
|
+
interface iDefineWp_Comments {
|
|
141
|
+
'COMMENT_ID': string;
|
|
142
|
+
}
|
|
143
|
+
export declare const wp_comments: C6RestfulModel & iDefineWp_Comments;
|
|
144
|
+
export interface iWp_Links {
|
|
145
|
+
'link_id'?: number;
|
|
146
|
+
}
|
|
147
|
+
interface iDefineWp_Links {
|
|
148
|
+
'LINK_ID': string;
|
|
149
|
+
}
|
|
150
|
+
export declare const wp_links: C6RestfulModel & iDefineWp_Links;
|
|
151
|
+
export interface iWp_Options {
|
|
152
|
+
'option_id'?: number;
|
|
153
|
+
}
|
|
154
|
+
interface iDefineWp_Options {
|
|
155
|
+
'OPTION_ID': string;
|
|
156
|
+
}
|
|
157
|
+
export declare const wp_options: C6RestfulModel & iDefineWp_Options;
|
|
158
|
+
export interface iWp_Postmeta {
|
|
159
|
+
'meta_id'?: number;
|
|
160
|
+
}
|
|
161
|
+
interface iDefineWp_Postmeta {
|
|
162
|
+
'META_ID': string;
|
|
163
|
+
}
|
|
164
|
+
export declare const wp_postmeta: C6RestfulModel & iDefineWp_Postmeta;
|
|
165
|
+
export interface iWp_Posts {
|
|
166
|
+
'ID'?: number;
|
|
167
|
+
}
|
|
168
|
+
interface iDefineWp_Posts {
|
|
169
|
+
'ID': string;
|
|
170
|
+
}
|
|
171
|
+
export declare const wp_posts: C6RestfulModel & iDefineWp_Posts;
|
|
172
|
+
export interface iWp_Term_Relationships {
|
|
173
|
+
'object_id'?: number;
|
|
174
|
+
}
|
|
175
|
+
interface iDefineWp_Term_Relationships {
|
|
176
|
+
'OBJECT_ID': string;
|
|
177
|
+
}
|
|
178
|
+
export declare const wp_term_relationships: C6RestfulModel & iDefineWp_Term_Relationships;
|
|
179
|
+
export interface iWp_Term_Taxonomy {
|
|
180
|
+
'term_taxonomy_id'?: number;
|
|
181
|
+
}
|
|
182
|
+
interface iDefineWp_Term_Taxonomy {
|
|
183
|
+
'TERM_TAXONOMY_ID': string;
|
|
184
|
+
}
|
|
185
|
+
export declare const wp_term_taxonomy: C6RestfulModel & iDefineWp_Term_Taxonomy;
|
|
186
|
+
export interface iWp_Termmeta {
|
|
187
|
+
'meta_id'?: number;
|
|
188
|
+
}
|
|
189
|
+
interface iDefineWp_Termmeta {
|
|
190
|
+
'META_ID': string;
|
|
191
|
+
}
|
|
192
|
+
export declare const wp_termmeta: C6RestfulModel & iDefineWp_Termmeta;
|
|
193
|
+
export interface iWp_Terms {
|
|
194
|
+
'term_id'?: number;
|
|
195
|
+
}
|
|
196
|
+
interface iDefineWp_Terms {
|
|
197
|
+
'TERM_ID': string;
|
|
198
|
+
}
|
|
199
|
+
export declare const wp_terms: C6RestfulModel & iDefineWp_Terms;
|
|
200
|
+
export interface iWp_Usermeta {
|
|
201
|
+
'umeta_id'?: number;
|
|
202
|
+
}
|
|
203
|
+
interface iDefineWp_Usermeta {
|
|
204
|
+
'UMETA_ID': string;
|
|
205
|
+
}
|
|
206
|
+
export declare const wp_usermeta: C6RestfulModel & iDefineWp_Usermeta;
|
|
207
|
+
export interface iWp_Users {
|
|
208
|
+
'ID'?: number;
|
|
209
|
+
}
|
|
210
|
+
interface iDefineWp_Users {
|
|
211
|
+
'ID': string;
|
|
212
|
+
}
|
|
213
|
+
export declare const wp_users: C6RestfulModel & iDefineWp_Users;
|
|
214
|
+
export declare const TABLES: {
|
|
215
|
+
carbons: any;
|
|
216
|
+
comments: any;
|
|
217
|
+
documentation: any;
|
|
218
|
+
feature_group_references: any;
|
|
219
|
+
features: any;
|
|
220
|
+
group_references: any;
|
|
221
|
+
groups: any;
|
|
222
|
+
history_logs: any;
|
|
223
|
+
location_references: any;
|
|
224
|
+
locations: any;
|
|
225
|
+
photos: any;
|
|
226
|
+
reports: any;
|
|
227
|
+
user_followers: any;
|
|
228
|
+
user_groups: any;
|
|
229
|
+
user_messages: any;
|
|
230
|
+
user_sessions: any;
|
|
231
|
+
user_tasks: any;
|
|
232
|
+
users: any;
|
|
233
|
+
wp_commentmeta: any;
|
|
234
|
+
wp_comments: any;
|
|
235
|
+
wp_links: any;
|
|
236
|
+
wp_options: any;
|
|
237
|
+
wp_postmeta: any;
|
|
238
|
+
wp_posts: any;
|
|
239
|
+
wp_term_relationships: any;
|
|
240
|
+
wp_term_taxonomy: any;
|
|
241
|
+
wp_termmeta: any;
|
|
242
|
+
wp_terms: any;
|
|
243
|
+
wp_usermeta: any;
|
|
244
|
+
wp_users: any;
|
|
245
|
+
};
|
|
246
|
+
export declare const C6: {
|
|
247
|
+
TABLES: {
|
|
248
|
+
[key: string]: (C6RestfulModel & {
|
|
249
|
+
[key: string]: any;
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
} & {
|
|
253
|
+
[key: string]: any;
|
|
254
|
+
};
|
|
255
|
+
export declare const COLUMNS: {
|
|
256
|
+
'carbon_carbons.entity_pk': string;
|
|
257
|
+
'carbon_comments.parent_id': string;
|
|
258
|
+
'carbon_documentation.documentation_uri': string;
|
|
259
|
+
'carbon_feature_group_references.feature_entity_id': string;
|
|
260
|
+
'carbon_features.feature_entity_id': string;
|
|
261
|
+
'carbon_group_references.group_id': string;
|
|
262
|
+
'carbon_groups.group_name': string;
|
|
263
|
+
'carbon_history_logs.history_uuid': string;
|
|
264
|
+
'carbon_location_references.entity_reference': string;
|
|
265
|
+
'carbon_locations.entity_id': string;
|
|
266
|
+
'carbon_photos.parent_id': string;
|
|
267
|
+
'carbon_reports.log_level': string;
|
|
268
|
+
'carbon_user_followers.follower_table_id': string;
|
|
269
|
+
'carbon_user_groups.group_id': string;
|
|
270
|
+
'carbon_user_messages.message_id': string;
|
|
271
|
+
'carbon_user_sessions.user_id': string;
|
|
272
|
+
'carbon_user_tasks.task_id': string;
|
|
273
|
+
'carbon_users.user_username': string;
|
|
274
|
+
'carbon_wp_commentmeta.meta_id': string;
|
|
275
|
+
'carbon_wp_comments.comment_ID': string;
|
|
276
|
+
'carbon_wp_links.link_id': string;
|
|
277
|
+
'carbon_wp_options.option_id': string;
|
|
278
|
+
'carbon_wp_postmeta.meta_id': string;
|
|
279
|
+
'carbon_wp_posts.ID': string;
|
|
280
|
+
'carbon_wp_term_relationships.object_id': string;
|
|
281
|
+
'carbon_wp_term_taxonomy.term_taxonomy_id': string;
|
|
282
|
+
'carbon_wp_termmeta.meta_id': string;
|
|
283
|
+
'carbon_wp_terms.term_id': string;
|
|
284
|
+
'carbon_wp_usermeta.umeta_id': string;
|
|
285
|
+
'carbon_wp_users.ID': string;
|
|
286
|
+
};
|
|
287
|
+
export type RestTableInterfaces = iCarbons | iComments | iDocumentation | iFeature_Group_References | iFeatures | iGroup_References | iGroups | iHistory_Logs | iLocation_References | iLocations | iPhotos | iReports | iUser_Followers | iUser_Groups | iUser_Messages | iUser_Sessions | iUser_Tasks | iUsers | iWp_Commentmeta | iWp_Comments | iWp_Links | iWp_Options | iWp_Postmeta | iWp_Posts | iWp_Term_Relationships | iWp_Term_Taxonomy | iWp_Termmeta | iWp_Terms | iWp_Usermeta | iWp_Users;
|
|
288
|
+
export type tStatefulApiData<T> = T[] | undefined | null;
|
|
289
|
+
export interface iRestfulObjectArrayTypes {
|
|
290
|
+
carbons: tStatefulApiData<iCarbons>;
|
|
291
|
+
comments: tStatefulApiData<iComments>;
|
|
292
|
+
documentation: tStatefulApiData<iDocumentation>;
|
|
293
|
+
feature_group_references: tStatefulApiData<iFeature_Group_References>;
|
|
294
|
+
features: tStatefulApiData<iFeatures>;
|
|
295
|
+
group_references: tStatefulApiData<iGroup_References>;
|
|
296
|
+
groups: tStatefulApiData<iGroups>;
|
|
297
|
+
history_logs: tStatefulApiData<iHistory_Logs>;
|
|
298
|
+
location_references: tStatefulApiData<iLocation_References>;
|
|
299
|
+
locations: tStatefulApiData<iLocations>;
|
|
300
|
+
photos: tStatefulApiData<iPhotos>;
|
|
301
|
+
reports: tStatefulApiData<iReports>;
|
|
302
|
+
user_followers: tStatefulApiData<iUser_Followers>;
|
|
303
|
+
user_groups: tStatefulApiData<iUser_Groups>;
|
|
304
|
+
user_messages: tStatefulApiData<iUser_Messages>;
|
|
305
|
+
user_sessions: tStatefulApiData<iUser_Sessions>;
|
|
306
|
+
user_tasks: tStatefulApiData<iUser_Tasks>;
|
|
307
|
+
users: tStatefulApiData<iUsers>;
|
|
308
|
+
wp_commentmeta: tStatefulApiData<iWp_Commentmeta>;
|
|
309
|
+
wp_comments: tStatefulApiData<iWp_Comments>;
|
|
310
|
+
wp_links: tStatefulApiData<iWp_Links>;
|
|
311
|
+
wp_options: tStatefulApiData<iWp_Options>;
|
|
312
|
+
wp_postmeta: tStatefulApiData<iWp_Postmeta>;
|
|
313
|
+
wp_posts: tStatefulApiData<iWp_Posts>;
|
|
314
|
+
wp_term_relationships: tStatefulApiData<iWp_Term_Relationships>;
|
|
315
|
+
wp_term_taxonomy: tStatefulApiData<iWp_Term_Taxonomy>;
|
|
316
|
+
wp_termmeta: tStatefulApiData<iWp_Termmeta>;
|
|
317
|
+
wp_terms: tStatefulApiData<iWp_Terms>;
|
|
318
|
+
wp_usermeta: tStatefulApiData<iWp_Usermeta>;
|
|
319
|
+
wp_users: tStatefulApiData<iWp_Users>;
|
|
320
|
+
}
|
|
321
|
+
export declare const initialRestfulObjectsState: iRestfulObjectArrayTypes;
|
|
322
|
+
export type tRestfulObjectArrayValues = iRestfulObjectArrayTypes[keyof iRestfulObjectArrayTypes];
|
|
323
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,6 +2,10 @@ import {
|
|
|
2
2
|
C6RestfulModel,
|
|
3
3
|
C6Constants
|
|
4
4
|
} from "@carbonorm/carbonnode";
|
|
5
|
+
{{#TABLES}}
|
|
6
|
+
import {{TABLE_NAME_SHORT_PASCAL_CASE}} from "./{{TABLE_NAME_SHORT_PASCAL_CASE}}";
|
|
7
|
+
{{/TABLES}}
|
|
8
|
+
|
|
5
9
|
|
|
6
10
|
export type RestTableNames = {{{RestTableNames}}};
|
|
7
11
|
|
|
@@ -70,6 +74,11 @@ export const {{TABLE_NAME_SHORT}}: C6RestfulModel & iDefine{{TABLE_NAME_SHORT_PA
|
|
|
70
74
|
CONSTRAINT: '{{CONSTRAINT}}',
|
|
71
75
|
},{{/this}}],{{/each}}
|
|
72
76
|
},
|
|
77
|
+
REST_STATE_OPERATIONS: {
|
|
78
|
+
PUT: {{TABLE_NAME_SHORT_PASCAL_CASE}}.putState{{TABLE_NAME_SHORT_PASCAL_CASE}},
|
|
79
|
+
POST: {{TABLE_NAME_SHORT_PASCAL_CASE}}.postState{{TABLE_NAME_SHORT_PASCAL_CASE}},
|
|
80
|
+
DELETE: {{TABLE_NAME_SHORT_PASCAL_CASE}}.deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}},
|
|
81
|
+
},
|
|
73
82
|
}
|
|
74
83
|
{{/TABLES}}
|
|
75
84
|
|
|
@@ -10,97 +10,128 @@ import {
|
|
|
10
10
|
iPutC6RestResponse,
|
|
11
11
|
removeInvalidKeys
|
|
12
12
|
} from "@carbonorm/carbonnode";
|
|
13
|
+
import {AxiosResponse} from "axios";
|
|
14
|
+
import {iAPI, Modify} from "restRequest";
|
|
13
15
|
import {deleteRestfulObjectArrays, updateRestfulObjectArrays} from "@carbonorm/carbonreact";
|
|
14
|
-
import {C6, i{{
|
|
16
|
+
import {C6, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, {{TABLE_NAME_SHORT}}, RestShortTableNames} from "./C6";
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
{{{TABLE_DEFINITION}}}
|
|
20
|
+
**/
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
type GetCustomAndRequiredFields = {}
|
|
23
|
+
|
|
24
|
+
type GetRequestTableOverrides = {}
|
|
25
|
+
|
|
26
|
+
// required parameters, optional parameters, parameter type overrides, response, and table names
|
|
27
|
+
export const Get = restRequest<GetCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, GetRequestTableOverrides, iGetC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestShortTableNames>({
|
|
19
28
|
C6: C6,
|
|
20
|
-
tableName: {{
|
|
29
|
+
tableName: {{TABLE_NAME_SHORT}}.TABLE_NAME,
|
|
21
30
|
requestMethod: GET,
|
|
22
31
|
queryCallback: (request) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
request.success ??= 'Successfully received {{TABLE_NAME_SHORT}}!'
|
|
33
|
+
request.error ??= 'An unknown issue occurred creating the {{TABLE_NAME_SHORT}}!'
|
|
34
|
+
return request
|
|
26
35
|
},
|
|
27
36
|
responseCallback: (response, _request) => {
|
|
28
|
-
updateRestfulObjectArrays<i{{
|
|
37
|
+
updateRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>(response?.data?.rest, "{{TABLE_NAME_SHORT}}", C6.{{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
29
38
|
}
|
|
30
|
-
})
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
type PutCustomAndRequiredFields = {}
|
|
42
|
+
|
|
43
|
+
type PutRequestTableOverrides = {}
|
|
44
|
+
|
|
45
|
+
export function putState{{TABLE_NAME_SHORT_PASCAL_CASE}}(response : AxiosResponse<iPutC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
|
|
46
|
+
updateRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>([
|
|
47
|
+
removeInvalidKeys<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>({
|
|
48
|
+
...request,
|
|
49
|
+
...response?.data?.rest,
|
|
50
|
+
}, C6.TABLES)
|
|
51
|
+
], "{{TABLE_NAME_SHORT}}", {{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
52
|
+
}
|
|
31
53
|
|
|
32
|
-
export const Put = restRequest<
|
|
54
|
+
export const Put = restRequest<PutCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PutRequestTableOverrides, iPutC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestShortTableNames>({
|
|
33
55
|
C6: C6,
|
|
34
|
-
tableName: {{
|
|
56
|
+
tableName: {{TABLE_NAME_SHORT}}.TABLE_NAME,
|
|
35
57
|
requestMethod: PUT,
|
|
36
58
|
queryCallback: (request) => {
|
|
37
|
-
request.success ??= 'Successfully updated {{
|
|
38
|
-
request.error ??= 'An unknown issue occurred updating the {{
|
|
59
|
+
request.success ??= 'Successfully updated {{TABLE_NAME_SHORT}} data!'
|
|
60
|
+
request.error ??= 'An unknown issue occurred updating the {{TABLE_NAME_SHORT}} data!'
|
|
39
61
|
return request
|
|
40
62
|
},
|
|
41
|
-
responseCallback:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...response?.data?.rest,
|
|
46
|
-
}, C6.TABLES)
|
|
47
|
-
], "{{noPrefix}}", {{noPrefix}}.PRIMARY_SHORT as (keyof i{{ucEachTableName}})[])
|
|
48
|
-
}
|
|
49
|
-
})
|
|
63
|
+
responseCallback: putState{{TABLE_NAME_SHORT_PASCAL_CASE}}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
type PostCustomAndRequiredFields = {}
|
|
50
67
|
|
|
68
|
+
type PostRequestTableOverrides = {}
|
|
51
69
|
|
|
52
|
-
export
|
|
70
|
+
export function postState{{TABLE_NAME_SHORT_PASCAL_CASE}}(response : AxiosResponse<iPostC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
|
|
71
|
+
if ('number' === typeof id || 'string' === typeof id) {
|
|
72
|
+
if (1 !== {{TABLE_NAME_SHORT}}.PRIMARY_SHORT.length) {
|
|
73
|
+
console.error("C6 received unexpected result's given the primary key length");
|
|
74
|
+
} else {
|
|
75
|
+
request[{{TABLE_NAME_SHORT}}.PRIMARY_SHORT[0]] = id
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
updateRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>(
|
|
79
|
+
undefined !== request.dataInsertMultipleRows
|
|
80
|
+
? request.dataInsertMultipleRows.map((request, index) => {
|
|
81
|
+
return removeInvalidKeys<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>({
|
|
82
|
+
...request,
|
|
83
|
+
...(index === 0 ? response?.data?.rest : {}),
|
|
84
|
+
}, C6.TABLES)
|
|
85
|
+
})
|
|
86
|
+
: [
|
|
87
|
+
removeInvalidKeys<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>({
|
|
88
|
+
...request,
|
|
89
|
+
...response?.data?.rest,
|
|
90
|
+
}, C6.TABLES)
|
|
91
|
+
],
|
|
92
|
+
"{{TABLE_NAME_SHORT}}",
|
|
93
|
+
{{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[]
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const Post = restRequest<PostCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, PostRequestTableOverrides, iPostC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestShortTableNames>({
|
|
53
98
|
C6: C6,
|
|
54
|
-
tableName: {{
|
|
99
|
+
tableName: {{TABLE_NAME_SHORT}}.TABLE_NAME,
|
|
55
100
|
requestMethod: POST,
|
|
56
101
|
queryCallback: (request) => {
|
|
57
|
-
request.success ??= 'Successfully created the {{
|
|
58
|
-
request.error ??= 'An unknown issue occurred creating the {{
|
|
102
|
+
request.success ??= 'Successfully created the {{TABLE_NAME_SHORT}} data!'
|
|
103
|
+
request.error ??= 'An unknown issue occurred creating the {{TABLE_NAME_SHORT}} data!'
|
|
59
104
|
return request
|
|
60
105
|
},
|
|
61
|
-
responseCallback:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else {
|
|
66
|
-
request[{{noPrefix}}.PRIMARY_SHORT[0]] = id
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
updateRestfulObjectArrays<i{{ucEachTableName}}>(
|
|
70
|
-
undefined !== request.dataInsertMultipleRows
|
|
71
|
-
? request.dataInsertMultipleRows.map((request, index) => {
|
|
72
|
-
return removeInvalidKeys<i{{ucEachTableName}}>({
|
|
73
|
-
...request,
|
|
74
|
-
...(index === 0 ? response?.data?.rest : {}),
|
|
75
|
-
}, C6.TABLES)
|
|
76
|
-
})
|
|
77
|
-
: [
|
|
78
|
-
removeInvalidKeys<i{{ucEachTableName}}>({
|
|
79
|
-
...request,
|
|
80
|
-
...response?.data?.rest,
|
|
81
|
-
}, C6.TABLES)
|
|
82
|
-
], "{{noPrefix}}", {{noPrefix}}.PRIMARY_SHORT as (keyof i{{ucEachTableName}})[])
|
|
83
|
-
}
|
|
84
|
-
})
|
|
106
|
+
responseCallback: postState{{TABLE_NAME_SHORT_PASCAL_CASE}}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
type DeleteCustomAndRequiredFields = {}
|
|
85
110
|
|
|
86
|
-
|
|
111
|
+
type DeleteRequestTableOverrides = {}
|
|
112
|
+
|
|
113
|
+
export function deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}}(_response : AxiosResponse<iDeleteC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>>, request : iAPI<Modify<i{{TABLE_NAME_SHORT_PASCAL_CASE}}, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
|
|
114
|
+
deleteRestfulObjectArrays<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>([
|
|
115
|
+
request
|
|
116
|
+
], "{{TABLE_NAME_SHORT}}", {{TABLE_NAME_SHORT}}.PRIMARY_SHORT as (keyof i{{TABLE_NAME_SHORT_PASCAL_CASE}})[])
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const Delete = restRequest<DeleteCustomAndRequiredFields, i{{TABLE_NAME_SHORT_PASCAL_CASE}}, DeleteRequestTableOverrides, iDeleteC6RestResponse<i{{TABLE_NAME_SHORT_PASCAL_CASE}}>, RestShortTableNames>({
|
|
87
120
|
C6: C6,
|
|
88
|
-
tableName: {{
|
|
121
|
+
tableName: {{TABLE_NAME_SHORT}}.TABLE_NAME,
|
|
89
122
|
requestMethod: DELETE,
|
|
90
123
|
queryCallback: (request) => {
|
|
91
|
-
request.success ??= 'Successfully removed the {{
|
|
92
|
-
request.error ??= 'An unknown issue occurred removing the {{
|
|
124
|
+
request.success ??= 'Successfully removed the {{TABLE_NAME_SHORT}} data!'
|
|
125
|
+
request.error ??= 'An unknown issue occurred removing the {{TABLE_NAME_SHORT}} data!'
|
|
93
126
|
return request
|
|
94
127
|
},
|
|
95
|
-
responseCallback:
|
|
96
|
-
// todo - request . where
|
|
97
|
-
deleteRestfulObjectArrays<i{{ucEachTableName}}>([
|
|
98
|
-
request
|
|
99
|
-
], "{{noPrefix}}", {{noPrefix}}.PRIMARY_SHORT as (keyof i{{ucEachTableName}})[])
|
|
100
|
-
}
|
|
128
|
+
responseCallback: deleteState{{TABLE_NAME_SHORT_PASCAL_CASE}}
|
|
101
129
|
});
|
|
102
130
|
|
|
103
|
-
|
|
104
131
|
export default {
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
// Export all GET, POST, PUT, DELETE functions for each table
|
|
133
|
+
Get,
|
|
134
|
+
Post,
|
|
135
|
+
Put,
|
|
136
|
+
Delete,
|
|
137
|
+
}
|
|
@@ -287,8 +287,8 @@ fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, 'C6.tsx'), Handlebars.compile(c
|
|
|
287
287
|
var template = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/Table.tsx.handlebars'), 'utf-8');
|
|
288
288
|
var testTemplate = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/Table.test.tsx.handlebars'), 'utf-8');
|
|
289
289
|
Object.values(tableData.TABLES).map(function (tableData, key) {
|
|
290
|
-
var tableName = tableData.
|
|
290
|
+
var tableName = tableData.TABLE_NAME_SHORT_PASCAL_CASE;
|
|
291
291
|
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, tableName + '.tsx'), Handlebars.compile(template)(tableData));
|
|
292
|
-
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, tableName + '.
|
|
292
|
+
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, tableName + '.test.tsx'), Handlebars.compile(testTemplate)(tableData));
|
|
293
293
|
});
|
|
294
294
|
console.log('Successfully created CarbonORM bindings!');
|
|
@@ -375,11 +375,11 @@ const testTemplate = fs.readFileSync(path.resolve(__dirname, 'assets/handlebars/
|
|
|
375
375
|
|
|
376
376
|
Object.values(tableData.TABLES).map((tableData, key) => {
|
|
377
377
|
|
|
378
|
-
const tableName = tableData.
|
|
378
|
+
const tableName = tableData.TABLE_NAME_SHORT_PASCAL_CASE
|
|
379
379
|
|
|
380
380
|
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, tableName + '.tsx'), Handlebars.compile(template)(tableData));
|
|
381
381
|
|
|
382
|
-
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, tableName + '.
|
|
382
|
+
fs.writeFileSync(path.join(MySQLDump.OUTPUT_DIR, tableName + '.test.tsx'), Handlebars.compile(testTemplate)(tableData));
|
|
383
383
|
|
|
384
384
|
})
|
|
385
385
|
|
|
@@ -36,5 +36,6 @@ export interface C6RestfulModel<RestShortTableNames extends string = string> {
|
|
|
36
36
|
REGEX_VALIDATION: RegExpMap,
|
|
37
37
|
TYPE_VALIDATION: {[key: string]: iTypeValidation},
|
|
38
38
|
TABLE_REFERENCES: {[columnName: string]: iConstraint[]},
|
|
39
|
-
TABLE_REFERENCED_BY: {[columnName: string]: iConstraint[]}
|
|
39
|
+
TABLE_REFERENCED_BY: {[columnName: string]: iConstraint[]},
|
|
40
|
+
REST_STATE_OPERATIONS: { PUT: Function, POST: Function, DELETE: Function },
|
|
40
41
|
}
|