@wp-playground/blueprints 3.0.22 → 3.0.32

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.
@@ -14,6 +14,6 @@ export declare class BlueprintReflection {
14
14
  getVersion(): number;
15
15
  getDeclaration(): import("./v2/wep-1-blueprint-v2-schema/appendix-A-blueprint-v2-schema").V2Schema.BlueprintV2 | BlueprintV1Declaration;
16
16
  isBundle(): boolean;
17
- getBundle(): import("@wp-playground/storage").Filesystem | undefined;
17
+ getBundle(): import("@wp-playground/storage").ReadableFilesystemBackend | undefined;
18
18
  getBlueprint(): Blueprint;
19
19
  }
@@ -1,4 +1,8 @@
1
1
  import type { BlueprintBundle } from './types';
2
+ export declare class BlueprintFetchError extends Error {
3
+ readonly url: string;
4
+ constructor(message: string, url: string, options?: ErrorOptions);
5
+ }
2
6
  /**
3
7
  * Resolves a remote blueprint from a URL.
4
8
  *
@@ -7,12 +7,10 @@ import type { PHPRunOptions } from '@php-wasm/universal';
7
7
  *
8
8
  * <code>
9
9
  * {
10
- * "step": "runPHP",
10
+ * "step": "runPHPWithOptions",
11
11
  * "options": {
12
- * "code": "<?php echo $_SERVER['CONTENT_TYPE']; ?>",
13
- * "headers": {
14
- * "Content-type": "text/plain"
15
- * }
12
+ * "code": "<?php require_once '/wordpress/wp-load.php'; update_option('blogname', file_get_contents('php://input'));?>",
13
+ * "body": "Site Name Modified by runPHPWithOptions"
16
14
  * }
17
15
  * }
18
16
  * </code>
@@ -28,8 +28,10 @@ export interface RunSqlStep<ResourceType> {
28
28
  /**
29
29
  * Run one or more SQL queries.
30
30
  *
31
- * This step will treat each non-empty line in the input SQL as a query and
32
- * try to execute it using `$wpdb`. Queries spanning multiple lines are not
33
- * yet supported.
31
+ * This step uses WP_MySQL_Naive_Query_Stream to parse and execute SQL queries using
32
+ * streaming semantics. It supports multiline queries, comments, and queries
33
+ * separated by semicolons. Each query is executed using `$wpdb`. This step assumes
34
+ * a presence of the `sqlite-database-integration` plugin that ships the required
35
+ * query tokenizer classes.
34
36
  */
35
37
  export declare const runSql: StepHandler<RunSqlStep<File>>;
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Filesystem } from '@wp-playground/storage';
1
+ import type { ReadableFilesystemBackend } from '@wp-playground/storage';
2
2
  import type { BlueprintV1, BlueprintV1Declaration, ExtraLibrary, PHPConstants } from './v1/types';
3
3
  import type { BlueprintV2, BlueprintV2Declaration } from './v2/blueprint-v2-declaration';
4
4
  import type { SupportedPHPVersion } from '@php-wasm/universal';
@@ -6,7 +6,7 @@ import type { SupportedPHPVersion } from '@php-wasm/universal';
6
6
  * A filesystem structure containing a /blueprint.json file and any
7
7
  * resources referenced by that blueprint.
8
8
  */
9
- export type BlueprintBundle = Filesystem;
9
+ export type BlueprintBundle = ReadableFilesystemBackend;
10
10
  export type BlueprintDeclaration = BlueprintV1Declaration | BlueprintV2Declaration;
11
11
  export type Blueprint = BlueprintV1 | BlueprintV2;
12
12
  export interface RuntimeConfiguration {
@@ -1,9 +1,31 @@
1
1
  import { ProgressTracker } from '@php-wasm/progress';
2
2
  import { Semaphore } from '@php-wasm/util';
3
3
  import type { SupportedPHPVersion, UniversalPHP } from '@php-wasm/universal';
4
- import type { StepDefinition } from '../steps';
4
+ import type { Step, StepDefinition } from '../steps';
5
5
  import type { BlueprintV1Declaration, ExtraLibrary, StreamBundledFile, BlueprintV1 } from './types';
6
6
  import type { BlueprintBundle } from '../types';
7
+ import type { ErrorObject } from 'ajv';
8
+ export declare class InvalidBlueprintError extends Error {
9
+ readonly validationErrors?: unknown;
10
+ constructor(message: string, validationErrors?: unknown);
11
+ }
12
+ /**
13
+ * Error thrown when a single Blueprint step fails during execution.
14
+ *
15
+ * This error carries structured information about the failing step so that
16
+ * consumers (e.g. the Playground UI) do not have to parse human‑readable
17
+ * error messages to understand what went wrong.
18
+ */
19
+ export declare class BlueprintStepExecutionError extends Error {
20
+ readonly stepNumber: number;
21
+ readonly step: StepDefinition;
22
+ readonly messages: string[];
23
+ constructor(options: {
24
+ stepNumber: number;
25
+ step: StepDefinition;
26
+ cause: unknown;
27
+ });
28
+ }
7
29
  export type CompiledV1Step = (php: UniversalPHP) => Promise<void> | void;
8
30
  export interface CompiledBlueprintV1 {
9
31
  /** The requested versions of PHP and WordPress for the blueprint */
@@ -12,6 +34,7 @@ export interface CompiledBlueprintV1 {
12
34
  wp: string;
13
35
  };
14
36
  features: {
37
+ /** Should boot with support for Intl dynamic extension */
15
38
  intl: boolean;
16
39
  /** Should boot with support for network request via wp_safe_remote_get? */
17
40
  networking: boolean;
@@ -42,6 +65,11 @@ export interface CompileBlueprintV1Options {
42
65
  * A filesystem to use for the blueprint.
43
66
  */
44
67
  streamBundledFile?: StreamBundledFile;
68
+ /**
69
+ * Additional headers to pass to git operations.
70
+ * A function that returns headers based on the URL being accessed.
71
+ */
72
+ gitAdditionalHeadersCallback?: (url: string) => Record<string, string>;
45
73
  /**
46
74
  * Additional steps to add to the blueprint.
47
75
  */
@@ -50,11 +78,18 @@ export interface CompileBlueprintV1Options {
50
78
  export declare function compileBlueprintV1(input: BlueprintV1Declaration | BlueprintBundle, options?: Omit<CompileBlueprintV1Options, 'streamBundledFile'>): Promise<CompiledBlueprintV1>;
51
79
  export declare function isBlueprintBundle(input: any): input is BlueprintBundle;
52
80
  export declare function getBlueprintDeclaration(blueprint: BlueprintV1 | BlueprintBundle): Promise<BlueprintV1Declaration>;
53
- export declare function validateBlueprint(blueprintMaybe: object): {
81
+ export type BlueprintValidationResult = {
54
82
  valid: true;
55
- errors?: undefined;
56
83
  } | {
57
84
  valid: false;
58
- errors: import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | undefined;
85
+ errors: ErrorObject[];
59
86
  };
87
+ export declare function validateBlueprint(blueprintMaybe: object): BlueprintValidationResult;
88
+ /**
89
+ * Determines if a step is a StepDefinition object
90
+ *
91
+ * @param step The object to test
92
+ * @returns Whether the object is a StepDefinition
93
+ */
94
+ export declare function isStepDefinition(step: Step | string | undefined | false | null): step is StepDefinition;
60
95
  export declare function runBlueprintV1Steps(compiledBlueprint: CompiledBlueprintV1, playground: UniversalPHP): Promise<void>;
@@ -3,8 +3,18 @@ import type { FileTree, UniversalPHP } from '@php-wasm/universal';
3
3
  import type { Semaphore } from '@php-wasm/util';
4
4
  import { StreamedFile } from '@php-wasm/stream-compression';
5
5
  import type { StreamBundledFile } from './types';
6
+ export declare class BlueprintFilesystemRequiredError extends Error {
7
+ constructor(message?: string);
8
+ }
9
+ /**
10
+ * Error thrown when a resource could not be downloaded from a URL.
11
+ */
12
+ export declare class ResourceDownloadError extends Error {
13
+ readonly url: string;
14
+ constructor(message: string, url: string, options?: ErrorOptions);
15
+ }
6
16
  export type { FileTree };
7
- export declare const ResourceTypes: readonly ["vfs", "literal", "wordpress.org/themes", "wordpress.org/plugins", "url", "git:directory", "bundled"];
17
+ export declare const ResourceTypes: readonly ["vfs", "literal", "wordpress.org/themes", "wordpress.org/plugins", "url", "git:directory", "bundled", "zip"];
8
18
  export type VFSReference = {
9
19
  /** Identifies the file resource as Virtual File System (VFS) */
10
20
  resource: 'vfs';
@@ -68,9 +78,44 @@ export type BundledReference = {
68
78
  /** The path to the file in the Blueprint */
69
79
  path: string;
70
80
  };
71
- export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference | BundledReference;
81
+ export type ZipWrapperReference = {
82
+ /** Identifies the resource as a ZIP wrapper */
83
+ resource: 'zip';
84
+ /** The inner resource to wrap in a ZIP file */
85
+ inner: FileReference | DirectoryReference;
86
+ /** Optional filename for the ZIP (defaults to inner resource name + .zip) */
87
+ name?: string;
88
+ };
89
+ export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference | BundledReference | ZipWrapperReference;
72
90
  export type DirectoryReference = GitDirectoryReference | DirectoryLiteralReference;
73
91
  export declare function isResourceReference(ref: any): ref is FileReference;
92
+ /**
93
+ * Checks if a URL is a github-proxy.com URL that can be rewritten.
94
+ *
95
+ * @param url The URL to check
96
+ * @returns true if the URL is a github-proxy.com URL
97
+ */
98
+ export declare function isGithubProxyUrl(url: string): boolean;
99
+ /**
100
+ * Rewrites a github-proxy.com URL to an equivalent Blueprint resource reference.
101
+ *
102
+ * github-proxy.com is being deprecated. This function enables automatic migration
103
+ * of existing Blueprints that use github-proxy.com URLs to native Blueprint resources.
104
+ *
105
+ * Supported URL patterns:
106
+ * - `?repo=owner/name` - Full repository at default branch
107
+ * - `?repo=owner/name&branch=trunk` - Full repository at specific branch
108
+ * - `?repo=owner/name&pr=123` - Full repository at PR head
109
+ * - `?repo=owner/name&commit=abc` - Full repository at specific commit
110
+ * - `?repo=owner/name&release=v1.0` - Full repository at release tag
111
+ * - `?repo=owner/name&directory=subdir` - Subdirectory of repository
112
+ * - `?repo=owner/name&release=v1.0&asset=file.zip` - Release asset download
113
+ * - `https://github-proxy.com/https://github.com/...` - Direct GitHub URL proxy
114
+ *
115
+ * @param url The github-proxy.com URL to rewrite
116
+ * @returns A ZipWrapperReference (wrapping git:directory) or UrlReference, or null if URL cannot be rewritten
117
+ */
118
+ export declare function rewriteGithubProxyUrl(url: string): ZipWrapperReference | UrlReference | null;
74
119
  export declare abstract class Resource<T extends File | Directory> {
75
120
  /** Optional progress tracker to monitor progress */
76
121
  protected _progress?: ProgressTracker;
@@ -92,12 +137,13 @@ export declare abstract class Resource<T extends File | Directory> {
92
137
  * @param options Additional options for the Resource
93
138
  * @returns A new Resource instance
94
139
  */
95
- static create(ref: FileReference | DirectoryReference, { semaphore, progress, corsProxy, streamBundledFile, }: {
140
+ static create(ref: FileReference | DirectoryReference, { semaphore, progress, corsProxy, streamBundledFile, gitAdditionalHeadersCallback, }: {
96
141
  /** Optional semaphore to limit concurrent downloads */
97
142
  semaphore?: Semaphore;
98
143
  progress?: ProgressTracker;
99
144
  corsProxy?: string;
100
145
  streamBundledFile?: StreamBundledFile;
146
+ gitAdditionalHeadersCallback?: (url: string) => Record<string, string>;
101
147
  }): Resource<File | Directory>;
102
148
  }
103
149
  export declare abstract class ResourceDecorator<T extends File | Directory> extends Resource<T> {
@@ -204,6 +250,7 @@ export declare class GitDirectoryResource extends Resource<Directory> {
204
250
  private options?;
205
251
  constructor(reference: GitDirectoryReference, _progress?: ProgressTracker, options?: {
206
252
  corsProxy?: string;
253
+ additionalHeaders?: (url: string) => Record<string, string>;
207
254
  });
208
255
  resolve(): Promise<{
209
256
  name: string;
@@ -290,3 +337,19 @@ export declare class BundledResource extends Resource<File> {
290
337
  /** @inheritDoc */
291
338
  get isAsync(): boolean;
292
339
  }
340
+ /**
341
+ * A `Resource` that wraps another resource and outputs it as a ZIP file.
342
+ * This is useful for converting directory resources to ZIP files, enabling
343
+ * compatibility with steps that expect ZIP input (like `unzip`).
344
+ */
345
+ export declare class ZipResource extends Resource<File> {
346
+ private reference;
347
+ private innerResource;
348
+ constructor(reference: ZipWrapperReference, innerResource: Resource<File | Directory>, _progress?: ProgressTracker);
349
+ /** @inheritDoc */
350
+ resolve(): Promise<File>;
351
+ /** @inheritDoc */
352
+ get name(): string;
353
+ /** @inheritDoc */
354
+ get isAsync(): boolean;
355
+ }
package/lib/v1/types.d.ts CHANGED
@@ -61,6 +61,7 @@ export type BlueprintV1Declaration = {
61
61
  wp: string | 'latest';
62
62
  };
63
63
  features?: {
64
+ /** Should boot with support for Intl dynamic extension */
64
65
  intl?: boolean;
65
66
  /** Should boot with support for network request via wp_safe_remote_get? */
66
67
  networking?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/blueprints",
3
- "version": "3.0.22",
3
+ "version": "3.0.32",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./index.js",
@@ -8,6 +8,10 @@
8
8
  },
9
9
  "./package.json": "./package.json"
10
10
  },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/WordPress/wordpress-playground"
14
+ },
11
15
  "type": "module",
12
16
  "main": "./index.cjs",
13
17
  "module": "./index.js",
@@ -21,7 +25,7 @@
21
25
  "access": "public",
22
26
  "directory": "../../../dist/packages/playground/blueprints"
23
27
  },
24
- "gitHead": "a624d1a97dc639e152d335e6a801b2fad7f6b594",
28
+ "gitHead": "1c6c30b1db744a7fdb36c0ee044da1b8cf54c5dc",
25
29
  "engines": {
26
30
  "node": ">=20.18.3",
27
31
  "npm": ">=10.1.0"
@@ -39,24 +43,26 @@
39
43
  "minimisted": "2.0.1",
40
44
  "octokit": "3.1.2",
41
45
  "pako": "1.0.10",
42
- "pify": "2.3.0",
46
+ "pify": "4.0.1",
43
47
  "readable-stream": "3.6.2",
48
+ "selfsigned": "2.4.1",
44
49
  "sha.js": "2.4.12",
45
50
  "simple-get": "4.0.1",
46
51
  "wasm-feature-detect": "1.8.0",
47
52
  "ws": "8.18.3",
48
53
  "yargs": "17.7.2",
49
- "@php-wasm/node-polyfills": "3.0.22",
50
- "@wp-playground/storage": "3.0.22",
51
- "@wp-playground/common": "3.0.22",
52
- "@php-wasm/universal": "3.0.22",
53
- "@php-wasm/util": "3.0.22",
54
- "@php-wasm/node": "3.0.22",
55
- "@wp-playground/wordpress": "3.0.22",
56
- "@php-wasm/logger": "3.0.22",
57
- "@php-wasm/progress": "3.0.22",
58
- "@php-wasm/stream-compression": "3.0.22",
59
- "@php-wasm/web": "3.0.22"
54
+ "@php-wasm/node-polyfills": "3.0.32",
55
+ "@wp-playground/storage": "3.0.32",
56
+ "@wp-playground/common": "3.0.32",
57
+ "@php-wasm/universal": "3.0.32",
58
+ "@php-wasm/util": "3.0.32",
59
+ "@php-wasm/node": "3.0.32",
60
+ "@wp-playground/wordpress": "3.0.32",
61
+ "@php-wasm/logger": "3.0.32",
62
+ "@php-wasm/scopes": "3.0.32",
63
+ "@php-wasm/progress": "3.0.32",
64
+ "@php-wasm/stream-compression": "3.0.32",
65
+ "@php-wasm/web": "3.0.32"
60
66
  },
61
67
  "packageManager": "npm@10.9.2",
62
68
  "overrides": {
@@ -64,8 +70,8 @@
64
70
  "react": "18.3.1",
65
71
  "react-dom": "18.3.1",
66
72
  "typescript": "5.4.5",
67
- "@playwright/test": "1.47.1",
68
- "ws": "^8.18.0",
73
+ "@playwright/test": "1.55.1",
74
+ "ws": "8.18.3",
69
75
  "tmp": "0.2.5",
70
76
  "form-data": "^4.0.4"
71
77
  },