wp-typia 0.23.1 → 0.24.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.
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  getPackageVersions
4
- } from "./cli-fp16mntv.js";
4
+ } from "./cli-zjw3eqfj.js";
5
5
  import"./cli-8hxf9qw6.js";
6
6
  import {
7
7
  discoverMigrationInitLayout
@@ -13,9 +13,9 @@ import {
13
13
  snapshotWorkspaceFiles,
14
14
  toPascalCase,
15
15
  updateWorkspaceInventorySource
16
- } from "./cli-k5q5v8g6.js";
16
+ } from "./cli-h2v72j8q.js";
17
17
  import"./cli-cvxvcw7c.js";
18
- import"./cli-43mx1vfb.js";
18
+ import"./cli-bajwv85z.js";
19
19
  import {
20
20
  CLI_DIAGNOSTIC_CODES,
21
21
  createCliDiagnosticCodeError
@@ -21,24 +21,24 @@ import {
21
21
  resolvePackageManagerId,
22
22
  resolveTemplateId,
23
23
  scaffoldProject
24
- } from "./cli-y7w3pybs.js";
24
+ } from "./cli-4ah8dawy.js";
25
25
  import"./cli-9fx0qgb7.js";
26
- import"./cli-nvs5atj1.js";
27
- import"./cli-fp16mntv.js";
26
+ import"./cli-gaq29kzp.js";
27
+ import"./cli-zjw3eqfj.js";
28
28
  import {
29
29
  OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
30
30
  isBuiltInTemplateId
31
31
  } from "./cli-8hxf9qw6.js";
32
- import"./cli-epsczb1c.js";
32
+ import"./cli-fzhkqzc7.js";
33
33
  import"./cli-e4bwd81c.js";
34
34
  import {
35
35
  pathExists
36
- } from "./cli-k5q5v8g6.js";
36
+ } from "./cli-h2v72j8q.js";
37
37
  import"./cli-cvxvcw7c.js";
38
38
  import {
39
39
  createManagedTempRoot
40
40
  } from "./cli-t73q5aqz.js";
41
- import"./cli-43mx1vfb.js";
41
+ import"./cli-bajwv85z.js";
42
42
  import"./cli-tq730sqt.js";
43
43
  import"./cli-1170yyve.js";
44
44
  import {
@@ -0,0 +1,229 @@
1
+ // @bun
2
+ import {
3
+ readJsonFile,
4
+ readJsonFileSync
5
+ } from "./cli-ccax7s0s.js";
6
+
7
+ // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-types.ts
8
+ var ADMIN_VIEW_REST_SOURCE_KIND = "rest-resource";
9
+ var ADMIN_VIEW_CORE_DATA_SOURCE_KIND = "core-data";
10
+ var ADMIN_VIEW_CORE_DATA_ENTITY_KIND_IDS = [
11
+ "postType",
12
+ "taxonomy"
13
+ ];
14
+ var ADMIN_VIEW_CORE_DATA_ENTITY_SEGMENT_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/u;
15
+ var ADMIN_VIEW_CORE_DATA_ENTITY_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/u;
16
+ var ADMIN_VIEW_SOURCE_USAGE = "wp-typia add admin-view <name> --source <rest-resource:slug|core-data:kind/name>";
17
+ var ADMIN_VIEWS_SCRIPT = "build/admin-views/index.js";
18
+ var ADMIN_VIEWS_ASSET = "build/admin-views/index.asset.php";
19
+ var ADMIN_VIEWS_STYLE = "build/admin-views/style-index.css";
20
+ var ADMIN_VIEWS_STYLE_RTL = "build/admin-views/style-index-rtl.css";
21
+ var ADMIN_VIEWS_PHP_GLOB = "/inc/admin-views/*.php";
22
+ var ADMIN_VIEW_MANUAL_REST_ROUTE_PARAMETER_PATTERN = /(?:^|[^\\])\(/u;
23
+ function isAdminViewCoreDataSource(source) {
24
+ return source?.kind === ADMIN_VIEW_CORE_DATA_SOURCE_KIND;
25
+ }
26
+ function isAdminViewRestResourceSource(source) {
27
+ return source?.kind === ADMIN_VIEW_REST_SOURCE_KIND;
28
+ }
29
+ function isAdminViewManualSettingsRestResource(restResource) {
30
+ return restResource?.mode === "manual" && typeof restResource.bodyTypeName === "string" && restResource.bodyTypeName.trim().length > 0 && typeof restResource.queryTypeName === "string" && restResource.queryTypeName.trim().length > 0 && typeof restResource.responseTypeName === "string" && restResource.responseTypeName.trim().length > 0;
31
+ }
32
+ function hasAdminViewManualSettingsRouteParameters(restResource) {
33
+ return [restResource?.pathPattern, restResource?.routePattern].some((pattern) => typeof pattern === "string" && ADMIN_VIEW_MANUAL_REST_ROUTE_PARAMETER_PATTERN.test(pattern));
34
+ }
35
+ function formatAdminViewSourceLocator(source) {
36
+ if (isAdminViewCoreDataSource(source)) {
37
+ return `${source.kind}:${source.entityKind}/${source.entityName}`;
38
+ }
39
+ return `${source.kind}:${source.slug}`;
40
+ }
41
+
42
+ // ../wp-typia-project-tools/src/runtime/post-meta-binding-fields.ts
43
+ import path from "path";
44
+ var SUPPORTED_SCHEMA_TYPES = new Set([
45
+ "array",
46
+ "boolean",
47
+ "integer",
48
+ "number",
49
+ "object",
50
+ "string"
51
+ ]);
52
+ function isJsonRecord(value) {
53
+ return typeof value === "object" && value !== null && !Array.isArray(value);
54
+ }
55
+ function resolveSchemaType(schema) {
56
+ const type = schema.type;
57
+ if (typeof type === "string" && SUPPORTED_SCHEMA_TYPES.has(type)) {
58
+ return type;
59
+ }
60
+ if (Array.isArray(type) && type.every((entry) => typeof entry === "string")) {
61
+ const nonNullType = type.find((entry) => entry !== "null" && SUPPORTED_SCHEMA_TYPES.has(entry));
62
+ if (nonNullType) {
63
+ return nonNullType;
64
+ }
65
+ }
66
+ if (Array.isArray(schema.enum) && schema.enum.length > 0) {
67
+ return "string";
68
+ }
69
+ return "unknown";
70
+ }
71
+ function resolveFallbackValue(name, schema, schemaType) {
72
+ const enumValue = Array.isArray(schema.enum) ? schema.enum.find((entry) => typeof entry === "string") : undefined;
73
+ if (typeof enumValue === "string") {
74
+ return enumValue;
75
+ }
76
+ switch (schemaType) {
77
+ case "array":
78
+ return "[]";
79
+ case "boolean":
80
+ return "false";
81
+ case "integer":
82
+ case "number":
83
+ return "0";
84
+ case "object":
85
+ return "{}";
86
+ default:
87
+ return `${name} preview`;
88
+ }
89
+ }
90
+ function resolveFieldLabel(name) {
91
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (match) => match.toUpperCase());
92
+ }
93
+ function extractPostMetaBindingFields(schema, context) {
94
+ if (!isJsonRecord(schema) || !isJsonRecord(schema.properties)) {
95
+ throw new Error(`${context} must expose an object schema with top-level properties before it can back a binding source.`);
96
+ }
97
+ const required = Array.isArray(schema.required) ? new Set(schema.required.filter((entry) => typeof entry === "string")) : new Set;
98
+ const fields = Object.entries(schema.properties).map(([name, propertySchema]) => {
99
+ const property = isJsonRecord(propertySchema) ? propertySchema : {};
100
+ const schemaType = resolveSchemaType(property);
101
+ return {
102
+ fallbackValue: resolveFallbackValue(name, property, schemaType),
103
+ label: resolveFieldLabel(name),
104
+ name,
105
+ required: required.has(name),
106
+ schemaType
107
+ };
108
+ });
109
+ if (fields.length === 0) {
110
+ throw new Error(`${context} does not expose any top-level properties that can back binding fields.`);
111
+ }
112
+ return fields;
113
+ }
114
+ async function loadPostMetaBindingFields(projectDir, postMeta) {
115
+ const schemaPath = path.join(projectDir, postMeta.schemaFile);
116
+ const schema = await readJsonFile(schemaPath, {
117
+ context: `post meta schema for ${postMeta.slug}`
118
+ });
119
+ return extractPostMetaBindingFields(schema, postMeta.schemaFile);
120
+ }
121
+ function loadPostMetaBindingFieldsSync(projectDir, postMeta) {
122
+ const schemaPath = path.join(projectDir, postMeta.schemaFile);
123
+ const schema = readJsonFileSync(schemaPath, {
124
+ context: `post meta schema for ${postMeta.slug}`
125
+ });
126
+ return extractPostMetaBindingFields(schema, postMeta.schemaFile);
127
+ }
128
+ function assertPostMetaBindingPath(fields, postMetaSlug, metaPath) {
129
+ const trimmed = metaPath.trim();
130
+ if (!trimmed) {
131
+ throw new Error("Post meta binding path must include a value.");
132
+ }
133
+ if (trimmed.includes(".")) {
134
+ throw new Error(`Nested post meta path "${trimmed}" for "${postMetaSlug}" is not supported yet. Use one of the top-level fields: ${fields.map((field2) => field2.name).join(", ")}.`);
135
+ }
136
+ const field = fields.find((candidate) => candidate.name === trimmed);
137
+ if (!field) {
138
+ throw new Error(`Post meta path "${trimmed}" does not exist in the "${postMetaSlug}" schema. Expected one of: ${fields.map((candidate) => candidate.name).join(", ")}.`);
139
+ }
140
+ return field;
141
+ }
142
+
143
+ // ../wp-typia-project-tools/src/runtime/ts-source-masking.ts
144
+ function maskSourceSegment(segment) {
145
+ return segment.replace(/[^\n\r]/gu, " ");
146
+ }
147
+ function testPattern(source, pattern) {
148
+ pattern.lastIndex = 0;
149
+ const matched = pattern.test(source);
150
+ pattern.lastIndex = 0;
151
+ return matched;
152
+ }
153
+ function maskTypeScriptComments(source) {
154
+ return source.replace(/\/\*[\s\S]*?\*\//gu, maskSourceSegment).replace(/\/\/[^\n\r]*/gu, maskSourceSegment);
155
+ }
156
+ function maskTypeScriptCommentsAndLiterals(source) {
157
+ let maskedSource = "";
158
+ let index = 0;
159
+ while (index < source.length) {
160
+ const current = source[index];
161
+ const next = source[index + 1];
162
+ if (current === "/" && next === "/") {
163
+ const start = index;
164
+ index += 2;
165
+ while (index < source.length && source[index] !== `
166
+ ` && source[index] !== "\r") {
167
+ index += 1;
168
+ }
169
+ maskedSource += maskSourceSegment(source.slice(start, index));
170
+ continue;
171
+ }
172
+ if (current === "/" && next === "*") {
173
+ const start = index;
174
+ index += 2;
175
+ while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
176
+ index += 1;
177
+ }
178
+ index = Math.min(index + 2, source.length);
179
+ maskedSource += maskSourceSegment(source.slice(start, index));
180
+ continue;
181
+ }
182
+ if (current === "'" || current === '"' || current === "`") {
183
+ const start = index;
184
+ const quote = current;
185
+ index += 1;
186
+ while (index < source.length) {
187
+ const char = source[index];
188
+ if (char === "\\") {
189
+ index += 2;
190
+ continue;
191
+ }
192
+ index += 1;
193
+ if (char === quote) {
194
+ break;
195
+ }
196
+ }
197
+ maskedSource += maskSourceSegment(source.slice(start, index));
198
+ continue;
199
+ }
200
+ maskedSource += current;
201
+ index += 1;
202
+ }
203
+ return maskedSource;
204
+ }
205
+ function hasExecutablePattern(source, pattern) {
206
+ return testPattern(maskTypeScriptCommentsAndLiterals(source), pattern);
207
+ }
208
+ function hasUncommentedPattern(source, pattern) {
209
+ return testPattern(maskTypeScriptComments(source), pattern);
210
+ }
211
+ function findExecutablePatternMatch(source, patterns) {
212
+ const maskedSource = maskTypeScriptCommentsAndLiterals(source);
213
+ for (const pattern of patterns) {
214
+ pattern.lastIndex = 0;
215
+ const match = pattern.exec(maskedSource);
216
+ pattern.lastIndex = 0;
217
+ if (match && match.index !== undefined) {
218
+ return {
219
+ end: match.index + match[0].length,
220
+ start: match.index
221
+ };
222
+ }
223
+ }
224
+ return;
225
+ }
226
+
227
+ export { ADMIN_VIEW_REST_SOURCE_KIND, ADMIN_VIEW_CORE_DATA_SOURCE_KIND, ADMIN_VIEW_CORE_DATA_ENTITY_KIND_IDS, ADMIN_VIEW_CORE_DATA_ENTITY_SEGMENT_PATTERN, ADMIN_VIEW_CORE_DATA_ENTITY_NAME_PATTERN, ADMIN_VIEW_SOURCE_USAGE, ADMIN_VIEWS_SCRIPT, ADMIN_VIEWS_ASSET, ADMIN_VIEWS_STYLE, ADMIN_VIEWS_STYLE_RTL, ADMIN_VIEWS_PHP_GLOB, isAdminViewCoreDataSource, isAdminViewRestResourceSource, isAdminViewManualSettingsRestResource, hasAdminViewManualSettingsRouteParameters, formatAdminViewSourceLocator, loadPostMetaBindingFields, loadPostMetaBindingFieldsSync, assertPostMetaBindingPath, maskTypeScriptCommentsAndLiterals, hasExecutablePattern, hasUncommentedPattern, findExecutablePatternMatch };
228
+
229
+ //# debugId=088B083477FD04FF64756E2164756E21
@@ -4,7 +4,10 @@ import {
4
4
  } from "./cli-8hxf9qw6.js";
5
5
  import {
6
6
  getOptionalNodeErrorCode
7
- } from "./cli-k5q5v8g6.js";
7
+ } from "./cli-h2v72j8q.js";
8
+ import {
9
+ safeJsonParse
10
+ } from "./cli-ccax7s0s.js";
8
11
 
9
12
  // ../wp-typia-project-tools/src/runtime/package-versions.ts
10
13
  import fs from "fs";
@@ -20,6 +23,7 @@ var DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION = "^0.9.0";
20
23
  var DEFAULT_WORDPRESS_CORE_DATA_VERSION = "^7.44.0";
21
24
  var DEFAULT_WORDPRESS_DATA_VERSION = "^9.28.0";
22
25
  var DEFAULT_WORDPRESS_DATAVIEWS_VERSION = "^14.1.0";
26
+ var DEFAULT_WORDPRESS_ENV_VERSION = "^11.2.0";
23
27
  var DEFAULT_WP_TYPIA_DATAVIEWS_VERSION = "^0.1.1";
24
28
  var cachedPackageVersions = null;
25
29
  function normalizeVersionRange(value) {
@@ -87,11 +91,10 @@ function readPackageManifest(location) {
87
91
  if (!location.packageJsonPath || location.source === null) {
88
92
  return null;
89
93
  }
90
- try {
91
- return JSON.parse(location.source);
92
- } catch (error) {
93
- throw new Error(`Failed to parse package version manifest at ${location.packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`);
94
- }
94
+ return safeJsonParse(location.source, {
95
+ context: "package version manifest",
96
+ filePath: location.packageJsonPath
97
+ });
95
98
  }
96
99
  function tryReadPackageManifest(location) {
97
100
  if (!location) {
@@ -131,6 +134,7 @@ function getPackageVersions() {
131
134
  const createManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "package.json"));
132
135
  const monorepoManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "..", "package.json"));
133
136
  const blockRuntimeManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia-block-runtime", "package.json"));
137
+ const blockTypesManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia-block-types", "package.json"));
134
138
  const wpTypiaManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia", "package.json"));
135
139
  const installedProjectToolsManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/project-tools");
136
140
  const installedApiClientManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/api-client");
@@ -146,6 +150,7 @@ function getPackageVersions() {
146
150
  createManifestLocation,
147
151
  monorepoManifestLocation,
148
152
  blockRuntimeManifestLocation,
153
+ blockTypesManifestLocation,
149
154
  wpTypiaManifestLocation,
150
155
  installedProjectToolsManifestLocation,
151
156
  installedApiClientManifestLocation,
@@ -164,12 +169,14 @@ function getPackageVersions() {
164
169
  const createManifest = readPackageManifest(createManifestLocation) ?? readPackageManifest(installedProjectToolsManifestLocation) ?? {};
165
170
  const monorepoManifest = readPackageManifest(monorepoManifestLocation) ?? {};
166
171
  const blockRuntimeManifest = readPackageManifest(blockRuntimeManifestLocation) ?? readPackageManifest(installedBlockRuntimeManifestLocation) ?? {};
172
+ const blockTypesManifest = readPackageManifest(blockTypesManifestLocation) ?? readPackageManifest(installedBlockTypesManifestLocation) ?? {};
167
173
  const wpTypiaManifest = readPackageManifest(wpTypiaManifestLocation) ?? readPackageManifest(installedWpTypiaManifestLocation) ?? {};
168
174
  const blockRuntimeDependencyVersion = normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-runtime"]);
175
+ const blockTypesDependencyVersion = normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-types"]);
169
176
  const versions = {
170
177
  apiClientPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/api-client"] ?? readPackageManifest(installedApiClientManifestLocation)?.version),
171
178
  blockRuntimePackageVersion: blockRuntimeDependencyVersion !== DEFAULT_VERSION_RANGE ? blockRuntimeDependencyVersion : normalizeVersionRange(blockRuntimeManifest.version),
172
- blockTypesPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-types"] ?? readPackageManifest(installedBlockTypesManifestLocation)?.version),
179
+ blockTypesPackageVersion: blockTypesDependencyVersion !== DEFAULT_VERSION_RANGE ? blockTypesDependencyVersion : normalizeVersionRange(blockTypesManifest.version),
173
180
  projectToolsPackageVersion: normalizeVersionRange(createManifest.version),
174
181
  restPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/rest"] ?? readPackageManifest(installedRestManifestLocation)?.version),
175
182
  tsxPackageVersion: normalizeVersionRangeWithFallback(monorepoManifest.dependencies?.tsx ?? monorepoManifest.devDependencies?.tsx ?? readPackageManifest(installedTsxManifestLocation)?.version, DEFAULT_TSX_PACKAGE_VERSION),
@@ -186,6 +193,6 @@ function getPackageVersions() {
186
193
  return versions;
187
194
  }
188
195
 
189
- export { DEFAULT_WORDPRESS_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_DATA_VERSION, DEFAULT_WORDPRESS_DATA_VERSION, DEFAULT_WORDPRESS_DATAVIEWS_VERSION, DEFAULT_WP_TYPIA_DATAVIEWS_VERSION, resolveManagedPackageVersionRange, getPackageVersions };
196
+ export { DEFAULT_WORDPRESS_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_DATA_VERSION, DEFAULT_WORDPRESS_DATA_VERSION, DEFAULT_WORDPRESS_DATAVIEWS_VERSION, DEFAULT_WORDPRESS_ENV_VERSION, DEFAULT_WP_TYPIA_DATAVIEWS_VERSION, resolveManagedPackageVersionRange, getPackageVersions };
190
197
 
191
- //# debugId=807B1242BD906C4E64756E2164756E21
198
+ //# debugId=8B55C11F64E194C164756E2164756E21
package/dist-bunli/cli.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  package_default,
23
23
  validateCliOutputFormatArgv,
24
24
  writeStructuredCliDiagnosticError
25
- } from "./cli-ymecd15q.js";
25
+ } from "./cli-1xt99e09.js";
26
26
  import"./cli-03j0axbt.js";
27
27
  import {
28
28
  GLOBAL_FLAGS,
@@ -37,7 +37,7 @@ import {
37
37
  } from "./cli-hv2yedw2.js";
38
38
  import"./cli-ac2ebaf8.js";
39
39
  import"./cli-6v0pcxw6.js";
40
- import"./cli-43mx1vfb.js";
40
+ import"./cli-bajwv85z.js";
41
41
  import {
42
42
  CLI_DIAGNOSTIC_CODES,
43
43
  createCliDiagnosticCodeError
@@ -2460,7 +2460,7 @@ async function formatCliError(error) {
2460
2460
  }
2461
2461
  async function createWpTypiaCli(options = {}) {
2462
2462
  applyStandaloneSupportLayoutEnv();
2463
- const { wpTypiaCommands } = await import("./command-list-vme7dr5v.js");
2463
+ const { wpTypiaCommands } = await import("./command-list-bd2582k1.js");
2464
2464
  const cli = await createCLI({
2465
2465
  ...bunliConfig,
2466
2466
  description: package_default.description,