@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,137 +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, iLocations, locations } from "api/rest/C6";
6
- import Locations from "./Locations";
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_locations` (
14
- `entity_id` binary(16) NOT NULL,
15
- `latitude` varchar(225) DEFAULT NULL,
16
- `longitude` varchar(225) DEFAULT NULL,
17
- `street` varchar(225) DEFAULT NULL,
18
- `city` varchar(40) DEFAULT NULL,
19
- `state` varchar(10) DEFAULT NULL,
20
- `elevation` varchar(40) DEFAULT NULL,
21
- `zip` int DEFAULT NULL,
22
- PRIMARY KEY (`entity_id`),
23
- UNIQUE KEY `entity_location_entity_id_uindex` (`entity_id`),
24
- CONSTRAINT `entity_location_entity_entity_pk_fk` FOREIGN KEY (`entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
25
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
26
- **/
27
-
28
- const Test_Data: iLocations = {
29
-
30
- }
31
-
32
- export default Test_Data;
33
-
34
- xdescribe('REST Locations api', () => {
35
-
36
- let testData = Test_Data;
37
-
38
- test('GET POST PUT DELETE', async () => {
39
-
40
- await act(async () => {
41
-
42
- let selectAllResponse = await Locations.Get({})
43
-
44
- if ('function' === typeof selectAllResponse) {
45
- throw Error('selectAllResponse is a promise, this typically means this specific get request has already run during test setup.');
46
- }
47
-
48
- // We don't care if it is filled or not, just that the request can be made.
49
- expect(selectAllResponse?.data?.rest).not.toBeUndefined();
50
-
51
- const postResponse = await Locations.Post(testData);
52
-
53
- console.log('postResponse', postResponse?.data)
54
-
55
- expect(postResponse?.data?.created).not.toBeUndefined();
56
-
57
- const primaryKey = locations.PRIMARY_SHORT[0];
58
-
59
- const postID = postResponse?.data?.created
60
-
61
- const singleRowSelect = await Locations.Get({
62
- [C6.WHERE]: {
63
- [locations[primaryKey.toUpperCase()]]: postID,
64
- }
65
- })
66
-
67
- if ('function' === typeof singleRowSelect) {
68
- throw Error('singleRowSelect is a promise, this is unexpected.');
69
- }
70
-
71
- console.log('singleRowSelect', singleRowSelect?.data)
72
-
73
- // Ensure the expected response datastructure is returned
74
- expect(singleRowSelect?.data?.rest).not.toBeUndefined();
75
-
76
- // Make sure the previously created post is now returned
77
- expect(typeof singleRowSelect?.data?.rest).toEqual('object');
78
-
79
- // todo - make this work correctly with multiple primary keys
80
- const selectedPostId = singleRowSelect?.data?.rest[0][primaryKey]
81
-
82
- expect(selectedPostId).toEqual(postID);
83
-
84
- const multipleRowSelect = await Locations.Get({
85
- [C6.WHERE]: {
86
- [locations[primaryKey.toUpperCase()]]: [C6.IN, [0, postID]],
87
- }
88
- })
89
-
90
- if ('function' === typeof multipleRowSelect) {
91
- throw Error('singleRowSelect is a promise, this is unexpected.');
92
- }
93
-
94
- console.log('singleRowSelect', multipleRowSelect?.data)
95
-
96
- // Ensure the expected response datastructure is returned
97
- expect(multipleRowSelect?.data?.rest).not.toBeUndefined();
98
-
99
- // Make sure the previously created post is now returned
100
- expect(typeof multipleRowSelect?.data?.rest).toEqual('object');
101
-
102
- testData[primaryKey] = postID
103
-
104
- testData.entity_id = fillString.substring(0, 16);
105
- testData.latitude = fillString.substring(0, 225);
106
- testData.longitude = fillString.substring(0, 225);
107
- testData.street = fillString.substring(0, 225);
108
- testData.city = fillString.substring(0, 40);
109
- testData.state = fillString.substring(0, 10);
110
- testData.elevation = fillString.substring(0, 40);
111
- testData.zip = randomInt;
112
-
113
- // wait for the global state to be updated
114
- expect(CarbonReact.getState<iRestfulObjectArrayTypes>().locations).not.toBeUndefined();
115
-
116
- const updateResponse = await Locations.Put(testData)
117
-
118
- expect(updateResponse?.data?.updated).not.toBeUndefined();
119
-
120
- const deleteResponse = await Locations.Delete({
121
- [primaryKey]: postID
122
- })
123
-
124
- console.log('deleteResponse', deleteResponse?.data)
125
-
126
- expect(deleteResponse?.data?.deleted).not.toBeUndefined();
127
-
128
- await waitFor(async () => {
129
- expect(checkAllRequestsComplete()).toEqual(true);
130
- }, {timeout: 10000, interval: 1000});
131
-
132
- })
133
-
134
- }, 100000);
135
-
136
- })
137
-
@@ -1,149 +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, iLocations, locations, RestTableNames} from "./C6";
17
-
18
- /**
19
- CREATE TABLE `carbon_locations` (
20
- `entity_id` binary(16) NOT NULL,
21
- `latitude` varchar(225) DEFAULT NULL,
22
- `longitude` varchar(225) DEFAULT NULL,
23
- `street` varchar(225) DEFAULT NULL,
24
- `city` varchar(40) DEFAULT NULL,
25
- `state` varchar(10) DEFAULT NULL,
26
- `elevation` varchar(40) DEFAULT NULL,
27
- `zip` int DEFAULT NULL,
28
- PRIMARY KEY (`entity_id`),
29
- UNIQUE KEY `entity_location_entity_id_uindex` (`entity_id`),
30
- CONSTRAINT `entity_location_entity_entity_pk_fk` FOREIGN KEY (`entity_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
31
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
32
- **/
33
-
34
- type GetCustomAndRequiredFields = {}
35
-
36
- type GetRequestTableOverrides = {}
37
-
38
- // required parameters, optional parameters, parameter type overrides, response, and table names
39
- export const Get = restRequest<GetCustomAndRequiredFields, iLocations, GetRequestTableOverrides, iGetC6RestResponse<iLocations>, RestTableNames>({
40
- C6: C6,
41
- tableName: locations.TABLE_NAME,
42
- requestMethod: GET,
43
- queryCallback: (request) => {
44
- request.success ??= 'Successfully received locations!'
45
- request.error ??= 'An unknown issue occurred creating the locations!'
46
- return request
47
- },
48
- responseCallback: (response, _request) => {
49
- updateRestfulObjectArrays<iLocations>(response?.data?.rest, "locations", C6.locations.PRIMARY_SHORT as (keyof iLocations)[])
50
- }
51
- });
52
-
53
- type PutCustomAndRequiredFields = {}
54
-
55
- type PutRequestTableOverrides = {}
56
-
57
- export function putStateLocations(response : AxiosResponse<iPutC6RestResponse<iLocations>>, request : iAPI<Modify<iLocations, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
58
- updateRestfulObjectArrays<iLocations>([
59
- removeInvalidKeys<iLocations>({
60
- ...request,
61
- ...response?.data?.rest,
62
- }, C6.TABLES)
63
- ], "locations", locations.PRIMARY_SHORT as (keyof iLocations)[])
64
- }
65
-
66
- export const Put = restRequest<PutCustomAndRequiredFields, iLocations, PutRequestTableOverrides, iPutC6RestResponse<iLocations>, RestTableNames>({
67
- C6: C6,
68
- tableName: locations.TABLE_NAME,
69
- requestMethod: PUT,
70
- queryCallback: (request) => {
71
- request.success ??= 'Successfully updated locations data!'
72
- request.error ??= 'An unknown issue occurred updating the locations data!'
73
- return request
74
- },
75
- responseCallback: putStateLocations
76
- });
77
-
78
- type PostCustomAndRequiredFields = {}
79
-
80
- type PostRequestTableOverrides = {}
81
-
82
- export function postStateLocations(response : AxiosResponse<iPostC6RestResponse<iLocations>>, request : iAPI<Modify<iLocations, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
83
- if ('number' === typeof id || 'string' === typeof id) {
84
- if (1 !== locations.PRIMARY_SHORT.length) {
85
- console.error("C6 received unexpected result's given the primary key length");
86
- } else {
87
- request[locations.PRIMARY_SHORT[0]] = id
88
- }
89
- }
90
- updateRestfulObjectArrays<iLocations>(
91
- undefined !== request.dataInsertMultipleRows
92
- ? request.dataInsertMultipleRows.map((request, index) => {
93
- return removeInvalidKeys<iLocations>({
94
- ...request,
95
- ...(index === 0 ? response?.data?.rest : {}),
96
- }, C6.TABLES)
97
- })
98
- : [
99
- removeInvalidKeys<iLocations>({
100
- ...request,
101
- ...response?.data?.rest,
102
- }, C6.TABLES)
103
- ],
104
- "locations",
105
- locations.PRIMARY_SHORT as (keyof iLocations)[]
106
- )
107
- }
108
-
109
- export const Post = restRequest<PostCustomAndRequiredFields, iLocations, PostRequestTableOverrides, iPostC6RestResponse<iLocations>, RestTableNames>({
110
- C6: C6,
111
- tableName: locations.TABLE_NAME,
112
- requestMethod: POST,
113
- queryCallback: (request) => {
114
- request.success ??= 'Successfully created the locations data!'
115
- request.error ??= 'An unknown issue occurred creating the locations data!'
116
- return request
117
- },
118
- responseCallback: postStateLocations
119
- });
120
-
121
- type DeleteCustomAndRequiredFields = {}
122
-
123
- type DeleteRequestTableOverrides = {}
124
-
125
- export function deleteStateLocations(_response : AxiosResponse<iDeleteC6RestResponse<iLocations>>, request : iAPI<Modify<iLocations, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
126
- deleteRestfulObjectArrays<iLocations>([
127
- request
128
- ], "locations", locations.PRIMARY_SHORT as (keyof iLocations)[])
129
- }
130
-
131
- export const Delete = restRequest<DeleteCustomAndRequiredFields, iLocations, DeleteRequestTableOverrides, iDeleteC6RestResponse<iLocations>, RestTableNames>({
132
- C6: C6,
133
- tableName: locations.TABLE_NAME,
134
- requestMethod: DELETE,
135
- queryCallback: (request) => {
136
- request.success ??= 'Successfully removed the locations data!'
137
- request.error ??= 'An unknown issue occurred removing the locations data!'
138
- return request
139
- },
140
- responseCallback: deleteStateLocations
141
- });
142
-
143
- export default {
144
- // Export all GET, POST, PUT, DELETE functions for each table
145
- Get,
146
- Post,
147
- Put,
148
- Delete,
149
- }
@@ -1,139 +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, iPhotos, photos } from "api/rest/C6";
6
- import Photos from "./Photos";
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_photos` (
14
- `parent_id` binary(16) NOT NULL,
15
- `photo_id` binary(16) NOT NULL,
16
- `user_id` binary(16) NOT NULL,
17
- `photo_src` longblob NOT NULL,
18
- `photo_description` text,
19
- `photo_upload_date` datetime DEFAULT CURRENT_TIMESTAMP,
20
- PRIMARY KEY (`photo_id`),
21
- UNIQUE KEY `entity_photos_photo_id_uindex` (`photo_id`),
22
- KEY `photos_entity_user_pk_fk` (`user_id`),
23
- KEY `carbon_photos_carbon_carbons_entity_pk_fk2` (`parent_id`),
24
- CONSTRAINT `carbon_photos_carbon_carbons_entity_pk_fk` FOREIGN KEY (`photo_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
25
- CONSTRAINT `carbon_photos_carbon_carbons_entity_pk_fk2` FOREIGN KEY (`parent_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
26
- CONSTRAINT `carbon_photos_carbon_carbons_entity_pk_fk3` FOREIGN KEY (`user_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
- const Test_Data: iPhotos = {
31
-
32
- photo_description: fillString.substring(0, ),
33
-
34
- }
35
-
36
- export default Test_Data;
37
-
38
- xdescribe('REST Photos api', () => {
39
-
40
- let testData = Test_Data;
41
-
42
- test('GET POST PUT DELETE', async () => {
43
-
44
- await act(async () => {
45
-
46
- let selectAllResponse = await Photos.Get({})
47
-
48
- if ('function' === typeof selectAllResponse) {
49
- throw Error('selectAllResponse is a promise, this typically means this specific get request has already run during test setup.');
50
- }
51
-
52
- // We don't care if it is filled or not, just that the request can be made.
53
- expect(selectAllResponse?.data?.rest).not.toBeUndefined();
54
-
55
- const postResponse = await Photos.Post(testData);
56
-
57
- console.log('postResponse', postResponse?.data)
58
-
59
- expect(postResponse?.data?.created).not.toBeUndefined();
60
-
61
- const primaryKey = photos.PRIMARY_SHORT[0];
62
-
63
- const postID = postResponse?.data?.created
64
-
65
- const singleRowSelect = await Photos.Get({
66
- [C6.WHERE]: {
67
- [photos[primaryKey.toUpperCase()]]: postID,
68
- }
69
- })
70
-
71
- if ('function' === typeof singleRowSelect) {
72
- throw Error('singleRowSelect is a promise, this is unexpected.');
73
- }
74
-
75
- console.log('singleRowSelect', singleRowSelect?.data)
76
-
77
- // Ensure the expected response datastructure is returned
78
- expect(singleRowSelect?.data?.rest).not.toBeUndefined();
79
-
80
- // Make sure the previously created post is now returned
81
- expect(typeof singleRowSelect?.data?.rest).toEqual('object');
82
-
83
- // todo - make this work correctly with multiple primary keys
84
- const selectedPostId = singleRowSelect?.data?.rest[0][primaryKey]
85
-
86
- expect(selectedPostId).toEqual(postID);
87
-
88
- const multipleRowSelect = await Photos.Get({
89
- [C6.WHERE]: {
90
- [photos[primaryKey.toUpperCase()]]: [C6.IN, [0, postID]],
91
- }
92
- })
93
-
94
- if ('function' === typeof multipleRowSelect) {
95
- throw Error('singleRowSelect is a promise, this is unexpected.');
96
- }
97
-
98
- console.log('singleRowSelect', multipleRowSelect?.data)
99
-
100
- // Ensure the expected response datastructure is returned
101
- expect(multipleRowSelect?.data?.rest).not.toBeUndefined();
102
-
103
- // Make sure the previously created post is now returned
104
- expect(typeof multipleRowSelect?.data?.rest).toEqual('object');
105
-
106
- testData[primaryKey] = postID
107
-
108
- testData.parent_id = fillString.substring(0, 16);
109
- testData.photo_id = fillString.substring(0, 16);
110
- testData.user_id = fillString.substring(0, 16);
111
- testData.photo_src = fillString.substring(0, );
112
- testData.photo_description = fillString.substring(0, );
113
- testData.photo_upload_date = fillString.substring(0, );
114
-
115
- // wait for the global state to be updated
116
- expect(CarbonReact.getState<iRestfulObjectArrayTypes>().photos).not.toBeUndefined();
117
-
118
- const updateResponse = await Photos.Put(testData)
119
-
120
- expect(updateResponse?.data?.updated).not.toBeUndefined();
121
-
122
- const deleteResponse = await Photos.Delete({
123
- [primaryKey]: postID
124
- })
125
-
126
- console.log('deleteResponse', deleteResponse?.data)
127
-
128
- expect(deleteResponse?.data?.deleted).not.toBeUndefined();
129
-
130
- await waitFor(async () => {
131
- expect(checkAllRequestsComplete()).toEqual(true);
132
- }, {timeout: 10000, interval: 1000});
133
-
134
- })
135
-
136
- }, 100000);
137
-
138
- })
139
-
@@ -1,151 +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, iPhotos, photos, RestTableNames} from "./C6";
17
-
18
- /**
19
- CREATE TABLE `carbon_photos` (
20
- `parent_id` binary(16) NOT NULL,
21
- `photo_id` binary(16) NOT NULL,
22
- `user_id` binary(16) NOT NULL,
23
- `photo_src` longblob NOT NULL,
24
- `photo_description` text,
25
- `photo_upload_date` datetime DEFAULT CURRENT_TIMESTAMP,
26
- PRIMARY KEY (`photo_id`),
27
- UNIQUE KEY `entity_photos_photo_id_uindex` (`photo_id`),
28
- KEY `photos_entity_user_pk_fk` (`user_id`),
29
- KEY `carbon_photos_carbon_carbons_entity_pk_fk2` (`parent_id`),
30
- CONSTRAINT `carbon_photos_carbon_carbons_entity_pk_fk` FOREIGN KEY (`photo_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
31
- CONSTRAINT `carbon_photos_carbon_carbons_entity_pk_fk2` FOREIGN KEY (`parent_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE,
32
- CONSTRAINT `carbon_photos_carbon_carbons_entity_pk_fk3` FOREIGN KEY (`user_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
33
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
34
- **/
35
-
36
- type GetCustomAndRequiredFields = {}
37
-
38
- type GetRequestTableOverrides = {}
39
-
40
- // required parameters, optional parameters, parameter type overrides, response, and table names
41
- export const Get = restRequest<GetCustomAndRequiredFields, iPhotos, GetRequestTableOverrides, iGetC6RestResponse<iPhotos>, RestTableNames>({
42
- C6: C6,
43
- tableName: photos.TABLE_NAME,
44
- requestMethod: GET,
45
- queryCallback: (request) => {
46
- request.success ??= 'Successfully received photos!'
47
- request.error ??= 'An unknown issue occurred creating the photos!'
48
- return request
49
- },
50
- responseCallback: (response, _request) => {
51
- updateRestfulObjectArrays<iPhotos>(response?.data?.rest, "photos", C6.photos.PRIMARY_SHORT as (keyof iPhotos)[])
52
- }
53
- });
54
-
55
- type PutCustomAndRequiredFields = {}
56
-
57
- type PutRequestTableOverrides = {}
58
-
59
- export function putStatePhotos(response : AxiosResponse<iPutC6RestResponse<iPhotos>>, request : iAPI<Modify<iPhotos, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
60
- updateRestfulObjectArrays<iPhotos>([
61
- removeInvalidKeys<iPhotos>({
62
- ...request,
63
- ...response?.data?.rest,
64
- }, C6.TABLES)
65
- ], "photos", photos.PRIMARY_SHORT as (keyof iPhotos)[])
66
- }
67
-
68
- export const Put = restRequest<PutCustomAndRequiredFields, iPhotos, PutRequestTableOverrides, iPutC6RestResponse<iPhotos>, RestTableNames>({
69
- C6: C6,
70
- tableName: photos.TABLE_NAME,
71
- requestMethod: PUT,
72
- queryCallback: (request) => {
73
- request.success ??= 'Successfully updated photos data!'
74
- request.error ??= 'An unknown issue occurred updating the photos data!'
75
- return request
76
- },
77
- responseCallback: putStatePhotos
78
- });
79
-
80
- type PostCustomAndRequiredFields = {}
81
-
82
- type PostRequestTableOverrides = {}
83
-
84
- export function postStatePhotos(response : AxiosResponse<iPostC6RestResponse<iPhotos>>, request : iAPI<Modify<iPhotos, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
85
- if ('number' === typeof id || 'string' === typeof id) {
86
- if (1 !== photos.PRIMARY_SHORT.length) {
87
- console.error("C6 received unexpected result's given the primary key length");
88
- } else {
89
- request[photos.PRIMARY_SHORT[0]] = id
90
- }
91
- }
92
- updateRestfulObjectArrays<iPhotos>(
93
- undefined !== request.dataInsertMultipleRows
94
- ? request.dataInsertMultipleRows.map((request, index) => {
95
- return removeInvalidKeys<iPhotos>({
96
- ...request,
97
- ...(index === 0 ? response?.data?.rest : {}),
98
- }, C6.TABLES)
99
- })
100
- : [
101
- removeInvalidKeys<iPhotos>({
102
- ...request,
103
- ...response?.data?.rest,
104
- }, C6.TABLES)
105
- ],
106
- "photos",
107
- photos.PRIMARY_SHORT as (keyof iPhotos)[]
108
- )
109
- }
110
-
111
- export const Post = restRequest<PostCustomAndRequiredFields, iPhotos, PostRequestTableOverrides, iPostC6RestResponse<iPhotos>, RestTableNames>({
112
- C6: C6,
113
- tableName: photos.TABLE_NAME,
114
- requestMethod: POST,
115
- queryCallback: (request) => {
116
- request.success ??= 'Successfully created the photos data!'
117
- request.error ??= 'An unknown issue occurred creating the photos data!'
118
- return request
119
- },
120
- responseCallback: postStatePhotos
121
- });
122
-
123
- type DeleteCustomAndRequiredFields = {}
124
-
125
- type DeleteRequestTableOverrides = {}
126
-
127
- export function deleteStatePhotos(_response : AxiosResponse<iDeleteC6RestResponse<iPhotos>>, request : iAPI<Modify<iPhotos, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
128
- deleteRestfulObjectArrays<iPhotos>([
129
- request
130
- ], "photos", photos.PRIMARY_SHORT as (keyof iPhotos)[])
131
- }
132
-
133
- export const Delete = restRequest<DeleteCustomAndRequiredFields, iPhotos, DeleteRequestTableOverrides, iDeleteC6RestResponse<iPhotos>, RestTableNames>({
134
- C6: C6,
135
- tableName: photos.TABLE_NAME,
136
- requestMethod: DELETE,
137
- queryCallback: (request) => {
138
- request.success ??= 'Successfully removed the photos data!'
139
- request.error ??= 'An unknown issue occurred removing the photos data!'
140
- return request
141
- },
142
- responseCallback: deleteStatePhotos
143
- });
144
-
145
- export default {
146
- // Export all GET, POST, PUT, DELETE functions for each table
147
- Get,
148
- Post,
149
- Put,
150
- Delete,
151
- }