@tryghost/algolia-netlify 0.4.1 → 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
 
@@ -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.1",
3
+ "version": "0.4.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TryGhost/algolia.git",