@wp-typia/project-tools 0.23.1 → 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 (152) hide show
  1. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  2. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  3. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  7. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  8. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  9. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  10. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  11. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  15. package/dist/runtime/cli-add-collision.js +8 -0
  16. package/dist/runtime/cli-add-help.js +10 -7
  17. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  18. package/dist/runtime/cli-add-kind-ids.js +1 -0
  19. package/dist/runtime/cli-add-types.d.ts +28 -1
  20. package/dist/runtime/cli-add-types.js +2 -0
  21. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  22. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  23. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  24. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  25. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  26. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -311
  27. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +1 -1
  28. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  29. package/dist/runtime/cli-add-workspace-ai-anchors.js +4 -232
  30. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  31. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  32. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -145
  33. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  34. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  35. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  36. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  37. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  38. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  39. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  40. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  41. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  42. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  43. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  44. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  45. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  46. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  47. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  48. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  49. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  50. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  51. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  52. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  53. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  54. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  55. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  56. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  57. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  58. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  59. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  60. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  61. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  62. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  63. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  64. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  65. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  66. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  67. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  68. package/dist/runtime/cli-add-workspace-integration-env.js +5 -345
  69. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  70. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  71. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  72. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  73. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  74. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  75. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  76. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  77. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  78. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  79. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  80. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +6 -9
  81. package/dist/runtime/cli-add-workspace-rest-anchors.js +6 -466
  82. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  83. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  84. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  85. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  86. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  87. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  88. package/dist/runtime/cli-add-workspace-rest-generated.js +5 -3
  89. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  90. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  91. package/dist/runtime/cli-add-workspace-rest-manual.js +3 -16
  92. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +1 -7
  93. package/dist/runtime/cli-add-workspace-rest-php-templates.js +3 -322
  94. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  95. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  96. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  97. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  99. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  100. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -99
  101. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -663
  102. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  103. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  104. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  105. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  106. package/dist/runtime/cli-add-workspace-rest-types.d.ts +3 -3
  107. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  108. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  109. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  110. package/dist/runtime/cli-add-workspace.js +42 -674
  111. package/dist/runtime/cli-add.d.ts +3 -3
  112. package/dist/runtime/cli-add.js +2 -2
  113. package/dist/runtime/cli-core.d.ts +2 -1
  114. package/dist/runtime/cli-core.js +1 -1
  115. package/dist/runtime/cli-doctor-workspace-bindings.js +59 -0
  116. package/dist/runtime/cli-doctor-workspace-block-addons.js +33 -5
  117. package/dist/runtime/cli-doctor.d.ts +2 -0
  118. package/dist/runtime/cli-doctor.js +13 -2
  119. package/dist/runtime/cli-help.js +6 -4
  120. package/dist/runtime/index.d.ts +5 -2
  121. package/dist/runtime/index.js +4 -2
  122. package/dist/runtime/local-dev-presets.js +2 -1
  123. package/dist/runtime/package-versions.d.ts +1 -0
  124. package/dist/runtime/package-versions.js +10 -2
  125. package/dist/runtime/pattern-catalog.d.ts +122 -0
  126. package/dist/runtime/pattern-catalog.js +471 -0
  127. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  128. package/dist/runtime/post-meta-binding-fields.js +135 -0
  129. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  130. package/dist/runtime/typia-llm-json-schema.js +33 -0
  131. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  132. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  133. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  134. package/dist/runtime/typia-llm-projection.js +58 -0
  135. package/dist/runtime/typia-llm-render.d.ts +21 -0
  136. package/dist/runtime/typia-llm-render.js +252 -0
  137. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  138. package/dist/runtime/typia-llm-sync.js +63 -0
  139. package/dist/runtime/typia-llm-types.d.ts +197 -0
  140. package/dist/runtime/typia-llm-types.js +1 -0
  141. package/dist/runtime/typia-llm.d.ts +9 -255
  142. package/dist/runtime/typia-llm.js +5 -634
  143. package/dist/runtime/workspace-inventory-mutations.js +13 -0
  144. package/dist/runtime/workspace-inventory-section-descriptors.js +9 -1
  145. package/dist/runtime/workspace-inventory-templates.d.ts +2 -2
  146. package/dist/runtime/workspace-inventory-templates.js +9 -1
  147. package/dist/runtime/workspace-inventory-types.d.ts +9 -1
  148. package/package.json +8 -3
  149. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  150. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  151. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  152. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -0,0 +1,80 @@
1
+ import { type ManualRestContractAuthId, type ManualRestContractHttpMethodId } from "./cli-add-shared.js";
2
+ /**
3
+ * Build the `REST_RESOURCES` config entry appended for a manual REST contract.
4
+ *
5
+ * @param options Manual contract file, route, type, and auth metadata.
6
+ * @param options.auth Auth intent stored in the endpoint manifest.
7
+ * @param options.bodyTypeName Optional exported body type name.
8
+ * @param options.method Uppercase HTTP method for the external route.
9
+ * @param options.namespace REST namespace such as `vendor/v1`.
10
+ * @param options.pathPattern Route pattern relative to the namespace.
11
+ * @param options.queryTypeName Exported query type name.
12
+ * @param options.responseTypeName Exported response type name.
13
+ * @param options.restResourceSlug Normalized workspace REST contract slug.
14
+ * @returns A TypeScript object literal string for `scripts/block-config.ts`.
15
+ */
16
+ export declare function buildManualRestContractConfigEntry(options: {
17
+ auth: ManualRestContractAuthId;
18
+ bodyTypeName?: string;
19
+ controllerClass?: string;
20
+ controllerExtends?: string;
21
+ method: ManualRestContractHttpMethodId;
22
+ namespace: string;
23
+ pathPattern: string;
24
+ permissionCallback?: string;
25
+ queryTypeName: string;
26
+ responseTypeName: string;
27
+ restResourceSlug: string;
28
+ secretFieldName?: string;
29
+ secretPreserveOnEmpty?: boolean;
30
+ secretStateFieldName?: string;
31
+ }): string;
32
+ /**
33
+ * Build the editable TypeScript type source for a manual REST contract.
34
+ *
35
+ * @param options Manual contract type naming metadata.
36
+ * @param options.bodyTypeName Optional exported body type name.
37
+ * @param options.pathParameterNames Route named captures that should be present
38
+ * in the starter query type so generated clients can fill provider paths.
39
+ * @param options.queryTypeName Exported query type name.
40
+ * @param options.responseTypeName Exported response type name.
41
+ * @param options.restResourceSlug Normalized workspace REST contract slug.
42
+ * @param options.secretFieldName Optional raw secret field included only in the request body.
43
+ * @param options.secretStateFieldName Optional masked response boolean field.
44
+ * @returns TypeScript source for `api-types.ts`.
45
+ */
46
+ export declare function buildManualRestContractTypesSource(options: {
47
+ bodyTypeName?: string;
48
+ pathParameterNames?: string[];
49
+ queryTypeName: string;
50
+ responseTypeName: string;
51
+ restResourceSlug: string;
52
+ secretFieldName?: string;
53
+ secretPreserveOnEmpty?: boolean;
54
+ secretStateFieldName?: string;
55
+ }): string;
56
+ /**
57
+ * Build Typia validator source for a manual REST contract.
58
+ *
59
+ * @param options Manual contract type names to validate.
60
+ * @param options.bodyTypeName Optional exported body type name.
61
+ * @param options.queryTypeName Exported query type name.
62
+ * @param options.responseTypeName Exported response type name.
63
+ * @returns TypeScript source for `api-validators.ts`.
64
+ */
65
+ export declare function buildManualRestContractValidatorsSource(options: {
66
+ bodyTypeName?: string;
67
+ queryTypeName: string;
68
+ responseTypeName: string;
69
+ }): string;
70
+ /**
71
+ * Build the public API shim for a manual REST contract.
72
+ *
73
+ * @param options Manual REST contract operation and request type metadata.
74
+ * @returns TypeScript source that re-exports the generated endpoint client.
75
+ */
76
+ export declare function buildManualRestContractApiSource(options: {
77
+ bodyTypeName?: string;
78
+ queryTypeName: string;
79
+ restResourceSlug: string;
80
+ }): string;
@@ -0,0 +1,238 @@
1
+ import { quoteTsString, } from "./cli-add-shared.js";
2
+ import { formatResolveRestNonceSource, indentMultiline, } from "./cli-add-workspace-rest-source-utils.js";
3
+ import { buildManualRestContractEndpointManifest } from "./rest-resource-artifacts.js";
4
+ import { toPascalCase, toTitleCase } from "./string-case.js";
5
+ /**
6
+ * Build the `REST_RESOURCES` config entry appended for a manual REST contract.
7
+ *
8
+ * @param options Manual contract file, route, type, and auth metadata.
9
+ * @param options.auth Auth intent stored in the endpoint manifest.
10
+ * @param options.bodyTypeName Optional exported body type name.
11
+ * @param options.method Uppercase HTTP method for the external route.
12
+ * @param options.namespace REST namespace such as `vendor/v1`.
13
+ * @param options.pathPattern Route pattern relative to the namespace.
14
+ * @param options.queryTypeName Exported query type name.
15
+ * @param options.responseTypeName Exported response type name.
16
+ * @param options.restResourceSlug Normalized workspace REST contract slug.
17
+ * @returns A TypeScript object literal string for `scripts/block-config.ts`.
18
+ */
19
+ export function buildManualRestContractConfigEntry(options) {
20
+ const pascalCase = toPascalCase(options.restResourceSlug);
21
+ const title = toTitleCase(options.restResourceSlug);
22
+ const manifest = buildManualRestContractEndpointManifest({
23
+ auth: options.auth,
24
+ ...(options.bodyTypeName ? { bodyTypeName: options.bodyTypeName } : {}),
25
+ method: options.method,
26
+ namespace: options.namespace,
27
+ pascalCase,
28
+ pathPattern: options.pathPattern,
29
+ queryTypeName: options.queryTypeName,
30
+ responseTypeName: options.responseTypeName,
31
+ slugKebabCase: options.restResourceSlug,
32
+ title,
33
+ });
34
+ return [
35
+ "\t{",
36
+ `\t\tapiFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api.ts`)},`,
37
+ `\t\tauth: ${quoteTsString(options.auth)},`,
38
+ ...(options.bodyTypeName
39
+ ? [`\t\tbodyTypeName: ${quoteTsString(options.bodyTypeName)},`]
40
+ : []),
41
+ `\t\tclientFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-client.ts`)},`,
42
+ ...(options.controllerClass
43
+ ? [`\t\tcontrollerClass: ${quoteTsString(options.controllerClass)},`]
44
+ : []),
45
+ ...(options.controllerExtends
46
+ ? [`\t\tcontrollerExtends: ${quoteTsString(options.controllerExtends)},`]
47
+ : []),
48
+ `\t\tmethod: ${quoteTsString(options.method)},`,
49
+ "\t\tmethods: [],",
50
+ "\t\tmode: 'manual',",
51
+ `\t\tnamespace: ${quoteTsString(options.namespace)},`,
52
+ `\t\topenApiFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api.openapi.json`)},`,
53
+ `\t\tpathPattern: ${quoteTsString(options.pathPattern)},`,
54
+ ...(options.permissionCallback
55
+ ? [`\t\tpermissionCallback: ${quoteTsString(options.permissionCallback)},`]
56
+ : []),
57
+ `\t\tqueryTypeName: ${quoteTsString(options.queryTypeName)},`,
58
+ "\t\trestManifest: defineEndpointManifest(",
59
+ indentMultiline(JSON.stringify(manifest, null, "\t"), "\t\t\t"),
60
+ "\t\t),",
61
+ `\t\tresponseTypeName: ${quoteTsString(options.responseTypeName)},`,
62
+ ...(options.secretFieldName
63
+ ? [`\t\tsecretFieldName: ${quoteTsString(options.secretFieldName)},`]
64
+ : []),
65
+ ...(options.secretPreserveOnEmpty !== undefined
66
+ ? [`\t\tsecretPreserveOnEmpty: ${options.secretPreserveOnEmpty},`]
67
+ : []),
68
+ ...(options.secretStateFieldName
69
+ ? [`\t\tsecretStateFieldName: ${quoteTsString(options.secretStateFieldName)},`]
70
+ : []),
71
+ `\t\tslug: ${quoteTsString(options.restResourceSlug)},`,
72
+ `\t\ttypesFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-types.ts`)},`,
73
+ `\t\tvalidatorsFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-validators.ts`)},`,
74
+ "\t},",
75
+ ].join("\n");
76
+ }
77
+ /**
78
+ * Build the editable TypeScript type source for a manual REST contract.
79
+ *
80
+ * @param options Manual contract type naming metadata.
81
+ * @param options.bodyTypeName Optional exported body type name.
82
+ * @param options.pathParameterNames Route named captures that should be present
83
+ * in the starter query type so generated clients can fill provider paths.
84
+ * @param options.queryTypeName Exported query type name.
85
+ * @param options.responseTypeName Exported response type name.
86
+ * @param options.restResourceSlug Normalized workspace REST contract slug.
87
+ * @param options.secretFieldName Optional raw secret field included only in the request body.
88
+ * @param options.secretStateFieldName Optional masked response boolean field.
89
+ * @returns TypeScript source for `api-types.ts`.
90
+ */
91
+ export function buildManualRestContractTypesSource(options) {
92
+ const title = toTitleCase(options.restResourceSlug);
93
+ const pathParameterNames = Array.from(new Set(options.pathParameterNames ?? []));
94
+ const queryFields = pathParameterNames.length > 0
95
+ ? pathParameterNames.map((parameterName) => `\t${parameterName}: string & tags.MinLength< 1 >;`)
96
+ : ["\tid?: string & tags.MinLength< 1 >;"];
97
+ const lines = [
98
+ "import type { tags } from '@wp-typia/block-runtime/typia-tags';",
99
+ "",
100
+ `export interface ${options.queryTypeName} {`,
101
+ ...queryFields,
102
+ ...(pathParameterNames.includes("preview") ? [] : ["\tpreview?: boolean;"]),
103
+ "}",
104
+ ];
105
+ if (options.bodyTypeName) {
106
+ const secretPreserveOnEmpty = options.secretPreserveOnEmpty ?? true;
107
+ const secretLines = options.secretFieldName && options.secretStateFieldName
108
+ ? [
109
+ `\t${options.secretFieldName}?: string${secretPreserveOnEmpty ? " & tags.MinLength< 1 >" : ""} & tags.MaxLength< 4096 > & tags.Secret< ${quoteTsString(options.secretStateFieldName)} >${secretPreserveOnEmpty ? " & tags.PreserveOnEmpty< true >" : ""};`,
110
+ secretPreserveOnEmpty
111
+ ? `\t// ${options.secretFieldName} is write-only: omit or submit an empty value to preserve the stored secret, and expose ${options.secretStateFieldName} in responses instead of returning the raw value.`
112
+ : `\t// ${options.secretFieldName} is write-only: persist it server-side and expose ${options.secretStateFieldName} in responses instead of returning the raw value.`,
113
+ ]
114
+ : [];
115
+ lines.push("", `export interface ${options.bodyTypeName} {`, ...secretLines, "\tpayload: string & tags.MinLength< 1 >;", "\tcomment?: string & tags.MaxLength< 500 >;", "}");
116
+ }
117
+ lines.push("", `export interface ${options.responseTypeName} {`, ...(options.secretStateFieldName
118
+ ? [
119
+ `\t${options.secretStateFieldName}: boolean;`,
120
+ `\t// Raw secret fields such as ${options.secretFieldName ?? "the request secret"} must never be returned in this response.`,
121
+ ]
122
+ : []), "\tid: string & tags.MinLength< 1 >;", "\tstatus: 'ok' | 'error';", "\tmessage?: string;", "\tupdatedAt?: string;", "}", "", `// ${title} is a manual REST contract: edit these types to match the external route owner.`);
123
+ return `${lines.join("\n")}\n`;
124
+ }
125
+ /**
126
+ * Build Typia validator source for a manual REST contract.
127
+ *
128
+ * @param options Manual contract type names to validate.
129
+ * @param options.bodyTypeName Optional exported body type name.
130
+ * @param options.queryTypeName Exported query type name.
131
+ * @param options.responseTypeName Exported response type name.
132
+ * @returns TypeScript source for `api-validators.ts`.
133
+ */
134
+ export function buildManualRestContractValidatorsSource(options) {
135
+ const importedTypes = [
136
+ options.queryTypeName,
137
+ ...(options.bodyTypeName ? [options.bodyTypeName] : []),
138
+ options.responseTypeName,
139
+ ].sort();
140
+ const validatorDeclarations = [
141
+ `const validateQuery = typia.createValidate< ${options.queryTypeName} >();`,
142
+ ...(options.bodyTypeName
143
+ ? [`const validateRequest = typia.createValidate< ${options.bodyTypeName} >();`]
144
+ : []),
145
+ `const validateResponse = typia.createValidate< ${options.responseTypeName} >();`,
146
+ ];
147
+ const validatorEntries = [
148
+ `\tquery: ( input: unknown ) => toValidationResult< ${options.queryTypeName} >( validateQuery( input ) ),`,
149
+ ...(options.bodyTypeName
150
+ ? [
151
+ `\trequest: ( input: unknown ) => toValidationResult< ${options.bodyTypeName} >( validateRequest( input ) ),`,
152
+ ]
153
+ : []),
154
+ `\tresponse: ( input: unknown ) => toValidationResult< ${options.responseTypeName} >( validateResponse( input ) ),`,
155
+ ];
156
+ return `import typia from 'typia';
157
+
158
+ import { toValidationResult } from '@wp-typia/rest';
159
+ import type {
160
+ \t${importedTypes.join(",\n\t")},
161
+ } from './api-types';
162
+
163
+ ${validatorDeclarations.join("\n")}
164
+
165
+ export const apiValidators = {
166
+ ${validatorEntries.join("\n")}
167
+ };
168
+ `;
169
+ }
170
+ /**
171
+ * Build the public API shim for a manual REST contract.
172
+ *
173
+ * @param options Manual REST contract operation and request type metadata.
174
+ * @returns TypeScript source that re-exports the generated endpoint client.
175
+ */
176
+ export function buildManualRestContractApiSource(options) {
177
+ const pascalCase = toPascalCase(options.restResourceSlug);
178
+ const operationId = `call${pascalCase}ManualRestContract`;
179
+ const requestTypeName = options.bodyTypeName
180
+ ? `${pascalCase}ManualRestContractRequest`
181
+ : options.queryTypeName;
182
+ const requestTypeSource = options.bodyTypeName
183
+ ? `export interface ${requestTypeName} {
184
+ \tbody: ${options.bodyTypeName};
185
+ \tquery: ${options.queryTypeName};
186
+ }
187
+
188
+ `
189
+ : "";
190
+ const typeImports = options.bodyTypeName
191
+ ? [options.bodyTypeName, options.queryTypeName]
192
+ : [options.queryTypeName];
193
+ return `import {
194
+ \tcallEndpoint,
195
+ \tresolveRestRouteUrl,
196
+ } from '@wp-typia/rest';
197
+
198
+ import type {
199
+ \t${typeImports.sort().join(",\n\t")},
200
+ } from './api-types';
201
+ import { ${operationId}Endpoint } from './api-client';
202
+
203
+ export * from './api-client';
204
+
205
+ ${requestTypeSource}${formatResolveRestNonceSource("compact")}
206
+
207
+ function resolveEndpointRouteOptions(request: ${requestTypeName}) {
208
+ \tconst requestOptions = ${operationId}Endpoint.buildRequestOptions?.(request) ?? {};
209
+ \tconst nonce = resolveRestNonce();
210
+ \tconst requestHeaders = (
211
+ \t\trequestOptions as { headers?: Record<string, string> }
212
+ \t).headers;
213
+
214
+ \treturn {
215
+ \t\t...requestOptions,
216
+ \t\theaders: nonce
217
+ \t\t\t? {
218
+ \t\t\t\t\t...(requestHeaders ?? {}),
219
+ \t\t\t\t\t'X-WP-Nonce': nonce,
220
+ \t\t\t\t}
221
+ \t\t\t: requestHeaders,
222
+ \t\tpath: undefined,
223
+ \t\turl:
224
+ \t\t\trequestOptions.url ??
225
+ \t\t\tresolveRestRouteUrl(requestOptions.path ?? ${operationId}Endpoint.path),
226
+ \t};
227
+ }
228
+
229
+ export const manualRestContractEndpoint = {
230
+ \t...${operationId}Endpoint,
231
+ \tbuildRequestOptions: resolveEndpointRouteOptions,
232
+ };
233
+
234
+ export function callManualRestContract(request: ${requestTypeName}) {
235
+ \treturn callEndpoint(manualRestContractEndpoint, request);
236
+ }
237
+ `;
238
+ }
@@ -2,8 +2,8 @@ import { promises as fsp } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { ensureBlockConfigCanAddRestManifests } from "./cli-add-block-legacy-validator.js";
4
4
  import { assertValidManualRestContractAuth, assertValidManualRestContractHttpMethod, assertValidTypeScriptIdentifier, collectRestRouteNamedCaptureNames, resolveOptionalPhpCallbackReference, resolveOptionalPhpClassReference, resolveManualRestContractPathPattern, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
5
- import { ensureRestResourceSyncScriptAnchors } from "./cli-add-workspace-rest-anchors.js";
6
- import { buildManualRestContractApiSource, buildManualRestContractConfigEntry, buildManualRestContractTypesSource, buildManualRestContractValidatorsSource, } from "./cli-add-workspace-rest-source-emitters.js";
5
+ import { ensureRestResourceSyncScriptAnchors, } from "./cli-add-workspace-rest-resource-sync-anchors.js";
6
+ import { buildManualRestContractApiSource, buildManualRestContractConfigEntry, buildManualRestContractTypesSource, buildManualRestContractValidatorsSource, } from "./cli-add-workspace-rest-manual-source-emitters.js";
7
7
  import { syncManualRestContractArtifacts } from "./rest-resource-artifacts.js";
8
8
  import { toPascalCase, toTitleCase } from "./string-case.js";
9
9
  import { appendWorkspaceInventoryEntries } from "./workspace-inventory.js";
@@ -15,20 +15,7 @@ const MANUAL_REST_RESPONSE_FIELD_NAMES = new Set([
15
15
  "updatedAt",
16
16
  ]);
17
17
  function resolveManualRestSecretPreserveOnEmpty(value) {
18
- if (value === undefined) {
19
- return true;
20
- }
21
- if (typeof value === "boolean") {
22
- return value;
23
- }
24
- const normalized = value.trim().toLowerCase();
25
- if (["1", "true", "yes"].includes(normalized)) {
26
- return true;
27
- }
28
- if (["0", "false", "no"].includes(normalized)) {
29
- return false;
30
- }
31
- throw new Error("Manual REST contract --secret-preserve-on-empty must be true or false.");
18
+ return value ?? true;
32
19
  }
33
20
  function resolveManualRestSecretStateFieldCandidate(options) {
34
21
  const candidates = [
@@ -1,4 +1,5 @@
1
1
  import { type RestResourceMethodId } from "./cli-add-shared.js";
2
+ export { buildWorkspaceRestSchemaHelperPhpSource, } from "./cli-add-workspace-rest-schema-helper-php-template.js";
2
3
  /**
3
4
  * Build the PHP route/controller glue for generated workspace REST resources.
4
5
  *
@@ -15,10 +16,3 @@ export declare function buildRestResourcePhpSource(restResourceSlug: string, nam
15
16
  permissionCallback?: string;
16
17
  routePattern: string;
17
18
  }): string;
18
- /**
19
- * Build the shared PHP helper loaded by workspace bootstraps for generated REST schemas.
20
- *
21
- * @param phpPrefix Plugin-scoped PHP function prefix.
22
- * @returns PHP source for `inc/rest-schema.php`.
23
- */
24
- export declare function buildWorkspaceRestSchemaHelperPhpSource(phpPrefix: string): string;