1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | 'use strict';
|
13 |
|
14 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
15 |
|
16 | var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
17 |
|
18 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
19 |
|
20 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
21 |
|
22 | var invariant = require("fbjs/lib/invariant");
|
23 |
|
24 | var warning = require("fbjs/lib/warning");
|
25 |
|
26 | function getPaginationVariables(direction, count, cursor, baseVariables, extraVariables, paginationMetadata) {
|
27 | var _objectSpread3;
|
28 |
|
29 | var backwardMetadata = paginationMetadata.backward,
|
30 | forwardMetadata = paginationMetadata.forward;
|
31 |
|
32 | if (direction === 'backward') {
|
33 | var _objectSpread2;
|
34 |
|
35 | !(backwardMetadata != null && backwardMetadata.count != null && backwardMetadata.cursor != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected backward pagination metadata to be available. ' + "If you're seeing this, this is likely a bug in Relay.") : invariant(false) : void 0;
|
36 | process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(backwardMetadata.cursor), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain cursor variable `%s`. This variable is automatically ' + 'determined by Relay.', backwardMetadata.cursor) : void 0;
|
37 | process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(backwardMetadata.count), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain count variable `%s`. This variable is automatically ' + 'determined by Relay.', backwardMetadata.count) : void 0;
|
38 |
|
39 | var _paginationVariables = _objectSpread({}, baseVariables, {}, extraVariables, (_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, backwardMetadata.cursor, cursor), (0, _defineProperty2["default"])(_objectSpread2, backwardMetadata.count, count), _objectSpread2));
|
40 |
|
41 | if (forwardMetadata && forwardMetadata.cursor) {
|
42 | _paginationVariables[forwardMetadata.cursor] = null;
|
43 | }
|
44 |
|
45 | if (forwardMetadata && forwardMetadata.count) {
|
46 | _paginationVariables[forwardMetadata.count] = null;
|
47 | }
|
48 |
|
49 | return _paginationVariables;
|
50 | }
|
51 |
|
52 | !(forwardMetadata != null && forwardMetadata.count != null && forwardMetadata.cursor != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected forward pagination metadata to be available. ' + "If you're seeing this, this is likely a bug in Relay.") : invariant(false) : void 0;
|
53 | process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(forwardMetadata.cursor), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain cursor variable `%s`. This variable is automatically ' + 'determined by Relay.', forwardMetadata.cursor) : void 0;
|
54 | process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(forwardMetadata.count), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain count variable `%s`. This variable is automatically ' + 'determined by Relay.', forwardMetadata.count) : void 0;
|
55 |
|
56 | var paginationVariables = _objectSpread({}, baseVariables, {}, extraVariables, (_objectSpread3 = {}, (0, _defineProperty2["default"])(_objectSpread3, forwardMetadata.cursor, cursor), (0, _defineProperty2["default"])(_objectSpread3, forwardMetadata.count, count), _objectSpread3));
|
57 |
|
58 | if (backwardMetadata && backwardMetadata.cursor) {
|
59 | paginationVariables[backwardMetadata.cursor] = null;
|
60 | }
|
61 |
|
62 | if (backwardMetadata && backwardMetadata.count) {
|
63 | paginationVariables[backwardMetadata.count] = null;
|
64 | }
|
65 |
|
66 | return paginationVariables;
|
67 | }
|
68 |
|
69 | module.exports = getPaginationVariables; |
\ | No newline at end of file |