@airtable/blocks 1.3.0 → 1.5.1
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/CHANGELOG.md +30 -1
- package/dist/cjs/index.js +30 -11
- package/dist/cjs/injected/airtable_interface.js +2 -1
- package/dist/cjs/models/cursor.js +4 -6
- package/dist/cjs/models/field.js +24 -0
- package/dist/cjs/models/grouped_record_query_result.js +475 -0
- package/dist/cjs/models/models.js +30 -0
- package/dist/cjs/models/mutations.js +41 -9
- package/dist/cjs/models/record_query_result.js +37 -12
- package/dist/cjs/models/session.js +65 -23
- package/dist/cjs/models/table_or_view_query_result.js +306 -97
- package/dist/cjs/models/view.js +71 -1
- package/dist/cjs/models/view_data_store.js +62 -20
- package/dist/cjs/models/view_metadata_query_result.js +41 -8
- package/dist/cjs/sdk.js +2 -2
- package/dist/cjs/testing/mock_airtable_interface.js +1 -110
- package/dist/cjs/types/airtable_interface.js +19 -1
- package/dist/cjs/types/mutations.js +2 -1
- package/dist/cjs/types/view.js +1 -0
- package/dist/cjs/ui/confirmation_dialog.js +12 -4
- package/dist/cjs/ui/expand_record.js +5 -5
- package/dist/cjs/ui/expand_record_list.js +2 -5
- package/dist/cjs/ui/expand_record_picker_async.js +9 -16
- package/dist/cjs/ui/form_field.js +2 -2
- package/dist/cjs/ui/icon_config.js +11 -4
- package/dist/cjs/ui/initialize_block.js +62 -10
- package/dist/cjs/ui/ui.js +9 -2
- package/dist/cjs/ui/use_loadable.js +2 -2
- package/dist/cjs/ui/use_records.js +54 -40
- package/dist/cjs/ui/use_view_metadata.js +1 -1
- package/dist/cjs/unstable_testing_utils.js +163 -0
- package/dist/types/src/color_utils.d.ts +4 -4
- package/dist/types/src/color_utils.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/injected/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/models/cursor.d.ts +4 -6
- package/dist/types/src/models/cursor.d.ts.map +1 -1
- package/dist/types/src/models/field.d.ts +17 -1
- package/dist/types/src/models/field.d.ts.map +1 -1
- package/dist/types/src/models/grouped_record_query_result.d.ts +61 -0
- package/dist/types/src/models/grouped_record_query_result.d.ts.map +1 -0
- package/dist/types/src/models/models.d.ts +4 -1
- package/dist/types/src/models/models.d.ts.map +1 -1
- package/dist/types/src/models/mutations.d.ts.map +1 -1
- package/dist/types/src/models/record.d.ts +0 -2
- package/dist/types/src/models/record.d.ts.map +1 -1
- package/dist/types/src/models/record_query_result.d.ts +22 -0
- package/dist/types/src/models/record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/session.d.ts +65 -23
- package/dist/types/src/models/session.d.ts.map +1 -1
- package/dist/types/src/models/table_or_view_query_result.d.ts +21 -0
- package/dist/types/src/models/table_or_view_query_result.d.ts.map +1 -1
- package/dist/types/src/models/view.d.ts +26 -1
- package/dist/types/src/models/view.d.ts.map +1 -1
- package/dist/types/src/models/view_data_store.d.ts +2 -0
- package/dist/types/src/models/view_data_store.d.ts.map +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts +21 -0
- package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +3 -0
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/testing/mock_airtable_interface.d.ts +79 -0
- package/dist/types/src/testing/mock_airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/airtable_interface.d.ts +28 -1
- package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/field.d.ts +241 -1
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/mutations.d.ts +19 -3
- package/dist/types/src/types/mutations.d.ts.map +1 -1
- package/dist/types/src/types/view.d.ts +26 -1
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/confirmation_dialog.d.ts +8 -0
- package/dist/types/src/ui/confirmation_dialog.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record.d.ts +1 -0
- package/dist/types/src/ui/expand_record.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record_list.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record_picker_async.d.ts +0 -3
- package/dist/types/src/ui/expand_record_picker_async.d.ts.map +1 -1
- package/dist/types/src/ui/icon_config.d.ts +15 -8
- package/dist/types/src/ui/icon_config.d.ts.map +1 -1
- package/dist/types/src/ui/initialize_block.d.ts +19 -2
- package/dist/types/src/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/ui/ui.d.ts +2 -2
- package/dist/types/src/ui/ui.d.ts.map +1 -1
- package/dist/types/src/ui/use_loadable.d.ts +2 -2
- package/dist/types/src/ui/use_records.d.ts +11 -1
- package/dist/types/src/ui/use_records.d.ts.map +1 -1
- package/dist/types/src/unstable_testing_utils.d.ts +13 -0
- package/dist/types/src/unstable_testing_utils.d.ts.map +1 -0
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface_internal.d.ts +32 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface_internal.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts.map +1 -1
- package/dist/types/test/ui/expand_record.test.d.ts +2 -0
- package/dist/types/test/ui/expand_record.test.d.ts.map +1 -0
- package/dist/types/test/ui/expand_record_list.test.d.ts +2 -0
- package/dist/types/test/ui/expand_record_list.test.d.ts.map +1 -0
- package/dist/types/test/ui/expand_record_picker_async.test.d.ts +2 -0
- package/dist/types/test/ui/expand_record_picker_async.test.d.ts.map +1 -0
- package/index.d.ts +4 -2
- package/package.json +4 -4
- package/types.d.ts +3 -0
- package/unstable_testing_utils.d.ts +1 -0
- package/unstable_testing_utils.js +1 -0
- package/dist/cjs/testing/inject_mock_airtable_interface.js +0 -63
- package/dist/cjs/testing/mock_airtable_interface_external.js +0 -741
- package/dist/cjs/testing/test_driver.js +0 -260
- package/dist/cjs/types/test_mutations.js +0 -32
- package/dist/cjs/unstable_testing.js +0 -17
- package/dist/types/src/testing/inject_mock_airtable_interface.d.ts +0 -2
- package/dist/types/src/testing/inject_mock_airtable_interface.d.ts.map +0 -1
- package/dist/types/src/testing/mock_airtable_interface_external.d.ts +0 -107
- package/dist/types/src/testing/mock_airtable_interface_external.d.ts.map +0 -1
- package/dist/types/src/testing/test_driver.d.ts +0 -90
- package/dist/types/src/testing/test_driver.d.ts.map +0 -1
- package/dist/types/src/types/test_mutations.d.ts +0 -27
- package/dist/types/src/types/test_mutations.d.ts.map +0 -1
- package/dist/types/src/unstable_testing.d.ts +0 -3
- package/dist/types/src/unstable_testing.d.ts.map +0 -1
- package/dist/types/test/testing/mock_airtable_interface_external.test.d.ts +0 -2
- package/dist/types/test/testing/mock_airtable_interface_external.test.d.ts.map +0 -1
- package/dist/types/test/testing/test_driver.test.d.ts +0 -2
- package/dist/types/test/testing/test_driver.test.d.ts.map +0 -1
- package/unstable_testing.d.ts +0 -1
- package/unstable_testing.js +0 -1
|
@@ -1,741 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.array.filter");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.from");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.array.includes");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.index-of");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.iterator");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.map");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.array.slice");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.array.splice");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.object.get-own-property-descriptors");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.object.to-string");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.object.values");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/es.promise");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/es.set");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/es.string.includes");
|
|
36
|
-
|
|
37
|
-
require("core-js/modules/web.dom-collections.for-each");
|
|
38
|
-
|
|
39
|
-
require("core-js/modules/web.dom-collections.iterator");
|
|
40
|
-
|
|
41
|
-
Object.defineProperty(exports, "__esModule", {
|
|
42
|
-
value: true
|
|
43
|
-
});
|
|
44
|
-
exports.default = void 0;
|
|
45
|
-
|
|
46
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
47
|
-
|
|
48
|
-
require("regenerator-runtime/runtime");
|
|
49
|
-
|
|
50
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
51
|
-
|
|
52
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
53
|
-
|
|
54
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
55
|
-
|
|
56
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
57
|
-
|
|
58
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
59
|
-
|
|
60
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
61
|
-
|
|
62
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
63
|
-
|
|
64
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
65
|
-
|
|
66
|
-
var _test_mutations = require("../types/test_mutations");
|
|
67
|
-
|
|
68
|
-
var _private_utils = require("../private_utils");
|
|
69
|
-
|
|
70
|
-
var _error_utils = require("../error_utils");
|
|
71
|
-
|
|
72
|
-
var _mock_airtable_interface = _interopRequireDefault(require("./mock_airtable_interface"));
|
|
73
|
-
|
|
74
|
-
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; }
|
|
75
|
-
|
|
76
|
-
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; }
|
|
77
|
-
|
|
78
|
-
var unmodifiableSdkData = {
|
|
79
|
-
isDevelopmentMode: false,
|
|
80
|
-
blockInstallationId: 'bliTESTING',
|
|
81
|
-
isFirstRun: false,
|
|
82
|
-
isFullscreen: false,
|
|
83
|
-
initialKvValuesByKey: {},
|
|
84
|
-
intentData: null
|
|
85
|
-
};
|
|
86
|
-
var unmodifiableBaseData = {
|
|
87
|
-
enabledFeatureNames: [],
|
|
88
|
-
billingPlanGrouping: 'pro',
|
|
89
|
-
permissionLevel: 'create',
|
|
90
|
-
appInterface: {},
|
|
91
|
-
isBlockDevelopmentRestrictionEnabled: false
|
|
92
|
-
};
|
|
93
|
-
var unmodifiableTableData = {
|
|
94
|
-
lock: null,
|
|
95
|
-
externalSyncById: null
|
|
96
|
-
};
|
|
97
|
-
var unmodifiableFieldData = {
|
|
98
|
-
lock: null
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Prior to version 4.1, TypeScript's built-in type guard for the native
|
|
102
|
-
* `Array.isArray` did not function correctly for values of type
|
|
103
|
-
* `ReadonlyArray`. This helper provides the expected functionality for the
|
|
104
|
-
* purposes of `setGlobalConfigValue`.
|
|
105
|
-
* TODO: replace with `Array.isArray` in TypeScript 4.1 or later.
|
|
106
|
-
*
|
|
107
|
-
* @internal
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
function isReadonlyArray(value) {
|
|
111
|
-
return Array.isArray(value);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
var alphanumerics = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
115
|
-
/**
|
|
116
|
-
* Select a random element from an array-like object.
|
|
117
|
-
*
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
function pick(arraylike) {
|
|
122
|
-
return arraylike[Math.floor(Math.random() * arraylike.length)];
|
|
123
|
-
}
|
|
124
|
-
/** @internal */
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
function setGlobalConfigValue(target, path, value) {
|
|
128
|
-
if (isReadonlyArray(target)) {
|
|
129
|
-
var _newTarget = target.slice();
|
|
130
|
-
|
|
131
|
-
var index = parseInt(path[0], 10);
|
|
132
|
-
|
|
133
|
-
if (path.length === 1) {
|
|
134
|
-
if (value === undefined) {
|
|
135
|
-
_newTarget.splice(index, 1);
|
|
136
|
-
} else {
|
|
137
|
-
_newTarget[index] = value;
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
_newTarget[index] = setGlobalConfigValue(target[index] || {}, path.slice(1), value);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return _newTarget;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
var newTarget = typeof target === 'object' ? _objectSpread({}, target) : {};
|
|
147
|
-
|
|
148
|
-
if (path.length === 1) {
|
|
149
|
-
if (value === undefined) {
|
|
150
|
-
delete newTarget[path[0]];
|
|
151
|
-
} else {
|
|
152
|
-
newTarget[path[0]] = value;
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
newTarget[path[0]] = setGlobalConfigValue(newTarget[path[0]] || {}, path.slice(1), value);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return newTarget;
|
|
159
|
-
}
|
|
160
|
-
/** @hidden */
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var getId = (_ref) => {
|
|
164
|
-
var id = _ref.id;
|
|
165
|
-
return id;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* An implementation of the MockAirtableInterface designed for use in automated
|
|
169
|
-
* test suites for Airtable Blocks maintained externally. Provides a more
|
|
170
|
-
* high-level constructor for specifying test fixture data and implements some
|
|
171
|
-
* features which approximate interactions with Hyperbase in production.
|
|
172
|
-
*
|
|
173
|
-
* @internal
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
var MockAirtableInterfaceExternal =
|
|
178
|
-
/*#__PURE__*/
|
|
179
|
-
function (_MockAirtableInterfac) {
|
|
180
|
-
(0, _inherits2.default)(MockAirtableInterfaceExternal, _MockAirtableInterfac);
|
|
181
|
-
|
|
182
|
-
function MockAirtableInterfaceExternal(fixtureData) {
|
|
183
|
-
var _this;
|
|
184
|
-
|
|
185
|
-
(0, _classCallCheck2.default)(this, MockAirtableInterfaceExternal);
|
|
186
|
-
var store = {
|
|
187
|
-
tables: {},
|
|
188
|
-
views: {}
|
|
189
|
-
};
|
|
190
|
-
var tables = fixtureData.base.tables.map(table => {
|
|
191
|
-
if (table.id in store.tables) {
|
|
192
|
-
throw (0, _error_utils.spawnError)('repeated table ID: %s', table.id);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
store.tables[table.id] = (0, _private_utils.keyBy)(table.records, getId);
|
|
196
|
-
store.views[table.id] = {};
|
|
197
|
-
var _iteratorNormalCompletion = true;
|
|
198
|
-
var _didIteratorError = false;
|
|
199
|
-
var _iteratorError = undefined;
|
|
200
|
-
|
|
201
|
-
try {
|
|
202
|
-
for (var _iterator = table.views[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
203
|
-
var view = _step.value;
|
|
204
|
-
|
|
205
|
-
if (view.id in store.views[table.id]) {
|
|
206
|
-
throw (0, _error_utils.spawnError)('repeated view ID: %s', view.id);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
var _iteratorNormalCompletion2 = true;
|
|
210
|
-
var _didIteratorError2 = false;
|
|
211
|
-
var _iteratorError2 = undefined;
|
|
212
|
-
|
|
213
|
-
try {
|
|
214
|
-
for (var _iterator2 = view.records[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
215
|
-
var record = _step2.value;
|
|
216
|
-
|
|
217
|
-
if (!(record.id in store.tables[table.id])) {
|
|
218
|
-
throw (0, _error_utils.spawnError)('record %s not present in table %s', record.id, table.id);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
} catch (err) {
|
|
222
|
-
_didIteratorError2 = true;
|
|
223
|
-
_iteratorError2 = err;
|
|
224
|
-
} finally {
|
|
225
|
-
try {
|
|
226
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
227
|
-
_iterator2.return();
|
|
228
|
-
}
|
|
229
|
-
} finally {
|
|
230
|
-
if (_didIteratorError2) {
|
|
231
|
-
throw _iteratorError2;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
store.views[table.id][view.id] = {
|
|
237
|
-
fieldOrder: view.fieldOrder,
|
|
238
|
-
records: view.records
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
} catch (err) {
|
|
242
|
-
_didIteratorError = true;
|
|
243
|
-
_iteratorError = err;
|
|
244
|
-
} finally {
|
|
245
|
-
try {
|
|
246
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
247
|
-
_iterator.return();
|
|
248
|
-
}
|
|
249
|
-
} finally {
|
|
250
|
-
if (_didIteratorError) {
|
|
251
|
-
throw _iteratorError;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return _objectSpread({}, unmodifiableTableData, {
|
|
257
|
-
id: table.id,
|
|
258
|
-
name: table.name,
|
|
259
|
-
description: table.description,
|
|
260
|
-
fieldsById: (0, _private_utils.keyBy)(table.fields.map(field => _objectSpread({}, field, {
|
|
261
|
-
typeOptions: field.options
|
|
262
|
-
}, unmodifiableFieldData)), getId),
|
|
263
|
-
primaryFieldId: table.fields[0].id,
|
|
264
|
-
viewsById: (0, _private_utils.keyBy)(table.views, getId),
|
|
265
|
-
activeViewId: table.views[0].id,
|
|
266
|
-
viewOrder: table.views.map((_ref2) => {
|
|
267
|
-
var id = _ref2.id;
|
|
268
|
-
return id;
|
|
269
|
-
})
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
var sdkInitData = _objectSpread({}, unmodifiableSdkData, {
|
|
274
|
-
baseData: _objectSpread({}, unmodifiableBaseData, {
|
|
275
|
-
id: fixtureData.base.id,
|
|
276
|
-
name: fixtureData.base.name,
|
|
277
|
-
activeTableId: tables[0].id,
|
|
278
|
-
tableOrder: tables.map((_ref3) => {
|
|
279
|
-
var id = _ref3.id;
|
|
280
|
-
return id;
|
|
281
|
-
}),
|
|
282
|
-
tablesById: (0, _private_utils.keyBy)(tables, getId),
|
|
283
|
-
currentUserId: fixtureData.base.collaborators[0].id,
|
|
284
|
-
cursorData: {
|
|
285
|
-
selectedRecordIdSet: {},
|
|
286
|
-
selectedFieldIdSet: {}
|
|
287
|
-
},
|
|
288
|
-
collaboratorsById: (0, _private_utils.keyBy)(fixtureData.base.collaborators, getId),
|
|
289
|
-
activeCollaboratorIds: fixtureData.base.collaborators.filter((_ref4) => {
|
|
290
|
-
var isActive = _ref4.isActive;
|
|
291
|
-
return isActive;
|
|
292
|
-
}).map((_ref5) => {
|
|
293
|
-
var id = _ref5.id;
|
|
294
|
-
return id;
|
|
295
|
-
})
|
|
296
|
-
})
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal).call(this, sdkInitData));
|
|
300
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_recordDataStore", void 0);
|
|
301
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_userPermissionCheck", void 0);
|
|
302
|
-
_this._recordDataStore = store;
|
|
303
|
-
return _this;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
(0, _createClass2.default)(MockAirtableInterfaceExternal, [{
|
|
307
|
-
key: "applyMutationAsync",
|
|
308
|
-
value: function applyMutationAsync(mutation, opts) {
|
|
309
|
-
var tableData, viewUpdates;
|
|
310
|
-
return _regenerator.default.async(function applyMutationAsync$(_context) {
|
|
311
|
-
while (1) {
|
|
312
|
-
switch (_context.prev = _context.next) {
|
|
313
|
-
case 0:
|
|
314
|
-
if (mutation.type === _test_mutations.TestMutationTypes.DELETE_SINGLE_FIELD) {
|
|
315
|
-
tableData = this.sdkInitData.baseData.tablesById[mutation.tableId];
|
|
316
|
-
(0, _error_utils.invariant)(tableData.primaryFieldId !== mutation.id, "A table's primary field may not be deleted.");
|
|
317
|
-
viewUpdates = Object.values(tableData.viewsById).filter(view => {
|
|
318
|
-
return view.fieldOrder && view.fieldOrder.fieldIds.includes(mutation.id);
|
|
319
|
-
}).map(view => {
|
|
320
|
-
var fieldOrder = view.fieldOrder;
|
|
321
|
-
(0, _error_utils.invariant)(fieldOrder, 'View must define a field ordering');
|
|
322
|
-
var index = fieldOrder.fieldIds.indexOf(mutation.id);
|
|
323
|
-
var fieldIds = fieldOrder.fieldIds.slice();
|
|
324
|
-
fieldIds.splice(index, 1);
|
|
325
|
-
var visibleFieldCount = index < fieldOrder.visibleFieldCount ? fieldOrder.visibleFieldCount - 1 : fieldOrder.visibleFieldCount;
|
|
326
|
-
return {
|
|
327
|
-
path: ['tablesById', mutation.tableId, 'viewsById', view.id, 'fieldOrder'],
|
|
328
|
-
value: {
|
|
329
|
-
fieldIds,
|
|
330
|
-
visibleFieldCount
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
});
|
|
334
|
-
viewUpdates.forEach((_ref6) => {
|
|
335
|
-
var path = _ref6.path,
|
|
336
|
-
value = _ref6.value;
|
|
337
|
-
var view = this._recordDataStore.views[path[1]][path[3]];
|
|
338
|
-
(0, _error_utils.invariant)(view, 'Internal update must reference existing view');
|
|
339
|
-
view.fieldOrder = value;
|
|
340
|
-
});
|
|
341
|
-
this.triggerModelUpdates([{
|
|
342
|
-
path: ['tablesById', mutation.tableId, 'fieldsById', mutation.id],
|
|
343
|
-
value: undefined
|
|
344
|
-
}, ...viewUpdates]);
|
|
345
|
-
} else {
|
|
346
|
-
this.emit('mutation', mutation);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
case 1:
|
|
350
|
-
case "end":
|
|
351
|
-
return _context.stop();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}, null, this);
|
|
355
|
-
}
|
|
356
|
-
}, {
|
|
357
|
-
key: "checkPermissionsForMutation",
|
|
358
|
-
value: function checkPermissionsForMutation(mutation) {
|
|
359
|
-
if (!this._userPermissionCheck || this._userPermissionCheck(mutation)) {
|
|
360
|
-
return {
|
|
361
|
-
hasPermission: true
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return {
|
|
366
|
-
hasPermission: false,
|
|
367
|
-
reasonDisplayString: 'The testing environment has been configured to deny this mutation.'
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
}, {
|
|
371
|
-
key: "emit",
|
|
372
|
-
value: function emit(key, data) {
|
|
373
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal.prototype), "emit", this).call(this, key, data);
|
|
374
|
-
}
|
|
375
|
-
}, {
|
|
376
|
-
key: "fetchAndSubscribeToCellValuesInFieldsAsync",
|
|
377
|
-
value: function fetchAndSubscribeToCellValuesInFieldsAsync(tableId, fieldIds) {
|
|
378
|
-
var _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, fieldId, recordsById, _i, _Object$values, record, cellValuesByFieldId, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _fieldId;
|
|
379
|
-
|
|
380
|
-
return _regenerator.default.async(function fetchAndSubscribeToCellValuesInFieldsAsync$(_context2) {
|
|
381
|
-
while (1) {
|
|
382
|
-
switch (_context2.prev = _context2.next) {
|
|
383
|
-
case 0:
|
|
384
|
-
if (tableId in this._recordDataStore.tables) {
|
|
385
|
-
_context2.next = 2;
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
throw (0, _error_utils.spawnError)('table not present in fixture data: %s', tableId);
|
|
390
|
-
|
|
391
|
-
case 2:
|
|
392
|
-
_iteratorNormalCompletion3 = true;
|
|
393
|
-
_didIteratorError3 = false;
|
|
394
|
-
_iteratorError3 = undefined;
|
|
395
|
-
_context2.prev = 5;
|
|
396
|
-
_iterator3 = fieldIds[Symbol.iterator]();
|
|
397
|
-
|
|
398
|
-
case 7:
|
|
399
|
-
if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) {
|
|
400
|
-
_context2.next = 14;
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
fieldId = _step3.value;
|
|
405
|
-
|
|
406
|
-
if (fieldId in this.sdkInitData.baseData.tablesById[tableId].fieldsById) {
|
|
407
|
-
_context2.next = 11;
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
throw (0, _error_utils.spawnError)('field %s not present in table %s', fieldId, tableId);
|
|
412
|
-
|
|
413
|
-
case 11:
|
|
414
|
-
_iteratorNormalCompletion3 = true;
|
|
415
|
-
_context2.next = 7;
|
|
416
|
-
break;
|
|
417
|
-
|
|
418
|
-
case 14:
|
|
419
|
-
_context2.next = 20;
|
|
420
|
-
break;
|
|
421
|
-
|
|
422
|
-
case 16:
|
|
423
|
-
_context2.prev = 16;
|
|
424
|
-
_context2.t0 = _context2["catch"](5);
|
|
425
|
-
_didIteratorError3 = true;
|
|
426
|
-
_iteratorError3 = _context2.t0;
|
|
427
|
-
|
|
428
|
-
case 20:
|
|
429
|
-
_context2.prev = 20;
|
|
430
|
-
_context2.prev = 21;
|
|
431
|
-
|
|
432
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
433
|
-
_iterator3.return();
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
case 23:
|
|
437
|
-
_context2.prev = 23;
|
|
438
|
-
|
|
439
|
-
if (!_didIteratorError3) {
|
|
440
|
-
_context2.next = 26;
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
throw _iteratorError3;
|
|
445
|
-
|
|
446
|
-
case 26:
|
|
447
|
-
return _context2.finish(23);
|
|
448
|
-
|
|
449
|
-
case 27:
|
|
450
|
-
return _context2.finish(20);
|
|
451
|
-
|
|
452
|
-
case 28:
|
|
453
|
-
recordsById = {};
|
|
454
|
-
_i = 0, _Object$values = Object.values(this._recordDataStore.tables[tableId]);
|
|
455
|
-
|
|
456
|
-
case 30:
|
|
457
|
-
if (!(_i < _Object$values.length)) {
|
|
458
|
-
_context2.next = 56;
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
record = _Object$values[_i];
|
|
463
|
-
cellValuesByFieldId = {};
|
|
464
|
-
_iteratorNormalCompletion4 = true;
|
|
465
|
-
_didIteratorError4 = false;
|
|
466
|
-
_iteratorError4 = undefined;
|
|
467
|
-
_context2.prev = 36;
|
|
468
|
-
|
|
469
|
-
for (_iterator4 = fieldIds[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
470
|
-
_fieldId = _step4.value;
|
|
471
|
-
cellValuesByFieldId[_fieldId] = record.cellValuesByFieldId[_fieldId];
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
_context2.next = 44;
|
|
475
|
-
break;
|
|
476
|
-
|
|
477
|
-
case 40:
|
|
478
|
-
_context2.prev = 40;
|
|
479
|
-
_context2.t1 = _context2["catch"](36);
|
|
480
|
-
_didIteratorError4 = true;
|
|
481
|
-
_iteratorError4 = _context2.t1;
|
|
482
|
-
|
|
483
|
-
case 44:
|
|
484
|
-
_context2.prev = 44;
|
|
485
|
-
_context2.prev = 45;
|
|
486
|
-
|
|
487
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
488
|
-
_iterator4.return();
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
case 47:
|
|
492
|
-
_context2.prev = 47;
|
|
493
|
-
|
|
494
|
-
if (!_didIteratorError4) {
|
|
495
|
-
_context2.next = 50;
|
|
496
|
-
break;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
throw _iteratorError4;
|
|
500
|
-
|
|
501
|
-
case 50:
|
|
502
|
-
return _context2.finish(47);
|
|
503
|
-
|
|
504
|
-
case 51:
|
|
505
|
-
return _context2.finish(44);
|
|
506
|
-
|
|
507
|
-
case 52:
|
|
508
|
-
recordsById[record.id] = _objectSpread({}, record, {
|
|
509
|
-
cellValuesByFieldId
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
case 53:
|
|
513
|
-
_i++;
|
|
514
|
-
_context2.next = 30;
|
|
515
|
-
break;
|
|
516
|
-
|
|
517
|
-
case 56:
|
|
518
|
-
return _context2.abrupt("return", {
|
|
519
|
-
recordsById
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
case 57:
|
|
523
|
-
case "end":
|
|
524
|
-
return _context2.stop();
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}, null, this, [[5, 16, 20, 28], [21,, 23, 27], [36, 40, 44, 52], [45,, 47, 51]]);
|
|
528
|
-
}
|
|
529
|
-
}, {
|
|
530
|
-
key: "fetchAndSubscribeToCursorDataAsync",
|
|
531
|
-
value: function fetchAndSubscribeToCursorDataAsync() {
|
|
532
|
-
var cursorData, selectedRecordIdSet;
|
|
533
|
-
return _regenerator.default.async(function fetchAndSubscribeToCursorDataAsync$(_context3) {
|
|
534
|
-
while (1) {
|
|
535
|
-
switch (_context3.prev = _context3.next) {
|
|
536
|
-
case 0:
|
|
537
|
-
cursorData = this.sdkInitData.baseData.cursorData;
|
|
538
|
-
selectedRecordIdSet = Object.assign({}, cursorData && cursorData.selectedRecordIdSet);
|
|
539
|
-
return _context3.abrupt("return", {
|
|
540
|
-
selectedRecordIdSet,
|
|
541
|
-
selectedFieldIdSet: {}
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
case 3:
|
|
545
|
-
case "end":
|
|
546
|
-
return _context3.stop();
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}, null, this);
|
|
550
|
-
}
|
|
551
|
-
}, {
|
|
552
|
-
key: "fetchAndSubscribeToTableDataAsync",
|
|
553
|
-
value: function fetchAndSubscribeToTableDataAsync(tableId) {
|
|
554
|
-
return _regenerator.default.async(function fetchAndSubscribeToTableDataAsync$(_context4) {
|
|
555
|
-
while (1) {
|
|
556
|
-
switch (_context4.prev = _context4.next) {
|
|
557
|
-
case 0:
|
|
558
|
-
if (tableId in this._recordDataStore.tables) {
|
|
559
|
-
_context4.next = 2;
|
|
560
|
-
break;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
throw (0, _error_utils.spawnError)('table not present in fixture data: %s', tableId);
|
|
564
|
-
|
|
565
|
-
case 2:
|
|
566
|
-
return _context4.abrupt("return", {
|
|
567
|
-
recordsById: this._recordDataStore.tables[tableId]
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
case 3:
|
|
571
|
-
case "end":
|
|
572
|
-
return _context4.stop();
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}, null, this);
|
|
576
|
-
}
|
|
577
|
-
}, {
|
|
578
|
-
key: "fetchAndSubscribeToViewDataAsync",
|
|
579
|
-
value: function fetchAndSubscribeToViewDataAsync(tableId, viewId) {
|
|
580
|
-
var tableSchema, viewData;
|
|
581
|
-
return _regenerator.default.async(function fetchAndSubscribeToViewDataAsync$(_context5) {
|
|
582
|
-
while (1) {
|
|
583
|
-
switch (_context5.prev = _context5.next) {
|
|
584
|
-
case 0:
|
|
585
|
-
if (tableId in this.sdkInitData.baseData.tablesById) {
|
|
586
|
-
_context5.next = 2;
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
throw (0, _error_utils.spawnError)('table not present in fixture data: %s', tableId);
|
|
591
|
-
|
|
592
|
-
case 2:
|
|
593
|
-
tableSchema = this.sdkInitData.baseData.tablesById[tableId];
|
|
594
|
-
|
|
595
|
-
if (viewId in tableSchema.viewsById) {
|
|
596
|
-
_context5.next = 5;
|
|
597
|
-
break;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
throw (0, _error_utils.spawnError)('view not present in fixture data: %s', viewId);
|
|
601
|
-
|
|
602
|
-
case 5:
|
|
603
|
-
viewData = this._recordDataStore.views[tableId][viewId];
|
|
604
|
-
return _context5.abrupt("return", {
|
|
605
|
-
visibleRecordIds: viewData.records.map((_ref7) => {
|
|
606
|
-
var id = _ref7.id;
|
|
607
|
-
return id;
|
|
608
|
-
}),
|
|
609
|
-
fieldOrder: viewData.fieldOrder,
|
|
610
|
-
colorsByRecordId: {}
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
case 7:
|
|
614
|
-
case "end":
|
|
615
|
-
return _context5.stop();
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}, null, this);
|
|
619
|
-
}
|
|
620
|
-
}, {
|
|
621
|
-
key: "hasRecord",
|
|
622
|
-
value: function hasRecord(tableId, recordId) {
|
|
623
|
-
var recordsById = this._recordDataStore.tables[tableId];
|
|
624
|
-
return recordsById && recordId in recordsById;
|
|
625
|
-
}
|
|
626
|
-
}, {
|
|
627
|
-
key: "on",
|
|
628
|
-
value: function on(key, fn) {
|
|
629
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal.prototype), "on", this).call(this, key, fn);
|
|
630
|
-
}
|
|
631
|
-
}, {
|
|
632
|
-
key: "off",
|
|
633
|
-
value: function off(key, fn) {
|
|
634
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal.prototype), "off", this).call(this, key, fn);
|
|
635
|
-
}
|
|
636
|
-
}, {
|
|
637
|
-
key: "setUserPermissionCheck",
|
|
638
|
-
value: function setUserPermissionCheck(check) {
|
|
639
|
-
this._userPermissionCheck = check;
|
|
640
|
-
}
|
|
641
|
-
}, {
|
|
642
|
-
key: "globalConfigHelpers",
|
|
643
|
-
get: function get() {
|
|
644
|
-
var globalConfigHelpers = (0, _get2.default)((0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal.prototype), "globalConfigHelpers", this);
|
|
645
|
-
|
|
646
|
-
globalConfigHelpers.validateAndApplyUpdates = (updates, store) => {
|
|
647
|
-
var changedTopLevelKeys = new Set();
|
|
648
|
-
|
|
649
|
-
var newKvStore = _objectSpread({}, store);
|
|
650
|
-
|
|
651
|
-
var _iteratorNormalCompletion5 = true;
|
|
652
|
-
var _didIteratorError5 = false;
|
|
653
|
-
var _iteratorError5 = undefined;
|
|
654
|
-
|
|
655
|
-
try {
|
|
656
|
-
for (var _iterator5 = updates[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
657
|
-
var update = _step5.value;
|
|
658
|
-
changedTopLevelKeys.add(update.path[0]);
|
|
659
|
-
newKvStore = setGlobalConfigValue(newKvStore, update.path, update.value);
|
|
660
|
-
}
|
|
661
|
-
} catch (err) {
|
|
662
|
-
_didIteratorError5 = true;
|
|
663
|
-
_iteratorError5 = err;
|
|
664
|
-
} finally {
|
|
665
|
-
try {
|
|
666
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
667
|
-
_iterator5.return();
|
|
668
|
-
}
|
|
669
|
-
} finally {
|
|
670
|
-
if (_didIteratorError5) {
|
|
671
|
-
throw _iteratorError5;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
return {
|
|
677
|
-
newKvStore,
|
|
678
|
-
changedTopLevelKeys: Array.from(changedTopLevelKeys)
|
|
679
|
-
};
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
return globalConfigHelpers;
|
|
683
|
-
}
|
|
684
|
-
}, {
|
|
685
|
-
key: "fieldTypeProvider",
|
|
686
|
-
get: function get() {
|
|
687
|
-
var fieldTypeProvider = (0, _get2.default)((0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal.prototype), "fieldTypeProvider", this);
|
|
688
|
-
|
|
689
|
-
fieldTypeProvider.convertCellValueToString = (appInterface, cellValue, fieldData) => {
|
|
690
|
-
if (cellValue === null) {
|
|
691
|
-
return '';
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
if (Array.isArray(cellValue)) {
|
|
695
|
-
return cellValue.map(item => {
|
|
696
|
-
return fieldTypeProvider.convertCellValueToString(appInterface, item, fieldData);
|
|
697
|
-
}).join(', ');
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
if (typeof cellValue === 'object' && // The following condition is tautological in this case, but
|
|
701
|
-
// the TypeScript compiler requires it.
|
|
702
|
-
cellValue !== null && (0, _private_utils.has)(cellValue, 'name')) {
|
|
703
|
-
// In this code path, the TypeScript compiler interprets the
|
|
704
|
-
// type of `cellValue` to be "object". An explicit type cast is
|
|
705
|
-
// necessary in order to reference the `name` property.
|
|
706
|
-
var named = cellValue;
|
|
707
|
-
|
|
708
|
-
if (typeof named.name === 'string') {
|
|
709
|
-
return named.name;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
return String(cellValue);
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
return fieldTypeProvider;
|
|
717
|
-
}
|
|
718
|
-
}, {
|
|
719
|
-
key: "idGenerator",
|
|
720
|
-
get: function get() {
|
|
721
|
-
var idGenerator = (0, _get2.default)((0, _getPrototypeOf2.default)(MockAirtableInterfaceExternal.prototype), "idGenerator", this); // At the time of writing, identifiers happen to exhibit some structure
|
|
722
|
-
// in production settings (e.g. fixed prefix and length), but the SDK
|
|
723
|
-
// does not commit to any particular characteristics. Use a less
|
|
724
|
-
// predictable format to reduce the likelihood that third-party App
|
|
725
|
-
// developers unintentionally write fragile tests by depending any
|
|
726
|
-
// structure in these identifiers.
|
|
727
|
-
|
|
728
|
-
idGenerator.generateRecordId = () => {
|
|
729
|
-
var length = 10 + Math.floor(Math.random() * 10);
|
|
730
|
-
return Array.from({
|
|
731
|
-
length
|
|
732
|
-
}).map(() => pick(alphanumerics)).join('');
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
return idGenerator;
|
|
736
|
-
}
|
|
737
|
-
}]);
|
|
738
|
-
return MockAirtableInterfaceExternal;
|
|
739
|
-
}(_mock_airtable_interface.default);
|
|
740
|
-
|
|
741
|
-
exports.default = MockAirtableInterfaceExternal;
|