@rebuy/rebuy 3.67.0 → 3.68.0

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.cjs CHANGED
@@ -140,10 +140,12 @@ __export(src_exports, {
140
140
  HealthResultRequestSchema: () => HealthResultRequestSchema,
141
141
  HealthResultResponseSchema: () => HealthResultResponseSchema,
142
142
  HealthResultSchema: () => HealthResultSchema,
143
+ HealthResultStatusSchema: () => HealthResultStatusSchema,
143
144
  HealthScheduleAcknowledgementSchema: () => HealthScheduleAcknowledgementSchema,
144
145
  HealthScheduleReceiptSchema: () => HealthScheduleReceiptSchema,
145
146
  HealthScheduleSchema: () => HealthScheduleSchema,
146
147
  HealthSchedulingResponseSchema: () => HealthSchedulingResponseSchema,
148
+ HealthStandingStatusSchema: () => HealthStandingStatusSchema,
147
149
  HealthStateSchema: () => HealthStateSchema,
148
150
  HoldSettingSchema: () => HoldSettingSchema,
149
151
  HorizontalAlignment: () => HorizontalAlignment,
@@ -3393,6 +3395,8 @@ var ReleaseAuthorityResponseSchema = import_zod42.z.object({
3393
3395
  });
3394
3396
 
3395
3397
  // src/schema/postPurchaseHealthProgress.ts
3398
+ var HealthResultStatusSchema = import_zod43.z.enum(["returned", "removed", "unresolved", "nonRebuyResidual", "unknown"]);
3399
+ var HealthStandingStatusSchema = import_zod43.z.enum(["pending", "attempted", ...HealthResultStatusSchema.options]);
3396
3400
  var HealthScheduleSchema = import_zod43.z.strictObject({
3397
3401
  checkoutToken: DecideRequestSchema.shape.checkoutToken,
3398
3402
  healthScheduledAt: PostPurchaseTimestampSchema,
@@ -3404,7 +3408,7 @@ var HealthScheduleSchema = import_zod43.z.strictObject({
3404
3408
  });
3405
3409
  var HealthSchedulingResponseSchema = import_zod43.z.object({
3406
3410
  data: import_zod43.z.object({
3407
- callbackStatus: import_zod43.z.enum(["pending", "attempted", "returned", "unknown"]),
3411
+ callbackStatus: HealthStandingStatusSchema,
3408
3412
  facts: HealthScheduleSchema,
3409
3413
  scheduling: import_zod43.z.union([
3410
3414
  import_zod43.z.strictObject({ recordedAt: PostPurchaseTimestampSchema, status: import_zod43.z.literal("verified") }),
@@ -4870,7 +4874,7 @@ var HealthAttemptSchema = StoredHealthFactSchema.extend({
4870
4874
  });
4871
4875
  var HealthResultSchema = HealthAttemptSchema.extend({
4872
4876
  finishedAt: PostPurchaseTimestampSchema,
4873
- status: import_zod76.z.enum(["returned", "unknown"])
4877
+ status: HealthResultStatusSchema
4874
4878
  });
4875
4879
  var HealthStateSchema = import_zod76.z.union([
4876
4880
  StoredHealthFactSchema.extend({ status: import_zod76.z.literal("pending") }),
@@ -4892,7 +4896,7 @@ var HealthClaimFactSchema = HealthClaimRequestSchema.extend({
4892
4896
  var HealthClaimResponseSchema = import_zod76.z.object({
4893
4897
  data: import_zod76.z.union([
4894
4898
  import_zod76.z.strictObject({ status: import_zod76.z.literal("missing") }),
4895
- HealthClaimFactSchema.extend({ status: import_zod76.z.enum(["pending", "attempted", "returned", "unknown"]) }),
4899
+ HealthClaimFactSchema.extend({ status: HealthStandingStatusSchema }),
4896
4900
  HealthClaimFactSchema.extend({ attemptId: HealthAttemptSchema.shape.attemptId, status: import_zod76.z.literal("claimed") })
4897
4901
  ]),
4898
4902
  successful: import_zod76.z.literal(true)
package/dist/index.mjs CHANGED
@@ -2906,6 +2906,8 @@ var ReleaseAuthorityResponseSchema = z42.object({
2906
2906
  });
2907
2907
 
2908
2908
  // src/schema/postPurchaseHealthProgress.ts
2909
+ var HealthResultStatusSchema = z43.enum(["returned", "removed", "unresolved", "nonRebuyResidual", "unknown"]);
2910
+ var HealthStandingStatusSchema = z43.enum(["pending", "attempted", ...HealthResultStatusSchema.options]);
2909
2911
  var HealthScheduleSchema = z43.strictObject({
2910
2912
  checkoutToken: DecideRequestSchema.shape.checkoutToken,
2911
2913
  healthScheduledAt: PostPurchaseTimestampSchema,
@@ -2917,7 +2919,7 @@ var HealthScheduleSchema = z43.strictObject({
2917
2919
  });
2918
2920
  var HealthSchedulingResponseSchema = z43.object({
2919
2921
  data: z43.object({
2920
- callbackStatus: z43.enum(["pending", "attempted", "returned", "unknown"]),
2922
+ callbackStatus: HealthStandingStatusSchema,
2921
2923
  facts: HealthScheduleSchema,
2922
2924
  scheduling: z43.union([
2923
2925
  z43.strictObject({ recordedAt: PostPurchaseTimestampSchema, status: z43.literal("verified") }),
@@ -4383,7 +4385,7 @@ var HealthAttemptSchema = StoredHealthFactSchema.extend({
4383
4385
  });
4384
4386
  var HealthResultSchema = HealthAttemptSchema.extend({
4385
4387
  finishedAt: PostPurchaseTimestampSchema,
4386
- status: z76.enum(["returned", "unknown"])
4388
+ status: HealthResultStatusSchema
4387
4389
  });
4388
4390
  var HealthStateSchema = z76.union([
4389
4391
  StoredHealthFactSchema.extend({ status: z76.literal("pending") }),
@@ -4405,7 +4407,7 @@ var HealthClaimFactSchema = HealthClaimRequestSchema.extend({
4405
4407
  var HealthClaimResponseSchema = z76.object({
4406
4408
  data: z76.union([
4407
4409
  z76.strictObject({ status: z76.literal("missing") }),
4408
- HealthClaimFactSchema.extend({ status: z76.enum(["pending", "attempted", "returned", "unknown"]) }),
4410
+ HealthClaimFactSchema.extend({ status: HealthStandingStatusSchema }),
4409
4411
  HealthClaimFactSchema.extend({ attemptId: HealthAttemptSchema.shape.attemptId, status: z76.literal("claimed") })
4410
4412
  ]),
4411
4413
  successful: z76.literal(true)
@@ -6868,10 +6870,12 @@ export {
6868
6870
  HealthResultRequestSchema,
6869
6871
  HealthResultResponseSchema,
6870
6872
  HealthResultSchema,
6873
+ HealthResultStatusSchema,
6871
6874
  HealthScheduleAcknowledgementSchema,
6872
6875
  HealthScheduleReceiptSchema,
6873
6876
  HealthScheduleSchema,
6874
6877
  HealthSchedulingResponseSchema,
6878
+ HealthStandingStatusSchema,
6875
6879
  HealthStateSchema,
6876
6880
  HoldSettingSchema,
6877
6881
  HorizontalAlignment,
@@ -95,6 +95,9 @@ export declare const SessionFinishResponseSchema: z.ZodObject<{
95
95
  attempted: "attempted";
96
96
  pending: "pending";
97
97
  returned: "returned";
98
+ removed: "removed";
99
+ unresolved: "unresolved";
100
+ nonRebuyResidual: "nonRebuyResidual";
98
101
  }>;
99
102
  facts: z.ZodObject<{
100
103
  checkoutToken: z.ZodString;
@@ -5,6 +5,9 @@ export declare const RequiredHealthSchema: z.ZodUnion<readonly [z.ZodObject<{
5
5
  attempted: "attempted";
6
6
  pending: "pending";
7
7
  returned: "returned";
8
+ removed: "removed";
9
+ unresolved: "unresolved";
10
+ nonRebuyResidual: "nonRebuyResidual";
8
11
  }>;
9
12
  facts: z.ZodObject<{
10
13
  checkoutToken: z.ZodString;
@@ -71,6 +74,9 @@ export declare const AcceptedFollowupsResponseSchema: z.ZodObject<{
71
74
  attempted: "attempted";
72
75
  pending: "pending";
73
76
  returned: "returned";
77
+ removed: "removed";
78
+ unresolved: "unresolved";
79
+ nonRebuyResidual: "nonRebuyResidual";
74
80
  }>;
75
81
  facts: z.ZodObject<{
76
82
  checkoutToken: z.ZodString;
@@ -24,7 +24,10 @@ export declare const HealthAttemptSchema: z.ZodObject<{
24
24
  attemptId: z.ZodUUID;
25
25
  status: z.ZodLiteral<"attempted">;
26
26
  }, z.core.$strict>;
27
- /** A reported check. `unknown` (like a stranded `attempted`) is never retried; it is manual follow-up. */
27
+ /**
28
+ * A reported check (see `HealthResultStatusSchema`). `unknown` (like a stranded `attempted`) is never retried; it is
29
+ * manual follow-up.
30
+ */
28
31
  export declare const HealthResultSchema: z.ZodObject<{
29
32
  removePartialOrder: z.ZodBoolean;
30
33
  operationId: z.ZodUUID;
@@ -40,6 +43,9 @@ export declare const HealthResultSchema: z.ZodObject<{
40
43
  status: z.ZodEnum<{
41
44
  unknown: "unknown";
42
45
  returned: "returned";
46
+ removed: "removed";
47
+ unresolved: "unresolved";
48
+ nonRebuyResidual: "nonRebuyResidual";
43
49
  }>;
44
50
  }, z.core.$strict>;
45
51
  /** `post_purchase_session.health`: NULL (no health required yet) or one of these states. */
@@ -80,6 +86,9 @@ export declare const HealthStateSchema: z.ZodUnion<readonly [z.ZodObject<{
80
86
  status: z.ZodEnum<{
81
87
  unknown: "unknown";
82
88
  returned: "returned";
89
+ removed: "removed";
90
+ unresolved: "unresolved";
91
+ nonRebuyResidual: "nonRebuyResidual";
83
92
  }>;
84
93
  }, z.core.$strict>]>;
85
94
  /**
@@ -130,6 +139,9 @@ export declare const HealthClaimResponseSchema: z.ZodObject<{
130
139
  attempted: "attempted";
131
140
  pending: "pending";
132
141
  returned: "returned";
142
+ removed: "removed";
143
+ unresolved: "unresolved";
144
+ nonRebuyResidual: "nonRebuyResidual";
133
145
  }>;
134
146
  }, z.core.$strict>, z.ZodObject<{
135
147
  orderId: z.ZodString;
@@ -150,6 +162,9 @@ export declare const HealthResultRequestSchema: z.ZodObject<{
150
162
  outcome: z.ZodEnum<{
151
163
  unknown: "unknown";
152
164
  returned: "returned";
165
+ removed: "removed";
166
+ unresolved: "unresolved";
167
+ nonRebuyResidual: "nonRebuyResidual";
153
168
  }>;
154
169
  }, z.core.$strict>;
155
170
  export declare const HealthResultResponseSchema: z.ZodObject<{
@@ -162,6 +177,9 @@ export declare const HealthResultResponseSchema: z.ZodObject<{
162
177
  status: z.ZodEnum<{
163
178
  unknown: "unknown";
164
179
  returned: "returned";
180
+ removed: "removed";
181
+ unresolved: "unresolved";
182
+ nonRebuyResidual: "nonRebuyResidual";
165
183
  }>;
166
184
  }, z.core.$strict>;
167
185
  successful: z.ZodLiteral<true>;
@@ -1,4 +1,28 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * A claimed check's reported outcome (apiv2's `Classification::healthStatus`, REB-25640). A resolver that returned
4
+ * is reported by what it did: `removed` (Shopify accepted the edit removing the unpaid Rebuy lines), `unresolved`
5
+ * (a Rebuy line or charge may be unpaid and was left on the order; the resolver alerted), `nonRebuyResidual` (the
6
+ * outstanding balance is not from a Rebuy edit), or `returned` (nothing to do, or cleanup off). One that threw is
7
+ * `unknown`. Every value is final: `unknown` (like a stranded `attempted`) is manual follow-up, never retried.
8
+ */
9
+ export declare const HealthResultStatusSchema: z.ZodEnum<{
10
+ unknown: "unknown";
11
+ returned: "returned";
12
+ removed: "removed";
13
+ unresolved: "unresolved";
14
+ nonRebuyResidual: "nonRebuyResidual";
15
+ }>;
16
+ /** Every stored `HealthState` status (no `claimed`/`missing`): what a repeated claim or the progress read answers. */
17
+ export declare const HealthStandingStatusSchema: z.ZodEnum<{
18
+ unknown: "unknown";
19
+ attempted: "attempted";
20
+ pending: "pending";
21
+ returned: "returned";
22
+ removed: "removed";
23
+ unresolved: "unresolved";
24
+ nonRebuyResidual: "nonRebuyResidual";
25
+ }>;
2
26
  /**
3
27
  * The body of apiv2's `session-health-schedule` (`SessionHealthSchedule.json`). apiv2 takes a lowercase
4
28
  * `operationId` only, so an uppercase UUID is refused here rather than as apiv2's 400.
@@ -19,6 +43,9 @@ export declare const HealthSchedulingResponseSchema: z.ZodObject<{
19
43
  attempted: "attempted";
20
44
  pending: "pending";
21
45
  returned: "returned";
46
+ removed: "removed";
47
+ unresolved: "unresolved";
48
+ nonRebuyResidual: "nonRebuyResidual";
22
49
  }>;
23
50
  facts: z.ZodObject<{
24
51
  checkoutToken: z.ZodString;
@@ -41,5 +68,6 @@ export declare const HealthSchedulingResponseSchema: z.ZodObject<{
41
68
  }, z.core.$strip>;
42
69
  successful: z.ZodLiteral<true>;
43
70
  }, z.core.$strip>;
71
+ export type HealthResultStatus = z.infer<typeof HealthResultStatusSchema>;
44
72
  export type HealthSchedule = z.infer<typeof HealthScheduleSchema>;
45
73
  export type HealthSchedulingResponse = z.infer<typeof HealthSchedulingResponseSchema>;
@@ -5661,6 +5661,12 @@ function serialize(obj) {
5661
5661
 
5662
5662
  // src/server/dataSourceResults.ts
5663
5663
  var encodeAttributes = (pairs = []) => JSON.stringify(Object.fromEntries(pairs.map(({ key, value }) => [key, value ?? ""])));
5664
+ var MISSING_CUSTOM_ENDPOINT = "Unable to find a custom_endpoint object";
5665
+ var isMissingCustomEndpoint = (err) => {
5666
+ if (err.status !== 400 || !err.body || typeof err.body !== "object") return false;
5667
+ const message = err.body.error;
5668
+ return typeof message === "string" && message.startsWith(MISSING_CUSTOM_ENDPOINT);
5669
+ };
5664
5670
  var buildEngineParams = (input, key) => {
5665
5671
  const { cart, customerId, filterInputs, integrations, limit, productType, shop, visitorId } = input;
5666
5672
  const items = cart.items.map(({ productId: productId2, properties, quantity: quantity3, subscriptionId, variantId }) => ({
@@ -5748,7 +5754,7 @@ var fetchDataSourceResults = async (input, ctx) => {
5748
5754
  try {
5749
5755
  upstream = await ctx.fetchUpstream(path, {}, { host: ctx.host, ...transport });
5750
5756
  } catch (err) {
5751
- if (err instanceof UpstreamError && (err.status === 404 || err.status === 410)) {
5757
+ if (err instanceof UpstreamError && (err.status === 404 || err.status === 410 || isMissingCustomEndpoint(err))) {
5752
5758
  throw new NotFoundError(`Data source not found: ${input.dataSourcePath}`);
5753
5759
  }
5754
5760
  throw err;
@@ -5588,6 +5588,12 @@ function serialize(obj) {
5588
5588
 
5589
5589
  // src/server/dataSourceResults.ts
5590
5590
  var encodeAttributes = (pairs = []) => JSON.stringify(Object.fromEntries(pairs.map(({ key, value }) => [key, value ?? ""])));
5591
+ var MISSING_CUSTOM_ENDPOINT = "Unable to find a custom_endpoint object";
5592
+ var isMissingCustomEndpoint = (err) => {
5593
+ if (err.status !== 400 || !err.body || typeof err.body !== "object") return false;
5594
+ const message = err.body.error;
5595
+ return typeof message === "string" && message.startsWith(MISSING_CUSTOM_ENDPOINT);
5596
+ };
5591
5597
  var buildEngineParams = (input, key) => {
5592
5598
  const { cart, customerId, filterInputs, integrations, limit, productType, shop, visitorId } = input;
5593
5599
  const items = cart.items.map(({ productId: productId2, properties, quantity: quantity3, subscriptionId, variantId }) => ({
@@ -5675,7 +5681,7 @@ var fetchDataSourceResults = async (input, ctx) => {
5675
5681
  try {
5676
5682
  upstream = await ctx.fetchUpstream(path, {}, { host: ctx.host, ...transport });
5677
5683
  } catch (err) {
5678
- if (err instanceof UpstreamError && (err.status === 404 || err.status === 410)) {
5684
+ if (err instanceof UpstreamError && (err.status === 404 || err.status === 410 || isMissingCustomEndpoint(err))) {
5679
5685
  throw new NotFoundError(`Data source not found: ${input.dataSourcePath}`);
5680
5686
  }
5681
5687
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebuy/rebuy",
3
- "version": "3.67.0",
3
+ "version": "3.68.0",
4
4
  "description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
5
5
  "license": "MIT",
6
6
  "author": "Rebuy, Inc.",