Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _lodash = _interopRequireDefault(require("lodash"));
var _graphqlTools = require("graphql-tools");
var _utils = require("../inputTypes/utils");
var HANDLER = _interopRequireWildcard(require("../inputTypes/handlers"));
var KIND = _interopRequireWildcard(require("../inputTypes/kinds"));
var _utils2 = require("../utils");
const DirectiveDBScheme = `directive @db(name:String!, defaultValue:String=null) on FIELD_DEFINITION`;
exports.DirectiveDBScheme = DirectiveDBScheme;
class DirectiveDB extends _graphqlTools.SchemaDirectiveVisitor {
constructor(...args) {
super(...args);
(0, _defineProperty2.default)(this, "_renameTransform", (fieldName, dbName) => params => {
let value = params[fieldName];
return { ..._lodash.default.omit(params, fieldName),
[dbName]: value
};
});
}
visitFieldDefinition(field) {
const {
name
} = this.args;
(0, _utils.appendTransform)(field, HANDLER.TRANSFORM_INPUT, {
[KIND.CREATE]: this._renameTransform(field.name, name),
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _graphqlTools = require("graphql-tools");
var _utils = require("../../inputTypes/utils");
var _transforms = require("../../inputTypes/transforms");
var _handlers = require("../../inputTypes/handlers");
var _kinds = require("../../inputTypes/kinds");
const typeDef = `directive @default(value: String!) on FIELD_DEFINITION`;
exports.typeDef = typeDef;
class DefaultDirective extends _graphqlTools.SchemaDirectiveVisitor {
constructor(...args) {
super(...args);
(0, _defineProperty2.default)(this, "_setDefaultValue", (fieldName, defaultValue) => params => {
let value = params[fieldName];
if (value === undefined || value === null) {
params[fieldName] = defaultValue;
}
return params;
});
}
visitFieldDefinition(field) {
let {
value
value: true
});
exports.default = exports.InheritScheme = void 0;
var _graphql = require("graphql");
var _graphqlTools = require("graphql-tools");
var _lodash = _interopRequireDefault(require("lodash"));
var _utils = require("../utils");
const InheritScheme = `directive @inherit on INTERFACE`;
exports.InheritScheme = InheritScheme;
class Inherit extends _graphqlTools.SchemaDirectiveVisitor {
visitInterface(iface) {
const {
_typeMap: SchemaTypes
} = this.schema;
if (!iface.mmDiscriminatorField) {
iface.mmDiscriminatorField = '_type';
}
_lodash.default.values(SchemaTypes).filter(type => type._interfaces && type._interfaces.includes(iface)).forEach(type => {
type._fields = { ...iface._fields,
...type._fields
};
if (!type.mmDiscriminator) {
type.mmDiscriminator = (0, _utils.lowercaseFirstLetter)(type.name);
var _default = queryExecutor => {
var _temp;
return _temp = class ExtRelationDirective extends _graphqlTools.SchemaDirectiveVisitor {
constructor(..._args) {
super(..._args);
(0, _defineProperty2.default)(this, "_onSchemaInit", ({
field
}) => {
let {
mmFieldTypeWrap: fieldTypeWrap
} = this;
if (fieldTypeWrap.isMany()) {
let whereType = _inputTypes.default.get(fieldTypeWrap.realType(), fieldTypeWrap.isInterface() ? KIND.WHERE_INTERFACE : KIND.WHERE);
let orderByType = _inputTypes.default.get(fieldTypeWrap.realType(), KIND.ORDER_BY);
field.args = (0, _utils.allQueryArgs)({
whereType,
value: true
});
exports.schemaDirectives = exports.typeDef = void 0;
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
var _graphqlTools = require("graphql-tools");
var _inputTypes = _interopRequireDefault(require("../../inputTypes"));
const typeDef = _graphqlTag.default`
directive @initInputTypes on OBJECT
`;
exports.typeDef = typeDef;
class InitInputTypes extends _graphqlTools.SchemaDirectiveVisitor {
visitObject(object) {
const {
_typeMap: SchemaTypes
} = this.schema;
_inputTypes.default.setSchemaTypes(SchemaTypes);
}
}
const schemaDirectives = {
initInputTypes: InitInputTypes
};
exports.schemaDirectives = schemaDirectives;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.AbstractScheme = void 0;
var _graphqlTools = require("graphql-tools");
const AbstractScheme = `directive @abstract(from:String = null) on INTERFACE`;
exports.AbstractScheme = AbstractScheme;
class Inherit extends _graphqlTools.SchemaDirectiveVisitor {
visitInterface(iface) {
const {
_typeMap: SchemaTypes
} = this.schema;
iface.mmAbstract = true;
iface.mmAbstractTypes = [];
iface._setAbstractTypes = function () {
if (this.mmFromAbstract) {
let types = new Set([...this.mmFromAbstract.mmAbstractTypes, ...this.mmAbstractTypes]);
this.mmFromAbstract.mmAbstractTypes = Array.from(types);
this.mmFromAbstract._setAbstractTypes();
}
}.bind(iface);
var _default = queryExecutor => {
var _temp;
return _temp = class RelationDirective extends _graphqlTools.SchemaDirectiveVisitor {
constructor(..._args) {
super(..._args);
(0, _defineProperty2.default)(this, "_transformToInputWhere", ({
field
}) => {
const {
field: relationField
} = this.args;
let {
mmFieldTypeWrap: fieldTypeWrap,
mmCollectionName: collection,
mmStoreField: storeField
} = this;
let inputType = _inputTypes.default.get(fieldTypeWrap.realType(), KIND.WHERE);
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(TimestampDirective)).call.apply(_getPrototypeOf2, [this].concat(args)));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "_setDateCreate", function (fieldName) {
return function (params) {
return (0, _defineProperty2.default)({}, fieldName, new Date().toISOString());
};
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "_setDateUpdate", function (fieldName) {
return function (params) {
return (0, _defineProperty2.default)({}, fieldName, new Date().toISOString());
};
});
return _this;
}
return TimestampDirective;
}(_graphqlTools.SchemaDirectiveVisitor);
exports.TimestampDirective = TimestampDirective;
value: true
});
exports.default = exports.IDScheme = void 0;
var _graphqlTools = require("graphql-tools");
var _utils = require("../inputTypes/utils");
var HANDLER = _interopRequireWildcard(require("../inputTypes/handlers"));
var KIND = _interopRequireWildcard(require("../inputTypes/kinds"));
const IDScheme = `directive @id on FIELD_DEFINITION`;
exports.IDScheme = IDScheme;
class ID extends _graphqlTools.SchemaDirectiveVisitor {
visitFieldDefinition(field) {
(0, _utils.appendTransform)(field, HANDLER.TRANSFORM_TO_INPUT, {
[KIND.CREATE]: field => [],
[KIND.UPDATE]: field => []
});
}
}
exports.default = ID;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.schemaDirectives = exports.typeDef = void 0;
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
var _graphqlTools = require("graphql-tools");
const typeDef = _graphqlTag.default`
directive @discriminator(value: String) on OBJECT | INTERFACE
`;
exports.typeDef = typeDef;
class Discriminator extends _graphqlTools.SchemaDirectiveVisitor {
visitInterface(iface) {
const {
value
} = this.args;
iface.mmDiscriminatorField = value;
}
visitObject(object) {
const {
value
} = this.args;
object.mmDiscriminator = value;
}
}