@drax/identity-front 0.0.6 → 0.0.8

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,20 +3,11 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.6",
6
+ "version": "0.0.8",
7
7
  "type": "module",
8
- "main": "./dist/drax-identity-front.umd.js",
9
- "module": "./dist/drax-identity-front.js",
10
- "types": "./dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "import": "./dist/drax-identity-front.js",
14
- "require": "./dist/drax-identity-front.umd.cjs"
15
- },
16
- "./style.css": "./dist/style.css"
17
- },
8
+ "main": "./src/index.ts",
9
+ "module": "./src/index.ts",
18
10
  "files": [
19
- "dist",
20
11
  "src"
21
12
  ],
22
13
  "scripts": {
@@ -31,6 +22,9 @@
31
22
  "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
32
23
  "format": "prettier --write src/"
33
24
  },
25
+ "dependencies": {
26
+ "@drax/common-front": "^0.0.8"
27
+ },
34
28
  "peerDependencies": {
35
29
  "pinia": "^2.1.7",
36
30
  "vue": "^3.4.21",
@@ -57,11 +51,12 @@
57
51
  "start-server-and-test": "^2.0.3",
58
52
  "typescript": "~5.4.0",
59
53
  "vite": "^5.2.8",
54
+ "vite-plugin-css-injected-by-js": "^3.5.1",
60
55
  "vite-plugin-dts": "^3.9.1",
61
56
  "vitest": "^1.4.0",
62
57
  "vue": "^3.4.21",
63
58
  "vue-tsc": "^2.0.11",
64
59
  "vuetify": "^3.6.4"
65
60
  },
66
- "gitHead": "3ccd970d2ebf447ba7c6092d42568453fa2816ac"
61
+ "gitHead": "46840505094d059c06338a8dfd76937a735cf05a"
67
62
  }
@@ -1,20 +1,82 @@
1
1
  <script setup lang="ts">
2
- import { VCard, VCardText, VCardTitle } from 'vuetify/components/VCard'
2
+ import { ref, computed, defineProps } from 'vue'
3
+ import {useAuthStore} from "../../stores/auth/AuthStore.js";
3
4
 
4
- defineProps<{
5
- msg: string
6
- }>()
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
+ }
7
40
  </script>
8
41
 
9
42
  <template>
10
-
11
- <v-card text="">
12
- <v-card-title><h1>IDENTITY LOGIN</h1></v-card-title>
13
- <v-card-text>INCA DRAX</v-card-text>
14
- <v-card-text>{{ msg }}</v-card-text>
15
- </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>
16
78
  </template>
17
79
 
18
80
  <style scoped lang="sass">
19
-
81
+ // Your styles here
20
82
  </style>
@@ -0,0 +1,28 @@
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/gql/AuthGqlProvider";
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()
16
+ return new AuthGqlProvider(gqlClient)
17
+ }
18
+
19
+ static createRest(): IAuthProviderInterface {
20
+ const baseUrl = process.env.VUE_APP_BACKEND_URL ? process.env.VUE_APP_BACKEND_URL : ''
21
+ const baseHeaders = new Headers()
22
+ const httpClient: IHttpClientInterface = HttpFetchClientFactory.create(baseUrl,baseHeaders)
23
+ return new AuthRestProvider(httpClient)
24
+ }
25
+ }
26
+
27
+ export default AuthProviderFactory
28
+ 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,20 @@
1
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
 
3
7
  export {
8
+ //Vue Components
9
+ IdentityLogin,
4
10
 
5
- IdentityLogin
11
+ //Providers
12
+ AuthRestProvider,
13
+ AuthGqlProvider,
14
+
15
+ //Systems
16
+ AuthSystem,
17
+
18
+ //Stores
19
+ useAuthStore
6
20
  }
@@ -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,15 +0,0 @@
1
- declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
2
- msg: string;
3
- }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
4
- msg: string;
5
- }>>>, {}, {}>;
6
- export default _default;
7
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
8
- type __VLS_TypePropsToRuntimeProps<T> = {
9
- [K in keyof T]-?: {} extends Pick<T, K> ? {
10
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
11
- } : {
12
- type: import('vue').PropType<T[K]>;
13
- required: true;
14
- };
15
- };
@@ -1,38 +0,0 @@
1
- import { defineComponent as l, resolveComponent as e, openBlock as d, createBlock as s, withCtx as t, createVNode as n, createTextVNode as _, toDisplayString as p, createElementVNode as i } from "vue";
2
- const m = /* @__PURE__ */ i("h1", null, "IDENTITY LOGIN", -1), x = /* @__PURE__ */ l({
3
- __name: "IdentityLogin",
4
- props: {
5
- msg: {}
6
- },
7
- setup(u) {
8
- return (c, f) => {
9
- const r = e("v-card-title"), o = e("v-card-text"), a = e("v-card");
10
- return d(), s(a, { text: "" }, {
11
- default: t(() => [
12
- n(r, null, {
13
- default: t(() => [
14
- m
15
- ]),
16
- _: 1
17
- }),
18
- n(o, null, {
19
- default: t(() => [
20
- _("INCA DRAX")
21
- ]),
22
- _: 1
23
- }),
24
- n(o, null, {
25
- default: t(() => [
26
- _(p(c.msg), 1)
27
- ]),
28
- _: 1
29
- })
30
- ]),
31
- _: 1
32
- });
33
- };
34
- }
35
- });
36
- export {
37
- x as IdentityLogin
38
- };
@@ -1 +0,0 @@
1
- (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t["@drax/identity-front"]={},t.Vue))})(this,function(t,e){"use strict";const o=e.createElementVNode("h1",null,"IDENTITY LOGIN",-1),d=e.defineComponent({__name:"IdentityLogin",props:{msg:{}},setup(l){return(i,s)=>{const r=e.resolveComponent("v-card-title"),n=e.resolveComponent("v-card-text"),c=e.resolveComponent("v-card");return e.openBlock(),e.createBlock(c,{text:""},{default:e.withCtx(()=>[e.createVNode(r,null,{default:e.withCtx(()=>[o]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createTextVNode("INCA DRAX")]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.msg),1)]),_:1})]),_:1})}}});t.IdentityLogin=d,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/dist/favicon.ico DELETED
Binary file
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { default as IdentityLogin } from './components/IdentityLogin/IdentityLogin.vue';
2
-
3
- export { IdentityLogin };
@@ -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>