From e8106a4eee0e33b6eb8411dca78056bda6b5786c Mon Sep 17 00:00:00 2001 From: Clement Mwimo Date: Fri, 17 Nov 2023 17:18:34 -0700 Subject: [PATCH 1/2] added backToSearch support --- lib/post_message_definition.yml | 4 +++ packages/swift/Sources/Generated.swift | 17 +++++++++++ .../docs/react-native-sdk-generated.md | 28 +++++++++++++++++++ packages/typescript/docs/web-sdk-generated.md | 26 +++++++++++++++++ packages/typescript/src/generated.ts | 28 +++++++++++++++++++ 5 files changed, 103 insertions(+) diff --git a/lib/post_message_definition.yml b/lib/post_message_definition.yml index b519e6c..d94d1bc 100644 --- a/lib/post_message_definition.yml +++ b/lib/post_message_definition.yml @@ -122,6 +122,10 @@ post_messages: type: code: string guid: string + backToSearch: + payload: + <<: *user_session_properties + context: string pulse: overdraftWarning/cta/transferFunds: payload: diff --git a/packages/swift/Sources/Generated.swift b/packages/swift/Sources/Generated.swift index 4dffeaa..e2421f9 100644 --- a/packages/swift/Sources/Generated.swift +++ b/packages/swift/Sources/Generated.swift @@ -234,6 +234,17 @@ public enum ConnectWidgetEvent { && lhs.institution == rhs.institution } } + public struct BackToSearch: Event { + public var userGuid: String + public var sessionGuid: String + public var context: String + + public static func == (lhs: ConnectWidgetEvent.BackToSearch, rhs: ConnectWidgetEvent.BackToSearch) -> Bool { + return lhs.userGuid == rhs.userGuid + && lhs.sessionGuid == rhs.sessionGuid + && lhs.context == rhs.context + } + } } public enum PulseWidgetEvent { @@ -314,6 +325,7 @@ public protocol ConnectWidgetEventDelegate: WidgetEventDelegate { func widgetEvent(_ payload: ConnectWidgetEvent.StepChange) func widgetEvent(_ payload: ConnectWidgetEvent.SubmitMFA) func widgetEvent(_ payload: ConnectWidgetEvent.UpdateCredentials) + func widgetEvent(_ payload: ConnectWidgetEvent.BackToSearch) } public extension ConnectWidgetEventDelegate { @@ -331,6 +343,7 @@ public extension ConnectWidgetEventDelegate { func widgetEvent(_: ConnectWidgetEvent.StepChange) {} func widgetEvent(_: ConnectWidgetEvent.SubmitMFA) {} func widgetEvent(_: ConnectWidgetEvent.UpdateCredentials) {} + func widgetEvent(_: ConnectWidgetEvent.BackToSearch) {} } public protocol PulseWidgetEventDelegate: WidgetEventDelegate { @@ -465,6 +478,8 @@ class ConnectWidgetEventDispatcher: Dispatcher { delegate.widgetEvent(event) case let event as ConnectWidgetEvent.UpdateCredentials: delegate.widgetEvent(event) + case let event as ConnectWidgetEvent.BackToSearch: + delegate.widgetEvent(event) default: // Unreachable return nil @@ -515,6 +530,8 @@ class ConnectWidgetEventDispatcher: Dispatcher { return try? decode(ConnectWidgetEvent.SubmitMFA.self, metadata) case ("connect", "/updateCredentials"): return try? decode(ConnectWidgetEvent.UpdateCredentials.self, metadata) + case ("connect", "/backToSearch"): + return try? decode(ConnectWidgetEvent.BackToSearch.self, metadata) default: return .none } diff --git a/packages/typescript/docs/react-native-sdk-generated.md b/packages/typescript/docs/react-native-sdk-generated.md index e027db6..31ef762 100644 --- a/packages/typescript/docs/react-native-sdk-generated.md +++ b/packages/typescript/docs/react-native-sdk-generated.md @@ -436,3 +436,31 @@ import { ConnectWidget } from "@mxenabled/react-native-widget-sdk" +--- +### Back to search (`mx/connect/backToSearch`) + +- Widget callback prop name: `onBackToSearch` +- Payload fields: + - `user_guid` (`string`) + - `session_guid` (`string`) + - `context` (`string`) + +
+Click here to view a sample usage of onBackToSearch. + +```jsx +import { ConnectWidget } from "@mxenabled/react-native-widget-sdk" + + { + console.log(`User guid: ${payload.user_guid}`) + console.log(`Session guid: ${payload.session_guid}`) + console.log(`Context: ${payload.context}`) + } +/> +``` + +
+ diff --git a/packages/typescript/docs/web-sdk-generated.md b/packages/typescript/docs/web-sdk-generated.md index e789497..378cfd5 100644 --- a/packages/typescript/docs/web-sdk-generated.md +++ b/packages/typescript/docs/web-sdk-generated.md @@ -408,3 +408,29 @@ const widget = widgetSdk.ConnectWidget({ +--- +### Back to search (`mx/connect/backToSearch`) + +- Widget callback prop name: `onBackToSearch` +- Payload fields: + - `user_guid` (`string`) + - `session_guid` (`string`) + - `context` (`string`) + +
+Click here to view a sample usage of onBackToSearch. + +```javascript +const widget = widgetSdk.ConnectWidget({ + url: "https://widgets.moneydesktop.com/md/connect/...", + + onBackToSearch: (payload) => { + console.log(`User guid: ${payload.user_guid}`) + console.log(`Session guid: ${payload.session_guid}`) + console.log(`Context: ${payload.context}`) + } +}) +``` + +
+ diff --git a/packages/typescript/src/generated.ts b/packages/typescript/src/generated.ts index 15fc8ba..d0570df 100644 --- a/packages/typescript/src/generated.ts +++ b/packages/typescript/src/generated.ts @@ -36,6 +36,7 @@ export enum Type { ConnectStepChange = "mx/connect/stepChange", ConnectSubmitMFA = "mx/connect/submitMFA", ConnectUpdateCredentials = "mx/connect/updateCredentials", + ConnectBackToSearch = "mx/connect/backToSearch", PulseOverdraftWarningCtaTransferFunds = "mx/pulse/overdraftWarning/cta/transferFunds", AccountCreated = "mx/account/created", } @@ -75,6 +76,8 @@ const typeLookup: Record = { "mx/connect/submitmfa": Type.ConnectSubmitMFA, // cspell:disable-line [Type.ConnectUpdateCredentials]: Type.ConnectUpdateCredentials, "mx/connect/updatecredentials": Type.ConnectUpdateCredentials, // cspell:disable-line + [Type.ConnectBackToSearch]: Type.ConnectBackToSearch, + "mx/connect/backtosearch": Type.ConnectBackToSearch, // cspell:disable-line [Type.PulseOverdraftWarningCtaTransferFunds]: Type.PulseOverdraftWarningCtaTransferFunds, "mx/pulse/overdraftwarning/cta/transferfunds": Type.PulseOverdraftWarningCtaTransferFunds, // cspell:disable-line [Type.AccountCreated]: Type.AccountCreated, @@ -214,6 +217,13 @@ export type ConnectUpdateCredentialsPayload = { institution: { code: string, guid: string }, } +export type ConnectBackToSearchPayload = { + type: Type.ConnectBackToSearch, + user_guid: string, + session_guid: string, + context: string, +} + export type PulseOverdraftWarningCtaTransferFundsPayload = { type: Type.PulseOverdraftWarningCtaTransferFunds, account_guid: string, @@ -246,6 +256,7 @@ export type WidgetPayload = | ConnectStepChangePayload | ConnectSubmitMFAPayload | ConnectUpdateCredentialsPayload + | ConnectBackToSearchPayload | PulseOverdraftWarningCtaTransferFundsPayload export type EntityPayload = @@ -495,6 +506,18 @@ function buildPayload(type: Type, metadata: Metadata): Payload { institution: metadata.institution as { code: string, guid: string }, } + case Type.ConnectBackToSearch: + assertMessageProp(metadata, "mx/connect/backToSearch", "user_guid", "string") + assertMessageProp(metadata, "mx/connect/backToSearch", "session_guid", "string") + assertMessageProp(metadata, "mx/connect/backToSearch", "context", "string") + + return { + type, + user_guid: metadata.user_guid as string, + session_guid: metadata.session_guid as string, + context: metadata.context as string, + } + case Type.PulseOverdraftWarningCtaTransferFunds: assertMessageProp(metadata, "mx/pulse/overdraftWarning/cta/transferFunds", "account_guid", "string") assertMessageProp(metadata, "mx/pulse/overdraftWarning/cta/transferFunds", "amount", "number") @@ -595,6 +618,7 @@ export type ConnectPostMessageCallbackProps = WidgetPostMessageCallbackProps< onStepChange?: (payload: ConnectStepChangePayload) => void onSubmitMFA?: (payload: ConnectSubmitMFAPayload) => void onUpdateCredentials?: (payload: ConnectUpdateCredentialsPayload) => void + onBackToSearch?: (payload: ConnectBackToSearchPayload) => void } export type PulsePostMessageCallbackProps = WidgetPostMessageCallbackProps & { @@ -810,6 +834,10 @@ function dispatchConnectInternalMessage(payload: Payload, callbacks: ConnectP callbacks.onUpdateCredentials?.(payload) break + case Type.ConnectBackToSearch: + callbacks.onBackToSearch?.(payload) + break + default: throw new PostMessageUnknownTypeError(payload.type) } From b748e19947b1dbc6f5a7d59a59915a768195411d Mon Sep 17 00:00:00 2001 From: Clement Mwimo Date: Wed, 22 Nov 2023 16:00:47 -0700 Subject: [PATCH 2/2] pumped up ptypescript package version --- packages/typescript/package-lock.json | 4 ++-- packages/typescript/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/typescript/package-lock.json b/packages/typescript/package-lock.json index 07fc7db..ba9cb83 100644 --- a/packages/typescript/package-lock.json +++ b/packages/typescript/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mxenabled/widget-post-message-definitions", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mxenabled/widget-post-message-definitions", - "version": "1.1.0", + "version": "1.2.0", "license": "MIT", "devDependencies": { "@types/jest": "^27.4.1", diff --git a/packages/typescript/package.json b/packages/typescript/package.json index f4406e2..3ab2143 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@mxenabled/widget-post-message-definitions", - "version": "1.1.0", + "version": "1.2.0", "description": "Widget Post Message Definitions for use in SDKs", "main": "dist/index.js", "license": "MIT",