@shopware-ag/meteor-component-library
Version:
The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).
64 lines (63 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const channel = require("./channel-8eabd4e1.js");
require("./useRepository-6169b5de.js");
require("vue");
const repository = (entityName) => ({
search: (criteria, context) => {
return channel.send("repositorySearch", { entityName, context, criteria });
},
get: (id, context, criteria) => {
return channel.send("repositoryGet", { entityName, id, context, criteria });
},
save: (entity, context) => {
return channel.send("repositorySave", { entityName, entity, context });
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
clone: (entityId, contextOrBehavior, behaviorOrContext) => {
let context;
let behavior;
if (isApiContext(contextOrBehavior)) {
context = contextOrBehavior;
behavior = behaviorOrContext;
} else if (isApiContext(behaviorOrContext)) {
context = behaviorOrContext;
behavior = contextOrBehavior;
} else {
throw new Error("Invalid arguments for clone method");
}
return channel.send("repositoryClone", { entityName, entityId, context, behavior });
},
hasChanges: (entity) => {
return channel.send("repositoryHasChanges", { entityName, entity });
},
saveAll: (entities, context) => {
return channel.send("repositorySaveAll", { entityName, entities, context });
},
delete: (entityId, context) => {
return channel.send("repositoryDelete", { entityName, entityId, context });
},
create: (context, entityId) => {
return channel.send("repositoryCreate", { entityName, entityId, context });
}
});
function isApiContext(value) {
const listOfApiContextProperties = [
"apiPath",
"apiResourcePath",
"assetsPath",
"authToken",
"basePath",
"pathInfo",
"inheritance",
"installationPath",
"languageId",
"language",
"apiVersion",
"liveVersionId",
"systemLanguageId"
];
return !!value && typeof value === "object" && listOfApiContextProperties.some((propertyKey) => propertyKey in value);
}
exports.default = repository;
//# sourceMappingURL=repository-0bc50a13.js.map