@wp-typia/create-workspace-template 0.16.0 → 0.17.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
CHANGED
|
@@ -12,10 +12,13 @@ The generated project starts with an empty `src/blocks/*` workspace shell and is
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
wp-typia add block my-block --template basic
|
|
15
|
+
wp-typia add integration-env local-smoke --wp-env --service docker-compose
|
|
15
16
|
wp-typia add style callout-emphasis --block my-block
|
|
16
17
|
wp-typia add transform quote-to-block --from core/quote --to my-block
|
|
17
18
|
wp-typia add binding-source hero-data
|
|
18
19
|
wp-typia add binding-source hero-data --block my-block --attribute headline
|
|
20
|
+
wp-typia add contract external-retrieve-response --type ExternalRetrieveResponse
|
|
21
|
+
wp-typia add post-meta integration-state --post-type post --type IntegrationStateMeta
|
|
19
22
|
wp-typia add editor-plugin review-workflow --slot sidebar
|
|
20
23
|
wp-typia add editor-plugin seo-notes --slot document-setting-panel
|
|
21
24
|
wp-typia add hooked-block my-block --anchor core/post-content --position after
|
package/README.md.mustache
CHANGED
|
@@ -20,8 +20,8 @@ wp-typia add block counter-card --template persistence --data-storage custom-tab
|
|
|
20
20
|
wp-typia add block faq-stack --template compound --data-storage custom-table --persistence-policy public
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Variations, block styles, transforms, patterns,
|
|
24
|
-
added after the first block exists:
|
|
23
|
+
Variations, block styles, transforms, patterns, REST resources, and post meta
|
|
24
|
+
contracts can also be added after the first block exists:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
wp-typia add variation hero-card --block counter-card
|
|
@@ -29,6 +29,7 @@ wp-typia add style callout-emphasis --block counter-card
|
|
|
29
29
|
wp-typia add transform quote-to-counter --from core/quote --to counter-card
|
|
30
30
|
wp-typia add pattern hero-layout
|
|
31
31
|
wp-typia add rest-resource snapshots --namespace {{namespace}}/v1 --methods list,read,create
|
|
32
|
+
wp-typia add post-meta integration-state --post-type post
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
## Development
|
package/package.json
CHANGED
|
@@ -42,22 +42,65 @@ export interface WorkspaceBindingSourceConfig {
|
|
|
42
42
|
slug: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export interface
|
|
45
|
+
export interface WorkspaceContractConfig {
|
|
46
|
+
schemaFile: string;
|
|
47
|
+
slug: string;
|
|
48
|
+
sourceTypeName: string;
|
|
49
|
+
typesFile: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface WorkspaceRestResourceBaseConfig {
|
|
46
53
|
apiFile: string;
|
|
54
|
+
auth?: 'authenticated' | 'public' | 'public-write-protected';
|
|
55
|
+
bodyTypeName?: string;
|
|
47
56
|
clientFile: string;
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
controllerClass?: string;
|
|
58
|
+
controllerExtends?: string;
|
|
50
59
|
namespace: string;
|
|
51
60
|
openApiFile: string;
|
|
52
|
-
|
|
61
|
+
permissionCallback?: string;
|
|
53
62
|
restManifest?: ReturnType<
|
|
54
63
|
typeof import( '@wp-typia/block-runtime/metadata-core' ).defineEndpointManifest
|
|
55
64
|
>;
|
|
65
|
+
secretFieldName?: string;
|
|
66
|
+
secretStateFieldName?: string;
|
|
56
67
|
slug: string;
|
|
57
68
|
typesFile: string;
|
|
58
69
|
validatorsFile: string;
|
|
59
70
|
}
|
|
60
71
|
|
|
72
|
+
export interface GeneratedWorkspaceRestResourceConfig extends WorkspaceRestResourceBaseConfig {
|
|
73
|
+
dataFile: string;
|
|
74
|
+
methods: Array< 'list' | 'read' | 'create' | 'update' | 'delete' >;
|
|
75
|
+
mode?: 'generated';
|
|
76
|
+
phpFile: string;
|
|
77
|
+
routePattern?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ManualWorkspaceRestResourceConfig extends WorkspaceRestResourceBaseConfig {
|
|
81
|
+
method: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
|
|
82
|
+
methods: [];
|
|
83
|
+
mode: 'manual';
|
|
84
|
+
pathPattern: string;
|
|
85
|
+
queryTypeName: string;
|
|
86
|
+
responseTypeName: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type WorkspaceRestResourceConfig =
|
|
90
|
+
| GeneratedWorkspaceRestResourceConfig
|
|
91
|
+
| ManualWorkspaceRestResourceConfig;
|
|
92
|
+
|
|
93
|
+
export interface WorkspacePostMetaConfig {
|
|
94
|
+
metaKey: string;
|
|
95
|
+
phpFile: string;
|
|
96
|
+
postType: string;
|
|
97
|
+
schemaFile: string;
|
|
98
|
+
showInRest: boolean;
|
|
99
|
+
slug: string;
|
|
100
|
+
sourceTypeName: string;
|
|
101
|
+
typesFile: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
61
104
|
export interface WorkspaceEditorPluginConfig {
|
|
62
105
|
file: string;
|
|
63
106
|
slug: string;
|
|
@@ -95,10 +138,18 @@ export const BINDING_SOURCES: WorkspaceBindingSourceConfig[] = [
|
|
|
95
138
|
// wp-typia add binding-source entries
|
|
96
139
|
];
|
|
97
140
|
|
|
141
|
+
export const CONTRACTS: WorkspaceContractConfig[] = [
|
|
142
|
+
// wp-typia add contract entries
|
|
143
|
+
];
|
|
144
|
+
|
|
98
145
|
export const REST_RESOURCES: WorkspaceRestResourceConfig[] = [
|
|
99
146
|
// wp-typia add rest-resource entries
|
|
100
147
|
];
|
|
101
148
|
|
|
149
|
+
export const POST_META: WorkspacePostMetaConfig[] = [
|
|
150
|
+
// wp-typia add post-meta entries
|
|
151
|
+
];
|
|
152
|
+
|
|
102
153
|
export const EDITOR_PLUGINS: WorkspaceEditorPluginConfig[] = [
|
|
103
154
|
// wp-typia add editor-plugin entries
|
|
104
155
|
];
|
|
@@ -10,8 +10,12 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
BLOCKS,
|
|
13
|
+
CONTRACTS,
|
|
14
|
+
POST_META,
|
|
13
15
|
REST_RESOURCES,
|
|
14
16
|
type WorkspaceBlockConfig,
|
|
17
|
+
type WorkspaceContractConfig,
|
|
18
|
+
type WorkspacePostMetaConfig,
|
|
15
19
|
type WorkspaceRestResourceConfig,
|
|
16
20
|
} from './block-config';
|
|
17
21
|
|
|
@@ -66,6 +70,34 @@ function isWorkspaceRestResource(
|
|
|
66
70
|
);
|
|
67
71
|
}
|
|
68
72
|
|
|
73
|
+
function isWorkspaceStandaloneContract(
|
|
74
|
+
contract: WorkspaceContractConfig
|
|
75
|
+
): contract is WorkspaceContractConfig & {
|
|
76
|
+
schemaFile: string;
|
|
77
|
+
sourceTypeName: string;
|
|
78
|
+
typesFile: string;
|
|
79
|
+
} {
|
|
80
|
+
return (
|
|
81
|
+
typeof contract.schemaFile === 'string' &&
|
|
82
|
+
typeof contract.sourceTypeName === 'string' &&
|
|
83
|
+
typeof contract.typesFile === 'string'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isWorkspacePostMetaContract(
|
|
88
|
+
postMeta: WorkspacePostMetaConfig
|
|
89
|
+
): postMeta is WorkspacePostMetaConfig & {
|
|
90
|
+
schemaFile: string;
|
|
91
|
+
sourceTypeName: string;
|
|
92
|
+
typesFile: string;
|
|
93
|
+
} {
|
|
94
|
+
return (
|
|
95
|
+
typeof postMeta.schemaFile === 'string' &&
|
|
96
|
+
typeof postMeta.sourceTypeName === 'string' &&
|
|
97
|
+
typeof postMeta.typesFile === 'string'
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
69
101
|
async function assertTypeArtifactsCurrent( block: WorkspaceBlockConfig ) {
|
|
70
102
|
const report = await runSyncBlockMetadata(
|
|
71
103
|
{
|
|
@@ -97,13 +129,20 @@ async function assertTypeArtifactsCurrent( block: WorkspaceBlockConfig ) {
|
|
|
97
129
|
async function main() {
|
|
98
130
|
const options = parseCliOptions( process.argv.slice( 2 ) );
|
|
99
131
|
const restBlocks = BLOCKS.filter( isRestEnabledBlock );
|
|
132
|
+
const standaloneContracts = CONTRACTS.filter( isWorkspaceStandaloneContract );
|
|
133
|
+
const postMetaContracts = POST_META.filter( isWorkspacePostMetaContract );
|
|
100
134
|
const restResources = REST_RESOURCES.filter( isWorkspaceRestResource );
|
|
101
135
|
|
|
102
|
-
if (
|
|
136
|
+
if (
|
|
137
|
+
restBlocks.length === 0 &&
|
|
138
|
+
standaloneContracts.length === 0 &&
|
|
139
|
+
postMetaContracts.length === 0 &&
|
|
140
|
+
restResources.length === 0
|
|
141
|
+
) {
|
|
103
142
|
console.log(
|
|
104
143
|
options.check
|
|
105
|
-
? 'ℹ️ No REST-enabled workspace blocks or plugin-level REST resources are registered yet. `sync-rest --check` is already clean.'
|
|
106
|
-
: 'ℹ️ No REST-enabled workspace blocks or plugin-level REST resources are registered yet.'
|
|
144
|
+
? 'ℹ️ No REST-enabled workspace blocks, standalone contracts, post meta contracts, or plugin-level REST resources are registered yet. `sync-rest --check` is already clean.'
|
|
145
|
+
: 'ℹ️ No REST-enabled workspace blocks, standalone contracts, post meta contracts, or plugin-level REST resources are registered yet.'
|
|
107
146
|
);
|
|
108
147
|
return;
|
|
109
148
|
}
|
|
@@ -167,6 +206,32 @@ async function main() {
|
|
|
167
206
|
);
|
|
168
207
|
}
|
|
169
208
|
|
|
209
|
+
for ( const contract of standaloneContracts ) {
|
|
210
|
+
await syncTypeSchemas(
|
|
211
|
+
{
|
|
212
|
+
jsonSchemaFile: contract.schemaFile,
|
|
213
|
+
sourceTypeName: contract.sourceTypeName,
|
|
214
|
+
typesFile: contract.typesFile,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
check: options.check,
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
for ( const postMeta of postMetaContracts ) {
|
|
223
|
+
await syncTypeSchemas(
|
|
224
|
+
{
|
|
225
|
+
jsonSchemaFile: postMeta.schemaFile,
|
|
226
|
+
sourceTypeName: postMeta.sourceTypeName,
|
|
227
|
+
typesFile: postMeta.typesFile,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
check: options.check,
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
170
235
|
for ( const resource of restResources ) {
|
|
171
236
|
const contracts = resource.restManifest.contracts;
|
|
172
237
|
|
|
@@ -218,8 +283,8 @@ async function main() {
|
|
|
218
283
|
|
|
219
284
|
console.log(
|
|
220
285
|
options.check
|
|
221
|
-
? '✅ REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date for workspace blocks and plugin-level resources!'
|
|
222
|
-
: '✅ REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents generated for workspace blocks and plugin-level resources!'
|
|
286
|
+
? '✅ REST contract schemas, standalone schemas, post meta schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date for workspace blocks, standalone contracts, post meta contracts, and plugin-level resources!'
|
|
287
|
+
: '✅ REST contract schemas, standalone schemas, post meta schemas, portable API clients, and endpoint-aware OpenAPI documents generated for workspace blocks, standalone contracts, post meta contracts, and plugin-level resources!'
|
|
223
288
|
);
|
|
224
289
|
}
|
|
225
290
|
|