@wp-typia/project-tools 0.16.10 → 0.16.12
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 +9 -3
- package/dist/runtime/built-in-block-artifact-documents.d.ts +3 -0
- package/dist/runtime/built-in-block-artifact-documents.js +2 -0
- package/dist/runtime/built-in-block-artifact-types.d.ts +51 -0
- package/dist/runtime/built-in-block-artifact-types.js +304 -0
- package/dist/runtime/built-in-block-artifacts.js +4 -803
- package/dist/runtime/built-in-block-attribute-emitters.d.ts +71 -0
- package/dist/runtime/built-in-block-attribute-emitters.js +176 -0
- package/dist/runtime/built-in-block-attribute-specs.d.ts +38 -0
- package/dist/runtime/built-in-block-attribute-specs.js +358 -0
- package/dist/runtime/built-in-block-code-templates/basic.d.ts +4 -0
- package/dist/runtime/built-in-block-code-templates/basic.js +249 -0
- package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +4 -0
- package/dist/runtime/built-in-block-code-templates/compound-child.js +138 -0
- package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +6 -0
- package/dist/runtime/built-in-block-code-templates/compound-parent.js +227 -0
- package/dist/runtime/built-in-block-code-templates/compound-persistence.d.ts +4 -0
- package/dist/runtime/built-in-block-code-templates/compound-persistence.js +478 -0
- package/dist/runtime/built-in-block-code-templates/compound.d.ts +3 -0
- package/dist/runtime/built-in-block-code-templates/compound.js +3 -0
- package/dist/runtime/built-in-block-code-templates/interactivity.d.ts +5 -0
- package/dist/runtime/built-in-block-code-templates/interactivity.js +547 -0
- package/dist/runtime/built-in-block-code-templates/persistence.d.ts +5 -0
- package/dist/runtime/built-in-block-code-templates/persistence.js +550 -0
- package/dist/runtime/built-in-block-code-templates/shared.d.ts +16 -0
- package/dist/runtime/built-in-block-code-templates/shared.js +53 -0
- package/dist/runtime/built-in-block-code-templates.d.ts +5 -32
- package/dist/runtime/built-in-block-code-templates.js +5 -2230
- package/dist/runtime/cli-add-block-config.d.ts +6 -0
- package/dist/runtime/cli-add-block-config.js +143 -0
- package/dist/runtime/cli-add-block-legacy-validator.d.ts +4 -0
- package/dist/runtime/cli-add-block-legacy-validator.js +168 -0
- package/dist/runtime/cli-add-block.js +3 -301
- package/dist/runtime/cli-add-workspace-assets.d.ts +38 -0
- package/dist/runtime/cli-add-workspace-assets.js +399 -0
- package/dist/runtime/cli-add-workspace.d.ts +2 -38
- package/dist/runtime/cli-add-workspace.js +5 -396
- package/dist/runtime/cli-doctor-environment.d.ts +12 -0
- package/dist/runtime/cli-doctor-environment.js +123 -0
- package/dist/runtime/cli-doctor-workspace.d.ts +14 -0
- package/dist/runtime/cli-doctor-workspace.js +296 -0
- package/dist/runtime/cli-doctor.d.ts +4 -2
- package/dist/runtime/cli-doctor.js +10 -405
- package/dist/runtime/cli-help.js +1 -1
- package/dist/runtime/cli-scaffold.js +1 -1
- package/dist/runtime/migration-command-surface.d.ts +67 -0
- package/dist/runtime/migration-command-surface.js +189 -0
- package/dist/runtime/migration-diff-rename.d.ts +13 -0
- package/dist/runtime/migration-diff-rename.js +192 -0
- package/dist/runtime/migration-diff-transform.d.ts +14 -0
- package/dist/runtime/migration-diff-transform.js +105 -0
- package/dist/runtime/migration-diff.js +12 -297
- package/dist/runtime/migration-generated-artifacts.d.ts +3 -0
- package/dist/runtime/migration-generated-artifacts.js +41 -0
- package/dist/runtime/migration-maintenance.d.ts +51 -0
- package/dist/runtime/migration-maintenance.js +380 -0
- package/dist/runtime/migration-planning.d.ts +23 -0
- package/dist/runtime/migration-planning.js +131 -0
- package/dist/runtime/migration-project-config-source.d.ts +6 -0
- package/dist/runtime/migration-project-config-source.js +424 -0
- package/dist/runtime/migration-project-layout-discovery.d.ts +61 -0
- package/dist/runtime/migration-project-layout-discovery.js +337 -0
- package/dist/runtime/migration-project-layout-paths.d.ts +135 -0
- package/dist/runtime/migration-project-layout-paths.js +288 -0
- package/dist/runtime/migration-project-layout.d.ts +3 -0
- package/dist/runtime/migration-project-layout.js +2 -0
- package/dist/runtime/migration-project-workspace.d.ts +47 -0
- package/dist/runtime/migration-project-workspace.js +212 -0
- package/dist/runtime/migration-project.d.ts +4 -94
- package/dist/runtime/migration-project.js +3 -1101
- package/dist/runtime/migration-render-diff-rule.d.ts +5 -0
- package/dist/runtime/migration-render-diff-rule.js +120 -0
- package/dist/runtime/migration-render-execution.d.ts +3 -0
- package/dist/runtime/migration-render-execution.js +428 -0
- package/dist/runtime/migration-render-generated.d.ts +27 -0
- package/dist/runtime/migration-render-generated.js +230 -0
- package/dist/runtime/migration-render-support.d.ts +3 -0
- package/dist/runtime/migration-render-support.js +16 -0
- package/dist/runtime/migration-render.d.ts +3 -33
- package/dist/runtime/migration-render.js +3 -789
- package/dist/runtime/migration-ui-capability.js +1 -1
- package/dist/runtime/migrations.d.ts +24 -118
- package/dist/runtime/migrations.js +12 -700
- package/dist/runtime/scaffold-bootstrap.d.ts +45 -0
- package/dist/runtime/scaffold-bootstrap.js +185 -0
- package/dist/runtime/scaffold-package-manager-files.d.ts +35 -0
- package/dist/runtime/scaffold-package-manager-files.js +79 -0
- package/dist/runtime/scaffold.d.ts +1 -12
- package/dist/runtime/scaffold.js +10 -393
- package/dist/runtime/template-source-contracts.d.ts +81 -0
- package/dist/runtime/template-source-contracts.js +1 -0
- package/dist/runtime/template-source-external.d.ts +21 -0
- package/dist/runtime/template-source-external.js +184 -0
- package/dist/runtime/template-source-locators.d.ts +4 -0
- package/dist/runtime/template-source-locators.js +72 -0
- package/dist/runtime/template-source-normalization.d.ts +7 -0
- package/dist/runtime/template-source-normalization.js +53 -0
- package/dist/runtime/template-source-remote.d.ts +23 -0
- package/dist/runtime/template-source-remote.js +336 -0
- package/dist/runtime/template-source-seeds.d.ts +12 -0
- package/dist/runtime/template-source-seeds.js +243 -0
- package/dist/runtime/template-source.d.ts +4 -86
- package/dist/runtime/template-source.js +9 -828
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -26,6 +26,12 @@ Implementation note:
|
|
|
26
26
|
- The shared implementation now lives in `@wp-typia/block-runtime/schema-core`.
|
|
27
27
|
- Shared manifest/migration contract types now live in
|
|
28
28
|
`@wp-typia/block-runtime/migration-types`.
|
|
29
|
+
- The public `doctor` surface still lives on `@wp-typia/project-tools`, while
|
|
30
|
+
environment and workspace checks now sit behind focused helper modules.
|
|
31
|
+
- These splits are maintainability refactors behind stable public facades. Keep
|
|
32
|
+
importing the documented `@wp-typia/project-tools` and
|
|
33
|
+
`@wp-typia/project-tools/schema-core` surfaces rather than the focused helper
|
|
34
|
+
files directly.
|
|
29
35
|
|
|
30
36
|
Example:
|
|
31
37
|
|
|
@@ -63,9 +69,9 @@ instead of local casts:
|
|
|
63
69
|
The higher-level generator architecture record, including the current phase map
|
|
64
70
|
and the non-mutating `plan -> validate -> render -> apply` tool-facing usage
|
|
65
71
|
model, lives in
|
|
66
|
-
[`docs/block-generator-architecture.md`](
|
|
72
|
+
[`docs/block-generator-architecture.md`](https://imjlk.github.io/wp-typia/architecture/block-generator-architecture/).
|
|
67
73
|
The public non-mutating controller/tool contract now lives in
|
|
68
|
-
[`docs/block-generator-tool-contract.md`](
|
|
74
|
+
[`docs/block-generator-tool-contract.md`](https://imjlk.github.io/wp-typia/architecture/block-generator-tool-contract/).
|
|
69
75
|
|
|
70
76
|
Reusable external layer packages on top of the built-in shared scaffold model
|
|
71
77
|
are now available through the canonical built-in CLI flags
|
|
@@ -73,6 +79,6 @@ are now available through the canonical built-in CLI flags
|
|
|
73
79
|
`wp-typia add block --external-layer-source ... [--external-layer-id ...]`,
|
|
74
80
|
and programmatically through `scaffoldProject(...)`, `BlockGeneratorService`,
|
|
75
81
|
and `inspectBlockGeneration(...)`. The layer contract record lives in
|
|
76
|
-
[`docs/external-template-layer-composition.md`](
|
|
82
|
+
[`docs/external-template-layer-composition.md`](https://imjlk.github.io/wp-typia/architecture/external-template-layer-composition/).
|
|
77
83
|
|
|
78
84
|
If you need metadata sync, editor helpers, validation helpers, or other generated-project runtime utilities, import them directly from `@wp-typia/block-runtime/*`.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, buildBlockJsonAttributes, buildManifestDocument, } from "./built-in-block-attribute-emitters.js";
|
|
2
|
+
export type { AttributeDescription, EmittedAttributeDefinition, } from "./built-in-block-attribute-emitters.js";
|
|
3
|
+
export { buildBasicAttributes, buildCompoundChildAttributes, buildCompoundParentAttributes, buildInteractivityAttributes, buildPersistenceAttributes, } from "./built-in-block-attribute-specs.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, buildBlockJsonAttributes, buildManifestDocument, } from "./built-in-block-attribute-emitters.js";
|
|
2
|
+
export { buildBasicAttributes, buildCompoundChildAttributes, buildCompoundParentAttributes, buildInteractivityAttributes, buildPersistenceAttributes, } from "./built-in-block-attribute-specs.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ScaffoldTemplateVariables } from "./scaffold.js";
|
|
2
|
+
interface AttributeDescription {
|
|
3
|
+
lines: string[];
|
|
4
|
+
}
|
|
5
|
+
interface EmittedAttributeDefinition {
|
|
6
|
+
description?: AttributeDescription;
|
|
7
|
+
name: string;
|
|
8
|
+
optional: boolean;
|
|
9
|
+
typeExpression: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds the generated attributes and validation type source for a basic block scaffold.
|
|
13
|
+
*
|
|
14
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
15
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
16
|
+
* @returns TypeScript source for the basic block attribute and validation types.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildBasicTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Builds the generated attributes, context, and validation type source for an interactivity scaffold.
|
|
21
|
+
*
|
|
22
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
23
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
24
|
+
* @returns TypeScript source for the interactivity block attribute, context, and validation types.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildInteractivityTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* Builds the generated attributes, context, state, client, and validation type source for a persistence scaffold.
|
|
29
|
+
*
|
|
30
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
31
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
32
|
+
* @returns TypeScript source for the persistence block runtime types.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildPersistenceTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the generated attributes and optional persistence runtime type source for a compound parent scaffold.
|
|
37
|
+
*
|
|
38
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
39
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
40
|
+
* @returns TypeScript source for the compound parent runtime types.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildCompoundTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
|
|
43
|
+
/**
|
|
44
|
+
* Builds the generated attributes and validation type source for a compound child scaffold.
|
|
45
|
+
*
|
|
46
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
47
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
48
|
+
* @returns TypeScript source for the compound child attribute and validation types.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildCompoundChildTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
const STANDARD_PREAMBLE_LINES = [
|
|
2
|
+
'import type { TextAlignment } from "@wp-typia/block-types/block-editor/alignment";',
|
|
3
|
+
"import type {",
|
|
4
|
+
"\tTypiaValidationError,",
|
|
5
|
+
"\tValidationResult,",
|
|
6
|
+
'} from "@wp-typia/block-runtime/validation";',
|
|
7
|
+
'import { tags } from "typia";',
|
|
8
|
+
"",
|
|
9
|
+
'export type { TypiaValidationError, ValidationResult } from "@wp-typia/block-runtime/validation";',
|
|
10
|
+
];
|
|
11
|
+
const VALIDATION_ONLY_PREAMBLE_LINES = [
|
|
12
|
+
'import type { ValidationResult } from "@wp-typia/block-runtime/validation";',
|
|
13
|
+
'import { tags } from "typia";',
|
|
14
|
+
"",
|
|
15
|
+
'export type { ValidationResult } from "@wp-typia/block-runtime/validation";',
|
|
16
|
+
];
|
|
17
|
+
function emitDocComment(description, indent = "") {
|
|
18
|
+
if (!description) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return [
|
|
22
|
+
`${indent}/**`,
|
|
23
|
+
...description.lines.map((line) => line.length === 0 ? `${indent} *` : `${indent} * ${line}`),
|
|
24
|
+
`${indent} */`,
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function emitInterface(definition) {
|
|
28
|
+
const lines = [
|
|
29
|
+
...emitDocComment(definition.description),
|
|
30
|
+
`export interface ${definition.name} {`,
|
|
31
|
+
];
|
|
32
|
+
for (const member of definition.members) {
|
|
33
|
+
lines.push(...emitDocComment(member.description, "\t"));
|
|
34
|
+
lines.push(`\t${member.name}${member.optional ? "?" : ""}: ${member.typeExpression};`);
|
|
35
|
+
}
|
|
36
|
+
lines.push("}");
|
|
37
|
+
return lines;
|
|
38
|
+
}
|
|
39
|
+
function emitTypesModule({ preambleLines, interfaces, typeAliases, }) {
|
|
40
|
+
const sections = [];
|
|
41
|
+
if (preambleLines.length > 0) {
|
|
42
|
+
sections.push(preambleLines.join("\n"));
|
|
43
|
+
}
|
|
44
|
+
for (const definition of interfaces) {
|
|
45
|
+
sections.push(emitInterface(definition).join("\n"));
|
|
46
|
+
}
|
|
47
|
+
if (typeAliases.length > 0) {
|
|
48
|
+
sections.push(typeAliases
|
|
49
|
+
.map((alias) => `export type ${alias.name} = ${alias.value};`)
|
|
50
|
+
.join("\n"));
|
|
51
|
+
}
|
|
52
|
+
return `${sections.join("\n\n")}\n`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Builds the generated attributes and validation type source for a basic block scaffold.
|
|
56
|
+
*
|
|
57
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
58
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
59
|
+
* @returns TypeScript source for the basic block attribute and validation types.
|
|
60
|
+
*/
|
|
61
|
+
export function buildBasicTypesSource(variables, attributes) {
|
|
62
|
+
return emitTypesModule({
|
|
63
|
+
preambleLines: [...STANDARD_PREAMBLE_LINES],
|
|
64
|
+
interfaces: [
|
|
65
|
+
{
|
|
66
|
+
description: {
|
|
67
|
+
lines: [
|
|
68
|
+
"Block attributes interface",
|
|
69
|
+
"Typia tags define runtime validation rules",
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
members: attributes.map((attribute) => ({
|
|
73
|
+
description: attribute.description,
|
|
74
|
+
name: attribute.name,
|
|
75
|
+
optional: attribute.optional,
|
|
76
|
+
typeExpression: attribute.typeExpression,
|
|
77
|
+
})),
|
|
78
|
+
name: `${variables.pascalCase}Attributes`,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
typeAliases: [
|
|
82
|
+
{
|
|
83
|
+
name: `${variables.pascalCase}ValidationResult`,
|
|
84
|
+
value: `ValidationResult<${variables.pascalCase}Attributes>`,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Builds the generated attributes, context, and validation type source for an interactivity scaffold.
|
|
91
|
+
*
|
|
92
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
93
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
94
|
+
* @returns TypeScript source for the interactivity block attribute, context, and validation types.
|
|
95
|
+
*/
|
|
96
|
+
export function buildInteractivityTypesSource(variables, attributes) {
|
|
97
|
+
return emitTypesModule({
|
|
98
|
+
preambleLines: [...STANDARD_PREAMBLE_LINES],
|
|
99
|
+
interfaces: [
|
|
100
|
+
{
|
|
101
|
+
members: attributes.map((attribute) => ({
|
|
102
|
+
name: attribute.name,
|
|
103
|
+
optional: attribute.optional,
|
|
104
|
+
typeExpression: attribute.typeExpression,
|
|
105
|
+
})),
|
|
106
|
+
name: `${variables.pascalCase}Attributes`,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
members: [
|
|
110
|
+
{ name: "clicks", typeExpression: "number" },
|
|
111
|
+
{ name: "isAnimating", typeExpression: "boolean" },
|
|
112
|
+
{ name: "isVisible", typeExpression: "boolean" },
|
|
113
|
+
{
|
|
114
|
+
name: "animation",
|
|
115
|
+
typeExpression: '"none" | "bounce" | "pulse" | "shake" | "flip"',
|
|
116
|
+
},
|
|
117
|
+
{ name: "maxClicks", typeExpression: "number" },
|
|
118
|
+
],
|
|
119
|
+
name: `${variables.pascalCase}Context`,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
typeAliases: [
|
|
123
|
+
{
|
|
124
|
+
name: `${variables.pascalCase}ValidationResult`,
|
|
125
|
+
value: `ValidationResult<${variables.pascalCase}Attributes>`,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Builds the generated attributes, context, state, client, and validation type source for a persistence scaffold.
|
|
132
|
+
*
|
|
133
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
134
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
135
|
+
* @returns TypeScript source for the persistence block runtime types.
|
|
136
|
+
*/
|
|
137
|
+
export function buildPersistenceTypesSource(variables, attributes) {
|
|
138
|
+
return emitTypesModule({
|
|
139
|
+
preambleLines: [...STANDARD_PREAMBLE_LINES],
|
|
140
|
+
interfaces: [
|
|
141
|
+
{
|
|
142
|
+
members: attributes.map((attribute) => ({
|
|
143
|
+
name: attribute.name,
|
|
144
|
+
optional: attribute.optional,
|
|
145
|
+
typeExpression: attribute.typeExpression,
|
|
146
|
+
})),
|
|
147
|
+
name: `${variables.pascalCase}Attributes`,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
members: [
|
|
151
|
+
{ name: "buttonLabel", typeExpression: "string" },
|
|
152
|
+
{ name: "bootstrapReady", typeExpression: "boolean" },
|
|
153
|
+
{ name: "canWrite", typeExpression: "boolean" },
|
|
154
|
+
{ name: "count", typeExpression: "number" },
|
|
155
|
+
{ name: "error", typeExpression: "string" },
|
|
156
|
+
{ name: "isBootstrapping", typeExpression: "boolean" },
|
|
157
|
+
{ name: "isLoading", typeExpression: "boolean" },
|
|
158
|
+
{ name: "isSaving", typeExpression: "boolean" },
|
|
159
|
+
{
|
|
160
|
+
name: "persistencePolicy",
|
|
161
|
+
typeExpression: '"authenticated" | "public"',
|
|
162
|
+
},
|
|
163
|
+
{ name: "postId", typeExpression: "number" },
|
|
164
|
+
{ name: "resourceKey", typeExpression: "string" },
|
|
165
|
+
{
|
|
166
|
+
name: "storage",
|
|
167
|
+
typeExpression: '"post-meta" | "custom-table"',
|
|
168
|
+
},
|
|
169
|
+
{ name: "isVisible", typeExpression: "boolean" },
|
|
170
|
+
{
|
|
171
|
+
name: "client",
|
|
172
|
+
optional: true,
|
|
173
|
+
typeExpression: `${variables.pascalCase}ClientState`,
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
name: `${variables.pascalCase}Context`,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
members: [{ name: "isHydrated", typeExpression: "boolean" }],
|
|
180
|
+
name: `${variables.pascalCase}State`,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
members: [
|
|
184
|
+
{ name: "bootstrapError", typeExpression: "string" },
|
|
185
|
+
{ name: "writeExpiry", typeExpression: "number" },
|
|
186
|
+
{ name: "writeNonce", typeExpression: "string" },
|
|
187
|
+
{ name: "writeToken", typeExpression: "string" },
|
|
188
|
+
],
|
|
189
|
+
name: `${variables.pascalCase}ClientState`,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
typeAliases: [
|
|
193
|
+
{
|
|
194
|
+
name: `${variables.pascalCase}ValidationResult`,
|
|
195
|
+
value: `ValidationResult<${variables.pascalCase}Attributes>`,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Builds the generated attributes and optional persistence runtime type source for a compound parent scaffold.
|
|
202
|
+
*
|
|
203
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
204
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
205
|
+
* @returns TypeScript source for the compound parent runtime types.
|
|
206
|
+
*/
|
|
207
|
+
export function buildCompoundTypesSource(variables, attributes) {
|
|
208
|
+
const persistenceEnabled = variables.compoundPersistenceEnabled === "true";
|
|
209
|
+
return emitTypesModule({
|
|
210
|
+
preambleLines: persistenceEnabled
|
|
211
|
+
? [...STANDARD_PREAMBLE_LINES]
|
|
212
|
+
: [...VALIDATION_ONLY_PREAMBLE_LINES],
|
|
213
|
+
interfaces: [
|
|
214
|
+
{
|
|
215
|
+
members: attributes.map((attribute) => ({
|
|
216
|
+
name: attribute.name,
|
|
217
|
+
optional: attribute.optional,
|
|
218
|
+
typeExpression: attribute.typeExpression,
|
|
219
|
+
})),
|
|
220
|
+
name: `${variables.pascalCase}Attributes`,
|
|
221
|
+
},
|
|
222
|
+
...(persistenceEnabled
|
|
223
|
+
? [
|
|
224
|
+
{
|
|
225
|
+
members: [
|
|
226
|
+
{ name: "buttonLabel", typeExpression: "string" },
|
|
227
|
+
{ name: "bootstrapReady", typeExpression: "boolean" },
|
|
228
|
+
{ name: "canWrite", typeExpression: "boolean" },
|
|
229
|
+
{ name: "count", typeExpression: "number" },
|
|
230
|
+
{ name: "error", typeExpression: "string" },
|
|
231
|
+
{ name: "isBootstrapping", typeExpression: "boolean" },
|
|
232
|
+
{ name: "isLoading", typeExpression: "boolean" },
|
|
233
|
+
{ name: "isSaving", typeExpression: "boolean" },
|
|
234
|
+
{
|
|
235
|
+
name: "persistencePolicy",
|
|
236
|
+
typeExpression: '"authenticated" | "public"',
|
|
237
|
+
},
|
|
238
|
+
{ name: "postId", typeExpression: "number" },
|
|
239
|
+
{ name: "resourceKey", typeExpression: "string" },
|
|
240
|
+
{ name: "showCount", typeExpression: "boolean" },
|
|
241
|
+
{
|
|
242
|
+
name: "storage",
|
|
243
|
+
typeExpression: '"post-meta" | "custom-table"',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "client",
|
|
247
|
+
optional: true,
|
|
248
|
+
typeExpression: `${variables.pascalCase}ClientState`,
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
name: `${variables.pascalCase}Context`,
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
members: [{ name: "isHydrated", typeExpression: "boolean" }],
|
|
255
|
+
name: `${variables.pascalCase}State`,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
members: [
|
|
259
|
+
{ name: "bootstrapError", typeExpression: "string" },
|
|
260
|
+
{ name: "writeExpiry", typeExpression: "number" },
|
|
261
|
+
{ name: "writeNonce", typeExpression: "string" },
|
|
262
|
+
{ name: "writeToken", typeExpression: "string" },
|
|
263
|
+
],
|
|
264
|
+
name: `${variables.pascalCase}ClientState`,
|
|
265
|
+
},
|
|
266
|
+
]
|
|
267
|
+
: []),
|
|
268
|
+
],
|
|
269
|
+
typeAliases: [
|
|
270
|
+
{
|
|
271
|
+
name: `${variables.pascalCase}ValidationResult`,
|
|
272
|
+
value: `ValidationResult<${variables.pascalCase}Attributes>`,
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Builds the generated attributes and validation type source for a compound child scaffold.
|
|
279
|
+
*
|
|
280
|
+
* @param variables Resolved scaffold template variables used to name emitted types.
|
|
281
|
+
* @param attributes Emitted built-in attribute definitions that drive the interface members.
|
|
282
|
+
* @returns TypeScript source for the compound child attribute and validation types.
|
|
283
|
+
*/
|
|
284
|
+
export function buildCompoundChildTypesSource(variables, attributes) {
|
|
285
|
+
return emitTypesModule({
|
|
286
|
+
preambleLines: [...VALIDATION_ONLY_PREAMBLE_LINES],
|
|
287
|
+
interfaces: [
|
|
288
|
+
{
|
|
289
|
+
members: attributes.map((attribute) => ({
|
|
290
|
+
name: attribute.name,
|
|
291
|
+
optional: attribute.optional,
|
|
292
|
+
typeExpression: attribute.typeExpression,
|
|
293
|
+
})),
|
|
294
|
+
name: `${variables.pascalCase}ItemAttributes`,
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
typeAliases: [
|
|
298
|
+
{
|
|
299
|
+
name: `${variables.pascalCase}ItemValidationResult`,
|
|
300
|
+
value: `ValidationResult<${variables.pascalCase}ItemAttributes>`,
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
});
|
|
304
|
+
}
|