@cloudquery/plugin-config-ui-connector
Advanced tools
Comparing version 0.1.2 to 0.1.3
/** | ||
* A library that is designed to establish communication between CloudQuery Cloud App form and Plugin UI | ||
* | ||
* @packageDocumentation | ||
*/ | ||
/** | ||
* Type of the message handler for the CloudQuery Cloud App form. | ||
@@ -17,3 +23,3 @@ * @public | ||
init: { | ||
apiAuthorizationToken: string; | ||
/** The initial values for the form */ | ||
initialValues: { | ||
@@ -48,7 +54,26 @@ migrateMode: 'forced' | 'safe' | undefined; | ||
/** | ||
* Payload for the 'api_authorization_token_changed' message type. | ||
* Payload for the 'api_call_response' message type. | ||
* This message type is used to respond to a Plugin UI message type `api_call_request`. | ||
*/ | ||
api_authorization_token_changed: { | ||
token: string; | ||
api_call_response: { | ||
/** The unique API request ID that was sent with Plugin UI message type `api_call_request` */ | ||
id: string; | ||
/** The API endpoint that was called */ | ||
endpoint: string; | ||
/** Whether the API call was successful */ | ||
ok: boolean; | ||
/** The response status */ | ||
status: number; | ||
/** The response headers */ | ||
headers: Headers; | ||
/** The response body */ | ||
body?: any; | ||
}; | ||
/** | ||
* Payload for the 'name_changed' message type. | ||
*/ | ||
name_changed: { | ||
/** The name of the sync source/destination */ | ||
name: string; | ||
}; | ||
}; | ||
@@ -69,3 +94,3 @@ | ||
*/ | ||
export declare const formMessageTypes: readonly ["init", "validate", "submit_failed", "request_current_values", "api_authorization_token_changed"]; | ||
export declare const formMessageTypes: readonly ["init", "validate", "submit_failed", "request_current_values", "api_call_response", "name_changed"]; | ||
@@ -77,3 +102,3 @@ /** | ||
*/ | ||
export declare function getPluginUiMessageHandler(): MessageHandler<"height_changed" | "validation_passed" | "validation_failed" | "open_url" | "ready" | "show_submit_button" | "hide_submit_button" | "current_values", PluginUiMessagePayload, "init" | "validate" | "submit_failed" | "request_current_values" | "api_authorization_token_changed", FormMessagePayload>; | ||
export declare function getPluginUiMessageHandler(): MessageHandler<"height_changed" | "validation_passed" | "validation_failed" | "open_url" | "ready" | "current_values" | "api_call_request" | "on_previous_step" | "on_cancel" | "on_submitted", PluginUiMessagePayload, "init" | "validate" | "submit_failed" | "request_current_values" | "api_call_response" | "name_changed", FormMessagePayload>; | ||
@@ -155,2 +180,3 @@ /** | ||
height_changed: { | ||
/** The new height value */ | ||
height: number; | ||
@@ -162,2 +188,3 @@ }; | ||
validation_passed: { | ||
/** The Plugin UI values that were validated */ | ||
values: { | ||
@@ -179,2 +206,3 @@ migrateMode?: 'forced' | 'safe'; | ||
validation_failed: { | ||
/** The errors that occurred during validation */ | ||
errors: Partial<{ | ||
@@ -192,2 +220,3 @@ migrateMode: string; | ||
open_url: { | ||
/** The URL to be opened */ | ||
url: string; | ||
@@ -199,15 +228,6 @@ }; | ||
ready: { | ||
hideSubmitButton?: boolean; | ||
/** Whether the Plugin UI implementes a custom footer with a previous step, cancel and submit buttons and thefore the default footer should be hidden */ | ||
implementsCustomFooter?: boolean; | ||
}; | ||
/** | ||
* Payload for the 'show_submit_button' message type. | ||
* This message type has no associated payload. | ||
*/ | ||
show_submit_button: void; | ||
/** | ||
* Payload for the 'hide_submit_button' message type. | ||
* This message type has no associated payload. | ||
*/ | ||
hide_submit_button: void; | ||
/** | ||
* Payload for the 'current_values' message type. | ||
@@ -228,2 +248,50 @@ */ | ||
}; | ||
/** | ||
* Payload for the 'api_call_request' message type. | ||
* This message type is used to request an API call with CloudQuery Authentication header. | ||
*/ | ||
api_call_request: { | ||
/** The unique API request ID that can be used to match with Form message type `api_call_response` */ | ||
id: string; | ||
/** The API endpoint to call */ | ||
endpoint: string; | ||
/** The request method */ | ||
method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE'; | ||
/** The request body */ | ||
body?: any; | ||
/** The request options */ | ||
options?: { | ||
headers?: HeadersInit; | ||
mode?: RequestMode; | ||
}; | ||
}; | ||
/** | ||
* Payload for the 'api_call_abort_request' message type. | ||
* This message type is used to abort an API call request with the given ID. | ||
*/ | ||
api_call_abort_request: { | ||
id: string; | ||
}; | ||
/** | ||
* Payload for the 'on_previous_step' message type. | ||
*/ | ||
on_previous_step: void; | ||
/** | ||
* Payload for the 'on_cancel' message type. | ||
*/ | ||
on_cancel: void; | ||
/** | ||
* Payload for the 'on_submitted' message type. | ||
*/ | ||
on_submitted: { | ||
migrateMode?: 'forced' | 'safe'; | ||
envs: Array<{ | ||
name: string; | ||
value: string; | ||
}>; | ||
spec: Record<string, any>; | ||
tables?: string[]; | ||
skipTables?: string[]; | ||
writeMode?: 'append' | 'overwrite' | 'overwrite-delete-stale'; | ||
}; | ||
}; | ||
@@ -244,4 +312,4 @@ | ||
*/ | ||
export declare const pluginUiMessageTypes: readonly ["height_changed", "validation_passed", "validation_failed", "open_url", "ready", "show_submit_button", "hide_submit_button", "current_values"]; | ||
export declare const pluginUiMessageTypes: readonly ["height_changed", "validation_passed", "validation_failed", "open_url", "ready", "current_values", "api_call_request", "on_previous_step", "on_cancel", "on_submitted"]; | ||
export { } |
@@ -1,1 +0,1 @@ | ||
!function(e,s){if("object"==typeof exports&&"object"==typeof module)module.exports=s();else if("function"==typeof define&&define.amd)define([],s);else{var t=s();for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}(this,(()=>(()=>{"use strict";var e={d:(s,t)=>{for(var a in t)e.o(t,a)&&!e.o(s,a)&&Object.defineProperty(s,a,{enumerable:!0,get:t[a]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},s={};e.r(s),e.d(s,{MessageHandler:()=>i,formMessageTypes:()=>n,getPluginUiMessageHandler:()=>o,pluginUiMessageTypes:()=>a});const t="plugin-ui-connector-iframe",a=["height_changed","validation_passed","validation_failed","open_url","ready","show_submit_button","hide_submit_button","current_values"],n=["init","validate","submit_failed","request_current_values","api_authorization_token_changed"];class i{constructor(e,s,t){this.callbacks=new Map,this.sendMessageTypes=new Set,this.receiveMessageTypes=new Set,this.sendMessageTypes=new Set(e),this.receiveMessageTypes=new Set(s),this.sendMessageWindow=t,window.addEventListener("message",this.handleMessage.bind(this))}sendMessage(e,s){if(!this.sendMessageTypes.has(e))throw new Error(`Unknown send message type: ${String(e)}`);this.sendMessageWindow.postMessage({type:e,payload:s,id:t},"*")}subscribeToMessage(e,s){if(!this.receiveMessageTypes.has(e))throw new Error(`Unknown receive message type: ${String(e)}`);const t=this.callbacks.get(e);return t?t.push(s):this.callbacks.set(e,[s]),()=>{const t=this.callbacks.get(e);t&&this.callbacks.set(e,t.filter((e=>e!==s)))}}subscribeToMessageOnce(e,s){const t=a=>{s(a);const n=this.callbacks.get(e);n&&this.callbacks.set(e,n.filter((e=>e!==t)))};return this.subscribeToMessage(e,t)}handleMessage(e){const{id:s}=e.data;if(s!==t)return;const a=e.data.type,n=this.callbacks.get(a);if(n)for(const s of n)s(e.data.payload)}}function o(){return new i(a,n,window.parent)}return s})())); | ||
!function(e,s){if("object"==typeof exports&&"object"==typeof module)module.exports=s();else if("function"==typeof define&&define.amd)define([],s);else{var t=s();for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}(this,(()=>(()=>{"use strict";var e={d:(s,t)=>{for(var a in t)e.o(t,a)&&!e.o(s,a)&&Object.defineProperty(s,a,{enumerable:!0,get:t[a]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},s={};e.r(s),e.d(s,{MessageHandler:()=>i,formMessageTypes:()=>n,getPluginUiMessageHandler:()=>o,pluginUiMessageTypes:()=>a});const t="plugin-ui-connector-iframe",a=["height_changed","validation_passed","validation_failed","open_url","ready","current_values","api_call_request","on_previous_step","on_cancel","on_submitted"],n=["init","validate","submit_failed","request_current_values","api_call_response","name_changed"];class i{constructor(e,s,t){this.callbacks=new Map,this.sendMessageTypes=new Set,this.receiveMessageTypes=new Set,this.sendMessageTypes=new Set(e),this.receiveMessageTypes=new Set(s),this.sendMessageWindow=t,window.addEventListener("message",this.handleMessage.bind(this))}sendMessage(e,s){if(!this.sendMessageTypes.has(e))throw new Error(`Unknown send message type: ${String(e)}`);this.sendMessageWindow.postMessage({type:e,payload:s,id:t},"*")}subscribeToMessage(e,s){if(!this.receiveMessageTypes.has(e))throw new Error(`Unknown receive message type: ${String(e)}`);const t=this.callbacks.get(e);return t?t.push(s):this.callbacks.set(e,[s]),()=>{const t=this.callbacks.get(e);t&&this.callbacks.set(e,t.filter((e=>e!==s)))}}subscribeToMessageOnce(e,s){const t=a=>{s(a);const n=this.callbacks.get(e);n&&this.callbacks.set(e,n.filter((e=>e!==t)))};return this.subscribeToMessage(e,t)}handleMessage(e){const{id:s}=e.data;if(s!==t)return;const a=e.data.type,n=this.callbacks.get(a);if(n)for(const s of n)s(e.data.payload)}}function o(){return new i(a,n,window.parent)}return s})())); |
{ | ||
"name": "@cloudquery/plugin-config-ui-connector", | ||
"description": "Plugin configuration UI connector for CloudQuery Cloud App", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
@@ -7,3 +7,3 @@ # @cloudquery/plugin-config-ui-connector | ||
`@cloudquery/plugin-config-ui-connector` is a library designed to facilitate communication between CloudQuery Cloud App form and Plugin UI. | ||
`@cloudquery/plugin-config-ui-connector` is a library designed to establish communication between CloudQuery Cloud App form and Plugin UI. | ||
@@ -10,0 +10,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33431
294