relay-runtime 1.3.0 → 1.5.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.
Files changed (90) hide show
  1. package/LICENSE +16 -26
  2. package/index.js +3 -6
  3. package/lib/ConvertToExecuteFunction.js +73 -0
  4. package/lib/RelayConcreteNode.js +31 -14
  5. package/lib/RelayConcreteVariables.js +11 -6
  6. package/lib/RelayConnectionHandler.js +2 -4
  7. package/lib/RelayConnectionInterface.js +3 -5
  8. package/lib/RelayCore.js +4 -6
  9. package/lib/RelayDataLoader.js +2 -4
  10. package/lib/RelayDeclarativeMutationConfig.js +316 -0
  11. package/lib/RelayDefaultHandleKey.js +2 -4
  12. package/lib/RelayDefaultHandlerProvider.js +2 -4
  13. package/lib/RelayError.js +2 -6
  14. package/lib/RelayInMemoryRecordSource.js +2 -4
  15. package/lib/RelayInternalTypes.js +2 -5
  16. package/lib/RelayInternals.js +2 -5
  17. package/lib/RelayMarkSweepStore.js +22 -5
  18. package/lib/RelayMetricsRecorder.js +9 -9
  19. package/lib/RelayMockRenderer.js +3 -8
  20. package/lib/RelayModernEnvironment.js +120 -135
  21. package/lib/RelayModernFragmentSpecResolver.js +81 -55
  22. package/lib/RelayModernGraphQLTag.js +8 -17
  23. package/lib/RelayModernOperationSelector.js +8 -8
  24. package/lib/RelayModernRecord.js +8 -8
  25. package/lib/RelayModernSelector.js +54 -43
  26. package/lib/RelayNetwork.js +9 -11
  27. package/lib/RelayNetworkDebug.js +4 -7
  28. package/lib/RelayNetworkLogger.js +2 -4
  29. package/lib/RelayNetworkLoggerTransaction.js +18 -20
  30. package/lib/RelayNetworkTypes.js +2 -4
  31. package/lib/RelayObservable.js +193 -120
  32. package/lib/RelayProfiler.js +7 -7
  33. package/lib/RelayPublishQueue.js +17 -9
  34. package/lib/RelayQueryCaching.js +2 -5
  35. package/lib/RelayQueryResponseCache.js +3 -5
  36. package/lib/RelayReader.js +18 -8
  37. package/lib/RelayRecordProxy.js +12 -11
  38. package/lib/RelayRecordSourceMutator.js +9 -9
  39. package/lib/RelayRecordSourceProxy.js +15 -13
  40. package/lib/RelayRecordSourceSelectorProxy.js +2 -4
  41. package/lib/RelayRecordState.js +2 -4
  42. package/lib/RelayReferenceMarker.js +2 -4
  43. package/lib/RelayResponseNormalizer.js +34 -25
  44. package/lib/RelayRuntime.js +25 -14
  45. package/lib/RelayRuntimeTypes.js +22 -0
  46. package/lib/RelayShallowMock.js +4 -7
  47. package/lib/RelayStoreTypes.js +2 -4
  48. package/lib/RelayStoreUtils.js +66 -26
  49. package/lib/RelayTaskQueue.js +2 -5
  50. package/lib/RelayTypes.js +2 -5
  51. package/lib/RelayViewerHandler.js +4 -5
  52. package/lib/applyRelayModernOptimisticMutation.js +9 -8
  53. package/lib/cloneRelayHandleSourceField.js +4 -11
  54. package/lib/commitLocalUpdate.js +2 -4
  55. package/lib/commitRelayModernMutation.js +24 -22
  56. package/lib/createRelayNetworkLogger.js +25 -27
  57. package/lib/dedent.js +2 -5
  58. package/lib/deepFreeze.js +3 -5
  59. package/lib/deferrableFragmentKey.js +21 -0
  60. package/lib/fetchRelayModernQuery.js +13 -21
  61. package/lib/generateRelayClientID.js +2 -4
  62. package/lib/getRelayHandleKey.js +2 -4
  63. package/lib/hasOverlappingIDs.js +2 -4
  64. package/lib/isCompatibleRelayFragmentType.js +2 -5
  65. package/lib/isPromise.js +2 -5
  66. package/lib/isRelayModernEnvironment.js +2 -4
  67. package/lib/isScalarAndEqual.js +3 -5
  68. package/lib/normalizePayload.js +10 -13
  69. package/lib/normalizeRelayPayload.js +8 -5
  70. package/lib/recycleNodesInto.js +2 -4
  71. package/lib/relayUnstableBatchedUpdates.js +2 -5
  72. package/lib/relayUnstableBatchedUpdates.native.js +2 -5
  73. package/lib/requestRelaySubscription.js +20 -34
  74. package/lib/simpleClone.js +2 -4
  75. package/lib/stableCopy.js +35 -0
  76. package/lib/testEditDistance.js +2 -5
  77. package/lib/throwFailedPromise.js +2 -5
  78. package/package.json +4 -5
  79. package/relay-runtime.js +2307 -2665
  80. package/relay-runtime.min.js +6 -9
  81. package/ARCHITECTURE.md +0 -232
  82. package/PATENTS +0 -33
  83. package/lib/ConvertToObserveFunction.js +0 -39
  84. package/lib/RelayDebugger.js +0 -199
  85. package/lib/RelayRecordSourceInspector.js +0 -289
  86. package/lib/RelayStoreProxyDebugger.js +0 -44
  87. package/lib/formatStorageKey.js +0 -37
  88. package/lib/prettyStringify.js +0 -35
  89. package/lib/setRelayModernMutationConfigs.js +0 -302
  90. package/lib/stableJSONStringify.js +0 -45
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayNetworkLoggerTransaction
10
8
  *
@@ -13,8 +11,6 @@
13
11
 
14
12
  'use strict';
15
13
 
16
- /* eslint-disable no-console-disallow */
17
-
18
14
  var _classCallCheck3 = _interopRequireDefault(require('babel-runtime/helpers/classCallCheck'));
19
15
 
20
16
  var _toConsumableArray3 = _interopRequireDefault(require('babel-runtime/helpers/toConsumableArray'));
@@ -32,7 +28,7 @@ var queryID = 1;
32
28
  */
33
29
  var RelayNetworkLoggerTransaction = function () {
34
30
  function RelayNetworkLoggerTransaction(_ref) {
35
- var operation = _ref.operation,
31
+ var request = _ref.request,
36
32
  variables = _ref.variables,
37
33
  cacheConfig = _ref.cacheConfig,
38
34
  uploadables = _ref.uploadables;
@@ -42,7 +38,7 @@ var RelayNetworkLoggerTransaction = function () {
42
38
 
43
39
  this._cacheConfig = cacheConfig;
44
40
  this._id = queryID++;
45
- this._operation = operation;
41
+ this._request = request;
46
42
  this._uploadables = uploadables;
47
43
  this._variables = variables;
48
44
  }
@@ -59,11 +55,12 @@ var RelayNetworkLoggerTransaction = function () {
59
55
  this._logs = [];
60
56
  };
61
57
 
62
- RelayNetworkLoggerTransaction.prototype.printLogs = function printLogs(error, response, status) {
58
+ RelayNetworkLoggerTransaction.prototype.printLogs = function printLogs(error, payload, status) {
59
+ /* eslint-disable no-console */
63
60
  var transactionId = this.getIdentifier();
64
- console.groupCollapsed('%c' + transactionId, error ? 'color:red' : '');
61
+ console.groupCollapsed && console.groupCollapsed('%c' + transactionId, error ? 'color:red' : '');
65
62
  console.timeEnd && console.timeEnd(transactionId);
66
- this.getLogsToPrint(error, response, status).forEach(function (_ref2) {
63
+ this.getLogsToPrint(error, payload, status).forEach(function (_ref2) {
67
64
  var _console;
68
65
 
69
66
  var label = _ref2.label,
@@ -71,12 +68,13 @@ var RelayNetworkLoggerTransaction = function () {
71
68
 
72
69
  (_console = console).log.apply(_console, [label + ':'].concat((0, _toConsumableArray3['default'])(values)));
73
70
  });
74
- console.groupEnd();
71
+ console.groupEnd && console.groupEnd();
72
+ /* eslint-enable no-console */
75
73
  };
76
74
 
77
- RelayNetworkLoggerTransaction.prototype.commitLogs = function commitLogs(error, response, status) {
75
+ RelayNetworkLoggerTransaction.prototype.commitLogs = function commitLogs(error, payload, status) {
78
76
  require('fbjs/lib/invariant')(this._hasCommittedLogs === false, 'The logs for transaction #' + this._id + ' have already been committed.');
79
- this.printLogs(error, response, status);
77
+ this.printLogs(error, payload, status);
80
78
  this.markCommitted();
81
79
  };
82
80
 
@@ -84,9 +82,9 @@ var RelayNetworkLoggerTransaction = function () {
84
82
  this._hasCommittedLogs = true;
85
83
  };
86
84
 
87
- RelayNetworkLoggerTransaction.prototype.flushLogs = function flushLogs(error, response, status) {
85
+ RelayNetworkLoggerTransaction.prototype.flushLogs = function flushLogs(error, payload, status) {
88
86
  require('fbjs/lib/invariant')(this._hasCommittedLogs === false, 'The logs for transaction #' + this._id + ' have already been committed.');
89
- this.printLogs(error, response, status);
87
+ this.printLogs(error, payload, status);
90
88
  this.clearLogs();
91
89
  };
92
90
 
@@ -95,15 +93,15 @@ var RelayNetworkLoggerTransaction = function () {
95
93
  };
96
94
 
97
95
  RelayNetworkLoggerTransaction.prototype.getIdentifier = function getIdentifier() {
98
- return '[' + this._id + '] Relay Modern: ' + this._operation.name;
96
+ return '[' + this._id + '] Relay Modern: ' + this._request.name;
99
97
  };
100
98
 
101
- RelayNetworkLoggerTransaction.prototype.getLogsToPrint = function getLogsToPrint(error, response, status) {
99
+ RelayNetworkLoggerTransaction.prototype.getLogsToPrint = function getLogsToPrint(error, payload, status) {
102
100
  return this._logs;
103
101
  };
104
102
 
105
- RelayNetworkLoggerTransaction.prototype.getOperation = function getOperation() {
106
- return this._operation;
103
+ RelayNetworkLoggerTransaction.prototype.getRequest = function getRequest() {
104
+ return this._request;
107
105
  };
108
106
 
109
107
  RelayNetworkLoggerTransaction.prototype.getUploadables = function getUploadables() {
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayNetworkTypes
10
8
  *