@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,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, iHistory_Logs, history_logs, RestTableNames} from "./C6";
17
-
18
- /**
19
- CREATE TABLE `carbon_history_logs` (
20
- `history_uuid` binary(16) NOT NULL,
21
- `history_table` varchar(255) DEFAULT NULL,
22
- `history_type` varchar(20) DEFAULT NULL,
23
- `history_data` json DEFAULT NULL,
24
- `history_original_query` varchar(1024) DEFAULT NULL,
25
- `history_time` datetime DEFAULT CURRENT_TIMESTAMP
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, iHistory_Logs, GetRequestTableOverrides, iGetC6RestResponse<iHistory_Logs>, RestTableNames>({
35
- C6: C6,
36
- tableName: history_logs.TABLE_NAME,
37
- requestMethod: GET,
38
- queryCallback: (request) => {
39
- request.success ??= 'Successfully received history_logs!'
40
- request.error ??= 'An unknown issue occurred creating the history_logs!'
41
- return request
42
- },
43
- responseCallback: (response, _request) => {
44
- updateRestfulObjectArrays<iHistory_Logs>(response?.data?.rest, "history_logs", C6.history_logs.PRIMARY_SHORT as (keyof iHistory_Logs)[])
45
- }
46
- });
47
-
48
- type PutCustomAndRequiredFields = {}
49
-
50
- type PutRequestTableOverrides = {}
51
-
52
- export function putStateHistory_Logs(response : AxiosResponse<iPutC6RestResponse<iHistory_Logs>>, request : iAPI<Modify<iHistory_Logs, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
53
- updateRestfulObjectArrays<iHistory_Logs>([
54
- removeInvalidKeys<iHistory_Logs>({
55
- ...request,
56
- ...response?.data?.rest,
57
- }, C6.TABLES)
58
- ], "history_logs", history_logs.PRIMARY_SHORT as (keyof iHistory_Logs)[])
59
- }
60
-
61
- export const Put = restRequest<PutCustomAndRequiredFields, iHistory_Logs, PutRequestTableOverrides, iPutC6RestResponse<iHistory_Logs>, RestTableNames>({
62
- C6: C6,
63
- tableName: history_logs.TABLE_NAME,
64
- requestMethod: PUT,
65
- queryCallback: (request) => {
66
- request.success ??= 'Successfully updated history_logs data!'
67
- request.error ??= 'An unknown issue occurred updating the history_logs data!'
68
- return request
69
- },
70
- responseCallback: putStateHistory_Logs
71
- });
72
-
73
- type PostCustomAndRequiredFields = {}
74
-
75
- type PostRequestTableOverrides = {}
76
-
77
- export function postStateHistory_Logs(response : AxiosResponse<iPostC6RestResponse<iHistory_Logs>>, request : iAPI<Modify<iHistory_Logs, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
78
- if ('number' === typeof id || 'string' === typeof id) {
79
- if (1 !== history_logs.PRIMARY_SHORT.length) {
80
- console.error("C6 received unexpected result's given the primary key length");
81
- } else {
82
- request[history_logs.PRIMARY_SHORT[0]] = id
83
- }
84
- }
85
- updateRestfulObjectArrays<iHistory_Logs>(
86
- undefined !== request.dataInsertMultipleRows
87
- ? request.dataInsertMultipleRows.map((request, index) => {
88
- return removeInvalidKeys<iHistory_Logs>({
89
- ...request,
90
- ...(index === 0 ? response?.data?.rest : {}),
91
- }, C6.TABLES)
92
- })
93
- : [
94
- removeInvalidKeys<iHistory_Logs>({
95
- ...request,
96
- ...response?.data?.rest,
97
- }, C6.TABLES)
98
- ],
99
- "history_logs",
100
- history_logs.PRIMARY_SHORT as (keyof iHistory_Logs)[]
101
- )
102
- }
103
-
104
- export const Post = restRequest<PostCustomAndRequiredFields, iHistory_Logs, PostRequestTableOverrides, iPostC6RestResponse<iHistory_Logs>, RestTableNames>({
105
- C6: C6,
106
- tableName: history_logs.TABLE_NAME,
107
- requestMethod: POST,
108
- queryCallback: (request) => {
109
- request.success ??= 'Successfully created the history_logs data!'
110
- request.error ??= 'An unknown issue occurred creating the history_logs data!'
111
- return request
112
- },
113
- responseCallback: postStateHistory_Logs
114
- });
115
-
116
- type DeleteCustomAndRequiredFields = {}
117
-
118
- type DeleteRequestTableOverrides = {}
119
-
120
- export function deleteStateHistory_Logs(_response : AxiosResponse<iDeleteC6RestResponse<iHistory_Logs>>, request : iAPI<Modify<iHistory_Logs, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
121
- deleteRestfulObjectArrays<iHistory_Logs>([
122
- request
123
- ], "history_logs", history_logs.PRIMARY_SHORT as (keyof iHistory_Logs)[])
124
- }
125
-
126
- export const Delete = restRequest<DeleteCustomAndRequiredFields, iHistory_Logs, DeleteRequestTableOverrides, iDeleteC6RestResponse<iHistory_Logs>, RestTableNames>({
127
- C6: C6,
128
- tableName: history_logs.TABLE_NAME,
129
- requestMethod: DELETE,
130
- queryCallback: (request) => {
131
- request.success ??= 'Successfully removed the history_logs data!'
132
- request.error ??= 'An unknown issue occurred removing the history_logs data!'
133
- return request
134
- },
135
- responseCallback: deleteStateHistory_Logs
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,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, iLikes, likes } from "api/rest/C6";
6
- import Likes from "./Likes";
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_likes` (
14
- `like_user_id` binary(16) NOT NULL,
15
- `like_entity_id` binary(16) NOT NULL,
16
- KEY `carbon_likes_carbon_carbons_entity_pk_fk` (`like_user_id`),
17
- KEY `carbon_likes_carbon_carbons_entity_pk_fk2` (`like_entity_id`),
18
- CONSTRAINT `carbon_likes_carbon_carbons_entity_pk_fk` FOREIGN KEY (`like_user_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
19
- CONSTRAINT `carbon_likes_carbon_carbons_entity_pk_fk2` FOREIGN KEY (`like_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: iLikes = {
24
-
25
- }
26
-
27
- export default Test_Data;
28
-
29
- xdescribe('REST Likes 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 Likes.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 Likes.Post(testData);
47
-
48
- console.log('postResponse', postResponse?.data)
49
-
50
- expect(postResponse?.data?.created).not.toBeUndefined();
51
-
52
- const primaryKey = likes.PRIMARY_SHORT[0];
53
-
54
- const postID = postResponse?.data?.created
55
-
56
- const singleRowSelect = await Likes.Get({
57
- [C6.WHERE]: {
58
- [likes[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 Likes.Get({
80
- [C6.WHERE]: {
81
- [likes[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.like_user_id = fillString.substring(0, 16);
100
- testData.like_entity_id = fillString.substring(0, 16);
101
-
102
- // wait for the global state to be updated
103
- expect(CarbonReact.getState<iRestfulObjectArrayTypes>().likes).not.toBeUndefined();
104
-
105
- const updateResponse = await Likes.Put(testData)
106
-
107
- expect(updateResponse?.data?.updated).not.toBeUndefined();
108
-
109
- const deleteResponse = await Likes.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, iLikes, likes, RestTableNames} from "./C6";
17
-
18
- /**
19
- CREATE TABLE `carbon_likes` (
20
- `like_user_id` binary(16) NOT NULL,
21
- `like_entity_id` binary(16) NOT NULL,
22
- KEY `carbon_likes_carbon_carbons_entity_pk_fk` (`like_user_id`),
23
- KEY `carbon_likes_carbon_carbons_entity_pk_fk2` (`like_entity_id`),
24
- CONSTRAINT `carbon_likes_carbon_carbons_entity_pk_fk` FOREIGN KEY (`like_user_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
25
- CONSTRAINT `carbon_likes_carbon_carbons_entity_pk_fk2` FOREIGN KEY (`like_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, iLikes, GetRequestTableOverrides, iGetC6RestResponse<iLikes>, RestTableNames>({
35
- C6: C6,
36
- tableName: likes.TABLE_NAME,
37
- requestMethod: GET,
38
- queryCallback: (request) => {
39
- request.success ??= 'Successfully received likes!'
40
- request.error ??= 'An unknown issue occurred creating the likes!'
41
- return request
42
- },
43
- responseCallback: (response, _request) => {
44
- updateRestfulObjectArrays<iLikes>(response?.data?.rest, "likes", C6.likes.PRIMARY_SHORT as (keyof iLikes)[])
45
- }
46
- });
47
-
48
- type PutCustomAndRequiredFields = {}
49
-
50
- type PutRequestTableOverrides = {}
51
-
52
- export function putStateLikes(response : AxiosResponse<iPutC6RestResponse<iLikes>>, request : iAPI<Modify<iLikes, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
53
- updateRestfulObjectArrays<iLikes>([
54
- removeInvalidKeys<iLikes>({
55
- ...request,
56
- ...response?.data?.rest,
57
- }, C6.TABLES)
58
- ], "likes", likes.PRIMARY_SHORT as (keyof iLikes)[])
59
- }
60
-
61
- export const Put = restRequest<PutCustomAndRequiredFields, iLikes, PutRequestTableOverrides, iPutC6RestResponse<iLikes>, RestTableNames>({
62
- C6: C6,
63
- tableName: likes.TABLE_NAME,
64
- requestMethod: PUT,
65
- queryCallback: (request) => {
66
- request.success ??= 'Successfully updated likes data!'
67
- request.error ??= 'An unknown issue occurred updating the likes data!'
68
- return request
69
- },
70
- responseCallback: putStateLikes
71
- });
72
-
73
- type PostCustomAndRequiredFields = {}
74
-
75
- type PostRequestTableOverrides = {}
76
-
77
- export function postStateLikes(response : AxiosResponse<iPostC6RestResponse<iLikes>>, request : iAPI<Modify<iLikes, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
78
- if ('number' === typeof id || 'string' === typeof id) {
79
- if (1 !== likes.PRIMARY_SHORT.length) {
80
- console.error("C6 received unexpected result's given the primary key length");
81
- } else {
82
- request[likes.PRIMARY_SHORT[0]] = id
83
- }
84
- }
85
- updateRestfulObjectArrays<iLikes>(
86
- undefined !== request.dataInsertMultipleRows
87
- ? request.dataInsertMultipleRows.map((request, index) => {
88
- return removeInvalidKeys<iLikes>({
89
- ...request,
90
- ...(index === 0 ? response?.data?.rest : {}),
91
- }, C6.TABLES)
92
- })
93
- : [
94
- removeInvalidKeys<iLikes>({
95
- ...request,
96
- ...response?.data?.rest,
97
- }, C6.TABLES)
98
- ],
99
- "likes",
100
- likes.PRIMARY_SHORT as (keyof iLikes)[]
101
- )
102
- }
103
-
104
- export const Post = restRequest<PostCustomAndRequiredFields, iLikes, PostRequestTableOverrides, iPostC6RestResponse<iLikes>, RestTableNames>({
105
- C6: C6,
106
- tableName: likes.TABLE_NAME,
107
- requestMethod: POST,
108
- queryCallback: (request) => {
109
- request.success ??= 'Successfully created the likes data!'
110
- request.error ??= 'An unknown issue occurred creating the likes data!'
111
- return request
112
- },
113
- responseCallback: postStateLikes
114
- });
115
-
116
- type DeleteCustomAndRequiredFields = {}
117
-
118
- type DeleteRequestTableOverrides = {}
119
-
120
- export function deleteStateLikes(_response : AxiosResponse<iDeleteC6RestResponse<iLikes>>, request : iAPI<Modify<iLikes, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
121
- deleteRestfulObjectArrays<iLikes>([
122
- request
123
- ], "likes", likes.PRIMARY_SHORT as (keyof iLikes)[])
124
- }
125
-
126
- export const Delete = restRequest<DeleteCustomAndRequiredFields, iLikes, DeleteRequestTableOverrides, iDeleteC6RestResponse<iLikes>, RestTableNames>({
127
- C6: C6,
128
- tableName: likes.TABLE_NAME,
129
- requestMethod: DELETE,
130
- queryCallback: (request) => {
131
- request.success ??= 'Successfully removed the likes data!'
132
- request.error ??= 'An unknown issue occurred removing the likes data!'
133
- return request
134
- },
135
- responseCallback: deleteStateLikes
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, iLocation_References, location_references } from "api/rest/C6";
6
- import Location_References from "./Location_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_location_references` (
14
- `entity_reference` binary(16) NOT NULL,
15
- `location_reference` binary(16) NOT NULL,
16
- `location_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
17
- KEY `carbon_location_references_carbons_entity_pk_fk` (`entity_reference`),
18
- KEY `carbon_location_references_carbons_entity_pk_fk_2` (`location_reference`),
19
- CONSTRAINT `carbon_location_references_carbons_entity_pk_fk` FOREIGN KEY (`entity_reference`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
20
- CONSTRAINT `carbon_location_references_carbons_entity_pk_fk_2` FOREIGN KEY (`location_reference`) 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: iLocation_References = {
25
-
26
- }
27
-
28
- export default Test_Data;
29
-
30
- xdescribe('REST Location_References 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 Location_References.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 Location_References.Post(testData);
48
-
49
- console.log('postResponse', postResponse?.data)
50
-
51
- expect(postResponse?.data?.created).not.toBeUndefined();
52
-
53
- const primaryKey = location_references.PRIMARY_SHORT[0];
54
-
55
- const postID = postResponse?.data?.created
56
-
57
- const singleRowSelect = await Location_References.Get({
58
- [C6.WHERE]: {
59
- [location_references[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 Location_References.Get({
81
- [C6.WHERE]: {
82
- [location_references[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.entity_reference = fillString.substring(0, 16);
101
- testData.location_reference = fillString.substring(0, 16);
102
- testData.location_time = fillString.substring(0, );
103
-
104
- // wait for the global state to be updated
105
- expect(CarbonReact.getState<iRestfulObjectArrayTypes>().location_references).not.toBeUndefined();
106
-
107
- const updateResponse = await Location_References.Put(testData)
108
-
109
- expect(updateResponse?.data?.updated).not.toBeUndefined();
110
-
111
- const deleteResponse = await Location_References.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, iLocation_References, location_references, RestTableNames} from "./C6";
17
-
18
- /**
19
- CREATE TABLE `carbon_location_references` (
20
- `entity_reference` binary(16) NOT NULL,
21
- `location_reference` binary(16) NOT NULL,
22
- `location_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
23
- KEY `carbon_location_references_carbons_entity_pk_fk` (`entity_reference`),
24
- KEY `carbon_location_references_carbons_entity_pk_fk_2` (`location_reference`),
25
- CONSTRAINT `carbon_location_references_carbons_entity_pk_fk` FOREIGN KEY (`entity_reference`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
26
- CONSTRAINT `carbon_location_references_carbons_entity_pk_fk_2` FOREIGN KEY (`location_reference`) 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, iLocation_References, GetRequestTableOverrides, iGetC6RestResponse<iLocation_References>, RestTableNames>({
36
- C6: C6,
37
- tableName: location_references.TABLE_NAME,
38
- requestMethod: GET,
39
- queryCallback: (request) => {
40
- request.success ??= 'Successfully received location_references!'
41
- request.error ??= 'An unknown issue occurred creating the location_references!'
42
- return request
43
- },
44
- responseCallback: (response, _request) => {
45
- updateRestfulObjectArrays<iLocation_References>(response?.data?.rest, "location_references", C6.location_references.PRIMARY_SHORT as (keyof iLocation_References)[])
46
- }
47
- });
48
-
49
- type PutCustomAndRequiredFields = {}
50
-
51
- type PutRequestTableOverrides = {}
52
-
53
- export function putStateLocation_References(response : AxiosResponse<iPutC6RestResponse<iLocation_References>>, request : iAPI<Modify<iLocation_References, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
54
- updateRestfulObjectArrays<iLocation_References>([
55
- removeInvalidKeys<iLocation_References>({
56
- ...request,
57
- ...response?.data?.rest,
58
- }, C6.TABLES)
59
- ], "location_references", location_references.PRIMARY_SHORT as (keyof iLocation_References)[])
60
- }
61
-
62
- export const Put = restRequest<PutCustomAndRequiredFields, iLocation_References, PutRequestTableOverrides, iPutC6RestResponse<iLocation_References>, RestTableNames>({
63
- C6: C6,
64
- tableName: location_references.TABLE_NAME,
65
- requestMethod: PUT,
66
- queryCallback: (request) => {
67
- request.success ??= 'Successfully updated location_references data!'
68
- request.error ??= 'An unknown issue occurred updating the location_references data!'
69
- return request
70
- },
71
- responseCallback: putStateLocation_References
72
- });
73
-
74
- type PostCustomAndRequiredFields = {}
75
-
76
- type PostRequestTableOverrides = {}
77
-
78
- export function postStateLocation_References(response : AxiosResponse<iPostC6RestResponse<iLocation_References>>, request : iAPI<Modify<iLocation_References, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
79
- if ('number' === typeof id || 'string' === typeof id) {
80
- if (1 !== location_references.PRIMARY_SHORT.length) {
81
- console.error("C6 received unexpected result's given the primary key length");
82
- } else {
83
- request[location_references.PRIMARY_SHORT[0]] = id
84
- }
85
- }
86
- updateRestfulObjectArrays<iLocation_References>(
87
- undefined !== request.dataInsertMultipleRows
88
- ? request.dataInsertMultipleRows.map((request, index) => {
89
- return removeInvalidKeys<iLocation_References>({
90
- ...request,
91
- ...(index === 0 ? response?.data?.rest : {}),
92
- }, C6.TABLES)
93
- })
94
- : [
95
- removeInvalidKeys<iLocation_References>({
96
- ...request,
97
- ...response?.data?.rest,
98
- }, C6.TABLES)
99
- ],
100
- "location_references",
101
- location_references.PRIMARY_SHORT as (keyof iLocation_References)[]
102
- )
103
- }
104
-
105
- export const Post = restRequest<PostCustomAndRequiredFields, iLocation_References, PostRequestTableOverrides, iPostC6RestResponse<iLocation_References>, RestTableNames>({
106
- C6: C6,
107
- tableName: location_references.TABLE_NAME,
108
- requestMethod: POST,
109
- queryCallback: (request) => {
110
- request.success ??= 'Successfully created the location_references data!'
111
- request.error ??= 'An unknown issue occurred creating the location_references data!'
112
- return request
113
- },
114
- responseCallback: postStateLocation_References
115
- });
116
-
117
- type DeleteCustomAndRequiredFields = {}
118
-
119
- type DeleteRequestTableOverrides = {}
120
-
121
- export function deleteStateLocation_References(_response : AxiosResponse<iDeleteC6RestResponse<iLocation_References>>, request : iAPI<Modify<iLocation_References, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
122
- deleteRestfulObjectArrays<iLocation_References>([
123
- request
124
- ], "location_references", location_references.PRIMARY_SHORT as (keyof iLocation_References)[])
125
- }
126
-
127
- export const Delete = restRequest<DeleteCustomAndRequiredFields, iLocation_References, DeleteRequestTableOverrides, iDeleteC6RestResponse<iLocation_References>, RestTableNames>({
128
- C6: C6,
129
- tableName: location_references.TABLE_NAME,
130
- requestMethod: DELETE,
131
- queryCallback: (request) => {
132
- request.success ??= 'Successfully removed the location_references data!'
133
- request.error ??= 'An unknown issue occurred removing the location_references data!'
134
- return request
135
- },
136
- responseCallback: deleteStateLocation_References
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
- }