From 6741e82479aa5dd0125183d8de494205629f18ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arwid=20Thornstr=C3=B6m?= Date: Wed, 8 Dec 2021 11:00:15 +0100 Subject: [PATCH] 89-poster-defaults (#96) * print defaults in printproducts * Add default to printproduct mutation * added insertDefaults when changing productgroup * fixed bug for square in square * cleanup, and tests for calculations * small fixes, added return values for update --- package.json | 3 +- src/__test__/unit.test.ts | 2 + .../printproduct-defaults-api.test.ts | 3294 +++++++++++++++++ src/datasources/printproduct-defaults-api.ts | 245 ++ src/datasources/product-api.ts | 31 +- src/index.ts | 10 +- src/resolvers/products-resolver.ts | 23 + src/schema.graphql | 67 +- src/types/printproduct-defaults-types.ts | 14 + 9 files changed, 3669 insertions(+), 20 deletions(-) create mode 100644 src/datasources/printproduct-defaults-api.test.ts create mode 100644 src/datasources/printproduct-defaults-api.ts create mode 100644 src/types/printproduct-defaults-types.ts diff --git a/package.json b/package.json index 1ca471b..6bd0c7c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "exportSQL": "cd src/__test__/db_generator/ && npm install && node index.js && cd ../../../", "test": "npm run exportSQL && jest --detectOpenHandles", "test:dev": "npm run exportSQL && jest --watch", - "unit:dev": "jest --watch src/__test__/unit.test.ts", + "unit": "jest --testPathIgnorePatterns=\"src/__test__/all.test.ts\"", + "unit:dev": "jest --testPathIgnorePatterns=\"src/__test__/all.test.ts\" --watch src/**/*", "test:manual": "cd manual-tests && ts-node test-scopes.ts" }, "engines": { diff --git a/src/__test__/unit.test.ts b/src/__test__/unit.test.ts index 0f45478..8c9f9d4 100644 --- a/src/__test__/unit.test.ts +++ b/src/__test__/unit.test.ts @@ -48,6 +48,7 @@ describe('GraphQL Apollo unit tests', () => { expect(() => checkAccess(['orders.read'], auth)).not.toThrow(); }); }); + describe('Test auth not ok for test', () => { it('user bla is accepted', () => { const auth: ClaimVerifyResult = { @@ -86,6 +87,7 @@ describe('GraphQL Apollo unit tests', () => { ).not.toThrow(); }); }); + describe('Test id auth no enough', () => { it('user test is accepted', () => { const auth = JSON.parse(JSON.stringify(idTokenAuth)) as ClaimVerifyResult; diff --git a/src/datasources/printproduct-defaults-api.test.ts b/src/datasources/printproduct-defaults-api.test.ts new file mode 100644 index 0000000..57026e8 --- /dev/null +++ b/src/datasources/printproduct-defaults-api.test.ts @@ -0,0 +1,3294 @@ +import { calculateDefaultPositioning } from './printproduct-defaults-api'; + +describe('Datasource: printproduct-defaults-api', () => { + const controlValues = [ + { + focusYpoint2: 48.980104501608, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 51.068785663338, + height_mm: 500, + width: 2000, + crop_y: 0.114566523440095, + print_id: 131293, + }, + { + focusYpoint2: 43.619372990354, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 51.496745720399, + height_mm: 500, + width: 2000, + crop_y: 0.060959208327555, + print_id: 131290, + }, + { + focusYpoint2: 43.621047695606, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 50.926132310984, + height_mm: 500, + width: 2000, + crop_y: 0.060975955380075, + print_id: 131286, + }, + { + focusYpoint2: 50.566964285714, + width_mm: 700, + height: 2000, + crop_x: 0.14779333095578, + focusXpoint2: 49.779333095578, + height_mm: 500, + width: 4000, + crop_y: 0, + print_id: 131282, + }, + { + focusYpoint2: 59.256213450292, + width_mm: 500, + height: 2000, + crop_x: 0.116846948306333, + focusXpoint2: 48.35502853067, + height_mm: 500, + width: 2727, + crop_y: 0, + print_id: 131278, + }, + { + focusYpoint2: 83.813973740622, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 55.776346291013, + height_mm: 500, + width: 2000, + crop_y: 0.24953095684803, + print_id: 131274, + }, + { + focusYpoint2: 82.740487674169, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 55.631463980029, + height_mm: 500, + width: 2000, + crop_y: 0.24953095684803, + print_id: 131271, + }, + { + focusYpoint2: 84.449524383708, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 55.34392831669, + height_mm: 500, + width: 2000, + crop_y: 0.24953095684803, + print_id: 131265, + }, + { + focusYpoint2: 60.055946861626, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50.640825606277, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131263, + }, + { + focusYpoint2: 49.520833333333, + width_mm: 500, + height: 2000, + crop_x: 0.206780011234285, + focusXpoint2: 58.201453281027, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131259, + }, + { + focusYpoint2: 59.044642857143, + width_mm: 500, + height: 2000, + crop_x: 0.183955474857685, + focusXpoint2: 55.918999643367, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131255, + }, + { + focusYpoint2: 57.901785714286, + width_mm: 500, + height: 2000, + crop_x: 0.191076997682215, + focusXpoint2: 56.63115192582, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131251, + }, + { + focusYpoint2: 41.71235380117, + width_mm: 500, + height: 2000, + crop_x: 0.125383859861263, + focusXpoint2: 49.208719686163, + height_mm: 500, + width: 2727, + crop_y: 0, + print_id: 131246, + }, + { + focusYpoint2: 79.616071428571, + width_mm: 500, + height: 2000, + crop_x: 0.24953095684803, + focusXpoint2: 71.89617510699, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131242, + }, + { + focusYpoint2: 52.184523809524, + width_mm: 500, + height: 2000, + crop_x: 0.096936929921875, + focusXpoint2: 47.217145149786, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131236, + }, + { + focusYpoint2: 44.377976190476, + width_mm: 500, + height: 2000, + crop_x: 0.135453335057395, + focusXpoint2: 51.068785663338, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131234, + }, + { + focusYpoint2: 46.089285714286, + width_mm: 500, + height: 2000, + crop_x: 0.085524661733575, + focusXpoint2: 46.075918330956, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131225, + }, + { + focusYpoint2: 49.904761904762, + width_mm: 500, + height: 2000, + crop_x: 0.225324947040275, + focusXpoint2: 60.055946861626, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131223, + }, + { + focusYpoint2: 60.190476190476, + width_mm: 500, + height: 2000, + crop_x: 0.216732311519595, + focusXpoint2: 59.196683309558, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131218, + }, + { + focusYpoint2: 35.044642857143, + width_mm: 500, + height: 2000, + crop_x: 0.061273591833435, + focusXpoint2: 43.650811340942, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131214, + }, + { + focusYpoint2: 51.639399072753, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50.212865549215, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131209, + }, + { + focusYpoint2: 55.149689885496, + width_mm: 500, + height: 2000, + crop_x: 0.245999102739797, + focusXpoint2: 62.053093794579, + height_mm: 500, + width: 2670, + crop_y: 0, + print_id: 131206, + }, + { + focusYpoint2: 42.279017857143, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 34.945613409415, + height_mm: 500, + width: 4000, + crop_y: 0, + print_id: 131202, + }, + { + focusYpoint2: 52.1875, + width_mm: 500, + height: 2000, + crop_x: 0.232413035485355, + focusXpoint2: 60.764755706134, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131198, + }, + { + focusYpoint2: 43.835409967846, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 31.097316333809, + height_mm: 500, + width: 2000, + crop_y: 0.0631195781024749, + print_id: 131195, + }, + { + focusYpoint2: 42.507355563481, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 49.784905492154, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131183, + }, + { + focusYpoint2: 43.413589857651, + width_mm: 700, + height: 2000, + crop_x: 0.06806303495007, + focusXpoint2: 34.806303495007, + height_mm: 500, + width: 5000, + crop_y: 0, + print_id: 131178, + }, + { + focusYpoint2: 47.206947424893, + width_mm: 700, + height: 2000, + crop_x: 0.287340257964817, + focusXpoint2: 52.067359129815, + height_mm: 500, + width: 6000, + crop_y: 0, + print_id: 131175, + }, + { + focusYpoint2: 39.040178571429, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 32.660930813124, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131170, + }, + { + focusYpoint2: 52.758928571429, + width_mm: 500, + height: 2000, + crop_x: 0.24953095684803, + focusXpoint2: 65.191467546362, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131167, + }, + { + focusYpoint2: 46.628621967655, + width_mm: 700, + height: 2000, + crop_x: 0.148571364397928, + focusXpoint2: 51.923591298146, + height_mm: 500, + width: 3777, + crop_y: 0, + print_id: 131158, + }, + { + focusYpoint2: 55.806547619048, + width_mm: 500, + height: 2000, + crop_x: 0.158277871434005, + focusXpoint2: 53.351239300999, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131150, + }, + { + focusYpoint2: 47.425595238095, + width_mm: 500, + height: 2000, + crop_x: 0.201040442760675, + focusXpoint2: 57.627496433666, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131146, + }, + { + focusYpoint2: 30.241396219686, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 62.481053851641, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131142, + }, + { + focusYpoint2: 53.48171221865, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 44.792038159772, + height_mm: 500, + width: 2000, + crop_y: 0.159582600610515, + print_id: 131138, + }, + { + focusYpoint2: 57.29259341637, + width_mm: 700, + height: 2000, + crop_x: 0.36478200784593, + focusXpoint2: 64.478200784593, + height_mm: 500, + width: 5000, + crop_y: 0, + print_id: 131130, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.13927870898716, + focusXpoint2: 48.927870898716, + height_mm: 500, + width: 4000, + crop_y: 0, + print_id: 131126, + }, + { + focusYpoint2: 74.889666547789, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 57.057997503566, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131122, + }, + { + focusYpoint2: 49.88864142539, + width_mm: 700, + height: 2000, + crop_x: 0.0745208854138538, + focusXpoint2: 52.352665834522, + height_mm: 500, + width: 3118, + crop_y: 0, + print_id: 131118, + }, + { + focusYpoint2: 39.390782828283, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 36.23172253923, + height_mm: 500, + width: 2828, + crop_y: 0, + print_id: 131637, + }, + { + focusYpoint2: 45.452254398827, + width_mm: 700, + height: 2000, + crop_x: 0.157927298133728, + focusXpoint2: 49.781562054208, + height_mm: 500, + width: 4119, + crop_y: 0, + print_id: 98597, + }, + { + focusYpoint2: 59.651927233429, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 33.23377318117, + height_mm: 500, + width: 4043, + crop_y: 0, + print_id: 131094, + }, + { + focusYpoint2: 37.190179528403, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 48.215718616262, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 120923, + }, + { + focusYpoint2: 53.103252141328, + width_mm: 700, + height: 2000, + crop_x: 0.0598351280671553, + focusXpoint2: 52.634629101284, + height_mm: 500, + width: 3001, + crop_y: 0, + print_id: 141407, + }, + { + focusYpoint2: 48.496993987976, + width_mm: 500, + height: 2849, + crop_x: 0, + focusXpoint2: 60.626560271041, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 131374, + }, + { + focusYpoint2: 49.292929292929, + width_mm: 500, + height: 2828, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 132153, + }, + { + focusYpoint2: 53.110096636546, + width_mm: 500, + height: 2845, + crop_x: 0, + focusXpoint2: 57.202879814551, + height_mm: 700, + width: 2000, + crop_y: 0.0158172232182776, + print_id: 131364, + }, + { + focusYpoint2: 48.006107685009, + width_mm: 500, + height: 2000, + crop_x: 0.0451588441997111, + focusXpoint2: 42.08162446505, + height_mm: 500, + width: 2662, + crop_y: 0, + print_id: 131134, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131653, + }, + { + focusYpoint2: 66.546762589928, + width_mm: 700, + height: 2000, + crop_x: 0.0877710655435535, + focusXpoint2: 36.571428571429, + height_mm: 500, + width: 5037, + crop_y: 0, + print_id: 132411, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0.141962047977086, + focusXpoint2: null, + height_mm: 500, + width: 2793, + crop_y: 0, + print_id: 131322, + }, + { + focusYpoint2: 50.28125, + width_mm: 700, + height: 2000, + crop_x: 0.06365014265335, + focusXpoint2: 41.365014265335, + height_mm: 500, + width: 4000, + crop_y: 0, + print_id: 131163, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 1200, + crop_x: 0.08, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 132285, + }, + { + focusYpoint2: 30.365296803653, + width_mm: 700, + height: 2000, + crop_x: 0.125, + focusXpoint2: 70.714285714286, + height_mm: 500, + width: 3200, + crop_y: 0, + print_id: 132333, + }, + { + focusYpoint2: 18, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 64.857142857143, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88688, + }, + { + focusYpoint2: 41.285714285714, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 70.142857142857, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88687, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 132407, + }, + { + focusYpoint2: 44.156953376206, + width_mm: 500, + height: 2665, + crop_x: 0, + focusXpoint2: 30.812009629101, + height_mm: 500, + width: 2000, + crop_y: 0.066335012186075, + print_id: 131186, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 1400, + crop_x: 0.237476560407179, + focusXpoint2: null, + height_mm: 500, + width: 3733, + crop_y: 0, + print_id: 88126, + }, + { + focusYpoint2: 27.618107601713, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 67.470577746077, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 89676, + }, + { + focusYpoint2: 54.464607348703, + width_mm: 700, + height: 2000, + crop_x: 0.305210918114144, + focusXpoint2: 74.317938659058, + height_mm: 500, + width: 4030, + crop_y: 0, + print_id: 114633, + }, + { + focusYpoint2: 26.636826109937, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 20.39497146933, + height_mm: 500, + width: 2967, + crop_y: 0, + print_id: 178909, + }, + { + focusYpoint2: 44.1875, + width_mm: 500, + height: 2000, + crop_x: 0.205353477710745, + focusXpoint2: 58.058799928673, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131154, + }, + { + focusYpoint2: 58.178267045455, + width_mm: 700, + height: 2000, + crop_x: 0.0165047241594302, + focusXpoint2: 45.647958273894, + height_mm: 500, + width: 3182, + crop_y: 0, + print_id: 132443, + }, + { + focusYpoint2: 34.857142857143, + width_mm: 500, + height: 2000, + crop_x: 0.24953095684803, + focusXpoint2: 71.895060627675, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131188, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0.124765478424015, + focusXpoint2: 50, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 131230, + }, + { + focusYpoint2: 52.246721092077, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 20.965584878745, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132495, + }, + { + focusYpoint2: 72.482552342971, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 25.571428571429, + height_mm: 700, + width: 1395, + crop_y: 0.02350000001953, + print_id: 77638, + }, + { + focusYpoint2: 33.840144230769, + width_mm: 700, + height: 2000, + crop_x: 0.482822312523088, + focusXpoint2: 79.167038159772, + height_mm: 500, + width: 5414, + crop_y: 0, + print_id: 119732, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 1333, + crop_x: 0.03345, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 84971, + }, + { + focusYpoint2: 26.394849785408, + width_mm: 700, + height: 1333, + crop_x: 0.02773571428571, + focusXpoint2: 49.428571428571, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 85178, + }, + { + focusYpoint2: 41.325950214133, + width_mm: 700, + height: 2000, + crop_x: 0.0311489538754133, + focusXpoint2: 49.781562054208, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 119185, + }, + { + focusYpoint2: 48.90297306959, + width_mm: 500, + height: 2997, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0.0218959302381088, + print_id: 157036, + }, + { + focusYpoint2: 43.383947939262, + width_mm: 700, + height: 1318, + crop_x: 0.00155714285714004, + focusXpoint2: 46.285714285714, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 87428, + }, + { + focusYpoint2: 49.873417721519, + width_mm: 700, + height: 2000, + crop_x: 0.0100081997596252, + focusXpoint2: 40.37089871612, + height_mm: 500, + width: 3556, + crop_y: 0, + print_id: 131114, + }, + { + focusYpoint2: 52.727272727273, + width_mm: 500, + height: 2828, + crop_x: 0, + focusXpoint2: 53.065932596291, + height_mm: 700, + width: 2000, + crop_y: 0.00990099011881183, + print_id: 132149, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 1200, + crop_x: 0.08, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 132289, + }, + { + focusYpoint2: 22.374429223744, + width_mm: 700, + height: 2000, + crop_x: 0.125, + focusXpoint2: 71, + height_mm: 500, + width: 3200, + crop_y: 0, + print_id: 132337, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88691, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0144437330861821, + focusXpoint2: 47.786644079886, + height_mm: 500, + width: 3021, + crop_y: 0, + print_id: 155884, + }, + { + focusYpoint2: 39.012258842444, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 48.643678673324, + height_mm: 500, + width: 2000, + crop_y: 0.0151694575657973, + print_id: 132645, + }, + { + focusYpoint2: 49.891260706638, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 26.812143366619, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 135298, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.120390455531453, + focusXpoint2: 50, + height_mm: 500, + width: 3688, + crop_y: 0, + print_id: 98672, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0328661995328662, + focusXpoint2: null, + height_mm: 500, + width: 2997, + crop_y: 0, + print_id: 141403, + }, + { + focusYpoint2: 40.952076222981, + width_mm: 500, + height: 2512, + crop_x: 0, + focusXpoint2: 49.499598787447, + height_mm: 500, + width: 2000, + crop_y: 0.0114315902552877, + print_id: 94100, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0333333333333333, + focusXpoint2: null, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 141594, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 156485, + }, + { + focusYpoint2: 57.343304208274, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 49.783791012839, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 144866, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131657, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 37, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131306, + }, + { + focusYpoint2: 50.525643139842, + width_mm: 500, + height: 2164, + crop_x: 0, + focusXpoint2: 65.334120898716, + height_mm: 500, + width: 2000, + crop_y: 0.0431492225259616, + print_id: 131649, + }, + { + focusYpoint2: 31.508741961415, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 28.244249286733, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 120926, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 43.935003566334, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 144878, + }, + { + focusYpoint2: 29.94555353902, + width_mm: 500, + height: 2000, + crop_x: 0.0378827233372673, + focusXpoint2: 43.142857142857, + height_mm: 500, + width: 2541, + crop_y: 0, + print_id: 130360, + }, + { + focusYpoint2: 38.756357066381, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 31.662357346648, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132491, + }, + { + focusYpoint2: 37.685693254818, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 35.655536733238, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132439, + }, + { + focusYpoint2: 49.516847534834, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.120215344489697, + print_id: 159673, + }, + { + focusYpoint2: 49.904761904762, + width_mm: 500, + height: 2000, + crop_x: 0.00422339568507507, + focusXpoint2: 37.945791726106, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 146648, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 39.938480741797, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 149512, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2997, + crop_x: 0, + focusXpoint2: null, + height_mm: 700, + width: 2000, + crop_y: 0.0328661995422089, + print_id: 155084, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0211855087969533, + focusXpoint2: 48.785217546362, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 165108, + }, + { + focusYpoint2: 49.68152866242, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 41.652549928673, + height_mm: 500, + width: 2974, + crop_y: 0, + print_id: 147588, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: null, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 162694, + }, + { + focusYpoint2: 57.713392857143, + width_mm: 500, + height: 2500, + crop_x: 0, + focusXpoint2: 54.777772824536, + height_mm: 500, + width: 2000, + crop_y: 0.17713392857143, + print_id: 132796, + }, + { + focusYpoint2: 49.677127944325, + width_mm: 700, + height: 2000, + crop_x: 0.0669776741086305, + focusXpoint2: 69.46772467903, + height_mm: 500, + width: 3001, + crop_y: 0, + print_id: 149557, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 43.714285714286, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 162730, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0328352176644527, + focusXpoint2: 49.641137660485, + height_mm: 500, + width: 3020, + crop_y: 0, + print_id: 164280, + }, + { + focusYpoint2: 48.900001144409, + width_mm: 500, + height: 2857, + crop_x: 0, + focusXpoint2: 50, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 162951, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.00430454719369261, + focusXpoint2: 46.788070613409, + height_mm: 500, + width: 3020, + crop_y: 0, + print_id: 164296, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 65, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 162722, + }, + { + focusYpoint2: 46.057142857143, + width_mm: 500, + height: 2500, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.06057142857143, + print_id: 165120, + }, + { + focusYpoint2: 36.50385555081, + width_mm: 500, + height: 3333, + crop_x: 0, + focusXpoint2: 68.571437290737, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 178911, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 157460, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 174377, + }, + { + focusYpoint2: 52.857142857143, + width_mm: 700, + height: 2000, + crop_x: 0.15991599159916, + focusXpoint2: 68.473609129815, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 153034, + }, + { + focusYpoint2: 44.966207173448, + width_mm: 700, + height: 2000, + crop_x: 0.0657323990657324, + focusXpoint2: 75.176087731812, + height_mm: 500, + width: 2997, + crop_y: 0, + print_id: 118978, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 54.777772824536, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 171592, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 56.489613052782, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 171604, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 52.780625891583, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 171608, + }, + { + focusYpoint2: 43.408360128617, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.0591304704275273, + print_id: 174393, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 168869, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131661, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131673, + }, + { + focusYpoint2: 37.41935483871, + width_mm: 700, + height: 1329, + crop_x: 0, + focusXpoint2: 36, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 87153, + }, + { + focusYpoint2: 51.107954545455, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 26.532409058488, + height_mm: 500, + width: 2828, + crop_y: 0, + print_id: 131645, + }, + { + focusYpoint2: 30.108173076923, + width_mm: 700, + height: 2000, + crop_x: 0.0227410446297213, + focusXpoint2: 47.787758559201, + height_mm: 500, + width: 3076, + crop_y: 0, + print_id: 131633, + }, + { + focusYpoint2: 47.050844051447, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 56.06165299572, + height_mm: 500, + width: 2000, + crop_y: 0.0955553096558273, + print_id: 120169, + }, + { + focusYpoint2: 38.733907421259, + width_mm: 500, + height: 2663, + crop_x: 0, + focusXpoint2: 41.571428571429, + height_mm: 500, + width: 2000, + crop_y: 0.0118227392520192, + print_id: 79837, + }, + { + focusYpoint2: 62.549867021277, + width_mm: 700, + height: 2000, + crop_x: 0.0340381865611126, + focusXpoint2: 50.352175463623, + height_mm: 500, + width: 2982, + crop_y: 0, + print_id: 141399, + }, + { + focusYpoint2: 48.861558775731, + width_mm: 500, + height: 2633, + crop_x: 0, + focusXpoint2: 48.358371968616, + height_mm: 500, + width: 2000, + crop_y: 0.108820677009114, + print_id: 152491, + }, + { + focusYpoint2: 19.86301369863, + width_mm: 700, + height: 2000, + crop_x: 0.125, + focusXpoint2: 64, + height_mm: 500, + width: 3200, + crop_y: 0, + print_id: 132341, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.106299212598425, + focusXpoint2: null, + height_mm: 500, + width: 3556, + crop_y: 0, + print_id: 141591, + }, + { + focusYpoint2: 47.187053145853, + width_mm: 500, + height: 2998, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0.00489254614432047, + print_id: 154584, + }, + { + focusYpoint2: 38.090128755365, + width_mm: 500, + height: 2660, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.00496143792958986, + print_id: 156481, + }, + { + focusYpoint2: 48.10379241517, + width_mm: 500, + height: 2000, + crop_x: 0.190405239459682, + focusXpoint2: 54.857142857143, + height_mm: 500, + width: 2792, + crop_y: 0, + print_id: 124379, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 87621, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.169811320754717, + focusXpoint2: null, + height_mm: 500, + width: 4240, + crop_y: 0, + print_id: 132293, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 45.076230385164, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 144874, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.125, + focusXpoint2: 63.428571428571, + height_mm: 500, + width: 3200, + crop_y: 0, + print_id: 132385, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.15991599159916, + focusXpoint2: 62.714285714286, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 142147, + }, + { + focusYpoint2: 60.626560271041, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 48.358371968616, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 144862, + }, + { + focusYpoint2: 49.1, + width_mm: 500, + height: 2857, + crop_x: 0, + focusXpoint2: 50, + height_mm: 700, + width: 2000, + crop_y: 0.000975498784739225, + print_id: 159669, + }, + { + focusYpoint2: 62.525093683084, + width_mm: 700, + height: 2000, + crop_x: 0.0469963263553152, + focusXpoint2: 51.3507489301, + height_mm: 500, + width: 3001, + crop_y: 0, + print_id: 132487, + }, + { + focusYpoint2: 41.818743139407, + width_mm: 500, + height: 2600, + crop_x: 0, + focusXpoint2: 54.635119472183, + height_mm: 500, + width: 2000, + crop_y: 0.0335720467786854, + print_id: 132642, + }, + { + focusYpoint2: 16.857142857143, + width_mm: 500, + height: 3000, + crop_x: 0, + focusXpoint2: 41, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 164918, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88646, + }, + { + focusYpoint2: 80.94051124197, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 56.62892296719, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132435, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0765419597380806, + focusXpoint2: 45.077344864479, + height_mm: 500, + width: 3741, + crop_y: 0, + print_id: 164688, + }, + { + focusYpoint2: 52.171697778828, + width_mm: 500, + height: 3020, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0.0581408188571541, + print_id: 164292, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: null, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 162726, + }, + { + focusYpoint2: 47.200001144409, + width_mm: 500, + height: 2857, + crop_x: 0, + focusXpoint2: 50, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 162895, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 67, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 162911, + }, + { + focusYpoint2: 45.257142857143, + width_mm: 500, + height: 2500, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.05257142857143, + print_id: 165116, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0328661995328662, + focusXpoint2: null, + height_mm: 500, + width: 2997, + crop_y: 0, + print_id: 157052, + }, + { + focusYpoint2: 50.000001144409, + width_mm: 500, + height: 2858, + crop_x: 0, + focusXpoint2: 50, + height_mm: 700, + width: 2000, + crop_y: 0.0101469673671131, + print_id: 162947, + }, + { + focusYpoint2: 47.372159090909, + width_mm: 500, + height: 2828, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 132145, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 43.364390156919, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 164728, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 48.928985378031, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 171600, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 45.933264978602, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 171596, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 168865, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 168857, + }, + { + focusYpoint2: 42.66369047619, + width_mm: 500, + height: 3000, + crop_x: 0, + focusXpoint2: 49.786019971469, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 174389, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0394736842105263, + focusXpoint2: 50, + height_mm: 500, + width: 3040, + crop_y: 0, + print_id: 175593, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0231607629427793, + focusXpoint2: null, + height_mm: 500, + width: 2936, + crop_y: 0, + print_id: 133024, + }, + { + focusYpoint2: 53.745650428266, + width_mm: 700, + height: 2000, + crop_x: 0.0382816214931033, + focusXpoint2: 50.494828815977, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 141395, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.164349076959962, + focusXpoint2: null, + height_mm: 500, + width: 4171, + crop_y: 0, + print_id: 132651, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0231607629427793, + focusXpoint2: null, + height_mm: 500, + width: 2936, + crop_y: 0, + print_id: 133032, + }, + { + focusYpoint2: 39.52380952381, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 41.285714285714, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 133040, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0.0294117647058824, + focusXpoint2: 50, + height_mm: 500, + width: 2125, + crop_y: 0, + print_id: 133427, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 134309, + }, + { + focusYpoint2: 43.661708047945, + width_mm: 500, + height: 2000, + crop_x: 0.0826200665715633, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2400, + crop_y: 0, + print_id: 100570, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131396, + }, + { + focusYpoint2: 45.219998216833, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 71.325561697575, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131426, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131665, + }, + { + focusYpoint2: 32.423453282828, + width_mm: 500, + height: 2828, + crop_x: 0, + focusXpoint2: 50.212865549215, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 132141, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.118216525770385, + focusXpoint2: null, + height_mm: 500, + width: 3667, + crop_y: 0, + print_id: 132297, + }, + { + focusYpoint2: 26.940639269406, + width_mm: 700, + height: 2000, + crop_x: 0.125, + focusXpoint2: 63.428571428571, + height_mm: 500, + width: 3200, + crop_y: 0, + print_id: 132345, + }, + { + focusYpoint2: 49.488636363636, + width_mm: 700, + height: 2000, + crop_x: 0.0099009900990099, + focusXpoint2: 52.635743580599, + height_mm: 500, + width: 2828, + crop_y: 0, + print_id: 131641, + }, + { + focusYpoint2: 27.295873955432, + width_mm: 700, + height: 2000, + crop_x: 0.240526377715671, + focusXpoint2: 59.913293509272, + height_mm: 500, + width: 3904, + crop_y: 0, + print_id: 131629, + }, + { + focusYpoint2: 52.724116161616, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 43.223965763195, + height_mm: 500, + width: 2828, + crop_y: 0, + print_id: 131621, + }, + { + focusYpoint2: 70.521838156484, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 48.215718616262, + height_mm: 500, + width: 2000, + crop_y: 0.250093738282715, + print_id: 120521, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88666, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0333333333333333, + focusXpoint2: null, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132431, + }, + { + focusYpoint2: 49.887133182844, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 41.654778887304, + height_mm: 500, + width: 3161, + crop_y: 0, + print_id: 94256, + }, + { + focusYpoint2: 47.645105206847, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 57.202879814551, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 132868, + }, + { + focusYpoint2: 53.714285714286, + width_mm: 500, + height: 2000, + crop_x: 0.125760135903127, + focusXpoint2: 50.071326676177, + height_mm: 500, + width: 2667, + crop_y: 0, + print_id: 132639, + }, + { + focusYpoint2: 50.317853319058, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 44.501159058488, + height_mm: 500, + width: 2999, + crop_y: 0, + print_id: 133004, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 39, + height_mm: 500, + width: 2832, + crop_y: 0, + print_id: 134045, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0604395604395604, + focusXpoint2: 50, + height_mm: 500, + width: 3185, + crop_y: 0, + print_id: 132702, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 38.372637303852, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133424, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133185, + }, + { + focusYpoint2: 54.196875, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 63.76604850214, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133324, + }, + { + focusYpoint2: 51.196875, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 36.232837018545, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133344, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133496, + }, + { + focusYpoint2: 32.947976878613, + width_mm: 700, + height: 2000, + crop_x: 0.153979238754325, + focusXpoint2: 50, + height_mm: 500, + width: 4046, + crop_y: 0, + print_id: 133617, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0.124765478424015, + focusXpoint2: null, + height_mm: 500, + width: 2665, + crop_y: 0, + print_id: 176827, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0657323990657324, + focusXpoint2: 54.206044935806, + height_mm: 500, + width: 2997, + crop_y: 0, + print_id: 178208, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0378367772789462, + focusXpoint2: 50.497057774608, + height_mm: 500, + width: 2997, + crop_y: 0, + print_id: 178196, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133472, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.168403600189484, + focusXpoint2: null, + height_mm: 500, + width: 4222, + crop_y: 0, + print_id: 141587, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133448, + }, + { + focusYpoint2: 43.263711734694, + width_mm: 500, + height: 2800, + crop_x: 0, + focusXpoint2: 43.793464693295, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133499, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0604395604395604, + focusXpoint2: 50, + height_mm: 500, + width: 3185, + crop_y: 0, + print_id: 132698, + }, + { + focusYpoint2: 43.773915816327, + width_mm: 500, + height: 2800, + crop_x: 0, + focusXpoint2: 50.355518901569, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133544, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0333333333333333, + focusXpoint2: null, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133008, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 61.053405848787, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 134277, + }, + { + focusYpoint2: 64.050240727532, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 52.923279243937, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 144870, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0333333333333333, + focusXpoint2: null, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 134039, + }, + { + focusYpoint2: 49.112635334646, + width_mm: 500, + height: 2899, + crop_x: 0, + focusXpoint2: 50.783478958631, + height_mm: 700, + width: 2000, + crop_y: 0.00820120675384178, + print_id: 133604, + }, + { + focusYpoint2: 36.142131979695, + width_mm: 500, + height: 2815, + crop_x: 0, + focusXpoint2: 51.857142857143, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 134097, + }, + { + focusYpoint2: 46.628571428571, + width_mm: 500, + height: 2500, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.06628571428571, + print_id: 165112, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 134029, + }, + { + focusYpoint2: 56.285714285714, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 53.857142857143, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 134053, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.118528610354223, + focusXpoint2: null, + height_mm: 500, + width: 3670, + crop_y: 0, + print_id: 133657, + }, + { + focusYpoint2: 46.361225035663, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 43.936118045649, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133961, + }, + { + focusYpoint2: 30.38404957204, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 41.368357703281, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133945, + }, + { + focusYpoint2: 50.105393468951, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 32.946237517832, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133929, + }, + { + focusYpoint2: 62.766360556348, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 48.928985378031, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133913, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0397304446029433, + focusXpoint2: 50.639711126961, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133881, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.298141653971073, + focusXpoint2: 54.492466119829, + height_mm: 500, + width: 5673, + crop_y: 0, + print_id: 121908, + }, + { + focusYpoint2: 63.595757494647, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 67.183042082739, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132483, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133181, + }, + { + focusYpoint2: 52.196875, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 57.057997503566, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133340, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133429, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133493, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133469, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.164349076959962, + focusXpoint2: null, + height_mm: 500, + width: 4171, + crop_y: 0, + print_id: 132655, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133445, + }, + { + focusYpoint2: 43.263711734694, + width_mm: 500, + height: 2800, + crop_x: 0, + focusXpoint2: 56.917573109843, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133553, + }, + { + focusYpoint2: 58.629413338088, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 52.067359129815, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 134273, + }, + { + focusYpoint2: 43.875956632653, + width_mm: 500, + height: 2800, + crop_x: 0, + focusXpoint2: 49.927558844508, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133541, + }, + { + focusYpoint2: 48.787878787879, + width_mm: 500, + height: 2828, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 132137, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.118216525770385, + focusXpoint2: null, + height_mm: 500, + width: 3667, + crop_y: 0, + print_id: 132301, + }, + { + focusYpoint2: 42.694063926941, + width_mm: 700, + height: 2000, + crop_x: 0.125, + focusXpoint2: 69.428571428571, + height_mm: 500, + width: 3200, + crop_y: 0, + print_id: 132349, + }, + { + focusYpoint2: 39.142857142857, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 51.142857142857, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88689, + }, + { + focusYpoint2: 33.654876741693, + width_mm: 500, + height: 2667, + crop_x: 0, + focusXpoint2: 66.428571428571, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 88640, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0333333333333333, + focusXpoint2: null, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133012, + }, + { + focusYpoint2: 65.619427603424, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 56.346959700428, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 144798, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0231607629427793, + focusXpoint2: null, + height_mm: 500, + width: 2936, + crop_y: 0, + print_id: 133036, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0159059474412171, + focusXpoint2: null, + height_mm: 500, + width: 2892, + crop_y: 0, + print_id: 133044, + }, + { + focusYpoint2: 46.632116336634, + width_mm: 500, + height: 2882, + crop_x: 0, + focusXpoint2: 49.214292082739, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133601, + }, + { + focusYpoint2: 50, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131392, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131669, + }, + { + focusYpoint2: 46.680766574586, + width_mm: 700, + height: 2000, + crop_x: 0.0690448733721075, + focusXpoint2: 43.080197931526, + height_mm: 500, + width: 3870, + crop_y: 0, + print_id: 131625, + }, + { + focusYpoint2: 52.805755395683, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 44.714285714286, + height_mm: 500, + width: 2015, + crop_y: 0, + print_id: 134101, + }, + { + focusYpoint2: 52.210012482168, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 53.921852710414, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133861, + }, + { + focusYpoint2: 41.083050998573, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 52.352665834522, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 132864, + }, + { + focusYpoint2: 41.968348501071, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 63.760476105563, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 132427, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0906458524329599, + focusXpoint2: 51.068785663338, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 144902, + }, + { + focusYpoint2: 65.796967455621, + width_mm: 500, + height: 2410, + crop_x: 0, + focusXpoint2: 46.361225035663, + height_mm: 500, + width: 2000, + crop_y: 0.170124481327801, + print_id: 132479, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.09635198652711, + focusXpoint2: 51.639399072753, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 144925, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 134037, + }, + { + focusYpoint2: 6.2352941176471, + width_mm: 500, + height: 2429, + crop_x: 0, + focusXpoint2: 36.857138497489, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 100558, + }, + { + focusYpoint2: 63.595757494647, + width_mm: 700, + height: 2000, + crop_x: 0.0382816214931033, + focusXpoint2: 50.494828815977, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 141391, + }, + { + focusYpoint2: 30.669356276748, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 53.065932596291, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133957, + }, + { + focusYpoint2: 42.9, + width_mm: 500, + height: 2858, + crop_x: 0, + focusXpoint2: 50, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 162943, + }, + { + focusYpoint2: 28.672209343795, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 40.512437589158, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133941, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0604395604395604, + focusXpoint2: 50, + height_mm: 500, + width: 3185, + crop_y: 0, + print_id: 132706, + }, + { + focusYpoint2: 47.217145149786, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 41.796317760342, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133813, + }, + { + focusYpoint2: 51.196875, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 56.489613052782, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133420, + }, + { + focusYpoint2: 59.770640156919, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 46.503878388017, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 134305, + }, + { + focusYpoint2: 64.236902050114, + width_mm: 700, + height: 2000, + crop_x: 0.116842812360058, + focusXpoint2: 55.571428571429, + height_mm: 500, + width: 3190, + crop_y: 0, + print_id: 133633, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0666666666666667, + focusXpoint2: 65.190353067047, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 144942, + }, + { + focusYpoint2: 20.600858369099, + width_mm: 700, + height: 1334, + crop_x: 0.0559571428571401, + focusXpoint2: 52.285714285714, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 87971, + }, + { + focusYpoint2: 42.610746788009, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 40.937054208274, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133925, + }, + { + focusYpoint2: 58.456571199143, + width_mm: 700, + height: 2000, + crop_x: 0.0568265572990933, + focusXpoint2: 52.349322396576, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133909, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.033022014676451, + focusXpoint2: null, + height_mm: 500, + width: 2998, + crop_y: 0, + print_id: 141583, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0685296074517631, + focusXpoint2: 57.142857142857, + height_mm: 500, + width: 3006, + crop_y: 0, + print_id: 134049, + }, + { + focusYpoint2: 54.635119472183, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 38.372637303852, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133877, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0333333333333333, + focusXpoint2: 50, + height_mm: 500, + width: 3000, + crop_y: 0, + print_id: 133865, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 144858, + }, + { + focusYpoint2: 51.724137931034, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 46.142857142857, + height_mm: 500, + width: 2842, + crop_y: 0, + print_id: 133621, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0.0231607629427793, + focusXpoint2: null, + height_mm: 500, + width: 2936, + crop_y: 0, + print_id: 133028, + }, + { + focusYpoint2: 55.298099078341, + width_mm: 500, + height: 3097, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 700, + width: 2000, + crop_y: 0.0958992573639005, + print_id: 152485, + }, + { + focusYpoint2: 49.892933618844, + width_mm: 700, + height: 2000, + crop_x: 0.0137415225223809, + focusXpoint2: 48.071950784593, + height_mm: 500, + width: 2998, + crop_y: 0, + print_id: 166843, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0728476821192053, + focusXpoint2: 65.903619828816, + height_mm: 500, + width: 3020, + crop_y: 0, + print_id: 164288, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 1333, + crop_x: 0, + focusXpoint2: 38.285714285714, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 91429, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.1820747146933, + focusXpoint2: 53.20747146933, + height_mm: 500, + width: 4000, + crop_y: 0, + print_id: 132636, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 131424, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.07995799579958, + focusXpoint2: 50, + height_mm: 500, + width: 3333, + crop_y: 0, + print_id: 131677, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0.0604395604395604, + focusXpoint2: 50, + height_mm: 500, + width: 3185, + crop_y: 0, + print_id: 132710, + }, + { + focusYpoint2: 58.058799928673, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 50.070212196862, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133905, + }, + { + focusYpoint2: 45.407366071429, + width_mm: 500, + height: 2796, + crop_x: 0, + focusXpoint2: 49.928673323823, + height_mm: 500, + width: 2000, + crop_y: 0.096419869584104, + print_id: 135034, + }, + { + focusYpoint2: 54.796875, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 59.198912268188, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133416, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133177, + }, + { + focusYpoint2: 53.596875, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 58.344106633381, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133336, + }, + { + focusYpoint2: 61.823361823362, + width_mm: 700, + height: 2000, + crop_x: 0.147782152700721, + focusXpoint2: 49.857142857143, + height_mm: 500, + width: 3991, + crop_y: 0, + print_id: 133625, + }, + { + focusYpoint2: 45.219998216833, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: 48.928985378031, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 133873, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133489, + }, + { + focusYpoint2: null, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133466, + }, + { + focusYpoint2: 50, + width_mm: 700, + height: 2000, + crop_x: 0, + focusXpoint2: 53.208585948645, + height_mm: 500, + width: 2800, + crop_y: 0, + print_id: 133442, + }, + { + focusYpoint2: null, + width_mm: 500, + height: 2000, + crop_x: 0, + focusXpoint2: null, + height_mm: 500, + width: 2000, + crop_y: 0, + print_id: 87028, + }, + { + focusYpoint2: 33.532196969697, + width_mm: 700, + height: 2000, + crop_x: 0.0099009900990099, + focusXpoint2: 61.625133737518, + height_mm: 500, + width: 2828, + crop_y: 0, + print_id: 131617, + }, + { + focusYpoint2: 42.957589285714, + width_mm: 500, + height: 2800, + crop_x: 0, + focusXpoint2: 50.212865549215, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133550, + }, + { + focusYpoint2: 42.141262755102, + width_mm: 500, + height: 2800, + crop_x: 0, + focusXpoint2: 54.492466119829, + height_mm: 700, + width: 2000, + crop_y: 0, + print_id: 133538, + }, + { + focusYpoint2: 49.310842337917, + width_mm: 500, + height: 2000, + crop_x: 0.239370986904647, + focusXpoint2: 60.195256776034, + height_mm: 500, + width: 2758, + crop_y: 0, + print_id: 132423, + }, + { + focusYpoint2: 48.758928571429, + width_mm: 500, + height: 2000, + crop_x: 0.215609458299707, + focusXpoint2: 59.056258915835, + height_mm: 500, + width: 2667, + crop_y: 0, + print_id: 134937, + }, + ]; + + it('should return correct values for all testdata', () => { + for (const v of controlValues) { + const result = calculateDefaultPositioning( + v.width, + v.height, + v.focusXpoint2, + v.focusYpoint2, + ); + + expect(result.width_mm).toBe(v.width_mm); + expect(result.height_mm).toBe(v.height_mm); + + expect(parseFloat(result.crop_x.toFixed(10))).toBe( + parseFloat(v.crop_x.toFixed(10)), + ); + expect(parseFloat(result.crop_y.toFixed(10))).toBe( + parseFloat(v.crop_y.toFixed(10)), + ); + } + }); +}); diff --git a/src/datasources/printproduct-defaults-api.ts b/src/datasources/printproduct-defaults-api.ts new file mode 100644 index 0000000..2a0d660 --- /dev/null +++ b/src/datasources/printproduct-defaults-api.ts @@ -0,0 +1,245 @@ +import { Maybe } from 'graphql/jsutils/Maybe'; +import { + BorderType, + PrintProductDefaults, +} from '../types/printproduct-defaults-types'; +import { BaseSQLDataSource } from './BaseSQLDataSource'; + +type TPosterDefaultPositioning = { + width_mm: number; + height_mm: number; + crop_x: number; + crop_y: number; +}; +export const calculateDefaultPositioning = ( + productWidth: number, + productHeight: number, + focusXpoint2: number, + focusYpoint2: number, +): TPosterDefaultPositioning => { + // Because we dont want to be dependent on different environments + // number of supported decimals to round to 10 decimal places. + // And I know 70/50 is 1.4 so its not needed but added for clarity. + const size70x50ratio = parseFloat((70 / 50).toFixed(10)); + const size50x70ratio = parseFloat((50 / 70).toFixed(10)); + const width_height_ratio = productWidth / productHeight; + + // If focuspoints are null we set to 50 to make calculations + // below a bit clearer. + const fpX = focusXpoint2 === null ? 50 : focusXpoint2; + const fpY = focusYpoint2 === null ? 50 : focusYpoint2; + + const width_mm = width_height_ratio >= size70x50ratio ? 700 : 500; + const height_mm = width_height_ratio <= size50x70ratio ? 700 : 500; + + // Calculate where to put the crop_x percent value + // We place the center of the crop area as close to + // the focusXpoint2 and focusYpoint2 values. We do + // different calculations depending on if the poster size + // orientation (landscape, portrait or square) is inside + // the motif orientation. + // + // The goal for the calculations is to get the smallest amount of area + // that we crop away. + const crop_x = (() => { + if (width_height_ratio >= size70x50ratio) { + const centerOfRatioArea = (productHeight * 1.4) / 2; + let x = Math.max(centerOfRatioArea, (fpX / 100) * productWidth); // Place center close to focuspointX but not outside the left edge + x = Math.min(productWidth - centerOfRatioArea, x); // Dont place outside the right edge + x = x - centerOfRatioArea; // Convert center to left edge + x = x / productWidth; // Convert to percent; + return x; + } else if ( + // Square in landscape + width_height_ratio > 1 && + width_height_ratio < size70x50ratio + ) { + const centerOfRatioArea = productHeight / 2; + let x = Math.max(centerOfRatioArea, (fpX / 100) * productWidth); // Place center close to focuspointX but not outside the left side + x = Math.min(productWidth - centerOfRatioArea, x); // Dont place outside the right edge + x = x - centerOfRatioArea; // Convert center to left edge + x = x / productWidth; // Convert to percent + return x; + } else { + // If the scenario is, square in portrait, portrait in portrait or square + // in square then we are placing vertical, therefor x will be 0. + return 0; + } + })(); + + // Read comment for crop_x above. + const crop_y = (() => { + if (width_height_ratio < 1 && width_height_ratio > size50x70ratio) { + // Square in portrait + const centerOfRatioArea = productWidth / 2; + let y = Math.max(centerOfRatioArea, (fpY / 100) * productHeight); // Place center close to focuspointY but not ouside top edge + y = Math.min(productHeight - centerOfRatioArea, y); // Dont place outside bottom edge + y = y - centerOfRatioArea; // Convert center to top edge + y = y / productHeight; // Convert to percent + return y; + } else if (width_height_ratio <= size50x70ratio) { + // Portrait in portrait + const centerOfRatioArea = productWidth / size50x70ratio / 2; + let y = Math.max(centerOfRatioArea, (fpY / 100) * productHeight); // Place center close to focuspointY but not ouside top edge + y = Math.min(productHeight - centerOfRatioArea, y); // Dont place outside bottom edge + y = y - centerOfRatioArea; // Convert center to top edge + y = y / productHeight; // Convert to percent + return y; + } else { + // If the scenario is landscape in landscape, square in landscape or square in square + // the we are placing horizontal and therefor y will be 0. + return 0; + } + })(); + + return { width_mm, height_mm, crop_x, crop_y }; +}; + +export class PrintProductDefaultsAPI extends BaseSQLDataSource { + constructor(config) { + super(config); + } + + /** + * @function getBorderType + * @description Will convert lowercase none | white | black to + * uppercase and define it as a BorderType + */ + getBorderType(dbValue: string): string { + switch (dbValue) { + case 'white': + return BorderType[BorderType.WHITE]; + case 'black': + return BorderType[BorderType.BLACK]; + default: + return BorderType[BorderType.NONE]; + } + } + + /** + * @function getDefaults + * @description This function will fetch the default values from printproducts_defaults table + * with the printId as a key. Border is defined in lowercase in DB but returned in uppercase + * to keep consistency in both DB and graphql. + */ + async getDefaults(printId: number): Promise> { + return this.knex + .column( + { printId: 'print_id' }, + { widthMm: 'width_mm' }, + { heightMm: 'height_mm' }, + { cropX: 'crop_x' }, + { cropY: 'crop_y' }, + 'border', + ) + .select() + .from('printproducts_defaults') + .where('print_id', printId) + .first() + .then((row) => { + if (row) { + return Object.assign( + { + ...row, + }, + { border: this.getBorderType(row.border) }, + ); + } else { + return null; + } + }); + } + + /** + * @function insertDefaults + * @description Inserts a new printproduct into printproducts_defaults, sets the default + * values the same way we did when settings default values for all older printproducts. + */ + async insertDefaults(printId: number): Promise<0 | 1> { + const product = await this.knex.raw( + ` + SELECT width, height, "focusXpoint2", "focusYpoint2" FROM + "product-printproducts" ppp + JOIN v_product vp ON ppp.productid = vp.id + WHERE printid = ?`, + [printId], + ); + + const { width, height, focusXpoint2, focusYpoint2 } = product.rows[0]; + + // GUARDS + if (!width || !height) + throw new Error( + 'PrintProductDefaultsAPI.insertDefaults: width and height must be defined for a motif to be able to set defaults', + ); + + const { width_mm, height_mm, crop_x, crop_y } = calculateDefaultPositioning( + width, + height, + focusXpoint2, + focusYpoint2, + ); + + return this.knex + .raw( + ` + INSERT INTO printproducts_defaults (print_id, width_mm, height_mm, crop_x, crop_y, border) + VALUES (?, ?, ?, ?, ?, 'none'); + `, + [printId, width_mm, height_mm, crop_x, crop_y], + ) + .catch((e) => { + throw new Error(e); + }); + } + + // --------------------------------------------------------- + // MUTATIONS + // --------------------------------------------------------- + + /** + * @function updateDefaults + * @description Updates or inserts default values for a printproduct in the + * table printproducts_defaults. + */ + async updateDefaults( + printId: number, + widthMm: number, + heightMm: number, + cropX: number, + cropY: number, + border: 'none' | 'white' | 'black', + ): Promise { + return this.knex + .table('printproducts_defaults') + .update( + { + width_mm: widthMm, + height_mm: heightMm, + crop_x: cropX, + crop_y: cropY, + border: border.toLocaleLowerCase(), + }, + ['print_id', 'width_mm', 'height_mm', 'crop_x', 'crop_y', 'border'], + ) + .where({ print_id: printId }) + .then((row) => { + if (row) { + const first = row[0]; + return Object.assign( + { + ...first, + }, + { border: this.getBorderType(first.border) }, + ); + } else { + return null; + } + }) + .catch((e) => { + throw new Error( + `Something went wrong when trying to update with printid [${printId}][${e.message}]`, + ); + }); + } +} diff --git a/src/datasources/product-api.ts b/src/datasources/product-api.ts index f4d881c..1ca2856 100644 --- a/src/datasources/product-api.ts +++ b/src/datasources/product-api.ts @@ -30,14 +30,18 @@ import { import { UserInputError } from 'apollo-server'; import { sendPathChangedCmd } from '../bernard/client'; import { TextsAPI } from './texts-api'; +import { PrintProductDefaultsAPI } from './printproduct-defaults-api'; const MINUTE = 60; export class ProductAPI extends BaseSQLDataSource { textsApi: TextsAPI; - constructor(config, textsApi) { + printProductDefaultsApi: PrintProductDefaultsAPI; + + constructor(config, textsApi, printProductDefaultsApi) { super(config); this.textsApi = textsApi; + this.printProductDefaultsApi = printProductDefaultsApi; } // async getMaterial(printId: number): Promise { @@ -607,12 +611,20 @@ export class ProductAPI extends BaseSQLDataSource { // Delete from product-printproducts_materials const printProductIds = shouldDelete.map((item) => item.printid); - // Delete from materials first, must be in sequence since we have constraint in materials to printproducts + // Delete from materials first, must be in sequence + // since we have constraint in materials to printproducts await this.knex .from('product-printproducts_materials') .whereIn('printid', printProductIds) .del(); + // Delete from printproducts_defaults, same here run + // this first because of constraint. + await this.knex + .from('printproducts_defaults') + .whereIn('printId', printProductIds) + .del(); + // Delete from product-printproducts await this.knex .from('product-printproducts') @@ -648,6 +660,21 @@ export class ProductAPI extends BaseSQLDataSource { .where('productid', productId) .whereIn('groupid', shouldAdd); + // Add printproduct-defaults for all new printIds + const insertDefaults = []; + newPrintIds.forEach(({ printid, groupid }) => { + // Possible to add for canvas and framed-print later + if (groupid === ProductGroup.POSTER) { + // Add printproduct defaults if poster + insertDefaults.push( + this.printProductDefaultsApi.insertDefaults(printid), + ); + } + }); + + // Run parallell + await Promise.all(insertDefaults); + // Insert printIds into product-printproducts_materials const insertMaterials = []; const insertMaterialQuery = `INSERT INTO "product-printproducts_materials" (printid, materialid) VALUES (?, ?)`; diff --git a/src/index.ts b/src/index.ts index 8ef1870..28eeaaa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,8 @@ import { verifyToken } from './cognito/cognito-client'; import { readFileSync } from 'fs'; import { InteriorsLambdaAPI } from './datasources/interiors-lambda-api'; import { TextsAPI } from './datasources/texts-api'; +import { PrintProductDefaultsAPI } from './datasources/printproduct-defaults-api'; + const path = require('path'); const typeDefs = readFileSync( path.join(__dirname, './schema.graphql'), @@ -35,14 +37,20 @@ const designerApi = new DesignerAPI(knexConfig); const imageServerApi = new ImageServerApi(); const interiorsLambdaApi = new InteriorsLambdaAPI(); const interiorApi = new InteriorAPI(knexConfig, imageServerApi); +const printProductDefaultsApi = new PrintProductDefaultsAPI(knexConfig); const keywordApi = new KeywordAPI(knexConfig); const orderApi = new OrderAPI(knexConfig); -const productApi = new ProductAPI(knexConfig, textsApi); +const productApi = new ProductAPI( + knexConfig, + textsApi, + printProductDefaultsApi, +); const dataSources = () => ({ categoryApi, designerApi, interiorApi, + printProductDefaultsApi, interiorsLambdaApi, imageServerApi, keywordApi, diff --git a/src/resolvers/products-resolver.ts b/src/resolvers/products-resolver.ts index e3b2e28..56dbf58 100644 --- a/src/resolvers/products-resolver.ts +++ b/src/resolvers/products-resolver.ts @@ -1,5 +1,6 @@ import { ProductAPI } from '../datasources/product-api'; import { + PrintProduct, Product, ProductListResult, ProductsFilterInput, @@ -17,6 +18,8 @@ import { IdNumberResult } from '../types/types'; import { moveS3File } from '../aws/s3'; import { DesignerAPI } from '../datasources/designer-api'; import { checkAccess } from '../cognito/access-control'; +import { PrintProductDefaultsAPI } from '../datasources/printproduct-defaults-api'; +import { PrintProductDefaults } from '../types/printproduct-defaults-types'; const ProductBlacklist = { async market(parent, _args, { dataSources }) { @@ -50,6 +53,11 @@ const PrintProduct = { async interiors({ id }, _args, { dataSources }) { return (dataSources.interiorApi).getPrintProductInteriors(id); }, + async defaults({ id }, _args, { dataSources }) { + return (( + dataSources.printProductDefaultsApi + )).getDefaults(id); + }, }; async function getProductsResult( @@ -276,6 +284,21 @@ export const productMutationTypeDefs = { ); }, + /** + * @function printProductDefaults + * @description Add default values to a printproduct, this is used through admin gui. + */ + async printProductDefaults( + _, + { printId, widthMm, heightMm, cropX, cropY, border }, + { dataSources, auth }, + ): Promise { + checkAccess(['products.write'], auth); + return (( + dataSources.printProductDefaultsApi + )).updateDefaults(printId, widthMm, heightMm, cropX, cropY, border); + }, + /** * @function productWallpaperType * @description Set the wallpapertype for a wallpaper product diff --git a/src/schema.graphql b/src/schema.graphql index 11783b4..c484abf 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -390,6 +390,7 @@ type PrintProduct { inserted: DateTime! updated: DateTime interiors: [Interior] + defaults: PrintProductDefaults } enum InteriorType { @@ -413,6 +414,21 @@ type Interior { orientation: Orientation } +enum BorderType { + NONE + WHITE + BLACK +} + +type PrintProductDefaults { + printId: ID + widthMm: Float + heightMm: Float + cropX: Float + cropY: Float + border: BorderType +} + type Designer { id: ID! name: String @@ -476,32 +492,29 @@ type IdNumberResult { } type Mutation { + + """ Product """ addProduct(name: String!, batch: String): Product productInfo(productId: Int!, info: ProductInfoInput!): Product - productFocusPoint( + productWallpaperType( productId: Int! - focusXpoint2: Float! - focusYpoint2: Float! + wallpaperTypes: [ProductWallpaperType]! ): Product productBlacklisting( productId: Int! markets: [ProductBlacklistingInput] ): Product - productGroup(productId: Int!, groupIds: [Int]): Product - productGroupInteriors(productId: Int!, groupId: Int!, uris: [String]): Product - productKeywords(productId: Int!, keywordIds: [Int]): Product + + """ Product Image """ + productFocusPoint( + productId: Int! + focusXpoint2: Float! + focusYpoint2: Float! + ): Product productProportionsWarning( productId: Int! proportions: ProductProportionsInput! ): Product - addOwnInteriorToPrintProduct( - printId: Int! - uploadedS3Key: String! - ): IdNumberResult - productWallpaperType( - productId: Int! - wallpaperTypes: [ProductWallpaperType]! - ): Product updateProductImage( productId: Int! uploadedS3Key: String! @@ -509,16 +522,38 @@ type Mutation { height: Int! ): String + """ Product Relations """ addRelatedProducts(productId: Int!, articleNumbers: [String]!): Product removeRelatedProducts(productId: Int!, relatedProductIds: [Int]!): Product - addKeyword(name: String!, type: KeywordType): Keyword - + """ Product Categories """ addCategoriesToProduct(productId: Int!, categoryIds: [Int]!): Product removeCategoriesFromProduct(productId: Int!, categoryIds: [Int]!): Product + """ Product Keywords """ + productKeywords(productId: Int!, keywordIds: [Int]): Product + addKeyword(name: String!, type: KeywordType): Keyword + + """ Product Other """ updateProductComments(productId: Int!, comments: String!): Product + """ Printproducts """ + productGroup(productId: Int!, groupIds: [Int]): Product + productGroupInteriors(productId: Int!, groupId: Int!, uris: [String]): Product + addOwnInteriorToPrintProduct( + printId: Int! + uploadedS3Key: String! + ): IdNumberResult + printProductDefaults( + printId: Int! + widthMm: Int! + heightMm: Int! + cropX: Float! + cropY: Float! + border: BorderType! + ): PrintProductDefaults + + """ Mass Update """ massUpdatePublishing( productIds: [Int]! visible: Boolean diff --git a/src/types/printproduct-defaults-types.ts b/src/types/printproduct-defaults-types.ts new file mode 100644 index 0000000..a931f7d --- /dev/null +++ b/src/types/printproduct-defaults-types.ts @@ -0,0 +1,14 @@ +export enum BorderType { + NONE = 0, + WHITE = 1, + BLACK = 2, +} + +export interface PrintProductDefaults { + printId: number; + widthMm: number; + heightMm: number; + cropX: number; + cropY: number; + border: string; +}