@teardown/react-native 2.0.19 → 2.0.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/react-native",
3
- "version": "2.0.19",
3
+ "version": "2.0.22",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/.DS_Store ADDED
Binary file
@@ -39,7 +39,7 @@ export const UpdateVersionStatusBodySchema = z.object({
39
39
  export const SessionSchema = z.object({
40
40
  session_id: z.string(),
41
41
  device_id: z.string(),
42
- user_id: z.string(),
42
+ user_id: z.string().or(z.object({ persona_id: z.string() }).transform((val) => val.persona_id)),
43
43
  token: z.string(),
44
44
  });
45
45
  export type Session = z.infer<typeof SessionSchema>;
@@ -1,80 +1,72 @@
1
1
  import type { Logger, LoggingClient } from "../logging";
2
2
  import type { StorageAdapter, SupportedStorage } from "./adapters/storage.adpater-interface";
3
3
 
4
-
5
4
  export class StorageClient {
6
-
7
- private readonly logger: Logger;
8
-
9
- private readonly storage: Map<string, SupportedStorage> = new Map();
10
-
11
- private readonly preloadPromises: Promise<void>[] = [];
12
-
13
- private _isReady = false;
14
-
15
- get isReady(): boolean {
16
- return this._isReady;
17
- }
18
-
19
- constructor(
20
- logging: LoggingClient,
21
- private readonly orgId: string,
22
- private readonly projectId: string,
23
- private readonly storageAdapter: StorageAdapter) {
24
- this.logger = logging.createLogger({
25
- name: "StorageClient",
26
- });
27
- }
28
-
29
- private createStorageKey(storageKey: string): string {
30
- return `teardown:v1:${this.orgId}:${this.projectId}:${storageKey}`;
31
- }
32
-
33
- createStorage(storageKey: string): SupportedStorage {
34
- const fullStorageKey = this.createStorageKey(storageKey);
35
-
36
- this.logger.debug(`Creating storage for ${fullStorageKey}`);
37
- if (this.storage.has(fullStorageKey)) {
38
- this.logger.debug(`Storage already exists for ${fullStorageKey}`);
39
- const existingStorage = this.storage.get(fullStorageKey);
40
-
41
- if (existingStorage != null) {
42
- this.logger.debug(`Returning existing storage for ${fullStorageKey}`);
43
- return existingStorage;
44
- }
45
-
46
- this.logger.error(`Existing storage was found for ${fullStorageKey}, but it was null`);
47
- }
48
-
49
- this.logger.debug(`Creating new storage for ${fullStorageKey}`);
50
- const newStorage = this.storageAdapter.createStorage(fullStorageKey);
51
- const preloadResult = newStorage.preload();
52
- if (preloadResult instanceof Promise) {
53
- this.preloadPromises.push(preloadResult);
54
- }
55
-
56
- const remappedStorage = {
57
- ...newStorage,
58
- clear: () => {
59
- this.storage.delete(fullStorageKey);
60
- },
61
- }
62
-
63
- this.storage.set(fullStorageKey, remappedStorage);
64
- this.logger.debug(`Storage created for ${fullStorageKey}`);
65
-
66
- return remappedStorage;
67
- }
68
-
69
- async whenReady(): Promise<void> {
70
- await Promise.all(this.preloadPromises);
71
- this._isReady = true;
72
- }
73
-
74
- shutdown(): void {
75
- this.storage.forEach((storage) => {
76
- storage.clear();
77
- });
78
- this.storage.clear();
79
- }
80
- }
5
+ private readonly logger: Logger;
6
+
7
+ private readonly storage: Map<string, SupportedStorage> = new Map();
8
+
9
+ private readonly preloadPromises: Promise<void>[] = [];
10
+
11
+ private _isReady = false;
12
+
13
+ get isReady(): boolean {
14
+ return this._isReady;
15
+ }
16
+
17
+ constructor(
18
+ logging: LoggingClient,
19
+ private readonly orgId: string,
20
+ private readonly projectId: string,
21
+ private readonly storageAdapter: StorageAdapter
22
+ ) {
23
+ this.logger = logging.createLogger({
24
+ name: "StorageClient",
25
+ });
26
+ }
27
+
28
+ private createStorageKey(storageKey: string): string {
29
+ return `teardown:v1:${this.orgId}:${this.projectId}:${storageKey}`;
30
+ }
31
+
32
+ createStorage(storageKey: string): SupportedStorage {
33
+ const fullStorageKey = this.createStorageKey(storageKey);
34
+
35
+ this.logger.debug(`Creating storage for ${fullStorageKey}`);
36
+ if (this.storage.has(fullStorageKey)) {
37
+ this.logger.debug(`Storage already exists for ${fullStorageKey}`);
38
+ const existingStorage = this.storage.get(fullStorageKey);
39
+
40
+ if (existingStorage != null) {
41
+ this.logger.debug(`Returning existing storage for ${fullStorageKey}`);
42
+ return existingStorage;
43
+ }
44
+
45
+ this.logger.error(`Existing storage was found for ${fullStorageKey}, but it was null`);
46
+ }
47
+
48
+ this.logger.debug(`Creating new storage for ${fullStorageKey}`);
49
+ const newStorage = this.storageAdapter.createStorage(fullStorageKey);
50
+ const preloadResult = newStorage.preload();
51
+ if (preloadResult instanceof Promise) {
52
+ this.preloadPromises.push(preloadResult);
53
+ }
54
+
55
+ const remappedStorage = {
56
+ ...newStorage,
57
+ clear: () => {
58
+ this.storage.delete(fullStorageKey);
59
+ },
60
+ };
61
+
62
+ this.storage.set(fullStorageKey, remappedStorage);
63
+ this.logger.debug(`Storage created for ${fullStorageKey}`);
64
+
65
+ return remappedStorage;
66
+ }
67
+
68
+ async whenReady(): Promise<void> {
69
+ await Promise.all(this.preloadPromises);
70
+ this._isReady = true;
71
+ }
72
+ }
@@ -85,6 +85,5 @@ export class TeardownCore {
85
85
 
86
86
  shutdown(): void {
87
87
  this.logger.debug("Shutting down TeardownCore");
88
- this.storage.shutdown();
89
88
  }
90
89
  }