@krantho/seo 0.0.0-stage → 1.0.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.
- package/LICENSE +21 -0
- package/dist/archetypes/define-archetype.d.ts +23 -0
- package/dist/archetypes/define-archetype.d.ts.map +1 -0
- package/dist/archetypes/define-archetype.js +51 -0
- package/dist/archetypes/define-archetype.js.map +1 -0
- package/dist/archetypes/index.d.ts +4 -0
- package/dist/archetypes/index.d.ts.map +1 -0
- package/dist/archetypes/index.js +3 -0
- package/dist/archetypes/index.js.map +1 -0
- package/dist/archetypes/presets.d.ts +21 -0
- package/dist/archetypes/presets.d.ts.map +1 -0
- package/dist/archetypes/presets.js +42 -0
- package/dist/archetypes/presets.js.map +1 -0
- package/dist/archetypes/types.d.ts +20 -0
- package/dist/archetypes/types.d.ts.map +1 -0
- package/dist/archetypes/types.js +2 -0
- package/dist/archetypes/types.js.map +1 -0
- package/dist/catalog/auto-mappings.d.ts +39 -0
- package/dist/catalog/auto-mappings.d.ts.map +1 -0
- package/dist/catalog/auto-mappings.js +64 -0
- package/dist/catalog/auto-mappings.js.map +1 -0
- package/dist/catalog/index.d.ts +7 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +4 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/catalog/properties.d.ts +9 -0
- package/dist/catalog/properties.d.ts.map +1 -0
- package/dist/catalog/properties.js +630 -0
- package/dist/catalog/properties.js.map +1 -0
- package/dist/catalog/property-atoms.d.ts +53 -0
- package/dist/catalog/property-atoms.d.ts.map +1 -0
- package/dist/catalog/property-atoms.js +170 -0
- package/dist/catalog/property-atoms.js.map +1 -0
- package/dist/catalog/types.d.ts +53 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/catalog/types.js +423 -0
- package/dist/catalog/types.js.map +1 -0
- package/dist/create-seo.d.ts +70 -0
- package/dist/create-seo.d.ts.map +1 -0
- package/dist/create-seo.js +137 -0
- package/dist/create-seo.js.map +1 -0
- package/dist/decorators/breadcrumb.d.ts +12 -0
- package/dist/decorators/breadcrumb.d.ts.map +1 -0
- package/dist/decorators/breadcrumb.js +36 -0
- package/dist/decorators/breadcrumb.js.map +1 -0
- package/dist/decorators/index.d.ts +8 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +13 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/nodes.d.ts +12 -0
- package/dist/decorators/nodes.d.ts.map +1 -0
- package/dist/decorators/nodes.js +29 -0
- package/dist/decorators/nodes.js.map +1 -0
- package/dist/decorators/page.d.ts +13 -0
- package/dist/decorators/page.d.ts.map +1 -0
- package/dist/decorators/page.js +68 -0
- package/dist/decorators/page.js.map +1 -0
- package/dist/decorators/registry.d.ts +11 -0
- package/dist/decorators/registry.d.ts.map +1 -0
- package/dist/decorators/registry.js +29 -0
- package/dist/decorators/registry.js.map +1 -0
- package/dist/decorators/sequence.d.ts +8 -0
- package/dist/decorators/sequence.d.ts.map +1 -0
- package/dist/decorators/sequence.js +22 -0
- package/dist/decorators/sequence.js.map +1 -0
- package/dist/decorators/types.d.ts +30 -0
- package/dist/decorators/types.d.ts.map +1 -0
- package/dist/decorators/types.js +2 -0
- package/dist/decorators/types.js.map +1 -0
- package/dist/define-seo.d.ts +21 -0
- package/dist/define-seo.d.ts.map +1 -0
- package/dist/define-seo.js +31 -0
- package/dist/define-seo.js.map +1 -0
- package/dist/graph/build-entity.d.ts +47 -0
- package/dist/graph/build-entity.d.ts.map +1 -0
- package/dist/graph/build-entity.js +69 -0
- package/dist/graph/build-entity.js.map +1 -0
- package/dist/graph/compose-from-config.d.ts +89 -0
- package/dist/graph/compose-from-config.d.ts.map +1 -0
- package/dist/graph/compose-from-config.js +189 -0
- package/dist/graph/compose-from-config.js.map +1 -0
- package/dist/graph/compose-graph.d.ts +40 -0
- package/dist/graph/compose-graph.d.ts.map +1 -0
- package/dist/graph/compose-graph.js +30 -0
- package/dist/graph/compose-graph.js.map +1 -0
- package/dist/graph/effective-config.d.ts +36 -0
- package/dist/graph/effective-config.d.ts.map +1 -0
- package/dist/graph/effective-config.js +84 -0
- package/dist/graph/effective-config.js.map +1 -0
- package/dist/graph/id-conventions.d.ts +47 -0
- package/dist/graph/id-conventions.d.ts.map +1 -0
- package/dist/graph/id-conventions.js +78 -0
- package/dist/graph/id-conventions.js.map +1 -0
- package/dist/graph/index.d.ts +9 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +4 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/resolve-properties.d.ts +36 -0
- package/dist/graph/resolve-properties.d.ts.map +1 -0
- package/dist/graph/resolve-properties.js +141 -0
- package/dist/graph/resolve-properties.js.map +1 -0
- package/dist/graph/resolve-references.d.ts +14 -0
- package/dist/graph/resolve-references.d.ts.map +1 -0
- package/dist/graph/resolve-references.js +49 -0
- package/dist/graph/resolve-references.js.map +1 -0
- package/dist/graph/typed-value.d.ts +7 -0
- package/dist/graph/typed-value.d.ts.map +1 -0
- package/dist/graph/typed-value.js +43 -0
- package/dist/graph/typed-value.js.map +1 -0
- package/dist/graph/types.d.ts +34 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +2 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/graph/value-scope.d.ts +19 -0
- package/dist/graph/value-scope.d.ts.map +1 -0
- package/dist/graph/value-scope.js +30 -0
- package/dist/graph/value-scope.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/json-ld.d.ts +24 -0
- package/dist/json-ld.d.ts.map +1 -0
- package/dist/json-ld.js +24 -0
- package/dist/json-ld.js.map +1 -0
- package/dist/profiles/bing.d.ts +10 -0
- package/dist/profiles/bing.d.ts.map +1 -0
- package/dist/profiles/bing.js +13 -0
- package/dist/profiles/bing.js.map +1 -0
- package/dist/profiles/check.d.ts +11 -0
- package/dist/profiles/check.d.ts.map +1 -0
- package/dist/profiles/check.js +66 -0
- package/dist/profiles/check.js.map +1 -0
- package/dist/profiles/eligibility.d.ts +26 -0
- package/dist/profiles/eligibility.d.ts.map +1 -0
- package/dist/profiles/eligibility.js +49 -0
- package/dist/profiles/eligibility.js.map +1 -0
- package/dist/profiles/google.d.ts +4 -0
- package/dist/profiles/google.d.ts.map +1 -0
- package/dist/profiles/google.js +387 -0
- package/dist/profiles/google.js.map +1 -0
- package/dist/profiles/index.d.ts +10 -0
- package/dist/profiles/index.d.ts.map +1 -0
- package/dist/profiles/index.js +13 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/registry.d.ts +16 -0
- package/dist/profiles/registry.d.ts.map +1 -0
- package/dist/profiles/registry.js +66 -0
- package/dist/profiles/registry.js.map +1 -0
- package/dist/profiles/types.d.ts +29 -0
- package/dist/profiles/types.d.ts.map +1 -0
- package/dist/profiles/types.js +2 -0
- package/dist/profiles/types.js.map +1 -0
- package/dist/seo-graph.d.ts +39 -0
- package/dist/seo-graph.d.ts.map +1 -0
- package/dist/seo-graph.js +34 -0
- package/dist/seo-graph.js.map +1 -0
- package/dist/types/built-in/content.d.ts +12 -0
- package/dist/types/built-in/content.d.ts.map +1 -0
- package/dist/types/built-in/content.js +79 -0
- package/dist/types/built-in/content.js.map +1 -0
- package/dist/types/built-in/events.d.ts +23 -0
- package/dist/types/built-in/events.d.ts.map +1 -0
- package/dist/types/built-in/events.js +93 -0
- package/dist/types/built-in/events.js.map +1 -0
- package/dist/types/built-in/index.d.ts +4 -0
- package/dist/types/built-in/index.d.ts.map +1 -0
- package/dist/types/built-in/index.js +26 -0
- package/dist/types/built-in/index.js.map +1 -0
- package/dist/types/built-in/media.d.ts +21 -0
- package/dist/types/built-in/media.d.ts.map +1 -0
- package/dist/types/built-in/media.js +104 -0
- package/dist/types/built-in/media.js.map +1 -0
- package/dist/types/built-in/site.d.ts +14 -0
- package/dist/types/built-in/site.d.ts.map +1 -0
- package/dist/types/built-in/site.js +35 -0
- package/dist/types/built-in/site.js.map +1 -0
- package/dist/types/context.d.ts +26 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +44 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/definition.d.ts +58 -0
- package/dist/types/definition.d.ts.map +1 -0
- package/dist/types/definition.js +2 -0
- package/dist/types/definition.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/registry.d.ts +14 -0
- package/dist/types/registry.d.ts.map +1 -0
- package/dist/types/registry.js +37 -0
- package/dist/types/registry.js.map +1 -0
- package/dist/types/values.d.ts +23 -0
- package/dist/types/values.d.ts.map +1 -0
- package/dist/types/values.js +52 -0
- package/dist/types/values.js.map +1 -0
- package/dist/validate/check-terms.d.ts +15 -0
- package/dist/validate/check-terms.d.ts.map +1 -0
- package/dist/validate/check-terms.js +42 -0
- package/dist/validate/check-terms.js.map +1 -0
- package/dist/validate/check-value.d.ts +19 -0
- package/dist/validate/check-value.d.ts.map +1 -0
- package/dist/validate/check-value.js +77 -0
- package/dist/validate/check-value.js.map +1 -0
- package/dist/validate/graph-nodes.d.ts +22 -0
- package/dist/validate/graph-nodes.d.ts.map +1 -0
- package/dist/validate/graph-nodes.js +50 -0
- package/dist/validate/graph-nodes.js.map +1 -0
- package/dist/validate/index.d.ts +4 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +2 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/types.d.ts +22 -0
- package/dist/validate/types.d.ts.map +1 -0
- package/dist/validate/types.js +2 -0
- package/dist/validate/types.js.map +1 -0
- package/dist/validate/validate-graph.d.ts +18 -0
- package/dist/validate/validate-graph.d.ts.map +1 -0
- package/dist/validate/validate-graph.js +109 -0
- package/dist/validate/validate-graph.js.map +1 -0
- package/dist/vocabulary/datatypes.d.ts +7 -0
- package/dist/vocabulary/datatypes.d.ts.map +1 -0
- package/dist/vocabulary/datatypes.js +46 -0
- package/dist/vocabulary/datatypes.js.map +1 -0
- package/dist/vocabulary/index.d.ts +5 -0
- package/dist/vocabulary/index.d.ts.map +1 -0
- package/dist/vocabulary/index.js +4 -0
- package/dist/vocabulary/index.js.map +1 -0
- package/dist/vocabulary/schemaorg.generated.d.ts +4 -0
- package/dist/vocabulary/schemaorg.generated.d.ts.map +1 -0
- package/dist/vocabulary/schemaorg.generated.js +3038 -0
- package/dist/vocabulary/schemaorg.generated.js.map +1 -0
- package/dist/vocabulary/types.d.ts +38 -0
- package/dist/vocabulary/types.d.ts.map +1 -0
- package/dist/vocabulary/types.js +2 -0
- package/dist/vocabulary/types.js.map +1 -0
- package/dist/vocabulary/vocabulary.d.ts +28 -0
- package/dist/vocabulary/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary/vocabulary.js +89 -0
- package/dist/vocabulary/vocabulary.js.map +1 -0
- package/package.json +40 -3
- package/README.md +0 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { ComposeFromConfigOptions, DocumentMeta, ResolvedEntity, ResolvedPropertyView, } from './compose-from-config.js';
|
|
2
|
+
export { composeFromConfig, resolvePageEntities } from './compose-from-config.js';
|
|
3
|
+
export type { ComposeGraphOptions } from './compose-graph.js';
|
|
4
|
+
export { composeGraph } from './compose-graph.js';
|
|
5
|
+
export type { ConfigScope, EffectiveSeoConfig, EffectiveSeoEntity, SeoConfigChain, } from './effective-config.js';
|
|
6
|
+
export { resolveEffectiveConfig } from './effective-config.js';
|
|
7
|
+
export type { JsonLdGraph, SchemaEntity, SeoGraphConfig } from './types.js';
|
|
8
|
+
export type { ValueScope } from './value-scope.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACjF,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GACf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3E,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAOjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { EntityLevel, ResolvedProperty, TypeDefinition } from '../types/definition.js';
|
|
2
|
+
import type { SeoGraphConfig } from './types.js';
|
|
3
|
+
/** Values computed from the page and its version history, with how each is computed */
|
|
4
|
+
export interface ComputedValues {
|
|
5
|
+
readonly url?: string | undefined;
|
|
6
|
+
readonly mainEntityOfPage?: string | undefined;
|
|
7
|
+
readonly datePublished?: string | undefined;
|
|
8
|
+
readonly dateModified?: string | undefined;
|
|
9
|
+
readonly inLanguage?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** What the properties of one entity are resolved from */
|
|
12
|
+
export interface PropertyInputs {
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly level: EntityLevel;
|
|
15
|
+
readonly definition?: TypeDefinition | undefined;
|
|
16
|
+
/** Values an editor or developer set on the entity in the SEO configuration */
|
|
17
|
+
readonly configured: Readonly<Record<string, unknown>>;
|
|
18
|
+
/** The document's content fields; empty for site entities */
|
|
19
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
20
|
+
/** Schema.org property (or `Type.property`) → content field */
|
|
21
|
+
readonly fieldMappings?: Readonly<Record<string, string>> | undefined;
|
|
22
|
+
readonly computed: ComputedValues;
|
|
23
|
+
readonly site: SeoGraphConfig;
|
|
24
|
+
}
|
|
25
|
+
/** A site setting entities take values from */
|
|
26
|
+
export type SiteKey = Exclude<keyof SeoGraphConfig, 'domain'>;
|
|
27
|
+
/** The site setting a site entity of the type takes the property's value from, if any */
|
|
28
|
+
export declare function siteSettingFor(type: string, property: string): SiteKey | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the value of every property an entity may carry, each from one
|
|
31
|
+
* source in a fixed order: the SEO settings (an editor's or developer's
|
|
32
|
+
* entry) › a content field › a value computed from the page › the site
|
|
33
|
+
* configuration. Properties with no value anywhere are absent.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveProperties(inputs: PropertyInputs): Map<string, ResolvedProperty>;
|
|
36
|
+
//# sourceMappingURL=resolve-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-properties.d.ts","sourceRoot":"","sources":["../../src/graph/resolve-properties.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAiBhD,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9C,QAA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+
import { getTypeProperties } from '../catalog/properties.js';
|
|
3
|
+
import { isEmpty } from '../types/values.js';
|
|
4
|
+
import { isSubtypeOf } from '../vocabulary/index.js';
|
|
5
|
+
/** Thing and CreativeWork properties — what a type the catalog does not list may carry */
|
|
6
|
+
const CORE_PROPERTIES = [
|
|
7
|
+
'name',
|
|
8
|
+
'alternateName',
|
|
9
|
+
'description',
|
|
10
|
+
'image',
|
|
11
|
+
'sameAs',
|
|
12
|
+
'identifier',
|
|
13
|
+
'headline',
|
|
14
|
+
'author',
|
|
15
|
+
'publisher',
|
|
16
|
+
'keywords',
|
|
17
|
+
'about',
|
|
18
|
+
];
|
|
19
|
+
const COMPUTED_ORIGIN = {
|
|
20
|
+
url: "the page's path",
|
|
21
|
+
mainEntityOfPage: "the page's path",
|
|
22
|
+
datePublished: "the document's first version",
|
|
23
|
+
dateModified: "the document's latest version",
|
|
24
|
+
inLanguage: "the document's locale",
|
|
25
|
+
};
|
|
26
|
+
const ORGANIZATION_IDENTITY = {
|
|
27
|
+
name: 'name',
|
|
28
|
+
url: 'baseUrl',
|
|
29
|
+
logo: 'logo',
|
|
30
|
+
description: 'description',
|
|
31
|
+
alternateName: 'alternateName',
|
|
32
|
+
sameAs: 'sameAs',
|
|
33
|
+
};
|
|
34
|
+
const WEBSITE_IDENTITY = {
|
|
35
|
+
name: 'name',
|
|
36
|
+
url: 'baseUrl',
|
|
37
|
+
inLanguage: 'language',
|
|
38
|
+
alternateName: 'alternateName',
|
|
39
|
+
};
|
|
40
|
+
const PERSON_IDENTITY = { name: 'name', url: 'baseUrl' };
|
|
41
|
+
const PAGE_IDENTITY = { inLanguage: 'language' };
|
|
42
|
+
/**
|
|
43
|
+
* Which site settings an entity takes its values from: a site entity its
|
|
44
|
+
* identity; a document entity, which describes the page's subject, only the
|
|
45
|
+
* site's language.
|
|
46
|
+
*/
|
|
47
|
+
function siteIdentity(type, level) {
|
|
48
|
+
if (level === 'document')
|
|
49
|
+
return PAGE_IDENTITY;
|
|
50
|
+
if (isSubtypeOf(type, 'Organization'))
|
|
51
|
+
return ORGANIZATION_IDENTITY;
|
|
52
|
+
if (isSubtypeOf(type, 'WebSite'))
|
|
53
|
+
return WEBSITE_IDENTITY;
|
|
54
|
+
if (isSubtypeOf(type, 'Person'))
|
|
55
|
+
return PERSON_IDENTITY;
|
|
56
|
+
return PAGE_IDENTITY;
|
|
57
|
+
}
|
|
58
|
+
/** The site setting a site entity of the type takes the property's value from, if any */
|
|
59
|
+
export function siteSettingFor(type, property) {
|
|
60
|
+
return siteIdentity(type, 'site')[property];
|
|
61
|
+
}
|
|
62
|
+
/** Every property a value is resolved for */
|
|
63
|
+
function candidates(inputs, catalog) {
|
|
64
|
+
const { type, definition } = inputs;
|
|
65
|
+
const listed = catalog.map((def) => def.property);
|
|
66
|
+
const mapped = Object.keys(inputs.fieldMappings ?? {})
|
|
67
|
+
.filter((key) => !key.includes('.') || key.startsWith(`${type}.`))
|
|
68
|
+
.map((key) => key.slice(key.indexOf('.') + 1));
|
|
69
|
+
return new Set([
|
|
70
|
+
...(listed.length > 0 || definition ? listed : CORE_PROPERTIES),
|
|
71
|
+
...Object.keys(definition?.fields ?? {}),
|
|
72
|
+
...Object.keys(inputs.configured).filter((key) => !key.startsWith('@')),
|
|
73
|
+
...mapped,
|
|
74
|
+
...Object.keys(siteIdentity(type, inputs.level)),
|
|
75
|
+
...(inputs.level === 'document' ? Object.keys(COMPUTED_ORIGIN) : []),
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
/** Whether a field named after the property competes in the default auto-mappings */
|
|
79
|
+
function competesByName(property) {
|
|
80
|
+
return DEFAULT_AUTO_MAPPINGS.some((m) => m.cmsField === property && m.schemaProperty === property);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Content fields that may hold the property's value, most specific first:
|
|
84
|
+
* explicit mappings, a field named after the property (unless it competes in
|
|
85
|
+
* the default mappings), the definition's alternate fields, then — for an
|
|
86
|
+
* entity describing the page — the default mappings by priority and the
|
|
87
|
+
* catalog's field. A site entity takes no default mapping: a page's title is
|
|
88
|
+
* not the organization's name.
|
|
89
|
+
*/
|
|
90
|
+
function contentFields(property, inputs, def) {
|
|
91
|
+
const mappings = inputs.fieldMappings ?? {};
|
|
92
|
+
const fields = [mappings[`${inputs.type}.${property}`], mappings[property]];
|
|
93
|
+
if (!competesByName(property))
|
|
94
|
+
fields.push(property);
|
|
95
|
+
fields.push(...(inputs.definition?.fields?.[property] ?? []));
|
|
96
|
+
if (inputs.level === 'document') {
|
|
97
|
+
const defaults = DEFAULT_AUTO_MAPPINGS.filter((m) => m.schemaProperty === property);
|
|
98
|
+
fields.push(...[...defaults].sort((a, b) => b.priority - a.priority).map((m) => m.cmsField));
|
|
99
|
+
fields.push(def?.autoMapField);
|
|
100
|
+
}
|
|
101
|
+
return fields.filter((field) => field !== undefined);
|
|
102
|
+
}
|
|
103
|
+
function resolveOne(property, inputs, def) {
|
|
104
|
+
const configured = inputs.configured[property];
|
|
105
|
+
if (!isEmpty(configured))
|
|
106
|
+
return { value: configured, source: 'manual', origin: 'the SEO settings' };
|
|
107
|
+
for (const field of contentFields(property, inputs, def)) {
|
|
108
|
+
const value = inputs.fields[field];
|
|
109
|
+
if (!isEmpty(value))
|
|
110
|
+
return { value, source: 'auto', origin: `the content field "${field}"` };
|
|
111
|
+
}
|
|
112
|
+
if (inputs.level === 'document' && property in COMPUTED_ORIGIN) {
|
|
113
|
+
const key = property;
|
|
114
|
+
const value = inputs.computed[key];
|
|
115
|
+
if (!isEmpty(value))
|
|
116
|
+
return { value, source: 'computed', origin: COMPUTED_ORIGIN[key] };
|
|
117
|
+
}
|
|
118
|
+
const setting = siteIdentity(inputs.type, inputs.level)[property];
|
|
119
|
+
if (setting && !isEmpty(inputs.site[setting])) {
|
|
120
|
+
return { value: inputs.site[setting], source: 'site', origin: `site.${setting}` };
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Resolve the value of every property an entity may carry, each from one
|
|
126
|
+
* source in a fixed order: the SEO settings (an editor's or developer's
|
|
127
|
+
* entry) › a content field › a value computed from the page › the site
|
|
128
|
+
* configuration. Properties with no value anywhere are absent.
|
|
129
|
+
*/
|
|
130
|
+
export function resolveProperties(inputs) {
|
|
131
|
+
const catalog = getTypeProperties(inputs.type);
|
|
132
|
+
const resolved = new Map();
|
|
133
|
+
for (const property of candidates(inputs, catalog)) {
|
|
134
|
+
const def = catalog.find((d) => d.property === property);
|
|
135
|
+
const value = resolveOne(property, inputs, def);
|
|
136
|
+
if (value)
|
|
137
|
+
resolved.set(property, value);
|
|
138
|
+
}
|
|
139
|
+
return resolved;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=resolve-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-properties.js","sourceRoot":"","sources":["../../src/graph/resolve-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGpD,0FAA0F;AAC1F,MAAM,eAAe,GAAG;IACtB,MAAM;IACN,eAAe;IACf,aAAa;IACb,OAAO;IACP,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,WAAW;IACX,UAAU;IACV,OAAO;CACC,CAAA;AAWV,MAAM,eAAe,GAAmD;IACtE,GAAG,EAAE,iBAAiB;IACtB,gBAAgB,EAAE,iBAAiB;IACnC,aAAa,EAAE,8BAA8B;IAC7C,YAAY,EAAE,+BAA+B;IAC7C,UAAU,EAAE,uBAAuB;CACpC,CAAA;AAoBD,MAAM,qBAAqB,GAAsC;IAC/D,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,SAAS;IACd,IAA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QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAA;IACpD,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACnD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAA;QACxD,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;QAC/C,IAAI,KAAK;YAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Finding } from '../validate/types.js';
|
|
2
|
+
import type { ComposedNode } from './build-entity.js';
|
|
3
|
+
import type { SchemaEntity } from './types.js';
|
|
4
|
+
/** Receives what composing a graph changed or could not do */
|
|
5
|
+
export type FindingSink = (finding: Finding) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Make every reference a type definition emits resolve within the graph: a
|
|
8
|
+
* reference whose target is missing points at a site entity of an acceptable
|
|
9
|
+
* type (`site-entity`), or is removed with a finding when the rule says
|
|
10
|
+
* `omit` or nothing fits. References in configured values are left as they
|
|
11
|
+
* are — validation reports them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveReferences(nodes: readonly ComposedNode[], onFinding?: FindingSink | undefined): SchemaEntity[];
|
|
14
|
+
//# sourceMappingURL=resolve-references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-references.d.ts","sourceRoot":"","sources":["../../src/graph/resolve-references.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;AA2CpD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,GAClC,YAAY,EAAE,CAGhB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ref } from '../types/values.js';
|
|
2
|
+
import { idOf, isReference, typesOf } from '../validate/graph-nodes.js';
|
|
3
|
+
import { isSubtypeOf } from '../vocabulary/index.js';
|
|
4
|
+
/** The first site entity of an acceptable type, in the rule's order of preference */
|
|
5
|
+
function siteEntityFor(rule, nodes) {
|
|
6
|
+
for (const type of rule.types) {
|
|
7
|
+
const match = nodes.find((node) => node.level === 'site' && typesOf(node.entity).some((t) => isSubtypeOf(t, type)));
|
|
8
|
+
const id = match ? idOf(match.entity) : undefined;
|
|
9
|
+
if (id)
|
|
10
|
+
return id;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
function resolveNode(node, nodes, defined, onFinding) {
|
|
15
|
+
const entity = { ...node.entity };
|
|
16
|
+
for (const [property, rule] of Object.entries(node.references)) {
|
|
17
|
+
const value = entity[property];
|
|
18
|
+
if (!isReference(value) || defined.has(idOf(value) ?? ''))
|
|
19
|
+
continue;
|
|
20
|
+
const target = rule.resolve === 'site-entity' ? siteEntityFor(rule, nodes) : undefined;
|
|
21
|
+
if (target) {
|
|
22
|
+
entity[property] = ref(target);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
delete entity[property];
|
|
26
|
+
onFinding?.({
|
|
27
|
+
severity: 'warning',
|
|
28
|
+
code: 'unresolved-reference',
|
|
29
|
+
profile: 'schema.org',
|
|
30
|
+
nodeId: entity['@id'],
|
|
31
|
+
type: entity['@type'],
|
|
32
|
+
property,
|
|
33
|
+
message: `"${property}" is left out: the site configures no ${rule.types.join(' or ')}.`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return entity;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Make every reference a type definition emits resolve within the graph: a
|
|
40
|
+
* reference whose target is missing points at a site entity of an acceptable
|
|
41
|
+
* type (`site-entity`), or is removed with a finding when the rule says
|
|
42
|
+
* `omit` or nothing fits. References in configured values are left as they
|
|
43
|
+
* are — validation reports them.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveReferences(nodes, onFinding) {
|
|
46
|
+
const defined = new Set(nodes.map((node) => idOf(node.entity)).filter((id) => id !== undefined));
|
|
47
|
+
return nodes.map((node) => resolveNode(node, nodes, defined, onFinding));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=resolve-references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-references.js","sourceRoot":"","sources":["../../src/graph/resolve-references.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAOpD,qFAAqF;AACrF,SAAS,aAAa,CAAC,IAAmB,EAAE,KAA8B;IACxE,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CACtB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAC1F,CAAA;QACD,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,IAA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CAAA;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA8B,EAC9B,SAAmC;IAEnC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAA;IAChG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A content or configuration value with a `@type` on every node given without
|
|
3
|
+
* one — `offers: { price: '10' }` becomes an Offer — so a nested node is never
|
|
4
|
+
* untyped when its property says what it is.
|
|
5
|
+
*/
|
|
6
|
+
export declare function typedValue(property: string, value: unknown): unknown;
|
|
7
|
+
//# sourceMappingURL=typed-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-value.d.ts","sourceRoot":"","sources":["../../src/graph/typed-value.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAIpE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getVocabularyProperty, isDatatype, isEnumeration } from '../vocabulary/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The type a node given without one takes, for properties whose range offers
|
|
4
|
+
* more than one class — the type search engines document for the property.
|
|
5
|
+
*/
|
|
6
|
+
const PREFERRED_VALUE_TYPES = {
|
|
7
|
+
offers: 'Offer',
|
|
8
|
+
author: 'Person',
|
|
9
|
+
creator: 'Person',
|
|
10
|
+
publisher: 'Organization',
|
|
11
|
+
provider: 'Organization',
|
|
12
|
+
organizer: 'Organization',
|
|
13
|
+
location: 'Place',
|
|
14
|
+
brand: 'Brand',
|
|
15
|
+
review: 'Review',
|
|
16
|
+
};
|
|
17
|
+
/** The single class the property's range admits, or its documented preference */
|
|
18
|
+
function valueType(property) {
|
|
19
|
+
const preferred = PREFERRED_VALUE_TYPES[property];
|
|
20
|
+
if (preferred)
|
|
21
|
+
return preferred;
|
|
22
|
+
const classes = (getVocabularyProperty(property)?.range ?? []).filter((type) => !isDatatype(type) && !isEnumeration(type));
|
|
23
|
+
return classes.length === 1 ? classes[0] : undefined;
|
|
24
|
+
}
|
|
25
|
+
function typeNode(property, value) {
|
|
26
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
27
|
+
return value;
|
|
28
|
+
if ('@type' in value || '@id' in value || '@value' in value)
|
|
29
|
+
return value;
|
|
30
|
+
const type = valueType(property);
|
|
31
|
+
return type ? { '@type': type, ...value } : value;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A content or configuration value with a `@type` on every node given without
|
|
35
|
+
* one — `offers: { price: '10' }` becomes an Offer — so a nested node is never
|
|
36
|
+
* untyped when its property says what it is.
|
|
37
|
+
*/
|
|
38
|
+
export function typedValue(property, value) {
|
|
39
|
+
return Array.isArray(value)
|
|
40
|
+
? value.map((item) => typeNode(property, item))
|
|
41
|
+
: typeNode(property, value);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=typed-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-value.js","sourceRoot":"","sources":["../../src/graph/typed-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEzF;;;GAGG;AACH,MAAM,qBAAqB,GAAqC;IAC9D,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,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AC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A Schema.org entity with standard properties and an open index signature */
|
|
2
|
+
export interface SchemaEntity {
|
|
3
|
+
'@type': string;
|
|
4
|
+
'@id'?: string | undefined;
|
|
5
|
+
name?: string | undefined;
|
|
6
|
+
description?: string | undefined;
|
|
7
|
+
url?: string | undefined;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** Site identity and address for SEO graph generation — the `site` section of the configuration */
|
|
11
|
+
export interface SeoGraphConfig {
|
|
12
|
+
/** Domain name, e.g., 'acme-consulting.example.com' */
|
|
13
|
+
domain: string;
|
|
14
|
+
/** Site name, e.g., 'Acme Consulting' */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Primary language, e.g., 'en' */
|
|
17
|
+
language: string;
|
|
18
|
+
/** Full base URL, e.g., 'https://acme-consulting.example.com' */
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
/** The site's logo, an absolute URL */
|
|
21
|
+
logo?: string | undefined;
|
|
22
|
+
/** What the site or its organization is, in a sentence */
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
/** Another name the site or organization is known by */
|
|
25
|
+
alternateName?: string | undefined;
|
|
26
|
+
/** Profile pages that identify the organization (social, registry, code hosting) */
|
|
27
|
+
sameAs?: readonly string[] | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** The composed JSON-LD graph output */
|
|
30
|
+
export interface JsonLdGraph {
|
|
31
|
+
'@context': 'https://schema.org';
|
|
32
|
+
'@graph': SchemaEntity[];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graph/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,mGAAmG;AACnG,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,oFAAoF;IACpF,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACvC;AAED,wCAAwC;AACxC,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,oBAAoB,CAAA;IAChC,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/graph/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResolvedProperty } from '../types/definition.js';
|
|
2
|
+
import type { ConfigScope } from './effective-config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Where a value a page emits comes from, as an editor sees it: the site, the
|
|
5
|
+
* collection, a URL pattern or the document itself; computed by krantho from
|
|
6
|
+
* the page and its history; or linked — a reference to another entity
|
|
7
|
+
*/
|
|
8
|
+
export type ValueScope = 'site' | ConfigScope | 'computed' | 'linked';
|
|
9
|
+
/**
|
|
10
|
+
* The scope of one resolved value. A value set in the SEO settings comes from
|
|
11
|
+
* the site settings on a site entity, and from the scope that set it on a
|
|
12
|
+
* document entity — the collection when the document has only its
|
|
13
|
+
* collection's (or the default) archetype.
|
|
14
|
+
*/
|
|
15
|
+
export declare function valueScope(resolved: ResolvedProperty, property: string, entity: {
|
|
16
|
+
fromSite: boolean;
|
|
17
|
+
scopes?: Readonly<Record<string, ConfigScope>> | undefined;
|
|
18
|
+
}): ValueScope;
|
|
19
|
+
//# sourceMappingURL=value-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-scope.d.ts","sourceRoot":"","sources":["../../src/graph/value-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;AAarE;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,SAAS,CAAA;CAAE,GACxF,UAAU,CAOZ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Whether a value is a reference (`{ "@id": … }`), or a list of them */
|
|
2
|
+
function isReference(value) {
|
|
3
|
+
if (Array.isArray(value))
|
|
4
|
+
return value.length > 0 && value.every(isReference);
|
|
5
|
+
if (value === null || typeof value !== 'object')
|
|
6
|
+
return false;
|
|
7
|
+
const keys = Object.keys(value);
|
|
8
|
+
return (typeof value['@id'] === 'string' &&
|
|
9
|
+
keys.every((key) => key === '@id' || key === '@type'));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The scope of one resolved value. A value set in the SEO settings comes from
|
|
13
|
+
* the site settings on a site entity, and from the scope that set it on a
|
|
14
|
+
* document entity — the collection when the document has only its
|
|
15
|
+
* collection's (or the default) archetype.
|
|
16
|
+
*/
|
|
17
|
+
export function valueScope(resolved, property, entity) {
|
|
18
|
+
if (isReference(resolved.value))
|
|
19
|
+
return 'linked';
|
|
20
|
+
if (resolved.source === 'computed')
|
|
21
|
+
return 'computed';
|
|
22
|
+
if (resolved.source === 'site')
|
|
23
|
+
return 'site';
|
|
24
|
+
if (resolved.source === 'auto')
|
|
25
|
+
return 'document';
|
|
26
|
+
if (entity.fromSite)
|
|
27
|
+
return 'site';
|
|
28
|
+
return entity.scopes?.[property] ?? 'collection';
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=value-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-scope.js","sourceRoot":"","sources":["../../src/graph/value-scope.ts"],"names":[],"mappings":"AAUA,yEAAyE;AACzE,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IAC7E,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,OAAO,CACL,OAAQ,KAAiC,CAAC,KAAK,CAAC,KAAK,QAAQ;QAC7D,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,CAAC,CACtD,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,QAA0B,EAC1B,QAAgB,EAChB,MAAyF;IAEzF,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAChD,IAAI,QAAQ,CAAC,MAAM,KAAK,UAAU;QAAE,OAAO,UAAU,CAAA;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,MAAM,CAAA;IAC7C,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,UAAU,CAAA;IACjD,IAAI,MAAM,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAA;IAClC,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAA;AAClD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS SEO module — structured data components and graph composition.
|
|
3
|
+
*/
|
|
4
|
+
export { DOCUMENT_SEO_METADATA_SCHEMA } from '@krantho/seo-shared';
|
|
5
|
+
export type { Archetype, ArchetypeConfig, SchemaType } from './archetypes/index.js';
|
|
6
|
+
export { aboutPageArchetype, blogPostArchetype, coursePageArchetype, defineArchetype, eventPageArchetype, homePageArchetype, howToPageArchetype, jobPostingPageArchetype, recipePageArchetype, servicePageArchetype, videoPageArchetype, } from './archetypes/index.js';
|
|
7
|
+
export type { AutoMapping, CatalogCategory, CatalogType, PropertyDef, PropertyImportance, PropertySource, SeoFieldMap, } from './catalog/index.js';
|
|
8
|
+
export { buildSeoFieldMap, CATEGORY_LABELS, DEFAULT_AUTO_MAPPINGS, getAutoMappableProperties, getCatalogByCategory, getCatalogType, getDocumentLevelTypes, getRequiredProperties, getSiteLevelTypes, getTypeProperties, resolveAutoMappings, resolveSeoField, SCHEMA_CATALOG, } from './catalog/index.js';
|
|
9
|
+
export type { ConfigurationFinding, Seo, SeoSettings } from './create-seo.js';
|
|
10
|
+
export { createSeo, SeoConfigurationError } from './create-seo.js';
|
|
11
|
+
export type { Decorator, PageContext, ResolvedStructure } from './decorators/index.js';
|
|
12
|
+
export { BUILT_IN_DECORATORS, breadcrumbDecorator, pageDecorator, pageTypeFor, registerDecorator, registeredDecorators, sequenceDecorator, } from './decorators/index.js';
|
|
13
|
+
export type { SeoExtensions } from './define-seo.js';
|
|
14
|
+
export { defineSeo } from './define-seo.js';
|
|
15
|
+
export type { ComposeFromConfigOptions, ComposeGraphOptions, ConfigScope, DocumentMeta, EffectiveSeoConfig, EffectiveSeoEntity, JsonLdGraph, ResolvedEntity, ResolvedPropertyView, SeoConfigChain, SeoGraphConfig, ValueScope, } from './graph/index.js';
|
|
16
|
+
export { composeFromConfig, composeGraph, resolveEffectiveConfig, resolvePageEntities, } from './graph/index.js';
|
|
17
|
+
export { JsonLd } from './json-ld.js';
|
|
18
|
+
export type { FeatureEligibility, FeatureStatus, ProfileRule, ReaderProfile, } from './profiles/index.js';
|
|
19
|
+
export { BUILT_IN_PROFILES, bingProfile, featureEligibility, getProfile, googleProfile, registeredProfiles, registerProfile, ruleFor, } from './profiles/index.js';
|
|
20
|
+
export type { SEOGraphProps } from './seo-graph.js';
|
|
21
|
+
export { SEOGraph } from './seo-graph.js';
|
|
22
|
+
export type { BuildContext, EntityLevel, ReferenceRule, ResolvedProperty, TypeDefinition, } from './types/index.js';
|
|
23
|
+
export { BUILT_IN_TYPES, getTypeDefinition, registeredTypes, registerType } from './types/index.js';
|
|
24
|
+
export type { Finding, FindingCode, FindingSeverity, ValidateGraphOptions, } from './validate/index.js';
|
|
25
|
+
export { validateGraph } from './validate/index.js';
|
|
26
|
+
export type { Lifecycle } from './vocabulary/index.js';
|
|
27
|
+
export { getVocabularyProperty, getVocabularyType, isPropertyOfType, isSubtypeOf, lifecycleOf, propertiesOf, SCHEMAORG_RELEASE, } from './vocabulary/index.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAClE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEnF,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EAAE,oBAAoB,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7E,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAClE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEtF,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,aAAa,EAAE,MAAM,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dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS SEO module — structured data components and graph composition.
|
|
3
|
+
*/
|
|
4
|
+
export { DOCUMENT_SEO_METADATA_SCHEMA } from '@krantho/seo-shared';
|
|
5
|
+
// Archetypes
|
|
6
|
+
export { aboutPageArchetype, blogPostArchetype, coursePageArchetype, defineArchetype, eventPageArchetype, homePageArchetype, howToPageArchetype, jobPostingPageArchetype, recipePageArchetype, servicePageArchetype, videoPageArchetype, } from './archetypes/index.js';
|
|
7
|
+
// Schema.org type catalog
|
|
8
|
+
export { buildSeoFieldMap, CATEGORY_LABELS, DEFAULT_AUTO_MAPPINGS, getAutoMappableProperties, getCatalogByCategory, getCatalogType, getDocumentLevelTypes, getRequiredProperties, getSiteLevelTypes, getTypeProperties, resolveAutoMappings, resolveSeoField, SCHEMA_CATALOG, } from './catalog/index.js';
|
|
9
|
+
// The SEO subsystem of a site
|
|
10
|
+
export { createSeo, SeoConfigurationError } from './create-seo.js';
|
|
11
|
+
// Page-structure decorators
|
|
12
|
+
export { BUILT_IN_DECORATORS, breadcrumbDecorator, pageDecorator, pageTypeFor, registerDecorator, registeredDecorators, sequenceDecorator, } from './decorators/index.js';
|
|
13
|
+
// A site's own types, readers and decorators
|
|
14
|
+
export { defineSeo } from './define-seo.js';
|
|
15
|
+
// Graph composition
|
|
16
|
+
export { composeFromConfig, composeGraph, resolveEffectiveConfig, resolvePageEntities, } from './graph/index.js';
|
|
17
|
+
// Components
|
|
18
|
+
export { JsonLd } from './json-ld.js';
|
|
19
|
+
// Reader profiles
|
|
20
|
+
export { BUILT_IN_PROFILES, bingProfile, featureEligibility, getProfile, googleProfile, registeredProfiles, registerProfile, ruleFor, } from './profiles/index.js';
|
|
21
|
+
// SEOGraph component
|
|
22
|
+
export { SEOGraph } from './seo-graph.js';
|
|
23
|
+
// Type definitions
|
|
24
|
+
export { BUILT_IN_TYPES, getTypeDefinition, registeredTypes, registerType } from './types/index.js';
|
|
25
|
+
// Validation
|
|
26
|
+
export { validateGraph } from './validate/index.js';
|
|
27
|
+
// Schema.org vocabulary
|
|
28
|
+
export { getVocabularyProperty, getVocabularyType, isPropertyOfType, isSubtypeOf, lifecycleOf, propertiesOf, SCHEMAORG_RELEASE, } from './vocabulary/index.js';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAElE,aAAa;AACb,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAU9B,0BAA0B;AAC1B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAA;AAE3B,8BAA8B;AAC9B,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAElE,4BAA4B;AAC5B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAE9B,6CAA6C;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAe3C,oBAAoB;AACpB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AACzB,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAOrC,kBAAkB;AAClB,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,OAAO,GACR,MAAM,qBAAqB,CAAA;AAE5B,qBAAqB;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAQzC,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAOnG,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,wBAAwB;AACxB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS JSON-LD component — renders Schema.org structured data as a script tag.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the dangerouslySetInnerHTML pattern required by React for
|
|
5
|
+
* script tag content. Applies XSS sanitization automatically.
|
|
6
|
+
*
|
|
7
|
+
* Server component — renders in SSR HTML, no client JS.
|
|
8
|
+
*/
|
|
9
|
+
import type React from 'react';
|
|
10
|
+
interface JsonLdProps {
|
|
11
|
+
/** Schema.org structured data object */
|
|
12
|
+
data: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render a JSON-LD script tag with automatic XSS sanitization.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <JsonLd data={{ '@context': 'https://schema.org', '@type': 'LocalBusiness', name: '...' }} />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function JsonLd({ data }: JsonLdProps): React.ReactElement;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=json-ld.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-ld.d.ts","sourceRoot":"","sources":["../src/json-ld.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,UAAU,WAAW;IACnB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY,CAQhE"}
|
package/dist/json-ld.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* CMS JSON-LD component — renders Schema.org structured data as a script tag.
|
|
4
|
+
*
|
|
5
|
+
* Encapsulates the dangerouslySetInnerHTML pattern required by React for
|
|
6
|
+
* script tag content. Applies XSS sanitization automatically.
|
|
7
|
+
*
|
|
8
|
+
* Server component — renders in SSR HTML, no client JS.
|
|
9
|
+
*/
|
|
10
|
+
import { serializeJsonLd } from '@krantho/seo-shared';
|
|
11
|
+
/**
|
|
12
|
+
* Render a JSON-LD script tag with automatic XSS sanitization.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <JsonLd data={{ '@context': 'https://schema.org', '@type': 'LocalBusiness', name: '...' }} />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function JsonLd({ data }) {
|
|
20
|
+
return (_jsx("script", { type: "application/ld+json",
|
|
21
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: serializeJsonLd escapes `<`, so the JSON cannot end the script tag
|
|
22
|
+
dangerouslySetInnerHTML: { __html: serializeJsonLd(data) } }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=json-ld.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-ld.js","sourceRoot":"","sources":["../src/json-ld.tsx"],"names":[],"mappings":";AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAQrD;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,IAAI,EAAe;IAC1C,OAAO,CACL,iBACE,IAAI,EAAC,qBAAqB;QAC1B,2HAA2H;QAC3H,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,GAC1D,CACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReaderProfile } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bing. Its webmaster guidelines publish no structured-data rule set beyond
|
|
4
|
+
* Schema.org (its help pages render client-side and were not readable
|
|
5
|
+
* programmatically when checked, 2026-10-02), so the profile adds no rules:
|
|
6
|
+
* Bing reads the Schema.org baseline every graph meets. A rule is added only
|
|
7
|
+
* with a source it can cite.
|
|
8
|
+
*/
|
|
9
|
+
export declare const bingProfile: ReaderProfile;
|
|
10
|
+
//# sourceMappingURL=bing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bing.d.ts","sourceRoot":"","sources":["../../src/profiles/bing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,aAIzB,CAAA"}
|