-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(package): add nuxt layer package
- Loading branch information
1 parent
6197d18
commit 369d839
Showing
32 changed files
with
669 additions
and
36 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,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["@nuxt/eslint-config"], | ||
}; |
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,21 @@ | ||
node_modules | ||
*.log | ||
.nuxt | ||
nuxt.d.ts | ||
.output | ||
.data | ||
.env | ||
package-lock.json | ||
framework | ||
dist | ||
.DS_Store | ||
|
||
# Yarn | ||
.yarn/cache | ||
.yarn/*state* | ||
|
||
# Local History | ||
.history | ||
|
||
# VSCode | ||
.vscode/ |
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 @@ | ||
typescript.includeWorkspace = true |
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,73 @@ | ||
# Nuxt Layer Starter | ||
|
||
Create Nuxt extendable layer with this GitHub template. | ||
|
||
## Setup | ||
|
||
Make sure to install the dependencies: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
## Working on your theme | ||
|
||
Your theme is at the root of this repository, it is exactly like a regular Nuxt project, except you can publish it on NPM. | ||
|
||
The `.playground` directory should help you on trying your theme during development. | ||
|
||
Running `pnpm dev` will prepare and boot `.playground` directory, which imports your theme itself. | ||
|
||
## Distributing your theme | ||
|
||
Your Nuxt layer is shaped exactly the same as any other Nuxt project, except you can publish it on NPM. | ||
|
||
To do so, you only have to check if `files` in `package.json` are valid, then run: | ||
|
||
```bash | ||
npm publish --access public | ||
``` | ||
|
||
Once done, your users will only have to run: | ||
|
||
```bash | ||
npm install --save your-theme | ||
``` | ||
|
||
Then add the dependency to their `extends` in `nuxt.config`: | ||
|
||
```ts | ||
defineNuxtConfig({ | ||
extends: 'your-theme' | ||
}) | ||
``` | ||
|
||
## Development Server | ||
|
||
Start the development server on http://localhost:3000 | ||
|
||
```bash | ||
pnpm dev | ||
``` | ||
|
||
## Production | ||
|
||
Build the application for production: | ||
|
||
```bash | ||
pnpm build | ||
``` | ||
|
||
Or statically generate it with: | ||
|
||
```bash | ||
pnpm generate | ||
``` | ||
|
||
Locally preview production build: | ||
|
||
```bash | ||
pnpm preview | ||
``` | ||
|
||
Checkout the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. |
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,7 @@ | ||
export default defineAppConfig({ | ||
}) | ||
|
||
declare module '@nuxt/schema' { | ||
interface AppConfigInput { | ||
} | ||
} |
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 @@ | ||
<template> | ||
<NuxtWelcome /> | ||
</template> |
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,7 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
devtools: { enabled: true }, | ||
build: { | ||
transpile: ['tslib', '@apollo/client', '@apollo/client/core', '@vue/apollo-composable', '@vue/apollo-option', 'ts-invariant', 'vue-toastification', '@erpgap/odoo-sdk-api-client'] | ||
}, | ||
}) |
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,24 @@ | ||
{ | ||
"name": "@erpgap/odoo-nuxt-layer", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"main": "./nuxt.config.ts", | ||
"files": [ | ||
"server" | ||
], | ||
"scripts": { | ||
"dev": "nuxi dev", | ||
"build": "nuxt build", | ||
"generate": "nuxt generate", | ||
"preview": "nuxt preview", | ||
"lint": "eslint .", | ||
"postinstall": "nuxt prepare" | ||
}, | ||
"devDependencies": { | ||
"@erpgap/odoo-sdk-api-client": "*", | ||
"@nuxt/eslint-config": "^0.1.1", | ||
"eslint": "^8.28.0", | ||
"nuxt": "^3.8.0", | ||
"typescript": "^4.9.3" | ||
} | ||
} |
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 @@ | ||
import { Endpoints } from '@erpgap/odoo-sdk-api-client'; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
|
||
const api: Endpoints = event.context.apolloClient.api; | ||
|
||
const response = await api.mutation(body?.[0], body?.[1]); | ||
|
||
if ((response.data as any)?.cookie) { | ||
appendResponseHeader(event, 'Set-cookie', (response.data as any)?.cookie); | ||
} | ||
|
||
if (response.errors) { | ||
throw createError({ statusCode: 400, data: response.errors }); | ||
} | ||
|
||
return response.data; | ||
}); | ||
|
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,21 @@ | ||
import { Endpoints } from '@erpgap/odoo-sdk-api-client'; | ||
import { getCached } from '~/server/utils/getCached'; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
const api: Endpoints = event.context.apolloClient.api; | ||
|
||
// const data = await getCached(event, body); | ||
const response = await api.query(body?.[0], body?.[1]); | ||
|
||
if ((response.data as any)?.cookie) { | ||
appendResponseHeader(event, 'Set-cookie', (response.data as any)?.cookie); | ||
} | ||
|
||
if (response.errors) { | ||
throw createError(response.errors[0].message); | ||
} | ||
|
||
return response.data; | ||
}); | ||
|
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 @@ | ||
import { createApiClient, MiddlewareConfig } from '@erpgap/odoo-sdk-api-client/server'; | ||
import { Queries } from '~/server/queries'; | ||
import { Mutations } from '~/server/mutations'; | ||
|
||
export default defineEventHandler((event) => { | ||
|
||
const config : MiddlewareConfig = { | ||
// https://odoo-cla.ce.promptequation.com/graphql/vsf | ||
odooGraphqlUrl: `${process.env.ODOO_BASE_URL}graphql/vsf`, | ||
queries: { ...Queries, ...Mutations }, | ||
headers: { | ||
'REAL-IP': getRequestIP(event) || '', | ||
Cookie: `session_id=${parseCookies(event).session_id}`, | ||
'resquest-host': getRequestHost(event) | ||
} | ||
}; | ||
|
||
event.context.apolloClient = createApiClient(config); | ||
}); | ||
|
10 changes: 10 additions & 0 deletions
10
packages/nuxt-layer/server/mutations/ChangePasswordMutation.ts
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,10 @@ | ||
import { gql } from '@apollo/client/core'; | ||
export default gql` | ||
mutation($newPassword: String!, $token: String!) { | ||
changePassword(newPassword: $newPassword, token: $token) { | ||
id | ||
name | ||
} | ||
} | ||
`; |
25 changes: 25 additions & 0 deletions
25
packages/nuxt-layer/server/mutations/CreateNewAccountMutation.ts
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,25 @@ | ||
import { gql } from '@apollo/client/core'; | ||
|
||
export default gql` | ||
mutation register($companyName: String!, $firstName: String!, $lastName: String!, $email: String!, $location : String!$password: String!, $phoneNumber: String!) { | ||
register(companyName: $companyName, firstName: $firstName, lastName: $lastName, email: $email, location: $location, password: $password, phoneNumber: $phoneNumber) { | ||
partner{ | ||
id | ||
name | ||
street | ||
street2 | ||
city | ||
state | ||
{ | ||
id | ||
} | ||
country | ||
{ | ||
id | ||
} | ||
phone | ||
} | ||
} | ||
}`; | ||
|
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,23 @@ | ||
import { gql } from '@apollo/client/core'; | ||
export default gql` | ||
mutation($email: String!, $password: String!) { | ||
login(email: $email, password: $password) { | ||
partner{ | ||
id | ||
name | ||
street | ||
street2 | ||
city | ||
state | ||
{ | ||
id | ||
} | ||
country | ||
{ | ||
id | ||
} | ||
phone | ||
} | ||
} | ||
}`; |
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,6 @@ | ||
import { gql } from '@apollo/client/core'; | ||
export default gql` | ||
mutation { | ||
logout | ||
} | ||
`; |
10 changes: 10 additions & 0 deletions
10
packages/nuxt-layer/server/mutations/SendResetPasswordMutation.ts
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,10 @@ | ||
import { gql } from '@apollo/client/core'; | ||
export default gql` | ||
mutation($email: String!) { | ||
resetPassword(email: $email) { | ||
id | ||
name | ||
} | ||
} | ||
`; |
8 changes: 8 additions & 0 deletions
8
packages/nuxt-layer/server/mutations/UpdatePasswordMutation.ts
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,8 @@ | ||
import { gql } from '@apollo/client/core'; | ||
export default gql` | ||
mutation($currentPassword: String!, $newPassword: String!){ | ||
updatePassword(currentPassword: $currentPassword, newPassword: $newPassword) { | ||
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,30 @@ | ||
import { DocumentNode } from '@apollo/client'; | ||
import LoginMutation from './LoginMutation'; | ||
import LogoutMutation from './LogoutMutation'; | ||
import CreateNewAccountMutation from './CreateNewAccountMutation'; | ||
import SendResetPasswordMutation from './SendResetPasswordMutation'; | ||
import UpdatePasswordMutation from './UpdatePasswordMutation'; | ||
import ChangePasswordMutation from './ChangePasswordMutation'; | ||
|
||
enum MutationName { | ||
LoginMutation = 'LoginMutation', | ||
LogoutMutation = 'LogoutMutation', | ||
CreateNewAccountMutation = 'CreateNewAccountMutation', | ||
SendResetPasswordMutation = 'SendResetPasswordMutation', | ||
UpdatePasswordMutation = 'UpdatePasswordMutation', | ||
ChangePasswordMutation = 'ChangePasswordMutation' | ||
} | ||
|
||
const Mutations : Record<MutationName, DocumentNode> = { | ||
LoginMutation, | ||
LogoutMutation, | ||
CreateNewAccountMutation, | ||
SendResetPasswordMutation, | ||
UpdatePasswordMutation, | ||
ChangePasswordMutation | ||
}; | ||
|
||
export { | ||
Mutations, | ||
MutationName | ||
}; |
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,7 @@ | ||
import { gql } from '@apollo/client/core'; | ||
import {partnerFragment} from './fragments'; | ||
export default gql` | ||
query LoadUser { | ||
${partnerFragment} | ||
} | ||
`; |
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,29 @@ | ||
import { gql } from '@apollo/client/core'; | ||
export default gql` | ||
query ProductVariant($productTemplateId: Int, $combinationId: [Int]) { | ||
productVariant( productTemplateId: $productTemplateId combinationId: $combinationId) { | ||
product { | ||
id | ||
image | ||
variantPrice | ||
variantPriceAfterDiscount | ||
variantHasDiscountedPrice | ||
alternativeProducts{ | ||
id | ||
typeId | ||
visibility | ||
status | ||
name | ||
displayName | ||
sku | ||
barcode | ||
description | ||
} | ||
} | ||
productTemplateId | ||
displayName | ||
price | ||
listPrice | ||
hasDiscountedPrice | ||
} | ||
}`; |
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 @@ | ||
export { default as partnerFragment } from './partnerFragment'; |
Oops, something went wrong.