-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into develop
- Loading branch information
Showing
85 changed files
with
1,975 additions
and
1,248 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,13 @@ | |
|
||
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). | ||
|
||
## [3.14.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-12-17) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* remove circular dependency in packages ([#1973](https://github.com/rudderlabs/rudder-sdk-js/issues/1973)) ([e525496](https://github.com/rudderlabs/rudder-sdk-js/commit/e5254964310c2c73baaf4d0655c3e4025c5e7d2b)) | ||
|
||
## [3.14.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-12-06) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
## [3.14.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].12...@rudderstack/[email protected].13) (2024-12-06) | ||
## [3.14.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].13...@rudderstack/[email protected].14) (2024-12-17) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* integration constants file type ([#1958](https://github.com/rudderlabs/rudder-sdk-js/issues/1958)) ([e0f6ff2](https://github.com/rudderlabs/rudder-sdk-js/commit/e0f6ff28f3b02d56e862e01d308653e2178eec43)) | ||
* remove circular dependency in packages ([#1973](https://github.com/rudderlabs/rudder-sdk-js/issues/1973)) ([e525496](https://github.com/rudderlabs/rudder-sdk-js/commit/e5254964310c2c73baaf4d0655c3e4025c5e7d2b)) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class BufferQueue<T> { | ||
items: T[] = []; | ||
enqueue = jest.fn(); | ||
dequeue = jest.fn(); | ||
isEmpty = jest.fn(); | ||
size = jest.fn(); | ||
clear = jest.fn(); | ||
} | ||
|
||
export { BufferQueue }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { IErrorHandler, PreLoadErrorData } from '../src/types/ErrorHandler'; | ||
import { BufferQueue } from './BufferQueue'; | ||
|
||
// Mock all the methods of the ErrorHandler class | ||
class ErrorHandler implements IErrorHandler { | ||
onError = jest.fn(); | ||
leaveBreadcrumb = jest.fn(); | ||
notifyError = jest.fn(); | ||
init = jest.fn(); | ||
attachErrorListeners = jest.fn(); | ||
errorBuffer = new BufferQueue<PreLoadErrorData>(); | ||
} | ||
|
||
const defaultErrorHandler = new ErrorHandler(); | ||
|
||
export { ErrorHandler, defaultErrorHandler }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { ILogger } from '../src/types/Logger'; | ||
|
||
class Logger implements ILogger { | ||
warn = jest.fn(); | ||
log = jest.fn(); | ||
error = jest.fn(); | ||
info = jest.fn(); | ||
debug = jest.fn(); | ||
minLogLevel = 0; | ||
scope = 'test scope'; | ||
setMinLogLevel = jest.fn(); | ||
setScope = jest.fn(); | ||
logProvider = console; | ||
} | ||
|
||
const defaultLogger = new Logger(); | ||
|
||
export { Logger, defaultLogger }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { cookie } from '../src/component-cookie'; | ||
import type { Nullable } from '../src/types/Nullable'; | ||
import type { IStorage } from '../src/types/Store'; | ||
import store from 'storejs'; | ||
|
||
class LocalStorage implements IStorage { | ||
keys = () => { | ||
return store.keys(); | ||
}; | ||
isEnabled = true; | ||
getItem = (key: string) => { | ||
return store.get(key) ?? null; | ||
}; | ||
setItem = (key: string, value: any) => { | ||
store.set(key, value); | ||
}; | ||
removeItem = (key: string) => store.remove(key); | ||
clear = () => { | ||
store.clear(); | ||
}; | ||
length = store.len(); | ||
key = (idx: number): Nullable<string> => { | ||
return this.keys()[idx] ?? null; | ||
}; | ||
} | ||
|
||
/** | ||
* A storage utility to retain values in memory via Storage interface | ||
*/ | ||
class InMemoryStorage implements IStorage { | ||
isEnabled = true; | ||
length = 0; | ||
data: Record<string, any> = {}; | ||
|
||
setItem(key: string, value: any): any { | ||
this.data[key] = value; | ||
this.length = Object.keys(this.data).length; | ||
return value; | ||
} | ||
|
||
getItem(key: string): any { | ||
if (key in this.data) { | ||
return this.data[key]; | ||
} | ||
return null; | ||
} | ||
|
||
removeItem(key: string) { | ||
if (key in this.data) { | ||
delete this.data[key]; | ||
} | ||
this.length = Object.keys(this.data).length; | ||
return null; | ||
} | ||
|
||
clear() { | ||
this.data = {}; | ||
this.length = 0; | ||
} | ||
|
||
key(index: number): Nullable<string> { | ||
const curKeys = this.keys(); | ||
return curKeys[index] ?? null; | ||
} | ||
|
||
keys(): string[] { | ||
return Object.keys(this.data); | ||
} | ||
} | ||
|
||
class CookieStorage implements IStorage { | ||
keys = () => { | ||
return Object.keys(cookie()); | ||
}; | ||
|
||
isEnabled = true; | ||
|
||
getItem = (key: string) => { | ||
const value = cookie(key); | ||
return value ?? null; | ||
}; | ||
|
||
setItem = (key: string, value: any) => { | ||
cookie(key, value); | ||
this.length = Object.keys(cookie()).length; | ||
}; | ||
|
||
removeItem = (key: string) => { | ||
const result = this.setItem(key, null); | ||
this.length = Object.keys(cookie()).length; | ||
return result; | ||
}; | ||
|
||
clear = () => { | ||
// Not implemented | ||
}; | ||
|
||
length = Object.keys(cookie()).length; | ||
|
||
key = (idx: number): Nullable<string> => { | ||
const curKeys = this.keys(); | ||
return curKeys[idx] ?? null; | ||
}; | ||
} | ||
|
||
const defaultCookieStorage = new CookieStorage(); | ||
|
||
export { CookieStorage, defaultCookieStorage }; | ||
|
||
const defaultInMemoryStorage = new InMemoryStorage(); | ||
|
||
export { InMemoryStorage, defaultInMemoryStorage }; | ||
|
||
const defaultLocalStorage = new LocalStorage(); | ||
|
||
export { LocalStorage, defaultLocalStorage }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { IStore, IStoreConfig } from '../src/types/Store'; | ||
import { defaultInMemoryStorage, defaultLocalStorage } from './Storage'; | ||
|
||
// Mock all the methods of the Store class | ||
|
||
class Store implements IStore { | ||
constructor(config: IStoreConfig, engine?: any) { | ||
this.id = config.id; | ||
this.name = config.name; | ||
this.isEncrypted = config.isEncrypted ?? false; | ||
this.validKeys = config.validKeys ?? {}; | ||
this.engine = engine ?? defaultLocalStorage; | ||
this.originalEngine = this.engine; | ||
} | ||
id = 'test'; | ||
name = 'test'; | ||
isEncrypted = false; | ||
validKeys: Record<string, string>; | ||
engine = defaultLocalStorage; | ||
originalEngine = defaultLocalStorage; | ||
createValidKey = (key: string) => { | ||
return [this.name, this.id, key].join('.'); | ||
}; | ||
swapQueueStoreToInMemoryEngine = () => { | ||
this.engine.keys().forEach((key: string) => { | ||
const value = this.engine.getItem(key); | ||
defaultInMemoryStorage.setItem(key, value); | ||
}); | ||
|
||
this.engine = defaultInMemoryStorage; | ||
}; | ||
set = (key: string, value: any) => { | ||
const validKey = this.createValidKey(key); | ||
this.engine.setItem(validKey, value); | ||
}; | ||
get = (key: string) => { | ||
const validKey = this.createValidKey(key); | ||
return this.engine.getItem(validKey); | ||
}; | ||
remove = (key: string) => { | ||
const validKey = this.createValidKey(key); | ||
this.engine.removeItem(validKey); | ||
}; | ||
clear = () => { | ||
this.engine.clear(); | ||
}; | ||
onError = jest.fn(); | ||
crypto = jest.fn(); | ||
encrypt = jest.fn(); | ||
decrypt = jest.fn(); | ||
getOriginalEngine = () => this.originalEngine; | ||
} | ||
|
||
const defaultStore = new Store({ id: 'test', name: 'test' }); | ||
|
||
export { Store, defaultStore }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { IStoreConfig, IStoreManager } from '../src/types/Store'; | ||
import { defaultCookieStorage, defaultInMemoryStorage, defaultLocalStorage } from './Storage'; | ||
import { defaultStore, Store } from './Store'; | ||
|
||
// Mock all the methods of the StoreManager class | ||
|
||
class StoreManager implements IStoreManager { | ||
init = jest.fn(); | ||
setStore = (config: IStoreConfig) => { | ||
let storageEngine; | ||
switch (config.type) { | ||
case 'localStorage': | ||
storageEngine = defaultLocalStorage; | ||
break; | ||
case 'cookieStorage': | ||
storageEngine = defaultCookieStorage; | ||
break; | ||
case 'memoryStorage': | ||
default: | ||
storageEngine = defaultInMemoryStorage; | ||
break; | ||
} | ||
|
||
return new Store(config, storageEngine); | ||
}; | ||
getStore = jest.fn(() => defaultStore); | ||
initializeStorageState = jest.fn(); | ||
} | ||
|
||
const defaultStoreManager = new StoreManager(); | ||
|
||
export { StoreManager, defaultStoreManager }; |
Oops, something went wrong.