@shopify/app-bridge-host
Version:
App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se
93 lines (89 loc) • 3.46 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var ROOT_URL = '/admin';
var APPS_URL = "".concat(ROOT_URL, "/apps");
var DISCOUNT_URL = "".concat(ROOT_URL, "/discounts");
var COLLECTION_URL = "".concat(ROOT_URL, "/collections");
var CUSTOMER_URL = "".concat(ROOT_URL, "/customers");
var ORDER_URL = "".concat(ROOT_URL, "/orders");
var DRAFT_ORDER_URL = "".concat(ROOT_URL, "/draft_orders");
var PRODUCT_URL = "".concat(ROOT_URL, "/products");
var resolver = {
home: function (params) {
return withQueryParams('/admin', params);
},
apps: function (params) {
return withQueryParams(APPS_URL, params);
},
app: function (id, path) {
return "/admin/apps/".concat(id).concat(path || '');
},
orderIndex: function (params) {
return withQueryParams(ORDER_URL, params);
},
orderShow: function (id, params) {
return withQueryParams("".concat(ORDER_URL, "/").concat(id), params);
},
orderNew: function (params) {
return withQueryParams("".concat(DRAFT_ORDER_URL, "/new"), params);
},
discountIndex: function (params) {
return withQueryParams("".concat(DISCOUNT_URL), params);
},
discountShow: function (id, params) {
return withQueryParams("".concat(DISCOUNT_URL, "/").concat(id), params);
},
discountNew: function (params) {
return withQueryParams("".concat(DISCOUNT_URL, "/new"), params);
},
collectionIndex: function (params) {
return withQueryParams(COLLECTION_URL, params);
},
collectionShow: function (id, params) {
return withQueryParams("".concat(COLLECTION_URL, "/").concat(id), params);
},
collectionNew: function (params) {
return withQueryParams("".concat(COLLECTION_URL, "/new"), params);
},
productIndex: function (params) {
return withQueryParams(PRODUCT_URL, params);
},
productDetails: function (id, params) {
return withQueryParams("".concat(PRODUCT_URL, "/").concat(id), params);
},
productNew: function (params) {
return withQueryParams("".concat(PRODUCT_URL, "/new"), params);
},
customerIndex: function (params) {
return withQueryParams(CUSTOMER_URL, params);
},
customerShow: function (id, params) {
return withQueryParams("".concat(CUSTOMER_URL, "/").concat(id), params);
},
customerCreate: function (params) {
return withQueryParams("".concat(CUSTOMER_URL, "/new"), params);
},
productVariantDetails: function (id, variantId, params) {
return withQueryParams("".concat(PRODUCT_URL, "/").concat(id, "/variants/").concat(variantId), params);
},
productVariantNew: function (id, params) {
return withQueryParams("".concat(PRODUCT_URL, "/").concat(id, "/variants/new"), params);
},
};
function withQueryParams(url, params) {
if (!params || !Object.keys(params).length) {
return url;
}
var queryParams = Object.keys(params)
.map(function (query) {
var paramIsArray = typeof params[query] === 'object';
return paramIsArray ? "".concat(query, "[]=").concat(params[query]) : "".concat(query, "=").concat(params[query]);
})
.join('&');
return "".concat(url, "?").concat(queryParams);
}
exports.APPS_URL = APPS_URL;
exports.ROOT_URL = ROOT_URL;
exports.default = resolver;
exports.resolver = resolver;
exports.withQueryParams = withQueryParams;