unframer 2.7.7 → 2.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/babel-plugin-imports.d.ts +21 -0
- package/dist/babel-plugin-imports.d.ts.map +1 -0
- package/dist/babel-plugin-imports.js +375 -0
- package/dist/babel-plugin-imports.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -11
- package/dist/cli.js.map +1 -1
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +4 -3
- package/dist/css.js.map +1 -1
- package/dist/exporter.d.ts.map +1 -1
- package/dist/exporter.js +57 -30
- package/dist/exporter.js.map +1 -1
- package/dist/framer.d.ts.map +1 -1
- package/dist/framer.js +56 -1850
- package/dist/framer.js.map +1 -1
- package/dist/renamer.d.ts +12 -0
- package/dist/renamer.d.ts.map +1 -0
- package/dist/renamer.js +169 -0
- package/dist/renamer.js.map +1 -0
- package/esm/babel-plugin-imports.d.ts +21 -0
- package/esm/babel-plugin-imports.d.ts.map +1 -0
- package/esm/babel-plugin-imports.js +344 -0
- package/esm/babel-plugin-imports.js.map +1 -0
- package/esm/cli.d.ts.map +1 -1
- package/esm/cli.js +2 -11
- package/esm/cli.js.map +1 -1
- package/esm/css.d.ts.map +1 -1
- package/esm/css.js +3 -2
- package/esm/css.js.map +1 -1
- package/esm/exporter.d.ts.map +1 -1
- package/esm/exporter.js +55 -28
- package/esm/exporter.js.map +1 -1
- package/esm/framer.d.ts.map +1 -1
- package/esm/framer.js +57 -1850
- package/esm/framer.js.map +1 -1
- package/esm/renamer.d.ts +12 -0
- package/esm/renamer.d.ts.map +1 -0
- package/esm/renamer.js +140 -0
- package/esm/renamer.js.map +1 -0
- package/package.json +5 -4
- package/src/babel-plugin-imports.ts +441 -0
- package/src/cli.tsx +2 -12
- package/src/css.ts +3 -2
- package/src/exporter.ts +64 -29
- package/src/framer.js +61 -1896
- package/src/renamer.ts +184 -0
package/src/framer.js
CHANGED
|
@@ -5481,9 +5481,9 @@ function velocityPerSecond(velocity, frameDuration,) {
|
|
|
5481
5481
|
return frameDuration ? velocity * (1e3 / frameDuration) : 0;
|
|
5482
5482
|
}
|
|
5483
5483
|
var velocitySampleDuration = 5;
|
|
5484
|
-
function calcGeneratorVelocity(
|
|
5484
|
+
function calcGeneratorVelocity(resolveValue, t, current,) {
|
|
5485
5485
|
const prevT = Math.max(t - velocitySampleDuration, 0,);
|
|
5486
|
-
return velocityPerSecond(current -
|
|
5486
|
+
return velocityPerSecond(current - resolveValue(prevT,), t - prevT,);
|
|
5487
5487
|
}
|
|
5488
5488
|
var durationKeys = ['duration', 'bounce',];
|
|
5489
5489
|
var physicsKeys = ['stiffness', 'damping', 'mass',];
|
|
@@ -15349,7 +15349,7 @@ function steps(numSteps, direction = 'end',) {
|
|
|
15349
15349
|
};
|
|
15350
15350
|
}
|
|
15351
15351
|
|
|
15352
|
-
// https :https://app.framerstatic.com/framer.
|
|
15352
|
+
// https :https://app.framerstatic.com/framer.ZONHQAMM.mjs
|
|
15353
15353
|
init_chunk_QLPHEVXG();
|
|
15354
15354
|
import React4 from 'react';
|
|
15355
15355
|
import { startTransition as startTransition2, } from 'react';
|
|
@@ -16807,39 +16807,6 @@ var require_hoist_non_react_statics_cjs = __commonJS({
|
|
|
16807
16807
|
module.exports = hoistNonReactStatics;
|
|
16808
16808
|
},
|
|
16809
16809
|
},);
|
|
16810
|
-
var require_archy = __commonJS({
|
|
16811
|
-
'../../../node_modules/archy/index.js'(exports, module,) {
|
|
16812
|
-
module.exports = function archy2(obj, prefix2, opts,) {
|
|
16813
|
-
if (prefix2 === void 0) prefix2 = '';
|
|
16814
|
-
if (!opts) opts = {};
|
|
16815
|
-
var chr = function (s,) {
|
|
16816
|
-
var chars = {
|
|
16817
|
-
'\u2502': '|',
|
|
16818
|
-
'\u2514': '`',
|
|
16819
|
-
'\u251C': '+',
|
|
16820
|
-
'\u2500': '-',
|
|
16821
|
-
'\u252C': '-',
|
|
16822
|
-
};
|
|
16823
|
-
return opts.unicode === false ? chars[s] : s;
|
|
16824
|
-
};
|
|
16825
|
-
if (typeof obj === 'string') {
|
|
16826
|
-
obj = {
|
|
16827
|
-
label: obj,
|
|
16828
|
-
};
|
|
16829
|
-
}
|
|
16830
|
-
var nodes = obj.nodes || [];
|
|
16831
|
-
var lines = (obj.label || '').split('\n',);
|
|
16832
|
-
var splitter = '\n' + prefix2 + (nodes.length ? chr('\u2502',) : ' ') + ' ';
|
|
16833
|
-
return prefix2 + lines.join(splitter,) + '\n' + nodes.map(function (node, ix,) {
|
|
16834
|
-
var last = ix === nodes.length - 1;
|
|
16835
|
-
var more = node.nodes && node.nodes.length;
|
|
16836
|
-
var prefix_ = prefix2 + (last ? ' ' : chr('\u2502',)) + ' ';
|
|
16837
|
-
return prefix2 + (last ? chr('\u2514',) : chr('\u251C',)) + chr('\u2500',) + (more ? chr('\u252C',) : chr('\u2500',)) + ' ' +
|
|
16838
|
-
archy2(node, prefix_, opts,).slice(prefix2.length + 2,);
|
|
16839
|
-
},).join('',);
|
|
16840
|
-
};
|
|
16841
|
-
},
|
|
16842
|
-
},);
|
|
16843
16810
|
var require_fontfaceobserver_standalone = __commonJS({
|
|
16844
16811
|
'../../../node_modules/fontfaceobserver/fontfaceobserver.standalone.js'(exports, module,) {
|
|
16845
16812
|
(function () {
|
|
@@ -18247,6 +18214,7 @@ function useMarkRouterEffects() {
|
|
|
18247
18214
|
var hydrationInsertionEffectStartHasRun = false;
|
|
18248
18215
|
var hydrationLayoutEffectStartHasRun = false;
|
|
18249
18216
|
var hydrationEffectStartHasRun = false;
|
|
18217
|
+
var wasInBackground = false;
|
|
18250
18218
|
function useMarkSuspenseEffectsStart() {
|
|
18251
18219
|
const hydrationMarkPrefix = 'framer-hydration-';
|
|
18252
18220
|
const hydrationLayoutEffectsEnd = `${hydrationMarkPrefix}layout-effects-end`;
|
|
@@ -18264,6 +18232,10 @@ function useMarkSuspenseEffectsStart() {
|
|
|
18264
18232
|
if (hydrationLayoutEffectStartHasRun || !shouldMark) return;
|
|
18265
18233
|
hydrationLayoutEffectStartHasRun = true;
|
|
18266
18234
|
performance.mark(`${hydrationMarkPrefix}layout-effects-start`,);
|
|
18235
|
+
if (document.visibilityState !== 'visible') {
|
|
18236
|
+
wasInBackground = true;
|
|
18237
|
+
return;
|
|
18238
|
+
}
|
|
18267
18239
|
requestAnimationFrame(() => {
|
|
18268
18240
|
var _a, _b, _c;
|
|
18269
18241
|
performance.mark(hydrationBrowserRenderStart,);
|
|
@@ -18298,7 +18270,6 @@ function useMarkSuspenseEffectsStart() {
|
|
|
18298
18270
|
var hydrationInsertionEffectHasRun = false;
|
|
18299
18271
|
var hydrationLayoutEffectHasRun = false;
|
|
18300
18272
|
var hydrationEffectHasRun = false;
|
|
18301
|
-
var hydrationPaintEffectHasRun = false;
|
|
18302
18273
|
function useMarkSuspenseEffectEnd() {
|
|
18303
18274
|
const hydrationMarkPrefix = 'framer-hydration-';
|
|
18304
18275
|
const hydrationLayoutEffectsEnd = `${hydrationMarkPrefix}layout-effects-end`;
|
|
@@ -18319,9 +18290,15 @@ function useMarkSuspenseEffectEnd() {
|
|
|
18319
18290
|
hydrationLayoutEffectHasRun = true;
|
|
18320
18291
|
performance.mark(hydrationLayoutEffectsEnd,);
|
|
18321
18292
|
measureSafe(`${hydrationMarkPrefix}layout-effects`, `${hydrationMarkPrefix}layout-effects-start`, hydrationLayoutEffectsEnd,);
|
|
18293
|
+
if (wasInBackground || document.visibilityState !== 'visible') return;
|
|
18322
18294
|
requestAnimationFrame(() => {
|
|
18323
18295
|
performance.mark(hydrationAnimationFrameEnd,);
|
|
18324
18296
|
measureSafe(`${hydrationMarkPrefix}raf`, hydrationBrowserRenderStart, hydrationAnimationFrameEnd,);
|
|
18297
|
+
void yieldBefore(() => {
|
|
18298
|
+
performance.mark(hydrationFP,);
|
|
18299
|
+
measureSafe(`${hydrationMarkPrefix}time-to-first-paint`, hydrationStart, hydrationFP,);
|
|
18300
|
+
measureSafe(`${hydrationMarkPrefix}browser-render`, hydrationAnimationFrameEnd, hydrationFP,);
|
|
18301
|
+
},);
|
|
18325
18302
|
},);
|
|
18326
18303
|
}, [],);
|
|
18327
18304
|
useEffect(() => {
|
|
@@ -18339,22 +18316,6 @@ function useMarkSuspenseEffectEnd() {
|
|
|
18339
18316
|
hydrationEffectsEnd,
|
|
18340
18317
|
);
|
|
18341
18318
|
}, [],);
|
|
18342
|
-
useAfterPaintEffect(
|
|
18343
|
-
() => {
|
|
18344
|
-
if (hydrationPaintEffectHasRun || !shouldMark) return;
|
|
18345
|
-
hydrationPaintEffectHasRun = true;
|
|
18346
|
-
performance.mark(hydrationFP,);
|
|
18347
|
-
measureSafe(`${hydrationMarkPrefix}time-to-first-paint`, hydrationStart, hydrationFP,);
|
|
18348
|
-
queueMicrotask(() => {
|
|
18349
|
-
measureSafe(`${hydrationMarkPrefix}browser-render`, hydrationAnimationFrameEnd, hydrationFP,);
|
|
18350
|
-
},);
|
|
18351
|
-
},
|
|
18352
|
-
[],
|
|
18353
|
-
// user-blocking ensures we get the correct timings here. Other priorites might delay this effect a little bit.
|
|
18354
|
-
{
|
|
18355
|
-
priority: 'user-blocking',
|
|
18356
|
-
},
|
|
18357
|
-
);
|
|
18358
18319
|
return null;
|
|
18359
18320
|
}
|
|
18360
18321
|
function MarkSuspenseEffectsStart() {
|
|
@@ -23651,7 +23612,8 @@ function getConstraintValue(constraint, value, parentSize, viewport,) {
|
|
|
23651
23612
|
break;
|
|
23652
23613
|
}
|
|
23653
23614
|
}
|
|
23654
|
-
if (value.endsWith('vh',)
|
|
23615
|
+
if (value.endsWith('vh',)) {
|
|
23616
|
+
if (!viewport) return constraintValueForUncalculatedViewport(constraint,);
|
|
23655
23617
|
switch (constraint) {
|
|
23656
23618
|
case 'maxWidth':
|
|
23657
23619
|
case 'minWidth':
|
|
@@ -23667,6 +23629,18 @@ function getConstraintValue(constraint, value, parentSize, viewport,) {
|
|
|
23667
23629
|
}
|
|
23668
23630
|
return value;
|
|
23669
23631
|
}
|
|
23632
|
+
function constraintValueForUncalculatedViewport(constraint,) {
|
|
23633
|
+
switch (constraint) {
|
|
23634
|
+
case 'minWidth':
|
|
23635
|
+
case 'minHeight':
|
|
23636
|
+
return Number.NEGATIVE_INFINITY;
|
|
23637
|
+
case 'maxWidth':
|
|
23638
|
+
case 'maxHeight':
|
|
23639
|
+
return Number.POSITIVE_INFINITY;
|
|
23640
|
+
default:
|
|
23641
|
+
assertNever(constraint, 'unknown constraint key',);
|
|
23642
|
+
}
|
|
23643
|
+
}
|
|
23670
23644
|
function constrainHeight(height, values, parentSize, viewport,) {
|
|
23671
23645
|
if (values.minHeight) {
|
|
23672
23646
|
height = Math.max(getConstraintValue('minHeight', values.minHeight, parentSize, viewport,), height,);
|
|
@@ -23708,18 +23682,6 @@ function pinnedOffset(start, end,) {
|
|
|
23708
23682
|
if (!isFiniteNumber(start,) || !isFiniteNumber(end,)) return null;
|
|
23709
23683
|
return start + end;
|
|
23710
23684
|
}
|
|
23711
|
-
function getMergedConstraintsProps(props, constraints,) {
|
|
23712
|
-
const result = {};
|
|
23713
|
-
if (props.constraints) {
|
|
23714
|
-
result.constraints = {
|
|
23715
|
-
...props.constraints,
|
|
23716
|
-
...constraints,
|
|
23717
|
-
};
|
|
23718
|
-
} else {
|
|
23719
|
-
Object.assign(result, constraints,);
|
|
23720
|
-
}
|
|
23721
|
-
return result;
|
|
23722
|
-
}
|
|
23723
23685
|
function containsInvalidStringValues(props,) {
|
|
23724
23686
|
if (typeof props.right === 'string') return true;
|
|
23725
23687
|
if (typeof props.bottom === 'string') return true;
|
|
@@ -24101,8 +24063,8 @@ var richTextLinkHoverStylesRule = `
|
|
|
24101
24063
|
}
|
|
24102
24064
|
`;
|
|
24103
24065
|
var richTextLinkCurrentStylesRule = `
|
|
24104
|
-
a[data-framer-page-link-current],
|
|
24105
|
-
a[data-framer-page-link-current] span:not([data-text-fill]):not([data-nested-link]) {
|
|
24066
|
+
[data-framer-component-type="DeprecatedRichText"] a[data-framer-page-link-current],
|
|
24067
|
+
[data-framer-component-type="DeprecatedRichText"] a[data-framer-page-link-current] span:not([data-text-fill]):not([data-nested-link]) {
|
|
24106
24068
|
font-family: var(--framer-link-current-font-family, var(--framer-link-font-family, var(--framer-font-family, Inter, Inter Placeholder, sans-serif)));
|
|
24107
24069
|
font-style: var(--framer-link-current-font-style, var(--framer-link-font-style, var(--framer-font-style, normal)));
|
|
24108
24070
|
font-weight: var(--framer-link-current-font-weight, var(--framer-link-font-weight, var(--framer-font-weight, 400)));
|
|
@@ -24113,8 +24075,8 @@ a[data-framer-page-link-current] span:not([data-text-fill]):not([data-nested-lin
|
|
|
24113
24075
|
}
|
|
24114
24076
|
`;
|
|
24115
24077
|
var richTextLinkCurrentHoverStylesRule = `
|
|
24116
|
-
a[data-framer-page-link-current]:hover,
|
|
24117
|
-
a[data-framer-page-link-current]:hover span:not([data-text-fill]):not([data-nested-link]) {
|
|
24078
|
+
[data-framer-component-type="DeprecatedRichText"] a[data-framer-page-link-current]:hover,
|
|
24079
|
+
[data-framer-component-type="DeprecatedRichText"] a[data-framer-page-link-current]:hover span:not([data-text-fill]):not([data-nested-link]) {
|
|
24118
24080
|
font-family: var(--framer-link-hover-font-family, var(--framer-link-current-font-family, var(--framer-link-font-family, var(--framer-font-family, Inter, Inter Placeholder, sans-serif))));
|
|
24119
24081
|
font-style: var(--framer-link-hover-font-style, var(--framer-link-current-font-style, var(--framer-link-font-style, var(--framer-font-style, normal))));
|
|
24120
24082
|
font-weight: var(--framer-link-hover-font-weight, var(--framer-link-current-font-weight, var(--framer-link-font-weight, var(--framer-font-weight, 400))));
|
|
@@ -37543,20 +37505,17 @@ var NestedLinksCollector = class {
|
|
|
37543
37505
|
this.links.clear();
|
|
37544
37506
|
}
|
|
37545
37507
|
getLinks() {
|
|
37546
|
-
return
|
|
37508
|
+
return this.links;
|
|
37547
37509
|
}
|
|
37548
|
-
addLink(
|
|
37549
|
-
if (typeof window !== 'undefined' && true || !
|
|
37510
|
+
addLink(parentLinkNodeId, linkNodeId,) {
|
|
37511
|
+
if (typeof window !== 'undefined' && true || !parentLinkNodeId || !linkNodeId) {
|
|
37550
37512
|
return;
|
|
37551
37513
|
}
|
|
37552
|
-
if (!this.links.has(
|
|
37553
|
-
this.links.set(
|
|
37554
|
-
parent: parentLink,
|
|
37555
|
-
links: [],
|
|
37556
|
-
},);
|
|
37514
|
+
if (!this.links.has(parentLinkNodeId,)) {
|
|
37515
|
+
this.links.set(parentLinkNodeId, /* @__PURE__ */ new Set(),);
|
|
37557
37516
|
}
|
|
37558
|
-
const entry = this.links.get(
|
|
37559
|
-
entry.
|
|
37517
|
+
const entry = this.links.get(parentLinkNodeId,);
|
|
37518
|
+
entry.add(linkNodeId,);
|
|
37560
37519
|
}
|
|
37561
37520
|
};
|
|
37562
37521
|
var nestedLinksCollector = /* @__PURE__ */ new NestedLinksCollector();
|
|
@@ -38054,20 +38013,18 @@ var Link = /* @__PURE__ */ withChildrenCanSuspend(/* @__PURE__ */ forwardRef(({
|
|
|
38054
38013
|
if (node === null) return;
|
|
38055
38014
|
return observerCallback(node,);
|
|
38056
38015
|
}, [observerCallback,],);
|
|
38057
|
-
const
|
|
38058
|
-
|
|
38059
|
-
|
|
38060
|
-
|
|
38061
|
-
|
|
38062
|
-
|
|
38063
|
-
|
|
38064
|
-
|
|
38065
|
-
|
|
38066
|
-
},);
|
|
38067
|
-
}, [props, clone, children, restProps, observerRef,],);
|
|
38016
|
+
const {
|
|
38017
|
+
navigate: _,
|
|
38018
|
+
...linkProps
|
|
38019
|
+
} = props;
|
|
38020
|
+
const el = clone.cloneAsArray(children, {
|
|
38021
|
+
...restProps,
|
|
38022
|
+
...linkProps,
|
|
38023
|
+
ref: observerRef,
|
|
38024
|
+
},);
|
|
38068
38025
|
return getChildren(el,);
|
|
38069
38026
|
},),);
|
|
38070
|
-
var ParentLinkContext = /* @__PURE__ */ createContext(
|
|
38027
|
+
var ParentLinkContext = /* @__PURE__ */ createContext(void 0,);
|
|
38071
38028
|
function useReplaceNestedLinks(nodeId, href, propsAddedByLink,) {
|
|
38072
38029
|
const parentLink = useContext(ParentLinkContext,);
|
|
38073
38030
|
const isOnFramerCanvas = useIsOnFramerCanvas();
|
|
@@ -38081,30 +38038,6 @@ function useReplaceNestedLinks(nodeId, href, propsAddedByLink,) {
|
|
|
38081
38038
|
if (!pageLink) return;
|
|
38082
38039
|
return getRouteFromPageLink(pageLink, router, currentRoute,);
|
|
38083
38040
|
}, [currentRoute, href, router,],);
|
|
38084
|
-
const linkData = useMemo(() => {
|
|
38085
|
-
if (!nodeId || !href) return null;
|
|
38086
|
-
if (isLinkToWebPage(href,)) {
|
|
38087
|
-
return {
|
|
38088
|
-
nodeId,
|
|
38089
|
-
targetNodeId: href.webPageId,
|
|
38090
|
-
href: propsAddedByLink.href,
|
|
38091
|
-
};
|
|
38092
|
-
}
|
|
38093
|
-
if (route && href.startsWith('#',)) {
|
|
38094
|
-
const routeNodeId = Object.keys(route.elements ?? {},)[0];
|
|
38095
|
-
if (routeNodeId) {
|
|
38096
|
-
return {
|
|
38097
|
-
nodeId,
|
|
38098
|
-
targetNodeId: routeNodeId,
|
|
38099
|
-
href,
|
|
38100
|
-
};
|
|
38101
|
-
}
|
|
38102
|
-
}
|
|
38103
|
-
return {
|
|
38104
|
-
nodeId,
|
|
38105
|
-
href,
|
|
38106
|
-
};
|
|
38107
|
-
}, [href, nodeId, propsAddedByLink, route,],);
|
|
38108
38041
|
const isValidLink = Object.keys(propsAddedByLink,).length > 0;
|
|
38109
38042
|
const shouldReplaceLink = Boolean(replaceNestedLinks && !isOnFramerCanvas && (parentLink || !isValidLink),);
|
|
38110
38043
|
const onClick = useCallback((event) => {
|
|
@@ -38153,7 +38086,7 @@ function useReplaceNestedLinks(nodeId, href, propsAddedByLink,) {
|
|
|
38153
38086
|
};
|
|
38154
38087
|
const replacedChildren = !shouldReplaceLink ? children : Children.map(children, (child) => {
|
|
38155
38088
|
if (!isChildReplaceable(child,)) return child;
|
|
38156
|
-
nestedLinksCollector.addLink(parentLink,
|
|
38089
|
+
nestedLinksCollector.addLink(parentLink, nodeId,);
|
|
38157
38090
|
const tag = maybeReplaceAnchorWithSpan(child.type,);
|
|
38158
38091
|
const {
|
|
38159
38092
|
children: childChildren,
|
|
@@ -38174,10 +38107,10 @@ function useReplaceNestedLinks(nodeId, href, propsAddedByLink,) {
|
|
|
38174
38107
|
}, childChildren,);
|
|
38175
38108
|
},);
|
|
38176
38109
|
return /* @__PURE__ */ jsx(ParentLinkContext.Provider, {
|
|
38177
|
-
value:
|
|
38110
|
+
value: nodeId,
|
|
38178
38111
|
children: replacedChildren,
|
|
38179
38112
|
},);
|
|
38180
|
-
}, [isValidLink,
|
|
38113
|
+
}, [isValidLink, nodeId, onAuxClick, onClick, onKeyDown, shouldReplaceLink, parentLink,],);
|
|
38181
38114
|
const refCallback = useCallback((node) => {
|
|
38182
38115
|
if (isOnFramerCanvas || !shouldReplaceLink || !isValidLink) return;
|
|
38183
38116
|
node.dataset.hydrated = 'true';
|
|
@@ -39346,7 +39279,6 @@ var Fetcher = /* @__PURE__ */ React2.forwardRef(function Fetcher2({
|
|
|
39346
39279
|
return cloneWithPropsAndRef(childrenWithValues, rest,);
|
|
39347
39280
|
},);
|
|
39348
39281
|
var callEach = (...fns) => fns.forEach((fn) => fn && fn());
|
|
39349
|
-
var import_archy = __toESM(require_archy(), 1,);
|
|
39350
39282
|
function getLogger(name,) {
|
|
39351
39283
|
return {
|
|
39352
39284
|
trace(...args) {
|
|
@@ -39532,10 +39464,6 @@ function castDate(value,) {
|
|
|
39532
39464
|
}
|
|
39533
39465
|
return null;
|
|
39534
39466
|
}
|
|
39535
|
-
function toDate(value,) {
|
|
39536
|
-
const cast = castDate(value,);
|
|
39537
|
-
return (cast == null ? void 0 : cast.value) ?? null;
|
|
39538
|
-
}
|
|
39539
39467
|
function castEnum(value,) {
|
|
39540
39468
|
switch (value == null ? void 0 : value.type) {
|
|
39541
39469
|
case 'enum': {
|
|
@@ -39992,1464 +39920,6 @@ function compare(left, right, collation10,) {
|
|
|
39992
39920
|
}
|
|
39993
39921
|
}
|
|
39994
39922
|
}
|
|
39995
|
-
var INDEX_IDENTIFIER = 'index';
|
|
39996
|
-
var ScalarExpression = class {
|
|
39997
|
-
static from(expression, schema,) {
|
|
39998
|
-
return convertExpression(expression, schema, void 0,);
|
|
39999
|
-
}
|
|
40000
|
-
};
|
|
40001
|
-
var ScalarIdentifier = class extends ScalarExpression {
|
|
40002
|
-
constructor(schema, name, collection,) {
|
|
40003
|
-
super();
|
|
40004
|
-
this.schema = schema;
|
|
40005
|
-
this.name = name;
|
|
40006
|
-
this.collection = collection;
|
|
40007
|
-
__publicField(this, 'definition',);
|
|
40008
|
-
if (name === INDEX_IDENTIFIER) {
|
|
40009
|
-
this.definition = {
|
|
40010
|
-
type: 'number',
|
|
40011
|
-
isNullable: false,
|
|
40012
|
-
};
|
|
40013
|
-
} else {
|
|
40014
|
-
this.definition = schema[name] ?? null;
|
|
40015
|
-
}
|
|
40016
|
-
}
|
|
40017
|
-
stringify() {
|
|
40018
|
-
return this.name;
|
|
40019
|
-
}
|
|
40020
|
-
equals(other,) {
|
|
40021
|
-
return other instanceof ScalarIdentifier && isEqual(this.definition, other.definition,) && isEqual(other.name, this.name,) &&
|
|
40022
|
-
isEqual(other.collection, this.collection,);
|
|
40023
|
-
}
|
|
40024
|
-
evaluate(item,) {
|
|
40025
|
-
const name = this.name;
|
|
40026
|
-
if (isUndefined(item,) || name === INDEX_IDENTIFIER) {
|
|
40027
|
-
throw new Error(`Can't evaluate identifier: ${name}`,);
|
|
40028
|
-
}
|
|
40029
|
-
if (this.collection) {
|
|
40030
|
-
const scopedName = `${this.collection}_${name}`;
|
|
40031
|
-
return item.data[scopedName] ?? item.data[name] ?? null;
|
|
40032
|
-
}
|
|
40033
|
-
return item.data[name] ?? null;
|
|
40034
|
-
}
|
|
40035
|
-
canEvaluate() {
|
|
40036
|
-
return false;
|
|
40037
|
-
}
|
|
40038
|
-
};
|
|
40039
|
-
var ScalarLiteralValue = class extends ScalarExpression {
|
|
40040
|
-
constructor(definition, value,) {
|
|
40041
|
-
super();
|
|
40042
|
-
this.definition = definition;
|
|
40043
|
-
this.value = value;
|
|
40044
|
-
}
|
|
40045
|
-
stringify() {
|
|
40046
|
-
return DatabaseValue.stringify(this.value,);
|
|
40047
|
-
}
|
|
40048
|
-
static fromNull() {
|
|
40049
|
-
return new ScalarLiteralValue(null, null,);
|
|
40050
|
-
}
|
|
40051
|
-
static fromBoolean(value,) {
|
|
40052
|
-
return new ScalarLiteralValue(
|
|
40053
|
-
{
|
|
40054
|
-
type: 'boolean',
|
|
40055
|
-
isNullable: isNull(value,),
|
|
40056
|
-
},
|
|
40057
|
-
isNull(value,) ? null : {
|
|
40058
|
-
type: 'boolean',
|
|
40059
|
-
value,
|
|
40060
|
-
},
|
|
40061
|
-
);
|
|
40062
|
-
}
|
|
40063
|
-
static fromDate(value,) {
|
|
40064
|
-
return new ScalarLiteralValue(
|
|
40065
|
-
{
|
|
40066
|
-
type: 'date',
|
|
40067
|
-
isNullable: isNull(value,),
|
|
40068
|
-
},
|
|
40069
|
-
isNull(value,) ? null : {
|
|
40070
|
-
type: 'date',
|
|
40071
|
-
value,
|
|
40072
|
-
},
|
|
40073
|
-
);
|
|
40074
|
-
}
|
|
40075
|
-
static fromEnum(value,) {
|
|
40076
|
-
return new ScalarLiteralValue(
|
|
40077
|
-
{
|
|
40078
|
-
type: 'enum',
|
|
40079
|
-
isNullable: isNull(value,),
|
|
40080
|
-
},
|
|
40081
|
-
isNull(value,) ? null : {
|
|
40082
|
-
type: 'enum',
|
|
40083
|
-
value,
|
|
40084
|
-
},
|
|
40085
|
-
);
|
|
40086
|
-
}
|
|
40087
|
-
static fromNumber(value,) {
|
|
40088
|
-
return new ScalarLiteralValue(
|
|
40089
|
-
{
|
|
40090
|
-
type: 'number',
|
|
40091
|
-
isNullable: isNull(value,),
|
|
40092
|
-
},
|
|
40093
|
-
isNull(value,) ? null : {
|
|
40094
|
-
type: 'number',
|
|
40095
|
-
value,
|
|
40096
|
-
},
|
|
40097
|
-
);
|
|
40098
|
-
}
|
|
40099
|
-
static fromString(value,) {
|
|
40100
|
-
return new ScalarLiteralValue(
|
|
40101
|
-
{
|
|
40102
|
-
type: 'string',
|
|
40103
|
-
isNullable: isNull(value,),
|
|
40104
|
-
},
|
|
40105
|
-
isNull(value,) ? null : {
|
|
40106
|
-
type: 'string',
|
|
40107
|
-
value,
|
|
40108
|
-
},
|
|
40109
|
-
);
|
|
40110
|
-
}
|
|
40111
|
-
equals(other,) {
|
|
40112
|
-
return other instanceof ScalarLiteralValue && isEqual(this.definition, other.definition,) && isEqual(other.value, this.value,);
|
|
40113
|
-
}
|
|
40114
|
-
evaluate() {
|
|
40115
|
-
return this.value;
|
|
40116
|
-
}
|
|
40117
|
-
canEvaluate() {
|
|
40118
|
-
return true;
|
|
40119
|
-
}
|
|
40120
|
-
};
|
|
40121
|
-
var ScalarFunctionCall = class extends ScalarExpression {
|
|
40122
|
-
constructor(argumentExpressions,) {
|
|
40123
|
-
super();
|
|
40124
|
-
this.argumentExpressions = argumentExpressions;
|
|
40125
|
-
__publicField(this, 'collation', {
|
|
40126
|
-
type: 0,
|
|
40127
|
-
/* CaseInsensitive */
|
|
40128
|
-
},);
|
|
40129
|
-
}
|
|
40130
|
-
getArgumentExpression(index,) {
|
|
40131
|
-
const argument = this.argumentExpressions[index];
|
|
40132
|
-
if (isUndefined(argument,)) {
|
|
40133
|
-
throw new Error('Missing argument in function call',);
|
|
40134
|
-
}
|
|
40135
|
-
return argument;
|
|
40136
|
-
}
|
|
40137
|
-
equals(other,) {
|
|
40138
|
-
return other instanceof ScalarFunctionCall && isEqual(this.constructor, other.constructor,) &&
|
|
40139
|
-
isEqual(this.argumentExpressions, other.argumentExpressions,);
|
|
40140
|
-
}
|
|
40141
|
-
canEvaluate() {
|
|
40142
|
-
return this.argumentExpressions.every((expression) => {
|
|
40143
|
-
return expression.canEvaluate();
|
|
40144
|
-
},);
|
|
40145
|
-
}
|
|
40146
|
-
};
|
|
40147
|
-
var ScalarFunctionCallContains = class extends ScalarFunctionCall {
|
|
40148
|
-
constructor() {
|
|
40149
|
-
super(...arguments,);
|
|
40150
|
-
__publicField(this, 'definition', ScalarFunctionCallContains.getDefinition(),);
|
|
40151
|
-
__publicField(this, 'sourceExpression', this.getArgumentExpression(0,),);
|
|
40152
|
-
__publicField(this, 'targetExpression', this.getArgumentExpression(1,),);
|
|
40153
|
-
}
|
|
40154
|
-
static getDefinition() {
|
|
40155
|
-
return {
|
|
40156
|
-
type: 'boolean',
|
|
40157
|
-
isNullable: false,
|
|
40158
|
-
};
|
|
40159
|
-
}
|
|
40160
|
-
stringify() {
|
|
40161
|
-
return `CONTAINS(${this.sourceExpression.stringify()}, ${this.targetExpression.stringify()})`;
|
|
40162
|
-
}
|
|
40163
|
-
getValue(source, target,) {
|
|
40164
|
-
if (isNull(source,) || source.type !== 'string') return false;
|
|
40165
|
-
if (isNull(target,) || target.type !== 'string') return false;
|
|
40166
|
-
let sourceValue = source.value;
|
|
40167
|
-
let targetValue = target.value;
|
|
40168
|
-
if (this.collation.type === 0) {
|
|
40169
|
-
sourceValue = sourceValue.toLowerCase();
|
|
40170
|
-
targetValue = targetValue.toLowerCase();
|
|
40171
|
-
}
|
|
40172
|
-
return sourceValue.includes(targetValue,);
|
|
40173
|
-
}
|
|
40174
|
-
evaluate(item,) {
|
|
40175
|
-
const source = this.sourceExpression.evaluate(item,);
|
|
40176
|
-
const target = this.targetExpression.evaluate(item,);
|
|
40177
|
-
return {
|
|
40178
|
-
type: 'boolean',
|
|
40179
|
-
value: this.getValue(source, target,),
|
|
40180
|
-
};
|
|
40181
|
-
}
|
|
40182
|
-
};
|
|
40183
|
-
var ScalarFunctionCallStartsWith = class extends ScalarFunctionCall {
|
|
40184
|
-
constructor() {
|
|
40185
|
-
super(...arguments,);
|
|
40186
|
-
__publicField(this, 'definition', ScalarFunctionCallStartsWith.getDefinition(),);
|
|
40187
|
-
__publicField(this, 'sourceExpression', this.getArgumentExpression(0,),);
|
|
40188
|
-
__publicField(this, 'targetExpression', this.getArgumentExpression(1,),);
|
|
40189
|
-
}
|
|
40190
|
-
static getDefinition() {
|
|
40191
|
-
return {
|
|
40192
|
-
type: 'boolean',
|
|
40193
|
-
isNullable: false,
|
|
40194
|
-
};
|
|
40195
|
-
}
|
|
40196
|
-
stringify() {
|
|
40197
|
-
return `STARTS_WITH(${this.sourceExpression.stringify()}, ${this.targetExpression.stringify()})`;
|
|
40198
|
-
}
|
|
40199
|
-
getValue(source, target,) {
|
|
40200
|
-
if (isNull(source,) || source.type !== 'string') return false;
|
|
40201
|
-
if (isNull(target,) || target.type !== 'string') return false;
|
|
40202
|
-
let sourceValue = source.value;
|
|
40203
|
-
let targetValue = target.value;
|
|
40204
|
-
if (this.collation.type === 0) {
|
|
40205
|
-
sourceValue = sourceValue.toLowerCase();
|
|
40206
|
-
targetValue = targetValue.toLowerCase();
|
|
40207
|
-
}
|
|
40208
|
-
return sourceValue.startsWith(targetValue,);
|
|
40209
|
-
}
|
|
40210
|
-
evaluate(item,) {
|
|
40211
|
-
const source = this.sourceExpression.evaluate(item,);
|
|
40212
|
-
const target = this.targetExpression.evaluate(item,);
|
|
40213
|
-
return {
|
|
40214
|
-
type: 'boolean',
|
|
40215
|
-
value: this.getValue(source, target,),
|
|
40216
|
-
};
|
|
40217
|
-
}
|
|
40218
|
-
};
|
|
40219
|
-
var ScalarFunctionCallEndsWith = class extends ScalarFunctionCall {
|
|
40220
|
-
constructor() {
|
|
40221
|
-
super(...arguments,);
|
|
40222
|
-
__publicField(this, 'definition', ScalarFunctionCallEndsWith.getDefinition(),);
|
|
40223
|
-
__publicField(this, 'sourceExpression', this.getArgumentExpression(0,),);
|
|
40224
|
-
__publicField(this, 'targetExpression', this.getArgumentExpression(1,),);
|
|
40225
|
-
}
|
|
40226
|
-
static getDefinition() {
|
|
40227
|
-
return {
|
|
40228
|
-
type: 'boolean',
|
|
40229
|
-
isNullable: false,
|
|
40230
|
-
};
|
|
40231
|
-
}
|
|
40232
|
-
stringify() {
|
|
40233
|
-
return `ENDS_WITH(${this.sourceExpression.stringify()}, ${this.targetExpression.stringify()})`;
|
|
40234
|
-
}
|
|
40235
|
-
getValue(source, target,) {
|
|
40236
|
-
if (isNull(source,) || source.type !== 'string') return false;
|
|
40237
|
-
if (isNull(target,) || target.type !== 'string') return false;
|
|
40238
|
-
let sourceValue = source.value;
|
|
40239
|
-
let targetValue = target.value;
|
|
40240
|
-
if (this.collation.type === 0) {
|
|
40241
|
-
sourceValue = sourceValue.toLowerCase();
|
|
40242
|
-
targetValue = targetValue.toLowerCase();
|
|
40243
|
-
}
|
|
40244
|
-
return sourceValue.endsWith(targetValue,);
|
|
40245
|
-
}
|
|
40246
|
-
evaluate(item,) {
|
|
40247
|
-
const source = this.sourceExpression.evaluate(item,);
|
|
40248
|
-
const target = this.targetExpression.evaluate(item,);
|
|
40249
|
-
return {
|
|
40250
|
-
type: 'boolean',
|
|
40251
|
-
value: this.getValue(source, target,),
|
|
40252
|
-
};
|
|
40253
|
-
}
|
|
40254
|
-
};
|
|
40255
|
-
var ScalarCase = class extends ScalarExpression {
|
|
40256
|
-
constructor(valueExpression, conditions, elseExpression,) {
|
|
40257
|
-
super();
|
|
40258
|
-
this.valueExpression = valueExpression;
|
|
40259
|
-
this.conditions = conditions;
|
|
40260
|
-
this.elseExpression = elseExpression;
|
|
40261
|
-
__publicField(this, 'definition',);
|
|
40262
|
-
__publicField(this, 'collation', {
|
|
40263
|
-
type: 0,
|
|
40264
|
-
/* CaseInsensitive */
|
|
40265
|
-
},);
|
|
40266
|
-
const definitions = [];
|
|
40267
|
-
for (
|
|
40268
|
-
const {
|
|
40269
|
-
thenExpression,
|
|
40270
|
-
} of conditions
|
|
40271
|
-
) {
|
|
40272
|
-
definitions.push(thenExpression.definition,);
|
|
40273
|
-
}
|
|
40274
|
-
if (elseExpression) {
|
|
40275
|
-
definitions.push(elseExpression.definition,);
|
|
40276
|
-
}
|
|
40277
|
-
this.definition = ScalarCase.getDefinition(definitions,);
|
|
40278
|
-
}
|
|
40279
|
-
static getDefinition(definitions,) {
|
|
40280
|
-
let result = null;
|
|
40281
|
-
let isNullable = false;
|
|
40282
|
-
for (const definition of definitions) {
|
|
40283
|
-
result ?? (result = definition);
|
|
40284
|
-
if (result && definition && result.type !== definition.type) {
|
|
40285
|
-
throw new Error('Incompatible types in CASE expression',);
|
|
40286
|
-
}
|
|
40287
|
-
isNullable || (isNullable = (definition == null ? void 0 : definition.isNullable) ?? true);
|
|
40288
|
-
}
|
|
40289
|
-
return result
|
|
40290
|
-
? {
|
|
40291
|
-
...result,
|
|
40292
|
-
isNullable,
|
|
40293
|
-
}
|
|
40294
|
-
: null;
|
|
40295
|
-
}
|
|
40296
|
-
stringify() {
|
|
40297
|
-
let result = 'CASE';
|
|
40298
|
-
if (this.valueExpression) {
|
|
40299
|
-
result += ` ${this.valueExpression.stringify()}`;
|
|
40300
|
-
}
|
|
40301
|
-
for (
|
|
40302
|
-
const {
|
|
40303
|
-
whenExpression,
|
|
40304
|
-
thenExpression,
|
|
40305
|
-
} of this.conditions
|
|
40306
|
-
) {
|
|
40307
|
-
result += ` WHEN ${whenExpression.stringify()} THEN ${thenExpression.stringify()}`;
|
|
40308
|
-
}
|
|
40309
|
-
if (this.elseExpression) {
|
|
40310
|
-
result += ` ELSE ${this.elseExpression.stringify()}`;
|
|
40311
|
-
}
|
|
40312
|
-
result += ' END';
|
|
40313
|
-
return result;
|
|
40314
|
-
}
|
|
40315
|
-
equals(other,) {
|
|
40316
|
-
return other instanceof ScalarCase && isEqual(this.valueExpression, other.valueExpression,) &&
|
|
40317
|
-
isEqual(this.conditions, other.conditions,) && isEqual(this.elseExpression, other.elseExpression,);
|
|
40318
|
-
}
|
|
40319
|
-
evaluate(item,) {
|
|
40320
|
-
var _a, _b;
|
|
40321
|
-
const value = ((_a = this.valueExpression) == null ? void 0 : _a.evaluate(item,)) ?? null;
|
|
40322
|
-
for (
|
|
40323
|
-
const {
|
|
40324
|
-
whenExpression,
|
|
40325
|
-
thenExpression,
|
|
40326
|
-
} of this.conditions
|
|
40327
|
-
) {
|
|
40328
|
-
const when = whenExpression.evaluate(item,);
|
|
40329
|
-
const isMatching = this.valueExpression ? DatabaseValue.equal(when, value, this.collation,) : toBoolean(when,);
|
|
40330
|
-
if (isMatching) return thenExpression.evaluate(item,);
|
|
40331
|
-
}
|
|
40332
|
-
return ((_b = this.elseExpression) == null ? void 0 : _b.evaluate(item,)) ?? null;
|
|
40333
|
-
}
|
|
40334
|
-
canEvaluate() {
|
|
40335
|
-
const expressions = [];
|
|
40336
|
-
if (this.valueExpression) {
|
|
40337
|
-
expressions.push(this.valueExpression,);
|
|
40338
|
-
}
|
|
40339
|
-
for (const condition of this.conditions) {
|
|
40340
|
-
expressions.push(condition.whenExpression,);
|
|
40341
|
-
expressions.push(condition.thenExpression,);
|
|
40342
|
-
}
|
|
40343
|
-
if (this.elseExpression) {
|
|
40344
|
-
expressions.push(this.elseExpression,);
|
|
40345
|
-
}
|
|
40346
|
-
return expressions.every((expression) => {
|
|
40347
|
-
return expression.canEvaluate();
|
|
40348
|
-
},);
|
|
40349
|
-
}
|
|
40350
|
-
};
|
|
40351
|
-
var ScalarCaseCondition = class {
|
|
40352
|
-
constructor(whenExpression, thenExpression,) {
|
|
40353
|
-
this.whenExpression = whenExpression;
|
|
40354
|
-
this.thenExpression = thenExpression;
|
|
40355
|
-
}
|
|
40356
|
-
};
|
|
40357
|
-
var ScalarUnaryOperation = class extends ScalarExpression {
|
|
40358
|
-
constructor(valueExpression,) {
|
|
40359
|
-
super();
|
|
40360
|
-
this.valueExpression = valueExpression;
|
|
40361
|
-
}
|
|
40362
|
-
equals(other,) {
|
|
40363
|
-
return other instanceof ScalarUnaryOperation && isEqual(this.constructor, other.constructor,) &&
|
|
40364
|
-
isEqual(this.valueExpression, other.valueExpression,);
|
|
40365
|
-
}
|
|
40366
|
-
canEvaluate() {
|
|
40367
|
-
return this.valueExpression.canEvaluate();
|
|
40368
|
-
}
|
|
40369
|
-
};
|
|
40370
|
-
var ScalarUnaryOperationNot = class extends ScalarUnaryOperation {
|
|
40371
|
-
constructor() {
|
|
40372
|
-
super(...arguments,);
|
|
40373
|
-
__publicField(this, 'definition', ScalarUnaryOperationNot.getDefinition(),);
|
|
40374
|
-
}
|
|
40375
|
-
static getDefinition() {
|
|
40376
|
-
return {
|
|
40377
|
-
type: 'boolean',
|
|
40378
|
-
isNullable: false,
|
|
40379
|
-
};
|
|
40380
|
-
}
|
|
40381
|
-
stringify() {
|
|
40382
|
-
return `NOT ${this.valueExpression.stringify()}`;
|
|
40383
|
-
}
|
|
40384
|
-
evaluate(item,) {
|
|
40385
|
-
const value = this.valueExpression.evaluate(item,);
|
|
40386
|
-
return {
|
|
40387
|
-
type: 'boolean',
|
|
40388
|
-
value: !toBoolean(value,),
|
|
40389
|
-
};
|
|
40390
|
-
}
|
|
40391
|
-
};
|
|
40392
|
-
var ScalarLogicalOperation = class extends ScalarExpression {
|
|
40393
|
-
constructor(operandExpressions,) {
|
|
40394
|
-
super();
|
|
40395
|
-
this.operandExpressions = operandExpressions;
|
|
40396
|
-
__publicField(this, 'definition', ScalarLogicalOperation.getDefinition(),);
|
|
40397
|
-
}
|
|
40398
|
-
static getDefinition() {
|
|
40399
|
-
return {
|
|
40400
|
-
type: 'boolean',
|
|
40401
|
-
isNullable: false,
|
|
40402
|
-
};
|
|
40403
|
-
}
|
|
40404
|
-
stringify() {
|
|
40405
|
-
return this.operandExpressions.map((expression) => expression.stringify()).join(' AND ',);
|
|
40406
|
-
}
|
|
40407
|
-
equals(other,) {
|
|
40408
|
-
return other instanceof ScalarLogicalOperation && isEqual(this.constructor, other.constructor,) &&
|
|
40409
|
-
isEqual(this.operandExpressions, other.operandExpressions,);
|
|
40410
|
-
}
|
|
40411
|
-
canEvaluate() {
|
|
40412
|
-
return this.operandExpressions.every((expression) => {
|
|
40413
|
-
return expression.canEvaluate();
|
|
40414
|
-
},);
|
|
40415
|
-
}
|
|
40416
|
-
};
|
|
40417
|
-
var ScalarLogicalOperationAnd = class extends ScalarLogicalOperation {
|
|
40418
|
-
constructor() {
|
|
40419
|
-
super(...arguments,);
|
|
40420
|
-
__publicField(this, 'operator', 'AND',);
|
|
40421
|
-
}
|
|
40422
|
-
evaluate(item,) {
|
|
40423
|
-
const result = this.operandExpressions.every((expression) => {
|
|
40424
|
-
const value = expression.evaluate(item,);
|
|
40425
|
-
return toBoolean(value,);
|
|
40426
|
-
},);
|
|
40427
|
-
return {
|
|
40428
|
-
type: 'boolean',
|
|
40429
|
-
value: result,
|
|
40430
|
-
};
|
|
40431
|
-
}
|
|
40432
|
-
};
|
|
40433
|
-
var ScalarLogicalOperationOr = class extends ScalarLogicalOperation {
|
|
40434
|
-
constructor() {
|
|
40435
|
-
super(...arguments,);
|
|
40436
|
-
__publicField(this, 'operator', 'OR',);
|
|
40437
|
-
}
|
|
40438
|
-
evaluate(item,) {
|
|
40439
|
-
const result = this.operandExpressions.some((expression) => {
|
|
40440
|
-
const value = expression.evaluate(item,);
|
|
40441
|
-
return toBoolean(value,);
|
|
40442
|
-
},);
|
|
40443
|
-
return {
|
|
40444
|
-
type: 'boolean',
|
|
40445
|
-
value: result,
|
|
40446
|
-
};
|
|
40447
|
-
}
|
|
40448
|
-
};
|
|
40449
|
-
var ScalarComparison = class extends ScalarExpression {
|
|
40450
|
-
constructor(leftExpression, rightExpression,) {
|
|
40451
|
-
super();
|
|
40452
|
-
this.leftExpression = leftExpression;
|
|
40453
|
-
this.rightExpression = rightExpression;
|
|
40454
|
-
__publicField(this, 'definition', ScalarComparison.getDefinition(),);
|
|
40455
|
-
__publicField(this, 'collation', {
|
|
40456
|
-
type: 0,
|
|
40457
|
-
/* CaseInsensitive */
|
|
40458
|
-
},);
|
|
40459
|
-
}
|
|
40460
|
-
static getDefinition() {
|
|
40461
|
-
return {
|
|
40462
|
-
type: 'boolean',
|
|
40463
|
-
isNullable: false,
|
|
40464
|
-
};
|
|
40465
|
-
}
|
|
40466
|
-
stringify() {
|
|
40467
|
-
return `${this.leftExpression.stringify()} ${this.operator} ${this.rightExpression.stringify()}`;
|
|
40468
|
-
}
|
|
40469
|
-
equals(other,) {
|
|
40470
|
-
return other instanceof ScalarComparison && isEqual(this.constructor, other.constructor,) &&
|
|
40471
|
-
isEqual(this.leftExpression, other.leftExpression,) && isEqual(this.rightExpression, other.rightExpression,);
|
|
40472
|
-
}
|
|
40473
|
-
canEvaluate() {
|
|
40474
|
-
return this.leftExpression.canEvaluate() && this.rightExpression.canEvaluate();
|
|
40475
|
-
}
|
|
40476
|
-
};
|
|
40477
|
-
var ScalarComparisonEquals = class extends ScalarComparison {
|
|
40478
|
-
constructor() {
|
|
40479
|
-
super(...arguments,);
|
|
40480
|
-
__publicField(this, 'operator', '=',);
|
|
40481
|
-
}
|
|
40482
|
-
evaluate(item,) {
|
|
40483
|
-
const leftValue = this.leftExpression.evaluate(item,);
|
|
40484
|
-
const rightValue = this.rightExpression.evaluate(item,);
|
|
40485
|
-
return {
|
|
40486
|
-
type: 'boolean',
|
|
40487
|
-
value: DatabaseValue.equal(leftValue, rightValue, this.collation,),
|
|
40488
|
-
};
|
|
40489
|
-
}
|
|
40490
|
-
};
|
|
40491
|
-
var ScalarComparisonNotEquals = class extends ScalarComparison {
|
|
40492
|
-
constructor() {
|
|
40493
|
-
super(...arguments,);
|
|
40494
|
-
__publicField(this, 'operator', '!=',);
|
|
40495
|
-
}
|
|
40496
|
-
evaluate(item,) {
|
|
40497
|
-
const leftValue = this.leftExpression.evaluate(item,);
|
|
40498
|
-
const rightValue = this.rightExpression.evaluate(item,);
|
|
40499
|
-
return {
|
|
40500
|
-
type: 'boolean',
|
|
40501
|
-
value: !DatabaseValue.equal(leftValue, rightValue, this.collation,),
|
|
40502
|
-
};
|
|
40503
|
-
}
|
|
40504
|
-
};
|
|
40505
|
-
var ScalarComparisonLessThan = class extends ScalarComparison {
|
|
40506
|
-
constructor() {
|
|
40507
|
-
super(...arguments,);
|
|
40508
|
-
__publicField(this, 'operator', '<',);
|
|
40509
|
-
}
|
|
40510
|
-
evaluate(item,) {
|
|
40511
|
-
const leftValue = this.leftExpression.evaluate(item,);
|
|
40512
|
-
const rightValue = this.rightExpression.evaluate(item,);
|
|
40513
|
-
return {
|
|
40514
|
-
type: 'boolean',
|
|
40515
|
-
value: DatabaseValue.lessThan(leftValue, rightValue, this.collation,),
|
|
40516
|
-
};
|
|
40517
|
-
}
|
|
40518
|
-
};
|
|
40519
|
-
var ScalarComparisonLessThanOrEqual = class extends ScalarComparison {
|
|
40520
|
-
constructor() {
|
|
40521
|
-
super(...arguments,);
|
|
40522
|
-
__publicField(this, 'operator', '<=',);
|
|
40523
|
-
}
|
|
40524
|
-
evaluate(item,) {
|
|
40525
|
-
const leftValue = this.leftExpression.evaluate(item,);
|
|
40526
|
-
const rightValue = this.rightExpression.evaluate(item,);
|
|
40527
|
-
return {
|
|
40528
|
-
type: 'boolean',
|
|
40529
|
-
value: DatabaseValue.lessThanOrEqual(leftValue, rightValue, this.collation,),
|
|
40530
|
-
};
|
|
40531
|
-
}
|
|
40532
|
-
};
|
|
40533
|
-
var ScalarComparisonGreaterThan = class extends ScalarComparison {
|
|
40534
|
-
constructor() {
|
|
40535
|
-
super(...arguments,);
|
|
40536
|
-
__publicField(this, 'operator', '>',);
|
|
40537
|
-
}
|
|
40538
|
-
evaluate(item,) {
|
|
40539
|
-
const leftValue = this.leftExpression.evaluate(item,);
|
|
40540
|
-
const rightValue = this.rightExpression.evaluate(item,);
|
|
40541
|
-
return {
|
|
40542
|
-
type: 'boolean',
|
|
40543
|
-
value: DatabaseValue.greaterThan(leftValue, rightValue, this.collation,),
|
|
40544
|
-
};
|
|
40545
|
-
}
|
|
40546
|
-
};
|
|
40547
|
-
var ScalarComparisonGreaterThanOrEqual = class extends ScalarComparison {
|
|
40548
|
-
constructor() {
|
|
40549
|
-
super(...arguments,);
|
|
40550
|
-
__publicField(this, 'operator', '>=',);
|
|
40551
|
-
}
|
|
40552
|
-
evaluate(item,) {
|
|
40553
|
-
const leftValue = this.leftExpression.evaluate(item,);
|
|
40554
|
-
const rightValue = this.rightExpression.evaluate(item,);
|
|
40555
|
-
return {
|
|
40556
|
-
type: 'boolean',
|
|
40557
|
-
value: DatabaseValue.greaterThanOrEqual(leftValue, rightValue, this.collation,),
|
|
40558
|
-
};
|
|
40559
|
-
}
|
|
40560
|
-
};
|
|
40561
|
-
var ScalarTypeCast = class extends ScalarExpression {
|
|
40562
|
-
constructor(valueExpression,) {
|
|
40563
|
-
super();
|
|
40564
|
-
this.valueExpression = valueExpression;
|
|
40565
|
-
}
|
|
40566
|
-
stringify() {
|
|
40567
|
-
return `CAST(${this.valueExpression.stringify()} AS ${this.dataType})`;
|
|
40568
|
-
}
|
|
40569
|
-
equals(other,) {
|
|
40570
|
-
return other instanceof ScalarTypeCast && isEqual(this.constructor, other.constructor,) &&
|
|
40571
|
-
isEqual(this.valueExpression, other.valueExpression,);
|
|
40572
|
-
}
|
|
40573
|
-
canEvaluate() {
|
|
40574
|
-
return this.valueExpression.canEvaluate();
|
|
40575
|
-
}
|
|
40576
|
-
};
|
|
40577
|
-
var ScalarTypeCastBoolean = class extends ScalarTypeCast {
|
|
40578
|
-
constructor() {
|
|
40579
|
-
super(...arguments,);
|
|
40580
|
-
__publicField(this, 'dataType', 'BOOLEAN',);
|
|
40581
|
-
__publicField(this, 'definition', ScalarTypeCastBoolean.getDefinition(),);
|
|
40582
|
-
}
|
|
40583
|
-
static getDefinition() {
|
|
40584
|
-
return {
|
|
40585
|
-
type: 'boolean',
|
|
40586
|
-
isNullable: true,
|
|
40587
|
-
};
|
|
40588
|
-
}
|
|
40589
|
-
evaluate(item,) {
|
|
40590
|
-
const value = this.valueExpression.evaluate(item,);
|
|
40591
|
-
return DatabaseValue.cast(value, this.definition,);
|
|
40592
|
-
}
|
|
40593
|
-
};
|
|
40594
|
-
var ScalarTypeCastDate = class extends ScalarTypeCast {
|
|
40595
|
-
constructor() {
|
|
40596
|
-
super(...arguments,);
|
|
40597
|
-
__publicField(this, 'dataType', 'DATE',);
|
|
40598
|
-
__publicField(this, 'definition', ScalarTypeCastDate.getDefinition(),);
|
|
40599
|
-
}
|
|
40600
|
-
static getDefinition() {
|
|
40601
|
-
return {
|
|
40602
|
-
type: 'date',
|
|
40603
|
-
isNullable: true,
|
|
40604
|
-
};
|
|
40605
|
-
}
|
|
40606
|
-
evaluate(item,) {
|
|
40607
|
-
const value = this.valueExpression.evaluate(item,);
|
|
40608
|
-
return DatabaseValue.cast(value, this.definition,);
|
|
40609
|
-
}
|
|
40610
|
-
};
|
|
40611
|
-
var ScalarTypeCastNumber = class extends ScalarTypeCast {
|
|
40612
|
-
constructor() {
|
|
40613
|
-
super(...arguments,);
|
|
40614
|
-
__publicField(this, 'dataType', 'NUMBER',);
|
|
40615
|
-
__publicField(this, 'definition', ScalarTypeCastNumber.getDefinition(),);
|
|
40616
|
-
}
|
|
40617
|
-
static getDefinition() {
|
|
40618
|
-
return {
|
|
40619
|
-
type: 'number',
|
|
40620
|
-
isNullable: true,
|
|
40621
|
-
};
|
|
40622
|
-
}
|
|
40623
|
-
evaluate(item,) {
|
|
40624
|
-
const value = this.valueExpression.evaluate(item,);
|
|
40625
|
-
return DatabaseValue.cast(value, this.definition,);
|
|
40626
|
-
}
|
|
40627
|
-
};
|
|
40628
|
-
var ScalarTypeCastString = class extends ScalarTypeCast {
|
|
40629
|
-
constructor() {
|
|
40630
|
-
super(...arguments,);
|
|
40631
|
-
__publicField(this, 'dataType', 'STRING',);
|
|
40632
|
-
__publicField(this, 'definition', ScalarTypeCastString.getDefinition(),);
|
|
40633
|
-
}
|
|
40634
|
-
static getDefinition() {
|
|
40635
|
-
return {
|
|
40636
|
-
type: 'string',
|
|
40637
|
-
isNullable: true,
|
|
40638
|
-
};
|
|
40639
|
-
}
|
|
40640
|
-
evaluate(item,) {
|
|
40641
|
-
const value = this.valueExpression.evaluate(item,);
|
|
40642
|
-
return DatabaseValue.cast(value, this.definition,);
|
|
40643
|
-
}
|
|
40644
|
-
};
|
|
40645
|
-
function convertExpression(expression, schema, typeAffinity,) {
|
|
40646
|
-
const scalarExpression = getScalarExpression(expression, schema, typeAffinity,);
|
|
40647
|
-
const isLiteralValue = scalarExpression instanceof ScalarLiteralValue;
|
|
40648
|
-
if (scalarExpression.canEvaluate() && !isLiteralValue) {
|
|
40649
|
-
const value = scalarExpression.evaluate();
|
|
40650
|
-
return new ScalarLiteralValue(scalarExpression.definition, value,);
|
|
40651
|
-
}
|
|
40652
|
-
return scalarExpression;
|
|
40653
|
-
}
|
|
40654
|
-
function getScalarExpression(expression, schema, typeAffinity,) {
|
|
40655
|
-
switch (expression.type) {
|
|
40656
|
-
case 'Identifier':
|
|
40657
|
-
return convertIdentifier(expression, schema,);
|
|
40658
|
-
case 'LiteralValue':
|
|
40659
|
-
return convertLiteralValue(expression, typeAffinity,);
|
|
40660
|
-
case 'FunctionCall':
|
|
40661
|
-
return convertFunctionCall(expression, schema,);
|
|
40662
|
-
case 'Case':
|
|
40663
|
-
return convertCase(expression, schema, typeAffinity,);
|
|
40664
|
-
case 'UnaryOperation':
|
|
40665
|
-
return convertUnaryOperation(expression, schema,);
|
|
40666
|
-
case 'BinaryOperation':
|
|
40667
|
-
return convertBinaryOperation(expression, schema,);
|
|
40668
|
-
case 'TypeCast':
|
|
40669
|
-
return convertTypeCast(expression, schema,);
|
|
40670
|
-
default:
|
|
40671
|
-
throw new Error(`Unsupported expression: ${JSON.stringify(expression,)}`,);
|
|
40672
|
-
}
|
|
40673
|
-
}
|
|
40674
|
-
function convertIdentifier(expression, schema,) {
|
|
40675
|
-
return new ScalarIdentifier(schema, expression.name, expression.collection,);
|
|
40676
|
-
}
|
|
40677
|
-
function convertLiteralValue(expression, typeAffinity,) {
|
|
40678
|
-
var _a;
|
|
40679
|
-
const scalarExpression = getScalarLiteralValue(expression.value,);
|
|
40680
|
-
switch (typeAffinity == null ? void 0 : typeAffinity.type) {
|
|
40681
|
-
case 'boolean': {
|
|
40682
|
-
const value = toBoolean(scalarExpression.value,);
|
|
40683
|
-
return ScalarLiteralValue.fromBoolean(value,);
|
|
40684
|
-
}
|
|
40685
|
-
case 'date': {
|
|
40686
|
-
const value = toDate(scalarExpression.value,);
|
|
40687
|
-
return ScalarLiteralValue.fromDate(value,);
|
|
40688
|
-
}
|
|
40689
|
-
case 'enum': {
|
|
40690
|
-
if (((_a = scalarExpression.value) == null ? void 0 : _a.type) === 'string') {
|
|
40691
|
-
return ScalarLiteralValue.fromEnum(scalarExpression.value.value,);
|
|
40692
|
-
}
|
|
40693
|
-
return scalarExpression;
|
|
40694
|
-
}
|
|
40695
|
-
case 'number': {
|
|
40696
|
-
const value = toNumber2(scalarExpression.value,);
|
|
40697
|
-
return ScalarLiteralValue.fromNumber(value,);
|
|
40698
|
-
}
|
|
40699
|
-
case 'string': {
|
|
40700
|
-
const value = toString(scalarExpression.value,);
|
|
40701
|
-
return ScalarLiteralValue.fromString(value,);
|
|
40702
|
-
}
|
|
40703
|
-
}
|
|
40704
|
-
return scalarExpression;
|
|
40705
|
-
}
|
|
40706
|
-
function getScalarLiteralValue(value,) {
|
|
40707
|
-
if (isBoolean(value,)) {
|
|
40708
|
-
return ScalarLiteralValue.fromBoolean(value,);
|
|
40709
|
-
}
|
|
40710
|
-
if (isValidDate(value,)) {
|
|
40711
|
-
const string = value.toISOString();
|
|
40712
|
-
return ScalarLiteralValue.fromDate(string,);
|
|
40713
|
-
}
|
|
40714
|
-
if (isNumber2(value,)) {
|
|
40715
|
-
return ScalarLiteralValue.fromNumber(value,);
|
|
40716
|
-
}
|
|
40717
|
-
if (isString2(value,)) {
|
|
40718
|
-
return ScalarLiteralValue.fromString(value,);
|
|
40719
|
-
}
|
|
40720
|
-
return ScalarLiteralValue.fromNull();
|
|
40721
|
-
}
|
|
40722
|
-
function convertFunctionCall(expression, schema,) {
|
|
40723
|
-
const argumentExpressions = expression.arguments.map((argument) => {
|
|
40724
|
-
return convertExpression(argument, schema, void 0,);
|
|
40725
|
-
},);
|
|
40726
|
-
switch (expression.functionName) {
|
|
40727
|
-
case 'CONTAINS':
|
|
40728
|
-
return new ScalarFunctionCallContains(argumentExpressions,);
|
|
40729
|
-
case 'STARTS_WITH':
|
|
40730
|
-
return new ScalarFunctionCallStartsWith(argumentExpressions,);
|
|
40731
|
-
case 'ENDS_WITH':
|
|
40732
|
-
return new ScalarFunctionCallEndsWith(argumentExpressions,);
|
|
40733
|
-
default:
|
|
40734
|
-
throw new Error(`Unsupported function name: ${expression.functionName}`,);
|
|
40735
|
-
}
|
|
40736
|
-
}
|
|
40737
|
-
function convertCase(expression, schema, typeAffinity,) {
|
|
40738
|
-
const valueExpression = expression.value && convertExpression(expression.value, schema, void 0,);
|
|
40739
|
-
const valueTypeAffinity = expression.value && getExpressionType(expression.value, schema,);
|
|
40740
|
-
const conditions = expression.conditions.map((condition) => {
|
|
40741
|
-
const whenExpression = convertExpression(condition.when, schema, valueTypeAffinity,);
|
|
40742
|
-
const thenExpression = convertExpression(condition.then, schema, typeAffinity,);
|
|
40743
|
-
return new ScalarCaseCondition(whenExpression, thenExpression,);
|
|
40744
|
-
},);
|
|
40745
|
-
const elseExpression = expression.else && convertExpression(expression.else, schema, typeAffinity,);
|
|
40746
|
-
return new ScalarCase(valueExpression, conditions, elseExpression,);
|
|
40747
|
-
}
|
|
40748
|
-
function convertUnaryOperation(expression, schema,) {
|
|
40749
|
-
const valueExpression = convertExpression(expression.value, schema, void 0,);
|
|
40750
|
-
switch (expression.operator) {
|
|
40751
|
-
case 'not':
|
|
40752
|
-
return getScalarUnaryOperationNot(valueExpression,);
|
|
40753
|
-
default:
|
|
40754
|
-
throw new Error(`Unsupported unary operator: ${expression.operator}`,);
|
|
40755
|
-
}
|
|
40756
|
-
}
|
|
40757
|
-
function getScalarUnaryOperationNot(valueExpression,) {
|
|
40758
|
-
var _a;
|
|
40759
|
-
if (valueExpression instanceof ScalarUnaryOperationNot) {
|
|
40760
|
-
const innerExpression = valueExpression.valueExpression;
|
|
40761
|
-
if (((_a = innerExpression.definition) == null ? void 0 : _a.type) === 'boolean') {
|
|
40762
|
-
return innerExpression;
|
|
40763
|
-
}
|
|
40764
|
-
return new ScalarTypeCastBoolean(innerExpression,);
|
|
40765
|
-
}
|
|
40766
|
-
if (valueExpression instanceof ScalarComparisonEquals) {
|
|
40767
|
-
const {
|
|
40768
|
-
leftExpression,
|
|
40769
|
-
rightExpression,
|
|
40770
|
-
} = valueExpression;
|
|
40771
|
-
return new ScalarComparisonNotEquals(leftExpression, rightExpression,);
|
|
40772
|
-
}
|
|
40773
|
-
if (valueExpression instanceof ScalarComparisonNotEquals) {
|
|
40774
|
-
const {
|
|
40775
|
-
leftExpression,
|
|
40776
|
-
rightExpression,
|
|
40777
|
-
} = valueExpression;
|
|
40778
|
-
return new ScalarComparisonEquals(leftExpression, rightExpression,);
|
|
40779
|
-
}
|
|
40780
|
-
if (valueExpression instanceof ScalarComparisonLessThan) {
|
|
40781
|
-
const {
|
|
40782
|
-
leftExpression,
|
|
40783
|
-
rightExpression,
|
|
40784
|
-
} = valueExpression;
|
|
40785
|
-
return new ScalarComparisonGreaterThanOrEqual(leftExpression, rightExpression,);
|
|
40786
|
-
}
|
|
40787
|
-
if (valueExpression instanceof ScalarComparisonLessThanOrEqual) {
|
|
40788
|
-
const {
|
|
40789
|
-
leftExpression,
|
|
40790
|
-
rightExpression,
|
|
40791
|
-
} = valueExpression;
|
|
40792
|
-
return new ScalarComparisonGreaterThan(leftExpression, rightExpression,);
|
|
40793
|
-
}
|
|
40794
|
-
if (valueExpression instanceof ScalarComparisonGreaterThan) {
|
|
40795
|
-
const {
|
|
40796
|
-
leftExpression,
|
|
40797
|
-
rightExpression,
|
|
40798
|
-
} = valueExpression;
|
|
40799
|
-
return new ScalarComparisonLessThanOrEqual(leftExpression, rightExpression,);
|
|
40800
|
-
}
|
|
40801
|
-
if (valueExpression instanceof ScalarComparisonGreaterThanOrEqual) {
|
|
40802
|
-
const {
|
|
40803
|
-
leftExpression,
|
|
40804
|
-
rightExpression,
|
|
40805
|
-
} = valueExpression;
|
|
40806
|
-
return new ScalarComparisonLessThan(leftExpression, rightExpression,);
|
|
40807
|
-
}
|
|
40808
|
-
if (valueExpression instanceof ScalarLogicalOperationAnd) {
|
|
40809
|
-
const {
|
|
40810
|
-
operandExpressions,
|
|
40811
|
-
} = valueExpression;
|
|
40812
|
-
const notExpressions = operandExpressions.map(getScalarUnaryOperationNot,);
|
|
40813
|
-
return new ScalarLogicalOperationOr(notExpressions,);
|
|
40814
|
-
}
|
|
40815
|
-
if (valueExpression instanceof ScalarLogicalOperationAnd) {
|
|
40816
|
-
const {
|
|
40817
|
-
operandExpressions,
|
|
40818
|
-
} = valueExpression;
|
|
40819
|
-
const notExpressions = operandExpressions.map(getScalarUnaryOperationNot,);
|
|
40820
|
-
return new ScalarLogicalOperationAnd(notExpressions,);
|
|
40821
|
-
}
|
|
40822
|
-
return new ScalarUnaryOperationNot(valueExpression,);
|
|
40823
|
-
}
|
|
40824
|
-
function getTypeAffinityForBinaryOperation(expression, schema,) {
|
|
40825
|
-
if (expression.operator !== 'and' && expression.operator !== 'or') {
|
|
40826
|
-
return getExpressionType(expression.left, schema,) || getExpressionType(expression.right, schema,);
|
|
40827
|
-
}
|
|
40828
|
-
}
|
|
40829
|
-
function convertBinaryOperation(expression, schema,) {
|
|
40830
|
-
const typeAffinity = getTypeAffinityForBinaryOperation(expression, schema,);
|
|
40831
|
-
const leftExpression = convertExpression(expression.left, schema, typeAffinity,);
|
|
40832
|
-
const rightExpression = convertExpression(expression.right, schema, typeAffinity,);
|
|
40833
|
-
switch (expression.operator) {
|
|
40834
|
-
case 'and':
|
|
40835
|
-
return getScalarLogicalOperationAnd(leftExpression, rightExpression,);
|
|
40836
|
-
case 'or':
|
|
40837
|
-
return getScalarLogicalOperationOr(leftExpression, rightExpression,);
|
|
40838
|
-
case '==':
|
|
40839
|
-
return getScalarComparisonEquals(leftExpression, rightExpression,);
|
|
40840
|
-
case '!=':
|
|
40841
|
-
return getScalarComparisonNotEquals(leftExpression, rightExpression,);
|
|
40842
|
-
case '<':
|
|
40843
|
-
return getScalarComparisonLessThan(leftExpression, rightExpression,);
|
|
40844
|
-
case '<=':
|
|
40845
|
-
return getScalarComparisonLessThanOrEqual(leftExpression, rightExpression,);
|
|
40846
|
-
case '>':
|
|
40847
|
-
return getScalarComparisonGreaterThan(leftExpression, rightExpression,);
|
|
40848
|
-
case '>=':
|
|
40849
|
-
return getScalarComparisonGreaterThanOrEqual(leftExpression, rightExpression,);
|
|
40850
|
-
default:
|
|
40851
|
-
throw new Error(`Unsupported binary operator: ${expression.operator}`,);
|
|
40852
|
-
}
|
|
40853
|
-
}
|
|
40854
|
-
function getScalarLogicalOperationAnd(leftExpression, rightExpression,) {
|
|
40855
|
-
const operandExpressions = [];
|
|
40856
|
-
if (leftExpression instanceof ScalarLogicalOperationAnd) {
|
|
40857
|
-
operandExpressions.push(...leftExpression.operandExpressions,);
|
|
40858
|
-
} else {
|
|
40859
|
-
operandExpressions.push(leftExpression,);
|
|
40860
|
-
}
|
|
40861
|
-
if (rightExpression instanceof ScalarLogicalOperationAnd) {
|
|
40862
|
-
operandExpressions.push(...rightExpression.operandExpressions,);
|
|
40863
|
-
} else {
|
|
40864
|
-
operandExpressions.push(rightExpression,);
|
|
40865
|
-
}
|
|
40866
|
-
return new ScalarLogicalOperationAnd(operandExpressions,);
|
|
40867
|
-
}
|
|
40868
|
-
function getScalarLogicalOperationOr(leftExpression, rightExpression,) {
|
|
40869
|
-
const operandExpressions = [];
|
|
40870
|
-
if (leftExpression instanceof ScalarLogicalOperationOr) {
|
|
40871
|
-
operandExpressions.push(...leftExpression.operandExpressions,);
|
|
40872
|
-
} else {
|
|
40873
|
-
operandExpressions.push(leftExpression,);
|
|
40874
|
-
}
|
|
40875
|
-
if (rightExpression instanceof ScalarLogicalOperationOr) {
|
|
40876
|
-
operandExpressions.push(...rightExpression.operandExpressions,);
|
|
40877
|
-
} else {
|
|
40878
|
-
operandExpressions.push(rightExpression,);
|
|
40879
|
-
}
|
|
40880
|
-
return new ScalarLogicalOperationOr(operandExpressions,);
|
|
40881
|
-
}
|
|
40882
|
-
function getScalarComparisonEquals(leftExpression, rightExpression,) {
|
|
40883
|
-
const isLeftIdentifier = leftExpression instanceof ScalarIdentifier;
|
|
40884
|
-
const isRightIdentifier = rightExpression instanceof ScalarIdentifier;
|
|
40885
|
-
if (isRightIdentifier && !isLeftIdentifier) {
|
|
40886
|
-
return new ScalarComparisonEquals(rightExpression, leftExpression,);
|
|
40887
|
-
}
|
|
40888
|
-
return new ScalarComparisonEquals(leftExpression, rightExpression,);
|
|
40889
|
-
}
|
|
40890
|
-
function getScalarComparisonNotEquals(leftExpression, rightExpression,) {
|
|
40891
|
-
const isLeftIdentifier = leftExpression instanceof ScalarIdentifier;
|
|
40892
|
-
const isRightIdentifier = rightExpression instanceof ScalarIdentifier;
|
|
40893
|
-
if (isRightIdentifier && !isLeftIdentifier) {
|
|
40894
|
-
return new ScalarComparisonNotEquals(rightExpression, leftExpression,);
|
|
40895
|
-
}
|
|
40896
|
-
return new ScalarComparisonNotEquals(leftExpression, rightExpression,);
|
|
40897
|
-
}
|
|
40898
|
-
function getScalarComparisonLessThan(leftExpression, rightExpression,) {
|
|
40899
|
-
const isLeftIdentifier = leftExpression instanceof ScalarIdentifier;
|
|
40900
|
-
const isRightIdentifier = rightExpression instanceof ScalarIdentifier;
|
|
40901
|
-
if (isRightIdentifier && !isLeftIdentifier) {
|
|
40902
|
-
return new ScalarComparisonGreaterThan(rightExpression, leftExpression,);
|
|
40903
|
-
}
|
|
40904
|
-
return new ScalarComparisonLessThan(leftExpression, rightExpression,);
|
|
40905
|
-
}
|
|
40906
|
-
function getScalarComparisonLessThanOrEqual(leftExpression, rightExpression,) {
|
|
40907
|
-
const isLeftIdentifier = leftExpression instanceof ScalarIdentifier;
|
|
40908
|
-
const isRightIdentifier = rightExpression instanceof ScalarIdentifier;
|
|
40909
|
-
if (isRightIdentifier && !isLeftIdentifier) {
|
|
40910
|
-
return new ScalarComparisonGreaterThanOrEqual(rightExpression, leftExpression,);
|
|
40911
|
-
}
|
|
40912
|
-
return new ScalarComparisonLessThanOrEqual(leftExpression, rightExpression,);
|
|
40913
|
-
}
|
|
40914
|
-
function getScalarComparisonGreaterThan(leftExpression, rightExpression,) {
|
|
40915
|
-
const isLeftIdentifier = leftExpression instanceof ScalarIdentifier;
|
|
40916
|
-
const isRightIdentifier = rightExpression instanceof ScalarIdentifier;
|
|
40917
|
-
if (isRightIdentifier && !isLeftIdentifier) {
|
|
40918
|
-
return new ScalarComparisonLessThan(rightExpression, leftExpression,);
|
|
40919
|
-
}
|
|
40920
|
-
return new ScalarComparisonGreaterThan(leftExpression, rightExpression,);
|
|
40921
|
-
}
|
|
40922
|
-
function getScalarComparisonGreaterThanOrEqual(leftExpression, rightExpression,) {
|
|
40923
|
-
const isLeftIdentifier = leftExpression instanceof ScalarIdentifier;
|
|
40924
|
-
const isRightIdentifier = rightExpression instanceof ScalarIdentifier;
|
|
40925
|
-
if (isRightIdentifier && !isLeftIdentifier) {
|
|
40926
|
-
return new ScalarComparisonLessThanOrEqual(rightExpression, leftExpression,);
|
|
40927
|
-
}
|
|
40928
|
-
return new ScalarComparisonGreaterThanOrEqual(leftExpression, rightExpression,);
|
|
40929
|
-
}
|
|
40930
|
-
function convertTypeCast(expression, schema,) {
|
|
40931
|
-
const valueExpression = convertExpression(expression.value, schema, void 0,);
|
|
40932
|
-
switch (expression.dataType) {
|
|
40933
|
-
case 'BOOLEAN':
|
|
40934
|
-
return getScalarTypeCastBoolean(valueExpression,);
|
|
40935
|
-
case 'DATE':
|
|
40936
|
-
return getScalarTypeCastDate(valueExpression,);
|
|
40937
|
-
case 'NUMBER':
|
|
40938
|
-
return getScalarTypeCastNumber(valueExpression,);
|
|
40939
|
-
case 'STRING':
|
|
40940
|
-
return getScalarTypeCastString(valueExpression,);
|
|
40941
|
-
default:
|
|
40942
|
-
throw new Error(`Unsupported data type: ${expression.dataType}`,);
|
|
40943
|
-
}
|
|
40944
|
-
}
|
|
40945
|
-
function getScalarTypeCastBoolean(valueExpression,) {
|
|
40946
|
-
var _a;
|
|
40947
|
-
if (((_a = valueExpression.definition) == null ? void 0 : _a.type) === 'boolean') {
|
|
40948
|
-
return valueExpression;
|
|
40949
|
-
}
|
|
40950
|
-
return new ScalarTypeCastBoolean(valueExpression,);
|
|
40951
|
-
}
|
|
40952
|
-
function getScalarTypeCastDate(valueExpression,) {
|
|
40953
|
-
var _a;
|
|
40954
|
-
if (((_a = valueExpression.definition) == null ? void 0 : _a.type) === 'date') {
|
|
40955
|
-
return valueExpression;
|
|
40956
|
-
}
|
|
40957
|
-
return new ScalarTypeCastDate(valueExpression,);
|
|
40958
|
-
}
|
|
40959
|
-
function getScalarTypeCastNumber(valueExpression,) {
|
|
40960
|
-
var _a;
|
|
40961
|
-
if (((_a = valueExpression.definition) == null ? void 0 : _a.type) === 'number') {
|
|
40962
|
-
return valueExpression;
|
|
40963
|
-
}
|
|
40964
|
-
return new ScalarTypeCastNumber(valueExpression,);
|
|
40965
|
-
}
|
|
40966
|
-
function getScalarTypeCastString(valueExpression,) {
|
|
40967
|
-
var _a;
|
|
40968
|
-
if (((_a = valueExpression.definition) == null ? void 0 : _a.type) === 'string') {
|
|
40969
|
-
return valueExpression;
|
|
40970
|
-
}
|
|
40971
|
-
return new ScalarTypeCastString(valueExpression,);
|
|
40972
|
-
}
|
|
40973
|
-
function getExpressionType(expression, schema,) {
|
|
40974
|
-
switch (expression.type) {
|
|
40975
|
-
case 'Identifier':
|
|
40976
|
-
return getIdentifierType(expression, schema,);
|
|
40977
|
-
case 'LiteralValue':
|
|
40978
|
-
return void 0;
|
|
40979
|
-
case 'FunctionCall':
|
|
40980
|
-
return getFunctionCallType(expression,);
|
|
40981
|
-
case 'Case':
|
|
40982
|
-
return getCaseType(expression, schema,);
|
|
40983
|
-
case 'UnaryOperation':
|
|
40984
|
-
return getUnaryOperationType(expression,);
|
|
40985
|
-
case 'BinaryOperation':
|
|
40986
|
-
return getBinaryOperationType(expression,);
|
|
40987
|
-
case 'TypeCast':
|
|
40988
|
-
return getTypeCastType(expression,);
|
|
40989
|
-
default:
|
|
40990
|
-
throw new Error(`Unsupported expression: ${JSON.stringify(expression,)}`,);
|
|
40991
|
-
}
|
|
40992
|
-
}
|
|
40993
|
-
function getIdentifierType(expression, schema,) {
|
|
40994
|
-
return schema[expression.name];
|
|
40995
|
-
}
|
|
40996
|
-
function getFunctionCallType(expression,) {
|
|
40997
|
-
switch (expression.functionName) {
|
|
40998
|
-
case 'CONTAINS':
|
|
40999
|
-
return ScalarFunctionCallContains.getDefinition();
|
|
41000
|
-
case 'STARTS_WITH':
|
|
41001
|
-
return ScalarFunctionCallStartsWith.getDefinition();
|
|
41002
|
-
case 'ENDS_WITH':
|
|
41003
|
-
return ScalarFunctionCallEndsWith.getDefinition();
|
|
41004
|
-
default:
|
|
41005
|
-
throw new Error(`Unsupported function name: ${expression.functionName}`,);
|
|
41006
|
-
}
|
|
41007
|
-
}
|
|
41008
|
-
function getCaseType(expression, schema,) {
|
|
41009
|
-
const definitions = [];
|
|
41010
|
-
for (const condition of expression.conditions) {
|
|
41011
|
-
const type = getExpressionType(condition.then, schema,);
|
|
41012
|
-
if (!isUndefined(type,)) definitions.push(type,);
|
|
41013
|
-
}
|
|
41014
|
-
if (expression.else) {
|
|
41015
|
-
const type = getExpressionType(expression.else, schema,);
|
|
41016
|
-
if (!isUndefined(type,)) definitions.push(type,);
|
|
41017
|
-
}
|
|
41018
|
-
return ScalarCase.getDefinition(definitions,) ?? void 0;
|
|
41019
|
-
}
|
|
41020
|
-
function getUnaryOperationType(expression,) {
|
|
41021
|
-
switch (expression.operator) {
|
|
41022
|
-
case 'not':
|
|
41023
|
-
return ScalarUnaryOperationNot.getDefinition();
|
|
41024
|
-
default:
|
|
41025
|
-
throw new Error(`Unsupported unary operator: ${expression.operator}`,);
|
|
41026
|
-
}
|
|
41027
|
-
}
|
|
41028
|
-
function getBinaryOperationType(expression,) {
|
|
41029
|
-
switch (expression.operator) {
|
|
41030
|
-
case 'and':
|
|
41031
|
-
case 'or':
|
|
41032
|
-
return ScalarLogicalOperation.getDefinition();
|
|
41033
|
-
case '==':
|
|
41034
|
-
case '!=':
|
|
41035
|
-
case '<':
|
|
41036
|
-
case '<=':
|
|
41037
|
-
case '>':
|
|
41038
|
-
case '>=':
|
|
41039
|
-
return ScalarComparison.getDefinition();
|
|
41040
|
-
default:
|
|
41041
|
-
throw new Error(`Unsupported binary operator: ${expression.operator}`,);
|
|
41042
|
-
}
|
|
41043
|
-
}
|
|
41044
|
-
function getTypeCastType(expression,) {
|
|
41045
|
-
switch (expression.dataType) {
|
|
41046
|
-
case 'BOOLEAN':
|
|
41047
|
-
return ScalarTypeCastBoolean.getDefinition();
|
|
41048
|
-
case 'DATE':
|
|
41049
|
-
return ScalarTypeCastDate.getDefinition();
|
|
41050
|
-
case 'NUMBER':
|
|
41051
|
-
return ScalarTypeCastNumber.getDefinition();
|
|
41052
|
-
case 'STRING':
|
|
41053
|
-
return ScalarTypeCastString.getDefinition();
|
|
41054
|
-
default:
|
|
41055
|
-
throw new Error(`Unsupported data type: ${expression.dataType}`,);
|
|
41056
|
-
}
|
|
41057
|
-
}
|
|
41058
|
-
function stringifyExecutionTime(self2, total,) {
|
|
41059
|
-
return `(self: ${self2}ms${total ? `, total: ${total}ms` : ''})`;
|
|
41060
|
-
}
|
|
41061
|
-
function stringifyItems(items,) {
|
|
41062
|
-
return `(items: ${items})`;
|
|
41063
|
-
}
|
|
41064
|
-
var QueryPlan = class {
|
|
41065
|
-
constructor() {
|
|
41066
|
-
__publicField(this, 'executionTime', 0,);
|
|
41067
|
-
__publicField(this, 'itemCount', 0,);
|
|
41068
|
-
}
|
|
41069
|
-
async execute() {
|
|
41070
|
-
const start = performance.now();
|
|
41071
|
-
const result = await this._execute();
|
|
41072
|
-
this.executionTime = performance.now() - start;
|
|
41073
|
-
this.itemCount = result.length;
|
|
41074
|
-
return result;
|
|
41075
|
-
}
|
|
41076
|
-
};
|
|
41077
|
-
var ScanCollectionPlan = class extends QueryPlan {
|
|
41078
|
-
constructor(collection, alias,) {
|
|
41079
|
-
super();
|
|
41080
|
-
this.collection = collection;
|
|
41081
|
-
this.alias = alias;
|
|
41082
|
-
}
|
|
41083
|
-
inspect() {
|
|
41084
|
-
return {
|
|
41085
|
-
label: `ScanCollectionPlan ${stringifyExecutionTime(this.executionTime,)} ${stringifyItems(this.itemCount,)}`,
|
|
41086
|
-
};
|
|
41087
|
-
}
|
|
41088
|
-
async _execute() {
|
|
41089
|
-
const items = await this.collection.scanItems();
|
|
41090
|
-
if (isUndefined(this.alias,)) return items;
|
|
41091
|
-
return items.map((item) => {
|
|
41092
|
-
const data2 = {
|
|
41093
|
-
...item.data,
|
|
41094
|
-
};
|
|
41095
|
-
const dataEntries = Object.entries(data2,);
|
|
41096
|
-
for (const [key7, value,] of dataEntries) {
|
|
41097
|
-
data2[`${this.alias}_${key7}`] = value;
|
|
41098
|
-
}
|
|
41099
|
-
return {
|
|
41100
|
-
pointer: item.pointer,
|
|
41101
|
-
data: data2,
|
|
41102
|
-
};
|
|
41103
|
-
},);
|
|
41104
|
-
}
|
|
41105
|
-
};
|
|
41106
|
-
var LeftJoinPlan = class extends QueryPlan {
|
|
41107
|
-
constructor(leftPlan, rightPlan, constraint,) {
|
|
41108
|
-
super();
|
|
41109
|
-
this.leftPlan = leftPlan;
|
|
41110
|
-
this.rightPlan = rightPlan;
|
|
41111
|
-
this.constraint = constraint;
|
|
41112
|
-
}
|
|
41113
|
-
inspect() {
|
|
41114
|
-
const childPlansTime = Math.max(this.leftPlan.executionTime ?? 0, this.rightPlan.executionTime ?? 0,);
|
|
41115
|
-
return {
|
|
41116
|
-
label: `LeftJoinPlan ${stringifyExecutionTime(this.executionTime - childPlansTime, this.executionTime,)} ${
|
|
41117
|
-
stringifyItems(this.itemCount,)
|
|
41118
|
-
}`,
|
|
41119
|
-
nodes: [this.leftPlan.inspect(), this.rightPlan.inspect(),],
|
|
41120
|
-
};
|
|
41121
|
-
}
|
|
41122
|
-
async _execute() {
|
|
41123
|
-
var _a;
|
|
41124
|
-
const leftItems = await this.leftPlan.execute();
|
|
41125
|
-
const rightItems = await this.rightPlan.execute();
|
|
41126
|
-
const result = [];
|
|
41127
|
-
for (const leftItem of leftItems) {
|
|
41128
|
-
let hasMatch = false;
|
|
41129
|
-
for (const rightItem of rightItems) {
|
|
41130
|
-
const combinedItem = {
|
|
41131
|
-
pointer: leftItem.pointer,
|
|
41132
|
-
data: {
|
|
41133
|
-
...leftItem.data,
|
|
41134
|
-
...rightItem.data,
|
|
41135
|
-
},
|
|
41136
|
-
};
|
|
41137
|
-
if ((_a = this.constraint.evaluate(combinedItem,)) == null ? void 0 : _a.value) {
|
|
41138
|
-
result.push(combinedItem,);
|
|
41139
|
-
hasMatch = true;
|
|
41140
|
-
}
|
|
41141
|
-
}
|
|
41142
|
-
if (!hasMatch) {
|
|
41143
|
-
result.push(leftItem,);
|
|
41144
|
-
}
|
|
41145
|
-
}
|
|
41146
|
-
return result;
|
|
41147
|
-
}
|
|
41148
|
-
};
|
|
41149
|
-
var LookupIndexPlan = class extends QueryPlan {
|
|
41150
|
-
constructor(index, query,) {
|
|
41151
|
-
super();
|
|
41152
|
-
this.index = index;
|
|
41153
|
-
this.query = query;
|
|
41154
|
-
}
|
|
41155
|
-
inspect() {
|
|
41156
|
-
const queries = [];
|
|
41157
|
-
const stringifyDatabaseLookupType = (indexLookup) => {
|
|
41158
|
-
switch (indexLookup.type) {
|
|
41159
|
-
case 'All':
|
|
41160
|
-
return indexLookup.type;
|
|
41161
|
-
case 'Equals':
|
|
41162
|
-
case 'NotEquals':
|
|
41163
|
-
case 'LessThan':
|
|
41164
|
-
case 'GreaterThan':
|
|
41165
|
-
case 'Contains':
|
|
41166
|
-
case 'StartsWith':
|
|
41167
|
-
case 'EndsWith':
|
|
41168
|
-
return `${indexLookup.type} ${DatabaseValue.stringify(indexLookup.value,)}`;
|
|
41169
|
-
default: {
|
|
41170
|
-
assertNever(indexLookup,);
|
|
41171
|
-
}
|
|
41172
|
-
}
|
|
41173
|
-
};
|
|
41174
|
-
for (let i = 0; i < this.index.fields.length; i++) {
|
|
41175
|
-
const field = this.index.fields[i];
|
|
41176
|
-
const query = this.query[i];
|
|
41177
|
-
if (!field || field.type !== 'Identifier') continue;
|
|
41178
|
-
if (!query || query.type === 'All') continue;
|
|
41179
|
-
queries.push(`${field.name} ${stringifyDatabaseLookupType(query,)}`,);
|
|
41180
|
-
}
|
|
41181
|
-
return {
|
|
41182
|
-
label: `LookupIndexPlan(${queries.join(', ',)}) ${stringifyExecutionTime(this.executionTime,)} ${stringifyItems(this.itemCount,)}`,
|
|
41183
|
-
};
|
|
41184
|
-
}
|
|
41185
|
-
async _execute() {
|
|
41186
|
-
return this.index.lookupItems(this.query,);
|
|
41187
|
-
}
|
|
41188
|
-
};
|
|
41189
|
-
var UnionPlan = class extends QueryPlan {
|
|
41190
|
-
constructor(childPlans,) {
|
|
41191
|
-
super();
|
|
41192
|
-
this.childPlans = childPlans;
|
|
41193
|
-
}
|
|
41194
|
-
inspect() {
|
|
41195
|
-
const childPlansTime = Math.max(...this.childPlans.map((childPlan) => childPlan.executionTime ?? 0),);
|
|
41196
|
-
return {
|
|
41197
|
-
label: `UnionPlan ${stringifyExecutionTime(this.executionTime - childPlansTime, this.executionTime,)} ${
|
|
41198
|
-
stringifyItems(this.itemCount,)
|
|
41199
|
-
}`,
|
|
41200
|
-
nodes: this.childPlans.map((childPlan) => childPlan.inspect()),
|
|
41201
|
-
};
|
|
41202
|
-
}
|
|
41203
|
-
async _execute() {
|
|
41204
|
-
const childItemMaps = await Promise.all(this.childPlans.map(async (childPlan) => {
|
|
41205
|
-
const items = await childPlan.execute();
|
|
41206
|
-
return new DatabaseItemMap(items,);
|
|
41207
|
-
},),);
|
|
41208
|
-
let result;
|
|
41209
|
-
for (const itemMap of childItemMaps) {
|
|
41210
|
-
if (result) {
|
|
41211
|
-
result = result.union(itemMap,);
|
|
41212
|
-
} else {
|
|
41213
|
-
result = itemMap;
|
|
41214
|
-
}
|
|
41215
|
-
}
|
|
41216
|
-
return (result == null ? void 0 : result.items()) ?? [];
|
|
41217
|
-
}
|
|
41218
|
-
};
|
|
41219
|
-
var IntersectionPlan = class extends QueryPlan {
|
|
41220
|
-
constructor(childPlans,) {
|
|
41221
|
-
super();
|
|
41222
|
-
this.childPlans = childPlans;
|
|
41223
|
-
}
|
|
41224
|
-
inspect() {
|
|
41225
|
-
const childPlansTime = Math.max(...this.childPlans.map((childPlan) => childPlan.executionTime ?? 0),);
|
|
41226
|
-
return {
|
|
41227
|
-
label: `IntersectionPlan ${stringifyExecutionTime(this.executionTime - childPlansTime, this.executionTime,)} ${
|
|
41228
|
-
stringifyItems(this.itemCount,)
|
|
41229
|
-
} ${stringifyItems(this.itemCount,)}`,
|
|
41230
|
-
nodes: this.childPlans.map((childPlan) => childPlan.inspect()),
|
|
41231
|
-
};
|
|
41232
|
-
}
|
|
41233
|
-
async _execute() {
|
|
41234
|
-
const childItemMaps = await Promise.all(this.childPlans.map(async (childPlan) => {
|
|
41235
|
-
const items = await childPlan.execute();
|
|
41236
|
-
return new DatabaseItemMap(items,);
|
|
41237
|
-
},),);
|
|
41238
|
-
let result;
|
|
41239
|
-
for (const itemMap of childItemMaps) {
|
|
41240
|
-
if (result) {
|
|
41241
|
-
result = result.intersection(itemMap,);
|
|
41242
|
-
} else {
|
|
41243
|
-
result = itemMap;
|
|
41244
|
-
}
|
|
41245
|
-
}
|
|
41246
|
-
return (result == null ? void 0 : result.items()) ?? [];
|
|
41247
|
-
}
|
|
41248
|
-
};
|
|
41249
|
-
var ResolveItemsPlan = class extends QueryPlan {
|
|
41250
|
-
constructor(childPlan, collection, richTextResolver, select,) {
|
|
41251
|
-
super();
|
|
41252
|
-
this.childPlan = childPlan;
|
|
41253
|
-
this.collection = collection;
|
|
41254
|
-
this.richTextResolver = richTextResolver;
|
|
41255
|
-
this.select = select;
|
|
41256
|
-
}
|
|
41257
|
-
inspect() {
|
|
41258
|
-
return {
|
|
41259
|
-
label: `ResolveItemsPlan ${stringifyExecutionTime(this.executionTime - this.childPlan.executionTime, this.executionTime,)} ${
|
|
41260
|
-
stringifyItems(this.itemCount,)
|
|
41261
|
-
}`,
|
|
41262
|
-
nodes: [this.childPlan.inspect(),],
|
|
41263
|
-
};
|
|
41264
|
-
}
|
|
41265
|
-
async _execute() {
|
|
41266
|
-
const childItems = await this.childPlan.execute();
|
|
41267
|
-
const childPointers = childItems.map((item) => item.pointer);
|
|
41268
|
-
for (const item of childItems) {
|
|
41269
|
-
for (const expression of this.select) {
|
|
41270
|
-
if (expression.type !== 'Identifier') continue;
|
|
41271
|
-
const value = item.data[expression.name];
|
|
41272
|
-
if ((value == null ? void 0 : value.type) !== 'richtext') continue;
|
|
41273
|
-
void this.richTextResolver.resolve(expression.name, value.value,);
|
|
41274
|
-
}
|
|
41275
|
-
}
|
|
41276
|
-
return this.collection.resolveItems(childPointers,);
|
|
41277
|
-
}
|
|
41278
|
-
};
|
|
41279
|
-
var FilterItemsPlan = class extends QueryPlan {
|
|
41280
|
-
constructor(childPlan, filterExpression,) {
|
|
41281
|
-
super();
|
|
41282
|
-
this.childPlan = childPlan;
|
|
41283
|
-
this.filterExpression = filterExpression;
|
|
41284
|
-
}
|
|
41285
|
-
inspect() {
|
|
41286
|
-
return {
|
|
41287
|
-
label: `FilterItemsPlan(${this.filterExpression.stringify()}) ${
|
|
41288
|
-
stringifyExecutionTime(this.executionTime - this.childPlan.executionTime, this.executionTime,)
|
|
41289
|
-
} ${stringifyItems(this.itemCount,)} ${stringifyItems(this.itemCount,)}`,
|
|
41290
|
-
nodes: [this.childPlan.inspect(),],
|
|
41291
|
-
};
|
|
41292
|
-
}
|
|
41293
|
-
async _execute() {
|
|
41294
|
-
const childItems = await this.childPlan.execute();
|
|
41295
|
-
return childItems.filter((item) => {
|
|
41296
|
-
const result = this.filterExpression.evaluate(item,);
|
|
41297
|
-
return toBoolean(result,);
|
|
41298
|
-
},);
|
|
41299
|
-
}
|
|
41300
|
-
};
|
|
41301
|
-
var SortItemsPlan = class extends QueryPlan {
|
|
41302
|
-
constructor(childPlan, orderExpressions, collection,) {
|
|
41303
|
-
super();
|
|
41304
|
-
this.childPlan = childPlan;
|
|
41305
|
-
this.orderExpressions = orderExpressions;
|
|
41306
|
-
this.collection = collection;
|
|
41307
|
-
}
|
|
41308
|
-
inspect() {
|
|
41309
|
-
const order = this.orderExpressions.map((expression) => `${expression.expression.stringify()} ${expression.direction.toUpperCase()}`)
|
|
41310
|
-
.join(', ',);
|
|
41311
|
-
return {
|
|
41312
|
-
label: `SortItemsPlan(${order}) ${stringifyExecutionTime(this.executionTime - this.childPlan.executionTime, this.executionTime,)} ${
|
|
41313
|
-
stringifyItems(this.itemCount,)
|
|
41314
|
-
}`,
|
|
41315
|
-
nodes: [this.childPlan.inspect(),],
|
|
41316
|
-
};
|
|
41317
|
-
}
|
|
41318
|
-
async _execute() {
|
|
41319
|
-
const childItems = await this.childPlan.execute();
|
|
41320
|
-
return childItems.sort((leftItem, rightItem,) => {
|
|
41321
|
-
const leftSortItem = {
|
|
41322
|
-
...leftItem,
|
|
41323
|
-
data: {},
|
|
41324
|
-
};
|
|
41325
|
-
const rightSortItem = {
|
|
41326
|
-
...rightItem,
|
|
41327
|
-
data: {},
|
|
41328
|
-
};
|
|
41329
|
-
for (
|
|
41330
|
-
const {
|
|
41331
|
-
expression,
|
|
41332
|
-
direction,
|
|
41333
|
-
collation: collation10,
|
|
41334
|
-
} of this.orderExpressions
|
|
41335
|
-
) {
|
|
41336
|
-
const isAscending = direction === 'asc';
|
|
41337
|
-
if (expression instanceof ScalarIdentifier && expression.name === INDEX_IDENTIFIER) {
|
|
41338
|
-
const order = this.collection.compareItems(leftSortItem, rightSortItem,);
|
|
41339
|
-
return isAscending ? order : -order;
|
|
41340
|
-
}
|
|
41341
|
-
const left = expression.evaluate(leftItem,);
|
|
41342
|
-
const right = expression.evaluate(rightItem,);
|
|
41343
|
-
if (DatabaseValue.equal(left, right, collation10,)) {
|
|
41344
|
-
continue;
|
|
41345
|
-
}
|
|
41346
|
-
if (DatabaseValue.lessThan(left, right, collation10,) || isNullish2(left,)) {
|
|
41347
|
-
return isAscending ? -1 : 1;
|
|
41348
|
-
}
|
|
41349
|
-
if (DatabaseValue.greaterThan(left, right, collation10,) || isNullish2(right,)) {
|
|
41350
|
-
return isAscending ? 1 : -1;
|
|
41351
|
-
}
|
|
41352
|
-
throw new Error('Invalid comparison result.',);
|
|
41353
|
-
}
|
|
41354
|
-
return this.collection.compareItems(leftSortItem, rightSortItem,);
|
|
41355
|
-
},);
|
|
41356
|
-
}
|
|
41357
|
-
};
|
|
41358
|
-
var ScalarOrderExpression = class {
|
|
41359
|
-
constructor(expression, direction, collation10,) {
|
|
41360
|
-
this.expression = expression;
|
|
41361
|
-
this.direction = direction;
|
|
41362
|
-
this.collation = collation10;
|
|
41363
|
-
}
|
|
41364
|
-
};
|
|
41365
|
-
var SliceItemsPlan = class extends QueryPlan {
|
|
41366
|
-
constructor(childPlan, offsetExpression, limitExpression,) {
|
|
41367
|
-
super();
|
|
41368
|
-
this.childPlan = childPlan;
|
|
41369
|
-
this.offsetExpression = offsetExpression;
|
|
41370
|
-
this.limitExpression = limitExpression;
|
|
41371
|
-
}
|
|
41372
|
-
inspect() {
|
|
41373
|
-
var _a, _b;
|
|
41374
|
-
return {
|
|
41375
|
-
label: `SliceItemsPlan(LIMIT ${((_a = this.limitExpression) == null ? void 0 : _a.stringify()) ?? 'Infinity'}, OFFSET ${
|
|
41376
|
-
((_b = this.offsetExpression) == null ? void 0 : _b.stringify()) ?? '0'
|
|
41377
|
-
}) ${stringifyExecutionTime(this.executionTime - this.childPlan.executionTime, this.executionTime,)} ${
|
|
41378
|
-
stringifyItems(this.itemCount,)
|
|
41379
|
-
}`,
|
|
41380
|
-
nodes: [this.childPlan.inspect(),],
|
|
41381
|
-
};
|
|
41382
|
-
}
|
|
41383
|
-
getOffset() {
|
|
41384
|
-
var _a;
|
|
41385
|
-
const value = (_a = this.offsetExpression) == null ? void 0 : _a.evaluate();
|
|
41386
|
-
if (isNullish2(value,) || value.type !== 'number') return;
|
|
41387
|
-
return value.value;
|
|
41388
|
-
}
|
|
41389
|
-
getLimit() {
|
|
41390
|
-
var _a;
|
|
41391
|
-
const value = (_a = this.limitExpression) == null ? void 0 : _a.evaluate();
|
|
41392
|
-
if (isNullish2(value,) || value.type !== 'number') return;
|
|
41393
|
-
return value.value;
|
|
41394
|
-
}
|
|
41395
|
-
async _execute() {
|
|
41396
|
-
const childItems = await this.childPlan.execute();
|
|
41397
|
-
const offset = this.getOffset() ?? 0;
|
|
41398
|
-
const limit = this.getLimit() ?? Infinity;
|
|
41399
|
-
return childItems.slice(offset, offset + limit,);
|
|
41400
|
-
}
|
|
41401
|
-
};
|
|
41402
|
-
var DatabaseItemMap = class extends Map {
|
|
41403
|
-
constructor(items = [],) {
|
|
41404
|
-
super();
|
|
41405
|
-
for (const item of items) {
|
|
41406
|
-
this.set(item.pointer, item,);
|
|
41407
|
-
}
|
|
41408
|
-
}
|
|
41409
|
-
union(other,) {
|
|
41410
|
-
const result = new DatabaseItemMap();
|
|
41411
|
-
for (const [pointer, item,] of this) {
|
|
41412
|
-
result.set(pointer, item,);
|
|
41413
|
-
}
|
|
41414
|
-
for (const [pointer, item,] of other) {
|
|
41415
|
-
result.set(pointer, item,);
|
|
41416
|
-
}
|
|
41417
|
-
return result;
|
|
41418
|
-
}
|
|
41419
|
-
intersection(other,) {
|
|
41420
|
-
const result = new DatabaseItemMap();
|
|
41421
|
-
for (const [pointer, item,] of this) {
|
|
41422
|
-
if (other.has(pointer,)) {
|
|
41423
|
-
result.set(pointer, item,);
|
|
41424
|
-
}
|
|
41425
|
-
}
|
|
41426
|
-
return result;
|
|
41427
|
-
}
|
|
41428
|
-
items() {
|
|
41429
|
-
const values = this.values();
|
|
41430
|
-
return [...values,];
|
|
41431
|
-
}
|
|
41432
|
-
};
|
|
41433
|
-
var RichTextResolver = class {
|
|
41434
|
-
constructor(collections,) {
|
|
41435
|
-
this.collections = collections;
|
|
41436
|
-
__publicField(this, 'cache', /* @__PURE__ */ new Map(),);
|
|
41437
|
-
}
|
|
41438
|
-
resolve(key7, pointer,) {
|
|
41439
|
-
const scopedCache = this.cache.get(key7,) ?? /* @__PURE__ */ new Map();
|
|
41440
|
-
this.cache.set(key7, scopedCache,);
|
|
41441
|
-
const cachedPromise = scopedCache.get(pointer,);
|
|
41442
|
-
if (cachedPromise) return cachedPromise;
|
|
41443
|
-
for (const collection of this.collections) {
|
|
41444
|
-
if (key7 in collection.schema) {
|
|
41445
|
-
const promise = collection.resolveRichText(pointer,);
|
|
41446
|
-
scopedCache.set(pointer, promise,);
|
|
41447
|
-
return promise;
|
|
41448
|
-
}
|
|
41449
|
-
}
|
|
41450
|
-
throw new Error(`Rich text field not found: ${key7}`,);
|
|
41451
|
-
}
|
|
41452
|
-
};
|
|
41453
39923
|
var unknownDefinition = {
|
|
41454
39924
|
type: 'unknown',
|
|
41455
39925
|
isNullable: true,
|
|
@@ -42006,7 +40476,7 @@ var CaseCondition = class {
|
|
|
42006
40476
|
return calculateHash('CaseCondition', this.when, this.then,);
|
|
42007
40477
|
}
|
|
42008
40478
|
};
|
|
42009
|
-
var
|
|
40479
|
+
var ScalarCase = class extends ScalarNode {
|
|
42010
40480
|
constructor(input, conditions, otherwise,) {
|
|
42011
40481
|
const referencedFields = new Fields();
|
|
42012
40482
|
const referencedOuterFields = new Fields();
|
|
@@ -42083,7 +40553,7 @@ var ScalarCase2 = class extends ScalarNode {
|
|
|
42083
40553
|
return new CaseCondition(when, then,);
|
|
42084
40554
|
},);
|
|
42085
40555
|
const otherwise = (_b = this.otherwise) == null ? void 0 : _b.getOptimized();
|
|
42086
|
-
return new
|
|
40556
|
+
return new ScalarCase(input, conditions, otherwise,);
|
|
42087
40557
|
}
|
|
42088
40558
|
*evaluate(context, tuple,) {
|
|
42089
40559
|
var _a, _b;
|
|
@@ -42349,6 +40819,7 @@ var Builder = class {
|
|
|
42349
40819
|
fromScope.setNode(node,);
|
|
42350
40820
|
}
|
|
42351
40821
|
const orderProjections = [];
|
|
40822
|
+
const orderFields = new Fields();
|
|
42352
40823
|
let ordering;
|
|
42353
40824
|
if (select.orderBy) {
|
|
42354
40825
|
ordering = new Ordering();
|
|
@@ -42356,6 +40827,7 @@ var Builder = class {
|
|
|
42356
40827
|
if (order.type === 'Identifier') {
|
|
42357
40828
|
const scopeField = fromScope.resolveField(order.name, order.collection,);
|
|
42358
40829
|
if (isUndefined(scopeField,)) continue;
|
|
40830
|
+
orderFields.add(scopeField.field,);
|
|
42359
40831
|
const orderingField = new OrderingField(scopeField.field, order.direction,);
|
|
42360
40832
|
ordering.push(orderingField,);
|
|
42361
40833
|
} else {
|
|
@@ -42372,7 +40844,7 @@ var Builder = class {
|
|
|
42372
40844
|
} else {
|
|
42373
40845
|
ordering = defaultOrdering;
|
|
42374
40846
|
}
|
|
42375
|
-
const projectionScope = this.buildSelectList(fromScope, select.select, orderProjections,);
|
|
40847
|
+
const projectionScope = this.buildSelectList(fromScope, select.select, orderFields, orderProjections,);
|
|
42376
40848
|
projectionScope.setOrdering(ordering,);
|
|
42377
40849
|
if (select.offset) {
|
|
42378
40850
|
const input = projectionScope.takeNode();
|
|
@@ -42388,9 +40860,9 @@ var Builder = class {
|
|
|
42388
40860
|
}
|
|
42389
40861
|
return projectionScope;
|
|
42390
40862
|
}
|
|
42391
|
-
buildSelectList(inScope, selects, orderProjections,) {
|
|
40863
|
+
buildSelectList(inScope, selects, orderFields, orderProjections,) {
|
|
42392
40864
|
const outScope = inScope.push();
|
|
42393
|
-
const passthrough = new Fields();
|
|
40865
|
+
const passthrough = new Fields(orderFields,);
|
|
42394
40866
|
const projections = [...orderProjections,];
|
|
42395
40867
|
for (const select of selects) {
|
|
42396
40868
|
if (select.type === 'Identifier') {
|
|
@@ -45023,7 +43495,7 @@ var Normalizer = class {
|
|
|
45023
43495
|
}
|
|
45024
43496
|
conditions = castConditions;
|
|
45025
43497
|
}
|
|
45026
|
-
const node = new
|
|
43498
|
+
const node = new ScalarCase(input, conditions, otherwise,);
|
|
45027
43499
|
return this.finishScalar(node,);
|
|
45028
43500
|
}
|
|
45029
43501
|
newScalarContains(source, target,) {
|
|
@@ -45251,36 +43723,8 @@ function stringifyQuery(query,) {
|
|
|
45251
43723
|
return autoIndentSql(queryString,);
|
|
45252
43724
|
}
|
|
45253
43725
|
var log = /* @__PURE__ */ getLogger('query-engine',);
|
|
45254
|
-
function getDatabaseCollection({
|
|
45255
|
-
data: data2,
|
|
45256
|
-
}, locale,) {
|
|
45257
|
-
if (isAnyLegacyCollection(data2,)) {
|
|
45258
|
-
return new CompatibilityDatabaseCollection(data2, locale,);
|
|
45259
|
-
}
|
|
45260
|
-
if (isDatabaseCollection(data2,)) {
|
|
45261
|
-
return data2;
|
|
45262
|
-
}
|
|
45263
|
-
if (isLocalizedDatabaseCollection(data2,)) {
|
|
45264
|
-
while (locale) {
|
|
45265
|
-
const collection = data2.collectionByLocaleId[locale.id];
|
|
45266
|
-
if (collection) return collection;
|
|
45267
|
-
locale = locale.fallback;
|
|
45268
|
-
}
|
|
45269
|
-
return data2.collectionByLocaleId.default;
|
|
45270
|
-
}
|
|
45271
|
-
assertNever(data2, 'Unsupported collection type',);
|
|
45272
|
-
}
|
|
45273
43726
|
var QueryEngine = class {
|
|
45274
|
-
constructor() {
|
|
45275
|
-
__publicField(this, 'useNewOptimizer', false,);
|
|
45276
|
-
}
|
|
45277
43727
|
async query(query, locale,) {
|
|
45278
|
-
if (this.useNewOptimizer || needsNewQueryOptimizer(query,)) {
|
|
45279
|
-
return this.queryNew(query, locale,);
|
|
45280
|
-
}
|
|
45281
|
-
return this.queryOld(query, locale,);
|
|
45282
|
-
}
|
|
45283
|
-
async queryNew(query, locale,) {
|
|
45284
43728
|
log.debug(`Query:
|
|
45285
43729
|
${stringifyQuery(query,)}`,);
|
|
45286
43730
|
const optimizer = new Optimizer(query, locale,);
|
|
@@ -45317,285 +43761,7 @@ ${stringifyQuery(query,)}`,);
|
|
|
45317
43761
|
}
|
|
45318
43762
|
return (value == null ? void 0 : value.value) ?? null;
|
|
45319
43763
|
}
|
|
45320
|
-
async queryOld(query, locale,) {
|
|
45321
|
-
const [plan, schema, richTextResolver,] = this.createQueryPlan(query, locale,);
|
|
45322
|
-
const items = await this.executeQueryPlan(schema, richTextResolver, query, plan,);
|
|
45323
|
-
log.debug(`Query:
|
|
45324
|
-
${stringifyQuery(query,)}
|
|
45325
|
-
|
|
45326
|
-
${(0, import_archy.default)(plan.inspect(),)}`,);
|
|
45327
|
-
return items;
|
|
45328
|
-
}
|
|
45329
|
-
buildFrom(from, schema, collections, locale,) {
|
|
45330
|
-
switch (from.type) {
|
|
45331
|
-
case 'Collection': {
|
|
45332
|
-
const collection = getDatabaseCollection(from, locale,);
|
|
45333
|
-
collections.push(collection,);
|
|
45334
|
-
Object.assign(schema, collection.schema,);
|
|
45335
|
-
return new ScanCollectionPlan(collection, from.alias,);
|
|
45336
|
-
}
|
|
45337
|
-
case 'LeftJoin': {
|
|
45338
|
-
const left = this.buildFrom(from.left, schema, collections, locale,);
|
|
45339
|
-
const right = this.buildFrom(from.right, schema, collections, locale,);
|
|
45340
|
-
const constraint = ScalarExpression.from(from.constraint, schema,);
|
|
45341
|
-
return new LeftJoinPlan(left, right, constraint,);
|
|
45342
|
-
}
|
|
45343
|
-
default:
|
|
45344
|
-
assertNever(from, 'Unsupported data source',);
|
|
45345
|
-
}
|
|
45346
|
-
}
|
|
45347
|
-
createQueryPlan(query, locale,) {
|
|
45348
|
-
var _a;
|
|
45349
|
-
const schema = {};
|
|
45350
|
-
const collections = [];
|
|
45351
|
-
let plan = this.buildFrom(query.from, schema, collections, locale,);
|
|
45352
|
-
const [firstCollection,] = collections;
|
|
45353
|
-
assert(firstCollection, 'At least one collection must exist',);
|
|
45354
|
-
const richTextResolver = new RichTextResolver(collections,);
|
|
45355
|
-
if (query.where) {
|
|
45356
|
-
const filterExpression = ScalarExpression.from(query.where, schema,);
|
|
45357
|
-
if (collections.length === 1) {
|
|
45358
|
-
plan = createPlanForWhereClause(firstCollection, filterExpression,);
|
|
45359
|
-
} else {
|
|
45360
|
-
plan = new FilterItemsPlan(plan, filterExpression,);
|
|
45361
|
-
}
|
|
45362
|
-
}
|
|
45363
|
-
const sortExpressions = (_a = query.orderBy) == null
|
|
45364
|
-
? void 0
|
|
45365
|
-
: _a.map((expression) =>
|
|
45366
|
-
new ScalarOrderExpression(ScalarExpression.from(expression, schema,), expression.direction ?? 'asc', {
|
|
45367
|
-
type: 0,
|
|
45368
|
-
/* CaseInsensitive */
|
|
45369
|
-
},)
|
|
45370
|
-
);
|
|
45371
|
-
plan = new SortItemsPlan(plan, sortExpressions ?? [], firstCollection,);
|
|
45372
|
-
let offsetExpression;
|
|
45373
|
-
if (query.offset) {
|
|
45374
|
-
offsetExpression = ScalarExpression.from(query.offset, schema,);
|
|
45375
|
-
}
|
|
45376
|
-
let limitExpression;
|
|
45377
|
-
if (query.limit) {
|
|
45378
|
-
limitExpression = ScalarExpression.from(query.limit, schema,);
|
|
45379
|
-
}
|
|
45380
|
-
if (offsetExpression || limitExpression) {
|
|
45381
|
-
plan = new SliceItemsPlan(plan, offsetExpression, limitExpression,);
|
|
45382
|
-
}
|
|
45383
|
-
if (query.select.length > 0 && collections.length === 1) {
|
|
45384
|
-
plan = new ResolveItemsPlan(plan, firstCollection, richTextResolver, query.select,);
|
|
45385
|
-
}
|
|
45386
|
-
return [plan, schema, richTextResolver,];
|
|
45387
|
-
}
|
|
45388
|
-
async executeQueryPlan(schema, richTextResolver, query, plan,) {
|
|
45389
|
-
const items = await plan.execute();
|
|
45390
|
-
return Promise.all(items.map(async (item) => {
|
|
45391
|
-
const data2 = {};
|
|
45392
|
-
for (const expression of query.select) {
|
|
45393
|
-
const scalarExpression = ScalarExpression.from(expression, schema,);
|
|
45394
|
-
const key7 = getSelectKey(expression,);
|
|
45395
|
-
const value = scalarExpression.evaluate(item,);
|
|
45396
|
-
data2[key7] = await resolveValue(richTextResolver, expression.type === 'Identifier' ? expression.name : void 0, value,);
|
|
45397
|
-
}
|
|
45398
|
-
return data2;
|
|
45399
|
-
},),);
|
|
45400
|
-
}
|
|
45401
43764
|
};
|
|
45402
|
-
function getSelectKey(expression,) {
|
|
45403
|
-
if (expression.alias) {
|
|
45404
|
-
return expression.alias;
|
|
45405
|
-
}
|
|
45406
|
-
if (expression.type === 'Identifier') {
|
|
45407
|
-
return expression.name;
|
|
45408
|
-
}
|
|
45409
|
-
throw new Error('Can\'t serialize expression',);
|
|
45410
|
-
}
|
|
45411
|
-
async function resolveValue(richTextResolver, key7, value,) {
|
|
45412
|
-
if (isNullish2(value,)) {
|
|
45413
|
-
return null;
|
|
45414
|
-
}
|
|
45415
|
-
if (value.type === 'richtext') {
|
|
45416
|
-
assert(isString2(key7,), 'Rich text field must be a string',);
|
|
45417
|
-
return richTextResolver.resolve(key7, value.value,);
|
|
45418
|
-
}
|
|
45419
|
-
return value.value;
|
|
45420
|
-
}
|
|
45421
|
-
function createPlanForWhereClause(collection, expression,) {
|
|
45422
|
-
if (expression instanceof ScalarLogicalOperationAnd) {
|
|
45423
|
-
const childPlans = expression.operandExpressions.map((expression2) => createPlanForWhereClause(collection, expression2,));
|
|
45424
|
-
return new IntersectionPlan(childPlans,);
|
|
45425
|
-
}
|
|
45426
|
-
if (expression instanceof ScalarLogicalOperationOr) {
|
|
45427
|
-
const childPlans = expression.operandExpressions.map((expression2) => createPlanForWhereClause(collection, expression2,));
|
|
45428
|
-
return new UnionPlan(childPlans,);
|
|
45429
|
-
}
|
|
45430
|
-
return findLookupIndexPlan(collection, expression,) ?? createScanCollectionPlan(collection, expression,);
|
|
45431
|
-
}
|
|
45432
|
-
function findLookupIndexPlan(collection, expression,) {
|
|
45433
|
-
var _a, _b;
|
|
45434
|
-
if (expression instanceof ScalarComparison) {
|
|
45435
|
-
return findLookupIndexPlanForComparison(collection, expression,);
|
|
45436
|
-
}
|
|
45437
|
-
if (expression instanceof ScalarFunctionCall) {
|
|
45438
|
-
return findLookupIndexPlanForFunctionCall(collection, expression,);
|
|
45439
|
-
}
|
|
45440
|
-
if (expression instanceof ScalarIdentifier && ((_a = expression.definition) == null ? void 0 : _a.type) === 'boolean') {
|
|
45441
|
-
const value = ScalarLiteralValue.fromBoolean(true,);
|
|
45442
|
-
const comparison = new ScalarComparisonEquals(expression, value,);
|
|
45443
|
-
return findLookupIndexPlanForComparison(collection, comparison,);
|
|
45444
|
-
}
|
|
45445
|
-
if (
|
|
45446
|
-
expression instanceof ScalarUnaryOperationNot && expression.valueExpression instanceof ScalarIdentifier &&
|
|
45447
|
-
((_b = expression.valueExpression.definition) == null ? void 0 : _b.type) === 'boolean'
|
|
45448
|
-
) {
|
|
45449
|
-
const value = ScalarLiteralValue.fromBoolean(true,);
|
|
45450
|
-
const comparison = new ScalarComparisonNotEquals(expression.valueExpression, value,);
|
|
45451
|
-
return findLookupIndexPlanForComparison(collection, comparison,);
|
|
45452
|
-
}
|
|
45453
|
-
}
|
|
45454
|
-
function findLookupIndexPlanForComparison(collection, expression,) {
|
|
45455
|
-
const leftExpression = expression.leftExpression;
|
|
45456
|
-
const rightExpression = expression.rightExpression;
|
|
45457
|
-
if (!(rightExpression instanceof ScalarLiteralValue)) return;
|
|
45458
|
-
for (const index of collection.indexes) {
|
|
45459
|
-
const field = index.fields[0];
|
|
45460
|
-
if (isUndefined(field,)) continue;
|
|
45461
|
-
const fieldExpression = ScalarExpression.from(field, collection.schema,);
|
|
45462
|
-
if (!leftExpression.equals(fieldExpression,)) continue;
|
|
45463
|
-
const fillerAllQueries = new Array(index.fields.length - 1,).fill({
|
|
45464
|
-
type: 'All',
|
|
45465
|
-
/* All */
|
|
45466
|
-
},);
|
|
45467
|
-
if (
|
|
45468
|
-
expression instanceof ScalarComparisonEquals && index.supportedLookupTypes.includes('Equals',/* Equals */
|
|
45469
|
-
)
|
|
45470
|
-
) {
|
|
45471
|
-
return new LookupIndexPlan(index, [{
|
|
45472
|
-
type: 'Equals',
|
|
45473
|
-
value: rightExpression.evaluate(),
|
|
45474
|
-
}, ...fillerAllQueries,],);
|
|
45475
|
-
}
|
|
45476
|
-
if (
|
|
45477
|
-
expression instanceof ScalarComparisonNotEquals && index.supportedLookupTypes.includes('NotEquals',/* NotEquals */
|
|
45478
|
-
)
|
|
45479
|
-
) {
|
|
45480
|
-
return new LookupIndexPlan(index, [{
|
|
45481
|
-
type: 'NotEquals',
|
|
45482
|
-
value: rightExpression.evaluate(),
|
|
45483
|
-
}, ...fillerAllQueries,],);
|
|
45484
|
-
}
|
|
45485
|
-
if (
|
|
45486
|
-
expression instanceof ScalarComparisonLessThan && index.supportedLookupTypes.includes('LessThan',/* LessThan */
|
|
45487
|
-
)
|
|
45488
|
-
) {
|
|
45489
|
-
return new LookupIndexPlan(index, [{
|
|
45490
|
-
type: 'LessThan',
|
|
45491
|
-
value: rightExpression.evaluate(),
|
|
45492
|
-
inclusive: false,
|
|
45493
|
-
}, ...fillerAllQueries,],);
|
|
45494
|
-
}
|
|
45495
|
-
if (
|
|
45496
|
-
expression instanceof ScalarComparisonLessThanOrEqual && index.supportedLookupTypes.includes('LessThan',/* LessThan */
|
|
45497
|
-
)
|
|
45498
|
-
) {
|
|
45499
|
-
return new LookupIndexPlan(index, [{
|
|
45500
|
-
type: 'LessThan',
|
|
45501
|
-
value: rightExpression.evaluate(),
|
|
45502
|
-
inclusive: true,
|
|
45503
|
-
}, ...fillerAllQueries,],);
|
|
45504
|
-
}
|
|
45505
|
-
if (
|
|
45506
|
-
expression instanceof ScalarComparisonGreaterThan && index.supportedLookupTypes.includes('GreaterThan',/* GreaterThan */
|
|
45507
|
-
)
|
|
45508
|
-
) {
|
|
45509
|
-
return new LookupIndexPlan(index, [{
|
|
45510
|
-
type: 'GreaterThan',
|
|
45511
|
-
value: rightExpression.evaluate(),
|
|
45512
|
-
inclusive: false,
|
|
45513
|
-
}, ...fillerAllQueries,],);
|
|
45514
|
-
}
|
|
45515
|
-
if (
|
|
45516
|
-
expression instanceof ScalarComparisonGreaterThanOrEqual && index.supportedLookupTypes.includes('GreaterThan',/* GreaterThan */
|
|
45517
|
-
)
|
|
45518
|
-
) {
|
|
45519
|
-
return new LookupIndexPlan(index, [{
|
|
45520
|
-
type: 'GreaterThan',
|
|
45521
|
-
value: rightExpression.evaluate(),
|
|
45522
|
-
inclusive: true,
|
|
45523
|
-
}, ...fillerAllQueries,],);
|
|
45524
|
-
}
|
|
45525
|
-
}
|
|
45526
|
-
}
|
|
45527
|
-
function findLookupIndexPlanForFunctionCall(collection, expression,) {
|
|
45528
|
-
if (expression.argumentExpressions.length !== 2) return;
|
|
45529
|
-
const sourceExpression = expression.argumentExpressions[0];
|
|
45530
|
-
const targetExpression = expression.argumentExpressions[1];
|
|
45531
|
-
if (isUndefined(sourceExpression,)) return;
|
|
45532
|
-
if (isUndefined(targetExpression,)) return;
|
|
45533
|
-
if (!(targetExpression instanceof ScalarLiteralValue)) return;
|
|
45534
|
-
for (const index of collection.indexes) {
|
|
45535
|
-
const field = index.fields[0];
|
|
45536
|
-
if (isUndefined(field,)) continue;
|
|
45537
|
-
const fieldExpression = ScalarExpression.from(field, collection.schema,);
|
|
45538
|
-
if (!sourceExpression.equals(fieldExpression,)) continue;
|
|
45539
|
-
const fillerAllQueries = new Array(index.fields.length - 1,).fill({
|
|
45540
|
-
type: 'All',
|
|
45541
|
-
/* All */
|
|
45542
|
-
},);
|
|
45543
|
-
if (
|
|
45544
|
-
expression instanceof ScalarFunctionCallContains && index.supportedLookupTypes.includes('Contains',/* Contains */
|
|
45545
|
-
)
|
|
45546
|
-
) {
|
|
45547
|
-
return new LookupIndexPlan(index, [{
|
|
45548
|
-
type: 'Contains',
|
|
45549
|
-
value: targetExpression.evaluate(),
|
|
45550
|
-
}, ...fillerAllQueries,],);
|
|
45551
|
-
}
|
|
45552
|
-
if (
|
|
45553
|
-
expression instanceof ScalarFunctionCallStartsWith && index.supportedLookupTypes.includes('StartsWith',/* StartsWith */
|
|
45554
|
-
)
|
|
45555
|
-
) {
|
|
45556
|
-
return new LookupIndexPlan(index, [{
|
|
45557
|
-
type: 'StartsWith',
|
|
45558
|
-
value: targetExpression.evaluate(),
|
|
45559
|
-
}, ...fillerAllQueries,],);
|
|
45560
|
-
}
|
|
45561
|
-
if (
|
|
45562
|
-
expression instanceof ScalarFunctionCallEndsWith && index.supportedLookupTypes.includes('EndsWith',/* EndsWith */
|
|
45563
|
-
)
|
|
45564
|
-
) {
|
|
45565
|
-
return new LookupIndexPlan(index, [{
|
|
45566
|
-
type: 'EndsWith',
|
|
45567
|
-
value: targetExpression.evaluate(),
|
|
45568
|
-
}, ...fillerAllQueries,],);
|
|
45569
|
-
}
|
|
45570
|
-
}
|
|
45571
|
-
}
|
|
45572
|
-
function createScanCollectionPlan(collection, expression,) {
|
|
45573
|
-
const plan = new ScanCollectionPlan(collection, void 0,);
|
|
45574
|
-
return new FilterItemsPlan(plan, expression,);
|
|
45575
|
-
}
|
|
45576
|
-
function needsNewQueryOptimizer(query,) {
|
|
45577
|
-
if (query.from.type !== 'Collection') return true;
|
|
45578
|
-
for (const expression of query.select) {
|
|
45579
|
-
if (expression.type === 'Identifier') return true;
|
|
45580
|
-
}
|
|
45581
|
-
if (query.where) return hasScalarIn(query.where,);
|
|
45582
|
-
return false;
|
|
45583
|
-
}
|
|
45584
|
-
function hasScalarIn(expression,) {
|
|
45585
|
-
switch (expression.type) {
|
|
45586
|
-
case 'UnaryOperation': {
|
|
45587
|
-
return hasScalarIn(expression.value,);
|
|
45588
|
-
}
|
|
45589
|
-
case 'BinaryOperation': {
|
|
45590
|
-
if (expression.operator === 'in') {
|
|
45591
|
-
return true;
|
|
45592
|
-
}
|
|
45593
|
-
return hasScalarIn(expression.left,) || hasScalarIn(expression.right,);
|
|
45594
|
-
}
|
|
45595
|
-
default:
|
|
45596
|
-
return false;
|
|
45597
|
-
}
|
|
45598
|
-
}
|
|
45599
43765
|
var defaultVariantKey = 'default';
|
|
45600
43766
|
var defaultVariants = /* @__PURE__ */ new Set([defaultVariantKey,],);
|
|
45601
43767
|
var _variantHashes;
|
|
@@ -53162,7 +51328,7 @@ MotionValue.prototype.addChild = function ({
|
|
|
53162
51328
|
return child;
|
|
53163
51329
|
};
|
|
53164
51330
|
if (false) {
|
|
53165
|
-
|
|
51331
|
+
MainLoop2.start();
|
|
53166
51332
|
}
|
|
53167
51333
|
export {
|
|
53168
51334
|
_injectRuntime,
|
|
@@ -53307,7 +51473,6 @@ export {
|
|
|
53307
51473
|
getFontsFromSharedStyle,
|
|
53308
51474
|
getLoadingLazyAtYPosition,
|
|
53309
51475
|
getMeasurableCodeComponentChildren,
|
|
53310
|
-
getMergedConstraintsProps,
|
|
53311
51476
|
getPropertyControls,
|
|
53312
51477
|
getWhereExpressionFromPathVariables,
|
|
53313
51478
|
gradientForShape,
|