@accordproject/template-engine 3.1.0 → 4.2.1
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 +151 -0
- package/lib/TemplateArchiveProcessor.js +447 -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 +42 -0
- package/lib/TypeScriptCompilationContext.js +170 -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/formatTokens.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/formatTokens.js +44 -0
- package/lib/drafting/MonetaryAmount/formatTokens.js.map +1 -0
- package/lib/drafting/MonetaryAmount/index.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/index.js +51 -0
- package/lib/drafting/MonetaryAmount/index.js.map +1 -0
- package/lib/drafting/PreciseAmount/index.d.ts +17 -0
- package/lib/drafting/PreciseAmount/index.js +113 -0
- package/lib/drafting/PreciseAmount/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 +63 -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/llm/LLMConfig.d.ts +121 -0
- package/lib/llm/LLMConfig.js +30 -0
- package/lib/llm/LLMConfig.js.map +1 -0
- package/lib/llm/LLMExecutor.d.ts +77 -0
- package/lib/llm/LLMExecutor.js +603 -0
- package/lib/llm/LLMExecutor.js.map +1 -0
- package/lib/llm/ModelManagerSchema.d.ts +14 -0
- package/lib/llm/ModelManagerSchema.js +67 -0
- package/lib/llm/ModelManagerSchema.js.map +1 -0
- package/lib/llm/Reasoners.d.ts +190 -0
- package/lib/llm/Reasoners.js +643 -0
- package/lib/llm/Reasoners.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 +2 -0
- package/lib/runtime/declarations.js +21 -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 +35 -0
- package/lib/utils.js +122 -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 +46 -25
- package/umd/template-engine.js +13 -0
- package/umd/template-engine.js.LICENSE.txt +21 -0
- package/dist/index.d.ts +0 -186
- package/dist/index.js +0 -1275
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1248
- package/dist/index.mjs.map +0 -1
- package/dist/worker.js.map +0 -1
|
@@ -0,0 +1,169 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.TypeScriptToJavaScriptCompiler = void 0;
|
|
50
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
51
|
+
const vfs_1 = require("@typescript/vfs");
|
|
52
|
+
const twoslash_1 = require("@typescript/twoslash");
|
|
53
|
+
const TypeScriptCompilationContext_1 = require("./TypeScriptCompilationContext");
|
|
54
|
+
const declarations_1 = require("./runtime/declarations");
|
|
55
|
+
const lzstring = __importStar(require("lz-string"));
|
|
56
|
+
/**
|
|
57
|
+
* Compiles user Typescript code to JavaScript. This uses the '@typescript/twoslash'
|
|
58
|
+
* project which is maintained by the Typescript team and powers their web playground.
|
|
59
|
+
* It uses the TypeScriptCompilationContext class to construct a payload for twoslash
|
|
60
|
+
* that is composed of multiple TS files to compile, along with their 3rd-party module
|
|
61
|
+
* dependencies.
|
|
62
|
+
*
|
|
63
|
+
* Note that the 'typescript' module is either dynamically loaded from node_modules (Node.js)
|
|
64
|
+
* or from the CDN (browser). This module is used by twoslash.
|
|
65
|
+
*
|
|
66
|
+
* The 'updateRuntimeDependencies' script it used to package type declarations for 3rd-party
|
|
67
|
+
* modules that we need to expose to user TS code: dayjs and jsonpath, these also need to be
|
|
68
|
+
* added to the twoslash compilation context.
|
|
69
|
+
*/
|
|
70
|
+
const TYPESCRIPT_URL = process.env.TYPESCRIPT_URL ? process.env.TYPESCRIPT_URL : 'https://cdn.jsdelivr.net/npm/typescript@4.9.4/+esm';
|
|
71
|
+
// https://microsoft.github.io/monaco-editor/typedoc/enums/languages.typescript.ScriptTarget.html#ES2020
|
|
72
|
+
// enum ScriptTarget {
|
|
73
|
+
// /** @deprecated */
|
|
74
|
+
// ES3 = 0,
|
|
75
|
+
// ES5 = 1,
|
|
76
|
+
// ES2015 = 2,
|
|
77
|
+
// ES2016 = 3,
|
|
78
|
+
// ES2017 = 4,
|
|
79
|
+
// ES2018 = 5,
|
|
80
|
+
// ES2019 = 6,
|
|
81
|
+
// ES2020 = 7,
|
|
82
|
+
// ES2021 = 8,
|
|
83
|
+
// ES2022 = 9,
|
|
84
|
+
// ES2023 = 10,
|
|
85
|
+
// ES2024 = 11,
|
|
86
|
+
// ESNext = 99,
|
|
87
|
+
// JSON = 100,
|
|
88
|
+
// Latest = 99,
|
|
89
|
+
// }
|
|
90
|
+
const SCRIPT_TARGET = 9;
|
|
91
|
+
// enum ModuleKind {
|
|
92
|
+
// None = 0,
|
|
93
|
+
// CommonJS = 1,
|
|
94
|
+
// AMD = 2,
|
|
95
|
+
// UMD = 3,
|
|
96
|
+
// System = 4,
|
|
97
|
+
// ES2015 = 5,
|
|
98
|
+
// ES2020 = 6,
|
|
99
|
+
// ES2022 = 7,
|
|
100
|
+
// ESNext = 99,
|
|
101
|
+
// Node16 = 100,
|
|
102
|
+
// Node18 = 101,
|
|
103
|
+
// NodeNext = 199,
|
|
104
|
+
// Preserve = 200,
|
|
105
|
+
// }
|
|
106
|
+
const MODULE_KIND = 6;
|
|
107
|
+
class TypeScriptToJavaScriptCompiler {
|
|
108
|
+
constructor(modelManager, templateConceptFqn) {
|
|
109
|
+
this.context = new TypeScriptCompilationContext_1.TypeScriptCompilationContext(modelManager, templateConceptFqn).getCompilationContext();
|
|
110
|
+
this.typescriptUrl = TYPESCRIPT_URL;
|
|
111
|
+
}
|
|
112
|
+
async initialize(typescriptUrl) {
|
|
113
|
+
if (typescriptUrl) {
|
|
114
|
+
this.typescriptUrl = typescriptUrl;
|
|
115
|
+
}
|
|
116
|
+
if (typeof window === 'undefined') {
|
|
117
|
+
// node does not (yet) support http(s) imports
|
|
118
|
+
// see: https://nodejs.org/api/esm.html#https-and-http-imports
|
|
119
|
+
this.ts = (await Promise.resolve().then(() => __importStar(require('typescript')))).default;
|
|
120
|
+
if (!this.ts) {
|
|
121
|
+
throw new Error('Failed to load typescript module');
|
|
122
|
+
}
|
|
123
|
+
this.fsMap = (0, vfs_1.createDefaultMapFromNodeModules)({
|
|
124
|
+
target: SCRIPT_TARGET,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Use the bundled typescript in the browser rather than a dynamic CDN module
|
|
129
|
+
// import: webpack cannot resolve the runtime CDN URL ('Cannot find module
|
|
130
|
+
// https://...'), and twoslash already pulls typescript into the browser bundle.
|
|
131
|
+
this.ts = (await Promise.resolve().then(() => __importStar(require('typescript')))).default;
|
|
132
|
+
if (!this.ts) {
|
|
133
|
+
throw new Error('Failed to load typescript module');
|
|
134
|
+
}
|
|
135
|
+
// lib.d.ts files are still fetched from the CDN at runtime (a browser fetch).
|
|
136
|
+
this.fsMap = await (0, vfs_1.createDefaultMapFromCDN)({ target: SCRIPT_TARGET }, this.ts.version, false, this.ts);
|
|
137
|
+
}
|
|
138
|
+
this.fsMap.set('/node_modules/@types/dayjs/index.d.ts', Buffer.from(declarations_1.DAYJS_BASE64, 'base64').toString());
|
|
139
|
+
this.fsMap.set('/node_modules/@types/jsonpath/index.d.ts', Buffer.from(declarations_1.JSONPATH_BASE64, 'base64').toString());
|
|
140
|
+
}
|
|
141
|
+
compile(typescript) {
|
|
142
|
+
if (!this.fsMap) {
|
|
143
|
+
throw new Error('initialize must be awaited before compile is called.');
|
|
144
|
+
}
|
|
145
|
+
const twoSlashCode = `
|
|
146
|
+
${this.context}
|
|
147
|
+
${typescript}
|
|
148
|
+
`;
|
|
149
|
+
const options = {
|
|
150
|
+
fsMap: this.fsMap,
|
|
151
|
+
tsModule: this.ts,
|
|
152
|
+
defaultCompilerOptions: {
|
|
153
|
+
target: SCRIPT_TARGET,
|
|
154
|
+
module: MODULE_KIND,
|
|
155
|
+
},
|
|
156
|
+
lzstringModule: lzstring,
|
|
157
|
+
defaultOptions: {
|
|
158
|
+
showEmit: true,
|
|
159
|
+
noErrorValidation: true,
|
|
160
|
+
showEmittedFile: 'code.js'
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
// console.log(twoSlashCode);
|
|
164
|
+
const result = (0, twoslash_1.twoslasher)(twoSlashCode, 'ts', options);
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.TypeScriptToJavaScriptCompiler = TypeScriptToJavaScriptCompiler;
|
|
169
|
+
//# sourceMappingURL=TypeScriptToJavaScriptCompiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeScriptToJavaScriptCompiler.js","sourceRoot":"","sources":["../src/TypeScriptToJavaScriptCompiler.ts"],"names":[],"mappings":"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"}
|
|
@@ -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"}
|