@carbonorm/carbonreact 3.4.4 → 3.4.5
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/CarbonReact.d.ts +3 -0
- package/dist/index.cjs.js +2133 -5049
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -49
- package/dist/index.esm.js +2114 -4952
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/CarbonReact.tsx +3 -0
- package/src/index.ts +0 -49
- package/dist/api/rest/C6.d.ts +0 -579
- package/dist/api/rest/Carbons.d.ts +0 -88
- package/dist/api/rest/Carbons.test.d.ts +0 -14
- package/dist/api/rest/Chat_Messages.d.ts +0 -88
- package/dist/api/rest/Chat_Messages.test.d.ts +0 -20
- package/dist/api/rest/Documentation.d.ts +0 -88
- package/dist/api/rest/Documentation.test.d.ts +0 -11
- package/dist/api/rest/Feature_Group_References.d.ts +0 -88
- package/dist/api/rest/Feature_Group_References.test.d.ts +0 -13
- package/dist/api/rest/Features.d.ts +0 -88
- package/dist/api/rest/Features.test.d.ts +0 -14
- package/dist/api/rest/Group_References.d.ts +0 -88
- package/dist/api/rest/Group_References.test.d.ts +0 -13
- package/dist/api/rest/Groups.d.ts +0 -88
- package/dist/api/rest/Groups.test.d.ts +0 -15
- package/dist/api/rest/History_Logs.d.ts +0 -88
- package/dist/api/rest/History_Logs.test.d.ts +0 -13
- package/dist/api/rest/Likes.d.ts +0 -88
- package/dist/api/rest/Likes.test.d.ts +0 -13
- package/dist/api/rest/Location_References.d.ts +0 -88
- package/dist/api/rest/Location_References.test.d.ts +0 -14
- package/dist/api/rest/Locations.d.ts +0 -88
- package/dist/api/rest/Locations.test.d.ts +0 -18
- package/dist/api/rest/Photos.d.ts +0 -88
- package/dist/api/rest/Photos.test.d.ts +0 -20
- package/dist/api/rest/Posts.d.ts +0 -88
- package/dist/api/rest/Posts.test.d.ts +0 -22
- package/dist/api/rest/Projects.d.ts +0 -88
- package/dist/api/rest/Projects.test.d.ts +0 -21
- package/dist/api/rest/Reports.d.ts +0 -88
- package/dist/api/rest/Reports.test.d.ts +0 -11
- package/dist/api/rest/Sessions.d.ts +0 -88
- package/dist/api/rest/Sessions.test.d.ts +0 -14
- package/dist/api/rest/Subscription.d.ts +0 -88
- package/dist/api/rest/Subscription.test.d.ts +0 -20
- package/dist/api/rest/User_Followers.d.ts +0 -88
- package/dist/api/rest/User_Followers.test.d.ts +0 -16
- package/dist/api/rest/User_Groups.d.ts +0 -88
- package/dist/api/rest/User_Groups.test.d.ts +0 -13
- package/dist/api/rest/User_Messages.d.ts +0 -88
- package/dist/api/rest/User_Messages.test.d.ts +0 -20
- package/dist/api/rest/User_Sessions.d.ts +0 -88
- package/dist/api/rest/User_Sessions.test.d.ts +0 -14
- package/dist/api/rest/User_Tasks.d.ts +0 -88
- package/dist/api/rest/User_Tasks.test.d.ts +0 -22
- package/dist/api/rest/Users.d.ts +0 -88
- package/dist/api/rest/Users.test.d.ts +0 -44
- package/dist/api/rest/WsLiveUpdates.d.ts +0 -3
- package/src/api/rest/C6.tsx +0 -2687
- package/src/api/rest/Carbons.test.tsx +0 -128
- package/src/api/rest/Carbons.tsx +0 -145
- package/src/api/rest/Chat_Messages.test.tsx +0 -138
- package/src/api/rest/Chat_Messages.tsx +0 -151
- package/src/api/rest/Documentation.test.tsx +0 -128
- package/src/api/rest/Documentation.tsx +0 -142
- package/src/api/rest/Feature_Group_References.test.tsx +0 -126
- package/src/api/rest/Feature_Group_References.tsx +0 -144
- package/src/api/rest/Features.test.tsx +0 -128
- package/src/api/rest/Features.tsx +0 -145
- package/src/api/rest/Group_References.test.tsx +0 -126
- package/src/api/rest/Group_References.tsx +0 -144
- package/src/api/rest/Groups.test.tsx +0 -130
- package/src/api/rest/Groups.tsx +0 -146
- package/src/api/rest/History_Logs.test.tsx +0 -130
- package/src/api/rest/History_Logs.tsx +0 -144
- package/src/api/rest/Likes.test.tsx +0 -126
- package/src/api/rest/Likes.tsx +0 -144
- package/src/api/rest/Location_References.test.tsx +0 -128
- package/src/api/rest/Location_References.tsx +0 -145
- package/src/api/rest/Locations.test.tsx +0 -137
- package/src/api/rest/Locations.tsx +0 -149
- package/src/api/rest/Photos.test.tsx +0 -139
- package/src/api/rest/Photos.tsx +0 -151
- package/src/api/rest/Posts.test.tsx +0 -142
- package/src/api/rest/Posts.tsx +0 -153
- package/src/api/rest/Projects.test.tsx +0 -144
- package/src/api/rest/Projects.tsx +0 -152
- package/src/api/rest/Reports.test.tsx +0 -128
- package/src/api/rest/Reports.tsx +0 -142
- package/src/api/rest/Sessions.test.tsx +0 -133
- package/src/api/rest/Sessions.tsx +0 -145
- package/src/api/rest/Subscription.test.tsx +0 -138
- package/src/api/rest/Subscription.tsx +0 -151
- package/src/api/rest/User_Followers.test.tsx +0 -130
- package/src/api/rest/User_Followers.tsx +0 -147
- package/src/api/rest/User_Groups.test.tsx +0 -126
- package/src/api/rest/User_Groups.tsx +0 -144
- package/src/api/rest/User_Messages.test.tsx +0 -137
- package/src/api/rest/User_Messages.tsx +0 -151
- package/src/api/rest/User_Sessions.test.tsx +0 -133
- package/src/api/rest/User_Sessions.tsx +0 -145
- package/src/api/rest/User_Tasks.test.tsx +0 -141
- package/src/api/rest/User_Tasks.tsx +0 -153
- package/src/api/rest/Users.test.tsx +0 -193
- package/src/api/rest/Users.tsx +0 -175
- package/src/api/rest/WsLiveUpdates.tsx +0 -150
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
iPostC6RestResponse,
|
|
3
|
-
restRequest,
|
|
4
|
-
GET,
|
|
5
|
-
POST,
|
|
6
|
-
PUT,
|
|
7
|
-
DELETE,
|
|
8
|
-
iDeleteC6RestResponse,
|
|
9
|
-
iGetC6RestResponse,
|
|
10
|
-
iPutC6RestResponse,
|
|
11
|
-
removeInvalidKeys
|
|
12
|
-
} from "@carbonorm/carbonnode";
|
|
13
|
-
import {AxiosResponse} from "axios";
|
|
14
|
-
import {iAPI, Modify} from "restRequest";
|
|
15
|
-
import {deleteRestfulObjectArrays, updateRestfulObjectArrays} from "@carbonorm/carbonreact";
|
|
16
|
-
import {C6, iDocumentation, documentation, RestTableNames} from "./C6";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
CREATE TABLE `carbon_documentation` (
|
|
20
|
-
`documentation_uri` varchar(255) NOT NULL,
|
|
21
|
-
`documentation_data` longblob,
|
|
22
|
-
`documentation_version` varchar(40) NOT NULL,
|
|
23
|
-
`documentation_active` tinyint NOT NULL
|
|
24
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
25
|
-
**/
|
|
26
|
-
|
|
27
|
-
type GetCustomAndRequiredFields = {}
|
|
28
|
-
|
|
29
|
-
type GetRequestTableOverrides = {}
|
|
30
|
-
|
|
31
|
-
// required parameters, optional parameters, parameter type overrides, response, and table names
|
|
32
|
-
export const Get = restRequest<GetCustomAndRequiredFields, iDocumentation, GetRequestTableOverrides, iGetC6RestResponse<iDocumentation>, RestTableNames>({
|
|
33
|
-
C6: C6,
|
|
34
|
-
tableName: documentation.TABLE_NAME,
|
|
35
|
-
requestMethod: GET,
|
|
36
|
-
queryCallback: (request) => {
|
|
37
|
-
request.success ??= 'Successfully received documentation!'
|
|
38
|
-
request.error ??= 'An unknown issue occurred creating the documentation!'
|
|
39
|
-
return request
|
|
40
|
-
},
|
|
41
|
-
responseCallback: (response, _request) => {
|
|
42
|
-
updateRestfulObjectArrays<iDocumentation>(response?.data?.rest, "documentation", C6.documentation.PRIMARY_SHORT as (keyof iDocumentation)[])
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
type PutCustomAndRequiredFields = {}
|
|
47
|
-
|
|
48
|
-
type PutRequestTableOverrides = {}
|
|
49
|
-
|
|
50
|
-
export function putStateDocumentation(response : AxiosResponse<iPutC6RestResponse<iDocumentation>>, request : iAPI<Modify<iDocumentation, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
|
|
51
|
-
updateRestfulObjectArrays<iDocumentation>([
|
|
52
|
-
removeInvalidKeys<iDocumentation>({
|
|
53
|
-
...request,
|
|
54
|
-
...response?.data?.rest,
|
|
55
|
-
}, C6.TABLES)
|
|
56
|
-
], "documentation", documentation.PRIMARY_SHORT as (keyof iDocumentation)[])
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const Put = restRequest<PutCustomAndRequiredFields, iDocumentation, PutRequestTableOverrides, iPutC6RestResponse<iDocumentation>, RestTableNames>({
|
|
60
|
-
C6: C6,
|
|
61
|
-
tableName: documentation.TABLE_NAME,
|
|
62
|
-
requestMethod: PUT,
|
|
63
|
-
queryCallback: (request) => {
|
|
64
|
-
request.success ??= 'Successfully updated documentation data!'
|
|
65
|
-
request.error ??= 'An unknown issue occurred updating the documentation data!'
|
|
66
|
-
return request
|
|
67
|
-
},
|
|
68
|
-
responseCallback: putStateDocumentation
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
type PostCustomAndRequiredFields = {}
|
|
72
|
-
|
|
73
|
-
type PostRequestTableOverrides = {}
|
|
74
|
-
|
|
75
|
-
export function postStateDocumentation(response : AxiosResponse<iPostC6RestResponse<iDocumentation>>, request : iAPI<Modify<iDocumentation, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
|
|
76
|
-
if ('number' === typeof id || 'string' === typeof id) {
|
|
77
|
-
if (1 !== documentation.PRIMARY_SHORT.length) {
|
|
78
|
-
console.error("C6 received unexpected result's given the primary key length");
|
|
79
|
-
} else {
|
|
80
|
-
request[documentation.PRIMARY_SHORT[0]] = id
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
updateRestfulObjectArrays<iDocumentation>(
|
|
84
|
-
undefined !== request.dataInsertMultipleRows
|
|
85
|
-
? request.dataInsertMultipleRows.map((request, index) => {
|
|
86
|
-
return removeInvalidKeys<iDocumentation>({
|
|
87
|
-
...request,
|
|
88
|
-
...(index === 0 ? response?.data?.rest : {}),
|
|
89
|
-
}, C6.TABLES)
|
|
90
|
-
})
|
|
91
|
-
: [
|
|
92
|
-
removeInvalidKeys<iDocumentation>({
|
|
93
|
-
...request,
|
|
94
|
-
...response?.data?.rest,
|
|
95
|
-
}, C6.TABLES)
|
|
96
|
-
],
|
|
97
|
-
"documentation",
|
|
98
|
-
documentation.PRIMARY_SHORT as (keyof iDocumentation)[]
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export const Post = restRequest<PostCustomAndRequiredFields, iDocumentation, PostRequestTableOverrides, iPostC6RestResponse<iDocumentation>, RestTableNames>({
|
|
103
|
-
C6: C6,
|
|
104
|
-
tableName: documentation.TABLE_NAME,
|
|
105
|
-
requestMethod: POST,
|
|
106
|
-
queryCallback: (request) => {
|
|
107
|
-
request.success ??= 'Successfully created the documentation data!'
|
|
108
|
-
request.error ??= 'An unknown issue occurred creating the documentation data!'
|
|
109
|
-
return request
|
|
110
|
-
},
|
|
111
|
-
responseCallback: postStateDocumentation
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
type DeleteCustomAndRequiredFields = {}
|
|
115
|
-
|
|
116
|
-
type DeleteRequestTableOverrides = {}
|
|
117
|
-
|
|
118
|
-
export function deleteStateDocumentation(_response : AxiosResponse<iDeleteC6RestResponse<iDocumentation>>, request : iAPI<Modify<iDocumentation, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
|
|
119
|
-
deleteRestfulObjectArrays<iDocumentation>([
|
|
120
|
-
request
|
|
121
|
-
], "documentation", documentation.PRIMARY_SHORT as (keyof iDocumentation)[])
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export const Delete = restRequest<DeleteCustomAndRequiredFields, iDocumentation, DeleteRequestTableOverrides, iDeleteC6RestResponse<iDocumentation>, RestTableNames>({
|
|
125
|
-
C6: C6,
|
|
126
|
-
tableName: documentation.TABLE_NAME,
|
|
127
|
-
requestMethod: DELETE,
|
|
128
|
-
queryCallback: (request) => {
|
|
129
|
-
request.success ??= 'Successfully removed the documentation data!'
|
|
130
|
-
request.error ??= 'An unknown issue occurred removing the documentation data!'
|
|
131
|
-
return request
|
|
132
|
-
},
|
|
133
|
-
responseCallback: deleteStateDocumentation
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
export default {
|
|
137
|
-
// Export all GET, POST, PUT, DELETE functions for each table
|
|
138
|
-
Get,
|
|
139
|
-
Post,
|
|
140
|
-
Put,
|
|
141
|
-
Delete,
|
|
142
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import {xdescribe, expect, test} from '@jest/globals';
|
|
2
|
-
import {CarbonReact} from "@carbonorm/carbonreact";
|
|
3
|
-
import {checkAllRequestsComplete} from "@carbonorm/carbonnode";
|
|
4
|
-
import {act, waitFor} from '@testing-library/react';
|
|
5
|
-
import {C6, iRestfulObjectArrayTypes, iFeature_Group_References, feature_group_references } from "api/rest/C6";
|
|
6
|
-
import Feature_Group_References from "./Feature_Group_References";
|
|
7
|
-
|
|
8
|
-
const randomString = Math.random().toString(36).substring(7);
|
|
9
|
-
const randomInt = Math.floor(Math.random() * 1000000);
|
|
10
|
-
const fillString = 'string' + randomString + randomInt;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
CREATE TABLE `carbon_feature_group_references` (
|
|
14
|
-
`feature_entity_id` binary(16) DEFAULT NULL,
|
|
15
|
-
`group_entity_id` binary(16) DEFAULT NULL,
|
|
16
|
-
KEY `carbon_feature_references_carbons_entity_pk_fk_2` (`feature_entity_id`),
|
|
17
|
-
KEY `carbon_feature_group_references_carbons_entity_pk_fk` (`group_entity_id`),
|
|
18
|
-
CONSTRAINT `carbon_feature_group_references_carbons_entity_pk_fk` FOREIGN KEY (`group_entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
19
|
-
CONSTRAINT `carbon_feature_references_carbons_entity_pk_fk` FOREIGN KEY (`feature_entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
20
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
21
|
-
**/
|
|
22
|
-
|
|
23
|
-
const Test_Data: iFeature_Group_References = {
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default Test_Data;
|
|
28
|
-
|
|
29
|
-
xdescribe('REST Feature_Group_References api', () => {
|
|
30
|
-
|
|
31
|
-
let testData = Test_Data;
|
|
32
|
-
|
|
33
|
-
test('GET POST PUT DELETE', async () => {
|
|
34
|
-
|
|
35
|
-
await act(async () => {
|
|
36
|
-
|
|
37
|
-
let selectAllResponse = await Feature_Group_References.Get({})
|
|
38
|
-
|
|
39
|
-
if ('function' === typeof selectAllResponse) {
|
|
40
|
-
throw Error('selectAllResponse is a promise, this typically means this specific get request has already run during test setup.');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// We don't care if it is filled or not, just that the request can be made.
|
|
44
|
-
expect(selectAllResponse?.data?.rest).not.toBeUndefined();
|
|
45
|
-
|
|
46
|
-
const postResponse = await Feature_Group_References.Post(testData);
|
|
47
|
-
|
|
48
|
-
console.log('postResponse', postResponse?.data)
|
|
49
|
-
|
|
50
|
-
expect(postResponse?.data?.created).not.toBeUndefined();
|
|
51
|
-
|
|
52
|
-
const primaryKey = feature_group_references.PRIMARY_SHORT[0];
|
|
53
|
-
|
|
54
|
-
const postID = postResponse?.data?.created
|
|
55
|
-
|
|
56
|
-
const singleRowSelect = await Feature_Group_References.Get({
|
|
57
|
-
[C6.WHERE]: {
|
|
58
|
-
[feature_group_references[primaryKey.toUpperCase()]]: postID,
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
if ('function' === typeof singleRowSelect) {
|
|
63
|
-
throw Error('singleRowSelect is a promise, this is unexpected.');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
console.log('singleRowSelect', singleRowSelect?.data)
|
|
67
|
-
|
|
68
|
-
// Ensure the expected response datastructure is returned
|
|
69
|
-
expect(singleRowSelect?.data?.rest).not.toBeUndefined();
|
|
70
|
-
|
|
71
|
-
// Make sure the previously created post is now returned
|
|
72
|
-
expect(typeof singleRowSelect?.data?.rest).toEqual('object');
|
|
73
|
-
|
|
74
|
-
// todo - make this work correctly with multiple primary keys
|
|
75
|
-
const selectedPostId = singleRowSelect?.data?.rest[0][primaryKey]
|
|
76
|
-
|
|
77
|
-
expect(selectedPostId).toEqual(postID);
|
|
78
|
-
|
|
79
|
-
const multipleRowSelect = await Feature_Group_References.Get({
|
|
80
|
-
[C6.WHERE]: {
|
|
81
|
-
[feature_group_references[primaryKey.toUpperCase()]]: [C6.IN, [0, postID]],
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
if ('function' === typeof multipleRowSelect) {
|
|
86
|
-
throw Error('singleRowSelect is a promise, this is unexpected.');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
console.log('singleRowSelect', multipleRowSelect?.data)
|
|
90
|
-
|
|
91
|
-
// Ensure the expected response datastructure is returned
|
|
92
|
-
expect(multipleRowSelect?.data?.rest).not.toBeUndefined();
|
|
93
|
-
|
|
94
|
-
// Make sure the previously created post is now returned
|
|
95
|
-
expect(typeof multipleRowSelect?.data?.rest).toEqual('object');
|
|
96
|
-
|
|
97
|
-
testData[primaryKey] = postID
|
|
98
|
-
|
|
99
|
-
testData.feature_entity_id = fillString.substring(0, 16);
|
|
100
|
-
testData.group_entity_id = fillString.substring(0, 16);
|
|
101
|
-
|
|
102
|
-
// wait for the global state to be updated
|
|
103
|
-
expect(CarbonReact.getState<iRestfulObjectArrayTypes>().feature_group_references).not.toBeUndefined();
|
|
104
|
-
|
|
105
|
-
const updateResponse = await Feature_Group_References.Put(testData)
|
|
106
|
-
|
|
107
|
-
expect(updateResponse?.data?.updated).not.toBeUndefined();
|
|
108
|
-
|
|
109
|
-
const deleteResponse = await Feature_Group_References.Delete({
|
|
110
|
-
[primaryKey]: postID
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
console.log('deleteResponse', deleteResponse?.data)
|
|
114
|
-
|
|
115
|
-
expect(deleteResponse?.data?.deleted).not.toBeUndefined();
|
|
116
|
-
|
|
117
|
-
await waitFor(async () => {
|
|
118
|
-
expect(checkAllRequestsComplete()).toEqual(true);
|
|
119
|
-
}, {timeout: 10000, interval: 1000});
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
}, 100000);
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
iPostC6RestResponse,
|
|
3
|
-
restRequest,
|
|
4
|
-
GET,
|
|
5
|
-
POST,
|
|
6
|
-
PUT,
|
|
7
|
-
DELETE,
|
|
8
|
-
iDeleteC6RestResponse,
|
|
9
|
-
iGetC6RestResponse,
|
|
10
|
-
iPutC6RestResponse,
|
|
11
|
-
removeInvalidKeys
|
|
12
|
-
} from "@carbonorm/carbonnode";
|
|
13
|
-
import {AxiosResponse} from "axios";
|
|
14
|
-
import {iAPI, Modify} from "restRequest";
|
|
15
|
-
import {deleteRestfulObjectArrays, updateRestfulObjectArrays} from "@carbonorm/carbonreact";
|
|
16
|
-
import {C6, iFeature_Group_References, feature_group_references, RestTableNames} from "./C6";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
CREATE TABLE `carbon_feature_group_references` (
|
|
20
|
-
`feature_entity_id` binary(16) DEFAULT NULL,
|
|
21
|
-
`group_entity_id` binary(16) DEFAULT NULL,
|
|
22
|
-
KEY `carbon_feature_references_carbons_entity_pk_fk_2` (`feature_entity_id`),
|
|
23
|
-
KEY `carbon_feature_group_references_carbons_entity_pk_fk` (`group_entity_id`),
|
|
24
|
-
CONSTRAINT `carbon_feature_group_references_carbons_entity_pk_fk` FOREIGN KEY (`group_entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
25
|
-
CONSTRAINT `carbon_feature_references_carbons_entity_pk_fk` FOREIGN KEY (`feature_entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
26
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
27
|
-
**/
|
|
28
|
-
|
|
29
|
-
type GetCustomAndRequiredFields = {}
|
|
30
|
-
|
|
31
|
-
type GetRequestTableOverrides = {}
|
|
32
|
-
|
|
33
|
-
// required parameters, optional parameters, parameter type overrides, response, and table names
|
|
34
|
-
export const Get = restRequest<GetCustomAndRequiredFields, iFeature_Group_References, GetRequestTableOverrides, iGetC6RestResponse<iFeature_Group_References>, RestTableNames>({
|
|
35
|
-
C6: C6,
|
|
36
|
-
tableName: feature_group_references.TABLE_NAME,
|
|
37
|
-
requestMethod: GET,
|
|
38
|
-
queryCallback: (request) => {
|
|
39
|
-
request.success ??= 'Successfully received feature_group_references!'
|
|
40
|
-
request.error ??= 'An unknown issue occurred creating the feature_group_references!'
|
|
41
|
-
return request
|
|
42
|
-
},
|
|
43
|
-
responseCallback: (response, _request) => {
|
|
44
|
-
updateRestfulObjectArrays<iFeature_Group_References>(response?.data?.rest, "feature_group_references", C6.feature_group_references.PRIMARY_SHORT as (keyof iFeature_Group_References)[])
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
type PutCustomAndRequiredFields = {}
|
|
49
|
-
|
|
50
|
-
type PutRequestTableOverrides = {}
|
|
51
|
-
|
|
52
|
-
export function putStateFeature_Group_References(response : AxiosResponse<iPutC6RestResponse<iFeature_Group_References>>, request : iAPI<Modify<iFeature_Group_References, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
|
|
53
|
-
updateRestfulObjectArrays<iFeature_Group_References>([
|
|
54
|
-
removeInvalidKeys<iFeature_Group_References>({
|
|
55
|
-
...request,
|
|
56
|
-
...response?.data?.rest,
|
|
57
|
-
}, C6.TABLES)
|
|
58
|
-
], "feature_group_references", feature_group_references.PRIMARY_SHORT as (keyof iFeature_Group_References)[])
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const Put = restRequest<PutCustomAndRequiredFields, iFeature_Group_References, PutRequestTableOverrides, iPutC6RestResponse<iFeature_Group_References>, RestTableNames>({
|
|
62
|
-
C6: C6,
|
|
63
|
-
tableName: feature_group_references.TABLE_NAME,
|
|
64
|
-
requestMethod: PUT,
|
|
65
|
-
queryCallback: (request) => {
|
|
66
|
-
request.success ??= 'Successfully updated feature_group_references data!'
|
|
67
|
-
request.error ??= 'An unknown issue occurred updating the feature_group_references data!'
|
|
68
|
-
return request
|
|
69
|
-
},
|
|
70
|
-
responseCallback: putStateFeature_Group_References
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
type PostCustomAndRequiredFields = {}
|
|
74
|
-
|
|
75
|
-
type PostRequestTableOverrides = {}
|
|
76
|
-
|
|
77
|
-
export function postStateFeature_Group_References(response : AxiosResponse<iPostC6RestResponse<iFeature_Group_References>>, request : iAPI<Modify<iFeature_Group_References, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
|
|
78
|
-
if ('number' === typeof id || 'string' === typeof id) {
|
|
79
|
-
if (1 !== feature_group_references.PRIMARY_SHORT.length) {
|
|
80
|
-
console.error("C6 received unexpected result's given the primary key length");
|
|
81
|
-
} else {
|
|
82
|
-
request[feature_group_references.PRIMARY_SHORT[0]] = id
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
updateRestfulObjectArrays<iFeature_Group_References>(
|
|
86
|
-
undefined !== request.dataInsertMultipleRows
|
|
87
|
-
? request.dataInsertMultipleRows.map((request, index) => {
|
|
88
|
-
return removeInvalidKeys<iFeature_Group_References>({
|
|
89
|
-
...request,
|
|
90
|
-
...(index === 0 ? response?.data?.rest : {}),
|
|
91
|
-
}, C6.TABLES)
|
|
92
|
-
})
|
|
93
|
-
: [
|
|
94
|
-
removeInvalidKeys<iFeature_Group_References>({
|
|
95
|
-
...request,
|
|
96
|
-
...response?.data?.rest,
|
|
97
|
-
}, C6.TABLES)
|
|
98
|
-
],
|
|
99
|
-
"feature_group_references",
|
|
100
|
-
feature_group_references.PRIMARY_SHORT as (keyof iFeature_Group_References)[]
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const Post = restRequest<PostCustomAndRequiredFields, iFeature_Group_References, PostRequestTableOverrides, iPostC6RestResponse<iFeature_Group_References>, RestTableNames>({
|
|
105
|
-
C6: C6,
|
|
106
|
-
tableName: feature_group_references.TABLE_NAME,
|
|
107
|
-
requestMethod: POST,
|
|
108
|
-
queryCallback: (request) => {
|
|
109
|
-
request.success ??= 'Successfully created the feature_group_references data!'
|
|
110
|
-
request.error ??= 'An unknown issue occurred creating the feature_group_references data!'
|
|
111
|
-
return request
|
|
112
|
-
},
|
|
113
|
-
responseCallback: postStateFeature_Group_References
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
type DeleteCustomAndRequiredFields = {}
|
|
117
|
-
|
|
118
|
-
type DeleteRequestTableOverrides = {}
|
|
119
|
-
|
|
120
|
-
export function deleteStateFeature_Group_References(_response : AxiosResponse<iDeleteC6RestResponse<iFeature_Group_References>>, request : iAPI<Modify<iFeature_Group_References, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
|
|
121
|
-
deleteRestfulObjectArrays<iFeature_Group_References>([
|
|
122
|
-
request
|
|
123
|
-
], "feature_group_references", feature_group_references.PRIMARY_SHORT as (keyof iFeature_Group_References)[])
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export const Delete = restRequest<DeleteCustomAndRequiredFields, iFeature_Group_References, DeleteRequestTableOverrides, iDeleteC6RestResponse<iFeature_Group_References>, RestTableNames>({
|
|
127
|
-
C6: C6,
|
|
128
|
-
tableName: feature_group_references.TABLE_NAME,
|
|
129
|
-
requestMethod: DELETE,
|
|
130
|
-
queryCallback: (request) => {
|
|
131
|
-
request.success ??= 'Successfully removed the feature_group_references data!'
|
|
132
|
-
request.error ??= 'An unknown issue occurred removing the feature_group_references data!'
|
|
133
|
-
return request
|
|
134
|
-
},
|
|
135
|
-
responseCallback: deleteStateFeature_Group_References
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
export default {
|
|
139
|
-
// Export all GET, POST, PUT, DELETE functions for each table
|
|
140
|
-
Get,
|
|
141
|
-
Post,
|
|
142
|
-
Put,
|
|
143
|
-
Delete,
|
|
144
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {xdescribe, expect, test} from '@jest/globals';
|
|
2
|
-
import {CarbonReact} from "@carbonorm/carbonreact";
|
|
3
|
-
import {checkAllRequestsComplete} from "@carbonorm/carbonnode";
|
|
4
|
-
import {act, waitFor} from '@testing-library/react';
|
|
5
|
-
import {C6, iRestfulObjectArrayTypes, iFeatures, features } from "api/rest/C6";
|
|
6
|
-
import Features from "./Features";
|
|
7
|
-
|
|
8
|
-
const randomString = Math.random().toString(36).substring(7);
|
|
9
|
-
const randomInt = Math.floor(Math.random() * 1000000);
|
|
10
|
-
const fillString = 'string' + randomString + randomInt;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
CREATE TABLE `carbon_features` (
|
|
14
|
-
`feature_entity_id` binary(16) NOT NULL,
|
|
15
|
-
`feature_code` varchar(30) NOT NULL,
|
|
16
|
-
`feature_creation_date` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
17
|
-
PRIMARY KEY (`feature_entity_id`),
|
|
18
|
-
UNIQUE KEY `carbon_features_feature_code_uindex` (`feature_code`),
|
|
19
|
-
UNIQUE KEY `carbon_features_feature_entity_id_uindex` (`feature_entity_id`),
|
|
20
|
-
CONSTRAINT `carbon_features_carbons_entity_pk_fk` FOREIGN KEY (`feature_entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
21
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
22
|
-
**/
|
|
23
|
-
|
|
24
|
-
const Test_Data: iFeatures = {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default Test_Data;
|
|
29
|
-
|
|
30
|
-
xdescribe('REST Features api', () => {
|
|
31
|
-
|
|
32
|
-
let testData = Test_Data;
|
|
33
|
-
|
|
34
|
-
test('GET POST PUT DELETE', async () => {
|
|
35
|
-
|
|
36
|
-
await act(async () => {
|
|
37
|
-
|
|
38
|
-
let selectAllResponse = await Features.Get({})
|
|
39
|
-
|
|
40
|
-
if ('function' === typeof selectAllResponse) {
|
|
41
|
-
throw Error('selectAllResponse is a promise, this typically means this specific get request has already run during test setup.');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// We don't care if it is filled or not, just that the request can be made.
|
|
45
|
-
expect(selectAllResponse?.data?.rest).not.toBeUndefined();
|
|
46
|
-
|
|
47
|
-
const postResponse = await Features.Post(testData);
|
|
48
|
-
|
|
49
|
-
console.log('postResponse', postResponse?.data)
|
|
50
|
-
|
|
51
|
-
expect(postResponse?.data?.created).not.toBeUndefined();
|
|
52
|
-
|
|
53
|
-
const primaryKey = features.PRIMARY_SHORT[0];
|
|
54
|
-
|
|
55
|
-
const postID = postResponse?.data?.created
|
|
56
|
-
|
|
57
|
-
const singleRowSelect = await Features.Get({
|
|
58
|
-
[C6.WHERE]: {
|
|
59
|
-
[features[primaryKey.toUpperCase()]]: postID,
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
if ('function' === typeof singleRowSelect) {
|
|
64
|
-
throw Error('singleRowSelect is a promise, this is unexpected.');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
console.log('singleRowSelect', singleRowSelect?.data)
|
|
68
|
-
|
|
69
|
-
// Ensure the expected response datastructure is returned
|
|
70
|
-
expect(singleRowSelect?.data?.rest).not.toBeUndefined();
|
|
71
|
-
|
|
72
|
-
// Make sure the previously created post is now returned
|
|
73
|
-
expect(typeof singleRowSelect?.data?.rest).toEqual('object');
|
|
74
|
-
|
|
75
|
-
// todo - make this work correctly with multiple primary keys
|
|
76
|
-
const selectedPostId = singleRowSelect?.data?.rest[0][primaryKey]
|
|
77
|
-
|
|
78
|
-
expect(selectedPostId).toEqual(postID);
|
|
79
|
-
|
|
80
|
-
const multipleRowSelect = await Features.Get({
|
|
81
|
-
[C6.WHERE]: {
|
|
82
|
-
[features[primaryKey.toUpperCase()]]: [C6.IN, [0, postID]],
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if ('function' === typeof multipleRowSelect) {
|
|
87
|
-
throw Error('singleRowSelect is a promise, this is unexpected.');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log('singleRowSelect', multipleRowSelect?.data)
|
|
91
|
-
|
|
92
|
-
// Ensure the expected response datastructure is returned
|
|
93
|
-
expect(multipleRowSelect?.data?.rest).not.toBeUndefined();
|
|
94
|
-
|
|
95
|
-
// Make sure the previously created post is now returned
|
|
96
|
-
expect(typeof multipleRowSelect?.data?.rest).toEqual('object');
|
|
97
|
-
|
|
98
|
-
testData[primaryKey] = postID
|
|
99
|
-
|
|
100
|
-
testData.feature_entity_id = fillString.substring(0, 16);
|
|
101
|
-
testData.feature_code = fillString.substring(0, 30);
|
|
102
|
-
testData.feature_creation_date = fillString.substring(0, );
|
|
103
|
-
|
|
104
|
-
// wait for the global state to be updated
|
|
105
|
-
expect(CarbonReact.getState<iRestfulObjectArrayTypes>().features).not.toBeUndefined();
|
|
106
|
-
|
|
107
|
-
const updateResponse = await Features.Put(testData)
|
|
108
|
-
|
|
109
|
-
expect(updateResponse?.data?.updated).not.toBeUndefined();
|
|
110
|
-
|
|
111
|
-
const deleteResponse = await Features.Delete({
|
|
112
|
-
[primaryKey]: postID
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
console.log('deleteResponse', deleteResponse?.data)
|
|
116
|
-
|
|
117
|
-
expect(deleteResponse?.data?.deleted).not.toBeUndefined();
|
|
118
|
-
|
|
119
|
-
await waitFor(async () => {
|
|
120
|
-
expect(checkAllRequestsComplete()).toEqual(true);
|
|
121
|
-
}, {timeout: 10000, interval: 1000});
|
|
122
|
-
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
}, 100000);
|
|
126
|
-
|
|
127
|
-
})
|
|
128
|
-
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
iPostC6RestResponse,
|
|
3
|
-
restRequest,
|
|
4
|
-
GET,
|
|
5
|
-
POST,
|
|
6
|
-
PUT,
|
|
7
|
-
DELETE,
|
|
8
|
-
iDeleteC6RestResponse,
|
|
9
|
-
iGetC6RestResponse,
|
|
10
|
-
iPutC6RestResponse,
|
|
11
|
-
removeInvalidKeys
|
|
12
|
-
} from "@carbonorm/carbonnode";
|
|
13
|
-
import {AxiosResponse} from "axios";
|
|
14
|
-
import {iAPI, Modify} from "restRequest";
|
|
15
|
-
import {deleteRestfulObjectArrays, updateRestfulObjectArrays} from "@carbonorm/carbonreact";
|
|
16
|
-
import {C6, iFeatures, features, RestTableNames} from "./C6";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
CREATE TABLE `carbon_features` (
|
|
20
|
-
`feature_entity_id` binary(16) NOT NULL,
|
|
21
|
-
`feature_code` varchar(30) NOT NULL,
|
|
22
|
-
`feature_creation_date` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
23
|
-
PRIMARY KEY (`feature_entity_id`),
|
|
24
|
-
UNIQUE KEY `carbon_features_feature_code_uindex` (`feature_code`),
|
|
25
|
-
UNIQUE KEY `carbon_features_feature_entity_id_uindex` (`feature_entity_id`),
|
|
26
|
-
CONSTRAINT `carbon_features_carbons_entity_pk_fk` FOREIGN KEY (`feature_entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
27
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
28
|
-
**/
|
|
29
|
-
|
|
30
|
-
type GetCustomAndRequiredFields = {}
|
|
31
|
-
|
|
32
|
-
type GetRequestTableOverrides = {}
|
|
33
|
-
|
|
34
|
-
// required parameters, optional parameters, parameter type overrides, response, and table names
|
|
35
|
-
export const Get = restRequest<GetCustomAndRequiredFields, iFeatures, GetRequestTableOverrides, iGetC6RestResponse<iFeatures>, RestTableNames>({
|
|
36
|
-
C6: C6,
|
|
37
|
-
tableName: features.TABLE_NAME,
|
|
38
|
-
requestMethod: GET,
|
|
39
|
-
queryCallback: (request) => {
|
|
40
|
-
request.success ??= 'Successfully received features!'
|
|
41
|
-
request.error ??= 'An unknown issue occurred creating the features!'
|
|
42
|
-
return request
|
|
43
|
-
},
|
|
44
|
-
responseCallback: (response, _request) => {
|
|
45
|
-
updateRestfulObjectArrays<iFeatures>(response?.data?.rest, "features", C6.features.PRIMARY_SHORT as (keyof iFeatures)[])
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
type PutCustomAndRequiredFields = {}
|
|
50
|
-
|
|
51
|
-
type PutRequestTableOverrides = {}
|
|
52
|
-
|
|
53
|
-
export function putStateFeatures(response : AxiosResponse<iPutC6RestResponse<iFeatures>>, request : iAPI<Modify<iFeatures, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
|
|
54
|
-
updateRestfulObjectArrays<iFeatures>([
|
|
55
|
-
removeInvalidKeys<iFeatures>({
|
|
56
|
-
...request,
|
|
57
|
-
...response?.data?.rest,
|
|
58
|
-
}, C6.TABLES)
|
|
59
|
-
], "features", features.PRIMARY_SHORT as (keyof iFeatures)[])
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const Put = restRequest<PutCustomAndRequiredFields, iFeatures, PutRequestTableOverrides, iPutC6RestResponse<iFeatures>, RestTableNames>({
|
|
63
|
-
C6: C6,
|
|
64
|
-
tableName: features.TABLE_NAME,
|
|
65
|
-
requestMethod: PUT,
|
|
66
|
-
queryCallback: (request) => {
|
|
67
|
-
request.success ??= 'Successfully updated features data!'
|
|
68
|
-
request.error ??= 'An unknown issue occurred updating the features data!'
|
|
69
|
-
return request
|
|
70
|
-
},
|
|
71
|
-
responseCallback: putStateFeatures
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
type PostCustomAndRequiredFields = {}
|
|
75
|
-
|
|
76
|
-
type PostRequestTableOverrides = {}
|
|
77
|
-
|
|
78
|
-
export function postStateFeatures(response : AxiosResponse<iPostC6RestResponse<iFeatures>>, request : iAPI<Modify<iFeatures, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
|
|
79
|
-
if ('number' === typeof id || 'string' === typeof id) {
|
|
80
|
-
if (1 !== features.PRIMARY_SHORT.length) {
|
|
81
|
-
console.error("C6 received unexpected result's given the primary key length");
|
|
82
|
-
} else {
|
|
83
|
-
request[features.PRIMARY_SHORT[0]] = id
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
updateRestfulObjectArrays<iFeatures>(
|
|
87
|
-
undefined !== request.dataInsertMultipleRows
|
|
88
|
-
? request.dataInsertMultipleRows.map((request, index) => {
|
|
89
|
-
return removeInvalidKeys<iFeatures>({
|
|
90
|
-
...request,
|
|
91
|
-
...(index === 0 ? response?.data?.rest : {}),
|
|
92
|
-
}, C6.TABLES)
|
|
93
|
-
})
|
|
94
|
-
: [
|
|
95
|
-
removeInvalidKeys<iFeatures>({
|
|
96
|
-
...request,
|
|
97
|
-
...response?.data?.rest,
|
|
98
|
-
}, C6.TABLES)
|
|
99
|
-
],
|
|
100
|
-
"features",
|
|
101
|
-
features.PRIMARY_SHORT as (keyof iFeatures)[]
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const Post = restRequest<PostCustomAndRequiredFields, iFeatures, PostRequestTableOverrides, iPostC6RestResponse<iFeatures>, RestTableNames>({
|
|
106
|
-
C6: C6,
|
|
107
|
-
tableName: features.TABLE_NAME,
|
|
108
|
-
requestMethod: POST,
|
|
109
|
-
queryCallback: (request) => {
|
|
110
|
-
request.success ??= 'Successfully created the features data!'
|
|
111
|
-
request.error ??= 'An unknown issue occurred creating the features data!'
|
|
112
|
-
return request
|
|
113
|
-
},
|
|
114
|
-
responseCallback: postStateFeatures
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
type DeleteCustomAndRequiredFields = {}
|
|
118
|
-
|
|
119
|
-
type DeleteRequestTableOverrides = {}
|
|
120
|
-
|
|
121
|
-
export function deleteStateFeatures(_response : AxiosResponse<iDeleteC6RestResponse<iFeatures>>, request : iAPI<Modify<iFeatures, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
|
|
122
|
-
deleteRestfulObjectArrays<iFeatures>([
|
|
123
|
-
request
|
|
124
|
-
], "features", features.PRIMARY_SHORT as (keyof iFeatures)[])
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export const Delete = restRequest<DeleteCustomAndRequiredFields, iFeatures, DeleteRequestTableOverrides, iDeleteC6RestResponse<iFeatures>, RestTableNames>({
|
|
128
|
-
C6: C6,
|
|
129
|
-
tableName: features.TABLE_NAME,
|
|
130
|
-
requestMethod: DELETE,
|
|
131
|
-
queryCallback: (request) => {
|
|
132
|
-
request.success ??= 'Successfully removed the features data!'
|
|
133
|
-
request.error ??= 'An unknown issue occurred removing the features data!'
|
|
134
|
-
return request
|
|
135
|
-
},
|
|
136
|
-
responseCallback: deleteStateFeatures
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
export default {
|
|
140
|
-
// Export all GET, POST, PUT, DELETE functions for each table
|
|
141
|
-
Get,
|
|
142
|
-
Post,
|
|
143
|
-
Put,
|
|
144
|
-
Delete,
|
|
145
|
-
}
|