wp-typia 0.23.1 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import {
4
4
  } from "./cli-8hxf9qw6.js";
5
5
  import {
6
6
  getOptionalNodeErrorCode
7
- } from "./cli-k5q5v8g6.js";
7
+ } from "./cli-v0nnagb3.js";
8
8
 
9
9
  // ../wp-typia-project-tools/src/runtime/package-versions.ts
10
10
  import fs from "fs";
@@ -20,6 +20,7 @@ var DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION = "^0.9.0";
20
20
  var DEFAULT_WORDPRESS_CORE_DATA_VERSION = "^7.44.0";
21
21
  var DEFAULT_WORDPRESS_DATA_VERSION = "^9.28.0";
22
22
  var DEFAULT_WORDPRESS_DATAVIEWS_VERSION = "^14.1.0";
23
+ var DEFAULT_WORDPRESS_ENV_VERSION = "^11.2.0";
23
24
  var DEFAULT_WP_TYPIA_DATAVIEWS_VERSION = "^0.1.1";
24
25
  var cachedPackageVersions = null;
25
26
  function normalizeVersionRange(value) {
@@ -131,6 +132,7 @@ function getPackageVersions() {
131
132
  const createManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "package.json"));
132
133
  const monorepoManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "..", "package.json"));
133
134
  const blockRuntimeManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia-block-runtime", "package.json"));
135
+ const blockTypesManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia-block-types", "package.json"));
134
136
  const wpTypiaManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia", "package.json"));
135
137
  const installedProjectToolsManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/project-tools");
136
138
  const installedApiClientManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/api-client");
@@ -146,6 +148,7 @@ function getPackageVersions() {
146
148
  createManifestLocation,
147
149
  monorepoManifestLocation,
148
150
  blockRuntimeManifestLocation,
151
+ blockTypesManifestLocation,
149
152
  wpTypiaManifestLocation,
150
153
  installedProjectToolsManifestLocation,
151
154
  installedApiClientManifestLocation,
@@ -164,12 +167,14 @@ function getPackageVersions() {
164
167
  const createManifest = readPackageManifest(createManifestLocation) ?? readPackageManifest(installedProjectToolsManifestLocation) ?? {};
165
168
  const monorepoManifest = readPackageManifest(monorepoManifestLocation) ?? {};
166
169
  const blockRuntimeManifest = readPackageManifest(blockRuntimeManifestLocation) ?? readPackageManifest(installedBlockRuntimeManifestLocation) ?? {};
170
+ const blockTypesManifest = readPackageManifest(blockTypesManifestLocation) ?? readPackageManifest(installedBlockTypesManifestLocation) ?? {};
167
171
  const wpTypiaManifest = readPackageManifest(wpTypiaManifestLocation) ?? readPackageManifest(installedWpTypiaManifestLocation) ?? {};
168
172
  const blockRuntimeDependencyVersion = normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-runtime"]);
173
+ const blockTypesDependencyVersion = normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-types"]);
169
174
  const versions = {
170
175
  apiClientPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/api-client"] ?? readPackageManifest(installedApiClientManifestLocation)?.version),
171
176
  blockRuntimePackageVersion: blockRuntimeDependencyVersion !== DEFAULT_VERSION_RANGE ? blockRuntimeDependencyVersion : normalizeVersionRange(blockRuntimeManifest.version),
172
- blockTypesPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-types"] ?? readPackageManifest(installedBlockTypesManifestLocation)?.version),
177
+ blockTypesPackageVersion: blockTypesDependencyVersion !== DEFAULT_VERSION_RANGE ? blockTypesDependencyVersion : normalizeVersionRange(blockTypesManifest.version),
173
178
  projectToolsPackageVersion: normalizeVersionRange(createManifest.version),
174
179
  restPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/rest"] ?? readPackageManifest(installedRestManifestLocation)?.version),
175
180
  tsxPackageVersion: normalizeVersionRangeWithFallback(monorepoManifest.dependencies?.tsx ?? monorepoManifest.devDependencies?.tsx ?? readPackageManifest(installedTsxManifestLocation)?.version, DEFAULT_TSX_PACKAGE_VERSION),
@@ -186,6 +191,6 @@ function getPackageVersions() {
186
191
  return versions;
187
192
  }
188
193
 
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 };
194
+ 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
195
 
191
- //# debugId=807B1242BD906C4E64756E2164756E21
196
+ //# debugId=5C44FE33F29175BD64756E2164756E21
@@ -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
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-cwjdzq6n.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-xaw5agks.js");
2464
2464
  const cli = await createCLI({
2465
2465
  ...bunliConfig,
2466
2466
  description: package_default.description,