Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contentful/visual-sdk

Package Overview
Dependencies
Maintainers
172
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentful/visual-sdk - npm Package Compare versions

Comparing version 1.0.0-alpha.12 to 1.0.0-alpha.13

3

dist/cjs/store/EditorEntityStore.js

@@ -60,2 +60,3 @@ "use strict";

if (missingIds.length === 0) {
// everything is already in cache
return ids.map((id)=>this.entitiesMap.get(id));

@@ -104,2 +105,3 @@ }

} catch (err) {
// TODO: move to debug utils once it is extracted
console.warn(`Failed to request asset ${id}`);

@@ -118,2 +120,3 @@ return undefined;

} catch (err) {
// TODO: move to debug utils once it is extracted
console.warn(`Failed to request entry ${id}`, err);

@@ -120,0 +123,0 @@ return undefined;

12

dist/cjs/store/EditorEntityStore.spec.js

@@ -5,4 +5,4 @@ "use strict";

});
const _assetjson = _interop_require_default(require("../__test__/fixtures/asset.json"));
const _entryjson = _interop_require_default(require("../__test__/fixtures/entry.json"));
const _assetjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/asset.json"));
const _entryjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/entry.json"));
const _EditorEntityStore = require("./EditorEntityStore");

@@ -37,4 +37,6 @@ function _interop_require_default(obj) {

const sendMessage = jest.fn();
const subscribe = jest.fn().mockReturnValue(()=>{});
const subscribe = jest.fn().mockReturnValue(()=>{
/* unsubscribe */ });
function resolveEntries(id, entityType, entities) {
// First it calls sendMessage to request the entity
expect(sendMessage).toHaveBeenCalledTimes(1);

@@ -48,4 +50,6 @@ 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]({

@@ -95,2 +99,3 @@ 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);

@@ -155,2 +160,3 @@ 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);

@@ -157,0 +163,0 @@ expect(resultFromStore).toEqual(result);

@@ -5,4 +5,4 @@ "use strict";

});
const _assetjson = _interop_require_default(require("../__test__/fixtures/asset.json"));
const _entryjson = _interop_require_default(require("../__test__/fixtures/entry.json"));
const _assetjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/asset.json"));
const _entryjson = /*#__PURE__*/ _interop_require_default(require("../__test__/fixtures/entry.json"));
const _EntityStore = require("./EntityStore");

@@ -9,0 +9,0 @@ function _interop_require_default(obj) {

@@ -37,2 +37,3 @@ "use strict";

if (!entity || entity.sys.type !== entityLink.sys.linkType) {
// TODO: move to `debug` utils once it is extracted
console.warn(`Unresolved entity reference: ${entityLink}`);

@@ -65,2 +66,3 @@ return;

} catch (err) {
// TODO: move to `debug` utils once it is extracted
console.warn(`Asset "${id}" is not in the store`);

@@ -79,2 +81,3 @@ return undefined;

} catch (err) {
// TODO: move to `debug` utils once it is extracted
console.warn(`Entry "${id}" is not in the store`);

@@ -81,0 +84,0 @@ return undefined;

@@ -20,3 +20,6 @@ function _define_property(obj, key, value) {

})(PostMessageMethods || (PostMessageMethods = {}));
export class EditorEntityStore extends EntityStore {
/**
* EntityStore which resolves entries and assets from the editor
* over the sendMessage and subscribe functions.
*/ export class EditorEntityStore extends EntityStore {
cleanupPromise(referenceId) {

@@ -43,2 +46,3 @@ setTimeout(()=>{

if (missingIds.length === 0) {
// everything is already in cache
return ids.map((id)=>this.entitiesMap.get(id));

@@ -87,2 +91,3 @@ }

} catch (err) {
// TODO: move to debug utils once it is extracted
console.warn(`Failed to request asset ${id}`);

@@ -101,2 +106,3 @@ return undefined;

} catch (err) {
// TODO: move to debug utils once it is extracted
console.warn(`Failed to request entry ${id}`, err);

@@ -103,0 +109,0 @@ return undefined;

@@ -27,4 +27,6 @@ import assetJSON from '../__test__/fixtures/asset.json';

const sendMessage = jest.fn();
const subscribe = jest.fn().mockReturnValue(()=>{});
const subscribe = jest.fn().mockReturnValue(()=>{
/* unsubscribe */ });
function resolveEntries(id, entityType, entities) {
// First it calls sendMessage to request the entity
expect(sendMessage).toHaveBeenCalledTimes(1);

@@ -38,4 +40,6 @@ 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]({

@@ -85,2 +89,3 @@ 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);

@@ -145,2 +150,3 @@ 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);

@@ -147,0 +153,0 @@ expect(resultFromStore).toEqual(result);

@@ -15,3 +15,6 @@ function _define_property(obj, key, value) {

import { get } from './utils';
export class EntityStore {
/**
* Base Store for entities
* Can be extened for the different loading behaviours (editor, production, ..)
*/ export class EntityStore {
get entities() {

@@ -28,2 +31,3 @@ return [

if (!entity || entity.sys.type !== entityLink.sys.linkType) {
// TODO: move to `debug` utils once it is extracted
console.warn(`Unresolved entity reference: ${entityLink}`);

@@ -56,2 +60,3 @@ return;

} catch (err) {
// TODO: move to `debug` utils once it is extracted
console.warn(`Asset "${id}" is not in the store`);

@@ -70,2 +75,3 @@ return undefined;

} catch (err) {
// TODO: move to `debug` utils once it is extracted
console.warn(`Entry "${id}" is not in the store`);

@@ -72,0 +78,0 @@ return undefined;

{
"name": "@contentful/visual-sdk",
"author": "Contentful GmbH",
"version": "1.0.0-alpha.12",
"version": "1.0.0-alpha.13",
"description": "Base SDK for building a visual SDK with contentful",

@@ -52,3 +52,3 @@ "license": "MIT",

"@swc/cli": "0.1.62",
"@swc/core": "1.3.78",
"@swc/core": "1.3.80",
"@swc/jest": "0.2.29",

@@ -60,3 +60,3 @@ "@types/jest": "29.5.3",

},
"gitHead": "b03bc09a434b5c5204f28343357b1fc897bd77c2"
"gitHead": "e62ba0eef833d500e08cd3c98aae72314ae58e27"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc