@meistrari/tela-sdk-js 2.9.2 → 2.9.3
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/index.cjs +194 -47
- package/dist/index.mjs +195 -48
- package/package.json +11 -1
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ const changeCase__namespace = /*#__PURE__*/_interopNamespaceCompat(changeCase);
|
|
|
23
23
|
const z__default = /*#__PURE__*/_interopDefaultCompat(z);
|
|
24
24
|
const Emittery__default = /*#__PURE__*/_interopDefaultCompat(Emittery);
|
|
25
25
|
|
|
26
|
-
const version = "2.9.
|
|
26
|
+
const version = "2.9.3";
|
|
27
27
|
|
|
28
28
|
var __defProp$a = Object.defineProperty;
|
|
29
29
|
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -246,80 +246,227 @@ const DEFAULT_FIELDS_TRANSFORMATION_EXCLUSIONS = [
|
|
|
246
246
|
"raw_input.override.functions.*.parameters.properties.*"
|
|
247
247
|
];
|
|
248
248
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
249
|
+
const MINIMATCH_OPTIONS = {
|
|
250
|
+
dot: true,
|
|
251
|
+
nobrace: false,
|
|
252
|
+
noglobstar: false,
|
|
253
|
+
matchBase: false
|
|
254
|
+
};
|
|
255
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
256
|
+
const GLOB_MAGIC_REGEX = /[*?[\]{}()!+@]/;
|
|
257
|
+
const MAX_COMPILED_EXCLUSION_CACHE_SIZE = 64;
|
|
258
|
+
const MAX_EXCLUSION_PATH_CACHE_SIZE = 5e4;
|
|
259
|
+
const MAX_ARRAY_PATH_CACHE_SIZE = 5e4;
|
|
260
|
+
function hasUpperCase(value) {
|
|
261
|
+
for (let index = 0; index < value.length; index++) {
|
|
262
|
+
const code = value.charCodeAt(index);
|
|
263
|
+
if (code >= 65 && code <= 90) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
258
268
|
}
|
|
259
|
-
function
|
|
260
|
-
|
|
269
|
+
function hasUnderscore(value) {
|
|
270
|
+
return value.includes("_");
|
|
271
|
+
}
|
|
272
|
+
function isObjectLike(value) {
|
|
273
|
+
return typeof value === "object" && value !== null;
|
|
274
|
+
}
|
|
275
|
+
const MAX_KEY_CACHE_SIZE = 1e4;
|
|
276
|
+
const CAMEL_TO_SNAKE_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
277
|
+
const SNAKE_TO_CAMEL_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
278
|
+
const ARRAY_PATH_CACHE = /* @__PURE__ */ new Map();
|
|
279
|
+
const COMPILED_EXCLUSION_CACHE = /* @__PURE__ */ new Map();
|
|
280
|
+
function getCachedKeyConversion(cache, key, transform, shouldTransform) {
|
|
281
|
+
const cached = cache.get(key);
|
|
282
|
+
if (cached !== void 0) {
|
|
283
|
+
return cached;
|
|
284
|
+
}
|
|
285
|
+
const transformed = shouldTransform(key) ? transform(key) : key;
|
|
286
|
+
if (cache.size > MAX_KEY_CACHE_SIZE) {
|
|
287
|
+
cache.clear();
|
|
288
|
+
}
|
|
289
|
+
cache.set(key, transformed);
|
|
290
|
+
return transformed;
|
|
291
|
+
}
|
|
292
|
+
function convertCamelToSnakeKey(key) {
|
|
293
|
+
return getCachedKeyConversion(CAMEL_TO_SNAKE_KEY_CACHE, key, changeCase__namespace.snakeCase, hasUpperCase);
|
|
294
|
+
}
|
|
295
|
+
function convertSnakeToCamelKey(key) {
|
|
296
|
+
return getCachedKeyConversion(SNAKE_TO_CAMEL_KEY_CACHE, key, changeCase__namespace.camelCase, hasUnderscore);
|
|
297
|
+
}
|
|
298
|
+
function getExclusionSignature(exclusions) {
|
|
299
|
+
return exclusions.join("");
|
|
300
|
+
}
|
|
301
|
+
function setBounded(map, key, value, maxSize) {
|
|
302
|
+
if (map.size > maxSize) {
|
|
303
|
+
map.clear();
|
|
304
|
+
}
|
|
305
|
+
map.set(key, value);
|
|
306
|
+
}
|
|
307
|
+
function getArrayPath(path) {
|
|
308
|
+
const cached = ARRAY_PATH_CACHE.get(path);
|
|
309
|
+
if (cached !== void 0) {
|
|
310
|
+
return cached;
|
|
311
|
+
}
|
|
312
|
+
const arrayPath = path ? `${path}.*` : "*";
|
|
313
|
+
setBounded(ARRAY_PATH_CACHE, path, arrayPath, MAX_ARRAY_PATH_CACHE_SIZE);
|
|
314
|
+
return arrayPath;
|
|
315
|
+
}
|
|
316
|
+
function getCompiledExclusions(exclusions) {
|
|
317
|
+
if (exclusions.length === 0) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
const signature = getExclusionSignature(exclusions);
|
|
321
|
+
const cached = COMPILED_EXCLUSION_CACHE.get(signature);
|
|
322
|
+
if (cached !== void 0) {
|
|
323
|
+
return cached;
|
|
324
|
+
}
|
|
325
|
+
const exactPaths = /* @__PURE__ */ new Set();
|
|
326
|
+
const wildcardMatchers = [];
|
|
327
|
+
for (const exclusion of exclusions) {
|
|
328
|
+
if (GLOB_MAGIC_REGEX.test(exclusion)) {
|
|
329
|
+
wildcardMatchers.push(new minimatch.Minimatch(exclusion, MINIMATCH_OPTIONS));
|
|
330
|
+
} else {
|
|
331
|
+
exactPaths.add(exclusion);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const pathResultCache = /* @__PURE__ */ new Map();
|
|
335
|
+
const compiled = {
|
|
336
|
+
isExcluded: (path) => {
|
|
337
|
+
const cachedResult = pathResultCache.get(path);
|
|
338
|
+
if (cachedResult !== void 0) {
|
|
339
|
+
return cachedResult;
|
|
340
|
+
}
|
|
341
|
+
let excluded = exactPaths.has(path);
|
|
342
|
+
if (!excluded) {
|
|
343
|
+
for (let index = 0; index < wildcardMatchers.length; index++) {
|
|
344
|
+
if (wildcardMatchers[index].match(path)) {
|
|
345
|
+
excluded = true;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
setBounded(pathResultCache, path, excluded, MAX_EXCLUSION_PATH_CACHE_SIZE);
|
|
351
|
+
return excluded;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
setBounded(COMPILED_EXCLUSION_CACHE, signature, compiled, MAX_COMPILED_EXCLUSION_CACHE_SIZE);
|
|
355
|
+
return compiled;
|
|
356
|
+
}
|
|
357
|
+
function getDecisionForKey(path, key, decisionCache, isExcluded, convertKey) {
|
|
358
|
+
let pathCache = decisionCache.get(path);
|
|
359
|
+
if (!pathCache) {
|
|
360
|
+
pathCache = /* @__PURE__ */ new Map();
|
|
361
|
+
decisionCache.set(path, pathCache);
|
|
362
|
+
}
|
|
363
|
+
const cached = pathCache.get(key);
|
|
364
|
+
if (cached !== void 0) {
|
|
365
|
+
return cached;
|
|
366
|
+
}
|
|
367
|
+
const currentPath = path ? `${path}.${key}` : key;
|
|
368
|
+
const transformedKey = isExcluded(currentPath) ? key : convertKey(key);
|
|
369
|
+
const decision = { currentPath, transformedKey };
|
|
370
|
+
pathCache.set(key, decision);
|
|
371
|
+
return decision;
|
|
372
|
+
}
|
|
373
|
+
function transformWithoutExclusions(sourceObject, convertKey) {
|
|
374
|
+
const result = Array.isArray(sourceObject) ? [] : {};
|
|
261
375
|
const stack = [
|
|
262
|
-
{ source:
|
|
376
|
+
{ source: sourceObject, target: result }
|
|
263
377
|
];
|
|
264
378
|
while (stack.length > 0) {
|
|
265
|
-
const { source, target
|
|
379
|
+
const { source, target } = stack.pop();
|
|
266
380
|
if (Array.isArray(source)) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
381
|
+
const arrayTarget = target;
|
|
382
|
+
for (let index = 0, size = source.length; index < size; index++) {
|
|
383
|
+
const item = source[index];
|
|
384
|
+
if (item !== null && typeof item === "object") {
|
|
385
|
+
const nextTarget = Array.isArray(item) ? [] : {};
|
|
386
|
+
arrayTarget[index] = nextTarget;
|
|
387
|
+
stack.push({ source: item, target: nextTarget });
|
|
272
388
|
} else {
|
|
273
|
-
|
|
389
|
+
arrayTarget[index] = item;
|
|
274
390
|
}
|
|
275
|
-
}
|
|
276
|
-
} else if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
391
|
+
}
|
|
392
|
+
} else if (isObjectLike(source)) {
|
|
393
|
+
const objectTarget = target;
|
|
394
|
+
for (const key in source) {
|
|
395
|
+
if (!hasOwn.call(source, key)) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const value = source[key];
|
|
399
|
+
const transformedKey = convertKey(key);
|
|
400
|
+
if (value !== null && typeof value === "object") {
|
|
401
|
+
const nextTarget = Array.isArray(value) ? [] : {};
|
|
402
|
+
objectTarget[transformedKey] = nextTarget;
|
|
403
|
+
stack.push({ source: value, target: nextTarget });
|
|
283
404
|
} else {
|
|
284
|
-
|
|
405
|
+
objectTarget[transformedKey] = value;
|
|
285
406
|
}
|
|
286
407
|
}
|
|
287
408
|
}
|
|
288
409
|
}
|
|
289
410
|
return result;
|
|
290
411
|
}
|
|
291
|
-
function
|
|
292
|
-
const result = Array.isArray(
|
|
412
|
+
function transformWithExclusions(sourceObject, convertKey, compiledExclusions) {
|
|
413
|
+
const result = Array.isArray(sourceObject) ? [] : {};
|
|
293
414
|
const stack = [
|
|
294
|
-
{ source:
|
|
415
|
+
{ source: sourceObject, target: result, path: "" }
|
|
295
416
|
];
|
|
417
|
+
const isExcluded = compiledExclusions.isExcluded;
|
|
418
|
+
const keyDecisionCache = /* @__PURE__ */ new Map();
|
|
296
419
|
while (stack.length > 0) {
|
|
297
420
|
const { source, target, path } = stack.pop();
|
|
298
421
|
if (Array.isArray(source)) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
422
|
+
const arrayTarget = target;
|
|
423
|
+
const arrayPath = getArrayPath(path);
|
|
424
|
+
for (let index = 0, size = source.length; index < size; index++) {
|
|
425
|
+
const item = source[index];
|
|
426
|
+
if (item !== null && typeof item === "object") {
|
|
427
|
+
const nextTarget = Array.isArray(item) ? [] : {};
|
|
428
|
+
arrayTarget[index] = nextTarget;
|
|
429
|
+
stack.push({ source: item, target: nextTarget, path: arrayPath });
|
|
304
430
|
} else {
|
|
305
|
-
|
|
431
|
+
arrayTarget[index] = item;
|
|
306
432
|
}
|
|
307
|
-
}
|
|
308
|
-
} else if (
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
433
|
+
}
|
|
434
|
+
} else if (isObjectLike(source)) {
|
|
435
|
+
const objectTarget = target;
|
|
436
|
+
for (const key in source) {
|
|
437
|
+
if (!hasOwn.call(source, key)) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
const value = source[key];
|
|
441
|
+
const { currentPath, transformedKey } = getDecisionForKey(
|
|
442
|
+
path,
|
|
443
|
+
key,
|
|
444
|
+
keyDecisionCache,
|
|
445
|
+
isExcluded,
|
|
446
|
+
convertKey
|
|
447
|
+
);
|
|
448
|
+
if (value !== null && typeof value === "object") {
|
|
449
|
+
const nextTarget = Array.isArray(value) ? [] : {};
|
|
450
|
+
objectTarget[transformedKey] = nextTarget;
|
|
451
|
+
stack.push({ source: value, target: nextTarget, path: currentPath });
|
|
315
452
|
} else {
|
|
316
|
-
|
|
453
|
+
objectTarget[transformedKey] = value;
|
|
317
454
|
}
|
|
318
455
|
}
|
|
319
456
|
}
|
|
320
457
|
}
|
|
321
458
|
return result;
|
|
322
459
|
}
|
|
460
|
+
function transformObjectFromCamelCaseToSnakeCase(obj, exclusions = []) {
|
|
461
|
+
const compiledExclusions = getCompiledExclusions(exclusions);
|
|
462
|
+
const transformed = compiledExclusions ? transformWithExclusions(obj, convertCamelToSnakeKey, compiledExclusions) : transformWithoutExclusions(obj, convertCamelToSnakeKey);
|
|
463
|
+
return transformed;
|
|
464
|
+
}
|
|
465
|
+
function transformObjectFromSnakeCaseToCamelCase(obj, exclusions = []) {
|
|
466
|
+
const compiledExclusions = getCompiledExclusions(exclusions);
|
|
467
|
+
const transformed = compiledExclusions ? transformWithExclusions(obj, convertSnakeToCamelKey, compiledExclusions) : transformWithoutExclusions(obj, convertSnakeToCamelKey);
|
|
468
|
+
return transformed;
|
|
469
|
+
}
|
|
323
470
|
const DURATION_REGEX = /(?<amount>\d+)(?<unit>[smhd])/;
|
|
324
471
|
const DURATION_UNITS = {
|
|
325
472
|
s: 1e3,
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as changeCase from 'change-case';
|
|
2
|
-
import {
|
|
2
|
+
import { Minimatch } from 'minimatch';
|
|
3
3
|
import z, { z as z$1, ZodError } from 'zod';
|
|
4
4
|
import Emittery from 'emittery';
|
|
5
5
|
|
|
6
|
-
const version = "2.9.
|
|
6
|
+
const version = "2.9.3";
|
|
7
7
|
|
|
8
8
|
var __defProp$a = Object.defineProperty;
|
|
9
9
|
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -226,80 +226,227 @@ const DEFAULT_FIELDS_TRANSFORMATION_EXCLUSIONS = [
|
|
|
226
226
|
"raw_input.override.functions.*.parameters.properties.*"
|
|
227
227
|
];
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
229
|
+
const MINIMATCH_OPTIONS = {
|
|
230
|
+
dot: true,
|
|
231
|
+
nobrace: false,
|
|
232
|
+
noglobstar: false,
|
|
233
|
+
matchBase: false
|
|
234
|
+
};
|
|
235
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
236
|
+
const GLOB_MAGIC_REGEX = /[*?[\]{}()!+@]/;
|
|
237
|
+
const MAX_COMPILED_EXCLUSION_CACHE_SIZE = 64;
|
|
238
|
+
const MAX_EXCLUSION_PATH_CACHE_SIZE = 5e4;
|
|
239
|
+
const MAX_ARRAY_PATH_CACHE_SIZE = 5e4;
|
|
240
|
+
function hasUpperCase(value) {
|
|
241
|
+
for (let index = 0; index < value.length; index++) {
|
|
242
|
+
const code = value.charCodeAt(index);
|
|
243
|
+
if (code >= 65 && code <= 90) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
238
248
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
249
|
+
function hasUnderscore(value) {
|
|
250
|
+
return value.includes("_");
|
|
251
|
+
}
|
|
252
|
+
function isObjectLike(value) {
|
|
253
|
+
return typeof value === "object" && value !== null;
|
|
254
|
+
}
|
|
255
|
+
const MAX_KEY_CACHE_SIZE = 1e4;
|
|
256
|
+
const CAMEL_TO_SNAKE_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
257
|
+
const SNAKE_TO_CAMEL_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
258
|
+
const ARRAY_PATH_CACHE = /* @__PURE__ */ new Map();
|
|
259
|
+
const COMPILED_EXCLUSION_CACHE = /* @__PURE__ */ new Map();
|
|
260
|
+
function getCachedKeyConversion(cache, key, transform, shouldTransform) {
|
|
261
|
+
const cached = cache.get(key);
|
|
262
|
+
if (cached !== void 0) {
|
|
263
|
+
return cached;
|
|
264
|
+
}
|
|
265
|
+
const transformed = shouldTransform(key) ? transform(key) : key;
|
|
266
|
+
if (cache.size > MAX_KEY_CACHE_SIZE) {
|
|
267
|
+
cache.clear();
|
|
268
|
+
}
|
|
269
|
+
cache.set(key, transformed);
|
|
270
|
+
return transformed;
|
|
271
|
+
}
|
|
272
|
+
function convertCamelToSnakeKey(key) {
|
|
273
|
+
return getCachedKeyConversion(CAMEL_TO_SNAKE_KEY_CACHE, key, changeCase.snakeCase, hasUpperCase);
|
|
274
|
+
}
|
|
275
|
+
function convertSnakeToCamelKey(key) {
|
|
276
|
+
return getCachedKeyConversion(SNAKE_TO_CAMEL_KEY_CACHE, key, changeCase.camelCase, hasUnderscore);
|
|
277
|
+
}
|
|
278
|
+
function getExclusionSignature(exclusions) {
|
|
279
|
+
return exclusions.join("");
|
|
280
|
+
}
|
|
281
|
+
function setBounded(map, key, value, maxSize) {
|
|
282
|
+
if (map.size > maxSize) {
|
|
283
|
+
map.clear();
|
|
284
|
+
}
|
|
285
|
+
map.set(key, value);
|
|
286
|
+
}
|
|
287
|
+
function getArrayPath(path) {
|
|
288
|
+
const cached = ARRAY_PATH_CACHE.get(path);
|
|
289
|
+
if (cached !== void 0) {
|
|
290
|
+
return cached;
|
|
291
|
+
}
|
|
292
|
+
const arrayPath = path ? `${path}.*` : "*";
|
|
293
|
+
setBounded(ARRAY_PATH_CACHE, path, arrayPath, MAX_ARRAY_PATH_CACHE_SIZE);
|
|
294
|
+
return arrayPath;
|
|
295
|
+
}
|
|
296
|
+
function getCompiledExclusions(exclusions) {
|
|
297
|
+
if (exclusions.length === 0) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const signature = getExclusionSignature(exclusions);
|
|
301
|
+
const cached = COMPILED_EXCLUSION_CACHE.get(signature);
|
|
302
|
+
if (cached !== void 0) {
|
|
303
|
+
return cached;
|
|
304
|
+
}
|
|
305
|
+
const exactPaths = /* @__PURE__ */ new Set();
|
|
306
|
+
const wildcardMatchers = [];
|
|
307
|
+
for (const exclusion of exclusions) {
|
|
308
|
+
if (GLOB_MAGIC_REGEX.test(exclusion)) {
|
|
309
|
+
wildcardMatchers.push(new Minimatch(exclusion, MINIMATCH_OPTIONS));
|
|
310
|
+
} else {
|
|
311
|
+
exactPaths.add(exclusion);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const pathResultCache = /* @__PURE__ */ new Map();
|
|
315
|
+
const compiled = {
|
|
316
|
+
isExcluded: (path) => {
|
|
317
|
+
const cachedResult = pathResultCache.get(path);
|
|
318
|
+
if (cachedResult !== void 0) {
|
|
319
|
+
return cachedResult;
|
|
320
|
+
}
|
|
321
|
+
let excluded = exactPaths.has(path);
|
|
322
|
+
if (!excluded) {
|
|
323
|
+
for (let index = 0; index < wildcardMatchers.length; index++) {
|
|
324
|
+
if (wildcardMatchers[index].match(path)) {
|
|
325
|
+
excluded = true;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
setBounded(pathResultCache, path, excluded, MAX_EXCLUSION_PATH_CACHE_SIZE);
|
|
331
|
+
return excluded;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
setBounded(COMPILED_EXCLUSION_CACHE, signature, compiled, MAX_COMPILED_EXCLUSION_CACHE_SIZE);
|
|
335
|
+
return compiled;
|
|
336
|
+
}
|
|
337
|
+
function getDecisionForKey(path, key, decisionCache, isExcluded, convertKey) {
|
|
338
|
+
let pathCache = decisionCache.get(path);
|
|
339
|
+
if (!pathCache) {
|
|
340
|
+
pathCache = /* @__PURE__ */ new Map();
|
|
341
|
+
decisionCache.set(path, pathCache);
|
|
342
|
+
}
|
|
343
|
+
const cached = pathCache.get(key);
|
|
344
|
+
if (cached !== void 0) {
|
|
345
|
+
return cached;
|
|
346
|
+
}
|
|
347
|
+
const currentPath = path ? `${path}.${key}` : key;
|
|
348
|
+
const transformedKey = isExcluded(currentPath) ? key : convertKey(key);
|
|
349
|
+
const decision = { currentPath, transformedKey };
|
|
350
|
+
pathCache.set(key, decision);
|
|
351
|
+
return decision;
|
|
352
|
+
}
|
|
353
|
+
function transformWithoutExclusions(sourceObject, convertKey) {
|
|
354
|
+
const result = Array.isArray(sourceObject) ? [] : {};
|
|
241
355
|
const stack = [
|
|
242
|
-
{ source:
|
|
356
|
+
{ source: sourceObject, target: result }
|
|
243
357
|
];
|
|
244
358
|
while (stack.length > 0) {
|
|
245
|
-
const { source, target
|
|
359
|
+
const { source, target } = stack.pop();
|
|
246
360
|
if (Array.isArray(source)) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
361
|
+
const arrayTarget = target;
|
|
362
|
+
for (let index = 0, size = source.length; index < size; index++) {
|
|
363
|
+
const item = source[index];
|
|
364
|
+
if (item !== null && typeof item === "object") {
|
|
365
|
+
const nextTarget = Array.isArray(item) ? [] : {};
|
|
366
|
+
arrayTarget[index] = nextTarget;
|
|
367
|
+
stack.push({ source: item, target: nextTarget });
|
|
252
368
|
} else {
|
|
253
|
-
|
|
369
|
+
arrayTarget[index] = item;
|
|
254
370
|
}
|
|
255
|
-
}
|
|
256
|
-
} else if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
371
|
+
}
|
|
372
|
+
} else if (isObjectLike(source)) {
|
|
373
|
+
const objectTarget = target;
|
|
374
|
+
for (const key in source) {
|
|
375
|
+
if (!hasOwn.call(source, key)) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
const value = source[key];
|
|
379
|
+
const transformedKey = convertKey(key);
|
|
380
|
+
if (value !== null && typeof value === "object") {
|
|
381
|
+
const nextTarget = Array.isArray(value) ? [] : {};
|
|
382
|
+
objectTarget[transformedKey] = nextTarget;
|
|
383
|
+
stack.push({ source: value, target: nextTarget });
|
|
263
384
|
} else {
|
|
264
|
-
|
|
385
|
+
objectTarget[transformedKey] = value;
|
|
265
386
|
}
|
|
266
387
|
}
|
|
267
388
|
}
|
|
268
389
|
}
|
|
269
390
|
return result;
|
|
270
391
|
}
|
|
271
|
-
function
|
|
272
|
-
const result = Array.isArray(
|
|
392
|
+
function transformWithExclusions(sourceObject, convertKey, compiledExclusions) {
|
|
393
|
+
const result = Array.isArray(sourceObject) ? [] : {};
|
|
273
394
|
const stack = [
|
|
274
|
-
{ source:
|
|
395
|
+
{ source: sourceObject, target: result, path: "" }
|
|
275
396
|
];
|
|
397
|
+
const isExcluded = compiledExclusions.isExcluded;
|
|
398
|
+
const keyDecisionCache = /* @__PURE__ */ new Map();
|
|
276
399
|
while (stack.length > 0) {
|
|
277
400
|
const { source, target, path } = stack.pop();
|
|
278
401
|
if (Array.isArray(source)) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
402
|
+
const arrayTarget = target;
|
|
403
|
+
const arrayPath = getArrayPath(path);
|
|
404
|
+
for (let index = 0, size = source.length; index < size; index++) {
|
|
405
|
+
const item = source[index];
|
|
406
|
+
if (item !== null && typeof item === "object") {
|
|
407
|
+
const nextTarget = Array.isArray(item) ? [] : {};
|
|
408
|
+
arrayTarget[index] = nextTarget;
|
|
409
|
+
stack.push({ source: item, target: nextTarget, path: arrayPath });
|
|
284
410
|
} else {
|
|
285
|
-
|
|
411
|
+
arrayTarget[index] = item;
|
|
286
412
|
}
|
|
287
|
-
}
|
|
288
|
-
} else if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
413
|
+
}
|
|
414
|
+
} else if (isObjectLike(source)) {
|
|
415
|
+
const objectTarget = target;
|
|
416
|
+
for (const key in source) {
|
|
417
|
+
if (!hasOwn.call(source, key)) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const value = source[key];
|
|
421
|
+
const { currentPath, transformedKey } = getDecisionForKey(
|
|
422
|
+
path,
|
|
423
|
+
key,
|
|
424
|
+
keyDecisionCache,
|
|
425
|
+
isExcluded,
|
|
426
|
+
convertKey
|
|
427
|
+
);
|
|
428
|
+
if (value !== null && typeof value === "object") {
|
|
429
|
+
const nextTarget = Array.isArray(value) ? [] : {};
|
|
430
|
+
objectTarget[transformedKey] = nextTarget;
|
|
431
|
+
stack.push({ source: value, target: nextTarget, path: currentPath });
|
|
295
432
|
} else {
|
|
296
|
-
|
|
433
|
+
objectTarget[transformedKey] = value;
|
|
297
434
|
}
|
|
298
435
|
}
|
|
299
436
|
}
|
|
300
437
|
}
|
|
301
438
|
return result;
|
|
302
439
|
}
|
|
440
|
+
function transformObjectFromCamelCaseToSnakeCase(obj, exclusions = []) {
|
|
441
|
+
const compiledExclusions = getCompiledExclusions(exclusions);
|
|
442
|
+
const transformed = compiledExclusions ? transformWithExclusions(obj, convertCamelToSnakeKey, compiledExclusions) : transformWithoutExclusions(obj, convertCamelToSnakeKey);
|
|
443
|
+
return transformed;
|
|
444
|
+
}
|
|
445
|
+
function transformObjectFromSnakeCaseToCamelCase(obj, exclusions = []) {
|
|
446
|
+
const compiledExclusions = getCompiledExclusions(exclusions);
|
|
447
|
+
const transformed = compiledExclusions ? transformWithExclusions(obj, convertSnakeToCamelKey, compiledExclusions) : transformWithoutExclusions(obj, convertSnakeToCamelKey);
|
|
448
|
+
return transformed;
|
|
449
|
+
}
|
|
303
450
|
const DURATION_REGEX = /(?<amount>\d+)(?<unit>[smhd])/;
|
|
304
451
|
const DURATION_UNITS = {
|
|
305
452
|
s: 1e3,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/tela-sdk-js",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/meistrari/tela-sdk-js.git"
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"husky": "9.1.6",
|
|
23
23
|
"lint-staged": "15.2.10",
|
|
24
24
|
"playwright": "1.51.0",
|
|
25
|
+
"tinybench": "6.0.0",
|
|
25
26
|
"type-fest": "^5.3.1",
|
|
26
27
|
"typedoc": "0.28.14",
|
|
27
28
|
"typedoc-plugin-merge-modules": "7.0.0",
|
|
@@ -60,6 +61,15 @@
|
|
|
60
61
|
"test:browser": "vitest run --browser",
|
|
61
62
|
"test:bun": "bun test",
|
|
62
63
|
"test:all": "bun run test:default && bun run test:browser && bun run test:bun",
|
|
64
|
+
"bench:data-transformation:profiles": "bun run benchmarks/data-transformation/generate.ts --list-profiles",
|
|
65
|
+
"bench:data-transformation:generate": "bun run benchmarks/data-transformation/generate.ts",
|
|
66
|
+
"bench:data-transformation:run": "bun run benchmarks/data-transformation/run.ts",
|
|
67
|
+
"bench:data-transformation:default": "bun run benchmarks/data-transformation/generate.ts --profile default && bun run benchmarks/data-transformation/run.ts --profile default",
|
|
68
|
+
"bench:data-transformation:large": "bun run benchmarks/data-transformation/generate.ts --profile large && bun run benchmarks/data-transformation/run.ts --profile large",
|
|
69
|
+
"bench:data-transformation:xlarge": "bun run benchmarks/data-transformation/generate.ts --profile xlarge && bun run benchmarks/data-transformation/run.ts --profile xlarge",
|
|
70
|
+
"bench:data-transformation:stress": "bun run benchmarks/data-transformation/generate.ts --profile stress && bun run benchmarks/data-transformation/run.ts --profile stress",
|
|
71
|
+
"bench:data-transformation:matrix": "bun run benchmarks/data-transformation/matrix.ts",
|
|
72
|
+
"bench:data-transformation": "bun run bench:data-transformation:default",
|
|
63
73
|
"lint:code": "eslint .",
|
|
64
74
|
"lint:code:fix": "eslint . --fix",
|
|
65
75
|
"lint:types": "tsc --noEmit",
|