Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Meeting staging to dev #338

Merged
merged 24 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c60e067
change calendar to fullcalendar
enkhtuvshinD Sep 6, 2023
4e81750
hide expire date meetings in sidebar
enkhtuvshinD Sep 6, 2023
b0163c2
add calendar full screen
enkhtuvshinD Sep 6, 2023
b84ee69
participant user get from core
enkhtuvshinD Sep 6, 2023
70a7d4a
convert to styled component
enkhtuvshinD Sep 6, 2023
1f4262f
some code refactor
enkhtuvshinD Sep 6, 2023
a3a7bef
refactor
enkhtuvshinD Sep 6, 2023
0ee5f94
Merge branch 'staging' of https://github.com/erxes/erxes-community in…
enkhtuvshinD Sep 19, 2023
471d7a4
connected meeting with deal
enkhtuvshinD Sep 19, 2023
06fe398
refacor
enkhtuvshinD Sep 19, 2023
46210ad
added deal in meeting (#313)
enkhtuvshinD Sep 19, 2023
f0a9810
Merge branch 'staging' of https://github.com/erxes/erxes-community in…
enkhtuvshinD Sep 19, 2023
d2b2f48
refactor in meeting
enkhtuvshinD Sep 19, 2023
2437c9d
refactor in meeting (#314)
enkhtuvshinD Sep 19, 2023
dc6dcf4
Merge branch 'staging' of https://github.com/erxes/erxes-community in…
enkhtuvshinD Sep 19, 2023
3ccd528
add select deal, search meeting and link to deal
enkhtuvshinD Sep 19, 2023
a2d1d96
refactor in meeting
enkhtuvshinD Sep 20, 2023
aee4259
refactor in meeting
enkhtuvshinD Sep 20, 2023
f55f249
Merge branch 'dev' of https://github.com/erxes/erxes-community into m…
enkhtuvshinD Sep 26, 2023
e059acf
add pagination, shift to detail
enkhtuvshinD Sep 26, 2023
22e9435
refactor
enkhtuvshinD Sep 26, 2023
de8dc64
refactor
enkhtuvshinD Sep 26, 2023
ae7e93e
refactor pagination
enkhtuvshinD Sep 26, 2023
ceb1705
Merge branch 'dev' of https://github.com/erxes/erxes-community into m…
enkhtuvshinD Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 64 additions & 61 deletions packages/api-plugin-template.erxes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,74 +224,77 @@ async function startServer() {
const apolloServer = await generateApolloServer(serviceDiscovery);
await apolloServer.start();

app.use('/graphql', expressMiddleware(apolloServer, {
context: async ({ req, res }) => {
let user: any = null;

if (req.headers.user) {
if (Array.isArray(req.headers.user)) {
throw new Error(`Multiple user headers`);
app.use(
'/graphql',
expressMiddleware(apolloServer, {
context: async ({ req, res }) => {
let user: any = null;

if (req.headers.user) {
if (Array.isArray(req.headers.user)) {
throw new Error(`Multiple user headers`);
}
const userJson = Buffer.from(req.headers.user, 'base64').toString(
'utf-8'
);
user = JSON.parse(userJson);
}
const userJson = Buffer.from(req.headers.user, 'base64').toString(
'utf-8'
);
user = JSON.parse(userJson);
}

let context;

if (USE_BRAND_RESTRICTIONS !== 'true') {
context = {
brandIdSelector: {},
singleBrandIdSelector: {},
userBrandIdsSelector: {},
docModifier: doc => doc,
commonQuerySelector: {},
user,
res
};
} else {
let scopeBrandIds = JSON.parse(req.cookies.scopeBrandIds || '[]');
let brandIds = [];
let brandIdSelector = {};
let commonQuerySelector = {};
let commonQuerySelectorElk;
let userBrandIdsSelector = {};
let singleBrandIdSelector = {};

if (user) {
brandIds = user.brandIds || [];

if (scopeBrandIds.length === 0) {
scopeBrandIds = brandIds;
let context;

if (USE_BRAND_RESTRICTIONS !== 'true') {
context = {
brandIdSelector: {},
singleBrandIdSelector: {},
userBrandIdsSelector: {},
docModifier: doc => doc,
commonQuerySelector: {},
user,
res
};
} else {
let scopeBrandIds = JSON.parse(req.cookies.scopeBrandIds || '[]');
let brandIds = [];
let brandIdSelector = {};
let commonQuerySelector = {};
let commonQuerySelectorElk;
let userBrandIdsSelector = {};
let singleBrandIdSelector = {};

if (user) {
brandIds = user.brandIds || [];

if (scopeBrandIds.length === 0) {
scopeBrandIds = brandIds;
}

if (!user.isOwner && scopeBrandIds.length > 0) {
brandIdSelector = { _id: { $in: scopeBrandIds } };
commonQuerySelector = { scopeBrandIds: { $in: scopeBrandIds } };
commonQuerySelectorElk = { terms: { scopeBrandIds } };
userBrandIdsSelector = { brandIds: { $in: scopeBrandIds } };
singleBrandIdSelector = { brandId: { $in: scopeBrandIds } };
}
}

if (!user.isOwner && scopeBrandIds.length > 0) {
brandIdSelector = { _id: { $in: scopeBrandIds } };
commonQuerySelector = { scopeBrandIds: { $in: scopeBrandIds } };
commonQuerySelectorElk = { terms: { scopeBrandIds } };
userBrandIdsSelector = { brandIds: { $in: scopeBrandIds } };
singleBrandIdSelector = { brandId: { $in: scopeBrandIds } };
}
context = {
brandIdSelector,
singleBrandIdSelector,
docModifier: doc => ({ ...doc, scopeBrandIds }),
commonQuerySelector,
commonQuerySelectorElk,
userBrandIdsSelector,
user,
res
};
}

context = {
brandIdSelector,
singleBrandIdSelector,
docModifier: doc => ({ ...doc, scopeBrandIds }),
commonQuerySelector,
commonQuerySelectorElk,
userBrandIdsSelector,
user,
res
};
}

await configs.apolloServerContext(context, req, res);
await configs.apolloServerContext(context, req, res);

return context;
}
}));
return context;
}
})
);

await new Promise<void>(resolve =>
httpServer.listen({ port: PORT }, resolve)
Expand Down
6 changes: 4 additions & 2 deletions packages/api-utils/src/random.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { customAlphabet } from 'nanoid';

export const randomAlphanumeric = customAlphabet('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
export const randomLowercase = customAlphabet('abcdefghijklmnopqrstuvwxyz');
export const randomAlphanumeric = customAlphabet(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
);
export const randomLowercase = customAlphabet('abcdefghijklmnopqrstuvwxyz');
3 changes: 1 addition & 2 deletions packages/api-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,4 @@ export interface IAttachment {
type: string;
}


// trigger
// trigger
131 changes: 67 additions & 64 deletions packages/core/src/apolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,81 @@ export const initApolloServer = async (app, httpServer) => {
}
]),
// for graceful shutdowns
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })]
});

await apolloServer.start();

app.use('/graphql', expressMiddleware(apolloServer, {
context: async ({ req, res }) => {
const subdomain = getSubdomain(req);
const models = await generateModels(subdomain);
app.use(
'/graphql',
expressMiddleware(apolloServer, {
context: async ({ req, res }) => {
const subdomain = getSubdomain(req);
const models = await generateModels(subdomain);

let user: any = null;
let user: any = null;

if (req.headers.user) {
const userJson = Buffer.from(req.headers.user, 'base64').toString(
'utf-8'
);
user = JSON.parse(userJson);
}
if (req.headers.user) {
const userJson = Buffer.from(req.headers.user, 'base64').toString(
'utf-8'
);
user = JSON.parse(userJson);
}

const dataLoaders: IDataLoaders = generateAllDataLoaders(models);

const requestInfo = {
secure: req.secure,
cookies: req.cookies
};

const dataLoaders: IDataLoaders = generateAllDataLoaders(models);
if (USE_BRAND_RESTRICTIONS !== 'true') {
return {
brandIdSelector: {},
singleBrandIdSelector: {},
userBrandIdsSelector: {},
docModifier: doc => doc,
commonQuerySelector: {},
user,
res,
requestInfo,
dataLoaders,
subdomain,
models
};
}

const requestInfo = {
secure: req.secure,
cookies: req.cookies
};
let scopeBrandIds = JSON.parse(req.cookies.scopeBrandIds || '[]');
let brandIds = [];
let brandIdSelector = {};
let commonQuerySelector = {};
let commonQuerySelectorElk;
let userBrandIdsSelector = {};
let singleBrandIdSelector = {};

if (user) {
brandIds = user.brandIds || [];

if (scopeBrandIds.length === 0) {
scopeBrandIds = brandIds;
}

if (!user.isOwner && scopeBrandIds.length > 0) {
brandIdSelector = { _id: { $in: scopeBrandIds } };
commonQuerySelector = { scopeBrandIds: { $in: scopeBrandIds } };
commonQuerySelectorElk = { terms: { scopeBrandIds } };
userBrandIdsSelector = { brandIds: { $in: scopeBrandIds } };
singleBrandIdSelector = { brandId: { $in: scopeBrandIds } };
}
}

if (USE_BRAND_RESTRICTIONS !== 'true') {
return {
brandIdSelector: {},
singleBrandIdSelector: {},
userBrandIdsSelector: {},
docModifier: doc => doc,
commonQuerySelector: {},
brandIdSelector,
singleBrandIdSelector,
docModifier: doc => ({ ...doc, scopeBrandIds }),
commonQuerySelector,
commonQuerySelectorElk,
userBrandIdsSelector,
user,
res,
requestInfo,
Expand All @@ -79,47 +121,8 @@ export const initApolloServer = async (app, httpServer) => {
models
};
}

let scopeBrandIds = JSON.parse(req.cookies.scopeBrandIds || '[]');
let brandIds = [];
let brandIdSelector = {};
let commonQuerySelector = {};
let commonQuerySelectorElk;
let userBrandIdsSelector = {};
let singleBrandIdSelector = {};

if (user) {
brandIds = user.brandIds || [];

if (scopeBrandIds.length === 0) {
scopeBrandIds = brandIds;
}

if (!user.isOwner && scopeBrandIds.length > 0) {
brandIdSelector = { _id: { $in: scopeBrandIds } };
commonQuerySelector = { scopeBrandIds: { $in: scopeBrandIds } };
commonQuerySelectorElk = { terms: { scopeBrandIds } };
userBrandIdsSelector = { brandIds: { $in: scopeBrandIds } };
singleBrandIdSelector = { brandId: { $in: scopeBrandIds } };
}
}

return {
brandIdSelector,
singleBrandIdSelector,
docModifier: doc => ({ ...doc, scopeBrandIds }),
commonQuerySelector,
commonQuerySelectorElk,
userBrandIdsSelector,
user,
res,
requestInfo,
dataLoaders,
subdomain,
models
};
}
}));
})
);

return apolloServer;
};
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/db/models/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const getUniqueValue = async (
defaultValue?: string
) => {
const getRandomValue = (type: string) =>
type === 'email' ? faker.internet.email().toLowerCase() : randomAlphanumeric();
type === 'email'
? faker.internet.email().toLowerCase()
: randomAlphanumeric();

let uniqueValue = defaultValue || getRandomValue(fieldName);

Expand Down
8 changes: 6 additions & 2 deletions packages/gateway/src/apollo-router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ const startRouter = async (

const devOptions = ['--dev', '--hot-reload'];

console.log("-------------------------------routerConfigPath--------------------------------")
console.log(
'-------------------------------routerConfigPath--------------------------------'
);
console.log([
...(NODE_ENV === 'development' ? devOptions : []),
'--log',
Expand All @@ -116,7 +118,9 @@ const startRouter = async (
`--config`,
routerConfigPath
]);
console.log("----------------------------------------------------------------------")
console.log(
'----------------------------------------------------------------------'
);

const routerProcess = spawn(
routerPath,
Expand Down
4 changes: 1 addition & 3 deletions packages/gateway/src/subscription/SubscriptionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ export default class SubscriptionResolver {
}

private async query(graphqlRequest: GraphQLRequest): Promise<FetchResult> {
const response = await toPromise(
execute(this.apolloLink, graphqlRequest)
);
const response = await toPromise(execute(this.apolloLink, graphqlRequest));
return response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { nanoid } from 'nanoid';
/*
* Mongoose field options wrapper
*/
export const field = (options) => {
export const field = options => {
const { pkey, type, optional } = options;

if (type === String && !pkey && !optional) {
Expand All @@ -19,7 +19,7 @@ export const field = (options) => {
return options;
};

export const schemaWrapper = (schema) => {
export const schemaWrapper = schema => {
schema.add({ scopeBrandIds: [String] });

return schema;
Expand All @@ -33,7 +33,7 @@ const hookList = [
'updateMany',
'deleteOne',
'deleteMany',
'findOneAndUpdate',
'findOneAndUpdate'
];

export const schemaHooksWrapper = (schema, cacheKey: string) => {
Expand Down
Loading