@oino-ts/types 0.11.0 → 0.12.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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Class for formatting strings and values.
3
+ *
4
+ */
5
+ export declare class OINOFormatter {
6
+ static OINO_FORMATTER_REGEXP: RegExp;
7
+ _types: string[];
8
+ _params: any[][];
9
+ /**
10
+ * Constructor of `OINOFormatter`
11
+ * @param types array of formatter types
12
+ * @param params array of formatter parameters according to type
13
+ */
14
+ constructor(types: string[], params: any[][]);
15
+ /**
16
+ * Constructor for `OINOFormatter` as parser of http parameter.
17
+ *
18
+ * @param formatters string or array of strings of serialized representation of formatters with following functions
19
+ * - trim()
20
+ * - trimLeft()
21
+ * - trimRight()
22
+ * - toUpper()
23
+ * - toLower()
24
+ * - cropLeft(charsToCrop)
25
+ * - cropRight(charsToCrop)
26
+ * - cropToDelimiter(delimiter,offsetChars)
27
+ * - cropFromDelimiter(delimiter,offsetChars)
28
+ * - substring(start,end)
29
+ * - replace(search,replace)
30
+ */
31
+ static parse(formatters: string | string[]): OINOFormatter;
32
+ /**
33
+ * Does formatter include any operations.
34
+ * @return true if formatter is empty
35
+ */
36
+ isEmpty(): boolean;
37
+ /**
38
+ * Applies all formatters in order to given value.
39
+ *
40
+ * @param value string value to be formatted
41
+ * @returns formatted string value
42
+ */
43
+ format(value: string): string;
44
+ }
45
+ export declare const OINO_EMPTY_FORMATTER: OINOFormatter;
@@ -3,9 +3,14 @@ import { OINOResult, OINOHttpResult } from ".";
3
3
  * Class for rendering HTML from data.
4
4
  */
5
5
  export declare class OINOHtmlTemplate {
6
- private _tag;
7
- private _tagCleanRegex;
6
+ private _tagOpen;
7
+ private _tagClose;
8
8
  private _variables;
9
+ private _tagStart;
10
+ private _tagEnd;
11
+ private _tagVariable;
12
+ private _tagFormatters;
13
+ private _tagCount;
9
14
  /** HTML template string */
10
15
  template: string;
11
16
  /** Cache modified value for template */
@@ -19,12 +24,13 @@ export declare class OINOHtmlTemplate {
19
24
  * @param tag tag to identify variables in template
20
25
  *
21
26
  */
22
- constructor(template: string, tag?: string);
27
+ constructor(template: string, tagOpen?: string, tagClose?: string);
23
28
  /**
24
29
  * @returns whether template is empty
25
30
  */
26
31
  isEmpty(): boolean;
27
- protected _createHttpResult(html: string, removeUnusedTags: boolean): OINOHttpResult;
32
+ protected _parseTemplate(): void;
33
+ protected _createHttpResult(html: string): OINOHttpResult;
28
34
  protected _renderHtml(): string;
29
35
  /**
30
36
  * Clear template variables.
@@ -51,32 +57,27 @@ export declare class OINOHtmlTemplate {
51
57
  /**
52
58
  * Creates HTML Response from set variables.
53
59
  *
54
- * @param removeUnusedTags whether to remove unused tags
55
- *
56
60
  */
57
- render(removeUnusedTags?: boolean): OINOHttpResult;
61
+ render(): OINOHttpResult;
58
62
  /**
59
63
  * Creates HTML Response from a key-value-pair.
60
64
  *
61
65
  * @param key key
62
66
  * @param value value
63
- * @param removeUnusedTags whether to remove unused tags
64
67
  *
65
68
  */
66
- renderFromKeyValue(key: string, value: string, removeUnusedTags?: boolean): OINOHttpResult;
69
+ renderFromKeyValue(key: string, value: string): OINOHttpResult;
67
70
  /**
68
71
  * Creates HTML Response from object properties.
69
72
  *
70
73
  * @param object object
71
- * @param removeUnusedTags whether to remove unused tags
72
74
  *
73
75
  */
74
- renderFromObject(object: any, removeUnusedTags?: boolean): OINOHttpResult;
76
+ renderFromObject(object?: any): OINOHttpResult;
75
77
  /**
76
78
  * Creates HTML Response from API result.
77
79
  *
78
80
  * @param result OINOResult-object
79
- * @param removeUnusedTags whether to remove unused tags
80
81
  * @param messageSeparator HTML separator for messages
81
82
  * @param includeErrorMessages include debug messages in result
82
83
  * @param includeWarningMessages include debug messages in result
@@ -84,5 +85,5 @@ export declare class OINOHtmlTemplate {
84
85
  * @param includeDebugMessages include debug messages in result
85
86
  *
86
87
  */
87
- renderFromResult(result: OINOResult, removeUnusedTags?: boolean, messageSeparator?: string, includeErrorMessages?: boolean, includeWarningMessages?: boolean, includeInfoMessages?: boolean, includeDebugMessages?: boolean): OINOHttpResult;
88
+ renderFromResult(result: OINOResult, messageSeparator?: string, includeErrorMessages?: boolean, includeWarningMessages?: boolean, includeInfoMessages?: boolean, includeDebugMessages?: boolean): OINOHttpResult;
88
89
  }
@@ -3,6 +3,7 @@ export { OINOLog, OINOLogLevel, OINOConsoleLog } from "./OINOLog.js";
3
3
  export { OINOResult, OINOHttpResult } from "./OINOResult.js";
4
4
  export { OINOStr } from "./OINOStr.js";
5
5
  export { OINOHtmlTemplate } from "./OINOHtmlTemplate.js";
6
+ export { OINOFormatter, OINO_EMPTY_FORMATTER } from "./OINOFormatter.js";
6
7
  /** OINO error message prefix */
7
8
  export declare const OINO_ERROR_PREFIX = "OINO ERROR";
8
9
  /** OINO warning message prefix */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/types",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "OINO TS package for types.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",