@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.
- package/dist/runtime/ai-feature-artifacts.js +4 -1
- package/dist/runtime/block-generator-service-spec.js +2 -1
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
- package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
- package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
- package/dist/runtime/cli-add-block-json.js +5 -1
- package/dist/runtime/cli-add-collision.js +8 -0
- package/dist/runtime/cli-add-help.js +14 -10
- package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
- package/dist/runtime/cli-add-kind-ids.js +1 -0
- package/dist/runtime/cli-add-types.d.ts +45 -6
- package/dist/runtime/cli-add-types.js +2 -0
- package/dist/runtime/cli-add-validation.d.ts +7 -0
- package/dist/runtime/cli-add-validation.js +9 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
- package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -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 +18 -27
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
- package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
- package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
- package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
- package/dist/runtime/cli-add-workspace-assets.js +6 -950
- package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
- package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
- package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
- package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-block-style.js +148 -0
- package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
- package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
- package/dist/runtime/cli-add-workspace-contract.js +1 -1
- package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
- package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
- package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
- package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
- package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
- package/dist/runtime/cli-add-workspace-pattern.js +99 -0
- package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
- package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
- package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
- package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
- package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
- package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
- package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
- package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
- package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
- package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
- package/dist/runtime/cli-add-workspace-rest.js +33 -788
- package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-variation.js +162 -0
- package/dist/runtime/cli-add-workspace.d.ts +42 -107
- package/dist/runtime/cli-add-workspace.js +42 -674
- package/dist/runtime/cli-add.d.ts +3 -3
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +3 -2
- package/dist/runtime/cli-core.js +2 -2
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
- package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
- package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
- package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
- package/dist/runtime/cli-doctor-workspace-features.js +14 -487
- package/dist/runtime/cli-doctor.d.ts +54 -3
- package/dist/runtime/cli-doctor.js +92 -10
- package/dist/runtime/cli-help.js +12 -7
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-prompt.d.ts +16 -2
- package/dist/runtime/cli-prompt.js +29 -12
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +19 -10
- package/dist/runtime/external-template-guards.js +4 -6
- package/dist/runtime/index.d.ts +6 -3
- package/dist/runtime/index.js +4 -2
- package/dist/runtime/json-utils.d.ts +62 -4
- package/dist/runtime/json-utils.js +78 -4
- package/dist/runtime/local-dev-presets.js +6 -2
- 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.d.ts +1 -0
- package/dist/runtime/package-versions.js +16 -3
- package/dist/runtime/pattern-catalog.d.ts +122 -0
- package/dist/runtime/pattern-catalog.js +471 -0
- package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
- package/dist/runtime/post-meta-binding-fields.js +135 -0
- package/dist/runtime/scaffold-bootstrap.js +7 -2
- package/dist/runtime/scaffold-package-manager-files.js +5 -1
- package/dist/runtime/scaffold-repository-reference.js +4 -2
- package/dist/runtime/scaffold-template-variables.js +2 -1
- package/dist/runtime/scaffold.d.ts +18 -1
- package/dist/runtime/scaffold.js +55 -2
- package/dist/runtime/temp-roots.js +4 -1
- package/dist/runtime/template-layers.js +4 -1
- package/dist/runtime/template-registry.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.js +18 -5
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
- package/dist/runtime/typia-llm-json-schema.js +33 -0
- package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
- package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
- package/dist/runtime/typia-llm-projection.d.ts +25 -0
- package/dist/runtime/typia-llm-projection.js +58 -0
- package/dist/runtime/typia-llm-render.d.ts +21 -0
- package/dist/runtime/typia-llm-render.js +252 -0
- package/dist/runtime/typia-llm-sync.d.ts +10 -0
- package/dist/runtime/typia-llm-sync.js +63 -0
- package/dist/runtime/typia-llm-types.d.ts +197 -0
- package/dist/runtime/typia-llm-types.js +1 -0
- package/dist/runtime/typia-llm.d.ts +9 -255
- package/dist/runtime/typia-llm.js +5 -634
- package/dist/runtime/workspace-inventory-mutations.js +15 -1
- package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
- package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
- package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
- package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
- package/dist/runtime/workspace-inventory-parser.js +3 -581
- package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
- package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
- package/dist/runtime/workspace-inventory-templates.js +10 -1
- package/dist/runtime/workspace-inventory-types.d.ts +10 -1
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +8 -3
- package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
- package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
- package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
- package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
|
@@ -3,6 +3,7 @@ import { execSync } from "node:child_process";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { formatInstallCommand, getPackageManager, transformPackageManagerText, } from "./package-managers.js";
|
|
5
5
|
import { readOptionalUtf8File } from "./fs-async.js";
|
|
6
|
+
import { safeJsonParse } from "./json-utils.js";
|
|
6
7
|
const LOCKFILES = {
|
|
7
8
|
bun: ["bun.lock", "bun.lockb"],
|
|
8
9
|
npm: ["package-lock.json"],
|
|
@@ -38,7 +39,10 @@ export async function normalizePackageJson(targetDir, packageManagerId) {
|
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
const packageManager = getPackageManager(packageManagerId);
|
|
41
|
-
const packageJson =
|
|
42
|
+
const packageJson = safeJsonParse(packageJsonSource, {
|
|
43
|
+
context: "generated package manifest",
|
|
44
|
+
filePath: packageJsonPath,
|
|
45
|
+
});
|
|
42
46
|
if (packageManagerId === "npm") {
|
|
43
47
|
delete packageJson.packageManager;
|
|
44
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import { createRequire } from "node:module";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { getOptionalNodeErrorCode } from "./fs-async.js";
|
|
4
|
+
import { readJsonFileSync } from "./json-utils.js";
|
|
5
5
|
import { PROJECT_TOOLS_PACKAGE_ROOT } from "./template-registry.js";
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
7
|
/**
|
|
@@ -11,7 +11,9 @@ const require = createRequire(import.meta.url);
|
|
|
11
11
|
export const DEFAULT_SCAFFOLD_REPOSITORY_REFERENCE = "imjlk/wp-typia";
|
|
12
12
|
function readRepositoryPackageManifest(packageJsonPath) {
|
|
13
13
|
try {
|
|
14
|
-
return
|
|
14
|
+
return readJsonFileSync(packageJsonPath, {
|
|
15
|
+
context: "repository package manifest",
|
|
16
|
+
});
|
|
15
17
|
}
|
|
16
18
|
catch (error) {
|
|
17
19
|
if (getOptionalNodeErrorCode(error) === "ENOENT") {
|
|
@@ -23,7 +23,7 @@ export function getTemplateVariables(templateId, answers) {
|
|
|
23
23
|
templateId,
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, } = getPackageVersions();
|
|
26
|
+
const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, wpTypiaPackageVersion, } = getPackageVersions();
|
|
27
27
|
const template = isBuiltInTemplateId(templateId) ? getTemplateById(templateId) : null;
|
|
28
28
|
const metadataDefaults = isBuiltInTemplateId(templateId)
|
|
29
29
|
? getBuiltInTemplateMetadataDefaults(templateId)
|
|
@@ -94,6 +94,7 @@ export function getTemplateVariables(templateId, answers) {
|
|
|
94
94
|
hasAlternatePlainTextRenderTarget: 'false',
|
|
95
95
|
hasAlternateRenderTargets: 'false',
|
|
96
96
|
projectToolsPackageVersion,
|
|
97
|
+
wpTypiaPackageVersion,
|
|
97
98
|
requiresAtLeast: compatibility.pluginHeader.requiresAtLeast,
|
|
98
99
|
requiresPhp: compatibility.pluginHeader.requiresPhp,
|
|
99
100
|
cssClassName,
|
|
@@ -27,6 +27,10 @@ export declare const DATA_STORAGE_MODES: readonly ["post-meta", "custom-table"];
|
|
|
27
27
|
export type DataStorageMode = (typeof DATA_STORAGE_MODES)[number];
|
|
28
28
|
export declare const PERSISTENCE_POLICIES: readonly ["authenticated", "public"];
|
|
29
29
|
export type PersistencePolicy = (typeof PERSISTENCE_POLICIES)[number];
|
|
30
|
+
/** Supported create profile ids for opt-in workspace scaffold presets. */
|
|
31
|
+
export declare const CREATE_PROFILE_IDS: readonly ["plugin-qa"];
|
|
32
|
+
/** Union of supported `wp-typia create --profile` id strings. */
|
|
33
|
+
export type CreateProfileId = (typeof CREATE_PROFILE_IDS)[number];
|
|
30
34
|
/**
|
|
31
35
|
* Normalized template variables shared by built-in and remote scaffold flows.
|
|
32
36
|
*/
|
|
@@ -58,6 +62,7 @@ export interface FlatScaffoldTemplateVariables extends Record<string, string> {
|
|
|
58
62
|
hasAlternatePlainTextRenderTarget: "false" | "true";
|
|
59
63
|
hasAlternateRenderTargets: "false" | "true";
|
|
60
64
|
projectToolsPackageVersion: string;
|
|
65
|
+
wpTypiaPackageVersion: string;
|
|
61
66
|
requiresAtLeast: string;
|
|
62
67
|
requiresPhp: string;
|
|
63
68
|
cssClassName: string;
|
|
@@ -163,6 +168,7 @@ interface ScaffoldProjectOptions {
|
|
|
163
168
|
onProgress?: ((event: ScaffoldProgressEvent) => void | Promise<void>) | undefined;
|
|
164
169
|
packageManager: PackageManagerId;
|
|
165
170
|
persistencePolicy?: PersistencePolicy;
|
|
171
|
+
profile?: CreateProfileId;
|
|
166
172
|
projectDir: string;
|
|
167
173
|
repositoryReference?: string;
|
|
168
174
|
templateId: string;
|
|
@@ -185,4 +191,15 @@ export { getTemplateVariables } from "./scaffold-template-variables.js";
|
|
|
185
191
|
export { getScaffoldTemplateVariableGroups, type BasicScaffoldTemplateVariableGroups, type CompoundScaffoldTemplateVariableGroups, type ExternalScaffoldTemplateVariableGroups, type InteractivityScaffoldTemplateVariableGroups, type PersistenceScaffoldTemplateVariableGroups, type QueryLoopScaffoldTemplateVariableGroups, type ScaffoldTemplateFamily, type ScaffoldTemplateVariableGroups, type ScaffoldTemplateVariableGroupsCarrier, } from "./scaffold-template-variable-groups.js";
|
|
186
192
|
export declare function isDataStorageMode(value: string): value is DataStorageMode;
|
|
187
193
|
export declare function isPersistencePolicy(value: string): value is PersistencePolicy;
|
|
188
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Return whether a raw string is a supported create profile id.
|
|
196
|
+
*/
|
|
197
|
+
export declare function isCreateProfileId(value: string): value is CreateProfileId;
|
|
198
|
+
/**
|
|
199
|
+
* Resolve an optional create profile flag into a validated profile id.
|
|
200
|
+
*
|
|
201
|
+
* Empty input disables profile application; unknown ids throw with the allowed
|
|
202
|
+
* profile list for CLI diagnostics.
|
|
203
|
+
*/
|
|
204
|
+
export declare function resolveCreateProfileId(profile?: string): CreateProfileId | undefined;
|
|
205
|
+
export declare function scaffoldProject({ projectDir, templateId, answers, alternateRenderTargets, dataStorageMode, persistencePolicy, packageManager, externalLayerId, externalLayerSource, externalLayerSourceLabel, profile, repositoryReference, cwd, allowExistingDir, noInstall, installDependencies, onProgress, variant, withMigrationUi, withTestPreset, withWpEnv, }: ScaffoldProjectOptions): Promise<ScaffoldProjectResult>;
|
package/dist/runtime/scaffold.js
CHANGED
|
@@ -3,11 +3,12 @@ import path from "node:path";
|
|
|
3
3
|
import { getPackageManager } from "./package-managers.js";
|
|
4
4
|
import { buildGitignore, buildReadme, mergeTextLines, removeQueryLoopPlaceholderFiles, replaceTextRecursively, } from "./scaffold-apply-utils.js";
|
|
5
5
|
import { applyGeneratedProjectDxPackageJson, applyLocalDevPresetFiles, } from "./local-dev-presets.js";
|
|
6
|
+
import { runAddIntegrationEnvCommand } from "./cli-add-workspace-integration-env.js";
|
|
6
7
|
import { applyMigrationUiCapability } from "./migration-ui-capability.js";
|
|
7
8
|
import { applyWorkspaceMigrationCapability, ensureScaffoldDirectory, isWorkspaceProject, seedBuiltInPersistenceArtifacts, writeStarterManifestFiles, } from "./scaffold-bootstrap.js";
|
|
8
9
|
import { defaultInstallDependencies, normalizePackageJson, normalizePackageManagerFiles, removeUnexpectedLockfiles, } from "./scaffold-package-manager-files.js";
|
|
9
10
|
import { copyInterpolatedDirectory } from "./template-render.js";
|
|
10
|
-
import { isBuiltInTemplateId, normalizeTemplateLookupId, } from "./template-registry.js";
|
|
11
|
+
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, isBuiltInTemplateId, normalizeTemplateLookupId, } from "./template-registry.js";
|
|
11
12
|
import { resolveTemplateSource } from "./template-source.js";
|
|
12
13
|
import { BlockGeneratorService, } from "./block-generator-service.js";
|
|
13
14
|
import { getTemplateVariables } from "./scaffold-template-variables.js";
|
|
@@ -16,6 +17,8 @@ import { assertExternalLayerCompositionOptions, } from "./cli-validation.js";
|
|
|
16
17
|
import { pathExists } from "./fs-async.js";
|
|
17
18
|
export const DATA_STORAGE_MODES = ["post-meta", "custom-table"];
|
|
18
19
|
export const PERSISTENCE_POLICIES = ["authenticated", "public"];
|
|
20
|
+
/** Supported create profile ids for opt-in workspace scaffold presets. */
|
|
21
|
+
export const CREATE_PROFILE_IDS = ["plugin-qa"];
|
|
19
22
|
export { buildBlockCssClassName } from "./scaffold-identifiers.js";
|
|
20
23
|
export { collectScaffoldAnswers, detectAuthor, getDefaultAnswers, resolvePackageManagerId, resolveTemplateId, } from "./scaffold-answer-resolution.js";
|
|
21
24
|
export { getTemplateVariables } from "./scaffold-template-variables.js";
|
|
@@ -26,16 +29,62 @@ export function isDataStorageMode(value) {
|
|
|
26
29
|
export function isPersistencePolicy(value) {
|
|
27
30
|
return PERSISTENCE_POLICIES.includes(value);
|
|
28
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Return whether a raw string is a supported create profile id.
|
|
34
|
+
*/
|
|
35
|
+
export function isCreateProfileId(value) {
|
|
36
|
+
return CREATE_PROFILE_IDS.includes(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve an optional create profile flag into a validated profile id.
|
|
40
|
+
*
|
|
41
|
+
* Empty input disables profile application; unknown ids throw with the allowed
|
|
42
|
+
* profile list for CLI diagnostics.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveCreateProfileId(profile) {
|
|
45
|
+
if (profile === undefined || profile.trim().length === 0) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const normalizedProfile = profile.trim();
|
|
49
|
+
if (isCreateProfileId(normalizedProfile)) {
|
|
50
|
+
return normalizedProfile;
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`Unknown create profile "${profile}". Expected one of: ${CREATE_PROFILE_IDS.join(", ")}.`);
|
|
53
|
+
}
|
|
29
54
|
function normalizeTemplateSelection(templateId) {
|
|
30
55
|
return normalizeTemplateLookupId(templateId);
|
|
31
56
|
}
|
|
57
|
+
function assertCreateProfileTemplateCompatibility({ profile, templateId, }) {
|
|
58
|
+
if (!profile) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (profile === "plugin-qa" && templateId !== OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE) {
|
|
62
|
+
throw new Error("`--profile plugin-qa` currently supports only the official workspace template. Use `--template workspace` or add QA files later with `wp-typia add integration-env <name> --wp-env --release-zip`.");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function applyCreateProfile({ profile, projectDir, }) {
|
|
66
|
+
if (profile !== "plugin-qa") {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
await runAddIntegrationEnvCommand({
|
|
70
|
+
cwd: projectDir,
|
|
71
|
+
integrationEnvName: "local-smoke",
|
|
72
|
+
service: "none",
|
|
73
|
+
withReleaseZip: true,
|
|
74
|
+
withWpEnv: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
32
77
|
async function reportScaffoldProgress(onProgress, event) {
|
|
33
78
|
await onProgress?.(event);
|
|
34
79
|
}
|
|
35
|
-
export async function scaffoldProject({ projectDir, templateId, answers, alternateRenderTargets, dataStorageMode, persistencePolicy, packageManager, externalLayerId, externalLayerSource, externalLayerSourceLabel, repositoryReference, cwd = process.cwd(), allowExistingDir = false, noInstall = false, installDependencies = undefined, onProgress = undefined, variant, withMigrationUi = false, withTestPreset = false, withWpEnv = false, }) {
|
|
80
|
+
export async function scaffoldProject({ projectDir, templateId, answers, alternateRenderTargets, dataStorageMode, persistencePolicy, packageManager, externalLayerId, externalLayerSource, externalLayerSourceLabel, profile, repositoryReference, cwd = process.cwd(), allowExistingDir = false, noInstall = false, installDependencies = undefined, onProgress = undefined, variant, withMigrationUi = false, withTestPreset = false, withWpEnv = false, }) {
|
|
36
81
|
const resolvedTemplateId = normalizeTemplateSelection(templateId);
|
|
37
82
|
const resolvedPackageManager = getPackageManager(packageManager).id;
|
|
38
83
|
const isBuiltInTemplate = isBuiltInTemplateId(resolvedTemplateId);
|
|
84
|
+
assertCreateProfileTemplateCompatibility({
|
|
85
|
+
profile,
|
|
86
|
+
templateId: resolvedTemplateId,
|
|
87
|
+
});
|
|
39
88
|
assertExternalLayerCompositionOptions({
|
|
40
89
|
externalLayerId,
|
|
41
90
|
externalLayerSource,
|
|
@@ -174,6 +223,10 @@ export async function scaffoldProject({ projectDir, templateId, answers, alterna
|
|
|
174
223
|
withWpEnv,
|
|
175
224
|
});
|
|
176
225
|
}
|
|
226
|
+
await applyCreateProfile({
|
|
227
|
+
profile,
|
|
228
|
+
projectDir,
|
|
229
|
+
});
|
|
177
230
|
await normalizePackageManagerFiles(projectDir, resolvedPackageManager);
|
|
178
231
|
await removeUnexpectedLockfiles(projectDir, resolvedPackageManager);
|
|
179
232
|
await replaceTextRecursively(projectDir, resolvedPackageManager, {
|
|
@@ -23,7 +23,10 @@ function cleanupTrackedTempRootsSync() {
|
|
|
23
23
|
try {
|
|
24
24
|
fs.rmSync(tempRoot, { force: true, recursive: true });
|
|
25
25
|
}
|
|
26
|
-
catch {
|
|
26
|
+
catch {
|
|
27
|
+
// Process-exit cleanup is best-effort: shutdown-time rm failures
|
|
28
|
+
// such as EPERM are intentionally ignored rather than made fatal.
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
function installCleanupHandlers() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { promises as fsp } from "node:fs";
|
|
3
3
|
import { pathExists } from "./fs-async.js";
|
|
4
|
+
import { readJsonFile } from "./json-utils.js";
|
|
4
5
|
import { isPlainObject } from "./object-utils.js";
|
|
5
6
|
import { getBuiltInSharedTemplateLayerDir, isBuiltInSharedTemplateLayerId, } from "./template-builtins.js";
|
|
6
7
|
import { listInterpolatedDirectoryOutputs } from "./template-render.js";
|
|
@@ -59,7 +60,9 @@ export async function loadExternalTemplateLayerManifest(sourceRoot) {
|
|
|
59
60
|
if (!(await pathExists(manifestPath))) {
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
62
|
-
const raw =
|
|
63
|
+
const raw = await readJsonFile(manifestPath, {
|
|
64
|
+
context: "template layer manifest",
|
|
65
|
+
});
|
|
63
66
|
if (!isPlainObject(raw)) {
|
|
64
67
|
throw new Error(`${TEMPLATE_LAYER_MANIFEST_FILENAME} must export a JSON object.`);
|
|
65
68
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { readJsonFileSync } from "./json-utils.js";
|
|
4
5
|
import { getBuiltInTemplateMetadataDefaults } from "./template-defaults.js";
|
|
5
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
7
|
const PROJECT_TOOLS_PACKAGE_ROOT_ENV = "WP_TYPIA_PROJECT_TOOLS_PACKAGE_ROOT";
|
|
@@ -11,7 +12,9 @@ function resolveValidProjectToolsPackageRoot(candidateRoot) {
|
|
|
11
12
|
return undefined;
|
|
12
13
|
}
|
|
13
14
|
try {
|
|
14
|
-
const packageJson =
|
|
15
|
+
const packageJson = readJsonFileSync(packageJsonPath, {
|
|
16
|
+
context: "project-tools package manifest override",
|
|
17
|
+
});
|
|
15
18
|
return packageJson.name === PROJECT_TOOLS_PACKAGE_NAME
|
|
16
19
|
? candidateRoot
|
|
17
20
|
: undefined;
|
|
@@ -42,13 +45,16 @@ export function resolvePackageRoot(startDir) {
|
|
|
42
45
|
const packageJsonPath = path.join(currentDir, "package.json");
|
|
43
46
|
if (fs.existsSync(packageJsonPath)) {
|
|
44
47
|
try {
|
|
45
|
-
const packageJson =
|
|
48
|
+
const packageJson = readJsonFileSync(packageJsonPath, {
|
|
49
|
+
context: "project-tools package root discovery manifest",
|
|
50
|
+
});
|
|
46
51
|
if (packageJson.name === PROJECT_TOOLS_PACKAGE_NAME) {
|
|
47
52
|
return currentDir;
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
catch {
|
|
51
|
-
// Ignore malformed package.json while walking upward
|
|
56
|
+
// Ignore malformed package.json while walking upward; discovery should
|
|
57
|
+
// keep searching parent directories instead of failing on unrelated files.
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
const parentDir = path.dirname(currentDir);
|
|
@@ -11,6 +11,8 @@ export interface TemplateVariableContext extends UnknownRecord {
|
|
|
11
11
|
blockRuntimePackageVersion: string;
|
|
12
12
|
/** Version string for `@wp-typia/block-types` used in generated dependencies. */
|
|
13
13
|
blockTypesPackageVersion: string;
|
|
14
|
+
/** Version string for `wp-typia` used when templates include the CLI binary locally. */
|
|
15
|
+
wpTypiaPackageVersion: string;
|
|
14
16
|
/** PascalCase block type name derived from the scaffold slug. */
|
|
15
17
|
pascalCase: string;
|
|
16
18
|
/** Snake_case PHP symbol prefix used for generated functions, constants, and keys. */
|
|
@@ -8,13 +8,14 @@ import { pathExists } from './fs-async.js';
|
|
|
8
8
|
export { renderCreateBlockExternalTemplate } from './template-source-external.js';
|
|
9
9
|
export { getTemplateProjectType, getTemplateProjectTypeAsync, getDefaultCategory, getDefaultCategoryAsync, normalizeCreateBlockSubset, normalizeWpTypiaTemplateSeed, } from './template-source-remote.js';
|
|
10
10
|
export function getTemplateVariableContext(variables) {
|
|
11
|
-
const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, } = getPackageVersions();
|
|
11
|
+
const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, wpTypiaPackageVersion, } = getPackageVersions();
|
|
12
12
|
return {
|
|
13
13
|
...variables,
|
|
14
14
|
apiClientPackageVersion: variables.apiClientPackageVersion ?? apiClientPackageVersion,
|
|
15
15
|
blockRuntimePackageVersion: variables.blockRuntimePackageVersion ?? blockRuntimePackageVersion,
|
|
16
16
|
blockTypesPackageVersion: variables.blockTypesPackageVersion ?? blockTypesPackageVersion,
|
|
17
17
|
projectToolsPackageVersion: variables.projectToolsPackageVersion ?? projectToolsPackageVersion,
|
|
18
|
+
wpTypiaPackageVersion: variables.wpTypiaPackageVersion ?? wpTypiaPackageVersion,
|
|
18
19
|
description: variables.description,
|
|
19
20
|
keyword: variables.keyword,
|
|
20
21
|
namespace: variables.namespace,
|
|
@@ -6,6 +6,7 @@ import { getBuiltInTemplateLayerDirs, isOmittableBuiltInTemplateLayerDir, } from
|
|
|
6
6
|
import { copyRawDirectory } from './template-render.js';
|
|
7
7
|
import { createManagedTempRoot } from './temp-roots.js';
|
|
8
8
|
import { pathExists } from './fs-async.js';
|
|
9
|
+
import { readJsonFile, readJsonFileSync, safeJsonParse, } from './json-utils.js';
|
|
9
10
|
async function cleanupSeedRootPair(cleanup, seedCleanup) {
|
|
10
11
|
let cleanupError;
|
|
11
12
|
try {
|
|
@@ -39,7 +40,9 @@ function readRemoteBlockJson(blockDir) {
|
|
|
39
40
|
path.join(sourceRoot, 'block.json'),
|
|
40
41
|
]) {
|
|
41
42
|
if (fs.existsSync(candidate)) {
|
|
42
|
-
return
|
|
43
|
+
return readJsonFileSync(candidate, {
|
|
44
|
+
context: 'remote block metadata',
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
throw new Error(`Unable to locate block.json in ${blockDir}`);
|
|
@@ -51,7 +54,9 @@ async function readRemoteBlockJsonAsync(blockDir) {
|
|
|
51
54
|
path.join(sourceRoot, 'block.json'),
|
|
52
55
|
]) {
|
|
53
56
|
if (await pathExists(candidate)) {
|
|
54
|
-
return
|
|
57
|
+
return readJsonFile(candidate, {
|
|
58
|
+
context: 'remote block metadata',
|
|
59
|
+
});
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
throw new Error(`Unable to locate block.json in ${blockDir}`);
|
|
@@ -105,7 +110,10 @@ function readTemplatePackageJson(sourceDir) {
|
|
|
105
110
|
maxBytes: getExternalTemplatePackageJsonMaxBytes(),
|
|
106
111
|
});
|
|
107
112
|
return {
|
|
108
|
-
packageJson:
|
|
113
|
+
packageJson: safeJsonParse(fs.readFileSync(candidate, 'utf8'), {
|
|
114
|
+
context: 'template metadata file',
|
|
115
|
+
filePath: candidate,
|
|
116
|
+
}),
|
|
109
117
|
sourcePath: candidate,
|
|
110
118
|
};
|
|
111
119
|
}
|
|
@@ -130,7 +138,10 @@ async function readTemplatePackageJsonAsync(sourceDir) {
|
|
|
130
138
|
maxBytes: getExternalTemplatePackageJsonMaxBytes(),
|
|
131
139
|
});
|
|
132
140
|
return {
|
|
133
|
-
packageJson:
|
|
141
|
+
packageJson: safeJsonParse(await fsp.readFile(candidate, 'utf8'), {
|
|
142
|
+
context: 'template metadata file',
|
|
143
|
+
filePath: candidate,
|
|
144
|
+
}),
|
|
134
145
|
sourcePath: candidate,
|
|
135
146
|
};
|
|
136
147
|
}
|
|
@@ -327,7 +338,9 @@ async function rewriteBlockJsonImports(directory) {
|
|
|
327
338
|
}
|
|
328
339
|
async function patchRemotePackageJson(templateDir, needsInteractivity) {
|
|
329
340
|
const packageJsonPath = path.join(templateDir, 'package.json.mustache');
|
|
330
|
-
const packageJson =
|
|
341
|
+
const packageJson = await readJsonFile(packageJsonPath, {
|
|
342
|
+
context: 'remote package template manifest',
|
|
343
|
+
});
|
|
331
344
|
const existingDependencies = { ...(packageJson.dependencies ?? {}) };
|
|
332
345
|
const existingDevDependencies = { ...(packageJson.devDependencies ?? {}) };
|
|
333
346
|
delete existingDependencies['@wp-typia/project-tools'];
|
|
@@ -9,6 +9,7 @@ import { createExternalTemplateTimeoutError, fetchWithExternalTemplateTimeout, g
|
|
|
9
9
|
import { findReusableExternalTemplateSourceCache, isExternalTemplateCacheEnabled, resolveExternalTemplateSourceCache, } from './template-source-cache.js';
|
|
10
10
|
import { CLI_DIAGNOSTIC_CODES, createCliDiagnosticCodeError, } from './cli-diagnostics.js';
|
|
11
11
|
import { pathExists } from './fs-async.js';
|
|
12
|
+
import { readJsonFile, readJsonFileSync } from './json-utils.js';
|
|
12
13
|
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, OFFICIAL_WORKSPACE_TEMPLATE_ALIAS, PROJECT_TOOLS_PACKAGE_ROOT, TEMPLATE_IDS, } from './template-registry.js';
|
|
13
14
|
import { isPlainObject } from './object-utils.js';
|
|
14
15
|
import { createManagedTempRoot } from './temp-roots.js';
|
|
@@ -206,7 +207,9 @@ function resolveInstalledNpmTemplateSource(locator, cwd) {
|
|
|
206
207
|
if (!fs.existsSync(packageJsonPath)) {
|
|
207
208
|
continue;
|
|
208
209
|
}
|
|
209
|
-
const manifest =
|
|
210
|
+
const manifest = readJsonFileSync(packageJsonPath, {
|
|
211
|
+
context: 'workspace template package manifest',
|
|
212
|
+
});
|
|
210
213
|
if (manifest.name === locator.name) {
|
|
211
214
|
return {
|
|
212
215
|
blockDir: packageDir,
|
|
@@ -259,7 +262,9 @@ export function isOfficialWorkspaceTemplateSeed(seed) {
|
|
|
259
262
|
return false;
|
|
260
263
|
}
|
|
261
264
|
try {
|
|
262
|
-
const packageJson =
|
|
265
|
+
const packageJson = readJsonFileSync(packageJsonPath, {
|
|
266
|
+
context: 'workspace template seed manifest',
|
|
267
|
+
});
|
|
263
268
|
return packageJson.name === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE;
|
|
264
269
|
}
|
|
265
270
|
catch {
|
|
@@ -278,7 +283,9 @@ export async function isOfficialWorkspaceTemplateSeedAsync(seed) {
|
|
|
278
283
|
return false;
|
|
279
284
|
}
|
|
280
285
|
try {
|
|
281
|
-
const packageJson =
|
|
286
|
+
const packageJson = await readJsonFile(packageJsonPath, {
|
|
287
|
+
context: 'workspace template seed manifest',
|
|
288
|
+
});
|
|
282
289
|
return packageJson.name === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE;
|
|
283
290
|
}
|
|
284
291
|
catch {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JsonSchemaObject } from './schema-core.js';
|
|
2
|
+
/**
|
|
3
|
+
* Clone a JSON-compatible value when the caller has provided one.
|
|
4
|
+
*
|
|
5
|
+
* @template T JSON-compatible value type.
|
|
6
|
+
* @param value Optional value to clone with the shared JSON clone helper.
|
|
7
|
+
* @returns A cloned value, or undefined when the input is undefined.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cloneJsonValueIfDefined<T>(value: T | undefined): T | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Check whether a candidate is a non-null JSON Schema object.
|
|
12
|
+
*
|
|
13
|
+
* @param value Candidate value to narrow.
|
|
14
|
+
* @returns True when the value is an object and not an array.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isJsonSchemaObject(value: unknown): value is JsonSchemaObject;
|
|
17
|
+
/**
|
|
18
|
+
* Narrow a `typia.llm` artifact field before applying JSON Schema mutations.
|
|
19
|
+
*
|
|
20
|
+
* @param value Candidate schema value emitted by `typia.llm`.
|
|
21
|
+
* @param context Human-readable artifact path for diagnostics.
|
|
22
|
+
* @returns The value narrowed to the shared JSON Schema object shape.
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertJsonSchemaObject(value: unknown, context: string): JsonSchemaObject;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cloneJsonValue } from './json-utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Clone a JSON-compatible value when the caller has provided one.
|
|
4
|
+
*
|
|
5
|
+
* @template T JSON-compatible value type.
|
|
6
|
+
* @param value Optional value to clone with the shared JSON clone helper.
|
|
7
|
+
* @returns A cloned value, or undefined when the input is undefined.
|
|
8
|
+
*/
|
|
9
|
+
export function cloneJsonValueIfDefined(value) {
|
|
10
|
+
return value === undefined ? undefined : cloneJsonValue(value);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check whether a candidate is a non-null JSON Schema object.
|
|
14
|
+
*
|
|
15
|
+
* @param value Candidate value to narrow.
|
|
16
|
+
* @returns True when the value is an object and not an array.
|
|
17
|
+
*/
|
|
18
|
+
export function isJsonSchemaObject(value) {
|
|
19
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Narrow a `typia.llm` artifact field before applying JSON Schema mutations.
|
|
23
|
+
*
|
|
24
|
+
* @param value Candidate schema value emitted by `typia.llm`.
|
|
25
|
+
* @param context Human-readable artifact path for diagnostics.
|
|
26
|
+
* @returns The value narrowed to the shared JSON Schema object shape.
|
|
27
|
+
*/
|
|
28
|
+
export function assertJsonSchemaObject(value, context) {
|
|
29
|
+
if (isJsonSchemaObject(value)) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`${context} must be a JSON Schema object.`);
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApplyOpenApiConstraintsToTypiaLlmFunctionArtifactOptions, ProjectedTypiaLlmFunctionArtifact } from './typia-llm-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Clone a projected function artifact before mutation-oriented constraint work.
|
|
4
|
+
*
|
|
5
|
+
* @param functionArtifact Projected artifact to clone.
|
|
6
|
+
* @returns A cloned artifact with parameters and optional output deep-cloned,
|
|
7
|
+
* and tags shallow-copied when present.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cloneProjectedTypiaLlmFunctionArtifact(functionArtifact: ProjectedTypiaLlmFunctionArtifact): ProjectedTypiaLlmFunctionArtifact;
|
|
10
|
+
/**
|
|
11
|
+
* Restores canonical request and response constraints from an endpoint-aware
|
|
12
|
+
* OpenAPI document onto one projected `typia.llm` function artifact.
|
|
13
|
+
*
|
|
14
|
+
* Query-only inputs merge into the root parameter object. Mixed body/query
|
|
15
|
+
* inputs merge into the generated `body` and `query` properties.
|
|
16
|
+
*
|
|
17
|
+
* @param options Projected artifact plus the canonical OpenAPI document.
|
|
18
|
+
* @returns A cloned artifact enriched with OpenAPI-backed constraints when available.
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyOpenApiConstraintsToTypiaLlmFunctionArtifact({ functionArtifact, openApiDocument, operationId, }: ApplyOpenApiConstraintsToTypiaLlmFunctionArtifactOptions): ProjectedTypiaLlmFunctionArtifact;
|