@caido/sdk-frontend 0.58.3-beta.0 → 0.58.3-beta.1

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.58.3-beta.0",
3
+ "version": "0.58.3-beta.1",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "repository": "https://github.com/caido/sdk-js/",
@@ -20628,6 +20628,110 @@ export type CreatedPluginEventSubscription = {
20628
20628
  eventName: string;
20629
20629
  };
20630
20630
  };
20631
+ export type PluginPackageDataFullFragment = {
20632
+ key: string;
20633
+ value?: unknown | undefined | null;
20634
+ flags: {
20635
+ exportable: boolean;
20636
+ };
20637
+ package: {
20638
+ id: string;
20639
+ };
20640
+ };
20641
+ export type PluginPackageDataQueryVariables = Exact<{
20642
+ id: Scalars["ID"]["input"];
20643
+ key: Scalars["String"]["input"];
20644
+ }>;
20645
+ export type PluginPackageDataQuery = {
20646
+ pluginPackageData?: {
20647
+ key: string;
20648
+ value?: unknown | undefined | null;
20649
+ flags: {
20650
+ exportable: boolean;
20651
+ };
20652
+ package: {
20653
+ id: string;
20654
+ };
20655
+ } | undefined | null;
20656
+ };
20657
+ export type DefinePluginPackageDataMutationVariables = Exact<{
20658
+ id: Scalars["ID"]["input"];
20659
+ input: DefinePluginPackageDataInput;
20660
+ }>;
20661
+ export type DefinePluginPackageDataMutation = {
20662
+ definePluginPackageData: {
20663
+ success: boolean;
20664
+ error?: {
20665
+ __typename: "OtherUserError";
20666
+ code: string;
20667
+ } | {
20668
+ __typename: "UnknownIdUserError";
20669
+ id: string;
20670
+ code: string;
20671
+ } | undefined | null;
20672
+ };
20673
+ };
20674
+ export type SetPluginPackageDataMutationVariables = Exact<{
20675
+ id: Scalars["ID"]["input"];
20676
+ key: Scalars["String"]["input"];
20677
+ data: Scalars["JSON"]["input"];
20678
+ }>;
20679
+ export type SetPluginPackageDataMutation = {
20680
+ setPluginPackageData: {
20681
+ success: boolean;
20682
+ error?: {
20683
+ __typename: "OtherUserError";
20684
+ code: string;
20685
+ } | {
20686
+ __typename: "UnknownIdUserError";
20687
+ id: string;
20688
+ code: string;
20689
+ } | undefined | null;
20690
+ };
20691
+ };
20692
+ export type DeletePluginPackageDataMutationVariables = Exact<{
20693
+ id: Scalars["ID"]["input"];
20694
+ key: Scalars["String"]["input"];
20695
+ }>;
20696
+ export type DeletePluginPackageDataMutation = {
20697
+ deletePluginPackageData: {
20698
+ success: boolean;
20699
+ error?: {
20700
+ __typename: "OtherUserError";
20701
+ code: string;
20702
+ } | {
20703
+ __typename: "UnknownIdUserError";
20704
+ id: string;
20705
+ code: string;
20706
+ } | undefined | null;
20707
+ };
20708
+ };
20709
+ export type UpdatedPluginPackageDataSubscriptionVariables = Exact<{
20710
+ [key: string]: never;
20711
+ }>;
20712
+ export type UpdatedPluginPackageDataSubscription = {
20713
+ updatedPluginPackageData: {
20714
+ packageData: {
20715
+ key: string;
20716
+ value?: unknown | undefined | null;
20717
+ flags: {
20718
+ exportable: boolean;
20719
+ };
20720
+ package: {
20721
+ id: string;
20722
+ };
20723
+ };
20724
+ };
20725
+ };
20726
+ export type DeletedPluginPackageDataSubscriptionVariables = Exact<{
20727
+ [key: string]: never;
20728
+ }>;
20729
+ export type DeletedPluginPackageDataSubscription = {
20730
+ deletedPluginPackageData: {
20731
+ packageId: string;
20732
+ key: string;
20733
+ };
20734
+ };
20631
20735
  export type ProjectFullFragment = {
20632
20736
  __typename: "Project";
20633
20737
  id: string;
@@ -123882,6 +123986,7 @@ export declare const WorkflowMetaFragmentDoc = "\n fragment workflowMeta on W
123882
123986
  export declare const PluginWorkflowFullFragmentDoc = "\n fragment pluginWorkflowFull on PluginWorkflow {\n ...pluginMeta\n name\n workflow {\n ...workflowMeta\n }\n}\n ";
123883
123987
  export declare const PluginPackageFullFragmentDoc = "\n fragment pluginPackageFull on PluginPackage {\n ...pluginPackageMeta\n plugins {\n ... on PluginFrontend {\n ...pluginFrontendFull\n }\n ... on PluginBackend {\n ...pluginBackendFull\n }\n ... on PluginWorkflow {\n ...pluginWorkflowFull\n }\n }\n}\n ";
123884
123988
  export declare const StorePluginPackageFullFragmentDoc = "\n fragment storePluginPackageFull on StorePluginPackage {\n author {\n email\n name\n url\n }\n description\n downloads\n license\n manifestId\n name\n repository\n version\n official\n quality\n readmeUrl\n changelogUrl\n}\n ";
123989
+ export declare const PluginPackageDataFullFragmentDoc = "\n fragment pluginPackageDataFull on PluginPackageData {\n key\n value\n flags {\n exportable\n }\n package {\n id\n }\n}\n ";
123885
123990
  export declare const ProjectConfigStreamFullFragmentDoc = "\n fragment projectConfigStreamFull on ProjectConfigStream {\n stripExtension\n}\n ";
123886
123991
  export declare const ProjectConfigFullFragmentDoc = "\n fragment projectConfigFull on ProjectConfig {\n stream {\n ...projectConfigStreamFull\n }\n}\n ";
123887
123992
  export declare const CurrentProjectFullFragmentDoc = "\n fragment currentProjectFull on CurrentProject {\n project {\n ...projectFull\n }\n config {\n ...projectConfigFull\n }\n}\n ";
@@ -124144,6 +124249,12 @@ export declare const CreatedPluginPackageDocument = "\n subscription createdP
124144
124249
  export declare const DeletedPluginPackageDocument = "\n subscription deletedPluginPackage {\n deletedPluginPackage {\n deletedPackageId\n }\n}\n ";
124145
124250
  export declare const UpdatedPluginDocument = "\n subscription updatedPlugin {\n updatedPlugin {\n plugin {\n ... on PluginFrontend {\n ...pluginFrontendFull\n }\n ... on PluginBackend {\n ...pluginBackendFull\n }\n ... on PluginWorkflow {\n ...pluginWorkflowFull\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 \n\n fragment pluginWorkflowFull on PluginWorkflow {\n ...pluginMeta\n name\n workflow {\n ...workflowMeta\n }\n}\n \n\n fragment workflowMeta on Workflow {\n __typename\n id\n kind\n name\n enabled\n global\n readOnly\n}\n ";
124146
124251
  export declare const CreatedPluginEventDocument = "\n subscription createdPluginEvent {\n createdPluginEvent {\n pluginId\n eventArgs\n eventName\n }\n}\n ";
124252
+ export declare const PluginPackageDataDocument = "\n query pluginPackageData($id: ID!, $key: String!) {\n pluginPackageData(id: $id, key: $key) {\n ...pluginPackageDataFull\n }\n}\n \n fragment pluginPackageDataFull on PluginPackageData {\n key\n value\n flags {\n exportable\n }\n package {\n id\n }\n}\n ";
124253
+ export declare const DefinePluginPackageDataDocument = "\n mutation definePluginPackageData($id: ID!, $input: DefinePluginPackageDataInput!) {\n definePluginPackageData(id: $id, input: $input) {\n success\n error {\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n ... on UnknownIdUserError {\n ...unknownIdUserErrorFull\n }\n }\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 unknownIdUserErrorFull on UnknownIdUserError {\n ...userErrorFull\n id\n}\n ";
124254
+ export declare const SetPluginPackageDataDocument = "\n mutation setPluginPackageData($id: ID!, $key: String!, $data: JSON!) {\n setPluginPackageData(id: $id, key: $key, data: $data) {\n success\n error {\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n ... on UnknownIdUserError {\n ...unknownIdUserErrorFull\n }\n }\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 unknownIdUserErrorFull on UnknownIdUserError {\n ...userErrorFull\n id\n}\n ";
124255
+ export declare const DeletePluginPackageDataDocument = "\n mutation deletePluginPackageData($id: ID!, $key: String!) {\n deletePluginPackageData(id: $id, key: $key) {\n success\n error {\n ... on OtherUserError {\n ...otherUserErrorFull\n }\n ... on UnknownIdUserError {\n ...unknownIdUserErrorFull\n }\n }\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 unknownIdUserErrorFull on UnknownIdUserError {\n ...userErrorFull\n id\n}\n ";
124256
+ export declare const UpdatedPluginPackageDataDocument = "\n subscription updatedPluginPackageData {\n updatedPluginPackageData {\n packageData {\n ...pluginPackageDataFull\n }\n }\n}\n \n fragment pluginPackageDataFull on PluginPackageData {\n key\n value\n flags {\n exportable\n }\n package {\n id\n }\n}\n ";
124257
+ export declare const DeletedPluginPackageDataDocument = "\n subscription deletedPluginPackageData {\n deletedPluginPackageData {\n packageId\n key\n }\n}\n ";
124147
124258
  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 temporary\n size\n createdAt\n updatedAt\n readOnly\n backups {\n id\n }\n}\n ";
124148
124259
  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 temporary\n size\n createdAt\n updatedAt\n readOnly\n backups {\n id\n }\n}\n ";
124149
124260
  export declare const DeletedProjectDocument = "\n subscription deletedProject {\n deletedProject {\n deletedProjectId\n }\n}\n ";
@@ -124503,6 +124614,12 @@ export declare function getSdk<C>(requester: Requester<C>): {
124503
124614
  deletedPluginPackage(variables?: DeletedPluginPackageSubscriptionVariables, options?: C): AsyncIterable<DeletedPluginPackageSubscription>;
124504
124615
  updatedPlugin(variables?: UpdatedPluginSubscriptionVariables, options?: C): AsyncIterable<UpdatedPluginSubscription>;
124505
124616
  createdPluginEvent(variables?: CreatedPluginEventSubscriptionVariables, options?: C): AsyncIterable<CreatedPluginEventSubscription>;
124617
+ pluginPackageData(variables: PluginPackageDataQueryVariables, options?: C): Promise<PluginPackageDataQuery>;
124618
+ definePluginPackageData(variables: DefinePluginPackageDataMutationVariables, options?: C): Promise<DefinePluginPackageDataMutation>;
124619
+ setPluginPackageData(variables: SetPluginPackageDataMutationVariables, options?: C): Promise<SetPluginPackageDataMutation>;
124620
+ deletePluginPackageData(variables: DeletePluginPackageDataMutationVariables, options?: C): Promise<DeletePluginPackageDataMutation>;
124621
+ updatedPluginPackageData(variables?: UpdatedPluginPackageDataSubscriptionVariables, options?: C): AsyncIterable<UpdatedPluginPackageDataSubscription>;
124622
+ deletedPluginPackageData(variables?: DeletedPluginPackageDataSubscriptionVariables, options?: C): AsyncIterable<DeletedPluginPackageDataSubscription>;
124506
124623
  createdProject(variables?: CreatedProjectSubscriptionVariables, options?: C): AsyncIterable<CreatedProjectSubscription>;
124507
124624
  updatedProject(variables?: UpdatedProjectSubscriptionVariables, options?: C): AsyncIterable<UpdatedProjectSubscription>;
124508
124625
  deletedProject(variables?: DeletedProjectSubscriptionVariables, options?: C): AsyncIterable<DeletedProjectSubscription>;
@@ -15,6 +15,7 @@ export type { HostedFile } from "./types/files";
15
15
  export { FilterSlot, type Filter, type FilterSlotContent, type CurrentFilterChangeEvent, } from "./types/filter";
16
16
  export type { HTTPQL, StreamQL, ID, ComponentDefinition, Selection, QueryInput, } from "./types/utils";
17
17
  export type { JSONValue, JSONCompatible } from "./types/json";
18
+ export type { KVValue, KVEvents } from "./types/kv";
18
19
  export type { SlotContent, ButtonSlotContent, CustomSlotContent, CommandSlotContent, SlotContentPropsInternal, SlotContentProps, } from "./types/slots";
19
20
  export type { RequestViewModeOptions, RequestWritableViewModeProps, RequestReadableViewModeProps, RequestReadableViewModePropsInternal, RequestWritableViewModePropsInternal, RequestViewModeProps, RequestFull, RequestDraft, RequestMeta, } from "./types/request";
20
21
  export type { ResponseViewModePropsInternal, ResponseViewModeOptions, ResponseViewModeProps, ResponseFull, } from "./types/response";
@@ -31,6 +32,7 @@ export type { SelectedProjectChangeEvent } from "./types/projects";
31
32
  export type { CommandPaletteViewProps, CommandPaletteViewPropsInternal, } from "./types/commandPalette";
32
33
  export type { CommandPaletteView } from "./sdks/commandPalette";
33
34
  export type { LogSDK } from "./sdks/log";
35
+ export type { KVSDK, KVDefineOptions } from "./sdks/kv";
34
36
  export type { API } from "./sdks";
35
37
  export { Routes } from "./types/navigation";
36
38
  export { type GlobalContext, type PageContext } from "./types/window";
@@ -14,6 +14,7 @@ import type { FindingsSDK } from "./findings";
14
14
  import type { FooterSDK } from "./footer";
15
15
  import type { HTTPHistorySDK } from "./httpHistory";
16
16
  import type { InterceptSDK } from "./intercept";
17
+ import type { KVSDK } from "./kv";
17
18
  import type { LogSDK } from "./log";
18
19
  import type { MatchReplaceSDK } from "./matchReplace";
19
20
  import type { MenuSDK } from "./menu";
@@ -102,6 +103,10 @@ export type API<T extends BackendEndpoints | BackendSpec = Record<string, never>
102
103
  * Utilities to interact with frontend-plugin storage.
103
104
  */
104
105
  storage: StorageSDK;
106
+ /**
107
+ * Utilities to interact with plugin package data (key-value store).
108
+ */
109
+ kv: KVSDK;
105
110
  /**
106
111
  * Utilities to interact with the plugin's static assets.
107
112
  */
@@ -0,0 +1,69 @@
1
+ import type { KVEvents, KVValue } from "../types/kv";
2
+ import type { ListenerHandle } from "../types/utils";
3
+ /**
4
+ * Options for defining a key-value pair.
5
+ * @category KV
6
+ */
7
+ export type KVDefineOptions = {
8
+ /**
9
+ * Whether the key-value pair is exportable.
10
+ *
11
+ * Usually this should be true for keys that are settings that you would want to
12
+ * transfer between Caido instances.
13
+ *
14
+ * @default false
15
+ */
16
+ exportable?: boolean | undefined;
17
+ };
18
+ /**
19
+ * The SDK for the key-value store.
20
+ *
21
+ * Plugin package data shared across frontend and backend surfaces of the same
22
+ * plugin package. Not per-user; separate from {@link StorageSDK}.
23
+ *
24
+ * @category KV
25
+ */
26
+ export type KVSDK = {
27
+ /**
28
+ * Defines a new key-value pair. Only call this once per key.
29
+ * If the key is not defined, it will be created at first set with default options.
30
+ * Defining a key alone does not notify listeners.
31
+ *
32
+ * @param key The key to define.
33
+ * @param options The options for the key.
34
+ */
35
+ define: (key: string, options: KVDefineOptions) => Promise<void>;
36
+ /**
37
+ * Gets a value from the key-value store.
38
+ *
39
+ * @param key The key to get.
40
+ * @returns The stored value (including null) or undefined if the key is not defined.
41
+ */
42
+ get: <T extends KVValue>(key: string) => Promise<T | undefined>;
43
+ /**
44
+ * Sets a value in the key-value store.
45
+ *
46
+ * @param key The key to set.
47
+ * @param value The value to set.
48
+ */
49
+ set: <T extends KVValue>(key: string, value: T) => Promise<void>;
50
+ /**
51
+ * Deletes a key-value pair from the key-value store.
52
+ *
53
+ * No-op if the key is not defined.
54
+ *
55
+ * @param key The key to delete.
56
+ */
57
+ del: (key: string) => Promise<void>;
58
+ /**
59
+ * Registers a callback for when a key-value pair is set.
60
+ *
61
+ * Fires for writes from any surface of the plugin package, including the
62
+ * local writer.
63
+ *
64
+ * @param event The event to register for.
65
+ * @param callback The callback to register.
66
+ * @returns A handle to stop listening.
67
+ */
68
+ on: <E extends keyof KVEvents>(event: E, callback: KVEvents[E]) => ListenerHandle;
69
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Represents any valid value for the key-value store.
3
+ * It needs to be serializable to JSON.
4
+ * @category KV
5
+ */
6
+ export type KVValue = string | number | boolean | KVValue[] | null | {
7
+ [key: string]: KVValue;
8
+ };
9
+ /**
10
+ * Represents the events that can be emitted by the key-value store.
11
+ * @category KV
12
+ */
13
+ export type KVEvents = {
14
+ set: <T extends KVValue>(key: string, value: T) => Promise<void> | void;
15
+ delete: (key: string) => Promise<void> | void;
16
+ };