@drax/identity-front 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,12 +3,12 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.7",
6
+ "version": "0.0.9",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
10
+ "types": "./src/index.ts",
10
11
  "files": [
11
- "dist",
12
12
  "src"
13
13
  ],
14
14
  "scripts": {
@@ -23,6 +23,9 @@
23
23
  "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
24
24
  "format": "prettier --write src/"
25
25
  },
26
+ "dependencies": {
27
+ "@drax/common-front": "^0.0.9"
28
+ },
26
29
  "peerDependencies": {
27
30
  "pinia": "^2.1.7",
28
31
  "vue": "^3.4.21",
@@ -56,5 +59,5 @@
56
59
  "vue-tsc": "^2.0.11",
57
60
  "vuetify": "^3.6.4"
58
61
  },
59
- "gitHead": "7fb7c130ba04e9c25d45b4e1f229e7c4c2e22068"
62
+ "gitHead": "26465c7ca403bae9b9a67fa249aee660fb4f3dd4"
60
63
  }
@@ -1,24 +1,82 @@
1
1
  <script setup lang="ts">
2
- import { VCard, VCardText, VCardTitle, VCardActions } from 'vuetify/components/VCard'
3
- import { VBtn } from 'vuetify/components/VBtn'
2
+ import { ref, computed, defineProps } from 'vue'
3
+ import {useAuthStore} from "../../stores/auth/AuthStore.js";
4
4
 
5
- defineProps<{
6
- msg: string
7
- }>()
5
+ const {getAuthSystem} = useAuthStore()
6
+
7
+ // Define props for customizing labels, title, and button text
8
+ const props = defineProps({
9
+ title: {
10
+ type: String,
11
+ default: 'Login'
12
+ },
13
+ usernameLabel: {
14
+ type: String,
15
+ default: 'Username'
16
+ },
17
+ passwordLabel: {
18
+ type: String,
19
+ default: 'Password'
20
+ },
21
+ buttonText: {
22
+ type: String,
23
+ default: 'Login'
24
+ }
25
+ })
26
+
27
+ // Define reactive variables for form inputs
28
+ const username = ref('')
29
+ const password = ref('')
30
+
31
+ // Compute whether the form is valid (both username and password are not empty)
32
+ const isFormValid = computed(() => username.value.trim() !== '' && password.value.trim() !== '')
33
+
34
+ // Function to handle form submission
35
+ const submitForm = () => {
36
+ console.log('Submitting:', { username: username.value, password: password.value })
37
+ getAuthSystem?.login(username.value, password.value)
38
+ // Here you would typically send the data to your backend
39
+ }
8
40
  </script>
9
41
 
10
42
  <template>
11
-
12
- <v-card variant="tonal">
13
- <v-card-title><h1>IDENTITY LOGIN</h1></v-card-title>
14
- <v-card-text>INCA DRAX</v-card-text>
15
- <v-card-text>{{ msg }}</v-card-text>
16
- <v-card-actions>
17
- <v-btn>BUTTON</v-btn>
18
- </v-card-actions>
19
- </v-card>
43
+ <v-container>
44
+ <v-row justify="center">
45
+ <v-col cols="12" sm="8" md="6" lg="5" xl="4" >
46
+ <v-form @submit.prevent="submitForm">
47
+ <v-card variant="tonal">
48
+ <v-card-title>{{ props.title }}</v-card-title>
49
+ <v-card-text>
50
+ <v-text-field
51
+ id="username-input"
52
+ v-model="username"
53
+ :label="props.usernameLabel"
54
+ required
55
+ ></v-text-field>
56
+ <v-text-field
57
+ id="password-input"
58
+ v-model="password"
59
+ :label="props.passwordLabel"
60
+ type="password"
61
+ required
62
+ ></v-text-field>
63
+ </v-card-text>
64
+ <v-card-actions>
65
+ <v-spacer></v-spacer>
66
+ <v-btn
67
+ id="submit-button"
68
+ type="submit"
69
+ color="primary"
70
+ :disabled="!isFormValid"
71
+ >{{ props.buttonText }}</v-btn>
72
+ </v-card-actions>
73
+ </v-card>
74
+ </v-form>
75
+ </v-col>
76
+ </v-row>
77
+ </v-container>
20
78
  </template>
21
79
 
22
80
  <style scoped lang="sass">
23
-
81
+ // Your styles here
24
82
  </style>
@@ -0,0 +1,29 @@
1
+ import type {IGqlClientInterface, IHttpClientInterface} from '@drax/common-front'
2
+ import {GqlApolloClientFactory, HttpFetchClientFactory} from '@drax/common-front';
3
+ import type {IAuthProviderInterface} from "@/core/interfaces/IAuthProviderInterface";
4
+ import AuthRestProvider from "@/core/providers/rest/AuthRestProvider";
5
+ import AuthGqlProvider from "@/core/providers/gql/AuthGqlProvider";
6
+ class AuthProviderFactory{
7
+ static create(type: string = 'rest'): IAuthProviderInterface {
8
+ if (type === 'gql') {
9
+ return AuthProviderFactory.createGql()
10
+ }
11
+ return AuthProviderFactory.createRest()
12
+ }
13
+
14
+ static createGql(): IAuthProviderInterface {
15
+ const gqlClient: IGqlClientInterface = GqlApolloClientFactory.create('/graphql')
16
+ return new AuthGqlProvider(gqlClient)
17
+ }
18
+
19
+ static createRest(): IAuthProviderInterface {
20
+ const baseUrl = import.meta.env.API_URL ? import.meta.env.API_URL : ''
21
+ console.log("baseUrl",baseUrl)
22
+ const baseHeaders = new Headers()
23
+ const httpClient: IHttpClientInterface = HttpFetchClientFactory.create(baseUrl,baseHeaders)
24
+ return new AuthRestProvider(httpClient)
25
+ }
26
+ }
27
+
28
+ export default AuthProviderFactory
29
+ export {AuthProviderFactory}
@@ -0,0 +1,12 @@
1
+ import AuthSystem from "@/core/system/AuthSystem";
2
+ import type {IAuthProviderInterface} from "@/core/interfaces/IAuthProviderInterface";
3
+ import AuthRestProviderFactory from "@/core/factories/providers/AuthProviderFactory";
4
+
5
+ class AuthSystemFactory {
6
+
7
+ static create(type: string = 'rest'): AuthSystem {
8
+ const provider: IAuthProviderInterface = AuthRestProviderFactory.create(type)
9
+
10
+ return new AuthSystem(provider)
11
+ }
12
+ }
@@ -0,0 +1,5 @@
1
+ interface IAuthProviderInterface{
2
+ login(username: string, password: string): Promise<object>
3
+ }
4
+
5
+ export type {IAuthProviderInterface}
@@ -0,0 +1,19 @@
1
+ import type {IGqlClientInterface} from '@drax/common-front'
2
+ import type {IAuthProviderInterface} from "../../interfaces/IAuthProviderInterface.ts";
3
+ class AuthGqlProvider implements IAuthProviderInterface{
4
+
5
+ gqlClient : IGqlClientInterface
6
+ constructor(gqlClient: IGqlClientInterface) {
7
+ this.gqlClient = gqlClient
8
+ }
9
+ async login(username: string, password: string): Promise<object> {
10
+
11
+ const url : string = ''
12
+ const data = {username, password}
13
+ let r = this.gqlClient.mutation(url, data)
14
+
15
+ return r
16
+ }
17
+ }
18
+
19
+ export default AuthGqlProvider
@@ -0,0 +1,19 @@
1
+ import type {IHttpClientInterface} from '@drax/common-front'
2
+ import type {IAuthProviderInterface} from "../../interfaces/IAuthProviderInterface.ts";
3
+ class AuthRestProvider implements IAuthProviderInterface{
4
+
5
+ httpClient : IHttpClientInterface
6
+ constructor(httpClient: IHttpClientInterface) {
7
+ this.httpClient = httpClient
8
+ }
9
+ async login(username: string, password: string): Promise<object> {
10
+ const url = '/api/auth'
11
+ const data = {username,password}
12
+ let r = await this.httpClient.post(url,data)
13
+
14
+ return r
15
+ }
16
+ }
17
+
18
+ export default AuthRestProvider
19
+ export {AuthRestProvider}
@@ -0,0 +1,21 @@
1
+ import type {IAuthProviderInterface} from "../interfaces/IAuthProviderInterface.ts";
2
+
3
+ class AuthSystem {
4
+
5
+ _provider : IAuthProviderInterface
6
+ prototype: string;
7
+ constructor(provider:IAuthProviderInterface) {
8
+ this._provider = provider;
9
+ this.prototype = 'AuthSystem'
10
+ }
11
+
12
+ async login(username:string, password:string):Promise<object> {
13
+ console.log("AuthSystem.login username",username)
14
+ const r = await this._provider.login(username, password)
15
+ console.log("AuthSystem.login",r)
16
+ return r
17
+ }
18
+ }
19
+
20
+ export default AuthSystem
21
+ export {AuthSystem}
package/src/index.ts CHANGED
@@ -1,6 +1,26 @@
1
- import IdentityLogin from "./components/IdentityLogin/IdentityLogin.vue";
1
+ import IdentityLogin from "@/components/IdentityLogin/IdentityLogin.vue";
2
+ import AuthSystem from "./core/system/AuthSystem.js"
3
+ import AuthRestProvider from "./core/providers/rest/AuthRestProvider.js";
4
+ import AuthGqlProvider from "./core/providers/gql/AuthGqlProvider.js";
5
+ import {useAuthStore} from "./stores/auth/AuthStore.js";
2
6
 
7
+ import type {IAuthProviderInterface} from "./core/interfaces/IAuthProviderInterface"
8
+
9
+ export type {
10
+ IAuthProviderInterface
11
+ }
3
12
 
4
13
  export {
5
- IdentityLogin
14
+ //Vue Components
15
+ IdentityLogin,
16
+
17
+ //Providers
18
+ AuthRestProvider,
19
+ AuthGqlProvider,
20
+
21
+ //Systems
22
+ AuthSystem,
23
+
24
+ //Stores
25
+ useAuthStore
6
26
  }
@@ -0,0 +1,19 @@
1
+ // Utilities
2
+ import { defineStore } from 'pinia'
3
+ import AuthSystem from "../../core/system/AuthSystem.js";
4
+
5
+ export const useAuthStore = defineStore('AuthStore', {
6
+ state: () => ({
7
+ authSystem : null as AuthSystem | null
8
+ }),
9
+ actions:{
10
+ setAuthSystem(authSystem:AuthSystem){
11
+ this.authSystem = authSystem
12
+ }
13
+ },
14
+ getters:{
15
+ getAuthSystem: (state) => {
16
+ return state.authSystem
17
+ }
18
+ }
19
+ })
@@ -1,88 +0,0 @@
1
- <script setup lang="ts">
2
- import WelcomeItem from './WelcomeItem.vue'
3
- import DocumentationIcon from './icons/IconDocumentation.vue'
4
- import ToolingIcon from './icons/IconTooling.vue'
5
- import EcosystemIcon from './icons/IconEcosystem.vue'
6
- import CommunityIcon from './icons/IconCommunity.vue'
7
- import SupportIcon from './icons/IconSupport.vue'
8
- </script>
9
-
10
- <template>
11
- <WelcomeItem>
12
- <template #icon>
13
- <DocumentationIcon />
14
- </template>
15
- <template #heading>Documentation</template>
16
-
17
- Vue’s
18
- <a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
19
- provides you with all information you need to get started.
20
- </WelcomeItem>
21
-
22
- <WelcomeItem>
23
- <template #icon>
24
- <ToolingIcon />
25
- </template>
26
- <template #heading>Tooling</template>
27
-
28
- This project is served and bundled with
29
- <a href="https://vitejs.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
30
- recommended IDE setup is
31
- <a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a> +
32
- <a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
33
- you need to test your components and web pages, check out
34
- <a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a> and
35
- <a href="https://on.cypress.io/component" target="_blank" rel="noopener"
36
- >Cypress Component Testing</a
37
- >.
38
-
39
- <br />
40
-
41
- More instructions are available in <code>README.md</code>.
42
- </WelcomeItem>
43
-
44
- <WelcomeItem>
45
- <template #icon>
46
- <EcosystemIcon />
47
- </template>
48
- <template #heading>Ecosystem</template>
49
-
50
- Get official tools and libraries for your project:
51
- <a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
52
- <a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
53
- <a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
54
- <a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
55
- you need more resources, we suggest paying
56
- <a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
57
- a visit.
58
- </WelcomeItem>
59
-
60
- <WelcomeItem>
61
- <template #icon>
62
- <CommunityIcon />
63
- </template>
64
- <template #heading>Community</template>
65
-
66
- Got stuck? Ask your question on
67
- <a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>, our official
68
- Discord server, or
69
- <a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
70
- >StackOverflow</a
71
- >. You should also subscribe to
72
- <a href="https://news.vuejs.org" target="_blank" rel="noopener">our mailing list</a> and follow
73
- the official
74
- <a href="https://twitter.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
75
- twitter account for latest news in the Vue world.
76
- </WelcomeItem>
77
-
78
- <WelcomeItem>
79
- <template #icon>
80
- <SupportIcon />
81
- </template>
82
- <template #heading>Support Vue</template>
83
-
84
- As an independent project, Vue relies on community backing for its sustainability. You can help
85
- us by
86
- <a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
87
- </WelcomeItem>
88
- </template>
@@ -1,87 +0,0 @@
1
- <template>
2
- <div class="item">
3
- <i>
4
- <slot name="icon"></slot>
5
- </i>
6
- <div class="details">
7
- <h3>
8
- <slot name="heading"></slot>
9
- </h3>
10
- <slot></slot>
11
- </div>
12
- </div>
13
- </template>
14
-
15
- <style scoped>
16
- .item {
17
- margin-top: 2rem;
18
- display: flex;
19
- position: relative;
20
- }
21
-
22
- .details {
23
- flex: 1;
24
- margin-left: 1rem;
25
- }
26
-
27
- i {
28
- display: flex;
29
- place-items: center;
30
- place-content: center;
31
- width: 32px;
32
- height: 32px;
33
-
34
- color: var(--color-text);
35
- }
36
-
37
- h3 {
38
- font-size: 1.2rem;
39
- font-weight: 500;
40
- margin-bottom: 0.4rem;
41
- color: var(--color-heading);
42
- }
43
-
44
- @media (min-width: 1024px) {
45
- .item {
46
- margin-top: 0;
47
- padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
48
- }
49
-
50
- i {
51
- top: calc(50% - 25px);
52
- left: -26px;
53
- position: absolute;
54
- border: 1px solid var(--color-border);
55
- background: var(--color-background);
56
- border-radius: 8px;
57
- width: 50px;
58
- height: 50px;
59
- }
60
-
61
- .item:before {
62
- content: ' ';
63
- border-left: 1px solid var(--color-border);
64
- position: absolute;
65
- left: 0;
66
- bottom: calc(50% + 25px);
67
- height: calc(50% - 25px);
68
- }
69
-
70
- .item:after {
71
- content: ' ';
72
- border-left: 1px solid var(--color-border);
73
- position: absolute;
74
- left: 0;
75
- top: calc(50% + 25px);
76
- height: calc(50% - 25px);
77
- }
78
-
79
- .item:first-of-type:before {
80
- display: none;
81
- }
82
-
83
- .item:last-of-type:after {
84
- display: none;
85
- }
86
- }
87
- </style>