@budibase/backend-core 2.29.28 → 2.29.30
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/index.js +485 -387
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/src/features/index.d.ts +31 -13
- package/dist/src/features/index.js +92 -60
- package/dist/src/features/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +2 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/sql/sql.js +388 -237
- package/dist/src/sql/sql.js.map +1 -1
- package/dist/src/sql/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/features/index.ts +88 -59
- package/src/features/tests/features.spec.ts +86 -0
- package/src/index.ts +1 -2
- package/src/sql/sql.ts +453 -290
- package/src/sql/utils.ts +1 -0
- package/dist/src/features/installation.d.ts +0 -1
- package/dist/src/features/installation.js +0 -19
- package/dist/src/features/installation.js.map +0 -1
- package/dist/src/sql/sqlStatements.d.ts +0 -16
- package/dist/src/sql/sqlStatements.js +0 -66
- package/dist/src/sql/sqlStatements.js.map +0 -1
- package/src/features/installation.ts +0 -17
- package/src/features/tests/featureFlags.spec.ts +0 -85
- package/src/sql/sqlStatements.ts +0 -87
package/dist/index.js
CHANGED
|
@@ -15440,7 +15440,7 @@ var require_cookie = __commonJS({
|
|
|
15440
15440
|
c.value = cookieValue;
|
|
15441
15441
|
return c;
|
|
15442
15442
|
}
|
|
15443
|
-
function
|
|
15443
|
+
function parse(str, options2) {
|
|
15444
15444
|
if (!options2 || typeof options2 !== "object") {
|
|
15445
15445
|
options2 = {};
|
|
15446
15446
|
}
|
|
@@ -15622,7 +15622,7 @@ var require_cookie = __commonJS({
|
|
|
15622
15622
|
});
|
|
15623
15623
|
}
|
|
15624
15624
|
Cookie2.cookiesCreated = 0;
|
|
15625
|
-
Cookie2.parse =
|
|
15625
|
+
Cookie2.parse = parse;
|
|
15626
15626
|
Cookie2.fromJSON = fromJSON;
|
|
15627
15627
|
Cookie2.prototype.key = "";
|
|
15628
15628
|
Cookie2.prototype.value = "";
|
|
@@ -16179,7 +16179,7 @@ var require_cookie = __commonJS({
|
|
|
16179
16179
|
exports.MemoryCookieStore = MemoryCookieStore;
|
|
16180
16180
|
exports.parseDate = parseDate;
|
|
16181
16181
|
exports.formatDate = formatDate;
|
|
16182
|
-
exports.parse =
|
|
16182
|
+
exports.parse = parse;
|
|
16183
16183
|
exports.fromJSON = fromJSON;
|
|
16184
16184
|
exports.domainMatch = domainMatch;
|
|
16185
16185
|
exports.defaultPath = defaultPath;
|
|
@@ -16381,7 +16381,7 @@ var require_aws_sign2 = __commonJS({
|
|
|
16381
16381
|
"../../node_modules/aws-sign2/index.js"(exports, module2) {
|
|
16382
16382
|
"use strict";
|
|
16383
16383
|
var crypto2 = require("crypto");
|
|
16384
|
-
var
|
|
16384
|
+
var parse = require("url").parse;
|
|
16385
16385
|
var keys2 = [
|
|
16386
16386
|
"acl",
|
|
16387
16387
|
"location",
|
|
@@ -16447,7 +16447,7 @@ var require_aws_sign2 = __commonJS({
|
|
|
16447
16447
|
}
|
|
16448
16448
|
module2.exports.canonicalizeHeaders = canonicalizeHeaders;
|
|
16449
16449
|
function canonicalizeResource(resource) {
|
|
16450
|
-
var url =
|
|
16450
|
+
var url = parse(resource, true), path3 = url.pathname, buf = [];
|
|
16451
16451
|
Object.keys(url.query).forEach(function(key) {
|
|
16452
16452
|
if (!~keys2.indexOf(key))
|
|
16453
16453
|
return;
|
|
@@ -41274,11 +41274,11 @@ var require_lib7 = __commonJS({
|
|
|
41274
41274
|
"../../node_modules/request/node_modules/qs/lib/index.js"(exports, module2) {
|
|
41275
41275
|
"use strict";
|
|
41276
41276
|
var stringify = require_stringify2();
|
|
41277
|
-
var
|
|
41277
|
+
var parse = require_parse();
|
|
41278
41278
|
var formats2 = require_formats();
|
|
41279
41279
|
module2.exports = {
|
|
41280
41280
|
formats: formats2,
|
|
41281
|
-
parse
|
|
41281
|
+
parse,
|
|
41282
41282
|
stringify
|
|
41283
41283
|
};
|
|
41284
41284
|
}
|
|
@@ -41870,7 +41870,7 @@ var require_uri_all = __commonJS({
|
|
|
41870
41870
|
}
|
|
41871
41871
|
var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
|
|
41872
41872
|
var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === void 0;
|
|
41873
|
-
function
|
|
41873
|
+
function parse(uriString) {
|
|
41874
41874
|
var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
41875
41875
|
var components = {};
|
|
41876
41876
|
var protocol = options2.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
@@ -42041,8 +42041,8 @@ var require_uri_all = __commonJS({
|
|
|
42041
42041
|
var skipNormalization = arguments[3];
|
|
42042
42042
|
var target = {};
|
|
42043
42043
|
if (!skipNormalization) {
|
|
42044
|
-
base3 =
|
|
42045
|
-
relative =
|
|
42044
|
+
base3 = parse(serialize(base3, options2), options2);
|
|
42045
|
+
relative = parse(serialize(relative, options2), options2);
|
|
42046
42046
|
}
|
|
42047
42047
|
options2 = options2 || {};
|
|
42048
42048
|
if (!options2.tolerant && relative.scheme) {
|
|
@@ -42093,24 +42093,24 @@ var require_uri_all = __commonJS({
|
|
|
42093
42093
|
}
|
|
42094
42094
|
function resolve(baseURI, relativeURI, options2) {
|
|
42095
42095
|
var schemelessOptions = assign({ scheme: "null" }, options2);
|
|
42096
|
-
return serialize(resolveComponents(
|
|
42096
|
+
return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
42097
42097
|
}
|
|
42098
42098
|
function normalize(uri, options2) {
|
|
42099
42099
|
if (typeof uri === "string") {
|
|
42100
|
-
uri = serialize(
|
|
42100
|
+
uri = serialize(parse(uri, options2), options2);
|
|
42101
42101
|
} else if (typeOf(uri) === "object") {
|
|
42102
|
-
uri =
|
|
42102
|
+
uri = parse(serialize(uri, options2), options2);
|
|
42103
42103
|
}
|
|
42104
42104
|
return uri;
|
|
42105
42105
|
}
|
|
42106
42106
|
function equal(uriA, uriB, options2) {
|
|
42107
42107
|
if (typeof uriA === "string") {
|
|
42108
|
-
uriA = serialize(
|
|
42108
|
+
uriA = serialize(parse(uriA, options2), options2);
|
|
42109
42109
|
} else if (typeOf(uriA) === "object") {
|
|
42110
42110
|
uriA = serialize(uriA, options2);
|
|
42111
42111
|
}
|
|
42112
42112
|
if (typeof uriB === "string") {
|
|
42113
|
-
uriB = serialize(
|
|
42113
|
+
uriB = serialize(parse(uriB, options2), options2);
|
|
42114
42114
|
} else if (typeOf(uriB) === "object") {
|
|
42115
42115
|
uriB = serialize(uriB, options2);
|
|
42116
42116
|
}
|
|
@@ -42125,7 +42125,7 @@ var require_uri_all = __commonJS({
|
|
|
42125
42125
|
var handler = {
|
|
42126
42126
|
scheme: "http",
|
|
42127
42127
|
domainHost: true,
|
|
42128
|
-
parse: function
|
|
42128
|
+
parse: function parse2(components, options2) {
|
|
42129
42129
|
if (!components.host) {
|
|
42130
42130
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
42131
42131
|
}
|
|
@@ -42154,7 +42154,7 @@ var require_uri_all = __commonJS({
|
|
|
42154
42154
|
var handler$2 = {
|
|
42155
42155
|
scheme: "ws",
|
|
42156
42156
|
domainHost: true,
|
|
42157
|
-
parse: function
|
|
42157
|
+
parse: function parse2(components, options2) {
|
|
42158
42158
|
var wsComponents = components;
|
|
42159
42159
|
wsComponents.secure = isSecure(wsComponents);
|
|
42160
42160
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -42330,7 +42330,7 @@ var require_uri_all = __commonJS({
|
|
|
42330
42330
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
42331
42331
|
var handler$6 = {
|
|
42332
42332
|
scheme: "urn:uuid",
|
|
42333
|
-
parse: function
|
|
42333
|
+
parse: function parse2(urnComponents, options2) {
|
|
42334
42334
|
var uuidComponents = urnComponents;
|
|
42335
42335
|
uuidComponents.uuid = uuidComponents.nss;
|
|
42336
42336
|
uuidComponents.nss = void 0;
|
|
@@ -42355,7 +42355,7 @@ var require_uri_all = __commonJS({
|
|
|
42355
42355
|
exports2.SCHEMES = SCHEMES;
|
|
42356
42356
|
exports2.pctEncChar = pctEncChar;
|
|
42357
42357
|
exports2.pctDecChars = pctDecChars;
|
|
42358
|
-
exports2.parse =
|
|
42358
|
+
exports2.parse = parse;
|
|
42359
42359
|
exports2.removeDotSegments = removeDotSegments;
|
|
42360
42360
|
exports2.serialize = serialize;
|
|
42361
42361
|
exports2.resolveComponents = resolveComponents;
|
|
@@ -54195,8 +54195,7 @@ __export(src_exports, {
|
|
|
54195
54195
|
env: () => environment_default,
|
|
54196
54196
|
errors: () => errors_exports,
|
|
54197
54197
|
events: () => events_exports,
|
|
54198
|
-
|
|
54199
|
-
features: () => installation_exports2,
|
|
54198
|
+
features: () => features_exports,
|
|
54200
54199
|
getPublicError: () => getPublicError,
|
|
54201
54200
|
init: () => init9,
|
|
54202
54201
|
installation: () => installation_exports,
|
|
@@ -54462,6 +54461,15 @@ var DatasourceFeature = /* @__PURE__ */ ((DatasourceFeature2) => {
|
|
|
54462
54461
|
})(DatasourceFeature || {});
|
|
54463
54462
|
|
|
54464
54463
|
// ../types/src/sdk/search.ts
|
|
54464
|
+
var BasicOperator = /* @__PURE__ */ ((BasicOperator2) => {
|
|
54465
|
+
BasicOperator2["EQUAL"] = "equal";
|
|
54466
|
+
BasicOperator2["NOT_EQUAL"] = "notEqual";
|
|
54467
|
+
BasicOperator2["EMPTY"] = "empty";
|
|
54468
|
+
BasicOperator2["NOT_EMPTY"] = "notEmpty";
|
|
54469
|
+
BasicOperator2["FUZZY"] = "fuzzy";
|
|
54470
|
+
BasicOperator2["STRING"] = "string";
|
|
54471
|
+
return BasicOperator2;
|
|
54472
|
+
})(BasicOperator || {});
|
|
54465
54473
|
var ArrayOperator = /* @__PURE__ */ ((ArrayOperator2) => {
|
|
54466
54474
|
ArrayOperator2["CONTAINS"] = "contains";
|
|
54467
54475
|
ArrayOperator2["NOT_CONTAINS"] = "notContains";
|
|
@@ -54469,6 +54477,10 @@ var ArrayOperator = /* @__PURE__ */ ((ArrayOperator2) => {
|
|
|
54469
54477
|
ArrayOperator2["ONE_OF"] = "oneOf";
|
|
54470
54478
|
return ArrayOperator2;
|
|
54471
54479
|
})(ArrayOperator || {});
|
|
54480
|
+
var RangeOperator = /* @__PURE__ */ ((RangeOperator2) => {
|
|
54481
|
+
RangeOperator2["RANGE"] = "range";
|
|
54482
|
+
return RangeOperator2;
|
|
54483
|
+
})(RangeOperator || {});
|
|
54472
54484
|
|
|
54473
54485
|
// ../types/src/sdk/db.ts
|
|
54474
54486
|
var isDocument = (doc) => {
|
|
@@ -54988,6 +55000,8 @@ function validate(cronExpression) {
|
|
|
54988
55000
|
// ../shared-core/src/helpers/schema.ts
|
|
54989
55001
|
var schema_exports = {};
|
|
54990
55002
|
__export(schema_exports, {
|
|
55003
|
+
decodeNonAscii: () => decodeNonAscii,
|
|
55004
|
+
encodeNonAscii: () => encodeNonAscii,
|
|
54991
55005
|
isDeprecatedSingleUserColumn: () => isDeprecatedSingleUserColumn,
|
|
54992
55006
|
isRequired: () => isRequired
|
|
54993
55007
|
});
|
|
@@ -54999,6 +55013,17 @@ function isRequired(constraints) {
|
|
|
54999
55013
|
const isRequired2 = !!constraints && (typeof constraints.presence !== "boolean" && constraints.presence?.allowEmpty === false || constraints.presence === true);
|
|
55000
55014
|
return isRequired2;
|
|
55001
55015
|
}
|
|
55016
|
+
function encodeNonAscii(str) {
|
|
55017
|
+
return str.split("").map((char) => {
|
|
55018
|
+
return char.charCodeAt(0) > 127 ? "\\u" + char.charCodeAt(0).toString(16).padStart(4, "0") : char;
|
|
55019
|
+
}).join("");
|
|
55020
|
+
}
|
|
55021
|
+
function decodeNonAscii(str) {
|
|
55022
|
+
return str.replace(
|
|
55023
|
+
/\\u([0-9a-fA-F]{4})/g,
|
|
55024
|
+
(match, p1) => String.fromCharCode(parseInt(p1, 16))
|
|
55025
|
+
);
|
|
55026
|
+
}
|
|
55002
55027
|
|
|
55003
55028
|
// ../shared-core/src/filters.ts
|
|
55004
55029
|
var import_lodash = require("lodash");
|
|
@@ -55102,7 +55127,7 @@ var getKeyNumbering = (key) => {
|
|
|
55102
55127
|
}
|
|
55103
55128
|
};
|
|
55104
55129
|
var ColumnSplitter = class {
|
|
55105
|
-
constructor(tables) {
|
|
55130
|
+
constructor(tables, opts) {
|
|
55106
55131
|
this.tableNames = tables.map((table) => table.name);
|
|
55107
55132
|
this.tableIds = tables.map((table) => table._id);
|
|
55108
55133
|
this.relationshipColumnNames = tables.flatMap(
|
|
@@ -55111,11 +55136,28 @@ var ColumnSplitter = class {
|
|
|
55111
55136
|
)
|
|
55112
55137
|
);
|
|
55113
55138
|
this.relationships = this.tableNames.concat(this.tableIds).concat(this.relationshipColumnNames).sort((a, b) => b.length - a.length);
|
|
55139
|
+
if (opts?.aliases) {
|
|
55140
|
+
this.aliases = {};
|
|
55141
|
+
for (const [key, value] of Object.entries(opts.aliases)) {
|
|
55142
|
+
this.aliases[value] = key;
|
|
55143
|
+
}
|
|
55144
|
+
}
|
|
55145
|
+
this.columnPrefix = opts?.columnPrefix;
|
|
55114
55146
|
}
|
|
55115
55147
|
run(key) {
|
|
55116
55148
|
let { prefix, key: splitKey } = getKeyNumbering(key);
|
|
55149
|
+
let tableName = void 0;
|
|
55150
|
+
if (this.aliases) {
|
|
55151
|
+
for (const possibleAlias of Object.keys(this.aliases || {})) {
|
|
55152
|
+
const withDot = `${possibleAlias}.`;
|
|
55153
|
+
if (splitKey.startsWith(withDot)) {
|
|
55154
|
+
tableName = this.aliases[possibleAlias];
|
|
55155
|
+
splitKey = splitKey.slice(withDot.length);
|
|
55156
|
+
}
|
|
55157
|
+
}
|
|
55158
|
+
}
|
|
55117
55159
|
let relationship;
|
|
55118
|
-
for (
|
|
55160
|
+
for (const possibleRelationship of this.relationships) {
|
|
55119
55161
|
const withDot = `${possibleRelationship}.`;
|
|
55120
55162
|
if (splitKey.startsWith(withDot)) {
|
|
55121
55163
|
const finalKeyParts = splitKey.split(withDot);
|
|
@@ -55125,7 +55167,13 @@ var ColumnSplitter = class {
|
|
|
55125
55167
|
break;
|
|
55126
55168
|
}
|
|
55127
55169
|
}
|
|
55170
|
+
if (this.columnPrefix) {
|
|
55171
|
+
if (splitKey.startsWith(this.columnPrefix)) {
|
|
55172
|
+
splitKey = decodeNonAscii(splitKey.slice(this.columnPrefix.length));
|
|
55173
|
+
}
|
|
55174
|
+
}
|
|
55128
55175
|
return {
|
|
55176
|
+
tableName,
|
|
55129
55177
|
numberPrefix: prefix,
|
|
55130
55178
|
relationshipPrefix: relationship,
|
|
55131
55179
|
column: splitKey
|
|
@@ -55466,7 +55514,7 @@ var sort = (docs, sort2, sortOrder, sortType = "string" /* STRING */) => {
|
|
|
55466
55514
|
if (!sort2 || !sortOrder || !sortType) {
|
|
55467
55515
|
return docs;
|
|
55468
55516
|
}
|
|
55469
|
-
const
|
|
55517
|
+
const parse = (x) => {
|
|
55470
55518
|
if (x == null) {
|
|
55471
55519
|
return x;
|
|
55472
55520
|
}
|
|
@@ -55476,8 +55524,8 @@ var sort = (docs, sort2, sortOrder, sortType = "string" /* STRING */) => {
|
|
|
55476
55524
|
return parseFloat(x);
|
|
55477
55525
|
};
|
|
55478
55526
|
return docs.slice().sort((a, b) => {
|
|
55479
|
-
const colA =
|
|
55480
|
-
const colB =
|
|
55527
|
+
const colA = parse(a[sort2]);
|
|
55528
|
+
const colB = parse(b[sort2]);
|
|
55481
55529
|
const result = colB == null || colA > colB ? 1 : -1;
|
|
55482
55530
|
if (sortOrder.toLowerCase() === "descending") {
|
|
55483
55531
|
return result * -1;
|
|
@@ -65889,90 +65937,70 @@ var DEFINITIONS = [
|
|
|
65889
65937
|
// src/features/index.ts
|
|
65890
65938
|
var features_exports = {};
|
|
65891
65939
|
__export(features_exports, {
|
|
65892
|
-
|
|
65893
|
-
|
|
65894
|
-
|
|
65895
|
-
isEnabled: () => isEnabled
|
|
65896
|
-
processFeatureEnvVar: () => processFeatureEnvVar
|
|
65940
|
+
defaultFlags: () => defaultFlags,
|
|
65941
|
+
fetch: () => fetch6,
|
|
65942
|
+
get: () => get4,
|
|
65943
|
+
isEnabled: () => isEnabled
|
|
65897
65944
|
});
|
|
65898
|
-
|
|
65899
|
-
|
|
65900
|
-
|
|
65901
|
-
|
|
65902
|
-
processFeatureEnvVar: () => processFeatureEnvVar
|
|
65903
|
-
});
|
|
65904
|
-
function processFeatureEnvVar(fullList, featureList) {
|
|
65905
|
-
let list;
|
|
65906
|
-
if (!featureList) {
|
|
65907
|
-
list = fullList;
|
|
65908
|
-
} else {
|
|
65909
|
-
list = featureList.split(",");
|
|
65945
|
+
var import_lodash2 = require("lodash");
|
|
65946
|
+
var Flag = class _Flag {
|
|
65947
|
+
constructor(defaultValue) {
|
|
65948
|
+
this.defaultValue = defaultValue;
|
|
65910
65949
|
}
|
|
65911
|
-
|
|
65912
|
-
|
|
65913
|
-
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
65914
|
-
}
|
|
65950
|
+
static withDefault(value) {
|
|
65951
|
+
return new _Flag(value);
|
|
65915
65952
|
}
|
|
65916
|
-
|
|
65917
|
-
|
|
65918
|
-
|
|
65919
|
-
|
|
65920
|
-
|
|
65921
|
-
|
|
65922
|
-
|
|
65923
|
-
|
|
65924
|
-
const
|
|
65925
|
-
|
|
65926
|
-
|
|
65927
|
-
|
|
65928
|
-
|
|
65929
|
-
|
|
65930
|
-
|
|
65931
|
-
|
|
65932
|
-
|
|
65933
|
-
|
|
65934
|
-
|
|
65935
|
-
|
|
65936
|
-
|
|
65937
|
-
const
|
|
65938
|
-
const
|
|
65939
|
-
|
|
65940
|
-
|
|
65941
|
-
function getTenantFeatureFlags(tenantId) {
|
|
65942
|
-
let flags = [];
|
|
65943
|
-
const envFlags = buildFeatureFlags();
|
|
65944
|
-
if (envFlags) {
|
|
65945
|
-
const globalFlags = envFlags["*"];
|
|
65946
|
-
const tenantFlags = envFlags[tenantId] || [];
|
|
65947
|
-
const tenantOverrides = tenantFlags.reduce(
|
|
65948
|
-
(acc, flag) => {
|
|
65949
|
-
if (flag.startsWith("!")) {
|
|
65950
|
-
let stripped = flag.substring(1);
|
|
65951
|
-
acc.push(stripped);
|
|
65952
|
-
}
|
|
65953
|
-
return acc;
|
|
65954
|
-
},
|
|
65955
|
-
[]
|
|
65956
|
-
);
|
|
65957
|
-
if (globalFlags) {
|
|
65958
|
-
flags.push(...globalFlags);
|
|
65953
|
+
};
|
|
65954
|
+
var FLAGS = {
|
|
65955
|
+
LICENSING: Flag.withDefault(false),
|
|
65956
|
+
GOOGLE_SHEETS: Flag.withDefault(false),
|
|
65957
|
+
USER_GROUPS: Flag.withDefault(false),
|
|
65958
|
+
ONBOARDING_TOUR: Flag.withDefault(false)
|
|
65959
|
+
};
|
|
65960
|
+
var DEFAULTS = Object.keys(FLAGS).reduce((acc, key) => {
|
|
65961
|
+
const typedKey = key;
|
|
65962
|
+
acc[typedKey] = FLAGS[typedKey].defaultValue;
|
|
65963
|
+
return acc;
|
|
65964
|
+
}, {});
|
|
65965
|
+
function defaultFlags() {
|
|
65966
|
+
return (0, import_lodash2.cloneDeep)(DEFAULTS);
|
|
65967
|
+
}
|
|
65968
|
+
function isFlagName(name) {
|
|
65969
|
+
return FLAGS[name] !== void 0;
|
|
65970
|
+
}
|
|
65971
|
+
async function fetch6() {
|
|
65972
|
+
const currentTenantId = getTenantId();
|
|
65973
|
+
const flags = defaultFlags();
|
|
65974
|
+
const split = (environment_default.TENANT_FEATURE_FLAGS || "").split(",").map((x) => x.split(":"));
|
|
65975
|
+
for (const [tenantId, ...features] of split) {
|
|
65976
|
+
if (!tenantId || tenantId !== "*" && tenantId !== currentTenantId) {
|
|
65977
|
+
continue;
|
|
65959
65978
|
}
|
|
65960
|
-
|
|
65961
|
-
|
|
65979
|
+
for (let feature of features) {
|
|
65980
|
+
let value = true;
|
|
65981
|
+
if (feature.startsWith("!")) {
|
|
65982
|
+
feature = feature.slice(1);
|
|
65983
|
+
value = false;
|
|
65984
|
+
}
|
|
65985
|
+
if (!isFlagName(feature)) {
|
|
65986
|
+
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
65987
|
+
}
|
|
65988
|
+
if (typeof flags[feature] !== "boolean") {
|
|
65989
|
+
throw new Error(`Feature: ${feature} is not a boolean`);
|
|
65990
|
+
}
|
|
65991
|
+
flags[feature] = value;
|
|
65962
65992
|
}
|
|
65963
|
-
flags = flags.filter((flag) => {
|
|
65964
|
-
return tenantOverrides.indexOf(flag) == -1 && !flag.startsWith("!");
|
|
65965
|
-
});
|
|
65966
65993
|
}
|
|
65967
65994
|
return flags;
|
|
65968
65995
|
}
|
|
65969
|
-
|
|
65970
|
-
|
|
65971
|
-
|
|
65972
|
-
|
|
65973
|
-
|
|
65974
|
-
|
|
65975
|
-
|
|
65996
|
+
async function get4(name) {
|
|
65997
|
+
const flags = await fetch6();
|
|
65998
|
+
return flags[name];
|
|
65999
|
+
}
|
|
66000
|
+
async function isEnabled(name) {
|
|
66001
|
+
const flags = await fetch6();
|
|
66002
|
+
return flags[name];
|
|
66003
|
+
}
|
|
65976
66004
|
|
|
65977
66005
|
// src/auth/index.ts
|
|
65978
66006
|
var auth_exports = {};
|
|
@@ -67432,62 +67460,6 @@ __export(sql_exports, {
|
|
|
67432
67460
|
// src/sql/sql.ts
|
|
67433
67461
|
var import_knex2 = require("knex");
|
|
67434
67462
|
|
|
67435
|
-
// src/sql/sqlStatements.ts
|
|
67436
|
-
var SqlStatements = class {
|
|
67437
|
-
constructor(client, table, { allOr, columnPrefix } = {}) {
|
|
67438
|
-
this.client = client;
|
|
67439
|
-
this.table = table;
|
|
67440
|
-
this.allOr = allOr;
|
|
67441
|
-
this.columnPrefix = columnPrefix;
|
|
67442
|
-
}
|
|
67443
|
-
getField(key) {
|
|
67444
|
-
const fieldName = key.split(".")[1];
|
|
67445
|
-
let found = this.table.schema[fieldName];
|
|
67446
|
-
if (!found && this.columnPrefix) {
|
|
67447
|
-
const prefixRemovedFieldName = fieldName.replace(this.columnPrefix, "");
|
|
67448
|
-
found = this.table.schema[prefixRemovedFieldName];
|
|
67449
|
-
}
|
|
67450
|
-
return found;
|
|
67451
|
-
}
|
|
67452
|
-
between(query, key, low, high) {
|
|
67453
|
-
const field = this.getField(key);
|
|
67454
|
-
if (field?.type === "bigint" /* BIGINT */ && this.client === "sqlite3" /* SQL_LITE */) {
|
|
67455
|
-
query = query.whereRaw(
|
|
67456
|
-
`CAST(${key} AS INTEGER) BETWEEN CAST(? AS INTEGER) AND CAST(? AS INTEGER)`,
|
|
67457
|
-
[low, high]
|
|
67458
|
-
);
|
|
67459
|
-
} else {
|
|
67460
|
-
const fnc = this.allOr ? "orWhereBetween" : "whereBetween";
|
|
67461
|
-
query = query[fnc](key, [low, high]);
|
|
67462
|
-
}
|
|
67463
|
-
return query;
|
|
67464
|
-
}
|
|
67465
|
-
lte(query, key, low) {
|
|
67466
|
-
const field = this.getField(key);
|
|
67467
|
-
if (field?.type === "bigint" /* BIGINT */ && this.client === "sqlite3" /* SQL_LITE */) {
|
|
67468
|
-
query = query.whereRaw(`CAST(${key} AS INTEGER) >= CAST(? AS INTEGER)`, [
|
|
67469
|
-
low
|
|
67470
|
-
]);
|
|
67471
|
-
} else {
|
|
67472
|
-
const fnc = this.allOr ? "orWhere" : "where";
|
|
67473
|
-
query = query[fnc](key, ">=", low);
|
|
67474
|
-
}
|
|
67475
|
-
return query;
|
|
67476
|
-
}
|
|
67477
|
-
gte(query, key, high) {
|
|
67478
|
-
const field = this.getField(key);
|
|
67479
|
-
if (field?.type === "bigint" /* BIGINT */ && this.client === "sqlite3" /* SQL_LITE */) {
|
|
67480
|
-
query = query.whereRaw(`CAST(${key} AS INTEGER) <= CAST(? AS INTEGER)`, [
|
|
67481
|
-
high
|
|
67482
|
-
]);
|
|
67483
|
-
} else {
|
|
67484
|
-
const fnc = this.allOr ? "orWhere" : "where";
|
|
67485
|
-
query = query[fnc](key, "<=", high);
|
|
67486
|
-
}
|
|
67487
|
-
return query;
|
|
67488
|
-
}
|
|
67489
|
-
};
|
|
67490
|
-
|
|
67491
67463
|
// src/sql/sqlTable.ts
|
|
67492
67464
|
var import_knex = require("knex");
|
|
67493
67465
|
function isIgnoredType(type) {
|
|
@@ -67704,109 +67676,6 @@ function getBaseLimit() {
|
|
|
67704
67676
|
const envLimit = environment_default.SQL_MAX_ROWS ? parseInt(environment_default.SQL_MAX_ROWS) : null;
|
|
67705
67677
|
return envLimit || 5e3;
|
|
67706
67678
|
}
|
|
67707
|
-
function quote(client, str) {
|
|
67708
|
-
switch (client) {
|
|
67709
|
-
case "sqlite3" /* SQL_LITE */:
|
|
67710
|
-
case "oracledb" /* ORACLE */:
|
|
67711
|
-
case "pg" /* POSTGRES */:
|
|
67712
|
-
return `"${str}"`;
|
|
67713
|
-
case "mssql" /* MS_SQL */:
|
|
67714
|
-
return `[${str}]`;
|
|
67715
|
-
case "mysql2" /* MY_SQL */:
|
|
67716
|
-
return `\`${str}\``;
|
|
67717
|
-
}
|
|
67718
|
-
}
|
|
67719
|
-
function quotedIdentifier(client, key) {
|
|
67720
|
-
return key.split(".").map((part) => quote(client, part)).join(".");
|
|
67721
|
-
}
|
|
67722
|
-
function parse(input) {
|
|
67723
|
-
if (Array.isArray(input)) {
|
|
67724
|
-
return JSON.stringify(input);
|
|
67725
|
-
}
|
|
67726
|
-
if (input == void 0) {
|
|
67727
|
-
return null;
|
|
67728
|
-
}
|
|
67729
|
-
if (typeof input !== "string") {
|
|
67730
|
-
return input;
|
|
67731
|
-
}
|
|
67732
|
-
if (isInvalidISODateString(input)) {
|
|
67733
|
-
return null;
|
|
67734
|
-
}
|
|
67735
|
-
if (isValidISODateString(input)) {
|
|
67736
|
-
return new Date(input.trim());
|
|
67737
|
-
}
|
|
67738
|
-
return input;
|
|
67739
|
-
}
|
|
67740
|
-
function parseBody(body2) {
|
|
67741
|
-
for (let [key, value] of Object.entries(body2)) {
|
|
67742
|
-
body2[key] = parse(value);
|
|
67743
|
-
}
|
|
67744
|
-
return body2;
|
|
67745
|
-
}
|
|
67746
|
-
function parseFilters(filters) {
|
|
67747
|
-
if (!filters) {
|
|
67748
|
-
return {};
|
|
67749
|
-
}
|
|
67750
|
-
for (let [key, value] of Object.entries(filters)) {
|
|
67751
|
-
let parsed;
|
|
67752
|
-
if (typeof value === "object") {
|
|
67753
|
-
parsed = parseFilters(value);
|
|
67754
|
-
} else {
|
|
67755
|
-
parsed = parse(value);
|
|
67756
|
-
}
|
|
67757
|
-
filters[key] = parsed;
|
|
67758
|
-
}
|
|
67759
|
-
return filters;
|
|
67760
|
-
}
|
|
67761
|
-
function generateSelectStatement(json, knex3) {
|
|
67762
|
-
const { resource, meta } = json;
|
|
67763
|
-
const client = knex3.client.config.client;
|
|
67764
|
-
if (!resource || !resource.fields || resource.fields.length === 0) {
|
|
67765
|
-
return "*";
|
|
67766
|
-
}
|
|
67767
|
-
const schema = meta.table.schema;
|
|
67768
|
-
return resource.fields.map((field) => {
|
|
67769
|
-
const parts = field.split(/\./g);
|
|
67770
|
-
let table = void 0;
|
|
67771
|
-
let column = void 0;
|
|
67772
|
-
if (parts.length === 1) {
|
|
67773
|
-
column = parts[0];
|
|
67774
|
-
}
|
|
67775
|
-
if (parts.length === 2) {
|
|
67776
|
-
table = parts[0];
|
|
67777
|
-
column = parts[1];
|
|
67778
|
-
}
|
|
67779
|
-
if (parts.length > 2) {
|
|
67780
|
-
table = parts[0];
|
|
67781
|
-
column = parts.slice(1).join(".");
|
|
67782
|
-
}
|
|
67783
|
-
if (!column) {
|
|
67784
|
-
throw new Error(`Invalid field name: ${field}`);
|
|
67785
|
-
}
|
|
67786
|
-
const columnSchema = schema[column];
|
|
67787
|
-
if (client === "pg" /* POSTGRES */ && columnSchema?.externalType?.includes("money")) {
|
|
67788
|
-
return knex3.raw(
|
|
67789
|
-
`${quotedIdentifier(
|
|
67790
|
-
client,
|
|
67791
|
-
[table, column].join(".")
|
|
67792
|
-
)}::money::numeric as ${quote(client, field)}`
|
|
67793
|
-
);
|
|
67794
|
-
}
|
|
67795
|
-
if (client === "mssql" /* MS_SQL */ && columnSchema?.type === "datetime" /* DATETIME */ && columnSchema.timeOnly) {
|
|
67796
|
-
return knex3.raw(`CONVERT(varchar, ${field}, 108) as "${field}"`);
|
|
67797
|
-
}
|
|
67798
|
-
if (table) {
|
|
67799
|
-
return knex3.raw(
|
|
67800
|
-
`${quote(client, table)}.${quote(client, column)} as ${quote(
|
|
67801
|
-
client,
|
|
67802
|
-
field
|
|
67803
|
-
)}`
|
|
67804
|
-
);
|
|
67805
|
-
} else {
|
|
67806
|
-
return knex3.raw(`${quote(client, field)} as ${quote(client, field)}`);
|
|
67807
|
-
}
|
|
67808
|
-
});
|
|
67809
|
-
}
|
|
67810
67679
|
function getTableName(table) {
|
|
67811
67680
|
if (table?.sourceType === "internal" /* INTERNAL */ || table?.sourceId === INTERNAL_TABLE_SOURCE_ID) {
|
|
67812
67681
|
return table?._id;
|
|
@@ -67830,23 +67699,203 @@ function convertBooleans(query) {
|
|
|
67830
67699
|
return query;
|
|
67831
67700
|
}
|
|
67832
67701
|
var InternalBuilder = class {
|
|
67833
|
-
constructor(client) {
|
|
67702
|
+
constructor(client, knex3, query) {
|
|
67834
67703
|
this.client = client;
|
|
67704
|
+
this.query = query;
|
|
67705
|
+
this.knex = knex3;
|
|
67706
|
+
this.splitter = new filters_exports.ColumnSplitter([this.table], {
|
|
67707
|
+
aliases: this.query.tableAliases,
|
|
67708
|
+
columnPrefix: this.query.meta.columnPrefix
|
|
67709
|
+
});
|
|
67710
|
+
}
|
|
67711
|
+
get table() {
|
|
67712
|
+
return this.query.meta.table;
|
|
67713
|
+
}
|
|
67714
|
+
getFieldSchema(key) {
|
|
67715
|
+
const { column } = this.splitter.run(key);
|
|
67716
|
+
return this.table.schema[column];
|
|
67717
|
+
}
|
|
67718
|
+
// Takes a string like foo and returns a quoted string like [foo] for SQL Server
|
|
67719
|
+
// and "foo" for Postgres.
|
|
67720
|
+
quote(str) {
|
|
67721
|
+
switch (this.client) {
|
|
67722
|
+
case "sqlite3" /* SQL_LITE */:
|
|
67723
|
+
case "oracledb" /* ORACLE */:
|
|
67724
|
+
case "pg" /* POSTGRES */:
|
|
67725
|
+
return `"${str}"`;
|
|
67726
|
+
case "mssql" /* MS_SQL */:
|
|
67727
|
+
return `[${str}]`;
|
|
67728
|
+
case "mysql2" /* MY_SQL */:
|
|
67729
|
+
return `\`${str}\``;
|
|
67730
|
+
}
|
|
67731
|
+
}
|
|
67732
|
+
// Takes a string like a.b.c and returns a quoted identifier like [a].[b].[c]
|
|
67733
|
+
// for SQL Server and `a`.`b`.`c` for MySQL.
|
|
67734
|
+
quotedIdentifier(key) {
|
|
67735
|
+
return key.split(".").map((part) => this.quote(part)).join(".");
|
|
67736
|
+
}
|
|
67737
|
+
generateSelectStatement() {
|
|
67738
|
+
const { resource, meta } = this.query;
|
|
67739
|
+
if (!resource || !resource.fields || resource.fields.length === 0) {
|
|
67740
|
+
return "*";
|
|
67741
|
+
}
|
|
67742
|
+
const schema = meta.table.schema;
|
|
67743
|
+
return resource.fields.map((field) => {
|
|
67744
|
+
const parts = field.split(/\./g);
|
|
67745
|
+
let table = void 0;
|
|
67746
|
+
let column = void 0;
|
|
67747
|
+
if (parts.length === 1) {
|
|
67748
|
+
column = parts[0];
|
|
67749
|
+
}
|
|
67750
|
+
if (parts.length === 2) {
|
|
67751
|
+
table = parts[0];
|
|
67752
|
+
column = parts[1];
|
|
67753
|
+
}
|
|
67754
|
+
if (parts.length > 2) {
|
|
67755
|
+
table = parts[0];
|
|
67756
|
+
column = parts.slice(1).join(".");
|
|
67757
|
+
}
|
|
67758
|
+
if (!column) {
|
|
67759
|
+
throw new Error(`Invalid field name: ${field}`);
|
|
67760
|
+
}
|
|
67761
|
+
const columnSchema = schema[column];
|
|
67762
|
+
if (this.client === "pg" /* POSTGRES */ && columnSchema?.externalType?.includes("money")) {
|
|
67763
|
+
return this.knex.raw(
|
|
67764
|
+
`${this.quotedIdentifier(
|
|
67765
|
+
[table, column].join(".")
|
|
67766
|
+
)}::money::numeric as ${this.quote(field)}`
|
|
67767
|
+
);
|
|
67768
|
+
}
|
|
67769
|
+
if (this.client === "mssql" /* MS_SQL */ && columnSchema?.type === "datetime" /* DATETIME */ && columnSchema.timeOnly) {
|
|
67770
|
+
return this.knex.raw(`CONVERT(varchar, ${field}, 108) as "${field}"`);
|
|
67771
|
+
}
|
|
67772
|
+
if (table) {
|
|
67773
|
+
return this.knex.raw(
|
|
67774
|
+
`${this.quote(table)}.${this.quote(column)} as ${this.quote(field)}`
|
|
67775
|
+
);
|
|
67776
|
+
} else {
|
|
67777
|
+
return this.knex.raw(`${this.quote(field)} as ${this.quote(field)}`);
|
|
67778
|
+
}
|
|
67779
|
+
});
|
|
67780
|
+
}
|
|
67781
|
+
// OracleDB can't use character-large-objects (CLOBs) in WHERE clauses,
|
|
67782
|
+
// so when we use them we need to wrap them in to_char(). This function
|
|
67783
|
+
// converts a field name to the appropriate identifier.
|
|
67784
|
+
convertClobs(field) {
|
|
67785
|
+
const parts = field.split(".");
|
|
67786
|
+
const col = parts.pop();
|
|
67787
|
+
const schema = this.table.schema[col];
|
|
67788
|
+
let identifier = this.quotedIdentifier(field);
|
|
67789
|
+
if (schema.type === "string" /* STRING */ || schema.type === "longform" /* LONGFORM */ || schema.type === "bb_reference_single" /* BB_REFERENCE_SINGLE */ || schema.type === "bb_reference" /* BB_REFERENCE */ || schema.type === "options" /* OPTIONS */ || schema.type === "barcodeqr" /* BARCODEQR */) {
|
|
67790
|
+
identifier = `to_char(${identifier})`;
|
|
67791
|
+
}
|
|
67792
|
+
return identifier;
|
|
67793
|
+
}
|
|
67794
|
+
parse(input, schema) {
|
|
67795
|
+
if (Array.isArray(input)) {
|
|
67796
|
+
return JSON.stringify(input);
|
|
67797
|
+
}
|
|
67798
|
+
if (input == void 0) {
|
|
67799
|
+
return null;
|
|
67800
|
+
}
|
|
67801
|
+
if (this.client === "oracledb" /* ORACLE */ && schema.type === "datetime" /* DATETIME */ && schema.timeOnly) {
|
|
67802
|
+
if (input instanceof Date) {
|
|
67803
|
+
const hours = input.getHours().toString().padStart(2, "0");
|
|
67804
|
+
const minutes = input.getMinutes().toString().padStart(2, "0");
|
|
67805
|
+
const seconds = input.getSeconds().toString().padStart(2, "0");
|
|
67806
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
67807
|
+
}
|
|
67808
|
+
if (typeof input === "string") {
|
|
67809
|
+
return /* @__PURE__ */ new Date(`1970-01-01T${input}Z`);
|
|
67810
|
+
}
|
|
67811
|
+
}
|
|
67812
|
+
if (typeof input === "string") {
|
|
67813
|
+
if (isInvalidISODateString(input)) {
|
|
67814
|
+
return null;
|
|
67815
|
+
}
|
|
67816
|
+
if (isValidISODateString(input)) {
|
|
67817
|
+
return new Date(input.trim());
|
|
67818
|
+
}
|
|
67819
|
+
}
|
|
67820
|
+
return input;
|
|
67821
|
+
}
|
|
67822
|
+
parseBody(body2) {
|
|
67823
|
+
for (let [key, value] of Object.entries(body2)) {
|
|
67824
|
+
const { column } = this.splitter.run(key);
|
|
67825
|
+
const schema = this.table.schema[column];
|
|
67826
|
+
if (!schema) {
|
|
67827
|
+
continue;
|
|
67828
|
+
}
|
|
67829
|
+
body2[key] = this.parse(value, schema);
|
|
67830
|
+
}
|
|
67831
|
+
return body2;
|
|
67832
|
+
}
|
|
67833
|
+
parseFilters(filters) {
|
|
67834
|
+
for (const op of Object.values(BasicOperator)) {
|
|
67835
|
+
const filter = filters[op];
|
|
67836
|
+
if (!filter) {
|
|
67837
|
+
continue;
|
|
67838
|
+
}
|
|
67839
|
+
for (const key of Object.keys(filter)) {
|
|
67840
|
+
if (Array.isArray(filter[key])) {
|
|
67841
|
+
filter[key] = JSON.stringify(filter[key]);
|
|
67842
|
+
continue;
|
|
67843
|
+
}
|
|
67844
|
+
const { column } = this.splitter.run(key);
|
|
67845
|
+
const schema = this.table.schema[column];
|
|
67846
|
+
if (!schema) {
|
|
67847
|
+
continue;
|
|
67848
|
+
}
|
|
67849
|
+
filter[key] = this.parse(filter[key], schema);
|
|
67850
|
+
}
|
|
67851
|
+
}
|
|
67852
|
+
for (const op of Object.values(ArrayOperator)) {
|
|
67853
|
+
const filter = filters[op];
|
|
67854
|
+
if (!filter) {
|
|
67855
|
+
continue;
|
|
67856
|
+
}
|
|
67857
|
+
for (const key of Object.keys(filter)) {
|
|
67858
|
+
const { column } = this.splitter.run(key);
|
|
67859
|
+
const schema = this.table.schema[column];
|
|
67860
|
+
if (!schema) {
|
|
67861
|
+
continue;
|
|
67862
|
+
}
|
|
67863
|
+
filter[key] = filter[key].map((v) => this.parse(v, schema));
|
|
67864
|
+
}
|
|
67865
|
+
}
|
|
67866
|
+
for (const op of Object.values(RangeOperator)) {
|
|
67867
|
+
const filter = filters[op];
|
|
67868
|
+
if (!filter) {
|
|
67869
|
+
continue;
|
|
67870
|
+
}
|
|
67871
|
+
for (const key of Object.keys(filter)) {
|
|
67872
|
+
const { column } = this.splitter.run(key);
|
|
67873
|
+
const schema = this.table.schema[column];
|
|
67874
|
+
if (!schema) {
|
|
67875
|
+
continue;
|
|
67876
|
+
}
|
|
67877
|
+
const value = filter[key];
|
|
67878
|
+
if ("low" in value) {
|
|
67879
|
+
value.low = this.parse(value.low, schema);
|
|
67880
|
+
}
|
|
67881
|
+
if ("high" in value) {
|
|
67882
|
+
value.high = this.parse(value.high, schema);
|
|
67883
|
+
}
|
|
67884
|
+
}
|
|
67885
|
+
}
|
|
67886
|
+
return filters;
|
|
67835
67887
|
}
|
|
67836
67888
|
// right now we only do filters on the specific table being queried
|
|
67837
|
-
addFilters(query, filters,
|
|
67889
|
+
addFilters(query, filters, opts) {
|
|
67838
67890
|
if (!filters) {
|
|
67839
67891
|
return query;
|
|
67840
67892
|
}
|
|
67841
|
-
filters = parseFilters(filters);
|
|
67893
|
+
filters = this.parseFilters(filters);
|
|
67894
|
+
const aliases = this.query.tableAliases;
|
|
67842
67895
|
const allOr = filters.allOr;
|
|
67843
|
-
const
|
|
67844
|
-
allOr,
|
|
67845
|
-
columnPrefix: opts.columnPrefix
|
|
67846
|
-
});
|
|
67847
|
-
const tableName = this.client === "sqlite3" /* SQL_LITE */ ? table._id : table.name;
|
|
67896
|
+
const tableName = this.client === "sqlite3" /* SQL_LITE */ ? this.table._id : this.table.name;
|
|
67848
67897
|
function getTableAlias(name) {
|
|
67849
|
-
const alias =
|
|
67898
|
+
const alias = aliases?.[name];
|
|
67850
67899
|
return alias || name;
|
|
67851
67900
|
}
|
|
67852
67901
|
function iterate(structure, fn, complexKeyFn) {
|
|
@@ -67863,10 +67912,10 @@ var InternalBuilder = class {
|
|
|
67863
67912
|
),
|
|
67864
67913
|
castedTypeValue.values
|
|
67865
67914
|
);
|
|
67866
|
-
} else if (!opts
|
|
67915
|
+
} else if (!opts?.relationship && !isRelationshipField) {
|
|
67867
67916
|
const alias = getTableAlias(tableName);
|
|
67868
67917
|
fn(alias ? `${alias}.${updatedKey}` : updatedKey, value);
|
|
67869
|
-
} else if (opts
|
|
67918
|
+
} else if (opts?.relationship && isRelationshipField) {
|
|
67870
67919
|
const [filterTableName, property] = updatedKey.split(".");
|
|
67871
67920
|
const alias = getTableAlias(filterTableName);
|
|
67872
67921
|
fn(alias ? `${alias}.${property}` : property, value);
|
|
@@ -67880,10 +67929,9 @@ var InternalBuilder = class {
|
|
|
67880
67929
|
query = query[fnc](key, "ilike", `%${value}%`);
|
|
67881
67930
|
} else {
|
|
67882
67931
|
const rawFnc = `${fnc}Raw`;
|
|
67883
|
-
query = query[rawFnc](
|
|
67884
|
-
|
|
67885
|
-
|
|
67886
|
-
);
|
|
67932
|
+
query = query[rawFnc](`LOWER(${this.quotedIdentifier(key)}) LIKE ?`, [
|
|
67933
|
+
`%${value.toLowerCase()}%`
|
|
67934
|
+
]);
|
|
67887
67935
|
}
|
|
67888
67936
|
};
|
|
67889
67937
|
const contains = (mode, any = false) => {
|
|
@@ -67902,10 +67950,10 @@ var InternalBuilder = class {
|
|
|
67902
67950
|
const wrap = any ? "" : "'";
|
|
67903
67951
|
const op = any ? "\\?| array" : "@>";
|
|
67904
67952
|
const fieldNames = key.split(/\./g);
|
|
67905
|
-
const
|
|
67953
|
+
const table = fieldNames[0];
|
|
67906
67954
|
const col = fieldNames[1];
|
|
67907
67955
|
query = query[rawFnc](
|
|
67908
|
-
`${not}COALESCE("${
|
|
67956
|
+
`${not}COALESCE("${table}"."${col}"::jsonb ${op} ${wrap}${stringifyArray(
|
|
67909
67957
|
value,
|
|
67910
67958
|
any ? "'" : '"'
|
|
67911
67959
|
)}${wrap}, FALSE)`
|
|
@@ -67924,21 +67972,26 @@ var InternalBuilder = class {
|
|
|
67924
67972
|
const andOr = mode === filters?.containsAny ? " OR " : " AND ";
|
|
67925
67973
|
iterate(mode, (key, value) => {
|
|
67926
67974
|
let statement = "";
|
|
67975
|
+
const identifier = this.quotedIdentifier(key);
|
|
67927
67976
|
for (let i in value) {
|
|
67928
67977
|
if (typeof value[i] === "string") {
|
|
67929
67978
|
value[i] = `%"${value[i].toLowerCase()}"%`;
|
|
67930
67979
|
} else {
|
|
67931
67980
|
value[i] = `%${value[i]}%`;
|
|
67932
67981
|
}
|
|
67933
|
-
statement +=
|
|
67934
|
-
this.client,
|
|
67935
|
-
key
|
|
67936
|
-
)}), '') LIKE ?`;
|
|
67982
|
+
statement += `${statement ? andOr : ""}COALESCE(LOWER(${identifier}), '') LIKE ?`;
|
|
67937
67983
|
}
|
|
67938
67984
|
if (statement === "") {
|
|
67939
67985
|
return;
|
|
67940
67986
|
}
|
|
67941
|
-
|
|
67987
|
+
if (not) {
|
|
67988
|
+
query = query[rawFnc](
|
|
67989
|
+
`(NOT (${statement}) OR ${identifier} IS NULL)`,
|
|
67990
|
+
value
|
|
67991
|
+
);
|
|
67992
|
+
} else {
|
|
67993
|
+
query = query[rawFnc](statement, value);
|
|
67994
|
+
}
|
|
67942
67995
|
});
|
|
67943
67996
|
}
|
|
67944
67997
|
};
|
|
@@ -67947,10 +68000,23 @@ var InternalBuilder = class {
|
|
|
67947
68000
|
iterate(
|
|
67948
68001
|
filters.oneOf,
|
|
67949
68002
|
(key, array) => {
|
|
67950
|
-
|
|
68003
|
+
if (this.client === "oracledb" /* ORACLE */) {
|
|
68004
|
+
key = this.convertClobs(key);
|
|
68005
|
+
array = Array.isArray(array) ? array : [array];
|
|
68006
|
+
const binding = new Array(array.length).fill("?").join(",");
|
|
68007
|
+
query = query.whereRaw(`${key} IN (${binding})`, array);
|
|
68008
|
+
} else {
|
|
68009
|
+
query = query[fnc](key, Array.isArray(array) ? array : [array]);
|
|
68010
|
+
}
|
|
67951
68011
|
},
|
|
67952
68012
|
(key, array) => {
|
|
67953
|
-
|
|
68013
|
+
if (this.client === "oracledb" /* ORACLE */) {
|
|
68014
|
+
const keyStr = `(${key.map((k) => this.convertClobs(k)).join(",")})`;
|
|
68015
|
+
const binding = `(${array.map((a) => `(${new Array(a.length).fill("?").join(",")})`).join(",")})`;
|
|
68016
|
+
query = query.whereRaw(`${keyStr} IN ${binding}`, array.flat());
|
|
68017
|
+
} else {
|
|
68018
|
+
query = query[fnc](key, Array.isArray(array) ? array : [array]);
|
|
68019
|
+
}
|
|
67954
68020
|
}
|
|
67955
68021
|
);
|
|
67956
68022
|
}
|
|
@@ -67961,10 +68027,9 @@ var InternalBuilder = class {
|
|
|
67961
68027
|
query = query[fnc](key, "ilike", `${value}%`);
|
|
67962
68028
|
} else {
|
|
67963
68029
|
const rawFnc = `${fnc}Raw`;
|
|
67964
|
-
query = query[rawFnc](
|
|
67965
|
-
|
|
67966
|
-
|
|
67967
|
-
);
|
|
68030
|
+
query = query[rawFnc](`LOWER(${this.quotedIdentifier(key)}) LIKE ?`, [
|
|
68031
|
+
`${value.toLowerCase()}%`
|
|
68032
|
+
]);
|
|
67968
68033
|
}
|
|
67969
68034
|
});
|
|
67970
68035
|
}
|
|
@@ -67983,12 +68048,40 @@ var InternalBuilder = class {
|
|
|
67983
68048
|
value.high = "";
|
|
67984
68049
|
}
|
|
67985
68050
|
const lowValid = isValidFilter(value.low), highValid = isValidFilter(value.high);
|
|
68051
|
+
const schema = this.getFieldSchema(key);
|
|
68052
|
+
if (this.client === "oracledb" /* ORACLE */) {
|
|
68053
|
+
key = this.knex.raw(this.convertClobs(key));
|
|
68054
|
+
}
|
|
67986
68055
|
if (lowValid && highValid) {
|
|
67987
|
-
|
|
68056
|
+
if (schema?.type === "bigint" /* BIGINT */ && this.client === "sqlite3" /* SQL_LITE */) {
|
|
68057
|
+
query = query.whereRaw(
|
|
68058
|
+
`CAST(${key} AS INTEGER) BETWEEN CAST(? AS INTEGER) AND CAST(? AS INTEGER)`,
|
|
68059
|
+
[value.low, value.high]
|
|
68060
|
+
);
|
|
68061
|
+
} else {
|
|
68062
|
+
const fnc = allOr ? "orWhereBetween" : "whereBetween";
|
|
68063
|
+
query = query[fnc](key, [value.low, value.high]);
|
|
68064
|
+
}
|
|
67988
68065
|
} else if (lowValid) {
|
|
67989
|
-
|
|
68066
|
+
if (schema?.type === "bigint" /* BIGINT */ && this.client === "sqlite3" /* SQL_LITE */) {
|
|
68067
|
+
query = query.whereRaw(
|
|
68068
|
+
`CAST(${key} AS INTEGER) >= CAST(? AS INTEGER)`,
|
|
68069
|
+
[value.low]
|
|
68070
|
+
);
|
|
68071
|
+
} else {
|
|
68072
|
+
const fnc = allOr ? "orWhere" : "where";
|
|
68073
|
+
query = query[fnc](key, ">=", value.low);
|
|
68074
|
+
}
|
|
67990
68075
|
} else if (highValid) {
|
|
67991
|
-
|
|
68076
|
+
if (schema?.type === "bigint" /* BIGINT */ && this.client === "sqlite3" /* SQL_LITE */) {
|
|
68077
|
+
query = query.whereRaw(
|
|
68078
|
+
`CAST(${key} AS INTEGER) <= CAST(? AS INTEGER)`,
|
|
68079
|
+
[value.high]
|
|
68080
|
+
);
|
|
68081
|
+
} else {
|
|
68082
|
+
const fnc = allOr ? "orWhere" : "where";
|
|
68083
|
+
query = query[fnc](key, "<=", value.high);
|
|
68084
|
+
}
|
|
67992
68085
|
}
|
|
67993
68086
|
});
|
|
67994
68087
|
}
|
|
@@ -67997,20 +68090,18 @@ var InternalBuilder = class {
|
|
|
67997
68090
|
const fnc = allOr ? "orWhereRaw" : "whereRaw";
|
|
67998
68091
|
if (this.client === "mssql" /* MS_SQL */) {
|
|
67999
68092
|
query = query[fnc](
|
|
68000
|
-
`CASE WHEN ${quotedIdentifier(
|
|
68001
|
-
this.client,
|
|
68002
|
-
key
|
|
68003
|
-
)} = ? THEN 1 ELSE 0 END = 1`,
|
|
68093
|
+
`CASE WHEN ${this.quotedIdentifier(key)} = ? THEN 1 ELSE 0 END = 1`,
|
|
68004
68094
|
[value]
|
|
68005
68095
|
);
|
|
68006
68096
|
} else if (this.client === "oracledb" /* ORACLE */) {
|
|
68097
|
+
const identifier = this.convertClobs(key);
|
|
68007
68098
|
query = query[fnc](
|
|
68008
|
-
`
|
|
68099
|
+
`(${identifier} IS NOT NULL AND ${identifier} = ?)`,
|
|
68009
68100
|
[value]
|
|
68010
68101
|
);
|
|
68011
68102
|
} else {
|
|
68012
68103
|
query = query[fnc](
|
|
68013
|
-
`COALESCE(${quotedIdentifier(
|
|
68104
|
+
`COALESCE(${this.quotedIdentifier(key)} = ?, FALSE)`,
|
|
68014
68105
|
[value]
|
|
68015
68106
|
);
|
|
68016
68107
|
}
|
|
@@ -68021,20 +68112,18 @@ var InternalBuilder = class {
|
|
|
68021
68112
|
const fnc = allOr ? "orWhereRaw" : "whereRaw";
|
|
68022
68113
|
if (this.client === "mssql" /* MS_SQL */) {
|
|
68023
68114
|
query = query[fnc](
|
|
68024
|
-
`CASE WHEN ${quotedIdentifier(
|
|
68025
|
-
this.client,
|
|
68026
|
-
key
|
|
68027
|
-
)} = ? THEN 1 ELSE 0 END = 0`,
|
|
68115
|
+
`CASE WHEN ${this.quotedIdentifier(key)} = ? THEN 1 ELSE 0 END = 0`,
|
|
68028
68116
|
[value]
|
|
68029
68117
|
);
|
|
68030
68118
|
} else if (this.client === "oracledb" /* ORACLE */) {
|
|
68119
|
+
const identifier = this.convertClobs(key);
|
|
68031
68120
|
query = query[fnc](
|
|
68032
|
-
`
|
|
68121
|
+
`(${identifier} IS NOT NULL AND ${identifier} != ?) OR ${identifier} IS NULL`,
|
|
68033
68122
|
[value]
|
|
68034
68123
|
);
|
|
68035
68124
|
} else {
|
|
68036
68125
|
query = query[fnc](
|
|
68037
|
-
`COALESCE(${quotedIdentifier(
|
|
68126
|
+
`COALESCE(${this.quotedIdentifier(key)} != ?, TRUE)`,
|
|
68038
68127
|
[value]
|
|
68039
68128
|
);
|
|
68040
68129
|
}
|
|
@@ -68061,8 +68150,8 @@ var InternalBuilder = class {
|
|
|
68061
68150
|
if (filters.containsAny) {
|
|
68062
68151
|
contains(filters.containsAny, true);
|
|
68063
68152
|
}
|
|
68064
|
-
const tableRef =
|
|
68065
|
-
if (filters.documentType && !isExternalTable(table) && tableRef) {
|
|
68153
|
+
const tableRef = aliases?.[this.table._id] || this.table._id;
|
|
68154
|
+
if (filters.documentType && !isExternalTable(this.table) && tableRef) {
|
|
68066
68155
|
query.andWhereLike(
|
|
68067
68156
|
`${tableRef}._id`,
|
|
68068
68157
|
`${prefixed(filters.documentType)}%`
|
|
@@ -68070,34 +68159,39 @@ var InternalBuilder = class {
|
|
|
68070
68159
|
}
|
|
68071
68160
|
return query;
|
|
68072
68161
|
}
|
|
68073
|
-
addDistinctCount(query
|
|
68074
|
-
const
|
|
68075
|
-
const
|
|
68076
|
-
const
|
|
68077
|
-
const aliased = table.name && aliases?.[table.name] ? aliases[table.name] : table.name;
|
|
68162
|
+
addDistinctCount(query) {
|
|
68163
|
+
const primary = this.table.primary;
|
|
68164
|
+
const aliases = this.query.tableAliases;
|
|
68165
|
+
const aliased = this.table.name && aliases?.[this.table.name] ? aliases[this.table.name] : this.table.name;
|
|
68078
68166
|
if (!primary) {
|
|
68079
68167
|
throw new Error("SQL counting requires primary key to be supplied");
|
|
68080
68168
|
}
|
|
68081
68169
|
return query.countDistinct(`${aliased}.${primary[0]} as total`);
|
|
68082
68170
|
}
|
|
68083
|
-
addSorting(query
|
|
68084
|
-
let { sort: sort2 } =
|
|
68085
|
-
const
|
|
68086
|
-
const
|
|
68087
|
-
const
|
|
68088
|
-
const
|
|
68089
|
-
const aliased = tableName && aliases?.[tableName] ? aliases[tableName] : table?.name;
|
|
68171
|
+
addSorting(query) {
|
|
68172
|
+
let { sort: sort2 } = this.query;
|
|
68173
|
+
const primaryKey = this.table.primary;
|
|
68174
|
+
const tableName = getTableName(this.table);
|
|
68175
|
+
const aliases = this.query.tableAliases;
|
|
68176
|
+
const aliased = tableName && aliases?.[tableName] ? aliases[tableName] : this.table?.name;
|
|
68090
68177
|
if (!Array.isArray(primaryKey)) {
|
|
68091
68178
|
throw new Error("Sorting requires primary key to be specified for table");
|
|
68092
68179
|
}
|
|
68093
68180
|
if (sort2 && Object.keys(sort2 || {}).length > 0) {
|
|
68094
68181
|
for (let [key, value] of Object.entries(sort2)) {
|
|
68095
68182
|
const direction = value.direction === "ascending" /* ASCENDING */ ? "asc" : "desc";
|
|
68096
|
-
let nulls;
|
|
68097
|
-
if (this.client === "pg" /* POSTGRES */) {
|
|
68183
|
+
let nulls = void 0;
|
|
68184
|
+
if (this.client === "pg" /* POSTGRES */ || this.client === "oracledb" /* ORACLE */) {
|
|
68098
68185
|
nulls = value.direction === "ascending" /* ASCENDING */ ? "first" : "last";
|
|
68099
68186
|
}
|
|
68100
|
-
|
|
68187
|
+
let composite = `${aliased}.${key}`;
|
|
68188
|
+
if (this.client === "oracledb" /* ORACLE */) {
|
|
68189
|
+
query = query.orderByRaw(
|
|
68190
|
+
`${this.convertClobs(composite)} ${direction} nulls ${nulls}`
|
|
68191
|
+
);
|
|
68192
|
+
} else {
|
|
68193
|
+
query = query.orderBy(composite, direction, nulls);
|
|
68194
|
+
}
|
|
68101
68195
|
}
|
|
68102
68196
|
}
|
|
68103
68197
|
if (!sort2 || sort2[primaryKey[0]] === void 0) {
|
|
@@ -68172,23 +68266,41 @@ var InternalBuilder = class {
|
|
|
68172
68266
|
}
|
|
68173
68267
|
return query;
|
|
68174
68268
|
}
|
|
68175
|
-
|
|
68176
|
-
|
|
68177
|
-
|
|
68178
|
-
|
|
68179
|
-
|
|
68180
|
-
|
|
68181
|
-
|
|
68269
|
+
qualifiedKnex(opts) {
|
|
68270
|
+
let alias = this.query.tableAliases?.[this.query.endpoint.entityId];
|
|
68271
|
+
if (opts?.alias === false) {
|
|
68272
|
+
alias = void 0;
|
|
68273
|
+
} else if (typeof opts?.alias === "string") {
|
|
68274
|
+
alias = opts.alias;
|
|
68275
|
+
}
|
|
68276
|
+
return this.knex(
|
|
68277
|
+
this.tableNameWithSchema(this.query.endpoint.entityId, {
|
|
68278
|
+
alias,
|
|
68279
|
+
schema: this.query.endpoint.schema
|
|
68182
68280
|
})
|
|
68183
68281
|
);
|
|
68184
68282
|
}
|
|
68185
|
-
create(
|
|
68186
|
-
const {
|
|
68187
|
-
let query = this.
|
|
68188
|
-
const parsedBody = parseBody(body2);
|
|
68189
|
-
|
|
68190
|
-
|
|
68191
|
-
|
|
68283
|
+
create(opts) {
|
|
68284
|
+
const { body: body2 } = this.query;
|
|
68285
|
+
let query = this.qualifiedKnex({ alias: false });
|
|
68286
|
+
const parsedBody = this.parseBody(body2);
|
|
68287
|
+
if (this.client === "oracledb" /* ORACLE */) {
|
|
68288
|
+
for (const [column, schema] of Object.entries(
|
|
68289
|
+
this.query.meta.table.schema
|
|
68290
|
+
)) {
|
|
68291
|
+
if (schema.constraints?.presence === true || schema.type === "formula" /* FORMULA */ || schema.type === "auto" /* AUTO */ || schema.type === "link" /* LINK */) {
|
|
68292
|
+
continue;
|
|
68293
|
+
}
|
|
68294
|
+
const value = parsedBody[column];
|
|
68295
|
+
if (value == null) {
|
|
68296
|
+
parsedBody[column] = null;
|
|
68297
|
+
}
|
|
68298
|
+
}
|
|
68299
|
+
} else {
|
|
68300
|
+
for (let [key, value] of Object.entries(parsedBody)) {
|
|
68301
|
+
if (value == null) {
|
|
68302
|
+
delete parsedBody[key];
|
|
68303
|
+
}
|
|
68192
68304
|
}
|
|
68193
68305
|
}
|
|
68194
68306
|
if (opts.disableReturning) {
|
|
@@ -68197,40 +68309,40 @@ var InternalBuilder = class {
|
|
|
68197
68309
|
return query.insert(parsedBody).returning("*");
|
|
68198
68310
|
}
|
|
68199
68311
|
}
|
|
68200
|
-
bulkCreate(
|
|
68201
|
-
const {
|
|
68202
|
-
let query = this.
|
|
68312
|
+
bulkCreate() {
|
|
68313
|
+
const { body: body2 } = this.query;
|
|
68314
|
+
let query = this.qualifiedKnex({ alias: false });
|
|
68203
68315
|
if (!Array.isArray(body2)) {
|
|
68204
68316
|
return query;
|
|
68205
68317
|
}
|
|
68206
|
-
const parsedBody = body2.map((row) => parseBody(row));
|
|
68318
|
+
const parsedBody = body2.map((row) => this.parseBody(row));
|
|
68207
68319
|
return query.insert(parsedBody);
|
|
68208
68320
|
}
|
|
68209
|
-
bulkUpsert(
|
|
68210
|
-
const {
|
|
68211
|
-
let query = this.
|
|
68321
|
+
bulkUpsert() {
|
|
68322
|
+
const { body: body2 } = this.query;
|
|
68323
|
+
let query = this.qualifiedKnex({ alias: false });
|
|
68212
68324
|
if (!Array.isArray(body2)) {
|
|
68213
68325
|
return query;
|
|
68214
68326
|
}
|
|
68215
|
-
const parsedBody = body2.map((row) => parseBody(row));
|
|
68327
|
+
const parsedBody = body2.map((row) => this.parseBody(row));
|
|
68216
68328
|
if (this.client === "pg" /* POSTGRES */ || this.client === "sqlite3" /* SQL_LITE */ || this.client === "mysql2" /* MY_SQL */) {
|
|
68217
|
-
const primary =
|
|
68329
|
+
const primary = this.table.primary;
|
|
68218
68330
|
if (!primary) {
|
|
68219
68331
|
throw new Error("Primary key is required for upsert");
|
|
68220
68332
|
}
|
|
68221
68333
|
const ret = query.insert(parsedBody).onConflict(primary).merge();
|
|
68222
68334
|
return ret;
|
|
68223
|
-
} else if (this.client === "mssql" /* MS_SQL */) {
|
|
68335
|
+
} else if (this.client === "mssql" /* MS_SQL */ || this.client === "oracledb" /* ORACLE */) {
|
|
68224
68336
|
return query.insert(parsedBody);
|
|
68225
68337
|
}
|
|
68226
68338
|
return query.upsert(parsedBody);
|
|
68227
68339
|
}
|
|
68228
|
-
read(
|
|
68229
|
-
let { endpoint, filters, paginate, relationships, tableAliases } =
|
|
68340
|
+
read(opts = {}) {
|
|
68341
|
+
let { endpoint, filters, paginate, relationships, tableAliases } = this.query;
|
|
68230
68342
|
const { limits } = opts;
|
|
68231
68343
|
const counting = endpoint.operation === "COUNT" /* COUNT */;
|
|
68232
68344
|
const tableName = endpoint.entityId;
|
|
68233
|
-
let query = this.
|
|
68345
|
+
let query = this.qualifiedKnex();
|
|
68234
68346
|
let foundOffset = null;
|
|
68235
68347
|
let foundLimit = limits?.query || limits?.base;
|
|
68236
68348
|
if (paginate && paginate.page && paginate.limit) {
|
|
@@ -68251,23 +68363,20 @@ var InternalBuilder = class {
|
|
|
68251
68363
|
if (foundOffset != null) {
|
|
68252
68364
|
query = query.offset(foundOffset);
|
|
68253
68365
|
}
|
|
68254
|
-
query = this.addSorting(query
|
|
68366
|
+
query = this.addSorting(query);
|
|
68255
68367
|
}
|
|
68256
|
-
query = this.addFilters(query, filters
|
|
68257
|
-
columnPrefix: json.meta.columnPrefix,
|
|
68258
|
-
aliases: tableAliases
|
|
68259
|
-
});
|
|
68368
|
+
query = this.addFilters(query, filters);
|
|
68260
68369
|
const alias = tableAliases?.[tableName] || tableName;
|
|
68261
|
-
let preQuery =
|
|
68370
|
+
let preQuery = this.knex({
|
|
68262
68371
|
// the typescript definition for the knex constructor doesn't support this
|
|
68263
68372
|
// syntax, but it is the only way to alias a pre-query result as part of
|
|
68264
68373
|
// a query - there is an alias dictionary type, but it assumes it can only
|
|
68265
68374
|
// be a table name, not a pre-query
|
|
68266
68375
|
[alias]: query
|
|
68267
68376
|
});
|
|
68268
|
-
preQuery = !counting ? preQuery.select(generateSelectStatement(
|
|
68377
|
+
preQuery = !counting ? preQuery.select(this.generateSelectStatement()) : this.addDistinctCount(preQuery);
|
|
68269
68378
|
if (this.client !== "mssql" /* MS_SQL */ && !counting) {
|
|
68270
|
-
preQuery = this.addSorting(preQuery
|
|
68379
|
+
preQuery = this.addSorting(preQuery);
|
|
68271
68380
|
}
|
|
68272
68381
|
query = this.addRelationships(
|
|
68273
68382
|
preQuery,
|
|
@@ -68279,37 +68388,27 @@ var InternalBuilder = class {
|
|
|
68279
68388
|
if (limits?.base) {
|
|
68280
68389
|
query = query.limit(limits.base);
|
|
68281
68390
|
}
|
|
68282
|
-
return this.addFilters(query, filters,
|
|
68283
|
-
columnPrefix: json.meta.columnPrefix,
|
|
68284
|
-
relationship: true,
|
|
68285
|
-
aliases: tableAliases
|
|
68286
|
-
});
|
|
68391
|
+
return this.addFilters(query, filters, { relationship: true });
|
|
68287
68392
|
}
|
|
68288
|
-
update(
|
|
68289
|
-
const {
|
|
68290
|
-
let query = this.
|
|
68291
|
-
const parsedBody = parseBody(body2);
|
|
68292
|
-
query = this.addFilters(query, filters
|
|
68293
|
-
columnPrefix: json.meta.columnPrefix,
|
|
68294
|
-
aliases: tableAliases
|
|
68295
|
-
});
|
|
68393
|
+
update(opts) {
|
|
68394
|
+
const { body: body2, filters } = this.query;
|
|
68395
|
+
let query = this.qualifiedKnex();
|
|
68396
|
+
const parsedBody = this.parseBody(body2);
|
|
68397
|
+
query = this.addFilters(query, filters);
|
|
68296
68398
|
if (opts.disableReturning) {
|
|
68297
68399
|
return query.update(parsedBody);
|
|
68298
68400
|
} else {
|
|
68299
68401
|
return query.update(parsedBody).returning("*");
|
|
68300
68402
|
}
|
|
68301
68403
|
}
|
|
68302
|
-
delete(
|
|
68303
|
-
const {
|
|
68304
|
-
let query = this.
|
|
68305
|
-
query = this.addFilters(query, filters
|
|
68306
|
-
columnPrefix: json.meta.columnPrefix,
|
|
68307
|
-
aliases: tableAliases
|
|
68308
|
-
});
|
|
68404
|
+
delete(opts) {
|
|
68405
|
+
const { filters } = this.query;
|
|
68406
|
+
let query = this.qualifiedKnex();
|
|
68407
|
+
query = this.addFilters(query, filters);
|
|
68309
68408
|
if (opts.disableReturning) {
|
|
68310
68409
|
return query.delete();
|
|
68311
68410
|
} else {
|
|
68312
|
-
return query.delete().returning(generateSelectStatement(
|
|
68411
|
+
return query.delete().returning(this.generateSelectStatement());
|
|
68313
68412
|
}
|
|
68314
68413
|
}
|
|
68315
68414
|
};
|
|
@@ -68342,18 +68441,18 @@ var SqlQueryBuilder = class extends sqlTable_default {
|
|
|
68342
68441
|
const config = {
|
|
68343
68442
|
client: sqlClient
|
|
68344
68443
|
};
|
|
68345
|
-
if (sqlClient === "sqlite3" /* SQL_LITE */) {
|
|
68444
|
+
if (sqlClient === "sqlite3" /* SQL_LITE */ || sqlClient === "oracledb" /* ORACLE */) {
|
|
68346
68445
|
config.useNullAsDefault = true;
|
|
68347
68446
|
}
|
|
68348
68447
|
const client = (0, import_knex2.knex)(config);
|
|
68349
68448
|
let query;
|
|
68350
|
-
const builder = new InternalBuilder(sqlClient);
|
|
68449
|
+
const builder = new InternalBuilder(sqlClient, client, json);
|
|
68351
68450
|
switch (this._operation(json)) {
|
|
68352
68451
|
case "CREATE" /* CREATE */:
|
|
68353
|
-
query = builder.create(
|
|
68452
|
+
query = builder.create(opts);
|
|
68354
68453
|
break;
|
|
68355
68454
|
case "READ" /* READ */:
|
|
68356
|
-
query = builder.read(
|
|
68455
|
+
query = builder.read({
|
|
68357
68456
|
limits: {
|
|
68358
68457
|
query: this.limit,
|
|
68359
68458
|
base: getBaseLimit()
|
|
@@ -68361,19 +68460,19 @@ var SqlQueryBuilder = class extends sqlTable_default {
|
|
|
68361
68460
|
});
|
|
68362
68461
|
break;
|
|
68363
68462
|
case "COUNT" /* COUNT */:
|
|
68364
|
-
query = builder.read(
|
|
68463
|
+
query = builder.read();
|
|
68365
68464
|
break;
|
|
68366
68465
|
case "UPDATE" /* UPDATE */:
|
|
68367
|
-
query = builder.update(
|
|
68466
|
+
query = builder.update(opts);
|
|
68368
68467
|
break;
|
|
68369
68468
|
case "DELETE" /* DELETE */:
|
|
68370
|
-
query = builder.delete(
|
|
68469
|
+
query = builder.delete(opts);
|
|
68371
68470
|
break;
|
|
68372
68471
|
case "BULK_CREATE" /* BULK_CREATE */:
|
|
68373
|
-
query = builder.bulkCreate(
|
|
68472
|
+
query = builder.bulkCreate();
|
|
68374
68473
|
break;
|
|
68375
68474
|
case "BULK_UPSERT" /* BULK_UPSERT */:
|
|
68376
|
-
query = builder.bulkUpsert(
|
|
68475
|
+
query = builder.bulkUpsert();
|
|
68377
68476
|
break;
|
|
68378
68477
|
case "CREATE_TABLE" /* CREATE_TABLE */:
|
|
68379
68478
|
case "UPDATE_TABLE" /* UPDATE_TABLE */:
|
|
@@ -68566,7 +68665,6 @@ var init9 = (opts = {}) => {
|
|
|
68566
68665
|
env,
|
|
68567
68666
|
errors,
|
|
68568
68667
|
events,
|
|
68569
|
-
featureFlags,
|
|
68570
68668
|
features,
|
|
68571
68669
|
getPublicError,
|
|
68572
68670
|
init,
|