🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@grouparoo/postgres

Package Overview
Dependencies
Maintainers
6
Versions
265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grouparoo/postgres - npm Package Compare versions

Comparing version
0.8.1-alpha.2
to
0.8.1-alpha.3
+0
-21
dist/initializers/plugin.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,3 +6,2 @@ exports.Plugins = void 0;

const core_1 = require("@grouparoo/core");
const path_1 = __importDefault(require("path"));
const appQuery_1 = require("../lib/appQuery");

@@ -21,9 +17,2 @@ const test_1 = require("./../lib/test");

const destinationMappingOptions_1 = require("../lib/export/destinationMappingOptions");
const getTables_1 = require("../lib/table-import/getTables");
const getColumns_1 = require("../lib/table-import/getColumns");
const templateRoot = path_1.default.join(__dirname, "..", "..", "public", "templates");
const app_1 = require("@grouparoo/app-templates/dist/app");
const templates_1 = require("@grouparoo/app-templates/dist/destination/templates");
const table_1 = require("@grouparoo/app-templates/dist/source/table");
const query_1 = require("@grouparoo/app-templates/dist/source/query");
// eslint-disable-next-line @typescript-eslint/no-var-requires

@@ -42,12 +31,2 @@ const packageJSON = require("./../../package.json");

icon: "/public/@grouparoo/postgres/postgres.png",
templates: [
new app_1.AppTemplate("postgres", [
path_1.default.join(templateRoot, "app", "*.template"),
]),
new table_1.TableSourceTemplate("postgres", { getTables: getTables_1.getTables, getColumns: getColumns_1.getColumns }),
new table_1.TablePropertyTemplate("postgres"),
new query_1.QuerySourceTemplate("postgres"),
new query_1.QueryPropertyTemplate("postgres"),
new templates_1.DestinationTemplate("postgres", [path_1.default.join(templateRoot, "destination", "*.template")], syncModes, defaultSyncMode),
],
apps: [

@@ -54,0 +33,0 @@ {

+6
-6

@@ -5,3 +5,3 @@ {

"description": "The Grouparoo postgres Plugin",
"version": "0.8.1-alpha.2",
"version": "0.8.1-alpha.3",
"license": "MPL-2.0",

@@ -32,3 +32,3 @@ "private": false,

"dependencies": {
"@grouparoo/app-templates": "0.8.1-alpha.2",
"@grouparoo/app-templates": "0.8.1-alpha.3",
"pg": "8.7.1",

@@ -40,4 +40,4 @@ "pg-format": "1.0.4",

"devDependencies": {
"@grouparoo/core": "0.8.1-alpha.2",
"@grouparoo/spec-helper": "0.8.1-alpha.2",
"@grouparoo/core": "0.8.1-alpha.3",
"@grouparoo/spec-helper": "0.8.1-alpha.3",
"@types/jest": "*",

@@ -49,3 +49,3 @@ "@types/node": "16.*.*",

"@typescript-eslint/parser": "5.10.2",
"actionhero": "28.1.7",
"actionhero": "28.1.8",
"csv-parse": "4.16.3",

@@ -60,3 +60,3 @@ "eslint": "8.8.0",

},
"gitHead": "c0d858ed9a8593f694fb0e6d4264a9994fdf3ae6"
"gitHead": "bfb4fad6ef978ac1396f31b5ebd5a7c54721daba"
}
import { Initializer } from "actionhero";
import { DestinationSyncMode, plugin } from "@grouparoo/core";
import path from "path";
import { appQuery } from "../lib/appQuery";

@@ -9,27 +7,9 @@ import { test } from "./../lib/test";

import { disconnect } from "./../lib/disconnect";
import { exportRecord } from "../lib/export/exportRecord";
import { exportArrayProperties } from "../lib/export/exportArrayProperties";
import { getConnection as getTableConnection } from "../lib/table-import/connection";
import { getConnection as getQueryConnection } from "../lib/query-import/connection";
import { destinationOptions } from "../lib/export/destinationOptions";
import { destinationMappingOptions } from "../lib/export/destinationMappingOptions";
import { getTables } from "../lib/table-import/getTables";
import { getColumns } from "../lib/table-import/getColumns";
const templateRoot = path.join(__dirname, "..", "..", "public", "templates");
import { AppTemplate } from "@grouparoo/app-templates/dist/app";
import { DestinationTemplate } from "@grouparoo/app-templates/dist/destination/templates";
import {
TableSourceTemplate,
TablePropertyTemplate,
} from "@grouparoo/app-templates/dist/source/table";
import {
QuerySourceTemplate,
QueryPropertyTemplate,
} from "@grouparoo/app-templates/dist/source/query";
// eslint-disable-next-line @typescript-eslint/no-var-requires

@@ -50,17 +30,2 @@ const packageJSON = require("./../../package.json");

icon: "/public/@grouparoo/postgres/postgres.png",
templates: [
new AppTemplate("postgres", [
path.join(templateRoot, "app", "*.template"),
]),
new TableSourceTemplate("postgres", { getTables, getColumns }),
new TablePropertyTemplate("postgres"),
new QuerySourceTemplate("postgres"),
new QueryPropertyTemplate("postgres"),
new DestinationTemplate(
"postgres",
[path.join(templateRoot, "destination", "*.template")],
syncModes,
defaultSyncMode
),
],
apps: [

@@ -67,0 +32,0 @@ {

import path from "path";
import fs from "fs-extra";
import os from "os";
process.env.GROUPAROO_INJECTED_PLUGINS = JSON.stringify({
"@grouparoo/postgres": { path: path.join(__dirname, "..", "..") },
});
import { helper } from "@grouparoo/spec-helper";
import { api } from "actionhero";
import { Generate } from "@grouparoo/core/dist/bin/generate";
import { Apply } from "@grouparoo/core/dist/bin/apply";
import {
beforeData,
afterData,
appOptions,
usersTableName,
} from "../utils/data";
process.env.GROUPAROO_CONFIG_DIR = `${os.tmpdir()}/test/${
process.env.JEST_WORKER_ID
}/config`;
describe("postgres cli tests", () => {
beforeAll(() => {
fs.mkdirpSync(process.env.GROUPAROO_CONFIG_DIR);
fs.emptyDirSync(process.env.GROUPAROO_CONFIG_DIR);
});
helper.grouparooTestServer({ truncate: true, enableTestPlugin: false });
beforeAll(async () => await beforeData());
afterAll(async () => await afterData());
let messages: string[] = [];
const spies: jest.SpyInstance[] = [];
beforeEach(() => {
messages = [];
spies.push(
jest
.spyOn(console, "log")
.mockImplementation((message) => messages.push(message))
);
spies.push(
jest
.spyOn(console, "error")
.mockImplementation((message) => messages.push(message))
);
});
afterEach(() => {
spies.map((s) => s.mockRestore());
});
test("the postgres commands appear in the generate list", async () => {
const command = new Generate();
await command.run({ params: { list: "true" } });
const output = messages.join(" ");
expect(output).toContain(`Available Templates:`);
expect(output).toContain(`postgres:app`);
expect(output).toContain(`postgres:table:source`);
expect(output).toContain(`postgres:table:property`);
expect(output).toContain(`postgres:query:source`);
expect(output).toContain(`postgres:query:property`);
expect(output).toContain(`postgres:destination`);
});
test("an app can be generated", async () => {
const command = new Generate();
await command.run({
params: { template: "postgres:app", id: "postgres_app" },
});
const file = `${process.env.GROUPAROO_CONFIG_DIR}/apps/postgres_app.js`;
const output = messages.join(" ");
expect(output).toContain(`wrote ${file}`);
const contents = fs.readFileSync(file).toString();
expect(contents).toContain('class: "app"');
expect(contents).toContain('id: "postgres_app"');
expect(contents).toContain('name: "postgres_app"');
//update the app to work
fs.writeFileSync(
file,
contents
.replace(`host: "localhost"`, `host: "${appOptions.host}"`)
.replace(`port: 5432`, `port: "${appOptions.port}"`)
.replace(`database: "..."`, `database: "${appOptions.database}"`)
.replace(`user: "..."`, `user: "${appOptions.user}"`)
.replace(`password: "..."`, `password: "${appOptions.password}"`)
);
});
test("a single source can be generated", async () => {
const command = new Generate();
await command.run({
params: {
template: "postgres:table:source",
id: usersTableName,
parent: "postgres_app",
},
});
const file = `${process.env.GROUPAROO_CONFIG_DIR}/sources/${usersTableName}.js`;
const output = messages.join(" ");
expect(output).toContain(`wrote ${file}`);
const contents = fs.readFileSync(file).toString();
expect(contents).toContain('class: "source"');
expect(contents).toContain(`id: "${usersTableName}"`);
expect(contents).toContain(`name: "${usersTableName}"`);
fs.unlinkSync(file);
});
test("a single property can be generated", async () => {
const command = new Generate();
await command.run({
params: {
template: "postgres:table:property",
id: "first_name",
parent: usersTableName,
},
});
const file = `${process.env.GROUPAROO_CONFIG_DIR}/properties/first_name.js`;
const output = messages.join(" ");
expect(output).toContain(`wrote ${file}`);
const contents = fs.readFileSync(file).toString();
expect(contents).toContain('class: "property"');
expect(contents).toContain('id: "first_name"');
expect(contents).toContain('name: "first_name"');
fs.unlinkSync(file);
});
test("a source can be generated with all of its properties", async () => {
api.codeConfig.allowLockedModelChanges = true;
await new Apply().run({ params: {} });
const command = new Generate();
await command.run({
params: {
template: "postgres:table:source",
id: usersTableName,
parent: "postgres_app",
from: usersTableName,
with: "*",
mapping: "id=user_id",
highWaterMark: "stamp",
overwrite: "true",
},
});
const file = `${process.env.GROUPAROO_CONFIG_DIR}/sources/${usersTableName}.js`;
const output = messages.join("\n");
expect(output).toContain(`wrote ${file}`);
const contents = fs.readFileSync(file).toString();
expect(contents).toContain('class: "source"');
expect(contents).toContain(`id: "${usersTableName}"`);
expect(contents).toContain(`name: "${usersTableName}"`);
expect(contents).toContain(`id: "user_id",`); // mapping
expect(contents).toContain(`column: "stamp",`); // schedule
// properties
[
{ id: "user_id", col: "id" },
{ id: "first_name", col: "first_name" },
{ id: "last_name", col: "last_name" },
{ id: "email", col: "email" },
{ id: "date", col: "date" },
].forEach(({ id, col }) => {
const propertyFile = `${process.env.GROUPAROO_CONFIG_DIR}/properties/${id}.js`;
expect(fs.existsSync(propertyFile)).toBe(true);
const propertyContents = fs.readFileSync(propertyFile).toString();
expect(propertyContents).toContain(`id: "${id}"`);
expect(propertyContents).toContain(`column: "${col}"`);
});
});
});
import { join } from "path";
import { CLISpecHelper } from "@grouparoo/spec-helper";
CLISpecHelper.validateGenerators(
"@grouparoo/postgres",
join(__dirname, "..", "..")
);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet