@rubixstudios/payload-typesense 1.0.5 → 1.0.7
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
CHANGED
|
@@ -4,6 +4,14 @@ This plugin is a fork of FrontTribe's Typesense Search Plugin for Payload CMS…
|
|
|
4
4
|
|
|
5
5
|
A production-ready search plugin that integrates Typesense with Payload CMS, offering fast, typo-tolerant search with real-time synchronization. This fork by Rubix Studios reduces bloat and introduces targeted changes for improved performance, maintainability, and flexibility.
|
|
6
6
|
|
|
7
|
+
[](https://packagephobia.com/result?p=@rubixstudios/payload-typesense)
|
|
8
|
+
**PayloadCMS + Typesense Plugin**
|
|
9
|
+
|
|
10
|
+
[](https://packagephobia.com/result?p=typesense-search-plugin)
|
|
11
|
+
**FrontTribe's Typesense Search Plugin**
|
|
12
|
+
|
|
13
|
+
This fork offers the same functionality as the original plugin but with fewer bugs, improved TypeScript type safety, no Vercel errors, additional usability features, and a smaller footprint.
|
|
14
|
+
|
|
7
15
|
[](https://www.npmjs.com/package/@rubixstudios/payload-typesense)
|
|
8
16
|

|
|
9
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Typesense from "typesense";
|
|
2
2
|
import type { TypesenseSearchConfig } from "../index.js";
|
|
3
|
-
export declare const createTypesenseClient: (typesenseConfig: TypesenseSearchConfig["typesense"]) =>
|
|
4
|
-
export declare const testTypesenseConnection: (
|
|
3
|
+
export declare const createTypesenseClient: (typesenseConfig: TypesenseSearchConfig["typesense"]) => Typesense.Client;
|
|
4
|
+
export declare const testTypesenseConnection: (c: Typesense.Client) => Promise<boolean>;
|
|
5
5
|
//# sourceMappingURL=typesense-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesense-client.d.ts","sourceRoot":"","sources":["../../src/lib/typesense-client.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"typesense-client.d.ts","sourceRoot":"","sources":["../../src/lib/typesense-client.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAiDxD,eAAO,MAAM,qBAAqB,GACjC,iBAAiB,qBAAqB,CAAC,WAAW,CAAC,KACjD,SAAS,CAAC,MAoBZ,CAAA;AAED,eAAO,MAAM,uBAAuB,GACnC,GAAG,SAAS,CAAC,MAAM,KACjB,OAAO,CAAC,OAAO,CAQjB,CAAA"}
|
|
@@ -1,31 +1,66 @@
|
|
|
1
1
|
import Typesense from "typesense";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
let client = null;
|
|
3
|
+
const isOffline = ()=>{
|
|
4
|
+
const evt = process.env.npm_lifecycle_event || "";
|
|
5
|
+
if (evt.includes("build") || evt === "tsc") {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (process.argv.some((a)=>/(?:^|:|\/)(?:build|tsc)(?::|$)/i.test(a))) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (process.env.CI === "true") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
const createOfflineClient = ()=>{
|
|
17
|
+
return {
|
|
18
|
+
analytics: {
|
|
19
|
+
retrieve: ()=>{
|
|
20
|
+
return Promise.reject(new Error("Typesense offline"));
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
collections: ()=>{
|
|
24
|
+
return {
|
|
25
|
+
retrieve: ()=>{
|
|
26
|
+
return Promise.reject(new Error("Typesense offline"));
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
health: {
|
|
31
|
+
retrieve: ()=>{
|
|
32
|
+
return Promise.reject(new Error("Typesense offline"));
|
|
13
33
|
}
|
|
14
|
-
}
|
|
34
|
+
},
|
|
35
|
+
operations: {
|
|
36
|
+
get: ()=>{
|
|
37
|
+
return Promise.reject(new Error("Typesense offline"));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export const createTypesenseClient = (typesenseConfig)=>{
|
|
43
|
+
if (client) {
|
|
44
|
+
return client;
|
|
45
|
+
}
|
|
46
|
+
if (isOffline()) {
|
|
47
|
+
client = createOfflineClient();
|
|
48
|
+
return client;
|
|
15
49
|
}
|
|
16
|
-
|
|
50
|
+
client = new Typesense.Client({
|
|
17
51
|
apiKey: typesenseConfig.apiKey,
|
|
18
52
|
connectionTimeoutSeconds: typesenseConfig.connectionTimeoutSeconds || 2,
|
|
19
53
|
nodes: typesenseConfig.nodes.map((node)=>({
|
|
20
54
|
...node,
|
|
21
|
-
port: typeof node.port === "string" ? parseInt(node.port) : node.port
|
|
55
|
+
port: typeof node.port === "string" ? parseInt(node.port, 10) : node.port
|
|
22
56
|
}))
|
|
23
57
|
});
|
|
58
|
+
return client;
|
|
24
59
|
};
|
|
25
|
-
export const testTypesenseConnection = async (
|
|
60
|
+
export const testTypesenseConnection = async (c)=>{
|
|
26
61
|
try {
|
|
27
|
-
await
|
|
28
|
-
return true;
|
|
62
|
+
const res = await c.health.retrieve();
|
|
63
|
+
return typeof res?.ok === "boolean" ? !!res.ok : true;
|
|
29
64
|
} catch {
|
|
30
65
|
return false;
|
|
31
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubixstudios/payload-typesense",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "A production-ready search plugin that integrates Typesense with Payload CMS, offering fast, typo-tolerant search with real-time synchronization. This fork by Rubix Studios reduces bloat and introduces targeted changes for improved performance, maintainability, and flexibility.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rubix Studios <hello@rubixstudios.com.au> (https://rubixstudios.com.au)",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@payloadcms/eslint-config": "3.28.0",
|
|
51
51
|
"@swc/cli": "^0.7.8",
|
|
52
52
|
"@swc/core": "^1.13.5",
|
|
53
|
-
"@types/react": "19.1.
|
|
53
|
+
"@types/react": "19.1.16",
|
|
54
54
|
"eslint": "^9.36.0",
|
|
55
|
-
"payload": "3.
|
|
55
|
+
"payload": "3.58.0",
|
|
56
56
|
"rimraf": "6.0.1",
|
|
57
|
-
"typescript": "5.9.
|
|
57
|
+
"typescript": "5.9.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"payload": "^3.57.0"
|