@wix/motion-edm-autogen-transformations-core 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__tests__/corvid-entity.spec.js +4 -2
- package/dist/cjs/__tests__/corvid-entity.spec.js.map +1 -1
- package/dist/cjs/__tests__/reduceTransformation.spec.js +1 -3
- package/dist/cjs/__tests__/reduceTransformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js +6 -3
- package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js +9 -4
- package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js +6 -3
- package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js +6 -3
- package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js +7 -6
- package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js +6 -3
- package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js +3 -1
- package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js.map +1 -1
- package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js +3 -1
- package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js.map +1 -1
- package/dist/cjs/index.js +13 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/corvid-entity/index.js +2 -4
- package/dist/cjs/lib/corvid-entity/index.js.map +1 -1
- package/dist/cjs/lib/helpers.js +10 -10
- package/dist/cjs/lib/helpers.js.map +1 -1
- package/dist/cjs/lib/transformations/common.js +1 -2
- package/dist/cjs/lib/transformations/common.js.map +1 -1
- package/dist/cjs/lib/transformations/constants.js +2 -4
- package/dist/cjs/lib/transformations/constants.js.map +1 -1
- package/dist/cjs/lib/transformations/preset/delete.js +3 -1
- package/dist/cjs/lib/transformations/preset/delete.js.map +1 -1
- package/dist/cjs/lib/transformations/preset/query.js +9 -7
- package/dist/cjs/lib/transformations/preset/query.js.map +1 -1
- package/dist/cjs/lib/transformations/reduceTransformation.js +46 -36
- package/dist/cjs/lib/transformations/reduceTransformation.js.map +1 -1
- package/dist/cjs/lib/transformations/validations/common.js +4 -2
- package/dist/cjs/lib/transformations/validations/common.js.map +1 -1
- package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js +3 -5
- package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js.map +1 -1
- package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js +7 -6
- package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js.map +1 -1
- package/dist/esm/__tests__/corvid-entity.spec.js +30 -24
- package/dist/esm/__tests__/corvid-entity.spec.js.map +1 -1
- package/dist/esm/__tests__/getArgumentCardinality.spec.js +20 -25
- package/dist/esm/__tests__/getArgumentCardinality.spec.js.map +1 -1
- package/dist/esm/__tests__/helpers.spec.js +37 -29
- package/dist/esm/__tests__/helpers.spec.js.map +1 -1
- package/dist/esm/__tests__/reduceTransformation.spec.js +147 -149
- package/dist/esm/__tests__/reduceTransformation.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/custom-functions.spec.js +62 -59
- package/dist/esm/__tests__/transformations/custom-functions.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js +24 -26
- package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js +39 -43
- package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js +22 -24
- package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js +11 -11
- package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js +29 -30
- package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js.map +1 -1
- package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js +58 -62
- package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js.map +1 -1
- package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js +94 -82
- package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js.map +1 -1
- package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js +130 -107
- package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js.map +1 -1
- package/dist/esm/index.js +22 -22
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/corvid-entity/index.js +6 -10
- package/dist/esm/lib/corvid-entity/index.js.map +1 -1
- package/dist/esm/lib/getArgumentCardinality.js +15 -21
- package/dist/esm/lib/getArgumentCardinality.js.map +1 -1
- package/dist/esm/lib/helpers.js +26 -40
- package/dist/esm/lib/helpers.js.map +1 -1
- package/dist/esm/lib/transformations/common.js +2 -5
- package/dist/esm/lib/transformations/common.js.map +1 -1
- package/dist/esm/lib/transformations/constants.js +2 -2
- package/dist/esm/lib/transformations/constants.js.map +1 -1
- package/dist/esm/lib/transformations/custom-functions.js +11 -14
- package/dist/esm/lib/transformations/custom-functions.js.map +1 -1
- package/dist/esm/lib/transformations/preset/create.js +1 -4
- package/dist/esm/lib/transformations/preset/create.js.map +1 -1
- package/dist/esm/lib/transformations/preset/delete.js +9 -13
- package/dist/esm/lib/transformations/preset/delete.js.map +1 -1
- package/dist/esm/lib/transformations/preset/get.js +1 -4
- package/dist/esm/lib/transformations/preset/get.js.map +1 -1
- package/dist/esm/lib/transformations/preset/list.js +1 -3
- package/dist/esm/lib/transformations/preset/list.js.map +1 -1
- package/dist/esm/lib/transformations/preset/query.js +17 -24
- package/dist/esm/lib/transformations/preset/query.js.map +1 -1
- package/dist/esm/lib/transformations/preset/update.js +3 -4
- package/dist/esm/lib/transformations/preset/update.js.map +1 -1
- package/dist/esm/lib/transformations/reduceTransformation.js +33 -44
- package/dist/esm/lib/transformations/reduceTransformation.js.map +1 -1
- package/dist/esm/lib/transformations/validations/common.js +17 -20
- package/dist/esm/lib/transformations/validations/common.js.map +1 -1
- package/dist/esm/lib/transformations/validations/validateRequestTransformation.js +35 -44
- package/dist/esm/lib/transformations/validations/validateRequestTransformation.js.map +1 -1
- package/dist/esm/lib/transformations/validations/validateResponseTransformation.js +57 -69
- package/dist/esm/lib/transformations/validations/validateResponseTransformation.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -1,87 +1,90 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
2
1
|
import { aString } from '@wix/motion-runtime-test-context';
|
|
3
2
|
import { set, times } from 'lodash';
|
|
4
3
|
import { isFunctionCallExpression, parseCustomFunctionCall } from '../..';
|
|
5
4
|
import { runCustomFunctionCallExpression } from '../../lib/transformations/custom-functions';
|
|
6
|
-
describe('parseCustomFunctionCall',
|
|
5
|
+
describe('parseCustomFunctionCall', () => {
|
|
7
6
|
/* eslint-disable max-len */
|
|
8
|
-
test.each
|
|
7
|
+
test.each `
|
|
8
|
+
argumentCount | argumentExpressions | expectedArgumentExpressions
|
|
9
|
+
${'a single argument'} | ${'$[0].some.path'} | ${['$[0].some.path']}
|
|
10
|
+
${'multiple arguments'} | ${'$[0].some.path,someString'} | ${['$[0].some.path', 'someString']}
|
|
11
|
+
${'multiple arguments with whitespaces'} | ${'$[0].some.path, someString , $[1]'} | ${['$[0].some.path', 'someString', '$[1]']}
|
|
12
|
+
${'no arguments'} | ${''} | ${[]}
|
|
13
|
+
`(
|
|
9
14
|
/* eslint-enable max-len */
|
|
10
|
-
'parses a custom-function call applied with $argumentCount',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var functionExpression = "#".concat(functionName, "(").concat(argumentExpressions, ")");
|
|
15
|
+
'parses a custom-function call applied with $argumentCount', ({ argumentExpressions, expectedArgumentExpressions }) => {
|
|
16
|
+
const functionName = aString();
|
|
17
|
+
const functionExpression = `#${functionName}(${argumentExpressions})`;
|
|
14
18
|
expect(parseCustomFunctionCall(functionExpression)).toStrictEqual({
|
|
15
|
-
functionName
|
|
19
|
+
functionName,
|
|
16
20
|
argumentExpressions: expectedArgumentExpressions,
|
|
17
21
|
});
|
|
18
22
|
});
|
|
19
23
|
});
|
|
20
|
-
describe('isFunctionCallExpression',
|
|
21
|
-
test.each
|
|
22
|
-
|
|
24
|
+
describe('isFunctionCallExpression', () => {
|
|
25
|
+
test.each `
|
|
26
|
+
description | expression | expectedResult
|
|
27
|
+
${'a #-prefixed with a valid function name'} | ${'#someInvalidName$#@#>'} | ${true}
|
|
28
|
+
${'a non-# prefixed with a valid function name'} | ${'someFunctions($[1])'} | ${false}
|
|
29
|
+
${'a non-string value'} | ${[1, 2, 3]} | ${false}
|
|
30
|
+
`('returns $expectedResult when $description function call expression is provided', ({ expression, expectedResult }) => {
|
|
23
31
|
expect(isFunctionCallExpression(expression)).toStrictEqual(expectedResult);
|
|
24
32
|
});
|
|
25
33
|
});
|
|
26
|
-
describe('runCustomFunctionCallExpression',
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
describe('runCustomFunctionCallExpression', () => {
|
|
35
|
+
const value = aString();
|
|
36
|
+
const transformationParentPath = aString();
|
|
37
|
+
const joinWithDots = (...args) => args.join('|');
|
|
38
|
+
describe.each `
|
|
39
|
+
argumentCount | argumentValues | expectedResult
|
|
40
|
+
${'single'} | ${[value]} | ${value}
|
|
41
|
+
${'multi'} | ${[value, value]} | ${`${value}|${value}`}
|
|
42
|
+
${'no'} | ${[]} | ${''}
|
|
43
|
+
`('$argumentCount-argument expression', ({ argumentValues, expectedResult }) => {
|
|
44
|
+
describe.each `
|
|
45
|
+
functionName | description
|
|
46
|
+
${'someFunction'} | ${'an unscoped'}
|
|
47
|
+
${'someScope.someFunction'} | ${'a scoped'}
|
|
48
|
+
`('$description custom function', ({ functionName }) => {
|
|
49
|
+
const customFunctions = set({}, functionName, joinWithDots);
|
|
50
|
+
test('runs it and returns its result', () => {
|
|
51
|
+
const result = runCustomFunctionCallExpression({
|
|
52
|
+
functionName,
|
|
53
|
+
customFunctions,
|
|
54
|
+
argumentValues,
|
|
55
|
+
transformationParentPath,
|
|
47
56
|
});
|
|
48
57
|
expect(result).toStrictEqual(expectedResult);
|
|
49
58
|
});
|
|
50
59
|
});
|
|
51
60
|
});
|
|
52
|
-
describe('error handling',
|
|
53
|
-
|
|
54
|
-
test('throws when the function is not recognized',
|
|
55
|
-
|
|
56
|
-
expect(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
}).toThrow("unrecognized custom function \"someNonexistentFunction\"");
|
|
61
|
+
describe('error handling', () => {
|
|
62
|
+
const argumentValues = times(2, () => aString());
|
|
63
|
+
test('throws when the function is not recognized', () => {
|
|
64
|
+
const customFunctions = {};
|
|
65
|
+
expect(() => runCustomFunctionCallExpression({
|
|
66
|
+
functionName: 'someNonexistentFunction',
|
|
67
|
+
customFunctions,
|
|
68
|
+
argumentValues,
|
|
69
|
+
transformationParentPath,
|
|
70
|
+
})).toThrow(`unrecognized custom function "someNonexistentFunction"`);
|
|
64
71
|
});
|
|
65
|
-
test('throws an error when the function call throws an error',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
_a[functionName] = function () {
|
|
72
|
+
test('throws an error when the function call throws an error', () => {
|
|
73
|
+
const functionName = aString();
|
|
74
|
+
const customFunctions = {
|
|
75
|
+
[functionName]: () => {
|
|
70
76
|
throw new Error('Something went wrong in the custom function');
|
|
71
77
|
},
|
|
72
|
-
_a);
|
|
73
|
-
var t = function () {
|
|
74
|
-
return runCustomFunctionCallExpression({
|
|
75
|
-
functionName: functionName,
|
|
76
|
-
customFunctions: customFunctions,
|
|
77
|
-
argumentValues: argumentValues,
|
|
78
|
-
transformationParentPath: transformationParentPath,
|
|
79
|
-
});
|
|
80
78
|
};
|
|
79
|
+
const t = () => runCustomFunctionCallExpression({
|
|
80
|
+
functionName,
|
|
81
|
+
customFunctions,
|
|
82
|
+
argumentValues,
|
|
83
|
+
transformationParentPath,
|
|
84
|
+
});
|
|
81
85
|
expect(t).toThrow(Error);
|
|
82
|
-
expect(t).toThrow(new RegExp(
|
|
86
|
+
expect(t).toThrow(new RegExp(`Transforming ${transformationParentPath} failed, #${functionName} threw: "Something went wrong in the custom function" for arguments: .+`));
|
|
83
87
|
});
|
|
84
88
|
});
|
|
85
89
|
});
|
|
86
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
87
90
|
//# sourceMappingURL=custom-functions.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-functions.spec.js","sourceRoot":"","sources":["../../../../src/__tests__/transformations/custom-functions.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-functions.spec.js","sourceRoot":"","sources":["../../../../src/__tests__/transformations/custom-functions.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA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AAG,EAAE,CACV,+BAA+B,CAAC;gBAC9B,YAAY,EAAE,yBAAyB;gBACvC,eAAe;gBACf,cAAc;gBACd,wBAAwB;aACzB,CAAC,CACH,CAAC,OAAO,CAAC,wDAAwD,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAClE,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC;YAE/B,MAAM,eAAe,GAAG;gBACtB,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE;oBACnB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;gBACjE,CAAC;aACF,CAAC;YAEF,MAAM,CAAC,GAAG,GAAG,EAAE,CACb,+BAA+B,CAAC;gBAC9B,YAAY;gBACZ,eAAe;gBACf,cAAc;gBACd,wBAAwB;aACzB,CAAC,CAAC;YAEL,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CACf,IAAI,MAAM,CACR,gBAAgB,wBAAwB,aAAa,YAAY,yEAAyE,CAC3I,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import { aString } from '@wix/motion-runtime-test-context';
|
|
2
2
|
import { times } from 'lodash';
|
|
3
3
|
import { preset } from '../../..';
|
|
4
|
-
|
|
5
|
-
describe('create-method transformations',
|
|
6
|
-
describe('buildRequestTransformation',
|
|
7
|
-
test('creates a transformation that maps the first argument into requestMessageEntityPath',
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const { create: { buildRequestTransformation, buildResponseTransformation }, } = preset;
|
|
5
|
+
describe('create-method transformations', () => {
|
|
6
|
+
describe('buildRequestTransformation', () => {
|
|
7
|
+
test('creates a transformation that maps the first argument into requestMessageEntityPath', () => {
|
|
8
|
+
const requestMessageEntityPath = aString();
|
|
9
|
+
const tranformationObject = buildRequestTransformation({
|
|
10
|
+
requestMessageEntityPath,
|
|
11
|
+
});
|
|
12
|
+
expect(tranformationObject).toStrictEqual({
|
|
13
|
+
[requestMessageEntityPath]: '$[0]',
|
|
12
14
|
});
|
|
13
|
-
expect(tranformationObject).toStrictEqual((_a = {},
|
|
14
|
-
_a[requestMessageEntityPath] = '$[0]',
|
|
15
|
-
_a));
|
|
16
15
|
});
|
|
17
|
-
test('supports nested paths',
|
|
18
|
-
var _a, _b;
|
|
16
|
+
test('supports nested paths', () => {
|
|
19
17
|
// @ts-expect-error
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
requestMessageEntityPath
|
|
18
|
+
const entityPathSegments = times(2, aString);
|
|
19
|
+
const requestMessageEntityPath = entityPathSegments.join('.');
|
|
20
|
+
const tranformationObject = buildRequestTransformation({
|
|
21
|
+
requestMessageEntityPath,
|
|
22
|
+
});
|
|
23
|
+
expect(tranformationObject).toStrictEqual({
|
|
24
|
+
[entityPathSegments[0]]: { [entityPathSegments[1]]: '$[0]' },
|
|
24
25
|
});
|
|
25
|
-
expect(tranformationObject).toStrictEqual((_a = {},
|
|
26
|
-
_a[entityPathSegments[0]] = (_b = {}, _b[entityPathSegments[1]] = '$[0]', _b),
|
|
27
|
-
_a));
|
|
28
26
|
});
|
|
29
27
|
});
|
|
30
|
-
describe('buildResponseTransformation',
|
|
31
|
-
test('unwraps the value of the provided property-path',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
responseMessageResultPath
|
|
28
|
+
describe('buildResponseTransformation', () => {
|
|
29
|
+
test('unwraps the value of the provided property-path', () => {
|
|
30
|
+
const responseMessageResultPath = aString();
|
|
31
|
+
const tranformationString = buildResponseTransformation({
|
|
32
|
+
responseMessageResultPath,
|
|
35
33
|
});
|
|
36
|
-
expect(tranformationString).toStrictEqual(
|
|
34
|
+
expect(tranformationString).toStrictEqual(`$.${responseMessageResultPath}`);
|
|
37
35
|
});
|
|
38
36
|
});
|
|
39
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/create-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"create-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/create-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,EACJ,MAAM,EAAE,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,GACpE,GAAG,MAAM,CAAC;AAEX,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,IAAI,CAAC,qFAAqF,EAAE,GAAG,EAAE;YAC/F,MAAM,wBAAwB,GAAG,OAAO,EAAE,CAAC;YAE3C,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;gBACrD,wBAAwB;aACzB,CAAC,CAAC;YAEH,MAAM,CAAC,mBAAmB,CAAC,CAAC,aAAa,CAAC;gBACxC,CAAC,wBAAwB,CAAC,EAAE,MAAM;aACnC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;YACjC,mBAAmB;YACnB,MAAM,kBAAkB,GAAG,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE9D,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;gBACrD,wBAAwB;aACzB,CAAC,CAAC;YAEH,MAAM,CAAC,mBAAmB,CAAC,CAAC,aAAa,CAAC;gBACxC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE;aAC7D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;QAC3C,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;YAC3D,MAAM,yBAAyB,GAAG,OAAO,EAAE,CAAC;YAE5C,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;gBACtD,yBAAyB;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,mBAAmB,CAAC,CAAC,aAAa,CACvC,KAAK,yBAAyB,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,63 +1,59 @@
|
|
|
1
1
|
import { aString } from '@wix/motion-runtime-test-context';
|
|
2
2
|
import { times } from 'lodash';
|
|
3
3
|
import { preset, transformations } from '../../..';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe('delete-method transformations',
|
|
7
|
-
describe('buildRequestTransformation',
|
|
8
|
-
|
|
9
|
-
test('creates a transformation that maps the first argument into requestMessageIdentifierPath',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const { RESPONSE_OBJECT_UNCHANGED } = transformations;
|
|
5
|
+
const { delete: { buildRequestTransformation, buildResponseTransformation }, } = preset;
|
|
6
|
+
describe('delete-method transformations', () => {
|
|
7
|
+
describe('buildRequestTransformation', () => {
|
|
8
|
+
const requestMessageIdentifierPath = aString();
|
|
9
|
+
test('creates a transformation that maps the first argument into requestMessageIdentifierPath', () => {
|
|
10
|
+
const transformationObject = buildRequestTransformation({
|
|
11
|
+
requestMessageIdentifierPath,
|
|
12
|
+
});
|
|
13
|
+
expect(transformationObject).toStrictEqual({
|
|
14
|
+
[requestMessageIdentifierPath]: '$[0]',
|
|
13
15
|
});
|
|
14
|
-
expect(transformationObject).toStrictEqual((_a = {},
|
|
15
|
-
_a[requestMessageIdentifierPath] = '$[0]',
|
|
16
|
-
_a));
|
|
17
16
|
});
|
|
18
|
-
test(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
test(`creates a transformation that maps the 2nd argument into requestMessageOptionsPath when provided`, () => {
|
|
18
|
+
const requestMessageOptionsPath = aString();
|
|
19
|
+
const transformationObject = buildRequestTransformation({
|
|
20
|
+
requestMessageIdentifierPath,
|
|
21
|
+
requestMessageOptionsPath,
|
|
22
|
+
});
|
|
23
|
+
expect(transformationObject).toStrictEqual({
|
|
24
|
+
[requestMessageIdentifierPath]: '$[0]',
|
|
25
|
+
[requestMessageOptionsPath]: '$[1]',
|
|
24
26
|
});
|
|
25
|
-
expect(transformationObject).toStrictEqual((_a = {},
|
|
26
|
-
_a[requestMessageIdentifierPath] = '$[0]',
|
|
27
|
-
_a[requestMessageOptionsPath] = '$[1]',
|
|
28
|
-
_a));
|
|
29
27
|
});
|
|
30
|
-
test('supports shared paths for requestMessageIdentifierPath and requestMessageOptionsPath',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
requestMessageIdentifierPath: "".concat(sharedPath, ".").concat(identifierPathSegment),
|
|
28
|
+
test('supports shared paths for requestMessageIdentifierPath and requestMessageOptionsPath', () => {
|
|
29
|
+
const sharedPath = aString();
|
|
30
|
+
const identifierPathSegment = aString();
|
|
31
|
+
const transformationObject = buildRequestTransformation({
|
|
32
|
+
requestMessageIdentifierPath: `${sharedPath}.${identifierPathSegment}`,
|
|
36
33
|
requestMessageOptionsPath: sharedPath,
|
|
37
34
|
});
|
|
38
|
-
expect(transformationObject).toStrictEqual(
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
expect(transformationObject).toStrictEqual({
|
|
36
|
+
[sharedPath]: { [identifierPathSegment]: '$[0]', '*': '$[1]' },
|
|
37
|
+
});
|
|
41
38
|
});
|
|
42
|
-
test('supports nested paths',
|
|
43
|
-
var _a, _b, _c;
|
|
39
|
+
test('supports nested paths', () => {
|
|
44
40
|
// @ts-expect-error
|
|
45
|
-
|
|
41
|
+
const idPathSegments = times(2, aString);
|
|
46
42
|
// @ts-expect-error
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const optionsPathSegments = times(2, aString);
|
|
44
|
+
const transformationObject = buildRequestTransformation({
|
|
49
45
|
requestMessageIdentifierPath: idPathSegments.join('.'),
|
|
50
46
|
requestMessageOptionsPath: optionsPathSegments.join('.'),
|
|
51
47
|
});
|
|
52
|
-
expect(transformationObject).toStrictEqual(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
expect(transformationObject).toStrictEqual({
|
|
49
|
+
[idPathSegments[0]]: { [idPathSegments[1]]: '$[0]' },
|
|
50
|
+
[optionsPathSegments[0]]: { [optionsPathSegments[1]]: '$[1]' },
|
|
51
|
+
});
|
|
56
52
|
});
|
|
57
53
|
});
|
|
58
|
-
describe('buildResponseTransformation',
|
|
59
|
-
test('returns the identity transformation',
|
|
60
|
-
|
|
54
|
+
describe('buildResponseTransformation', () => {
|
|
55
|
+
test('returns the identity transformation', () => {
|
|
56
|
+
const trasformationString = buildResponseTransformation();
|
|
61
57
|
expect(trasformationString).toStrictEqual(RESPONSE_OBJECT_UNCHANGED);
|
|
62
58
|
});
|
|
63
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/delete-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/delete-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,EAAE,yBAAyB,EAAE,GAAG,eAAe,CAAC;AACtD,MAAM,EACJ,MAAM,EAAE,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,GACpE,GAAG,MAAM,CAAC;AAEX,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,MAAM,4BAA4B,GAAG,OAAO,EAAE,CAAC;QAE/C,IAAI,CAAC,yFAAyF,EAAE,GAAG,EAAE;YACnG,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;gBACtD,4BAA4B;aAC7B,CAAC,CAAC;YAEH,MAAM,CAAC,oBAAoB,CAAC,CAAC,aAAa,CAAC;gBACzC,CAAC,4BAA4B,CAAC,EAAE,MAAM;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,kGAAkG,EAAE,GAAG,EAAE;YAC5G,MAAM,yBAAyB,GAAG,OAAO,EAAE,CAAC;YAC5C,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;gBACtD,4BAA4B;gBAC5B,yBAAyB;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,oBAAoB,CAAC,CAAC,aAAa,CAAC;gBACzC,CAAC,4BAA4B,CAAC,EAAE,MAAM;gBACtC,CAAC,yBAAyB,CA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AC,CAAC,CAAC;IAEH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;QAC3C,IAAI,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC/C,MAAM,mBAAmB,GAAG,2BAA2B,EAAE,CAAC;YAE1D,MAAM,CAAC,mBAAmB,CAAC,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,38 +1,36 @@
|
|
|
1
1
|
import { aString } from '@wix/motion-runtime-test-context';
|
|
2
2
|
import { times } from 'lodash';
|
|
3
3
|
import { preset } from '../../..';
|
|
4
|
-
|
|
5
|
-
describe('get-method transformations',
|
|
6
|
-
describe('buildRequestTransformation',
|
|
7
|
-
|
|
8
|
-
test('creates a transformation that maps the first argument into requestMessageIdentifierPath',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const { get: { buildRequestTransformation, buildResponseTransformation }, } = preset;
|
|
5
|
+
describe('get-method transformations', () => {
|
|
6
|
+
describe('buildRequestTransformation', () => {
|
|
7
|
+
const requestMessageIdentifierPath = aString();
|
|
8
|
+
test('creates a transformation that maps the first argument into requestMessageIdentifierPath', () => {
|
|
9
|
+
const transformationObject = buildRequestTransformation({
|
|
10
|
+
requestMessageIdentifierPath,
|
|
11
|
+
});
|
|
12
|
+
expect(transformationObject).toStrictEqual({
|
|
13
|
+
[requestMessageIdentifierPath]: '$[0]',
|
|
12
14
|
});
|
|
13
|
-
expect(transformationObject).toStrictEqual((_a = {},
|
|
14
|
-
_a[requestMessageIdentifierPath] = '$[0]',
|
|
15
|
-
_a));
|
|
16
15
|
});
|
|
17
|
-
test('supports a nested path',
|
|
18
|
-
var _a, _b;
|
|
16
|
+
test('supports a nested path', () => {
|
|
19
17
|
// @ts-expect-errora
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const idPathSegments = times(2, aString);
|
|
19
|
+
const transformationObject = buildRequestTransformation({
|
|
22
20
|
requestMessageIdentifierPath: idPathSegments.join('.'),
|
|
23
21
|
});
|
|
24
|
-
expect(transformationObject).toStrictEqual(
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
expect(transformationObject).toStrictEqual({
|
|
23
|
+
[idPathSegments[0]]: { [idPathSegments[1]]: '$[0]' },
|
|
24
|
+
});
|
|
27
25
|
});
|
|
28
26
|
});
|
|
29
|
-
describe('buildResponseTransformation',
|
|
30
|
-
test('unwraps the value of the provided property-path',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
responseMessageResultPath
|
|
27
|
+
describe('buildResponseTransformation', () => {
|
|
28
|
+
test('unwraps the value of the provided property-path', () => {
|
|
29
|
+
const responseMessageResultPath = aString();
|
|
30
|
+
const transformationString = buildResponseTransformation({
|
|
31
|
+
responseMessageResultPath,
|
|
34
32
|
});
|
|
35
|
-
expect(transformationString).toStrictEqual(
|
|
33
|
+
expect(transformationString).toStrictEqual(`$.${responseMessageResultPath}`);
|
|
36
34
|
});
|
|
37
35
|
});
|
|
38
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/get-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"get-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/get-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,EACJ,GAAG,EAAE,EAAE,0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ACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { aString } from '@wix/motion-runtime-test-context';
|
|
2
2
|
import { preset } from '../../..';
|
|
3
|
-
|
|
4
|
-
describe('list-method transformations',
|
|
5
|
-
describe('buildRequestTransformation',
|
|
3
|
+
const { list: { buildRequestTransformation, buildResponseTransformation }, } = preset;
|
|
4
|
+
describe('list-method transformations', () => {
|
|
5
|
+
describe('buildRequestTransformation', () => {
|
|
6
6
|
// eslint-disable-next-line max-len
|
|
7
|
-
test('returns the passthrough request transformation',
|
|
8
|
-
|
|
7
|
+
test('returns the passthrough request transformation', () => {
|
|
8
|
+
const transformationString = buildRequestTransformation();
|
|
9
9
|
expect(transformationString).toStrictEqual('$[0]');
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
describe('buildResponseTransformation',
|
|
13
|
-
test('unwraps the value of the provided property-path',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
responseMessageResultPath
|
|
12
|
+
describe('buildResponseTransformation', () => {
|
|
13
|
+
test('unwraps the value of the provided property-path', () => {
|
|
14
|
+
const responseMessageResultPath = aString();
|
|
15
|
+
const transformationString = buildResponseTransformation({
|
|
16
|
+
responseMessageResultPath,
|
|
17
17
|
});
|
|
18
|
-
expect(transformationString).toStrictEqual(
|
|
18
|
+
expect(transformationString).toStrictEqual(`$.${responseMessageResultPath}`);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/list-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"list-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/list-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,EACJ,IAAI,EAAE,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,GAClE,GAAG,MAAM,CAAC;AAEX,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,mCAAmC;QACnC,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;YAC1D,MAAM,oBAAoB,GAAG,0BAA0B,EAAE,CAAC;YAE1D,MAAM,CAAC,oBAAoB,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;QAC3C,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;YAC3D,MAAM,yBAAyB,GAAG,OAAO,EAAE,CAAC;YAE5C,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;gBACvD,yBAAyB;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,oBAAoB,CAAC,CAAC,aAAa,CACxC,KAAK,yBAAyB,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,55 +1,54 @@
|
|
|
1
1
|
import { aString } from '@wix/motion-runtime-test-context';
|
|
2
2
|
import { times } from 'lodash';
|
|
3
3
|
import { preset } from '../../..';
|
|
4
|
-
|
|
5
|
-
describe('query-method transformations',
|
|
6
|
-
describe('buildRequestTransformation',
|
|
4
|
+
const { query: { buildRequestTransformation, buildResponseTransformation }, } = preset;
|
|
5
|
+
describe('query-method transformations', () => {
|
|
6
|
+
describe('buildRequestTransformation', () => {
|
|
7
7
|
// eslint-disable-next-line max-len
|
|
8
|
-
test('sets the query object as a property named via requestQueryObjectPropertyName, and spreads the 2nd argument',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
test('sets the query object as a property named via requestQueryObjectPropertyName, and spreads the 2nd argument', () => {
|
|
9
|
+
const requestQueryObjectPropertyName = aString();
|
|
10
|
+
const transformationString = buildRequestTransformation({
|
|
11
|
+
requestQueryObjectPropertyName,
|
|
12
|
+
});
|
|
13
|
+
expect(transformationString).toStrictEqual({
|
|
14
|
+
[requestQueryObjectPropertyName]: '$[0]',
|
|
15
|
+
'*': '$[1]',
|
|
13
16
|
});
|
|
14
|
-
expect(transformationString).toStrictEqual((_a = {},
|
|
15
|
-
_a[requestQueryObjectPropertyName] = '$[0]',
|
|
16
|
-
_a['*'] = '$[1]',
|
|
17
|
-
_a));
|
|
18
17
|
});
|
|
19
18
|
// eslint-disable-next-line max-len
|
|
20
|
-
test("sets the given query tree under the 'query' property as a default, with the second argument spread into the payload",
|
|
21
|
-
|
|
19
|
+
test("sets the given query tree under the 'query' property as a default, with the second argument spread into the payload", () => {
|
|
20
|
+
const transformationString = buildRequestTransformation();
|
|
22
21
|
expect(transformationString).toStrictEqual({
|
|
23
22
|
query: '$[0]',
|
|
24
23
|
'*': '$[1]',
|
|
25
24
|
});
|
|
26
25
|
});
|
|
27
26
|
});
|
|
28
|
-
describe('buildResponseTransformation',
|
|
29
|
-
|
|
30
|
-
test('unwraps the value of the provided property-path',
|
|
31
|
-
|
|
32
|
-
responseMessageResultPath
|
|
33
|
-
responseMessagePagingMetadataPath
|
|
27
|
+
describe('buildResponseTransformation', () => {
|
|
28
|
+
const [responseMessageResultPath, responseMessagePagingMetadataPath] = times(2, () => aString());
|
|
29
|
+
test('unwraps the value of the provided property-path', () => {
|
|
30
|
+
const transformationObject = buildResponseTransformation({
|
|
31
|
+
responseMessageResultPath,
|
|
32
|
+
responseMessagePagingMetadataPath,
|
|
34
33
|
});
|
|
35
34
|
expect(transformationObject).toStrictEqual({
|
|
36
|
-
items:
|
|
37
|
-
pagingMetadata:
|
|
35
|
+
items: `$.${responseMessageResultPath}`,
|
|
36
|
+
pagingMetadata: `$.${responseMessagePagingMetadataPath}`,
|
|
38
37
|
});
|
|
39
38
|
});
|
|
40
|
-
test('adds an item-transformation when provided',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
responseMessageResultPath
|
|
44
|
-
responseMessagePagingMetadataPath
|
|
45
|
-
itemTransformation
|
|
39
|
+
test('adds an item-transformation when provided', () => {
|
|
40
|
+
const itemTransformation = `$.some.path.${aString()}`;
|
|
41
|
+
const transformationObject = buildResponseTransformation({
|
|
42
|
+
responseMessageResultPath,
|
|
43
|
+
responseMessagePagingMetadataPath,
|
|
44
|
+
itemTransformation,
|
|
46
45
|
});
|
|
47
46
|
expect(transformationObject).toStrictEqual({
|
|
48
47
|
items: {
|
|
49
|
-
'@path':
|
|
48
|
+
'@path': `$.${responseMessageResultPath}`,
|
|
50
49
|
'@itemTransformation': itemTransformation,
|
|
51
50
|
},
|
|
52
|
-
pagingMetadata:
|
|
51
|
+
pagingMetadata: `$.${responseMessagePagingMetadataPath}`,
|
|
53
52
|
});
|
|
54
53
|
});
|
|
55
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/query-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"query-transformation.spec.js","sourceRoot":"","sources":["../../../../../src/__tests__/transformations/preset/query-transformation.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,QAA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