From cec4ff98ec87a47c1a9d0e5b2898e6b6f6438003 Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:15:29 -0700 Subject: [PATCH 1/7] measure page env vars --- project.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/project.yaml b/project.yaml index b05066b9..22f07518 100644 --- a/project.yaml +++ b/project.yaml @@ -40,11 +40,17 @@ client: CLIENT_PORT: ssm: null default: 10009 + GOOGLE_MAPS_API_KEY: + ssm: null + # todo: precommit hook requiring null + default: null get: - POOL_ID - CLIENT_ID - GRAPHQL_URI - CLIENT_PORT + - GOOGLE_MAPS_API_KEY + - GRAPHQL_SUBSCRIPTIONS_URI params: - ENABLE_API_AUTH crates: @@ -159,6 +165,9 @@ infrastructure: GRAPHQL_URI: ssm: api/graphql/uri default: null # script sets as localhost:$PORT + GRAPHQL_SUBSCRIPTIONS_URI: + ssm: null + default: null REQUEST_CREATE_URL: ssm: service/lambda/request_create/url default: null From 49e8ff2e43e2680e9b97c033c20556100b9ef06f Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:17:10 -0700 Subject: [PATCH 2/7] set env var to graphql subscription uri --- scripts/create-env-file.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/create-env-file.sh b/scripts/create-env-file.sh index 319b4f40..73966bda 100644 --- a/scripts/create-env-file.sh +++ b/scripts/create-env-file.sh @@ -84,6 +84,16 @@ function set_default_values() { else echo "$s=$HOST:$PORT_VAL" >> $ENV_FILE fi + elif [[ "$s" == 'GRAPHQL_SUBSCRIPTIONS_URI' ]]; then + SVC_NAME=$(printf '%s' "$s" | sed 's/_SUBSCRIPTIONS_URI//') + PORT_ENV_VAR="$SVC_NAME"_PORT + PORT_VAL=$(yq "... | select(has(\"$PORT_ENV_VAR\")).$PORT_ENV_VAR.default" $PROJECT_CONF) + # todo: handle in scripts/set-uri-vars.sh + if [[ $GITPOD_WORKSPACE_URL ]] || [[ $CODESPACES ]]; then + echo "$s=$GRAPHQL_URI" >> $ENV_FILE + else + echo "$s=ws://$LOCAL_ADDRESS:$PORT_VAL/ws" >> $ENV_FILE + fi elif [[ "$s" == 'CLIENT_URI' ]]; then # todo: change CLIENT_URI to CLIENT_URL SVC_NAME=$(printf '%s' "$s" | sed 's/_URI//') PORT_ENV_VAR="$SVC_NAME"_PORT From 48224e901a44ef3d75e5ae82d042093266ce20e0 Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:19:32 -0700 Subject: [PATCH 3/7] client measure page deps --- client/package-lock.json | 80 +++++++++++++++++++++++++++++++++------- client/package.json | 3 ++ 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 2219d31f..97e374b1 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -9,10 +9,12 @@ "version": "0.0.1", "devDependencies": { "@fortawesome/free-solid-svg-icons": "^6.2.1", + "@googlemaps/js-api-loader": "^1.16.8", "@playwright/test": "^1.28.1", "@sveltejs/adapter-auto": "^1.0.0", "@sveltejs/kit": "^1.0.0", "@types/base-64": "^1.0.0", + "@types/google.maps": "^3.55.12", "@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/parser": "^5.45.0", "@urql/core": "^3.1.1", @@ -24,6 +26,7 @@ "eslint-config-prettier": "^8.5.0", "eslint-plugin-svelte3": "^4.0.0", "graphql": "^16.6.0", + "graphql-ws": "^5.16.0", "prettier": "^2.8.0", "prettier-plugin-svelte": "^2.8.1", "shelljs": "^0.8.5", @@ -489,6 +492,13 @@ "node": ">=6" } }, + "node_modules/@googlemaps/js-api-loader": { + "version": "1.16.8", + "resolved": "https://registry.npmjs.org/@googlemaps/js-api-loader/-/js-api-loader-1.16.8.tgz", + "integrity": "sha512-CROqqwfKotdO6EBjZO/gQGVTbeDps5V7Mt9+8+5Q+jTg5CRMi3Ii/L9PmV3USROrt2uWxtGzJHORmByxyo9pSQ==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -681,6 +691,13 @@ "integrity": "sha512-COUnqfB2+ckwXXSFInsFdOAWQzCCx+a5hq2ruyj+Vjund94RJQd4LG2u9hnvJrTgunKAaax7ancBYlDrNYxA0g==", "dev": true }, + "node_modules/@types/google.maps": { + "version": "3.55.12", + "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.55.12.tgz", + "integrity": "sha512-Q8MsLE+YYIrE1H8wdN69YHHAF8h7ApvF5MiMXh/zeCpP9Ut745mV9M0F4X4eobZ2WJe9k8tW2ryYjLa87IO2Sg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -903,10 +920,11 @@ } }, "node_modules/@urql/core": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@urql/core/-/core-3.1.1.tgz", - "integrity": "sha512-Mnxtq4I4QeFJsgs7Iytw+HyhiGxISR6qtyk66c9tipozLZ6QVxrCiUPF2HY4BxNIabaxcp+rivadvm8NAnXj4Q==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@urql/core/-/core-3.2.2.tgz", + "integrity": "sha512-i046Cz8cZ4xIzGMTyHZrbdgzcFMcKD7+yhCAH5FwWBRjcKrc+RjEOuR9X5AMuBvr8c6IAaE92xAqa4wmlGfWTQ==", "dev": true, + "license": "MIT", "dependencies": { "wonka": "^6.1.2" }, @@ -1841,6 +1859,22 @@ "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } }, + "node_modules/graphql-ws": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.16.0.tgz", + "integrity": "sha512-Ju2RCU2dQMgSKtArPbEtsK5gNLnsQyTNIo/T7cZNp96niC1x0KdJNZV0TIoilceBPQwfb5itrGl8pkFeOUMl4A==", + "dev": true, + "license": "MIT", + "workspaces": [ + "website" + ], + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": ">=0.11 <=16" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -3207,10 +3241,11 @@ } }, "node_modules/wonka": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/wonka/-/wonka-6.1.2.tgz", - "integrity": "sha512-zNrXPMccg/7OEp9tSfFkMgTvhhowqasiSHdJ3eCZolXxVTV/aT6HUTofoZk9gwRbGoFey/Nss3JaZKUMKMbofg==", - "dev": true + "version": "6.3.4", + "resolved": "https://registry.npmjs.org/wonka/-/wonka-6.3.4.tgz", + "integrity": "sha512-CjpbqNtBGNAeyNS/9W6q3kSkKE52+FjIj7AkFlLr11s/VWGUu6a2CdYSdGxocIhIVjaW/zchesBQUKPVU69Cqg==", + "dev": true, + "license": "MIT" }, "node_modules/word-wrap": { "version": "1.2.3", @@ -3489,6 +3524,12 @@ "@fortawesome/fontawesome-common-types": "6.2.1" } }, + "@googlemaps/js-api-loader": { + "version": "1.16.8", + "resolved": "https://registry.npmjs.org/@googlemaps/js-api-loader/-/js-api-loader-1.16.8.tgz", + "integrity": "sha512-CROqqwfKotdO6EBjZO/gQGVTbeDps5V7Mt9+8+5Q+jTg5CRMi3Ii/L9PmV3USROrt2uWxtGzJHORmByxyo9pSQ==", + "dev": true + }, "@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -3632,6 +3673,12 @@ "integrity": "sha512-COUnqfB2+ckwXXSFInsFdOAWQzCCx+a5hq2ruyj+Vjund94RJQd4LG2u9hnvJrTgunKAaax7ancBYlDrNYxA0g==", "dev": true }, + "@types/google.maps": { + "version": "3.55.12", + "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.55.12.tgz", + "integrity": "sha512-Q8MsLE+YYIrE1H8wdN69YHHAF8h7ApvF5MiMXh/zeCpP9Ut745mV9M0F4X4eobZ2WJe9k8tW2ryYjLa87IO2Sg==", + "dev": true + }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -3765,9 +3812,9 @@ } }, "@urql/core": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@urql/core/-/core-3.1.1.tgz", - "integrity": "sha512-Mnxtq4I4QeFJsgs7Iytw+HyhiGxISR6qtyk66c9tipozLZ6QVxrCiUPF2HY4BxNIabaxcp+rivadvm8NAnXj4Q==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@urql/core/-/core-3.2.2.tgz", + "integrity": "sha512-i046Cz8cZ4xIzGMTyHZrbdgzcFMcKD7+yhCAH5FwWBRjcKrc+RjEOuR9X5AMuBvr8c6IAaE92xAqa4wmlGfWTQ==", "dev": true, "requires": { "wonka": "^6.1.2" @@ -4474,6 +4521,13 @@ "integrity": "sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==", "dev": true }, + "graphql-ws": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.16.0.tgz", + "integrity": "sha512-Ju2RCU2dQMgSKtArPbEtsK5gNLnsQyTNIo/T7cZNp96niC1x0KdJNZV0TIoilceBPQwfb5itrGl8pkFeOUMl4A==", + "dev": true, + "requires": {} + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -5370,9 +5424,9 @@ } }, "wonka": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/wonka/-/wonka-6.1.2.tgz", - "integrity": "sha512-zNrXPMccg/7OEp9tSfFkMgTvhhowqasiSHdJ3eCZolXxVTV/aT6HUTofoZk9gwRbGoFey/Nss3JaZKUMKMbofg==", + "version": "6.3.4", + "resolved": "https://registry.npmjs.org/wonka/-/wonka-6.3.4.tgz", + "integrity": "sha512-CjpbqNtBGNAeyNS/9W6q3kSkKE52+FjIj7AkFlLr11s/VWGUu6a2CdYSdGxocIhIVjaW/zchesBQUKPVU69Cqg==", "dev": true }, "word-wrap": { diff --git a/client/package.json b/client/package.json index 74ab9338..c00f8fc4 100644 --- a/client/package.json +++ b/client/package.json @@ -15,10 +15,12 @@ }, "devDependencies": { "@fortawesome/free-solid-svg-icons": "^6.2.1", + "@googlemaps/js-api-loader": "^1.16.8", "@playwright/test": "^1.28.1", "@sveltejs/adapter-auto": "^1.0.0", "@sveltejs/kit": "^1.0.0", "@types/base-64": "^1.0.0", + "@types/google.maps": "^3.55.12", "@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/parser": "^5.45.0", "@urql/core": "^3.1.1", @@ -30,6 +32,7 @@ "eslint-config-prettier": "^8.5.0", "eslint-plugin-svelte3": "^4.0.0", "graphql": "^16.6.0", + "graphql-ws": "^5.16.0", "prettier": "^2.8.0", "prettier-plugin-svelte": "^2.8.1", "shelljs": "^0.8.5", From 3254af38cb4c4050acc359aced2a8d574e7b8b23 Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:21:00 -0700 Subject: [PATCH 4/7] replace deprecated export --- client/src/graphql/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/graphql/client.ts b/client/src/graphql/client.ts index f595ac64..6ff2bfbc 100644 --- a/client/src/graphql/client.ts +++ b/client/src/graphql/client.ts @@ -1,4 +1,4 @@ -import { createClient, defaultExchanges } from '@urql/core'; +import { createClient, cacheExchange, fetchExchange } from '@urql/core'; import type { ClientOptions } from '@urql/core'; import { getIdToken } from '../auth/cognito'; import b64 from 'base-64'; @@ -9,7 +9,7 @@ const url: string = b64.decode(process.env.GRAPHQL_URI as string)?.trim() + '/' const clientOpts: ClientOptions = { url, - exchanges: defaultExchanges, + exchanges: [cacheExchange, fetchExchange], maskTypename: true, fetchOptions: { credentials: 'same-origin' From 715cab3f42fed0813f2da6a2da6ace95123e985a Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:21:37 -0700 Subject: [PATCH 5/7] avoid default client styling on measure page --- client/src/routes/+layout.svelte | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/client/src/routes/+layout.svelte b/client/src/routes/+layout.svelte index 65a88e7d..db25792a 100644 --- a/client/src/routes/+layout.svelte +++ b/client/src/routes/+layout.svelte @@ -1,11 +1,16 @@ - - - +{#if $page.url.pathname !== '/measure'} + + + +{:else} + +{/if} \ No newline at end of file From 0dc74ab503afdfe11e73021c35aa9afdd4f7e4dd Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:21:53 -0700 Subject: [PATCH 6/7] add measure page to client --- client/src/routes/measure/+page.svelte | 282 +++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 client/src/routes/measure/+page.svelte diff --git a/client/src/routes/measure/+page.svelte b/client/src/routes/measure/+page.svelte new file mode 100644 index 00000000..3a8783f9 --- /dev/null +++ b/client/src/routes/measure/+page.svelte @@ -0,0 +1,282 @@ + + +
+ +
+ +
+
+
+ + From 97a85136fa0b2813fb2d8e03f140ba6df582933a Mon Sep 17 00:00:00 2001 From: max funk Date: Tue, 3 Sep 2024 19:22:18 -0700 Subject: [PATCH 7/7] continue-insert convenience target --- makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makefile b/makefile index 9953b98d..05520ea8 100644 --- a/makefile +++ b/makefile @@ -247,6 +247,10 @@ restore-testseed: insert: @$(MAKE) -C ./migrations insert +continue-insert: + bash scripts/manage-redis.sh --flush + bash scripts/insert-transactions.sh --continue + ###################### secrets ###################### clean-env: