@wordpress/e2e-test-utils-playwright 1.32.0 → 1.32.1-next.ff1cebbba.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.
Files changed (113) hide show
  1. package/build/admin/create-new-post.js +46 -28
  2. package/build/admin/create-new-post.js.map +7 -1
  3. package/build/admin/edit-post.js +35 -17
  4. package/build/admin/edit-post.js.map +7 -1
  5. package/build/admin/get-page-error.js +30 -22
  6. package/build/admin/get-page-error.js.map +7 -1
  7. package/build/admin/index.js +54 -34
  8. package/build/admin/index.js.map +7 -1
  9. package/build/admin/visit-admin-page.js +42 -29
  10. package/build/admin/visit-admin-page.js.map +7 -1
  11. package/build/admin/visit-site-editor.js +71 -64
  12. package/build/admin/visit-site-editor.js.map +7 -1
  13. package/build/config.js +40 -10
  14. package/build/config.js.map +7 -1
  15. package/build/editor/click-block-options-menu-item.js +29 -14
  16. package/build/editor/click-block-options-menu-item.js.map +7 -1
  17. package/build/editor/click-block-toolbar-button.js +33 -13
  18. package/build/editor/click-block-toolbar-button.js.map +7 -1
  19. package/build/editor/get-blocks.js +59 -43
  20. package/build/editor/get-blocks.js.map +7 -1
  21. package/build/editor/get-edited-post-content.js +31 -12
  22. package/build/editor/get-edited-post-content.js.map +7 -1
  23. package/build/editor/index.js +92 -72
  24. package/build/editor/index.js.map +7 -1
  25. package/build/editor/insert-block.js +50 -21
  26. package/build/editor/insert-block.js.map +7 -1
  27. package/build/editor/open-document-settings-sidebar.js +37 -24
  28. package/build/editor/open-document-settings-sidebar.js.map +7 -1
  29. package/build/editor/preview.js +37 -18
  30. package/build/editor/preview.js.map +7 -1
  31. package/build/editor/publish-post.js +42 -42
  32. package/build/editor/publish-post.js.map +7 -1
  33. package/build/editor/save-draft.js +29 -15
  34. package/build/editor/save-draft.js.map +7 -1
  35. package/build/editor/select-blocks.js +46 -25
  36. package/build/editor/select-blocks.js.map +7 -1
  37. package/build/editor/set-content.js +34 -14
  38. package/build/editor/set-content.js.map +7 -1
  39. package/build/editor/set-is-fixed-toolbar.js +31 -15
  40. package/build/editor/set-is-fixed-toolbar.js.map +7 -1
  41. package/build/editor/set-preferences.js +38 -18
  42. package/build/editor/set-preferences.js.map +7 -1
  43. package/build/editor/show-block-toolbar.js +30 -16
  44. package/build/editor/show-block-toolbar.js.map +7 -1
  45. package/build/editor/site-editor.js +46 -41
  46. package/build/editor/site-editor.js.map +7 -1
  47. package/build/editor/switch-editor-tool.js +42 -30
  48. package/build/editor/switch-editor-tool.js.map +7 -1
  49. package/build/editor/switch-to-legacy-canvas.js +33 -14
  50. package/build/editor/switch-to-legacy-canvas.js.map +7 -1
  51. package/build/editor/transform-block-to.js +41 -21
  52. package/build/editor/transform-block-to.js.map +7 -1
  53. package/build/index.js +50 -32
  54. package/build/index.js.map +7 -1
  55. package/build/lighthouse/index.js +89 -53
  56. package/build/lighthouse/index.js.map +7 -1
  57. package/build/metrics/index.js +298 -249
  58. package/build/metrics/index.js.map +7 -1
  59. package/build/page-utils/drag-files.js +134 -112
  60. package/build/page-utils/drag-files.js.map +7 -1
  61. package/build/page-utils/emulate-network-conditions.js +92 -66
  62. package/build/page-utils/emulate-network-conditions.js.map +7 -1
  63. package/build/page-utils/index.js +54 -34
  64. package/build/page-utils/index.js.map +7 -1
  65. package/build/page-utils/is-current-url.js +31 -18
  66. package/build/page-utils/is-current-url.js.map +7 -1
  67. package/build/page-utils/keycodes.js +51 -39
  68. package/build/page-utils/keycodes.js.map +7 -1
  69. package/build/page-utils/press-keys.js +148 -127
  70. package/build/page-utils/press-keys.js.map +7 -1
  71. package/build/page-utils/set-browser-viewport.js +32 -41
  72. package/build/page-utils/set-browser-viewport.js.map +7 -1
  73. package/build/request-utils/blocks.js +49 -40
  74. package/build/request-utils/blocks.js.map +7 -1
  75. package/build/request-utils/comments.js +57 -45
  76. package/build/request-utils/comments.js.map +7 -1
  77. package/build/request-utils/gutenberg-experiments.js +48 -26
  78. package/build/request-utils/gutenberg-experiments.js.map +7 -1
  79. package/build/request-utils/index.js +187 -153
  80. package/build/request-utils/index.js.map +7 -1
  81. package/build/request-utils/login.js +43 -18
  82. package/build/request-utils/login.js.map +7 -1
  83. package/build/request-utils/media.js +72 -64
  84. package/build/request-utils/media.js.map +7 -1
  85. package/build/request-utils/menus.js +119 -109
  86. package/build/request-utils/menus.js.map +7 -1
  87. package/build/request-utils/pages.js +60 -49
  88. package/build/request-utils/pages.js.map +7 -1
  89. package/build/request-utils/patterns.js +39 -24
  90. package/build/request-utils/patterns.js.map +7 -1
  91. package/build/request-utils/plugins.js +68 -74
  92. package/build/request-utils/plugins.js.map +7 -1
  93. package/build/request-utils/posts.js +52 -39
  94. package/build/request-utils/posts.js.map +7 -1
  95. package/build/request-utils/preferences.js +36 -17
  96. package/build/request-utils/preferences.js.map +7 -1
  97. package/build/request-utils/rest.js +153 -129
  98. package/build/request-utils/rest.js.map +7 -1
  99. package/build/request-utils/site-settings.js +38 -28
  100. package/build/request-utils/site-settings.js.map +7 -1
  101. package/build/request-utils/templates.js +57 -45
  102. package/build/request-utils/templates.js.map +7 -1
  103. package/build/request-utils/themes.js +78 -53
  104. package/build/request-utils/themes.js.map +7 -1
  105. package/build/request-utils/users.js +72 -72
  106. package/build/request-utils/users.js.map +7 -1
  107. package/build/request-utils/widgets.js +71 -55
  108. package/build/request-utils/widgets.js.map +7 -1
  109. package/build/test.js +128 -146
  110. package/build/test.js.map +7 -1
  111. package/build/types.js +16 -2
  112. package/build/types.js.map +7 -1
  113. package/package.json +6 -2
@@ -1,158 +1,192 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequestUtils = void 0;
4
- /**
5
- * External dependencies
6
- */
7
- const fs = require("fs/promises");
8
- const path = require("path");
9
- const test_1 = require("@playwright/test");
10
- /**
11
- * Internal dependencies
12
- */
13
- const config_1 = require("../config");
14
- const login_1 = require("./login");
15
- const media_1 = require("./media");
16
- const users_1 = require("./users");
17
- const rest_1 = require("./rest");
18
- const plugins_1 = require("./plugins");
19
- const templates_1 = require("./templates");
20
- const themes_1 = require("./themes");
21
- const blocks_1 = require("./blocks");
22
- const comments_1 = require("./comments");
23
- const posts_1 = require("./posts");
24
- const menus_1 = require("./menus");
25
- const pages_1 = require("./pages");
26
- const preferences_1 = require("./preferences");
27
- const site_settings_1 = require("./site-settings");
28
- const widgets_1 = require("./widgets");
29
- const patterns_1 = require("./patterns");
30
- const gutenberg_experiments_1 = require("./gutenberg-experiments");
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var request_utils_exports = {};
30
+ __export(request_utils_exports, {
31
+ RequestUtils: () => RequestUtils
32
+ });
33
+ module.exports = __toCommonJS(request_utils_exports);
34
+ var fs = __toESM(require("fs/promises"));
35
+ var path = __toESM(require("path"));
36
+ var import_test = require("@playwright/test");
37
+ var import_config = require("../config");
38
+ var import_login = require("./login");
39
+ var import_media = require("./media");
40
+ var import_users = require("./users");
41
+ var import_rest = require("./rest");
42
+ var import_plugins = require("./plugins");
43
+ var import_templates = require("./templates");
44
+ var import_themes = require("./themes");
45
+ var import_blocks = require("./blocks");
46
+ var import_comments = require("./comments");
47
+ var import_posts = require("./posts");
48
+ var import_menus = require("./menus");
49
+ var import_pages = require("./pages");
50
+ var import_preferences = require("./preferences");
51
+ var import_site_settings = require("./site-settings");
52
+ var import_widgets = require("./widgets");
53
+ var import_patterns = require("./patterns");
54
+ var import_gutenberg_experiments = require("./gutenberg-experiments");
31
55
  class RequestUtils {
32
- request;
33
- user;
34
- maxBatchSize;
35
- storageState;
36
- storageStatePath;
37
- baseURL;
38
- pluginsMap = null;
39
- static async setup({ user, storageStatePath, baseURL = config_1.WP_BASE_URL, }) {
40
- let storageState;
41
- if (storageStatePath) {
42
- await fs.mkdir(path.dirname(storageStatePath), {
43
- recursive: true,
44
- });
45
- try {
46
- storageState = JSON.parse(await fs.readFile(storageStatePath, 'utf-8'));
47
- }
48
- catch (error) {
49
- if (error instanceof Error &&
50
- error.code === 'ENOENT') {
51
- // Ignore errors if the state is not found.
52
- }
53
- else {
54
- throw error;
55
- }
56
- }
56
+ request;
57
+ user;
58
+ maxBatchSize;
59
+ storageState;
60
+ storageStatePath;
61
+ baseURL;
62
+ pluginsMap = null;
63
+ static async setup({
64
+ user,
65
+ storageStatePath,
66
+ baseURL = import_config.WP_BASE_URL
67
+ }) {
68
+ let storageState;
69
+ if (storageStatePath) {
70
+ await fs.mkdir(path.dirname(storageStatePath), {
71
+ recursive: true
72
+ });
73
+ try {
74
+ storageState = JSON.parse(
75
+ await fs.readFile(storageStatePath, "utf-8")
76
+ );
77
+ } catch (error) {
78
+ if (error instanceof Error && error.code === "ENOENT") {
79
+ } else {
80
+ throw error;
57
81
  }
58
- const requestContext = await test_1.request.newContext({
59
- baseURL,
60
- storageState: storageState && {
61
- cookies: storageState.cookies,
62
- origins: [],
63
- },
64
- });
65
- const requestUtils = new this(requestContext, {
66
- user,
67
- storageState,
68
- storageStatePath,
69
- baseURL,
70
- });
71
- return requestUtils;
82
+ }
72
83
  }
73
- constructor(requestContext, { user = config_1.WP_ADMIN_USER, storageState, storageStatePath, baseURL = config_1.WP_BASE_URL, } = {}) {
74
- this.user = user;
75
- this.request = requestContext;
76
- this.storageStatePath = storageStatePath;
77
- this.storageState = storageState;
78
- this.baseURL = baseURL;
79
- }
80
- /** @borrows login as this.login */
81
- login = login_1.login.bind(this);
82
- /** @borrows setupRest as this.setupRest */
83
- setupRest = rest_1.setupRest.bind(this);
84
- // .bind() drops the generic types. Re-casting it to keep the type signature.
85
- rest = rest_1.rest.bind(this);
86
- /** @borrows getMaxBatchSize as this.getMaxBatchSize */
87
- getMaxBatchSize = rest_1.getMaxBatchSize.bind(this);
88
- // .bind() drops the generic types. Re-casting it to keep the type signature.
89
- batchRest = rest_1.batchRest.bind(this);
90
- /** @borrows getPluginsMap as this.getPluginsMap */
91
- getPluginsMap = plugins_1.getPluginsMap.bind(this);
92
- /** @borrows activatePlugin as this.activatePlugin */
93
- activatePlugin = plugins_1.activatePlugin.bind(this);
94
- /** @borrows deactivatePlugin as this.deactivatePlugin */
95
- deactivatePlugin = plugins_1.deactivatePlugin.bind(this);
96
- /** @borrows activateTheme as this.activateTheme */
97
- activateTheme = themes_1.activateTheme.bind(this);
98
- /** @borrows createBlock as this.createBlock */
99
- createBlock = blocks_1.createBlock.bind(this);
100
- /** @borrows deleteAllBlocks as this.deleteAllBlocks */
101
- deleteAllBlocks = blocks_1.deleteAllBlocks.bind(this);
102
- /** @borrows createPost as this.createPost */
103
- createPost = posts_1.createPost.bind(this);
104
- /** @borrows deleteAllPosts as this.deleteAllPosts */
105
- deleteAllPosts = posts_1.deleteAllPosts.bind(this);
106
- /** @borrows createClassicMenu as this.createClassicMenu */
107
- createClassicMenu = menus_1.createClassicMenu.bind(this);
108
- /** @borrows createNavigationMenu as this.createNavigationMenu */
109
- createNavigationMenu = menus_1.createNavigationMenu.bind(this);
110
- /** @borrows deleteAllMenus as this.deleteAllMenus */
111
- deleteAllMenus = menus_1.deleteAllMenus.bind(this);
112
- /** @borrows getNavigationMenus as this.getNavigationMenus */
113
- getNavigationMenus = menus_1.getNavigationMenus.bind(this);
114
- /** @borrows createComment as this.createComment */
115
- createComment = comments_1.createComment.bind(this);
116
- /** @borrows deleteAllComments as this.deleteAllComments */
117
- deleteAllComments = comments_1.deleteAllComments.bind(this);
118
- /** @borrows deleteAllWidgets as this.deleteAllWidgets */
119
- deleteAllWidgets = widgets_1.deleteAllWidgets.bind(this);
120
- /** @borrows addWidgetBlock as this.addWidgetBlock */
121
- addWidgetBlock = widgets_1.addWidgetBlock.bind(this);
122
- /** @borrows deleteAllTemplates as this.deleteAllTemplates */
123
- deleteAllTemplates = templates_1.deleteAllTemplates.bind(this);
124
- /** @borrows createTemplate as this.createTemplate */
125
- createTemplate = templates_1.createTemplate.bind(this);
126
- /** @borrows resetPreferences as this.resetPreferences */
127
- resetPreferences = preferences_1.resetPreferences.bind(this);
128
- /** @borrows listMedia as this.listMedia */
129
- listMedia = media_1.listMedia.bind(this);
130
- /** @borrows uploadMedia as this.uploadMedia */
131
- uploadMedia = media_1.uploadMedia.bind(this);
132
- /** @borrows deleteMedia as this.deleteMedia */
133
- deleteMedia = media_1.deleteMedia.bind(this);
134
- /** @borrows deleteAllMedia as this.deleteAllMedia */
135
- deleteAllMedia = media_1.deleteAllMedia.bind(this);
136
- /** @borrows createUser as this.createUser */
137
- createUser = users_1.createUser.bind(this);
138
- /** @borrows deleteAllUsers as this.deleteAllUsers */
139
- deleteAllUsers = users_1.deleteAllUsers.bind(this);
140
- /** @borrows getSiteSettings as this.getSiteSettings */
141
- getSiteSettings = site_settings_1.getSiteSettings.bind(this);
142
- /** @borrows updateSiteSettings as this.updateSiteSettings */
143
- updateSiteSettings = site_settings_1.updateSiteSettings.bind(this);
144
- /** @borrows deleteAllPages as this.deleteAllPages */
145
- deleteAllPages = pages_1.deleteAllPages.bind(this);
146
- /** @borrows createPage as this.createPage */
147
- createPage = pages_1.createPage.bind(this);
148
- /** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */
149
- getCurrentThemeGlobalStylesPostId = themes_1.getCurrentThemeGlobalStylesPostId.bind(this);
150
- /** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */
151
- getThemeGlobalStylesRevisions = themes_1.getThemeGlobalStylesRevisions.bind(this);
152
- /** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */
153
- deleteAllPatternCategories = patterns_1.deleteAllPatternCategories.bind(this);
154
- /** @borrows setGutenbergExperiments as this.setGutenbergExperiments */
155
- setGutenbergExperiments = gutenberg_experiments_1.setGutenbergExperiments.bind(this);
84
+ const requestContext = await import_test.request.newContext({
85
+ baseURL,
86
+ storageState: storageState && {
87
+ cookies: storageState.cookies,
88
+ origins: []
89
+ }
90
+ });
91
+ const requestUtils = new this(requestContext, {
92
+ user,
93
+ storageState,
94
+ storageStatePath,
95
+ baseURL
96
+ });
97
+ return requestUtils;
98
+ }
99
+ constructor(requestContext, {
100
+ user = import_config.WP_ADMIN_USER,
101
+ storageState,
102
+ storageStatePath,
103
+ baseURL = import_config.WP_BASE_URL
104
+ } = {}) {
105
+ this.user = user;
106
+ this.request = requestContext;
107
+ this.storageStatePath = storageStatePath;
108
+ this.storageState = storageState;
109
+ this.baseURL = baseURL;
110
+ }
111
+ /** @borrows login as this.login */
112
+ login = import_login.login.bind(this);
113
+ /** @borrows setupRest as this.setupRest */
114
+ setupRest = import_rest.setupRest.bind(this);
115
+ // .bind() drops the generic types. Re-casting it to keep the type signature.
116
+ rest = import_rest.rest.bind(this);
117
+ /** @borrows getMaxBatchSize as this.getMaxBatchSize */
118
+ getMaxBatchSize = import_rest.getMaxBatchSize.bind(this);
119
+ // .bind() drops the generic types. Re-casting it to keep the type signature.
120
+ batchRest = import_rest.batchRest.bind(this);
121
+ /** @borrows getPluginsMap as this.getPluginsMap */
122
+ getPluginsMap = import_plugins.getPluginsMap.bind(this);
123
+ /** @borrows activatePlugin as this.activatePlugin */
124
+ activatePlugin = import_plugins.activatePlugin.bind(this);
125
+ /** @borrows deactivatePlugin as this.deactivatePlugin */
126
+ deactivatePlugin = import_plugins.deactivatePlugin.bind(this);
127
+ /** @borrows activateTheme as this.activateTheme */
128
+ activateTheme = import_themes.activateTheme.bind(this);
129
+ /** @borrows createBlock as this.createBlock */
130
+ createBlock = import_blocks.createBlock.bind(this);
131
+ /** @borrows deleteAllBlocks as this.deleteAllBlocks */
132
+ deleteAllBlocks = import_blocks.deleteAllBlocks.bind(this);
133
+ /** @borrows createPost as this.createPost */
134
+ createPost = import_posts.createPost.bind(this);
135
+ /** @borrows deleteAllPosts as this.deleteAllPosts */
136
+ deleteAllPosts = import_posts.deleteAllPosts.bind(this);
137
+ /** @borrows createClassicMenu as this.createClassicMenu */
138
+ createClassicMenu = import_menus.createClassicMenu.bind(this);
139
+ /** @borrows createNavigationMenu as this.createNavigationMenu */
140
+ createNavigationMenu = import_menus.createNavigationMenu.bind(this);
141
+ /** @borrows deleteAllMenus as this.deleteAllMenus */
142
+ deleteAllMenus = import_menus.deleteAllMenus.bind(this);
143
+ /** @borrows getNavigationMenus as this.getNavigationMenus */
144
+ getNavigationMenus = import_menus.getNavigationMenus.bind(this);
145
+ /** @borrows createComment as this.createComment */
146
+ createComment = import_comments.createComment.bind(this);
147
+ /** @borrows deleteAllComments as this.deleteAllComments */
148
+ deleteAllComments = import_comments.deleteAllComments.bind(this);
149
+ /** @borrows deleteAllWidgets as this.deleteAllWidgets */
150
+ deleteAllWidgets = import_widgets.deleteAllWidgets.bind(this);
151
+ /** @borrows addWidgetBlock as this.addWidgetBlock */
152
+ addWidgetBlock = import_widgets.addWidgetBlock.bind(this);
153
+ /** @borrows deleteAllTemplates as this.deleteAllTemplates */
154
+ deleteAllTemplates = import_templates.deleteAllTemplates.bind(this);
155
+ /** @borrows createTemplate as this.createTemplate */
156
+ createTemplate = import_templates.createTemplate.bind(this);
157
+ /** @borrows resetPreferences as this.resetPreferences */
158
+ resetPreferences = import_preferences.resetPreferences.bind(this);
159
+ /** @borrows listMedia as this.listMedia */
160
+ listMedia = import_media.listMedia.bind(this);
161
+ /** @borrows uploadMedia as this.uploadMedia */
162
+ uploadMedia = import_media.uploadMedia.bind(this);
163
+ /** @borrows deleteMedia as this.deleteMedia */
164
+ deleteMedia = import_media.deleteMedia.bind(this);
165
+ /** @borrows deleteAllMedia as this.deleteAllMedia */
166
+ deleteAllMedia = import_media.deleteAllMedia.bind(this);
167
+ /** @borrows createUser as this.createUser */
168
+ createUser = import_users.createUser.bind(this);
169
+ /** @borrows deleteAllUsers as this.deleteAllUsers */
170
+ deleteAllUsers = import_users.deleteAllUsers.bind(this);
171
+ /** @borrows getSiteSettings as this.getSiteSettings */
172
+ getSiteSettings = import_site_settings.getSiteSettings.bind(this);
173
+ /** @borrows updateSiteSettings as this.updateSiteSettings */
174
+ updateSiteSettings = import_site_settings.updateSiteSettings.bind(this);
175
+ /** @borrows deleteAllPages as this.deleteAllPages */
176
+ deleteAllPages = import_pages.deleteAllPages.bind(this);
177
+ /** @borrows createPage as this.createPage */
178
+ createPage = import_pages.createPage.bind(this);
179
+ /** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */
180
+ getCurrentThemeGlobalStylesPostId = import_themes.getCurrentThemeGlobalStylesPostId.bind(this);
181
+ /** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */
182
+ getThemeGlobalStylesRevisions = import_themes.getThemeGlobalStylesRevisions.bind(this);
183
+ /** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */
184
+ deleteAllPatternCategories = import_patterns.deleteAllPatternCategories.bind(this);
185
+ /** @borrows setGutenbergExperiments as this.setGutenbergExperiments */
186
+ setGutenbergExperiments = import_gutenberg_experiments.setGutenbergExperiments.bind(this);
156
187
  }
157
- exports.RequestUtils = RequestUtils;
158
- //# sourceMappingURL=index.js.map
188
+ // Annotate the CommonJS export names for ESM import in node:
189
+ 0 && (module.exports = {
190
+ RequestUtils
191
+ });
192
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request-utils/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,kCAAkC;AAClC,6BAA6B;AAC7B,2CAA2C;AAG3C;;GAEG;AACH,sCAAuD;AAEvD,mCAAgC;AAChC,mCAA8E;AAC9E,mCAAqD;AACrD,iCAAqE;AACrE,uCAA4E;AAC5E,2CAAiE;AACjE,qCAIkB;AAClB,qCAAwD;AACxD,yCAA8D;AAC9D,mCAAqD;AACrD,mCAKiB;AACjB,mCAAqD;AACrD,+CAAiD;AACjD,mDAAsE;AACtE,uCAA6D;AAC7D,yCAAwD;AACxD,mEAAkE;AAQlE,MAAM,YAAY;IACjB,OAAO,CAAoB;IAC3B,IAAI,CAAO;IACX,YAAY,CAAU;IACtB,YAAY,CAAgB;IAC5B,gBAAgB,CAAU;IAC1B,OAAO,CAAU;IAEjB,UAAU,GAAoC,IAAI,CAAC;IAEnD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAE,EACnB,IAAI,EACJ,gBAAgB,EAChB,OAAO,GAAG,oBAAW,GAKrB;QACA,IAAI,YAAsC,CAAC;QAC3C,IAAK,gBAAgB,EAAG,CAAC;YACxB,MAAM,EAAE,CAAC,KAAK,CAAE,IAAI,CAAC,OAAO,CAAE,gBAAgB,CAAE,EAAE;gBACjD,SAAS,EAAE,IAAI;aACf,CAAE,CAAC;YAEJ,IAAI,CAAC;gBACJ,YAAY,GAAG,IAAI,CAAC,KAAK,CACxB,MAAM,EAAE,CAAC,QAAQ,CAAE,gBAAgB,EAAE,OAAO,CAAE,CAC9C,CAAC;YACH,CAAC;YAAC,OAAQ,KAA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AAE,CAAC;IAC5C,6EAA6E;IAC7E,0BAA0B,GAAG,qCAA0B,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrE,uEAAuE;IACvE,uBAAuB,GACtB,+CAAuB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;CACtC;AAGQ,oCAAY"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/request-utils/index.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { request } from '@playwright/test';\nimport type { APIRequestContext, Cookie } from '@playwright/test';\n\n/**\n * Internal dependencies\n */\nimport { WP_ADMIN_USER, WP_BASE_URL } from '../config';\nimport type { User } from './login';\nimport { login } from './login';\nimport { listMedia, uploadMedia, deleteMedia, deleteAllMedia } from './media';\nimport { createUser, deleteAllUsers } from './users';\nimport { setupRest, rest, getMaxBatchSize, batchRest } from './rest';\nimport { getPluginsMap, activatePlugin, deactivatePlugin } from './plugins';\nimport { deleteAllTemplates, createTemplate } from './templates';\nimport {\n\tactivateTheme,\n\tgetCurrentThemeGlobalStylesPostId,\n\tgetThemeGlobalStylesRevisions,\n} from './themes';\nimport { createBlock, deleteAllBlocks } from './blocks';\nimport { createComment, deleteAllComments } from './comments';\nimport { createPost, deleteAllPosts } from './posts';\nimport {\n\tcreateClassicMenu,\n\tcreateNavigationMenu,\n\tdeleteAllMenus,\n\tgetNavigationMenus,\n} from './menus';\nimport { deleteAllPages, createPage } from './pages';\nimport { resetPreferences } from './preferences';\nimport { getSiteSettings, updateSiteSettings } from './site-settings';\nimport { deleteAllWidgets, addWidgetBlock } from './widgets';\nimport { deleteAllPatternCategories } from './patterns';\nimport { setGutenbergExperiments } from './gutenberg-experiments';\n\ninterface StorageState {\n\tcookies: Cookie[];\n\tnonce: string;\n\trootURL: string;\n}\n\nclass RequestUtils {\n\trequest: APIRequestContext;\n\tuser: User;\n\tmaxBatchSize?: number;\n\tstorageState?: StorageState;\n\tstorageStatePath?: string;\n\tbaseURL?: string;\n\n\tpluginsMap: Record< string, string > | null = null;\n\n\tstatic async setup( {\n\t\tuser,\n\t\tstorageStatePath,\n\t\tbaseURL = WP_BASE_URL,\n\t}: {\n\t\tuser?: User;\n\t\tstorageStatePath?: string;\n\t\tbaseURL?: string;\n\t} ) {\n\t\tlet storageState: StorageState | undefined;\n\t\tif ( storageStatePath ) {\n\t\t\tawait fs.mkdir( path.dirname( storageStatePath ), {\n\t\t\t\trecursive: true,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tstorageState = JSON.parse(\n\t\t\t\t\tawait fs.readFile( storageStatePath, 'utf-8' )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t( error as NodeJS.ErrnoException ).code === 'ENOENT'\n\t\t\t\t) {\n\t\t\t\t\t// Ignore errors if the state is not found.\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst requestContext = await request.newContext( {\n\t\t\tbaseURL,\n\t\t\tstorageState: storageState && {\n\t\t\t\tcookies: storageState.cookies,\n\t\t\t\torigins: [],\n\t\t\t},\n\t\t} );\n\n\t\tconst requestUtils = new this( requestContext, {\n\t\t\tuser,\n\t\t\tstorageState,\n\t\t\tstorageStatePath,\n\t\t\tbaseURL,\n\t\t} );\n\n\t\treturn requestUtils;\n\t}\n\n\tconstructor(\n\t\trequestContext: APIRequestContext,\n\t\t{\n\t\t\tuser = WP_ADMIN_USER,\n\t\t\tstorageState,\n\t\t\tstorageStatePath,\n\t\t\tbaseURL = WP_BASE_URL,\n\t\t}: {\n\t\t\tuser?: User;\n\t\t\tstorageState?: StorageState;\n\t\t\tstorageStatePath?: string;\n\t\t\tbaseURL?: string;\n\t\t} = {}\n\t) {\n\t\tthis.user = user;\n\t\tthis.request = requestContext;\n\t\tthis.storageStatePath = storageStatePath;\n\t\tthis.storageState = storageState;\n\t\tthis.baseURL = baseURL;\n\t}\n\n\t/** @borrows login as this.login */\n\tlogin: typeof login = login.bind( this );\n\t/** @borrows setupRest as this.setupRest */\n\tsetupRest: typeof setupRest = setupRest.bind( this );\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\trest: typeof rest = rest.bind( this ) as typeof rest;\n\t/** @borrows getMaxBatchSize as this.getMaxBatchSize */\n\tgetMaxBatchSize: typeof getMaxBatchSize = getMaxBatchSize.bind( this );\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\tbatchRest: typeof batchRest = batchRest.bind( this ) as typeof batchRest;\n\t/** @borrows getPluginsMap as this.getPluginsMap */\n\tgetPluginsMap: typeof getPluginsMap = getPluginsMap.bind( this );\n\t/** @borrows activatePlugin as this.activatePlugin */\n\tactivatePlugin: typeof activatePlugin = activatePlugin.bind( this );\n\t/** @borrows deactivatePlugin as this.deactivatePlugin */\n\tdeactivatePlugin: typeof deactivatePlugin = deactivatePlugin.bind( this );\n\t/** @borrows activateTheme as this.activateTheme */\n\tactivateTheme: typeof activateTheme = activateTheme.bind( this );\n\t/** @borrows createBlock as this.createBlock */\n\tcreateBlock: typeof createBlock = createBlock.bind( this );\n\t/** @borrows deleteAllBlocks as this.deleteAllBlocks */\n\tdeleteAllBlocks = deleteAllBlocks.bind( this );\n\t/** @borrows createPost as this.createPost */\n\tcreatePost: typeof createPost = createPost.bind( this );\n\t/** @borrows deleteAllPosts as this.deleteAllPosts */\n\tdeleteAllPosts: typeof deleteAllPosts = deleteAllPosts.bind( this );\n\t/** @borrows createClassicMenu as this.createClassicMenu */\n\tcreateClassicMenu: typeof createClassicMenu =\n\t\tcreateClassicMenu.bind( this );\n\t/** @borrows createNavigationMenu as this.createNavigationMenu */\n\tcreateNavigationMenu: typeof createNavigationMenu =\n\t\tcreateNavigationMenu.bind( this );\n\t/** @borrows deleteAllMenus as this.deleteAllMenus */\n\tdeleteAllMenus: typeof deleteAllMenus = deleteAllMenus.bind( this );\n\t/** @borrows getNavigationMenus as this.getNavigationMenus */\n\tgetNavigationMenus: typeof getNavigationMenus =\n\t\tgetNavigationMenus.bind( this );\n\t/** @borrows createComment as this.createComment */\n\tcreateComment: typeof createComment = createComment.bind( this );\n\t/** @borrows deleteAllComments as this.deleteAllComments */\n\tdeleteAllComments: typeof deleteAllComments =\n\t\tdeleteAllComments.bind( this );\n\t/** @borrows deleteAllWidgets as this.deleteAllWidgets */\n\tdeleteAllWidgets: typeof deleteAllWidgets = deleteAllWidgets.bind( this );\n\t/** @borrows addWidgetBlock as this.addWidgetBlock */\n\taddWidgetBlock: typeof addWidgetBlock = addWidgetBlock.bind( this );\n\t/** @borrows deleteAllTemplates as this.deleteAllTemplates */\n\tdeleteAllTemplates: typeof deleteAllTemplates =\n\t\tdeleteAllTemplates.bind( this );\n\t/** @borrows createTemplate as this.createTemplate */\n\tcreateTemplate: typeof createTemplate = createTemplate.bind( this );\n\t/** @borrows resetPreferences as this.resetPreferences */\n\tresetPreferences: typeof resetPreferences = resetPreferences.bind( this );\n\t/** @borrows listMedia as this.listMedia */\n\tlistMedia: typeof listMedia = listMedia.bind( this );\n\t/** @borrows uploadMedia as this.uploadMedia */\n\tuploadMedia: typeof uploadMedia = uploadMedia.bind( this );\n\t/** @borrows deleteMedia as this.deleteMedia */\n\tdeleteMedia: typeof deleteMedia = deleteMedia.bind( this );\n\t/** @borrows deleteAllMedia as this.deleteAllMedia */\n\tdeleteAllMedia: typeof deleteAllMedia = deleteAllMedia.bind( this );\n\t/** @borrows createUser as this.createUser */\n\tcreateUser: typeof createUser = createUser.bind( this );\n\t/** @borrows deleteAllUsers as this.deleteAllUsers */\n\tdeleteAllUsers: typeof deleteAllUsers = deleteAllUsers.bind( this );\n\t/** @borrows getSiteSettings as this.getSiteSettings */\n\tgetSiteSettings: typeof getSiteSettings = getSiteSettings.bind( this );\n\t/** @borrows updateSiteSettings as this.updateSiteSettings */\n\tupdateSiteSettings: typeof updateSiteSettings =\n\t\tupdateSiteSettings.bind( this );\n\t/** @borrows deleteAllPages as this.deleteAllPages */\n\tdeleteAllPages: typeof deleteAllPages = deleteAllPages.bind( this );\n\t/** @borrows createPage as this.createPage */\n\tcreatePage: typeof createPage = createPage.bind( this );\n\t/** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */\n\tgetCurrentThemeGlobalStylesPostId: typeof getCurrentThemeGlobalStylesPostId =\n\t\tgetCurrentThemeGlobalStylesPostId.bind( this );\n\t/** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */\n\tgetThemeGlobalStylesRevisions: typeof getThemeGlobalStylesRevisions =\n\t\tgetThemeGlobalStylesRevisions.bind( this );\n\t/** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */\n\tdeleteAllPatternCategories = deleteAllPatternCategories.bind( this );\n\t/** @borrows setGutenbergExperiments as this.setGutenbergExperiments */\n\tsetGutenbergExperiments: typeof setGutenbergExperiments =\n\t\tsetGutenbergExperiments.bind( this );\n}\n\nexport type { StorageState };\nexport { RequestUtils };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAoB;AACpB,WAAsB;AACtB,kBAAwB;AAMxB,oBAA2C;AAE3C,mBAAsB;AACtB,mBAAoE;AACpE,mBAA2C;AAC3C,kBAA4D;AAC5D,qBAAgE;AAChE,uBAAmD;AACnD,oBAIO;AACP,oBAA6C;AAC7C,sBAAiD;AACjD,mBAA2C;AAC3C,mBAKO;AACP,mBAA2C;AAC3C,yBAAiC;AACjC,2BAAoD;AACpD,qBAAiD;AACjD,sBAA2C;AAC3C,mCAAwC;AAQxC,MAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,aAA8C;AAAA,EAE9C,aAAa,MAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACX,GAII;AACH,QAAI;AACJ,QAAK,kBAAm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A,EAE1C,6BAA6B,2CAA2B,KAAM,IAAK;AAAA;AAAA,EAEnE,0BACC,qDAAwB,KAAM,IAAK;AACrC;",
6
+ "names": []
7
+ }
@@ -1,21 +1,46 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.login = login;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var login_exports = {};
20
+ __export(login_exports, {
21
+ login: () => login
22
+ });
23
+ module.exports = __toCommonJS(login_exports);
4
24
  async function login(user = this.user) {
5
- // Login to admin using request context.
6
- let response = await this.request.post('wp-login.php', {
7
- failOnStatusCode: true,
8
- form: {
9
- log: user.username,
10
- pwd: user.password,
11
- },
12
- });
13
- await response.dispose();
14
- // Get the nonce.
15
- response = await this.request.get('wp-admin/admin-ajax.php?action=rest-nonce', {
16
- failOnStatusCode: true,
17
- });
18
- const nonce = await response.text();
19
- return nonce;
25
+ let response = await this.request.post("wp-login.php", {
26
+ failOnStatusCode: true,
27
+ form: {
28
+ log: user.username,
29
+ pwd: user.password
30
+ }
31
+ });
32
+ await response.dispose();
33
+ response = await this.request.get(
34
+ "wp-admin/admin-ajax.php?action=rest-nonce",
35
+ {
36
+ failOnStatusCode: true
37
+ }
38
+ );
39
+ const nonce = await response.text();
40
+ return nonce;
20
41
  }
21
- //# sourceMappingURL=login.js.map
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ login
45
+ });
46
+ //# sourceMappingURL=login.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/request-utils/login.ts"],"names":[],"mappings":";;AAiCS,sBAAK;AAvBd,KAAK,UAAU,KAAK,CAAsB,OAAa,IAAI,CAAC,IAAI;IAC/D,wCAAwC;IACxC,IAAI,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAE,cAAc,EAAE;QACvD,gBAAgB,EAAE,IAAI;QACtB,IAAI,EAAE;YACL,GAAG,EAAE,IAAI,CAAC,QAAQ;YAClB,GAAG,EAAE,IAAI,CAAC,QAAQ;SAClB;KACD,CAAE,CAAC;IACJ,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAEzB,iBAAiB;IACjB,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAChC,2CAA2C,EAC3C;QACC,gBAAgB,EAAE,IAAI;KACtB,CACD,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEpC,OAAO,KAAK,CAAC;AACd,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/request-utils/login.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface User {\n\tusername: string;\n\tpassword: string;\n}\n\nasync function login( this: RequestUtils, user: User = this.user ) {\n\t// Login to admin using request context.\n\tlet response = await this.request.post( 'wp-login.php', {\n\t\tfailOnStatusCode: true,\n\t\tform: {\n\t\t\tlog: user.username,\n\t\t\tpwd: user.password,\n\t\t},\n\t} );\n\tawait response.dispose();\n\n\t// Get the nonce.\n\tresponse = await this.request.get(\n\t\t'wp-admin/admin-ajax.php?action=rest-nonce',\n\t\t{\n\t\t\tfailOnStatusCode: true,\n\t\t}\n\t);\n\tconst nonce = await response.text();\n\n\treturn nonce;\n}\n\nexport { login };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAAe,MAA2B,OAAa,KAAK,MAAO;AAElE,MAAI,WAAW,MAAM,KAAK,QAAQ,KAAM,gBAAgB;AAAA,IACvD,kBAAkB;AAAA,IAClB,MAAM;AAAA,MACL,KAAK,KAAK;AAAA,MACV,KAAK,KAAK;AAAA,IACX;AAAA,EACD,CAAE;AACF,QAAM,SAAS,QAAQ;AAGvB,aAAW,MAAM,KAAK,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,MACC,kBAAkB;AAAA,IACnB;AAAA,EACD;AACA,QAAM,QAAQ,MAAM,SAAS,KAAK;AAElC,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,73 +1,81 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listMedia = listMedia;
4
- exports.uploadMedia = uploadMedia;
5
- exports.deleteMedia = deleteMedia;
6
- exports.deleteAllMedia = deleteAllMedia;
7
- /**
8
- * External dependencies
9
- */
10
- const fs = require("fs");
11
- /**
12
- * List all media files.
13
- *
14
- * @see https://developer.wordpress.org/rest-api/reference/media/#list-media
15
- * @param this
16
- */
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var media_exports = {};
30
+ __export(media_exports, {
31
+ deleteAllMedia: () => deleteAllMedia,
32
+ deleteMedia: () => deleteMedia,
33
+ listMedia: () => listMedia,
34
+ uploadMedia: () => uploadMedia
35
+ });
36
+ module.exports = __toCommonJS(media_exports);
37
+ var fs = __toESM(require("fs"));
17
38
  async function listMedia() {
18
- const response = await this.rest({
19
- method: 'GET',
20
- path: '/wp/v2/media',
21
- params: {
22
- per_page: 100,
23
- },
24
- });
25
- return response;
39
+ const response = await this.rest({
40
+ method: "GET",
41
+ path: "/wp/v2/media",
42
+ params: {
43
+ per_page: 100
44
+ }
45
+ });
46
+ return response;
26
47
  }
27
- /**
28
- * Upload a media file.
29
- *
30
- * @see https://developer.wordpress.org/rest-api/reference/media/#create-a-media-item
31
- * @param this
32
- * @param filePathOrData The path or data of the file being uploaded.
33
- */
34
48
  async function uploadMedia(filePathOrData) {
35
- const file = typeof filePathOrData === 'string'
36
- ? fs.createReadStream(filePathOrData)
37
- : filePathOrData;
38
- const response = await this.rest({
39
- method: 'POST',
40
- path: '/wp/v2/media',
41
- multipart: {
42
- file,
43
- },
44
- });
45
- return response;
49
+ const file = typeof filePathOrData === "string" ? fs.createReadStream(filePathOrData) : filePathOrData;
50
+ const response = await this.rest({
51
+ method: "POST",
52
+ path: "/wp/v2/media",
53
+ multipart: {
54
+ file
55
+ }
56
+ });
57
+ return response;
46
58
  }
47
- /**
48
- * delete a media file.
49
- *
50
- * @see https://developer.wordpress.org/rest-api/reference/media/#delete-a-media-item
51
- * @param this
52
- * @param mediaId The ID of the media file.
53
- */
54
59
  async function deleteMedia(mediaId) {
55
- const response = await this.rest({
56
- method: 'DELETE',
57
- path: `/wp/v2/media/${mediaId}`,
58
- params: { force: true },
59
- });
60
- return response;
60
+ const response = await this.rest({
61
+ method: "DELETE",
62
+ path: `/wp/v2/media/${mediaId}`,
63
+ params: { force: true }
64
+ });
65
+ return response;
61
66
  }
62
- /**
63
- * delete all media files.
64
- *
65
- * @param this
66
- */
67
67
  async function deleteAllMedia() {
68
- const files = await this.listMedia();
69
- // The media endpoint doesn't support batch request yet.
70
- const responses = await Promise.all(files.map((media) => this.deleteMedia(media.id)));
71
- return responses;
68
+ const files = await this.listMedia();
69
+ const responses = await Promise.all(
70
+ files.map((media) => this.deleteMedia(media.id))
71
+ );
72
+ return responses;
72
73
  }
73
- //# sourceMappingURL=media.js.map
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ deleteAllMedia,
77
+ deleteMedia,
78
+ listMedia,
79
+ uploadMedia
80
+ });
81
+ //# sourceMappingURL=media.js.map