@carbonorm/carbonnode 6.0.2 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executors/SqlExecutor.d.ts +2 -15
- package/dist/index.cjs.js +78 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +78 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/types/ormInterfaces.d.ts +16 -4
- package/package.json +2 -2
- package/src/__tests__/sakila-db/C6.js +1 -1
- package/src/__tests__/sakila-db/C6.mysqldump.json +1 -1
- package/src/__tests__/sakila-db/C6.mysqldump.sql +1 -1
- package/src/__tests__/sakila-db/C6.ts +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.post.json +4 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.post.latest.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.put.lookup.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.address.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.address.post.json +6 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.address.post.latest.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.address.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.address.put.lookup.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.category.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.category.post.json +3 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.category.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.category.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.category.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.city.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.city.post.json +3 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.city.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.city.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.city.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.country.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.country.post.json +3 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.country.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.country.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.country.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.post.json +6 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.post.latest.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.put.lookup.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.film.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.film.post.json +3 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.film.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.film.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.film.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.post.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.post.latest.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.put.lookup.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.language.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.language.post.json +3 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.language.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.language.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.language.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.post.json +3 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.put.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.delete.json +1 -0
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.post.json +4 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.post.latest.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.put.json +2 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.put.lookup.json +3 -3
- package/src/executors/SqlExecutor.ts +98 -21
- package/src/types/ormInterfaces.ts +16 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"affected": 1,
|
|
3
|
+
"insertId": 16050,
|
|
3
4
|
"rest": [],
|
|
4
5
|
"sql": {
|
|
5
6
|
"sql": "INSERT INTO `payment` (\n `customer_id`, `staff_id`, `rental_id`, `amount`, `payment_date`, `last_update`\n ) VALUES (\n ?, ?, ?, ?, ?, ?\n )",
|
|
@@ -8,8 +9,8 @@
|
|
|
8
9
|
1,
|
|
9
10
|
1,
|
|
10
11
|
1,
|
|
11
|
-
"2026-01
|
|
12
|
-
"2026-01
|
|
12
|
+
"2026-02-01 16:41:48",
|
|
13
|
+
"2026-02-01 16:41:48"
|
|
13
14
|
]
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"affected": 1,
|
|
3
|
+
"insertId": 16050,
|
|
3
4
|
"rest": [],
|
|
4
5
|
"sql": {
|
|
5
6
|
"sql": "INSERT INTO `rental` (\n `rental_date`, `inventory_id`, `customer_id`, `return_date`, `staff_id`, `last_update`\n ) VALUES (\n ?, ?, ?, ?, ?, ?\n )",
|
|
6
7
|
"values": [
|
|
7
|
-
"2026-01
|
|
8
|
+
"2026-02-01 16:41:48",
|
|
8
9
|
1,
|
|
9
10
|
1,
|
|
10
|
-
"2026-01
|
|
11
|
+
"2026-02-01 16:41:48",
|
|
11
12
|
1,
|
|
12
|
-
"2026-01
|
|
13
|
+
"2026-02-01 16:41:48"
|
|
13
14
|
]
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"rest": [
|
|
3
3
|
{
|
|
4
4
|
"rental_id": 16050,
|
|
5
|
-
"rental_date": "2026-
|
|
5
|
+
"rental_date": "2026-02-01T16:41:48.000Z",
|
|
6
6
|
"inventory_id": 1,
|
|
7
7
|
"customer_id": 1,
|
|
8
|
-
"return_date": "2026-
|
|
8
|
+
"return_date": "2026-02-01T16:41:48.000Z",
|
|
9
9
|
"staff_id": 1,
|
|
10
|
-
"last_update": "2026-
|
|
10
|
+
"last_update": "2026-02-01T16:41:48.000Z"
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
13
|
"sql": {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"rest": [
|
|
3
3
|
{
|
|
4
4
|
"rental_id": 16050,
|
|
5
|
-
"rental_date": "2026-
|
|
5
|
+
"rental_date": "2026-02-01T16:41:48.000Z",
|
|
6
6
|
"inventory_id": 1,
|
|
7
7
|
"customer_id": 1,
|
|
8
|
-
"return_date": "2026-
|
|
8
|
+
"return_date": "2026-02-01T16:41:48.000Z",
|
|
9
9
|
"staff_id": 1,
|
|
10
|
-
"last_update": "2026-
|
|
10
|
+
"last_update": "2026-02-01T16:41:48.000Z"
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
13
|
"sql": {
|
|
@@ -47,19 +47,19 @@ export class SqlExecutor<
|
|
|
47
47
|
|
|
48
48
|
case 'POST': {
|
|
49
49
|
const result = await this.runQuery();
|
|
50
|
-
await this.broadcastWebsocketIfConfigured();
|
|
50
|
+
await this.broadcastWebsocketIfConfigured(result);
|
|
51
51
|
return result as DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
case 'PUT': {
|
|
55
55
|
const result = await this.runQuery();
|
|
56
|
-
await this.broadcastWebsocketIfConfigured();
|
|
56
|
+
await this.broadcastWebsocketIfConfigured(result);
|
|
57
57
|
return result as DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
case 'DELETE': {
|
|
61
61
|
const result = await this.runQuery();
|
|
62
|
-
await this.broadcastWebsocketIfConfigured();
|
|
62
|
+
await this.broadcastWebsocketIfConfigured(result);
|
|
63
63
|
return result as DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -110,7 +110,7 @@ export class SqlExecutor<
|
|
|
110
110
|
return `'${JSON.stringify(val)}'`;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
private stripRequestMetadata(source: Record<string,
|
|
113
|
+
private stripRequestMetadata(source: Record<string, unknown>): Record<string, unknown> {
|
|
114
114
|
const ignoredKeys = new Set<string>([
|
|
115
115
|
C6C.SELECT,
|
|
116
116
|
C6C.UPDATE,
|
|
@@ -128,7 +128,7 @@ export class SqlExecutor<
|
|
|
128
128
|
"error",
|
|
129
129
|
]);
|
|
130
130
|
|
|
131
|
-
const filtered: Record<string,
|
|
131
|
+
const filtered: Record<string, unknown> = {};
|
|
132
132
|
for (const [key, value] of Object.entries(source)) {
|
|
133
133
|
if (!ignoredKeys.has(key)) {
|
|
134
134
|
filtered[key] = value;
|
|
@@ -137,10 +137,10 @@ export class SqlExecutor<
|
|
|
137
137
|
return filtered;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
private normalizeRequestPayload(source: Record<string,
|
|
140
|
+
private normalizeRequestPayload(source: Record<string, unknown>): Record<string, unknown> {
|
|
141
141
|
const columns = this.config.restModel.COLUMNS as Record<string, string>;
|
|
142
142
|
const validColumns = new Set(Object.values(columns));
|
|
143
|
-
const normalized: Record<string,
|
|
143
|
+
const normalized: Record<string, unknown> = {};
|
|
144
144
|
|
|
145
145
|
for (const [key, value] of Object.entries(source)) {
|
|
146
146
|
const shortKey = columns[key] ?? (key.includes(".") ? key.split(".").pop()! : key);
|
|
@@ -152,25 +152,27 @@ export class SqlExecutor<
|
|
|
152
152
|
return normalized;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
|
|
156
|
+
private extractRequestBody() {
|
|
157
|
+
const request = this.request;
|
|
157
158
|
|
|
158
159
|
if (this.config.requestMethod === C6C.POST) {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
const insertRows = request.dataInsertMultipleRows;
|
|
161
|
+
if (Array.isArray(insertRows) && insertRows.length > 0) {
|
|
162
|
+
return insertRows[0] as Record<string, unknown>;
|
|
161
163
|
}
|
|
162
164
|
if (C6C.INSERT in request) {
|
|
163
|
-
return
|
|
165
|
+
return request[C6C.INSERT] ?? {};
|
|
164
166
|
}
|
|
165
167
|
if (C6C.REPLACE in request) {
|
|
166
|
-
return
|
|
168
|
+
return request[C6C.REPLACE] ?? {};
|
|
167
169
|
}
|
|
168
170
|
return this.stripRequestMetadata(request);
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
if (this.config.requestMethod === C6C.PUT) {
|
|
172
174
|
if (request[C6C.UPDATE] && typeof request[C6C.UPDATE] === "object") {
|
|
173
|
-
return request[C6C.UPDATE] as Record<string,
|
|
175
|
+
return request[C6C.UPDATE] as Record<string, unknown>;
|
|
174
176
|
}
|
|
175
177
|
return this.stripRequestMetadata(request);
|
|
176
178
|
}
|
|
@@ -223,17 +225,91 @@ export class SqlExecutor<
|
|
|
223
225
|
return Object.keys(pkValues).length > 0 ? pkValues : null;
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
private
|
|
228
|
+
private extractPrimaryKeyValuesFromData(data: any): Record<string, any> | null {
|
|
229
|
+
if (!data) return null;
|
|
230
|
+
const row = Array.isArray(data) ? data[0] : data;
|
|
231
|
+
if (!row || typeof row !== "object") return null;
|
|
232
|
+
|
|
233
|
+
const pkShorts = this.config.restModel.PRIMARY_SHORT;
|
|
234
|
+
const columns = this.config.restModel.COLUMNS as Record<string, string>;
|
|
235
|
+
const pkValues: Record<string, any> = {};
|
|
236
|
+
|
|
237
|
+
for (const pk of pkShorts) {
|
|
238
|
+
if (pk in row) {
|
|
239
|
+
pkValues[pk] = (row as any)[pk];
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const fullKey = Object.keys(columns).find(
|
|
244
|
+
(key) => columns[key] === pk,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
if (fullKey && fullKey in row) {
|
|
248
|
+
pkValues[pk] = (row as any)[fullKey];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (pkShorts.length > 0 && Object.keys(pkValues).length < pkShorts.length) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return Object.keys(pkValues).length > 0 ? pkValues : null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private async broadcastWebsocketIfConfigured(
|
|
260
|
+
response?: DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>
|
|
261
|
+
): Promise<void> {
|
|
227
262
|
const broadcast = this.config.websocketBroadcast;
|
|
228
263
|
if (!broadcast || this.config.requestMethod === C6C.GET) return;
|
|
229
264
|
|
|
265
|
+
const normalizedRequest = this.normalizeRequestPayload(this.extractRequestBody());
|
|
266
|
+
const pkShorts = this.config.restModel.PRIMARY_SHORT ?? [];
|
|
267
|
+
const columns = this.config.restModel.COLUMNS as Record<string, string>;
|
|
268
|
+
const validColumns = new Set(Object.values(columns));
|
|
269
|
+
let responseRest = response?.rest;
|
|
270
|
+
let responsePrimaryKey = this.extractPrimaryKeyValuesFromData(responseRest);
|
|
271
|
+
|
|
272
|
+
if (
|
|
273
|
+
(responseRest === null || (Array.isArray(responseRest) && responseRest.length === 0))
|
|
274
|
+
&& this.config.requestMethod === C6C.POST
|
|
275
|
+
) {
|
|
276
|
+
const insertId = (response as DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']> & { insertId?: number | string | null })?.insertId;
|
|
277
|
+
if (insertId !== undefined && pkShorts.length === 1) {
|
|
278
|
+
const synthesizedRequest = {
|
|
279
|
+
...normalizedRequest,
|
|
280
|
+
};
|
|
281
|
+
const now = new Date().toISOString();
|
|
282
|
+
if (validColumns.has("changed_at") && (synthesizedRequest as Record<string, unknown>).changed_at === undefined) {
|
|
283
|
+
synthesizedRequest.changed_at = now;
|
|
284
|
+
}
|
|
285
|
+
if (validColumns.has("created_at") && (synthesizedRequest as Record<string, unknown>).created_at === undefined) {
|
|
286
|
+
synthesizedRequest.created_at = now;
|
|
287
|
+
}
|
|
288
|
+
if (validColumns.has("updated_at") && (synthesizedRequest as Record<string, unknown>).updated_at === undefined) {
|
|
289
|
+
synthesizedRequest.updated_at = now;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const synthesized = {
|
|
293
|
+
...synthesizedRequest,
|
|
294
|
+
[pkShorts[0]]: insertId,
|
|
295
|
+
};
|
|
296
|
+
// @ts-ignore - todo
|
|
297
|
+
responseRest = [synthesized];
|
|
298
|
+
responsePrimaryKey = {
|
|
299
|
+
[pkShorts[0]]: insertId,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
230
304
|
const payload: iRestWebsocketPayload = {
|
|
231
305
|
REST: {
|
|
232
306
|
TABLE_NAME: this.config.restModel.TABLE_NAME as string,
|
|
233
307
|
TABLE_PREFIX: this.config.C6?.PREFIX ?? "",
|
|
234
308
|
METHOD: this.config.requestMethod,
|
|
235
|
-
REQUEST:
|
|
309
|
+
REQUEST: normalizedRequest,
|
|
236
310
|
REQUEST_PRIMARY_KEY: this.extractPrimaryKeyValues(),
|
|
311
|
+
RESPONSE: responseRest,
|
|
312
|
+
RESPONSE_PRIMARY_KEY: responsePrimaryKey,
|
|
237
313
|
},
|
|
238
314
|
};
|
|
239
315
|
|
|
@@ -245,7 +321,7 @@ export class SqlExecutor<
|
|
|
245
321
|
}
|
|
246
322
|
}
|
|
247
323
|
}
|
|
248
|
-
async runQuery() {
|
|
324
|
+
async runQuery(): Promise<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>> {
|
|
249
325
|
const {TABLE_NAME} = this.config.restModel;
|
|
250
326
|
const method = this.config.requestMethod;
|
|
251
327
|
let builder: SelectQueryBuilder<G> | UpdateQueryBuilder<G> | DeleteQueryBuilder<G> | PostQueryBuilder<G>;
|
|
@@ -286,14 +362,15 @@ export class SqlExecutor<
|
|
|
286
362
|
return {
|
|
287
363
|
rest: result.map(this.serialize),
|
|
288
364
|
sql: {sql, values}
|
|
289
|
-
}
|
|
365
|
+
} as DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>;
|
|
290
366
|
} else {
|
|
291
367
|
this.config.verbose && console.log(`[SQL EXECUTOR] ✏️ Rows affected:`, result.affectedRows);
|
|
292
368
|
return {
|
|
293
|
-
affected: result.affectedRows,
|
|
294
|
-
|
|
369
|
+
affected: result.affectedRows as number,
|
|
370
|
+
insertId: result.insertId as number,
|
|
371
|
+
rest: [], // TODO - remove rest empty array from non-GET responses?
|
|
295
372
|
sql: {sql, values}
|
|
296
|
-
}
|
|
373
|
+
} as DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>;
|
|
297
374
|
}
|
|
298
375
|
});
|
|
299
376
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
// Refined TypeScript types for CarbonORM
|
|
2
|
-
|
|
3
1
|
import type {AxiosInstance, AxiosPromise, AxiosResponse} from "axios";
|
|
4
2
|
import type {Pool} from "mysql2/promise";
|
|
5
3
|
import {eFetchDependencies} from "./dynamicFetching";
|
|
6
4
|
import {Modify} from "./modifyTypes";
|
|
7
5
|
import {JoinType, OrderDirection, SQLComparisonOperator, SQLFunction} from "./mysqlTypes";
|
|
8
|
-
import type {CarbonReact} from "@carbonorm/carbonreact";
|
|
6
|
+
import type {CarbonReact, iStateAdapter} from "@carbonorm/carbonreact";
|
|
9
7
|
import type {OrmGenerics} from "./ormGenerics";
|
|
10
8
|
import {restOrm} from "../api/restOrm";
|
|
11
9
|
|
|
10
|
+
|
|
12
11
|
type RestOrmFactory = typeof restOrm<OrmGenerics<any>>;
|
|
13
12
|
type RestOrmReturn = ReturnType<RestOrmFactory>;
|
|
14
13
|
|
|
@@ -78,6 +77,11 @@ export type RequestGetPutDeleteBody<T extends { [key: string]: any } = any> = T
|
|
|
78
77
|
PAGINATION?: Pagination<T>;
|
|
79
78
|
};
|
|
80
79
|
|
|
80
|
+
export type RequestPostBody<T extends { [key: string]: any } = any> = T | {
|
|
81
|
+
INSERT?: Partial<T>;
|
|
82
|
+
REPLACE?: Partial<T>;
|
|
83
|
+
};
|
|
84
|
+
|
|
81
85
|
export type iAPI<T extends { [key: string]: any }> = T & {
|
|
82
86
|
dataInsertMultipleRows?: T[];
|
|
83
87
|
cacheResults?: boolean;
|
|
@@ -95,7 +99,7 @@ export type RequestQueryBody<
|
|
|
95
99
|
Overrides extends { [key: string]: any } = {}
|
|
96
100
|
> = Method extends 'GET' | 'PUT' | 'DELETE'
|
|
97
101
|
? iAPI<RequestGetPutDeleteBody<Modify<T, Overrides> & Custom>>
|
|
98
|
-
: iAPI<Modify<T, Overrides> & Custom
|
|
102
|
+
: iAPI<RequestPostBody<Modify<T, Overrides> & Custom>>;
|
|
99
103
|
|
|
100
104
|
export interface iCacheAPI<ResponseDataType = any> {
|
|
101
105
|
requestArgumentsSerialized: string;
|
|
@@ -120,12 +124,15 @@ export type C6RestResponse<
|
|
|
120
124
|
RestData extends { [key: string]: any },
|
|
121
125
|
Overrides = {}
|
|
122
126
|
> = {
|
|
123
|
-
rest: Method extends 'GET' ? Modify<RestData, Overrides>[] :
|
|
127
|
+
rest: Method extends 'GET' ? Modify<RestData, Overrides>[] : never;
|
|
124
128
|
session?: any;
|
|
125
129
|
sql?: any;
|
|
126
130
|
} & (Method extends 'GET'
|
|
127
131
|
? { next?: () => Promise<DetermineResponseDataType<'GET', RestData, Overrides>> }
|
|
128
|
-
: {
|
|
132
|
+
: {
|
|
133
|
+
affected: number,
|
|
134
|
+
insertId?: number | string,
|
|
135
|
+
});
|
|
129
136
|
|
|
130
137
|
export interface iC6RestResponse<RestData> {
|
|
131
138
|
// Backwards compatibility: base interface for rest/sql/session (singular)
|
|
@@ -173,6 +180,8 @@ export type iRestWebsocketPayload = {
|
|
|
173
180
|
METHOD: iRestMethods;
|
|
174
181
|
REQUEST: Record<string, any>;
|
|
175
182
|
REQUEST_PRIMARY_KEY: Record<string, any> | null;
|
|
183
|
+
RESPONSE?: Record<string, any> | Record<string, any>[];
|
|
184
|
+
RESPONSE_PRIMARY_KEY?: Record<string, any> | null;
|
|
176
185
|
};
|
|
177
186
|
};
|
|
178
187
|
|
|
@@ -190,6 +199,7 @@ export interface iRest<
|
|
|
190
199
|
withCredentials?: boolean;
|
|
191
200
|
restModel: C6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
192
201
|
reactBootstrap?: CarbonReact<any, any>;
|
|
202
|
+
stateAdapter?: iStateAdapter<any>;
|
|
193
203
|
requestMethod: iRestMethods;
|
|
194
204
|
clearCache?: () => void;
|
|
195
205
|
skipPrimaryCheck?: boolean;
|