ochre-sdk 1.0.13 → 1.0.15
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/constants.d.mts +17 -0
- package/dist/constants.mjs +85 -0
- package/dist/fetchers/gallery.d.mts +38 -0
- package/dist/fetchers/gallery.mjs +91 -0
- package/dist/fetchers/item-links.d.mts +32 -0
- package/dist/fetchers/item-links.mjs +120 -0
- package/dist/fetchers/item.d.mts +74 -0
- package/dist/fetchers/item.mjs +146 -0
- package/dist/fetchers/set/items.d.mts +48 -0
- package/dist/fetchers/set/items.mjs +268 -0
- package/dist/fetchers/set/property-values.d.mts +46 -0
- package/dist/fetchers/set/property-values.mjs +514 -0
- package/dist/fetchers/website.d.mts +25 -0
- package/dist/fetchers/website.mjs +38 -0
- package/dist/getters.d.mts +193 -0
- package/dist/getters.mjs +341 -0
- package/dist/helpers.d.mts +18 -0
- package/dist/helpers.mjs +33 -0
- package/dist/index.d.mts +12 -1971
- package/dist/index.mjs +9 -7236
- package/dist/parsers/helpers.d.mts +27 -0
- package/dist/parsers/helpers.mjs +53 -0
- package/dist/parsers/index.d.mts +65 -0
- package/dist/parsers/index.mjs +1338 -0
- package/dist/parsers/mdx.d.mts +4 -0
- package/dist/parsers/mdx.mjs +9 -0
- package/dist/parsers/multilingual.d.mts +189 -0
- package/dist/parsers/multilingual.mjs +410 -0
- package/dist/parsers/string.d.mts +29 -0
- package/dist/parsers/string.mjs +445 -0
- package/dist/parsers/website/index.d.mts +20 -0
- package/dist/parsers/website/index.mjs +1245 -0
- package/dist/parsers/website/reader.d.mts +29 -0
- package/dist/parsers/website/reader.mjs +75 -0
- package/dist/query.d.mts +13 -0
- package/dist/query.mjs +827 -0
- package/dist/schemas.d.mts +79 -0
- package/dist/schemas.mjs +223 -0
- package/dist/types/index.d.mts +840 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/website.d.mts +501 -0
- package/dist/types/website.mjs +1 -0
- package/dist/utils.d.mts +34 -0
- package/dist/utils.mjs +172 -0
- package/dist/xml/metadata.d.mts +5 -0
- package/dist/xml/metadata.mjs +30 -0
- package/dist/xml/schemas.d.mts +13 -0
- package/dist/xml/schemas.mjs +849 -0
- package/dist/xml/types.d.mts +901 -0
- package/dist/xml/types.mjs +1 -0
- package/package.json +19 -17
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Query } from "./types/index.mjs";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
|
|
4
|
+
//#region src/schemas.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Schema for validating UUIDs
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
declare const uuidSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
10
|
+
/**
|
|
11
|
+
* Schema for validating language codes
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare const iso639_3Schema: v.SchemaWithPipe<readonly [v.StringSchema<"Language code must be a string">, v.LengthAction<string, 3, "Language code must be exactly 3 characters">, v.RegexAction<string, "Language code must be exactly 3 lowercase letters">]>;
|
|
15
|
+
/**
|
|
16
|
+
* Valid component types for web elements
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
declare const componentSchema: v.PicklistSchema<readonly ["3d-viewer", "advanced-search", "annotated-document", "annotated-image", "audio-player", "bibliography", "button", "collection", "empty-space", "entries", "iframe", "iiif-viewer", "image", "image-gallery", "map", "query", "search-bar", "table", "text", "timeline", "video"], "Invalid/unknown web element component">;
|
|
20
|
+
/**
|
|
21
|
+
* Schema for validating gallery parameters
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
declare const gallerySchema: v.ObjectSchema<{
|
|
25
|
+
readonly uuid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
26
|
+
readonly filter: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
27
|
+
readonly page: v.SchemaWithPipe<readonly [v.NumberSchema<"Page must be positive">, v.CheckAction<number, "Page must be positive">]>;
|
|
28
|
+
readonly perPage: v.SchemaWithPipe<readonly [v.NumberSchema<"Per page must be positive">, v.CheckAction<number, "Per page must be positive">]>;
|
|
29
|
+
}, undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Schema for validating and parsing render options
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
declare const renderOptionsSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>, v.ArraySchema<v.PicklistSchema<["bold", "italic", "underline"], undefined>, undefined>]>;
|
|
35
|
+
/**
|
|
36
|
+
* Schema for validating the parameters for the Set property values fetching function
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
declare const setPropertyValuesParamsSchema: v.ObjectSchema<{
|
|
40
|
+
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
41
|
+
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
42
|
+
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
43
|
+
readonly attributes: v.OptionalSchema<v.ObjectSchema<{
|
|
44
|
+
readonly bibliographies: v.GenericSchema<unknown, boolean>;
|
|
45
|
+
readonly periods: v.GenericSchema<unknown, boolean>;
|
|
46
|
+
}, undefined>, {
|
|
47
|
+
readonly bibliographies: false;
|
|
48
|
+
readonly periods: false;
|
|
49
|
+
}>;
|
|
50
|
+
readonly isLimitedToLeafPropertyValues: v.GenericSchema<unknown, boolean>;
|
|
51
|
+
}, undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Schema for validating Set items parameters
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
declare const setItemsParamsSchema: v.ObjectSchema<{
|
|
57
|
+
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
58
|
+
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
59
|
+
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
60
|
+
readonly sort: v.OptionalSchema<v.VariantSchema<"target", [v.StrictObjectSchema<{
|
|
61
|
+
readonly target: v.LiteralSchema<"none", undefined>;
|
|
62
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
63
|
+
readonly target: v.LiteralSchema<"title", undefined>;
|
|
64
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
65
|
+
readonly language: v.GenericSchema<unknown, string>;
|
|
66
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
67
|
+
readonly target: v.LiteralSchema<"propertyValue", undefined>;
|
|
68
|
+
readonly propertyVariableUuid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
69
|
+
readonly dataType: v.PicklistSchema<readonly ["string", "integer", "decimal", "boolean", "date", "dateTime", "time", "IDREF"], undefined>;
|
|
70
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
71
|
+
readonly language: v.GenericSchema<unknown, string>;
|
|
72
|
+
}, undefined>], undefined>, {
|
|
73
|
+
readonly target: "none";
|
|
74
|
+
}>;
|
|
75
|
+
readonly page: v.OptionalSchema<v.GenericSchema<unknown, number>, 1>;
|
|
76
|
+
readonly pageSize: v.OptionalSchema<v.GenericSchema<unknown, number>, 48>;
|
|
77
|
+
}, undefined>;
|
|
78
|
+
//#endregion
|
|
79
|
+
export { componentSchema, gallerySchema, iso639_3Schema, renderOptionsSchema, setItemsParamsSchema, setPropertyValuesParamsSchema, uuidSchema };
|
package/dist/schemas.mjs
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { isPseudoUuid } from "./utils.mjs";
|
|
2
|
+
import "./helpers.mjs";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
//#region src/schemas.ts
|
|
5
|
+
const positiveNumber = (message) => v.pipe(v.number(), v.minValue(1, message));
|
|
6
|
+
const defaultString = (value) => v.optional(v.string(), value);
|
|
7
|
+
const defaultBoolean = (value) => v.optional(v.boolean(), value);
|
|
8
|
+
const sortDirectionSchema = v.optional(v.picklist(["asc", "desc"]), "asc");
|
|
9
|
+
/**
|
|
10
|
+
* Schema for validating UUIDs
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
const uuidSchema = v.pipe(v.string(), v.check(isPseudoUuid, "Invalid pseudo-UUID"));
|
|
14
|
+
/**
|
|
15
|
+
* Schema for validating language codes
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
const iso639_3Schema = v.pipe(v.string("Language code must be a string"), v.length(3, "Language code must be exactly 3 characters"), v.regex(/^[a-z]{3}$/, "Language code must be exactly 3 lowercase letters"));
|
|
19
|
+
/**
|
|
20
|
+
* Valid component types for web elements
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
const componentSchema = v.picklist([
|
|
24
|
+
"3d-viewer",
|
|
25
|
+
"advanced-search",
|
|
26
|
+
"annotated-document",
|
|
27
|
+
"annotated-image",
|
|
28
|
+
"audio-player",
|
|
29
|
+
"bibliography",
|
|
30
|
+
"button",
|
|
31
|
+
"collection",
|
|
32
|
+
"empty-space",
|
|
33
|
+
"entries",
|
|
34
|
+
"iframe",
|
|
35
|
+
"iiif-viewer",
|
|
36
|
+
"image",
|
|
37
|
+
"image-gallery",
|
|
38
|
+
"map",
|
|
39
|
+
"query",
|
|
40
|
+
"search-bar",
|
|
41
|
+
"table",
|
|
42
|
+
"text",
|
|
43
|
+
"timeline",
|
|
44
|
+
"video"
|
|
45
|
+
], "Invalid/unknown web element component");
|
|
46
|
+
/**
|
|
47
|
+
* Schema for validating gallery parameters
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
const gallerySchema = v.object({
|
|
51
|
+
uuid: v.pipe(v.string(), v.check(isPseudoUuid, "Invalid pseudo-UUID")),
|
|
52
|
+
filter: v.optional(v.string()),
|
|
53
|
+
page: v.pipe(v.number("Page must be positive"), v.check((n) => n > 0, "Page must be positive")),
|
|
54
|
+
perPage: v.pipe(v.number("Per page must be positive"), v.check((n) => n > 0, "Per page must be positive"))
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Schema for validating and parsing render options
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
const renderOptionsSchema = v.pipe(v.string(), v.transform((str) => str.split(" ")), v.array(v.picklist([
|
|
61
|
+
"bold",
|
|
62
|
+
"italic",
|
|
63
|
+
"underline"
|
|
64
|
+
])));
|
|
65
|
+
/**
|
|
66
|
+
* Schema for validating date data types
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
const dateDataTypeSchema = v.picklist(["date", "dateTime"]);
|
|
70
|
+
/**
|
|
71
|
+
* Shared schema for query fields
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
const standardQueryFields = {
|
|
75
|
+
matchMode: v.picklist(["includes", "exact"]),
|
|
76
|
+
isCaseSensitive: v.boolean(),
|
|
77
|
+
language: defaultString("eng"),
|
|
78
|
+
isNegated: defaultBoolean(false)
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Shared schema for Set queries
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
const setQueryLeafSchema = v.union([
|
|
85
|
+
v.pipe(v.strictObject({
|
|
86
|
+
target: v.literal("property"),
|
|
87
|
+
propertyVariable: v.optional(uuidSchema),
|
|
88
|
+
dataType: v.picklist([
|
|
89
|
+
"string",
|
|
90
|
+
"integer",
|
|
91
|
+
"decimal",
|
|
92
|
+
"boolean",
|
|
93
|
+
"time",
|
|
94
|
+
"IDREF"
|
|
95
|
+
]),
|
|
96
|
+
value: v.optional(v.string()),
|
|
97
|
+
...standardQueryFields
|
|
98
|
+
}), v.check((value) => value.propertyVariable != null || value.value != null, "Property queries must include at least one propertyVariable or value")),
|
|
99
|
+
v.strictObject({
|
|
100
|
+
target: v.literal("property"),
|
|
101
|
+
propertyVariable: uuidSchema,
|
|
102
|
+
dataType: dateDataTypeSchema,
|
|
103
|
+
value: v.string(),
|
|
104
|
+
from: v.optional(v.never()),
|
|
105
|
+
to: v.optional(v.never()),
|
|
106
|
+
...standardQueryFields
|
|
107
|
+
}),
|
|
108
|
+
v.strictObject({
|
|
109
|
+
target: v.literal("property"),
|
|
110
|
+
propertyVariable: uuidSchema,
|
|
111
|
+
dataType: dateDataTypeSchema,
|
|
112
|
+
value: v.optional(v.never()),
|
|
113
|
+
from: v.string(),
|
|
114
|
+
to: v.optional(v.string()),
|
|
115
|
+
...standardQueryFields
|
|
116
|
+
}),
|
|
117
|
+
v.strictObject({
|
|
118
|
+
target: v.literal("property"),
|
|
119
|
+
propertyVariable: uuidSchema,
|
|
120
|
+
dataType: dateDataTypeSchema,
|
|
121
|
+
value: v.optional(v.never()),
|
|
122
|
+
from: v.optional(v.string()),
|
|
123
|
+
to: v.string(),
|
|
124
|
+
...standardQueryFields
|
|
125
|
+
}),
|
|
126
|
+
v.strictObject({
|
|
127
|
+
target: v.literal("property"),
|
|
128
|
+
propertyVariable: v.optional(uuidSchema),
|
|
129
|
+
dataType: v.literal("all"),
|
|
130
|
+
value: v.string(),
|
|
131
|
+
...standardQueryFields
|
|
132
|
+
}),
|
|
133
|
+
v.strictObject({
|
|
134
|
+
target: v.literal("string"),
|
|
135
|
+
value: v.string(),
|
|
136
|
+
...standardQueryFields
|
|
137
|
+
}),
|
|
138
|
+
v.strictObject({
|
|
139
|
+
target: v.picklist([
|
|
140
|
+
"title",
|
|
141
|
+
"description",
|
|
142
|
+
"image",
|
|
143
|
+
"periods",
|
|
144
|
+
"bibliography",
|
|
145
|
+
"notes"
|
|
146
|
+
]),
|
|
147
|
+
value: v.string(),
|
|
148
|
+
...standardQueryFields
|
|
149
|
+
})
|
|
150
|
+
]);
|
|
151
|
+
/**
|
|
152
|
+
* Schema for validating Set queries
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
const setQuerySchema = v.lazy(() => v.union([
|
|
156
|
+
setQueryLeafSchema,
|
|
157
|
+
v.strictObject({ and: v.pipe(v.array(setQuerySchema), v.minLength(1, "AND groups must contain at least one query")) }),
|
|
158
|
+
v.strictObject({ or: v.pipe(v.array(setQuerySchema), v.minLength(1, "OR groups must contain at least one query")) })
|
|
159
|
+
]));
|
|
160
|
+
/**
|
|
161
|
+
* Schema for validating Set queries
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
const setQueriesSchema = v.optional(v.nullable(setQuerySchema), null);
|
|
165
|
+
/**
|
|
166
|
+
* Schema for validating Set items sort
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
const setItemsSortSchema = v.optional(v.variant("target", [
|
|
170
|
+
v.strictObject({ target: v.literal("none") }),
|
|
171
|
+
v.strictObject({
|
|
172
|
+
target: v.literal("title"),
|
|
173
|
+
direction: sortDirectionSchema,
|
|
174
|
+
language: defaultString("eng")
|
|
175
|
+
}),
|
|
176
|
+
v.strictObject({
|
|
177
|
+
target: v.literal("propertyValue"),
|
|
178
|
+
propertyVariableUuid: uuidSchema,
|
|
179
|
+
dataType: v.picklist([
|
|
180
|
+
"string",
|
|
181
|
+
"integer",
|
|
182
|
+
"decimal",
|
|
183
|
+
"boolean",
|
|
184
|
+
"date",
|
|
185
|
+
"dateTime",
|
|
186
|
+
"time",
|
|
187
|
+
"IDREF"
|
|
188
|
+
]),
|
|
189
|
+
direction: sortDirectionSchema,
|
|
190
|
+
language: defaultString("eng")
|
|
191
|
+
})
|
|
192
|
+
]), { target: "none" });
|
|
193
|
+
/**
|
|
194
|
+
* Schema for validating the parameters for the Set property values fetching function
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
const setPropertyValuesParamsSchema = v.object({
|
|
198
|
+
setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
|
|
199
|
+
belongsToCollectionScopeUuids: v.optional(v.array(uuidSchema), []),
|
|
200
|
+
queries: setQueriesSchema,
|
|
201
|
+
attributes: v.optional(v.object({
|
|
202
|
+
bibliographies: defaultBoolean(false),
|
|
203
|
+
periods: defaultBoolean(false)
|
|
204
|
+
}), {
|
|
205
|
+
bibliographies: false,
|
|
206
|
+
periods: false
|
|
207
|
+
}),
|
|
208
|
+
isLimitedToLeafPropertyValues: defaultBoolean(false)
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* Schema for validating Set items parameters
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
const setItemsParamsSchema = v.object({
|
|
215
|
+
setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
|
|
216
|
+
belongsToCollectionScopeUuids: v.optional(v.array(uuidSchema), []),
|
|
217
|
+
queries: setQueriesSchema,
|
|
218
|
+
sort: setItemsSortSchema,
|
|
219
|
+
page: v.optional(positiveNumber("Page must be positive"), 1),
|
|
220
|
+
pageSize: v.optional(positiveNumber("Page size must be positive"), 48)
|
|
221
|
+
});
|
|
222
|
+
//#endregion
|
|
223
|
+
export { componentSchema, gallerySchema, iso639_3Schema, renderOptionsSchema, setItemsParamsSchema, setPropertyValuesParamsSchema, uuidSchema };
|