@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 kB
JavaScript
import { s as send } from "./channel-e8be2d79.mjs";
import "./useRepository-8f4e50b0.mjs";
import "vue";
const repository = (entityName) => ({
search: (criteria, context) => {
return send("repositorySearch", { entityName, context, criteria });
},
get: (id, context, criteria) => {
return send("repositoryGet", { entityName, id, context, criteria });
},
save: (entity, context) => {
return 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 send("repositoryClone", { entityName, entityId, context, behavior });
},
hasChanges: (entity) => {
return send("repositoryHasChanges", { entityName, entity });
},
saveAll: (entities, context) => {
return send("repositorySaveAll", { entityName, entities, context });
},
delete: (entityId, context) => {
return send("repositoryDelete", { entityName, entityId, context });
},
create: (context, entityId) => {
return 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);
}
export {
repository as default
};
//# sourceMappingURL=repository-0cf40ae4.mjs.map