Skip to content

Commit

Permalink
fix: 🐛 Fix duplication when customDomain is set
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 28, 2022
1 parent cb51e6b commit 33497b8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 89 deletions.
3 changes: 0 additions & 3 deletions apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"deep-object-diff": "^1.1.7",
"fast-equals": "^3.0.0",
"focus-visible": "^5.2.0",
"form-data": "^4.0.0",
"framer-motion": "^4",
"google-auth-library": "^7.12.0",
"google-spreadsheet": "^3.2.0",
Expand All @@ -54,7 +53,6 @@
"immer": "^9.0.12",
"js-video-url-parser": "^0.5.1",
"kbar": "^0.1.0-beta.27",
"mailgun.js": "^4.2.1",
"micro": "^9.3.4",
"micro-cors": "^0.1.1",
"models": "*",
Expand Down Expand Up @@ -100,7 +98,6 @@
"eslint-config-next": "12.0.10",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"firebase-admin": "^10.0.2",
"next-transpile-modules": "^9.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.5"
Expand Down
1 change: 1 addition & 0 deletions apps/builder/pages/api/typebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
ownerId: user.id,
folderId,
},
orderBy: { createdAt: 'desc' },
select: { name: true, publishedTypebotId: true, id: true },
})
return res.send({ typebots })
Expand Down
11 changes: 8 additions & 3 deletions apps/builder/pages/api/typebots/[typebotId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ const parseWhereFilter = (
OR: [
{
id: typebotId,
ownerId: user.email === adminEmail ? undefined : user.id,
ownerId:
(type === 'read' && user.email === adminEmail) ||
process.env.NEXT_PUBLIC_E2E_TEST
? undefined
: user.id,
},
{
id: typebotId,
collaborators: {
every: {
some: {
userId: user.id,
type: type === 'write' ? CollaborationType.WRITE : undefined,
type:
type === 'write' ? CollaborationType.WRITE : CollaborationType.READ,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions apps/builder/playwright/services/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
settings: defaultSettings,
publicId: null,
updatedAt: new Date(),
createdAt: new Date(),
publishedTypebotId: null,
customDomain: null,
variables: [{ id: 'var1', name: 'var1' }],
Expand Down
29 changes: 18 additions & 11 deletions apps/builder/services/typebots/typebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,16 @@ export const createTypebot = async ({
}

export const importTypebot = async (typebot: Typebot) => {
const typebotToImport: Omit<Typebot, 'id'> = omit(
const typebotToImport: Omit<Typebot, 'id' | 'updatedAt' | 'createdAt'> = omit(
{
...typebot,
publishedTypebotId: null,
publicId: null,
customDomain: null,
},
'id'
'id',
'updatedAt',
'createdAt'
)
return sendRequest<Typebot>({
url: `/api/typebots`,
Expand All @@ -111,15 +114,19 @@ export const duplicateTypebot = async (typebotId: string) => {
const { data } = await getTypebot(typebotId)
const typebotToDuplicate = data?.typebot
if (!typebotToDuplicate) return { error: new Error('Typebot not found') }
const duplicatedTypebot: Omit<Typebot, 'id'> = omit(
{
...typebotToDuplicate,
name: `${typebotToDuplicate.name} copy`,
publishedTypebotId: null,
publicId: null,
},
'id'
)
const duplicatedTypebot: Omit<Typebot, 'id' | 'updatedAt' | 'createdAt'> =
omit(
{
...typebotToDuplicate,
name: `${typebotToDuplicate.name} copy`,
publishedTypebotId: null,
publicId: null,
customDomain: null,
},
'id',
'updatedAt',
'createdAt'
)
return sendRequest<Typebot>({
url: `/api/typebots`,
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions apps/viewer/playwright/services/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
publicId: partialTypebot.id + '-public',
publishedTypebotId: null,
updatedAt: new Date(),
createdAt: new Date(),
customDomain: null,
variables: [{ id: 'var1', name: 'var1' }],
...partialTypebot,
Expand Down
2 changes: 1 addition & 1 deletion packages/models/src/typebot/typebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Variable } from './variable'

export type Typebot = Omit<
TypebotFromPrisma,
'blocks' | 'theme' | 'settings' | 'variables' | 'edges' | 'createdAt'
'blocks' | 'theme' | 'settings' | 'variables' | 'edges'
> & {
blocks: Block[]
variables: Variable[]
Expand Down
73 changes: 2 additions & 71 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5119,11 +5119,6 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base-64@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/base-64/-/base-64-1.0.0.tgz#09d0f2084e32a3fd08c2475b973788eee6ae8f4a"
integrity sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==

base16@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/base16/-/base16-1.0.0.tgz#e297f60d7ec1014a7a971a39ebc8a98c0b681e70"
Expand Down Expand Up @@ -5163,7 +5158,7 @@ bl@^4.1.0:
inherits "^2.0.4"
readable-stream "^3.4.0"

bluebird@^3.7.1, bluebird@^3.7.2:
bluebird@^3.7.1:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
Expand Down Expand Up @@ -6162,11 +6157,6 @@ damerau-levenshtein@^1.0.7:
resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7"
integrity sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==

data-uri-to-buffer@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636"
integrity sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==

date-and-time@^2.0.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/date-and-time/-/date-and-time-2.1.2.tgz#5b0e71296bbdd66ff1ce0e456c77d40f1479db5a"
Expand Down Expand Up @@ -7278,11 +7268,6 @@ feed@^4.2.2:
dependencies:
xml-js "^1.6.11"

fetch-blob@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-2.1.2.tgz#a7805db1361bd44c1ef62bb57fb5fe8ea173ef3c"
integrity sha512-YKqtUDwqLyfyMnmbw8XD6Q8j9i/HggKtPEI+pZ1+8bvheBu78biSmNaXWusx1TauGqtUUGx/cBb1mKdq2rLYow==

fflate@^0.4.1:
version "0.4.8"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae"
Expand Down Expand Up @@ -7474,15 +7459,6 @@ form-data@^3.0.0:
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

forwarded@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
Expand Down Expand Up @@ -9165,19 +9141,6 @@ klona@^2.0.5:
resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.5.tgz#d166574d90076395d9963aa7a928fabb8d76afbc"
integrity sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ==

ky-universal@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/ky-universal/-/ky-universal-0.8.2.tgz#edc398d54cf495d7d6830aa1ab69559a3cc7f824"
integrity sha512-xe0JaOH9QeYxdyGLnzUOVGK4Z6FGvDVzcXFTdrYA1f33MZdEa45sUDaMBy98xQMcsd2XIBrTXRrRYnegcSdgVQ==
dependencies:
abort-controller "^3.0.0"
node-fetch "3.0.0-beta.9"

ky@^0.25.1:
version "0.25.1"
resolved "https://registry.yarnpkg.com/ky/-/ky-0.25.1.tgz#0df0bd872a9cc57e31acd5dbc1443547c881bfbc"
integrity sha512-PjpCEWlIU7VpiMVrTwssahkYXX1by6NCT0fhTUX34F3DTinARlgMpriuroolugFPcMgpPWrOW4mTb984Qm1RXA==

language-subtag-registry@~0.3.2:
version "0.3.21"
resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz#04ac218bea46f04cb039084602c6da9e788dd45a"
Expand Down Expand Up @@ -9544,20 +9507,6 @@ magic-string@^0.25.3, magic-string@^0.25.7:
dependencies:
sourcemap-codec "^1.4.4"

mailgun.js@^4.2.1:
version "4.2.2"
resolved "https://registry.yarnpkg.com/mailgun.js/-/mailgun.js-4.2.2.tgz#8fba525fdc4ba367fd30faee1d75a1423c836839"
integrity sha512-sWX9Sgy/uHe5liegJLJkFRRuvjyFE58c8mqpyEx1QdZSn3UgLfAe5D41ncBdPy+EROnI8zrhkHYlF8trpSSqDA==
dependencies:
base-64 "^1.0.0"
bluebird "^3.7.2"
ky "^0.25.1"
ky-universal "^0.8.2"
url "^0.11.0"
url-join "0.0.1"
web-streams-polyfill "^3.0.1"
webpack-merge "^5.4.0"

make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down Expand Up @@ -9979,14 +9928,6 @@ node-fetch@2.6.7, node-fetch@^2.6.1, node-fetch@^2.6.7:
dependencies:
whatwg-url "^5.0.0"

node-fetch@3.0.0-beta.9:
version "3.0.0-beta.9"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.0.0-beta.9.tgz#0a7554cfb824380dd6812864389923c783c80d9b"
integrity sha512-RdbZCEynH2tH46+tj0ua9caUHVWrd/RHnRfvly2EVdqGmI3ndS1Vn/xjm5KuGejDt2RNDQsVRLPNd2QPwcewVg==
dependencies:
data-uri-to-buffer "^3.0.1"
fetch-blob "^2.1.1"

node-forge@^1.0.0, node-forge@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.2.1.tgz#82794919071ef2eb5c509293325cec8afd0fd53c"
Expand Down Expand Up @@ -13590,11 +13531,6 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

url-join@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/url-join/-/url-join-0.0.1.tgz#1db48ad422d3402469a87f7d97bdebfe4fb1e3c8"
integrity sha1-HbSK1CLTQCRpqH99l73r/k+x48g=

url-loader@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-4.1.1.tgz#28505e905cae158cf07c92ca622d7f237e70a4e2"
Expand Down Expand Up @@ -13832,11 +13768,6 @@ web-namespaces@^1.0.0, web-namespaces@^1.1.2:
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.4.tgz#bc98a3de60dadd7faefc403d1076d529f5e030ec"
integrity sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==

web-streams-polyfill@^3.0.1:
version "3.2.0"
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz#a6b74026b38e4885869fb5c589e90b95ccfc7965"
integrity sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA==

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
Expand Down Expand Up @@ -13919,7 +13850,7 @@ webpack-dev-server@^4.7.1:
webpack-dev-middleware "^5.3.1"
ws "^8.4.2"

webpack-merge@^5.4.0, webpack-merge@^5.8.0:
webpack-merge@^5.8.0:
version "5.8.0"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61"
integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==
Expand Down

2 comments on commit 33497b8

@vercel
Copy link

@vercel vercel bot commented on 33497b8 Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 33497b8 Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

Please sign in to comment.