@uniformdev/insights 20.7.1-alpha.102

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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Backend proxy handler for Uniform Insights API requests
3
+ * Designed for Node.js environments with proper fetch API types
4
+ */
5
+ interface BackendProxyConfig {
6
+ /** API host to proxy requests to (e.g., 'https://analytics.uniform.global') */
7
+ apiHost: string;
8
+ /** API key for authentication */
9
+ apiKey: string;
10
+ }
11
+ /**
12
+ * Backend proxy handler optimized for Node.js environments
13
+ * Only requires body since URL, headers, and method are determined by configuration
14
+ */
15
+ declare class BackendInsightsProxyHandler {
16
+ private config;
17
+ constructor(config: BackendProxyConfig);
18
+ /**
19
+ * Handle a proxy request with only the body payload
20
+ * @param body - The request body to forward
21
+ * @returns Promise resolving to the API response
22
+ */
23
+ handleRequest(originalBody: string): Promise<Response>;
24
+ }
25
+ /**
26
+ * Factory function to create a backend proxy handler
27
+ */
28
+ declare function createBackendInsightsProxyHandler(config: BackendProxyConfig): BackendInsightsProxyHandler;
29
+
30
+ export { BackendInsightsProxyHandler, type BackendProxyConfig, createBackendInsightsProxyHandler };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Backend proxy handler for Uniform Insights API requests
3
+ * Designed for Node.js environments with proper fetch API types
4
+ */
5
+ interface BackendProxyConfig {
6
+ /** API host to proxy requests to (e.g., 'https://analytics.uniform.global') */
7
+ apiHost: string;
8
+ /** API key for authentication */
9
+ apiKey: string;
10
+ }
11
+ /**
12
+ * Backend proxy handler optimized for Node.js environments
13
+ * Only requires body since URL, headers, and method are determined by configuration
14
+ */
15
+ declare class BackendInsightsProxyHandler {
16
+ private config;
17
+ constructor(config: BackendProxyConfig);
18
+ /**
19
+ * Handle a proxy request with only the body payload
20
+ * @param body - The request body to forward
21
+ * @returns Promise resolving to the API response
22
+ */
23
+ handleRequest(originalBody: string): Promise<Response>;
24
+ }
25
+ /**
26
+ * Factory function to create a backend proxy handler
27
+ */
28
+ declare function createBackendInsightsProxyHandler(config: BackendProxyConfig): BackendInsightsProxyHandler;
29
+
30
+ export { BackendInsightsProxyHandler, type BackendProxyConfig, createBackendInsightsProxyHandler };
package/dist/proxy.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/proxy.ts
21
+ var proxy_exports = {};
22
+ __export(proxy_exports, {
23
+ BackendInsightsProxyHandler: () => BackendInsightsProxyHandler,
24
+ createBackendInsightsProxyHandler: () => createBackendInsightsProxyHandler
25
+ });
26
+ module.exports = __toCommonJS(proxy_exports);
27
+ var BackendInsightsProxyHandler = class {
28
+ constructor(config) {
29
+ this.config = config;
30
+ }
31
+ /**
32
+ * Handle a proxy request with only the body payload
33
+ * @param body - The request body to forward
34
+ * @returns Promise resolving to the API response
35
+ */
36
+ async handleRequest(originalBody) {
37
+ try {
38
+ const targetUrl = new URL("/v0/events", this.config.apiHost);
39
+ targetUrl.searchParams.set("name", "events");
40
+ return fetch(targetUrl.toString(), {
41
+ method: "POST",
42
+ headers: {
43
+ Authorization: `Bearer ${this.config.apiKey}`,
44
+ "Content-Type": "application/x-ndjson",
45
+ Accept: "application/json"
46
+ },
47
+ body: originalBody
48
+ });
49
+ } catch (error) {
50
+ throw new Error(
51
+ `Backend proxy request failed: ${error instanceof Error ? error.message : "Unknown error"}`
52
+ );
53
+ }
54
+ }
55
+ };
56
+ function createBackendInsightsProxyHandler(config) {
57
+ return new BackendInsightsProxyHandler(config);
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ BackendInsightsProxyHandler,
62
+ createBackendInsightsProxyHandler
63
+ });
package/dist/proxy.mjs ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ BackendInsightsProxyHandler,
3
+ createBackendInsightsProxyHandler
4
+ } from "./chunk-FFLO523H.mjs";
5
+ export {
6
+ BackendInsightsProxyHandler,
7
+ createBackendInsightsProxyHandler
8
+ };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@uniformdev/insights",
3
+ "version": "20.7.1-alpha.102+d621aa22b2",
4
+ "description": "Uniform Context Insights package",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "node": "./dist/index.mjs",
13
+ "default": "./dist/index.esm.js"
14
+ },
15
+ "require": "./dist/index.js"
16
+ },
17
+ "./proxy": {
18
+ "import": {
19
+ "types": "./dist/proxy.d.mts",
20
+ "node": "./dist/proxy.mjs",
21
+ "default": "./dist/proxy.esm.js"
22
+ },
23
+ "require": "./dist/proxy.js"
24
+ }
25
+ },
26
+ "types": "./dist/index.d.ts",
27
+ "sideEffects": false,
28
+ "scripts": {
29
+ "build": "run-s build:ts",
30
+ "build:ts": "tsup",
31
+ "dev": "run-s dev:ts",
32
+ "dev:ts": "tsup --watch",
33
+ "clean": "rimraf dist",
34
+ "test": "vitest run",
35
+ "test:coverage": "vitest run --coverage",
36
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
37
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
38
+ "benchmark:build": "tsup src/storage/__benchmarks__/storage.benchmark.ts",
39
+ "benchmark:run": "node ./dist/storage.benchmark.js",
40
+ "document:prebuild": "api-extractor run --local"
41
+ },
42
+ "devDependencies": {
43
+ "@types/js-cookie": "3.0.6",
44
+ "@types/node": "^20.0.0",
45
+ "@types/uuid": "9.0.4",
46
+ "@vitest/coverage-v8": "3.2.4",
47
+ "benny": "3.7.1",
48
+ "vite": "^7.0.6",
49
+ "vite-tsconfig-paths": "^5.1.4",
50
+ "vitest": "3.2.4"
51
+ },
52
+ "dependencies": {
53
+ "@uniformdev/context": "20.7.1-alpha.102+d621aa22b2",
54
+ "p-limit": "3.1.0"
55
+ },
56
+ "files": [
57
+ "/dist"
58
+ ],
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "gitHead": "d621aa22b220347565e307b064fb1eda8963abbe"
63
+ }