@data7expressions/json-light 5.0.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE +21 -0
  3. package/README.md +262 -0
  4. package/__tests__/country.test.d.ts +2 -0
  5. package/__tests__/country.test.d.ts.map +1 -0
  6. package/__tests__/country.test.js +62 -0
  7. package/__tests__/country.test.js.map +1 -0
  8. package/__tests__/order.test.d.ts +2 -0
  9. package/__tests__/order.test.d.ts.map +1 -0
  10. package/__tests__/order.test.js +84 -0
  11. package/__tests__/order.test.js.map +1 -0
  12. package/application/facade.d.ts +13 -0
  13. package/application/facade.d.ts.map +1 -0
  14. package/application/facade.js +26 -0
  15. package/application/facade.js.map +1 -0
  16. package/application/index.d.ts +6 -0
  17. package/application/index.d.ts.map +1 -0
  18. package/application/index.js +22 -0
  19. package/application/index.js.map +1 -0
  20. package/application/services/jsonLightService.d.ts +5 -0
  21. package/application/services/jsonLightService.d.ts.map +1 -0
  22. package/application/services/jsonLightService.js +31 -0
  23. package/application/services/jsonLightService.js.map +1 -0
  24. package/application/useCases/compress.d.ts +9 -0
  25. package/application/useCases/compress.d.ts.map +1 -0
  26. package/application/useCases/compress.js +106 -0
  27. package/application/useCases/compress.js.map +1 -0
  28. package/application/useCases/decompress.d.ts +9 -0
  29. package/application/useCases/decompress.d.ts.map +1 -0
  30. package/application/useCases/decompress.js +102 -0
  31. package/application/useCases/decompress.js.map +1 -0
  32. package/application/useCases/getType.d.ts +5 -0
  33. package/application/useCases/getType.d.ts.map +1 -0
  34. package/application/useCases/getType.js +12 -0
  35. package/application/useCases/getType.js.map +1 -0
  36. package/domain/index.d.ts +2 -0
  37. package/domain/index.d.ts.map +1 -0
  38. package/domain/index.js +18 -0
  39. package/domain/index.js.map +1 -0
  40. package/domain/services.d.ts +22 -0
  41. package/domain/services.d.ts.map +1 -0
  42. package/domain/services.js +3 -0
  43. package/domain/services.js.map +1 -0
  44. package/index.d.ts +2 -0
  45. package/index.d.ts.map +1 -0
  46. package/index.js +18 -0
  47. package/index.js.map +1 -0
  48. package/infrastructure/builder.d.ts +5 -0
  49. package/infrastructure/builder.d.ts.map +1 -0
  50. package/infrastructure/builder.js +12 -0
  51. package/infrastructure/builder.js.map +1 -0
  52. package/infrastructure/cli/json-light.d.ts +5 -0
  53. package/infrastructure/cli/json-light.d.ts.map +1 -0
  54. package/infrastructure/cli/json-light.js +27 -0
  55. package/infrastructure/cli/json-light.js.map +1 -0
  56. package/infrastructure/commands/compress.d.ts +2 -0
  57. package/infrastructure/commands/compress.d.ts.map +1 -0
  58. package/infrastructure/commands/compress.js +40 -0
  59. package/infrastructure/commands/compress.js.map +1 -0
  60. package/infrastructure/commands/decompress.d.ts +2 -0
  61. package/infrastructure/commands/decompress.d.ts.map +1 -0
  62. package/infrastructure/commands/decompress.js +39 -0
  63. package/infrastructure/commands/decompress.js.map +1 -0
  64. package/infrastructure/commands/help.d.ts +2 -0
  65. package/infrastructure/commands/help.d.ts.map +1 -0
  66. package/infrastructure/commands/help.js +38 -0
  67. package/infrastructure/commands/help.js.map +1 -0
  68. package/infrastructure/commands/schema.d.ts +2 -0
  69. package/infrastructure/commands/schema.d.ts.map +1 -0
  70. package/infrastructure/commands/schema.js +37 -0
  71. package/infrastructure/commands/schema.js.map +1 -0
  72. package/infrastructure/commands/version.d.ts +2 -0
  73. package/infrastructure/commands/version.d.ts.map +1 -0
  74. package/infrastructure/commands/version.js +6 -0
  75. package/infrastructure/commands/version.js.map +1 -0
  76. package/infrastructure/helper.d.ts +5 -0
  77. package/infrastructure/helper.d.ts.map +1 -0
  78. package/infrastructure/helper.js +9 -0
  79. package/infrastructure/helper.js.map +1 -0
  80. package/infrastructure/index.d.ts +2 -0
  81. package/infrastructure/index.d.ts.map +1 -0
  82. package/infrastructure/index.js +6 -0
  83. package/infrastructure/index.js.map +1 -0
  84. package/jest-unit-config.json +15 -0
  85. package/package.json +36 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLightService.js","sourceRoot":"","sources":["../../../../src/lib/application/services/jsonLightService.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAmB;IACxB,IAAI,CAAE,KAAU;QACtB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAA;QACb,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC;oBACJ,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACzB,CAAC;gBAAC,WAAM,CAAC;oBACR,OAAO,IAAI,CAAA;gBACZ,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,OAAO,IAAI,CAAA;YACZ,CAAC;QACF,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAA;QACb,CAAC;aAAM,CAAC;YACP,OAAO,IAAI,CAAA;QACZ,CAAC;IACF,CAAC;CACD;AAtBD,kDAsBC"}
@@ -0,0 +1,9 @@
1
+ import { Compressor, CompressorOptions, JsonLightService } from '../../domain';
2
+ export declare class Compress implements Compressor {
3
+ private readonly service;
4
+ constructor(service: JsonLightService);
5
+ compress(data: any, options?: CompressorOptions): any;
6
+ private getKey;
7
+ private _compress;
8
+ }
9
+ //# sourceMappingURL=compress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../../../../src/lib/application/useCases/compress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG9E,qBAAa,QAAS,YAAW,UAAU;IAE7B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAC,gBAAgB;IAE/C,QAAQ,CAAE,IAAI,EAAC,GAAG,EAAE,OAAO,CAAC,EAAC,iBAAiB,GAAE,GAAG;IAQ1D,OAAO,CAAC,MAAM;IAcd,OAAO,CAAC,SAAS;CAiEjB"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Compress = void 0;
4
+ const typ3s_1 = require("@data7expressions/typ3s");
5
+ class Compress {
6
+ // eslint-disable-next-line no-useless-constructor
7
+ constructor(service) {
8
+ this.service = service;
9
+ }
10
+ compress(data, options) {
11
+ const type = options && options.type ? typ3s_1.Type.parse(options.type) : undefined;
12
+ const mapping = options && options.mapping ? {} : undefined;
13
+ const result = this._compress(data, type, mapping);
14
+ result.__map = mapping;
15
+ return result;
16
+ }
17
+ getKey(name, mapping) {
18
+ if (mapping === undefined) {
19
+ return name;
20
+ }
21
+ const entry = Object.entries(mapping).find(p => p[1] === name);
22
+ if (entry !== undefined) {
23
+ return entry[0];
24
+ }
25
+ const keys = Object.keys(mapping).map(p => parseInt(p));
26
+ const key = (keys.length === 0 ? 0 : Math.max(...keys) + 1).toString();
27
+ mapping[key] = name;
28
+ return key;
29
+ }
30
+ _compress(data, type, mapping) {
31
+ let result;
32
+ const _type = type !== undefined && type.primitive !== typ3s_1.Primitive.any ? type : typ3s_1.Type.type(data);
33
+ if (typ3s_1.Type.isPrimitive(_type)) {
34
+ result = data;
35
+ }
36
+ if (_type.primitive === typ3s_1.Primitive.obj && _type.obj !== undefined) {
37
+ const primitives = [];
38
+ const others = {};
39
+ for (const property of _type.obj.properties) {
40
+ if (property.type !== undefined) {
41
+ if (data[property.name] === undefined) {
42
+ if (typ3s_1.Type.isPrimitive(property.type)) {
43
+ primitives.push('<N/D>');
44
+ }
45
+ else {
46
+ others[this.getKey(property.name, mapping)] = '<N/D>';
47
+ }
48
+ }
49
+ else {
50
+ // const value = data[property.name] !== undefined ? data[property.name] : null
51
+ const value = data[property.name];
52
+ if (typ3s_1.Type.isPrimitive(property.type)) {
53
+ primitives.push(value);
54
+ }
55
+ else if (property.type.primitive === typ3s_1.Primitive.any) {
56
+ others[this.getKey(property.name, mapping)] = data[property.name];
57
+ }
58
+ else if (value !== null) {
59
+ others[this.getKey(property.name, mapping)] = this._compress(data[property.name], property.type, mapping);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ if (Object.entries(others).length === 0) {
65
+ result = primitives;
66
+ }
67
+ else {
68
+ result = Object.assign({ _: primitives }, others);
69
+ }
70
+ }
71
+ else if (_type.primitive === typ3s_1.Primitive.list && _type.list !== undefined) {
72
+ const list = [];
73
+ for (const item of data) {
74
+ if (typ3s_1.Type.isPrimitive(_type.list.items) || _type.list.items.primitive === typ3s_1.Primitive.any) {
75
+ list.push(item);
76
+ }
77
+ else {
78
+ const value = this._compress(item, _type.list.items, mapping);
79
+ if (value !== null && value !== undefined && value !== '<N/D>') {
80
+ list.push(value);
81
+ }
82
+ }
83
+ }
84
+ result = list;
85
+ }
86
+ else {
87
+ const input = this.service.json(data);
88
+ if (input) {
89
+ throw new Error(`cannot resolve type ${_type.primitive} for : ${JSON.stringify(input)}`);
90
+ }
91
+ else {
92
+ throw new Error(`cannot resolve type ${_type.primitive} for : ${data}`);
93
+ }
94
+ }
95
+ // If the type was not passed or it was any, the type must be added in the json
96
+ if (type !== undefined && type.primitive !== typ3s_1.Primitive.any) {
97
+ return result;
98
+ }
99
+ if (Object.entries(result).length === 1 && result._ !== undefined) {
100
+ return { _schema: typ3s_1.Type.stringify(_type), _: result._ };
101
+ }
102
+ return { _schema: typ3s_1.Type.stringify(_type), _data: result };
103
+ }
104
+ }
105
+ exports.Compress = Compress;
106
+ //# sourceMappingURL=compress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../../src/lib/application/useCases/compress.ts"],"names":[],"mappings":";;;AAEA,mDAAyD;AAE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EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;IACzD,CAAC;CACD;AA3FD,4BA2FC"}
@@ -0,0 +1,9 @@
1
+ import { Decompressor, DecompressorOptions, JsonLightService } from '../../domain';
2
+ export declare class Decompress implements Decompressor {
3
+ private readonly service;
4
+ constructor(service: JsonLightService);
5
+ decompress(data: any, options?: DecompressorOptions): any;
6
+ private getKey;
7
+ private _decompress;
8
+ }
9
+ //# sourceMappingURL=decompress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../../../src/lib/application/useCases/decompress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAGlF,qBAAa,UAAW,YAAW,YAAY;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAC,gBAAgB;IAE/C,UAAU,CAAE,IAAI,EAAC,GAAG,EAAE,OAAO,CAAC,EAAC,mBAAmB,GAAE,GAAG;IAM9D,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,WAAW;CAgEnB"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Decompress = void 0;
4
+ const typ3s_1 = require("@data7expressions/typ3s");
5
+ class Decompress {
6
+ // eslint-disable-next-line no-useless-constructor
7
+ constructor(service) {
8
+ this.service = service;
9
+ }
10
+ decompress(data, options) {
11
+ const type = options && options.type ? typ3s_1.Type.parse(options.type) : undefined;
12
+ const mapping = data.__map ? data.__map : undefined;
13
+ return this._decompress(data, type, mapping);
14
+ }
15
+ getKey(name, mapping) {
16
+ if (mapping === undefined) {
17
+ return name;
18
+ }
19
+ const entry = Object.entries(mapping).find(p => p[1] === name);
20
+ if (entry !== undefined) {
21
+ return entry[0];
22
+ }
23
+ return name;
24
+ }
25
+ _decompress(data, type, mapping) {
26
+ let _type;
27
+ let _data;
28
+ let result;
29
+ if (type !== undefined && type.primitive !== typ3s_1.Primitive.any) {
30
+ _type = type;
31
+ _data = data;
32
+ }
33
+ else if (data._schema !== undefined) {
34
+ _type = typ3s_1.Type.parse(data._schema);
35
+ _data = data._data;
36
+ }
37
+ else {
38
+ throw new Error('cannot resolve type');
39
+ }
40
+ if (typ3s_1.Type.isPrimitive(_type)) {
41
+ result = data;
42
+ }
43
+ if (_type.primitive === typ3s_1.Primitive.obj && _type.obj !== undefined) {
44
+ result = {};
45
+ let index = 0;
46
+ for (const property of _type.obj.properties) {
47
+ if (property.type !== undefined) {
48
+ if (typ3s_1.Type.isPrimitive(property.type)) {
49
+ const value = _data._ ? _data._[index] : _data[index];
50
+ if (value === '<N/D>') {
51
+ result[property.name] = undefined;
52
+ }
53
+ else {
54
+ result[property.name] = value;
55
+ }
56
+ index = index + 1;
57
+ }
58
+ else {
59
+ const key = this.getKey(property.name, mapping);
60
+ const value = _data[key];
61
+ if (value === '<N/D>') {
62
+ result[property.name] = undefined;
63
+ }
64
+ else if (_data[property.name] === null || value === undefined) {
65
+ result[property.name] = null;
66
+ }
67
+ else if (property.type.primitive === typ3s_1.Primitive.any) {
68
+ result[property.name] = value;
69
+ }
70
+ else {
71
+ result[property.name] = this._decompress(value, property.type, mapping);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ else if (_type.primitive === typ3s_1.Primitive.list && _type.list !== undefined) {
78
+ result = [];
79
+ for (const item of _data) {
80
+ if (typ3s_1.Type.isPrimitive(_type.list.items) || _type.list.items.primitive === typ3s_1.Primitive.any) {
81
+ result.push(item);
82
+ }
83
+ else {
84
+ const value = this._decompress(item, _type.list.items, mapping);
85
+ result.push(value);
86
+ }
87
+ }
88
+ }
89
+ else {
90
+ const input = this.service.json(_data);
91
+ if (input) {
92
+ throw new Error(`cannot resolve type ${_type.primitive} for : ${JSON.stringify(input)}`);
93
+ }
94
+ else {
95
+ throw new Error(`cannot resolve type ${_type.primitive} for : ${_data}`);
96
+ }
97
+ }
98
+ return result;
99
+ }
100
+ }
101
+ exports.Decompress = Decompress;
102
+ //# sourceMappingURL=decompress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.js","sourceRoot":"","sources":["../../../../src/lib/application/useCases/decompress.ts"],"names":[],"mappings":";;;AAEA,mDAAyD;AAEzD,MAAa,UAAU;IACtB,kDAAkD;IAClD,YAA8B,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAEnD,UAAU,CAAE,IAAQ,EAAE,OAA4B;QACxD,MAAM,IAAI,GAAG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,YAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAEO,MAAM,CAAE,IAAW,EAAE,OAAW;QACvC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAA;QACZ,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;QAC9D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,CAAC;QACD,OAAO,IAAI,CAAA;IACZ,CAAC;IAEO,WAAW,CAAE,IAAQ,EAAE,IAAU,EAAE,OAAY;QACtD,IAAI,KAAK,CAAA;QACT,IAAI,KAAK,CAAA;QACT,IAAI,MAAU,CAAA;QACd,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CA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AClB,CAAC;qBAAM,CAAC;oBACP,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;oBAC/D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACnB,CAAC;YACF,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACtC,IAAI,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,CAAC,SAAS,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACzF,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,CAAC,SAAS,UAAU,KAAK,EAAE,CAAC,CAAA;YACzE,CAAC;QACF,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;CACD;AArFD,gCAqFC"}
@@ -0,0 +1,5 @@
1
+ import { TypeSolver } from 'lib/domain';
2
+ export declare class GetType implements TypeSolver {
3
+ type(data: any): string;
4
+ }
5
+ //# sourceMappingURL=getType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../src/lib/application/useCases/getType.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,qBAAa,OAAQ,YAAW,UAAU;IAClC,IAAI,CAAE,IAAI,EAAC,GAAG,GAAE,MAAM;CAI7B"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetType = void 0;
4
+ const typ3s_1 = require("@data7expressions/typ3s");
5
+ class GetType {
6
+ type(data) {
7
+ const type = typ3s_1.Type.type(data);
8
+ return typ3s_1.Type.stringify(type);
9
+ }
10
+ }
11
+ exports.GetType = GetType;
12
+ //# sourceMappingURL=getType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getType.js","sourceRoot":"","sources":["../../../../src/lib/application/useCases/getType.ts"],"names":[],"mappings":";;;AAEA,mDAA8C;AAE9C,MAAa,OAAO;IACZ,IAAI,CAAE,IAAQ;QACpB,MAAM,IAAI,GAAG,YAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5B,OAAO,YAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACD;AALD,0BAKC"}
@@ -0,0 +1,2 @@
1
+ export * from './services';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/domain/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./services"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/domain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B"}
@@ -0,0 +1,22 @@
1
+ export interface TypeSolver {
2
+ type(data: any): string;
3
+ }
4
+ export interface JsonLightService {
5
+ json(value: any): any;
6
+ }
7
+ export interface CompressorOptions {
8
+ type?: string;
9
+ mapping?: boolean;
10
+ }
11
+ export interface Compressor {
12
+ compress(data: any, options?: CompressorOptions): any;
13
+ }
14
+ export interface DecompressorOptions {
15
+ type?: string;
16
+ }
17
+ export interface Decompressor {
18
+ decompress(data: any, options?: DecompressorOptions): any;
19
+ }
20
+ export interface JsonLight extends TypeSolver, JsonLightService, Compressor, Decompressor {
21
+ }
22
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../src/lib/domain/services.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IAC1B,IAAI,CAAE,IAAI,EAAC,GAAG,GAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,CAAC,EAAC,MAAM,CAAA;IACZ,OAAO,CAAC,EAAC,OAAO,CAAA;CAChB;AACD,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAE,IAAI,EAAC,GAAG,EAAE,OAAO,CAAC,EAAC,iBAAiB,GAAE,GAAG,CAAA;CACnD;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,CAAC,EAAC,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,YAAY;IAC5B,UAAU,CAAE,IAAI,EAAC,GAAG,EAAE,OAAO,CAAC,EAAC,mBAAmB,GAAE,GAAG,CAAA;CACvD;AAED,MAAM,WAAW,SAAU,SAAQ,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY;CAAG"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../../src/lib/domain/services.ts"],"names":[],"mappings":""}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './infrastructure';
2
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./infrastructure"), exports);
18
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC"}
@@ -0,0 +1,5 @@
1
+ import { JsonLight } from '../domain';
2
+ export declare class JsonLightBuilder {
3
+ build(): JsonLight;
4
+ }
5
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/lib/infrastructure/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,qBAAa,gBAAgB;IACrB,KAAK,IAAI,SAAS;CAIzB"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonLightBuilder = void 0;
4
+ const application_1 = require("../application");
5
+ class JsonLightBuilder {
6
+ build() {
7
+ const service = new application_1.JsonLightServiceImp();
8
+ return new application_1.JsonLightFacade(new application_1.GetType(), service, new application_1.Compress(service), new application_1.Decompress(service));
9
+ }
10
+ }
11
+ exports.JsonLightBuilder = JsonLightBuilder;
12
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../src/lib/infrastructure/builder.ts"],"names":[],"mappings":";;;AACA,gDAAoG;AAEpG,MAAa,gBAAgB;IACrB,KAAK;QACX,MAAM,OAAO,GAAG,IAAI,iCAAmB,EAAE,CAAA;QACzC,OAAO,IAAI,6BAAe,CAAC,IAAI,qBAAO,EAAE,EAAE,OAAO,EAAE,IAAI,sBAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,wBAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IACnG,CAAC;CACD;AALD,4CAKC"}
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ declare const minimist: any;
3
+ declare const args: any;
4
+ declare const cmd: any;
5
+ //# sourceMappingURL=json-light.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-light.d.ts","sourceRoot":"","sources":["../../../../src/lib/infrastructure/cli/json-light.ts"],"names":[],"mappings":";AACA,QAAA,MAAM,QAAQ,KAAsB,CAAA;AACpC,QAAA,MAAM,IAAI,KAAkC,CAAA;AAC5C,QAAA,MAAM,GAAG,KAAY,CAAA"}
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const minimist = require('minimist');
4
+ const args = minimist(process.argv.slice(2));
5
+ const cmd = args._[0];
6
+ switch (cmd) {
7
+ case 'help':
8
+ require('../commands/help')(args);
9
+ break;
10
+ case 'version':
11
+ require('../commands/version')(args);
12
+ break;
13
+ case 'schema':
14
+ require('../commands/schema')(args);
15
+ break;
16
+ case 'compress':
17
+ require('../commands/compress')(args);
18
+ break;
19
+ case 'decompress':
20
+ require('../commands/decompress')(args);
21
+ break;
22
+ default:
23
+ console.error(`"${cmd}" is not a valid command!`);
24
+ require('../commands/help')(args);
25
+ break;
26
+ }
27
+ //# sourceMappingURL=json-light.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-light.js","sourceRoot":"","sources":["../../../../src/lib/infrastructure/cli/json-light.ts"],"names":[],"mappings":";;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAErB,QAAQ,GAAG,EAAE,CAAC;IACd,KAAK,MAAM;QACV,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAA;QACjC,MAAK;IACN,KAAK,SAAS;QACb,OAAO,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,CAAA;QACpC,MAAK;IACN,KAAK,QAAQ;QACZ,OAAO,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAA;QACnC,MAAK;IACN,KAAK,UAAU;QACd,OAAO,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,CAAA;QACrC,MAAK;IACN,KAAK,YAAY;QAChB,OAAO,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,CAAA;QACvC,MAAK;IACN;QACC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,2BAA2B,CAAC,CAAA;QACjD,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAA;QACjC,MAAK;AACN,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=compress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/compress.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const index_1 = require("../index");
13
+ const helper_1 = require("../helper");
14
+ module.exports = (args) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const input = args.input || args.i;
16
+ const type = args.type || args.t;
17
+ const output = args.output || args.o;
18
+ const mapping = (args.mapping || args.m) !== undefined;
19
+ if (!input) {
20
+ console.error('input is required!');
21
+ return;
22
+ }
23
+ let data = index_1.JsonLight.json(input);
24
+ if (data === null) {
25
+ const str = yield helper_1.jsonLightHelp.fs.read(input);
26
+ if (str === null) {
27
+ throw new Error(`File ${input} not found`);
28
+ }
29
+ data = JSON.parse(str);
30
+ }
31
+ const compressed = index_1.JsonLight.compress(data, { type, mapping });
32
+ const result = JSON.stringify(compressed);
33
+ if (output) {
34
+ yield helper_1.jsonLightHelp.fs.write(output, result);
35
+ }
36
+ else {
37
+ console.log(result);
38
+ }
39
+ });
40
+ //# sourceMappingURL=compress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/compress.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oCAAoC;AACpC,sCAAyC;AACzC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AAA,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=decompress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/decompress.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const index_1 = require("../index");
13
+ const helper_1 = require("../helper");
14
+ module.exports = (args) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const input = args.input || args.i;
16
+ const type = args.type || args.t;
17
+ const output = args.output || args.o;
18
+ if (!input) {
19
+ console.error('input is required!');
20
+ return;
21
+ }
22
+ let data = index_1.JsonLight.json(input);
23
+ if (data === null) {
24
+ const str = yield helper_1.jsonLightHelp.fs.read(input);
25
+ if (str === null) {
26
+ throw new Error(`File ${input} not found`);
27
+ }
28
+ data = JSON.parse(str);
29
+ }
30
+ const decompressed = index_1.JsonLight.decompress(data, { type });
31
+ const result = JSON.stringify(decompressed);
32
+ if (output) {
33
+ yield helper_1.jsonLightHelp.fs.write(output, result);
34
+ }
35
+ else {
36
+ console.log(result);
37
+ }
38
+ });
39
+ //# sourceMappingURL=decompress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.js","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/decompress.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oCAAo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1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/help.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,EAAC,GAiCX,CAAA"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ const menus = {
3
+ main: `
4
+ json-light [command] <options>
5
+
6
+ version ............ show package version
7
+ help................ show help menu for a command
8
+ schema ............. returns the schema from the json data
9
+ compress ........... compress a json file
10
+ decompress ......... decompress a compressed json file`,
11
+ schema: `
12
+ json-light schema <options>
13
+
14
+ --input, -i ........ input json file path or json data
15
+ --output, -o ....... output file (optional)`,
16
+ compress: `
17
+ json-light compress <options>
18
+
19
+ --input, -i ........ input json file path or json data
20
+ --schema, -s ....... schema (optional)
21
+ --output, -o ....... output file (optional)
22
+ --mapping, -m ....... replace property names with keys`,
23
+ decompress: `
24
+ json-light decompress <options>
25
+
26
+ --input, -i ........ input compressed json file path or compressed json data
27
+ --schema, -s ....... schema (optional)
28
+ --output, -o ....... output file (optional)`,
29
+ version: `
30
+ json-light version`
31
+ };
32
+ module.exports = (args) => {
33
+ const subCmd = args._[0] === 'help'
34
+ ? args._[1]
35
+ : args._[0];
36
+ console.log(menus[subCmd] || menus.main);
37
+ };
38
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/help.ts"],"names":[],"mappings":";AAAA,MAAM,KAAK,GAAO;IACjB,IAAI,EAAE;;;;;;;6DAOsD;IAE5D,MAAM,EAAE;;;;kDAIyC;IAEjD,QAAQ,EAAE;;;;;;6DAMkD;IAE5D,UAAU,EAAE;;;;;kDAKqC;IAEjD,OAAO,EAAE;yBACe;CACxB,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,IAAQ,EAAE,EAAE;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM;QAClC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;AACzC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/lib/infrastructure/commands/schema.ts"],"names":[],"mappings":""}