ochre-sdk 1.1.2 → 1.1.3
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.
|
@@ -82,7 +82,10 @@ declare function local:matching-pages($resources, $target-slug, $slug-prefix) {
|
|
|
82
82
|
return local:matching-pages(
|
|
83
83
|
local:resource-items($segment/items/resource),
|
|
84
84
|
$target-slug,
|
|
85
|
-
|
|
85
|
+
local:prefix-slug(
|
|
86
|
+
$segment/identification/abbreviation/content/string,
|
|
87
|
+
$page-slug
|
|
88
|
+
)
|
|
86
89
|
)
|
|
87
90
|
)
|
|
88
91
|
};
|
|
@@ -56,8 +56,11 @@ export declare function childSlugPrefix(pageSlug: string, slugPrefix: string | u
|
|
|
56
56
|
* The XQuery counterpart of {@link cleanWebsitePageSlug},
|
|
57
57
|
* {@link prefixSlug} and {@link childSlugPrefix}
|
|
58
58
|
*
|
|
59
|
-
* Declares `local:clean-slug`, `local:page-slug` and
|
|
59
|
+
* Declares `local:clean-slug`, `local:prefix-slug`, `local:page-slug` and
|
|
60
60
|
* `local:page-child-slug-prefix`. "No prefix" is the empty string here.
|
|
61
|
+
* `local:prefix-slug` takes a slug value rather than a resource, because a
|
|
62
|
+
* segment's own slug comes from its abbreviation instead of a `@slug`
|
|
63
|
+
* attribute.
|
|
61
64
|
* @internal
|
|
62
65
|
*/
|
|
63
66
|
export declare const WEBSITE_PAGE_SLUG_DECLARATIONS: string;
|
|
@@ -57,20 +57,27 @@ function childSlugPrefix(pageSlug, slugPrefix) {
|
|
|
57
57
|
* The XQuery counterpart of {@link cleanWebsitePageSlug},
|
|
58
58
|
* {@link prefixSlug} and {@link childSlugPrefix}
|
|
59
59
|
*
|
|
60
|
-
* Declares `local:clean-slug`, `local:page-slug` and
|
|
60
|
+
* Declares `local:clean-slug`, `local:prefix-slug`, `local:page-slug` and
|
|
61
61
|
* `local:page-child-slug-prefix`. "No prefix" is the empty string here.
|
|
62
|
+
* `local:prefix-slug` takes a slug value rather than a resource, because a
|
|
63
|
+
* segment's own slug comes from its abbreviation instead of a `@slug`
|
|
64
|
+
* attribute.
|
|
62
65
|
* @internal
|
|
63
66
|
*/
|
|
64
67
|
const WEBSITE_PAGE_SLUG_DECLARATIONS = `declare function local:clean-slug($slug) {
|
|
65
68
|
replace(string($slug), ${stringLiteral(SEGMENT_UNIQUE_SLUG_PREFIX_PATTERN)}, "")
|
|
66
69
|
};
|
|
67
70
|
|
|
68
|
-
declare function local:
|
|
69
|
-
let $slug :=
|
|
71
|
+
declare function local:prefix-slug($slug, $slug-prefix) {
|
|
72
|
+
let $slug-string := string(($slug)[1])
|
|
70
73
|
return
|
|
71
|
-
if ($slug-prefix = "") then $slug
|
|
72
|
-
else if ($slug = "") then $slug-prefix
|
|
73
|
-
else concat($slug-prefix, ${stringLiteral("/")}, $slug)
|
|
74
|
+
if ($slug-prefix = "") then $slug-string
|
|
75
|
+
else if ($slug-string = "") then $slug-prefix
|
|
76
|
+
else concat($slug-prefix, ${stringLiteral("/")}, $slug-string)
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
declare function local:page-slug($resource, $slug-prefix) {
|
|
80
|
+
local:prefix-slug(local:clean-slug($resource/@slug), $slug-prefix)
|
|
74
81
|
};
|
|
75
82
|
|
|
76
83
|
declare function local:page-child-slug-prefix($resource, $slug-prefix) {
|
package/dist/xml/schemas.mjs
CHANGED
|
@@ -776,10 +776,22 @@ const XMLWebsiteSegment = v.lazy(() => v.object({
|
|
|
776
776
|
uuid: v.pipe(v.string("XMLWebsiteSegment: uuid is string and required"), v.check(isPseudoUuid, "XMLWebsiteSegment: uuid is not a valid pseudo-UUID")),
|
|
777
777
|
publicationDateTime: v.optional(customDateTime("XMLWebsiteSegment: publicationDateTime is not a valid datetime"))
|
|
778
778
|
}, "XMLWebsiteSegment: Shape error"));
|
|
779
|
+
/**
|
|
780
|
+
* A website resource item
|
|
781
|
+
*
|
|
782
|
+
* The member order is load-bearing, because a union returns its first match
|
|
783
|
+
* and every member is an object schema, which drops the keys its own shape
|
|
784
|
+
* does not name. {@link XMLWebsiteSegment} goes first: every entry on
|
|
785
|
+
* {@link XMLWebsiteResource} other than `uuid` is optional, so a segment
|
|
786
|
+
* wrapper satisfies that schema too and would come back without its
|
|
787
|
+
* `segments`. {@link XMLWebsiteResourceGroup} goes last for the mirror
|
|
788
|
+
* reason, since a resource holding children satisfies the group shape and
|
|
789
|
+
* would lose its own slug and properties.
|
|
790
|
+
*/
|
|
779
791
|
const XMLWebsiteResourceItem = v.lazy(() => v.union([
|
|
792
|
+
XMLWebsiteSegment,
|
|
780
793
|
XMLWebsiteResource,
|
|
781
|
-
XMLWebsiteResourceGroup
|
|
782
|
-
XMLWebsiteSegment
|
|
794
|
+
XMLWebsiteResourceGroup
|
|
783
795
|
]));
|
|
784
796
|
const XMLWebsiteResource = v.lazy(() => v.object({
|
|
785
797
|
...XMLBaseItem.entries,
|