@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.
Files changed (3) hide show
  1. package/dist/index.cjs +194 -47
  2. package/dist/index.mjs +195 -48
  3. 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.2";
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
- function isExcluded(path, exclusions) {
250
- return exclusions.some((pattern) => {
251
- return minimatch.minimatch(path, pattern, {
252
- dot: true,
253
- nobrace: false,
254
- noglobstar: false,
255
- matchBase: false
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 transformObjectFromCamelCaseToSnakeCase(obj, exclusions = []) {
260
- const result = Array.isArray(obj) ? [] : {};
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: obj, target: result, path: "" }
376
+ { source: sourceObject, target: result }
263
377
  ];
264
378
  while (stack.length > 0) {
265
- const { source, target, path } = stack.pop();
379
+ const { source, target } = stack.pop();
266
380
  if (Array.isArray(source)) {
267
- source.forEach((item, index) => {
268
- const newPath = path ? `${path}.*` : "*";
269
- if (Array.isArray(item) || typeof item === "object" && item !== null) {
270
- target[index] = Array.isArray(item) ? [] : {};
271
- stack.push({ source: item, target: target[index], path: newPath });
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
- target[index] = item;
389
+ arrayTarget[index] = item;
274
390
  }
275
- });
276
- } else if (typeof source === "object" && source !== null) {
277
- for (const [key, value] of Object.entries(source)) {
278
- const newPath = path ? `${path}.${key}` : key;
279
- const snakeKey = isExcluded(newPath, exclusions) ? key : changeCase__namespace.snakeCase(key);
280
- if (Array.isArray(value) || typeof value === "object" && value !== null) {
281
- target[snakeKey] = Array.isArray(value) ? [] : {};
282
- stack.push({ source: value, target: target[snakeKey], path: newPath });
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
- target[snakeKey] = value;
405
+ objectTarget[transformedKey] = value;
285
406
  }
286
407
  }
287
408
  }
288
409
  }
289
410
  return result;
290
411
  }
291
- function transformObjectFromSnakeCaseToCamelCase(obj, exclusions = []) {
292
- const result = Array.isArray(obj) ? [] : {};
412
+ function transformWithExclusions(sourceObject, convertKey, compiledExclusions) {
413
+ const result = Array.isArray(sourceObject) ? [] : {};
293
414
  const stack = [
294
- { source: obj, target: result, path: "" }
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
- source.forEach((item, index) => {
300
- const newPath = path ? `${path}.*` : "*";
301
- if (Array.isArray(item) || typeof item === "object" && item !== null) {
302
- target[index] = Array.isArray(item) ? [] : {};
303
- stack.push({ source: item, target: target[index], path: newPath });
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
- target[index] = item;
431
+ arrayTarget[index] = item;
306
432
  }
307
- });
308
- } else if (typeof source === "object" && source !== null) {
309
- for (const [key, value] of Object.entries(source)) {
310
- const newPath = path ? `${path}.${key}` : key;
311
- const camelKey = isExcluded(newPath, exclusions) ? key : changeCase__namespace.camelCase(key);
312
- if (Array.isArray(value) || typeof value === "object" && value !== null) {
313
- target[camelKey] = Array.isArray(value) ? [] : {};
314
- stack.push({ source: value, target: target[camelKey], path: newPath });
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
- target[camelKey] = value;
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 { minimatch } from 'minimatch';
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.2";
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
- function isExcluded(path, exclusions) {
230
- return exclusions.some((pattern) => {
231
- return minimatch(path, pattern, {
232
- dot: true,
233
- nobrace: false,
234
- noglobstar: false,
235
- matchBase: false
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 transformObjectFromCamelCaseToSnakeCase(obj, exclusions = []) {
240
- const result = Array.isArray(obj) ? [] : {};
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: obj, target: result, path: "" }
356
+ { source: sourceObject, target: result }
243
357
  ];
244
358
  while (stack.length > 0) {
245
- const { source, target, path } = stack.pop();
359
+ const { source, target } = stack.pop();
246
360
  if (Array.isArray(source)) {
247
- source.forEach((item, index) => {
248
- const newPath = path ? `${path}.*` : "*";
249
- if (Array.isArray(item) || typeof item === "object" && item !== null) {
250
- target[index] = Array.isArray(item) ? [] : {};
251
- stack.push({ source: item, target: target[index], path: newPath });
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
- target[index] = item;
369
+ arrayTarget[index] = item;
254
370
  }
255
- });
256
- } else if (typeof source === "object" && source !== null) {
257
- for (const [key, value] of Object.entries(source)) {
258
- const newPath = path ? `${path}.${key}` : key;
259
- const snakeKey = isExcluded(newPath, exclusions) ? key : changeCase.snakeCase(key);
260
- if (Array.isArray(value) || typeof value === "object" && value !== null) {
261
- target[snakeKey] = Array.isArray(value) ? [] : {};
262
- stack.push({ source: value, target: target[snakeKey], path: newPath });
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
- target[snakeKey] = value;
385
+ objectTarget[transformedKey] = value;
265
386
  }
266
387
  }
267
388
  }
268
389
  }
269
390
  return result;
270
391
  }
271
- function transformObjectFromSnakeCaseToCamelCase(obj, exclusions = []) {
272
- const result = Array.isArray(obj) ? [] : {};
392
+ function transformWithExclusions(sourceObject, convertKey, compiledExclusions) {
393
+ const result = Array.isArray(sourceObject) ? [] : {};
273
394
  const stack = [
274
- { source: obj, target: result, path: "" }
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
- source.forEach((item, index) => {
280
- const newPath = path ? `${path}.*` : "*";
281
- if (Array.isArray(item) || typeof item === "object" && item !== null) {
282
- target[index] = Array.isArray(item) ? [] : {};
283
- stack.push({ source: item, target: target[index], path: newPath });
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
- target[index] = item;
411
+ arrayTarget[index] = item;
286
412
  }
287
- });
288
- } else if (typeof source === "object" && source !== null) {
289
- for (const [key, value] of Object.entries(source)) {
290
- const newPath = path ? `${path}.${key}` : key;
291
- const camelKey = isExcluded(newPath, exclusions) ? key : changeCase.camelCase(key);
292
- if (Array.isArray(value) || typeof value === "object" && value !== null) {
293
- target[camelKey] = Array.isArray(value) ? [] : {};
294
- stack.push({ source: value, target: target[camelKey], path: newPath });
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
- target[camelKey] = value;
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.2",
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",