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

graphql-compose-aws

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-compose-aws - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

lib/__tests__/aws-sdk-test.js

198

lib/AwsApiParser.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,137 +6,113 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends2 = require('babel-runtime/helpers/extends');
var _graphqlCompose = require("graphql-compose");
var _extends3 = _interopRequireDefault(_extends2);
var _AwsService = _interopRequireDefault(require("./AwsService"));
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _AwsConfigITC = _interopRequireDefault(require("./types/AwsConfigITC"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _createClass2 = require('babel-runtime/helpers/createClass');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _createClass3 = _interopRequireDefault(_createClass2);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _graphqlCompose = require('graphql-compose');
class AwsApiParser {
constructor(opts) {
this.name = opts.name || 'Aws';
this.awsSDK = opts.awsSDK;
this._serviceMap = {};
this.getServicesNames();
}
var _AwsService = require('./AwsService');
getServicesNames() {
const serviceNames = Object.keys(this.awsSDK).reduce((res, name) => {
if (this.awsSDK[name].serviceIdentifier) {
this._serviceMap[this.awsSDK[name].serviceIdentifier] = name;
res.push(name);
}
var _AwsService2 = _interopRequireDefault(_AwsService);
return res;
}, []);
serviceNames.sort();
return serviceNames;
}
var _AwsConfigITC = require('./types/AwsConfigITC');
getServiceIdentifier(name) {
if (this._serviceMap[name]) return name;
var _AwsConfigITC2 = _interopRequireDefault(_AwsConfigITC);
if (!this.awsSDK[name]) {
throw new Error(`Service with name '${name}' does not exist. Run AwsApiParser.`);
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
return this.awsSDK[name].serviceIdentifier;
}
var AwsApiParser = function () {
function AwsApiParser(opts) {
(0, _classCallCheck3.default)(this, AwsApiParser);
getServiceConfig(name) {
const cfg = this.awsSDK.apiLoader.services[this.getServiceIdentifier(name)];
this.name = opts.name || 'Aws';
this.awsSDK = opts.awsSDK;
if (!cfg) {
throw new Error(`Service with name '${name}' does not exist.`);
}
this._serviceMap = {};
this.getServicesNames();
const versions = Object.keys(cfg);
if (versions.length === 1) {
return cfg[versions[0]];
}
versions.sort();
return cfg[versions[versions.length - 1]];
}
(0, _createClass3.default)(AwsApiParser, [{
key: 'getServicesNames',
value: function getServicesNames() {
var _this = this;
getService(name) {
const config = this.getServiceConfig(name); // console.log(config);
var serviceNames = Object.keys(this.awsSDK).reduce(function (res, name) {
if (_this.awsSDK[name].serviceIdentifier) {
_this._serviceMap[_this.awsSDK[name].serviceIdentifier] = name;
res.push(name);
}
return new _AwsService.default({
serviceId: this._serviceMap[name] || name,
prefix: this.name,
config,
awsSDK: this.awsSDK
});
}
getTypeComposer() {
if (!this.tc) {
const fields = this.getServicesNames().reduce((res, name) => {
res[this.getServiceIdentifier(name)] = this.getService(name).getFieldConfig();
return res;
}, []);
serviceNames.sort();
return serviceNames;
}, {});
this.tc = _graphqlCompose.TypeComposer.create({
name: this.name,
fields,
description: `AWS SDK ${this.awsSDK.VERSION}`
});
}
}, {
key: 'getServiceIdentifier',
value: function getServiceIdentifier(name) {
if (this._serviceMap[name]) return name;
if (!this.awsSDK[name]) {
throw new Error(`Service with name '${name}' does not exist. Run AwsApiParser.`);
}
return this.awsSDK[name].serviceIdentifier;
}
}, {
key: 'getServiceConfig',
value: function getServiceConfig(name) {
var cfg = this.awsSDK.apiLoader.services[this.getServiceIdentifier(name)];
if (!cfg) {
throw new Error(`Service with name '${name}' does not exist.`);
}
var versions = Object.keys(cfg);
if (versions.length === 1) {
return cfg[versions[0]];
}
return this.tc;
}
versions.sort();
return cfg[versions[versions.length - 1]];
}
}, {
key: 'getService',
value: function getService(name) {
var config = this.getServiceConfig(name);
// console.log(config);
return new _AwsService2.default({
serviceId: this._serviceMap[name] || name,
prefix: this.name,
config,
awsSDK: this.awsSDK
});
}
}, {
key: 'getTypeComposer',
value: function getTypeComposer() {
var _this2 = this;
getType() {
return this.getTypeComposer().getType();
}
if (!this.tc) {
var fields = this.getServicesNames().reduce(function (res, name) {
res[_this2.getServiceIdentifier(name)] = _this2.getService(name).getFieldConfig();
return res;
}, {});
getFieldConfig() {
return {
type: this.getType(),
args: {
config: {
type: _AwsConfigITC.default.getType(),
description: 'Will override default configs for aws-sdk.'
}
},
resolve: (source, args) => ({
awsConfig: _objectSpread({}, source && source.awsConfig, args && args.config)
}),
description: this.getTypeComposer().getDescription()
};
}
this.tc = _graphqlCompose.TypeComposer.create({
name: this.name,
fields,
description: `AWS SDK ${this.awsSDK.VERSION}`
});
}
return this.tc;
}
}, {
key: 'getType',
value: function getType() {
return this.getTypeComposer().getType();
}
}, {
key: 'getFieldConfig',
value: function getFieldConfig() {
return {
type: this.getType(),
args: {
config: {
type: _AwsConfigITC2.default.getType(),
description: 'Will override default configs for aws-sdk.'
}
},
resolve: function resolve(source, args) {
return {
awsConfig: (0, _extends3.default)({}, source && source.awsConfig, args && args.config)
};
},
description: this.getTypeComposer().getDescription()
};
}
}]);
return AwsApiParser;
}();
}
exports.default = AwsApiParser;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,119 +6,107 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _graphqlCompose = require("graphql-compose");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
class AwsParam {
static convertInputStructure(param, name, shapes) {
const fields = {};
var _createClass2 = require('babel-runtime/helpers/createClass');
if (param.members) {
Object.keys(param.members).forEach(fname => {
fields[fname] = this.convertParam(param.members[fname], `${name}${(0, _graphqlCompose.upperFirst)(fname)}`, true, shapes);
});
}
var _createClass3 = _interopRequireDefault(_createClass2);
const itc = _graphqlCompose.InputTypeComposer.create({
name: `${name}Input`,
fields
});
var _graphqlCompose = require('graphql-compose');
if (Array.isArray(param.required)) {
itc.makeRequired(param.required);
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
return itc;
}
var AwsParam = function () {
function AwsParam() {
(0, _classCallCheck3.default)(this, AwsParam);
static convertOutputStructure(param, name, shapes) {
const fields = {};
if (param.members) {
Object.keys(param.members).forEach(fname => {
fields[fname] = this.convertParam(param.members[fname], `${name}${(0, _graphqlCompose.upperFirst)(fname)}`, false, shapes);
});
}
const tc = _graphqlCompose.TypeComposer.create({
name,
fields
});
if (Array.isArray(param.required)) {
tc.makeFieldNonNull(param.required);
}
return tc;
}
(0, _createClass3.default)(AwsParam, null, [{
key: 'convertInputStructure',
value: function convertInputStructure(param, name, shapes) {
var _this = this;
static convertParam(param, name, isInput, shapes) {
if (param.type) {
switch (param.type) {
case 'boolean':
return 'Boolean';
var fields = {};
case 'string':
return 'String';
if (param.members) {
Object.keys(param.members).forEach(function (fname) {
fields[fname] = _this.convertParam(param.members[fname], `${name}${(0, _graphqlCompose.upperFirst)(fname)}`, true, shapes);
});
}
case 'integer':
return 'Int';
var itc = _graphqlCompose.InputTypeComposer.create({
name: `${name}Input`,
fields
});
case 'float':
return 'Float';
if (Array.isArray(param.required)) {
itc.makeRequired(param.required);
}
case 'timestamp':
return 'Date';
return itc;
}
}, {
key: 'convertOutputStructure',
value: function convertOutputStructure(param, name, shapes) {
var _this2 = this;
case 'structure':
{
const tc = isInput ? this.convertInputStructure(param, name, shapes) : this.convertOutputStructure(param, name, shapes); // If bugous structure without fields, then return JSON
var fields = {};
if (Object.keys(tc.getFields()).length === 0) {
return 'JSON';
}
if (param.members) {
Object.keys(param.members).forEach(function (fname) {
fields[fname] = _this2.convertParam(param.members[fname], `${name}${(0, _graphqlCompose.upperFirst)(fname)}`, false, shapes);
});
}
return tc;
}
var tc = _graphqlCompose.TypeComposer.create({
name,
fields
});
case 'map':
return 'JSON';
if (Array.isArray(param.required)) {
tc.makeFieldNonNull(param.required);
case 'list':
// $FlowFixMe
return [this.convertParam(param.member, name, isInput, shapes)];
default:
return 'JSON';
}
}
return tc;
if (param.shape) {
return this.convertShape(param, isInput, shapes);
}
}, {
key: 'convertParam',
value: function convertParam(param, name, isInput, shapes) {
if (param.type) {
switch (param.type) {
case 'boolean':
return 'Boolean';
case 'string':
return 'String';
case 'integer':
return 'Int';
case 'float':
return 'Float';
case 'timestamp':
return 'Date';
case 'structure':
{
var tc = isInput ? this.convertInputStructure(param, name, shapes) : this.convertOutputStructure(param, name, shapes);
// If bugous structure without fields, then return JSON
if (Object.keys(tc.getFields()).length === 0) {
return 'JSON';
}
return tc;
}
case 'map':
return 'JSON';
case 'list':
// $FlowFixMe
return [this.convertParam(param.member, name, isInput, shapes)];
default:
return 'JSON';
}
}
if (param.shape) {
return this.convertShape(param, isInput, shapes);
}
return 'String';
return 'String';
}
static convertShape(param, isInput, shapes) {
if (shapes) {
return isInput ? shapes.getInputShape(param.shape) : shapes.getOutputShape(param.shape);
}
}, {
key: 'convertShape',
value: function convertShape(param, isInput, shapes) {
if (shapes) {
return isInput ? shapes.getInputShape(param.shape) : shapes.getOutputShape(param.shape);
}
return 'JSON';
}
}]);
return AwsParam;
}();
return 'JSON';
}
}
exports.default = AwsParam;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,125 +6,96 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends2 = require('babel-runtime/helpers/extends');
var _graphqlCompose = require("graphql-compose");
var _extends3 = _interopRequireDefault(_extends2);
var _AwsServiceMetadata = _interopRequireDefault(require("./AwsServiceMetadata"));
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _AwsServiceOperation = _interopRequireDefault(require("./AwsServiceOperation"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _AwsShapes = _interopRequireDefault(require("./AwsShapes"));
var _createClass2 = require('babel-runtime/helpers/createClass');
var _AwsConfigITC = _interopRequireDefault(require("./types/AwsConfigITC"));
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _graphqlCompose = require('graphql-compose');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _AwsServiceMetadata = require('./AwsServiceMetadata');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _AwsServiceMetadata2 = _interopRequireDefault(_AwsServiceMetadata);
class AwsService {
constructor(opts) {
this.prefix = opts.prefix;
this.serviceId = opts.serviceId;
this.awsSDK = opts.awsSDK;
this.config = opts.config;
this.metadata = new _AwsServiceMetadata.default(this.config.metadata);
this.shapes = new _AwsShapes.default(this.config.shapes, this.getTypeName());
}
var _AwsServiceOperation = require('./AwsServiceOperation');
getTypeName() {
return `${this.prefix}${(0, _graphqlCompose.upperFirst)(this.serviceId)}`;
}
var _AwsServiceOperation2 = _interopRequireDefault(_AwsServiceOperation);
static lowerFirst(name) {
return name.charAt(0).toLowerCase() + name.slice(1);
}
var _AwsShapes = require('./AwsShapes');
getOperationNames() {
return Object.keys(this.config.operations);
}
var _AwsShapes2 = _interopRequireDefault(_AwsShapes);
getOperation(name) {
const operConfig = this.config.operations[name];
var _AwsConfigITC = require('./types/AwsConfigITC');
if (!operConfig) {
throw new Error(`Operation with name ${name} does not exist.`);
}
var _AwsConfigITC2 = _interopRequireDefault(_AwsConfigITC);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AwsService = function () {
function AwsService(opts) {
(0, _classCallCheck3.default)(this, AwsService);
this.prefix = opts.prefix;
this.serviceId = opts.serviceId;
this.awsSDK = opts.awsSDK;
this.config = opts.config;
this.metadata = new _AwsServiceMetadata2.default(this.config.metadata);
this.shapes = new _AwsShapes2.default(this.config.shapes, this.getTypeName());
return new _AwsServiceOperation.default({
serviceId: this.serviceId,
name: this.constructor.lowerFirst(name),
prefix: this.prefix,
config: operConfig,
shapes: this.shapes,
awsSDK: this.awsSDK
});
}
(0, _createClass3.default)(AwsService, [{
key: 'getTypeName',
value: function getTypeName() {
return `${this.prefix}${(0, _graphqlCompose.upperFirst)(this.serviceId)}`;
}
}, {
key: 'getOperationNames',
value: function getOperationNames() {
return Object.keys(this.config.operations);
}
}, {
key: 'getOperation',
value: function getOperation(name) {
var operConfig = this.config.operations[name];
if (!operConfig) {
throw new Error(`Operation with name ${name} does not exist.`);
}
return new _AwsServiceOperation2.default({
serviceId: this.serviceId,
name: this.constructor.lowerFirst(name),
prefix: this.prefix,
config: operConfig,
shapes: this.shapes,
awsSDK: this.awsSDK
getTypeComposer() {
if (!this.tc) {
const fields = this.getOperationNames().reduce((res, name) => {
res[this.constructor.lowerFirst(name)] = this.getOperation(name).getFieldConfig();
return res;
}, {});
this.tc = _graphqlCompose.TypeComposer.create({
name: this.getTypeName(),
fields,
description: this.metadata.getDescription()
});
}
}, {
key: 'getTypeComposer',
value: function getTypeComposer() {
var _this = this;
if (!this.tc) {
var fields = this.getOperationNames().reduce(function (res, name) {
res[_this.constructor.lowerFirst(name)] = _this.getOperation(name).getFieldConfig();
return res;
}, {});
return this.tc;
}
this.tc = _graphqlCompose.TypeComposer.create({
name: this.getTypeName(),
fields,
description: this.metadata.getDescription()
});
}
return this.tc;
}
}, {
key: 'getType',
value: function getType() {
return this.getTypeComposer().getType();
}
}, {
key: 'getFieldConfig',
value: function getFieldConfig() {
return {
type: this.getType(),
args: {
config: {
type: _AwsConfigITC2.default.getType(),
description: 'Will override default configs for aws-sdk.'
}
},
resolve: function resolve(source, args) {
return {
awsConfig: (0, _extends3.default)({}, source && source.awsConfig, args && args.config)
};
getType() {
return this.getTypeComposer().getType();
}
getFieldConfig() {
return {
type: this.getType(),
args: {
config: {
type: _AwsConfigITC.default.getType(),
description: 'Will override default configs for aws-sdk.'
}
};
}
}], [{
key: 'lowerFirst',
value: function lowerFirst(name) {
return name.charAt(0).toLowerCase() + name.slice(1);
}
}]);
return AwsService;
}();
},
resolve: (source, args) => ({
awsConfig: _objectSpread({}, source && source.awsConfig, args && args.config)
})
};
}
}
exports.default = AwsService;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,57 +6,41 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends2 = require('babel-runtime/helpers/extends');
var _graphqlCompose = require("graphql-compose");
var _extends3 = _interopRequireDefault(_extends2);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
class AwsServiceMetadata {
constructor(metadata) {
this.metadata = metadata;
}
var _createClass2 = require('babel-runtime/helpers/createClass');
getPrefix() {
return `Aws${(0, _graphqlCompose.upperFirst)(this.metadata.endpointPrefix)}`;
}
var _createClass3 = _interopRequireDefault(_createClass2);
var _graphqlCompose = require('graphql-compose');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AwsServiceMetadata = function () {
function AwsServiceMetadata(metadata) {
(0, _classCallCheck3.default)(this, AwsServiceMetadata);
this.metadata = metadata;
getDescription() {
// { apiVersion: '2006-03-01',
// checksumFormat: 'md5',
// endpointPrefix: 's3',
//
// globalEndpoint: 's3.amazonaws.com',
// protocol: 'rest-xml',
// serviceAbbreviation: 'Amazon S3',
// serviceFullName: 'Amazon Simple Storage Service',
// serviceId: 'S3',
// signatureVersion: 's3',
// timestampFormat: 'rfc822',
// uid: 's3-2006-03-01' }
const _this$metadata = this.metadata,
serviceFullName = _this$metadata.serviceFullName,
apiVersion = _this$metadata.apiVersion;
return `${serviceFullName} (${apiVersion})`;
}
(0, _createClass3.default)(AwsServiceMetadata, [{
key: 'getPrefix',
value: function getPrefix() {
return `Aws${(0, _graphqlCompose.upperFirst)(this.metadata.endpointPrefix)}`;
}
}, {
key: 'getDescription',
value: function getDescription() {
// { apiVersion: '2006-03-01',
// checksumFormat: 'md5',
// endpointPrefix: 's3',
//
// globalEndpoint: 's3.amazonaws.com',
// protocol: 'rest-xml',
// serviceAbbreviation: 'Amazon S3',
// serviceFullName: 'Amazon Simple Storage Service',
// serviceId: 'S3',
// signatureVersion: 's3',
// timestampFormat: 'rfc822',
// uid: 's3-2006-03-01' }
var _metadata = this.metadata,
serviceFullName = _metadata.serviceFullName,
apiVersion = _metadata.apiVersion;
return `${serviceFullName} (${apiVersion})`;
}
}, {
key: 'getTypeComposer',
value: function getTypeComposer() {
if (!this.tc) {
this.tc = _graphqlCompose.TypeComposer.create(`
getTypeComposer() {
if (!this.tc) {
this.tc = _graphqlCompose.TypeComposer.create(`
type ${this.getPrefix()}Metadata {

@@ -73,23 +57,20 @@ apiVersion: String

`);
}
return this.tc;
}
}, {
key: 'getFieldConfig',
value: function getFieldConfig() {
var _this = this;
return {
type: this.getTypeComposer().getType(),
resolve: function resolve() {
return (0, _extends3.default)({}, _this.metadata, {
raw: _this.metadata
});
}
};
}
}]);
return AwsServiceMetadata;
}();
return this.tc;
}
getFieldConfig() {
return {
type: this.getTypeComposer().getType(),
resolve: () => {
return _objectSpread({}, this.metadata, {
raw: this.metadata
});
}
};
}
}
exports.default = AwsServiceMetadata;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,31 +6,18 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends2 = require('babel-runtime/helpers/extends');
var _graphqlCompose = require("graphql-compose");
var _extends3 = _interopRequireDefault(_extends2);
var _AwsParam = _interopRequireDefault(require("./AwsParam"));
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _AwsConfigITC = _interopRequireDefault(require("./types/AwsConfigITC"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _createClass2 = require('babel-runtime/helpers/createClass');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _createClass3 = _interopRequireDefault(_createClass2);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _graphqlCompose = require('graphql-compose');
var _AwsParam = require('./AwsParam');
var _AwsParam2 = _interopRequireDefault(_AwsParam);
var _AwsConfigITC = require('./types/AwsConfigITC');
var _AwsConfigITC2 = _interopRequireDefault(_AwsConfigITC);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AwsServiceOperation = function () {
function AwsServiceOperation(opts) {
(0, _classCallCheck3.default)(this, AwsServiceOperation);
class AwsServiceOperation {
constructor(opts) {
this.prefix = opts.prefix;

@@ -44,88 +31,79 @@ this.name = opts.name;

(0, _createClass3.default)(AwsServiceOperation, [{
key: 'getTypeName',
value: function getTypeName() {
return `${this.prefix}${(0, _graphqlCompose.upperFirst)(this.serviceId)}${(0, _graphqlCompose.upperFirst)(this.name)}`;
}
}, {
key: 'getType',
value: function getType() {
if (this.config.output && this.config.output.type === 'structure') {
var tc = _AwsParam2.default.convertOutputStructure(this.config.output, `${this.getTypeName()}Output`, this.shapes);
getTypeName() {
return `${this.prefix}${(0, _graphqlCompose.upperFirst)(this.serviceId)}${(0, _graphqlCompose.upperFirst)(this.name)}`;
}
// If bugous structure without fields, then return JSON
if (Object.keys(tc.getFields()).length === 0) {
return _graphqlCompose.GraphQLJSON;
}
getType() {
if (this.config.output && this.config.output.type === 'structure') {
const tc = _AwsParam.default.convertOutputStructure(this.config.output, `${this.getTypeName()}Output`, this.shapes); // If bugous structure without fields, then return JSON
return tc.getType();
if (Object.keys(tc.getFields()).length === 0) {
return _graphqlCompose.GraphQLJSON;
}
return _graphqlCompose.GraphQLJSON;
return tc.getType();
}
}, {
key: 'getArgs',
value: function getArgs() {
if (!this.args) {
if (!this.config.input) {
this.args = {};
} else {
var itc = _AwsParam2.default.convertInputStructure(this.config.input, this.getTypeName(), this.shapes);
var type = void 0;
// If bugous structure without fields, then return JSON
if (Object.keys(itc.getFields()).length === 0) {
type = _graphqlCompose.GraphQLJSON;
} else {
var hasRequiredFields = itc.getFieldNames().some(function (f) {
return itc.isRequired(f);
});
type = hasRequiredFields ? itc.getTypeNonNull() : itc.getType();
}
return _graphqlCompose.GraphQLJSON;
}
this.args = {
input: {
type
}
};
getArgs() {
if (!this.args) {
if (!this.config.input) {
this.args = {};
} else {
const itc = _AwsParam.default.convertInputStructure(this.config.input, this.getTypeName(), this.shapes);
let type; // If bugous structure without fields, then return JSON
if (Object.keys(itc.getFields()).length === 0) {
type = _graphqlCompose.GraphQLJSON;
} else {
const hasRequiredFields = itc.getFieldNames().some(f => itc.isRequired(f));
type = hasRequiredFields ? itc.getTypeNonNull() : itc.getType();
}
this.args.config = {
type: _AwsConfigITC2.default.getType()
this.args = {
input: {
type
}
};
}
return this.args;
this.args.config = {
type: _AwsConfigITC.default.getType()
};
}
}, {
key: 'getResolve',
value: function getResolve() {
var _this = this;
return function (source, args) {
return new Promise(function (resolve, reject) {
var awsConfig = (0, _extends3.default)({}, source && source.awsConfig, args && args.config);
var service = new _this.awsSDK[_this.serviceId](awsConfig);
service[_this.name](args.input, function (err, data) {
if (err) {
reject(err);
}
resolve(data);
});
return this.args;
}
getResolve() {
return (source, args) => {
return new Promise((resolve, reject) => {
const awsConfig = _objectSpread({}, source && source.awsConfig, args && args.config);
const service = new this.awsSDK[this.serviceId](awsConfig);
service[this.name](args.input, (err, data) => {
if (err) {
reject(err);
}
resolve(data);
});
};
}
}, {
key: 'getFieldConfig',
value: function getFieldConfig() {
return {
type: this.getType(),
args: this.getArgs(),
resolve: this.getResolve()
};
}
}]);
return AwsServiceOperation;
}();
});
};
}
getFieldConfig() {
return {
type: this.getType(),
args: this.getArgs(),
resolve: this.getResolve()
};
}
}
exports.default = AwsServiceOperation;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,23 +6,10 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _AwsParam = _interopRequireDefault(require("./AwsParam"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
require('graphql-compose');
var _AwsParam = require('./AwsParam');
var _AwsParam2 = _interopRequireDefault(_AwsParam);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AwsShapes = function () {
function AwsShapes(shapes, prefix) {
(0, _classCallCheck3.default)(this, AwsShapes);
class AwsShapes {
constructor(shapes, prefix) {
this.shapes = shapes;

@@ -34,36 +21,32 @@ this.prefix = prefix;

(0, _createClass3.default)(AwsShapes, [{
key: 'getInputShape',
value: function getInputShape(name) {
if (!this.shapesInput[name]) {
if (!this.shapes[name]) {
throw new Error(`Shape with name '${name}' not found in service config ${this.prefix}`);
}
getInputShape(name) {
if (!this.shapesInput[name]) {
if (!this.shapes[name]) {
throw new Error(`Shape with name '${name}' not found in service config ${this.prefix}`);
} // store firstly as JSON, for solving recursion calls
// store firstly as JSON, for solving recursion calls
this.shapesInput[name] = 'JSON';
this.shapesInput[name] = _AwsParam2.default.convertParam(this.shapes[name], `${this.prefix}${name}`, true, this);
}
return this.shapesInput[name];
this.shapesInput[name] = 'JSON';
this.shapesInput[name] = _AwsParam.default.convertParam(this.shapes[name], `${this.prefix}${name}`, true, this);
}
}, {
key: 'getOutputShape',
value: function getOutputShape(name) {
if (!this.shapesOutput[name]) {
if (!this.shapes[name]) {
throw new Error(`Shape with name '${name}' not found in service config ${this.prefix}`);
}
// store firstly as JSON, for solving recursion calls
this.shapesOutput[name] = 'JSON';
this.shapesOutput[name] = _AwsParam2.default.convertParam(this.shapes[name], `${this.prefix}${name}`, false, this);
}
return this.shapesInput[name];
}
return this.shapesOutput[name];
getOutputShape(name) {
if (!this.shapesOutput[name]) {
if (!this.shapes[name]) {
throw new Error(`Shape with name '${name}' not found in service config ${this.prefix}`);
} // store firstly as JSON, for solving recursion calls
this.shapesOutput[name] = 'JSON';
this.shapesOutput[name] = _AwsParam.default.convertParam(this.shapes[name], `${this.prefix}${name}`, false, this);
}
}]);
return AwsShapes;
}();
return this.shapesOutput[name];
}
}
exports.default = AwsShapes;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {

});
var _AwsApiParser = require('./AwsApiParser');
Object.defineProperty(exports, 'AwsApiParser', {
Object.defineProperty(exports, "AwsApiParser", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_AwsApiParser).default;
return _AwsApiParser.default;
}
});
var _AwsApiParser = _interopRequireDefault(require("./AwsApiParser"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _graphqlCompose = require('graphql-compose');
var _graphqlCompose = require("graphql-compose");
exports.default = _graphqlCompose.InputTypeComposer.create({
var _default = _graphqlCompose.InputTypeComposer.create({
name: 'AwsConfig',

@@ -17,2 +18,4 @@ fields: {

}
});
});
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,61 +6,35 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _graphqlCompose = require("graphql-compose");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
class TypeStorage extends Map {
// this `create` hack due TypeError:
// Constructor Map requires 'new' at TypeStorage.Map (native)
static create(array) {
const inst = new Map(array); // $FlowFixMe
var _createClass2 = require('babel-runtime/helpers/createClass');
inst.__proto__ = TypeStorage.prototype; // eslint-disable-line
var _createClass3 = _interopRequireDefault(_createClass2);
return inst;
}
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
getOrSet(typeName, typeOrThunk) {
if (this.has(typeName)) {
return this.get(typeName);
}
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
const gqType = (0, _graphqlCompose.isFunction)(typeOrThunk) ? typeOrThunk() : typeOrThunk;
var _inherits2 = require('babel-runtime/helpers/inherits');
if (gqType) {
this.set(typeName, gqType);
}
var _inherits3 = _interopRequireDefault(_inherits2);
var _graphqlCompose = require('graphql-compose');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var TypeStorage = function (_Map) {
(0, _inherits3.default)(TypeStorage, _Map);
function TypeStorage() {
(0, _classCallCheck3.default)(this, TypeStorage);
return (0, _possibleConstructorReturn3.default)(this, (TypeStorage.__proto__ || Object.getPrototypeOf(TypeStorage)).apply(this, arguments));
return gqType;
}
(0, _createClass3.default)(TypeStorage, [{
key: 'getOrSet',
value: function getOrSet(typeName, typeOrThunk) {
if (this.has(typeName)) {
return this.get(typeName);
}
}
var gqType = (0, _graphqlCompose.isFunction)(typeOrThunk) ? typeOrThunk() : typeOrThunk;
if (gqType) {
this.set(typeName, gqType);
}
return gqType;
}
}], [{
key: 'create',
// this `create` hack due TypeError:
// Constructor Map requires 'new' at TypeStorage.Map (native)
value: function create(array) {
var inst = new Map(array);
// $FlowFixMe
inst.__proto__ = TypeStorage.prototype; // eslint-disable-line
return inst;
}
}]);
return TypeStorage;
}(Map);
var typeStorage = TypeStorage.create();
exports.default = typeStorage;
const typeStorage = TypeStorage.create();
var _default = typeStorage;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,7 +6,2 @@ Object.defineProperty(exports, "__esModule", {

});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
exports.getTypeName = getTypeName;

@@ -17,8 +12,10 @@ exports.getOrSetType = getOrSetType;

var _typeStorage = require('./typeStorage');
var _typeStorage = _interopRequireDefault(require("./typeStorage"));
var _typeStorage2 = _interopRequireDefault(_typeStorage);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function getTypeName(name, opts) {

@@ -29,7 +26,8 @@ return `${opts && opts.prefix || 'Elastic'}${name}${opts && opts.postfix || ''}`;

function getOrSetType(typeName, typeOrThunk) {
var type = _typeStorage2.default.getOrSet(typeName, typeOrThunk);
const type = _typeStorage.default.getOrSet(typeName, typeOrThunk);
return type;
}
} // Remove newline multiline in descriptions
// Remove newline multiline in descriptions
function desc(str) {

@@ -40,5 +38,7 @@ return str.replace(/\n\s+/gi, ' ').replace(/^\s+/, '');

function reorderKeys(obj, names) {
var orderedFields = {};
var fields = (0, _extends3.default)({}, obj);
names.forEach(function (name) {
const orderedFields = {};
const fields = _objectSpread({}, obj);
names.forEach(name => {
if (fields[name]) {

@@ -49,3 +49,3 @@ orderedFields[name] = fields[name];

});
return (0, _extends3.default)({}, orderedFields, fields);
return _objectSpread({}, orderedFields, fields);
}
{
"name": "graphql-compose-aws",
"version": "1.1.0",
"version": "2.0.0",
"description": "AWS Cloud API via GraphQL",

@@ -27,35 +27,36 @@ "files": [

"homepage": "https://github.com/graphql-compose/graphql-compose-aws#readme",
"dependencies": {
"babel-runtime": "^6.26.0"
},
"peerDependencies": {
"graphql-compose": ">=2.10.1 || >=3.0.0 || >=4.0.0"
"graphql-compose": ">=5.0.1 || >=4.0.0 || >=3.0.0 || >=2.10.1"
},
"devDependencies": {
"aws-sdk": "^2.263.1",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.5",
"babel-jest": "^23.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"aws-sdk": "^2.308.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.4.2",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^5.0.1",
"eslint": "^5.5.0",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.49.3",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-prettier": "^2.6.1",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-flowtype": "^2.50.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-prettier": "^2.6.2",
"express": "^4.16.3",
"express-graphql": "^0.6.12",
"flow-bin": "^0.75.0",
"graphql": "0.13.2",
"graphql-compose": "^4.4.1",
"jest": "^23.2.0",
"nodemon": "^1.17.5",
"prettier": "^1.13.6",
"flow-bin": "^0.80.0",
"graphql": "14.0.0",
"graphql-compose": "^5.0.2",
"jest": "^23.5.0",
"nodemon": "^1.18.4",
"prettier": "^1.14.2",
"rimraf": "^2.6.2",
"semantic-release": "^15.6.0"
"semantic-release": "^15.9.12"
},

@@ -62,0 +63,0 @@ "config": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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