@wp-typia/project-tools 0.22.10 → 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-collision.d.ts +25 -0
- package/dist/runtime/cli-add-collision.js +76 -0
- package/dist/runtime/cli-add-help.js +12 -2
- package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
- package/dist/runtime/cli-add-kind-ids.js +3 -0
- package/dist/runtime/cli-add-types.d.ts +129 -0
- package/dist/runtime/cli-add-types.js +26 -0
- package/dist/runtime/cli-add-validation.d.ts +97 -1
- package/dist/runtime/cli-add-validation.js +313 -1
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +4 -1
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +79 -20
- package/dist/runtime/cli-add-workspace-admin-view-source.js +11 -2
- 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 +19 -10
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +31 -971
- package/dist/runtime/cli-add-workspace-admin-view-types.d.ts +21 -0
- package/dist/runtime/cli-add-workspace-admin-view-types.js +22 -0
- package/dist/runtime/cli-add-workspace-ai-anchors.js +125 -32
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +17 -1
- package/dist/runtime/cli-add-workspace-contract-source-emitters.d.ts +15 -0
- package/dist/runtime/cli-add-workspace-contract-source-emitters.js +42 -0
- package/dist/runtime/cli-add-workspace-contract.d.ts +15 -0
- package/dist/runtime/cli-add-workspace-contract.js +65 -0
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +26 -0
- package/dist/runtime/cli-add-workspace-integration-env.js +428 -0
- package/dist/runtime/cli-add-workspace-post-meta-anchors.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-post-meta-anchors.js +244 -0
- package/dist/runtime/cli-add-workspace-post-meta-source-emitters.d.ts +63 -0
- package/dist/runtime/cli-add-workspace-post-meta-source-emitters.js +179 -0
- package/dist/runtime/cli-add-workspace-post-meta.d.ts +15 -0
- package/dist/runtime/cli-add-workspace-post-meta.js +107 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.js +326 -21
- 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 +98 -2
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +323 -29
- 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 -7
- package/dist/runtime/cli-add-workspace-rest.js +34 -481
- package/dist/runtime/cli-add-workspace.d.ts +15 -0
- package/dist/runtime/cli-add-workspace.js +15 -0
- package/dist/runtime/cli-add.d.ts +1 -1
- package/dist/runtime/cli-add.js +1 -1
- package/dist/runtime/cli-core.d.ts +3 -2
- package/dist/runtime/cli-core.js +3 -2
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-environment.js +1 -3
- 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 -369
- package/dist/runtime/cli-doctor-workspace-package.d.ts +25 -3
- package/dist/runtime/cli-doctor-workspace-package.js +35 -13
- package/dist/runtime/cli-doctor-workspace-shared.d.ts +2 -0
- package/dist/runtime/cli-doctor-workspace-shared.js +2 -0
- package/dist/runtime/cli-doctor-workspace.js +8 -3
- package/dist/runtime/cli-doctor.d.ts +52 -3
- package/dist/runtime/cli-doctor.js +79 -8
- package/dist/runtime/cli-help.js +10 -0
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-init-templates.js +11 -1
- 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/contract-artifacts.d.ts +14 -0
- package/dist/runtime/contract-artifacts.js +15 -0
- 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/rest-resource-artifacts.d.ts +57 -1
- package/dist/runtime/rest-resource-artifacts.js +97 -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-render.d.ts +1 -1
- package/dist/runtime/template-render.js +1 -1
- package/dist/runtime/template-source-cache-markers.d.ts +37 -0
- package/dist/runtime/template-source-cache-markers.js +125 -0
- package/dist/runtime/template-source-cache.d.ts +1 -4
- package/dist/runtime/template-source-cache.js +16 -122
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-external.d.ts +4 -2
- package/dist/runtime/template-source-external.js +4 -2
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.d.ts +8 -4
- package/dist/runtime/template-source-remote.js +26 -9
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/workspace-inventory-mutations.js +54 -4
- 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 -44
- package/dist/runtime/workspace-inventory-parser.js +7 -464
- package/dist/runtime/workspace-inventory-read.d.ts +9 -2
- package/dist/runtime/workspace-inventory-read.js +9 -2
- 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 +16 -1
- package/dist/runtime/workspace-inventory-templates.js +75 -4
- package/dist/runtime/workspace-inventory-types.d.ts +52 -2
- package/dist/runtime/workspace-inventory.d.ts +2 -2
- package/dist/runtime/workspace-inventory.js +1 -1
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +2 -2
|
@@ -1,5 +1,101 @@
|
|
|
1
|
-
import { type RestResourceMethodId } from "./cli-add-shared.js";
|
|
2
|
-
|
|
1
|
+
import { type ManualRestContractAuthId, type ManualRestContractHttpMethodId, type RestResourceMethodId } from "./cli-add-shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build a generated REST resource config entry for `scripts/block-config.ts`.
|
|
4
|
+
*
|
|
5
|
+
* @param options REST resource metadata. `restResourceSlug`, `namespace`, and
|
|
6
|
+
* `methods` are required; `controllerClass`, `controllerExtends`,
|
|
7
|
+
* `permissionCallback`, and `routePattern` opt into generated controller,
|
|
8
|
+
* permission, and item-route escape hatches.
|
|
9
|
+
* @returns TypeScript object literal source for one generated REST resource entry.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildRestResourceConfigEntry(options: {
|
|
12
|
+
controllerClass?: string;
|
|
13
|
+
controllerExtends?: string;
|
|
14
|
+
methods: RestResourceMethodId[];
|
|
15
|
+
namespace: string;
|
|
16
|
+
permissionCallback?: string;
|
|
17
|
+
restResourceSlug: string;
|
|
18
|
+
routePattern?: string;
|
|
19
|
+
}): string;
|
|
20
|
+
/**
|
|
21
|
+
* Build the `REST_RESOURCES` config entry appended for a manual REST contract.
|
|
22
|
+
*
|
|
23
|
+
* @param options Manual contract file, route, type, and auth metadata.
|
|
24
|
+
* @param options.auth Auth intent stored in the endpoint manifest.
|
|
25
|
+
* @param options.bodyTypeName Optional exported body type name.
|
|
26
|
+
* @param options.method Uppercase HTTP method for the external route.
|
|
27
|
+
* @param options.namespace REST namespace such as `vendor/v1`.
|
|
28
|
+
* @param options.pathPattern Route pattern relative to the namespace.
|
|
29
|
+
* @param options.queryTypeName Exported query type name.
|
|
30
|
+
* @param options.responseTypeName Exported response type name.
|
|
31
|
+
* @param options.restResourceSlug Normalized workspace REST contract slug.
|
|
32
|
+
* @returns A TypeScript object literal string for `scripts/block-config.ts`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildManualRestContractConfigEntry(options: {
|
|
35
|
+
auth: ManualRestContractAuthId;
|
|
36
|
+
bodyTypeName?: string;
|
|
37
|
+
controllerClass?: string;
|
|
38
|
+
controllerExtends?: string;
|
|
39
|
+
method: ManualRestContractHttpMethodId;
|
|
40
|
+
namespace: string;
|
|
41
|
+
pathPattern: string;
|
|
42
|
+
permissionCallback?: string;
|
|
43
|
+
queryTypeName: string;
|
|
44
|
+
responseTypeName: string;
|
|
45
|
+
restResourceSlug: string;
|
|
46
|
+
secretFieldName?: string;
|
|
47
|
+
secretPreserveOnEmpty?: boolean;
|
|
48
|
+
secretStateFieldName?: string;
|
|
49
|
+
}): string;
|
|
50
|
+
/**
|
|
51
|
+
* Build the editable TypeScript type source for a manual REST contract.
|
|
52
|
+
*
|
|
53
|
+
* @param options Manual contract type naming metadata.
|
|
54
|
+
* @param options.bodyTypeName Optional exported body type name.
|
|
55
|
+
* @param options.pathParameterNames Route named captures that should be present
|
|
56
|
+
* in the starter query type so generated clients can fill provider paths.
|
|
57
|
+
* @param options.queryTypeName Exported query type name.
|
|
58
|
+
* @param options.responseTypeName Exported response type name.
|
|
59
|
+
* @param options.restResourceSlug Normalized workspace REST contract slug.
|
|
60
|
+
* @param options.secretFieldName Optional raw secret field included only in the request body.
|
|
61
|
+
* @param options.secretStateFieldName Optional masked response boolean field.
|
|
62
|
+
* @returns TypeScript source for `api-types.ts`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildManualRestContractTypesSource(options: {
|
|
65
|
+
bodyTypeName?: string;
|
|
66
|
+
pathParameterNames?: string[];
|
|
67
|
+
queryTypeName: string;
|
|
68
|
+
responseTypeName: string;
|
|
69
|
+
restResourceSlug: string;
|
|
70
|
+
secretFieldName?: string;
|
|
71
|
+
secretPreserveOnEmpty?: boolean;
|
|
72
|
+
secretStateFieldName?: string;
|
|
73
|
+
}): string;
|
|
74
|
+
/**
|
|
75
|
+
* Build Typia validator source for a manual REST contract.
|
|
76
|
+
*
|
|
77
|
+
* @param options Manual contract type names to validate.
|
|
78
|
+
* @param options.bodyTypeName Optional exported body type name.
|
|
79
|
+
* @param options.queryTypeName Exported query type name.
|
|
80
|
+
* @param options.responseTypeName Exported response type name.
|
|
81
|
+
* @returns TypeScript source for `api-validators.ts`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildManualRestContractValidatorsSource(options: {
|
|
84
|
+
bodyTypeName?: string;
|
|
85
|
+
queryTypeName: string;
|
|
86
|
+
responseTypeName: string;
|
|
87
|
+
}): string;
|
|
88
|
+
/**
|
|
89
|
+
* Build the public API shim for a manual REST contract.
|
|
90
|
+
*
|
|
91
|
+
* @param options Manual REST contract operation and request type metadata.
|
|
92
|
+
* @returns TypeScript source that re-exports the generated endpoint client.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildManualRestContractApiSource(options: {
|
|
95
|
+
bodyTypeName?: string;
|
|
96
|
+
queryTypeName: string;
|
|
97
|
+
restResourceSlug: string;
|
|
98
|
+
}): string;
|
|
3
99
|
export declare function buildRestResourceTypesSource(restResourceSlug: string, methods: RestResourceMethodId[]): string;
|
|
4
100
|
export declare function buildRestResourceValidatorsSource(restResourceSlug: string, methods: RestResourceMethodId[]): string;
|
|
5
101
|
export declare function buildRestResourceApiSource(restResourceSlug: string, methods: RestResourceMethodId[]): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { quoteTsString, } from "./cli-add-shared.js";
|
|
2
|
-
import { buildRestResourceEndpointManifest } from "./rest-resource-artifacts.js";
|
|
2
|
+
import { buildManualRestContractEndpointManifest, buildRestResourceEndpointManifest, } from "./rest-resource-artifacts.js";
|
|
3
3
|
import { toPascalCase, toTitleCase } from "./string-case.js";
|
|
4
4
|
function indentMultiline(source, prefix) {
|
|
5
5
|
return source
|
|
@@ -7,33 +7,308 @@ function indentMultiline(source, prefix) {
|
|
|
7
7
|
.map((line) => `${prefix}${line}`)
|
|
8
8
|
.join("\n");
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Build a generated REST resource config entry for `scripts/block-config.ts`.
|
|
12
|
+
*
|
|
13
|
+
* @param options REST resource metadata. `restResourceSlug`, `namespace`, and
|
|
14
|
+
* `methods` are required; `controllerClass`, `controllerExtends`,
|
|
15
|
+
* `permissionCallback`, and `routePattern` opt into generated controller,
|
|
16
|
+
* permission, and item-route escape hatches.
|
|
17
|
+
* @returns TypeScript object literal source for one generated REST resource entry.
|
|
18
|
+
*/
|
|
19
|
+
export function buildRestResourceConfigEntry(options) {
|
|
20
|
+
const pascalCase = toPascalCase(options.restResourceSlug);
|
|
21
|
+
const title = toTitleCase(options.restResourceSlug);
|
|
13
22
|
const manifest = buildRestResourceEndpointManifest({
|
|
14
|
-
namespace,
|
|
23
|
+
namespace: options.namespace,
|
|
24
|
+
pascalCase,
|
|
25
|
+
...(options.routePattern ? { routePattern: options.routePattern } : {}),
|
|
26
|
+
slugKebabCase: options.restResourceSlug,
|
|
27
|
+
title,
|
|
28
|
+
}, options.methods);
|
|
29
|
+
return [
|
|
30
|
+
"\t{",
|
|
31
|
+
`\t\tapiFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api.ts`)},`,
|
|
32
|
+
...(options.controllerClass
|
|
33
|
+
? [`\t\tcontrollerClass: ${quoteTsString(options.controllerClass)},`]
|
|
34
|
+
: []),
|
|
35
|
+
...(options.controllerExtends
|
|
36
|
+
? [`\t\tcontrollerExtends: ${quoteTsString(options.controllerExtends)},`]
|
|
37
|
+
: []),
|
|
38
|
+
`\t\tclientFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-client.ts`)},`,
|
|
39
|
+
`\t\tdataFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/data.ts`)},`,
|
|
40
|
+
`\t\tmethods: [ ${options.methods.map((method) => quoteTsString(method)).join(", ")} ],`,
|
|
41
|
+
`\t\tnamespace: ${quoteTsString(options.namespace)},`,
|
|
42
|
+
`\t\topenApiFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api.openapi.json`)},`,
|
|
43
|
+
...(options.permissionCallback
|
|
44
|
+
? [`\t\tpermissionCallback: ${quoteTsString(options.permissionCallback)},`]
|
|
45
|
+
: []),
|
|
46
|
+
`\t\tphpFile: ${quoteTsString(`inc/rest/${options.restResourceSlug}.php`)},`,
|
|
47
|
+
"\t\trestManifest: defineEndpointManifest(",
|
|
48
|
+
indentMultiline(JSON.stringify(manifest, null, "\t"), "\t\t\t"),
|
|
49
|
+
"\t\t),",
|
|
50
|
+
...(options.routePattern
|
|
51
|
+
? [`\t\troutePattern: ${quoteTsString(options.routePattern)},`]
|
|
52
|
+
: []),
|
|
53
|
+
`\t\tslug: ${quoteTsString(options.restResourceSlug)},`,
|
|
54
|
+
`\t\ttypesFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-types.ts`)},`,
|
|
55
|
+
`\t\tvalidatorsFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-validators.ts`)},`,
|
|
56
|
+
"\t},",
|
|
57
|
+
].join("\n");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build the `REST_RESOURCES` config entry appended for a manual REST contract.
|
|
61
|
+
*
|
|
62
|
+
* @param options Manual contract file, route, type, and auth metadata.
|
|
63
|
+
* @param options.auth Auth intent stored in the endpoint manifest.
|
|
64
|
+
* @param options.bodyTypeName Optional exported body type name.
|
|
65
|
+
* @param options.method Uppercase HTTP method for the external route.
|
|
66
|
+
* @param options.namespace REST namespace such as `vendor/v1`.
|
|
67
|
+
* @param options.pathPattern Route pattern relative to the namespace.
|
|
68
|
+
* @param options.queryTypeName Exported query type name.
|
|
69
|
+
* @param options.responseTypeName Exported response type name.
|
|
70
|
+
* @param options.restResourceSlug Normalized workspace REST contract slug.
|
|
71
|
+
* @returns A TypeScript object literal string for `scripts/block-config.ts`.
|
|
72
|
+
*/
|
|
73
|
+
export function buildManualRestContractConfigEntry(options) {
|
|
74
|
+
const pascalCase = toPascalCase(options.restResourceSlug);
|
|
75
|
+
const title = toTitleCase(options.restResourceSlug);
|
|
76
|
+
const manifest = buildManualRestContractEndpointManifest({
|
|
77
|
+
auth: options.auth,
|
|
78
|
+
...(options.bodyTypeName ? { bodyTypeName: options.bodyTypeName } : {}),
|
|
79
|
+
method: options.method,
|
|
80
|
+
namespace: options.namespace,
|
|
15
81
|
pascalCase,
|
|
16
|
-
|
|
82
|
+
pathPattern: options.pathPattern,
|
|
83
|
+
queryTypeName: options.queryTypeName,
|
|
84
|
+
responseTypeName: options.responseTypeName,
|
|
85
|
+
slugKebabCase: options.restResourceSlug,
|
|
17
86
|
title,
|
|
18
|
-
}
|
|
87
|
+
});
|
|
19
88
|
return [
|
|
20
89
|
"\t{",
|
|
21
|
-
`\t\tapiFile: ${quoteTsString(`src/rest/${restResourceSlug}/api.ts`)},`,
|
|
22
|
-
`\t\
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`\t\
|
|
27
|
-
|
|
90
|
+
`\t\tapiFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api.ts`)},`,
|
|
91
|
+
`\t\tauth: ${quoteTsString(options.auth)},`,
|
|
92
|
+
...(options.bodyTypeName
|
|
93
|
+
? [`\t\tbodyTypeName: ${quoteTsString(options.bodyTypeName)},`]
|
|
94
|
+
: []),
|
|
95
|
+
`\t\tclientFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-client.ts`)},`,
|
|
96
|
+
...(options.controllerClass
|
|
97
|
+
? [`\t\tcontrollerClass: ${quoteTsString(options.controllerClass)},`]
|
|
98
|
+
: []),
|
|
99
|
+
...(options.controllerExtends
|
|
100
|
+
? [`\t\tcontrollerExtends: ${quoteTsString(options.controllerExtends)},`]
|
|
101
|
+
: []),
|
|
102
|
+
`\t\tmethod: ${quoteTsString(options.method)},`,
|
|
103
|
+
"\t\tmethods: [],",
|
|
104
|
+
"\t\tmode: 'manual',",
|
|
105
|
+
`\t\tnamespace: ${quoteTsString(options.namespace)},`,
|
|
106
|
+
`\t\topenApiFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api.openapi.json`)},`,
|
|
107
|
+
`\t\tpathPattern: ${quoteTsString(options.pathPattern)},`,
|
|
108
|
+
...(options.permissionCallback
|
|
109
|
+
? [`\t\tpermissionCallback: ${quoteTsString(options.permissionCallback)},`]
|
|
110
|
+
: []),
|
|
111
|
+
`\t\tqueryTypeName: ${quoteTsString(options.queryTypeName)},`,
|
|
28
112
|
"\t\trestManifest: defineEndpointManifest(",
|
|
29
113
|
indentMultiline(JSON.stringify(manifest, null, "\t"), "\t\t\t"),
|
|
30
114
|
"\t\t),",
|
|
31
|
-
`\t\
|
|
32
|
-
|
|
33
|
-
|
|
115
|
+
`\t\tresponseTypeName: ${quoteTsString(options.responseTypeName)},`,
|
|
116
|
+
...(options.secretFieldName
|
|
117
|
+
? [`\t\tsecretFieldName: ${quoteTsString(options.secretFieldName)},`]
|
|
118
|
+
: []),
|
|
119
|
+
...(options.secretPreserveOnEmpty !== undefined
|
|
120
|
+
? [`\t\tsecretPreserveOnEmpty: ${options.secretPreserveOnEmpty},`]
|
|
121
|
+
: []),
|
|
122
|
+
...(options.secretStateFieldName
|
|
123
|
+
? [`\t\tsecretStateFieldName: ${quoteTsString(options.secretStateFieldName)},`]
|
|
124
|
+
: []),
|
|
125
|
+
`\t\tslug: ${quoteTsString(options.restResourceSlug)},`,
|
|
126
|
+
`\t\ttypesFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-types.ts`)},`,
|
|
127
|
+
`\t\tvalidatorsFile: ${quoteTsString(`src/rest/${options.restResourceSlug}/api-validators.ts`)},`,
|
|
34
128
|
"\t},",
|
|
35
129
|
].join("\n");
|
|
36
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Build the editable TypeScript type source for a manual REST contract.
|
|
133
|
+
*
|
|
134
|
+
* @param options Manual contract type naming metadata.
|
|
135
|
+
* @param options.bodyTypeName Optional exported body type name.
|
|
136
|
+
* @param options.pathParameterNames Route named captures that should be present
|
|
137
|
+
* in the starter query type so generated clients can fill provider paths.
|
|
138
|
+
* @param options.queryTypeName Exported query type name.
|
|
139
|
+
* @param options.responseTypeName Exported response type name.
|
|
140
|
+
* @param options.restResourceSlug Normalized workspace REST contract slug.
|
|
141
|
+
* @param options.secretFieldName Optional raw secret field included only in the request body.
|
|
142
|
+
* @param options.secretStateFieldName Optional masked response boolean field.
|
|
143
|
+
* @returns TypeScript source for `api-types.ts`.
|
|
144
|
+
*/
|
|
145
|
+
export function buildManualRestContractTypesSource(options) {
|
|
146
|
+
const title = toTitleCase(options.restResourceSlug);
|
|
147
|
+
const pathParameterNames = Array.from(new Set(options.pathParameterNames ?? []));
|
|
148
|
+
const queryFields = pathParameterNames.length > 0
|
|
149
|
+
? pathParameterNames.map((parameterName) => `\t${parameterName}: string & tags.MinLength< 1 >;`)
|
|
150
|
+
: ["\tid?: string & tags.MinLength< 1 >;"];
|
|
151
|
+
const lines = [
|
|
152
|
+
"import type { tags } from '@wp-typia/block-runtime/typia-tags';",
|
|
153
|
+
"",
|
|
154
|
+
`export interface ${options.queryTypeName} {`,
|
|
155
|
+
...queryFields,
|
|
156
|
+
...(pathParameterNames.includes("preview") ? [] : ["\tpreview?: boolean;"]),
|
|
157
|
+
"}",
|
|
158
|
+
];
|
|
159
|
+
if (options.bodyTypeName) {
|
|
160
|
+
const secretPreserveOnEmpty = options.secretPreserveOnEmpty ?? true;
|
|
161
|
+
const secretLines = options.secretFieldName && options.secretStateFieldName
|
|
162
|
+
? [
|
|
163
|
+
`\t${options.secretFieldName}?: string${secretPreserveOnEmpty ? " & tags.MinLength< 1 >" : ""} & tags.MaxLength< 4096 > & tags.Secret< ${quoteTsString(options.secretStateFieldName)} >${secretPreserveOnEmpty ? " & tags.PreserveOnEmpty< true >" : ""};`,
|
|
164
|
+
secretPreserveOnEmpty
|
|
165
|
+
? `\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.`
|
|
166
|
+
: `\t// ${options.secretFieldName} is write-only: persist it server-side and expose ${options.secretStateFieldName} in responses instead of returning the raw value.`,
|
|
167
|
+
]
|
|
168
|
+
: [];
|
|
169
|
+
lines.push("", `export interface ${options.bodyTypeName} {`, ...secretLines, "\tpayload: string & tags.MinLength< 1 >;", "\tcomment?: string & tags.MaxLength< 500 >;", "}");
|
|
170
|
+
}
|
|
171
|
+
lines.push("", `export interface ${options.responseTypeName} {`, ...(options.secretStateFieldName
|
|
172
|
+
? [
|
|
173
|
+
`\t${options.secretStateFieldName}: boolean;`,
|
|
174
|
+
`\t// Raw secret fields such as ${options.secretFieldName ?? "the request secret"} must never be returned in this response.`,
|
|
175
|
+
]
|
|
176
|
+
: []), "\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.`);
|
|
177
|
+
return `${lines.join("\n")}\n`;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Build Typia validator source for a manual REST contract.
|
|
181
|
+
*
|
|
182
|
+
* @param options Manual contract type names to validate.
|
|
183
|
+
* @param options.bodyTypeName Optional exported body type name.
|
|
184
|
+
* @param options.queryTypeName Exported query type name.
|
|
185
|
+
* @param options.responseTypeName Exported response type name.
|
|
186
|
+
* @returns TypeScript source for `api-validators.ts`.
|
|
187
|
+
*/
|
|
188
|
+
export function buildManualRestContractValidatorsSource(options) {
|
|
189
|
+
const importedTypes = [
|
|
190
|
+
options.queryTypeName,
|
|
191
|
+
...(options.bodyTypeName ? [options.bodyTypeName] : []),
|
|
192
|
+
options.responseTypeName,
|
|
193
|
+
].sort();
|
|
194
|
+
const validatorDeclarations = [
|
|
195
|
+
`const validateQuery = typia.createValidate< ${options.queryTypeName} >();`,
|
|
196
|
+
...(options.bodyTypeName
|
|
197
|
+
? [`const validateRequest = typia.createValidate< ${options.bodyTypeName} >();`]
|
|
198
|
+
: []),
|
|
199
|
+
`const validateResponse = typia.createValidate< ${options.responseTypeName} >();`,
|
|
200
|
+
];
|
|
201
|
+
const validatorEntries = [
|
|
202
|
+
`\tquery: ( input: unknown ) => toValidationResult< ${options.queryTypeName} >( validateQuery( input ) ),`,
|
|
203
|
+
...(options.bodyTypeName
|
|
204
|
+
? [
|
|
205
|
+
`\trequest: ( input: unknown ) => toValidationResult< ${options.bodyTypeName} >( validateRequest( input ) ),`,
|
|
206
|
+
]
|
|
207
|
+
: []),
|
|
208
|
+
`\tresponse: ( input: unknown ) => toValidationResult< ${options.responseTypeName} >( validateResponse( input ) ),`,
|
|
209
|
+
];
|
|
210
|
+
return `import typia from 'typia';
|
|
211
|
+
|
|
212
|
+
import { toValidationResult } from '@wp-typia/rest';
|
|
213
|
+
import type {
|
|
214
|
+
\t${importedTypes.join(",\n\t")},
|
|
215
|
+
} from './api-types';
|
|
216
|
+
|
|
217
|
+
${validatorDeclarations.join("\n")}
|
|
218
|
+
|
|
219
|
+
export const apiValidators = {
|
|
220
|
+
${validatorEntries.join("\n")}
|
|
221
|
+
};
|
|
222
|
+
`;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Build the public API shim for a manual REST contract.
|
|
226
|
+
*
|
|
227
|
+
* @param options Manual REST contract operation and request type metadata.
|
|
228
|
+
* @returns TypeScript source that re-exports the generated endpoint client.
|
|
229
|
+
*/
|
|
230
|
+
export function buildManualRestContractApiSource(options) {
|
|
231
|
+
const pascalCase = toPascalCase(options.restResourceSlug);
|
|
232
|
+
const operationId = `call${pascalCase}ManualRestContract`;
|
|
233
|
+
const requestTypeName = options.bodyTypeName
|
|
234
|
+
? `${pascalCase}ManualRestContractRequest`
|
|
235
|
+
: options.queryTypeName;
|
|
236
|
+
const requestTypeSource = options.bodyTypeName
|
|
237
|
+
? `export interface ${requestTypeName} {
|
|
238
|
+
\tbody: ${options.bodyTypeName};
|
|
239
|
+
\tquery: ${options.queryTypeName};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
`
|
|
243
|
+
: "";
|
|
244
|
+
const typeImports = options.bodyTypeName
|
|
245
|
+
? [options.bodyTypeName, options.queryTypeName]
|
|
246
|
+
: [options.queryTypeName];
|
|
247
|
+
return `import {
|
|
248
|
+
\tcallEndpoint,
|
|
249
|
+
\tresolveRestRouteUrl,
|
|
250
|
+
} from '@wp-typia/rest';
|
|
251
|
+
|
|
252
|
+
import type {
|
|
253
|
+
\t${typeImports.sort().join(",\n\t")},
|
|
254
|
+
} from './api-types';
|
|
255
|
+
import { ${operationId}Endpoint } from './api-client';
|
|
256
|
+
|
|
257
|
+
export * from './api-client';
|
|
258
|
+
|
|
259
|
+
${requestTypeSource}function resolveRestNonce(fallback?: string): string | undefined {
|
|
260
|
+
\tif (typeof fallback === 'string' && fallback.length > 0) {
|
|
261
|
+
\t\treturn fallback;
|
|
262
|
+
\t}
|
|
263
|
+
|
|
264
|
+
\tif (typeof window === 'undefined') {
|
|
265
|
+
\t\treturn undefined;
|
|
266
|
+
\t}
|
|
267
|
+
|
|
268
|
+
\tconst wpApiSettings = (
|
|
269
|
+
\t\twindow as typeof window & {
|
|
270
|
+
\t\t\twpApiSettings?: { nonce?: string };
|
|
271
|
+
\t\t}
|
|
272
|
+
\t).wpApiSettings;
|
|
273
|
+
|
|
274
|
+
\treturn typeof wpApiSettings?.nonce === 'string' &&
|
|
275
|
+
\t\twpApiSettings.nonce.length > 0
|
|
276
|
+
\t\t? wpApiSettings.nonce
|
|
277
|
+
\t\t: undefined;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function resolveEndpointRouteOptions(request: ${requestTypeName}) {
|
|
281
|
+
\tconst requestOptions = ${operationId}Endpoint.buildRequestOptions?.(request) ?? {};
|
|
282
|
+
\tconst nonce = resolveRestNonce();
|
|
283
|
+
\tconst requestHeaders = (
|
|
284
|
+
\t\trequestOptions as { headers?: Record<string, string> }
|
|
285
|
+
\t).headers;
|
|
286
|
+
|
|
287
|
+
\treturn {
|
|
288
|
+
\t\t...requestOptions,
|
|
289
|
+
\t\theaders: nonce
|
|
290
|
+
\t\t\t? {
|
|
291
|
+
\t\t\t\t\t...(requestHeaders ?? {}),
|
|
292
|
+
\t\t\t\t\t'X-WP-Nonce': nonce,
|
|
293
|
+
\t\t\t\t}
|
|
294
|
+
\t\t\t: requestHeaders,
|
|
295
|
+
\t\tpath: undefined,
|
|
296
|
+
\t\turl:
|
|
297
|
+
\t\t\trequestOptions.url ??
|
|
298
|
+
\t\t\tresolveRestRouteUrl(requestOptions.path ?? ${operationId}Endpoint.path),
|
|
299
|
+
\t};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export const manualRestContractEndpoint = {
|
|
303
|
+
\t...${operationId}Endpoint,
|
|
304
|
+
\tbuildRequestOptions: resolveEndpointRouteOptions,
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export function callManualRestContract(request: ${requestTypeName}) {
|
|
308
|
+
\treturn callEndpoint(manualRestContractEndpoint, request);
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
}
|
|
37
312
|
export function buildRestResourceTypesSource(restResourceSlug, methods) {
|
|
38
313
|
const pascalCase = toPascalCase(restResourceSlug);
|
|
39
314
|
const lines = [
|
|
@@ -122,9 +397,8 @@ export function buildRestResourceApiSource(restResourceSlug, methods) {
|
|
|
122
397
|
clientEndpointImports.push(`list${pascalCase}ResourcesEndpoint`);
|
|
123
398
|
exportedBindings.push(`export const restResourceListEndpoint = {
|
|
124
399
|
\t...list${pascalCase}ResourcesEndpoint,
|
|
125
|
-
\tbuildRequestOptions: () =>
|
|
126
|
-
\t\
|
|
127
|
-
\t} ),
|
|
400
|
+
\tbuildRequestOptions: ( request: ${pascalCase}ListQuery ) =>
|
|
401
|
+
\t\tresolveEndpointRouteOptions( list${pascalCase}ResourcesEndpoint, request ),
|
|
128
402
|
};
|
|
129
403
|
|
|
130
404
|
export function listResource( request: ${pascalCase}ListQuery ) {
|
|
@@ -136,9 +410,8 @@ export function listResource( request: ${pascalCase}ListQuery ) {
|
|
|
136
410
|
clientEndpointImports.push(`read${pascalCase}ResourceEndpoint`);
|
|
137
411
|
exportedBindings.push(`export const restResourceReadEndpoint = {
|
|
138
412
|
\t...read${pascalCase}ResourceEndpoint,
|
|
139
|
-
\tbuildRequestOptions: () =>
|
|
140
|
-
\t\
|
|
141
|
-
\t} ),
|
|
413
|
+
\tbuildRequestOptions: ( request: ${pascalCase}ReadQuery ) =>
|
|
414
|
+
\t\tresolveEndpointRouteOptions( read${pascalCase}ResourceEndpoint, request ),
|
|
142
415
|
};
|
|
143
416
|
|
|
144
417
|
export function readResource( request: ${pascalCase}ReadQuery ) {
|
|
@@ -150,15 +423,15 @@ export function readResource( request: ${pascalCase}ReadQuery ) {
|
|
|
150
423
|
clientEndpointImports.push(`create${pascalCase}ResourceEndpoint`);
|
|
151
424
|
exportedBindings.push(`export const restResourceCreateEndpoint = {
|
|
152
425
|
\t...create${pascalCase}ResourceEndpoint,
|
|
153
|
-
\tbuildRequestOptions: () => {
|
|
426
|
+
\tbuildRequestOptions: ( request: ${pascalCase}CreateRequest ) => {
|
|
154
427
|
\t\tconst nonce = resolveRestNonce();
|
|
155
428
|
\t\treturn {
|
|
429
|
+
\t\t\t...resolveEndpointRouteOptions( create${pascalCase}ResourceEndpoint, request ),
|
|
156
430
|
\t\t\theaders: nonce
|
|
157
431
|
\t\t\t\t? {
|
|
158
432
|
\t\t\t\t\t'X-WP-Nonce': nonce,
|
|
159
433
|
\t\t\t\t}
|
|
160
434
|
\t\t\t\t: undefined,
|
|
161
|
-
\t\t\turl: resolveRestRouteUrl( create${pascalCase}ResourceEndpoint.path ),
|
|
162
435
|
\t\t};
|
|
163
436
|
\t},
|
|
164
437
|
};
|
|
@@ -173,15 +446,18 @@ export function createResource( request: ${pascalCase}CreateRequest ) {
|
|
|
173
446
|
clientEndpointImports.push(`update${pascalCase}ResourceEndpoint`);
|
|
174
447
|
exportedBindings.push(`export const restResourceUpdateEndpoint = {
|
|
175
448
|
\t...update${pascalCase}ResourceEndpoint,
|
|
176
|
-
\tbuildRequestOptions: (
|
|
449
|
+
\tbuildRequestOptions: ( request: {
|
|
450
|
+
\t\tbody: ${pascalCase}UpdateRequest;
|
|
451
|
+
\t\tquery: ${pascalCase}UpdateQuery;
|
|
452
|
+
\t} ) => {
|
|
177
453
|
\t\tconst nonce = resolveRestNonce();
|
|
178
454
|
\t\treturn {
|
|
455
|
+
\t\t\t...resolveEndpointRouteOptions( update${pascalCase}ResourceEndpoint, request ),
|
|
179
456
|
\t\t\theaders: nonce
|
|
180
457
|
\t\t\t\t? {
|
|
181
458
|
\t\t\t\t\t'X-WP-Nonce': nonce,
|
|
182
459
|
\t\t\t\t}
|
|
183
460
|
\t\t\t\t: undefined,
|
|
184
|
-
\t\t\turl: resolveRestRouteUrl( update${pascalCase}ResourceEndpoint.path ),
|
|
185
461
|
\t\t};
|
|
186
462
|
\t},
|
|
187
463
|
};
|
|
@@ -198,15 +474,15 @@ export function updateResource( request: {
|
|
|
198
474
|
clientEndpointImports.push(`delete${pascalCase}ResourceEndpoint`);
|
|
199
475
|
exportedBindings.push(`export const restResourceDeleteEndpoint = {
|
|
200
476
|
\t...delete${pascalCase}ResourceEndpoint,
|
|
201
|
-
\tbuildRequestOptions: () => {
|
|
477
|
+
\tbuildRequestOptions: ( request: ${pascalCase}DeleteQuery ) => {
|
|
202
478
|
\t\tconst nonce = resolveRestNonce();
|
|
203
479
|
\t\treturn {
|
|
480
|
+
\t\t\t...resolveEndpointRouteOptions( delete${pascalCase}ResourceEndpoint, request ),
|
|
204
481
|
\t\t\theaders: nonce
|
|
205
482
|
\t\t\t\t? {
|
|
206
483
|
\t\t\t\t\t'X-WP-Nonce': nonce,
|
|
207
484
|
\t\t\t\t}
|
|
208
485
|
\t\t\t\t: undefined,
|
|
209
|
-
\t\t\turl: resolveRestRouteUrl( delete${pascalCase}ResourceEndpoint.path ),
|
|
210
486
|
\t\t};
|
|
211
487
|
\t},
|
|
212
488
|
};
|
|
@@ -251,6 +527,24 @@ import {
|
|
|
251
527
|
\t${clientEndpointImports.sort().join(",\n\t")},
|
|
252
528
|
} from './api-client';
|
|
253
529
|
${resolveRestNonceSource}
|
|
530
|
+
function resolveEndpointRouteOptions<TRequest>(
|
|
531
|
+
\tendpoint: {
|
|
532
|
+
\t\tbuildRequestOptions?: ( request: TRequest ) => {
|
|
533
|
+
\t\t\tpath?: string;
|
|
534
|
+
\t\t\turl?: string;
|
|
535
|
+
\t\t};
|
|
536
|
+
\t\tpath: string;
|
|
537
|
+
\t},
|
|
538
|
+
\trequest: TRequest
|
|
539
|
+
) {
|
|
540
|
+
\tconst requestOptions = endpoint.buildRequestOptions?.( request ) ?? {};
|
|
541
|
+
\treturn {
|
|
542
|
+
\t\t...requestOptions,
|
|
543
|
+
\t\tpath: undefined,
|
|
544
|
+
\t\turl: requestOptions.url ?? resolveRestRouteUrl( requestOptions.path ?? endpoint.path ),
|
|
545
|
+
\t};
|
|
546
|
+
}
|
|
547
|
+
|
|
254
548
|
${exportedBindings.join("\n\n")}
|
|
255
549
|
`;
|
|
256
550
|
}
|
|
@@ -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 true/false string or boolean for
|
|
62
|
+
* blank-secret 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 | string | 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
|
|
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,9 +7,4 @@ import { type RestResourceMethodId, type RunAddRestResourceCommandOptions } from
|
|
|
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({ cwd, methods, namespace, restResourceName, }: RunAddRestResourceCommandOptions): Promise<
|
|
10
|
-
methods: RestResourceMethodId[];
|
|
11
|
-
namespace: string;
|
|
12
|
-
projectDir: string;
|
|
13
|
-
restResourceSlug: string;
|
|
14
|
-
}>;
|
|
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>;
|