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