react-native-sdk-pianoio 0.3.2 → 0.3.5
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/README.md +111 -212
- package/android/build.gradle +29 -42
- package/android/gradle.properties +33 -14
- package/android/src/main/java/com/sdkpianoio/ComposerPianoImpl.kt +366 -0
- package/android/src/main/java/com/sdkpianoio/SdkPianoioModule.kt +281 -507
- package/android/src/main/java/com/sdkpianoio/TokenService.kt +139 -0
- package/android/test.sh +494 -0
- package/ios/ComposerPianoImpl.swift +128 -225
- package/ios/MyComposerDelegate.swift +142 -109
- package/ios/SdkPianoio.swift +69 -143
- package/ios/SdkPianoioBridge.m +18 -46
- package/ios/TokenService.swift +219 -0
- package/lib/commonjs/NativeSdkPianoio.ts +34 -10
- package/lib/commonjs/PianoComposer.js +69 -51
- package/lib/commonjs/PianoComposer.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeSdkPianoio.ts +34 -10
- package/lib/module/PianoComposer.js +70 -51
- package/lib/module/PianoComposer.js.map +1 -1
- package/lib/module/index.js +0 -14
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeSdkPianoio.d.ts +27 -9
- package/lib/typescript/commonjs/src/NativeSdkPianoio.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/PianoComposer.d.ts +45 -18
- package/lib/typescript/commonjs/src/PianoComposer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeSdkPianoio.d.ts +27 -9
- package/lib/typescript/module/src/NativeSdkPianoio.d.ts.map +1 -1
- package/lib/typescript/module/src/PianoComposer.d.ts +45 -18
- package/lib/typescript/module/src/PianoComposer.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/NativeSdkPianoio.ts +34 -10
- package/src/PianoComposer.tsx +76 -59
- package/src/index.tsx +0 -14
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/ios/services/TokenService.swift +0 -70
@@ -1,14 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* This interface defines the full API surface of the native module.
|
3
|
+
* It is a complete and accurate representation of the methods exposed
|
4
|
+
* in SdkPianoioModule.kt.
|
5
|
+
*/
|
1
6
|
interface SdkPianoioType {
|
2
|
-
|
7
|
+
initialize(aid: string): Promise<boolean>;
|
8
|
+
addTag(tag: string): Promise<boolean>;
|
9
|
+
addTags(tags: string[]): Promise<boolean>;
|
10
|
+
setZoneId(zoneId: string): Promise<boolean>;
|
11
|
+
setReferrer(referrer: string): Promise<boolean>;
|
12
|
+
setUrl(url: string): Promise<boolean>;
|
13
|
+
setUserToken(token: string): Promise<boolean>;
|
14
|
+
addCustomVariable(key: string, value: string): Promise<boolean>;
|
15
|
+
setCustomVariables(variables: {
|
16
|
+
[key: string]: string;
|
17
|
+
}): Promise<boolean>;
|
3
18
|
executeExperience(): Promise<any>;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
19
|
+
signIn(): Promise<any>;
|
20
|
+
signOut(): Promise<any>;
|
21
|
+
getCurrentUser(): Promise<any>;
|
22
|
+
isAuthenticated(): Promise<any>;
|
23
|
+
getStatus(): Promise<any>;
|
24
|
+
isInitialized(): Promise<boolean>;
|
25
|
+
clearConfiguration(): Promise<boolean>;
|
26
|
+
removeTag(tag: string): Promise<boolean>;
|
27
|
+
removeCustomVariable(key: string): Promise<boolean>;
|
28
|
+
clearTags(): Promise<boolean>;
|
29
|
+
clearCustomVariables(): Promise<boolean>;
|
12
30
|
}
|
13
31
|
declare const _default: SdkPianoioType;
|
14
32
|
export default _default;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"NativeSdkPianoio.d.ts","sourceRoot":"","sources":["../../../../src/NativeSdkPianoio.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;
|
1
|
+
{"version":3,"file":"NativeSdkPianoio.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C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C;wBAW4B,cAAc;AAA3C,wBAA4C"}
|
@@ -1,34 +1,61 @@
|
|
1
|
+
/**
|
2
|
+
* A wrapper class for the native SdkPianoio module that provides a clean,
|
3
|
+
* object-oriented API for interacting with the Piano SDK.
|
4
|
+
*/
|
1
5
|
declare class PianoComposer {
|
2
|
-
private aid;
|
3
|
-
private tags;
|
4
|
-
private zoneId;
|
5
|
-
private referrer;
|
6
|
-
private customVariables;
|
7
|
-
private userToken;
|
8
|
-
private url;
|
9
6
|
private constructor();
|
10
7
|
/**
|
11
8
|
* Creates and initializes a new PianoComposer instance.
|
12
|
-
* This is the entry point for using the library.
|
9
|
+
* This is the main entry point for using the library.
|
13
10
|
* @param aid Your Application ID from Piano.io
|
14
11
|
*/
|
15
12
|
static create(aid: string): Promise<PianoComposer>;
|
16
|
-
addTag(tag: string): Promise<
|
17
|
-
addTags(tags: string[]): Promise<
|
18
|
-
setZoneId(zoneId: string): Promise<
|
19
|
-
setReferrer(referrer: string): Promise<
|
20
|
-
setCustomVariable(name: string, value: string): Promise<
|
21
|
-
|
22
|
-
|
13
|
+
addTag(tag: string): Promise<boolean>;
|
14
|
+
addTags(tags: string[]): Promise<boolean>;
|
15
|
+
setZoneId(zoneId: string): Promise<boolean>;
|
16
|
+
setReferrer(referrer: string): Promise<boolean>;
|
17
|
+
setCustomVariable(name: string, value: string): Promise<boolean>;
|
18
|
+
setCustomVariables(variables: {
|
19
|
+
[key: string]: string;
|
20
|
+
}): Promise<boolean>;
|
21
|
+
setUserToken(token: string): Promise<boolean>;
|
22
|
+
setUrl(url: string): Promise<boolean>;
|
23
|
+
/**
|
24
|
+
* Signs in the user with Piano.
|
25
|
+
* @returns A promise that resolves with user information.
|
26
|
+
*/
|
27
|
+
signIn(): Promise<any>;
|
28
|
+
/**
|
29
|
+
* Signs out the current user.
|
30
|
+
* @returns A promise that resolves when sign out is complete.
|
31
|
+
*/
|
32
|
+
signOut(): Promise<any>;
|
33
|
+
/**
|
34
|
+
* Gets information about the current authenticated user.
|
35
|
+
* @returns A promise that resolves with user information.
|
36
|
+
*/
|
37
|
+
getCurrentUser(): Promise<any>;
|
38
|
+
/**
|
39
|
+
* Checks if a user is currently authenticated.
|
40
|
+
* @returns A promise that resolves with the authentication status.
|
41
|
+
*/
|
42
|
+
isAuthenticated(): Promise<any>;
|
23
43
|
/**
|
24
44
|
* Executes the Piano experience with the current configuration.
|
25
45
|
* This is the primary method to get a decision from the Piano backend.
|
26
46
|
* @returns A promise that resolves with the event data object from the native SDK.
|
27
47
|
*/
|
28
48
|
executeExperience(): Promise<any>;
|
29
|
-
|
30
|
-
|
31
|
-
|
49
|
+
/**
|
50
|
+
* Gets the current status of the SDK.
|
51
|
+
* @returns A promise that resolves with status information.
|
52
|
+
*/
|
53
|
+
getStatus(): Promise<any>;
|
54
|
+
/**
|
55
|
+
* Clears all configured tags and custom variables.
|
56
|
+
* @returns A promise that resolves when the configuration is cleared.
|
57
|
+
*/
|
58
|
+
clearConfiguration(): Promise<boolean>;
|
32
59
|
}
|
33
60
|
export default PianoComposer;
|
34
61
|
//# sourceMappingURL=PianoComposer.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PianoComposer.d.ts","sourceRoot":"","sources":["../../../../src/PianoComposer.tsx"],"names":[],"mappings":"AAEA,cAAM,aAAa;IAEjB,OAAO,CAAC,GAAG,
|
1
|
+
{"version":3,"file":"PianoComposer.d.ts","sourceRoot":"","sources":["../../../../src/PianoComposer.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AACH,cAAM,aAAa;IAEjB,OAAO;IAIP;;;;OAIG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":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-sdk-pianoio",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.5",
|
4
4
|
"description": "Piano io sdk integration",
|
5
5
|
"source": "./src/index.tsx",
|
6
6
|
"main": "./lib/commonjs/index.js",
|
@@ -214,5 +214,8 @@
|
|
214
214
|
"type": "turbo-module",
|
215
215
|
"languages": "kotlin-objc",
|
216
216
|
"version": "0.48.9"
|
217
|
+
},
|
218
|
+
"dependencies": {
|
219
|
+
"@react-native-community/cli-platform-android": "^18.0.0"
|
217
220
|
}
|
218
221
|
}
|
package/src/NativeSdkPianoio.ts
CHANGED
@@ -1,17 +1,41 @@
|
|
1
1
|
import { NativeModules, Platform } from 'react-native';
|
2
2
|
|
3
|
+
/**
|
4
|
+
* This interface defines the full API surface of the native module.
|
5
|
+
* It is a complete and accurate representation of the methods exposed
|
6
|
+
* in SdkPianoioModule.kt.
|
7
|
+
*/
|
3
8
|
interface SdkPianoioType {
|
4
|
-
|
9
|
+
// Initialization
|
10
|
+
initialize(aid: string): Promise<boolean>;
|
11
|
+
|
12
|
+
// Configuration
|
13
|
+
addTag(tag: string): Promise<boolean>;
|
14
|
+
addTags(tags: string[]): Promise<boolean>;
|
15
|
+
setZoneId(zoneId: string): Promise<boolean>;
|
16
|
+
setReferrer(referrer: string): Promise<boolean>;
|
17
|
+
setUrl(url: string): Promise<boolean>;
|
18
|
+
setUserToken(token: string): Promise<boolean>;
|
19
|
+
addCustomVariable(key: string, value: string): Promise<boolean>;
|
20
|
+
setCustomVariables(variables: { [key: string]: string }): Promise<boolean>;
|
21
|
+
|
22
|
+
// Execution
|
5
23
|
executeExperience(): Promise<any>;
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
24
|
+
|
25
|
+
// Authentication
|
26
|
+
signIn(): Promise<any>;
|
27
|
+
signOut(): Promise<any>;
|
28
|
+
getCurrentUser(): Promise<any>;
|
29
|
+
isAuthenticated(): Promise<any>;
|
30
|
+
|
31
|
+
// Status & Cleanup
|
32
|
+
getStatus(): Promise<any>;
|
33
|
+
isInitialized(): Promise<boolean>;
|
34
|
+
clearConfiguration(): Promise<boolean>;
|
35
|
+
removeTag(tag: string): Promise<boolean>;
|
36
|
+
removeCustomVariable(key: string): Promise<boolean>;
|
37
|
+
clearTags(): Promise<boolean>;
|
38
|
+
clearCustomVariables(): Promise<boolean>;
|
15
39
|
}
|
16
40
|
|
17
41
|
const SdkPianoio = NativeModules.SdkPianoio;
|
package/src/PianoComposer.tsx
CHANGED
@@ -1,65 +1,92 @@
|
|
1
1
|
import SdkPianoio from './NativeSdkPianoio';
|
2
2
|
|
3
|
+
/**
|
4
|
+
* A wrapper class for the native SdkPianoio module that provides a clean,
|
5
|
+
* object-oriented API for interacting with the Piano SDK.
|
6
|
+
*/
|
3
7
|
class PianoComposer {
|
4
|
-
// --- Properties to hold configuration state ---
|
5
|
-
private aid: string;
|
6
|
-
private tags: string[] = [];
|
7
|
-
private zoneId: string | null = null;
|
8
|
-
private referrer: string | null = null;
|
9
|
-
private customVariables: { [key: string]: string } = {};
|
10
|
-
private userToken: string | null = null;
|
11
|
-
private url: string | null = null;
|
12
|
-
|
13
8
|
// The constructor is private to force users to use the async `create` method.
|
14
|
-
private constructor(
|
15
|
-
|
9
|
+
private constructor() {
|
10
|
+
// This constructor is intentionally empty.
|
16
11
|
}
|
17
12
|
|
18
13
|
/**
|
19
14
|
* Creates and initializes a new PianoComposer instance.
|
20
|
-
* This is the entry point for using the library.
|
15
|
+
* This is the main entry point for using the library.
|
21
16
|
* @param aid Your Application ID from Piano.io
|
22
17
|
*/
|
23
18
|
static async create(aid: string): Promise<PianoComposer> {
|
24
|
-
|
25
|
-
|
19
|
+
// Call the corrected native initialize method
|
20
|
+
await SdkPianoio.initialize(aid);
|
21
|
+
return new PianoComposer();
|
26
22
|
}
|
27
23
|
|
28
24
|
// --- Configuration Methods ---
|
29
25
|
|
30
|
-
async addTag(tag: string) {
|
31
|
-
|
32
|
-
|
26
|
+
async addTag(tag: string): Promise<boolean> {
|
27
|
+
return SdkPianoio.addTag(tag);
|
28
|
+
}
|
29
|
+
|
30
|
+
async addTags(tags: string[]): Promise<boolean> {
|
31
|
+
return SdkPianoio.addTags(tags);
|
32
|
+
}
|
33
|
+
|
34
|
+
async setZoneId(zoneId: string): Promise<boolean> {
|
35
|
+
return SdkPianoio.setZoneId(zoneId);
|
36
|
+
}
|
37
|
+
|
38
|
+
async setReferrer(referrer: string): Promise<boolean> {
|
39
|
+
return SdkPianoio.setReferrer(referrer);
|
33
40
|
}
|
34
41
|
|
35
|
-
async
|
36
|
-
|
37
|
-
return SdkPianoio.addComposerTags(tags);
|
42
|
+
async setCustomVariable(name: string, value: string): Promise<boolean> {
|
43
|
+
return SdkPianoio.addCustomVariable(name, value);
|
38
44
|
}
|
39
45
|
|
40
|
-
async
|
41
|
-
|
42
|
-
return SdkPianoio.setComposerZoneId(zoneId);
|
46
|
+
async setCustomVariables(variables: { [key: string]: string }): Promise<boolean> {
|
47
|
+
return SdkPianoio.setCustomVariables(variables);
|
43
48
|
}
|
44
49
|
|
45
|
-
async
|
46
|
-
|
47
|
-
|
50
|
+
async setUserToken(token: string): Promise<boolean> {
|
51
|
+
return SdkPianoio.setUserToken(token);
|
52
|
+
}
|
53
|
+
|
54
|
+
async setUrl(url: string): Promise<boolean> {
|
55
|
+
return SdkPianoio.setUrl(url);
|
56
|
+
}
|
57
|
+
|
58
|
+
// --- Authentication Methods ---
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Signs in the user with Piano.
|
62
|
+
* @returns A promise that resolves with user information.
|
63
|
+
*/
|
64
|
+
async signIn(): Promise<any> {
|
65
|
+
return SdkPianoio.signIn();
|
48
66
|
}
|
49
67
|
|
50
|
-
|
51
|
-
|
52
|
-
|
68
|
+
/**
|
69
|
+
* Signs out the current user.
|
70
|
+
* @returns A promise that resolves when sign out is complete.
|
71
|
+
*/
|
72
|
+
async signOut(): Promise<any> {
|
73
|
+
return SdkPianoio.signOut();
|
53
74
|
}
|
54
75
|
|
55
|
-
|
56
|
-
|
57
|
-
|
76
|
+
/**
|
77
|
+
* Gets information about the current authenticated user.
|
78
|
+
* @returns A promise that resolves with user information.
|
79
|
+
*/
|
80
|
+
async getCurrentUser(): Promise<any> {
|
81
|
+
return SdkPianoio.getCurrentUser();
|
58
82
|
}
|
59
83
|
|
60
|
-
|
61
|
-
|
62
|
-
|
84
|
+
/**
|
85
|
+
* Checks if a user is currently authenticated.
|
86
|
+
* @returns A promise that resolves with the authentication status.
|
87
|
+
*/
|
88
|
+
async isAuthenticated(): Promise<any> {
|
89
|
+
return SdkPianoio.isAuthenticated();
|
63
90
|
}
|
64
91
|
|
65
92
|
// --- Core Execution Method ---
|
@@ -69,36 +96,26 @@ class PianoComposer {
|
|
69
96
|
* This is the primary method to get a decision from the Piano backend.
|
70
97
|
* @returns A promise that resolves with the event data object from the native SDK.
|
71
98
|
*/
|
72
|
-
async executeExperience() {
|
73
|
-
// This now correctly calls the native method AND returns the result.
|
99
|
+
async executeExperience(): Promise<any> {
|
74
100
|
return SdkPianoio.executeExperience();
|
75
101
|
}
|
76
102
|
|
77
|
-
// ---
|
103
|
+
// --- Utility and Cleanup Methods ---
|
78
104
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
static async getComposerFromSdkIOS() {
|
89
|
-
return SdkPianoio.getComposer();
|
105
|
+
/**
|
106
|
+
* Gets the current status of the SDK.
|
107
|
+
* @returns A promise that resolves with status information.
|
108
|
+
*/
|
109
|
+
async getStatus(): Promise<any> {
|
110
|
+
return SdkPianoio.getStatus();
|
90
111
|
}
|
91
112
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
customVariables: ${JSON.stringify(this.customVariables)},
|
99
|
-
userToken: ${this.userToken},
|
100
|
-
url: ${this.url}
|
101
|
-
}`;
|
113
|
+
/**
|
114
|
+
* Clears all configured tags and custom variables.
|
115
|
+
* @returns A promise that resolves when the configuration is cleared.
|
116
|
+
*/
|
117
|
+
async clearConfiguration(): Promise<boolean> {
|
118
|
+
return SdkPianoio.clearConfiguration();
|
102
119
|
}
|
103
120
|
}
|
104
121
|
|
package/src/index.tsx
CHANGED
@@ -1,16 +1,2 @@
|
|
1
|
-
// import SdkPianoio from './NativeSdkPianoio';
|
2
1
|
export { default as PianoComposer } from './PianoComposer';
|
3
2
|
export { debugNativeModule } from './debug';
|
4
|
-
|
5
|
-
// export const {
|
6
|
-
// initializeComposer,
|
7
|
-
// getComposer,
|
8
|
-
// addComposerTag,
|
9
|
-
// addComposerTags,
|
10
|
-
// setComposerZoneId,
|
11
|
-
// setComposerReferrer,
|
12
|
-
// setComposerUrl,
|
13
|
-
// setComposerCustomVariable,
|
14
|
-
// setComposerUserToken,
|
15
|
-
// executeComposer
|
16
|
-
// } = SdkPianoio;
|
@@ -1,70 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// TokenService.swift
|
3
|
-
// Pods
|
4
|
-
//
|
5
|
-
// Created by Alessia Sarak on 24.04.2025.
|
6
|
-
//
|
7
|
-
|
8
|
-
import PianoOAuth
|
9
|
-
|
10
|
-
public class TokenService: NSObject, PianoIDDelegate {
|
11
|
-
|
12
|
-
@Published private(set) var initialized = false
|
13
|
-
@Published private(set) var token: PianoIDToken?
|
14
|
-
|
15
|
-
public override init() {
|
16
|
-
/// Set Piano ID settings
|
17
|
-
PianoID.shared.endpoint = PianoEndpoint.sandbox
|
18
|
-
PianoID.shared.aid = ComposerPianoImpl.aid
|
19
|
-
|
20
|
-
super.init()
|
21
|
-
|
22
|
-
PianoID.shared.delegate = self
|
23
|
-
|
24
|
-
token = PianoID.shared.currentToken
|
25
|
-
request { [weak self] _ in
|
26
|
-
DispatchQueue.main.async {
|
27
|
-
self?.initialized = true
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
func request(completion: @escaping (PianoIDToken?) -> Void) {
|
33
|
-
if let t = token {
|
34
|
-
if t.isExpired {
|
35
|
-
/// Refresh token if expired
|
36
|
-
PianoID.shared.refreshToken(t.refreshToken) { token, error in
|
37
|
-
if let t = token {
|
38
|
-
self.token = t
|
39
|
-
completion(t)
|
40
|
-
return
|
41
|
-
}
|
42
|
-
completion(nil)
|
43
|
-
}
|
44
|
-
} else {
|
45
|
-
completion(t)
|
46
|
-
}
|
47
|
-
return
|
48
|
-
}
|
49
|
-
|
50
|
-
completion(nil)
|
51
|
-
}
|
52
|
-
|
53
|
-
/// Sign In callback
|
54
|
-
public func signIn(result: PianoIDSignInResult!, withError error: Error!) {
|
55
|
-
if let r = result {
|
56
|
-
token = r.token
|
57
|
-
} else {
|
58
|
-
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
/// Sign Out callback
|
63
|
-
public func signOut(withError error: Error!) {
|
64
|
-
token = nil
|
65
|
-
}
|
66
|
-
|
67
|
-
/// Cancel callback
|
68
|
-
public func cancel() {
|
69
|
-
}
|
70
|
-
}
|