diff --git a/www/utils/generated/route-examples-output/route-examples.json b/www/utils/generated/route-examples-output/route-examples.json new file mode 100644 index 0000000000..4051f04baa --- /dev/null +++ b/www/utils/generated/route-examples-output/route-examples.json @@ -0,0 +1,683 @@ +{ + "GET /admin/api-keys": { + "js-sdk": "sdk.admin.apiKey.list()\n.then(({ api_keys, count, limit, offset }) => {\n console.log(api_keys)\n})" + }, + "POST /admin/api-keys": { + "js-sdk": "sdk.admin.apiKey.create({\n title: \"Development\",\n type: \"publishable\"\n})\n.then(({ api_key }) => {\n console.log(api_key)\n})" + }, + "POST /admin/api-keys/${id}/revoke": { + "js-sdk": "sdk.admin.apiKey.revoke(\"apk_123\")\n.then(({ api_key }) => {\n console.log(api_key)\n})" + }, + "GET /admin/api-keys/${id}": { + "js-sdk": "sdk.admin.apiKey.retrieve(\"apk_123\")\n.then(({ api_key }) => {\n console.log(api_key)\n})" + }, + "POST /admin/api-keys/${id}": { + "js-sdk": "sdk.admin.apiKey.update(\"apk_123\", {\n title: \"Development\"\n})\n.then(({ api_key }) => {\n console.log(api_key)\n})" + }, + "DELETE /admin/api-keys/${id}": { + "js-sdk": "sdk.admin.apiKey.delete(\"apk_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/api-keys/${id}/sales-channels": { + "js-sdk": "sdk.admin.apiKey.batchSalesChannels(\"apk_123\", {\n add: [\"sc_123\"],\n remove: [\"sc_321\"]\n})\n.then(({ api_key }) => {\n console.log(api_key)\n})" + }, + "GET /admin/campaigns/${id}": { + "js-sdk": "sdk.admin.campaign.retrieve(\"procamp_123\")\n.then(({ campaign }) => {\n console.log(campaign)\n})" + }, + "GET /admin/campaigns": { + "js-sdk": "sdk.admin.campaign.list()\n.then(({ campaigns, count, limit, offset }) => {\n console.log(campaigns)\n})" + }, + "POST /admin/campaigns": { + "js-sdk": "sdk.admin.campaign.create({\n name: \"Summer Campaign\"\n})\n.then(({ campaign }) => {\n console.log(campaign)\n})" + }, + "POST /admin/campaigns/${id}": { + "js-sdk": "sdk.admin.campaign.update(\"procamp_123\", {\n name: \"Summer Campaign\"\n})\n.then(({ campaign }) => {\n console.log(campaign)\n})" + }, + "DELETE /admin/campaigns/${id}": { + "js-sdk": "sdk.admin.campaign.delete(\"procamp_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "GET /admin/claims": { + "js-sdk": "sdk.admin.claim.list()\n.then(({ claims, count, limit, offset }) => {\n console.log(claims)\n})" + }, + "GET /admin/claims/${id}": { + "js-sdk": "sdk.admin.claim.retrieve(\"claim_123\")\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims": { + "js-sdk": "sdk.admin.claim.create({\n type: \"refund\",\n order_id: \"order_123\",\n})\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/cancel": { + "js-sdk": "sdk.admin.claim.cancel(\"claim_123\")\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/claim-items": { + "js-sdk": "sdk.admin.claim.addItems(\"claim_123\", {\n items: [\n {\n id: \"orli_123\",\n quantity: 1\n }\n ]\n})\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/claim-items/${actionid}": { + "js-sdk": "sdk.admin.claim.updateItem(\n \"claim_123\", \n \"ordchact_123\",\n {\n quantity: 1\n }\n )\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "DELETE /admin/claims/${id}/claim-items/${actionid}": { + "js-sdk": "sdk.admin.claim.removeItem(\n \"claim_123\", \n \"ordchact_123\",\n )\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/inbound/items": { + "js-sdk": "sdk.admin.claim.addInboundItems(\n \"claim_123\", \n {\n items: [\n {\n id: \"orli_123\",\n quantity: 1\n }\n ]\n },\n )\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/claims/${id}/inbound/items/${actionid}": { + "js-sdk": "sdk.admin.claim.updateInboundItem(\n \"claim_123\", \n \"ordchact_123\",\n {\n quantity: 1\n },\n )\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "DELETE /admin/claims/${id}/inbound/items/${actionid}": { + "js-sdk": "sdk.admin.claim.removeInboundItem(\n \"claim_123\", \n \"ordchact_123\",\n )\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/claims/${id}/inbound/shipping-method": { + "js-sdk": "sdk.admin.claim.addInboundShipping(\n \"claim_123\", \n {\n shipping_option_id: \"so_123\",\n custom_amount: 10\n },\n )\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/claims/${id}/inbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.claim.updateInboundShipping(\n \"claim_123\", \n \"ordchact_123\",\n {\n custom_amount: 10\n },\n )\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "DELETE /admin/claims/${id}/inbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.claim.deleteInboundShipping(\n \"claim_123\", \n \"ordchact_123\",\n )\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/claims/${id}/outbound/items": { + "js-sdk": "sdk.admin.claim.addOutboundItems(\n \"claim_123\", \n {\n items: [{\n id: \"orli_123\",\n quantity: 1\n }]\n },\n )\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/outbound/items/${actionid}": { + "js-sdk": "sdk.admin.claim.updateOutboundItem(\n \"claim_123\", \n \"ordchact_123\",\n {\n quantity: 1\n },\n )\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "DELETE /admin/claims/${id}/outbound/items/${actionid}": { + "js-sdk": "sdk.admin.claim.removeOutboundItem(\n \"claim_123\", \n \"ordchact_123\",\n)\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/outbound/shipping-method": { + "js-sdk": " * sdk.admin.claim.addOutboundShipping(\n \"claim_123\", \n {\n shipping_option_id: \"so_123\",\n custom_amount: 10\n },\n)\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/outbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.claim.updateOutboundShipping(\n \"claim_123\", \n \"ordchact_123\",\n {\n custom_amount: 10\n },\n)\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "DELETE /admin/claims/${id}/outbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.claim.deleteOutboundShipping(\n \"claim_123\", \n \"ordchact_123\",\n)\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "POST /admin/claims/${id}/request": { + "js-sdk": "sdk.admin.claim.request(\n \"claim_123\", \n {},\n)\n.then(({ claim }) => {\n console.log(claim)\n})" + }, + "DELETE /admin/claims/${id}/request": { + "js-sdk": "sdk.admin.claim.cancelRequest(\n \"claim_123\", \n)\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "GET /admin/currencies": { + "js-sdk": "sdk.admin.currency.list()\n.then(({ currencies, count, limit, offset }) => {\n console.log(currencies)\n})" + }, + "GET /admin/currencies/${code}": { + "js-sdk": "sdk.admin.currency.retrieve(\"usd\")\n.then(({ currency }) => {\n console.log(currency)\n})" + }, + "POST /admin/customers": { + "js-sdk": "sdk.admin.customer.create({\n email: \"customer@gmail.com\"\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "POST /admin/customers/${id}": { + "js-sdk": "sdk.admin.customer.update(\"cus_123\", {\n first_name: \"John\"\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "GET /admin/customers": { + "js-sdk": "sdk.admin.customer.list()\n.then(({ customers, count, limit, offset }) => {\n console.log(customers)\n})" + }, + "GET /admin/customers/${id}": { + "js-sdk": "sdk.admin.customer.retrieve(\"cus_123\")\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "DELETE /admin/customers/${id}": { + "js-sdk": "sdk.admin.customer.delete(\"cus_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/customers/${id}/customer-groups": { + "js-sdk": "sdk.admin.customer.batchCustomerGroups(\"cus_123\", {\n add: [\"cusgroup_123\"],\n remove: [\"cusgroup_321\"]\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "POST /admin/customers/${id}/addresses": { + "js-sdk": "sdk.admin.customer.createAddress(\"cus_123\", {\n address_1: \"123 Main St\",\n city: \"Anytown\",\n country_code: \"US\",\n postal_code: \"12345\"\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "POST /admin/customers/${id}/addresses/${addressid}": { + "js-sdk": "sdk.admin.customer.updateAddress(\"cus_123\", \"cus_addr_123\", {\n address_1: \"123 Main St\",\n city: \"Anytown\",\n country_code: \"US\",\n postal_code: \"12345\"\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "DELETE /admin/customers/${id}/addresses/${addressid}": { + "js-sdk": "sdk.admin.customer.deleteAddress(\"cus_123\", \"cus_addr_123\")\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "GET /admin/customers/${id}/addresses/${addressid}": { + "js-sdk": "sdk.admin.customer.retrieveAddress(\"cus_123\", \"cus_addr_123\")\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "GET /admin/customers/${id}/addresses": { + "js-sdk": "sdk.admin.customer.listAddresses(\"cus_123\")\n.then(({ addresses }) => {\n console.log(addresses)\n})" + }, + "GET /admin/customer-groups/${id}": { + "js-sdk": "sdk.admin.customerGroup.retrieve(\"cusgroup_123\")\n.then(({ customer_group }) => {\n console.log(customer_group)\n})" + }, + "GET /admin/customer-groups": { + "js-sdk": "sdk.admin.customerGroup.list()\n.then(({ customer_groups, count, limit, offset }) => {\n console.log(customer_groups)\n})" + }, + "POST /admin/customer-groups": { + "js-sdk": "sdk.admin.customerGroup.create({\n name: \"VIP\"\n})\n.then(({ customer_group }) => {\n console.log(customer_group)\n})" + }, + "POST /admin/customer-groups/${id}": { + "js-sdk": "sdk.admin.customerGroup.update(\"cusgroup_123\", {\n name: \"VIP\"\n})\n.then(({ customer_group }) => {\n console.log(customer_group)\n})" + }, + "DELETE /admin/customer-groups/${id}": { + "js-sdk": "sdk.admin.customerGroup.delete(\"cusgroup_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/customer-groups/${id}/customers": { + "js-sdk": "sdk.admin.customerGroup.batchCustomers(\"cusgroup_123\", {\n add: [\"cus_123\"],\n remove: [\"cus_321\"]\n})\n.then(({ customer_group }) => {\n console.log(customer_group)\n})" + }, + "GET /admin/draft-orders/${id}": { + "js-sdk": "sdk.admin.draftOrder.retrieve(\"draft_order_123\")\n.then(({ draft_order }) => {\n console.log(draft_order)\n})" + }, + "GET /admin/draft-orders": { + "js-sdk": "sdk.admin.draftOrder.list()\n.then(({ draft_orders, count, limit, offset }) => {\n console.log(draft_orders)\n})" + }, + "POST /admin/draft-orders": { + "js-sdk": "sdk.admin.draftOrder.create({\n email: \"test@test.com\",\n items: [\n {\n variant_id: \"variant_123\",\n quantity: 1,\n },\n ],\n region_id: \"region_123\",\n sales_channel_id: \"sales_channel_123\",\n})\n.then(({ draft_order }) => {\n console.log(draft_order)\n})" + }, + "POST /admin/draft-orders/${id}": { + "js-sdk": "sdk.admin.draftOrder.update(\"draft_order_123\", {\n email: \"test@test.com\",\n})\n.then(({ draft_order }) => {\n console.log(draft_order)\n})" + }, + "GET /admin/exchanges": { + "js-sdk": "sdk.admin.exchange.list()\n.then(({ exchanges, count, limit, offset }) => {\n console.log(exchanges)\n})" + }, + "GET /admin/exchanges/${id}": { + "js-sdk": "sdk.admin.exchange.retrieve(\"exchange_123\")\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges": { + "js-sdk": "sdk.admin.exchange.create({\n order_id: \"order_123\"\n})\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges/${id}/cancel": { + "js-sdk": "sdk.admin.exchange.cancel(\"exchange_123\")\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges/${id}/inbound/items": { + "js-sdk": "sdk.admin.exchange.addInboundItems(\"exchange_123\", {\n items: [{\n id: \"orli_123\",\n quantity: 1\n }]\n})\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/exchanges/${id}/inbound/items/${actionid}": { + "js-sdk": "sdk.admin.exchange.updateInboundItem(\n \"exchange_123\", \n \"ordchact_123\",\n {\n quantity: 1\n }\n)\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "DELETE /admin/exchanges/${id}/inbound/items/${actionid}": { + "js-sdk": "sdk.admin.exchange.removeInboundItem(\n \"exchange_123\", \n \"ordchact_123\",\n)\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/exchanges/${id}/inbound/shipping-method": { + "js-sdk": "sdk.admin.exchange.addInboundShipping(\"exchange_123\", {\n shipping_option_id: \"so_123\"\n})\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/exchanges/${id}/inbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.exchange.updateInboundShipping(\n \"exchange_123\",\n \"ordchact_123\",\n {\n custom_amount: 10\n }\n)\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "DELETE /admin/exchanges/${id}/inbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.exchange.deleteInboundShipping(\n \"exchange_123\",\n \"ordchact_123\",\n)\n.then(({ return: returnData }) => {\n console.log(returnData)\n})" + }, + "POST /admin/exchanges/${id}/outbound/items": { + "js-sdk": "sdk.admin.exchange.addOutboundItems(\"exchange_123\", {\n items: [{\n id: \"variant_123\",\n quantity: 1\n }]\n})\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges/${id}/outbound/items/${actionid}": { + "js-sdk": "sdk.admin.exchange.updateOutboundItem(\n \"exchange_123\",\n \"ordchact_123\",\n {\n quantity: 1\n }\n)\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "DELETE /admin/exchanges/${id}/outbound/items/${actionid}": { + "js-sdk": "sdk.admin.exchange.removeOutboundItem(\n \"exchange_123\",\n \"ordchact_123\",\n)\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges/${id}/outbound/shipping-method": { + "js-sdk": "sdk.admin.exchange.addOutboundShipping(\"exchange_123\", {\n shipping_option_id: \"so_123\"\n})\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges/${id}/outbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.exchange.updateOutboundShipping(\n \"exchange_123\",\n \"ordchact_123\",\n {\n custom_amount: 10\n }\n)\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "DELETE /admin/exchanges/${id}/outbound/shipping-method/${actionid}": { + "js-sdk": "sdk.admin.exchange.deleteOutboundShipping(\n \"exchange_123\",\n \"ordchact_123\",\n)\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "POST /admin/exchanges/${id}/request": { + "js-sdk": "sdk.admin.exchange.request(\"exchange_123\", {})\n.then(({ exchange }) => {\n console.log(exchange)\n})" + }, + "DELETE /admin/exchanges/${id}/request": { + "js-sdk": "sdk.admin.exchange.cancel(\"exchange_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/fulfillments": { + "js-sdk": "sdk.admin.fulfillment.create({\n location_id: \"sloc_123\",\n provider_id: \"my_fulfillment\",\n delivery_address: {\n country_code: \"us\"\n },\n items: [\n {\n title: \"Shirt\",\n sku: \"SHIRT\",\n quantity: 1,\n barcode: \"123\"\n }\n ],\n labels: [],\n order: {},\n order_id: \"order_123\"\n})\n.then(({ fulfillment }) => {\n console.log(fulfillment)\n})" + }, + "POST /admin/fulfillments/${id}": { + "js-sdk": "sdk.admin.fulfillment.cancel(\"ful_123\")\n.then(({ fulfillment }) => {\n console.log(fulfillment)\n})" + }, + "POST /admin/fulfillments/${id}/shipment": { + "js-sdk": "sdk.admin.fulfillment.createShipment(\"ful_123\", {\n labels: [\n {\n tracking_number: \"123\",\n tracking_url: \"example.com\",\n label_url: \"example.com\"\n }\n ]\n})\n.then(({ fulfillment }) => {\n console.log(fulfillment)\n})" + }, + "GET /admin/fulfillment-providers": { + "js-sdk": "sdk.admin.fulfillmentProvider.list()\n.then(({ fulfillment_providers, count, limit, offset }) => {\n console.log(fulfillment_providers)\n})" + }, + "DELETE /admin/fulfillment-sets/${id}": { + "js-sdk": "sdk.admin.fulfillmentSet.delete(\"fset_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/fulfillment-sets/${id}/service-zones": { + "js-sdk": "sdk.admin.fulfillmentSet.createServiceZone(\"fset_123\", {\n name: \"Europe Service Zone\",\n geo_zones: [{\n type: \"country\",\n country_code: \"us\"\n }]\n})\n.then(({ fulfillment_set }) => {\n console.log(fulfillment_set)\n})" + }, + "GET /admin/fulfillment-sets/${fulfillmentsetid}/service-zones/${servicezoneid}": { + "js-sdk": "sdk.admin.fulfillmentSet.retrieveServiceZone(\n \"fset_123\",\n \"serzo_123\"\n)\n.then(({ service_zone }) => {\n console.log(service_zone)\n})" + }, + "POST /admin/fulfillment-sets/${fulfillmentsetid}/service-zones/${servicezoneid}": { + "js-sdk": "sdk.admin.fulfillmentSet.updateServiceZone(\n \"fset_123\", \n \"serzo_123\",\n {\n name: \"Europe Service Zone\",\n }\n)\n.then(({ fulfillment_set }) => {\n console.log(fulfillment_set)\n})" + }, + "DELETE /admin/fulfillment-sets/${fulfillmentsetid}/service-zones/${servicezoneid}": { + "js-sdk": "sdk.admin.fulfillmentSet.deleteServiceZone(\n \"fset_123\", \n \"serzo_123\",\n)\n.then(({ deleted, parent: fulfillmentSet }) => {\n console.log(deleted, fulfillmentSet)\n})" + }, + "POST /admin/inventory-items": { + "js-sdk": "sdk.admin.inventoryItem.create({\n sku: \"SHIRT\"\n})\n.then(({ inventory_item }) => {\n console.log(inventory_item)\n})" + }, + "POST /admin/inventory-items/${id}": { + "js-sdk": "sdk.admin.inventoryItem.update(\"iitem_123\", {\n sku: \"SHIRT\"\n})\n.then(({ inventory_item }) => {\n console.log(inventory_item)\n})" + }, + "GET /admin/inventory-items": { + "js-sdk": "sdk.admin.inventoryItem.list()\n.then(({ inventory_items, count, limit, offset }) => {\n console.log(inventory_items)\n})" + }, + "GET /admin/inventory-items/${id}": { + "js-sdk": "sdk.admin.inventoryItem.retrieve(\"iitem_123\")\n.then(({ inventory_item }) => {\n console.log(inventory_item)\n})" + }, + "DELETE /admin/inventory-items/${id}": { + "js-sdk": "sdk.admin.inventoryItem.delete(\"iitem_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "GET /admin/inventory-items/${id}/location-levels": { + "js-sdk": "sdk.admin.inventoryItem.listLevels(\"iitem_123\")\n.then(({ inventory_levels, count, limit, offset }) => {\n console.log(inventory_levels)\n})" + }, + "POST /admin/inventory-items/${id}/location-levels/${locationid}": { + "js-sdk": "sdk.admin.inventoryItem.updateLevel(\n \"iitem_123\",\n \"sloc_123\",\n {\n stocked_quantity: 10\n }\n)\n.then(({ inventory_item }) => {\n console.log(inventory_item)\n})" + }, + "DELETE /admin/inventory-items/${id}/location-levels/${locationid}": { + "js-sdk": "sdk.admin.inventoryItem.deleteLevel(\n \"iitem_123\",\n \"sloc_123\",\n)\n.then(({ deleted, parent: inventoryItem }) => {\n console.log(deleted, inventoryItem)\n})" + }, + "POST /admin/inventory-items/${id}/location-levels/batch": { + "js-sdk": "sdk.admin.inventoryItem.batchInventoryItemLocationLevels(\"iitem_123\", {\n create: [{\n location_id: \"sloc_123\",\n stocked_quantity: 10\n }],\n delete: [\"ilvl_123\"]\n})\n.then(({ created, updated, deleted }) => {\n console.log(created, updated, deleted)\n})" + }, + "POST /admin/inventory-items/location-levels/batch": { + "js-sdk": "sdk.admin.inventoryItem.batchInventoryItemsLocationLevels({\n create: [{\n inventory_item_id: \"iitem_123\",\n location_id: \"sloc_123\",\n stocked_quantity: 10\n }],\n delete: [\"ilvl_123\"]\n})\n.then(({ created, updated, deleted }) => {\n console.log(created, updated, deleted)\n})" + }, + "POST /admin/invites/accept?token=${input.invite_token}": { + "js-sdk": "const token = await sdk.auth.register(\"user\", \"emailpass\", {\n email: \"user@gmail.com\",\n password: \"supersecret\"\n})\n\nsdk.admin.invite.accept(\n {\n email: \"user@gmail.com\",\n first_name: \"John\",\n last_name: \"Smith\",\n invite_token: \"12345...\"\n },\n {\n Authorization: `Bearer ${token}`\n }\n)\n.then(({ user }) => {\n console.log(user)\n})" + }, + "POST /admin/invites": { + "js-sdk": "sdk.admin.invite.create({\n email: \"user@gmail.com\",\n})\n.then(({ invite }) => {\n console.log(invite)\n})" + }, + "GET /admin/invites/${id}": { + "js-sdk": "sdk.admin.invite.retrieve(\"invite_123\")\n.then(({ invite }) => {\n console.log(invite)\n})" + }, + "GET /admin/invites": { + "js-sdk": "sdk.admin.invite.list()\n.then(({ invites, count, limit, offset }) => {\n console.log(invites)\n})" + }, + "POST /admin/invites/${id}/resend": { + "js-sdk": "sdk.admin.invite.resend(\"invite_123\")\n.then(({ invite }) => {\n console.log(invite)\n})" + }, + "DELETE /admin/invites/${id}": { + "js-sdk": "sdk.admin.invite.delete(\"invite_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "GET /admin/notifications/${id}": { + "js-sdk": "sdk.admin.notification.retrieve(\"notif_123\")\n.then(({ notification }) => {\n console.log(notification)\n})" + }, + "GET /admin/notifications": { + "js-sdk": "sdk.admin.notification.list()\n.then(({ notifications, count, limit, offset }) => {\n console.log(notifications)\n})" + }, + "GET /admin/orders/${id}": { + "js-sdk": "sdk.admin.order.retrieve(\"order_123\")\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}": { + "js-sdk": "sdk.admin.order.update(\n \"order_123\",\n {\n email: \"new_email@example.com\",\n shipping_address: {\n first_name: \"John\",\n last_name: \"Doe\",\n address_1: \"123 Main St\",\n }\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "GET /admin/orders/${id}/preview": { + "js-sdk": "sdk.admin.order.retrievePreview(\"order_123\")\n.then(({ order }) => {\n console.log(order)\n})" + }, + "GET /admin/orders": { + "js-sdk": "sdk.admin.order.list()\n.then(({ orders, count, limit, offset }) => {\n console.log(orders)\n})" + }, + "POST /admin/orders/${id}/cancel": { + "js-sdk": "sdk.admin.order.cancel(\"order_123\")\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}/transfer": { + "js-sdk": "sdk.admin.order.requestTransfer(\"order_123\", {\n customer_id: \"cus_123\",\n internal_note: \"Internal note\",\n})\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}/transfer/cancel": { + "js-sdk": "sdk.admin.order.cancelTransfer(\"order_123\")\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}/fulfillments": { + "js-sdk": "sdk.admin.order.createFulfillment(\"order_123\", {\n items: [\n {\n id: \"orli_123\",\n quantity: 1\n }\n ]\n})\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}/fulfillments/${fulfillmentid}/cancel": { + "js-sdk": "sdk.admin.order.cancelFulfillment(\n \"order_123\",\n \"ful_123\",\n {\n no_notification: false\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}/fulfillments/${fulfillmentid}/shipments": { + "js-sdk": "sdk.admin.order.createShipment(\n \"order_123\",\n \"ful_123\",\n {\n items: [\n {\n id: \"fulit_123\",\n quantity: 1\n }\n ]\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /admin/orders/${id}/fulfillments/${fulfillmentid}/mark-as-delivered": { + "js-sdk": "sdk.admin.order.markAsDelivered(\n \"order_123\",\n \"ful_123\",\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "GET /admin/orders/${id}/changes": { + "js-sdk": "sdk.admin.order.listChanges(\"order_123\")\n.then(({ order_changes }) => {\n console.log(order_changes)\n})" + }, + "GET /admin/orders/${id}/line-items": { + "js-sdk": "sdk.admin.order.listLineItems(\"order_123\")\n.then(({ order_items }) => {\n console.log(order_items)\n})" + }, + "POST /admin/order-edits": { + "js-sdk": "sdk.admin.orderEdit.initiateRequest({\n order_id: \"order_123\"\n})\n.then(({ order_change }) => {\n console.log(order_change)\n})" + }, + "POST /admin/order-edits/${id}/request": { + "js-sdk": "sdk.admin.orderEdit.request(\"ordch_123\")\n.then(({ order_preview }) => {\n console.log(order_preview)\n})" + }, + "POST /admin/order-edits/${id}/confirm": { + "js-sdk": "sdk.admin.orderEdit.confirm(\"ordch_123\")\n.then(({ order_preview }) => {\n console.log(order_preview)\n})" + }, + "DELETE /admin/order-edits/${id}": { + "js-sdk": "sdk.admin.orderEdit.cancelRequest(\"ordch_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/order-edits/${id}/items": { + "js-sdk": "sdk.admin.orderEdit.addItems(\"ordch_123\", {\n items: [\n {\n variant_id: \"variant_123\",\n quantity: 1\n }\n ]\n})\n.then(({ order_preview }) => {\n console.log(order_preview)\n})" + }, + "POST /admin/order-edits/${id}/items/item/${itemid}": { + "js-sdk": "sdk.admin.orderEdit.updateOriginalItem(\n \"ordch_123\", \n \"orli_123\",\n {\n quantity: 1\n }\n)\n.then(({ order_preview }) => {\n console.log(order_preview)\n})" + }, + "POST /admin/order-edits/${id}/items/${actionid}": { + "js-sdk": "sdk.admin.orderEdit.updateAddedItem(\n \"ordch_123\", \n \"orli_123\",\n {\n quantity: 1\n }\n)\n.then(({ order_preview }) => {\n console.log(order_preview)\n})" + }, + "DELETE /admin/order-edits/${id}/items/${actionid}": { + "js-sdk": "sdk.admin.orderEdit.removeAddedItem(\n \"ordch_123\", \n \"orli_123\",\n)\n.then(({ order_preview }) => {\n console.log(order_preview)\n})" + }, + "GET /admin/payments": { + "js-sdk": "sdk.admin.payment.list()\n.then(({ payments, count, limit, offset }) => {\n console.log(payments)\n})" + }, + "GET /admin/payments/payment-providers": { + "js-sdk": "sdk.admin.payment.listPaymentProviders()\n.then(({ payment_providers, count, limit, offset }) => {\n console.log(payment_providers)\n})" + }, + "GET /admin/payments/${id}": { + "js-sdk": "sdk.admin.payment.retrieve(\"pay_123\")\n.then(({ payment }) => {\n console.log(payment)\n})" + }, + "POST /admin/payments/${id}/capture": { + "js-sdk": "sdk.admin.payment.capture(\"paycol_123\", {})\n.then(({ payment }) => {\n console.log(payment)\n})" + }, + "POST /admin/payments/${id}/refund": { + "js-sdk": "sdk.admin.payment.refund(\"paycol_123\", {})\n.then(({ payment }) => {\n console.log(payment)\n})" + }, + "POST /admin/payment-collections": { + "js-sdk": "sdk.admin.paymentCollection.create({\n order_id: \"order_123\"\n})\n.then(({ payment_collection }) => {\n console.log(payment_collection)\n})" + }, + "DELETE /admin/payment-collections/${id}": { + "js-sdk": "sdk.admin.paymentCollection.delete(\"paycol_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/payment-collections/${id}/mark-as-paid": { + "js-sdk": "sdk.admin.paymentCollection.markAsPaid(\"paycol_123\", {\n order_id: \"order_123\"\n})\n.then(({ payment_collection }) => {\n console.log(payment_collection)\n})" + }, + "GET /admin/price-lists/${id}": { + "js-sdk": "sdk.admin.priceList.retrieve(\"plist_123\")\n.then(({ price_list }) => {\n console.log(price_list)\n})" + }, + "GET /admin/price-lists": { + "js-sdk": "sdk.admin.priceList.list()\n.then(({ price_lists, count, limit, offset }) => {\n console.log(price_lists)\n})" + }, + "POST /admin/price-lists": { + "js-sdk": "sdk.admin.priceList.create({\n title: \"My Price List\",\n status: \"active\",\n type: \"sale\",\n prices: [\n {\n variant_id: \"variant_123\",\n amount: 10,\n currency_code: \"usd\",\n rules: {\n region_id: \"reg_123\"\n }\n }\n ]\n})\n.then(({ price_list }) => {\n console.log(price_list)\n})" + }, + "POST /admin/price-lists/${id}": { + "js-sdk": "sdk.admin.priceList.update(\"plist_123\", {\n title: \"My Price List\",\n})\n.then(({ price_list }) => {\n console.log(price_list)\n})" + }, + "DELETE /admin/price-lists/${id}": { + "js-sdk": "sdk.admin.priceList.delete(\"plist_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/price-lists/${id}/prices/batch": { + "js-sdk": "sdk.admin.priceList.batchPrices(\"plist_123\", {\n create: [{\n variant_id: \"variant_123\",\n currency_code: \"usd\",\n amount: 10,\n rules: {\n region_id: \"reg_123\"\n }\n }],\n update: [{\n id: \"price_123\",\n variant_id: \"variant_123\",\n amount: 20,\n }],\n delete: [\"price_123\"]\n})\n.then(({ created, updated, deleted }) => {\n console.log(created, updated, deleted)\n})" + }, + "POST /admin/price-lists/${id}/products": { + "js-sdk": "sdk.admin.priceList.linkProducts(\"plist_123\", {\n remove: [\"prod_123\"]\n})\n.then(({ price_list }) => {\n console.log(price_list)\n})" + }, + "GET /admin/price-preferences/${id}": { + "js-sdk": "sdk.admin.pricePreference.retrieve(\"prpref_123\")\n.then(({ price_preference }) => {\n console.log(price_preference)\n})" + }, + "GET /admin/price-preferences": { + "js-sdk": "sdk.admin.pricePreference.list()\n.then(({ price_preferences, count, limit, offset }) => {\n console.log(price_preferences)\n})" + }, + "POST /admin/price-preferences": { + "js-sdk": "sdk.admin.pricePreference.create({\n attribute: \"region_id\",\n value: \"region_123\",\n is_tax_inclusive: true\n})\n.then(({ price_preference }) => {\n console.log(price_preference)\n})" + }, + "POST /admin/price-preferences/${id}": { + "js-sdk": "sdk.admin.pricePreference.update(\"prpref_123\", {\n is_tax_inclusive: true\n})\n.then(({ price_preference }) => {\n console.log(price_preference)\n})" + }, + "DELETE /admin/price-preferences/${id}": { + "js-sdk": "sdk.admin.pricePreference.delete(\"prpref_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/products/import": { + "js-sdk": "sdk.admin.product.import({\n file // uploaded File instance\n})\n.then(({ transaction_id }) => {\n console.log(transaction_id)\n})" + }, + "POST /admin/products/import/${transactionid}/confirm": { + "js-sdk": "sdk.admin.product.confirmImport(\"transaction_123\")\n.then(() => {\n console.log(\"Import confirmed\")\n})" + }, + "POST /admin/products/export": { + "js-sdk": "sdk.admin.product.export({})\n.then(({ transaction_id }) => {\n console.log(transaction_id)\n})" + }, + "POST /admin/products/batch": { + "js-sdk": "sdk.admin.product.batch({\n create: [\n {\n title: \"Shirt\",\n options: [{\n title: \"Default\",\n values: [\"Default Option\"]\n }],\n variants: [\n {\n title: \"Default\",\n options: {\n Default: \"Default Option\"\n },\n prices: []\n }\n ]\n }\n ],\n update: [{\n id: \"prod_123\",\n title: \"Pants\"\n }],\n delete: [\"prod_321\"]\n})\n.then(({ created, updated, deleted }) => {\n console.log(created, updated, deleted)\n})" + }, + "POST /admin/products": { + "js-sdk": "sdk.admin.product.create({\n title: \"Shirt\",\n options: [{\n title: \"Default\",\n values: [\"Default Option\"]\n }],\n variants: [\n {\n title: \"Default\",\n options: {\n Default: \"Default Option\"\n },\n prices: []\n }\n ],\n shipping_profile_id: \"sp_123\"\n})\n.then(({ product }) => {\n console.log(product)\n})" + }, + "POST /admin/products/${id}": { + "js-sdk": "sdk.admin.product.update(\"prod_123\", {\n title: \"Shirt\",\n})\n.then(({ product }) => {\n console.log(product)\n})" + }, + "GET /admin/products": { + "js-sdk": "sdk.admin.product.list()\n.then(({ products, count, limit, offset }) => {\n console.log(products)\n})" + }, + "GET /admin/products/${id}": { + "js-sdk": "sdk.admin.product.retrieve(\"prod_123\")\n.then(({ product }) => {\n console.log(product)\n})" + }, + "DELETE /admin/products/${id}": { + "js-sdk": "sdk.admin.product.delete(\"prod_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/products/${productid}/variants/batch": { + "js-sdk": "sdk.admin.product.batchVariants(\"prod_123\", {\n create: [\n {\n title: \"Blue Shirt\",\n options: {\n Color: \"Blue\"\n },\n prices: []\n }\n ],\n update: [\n {\n id: \"variant_123\",\n title: \"Pants\"\n }\n ],\n delete: [\"variant_123\"]\n})\n.then(({ created, updated, deleted }) => {\n console.log(created, updated, deleted)\n})" + }, + "POST /admin/products/${productid}/variants": { + "js-sdk": "sdk.admin.product.createVariant(\"prod_123\", {\n title: \"Blue Shirt\",\n options: {\n Color: \"Blue\"\n },\n prices: [\n {\n amount: 10,\n currency_code: \"usd\"\n }\n ]\n})\n.then(({ product }) => {\n console.log(product)\n})" + }, + "POST /admin/products/${productid}/variants/${id}": { + "js-sdk": "sdk.admin.product.updateVariant(\n \"prod_123\", \n \"variant_123\",\n {\n title: \"Blue Shirt\",\n }\n)\n.then(({ product }) => {\n console.log(product)\n})" + }, + "GET /admin/products/${productid}/variants": { + "js-sdk": "sdk.admin.product.listVariants(\"prod_123\")\n.then(({ variants, count, limit, offset }) => {\n console.log(variants)\n})" + }, + "GET /admin/products/${productid}/variants/${id}": { + "js-sdk": "sdk.admin.product.retrieveVariant(\n \"prod_123\",\n \"variant_123\"\n)\n.then(({ variant }) => {\n console.log(variant)\n})" + }, + "DELETE /admin/products/${productid}/variants/${id}": { + "js-sdk": "sdk.admin.product.deleteVariant(\"prod_123\", \"variant_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/products/${productid}/variants/inventory-items/batch": { + "js-sdk": "sdk.admin.product.batchVariantInventoryItems(\n \"prod_123\", \n {\n create: [\n {\n inventory_item_id: \"iitem_123\",\n variant_id: \"variant_123\",\n required_quantity: 10\n }\n ],\n update: [\n {\n inventory_item_id: \"iitem_1234\",\n variant_id: \"variant_1234\",\n required_quantity: 20\n }\n ],\n delete: [\n {\n inventory_item_id: \"iitem_321\",\n variant_id: \"variant_321\"\n }\n ]\n }\n)\n.then(({ created, updated, deleted }) => {\n console.log(created, updated, deleted)\n})" + }, + "POST /admin/products/${productid}/options": { + "js-sdk": "sdk.admin.product.createOption(\n \"prod_123\", \n {\n title: \"Color\",\n values: [\"Green\", \"Blue\"]\n }\n)\n.then(({ product }) => {\n console.log(product)\n})" + }, + "POST /admin/products/${productid}/options/${id}": { + "js-sdk": "sdk.admin.product.updateOption(\n \"prod_123\", \n \"prodopt_123\",\n {\n title: \"Color\"\n }\n)\n.then(({ product }) => {\n console.log(product)\n})" + }, + "GET /admin/products/${productid}/options": { + "js-sdk": "sdk.admin.product.listOptions(\"prod_123\")\n.then(({ product_options, count, limit, offset }) => {\n console.log(product_options)\n})" + }, + "GET /admin/products/${productid}/options/${id}": { + "js-sdk": "sdk.admin.product.retrieveOption(\n \"prod_123\",\n \"prodopt_123\"\n)\n.then(({ product_option }) => {\n console.log(product_option)\n})" + }, + "DELETE /admin/products/${productid}/options/${id}": { + "js-sdk": "sdk.admin.product.deleteOption(\"prod_123\", \"prodopt_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/product-categories": { + "js-sdk": "sdk.admin.productCategory.create({\n name: \"Shirts\"\n})\n.then(({ product_category }) => {\n console.log(product_category)\n})" + }, + "POST /admin/product-categories/${id}": { + "js-sdk": "sdk.admin.productCategory.update(\"pcat_123\", {\n name: \"Shirts\"\n})\n.then(({ product_category }) => {\n console.log(product_category)\n})" + }, + "GET /admin/product-categories": { + "js-sdk": "sdk.admin.productCategory.list()\n.then(({ product_categories, count, limit, offset }) => {\n console.log(product_categories)\n})" + }, + "GET /admin/product-categories/${id}": { + "js-sdk": "sdk.admin.productCategory.retrieve(\"pcat_123\")\n.then(({ product_category }) => {\n console.log(product_category)\n})" + }, + "DELETE /admin/product-categories/${id}": { + "js-sdk": "sdk.admin.productCategory.delete(\"pcat_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/product-categories/${id}/products": { + "js-sdk": "sdk.admin.productCategory.updateProducts(\"pcat_123\", {\n add: [\"prod_123\"],\n remove: [\"prod_321\"]\n})\n.then(({ product_category }) => {\n console.log(product_category)\n})" + }, + "POST /admin/collections": { + "js-sdk": "sdk.admin.productCollection.create({\n title: \"Summer Collection\"\n})\n.then(({ collection }) => {\n console.log(collection)\n})" + }, + "POST /admin/collections/${id}": { + "js-sdk": "sdk.admin.productCollection.update(\"pcol_123\", {\n title: \"Summer Collection\"\n})\n.then(({ collection }) => {\n console.log(collection)\n})" + }, + "GET /admin/collections": { + "js-sdk": "sdk.admin.productCollection.list()\n.then(({ collections, count, limit, offset }) => {\n console.log(collections)\n})" + }, + "GET /admin/collections/${id}": { + "js-sdk": "sdk.admin.productCollection.retrieve(\"pcol_123\")\n.then(({ collection }) => {\n console.log(collection)\n})" + }, + "DELETE /admin/collections/${id}": { + "js-sdk": "sdk.admin.productCollection.delete(\"pcol_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/collections/${id}/products": { + "js-sdk": "sdk.admin.productCollection.updateProducts(\"pcol_123\", {\n add: [\"prod_123\"],\n remove: [\"prod_321\"]\n})\n.then(({ collection }) => {\n console.log(collection)\n})" + }, + "POST /admin/product-tags": { + "js-sdk": "sdk.admin.productTag.create({\n value: \"shirt\"\n})\n.then(({ product_tag }) => {\n console.log(product_tag)\n})" + }, + "POST /admin/product-tags/${id}": { + "js-sdk": "sdk.admin.productTag.update(\"ptag_123\", {\n value: \"shirt\"\n})\n.then(({ product_tag }) => {\n console.log(product_tag)\n})" + }, + "GET /admin/product-tags": { + "js-sdk": "sdk.admin.productTag.list()\n.then(({ product_tags, count, limit, offset }) => {\n console.log(product_tags)\n})" + }, + "GET /admin/product-tags/${id}": { + "js-sdk": "sdk.admin.productTag.retrieve(\"ptag_123\")\n.then(({ product_tag }) => {\n console.log(product_tag)\n})" + }, + "DELETE /admin/product-tags/${id}": { + "js-sdk": "sdk.admin.productTag.delete(\"ptag_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "POST /admin/product-types": { + "js-sdk": "sdk.admin.productType.create({\n value: \"Clothes\"\n})\n.then(({ product_type }) => {\n console.log(product_type)\n})" + }, + "POST /admin/product-types/${id}": { + "js-sdk": "sdk.admin.productType.update(\"ptyp_123\", {\n value: \"Clothes\"\n})\n.then(({ product_type }) => {\n console.log(product_type)\n})" + }, + "GET /admin/product-types": { + "js-sdk": "sdk.admin.productType.list()\n.then(({ product_types, count, limit, offset }) => {\n console.log(product_types)\n})" + }, + "GET /admin/product-types/${id}": { + "js-sdk": "sdk.admin.productType.retrieve(\"ptyp_123\")\n.then(({ product_type }) => {\n console.log(product_type)\n})" + }, + "DELETE /admin/product-types/${id}": { + "js-sdk": "sdk.admin.productType.delete(\"ptyp_123\")\n.then(({ deleted }) => {\n console.log(deleted)\n})" + }, + "GET /admin/product-variants": { + "js-sdk": "sdk.admin.productVariant.list()\n.then(({ variants, count, limit, offset }) => {\n console.log(variants)\n})" + }, + "POST /auth/${actor}/${method}/register": { + "js-sdk": "sdk.auth.register(\n \"customer\",\n \"emailpass\",\n {\n email: \"customer@gmail.com\",\n password: \"supersecret\"\n }\n).then((token) => {\n console.log(token)\n})" + }, + "POST /auth/${actor}/${method}": { + "js-sdk": "sdk.auth.login(\n \"customer\",\n \"emailpass\",\n {\n email: \"customer@gmail.com\",\n password: \"supersecret\"\n }\n).then((token) => {\n console.log(token)\n})" + }, + "GET /auth/${actor}/${method}/callback": { + "js-sdk": "sdk.auth.callback(\n \"customer\",\n \"google\",\n {\n code: \"123\",\n state: \"456\"\n }\n).then((token) => {\n console.log(token)\n})" + }, + "POST /auth/token/refresh": { + "js-sdk": "sdk.auth.refresh()\n.then((token) => {\n console.log(token)\n})" + }, + "DELETE /auth/session": { + "js-sdk": "sdk.auth.logout()\n.then(() => {\n // user is logged out\n})" + }, + "POST /auth/${actor}/${provider}/reset-password": { + "js-sdk": "sdk.auth.resetPassword(\n \"customer\",\n \"emailpass\",\n {\n identifier: \"customer@gmail.com\"\n }\n)\n.then(() => {\n // user receives token\n})" + }, + "POST /auth/${actor}/${provider}/update": { + "js-sdk": "sdk.auth.updateProvider(\n \"customer\",\n \"emailpass\",\n {\n password: \"supersecret\"\n },\n token\n)\n.then(() => {\n // password updated\n})" + }, + "GET /store/regions": { + "js-sdk": "sdk.store.region.list()\n.then(({ regions, count, limit, offset }) => {\n console.log(regions)\n})" + }, + "GET /store/regions/${id}": { + "js-sdk": "sdk.store.region.retrieve(\"reg_123\")\n.then(({ region }) => {\n console.log(region)\n})" + }, + "GET /store/collections": { + "js-sdk": "sdk.store.collection.list()\n.then(({ collections, count, limit, offset }) => {\n console.log(collections)\n})" + }, + "GET /store/collections/${id}": { + "js-sdk": "sdk.store.collection.retrieve(\"pcol_123\")\n.then(({ collection }) => {\n console.log(collection)\n})" + }, + "GET /store/product-categories": { + "js-sdk": "sdk.store.category.list()\n.then(({ product_categories, count, offset, limit }) => {\n console.log(product_categories)\n})" + }, + "GET /store/product-categories/${id}": { + "js-sdk": "sdk.store.category.retrieve(\"pcat_123\")\n.then(({ product_category }) => {\n console.log(product_category)\n})" + }, + "GET /store/products": { + "js-sdk": "sdk.store.product.list()\n.then(({ products, count, offset, limit }) => {\n console.log(products)\n})" + }, + "GET /store/products/${id}": { + "js-sdk": "sdk.store.product.retrieve(\"prod_123\")\n.then(({ product }) => {\n console.log(product)\n})" + }, + "POST /store/carts": { + "js-sdk": "sdk.store.cart.create({\n region_id: \"reg_123\"\n})\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "POST /store/carts/${id}": { + "js-sdk": "sdk.store.cart.update(\"cart_123\", {\n region_id: \"reg_123\"\n})\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "GET /store/carts/${id}": { + "js-sdk": "sdk.store.cart.retrieve(\"cart_123\")\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "POST /store/carts/${cartid}/line-items": { + "js-sdk": "sdk.store.cart.createLineItem(\"cart_123\", {\n variant_id: \"variant_123\",\n quantity: 1\n})\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "POST /store/carts/${cartid}/line-items/${lineitemid}": { + "js-sdk": "sdk.store.cart.updateLineItem(\n \"cart_123\",\n \"li_123\",\n {\n quantity: 1\n }\n)\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "DELETE /store/carts/${cartid}/line-items/${lineitemid}": { + "js-sdk": "sdk.store.cart.deleteLineItem(\n \"cart_123\",\n \"li_123\"\n)\n.then(({ deleted, parent: cart }) => {\n console.log(deleted, cart)\n})" + }, + "POST /store/carts/${cartid}/shipping-methods": { + "js-sdk": "sdk.store.cart.addShippingMethod(\"cart_123\", {\n option_id: \"so_123\",\n data: {\n // custom data for fulfillment provider.\n }\n})\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "POST /store/carts/${cartid}/complete": { + "js-sdk": "sdk.store.cart.complete(\"cart_123\")\n.then((data) => {\n if(data.type === \"cart\") {\n // an error occurred\n console.log(data.error, data.cart)\n } else {\n // order placed successfully\n console.log(data.order)\n }\n})" + }, + "POST /store/carts/${id}/customer": { + "js-sdk": "sdk.store.cart.transferCart(\"cart_123\")\n.then(({ cart }) => {\n console.log(cart)\n})" + }, + "GET /store/shipping-options": { + "js-sdk": "sdk.store.fulfillment.listCartOptions({\n cart_id: \"cart_123\"\n})\n.then(({ shipping_options }) => {\n console.log(shipping_options)\n})" + }, + "GET /store/payment-providers": { + "js-sdk": "sdk.store.payment.listPaymentProviders({\n region_id: \"reg_123\"\n})\n.then(({ payment_providers, count, offset, limit }) => {\n console.log(payment_providers)\n})" + }, + "POST /store/payment-collections": { + "js-sdk": "sdk.store.payment.initiatePaymentSession(\n cart, // assuming you already have the cart object.\n {\n provider_id: \"pp_stripe_stripe\",\n data: {\n // any data relevant for the provider.\n }\n }\n)\n.then(({ payment_collection }) => {\n console.log(payment_collection)\n})" + }, + "GET /store/orders": { + "js-sdk": "sdk.store.order.list()\n.then(({ orders, count, offset, limit }) => {\n console.log(orders)\n})" + }, + "GET /store/orders/${id}": { + "js-sdk": "sdk.store.order.retrieve(\"order_123\")\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /store/orders/${id}/transfer/request": { + "js-sdk": "sdk.store.order.requestTransfer(\n \"order_123\",\n {\n description: \"I want to transfer this order to my friend.\"\n },\n {},\n {\n Authorization: `Bearer ${token}`\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /store/orders/${id}/transfer/cancel": { + "js-sdk": "sdk.store.order.cancelTransfer(\n \"order_123\",\n {},\n {\n Authorization: `Bearer ${token}`\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /store/orders/${id}/transfer/accept": { + "js-sdk": "sdk.store.order.acceptTransfer(\n \"order_123\",\n {\n token: \"transfer_token\"\n },\n {\n Authorization: `Bearer ${token}`\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /store/orders/${id}/transfer/decline": { + "js-sdk": "sdk.store.order.declineTransfer(\n \"order_123\",\n {\n token: \"transfer_token\"\n },\n {\n Authorization: `Bearer ${token}`\n }\n)\n.then(({ order }) => {\n console.log(order)\n})" + }, + "POST /store/customers": { + "js-sdk": "const token = await sdk.auth.register(\"customer\", \"emailpass\", {\n \"email\": \"customer@gmail.com\",\n \"password\": \"supersecret\"\n})\n\nsdk.store.customer.create(\n {\n \"email\": \"customer@gmail.com\"\n },\n {},\n {\n Authorization: `Bearer ${token}`\n }\n)\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "POST /store/customers/me": { + "js-sdk": "sdk.store.customer.update({\n first_name: \"John\"\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "GET /store/customers/me": { + "js-sdk": "sdk.store.customer.retrieve()\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "POST /store/customers/me/addresses": { + "js-sdk": "sdk.store.customer.createAddress({\n country_code: \"us\"\n})\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "POST /store/customers/me/addresses/${addressid}": { + "js-sdk": "sdk.store.customer.updateAddress(\n \"caddr_123\",\n {\n country_code: \"us\"\n }\n)\n.then(({ customer }) => {\n console.log(customer)\n})" + }, + "GET /store/customers/me/addresses": { + "js-sdk": "sdk.store.customer.listAddress()\n.then(({ addresses, count, offset, limit }) => {\n console.log(addresses)\n})" + }, + "GET /store/customers/me/addresses/${addressid}": { + "js-sdk": "sdk.store.customer.retrieveAddress(\n \"caddr_123\"\n)\n.then(({ address }) => {\n console.log(address)\n})" + }, + "DELETE /store/customers/me/addresses/${addressid}": { + "js-sdk": "sdk.store.customer.deleteAddress(\"caddr_123\")\n.then(({ deleted, parent: customer }) => {\n console.log(customer)\n})" + } +} \ No newline at end of file diff --git a/www/utils/packages/docs-generator/src/classes/generators/route-examples.ts b/www/utils/packages/docs-generator/src/classes/generators/route-examples.ts new file mode 100644 index 0000000000..1c0228a960 --- /dev/null +++ b/www/utils/packages/docs-generator/src/classes/generators/route-examples.ts @@ -0,0 +1,105 @@ +import { minimatch } from "minimatch" +import AbstractGenerator from "./index.js" +import getBasePath from "../../utils/get-base-path.js" +import RouteExamplesKindGenerator from "../kinds/route-examples.js" +import ts from "typescript" +import type { RouteExamples } from "types" +import getMonorepoRoot from "../../utils/get-monorepo-root.js" +import path from "path" +class RouteExamplesGenerator extends AbstractGenerator { + protected routeExamplesKindGenerator?: RouteExamplesKindGenerator + + async run() { + this.init() + + this.routeExamplesKindGenerator = new RouteExamplesKindGenerator({ + checker: this.checker!, + generatorEventManager: this.generatorEventManager, + }) + + let routeExamples: RouteExamples = {} + + await Promise.all( + this.program!.getSourceFiles().map(async (file) => { + if (file.isDeclarationFile || !this.isFileIncluded(file.fileName)) { + return + } + + const fileNodes: ts.Node[] = [file] + + console.log(`[Route Examples] Generating for ${file.fileName}...`) + + // since typescript's compiler API doesn't support + // async processes, we have to retrieve the nodes first then + // traverse them separately. + const pushNodesToArr = (node: ts.Node) => { + fileNodes.push(node) + + ts.forEachChild(node, pushNodesToArr) + } + ts.forEachChild(file, pushNodesToArr) + + const documentChild = async (node: ts.Node) => { + if ( + this.routeExamplesKindGenerator!.isAllowed(node) && + this.routeExamplesKindGenerator!.canDocumentNode(node) + ) { + const result = + await this.routeExamplesKindGenerator!.getDocBlock(node) + if (!result) { + return + } + + routeExamples = Object.assign(routeExamples, JSON.parse(result)) + } + } + + await Promise.all( + fileNodes.map(async (node) => await documentChild(node)) + ) + + if (!this.options.dryRun) { + this.writeJson(routeExamples) + } + }) + ) + } + + /** + * Checks whether the specified file path is included in the program + * and is an API file. + * + * @param fileName - The file path to check + * @returns Whether the Route Examples generator can run on this file. + */ + isFileIncluded(fileName: string): boolean { + return ( + super.isFileIncluded(fileName) && + minimatch( + getBasePath(fileName), + "packages/core/**/js-sdk/src/@(store|admin|auth)/**", + { + matchBase: true, + } + ) + ) + } + + /** + * Writes the route examples to a JSON file. + * + * @param routeExamples - The route examples to write. + */ + writeJson(routeExamples: RouteExamples) { + const filePath = path.join( + getMonorepoRoot(), + "www/utils/generated/route-examples-output/route-examples.json" + ) + + const fileContent = JSON.stringify(routeExamples, null, 2) + + ts.sys.writeFile(filePath, fileContent) + } +} + +export default RouteExamplesGenerator diff --git a/www/utils/packages/docs-generator/src/classes/kinds/oas.ts b/www/utils/packages/docs-generator/src/classes/kinds/oas.ts index 10db39fed3..979ce02d0e 100644 --- a/www/utils/packages/docs-generator/src/classes/kinds/oas.ts +++ b/www/utils/packages/docs-generator/src/classes/kinds/oas.ts @@ -239,7 +239,6 @@ class OasKindGenerator extends FunctionKindGenerator { node: ts.Node | FunctionOrVariableNode, options?: GetDocBlockOptions ): Promise { - // TODO use AiGenerator to generate descriptions + examples if (!this.isAllowed(node)) { return await super.getDocBlock(node, options) } diff --git a/www/utils/packages/docs-generator/src/classes/kinds/route-examples.ts b/www/utils/packages/docs-generator/src/classes/kinds/route-examples.ts new file mode 100644 index 0000000000..0fc8b4d1fc --- /dev/null +++ b/www/utils/packages/docs-generator/src/classes/kinds/route-examples.ts @@ -0,0 +1,189 @@ +import ts from "typescript" +import { SyntaxKind } from "typescript" +import DefaultKindGenerator, { GetDocBlockOptions } from "./default.js" +import { API_ROUTE_PARAM_REGEX } from "../../constants.js" +import type { RouteExamples } from "types" +const EXAMPLE_CODEBLOCK_REGEX = /```(ts|typescript)\s*([.\s\S]*?)\s*```/ + +type RouteData = { + route: string + method: string +} + +// eslint-disable-next-line max-len +class RouteExamplesKindGenerator extends DefaultKindGenerator { + public name = "route-examples" + protected allowedKinds: SyntaxKind[] = [ + SyntaxKind.MethodDeclaration, + SyntaxKind.ArrowFunction, + ] + + /** + * Gets the route examples from the specified node. + * + * @param node - The node to get the route examples from. + * @param options - The options for the route examples. + * @returns The route examples for the specified node. + */ + async getDocBlock( + node: ts.MethodDeclaration, + options?: GetDocBlockOptions + ): Promise { + if (!this.isAllowed(node)) { + return await super.getDocBlock(node, options) + } + + // extract the route path from the node + const routeData = this.findRoute(node.body as ts.Node) + + if (!routeData.route) { + return "" + } + if (!routeData.method) { + routeData.method = "GET" // default method + } + + // get examples from the comments + const example = ts + .getJSDocTags(node) + .find((tag) => tag.tagName.escapedText === "example") + + if (!example || !example.comment) { + return "" + } + + const exampleText = this.getExampleText( + typeof example.comment === "string" + ? example.comment + : example.comment[example.comment.length - 1].text + ) + + return JSON.stringify({ + [this.formatRouteData(routeData)]: { + [this.getExampleType(node)]: exampleText, + }, + } as RouteExamples) + } + + getExampleText(comment: string): string { + // try to match the example codeblock first + const match = comment.match(EXAMPLE_CODEBLOCK_REGEX) + if (match) { + // return the last match + return match[match.length - 1] + } + + // consider the comment as the example text + return comment + } + + /** + * Use this method later to support different example types. + * + * @param node - The node to get the example type for. + * @returns The example type. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getExampleType(node: ts.MethodDeclaration): string { + return "js-sdk" + } + + /** + * Finds the route data from the specified node. + * + * @param node - The node to find the route from. + * @returns The route data. + */ + findRoute(node: ts.Node): RouteData { + const result = { + route: "", + method: "", + } + + if ( + node.kind === ts.SyntaxKind.StringLiteral || + node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral || + node.kind === ts.SyntaxKind.TemplateExpression + ) { + const str = node + .getText() + .replace(/^["'`]|["'`]$/g, "") + .replace(API_ROUTE_PARAM_REGEX, `{$1}`) + .toLowerCase() + if ( + str.startsWith("/store") || + str.startsWith("/admin") || + str.startsWith("/auth") + ) { + result.route = str + } else if ( + str === "get" || + str === "post" || + str === "put" || + str === "delete" + ) { + result.method = str.toUpperCase() + } + } else { + node.forEachChild((child) => { + if (result.route.length > 0 && result.method.length > 0) { + return + } + + const childResult = this.findRoute(child) + if (result.route.length === 0) { + result.route = childResult.route + } + if (result.method.length === 0) { + result.method = childResult.method + } + }) + } + + return result + } + + /** + * Formats the route data as a string. + * + * @param routeData - The route data to format. + * @returns The formatted route data as a string. + */ + formatRouteData(routeData: RouteData): string { + return `${routeData.method} ${routeData.route}` + } + + /** + * Checks whether a node can be documented. + * + * @param {ts.Node} node - The node to check for. + * @returns {boolean} Whether the node can be documented. + */ + canDocumentNode(node: ts.Node): boolean { + // check if node has docblock + return ts.getJSDocCommentsAndTags(node).length > 0 && !this.isPrivate(node) + } + + /** + * Checks whether a node is private. + * + * @param node - The node to check for. + * @returns Whether the node is private. + */ + isPrivate(node: ts.Node): boolean { + // Check for explicit private keyword + if (ts.canHaveModifiers(node)) { + const modifiers = ts.getModifiers(node) + if (modifiers) { + return modifiers.some( + (modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword + ) + } + } + + // Check for private class member + return (node.flags & ts.ModifierFlags.Private) !== 0 + } +} + +export default RouteExamplesKindGenerator diff --git a/www/utils/packages/docs-generator/src/commands/run-git-changes.ts b/www/utils/packages/docs-generator/src/commands/run-git-changes.ts index 0e3aa89c00..0bd301441b 100644 --- a/www/utils/packages/docs-generator/src/commands/run-git-changes.ts +++ b/www/utils/packages/docs-generator/src/commands/run-git-changes.ts @@ -5,6 +5,7 @@ import { GitManager } from "../classes/helpers/git-manager.js" import { CommonCliOptions } from "../types/index.js" import OasGenerator from "../classes/generators/oas.js" import DmlGenerator from "../classes/generators/dml.js" +import RouteExamplesGenerator from "../classes/generators/route-examples.js" export default async function runGitChanges({ type, @@ -53,5 +54,14 @@ export default async function runGitChanges({ await dmlGenerator.run() } + if (type === "all" || type === "route-examples") { + const routeExamplesGenerator = new RouteExamplesGenerator({ + paths: files, + ...options, + }) + + await routeExamplesGenerator.run() + } + console.log(`Finished generating docs for ${files.length} files.`) } diff --git a/www/utils/packages/docs-generator/src/commands/run-git-commit.ts b/www/utils/packages/docs-generator/src/commands/run-git-commit.ts index f55c018c9c..d0c364144a 100644 --- a/www/utils/packages/docs-generator/src/commands/run-git-commit.ts +++ b/www/utils/packages/docs-generator/src/commands/run-git-commit.ts @@ -6,6 +6,7 @@ import OasGenerator from "../classes/generators/oas.js" import { CommonCliOptions } from "../types/index.js" import { GitManager } from "../classes/helpers/git-manager.js" import DmlGenerator from "../classes/generators/dml.js" +import RouteExamplesGenerator from "../classes/generators/route-examples.js" export default async function ( commitSha: string, @@ -61,5 +62,14 @@ export default async function ( await dmlGenerator.run() } + if (type === "all" || type === "route-examples") { + const routeExamplesGenerator = new RouteExamplesGenerator({ + paths: filteredFiles, + ...options, + }) + + await routeExamplesGenerator.run() + } + console.log(`Finished generating docs for ${filteredFiles.length} files.`) } diff --git a/www/utils/packages/docs-generator/src/commands/run-release.ts b/www/utils/packages/docs-generator/src/commands/run-release.ts index 53c5bd0bd7..d31aa85dad 100644 --- a/www/utils/packages/docs-generator/src/commands/run-release.ts +++ b/www/utils/packages/docs-generator/src/commands/run-release.ts @@ -6,6 +6,7 @@ import { GitManager } from "../classes/helpers/git-manager.js" import OasGenerator from "../classes/generators/oas.js" import { CommonCliOptions } from "../types/index.js" import DmlGenerator from "../classes/generators/dml.js" +import RouteExamplesGenerator from "../classes/generators/route-examples.js" export default async function ({ type, tag, ...options }: CommonCliOptions) { const gitManager = new GitManager() @@ -59,5 +60,14 @@ export default async function ({ type, tag, ...options }: CommonCliOptions) { await dmlGenerator.run() } + if (type === "all" || type === "route-examples") { + const routeExamplesGenerator = new RouteExamplesGenerator({ + paths: filteredFiles, + ...options, + }) + + await routeExamplesGenerator.run() + } + console.log(`Finished generating docs for ${filteredFiles.length} files.`) } diff --git a/www/utils/packages/docs-generator/src/commands/run.ts b/www/utils/packages/docs-generator/src/commands/run.ts index c1daa79688..028c2b1d8a 100644 --- a/www/utils/packages/docs-generator/src/commands/run.ts +++ b/www/utils/packages/docs-generator/src/commands/run.ts @@ -2,6 +2,7 @@ import DmlGenerator from "../classes/generators/dml.js" import DocblockGenerator from "../classes/generators/docblock.js" import { Options } from "../classes/generators/index.js" import OasGenerator from "../classes/generators/oas.js" +import RouteExamplesGenerator from "../classes/generators/route-examples.js" import { CommonCliOptions } from "../types/index.js" export default async function run( @@ -37,5 +38,14 @@ export default async function run( await dmlGenerator.run() } + if (type === "all" || type === "route-examples") { + const routeExamplesGenerator = new RouteExamplesGenerator({ + paths, + ...options, + }) + + await routeExamplesGenerator.run() + } + console.log(`Finished running.`) } diff --git a/www/utils/packages/docs-generator/src/index.ts b/www/utils/packages/docs-generator/src/index.ts index 6a035228d9..911e92e351 100644 --- a/www/utils/packages/docs-generator/src/index.ts +++ b/www/utils/packages/docs-generator/src/index.ts @@ -14,7 +14,7 @@ program.name("docs-generator").description("Generate TSDoc doc-blocks") // define common options const typeOption = new Option("--type ", "The type of docs to generate.") - .choices(["all", "docs", "oas", "dml"]) + .choices(["all", "docs", "oas", "dml", "route-examples"]) .default("all") const generateExamplesOption = new Option( diff --git a/www/utils/packages/docs-generator/src/types/index.d.ts b/www/utils/packages/docs-generator/src/types/index.d.ts index c827dc02c2..39faaee6ee 100644 --- a/www/utils/packages/docs-generator/src/types/index.d.ts +++ b/www/utils/packages/docs-generator/src/types/index.d.ts @@ -13,7 +13,7 @@ export declare type OpenApiOperation = Partial & { } export declare type CommonCliOptions = { - type: "all" | "oas" | "docs" | "dml" + type: "all" | "oas" | "docs" | "dml" | "route-examples" generateExamples?: boolean tag?: string } diff --git a/www/utils/packages/types/lib/index.d.ts b/www/utils/packages/types/lib/index.d.ts index 176dac7705..2249fee488 100644 --- a/www/utils/packages/types/lib/index.d.ts +++ b/www/utils/packages/types/lib/index.d.ts @@ -301,6 +301,12 @@ export declare type DmlFile = { } } +export declare type RouteExamples = { + [k: string]: { + [k: string]: string + } +} + export declare type NamespaceGenerateDetails = { /** * The namespace's names.