@wepublish/api
Version:
API core for we.publish.
179 lines • 9.08 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLMemberPlanInput = exports.GraphQLAvailablePaymentMethodInput = exports.GraphQLPublicMemberPlanConnection = exports.GraphQLMemberPlanConnection = exports.GraphQLMemberPlanSort = exports.GraphQLMemberPlanFilter = exports.GraphQLPublicMemberPlan = exports.GraphQLMemberPlan = exports.GraphQLPublicAvailablePaymentMethod = exports.GraphQLAvailablePaymentMethod = exports.GraphQLPaymentPeriodicity = void 0;
const tslib_1 = require("tslib");
const memberPlan_1 = require("../db/memberPlan");
const api_1 = require("../../../richtext-api/src");
const image_1 = require("./image");
const utility_1 = require("../utility");
const graphql_1 = require("graphql");
const graphql_scalars_1 = require("graphql-scalars");
const common_1 = require("./common");
const paymentMethod_1 = require("./paymentMethod");
const client_1 = require("@prisma/client");
exports.GraphQLPaymentPeriodicity = new graphql_1.GraphQLEnumType({
name: 'PaymentPeriodicity',
values: {
MONTHLY: { value: client_1.PaymentPeriodicity.monthly },
QUARTERLY: { value: client_1.PaymentPeriodicity.quarterly },
BIANNUAL: { value: client_1.PaymentPeriodicity.biannual },
YEARLY: { value: client_1.PaymentPeriodicity.yearly }
}
});
exports.GraphQLAvailablePaymentMethod = new graphql_1.GraphQLObjectType({
name: 'AvailablePaymentMethod',
fields: {
paymentMethods: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(paymentMethod_1.GraphQLPaymentMethod))),
resolve({ paymentMethodIDs }, args, { prisma: { paymentMethod } }) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const paymentMethods = yield paymentMethod.findMany({
where: {
id: {
in: paymentMethodIDs
}
},
orderBy: {
createdAt: 'desc'
}
});
return paymentMethods;
});
}
},
paymentPeriodicities: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLPaymentPeriodicity)))
},
forceAutoRenewal: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) }
}
});
exports.GraphQLPublicAvailablePaymentMethod = new graphql_1.GraphQLObjectType({
name: 'AvailablePaymentMethod',
fields: {
paymentMethods: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(paymentMethod_1.GraphQLPublicPaymentMethod))),
resolve({ paymentMethodIDs }, args, { prisma: { paymentMethod } }) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const paymentMethods = yield paymentMethod.findMany({
where: {
id: {
in: paymentMethodIDs
},
active: true
},
orderBy: {
createdAt: 'desc'
}
});
return paymentMethods;
});
}
},
paymentPeriodicities: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLPaymentPeriodicity)))
},
forceAutoRenewal: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) }
}
});
exports.GraphQLMemberPlan = new graphql_1.GraphQLObjectType({
name: 'MemberPlan',
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) },
name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
slug: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
image: {
type: image_1.GraphQLImage,
resolve: (0, utility_1.createProxyingResolver)(({ imageID }, args, { loaders }) => {
return imageID ? loaders.images.load(imageID) : null;
})
},
description: { type: api_1.GraphQLRichText },
tags: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)) },
active: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
amountPerMonthMin: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
availablePaymentMethods: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLAvailablePaymentMethod)))
}
}
});
exports.GraphQLPublicMemberPlan = new graphql_1.GraphQLObjectType({
name: 'MemberPlan',
fields: {
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) },
name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
slug: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
image: {
type: image_1.GraphQLImage,
resolve: (0, utility_1.createProxyingResolver)(({ imageID }, args, { loaders }) => {
return imageID ? loaders.images.load(imageID) : null;
})
},
description: { type: api_1.GraphQLRichText },
tags: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)) },
amountPerMonthMin: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
availablePaymentMethods: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLPublicAvailablePaymentMethod)))
}
}
});
exports.GraphQLMemberPlanFilter = new graphql_1.GraphQLInputObjectType({
name: 'MemberPlanFilter',
fields: {
name: { type: graphql_1.GraphQLString },
active: { type: graphql_1.GraphQLBoolean },
tags: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)) }
}
});
exports.GraphQLMemberPlanSort = new graphql_1.GraphQLEnumType({
name: 'MemberPlanSort',
values: {
CREATED_AT: { value: memberPlan_1.MemberPlanSort.CreatedAt },
MODIFIED_AT: { value: memberPlan_1.MemberPlanSort.ModifiedAt }
}
});
exports.GraphQLMemberPlanConnection = new graphql_1.GraphQLObjectType({
name: 'MemberPlanConnection',
fields: {
nodes: { type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLMemberPlan))) },
pageInfo: { type: new graphql_1.GraphQLNonNull(common_1.GraphQLPageInfo) },
totalCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) }
}
});
exports.GraphQLPublicMemberPlanConnection = new graphql_1.GraphQLObjectType({
name: 'MemberPlanConnection',
fields: {
nodes: { type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLPublicMemberPlan))) },
pageInfo: { type: new graphql_1.GraphQLNonNull(common_1.GraphQLPageInfo) },
totalCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) }
}
});
exports.GraphQLAvailablePaymentMethodInput = new graphql_1.GraphQLInputObjectType({
name: 'AvailablePaymentMethodInput',
fields: {
paymentMethodIDs: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)))
},
paymentPeriodicities: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLPaymentPeriodicity)))
},
forceAutoRenewal: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) }
}
});
exports.GraphQLMemberPlanInput = new graphql_1.GraphQLInputObjectType({
name: 'MemberPlanInput',
fields: {
name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
slug: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
imageID: { type: graphql_1.GraphQLID },
description: { type: api_1.GraphQLRichText },
tags: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)) },
active: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
amountPerMonthMin: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
availablePaymentMethods: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLAvailablePaymentMethodInput)))
}
}
});
//# sourceMappingURL=memberPlan.js.map