@reactionary/core 0.3.1 → 0.3.2
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/initialization.js
CHANGED
package/package.json
CHANGED
|
@@ -3,6 +3,10 @@ class IdentityProvider extends BaseProvider {
|
|
|
3
3
|
getResourceName() {
|
|
4
4
|
return "identity";
|
|
5
5
|
}
|
|
6
|
+
updateIdentityContext(identity) {
|
|
7
|
+
this.context.session.identityContext.lastUpdated = /* @__PURE__ */ new Date();
|
|
8
|
+
this.context.session.identityContext.identity = identity;
|
|
9
|
+
}
|
|
6
10
|
}
|
|
7
11
|
export {
|
|
8
12
|
IdentityProvider
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { IdentityIdentifierSchema, WebStoreIdentifierSchema } from "./models/identifiers.model.js";
|
|
3
3
|
import { CurrencySchema } from "./models/currency.model.js";
|
|
4
|
+
import { IdentitySchema } from "./models/identity.model.js";
|
|
4
5
|
const LanguageContextSchema = z.looseObject({
|
|
5
6
|
locale: z.string().default("en-US"),
|
|
6
7
|
currencyCode: CurrencySchema.default(() => CurrencySchema.parse({}))
|
|
7
8
|
});
|
|
8
9
|
const IdentityContextSchema = z.looseObject({
|
|
9
|
-
|
|
10
|
+
identity: IdentitySchema,
|
|
10
11
|
personalizationKey: z.string(),
|
|
11
12
|
lastUpdated: z.date()
|
|
12
13
|
});
|
|
@@ -9,4 +9,5 @@ export declare abstract class IdentityProvider extends BaseProvider {
|
|
|
9
9
|
abstract logout(payload: IdentityMutationLogout): Promise<Result<Identity>>;
|
|
10
10
|
abstract register(payload: IdentityMutationRegister): Promise<Result<Identity>>;
|
|
11
11
|
protected getResourceName(): string;
|
|
12
|
+
protected updateIdentityContext(identity: Identity): void;
|
|
12
13
|
}
|
|
@@ -189,17 +189,37 @@ export declare const LanguageContextSchema: z.ZodObject<{
|
|
|
189
189
|
}>>;
|
|
190
190
|
}, z.core.$loose>;
|
|
191
191
|
export declare const IdentityContextSchema: z.ZodObject<{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}, z.core.$loose
|
|
192
|
+
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
193
|
+
type: z.ZodLiteral<"Anonymous">;
|
|
194
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
195
|
+
id: z.ZodObject<{
|
|
196
|
+
userId: z.ZodString;
|
|
197
|
+
}, z.core.$loose>;
|
|
198
|
+
type: z.ZodLiteral<"Guest">;
|
|
199
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
200
|
+
id: z.ZodObject<{
|
|
201
|
+
userId: z.ZodString;
|
|
202
|
+
}, z.core.$loose>;
|
|
203
|
+
type: z.ZodLiteral<"Registered">;
|
|
204
|
+
}, z.core.$loose>], "type">;
|
|
195
205
|
personalizationKey: z.ZodString;
|
|
196
206
|
lastUpdated: z.ZodDate;
|
|
197
207
|
}, z.core.$loose>;
|
|
198
208
|
export declare const SessionSchema: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
|
|
199
209
|
identityContext: z.ZodObject<{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}, z.core.$loose
|
|
210
|
+
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
211
|
+
type: z.ZodLiteral<"Anonymous">;
|
|
212
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
213
|
+
id: z.ZodObject<{
|
|
214
|
+
userId: z.ZodString;
|
|
215
|
+
}, z.core.$loose>;
|
|
216
|
+
type: z.ZodLiteral<"Guest">;
|
|
217
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
218
|
+
id: z.ZodObject<{
|
|
219
|
+
userId: z.ZodString;
|
|
220
|
+
}, z.core.$loose>;
|
|
221
|
+
type: z.ZodLiteral<"Registered">;
|
|
222
|
+
}, z.core.$loose>], "type">;
|
|
203
223
|
personalizationKey: z.ZodString;
|
|
204
224
|
lastUpdated: z.ZodDate;
|
|
205
225
|
}, z.core.$loose>;
|
|
@@ -213,9 +233,19 @@ export declare const TaxJurisdictionSchema: z.ZodObject<{
|
|
|
213
233
|
export declare const RequestContextSchema: z.ZodObject<{
|
|
214
234
|
session: z.ZodDefault<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
|
|
215
235
|
identityContext: z.ZodObject<{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}, z.core.$loose
|
|
236
|
+
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
237
|
+
type: z.ZodLiteral<"Anonymous">;
|
|
238
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
239
|
+
id: z.ZodObject<{
|
|
240
|
+
userId: z.ZodString;
|
|
241
|
+
}, z.core.$loose>;
|
|
242
|
+
type: z.ZodLiteral<"Guest">;
|
|
243
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
244
|
+
id: z.ZodObject<{
|
|
245
|
+
userId: z.ZodString;
|
|
246
|
+
}, z.core.$loose>;
|
|
247
|
+
type: z.ZodLiteral<"Registered">;
|
|
248
|
+
}, z.core.$loose>], "type">;
|
|
219
249
|
personalizationKey: z.ZodString;
|
|
220
250
|
lastUpdated: z.ZodDate;
|
|
221
251
|
}, z.core.$loose>;
|