@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
@@ -15,7 +15,9 @@ function createInitialRequestContext() {
15
15
  },
16
16
  session: {
17
17
  identityContext: {
18
- identifier: { userId: "" },
18
+ identity: {
19
+ type: "Anonymous"
20
+ },
19
21
  lastUpdated: /* @__PURE__ */ new Date(),
20
22
  personalizationKey: crypto.randomUUID()
21
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
@@ -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
- identifier: IdentityIdentifierSchema,
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
- identifier: z.ZodObject<{
193
- userId: z.ZodString;
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
- identifier: z.ZodObject<{
201
- userId: z.ZodString;
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
- identifier: z.ZodObject<{
217
- userId: z.ZodString;
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>;