@playpilot/tpi 5.2.0-beta.1 → 5.2.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "5.2.0-beta.1",
3
+ "version": "5.2.0-beta.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
package/src/lib/api.ts CHANGED
@@ -29,15 +29,15 @@ export async function fetchLinkInjections(
29
29
 
30
30
  if (!apiToken) throw new Error('No token was provided')
31
31
 
32
- // Add additional parameters if request is made to run the AI. These parameters are only necessary
33
- // when running the AI and should not be passed when not running the AI, otherwise you would
34
- // override the hash, page_text, and/or meta data unintentionally, making comparisons impossible.
32
+ // Add additional parameters if request is made to run the AI. We only include these when saving new data.
33
+ // Most requests will not include these.
35
34
  if (params.run_ai) {
36
35
  params.hash = hash
37
36
  params.page_text = pageText
38
- params.metadata = getPageMetaData()
39
37
  }
40
38
 
39
+ params.metadata = getPageMetaData()
40
+
41
41
  const response = await fetch(apiBaseUrl + `/external-pages/?api-token=${apiToken}&include_title_details=true${isEditorialMode ? '&editorial_mode_enabled=true' : ''}&language=${language}`, {
42
42
  headers,
43
43
  method: 'POST',
@@ -28,24 +28,28 @@ describe('$lib/api', () => {
28
28
  window.PlayPilotLinkInjections = { token: 'a' }
29
29
  })
30
30
 
31
- // TODO: See $lib/api.ts:35
32
- // it('Should call fetch with given url and body', async () => {
33
- // fakeFetch({ response: 'Some response' })
34
-
35
- // const response = await fetchLinkInjections('Some text', { url: 'https://some-url', hash: 'some-hash' })
36
-
37
- // expect(response).toBe('Some response')
38
- // expect(global.fetch).toHaveBeenCalledWith(
39
- // expect.stringContaining('api-token'),
40
- // expect.objectContaining({
41
- // body: JSON.stringify({
42
- // url: 'https://some-url',
43
- // }),
44
- // method: 'POST',
45
- // headers: expect.any(Object),
46
- // }),
47
- // )
48
- // })
31
+ it('Should call fetch with given url and body', async () => {
32
+ fakeFetch({ response: 'Some response' })
33
+
34
+ const response = await fetchLinkInjections('Some text', { url: 'https://some-url', hash: 'some-hash' })
35
+
36
+ expect(response).toBe('Some response')
37
+ expect(global.fetch).toHaveBeenCalledWith(
38
+ expect.stringContaining('api-token'),
39
+ expect.objectContaining({
40
+ body: JSON.stringify({
41
+ url: 'https://some-url',
42
+ metadata: {
43
+ content_heading: null,
44
+ content_modified_time: null,
45
+ content_published_time: null,
46
+ },
47
+ }),
48
+ method: 'POST',
49
+ headers: expect.any(Object),
50
+ }),
51
+ )
52
+ })
49
53
 
50
54
  it('Should call fetch with full details when fetching with run_ai as true', async () => {
51
55
  fakeFetch({ response: 'Some response' })