@sap-ux/odata-entity-model 0.1.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/LICENSE +201 -0
- package/README.md +50 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata-service.d.ts +120 -0
- package/dist/metadata-service.d.ts.map +1 -0
- package/dist/metadata-service.js +313 -0
- package/dist/metadata-service.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# OData Entity Model
|
|
2
|
+
|
|
3
|
+
Package containing metadata service, which allows to look up elements from entity data model of an OData service.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
Npm
|
|
7
|
+
`npm install --save @sap-ux/odata-entity-model`
|
|
8
|
+
|
|
9
|
+
Yarn
|
|
10
|
+
`yarn add @sap-ux/odata-entity-model`
|
|
11
|
+
|
|
12
|
+
Pnpm
|
|
13
|
+
`pnpm add @sap-ux/odata-entity-model`
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
1. Import the needed functions in your modules
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { MetadataService } from '@sap-ux/odata-entity-model';
|
|
21
|
+
const metadataFileUri = 'testFileUri';
|
|
22
|
+
const metadataElements: MetadataElement[] = [
|
|
23
|
+
{
|
|
24
|
+
isAnnotatable: true,
|
|
25
|
+
kind: 'EntityType',
|
|
26
|
+
name: 'com.sap.gateway.default.iwbep.tea_busi.v0001.Department',
|
|
27
|
+
path: 'com.sap.gateway.default.iwbep.tea_busi.v0001.Department',
|
|
28
|
+
isCollectionValued: false,
|
|
29
|
+
isComplexType: false,
|
|
30
|
+
isEntityType: true,
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
content: [],
|
|
34
|
+
isAnnotatable: true,
|
|
35
|
+
kind: 'Property',
|
|
36
|
+
name: 'Sector',
|
|
37
|
+
path: 'com.sap.gateway.default.iwbep.tea_busi.v0001.Department/Sector',
|
|
38
|
+
isCollectionValued: false,
|
|
39
|
+
isComplexType: false,
|
|
40
|
+
isEntityType: false,
|
|
41
|
+
edmPrimitiveType: 'Edm.String'
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}];
|
|
45
|
+
const metadata = new MetadataService({ ODataVersion: '4.0' });
|
|
46
|
+
metadata.import(metadataElements, metadataFileUri);
|
|
47
|
+
const pathBase = metadata.getMetadataElement('com.sap.gateway.default.iwbep.tea_busi.v0001.Department');
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For usage examples see unit tests in `odata-entity-model/test`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./metadata-service"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { TargetKind, Location, MetadataElement, Path, ODataVersionType, MetadataServiceOptions, MetadataElementVisitor, IMetadataService } from '@sap-ux/odata-annotation-core-types';
|
|
2
|
+
/**
|
|
3
|
+
* Metadata service
|
|
4
|
+
*/
|
|
5
|
+
export declare class MetadataService implements IMetadataService {
|
|
6
|
+
/**
|
|
7
|
+
* Keeps all metadata based on file level (for invalidation when file changes)
|
|
8
|
+
*/
|
|
9
|
+
private metadata;
|
|
10
|
+
/**
|
|
11
|
+
* Keeps all namespaces based on file level (for invalidation when file changes)
|
|
12
|
+
*/
|
|
13
|
+
private namespaces;
|
|
14
|
+
/**
|
|
15
|
+
* Mapping of action names to set of overloads on file level (for invalidation when file changes)
|
|
16
|
+
*/
|
|
17
|
+
private actionNames;
|
|
18
|
+
/**
|
|
19
|
+
* Map of relative to absolute uri
|
|
20
|
+
*/
|
|
21
|
+
private uriMap;
|
|
22
|
+
/**
|
|
23
|
+
* Lookup metadata element by its path.
|
|
24
|
+
*
|
|
25
|
+
* @param path - need to exactly match path of metadata element (i.e. function/action segment needs to contain ())
|
|
26
|
+
* @returns Metadata element if it exists for the given path.
|
|
27
|
+
*/
|
|
28
|
+
private lookup;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param path element path
|
|
32
|
+
* @returns element location
|
|
33
|
+
*/
|
|
34
|
+
private getMetadataElementLocationsInternal;
|
|
35
|
+
/**
|
|
36
|
+
* OData Version
|
|
37
|
+
* '2.0': OData 2.0
|
|
38
|
+
* '4.0': OData 4.0
|
|
39
|
+
* '': not specified (e.g. for metadata generated from CDS sources)
|
|
40
|
+
*/
|
|
41
|
+
readonly ODataVersion: ODataVersionType | '';
|
|
42
|
+
/**
|
|
43
|
+
* isCds
|
|
44
|
+
* true: metadata are generated based on CDS sources
|
|
45
|
+
*/
|
|
46
|
+
readonly isCds: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Metadata file URI.
|
|
49
|
+
*/
|
|
50
|
+
fileUri: string;
|
|
51
|
+
/**
|
|
52
|
+
* Create new metadata service instance.
|
|
53
|
+
*
|
|
54
|
+
* @param options metadata service instance option
|
|
55
|
+
*/
|
|
56
|
+
constructor(options?: MetadataServiceOptions);
|
|
57
|
+
/**
|
|
58
|
+
* Set map of uris from relative to absolute.
|
|
59
|
+
*
|
|
60
|
+
* @param uriMap A map where keys are relative URIs and values are their corresponding absolute URIs.
|
|
61
|
+
*/
|
|
62
|
+
setUriMap(uriMap: Map<string, string>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Import metadata.
|
|
65
|
+
*
|
|
66
|
+
* @param rootNodes Metadata elements.
|
|
67
|
+
* @param fileUri Metadata file URI.
|
|
68
|
+
*
|
|
69
|
+
* The metadata is cached and invalidated (on file change) based on file level
|
|
70
|
+
*/
|
|
71
|
+
import(rootNodes: MetadataElement[], fileUri: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* Traverses all metadata elements and calls the specified visitor function for each element.
|
|
74
|
+
*
|
|
75
|
+
* @param {MetadataElementVisitor} visitElement - A function that will be called for each metadata element during traversal.
|
|
76
|
+
* The function should accept a single argument, which is the metadata element being visited.
|
|
77
|
+
*/
|
|
78
|
+
visitMetadataElements(visitElement: MetadataElementVisitor): void;
|
|
79
|
+
/**
|
|
80
|
+
* Returns namespaces representing metadata.
|
|
81
|
+
*
|
|
82
|
+
* @returns set of namespaces
|
|
83
|
+
*/
|
|
84
|
+
getNamespaces(): Set<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Returns all metadata root elements.
|
|
87
|
+
*
|
|
88
|
+
* @returns a map containing metadata root elements, where the keys are the paths and the values are the corresponding metadata elements.
|
|
89
|
+
*/
|
|
90
|
+
getRootMetadataElements(): Map<Path, MetadataElement>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a specific metadata element specified by its path.
|
|
93
|
+
*
|
|
94
|
+
* @param path Path identifying the metadata element (conforming to EDMX, i.e. function/action segments can also be without ())
|
|
95
|
+
* @returns Metadata element
|
|
96
|
+
*/
|
|
97
|
+
getMetadataElement(path: Path): MetadataElement | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Get Action or Function overloads by their top level name.
|
|
100
|
+
*
|
|
101
|
+
* @param topLevelName First segment represents action function name.
|
|
102
|
+
* @returns if first segment represents action function name (without signature).
|
|
103
|
+
*/
|
|
104
|
+
private getActionFunctionOverloads;
|
|
105
|
+
/**
|
|
106
|
+
* Get OData target kinds for a metadata element.
|
|
107
|
+
*
|
|
108
|
+
* @param path Path identifying metadata element.
|
|
109
|
+
* @returns OData target kinds.
|
|
110
|
+
*/
|
|
111
|
+
getEdmTargetKinds(path: Path): TargetKind[];
|
|
112
|
+
/**
|
|
113
|
+
* Get (LSP) Locations of metadata element.
|
|
114
|
+
*
|
|
115
|
+
* @param path - path identifying metadata element
|
|
116
|
+
* @returns Locations for the metadata element
|
|
117
|
+
*/
|
|
118
|
+
getMetadataElementLocations(path: string): Location[];
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=metadata-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-service.d.ts","sourceRoot":"","sources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IACH,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE;IA0B3C;;;;;OAKG;IACH,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE;CAkBxD"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetadataService = void 0;
|
|
4
|
+
// OData conform target kinds for CDS kinds
|
|
5
|
+
const targetKindsCds = {
|
|
6
|
+
service: ["EntityContainer" /* Edm.EntityContainer */],
|
|
7
|
+
entitySet: ["EntitySet" /* Edm.EntitySet */],
|
|
8
|
+
entity: ["EntityType" /* Edm.EntityType */, "EntitySet" /* Edm.EntitySet */],
|
|
9
|
+
view: ["EntityType" /* Edm.EntityType */, "EntitySet" /* Edm.EntitySet */],
|
|
10
|
+
aspect: ["ComplexType" /* Edm.ComplexType */, "EntityType" /* Edm.EntityType */, "EntitySet" /* Edm.EntitySet */],
|
|
11
|
+
element: ["Property" /* Edm.Property */],
|
|
12
|
+
action: ["Action" /* Edm.Action */, "ActionImport" /* Edm.ActionImport */],
|
|
13
|
+
function: ["Function" /* Edm.Function */, "FunctionImport" /* Edm.FunctionImport */],
|
|
14
|
+
actionImport: ["Action" /* Edm.Action */],
|
|
15
|
+
functionImport: ["FunctionImport" /* Edm.FunctionImport */],
|
|
16
|
+
param: ["Parameter" /* Edm.Parameter */],
|
|
17
|
+
type: ["TypeDefinition" /* Edm.TypeDefinition */, "Property" /* Edm.Property */, "Parameter" /* Edm.Parameter */]
|
|
18
|
+
};
|
|
19
|
+
const targetKindsMapCds = new Map(Object.entries(targetKindsCds));
|
|
20
|
+
/**
|
|
21
|
+
* Extracts action/function name by removing the part enclosed in parentheses.
|
|
22
|
+
*
|
|
23
|
+
* @param name action/function name
|
|
24
|
+
* @returns extracted name
|
|
25
|
+
*/
|
|
26
|
+
function getActionName(name) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const partsOpen = name.split('(');
|
|
29
|
+
const partsClose = name.split(')');
|
|
30
|
+
return partsOpen.length > 1 && partsClose.length > 1 ? ((_a = partsOpen.shift()) !== null && _a !== void 0 ? _a : '') + ((_b = partsClose.pop()) !== null && _b !== void 0 ? _b : '') : name;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builds a lookup for metadata elements based on provided data.
|
|
34
|
+
*
|
|
35
|
+
* @param metadata - The map to store metadata elements, keyed by their paths.
|
|
36
|
+
* @param actionNames - The map to store action names and associated overload paths.
|
|
37
|
+
* @param namespaces - The set to store unique namespaces encountered during the process.
|
|
38
|
+
* @param metadataElements - The array of metadata elements to process and build the lookup.
|
|
39
|
+
*/
|
|
40
|
+
function buildMetadataElementLookup(metadata, actionNames, namespaces, metadataElements) {
|
|
41
|
+
for (const node of metadataElements) {
|
|
42
|
+
const namespace = getNamespace(node.path);
|
|
43
|
+
if (namespace) {
|
|
44
|
+
namespaces.add(namespace);
|
|
45
|
+
}
|
|
46
|
+
if (node.name.includes('(')) {
|
|
47
|
+
const actionName = getActionName(node.name);
|
|
48
|
+
let overloadPaths = actionNames.get(actionName);
|
|
49
|
+
if (!overloadPaths) {
|
|
50
|
+
overloadPaths = new Set();
|
|
51
|
+
actionNames.set(actionName, overloadPaths);
|
|
52
|
+
}
|
|
53
|
+
overloadPaths.add(node.name);
|
|
54
|
+
}
|
|
55
|
+
metadata.set(node.path, node);
|
|
56
|
+
if (node.content) {
|
|
57
|
+
buildMetadataElementLookup(metadata, actionNames, namespaces, node.content);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the namespace of an element identified by its path.
|
|
63
|
+
*
|
|
64
|
+
* @param path - Path of an element
|
|
65
|
+
* @returns - Namespace
|
|
66
|
+
*/
|
|
67
|
+
function getNamespace(path) {
|
|
68
|
+
let namespace = '';
|
|
69
|
+
const segments = path.split('/');
|
|
70
|
+
const firstSegment = segments[0] === '' ? segments[1] : segments[0];
|
|
71
|
+
if (firstSegment) {
|
|
72
|
+
// segment name for overloads can be <fqFunctionName>(<fqNamePar1>, <fqNamePar2>)
|
|
73
|
+
// each fqName can contain dots
|
|
74
|
+
const beforeFirstBracket = firstSegment.split('(')[0];
|
|
75
|
+
const parts = beforeFirstBracket.split('.');
|
|
76
|
+
parts.pop();
|
|
77
|
+
namespace = parts.join('.');
|
|
78
|
+
}
|
|
79
|
+
return namespace;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Metadata service
|
|
83
|
+
*/
|
|
84
|
+
class MetadataService {
|
|
85
|
+
/**
|
|
86
|
+
* Lookup metadata element by its path.
|
|
87
|
+
*
|
|
88
|
+
* @param path - need to exactly match path of metadata element (i.e. function/action segment needs to contain ())
|
|
89
|
+
* @returns Metadata element if it exists for the given path.
|
|
90
|
+
*/
|
|
91
|
+
lookup(path) {
|
|
92
|
+
return this.metadata.get(path);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param path element path
|
|
97
|
+
* @returns element location
|
|
98
|
+
*/
|
|
99
|
+
getMetadataElementLocationsInternal(path) {
|
|
100
|
+
const locations = [];
|
|
101
|
+
const elements = [];
|
|
102
|
+
const mdElement = this.lookup(path);
|
|
103
|
+
if (mdElement) {
|
|
104
|
+
elements.push(mdElement);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// action/function name? find all action/function overloads
|
|
108
|
+
const overloadPaths = this.actionNames.get(path);
|
|
109
|
+
if (overloadPaths) {
|
|
110
|
+
for (const overloadPath of overloadPaths) {
|
|
111
|
+
const overloadElement = this.getMetadataElement(overloadPath);
|
|
112
|
+
if (overloadElement) {
|
|
113
|
+
elements.push(overloadElement);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// build locations
|
|
119
|
+
for (const element of elements) {
|
|
120
|
+
if (element.location) {
|
|
121
|
+
locations.push(element.location);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return locations;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Create new metadata service instance.
|
|
128
|
+
*
|
|
129
|
+
* @param options metadata service instance option
|
|
130
|
+
*/
|
|
131
|
+
constructor(options) {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
/**
|
|
134
|
+
* Keeps all metadata based on file level (for invalidation when file changes)
|
|
135
|
+
*/
|
|
136
|
+
this.metadata = new Map();
|
|
137
|
+
/**
|
|
138
|
+
* Keeps all namespaces based on file level (for invalidation when file changes)
|
|
139
|
+
*/
|
|
140
|
+
this.namespaces = new Set();
|
|
141
|
+
/**
|
|
142
|
+
* Mapping of action names to set of overloads on file level (for invalidation when file changes)
|
|
143
|
+
*/
|
|
144
|
+
this.actionNames = new Map();
|
|
145
|
+
/**
|
|
146
|
+
* Metadata file URI.
|
|
147
|
+
*/
|
|
148
|
+
this.fileUri = '';
|
|
149
|
+
this.ODataVersion = (_a = options === null || options === void 0 ? void 0 : options.ODataVersion) !== null && _a !== void 0 ? _a : '';
|
|
150
|
+
this.isCds = (options === null || options === void 0 ? void 0 : options.isCds) !== undefined ? options.isCds : this.ODataVersion === '';
|
|
151
|
+
this.uriMap = (_b = options === null || options === void 0 ? void 0 : options.uriMap) !== null && _b !== void 0 ? _b : new Map();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Set map of uris from relative to absolute.
|
|
155
|
+
*
|
|
156
|
+
* @param uriMap A map where keys are relative URIs and values are their corresponding absolute URIs.
|
|
157
|
+
*/
|
|
158
|
+
setUriMap(uriMap) {
|
|
159
|
+
this.uriMap = uriMap;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Import metadata.
|
|
163
|
+
*
|
|
164
|
+
* @param rootNodes Metadata elements.
|
|
165
|
+
* @param fileUri Metadata file URI.
|
|
166
|
+
*
|
|
167
|
+
* The metadata is cached and invalidated (on file change) based on file level
|
|
168
|
+
*/
|
|
169
|
+
import(rootNodes, fileUri) {
|
|
170
|
+
// build map of all metadata elements contained in file
|
|
171
|
+
const metadataMap = new Map();
|
|
172
|
+
const actionNameMap = new Map();
|
|
173
|
+
const namespaceSet = new Set();
|
|
174
|
+
buildMetadataElementLookup(metadataMap, actionNameMap, namespaceSet, rootNodes);
|
|
175
|
+
this.fileUri = fileUri;
|
|
176
|
+
this.namespaces = namespaceSet;
|
|
177
|
+
this.actionNames = actionNameMap;
|
|
178
|
+
this.metadata = metadataMap;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Traverses all metadata elements and calls the specified visitor function for each element.
|
|
182
|
+
*
|
|
183
|
+
* @param {MetadataElementVisitor} visitElement - A function that will be called for each metadata element during traversal.
|
|
184
|
+
* The function should accept a single argument, which is the metadata element being visited.
|
|
185
|
+
*/
|
|
186
|
+
visitMetadataElements(visitElement) {
|
|
187
|
+
for (const [, element] of this.metadata.entries()) {
|
|
188
|
+
visitElement(element);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns namespaces representing metadata.
|
|
193
|
+
*
|
|
194
|
+
* @returns set of namespaces
|
|
195
|
+
*/
|
|
196
|
+
getNamespaces() {
|
|
197
|
+
return new Set([...this.namespaces]);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Returns all metadata root elements.
|
|
201
|
+
*
|
|
202
|
+
* @returns a map containing metadata root elements, where the keys are the paths and the values are the corresponding metadata elements.
|
|
203
|
+
*/
|
|
204
|
+
getRootMetadataElements() {
|
|
205
|
+
const map = new Map();
|
|
206
|
+
for (const metadataElement of this.metadata.values()) {
|
|
207
|
+
if (metadataElement.path.indexOf('/') < 0) {
|
|
208
|
+
map.set(metadataElement.path, metadataElement);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return map;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Returns a specific metadata element specified by its path.
|
|
215
|
+
*
|
|
216
|
+
* @param path Path identifying the metadata element (conforming to EDMX, i.e. function/action segments can also be without ())
|
|
217
|
+
* @returns Metadata element
|
|
218
|
+
*/
|
|
219
|
+
getMetadataElement(path) {
|
|
220
|
+
const element = this.lookup(path);
|
|
221
|
+
if (element) {
|
|
222
|
+
return element;
|
|
223
|
+
}
|
|
224
|
+
// check if first segment represents action function name (without signature)
|
|
225
|
+
const segments = path.split('/');
|
|
226
|
+
const topLevelName = segments.shift();
|
|
227
|
+
if (!topLevelName) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
const actionFunctionOverloads = this.getActionFunctionOverloads(topLevelName);
|
|
231
|
+
if (actionFunctionOverloads) {
|
|
232
|
+
const remainingSegments = segments.join('/');
|
|
233
|
+
for (const overloadName of actionFunctionOverloads) {
|
|
234
|
+
const newPath = overloadName + (remainingSegments ? '/' + remainingSegments : '');
|
|
235
|
+
const element = this.lookup(newPath);
|
|
236
|
+
if (element) {
|
|
237
|
+
return element;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get Action or Function overloads by their top level name.
|
|
245
|
+
*
|
|
246
|
+
* @param topLevelName First segment represents action function name.
|
|
247
|
+
* @returns if first segment represents action function name (without signature).
|
|
248
|
+
*/
|
|
249
|
+
getActionFunctionOverloads(topLevelName) {
|
|
250
|
+
return this.actionNames.get(topLevelName);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get OData target kinds for a metadata element.
|
|
254
|
+
*
|
|
255
|
+
* @param path Path identifying metadata element.
|
|
256
|
+
* @returns OData target kinds.
|
|
257
|
+
*/
|
|
258
|
+
getEdmTargetKinds(path) {
|
|
259
|
+
var _a;
|
|
260
|
+
const element = this.getMetadataElement(path);
|
|
261
|
+
if (!element) {
|
|
262
|
+
return [];
|
|
263
|
+
}
|
|
264
|
+
const targetKinds = [];
|
|
265
|
+
if (this.isCds) {
|
|
266
|
+
targetKinds.push(...((_a = targetKindsMapCds.get(element.kind)) !== null && _a !== void 0 ? _a : []));
|
|
267
|
+
if (element.kind === 'element' && element.structuredType && element.isEntityType) {
|
|
268
|
+
// CDS elements pointing to an entity type can be annotated like a EDMX navigation property
|
|
269
|
+
targetKinds.unshift("NavigationProperty" /* Edm.NavigationProperty */);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
targetKinds.push(element.kind);
|
|
274
|
+
if (element.kind === "FunctionImport" /* Edm.FunctionImport */ && this.ODataVersion !== '4.0') {
|
|
275
|
+
// vocabulary and annotation files are defined based on OData v4, but are used to annotate both OData v2 and OData v4 metadata.
|
|
276
|
+
// OData v2 does not have 'Action' but only 'FunctionImport'. Map to 'Action' to support annotating 'FunctionImport' with terms targeting actions.
|
|
277
|
+
targetKinds.push("Action" /* Edm.Action */);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (targetKinds.includes("EntitySet" /* Edm.EntitySet */) || element.isCollectionValued) {
|
|
281
|
+
targetKinds.push("Collection" /* Edm.Collection */);
|
|
282
|
+
}
|
|
283
|
+
return targetKinds;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get (LSP) Locations of metadata element.
|
|
287
|
+
*
|
|
288
|
+
* @param path - path identifying metadata element
|
|
289
|
+
* @returns Locations for the metadata element
|
|
290
|
+
*/
|
|
291
|
+
getMetadataElementLocations(path) {
|
|
292
|
+
const result = this.getMetadataElementLocationsInternal(path);
|
|
293
|
+
if (this.uriMap) {
|
|
294
|
+
// map locations of result to external uri
|
|
295
|
+
result.forEach((location) => {
|
|
296
|
+
var _a;
|
|
297
|
+
if (location.uri.indexOf('node_modules') > -1) {
|
|
298
|
+
const values = [...this.uriMap.values()];
|
|
299
|
+
const item = values.find((val) => val.endsWith(location.uri.replace(/\\/g, '/')));
|
|
300
|
+
if (item) {
|
|
301
|
+
location.uri = item;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
location.uri = (_a = this.uriMap.get(location.uri)) !== null && _a !== void 0 ? _a : location.uri;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
exports.MetadataService = MetadataService;
|
|
313
|
+
//# sourceMappingURL=metadata-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-service.js","sourceRoot":"","sources":["../src/metadata-service.ts"],"names":[],"mappings":";;;AAgBA,2CAA2C;AAC3C,MAAM,cAAc,GAAG;IACnB,OAAO,EAAE,6CAAqB;IAC9B,SAAS,EAAE,iCAAe;IAC1B,MAAM,EAAE,oEAA+B;IACvC,IAAI,EAAE,oEAA+B;IACrC,MAAM,EAAE,yGAAgD;IACxD,OAAO,EAAE,+BAAc;IACvB,MAAM,EAAE,kEAA8B;IACtC,QAAQ,EAAE,0EAAkC;IAC5C,YAAY,EAAE,2BAAY;IAC1B,cAAc,EAAE,2CAAoB;IACpC,KAAK,EAAE,iCAAe;IACtB,IAAI,EAAE,2GAAiD;CAC1D,CAAC;AACF,MAAM,iBAAiB,GAA0B,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAEzF;;;;;GAKG;AACH,SAAS,aAAa,CAAC,IAAU;;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,SAAS,CAAC,KAAK,EAAE,mCAAI,EAAE,CAAC,GAAG,CAAC,MAAA,UAAU,CAAC,GAAG,EAAE,mCAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACvH,CAAC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AAI,WAAW,CAAC,QAAQ,iCAAe,IAAI,OAAO,CAAC,kBAAkB,EAAE;YACnE,WAAW,CAAC,IAAI,mCAAgB,CAAC;SACpC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,2BAA2B,CAAC,IAAY;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,0CAA0C;YAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;;gBACxB,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC3C,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;oBACzC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;oBAClF,IAAI,IAAI,EAAE;wBACN,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC;qBACvB;iBACJ;qBAAM;oBACH,QAAQ,CAAC,GAAG,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,mCAAI,QAAQ,CAAC,GAAG,CAAC;iBAChE;YACL,CAAC,CAAC,CAAC;SACN;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAnQD,0CAmQC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sap-ux/odata-entity-model",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "OData model representation without annotations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"author": "SAP SE",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"private": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**"
|
|
11
|
+
],
|
|
12
|
+
"jestSonar": {
|
|
13
|
+
"reportPath": "reports/test/unit",
|
|
14
|
+
"reportFile": "test-report.xml"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"npm-run-all": "4.1.5",
|
|
18
|
+
"typescript": "4.9.5",
|
|
19
|
+
"@sap-ux/odata-annotation-core-types": "0.1.1"
|
|
20
|
+
},
|
|
21
|
+
"eslint-formatter-multiple": {
|
|
22
|
+
"formatters": [
|
|
23
|
+
{
|
|
24
|
+
"name": "stylish",
|
|
25
|
+
"output": "console"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "json",
|
|
29
|
+
"output": "file",
|
|
30
|
+
"path": "reports/lint/eslint.json"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "checkstyle",
|
|
34
|
+
"output": "file",
|
|
35
|
+
"path": "reports/lint/eslint.checkstyle.xml"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "npm-run-all clean && tsc --build ./tsconfig.build.json",
|
|
41
|
+
"clean:dist": "rimraf ./dist ./generators *.tsbuildinfo",
|
|
42
|
+
"clean": "rimraf ./reports",
|
|
43
|
+
"format:fix": "prettier --write --loglevel silent --ignore-path ../../../.prettierignore",
|
|
44
|
+
"format:fix:all": "prettier --write '**/*.{css,scss,html,js,json,ts,tsx,yaml,yml}' '!**/{out,dist,typings,node_modules}/**' '!**/*.{svg,png,xml}' --ignore-path ../../../.prettierignore",
|
|
45
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
46
|
+
"lint:summary": "eslint . --ext .ts,.tsx -f summary",
|
|
47
|
+
"lint:fix": "eslint --fix",
|
|
48
|
+
"lint:fix:all": "eslint . --ext .ts,.tsx --fix",
|
|
49
|
+
"lint:report": "eslint . --ext .ts,.tsx -f multiple ",
|
|
50
|
+
"test": "jest --maxWorkers=1 --ci --forceExit --detectOpenHandles",
|
|
51
|
+
"watch": "tsc --build ./ -watch"
|
|
52
|
+
}
|
|
53
|
+
}
|