From 6a934f3f5bba465e6bab25200334430429861c0f Mon Sep 17 00:00:00 2001 From: Raymond Cheng Date: Fri, 21 Jun 2024 18:01:51 -0700 Subject: [PATCH] fix: allow multiple Plasmic projects (#1692) --- apps/docs/package.json | 2 +- apps/frontend/plasmic-init.ts | 22 +++++++++++---- .../cloudsql/tables/contracts_v0.yaml | 22 +++++++++++++++ pnpm-lock.yaml | 28 +++++++++---------- 4 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 apps/hasura/metadata/databases/cloudsql/tables/contracts_v0.yaml diff --git a/apps/docs/package.json b/apps/docs/package.json index 85ffb0552..1ac9f4909 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -27,7 +27,7 @@ "@docusaurus/theme-common": "3.1.1", "@laxels/docusaurus-plugin-segment": "^1.0.6", "@mdx-js/react": "^3.0.0", - "@plasmicapp/react-web": "^0.2.340", + "@plasmicapp/react-web": "^0.2.341", "clsx": "^2.1.0", "prism-react-renderer": "^2.3.1", "react": "^18.2.0", diff --git a/apps/frontend/plasmic-init.ts b/apps/frontend/plasmic-init.ts index 2557bffa2..c184c892d 100644 --- a/apps/frontend/plasmic-init.ts +++ b/apps/frontend/plasmic-init.ts @@ -1,13 +1,23 @@ import { initPlasmicLoader } from "@plasmicapp/loader-nextjs/react-server-conditional"; +import _ from "lodash"; +import { assert, ensure } from "@opensource-observer/utils"; import { PLASMIC_PROJECT_ID, PLASMIC_PROJECT_API_TOKEN } from "./lib/config"; +const DELIMITER = ","; +const ids = _.compact(PLASMIC_PROJECT_ID.split(DELIMITER)); +const tokens = _.compact(PLASMIC_PROJECT_API_TOKEN.split(DELIMITER)); +assert( + ids.length === tokens.length, + `Plasmic Project ID count (${ids.length}) and API token count (${tokens.length}) mismatch`, +); + export const PLASMIC = initPlasmicLoader({ - projects: [ - { - id: PLASMIC_PROJECT_ID, - token: PLASMIC_PROJECT_API_TOKEN, - }, - ], + projects: _.zip(ids, tokens).map(([id, token]) => { + return { + id: ensure(id, "Plasmic Project ID is required"), + token: ensure(token, "Plasmic Project API token is required"), + }; + }), // Fetches the latest revisions, whether or not they were unpublished! // Disable for production to ensure you render only published changes. preview: false, diff --git a/apps/hasura/metadata/databases/cloudsql/tables/contracts_v0.yaml b/apps/hasura/metadata/databases/cloudsql/tables/contracts_v0.yaml new file mode 100644 index 000000000..f42725729 --- /dev/null +++ b/apps/hasura/metadata/databases/cloudsql/tables/contracts_v0.yaml @@ -0,0 +1,22 @@ +table: + name: contracts_v0 + schema: public +select_permissions: + - role: anonymous + permission: + columns: "*" + filter: {} + allow_aggregations: false + comment: "" + - role: user + permission: + columns: "*" + filter: {} + allow_aggregations: false + comment: "" + - role: developer + permission: + columns: "*" + filter: {} + allow_aggregations: true + comment: "" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e21c4e4e..0a2ff62a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,8 +42,8 @@ importers: specifier: ^3.0.0 version: 3.0.0(@types/react@18.3.3)(react@18.2.0) '@plasmicapp/react-web': - specifier: ^0.2.340 - version: 0.2.340(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + specifier: ^0.2.341 + version: 0.2.341(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) clsx: specifier: ^2.1.0 version: 2.1.0 @@ -2903,8 +2903,8 @@ packages: peerDependencies: react: '>=16.8.0' - '@plasmicapp/data-sources@0.1.156': - resolution: {integrity: sha512-jb1lMRNyL/zwgBhY46PfDKiWJW9jFTSy1n8qowGEhPooYto2jf/fGkm+csWJV5pvdjGIbAz/nQKsfw9GCbgm4g==} + '@plasmicapp/data-sources@0.1.157': + resolution: {integrity: sha512-Bmy/lowklnApxX5yDETbP/7CGtgSV6kTKO0hm8cN8h324xhGZsNICyoA6T0z/WM49zIGml/HfY0bElqIDc8K4A==} engines: {node: '>=10'} peerDependencies: react: '>=16.8.0' @@ -2915,8 +2915,8 @@ packages: react: '>=16.8.0' react-dom: '>=16.8.0' - '@plasmicapp/host@1.0.197': - resolution: {integrity: sha512-aotntQbSTccCLKZqKb3k2/1JEtVvuG+CS0JIqRIibcKEdgcCAS82lvemBATSY0RZWK6r/pTMWMsabQa0TxSyQw==} + '@plasmicapp/host@1.0.198': + resolution: {integrity: sha512-VsGZyKE+BLuANaTg+6wiuWoqLROCX+gwn5WZ3AZ6PFarmIdVgVPB5HZjC4qDPIbCb58pgifJ+za8SOX4JUtpsw==} peerDependencies: react: '>=16.8.0' react-dom: '>=16.8.0' @@ -3003,8 +3003,8 @@ packages: peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 - '@plasmicapp/react-web@0.2.340': - resolution: {integrity: sha512-E/N8obSU63iqwoyq0GLB42ZRmJ1Kh/DmuHTphfM2N+QbR3SrmYKD9IWakpR5+JMA7UsbmFKl0ZyTXsb+3fv+eA==} + '@plasmicapp/react-web@0.2.341': + resolution: {integrity: sha512-S4up4oXtHzJVnQDLlhhsKujqeXvODrWY+Nedu8C33k/NhjLiDjCzvduX5rZUtjagB/8VokZd4oqdaKs/jeh5TQ==} peerDependencies: react: '>=16.8.0' react-dom: '>=16.8.0' @@ -15710,10 +15710,10 @@ snapshots: dependencies: react: 18.2.0 - '@plasmicapp/data-sources@0.1.156(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@plasmicapp/data-sources@0.1.157(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@plasmicapp/data-sources-context': 0.1.21(react@18.2.0) - '@plasmicapp/host': 1.0.197(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@plasmicapp/host': 1.0.198(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@plasmicapp/isomorphic-unfetch': 1.0.3 '@plasmicapp/query': 0.1.79(react@18.2.0) fast-stringify: 2.0.0 @@ -15729,7 +15729,7 @@ snapshots: react-dom: 18.2.0(react@18.2.0) window-or-global: 1.0.1 - '@plasmicapp/host@1.0.197(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@plasmicapp/host@1.0.198(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@plasmicapp/query': 0.1.79(react@18.2.0) csstype: 3.1.3 @@ -15834,12 +15834,12 @@ snapshots: dependencies: react: 18.2.0 - '@plasmicapp/react-web@0.2.340(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@plasmicapp/react-web@0.2.341(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@plasmicapp/auth-react': 0.0.21(react@18.2.0) - '@plasmicapp/data-sources': 0.1.156(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@plasmicapp/data-sources': 0.1.157(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@plasmicapp/data-sources-context': 0.1.21(react@18.2.0) - '@plasmicapp/host': 1.0.197(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@plasmicapp/host': 1.0.198(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@plasmicapp/loader-splits': 1.0.62 '@plasmicapp/nextjs-app-router': 1.0.11(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@plasmicapp/prepass': 1.0.17(react-dom@18.2.0(react@18.2.0))(react@18.2.0)