@altcraft/react-native-sdk 0.0.5 → 1.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.
Files changed (52) hide show
  1. package/README.md +21 -120
  2. package/autolink.js +36 -0
  3. package/lib/commonjs/altcraft_sdk.js +297 -0
  4. package/lib/commonjs/altcraft_sdk.js.map +1 -0
  5. package/lib/commonjs/index.js +192 -0
  6. package/lib/commonjs/index.js.map +1 -0
  7. package/lib/commonjs/package.json +1 -0
  8. package/lib/module/altcraft_sdk.js +292 -0
  9. package/lib/module/altcraft_sdk.js.map +1 -0
  10. package/lib/module/index.js +13 -427
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/commonjs/package.json +1 -0
  13. package/lib/typescript/commonjs/src/altcraft_sdk.d.ts +143 -0
  14. package/lib/typescript/commonjs/src/altcraft_sdk.d.ts.map +1 -0
  15. package/lib/typescript/commonjs/src/index.d.ts +24 -0
  16. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  17. package/lib/typescript/module/src/altcraft_sdk.d.ts +143 -0
  18. package/lib/typescript/module/src/altcraft_sdk.d.ts.map +1 -0
  19. package/lib/typescript/module/src/index.d.ts +24 -0
  20. package/lib/typescript/module/src/index.d.ts.map +1 -0
  21. package/package.json +49 -95
  22. package/scripts/postinstall.cjs +195 -0
  23. package/src/altcraft_sdk.ts +337 -0
  24. package/src/index.ts +91 -0
  25. package/Sdk.podspec +0 -48
  26. package/android/build.gradle +0 -77
  27. package/android/gradle.properties +0 -5
  28. package/android/src/main/AndroidManifest.xml +0 -2
  29. package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +0 -55
  30. package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +0 -993
  31. package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +0 -41
  32. package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +0 -326
  33. package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +0 -72
  34. package/ios/Converter.swift +0 -640
  35. package/ios/Sdk.h +0 -20
  36. package/ios/Sdk.mm +0 -979
  37. package/ios/SdkModule.swift +0 -778
  38. package/lib/module/NativeSdk.js +0 -48
  39. package/lib/module/NativeSdk.js.map +0 -1
  40. package/lib/module/Utilities.js +0 -178
  41. package/lib/module/Utilities.js.map +0 -1
  42. package/lib/typescript/src/NativeSdk.d.ts +0 -215
  43. package/lib/typescript/src/NativeSdk.d.ts.map +0 -1
  44. package/lib/typescript/src/Utilities.d.ts +0 -47
  45. package/lib/typescript/src/Utilities.d.ts.map +0 -1
  46. package/lib/typescript/src/index.d.ts +0 -252
  47. package/lib/typescript/src/index.d.ts.map +0 -1
  48. package/react-native.config.js +0 -10
  49. package/src/NativeSdk.ts +0 -313
  50. package/src/Utilities.ts +0 -180
  51. package/src/index.tsx +0 -570
  52. /package/lib/typescript/{package.json → module/package.json} +0 -0
package/src/Utilities.ts DELETED
@@ -1,180 +0,0 @@
1
- import type { Subscription } from './NativeSdk';
2
-
3
- /** Supported action types for profile field manipulation. */
4
- export type ActionFieldType =
5
- | 'set'
6
- | 'unset'
7
- | 'incr'
8
- | 'add'
9
- | 'delete'
10
- | 'upsert';
11
-
12
- /**
13
- * Builder for structured profile field actions.
14
- *
15
- * Produces a map entry compatible with the native SDK's ActionFieldBuilder.
16
- * The resulting map is intended to be merged into `profileFields` before
17
- * passing to `pushSubscribe`, `updateProfileFields`, or similar APIs.
18
- */
19
- export class ActionFieldBuilder {
20
- private key: string;
21
-
22
- constructor(key: string) {
23
- this.key = key;
24
- }
25
-
26
- /** Set field to a specific value. */
27
- set(value: unknown): Record<string, unknown> {
28
- return { [this.key]: { action: 'set', value } };
29
- }
30
-
31
- /** Unset (remove) a field value. */
32
- unset(value: unknown): Record<string, unknown> {
33
- return { [this.key]: { action: 'unset', value } };
34
- }
35
-
36
- /** Increment a numeric field by the given value. */
37
- incr(value: unknown): Record<string, unknown> {
38
- return { [this.key]: { action: 'incr', value } };
39
- }
40
-
41
- /** Add a value to a set/array field. */
42
- add(value: unknown): Record<string, unknown> {
43
- return { [this.key]: { action: 'add', value } };
44
- }
45
-
46
- /** Delete a value from a set/array field. */
47
- delete(value: unknown): Record<string, unknown> {
48
- return { [this.key]: { action: 'delete', value } };
49
- }
50
-
51
- /** Upsert: set if missing, update if exists. */
52
- upsert(value: unknown): Record<string, unknown> {
53
- return { [this.key]: { action: 'upsert', value } };
54
- }
55
- }
56
-
57
- /**
58
- * Creates an ActionFieldBuilder for the given field key.
59
- *
60
- * @param key Profile field key to operate on.
61
- * @returns Builder instance with action methods.
62
- */
63
- export function actionField(key: string): ActionFieldBuilder {
64
- return new ActionFieldBuilder(key);
65
- }
66
-
67
- export class Utilities {
68
- /** Converts a JS object to { [key: string]: string }
69
- * for the RN bridge; drops null/undefined. */
70
- static toNativeStringMap(
71
- input: Record<string, unknown> | null
72
- ): Record<string, string> | null {
73
- if (input == null) return null;
74
-
75
- const out: Record<string, string> = {};
76
-
77
- for (const [key, value] of Object.entries(input)) {
78
- if (value == null) continue;
79
-
80
- switch (typeof value) {
81
- case 'string':
82
- out[key] = value;
83
- break;
84
-
85
- case 'number':
86
- case 'boolean':
87
- case 'bigint':
88
- out[key] = String(value);
89
- break;
90
-
91
- default:
92
- try {
93
- out[key] = JSON.stringify(value);
94
- } catch {
95
- out[key] = String(value);
96
- }
97
- break;
98
- }
99
- }
100
-
101
- return Object.keys(out).length > 0 ? out : null;
102
- }
103
-
104
- /**
105
- * New Arch safe:
106
- * TurboModule codegen does NOT support `any`.
107
- * Therefore, we serialize any value for UserDefaults into `string`.
108
- */
109
- static toUserDefaultsString(value: unknown): string | null {
110
- if (value == null) return null;
111
-
112
- const t = typeof value;
113
-
114
- if (t === 'string') return String(value);
115
- if (t === 'number' || t === 'boolean') return String(value);
116
-
117
- try {
118
- return JSON.stringify(value);
119
- } catch {
120
- return String(value);
121
- }
122
- }
123
-
124
- /** Converts Subscription object to native string map format. */
125
- static subscriptionToNativeMap(
126
- subscription: Subscription | null
127
- ): Record<string, string> | null {
128
- if (subscription == null) return null;
129
-
130
- const result: Record<string, string> = {
131
- type: subscription.type,
132
- resource_id: String(subscription.resource_id),
133
- };
134
-
135
- if (subscription.status != null) result.status = subscription.status;
136
- if (subscription.priority != null)
137
- result.priority = String(subscription.priority);
138
-
139
- if (subscription.custom_fields != null) {
140
- try {
141
- result.custom_fields = JSON.stringify(subscription.custom_fields);
142
- } catch {
143
- result.custom_fields = '{}';
144
- }
145
- }
146
-
147
- if (subscription.cats != null) {
148
- try {
149
- result.cats = JSON.stringify(subscription.cats);
150
- } catch {
151
- result.cats = '[]';
152
- }
153
- }
154
-
155
- switch (subscription.type) {
156
- case 'email':
157
- result.email = subscription.email;
158
- break;
159
-
160
- case 'sms':
161
- result.phone = subscription.phone;
162
- break;
163
-
164
- case 'push':
165
- result.provider = subscription.provider;
166
- result.subscription_id = subscription.subscription_id;
167
- break;
168
-
169
- case 'cc_data':
170
- try {
171
- result.cc_data = JSON.stringify(subscription.cc_data);
172
- } catch {
173
- result.cc_data = '{}';
174
- }
175
- break;
176
- }
177
-
178
- return result;
179
- }
180
- }