feat!: @rudder/sdk 0.1.0: createClient, idempotent modules.call retries, storage save(type, data), drop resources and projectStorage
This commit is contained in:
+7
-1
@@ -1,4 +1,5 @@
|
||||
import type { ResolvedRudderClientOptions } from '../client/RudderClientOptions.js';
|
||||
import type { RequestOptions } from '../transport/request.js';
|
||||
|
||||
/**
|
||||
* RudderContext — the low-level surface every feature service depends on:
|
||||
@@ -10,5 +11,10 @@ import type { ResolvedRudderClientOptions } from '../client/RudderClientOptions.
|
||||
*/
|
||||
export interface RudderContext {
|
||||
readonly options: ResolvedRudderClientOptions;
|
||||
request<TResponse>(method: string, path: string, body?: unknown): Promise<TResponse>;
|
||||
request<TResponse>(
|
||||
method: string,
|
||||
path: string,
|
||||
body?: unknown,
|
||||
options?: RequestOptions,
|
||||
): Promise<TResponse>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/** UUID v4. Falls back to getRandomValues where randomUUID is missing (non-secure contexts, old runtimes). */
|
||||
export function uuidv4(): string {
|
||||
if (typeof crypto.randomUUID === 'function') return crypto.randomUUID();
|
||||
const b = crypto.getRandomValues(new Uint8Array(16));
|
||||
b[6] = (b[6] & 0x0f) | 0x40;
|
||||
b[8] = (b[8] & 0x3f) | 0x80;
|
||||
const h = Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
|
||||
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user