@tryghost/algolia-netlify 0.4.0 → 0.4.2

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
@@ -23,12 +23,14 @@ Use a restricted Algolia API key to limit the impact of unauthorized requests.
23
23
 
24
24
  ### Set up Algolia
25
25
 
26
- The functions need the Algolia Application ID and an API key that can update the target index. The general Admin API key works, but a key scoped to this index is preferable. A scoped key needs these permissions:
26
+ Run the [`@tryghost/algolia` CLI](../algolia/README.md) once before enabling the webhooks. It creates the index and adds `filterOnly(slug)`, which the unpublish webhook uses to delete all records for a post. If you use custom index settings, add `filterOnly(slug)` to `attributesForFaceting` yourself.
27
+
28
+ The functions need your Algolia Application ID and an API key restricted to the target index. Give this key these permissions:
27
29
 
28
30
  - Add records (`addObject`)
29
31
  - Delete records matching a filter (`deleteIndex`)
30
- - Get index settings (`settings`)
31
- - Set index settings (`editSettings`)
32
+
33
+ Algolia requires `deleteIndex` for filtered deletions. The name is a bit misleading: this permission can also delete the whole index, so do not grant the key access to any other index. The publish webhook does not read or change settings, so the key does not need `settings` or `editSettings` after setup.
32
34
 
33
35
  ### Deploy the Netlify Functions
34
36
 
@@ -59,7 +61,7 @@ Use the function URL shown by Netlify and pass the configured `NETLIFY_KEY` as t
59
61
  https://YOUR-SITE-ID.netlify.app/.netlify/functions/post-published?key=NETLIFY_KEY
60
62
  ```
61
63
 
62
- These webhooks keep future post changes synchronized. Use the [`@tryghost/algolia` CLI](../algolia/README.md) to create the initial index.
64
+ Once configured, these webhooks keep post changes in sync without touching the index settings.
63
65
 
64
66
  ## Development
65
67
 
@@ -74,7 +76,7 @@ pnpm dev
74
76
 
75
77
  `pnpm dev` starts Netlify Dev, which builds the TypeScript functions as needed. Use the local URL it prints for endpoints such as `/.netlify/functions/post-published`.
76
78
 
77
- Run this package's tests and ESLint checks from the repository root:
79
+ Run this package's tests and lint checks from the repository root:
78
80
 
79
81
  ```sh
80
82
  pnpm --filter @tryghost/algolia-netlify test
@@ -86,7 +88,7 @@ Run the full monorepo suite with `pnpm test`.
86
88
 
87
89
  The modern handlers use native `Request` and `Response` objects. Malformed, empty, or structurally invalid JSON now receives `400 Invalid request body`; a valid Ghost envelope with no selected post remains a `200 No valid request body detected` response. Existing valid webhook behavior, endpoint URLs, and optional `key` handling are unchanged.
88
90
 
89
- `pnpm pack` builds an ESM-only Node 24 package with generated TypeScript declarations. The package intentionally exposes only the two handlers; webhook utilities remain internal.
91
+ From this package directory, `pnpm pack` builds an ESM-only package with generated TypeScript declarations. The supported Node range is declared in [`package.json`](package.json). The package intentionally exposes only the two handlers; webhook utilities remain internal.
90
92
 
91
93
  ---
92
94
 
@@ -65,7 +65,7 @@ async function postPublished(request) {
65
65
  const algoliaObjects = transforms.transformToAlgoliaObject([post]);
66
66
  const fragments = algoliaObjects.reduce(transforms.fragmentTransformer, []);
67
67
  const index = new IndexFactory(algoliaSettings());
68
- await index.setSettingsForIndex();
68
+ await index.initIndex();
69
69
  await index.save(fragments);
70
70
  console.log("Fragments successfully saved to Algolia index");
71
71
  return textResponse(`Post "${String(post.title)}" has been added to the index.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/algolia-netlify",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TryGhost/algolia.git",
@@ -34,47 +34,23 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "eslintConfig": {
38
- "parser": "@typescript-eslint/parser",
39
- "parserOptions": {
40
- "ecmaVersion": 2023,
41
- "sourceType": "module"
42
- },
43
- "extends": [
44
- "airbnb-base",
45
- "plugin:ghost/browser"
46
- ],
47
- "plugins": [
48
- "ghost"
49
- ]
50
- },
51
- "eslintIgnore": [
52
- "webpack.functions.js",
53
- "build/*",
54
- "dist/*"
55
- ],
56
37
  "devDependencies": {
57
38
  "@types/node": "24.13.3",
58
- "@typescript-eslint/parser": "8.67.0",
59
- "eslint": "8.57.1",
60
- "eslint-config-airbnb-base": "15.0.0",
61
- "eslint-plugin-ghost": "3.5.0",
62
- "eslint-plugin-import": "2.32.0",
63
39
  "esbuild": "0.28.2",
64
40
  "netlify-cli": "27.1.1",
65
- "typescript": "6.0.3"
41
+ "typescript": "7.0.2"
66
42
  },
67
43
  "dependencies": {
68
44
  "algolia-html-extractor": "0.0.1",
69
- "algoliasearch": "4.20.0",
70
- "@tryghost/algolia-indexer": "^0.3.2",
71
- "@tryghost/algolia-fragmenter": "^0.2.8"
45
+ "algoliasearch": "5.56.0",
46
+ "@tryghost/algolia-fragmenter": "^0.2.9",
47
+ "@tryghost/algolia-indexer": "^0.3.3"
72
48
  },
73
49
  "scripts": {
74
50
  "dev": "pnpm --dir ../.. exec netlify dev --filter @tryghost/algolia-netlify",
75
51
  "test": "NODE_ENV=testing vitest run --root .",
76
52
  "typecheck": "tsc --project tsconfig.functions.json && tsc --project tsconfig.test.json",
77
- "lint": "eslint . --ext .js,.cjs,.ts,.mts,.cts --cache",
53
+ "lint": "oxlint --quiet . && oxfmt --check .",
78
54
  "posttest": "pnpm typecheck && pnpm lint",
79
55
  "build": "NODE_ENV=production pnpm --dir ../.. exec netlify build --offline --filter @tryghost/algolia-netlify",
80
56
  "build:package": "node scripts/build-package.mjs && tsc --project tsconfig.package.json && node scripts/clean-package.mjs"