@ulb-darmstadt/shacl-form 1.0.13 → 1.1.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.
@@ -1,7 +1,3 @@
1
- /*!
2
- * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
-
5
1
  /*!
6
2
  * The buffer module from node.js, for the browser.
7
3
  *
package/dist/inputs.d.ts CHANGED
@@ -1,52 +1,56 @@
1
- import { Quad, NamedNode } from 'n3';
2
- import { Term, Literal } from '@rdfjs/types';
3
- import { Config } from './config';
4
- export declare type Editor = HTMLElement & {
1
+ import { NamedNode, Literal } from 'n3';
2
+ import { Term } from '@rdfjs/types';
3
+ import { ShaclPropertySpec } from './property-spec';
4
+ export type Editor = HTMLElement & {
5
5
  value: string;
6
6
  };
7
7
  export declare abstract class InputBase extends HTMLElement {
8
8
  static idCtr: number;
9
- config: Config;
9
+ property: ShaclPropertySpec;
10
10
  editor: Editor;
11
11
  required: boolean;
12
- name: string;
13
- description: string;
14
- defaultValue: string;
15
- minCount: string;
16
- maxCount: string;
17
- path: string;
18
- pattern: string;
19
- dataType: NamedNode | undefined;
20
- nodeKind: NamedNode | null;
21
- constructor(quads: Quad[], config: Config);
22
- setValue(value: string): void;
23
- abstract createEditor(quads: Quad[]): Editor;
12
+ constructor(property: ShaclPropertySpec);
13
+ setValue(value: Term): void;
14
+ abstract createEditor(): Editor;
24
15
  abstract toRDFObject(): Literal | NamedNode | undefined;
25
16
  }
26
17
  export declare class InputDate extends InputBase {
27
- createEditor(quads: Quad[]): Editor;
28
- setValue(value: string): void;
18
+ createEditor(): Editor;
19
+ setValue(value: Term): void;
29
20
  toRDFObject(): Literal | undefined;
30
21
  }
31
22
  export declare class InputText extends InputBase {
32
- constructor(quads: Quad[], config: Config);
33
- createEditor(quads: Quad[]): Editor;
23
+ constructor(property: ShaclPropertySpec);
24
+ createEditor(): Editor;
34
25
  toRDFObject(): Literal | NamedNode | undefined;
35
26
  }
27
+ export declare class InputLangString extends InputText {
28
+ language: string | undefined;
29
+ langChooser: HTMLInputElement | HTMLSelectElement;
30
+ constructor(property: ShaclPropertySpec);
31
+ setValue(value: Term): void;
32
+ toRDFObject(): Literal | NamedNode | undefined;
33
+ createLangChooser(): HTMLInputElement | HTMLSelectElement;
34
+ }
35
+ export declare class InputBoolean extends InputBase {
36
+ constructor(property: ShaclPropertySpec);
37
+ createEditor(): Editor;
38
+ setValue(value: Term): void;
39
+ toRDFObject(): Literal | undefined;
40
+ }
36
41
  export declare class InputNumber extends InputBase {
37
- constructor(quads: Quad[], config: Config);
38
- createEditor(quads: Quad[]): Editor;
42
+ constructor(property: ShaclPropertySpec);
43
+ createEditor(): Editor;
39
44
  toRDFObject(): Literal | undefined;
40
45
  }
41
- export declare type InputListEntry = Term | {
46
+ export type InputListEntry = {
47
+ value: Term;
42
48
  label?: string;
43
- value: string;
44
49
  };
45
50
  export declare class InputList extends InputBase {
46
- constructor(quads: Quad[], config: Config);
51
+ constructor(property: ShaclPropertySpec, listEntries?: InputListEntry[]);
47
52
  setListEntries(list: InputListEntry[]): void;
48
- findLabel(subject: NamedNode, config: Config): string | null;
49
- createEditor(quads: Quad[]): Editor;
53
+ createEditor(): Editor;
50
54
  toRDFObject(): Literal | NamedNode | undefined;
51
55
  }
52
- export declare function inputFactory(quads: Quad[], config: Config): InputBase;
56
+ export declare function inputFactory(property: ShaclPropertySpec): InputBase;
@@ -0,0 +1,12 @@
1
+ import { Store, Parser, Prefixes, NamedNode } from 'n3';
2
+ import { ShaclForm } from './form';
3
+ export declare class Loader {
4
+ private abortController;
5
+ private form;
6
+ constructor(form: ShaclForm);
7
+ loadGraphs(): Promise<void>;
8
+ importRDF(input: string | Promise<string>, store: Store, graph?: NamedNode, parser?: Parser): Promise<void>;
9
+ fetchRDF(url: string): Promise<string>;
10
+ toURL(id: string, prefixes: Prefixes | undefined): string | null;
11
+ isURL(input: string): boolean;
12
+ }
package/dist/node.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { BlankNode, NamedNode, Store } from 'n3';
2
- import { ShaclProperty } from './property';
3
- import { ShaclForm } from './form';
2
+ import { ShaclPropertyInstance } from './property';
3
+ import { Config } from './config';
4
4
  export declare class ShaclNode extends HTMLElement {
5
5
  shaclSubject: NamedNode;
6
6
  exportValueSubject: NamedNode | BlankNode;
7
7
  targetClass: NamedNode | undefined;
8
- parent: ShaclNode | ShaclProperty | undefined;
9
- form: ShaclForm;
10
- constructor(form: ShaclForm, shaclSubject: NamedNode, parent: ShaclNode | ShaclProperty | undefined, valueSubject: NamedNode | BlankNode | undefined);
8
+ parent: ShaclNode | ShaclPropertyInstance | undefined;
9
+ config: Config;
10
+ constructor(shaclSubject: NamedNode, config: Config, parent: ShaclNode | ShaclPropertyInstance | undefined, valueSubject: NamedNode | BlankNode | undefined);
11
11
  toRDF(graph: Store, subject?: NamedNode | BlankNode): (NamedNode | BlankNode);
12
12
  }
package/dist/plugin.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { ShaclProperty } from './property';
1
+ import { ShaclPropertySpec } from './property-spec';
2
2
  import { InputBase } from './inputs';
3
- export declare type Plugins = {
3
+ export type Plugins = {
4
4
  [predicate: string]: Plugin;
5
5
  };
6
6
  export declare abstract class Plugin {
7
7
  predicate: string;
8
8
  constructor(predicate: string);
9
- abstract createInstance(property: ShaclProperty, value?: string): InputBase;
9
+ abstract createInstance(property: ShaclPropertySpec, value?: string): InputBase;
10
10
  }
@@ -1,8 +1,8 @@
1
1
  import { Plugin } from '../plugin';
2
- import { ShaclProperty } from '../property';
2
+ import { ShaclPropertySpec } from '../property-spec';
3
3
  import { InputList, InputListEntry } from '../inputs';
4
4
  export declare class FixedListPlugin extends Plugin {
5
5
  entries: InputListEntry[] | Promise<InputListEntry[]>;
6
6
  constructor(predicate: string, entries: InputListEntry[] | Promise<InputListEntry[]>);
7
- createInstance(property: ShaclProperty, value?: string): InputList;
7
+ createInstance(property: ShaclPropertySpec, value?: string): InputList;
8
8
  }
@@ -1,8 +1,8 @@
1
1
  import { InputText } from '../inputs';
2
2
  import { Plugin } from '../plugin';
3
- import { ShaclProperty } from '../property';
3
+ import { ShaclPropertySpec } from '../property-spec';
4
4
  export declare class MapBoxPlugin extends Plugin {
5
5
  apiKey: string;
6
6
  constructor(predicate: string, apiKey: string);
7
- createInstance(property: ShaclProperty, value?: string): InputText;
7
+ createInstance(property: ShaclPropertySpec, value?: string): InputText;
8
8
  }
@@ -0,0 +1,34 @@
1
+ import { Literal, NamedNode, Quad } from 'n3';
2
+ import { Term } from '@rdfjs/types';
3
+ import { Config } from './config';
4
+ export declare class ShaclPropertySpec {
5
+ label: string;
6
+ name: Literal | undefined;
7
+ description: Literal | undefined;
8
+ classInstances: Term[] | undefined;
9
+ path: string | undefined;
10
+ node: NamedNode | undefined;
11
+ class: NamedNode | undefined;
12
+ minCount: number | undefined;
13
+ maxCount: number | undefined;
14
+ minLength: number | undefined;
15
+ maxLength: number | undefined;
16
+ minInclusive: number | undefined;
17
+ maxInclusive: number | undefined;
18
+ minExclusive: number | undefined;
19
+ maxExclusive: number | undefined;
20
+ singleLine: boolean | undefined;
21
+ defaultValue: Term | undefined;
22
+ pattern: string | undefined;
23
+ order: string | undefined;
24
+ nodeKind: NamedNode | undefined;
25
+ shaclIn: string | undefined;
26
+ shaclOr: Term[] | undefined;
27
+ languageIn: Term[] | undefined;
28
+ datatype: NamedNode | undefined;
29
+ hasValue: Term | undefined;
30
+ config: Config;
31
+ constructor(quads: Quad[], config: Config);
32
+ merge(quads: Quad[]): ShaclPropertySpec;
33
+ clone(): ShaclPropertySpec;
34
+ }
@@ -1,15 +1,16 @@
1
- import { BlankNode, NamedNode, Quad, Store, Quad_Object } from 'n3';
2
- import { ShaclForm } from './form';
1
+ import { BlankNode, NamedNode, Store } from 'n3';
2
+ import { Term } from '@rdfjs/types';
3
+ import { Config } from './config';
4
+ import { ShaclPropertySpec } from './property-spec';
3
5
  export declare class ShaclProperty extends HTMLElement {
4
- name: string;
5
- node: NamedNode | null;
6
- minCount: number;
7
- maxCount: number;
8
- quads: Quad[];
9
- form: ShaclForm;
6
+ spec: ShaclPropertySpec;
10
7
  addButton: HTMLElement;
11
- constructor(form: ShaclForm, shaclSubject: BlankNode | NamedNode, valueSubject?: NamedNode | BlankNode);
12
- createPropertyInstance(value?: Quad_Object): HTMLElement;
8
+ constructor(shaclSubject: BlankNode | NamedNode, config: Config, valueSubject?: NamedNode | BlankNode);
9
+ createPropertyInstance(value?: Term): HTMLElement;
13
10
  updateControls(): void;
14
11
  toRDF(graph: Store, subject: NamedNode | BlankNode): void;
15
12
  }
13
+ export declare class ShaclPropertyInstance extends HTMLElement {
14
+ spec: ShaclPropertySpec;
15
+ constructor(spec: ShaclPropertySpec, value?: Term, forceRemovable?: boolean);
16
+ }
@@ -0,0 +1,2 @@
1
+ import { Quad } from 'n3';
2
+ export declare function serialize(quads: Quad[], format: string): string | {}[];
package/dist/util.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- import { Quad, Quad_Object } from 'n3';
1
+ import { Quad, Store } from 'n3';
2
+ import { Term } from '@rdfjs/types';
3
+ import { InputListEntry } from './inputs';
2
4
  export declare function findObjectValueByPredicate(quads: Quad[], predicate: string, prefix?: string, language?: string | null): string;
3
- export declare function findObjectByPredicate(quads: Quad[], predicate: string, prefix?: string, language?: string | null): Quad_Object | null;
5
+ export declare function findObjectByPredicate(quads: Quad[], predicate: string, prefix?: string, language?: string | null): Term | undefined;
4
6
  export declare function focusFirstInputElement(context: HTMLElement): void;
7
+ export declare function findLabel(quads: Quad[], language?: string | null): string;
8
+ export declare function createInputListEntries(subjects: Term[], shapesGraph: Store, language?: string | null): InputListEntry[];
9
+ export declare function removeKnownPrefixes(id: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "1.0.13",
3
+ "version": "1.1.0",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -30,22 +30,21 @@
30
30
  "serve": "webpack serve --mode development"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/n3": "^1.10.4",
33
+ "@types/n3": "^1.16.0",
34
34
  "buffer": "^6.0.3",
35
- "css-loader": "^6.7.3",
36
- "rimraf": "^4.1.2",
35
+ "css-loader": "^6.8.1",
36
+ "rimraf": "^5.0.1",
37
37
  "save": "^2.9.0",
38
38
  "stream-browserify": "^3.0.0",
39
- "style-loader": "^3.3.1",
40
- "ts-loader": "^9.4.1",
41
- "typescript": "^4.8.4",
42
- "webpack": "^5.75.0",
43
- "webpack-cli": "^4.10.0",
44
- "webpack-dev-server": "^4.11.1"
39
+ "style-loader": "^3.3.3",
40
+ "ts-loader": "^9.4.4",
41
+ "typescript": "^5.1.6",
42
+ "webpack": "^5.88.2",
43
+ "webpack-cli": "^5.1.4",
44
+ "webpack-dev-server": "^4.15.1"
45
45
  },
46
46
  "dependencies": {
47
- "n3": "^1.16.2",
48
- "rdf-ext": "^2.1.0",
47
+ "n3": "^1.17.0",
49
48
  "rdf-validate-shacl": "^0.4.5",
50
49
  "uuid": "^9.0.0"
51
50
  }
@@ -1,11 +0,0 @@
1
- export declare const PREFIX_SHACL = "http://www.w3.org/ns/shacl#";
2
- export declare const PREFIX_DASH = "http://datashapes.org/dash#";
3
- export declare const PREFIX_XSD = "http://www.w3.org/2001/XMLSchema#";
4
- export declare const PREFIX_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
5
- export declare const PREFIX_RDFS = "http://www.w3.org/2000/01/rdf-schema#";
6
- export declare const PREFIX_SCHEMA = "http://schema.org/";
7
- export declare const DEFAULT_PREFIXES: {
8
- xsd: string;
9
- rdf: string;
10
- schema: string;
11
- };