cedar-embeddable-designer 0.0.0-stage → 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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "bytes": 1996685,
3
+ "sha256": "8296a12fbb0e9292b6f2c40d7b26ed0a11546722794d512c3afb5e0a074a3c40",
4
+ "inputs": [
5
+ "dist/cedar-embeddable-designer/browser/polyfills.js",
6
+ "dist/cedar-embeddable-designer/browser/main.js"
7
+ ],
8
+ "provenance": {
9
+ "source": "0577b5d7af4344ef4dda92769b322117096489975874b41660994350c4cf942a",
10
+ "output": "109ca76f54de8a217678cf6e6c0c927e1b396c0bd9de00ce36791ede0d278e65"
11
+ }
12
+ }
@@ -0,0 +1,349 @@
1
+ /** Options for adopting a saved artifact without resetting inspection state. */
2
+ export interface CedLoadOptions {
3
+ /** Retain tabs, expansion and selection for matching deployment paths and field types. */
4
+ preserveView?: boolean;
5
+ }
6
+ /** Opaque JSON recovery state, including unfinished controls; never submit it as an artifact. */
7
+ export interface CedRecoveryDraft {
8
+ format: 'cedar-designer-draft';
9
+ version: 1;
10
+ kind: 'template' | 'element' | 'field';
11
+ state: string;
12
+ }
13
+ /**
14
+ * The contract an embedding page programs against.
15
+ *
16
+ * Everything here is deliberately self-contained: no imports, and no reference to
17
+ * a type declared elsewhere in the designer. That is not tidiness — it is what
18
+ * lets `tsc --emitDeclarationOnly` turn this one file into the `.d.ts` the npm
19
+ * package ships, without dragging in paths that exist only in this repository.
20
+ *
21
+ * Types only, with no runtime values, and that is a constraint rather than a
22
+ * style. The shipped bundle is a script that registers a custom element and
23
+ * exports nothing at all, so a `const` declared here would satisfy a host's
24
+ * compiler and then be `undefined` at runtime.
25
+ */
26
+ /**
27
+ * A language the designer's own text is available in.
28
+ *
29
+ * Assigning any other value to an element's `language` selects English.
30
+ */
31
+ export type CedLanguage = 'en' | 'hu';
32
+ /** A configuration key, as a type. */
33
+ export type CedConfigKey = keyof CedConfig;
34
+ /**
35
+ * The configuration the designer accepts.
36
+ *
37
+ * Every key is optional, and an omitted key takes its default.
38
+ */
39
+ export interface CedConfig {
40
+ /**
41
+ * Base for controlled-term search. A missing trailing slash is normalized.
42
+ *
43
+ * Identifies the CEDAR terminology server, and nothing below it: the search
44
+ * path hangs off this and is the designer's own. Unset, the controlled-term
45
+ * panel offers no terms, and the designer says so once.
46
+ *
47
+ * There is no default. A hardcoded production endpoint is one an embedder
48
+ * reaches without asking and without knowing.
49
+ */
50
+ terminologyBaseUrl?: string;
51
+ /** Base URL for external-authority default lookups through CEF. A missing trailing slash is normalized. */
52
+ bridgeBaseUrl?: string;
53
+ }
54
+ /** A JSON-serialisable value, as it appears in a CEDAR artifact. */
55
+ /** Exact numeric artifact atom; use String(value) to inspect it without rounding. */
56
+ export interface CedExactNumber {
57
+ readonly cedarExactDecimal: true;
58
+ toString(): string;
59
+ toJSON(): unknown;
60
+ }
61
+ export type CedJsonValue = string | number | CedExactNumber | boolean | null | CedJsonObject | CedJsonValue[];
62
+ export interface CedJsonObject {
63
+ [key: string]: CedJsonValue;
64
+ }
65
+ /**
66
+ * What the change events carry: the complete template or element as CEDAR JSON-LD.
67
+ *
68
+ * The same document the CEDAR artifact server accepts, written by the CEDAR
69
+ * model library rather than by the designer.
70
+ */
71
+ export type CedTemplate = CedJsonObject;
72
+ /**
73
+ * The element, as a host sees it.
74
+ *
75
+ * `artifact` (and its legacy alias `template`) takes CEDAR JSON-LD or CEDAR YAML — an object, or a string in
76
+ * either serialization. A source that cannot be read is reported to the console
77
+ * rather than thrown, because assigning a property should not fail inside the
78
+ * host's own code.
79
+ */
80
+ export interface CedarEmbeddableDesignerElement extends HTMLElement {
81
+ config: CedConfig | null;
82
+ /**
83
+ * The language of the designer's own text, also settable as the `language` attribute.
84
+ *
85
+ * It may change at any time, and the designer, the term pickers it embeds and its CEE
86
+ * preview follow. An unsupported value selects English, which is also the default. The
87
+ * content of the template is never translated.
88
+ */
89
+ get language(): CedLanguage;
90
+ set language(value: CedLanguage | string | null);
91
+ /**
92
+ * Host read-only mode: inspection and the validation report remain available;
93
+ * editing, saving and inline authoring error markers are disabled.
94
+ */
95
+ readOnly: boolean;
96
+ /** Host-owned repository search and artifact retrieval. Replaceable between documents. */
97
+ childSource: CedChildSource | null;
98
+ /** A template or element document. The legacy property name remains supported. */
99
+ template: CedJsonObject | string | null;
100
+ artifact: CedJsonObject | string | null;
101
+ /** Load a document synchronously; throws if it cannot be read. */
102
+ loadArtifact(source: CedJsonObject | string, options?: CedLoadOptions): void;
103
+ captureDraft(): CedRecoveryDraft;
104
+ /** Throws before replacing the working document if the draft cannot be restored. */
105
+ restoreDraft(draft: CedRecoveryDraft): void;
106
+ /** Start an empty template or element, without the demo's starter fields. */
107
+ newArtifact(kind: 'template' | 'element'): void;
108
+ /** Includes invalid, uncommitted setting edits. Reset by loading a saved document. */
109
+ readonly isDirty: boolean;
110
+ addEventListener(type: 'dirtyChange', listener: (event: CustomEvent<boolean>) => void, options?: boolean | AddEventListenerOptions): void;
111
+ /** Findings for the current accepted artifact; replaced by assignment, cleared by an accepted edit or load. */
112
+ set validationFindings(findings: CedHostFinding[]);
113
+ /** Reveal a mapped host finding; false for stale or unsupported paths. */
114
+ revealValidationFinding(location: string): boolean;
115
+ readonly validationReport: CedValidationReport;
116
+ readonly canSave: boolean;
117
+ validate(): CedValidationReport;
118
+ /**
119
+ * The CEDAR meta-schema's verdict on any schema artifact, not only the open one: the same check the
120
+ * designer applies to its own document. `kind` is read from the artifact's `@type` when omitted.
121
+ */
122
+ validateArtifact(artifact: CedJsonObject, kind?: CedArtifactKind): CedArtifactVerdict;
123
+ addEventListener(type: 'validationChange', listener: (event: CustomEvent<CedValidationReport>) => void, options?: boolean | AddEventListenerOptions): void;
124
+ readonly currentArtifact: CedJsonObject;
125
+ readonly currentTemplate: CedTemplate;
126
+ addEventListener(type: 'templateChange' | 'artifactChange', listener: (event: CustomEvent<CedTemplate>) => void, options?: boolean | AddEventListenerOptions): void;
127
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
128
+ }
129
+ declare global {
130
+ interface HTMLElementTagNameMap {
131
+ 'cedar-embeddable-designer': CedarEmbeddableDesignerElement;
132
+ }
133
+ }
134
+ /**
135
+ * Settings validation includes unsaved edits; IDs are stable within this document session.
136
+ *
137
+ * `label` and `message` are written for the author, in the element's `language`. `tab`
138
+ * and `code` are identifiers, and stay the same in every language.
139
+ */
140
+ export interface CedHostFinding {
141
+ /** JSON Pointer into the schema artifact, including properties and items segments. */
142
+ location: string;
143
+ message: string;
144
+ severity: 'error' | 'warning';
145
+ }
146
+ export interface CedValidationIssue {
147
+ nodeId: number;
148
+ path: number[];
149
+ label: string;
150
+ setting: string;
151
+ tab: string;
152
+ code: string;
153
+ message: string;
154
+ severity: 'error' | 'warning';
155
+ source: 'model' | 'draft' | 'host';
156
+ location?: string;
157
+ /** Unsupported paths remain in the report without navigating to an unrelated control. */
158
+ unmapped?: boolean;
159
+ /**
160
+ * Whether the designer's error summary lists the issue. A name nobody has touched yet, and a new
161
+ * choice field's blank starter option, block saving without being listed until the author
162
+ * reaches them.
163
+ */
164
+ shown: boolean;
165
+ }
166
+ /**
167
+ * A shape the loaded artifact stored that the designer cannot represent and the CEDAR validator refuses.
168
+ * The designer's projection of the artifact holds `value` in its place, or nothing when there is no
169
+ * `value`. A host that merges the projection into the stored artifact, retaining what the author did not
170
+ * change, applies each of these to its stored copy first. A retained branch then cannot carry a refused
171
+ * shape into a save that the server would reject and the author could not repair.
172
+ */
173
+ export interface CedSupersededShape {
174
+ /** JSON Pointer into the artifact as it was loaded. */
175
+ location: string;
176
+ /**
177
+ * - `numberType`: a numeric field whose datatype is missing or unsupported, which the designer reads as `value`.
178
+ * - `termDefault`: a controlled-term field whose default is stored as text rather than as a term.
179
+ * - `fieldOrder`: an order on a field, which has no children to order.
180
+ * - `termTextConstraint`: a length limit or pattern on a controlled-term field, which the validator would
181
+ * apply to the IRI of any term chosen as its default.
182
+ */
183
+ code: 'numberType' | 'termDefault' | 'fieldOrder' | 'termTextConstraint';
184
+ value?: CedJsonValue;
185
+ }
186
+ export type CedArtifactKind = 'template' | 'element' | 'field';
187
+ /** One reason the CEDAR meta-schema gives for its verdict on an artifact. */
188
+ export interface CedArtifactFinding {
189
+ code: string;
190
+ category: 'structural' | 'constraint' | 'completeness' | 'verification';
191
+ /** JSON Pointer into the artifact, including array indexes and the offending property. */
192
+ path: string;
193
+ message: string;
194
+ verificationStatus?: 'passed' | 'failed' | 'notChecked' | 'unavailable';
195
+ }
196
+ /**
197
+ * What `validateArtifact` returns. `canSave` is false exactly when a finding would make the CEDAR
198
+ * server refuse to store the artifact. `isValid` is false also when an applicable check could not run.
199
+ */
200
+ export interface CedArtifactVerdict {
201
+ findings: CedArtifactFinding[];
202
+ structurallyValid: boolean;
203
+ canSave: boolean;
204
+ isValid: boolean;
205
+ }
206
+ export interface CedValidationReport {
207
+ /**
208
+ * The stored shapes the designer's projection superseded when the artifact was loaded, listed only when
209
+ * there are any. They never affect `valid` or `canSave`, and they stay the same until the next load.
210
+ */
211
+ superseded?: CedSupersededShape[];
212
+ /** Semantic coverage is independent of local consistency and save permission. */
213
+ semanticChecks?: Array<{
214
+ nodeId: number;
215
+ path: number[];
216
+ iri: string;
217
+ code: string;
218
+ message: string;
219
+ status: 'passed' | 'failed' | 'notChecked' | 'unavailable';
220
+ }>;
221
+ /** Save remains unavailable while bounded pattern checks are running. */
222
+ pendingValidation?: boolean;
223
+ valid: boolean;
224
+ canSave: boolean;
225
+ issues: CedValidationIssue[];
226
+ }
227
+ /** A permission-filtered first-class artifact returned by the embedding host. */
228
+ export interface CedChildResult {
229
+ id: string;
230
+ name: string;
231
+ type: 'field' | 'element';
232
+ createdOn?: string | null;
233
+ modifiedOn?: string | null;
234
+ version?: string | null;
235
+ status?: string | null;
236
+ }
237
+ export interface CedChildSource {
238
+ /** Return one page. Omit nextCursor on the final page; honor the abort signal. */
239
+ search(query: string, options: {
240
+ signal: AbortSignal;
241
+ cursor?: string;
242
+ }): Promise<{
243
+ results: CedChildResult[];
244
+ nextCursor?: string;
245
+ }>;
246
+ /** Fetch the complete JSON-LD artifact, using the host's authentication. */
247
+ load(result: CedChildResult, options: {
248
+ signal: AbortSignal;
249
+ }): Promise<CedJsonObject>;
250
+ /**
251
+ * Every version of the artifact's version line that the user can read, newest first, or null
252
+ * when the artifact itself cannot be read because it was deleted or the user has no access.
253
+ * Reject only when the lookup itself fails. Without this method the Version tab offers nothing
254
+ * that needs a stored origin.
255
+ */
256
+ versions?(reference: CedArtifactReference, options: {
257
+ signal: AbortSignal;
258
+ }): Promise<CedArtifactVersion[] | null>;
259
+ /**
260
+ * Whether every instance that is valid under `current` stays valid under `candidate`. Both are
261
+ * complete JSON-LD artifacts of the same type. This guarantee is distinct from checking only
262
+ * currently stored instances. Without this method upgrades carry no verdict and the host must
263
+ * enforce its update policy when saving. A document edit retires the assessment.
264
+ */
265
+ compatibility?(current: CedJsonObject, candidate: CedJsonObject, options: {
266
+ type: CedChildResult['type'];
267
+ signal: AbortSignal;
268
+ /** The full open document and exact proposed document, including retained placement. */
269
+ document: CedJsonObject;
270
+ replacement: CedJsonObject;
271
+ }): Promise<CedCompatibility>;
272
+ /**
273
+ * Store a child as a new reusable artifact, as a draft or published, and return it as stored.
274
+ * The stored artifact may carry an identifier, version and dates of the repository's choosing.
275
+ */
276
+ save?(artifact: CedJsonObject, options: {
277
+ type: CedChildResult['type'];
278
+ publish: boolean;
279
+ signal: AbortSignal;
280
+ }): Promise<CedJsonObject>;
281
+ /** Show a stored artifact to the user, for example in another browser tab. */
282
+ open?(reference: CedArtifactReference): void;
283
+ }
284
+ /** A stored artifact, identified by its `@id`. */
285
+ export interface CedArtifactReference {
286
+ id: string;
287
+ type: 'field' | 'element' | 'template';
288
+ }
289
+ /** One version of a stored artifact, as a `versions` lookup returns it. */
290
+ export interface CedArtifactVersion {
291
+ id: string;
292
+ name: string;
293
+ version: string | null;
294
+ publicationStatus: 'bibo:draft' | 'bibo:published' | null;
295
+ /** Display text for the artifact's owner and folder, where the user may see them. */
296
+ owner?: string | null;
297
+ folder?: string | null;
298
+ }
299
+ /**
300
+ * A host's verdict on replacing one version of a child with another.
301
+ *
302
+ * `invalidatedInstances` counts the instances of the open template that the replacement would
303
+ * invalidate. A breaking replacement is refused while that count is above zero, because those
304
+ * instances belong to this version of the template. For a breaking replacement the count must be
305
+ * an explicit nonnegative safe integer, including zero to permit replacement. Missing, invalid or
306
+ * contradictory answers withhold replacement. The server must enforce the same policy at write
307
+ * time, including instances created after this assessment.
308
+ */
309
+ export interface CedCompatibility {
310
+ /** null means schema compatibility is unknown; only an explicit zero impact permits replacement. */
311
+ compatible: boolean | null;
312
+ invalidatedInstances?: number;
313
+ }
314
+ /** CED field kinds, including the temporal subtypes accepted when creating a definition. */
315
+ export type CedFieldType = 'text' | 'paragraph' | 'multipleChoice' | 'checkboxes' | 'singleChoiceList' | 'multipleChoiceList' | 'date' | 'time' | 'email' | 'link' | 'phone' | 'number' | 'controlledTerms' | 'attributeValue' | 'orcid' | 'ror' | 'pfas' | 'rrid' | 'pubmed' | 'nihGrantId' | 'doi' | 'image' | 'richText' | 'youtube' | 'sectionBreak' | 'pageBreak';
316
+ /**
317
+ * <cedar-embeddable-field-designer>, registered by the same bundle as CED.
318
+ * Designs a field definition; placement, persistence and lifecycle decisions belong to its host.
319
+ */
320
+ export interface CedarEmbeddableFieldDesignerElement extends HTMLElement {
321
+ config: CedConfig | null;
322
+ /** The language of the field designer's own text, as on `CedarEmbeddableDesignerElement`. */
323
+ get language(): CedLanguage;
324
+ set language(value: CedLanguage | string | null);
325
+ artifact: CedJsonObject | string | null;
326
+ /** Host read-only mode; published definitions are always read only. */
327
+ readOnly: boolean;
328
+ /** Throws on invalid input, preserving the currently open document. */
329
+ loadArtifact(source: CedJsonObject | string, options?: CedLoadOptions): void;
330
+ captureDraft(): CedRecoveryDraft;
331
+ restoreDraft(draft: CedRecoveryDraft): void;
332
+ /** Omit the type to show the field-type chooser. Resets the dirty baseline. */
333
+ newArtifact(type?: CedFieldType): void;
334
+ /** Null before choosing a type. May throw for an invalid draft; check canSave first. */
335
+ readonly currentArtifact: CedJsonObject | null;
336
+ readonly isDirty: boolean;
337
+ readonly canSave: boolean;
338
+ /** Same snapshot-scoped finding contract as the template designer. */
339
+ set validationFindings(findings: CedHostFinding[]);
340
+ revealValidationFinding(location: string): boolean;
341
+ readonly validationReport: CedValidationReport;
342
+ validate(): CedValidationReport;
343
+ /** The CEDAR meta-schema's verdict on any schema artifact; see `CedarEmbeddableDesignerElement`. */
344
+ validateArtifact(artifact: CedJsonObject, kind?: CedArtifactKind): CedArtifactVerdict;
345
+ addEventListener(type: 'artifactChange', listener: (event: CustomEvent<CedJsonObject>) => void, options?: boolean | AddEventListenerOptions): void;
346
+ addEventListener(type: 'dirtyChange', listener: (event: CustomEvent<boolean>) => void, options?: boolean | AddEventListenerOptions): void;
347
+ addEventListener(type: 'validationChange', listener: (event: CustomEvent<CedValidationReport>) => void, options?: boolean | AddEventListenerOptions): void;
348
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
349
+ }