@chatium/json
Advanced tools
Comparing version 0.1.11 to 0.2.0
import { ChatiumActions } from './actions'; | ||
import { ChatiumScreen } from './Screen'; | ||
/** | ||
* Standard response type for standard chatium calls including screen, apiCall action and simple data requests | ||
* Union of all kinds of responses supported by the chatium router | ||
*/ | ||
export declare type ChatiumResponse<ExtraBlocks, ExtraActions> = ChatiumSuccessResponse<ExtraBlocks, ExtraActions> | ErrorResponse<ExtraBlocks, ExtraActions>; | ||
declare type ChatiumSuccessResponse<ExtraBlocks, ExtraActions> = { | ||
success: true; | ||
} & (ScreenResponse<ExtraBlocks, ExtraActions> | ApiCallResponse<ExtraBlocks, ExtraActions> | DataResponse); | ||
declare type ErrorResponse<ExtraBlocks, ExtraActions> = ScreenErrorResponse<ExtraBlocks, ExtraActions> | ApiCallErrorResponse<ExtraBlocks, ExtraActions> | DataErrorResponse; | ||
export declare type ChatiumResponse<ExtraBlocks, ExtraActions> = ApiCallResponse<ExtraBlocks, ExtraActions> | ScreenResponse<ExtraBlocks, ExtraActions> | CustomResponse; | ||
/** | ||
* Standard response for apiCall client action | ||
*/ | ||
export interface ApiCallResponse<ExtraBlocks, ExtraActions> { | ||
export declare type ApiCallResponse<ExtraBlocks, ExtraActions> = ApiCallSuccessResponse<ExtraBlocks, ExtraActions> | ApiCallErrorResponse<ExtraBlocks, ExtraActions>; | ||
export interface ApiCallErrorResponse<ExtraBlocks, ExtraActions> extends ChatiumErrorResponse, ApiCallResponseFields<ExtraBlocks, ExtraActions> { | ||
} | ||
export interface ApiCallSuccessResponse<ExtraBlocks, ExtraActions> extends ApiCallResponseFields<ExtraBlocks, ExtraActions> { | ||
success: true; | ||
} | ||
export interface ApiCallResponseFields<ExtraBlocks, ExtraActions> { | ||
appAction?: ChatiumActions<ExtraActions>; | ||
@@ -19,11 +21,11 @@ appScreens?: Record<string, ChatiumScreen<ExtraBlocks, ExtraActions>>; | ||
/** | ||
* Standard plain data response (whole payload should be put in `data` field) | ||
* Standard get-screen response | ||
*/ | ||
interface DataResponse { | ||
data: unknown; | ||
export declare type ScreenResponse<ExtraBlocks, ExtraActions> = ScreenSuccessResponse<ExtraBlocks, ExtraActions> | ScreenErrorResponse<ExtraBlocks, ExtraActions>; | ||
export interface ScreenSuccessResponse<ExtraBlocks, ExtraActions> extends ScreenResponseFields<ExtraBlocks, ExtraActions> { | ||
success: true; | ||
} | ||
/** | ||
* Standard get-screen response | ||
*/ | ||
export interface ScreenResponse<ExtraBlocks, ExtraActions> { | ||
export interface ScreenErrorResponse<ExtraBlocks, ExtraActions> extends ChatiumErrorResponse, Partial<ScreenResponseFields<ExtraBlocks, ExtraActions>> { | ||
} | ||
export interface ScreenResponseFields<ExtraBlocks, ExtraActions> { | ||
data: ChatiumScreen<ExtraBlocks, ExtraActions>; | ||
@@ -34,2 +36,17 @@ appScreens?: Record<string, ChatiumScreen<ExtraBlocks, ExtraActions>>; | ||
/** | ||
* Untyped direct data response | ||
*/ | ||
export declare type CustomResponse = CustomSuccessResponse | CustomErrorResponse; | ||
export declare type CustomSuccessResponse = unknown | TuneHttpHeadersResponse; | ||
export declare type CustomErrorResponse = ChatiumErrorResponse; | ||
/** | ||
* Special format recognized by the router to allow tuning of headers and status code | ||
*/ | ||
export interface TuneHttpHeadersResponse { | ||
rawHttpBody: unknown; | ||
headers?: Record<string, string>; | ||
statusCode?: number; | ||
} | ||
export declare function isTuneHttpHeadersResponse(resp: any): resp is TuneHttpHeadersResponse; | ||
/** | ||
* Standard error shape | ||
@@ -47,10 +64,4 @@ * Can be extended depending on request type, see below | ||
} | ||
export interface ScreenErrorResponse<ExtraBlocks, ExtraActions> extends ChatiumErrorResponse, Partial<ScreenResponse<ExtraBlocks, ExtraActions>> { | ||
} | ||
export interface ApiCallErrorResponse<ExtraBlocks, ExtraActions> extends ChatiumErrorResponse, ApiCallResponse<ExtraBlocks, ExtraActions> { | ||
} | ||
export interface DataErrorResponse extends ChatiumErrorResponse, Partial<DataResponse> { | ||
} | ||
export declare function isChatiumErrorResponse(val: any): val is ChatiumErrorResponse; | ||
export declare function screenResponse<ExtraBlocks, ExtraActions>(props: ScreenResponse<ExtraBlocks, ExtraActions>): { | ||
export declare function screenResponse<ExtraBlocks, ExtraActions>(props: ScreenResponseFields<ExtraBlocks, ExtraActions>): { | ||
data: ChatiumScreen<ExtraBlocks, ExtraActions>; | ||
@@ -61,3 +72,3 @@ appScreens?: Record<string, ChatiumScreen<ExtraBlocks, ExtraActions>> | undefined; | ||
}; | ||
export declare function apiCallResponse<ExtraBlocks, ExtraActions>(props: ApiCallResponse<ExtraBlocks, ExtraActions>): { | ||
export declare function apiCallResponse<ExtraBlocks, ExtraActions>(props: ApiCallResponseFields<ExtraBlocks, ExtraActions>): { | ||
appAction?: import(".").AttachMediaAction | import(".").ConfirmEmailAction | import(".").ConfirmPhoneAction | import(".").CopyToClipboardAction | import(".").GoBackAction | import(".").NavigateAction | import(".").NextSlideAction | import(".").NoopAction | import(".").PreloadMediaAction | import(".").RefreshAction | import(".").RequestPaymentAction | import(".").ResetSearchAction | import(".").SelectContactsAction | import(".").ApiCallAction<unknown> | import(".").ShowTextDialogAction | import(".").ShowToastAction | import(".").UpdateCurrentScreenBlock<unknown> | ExtraActions | import(".").ShowContextMenuAction<ExtraActions> | import("./actions").ChatiumAction<ExtraActions>[] | undefined; | ||
@@ -67,2 +78,1 @@ appScreens?: Record<string, ChatiumScreen<ExtraBlocks, ExtraActions>> | undefined; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.apiCallResponse = exports.screenResponse = exports.isChatiumErrorResponse = void 0; | ||
exports.apiCallResponse = exports.screenResponse = exports.isChatiumErrorResponse = exports.isTuneHttpHeadersResponse = void 0; | ||
function isTuneHttpHeadersResponse(resp) { | ||
return !!resp && 'rawHttpBody' in resp; | ||
} | ||
exports.isTuneHttpHeadersResponse = isTuneHttpHeadersResponse; | ||
function isChatiumErrorResponse(val) { | ||
@@ -5,0 +9,0 @@ return val && val.success === false && 'statusCode' in val && 'reason' in val; |
@@ -33,3 +33,3 @@ export { ChatiumAction, ChatiumActions } from './actions'; | ||
export { Author, ChatiumJsonId, ChatiumJsonKey, ContainerStyle, CommonBlockProps, Color, FontSize, Icon, ImageSize, ImageSizePreset, OverlayProps, StatusIcon, WithKey, } from './commonTypes'; | ||
export { ApiCallErrorResponse, ApiCallResponse, apiCallResponse, ChatiumErrorFields, ChatiumErrorResponse, ChatiumResponse, DataErrorResponse, isChatiumErrorResponse, ScreenErrorResponse, ScreenResponse, screenResponse, } from './ChatiumResponse'; | ||
export { ApiCallErrorResponse, ApiCallResponse, ApiCallResponseFields, apiCallResponse, ChatiumErrorFields, ChatiumErrorResponse, ChatiumResponse, CustomResponse, CustomErrorResponse, isChatiumErrorResponse, isTuneHttpHeadersResponse, ScreenResponse, ScreenErrorResponse, ScreenSuccessResponse, screenResponse, } from './ChatiumResponse'; | ||
export { ChatiumFileInfo, ChatMessage, ChatProps, ChatReplyMessage } from './Chat'; | ||
@@ -36,0 +36,0 @@ export { ChatiumScreen, HeaderButton, Screen } from './Screen'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.intrinsicBlocks = exports.flattenChildren = exports.jsxFactory = exports.jsx = exports.Screen = exports.screenResponse = exports.isChatiumErrorResponse = exports.apiCallResponse = exports.Video = exports.InlineVideo = exports.Text = exports.Search = exports.ListItem = exports.Image = exports.HorizontalCards = exports.Card = exports.Header = exports.Gallery = exports.Footer = exports.Button = exports.Audio = exports.updateCurrentScreenBlock = exports.showToast = exports.showTextDialog = exports.showContextMenu = exports.selectContacts = exports.resetSearch = exports.humanizePaymentIntegration = exports.requestPayment = exports.refresh = exports.preloadMedia = exports.noop = exports.nextSlide = exports.navigate = exports.goBack = exports.copyToClipboard = exports.confirmPhone = exports.confirmEmail = exports.MediaType = exports.attachMedia = exports.apiCall = void 0; | ||
exports.intrinsicBlocks = exports.flattenChildren = exports.jsxFactory = exports.jsx = exports.Screen = exports.screenResponse = exports.isTuneHttpHeadersResponse = exports.isChatiumErrorResponse = exports.apiCallResponse = exports.Video = exports.InlineVideo = exports.Text = exports.Search = exports.ListItem = exports.Image = exports.HorizontalCards = exports.Card = exports.Header = exports.Gallery = exports.Footer = exports.Button = exports.Audio = exports.updateCurrentScreenBlock = exports.showToast = exports.showTextDialog = exports.showContextMenu = exports.selectContacts = exports.resetSearch = exports.humanizePaymentIntegration = exports.requestPayment = exports.refresh = exports.preloadMedia = exports.noop = exports.nextSlide = exports.navigate = exports.goBack = exports.copyToClipboard = exports.confirmPhone = exports.confirmEmail = exports.MediaType = exports.attachMedia = exports.apiCall = void 0; | ||
var apiCall_1 = require("./actions/apiCall"); | ||
@@ -69,2 +69,3 @@ Object.defineProperty(exports, "apiCall", { enumerable: true, get: function () { return apiCall_1.apiCall; } }); | ||
Object.defineProperty(exports, "isChatiumErrorResponse", { enumerable: true, get: function () { return ChatiumResponse_1.isChatiumErrorResponse; } }); | ||
Object.defineProperty(exports, "isTuneHttpHeadersResponse", { enumerable: true, get: function () { return ChatiumResponse_1.isTuneHttpHeadersResponse; } }); | ||
Object.defineProperty(exports, "screenResponse", { enumerable: true, get: function () { return ChatiumResponse_1.screenResponse; } }); | ||
@@ -71,0 +72,0 @@ var Screen_1 = require("./Screen"); |
{ | ||
"name": "@chatium/json", | ||
"version": "0.1.11", | ||
"version": "0.2.0", | ||
"description": "Chatium-JSON UI browser format specification and reference implementation for JS/TS", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
70236
83
1579