Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ ignore:
reason: 'Transitive dependency in Docusaurus; not exploitable in current usage.'
expires: '2026-06-28T00:00:00.000Z'
created: '2026-05-11T10:00:00.000Z'
'SNYK-JS-AI-16734889':
- '* > ai@5.0.105':
reason: 'Transitive dependency in @docusaurus/preset-classic; not exploitable in current usage.'
expires: '2026-06-18T00:00:00.000Z'
created: '2026-05-18T11:04:00.000Z'
'SNYK-JS-AISDKPROVIDERUTILS-16734888':
- '* > @ai-sdk/provider-utils@3.0.18':
reason: 'Transitive dependency in @docusaurus/preset-classic; not exploitable in current usage.'
expires: '2026-06-18T00:00:00.000Z'
created: '2026-05-18T11:04:00.000Z'
'SNYK-JS-AISDKPROVIDERUTILS-16735288':
- '* > @ai-sdk/provider-utils@3.0.18':
reason: 'Transitive dependency in @docusaurus/preset-classic; not exploitable in current usage.'
expires: '2026-06-18T00:00:00.000Z'
created: '2026-05-18T11:04:00.000Z'
12 changes: 6 additions & 6 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"test:watch": "vitest"
},
"dependencies": {
"@docusaurus/core": "3.9.2",
"@docusaurus/plugin-content-docs": "^3.9.2",
"@docusaurus/preset-classic": "3.9.2",
"@docusaurus/core": "3.10.1",
"@docusaurus/plugin-content-docs": "^3.10.1",
"@docusaurus/preset-classic": "3.10.1",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
Expand All @@ -31,9 +31,9 @@
"devDependencies": {
"@cellix/config-typescript": "workspace:*",
"@cellix/config-vitest": "workspace:*",
"@docusaurus/module-type-aliases": "3.9.2",
"@docusaurus/tsconfig": "3.9.2",
"@docusaurus/types": "3.9.2",
"@docusaurus/module-type-aliases": "3.10.1",
"@docusaurus/tsconfig": "3.10.1",
"@docusaurus/types": "3.10.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@types/react": "^19.1.11",
Expand Down
5 changes: 4 additions & 1 deletion apps/server-mongodb-memory-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
},
"dependencies": {
"@cellix/server-mongodb-memory-mock-seedwork": "workspace:*",
"dotenv": "^16.4.5"
"@ocom/data-sources-mongoose-models": "workspace:*",
"dotenv": "^16.4.5",
"mongodb": "catalog:",
"mongoose": "catalog:"
},
"devDependencies": {
"@cellix/config-typescript": "workspace:*",
Expand Down
52 changes: 17 additions & 35 deletions apps/server-mongodb-memory-mock/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
import { startMongoMemoryReplicaSet, type MongoMemoryReplicaSetConfig } from '@cellix/server-mongodb-memory-mock-seedwork';
import { type MongoMemoryServerConfig, startMockMongoDB } from '@cellix/server-mongodb-memory-mock-seedwork';
import { seedDatabase } from './seed/seed.ts';
import { setupEnvironment } from './setup-environment.ts';

setupEnvironment();

const { PORT, DB_NAME, REPL_SET_NAME } = process.env;
const collectionsToSeed = ['users', 'communities', 'roles', 'members', 'properties', 'services'];

const config: MongoMemoryReplicaSetConfig = {
port: Number(PORT ?? 50000),
dbName: DB_NAME ?? 'owner-community',
replSetName: REPL_SET_NAME ?? 'globaldb',
};
const { PORT, DB_NAME, REPL_SET_NAME } = process.env;

// Start replica set and wire disposer into process shutdown handlers
try {
const { disposer } = await startMongoMemoryReplicaSet(config);
const port = Number(PORT ?? 50000);
const dbName = DB_NAME ?? 'owner-community';
const replSetName = REPL_SET_NAME ?? 'globaldb';

const shutdown = async (signal?: string, exitCode = 0) => {
try {
console.log(`Shutting down MongoDB memory replica set (${signal ?? 'signal'})`);
await disposer.stop();
} catch (err) {
console.error('Error during MongoDB replica set shutdown:', err);
} finally {
// Exit with provided code so CI can detect crash paths when appropriate
process.exit(exitCode);
}
};
const config: MongoMemoryServerConfig = {
collectionsToSeed,
seedDatabase,
port,
dbName,
replSetName,
};

process.once('SIGINT', () => void shutdown('SIGINT'));
process.once('SIGTERM', () => void shutdown('SIGTERM'));
process.once('SIGQUIT', () => void shutdown('SIGQUIT'));
process.once('uncaughtException', async (err) => {
console.error('Uncaught exception, shutting down:', err);
await shutdown('uncaughtException', 1);
});
process.once('unhandledRejection', async (reason) => {
console.error('Unhandled rejection, shutting down:', reason);
await shutdown('unhandledRejection', 1);
});
} catch (error: unknown) {
console.error('Failed to start MongoDB memory replica set:', error);
startMockMongoDB(config).catch((err: unknown) => {
console.error('Failed to start mock MongoDB:', err);
process.exit(1);
}
});
21 changes: 21 additions & 0 deletions apps/server-mongodb-memory-mock/src/seed/communities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Community } from '@ocom/data-sources-mongoose-models/community';
import { END_USER_IDS } from './end-users.ts';

export const COMMUNITY_IDS = {
riverside: 'b00000000000000000000001',
} as const;

export const communities = [
{
_id: COMMUNITY_IDS.riverside,
name: 'Riverside Community',
domain: 'riverside',
whiteLabelDomain: '',
handle: 'riverside',
createdBy: END_USER_IDS.testUser,
schemaVersion: '1.0.0',
version: 0,
createdAt: new Date('2024-02-01T00:00:00Z'),
updatedAt: new Date('2024-02-01T00:00:00Z'),
},
] as unknown as Community[];
53 changes: 53 additions & 0 deletions apps/server-mongodb-memory-mock/src/seed/end-users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { EndUser } from '@ocom/data-sources-mongoose-models/user/end-user';

export const END_USER_IDS = {
testUser: 'a00000000000000000000001',
janeSmith: 'a00000000000000000000002',
} as const;

export const endUsers = [
{
_id: END_USER_IDS.testUser,
userType: 'end-users',
externalId: '00000000-0000-4000-8000-000000000001',
displayName: 'Test User',
email: 'test@example.com',
personalInformation: {
identityDetails: {
lastName: 'User',
legalNameConsistsOfOneName: false,
restOfName: 'Test',
},
contactInformation: {
email: 'test@example.com',
},
},
accessBlocked: false,
tags: [],
schemaVersion: '1.0.0',
createdAt: new Date('2024-01-01T00:00:00Z'),
updatedAt: new Date('2024-01-01T00:00:00Z'),
},
{
_id: END_USER_IDS.janeSmith,
userType: 'end-users',
externalId: '00000000-0000-4000-8000-000000000002',
displayName: 'Jane Smith',
email: 'jane@example.com',
personalInformation: {
identityDetails: {
lastName: 'Smith',
legalNameConsistsOfOneName: false,
restOfName: 'Jane',
},
contactInformation: {
email: 'jane@example.com',
},
},
accessBlocked: false,
tags: [],
schemaVersion: '1.0.0',
createdAt: new Date('2024-01-15T00:00:00Z'),
updatedAt: new Date('2024-01-15T00:00:00Z'),
},
] as unknown as EndUser[];
82 changes: 82 additions & 0 deletions apps/server-mongodb-memory-mock/src/seed/members.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import type { Member } from '@ocom/data-sources-mongoose-models/member';
import { COMMUNITY_IDS } from './communities.ts';
import { END_USER_IDS } from './end-users.ts';
import { ROLE_IDS } from './roles.ts';

export const MEMBER_IDS = {
testUserMember: 'd00000000000000000000001',
janeSmithMember: 'd00000000000000000000002',
} as const;

export const members = [
{
_id: MEMBER_IDS.testUserMember,
memberName: 'Test User',
community: COMMUNITY_IDS.riverside,
role: ROLE_IDS.admin,
accounts: [
{
firstName: 'Test',
lastName: 'User',
user: END_USER_IDS.testUser,
statusCode: 'ACCEPTED',
createdBy: END_USER_IDS.testUser,
createdAt: new Date('2024-02-01T00:00:00Z'),
updatedAt: new Date('2024-02-01T00:00:00Z'),
version: 0,
},
],
customViews: [],
profile: {
name: 'Test User',
email: 'test@example.com',
bio: 'Community admin and test user.',
avatarDocumentId: '',
interests: ['community-management', 'testing'],
showInterests: true,
showEmail: true,
showProfile: true,
showLocation: true,
showProperties: true,
},
schemaVersion: '1.0.0',
version: 0,
createdAt: new Date('2024-02-01T00:00:00Z'),
updatedAt: new Date('2024-02-01T00:00:00Z'),
},
{
_id: MEMBER_IDS.janeSmithMember,
memberName: 'Jane Smith',
community: COMMUNITY_IDS.riverside,
role: ROLE_IDS.member,
accounts: [
{
firstName: 'Jane',
lastName: 'Smith',
user: END_USER_IDS.janeSmith,
statusCode: 'ACCEPTED',
createdBy: END_USER_IDS.testUser,
createdAt: new Date('2024-02-15T00:00:00Z'),
updatedAt: new Date('2024-02-15T00:00:00Z'),
version: 0,
},
],
customViews: [],
profile: {
name: 'Jane Smith',
email: 'jane@example.com',
bio: 'Riverside community member.',
avatarDocumentId: '',
interests: ['gardening', 'community-events'],
showInterests: true,
showEmail: false,
showProfile: true,
showLocation: false,
showProperties: true,
},
schemaVersion: '1.0.0',
version: 0,
createdAt: new Date('2024-02-15T00:00:00Z'),
updatedAt: new Date('2024-02-15T00:00:00Z'),
},
] as unknown as Member[];
Loading
Loading