@caido/sdk-frontend 0.39.0 → 0.40.1-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-frontend",
3
- "version": "0.39.0",
3
+ "version": "0.40.1-beta.0",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -9,5 +9,7 @@
9
9
  "module": "./src/index.js",
10
10
  "files": [
11
11
  "src/*"
12
- ]
12
+ ],
13
+ "peerDependencies": {},
14
+ "peerDependenciesMeta": {}
13
15
  }
@@ -82,6 +82,10 @@ export type Scalars = {
82
82
  input: JSONValue;
83
83
  output: JSONValue;
84
84
  };
85
+ JsonRaw: {
86
+ input: string;
87
+ output: string;
88
+ };
85
89
  Port: {
86
90
  input: number;
87
91
  output: number;
@@ -785,6 +789,11 @@ export type CreatedInterceptMessagePayload = {
785
789
  messageEdge: InterceptMessageEdge;
786
790
  snapshot: Scalars["Snapshot"]["output"];
787
791
  };
792
+ export type CreatedPluginEventPayload = {
793
+ eventArgs: Array<Scalars["JsonRaw"]["output"]>;
794
+ eventName: Scalars["String"]["output"];
795
+ pluginId: Scalars["ID"]["output"];
796
+ };
788
797
  export type CreatedPluginPackagePayload = {
789
798
  package: PluginPackage;
790
799
  };
@@ -2627,7 +2636,7 @@ export type StartExportRequestsTaskPayload = {
2627
2636
  task?: Maybe<DataExportTask>;
2628
2637
  };
2629
2638
  export type StartExportRequestsTaskPayloadError = OtherUserError | PermissionDeniedUserError;
2630
- export type StartReplayTaskError = OtherUserError | TaskInProgressUserError;
2639
+ export type StartReplayTaskError = OtherUserError | PermissionDeniedUserError | TaskInProgressUserError;
2631
2640
  export type StartReplayTaskInput = {
2632
2641
  connection: ConnectionInfoInput;
2633
2642
  raw: Scalars["Blob"]["input"];
@@ -2758,6 +2767,7 @@ export type SubscriptionRoot = {
2758
2767
  createdFinding: CreatedFindingPayload;
2759
2768
  createdInterceptEntry: CreatedInterceptEntryPayload;
2760
2769
  createdInterceptMessage: CreatedInterceptMessagePayload;
2770
+ createdPluginEvent: CreatedPluginEventPayload;
2761
2771
  createdPluginPackage: CreatedPluginPackagePayload;
2762
2772
  createdProject: CreatedProjectPayload;
2763
2773
  createdReplaySession: CreatedReplaySessionPayload;
@@ -8217,6 +8227,10 @@ export type StartReplayTaskMutation = {
8217
8227
  error?: {
8218
8228
  __typename: "OtherUserError";
8219
8229
  code: string;
8230
+ } | {
8231
+ __typename: "PermissionDeniedUserError";
8232
+ code: string;
8233
+ permissionDeniedReason: PermissionDeniedErrorReason;
8220
8234
  } | {
8221
8235
  __typename: "TaskInProgressUserError";
8222
8236
  taskId: string;
@@ -12803,6 +12817,16 @@ export type UpdatedPluginSubscription = {
12803
12817
  };
12804
12818
  };
12805
12819
  };
12820
+ export type CreatedPluginEventSubscriptionVariables = Exact<{
12821
+ [key: string]: never;
12822
+ }>;
12823
+ export type CreatedPluginEventSubscription = {
12824
+ createdPluginEvent: {
12825
+ pluginId: string;
12826
+ eventArgs: Array<string>;
12827
+ eventName: string;
12828
+ };
12829
+ };
12806
12830
  export type CreatedProjectSubscriptionVariables = Exact<{
12807
12831
  [key: string]: never;
12808
12832
  }>;
@@ -13707,7 +13731,7 @@ export declare const SetActiveReplaySessionEntryDocument = "\n mutation setAc
13707
13731
  export declare const DeleteReplaySessionsDocument = "\n mutation deleteReplaySessions($ids: [ID!]!) {\n deleteReplaySessions(ids: $ids) {\n deletedIds\n }\n}\n ";
13708
13732
  export declare const CreateReplaySessionDocument = "\n mutation createReplaySession($input: CreateReplaySessionInput!) {\n createReplaySession(input: $input) {\n session {\n ...replaySessionMeta\n collection {\n ...replaySessionCollectionMeta\n }\n }\n }\n}\n \n fragment replaySessionMeta on ReplaySession {\n __typename\n id\n name\n activeEntry {\n ...replayEntryMeta\n }\n collection {\n id\n }\n entries {\n nodes {\n ...replayEntryMeta\n }\n pageInfo {\n ...pageInfoFull\n }\n count {\n ...countFull\n }\n }\n}\n \n\n fragment replayEntryMeta on ReplayEntry {\n __typename\n id\n error\n connection {\n ...connectionInfoFull\n }\n session {\n id\n }\n request {\n ...requestMeta\n }\n}\n \n\n fragment connectionInfoFull on ConnectionInfo {\n __typename\n host\n port\n isTls\n}\n \n\n fragment requestMeta on Request {\n __typename\n id\n host\n port\n path\n query\n method\n edited\n isTls\n length\n alteration\n metadata {\n ...requestMetadataFull\n }\n fileExtension\n source\n createdAt\n response {\n ...responseMeta\n }\n}\n \n\n fragment requestMetadataFull on RequestMetadata {\n __typename\n id\n color\n}\n \n\n fragment responseMeta on Response {\n __typename\n id\n statusCode\n roundtripTime\n length\n createdAt\n alteration\n edited\n}\n \n\n fragment pageInfoFull on PageInfo {\n __typename\n hasPreviousPage\n hasNextPage\n startCursor\n endCursor\n}\n \n\n fragment countFull on Count {\n __typename\n value\n snapshot\n}\n \n\n fragment replaySessionCollectionMeta on ReplaySessionCollection {\n __typename\n id\n name\n sessions {\n ...replaySessionMeta\n }\n}\n ";
13709
13733
  export declare const MoveReplaySessionDocument = "\n mutation moveReplaySession($id: ID!, $collectionId: ID!) {\n moveReplaySession(collectionId: $collectionId, id: $id) {\n session {\n ...replaySessionMeta\n }\n }\n}\n \n fragment replaySessionMeta on ReplaySession {\n __typename\n id\n name\n activeEntry {\n ...replayEntryMeta\n }\n collection {\n id\n }\n entries {\n nodes {\n ...replayEntryMeta\n }\n pageInfo {\n ...pageInfoFull\n }\n count {\n ...countFull\n }\n }\n}\n \n\n fragment replayEntryMeta on ReplayEntry {\n __typename\n id\n error\n connection {\n ...connectionInfoFull\n }\n session {\n id\n }\n request {\n ...requestMeta\n }\n}\n \n\n fragment connectionInfoFull on ConnectionInfo {\n __typename\n host\n port\n isTls\n}\n \n\n fragment requestMeta on Request {\n __typename\n id\n host\n port\n path\n query\n method\n edited\n isTls\n length\n alteration\n metadata {\n ...requestMetadataFull\n }\n fileExtension\n source\n createdAt\n response {\n ...responseMeta\n }\n}\n \n\n fragment requestMetadataFull on RequestMetadata {\n __typename\n id\n color\n}\n \n\n fragment responseMeta on Response {\n __typename\n id\n statusCode\n roundtripTime\n length\n createdAt\n alteration\n edited\n}\n \n\n fragment pageInfoFull on PageInfo {\n __typename\n hasPreviousPage\n hasNextPage\n startCursor\n endCursor\n}\n \n\n fragment countFull on Count {\n __typename\n value\n snapshot\n}\n ";
13710
- export declare const StartReplayTaskDocument = "\n mutation startReplayTask($sessionId: ID!, $input: StartReplayTaskInput!) {\n startReplayTask(sessionId: $sessionId, input: $input) {\n task {\n ...replayTaskMeta\n }\n error {\n ... on TaskInProgressUserError {\n ...taskInProgressUserErrorFull\n }\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n }\n }\n}\n \n fragment replayTaskMeta on ReplayTask {\n ...taskMeta\n replayEntry {\n ...replayEntryMeta\n }\n}\n \n\n fragment taskMeta on Task {\n __typename\n id\n createdAt\n}\n \n\n fragment replayEntryMeta on ReplayEntry {\n __typename\n id\n error\n connection {\n ...connectionInfoFull\n }\n session {\n id\n }\n request {\n ...requestMeta\n }\n}\n \n\n fragment connectionInfoFull on ConnectionInfo {\n __typename\n host\n port\n isTls\n}\n \n\n fragment requestMeta on Request {\n __typename\n id\n host\n port\n path\n query\n method\n edited\n isTls\n length\n alteration\n metadata {\n ...requestMetadataFull\n }\n fileExtension\n source\n createdAt\n response {\n ...responseMeta\n }\n}\n \n\n fragment requestMetadataFull on RequestMetadata {\n __typename\n id\n color\n}\n \n\n fragment responseMeta on Response {\n __typename\n id\n statusCode\n roundtripTime\n length\n createdAt\n alteration\n edited\n}\n \n\n fragment taskInProgressUserErrorFull on TaskInProgressUserError {\n ...userErrorFull\n taskId\n}\n \n\n fragment userErrorFull on UserError {\n __typename\n code\n}\n \n\n fragment otherUserErrorFull on OtherUserError {\n ...userErrorFull\n}\n ";
13734
+ export declare const StartReplayTaskDocument = "\n mutation startReplayTask($sessionId: ID!, $input: StartReplayTaskInput!) {\n startReplayTask(sessionId: $sessionId, input: $input) {\n task {\n ...replayTaskMeta\n }\n error {\n ... on TaskInProgressUserError {\n ...taskInProgressUserErrorFull\n }\n ... on PermissionDeniedUserError {\n ...permissionDeniedUserErrorFull\n }\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n }\n }\n}\n \n fragment replayTaskMeta on ReplayTask {\n ...taskMeta\n replayEntry {\n ...replayEntryMeta\n }\n}\n \n\n fragment taskMeta on Task {\n __typename\n id\n createdAt\n}\n \n\n fragment replayEntryMeta on ReplayEntry {\n __typename\n id\n error\n connection {\n ...connectionInfoFull\n }\n session {\n id\n }\n request {\n ...requestMeta\n }\n}\n \n\n fragment connectionInfoFull on ConnectionInfo {\n __typename\n host\n port\n isTls\n}\n \n\n fragment requestMeta on Request {\n __typename\n id\n host\n port\n path\n query\n method\n edited\n isTls\n length\n alteration\n metadata {\n ...requestMetadataFull\n }\n fileExtension\n source\n createdAt\n response {\n ...responseMeta\n }\n}\n \n\n fragment requestMetadataFull on RequestMetadata {\n __typename\n id\n color\n}\n \n\n fragment responseMeta on Response {\n __typename\n id\n statusCode\n roundtripTime\n length\n createdAt\n alteration\n edited\n}\n \n\n fragment taskInProgressUserErrorFull on TaskInProgressUserError {\n ...userErrorFull\n taskId\n}\n \n\n fragment userErrorFull on UserError {\n __typename\n code\n}\n \n\n fragment permissionDeniedUserErrorFull on PermissionDeniedUserError {\n ...userErrorFull\n permissionDeniedReason: reason\n}\n \n\n fragment otherUserErrorFull on OtherUserError {\n ...userErrorFull\n}\n ";
13711
13735
  export declare const UpdateRequestMetadataDocument = "\n mutation updateRequestMetadata($id: ID!, $input: UpdateRequestMetadataInput!) {\n updateRequestMetadata(id: $id, input: $input) {\n snapshot\n metadata {\n ...requestMetadataFull\n }\n }\n}\n \n fragment requestMetadataFull on RequestMetadata {\n __typename\n id\n color\n}\n ";
13712
13736
  export declare const StartExportRequestsTaskDocument = "\n mutation startExportRequestsTask($input: StartExportRequestsTaskInput!) {\n startExportRequestsTask(input: $input) {\n task {\n ...dataExportTaskMeta\n }\n error {\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n ... on PermissionDeniedUserError {\n ...permissionDeniedUserErrorFull\n }\n }\n }\n}\n \n fragment dataExportTaskMeta on DataExportTask {\n ...dataExportTaskMetaFields\n}\n \n\n fragment dataExportTaskMetaFields on DataExportTask {\n __typename\n id\n export {\n ...dataExportMeta\n }\n}\n \n\n fragment dataExportMeta on DataExport {\n ...dataExportMetaFields\n}\n \n\n fragment dataExportMetaFields on DataExport {\n __typename\n id\n name\n path\n size\n status\n format\n error\n createdAt\n}\n \n\n fragment otherUserErrorFull on OtherUserError {\n ...userErrorFull\n}\n \n\n fragment userErrorFull on UserError {\n __typename\n code\n}\n \n\n fragment permissionDeniedUserErrorFull on PermissionDeniedUserError {\n ...userErrorFull\n permissionDeniedReason: reason\n}\n ";
13713
13737
  export declare const RenderRequestDocument = "\n mutation renderRequest($id: ID!, $input: RenderRequestInput!) {\n renderRequest(id: $id, input: $input) {\n render\n error {\n ... on RenderFailedUserError {\n ...renderFailedUserErrorFull\n }\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n }\n }\n}\n \n fragment renderFailedUserErrorFull on RenderFailedUserError {\n ...userErrorFull\n reason\n}\n \n\n fragment userErrorFull on UserError {\n __typename\n code\n}\n \n\n fragment otherUserErrorFull on OtherUserError {\n ...userErrorFull\n}\n ";
@@ -13849,6 +13873,7 @@ export declare const UpdatedInterceptOptionsDocument = "\n subscription updat
13849
13873
  export declare const CreatedPluginPackageDocument = "\n subscription createdPluginPackage {\n createdPluginPackage {\n package {\n ...pluginPackageFull\n }\n }\n}\n \n fragment pluginPackageFull on PluginPackage {\n ...pluginPackageMeta\n plugins {\n ... on PluginFrontend {\n ...pluginFrontendFull\n }\n ... on PluginBackend {\n ...pluginBackendFull\n }\n }\n}\n \n\n fragment pluginPackageMeta on PluginPackage {\n id\n name\n description\n author {\n ...pluginAuthorFull\n }\n version\n installedAt\n manifestId\n}\n \n\n fragment pluginAuthorFull on PluginAuthor {\n name\n email\n url\n}\n \n\n fragment pluginFrontendFull on PluginFrontend {\n ...pluginMeta\n entrypoint\n style\n data\n backend {\n ...pluginBackendMeta\n }\n}\n \n\n fragment pluginMeta on Plugin {\n __typename\n id\n name\n enabled\n manifestId\n package {\n id\n }\n}\n \n\n fragment pluginBackendMeta on PluginBackend {\n __typename\n id\n}\n \n\n fragment pluginBackendFull on PluginBackend {\n ...pluginMeta\n runtime\n state {\n error\n running\n }\n}\n ";
13850
13874
  export declare const DeletedPluginPackageDocument = "\n subscription deletedPluginPackage {\n deletedPluginPackage {\n deletedPackageId\n }\n}\n ";
13851
13875
  export declare const UpdatedPluginDocument = "\n subscription updatedPlugin {\n updatedPlugin {\n plugin {\n ... on PluginFrontend {\n ...pluginFrontendFull\n }\n ... on PluginBackend {\n ...pluginBackendFull\n }\n }\n }\n}\n \n fragment pluginFrontendFull on PluginFrontend {\n ...pluginMeta\n entrypoint\n style\n data\n backend {\n ...pluginBackendMeta\n }\n}\n \n\n fragment pluginMeta on Plugin {\n __typename\n id\n name\n enabled\n manifestId\n package {\n id\n }\n}\n \n\n fragment pluginBackendMeta on PluginBackend {\n __typename\n id\n}\n \n\n fragment pluginBackendFull on PluginBackend {\n ...pluginMeta\n runtime\n state {\n error\n running\n }\n}\n ";
13876
+ export declare const CreatedPluginEventDocument = "\n subscription createdPluginEvent {\n createdPluginEvent {\n pluginId\n eventArgs\n eventName\n }\n}\n ";
13852
13877
  export declare const CreatedProjectDocument = "\n subscription createdProject {\n createdProject {\n project {\n ...projectFull\n }\n }\n}\n \n fragment projectFull on Project {\n __typename\n id\n name\n path\n version\n status\n size\n createdAt\n updatedAt\n backups {\n id\n }\n}\n ";
13853
13878
  export declare const UpdatedProjectDocument = "\n subscription updatedProject {\n updatedProject {\n project {\n ...projectFull\n }\n }\n}\n \n fragment projectFull on Project {\n __typename\n id\n name\n path\n version\n status\n size\n createdAt\n updatedAt\n backups {\n id\n }\n}\n ";
13854
13879
  export declare const DeletedProjectDocument = "\n subscription deletedProject {\n deletedProject {\n deletedProjectId\n }\n}\n ";
@@ -14078,6 +14103,7 @@ export declare function getSdk<C>(requester: Requester<C>): {
14078
14103
  createdPluginPackage(variables?: CreatedPluginPackageSubscriptionVariables, options?: C): AsyncIterable<CreatedPluginPackageSubscription>;
14079
14104
  deletedPluginPackage(variables?: DeletedPluginPackageSubscriptionVariables, options?: C): AsyncIterable<DeletedPluginPackageSubscription>;
14080
14105
  updatedPlugin(variables?: UpdatedPluginSubscriptionVariables, options?: C): AsyncIterable<UpdatedPluginSubscription>;
14106
+ createdPluginEvent(variables?: CreatedPluginEventSubscriptionVariables, options?: C): AsyncIterable<CreatedPluginEventSubscription>;
14081
14107
  createdProject(variables?: CreatedProjectSubscriptionVariables, options?: C): AsyncIterable<CreatedProjectSubscription>;
14082
14108
  updatedProject(variables?: UpdatedProjectSubscriptionVariables, options?: C): AsyncIterable<UpdatedProjectSubscription>;
14083
14109
  deletedProject(variables?: DeletedProjectSubscriptionVariables, options?: C): AsyncIterable<DeletedProjectSubscription>;
@@ -1,4 +1,20 @@
1
- export type BackendAPI = Record<string, (...args: any[]) => any>;
2
- export type ToBackendRPC<T extends BackendAPI> = {
3
- [K in keyof T]: (...args: Parameters<T[K]>) => ReturnType<T[K]> extends Promise<infer U> ? Promise<U> : Promise<ReturnType<T[K]>>;
1
+ import type { PromisifiedReturnType } from "./utils";
2
+ export type BackendEndpoints = {
3
+ [key: string]: (...args: any[]) => any;
4
+ };
5
+ export type BackendEvents = {
6
+ [key: string]: (...args: any[]) => void;
7
+ };
8
+ export type ToBackendRPC<T extends BackendEndpoints, E extends BackendEvents> = {
9
+ [K in keyof T]: (...args: Parameters<T[K]>) => PromisifiedReturnType<T[K]>;
10
+ } & {
11
+ /**
12
+ * Subscribe to a backend event.
13
+ * @param event The event to subscribe to.
14
+ * @param callback The callback to call when the event is emitted.
15
+ * @returns An object with a `stop` method that can be called to stop listening to the event.
16
+ */
17
+ onEvent: <K extends keyof E>(event: K, callback: E[K]) => {
18
+ stop: () => void;
19
+ };
4
20
  };
@@ -1,5 +1,5 @@
1
1
  import type { Sdk } from "./__generated__/graphql-sdk";
2
- import type { BackendAPI, ToBackendRPC } from "./backend";
2
+ import type { BackendEndpoints, BackendEvents, ToBackendRPC } from "./backend";
3
3
  import type { Commands } from "./commands";
4
4
  import type { Findings } from "./findings";
5
5
  import type { Menu } from "./menu";
@@ -9,9 +9,9 @@ import type { Storage } from "./storage";
9
9
  import type { UI } from "./ui";
10
10
  import type { Window } from "./window";
11
11
  export type { CommandContext } from "./commands";
12
- export type API<T extends BackendAPI = Record<string, never>> = {
12
+ export type API<T extends BackendEndpoints = Record<string, never>, E extends BackendEvents = Record<string, never>> = {
13
13
  ui: UI;
14
- backend: ToBackendRPC<T>;
14
+ backend: ToBackendRPC<T, E>;
15
15
  scopes: Scopes;
16
16
  findings: Findings;
17
17
  commands: Commands;
@@ -6,4 +6,5 @@ type NotAssignableToJson = bigint | symbol | Function;
6
6
  export type JSONCompatible<T> = unknown extends T ? never : {
7
7
  [P in keyof T]: T[P] extends JSONValue ? T[P] : T[P] extends NotAssignableToJson ? never : JSONCompatible<T[P]>;
8
8
  };
9
+ export type PromisifiedReturnType<T extends (...args: unknown[]) => unknown> = ReturnType<T> extends Promise<infer U> ? Promise<U> : Promise<ReturnType<T>>;
9
10
  export {};