@gustavo-valsechi/utils 1.0.0 → 1.0.2

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.
@@ -0,0 +1,8 @@
1
+ type DefaultValue<T> = {
2
+ [K in keyof T]: T[K] extends string ? '' : T[K] extends number ? 0 : T[K] extends boolean ? false : T[K] extends Array<infer U> ? DefaultValue<U>[] : T[K] extends object ? DefaultValue<T[K]> : null;
3
+ };
4
+ declare const Default: {
5
+ build<T>(schema: T): DefaultValue<T>;
6
+ };
7
+
8
+ export { type DefaultValue, Default as default };
@@ -0,0 +1,8 @@
1
+ type DefaultValue<T> = {
2
+ [K in keyof T]: T[K] extends string ? '' : T[K] extends number ? 0 : T[K] extends boolean ? false : T[K] extends Array<infer U> ? DefaultValue<U>[] : T[K] extends object ? DefaultValue<T[K]> : null;
3
+ };
4
+ declare const Default: {
5
+ build<T>(schema: T): DefaultValue<T>;
6
+ };
7
+
8
+ export { type DefaultValue, Default as default };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/default/index.ts
31
+ var default_exports = {};
32
+ __export(default_exports, {
33
+ default: () => default_default
34
+ });
35
+ module.exports = __toCommonJS(default_exports);
36
+ var import_lodash = __toESM(require("lodash"));
37
+ var Default = {
38
+ build(schema) {
39
+ const result = {};
40
+ for (const key in schema) {
41
+ const value = schema[key];
42
+ switch (typeof value) {
43
+ case "string":
44
+ result[key] = "";
45
+ break;
46
+ case "number":
47
+ result[key] = 0;
48
+ break;
49
+ case "boolean":
50
+ result[key] = "";
51
+ break;
52
+ case "object":
53
+ if (import_lodash.default.isArray(value)) {
54
+ result[key] = [];
55
+ } else if (value !== null) {
56
+ result[key] = Default.build(value);
57
+ }
58
+ break;
59
+ default:
60
+ result[key] = null;
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ };
66
+ var default_default = Default;
@@ -0,0 +1,35 @@
1
+ // src/default/index.ts
2
+ import _ from "lodash";
3
+ var Default = {
4
+ build(schema) {
5
+ const result = {};
6
+ for (const key in schema) {
7
+ const value = schema[key];
8
+ switch (typeof value) {
9
+ case "string":
10
+ result[key] = "";
11
+ break;
12
+ case "number":
13
+ result[key] = 0;
14
+ break;
15
+ case "boolean":
16
+ result[key] = "";
17
+ break;
18
+ case "object":
19
+ if (_.isArray(value)) {
20
+ result[key] = [];
21
+ } else if (value !== null) {
22
+ result[key] = Default.build(value);
23
+ }
24
+ break;
25
+ default:
26
+ result[key] = null;
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+ };
32
+ var default_default = Default;
33
+ export {
34
+ default_default as default
35
+ };
@@ -4,6 +4,5 @@ declare const Format: {
4
4
  match(value: any): string | any[];
5
5
  money: (value: any, notSign?: boolean) => string;
6
6
  };
7
- //# sourceMappingURL=index.d.ts.map
8
7
 
9
8
  export { Format as default };
@@ -4,6 +4,5 @@ declare const Format: {
4
4
  match(value: any): string | any[];
5
5
  money: (value: any, notSign?: boolean) => string;
6
6
  };
7
- //# sourceMappingURL=index.d.ts.map
8
7
 
9
8
  export { Format as default };
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/format/index.tsx
30
+ // src/format/index.ts
31
31
  var format_exports = {};
32
32
  __export(format_exports, {
33
33
  default: () => format_default
@@ -1,4 +1,4 @@
1
- // src/format/index.tsx
1
+ // src/format/index.ts
2
2
  import _ from "lodash";
3
3
  var Format = {
4
4
  stringLimit(value, limit) {
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DefaultValue } from './src/default/index.mjs';
1
2
  import * as moment from 'moment';
2
3
 
3
4
  declare class Utils {
@@ -29,6 +30,9 @@ declare class Utils {
29
30
  money: (value: any) => any;
30
31
  number: (value: any) => any;
31
32
  };
33
+ static default: {
34
+ build<T>(schema: T): DefaultValue<T>;
35
+ };
32
36
  }
33
37
 
34
- export { Utils as default };
38
+ export { DefaultValue, Utils as default };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DefaultValue } from './src/default/index.js';
1
2
  import * as moment from 'moment';
2
3
 
3
4
  declare class Utils {
@@ -29,6 +30,9 @@ declare class Utils {
29
30
  money: (value: any) => any;
30
31
  number: (value: any) => any;
31
32
  };
33
+ static default: {
34
+ build<T>(schema: T): DefaultValue<T>;
35
+ };
32
36
  }
33
37
 
34
- export { Utils as default };
38
+ export { DefaultValue, Utils as default };
package/dist/index.js CHANGED
@@ -27,14 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // index.tsx
30
+ // index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  default: () => index_default
34
34
  });
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
- // src/moment/index.tsx
37
+ // src/moment/index.ts
38
38
  var import_moment_timezone = __toESM(require("moment-timezone"));
39
39
  import_moment_timezone.default.tz(process.env.NEXT_PUBLIC_TIMEZONE || "");
40
40
  var Moment = (...args) => {
@@ -42,7 +42,7 @@ var Moment = (...args) => {
42
42
  };
43
43
  var moment_default = Moment;
44
44
 
45
- // src/format/index.tsx
45
+ // src/format/index.ts
46
46
  var import_lodash = __toESM(require("lodash"));
47
47
  var Format = {
48
48
  stringLimit(value, limit) {
@@ -74,7 +74,7 @@ var Format = {
74
74
  };
75
75
  var format_default = Format;
76
76
 
77
- // src/mask/index.tsx
77
+ // src/mask/index.ts
78
78
  var import_lodash2 = __toESM(require("lodash"));
79
79
  var Mask = {
80
80
  docNumber: (value) => {
@@ -170,7 +170,7 @@ var Mask = {
170
170
  };
171
171
  var mask_default = Mask;
172
172
 
173
- // src/remove-mask/index.tsx
173
+ // src/remove-mask/index.ts
174
174
  var RemoveMask = {
175
175
  phone: (value) => {
176
176
  if (!value) return "";
@@ -195,13 +195,47 @@ var RemoveMask = {
195
195
  };
196
196
  var remove_mask_default = RemoveMask;
197
197
 
198
- // src/index.tsx
198
+ // src/default/index.ts
199
+ var import_lodash3 = __toESM(require("lodash"));
200
+ var Default = {
201
+ build(schema) {
202
+ const result = {};
203
+ for (const key in schema) {
204
+ const value = schema[key];
205
+ switch (typeof value) {
206
+ case "string":
207
+ result[key] = "";
208
+ break;
209
+ case "number":
210
+ result[key] = 0;
211
+ break;
212
+ case "boolean":
213
+ result[key] = "";
214
+ break;
215
+ case "object":
216
+ if (import_lodash3.default.isArray(value)) {
217
+ result[key] = [];
218
+ } else if (value !== null) {
219
+ result[key] = Default.build(value);
220
+ }
221
+ break;
222
+ default:
223
+ result[key] = null;
224
+ }
225
+ }
226
+ return result;
227
+ }
228
+ };
229
+ var default_default = Default;
230
+
231
+ // src/index.ts
199
232
  var Utils = class {
200
233
  };
201
234
  Utils.moment = moment_default;
202
235
  Utils.format = format_default;
203
236
  Utils.mask = mask_default;
204
237
  Utils.removeMask = remove_mask_default;
238
+ Utils.default = default_default;
205
239
 
206
- // index.tsx
240
+ // index.ts
207
241
  var index_default = Utils;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // src/moment/index.tsx
1
+ // src/moment/index.ts
2
2
  import moment from "moment-timezone";
3
3
  moment.tz(process.env.NEXT_PUBLIC_TIMEZONE || "");
4
4
  var Moment = (...args) => {
@@ -6,7 +6,7 @@ var Moment = (...args) => {
6
6
  };
7
7
  var moment_default = Moment;
8
8
 
9
- // src/format/index.tsx
9
+ // src/format/index.ts
10
10
  import _ from "lodash";
11
11
  var Format = {
12
12
  stringLimit(value, limit) {
@@ -38,7 +38,7 @@ var Format = {
38
38
  };
39
39
  var format_default = Format;
40
40
 
41
- // src/mask/index.tsx
41
+ // src/mask/index.ts
42
42
  import _2 from "lodash";
43
43
  var Mask = {
44
44
  docNumber: (value) => {
@@ -134,7 +134,7 @@ var Mask = {
134
134
  };
135
135
  var mask_default = Mask;
136
136
 
137
- // src/remove-mask/index.tsx
137
+ // src/remove-mask/index.ts
138
138
  var RemoveMask = {
139
139
  phone: (value) => {
140
140
  if (!value) return "";
@@ -159,15 +159,49 @@ var RemoveMask = {
159
159
  };
160
160
  var remove_mask_default = RemoveMask;
161
161
 
162
- // src/index.tsx
162
+ // src/default/index.ts
163
+ import _3 from "lodash";
164
+ var Default = {
165
+ build(schema) {
166
+ const result = {};
167
+ for (const key in schema) {
168
+ const value = schema[key];
169
+ switch (typeof value) {
170
+ case "string":
171
+ result[key] = "";
172
+ break;
173
+ case "number":
174
+ result[key] = 0;
175
+ break;
176
+ case "boolean":
177
+ result[key] = "";
178
+ break;
179
+ case "object":
180
+ if (_3.isArray(value)) {
181
+ result[key] = [];
182
+ } else if (value !== null) {
183
+ result[key] = Default.build(value);
184
+ }
185
+ break;
186
+ default:
187
+ result[key] = null;
188
+ }
189
+ }
190
+ return result;
191
+ }
192
+ };
193
+ var default_default = Default;
194
+
195
+ // src/index.ts
163
196
  var Utils = class {
164
197
  };
165
198
  Utils.moment = moment_default;
166
199
  Utils.format = format_default;
167
200
  Utils.mask = mask_default;
168
201
  Utils.removeMask = remove_mask_default;
202
+ Utils.default = default_default;
169
203
 
170
- // index.tsx
204
+ // index.ts
171
205
  var index_default = Utils;
172
206
  export {
173
207
  index_default as default
@@ -12,6 +12,5 @@ declare const Mask: {
12
12
  regex?: string;
13
13
  }) => string;
14
14
  };
15
- //# sourceMappingURL=index.d.ts.map
16
15
 
17
16
  export { Mask as default };
@@ -12,6 +12,5 @@ declare const Mask: {
12
12
  regex?: string;
13
13
  }) => string;
14
14
  };
15
- //# sourceMappingURL=index.d.ts.map
16
15
 
17
16
  export { Mask as default };
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/mask/index.tsx
30
+ // src/mask/index.ts
31
31
  var mask_exports = {};
32
32
  __export(mask_exports, {
33
33
  default: () => mask_default
@@ -1,4 +1,4 @@
1
- // src/mask/index.tsx
1
+ // src/mask/index.ts
2
2
  import _ from "lodash";
3
3
  var Mask = {
4
4
  docNumber: (value) => {
@@ -1,6 +1,5 @@
1
1
  import moment from 'moment-timezone';
2
2
 
3
3
  declare const Moment: (inp?: moment.MomentInput, format?: moment.MomentFormatSpecification | undefined, language?: string | undefined, strict?: boolean | undefined) => moment.Moment;
4
- //# sourceMappingURL=index.d.ts.map
5
4
 
6
5
  export { Moment as default };
@@ -1,6 +1,5 @@
1
1
  import moment from 'moment-timezone';
2
2
 
3
3
  declare const Moment: (inp?: moment.MomentInput, format?: moment.MomentFormatSpecification | undefined, language?: string | undefined, strict?: boolean | undefined) => moment.Moment;
4
- //# sourceMappingURL=index.d.ts.map
5
4
 
6
5
  export { Moment as default };
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/moment/index.tsx
30
+ // src/moment/index.ts
31
31
  var moment_exports = {};
32
32
  __export(moment_exports, {
33
33
  default: () => moment_default
@@ -1,4 +1,4 @@
1
- // src/moment/index.tsx
1
+ // src/moment/index.ts
2
2
  import moment from "moment-timezone";
3
3
  moment.tz(process.env.NEXT_PUBLIC_TIMEZONE || "");
4
4
  var Moment = (...args) => {
@@ -5,6 +5,5 @@ declare const RemoveMask: {
5
5
  money: (value: any) => any;
6
6
  number: (value: any) => any;
7
7
  };
8
- //# sourceMappingURL=index.d.ts.map
9
8
 
10
9
  export { RemoveMask as default };
@@ -5,6 +5,5 @@ declare const RemoveMask: {
5
5
  money: (value: any) => any;
6
6
  number: (value: any) => any;
7
7
  };
8
- //# sourceMappingURL=index.d.ts.map
9
8
 
10
9
  export { RemoveMask as default };
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/remove-mask/index.tsx
20
+ // src/remove-mask/index.ts
21
21
  var remove_mask_exports = {};
22
22
  __export(remove_mask_exports, {
23
23
  default: () => remove_mask_default
@@ -1,4 +1,4 @@
1
- // src/remove-mask/index.tsx
1
+ // src/remove-mask/index.ts
2
2
  var RemoveMask = {
3
3
  phone: (value) => {
4
4
  if (!value) return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "build:js": "tsup && tsc-alias",
14
14
  "build:remodel": "node scripts/remodel.js",
15
15
  "build": "npm run clean && npm run build:js && npm run build:remodel",
16
- "commit": "npm run build && npm publish --access public"
16
+ "commit": "npm run build && npm version patch --no-git-tag-version && npm publish --access public"
17
17
  },
18
18
  "dependencies": {
19
19
  "lodash": "4.17.21",
package/README.md DELETED
File without changes