@reactionary/feeds 0.12.3 → 0.12.4

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.
Files changed (2) hide show
  1. package/cli.cjs +179 -138
  2. package/package.json +9 -9
package/cli.cjs CHANGED
@@ -37455,92 +37455,6 @@ var init_cart_model = __esm({
37455
37455
  }
37456
37456
  });
37457
37457
 
37458
- // packages/core/src/schemas/models/employee.model.ts
37459
- var EmployeeSchema, EmployeePaginatedListSchema;
37460
- var init_employee_model = __esm({
37461
- "packages/core/src/schemas/models/employee.model.ts"() {
37462
- "use strict";
37463
- init_zod();
37464
- init_base_model();
37465
- init_identifiers_model();
37466
- init_price_model();
37467
- EmployeeSchema = looseObject({
37468
- identifier: IdentityIdentifierSchema,
37469
- company: CompanyIdentifierSchema,
37470
- firstName: string2().optional().meta({ description: "The first name of the employee. This is the human readable name that will be displayed in the UI." }),
37471
- lastName: string2().optional().meta({ description: "The last name of the employee. This is the human readable name that will be displayed in the UI." }),
37472
- email: email2().meta({ description: "The email of the employee. This is the email that the employee uses to log in and access the storefront." }),
37473
- role: EmployeeRoleSchema.meta({ description: "The role of the employee in the company. This can be used to determine what permissions and access the employee has in the storefront." }),
37474
- spendingLimit: MonetaryAmountSchema.optional().meta({ description: "The spending limit for the employee. This can be used to restrict the amount of money the employee can spend when placing orders on behalf of the company." })
37475
- });
37476
- EmployeePaginatedListSchema = createPaginatedResponseSchema(EmployeeSchema).extend({
37477
- identifier: EmployeeSearchIdentifierSchema
37478
- });
37479
- }
37480
- });
37481
-
37482
- // packages/core/src/schemas/models/company.model.ts
37483
- var CompanyStatusSchema, CompanySchema, CompanyPaginatedListSchema;
37484
- var init_company_model = __esm({
37485
- "packages/core/src/schemas/models/company.model.ts"() {
37486
- "use strict";
37487
- init_zod();
37488
- init_identifiers_model();
37489
- init_base_model();
37490
- init_profile_model();
37491
- CompanyStatusSchema = _enum(["active", "blocked"]);
37492
- CompanySchema = looseObject({
37493
- identifier: CompanyIdentifierSchema,
37494
- /**
37495
- * DUN and Bradstreet identifier. Useful for doing automated credit checks
37496
- */
37497
- dunsIdentifier: string2().optional().meta({ description: "The DUNS number of the company. This is a unique identifier for businesses that can be used for credit reporting and other purposes." }),
37498
- /**
37499
- * EU Tax identifier. Useful for reporting and printing
37500
- */
37501
- tinIdentifier: string2().optional().meta({ description: "The TIN (Tax Identification Number) of the company. This is a unique identifier for tax purposes." }),
37502
- name: string2().meta({ description: "The name of the company. This is the human readable name that will be displayed in the UI." }),
37503
- logo: ImageSchema.optional().meta({ description: "The logo of the company. This is the image that will be displayed in the UI to represent the company." }),
37504
- /**
37505
- * future
37506
- parentCompany: CompanyIdentifierSchema.optional(),
37507
- childOrganizationalEntities: z.array(CompanyIdentifierSchema).optional()
37508
- */
37509
- status: CompanyStatusSchema.default("blocked").meta({ description: "The current status of the company in the system. This can be used to determine if the company is active and allowed to perform certain actions, or if it is pending approval or blocked due to violations of terms of service or other issues." }),
37510
- /**
37511
- * The legal contact point for this company. Might not be someone with an actual profile on the site.
37512
- */
37513
- pointOfContact: PointOfContactSchema.meta({ description: "Email and optional phone for the CFO / signatory of the company" }),
37514
- /**
37515
- * Default shipping address if different from default billing address
37516
- */
37517
- shippingAddress: AddressSchema.optional().meta({ description: "The default shipping address for the company. This can be used as the default shipping address for orders placed by this company." }),
37518
- /**
37519
- * The billing address for this company.
37520
- */
37521
- billingAddress: AddressSchema.meta({ description: "The billing address for this company. Not user editable." }),
37522
- /**
37523
- * Other allowed shipping addresses
37524
- */
37525
- alternateShippingAddresses: array(AddressSchema).default(() => []).meta({ description: "Other approved shipping addresses for this company" }),
37526
- /**
37527
- * Various indicators the merchant can use to indicate what the company can self-manage.
37528
- */
37529
- /**
37530
- * Can user type in a different shipping address at checkout?
37531
- */
37532
- isCustomAddressesAllowed: boolean2().default(false).meta({ description: "Whether the company allows using custom shipping addresses that are not in the address book. If false, the user must select from the address book when placing an order." }),
37533
- /**
37534
- * Can admin users manage the address book of the company, adding and removing shipping addresses as needed?
37535
- */
37536
- isSelfManagementOfShippingAddressesAllowed: boolean2().default(false).meta({ description: "Whether the company allows users to manage their own shipping addresses in an address book. If false, the user must contact support to add or update shipping addresses." })
37537
- });
37538
- CompanyPaginatedListSchema = createPaginatedResponseSchema(CompanySchema).extend({
37539
- identifier: CompanySearchIdentifierSchema
37540
- });
37541
- }
37542
- });
37543
-
37544
37458
  // packages/core/src/schemas/models/shipping-method.model.ts
37545
37459
  var ShippingFulfillmentTypeSchema, ShippingProtocolDataSchema, SHIPPING_PROTOCOL_DATA_KEYS, PickupPointSchema, ShippingMethodSchema, ShippingInstructionSchema;
37546
37460
  var init_shipping_method_model = __esm({
@@ -37627,6 +37541,141 @@ var init_payment_model = __esm({
37627
37541
  }
37628
37542
  });
37629
37543
 
37544
+ // packages/core/src/schemas/models/checkout.model.ts
37545
+ var CheckoutItemSchema, CheckoutSchema;
37546
+ var init_checkout_model = __esm({
37547
+ "packages/core/src/schemas/models/checkout.model.ts"() {
37548
+ "use strict";
37549
+ init_zod();
37550
+ init_base_model();
37551
+ init_identifiers_model();
37552
+ init_cost_model();
37553
+ init_profile_model();
37554
+ init_shipping_method_model();
37555
+ init_payment_model();
37556
+ CheckoutItemSchema = looseObject({
37557
+ identifier: CheckoutItemIdentifierSchema.default(() => CheckoutItemIdentifierSchema.parse({})),
37558
+ variant: ProductVariantIdentifierSchema.default(() => ProductVariantIdentifierSchema.parse({})),
37559
+ quantity: number2().default(0),
37560
+ price: ItemCostBreakdownSchema.default(() => ItemCostBreakdownSchema.parse({}))
37561
+ });
37562
+ CheckoutSchema = BaseModelSchema.extend({
37563
+ identifier: CheckoutIdentifierSchema.default(() => CheckoutIdentifierSchema.parse({})),
37564
+ /**
37565
+ * Do we need this?
37566
+ */
37567
+ originalCartReference: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({})),
37568
+ /**
37569
+ * If the checkout has been completed, this will point to the resulting order.
37570
+ */
37571
+ resultingOrder: OrderIdentifierSchema.optional(),
37572
+ items: array(CheckoutItemSchema).default(() => []),
37573
+ price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
37574
+ name: string2().default(""),
37575
+ description: string2().default(""),
37576
+ pointOfContact: PointOfContactSchema,
37577
+ billingAddress: AddressSchema.optional().nullable(),
37578
+ /**
37579
+ * Shipping and billing details can be changed on the checkout, but not items or quantities.
37580
+ */
37581
+ shippingAddress: AddressSchema.optional(),
37582
+ shippingInstruction: ShippingInstructionSchema.optional(),
37583
+ paymentInstructions: array(PaymentInstructionSchema).default(() => []),
37584
+ /**
37585
+ * Indicates if the checkout has all the required information to be finalized into an order.
37586
+ * This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present.
37587
+ */
37588
+ readyForFinalization: boolean2().default(false).meta({ description: "Indicates if the checkout has all the required information to be finalized into an order. This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present." })
37589
+ });
37590
+ }
37591
+ });
37592
+
37593
+ // packages/core/src/schemas/models/employee.model.ts
37594
+ var EmployeeSchema, EmployeePaginatedListSchema;
37595
+ var init_employee_model = __esm({
37596
+ "packages/core/src/schemas/models/employee.model.ts"() {
37597
+ "use strict";
37598
+ init_zod();
37599
+ init_base_model();
37600
+ init_identifiers_model();
37601
+ init_price_model();
37602
+ EmployeeSchema = looseObject({
37603
+ identifier: IdentityIdentifierSchema,
37604
+ company: CompanyIdentifierSchema,
37605
+ firstName: string2().optional().meta({ description: "The first name of the employee. This is the human readable name that will be displayed in the UI." }),
37606
+ lastName: string2().optional().meta({ description: "The last name of the employee. This is the human readable name that will be displayed in the UI." }),
37607
+ email: email2().meta({ description: "The email of the employee. This is the email that the employee uses to log in and access the storefront." }),
37608
+ role: EmployeeRoleSchema.meta({ description: "The role of the employee in the company. This can be used to determine what permissions and access the employee has in the storefront." }),
37609
+ spendingLimit: MonetaryAmountSchema.optional().meta({ description: "The spending limit for the employee. This can be used to restrict the amount of money the employee can spend when placing orders on behalf of the company." })
37610
+ });
37611
+ EmployeePaginatedListSchema = createPaginatedResponseSchema(EmployeeSchema).extend({
37612
+ identifier: EmployeeSearchIdentifierSchema
37613
+ });
37614
+ }
37615
+ });
37616
+
37617
+ // packages/core/src/schemas/models/company.model.ts
37618
+ var CompanyStatusSchema, CompanySchema, CompanyPaginatedListSchema;
37619
+ var init_company_model = __esm({
37620
+ "packages/core/src/schemas/models/company.model.ts"() {
37621
+ "use strict";
37622
+ init_zod();
37623
+ init_identifiers_model();
37624
+ init_base_model();
37625
+ init_profile_model();
37626
+ CompanyStatusSchema = _enum(["active", "blocked"]);
37627
+ CompanySchema = looseObject({
37628
+ identifier: CompanyIdentifierSchema,
37629
+ /**
37630
+ * DUN and Bradstreet identifier. Useful for doing automated credit checks
37631
+ */
37632
+ dunsIdentifier: string2().optional().meta({ description: "The DUNS number of the company. This is a unique identifier for businesses that can be used for credit reporting and other purposes." }),
37633
+ /**
37634
+ * EU Tax identifier. Useful for reporting and printing
37635
+ */
37636
+ tinIdentifier: string2().optional().meta({ description: "The TIN (Tax Identification Number) of the company. This is a unique identifier for tax purposes." }),
37637
+ name: string2().meta({ description: "The name of the company. This is the human readable name that will be displayed in the UI." }),
37638
+ logo: ImageSchema.optional().meta({ description: "The logo of the company. This is the image that will be displayed in the UI to represent the company." }),
37639
+ /**
37640
+ * future
37641
+ parentCompany: CompanyIdentifierSchema.optional(),
37642
+ childOrganizationalEntities: z.array(CompanyIdentifierSchema).optional()
37643
+ */
37644
+ status: CompanyStatusSchema.default("blocked").meta({ description: "The current status of the company in the system. This can be used to determine if the company is active and allowed to perform certain actions, or if it is pending approval or blocked due to violations of terms of service or other issues." }),
37645
+ /**
37646
+ * The legal contact point for this company. Might not be someone with an actual profile on the site.
37647
+ */
37648
+ pointOfContact: PointOfContactSchema.meta({ description: "Email and optional phone for the CFO / signatory of the company" }),
37649
+ /**
37650
+ * Default shipping address if different from default billing address
37651
+ */
37652
+ shippingAddress: AddressSchema.optional().meta({ description: "The default shipping address for the company. This can be used as the default shipping address for orders placed by this company." }),
37653
+ /**
37654
+ * The billing address for this company.
37655
+ */
37656
+ billingAddress: AddressSchema.meta({ description: "The billing address for this company. Not user editable." }),
37657
+ /**
37658
+ * Other allowed shipping addresses
37659
+ */
37660
+ alternateShippingAddresses: array(AddressSchema).default(() => []).meta({ description: "Other approved shipping addresses for this company" }),
37661
+ /**
37662
+ * Various indicators the merchant can use to indicate what the company can self-manage.
37663
+ */
37664
+ /**
37665
+ * Can user type in a different shipping address at checkout?
37666
+ */
37667
+ isCustomAddressesAllowed: boolean2().default(false).meta({ description: "Whether the company allows using custom shipping addresses that are not in the address book. If false, the user must select from the address book when placing an order." }),
37668
+ /**
37669
+ * Can admin users manage the address book of the company, adding and removing shipping addresses as needed?
37670
+ */
37671
+ isSelfManagementOfShippingAddressesAllowed: boolean2().default(false).meta({ description: "Whether the company allows users to manage their own shipping addresses in an address book. If false, the user must contact support to add or update shipping addresses." })
37672
+ });
37673
+ CompanyPaginatedListSchema = createPaginatedResponseSchema(CompanySchema).extend({
37674
+ identifier: CompanySearchIdentifierSchema
37675
+ });
37676
+ }
37677
+ });
37678
+
37630
37679
  // packages/core/src/schemas/models/order.model.ts
37631
37680
  var OrderItemSchema, OrderSchema;
37632
37681
  var init_order_model = __esm({
@@ -37673,6 +37722,7 @@ var init_commerce_mutation = __esm({
37673
37722
  init_zod();
37674
37723
  init_event_parts_model();
37675
37724
  init_cart_model();
37725
+ init_checkout_model();
37676
37726
  init_company_model();
37677
37727
  init_identifiers_model();
37678
37728
  init_order_model();
@@ -37722,7 +37772,8 @@ var init_commerce_mutation = __esm({
37722
37772
  paymentMethod: PaymentMethodSchema
37723
37773
  });
37724
37774
  AnalyticsMutationOrderPlacedSchema = AnalyticsEventMutationBaseSchema.extend({
37725
- order: OrderSchema
37775
+ checkout: CheckoutSchema.optional().meta({ description: "The finalized checkout: what the customer placed. Preferred over order, as the order may not exist yet when the OMS is the order source. Either checkout or order is required." }),
37776
+ order: OrderSchema.optional().meta({ description: "Deprecated: pass the checkout instead. Either checkout or order is required.", deprecated: true })
37726
37777
  });
37727
37778
  AnalyticsMutationQuoteRequestedSchema = AnalyticsEventMutationBaseSchema.extend({
37728
37779
  cart: CartSchema
@@ -38156,55 +38207,6 @@ var init_product_reviews_model = __esm({
38156
38207
  }
38157
38208
  });
38158
38209
 
38159
- // packages/core/src/schemas/models/checkout.model.ts
38160
- var CheckoutItemSchema, CheckoutSchema;
38161
- var init_checkout_model = __esm({
38162
- "packages/core/src/schemas/models/checkout.model.ts"() {
38163
- "use strict";
38164
- init_zod();
38165
- init_base_model();
38166
- init_identifiers_model();
38167
- init_cost_model();
38168
- init_profile_model();
38169
- init_shipping_method_model();
38170
- init_payment_model();
38171
- CheckoutItemSchema = looseObject({
38172
- identifier: CheckoutItemIdentifierSchema.default(() => CheckoutItemIdentifierSchema.parse({})),
38173
- variant: ProductVariantIdentifierSchema.default(() => ProductVariantIdentifierSchema.parse({})),
38174
- quantity: number2().default(0),
38175
- price: ItemCostBreakdownSchema.default(() => ItemCostBreakdownSchema.parse({}))
38176
- });
38177
- CheckoutSchema = BaseModelSchema.extend({
38178
- identifier: CheckoutIdentifierSchema.default(() => CheckoutIdentifierSchema.parse({})),
38179
- /**
38180
- * Do we need this?
38181
- */
38182
- originalCartReference: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({})),
38183
- /**
38184
- * If the checkout has been completed, this will point to the resulting order.
38185
- */
38186
- resultingOrder: OrderIdentifierSchema.optional(),
38187
- items: array(CheckoutItemSchema).default(() => []),
38188
- price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
38189
- name: string2().default(""),
38190
- description: string2().default(""),
38191
- pointOfContact: PointOfContactSchema,
38192
- billingAddress: AddressSchema.optional().nullable(),
38193
- /**
38194
- * Shipping and billing details can be changed on the checkout, but not items or quantities.
38195
- */
38196
- shippingAddress: AddressSchema.optional(),
38197
- shippingInstruction: ShippingInstructionSchema.optional(),
38198
- paymentInstructions: array(PaymentInstructionSchema).default(() => []),
38199
- /**
38200
- * Indicates if the checkout has all the required information to be finalized into an order.
38201
- * This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present.
38202
- */
38203
- readyForFinalization: boolean2().default(false).meta({ description: "Indicates if the checkout has all the required information to be finalized into an order. This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present." })
38204
- });
38205
- }
38206
- });
38207
-
38208
38210
  // packages/core/src/schemas/models/order-search.model.ts
38209
38211
  var OrderSearchResultItemSchema, OrderSearchResultSchema;
38210
38212
  var init_order_search_model = __esm({
@@ -39958,6 +39960,7 @@ var init_analytics_capability = __esm({
39958
39960
  init_legacy_adapter();
39959
39961
  init_reactionary_decorator();
39960
39962
  init_schemas3();
39963
+ init_result();
39961
39964
  init_base_capability();
39962
39965
  AnalyticsCapability = class extends BaseCapability {
39963
39966
  dispatcher;
@@ -40034,6 +40037,9 @@ var init_analytics_capability = __esm({
40034
40037
  return this.dispatcher.emit("payment-info-added", payload);
40035
40038
  }
40036
40039
  async orderPlaced(payload) {
40040
+ if (!payload.checkout && !payload.order) {
40041
+ return error({ type: "Generic", message: "orderPlaced needs a checkout (or the deprecated order)" });
40042
+ }
40037
40043
  return this.dispatcher.emit("order-placed", payload);
40038
40044
  }
40039
40045
  async quoteRequested(payload) {
@@ -41562,6 +41568,25 @@ var init_capabilities = __esm({
41562
41568
  }
41563
41569
  });
41564
41570
 
41571
+ // packages/core/src/analytics/placed-order.ts
41572
+ function summarizePlacedOrder(payload) {
41573
+ const { checkout, order } = payload;
41574
+ const source = checkout ?? order;
41575
+ if (!source) {
41576
+ return void 0;
41577
+ }
41578
+ return {
41579
+ transactionId: order?.identifier.key ?? checkout?.resultingOrder?.key ?? source.identifier.key,
41580
+ items: source.items,
41581
+ price: source.price
41582
+ };
41583
+ }
41584
+ var init_placed_order = __esm({
41585
+ "packages/core/src/analytics/placed-order.ts"() {
41586
+ "use strict";
41587
+ }
41588
+ });
41589
+
41565
41590
  // packages/core/src/analytics/recording-subscriber.ts
41566
41591
  var init_recording_subscriber = __esm({
41567
41592
  "packages/core/src/analytics/recording-subscriber.ts"() {
@@ -41587,6 +41612,7 @@ var init_analytics3 = __esm({
41587
41612
  init_dispatcher();
41588
41613
  init_legacy_adapter();
41589
41614
  init_origins();
41615
+ init_placed_order();
41590
41616
  init_recording_subscriber();
41591
41617
  init_refs();
41592
41618
  }
@@ -72559,8 +72585,12 @@ var init_analytics_capability2 = __esm({
72559
72585
  return "accepted";
72560
72586
  }
72561
72587
  async orderPlaced(event, ctx) {
72588
+ const placed = summarizePlacedOrder(event.payload);
72589
+ if (!placed) {
72590
+ return "ignored";
72591
+ }
72562
72592
  const lines = await Promise.all(
72563
- event.payload.order.items.map(async (item) => {
72593
+ placed.items.map(async (item) => {
72564
72594
  const product = await ctx.products.bySku(item.variant);
72565
72595
  return product.success ? { objectID: product.value.identifier.key, item } : void 0;
72566
72596
  })
@@ -72570,7 +72600,7 @@ var init_analytics_capability2 = __esm({
72570
72600
  return "ignored";
72571
72601
  }
72572
72602
  const search = this.searchFor(event);
72573
- const total = event.payload.order.price.grandTotal;
72603
+ const total = placed.price.grandTotal;
72574
72604
  const common = {
72575
72605
  eventName: "purchase",
72576
72606
  eventType: "conversion",
@@ -116852,6 +116882,17 @@ var init_checkout_capability2 = __esm({
116852
116882
  if (!result.success) {
116853
116883
  throw new Error("Unable to fetch checkout after finalization.");
116854
116884
  }
116885
+ const originalCartId = result.value.originalCartReference?.key;
116886
+ if (originalCartId && originalCartId !== ctId.key) {
116887
+ try {
116888
+ const originalCart = await client.carts.withId({ ID: originalCartId }).get().execute();
116889
+ await client.carts.withId({ ID: originalCartId }).delete({
116890
+ queryArgs: { version: originalCart.body.version, dataErasure: false }
116891
+ }).execute();
116892
+ } catch (e2) {
116893
+ console.error(`Unable to delete original cart ${originalCartId} after finalizing checkout`, e2);
116894
+ }
116895
+ }
116855
116896
  return success(result.value);
116856
116897
  }
116857
116898
  async applyActions(checkout, actions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/feeds",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -12,14 +12,14 @@
12
12
  "url": "git+https://github.com/Solteq/reactionary.git"
13
13
  },
14
14
  "dependencies": {
15
- "@reactionary/algolia": "0.12.3",
16
- "@reactionary/commercetools": "0.12.3",
17
- "@reactionary/core": "0.12.3",
18
- "@reactionary/fake": "0.12.3",
19
- "@reactionary/magento": "0.12.3",
20
- "@reactionary/medusa": "0.12.3",
21
- "@reactionary/meilisearch": "0.12.3",
22
- "@reactionary/unomi": "0.12.3",
15
+ "@reactionary/algolia": "0.12.4",
16
+ "@reactionary/commercetools": "0.12.4",
17
+ "@reactionary/core": "0.12.4",
18
+ "@reactionary/fake": "0.12.4",
19
+ "@reactionary/magento": "0.12.4",
20
+ "@reactionary/medusa": "0.12.4",
21
+ "@reactionary/meilisearch": "0.12.4",
22
+ "@reactionary/unomi": "0.12.4",
23
23
  "commander": "^15.0.0",
24
24
  "dotenv": "^17.2.2",
25
25
  "sitemap": "^9.0.1",