@carbonorm/carbonnode 1.4.4 → 1.5.0

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/README.md CHANGED
@@ -9,9 +9,9 @@
9
9
  # CarbonNode (Alpha Release)
10
10
 
11
11
  CarbonNode is a part of the CarbonORM series. It is a NodeJS MySQL ORM that is designed to work with CarbonPHP. This langauge
12
- will implement the same ORM as CarbonPHP, but will be written in Typescript. Currently only C6 enabled request can be sent
12
+ will implement the same ORM as CarbonPHP, but will be written in Typescript. Currently only C6 enabled requests can be sent
13
13
  using the bindings. Receiving API requests and handling it appropriately is not yet implemented. This is scheduled for
14
- early 2023. This repository is in the early stages of development an any support is greatly appreciated.
14
+ early 2024. This repository is in the early stages of development an any support is greatly appreciated.
15
15
 
16
16
  ## Alpha Release
17
17
 
@@ -65,6 +65,502 @@ generate. Here are the templates used to generate the code:
65
65
  2) [Table.ts.handlebars](https://github.com/CarbonORM/CarbonNode/blob/main/scripts/assets/handlebars/Table.ts.handlebars)
66
66
  3) [Websocket.ts.handlebars](https://github.com/CarbonORM/CarbonNode/blob/main/scripts/assets/handlebars/WsLiveUpdates.ts.handlebars)
67
67
 
68
+ #### Generation Example
69
+
70
+ 0) **npx generateRestBindings** is executed.
71
+ 1) **The MySQL dump tool** outputs a strcture for every table.
72
+ ```sql
73
+ --
74
+ -- Table structure for table `carbon_users`
75
+ --
76
+
77
+ DROP TABLE IF EXISTS `carbon_users`;
78
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
79
+ /*!50503 SET character_set_client = utf8mb4 */;
80
+ CREATE TABLE `carbon_users` (
81
+ `user_username` varchar(100) NOT NULL,
82
+ `user_password` varchar(225) NOT NULL,
83
+ `user_id` binary(16) NOT NULL,
84
+ `user_type` varchar(20) NOT NULL DEFAULT 'Athlete',
85
+ `user_sport` varchar(20) DEFAULT 'GOLF',
86
+ `user_session_id` varchar(225) DEFAULT NULL,
87
+ `user_facebook_id` varchar(225) DEFAULT NULL,
88
+ `user_first_name` varchar(25) NOT NULL,
89
+ `user_last_name` varchar(25) NOT NULL,
90
+ `user_profile_pic` varchar(225) DEFAULT NULL,
91
+ `user_profile_uri` varchar(225) DEFAULT NULL,
92
+ `user_cover_photo` varchar(225) DEFAULT NULL,
93
+ `user_birthday` varchar(9) DEFAULT NULL,
94
+ `user_gender` varchar(25) DEFAULT NULL,
95
+ `user_about_me` varchar(225) DEFAULT NULL,
96
+ `user_rank` int DEFAULT '0',
97
+ `user_email` varchar(50) NOT NULL,
98
+ `user_email_code` varchar(225) DEFAULT NULL,
99
+ `user_email_confirmed` tinyint DEFAULT '0' COMMENT 'need to change to enums, but no support in rest yet',
100
+ `user_generated_string` varchar(200) DEFAULT NULL,
101
+ `user_membership` int DEFAULT '0',
102
+ `user_deactivated` tinyint DEFAULT '0',
103
+ `user_last_login` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
104
+ `user_ip` varchar(20) NOT NULL,
105
+ `user_education_history` varchar(200) DEFAULT NULL,
106
+ `user_location` varchar(20) DEFAULT NULL,
107
+ `user_creation_date` datetime DEFAULT CURRENT_TIMESTAMP,
108
+ PRIMARY KEY (`user_id`),
109
+ UNIQUE KEY `carbon_users_user_username_uindex` (`user_username`),
110
+ UNIQUE KEY `user_user_profile_uri_uindex` (`user_profile_uri`),
111
+ UNIQUE KEY `carbon_users_user_facebook_id_uindex` (`user_facebook_id`),
112
+ CONSTRAINT `user_entity_entity_pk_fk` FOREIGN KEY (`user_id`) REFERENCES `carbon_carbons` (`entity_pk`) ON DELETE CASCADE ON UPDATE CASCADE
113
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
114
+ /*!40101 SET character_set_client = @saved_cs_client */;
115
+ ```
116
+ 3) **Profit**
117
+ - C6 will produce 1-1 constants.
118
+ ```typescript
119
+ export interface iUsers {
120
+ 'user_username'?: string;
121
+ 'user_password'?: string;
122
+ 'user_id'?: string;
123
+ 'user_type'?: string;
124
+ 'user_sport'?: string | null;
125
+ 'user_session_id'?: string | null;
126
+ 'user_facebook_id'?: string | null;
127
+ 'user_first_name'?: string;
128
+ 'user_last_name'?: string;
129
+ 'user_profile_pic'?: string | null;
130
+ 'user_profile_uri'?: string | null;
131
+ 'user_cover_photo'?: string | null;
132
+ 'user_birthday'?: string | null;
133
+ 'user_gender'?: string | null;
134
+ 'user_about_me'?: string | null;
135
+ 'user_rank'?: number | null;
136
+ 'user_email'?: string;
137
+ 'user_email_code'?: string | null;
138
+ 'user_email_confirmed'?: number | null;
139
+ 'user_generated_string'?: string | null;
140
+ 'user_membership'?: number | null;
141
+ 'user_deactivated'?: number | null;
142
+ 'user_last_login'?: string;
143
+ 'user_ip'?: string;
144
+ 'user_education_history'?: string | null;
145
+ 'user_location'?: string | null;
146
+ 'user_creation_date'?: string | null;
147
+ }
148
+
149
+ interface iDefineUsers {
150
+ 'USER_USERNAME': string;
151
+ 'USER_PASSWORD': string;
152
+ 'USER_ID': string;
153
+ 'USER_TYPE': string;
154
+ 'USER_SPORT': string;
155
+ 'USER_SESSION_ID': string;
156
+ 'USER_FACEBOOK_ID': string;
157
+ 'USER_FIRST_NAME': string;
158
+ 'USER_LAST_NAME': string;
159
+ 'USER_PROFILE_PIC': string;
160
+ 'USER_PROFILE_URI': string;
161
+ 'USER_COVER_PHOTO': string;
162
+ 'USER_BIRTHDAY': string;
163
+ 'USER_GENDER': string;
164
+ 'USER_ABOUT_ME': string;
165
+ 'USER_RANK': string;
166
+ 'USER_EMAIL': string;
167
+ 'USER_EMAIL_CODE': string;
168
+ 'USER_EMAIL_CONFIRMED': string;
169
+ 'USER_GENERATED_STRING': string;
170
+ 'USER_MEMBERSHIP': string;
171
+ 'USER_DEACTIVATED': string;
172
+ 'USER_LAST_LOGIN': string;
173
+ 'USER_IP': string;
174
+ 'USER_EDUCATION_HISTORY': string;
175
+ 'USER_LOCATION': string;
176
+ 'USER_CREATION_DATE': string;
177
+ }
178
+
179
+ export const users: iC6RestfulModel<RestTableNames> & iDefineUsers = {
180
+ TABLE_NAME: 'carbon_users',
181
+ USER_USERNAME: 'carbon_users.user_username',
182
+ USER_PASSWORD: 'carbon_users.user_password',
183
+ USER_ID: 'carbon_users.user_id',
184
+ USER_TYPE: 'carbon_users.user_type',
185
+ USER_SPORT: 'carbon_users.user_sport',
186
+ USER_SESSION_ID: 'carbon_users.user_session_id',
187
+ USER_FACEBOOK_ID: 'carbon_users.user_facebook_id',
188
+ USER_FIRST_NAME: 'carbon_users.user_first_name',
189
+ USER_LAST_NAME: 'carbon_users.user_last_name',
190
+ USER_PROFILE_PIC: 'carbon_users.user_profile_pic',
191
+ USER_PROFILE_URI: 'carbon_users.user_profile_uri',
192
+ USER_COVER_PHOTO: 'carbon_users.user_cover_photo',
193
+ USER_BIRTHDAY: 'carbon_users.user_birthday',
194
+ USER_GENDER: 'carbon_users.user_gender',
195
+ USER_ABOUT_ME: 'carbon_users.user_about_me',
196
+ USER_RANK: 'carbon_users.user_rank',
197
+ USER_EMAIL: 'carbon_users.user_email',
198
+ USER_EMAIL_CODE: 'carbon_users.user_email_code',
199
+ USER_EMAIL_CONFIRMED: 'carbon_users.user_email_confirmed',
200
+ USER_GENERATED_STRING: 'carbon_users.user_generated_string',
201
+ USER_MEMBERSHIP: 'carbon_users.user_membership',
202
+ USER_DEACTIVATED: 'carbon_users.user_deactivated',
203
+ USER_LAST_LOGIN: 'carbon_users.user_last_login',
204
+ USER_IP: 'carbon_users.user_ip',
205
+ USER_EDUCATION_HISTORY: 'carbon_users.user_education_history',
206
+ USER_LOCATION: 'carbon_users.user_location',
207
+ USER_CREATION_DATE: 'carbon_users.user_creation_date',
208
+ PRIMARY: [
209
+ 'carbon_users.user_id',
210
+ ],
211
+ PRIMARY_SHORT: [
212
+ 'user_id',
213
+ ],
214
+ COLUMNS: {
215
+ 'carbon_users.user_username': 'user_username',
216
+ 'carbon_users.user_password': 'user_password',
217
+ 'carbon_users.user_id': 'user_id',
218
+ 'carbon_users.user_type': 'user_type',
219
+ 'carbon_users.user_sport': 'user_sport',
220
+ 'carbon_users.user_session_id': 'user_session_id',
221
+ 'carbon_users.user_facebook_id': 'user_facebook_id',
222
+ 'carbon_users.user_first_name': 'user_first_name',
223
+ 'carbon_users.user_last_name': 'user_last_name',
224
+ 'carbon_users.user_profile_pic': 'user_profile_pic',
225
+ 'carbon_users.user_profile_uri': 'user_profile_uri',
226
+ 'carbon_users.user_cover_photo': 'user_cover_photo',
227
+ 'carbon_users.user_birthday': 'user_birthday',
228
+ 'carbon_users.user_gender': 'user_gender',
229
+ 'carbon_users.user_about_me': 'user_about_me',
230
+ 'carbon_users.user_rank': 'user_rank',
231
+ 'carbon_users.user_email': 'user_email',
232
+ 'carbon_users.user_email_code': 'user_email_code',
233
+ 'carbon_users.user_email_confirmed': 'user_email_confirmed',
234
+ 'carbon_users.user_generated_string': 'user_generated_string',
235
+ 'carbon_users.user_membership': 'user_membership',
236
+ 'carbon_users.user_deactivated': 'user_deactivated',
237
+ 'carbon_users.user_last_login': 'user_last_login',
238
+ 'carbon_users.user_ip': 'user_ip',
239
+ 'carbon_users.user_education_history': 'user_education_history',
240
+ 'carbon_users.user_location': 'user_location',
241
+ 'carbon_users.user_creation_date': 'user_creation_date',
242
+ },
243
+ TYPE_VALIDATION: {
244
+ 'carbon_users.user_username': {
245
+ MYSQL_TYPE: 'varchar',
246
+ MAX_LENGTH: '100',
247
+ AUTO_INCREMENT: false,
248
+ SKIP_COLUMN_IN_POST: false
249
+ },
250
+ 'carbon_users.user_password': {
251
+ MYSQL_TYPE: 'varchar',
252
+ MAX_LENGTH: '225',
253
+ AUTO_INCREMENT: false,
254
+ SKIP_COLUMN_IN_POST: false
255
+ },
256
+ 'carbon_users.user_id': {
257
+ MYSQL_TYPE: 'binary',
258
+ MAX_LENGTH: '16',
259
+ AUTO_INCREMENT: false,
260
+ SKIP_COLUMN_IN_POST: false
261
+ },
262
+ 'carbon_users.user_type': {
263
+ MYSQL_TYPE: 'varchar',
264
+ MAX_LENGTH: '20',
265
+ AUTO_INCREMENT: false,
266
+ SKIP_COLUMN_IN_POST: false
267
+ },
268
+ 'carbon_users.user_sport': {
269
+ MYSQL_TYPE: 'varchar',
270
+ MAX_LENGTH: '20',
271
+ AUTO_INCREMENT: false,
272
+ SKIP_COLUMN_IN_POST: false
273
+ },
274
+ 'carbon_users.user_session_id': {
275
+ MYSQL_TYPE: 'varchar',
276
+ MAX_LENGTH: '225',
277
+ AUTO_INCREMENT: false,
278
+ SKIP_COLUMN_IN_POST: false
279
+ },
280
+ 'carbon_users.user_facebook_id': {
281
+ MYSQL_TYPE: 'varchar',
282
+ MAX_LENGTH: '225',
283
+ AUTO_INCREMENT: false,
284
+ SKIP_COLUMN_IN_POST: false
285
+ },
286
+ 'carbon_users.user_first_name': {
287
+ MYSQL_TYPE: 'varchar',
288
+ MAX_LENGTH: '25',
289
+ AUTO_INCREMENT: false,
290
+ SKIP_COLUMN_IN_POST: false
291
+ },
292
+ 'carbon_users.user_last_name': {
293
+ MYSQL_TYPE: 'varchar',
294
+ MAX_LENGTH: '25',
295
+ AUTO_INCREMENT: false,
296
+ SKIP_COLUMN_IN_POST: false
297
+ },
298
+ 'carbon_users.user_profile_pic': {
299
+ MYSQL_TYPE: 'varchar',
300
+ MAX_LENGTH: '225',
301
+ AUTO_INCREMENT: false,
302
+ SKIP_COLUMN_IN_POST: false
303
+ },
304
+ 'carbon_users.user_profile_uri': {
305
+ MYSQL_TYPE: 'varchar',
306
+ MAX_LENGTH: '225',
307
+ AUTO_INCREMENT: false,
308
+ SKIP_COLUMN_IN_POST: false
309
+ },
310
+ 'carbon_users.user_cover_photo': {
311
+ MYSQL_TYPE: 'varchar',
312
+ MAX_LENGTH: '225',
313
+ AUTO_INCREMENT: false,
314
+ SKIP_COLUMN_IN_POST: false
315
+ },
316
+ 'carbon_users.user_birthday': {
317
+ MYSQL_TYPE: 'varchar',
318
+ MAX_LENGTH: '9',
319
+ AUTO_INCREMENT: false,
320
+ SKIP_COLUMN_IN_POST: false
321
+ },
322
+ 'carbon_users.user_gender': {
323
+ MYSQL_TYPE: 'varchar',
324
+ MAX_LENGTH: '25',
325
+ AUTO_INCREMENT: false,
326
+ SKIP_COLUMN_IN_POST: false
327
+ },
328
+ 'carbon_users.user_about_me': {
329
+ MYSQL_TYPE: 'varchar',
330
+ MAX_LENGTH: '225',
331
+ AUTO_INCREMENT: false,
332
+ SKIP_COLUMN_IN_POST: false
333
+ },
334
+ 'carbon_users.user_rank': {
335
+ MYSQL_TYPE: 'int',
336
+ MAX_LENGTH: '',
337
+ AUTO_INCREMENT: false,
338
+ SKIP_COLUMN_IN_POST: false
339
+ },
340
+ 'carbon_users.user_email': {
341
+ MYSQL_TYPE: 'varchar',
342
+ MAX_LENGTH: '50',
343
+ AUTO_INCREMENT: false,
344
+ SKIP_COLUMN_IN_POST: false
345
+ },
346
+ 'carbon_users.user_email_code': {
347
+ MYSQL_TYPE: 'varchar',
348
+ MAX_LENGTH: '225',
349
+ AUTO_INCREMENT: false,
350
+ SKIP_COLUMN_IN_POST: false
351
+ },
352
+ 'carbon_users.user_email_confirmed': {
353
+ MYSQL_TYPE: 'tinyint',
354
+ MAX_LENGTH: '',
355
+ AUTO_INCREMENT: false,
356
+ SKIP_COLUMN_IN_POST: false
357
+ },
358
+ 'carbon_users.user_generated_string': {
359
+ MYSQL_TYPE: 'varchar',
360
+ MAX_LENGTH: '200',
361
+ AUTO_INCREMENT: false,
362
+ SKIP_COLUMN_IN_POST: false
363
+ },
364
+ 'carbon_users.user_membership': {
365
+ MYSQL_TYPE: 'int',
366
+ MAX_LENGTH: '',
367
+ AUTO_INCREMENT: false,
368
+ SKIP_COLUMN_IN_POST: false
369
+ },
370
+ 'carbon_users.user_deactivated': {
371
+ MYSQL_TYPE: 'tinyint',
372
+ MAX_LENGTH: '',
373
+ AUTO_INCREMENT: false,
374
+ SKIP_COLUMN_IN_POST: false
375
+ },
376
+ 'carbon_users.user_last_login': {
377
+ MYSQL_TYPE: 'datetime',
378
+ MAX_LENGTH: '',
379
+ AUTO_INCREMENT: false,
380
+ SKIP_COLUMN_IN_POST: false
381
+ },
382
+ 'carbon_users.user_ip': {
383
+ MYSQL_TYPE: 'varchar',
384
+ MAX_LENGTH: '20',
385
+ AUTO_INCREMENT: false,
386
+ SKIP_COLUMN_IN_POST: false
387
+ },
388
+ 'carbon_users.user_education_history': {
389
+ MYSQL_TYPE: 'varchar',
390
+ MAX_LENGTH: '200',
391
+ AUTO_INCREMENT: false,
392
+ SKIP_COLUMN_IN_POST: false
393
+ },
394
+ 'carbon_users.user_location': {
395
+ MYSQL_TYPE: 'varchar',
396
+ MAX_LENGTH: '20',
397
+ AUTO_INCREMENT: false,
398
+ SKIP_COLUMN_IN_POST: false
399
+ },
400
+ 'carbon_users.user_creation_date': {
401
+ MYSQL_TYPE: 'datetime',
402
+ MAX_LENGTH: '',
403
+ AUTO_INCREMENT: false,
404
+ SKIP_COLUMN_IN_POST: false
405
+ },
406
+ },
407
+ REGEX_VALIDATION: {
408
+ },
409
+ TABLE_REFERENCES: {
410
+ 'user_id': [{
411
+ TABLE: 'carbon_carbons',
412
+ COLUMN: 'entity_pk',
413
+ CONSTRAINT: 'user_entity_entity_pk_fk',
414
+ },],
415
+ },
416
+ TABLE_REFERENCED_BY: {
417
+
418
+ }
419
+ }
420
+ ```
421
+ - A File named the pascal case formated table name will be created with bindings to query the middleware (backend langague) -> MySQL.
422
+ ```typescript
423
+ import {AxiosResponse} from "axios";
424
+ import {
425
+ iPostC6RestResponse,
426
+ restRequest,
427
+ GET,
428
+ POST,
429
+ PUT,
430
+ DELETE,
431
+ iDeleteC6RestResponse,
432
+ iGetC6RestResponse,
433
+ iPutC6RestResponse,
434
+ removeInvalidKeys,
435
+ iAPI,
436
+ Modify
437
+ } from "@carbonorm/carbonnode";
438
+ import {deleteRestfulObjectArrays, updateRestfulObjectArrays} from "@carbonorm/carbonreact";
439
+ import {C6, iUsers, users, RestTableNames} from "./C6";
440
+
441
+ type GetCustomAndRequiredFields = {}
442
+
443
+ type GetRequestTableOverrides = {}
444
+
445
+ // required parameters, optional parameters, parameter type overrides, response, and table names
446
+ const Get = restRequest<GetCustomAndRequiredFields, iUsers, GetRequestTableOverrides, iGetC6RestResponse<iUsers>, RestTableNames>({
447
+ C6: C6,
448
+ tableName: users.TABLE_NAME,
449
+ requestMethod: GET,
450
+ queryCallback: (request) => {
451
+ request.success ??= 'Successfully received users!'
452
+ request.error ??= 'An unknown issue occurred creating the users!'
453
+ return request
454
+ },
455
+ responseCallback: (response, _request) => {
456
+ const responseData = response?.data?.rest;
457
+ updateRestfulObjectArrays<iUsers>(Array.isArray(responseData) ? responseData : [responseData], "users", C6.users.PRIMARY_SHORT as (keyof iUsers)[])
458
+ }
459
+ });
460
+
461
+ type PutCustomAndRequiredFields = {}
462
+
463
+ type PutRequestTableOverrides = {}
464
+
465
+ export function putStateUsers(response : AxiosResponse<iPutC6RestResponse<iUsers>>, request : iAPI<Modify<iUsers, PutRequestTableOverrides>> & PutCustomAndRequiredFields) {
466
+ updateRestfulObjectArrays<iUsers>([
467
+ removeInvalidKeys<iUsers>({
468
+ ...request,
469
+ ...response?.data?.rest,
470
+ }, C6.TABLES)
471
+ ], "users", users.PRIMARY_SHORT as (keyof iUsers)[])
472
+ }
473
+
474
+ const Put = restRequest<PutCustomAndRequiredFields, iUsers, PutRequestTableOverrides, iPutC6RestResponse<iUsers>, RestTableNames>({
475
+ C6: C6,
476
+ tableName: users.TABLE_NAME,
477
+ requestMethod: PUT,
478
+ queryCallback: (request) => {
479
+ request.success ??= 'Successfully updated users data!'
480
+ request.error ??= 'An unknown issue occurred updating the users data!'
481
+ return request
482
+ },
483
+ responseCallback: putStateUsers
484
+ });
485
+
486
+ type PostCustomAndRequiredFields = {}
487
+
488
+ type PostRequestTableOverrides = {}
489
+
490
+ export function postStateUsers(response : AxiosResponse<iPostC6RestResponse<iUsers>>, request : iAPI<Modify<iUsers, PostRequestTableOverrides>> & PostCustomAndRequiredFields, id: string | number | boolean) {
491
+ if ('number' === typeof id || 'string' === typeof id) {
492
+ if (1 !== users.PRIMARY_SHORT.length) {
493
+ console.error("C6 received unexpected result's given the primary key length");
494
+ } else {
495
+ request[users.PRIMARY_SHORT[0]] = id
496
+ }
497
+ }
498
+ updateRestfulObjectArrays<iUsers>(
499
+ undefined !== request.dataInsertMultipleRows
500
+ ? request.dataInsertMultipleRows.map((request, index) => {
501
+ return removeInvalidKeys<iUsers>({
502
+ ...request,
503
+ ...(index === 0 ? response?.data?.rest : {}),
504
+ }, C6.TABLES)
505
+ })
506
+ : [
507
+ removeInvalidKeys<iUsers>({
508
+ ...request,
509
+ ...response?.data?.rest,
510
+ }, C6.TABLES)
511
+ ],
512
+ "users",
513
+ users.PRIMARY_SHORT as (keyof iUsers)[]
514
+ )
515
+ }
516
+
517
+ const Post = restRequest<PostCustomAndRequiredFields, iUsers, PostRequestTableOverrides, iPostC6RestResponse<iUsers>, RestTableNames>({
518
+ C6: C6,
519
+ tableName: users.TABLE_NAME,
520
+ requestMethod: POST,
521
+ queryCallback: (request) => {
522
+ request.success ??= 'Successfully created the users data!'
523
+ request.error ??= 'An unknown issue occurred creating the users data!'
524
+ return request
525
+ },
526
+ responseCallback: postStateUsers
527
+ });
528
+
529
+ type DeleteCustomAndRequiredFields = {}
530
+
531
+ type DeleteRequestTableOverrides = {}
532
+
533
+ export function deleteStateUsers(_response : AxiosResponse<iDeleteC6RestResponse<iUsers>>, request : iAPI<Modify<iUsers, DeleteRequestTableOverrides>> & DeleteCustomAndRequiredFields) {
534
+ deleteRestfulObjectArrays<iUsers>([
535
+ request
536
+ ], "users", users.PRIMARY_SHORT as (keyof iUsers)[])
537
+ }
538
+
539
+ const Delete = restRequest<DeleteCustomAndRequiredFields, iUsers, DeleteRequestTableOverrides, iDeleteC6RestResponse<iUsers>, RestTableNames>({
540
+ C6: C6,
541
+ tableName: users.TABLE_NAME,
542
+ requestMethod: DELETE,
543
+ queryCallback: (request) => {
544
+ request.success ??= 'Successfully removed the users data!'
545
+ request.error ??= 'An unknown issue occurred removing the users data!'
546
+ return request
547
+ },
548
+ responseCallback: deleteStateUsers
549
+ });
550
+
551
+ const Users = {
552
+ // Export all GET, POST, PUT, DELETE functions for each table
553
+ Get,
554
+ Post,
555
+ Put,
556
+ Delete,
557
+ }
558
+
559
+ export default Users;
560
+ ```
561
+
562
+
563
+
68
564
 
69
565
  # Support and Issues
70
566
 
@@ -102,6 +102,7 @@ interface iRest<CustomAndRequiredFields extends {
102
102
  C6: iC6Object;
103
103
  axios?: AxiosInstance;
104
104
  restURL?: string;
105
+ withCredentials?: boolean;
105
106
  tableName: RestShortTableNames | RestShortTableNames[];
106
107
  requestMethod: iRestMethods;
107
108
  clearCache?: () => void;
@@ -132,5 +133,5 @@ export default function restApi<CustomAndRequiredFields extends {
132
133
  [key: string]: any;
133
134
  } = any, RequestTableOverrides extends {
134
135
  [key: string]: any;
135
- } = any, ResponseDataType = any, RestShortTableNames extends string = any>({ C6, axios, restURL, tableName, requestMethod, queryCallback, responseCallback, skipPrimaryCheck, clearCache }: iRest<CustomAndRequiredFields, RestTableInterfaces, RequestTableOverrides, ResponseDataType, RestShortTableNames>): (request?: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields) => apiReturn<ResponseDataType>;
136
+ } = any, ResponseDataType = any, RestShortTableNames extends string = any>({ C6, axios, restURL, withCredentials, tableName, requestMethod, queryCallback, responseCallback, skipPrimaryCheck, clearCache }: iRest<CustomAndRequiredFields, RestTableInterfaces, RequestTableOverrides, ResponseDataType, RestShortTableNames>): (request?: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields) => apiReturn<ResponseDataType>;
136
137
  export {};
package/dist/index.cjs.js CHANGED
@@ -472,7 +472,7 @@ function extendedTypeHints() {
472
472
  return function (argv) { return restApi(argv); };
473
473
  }
474
474
  function restApi(_a) {
475
- var C6 = _a.C6, _b = _a.axios, axios = _b === void 0 ? axiosInstance : _b, _c = _a.restURL, restURL = _c === void 0 ? '/rest/' : _c, tableName = _a.tableName, _d = _a.requestMethod, requestMethod = _d === void 0 ? GET : _d, _e = _a.queryCallback, queryCallback = _e === void 0 ? {} : _e, responseCallback = _a.responseCallback, _f = _a.skipPrimaryCheck, skipPrimaryCheck = _f === void 0 ? false : _f, _g = _a.clearCache, clearCache = _g === void 0 ? undefined : _g;
475
+ var C6 = _a.C6, _b = _a.axios, axios = _b === void 0 ? axiosInstance : _b, _c = _a.restURL, restURL = _c === void 0 ? '/rest/' : _c, _d = _a.withCredentials, withCredentials = _d === void 0 ? true : _d, tableName = _a.tableName, _e = _a.requestMethod, requestMethod = _e === void 0 ? GET : _e, _f = _a.queryCallback, queryCallback = _f === void 0 ? {} : _f, responseCallback = _a.responseCallback, _g = _a.skipPrimaryCheck, skipPrimaryCheck = _g === void 0 ? false : _g, _h = _a.clearCache, clearCache = _h === void 0 ? undefined : _h;
476
476
  var fullTableList = Array.isArray(tableName) ? tableName : [tableName];
477
477
  var operatingTableFullName = fullTableList[0];
478
478
  var operatingTable = operatingTableFullName.replace(C6.PREFIX, '');
@@ -652,7 +652,7 @@ function restApi(_a) {
652
652
  console.log('%c Remember undefined indicated the request has not fired, null indicates the request is firing, an empty array would signal no data was returned for the sql stmt.', 'color: #A020F0');
653
653
  console.trace();
654
654
  console.groupEnd();
655
- var axiosActiveRequest = axios[requestMethod.toLowerCase()](restRequestUri, (function () {
655
+ var axiosActiveRequest = axios[requestMethod.toLowerCase()](restRequestUri, __assign({ withCredentials: withCredentials }, ((function () {
656
656
  if (requestMethod === GET) {
657
657
  return {
658
658
  params: query
@@ -677,7 +677,7 @@ function restApi(_a) {
677
677
  else {
678
678
  throw new Error('The request method (' + requestMethod + ') was not recognized.');
679
679
  }
680
- })());
680
+ })())));
681
681
  if (cachingConfirmed) {
682
682
  // push to cache so we do not repeat the request
683
683
  apiRequestCache.push({