@digitalculture/ochre-sdk 0.7.15 → 0.7.17
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/dist/index.cjs +3 -578
- package/dist/index.d.cts +76 -14
- package/dist/index.d.ts +76 -14
- package/dist/index.js +3 -578
- package/package.json +5 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { Language } from "iso-639-3";
|
|
2
|
-
|
|
3
1
|
//#region src/types/main.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Represents the core data structure containing item information and metadata
|
|
6
|
-
*/
|
|
7
2
|
/**
|
|
8
3
|
* Represents the core data structure containing item information and metadata
|
|
9
4
|
*/
|
|
@@ -42,7 +37,7 @@ type Metadata = {
|
|
|
42
37
|
} | null;
|
|
43
38
|
dataset: string;
|
|
44
39
|
publisher: string;
|
|
45
|
-
languages: Array<
|
|
40
|
+
languages: Array<string>;
|
|
46
41
|
identifier: string;
|
|
47
42
|
description: string;
|
|
48
43
|
};
|
|
@@ -177,7 +172,7 @@ type Coordinates = {
|
|
|
177
172
|
type Observation = {
|
|
178
173
|
number: number;
|
|
179
174
|
date: Date | null;
|
|
180
|
-
observers: Array<string>;
|
|
175
|
+
observers: Array<string> | Array<Person>;
|
|
181
176
|
notes: Array<Note>;
|
|
182
177
|
links: Array<Link>;
|
|
183
178
|
properties: Array<Property>;
|
|
@@ -360,11 +355,11 @@ type PropertyValueContentType = "string" | "integer" | "decimal" | "boolean" | "
|
|
|
360
355
|
/**
|
|
361
356
|
* Represents a property value with type information
|
|
362
357
|
*/
|
|
363
|
-
type PropertyValueContent = {
|
|
364
|
-
content: string
|
|
365
|
-
|
|
358
|
+
type PropertyValueContent<T extends PropertyValueContentType> = {
|
|
359
|
+
content: T extends "string" ? string : T extends "IDREF" ? string : T extends "integer" ? number : T extends "decimal" ? number : T extends "boolean" ? boolean : T extends "date" ? Date : T extends "dateTime" ? Date : T extends "time" ? Date : null;
|
|
360
|
+
booleanLabel: T extends "boolean" ? string | null : null;
|
|
366
361
|
isUncertain: boolean;
|
|
367
|
-
type:
|
|
362
|
+
type: T;
|
|
368
363
|
category: string;
|
|
369
364
|
uuid: string | null;
|
|
370
365
|
publicationDateTime: Date | null;
|
|
@@ -373,10 +368,10 @@ type PropertyValueContent = {
|
|
|
373
368
|
/**
|
|
374
369
|
* Represents a property with label, values and nested properties
|
|
375
370
|
*/
|
|
376
|
-
type Property = {
|
|
371
|
+
type Property<T extends PropertyValueContentType = PropertyValueContentType> = {
|
|
377
372
|
uuid: string;
|
|
378
373
|
label: string;
|
|
379
|
-
values: Array<PropertyValueContent
|
|
374
|
+
values: Array<PropertyValueContent<T>>;
|
|
380
375
|
comment: string | null;
|
|
381
376
|
properties: Array<Property>;
|
|
382
377
|
};
|
|
@@ -782,6 +777,59 @@ type PropertyOptions = {
|
|
|
782
777
|
/** Whether to recursively search through nested properties */
|
|
783
778
|
includeNestedProperties: boolean;
|
|
784
779
|
};
|
|
780
|
+
/**
|
|
781
|
+
* Finds a property by its UUID in an array of properties
|
|
782
|
+
*
|
|
783
|
+
* @param properties - Array of properties to search through
|
|
784
|
+
* @param uuid - The UUID to search for
|
|
785
|
+
* @param options - Search options, including whether to include nested properties
|
|
786
|
+
* @returns The matching Property object, or null if not found
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```ts
|
|
790
|
+
* const property = getPropertyByUuid(properties, "123e4567-e89b-12d3-a456-426614174000", { includeNestedProperties: true });
|
|
791
|
+
* if (property) {
|
|
792
|
+
* console.log(property.values);
|
|
793
|
+
* }
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
796
|
+
declare function getPropertyByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Property | null;
|
|
797
|
+
/**
|
|
798
|
+
* Retrieves all values for a property with the given UUID
|
|
799
|
+
*
|
|
800
|
+
* @param properties - Array of properties to search through
|
|
801
|
+
* @param uuid - The UUID to search for
|
|
802
|
+
* @param options - Search options, including whether to include nested properties
|
|
803
|
+
* @returns Array of property values as strings, or null if property not found
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```ts
|
|
807
|
+
* const values = getPropertyValuesByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
|
|
808
|
+
* if (values) {
|
|
809
|
+
* for (const value of values) {
|
|
810
|
+
* console.log(value);
|
|
811
|
+
* }
|
|
812
|
+
* }
|
|
813
|
+
* ```
|
|
814
|
+
*/
|
|
815
|
+
declare function getPropertyValuesByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Array<string | number | boolean | Date | null> | null;
|
|
816
|
+
/**
|
|
817
|
+
* Gets the first value of a property with the given UUID
|
|
818
|
+
*
|
|
819
|
+
* @param properties - Array of properties to search through
|
|
820
|
+
* @param uuid - The UUID to search for
|
|
821
|
+
* @param options - Search options, including whether to include nested properties
|
|
822
|
+
* @returns The first property value as string, or null if property not found
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```ts
|
|
826
|
+
* const title = getPropertyValueByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
|
|
827
|
+
* if (title) {
|
|
828
|
+
* console.log(`Document title: ${title}`);
|
|
829
|
+
* }
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
832
|
+
declare function getPropertyValueByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): string | number | boolean | Date | null;
|
|
785
833
|
/**
|
|
786
834
|
* Finds a property by its label in an array of properties
|
|
787
835
|
*
|
|
@@ -849,6 +897,20 @@ declare function getPropertyValueByLabel(properties: Array<Property>, label: str
|
|
|
849
897
|
* ```
|
|
850
898
|
*/
|
|
851
899
|
declare function getUniqueProperties(properties: Array<Property>, options?: PropertyOptions): Array<Property>;
|
|
900
|
+
/**
|
|
901
|
+
* Gets all unique property labels from an array of properties
|
|
902
|
+
*
|
|
903
|
+
* @param properties - Array of properties to get unique property labels from
|
|
904
|
+
* @param options - Search options, including whether to include nested properties
|
|
905
|
+
* @returns Array of unique property labels
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```ts
|
|
909
|
+
* const properties = getAllUniquePropertyLabels(properties, { includeNestedProperties: true });
|
|
910
|
+
* console.log(`Available properties: ${properties.join(", ")}`);
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
declare function getUniquePropertyLabels(properties: Array<Property>, options?: PropertyOptions): Array<string>;
|
|
852
914
|
/**
|
|
853
915
|
* Filters a property based on a label and value criteria
|
|
854
916
|
*
|
|
@@ -876,4 +938,4 @@ declare function filterProperties(property: Property, filter: {
|
|
|
876
938
|
}, options?: PropertyOptions): boolean;
|
|
877
939
|
|
|
878
940
|
//#endregion
|
|
879
|
-
export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, getUniqueProperties };
|
|
941
|
+
export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { Language } from "iso-639-3";
|
|
2
|
-
|
|
3
1
|
//#region src/types/main.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Represents the core data structure containing item information and metadata
|
|
6
|
-
*/
|
|
7
2
|
/**
|
|
8
3
|
* Represents the core data structure containing item information and metadata
|
|
9
4
|
*/
|
|
@@ -42,7 +37,7 @@ type Metadata = {
|
|
|
42
37
|
} | null;
|
|
43
38
|
dataset: string;
|
|
44
39
|
publisher: string;
|
|
45
|
-
languages: Array<
|
|
40
|
+
languages: Array<string>;
|
|
46
41
|
identifier: string;
|
|
47
42
|
description: string;
|
|
48
43
|
};
|
|
@@ -177,7 +172,7 @@ type Coordinates = {
|
|
|
177
172
|
type Observation = {
|
|
178
173
|
number: number;
|
|
179
174
|
date: Date | null;
|
|
180
|
-
observers: Array<string>;
|
|
175
|
+
observers: Array<string> | Array<Person>;
|
|
181
176
|
notes: Array<Note>;
|
|
182
177
|
links: Array<Link>;
|
|
183
178
|
properties: Array<Property>;
|
|
@@ -360,11 +355,11 @@ type PropertyValueContentType = "string" | "integer" | "decimal" | "boolean" | "
|
|
|
360
355
|
/**
|
|
361
356
|
* Represents a property value with type information
|
|
362
357
|
*/
|
|
363
|
-
type PropertyValueContent = {
|
|
364
|
-
content: string
|
|
365
|
-
|
|
358
|
+
type PropertyValueContent<T extends PropertyValueContentType> = {
|
|
359
|
+
content: T extends "string" ? string : T extends "IDREF" ? string : T extends "integer" ? number : T extends "decimal" ? number : T extends "boolean" ? boolean : T extends "date" ? Date : T extends "dateTime" ? Date : T extends "time" ? Date : null;
|
|
360
|
+
booleanLabel: T extends "boolean" ? string | null : null;
|
|
366
361
|
isUncertain: boolean;
|
|
367
|
-
type:
|
|
362
|
+
type: T;
|
|
368
363
|
category: string;
|
|
369
364
|
uuid: string | null;
|
|
370
365
|
publicationDateTime: Date | null;
|
|
@@ -373,10 +368,10 @@ type PropertyValueContent = {
|
|
|
373
368
|
/**
|
|
374
369
|
* Represents a property with label, values and nested properties
|
|
375
370
|
*/
|
|
376
|
-
type Property = {
|
|
371
|
+
type Property<T extends PropertyValueContentType = PropertyValueContentType> = {
|
|
377
372
|
uuid: string;
|
|
378
373
|
label: string;
|
|
379
|
-
values: Array<PropertyValueContent
|
|
374
|
+
values: Array<PropertyValueContent<T>>;
|
|
380
375
|
comment: string | null;
|
|
381
376
|
properties: Array<Property>;
|
|
382
377
|
};
|
|
@@ -782,6 +777,59 @@ type PropertyOptions = {
|
|
|
782
777
|
/** Whether to recursively search through nested properties */
|
|
783
778
|
includeNestedProperties: boolean;
|
|
784
779
|
};
|
|
780
|
+
/**
|
|
781
|
+
* Finds a property by its UUID in an array of properties
|
|
782
|
+
*
|
|
783
|
+
* @param properties - Array of properties to search through
|
|
784
|
+
* @param uuid - The UUID to search for
|
|
785
|
+
* @param options - Search options, including whether to include nested properties
|
|
786
|
+
* @returns The matching Property object, or null if not found
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```ts
|
|
790
|
+
* const property = getPropertyByUuid(properties, "123e4567-e89b-12d3-a456-426614174000", { includeNestedProperties: true });
|
|
791
|
+
* if (property) {
|
|
792
|
+
* console.log(property.values);
|
|
793
|
+
* }
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
796
|
+
declare function getPropertyByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Property | null;
|
|
797
|
+
/**
|
|
798
|
+
* Retrieves all values for a property with the given UUID
|
|
799
|
+
*
|
|
800
|
+
* @param properties - Array of properties to search through
|
|
801
|
+
* @param uuid - The UUID to search for
|
|
802
|
+
* @param options - Search options, including whether to include nested properties
|
|
803
|
+
* @returns Array of property values as strings, or null if property not found
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```ts
|
|
807
|
+
* const values = getPropertyValuesByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
|
|
808
|
+
* if (values) {
|
|
809
|
+
* for (const value of values) {
|
|
810
|
+
* console.log(value);
|
|
811
|
+
* }
|
|
812
|
+
* }
|
|
813
|
+
* ```
|
|
814
|
+
*/
|
|
815
|
+
declare function getPropertyValuesByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Array<string | number | boolean | Date | null> | null;
|
|
816
|
+
/**
|
|
817
|
+
* Gets the first value of a property with the given UUID
|
|
818
|
+
*
|
|
819
|
+
* @param properties - Array of properties to search through
|
|
820
|
+
* @param uuid - The UUID to search for
|
|
821
|
+
* @param options - Search options, including whether to include nested properties
|
|
822
|
+
* @returns The first property value as string, or null if property not found
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```ts
|
|
826
|
+
* const title = getPropertyValueByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
|
|
827
|
+
* if (title) {
|
|
828
|
+
* console.log(`Document title: ${title}`);
|
|
829
|
+
* }
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
832
|
+
declare function getPropertyValueByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): string | number | boolean | Date | null;
|
|
785
833
|
/**
|
|
786
834
|
* Finds a property by its label in an array of properties
|
|
787
835
|
*
|
|
@@ -849,6 +897,20 @@ declare function getPropertyValueByLabel(properties: Array<Property>, label: str
|
|
|
849
897
|
* ```
|
|
850
898
|
*/
|
|
851
899
|
declare function getUniqueProperties(properties: Array<Property>, options?: PropertyOptions): Array<Property>;
|
|
900
|
+
/**
|
|
901
|
+
* Gets all unique property labels from an array of properties
|
|
902
|
+
*
|
|
903
|
+
* @param properties - Array of properties to get unique property labels from
|
|
904
|
+
* @param options - Search options, including whether to include nested properties
|
|
905
|
+
* @returns Array of unique property labels
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```ts
|
|
909
|
+
* const properties = getAllUniquePropertyLabels(properties, { includeNestedProperties: true });
|
|
910
|
+
* console.log(`Available properties: ${properties.join(", ")}`);
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
declare function getUniquePropertyLabels(properties: Array<Property>, options?: PropertyOptions): Array<string>;
|
|
852
914
|
/**
|
|
853
915
|
* Filters a property based on a label and value criteria
|
|
854
916
|
*
|
|
@@ -876,4 +938,4 @@ declare function filterProperties(property: Property, filter: {
|
|
|
876
938
|
}, options?: PropertyOptions): boolean;
|
|
877
939
|
|
|
878
940
|
//#endregion
|
|
879
|
-
export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, getUniqueProperties };
|
|
941
|
+
export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|