@wepublish/api
Version:
API core for we.publish.
124 lines • 6.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLSubscribersPerMonth = exports.GraphQLSubscriptionInput = exports.GraphQLSubscriptionDeactivationInput = exports.GraphQLSubscriptionConnection = exports.GraphQLSubscriptionSort = exports.GraphQLSubscriptionFilter = exports.GraphQLSubscription = void 0;
const tslib_1 = require("tslib");
const api_1 = require("../../../user-api/src");
const graphql_1 = require("graphql");
const graphql_scalars_1 = require("graphql-scalars");
const subscription_1 = require("../db/subscription");
const common_1 = require("./common");
const memberPlan_1 = require("./memberPlan");
const paymentMethod_1 = require("./paymentMethod");
const subscriptionDeactivation_1 = require("./subscriptionDeactivation");
const user_1 = require("./user");
exports.GraphQLSubscription = new graphql_1.GraphQLObjectType({
name: 'Subscription',
fields: {
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) },
createdAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) },
modifiedAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) },
user: {
type: user_1.GraphQLUser,
resolve({ userID }, args, { prisma }) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return prisma.user.findUnique({
where: {
id: userID
},
select: api_1.unselectPassword
});
});
}
},
memberPlan: {
type: new graphql_1.GraphQLNonNull(memberPlan_1.GraphQLMemberPlan),
resolve({ memberPlanID }, args, { loaders }) {
return loaders.memberPlansByID.load(memberPlanID);
}
},
paymentPeriodicity: { type: new graphql_1.GraphQLNonNull(memberPlan_1.GraphQLPaymentPeriodicity) },
monthlyAmount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
autoRenew: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
startsAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) },
paidUntil: { type: graphql_scalars_1.GraphQLDateTime },
paymentMethod: {
type: new graphql_1.GraphQLNonNull(paymentMethod_1.GraphQLPaymentMethod),
resolve({ paymentMethodID }, args, { loaders }) {
return loaders.paymentMethodsByID.load(paymentMethodID);
}
},
properties: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(common_1.GraphQLMetadataProperty)))
},
deactivation: { type: subscriptionDeactivation_1.GraphQLSubscriptionDeactivation }
}
});
exports.GraphQLSubscriptionFilter = new graphql_1.GraphQLInputObjectType({
name: 'SubscriptionFilter',
fields: {
startsAt: { type: common_1.GraphQLDateFilter },
paidUntil: { type: common_1.GraphQLDateFilter },
startsAtFrom: { type: common_1.GraphQLDateFilter },
startsAtTo: { type: common_1.GraphQLDateFilter },
paidUntilFrom: { type: common_1.GraphQLDateFilter },
paidUntilTo: { type: common_1.GraphQLDateFilter },
deactivationDateFrom: { type: common_1.GraphQLDateFilter },
deactivationDateTo: { type: common_1.GraphQLDateFilter },
cancellationDateFrom: { type: common_1.GraphQLDateFilter },
cancellationDateTo: { type: common_1.GraphQLDateFilter },
deactivationReason: { type: subscriptionDeactivation_1.GraphQLSubscriptionDeactivationReason },
autoRenew: { type: graphql_1.GraphQLBoolean },
paymentMethodID: { type: graphql_1.GraphQLString },
memberPlanID: { type: graphql_1.GraphQLString },
paymentPeriodicity: { type: memberPlan_1.GraphQLPaymentPeriodicity },
userHasAddress: { type: graphql_1.GraphQLBoolean },
userID: { type: graphql_1.GraphQLID }
}
});
exports.GraphQLSubscriptionSort = new graphql_1.GraphQLEnumType({
name: 'SubscriptionSort',
values: {
CREATED_AT: { value: subscription_1.SubscriptionSort.CreatedAt },
MODIFIED_AT: { value: subscription_1.SubscriptionSort.ModifiedAt }
}
});
exports.GraphQLSubscriptionConnection = new graphql_1.GraphQLObjectType({
name: 'SubscriptionConnection',
fields: {
nodes: { type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLSubscription))) },
pageInfo: { type: new graphql_1.GraphQLNonNull(common_1.GraphQLPageInfo) },
totalCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) }
}
});
exports.GraphQLSubscriptionDeactivationInput = new graphql_1.GraphQLInputObjectType({
name: 'SubscriptionDeactivationInput',
fields: {
date: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) },
reason: { type: new graphql_1.GraphQLNonNull(subscriptionDeactivation_1.GraphQLSubscriptionDeactivationReason) }
}
});
exports.GraphQLSubscriptionInput = new graphql_1.GraphQLInputObjectType({
name: 'SubscriptionInput',
fields: {
userID: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) },
memberPlanID: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
paymentPeriodicity: { type: new graphql_1.GraphQLNonNull(memberPlan_1.GraphQLPaymentPeriodicity) },
monthlyAmount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
autoRenew: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
startsAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) },
paidUntil: { type: graphql_scalars_1.GraphQLDateTime },
paymentMethodID: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
properties: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(common_1.GraphQLMetadataPropertyInput)))
},
deactivation: { type: exports.GraphQLSubscriptionDeactivationInput }
}
});
exports.GraphQLSubscribersPerMonth = new graphql_1.GraphQLObjectType({
name: 'SubscribersPerMonth',
fields: {
month: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
subscriberCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) }
}
});
//# sourceMappingURL=subscription.js.map