shopify-webhook-schemas 0.1.3 → 0.1.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 (155) hide show
  1. package/Readme.md +14 -2
  2. package/dist/src/anonymize-exemplars.d.ts +1 -0
  3. package/dist/src/anonymize-exemplars.js +51 -0
  4. package/dist/src/index.js +2 -2
  5. package/dist/src/scrape.js +501 -182
  6. package/metadatas/2024-07/app_purchases_one_time/update.json +1 -1
  7. package/metadatas/2024-07/app_subscriptions/approaching_capped_amount.json +1 -1
  8. package/metadatas/2024-07/app_subscriptions/update.json +1 -1
  9. package/metadatas/2024-07/bulk_operations/finish.json +2 -2
  10. package/metadatas/2024-07/checkouts/create.json +6 -6
  11. package/metadatas/2024-07/checkouts/update.json +6 -6
  12. package/metadatas/2024-07/draft_orders/create.json +20 -20
  13. package/metadatas/2024-07/draft_orders/update.json +20 -20
  14. package/metadatas/2024-07/orders/edited.json +1 -0
  15. package/metadatas/2024-07/product_listings/add.json +1 -13
  16. package/metadatas/2024-07/product_listings/update.json +1 -13
  17. package/metadatas/2024-07/scheduled_product_listings/add.json +1 -13
  18. package/metadatas/2024-07/scheduled_product_listings/update.json +1 -13
  19. package/metadatas/2024-07/selling_plan_groups/create.json +2 -2
  20. package/metadatas/2024-07/selling_plan_groups/delete.json +2 -2
  21. package/metadatas/2024-07/selling_plan_groups/update.json +2 -2
  22. package/metadatas/2024-07/subscription_billing_attempts/challenged.json +2 -2
  23. package/metadatas/2024-07/subscription_billing_attempts/failure.json +2 -2
  24. package/metadatas/2024-07/subscription_billing_attempts/success.json +2 -2
  25. package/metadatas/2024-07/subscription_billing_cycle_edits/create.json +1 -1
  26. package/metadatas/2024-07/subscription_billing_cycle_edits/delete.json +1 -1
  27. package/metadatas/2024-07/subscription_billing_cycle_edits/update.json +1 -1
  28. package/metadatas/2024-07/subscription_billing_cycles/skip.json +1 -1
  29. package/metadatas/2024-07/subscription_billing_cycles/unskip.json +1 -1
  30. package/metadatas/2024-07/subscription_contracts/activate.json +3 -3
  31. package/metadatas/2024-07/subscription_contracts/cancel.json +3 -3
  32. package/metadatas/2024-07/subscription_contracts/create.json +3 -3
  33. package/metadatas/2024-07/subscription_contracts/expire.json +3 -3
  34. package/metadatas/2024-07/subscription_contracts/fail.json +3 -3
  35. package/metadatas/2024-07/subscription_contracts/pause.json +3 -3
  36. package/metadatas/2024-07/subscription_contracts/update.json +3 -3
  37. package/package.json +9 -1
  38. package/schemas/2023-07/checkouts/create.json +578 -102
  39. package/schemas/2023-07/checkouts/delete.json +26 -4
  40. package/schemas/2023-07/checkouts/update.json +578 -102
  41. package/schemas/2023-07/collection_listings/add.json +9 -2
  42. package/schemas/2023-07/collection_listings/remove.json +7 -0
  43. package/schemas/2023-07/collection_listings/update.json +9 -2
  44. package/schemas/2023-07/company_locations/create.json +8 -2
  45. package/schemas/2023-07/company_locations/delete.json +8 -2
  46. package/schemas/2023-07/company_locations/update.json +8 -2
  47. package/schemas/2023-07/draft_orders/create.json +729 -126
  48. package/schemas/2023-07/draft_orders/update.json +729 -126
  49. package/schemas/2023-07/fulfillments/create.json +149 -30
  50. package/schemas/2023-07/fulfillments/update.json +149 -30
  51. package/schemas/2023-07/order_transactions/create.json +31 -9
  52. package/schemas/2023-07/orders/cancelled.json +966 -48
  53. package/schemas/2023-07/orders/create.json +966 -48
  54. package/schemas/2023-07/orders/fulfilled.json +966 -48
  55. package/schemas/2023-07/orders/paid.json +966 -48
  56. package/schemas/2023-07/orders/partially_fulfilled.json +966 -48
  57. package/schemas/2023-07/orders/updated.json +966 -48
  58. package/schemas/2023-07/products/create.json +191 -17
  59. package/schemas/2023-07/products/update.json +191 -17
  60. package/schemas/2023-10/checkouts/create.json +578 -102
  61. package/schemas/2023-10/checkouts/delete.json +26 -4
  62. package/schemas/2023-10/checkouts/update.json +578 -102
  63. package/schemas/2023-10/collection_listings/add.json +9 -2
  64. package/schemas/2023-10/collection_listings/remove.json +7 -0
  65. package/schemas/2023-10/collection_listings/update.json +9 -2
  66. package/schemas/2023-10/company_locations/create.json +8 -2
  67. package/schemas/2023-10/company_locations/delete.json +8 -2
  68. package/schemas/2023-10/company_locations/update.json +8 -2
  69. package/schemas/2023-10/draft_orders/create.json +729 -126
  70. package/schemas/2023-10/draft_orders/update.json +729 -126
  71. package/schemas/2023-10/fulfillments/create.json +149 -30
  72. package/schemas/2023-10/fulfillments/update.json +149 -30
  73. package/schemas/2023-10/order_transactions/create.json +28 -9
  74. package/schemas/2023-10/orders/cancelled.json +966 -48
  75. package/schemas/2023-10/orders/create.json +966 -48
  76. package/schemas/2023-10/orders/fulfilled.json +966 -48
  77. package/schemas/2023-10/orders/paid.json +966 -48
  78. package/schemas/2023-10/orders/partially_fulfilled.json +966 -48
  79. package/schemas/2023-10/orders/updated.json +966 -48
  80. package/schemas/2023-10/products/create.json +191 -17
  81. package/schemas/2023-10/products/update.json +191 -17
  82. package/schemas/2024-01/checkouts/create.json +585 -100
  83. package/schemas/2024-01/checkouts/delete.json +26 -4
  84. package/schemas/2024-01/checkouts/update.json +585 -100
  85. package/schemas/2024-01/collection_listings/add.json +9 -2
  86. package/schemas/2024-01/collection_listings/remove.json +7 -0
  87. package/schemas/2024-01/collection_listings/update.json +9 -2
  88. package/schemas/2024-01/company_locations/create.json +8 -2
  89. package/schemas/2024-01/company_locations/delete.json +8 -2
  90. package/schemas/2024-01/company_locations/update.json +8 -2
  91. package/schemas/2024-01/draft_orders/create.json +733 -124
  92. package/schemas/2024-01/draft_orders/update.json +733 -124
  93. package/schemas/2024-01/fulfillment_orders/split.json +237 -2
  94. package/schemas/2024-01/fulfillments/create.json +149 -30
  95. package/schemas/2024-01/fulfillments/update.json +149 -30
  96. package/schemas/2024-01/order_transactions/create.json +28 -9
  97. package/schemas/2024-01/orders/cancelled.json +970 -50
  98. package/schemas/2024-01/orders/create.json +970 -50
  99. package/schemas/2024-01/orders/fulfilled.json +970 -50
  100. package/schemas/2024-01/orders/paid.json +970 -50
  101. package/schemas/2024-01/orders/partially_fulfilled.json +970 -50
  102. package/schemas/2024-01/orders/updated.json +970 -50
  103. package/schemas/2024-01/products/create.json +191 -17
  104. package/schemas/2024-01/products/update.json +191 -17
  105. package/schemas/2024-04/checkouts/create.json +585 -100
  106. package/schemas/2024-04/checkouts/delete.json +26 -4
  107. package/schemas/2024-04/checkouts/update.json +585 -100
  108. package/schemas/2024-04/collection_listings/add.json +9 -2
  109. package/schemas/2024-04/collection_listings/remove.json +7 -0
  110. package/schemas/2024-04/collection_listings/update.json +9 -2
  111. package/schemas/2024-04/company_locations/create.json +8 -2
  112. package/schemas/2024-04/company_locations/delete.json +8 -2
  113. package/schemas/2024-04/company_locations/update.json +8 -2
  114. package/schemas/2024-04/draft_orders/create.json +733 -124
  115. package/schemas/2024-04/draft_orders/update.json +733 -124
  116. package/schemas/2024-04/fulfillment_orders/split.json +237 -2
  117. package/schemas/2024-04/fulfillments/create.json +149 -30
  118. package/schemas/2024-04/fulfillments/update.json +149 -30
  119. package/schemas/2024-04/order_transactions/create.json +28 -9
  120. package/schemas/2024-04/orders/cancelled.json +967 -50
  121. package/schemas/2024-04/orders/create.json +967 -50
  122. package/schemas/2024-04/orders/fulfilled.json +967 -50
  123. package/schemas/2024-04/orders/paid.json +967 -50
  124. package/schemas/2024-04/orders/partially_fulfilled.json +967 -50
  125. package/schemas/2024-04/orders/updated.json +967 -50
  126. package/schemas/2024-04/products/create.json +191 -17
  127. package/schemas/2024-04/products/update.json +191 -17
  128. package/schemas/2024-07/checkouts/create.json +585 -100
  129. package/schemas/2024-07/checkouts/delete.json +26 -4
  130. package/schemas/2024-07/checkouts/update.json +585 -100
  131. package/schemas/2024-07/collection_listings/add.json +9 -2
  132. package/schemas/2024-07/collection_listings/remove.json +7 -0
  133. package/schemas/2024-07/collection_listings/update.json +9 -2
  134. package/schemas/2024-07/company_locations/create.json +8 -2
  135. package/schemas/2024-07/company_locations/delete.json +8 -2
  136. package/schemas/2024-07/company_locations/update.json +8 -2
  137. package/schemas/2024-07/draft_orders/create.json +733 -124
  138. package/schemas/2024-07/draft_orders/update.json +733 -124
  139. package/schemas/2024-07/fulfillment_orders/split.json +237 -2
  140. package/schemas/2024-07/fulfillments/create.json +149 -30
  141. package/schemas/2024-07/fulfillments/update.json +149 -30
  142. package/schemas/2024-07/order_transactions/create.json +28 -9
  143. package/schemas/2024-07/orders/cancelled.json +967 -50
  144. package/schemas/2024-07/orders/create.json +967 -50
  145. package/schemas/2024-07/orders/edited.json +5 -0
  146. package/schemas/2024-07/orders/fulfilled.json +967 -50
  147. package/schemas/2024-07/orders/paid.json +967 -50
  148. package/schemas/2024-07/orders/partially_fulfilled.json +967 -50
  149. package/schemas/2024-07/orders/updated.json +967 -50
  150. package/schemas/2024-07/product_listings/add.json +1 -44
  151. package/schemas/2024-07/product_listings/update.json +1 -44
  152. package/schemas/2024-07/products/create.json +191 -17
  153. package/schemas/2024-07/products/update.json +191 -17
  154. package/schemas/2024-07/scheduled_product_listings/add.json +1 -44
  155. package/schemas/2024-07/scheduled_product_listings/update.json +1 -44
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = require("fs");
6
+ const fs_extra_1 = __importDefault(require("fs-extra"));
7
+ const globby_1 = require("globby");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const json_schema_walker_1 = require("@cloudflare/json-schema-walker");
7
10
  const schema_infer_1 = require("@jsonhero/schema-infer");
8
11
  const cheerio_1 = __importDefault(require("cheerio"));
9
12
  const got_1 = __importDefault(require("got"));
@@ -35,49 +38,77 @@ const loadRailsData = async (url) => {
35
38
  };
36
39
  const docsWebhooksPageForVersion = (version) => `https://shopify.dev/docs/api/admin-rest/${version}/resources/webhook#event-topics`;
37
40
  let warnings = 0;
38
- const inferSchemaFromExamplePayload = (examplePayload, metadata) => {
41
+ let errors = 0;
42
+ const inferSchemaFromExamplePayload = async (examplePayload, metadata) => {
39
43
  const inference = (0, schema_infer_1.inferSchema)(examplePayload);
40
44
  // build a copy of the payload and apply overrides based on the webhook name
41
- const overridesPayload = (0, lodash_1.cloneDeep)(examplePayload);
42
- for (const [matcher, override] of overrides) {
45
+ for (const [matcher, override] of manualExamples) {
43
46
  if (matcher.test(metadata.name)) {
44
- for (const [key, value] of Object.entries(override)) {
45
- if (key in overridesPayload && (0, lodash_1.isNull)(overridesPayload[key])) {
46
- overridesPayload[key] = value;
47
- }
48
- }
47
+ const overridesPayload = (0, lodash_1.cloneDeep)(examplePayload);
48
+ const maskedOverride = (0, lodash_1.pick)(override, Object.keys(examplePayload));
49
+ (0, lodash_1.merge)(overridesPayload, maskedOverride);
50
+ inference.infer(overridesPayload);
49
51
  }
50
52
  }
51
- inference.infer(overridesPayload);
52
53
  const schema = {
53
- "$schema": "https://json-schema.org/draft/2020-12/schema",
54
- ...inference.toJSONSchema()
54
+ $schema: "https://json-schema.org/draft/2020-12/schema",
55
+ ...inference.toJSONSchema(),
55
56
  };
56
- for (const [key, value] of Object.entries(schema.properties)) {
57
- if ((0, lodash_1.isEqual)(value, { type: "null" })) {
58
- warnings += 1;
59
- console.log(`schema warning: null value found in example payload for ${metadata.name} at key ${key}`);
57
+ for (const override of overrides) {
58
+ if (override.topics.includes(metadata.name) && (!override.versions || override.versions.includes(startVersion))) {
59
+ for (const [key, schemaOverride] of Object.entries(override.schema)) {
60
+ schema.properties[key] = schemaOverride;
61
+ }
60
62
  }
61
63
  }
64
+ (0, json_schema_walker_1.schemaWalk)(schema, (subschema, path, _parent, parentPath) => {
65
+ if ((0, lodash_1.isEqual)(subschema, { type: "null" })) {
66
+ warnings += 1;
67
+ const fullPath = [...parentPath, ...path].join(".");
68
+ if (unknownPaths.some(([pattern, paths]) => pattern.test(metadata.name) && paths.includes(fullPath))) {
69
+ // we know this path is always null, so don't error
70
+ }
71
+ else {
72
+ errors += 1;
73
+ console.error(`${chalk_1.default.red("schema error")}: null type found in final schema for ${chalk_1.default.blue(metadata.name)} at path ${chalk_1.default.green(fullPath)}`);
74
+ }
75
+ }
76
+ }, () => { }, (0, json_schema_walker_1.getVocabulary)(schema));
62
77
  return schema;
63
78
  };
79
+ const loadExemplars = async () => {
80
+ const files = await (0, globby_1.globby)(path_1.default.join(__dirname, "../exemplars/**/*.json"));
81
+ for (const file of files) {
82
+ const segments = file.split(path_1.default.sep);
83
+ const _filename = segments.pop();
84
+ const topicPattern = new RegExp(`${segments.pop()}.+`);
85
+ const version = segments.pop();
86
+ const exemplar = await fs_extra_1.default.readJSON(file);
87
+ manualExamples.push([topicPattern, exemplar]);
88
+ }
89
+ console.log(`loaded ${files.length} exemplars`);
90
+ };
91
+ const getAllVersions = async () => {
92
+ const rootPage = await loadRailsData(docsWebhooksPageForVersion(startVersion));
93
+ return (0, lodash_1.uniq)([startVersion, ...rootPage.api.selectable_versions]).filter((version) => version != "unstable");
94
+ };
64
95
  const main = async () => {
96
+ await loadExemplars();
65
97
  const rootDir = (0, src_1.getPackageRootDir)();
66
- const rootPage = await loadRailsData(docsWebhooksPageForVersion(startVersion));
67
- const versions = (0, lodash_1.uniq)([startVersion, ...rootPage.api.selectable_versions]).filter((version) => version != "unstable");
98
+ const versions = process.env.VERSION ? [process.env.VERSION] : await getAllVersions();
68
99
  for (const version of versions) {
69
100
  const page = await loadRailsData(docsWebhooksPageForVersion(version));
70
101
  const webhooks = assert(page.api.rest_resource.info["x-description-list"]["items"]);
71
102
  console.log(`Loaded ${webhooks.length} webhooks for version ${version}`);
72
103
  for (const webhook of webhooks) {
73
104
  webhook.response = JSON.parse(webhook.response);
74
- const metadataFile = path_1.default.join(rootDir, 'metadatas', version, webhook.name + ".json");
75
- await fs_1.promises.mkdir(path_1.default.dirname(metadataFile), { recursive: true });
76
- await fs_1.promises.writeFile(metadataFile, JSON.stringify(webhook, null, 2), "utf-8");
77
- const schema = inferSchemaFromExamplePayload(webhook.response, webhook);
78
- const schemaFile = path_1.default.join(rootDir, 'schemas', version, webhook.name + ".json");
79
- await fs_1.promises.mkdir(path_1.default.dirname(schemaFile), { recursive: true });
80
- await fs_1.promises.writeFile(schemaFile, JSON.stringify(schema, null, 2), "utf-8");
105
+ const metadataFile = path_1.default.join(rootDir, "metadatas", version, webhook.name + ".json");
106
+ await fs_extra_1.default.mkdir(path_1.default.dirname(metadataFile), { recursive: true });
107
+ await fs_extra_1.default.writeFile(metadataFile, JSON.stringify(webhook, null, 2), "utf-8");
108
+ const schema = await inferSchemaFromExamplePayload(webhook.response, webhook);
109
+ const schemaFile = path_1.default.join(rootDir, "schemas", version, webhook.name + ".json");
110
+ await fs_extra_1.default.mkdir(path_1.default.dirname(schemaFile), { recursive: true });
111
+ await fs_extra_1.default.writeFile(schemaFile, JSON.stringify(schema, null, 2), "utf-8");
81
112
  }
82
113
  }
83
114
  if (warnings > 0) {
@@ -89,8 +120,57 @@ const main = async () => {
89
120
  }
90
121
  };
91
122
  void main();
92
- const overrides = [
93
- [/.+/, {
123
+ // paths that we can't find any source data for at all, so we don't know what type they should be
124
+ const unknownPaths = [
125
+ [
126
+ /checkouts\/.+/,
127
+ [
128
+ "properties.line_items.items.properties.unit_price_measurement.properties.measured_type",
129
+ "properties.line_items.items.properties.unit_price_measurement.properties.quantity_value",
130
+ "properties.line_items.items.properties.unit_price_measurement.properties.quantity_unit",
131
+ "properties.line_items.items.properties.unit_price_measurement.properties.reference_value",
132
+ "properties.line_items.items.properties.unit_price_measurement.properties.reference_unit",
133
+ "properties.line_items.items.properties.tax_lines.items.properties.reporting_jurisdiction_name",
134
+ "properties.line_items.items.properties.tax_lines.items.properties.reporting_jurisdiction_type",
135
+ "properties.line_items.items.properties.tax_lines.items.properties.reporting_jurisdiction_code",
136
+ "properties.line_items.items.properties.user_id",
137
+ "properties.line_items.items.properties.compare_at_price",
138
+ "properties.gateway",
139
+ "properties.shipping_lines.items.properties.delivery_category",
140
+ "properties.shipping_lines.items.properties.validation_context",
141
+ "properties.shipping_lines.items.properties.requested_fulfillment_service_id",
142
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.identifier",
143
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.reporting_jurisdiction_name",
144
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.tax_api_client_id",
145
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.reporting_exempt_amount",
146
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.jurisdiction_source",
147
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.reporting_jurisdiction_code",
148
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.reporting_jurisdiction_type",
149
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.reporting_taxable_amount",
150
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.jurisdiction_type",
151
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.tax_type",
152
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.jurisdiction_id",
153
+ "properties.shipping_lines.items.properties.tax_lines.items.properties.reporting_non_taxable_amount",
154
+ "properties.shipping_lines.items.properties.custom_tax_lines",
155
+ "properties.shipping_lines.items.properties.estimated_delivery_time_range",
156
+ "properties.line_items.items.properties.tax_lines.items.properties.tax_type",
157
+ "properties.line_items.items.properties.tax_lines.items.properties.identifier",
158
+ "properties.line_items.items.properties.discount_allocations.items.properties.id",
159
+ "properties.line_items.items.properties.discount_allocations.items.properties.created_at",
160
+ ],
161
+ ],
162
+ [
163
+ /collection_listings\/.+/,
164
+ ["properties.collection_listing.properties.default_product_image", "properties.collection_listing.properties.image"],
165
+ ],
166
+ [/domains\/.+/, ["properties.localization.properties.country"]],
167
+ [/orders\/.+/, ["properties.client_details.properties.session_hash"]]
168
+ ];
169
+ // example data we feed the schema infer-er for each topic to allow it to discover real types
170
+ const manualExamples = [
171
+ [
172
+ /.+/,
173
+ {
94
174
  admin_graphql_api_id: "gid://shopify/Something/1234567890",
95
175
  admin_graphql_api_job_id: "gid://shopify/Job/1234567890",
96
176
  created_at: "2021-12-30T19:00:00-05:00",
@@ -99,8 +179,11 @@ const overrides = [
99
179
  latitude: 10.1,
100
180
  longitude: 10.1,
101
181
  location_id: 111111,
102
- }],
103
- [/(app|shop)\/.+/, {
182
+ },
183
+ ],
184
+ [
185
+ /(app|shop)\/.+/,
186
+ {
104
187
  domain: "example.com",
105
188
  source: "example source",
106
189
  myshopify_domain: "example.myshopify.com",
@@ -112,14 +195,23 @@ const overrides = [
112
195
  iana_timezone: "America/New_York",
113
196
  auto_configure_tax_inclusivity: true,
114
197
  county_taxes: true,
115
- }],
116
- [/bulk_operations\/.+/, {
117
- error_code: "SOME_ERROR_ENUM"
118
- }],
119
- [/carts\/.+/, {
120
- note: "some cart note string"
121
- }],
122
- [/(checkouts|orders)\/.+/, {
198
+ },
199
+ ],
200
+ [
201
+ /bulk_operations\/.+/,
202
+ {
203
+ error_code: "SOME_ERROR_ENUM",
204
+ },
205
+ ],
206
+ [
207
+ /carts\/.+/,
208
+ {
209
+ note: "some cart note string",
210
+ },
211
+ ],
212
+ [
213
+ /(checkouts|orders)\/.+/,
214
+ {
123
215
  gateway: "shopify_payments",
124
216
  landing_site: "https://example.com",
125
217
  note: "some order note",
@@ -141,49 +233,49 @@ const overrides = [
141
233
  cart_token: "some_cart_token",
142
234
  checkout_id: 12345,
143
235
  client_details: {
144
- "accept_language": "en-US,en;q=0.9",
145
- "browser_height": 800,
236
+ accept_language: "en-US,en;q=0.9",
237
+ browser_height: 800,
146
238
  },
147
239
  confirmation_number: "some_confirmation_number",
148
240
  current_total_additional_fees_set: {
149
- "shop_money": {
150
- "amount": "0.00",
151
- "currency_code": "USD"
241
+ shop_money: {
242
+ amount: "0.00",
243
+ currency_code: "USD",
244
+ },
245
+ presentment_money: {
246
+ amount: "0.00",
247
+ currency_code: "USD",
152
248
  },
153
- "presentment_money": {
154
- "amount": "0.00",
155
- "currency_code": "USD"
156
- }
157
249
  },
158
250
  current_total_duties_set: {
159
- "shop_money": {
160
- "amount": "0.00",
161
- "currency_code": "USD"
251
+ shop_money: {
252
+ amount: "0.00",
253
+ currency_code: "USD",
254
+ },
255
+ presentment_money: {
256
+ amount: "0.00",
257
+ currency_code: "USD",
162
258
  },
163
- "presentment_money": {
164
- "amount": "0.00",
165
- "currency_code": "USD"
166
- }
167
259
  },
168
260
  original_total_additional_fees_set: {
169
- "shop_money": {
170
- "amount": "0.00",
171
- "currency_code": "USD"
261
+ shop_money: {
262
+ amount: "0.00",
263
+ currency_code: "USD",
264
+ },
265
+ presentment_money: {
266
+ amount: "0.00",
267
+ currency_code: "USD",
172
268
  },
173
- "presentment_money": {
174
- "amount": "0.00",
175
- "currency_code": "USD"
176
- }
177
269
  },
178
270
  original_total_duties_set: {
179
- "shop_money": {
180
- "amount": "0.00",
181
- "currency_code": "USD"
271
+ shop_money: {
272
+ amount: "0.00",
273
+ currency_code: "USD",
274
+ },
275
+ presentment_money: {
276
+ amount: "0.00",
277
+ currency_code: "USD",
182
278
  },
183
- "presentment_money": {
184
- "amount": "0.00",
185
- "currency_code": "USD"
186
- }
187
279
  },
188
280
  checkout_token: "some_checkout_token",
189
281
  landing_site_ref: "https://example.com",
@@ -193,15 +285,127 @@ const overrides = [
193
285
  reference: "some_reference",
194
286
  payment_terms: "some_payment_terms",
195
287
  reservation_token: "some_reservation_token",
196
- }],
197
- [/collections\/.+/, {
288
+ billing_address: {
289
+ address2: "suite 101",
290
+ latitude: 34.1,
291
+ longitude: 34.1,
292
+ },
293
+ shipping_address: {
294
+ address2: "suite 101",
295
+ latitude: 34.1,
296
+ longitude: 34.1,
297
+ },
298
+ customer: {
299
+ created_at: "2024-05-05T02:42:32+08:00",
300
+ marketing_opt_in_level: "single_opt_in",
301
+ note: "some string",
302
+ multipass_identifier: "hello",
303
+ },
304
+ },
305
+ ],
306
+ [
307
+ /checkouts\/.+/,
308
+ {
309
+ line_items: [
310
+ {
311
+ presentment_variant_title: "51 x 76 / Blanc / 1",
312
+ taxable: true,
313
+ variant_price: "69.00",
314
+ presentment_title: "Taie d'oreiller Pure Soie de Mûrier",
315
+ requires_shipping: true,
316
+ unit_price_measurement: {
317
+ measured_type: null,
318
+ quantity_unit: null,
319
+ quantity_value: null,
320
+ reference_unit: null,
321
+ reference_value: null,
322
+ },
323
+ variant_title: "51 x 76 / Blanc / 1",
324
+ title: "Taie d'oreiller Pure Soie de Mûrier",
325
+ gift_card: false,
326
+ destination_location_id: 4042942054746,
327
+ compare_at_price: null,
328
+ key: "e0105d4efb1970501cf831566fa79752",
329
+ line_price: "69.00",
330
+ vendor: "Emily's pillow",
331
+ quantity: 1,
332
+ applied_discounts: [],
333
+ grams: 110,
334
+ properties: [
335
+ {
336
+ name: "_isJust",
337
+ value: "true",
338
+ },
339
+ ],
340
+ tax_lines: [
341
+ {
342
+ reporting_jurisdiction_type: null,
343
+ reporting_non_taxable_amount: "0.00",
344
+ zone: null,
345
+ compare_at: 0.2,
346
+ reporting_taxable_amount: "57.50",
347
+ tax_api_client_id: null,
348
+ jurisdiction_source: "ActiveTax",
349
+ title: "FR TVA",
350
+ identifier: null,
351
+ jurisdiction_type: "COUNTRY",
352
+ reporting_jurisdiction_code: null,
353
+ source: "MerchantActiveTax",
354
+ reporting_exempt_amount: "0.00",
355
+ reporting_jurisdiction_name: null,
356
+ jurisdiction_id: "FR",
357
+ tax_type: null,
358
+ channel_liable: false,
359
+ price: "11.50",
360
+ rate: 0.2,
361
+ position: 1,
362
+ tax_calculation_price: "11.50",
363
+ },
364
+ ],
365
+ sku: "EMIL-TO5176-22WH",
366
+ rank: 0,
367
+ user_id: null,
368
+ product_id: 4610455470216,
369
+ discount_allocations: [],
370
+ origin_location_id: 1743669821576,
371
+ fulfillment_service: "manual",
372
+ variant_id: 32516187029640,
373
+ price: "69.00",
374
+ },
375
+ ],
376
+ },
377
+ ],
378
+ [
379
+ /collections\/.+/,
380
+ {
198
381
  sort_order: "manual",
199
382
  template_suffix: "some_template_suffix",
200
- }],
201
- [/company_locations\/.+/, {
202
- buyer_experience_configuration: { pay_now_only: true }
203
- }],
204
- [/customers\/.+/, {
383
+ },
384
+ ],
385
+ [
386
+ /collection_listings\/.+/,
387
+ {
388
+ collection_listing: {
389
+ updated_at: "2021-12-30T19:00:00-05:00",
390
+ sort_order: 1,
391
+ }
392
+ },
393
+ ],
394
+ [
395
+ /company_locations\/.+/,
396
+ {
397
+ buyer_experience_configuration: { pay_now_only: true },
398
+ billing_address: {
399
+ address2: "suite 101"
400
+ },
401
+ shipping_address: {
402
+ address2: "suite 101"
403
+ },
404
+ },
405
+ ],
406
+ [
407
+ /customers\/.+/,
408
+ {
205
409
  last_order_id: 12345,
206
410
  multipass_identifier: "some_multipass_identifier",
207
411
  last_order_name: "Foobar",
@@ -210,158 +414,273 @@ const overrides = [
210
414
  email_marketing_consent: false,
211
415
  accepts_marketing_updated_at: "2021-12-30T19:00:00-05:00",
212
416
  marketing_opt_in_level: "single_opt_in",
213
- }],
214
- [/customer_account_settings\/.+/, {
417
+ },
418
+ ],
419
+ [
420
+ /customer_account_settings\/.+/,
421
+ {
215
422
  url: "https://example.com",
216
- }],
217
- [/customer.+consent\/.+/, {
423
+ },
424
+ ],
425
+ [
426
+ /customer.+consent\/.+/,
427
+ {
218
428
  phone: "+1 (123) 456 7890",
219
- email_address: "test@test.com"
220
- }],
221
- [/disputes\/.+/, {
429
+ email_address: "test@test.com",
430
+ },
431
+ ],
432
+ [
433
+ /disputes\/.+/,
434
+ {
222
435
  evidence_sent_on: "2021-12-30T19:00:00-05:00",
223
436
  finalized_on: "2021-12-30T19:00:00-05:00",
224
- }],
225
- [/draft_orders\/.+/, {
437
+ },
438
+ ],
439
+ [
440
+ /draft_orders\/.+/,
441
+ {
226
442
  invoice_sent_at: "2021-12-30T19:00:00-05:00",
227
443
  order_id: 12345,
228
- }],
229
- [/fulfillment_events\/.+/, {
444
+ },
445
+ ],
446
+ [
447
+ /fulfillment_events\/.+/,
448
+ {
230
449
  city: "Ottawa",
231
450
  province: "ON",
232
451
  zip: "K1P1J1",
233
452
  address1: "150 Elgin St",
234
453
  estimated_delivery_at: "2021-12-30T19:00:00-05:00",
235
- }],
236
- [/fulfillment_orders\/.+/, {
454
+ },
455
+ ],
456
+ [
457
+ /fulfillment_orders\/.+/,
458
+ {
237
459
  remaining_fulfillment_order: {
238
- "id": 5859333242902,
239
- "shop_id": 20978040854,
240
- "order_id": 4804938989590,
241
- "assigned_location_id": 67794436118,
242
- "request_status": "unsubmitted",
243
- "status": "open",
244
- "supported_actions": [
245
- "request_fulfillment",
246
- "hold",
247
- "move"
248
- ],
249
- "destination": {
250
- "id": 5479404371990,
251
- "address1": "23 Hassall Street",
252
- "address2": "",
253
- "city": "Parramatta",
254
- "company": null,
255
- "country": "Australia",
256
- "email": "",
257
- "first_name": "Tyler",
258
- "last_name": "Kelleher",
259
- "phone": null,
260
- "province": "New South Wales",
261
- "zip": "2150"
460
+ id: 5859333242902,
461
+ shop_id: 20978040854,
462
+ order_id: 4804938989590,
463
+ assigned_location_id: 67794436118,
464
+ request_status: "unsubmitted",
465
+ status: "open",
466
+ supported_actions: ["request_fulfillment", "hold", "move"],
467
+ destination: {
468
+ id: 5479404371990,
469
+ address1: "23 Hassall Street",
470
+ address2: "",
471
+ city: "Parramatta",
472
+ company: null,
473
+ country: "Australia",
474
+ email: "",
475
+ first_name: "Tyler",
476
+ last_name: "Kelleher",
477
+ phone: null,
478
+ province: "New South Wales",
479
+ zip: "2150",
262
480
  },
263
- "line_items": [
481
+ line_items: [
264
482
  {
265
- "id": 12675478814742,
266
- "shop_id": 20978040854,
267
- "fulfillment_order_id": 5859333242902,
268
- "quantity": 1,
269
- "line_item_id": 12553770336278,
270
- "inventory_item_id": 44276125368342,
271
- "fulfillable_quantity": 1,
272
- "variant_id": 42182036422678
273
- }
483
+ id: 12675478814742,
484
+ shop_id: 20978040854,
485
+ fulfillment_order_id: 5859333242902,
486
+ quantity: 1,
487
+ line_item_id: 12553770336278,
488
+ inventory_item_id: 44276125368342,
489
+ fulfillable_quantity: 1,
490
+ variant_id: 42182036422678,
491
+ },
274
492
  ],
275
- "fulfill_at": "2022-10-13T13:00:00-04:00",
276
- "fulfill_by": null,
277
- "international_duties": {
278
- "incoterm": "DAP"
493
+ fulfill_at: "2022-10-13T13:00:00-04:00",
494
+ fulfill_by: null,
495
+ international_duties: {
496
+ incoterm: "DAP",
279
497
  },
280
- "fulfillment_holds": [],
281
- "delivery_method": {
282
- "id": 140816351254,
283
- "method_type": "shipping",
284
- "min_delivery_date_time": null,
285
- "max_delivery_date_time": null
498
+ fulfillment_holds: [],
499
+ delivery_method: {
500
+ id: 140816351254,
501
+ method_type: "shipping",
502
+ min_delivery_date_time: null,
503
+ max_delivery_date_time: null,
286
504
  },
287
- "assigned_location": {
288
- "address1": null,
289
- "address2": null,
290
- "city": null,
291
- "country_code": "CA",
292
- "location_id": 67794436118,
293
- "name": "test-created-via-api-2",
294
- "phone": null,
295
- "province": null,
296
- "zip": null
505
+ assigned_location: {
506
+ address1: null,
507
+ address2: null,
508
+ city: null,
509
+ country_code: "CA",
510
+ location_id: 67794436118,
511
+ name: "test-created-via-api-2",
512
+ phone: null,
513
+ province: null,
514
+ zip: null,
297
515
  },
298
- }
299
- }],
300
- [/fulfillments\/.+/, {
516
+ },
517
+ },
518
+ ],
519
+ [
520
+ /fulfillments\/.+/,
521
+ {
301
522
  service: "manual",
302
523
  shipment_status: "confirmed",
303
524
  origin_address: {
304
- "first_name": "Steve",
305
- "address1": "123 Shipping Street",
306
- "phone": "555-555-SHIP",
307
- "city": "Shippington",
308
- "zip": "40003",
309
- "province": "Kentucky",
310
- "country": "United States",
311
- "last_name": "Shipper",
312
- "address2": null,
313
- "company": "Shipping Company",
314
- "latitude": null,
315
- "longitude": null,
316
- "name": "Steve Shipper",
317
- "country_code": "US",
318
- "province_code": "KY"
319
- }
320
- }],
321
- [/inventory_items\/.+/, {
525
+ first_name: "Steve",
526
+ address1: "123 Shipping Street",
527
+ phone: "555-555-SHIP",
528
+ city: "Shippington",
529
+ zip: "40003",
530
+ province: "Kentucky",
531
+ country: "United States",
532
+ last_name: "Shipper",
533
+ address2: null,
534
+ company: "Shipping Company",
535
+ latitude: null,
536
+ longitude: null,
537
+ name: "Steve Shipper",
538
+ country_code: "US",
539
+ province_code: "KY",
540
+ },
541
+ },
542
+ ],
543
+ [
544
+ /inventory_items\/.+/,
545
+ {
322
546
  cost: 10.11,
323
547
  country_code_of_origin: "CA",
324
548
  province_code_of_origin: "CA",
325
549
  harmonized_system_code: "1234567890",
326
- }],
327
- [/inventory_levels\/.+/, {
550
+ },
551
+ ],
552
+ [
553
+ /inventory_levels\/.+/,
554
+ {
328
555
  available: 10,
329
- }],
330
- [/order_transactions\/.+/, {
556
+ },
557
+ ],
558
+ [
559
+ /order_transactions\/.+/,
560
+ {
331
561
  message: "some message from the gateway",
332
562
  user_id: 12345,
333
563
  parent_id: 12345,
334
564
  processed_at: "2021-12-30T19:00:00-05:00",
335
565
  device_id: "some_device_id",
336
566
  error_code: "SOME_ERROR_ENUM",
337
- }],
338
- [/orders\/risk_assessment.+/, {
567
+ },
568
+ ],
569
+ [
570
+ /orders\/risk_assessment.+/,
571
+ {
339
572
  provider_id: 12345,
340
573
  provider_title: "whatever",
341
- }],
342
- [/products\/.+/, {
574
+ },
575
+ ],
576
+ [
577
+ /products\/.+/,
578
+ {
343
579
  template_suffix: "something",
344
580
  image: "gid://shopify/ProductImage/1234567890",
345
- }],
346
- [/refunds\/.+/, {
581
+ },
582
+ ],
583
+ [
584
+ /refunds\/.+/,
585
+ {
347
586
  return: "unknown",
348
- }],
349
- [/selling_plan_groups\/.+/, {
587
+ },
588
+ ],
589
+ [
590
+ /selling_plan_groups\/.+/,
591
+ {
350
592
  app_id: 12345,
351
593
  description: "some description",
352
- position: 1
353
- }],
354
- [/subscription_billing_attempts\/.+/, {
594
+ position: 1,
595
+ },
596
+ ],
597
+ [
598
+ /subscription_billing_attempts\/.+/,
599
+ {
355
600
  id: 12345,
356
601
  error_message: "some error message",
357
602
  error_code: "some error copde",
358
- }],
359
- [/subscription_billing_cycle.+/, {
603
+ },
604
+ ],
605
+ [
606
+ /subscription_billing_cycle.+/,
607
+ {
360
608
  contract_edit: "some contract edit",
361
- }],
362
- [/tender_transactions\/.+/, {
609
+ },
610
+ ],
611
+ [
612
+ /tender_transactions\/.+/,
613
+ {
363
614
  user_id: 12345,
364
615
  processed_at: "2021-12-30T19:00:00-05:00",
365
616
  payment_details: { something: "true" },
366
- }],
617
+ },
618
+ ],
619
+ ];
620
+ const shippingAddress = {
621
+ type: "object",
622
+ properties: {
623
+ first_name: {
624
+ type: "string",
625
+ },
626
+ address1: {
627
+ type: "string",
628
+ },
629
+ phone: {
630
+ type: "string",
631
+ },
632
+ city: {
633
+ type: "string",
634
+ },
635
+ zip: {
636
+ type: "string",
637
+ },
638
+ province: {
639
+ type: "string",
640
+ },
641
+ country: {
642
+ type: "string",
643
+ },
644
+ last_name: {
645
+ type: "string",
646
+ },
647
+ address2: {
648
+ type: ["string", "null"],
649
+ },
650
+ company: {
651
+ type: ["string", "null"],
652
+ },
653
+ latitude: {
654
+ type: ["number", "null"],
655
+ },
656
+ longitude: {
657
+ type: ["number", "null"],
658
+ },
659
+ name: {
660
+ type: "string",
661
+ },
662
+ country_code: {
663
+ type: "string",
664
+ },
665
+ province_code: {
666
+ type: "string",
667
+ },
668
+ },
669
+ };
670
+ const overrides = [
671
+ {
672
+ topics: ["checkouts/create", "checkouts/update"],
673
+ schema: {
674
+ shipping_address: shippingAddress,
675
+ },
676
+ },
677
+ {
678
+ topics: ["order_transactions/create", "order_transactions/update"],
679
+ schema: {
680
+ receipt: {
681
+ type: "object",
682
+ additionalProperties: true,
683
+ }
684
+ }
685
+ }
367
686
  ];