jscrambler 6.2.6 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mutations.js CHANGED
@@ -19,25 +19,15 @@ exports.unlockApplication = unlockApplication;
19
19
  exports.updateApplication = updateApplication;
20
20
  exports.updateApplicationSource = updateApplicationSource;
21
21
  exports.updateTemplate = updateTemplate;
22
-
23
22
  var _cleanupInputFields3 = _interopRequireDefault(require("./cleanup-input-fields"));
24
-
25
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
-
27
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
28
-
29
25
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
30
-
31
26
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
32
-
33
27
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
34
-
35
28
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
36
-
37
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
38
-
39
30
  var createApplicationDefaultFragments = "\n _id,\n createdAt,\n name\n";
40
-
41
31
  function createApplication(data) {
42
32
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createApplicationDefaultFragments;
43
33
  return {
@@ -47,9 +37,7 @@ function createApplication(data) {
47
37
  }
48
38
  };
49
39
  }
50
-
51
40
  var duplicateApplicationDefaultFragments = "\n _id\n";
52
-
53
41
  function duplicateApplication(id) {
54
42
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : duplicateApplicationDefaultFragments;
55
43
  return {
@@ -59,9 +47,7 @@ function duplicateApplication(id) {
59
47
  }
60
48
  };
61
49
  }
62
-
63
50
  var removeApplicationDefaultFragments = "\n _id\n";
64
-
65
51
  function removeApplication(id) {
66
52
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : removeApplicationDefaultFragments;
67
53
  return {
@@ -71,9 +57,7 @@ function removeApplication(id) {
71
57
  }
72
58
  };
73
59
  }
74
-
75
60
  var removeProtectionDefaultFragments = "\n _id\n";
76
-
77
61
  function removeProtection(id, appId) {
78
62
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : removeProtectionDefaultFragments;
79
63
  return {
@@ -84,9 +68,7 @@ function removeProtection(id, appId) {
84
68
  }
85
69
  };
86
70
  }
87
-
88
71
  var cancelProtectionDefaultFragments = "\n _id\n";
89
-
90
72
  function cancelProtection(id, appId) {
91
73
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : cancelProtectionDefaultFragments;
92
74
  return {
@@ -97,9 +79,7 @@ function cancelProtection(id, appId) {
97
79
  }
98
80
  };
99
81
  }
100
-
101
82
  var updateApplicationDefaultFragments = "\n _id,\n createdAt,\n name\n";
102
-
103
83
  function updateApplication(application) {
104
84
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : updateApplicationDefaultFragments;
105
85
  var applicationId = application._id;
@@ -112,9 +92,7 @@ function updateApplication(application) {
112
92
  }
113
93
  };
114
94
  }
115
-
116
95
  var unlockApplicationDefaultFragments = "\n _id,\n createdAt,\n name\n";
117
-
118
96
  function unlockApplication(application) {
119
97
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : unlockApplicationDefaultFragments;
120
98
  return {
@@ -124,9 +102,7 @@ function unlockApplication(application) {
124
102
  }
125
103
  };
126
104
  }
127
-
128
105
  var addApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n";
129
-
130
106
  function addApplicationSource(applicationId, data) {
131
107
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : addApplicationSourceDefaultFragments;
132
108
  return {
@@ -137,9 +113,7 @@ function addApplicationSource(applicationId, data) {
137
113
  }
138
114
  };
139
115
  }
140
-
141
116
  var updateApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n";
142
-
143
117
  function updateApplicationSource(applicationSource) {
144
118
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : updateApplicationSourceDefaultFragments;
145
119
  var sourceId = applicationSource._id;
@@ -152,9 +126,7 @@ function updateApplicationSource(applicationSource) {
152
126
  }
153
127
  };
154
128
  }
155
-
156
129
  var removeSourceFromApplicationDefaultFragments = "\n _id,\n sources {\n filename\n }\n";
157
-
158
130
  function removeSourceFromApplication(filename, applicationId) {
159
131
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : removeSourceFromApplicationDefaultFragments;
160
132
  return {
@@ -165,9 +137,7 @@ function removeSourceFromApplication(filename, applicationId) {
165
137
  }
166
138
  };
167
139
  }
168
-
169
140
  var createTemplateDefaultFragments = "\n _id,\n name,\n description,\n parameters\n";
170
-
171
141
  function createTemplate(template) {
172
142
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createTemplateDefaultFragments;
173
143
  return {
@@ -177,9 +147,7 @@ function createTemplate(template) {
177
147
  }
178
148
  };
179
149
  }
180
-
181
150
  var removeTemplateDefaultFragments = "\n _id\n";
182
-
183
151
  function removeTemplate(id) {
184
152
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : removeTemplateDefaultFragments;
185
153
  return {
@@ -189,9 +157,7 @@ function removeTemplate(id) {
189
157
  }
190
158
  };
191
159
  }
192
-
193
160
  var updateTemplateDefaultFragments = "\n _id,\n parameters\n";
194
-
195
161
  function updateTemplate(template) {
196
162
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : updateTemplateDefaultFragments;
197
163
  var templateId = template._id;
@@ -204,38 +170,28 @@ function updateTemplate(template) {
204
170
  }
205
171
  };
206
172
  }
207
-
208
173
  var createProtectionDefaultFragments = "\n _id,\n state\n";
209
-
210
174
  function createApplicationProtection(applicationId) {
211
175
  var _fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createProtectionDefaultFragments;
212
-
213
176
  var _options = arguments.length > 2 ? arguments[2] : undefined;
214
-
215
177
  var args = arguments.length > 3 ? arguments[3] : undefined;
216
-
217
178
  var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
218
- _ref$mutationName = _ref.mutationName,
219
- mutationName = _ref$mutationName === void 0 ? 'createApplicationProtection' : _ref$mutationName,
220
- _ref$mutationInputTyp = _ref.mutationInputType,
221
- mutationInputType = _ref$mutationInputTyp === void 0 ? 'ApplicationProtectionCreate' : _ref$mutationInputTyp;
222
-
179
+ _ref$mutationName = _ref.mutationName,
180
+ mutationName = _ref$mutationName === void 0 ? 'createApplicationProtection' : _ref$mutationName,
181
+ _ref$mutationInputTyp = _ref.mutationInputType,
182
+ mutationInputType = _ref$mutationInputTyp === void 0 ? 'ApplicationProtectionCreate' : _ref$mutationInputTyp;
223
183
  var fragments = _fragments;
224
184
  var options = _options;
225
-
226
185
  var _cleanupInputFields = (0, _cleanupInputFields3.default)(args, fragments, options);
227
-
228
186
  var _cleanupInputFields2 = _slicedToArray(_cleanupInputFields, 2);
229
-
230
187
  options = _cleanupInputFields2[0];
231
188
  fragments = _cleanupInputFields2[1];
232
-
233
189
  if (!args.some(function (f) {
234
190
  return f.name === 'options';
235
191
  })) {
236
192
  var _options2 = options,
237
- bail = _options2.bail,
238
- randomizationSeed = _options2.randomizationSeed;
193
+ bail = _options2.bail,
194
+ randomizationSeed = _options2.randomizationSeed;
239
195
  return {
240
196
  query: "\n mutation ".concat(mutationName, " ($applicationId: String!, $bail: Boolean, $randomizationSeed: String) {\n ").concat(mutationName, " (applicationId: $applicationId, bail: $bail, randomizationSeed: $randomizationSeed) {\n ").concat(fragments, "\n }\n }\n "),
241
197
  params: {
@@ -244,9 +200,9 @@ function createApplicationProtection(applicationId) {
244
200
  randomizationSeed: randomizationSeed
245
201
  }
246
202
  };
247
- } // Check if createApplicationProtection supports "data" argument
248
-
203
+ }
249
204
 
205
+ // Check if createApplicationProtection supports "data" argument
250
206
  if (args.some(function (arg) {
251
207
  return arg.name === 'data';
252
208
  })) {
@@ -258,7 +214,6 @@ function createApplicationProtection(applicationId) {
258
214
  }
259
215
  };
260
216
  }
261
-
262
217
  return {
263
218
  query: "\n mutation ".concat(mutationName, " ($applicationId: String!, $options: JSON) {\n ").concat(mutationName, " (applicationId: $applicationId, options: $options) {\n ").concat(fragments, "\n }\n }\n "),
264
219
  params: {
@@ -267,23 +222,17 @@ function createApplicationProtection(applicationId) {
267
222
  }
268
223
  };
269
224
  }
270
-
271
225
  var createProtectionsDefaultFragments = "\n protections {\n ".concat(createProtectionDefaultFragments, "\n }\n");
272
-
273
226
  function createApplicationProtections(applicationId) {
274
227
  var _fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createProtectionsDefaultFragments;
275
-
276
228
  var _options = arguments.length > 2 ? arguments[2] : undefined;
277
-
278
229
  var args = arguments.length > 3 ? arguments[3] : undefined;
279
230
  return createApplicationProtection(applicationId, _fragments, _options, args, {
280
231
  mutationName: 'createApplicationProtections',
281
232
  mutationInputType: 'ApplicationProtectionsCreate'
282
233
  });
283
234
  }
284
-
285
235
  var applyTemplateDefaultFragments = "\n _id,\n parameters\n";
286
-
287
236
  function applyTemplate(templateId, appId) {
288
237
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : applyTemplateDefaultFragments;
289
238
  return {
package/dist/queries.js CHANGED
@@ -10,13 +10,9 @@ exports.getApplicationSource = getApplicationSource;
10
10
  exports.getApplications = getApplications;
11
11
  exports.getProtection = getProtection;
12
12
  exports.getTemplates = getTemplates;
13
-
14
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
15
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
16
  var getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources {\n _id,\n filename,\n extension\n }\n";
21
17
  /**
22
18
  * Return one application by id.
@@ -25,7 +21,6 @@ var getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources
25
21
  * @param {fragment} fragments GraphQL fragment
26
22
  * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber}
27
23
  */
28
-
29
24
  function getApplication(applicationId) {
30
25
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationDefaultFragments;
31
26
  var params = arguments.length > 2 ? arguments[2] : undefined;
@@ -36,9 +31,7 @@ function getApplication(applicationId) {
36
31
  }, params))
37
32
  };
38
33
  }
39
-
40
34
  var getApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n";
41
-
42
35
  function getApplicationSource(sourceId) {
43
36
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationSourceDefaultFragments;
44
37
  var limits = arguments.length > 2 ? arguments[2] : undefined;
@@ -49,9 +42,7 @@ function getApplicationSource(sourceId) {
49
42
  }, limits))
50
43
  };
51
44
  }
52
-
53
45
  var getApplicationProtectionsDefaultFragments = "\n _id,\n sources,\n parameters,\n finishedAt,\n randomizationSeed\n";
54
-
55
46
  function getApplicationProtections(applicationId, params) {
56
47
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getApplicationProtectionsDefaultFragments;
57
48
  var queryArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
@@ -66,9 +57,7 @@ function getApplicationProtections(applicationId, params) {
66
57
  }, params))
67
58
  };
68
59
  }
69
-
70
60
  var getApplicationProtectionsCountDefaultFragments = "\n count\n";
71
-
72
61
  function getApplicationProtectionsCount(applicationId) {
73
62
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationProtectionsCountDefaultFragments;
74
63
  return {
@@ -78,9 +67,7 @@ function getApplicationProtectionsCount(applicationId) {
78
67
  })
79
68
  };
80
69
  }
81
-
82
70
  var getTemplatesDefaultFragments = "\n _id,\n parameters\n";
83
-
84
71
  function getTemplates() {
85
72
  var fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplatesDefaultFragments;
86
73
  return {
@@ -88,7 +75,6 @@ function getTemplates() {
88
75
  params: '{}'
89
76
  };
90
77
  }
91
-
92
78
  var getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n parameters\n";
93
79
  /**
94
80
  * Return all applications.
@@ -96,7 +82,6 @@ var getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n para
96
82
  * @param {fragment} fragments GraphQL fragment
97
83
  * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber}
98
84
  */
99
-
100
85
  function getApplications() {
101
86
  var fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getApplicationsDefaultFragments;
102
87
  var params = arguments.length > 1 ? arguments[1] : undefined;
@@ -105,12 +90,10 @@ function getApplications() {
105
90
  params: JSON.stringify(_objectSpread({}, params))
106
91
  };
107
92
  }
108
-
109
93
  var getProtectionDefaultFragments = {
110
94
  application: "\n name\n ",
111
95
  applicationProtection: "\n _id,\n state,\n bail,\n deprecations {\n type,\n entity\n },\n errorMessage,\n sources {\n filename,\n errorMessages {\n message,\n line,\n column,\n fatal\n }\n }\n "
112
96
  };
113
-
114
97
  function getProtection(applicationId, protectionId) {
115
98
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getProtectionDefaultFragments;
116
99
  return {
package/dist/utils.js CHANGED
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getMatchedFiles = getMatchedFiles;
7
7
  exports.validateNProtections = validateNProtections;
8
-
9
8
  var _glob = _interopRequireDefault(require("glob"));
10
-
11
9
  var _fs = _interopRequireDefault(require("fs"));
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  /**
16
12
  * Return the list of matched files for minimatch patterns.
17
13
  * @param {string} pattern
@@ -20,27 +16,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
20
16
  function getMatchedFiles(pattern) {
21
17
  var matchedFiles = _glob.default.sync(pattern, {
22
18
  dot: true
23
- }); // special case when the real file name contains a minimatch expression (f.e [id]-1234.js)
24
-
19
+ });
25
20
 
21
+ // special case when the real file name contains a minimatch expression (f.e [id]-1234.js)
26
22
  if (matchedFiles.length === 0 && _fs.default.existsSync(pattern)) {
27
23
  matchedFiles = [pattern];
28
24
  }
29
-
30
25
  return matchedFiles;
31
26
  }
32
-
33
27
  function validateNProtections(n) {
34
28
  if (n === undefined) {
35
29
  return n;
36
30
  }
37
-
38
31
  var nProtections = parseInt(n, 10);
39
-
40
32
  if (Number.isNaN(nProtections) || nProtections.toString() !== n.toString() || nProtections < 1) {
41
33
  console.error("*protections* requires an integer greater than 0.");
42
34
  process.exit(1);
43
35
  }
44
-
45
36
  return nProtections;
46
37
  }