@wp-typia/block-runtime 0.2.3 → 0.4.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/README.md +10 -10
- package/dist/blocks.d.ts +180 -0
- package/dist/blocks.js +108 -0
- package/dist/defaults.d.ts +25 -1
- package/dist/defaults.js +73 -1
- package/dist/editor.d.ts +33 -1
- package/dist/editor.js +165 -1
- package/dist/identifiers.d.ts +18 -0
- package/dist/identifiers.js +84 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inspector-runtime.d.ts +129 -0
- package/dist/inspector-runtime.js +283 -0
- package/dist/inspector.d.ts +1 -1
- package/dist/inspector.js +1 -1
- package/dist/json-utils.d.ts +10 -0
- package/dist/json-utils.js +12 -0
- package/dist/metadata-analysis.d.ts +11 -0
- package/dist/metadata-analysis.js +285 -0
- package/dist/metadata-core.d.ts +286 -0
- package/dist/metadata-core.js +810 -0
- package/dist/metadata-model.d.ts +84 -0
- package/dist/metadata-model.js +59 -0
- package/dist/metadata-parser.d.ts +53 -0
- package/dist/metadata-parser.js +794 -0
- package/dist/metadata-php-render.d.ts +29 -0
- package/dist/metadata-php-render.js +549 -0
- package/dist/metadata-projection.d.ts +7 -0
- package/dist/metadata-projection.js +233 -0
- package/dist/migration-types.d.ts +53 -0
- package/dist/migration-types.js +1 -0
- package/dist/object-utils.d.ts +2 -0
- package/dist/object-utils.js +7 -0
- package/dist/schema-core.d.ts +267 -0
- package/dist/schema-core.js +597 -0
- package/dist/typia-tags.d.ts +11 -0
- package/dist/typia-tags.js +1 -0
- package/dist/validation.d.ts +53 -1
- package/dist/validation.js +206 -1
- package/package.json +21 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type AttributeKind = "string" | "number" | "boolean" | "array" | "object" | "union";
|
|
6
|
+
export type WordPressAttributeKind = "string" | "number" | "boolean" | "array" | "object";
|
|
7
|
+
export type WordPressAttributeSource = "html" | "text" | "rich-text";
|
|
8
|
+
export interface AttributeConstraints {
|
|
9
|
+
exclusiveMaximum: number | null;
|
|
10
|
+
exclusiveMinimum: number | null;
|
|
11
|
+
format: string | null;
|
|
12
|
+
maxLength: number | null;
|
|
13
|
+
maxItems: number | null;
|
|
14
|
+
maximum: number | null;
|
|
15
|
+
minLength: number | null;
|
|
16
|
+
minItems: number | null;
|
|
17
|
+
minimum: number | null;
|
|
18
|
+
multipleOf: number | null;
|
|
19
|
+
pattern: string | null;
|
|
20
|
+
typeTag: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface AttributeNode {
|
|
23
|
+
constraints: AttributeConstraints;
|
|
24
|
+
defaultValue?: JsonValue;
|
|
25
|
+
enumValues: Array<string | number | boolean> | null;
|
|
26
|
+
items?: AttributeNode;
|
|
27
|
+
kind: AttributeKind;
|
|
28
|
+
path: string;
|
|
29
|
+
properties?: Record<string, AttributeNode>;
|
|
30
|
+
required: boolean;
|
|
31
|
+
union?: AttributeUnion | null;
|
|
32
|
+
wp: {
|
|
33
|
+
selector: string | null;
|
|
34
|
+
source: WordPressAttributeSource | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface AttributeUnion {
|
|
38
|
+
branches: Record<string, AttributeNode>;
|
|
39
|
+
discriminator: string;
|
|
40
|
+
}
|
|
41
|
+
export interface BlockJsonAttribute {
|
|
42
|
+
default?: JsonValue;
|
|
43
|
+
enum?: Array<string | number | boolean>;
|
|
44
|
+
selector?: string;
|
|
45
|
+
source?: WordPressAttributeSource;
|
|
46
|
+
type: WordPressAttributeKind;
|
|
47
|
+
}
|
|
48
|
+
export interface ManifestAttribute {
|
|
49
|
+
typia: {
|
|
50
|
+
constraints: AttributeConstraints;
|
|
51
|
+
defaultValue: JsonValue | null;
|
|
52
|
+
hasDefault: boolean;
|
|
53
|
+
};
|
|
54
|
+
ts: {
|
|
55
|
+
items: ManifestAttribute | null;
|
|
56
|
+
kind: AttributeKind;
|
|
57
|
+
properties: Record<string, ManifestAttribute> | null;
|
|
58
|
+
required: boolean;
|
|
59
|
+
union: ManifestUnion | null;
|
|
60
|
+
};
|
|
61
|
+
wp: {
|
|
62
|
+
defaultValue: JsonValue | null;
|
|
63
|
+
enum: Array<string | number | boolean> | null;
|
|
64
|
+
hasDefault: boolean;
|
|
65
|
+
selector?: string | null;
|
|
66
|
+
source?: WordPressAttributeSource | null;
|
|
67
|
+
type: WordPressAttributeKind;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface ManifestUnion {
|
|
71
|
+
branches: Record<string, ManifestAttribute>;
|
|
72
|
+
discriminator: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ManifestDocument {
|
|
75
|
+
attributes: Record<string, ManifestAttribute>;
|
|
76
|
+
manifestVersion: 2;
|
|
77
|
+
sourceType: string;
|
|
78
|
+
}
|
|
79
|
+
export declare function defaultAttributeConstraints(): AttributeConstraints;
|
|
80
|
+
export declare function getWordPressKind(node: AttributeNode): WordPressAttributeKind;
|
|
81
|
+
export declare function baseNode(kind: AttributeKind, pathLabel: string): AttributeNode;
|
|
82
|
+
export declare function withRequired(node: AttributeNode, required: boolean): AttributeNode;
|
|
83
|
+
export declare function cloneUnion(union: AttributeUnion): AttributeUnion;
|
|
84
|
+
export declare function cloneProperties(properties: Record<string, AttributeNode>): Record<string, AttributeNode>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export function defaultAttributeConstraints() {
|
|
2
|
+
return {
|
|
3
|
+
exclusiveMaximum: null,
|
|
4
|
+
exclusiveMinimum: null,
|
|
5
|
+
format: null,
|
|
6
|
+
maxLength: null,
|
|
7
|
+
maxItems: null,
|
|
8
|
+
maximum: null,
|
|
9
|
+
minLength: null,
|
|
10
|
+
minItems: null,
|
|
11
|
+
minimum: null,
|
|
12
|
+
multipleOf: null,
|
|
13
|
+
pattern: null,
|
|
14
|
+
typeTag: null,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function getWordPressKind(node) {
|
|
18
|
+
return node.kind === "union" ? "object" : node.kind;
|
|
19
|
+
}
|
|
20
|
+
export function baseNode(kind, pathLabel) {
|
|
21
|
+
return {
|
|
22
|
+
constraints: defaultAttributeConstraints(),
|
|
23
|
+
enumValues: null,
|
|
24
|
+
kind,
|
|
25
|
+
path: pathLabel,
|
|
26
|
+
required: true,
|
|
27
|
+
union: null,
|
|
28
|
+
wp: {
|
|
29
|
+
selector: null,
|
|
30
|
+
source: null,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function withRequired(node, required) {
|
|
35
|
+
return {
|
|
36
|
+
...node,
|
|
37
|
+
items: node.items
|
|
38
|
+
? withRequired(node.items, node.items.required)
|
|
39
|
+
: undefined,
|
|
40
|
+
properties: node.properties ? cloneProperties(node.properties) : undefined,
|
|
41
|
+
required,
|
|
42
|
+
union: node.union ? cloneUnion(node.union) : null,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function cloneUnion(union) {
|
|
46
|
+
return {
|
|
47
|
+
branches: Object.fromEntries(Object.entries(union.branches).map(([key, branch]) => [
|
|
48
|
+
key,
|
|
49
|
+
withRequired(branch, branch.required),
|
|
50
|
+
])),
|
|
51
|
+
discriminator: union.discriminator,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function cloneProperties(properties) {
|
|
55
|
+
return Object.fromEntries(Object.entries(properties).map(([key, node]) => [
|
|
56
|
+
key,
|
|
57
|
+
withRequired(node, node.required),
|
|
58
|
+
]));
|
|
59
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { type AnalysisContext } from "./metadata-analysis.js";
|
|
3
|
+
import { type AttributeNode } from "./metadata-model.js";
|
|
4
|
+
/**
|
|
5
|
+
* Analyze one named source type from a TypeScript module.
|
|
6
|
+
*
|
|
7
|
+
* @param options Metadata analysis options including the project root, source
|
|
8
|
+
* type name, and types file path.
|
|
9
|
+
* @returns The resolved project root plus the parsed root attribute node for
|
|
10
|
+
* the requested source type.
|
|
11
|
+
*/
|
|
12
|
+
export declare function analyzeSourceType(options: {
|
|
13
|
+
projectRoot?: string;
|
|
14
|
+
sourceTypeName: string;
|
|
15
|
+
typesFile: string;
|
|
16
|
+
}): {
|
|
17
|
+
projectRoot: string;
|
|
18
|
+
rootNode: AttributeNode;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Analyze multiple named source types from a TypeScript module.
|
|
22
|
+
*
|
|
23
|
+
* @param options Metadata analysis options including the optional project root
|
|
24
|
+
* and the relative types file path to parse.
|
|
25
|
+
* @param sourceTypeNames Exported type or interface names to resolve from the
|
|
26
|
+
* configured types file.
|
|
27
|
+
* @returns A record keyed by source type name with parsed attribute-node trees
|
|
28
|
+
* for each requested type.
|
|
29
|
+
*/
|
|
30
|
+
export declare function analyzeSourceTypes(options: {
|
|
31
|
+
projectRoot?: string;
|
|
32
|
+
typesFile: string;
|
|
33
|
+
}, sourceTypeNames: string[]): Record<string, AttributeNode>;
|
|
34
|
+
/**
|
|
35
|
+
* Parse an interface or type alias declaration into one attribute-node tree.
|
|
36
|
+
*
|
|
37
|
+
* @param declaration TypeScript declaration node to parse.
|
|
38
|
+
* @param ctx Shared analysis context used for type resolution and recursion
|
|
39
|
+
* detection.
|
|
40
|
+
* @param pathLabel Human-readable path label for diagnostics.
|
|
41
|
+
* @param required Whether the resulting node should be marked as required.
|
|
42
|
+
* @returns The parsed attribute-node representation for the declaration.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseNamedDeclaration(declaration: ts.InterfaceDeclaration | ts.TypeAliasDeclaration, ctx: AnalysisContext, pathLabel: string, required: boolean): AttributeNode;
|
|
45
|
+
/**
|
|
46
|
+
* Parse one TypeScript type node into the internal metadata model.
|
|
47
|
+
*
|
|
48
|
+
* @param node TypeScript AST node describing the source type shape.
|
|
49
|
+
* @param ctx Shared analysis context used for symbol and type resolution.
|
|
50
|
+
* @param pathLabel Human-readable path label used in parse errors and warnings.
|
|
51
|
+
* @returns The parsed attribute-node representation of the provided type node.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseTypeNode(node: ts.TypeNode, ctx: AnalysisContext, pathLabel: string): AttributeNode;
|