@geexcode/geex-angular 0.0.24 → 0.0.26

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/dist/index.js CHANGED
@@ -126,7 +126,18 @@ var GQL_ORGS_CACHE = import_graphql_tag.default`query orgsCache { orgs(take: 999
126
126
  var GQL_INIT_SETTINGS = import_graphql_tag.default`query initSettings { initSettings { id name value } }`;
127
127
  function createTenantModule(injector) {
128
128
  const current = (0, import_core.signal)(null);
129
- return {
129
+ const module2 = {
130
+ init: async () => {
131
+ try {
132
+ const tenantCode = injector.get(import_util.CookieService).get("__tenant");
133
+ if (tenantCode) {
134
+ const tenantData = await module2.loadTenantData(tenantCode);
135
+ current.set(tenantData ?? null);
136
+ }
137
+ } catch (err) {
138
+ console.error(err);
139
+ }
140
+ },
130
141
  current,
131
142
  async loadTenantData(code) {
132
143
  const res = await (0, import_rxjs.firstValueFrom)(
@@ -148,6 +159,7 @@ function createTenantModule(injector) {
148
159
  });
149
160
  }
150
161
  };
162
+ return module2;
151
163
  }
152
164
  function createAuthModule(injector) {
153
165
  const user = (0, import_core.signal)(null);
@@ -164,12 +176,12 @@ function createAuthModule(injector) {
164
176
  async loadUserData() {
165
177
  const oAuthService = injector.get(import_angular_oauth2_oidc.OAuthService);
166
178
  try {
167
- if (!oAuthService.hasValidIdToken()) {
179
+ if (!oAuthService.hasValidAccessToken()) {
168
180
  return void 0;
169
181
  }
170
182
  await oAuthService.loadUserProfile();
171
183
  const profile = oAuthService.getIdentityClaims();
172
- if (profile && oAuthService.hasValidAccessToken()) {
184
+ if (profile) {
173
185
  const result = await (0, import_rxjs.firstValueFrom)(injector.get(import_apollo_angular.Apollo).mutate({
174
186
  mutation: GQL_FEDERATE_AUTH,
175
187
  variables: {
@@ -216,6 +228,9 @@ function createIdentityModule(injector) {
216
228
  }
217
229
  function createMessagingModule(injector) {
218
230
  return {
231
+ init: async () => {
232
+ return;
233
+ },
219
234
  onPublicNotify() {
220
235
  const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
221
236
  subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
package/dist/index.mjs CHANGED
@@ -81,7 +81,18 @@ var GQL_ORGS_CACHE = gql`query orgsCache { orgs(take: 999) { items { id orgType
81
81
  var GQL_INIT_SETTINGS = gql`query initSettings { initSettings { id name value } }`;
82
82
  function createTenantModule(injector) {
83
83
  const current = signal(null);
84
- return {
84
+ const module = {
85
+ init: async () => {
86
+ try {
87
+ const tenantCode = injector.get(CookieService).get("__tenant");
88
+ if (tenantCode) {
89
+ const tenantData = await module.loadTenantData(tenantCode);
90
+ current.set(tenantData ?? null);
91
+ }
92
+ } catch (err) {
93
+ console.error(err);
94
+ }
95
+ },
85
96
  current,
86
97
  async loadTenantData(code) {
87
98
  const res = await firstValueFrom(
@@ -103,6 +114,7 @@ function createTenantModule(injector) {
103
114
  });
104
115
  }
105
116
  };
117
+ return module;
106
118
  }
107
119
  function createAuthModule(injector) {
108
120
  const user = signal(null);
@@ -119,12 +131,12 @@ function createAuthModule(injector) {
119
131
  async loadUserData() {
120
132
  const oAuthService = injector.get(OAuthService);
121
133
  try {
122
- if (!oAuthService.hasValidIdToken()) {
134
+ if (!oAuthService.hasValidAccessToken()) {
123
135
  return void 0;
124
136
  }
125
137
  await oAuthService.loadUserProfile();
126
138
  const profile = oAuthService.getIdentityClaims();
127
- if (profile && oAuthService.hasValidAccessToken()) {
139
+ if (profile) {
128
140
  const result = await firstValueFrom(injector.get(Apollo).mutate({
129
141
  mutation: GQL_FEDERATE_AUTH,
130
142
  variables: {
@@ -171,6 +183,9 @@ function createIdentityModule(injector) {
171
183
  }
172
184
  function createMessagingModule(injector) {
173
185
  return {
186
+ init: async () => {
187
+ return;
188
+ },
174
189
  onPublicNotify() {
175
190
  const subClient = injector.get(Apollo).use("subscription");
176
191
  subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geexcode/geex-angular",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "Angular adapter for Geex core.",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.cjs",