cedar-embeddable-editor 1.5.2 → 2.0.2

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 CHANGED
@@ -1,342 +1,228 @@
1
- # Cedar Embeddable Editor (CEE)
1
+ # CEDAR Embeddable Editor (CEE)
2
2
 
3
- The CEDAR Embeddable Editor is as a web component that implements the functionality of the CEDAR Metadata Editor.
3
+ [![Test](https://github.com/metadatacenter/cedar-embeddable-editor/actions/workflows/test.yml/badge.svg?branch=develop)](https://github.com/metadatacenter/cedar-embeddable-editor/actions/workflows/test.yml)
4
4
 
5
- It takes CEDAR JSON Schema templates as input, and produces CEDAR JSON-LD metadata.
5
+ The CEDAR Embeddable Editor (CEE) is a reusable Web Component for adding
6
+ structured, standards-based metadata authoring to web applications.
6
7
 
7
- ## Running as a standalone application
8
+ The CEE dynamically renders data-entry forms from machine-actionable CEDAR
9
+ templates and produces semantically rich metadata as JSON-LD. Templates define
10
+ the fields, constraints, controlled vocabularies, and repeatable structures in a
11
+ form, allowing the metadata-authoring experience to evolve independently of the
12
+ application that embeds it. The CEE also supports ontology-backed value selection
13
+ and persistent identifiers from external authorities such as ORCID and ROR.
8
14
 
9
- You can run CEE as a standalone application. This is helpful for developers to see changes to the code reflected immediately in the application. To run CEE in the standalone mode (NOT as a Webcomponent), you will need the editor itself and the sample templates that the editor uses. These are stored in a [separate repo](https://github.com/metadatacenter/cedar-component-distribution).
15
+ For the design rationale, architecture, and deployments in research platforms,
16
+ see [*Author Once, Publish Everywhere: Portable Metadata Authoring with the CEDAR
17
+ Embeddable Editor*](https://doi.org/10.5334/dsj-2026-002), published in the
18
+ *Data Science Journal* (2026).
10
19
 
11
- Proceed with the following steps:
20
+ For embedding and using the CEE in a web application, see the
21
+ [CEDAR Embeddable Editor documentation](https://metadatacenter.readthedocs.io/en/latest/cedar-embeddable-editor/intro/).
12
22
 
13
- ### Clone the repository
23
+ This README covers developing, building, and testing the component.
14
24
 
15
- Clone this repository onto a local directory of your choice:
25
+ ## Building the Web Component
16
26
 
17
- ```shell
18
- git clone https://github.com/metadatacenter/cedar-embeddable-editor.git
19
- git clone https://github.com/metadatacenter/cedar-component-distribution.git
20
- ```
27
+ The CEE is shipped as one JavaScript file that can be embedded in an application or
28
+ HTML page. Do not concatenate named Angular output files manually: their names,
29
+ locations, and module structure change when Angular changes builders.
21
30
 
22
- ### Edit configuration
31
+ Build the production application, then run the browser suite against the
32
+ single-file bundle it produced:
23
33
 
24
- 1. Open the file ```app/app.component.dev.ts``` in your favorite editor.
25
- 2. Edit configuration parameters based on your local environment (see section [Configuration](https://github.com/metadatacenter/cedar-embeddable-editor/tree/develop#configuration) for details).
26
-
27
- ### Build the project and start the server
28
-
29
- 1. Navigate to the CEE directory:
30
34
  ```shell
31
- $ cd <...>/<clone directory>/cedar-embeddable-editor/
32
- ```
33
- 1. Run these commands:
34
- ```shell
35
- cedar-embeddable-editor$ npm install
36
- cedar-embeddable-editor$ ng serve
35
+ nvm use
36
+ npm run build:production
37
+ npm run test:visual:prebuilt
37
38
  ```
38
39
 
39
- 1. In a different shell navigate to the component distribution directory:
40
- ```shell
41
- $ cd <...>/<clone directory>/cedar-component-distribution/
42
- ```
40
+ Use Node 24.19.0, which `.nvmrc`, `package.json` and CI all specify. The build and
41
+ tests use that same version, so the distribution is produced by the toolchain
42
+ that exercises it.
43
+
44
+ Once that exact bundle is green, stage the publishable npm directory from it:
43
45
 
44
- 1. Run these commands:
45
46
  ```shell
46
- cedar-embeddable-editor$ npm install
47
- cedar-embeddable-editor$ ng serve
47
+ npm run package:npm:prebuilt
48
48
  ```
49
49
 
50
- 1. In your browser, navigate to `http://localhost:4400/`. The app will automatically reload if you change any of the source files.
50
+ For a release candidate, `npm run test:package` performs both operations in one command: it builds
51
+ and browser-tests the production bundle, then stages and verifies the package from those exact
52
+ tested bytes.
51
53
 
52
- ## Building the Webcomponent
54
+ This copies the tested bytes to
55
+ `dist-npm/cedar-embeddable-editor/cedar-embeddable-editor.js`, refreshes its
56
+ version, README, changelog, and package lock, and records the bundle manifest.
57
+ The command fails if the browser bundle is stale or does not match its SHA-256
58
+ digest. `npm run check:npm-package` can repeat the byte-for-byte verification
59
+ before `npm pack` or `npm publish`.
53
60
 
54
- This method creates a single Javascript (JS) file that encapsulates all the functionality of CEE. The JS file can be embedded in any application or HTML page. To build a CEE Webcomponent, proceed with these steps:
61
+ ## Testing
55
62
 
56
- ### Build and copy the Webcomponent JS file
63
+ The complete test gate is available from the repository root:
57
64
 
58
- 1. Run the build command:
59
65
  ```shell
60
- cedar-embeddable-editor$ ng build --configuration=production
66
+ npm run test:ci
61
67
  ```
62
- 1. Combine the generated files into a single file and copy the final JS to the sample application:
63
- ```shell
64
- cedar-embeddable-editor$ cat dist/cedar-embeddable-editor/{runtime,polyfills,main}.js > cedar-embeddable-editor.js
65
- ```
66
-
67
- ## Running as an `npm` package
68
-
69
- Please import the latest version of the editor into your project from: [https://www.npmjs.com/package/cedar-embeddable-editor](https://www.npmjs.com/package/cedar-embeddable-editor)
70
68
 
71
- ## Configuration
69
+ It runs, in order:
72
70
 
73
- ### Configuration file
71
+ 1. `ng lint` over the sources and the ESLint configuration.
72
+ 2. A type check of the application and the domain harness, with `strict` on
73
+ throughout.
74
+ 3. The unit tests, in Node under Vitest.
75
+ 4. The headless domain harness with V8 coverage, and its per-directory coverage
76
+ floors.
77
+ 5. A production build, then the Playwright suite against that bundle, in a
78
+ container: the full Chromium baseline at desktop and narrow viewport sizes,
79
+ plus focused Chromium, Firefox and WebKit compatibility checks. The container
80
+ is what makes a screenshot baseline mean the same thing on a laptop and on CI,
81
+ so the pixel budget is zero — see `visual/run-in-container.sh`.
82
+ 6. Staging the npm package from the bundle the suite just exercised, which
83
+ checks the raw and gzip size budgets and verifies every staged byte against
84
+ its source.
74
85
 
75
- The CEE configuration file format and storage location depends on the application and the mode in which CEE is being used.
76
-
77
- * When running CEE in the standalone mode (developer mode), the configuration parameters are stored in and read from the file: `src/app/app.component.dev.ts`.
78
- * When running CEE as a generic Webcomponent, the configuration parameters can be stored in any `.json` file that is visible to the application that embeds CEE Webcomponent. CEE Webcomponent API provides a method for loading the configuration file from its path at runtime. For example:
79
- ```javascript
80
- document.addEventListener('WebComponentsReady', function () {
81
- const cee = document.querySelector('cedar-embeddable-editor');
82
- cee.loadConfigFromURL('assets/data/cee-config.json');
83
- });
84
- ```
85
- * The configuration can also be passed into the editor as a json map. In Angular this looks as follows:
86
- ```html
87
- <cedar-embeddable-editor
88
- [config]="conf"
89
- [templateObject]="template"
90
- [instanceObject]="instance"
91
- ></cedar-embeddable-editor>
92
- ```
86
+ The domain corpora are checked into `harness/fixtures/`; running the tests does
87
+ not require `cedar-artifact-library` or `cedar-test-artifacts` checkouts.
93
88
 
89
+ `.github/workflows/test.yml` runs the same gate on every pull request and on
90
+ pushes to `main` and `develop`. Nothing is published from CI: releasing is a
91
+ separate, manual procedure.
94
92
 
95
- ### Required configuration parameters
93
+ ### Auditing what ships
96
94
 
97
- * **showSampleTemplateLinks:** Wether the sample links are shown or not.
98
- * For production this should be false, the template should be injected into the component by the embedding application
99
- * **terminologyIntegratedSearchUrl:** The URL of the CEDAR integrated search endpoint that communicates with BioPortal.
100
- * The value `https://terminology.metadatacenter.org/bioportal/integrated-search` should work for the majority of applications.
101
-
102
- ```json
103
- {
104
- "showSampleTemplateLinks": false,
105
- "terminologyIntegratedSearchUrl": 'https://terminology.metadatacenter.org/bioportal/integrated-search',
106
- }
95
+ ```shell
96
+ npm run audit:prod
107
97
  ```
108
98
 
109
- ### Optional configuration parameters
110
-
111
- There are other optional configuration parameters available for controlling various aspects of the CEE user interface. Most of these are self-explanatory. The example below includes the default values in cases, where the parameter isn't explicitly declared.
112
-
113
- ```json
114
- {
115
- "sampleTemplateLocationPrefix": "http://localhost:4240/cedar-embeddable-editor-sample-templates/",
116
- "loadSampleTemplateName": "01",
117
- "expandedSampleTemplateLinks": true,
118
- "showTemplateDescription": false,
119
-
120
- "showTemplateRenderingRepresentation": true,
121
- "expandedTemplateRenderingRepresentation": false,
122
-
123
- "showInstanceDataCore": true,
124
- "expandedInstanceDataCore": false,
125
-
126
- "showMultiInstanceInfo": true,
127
- "expandedMultiInstanceInfo": false,
128
-
129
- "showInstanceDataFull": false,
130
- "expandedInstanceDataFull": false,
131
-
132
- "showTemplateSourceData": true,
133
- "expandedTemplateSourceData": false,
134
-
135
- "showDataQualityReport": false,
136
- "expandedDataQualityReport": false,
137
-
138
- "showHeader": true,
139
- "showFooter": true,
140
-
141
- "languageMapPathPrefix": null,
142
- "defaultLanguage": "en",
143
- "fallbackLanguage": "en",
99
+ Only runtime dependencies reach the file an embedder downloads, so this audit is
100
+ the one that describes the shipped artifact, and it is deliberately not part of
101
+ `test:ci` it can fail on a disclosure rather than on a commit, which would
102
+ break an unrelated pull request its author cannot fix.
144
103
 
145
- "collapseStaticComponents": false,
146
- "showStaticText": true,
147
-
148
- "readOnlyMode": false,
149
- "hideEmptyFields": false,
150
- "showPreferencesMenu": true
151
- }
152
- ```
153
- Enabling of hiding empty fields is only possible in read-only mode.
154
- ## Metadata API
155
-
156
- CEE Webcomponent includes APIs for exporting metadata externally and importing metadata into CEE.
104
+ A root `npm audit` also reports on development tooling that is not shipped to an
105
+ embedder. **Never run `npm audit fix --force` here:** it can replace the declared
106
+ toolchain with incompatible major versions. Review and update affected
107
+ dependencies explicitly instead.
157
108
 
158
- ### Metadata Export
109
+ ### First-time setup
159
110
 
160
- The metadata currently being edited inside CEE can be exported at anytime by making this API call:
111
+ The CEE resolves `cedar-model-typescript-library` from npmjs.org, so a sibling
112
+ checkout is not needed:
161
113
 
162
- ```javascript
163
- const meta = cee.currentMetadata;
114
+ ```shell
115
+ nvm use
116
+ npm ci
117
+ npm --prefix harness ci
164
118
  ```
165
119
 
166
- In the example below, the metadata is sent to an external endpoint every 15 seconds:
167
-
168
- ```javascript
169
- document.addEventListener('WebComponentsReady', function () {
170
- const cee = document.querySelector('cedar-embeddable-editor');
171
- cee.loadConfigFromURL('assets/data/cee-config.json');
172
- const saveTime = 15000; // 15 seconds
173
-
174
- setInterval(() => {
175
- const meta = cee.currentMetadata;
176
-
177
- const xhr = new XMLHttpRequest();
178
- xhr.open("POST", "http://localhost:8001/metadatasave.php");
179
- xhr.setRequestHeader("Accept", "application/json");
180
- xhr.setRequestHeader("Content-Type", "application/json");
181
- xhr.send(JSON.stringify(meta, null, 2));
182
- console.log('Saved metadata after ' + saveTime / 1000 + ' seconds');
183
- }, saveTime);
184
- });
185
- ```
120
+ The visual suite installs nothing here. It runs inside Playwright's own container,
121
+ which carries the browsers it drives, and installs its dependencies there against a
122
+ named volume — so it needs Docker running and no `playwright install` of its own.
186
123
 
187
- ### Template Injection
124
+ The CEE uses Angular 22.1 and Node 24.19.0. `.nvmrc`, the package `engines` field and
125
+ CI specify the Node version.
188
126
 
189
- You can inject your template into CEE:
127
+ The application bundle and the visual fixture generator each install the model
128
+ library directly from npmjs.org:
190
129
 
191
- ```javascript
192
- cee.templateObject = yourCustomTemplateJson;
130
+ ```json
131
+ "cedar-model-typescript-library": "<version>"
193
132
  ```
194
133
 
195
- ### Metadata Injection
134
+ Keep the version in the root and `visual/` manifests, and both lockfiles, in
135
+ sync. The production bundle imports the root copy while the browser fixtures are
136
+ generated with the visual copy, so a mismatch means the tests and the artifact
137
+ are using different model contracts. The harness declares no separate copy; it
138
+ resolves the root installation.
196
139
 
197
- You can inject your metadata into CEE, provided it matches the template currently being edited:
140
+ ### Focused test commands
198
141
 
199
- ```javascript
200
- cee.instanceObject = yourCustomMetadataJson
201
- ```
142
+ Use these when working on one layer:
202
143
 
203
- In the example below, the metadata is fetched from a remote URL and injected into CEE:
204
-
205
- ```javascript
206
- function restoreMetadataFromURL(metaUrl, cee, successHandler = null, errorHandler = null) {
207
- const xhr = new XMLHttpRequest();
208
- xhr.onreadystatechange = () => {
209
- if (xhr.readyState === XMLHttpRequest.DONE) {
210
- if (xhr.status === 200) {
211
- const jsonMeta = JSON.parse(xhr.responseText);
212
- cee.instanceObject = jsonMeta;
213
-
214
- if (successHandler) {
215
- successHandler(jsonMeta);
216
- }
217
- } else {
218
- if (errorHandler) {
219
- errorHandler(xhr);
220
- }
221
- }
222
- }
223
- };
224
- xhr.open('GET', metaUrl, true);
225
- xhr.send();
226
- }
227
-
228
- document.addEventListener('WebComponentsReady', function () {
229
- const cee = document.querySelector('cedar-embeddable-editor');
230
- cee.loadConfigFromURL('assets/data/cee-config.json');
231
- restoreMetadataFromURL('uploads/metadata-for-restore.json', cee);
232
- });
144
+ ```shell
145
+ npm run test:unit:ci # Vitest unit tests, one run
146
+ npm run test:unit:coverage # unit tests with coverage report
147
+ npm run test:domain # Vitest domain harness
148
+ npm run test:domain:coverage # domain harness with coverage report
149
+ npm run test:bundle-size # exact raw and gzip budgets for the shipped bundle
150
+ npm run test:visual # production build, fixture preparation, Playwright
233
151
  ```
234
152
 
235
- To reiterate, the metadata being injected **MUST** match the template currently being edited and open in your browser window.
153
+ `npm test` runs the unit tests once, and `npm run test:watch` keeps them running
154
+ for interactive development. Use `npm run test:ci` for a complete verification.
236
155
 
237
- ### Injecting Template And Metadata Together
156
+ The unit tests run in Node and do not use `TestBed` or Angular's JIT compiler.
157
+ Browser behavior belongs in the Playwright suite under `visual/`, which tests the
158
+ shipped bundle rather than the sources.
238
159
 
239
- You can inject your template and metadata together into CEE:
240
-
241
- ```javascript
242
- const templateAndInstance = {templateObject: object, instanceObject: object};
243
- cee.templateAndInstanceObject = templateAndInstance;
244
- ```
160
+ ## Running
245
161
 
246
- Injecting template and metadata together brings performance benefits as well as allows configuring hiding empty fields.
247
- Object being injected must strictly have two objects one named 'templateObject' and the other 'instanceObject'.
162
+ ### As an `npm` package
248
163
 
249
- ### Data Quality Report
164
+ Releases are published to npmjs.org as
165
+ [`cedar-embeddable-editor`](https://www.npmjs.com/package/cedar-embeddable-editor)
166
+ under the `latest` tag, so an embedder installs the current one by name:
250
167
 
251
- The dataQualityReport summarizes basic metrics on the instance data.
252
-
253
- ```javascript
254
- const report = cee.dataQualityReport;
168
+ ```shell
169
+ npm install cedar-embeddable-editor
255
170
  ```
256
171
 
257
- At the moment these three fields are available, with more to come:
172
+ The `latest` tag is the public stable channel. To see the current release without
173
+ depending on a version copied into this README:
258
174
 
259
- ```
260
- requiredFieldValueCount: int
261
- nonNullRequiredFieldValueCount: int
262
- isValid: boolean
175
+ ```shell
176
+ npm view cedar-embeddable-editor version
263
177
  ```
264
178
 
265
- ### Language Maps / Translations
179
+ ### As a standalone application
266
180
 
267
- The application currently has two built-in language maps: `en` and `hu`. If you do not specify any language-related config option, the default `English` map will be used.
268
-
269
- If you wish to change the language to another built-in one (currently the only other language is `Hungarian`), specify the config like below:
270
-
271
- ```json
272
- {
273
- "defaultLanguage": "hu",
274
- "fallbackLanguage": "en"
275
- }
276
- ```
181
+ You can run the CEE as a standalone application. This is helpful for developers to
182
+ see changes to the code reflected immediately in the application.
277
183
 
278
- You can use external language maps as well. In order to do this, specify a relative path to a folder containing the language file. The file should be named `x.json`, and should have the identical structure of the language map found in the source of the application:
184
+ Proceed with the following steps:
279
185
 
280
- https://github.com/metadatacenter/cedar-embeddable-editor/blob/main/src/assets/i18n-cee/en.json
186
+ #### Clone the repository
281
187
 
282
- In order to use an external language file, specify the config as follows:
188
+ Clone this repository onto a local directory of your choice:
283
189
 
284
- ```json
285
- {
286
- "languageMapPathPrefix": "/assets/i18n-cee/",
287
- "defaultLanguage": "de",
288
- "fallbackLanguage": "en"
289
- }
190
+ ```shell
191
+ git clone https://github.com/metadatacenter/cedar-embeddable-editor.git
290
192
  ```
291
193
 
292
- In the example above we want to use a `German` language file, which is located in the specified directory. Starting the path with `/` makes the path absolute.
293
-
294
- In our case the `/assets/i18n-cee/de.json` will be loaded if present.
295
-
296
- If the file is missing, the `/assets/i18n-cee/en.json` will be used.
297
-
298
- If that file is also missing, the built-in `de` map would be the next. As this does not exist at this moment, the last option, the built-in `en` map will be used.
299
-
300
- Information about the loading process is logged onto the console with the `CEE TRACE` prefix.
194
+ #### Edit configuration
301
195
 
302
- ### Listening for changes
196
+ Open the standalone application's configuration file, `src/app/app.component.dev.ts`.
197
+ This minimal configuration enables lookups through the public CEDAR services:
303
198
 
304
- If you need to listen to data changes inside the embeddable editor, you can use the existing `change` DOM events. We added custom events in case of a multi-instance add, copy and delete operations, so you can listen to all the events on the instance.
305
-
306
- An example in Angular is:
307
-
308
- - `component.html`:
309
- ```html
310
- <cedar-embeddable-editor
311
- [config]="conf"
312
- [templateObject]="template"
313
- [instanceObject]="instance"
314
- (change)="logChange($event)"
315
- ></cedar-embeddable-editor>
316
- ```
317
-
318
- - `component.ts`:
319
199
  ```typescript
320
- logChange(event) {
321
- console.log('CHANGE', event);
322
- }
200
+ import type { CeeConfig } from 'cedar-embeddable-editor';
201
+
202
+ const ceeConfig: CeeConfig = {
203
+ terminologyBaseUrl: 'https://terminology.metadatacenter.org/',
204
+ bridgeBaseUrl: 'https://bridge.metadatacenter.org/',
205
+ };
323
206
  ```
324
207
 
325
- ### Viewer Mode
208
+ For a different CEDAR deployment, replace both URLs with its service URLs. See
209
+ the [configuration documentation](https://metadatacenter.readthedocs.io/en/latest/cedar-embeddable-editor/configuration/)
210
+ for all available settings.
326
211
 
327
- CEE can be used as a viewer to display metadata instances. This can be achieved by the following configuration setting:
212
+ #### Build the project and start the server
328
213
 
329
- ```json
330
- "readOnlyMode": true
331
- ```
332
- When used in this mode, users won't be able to manipulate the metadata instance but can only read it.
333
- ## Example Applications
214
+ 1. Navigate to the CEE directory:
334
215
 
335
- There is a sample applications you can use to demonstrate how to embed and use CEE.
336
- Follow the links below to the demo application of your choice. The documentation for each demo application can be found in the README file of the corresponding application.
216
+ ```shell
217
+ cd <...>/<clone directory>/cedar-embeddable-editor/
218
+ ```
337
219
 
338
- ### CEE Demo Angular
220
+ 2. Run these commands:
339
221
 
340
- This demo is written in Angular 2 and requires that framework to run properly.
222
+ ```shell
223
+ npm install
224
+ ng serve
225
+ ```
341
226
 
342
- https://github.com/metadatacenter/cedar-cee-demo/tree/main/cedar-cee-demo-angular-src
227
+ 3. In your browser, navigate to `http://localhost:4400/`. The app will
228
+ automatically reload if you change any of the source files.
@@ -0,0 +1,9 @@
1
+ {
2
+ "strategy": "bundle",
3
+ "inputs": [
4
+ "main.js",
5
+ "polyfills.js"
6
+ ],
7
+ "bytes": 2183062,
8
+ "sha256": "bbcd976e2baed672c9a68851ebbadbed55544247daeb59adcd4422b79f219269"
9
+ }