Skip to content

Commit

Permalink
Merge pull request #316 from Axinom/releases/iteration-98-merge
Browse files Browse the repository at this point in the history
[AB#44203] release: iteration 98
  • Loading branch information
EmperorRXF authored Jun 7, 2024
2 parents 31b988d + 9f30295 commit a4bcfa1
Show file tree
Hide file tree
Showing 227 changed files with 3,899 additions and 3,297 deletions.
24 changes: 15 additions & 9 deletions .adops/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
trigger: none

pr:
- main
- dev

pool:
vmImage: 'ubuntu-latest'
demands: project_navy
name: 'Mosaic Auto Tests Cloud'

variables:
YARN_CACHE_FOLDER: /home/vsts/.yarn/berry/cache
Expand All @@ -28,6 +29,7 @@ stages:
placeholder
path: $(Agent.TempDirectory)/cache
displayName: Cache Yarn packages

- stage: pr_check
dependsOn: cache_init
jobs:
Expand All @@ -45,13 +47,22 @@ stages:
versionSpec: '18.x'
displayName: 'Install Node.js'

- script: yarn install --immutable
displayName: Install dependencies
- script: |
corepack enable # this is supposed to introduce yarn into the system.
echo "Yarn version $(yarn --version)"
echo "Node version $(node --version)"
docker --version
docker-compose --version
[ -d /home/vsts/ ] || sudo mkdir /home/vsts
sudo chown AzDevOps:AzDevOps -R /home/vsts
displayName: 'Setup Prerequisites'
- task: Bash@3
inputs:
targetType: 'inline'
script: |
yarn install
yarn build || echo "Build exited with non-0 exit code"
echo "Build Exit Code: $?"
displayName: Build
Expand All @@ -67,11 +78,6 @@ stages:
sed -i 's/^\(RABBITMQ_PASSWORD=\)$/\1fake/' .env
sed -i 's/^\(DEV_SERVICE_ACCOUNT_CLIENT_ID=\)$/\1fake/' .env
sed -i 's/^\(DEV_SERVICE_ACCOUNT_CLIENT_SECRET=\)$/\1fake/' .env
sed -i '/POSTGRESQL_HOST/d' .env
sed -i '/POSTGRESQL_ROOT/d' .env
echo -e "\nPOSTGRESQL_HOST=$(DATABASE_HOST)" >> .env
echo "POSTGRESQL_ROOT=$(DATABASE_USERNAME)" >> .env
echo "POSTGRESQL_ROOT_PASSWORD=$(DATABASE_PASSWORD)" >> .env
displayName:
Add fake values to .env to keep config loader happy
Expand Down
10 changes: 7 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
"no-fallthrough": "error",
"jest/valid-expect": ["error", { "maxArgs": 2 }],
"jest/require-top-level-describe": "error",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "ignoreRestSiblings": true }], // Allow unused vars when prefixed with underscore
"@typescript-eslint/no-unused-vars": [
"warn",
{ "argsIgnorePattern": "^_", "ignoreRestSiblings": true }
], // Allow unused vars when prefixed with underscore

"jest/no-commented-out-tests": "warn",
"@typescript-eslint/no-explicit-any": "warn",
Expand All @@ -68,7 +71,8 @@
],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"curly": ["warn", "all"],
"eqeqeq": ["error", "allow-null"]
"eqeqeq": ["error", "allow-null"],
"spaced-comment": ["error", "always"]
},
"overrides": [
{
Expand All @@ -88,7 +92,7 @@
"@typescript-eslint/explicit-module-boundary-types": "error"
}
},
{
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ ingest-gen

# Mac specific
.DS_Store

# Temporary Data Dumps
data-dump/
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ The code included in that repository can be either used as is or customized to
your specific requirements. The Mosaic libraries and services used by that
solution will be provided, updated and maintained by Axinom.

## Getting Started

To get started with developing your own customized solution based on the
Mosaic Media Template, run the following command:

```shell
npx -p @axinom/mosaic-cli mosaic create
```

This process will guide you through the creation of a new Mosaic project based
on the Mosaic Media Template.
See [the CLI documentation](https://portal.axinom.com/mosaic/documentation/axinom-mosaic-cli#_mosaic_create) for more details.

## Prerequisites

Before using the customizable solution make sure that you have the following
Expand Down
2 changes: 1 addition & 1 deletion infra/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '3.7'

services:
postgres:
image: postgres:11.12-alpine
image: postgres:16.2-alpine
command:
- 'postgres'
- '-c'
Expand Down
6 changes: 3 additions & 3 deletions libs/media-messages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"build:compile": "tsc"
},
"devDependencies": {
"@axinom/mosaic-cli": "0.32.0",
"@axinom/mosaic-message-bus-abstractions": "0.13.0",
"@axinom/mosaic-cli": "0.33.1",
"@axinom/mosaic-message-bus-abstractions": "0.14.0",
"@types/glob": "^7.2.0",
"concurrently": "^5.3.0",
"rimraf": "^3.0.2",
Expand All @@ -31,4 +31,4 @@
"typescript": "^4.9.4",
"watch": "^1.0.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ channels:
publish:
message:
$ref: '#/components/messages/update-metadata-command'
'ingest.check_finish_item':
bindings:
amqp:
queue:
name: inbox
publish:
message:
$ref: '#/components/messages/check-finish-ingest-item-command'
'ingest.check_finish_document':
bindings:
amqp:
Expand All @@ -85,12 +77,6 @@ channels:
$ref: '#/components/messages/entity-deleted-event'
components:
messages:
check-finish-ingest-item-command:
tags:
- name: aggregate-type:ingest-item
contentType: application/json
payload:
$ref: 'commands/check-finish-ingest-item-command.json'
check-finish-ingest-document-command:
tags:
- name: aggregate-type:ingest-document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ export class MediaServiceMessagingSettings implements MessagingSettings {
'command',
'ingest-item'
);
public static CheckFinishIngestItem = new MediaServiceMessagingSettings(
'CheckFinishIngestItem',
'inbox',
'ingest.check_finish_item',
'command',
'ingest-item'
);
public static CheckFinishIngestDocument = new MediaServiceMessagingSettings(
'CheckFinishIngestDocument',
'inbox',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as CheckFinishIngestDocumentCommand from './check-finish-ingest-document-command.json';
import * as CheckFinishIngestItemCommand from './check-finish-ingest-item-command.json';
import * as DeleteEntityCommand from './delete-entity-command.json';
import * as PublishEntityCommand from './publish-entity-command.json';
import * as StartIngestCommand from './start-ingest-command.json';
Expand All @@ -8,7 +7,6 @@ import * as UnpublishEntityCommand from './unpublish-entity-command.json';
import * as UpdateMetadataCommand from './update-metadata-command.json';

export const CheckFinishIngestDocumentCommandSchema = CheckFinishIngestDocumentCommand;
export const CheckFinishIngestItemCommandSchema = CheckFinishIngestItemCommand;
export const DeleteEntityCommandSchema = DeleteEntityCommand;
export const PublishEntityCommandSchema = PublishEntityCommand;
export const StartIngestCommandSchema = StartIngestCommand;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './check-finish-ingest-document-command';
export * from './check-finish-ingest-item-command';
export * from './delete-entity-command';
export * from './publish-entity-command';
export * from './start-ingest-command';
Expand All @@ -9,7 +8,6 @@ export * from './update-metadata-command';

export enum MediaCommandsSchemas {
CheckFinishIngestDocumentCommand = 'payloads/media/commands/check-finish-ingest-document-command.json',
CheckFinishIngestItemCommand = 'payloads/media/commands/check-finish-ingest-item-command.json',
DeleteEntityCommand = 'payloads/media/commands/delete-entity-command.json',
PublishEntityCommand = 'payloads/media/commands/publish-entity-command.json',
StartIngestCommand = 'payloads/media/commands/start-ingest-command.json',
Expand All @@ -20,7 +18,6 @@ export enum MediaCommandsSchemas {

export enum MediaCommandsTypes {
CheckFinishIngestDocumentCommand = 'CheckFinishIngestDocumentCommand',
CheckFinishIngestItemCommand = 'CheckFinishIngestItemCommand',
DeleteEntityCommand = 'DeleteEntityCommand',
PublishEntityCommand = 'PublishEntityCommand',
StartIngestCommand = 'StartIngestCommand',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"yarn:de-dupe": "npx yarn-deduplicate yarn.lock"
},
"devDependencies": {
"@axinom/mosaic-cli": "0.32.0",
"@axinom/mosaic-cli": "0.33.1",
"@dbeining/react-atom": "^4.1.21",
"@jest/globals": "^29.5.0",
"@libre/atom": "^1.3.3",
Expand Down Expand Up @@ -107,4 +107,4 @@
"jest": "^29",
"jest-cli": "^29"
}
}
}
101 changes: 101 additions & 0 deletions scripts/create-data-dump.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* eslint-disable no-console */

/**
* This script is to create a data only dumps from the existing Mosaic databases.
* The scripts exports dump files to the data-dump folder at the root of the project.
*
* Run the file using the following command from Mosaic Media Template root.
*
* `yarn run env-cmd --silent -f .env ts-node scripts/create-data-dump.ts`
*/

import { execSync } from 'child_process';
import { existsSync, mkdirSync, readdirSync, readFileSync } from 'fs';
import { dirname, join } from 'path';

const ensureDumpDirectoryExist = (targetPath: string): string => {
const dbSchemaExportPath = join(process.cwd(), targetPath);
const dirPath = dirname(dbSchemaExportPath);
if (!existsSync(dirPath)) {
mkdirSync(dirPath, { recursive: true });
}
return dbSchemaExportPath;
};

const createDump = async (databaseName: string): Promise<void> => {
const dumpDirectory = `data-dump`;
try {
const connectionString = `postgresql://${process.env.POSTGRESQL_ROOT}:${process.env.POSTGRESQL_ROOT_PASSWORD}@host.docker.internal:${process.env.POSTGRESQL_PORT}/${databaseName}`;
console.log(`Connecting to: `, connectionString);
const dumpPath = ensureDumpDirectoryExist(
`${dumpDirectory}/${databaseName}.sql`,
);

const dumpOptions = [
'--data-only',
'--column-inserts',
'--disable-triggers',
'--on-conflict-do-nothing',
'--exclude-schema=graphile_migrate',
'--exclude-schema=ax_define',
'--exclude-schema=ax_utils',
'--exclude-schema=graphile_worker',
connectionString,
].join(' ');

console.log(`Starting pg-dump command for `, databaseName);
execSync(
`docker run --rm --add-host=host.docker.internal:host-gateway postgres:16.2-alpine pg_dump ${dumpOptions} > ${dumpPath}`,
);
console.log('Dump file ready at: ', dumpPath);
} catch (e) {
console.log('Command failed:', (e as Error).message);
process.exit(1);
}
};

function exportData(databases: string[]): void {
for (const database of databases) {
createDump(database);
}
}

const databases: string[] = [];

function traverseEnvFiles(directory: string): string[] {
const files: string[] = [];

const entries = readdirSync(directory, { withFileTypes: true });

for (const entry of entries) {
const fullPath = join(directory, entry.name);
if (entry.isDirectory()) {
files.push(...traverseEnvFiles(fullPath));
} else if (entry.isFile() && entry.name.endsWith('.env.template')) {
const databaseName = getDatabaseName(fullPath);
if (databaseName !== undefined) {
databases.push(databaseName);
break;
}
files.push(fullPath);
}
}

return files;
}

function getDatabaseName(filePath: string): string | undefined {
const fileContent = readFileSync(filePath, 'utf-8');
const lines = fileContent.split('\n');
for (const line of lines) {
if (line.startsWith('DATABASE_NAME=')) {
return line.split('=')[1].trim();
}
}
return undefined;
}

const serviceDirectory = join(process.cwd(), 'services');
traverseEnvFiles(serviceDirectory);

exportData(databases);
Loading

0 comments on commit a4bcfa1

Please sign in to comment.