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

babel-plugin-s2s-action-types-ts

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-s2s-action-types-ts - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

27

lib/index.js

@@ -18,6 +18,4 @@ "use strict";

var _lodash = _interopRequireDefault(require("lodash.snakecase"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -79,4 +77,3 @@

const imports = [];
let actionsNode = [];
const typeNameSet = new Set();
const typeNameSet = [];
const intMap = new Map(); // has interfaces

@@ -88,7 +85,7 @@

const name = typeName.name;
typeNameSet.add(name);
typeNameSet.push(name);
if (name.endsWith('Request')) {
typeNameSet.add(name.replace(/Request$/, 'Success'));
typeNameSet.add(name.replace(/Request$/, 'Failure'));
typeNameSet.push(name.replace(/Request$/, 'Success'));
typeNameSet.push(name.replace(/Request$/, 'Failure'));
}

@@ -106,4 +103,2 @@ } // collect exist type infomation

if (path.node.id.name === 'Action') {
actionsNode.push(path.parent);
switch (path.node.typeAnnotation.type) {

@@ -134,9 +129,11 @@ case 'TSUnionType':

}); // add additionalInterfaces to interfaces map
}); // replace actionNode
const notFoundInterfaces = Array.from(typeNameSet).filter(name => !intMap.has(name));
const actionsNode = types.ExportNamedDeclaration(types.TSTypeAliasDeclaration(types.Identifier('Action'), undefined, types.TSUnionType(typeNameSet.map(type => types.TSTypeReference(types.Identifier(type))))), []); // add additionalInterfaces to interfaces map
const notFoundInterfaces = typeNameSet.filter(name => !intMap.has(name));
const additionalInterfaces = notFoundInterfaces.map(name => [name, interfaceGen(name, [['type', name]])]);
additionalInterfaces.forEach(([name, int]) => intMap.set(name, int));
const interfaces = Array.from(typeNameSet).map(name => intMap.get(name));
const enumMembers = Array.from(typeNameSet).map(name => {
const interfaces = typeNameSet.map(name => intMap.get(name));
const enumMembers = typeNameSet.map(name => {
return types.TSEnumMember(types.Identifier(name), types.StringLiteral(prefix + name));

@@ -154,3 +151,3 @@ });

programPath.node.body = [...imports, ...actionsNode, types.noop(), ...interfaces, exportEnum];
programPath.node.body = [...imports, actionsNode, types.noop(), ...interfaces, exportEnum];
}

@@ -157,0 +154,0 @@

{
"name": "babel-plugin-s2s-action-types-ts",
"version": "2.0.0",
"version": "2.1.0",
"description": "generate action types",

@@ -14,8 +14,7 @@ "main": "lib/index.js",

"dependencies": {
"@babel/plugin-syntax-typescript": "^7.0.0-beta.32",
"@babel/template": "^7.0.0-beta.32",
"@babel/types": "^7.0.0-beta.32",
"lodash.snakecase": "^4.1.1",
"@babel/plugin-syntax-typescript": "^7.0.0-beta.35",
"@babel/template": "^7.0.0-beta.35",
"@babel/types": "^7.0.0-beta.35",
"slash": "^1.0.0"
}
}

@@ -55,3 +55,3 @@ # babel-plugin-s2s-action-types-ts

```typescript
export type Action = FetchRequest;
export type Action = FetchRequest | FetchSuccess | FetchFailure;

@@ -58,0 +58,0 @@ export interface FetchRequest {

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