@contentful/visual-sdk
Advanced tools
Comparing version 1.0.0-alpha.32 to 1.0.0-alpha.33
@@ -50,3 +50,2 @@ "use strict"; | ||
if (missing.length === 0) { | ||
// everything is already in cache | ||
return resolved; | ||
@@ -95,3 +94,2 @@ } | ||
} catch (err) { | ||
// TODO: move to debug utils once it is extracted | ||
console.warn(`Failed to request asset ${id}`); | ||
@@ -110,3 +108,2 @@ return undefined; | ||
} catch (err) { | ||
// TODO: move to debug utils once it is extracted | ||
console.warn(`Failed to request entry ${id}`, err); | ||
@@ -113,0 +110,0 @@ return undefined; |
@@ -5,4 +5,4 @@ "use strict"; | ||
}); | ||
const _assetjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/asset.json")); | ||
const _entryjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/entry.json")); | ||
const _assetjson = _interop_require_default(require("../__test__/fixtures/asset.json")); | ||
const _entryjson = _interop_require_default(require("../__test__/fixtures/entry.json")); | ||
const _EditorEntityStore = require("./EditorEntityStore"); | ||
@@ -37,6 +37,4 @@ function _interop_require_default(obj) { | ||
const sendMessage = jest.fn(); | ||
const subscribe = jest.fn().mockReturnValue(()=>{ | ||
/* unsubscribe */ }); | ||
const subscribe = jest.fn().mockReturnValue(()=>{}); | ||
function resolveEntries(id, entityType, entities) { | ||
// First it calls sendMessage to request the entity | ||
expect(sendMessage).toHaveBeenCalledTimes(1); | ||
@@ -50,6 +48,4 @@ expect(sendMessage).toHaveBeenCalledWith(_EditorEntityStore.PostMessageMethods.REQUEST_ENTITIES, { | ||
}); | ||
// Then it registers the listener to wait for a respsone | ||
expect(subscribe).toHaveBeenCalledTimes(1); | ||
expect(subscribe).toHaveBeenCalledWith(_EditorEntityStore.PostMessageMethods.REQUESTED_ENTITIES, expect.any(Function)); | ||
// Let it resolve | ||
subscribe.mock.lastCall[1]({ | ||
@@ -99,3 +95,2 @@ entities | ||
expect(store.entities).toHaveLength(entities.length + 1); | ||
// fetch again to see if it's now used from the store | ||
const resultFromStore = await store.fetchAsset(editorAsset.sys.id); | ||
@@ -160,3 +155,2 @@ expect(resultFromStore).toEqual(result); | ||
expect(store.entities).toHaveLength(entities.length + 1); | ||
// fetch again to see if it's now used from the store | ||
const resultFromStore = await store.fetchAsset(editorEntry.sys.id); | ||
@@ -163,0 +157,0 @@ expect(resultFromStore).toEqual(result); |
@@ -5,4 +5,4 @@ "use strict"; | ||
}); | ||
const _assetjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/asset.json")); | ||
const _entryjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/entry.json")); | ||
const _assetjson = _interop_require_default(require("../__test__/fixtures/asset.json")); | ||
const _entryjson = _interop_require_default(require("../__test__/fixtures/entry.json")); | ||
const _EntityStore = require("./EntityStore"); | ||
@@ -9,0 +9,0 @@ function _interop_require_default(obj) { |
@@ -39,3 +39,2 @@ "use strict"; | ||
if (!entity) { | ||
// TODO: move to `debug` utils once it is extracted | ||
console.warn(`Unresolved entity reference: ${entityLink}`); | ||
@@ -74,3 +73,2 @@ return; | ||
if (missing.length) { | ||
// TODO: move to `debug` utils once it is extracted | ||
console.warn(`Asset "${id}" is not in the store`); | ||
@@ -93,3 +91,2 @@ return undefined; | ||
if (missing.length) { | ||
// TODO: move to `debug` utils once it is extracted | ||
console.warn(`Entry "${id}" is not in the store`); | ||
@@ -96,0 +93,0 @@ return undefined; |
@@ -20,6 +20,3 @@ function _define_property(obj, key, value) { | ||
})(PostMessageMethods || (PostMessageMethods = {})); | ||
/** | ||
* EntityStore which resolves entries and assets from the editor | ||
* over the sendMessage and subscribe functions. | ||
*/ export class EditorEntityStore extends EntityStore { | ||
export class EditorEntityStore extends EntityStore { | ||
cleanupPromise(referenceId) { | ||
@@ -36,3 +33,2 @@ setTimeout(()=>{ | ||
if (missing.length === 0) { | ||
// everything is already in cache | ||
return resolved; | ||
@@ -81,3 +77,2 @@ } | ||
} catch (err) { | ||
// TODO: move to debug utils once it is extracted | ||
console.warn(`Failed to request asset ${id}`); | ||
@@ -96,3 +91,2 @@ return undefined; | ||
} catch (err) { | ||
// TODO: move to debug utils once it is extracted | ||
console.warn(`Failed to request entry ${id}`, err); | ||
@@ -99,0 +93,0 @@ return undefined; |
@@ -27,6 +27,4 @@ import assetJSON from '../__test__/fixtures/asset.json'; | ||
const sendMessage = jest.fn(); | ||
const subscribe = jest.fn().mockReturnValue(()=>{ | ||
/* unsubscribe */ }); | ||
const subscribe = jest.fn().mockReturnValue(()=>{}); | ||
function resolveEntries(id, entityType, entities) { | ||
// First it calls sendMessage to request the entity | ||
expect(sendMessage).toHaveBeenCalledTimes(1); | ||
@@ -40,6 +38,4 @@ expect(sendMessage).toHaveBeenCalledWith(PostMessageMethods.REQUEST_ENTITIES, { | ||
}); | ||
// Then it registers the listener to wait for a respsone | ||
expect(subscribe).toHaveBeenCalledTimes(1); | ||
expect(subscribe).toHaveBeenCalledWith(PostMessageMethods.REQUESTED_ENTITIES, expect.any(Function)); | ||
// Let it resolve | ||
subscribe.mock.lastCall[1]({ | ||
@@ -89,3 +85,2 @@ entities | ||
expect(store.entities).toHaveLength(entities.length + 1); | ||
// fetch again to see if it's now used from the store | ||
const resultFromStore = await store.fetchAsset(editorAsset.sys.id); | ||
@@ -150,3 +145,2 @@ expect(resultFromStore).toEqual(result); | ||
expect(store.entities).toHaveLength(entities.length + 1); | ||
// fetch again to see if it's now used from the store | ||
const resultFromStore = await store.fetchAsset(editorEntry.sys.id); | ||
@@ -153,0 +147,0 @@ expect(resultFromStore).toEqual(result); |
@@ -15,6 +15,3 @@ function _define_property(obj, key, value) { | ||
import { get } from './utils'; | ||
/** | ||
* Base Store for entities | ||
* Can be extened for the different loading behaviours (editor, production, ..) | ||
*/ export class EntityStore { | ||
export class EntityStore { | ||
get entities() { | ||
@@ -33,3 +30,2 @@ return [ | ||
if (!entity) { | ||
// TODO: move to `debug` utils once it is extracted | ||
console.warn(`Unresolved entity reference: ${entityLink}`); | ||
@@ -68,3 +64,2 @@ return; | ||
if (missing.length) { | ||
// TODO: move to `debug` utils once it is extracted | ||
console.warn(`Asset "${id}" is not in the store`); | ||
@@ -87,3 +82,2 @@ return undefined; | ||
if (missing.length) { | ||
// TODO: move to `debug` utils once it is extracted | ||
console.warn(`Entry "${id}" is not in the store`); | ||
@@ -90,0 +84,0 @@ return undefined; |
{ | ||
"name": "@contentful/visual-sdk", | ||
"author": "Contentful GmbH", | ||
"version": "1.0.0-alpha.32", | ||
"version": "1.0.0-alpha.33", | ||
"description": "Base SDK for building a visual SDK with contentful", | ||
@@ -52,5 +52,5 @@ "license": "MIT", | ||
"@swc/cli": "0.1.63", | ||
"@swc/core": "1.3.96", | ||
"@swc/core": "1.3.99", | ||
"@swc/jest": "0.2.29", | ||
"@types/jest": "29.5.8", | ||
"@types/jest": "29.5.10", | ||
"contentful": "10.6.11", | ||
@@ -60,3 +60,3 @@ "jest": "29.7.0", | ||
}, | ||
"gitHead": "6b31eac9f5a66482e07e875d3420c5a56595842f" | ||
"gitHead": "1fa66457b5f0d748c07ac243cfc0a6e0a29f63a4" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74175
2075