@outbuild/supa-store 1.0.6 → 1.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/README.md +9 -5
- package/fesm2022/outbuild-supa-store.mjs +79 -14
- package/fesm2022/outbuild-supa-store.mjs.map +1 -1
- package/index.d.ts +187 -5
- package/package.json +19 -10
- package/lib/common/features/post-auth-loader.feature.d.ts +0 -12
- package/lib/common/features/supa-store-core.feature.d.ts +0 -29
- package/lib/common/token/initial-state.token.d.ts +0 -3
- package/lib/common/token/supabase-credentials.token.d.ts +0 -3
- package/lib/common/type/supa-store.types.d.ts +0 -29
- package/lib/supa-store.provider.d.ts +0 -49
- package/lib/supa-store.store.d.ts +0 -28
- package/public-api.d.ts +0 -4
package/README.md
CHANGED
|
@@ -56,8 +56,11 @@ provideSupaStore({
|
|
|
56
56
|
|
|
57
57
|
## Observables
|
|
58
58
|
|
|
59
|
-
Observables will
|
|
60
|
-
|
|
59
|
+
Observables will have either undefined, null or the logged in user value.
|
|
60
|
+
|
|
61
|
+
undefined - auth call is in progress.
|
|
62
|
+
null - auth call complete, no logged user found, not logged in.
|
|
63
|
+
value - auth call complete, logged user found.
|
|
61
64
|
|
|
62
65
|
## Store type
|
|
63
66
|
|
|
@@ -73,8 +76,9 @@ type SupaStoreState = {
|
|
|
73
76
|
curr: AuthChangeEvent | null
|
|
74
77
|
}
|
|
75
78
|
},
|
|
76
|
-
user
|
|
77
|
-
session
|
|
78
|
-
metadata
|
|
79
|
+
user$: Observable<null | User>
|
|
80
|
+
session$: Observable<null | Session>
|
|
81
|
+
metadata$: Observable<null | unknown>
|
|
82
|
+
signInWithGoogle: (options: SignInWithOAuthCredentials['options']) => void
|
|
79
83
|
}
|
|
80
84
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { signalStoreFeature, type, withMethods, withHooks, withState,
|
|
1
|
+
import { signalStoreFeature, type, withMethods, withProps, withHooks, withState, signalStore, patchState } from '@ngrx/signals';
|
|
2
2
|
import { InjectionToken, inject, makeEnvironmentProviders } from '@angular/core';
|
|
3
3
|
import { updateState, withDevtools } from '@angular-architects/ngrx-toolkit';
|
|
4
4
|
import { createClient } from '@supabase/supabase-js';
|
|
@@ -6,6 +6,7 @@ import { toObservable } from '@angular/core/rxjs-interop';
|
|
|
6
6
|
import { firstValueFrom, filter } from 'rxjs';
|
|
7
7
|
import { WA_WINDOW, WA_SCREEN } from '@ng-web-apis/common';
|
|
8
8
|
import { createInjectionToken } from 'ngxtension/create-injection-token';
|
|
9
|
+
import { setAllEntities } from '@ngrx/signals/entities';
|
|
9
10
|
|
|
10
11
|
const SUPA_STORE_OPTIONS = new InjectionToken('SUPA_STORE_OPTIONS');
|
|
11
12
|
|
|
@@ -25,10 +26,10 @@ const INITIAL_STATE = new InjectionToken('SupaStoreState', {
|
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
const
|
|
29
|
+
const withMetadata = () => signalStoreFeature({
|
|
29
30
|
state: type()
|
|
30
31
|
}, withMethods((store, { metadataRpc: rpc, metadataTable: table } = inject(SUPA_STORE_OPTIONS)) => ({
|
|
31
|
-
|
|
32
|
+
_loadMetadata: async () => {
|
|
32
33
|
if (table || rpc) {
|
|
33
34
|
const session = await firstValueFrom(toObservable(store.auth.session).pipe(filter(res => res !== undefined)));
|
|
34
35
|
if (!session)
|
|
@@ -45,15 +46,19 @@ const withPostAuth = () => signalStoreFeature({
|
|
|
45
46
|
updateState(store, 'No Metadata', { auth: { ...store.auth(), metadata: null } });
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
+
}
|
|
50
|
+
})), withProps(store => ({
|
|
51
|
+
hydrateMetadata: store._loadMetadata()
|
|
49
52
|
})), withHooks({
|
|
50
53
|
onInit(store) {
|
|
51
54
|
/* Auto Load Additional User Auth Data */
|
|
52
|
-
store.
|
|
55
|
+
store._loadMetadata();
|
|
53
56
|
}
|
|
54
57
|
}));
|
|
55
58
|
|
|
56
|
-
const
|
|
59
|
+
const withAuth = () => signalStoreFeature({
|
|
60
|
+
state: type()
|
|
61
|
+
}, withProps(({ auth: { user, session, metadata } }) => ({
|
|
57
62
|
_SCREEN: inject(WA_SCREEN),
|
|
58
63
|
_WINDOW: inject(WA_WINDOW),
|
|
59
64
|
user$: toObservable(user).pipe(filter(res => res !== undefined)),
|
|
@@ -68,12 +73,13 @@ const withSupaStoreCore = () => signalStoreFeature(withDevtools('supaStore'), wi
|
|
|
68
73
|
const { data: { user }, error } = await store.client().auth.getUser();
|
|
69
74
|
updateState(store, 'Initialise User', { auth: { ...store.auth(), user } });
|
|
70
75
|
},
|
|
71
|
-
signInWithGoogle:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
76
|
+
signInWithGoogle: (options = {}) => store.client().auth.signInWithOAuth({ provider: 'google', ...options })
|
|
77
|
+
// const { data: { url }, error } = await store.client().auth.signInWithOAuth({ provider: 'google', ...options })
|
|
78
|
+
// console.log('url', url)
|
|
79
|
+
// // const [ width, height ] = [500,600]
|
|
80
|
+
// // const [ left, top ] = [(store._SCREEN.width / 2) - (width / 2), (store._SCREEN.height / 2) - (height / 2)]
|
|
81
|
+
// // store._WINDOW.open(url!, '_blank', `width=${width},height=${height},left=${left},top=${top},toolbar=no,menubar=no`)
|
|
82
|
+
// }
|
|
77
83
|
})), withHooks({
|
|
78
84
|
onInit(store) {
|
|
79
85
|
/* Listen For Auth State Changes */
|
|
@@ -87,7 +93,9 @@ const withSupaStoreCore = () => signalStoreFeature(withDevtools('supaStore'), wi
|
|
|
87
93
|
}
|
|
88
94
|
}));
|
|
89
95
|
|
|
90
|
-
const
|
|
96
|
+
const withSupaStore = () => signalStoreFeature(withDevtools('supaStore'), withState(() => inject(INITIAL_STATE)), withAuth(), withMetadata());
|
|
97
|
+
|
|
98
|
+
const SupaStore = signalStore(withSupaStore());
|
|
91
99
|
|
|
92
100
|
const provideSupaStore = (options) => makeEnvironmentProviders([
|
|
93
101
|
{
|
|
@@ -99,6 +107,63 @@ const provideSupaStore = (options) => makeEnvironmentProviders([
|
|
|
99
107
|
const [injectSupaClient] = createInjectionToken(() => inject(SupaStore).client);
|
|
100
108
|
const [injectSupaAuth] = createInjectionToken(() => inject(SupaStore).auth);
|
|
101
109
|
|
|
110
|
+
const handleOptions = (table, options = {}) => {
|
|
111
|
+
const { select, match, or, order, eq, range, query } = options;
|
|
112
|
+
const filter = table.select(select);
|
|
113
|
+
if (eq)
|
|
114
|
+
filter.eq(eq[0], eq[1]);
|
|
115
|
+
if (or)
|
|
116
|
+
filter.or(or);
|
|
117
|
+
if (match)
|
|
118
|
+
filter.match(match);
|
|
119
|
+
if (order)
|
|
120
|
+
filter.order(order[0], order[1]);
|
|
121
|
+
if (range)
|
|
122
|
+
filter.range(range[0], range[1]);
|
|
123
|
+
if (query)
|
|
124
|
+
filter.textSearch(query[0], query[1]);
|
|
125
|
+
return filter;
|
|
126
|
+
};
|
|
127
|
+
const supabaseQueryBuilder = (table, options = {}) => {
|
|
128
|
+
const { select, match, or, order, eq, range, query } = options;
|
|
129
|
+
const filter = table.select(select);
|
|
130
|
+
if (eq)
|
|
131
|
+
filter.eq(eq[0], eq[1]);
|
|
132
|
+
if (or)
|
|
133
|
+
filter.or(or);
|
|
134
|
+
if (match)
|
|
135
|
+
filter.match(match);
|
|
136
|
+
if (order)
|
|
137
|
+
filter.order(order[0], order[1]);
|
|
138
|
+
if (range)
|
|
139
|
+
filter.range(range[0], range[1]);
|
|
140
|
+
if (query)
|
|
141
|
+
filter.textSearch(query[0], query[1]);
|
|
142
|
+
return filter;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const initialState = {
|
|
146
|
+
isLoaded: false,
|
|
147
|
+
error: null
|
|
148
|
+
};
|
|
149
|
+
function withSupaEntities({ schemaStr = 'public', table }) {
|
|
150
|
+
return signalStoreFeature(withState(() => initialState), withProps(() => {
|
|
151
|
+
const client = inject(SupaStore).client;
|
|
152
|
+
console.log('client', client);
|
|
153
|
+
const schema = schemaStr === 'public' ? client() : client().schema(schemaStr);
|
|
154
|
+
return { schema, table: () => schema.from(table) };
|
|
155
|
+
}), withMethods(store => ({
|
|
156
|
+
allItems: async (options = {}) => {
|
|
157
|
+
patchState(store, { error: null });
|
|
158
|
+
const { data, error } = await supabaseQueryBuilder(store.table(), options);
|
|
159
|
+
error
|
|
160
|
+
? patchState(store, { error: error.message, isLoaded: true })
|
|
161
|
+
: patchState(store, setAllEntities(data || [], { collection: table }), { isLoaded: true });
|
|
162
|
+
return { data, error };
|
|
163
|
+
}
|
|
164
|
+
})));
|
|
165
|
+
}
|
|
166
|
+
|
|
102
167
|
/*
|
|
103
168
|
* Public API Surface of ob-supa-store
|
|
104
169
|
*/
|
|
@@ -107,5 +172,5 @@ const [injectSupaAuth] = createInjectionToken(() => inject(SupaStore).auth);
|
|
|
107
172
|
* Generated bundle index. Do not edit.
|
|
108
173
|
*/
|
|
109
174
|
|
|
110
|
-
export { SupaStore, injectSupaAuth, injectSupaClient, provideSupaStore,
|
|
175
|
+
export { SupaStore, injectSupaAuth, injectSupaClient, provideSupaStore, withSupaEntities, withSupaStore };
|
|
111
176
|
//# sourceMappingURL=outbuild-supa-store.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbuild-supa-store.mjs","sources":["../../../projects/ob-supa-store/src/lib/common/token/supabase-credentials.token.ts","../../../projects/ob-supa-store/src/lib/common/token/initial-state.token.ts","../../../projects/ob-supa-store/src/lib/common/features/post-auth-loader.feature.ts","../../../projects/ob-supa-store/src/lib/common/features/supa-store-core.feature.ts","../../../projects/ob-supa-store/src/lib/supa-store.store.ts","../../../projects/ob-supa-store/src/lib/supa-store.provider.ts","../../../projects/ob-supa-store/src/public-api.ts","../../../projects/ob-supa-store/src/outbuild-supa-store.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\"\r\nimport { SupaStoreOptions } from \"../type/supa-store.types\"\r\n\r\nexport const SUPA_STORE_OPTIONS = new InjectionToken<SupaStoreOptions>('SUPA_STORE_OPTIONS')\r\n","import { inject, InjectionToken } from \"@angular/core\"\r\nimport { SUPA_STORE_OPTIONS } from \"./supabase-credentials.token\"\r\nimport { createClient } from \"@supabase/supabase-js\"\r\nimport { SupaStoreState } from \"../type/supa-store.types\"\r\n\r\nexport const INITIAL_STATE = new InjectionToken<SupaStoreState>('SupaStoreState', {\r\n factory: () => {\r\n\r\n const { createClient: { supabaseUrl, supabaseKey, options }} = inject(SUPA_STORE_OPTIONS)\r\n const client = createClient(supabaseUrl, supabaseKey, options)\r\n\r\n return {\r\n client,\r\n auth: {\r\n session: undefined,\r\n user: undefined,\r\n metadata: undefined,\r\n state: { prev: null, curr: null }\r\n }\r\n }\r\n\r\n }\r\n})\r\n","import { inject } from '@angular/core'\r\nimport { Session } from '@supabase/supabase-js'\r\nimport { toObservable } from \"@angular/core/rxjs-interop\"\r\nimport { SupaStoreState } from '../type/supa-store.types'\r\nimport { SUPA_STORE_OPTIONS } from '../token/supabase-credentials.token'\r\nimport { filter, firstValueFrom, Observable } from 'rxjs'\r\nimport { signalStoreFeature, type, withHooks, withMethods } from '@ngrx/signals'\r\nimport { updateState } from '@angular-architects/ngrx-toolkit'\r\n\r\nexport const withPostAuth = () => signalStoreFeature(\r\n\r\n {\r\n state: type<SupaStoreState>()\r\n },\r\n\r\n withMethods((store, { metadataRpc: rpc, metadataTable: table } = inject(SUPA_STORE_OPTIONS)) => ({\r\n\r\n _postAuth: async () => {\r\n\r\n if (table || rpc) {\r\n\r\n const session = await firstValueFrom(toObservable(store.auth.session).pipe(filter(res => res !== undefined)) as Observable<Session>)\r\n if (!session) return\r\n\r\n if (table) {\r\n const { data } = await store.client().from(table).select('*').eq('id', session?.user?.id).single()\r\n updateState(store, 'Load Metadata - Table', { auth: { ...store.auth(), metadata: data }})\r\n } else if (rpc) {\r\n const { data } = await store.client().rpc(rpc, { input: { user_id: session?.user?.id }})\r\n updateState(store, 'Load Metadata - Rpc', { auth: { ...store.auth(), metadata: data }})\r\n } else {\r\n updateState(store, 'No Metadata', { auth: { ...store.auth(), metadata: null}})\r\n }\r\n\r\n }\r\n },\r\n\r\n })),\r\n\r\n withHooks({\r\n\r\n onInit(store) {\r\n\r\n /* Auto Load Additional User Auth Data */\r\n store._postAuth()\r\n\r\n }\r\n\r\n })\r\n\r\n)\r\n","import { inject } from '@angular/core';\r\nimport { updateState, withDevtools } from '@angular-architects/ngrx-toolkit'\r\nimport { INITIAL_STATE } from '../token/initial-state.token'\r\nimport { SupaStoreState } from '../type/supa-store.types'\r\nimport { withPostAuth } from '../features/post-auth-loader.feature'\r\nimport { signalStoreFeature, withHooks, withMethods, withProps, withState } from '@ngrx/signals'\r\nimport { toObservable } from '@angular/core/rxjs-interop'\r\nimport { filter } from 'rxjs'\r\nimport { SignInWithOAuthCredentials } from '@supabase/supabase-js'\r\nimport { WA_WINDOW, WA_SCREEN } from '@ng-web-apis/common'\r\n\r\nexport const withSupaStoreCore = () => signalStoreFeature(\r\n\r\n withDevtools('supaStore'),\r\n withState<SupaStoreState>(() => inject(INITIAL_STATE)),\r\n withPostAuth(),\r\n\r\n withProps(({ auth: { user, session, metadata }}) => ({\r\n _SCREEN: inject(WA_SCREEN),\r\n _WINDOW: inject(WA_WINDOW),\r\n user$: toObservable(user).pipe(filter(res => res !== undefined)),\r\n session$: toObservable(session).pipe(filter(res => res !== undefined)),\r\n metadata$: toObservable(metadata).pipe(filter(res => res !== undefined))\r\n })),\r\n\r\n withMethods(store => ({\r\n\r\n _initSession: async () => {\r\n const { data: { session }, error} = await store.client().auth.getSession()\r\n updateState(store, 'Initialise Session', { auth: { ...store.auth(), session }})\r\n },\r\n\r\n _initUser: async () => {\r\n const { data: { user }, error } = await store.client().auth.getUser()\r\n updateState(store, 'Initialise User', { auth: { ...store.auth(), user }})\r\n },\r\n\r\n signInWithGoogle: async (options: SignInWithOAuthCredentials['options'] = {}) => {\r\n const { data: { url }, error } = await store.client().auth.signInWithOAuth({ provider: 'google', ...options })\r\n const [ width, height ] = [500,600]\r\n const [ left, top ] = [(store._SCREEN.width / 2) - (width / 2), (store._SCREEN.height / 2) - (height / 2)]\r\n store._WINDOW.open(url!, '_blank', `width=${width},height=${height},left=${left},top=${top},toolbar=no,menubar=no`)\r\n }\r\n\r\n })),\r\n\r\n withHooks({\r\n\r\n onInit(store) {\r\n\r\n /* Listen For Auth State Changes */\r\n store.client().auth.onAuthStateChange(state => {\r\n updateState(store, 'Auth State Change', { auth: { ...store.auth(), state: { prev: store.auth.state.curr(), curr: state }}})\r\n })\r\n\r\n /* Init Supabase Session */\r\n store._initSession()\r\n\r\n /* Init Supabase User */\r\n store._initUser()\r\n\r\n }\r\n\r\n })\r\n\r\n)\r\n","import { signalStore } from '@ngrx/signals'\r\nimport { withSupaStoreCore } from './common/features/supa-store-core.feature'\r\n\r\nexport const SupaStore = signalStore(\r\n withSupaStoreCore()\r\n)\r\n","import { EnvironmentProviders, inject, makeEnvironmentProviders } from \"@angular/core\"\r\nimport { SupaStore } from \"./supa-store.store\"\r\nimport { SUPA_STORE_OPTIONS } from \"./common/token/supabase-credentials.token\"\r\nimport { SupaStoreOptions } from \"./common/type/supa-store.types\"\r\nimport { createInjectionToken } from 'ngxtension/create-injection-token'\r\n\r\n\r\nexport const provideSupaStore = (options: SupaStoreOptions): EnvironmentProviders => makeEnvironmentProviders([\r\n {\r\n provide: SUPA_STORE_OPTIONS,\r\n useValue: options\r\n },\r\n SupaStore\r\n])\r\n\r\n\r\nexport const [ injectSupaClient ] = createInjectionToken(() => inject(SupaStore).client)\r\nexport const [ injectSupaAuth ] = createInjectionToken(() => inject(SupaStore).auth)\r\n","/*\r\n * Public API Surface of ob-supa-store\r\n*/\r\n\r\nexport * from './lib/supa-store.store'\r\nexport * from './lib/supa-store.provider'\r\nexport * from './lib/common/features/supa-store-core.feature'\r\nexport * from './lib/common/type/supa-store.types'\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';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B,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM;AAC1E,MAAA,CAAE,cAAc,CAAE,GAAK,oBAAoB,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI;;ACjBrF;;AAEE;;ACFF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"outbuild-supa-store.mjs","sources":["../../../projects/ob-supa-store/src/lib/common/token/supabase-credentials.token.ts","../../../projects/ob-supa-store/src/lib/common/token/initial-state.token.ts","../../../projects/ob-supa-store/src/lib/common/features/with-metadata.feature.ts","../../../projects/ob-supa-store/src/lib/common/features/with-auth.feature.ts","../../../projects/ob-supa-store/src/lib/common/features/with-supa-store.feature.ts","../../../projects/ob-supa-store/src/lib/supa-store.store.ts","../../../projects/ob-supa-store/src/lib/supa-store.provider.ts","../../../projects/ob-supa-store/src/lib/common/helper/handle-options.ts","../../../projects/ob-supa-store/src/lib/common/features/with-supa-entities.feature.ts","../../../projects/ob-supa-store/src/public-api.ts","../../../projects/ob-supa-store/src/outbuild-supa-store.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\"\r\nimport { SupaStoreOptions } from \"../type/supa-store.types\"\r\n\r\nexport const SUPA_STORE_OPTIONS = new InjectionToken<SupaStoreOptions>('SUPA_STORE_OPTIONS')\r\n","import { inject, InjectionToken } from \"@angular/core\"\r\nimport { SUPA_STORE_OPTIONS } from \"./supabase-credentials.token\"\r\nimport { createClient } from \"@supabase/supabase-js\"\r\nimport { SupaStoreState } from \"../type/supa-store.types\"\r\n\r\nexport const INITIAL_STATE = new InjectionToken<SupaStoreState>('SupaStoreState', {\r\n factory: () => {\r\n\r\n const { createClient: { supabaseUrl, supabaseKey, options }} = inject(SUPA_STORE_OPTIONS)\r\n const client = createClient(supabaseUrl, supabaseKey, options)\r\n\r\n return {\r\n client,\r\n auth: {\r\n session: undefined,\r\n user: undefined,\r\n metadata: undefined,\r\n state: { prev: null, curr: null }\r\n }\r\n }\r\n\r\n }\r\n})\r\n","import { inject } from '@angular/core'\r\nimport { Session } from '@supabase/supabase-js'\r\nimport { toObservable } from \"@angular/core/rxjs-interop\"\r\nimport { SupaStoreState } from '../type/supa-store.types'\r\nimport { SUPA_STORE_OPTIONS } from '../token/supabase-credentials.token'\r\nimport { filter, firstValueFrom, Observable } from 'rxjs'\r\nimport { signalStoreFeature, type, withHooks, withMethods, withProps } from '@ngrx/signals'\r\nimport { updateState } from '@angular-architects/ngrx-toolkit'\r\n\r\nexport const withMetadata = () => signalStoreFeature(\r\n\r\n {\r\n state: type<SupaStoreState>()\r\n },\r\n\r\n withMethods((store, { metadataRpc: rpc, metadataTable: table } = inject(SUPA_STORE_OPTIONS)) => ({\r\n\r\n _loadMetadata: async () => {\r\n\r\n if (table || rpc) {\r\n\r\n const session = await firstValueFrom(toObservable(store.auth.session).pipe(filter(res => res !== undefined)) as Observable<Session>)\r\n if (!session) return\r\n\r\n if (table) {\r\n const { data } = await store.client().from(table).select('*').eq('id', session?.user?.id).single()\r\n updateState(store, 'Load Metadata - Table', { auth: { ...store.auth(), metadata: data }})\r\n } else if (rpc) {\r\n const { data } = await store.client().rpc(rpc, { input: { user_id: session?.user?.id }})\r\n updateState(store, 'Load Metadata - Rpc', { auth: { ...store.auth(), metadata: data }})\r\n } else {\r\n updateState(store, 'No Metadata', { auth: { ...store.auth(), metadata: null}})\r\n }\r\n\r\n }\r\n }\r\n\r\n })),\r\n\r\n withProps(store => ({\r\n hydrateMetadata: store._loadMetadata()\r\n })),\r\n\r\n withHooks({\r\n\r\n onInit(store) {\r\n\r\n /* Auto Load Additional User Auth Data */\r\n store._loadMetadata()\r\n\r\n }\r\n\r\n })\r\n\r\n)\r\n","import { inject } from '@angular/core'\r\nimport { SignInWithOAuthCredentials } from '@supabase/supabase-js'\r\nimport { toObservable } from \"@angular/core/rxjs-interop\"\r\nimport { SupaStoreState } from '../type/supa-store.types'\r\nimport { filter } from 'rxjs'\r\nimport { signalStoreFeature, type, withHooks, withMethods, withProps } from '@ngrx/signals'\r\nimport { updateState } from '@angular-architects/ngrx-toolkit'\r\nimport { WA_SCREEN, WA_WINDOW } from '@ng-web-apis/common'\r\n\r\nexport const withAuth = () => signalStoreFeature(\r\n\r\n {\r\n state: type<SupaStoreState>()\r\n },\r\n\r\n withProps(({ auth: { user, session, metadata }}) => ({\r\n _SCREEN: inject(WA_SCREEN),\r\n _WINDOW: inject(WA_WINDOW),\r\n user$: toObservable(user).pipe(filter(res => res !== undefined)),\r\n session$: toObservable(session).pipe(filter(res => res !== undefined)),\r\n metadata$: toObservable(metadata).pipe(filter(res => res !== undefined))\r\n })),\r\n\r\n withMethods(store => ({\r\n\r\n _initSession: async () => {\r\n const { data: { session }, error} = await store.client().auth.getSession()\r\n updateState(store, 'Initialise Session', { auth: { ...store.auth(), session }})\r\n },\r\n\r\n _initUser: async () => {\r\n const { data: { user }, error } = await store.client().auth.getUser()\r\n updateState(store, 'Initialise User', { auth: { ...store.auth(), user }})\r\n },\r\n\r\n signInWithGoogle: (options: SignInWithOAuthCredentials['options'] = {}) => store.client().auth.signInWithOAuth({ provider: 'google', ...options })\r\n // const { data: { url }, error } = await store.client().auth.signInWithOAuth({ provider: 'google', ...options })\r\n // console.log('url', url)\r\n // // const [ width, height ] = [500,600]\r\n // // const [ left, top ] = [(store._SCREEN.width / 2) - (width / 2), (store._SCREEN.height / 2) - (height / 2)]\r\n // // store._WINDOW.open(url!, '_blank', `width=${width},height=${height},left=${left},top=${top},toolbar=no,menubar=no`)\r\n // }\r\n\r\n })),\r\n\r\n withHooks({\r\n\r\n onInit(store) {\r\n\r\n /* Listen For Auth State Changes */\r\n store.client().auth.onAuthStateChange(state => {\r\n updateState(store, 'Auth State Change', { auth: { ...store.auth(), state: { prev: store.auth.state.curr(), curr: state }}})\r\n })\r\n\r\n /* Init Supabase Session */\r\n store._initSession()\r\n\r\n /* Init Supabase User */\r\n store._initUser()\r\n\r\n }\r\n\r\n })\r\n\r\n)\r\n","import { inject } from '@angular/core';\r\nimport { withDevtools } from '@angular-architects/ngrx-toolkit'\r\nimport { INITIAL_STATE } from '../token/initial-state.token'\r\nimport { SupaStoreState } from '../type/supa-store.types'\r\nimport { withMetadata } from './with-metadata.feature'\r\nimport { signalStoreFeature, withState } from '@ngrx/signals'\r\nimport { withAuth } from './with-auth.feature'\r\n\r\nexport const withSupaStore = () => signalStoreFeature(\r\n withDevtools('supaStore'),\r\n withState<SupaStoreState>(() => inject(INITIAL_STATE)),\r\n withAuth(),\r\n withMetadata(),\r\n)\r\n","import { signalStore } from '@ngrx/signals'\r\nimport { withSupaStore } from './common/features/with-supa-store.feature'\r\n\r\nexport const SupaStore = signalStore(\r\n withSupaStore()\r\n)\r\n","import { EnvironmentProviders, inject, makeEnvironmentProviders } from \"@angular/core\"\r\nimport { SupaStore } from \"./supa-store.store\"\r\nimport { SUPA_STORE_OPTIONS } from \"./common/token/supabase-credentials.token\"\r\nimport { SupaStoreOptions } from \"./common/type/supa-store.types\"\r\nimport { createInjectionToken } from 'ngxtension/create-injection-token'\r\n\r\n\r\nexport const provideSupaStore = (options: SupaStoreOptions): EnvironmentProviders => makeEnvironmentProviders([\r\n {\r\n provide: SUPA_STORE_OPTIONS,\r\n useValue: options\r\n },\r\n SupaStore\r\n])\r\n\r\n\r\nexport const [ injectSupaClient ] = createInjectionToken(() => inject(SupaStore).client)\r\nexport const [ injectSupaAuth ] = createInjectionToken(() => inject(SupaStore).auth)\r\n","import { Observable } from \"rxjs\"\r\nimport { FindOptions } from \"../type/supa-store.types\"\r\nimport { PostgrestSingleResponse } from \"@supabase/supabase-js\"\r\n\r\nexport const handleOptions = <T>(table: any, options: FindOptions = {}): PostgrestSingleResponse<T[]> => {\r\n const { select, match, or, order, eq, range, query } = options\r\n const filter = table.select(select)\r\n if (eq) filter.eq(eq[0], eq[1])\r\n if (or) filter.or(or)\r\n if (match) filter.match(match)\r\n if (order) filter.order(order[0], order[1])\r\n if (range) filter.range(range[0], range[1])\r\n if (query) filter.textSearch(query[0], query[1])\r\n return filter\r\n}\r\n\r\n\r\n\r\nexport const supabaseQueryBuilder = <T>(table: any, options: FindOptions = {}): PostgrestSingleResponse<T[]> => {\r\n const { select, match, or, order, eq, range, query } = options\r\n const filter = table.select(select)\r\n if (eq) filter.eq(eq[0], eq[1])\r\n if (or) filter.or(or)\r\n if (match) filter.match(match)\r\n if (order) filter.order(order[0], order[1])\r\n if (range) filter.range(range[0], range[1])\r\n if (query) filter.textSearch(query[0], query[1])\r\n return filter\r\n}\r\n","import { PostgrestError } from \"@supabase/supabase-js\"\r\nimport { supabaseQueryBuilder } from \"../helper/handle-options\"\r\nimport { EntityId, EntityMap, setAllEntities, withEntities } from \"@ngrx/signals/entities\"\r\nimport { FindOptions, SupabaseSyncInput } from \"../type/supa-store.types\"\r\nimport { patchState, signalStoreFeature, type, withMethods, withProps, withState } from \"@ngrx/signals\"\r\nimport { injectSupaClient } from \"../../supa-store.provider\"\r\nimport { inject, Signal, signal } from \"@angular/core\"\r\nimport { SupaStore } from \"../../supa-store.store\"\r\n\r\nexport type State = {\r\n isLoaded: boolean\r\n error: null | string\r\n}\r\n\r\nconst initialState = {\r\n isLoaded: false,\r\n error: null\r\n}\r\n\r\nexport function withSupaEntities<T extends { id: EntityId }>({ schemaStr = 'public', table }: SupabaseSyncInput<T>) {\r\n return signalStoreFeature(\r\n\r\n withState<State>(() => initialState),\r\n\r\n withProps(() => {\r\n const client = inject(SupaStore).client\r\n console.log('client', client)\r\n const schema = schemaStr === 'public' ? client() : client().schema(schemaStr)\r\n return { schema, table: () => schema.from(table) }\r\n }),\r\n\r\n withMethods(store => ({\r\n\r\n allItems: async (options: FindOptions = {}): Promise<{ data: T[] | null, error: PostgrestError | null }> => {\r\n patchState(store, { error: null })\r\n const { data, error } = await supabaseQueryBuilder<T>(store.table(), options)\r\n error\r\n ? patchState(store, { error: error.message, isLoaded: true })\r\n : patchState(store, setAllEntities(data || [], { collection: table }), { isLoaded: true})\r\n return { data, error }\r\n }\r\n\r\n }))\r\n\r\n )\r\n}\r\n","/*\r\n * Public API Surface of ob-supa-store\r\n*/\r\n\r\nexport * from './lib/supa-store.store'\r\nexport * from './lib/supa-store.provider'\r\nexport * from './lib/common/features/with-supa-store.feature'\r\nexport * from './lib/common/features/with-supa-entities.feature'\r\nexport * from './lib/common/type/supa-store.types'\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAGO,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAmB,oBAAoB,CAAC;;ACErF,MAAM,aAAa,GAAG,IAAI,cAAc,CAAiB,gBAAgB,EAAE;IAChF,OAAO,EAAE,MAAK;AAEZ,QAAA,MAAM,EAAE,YAAY,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,EAAC,GAAG,MAAM,CAAC,kBAAkB,CAAC;QACzF,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC;QAE9D,OAAO;YACL,MAAM;AACN,YAAA,IAAI,EAAE;AACJ,gBAAA,OAAO,EAAE,SAAS;AAClB,gBAAA,IAAI,EAAE,SAAS;AACf,gBAAA,QAAQ,EAAE,SAAS;gBACnB,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;AAChC;SACF;;AAGJ,CAAA,CAAC;;ACbK,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAElD;IACE,KAAK,EAAE,IAAI;CACZ,EAED,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,MAAM;IAE/F,aAAa,EAAE,YAAW;AAExB,QAAA,IAAI,KAAK,IAAI,GAAG,EAAE;AAEhB,YAAA,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG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,QAAQ,EAAE,OAAO,OAAA,GAAuB,EAAE,KAAiE;YACzG,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAClC,YAAA,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,oBAAoB,CAAI,KAAK,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC;YAC7E;AACE,kBAAE,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;kBAC1D,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;AAC3F,YAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;;KAGzB,CAAC,CAAC,CAEJ;AACH;;AC7CA;;AAEE;;ACFF;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import * as rxjs from 'rxjs';
|
|
4
|
+
import * as _supabase_auth_js from '@supabase/auth-js';
|
|
5
|
+
import * as _ngrx_signals from '@ngrx/signals';
|
|
6
|
+
import * as _supabase_supabase_js from '@supabase/supabase-js';
|
|
7
|
+
import { SupabaseClientOptions, SupabaseClient, Session, User, AuthChangeEvent, PostgrestError } from '@supabase/supabase-js';
|
|
8
|
+
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
9
|
+
import { EntityId } from '@ngrx/signals/entities';
|
|
10
|
+
|
|
11
|
+
declare const SupaStore: _angular_core.Type<{
|
|
12
|
+
client: _ngrx_signals.DeepSignal<_supabase_supabase_js.SupabaseClient<any, "public", "public", any, any>>;
|
|
13
|
+
auth: _ngrx_signals.DeepSignal<{
|
|
14
|
+
session: undefined | null | _supabase_auth_js.Session;
|
|
15
|
+
user: undefined | null | _supabase_auth_js.User;
|
|
16
|
+
metadata: undefined | null | unknown;
|
|
17
|
+
state: {
|
|
18
|
+
prev: _supabase_auth_js.AuthChangeEvent | null;
|
|
19
|
+
curr: _supabase_auth_js.AuthChangeEvent | null;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
user$: rxjs.Observable<_supabase_auth_js.User | null>;
|
|
23
|
+
session$: rxjs.Observable<_supabase_auth_js.Session | null>;
|
|
24
|
+
metadata$: rxjs.Observable<{} | null>;
|
|
25
|
+
hydrateMetadata: Promise<void>;
|
|
26
|
+
signInWithGoogle: (options?: _supabase_auth_js.SignInWithOAuthCredentials["options"]) => Promise<_supabase_auth_js.OAuthResponse>;
|
|
27
|
+
} & _ngrx_signals.StateSource<{
|
|
28
|
+
client: _supabase_supabase_js.SupabaseClient;
|
|
29
|
+
auth: {
|
|
30
|
+
session: undefined | null | _supabase_auth_js.Session;
|
|
31
|
+
user: undefined | null | _supabase_auth_js.User;
|
|
32
|
+
metadata: undefined | null | unknown;
|
|
33
|
+
state: {
|
|
34
|
+
prev: _supabase_auth_js.AuthChangeEvent | null;
|
|
35
|
+
curr: _supabase_auth_js.AuthChangeEvent | null;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}>>;
|
|
39
|
+
|
|
40
|
+
type SupaStoreState = {
|
|
41
|
+
client: SupabaseClient;
|
|
42
|
+
auth: {
|
|
43
|
+
session: undefined | null | Session;
|
|
44
|
+
user: undefined | null | User;
|
|
45
|
+
metadata: undefined | null | unknown;
|
|
46
|
+
state: {
|
|
47
|
+
prev: AuthChangeEvent | null;
|
|
48
|
+
curr: AuthChangeEvent | null;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type SupaStoreOptions = {
|
|
53
|
+
createClient: {
|
|
54
|
+
supabaseUrl: string;
|
|
55
|
+
supabaseKey: string;
|
|
56
|
+
options?: SupabaseClientOptions<any>;
|
|
57
|
+
};
|
|
58
|
+
} & ({
|
|
59
|
+
metadataTable: string;
|
|
60
|
+
metadataRpc?: never;
|
|
61
|
+
} | {
|
|
62
|
+
metadataRpc: string;
|
|
63
|
+
metadataTable?: never;
|
|
64
|
+
} | {
|
|
65
|
+
metadataTable?: undefined;
|
|
66
|
+
metadataRpc?: undefined;
|
|
67
|
+
});
|
|
68
|
+
type SupabaseSyncInput<T> = {
|
|
69
|
+
schemaStr?: string;
|
|
70
|
+
table: string;
|
|
71
|
+
};
|
|
72
|
+
interface FindOptions {
|
|
73
|
+
select?: string;
|
|
74
|
+
single?: boolean;
|
|
75
|
+
eq?: string[];
|
|
76
|
+
match?: Record<string, unknown>;
|
|
77
|
+
filter?: string;
|
|
78
|
+
or?: string;
|
|
79
|
+
order?: [string, {
|
|
80
|
+
ascending: boolean;
|
|
81
|
+
}];
|
|
82
|
+
range?: number[];
|
|
83
|
+
query?: [string, string];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare const provideSupaStore: (options: SupaStoreOptions) => EnvironmentProviders;
|
|
87
|
+
declare const injectSupaClient: {
|
|
88
|
+
(): _ngrx_signals.DeepSignal<_supabase_supabase_js.SupabaseClient<any, "public", "public", any, any>>;
|
|
89
|
+
(injectOptions: _angular_core.InjectOptions & {
|
|
90
|
+
optional?: false;
|
|
91
|
+
} & {
|
|
92
|
+
injector?: _angular_core.Injector;
|
|
93
|
+
}): _ngrx_signals.DeepSignal<_supabase_supabase_js.SupabaseClient<any, "public", "public", any, any>>;
|
|
94
|
+
(injectOptions: _angular_core.InjectOptions & {
|
|
95
|
+
injector?: _angular_core.Injector;
|
|
96
|
+
}): _ngrx_signals.DeepSignal<_supabase_supabase_js.SupabaseClient<any, "public", "public", any, any>> | null;
|
|
97
|
+
};
|
|
98
|
+
declare const injectSupaAuth: {
|
|
99
|
+
(): _ngrx_signals.DeepSignal<{
|
|
100
|
+
session: undefined | null | _supabase_auth_js.Session;
|
|
101
|
+
user: undefined | null | _supabase_auth_js.User;
|
|
102
|
+
metadata: undefined | null | unknown;
|
|
103
|
+
state: {
|
|
104
|
+
prev: _supabase_auth_js.AuthChangeEvent | null;
|
|
105
|
+
curr: _supabase_auth_js.AuthChangeEvent | null;
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
(injectOptions: _angular_core.InjectOptions & {
|
|
109
|
+
optional?: false;
|
|
110
|
+
} & {
|
|
111
|
+
injector?: _angular_core.Injector;
|
|
112
|
+
}): _ngrx_signals.DeepSignal<{
|
|
113
|
+
session: undefined | null | _supabase_auth_js.Session;
|
|
114
|
+
user: undefined | null | _supabase_auth_js.User;
|
|
115
|
+
metadata: undefined | null | unknown;
|
|
116
|
+
state: {
|
|
117
|
+
prev: _supabase_auth_js.AuthChangeEvent | null;
|
|
118
|
+
curr: _supabase_auth_js.AuthChangeEvent | null;
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
121
|
+
(injectOptions: _angular_core.InjectOptions & {
|
|
122
|
+
injector?: _angular_core.Injector;
|
|
123
|
+
}): _ngrx_signals.DeepSignal<{
|
|
124
|
+
session: undefined | null | _supabase_auth_js.Session;
|
|
125
|
+
user: undefined | null | _supabase_auth_js.User;
|
|
126
|
+
metadata: undefined | null | unknown;
|
|
127
|
+
state: {
|
|
128
|
+
prev: _supabase_auth_js.AuthChangeEvent | null;
|
|
129
|
+
curr: _supabase_auth_js.AuthChangeEvent | null;
|
|
130
|
+
};
|
|
131
|
+
}> | null;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
declare const withSupaStore: () => _ngrx_signals.SignalStoreFeature<_ngrx_signals.EmptyFeatureResult, {
|
|
135
|
+
state: {
|
|
136
|
+
client: _supabase_supabase_js.SupabaseClient;
|
|
137
|
+
auth: {
|
|
138
|
+
session: undefined | null | _supabase_auth_js.Session;
|
|
139
|
+
user: undefined | null | _supabase_auth_js.User;
|
|
140
|
+
metadata: undefined | null | unknown;
|
|
141
|
+
state: {
|
|
142
|
+
prev: _supabase_auth_js.AuthChangeEvent | null;
|
|
143
|
+
curr: _supabase_auth_js.AuthChangeEvent | null;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
props: {
|
|
148
|
+
_SCREEN: Screen;
|
|
149
|
+
_WINDOW: Window;
|
|
150
|
+
user$: rxjs.Observable<_supabase_auth_js.User | null>;
|
|
151
|
+
session$: rxjs.Observable<_supabase_auth_js.Session | null>;
|
|
152
|
+
metadata$: rxjs.Observable<{} | null>;
|
|
153
|
+
hydrateMetadata: Promise<void>;
|
|
154
|
+
};
|
|
155
|
+
methods: {
|
|
156
|
+
_initSession: () => Promise<void>;
|
|
157
|
+
_initUser: () => Promise<void>;
|
|
158
|
+
signInWithGoogle: (options?: _supabase_auth_js.SignInWithOAuthCredentials["options"]) => Promise<_supabase_auth_js.OAuthResponse>;
|
|
159
|
+
_loadMetadata: () => Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
}>;
|
|
162
|
+
|
|
163
|
+
type State = {
|
|
164
|
+
isLoaded: boolean;
|
|
165
|
+
error: null | string;
|
|
166
|
+
};
|
|
167
|
+
declare function withSupaEntities<T extends {
|
|
168
|
+
id: EntityId;
|
|
169
|
+
}>({ schemaStr, table }: SupabaseSyncInput<T>): _ngrx_signals.SignalStoreFeature<_ngrx_signals.EmptyFeatureResult, {
|
|
170
|
+
state: {
|
|
171
|
+
isLoaded: boolean;
|
|
172
|
+
error: null | string;
|
|
173
|
+
};
|
|
174
|
+
props: {
|
|
175
|
+
schema: _supabase_supabase_js.SupabaseClient<any, "public", "public", any, any> | _supabase_postgrest_js.PostgrestClient<any, any, string, any>;
|
|
176
|
+
table: () => _supabase_postgrest_js.PostgrestQueryBuilder<any, any, any, string, unknown>;
|
|
177
|
+
};
|
|
178
|
+
methods: {
|
|
179
|
+
allItems: (options?: FindOptions) => Promise<{
|
|
180
|
+
data: T[] | null;
|
|
181
|
+
error: PostgrestError | null;
|
|
182
|
+
}>;
|
|
183
|
+
};
|
|
184
|
+
}>;
|
|
185
|
+
|
|
186
|
+
export { SupaStore, injectSupaAuth, injectSupaClient, provideSupaStore, withSupaEntities, withSupaStore };
|
|
187
|
+
export type { FindOptions, State, SupaStoreOptions, SupaStoreState, SupabaseSyncInput };
|
package/package.json
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outbuild/supa-store",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/
|
|
6
|
-
"@angular/
|
|
7
|
-
"@
|
|
8
|
-
"@
|
|
9
|
-
"
|
|
10
|
-
"@
|
|
5
|
+
"@angular-architects/ngrx-toolkit": "^20.5.0",
|
|
6
|
+
"@angular/common": "^20.3.15",
|
|
7
|
+
"@angular/core": "^20.3.15",
|
|
8
|
+
"@ng-web-apis/common": "^5.0.2",
|
|
9
|
+
"@ngrx/signals": "^20.0.0",
|
|
10
|
+
"@supabase/supabase-js": "^2.89.0",
|
|
11
|
+
"ngxtension": "^7.0.2"
|
|
12
|
+
},
|
|
13
|
+
"peerDependenciesMeta": {
|
|
14
|
+
"@angular-architects/ngrx-toolkit": {
|
|
15
|
+
"optional": true
|
|
16
|
+
},
|
|
17
|
+
"@ng-web-apis/common": {
|
|
18
|
+
"optional": true
|
|
19
|
+
},
|
|
20
|
+
"ngxtension": {
|
|
21
|
+
"optional": true
|
|
22
|
+
}
|
|
11
23
|
},
|
|
12
24
|
"dependencies": {
|
|
13
25
|
"tslib": "^2.8.1"
|
|
14
26
|
},
|
|
15
|
-
"resolutions": {
|
|
16
|
-
"@supabase/auth-js": "2.61.0"
|
|
17
|
-
},
|
|
18
27
|
"sideEffects": false,
|
|
19
28
|
"module": "fesm2022/outbuild-supa-store.mjs",
|
|
20
29
|
"typings": "index.d.ts",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SupaStoreState } from '../type/supa-store.types';
|
|
2
|
-
export declare const withPostAuth: () => import("@ngrx/signals").SignalStoreFeature<{
|
|
3
|
-
state: SupaStoreState;
|
|
4
|
-
props: {};
|
|
5
|
-
methods: {};
|
|
6
|
-
}, {
|
|
7
|
-
state: {};
|
|
8
|
-
props: {};
|
|
9
|
-
methods: {
|
|
10
|
-
_postAuth: () => Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SignInWithOAuthCredentials } from '@supabase/supabase-js';
|
|
2
|
-
export declare const withSupaStoreCore: () => import("@ngrx/signals").SignalStoreFeature<import("@ngrx/signals").EmptyFeatureResult, {
|
|
3
|
-
state: {
|
|
4
|
-
client: import("@supabase/supabase-js").SupabaseClient;
|
|
5
|
-
auth: {
|
|
6
|
-
session: undefined | null | import("@supabase/supabase-js").AuthSession;
|
|
7
|
-
user: undefined | null | import("@supabase/supabase-js").AuthUser;
|
|
8
|
-
metadata: undefined | null | unknown;
|
|
9
|
-
state: {
|
|
10
|
-
prev: import("@supabase/supabase-js").AuthChangeEvent | null;
|
|
11
|
-
curr: import("@supabase/supabase-js").AuthChangeEvent | null;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
props: {
|
|
16
|
-
_SCREEN: Screen;
|
|
17
|
-
_WINDOW: Window;
|
|
18
|
-
user$: import("rxjs").Observable<import("@supabase/supabase-js").AuthUser | null>;
|
|
19
|
-
session$: import("rxjs").Observable<import("@supabase/supabase-js").AuthSession | null>;
|
|
20
|
-
metadata$: import("rxjs").Observable<{} | null>;
|
|
21
|
-
};
|
|
22
|
-
methods: {
|
|
23
|
-
[x: string]: (newName?: unknown) => unknown;
|
|
24
|
-
_postAuth: () => Promise<void>;
|
|
25
|
-
_initSession: () => Promise<void>;
|
|
26
|
-
_initUser: () => Promise<void>;
|
|
27
|
-
signInWithGoogle: (options?: SignInWithOAuthCredentials["options"]) => Promise<void>;
|
|
28
|
-
};
|
|
29
|
-
}>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AuthChangeEvent, Session, SupabaseClient, SupabaseClientOptions, User } from "@supabase/supabase-js";
|
|
2
|
-
export type SupaStoreState = {
|
|
3
|
-
client: SupabaseClient;
|
|
4
|
-
auth: {
|
|
5
|
-
session: undefined | null | Session;
|
|
6
|
-
user: undefined | null | User;
|
|
7
|
-
metadata: undefined | null | unknown;
|
|
8
|
-
state: {
|
|
9
|
-
prev: AuthChangeEvent | null;
|
|
10
|
-
curr: AuthChangeEvent | null;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export type SupaStoreOptions = {
|
|
15
|
-
createClient: {
|
|
16
|
-
supabaseUrl: string;
|
|
17
|
-
supabaseKey: string;
|
|
18
|
-
options?: SupabaseClientOptions<any>;
|
|
19
|
-
};
|
|
20
|
-
} & ({
|
|
21
|
-
metadataTable: string;
|
|
22
|
-
metadataRpc?: never;
|
|
23
|
-
} | {
|
|
24
|
-
metadataRpc: string;
|
|
25
|
-
metadataTable?: never;
|
|
26
|
-
} | {
|
|
27
|
-
metadataTable?: undefined;
|
|
28
|
-
metadataRpc?: undefined;
|
|
29
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { EnvironmentProviders } from "@angular/core";
|
|
2
|
-
import { SupaStoreOptions } from "./common/type/supa-store.types";
|
|
3
|
-
export declare const provideSupaStore: (options: SupaStoreOptions) => EnvironmentProviders;
|
|
4
|
-
export declare const injectSupaClient: {
|
|
5
|
-
(): import("@ngrx/signals").DeepSignal<import("@supabase/supabase-js").SupabaseClient<any, "public", any>>;
|
|
6
|
-
(injectOptions: import("@angular/core").InjectOptions & {
|
|
7
|
-
optional?: false;
|
|
8
|
-
} & {
|
|
9
|
-
injector?: import("@angular/core").Injector;
|
|
10
|
-
}): import("@ngrx/signals").DeepSignal<import("@supabase/supabase-js").SupabaseClient<any, "public", any>>;
|
|
11
|
-
(injectOptions: import("@angular/core").InjectOptions & {
|
|
12
|
-
injector?: import("@angular/core").Injector;
|
|
13
|
-
}): import("@ngrx/signals").DeepSignal<import("@supabase/supabase-js").SupabaseClient<any, "public", any>> | null;
|
|
14
|
-
};
|
|
15
|
-
export declare const injectSupaAuth: {
|
|
16
|
-
(): import("@ngrx/signals").DeepSignal<{
|
|
17
|
-
session: undefined | null | import("@supabase/auth-js").Session;
|
|
18
|
-
user: undefined | null | import("@supabase/auth-js").User;
|
|
19
|
-
metadata: undefined | null | unknown;
|
|
20
|
-
state: {
|
|
21
|
-
prev: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
22
|
-
curr: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
23
|
-
};
|
|
24
|
-
}>;
|
|
25
|
-
(injectOptions: import("@angular/core").InjectOptions & {
|
|
26
|
-
optional?: false;
|
|
27
|
-
} & {
|
|
28
|
-
injector?: import("@angular/core").Injector;
|
|
29
|
-
}): import("@ngrx/signals").DeepSignal<{
|
|
30
|
-
session: undefined | null | import("@supabase/auth-js").Session;
|
|
31
|
-
user: undefined | null | import("@supabase/auth-js").User;
|
|
32
|
-
metadata: undefined | null | unknown;
|
|
33
|
-
state: {
|
|
34
|
-
prev: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
35
|
-
curr: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
36
|
-
};
|
|
37
|
-
}>;
|
|
38
|
-
(injectOptions: import("@angular/core").InjectOptions & {
|
|
39
|
-
injector?: import("@angular/core").Injector;
|
|
40
|
-
}): import("@ngrx/signals").DeepSignal<{
|
|
41
|
-
session: undefined | null | import("@supabase/auth-js").Session;
|
|
42
|
-
user: undefined | null | import("@supabase/auth-js").User;
|
|
43
|
-
metadata: undefined | null | unknown;
|
|
44
|
-
state: {
|
|
45
|
-
prev: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
46
|
-
curr: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
47
|
-
};
|
|
48
|
-
}> | null;
|
|
49
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare const SupaStore: import("@angular/core").Type<{
|
|
2
|
-
[x: string]: (newName?: unknown) => unknown;
|
|
3
|
-
client: import("@ngrx/signals").DeepSignal<import("@supabase/supabase-js").SupabaseClient<any, "public", any>>;
|
|
4
|
-
auth: import("@ngrx/signals").DeepSignal<{
|
|
5
|
-
session: undefined | null | import("@supabase/auth-js").Session;
|
|
6
|
-
user: undefined | null | import("@supabase/auth-js").User;
|
|
7
|
-
metadata: undefined | null | unknown;
|
|
8
|
-
state: {
|
|
9
|
-
prev: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
10
|
-
curr: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
user$: import("rxjs").Observable<import("@supabase/auth-js").User | null>;
|
|
14
|
-
session$: import("rxjs").Observable<import("@supabase/auth-js").Session | null>;
|
|
15
|
-
metadata$: import("rxjs").Observable<{} | null>;
|
|
16
|
-
signInWithGoogle: (options?: import("@supabase/auth-js").SignInWithOAuthCredentials["options"]) => Promise<void>;
|
|
17
|
-
} & import("@ngrx/signals").StateSource<{
|
|
18
|
-
client: import("@supabase/supabase-js").SupabaseClient;
|
|
19
|
-
auth: {
|
|
20
|
-
session: undefined | null | import("@supabase/auth-js").Session;
|
|
21
|
-
user: undefined | null | import("@supabase/auth-js").User;
|
|
22
|
-
metadata: undefined | null | unknown;
|
|
23
|
-
state: {
|
|
24
|
-
prev: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
25
|
-
curr: import("@supabase/auth-js").AuthChangeEvent | null;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
}>>;
|
package/public-api.d.ts
DELETED