@pantheon-systems/p1-content-validator 2.1.3 → 2.2.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/dist/authority-enforcement.d.ts.map +1 -1
- package/dist/authority-enforcement.js +10 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/localization.d.ts +5 -0
- package/dist/localization.d.ts.map +1 -1
- package/dist/localization.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authority-enforcement.d.ts","sourceRoot":"","sources":["../src/authority-enforcement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,iCAAiC,EAClC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"authority-enforcement.d.ts","sourceRoot":"","sources":["../src/authority-enforcement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAgDpB,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC;IAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA;CAAE,CA4ExC"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { isAuthority, resolveSlotAuthority } from './localization.js';
|
|
1
|
+
import { isAuthority, resolveSlotAuthority, ROOT_SLOT_ID } from './localization.js';
|
|
2
2
|
import { isPlainObject, resolvePropPath } from './guards.js';
|
|
3
3
|
function resolveSlot(path, snapshot) {
|
|
4
|
+
const parts = path.split('.');
|
|
5
|
+
if (parts[0] === 'root' && parts.lastIndexOf('props') === 1) {
|
|
6
|
+
return { slotId: ROOT_SLOT_ID, propsIdx: 1, parts };
|
|
7
|
+
}
|
|
4
8
|
const resolved = resolvePropPath(path, snapshot);
|
|
5
9
|
if (resolved === undefined || typeof resolved.component.props.id !== 'string') {
|
|
6
10
|
return undefined;
|
|
7
11
|
}
|
|
8
12
|
return { slotId: resolved.component.props.id, propsIdx: resolved.propsIdx, parts: resolved.parts };
|
|
9
13
|
}
|
|
14
|
+
function isContentProp(propName) {
|
|
15
|
+
return propName !== 'id' && !propName.startsWith('_');
|
|
16
|
+
}
|
|
10
17
|
export function validateTranslationAuthority(input) {
|
|
11
18
|
const { operations, currentSnapshot, templateSnapshot, authorityOverrides = {}, slotAuthority = {}, severity = 'warning', } = input;
|
|
12
19
|
const diagnostics = [];
|
|
@@ -44,7 +51,7 @@ export function validateTranslationAuthority(input) {
|
|
|
44
51
|
if (!isPlainObject(op.content))
|
|
45
52
|
return;
|
|
46
53
|
for (const propName of Object.keys(op.content)) {
|
|
47
|
-
if (propName
|
|
54
|
+
if (!isContentProp(propName))
|
|
48
55
|
continue;
|
|
49
56
|
if (effectiveAuthority(slotId, propName) === 'canonical') {
|
|
50
57
|
flag(opIndex, `${op.path}.${propName}`, slotId, propName);
|
|
@@ -53,7 +60,7 @@ export function validateTranslationAuthority(input) {
|
|
|
53
60
|
return;
|
|
54
61
|
}
|
|
55
62
|
const propName = parts[propsIdx + 1];
|
|
56
|
-
if (propName
|
|
63
|
+
if (!isContentProp(propName))
|
|
57
64
|
return;
|
|
58
65
|
if (effectiveAuthority(slotId, propName) === 'canonical') {
|
|
59
66
|
flag(opIndex, op.path, slotId, propName);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { validateOps } from './validator.js';
|
|
|
2
2
|
export { fetchRegistry, listRegistryVersions, snapshotToComponentSchema, registryComponentKey, componentNameFromPath, } from './registry.js';
|
|
3
3
|
export { validateDocumentStructure } from './structure-validator.js';
|
|
4
4
|
export { validateTranslationAuthority } from './authority-enforcement.js';
|
|
5
|
-
export { resolveTranslatable, resolveSlotAuthority, resolveSlotAuthorityMap, isAuthority, AUTHORITIES, DEFAULT_AUTHORITY, } from './localization.js';
|
|
5
|
+
export { resolveTranslatable, resolveSlotAuthority, resolveSlotAuthorityMap, isAuthority, AUTHORITIES, DEFAULT_AUTHORITY, ROOT_SLOT_ID, } from './localization.js';
|
|
6
6
|
export type { EditOperation, Authority, ComponentSchema, ComponentField, FieldOption, ValidationError, ValidateInput, FetchRegistryOpts, TemplateComponent, TemplateSnapshot, StructuralConformanceError, ValidateStructureInput, AuthoritySeverity, AuthorityOverrideMap, AuthorityDiagnostic, ValidateTranslationAuthorityInput, } from './types.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export { validateOps } from './validator.js';
|
|
|
2
2
|
export { fetchRegistry, listRegistryVersions, snapshotToComponentSchema, registryComponentKey, componentNameFromPath, } from './registry.js';
|
|
3
3
|
export { validateDocumentStructure } from './structure-validator.js';
|
|
4
4
|
export { validateTranslationAuthority } from './authority-enforcement.js';
|
|
5
|
-
export { resolveTranslatable, resolveSlotAuthority, resolveSlotAuthorityMap, isAuthority, AUTHORITIES, DEFAULT_AUTHORITY, } from './localization.js';
|
|
5
|
+
export { resolveTranslatable, resolveSlotAuthority, resolveSlotAuthorityMap, isAuthority, AUTHORITIES, DEFAULT_AUTHORITY, ROOT_SLOT_ID, } from './localization.js';
|
package/dist/localization.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ import type { Authority } from './types.js';
|
|
|
15
15
|
export declare const AUTHORITIES: readonly ["canonical", "locale"];
|
|
16
16
|
/** The authority a slot falls back to when the template declares none. */
|
|
17
17
|
export declare const DEFAULT_AUTHORITY: Authority;
|
|
18
|
+
/**
|
|
19
|
+
* The slot id root props are keyed by. Authority and translatability are keyed by
|
|
20
|
+
* the slot id of the component owning a prop; root props belong to no component.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ROOT_SLOT_ID = "__root__";
|
|
18
23
|
/** Whether a value is one of the two authorities. */
|
|
19
24
|
export declare function isAuthority(value: unknown): value is Authority;
|
|
20
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../src/localization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAA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AAE,MAAM,GAAG,SAAS,CAGzF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAM5F"}
|
package/dist/localization.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isPlainObject } from './guards.js';
|
|
2
2
|
export const AUTHORITIES = ['canonical', 'locale'];
|
|
3
3
|
export const DEFAULT_AUTHORITY = 'canonical';
|
|
4
|
+
export const ROOT_SLOT_ID = '__root__';
|
|
4
5
|
export function isAuthority(value) {
|
|
5
6
|
return AUTHORITIES.includes(value);
|
|
6
7
|
}
|