@seekora-ai/search-sdk 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.
- package/README.md +213 -0
- package/cdn/.htaccess +37 -0
- package/cdn/README.md +130 -0
- package/cdn/_headers +25 -0
- package/cdn/example.html +299 -0
- package/cdn/seekora-sdk.js +4651 -0
- package/cdn/seekora-sdk.min.js +17 -0
- package/cdn/ui-sdk-integration-example.html +183 -0
- package/dist/cdn.d.ts +16 -0
- package/dist/cdn.js +26 -0
- package/dist/client.d.ts +401 -0
- package/dist/client.js +991 -0
- package/dist/config-loader.d.ts +43 -0
- package/dist/config-loader.js +147 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.js +58 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +40 -0
- package/dist/logger.d.ts +61 -0
- package/dist/logger.js +172 -0
- package/dist/src/cdn.d.ts +16 -0
- package/dist/src/cdn.js +26 -0
- package/dist/src/client.d.ts +401 -0
- package/dist/src/client.js +991 -0
- package/dist/src/config-loader.d.ts +43 -0
- package/dist/src/config-loader.js +147 -0
- package/dist/src/config.d.ts +22 -0
- package/dist/src/config.js +58 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +40 -0
- package/dist/src/logger.d.ts +61 -0
- package/dist/src/logger.js +172 -0
- package/dist/src/utils.d.ts +20 -0
- package/dist/src/utils.js +73 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +73 -0
- package/package.json +47 -0
package/dist/utils.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for the Seekora SDK
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateUUID = generateUUID;
|
|
7
|
+
exports.getOrCreateAnonId = getOrCreateAnonId;
|
|
8
|
+
exports.getOrCreateSessionId = getOrCreateSessionId;
|
|
9
|
+
// Browser environment types are handled via typeof checks and type assertions
|
|
10
|
+
/**
|
|
11
|
+
* Generate a UUID v4
|
|
12
|
+
* Uses crypto.randomUUID() if available, otherwise falls back to manual generation
|
|
13
|
+
*/
|
|
14
|
+
function generateUUID() {
|
|
15
|
+
// Use native crypto.randomUUID() if available (Node.js 14.17+, modern browsers)
|
|
16
|
+
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) {
|
|
17
|
+
return crypto.randomUUID();
|
|
18
|
+
}
|
|
19
|
+
// Fallback for older environments
|
|
20
|
+
// Simplified UUID v4 generation
|
|
21
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
22
|
+
const r = Math.random() * 16 | 0;
|
|
23
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
24
|
+
return v.toString(16);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get or create anonymous ID from storage
|
|
29
|
+
* In browser: uses localStorage
|
|
30
|
+
* In Node.js: uses a simple in-memory store (consider file-based storage for production)
|
|
31
|
+
*/
|
|
32
|
+
function getOrCreateAnonId() {
|
|
33
|
+
// Check for browser environment
|
|
34
|
+
if (typeof window !== 'undefined' && window?.localStorage) {
|
|
35
|
+
const key = 'seekora_anon_id';
|
|
36
|
+
const storage = window.localStorage;
|
|
37
|
+
let anonId = storage.getItem(key);
|
|
38
|
+
if (!anonId) {
|
|
39
|
+
anonId = generateUUID();
|
|
40
|
+
storage.setItem(key, anonId);
|
|
41
|
+
}
|
|
42
|
+
return anonId;
|
|
43
|
+
}
|
|
44
|
+
// Node.js environment - use in-memory storage
|
|
45
|
+
// For production Node.js apps, consider using a file-based storage
|
|
46
|
+
if (!global.__seekora_anon_id) {
|
|
47
|
+
global.__seekora_anon_id = generateUUID();
|
|
48
|
+
}
|
|
49
|
+
return global.__seekora_anon_id;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get or create session ID
|
|
53
|
+
* In browser: uses sessionStorage
|
|
54
|
+
* In Node.js: uses a simple in-memory store (session ends when process ends)
|
|
55
|
+
*/
|
|
56
|
+
function getOrCreateSessionId() {
|
|
57
|
+
// Check for browser environment
|
|
58
|
+
if (typeof window !== 'undefined' && window?.sessionStorage) {
|
|
59
|
+
const key = 'seekora_session_id';
|
|
60
|
+
const storage = window.sessionStorage;
|
|
61
|
+
let sessionId = storage.getItem(key);
|
|
62
|
+
if (!sessionId) {
|
|
63
|
+
sessionId = generateUUID();
|
|
64
|
+
storage.setItem(key, sessionId);
|
|
65
|
+
}
|
|
66
|
+
return sessionId;
|
|
67
|
+
}
|
|
68
|
+
// Node.js environment - use in-memory storage
|
|
69
|
+
if (!global.__seekora_session_id) {
|
|
70
|
+
global.__seekora_session_id = generateUUID();
|
|
71
|
+
}
|
|
72
|
+
return global.__seekora_session_id;
|
|
73
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seekora-ai/search-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Seekora Search SDK for JavaScript/TypeScript",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"cdn",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc && npm run build:copy-generated",
|
|
14
|
+
"build:copy-generated": "rm -rf dist/generated && mkdir -p dist/generated && cp generated/*.{js,d.ts,ts} dist/generated/ 2>/dev/null || true && rm -f dist/generated/package.json",
|
|
15
|
+
"build:cdn": "npm run build && node scripts/build-cdn.js",
|
|
16
|
+
"build:cdn:prod": "NODE_ENV=production npm run build:cdn",
|
|
17
|
+
"prepack": "npm run build",
|
|
18
|
+
"pack": "npm run build && npm pack",
|
|
19
|
+
"link": "npm run build && npm link",
|
|
20
|
+
"test": "node test/test.js",
|
|
21
|
+
"test:comprehensive": "node test/comprehensive-test.js",
|
|
22
|
+
"test:config": "node test/full-config-test-suite.js",
|
|
23
|
+
"test:config-impact": "node test/config-verification-test.js",
|
|
24
|
+
"test:all": "npm run test:comprehensive && npm run test:config",
|
|
25
|
+
"demo": "node demo/server.js",
|
|
26
|
+
"demo:dev": "node demo/server.js"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"seekora",
|
|
30
|
+
"search",
|
|
31
|
+
"sdk"
|
|
32
|
+
],
|
|
33
|
+
"author": "Seekora",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@fingerprintjs/fingerprintjs": "^5.0.1",
|
|
37
|
+
"axios": "^1.6.0"
|
|
38
|
+
},
|
|
39
|
+
"optionalDependencies": {
|
|
40
|
+
"winston": "^3.11.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"esbuild": "^0.19.12",
|
|
45
|
+
"typescript": "^5.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|