@wp-typia/project-tools 0.23.0 → 0.24.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.
Files changed (228) hide show
  1. package/dist/runtime/ai-feature-artifacts.js +4 -1
  2. package/dist/runtime/block-generator-service-spec.js +2 -1
  3. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  7. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  8. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  9. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  10. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  11. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  15. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  16. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  17. package/dist/runtime/cli-add-block-json.js +5 -1
  18. package/dist/runtime/cli-add-collision.js +8 -0
  19. package/dist/runtime/cli-add-help.js +14 -10
  20. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  21. package/dist/runtime/cli-add-kind-ids.js +1 -0
  22. package/dist/runtime/cli-add-types.d.ts +45 -6
  23. package/dist/runtime/cli-add-types.js +2 -0
  24. package/dist/runtime/cli-add-validation.d.ts +7 -0
  25. package/dist/runtime/cli-add-validation.js +9 -0
  26. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  27. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  28. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  29. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  30. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  31. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
  32. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
  33. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
  34. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
  35. package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
  36. package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
  37. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
  38. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
  39. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
  40. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
  41. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
  42. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
  43. package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
  44. package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
  45. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  46. package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
  47. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  48. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  49. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
  50. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  51. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  52. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  53. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  54. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  55. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  56. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  57. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  58. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  59. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  60. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  61. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  62. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  63. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  64. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  65. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  66. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  67. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  68. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  69. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  70. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  71. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  72. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  73. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  74. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  75. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  76. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  77. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  78. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  79. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  80. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  81. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  82. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  83. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  84. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  85. package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
  86. package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
  87. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  88. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  89. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  90. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  91. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  92. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  93. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  94. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  95. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  96. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  97. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
  99. package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
  100. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  101. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  102. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  103. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  104. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  105. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  106. package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
  107. package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
  108. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  109. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  110. package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
  111. package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
  112. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
  113. package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
  114. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  115. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  116. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  117. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  118. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  119. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  120. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
  121. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
  122. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  123. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  124. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  125. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  126. package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
  127. package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
  128. package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
  129. package/dist/runtime/cli-add-workspace-rest.js +33 -788
  130. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  131. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  132. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  133. package/dist/runtime/cli-add-workspace.js +42 -674
  134. package/dist/runtime/cli-add.d.ts +3 -3
  135. package/dist/runtime/cli-add.js +2 -2
  136. package/dist/runtime/cli-core.d.ts +3 -2
  137. package/dist/runtime/cli-core.js +2 -2
  138. package/dist/runtime/cli-diagnostics.d.ts +3 -1
  139. package/dist/runtime/cli-diagnostics.js +17 -5
  140. package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
  141. package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
  142. package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
  143. package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
  144. package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
  145. package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
  146. package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
  147. package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
  148. package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
  149. package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
  150. package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
  151. package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
  152. package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
  153. package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
  154. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
  155. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
  156. package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
  157. package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
  158. package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
  159. package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
  160. package/dist/runtime/cli-doctor-workspace-features.js +14 -487
  161. package/dist/runtime/cli-doctor.d.ts +54 -3
  162. package/dist/runtime/cli-doctor.js +92 -10
  163. package/dist/runtime/cli-help.js +12 -7
  164. package/dist/runtime/cli-init-package-json.js +4 -2
  165. package/dist/runtime/cli-prompt.d.ts +16 -2
  166. package/dist/runtime/cli-prompt.js +29 -12
  167. package/dist/runtime/cli-scaffold.d.ts +2 -1
  168. package/dist/runtime/cli-scaffold.js +19 -10
  169. package/dist/runtime/external-template-guards.js +4 -6
  170. package/dist/runtime/index.d.ts +6 -3
  171. package/dist/runtime/index.js +4 -2
  172. package/dist/runtime/json-utils.d.ts +62 -4
  173. package/dist/runtime/json-utils.js +78 -4
  174. package/dist/runtime/local-dev-presets.js +6 -2
  175. package/dist/runtime/migration-ui-capability.js +4 -1
  176. package/dist/runtime/migration-utils.js +4 -1
  177. package/dist/runtime/package-managers.js +6 -1
  178. package/dist/runtime/package-versions.d.ts +1 -0
  179. package/dist/runtime/package-versions.js +16 -3
  180. package/dist/runtime/pattern-catalog.d.ts +122 -0
  181. package/dist/runtime/pattern-catalog.js +471 -0
  182. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  183. package/dist/runtime/post-meta-binding-fields.js +135 -0
  184. package/dist/runtime/scaffold-bootstrap.js +7 -2
  185. package/dist/runtime/scaffold-package-manager-files.js +5 -1
  186. package/dist/runtime/scaffold-repository-reference.js +4 -2
  187. package/dist/runtime/scaffold-template-variables.js +2 -1
  188. package/dist/runtime/scaffold.d.ts +18 -1
  189. package/dist/runtime/scaffold.js +55 -2
  190. package/dist/runtime/temp-roots.js +4 -1
  191. package/dist/runtime/template-layers.js +4 -1
  192. package/dist/runtime/template-registry.js +9 -3
  193. package/dist/runtime/template-source-contracts.d.ts +2 -0
  194. package/dist/runtime/template-source-normalization.js +2 -1
  195. package/dist/runtime/template-source-remote.js +18 -5
  196. package/dist/runtime/template-source-seeds.js +10 -3
  197. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  198. package/dist/runtime/typia-llm-json-schema.js +33 -0
  199. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  200. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  201. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  202. package/dist/runtime/typia-llm-projection.js +58 -0
  203. package/dist/runtime/typia-llm-render.d.ts +21 -0
  204. package/dist/runtime/typia-llm-render.js +252 -0
  205. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  206. package/dist/runtime/typia-llm-sync.js +63 -0
  207. package/dist/runtime/typia-llm-types.d.ts +197 -0
  208. package/dist/runtime/typia-llm-types.js +1 -0
  209. package/dist/runtime/typia-llm.d.ts +9 -255
  210. package/dist/runtime/typia-llm.js +5 -634
  211. package/dist/runtime/workspace-inventory-mutations.js +15 -1
  212. package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
  213. package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
  214. package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
  215. package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
  216. package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
  217. package/dist/runtime/workspace-inventory-parser.js +3 -581
  218. package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
  219. package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
  220. package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
  221. package/dist/runtime/workspace-inventory-templates.js +10 -1
  222. package/dist/runtime/workspace-inventory-types.d.ts +10 -1
  223. package/dist/runtime/workspace-project.js +4 -6
  224. package/package.json +8 -3
  225. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  226. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  227. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  228. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Prefix every line in a multi-line source fragment.
3
+ *
4
+ * @param source Source fragment to indent.
5
+ * @param prefix Prefix to prepend to every line.
6
+ * @returns The source fragment with each line prefixed.
7
+ */
8
+ export function indentMultiline(source, prefix) {
9
+ return source
10
+ .split("\n")
11
+ .map((line) => `${prefix}${line}`)
12
+ .join("\n");
13
+ }
14
+ const RESOLVE_REST_NONCE_SOURCE = `function resolveRestNonce( fallback?: string ): string | undefined {
15
+ \tif ( typeof fallback === 'string' && fallback.length > 0 ) {
16
+ \t\treturn fallback;
17
+ \t}
18
+
19
+ \tif ( typeof window === 'undefined' ) {
20
+ \t\treturn undefined;
21
+ \t}
22
+
23
+ \tconst wpApiSettings = (
24
+ \t\twindow as typeof window & {
25
+ \t\t\twpApiSettings?: { nonce?: string };
26
+ \t\t}
27
+ \t).wpApiSettings;
28
+
29
+ \treturn typeof wpApiSettings?.nonce === 'string' &&
30
+ \t\twpApiSettings.nonce.length > 0
31
+ \t\t? wpApiSettings.nonce
32
+ \t\t: undefined;
33
+ }`;
34
+ /**
35
+ * Render the shared REST nonce helper in the formatting style expected by a
36
+ * generated source file.
37
+ *
38
+ * @param style Compact output is used by manual-contract shims; spaced output
39
+ * matches generated REST resource shims.
40
+ * @returns TypeScript source for the embedded `resolveRestNonce()` helper.
41
+ */
42
+ export function formatResolveRestNonceSource(style) {
43
+ if (style === "spaced") {
44
+ return RESOLVE_REST_NONCE_SOURCE;
45
+ }
46
+ return RESOLVE_REST_NONCE_SOURCE
47
+ .replace("function resolveRestNonce( fallback?: string ): string | undefined {", "function resolveRestNonce(fallback?: string): string | undefined {")
48
+ .replace("\tif ( typeof fallback === 'string' && fallback.length > 0 ) {", "\tif (typeof fallback === 'string' && fallback.length > 0) {")
49
+ .replace("\tif ( typeof window === 'undefined' ) {", "\tif (typeof window === 'undefined') {");
50
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Build the standard sync-rest patch failure message for missing anchors.
3
+ *
4
+ * @param functionName Name of the patcher that could not complete.
5
+ * @param syncRestScriptPath Path to the workspace sync-rest script.
6
+ * @param anchorDescription Human-readable description of the missing anchor.
7
+ * @param subject Configuration subject the patcher was trying to wire.
8
+ * @returns A formatted error message with manual recovery guidance.
9
+ */
10
+ export declare function getSyncRestPatchErrorMessage(functionName: string, syncRestScriptPath: string, anchorDescription: string, subject: string): string;
11
+ /**
12
+ * Add a required block-config value and type import to sync-rest source.
13
+ *
14
+ * @param options Import patching options.
15
+ * @param options.functionName Name of the calling patcher for error messages.
16
+ * @param options.nextSource Current sync-rest script source.
17
+ * @param options.subject Value and type names that must be imported.
18
+ * @param options.syncRestScriptPath Path to the target sync-rest script.
19
+ * @returns Source with the block-config import updated or left unchanged.
20
+ * @throws When the generated block-config import anchor cannot be found.
21
+ */
22
+ export declare function replaceBlockConfigImport({ functionName, nextSource, subject, syncRestScriptPath, }: {
23
+ functionName: string;
24
+ nextSource: string;
25
+ subject: {
26
+ configTypeName: string;
27
+ constName: string;
28
+ };
29
+ syncRestScriptPath: string;
30
+ }): string;
31
+ /**
32
+ * Render a sync-rest guard for the selected empty resource collections.
33
+ *
34
+ * @param options Guard rendering options.
35
+ * @param options.subjects Candidate guard subjects and conditions.
36
+ * @returns TypeScript source for the no-resources guard block.
37
+ */
38
+ export declare function buildNoResourcesGuard({ subjects, }: {
39
+ subjects: readonly {
40
+ condition: string;
41
+ include: boolean;
42
+ subject: string;
43
+ }[];
44
+ }): string;
45
+ /**
46
+ * Replace the generated no-resources guard in sync-rest source.
47
+ *
48
+ * @param nextSource Current sync-rest script source.
49
+ * @param replacement New no-resources guard source.
50
+ * @param functionName Name of the calling patcher for error messages.
51
+ * @param syncRestScriptPath Path to the target sync-rest script.
52
+ * @param subject Configuration subject the patcher was trying to wire.
53
+ * @returns Source with the no-resources guard replaced.
54
+ * @throws When the generated no-resources guard cannot be found.
55
+ */
56
+ export declare function replaceNoResourcesGuard(nextSource: string, replacement: string, functionName: string, syncRestScriptPath: string, subject: string): string;
@@ -0,0 +1,122 @@
1
+ import path from "node:path";
2
+ /**
3
+ * Build the standard sync-rest patch failure message for missing anchors.
4
+ *
5
+ * @param functionName Name of the patcher that could not complete.
6
+ * @param syncRestScriptPath Path to the workspace sync-rest script.
7
+ * @param anchorDescription Human-readable description of the missing anchor.
8
+ * @param subject Configuration subject the patcher was trying to wire.
9
+ * @returns A formatted error message with manual recovery guidance.
10
+ */
11
+ export function getSyncRestPatchErrorMessage(functionName, syncRestScriptPath, anchorDescription, subject) {
12
+ return [
13
+ `${functionName} could not patch ${path.basename(syncRestScriptPath)}.`,
14
+ `Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
15
+ `Restore the generated template or add the ${subject} wiring manually before retrying.`,
16
+ ].join(" ");
17
+ }
18
+ const BLOCK_CONFIG_IMPORT_PATTERNS = [
19
+ /^import\s*\{\n(?:\t[^\n]*\n)+\} from ["']\.\/block-config["'];?$/mu,
20
+ /^import\s*\{[^\n]*\}\s*from\s*["']\.\/block-config["'];?$/mu,
21
+ ];
22
+ const BLOCK_CONFIG_VALUE_IMPORT_ORDER = [
23
+ "AI_FEATURES",
24
+ "BLOCKS",
25
+ "CONTRACTS",
26
+ "POST_META",
27
+ "REST_RESOURCES",
28
+ ];
29
+ const BLOCK_CONFIG_TYPE_IMPORT_ORDER = [
30
+ "WorkspaceAiFeatureConfig",
31
+ "WorkspaceBlockConfig",
32
+ "WorkspaceContractConfig",
33
+ "WorkspacePostMetaConfig",
34
+ "WorkspaceRestResourceConfig",
35
+ ];
36
+ /**
37
+ * Add a required block-config value and type import to sync-rest source.
38
+ *
39
+ * @param options Import patching options.
40
+ * @param options.functionName Name of the calling patcher for error messages.
41
+ * @param options.nextSource Current sync-rest script source.
42
+ * @param options.subject Value and type names that must be imported.
43
+ * @param options.syncRestScriptPath Path to the target sync-rest script.
44
+ * @returns Source with the block-config import updated or left unchanged.
45
+ * @throws When the generated block-config import anchor cannot be found.
46
+ */
47
+ export function replaceBlockConfigImport({ functionName, nextSource, subject, syncRestScriptPath, }) {
48
+ const importMatch = BLOCK_CONFIG_IMPORT_PATTERNS.map((pattern) => pattern.exec(nextSource)).find(Boolean) ?? null;
49
+ if (!importMatch) {
50
+ throw new Error(getSyncRestPatchErrorMessage(functionName, syncRestScriptPath, "block-config import", subject.constName));
51
+ }
52
+ const importSource = importMatch[0];
53
+ if (importSource.includes(subject.constName) &&
54
+ importSource.includes(subject.configTypeName)) {
55
+ return nextSource;
56
+ }
57
+ if (!importSource.includes("BLOCKS") ||
58
+ !importSource.includes("WorkspaceBlockConfig")) {
59
+ throw new Error(getSyncRestPatchErrorMessage(functionName, syncRestScriptPath, "BLOCKS import", subject.constName));
60
+ }
61
+ const replacement = [
62
+ "import {",
63
+ ...BLOCK_CONFIG_VALUE_IMPORT_ORDER.flatMap((constName) => constName === subject.constName || importSource.includes(constName)
64
+ ? [`\t${constName},`]
65
+ : []),
66
+ ...BLOCK_CONFIG_TYPE_IMPORT_ORDER.flatMap((configTypeName) => configTypeName === subject.configTypeName ||
67
+ importSource.includes(configTypeName)
68
+ ? [`\ttype ${configTypeName},`]
69
+ : []),
70
+ "} from './block-config';",
71
+ ].join("\n");
72
+ return nextSource.replace(importSource, replacement);
73
+ }
74
+ function formatNoResourcesSubject(subjects) {
75
+ if (subjects.length <= 2) {
76
+ return subjects.join(" or ");
77
+ }
78
+ const lastSubject = subjects[subjects.length - 1];
79
+ return `${subjects.slice(0, -1).join(", ")}, or ${lastSubject}`;
80
+ }
81
+ /**
82
+ * Render a sync-rest guard for the selected empty resource collections.
83
+ *
84
+ * @param options Guard rendering options.
85
+ * @param options.subjects Candidate guard subjects and conditions.
86
+ * @returns TypeScript source for the no-resources guard block.
87
+ */
88
+ export function buildNoResourcesGuard({ subjects, }) {
89
+ const includedSubjects = subjects.filter((subject) => subject.include);
90
+ const condition = includedSubjects.map(({ condition }, index) => index === includedSubjects.length - 1 ? condition : `${condition} &&`);
91
+ const noResourcesSubject = formatNoResourcesSubject(includedSubjects.map(({ subject }) => subject));
92
+ return [
93
+ "if (",
94
+ ...condition.map((line) => `\t\t${line}`),
95
+ "\t) {",
96
+ "\t\tconsole.log(",
97
+ "\t\t\toptions.check",
98
+ `\t\t\t\t? 'ℹ️ No ${noResourcesSubject} are registered yet. \`sync-rest --check\` is already clean.'`,
99
+ `\t\t\t\t: 'ℹ️ No ${noResourcesSubject} are registered yet.'`,
100
+ "\t\t);",
101
+ "\t\treturn;",
102
+ "\t}",
103
+ ].join("\n");
104
+ }
105
+ const NO_RESOURCES_GUARD_PATTERN = /if \(\s*restBlocks\.length === 0(?:\s*&&\s*standaloneContracts\.length === 0)?(?:\s*&&\s*postMetaContracts\.length === 0)?(?:\s*&&\s*restResources\.length === 0)?(?:\s*&&\s*aiFeatures\.length === 0)?\s*\) \{[\s\S]*?\n\t\treturn;\n\t\}/u;
106
+ /**
107
+ * Replace the generated no-resources guard in sync-rest source.
108
+ *
109
+ * @param nextSource Current sync-rest script source.
110
+ * @param replacement New no-resources guard source.
111
+ * @param functionName Name of the calling patcher for error messages.
112
+ * @param syncRestScriptPath Path to the target sync-rest script.
113
+ * @param subject Configuration subject the patcher was trying to wire.
114
+ * @returns Source with the no-resources guard replaced.
115
+ * @throws When the generated no-resources guard cannot be found.
116
+ */
117
+ export function replaceNoResourcesGuard(nextSource, replacement, functionName, syncRestScriptPath, subject) {
118
+ if (!NO_RESOURCES_GUARD_PATTERN.test(nextSource)) {
119
+ throw new Error(getSyncRestPatchErrorMessage(functionName, syncRestScriptPath, "no-resources guard", subject));
120
+ }
121
+ return nextSource.replace(NO_RESOURCES_GUARD_PATTERN, replacement);
122
+ }
@@ -0,0 +1,108 @@
1
+ import type { ManualRestContractAuthId, ManualRestContractHttpMethodId, RestResourceMethodId } from "./cli-add-shared.js";
2
+ import type { WorkspaceProject } from "./workspace-project.js";
3
+ /**
4
+ * Normalized metadata returned after `wp-typia add rest-resource` completes.
5
+ *
6
+ * @property auth Manual-mode authentication policy when `mode` is `"manual"`.
7
+ * @property bodyTypeName Optional manual-mode request body type export.
8
+ * @property controllerClass Optional PHP controller class reference. Generated
9
+ * mode uses it for callbacks; manual mode records it as route-owner metadata.
10
+ * @property methods Generated-mode REST operation ids, or an empty array for
11
+ * manual contracts.
12
+ * @property mode Whether the scaffold wrote generated REST glue or a type-only
13
+ * manual contract.
14
+ * @property namespace REST namespace in `vendor/v1` format.
15
+ * @property projectDir Absolute workspace project directory.
16
+ * @property restResourceSlug Normalized kebab-case REST resource slug.
17
+ * @property secretPreserveOnEmpty Whether blank settings secret submissions
18
+ * should preserve the stored value when `secretFieldName` is set.
19
+ */
20
+ export interface RunAddRestResourceCommandResult {
21
+ auth?: ManualRestContractAuthId;
22
+ bodyTypeName?: string;
23
+ controllerClass?: string;
24
+ controllerExtends?: string;
25
+ method?: ManualRestContractHttpMethodId;
26
+ methods: RestResourceMethodId[];
27
+ mode: "generated" | "manual";
28
+ namespace: string;
29
+ permissionCallback?: string;
30
+ pathPattern?: string;
31
+ projectDir: string;
32
+ queryTypeName?: string;
33
+ restResourceSlug: string;
34
+ responseTypeName?: string;
35
+ routePattern?: string;
36
+ secretFieldName?: string;
37
+ secretHasValueFieldName?: string;
38
+ secretMaskedResponseFieldName?: string;
39
+ secretPreserveOnEmpty?: boolean;
40
+ secretStateFieldName?: string;
41
+ }
42
+ /**
43
+ * Raw command options passed from the REST orchestrator into manual-mode
44
+ * contract scaffolding.
45
+ *
46
+ * @property auth Optional raw manual authentication id, validated before use.
47
+ * @property bodyTypeName Optional exported request body type name.
48
+ * @property method Optional raw HTTP method id, validated as a manual REST
49
+ * contract method.
50
+ * @property namespace Resolved REST namespace in `vendor/v1` format.
51
+ * @property pathPattern Optional manual route path pattern relative to the
52
+ * namespace.
53
+ * @property permissionCallback Optional manual route-owner permission callback
54
+ * metadata.
55
+ * @property restResourceSlug Normalized kebab-case REST resource slug.
56
+ * @property routePattern Optional manual route path alias for `pathPattern`.
57
+ * @property secretHasValueFieldName Optional alias for `secretStateFieldName`.
58
+ * @property secretMaskedResponseFieldName Optional alias for
59
+ * `secretStateFieldName`.
60
+ * @property secretFieldName Optional write-only request secret field.
61
+ * @property secretPreserveOnEmpty Optional normalized boolean for blank-secret
62
+ * preservation. Defaults to true when `secretFieldName` is set.
63
+ * @property workspace Resolved official workspace project.
64
+ */
65
+ export interface ManualRestContractScaffoldOptions {
66
+ auth: string | undefined;
67
+ bodyTypeName: string | undefined;
68
+ controllerClass: string | undefined;
69
+ controllerExtends: string | undefined;
70
+ method: string | undefined;
71
+ namespace: string;
72
+ pathPattern: string | undefined;
73
+ permissionCallback: string | undefined;
74
+ queryTypeName: string | undefined;
75
+ responseTypeName: string | undefined;
76
+ restResourceSlug: string;
77
+ routePattern: string | undefined;
78
+ secretFieldName: string | undefined;
79
+ secretHasValueFieldName: string | undefined;
80
+ secretMaskedResponseFieldName: string | undefined;
81
+ secretPreserveOnEmpty: boolean | undefined;
82
+ secretStateFieldName: string | undefined;
83
+ workspace: WorkspaceProject;
84
+ }
85
+ /**
86
+ * Raw command options passed from the REST orchestrator into generated-mode
87
+ * resource scaffolding.
88
+ *
89
+ * @property controllerClass Optional PHP controller class reference.
90
+ * @property controllerExtends Optional PHP base class reference; requires
91
+ * `controllerClass`.
92
+ * @property methods Optional comma-separated REST method list validated into
93
+ * `RestResourceMethodId` values.
94
+ * @property namespace Resolved REST namespace in `vendor/v1` format.
95
+ * @property permissionCallback Optional PHP permission callback reference.
96
+ * @property restResourceSlug Normalized kebab-case REST resource slug.
97
+ * @property workspace Resolved official workspace project.
98
+ */
99
+ export interface GeneratedRestResourceScaffoldOptions {
100
+ controllerClass: string | undefined;
101
+ controllerExtends: string | undefined;
102
+ methods: string | undefined;
103
+ namespace: string;
104
+ permissionCallback: string | undefined;
105
+ restResourceSlug: string;
106
+ routePattern: string | undefined;
107
+ workspace: WorkspaceProject;
108
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
- import { type ManualRestContractAuthId, type ManualRestContractHttpMethodId, type RestResourceMethodId, type RunAddRestResourceCommandOptions } from "./cli-add-shared.js";
1
+ import { type RunAddRestResourceCommandOptions } from "./cli-add-shared.js";
2
+ import { type RunAddRestResourceCommandResult } from "./cli-add-workspace-rest-types.js";
2
3
  /**
3
4
  * Scaffold a workspace-level REST resource and synchronize its generated
4
5
  * TypeScript and PHP artifacts.
@@ -6,22 +7,4 @@ import { type ManualRestContractAuthId, type ManualRestContractHttpMethodId, typ
6
7
  * @param options Command options for the REST resource scaffold workflow.
7
8
  * @returns Resolved scaffold metadata for the created REST resource.
8
9
  */
9
- export declare function runAddRestResourceCommand({ auth, bodyTypeName, controllerClass, controllerExtends, cwd, manual, method, methods, namespace, permissionCallback, pathPattern, queryTypeName, restResourceName, responseTypeName, routePattern, secretFieldName, secretStateFieldName, }: RunAddRestResourceCommandOptions): Promise<{
10
- auth?: ManualRestContractAuthId;
11
- bodyTypeName?: string;
12
- controllerClass?: string;
13
- controllerExtends?: string;
14
- method?: ManualRestContractHttpMethodId;
15
- methods: RestResourceMethodId[];
16
- mode: "generated" | "manual";
17
- namespace: string;
18
- permissionCallback?: string;
19
- pathPattern?: string;
20
- projectDir: string;
21
- queryTypeName?: string;
22
- restResourceSlug: string;
23
- responseTypeName?: string;
24
- routePattern?: string;
25
- secretFieldName?: string;
26
- secretStateFieldName?: string;
27
- }>;
10
+ export declare function runAddRestResourceCommand({ auth, bodyTypeName, controllerClass, controllerExtends, cwd, manual, method, methods, namespace, permissionCallback, pathPattern, queryTypeName, restResourceName, responseTypeName, routePattern, secretFieldName, secretHasValueFieldName, secretMaskedResponseFieldName, secretPreserveOnEmpty, secretStateFieldName, }: RunAddRestResourceCommandOptions): Promise<RunAddRestResourceCommandResult>;