@wp-typia/project-tools 0.22.3 → 0.22.4

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.
Files changed (40) hide show
  1. package/dist/runtime/cli-add-block-json.d.ts +31 -0
  2. package/dist/runtime/cli-add-block-json.js +65 -0
  3. package/dist/runtime/cli-add-collision.d.ts +129 -0
  4. package/dist/runtime/cli-add-collision.js +293 -0
  5. package/dist/runtime/cli-add-filesystem.d.ts +29 -0
  6. package/dist/runtime/cli-add-filesystem.js +77 -0
  7. package/dist/runtime/cli-add-help.d.ts +4 -0
  8. package/dist/runtime/cli-add-help.js +41 -0
  9. package/dist/runtime/cli-add-shared.d.ts +6 -304
  10. package/dist/runtime/cli-add-shared.js +6 -524
  11. package/dist/runtime/cli-add-types.d.ts +247 -0
  12. package/dist/runtime/cli-add-types.js +64 -0
  13. package/dist/runtime/cli-add-validation.d.ts +87 -0
  14. package/dist/runtime/cli-add-validation.js +147 -0
  15. package/dist/runtime/cli-add-workspace-ability-scaffold.js +46 -72
  16. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +35 -61
  17. package/dist/runtime/cli-add-workspace-ai-scaffold.js +53 -57
  18. package/dist/runtime/cli-add-workspace-ai-templates.js +2 -0
  19. package/dist/runtime/cli-add-workspace-mutation.d.ts +30 -0
  20. package/dist/runtime/cli-add-workspace-mutation.js +60 -0
  21. package/dist/runtime/cli-add-workspace.js +1 -79
  22. package/dist/runtime/cli-add.d.ts +2 -2
  23. package/dist/runtime/cli-add.js +2 -2
  24. package/dist/runtime/cli-doctor-workspace-blocks.js +1 -66
  25. package/dist/runtime/index.d.ts +2 -0
  26. package/dist/runtime/index.js +1 -0
  27. package/dist/runtime/migration-utils.d.ts +2 -1
  28. package/dist/runtime/migration-utils.js +3 -11
  29. package/dist/runtime/package-managers.d.ts +19 -0
  30. package/dist/runtime/package-managers.js +62 -0
  31. package/dist/runtime/template-source-cache.d.ts +59 -0
  32. package/dist/runtime/template-source-cache.js +160 -0
  33. package/dist/runtime/ts-source-masking.d.ts +28 -0
  34. package/dist/runtime/ts-source-masking.js +104 -0
  35. package/dist/runtime/typia-llm.d.ts +9 -1
  36. package/dist/runtime/typia-llm.js +20 -5
  37. package/dist/runtime/workspace-inventory.js +116 -59
  38. package/dist/runtime/workspace-project.d.ts +1 -1
  39. package/dist/runtime/workspace-project.js +2 -10
  40. package/package.json +2 -2
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Supported top-level `wp-typia add` kinds exposed by the canonical CLI.
3
+ */
4
+ export declare const ADD_KIND_IDS: readonly ["admin-view", "block", "variation", "style", "transform", "pattern", "binding-source", "rest-resource", "ability", "ai-feature", "hooked-block", "editor-plugin"];
5
+ /**
6
+ * Union of supported top-level `wp-typia add` kind ids.
7
+ */
8
+ export type AddKindId = (typeof ADD_KIND_IDS)[number];
9
+ /**
10
+ * Supported plugin-level REST resource methods accepted by
11
+ * `wp-typia add rest-resource --methods`.
12
+ */
13
+ export declare const REST_RESOURCE_METHOD_IDS: readonly ["list", "read", "create", "update", "delete"];
14
+ /**
15
+ * Union of supported plugin-level REST resource method ids.
16
+ */
17
+ export type RestResourceMethodId = (typeof REST_RESOURCE_METHOD_IDS)[number];
18
+ /**
19
+ * Canonical editor-plugin shell surface ids accepted by
20
+ * `wp-typia add editor-plugin --slot`.
21
+ */
22
+ export declare const EDITOR_PLUGIN_SLOT_IDS: readonly ["sidebar", "document-setting-panel"];
23
+ /**
24
+ * Union of canonical editor-plugin shell surface ids.
25
+ */
26
+ export type EditorPluginSlotId = (typeof EDITOR_PLUGIN_SLOT_IDS)[number];
27
+ /**
28
+ * Legacy and canonical editor-plugin slot aliases keyed by user-facing input.
29
+ */
30
+ export declare const EDITOR_PLUGIN_SLOT_ALIASES: {
31
+ readonly PluginDocumentSettingPanel: "document-setting-panel";
32
+ readonly PluginSidebar: "sidebar";
33
+ readonly "document-setting-panel": "document-setting-panel";
34
+ readonly sidebar: "sidebar";
35
+ };
36
+ /**
37
+ * Resolve a user-provided editor-plugin slot alias to its canonical id.
38
+ *
39
+ * @param slot Raw slot value from CLI input.
40
+ * @returns The canonical slot id, or `undefined` when unsupported.
41
+ */
42
+ export declare function resolveEditorPluginSlotAlias(slot: string): EditorPluginSlotId | undefined;
43
+ /**
44
+ * Supported built-in block families accepted by `wp-typia add block --template`.
45
+ */
46
+ export declare const ADD_BLOCK_TEMPLATE_IDS: readonly ["basic", "interactivity", "persistence", "compound"];
47
+ /**
48
+ * Union of supported built-in block template ids.
49
+ */
50
+ export type AddBlockTemplateId = (typeof ADD_BLOCK_TEMPLATE_IDS)[number];
51
+ /**
52
+ * Options for `wp-typia add variation`.
53
+ *
54
+ * @property blockName Existing workspace block slug that owns the variation.
55
+ * @property cwd Working directory used to resolve the nearest official workspace.
56
+ * @property variationName Human-entered variation name normalized into a slug.
57
+ */
58
+ export interface RunAddVariationCommandOptions {
59
+ blockName: string;
60
+ cwd?: string;
61
+ variationName: string;
62
+ }
63
+ /**
64
+ * Options for `wp-typia add style`.
65
+ *
66
+ * @property blockName Existing workspace block slug that owns the style.
67
+ * @property cwd Working directory used to resolve the nearest official workspace.
68
+ * Defaults to `process.cwd()`.
69
+ * @property styleName Human-entered style name that will be normalized into the
70
+ * generated style slug.
71
+ */
72
+ export interface RunAddBlockStyleCommandOptions {
73
+ blockName: string;
74
+ cwd?: string;
75
+ styleName: string;
76
+ }
77
+ /**
78
+ * Options for `wp-typia add transform`.
79
+ *
80
+ * @property cwd Working directory used to resolve the nearest official workspace.
81
+ * Defaults to `process.cwd()`.
82
+ * @property fromBlockName Full `namespace/block` source block name accepted by
83
+ * WordPress block transform definitions.
84
+ * @property toBlockName Existing workspace block slug or full block name that
85
+ * owns the generated transform.
86
+ * @property transformName Human-entered transform name that will be normalized
87
+ * into the generated transform slug.
88
+ */
89
+ export interface RunAddBlockTransformCommandOptions {
90
+ cwd?: string;
91
+ fromBlockName: string;
92
+ toBlockName: string;
93
+ transformName: string;
94
+ }
95
+ /**
96
+ * Options for `wp-typia add pattern`.
97
+ *
98
+ * @property cwd Working directory used to resolve the nearest official workspace.
99
+ * @property patternName Human-entered pattern name normalized into a slug.
100
+ */
101
+ export interface RunAddPatternCommandOptions {
102
+ cwd?: string;
103
+ patternName: string;
104
+ }
105
+ /**
106
+ * Options for `wp-typia add binding-source`.
107
+ *
108
+ * @property attributeName Optional block attribute to bind when `blockName` is provided.
109
+ * @property blockName Optional existing workspace block slug or full block name.
110
+ * @property bindingSourceName Human-entered binding source name normalized into a slug.
111
+ * @property cwd Working directory used to resolve the nearest official workspace.
112
+ */
113
+ export interface RunAddBindingSourceCommandOptions {
114
+ attributeName?: string;
115
+ blockName?: string;
116
+ bindingSourceName: string;
117
+ cwd?: string;
118
+ }
119
+ /**
120
+ * Options for `wp-typia add rest-resource`.
121
+ *
122
+ * @property cwd Working directory used to resolve the nearest official workspace.
123
+ * @property methods Optional comma-separated REST method list.
124
+ * @property namespace Optional REST namespace, defaulting to the workspace namespace.
125
+ * @property restResourceName Human-entered resource name normalized into a slug.
126
+ */
127
+ export interface RunAddRestResourceCommandOptions {
128
+ cwd?: string;
129
+ methods?: string;
130
+ namespace?: string;
131
+ restResourceName: string;
132
+ }
133
+ /**
134
+ * Options for `wp-typia add admin-view`.
135
+ *
136
+ * @property adminViewName Human-entered admin screen name that will be
137
+ * normalized into the generated slug.
138
+ * @property cwd Working directory used to resolve the nearest official workspace.
139
+ * Defaults to `process.cwd()`.
140
+ * @property source Optional data source locator. `rest-resource:<slug>` wires
141
+ * the generated screen to an existing list-capable REST resource.
142
+ * `core-data:<kind>/<name>` binds the screen to a supported WordPress-owned
143
+ * entity collection such as `core-data:postType/post`.
144
+ */
145
+ export interface RunAddAdminViewCommandOptions {
146
+ adminViewName: string;
147
+ cwd?: string;
148
+ source?: string;
149
+ }
150
+ /**
151
+ * Options for `wp-typia add ability`.
152
+ *
153
+ * @property cwd Working directory used to resolve the nearest official workspace.
154
+ * Defaults to `process.cwd()`.
155
+ * @property abilityName Human-entered workflow ability name that will be
156
+ * normalized into the generated slug.
157
+ */
158
+ export interface RunAddAbilityCommandOptions {
159
+ abilityName: string;
160
+ cwd?: string;
161
+ }
162
+ /**
163
+ * Options for `wp-typia add ai-feature`.
164
+ *
165
+ * @property aiFeatureName Human-entered AI feature name normalized into a slug.
166
+ * @property cwd Working directory used to resolve the nearest official workspace.
167
+ * @property namespace Optional REST namespace, defaulting to the workspace namespace.
168
+ */
169
+ export interface RunAddAiFeatureCommandOptions {
170
+ aiFeatureName: string;
171
+ cwd?: string;
172
+ namespace?: string;
173
+ }
174
+ /**
175
+ * Options for `wp-typia add hooked-block`.
176
+ *
177
+ * @property anchorBlockName Full `namespace/block` anchor block name.
178
+ * @property blockName Existing workspace block slug that receives metadata.
179
+ * @property cwd Working directory used to resolve the nearest official workspace.
180
+ * @property position Hook position accepted by WordPress block hooks.
181
+ */
182
+ export interface RunAddHookedBlockCommandOptions {
183
+ anchorBlockName: string;
184
+ blockName: string;
185
+ cwd?: string;
186
+ position: string;
187
+ }
188
+ /**
189
+ * Options for `wp-typia add editor-plugin`.
190
+ *
191
+ * @property cwd Working directory used to resolve the nearest official workspace.
192
+ * Defaults to `process.cwd()`.
193
+ * @property editorPluginName Human-entered editor plugin name that will be
194
+ * normalized into the generated slug.
195
+ * @property slot Optional editor shell slot. Defaults to `sidebar`.
196
+ */
197
+ export interface RunAddEditorPluginCommandOptions {
198
+ cwd?: string;
199
+ editorPluginName: string;
200
+ slot?: string;
201
+ }
202
+ /**
203
+ * Options for `wp-typia add block`.
204
+ *
205
+ * @property alternateRenderTargets Optional comma-separated alternate render targets.
206
+ * @property blockName Human-entered block name normalized into a slug.
207
+ * @property cwd Working directory used to resolve the nearest official workspace.
208
+ * @property dataStorageMode Optional persistence storage mode.
209
+ * @property externalLayerId Optional external layer id to apply.
210
+ * @property externalLayerSource Optional local, GitHub, or npm external layer source.
211
+ * @property innerBlocksPreset Optional compound block inner blocks preset.
212
+ * @property persistencePolicy Optional persistence access policy.
213
+ * @property selectExternalLayerId Optional selector for interactive external layer choice.
214
+ * @property templateId Optional built-in block template id.
215
+ */
216
+ export interface RunAddBlockCommandOptions {
217
+ alternateRenderTargets?: string;
218
+ blockName: string;
219
+ cwd?: string;
220
+ dataStorageMode?: string;
221
+ externalLayerId?: string;
222
+ externalLayerSource?: string;
223
+ innerBlocksPreset?: string;
224
+ persistencePolicy?: string;
225
+ selectExternalLayerId?: (options: Array<{
226
+ description?: string;
227
+ extends: string[];
228
+ id: string;
229
+ }>) => Promise<string>;
230
+ templateId?: string;
231
+ }
232
+ /**
233
+ * Captured workspace mutation state used to roll back partial add operations.
234
+ */
235
+ export interface WorkspaceMutationSnapshot {
236
+ /** Snapshots of file contents taken before the mutation starts. */
237
+ fileSources: Array<{
238
+ /** Absolute file path recorded for rollback. */
239
+ filePath: string;
240
+ /** Previous file contents, or `null` when the file did not exist. */
241
+ source: string | null;
242
+ }>;
243
+ /** Snapshot directories created while seeding migration history. */
244
+ snapshotDirs: string[];
245
+ /** Files or directories created by the mutation that should be removed on rollback. */
246
+ targetPaths: string[];
247
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Supported top-level `wp-typia add` kinds exposed by the canonical CLI.
3
+ */
4
+ export const ADD_KIND_IDS = [
5
+ "admin-view",
6
+ "block",
7
+ "variation",
8
+ "style",
9
+ "transform",
10
+ "pattern",
11
+ "binding-source",
12
+ "rest-resource",
13
+ "ability",
14
+ "ai-feature",
15
+ "hooked-block",
16
+ "editor-plugin",
17
+ ];
18
+ /**
19
+ * Supported plugin-level REST resource methods accepted by
20
+ * `wp-typia add rest-resource --methods`.
21
+ */
22
+ export const REST_RESOURCE_METHOD_IDS = [
23
+ "list",
24
+ "read",
25
+ "create",
26
+ "update",
27
+ "delete",
28
+ ];
29
+ /**
30
+ * Canonical editor-plugin shell surface ids accepted by
31
+ * `wp-typia add editor-plugin --slot`.
32
+ */
33
+ export const EDITOR_PLUGIN_SLOT_IDS = ["sidebar", "document-setting-panel"];
34
+ /**
35
+ * Legacy and canonical editor-plugin slot aliases keyed by user-facing input.
36
+ */
37
+ export const EDITOR_PLUGIN_SLOT_ALIASES = {
38
+ PluginDocumentSettingPanel: "document-setting-panel",
39
+ PluginSidebar: "sidebar",
40
+ "document-setting-panel": "document-setting-panel",
41
+ sidebar: "sidebar",
42
+ };
43
+ /**
44
+ * Resolve a user-provided editor-plugin slot alias to its canonical id.
45
+ *
46
+ * @param slot Raw slot value from CLI input.
47
+ * @returns The canonical slot id, or `undefined` when unsupported.
48
+ */
49
+ export function resolveEditorPluginSlotAlias(slot) {
50
+ const trimmed = slot.trim();
51
+ if (!Object.prototype.hasOwnProperty.call(EDITOR_PLUGIN_SLOT_ALIASES, trimmed)) {
52
+ return undefined;
53
+ }
54
+ return EDITOR_PLUGIN_SLOT_ALIASES[trimmed];
55
+ }
56
+ /**
57
+ * Supported built-in block families accepted by `wp-typia add block --template`.
58
+ */
59
+ export const ADD_BLOCK_TEMPLATE_IDS = [
60
+ "basic",
61
+ "interactivity",
62
+ "persistence",
63
+ "compound",
64
+ ];
@@ -0,0 +1,87 @@
1
+ import { type HookedBlockPositionId } from "./hooked-blocks.js";
2
+ import { type AddBlockTemplateId, type EditorPluginSlotId, type RestResourceMethodId } from "./cli-add-types.js";
3
+ /**
4
+ * Namespace format accepted by plugin-level REST resources.
5
+ */
6
+ export declare const REST_RESOURCE_NAMESPACE_PATTERN: RegExp;
7
+ /**
8
+ * Validate a normalized workspace-generated slug.
9
+ *
10
+ * @param label Human-readable field label used in error messages.
11
+ * @param slug Normalized slug value to validate.
12
+ * @param usage CLI usage hint shown when the slug is empty.
13
+ * @returns The validated slug.
14
+ * @throws {Error} When the slug is empty or contains unsupported characters.
15
+ */
16
+ export declare function assertValidGeneratedSlug(label: string, slug: string, usage: string): string;
17
+ /**
18
+ * Validate a REST resource namespace.
19
+ *
20
+ * @param namespace Namespace candidate such as `vendor/v1`.
21
+ * @returns The trimmed namespace.
22
+ * @throws {Error} When the namespace is empty or not lowercase slash-separated.
23
+ */
24
+ export declare function assertValidRestResourceNamespace(namespace: string): string;
25
+ /**
26
+ * Resolve the effective REST resource namespace for a workspace.
27
+ *
28
+ * @param workspaceNamespace Default workspace namespace prefix.
29
+ * @param namespace Optional explicit namespace from CLI input.
30
+ * @returns A validated namespace, defaulting to `<workspaceNamespace>/v1`.
31
+ * @throws {Error} When the resolved namespace is invalid.
32
+ */
33
+ export declare function resolveRestResourceNamespace(workspaceNamespace: string, namespace?: string): string;
34
+ /**
35
+ * Parse and validate REST resource method ids from a comma-separated list.
36
+ *
37
+ * @param methods Optional comma-separated method list. Defaults to list, read, and create.
38
+ * @returns Deduplicated canonical REST resource method ids.
39
+ * @throws {Error} When any method is unsupported or the list is empty.
40
+ */
41
+ export declare function assertValidRestResourceMethods(methods?: string): RestResourceMethodId[];
42
+ /**
43
+ * Validate a hooked block insertion position.
44
+ *
45
+ * @param position Position candidate from CLI input.
46
+ * @returns The canonical hooked block position id.
47
+ * @throws {Error} When the position is not supported.
48
+ */
49
+ export declare function assertValidHookedBlockPosition(position: string): HookedBlockPositionId;
50
+ /**
51
+ * Build a PHP-safe workspace identifier prefix for a generated artifact.
52
+ *
53
+ * @param workspacePhpPrefix Workspace PHP prefix from project metadata.
54
+ * @param slug Generated artifact slug to append.
55
+ * @returns Snake-case PHP prefix for generated identifiers.
56
+ */
57
+ export declare function buildWorkspacePhpPrefix(workspacePhpPrefix: string, slug: string): string;
58
+ /**
59
+ * Check whether a value is a supported built-in add block template id.
60
+ *
61
+ * @param value Candidate template id from CLI input.
62
+ * @returns True when the value is an `AddBlockTemplateId`.
63
+ */
64
+ export declare function isAddBlockTemplateId(value: string): value is AddBlockTemplateId;
65
+ /**
66
+ * Quote a value for safe insertion into generated TypeScript source.
67
+ *
68
+ * @param value Raw string value.
69
+ * @returns JSON-escaped TypeScript string literal.
70
+ */
71
+ export declare function quoteTsString(value: string): string;
72
+ /**
73
+ * Validate a full block name used as a hooked block anchor.
74
+ *
75
+ * @param anchorBlockName Anchor block name from CLI input.
76
+ * @returns The trimmed full block name.
77
+ * @throws {Error} When the anchor is empty or not `namespace/slug`.
78
+ */
79
+ export declare function assertValidHookAnchor(anchorBlockName: string): string;
80
+ /**
81
+ * Validate and normalize the editor plugin shell slot.
82
+ *
83
+ * @param slot Optional shell slot. Defaults to `sidebar`.
84
+ * @returns The canonical editor plugin slot id.
85
+ * @throws {Error} When the slot is not supported by the workspace scaffold.
86
+ */
87
+ export declare function assertValidEditorPluginSlot(slot?: string): EditorPluginSlotId;
@@ -0,0 +1,147 @@
1
+ import { HOOKED_BLOCK_ANCHOR_PATTERN, HOOKED_BLOCK_POSITION_IDS, } from "./hooked-blocks.js";
2
+ import { toSnakeCase, } from "./string-case.js";
3
+ import { ADD_BLOCK_TEMPLATE_IDS, EDITOR_PLUGIN_SLOT_IDS, REST_RESOURCE_METHOD_IDS, resolveEditorPluginSlotAlias, } from "./cli-add-types.js";
4
+ const WORKSPACE_GENERATED_SLUG_PATTERN = /^[a-z][a-z0-9-]*$/;
5
+ /**
6
+ * Namespace format accepted by plugin-level REST resources.
7
+ */
8
+ export const REST_RESOURCE_NAMESPACE_PATTERN = /^[a-z][a-z0-9-]*(?:\/[a-z0-9-]+)+$/u;
9
+ /**
10
+ * Validate a normalized workspace-generated slug.
11
+ *
12
+ * @param label Human-readable field label used in error messages.
13
+ * @param slug Normalized slug value to validate.
14
+ * @param usage CLI usage hint shown when the slug is empty.
15
+ * @returns The validated slug.
16
+ * @throws {Error} When the slug is empty or contains unsupported characters.
17
+ */
18
+ export function assertValidGeneratedSlug(label, slug, usage) {
19
+ if (!slug) {
20
+ throw new Error(`${label} is required. Use \`${usage}\`.`);
21
+ }
22
+ if (!WORKSPACE_GENERATED_SLUG_PATTERN.test(slug)) {
23
+ throw new Error(`${label} must start with a letter and contain only lowercase letters, numbers, and hyphens.`);
24
+ }
25
+ return slug;
26
+ }
27
+ /**
28
+ * Validate a REST resource namespace.
29
+ *
30
+ * @param namespace Namespace candidate such as `vendor/v1`.
31
+ * @returns The trimmed namespace.
32
+ * @throws {Error} When the namespace is empty or not lowercase slash-separated.
33
+ */
34
+ export function assertValidRestResourceNamespace(namespace) {
35
+ const trimmed = namespace.trim();
36
+ if (!trimmed) {
37
+ throw new Error("REST resource namespace is required. Use `--namespace <vendor/v1>` or let the workspace default apply.");
38
+ }
39
+ if (!REST_RESOURCE_NAMESPACE_PATTERN.test(trimmed)) {
40
+ throw new Error("REST resource namespace must use lowercase slash-separated segments like `demo-space/v1`.");
41
+ }
42
+ return trimmed;
43
+ }
44
+ /**
45
+ * Resolve the effective REST resource namespace for a workspace.
46
+ *
47
+ * @param workspaceNamespace Default workspace namespace prefix.
48
+ * @param namespace Optional explicit namespace from CLI input.
49
+ * @returns A validated namespace, defaulting to `<workspaceNamespace>/v1`.
50
+ * @throws {Error} When the resolved namespace is invalid.
51
+ */
52
+ export function resolveRestResourceNamespace(workspaceNamespace, namespace) {
53
+ return assertValidRestResourceNamespace(namespace ?? `${workspaceNamespace}/v1`);
54
+ }
55
+ /**
56
+ * Parse and validate REST resource method ids from a comma-separated list.
57
+ *
58
+ * @param methods Optional comma-separated method list. Defaults to list, read, and create.
59
+ * @returns Deduplicated canonical REST resource method ids.
60
+ * @throws {Error} When any method is unsupported or the list is empty.
61
+ */
62
+ export function assertValidRestResourceMethods(methods) {
63
+ const rawMethods = typeof methods === "string" && methods.trim().length > 0
64
+ ? methods.split(",").map((value) => value.trim()).filter(Boolean)
65
+ : ["list", "read", "create"];
66
+ const normalizedMethods = Array.from(new Set(rawMethods));
67
+ const invalidMethods = normalizedMethods.filter((method) => !REST_RESOURCE_METHOD_IDS.includes(method));
68
+ if (invalidMethods.length > 0) {
69
+ throw new Error(`REST resource methods must be a comma-separated list of: ${REST_RESOURCE_METHOD_IDS.join(", ")}.`);
70
+ }
71
+ if (normalizedMethods.length === 0) {
72
+ throw new Error(`REST resource methods must include at least one of: ${REST_RESOURCE_METHOD_IDS.join(", ")}.`);
73
+ }
74
+ return normalizedMethods;
75
+ }
76
+ /**
77
+ * Validate a hooked block insertion position.
78
+ *
79
+ * @param position Position candidate from CLI input.
80
+ * @returns The canonical hooked block position id.
81
+ * @throws {Error} When the position is not supported.
82
+ */
83
+ export function assertValidHookedBlockPosition(position) {
84
+ if (HOOKED_BLOCK_POSITION_IDS.includes(position)) {
85
+ return position;
86
+ }
87
+ throw new Error(`Hook position must be one of: ${HOOKED_BLOCK_POSITION_IDS.join(", ")}.`);
88
+ }
89
+ /**
90
+ * Build a PHP-safe workspace identifier prefix for a generated artifact.
91
+ *
92
+ * @param workspacePhpPrefix Workspace PHP prefix from project metadata.
93
+ * @param slug Generated artifact slug to append.
94
+ * @returns Snake-case PHP prefix for generated identifiers.
95
+ */
96
+ export function buildWorkspacePhpPrefix(workspacePhpPrefix, slug) {
97
+ return toSnakeCase(`${workspacePhpPrefix}_${slug}`);
98
+ }
99
+ /**
100
+ * Check whether a value is a supported built-in add block template id.
101
+ *
102
+ * @param value Candidate template id from CLI input.
103
+ * @returns True when the value is an `AddBlockTemplateId`.
104
+ */
105
+ export function isAddBlockTemplateId(value) {
106
+ return ADD_BLOCK_TEMPLATE_IDS.includes(value);
107
+ }
108
+ /**
109
+ * Quote a value for safe insertion into generated TypeScript source.
110
+ *
111
+ * @param value Raw string value.
112
+ * @returns JSON-escaped TypeScript string literal.
113
+ */
114
+ export function quoteTsString(value) {
115
+ return JSON.stringify(value);
116
+ }
117
+ /**
118
+ * Validate a full block name used as a hooked block anchor.
119
+ *
120
+ * @param anchorBlockName Anchor block name from CLI input.
121
+ * @returns The trimmed full block name.
122
+ * @throws {Error} When the anchor is empty or not `namespace/slug`.
123
+ */
124
+ export function assertValidHookAnchor(anchorBlockName) {
125
+ const trimmed = anchorBlockName.trim();
126
+ if (!trimmed) {
127
+ throw new Error("`wp-typia add hooked-block` requires --anchor <anchor-block-name>.");
128
+ }
129
+ if (!HOOKED_BLOCK_ANCHOR_PATTERN.test(trimmed)) {
130
+ throw new Error("`wp-typia add hooked-block` requires --anchor <anchor-block-name> to use the full `namespace/slug` block name format.");
131
+ }
132
+ return trimmed;
133
+ }
134
+ /**
135
+ * Validate and normalize the editor plugin shell slot.
136
+ *
137
+ * @param slot Optional shell slot. Defaults to `sidebar`.
138
+ * @returns The canonical editor plugin slot id.
139
+ * @throws {Error} When the slot is not supported by the workspace scaffold.
140
+ */
141
+ export function assertValidEditorPluginSlot(slot = "sidebar") {
142
+ const alias = resolveEditorPluginSlotAlias(slot);
143
+ if (alias) {
144
+ return alias;
145
+ }
146
+ throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
147
+ }