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

@shopify/admin-graphql-api-utilities

Package Overview
Dependencies
Maintainers
19
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/admin-graphql-api-utilities - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4-graphql-config-beta.1

4

build/ts/index.d.ts

@@ -13,5 +13,5 @@ interface ParsedGid {

}
export declare function nodesFromEdges<T>(edges: Edge<T>[]): T[];
export declare function keyFromEdges<T, K extends keyof T>(edges: Edge<T>[], key: K): T[K][];
export declare function nodesFromEdges<T>(edges: Array<Edge<T>>): T[];
export declare function keyFromEdges<T, K extends keyof T>(edges: Array<Edge<T>>, key: K): Array<T[K]>;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,31 +0,25 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.keyFromEdges = exports.nodesFromEdges = exports.composeGid = exports.composeGidFactory = exports.parseGidWithParams = exports.parseGid = exports.parseGidType = void 0;
var tslib_1 = require("tslib");
var GID_TYPE_REGEXP = /^gid:\/\/[\w-]+\/([\w-]+)\//;
var GID_REGEXP = /\/(\w[\w-]*)(?:\?(.*))*$/;
function parseGidType(gid) {
var matches = GID_TYPE_REGEXP.exec(gid);
const GID_TYPE_REGEXP = /^gid:\/\/[\w-]+\/([\w-]+)\//;
const GID_REGEXP = /\/(\w[\w-]*)(?:\?(.*))*$/;
export function parseGidType(gid) {
const matches = GID_TYPE_REGEXP.exec(gid);
if (matches && matches[1] !== undefined) {
return matches[1];
}
throw new Error("Invalid gid: " + gid);
throw new Error(`Invalid gid: ${gid}`);
}
exports.parseGidType = parseGidType;
function parseGid(gid) {
export function parseGid(gid) {
// prepends forward slash to help identify invalid id
var id = "/" + gid;
var matches = GID_REGEXP.exec(id);
const id = `/${gid}`;
const matches = GID_REGEXP.exec(id);
if (matches && matches[1] !== undefined) {
return matches[1];
}
throw new Error("Invalid gid: " + gid);
throw new Error(`Invalid gid: ${gid}`);
}
exports.parseGid = parseGid;
function parseGidWithParams(gid) {
export function parseGidWithParams(gid) {
// appends forward slash to help identify invalid id
var id = "/" + gid;
var matches = GID_REGEXP.exec(id);
const id = `/${gid}`;
const matches = GID_REGEXP.exec(id);
if (matches && matches[1] !== undefined) {
var params = matches[2] === undefined
const params = matches[2] === undefined
? {}

@@ -35,54 +29,32 @@ : fromEntries(new URLSearchParams(matches[2]).entries());

id: matches[1],
params: params,
params,
};
}
throw new Error("Invalid gid: " + gid);
throw new Error(`Invalid gid: ${gid}`);
}
exports.parseGidWithParams = parseGidWithParams;
function composeGidFactory(namescape) {
return function composeGid(key, id, params) {
if (params === void 0) { params = {}; }
var gid = "gid://" + namescape + "/" + key + "/" + id;
var paramKeys = Object.keys(params);
export function composeGidFactory(namescape) {
return function composeGid(key, id, params = {}) {
const gid = `gid://${namescape}/${key}/${id}`;
const paramKeys = Object.keys(params);
if (paramKeys.length === 0) {
return gid;
}
var paramString = new URLSearchParams(params).toString();
return gid + "?" + paramString;
const paramString = new URLSearchParams(params).toString();
return `${gid}?${paramString}`;
};
}
exports.composeGidFactory = composeGidFactory;
exports.composeGid = composeGidFactory('shopify');
function nodesFromEdges(edges) {
return edges.map(function (_a) {
var node = _a.node;
return node;
});
export const composeGid = composeGidFactory('shopify');
export function nodesFromEdges(edges) {
return edges.map(({ node }) => node);
}
exports.nodesFromEdges = nodesFromEdges;
function keyFromEdges(edges, key) {
return edges.map(function (_a) {
var node = _a.node;
return node[key];
});
export function keyFromEdges(edges, key) {
return edges.map(({ node }) => node[key]);
}
exports.keyFromEdges = keyFromEdges;
// Once we update to Node 12, we can drop this helper to use `Object.fromEntries` instead.
function fromEntries(entries) {
var e_1, _a;
var obj = {};
try {
for (var entries_1 = tslib_1.__values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
var _b = tslib_1.__read(entries_1_1.value, 2), key = _b[0], val = _b[1];
obj[key] = val;
}
const obj = {};
for (const [key, val] of entries) {
obj[key] = val;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
}
finally { if (e_1) throw e_1.error; }
}
return obj;
}

@@ -8,4 +8,12 @@ # Changelog

## [0.2.2] - 2021-03-03
<!-- ## Unreleased -->
## 0.2.4 - 2021-04-13
### Changed
- Removed dependency on tslib, as we no-longer compile with `tsc`. [#1829](https://github.com/Shopify/quilt/pull/1829)
## 0.2.2 - 2021-03-03
### Fixed

@@ -15,3 +23,3 @@

## [0.2.0] - 2020-12-18
## 0.2.0 - 2020-12-18

@@ -22,16 +30,16 @@ ### Added

## [0.1.1] - 2020-10-20
## 0.1.1 - 2020-10-20
- Updated `tslib` dependency to `^1.14.1`. [#1657](https://github.com/Shopify/quilt/pull/1657)
## [0.1.0] - 2020-07-28
## 0.1.0 - 2020-07-28
- Add `parseGidWithParams` and `composeGidFactory`. Also add support for optional params in `composeGid` ([#1548](https://github.com/Shopify/quilt/pull/1548))
## [0.0.14] - 2020-06-30
## 0.0.14 - 2020-06-30
- Let `parseGid` parse GIDs containing query parameters.
## [0.0.4] - 2019-01-09
## 0.0.4 - 2019-01-09
- Start of Changelog
{
"name": "@shopify/admin-graphql-api-utilities",
"version": "0.2.3",
"version": "0.2.4-graphql-config-beta.1",
"license": "MIT",

@@ -8,5 +8,2 @@ "description": "A set of utilities to use when consuming Shopify’s admin GraphQL API",

"types": "index.d.ts",
"scripts": {
"build": "tsc --p tsconfig.json"
},
"publishConfig": {

@@ -27,5 +24,2 @@ "access": "public",

"sideEffects": false,
"dependencies": {
"tslib": "^1.14.1"
},
"files": [

@@ -32,0 +26,0 @@ "build/*",

Sorry, the diff of this file is not supported yet

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