protocol-parser.d.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * Copyright 2022 Google LLC.
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /**
  18. * @fileoverview Provides parsing and validator for WebDriver BiDi protocol.
  19. * Parser types should match the `../protocol` types.
  20. */
  21. import { z, type ZodType } from 'zod';
  22. import type * as Protocol from '../protocol/protocol.js';
  23. export declare function parseObject<T extends ZodType>(obj: unknown, schema: T): z.infer<T>;
  24. /** @see https://w3c.github.io/webdriver-bidi/#module-browser */
  25. export declare namespace Browser {
  26. function parseRemoveUserContextParams(params: unknown): Protocol.Browser.RemoveUserContextParameters;
  27. }
  28. /** @see https://w3c.github.io/webdriver-bidi/#module-network */
  29. export declare namespace Network {
  30. function parseAddInterceptParameters(params: unknown): Protocol.Network.AddInterceptParameters;
  31. function parseContinueRequestParameters(params: unknown): {
  32. request: string;
  33. body?: {
  34. type: "string";
  35. value: string;
  36. } | {
  37. type: "base64";
  38. value: string;
  39. } | undefined;
  40. cookies?: {
  41. value: {
  42. type: "string";
  43. value: string;
  44. } | {
  45. type: "base64";
  46. value: string;
  47. };
  48. name: string;
  49. }[] | undefined;
  50. headers?: {
  51. value: {
  52. type: "string";
  53. value: string;
  54. } | {
  55. type: "base64";
  56. value: string;
  57. };
  58. name: string;
  59. }[] | undefined;
  60. method?: string | undefined;
  61. url?: string | undefined;
  62. };
  63. function parseContinueResponseParameters(params: unknown): Protocol.Network.ContinueResponseParameters;
  64. function parseContinueWithAuthParameters(params: unknown): {
  65. request: string;
  66. } & ({
  67. credentials: {
  68. type: "password";
  69. password: string;
  70. username: string;
  71. };
  72. action: "provideCredentials";
  73. } | {
  74. action: "default" | "cancel";
  75. });
  76. function parseFailRequestParameters(params: unknown): {
  77. request: string;
  78. };
  79. function parseProvideResponseParameters(params: unknown): Protocol.Network.ProvideResponseParameters;
  80. function parseRemoveInterceptParameters(params: unknown): {
  81. intercept: string;
  82. };
  83. }
  84. /** @see https://w3c.github.io/webdriver-bidi/#module-script */
  85. export declare namespace Script {
  86. function parseGetRealmsParams(params: unknown): Protocol.Script.GetRealmsParameters;
  87. function parseEvaluateParams(params: unknown): Protocol.Script.EvaluateParameters;
  88. function parseDisownParams(params: unknown): Protocol.Script.DisownParameters;
  89. function parseAddPreloadScriptParams(params: unknown): Protocol.Script.AddPreloadScriptParameters;
  90. function parseRemovePreloadScriptParams(params: unknown): {
  91. script: string;
  92. };
  93. function parseCallFunctionParams(params: unknown): Protocol.Script.CallFunctionParameters;
  94. }
  95. /** @see https://w3c.github.io/webdriver-bidi/#module-browsingContext */
  96. export declare namespace BrowsingContext {
  97. function parseActivateParams(params: unknown): {
  98. context: string;
  99. };
  100. function parseGetTreeParams(params: unknown): Protocol.BrowsingContext.GetTreeParameters;
  101. function parseNavigateParams(params: unknown): Protocol.BrowsingContext.NavigateParameters;
  102. function parseReloadParams(params: unknown): Protocol.BrowsingContext.ReloadParameters;
  103. function parseCreateParams(params: unknown): Protocol.BrowsingContext.CreateParameters;
  104. function parseCloseParams(params: unknown): Protocol.BrowsingContext.CloseParameters;
  105. function parseCaptureScreenshotParams(params: unknown): Protocol.BrowsingContext.CaptureScreenshotParameters;
  106. function parsePrintParams(params: unknown): Protocol.BrowsingContext.PrintParameters;
  107. function parseSetViewportParams(params: unknown): Protocol.BrowsingContext.SetViewportParameters;
  108. function parseTraverseHistoryParams(params: unknown): Protocol.BrowsingContext.TraverseHistoryParameters;
  109. function parseHandleUserPromptParameters(params: unknown): Protocol.BrowsingContext.HandleUserPromptParameters;
  110. function parseLocateNodesParams(params: unknown): Protocol.BrowsingContext.LocateNodesParameters;
  111. }
  112. /** @see https://w3c.github.io/webdriver-bidi/#module-session */
  113. export declare namespace Session {
  114. function parseSubscribeParams(params: unknown): Protocol.Session.SubscriptionRequest;
  115. }
  116. export declare namespace Input {
  117. function parsePerformActionsParams(params: unknown): Protocol.Input.PerformActionsParameters;
  118. function parseReleaseActionsParams(params: unknown): Protocol.Input.ReleaseActionsParameters;
  119. function parseSetFilesParams(params: unknown): Protocol.Input.SetFilesParameters;
  120. }
  121. export declare namespace Storage {
  122. function parseGetCookiesParams(params: unknown): Protocol.Storage.GetCookiesParameters;
  123. function parseSetCookieParams(params: unknown): Protocol.Storage.SetCookieParameters;
  124. function parseDeleteCookiesParams(params: unknown): Protocol.Storage.DeleteCookiesParameters;
  125. }
  126. export declare namespace Cdp {
  127. function parseSendCommandRequest(params: unknown): Protocol.Cdp.SendCommandParameters;
  128. function parseGetSessionRequest(params: unknown): Protocol.Cdp.GetSessionParameters;
  129. function parseResolveRealmRequest(params: unknown): Protocol.Cdp.ResolveRealmParameters;
  130. }
  131. export declare namespace Permissions {
  132. function parseSetPermissionsParams(params: unknown): Protocol.Permissions.SetPermissionParameters;
  133. }