New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

0gql

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

0gql - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

7

CHANGELOG.md
# 0gql
## 0.0.8
### Patch Changes
- 74851a2: Fix non-gql imports from gql modules being wrongly recognised as gql tags
- 74851a2: Fix missing extension in import lines when handling fragment
## 0.0.7

@@ -4,0 +11,0 @@

19

dist/main.js

@@ -48,3 +48,3 @@ "use strict";

const targetFilename = (0, changeExtension_1.changeExtension)(file, options.targetExtension);
const indentifiers = {
const importIdentifiers = {
gqlTags: {},

@@ -58,15 +58,8 @@ others: {},

if (typescript_1.default.isImportDeclaration(node)) {
const identifiers = (0, parseGqlTagImportIdentifiers_1.parseGqlTagImportIdentifiers)({
(0, parseGqlTagImportIdentifiers_1.parseGqlTagImportIdentifiers)({
node,
source: sourceFile,
gqlTagModules: options.gqlTagModules,
importIdentifiers,
});
Object.entries(identifiers).forEach(([key, moduleMeta]) => {
if (moduleMeta.isGqlTagModule) {
indentifiers.gqlTags[key] = moduleMeta;
}
else {
indentifiers.others[key] = moduleMeta;
}
});
}

@@ -81,3 +74,3 @@ if (typescript_1.default.isVariableStatement(node)) {

// If tag is not part of gqlTags, do nothing
if (!indentifiers.gqlTags[tagIdentifier]) {
if (!importIdentifiers.gqlTags[tagIdentifier]) {
return;

@@ -98,4 +91,4 @@ }

const identifier = span.expression.getText(sourceFile);
if (indentifiers.others[identifier]) {
convertedGraphqlImportLines.push(`#import "${indentifiers.others[identifier].module}"`);
if (importIdentifiers.others[identifier]) {
convertedGraphqlImportLines.push(`#import "${importIdentifiers.others[identifier].moduleName}.graphql"`);
substitutionsToReplace.push("${" + identifier + "}");

@@ -102,0 +95,0 @@ }

import ts from "typescript";
import { IdentifierMeta } from "../types";
interface ParseGqlTagImportIdentifiersParams {
interface ImportIdentifierMeta {
moduleName: string;
}
export interface ParseGqlTagImportIdentifiersParams {
node: ts.ImportDeclaration;
source: ts.SourceFile;
gqlTagModules: string[];
importIdentifiers: {
gqlTags: Record<string, ImportIdentifierMeta>;
others: Record<string, ImportIdentifierMeta>;
};
}

@@ -12,3 +18,3 @@ /**

*/
export declare const parseGqlTagImportIdentifiers: ({ node, source, gqlTagModules, }: ParseGqlTagImportIdentifiersParams) => Record<string, IdentifierMeta>;
export declare const parseGqlTagImportIdentifiers: ({ node, source, gqlTagModules, importIdentifiers, }: ParseGqlTagImportIdentifiersParams) => void;
export {};

@@ -13,14 +13,11 @@ "use strict";

*/
const parseGqlTagImportIdentifiers = ({ node, source, gqlTagModules, }) => {
const parseGqlTagImportIdentifiers = ({ node, source, gqlTagModules, importIdentifiers, }) => {
var _a, _b, _c, _d;
const module = (0, trimQuotes_1.trimQuotes)(node.moduleSpecifier.getText(source));
// TODO: there are other modules to check. Maybe let users pass it in?
const isGqlTagModule = gqlTagModules.includes(module);
const identifiers = {};
const moduleName = (0, trimQuotes_1.trimQuotes)(node.moduleSpecifier.getText(source));
const isGqlTagModule = gqlTagModules.includes(moduleName);
const defaultImportIdentifier = (_b = (_a = node.importClause) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.getText(source);
if (defaultImportIdentifier) {
identifiers[defaultImportIdentifier] = {
isGqlTag: isGqlTagModule,
isGqlTagModule,
module,
const key = isGqlTagModule ? "gqlTags" : "others";
importIdentifiers[key][defaultImportIdentifier] = {
moduleName,
};

@@ -33,11 +30,9 @@ }

((_a = cn.propertyName) === null || _a === void 0 ? void 0 : _a.getText(source)) === "gql";
identifiers[cn.name.getText(source)] = {
isGqlTag,
isGqlTagModule,
module,
const key = isGqlTag && isGqlTagModule ? "gqlTags" : "others";
importIdentifiers[key][cn.name.getText(source)] = {
moduleName,
};
}
});
return identifiers;
};
exports.parseGqlTagImportIdentifiers = parseGqlTagImportIdentifiers;
{
"name": "0gql",
"version": "0.0.7",
"version": "0.0.8",
"description": "Migrate from gql tag",

@@ -5,0 +5,0 @@ "repository": "git@github.com:eddeee888/nogql.git",

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