@wp-typia/project-tools 0.23.0 → 0.23.1
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/runtime/ai-feature-artifacts.js +4 -1
- package/dist/runtime/block-generator-service-spec.js +2 -1
- package/dist/runtime/cli-add-block-json.js +5 -1
- package/dist/runtime/cli-add-help.js +4 -3
- package/dist/runtime/cli-add-types.d.ts +18 -6
- package/dist/runtime/cli-add-validation.d.ts +7 -0
- package/dist/runtime/cli-add-validation.js +9 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +4 -1
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +5 -1
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
- package/dist/runtime/cli-add-workspace-ai-anchors.js +4 -1
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +17 -1
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-integration-env.js +42 -5
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.js +41 -0
- package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-generated.js +158 -0
- package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-manual.js +279 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +24 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.js +678 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +25 -4
- package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
- package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
- package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
- package/dist/runtime/cli-add-workspace-rest.js +33 -788
- package/dist/runtime/cli-core.d.ts +1 -1
- package/dist/runtime/cli-core.js +1 -1
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-workspace-bindings.js +4 -1
- package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
- package/dist/runtime/cli-doctor-workspace-block-addons.js +134 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
- package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
- package/dist/runtime/cli-doctor-workspace-features.js +14 -487
- package/dist/runtime/cli-doctor.d.ts +52 -3
- package/dist/runtime/cli-doctor.js +79 -8
- package/dist/runtime/cli-help.js +6 -3
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-prompt.d.ts +16 -2
- package/dist/runtime/cli-prompt.js +29 -12
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +19 -10
- package/dist/runtime/external-template-guards.js +4 -6
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/json-utils.d.ts +62 -4
- package/dist/runtime/json-utils.js +78 -4
- package/dist/runtime/local-dev-presets.js +4 -1
- package/dist/runtime/migration-ui-capability.js +4 -1
- package/dist/runtime/migration-utils.js +4 -1
- package/dist/runtime/package-managers.js +6 -1
- package/dist/runtime/package-versions.js +6 -1
- package/dist/runtime/scaffold-bootstrap.js +7 -2
- package/dist/runtime/scaffold-package-manager-files.js +5 -1
- package/dist/runtime/scaffold-repository-reference.js +4 -2
- package/dist/runtime/scaffold-template-variables.js +2 -1
- package/dist/runtime/scaffold.d.ts +18 -1
- package/dist/runtime/scaffold.js +55 -2
- package/dist/runtime/temp-roots.js +4 -1
- package/dist/runtime/template-layers.js +4 -1
- package/dist/runtime/template-registry.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.js +18 -5
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/workspace-inventory-mutations.js +2 -1
- package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
- package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
- package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
- package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
- package/dist/runtime/workspace-inventory-parser.js +3 -581
- package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
- package/dist/runtime/workspace-inventory-section-descriptors.js +435 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +1 -1
- package/dist/runtime/workspace-inventory-templates.js +1 -0
- package/dist/runtime/workspace-inventory-types.d.ts +1 -0
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { defineEndpointManifest, syncEndpointClient, syncRestOpenApi, syncTypeSchemas, } from "@wp-typia/block-runtime/metadata-core";
|
|
4
4
|
import { projectWordPressAiSchema } from "./ai-artifacts.js";
|
|
5
5
|
import { isFileNotFoundError } from "./fs-async.js";
|
|
6
|
+
import { readJsonFile } from "./json-utils.js";
|
|
6
7
|
function normalizeGeneratedArtifactContent(content) {
|
|
7
8
|
return content.replace(/\r\n?/g, "\n");
|
|
8
9
|
}
|
|
@@ -120,7 +121,9 @@ export async function syncAiFeatureRestArtifacts({ clientFile, executionOptions,
|
|
|
120
121
|
*/
|
|
121
122
|
export async function syncAiFeatureSchemaArtifact({ aiSchemaFile, check = false, outputDir, projectDir, }) {
|
|
122
123
|
const sourceSchemaPath = path.join(projectDir, outputDir, "api-schemas", "feature-result.schema.json");
|
|
123
|
-
const responseSchema = assertJsonObject(
|
|
124
|
+
const responseSchema = assertJsonObject(await readJsonFile(sourceSchemaPath, {
|
|
125
|
+
context: "AI feature response schema",
|
|
126
|
+
}), sourceSchemaPath);
|
|
124
127
|
const aiSchema = projectWordPressAiSchema(responseSchema);
|
|
125
128
|
await reconcileGeneratedArtifact({
|
|
126
129
|
check,
|
|
@@ -98,7 +98,7 @@ export function createBuiltInBlockSpec({ alternateRenderTargets, answers, dataSt
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
export function buildTemplateVariablesFromBlockSpec(spec) {
|
|
101
|
-
const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, } = getPackageVersions();
|
|
101
|
+
const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, wpTypiaPackageVersion, } = getPackageVersions();
|
|
102
102
|
const slug = spec.block.slug;
|
|
103
103
|
const slugSnakeCase = toSnakeCase(slug);
|
|
104
104
|
const pascalCase = toPascalCase(slug);
|
|
@@ -167,6 +167,7 @@ export function buildTemplateVariablesFromBlockSpec(spec) {
|
|
|
167
167
|
requiresPhp: compatibility.pluginHeader.requiresPhp,
|
|
168
168
|
testedUpTo: compatibility.pluginHeader.testedUpTo,
|
|
169
169
|
projectToolsPackageVersion,
|
|
170
|
+
wpTypiaPackageVersion,
|
|
170
171
|
cssClassName,
|
|
171
172
|
dashCase: slug,
|
|
172
173
|
dataStorageMode,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
|
|
3
3
|
import { readOptionalUtf8File } from "./fs-async.js";
|
|
4
|
+
import { safeJsonParse } from "./json-utils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Resolve an existing workspace block inventory entry by slug.
|
|
6
7
|
*
|
|
@@ -32,7 +33,10 @@ export async function readWorkspaceBlockJson(projectDir, blockSlug) {
|
|
|
32
33
|
}
|
|
33
34
|
let blockJson;
|
|
34
35
|
try {
|
|
35
|
-
blockJson = parseScaffoldBlockMetadata(
|
|
36
|
+
blockJson = parseScaffoldBlockMetadata(safeJsonParse(source, {
|
|
37
|
+
context: "workspace block metadata",
|
|
38
|
+
filePath: blockJsonPath,
|
|
39
|
+
}));
|
|
36
40
|
}
|
|
37
41
|
catch (error) {
|
|
38
42
|
throw new Error(error instanceof Error
|
|
@@ -8,7 +8,7 @@ export function formatAddHelpText() {
|
|
|
8
8
|
return `Usage:
|
|
9
9
|
wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>] [--dry-run]
|
|
10
10
|
wp-typia add block <name> [--template <${ADD_BLOCK_TEMPLATE_IDS.join("|")}>] [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--inner-blocks-preset <freeform|ordered|horizontal|locked-structure>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>] [--dry-run]
|
|
11
|
-
wp-typia add integration-env <name> [--wp-env] [--service <none|docker-compose>] [--dry-run]
|
|
11
|
+
wp-typia add integration-env <name> [--wp-env] [--release-zip] [--service <none|docker-compose>] [--dry-run]
|
|
12
12
|
wp-typia add variation <name> --block <block-slug> [--dry-run]
|
|
13
13
|
wp-typia add style <name> --block <block-slug> [--dry-run]
|
|
14
14
|
wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug> [--dry-run]
|
|
@@ -16,7 +16,7 @@ export function formatAddHelpText() {
|
|
|
16
16
|
wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--dry-run]
|
|
17
17
|
wp-typia add contract <name> [--type <ExportedTypeName>] [--dry-run]
|
|
18
18
|
wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <${REST_RESOURCE_METHOD_IDS.join(",")}>] [--route-pattern <route-pattern>] [--permission-callback <callback>] [--controller-class <ClassName>] [--controller-extends <BaseClass>] [--dry-run]
|
|
19
|
-
wp-typia add rest-resource <name> --manual [--namespace <vendor/v1>] [--method <GET|POST|PUT|PATCH|DELETE>] [--auth <public|authenticated|public-write-protected>] [--path <route-pattern>] [--query-type <Type>] [--body-type <Type>] [--response-type <Type>] [--dry-run]
|
|
19
|
+
wp-typia add rest-resource <name> --manual [--namespace <vendor/v1>] [--method <GET|POST|PUT|PATCH|DELETE>] [--auth <public|authenticated|public-write-protected>] [--path <route-pattern>|--route-pattern <route-pattern>] [--permission-callback <callback>] [--controller-class <ClassName>] [--controller-extends <BaseClass>] [--query-type <Type>] [--body-type <Type>] [--response-type <Type>] [--secret-field <field>] [--secret-state-field|--secret-has-value-field <field>] [--secret-preserve-on-empty <true|false>] [--dry-run]
|
|
20
20
|
wp-typia add post-meta <name> --post-type <post-type> [--type <ExportedTypeName>] [--meta-key <meta-key>] [--hide-from-rest] [--dry-run]
|
|
21
21
|
wp-typia add ability <name> [--dry-run]
|
|
22
22
|
wp-typia add ai-feature <name> [--namespace <vendor/v1>] [--dry-run]
|
|
@@ -32,6 +32,7 @@ Notes:
|
|
|
32
32
|
Pass \`--source core-data:postType/post\` or \`--source core-data:taxonomy/category\` to bind a WordPress-owned entity collection.
|
|
33
33
|
Generated admin-view workspaces add \`@wp-typia/dataviews\` and the needed WordPress DataViews packages as opt-in dependencies.
|
|
34
34
|
\`add integration-env\` generates an opt-in local smoke starter under \`scripts/integration-smoke/\`, updates \`.env.example\`, and can add \`@wordpress/env\` plus \`.wp-env.json\` when \`--wp-env\` is passed.
|
|
35
|
+
Pass \`--release-zip\` to add \`release:zip\`, \`release:zip:check\`, and \`qa:check\` scripts for plugin QA packaging.
|
|
35
36
|
Pass \`--service docker-compose\` to include a placeholder local service stack that can be adapted to project-specific dependencies.
|
|
36
37
|
\`query-loop\` is a create-time scaffold family. Use \`wp-typia create <project-dir> --template query-loop\` instead of \`wp-typia add block\`.
|
|
37
38
|
\`add variation\` targets an existing block slug from \`scripts/block-config.ts\`.
|
|
@@ -41,7 +42,7 @@ Notes:
|
|
|
41
42
|
\`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings/\`; pass \`--block\` and \`--attribute\` together to declare an end-to-end bindable attribute on an existing generated block.
|
|
42
43
|
\`add contract\` registers a standalone TypeScript wire contract under \`src/contracts/\` and generates a stable JSON Schema artifact without creating PHP route glue.
|
|
43
44
|
\`add rest-resource\` scaffolds plugin-level TypeScript REST contracts under \`src/rest/\` and PHP route glue under \`inc/rest/\`. Use \`--route-pattern\`, \`--permission-callback\`, \`--controller-class\`, and \`--controller-extends\` when an existing WordPress controller or permission model needs to own part of the generated route surface.
|
|
44
|
-
Pass \`--manual\` with \`add rest-resource\` to track an external REST route with typed schemas, OpenAPI, clients, and drift checks without generating PHP route/controller files.
|
|
45
|
+
Pass \`--manual\` with \`add rest-resource\` to track an external/provider REST route with typed schemas, OpenAPI, clients, and drift checks without generating PHP route/controller files. Manual routes may still declare \`--permission-callback\`, \`--controller-class\`, and \`--controller-extends\` as metadata for the route owner. Settings contracts can add \`--secret-field\` with \`--secret-preserve-on-empty\` metadata so generated schemas, clients, and admin forms treat blank secret submissions as preserve-by-default.
|
|
45
46
|
\`add post-meta\` scaffolds a typed post meta contract under \`src/post-meta/\`, generates a schema artifact, and wires \`register_post_meta()\` helpers under \`inc/post-meta/\`.
|
|
46
47
|
\`add ability\` scaffolds typed workflow abilities under \`src/abilities/\` and server registration under \`inc/abilities/\`.
|
|
47
48
|
\`add ai-feature\` scaffolds server-owned AI feature endpoints under \`src/ai-features/\` and PHP route glue under \`inc/ai-features/\`.
|
|
@@ -189,17 +189,17 @@ export interface RunAddPostMetaCommandOptions {
|
|
|
189
189
|
* @property auth Optional auth intent for manual mode. Defaults to public.
|
|
190
190
|
* @property bodyTypeName Optional exported TypeScript body type for manual
|
|
191
191
|
* mode. Defaults to `<PascalName>Request` for write methods.
|
|
192
|
-
* @property controllerClass Optional
|
|
193
|
-
*
|
|
192
|
+
* @property controllerClass Optional REST controller class reference. Generated
|
|
193
|
+
* routes delegate through it; manual/provider routes record it as owner metadata.
|
|
194
194
|
* @property controllerExtends Optional base class for the generated controller
|
|
195
|
-
* wrapper
|
|
195
|
+
* wrapper or declared manual/provider controller owner.
|
|
196
196
|
* @property cwd Working directory used to resolve the nearest official workspace.
|
|
197
197
|
* @property manual Whether to scaffold a type-only external REST contract.
|
|
198
198
|
* @property method HTTP method for manual REST contract mode. Defaults to GET.
|
|
199
199
|
* @property methods Optional comma-separated REST method list.
|
|
200
200
|
* @property namespace Optional REST namespace, defaulting to the workspace namespace.
|
|
201
201
|
* @property permissionCallback Optional PHP callback used for generated REST
|
|
202
|
-
* route permission checks.
|
|
202
|
+
* route permission checks or declared manual/provider route ownership.
|
|
203
203
|
* @property pathPattern Route path pattern for manual mode, relative to the
|
|
204
204
|
* namespace. Defaults to `/<name>`.
|
|
205
205
|
* @property queryTypeName Optional exported TypeScript query type for manual
|
|
@@ -207,10 +207,17 @@ export interface RunAddPostMetaCommandOptions {
|
|
|
207
207
|
* @property restResourceName Human-entered resource name normalized into a slug.
|
|
208
208
|
* @property responseTypeName Optional exported TypeScript response type for
|
|
209
209
|
* manual mode. Defaults to `<PascalName>Response`.
|
|
210
|
-
* @property routePattern Optional generated item route pattern,
|
|
211
|
-
*
|
|
210
|
+
* @property routePattern Optional generated item route pattern, or manual
|
|
211
|
+
* provider-route alias for `pathPattern`, relative to the namespace.
|
|
212
|
+
* Generated mode defaults to `/<name>/item`; manual mode defaults to `/<name>`.
|
|
212
213
|
* @property secretFieldName Optional write-only secret field name for manual
|
|
213
214
|
* settings contracts. Requires a request body.
|
|
215
|
+
* @property secretHasValueFieldName Optional alias for `secretStateFieldName`
|
|
216
|
+
* when the response field is a safe presence indicator.
|
|
217
|
+
* @property secretMaskedResponseFieldName Optional alias for
|
|
218
|
+
* `secretStateFieldName` when the response field represents masked state.
|
|
219
|
+
* @property secretPreserveOnEmpty Whether blank secret submissions should
|
|
220
|
+
* preserve the existing value. Defaults to true when `secretFieldName` is set.
|
|
214
221
|
* @property secretStateFieldName Optional masked response boolean field for
|
|
215
222
|
* `secretFieldName`. Defaults to `has<PascalSecretField>`.
|
|
216
223
|
*/
|
|
@@ -231,6 +238,9 @@ export interface RunAddRestResourceCommandOptions {
|
|
|
231
238
|
responseTypeName?: string;
|
|
232
239
|
routePattern?: string;
|
|
233
240
|
secretFieldName?: string;
|
|
241
|
+
secretHasValueFieldName?: string;
|
|
242
|
+
secretMaskedResponseFieldName?: string;
|
|
243
|
+
secretPreserveOnEmpty?: boolean | string;
|
|
234
244
|
secretStateFieldName?: string;
|
|
235
245
|
}
|
|
236
246
|
/**
|
|
@@ -310,12 +320,14 @@ export interface RunAddEditorPluginCommandOptions {
|
|
|
310
320
|
* @property integrationEnvName Human-entered environment name that will be
|
|
311
321
|
* normalized into script and documentation paths.
|
|
312
322
|
* @property service Optional local service starter. Defaults to `none`.
|
|
323
|
+
* @property withReleaseZip Whether to add release zip packaging scripts.
|
|
313
324
|
* @property withWpEnv Whether to add a local `@wordpress/env` preset and scripts.
|
|
314
325
|
*/
|
|
315
326
|
export interface RunAddIntegrationEnvCommandOptions {
|
|
316
327
|
cwd?: string;
|
|
317
328
|
integrationEnvName: string;
|
|
318
329
|
service?: string;
|
|
330
|
+
withReleaseZip?: boolean;
|
|
319
331
|
withWpEnv?: boolean;
|
|
320
332
|
}
|
|
321
333
|
/**
|
|
@@ -110,6 +110,13 @@ export declare function assertValidManualRestContractAuth(auth?: string): Manual
|
|
|
110
110
|
* @returns True when the pattern has no regex groups or uses only `(?P<id>...)`.
|
|
111
111
|
*/
|
|
112
112
|
export declare function isGeneratedRestResourceRoutePatternCompatible(routePattern: string): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Collect unique WordPress named capture parameters from a REST route pattern.
|
|
115
|
+
*
|
|
116
|
+
* @param routePattern Route pattern relative to the namespace.
|
|
117
|
+
* @returns Capture names in first-seen order.
|
|
118
|
+
*/
|
|
119
|
+
export declare function collectRestRouteNamedCaptureNames(routePattern: string): string[];
|
|
113
120
|
export declare function resolveManualRestContractPathPattern(slug: string, pathPattern?: string): string;
|
|
114
121
|
/**
|
|
115
122
|
* Normalize and validate a generated REST resource item route pattern.
|
|
@@ -332,6 +332,15 @@ export function isGeneratedRestResourceRoutePatternCompatible(routePattern) {
|
|
|
332
332
|
return (!hasUnsupportedCapture &&
|
|
333
333
|
(!hasRegexGroup || (namedCaptures.length === 1 && namedCaptures[0] === "id")));
|
|
334
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Collect unique WordPress named capture parameters from a REST route pattern.
|
|
337
|
+
*
|
|
338
|
+
* @param routePattern Route pattern relative to the namespace.
|
|
339
|
+
* @returns Capture names in first-seen order.
|
|
340
|
+
*/
|
|
341
|
+
export function collectRestRouteNamedCaptureNames(routePattern) {
|
|
342
|
+
return Array.from(new Set(Array.from(routePattern.matchAll(REST_ROUTE_NAMED_CAPTURE_PATTERN), (match) => match[1])));
|
|
343
|
+
}
|
|
335
344
|
export function resolveManualRestContractPathPattern(slug, pathPattern) {
|
|
336
345
|
return resolveRestRoutePathPattern({
|
|
337
346
|
defaultPath: `/${slug}`,
|
|
@@ -4,6 +4,7 @@ import { syncTypeSchemas } from "@wp-typia/block-runtime/metadata-core";
|
|
|
4
4
|
import semver from "semver";
|
|
5
5
|
import { appendWorkspaceInventoryEntries, readWorkspaceInventoryAsync, } from "./workspace-inventory.js";
|
|
6
6
|
import { pathExists, readOptionalUtf8File } from "./fs-async.js";
|
|
7
|
+
import { readJsonFile } from "./json-utils.js";
|
|
7
8
|
import { buildAbilityClientSource, buildAbilityConfigEntry, buildAbilityConfigSource, buildAbilityDataSource, buildAbilityPhpSource, buildAbilityRegistrySource, buildAbilitySyncScriptSource, buildAbilityTypesSource, } from "./cli-add-workspace-ability-templates.js";
|
|
8
9
|
import { ABILITY_EDITOR_ASSET, ABILITY_EDITOR_SCRIPT, ABILITY_REGISTRY_END_MARKER, ABILITY_REGISTRY_START_MARKER, ABILITY_SERVER_GLOB, WP_ABILITIES_SCRIPT_MODULE_ID, WP_CORE_ABILITIES_SCRIPT_MODULE_ID, } from "./cli-add-workspace-ability-types.js";
|
|
9
10
|
import { getWorkspaceBootstrapPath, patchFile, } from "./cli-add-shared.js";
|
|
@@ -163,7 +164,9 @@ function ${enqueueFunctionName}() {
|
|
|
163
164
|
}
|
|
164
165
|
async function ensureAbilityPackageScripts(workspace) {
|
|
165
166
|
const packageJsonPath = path.join(workspace.projectDir, "package.json");
|
|
166
|
-
const packageJson =
|
|
167
|
+
const packageJson = await readJsonFile(packageJsonPath, {
|
|
168
|
+
context: "workspace package manifest",
|
|
169
|
+
});
|
|
167
170
|
const nextScripts = {
|
|
168
171
|
...(packageJson.scripts ?? {}),
|
|
169
172
|
"sync-abilities": packageJson.scripts?.["sync-abilities"] ?? "tsx scripts/sync-abilities.ts",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fsp } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { pathExists, readOptionalUtf8File } from './fs-async.js';
|
|
4
|
+
import { safeJsonParse } from './json-utils.js';
|
|
4
5
|
import { appendWorkspaceInventoryEntries, readWorkspaceInventoryAsync, } from './workspace-inventory.js';
|
|
5
6
|
import { buildAdminViewConfigEntry, buildAdminViewConfigSource, buildAdminViewEntrySource, buildAdminViewPhpSource, buildAdminViewRegistrySource, buildAdminViewScreenSource, buildAdminViewStyleSource, buildAdminViewTypesSource, buildCoreDataAdminViewDataSource, buildCoreDataAdminViewScreenSource, buildDefaultAdminViewDataSource, buildRestAdminViewDataSource, buildRestSettingsAdminViewConfigSource, buildRestSettingsAdminViewDataSource, buildRestSettingsAdminViewScreenSource, buildRestSettingsAdminViewTypesSource, } from './cli-add-workspace-admin-view-templates.js';
|
|
6
7
|
import { ADMIN_VIEWS_PHP_GLOB, isAdminViewCoreDataSource, isAdminViewManualSettingsRestResource, } from './cli-add-workspace-admin-view-types.js';
|
|
@@ -60,7 +61,10 @@ async function ensureAdminViewPackageDependencies(workspace, adminViewSource, re
|
|
|
60
61
|
packageName: '@wordpress/data',
|
|
61
62
|
});
|
|
62
63
|
await patchFile(packageJsonPath, (source) => {
|
|
63
|
-
const packageJson =
|
|
64
|
+
const packageJson = safeJsonParse(source, {
|
|
65
|
+
context: 'admin view package manifest',
|
|
66
|
+
filePath: packageJsonPath,
|
|
67
|
+
});
|
|
64
68
|
const needsDataViews = !isAdminViewManualSettingsRestResource(restResource);
|
|
65
69
|
const coreDataDependencies = isAdminViewCoreDataSource(adminViewSource)
|
|
66
70
|
? {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type AdminViewCoreDataSource } from './cli-add-workspace-admin-view-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds TypeScript item and dataset types for a core-data-backed admin view.
|
|
4
|
+
*
|
|
5
|
+
* @param adminViewSlug - Admin-view slug used to derive generated type names.
|
|
6
|
+
* @param coreDataSource - WordPress core-data entity source for the admin view.
|
|
7
|
+
* @returns Generated TypeScript source for core-data admin-view types.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildCoreDataAdminViewTypesSource(adminViewSlug: string, coreDataSource: AdminViewCoreDataSource): string;
|
|
10
|
+
/**
|
|
11
|
+
* Builds a DataViews config module for a core-data-backed admin view.
|
|
12
|
+
*
|
|
13
|
+
* @param adminViewSlug - Admin-view slug used to derive generated identifiers.
|
|
14
|
+
* @param textDomain - WordPress i18n text domain for generated labels.
|
|
15
|
+
* @param coreDataSource - WordPress core-data entity source for field selection.
|
|
16
|
+
* @returns Generated TypeScript source for the core-data DataViews config.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildCoreDataAdminViewConfigSource(adminViewSlug: string, textDomain: string, coreDataSource: AdminViewCoreDataSource): string;
|
|
19
|
+
/**
|
|
20
|
+
* Builds data hooks for loading records from the WordPress core-data store.
|
|
21
|
+
*
|
|
22
|
+
* @param adminViewSlug - Admin-view slug used to derive generated identifiers.
|
|
23
|
+
* @param coreDataSource - WordPress core-data entity source for generated hooks.
|
|
24
|
+
* @returns Generated TypeScript source for core-data data access.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildCoreDataAdminViewDataSource(adminViewSlug: string, coreDataSource: AdminViewCoreDataSource): string;
|
|
27
|
+
/**
|
|
28
|
+
* Builds the React screen module for a core-data-backed admin view.
|
|
29
|
+
*
|
|
30
|
+
* @param adminViewSlug - Admin-view slug used to derive generated identifiers.
|
|
31
|
+
* @param textDomain - WordPress i18n text domain for generated labels.
|
|
32
|
+
* @returns Generated TSX source for the core-data admin-view screen.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildCoreDataAdminViewScreenSource(adminViewSlug: string, textDomain: string): string;
|