Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@json-layout/core

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@json-layout/core - npm Package Compare versions

Comparing version 0.9.3 to 0.10.0

4

package.json
{
"name": "@json-layout/core",
"version": "0.9.3",
"version": "0.10.0",
"description": "Compilation and state management utilities for JSON Layout.",

@@ -62,3 +62,3 @@ "type": "module",

"dependencies": {
"@json-layout/vocabulary": "^0.9.1",
"@json-layout/vocabulary": "^0.10.0",
"@types/markdown-it": "^13.0.1",

@@ -65,0 +65,0 @@ "ajv": "^8.12.0",

@@ -64,2 +64,3 @@ // compileStatic is meant to produce a serializable result

markdown,
optionsKeys: [],
...partialOptions,

@@ -66,0 +67,0 @@ locale,

@@ -36,3 +36,8 @@ // import Debug from 'debug'

if (!normalizedLayouts[pointer]) {
const normalizationResult = normalizeLayoutFragment(/** @type {import('@json-layout/vocabulary').SchemaFragment} */(schema), pointer, options.markdown)
const normalizationResult = normalizeLayoutFragment(
/** @type {import('@json-layout/vocabulary').SchemaFragment} */(schema),
pointer,
options.markdown,
options.optionsKeys
)
normalizedLayouts[pointer] = normalizationResult.layout

@@ -84,2 +89,5 @@ if (normalizationResult.errors.length) {

if (compObject.props !== undefined && !compObject.getProps) compObject.getProps = { type: 'js-eval', expr: 'layout.props', pure: true }
if (compObject.getProps) pushExpression(expressions, compObject.getProps)
if (compObject.transformData) pushExpression(expressions, compObject.transformData)

@@ -99,3 +107,3 @@

/** @type {import('./types.js').SkeletonNode} */
const node = { key: key ?? '', pointer, parentPointer, pure, propertyKeys: [] }
const node = { key: key ?? '', pointer, parentPointer, pure, propertyKeys: [], roPropertyKeys: [] }
if (schema.type === 'object') {

@@ -106,2 +114,3 @@ if (schema.properties) {

node.propertyKeys.push(propertyKey)
if (schema.properties[propertyKey].readOnly) node.roPropertyKeys.push(propertyKey)
node.children.push(makeSkeletonNode(

@@ -141,2 +150,3 @@ schema.properties[propertyKey],

node.propertyKeys = node.propertyKeys.concat(allOfNode.propertyKeys)
node.roPropertyKeys = node.roPropertyKeys.concat(allOfNode.roPropertyKeys)
node.children.push(allOfNode)

@@ -148,3 +158,9 @@ }

if (!normalizedLayouts[oneOfPointer]) {
const normalizationResult = normalizeLayoutFragment(schema, oneOfPointer, options.markdown, 'oneOf')
const normalizationResult = normalizeLayoutFragment(
schema,
oneOfPointer,
options.markdown,
options.optionsKeys,
'oneOf'
)
normalizedLayouts[oneOfPointer] = normalizationResult.layout

@@ -180,3 +196,4 @@ if (normalizationResult.errors.length) {

pure: childrenTrees[0].root.pure,
propertyKeys: []
propertyKeys: [],
roPropertyKeys: []
})

@@ -183,0 +200,0 @@

@@ -26,2 +26,3 @@ import type ajvModule from 'ajv/dist/2019.js'

messages: LocaleMessages
optionsKeys: string[]
}

@@ -59,4 +60,5 @@

propertyKeys: string[]
roPropertyKeys: string[]
children?: SkeletonNode[] // optional children in the case of arrays and object nodes
childrenTrees?: SkeletonTree[] // other trees that can be instantiated with separate validation (for example in the case of new array items of oneOfs, etc)
}

@@ -76,2 +76,3 @@ // eslint-disable-next-line import/no-named-default

autofocus: false,
readOnlyPropertiesMode: 'show',
...partialOptions,

@@ -78,0 +79,0 @@ messages

@@ -67,4 +67,4 @@ import { isSwitchStruct, childIsCompObject, isCompositeLayout, isFocusableLayout } from '@json-layout/vocabulary'

/** @type {(draft: Record<string, unknown>, parentDataPath: string, children?: import('../index.js').StateNode[], additionalPropertiesErrors?: import('ajv').ErrorObject[], propertyKeys?: string[]) => Record<string, unknown>} */
const produceStateNodeData = produce((draft, parentDataPath, children, additionalPropertiesErrors, propertyKeys) => {
/** @type {(draft: Record<string, unknown>, parentDataPath: string, children?: import('../index.js').StateNode[], additionalPropertiesErrors?: import('ajv').ErrorObject[], propertyKeys?: string[], removePropertyKeys?: string[]) => Record<string, unknown>} */
const produceStateNodeData = produce((draft, parentDataPath, children, additionalPropertiesErrors, propertyKeys, removePropertyKeys) => {
if (propertyKeys) {

@@ -75,2 +75,7 @@ for (const key of Object.keys(draft)) {

}
if (removePropertyKeys) {
for (const key of removePropertyKeys) {
delete draft[key]
}
}
if (children) {

@@ -280,2 +285,6 @@ for (const child of children) {

const childLayout = layout.children[i]
if (
['remove', 'hide'].includes(options.readOnlyPropertiesMode) &&
skeleton.roPropertyKeys?.includes(/** @type {string} */(childLayout.key))
) continue
const childSkeleton = skeleton.children?.find(c => c.key === childLayout.key) ?? skeleton

@@ -387,3 +396,4 @@ const isSameData = typeof childLayout.key === 'string' && childLayout.key.startsWith('$')

context.additionalPropertiesErrors,
[true, 'unknown'].includes(options.removeAdditional) ? skeleton.propertyKeys : undefined
[true, 'unknown'].includes(options.removeAdditional) ? skeleton.propertyKeys : undefined,
options.readOnlyPropertiesMode === 'remove' ? skeleton.roPropertyKeys : undefined
)

@@ -390,0 +400,0 @@ : data

@@ -107,11 +107,6 @@ import { type ErrorObject } from 'ajv/dist/2019.js'

// StateNodeOptionsBase come from the vocabulary and should contain all node options that can be set in the layout
export type StateNodeOptions = Required<StateNodeOptionsBase & {
context: Record<string, any>
validateOn: 'input' | 'blur' | 'submit'
initialValidation: 'never' | 'always' | 'withData'
defaultOn: 'missing' | 'empty' | 'never'
// true is the same as 'unknown', false is the same as 'none'
removeAdditional: true | 'unknown' | 'error' | 'none' | false
messages: LocaleMessages
autofocus: boolean
}>

@@ -118,0 +113,0 @@

@@ -97,3 +97,3 @@ import en from '../i18n/en.js'

values: {
never: 'Never use the default data',
never: 'Never use the default data.',
missing: 'The default data is used when the property if not defined in the data.',

@@ -108,5 +108,5 @@ empty: 'The default data is used when the property is either undefined of defined but empty (empty string, empty object, etc.).'

values: {
true: 'Remove all additional properties (alias "unknown")',
error: 'Remove additional properties that cause a validation error',
false: 'Never remove additional properties (alias "none")'
true: 'Remove all additional properties (alias "unknown").',
error: 'Remove additional properties that cause a validation error.',
false: 'Never remove additional properties (alias "none").'
}

@@ -118,3 +118,13 @@ },

default: false
},
{
key: 'readOnlyPropertiesMode',
description: 'Control the way readOnly properties from the schema are managed.',
default: 'show',
values: {
remove: 'Hide the readOnly properties and remove them from the data.',
hide: 'Hide the readOnly properties but keep them in the data.',
show: 'Show the readOnly properties.'
}
}
]

@@ -16,2 +16,3 @@ import type ajvModule from 'ajv/dist/2019.js';

messages: LocaleMessages;
optionsKeys: string[];
}

@@ -43,2 +44,3 @@ export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {

propertyKeys: string[];
roPropertyKeys: string[];
children?: SkeletonNode[];

@@ -45,0 +47,0 @@ childrenTrees?: SkeletonTree[];

@@ -70,8 +70,3 @@ import { type ErrorObject } from 'ajv/dist/2019.js';

context: Record<string, any>;
validateOn: 'input' | 'blur' | 'submit';
initialValidation: 'never' | 'always' | 'withData';
defaultOn: 'missing' | 'empty' | 'never';
removeAdditional: true | 'unknown' | 'error' | 'none' | false;
messages: LocaleMessages;
autofocus: boolean;
}>;

@@ -78,0 +73,0 @@ export type StatefulLayoutOptions = StateNodeOptions & {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc