@myrmidon/cadmus-profile-core 11.0.0 → 12.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 +3 -59
- package/fesm2022/myrmidon-cadmus-profile-core.mjs +6 -6
- package/index.d.ts +138 -3
- package/package.json +3 -3
- package/lib/profile-models.d.ts +0 -8
- package/lib/services/csv-reader.d.ts +0 -44
- package/lib/services/csv-thesaurus-reader.d.ts +0 -27
- package/lib/services/profile-util.service.d.ts +0 -38
- package/lib/services/text-to-file.service.d.ts +0 -17
- package/public-api.d.ts +0 -5
package/README.md
CHANGED
|
@@ -1,63 +1,7 @@
|
|
|
1
1
|
# CadmusProfileCore
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
ng generate component component-name
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
ng generate --help
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Building
|
|
20
|
-
|
|
21
|
-
To build the library, run:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
ng build cadmus-profile-core
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
-
|
|
29
|
-
### Publishing the Library
|
|
3
|
+
- 📦 `@myrmidon/cadmus-profile-core`
|
|
30
4
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
1. Navigate to the `dist` directory:
|
|
34
|
-
```bash
|
|
35
|
-
cd dist/cadmus-profile-core
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
39
|
-
```bash
|
|
40
|
-
npm publish
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Running unit tests
|
|
44
|
-
|
|
45
|
-
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
ng test
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Running end-to-end tests
|
|
52
|
-
|
|
53
|
-
For end-to-end (e2e) testing, run:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
ng e2e
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
60
|
-
|
|
61
|
-
## Additional Resources
|
|
5
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.0.
|
|
62
6
|
|
|
63
|
-
|
|
7
|
+
This library contains services and models for managing Cadmus profiles (mostly thesauri).
|
|
@@ -309,10 +309,10 @@ class ProfileUtilService {
|
|
|
309
309
|
}
|
|
310
310
|
return groups;
|
|
311
311
|
}
|
|
312
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
313
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
312
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: ProfileUtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
313
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: ProfileUtilService, providedIn: 'root' });
|
|
314
314
|
}
|
|
315
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
315
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: ProfileUtilService, decorators: [{
|
|
316
316
|
type: Injectable,
|
|
317
317
|
args: [{
|
|
318
318
|
providedIn: 'root',
|
|
@@ -340,10 +340,10 @@ class TextToFileService {
|
|
|
340
340
|
a.click();
|
|
341
341
|
URL.revokeObjectURL(a.href);
|
|
342
342
|
}
|
|
343
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
344
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
343
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: TextToFileService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
344
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: TextToFileService, providedIn: 'root' });
|
|
345
345
|
}
|
|
346
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
346
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: TextToFileService, decorators: [{
|
|
347
347
|
type: Injectable,
|
|
348
348
|
args: [{
|
|
349
349
|
providedIn: 'root',
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,140 @@
|
|
|
1
|
+
import { Thesaurus } from '@myrmidon/cadmus-core';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* Options for CsvReader.
|
|
3
6
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
interface CsvReaderOptions {
|
|
8
|
+
fieldSeparator?: string;
|
|
9
|
+
lineSeparator?: string;
|
|
10
|
+
quote?: string;
|
|
11
|
+
trimming?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CSV text reader.
|
|
15
|
+
* Refactored from https://github.com/gregoranders/ts-csv/blob/master/src/index.ts.
|
|
16
|
+
*/
|
|
17
|
+
declare class CsvReader {
|
|
18
|
+
private readonly _text;
|
|
19
|
+
private _lastRow;
|
|
20
|
+
private _row;
|
|
21
|
+
private _cell;
|
|
22
|
+
private _options;
|
|
23
|
+
private _state;
|
|
24
|
+
private _index;
|
|
25
|
+
private _current;
|
|
26
|
+
private _previous;
|
|
27
|
+
constructor(text: string, options?: CsvReaderOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Read the next row from the CSV text.
|
|
30
|
+
*
|
|
31
|
+
* @param text - CSV text
|
|
32
|
+
* @returns array of fields, each being an array of strings.
|
|
33
|
+
* @throws Error on parse error
|
|
34
|
+
*/
|
|
35
|
+
read(): readonly string[] | null;
|
|
36
|
+
private handleNext;
|
|
37
|
+
private handleQuote;
|
|
38
|
+
private handleQuoteEscaped;
|
|
39
|
+
private handleQuoteNotEscaped;
|
|
40
|
+
private handleFieldSeparator;
|
|
41
|
+
private handleLineSeparator;
|
|
42
|
+
private processState;
|
|
43
|
+
private fieldValue;
|
|
44
|
+
private addField;
|
|
45
|
+
private nextRow;
|
|
46
|
+
private reset;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* CSV thesaurus reader. This reads any number of thesauri from a CSV text.
|
|
51
|
+
* By convention, the CSV has column 1=ID and column 2=value for each
|
|
52
|
+
* thesaurus entry. Each thesaurus is started by a row having in the ID
|
|
53
|
+
* the thesaurus ID and an empty value.
|
|
54
|
+
* If a thesaurus ID is just an alias, the value starts with an equal sign
|
|
55
|
+
* (e.g. "biblio-languages,=languages") and has no other entries.
|
|
56
|
+
*/
|
|
57
|
+
declare class CsvThesaurusReader {
|
|
58
|
+
private readonly _csvReader;
|
|
59
|
+
private _id?;
|
|
60
|
+
private _targetId?;
|
|
61
|
+
private _entries;
|
|
62
|
+
private _eof;
|
|
63
|
+
constructor(text: string, options?: CsvReaderOptions);
|
|
64
|
+
private parseLanguage;
|
|
65
|
+
private getThesaurus;
|
|
66
|
+
private reset;
|
|
67
|
+
/**
|
|
68
|
+
* Read the next thesaurus if any.
|
|
69
|
+
*
|
|
70
|
+
* @returns Thesaurus or null if end of CSV text reached.
|
|
71
|
+
*/
|
|
72
|
+
read(): Thesaurus | null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A generic group of items under a group key.
|
|
77
|
+
*/
|
|
78
|
+
interface KeyedGroup<T> {
|
|
79
|
+
key: string;
|
|
80
|
+
items: T[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Utility functions for Cadmus profile data.
|
|
84
|
+
*/
|
|
85
|
+
declare class ProfileUtilService {
|
|
86
|
+
constructor();
|
|
87
|
+
/**
|
|
88
|
+
* Group an array of objects by 1 or more of its string properties.
|
|
89
|
+
*
|
|
90
|
+
* @param arr The array of objects to group.
|
|
91
|
+
* @param keys The keys to be used in grouping objects. It is assumed
|
|
92
|
+
* that such keys are all string properties.
|
|
93
|
+
* @returns An object where each property is a key with value equal
|
|
94
|
+
* to an array of items.
|
|
95
|
+
*/
|
|
96
|
+
groupIntoObject<T>(arr: T[], keys: (keyof T)[]): {
|
|
97
|
+
[key: string]: T[];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Group an array of objects by 1 or more of its string properties,
|
|
101
|
+
* storing the result into an array of KeyedGroup<T>.
|
|
102
|
+
*
|
|
103
|
+
* @param arr The array of objects to group.
|
|
104
|
+
* @param keys The keys to be used in grouping objects. It is assumed
|
|
105
|
+
* that such keys are all string properties.
|
|
106
|
+
* @returns An array of KeyedGroup<T>.
|
|
107
|
+
*/
|
|
108
|
+
groupIntoKeyedGroups<T>(arr: T[], keys: (keyof T)[]): KeyedGroup<T>[];
|
|
109
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileUtilService, never>;
|
|
110
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ProfileUtilService>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Service to let user download a text file generated into a string.
|
|
115
|
+
*/
|
|
116
|
+
declare class TextToFileService {
|
|
117
|
+
constructor();
|
|
118
|
+
/**
|
|
119
|
+
* Save the specified text into a file.
|
|
120
|
+
*
|
|
121
|
+
* @param text The text content to be saved.
|
|
122
|
+
* @param name The file name.
|
|
123
|
+
* @param contentType The content type.
|
|
124
|
+
*/
|
|
125
|
+
saveToFile(text: string, name: string, contentType?: string): void;
|
|
126
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TextToFileService, never>;
|
|
127
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TextToFileService>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A generic signal used by child components to emit
|
|
132
|
+
* events signaling some action to be taken.
|
|
133
|
+
*/
|
|
134
|
+
interface ComponentSignal<T> {
|
|
135
|
+
id: string;
|
|
136
|
+
payload?: T;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { CsvReader, CsvThesaurusReader, ProfileUtilService, TextToFileService };
|
|
140
|
+
export type { ComponentSignal, CsvReaderOptions, KeyedGroup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrmidon/cadmus-profile-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Cadmus - profile services.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Cadmus"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"name": "Daniele Fusi"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@angular/common": "^
|
|
18
|
-
"@angular/core": "^
|
|
17
|
+
"@angular/common": "^20.0.0",
|
|
18
|
+
"@angular/core": "^20.0.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"tslib": "^2.3.0"
|
package/lib/profile-models.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for CsvReader.
|
|
3
|
-
*/
|
|
4
|
-
export interface CsvReaderOptions {
|
|
5
|
-
fieldSeparator?: string;
|
|
6
|
-
lineSeparator?: string;
|
|
7
|
-
quote?: string;
|
|
8
|
-
trimming?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* CSV text reader.
|
|
12
|
-
* Refactored from https://github.com/gregoranders/ts-csv/blob/master/src/index.ts.
|
|
13
|
-
*/
|
|
14
|
-
export declare class CsvReader {
|
|
15
|
-
private readonly _text;
|
|
16
|
-
private _lastRow;
|
|
17
|
-
private _row;
|
|
18
|
-
private _cell;
|
|
19
|
-
private _options;
|
|
20
|
-
private _state;
|
|
21
|
-
private _index;
|
|
22
|
-
private _current;
|
|
23
|
-
private _previous;
|
|
24
|
-
constructor(text: string, options?: CsvReaderOptions);
|
|
25
|
-
/**
|
|
26
|
-
* Read the next row from the CSV text.
|
|
27
|
-
*
|
|
28
|
-
* @param text - CSV text
|
|
29
|
-
* @returns array of fields, each being an array of strings.
|
|
30
|
-
* @throws Error on parse error
|
|
31
|
-
*/
|
|
32
|
-
read(): readonly string[] | null;
|
|
33
|
-
private handleNext;
|
|
34
|
-
private handleQuote;
|
|
35
|
-
private handleQuoteEscaped;
|
|
36
|
-
private handleQuoteNotEscaped;
|
|
37
|
-
private handleFieldSeparator;
|
|
38
|
-
private handleLineSeparator;
|
|
39
|
-
private processState;
|
|
40
|
-
private fieldValue;
|
|
41
|
-
private addField;
|
|
42
|
-
private nextRow;
|
|
43
|
-
private reset;
|
|
44
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Thesaurus } from '@myrmidon/cadmus-core';
|
|
2
|
-
import { CsvReaderOptions } from './csv-reader';
|
|
3
|
-
/**
|
|
4
|
-
* CSV thesaurus reader. This reads any number of thesauri from a CSV text.
|
|
5
|
-
* By convention, the CSV has column 1=ID and column 2=value for each
|
|
6
|
-
* thesaurus entry. Each thesaurus is started by a row having in the ID
|
|
7
|
-
* the thesaurus ID and an empty value.
|
|
8
|
-
* If a thesaurus ID is just an alias, the value starts with an equal sign
|
|
9
|
-
* (e.g. "biblio-languages,=languages") and has no other entries.
|
|
10
|
-
*/
|
|
11
|
-
export declare class CsvThesaurusReader {
|
|
12
|
-
private readonly _csvReader;
|
|
13
|
-
private _id?;
|
|
14
|
-
private _targetId?;
|
|
15
|
-
private _entries;
|
|
16
|
-
private _eof;
|
|
17
|
-
constructor(text: string, options?: CsvReaderOptions);
|
|
18
|
-
private parseLanguage;
|
|
19
|
-
private getThesaurus;
|
|
20
|
-
private reset;
|
|
21
|
-
/**
|
|
22
|
-
* Read the next thesaurus if any.
|
|
23
|
-
*
|
|
24
|
-
* @returns Thesaurus or null if end of CSV text reached.
|
|
25
|
-
*/
|
|
26
|
-
read(): Thesaurus | null;
|
|
27
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
/**
|
|
3
|
-
* A generic group of items under a group key.
|
|
4
|
-
*/
|
|
5
|
-
export interface KeyedGroup<T> {
|
|
6
|
-
key: string;
|
|
7
|
-
items: T[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Utility functions for Cadmus profile data.
|
|
11
|
-
*/
|
|
12
|
-
export declare class ProfileUtilService {
|
|
13
|
-
constructor();
|
|
14
|
-
/**
|
|
15
|
-
* Group an array of objects by 1 or more of its string properties.
|
|
16
|
-
*
|
|
17
|
-
* @param arr The array of objects to group.
|
|
18
|
-
* @param keys The keys to be used in grouping objects. It is assumed
|
|
19
|
-
* that such keys are all string properties.
|
|
20
|
-
* @returns An object where each property is a key with value equal
|
|
21
|
-
* to an array of items.
|
|
22
|
-
*/
|
|
23
|
-
groupIntoObject<T>(arr: T[], keys: (keyof T)[]): {
|
|
24
|
-
[key: string]: T[];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Group an array of objects by 1 or more of its string properties,
|
|
28
|
-
* storing the result into an array of KeyedGroup<T>.
|
|
29
|
-
*
|
|
30
|
-
* @param arr The array of objects to group.
|
|
31
|
-
* @param keys The keys to be used in grouping objects. It is assumed
|
|
32
|
-
* that such keys are all string properties.
|
|
33
|
-
* @returns An array of KeyedGroup<T>.
|
|
34
|
-
*/
|
|
35
|
-
groupIntoKeyedGroups<T>(arr: T[], keys: (keyof T)[]): KeyedGroup<T>[];
|
|
36
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileUtilService, never>;
|
|
37
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ProfileUtilService>;
|
|
38
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
/**
|
|
3
|
-
* Service to let user download a text file generated into a string.
|
|
4
|
-
*/
|
|
5
|
-
export declare class TextToFileService {
|
|
6
|
-
constructor();
|
|
7
|
-
/**
|
|
8
|
-
* Save the specified text into a file.
|
|
9
|
-
*
|
|
10
|
-
* @param text The text content to be saved.
|
|
11
|
-
* @param name The file name.
|
|
12
|
-
* @param contentType The content type.
|
|
13
|
-
*/
|
|
14
|
-
saveToFile(text: string, name: string, contentType?: string): void;
|
|
15
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<TextToFileService, never>;
|
|
16
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<TextToFileService>;
|
|
17
|
-
}
|
package/public-api.d.ts
DELETED