@reactionary/core 0.10.53 → 0.10.54

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.10.53",
3
+ "version": "0.10.54",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -1,8 +1,13 @@
1
1
  import * as z from "zod";
2
- import { ShippingMethodIdentifierSchema } from "./identifiers.model.js";
2
+ import { ShippingMethodIdentifierSchema, StoreIdentifierSchema } from "./identifiers.model.js";
3
3
  import { MonetaryAmountSchema } from "./price.model.js";
4
4
  import { BaseModelSchema, ImageSchema } from "./base.model.js";
5
5
  import { AddressSchema } from "./profile.model.js";
6
+ const ShippingFulfillmentTypeSchema = z.enum(["delivery", "pickup"]);
7
+ const ShippingProtocolDataSchema = z.looseObject({
8
+ key: z.string().meta({ description: 'The protocol-specific key, e.g. "timeSlotId".' }),
9
+ value: z.union([z.string(), z.record(z.string(), z.json())]).meta({ description: "The protocol-specific value: either a plain string, or a JSON-serializable object for richer structures." })
10
+ });
6
11
  const PickupPointSchema = z.looseObject({
7
12
  identifier: z.object({
8
13
  key: z.string()
@@ -22,16 +27,22 @@ const ShippingMethodSchema = z.looseObject({
22
27
  logo: ImageSchema.optional(),
23
28
  price: MonetaryAmountSchema,
24
29
  deliveryTime: z.string(),
25
- carrier: z.string().optional()
30
+ carrier: z.string().optional(),
31
+ fulfillmentType: ShippingFulfillmentTypeSchema.optional().meta({ description: `How this shipping method fulfills the order: "delivery" for shipment to an address (including third-party carrier service points selected via the shipping instruction's pickupPoint), "pickup" for collection at one of the brand's own stores (BOPIS). When absent, "delivery" can be assumed.` }),
32
+ protocolData: z.array(ShippingProtocolDataSchema).optional().meta({ description: "Additional provider-populated, protocol-specific data for this shipping method, e.g. available pickup time slots." })
26
33
  });
27
34
  const ShippingInstructionSchema = BaseModelSchema.extend({
28
35
  shippingMethod: ShippingMethodIdentifierSchema,
29
- pickupPoint: z.string().meta({ description: "An optional pickup point for the shipping method. This could be a physical store, a locker, or similar. If not set, it means home delivery to the shipping address." }),
36
+ pickupPoint: z.string().meta({ description: "An optional third-party carrier service point for the shipping method (e.g. a GLS or PostNord parcel shop, or a locker). Reserved for the carrier-service-point case; for pickup at one of the brand's own stores (BOPIS), use the store field instead. If neither is set, it means home delivery to the shipping address." }),
30
37
  instructions: z.string().meta({ description: "Optional instructions for the shipping. This could be delivery instructions, or similar." }),
31
- consentForUnattendedDelivery: z.boolean().meta({ description: "Indicates if the customer has given consent for unattended delivery, if applicable." })
38
+ consentForUnattendedDelivery: z.boolean().meta({ description: "Indicates if the customer has given consent for unattended delivery, if applicable." }),
39
+ store: StoreIdentifierSchema.optional().meta({ description: "An optional reference to one of the brand's own stores where the order will be picked up (BOPIS). Distinct from pickupPoint, which is reserved for third-party carrier service points." }),
40
+ protocolData: z.array(ShippingProtocolDataSchema).optional().meta({ description: "Additional client-set, protocol-specific data for the shipping instruction, e.g. a selected pickup time slot." })
32
41
  });
33
42
  export {
34
43
  PickupPointSchema,
44
+ ShippingFulfillmentTypeSchema,
35
45
  ShippingInstructionSchema,
36
- ShippingMethodSchema
46
+ ShippingMethodSchema,
47
+ ShippingProtocolDataSchema
37
48
  };
@@ -1,14 +1,19 @@
1
1
  import * as z from "zod";
2
- import { BaseModelSchema } from "./base.model.js";
2
+ import { BaseModelSchema, createPaginatedResponseSchema } from "./base.model.js";
3
3
  import {
4
4
  FulfillmentCenterIdentifierSchema,
5
5
  StoreIdentifierSchema
6
6
  } from "./identifiers.model.js";
7
+ import { AddressSchema } from "./profile.model.js";
7
8
  const StoreSchema = BaseModelSchema.extend({
8
9
  identifier: StoreIdentifierSchema,
9
10
  name: z.string(),
10
- fulfillmentCenter: FulfillmentCenterIdentifierSchema
11
+ fulfillmentCenter: FulfillmentCenterIdentifierSchema,
12
+ address: AddressSchema.optional().meta({ description: "The physical address of the store, if known. Useful for showing the store on a map, and as the shipping address for in-store pickup (BOPIS)." }),
13
+ openingHours: z.string().optional().meta({ description: 'The opening hours of the store, if known. This could be a string like "Mon-Fri 9am-5pm".' })
11
14
  });
15
+ const StorePaginatedResultSchema = createPaginatedResponseSchema(StoreSchema);
12
16
  export {
17
+ StorePaginatedResultSchema,
13
18
  StoreSchema
14
19
  };
@@ -1,11 +1,21 @@
1
1
  import * as z from "zod";
2
2
  import { BaseQuerySchema } from "./base.query.js";
3
+ import { StoreIdentifierSchema } from "../models/identifiers.model.js";
4
+ import { PaginationOptionsSchema } from "../models/base.model.js";
3
5
  const StoreQueryByProximitySchema = BaseQuerySchema.extend({
4
6
  longitude: z.number(),
5
7
  latitude: z.number(),
6
8
  distance: z.number(),
7
9
  limit: z.number()
8
10
  });
11
+ const StoreQueryByIdSchema = BaseQuerySchema.extend({
12
+ identifier: StoreIdentifierSchema
13
+ });
14
+ const StoreQueryForListSchema = BaseQuerySchema.extend({
15
+ paginationOptions: PaginationOptionsSchema
16
+ });
9
17
  export {
10
- StoreQueryByProximitySchema
18
+ StoreQueryByIdSchema,
19
+ StoreQueryByProximitySchema,
20
+ StoreQueryForListSchema
11
21
  };
@@ -1,8 +1,23 @@
1
- import type { Store } from '../schemas/models/store.model.js';
2
- import type { StoreQueryByProximity } from '../schemas/queries/index.js';
1
+ import type { NotFoundError } from '../schemas/errors/not-found.error.js';
2
+ import type { Store, StorePaginatedResult } from '../schemas/models/store.model.js';
3
+ import type { StoreQueryById, StoreQueryByProximity, StoreQueryForList } from '../schemas/queries/index.js';
3
4
  import type { Result } from '../schemas/result.js';
4
5
  import { BaseCapability } from './base.capability.js';
5
- export declare abstract class StoreCapability<TStore extends Store = Store> extends BaseCapability {
6
+ export declare abstract class StoreCapability<TStore extends Store = Store, TStorePaginatedResult extends StorePaginatedResult = StorePaginatedResult> extends BaseCapability {
6
7
  abstract queryByProximity(payload: StoreQueryByProximity): Promise<Result<Array<TStore>>>;
8
+ /**
9
+ * Lists the brand's own stores, paged.
10
+ *
11
+ * Usecase: You are rendering a store picker for in-store pickup (BOPIS), or a store locator page,
12
+ * and geo coordinates are not available.
13
+ */
14
+ abstract list(payload: StoreQueryForList): Promise<Result<TStorePaginatedResult>>;
15
+ /**
16
+ * Gets a single store by its identifier.
17
+ *
18
+ * Usecase: You have a store reference on a shipping instruction (in-store pickup / BOPIS) and
19
+ * need to show the store's name, address and opening hours.
20
+ */
21
+ abstract getById(payload: StoreQueryById): Promise<Result<TStore, NotFoundError>>;
7
22
  protected getResourceName(): string;
8
23
  }
@@ -2684,6 +2684,13 @@ export declare const CheckoutSchema: z.ZodObject<{
2684
2684
  pickupPoint: z.ZodString;
2685
2685
  instructions: z.ZodString;
2686
2686
  consentForUnattendedDelivery: z.ZodBoolean;
2687
+ store: z.ZodOptional<z.ZodObject<{
2688
+ key: z.ZodString;
2689
+ }, z.core.$loose>>;
2690
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
2691
+ key: z.ZodString;
2692
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
2693
+ }, z.core.$loose>>>;
2687
2694
  }, z.core.$loose>>;
2688
2695
  paymentInstructions: z.ZodDefault<z.ZodArray<z.ZodObject<{
2689
2696
  identifier: z.ZodObject<{
@@ -2879,6 +2879,14 @@ export declare const OrderSchema: z.ZodObject<{
2879
2879
  }, z.core.$loose>;
2880
2880
  deliveryTime: z.ZodString;
2881
2881
  carrier: z.ZodOptional<z.ZodString>;
2882
+ fulfillmentType: z.ZodOptional<z.ZodEnum<{
2883
+ delivery: "delivery";
2884
+ pickup: "pickup";
2885
+ }>>;
2886
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
2887
+ key: z.ZodString;
2888
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
2889
+ }, z.core.$loose>>>;
2882
2890
  }, z.core.$loose>>;
2883
2891
  orderStatus: z.ZodEnum<{
2884
2892
  AwaitingPayment: "AwaitingPayment";
@@ -1,5 +1,24 @@
1
1
  import * as z from "zod";
2
2
  import type { InferType } from '../../zod-utils.js';
3
+ /**
4
+ * How a shipping method fulfills the order:
5
+ * - 'delivery': the order is shipped to an address (home delivery, or delivery to a third-party
6
+ * carrier service point selected via the shipping instruction's pickupPoint field).
7
+ * - 'pickup': the order is picked up at one of the brand's own stores (BOPIS - buy online, pickup in store).
8
+ */
9
+ export declare const ShippingFulfillmentTypeSchema: z.ZodEnum<{
10
+ delivery: "delivery";
11
+ pickup: "pickup";
12
+ }>;
13
+ /**
14
+ * A single protocol-specific key/value pair exchanged with the shipping provider.
15
+ * The value is either a plain string or a JSON-serializable object, so richer
16
+ * structures (e.g. a selected time slot) round-trip cleanly.
17
+ */
18
+ export declare const ShippingProtocolDataSchema: z.ZodObject<{
19
+ key: z.ZodString;
20
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
21
+ }, z.core.$loose>;
3
22
  export declare const PickupPointSchema: z.ZodObject<{
4
23
  identifier: z.ZodObject<{
5
24
  key: z.ZodString;
@@ -224,6 +243,14 @@ export declare const ShippingMethodSchema: z.ZodObject<{
224
243
  }, z.core.$loose>;
225
244
  deliveryTime: z.ZodString;
226
245
  carrier: z.ZodOptional<z.ZodString>;
246
+ fulfillmentType: z.ZodOptional<z.ZodEnum<{
247
+ delivery: "delivery";
248
+ pickup: "pickup";
249
+ }>>;
250
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
251
+ key: z.ZodString;
252
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
253
+ }, z.core.$loose>>>;
227
254
  }, z.core.$loose>;
228
255
  export declare const ShippingInstructionSchema: z.ZodObject<{
229
256
  shippingMethod: z.ZodObject<{
@@ -232,7 +259,16 @@ export declare const ShippingInstructionSchema: z.ZodObject<{
232
259
  pickupPoint: z.ZodString;
233
260
  instructions: z.ZodString;
234
261
  consentForUnattendedDelivery: z.ZodBoolean;
262
+ store: z.ZodOptional<z.ZodObject<{
263
+ key: z.ZodString;
264
+ }, z.core.$loose>>;
265
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
266
+ key: z.ZodString;
267
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
268
+ }, z.core.$loose>>>;
235
269
  }, z.core.$loose>;
236
270
  export type ShippingMethod = InferType<typeof ShippingMethodSchema>;
237
271
  export type PickupPoint = InferType<typeof PickupPointSchema>;
238
272
  export type ShippingInstruction = InferType<typeof ShippingInstructionSchema>;
273
+ export type ShippingFulfillmentType = InferType<typeof ShippingFulfillmentTypeSchema>;
274
+ export type ShippingProtocolData = InferType<typeof ShippingProtocolDataSchema>;
@@ -8,5 +8,49 @@ export declare const StoreSchema: z.ZodObject<{
8
8
  fulfillmentCenter: z.ZodObject<{
9
9
  key: z.ZodString;
10
10
  }, z.core.$loose>;
11
+ address: z.ZodOptional<z.ZodObject<{
12
+ identifier: z.ZodDefault<z.ZodObject<{
13
+ nickName: z.ZodString;
14
+ }, z.core.$loose>>;
15
+ firstName: z.ZodString;
16
+ lastName: z.ZodString;
17
+ streetAddress: z.ZodString;
18
+ streetNumber: z.ZodString;
19
+ city: z.ZodString;
20
+ region: z.ZodString;
21
+ postalCode: z.ZodString;
22
+ countryCode: z.ZodString;
23
+ }, z.core.$loose>>;
24
+ openingHours: z.ZodOptional<z.ZodString>;
11
25
  }, z.core.$loose>;
26
+ export declare const StorePaginatedResultSchema: z.ZodObject<{
27
+ pageNumber: z.ZodNumber;
28
+ pageSize: z.ZodNumber;
29
+ totalCount: z.ZodNumber;
30
+ totalPages: z.ZodNumber;
31
+ items: z.ZodArray<z.ZodObject<{
32
+ identifier: z.ZodObject<{
33
+ key: z.ZodString;
34
+ }, z.core.$loose>;
35
+ name: z.ZodString;
36
+ fulfillmentCenter: z.ZodObject<{
37
+ key: z.ZodString;
38
+ }, z.core.$loose>;
39
+ address: z.ZodOptional<z.ZodObject<{
40
+ identifier: z.ZodDefault<z.ZodObject<{
41
+ nickName: z.ZodString;
42
+ }, z.core.$loose>>;
43
+ firstName: z.ZodString;
44
+ lastName: z.ZodString;
45
+ streetAddress: z.ZodString;
46
+ streetNumber: z.ZodString;
47
+ city: z.ZodString;
48
+ region: z.ZodString;
49
+ postalCode: z.ZodString;
50
+ countryCode: z.ZodString;
51
+ }, z.core.$loose>>;
52
+ openingHours: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$loose>>;
54
+ }, z.core.$strip>;
12
55
  export type Store = InferType<typeof StoreSchema>;
56
+ export type StorePaginatedResult = InferType<typeof StorePaginatedResultSchema>;
@@ -2253,6 +2253,14 @@ export declare const AnalyticsMutationSchema: z.ZodDiscriminatedUnion<[z.ZodObje
2253
2253
  }, z.core.$loose>;
2254
2254
  deliveryTime: z.ZodString;
2255
2255
  carrier: z.ZodOptional<z.ZodString>;
2256
+ fulfillmentType: z.ZodOptional<z.ZodEnum<{
2257
+ delivery: "delivery";
2258
+ pickup: "pickup";
2259
+ }>>;
2260
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
2261
+ key: z.ZodString;
2262
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
2263
+ }, z.core.$loose>>>;
2256
2264
  }, z.core.$loose>>;
2257
2265
  orderStatus: z.ZodEnum<{
2258
2266
  AwaitingPayment: "AwaitingPayment";
@@ -2126,6 +2126,14 @@ export declare const AnalyticsMutationPurchaseEventSchema: z.ZodObject<{
2126
2126
  }, z.core.$loose>;
2127
2127
  deliveryTime: z.ZodString;
2128
2128
  carrier: z.ZodOptional<z.ZodString>;
2129
+ fulfillmentType: z.ZodOptional<z.ZodEnum<{
2130
+ delivery: "delivery";
2131
+ pickup: "pickup";
2132
+ }>>;
2133
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
2134
+ key: z.ZodString;
2135
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
2136
+ }, z.core.$loose>>>;
2129
2137
  }, z.core.$loose>>;
2130
2138
  orderStatus: z.ZodEnum<{
2131
2139
  AwaitingPayment: "AwaitingPayment";
@@ -2333,6 +2333,13 @@ export declare const CheckoutMutationSetShippingInstructionSchema: z.ZodObject<{
2333
2333
  pickupPoint: z.ZodString;
2334
2334
  instructions: z.ZodString;
2335
2335
  consentForUnattendedDelivery: z.ZodBoolean;
2336
+ store: z.ZodOptional<z.ZodObject<{
2337
+ key: z.ZodString;
2338
+ }, z.core.$loose>>;
2339
+ protocolData: z.ZodOptional<z.ZodArray<z.ZodObject<{
2340
+ key: z.ZodString;
2341
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
2342
+ }, z.core.$loose>>>;
2336
2343
  }, z.core.$loose>;
2337
2344
  checkout: z.ZodObject<{
2338
2345
  key: z.ZodString;
@@ -6,4 +6,17 @@ export declare const StoreQueryByProximitySchema: z.ZodObject<{
6
6
  distance: z.ZodNumber;
7
7
  limit: z.ZodNumber;
8
8
  }, z.core.$loose>;
9
+ export declare const StoreQueryByIdSchema: z.ZodObject<{
10
+ identifier: z.ZodObject<{
11
+ key: z.ZodString;
12
+ }, z.core.$loose>;
13
+ }, z.core.$loose>;
14
+ export declare const StoreQueryForListSchema: z.ZodObject<{
15
+ paginationOptions: z.ZodObject<{
16
+ pageNumber: z.ZodDefault<z.ZodNumber>;
17
+ pageSize: z.ZodDefault<z.ZodNumber>;
18
+ }, z.core.$loose>;
19
+ }, z.core.$loose>;
9
20
  export type StoreQueryByProximity = InferType<typeof StoreQueryByProximitySchema>;
21
+ export type StoreQueryById = InferType<typeof StoreQueryByIdSchema>;
22
+ export type StoreQueryForList = InferType<typeof StoreQueryForListSchema>;