@pinwheel/react-native-pinwheel 2.5.1 → 3.0.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/CHANGELOG.md CHANGED
@@ -2,9 +2,33 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # 3.0.x Releases
6
+
7
+ - `3.0.x` Releases - [3.0.0](#300)
8
+
9
+ ### [3.0.0](https://github.com/underdog-tech/pinwheel-ios-sdk/releases/tag/3.0.0)
10
+
11
+ ---
12
+
13
+ This new major version bump introduces an updated API to support partner-based switches.
14
+
15
+ #### Changed
16
+ - The `action` field in `input_allocation` event is now optional.
17
+ - The `params` field in the `success` event uses the `input_allocation` schema with fields `action` and `allocation`.
18
+
19
+ #### Removed
20
+ - Removed `LinkResult` type export. This was the old `success` event payload. The new payload has the same format as the newly exported `SuccessEventPayload`.
21
+ - Removed `EventPayload` type export. The event handler function will now be implicitly typed.
22
+ - Removed `ScreenTransition` type export. Use `ScreenTransitionEventPayload` instead.
23
+ - Removed `EmptyPayloadObject` type export.
24
+ - Removed `Error` type export. Use `ErrorEventPayload` instead. (`Error` was marked as deprecated in version 2.)
25
+ - Removed `ErrorType` type export. Use `PinwheelErrorType` instead. (`ErrorType` was marked as deprecated in version 2.)
26
+ - Removed `input_amount` event. Use `input_allocation` even instead.
27
+ - Removed `PINWHEEL_MESSAGE_TYPES`.
28
+
5
29
  ## 2.5.x Releases
6
30
 
7
- [2.5.0](#250) | [2.5.1](#251)
31
+ [2.5.0](#250) | [2.5.1](#251)
8
32
 
9
33
  ---
10
34
  ### 2.5.1
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = "RNPinwheelSDK"
3
- s.version = "2.5.1"
3
+ s.version = "3.0.0"
4
4
  s.summary = "React Native plugin for Pinwheel's SDK"
5
5
  s.description = <<-DESC
6
6
  An open source React Native plugin for calling Pinwheel's native SDKs to manage payroll data.
@@ -14,5 +14,5 @@ Pod::Spec.new do |s|
14
14
  s.public_header_files = 'ios/**/*.h'
15
15
  s.requires_arc = true
16
16
  s.dependency "React"
17
- s.dependency 'PinwheelSDK', '2.4.5'
17
+ s.dependency 'PinwheelSDK', '3.0.0'
18
18
  end
@@ -41,7 +41,7 @@ rootProject.allprojects {
41
41
  }
42
42
  }
43
43
 
44
- def PW_SDK_VERSION = '2.4.5'
44
+ def PW_SDK_VERSION = '3.0.0'
45
45
 
46
46
  dependencies {
47
47
  def pwVersion = rootProject.hasProperty('pwVersion') ? rootProject.pwVersion : PW_SDK_VERSION
@@ -19,7 +19,7 @@ import com.underdog_tech.pinwheel_android.PinwheelFragment
19
19
  import com.underdog_tech.pinwheel_android.PinwheelEventListener
20
20
  import com.underdog_tech.pinwheel_android.model.PinwheelEventType
21
21
  import com.underdog_tech.pinwheel_android.model.PinwheelEventPayload
22
- import com.underdog_tech.pinwheel_android.model.PinwheelAmount
22
+ import com.underdog_tech.pinwheel_android.model.PinwheelInputAllocationPayload
23
23
  import com.underdog_tech.pinwheel_android.model.PinwheelTarget
24
24
  import com.underdog_tech.pinwheel_android.model.PinwheelAllocation
25
25
  import com.underdog_tech.pinwheel_android.model.PinwheelParams
@@ -31,7 +31,6 @@ import com.underdog_tech.pinwheel_android.model.PinwheelLoginPayload
31
31
  import com.underdog_tech.pinwheel_android.model.PinwheelLoginAttemptPayload
32
32
  import com.underdog_tech.pinwheel_android.model.PinwheelDDFormCreatePayload
33
33
  import com.underdog_tech.pinwheel_android.model.PinwheelScreenTransitionPayload
34
- import com.underdog_tech.pinwheel_android.model.PinwheelInputAmountPayload
35
34
 
36
35
  fun PinwheelTarget.toWritableMap(): WritableMap {
37
36
  return Arguments.createMap().apply {
@@ -50,17 +49,14 @@ fun PinwheelAllocation.toWritableMap(): WritableMap {
50
49
 
51
50
  fun PinwheelParams.toWritableMap(): WritableMap {
52
51
  return Arguments.createMap().apply {
53
- putMap("amount", this@toWritableMap.amount?.toWritableMap())
52
+ putString("action", this@toWritableMap.action)
53
+ putMap("allocation", this@toWritableMap.allocation?.toWritableMap())
54
54
  }
55
55
  }
56
56
 
57
57
  fun PinwheelEventPayload.toWritableMap(): WritableMap = when (this) {
58
- is PinwheelAmount -> Arguments.createMap().apply {
59
- putDouble("value", this@toWritableMap.value.toDouble())
60
- putString("unit", this@toWritableMap.unit)
61
- }
62
58
 
63
- is PinwheelInputAmountPayload -> Arguments.createMap().apply {
59
+ is PinwheelInputAllocationPayload -> Arguments.createMap().apply {
64
60
  putString("action", this@toWritableMap.action)
65
61
  putMap("allocation", this@toWritableMap.allocation?.toWritableMap())
66
62
  }
@@ -162,7 +158,7 @@ class PinwheelViewManager(
162
158
 
163
159
 
164
160
  this.token?.let {
165
- val pinwheelFragment = PinwheelFragment.newInstance(it, "react native", "2.5.1")
161
+ val pinwheelFragment = PinwheelFragment.newInstance(it, "react native", "3.0.0")
166
162
  pinwheelFragment.pinwheelEventListener = this
167
163
  val activity = reactContext.currentActivity as FragmentActivity
168
164
  activity.supportFragmentManager
@@ -210,4 +206,4 @@ class PinwheelViewManager(
210
206
  private const val REACT_CLASS = "RNTPinwheel"
211
207
  private const val COMMAND_CREATE = 1
212
208
  }
213
- }
209
+ }}
@@ -0,0 +1,10 @@
1
+ import type { LoginEventPayload, SuccessEventPayload, EventHandler, ErrorEventPayload, LoginAttemptEventPayload } from './registry/v3';
2
+ export type LinkOptions = {
3
+ linkToken: string;
4
+ onLogin?: (payload: LoginEventPayload) => void;
5
+ onLoginAttempt?: (payload: LoginAttemptEventPayload) => void;
6
+ onSuccess?: (payload: SuccessEventPayload) => void;
7
+ onError?: (error: ErrorEventPayload) => void;
8
+ onExit?: (error?: ErrorEventPayload) => void;
9
+ onEvent?: EventHandler;
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,116 @@
1
+ import type { AdditionsType, ModificationsType, RemovalsType } from '../utils';
2
+ export type PinwheelErrorType = 'sandboxError' | 'clientError' | 'systemError' | 'userActionRequired' | 'platformError' | 'invalidAccountsConfiguration' | 'invalidUserInput' | 'invalidLinkToken' | 'networkError';
3
+ export type LinkApiJob = 'login' | 'direct_deposit_switch' | 'card_switch';
4
+ export type OpenEventPayload = {};
5
+ export type SelectEmployerEventPayload = {
6
+ selectedEmployerId: string;
7
+ selectedEmployerName: string;
8
+ };
9
+ export type SelectPlatformEventPayload = {
10
+ selectedPlatformId: string;
11
+ selectedPlatformName: string;
12
+ };
13
+ export type IncorrectPlatformGivenEventPayload = {};
14
+ export type LoginAttemptEventPayload = {
15
+ platformId: string;
16
+ };
17
+ export type LoginEventPayload = {
18
+ accountId: string;
19
+ platformId: string;
20
+ };
21
+ export type InputAmountEventPayload = {
22
+ value: number;
23
+ unit: '$' | '%';
24
+ };
25
+ type _PartialSwitch<T> = {
26
+ action: 'partial_switch';
27
+ allocation: T;
28
+ };
29
+ type InputAllocationPercentage = _PartialSwitch<{
30
+ type: 'percentage';
31
+ value: number;
32
+ }>;
33
+ type InputAllocationAmount = _PartialSwitch<{
34
+ type: 'amount';
35
+ value: number;
36
+ }>;
37
+ type InputAllocationRemainder = _PartialSwitch<{
38
+ type: 'remainder';
39
+ }>;
40
+ export type InputAllocationEventPayload = {
41
+ action: 'full_switch';
42
+ } | InputAllocationRemainder | InputAllocationAmount | InputAllocationPercentage;
43
+ /**
44
+ * @deprecated - Use `InputAllocationEventPayload` instead.
45
+ */
46
+ export type InputAllocation = InputAllocationEventPayload;
47
+ export type CardSwitchBeginEventPayload = {};
48
+ export type DocUploadsBeginEventPayload = {
49
+ uploadedDocumentsSubmittedCount?: number;
50
+ };
51
+ export type DocUploadsSubmittedEventPayload = {
52
+ uploadedDocumentSubmittedCount: number;
53
+ };
54
+ export type DdFormBeginEventPayload = {};
55
+ export type DdFormCreateEventPayload = {
56
+ url: string;
57
+ };
58
+ export type DdFormDownloadEventPayload = {};
59
+ export type ScreenTransitionEventPayload = {
60
+ screen_name: string;
61
+ selectedEmployerId?: string;
62
+ selectedEmployerName?: string;
63
+ selectedPlatformId?: string;
64
+ selectedPlatformName?: string;
65
+ };
66
+ /**
67
+ * @deprecated - Use `ScreenTransitionEventPayload` instead.
68
+ */
69
+ export type ScreenTransition = ScreenTransitionEventPayload;
70
+ export type ExitEventPayload = Record<string, never>;
71
+ export type SuccessEventPayload = {
72
+ accountId: string;
73
+ platformId: string;
74
+ job: LinkApiJob;
75
+ params?: {
76
+ amount?: {
77
+ value: number;
78
+ unit: '%' | '$';
79
+ };
80
+ };
81
+ };
82
+ export type ErrorEventPayload = {
83
+ type: PinwheelErrorType;
84
+ code: string;
85
+ message: string;
86
+ pendingRetry: boolean;
87
+ };
88
+ /**
89
+ * @deprecated - Use `ErrorEventPayload` instead.
90
+ */
91
+ export type PinwheelError = ErrorEventPayload;
92
+ type EventPayloadAdditions = {
93
+ open: OpenEventPayload;
94
+ select_employer: SelectEmployerEventPayload;
95
+ select_platform: SelectPlatformEventPayload;
96
+ incorrect_platform_given: IncorrectPlatformGivenEventPayload;
97
+ login_attempt: LoginAttemptEventPayload;
98
+ login: LoginEventPayload;
99
+ input_amount: InputAmountEventPayload;
100
+ input_allocation: InputAllocationEventPayload;
101
+ card_switch_begin: CardSwitchBeginEventPayload;
102
+ doc_uploads_begin: DocUploadsBeginEventPayload;
103
+ doc_uploads_submitted: DocUploadsSubmittedEventPayload;
104
+ dd_form_begin: DdFormBeginEventPayload;
105
+ dd_form_create: DdFormCreateEventPayload;
106
+ dd_form_download: DdFormDownloadEventPayload;
107
+ screen_transition: ScreenTransitionEventPayload;
108
+ exit: ErrorEventPayload | ExitEventPayload;
109
+ success: SuccessEventPayload;
110
+ error: ErrorEventPayload;
111
+ };
112
+ type EventPayloadModifications = {};
113
+ type EventPayloadRemovals = [];
114
+ export type EventPayloadMap = Omit<AdditionsType<EventPayloadAdditions> & ModificationsType<EventPayloadModifications>, keyof RemovalsType<EventPayloadRemovals>>;
115
+ export type EventHandler = <T extends keyof EventPayloadMap>(eventName: T, payload: EventPayloadMap[T]) => void;
116
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { AdditionsType, ModificationsType, RemovalsType } from '../utils';
2
+ import type { EventPayloadMap as EventPayloadMapV2, LinkApiJob } from './v2.3';
3
+ import { InputAllocationEventPayload as InputAllocationEventPayload2_3 } from './v2.3';
4
+ export * from './v2.3';
5
+ export type SuccessEventPayload = {
6
+ accountId: string;
7
+ platformId: string;
8
+ job: LinkApiJob;
9
+ params?: InputAllocationEventPayload;
10
+ };
11
+ export type InputAllocationEventPayload = {
12
+ action: null;
13
+ allocation: null;
14
+ } | InputAllocationEventPayload2_3;
15
+ /**
16
+ * @deprecated - Use `InputAllocationEventPayload` instead.
17
+ */
18
+ export type InputAllocation = InputAllocationEventPayload;
19
+ type EventPayloadAdditions = {};
20
+ type EventPayloadModifications = {
21
+ input_allocation: InputAllocationEventPayload;
22
+ };
23
+ type EventPayloadRemovals = ['input_amount'];
24
+ export type EventPayloadMap = Omit<EventPayloadMapV2 & AdditionsType<EventPayloadAdditions> & ModificationsType<EventPayloadModifications>, keyof RemovalsType<EventPayloadRemovals>>;
25
+ export type EventHandler = <T extends keyof EventPayloadMap>(eventName: T, payload: EventPayloadMap[T]) => void;
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Export all the types from V3 and we override whatever changes
3
+ */
4
+ export * from './v2.3';
@@ -0,0 +1,9 @@
1
+ export type AdditionsType<Additions> = {
2
+ [Event in keyof Additions]: Additions[Event];
3
+ };
4
+ export type ModificationsType<Modifications> = {
5
+ [Event in keyof Modifications]: Modifications[Event];
6
+ };
7
+ export type RemovalsType<Removals extends string[]> = {
8
+ [Event in Removals[number]]: never;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Importing package.json here causes a problem with the folder structure when we npm pack and publish.
3
3
  */
4
- export declare const VERSION = "2.5.1";
4
+ export declare const VERSION = "3.0.0";
5
5
  export declare const LINK_PAGE_URL = "https://cdn.getpinwheel.com/link-v2.3.0.html";
6
6
  export declare const PINWHEEL_DOMAIN = "getpinwheel.com";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Importing package.json here causes a problem with the folder structure when we npm pack and publish.
3
3
  */
4
- export const VERSION = '2.5.1';
4
+ export const VERSION = '3.0.0';
5
5
  export const LINK_PAGE_URL = 'https://cdn.getpinwheel.com/link-v2.3.0.html';
6
6
  export const PINWHEEL_DOMAIN = 'getpinwheel.com';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { LinkOptions } from './client-events/client';
3
+ type PinwheelProps = {} & LinkOptions;
4
+ declare const _default: ({ linkToken, onLogin, onLoginAttempt, onSuccess, onError, onExit, onEvent }: PinwheelProps) => React.JSX.Element;
5
+ export default _default;
@@ -7,13 +7,6 @@ const styles = StyleSheet.create({
7
7
  flex: 1,
8
8
  },
9
9
  });
10
- export const PINWHEEL_MESSAGE_TYPES = {
11
- PINWHEEL_EXIT: 'PINWHEEL_EXIT',
12
- PINWHEEL_MODAL_CLOSE: 'PINWHEEL_MODAL_CLOSE',
13
- PINWHEEL_LOAD_COMPLETE: 'PINWHEEL_LOAD_COMPLETE',
14
- PINWHEEL_SUCCESS: 'PINWHEEL_SUCCESS',
15
- PINWHEEL_EVENT: 'PINWHEEL_EVENT',
16
- };
17
10
  export default ({ linkToken, onLogin, onLoginAttempt, onSuccess, onError, onExit, onEvent }) => {
18
11
  const handleEvent = (event) => {
19
12
  if (!event) {
@@ -18,7 +18,7 @@
18
18
 
19
19
  - (void)initPinwheelWrapperVC {
20
20
  if (self.token != nil && self.pinwheelWrapperVC == nil) {
21
- self.pinwheelWrapperVC = [[PinwheelWrapperVC alloc] initWithToken:self.token delegate:self sdk:@"react native" version: @"2.5.1"];
21
+ self.pinwheelWrapperVC = [[PinwheelWrapperVC alloc] initWithToken:self.token delegate:self sdk:@"react native" version: @"3.0.0"];
22
22
  [self addSubview:self.pinwheelWrapperVC.view];
23
23
  }
24
24
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@pinwheel/react-native-pinwheel",
3
- "version": "2.5.1",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "description": "Pinwheel React Native SDK",
6
- "main": "index.js",
7
- "types": "index.d.ts",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "tsc",
10
10
  "bump-pkg-version": "./scripts/bump-pkg-version.sh",
@@ -14,7 +14,8 @@
14
14
  "license": "MIT",
15
15
  "peerDependencies": {
16
16
  "react": "^16.13.1 || ^17 || ^18",
17
- "react-native": "*"
17
+ "react-native": "*",
18
+ "react-native-webview": "*"
18
19
  },
19
20
  "devDependencies": {
20
21
  "@types/react-native": "^0.72.2",
package/index.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import React from 'react';
2
- export declare const PINWHEEL_MESSAGE_TYPES: {
3
- PINWHEEL_EXIT: string;
4
- PINWHEEL_MODAL_CLOSE: string;
5
- PINWHEEL_LOAD_COMPLETE: string;
6
- PINWHEEL_SUCCESS: string;
7
- PINWHEEL_EVENT: string;
8
- };
9
- export type LinkResult = {
10
- accountId: string;
11
- platformId: string;
12
- job: string;
13
- params: {
14
- amount?: {
15
- value: number;
16
- unit: '%' | '$';
17
- };
18
- };
19
- };
20
- export type ScreenTransition = {
21
- screenName: string;
22
- selectedEmployerId?: string;
23
- selectedEmployerName?: string;
24
- selectedPlatformId?: string;
25
- selectedPlatformName?: string;
26
- };
27
- /**
28
- * @deprecated This type will be removed in version 2.4. Use the renamed type `PinwheelErrorType`
29
- * instead.
30
- */
31
- export type ErrorType = 'clientError' | 'systemError' | 'userActionRequired' | 'platformError' | 'invalidAccountsConfiguration' | 'invalidUserInput' | 'invalidLinkToken';
32
- export type PinwheelErrorType = ErrorType;
33
- /**
34
- * @deprecated The type should not be used as it clashes with the native JS `Error` object.
35
- * You should use `PinwheelError` instead. `Error` will be removed in version 2.4
36
- */
37
- export type Error = {
38
- type: PinwheelErrorType;
39
- code: string;
40
- message: string;
41
- pendingRetry: boolean;
42
- };
43
- export type PinwheelError = Error;
44
- export type EmptyPayloadObject = Record<string, never>;
45
- export type EventPayload = {
46
- selectedEmployerId: string;
47
- selectedEmployerName: string;
48
- } | {
49
- selectedPlatformId: string;
50
- selectedPlatformName: string;
51
- } | {
52
- value: number;
53
- unit: '%' | '$';
54
- } | LinkResult | {
55
- accountId: string;
56
- platformId: string;
57
- } | ScreenTransition | PinwheelError | EmptyPayloadObject | undefined;
58
- type PinwheelProps = {
59
- linkToken: string;
60
- onLogin?: (result: {
61
- accountId: string;
62
- platformId: string;
63
- }) => void;
64
- onLoginAttempt?: (result: {
65
- platformId: string;
66
- }) => void;
67
- onSuccess?: (result: LinkResult) => void;
68
- onError?: (error: PinwheelError) => void;
69
- onExit?: (error: PinwheelError | EmptyPayloadObject) => void;
70
- onEvent?: (eventName: string, payload: EventPayload) => void;
71
- };
72
- declare const _default: ({ linkToken, onLogin, onLoginAttempt, onSuccess, onError, onExit, onEvent }: PinwheelProps) => React.JSX.Element;
73
- export default _default;
File without changes
File without changes