@accordproject/template-engine 3.0.1 → 4.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.
- package/README.md +41 -0
- package/lib/JavaScriptEvaluator.d.ts +71 -0
- package/lib/JavaScriptEvaluator.js +245 -0
- package/lib/JavaScriptEvaluator.js.map +1 -0
- package/lib/TemplateArchiveProcessor.d.ts +61 -0
- package/lib/TemplateArchiveProcessor.js +152 -0
- package/lib/TemplateArchiveProcessor.js.map +1 -0
- package/lib/TemplateMarkInterpreter.d.ts +34 -0
- package/lib/TemplateMarkInterpreter.js +689 -0
- package/lib/TemplateMarkInterpreter.js.map +1 -0
- package/lib/TemplateMarkNodes.d.ts +19 -0
- package/lib/TemplateMarkNodes.js +45 -0
- package/lib/TemplateMarkNodes.js.map +1 -0
- package/lib/TemplateMarkToJavaScriptCompiler.d.ts +20 -0
- package/lib/TemplateMarkToJavaScriptCompiler.js +99 -0
- package/lib/TemplateMarkToJavaScriptCompiler.js.map +1 -0
- package/lib/TypeScriptCompilationContext.d.ts +15 -0
- package/lib/TypeScriptCompilationContext.js +57 -0
- package/lib/TypeScriptCompilationContext.js.map +1 -0
- package/lib/TypeScriptRuntime.d.ts +17 -0
- package/lib/TypeScriptRuntime.js +84 -0
- package/lib/TypeScriptRuntime.js.map +1 -0
- package/lib/TypeScriptToJavaScriptCompiler.d.ts +11 -0
- package/lib/TypeScriptToJavaScriptCompiler.js +169 -0
- package/lib/TypeScriptToJavaScriptCompiler.js.map +1 -0
- package/lib/drafting/Boolean/index.d.ts +6 -0
- package/lib/drafting/Boolean/index.js +30 -0
- package/lib/drafting/Boolean/index.js.map +1 -0
- package/lib/drafting/DateTime/index.d.ts +8 -0
- package/lib/drafting/DateTime/index.js +33 -0
- package/lib/drafting/DateTime/index.js.map +1 -0
- package/lib/drafting/Double/format.d.ts +14 -0
- package/lib/drafting/Double/format.js +62 -0
- package/lib/drafting/Double/format.js.map +1 -0
- package/lib/drafting/Double/index.d.ts +8 -0
- package/lib/drafting/Double/index.js +33 -0
- package/lib/drafting/Double/index.js.map +1 -0
- package/lib/drafting/DraftFormat.d.ts +5 -0
- package/lib/drafting/DraftFormat.js +18 -0
- package/lib/drafting/DraftFormat.js.map +1 -0
- package/lib/drafting/Duration/index.d.ts +6 -0
- package/lib/drafting/Duration/index.js +39 -0
- package/lib/drafting/Duration/index.js.map +1 -0
- package/lib/drafting/Integer/format.d.ts +14 -0
- package/lib/drafting/Integer/format.js +52 -0
- package/lib/drafting/Integer/format.js.map +1 -0
- package/lib/drafting/Integer/index.d.ts +8 -0
- package/lib/drafting/Integer/index.js +33 -0
- package/lib/drafting/Integer/index.js.map +1 -0
- package/lib/drafting/Long/index.d.ts +8 -0
- package/lib/drafting/Long/index.js +33 -0
- package/lib/drafting/Long/index.js.map +1 -0
- package/lib/drafting/MonetaryAmount/currencycode.d.ts +35 -0
- package/lib/drafting/MonetaryAmount/currencycode.js +53 -0
- package/lib/drafting/MonetaryAmount/currencycode.js.map +1 -0
- package/lib/drafting/MonetaryAmount/index.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/index.js +67 -0
- package/lib/drafting/MonetaryAmount/index.js.map +1 -0
- package/lib/drafting/String/index.d.ts +6 -0
- package/lib/drafting/String/index.js +25 -0
- package/lib/drafting/String/index.js.map +1 -0
- package/lib/drafting/index.d.ts +2 -0
- package/lib/drafting/index.js +43 -0
- package/lib/drafting/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +42 -0
- package/lib/index.js.map +1 -0
- package/lib/model-gen/concerto.d.ts +13 -0
- package/lib/model-gen/concerto.js +4 -0
- package/lib/model-gen/concerto.js.map +1 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.d.ts +196 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.js +4 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.js.map +1 -0
- package/lib/model-gen/concerto@1.0.0.d.ts +19 -0
- package/lib/model-gen/concerto@1.0.0.js +4 -0
- package/lib/model-gen/concerto@1.0.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.d.ts +49 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js +4 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.d.ts +89 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.js +4 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.d.ts +76 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.js +11 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.js.map +1 -0
- package/lib/runtime/declarations.d.ts +3 -0
- package/lib/runtime/declarations.js +22 -0
- package/lib/runtime/declarations.js.map +1 -0
- package/lib/slc/model-gen/concerto.d.ts +13 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.d.ts +6 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.js +5 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.js.map +1 -0
- package/lib/slc/model-gen/concerto.js +5 -0
- package/lib/slc/model-gen/concerto.js.map +1 -0
- package/lib/slc/model-gen/concerto@1.0.0.d.ts +24 -0
- package/lib/slc/model-gen/concerto@1.0.0.js +6 -0
- package/lib/slc/model-gen/concerto@1.0.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.d.ts +7 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js +5 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.d.ts +15 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js +4 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.d.ts +46 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.js +48 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.js.map +1 -0
- package/lib/utils.d.ts +6 -0
- package/lib/utils.js +71 -0
- package/lib/utils.js.map +1 -0
- package/lib/worker.d.ts +1 -0
- package/{dist → lib}/worker.js +12 -10
- package/lib/worker.js.map +1 -0
- package/package.json +37 -25
- package/umd/template-engine.js +13 -0
- package/umd/template-engine.js.LICENSE.txt +21 -0
- package/dist/index.d.ts +0 -174
- package/dist/index.js +0 -1244
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1217
- package/dist/index.mjs.map +0 -1
- package/dist/worker.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = booleanDrafter;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a drafter for Boolean
|
|
19
|
+
* @param {Boolean} value the Boolean
|
|
20
|
+
* @returns {string} the text
|
|
21
|
+
*/
|
|
22
|
+
function booleanDrafter(value) {
|
|
23
|
+
if (value) {
|
|
24
|
+
return 'true';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return 'false';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/Boolean/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAOH,iCAMC;AAXD;;;;GAIG;AACH,SAAwB,cAAc,CAAC,KAAa;IAChD,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,MAAM,CAAC;IAClB,CAAC;SAAM,CAAC;QACJ,OAAO,OAAO,CAAC;IACnB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DateTimeFormat } from '../DraftFormat';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a drafter for DateTime
|
|
4
|
+
* @param {string} value the DateTime
|
|
5
|
+
* @param {object} format the the format
|
|
6
|
+
* @returns {string} the text
|
|
7
|
+
*/
|
|
8
|
+
export default function dateTimeDrafter(value: string, format?: DateTimeFormat): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.default = dateTimeDrafter;
|
|
20
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
21
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
22
|
+
dayjs_1.default.extend(utc_1.default);
|
|
23
|
+
/**
|
|
24
|
+
* Creates a drafter for DateTime
|
|
25
|
+
* @param {string} value the DateTime
|
|
26
|
+
* @param {object} format the the format
|
|
27
|
+
* @returns {string} the text
|
|
28
|
+
*/
|
|
29
|
+
function dateTimeDrafter(value, format) {
|
|
30
|
+
const f = format ? format : 'MM/DD/YYYY';
|
|
31
|
+
return dayjs_1.default.utc(value).format(f);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/DateTime/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;AAaH,kCAGC;AAdD,kDAA0B;AAC1B,2DAAmC;AAEnC,eAAK,CAAC,MAAM,CAAC,aAAG,CAAC,CAAC;AAElB;;;;;GAKG;AACH,SAAwB,eAAe,CAAC,KAAY,EAAC,MAAsB;IACvE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC;IACzC,OAAO,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NumberDraftFormat } from '../DraftFormat';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a drafter for Double
|
|
4
|
+
* @param {number} value - the double
|
|
5
|
+
* @returns {string} the text
|
|
6
|
+
*/
|
|
7
|
+
export declare function draftDoubleIEEE(value: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a drafter for a formatted Double
|
|
10
|
+
* @param {number} value - the Double
|
|
11
|
+
* @param {NumberDraftFormat} format - the format
|
|
12
|
+
* @returns {string} formatted double value as string
|
|
13
|
+
*/
|
|
14
|
+
export declare function draftDoubleFormat(value: number, format: NumberDraftFormat): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.draftDoubleIEEE = draftDoubleIEEE;
|
|
4
|
+
exports.draftDoubleFormat = draftDoubleFormat;
|
|
5
|
+
/*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
const to_words_1 = require("to-words");
|
|
19
|
+
/**
|
|
20
|
+
* Creates a drafter for Double
|
|
21
|
+
* @param {number} value - the double
|
|
22
|
+
* @returns {string} the text
|
|
23
|
+
*/
|
|
24
|
+
function draftDoubleIEEE(value) {
|
|
25
|
+
if (Math.floor(value) === value) {
|
|
26
|
+
return (new Number(value)).toFixed(1); // Make sure there is always decimal point
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return '' + value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a drafter for a formatted Double
|
|
34
|
+
* @param {number} value - the Double
|
|
35
|
+
* @param {NumberDraftFormat} format - the format
|
|
36
|
+
* @returns {string} formatted double value as string
|
|
37
|
+
*/
|
|
38
|
+
function draftDoubleFormat(value, format) {
|
|
39
|
+
if (format === 'text') {
|
|
40
|
+
const converter = new to_words_1.ToWords();
|
|
41
|
+
const res = converter.convert(value);
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return format.replace(/0(.)0((.)(0+))?/gi, function (_a, sep1, _b, sep2, digits) {
|
|
46
|
+
const len = digits ? digits.length : 0;
|
|
47
|
+
const vs = value.toFixed(len);
|
|
48
|
+
let res = '';
|
|
49
|
+
if (sep2) {
|
|
50
|
+
const d = vs.substring(vs.length - len);
|
|
51
|
+
res += sep2 + d;
|
|
52
|
+
}
|
|
53
|
+
let i = vs.substring(0, vs.length - (len === 0 ? 0 : len + 1));
|
|
54
|
+
while (i.length > 3) {
|
|
55
|
+
res = sep1 + i.substring(i.length - 3) + res;
|
|
56
|
+
i = i.substring(0, i.length - 3);
|
|
57
|
+
}
|
|
58
|
+
return i + res;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/drafting/Double/format.ts"],"names":[],"mappings":";;AAoBA,0CAMC;AAQD,8CAsBC;AAxDD;;;;;;;;;;;;GAYG;AACH,uCAAiC;AAEjC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,KAAY;IACxC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,0CAA0C;IACrF,CAAC;SAAM,CAAC;QACJ,OAAO,EAAE,GAAG,KAAK,CAAC;IACtB,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAY,EAAC,MAAwB;IACnE,IAAG,MAAM,KAAG,MAAM,EAAE,CAAC;QACjB,MAAM,SAAS,GAAW,IAAI,kBAAO,EAAE,CAAC;QACxC,MAAM,GAAG,GAAQ,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,GAAG,CAAC;IACf,CAAC;SAAM,CAAC;QACJ,OAAO,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAS,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM;YACtE,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAI,GAAG,GAAG,EAAE,CAAC;YACb,IAAI,IAAI,EAAE,CAAC;gBACP,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;gBACxC,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC;YACpB,CAAC;YACD,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAC,EAAE,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAC,CAAC,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClB,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;gBAC7C,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,GAAG,GAAG,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberDraftFormat } from '../DraftFormat';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a drafter for a double
|
|
4
|
+
* @param {number} value - the Double
|
|
5
|
+
* @param {NumberDraftFormat} format - the format
|
|
6
|
+
* @returns {string} the text
|
|
7
|
+
*/
|
|
8
|
+
export default function doubleDrafter(value: number, format?: NumberDraftFormat): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = doubleDrafter;
|
|
17
|
+
const format_1 = require("./format");
|
|
18
|
+
const format_2 = require("./format");
|
|
19
|
+
/**
|
|
20
|
+
* Creates a drafter for a double
|
|
21
|
+
* @param {number} value - the Double
|
|
22
|
+
* @param {NumberDraftFormat} format - the format
|
|
23
|
+
* @returns {string} the text
|
|
24
|
+
*/
|
|
25
|
+
function doubleDrafter(value, format) {
|
|
26
|
+
if (format) {
|
|
27
|
+
return (0, format_2.draftDoubleFormat)(value, format);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return (0, format_1.draftDoubleIEEE)(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/Double/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAYH,gCAMC;AAfD,qCAA2C;AAC3C,qCAA6C;AAE7C;;;;;GAKG;AACH,SAAwB,aAAa,CAAC,KAAY,EAAC,MAAyB;IACxE,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,IAAA,0BAAiB,EAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACJ,OAAO,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TextNumberDraftFormat = "text";
|
|
2
|
+
export type NumberDraftFormat = typeof TextNumberDraftFormat | string;
|
|
3
|
+
export type DateTimeFormat = string;
|
|
4
|
+
export type MonetaryAmountFormat = string;
|
|
5
|
+
export type DraftFormat = NumberDraftFormat | DateTimeFormat | MonetaryAmountFormat;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.TextNumberDraftFormat = void 0;
|
|
17
|
+
exports.TextNumberDraftFormat = 'text';
|
|
18
|
+
//# sourceMappingURL=DraftFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraftFormat.js","sourceRoot":"","sources":["../../src/drafting/DraftFormat.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEU,QAAA,qBAAqB,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = durationDrafter;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a value is a valid Duration
|
|
19
|
+
*/
|
|
20
|
+
function isDuration(value) {
|
|
21
|
+
return (value != null &&
|
|
22
|
+
typeof value === 'object' &&
|
|
23
|
+
'amount' in value &&
|
|
24
|
+
'unit' in value &&
|
|
25
|
+
typeof value.amount === 'number' &&
|
|
26
|
+
typeof value.unit === 'string');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a drafter for Duration/Period types
|
|
30
|
+
* @param {unknown} value the duration or period (validated at runtime)
|
|
31
|
+
* @returns {string} the text (e.g., "2 days")
|
|
32
|
+
*/
|
|
33
|
+
function durationDrafter(value) {
|
|
34
|
+
if (!isDuration(value)) {
|
|
35
|
+
return '0 unknown';
|
|
36
|
+
}
|
|
37
|
+
return `${value.amount} ${value.unit}`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/Duration/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AA0BH,kCAMC;AAzBD;;GAEG;AACH,SAAS,UAAU,CAAC,KAAc;IAC9B,OAAO,CACH,KAAK,IAAI,IAAI;QACb,OAAO,KAAK,KAAK,QAAQ;QACzB,QAAQ,IAAI,KAAK;QACjB,MAAM,IAAI,KAAK;QACf,OAAQ,KAAkB,CAAC,MAAM,KAAK,QAAQ;QAC9C,OAAQ,KAAkB,CAAC,IAAI,KAAK,QAAQ,CAC/C,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAwB,eAAe,CAAC,KAAc;IAClD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NumberDraftFormat } from '../DraftFormat';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a drafter for Integer
|
|
4
|
+
* @param {number} value - the integer
|
|
5
|
+
* @returns {string} the text
|
|
6
|
+
*/
|
|
7
|
+
export declare function draftInteger(value: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a drafter for a formatted Integer
|
|
10
|
+
* @param {number} value - the Integer
|
|
11
|
+
* @param {NumberDraftFormat} format - the format
|
|
12
|
+
* @returns {string} formatted integer value as string
|
|
13
|
+
*/
|
|
14
|
+
export declare function draftIntegerFormat(value: number, format: NumberDraftFormat): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.draftInteger = draftInteger;
|
|
17
|
+
exports.draftIntegerFormat = draftIntegerFormat;
|
|
18
|
+
const to_words_1 = require("to-words");
|
|
19
|
+
/**
|
|
20
|
+
* Creates a drafter for Integer
|
|
21
|
+
* @param {number} value - the integer
|
|
22
|
+
* @returns {string} the text
|
|
23
|
+
*/
|
|
24
|
+
function draftInteger(value) {
|
|
25
|
+
return '' + value;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a drafter for a formatted Integer
|
|
29
|
+
* @param {number} value - the Integer
|
|
30
|
+
* @param {NumberDraftFormat} format - the format
|
|
31
|
+
* @returns {string} formatted integer value as string
|
|
32
|
+
*/
|
|
33
|
+
function draftIntegerFormat(value, format) {
|
|
34
|
+
if (format === 'text') {
|
|
35
|
+
const converter = new to_words_1.ToWords();
|
|
36
|
+
const res = converter.convert(value);
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return format.replace(/0(.)0/gi, function (_a, sep1) {
|
|
41
|
+
const vs = value.toFixed(0);
|
|
42
|
+
let res = '';
|
|
43
|
+
let i = vs.substring(0, vs.length);
|
|
44
|
+
while (i.length > 3) {
|
|
45
|
+
res = sep1 + i.substring(i.length - 3) + res;
|
|
46
|
+
i = i.substring(0, i.length - 3);
|
|
47
|
+
}
|
|
48
|
+
return i + res;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/drafting/Integer/format.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAUH,oCAEC;AAQD,gDAiBC;AAnCD,uCAAiC;AAGjC;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAY;IACrC,OAAO,EAAE,GAAG,KAAK,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,KAAY,EAAC,MAAwB;IACpE,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACpB,MAAM,SAAS,GAAW,IAAI,kBAAO,EAAE,CAAC;QACxC,MAAM,GAAG,GAAQ,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,GAAG,CAAC;IACf,CAAC;SAAM,CAAC;QACJ,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,UAAS,EAAE,EAAC,IAAI;YAC7C,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,GAAG,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAC,EAAE,CAAC,MAAM,CAAC,CAAC;YAClC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClB,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;gBAC7C,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,GAAG,GAAG,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberDraftFormat } from '../DraftFormat';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a drafter for an Integer
|
|
4
|
+
* @param {number} value - the integer
|
|
5
|
+
* @param {NumberDraftFormat} format - the format
|
|
6
|
+
* @returns {string} the text
|
|
7
|
+
*/
|
|
8
|
+
export default function integerDrafter(value: number, format?: NumberDraftFormat): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
* See the License for the specific language governing permissions and
|
|
12
|
+
* limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
'use strict';
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = integerDrafter;
|
|
17
|
+
const format_1 = require("./format");
|
|
18
|
+
const format_2 = require("./format");
|
|
19
|
+
/**
|
|
20
|
+
* Creates a drafter for an Integer
|
|
21
|
+
* @param {number} value - the integer
|
|
22
|
+
* @param {NumberDraftFormat} format - the format
|
|
23
|
+
* @returns {string} the text
|
|
24
|
+
*/
|
|
25
|
+
function integerDrafter(value, format) {
|
|
26
|
+
if (format) {
|
|
27
|
+
return (0, format_2.draftIntegerFormat)(value, format);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return (0, format_1.draftInteger)(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/Integer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,YAAY,CAAC;;AAYb,iCAMC;AAfD,qCAAwC;AACxC,qCAA8C;AAE9C;;;;;GAKG;AACH,SAAwB,cAAc,CAAC,KAAY,EAAC,MAAyB;IACzE,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,IAAA,2BAAkB,EAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACJ,OAAO,IAAA,qBAAY,EAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberDraftFormat } from '../DraftFormat';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a drafter for a long
|
|
4
|
+
* @param {number} value - the Long
|
|
5
|
+
* @param {NumberDraftFormat} format - the format
|
|
6
|
+
* @returns {string} the text
|
|
7
|
+
*/
|
|
8
|
+
export default function longDrafter(value: number, format?: NumberDraftFormat): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = longDrafter;
|
|
17
|
+
const format_1 = require("../Integer/format");
|
|
18
|
+
const format_2 = require("../Integer/format");
|
|
19
|
+
/**
|
|
20
|
+
* Creates a drafter for a long
|
|
21
|
+
* @param {number} value - the Long
|
|
22
|
+
* @param {NumberDraftFormat} format - the format
|
|
23
|
+
* @returns {string} the text
|
|
24
|
+
*/
|
|
25
|
+
function longDrafter(value, format) {
|
|
26
|
+
if (format) {
|
|
27
|
+
return (0, format_2.draftIntegerFormat)(value, format);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return (0, format_1.draftInteger)(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/Long/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAYH,8BAMC;AAhBD,8CAA8D;AAC9D,8CAA0E;AAG1E;;;;;GAKG;AACH,SAAwB,WAAW,CAAC,KAAY,EAAC,MAAyB;IACtE,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,IAAA,2BAAe,EAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACJ,OAAO,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare enum CurrencyCode {
|
|
2
|
+
'USD' = "$",
|
|
3
|
+
'EUR' = "\u20AC",
|
|
4
|
+
'JPY' = "\u00A5",
|
|
5
|
+
'GBP' = "\u00A3",
|
|
6
|
+
'AUD' = "A$",
|
|
7
|
+
'CAD' = "C$",
|
|
8
|
+
'CHF' = "CHF",
|
|
9
|
+
'CNY' = "\u5143",
|
|
10
|
+
'HKD' = "HK$",
|
|
11
|
+
'NZD' = "NZ$",
|
|
12
|
+
'KRW' = "\u20A9",
|
|
13
|
+
'SGD' = "S$",
|
|
14
|
+
'MXN' = "MEX$",
|
|
15
|
+
'INR' = "\u20B9",
|
|
16
|
+
'RUB' = "\u20BD",
|
|
17
|
+
'ZAR' = "R",
|
|
18
|
+
'TRY' = "\u20BA",
|
|
19
|
+
'BRL' = "R$",
|
|
20
|
+
'TWD' = "NT$",
|
|
21
|
+
'PLN' = "z\u0142",
|
|
22
|
+
'THB' = "\u0E3F",
|
|
23
|
+
'IDR' = "Rp",
|
|
24
|
+
'HUF' = "Ft",
|
|
25
|
+
'CZK' = "K\u010D",
|
|
26
|
+
'ILS' = "\u20AA",
|
|
27
|
+
'CLP' = "CLP$",
|
|
28
|
+
'PHP' = "\u20B1",
|
|
29
|
+
'AED' = "\u062F.\u0625",
|
|
30
|
+
'COP' = "COL$",
|
|
31
|
+
'SAR' = "\uFDFC",
|
|
32
|
+
'MYR' = "RM",
|
|
33
|
+
'RON' = "L",
|
|
34
|
+
'BGN' = "\u043B\u0432."
|
|
35
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CurrencyCode = void 0;
|
|
17
|
+
var CurrencyCode;
|
|
18
|
+
(function (CurrencyCode) {
|
|
19
|
+
CurrencyCode["USD"] = "$";
|
|
20
|
+
CurrencyCode["EUR"] = "\u20AC";
|
|
21
|
+
CurrencyCode["JPY"] = "\u00A5";
|
|
22
|
+
CurrencyCode["GBP"] = "\u00A3";
|
|
23
|
+
CurrencyCode["AUD"] = "A$";
|
|
24
|
+
CurrencyCode["CAD"] = "C$";
|
|
25
|
+
CurrencyCode["CHF"] = "CHF";
|
|
26
|
+
CurrencyCode["CNY"] = "\u5143";
|
|
27
|
+
CurrencyCode["HKD"] = "HK$";
|
|
28
|
+
CurrencyCode["NZD"] = "NZ$";
|
|
29
|
+
CurrencyCode["KRW"] = "\u20A9";
|
|
30
|
+
CurrencyCode["SGD"] = "S$";
|
|
31
|
+
CurrencyCode["MXN"] = "MEX$";
|
|
32
|
+
CurrencyCode["INR"] = "\u20B9";
|
|
33
|
+
CurrencyCode["RUB"] = "\u20BD";
|
|
34
|
+
CurrencyCode["ZAR"] = "R";
|
|
35
|
+
CurrencyCode["TRY"] = "\u20BA";
|
|
36
|
+
CurrencyCode["BRL"] = "R$";
|
|
37
|
+
CurrencyCode["TWD"] = "NT$";
|
|
38
|
+
CurrencyCode["PLN"] = "z\u0142";
|
|
39
|
+
CurrencyCode["THB"] = "\u0E3F";
|
|
40
|
+
CurrencyCode["IDR"] = "Rp";
|
|
41
|
+
CurrencyCode["HUF"] = "Ft";
|
|
42
|
+
CurrencyCode["CZK"] = "K\u010D";
|
|
43
|
+
CurrencyCode["ILS"] = "\u20AA";
|
|
44
|
+
CurrencyCode["CLP"] = "CLP$";
|
|
45
|
+
CurrencyCode["PHP"] = "\u20B1";
|
|
46
|
+
CurrencyCode["AED"] = "\u062F.\u0625";
|
|
47
|
+
CurrencyCode["COP"] = "COL$";
|
|
48
|
+
CurrencyCode["SAR"] = "\uFDFC";
|
|
49
|
+
CurrencyCode["MYR"] = "RM";
|
|
50
|
+
CurrencyCode["RON"] = "L";
|
|
51
|
+
CurrencyCode["BGN"] = "\u043B\u0432.";
|
|
52
|
+
})(CurrencyCode || (exports.CurrencyCode = CurrencyCode = {}));
|
|
53
|
+
//# sourceMappingURL=currencycode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currencycode.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/currencycode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,IAAY,YAkCX;AAlCD,WAAY,YAAY;IACpB,yBAAW,CAAA;IACX,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,0BAAW,CAAA;IACX,2BAAY,CAAA;IACZ,8BAAU,CAAA;IACV,2BAAY,CAAA;IACZ,2BAAY,CAAA;IACZ,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,yBAAU,CAAA;IACV,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,2BAAY,CAAA;IACZ,+BAAW,CAAA;IACX,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,0BAAW,CAAA;IACX,+BAAW,CAAA;IACX,8BAAU,CAAA;IACV,4BAAa,CAAA;IACb,8BAAU,CAAA;IACV,qCAAY,CAAA;IACZ,4BAAa,CAAA;IACb,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,yBAAU,CAAA;IACV,qCAAY,CAAA;AAChB,CAAC,EAlCW,YAAY,4BAAZ,YAAY,QAkCvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MonetaryAmountFormat } from '../DraftFormat';
|
|
2
|
+
type MonetaryAmount = {
|
|
3
|
+
doubleValue: number;
|
|
4
|
+
currencyCode: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Creates a drafter for a monetary amount
|
|
8
|
+
* @param {object} value the monetary amount
|
|
9
|
+
* @param {string} format the format
|
|
10
|
+
* @returns {string} the text
|
|
11
|
+
*/
|
|
12
|
+
export default function monetaryAmountDrafter(value: MonetaryAmount, format?: MonetaryAmountFormat): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = monetaryAmountDrafter;
|
|
17
|
+
const format_1 = require("../Double/format");
|
|
18
|
+
const format_2 = require("../Double/format");
|
|
19
|
+
const currencycode_1 = require("./currencycode");
|
|
20
|
+
/**
|
|
21
|
+
* Creates a drafter for monetary amount with no format
|
|
22
|
+
* @param {object} value the monetary amount
|
|
23
|
+
* @returns {string} the text
|
|
24
|
+
*/
|
|
25
|
+
function monetaryAmountDefaultDrafter(value) {
|
|
26
|
+
return '' + (0, format_1.draftDoubleIEEE)(value.doubleValue) + ' ' + value.currencyCode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Symbol from a currency code
|
|
30
|
+
* @param {string} c - the currency code
|
|
31
|
+
* @returns {string} the symbol
|
|
32
|
+
*/
|
|
33
|
+
function codeSymbol(c) {
|
|
34
|
+
const index = Object.keys(currencycode_1.CurrencyCode).indexOf(c);
|
|
35
|
+
if (index >= 0) {
|
|
36
|
+
return Object.values(currencycode_1.CurrencyCode)[index];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return c;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a drafter for monetary amount with a given format
|
|
44
|
+
* @param {object} value the monetary amount
|
|
45
|
+
* @param {string} format the format
|
|
46
|
+
* @returns {string} the text
|
|
47
|
+
*/
|
|
48
|
+
function monetaryAmountFormatDrafter(value, format) {
|
|
49
|
+
return (0, format_2.draftDoubleFormat)(value.doubleValue, format
|
|
50
|
+
.replace(/K/gi, codeSymbol(value.currencyCode))
|
|
51
|
+
.replace(/CCC/gi, value.currencyCode));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a drafter for a monetary amount
|
|
55
|
+
* @param {object} value the monetary amount
|
|
56
|
+
* @param {string} format the format
|
|
57
|
+
* @returns {string} the text
|
|
58
|
+
*/
|
|
59
|
+
function monetaryAmountDrafter(value, format) {
|
|
60
|
+
if (format) {
|
|
61
|
+
return monetaryAmountFormatDrafter(value, format);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return monetaryAmountDefaultDrafter(value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAuDH,wCAMC;AA3DD,6CAAmD;AACnD,6CAAqD;AAErD,iDAA8C;AAO9C;;;;GAIG;AACH,SAAS,4BAA4B,CAAC,KAAoB;IACtD,OAAO,EAAE,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,CAAQ;IACxB,MAAM,KAAK,GAAW,MAAM,CAAC,IAAI,CAAC,2BAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAG,KAAK,IAAG,CAAC,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAY,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;SACI,CAAC;QACF,OAAO,CAAC,CAAC;IACb,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,KAAoB,EAAC,MAA2B;IACjF,OAAO,IAAA,0BAAiB,EAAC,KAAK,CAAC,WAAW,EACtC,MAAM;SACD,OAAO,CAAC,KAAK,EAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;SAC7C,OAAO,CAAC,OAAO,EAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,SAAwB,qBAAqB,CAAC,KAAoB,EAAC,MAA4B;IAC3F,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,2BAA2B,CAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACJ,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC"}
|