@carbonorm/carbonnode 5.0.1 → 6.0.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/dist/api/convertForRequestBody.d.ts +1 -1
- package/dist/api/restOrm.d.ts +6 -6
- package/dist/api/restRequest.d.ts +2 -2
- package/dist/{api/executors → executors}/HttpExecutor.d.ts +2 -2
- package/dist/{api/handlers → handlers}/ExpressHandler.d.ts +3 -3
- package/dist/index.cjs.js +229 -160
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +30 -29
- package/dist/index.esm.js +225 -161
- package/dist/index.esm.js.map +1 -1
- package/dist/{api/types → types}/ormGenerics.d.ts +1 -1
- package/dist/{api/types → types}/ormInterfaces.d.ts +7 -6
- package/dist/{api/utils → utils}/apiHelpers.d.ts +2 -2
- package/dist/{api/utils → utils}/cacheManager.d.ts +2 -2
- package/dist/utils/sqlAllowList.d.ts +5 -0
- package/dist/utils/toastRuntime.d.ts +5 -0
- package/dist/variables/toastOptions.d.ts +10 -1
- package/package.json +2 -7
- package/scripts/assets/handlebars/C6.test.ts.handlebars +4 -8
- package/src/__tests__/binaryHex.e2e.test.ts +1 -1
- package/src/__tests__/cacheManager.test.ts +2 -3
- package/src/__tests__/expressServer.e2e.test.ts +1 -1
- package/src/__tests__/fixtures/c6.fixture.ts +1 -1
- package/src/__tests__/fixtures/createTestServer.ts +2 -2
- package/src/__tests__/fixtures/pu.fixture.ts +1 -2
- package/src/__tests__/httpExecutorSingular.e2e.test.ts +1 -1
- package/src/__tests__/normalizeSingularRequest.test.ts +3 -3
- 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.test.ts +4 -8
- package/src/__tests__/sakila-db/C6.ts +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.post.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.post.latest.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.actor.put.lookup.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.address.post.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.address.post.latest.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.address.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.address.put.lookup.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.category.post.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.category.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.category.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.category.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.city.post.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.city.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.city.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.city.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.country.post.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.country.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.country.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.country.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.post.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.post.latest.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.customer.put.lookup.json +5 -5
- package/src/__tests__/sakila-db/sqlResponses/C6.film.post.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.film.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.film.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.film.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.post.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.post.latest.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.inventory.put.lookup.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.language.post.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.language.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.language.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.language.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.post.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.post.latest.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.payment.put.lookup.json +2 -2
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.post.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.post.latest.json +3 -3
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.put.json +1 -1
- package/src/__tests__/sakila-db/sqlResponses/C6.rental.put.lookup.json +3 -3
- package/src/__tests__/sqlAllowList.test.ts +67 -74
- package/src/__tests__/sqlBuilders.complex.test.ts +3 -3
- package/src/__tests__/sqlBuilders.expressions.test.ts +2 -2
- package/src/__tests__/sqlBuilders.test.ts +5 -5
- package/src/__tests__/toastRuntime.test.ts +22 -0
- package/src/api/convertForRequestBody.ts +2 -2
- package/src/api/restOrm.ts +2 -2
- package/src/api/restRequest.ts +4 -5
- package/src/{api/executors → executors}/HttpExecutor.ts +21 -13
- package/src/{api/executors → executors}/SqlExecutor.ts +2 -2
- package/src/{api/handlers → handlers}/ExpressHandler.ts +5 -5
- package/src/index.ts +30 -29
- package/src/{api/orm → orm}/builders/AggregateBuilder.ts +1 -1
- package/src/{api/orm → orm}/builders/ConditionBuilder.ts +1 -1
- package/src/{api/orm → orm}/builders/JoinBuilder.ts +1 -1
- package/src/{api/orm → orm}/builders/PaginationBuilder.ts +1 -1
- package/src/{api/orm → orm}/queries/PostQueryBuilder.ts +1 -1
- package/src/{api/orm → orm}/queries/UpdateQueryBuilder.ts +1 -1
- package/src/{api/orm → orm}/queryHelpers.ts +1 -2
- package/src/{api/types → types}/ormGenerics.ts +1 -1
- package/src/{api/types → types}/ormInterfaces.ts +8 -6
- package/src/{api/utils → utils}/apiHelpers.ts +8 -8
- package/src/{api/utils → utils}/cacheManager.ts +2 -2
- package/src/{api/utils → utils}/normalizeSingularRequest.ts +1 -1
- package/src/utils/sqlAllowList.ts +120 -0
- package/src/{api/utils → utils}/testHelpers.ts +1 -1
- package/src/{api/utils → utils}/toastNotifier.ts +3 -3
- package/src/utils/toastRuntime.ts +22 -0
- package/src/variables/toastOptions.ts +10 -3
- package/dist/api/utils/sqlAllowList.d.ts +0 -2
- package/src/api/utils/sqlAllowList.ts +0 -54
- /package/dist/{api → constants}/C6Constants.d.ts +0 -0
- /package/dist/{api/executors → executors}/Executor.d.ts +0 -0
- /package/dist/{api/executors → executors}/SqlExecutor.d.ts +0 -0
- /package/dist/{api/orm → orm}/builders/AggregateBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/builders/ConditionBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/builders/JoinBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/builders/PaginationBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/queries/DeleteQueryBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/queries/PostQueryBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/queries/SelectQueryBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/queries/UpdateQueryBuilder.d.ts +0 -0
- /package/dist/{api/orm → orm}/queryHelpers.d.ts +0 -0
- /package/dist/{api/orm → orm}/utils/sqlUtils.d.ts +0 -0
- /package/dist/{api/types → types}/dynamicFetching.d.ts +0 -0
- /package/dist/{api/types → types}/modifyTypes.d.ts +0 -0
- /package/dist/{api/types → types}/mysqlTypes.d.ts +0 -0
- /package/dist/{api/utils → utils}/determineRuntimeJsType.d.ts +0 -0
- /package/dist/{api/utils → utils}/logger.d.ts +0 -0
- /package/dist/{api/utils → utils}/normalizeSingularRequest.d.ts +0 -0
- /package/dist/{api/utils → utils}/sortAndSerializeQueryObject.d.ts +0 -0
- /package/dist/{api/utils → utils}/testHelpers.d.ts +0 -0
- /package/dist/{api/utils → utils}/toastNotifier.d.ts +0 -0
- /package/src/{api → constants}/C6Constants.ts +0 -0
- /package/src/{api/executors → executors}/Executor.ts +0 -0
- /package/src/{api/orm → orm}/queries/DeleteQueryBuilder.ts +0 -0
- /package/src/{api/orm → orm}/queries/SelectQueryBuilder.ts +0 -0
- /package/src/{api/orm → orm}/utils/sqlUtils.ts +0 -0
- /package/src/{api/types → types}/dynamicFetching.ts +0 -0
- /package/src/{api/types → types}/modifyTypes.ts +0 -0
- /package/src/{api/types → types}/mysqlTypes.ts +0 -0
- /package/src/{api/utils → utils}/determineRuntimeJsType.ts +0 -0
- /package/src/{api/utils → utils}/logger.ts +0 -0
- /package/src/{api/utils → utils}/sortAndSerializeQueryObject.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Automatically generated by barrelsby.
|
|
3
3
|
*/
|
|
4
|
-
export * from "./api/C6Constants";
|
|
5
4
|
export { default as axiosInstance } from "./api/axiosInstance";
|
|
6
5
|
export * from "./api/axiosInstance";
|
|
7
6
|
export { default as convertForRequestBody } from "./api/convertForRequestBody";
|
|
@@ -11,34 +10,36 @@ export { default as restRequest } from "./api/restRequest";
|
|
|
11
10
|
export * from "./api/restRequest";
|
|
12
11
|
export { default as timeout } from "./api/timeout";
|
|
13
12
|
export * from "./api/timeout";
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
20
|
-
export * from "./
|
|
21
|
-
export * from "./
|
|
22
|
-
export * from "./
|
|
23
|
-
export * from "./
|
|
24
|
-
export * from "./
|
|
25
|
-
export * from "./
|
|
26
|
-
export * from "./
|
|
27
|
-
export * from "./
|
|
28
|
-
export * from "./
|
|
29
|
-
export * from "./
|
|
30
|
-
export * from "./
|
|
31
|
-
export * from "./
|
|
32
|
-
export * from "./
|
|
33
|
-
export * from "./
|
|
34
|
-
export * from "./
|
|
35
|
-
export * from "./
|
|
36
|
-
export * from "./
|
|
37
|
-
export * from "./
|
|
38
|
-
export * from "./
|
|
39
|
-
export * from "./
|
|
40
|
-
export * from "./
|
|
41
|
-
export * from "./
|
|
13
|
+
export * from "./constants/C6Constants";
|
|
14
|
+
export * from "./executors/Executor";
|
|
15
|
+
export * from "./executors/HttpExecutor";
|
|
16
|
+
export * from "./executors/SqlExecutor";
|
|
17
|
+
export * from "./handlers/ExpressHandler";
|
|
18
|
+
export * from "./orm/queryHelpers";
|
|
19
|
+
export * from "./orm/builders/AggregateBuilder";
|
|
20
|
+
export * from "./orm/builders/ConditionBuilder";
|
|
21
|
+
export * from "./orm/builders/JoinBuilder";
|
|
22
|
+
export * from "./orm/builders/PaginationBuilder";
|
|
23
|
+
export * from "./orm/queries/DeleteQueryBuilder";
|
|
24
|
+
export * from "./orm/queries/PostQueryBuilder";
|
|
25
|
+
export * from "./orm/queries/SelectQueryBuilder";
|
|
26
|
+
export * from "./orm/queries/UpdateQueryBuilder";
|
|
27
|
+
export * from "./orm/utils/sqlUtils";
|
|
28
|
+
export * from "./types/dynamicFetching";
|
|
29
|
+
export * from "./types/modifyTypes";
|
|
30
|
+
export * from "./types/mysqlTypes";
|
|
31
|
+
export * from "./types/ormGenerics";
|
|
32
|
+
export * from "./types/ormInterfaces";
|
|
33
|
+
export * from "./utils/apiHelpers";
|
|
34
|
+
export * from "./utils/cacheManager";
|
|
35
|
+
export * from "./utils/determineRuntimeJsType";
|
|
36
|
+
export * from "./utils/logger";
|
|
37
|
+
export * from "./utils/normalizeSingularRequest";
|
|
38
|
+
export * from "./utils/sortAndSerializeQueryObject";
|
|
39
|
+
export * from "./utils/sqlAllowList";
|
|
40
|
+
export * from "./utils/testHelpers";
|
|
41
|
+
export * from "./utils/toastNotifier";
|
|
42
|
+
export * from "./utils/toastRuntime";
|
|
42
43
|
export * from "./variables/getEnvVar";
|
|
43
44
|
export { default as isLocal } from "./variables/isLocal";
|
|
44
45
|
export * from "./variables/isLocal";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,10 +1,156 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import Qs from 'qs';
|
|
3
3
|
import { __assign, __awaiter, __generator, __extends, __spreadArray, __rest } from 'tslib';
|
|
4
|
-
import { toast } from 'react-toastify';
|
|
5
4
|
import namedPlaceholders from 'named-placeholders';
|
|
6
5
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
7
6
|
|
|
7
|
+
// @link https://www.npmjs.com/package/axios-cache-adapter
|
|
8
|
+
var carbonNodeQsStringify = function (params) {
|
|
9
|
+
return Qs.stringify(params, {
|
|
10
|
+
arrayFormat: "indices",
|
|
11
|
+
indices: true,
|
|
12
|
+
skipNulls: false,
|
|
13
|
+
strictNullHandling: true,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
// updating these values
|
|
17
|
+
// @link https://github.com/axios/axios/issues/209
|
|
18
|
+
//
|
|
19
|
+
// only affects the global instance and instances created afterwards
|
|
20
|
+
// axios.defaults.headers.common['Auth-Token'] = 'foo bar';
|
|
21
|
+
//
|
|
22
|
+
// immediately affects this instance
|
|
23
|
+
// axiosInstance.defaults.headers['Auth-Token'] = 'foo bar';
|
|
24
|
+
var axiosInstance = (axios.create({
|
|
25
|
+
// `baseURL` will be prepended to `url` unless `url` is absolute.
|
|
26
|
+
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
|
27
|
+
// to methods of that instance.
|
|
28
|
+
baseURL: '',
|
|
29
|
+
/**
|
|
30
|
+
* These headers are important to C6.
|
|
31
|
+
* XMLHttpRequest - is a standard header all jquery ajax requests send by default. This allows our php side to return
|
|
32
|
+
* nothing while running the get_header() and get_footer() functions with (bool) DropVariables::$ajax;
|
|
33
|
+
*
|
|
34
|
+
* application/json - is for the error catcher in php; this header will cause a JSON response instead of the default HTML
|
|
35
|
+
*/
|
|
36
|
+
headers: {
|
|
37
|
+
crossDomain: true,
|
|
38
|
+
'Access-Control-Allow-Credentials': true,
|
|
39
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
},
|
|
42
|
+
// `paramsSerializer` is an optional function in charge of serializing `params`
|
|
43
|
+
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
|
|
44
|
+
paramsSerializer: function (params) {
|
|
45
|
+
// Nested get params [][][,,,] do not serialize correctly without Qs
|
|
46
|
+
return carbonNodeQsStringify(params);
|
|
47
|
+
},
|
|
48
|
+
// `data` is the data to be sent as the request body
|
|
49
|
+
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
|
|
50
|
+
// When no `transformRequest` is set, must be of one of the following types:
|
|
51
|
+
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
|
|
52
|
+
// - Browser only: FormData, File, Blob
|
|
53
|
+
// - Node only: Stream, Buffer
|
|
54
|
+
// data should be default to empty for get request to serialize correctly
|
|
55
|
+
data: {}, // do not change
|
|
56
|
+
// `timeout` specifies the number of milliseconds before the request times out.
|
|
57
|
+
// If the request takes longer than `timeout`, the request will be aborted.
|
|
58
|
+
// Default is 1000 - lets increase this for large request which we are favored for
|
|
59
|
+
timeout: 120000, // shit fails
|
|
60
|
+
// `withCredentials` indicates weather cross-site Access-Control requests
|
|
61
|
+
// should be made using credentials
|
|
62
|
+
withCredentials: true,
|
|
63
|
+
// `adapter` allows custom handling of requests which makes testing easier.
|
|
64
|
+
// Return a promise and supply a valid response (see lib/adapters/README.md).
|
|
65
|
+
// adapter: cache.adapter,
|
|
66
|
+
// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
|
|
67
|
+
// This will set an `Authorization` header, overwriting any existing
|
|
68
|
+
// `Authorization` custom headers you have set using `headers`.
|
|
69
|
+
/*
|
|
70
|
+
auth: {
|
|
71
|
+
username: 'janedoe',
|
|
72
|
+
password: 's00pers3cret'
|
|
73
|
+
},
|
|
74
|
+
*/
|
|
75
|
+
// `responseType` indicates the type of data that the server will respond with
|
|
76
|
+
// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
|
|
77
|
+
// responseType: 'json', // default
|
|
78
|
+
// `responseEncoding` indicates encoding to use for decoding responses
|
|
79
|
+
// Note: Ignored for `responseType` of 'stream' or client-side requests
|
|
80
|
+
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
|
|
81
|
+
//xsrfCookieName: 'XSRF-TOKEN', // default
|
|
82
|
+
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
|
83
|
+
//xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
|
84
|
+
// `onUploadProgress` allows handling of progress events for uploads
|
|
85
|
+
onUploadProgress: function () {
|
|
86
|
+
// Do whatever you want with the native progress event
|
|
87
|
+
},
|
|
88
|
+
// `onDownloadProgress` allows handling of progress events for downloads
|
|
89
|
+
onDownloadProgress: function () {
|
|
90
|
+
// Do whatever you want with the native progress event
|
|
91
|
+
},
|
|
92
|
+
// `maxContentLength` defines the max size of the http response content in bytes allowed
|
|
93
|
+
/*maxContentLength: 2000,*/
|
|
94
|
+
// `validateStatus` defines whether to resolve or reject the promise for a given
|
|
95
|
+
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
|
|
96
|
+
// or `undefined`), the promise will be resolved; otherwise, the promise will be
|
|
97
|
+
// rejected.
|
|
98
|
+
/* validateStatus: function (status) {
|
|
99
|
+
return status >= 200 && status < 300;
|
|
100
|
+
},*/
|
|
101
|
+
// `maxRedirects` defines the maximum number of redirects to follow in node.js.
|
|
102
|
+
// If set to 0, no redirects will be followed.
|
|
103
|
+
maxRedirects: 2, // default
|
|
104
|
+
// `socketPath` defines a UNIX Socket to be used in node.js.
|
|
105
|
+
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
|
|
106
|
+
// Only either `socketPath` or `proxy` can be specified.
|
|
107
|
+
// If both are specified, `socketPath` is used.
|
|
108
|
+
socketPath: null, // default
|
|
109
|
+
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
|
110
|
+
// and https requests, respectively, in node.js. This allows options to be added like
|
|
111
|
+
// `keepAlive` that are not enabled by default.
|
|
112
|
+
/*
|
|
113
|
+
httpAgent: new http.Agent({ keepAlive: true }),
|
|
114
|
+
httpsAgent: new https.Agent({ keepAlive: true }),
|
|
115
|
+
*/
|
|
116
|
+
}));
|
|
117
|
+
axiosInstance.interceptors.request.use(function (config) {
|
|
118
|
+
if (config.params) {
|
|
119
|
+
var serialized = carbonNodeQsStringify(config.params);
|
|
120
|
+
if (serialized.length > 2000) {
|
|
121
|
+
// Move params into body but keep track of intended method
|
|
122
|
+
config.method = "post";
|
|
123
|
+
config.data = config.params;
|
|
124
|
+
config.params = {
|
|
125
|
+
METHOD: "GET", // 👈 explicit signal for your REST parser
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
config.__carbonStart = performance.now();
|
|
130
|
+
return config;
|
|
131
|
+
});
|
|
132
|
+
axiosInstance.interceptors.response.use(function (response) {
|
|
133
|
+
var end = performance.now();
|
|
134
|
+
var start = response.config.__carbonStart;
|
|
135
|
+
response.__carbonTiming = {
|
|
136
|
+
start: start,
|
|
137
|
+
end: end,
|
|
138
|
+
duration: end - start,
|
|
139
|
+
};
|
|
140
|
+
return response;
|
|
141
|
+
}, function (error) {
|
|
142
|
+
if (error.config) {
|
|
143
|
+
var end = performance.now();
|
|
144
|
+
var start = error.config.__carbonStart;
|
|
145
|
+
error.__carbonTiming = {
|
|
146
|
+
start: start,
|
|
147
|
+
end: end,
|
|
148
|
+
duration: end - start,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
});
|
|
153
|
+
|
|
8
154
|
var C6Constants = {
|
|
9
155
|
// try to 1=1 match the Rest abstract class
|
|
10
156
|
ADDDATE: 'ADDDATE',
|
|
@@ -182,153 +328,6 @@ var C6Constants = {
|
|
|
182
328
|
};
|
|
183
329
|
var C6C = C6Constants;
|
|
184
330
|
|
|
185
|
-
// @link https://www.npmjs.com/package/axios-cache-adapter
|
|
186
|
-
var carbonNodeQsStringify = function (params) {
|
|
187
|
-
return Qs.stringify(params, {
|
|
188
|
-
arrayFormat: "indices",
|
|
189
|
-
indices: true,
|
|
190
|
-
skipNulls: false,
|
|
191
|
-
strictNullHandling: true,
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
// updating these values
|
|
195
|
-
// @link https://github.com/axios/axios/issues/209
|
|
196
|
-
//
|
|
197
|
-
// only affects the global instance and instances created afterwards
|
|
198
|
-
// axios.defaults.headers.common['Auth-Token'] = 'foo bar';
|
|
199
|
-
//
|
|
200
|
-
// immediately affects this instance
|
|
201
|
-
// axiosInstance.defaults.headers['Auth-Token'] = 'foo bar';
|
|
202
|
-
var axiosInstance = (axios.create({
|
|
203
|
-
// `baseURL` will be prepended to `url` unless `url` is absolute.
|
|
204
|
-
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
|
205
|
-
// to methods of that instance.
|
|
206
|
-
baseURL: '',
|
|
207
|
-
/**
|
|
208
|
-
* These headers are important to C6.
|
|
209
|
-
* XMLHttpRequest - is a standard header all jquery ajax requests send by default. This allows our php side to return
|
|
210
|
-
* nothing while running the get_header() and get_footer() functions with (bool) DropVariables::$ajax;
|
|
211
|
-
*
|
|
212
|
-
* application/json - is for the error catcher in php; this header will cause a JSON response instead of the default HTML
|
|
213
|
-
*/
|
|
214
|
-
headers: {
|
|
215
|
-
crossDomain: true,
|
|
216
|
-
'Access-Control-Allow-Credentials': true,
|
|
217
|
-
'X-Requested-With': 'XMLHttpRequest',
|
|
218
|
-
'Content-Type': 'application/json',
|
|
219
|
-
},
|
|
220
|
-
// `paramsSerializer` is an optional function in charge of serializing `params`
|
|
221
|
-
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
|
|
222
|
-
paramsSerializer: function (params) {
|
|
223
|
-
// Nested get params [][][,,,] do not serialize correctly without Qs
|
|
224
|
-
return carbonNodeQsStringify(params);
|
|
225
|
-
},
|
|
226
|
-
// `data` is the data to be sent as the request body
|
|
227
|
-
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
|
|
228
|
-
// When no `transformRequest` is set, must be of one of the following types:
|
|
229
|
-
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
|
|
230
|
-
// - Browser only: FormData, File, Blob
|
|
231
|
-
// - Node only: Stream, Buffer
|
|
232
|
-
// data should be default to empty for get request to serialize correctly
|
|
233
|
-
data: {}, // do not change
|
|
234
|
-
// `timeout` specifies the number of milliseconds before the request times out.
|
|
235
|
-
// If the request takes longer than `timeout`, the request will be aborted.
|
|
236
|
-
// Default is 1000 - lets increase this for large request which we are favored for
|
|
237
|
-
timeout: 120000, // shit fails
|
|
238
|
-
// `withCredentials` indicates weather cross-site Access-Control requests
|
|
239
|
-
// should be made using credentials
|
|
240
|
-
withCredentials: true,
|
|
241
|
-
// `adapter` allows custom handling of requests which makes testing easier.
|
|
242
|
-
// Return a promise and supply a valid response (see lib/adapters/README.md).
|
|
243
|
-
// adapter: cache.adapter,
|
|
244
|
-
// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
|
|
245
|
-
// This will set an `Authorization` header, overwriting any existing
|
|
246
|
-
// `Authorization` custom headers you have set using `headers`.
|
|
247
|
-
/*
|
|
248
|
-
auth: {
|
|
249
|
-
username: 'janedoe',
|
|
250
|
-
password: 's00pers3cret'
|
|
251
|
-
},
|
|
252
|
-
*/
|
|
253
|
-
// `responseType` indicates the type of data that the server will respond with
|
|
254
|
-
// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
|
|
255
|
-
// responseType: 'json', // default
|
|
256
|
-
// `responseEncoding` indicates encoding to use for decoding responses
|
|
257
|
-
// Note: Ignored for `responseType` of 'stream' or client-side requests
|
|
258
|
-
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
|
|
259
|
-
//xsrfCookieName: 'XSRF-TOKEN', // default
|
|
260
|
-
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
|
261
|
-
//xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
|
262
|
-
// `onUploadProgress` allows handling of progress events for uploads
|
|
263
|
-
onUploadProgress: function () {
|
|
264
|
-
// Do whatever you want with the native progress event
|
|
265
|
-
},
|
|
266
|
-
// `onDownloadProgress` allows handling of progress events for downloads
|
|
267
|
-
onDownloadProgress: function () {
|
|
268
|
-
// Do whatever you want with the native progress event
|
|
269
|
-
},
|
|
270
|
-
// `maxContentLength` defines the max size of the http response content in bytes allowed
|
|
271
|
-
/*maxContentLength: 2000,*/
|
|
272
|
-
// `validateStatus` defines whether to resolve or reject the promise for a given
|
|
273
|
-
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
|
|
274
|
-
// or `undefined`), the promise will be resolved; otherwise, the promise will be
|
|
275
|
-
// rejected.
|
|
276
|
-
/* validateStatus: function (status) {
|
|
277
|
-
return status >= 200 && status < 300;
|
|
278
|
-
},*/
|
|
279
|
-
// `maxRedirects` defines the maximum number of redirects to follow in node.js.
|
|
280
|
-
// If set to 0, no redirects will be followed.
|
|
281
|
-
maxRedirects: 2, // default
|
|
282
|
-
// `socketPath` defines a UNIX Socket to be used in node.js.
|
|
283
|
-
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
|
|
284
|
-
// Only either `socketPath` or `proxy` can be specified.
|
|
285
|
-
// If both are specified, `socketPath` is used.
|
|
286
|
-
socketPath: null, // default
|
|
287
|
-
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
|
288
|
-
// and https requests, respectively, in node.js. This allows options to be added like
|
|
289
|
-
// `keepAlive` that are not enabled by default.
|
|
290
|
-
/*
|
|
291
|
-
httpAgent: new http.Agent({ keepAlive: true }),
|
|
292
|
-
httpsAgent: new https.Agent({ keepAlive: true }),
|
|
293
|
-
*/
|
|
294
|
-
}));
|
|
295
|
-
axiosInstance.interceptors.request.use(function (config) {
|
|
296
|
-
if (config.params) {
|
|
297
|
-
var serialized = carbonNodeQsStringify(config.params);
|
|
298
|
-
if (serialized.length > 2000) {
|
|
299
|
-
// Move params into body but keep track of intended method
|
|
300
|
-
config.method = "post";
|
|
301
|
-
config.data = config.params;
|
|
302
|
-
config.params = {
|
|
303
|
-
METHOD: "GET", // 👈 explicit signal for your REST parser
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
config.__carbonStart = performance.now();
|
|
308
|
-
return config;
|
|
309
|
-
});
|
|
310
|
-
axiosInstance.interceptors.response.use(function (response) {
|
|
311
|
-
var end = performance.now();
|
|
312
|
-
var start = response.config.__carbonStart;
|
|
313
|
-
response.__carbonTiming = {
|
|
314
|
-
start: start,
|
|
315
|
-
end: end,
|
|
316
|
-
duration: end - start,
|
|
317
|
-
};
|
|
318
|
-
return response;
|
|
319
|
-
}, function (error) {
|
|
320
|
-
if (error.config) {
|
|
321
|
-
var end = performance.now();
|
|
322
|
-
var start = error.config.__carbonStart;
|
|
323
|
-
error.__carbonTiming = {
|
|
324
|
-
start: start,
|
|
325
|
-
end: end,
|
|
326
|
-
duration: end - start,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
throw error;
|
|
330
|
-
});
|
|
331
|
-
|
|
332
331
|
function convertForRequestBody (restfulObject, tableName, C6, regexErrorHandler) {
|
|
333
332
|
if (regexErrorHandler === void 0) { regexErrorHandler = alert; }
|
|
334
333
|
var payload = {};
|
|
@@ -602,6 +601,14 @@ var toastOptionsDevs = {
|
|
|
602
601
|
theme: "dark",
|
|
603
602
|
};
|
|
604
603
|
|
|
604
|
+
var toastHandler = null;
|
|
605
|
+
var setToastHandler = function (handler) {
|
|
606
|
+
toastHandler = handler;
|
|
607
|
+
};
|
|
608
|
+
var notifyToast = function (level, message, options) {
|
|
609
|
+
toastHandler === null || toastHandler === void 0 ? void 0 : toastHandler(level, message, options);
|
|
610
|
+
};
|
|
611
|
+
|
|
605
612
|
// When we capture DropExceptions and display them as a custom page, this will change.
|
|
606
613
|
function TestRestfulResponse(response, success, error) {
|
|
607
614
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -612,14 +619,14 @@ function TestRestfulResponse(response, success, error) {
|
|
|
612
619
|
|| undefined !== ((_e = response.data) === null || _e === void 0 ? void 0 : _e.deleted))) {
|
|
613
620
|
var successReturn = 'function' === typeof success ? success === null || success === void 0 ? void 0 : success(response) : success;
|
|
614
621
|
if (typeof successReturn === 'string') {
|
|
615
|
-
|
|
622
|
+
notifyToast("success", successReturn, toastOptions);
|
|
616
623
|
}
|
|
617
624
|
// this could end up with bad results for deleting id's === 0
|
|
618
625
|
return (_h = (_g = (_f = response.data.created) !== null && _f !== void 0 ? _f : response.data.updated) !== null && _g !== void 0 ? _g : response.data.deleted) !== null && _h !== void 0 ? _h : true;
|
|
619
626
|
}
|
|
620
627
|
var errorReturn = 'function' === typeof error ? error === null || error === void 0 ? void 0 : error(response) : error;
|
|
621
628
|
if (typeof errorReturn === 'string') {
|
|
622
|
-
|
|
629
|
+
notifyToast("error", errorReturn, toastOptions);
|
|
623
630
|
}
|
|
624
631
|
return false;
|
|
625
632
|
}
|
|
@@ -871,10 +878,10 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
871
878
|
cachingConfirmed = true;
|
|
872
879
|
}
|
|
873
880
|
else if (debug && isLocal()) {
|
|
874
|
-
|
|
881
|
+
notifyToast("info", "DEVS: Ignore cache was set to true.", toastOptionsDevs);
|
|
875
882
|
}
|
|
876
883
|
if (cacheResults && debug && isLocal()) {
|
|
877
|
-
|
|
884
|
+
notifyToast("success", "DEVS: Request not in cache." + (requestMethod === C6.GET ? " Page (" + query[C6.PAGINATION][C6.PAGE] + ")" : ''), toastOptionsDevs);
|
|
878
885
|
}
|
|
879
886
|
restRequestUri = restURL + operatingTable + '/';
|
|
880
887
|
needsConditionOrPrimaryCheck = (PUT === requestMethod || DELETE === requestMethod)
|
|
@@ -899,13 +906,13 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
899
906
|
|| null === query
|
|
900
907
|
|| (!(primaryKey in query) && !(primaryKeyFullyQualified && primaryKeyFullyQualified in query))) {
|
|
901
908
|
if (true === debug && isLocal()) {
|
|
902
|
-
|
|
909
|
+
notifyToast("error", "DEVS: The primary key (".concat(primaryKey, ") was not provided!!"));
|
|
903
910
|
}
|
|
904
911
|
throw Error('You must provide the primary key (' + primaryKey + ') for table (' + operatingTable + '). Request (' + JSON.stringify(this.request, undefined, 4) + ') Query (' + JSON.stringify(query) + ')');
|
|
905
912
|
}
|
|
906
913
|
providedPrimary = (_k = query === null || query === void 0 ? void 0 : query[primaryKey]) !== null && _k !== void 0 ? _k : (primaryKeyFullyQualified ? query === null || query === void 0 ? void 0 : query[primaryKeyFullyQualified] : undefined);
|
|
907
914
|
if (undefined === providedPrimary || null === providedPrimary) {
|
|
908
|
-
|
|
915
|
+
notifyToast("error", "The primary key (".concat(primaryKey, ") provided is undefined or null explicitly!!"));
|
|
909
916
|
throw Error('The primary key (' + primaryKey + ') provided in the request was exactly equal to undefined.');
|
|
910
917
|
}
|
|
911
918
|
}
|
|
@@ -947,7 +954,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
947
954
|
});
|
|
948
955
|
axiosActiveRequest_1 = (_e = axios)[requestMethod.toLowerCase()].apply(_e, __spreadArray([restRequestUri], (function () {
|
|
949
956
|
var convert = function (data) {
|
|
950
|
-
return convertForRequestBody(data, fullTableList, C6, function (message) { return
|
|
957
|
+
return convertForRequestBody(data, fullTableList, C6, function (message) { return notifyToast("error", message, toastOptions); });
|
|
951
958
|
};
|
|
952
959
|
var baseConfig = {
|
|
953
960
|
withCredentials: withCredentials,
|
|
@@ -1017,7 +1024,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
1017
1024
|
apiResponse = TestRestfulResponse(response, success, error);
|
|
1018
1025
|
if (false === apiResponse) {
|
|
1019
1026
|
if (debug && isLocal()) {
|
|
1020
|
-
|
|
1027
|
+
notifyToast("warning", "DEVS: TestRestfulResponse returned false.", toastOptionsDevs);
|
|
1021
1028
|
}
|
|
1022
1029
|
// Force a null payload so the final .then(response => response.data) yields null
|
|
1023
1030
|
return [2 /*return*/, Promise.resolve(__assign(__assign({}, response), { data: null }))];
|
|
@@ -1251,7 +1258,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
1251
1258
|
});
|
|
1252
1259
|
}
|
|
1253
1260
|
if (debug && isLocal()) {
|
|
1254
|
-
|
|
1261
|
+
notifyToast("success", "DEVS: (".concat(requestMethod, ") request complete."), toastOptionsDevs);
|
|
1255
1262
|
}
|
|
1256
1263
|
// this is the literal axios return
|
|
1257
1264
|
return [2 /*return*/, response];
|
|
@@ -3016,6 +3023,63 @@ var loadSqlAllowList = function (allowListPath) { return __awaiter(void 0, void
|
|
|
3016
3023
|
}
|
|
3017
3024
|
});
|
|
3018
3025
|
}); };
|
|
3026
|
+
var extractSqlEntries = function (payload) {
|
|
3027
|
+
if (typeof payload === "string") {
|
|
3028
|
+
return [payload];
|
|
3029
|
+
}
|
|
3030
|
+
if (Array.isArray(payload)) {
|
|
3031
|
+
return payload.flatMap(extractSqlEntries);
|
|
3032
|
+
}
|
|
3033
|
+
if (!payload || typeof payload !== "object") {
|
|
3034
|
+
return [];
|
|
3035
|
+
}
|
|
3036
|
+
var sqlValue = payload.sql;
|
|
3037
|
+
if (typeof sqlValue === "string") {
|
|
3038
|
+
return [sqlValue];
|
|
3039
|
+
}
|
|
3040
|
+
if (sqlValue && typeof sqlValue === "object") {
|
|
3041
|
+
var nested = sqlValue.sql;
|
|
3042
|
+
if (typeof nested === "string") {
|
|
3043
|
+
return [nested];
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
return [];
|
|
3047
|
+
};
|
|
3048
|
+
var collectSqlAllowListEntries = function (payload, entries) {
|
|
3049
|
+
if (entries === void 0) { entries = new Set(); }
|
|
3050
|
+
var sqlEntries = extractSqlEntries(payload)
|
|
3051
|
+
.map(normalizeSql)
|
|
3052
|
+
.filter(function (entry) { return entry.length > 0; });
|
|
3053
|
+
sqlEntries.forEach(function (entry) { return entries.add(entry); });
|
|
3054
|
+
return entries;
|
|
3055
|
+
};
|
|
3056
|
+
var compileSqlAllowList = function (allowListPath, entries) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3057
|
+
var _a, writeFile, mkdir, path, compiled;
|
|
3058
|
+
return __generator(this, function (_b) {
|
|
3059
|
+
switch (_b.label) {
|
|
3060
|
+
case 0:
|
|
3061
|
+
if (!isNode()) {
|
|
3062
|
+
throw new Error("SQL allowlist compilation requires a Node runtime.");
|
|
3063
|
+
}
|
|
3064
|
+
return [4 /*yield*/, import('node:fs/promises')];
|
|
3065
|
+
case 1:
|
|
3066
|
+
_a = _b.sent(), writeFile = _a.writeFile, mkdir = _a.mkdir;
|
|
3067
|
+
return [4 /*yield*/, import('node:path')];
|
|
3068
|
+
case 2:
|
|
3069
|
+
path = _b.sent();
|
|
3070
|
+
return [4 /*yield*/, mkdir(path.dirname(allowListPath), { recursive: true })];
|
|
3071
|
+
case 3:
|
|
3072
|
+
_b.sent();
|
|
3073
|
+
compiled = Array.from(new Set(Array.from(entries)
|
|
3074
|
+
.map(normalizeSql)
|
|
3075
|
+
.filter(function (entry) { return entry.length > 0; }))).sort();
|
|
3076
|
+
return [4 /*yield*/, writeFile(allowListPath, JSON.stringify(compiled, null, 2))];
|
|
3077
|
+
case 4:
|
|
3078
|
+
_b.sent();
|
|
3079
|
+
return [2 /*return*/, compiled];
|
|
3080
|
+
}
|
|
3081
|
+
});
|
|
3082
|
+
}); };
|
|
3019
3083
|
|
|
3020
3084
|
var SqlExecutor = /** @class */ (function (_super) {
|
|
3021
3085
|
__extends(SqlExecutor, _super);
|
|
@@ -3562,7 +3626,7 @@ function checkAllRequestsComplete() {
|
|
|
3562
3626
|
var cacheEntries = Array.from(apiRequestCache.values());
|
|
3563
3627
|
var stillRunning = cacheEntries.filter(function (cache) { return undefined === cache.response; });
|
|
3564
3628
|
if (stillRunning.length !== 0) {
|
|
3565
|
-
if (document ===
|
|
3629
|
+
if (typeof document === "undefined" || document === null) {
|
|
3566
3630
|
throw new Error('document is undefined while waiting for API requests to complete (' + JSON.stringify(cacheEntries) + ')');
|
|
3567
3631
|
}
|
|
3568
3632
|
// when requests return emtpy sets in full renders, it may not be possible to track their progress.
|
|
@@ -3573,10 +3637,10 @@ function checkAllRequestsComplete() {
|
|
|
3573
3637
|
}
|
|
3574
3638
|
|
|
3575
3639
|
function onSuccess(message) {
|
|
3576
|
-
|
|
3640
|
+
notifyToast("success", message, isLocal() ? toastOptionsDevs : toastOptions);
|
|
3577
3641
|
}
|
|
3578
3642
|
function onError(message) {
|
|
3579
|
-
|
|
3643
|
+
notifyToast("error", message, isLocal() ? toastOptionsDevs : toastOptions);
|
|
3580
3644
|
}
|
|
3581
3645
|
|
|
3582
3646
|
function isVerbose () {
|
|
@@ -3584,5 +3648,5 @@ function isVerbose () {
|
|
|
3584
3648
|
return ['true', '1', 'yes', 'on'].includes(envVerbose.toLowerCase());
|
|
3585
3649
|
}
|
|
3586
3650
|
|
|
3587
|
-
export { A, AggregateBuilder, C6C, C6Constants, ConditionBuilder, DELETE, DeleteQueryBuilder, Executor, ExpressHandler, F, GET, HttpExecutor, JoinBuilder, POST, PUT, PaginationBuilder, PostQueryBuilder, SelectQueryBuilder, SqlExecutor, TestRestfulResponse, UpdateQueryBuilder, apiRequestCache, axiosInstance, bbox, carbonNodeQsStringify, checkAllRequestsComplete, checkCache, clearCache, convertForRequestBody, convertHexIfBinary, derivedTable, determineRuntimeJsType, distSphere, eFetchDependencies, error, fieldEq, getEnvVar, getPrimaryKeyTypes, group, info, isDerivedTableKey, isLocal, isNode, isTest, isVerbose, loadSqlAllowList, normalizeSingularRequest, normalizeSql, onError, onSuccess, removeInvalidKeys, removePrefixIfExists, resolveDerivedTable, restOrm, restRequest, setCache, sortAndSerializeQueryObject, stContains, timeout, toastOptions, toastOptionsDevs, userCustomClearCache, warn };
|
|
3651
|
+
export { A, AggregateBuilder, C6C, C6Constants, ConditionBuilder, DELETE, DeleteQueryBuilder, Executor, ExpressHandler, F, GET, HttpExecutor, JoinBuilder, POST, PUT, PaginationBuilder, PostQueryBuilder, SelectQueryBuilder, SqlExecutor, TestRestfulResponse, UpdateQueryBuilder, apiRequestCache, axiosInstance, bbox, carbonNodeQsStringify, checkAllRequestsComplete, checkCache, clearCache, collectSqlAllowListEntries, compileSqlAllowList, convertForRequestBody, convertHexIfBinary, derivedTable, determineRuntimeJsType, distSphere, eFetchDependencies, error, extractSqlEntries, fieldEq, getEnvVar, getPrimaryKeyTypes, group, info, isDerivedTableKey, isLocal, isNode, isTest, isVerbose, loadSqlAllowList, normalizeSingularRequest, normalizeSql, notifyToast, onError, onSuccess, removeInvalidKeys, removePrefixIfExists, resolveDerivedTable, restOrm, restRequest, setCache, setToastHandler, sortAndSerializeQueryObject, stContains, timeout, toastOptions, toastOptionsDevs, userCustomClearCache, warn };
|
|
3588
3652
|
//# sourceMappingURL=index.esm.js.map
|