@shopware-ag/admin-extension-sdk
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -22,5 +22,3 @@ import { hasType } from '../utils'; | ||
if (hasType('__EntityCollection__', value)) { | ||
return new EntityCollection(value.__source__, | ||
// @ts-expect-error - we know that this property exists in the deserialized object. If not, it will fail | ||
value.__entityName__, value.__context__, customizerMethod(value.__criteria__), customizerMethod(value.__entities__), value.__total__, value.__aggregations__); | ||
return new EntityCollection(value.__source__, value.__entityName__, value.__context__, customizerMethod(value.__criteria__), customizerMethod(value.__entities__), value.__total__, value.__aggregations__); | ||
} | ||
@@ -27,0 +25,0 @@ }, |
@@ -22,5 +22,3 @@ import { isObject, hasType } from '../utils'; | ||
if (hasType('__Entity__', value) && typeof value.__origin__ === 'object') { | ||
return new EntityClass(value.__id__, | ||
// @ts-expect-error - we know that this property exists in the deserialized object. If not, it will fail | ||
value.__entityName__, customizerMethod(value.__draft__), { | ||
return new EntityClass(value.__id__, value.__entityName__, customizerMethod(value.__draft__), { | ||
originData: customizerMethod(value.__origin__), | ||
@@ -27,0 +25,0 @@ isDirty: value.__isDirty__, |
@@ -59,5 +59,7 @@ import cloneDeep from 'lodash/cloneDeep'; | ||
const that = this; | ||
// @ts-expect-error - the proxy contains the draft and the entity class | ||
return new Proxy(this._draft, { | ||
get(_, property) { | ||
if (property in that._draft) { | ||
// @ts-expect-error - the proxy contains the draft and the entity class | ||
return that._draft[property]; | ||
@@ -64,0 +66,0 @@ } |
@@ -135,3 +135,2 @@ import Criteria from '../Criteria'; | ||
this.remove = function removeEntityFromCollection(id) { | ||
// @ts-expect-error - we know that every entity has an id | ||
const itemIndex = this.findIndex(i => i.id === id); | ||
@@ -148,3 +147,2 @@ if (itemIndex < 0) { | ||
this.has = function hasEntityInCollection(id) { | ||
// @ts-expect-error - we know that every entity has an id | ||
return this.some(i => i.id === id); | ||
@@ -156,3 +154,2 @@ }; | ||
this.get = function getEntityByIdOfCollection(id) { | ||
// @ts-expect-error - we know that every entity has an id | ||
const item = this.find(i => i.id === id); | ||
@@ -180,3 +177,2 @@ if (typeof item !== 'undefined') { | ||
this.getIds = function getEntityIdsOfCollection() { | ||
// @ts-expect-error - we know that every entity has an id | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
@@ -183,0 +179,0 @@ return this.map(i => i.id); |
@@ -6,3 +6,3 @@ import type Criteria from './Criteria'; | ||
type Entities = EntitySchema.Entities; | ||
declare const _default: <EntityName extends never>(entityName: EntityName) => { | ||
declare const _default: <EntityName extends keyof EntitySchema.Entities>(entityName: EntityName) => { | ||
search: (criteria: Criteria, context?: ApiContext) => Promise<EntityCollection<EntityName> | null>; | ||
@@ -9,0 +9,0 @@ get: (id: string, context?: ApiContext, criteria?: Criteria) => Promise<Entity<EntityName> | null>; |
@@ -44,4 +44,12 @@ import * as window from './window'; | ||
interface Entities { | ||
private_example_entity: private_example_entity; | ||
private_example_entity_two: private_example_entity_two; | ||
} | ||
interface private_example_entity { | ||
id: string; | ||
} | ||
interface private_example_entity_two { | ||
id: string; | ||
} | ||
} | ||
} |
{ | ||
"name": "@shopware-ag/admin-extension-sdk", | ||
"license": "MIT", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"repository": "git://github.com/shopware/admin-extension-sdk.git", | ||
@@ -6,0 +6,0 @@ "description": "The SDK for App iframes to communicate with the Shopware Administration", |
@@ -36,5 +36,3 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
if ((0, utils_1.hasType)('__EntityCollection__', value)) { | ||
return new EntityCollection_1.default(value.__source__, | ||
// @ts-expect-error - we know that this property exists in the deserialized object. If not, it will fail | ||
value.__entityName__, value.__context__, customizerMethod(value.__criteria__), customizerMethod(value.__entities__), value.__total__, value.__aggregations__); | ||
return new EntityCollection_1.default(value.__source__, value.__entityName__, value.__context__, customizerMethod(value.__criteria__), customizerMethod(value.__entities__), value.__total__, value.__aggregations__); | ||
} | ||
@@ -41,0 +39,0 @@ }, |
@@ -36,5 +36,3 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
if ((0, utils_1.hasType)('__Entity__', value) && typeof value.__origin__ === 'object') { | ||
return new Entity_1.default(value.__id__, | ||
// @ts-expect-error - we know that this property exists in the deserialized object. If not, it will fail | ||
value.__entityName__, customizerMethod(value.__draft__), { | ||
return new Entity_1.default(value.__id__, value.__entityName__, customizerMethod(value.__draft__), { | ||
originData: customizerMethod(value.__origin__), | ||
@@ -41,0 +39,0 @@ isDirty: value.__isDirty__, |
@@ -75,5 +75,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
const that = this; | ||
// @ts-expect-error - the proxy contains the draft and the entity class | ||
return new Proxy(this._draft, { | ||
get(_, property) { | ||
if (property in that._draft) { | ||
// @ts-expect-error - the proxy contains the draft and the entity class | ||
return that._draft[property]; | ||
@@ -80,0 +82,0 @@ } |
@@ -149,3 +149,2 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
this.remove = function removeEntityFromCollection(id) { | ||
// @ts-expect-error - we know that every entity has an id | ||
const itemIndex = this.findIndex(i => i.id === id); | ||
@@ -162,3 +161,2 @@ if (itemIndex < 0) { | ||
this.has = function hasEntityInCollection(id) { | ||
// @ts-expect-error - we know that every entity has an id | ||
return this.some(i => i.id === id); | ||
@@ -170,3 +168,2 @@ }; | ||
this.get = function getEntityByIdOfCollection(id) { | ||
// @ts-expect-error - we know that every entity has an id | ||
const item = this.find(i => i.id === id); | ||
@@ -194,3 +191,2 @@ if (typeof item !== 'undefined') { | ||
this.getIds = function getEntityIdsOfCollection() { | ||
// @ts-expect-error - we know that every entity has an id | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
@@ -197,0 +193,0 @@ return this.map(i => i.id); |
@@ -6,3 +6,3 @@ import type Criteria from './Criteria'; | ||
type Entities = EntitySchema.Entities; | ||
declare const _default: <EntityName extends never>(entityName: EntityName) => { | ||
declare const _default: <EntityName extends keyof EntitySchema.Entities>(entityName: EntityName) => { | ||
search: (criteria: Criteria, context?: ApiContext) => Promise<EntityCollection<EntityName> | null>; | ||
@@ -9,0 +9,0 @@ get: (id: string, context?: ApiContext, criteria?: Criteria) => Promise<Entity<EntityName> | null>; |
@@ -44,4 +44,12 @@ import * as window from './window'; | ||
interface Entities { | ||
private_example_entity: private_example_entity; | ||
private_example_entity_two: private_example_entity_two; | ||
} | ||
interface private_example_entity { | ||
id: string; | ||
} | ||
interface private_example_entity_two { | ||
id: string; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9037
582197