租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
2.0 KiB

3 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.formatInventoryConfig = void 0;
  4. const dataFix_1 = require("../utils/dataFix");
  5. const isObject_1 = require("../utils/isObject");
  6. const isArray_1 = require("../utils/isArray");
  7. const formatObjKey_1 = require("../utils/formatObjKey");
  8. function formatInventoryConfig(inventoryConfig, toArray = false) {
  9. if (toArray && isObject_1.isObject(inventoryConfig))
  10. inventoryConfig = [inventoryConfig];
  11. if (isArray_1.isArray(inventoryConfig)) {
  12. inventoryConfig = inventoryConfig.map(formatFn);
  13. }
  14. else {
  15. inventoryConfig = formatFn(inventoryConfig);
  16. }
  17. return inventoryConfig;
  18. }
  19. exports.formatInventoryConfig = formatInventoryConfig;
  20. function formatFn(_) {
  21. dataFix_1.dataFix(_, { bool: ['IsEnabled'] }, conf => {
  22. var _a, _b;
  23. // prefix
  24. conf.prefix = conf.Filter.Prefix;
  25. delete conf.Filter;
  26. // OSSBucketDestination
  27. conf.OSSBucketDestination = conf.Destination.OSSBucketDestination;
  28. // OSSBucketDestination.rolename
  29. conf.OSSBucketDestination.rolename = conf.OSSBucketDestination.RoleArn.replace(/.*\//, '');
  30. delete conf.OSSBucketDestination.RoleArn;
  31. // OSSBucketDestination.bucket
  32. conf.OSSBucketDestination.bucket = conf.OSSBucketDestination.Bucket.replace(/.*:::/, '');
  33. delete conf.OSSBucketDestination.Bucket;
  34. delete conf.Destination;
  35. // frequency
  36. conf.frequency = conf.Schedule.Frequency;
  37. delete conf.Schedule.Frequency;
  38. // optionalFields
  39. if (((_a = conf === null || conf === void 0 ? void 0 : conf.OptionalFields) === null || _a === void 0 ? void 0 : _a.Field) && !isArray_1.isArray((_b = conf.OptionalFields) === null || _b === void 0 ? void 0 : _b.Field))
  40. conf.OptionalFields.Field = [conf.OptionalFields.Field];
  41. });
  42. // firstLowerCase
  43. _ = formatObjKey_1.formatObjKey(_, 'firstLowerCase', { exclude: ['OSSBucketDestination', 'SSE-OSS', 'SSE-KMS'] });
  44. return _;
  45. }