From 9a80274a76e1d9eacadc9f2780d4f6a182fb03f0 Mon Sep 17 00:00:00 2001 From: Reina Feather Date: Tue, 15 Feb 2022 11:33:49 -0800 Subject: [PATCH 1/4] Add new query sources to `demo` command --- .../demo/config/accounts/properties/planname.json | 13 +++++++++++++ .../demo/config/accounts/sources/plan.json | 9 +++++++++ .../demo/config/users/properties/ipaddress.json | 13 +++++++++++++ .../demo/config/users/sources/ip_address.json | 9 +++++++++ 4 files changed, 44 insertions(+) create mode 100644 plugins/@grouparoo/demo/config/accounts/properties/planname.json create mode 100644 plugins/@grouparoo/demo/config/accounts/sources/plan.json create mode 100644 plugins/@grouparoo/demo/config/users/properties/ipaddress.json create mode 100644 plugins/@grouparoo/demo/config/users/sources/ip_address.json diff --git a/plugins/@grouparoo/demo/config/accounts/properties/planname.json b/plugins/@grouparoo/demo/config/accounts/properties/planname.json new file mode 100644 index 0000000000..1fadeda304 --- /dev/null +++ b/plugins/@grouparoo/demo/config/accounts/properties/planname.json @@ -0,0 +1,13 @@ +{ + "class": "Property", + "id": "planname", + "type": "string", + "key": "planName", + "sourceId": "plan", + "unique": false, + "isArray": false, + "options": { + "query": "select demo.plans.name \nfrom demo.\"plans\"\njoin demo.accounts on accounts.plan_id = plans.id\nwhere accounts.id = {{{ accountId }}}" + }, + "filters": [] +} diff --git a/plugins/@grouparoo/demo/config/accounts/sources/plan.json b/plugins/@grouparoo/demo/config/accounts/sources/plan.json new file mode 100644 index 0000000000..9748232a4b --- /dev/null +++ b/plugins/@grouparoo/demo/config/accounts/sources/plan.json @@ -0,0 +1,9 @@ +{ + "class": "Source", + "id": "plan", + "modelId": "accounts", + "name": "Plan", + "type": "postgres-import-query", + "appId": "demo_db", + "options": {} +} diff --git a/plugins/@grouparoo/demo/config/users/properties/ipaddress.json b/plugins/@grouparoo/demo/config/users/properties/ipaddress.json new file mode 100644 index 0000000000..d75a0c5a9a --- /dev/null +++ b/plugins/@grouparoo/demo/config/users/properties/ipaddress.json @@ -0,0 +1,13 @@ +{ + "class": "Property", + "id": "ipaddress", + "type": "string", + "key": "ipAddress", + "sourceId": "ip_address", + "unique": false, + "isArray": false, + "options": { + "query": "select demo.users.ip_address \nfrom demo.users\nwhere demo.users.id = {{{ userId }}}" + }, + "filters": [] +} diff --git a/plugins/@grouparoo/demo/config/users/sources/ip_address.json b/plugins/@grouparoo/demo/config/users/sources/ip_address.json new file mode 100644 index 0000000000..fcb7112f0e --- /dev/null +++ b/plugins/@grouparoo/demo/config/users/sources/ip_address.json @@ -0,0 +1,9 @@ +{ + "class": "Source", + "id": "ip_address", + "modelId": "users", + "name": "Ip Address", + "type": "postgres-import-query", + "appId": "demo_db", + "options": {} +} From 328070427055b6839fd54e0f49839e753a1a6c9b Mon Sep 17 00:00:00 2001 From: Reina Feather Date: Mon, 21 Feb 2022 09:35:12 -0800 Subject: [PATCH 2/4] move config files to subdir, avoid conflicts from other db setups --- .../plan.json => postgres/accounts/account_queries.json} | 0 .../planname.json => postgres/accounts/plan_name.json} | 2 +- .../ipaddress.json => postgres/users/ip_address.json} | 2 +- .../ip_address.json => postgres/users/user_queries.json} | 0 plugins/@grouparoo/demo/src/util/configFiles.ts | 3 +++ 5 files changed, 5 insertions(+), 2 deletions(-) rename plugins/@grouparoo/demo/config/{accounts/sources/plan.json => postgres/accounts/account_queries.json} (100%) rename plugins/@grouparoo/demo/config/{accounts/properties/planname.json => postgres/accounts/plan_name.json} (93%) rename plugins/@grouparoo/demo/config/{users/properties/ipaddress.json => postgres/users/ip_address.json} (92%) rename plugins/@grouparoo/demo/config/{users/sources/ip_address.json => postgres/users/user_queries.json} (100%) diff --git a/plugins/@grouparoo/demo/config/accounts/sources/plan.json b/plugins/@grouparoo/demo/config/postgres/accounts/account_queries.json similarity index 100% rename from plugins/@grouparoo/demo/config/accounts/sources/plan.json rename to plugins/@grouparoo/demo/config/postgres/accounts/account_queries.json diff --git a/plugins/@grouparoo/demo/config/accounts/properties/planname.json b/plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json similarity index 93% rename from plugins/@grouparoo/demo/config/accounts/properties/planname.json rename to plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json index 1fadeda304..f203295622 100644 --- a/plugins/@grouparoo/demo/config/accounts/properties/planname.json +++ b/plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json @@ -1,6 +1,6 @@ { "class": "Property", - "id": "planname", + "id": "plan_name", "type": "string", "key": "planName", "sourceId": "plan", diff --git a/plugins/@grouparoo/demo/config/users/properties/ipaddress.json b/plugins/@grouparoo/demo/config/postgres/users/ip_address.json similarity index 92% rename from plugins/@grouparoo/demo/config/users/properties/ipaddress.json rename to plugins/@grouparoo/demo/config/postgres/users/ip_address.json index d75a0c5a9a..e64fe10b77 100644 --- a/plugins/@grouparoo/demo/config/users/properties/ipaddress.json +++ b/plugins/@grouparoo/demo/config/postgres/users/ip_address.json @@ -1,6 +1,6 @@ { "class": "Property", - "id": "ipaddress", + "id": "ip_address", "type": "string", "key": "ipAddress", "sourceId": "ip_address", diff --git a/plugins/@grouparoo/demo/config/users/sources/ip_address.json b/plugins/@grouparoo/demo/config/postgres/users/user_queries.json similarity index 100% rename from plugins/@grouparoo/demo/config/users/sources/ip_address.json rename to plugins/@grouparoo/demo/config/postgres/users/user_queries.json diff --git a/plugins/@grouparoo/demo/src/util/configFiles.ts b/plugins/@grouparoo/demo/src/util/configFiles.ts index 282dcab8e9..0c46481ba3 100644 --- a/plugins/@grouparoo/demo/src/util/configFiles.ts +++ b/plugins/@grouparoo/demo/src/util/configFiles.ts @@ -71,6 +71,9 @@ async function generateConfig( for (const sourceName of sources) { copySource(configDir, sourceName); + if (db) { + copyDir(configDir, db.name(), sourceName); + } } for (const destinationName of destinations) { From b42b70b7b863367e79ee4c47e7f632c677400190 Mon Sep 17 00:00:00 2001 From: Reina Feather Date: Mon, 21 Feb 2022 09:59:46 -0800 Subject: [PATCH 3/4] Provide more consistent names and fix tests --- plugins/@grouparoo/demo/__tests__/bin/accounts.ts | 1 + plugins/@grouparoo/demo/__tests__/bin/users.ts | 1 + .../{account_queries.json => demo_accounts_queries.json} | 4 ++-- .../users/{user_queries.json => demo_users_queries.json} | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) rename plugins/@grouparoo/demo/config/postgres/accounts/{account_queries.json => demo_accounts_queries.json} (66%) rename plugins/@grouparoo/demo/config/postgres/users/{user_queries.json => demo_users_queries.json} (67%) diff --git a/plugins/@grouparoo/demo/__tests__/bin/accounts.ts b/plugins/@grouparoo/demo/__tests__/bin/accounts.ts index 6cde0f5da8..214b11062f 100644 --- a/plugins/@grouparoo/demo/__tests__/bin/accounts.ts +++ b/plugins/@grouparoo/demo/__tests__/bin/accounts.ts @@ -30,6 +30,7 @@ describe("demo accounts", () => { "account_users", "demo_accounts", "demo_payments", + "demo_accounts_queries", ]); const properties = (await Property.findAll()).map((o) => o.id).sort(); diff --git a/plugins/@grouparoo/demo/__tests__/bin/users.ts b/plugins/@grouparoo/demo/__tests__/bin/users.ts index 35f67ef5d3..b92e84f4a4 100644 --- a/plugins/@grouparoo/demo/__tests__/bin/users.ts +++ b/plugins/@grouparoo/demo/__tests__/bin/users.ts @@ -31,6 +31,7 @@ describe("demo users", () => { "demo_calculated_property_source", "demo_purchases", "demo_users", + "demo_users_queries", ]); const properties = (await Property.findAll()).map((o) => o.id).sort(); diff --git a/plugins/@grouparoo/demo/config/postgres/accounts/account_queries.json b/plugins/@grouparoo/demo/config/postgres/accounts/demo_accounts_queries.json similarity index 66% rename from plugins/@grouparoo/demo/config/postgres/accounts/account_queries.json rename to plugins/@grouparoo/demo/config/postgres/accounts/demo_accounts_queries.json index 9748232a4b..40d7faec61 100644 --- a/plugins/@grouparoo/demo/config/postgres/accounts/account_queries.json +++ b/plugins/@grouparoo/demo/config/postgres/accounts/demo_accounts_queries.json @@ -1,8 +1,8 @@ { "class": "Source", - "id": "plan", + "id": "demo_accounts_queries", "modelId": "accounts", - "name": "Plan", + "name": "Accounts Queries", "type": "postgres-import-query", "appId": "demo_db", "options": {} diff --git a/plugins/@grouparoo/demo/config/postgres/users/user_queries.json b/plugins/@grouparoo/demo/config/postgres/users/demo_users_queries.json similarity index 67% rename from plugins/@grouparoo/demo/config/postgres/users/user_queries.json rename to plugins/@grouparoo/demo/config/postgres/users/demo_users_queries.json index fcb7112f0e..7fd4a904cd 100644 --- a/plugins/@grouparoo/demo/config/postgres/users/user_queries.json +++ b/plugins/@grouparoo/demo/config/postgres/users/demo_users_queries.json @@ -1,8 +1,8 @@ { "class": "Source", - "id": "ip_address", + "id": "demo_users_queries", "modelId": "users", - "name": "Ip Address", + "name": "Users Queries", "type": "postgres-import-query", "appId": "demo_db", "options": {} From 9b927628b54d0217faa1b96f8d14c9be5ceaa059 Mon Sep 17 00:00:00 2001 From: Reina Feather Date: Mon, 21 Feb 2022 10:19:34 -0800 Subject: [PATCH 4/4] More test updates --- plugins/@grouparoo/demo/__tests__/bin/accounts.ts | 3 ++- plugins/@grouparoo/demo/__tests__/bin/users.ts | 1 + .../@grouparoo/demo/config/postgres/accounts/plan_name.json | 2 +- plugins/@grouparoo/demo/config/postgres/users/ip_address.json | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/@grouparoo/demo/__tests__/bin/accounts.ts b/plugins/@grouparoo/demo/__tests__/bin/accounts.ts index 214b11062f..7bd5ee90ec 100644 --- a/plugins/@grouparoo/demo/__tests__/bin/accounts.ts +++ b/plugins/@grouparoo/demo/__tests__/bin/accounts.ts @@ -29,8 +29,8 @@ describe("demo accounts", () => { expect(sources).toEqual([ "account_users", "demo_accounts", - "demo_payments", "demo_accounts_queries", + "demo_payments", ]); const properties = (await Property.findAll()).map((o) => o.id).sort(); @@ -40,6 +40,7 @@ describe("demo accounts", () => { "account_value", "contact_email", "domain", + "plan_name", ]); const schedules = (await Schedule.findAll()).map((o) => o.id).sort(); diff --git a/plugins/@grouparoo/demo/__tests__/bin/users.ts b/plugins/@grouparoo/demo/__tests__/bin/users.ts index b92e84f4a4..aa3bf2ee50 100644 --- a/plugins/@grouparoo/demo/__tests__/bin/users.ts +++ b/plugins/@grouparoo/demo/__tests__/bin/users.ts @@ -40,6 +40,7 @@ describe("demo users", () => { "email", "first_name", "full_name", + "ip_address", "language", "last_name", "last_purchase_category", diff --git a/plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json b/plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json index f203295622..eb90b67417 100644 --- a/plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json +++ b/plugins/@grouparoo/demo/config/postgres/accounts/plan_name.json @@ -3,7 +3,7 @@ "id": "plan_name", "type": "string", "key": "planName", - "sourceId": "plan", + "sourceId": "demo_accounts_queries", "unique": false, "isArray": false, "options": { diff --git a/plugins/@grouparoo/demo/config/postgres/users/ip_address.json b/plugins/@grouparoo/demo/config/postgres/users/ip_address.json index e64fe10b77..31d410c99e 100644 --- a/plugins/@grouparoo/demo/config/postgres/users/ip_address.json +++ b/plugins/@grouparoo/demo/config/postgres/users/ip_address.json @@ -3,7 +3,7 @@ "id": "ip_address", "type": "string", "key": "ipAddress", - "sourceId": "ip_address", + "sourceId": "demo_users_queries", "unique": false, "isArray": false, "options": {