@rebasepro/common 0.2.5 → 0.4.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/data/query_builder.d.ts +6 -2
- package/dist/index.es.js +62 -42
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +62 -42
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/collections/default-collections.ts +5 -0
- package/src/data/buildRebaseData.ts +22 -8
- package/src/data/query_builder.ts +37 -27
package/dist/index.umd.js
CHANGED
|
@@ -1973,6 +1973,13 @@
|
|
|
1973
1973
|
group: "Settings",
|
|
1974
1974
|
openEntityMode: "dialog",
|
|
1975
1975
|
disableDefaultActions: ["copy"],
|
|
1976
|
+
securityRules: [{
|
|
1977
|
+
operation: "select",
|
|
1978
|
+
roles: ["admin"]
|
|
1979
|
+
}, {
|
|
1980
|
+
operations: ["insert", "update", "delete"],
|
|
1981
|
+
roles: ["admin"]
|
|
1982
|
+
}],
|
|
1976
1983
|
sort: ["createdAt", "desc"],
|
|
1977
1984
|
properties: {
|
|
1978
1985
|
id: {
|
|
@@ -2079,6 +2086,7 @@
|
|
|
2079
2086
|
name: "Created At",
|
|
2080
2087
|
type: "date",
|
|
2081
2088
|
columnName: "created_at",
|
|
2089
|
+
autoValue: "on_create",
|
|
2082
2090
|
ui: {
|
|
2083
2091
|
readOnly: true
|
|
2084
2092
|
}
|
|
@@ -2099,29 +2107,24 @@
|
|
|
2099
2107
|
listProperties: ["displayName", "email", "roles", "createdAt"],
|
|
2100
2108
|
propertiesOrder: ["id", "email", "displayName", "roles", "createdAt"]
|
|
2101
2109
|
};
|
|
2102
|
-
function
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
case "not-in":
|
|
2121
|
-
return "nin";
|
|
2122
|
-
default:
|
|
2123
|
-
return op;
|
|
2124
|
-
}
|
|
2110
|
+
function or(...conditions) {
|
|
2111
|
+
return {
|
|
2112
|
+
type: "or",
|
|
2113
|
+
conditions
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
function and(...conditions) {
|
|
2117
|
+
return {
|
|
2118
|
+
type: "and",
|
|
2119
|
+
conditions
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2122
|
+
function cond(column, operator, value) {
|
|
2123
|
+
return {
|
|
2124
|
+
column,
|
|
2125
|
+
operator,
|
|
2126
|
+
value
|
|
2127
|
+
};
|
|
2125
2128
|
}
|
|
2126
2129
|
class QueryBuilder {
|
|
2127
2130
|
constructor(collection) {
|
|
@@ -2130,23 +2133,30 @@
|
|
|
2130
2133
|
params = {
|
|
2131
2134
|
where: {}
|
|
2132
2135
|
};
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
where(column, operator, value) {
|
|
2136
|
+
where(columnOrCondition, operator, value) {
|
|
2137
|
+
if (typeof columnOrCondition === "object" && columnOrCondition !== null && "type" in columnOrCondition) {
|
|
2138
|
+
this.params.logical = columnOrCondition;
|
|
2139
|
+
return this;
|
|
2140
|
+
}
|
|
2139
2141
|
if (!this.params.where) {
|
|
2140
2142
|
this.params.where = {};
|
|
2141
2143
|
}
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2144
|
+
const column = columnOrCondition;
|
|
2145
|
+
const condition = [operator, value];
|
|
2146
|
+
const existing = this.params.where[column];
|
|
2147
|
+
if (existing === void 0) {
|
|
2148
|
+
this.params.where[column] = condition;
|
|
2149
|
+
} else if (Array.isArray(existing) && existing.length > 0 && Array.isArray(existing[0])) {
|
|
2150
|
+
this.params.where[column].push(condition);
|
|
2151
|
+
} else {
|
|
2152
|
+
let firstCondition;
|
|
2153
|
+
if (Array.isArray(existing) && existing.length === 2 && typeof existing[0] === "string") {
|
|
2154
|
+
firstCondition = existing;
|
|
2155
|
+
} else {
|
|
2156
|
+
firstCondition = ["==", existing];
|
|
2157
|
+
}
|
|
2158
|
+
this.params.where[column] = [firstCondition, condition];
|
|
2148
2159
|
}
|
|
2149
|
-
this.params.where[column] = mappedOp === "eq" ? String(formattedValue) : `${mappedOp}.${formattedValue}`;
|
|
2150
2160
|
return this;
|
|
2151
2161
|
}
|
|
2152
2162
|
/**
|
|
@@ -2248,10 +2258,13 @@
|
|
|
2248
2258
|
filter[field] = ["==", rawValue];
|
|
2249
2259
|
continue;
|
|
2250
2260
|
}
|
|
2251
|
-
if (Array.isArray(rawValue)
|
|
2252
|
-
const [
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2261
|
+
if (Array.isArray(rawValue)) {
|
|
2262
|
+
const conditions = Array.isArray(rawValue[0]) ? rawValue : [rawValue];
|
|
2263
|
+
const mappedConditions = conditions.map(([rawOp, val]) => {
|
|
2264
|
+
const mappedOp = operatorMap[rawOp] ?? "==";
|
|
2265
|
+
return [mappedOp, val];
|
|
2266
|
+
});
|
|
2267
|
+
filter[field] = Array.isArray(rawValue[0]) ? mappedConditions : mappedConditions[0];
|
|
2255
2268
|
continue;
|
|
2256
2269
|
}
|
|
2257
2270
|
if (typeof rawValue === "string") {
|
|
@@ -2389,8 +2402,12 @@
|
|
|
2389
2402
|
});
|
|
2390
2403
|
} : void 0,
|
|
2391
2404
|
// Fluent Query Builder
|
|
2392
|
-
where(
|
|
2393
|
-
|
|
2405
|
+
where(columnOrCondition, operator, value) {
|
|
2406
|
+
const builder = new QueryBuilder(accessor);
|
|
2407
|
+
if (typeof columnOrCondition === "object") {
|
|
2408
|
+
return builder.where(columnOrCondition);
|
|
2409
|
+
}
|
|
2410
|
+
return builder.where(columnOrCondition, operator, value);
|
|
2394
2411
|
},
|
|
2395
2412
|
orderBy(column, ascending) {
|
|
2396
2413
|
return new QueryBuilder(accessor).orderBy(column, ascending);
|
|
@@ -2439,6 +2456,7 @@
|
|
|
2439
2456
|
exports2.DEFAULT_ONE_OF_VALUE = DEFAULT_ONE_OF_VALUE;
|
|
2440
2457
|
exports2.QueryBuilder = QueryBuilder;
|
|
2441
2458
|
exports2.addInitialSlash = addInitialSlash;
|
|
2459
|
+
exports2.and = and;
|
|
2442
2460
|
exports2.applyPropertyConditions = applyPropertyConditions;
|
|
2443
2461
|
exports2.buildAdditionalFieldDelegate = buildAdditionalFieldDelegate;
|
|
2444
2462
|
exports2.buildCollection = buildCollection;
|
|
@@ -2456,6 +2474,7 @@
|
|
|
2456
2474
|
exports2.canEditEntity = canEditEntity;
|
|
2457
2475
|
exports2.canReadCollection = canReadCollection;
|
|
2458
2476
|
exports2.checkOperation = checkOperation;
|
|
2477
|
+
exports2.cond = cond;
|
|
2459
2478
|
exports2.createRelationRef = createRelationRef;
|
|
2460
2479
|
exports2.createRelationRefWithData = createRelationRefWithData;
|
|
2461
2480
|
exports2.defaultUsersCollection = defaultUsersCollection;
|
|
@@ -2487,6 +2506,7 @@
|
|
|
2487
2506
|
exports2.isPropertyBuilder = isPropertyBuilder;
|
|
2488
2507
|
exports2.isReadOnly = isReadOnly;
|
|
2489
2508
|
exports2.normalizeToEntityRelation = normalizeToEntityRelation;
|
|
2509
|
+
exports2.or = or;
|
|
2490
2510
|
exports2.registerConditionOperations = registerConditionOperations;
|
|
2491
2511
|
exports2.removeInitialAndTrailingSlashes = removeInitialAndTrailingSlashes;
|
|
2492
2512
|
exports2.removeInitialSlash = removeInitialSlash;
|