-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a5f824f
Showing
19 changed files
with
7,940 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DATABASE_URL="postgres://postgres:password@localhost:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
extends: ['universe/node'], | ||
rules: { | ||
'import/order': [ | ||
'warn', | ||
{ | ||
'newlines-between': 'always', | ||
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], | ||
alphabetize: { order: 'asc' }, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Build | ||
dist | ||
|
||
# Dependencies | ||
node_modules | ||
package-lock.json | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.yarn/* | ||
!.yarn/releases | ||
!.yarn/plugins | ||
!.yarn/sdks | ||
!.yarn/versions | ||
.pnp.* | ||
|
||
# Development files | ||
.env | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Other | ||
README.pdf | ||
|
||
# webstorm | ||
*.idea/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"printWidth": 90, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"jsxSingleQuote": false, | ||
"trailingComma": "es5", | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": true, | ||
"arrowParens": "always", | ||
"endOfLine": "lf" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
nmHoistingLimits: workspaces | ||
|
||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-2.4.2.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Repro for issue https://github.com/prisma/prisma/issues/7518 | ||
|
||
```bash | ||
ian@air ~/Code/ianmartorell/prisma-issue-7518 $ yarn lint | ||
src/index.ts:19:13 - error TS2322: Type '{ product: { include: { latestUpdate: true; }; }; }' is not assignable to type 'ProductInclude'. | ||
Object literal may only specify known properties, and 'product' does not exist in type 'ProductInclude'. | ||
|
||
19 product: { | ||
~~~~~~~~~~ | ||
20 include: { | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
... | ||
22 }, | ||
~~~~~~~~~~~~~~~~ | ||
23 }, | ||
~~~~~~~~~~~~~ | ||
|
||
|
||
Found 1 error. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = function (api) { | ||
api.cache(true); | ||
return { | ||
presets: [ | ||
['@babel/preset-typescript'], | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: 'current', | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ | ||
legacy: true, | ||
}, | ||
], | ||
[ | ||
'module-resolver', | ||
{ | ||
alias: { | ||
'': './', | ||
}, | ||
}, | ||
], | ||
], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3.8' | ||
services: | ||
postgres: | ||
image: postgres:13.1 | ||
restart: always | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
ports: | ||
- '5432:5432' | ||
environment: | ||
- POSTGRES_PASSWORD=password | ||
container_name: postgres | ||
|
||
volumes: | ||
postgres: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "prisma-issue-7518", | ||
"version": "1.0.0", | ||
"main": "./dist/index.js", | ||
"scripts": { | ||
"start": "nodemon --watch src -e '*' --exec babel-node ./src --extensions .ts -r dotenv/config", | ||
"build": "yarn build:clean && yarn prisma:generate && yarn build:code", | ||
"build:clean": "rimraf ./dist", | ||
"build:code": "babel ./src --out-dir ./dist --extensions .ts,.d.ts ", | ||
"dist": "node ./dist", | ||
"lint": "eslint ./src --ext .ts && tsc", | ||
"db:start": "docker-compose up -d", | ||
"db:stop": "docker-compose down -v", | ||
"db:reset": "prisma migrate reset", | ||
"db:migrate": "prisma migrate dev", | ||
"prisma:generate": "prisma generate", | ||
"prisma:studio": "prisma studio" | ||
}, | ||
"dependencies": { | ||
"@prisma/client": "^2.25.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.12.1", | ||
"@babel/core": "^7.12.3", | ||
"@babel/eslint-parser": "^7.12.1", | ||
"@babel/node": "^7.12.6", | ||
"@babel/plugin-proposal-decorators": "^7.12.1", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/preset-typescript": "^7.12.1", | ||
"@typescript-eslint/eslint-plugin": "^4.6.1", | ||
"@typescript-eslint/parser": "^4.6.1", | ||
"babel-plugin-module-resolver": "^4.1.0", | ||
"dotenv": "^8.2.0", | ||
"eslint": "^7.13.0", | ||
"eslint-config-universe": "^6.0.0", | ||
"nodemon": "^2.0.6", | ||
"prettier": "^2.1.2", | ||
"prisma": "^2.25.0", | ||
"prisma-dbml-generator": "^0.6.0", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^9.0.0", | ||
"typescript": "~4.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//// ------------------------------------------------------ | ||
//// THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) | ||
//// ------------------------------------------------------ | ||
|
||
Table Product { | ||
id String [pk] | ||
updates ProductUpdate [not null] | ||
latestUpdateId String | ||
latestUpdate ProductUpdate | ||
} | ||
|
||
Table ProductUpdate { | ||
id String [pk] | ||
productId String [not null] | ||
product Product [not null] | ||
products Product [not null] | ||
orderItems OrderItem [not null] | ||
} | ||
|
||
Table OrderItem { | ||
id String [pk] | ||
productUpdateId String [not null] | ||
productUpdate ProductUpdate [not null] | ||
} | ||
|
||
Ref: Product.latestUpdateId - ProductUpdate.id | ||
|
||
Ref: ProductUpdate.productId > Product.id | ||
|
||
Ref: OrderItem.productUpdateId > ProductUpdate.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
generator dbml { | ||
provider = "prisma-dbml-generator" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model Product { | ||
id String @id @default(uuid()) | ||
updates ProductUpdate[] @relation(name: "ProductUpdates") | ||
latestUpdateId String? | ||
latestUpdate ProductUpdate? @relation(name: "LatestProductUpdate", fields: [latestUpdateId], references: [id]) | ||
} | ||
|
||
model ProductUpdate { | ||
id String @id @default(uuid()) | ||
productId String | ||
product Product @relation(name: "ProductUpdates", fields: [productId], references: [id]) | ||
products Product[] @relation(name: "LatestProductUpdate") | ||
orderItems OrderItem[] | ||
} | ||
|
||
model OrderItem { | ||
id String @id @default(uuid()) | ||
productUpdateId String | ||
productUpdate ProductUpdate @relation(fields: [productUpdateId], references: [id]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const env = { | ||
NODE_ENV: process.env.NODE_ENV || 'development', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
import { env } from '/src/config/globals'; | ||
|
||
let prisma: PrismaClient; | ||
|
||
// In development we attach the prisma client to global | ||
// to avoid creating new connections on every code reload. | ||
if (env.NODE_ENV !== 'production') { | ||
if (!global.prisma) { | ||
global.prisma = new PrismaClient(); | ||
} | ||
prisma = global.prisma; | ||
} else { | ||
prisma = new PrismaClient(); | ||
} | ||
|
||
export { prisma }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { prisma } from './config/prisma'; | ||
|
||
// Startup | ||
(async function main() { | ||
try { | ||
prisma.orderItem.create({ | ||
data: { | ||
productUpdate: { | ||
create: { | ||
product: { | ||
create: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
include: { | ||
productUpdate: { | ||
include: { | ||
product: { | ||
include: { | ||
latestUpdate: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} catch (err) { | ||
console.error(err.stack); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
declare global { | ||
namespace NodeJS { | ||
interface Global { | ||
prisma: PrismaClient; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"compilerOptions": { | ||
// Basic options | ||
"target": "ES2019", | ||
"module": "CommonJS", | ||
"lib": ["ESNext"], | ||
"rootDir": "./src", | ||
// Module resolution | ||
"baseUrl": "./src", | ||
"paths": { | ||
"/src/*": ["./*"] | ||
}, | ||
// Search under node_modules for non-relative imports. | ||
"moduleResolution": "node", | ||
// Import non-ES modules as default imports. | ||
"esModuleInterop": true, | ||
// Don't emit; we're going to run ts-node directly | ||
"noEmit": true, | ||
// Enable strict settings like strictNullChecks & noImplicitAny. | ||
"strict": true, | ||
// Disallow features that require cross-file information. | ||
"isolatedModules": true, | ||
// Skip node_modules | ||
"skipLibCheck": true, | ||
// Process & infer types from .js files. | ||
"allowJs": true, | ||
// Linter checks | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
// Other | ||
"forceConsistentCasingInFileNames": true, | ||
"allowSyntheticDefaultImports": true, | ||
"resolveJsonModule": true, | ||
"experimentalDecorators": true, | ||
}, | ||
"exclude": ["dist"] | ||
} |
Oops, something went wrong.