From 1be2a50e9b9ef6971179cdf23380ad9879033496 Mon Sep 17 00:00:00 2001 From: James Calverley Date: Wed, 8 May 2024 17:13:12 +0000 Subject: [PATCH] add shop object to web pixel init data --- .../src/schemas/pixel-events.ts | 4093 ++++++++--------- .../src/types/EventBus.ts | 60 +- .../src/types/ExtensionApi.ts | 4 +- .../src/types/PixelEvents/index.ts | 194 +- .../src/types/PublicApi.ts | 6 +- .../src/types/RegisterInit.ts | 3 + .../src/types/WebPixelsManager.ts | 62 + .../web-pixels-extension/src/types/index.ts | 8 +- 8 files changed, 2181 insertions(+), 2249 deletions(-) create mode 100644 packages/web-pixels-extension/src/types/WebPixelsManager.ts diff --git a/packages/web-pixels-extension/src/schemas/pixel-events.ts b/packages/web-pixels-extension/src/schemas/pixel-events.ts index 068c680ab..bcd1f1149 100644 --- a/packages/web-pixels-extension/src/schemas/pixel-events.ts +++ b/packages/web-pixels-extension/src/schemas/pixel-events.ts @@ -1,2166 +1,2073 @@ export const pixelEvents = { - definitions: { - Browser: { - properties: { - cookie: { - metadata: { - description: - 'This object replaces the native document.cookie API and provides a setter/getter to set cookies on the top frame.', - }, - properties: { - get: { - metadata: { - description: - 'An asynchronous method to get a specific cookie by name. Takes a cookie name of type `string` and returns the cookie value as a `string`', - typescriptType: '(name?: string) => Promise', - }, - }, - set: { - metadata: { - description: - 'An asynchronous method to set a cookie by name. It takes two arguments, a string of form `key=value` as [described here](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#write_a_new_cookie) or the name of the cookie as the first argument and the value as the second argument.', - typescriptType: - '(cookieOrName: string, value?: string) => Promise', - }, - }, - }, - }, - sendBeacon: { - metadata: { - description: - '@deprecated The navigator.sendBeacon() method asynchronously sends an HTTP POST request containing a small amount of data to a web server. Please use the standard web `fetch` api with the option `keepalive: true` to achieve this functionality.', - typescriptType: '(url: string, body?: string) => Promise', - }, - }, - localStorage: { - properties: { - length: { - metadata: { - description: - 'Returns an integer representing the number of data items stored in the Storage object.', - typescriptType: - "() => Promise", - }, - }, - key: { - metadata: { - description: - 'When passed a number n, this method will return the name of the nth key in the storage.', - typescriptType: - "(index: number) => Promise>", - }, + "definitions": { + "Browser": { + "properties": { + "cookie": { + "metadata": { + "description": "This object replaces the native document.cookie API and provides a setter/getter to set cookies on the top frame." + }, + "properties": { + "get": { + "metadata": { + "description": "An asynchronous method to get a specific cookie by name. Takes a cookie name of type `string` and returns the cookie value as a `string`", + "typescriptType": "(name?: string) => Promise" + } }, - getItem: { - metadata: { - description: - "When passed a key name, will return that key's value.", - typescriptType: - "(key: string) => Promise>", - }, + "set": { + "metadata": { + "description": "An asynchronous method to set a cookie by name. It takes two arguments, a string of form `key=value` as [described here](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#write_a_new_cookie) or the name of the cookie as the first argument and the value as the second argument.", + "typescriptType": "(cookieOrName: string, value?: string) => Promise" + } + } + } + }, + "sendBeacon": { + "metadata": { + "description": "@deprecated The navigator.sendBeacon() method asynchronously sends an HTTP POST request containing a small amount of data to a web server. Please use the standard web `fetch` api with the option `keepalive: true` to achieve this functionality.", + "typescriptType": "(url: string, body?: string) => Promise" + } + }, + "localStorage": { + "properties": { + "length": { + "metadata": { + "description": "Returns an integer representing the number of data items stored in the Storage object.", + "typescriptType": "() => Promise" + } }, - setItem: { - metadata: { - description: - "When passed a key name and value, will add that key to the storage, or update that key's value if it already exists.", - typescriptType: - "(key: string, value: any) => Promise>", - }, + "key": { + "metadata": { + "description": "When passed a number n, this method will return the name of the nth key in the storage.", + "typescriptType": "(index: number) => Promise>" + } }, - removeItem: { - metadata: { - description: - 'When passed a key name, will remove that key from the storage.', - typescriptType: - "(key: string) => Promise>", - }, + "getItem": { + "metadata": { + "description": "When passed a key name, will return that key's value.", + "typescriptType": "(key: string) => Promise>" + } }, - clear: { - metadata: { - description: - 'When invoked, will empty all keys out of the storage.', - typescriptType: - "() => Promise>", - }, + "setItem": { + "metadata": { + "description": "When passed a key name and value, will add that key to the storage, or update that key's value if it already exists.", + "typescriptType": "(key: string, value: any) => Promise>" + } }, - }, - }, - sessionStorage: { - properties: { - length: { - metadata: { - description: - 'Returns an integer representing the number of data items stored in the Storage object.', - typescriptType: - "() => Promise", - }, + "removeItem": { + "metadata": { + "description": "When passed a key name, will remove that key from the storage.", + "typescriptType": "(key: string) => Promise>" + } }, - key: { - metadata: { - description: - 'When passed a number n, this method will return the name of the nth key in the storage.', - typescriptType: - "(index: number) => Promise>", - }, + "clear": { + "metadata": { + "description": "When invoked, will empty all keys out of the storage.", + "typescriptType": "() => Promise>" + } + } + } + }, + "sessionStorage": { + "properties": { + "length": { + "metadata": { + "description": "Returns an integer representing the number of data items stored in the Storage object.", + "typescriptType": "() => Promise" + } }, - getItem: { - metadata: { - description: - "When passed a key name, will return that key's value.", - typescriptType: - "(key: string) => Promise>", - }, + "key": { + "metadata": { + "description": "When passed a number n, this method will return the name of the nth key in the storage.", + "typescriptType": "(index: number) => Promise>" + } }, - setItem: { - metadata: { - description: - "When passed a key name and value, will add that key to the storage, or update that key's value if it already exists.", - typescriptType: - "(key: string, value: any) => Promise>", - }, + "getItem": { + "metadata": { + "description": "When passed a key name, will return that key's value.", + "typescriptType": "(key: string) => Promise>" + } }, - removeItem: { - metadata: { - description: - 'When passed a key name, will remove that key from the storage.', - typescriptType: - "(key: string) => Promise>", - }, + "setItem": { + "metadata": { + "description": "When passed a key name and value, will add that key to the storage, or update that key's value if it already exists.", + "typescriptType": "(key: string, value: any) => Promise>" + } }, - clear: { - metadata: { - description: - 'When invoked, will empty all keys out of the storage.', - typescriptType: - "() => Promise>", - }, + "removeItem": { + "metadata": { + "description": "When passed a key name, will remove that key from the storage.", + "typescriptType": "(key: string) => Promise>" + } }, - }, - }, - }, + "clear": { + "metadata": { + "description": "When invoked, will empty all keys out of the storage.", + "typescriptType": "() => Promise>" + } + } + } + } + } }, - Context: { - metadata: { - description: - 'A snapshot of various read-only properties of the browser at the time of event', - }, - properties: { - window: { - ref: 'WebPixelsWindow', - metadata: { - description: - 'Snapshot of a subset of properties of the `window` object in the top frame of the browser', - }, - }, - document: { - ref: 'WebPixelsDocument', - metadata: { - description: - 'Snapshot of a subset of properties of the `document` object in the top frame of the browser', - }, - }, - navigator: { - ref: 'WebPixelsNavigator', - metadata: { - description: - 'Snapshot of a subset of properties of the `navigator` object in the top frame of the browser', - }, - }, - }, + "Context": { + "metadata": { + "description": "A snapshot of various read-only properties of the browser at the time of event" + }, + "properties": { + "window": { + "ref": "WebPixelsWindow", + "metadata": { + "description": "Snapshot of a subset of properties of the `window` object in the top frame of the browser" + } + }, + "document": { + "ref": "WebPixelsDocument", + "metadata": { + "description": "Snapshot of a subset of properties of the `document` object in the top frame of the browser" + } + }, + "navigator": { + "ref": "WebPixelsNavigator", + "metadata": { + "description": "Snapshot of a subset of properties of the `navigator` object in the top frame of the browser" + } + } + } }, - InitData: { - properties: { - customer: { - nullable: true, - ref: 'Customer', - }, - cart: { - nullable: true, - ref: 'Cart', - }, - checkout: { - nullable: true, - ref: 'Checkout', - }, - productVariants: { - nullable: true, - elements: { - ref: 'ProductVariant', - }, - }, - }, + "InitData": { + "properties": { + "customer": { + "nullable": true, + "ref": "Customer" + }, + "cart": { + "nullable": true, + "ref": "Cart" + }, + "shop": { + "ref": "Shop" + }, + "checkout": { + "nullable": true, + "ref": "Checkout" + }, + "productVariants": { + "nullable": true, + "elements": { + "ref": "ProductVariant" + } + } + } }, - WebPixelsWindow: { - metadata: { - description: - 'A snapshot of a subset of properties of the `window` object in the top frame of the browser', - }, - properties: { - innerHeight: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar', - }, - }, - innerWidth: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the width of the content area of the browser window including, if rendered, the vertical scrollbar', - }, - }, - outerHeight: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the height of the outside of the browser window', - }, - }, - outerWidth: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the width of the outside of the browser window', - }, - }, - pageXOffset: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), an alias for window.scrollX', - }, - }, - pageYOffset: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), an alias for window.scrollY', - }, - }, - screen: { - ref: 'Screen', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen), the interface representing a screen, usually the one on which the current window is being rendered', - }, - }, - screenX: { - type: 'uint32', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the horizontal distance from the left border of the user's browser viewport to the left side of the screen", - }, - }, - screenY: { - type: 'uint32', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the vertical distance from the top border of the user's browser viewport to the top side of the screen", - }, - }, - scrollX: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the number of pixels that the document has already been scrolled horizontally', - }, - }, - scrollY: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the number of pixels that the document has already been scrolled vertically', - }, - }, - origin: { - type: 'string', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the global object's origin, serialized as a string", - }, - }, - location: { - ref: 'Location', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the location, or current URL, of the window object', - }, - }, - }, + "WebPixelsWindow": { + "metadata": { + "description": "A snapshot of a subset of properties of the `window` object in the top frame of the browser" + }, + "properties": { + "innerHeight": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar" + } + }, + "innerWidth": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the width of the content area of the browser window including, if rendered, the vertical scrollbar" + } + }, + "outerHeight": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the height of the outside of the browser window" + } + }, + "outerWidth": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the width of the outside of the browser window" + } + }, + "pageXOffset": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), an alias for window.scrollX" + } + }, + "pageYOffset": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), an alias for window.scrollY" + } + }, + "screen": { + "ref": "Screen", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen), the interface representing a screen, usually the one on which the current window is being rendered" + } + }, + "screenX": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the horizontal distance from the left border of the user's browser viewport to the left side of the screen" + } + }, + "screenY": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the vertical distance from the top border of the user's browser viewport to the top side of the screen" + } + }, + "scrollX": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the number of pixels that the document has already been scrolled horizontally" + } + }, + "scrollY": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the number of pixels that the document has already been scrolled vertically" + } + }, + "origin": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the global object's origin, serialized as a string" + } + }, + "location": { + "ref": "Location", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the location, or current URL, of the window object" + } + } + } }, - Location: { - metadata: { - description: - 'A snapshot of a subset of properties of the `location` object in the top frame of the browser', - }, - properties: { - href: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the entire URL', - }, - }, - protocol: { - type: 'string', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the protocol scheme of the URL, including the final `':'`", - }, - }, - host: { - type: 'string', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the host, that is the hostname, a `':'`, and the port of the URL", - }, - }, - hostname: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the domain of the URL', - }, - }, - port: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the port number of the URL', - }, - }, - pathname: { - type: 'string', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing an initial `'/'` followed by the path of the URL, not including the query string or fragment", - }, - }, - search: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing a `\'?\'` followed by the parameters or "querystring" of the URL', - }, - }, - hash: { - type: 'string', - metadata: { - description: - "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing a `'#'` followed by the fragment identifier of the URL", - }, - }, - origin: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the canonical form of the origin of the specific location', - }, - }, - }, + "Location": { + "metadata": { + "description": "A snapshot of a subset of properties of the `location` object in the top frame of the browser" + }, + "properties": { + "href": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the entire URL" + } + }, + "protocol": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the protocol scheme of the URL, including the final `':'`" + } + }, + "host": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the host, that is the hostname, a `':'`, and the port of the URL" + } + }, + "hostname": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the domain of the URL" + } + }, + "port": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the port number of the URL" + } + }, + "pathname": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing an initial `'/'` followed by the path of the URL, not including the query string or fragment" + } + }, + "search": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing a `'?'` followed by the parameters or \"querystring\" of the URL" + } + }, + "hash": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing a `'#'` followed by the fragment identifier of the URL" + } + }, + "origin": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the canonical form of the origin of the specific location" + } + } + } }, - Screen: { - metadata: { - description: - 'The interface representing a screen, usually the one on which the current window is being rendered', - }, - properties: { - height: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/height), the height of the screen', - }, - }, - width: { - type: 'uint32', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/width), the width of the screen', - }, - }, - }, + "Screen": { + "metadata": { + "description": "The interface representing a screen, usually the one on which the current window is being rendered" + }, + "properties": { + "height": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/height), the height of the screen" + } + }, + "width": { + "type": "uint32", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/width), the width of the screen" + } + } + } }, - WebPixelsDocument: { - metadata: { - description: - 'A snapshot of a subset of properties of the `document` object in the top frame of the browser', - }, - properties: { - characterSet: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the character set being used by the document', - }, - }, - location: { - ref: 'Location', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the URI of the current document', - }, - }, - referrer: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the URI of the page that linked to this page', - }, - }, - title: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the title of the current document', - }, - }, - }, + "WebPixelsDocument": { + "metadata": { + "description": "A snapshot of a subset of properties of the `document` object in the top frame of the browser" + }, + "properties": { + "characterSet": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the character set being used by the document" + } + }, + "location": { + "ref": "Location", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the URI of the current document" + } + }, + "referrer": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the URI of the page that linked to this page" + } + }, + "title": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the title of the current document" + } + } + } }, - WebPixelsNavigator: { - metadata: { - description: - 'A snapshot of a subset of properties of the `navigator` object in the top frame of the browser', - }, - properties: { - cookieEnabled: { - type: 'boolean', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns `false` if setting a cookie will be ignored and true otherwise', - }, - }, - language: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns a string representing the preferred language of the user, usually the language of the browser UI. The `null` value is returned when this is unknown', - }, - }, - languages: { - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns an array of strings representing the languages known to the user, by order of preference', - typescriptType: 'ReadonlyArray', - }, - }, - userAgent: { - type: 'string', - metadata: { - description: - 'Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns the user agent string for the current browser', - }, - }, - }, + "WebPixelsNavigator": { + "metadata": { + "description": "A snapshot of a subset of properties of the `navigator` object in the top frame of the browser" + }, + "properties": { + "cookieEnabled": { + "type": "boolean", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns `false` if setting a cookie will be ignored and true otherwise" + } + }, + "language": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns a string representing the preferred language of the user, usually the language of the browser UI. The `null` value is returned when this is unknown" + } + }, + "languages": { + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns an array of strings representing the languages known to the user, by order of preference", + "typescriptType": "ReadonlyArray" + } + }, + "userAgent": { + "type": "string", + "metadata": { + "description": "Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns the user agent string for the current browser" + } + } + } }, - EventType: { - enum: ['standard', 'dom', 'custom'], + "EventType": { + "enum": [ + "standard", + "dom", + "custom" + ] }, - Id: { - type: 'string', - metadata: { - description: 'The ID of the customer event', - }, + "Id": { + "type": "string", + "metadata": { + "description": "The ID of the customer event" + } }, - ClientId: { - type: 'string', - metadata: { - description: 'The client-side ID of the customer, provided by Shopify', - }, + "ClientId": { + "type": "string", + "metadata": { + "description": "The client-side ID of the customer, provided by Shopify" + } }, - Name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - }, + "Name": { + "type": "string", + "metadata": { + "description": "The name of the customer event" + } }, - Timestamp: { - type: 'string', - metadata: { - description: - 'The timestamp of when the customer event occurred, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format', - }, + "Timestamp": { + "type": "string", + "metadata": { + "description": "The timestamp of when the customer event occurred, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format" + } }, - Data: { - metadata: { - description: - 'A free-form object representing data specific to this event provided by Shopify. Refer to [standard events](#standard-events) for details on the payload available to each event', - typescriptType: 'Record', - }, + "Data": { + "metadata": { + "description": "A free-form object representing data specific to this event provided by Shopify. Refer to [standard events](#standard-events) for details on the payload available to each event", + "typescriptType": "Record" + } }, - Attribute: { - metadata: { - description: - 'Custom attributes left by the customer to the merchant, either in their cart or during checkout.', - }, - properties: { - key: { - type: 'string', - metadata: { - description: 'The key for the attribute.', - }, - }, - value: { - type: 'string', - metadata: { - description: 'The value for the attribute.', - }, - }, - }, + "Attribute": { + "metadata": { + "description": "Custom attributes left by the customer to the merchant, either in their cart or during checkout." + }, + "properties": { + "key": { + "type": "string", + "metadata": { + "description": "The key for the attribute." + } + }, + "value": { + "type": "string", + "metadata": { + "description": "The value for the attribute." + } + } + } }, - Checkout: { - metadata: { - description: - 'A container for all the information required to add items to checkout and pay.', - }, - properties: { - attributes: { - metadata: { - description: - 'A list of attributes accumulated throughout the checkout process.', - }, - elements: { - ref: 'Attribute', - }, - }, - billingAddress: { - ref: 'MailingAddress', - nullable: true, - metadata: { - description: - 'The billing address to where the order will be charged.', - }, - }, - currencyCode: { - type: 'string', - metadata: { - description: - 'The three-letter code that represents the currency, for example, USD. Supported codes include standard ISO 4217 codes, legacy codes, and non-standard codes.', - }, - }, - discountApplications: { - metadata: { - description: 'A list of discount applications.', - }, - elements: { - ref: 'DiscountApplication', - }, - }, - email: { - type: 'string', - nullable: true, - metadata: { - description: 'The email attached to this checkout.', - }, - }, - lineItems: { - metadata: { - description: - 'A list of line item objects, each one containing information about an item in the checkout.', - }, - elements: { - ref: 'CheckoutLineItem', - }, - }, - order: { - ref: 'Order', - nullable: true, - metadata: { - description: 'The resulting order from a paid checkout.', - }, - }, - phone: { - type: 'string', - nullable: true, - metadata: { - description: - 'A unique phone number for the customer. Formatted using E.164 standard. For example, *+16135551111*.', - }, - }, - shippingAddress: { - ref: 'MailingAddress', - nullable: true, - metadata: { - description: - 'The shipping address to where the line items will be shipped.', - }, - }, - shippingLine: { - ref: 'ShippingRate', - nullable: true, - metadata: { - description: - 'Once a shipping rate is selected by the customer it is transitioned to a `shipping_line` object.', - }, - }, - subtotalPrice: { - ref: 'MoneyV2', - metadata: { - description: - 'The price at checkout before duties, shipping, and taxes.', - }, - }, - token: { - type: 'string', - metadata: { - description: 'A unique identifier for a particular checkout.', - }, - }, - totalPrice: { - ref: 'MoneyV2', - metadata: { - description: - 'The sum of all the prices of all the items in the checkout, including duties, taxes, and discounts.', - }, - }, - totalTax: { - ref: 'MoneyV2', - metadata: { - description: - 'The sum of all the taxes applied to the line items and shipping lines in the checkout.', - }, - }, - transactions: { - metadata: { - description: - 'A list of transactions associated with a checkout or order.', - }, - elements: { - ref: 'Transaction', - }, - }, - }, + "Checkout": { + "metadata": { + "description": "A container for all the information required to add items to checkout and pay." + }, + "properties": { + "attributes": { + "metadata": { + "description": "A list of attributes accumulated throughout the checkout process." + }, + "elements": { + "ref": "Attribute" + } + }, + "billingAddress": { + "ref": "MailingAddress", + "nullable": true, + "metadata": { + "description": "The billing address to where the order will be charged." + } + }, + "currencyCode": { + "type": "string", + "metadata": { + "description": "The three-letter code that represents the currency, for example, USD. Supported codes include standard ISO 4217 codes, legacy codes, and non-standard codes." + } + }, + "discountApplications": { + "metadata": { + "description": "A list of discount applications." + }, + "elements": { + "ref": "DiscountApplication" + } + }, + "email": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The email attached to this checkout." + } + }, + "lineItems": { + "metadata": { + "description": "A list of line item objects, each one containing information about an item in the checkout." + }, + "elements": { + "ref": "CheckoutLineItem" + } + }, + "order": { + "ref": "Order", + "nullable": true, + "metadata": { + "description": "The resulting order from a paid checkout." + } + }, + "phone": { + "type": "string", + "nullable": true, + "metadata": { + "description": "A unique phone number for the customer. Formatted using E.164 standard. For example, *+16135551111*." + } + }, + "shippingAddress": { + "ref": "MailingAddress", + "nullable": true, + "metadata": { + "description": "The shipping address to where the line items will be shipped." + } + }, + "shippingLine": { + "ref": "ShippingRate", + "nullable": true, + "metadata": { + "description": "Once a shipping rate is selected by the customer it is transitioned to a `shipping_line` object." + } + }, + "subtotalPrice": { + "ref": "MoneyV2", + "metadata": { + "description": "The price at checkout before duties, shipping, and taxes." + } + }, + "token": { + "type": "string", + "metadata": { + "description": "A unique identifier for a particular checkout." + } + }, + "totalPrice": { + "ref": "MoneyV2", + "metadata": { + "description": "The sum of all the prices of all the items in the checkout, including duties, taxes, and discounts." + } + }, + "totalTax": { + "ref": "MoneyV2", + "metadata": { + "description": "The sum of all the taxes applied to the line items and shipping lines in the checkout." + } + }, + "transactions": { + "metadata": { + "description": "A list of transactions associated with a checkout or order." + }, + "elements": { + "ref": "Transaction" + } + } + } }, - CheckoutLineItem: { - metadata: { - description: - 'A single line item in the checkout, grouped by variant and attributes.', - }, - properties: { - discountAllocations: { - metadata: { - description: - 'The discounts that have been applied to the checkout line item by a discount application.', - }, - elements: { - ref: 'DiscountAllocation', - }, - }, - id: { - type: 'string', - metadata: { - description: 'A globally unique identifier.', - }, - }, - quantity: { - type: 'uint32', - metadata: { - description: 'The quantity of the line item.', - }, - }, - title: { - type: 'string', - nullable: true, - metadata: { - description: - "The title of the line item. Defaults to the product's title.", - }, - }, - variant: { - ref: 'ProductVariant', - nullable: true, - metadata: { - description: 'Product variant of the line item.', - }, - }, - }, + "CheckoutLineItem": { + "metadata": { + "description": "A single line item in the checkout, grouped by variant and attributes." + }, + "properties": { + "discountAllocations": { + "metadata": { + "description": "The discounts that have been applied to the checkout line item by a discount application." + }, + "elements": { + "ref": "DiscountAllocation" + } + }, + "id": { + "type": "string", + "metadata": { + "description": "A globally unique identifier." + } + }, + "quantity": { + "type": "uint32", + "metadata": { + "description": "The quantity of the line item." + } + }, + "title": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The title of the line item. Defaults to the product's title." + } + }, + "variant": { + "ref": "ProductVariant", + "nullable": true, + "metadata": { + "description": "Product variant of the line item." + } + } + } }, - DiscountAllocation: { - metadata: { - description: - 'The discount that has been applied to the checkout line item.', - }, - properties: { - amount: { - ref: 'MoneyV2', - metadata: { - description: - 'The monetary value with currency allocated to the discount.', - }, - }, - discountApplication: { - ref: 'DiscountApplication', - metadata: { - description: 'The information about the intent of the discount.', - }, - }, - }, + "DiscountAllocation": { + "metadata": { + "description": "The discount that has been applied to the checkout line item." + }, + "properties": { + "amount": { + "ref": "MoneyV2", + "metadata": { + "description": "The monetary value with currency allocated to the discount." + } + }, + "discountApplication": { + "ref": "DiscountApplication", + "metadata": { + "description": "The information about the intent of the discount." + } + } + } }, - DiscountApplication: { - metadata: { - description: 'The information about the intent of the discount.', - }, - properties: { - allocationMethod: { - type: 'string', - metadata: { - description: - "The method by which the discount's value is applied to its entitled items.\n\n- `ACROSS`: The value is spread across all entitled lines.\n- `EACH`: The value is applied onto every entitled line.\n", - enum: ['ACROSS', 'EACH'], - }, - }, - targetSelection: { - type: 'string', - metadata: { - description: - "How the discount amount is distributed on the discounted lines.\n\n- `ALL`: The discount is allocated onto all the lines.\n- `ENTITLED`: The discount is allocated onto only the lines that it's entitled for.\n- `EXPLICIT`: The discount is allocated onto explicitly chosen lines.\n", - enum: ['ALL', 'ENTITLED', 'EXPLICIT'], - }, - }, - targetType: { - type: 'string', - metadata: { - description: - 'The type of line (i.e. line item or shipping line) on an order that the discount is applicable towards.\n\n- `LINE_ITEM`: The discount applies onto line items.\n- `SHIPPING_LINE`: The discount applies onto shipping lines.\n', - enum: ['LINE_ITEM', 'SHIPPING_LINE'], - }, - }, - title: { - type: 'string', - metadata: { - description: - 'The customer-facing name of the discount. If the type of discount is a `DISCOUNT_CODE`, this `title` attribute represents the code of the discount.', - }, - }, - type: { - type: 'string', - metadata: { - description: - "The type of the discount.\n\n- `AUTOMATIC`: A discount automatically at checkout or in the cart without the need for a code.\n- `DISCOUNT_CODE`: A discount applied onto checkouts through the use of a code.\n- `MANUAL`: A discount that is applied to an order by a merchant or store owner manually, rather than being automatically applied by the system or through a script.\n- `SCRIPT`: A discount applied to a customer's order using a script\n", - enum: ['AUTOMATIC', 'DISCOUNT_CODE', 'MANUAL', 'SCRIPT'], - }, - }, - value: { - type: 'string', - metadata: { - typescriptType: 'MoneyV2 | PricingPercentageValue', - description: - 'The value of the discount. Fixed discounts return a `Money` Object, while Percentage discounts return a `PricingPercentageValue` object.', - }, - }, - }, + "DiscountApplication": { + "metadata": { + "description": "The information about the intent of the discount." + }, + "properties": { + "allocationMethod": { + "type": "string", + "metadata": { + "description": "The method by which the discount's value is applied to its entitled items.\n\n- `ACROSS`: The value is spread across all entitled lines.\n- `EACH`: The value is applied onto every entitled line.\n", + "enum": [ + "ACROSS", + "EACH" + ] + } + }, + "targetSelection": { + "type": "string", + "metadata": { + "description": "How the discount amount is distributed on the discounted lines.\n\n- `ALL`: The discount is allocated onto all the lines.\n- `ENTITLED`: The discount is allocated onto only the lines that it's entitled for.\n- `EXPLICIT`: The discount is allocated onto explicitly chosen lines.\n", + "enum": [ + "ALL", + "ENTITLED", + "EXPLICIT" + ] + } + }, + "targetType": { + "type": "string", + "metadata": { + "description": "The type of line (i.e. line item or shipping line) on an order that the discount is applicable towards.\n\n- `LINE_ITEM`: The discount applies onto line items.\n- `SHIPPING_LINE`: The discount applies onto shipping lines.\n", + "enum": [ + "LINE_ITEM", + "SHIPPING_LINE" + ] + } + }, + "title": { + "type": "string", + "metadata": { + "description": "The customer-facing name of the discount. If the type of discount is a `DISCOUNT_CODE`, this `title` attribute represents the code of the discount." + } + }, + "type": { + "type": "string", + "metadata": { + "description": "The type of the discount.\n\n- `AUTOMATIC`: A discount automatically at checkout or in the cart without the need for a code.\n- `DISCOUNT_CODE`: A discount applied onto checkouts through the use of a code.\n- `MANUAL`: A discount that is applied to an order by a merchant or store owner manually, rather than being automatically applied by the system or through a script.\n- `SCRIPT`: A discount applied to a customer's order using a script\n", + "enum": [ + "AUTOMATIC", + "DISCOUNT_CODE", + "MANUAL", + "SCRIPT" + ] + } + }, + "value": { + "type": "string", + "metadata": { + "typescriptType": "MoneyV2 | PricingPercentageValue", + "description": "The value of the discount. Fixed discounts return a `Money` Object, while Percentage discounts return a `PricingPercentageValue` object." + } + } + } }, - ProductVariant: { - metadata: { - description: - 'A product variant represents a different version of a product, such as differing sizes or differing colors.', - }, - properties: { - id: { - type: 'string', - metadata: { - description: 'A globally unique identifier.', - }, - }, - image: { - ref: 'Image', - nullable: true, - metadata: { - description: - 'Image associated with the product variant. This field falls back to the product image if no image is available.', - }, - }, - price: { - ref: 'MoneyV2', - metadata: { - description: 'The product variant’s price.', - }, - }, - product: { - ref: 'Product', - metadata: { - description: - 'The product object that the product variant belongs to.', - }, - }, - sku: { - type: 'string', - nullable: true, - metadata: { - description: - 'The SKU (stock keeping unit) associated with the variant.', - }, - }, - title: { - type: 'string', - metadata: { - description: 'The product variant’s title.', - }, - }, - untranslatedTitle: { - type: 'string', - metadata: { - description: 'The product variant’s untranslated title.', - }, - }, - }, + "ProductVariant": { + "metadata": { + "description": "A product variant represents a different version of a product, such as differing sizes or differing colors." + }, + "properties": { + "id": { + "type": "string", + "metadata": { + "description": "A globally unique identifier." + } + }, + "image": { + "ref": "Image", + "nullable": true, + "metadata": { + "description": "Image associated with the product variant. This field falls back to the product image if no image is available." + } + }, + "price": { + "ref": "MoneyV2", + "metadata": { + "description": "The product variant’s price." + } + }, + "product": { + "ref": "Product", + "metadata": { + "description": "The product object that the product variant belongs to." + } + }, + "sku": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The SKU (stock keeping unit) associated with the variant." + } + }, + "title": { + "type": "string", + "metadata": { + "description": "The product variant’s title." + } + }, + "untranslatedTitle": { + "type": "string", + "metadata": { + "description": "The product variant’s untranslated title." + } + } + } }, - Image: { - metadata: { - description: 'An image resource.', - }, - properties: { - src: { - type: 'string', - metadata: { - description: 'The location of the image as a URL.', - }, - }, - }, + "Image": { + "metadata": { + "description": "An image resource." + }, + "properties": { + "src": { + "type": "string", + "metadata": { + "description": "The location of the image as a URL." + } + } + } }, - MoneyV2: { - metadata: { - description: 'A monetary value with currency.', - }, - properties: { - amount: { - type: 'float64', - metadata: { - description: 'The decimal money amount.', - }, - }, - currencyCode: { - type: 'string', - metadata: { - description: - 'The three-letter code that represents the currency, for example, USD. Supported codes include standard ISO 4217 codes, legacy codes, and non-standard codes.', - }, - }, - }, + "MoneyV2": { + "metadata": { + "description": "A monetary value with currency." + }, + "properties": { + "amount": { + "type": "float64", + "metadata": { + "description": "The decimal money amount." + } + }, + "currencyCode": { + "type": "string", + "metadata": { + "description": "The three-letter code that represents the currency, for example, USD. Supported codes include standard ISO 4217 codes, legacy codes, and non-standard codes." + } + } + } }, - Product: { - metadata: { - description: - 'A product is an individual item for sale in a Shopify store.', - }, - properties: { - id: { - type: 'string', - metadata: { - description: 'The ID of the product.', - }, - }, - title: { - type: 'string', - metadata: { - description: 'The product’s title.', - }, - }, - untranslatedTitle: { - type: 'string', - metadata: { - description: 'The product’s untranslated title.', - }, - }, - url: { - type: 'string', - metadata: { - description: 'The relative URL of the product.', - }, - }, - vendor: { - type: 'string', - metadata: { - description: 'The product’s vendor name.', - }, - }, - type: { - type: 'string', - nullable: true, - metadata: { - description: - 'The [product type](https://help.shopify.com/en/manual/products/details/product-type) specified by the merchant.', - }, - }, - }, + "Product": { + "metadata": { + "description": "A product is an individual item for sale in a Shopify store." + }, + "properties": { + "id": { + "type": "string", + "metadata": { + "description": "The ID of the product." + } + }, + "title": { + "type": "string", + "metadata": { + "description": "The product’s title." + } + }, + "untranslatedTitle": { + "type": "string", + "metadata": { + "description": "The product’s untranslated title." + } + }, + "url": { + "type": "string", + "metadata": { + "description": "The relative URL of the product." + } + }, + "vendor": { + "type": "string", + "metadata": { + "description": "The product’s vendor name." + } + }, + "type": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The [product type](https://help.shopify.com/en/manual/products/details/product-type) specified by the merchant." + } + } + } }, - Order: { - metadata: { - description: - 'An order is a customer’s completed request to purchase one or more products from a shop. An order is created when a customer completes the checkout process.', - }, - properties: { - customer: { - ref: 'OrderCustomer', - nullable: true, - metadata: { - description: 'The customer that placed the order.', - }, - }, - id: { - type: 'string', - metadata: { - description: 'The ID of the order.', - }, - }, - }, + "Order": { + "metadata": { + "description": "An order is a customer’s completed request to purchase one or more products from a shop. An order is created when a customer completes the checkout process." + }, + "properties": { + "customer": { + "ref": "OrderCustomer", + "nullable": true, + "metadata": { + "description": "The customer that placed the order." + } + }, + "id": { + "type": "string", + "metadata": { + "description": "The ID of the order." + } + } + } }, - MailingAddress: { - metadata: { - description: 'A mailing address for customers and shipping.', - }, - properties: { - address1: { - type: 'string', - nullable: true, - metadata: { - description: - 'The first line of the address. This is usually the street address or a P.O. Box number.', - }, - }, - address2: { - type: 'string', - nullable: true, - metadata: { - description: - 'The second line of the address. This is usually an apartment, suite, or unit number.', - }, - }, - city: { - type: 'string', - nullable: true, - metadata: { - description: 'The name of the city, district, village, or town.', - }, - }, - country: { - type: 'string', - nullable: true, - metadata: { - description: 'The name of the country.', - }, - }, - countryCode: { - type: 'string', - nullable: true, - metadata: { - description: - 'The two-letter code that represents the country, for example, US.\nThe country codes generally follows ISO 3166-1 alpha-2 guidelines.\n', - }, - }, - firstName: { - type: 'string', - nullable: true, - metadata: { - description: 'The customer’s first name.', - }, - }, - lastName: { - type: 'string', - nullable: true, - metadata: { - description: 'The customer’s last name.', - }, - }, - phone: { - type: 'string', - nullable: true, - metadata: { - description: - 'The phone number for this mailing address as entered by the customer.', - }, - }, - province: { - type: 'string', - nullable: true, - metadata: { - description: - 'The region of the address, such as the province, state, or district.', - }, - }, - provinceCode: { - type: 'string', - nullable: true, - metadata: { - description: - 'The two-letter code for the region.\nFor example, ON.\n', - }, - }, - zip: { - type: 'string', - nullable: true, - metadata: { - description: 'The ZIP or postal code of the address.', - }, - }, - }, + "MailingAddress": { + "metadata": { + "description": "A mailing address for customers and shipping." + }, + "properties": { + "address1": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The first line of the address. This is usually the street address or a P.O. Box number." + } + }, + "address2": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The second line of the address. This is usually an apartment, suite, or unit number." + } + }, + "city": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The name of the city, district, village, or town." + } + }, + "country": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The name of the country." + } + }, + "countryCode": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The two-letter code that represents the country, for example, US.\nThe country codes generally follows ISO 3166-1 alpha-2 guidelines.\n" + } + }, + "firstName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The customer’s first name." + } + }, + "lastName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The customer’s last name." + } + }, + "phone": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The phone number for this mailing address as entered by the customer." + } + }, + "province": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The region of the address, such as the province, state, or district." + } + }, + "provinceCode": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The two-letter code for the region.\nFor example, ON.\n" + } + }, + "zip": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The ZIP or postal code of the address." + } + } + } }, - ShippingRate: { - metadata: { - description: 'A shipping rate to be applied to a checkout.', - }, - properties: { - price: { - ref: 'MoneyV2', - metadata: { - description: 'Price of this shipping rate.', - }, - }, - }, + "ShippingRate": { + "metadata": { + "description": "A shipping rate to be applied to a checkout." + }, + "properties": { + "price": { + "ref": "MoneyV2", + "metadata": { + "description": "Price of this shipping rate." + } + } + } }, - Cart: { - metadata: { - description: - 'A cart represents the merchandise that a customer intends to purchase, and the estimated cost associated with the cart.', - }, - properties: { - cost: { - ref: 'CartCost', - metadata: { - description: - 'The estimated costs that the customer will pay at checkout.', - }, - }, - id: { - type: 'string', - metadata: { - description: 'A globally unique identifier.', - }, - }, - lines: { - elements: { - ref: 'CartLine', - metadata: { - description: - 'A list of lines containing information about the items the customer intends to purchase.', - }, - }, - }, - totalQuantity: { - type: 'uint32', - metadata: { - description: 'The total number of items in the cart.', - }, - }, - }, + "Cart": { + "metadata": { + "description": "A cart represents the merchandise that a customer intends to purchase, and the estimated cost associated with the cart." + }, + "properties": { + "cost": { + "ref": "CartCost", + "metadata": { + "description": "The estimated costs that the customer will pay at checkout." + } + }, + "id": { + "type": "string", + "metadata": { + "description": "A globally unique identifier." + } + }, + "lines": { + "elements": { + "ref": "CartLine", + "metadata": { + "description": "A list of lines containing information about the items the customer intends to purchase." + } + } + }, + "totalQuantity": { + "type": "uint32", + "metadata": { + "description": "The total number of items in the cart." + } + } + } }, - CartCost: { - metadata: { - description: - 'The costs that the customer will pay at checkout. It uses [`CartBuyerIdentity`](https://shopify.dev/api/storefront/reference/cart/cartbuyeridentity) to determine [international pricing](https://shopify.dev/custom-storefronts/internationalization/international-pricing#create-a-cart).\n', - }, - properties: { - totalAmount: { - ref: 'MoneyV2', - metadata: { - description: 'The total amount for the customer to pay.', - }, - }, - }, + "CartCost": { + "metadata": { + "description": "The costs that the customer will pay at checkout. It uses [`CartBuyerIdentity`](https://shopify.dev/api/storefront/reference/cart/cartbuyeridentity) to determine [international pricing](https://shopify.dev/custom-storefronts/internationalization/international-pricing#create-a-cart).\n" + }, + "properties": { + "totalAmount": { + "ref": "MoneyV2", + "metadata": { + "description": "The total amount for the customer to pay." + } + } + } }, - CartLine: { - metadata: { - description: 'Information about the merchandise in the cart.', - }, - properties: { - cost: { - ref: 'CartLineCost', - metadata: { - description: - 'The cost of the merchandise that the customer will pay for at checkout. The costs are subject to change and changes will be reflected at checkout.', - }, - }, - merchandise: { - ref: 'ProductVariant', - metadata: { - description: 'The merchandise that the buyer intends to purchase.', - }, - }, - quantity: { - type: 'uint32', - metadata: { - description: - 'The quantity of the merchandise that the customer intends to purchase.', - }, - }, - }, + "CartLine": { + "metadata": { + "description": "Information about the merchandise in the cart." + }, + "properties": { + "cost": { + "ref": "CartLineCost", + "metadata": { + "description": "The cost of the merchandise that the customer will pay for at checkout. The costs are subject to change and changes will be reflected at checkout." + } + }, + "merchandise": { + "ref": "ProductVariant", + "metadata": { + "description": "The merchandise that the buyer intends to purchase." + } + }, + "quantity": { + "type": "uint32", + "metadata": { + "description": "The quantity of the merchandise that the customer intends to purchase." + } + } + } }, - CartLineCost: { - metadata: { - description: - 'The cost of the merchandise line that the customer will pay at checkout.', - }, - properties: { - totalAmount: { - ref: 'MoneyV2', - metadata: { - description: 'The total cost of the merchandise line.', - }, - }, - }, + "CartLineCost": { + "metadata": { + "description": "The cost of the merchandise line that the customer will pay at checkout." + }, + "properties": { + "totalAmount": { + "ref": "MoneyV2", + "metadata": { + "description": "The total cost of the merchandise line." + } + } + } }, - OrderCustomer: { - metadata: { - description: 'The customer that placed the order.', - }, - properties: { - id: { - type: 'string', - nullable: true, - metadata: { - description: 'The ID of the customer.', - }, - }, - }, + "OrderCustomer": { + "metadata": { + "description": "The customer that placed the order." + }, + "properties": { + "id": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The ID of the customer." + } + } + } }, - Customer: { - metadata: { - description: - 'A customer represents a customer account with the shop. Customer accounts store contact information for the customer, saving logged-in customers the trouble of having to provide it at every checkout.', - }, - properties: { - email: { - type: 'string', - nullable: true, - metadata: { - description: 'The customer’s email address.', - }, - }, - firstName: { - type: 'string', - nullable: true, - metadata: { - description: 'The customer’s first name.', - }, - }, - id: { - type: 'string', - metadata: { - description: 'The ID of the customer.', - }, - }, - lastName: { - type: 'string', - nullable: true, - metadata: { - description: 'The customer’s last name.', - }, - }, - ordersCount: { - type: 'uint32', - nullable: true, - metadata: { - description: - 'The total number of orders that the customer has placed.', - }, - }, - phone: { - type: 'string', - nullable: true, - metadata: { - description: 'The customer’s phone number.', - }, - }, - }, + "Customer": { + "metadata": { + "description": "A customer represents a customer account with the shop. Customer accounts store contact information for the customer, saving logged-in customers the trouble of having to provide it at every checkout." + }, + "properties": { + "email": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The customer’s email address." + } + }, + "firstName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The customer’s first name." + } + }, + "id": { + "type": "string", + "metadata": { + "description": "The ID of the customer." + } + }, + "lastName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The customer’s last name." + } + }, + "ordersCount": { + "type": "uint32", + "nullable": true, + "metadata": { + "description": "The total number of orders that the customer has placed." + } + }, + "phone": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The customer’s phone number." + } + } + } }, - Collection: { - metadata: { - description: - 'A collection is a group of products that a shop owner can create to organize them or make their shops easier to browse.', - }, - properties: { - id: { - type: 'string', - metadata: { - description: 'A globally unique identifier.', - }, - }, - title: { - type: 'string', - metadata: { - description: - 'The collection’s name. Maximum length: 255 characters.', - }, - }, - productVariants: { - elements: { - ref: 'ProductVariant', - metadata: { - description: - 'A list of products in the collection. The first product variant for each product is returned.', - }, - }, - }, - }, + "Collection": { + "metadata": { + "description": "A collection is a group of products that a shop owner can create to organize them or make their shops easier to browse." + }, + "properties": { + "id": { + "type": "string", + "metadata": { + "description": "A globally unique identifier." + } + }, + "title": { + "type": "string", + "metadata": { + "description": "The collection’s name. Maximum length: 255 characters." + } + }, + "productVariants": { + "elements": { + "ref": "ProductVariant", + "metadata": { + "description": "A list of products in the collection. The first product variant for each product is returned." + } + } + } + } }, - PricingPercentageValue: { - metadata: { - description: - 'A value given to a customer when a discount is applied to an order. The application of a discount with this value gives the customer the specified percentage off a specified item.', - }, - properties: { - percentage: { - type: 'float64', - metadata: { - description: 'The percentage value of the object.', - }, - }, - }, + "PricingPercentageValue": { + "metadata": { + "description": "A value given to a customer when a discount is applied to an order. The application of a discount with this value gives the customer the specified percentage off a specified item." + }, + "properties": { + "percentage": { + "type": "float64", + "metadata": { + "description": "The percentage value of the object." + } + } + } }, - SearchResult: { - metadata: { - description: - 'An object that contains the metadata of when a search has been performed.', - }, - properties: { - query: { - type: 'string', - metadata: { - description: 'The search query that was executed', - }, - }, - productVariants: { - elements: { - ref: 'ProductVariant', - metadata: { - description: - 'A list of products returned by the search query. The first product variant for each product is returned', - }, - }, - }, - }, + "SearchResult": { + "metadata": { + "description": "An object that contains the metadata of when a search has been performed." + }, + "properties": { + "query": { + "type": "string", + "metadata": { + "description": "The search query that was executed" + } + }, + "productVariants": { + "elements": { + "ref": "ProductVariant", + "metadata": { + "description": "A list of products returned by the search query. The first product variant for each product is returned" + } + } + } + } }, - Transaction: { - metadata: { - description: 'A transaction associated with a checkout or order.', - }, - properties: { - amount: { - ref: 'MoneyV2', - metadata: { - description: - 'The monetary value with currency allocated to the transaction method.', - }, - }, - gateway: { - type: 'string', - metadata: { - description: - 'The name of the payment provider used for the transaction.', - }, - }, - }, + "Transaction": { + "metadata": { + "description": "A transaction associated with a checkout or order." + }, + "properties": { + "amount": { + "ref": "MoneyV2", + "metadata": { + "description": "The monetary value with currency allocated to the transaction method." + } + }, + "gateway": { + "type": "string", + "metadata": { + "description": "The name of the payment provider used for the transaction." + } + } + } }, - InputElement: { - metadata: { - description: 'An object that contains data about an input element type', - }, - properties: { - id: { - type: 'string', - nullable: true, - metadata: { - description: 'The id attribute of an element', - }, - }, - name: { - type: 'string', - nullable: true, - metadata: { - description: 'The name attribute of an element', - }, - }, - tagName: { - type: 'string', - nullable: true, - metadata: { - description: 'A string representation of the tag of an element', - }, - }, - type: { - type: 'string', - nullable: true, - metadata: { - description: - 'The type attribute of an element. Often relevant for an input or button element.', - }, - }, - value: { - type: 'string', - nullable: true, - metadata: { - description: - 'The value attribute of an element. Often relevant for an input element.', - }, - }, - }, + "Shop": { + "metadata": { + "description": "The shop represents information about the store, such as the store name and currency." + }, + "properties": { + "name": { + "type": "string", + "metadata": { + "description": "The shop’s name." + } + }, + "paymentSettings": { + "metadata": { + "description": "Settings related to payments." + }, + "properties": { + "currencyCode": { + "type": "string", + "metadata": { + "description": "The three-letter code for the shop’s primary currency." + } + } + } + }, + "myshopifyDomain": { + "type": "string", + "metadata": { + "description": "The shop’s myshopify.com domain." + } + }, + "storefrontUrl": { + "type": "string", + "metadata": { + "description": "The shop’s primary storefront URL." + } + } + } }, - FormElement: { - metadata: { - description: 'An object that contains data about a form element type', - }, - properties: { - action: { - type: 'string', - nullable: true, - metadata: { - description: 'The action attribute of a form element', - }, - }, - id: { - type: 'string', - nullable: true, - metadata: { - description: 'The id attribute of an element', - }, - }, - elements: { - elements: { - ref: 'InputElement', - }, - }, - }, + "InputElement": { + "metadata": { + "description": "An object that contains data about an input element type" + }, + "properties": { + "id": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The id attribute of an element" + } + }, + "name": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The name attribute of an element" + } + }, + "tagName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "A string representation of the tag of an element" + } + }, + "type": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The type attribute of an element. Often relevant for an input or button element." + } + }, + "value": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The value attribute of an element. Often relevant for an input element." + } + } + } }, - GenericElement: { - metadata: { - description: - 'An object that contains data about a generic element type', - }, - properties: { - href: { - type: 'string', - nullable: true, - metadata: { - description: 'The href attribute of an element', - }, - }, - id: { - type: 'string', - nullable: true, - metadata: { - description: 'The id attribute of an element', - }, - }, - name: { - type: 'string', - nullable: true, - metadata: { - description: 'The name attribute of an element', - }, - }, - tagName: { - type: 'string', - nullable: true, - metadata: { - description: 'A string representation of the tag of an element', - }, - }, - type: { - type: 'string', - nullable: true, - metadata: { - description: - 'The type attribute of an element. Often relevant for an input or button element.', - }, - }, - value: { - type: 'string', - nullable: true, - metadata: { - description: - 'The value attribute of an element. Often relevant for an input element.', - }, - }, - }, + "FormElement": { + "metadata": { + "description": "An object that contains data about a form element type" + }, + "properties": { + "action": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The action attribute of a form element" + } + }, + "id": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The id attribute of an element" + } + }, + "elements": { + "elements": { + "ref": "InputElement" + } + } + } }, - CustomData: { - metadata: { - description: - 'A free-form object representing data specific to a custom event provided by the custom event publisher', - typescriptType: 'Record', - }, + "GenericElement": { + "metadata": { + "description": "An object that contains data about a generic element type" + }, + "properties": { + "href": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The href attribute of an element" + } + }, + "id": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The id attribute of an element" + } + }, + "name": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The name attribute of an element" + } + }, + "tagName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "A string representation of the tag of an element" + } + }, + "type": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The type attribute of an element. Often relevant for an input or button element." + } + }, + "value": { + "type": "string", + "nullable": true, + "metadata": { + "description": "The value attribute of an element. Often relevant for an input element." + } + } + } }, - CustomEvent: { - metadata: { - description: - 'This event represents any custom events emitted by partners or merchants via the `publish` method', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Custom', - }, - }, - name: { - type: 'string', - metadata: { - description: 'Arbitrary name of the custom event', - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - customData: { - nullable: true, - ref: 'CustomData', - }, - }, + "CustomData": { + "metadata": { + "description": "A free-form object representing data specific to a custom event provided by the custom event publisher", + "typescriptType": "Record" + } }, + "CustomEvent": { + "metadata": { + "description": "This event represents any custom events emitted by partners or merchants via the `publish` method" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Custom" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "Arbitrary name of the custom event" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "customData": { + "nullable": true, + "ref": "CustomData" + } + } + } }, - properties: { - checkout_address_info_submitted: { - metadata: { - description: - 'The `checkout_address_info_submitted` event logs an instance of a customer submitting their mailing address. This event is only available in checkouts where Checkout Extensibility for customizations is enabled', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'checkout_address_info_submitted'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - checkout: { - ref: 'Checkout', - }, - }, - }, - }, + "properties": { + "checkout_address_info_submitted": { + "metadata": { + "description": "The `checkout_address_info_submitted` event logs an instance of a customer submitting their mailing address. This event is only available in checkouts where Checkout Extensibility for customizations is enabled" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'checkout_address_info_submitted'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "checkout": { + "ref": "Checkout" + } + } + } + } }, - checkout_completed: { - metadata: { - description: - 'The `checkout_completed` event logs when a visitor completes a purchase. This event is available on the **Order status** and checkout pages', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'checkout_completed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - checkout: { - ref: 'Checkout', - }, - }, - }, - }, + "checkout_completed": { + "metadata": { + "description": "The `checkout_completed` event logs when a visitor completes a purchase. This event is available on the **Order status** and checkout pages" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'checkout_completed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "checkout": { + "ref": "Checkout" + } + } + } + } }, - checkout_started: { - metadata: { - description: - 'The `checkout_started` event logs an instance of a customer starting the checkout process. This event is available on the checkout page. For Checkout Extensibility, this event is triggered every time a customer enters checkout. For non-checkout extensible shops, this event is only triggered the first time a customer enters checkout.', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'checkout_started'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - checkout: { - ref: 'Checkout', - }, - }, - }, - }, + "checkout_started": { + "metadata": { + "description": "The `checkout_started` event logs an instance of a customer starting the checkout process. This event is available on the checkout page. For Checkout Extensibility, this event is triggered every time a customer enters checkout. For non-checkout extensible shops, this event is only triggered the first time a customer enters checkout." + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'checkout_started'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "checkout": { + "ref": "Checkout" + } + } + } + } }, - payment_info_submitted: { - metadata: { - description: - 'The `payment_info_submitted` event logs an instance of a customer submitting their payment information. This event is available on the checkout page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'payment_info_submitted'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - checkout: { - ref: 'Checkout', - }, - }, - }, - }, + "payment_info_submitted": { + "metadata": { + "description": "The `payment_info_submitted` event logs an instance of a customer submitting their payment information. This event is available on the checkout page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'payment_info_submitted'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "checkout": { + "ref": "Checkout" + } + } + } + } }, - collection_viewed: { - metadata: { - description: - 'The `collection_viewed` event logs an instance where a customer visited a product collection index page. This event is available on the online store page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'collection_viewed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - collection: { - ref: 'Collection', - }, - }, - }, - }, + "collection_viewed": { + "metadata": { + "description": "The `collection_viewed` event logs an instance where a customer visited a product collection index page. This event is available on the online store page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'collection_viewed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "collection": { + "ref": "Collection" + } + } + } + } }, - checkout_contact_info_submitted: { - metadata: { - description: - 'The `checkout_contact_info_submitted` event logs an instance where a customer submits a checkout form. This event is only available in checkouts where Checkout Extensibility for customizations is enabled', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'checkout_contact_info_submitted'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - checkout: { - ref: 'Checkout', - }, - }, - }, - }, + "checkout_contact_info_submitted": { + "metadata": { + "description": "The `checkout_contact_info_submitted` event logs an instance where a customer submits a checkout form. This event is only available in checkouts where Checkout Extensibility for customizations is enabled" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'checkout_contact_info_submitted'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "checkout": { + "ref": "Checkout" + } + } + } + } }, - page_viewed: { - metadata: { - description: - 'The `page_viewed` event logs an instance where a customer visited a page. This event is available on the online store, checkout, and **Order status** pages', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'page_viewed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: {}, - }, - }, + "page_viewed": { + "metadata": { + "description": "The `page_viewed` event logs an instance where a customer visited a page. This event is available on the online store, checkout, and **Order status** pages" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'page_viewed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": {} + } + } }, - product_added_to_cart: { - metadata: { - description: - 'The `product_added_to_cart` event logs an instance where a customer adds a product to their cart. This event is available on the online store page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'product_added_to_cart'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - cartLine: { - nullable: true, - ref: 'CartLine', - }, - }, - }, - }, + "product_added_to_cart": { + "metadata": { + "description": "The `product_added_to_cart` event logs an instance where a customer adds a product to their cart. This event is available on the online store page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'product_added_to_cart'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "cartLine": { + "nullable": true, + "ref": "CartLine" + } + } + } + } }, - product_removed_from_cart: { - metadata: { - description: - 'The `product_removed_from_cart` event logs an instance where a customer removes a product from their cart. This event is available on the online store page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'product_removed_from_cart'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - cartLine: { - nullable: true, - ref: 'CartLine', - }, - }, - }, - }, + "product_removed_from_cart": { + "metadata": { + "description": "The `product_removed_from_cart` event logs an instance where a customer removes a product from their cart. This event is available on the online store page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'product_removed_from_cart'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "cartLine": { + "nullable": true, + "ref": "CartLine" + } + } + } + } }, - product_viewed: { - metadata: { - description: - 'The `product_viewed` event logs an instance where a customer visited a product details page. This event is available on the product page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'product_viewed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - productVariant: { - ref: 'ProductVariant', - }, - }, - }, - }, + "product_viewed": { + "metadata": { + "description": "The `product_viewed` event logs an instance where a customer visited a product details page. This event is available on the product page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'product_viewed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "productVariant": { + "ref": "ProductVariant" + } + } + } + } }, - product_variant_viewed: { - metadata: { - description: - 'The `product_variant_viewed` event logs an instance where a customer interacts with the product page and views a different variant than the initial `product_viewed` impression. This event is available on the Product page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'product_variant_viewed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - productVariant: { - ref: 'ProductVariant', - }, - }, - }, - }, + "product_variant_viewed": { + "metadata": { + "description": "The `product_variant_viewed` event logs an instance where a customer interacts with the product page and views a different variant than the initial `product_viewed` impression. This event is available on the Product page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'product_variant_viewed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "productVariant": { + "ref": "ProductVariant" + } + } + } + } }, - search_submitted: { - metadata: { - description: - 'The `search_submitted` event logs an instance where a customer performed a search on the storefront. This event is available on the online store page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'search_submitted'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - searchResult: { - ref: 'SearchResult', - }, - }, - }, - }, + "search_submitted": { + "metadata": { + "description": "The `search_submitted` event logs an instance where a customer performed a search on the storefront. This event is available on the online store page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'search_submitted'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "searchResult": { + "ref": "SearchResult" + } + } + } + } }, - cart_viewed: { - metadata: { - description: - 'The `cart_viewed` event logs an instance where a customer visited the cart page', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'cart_viewed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - cart: { - nullable: true, - ref: 'Cart', - }, - }, - }, - }, - }, - checkout_shipping_info_submitted: { - metadata: { - description: - 'The `checkout_shipping_info_submitted` event logs an instance where the customer chooses a shipping rate. This event is only available in checkouts where Checkout Extensibility for customizations is enabled', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Standard', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'checkout_shipping_info_submitted'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - context: { - ref: 'Context', - }, - data: { - properties: { - checkout: { - ref: 'Checkout', - }, - }, - }, - }, + "cart_viewed": { + "metadata": { + "description": "The `cart_viewed` event logs an instance where a customer visited the cart page" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'cart_viewed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "cart": { + "nullable": true, + "ref": "Cart" + } + } + } + } }, - input_changed: { - metadata: { - description: - 'The `input_changed` event logs an instance where an input, textarea, or select element on the page has changed', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Dom', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'input_changed'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - data: { - properties: { - element: { - ref: 'InputElement', - }, - }, - }, - }, + "checkout_shipping_info_submitted": { + "metadata": { + "description": "The `checkout_shipping_info_submitted` event logs an instance where the customer chooses a shipping rate. This event is only available in checkouts where Checkout Extensibility for customizations is enabled" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Standard" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'checkout_shipping_info_submitted'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "context": { + "ref": "Context" + }, + "data": { + "properties": { + "checkout": { + "ref": "Checkout" + } + } + } + } }, - input_blurred: { - metadata: { - description: - 'The `input_blurred` event logs an instance where an input, textarea, or select element on the page has lost focus', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Dom', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'input_blurred'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - data: { - properties: { - element: { - ref: 'InputElement', - }, - }, - }, - }, + "input_changed": { + "metadata": { + "description": "The `input_changed` event logs an instance where an input, textarea, or select element on the page has changed" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Dom" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'input_changed'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "data": { + "properties": { + "element": { + "ref": "InputElement" + } + } + } + } }, - input_focused: { - metadata: { - description: - 'The `input_focused` event logs an instance where an input, textarea, or select element on the page has received focus', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Dom', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'input_focused'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - data: { - properties: { - element: { - ref: 'InputElement', - }, - }, - }, - }, + "input_blurred": { + "metadata": { + "description": "The `input_blurred` event logs an instance where an input, textarea, or select element on the page has lost focus" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Dom" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'input_blurred'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "data": { + "properties": { + "element": { + "ref": "InputElement" + } + } + } + } }, - form_submitted: { - metadata: { - description: - 'The `form_submitted` event logs an instance where a form element on the page has been submitted', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Dom', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'form_submitted'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - data: { - properties: { - element: { - ref: 'FormElement', - }, - }, - }, - }, + "input_focused": { + "metadata": { + "description": "The `input_focused` event logs an instance where an input, textarea, or select element on the page has received focus" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Dom" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'input_focused'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "data": { + "properties": { + "element": { + "ref": "InputElement" + } + } + } + } }, - clicked: { - metadata: { - description: - 'The `clicked` event logs an instance where any element on the page has been clicked', - }, - properties: { - id: { - ref: 'Id', - }, - clientId: { - ref: 'ClientId', - }, - type: { - type: 'string', - metadata: { - typescriptType: 'EventType.Dom', - }, - }, - name: { - type: 'string', - metadata: { - description: 'The name of the customer event', - typescriptType: "'clicked'", - }, - }, - timestamp: { - ref: 'Timestamp', - }, - data: { - properties: { - element: { - ref: 'GenericElement', - }, - }, - }, - }, + "form_submitted": { + "metadata": { + "description": "The `form_submitted` event logs an instance where a form element on the page has been submitted" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Dom" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'form_submitted'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "data": { + "properties": { + "element": { + "ref": "FormElement" + } + } + } + } }, - }, + "clicked": { + "metadata": { + "description": "The `clicked` event logs an instance where any element on the page has been clicked" + }, + "properties": { + "id": { + "ref": "Id" + }, + "clientId": { + "ref": "ClientId" + }, + "type": { + "type": "string", + "metadata": { + "typescriptType": "EventType.Dom" + } + }, + "name": { + "type": "string", + "metadata": { + "description": "The name of the customer event", + "typescriptType": "'clicked'" + } + }, + "timestamp": { + "ref": "Timestamp" + }, + "data": { + "properties": { + "element": { + "ref": "GenericElement" + } + } + } + } + } + } }; diff --git a/packages/web-pixels-extension/src/types/EventBus.ts b/packages/web-pixels-extension/src/types/EventBus.ts index c2c6d65dc..883196e9f 100644 --- a/packages/web-pixels-extension/src/types/EventBus.ts +++ b/packages/web-pixels-extension/src/types/EventBus.ts @@ -1,38 +1,3 @@ -import type {PixelEvents, CustomEvent, EventType} from './PixelEvents'; - -export type SchemaVersion = 'v1'; - -export type PixelEventName = keyof PixelEvents; - -type EventNameOfType = { - [K in PixelEventName]: PixelEvents[K] extends {type: T} ? K : never; -}[PixelEventName]; - -export type StandardEventName = EventNameOfType; -export type StandardEvent = PixelEvents[StandardEventName]; - -export type DomEventName = EventNameOfType; -export type DomEvent = PixelEvents[DomEventName]; - -export interface StandardEvents extends PixelEvents { - all_events: StandardEvent | CustomEvent | DomEvent; - all_standard_events: StandardEvent; - all_custom_events: CustomEvent; - all_dom_events: DomEvent; -} - -export type DomEvents = { - [key in DomEventName]: PixelEvents[key]; -}; - -export interface CustomEvents { - [key: string]: CustomEvent; -} - -export type Events = StandardEvents & CustomEvents; - -export type KeyOfEvent = Extract; - export type PublisherData

= P extends {data: infer T} ? T : never; export type PublisherCustomData

= P extends {customData: infer T} ? T @@ -47,27 +12,4 @@ export interface PublisherOptions extends Record { } export type SubscriberCallback = (event: T) => void; -export type SubscriberOptions = Record; - -export interface EventBus { - publish( - name: K, - payload: PublisherData, - options?: PublisherOptions, - ): boolean; - publishCustomEvent( - name: string, - payload?: PublisherCustomData, - options?: PublisherOptions, - ): boolean; - publishDomEvent( - name: K, - payload: PublisherData, - options?: PublisherOptions, - ): boolean; - subscribe>( - name: K, - callback: SubscriberCallback, - options?: SubscriberOptions, - ): () => boolean; -} +export type SubscriberOptions = Record; diff --git a/packages/web-pixels-extension/src/types/ExtensionApi.ts b/packages/web-pixels-extension/src/types/ExtensionApi.ts index cbaab34b1..9742acdfb 100644 --- a/packages/web-pixels-extension/src/types/ExtensionApi.ts +++ b/packages/web-pixels-extension/src/types/ExtensionApi.ts @@ -1,11 +1,11 @@ import type {Browser} from './PixelEvents'; -import type {EventBus} from './EventBus'; +import type {WebPixelsManager} from './WebPixelsManager'; import type {RegisterInit} from './RegisterInit'; export interface ExtensionApi { readonly settings: Record; readonly analytics: { - readonly subscribe: EventBus['subscribe']; + readonly subscribe: WebPixelsManager['subscribe']; }; readonly browser: Browser; readonly init: RegisterInit; diff --git a/packages/web-pixels-extension/src/types/PixelEvents/index.ts b/packages/web-pixels-extension/src/types/PixelEvents/index.ts index 2b0f7daab..92aeac1cf 100644 --- a/packages/web-pixels-extension/src/types/PixelEvents/index.ts +++ b/packages/web-pixels-extension/src/types/PixelEvents/index.ts @@ -1,7 +1,7 @@ // Code generated by jtd-codegen for TypeScript v0.2.1 export interface PixelEventsCartViewedData { - cart: Cart | null; + cart: (Cart | null); } /** @@ -266,7 +266,8 @@ export interface PixelEventsInputFocused { type: EventType.Dom; } -export interface PixelEventsPageViewedData {} +export interface PixelEventsPageViewedData { +} /** * The `page_viewed` event logs an instance where a customer visited a page. @@ -310,7 +311,7 @@ export interface PixelEventsPaymentInfoSubmitted { } export interface PixelEventsProductAddedToCartData { - cartLine: CartLine | null; + cartLine: (CartLine | null); } /** @@ -332,7 +333,7 @@ export interface PixelEventsProductAddedToCart { } export interface PixelEventsProductRemovedFromCartData { - cartLine: CartLine | null; + cartLine: (CartLine | null); } /** @@ -596,17 +597,13 @@ export interface BrowserLocalStorage { /** * When passed a key name, will return that key's value. */ - getItem: ( - key: string, - ) => Promise>; + getItem: (key: string) => Promise>; /** * When passed a number n, this method will return the name of the nth key in * the storage. */ - key: ( - index: number, - ) => Promise>; + key: (index: number) => Promise>; /** * Returns an integer representing the number of data items stored in the @@ -617,42 +614,31 @@ export interface BrowserLocalStorage { /** * When passed a key name, will remove that key from the storage. */ - removeItem: ( - key: string, - ) => Promise>; + removeItem: (key: string) => Promise>; /** * When passed a key name and value, will add that key to the storage, or * update that key's value if it already exists. */ - setItem: ( - key: string, - value: any, - ) => Promise>; + setItem: (key: string, value: any) => Promise>; } export interface BrowserSessionStorage { /** * When invoked, will empty all keys out of the storage. */ - clear: () => Promise< - ReturnType - >; + clear: () => Promise>; /** * When passed a key name, will return that key's value. */ - getItem: ( - key: string, - ) => Promise>; + getItem: (key: string) => Promise>; /** * When passed a number n, this method will return the name of the nth key in * the storage. */ - key: ( - index: number, - ) => Promise>; + key: (index: number) => Promise>; /** * Returns an integer representing the number of data items stored in the @@ -663,20 +649,13 @@ export interface BrowserSessionStorage { /** * When passed a key name, will remove that key from the storage. */ - removeItem: ( - key: string, - ) => Promise< - ReturnType - >; + removeItem: (key: string) => Promise>; /** * When passed a key name and value, will add that key to the storage, or * update that key's value if it already exists. */ - setItem: ( - key: string, - value: any, - ) => Promise>; + setItem: (key: string, value: any) => Promise>; } export interface Browser { @@ -776,7 +755,7 @@ export interface Checkout { /** * The billing address to where the order will be charged. */ - billingAddress: MailingAddress | null; + billingAddress: (MailingAddress | null); /** * The three-letter code that represents the currency, for example, USD. @@ -793,7 +772,7 @@ export interface Checkout { /** * The email attached to this checkout. */ - email: string | null; + email: (string | null); /** * A list of line item objects, each one containing information about an item @@ -804,24 +783,24 @@ export interface Checkout { /** * The resulting order from a paid checkout. */ - order: Order | null; + order: (Order | null); /** * A unique phone number for the customer. Formatted using E.164 standard. For * example, *+16135551111*. */ - phone: string | null; + phone: (string | null); /** * The shipping address to where the line items will be shipped. */ - shippingAddress: MailingAddress | null; + shippingAddress: (MailingAddress | null); /** * Once a shipping rate is selected by the customer it is transitioned to a * `shipping_line` object. */ - shippingLine: ShippingRate | null; + shippingLine: (ShippingRate | null); /** * The price at checkout before duties, shipping, and taxes. @@ -874,12 +853,12 @@ export interface CheckoutLineItem { /** * The title of the line item. Defaults to the product's title. */ - title: string | null; + title: (string | null); /** * Product variant of the line item. */ - variant: ProductVariant | null; + variant: (ProductVariant | null); } /** @@ -941,7 +920,7 @@ export type CustomData = Record; export interface CustomEvent { clientId: ClientId; context: Context; - customData: CustomData | null; + customData: (CustomData | null); id: Id; /** @@ -961,12 +940,12 @@ export interface Customer { /** * The customer’s email address. */ - email: string | null; + email: (string | null); /** * The customer’s first name. */ - firstName: string | null; + firstName: (string | null); /** * The ID of the customer. @@ -976,17 +955,17 @@ export interface Customer { /** * The customer’s last name. */ - lastName: string | null; + lastName: (string | null); /** * The total number of orders that the customer has placed. */ - ordersCount: number | null; + ordersCount: (number | null); /** * The customer’s phone number. */ - phone: string | null; + phone: (string | null); } /** @@ -1017,7 +996,7 @@ export interface DiscountAllocation { export interface DiscountApplication { /** * The method by which the discount's value is applied to its entitled items. - * + * * - `ACROSS`: The value is spread across all entitled lines. * - `EACH`: The value is applied onto every entitled line. */ @@ -1025,7 +1004,7 @@ export interface DiscountApplication { /** * How the discount amount is distributed on the discounted lines. - * + * * - `ALL`: The discount is allocated onto all the lines. * - `ENTITLED`: The discount is allocated onto only the lines that it's * entitled for. @@ -1036,7 +1015,7 @@ export interface DiscountApplication { /** * The type of line (i.e. line item or shipping line) on an order that the * discount is applicable towards. - * + * * - `LINE_ITEM`: The discount applies onto line items. * - `SHIPPING_LINE`: The discount applies onto shipping lines. */ @@ -1051,7 +1030,7 @@ export interface DiscountApplication { /** * The type of the discount. - * + * * - `AUTOMATIC`: A discount automatically at checkout or in the cart without * the need for a code. * - `DISCOUNT_CODE`: A discount applied onto checkouts through the use of @@ -1071,9 +1050,9 @@ export interface DiscountApplication { } export enum EventType { - Custom = 'custom', - Dom = 'dom', - Standard = 'standard', + Custom = "custom", + Dom = "dom", + Standard = "standard", } /** @@ -1083,13 +1062,13 @@ export interface FormElement { /** * The action attribute of a form element */ - action: string | null; + action: (string | null); elements: InputElement[]; /** * The id attribute of an element */ - id: string | null; + id: (string | null); } /** @@ -1099,33 +1078,33 @@ export interface GenericElement { /** * The href attribute of an element */ - href: string | null; + href: (string | null); /** * The id attribute of an element */ - id: string | null; + id: (string | null); /** * The name attribute of an element */ - name: string | null; + name: (string | null); /** * A string representation of the tag of an element */ - tagName: string | null; + tagName: (string | null); /** * The type attribute of an element. Often relevant for an input or button * element. */ - type: string | null; + type: (string | null); /** * The value attribute of an element. Often relevant for an input element. */ - value: string | null; + value: (string | null); } /** @@ -1144,10 +1123,11 @@ export interface Image { } export interface InitData { - cart: Cart | null; - checkout: Checkout | null; - customer: Customer | null; - productVariants: ProductVariant[] | null; + cart: (Cart | null); + checkout: (Checkout | null); + customer: (Customer | null); + productVariants: (ProductVariant[] | null); + shop: Shop; } /** @@ -1157,28 +1137,28 @@ export interface InputElement { /** * The id attribute of an element */ - id: string | null; + id: (string | null); /** * The name attribute of an element */ - name: string | null; + name: (string | null); /** * A string representation of the tag of an element */ - tagName: string | null; + tagName: (string | null); /** * The type attribute of an element. Often relevant for an input or button * element. */ - type: string | null; + type: (string | null); /** * The value attribute of an element. Often relevant for an input element. */ - value: string | null; + value: (string | null); } /** @@ -1252,60 +1232,60 @@ export interface MailingAddress { * The first line of the address. This is usually the street address or a P.O. * Box number. */ - address1: string | null; + address1: (string | null); /** * The second line of the address. This is usually an apartment, suite, or * unit number. */ - address2: string | null; + address2: (string | null); /** * The name of the city, district, village, or town. */ - city: string | null; + city: (string | null); /** * The name of the country. */ - country: string | null; + country: (string | null); /** * The two-letter code that represents the country, for example, US. * The country codes generally follows ISO 3166-1 alpha-2 guidelines. */ - countryCode: string | null; + countryCode: (string | null); /** * The customer’s first name. */ - firstName: string | null; + firstName: (string | null); /** * The customer’s last name. */ - lastName: string | null; + lastName: (string | null); /** * The phone number for this mailing address as entered by the customer. */ - phone: string | null; + phone: (string | null); /** * The region of the address, such as the province, state, or district. */ - province: string | null; + province: (string | null); /** * The two-letter code for the region. * For example, ON. */ - provinceCode: string | null; + provinceCode: (string | null); /** * The ZIP or postal code of the address. */ - zip: string | null; + zip: (string | null); } /** @@ -1339,7 +1319,7 @@ export interface Order { /** * The customer that placed the order. */ - customer: OrderCustomer | null; + customer: (OrderCustomer | null); /** * The ID of the order. @@ -1354,7 +1334,7 @@ export interface OrderCustomer { /** * The ID of the customer. */ - id: string | null; + id: (string | null); } /** @@ -1388,7 +1368,7 @@ export interface Product { * type](https://help.shopify.com/en/manual/products/details/product-type) * specified by the merchant. */ - type: string | null; + type: (string | null); /** * The product’s untranslated title. @@ -1420,7 +1400,7 @@ export interface ProductVariant { * Image associated with the product variant. This field falls back to the * product image if no image is available. */ - image: Image | null; + image: (Image | null); /** * The product variant’s price. @@ -1435,7 +1415,7 @@ export interface ProductVariant { /** * The SKU (stock keeping unit) associated with the variant. */ - sku: string | null; + sku: (string | null); /** * The product variant’s title. @@ -1488,6 +1468,42 @@ export interface ShippingRate { price: MoneyV2; } +/** + * Settings related to payments. + */ +export interface ShopPaymentSettings { + /** + * The three-letter code for the shop’s primary currency. + */ + currencyCode: string; +} + +/** + * The shop represents information about the store, such as the store name and + * currency. + */ +export interface Shop { + /** + * The shop’s myshopify.com domain. + */ + myshopifyDomain: string; + + /** + * The shop’s name. + */ + name: string; + + /** + * Settings related to payments. + */ + paymentSettings: ShopPaymentSettings; + + /** + * The shop’s primary storefront URL. + */ + storefrontUrl: string; +} + /** * The timestamp of when the customer event occurred, in [ISO * 8601](https://en.wikipedia.org/wiki/ISO_8601) format diff --git a/packages/web-pixels-extension/src/types/PublicApi.ts b/packages/web-pixels-extension/src/types/PublicApi.ts index 1c1056225..f1c615778 100644 --- a/packages/web-pixels-extension/src/types/PublicApi.ts +++ b/packages/web-pixels-extension/src/types/PublicApi.ts @@ -1,8 +1,8 @@ -import type {EventBus} from './EventBus'; +import type {WebPixelsManager} from './WebPixelsManager'; import type {VisitorApi} from './VisitorApi'; export interface PublicApi { - publish: EventBus['publish']; - publishCustomEvent: EventBus['publishCustomEvent']; + publish: WebPixelsManager['publish']; + publishCustomEvent: WebPixelsManager['publishCustomEvent']; visitor: VisitorApi['visitor']; } diff --git a/packages/web-pixels-extension/src/types/RegisterInit.ts b/packages/web-pixels-extension/src/types/RegisterInit.ts index 4f6c056ba..a32236b7d 100644 --- a/packages/web-pixels-extension/src/types/RegisterInit.ts +++ b/packages/web-pixels-extension/src/types/RegisterInit.ts @@ -1,6 +1,7 @@ import type { Context, Cart, + Shop, Checkout, Customer, ProductVariant, @@ -12,6 +13,7 @@ export interface RegisterInit { data: { customer: Partial | null; cart: Partial | null; + shop: Shop | null; }; } @@ -19,6 +21,7 @@ export interface RegisterInit { export interface InitData { customer?: Customer; cart?: Cart; + shop?: Shop; checkout?: Checkout; productVariants?: ProductVariant[]; } diff --git a/packages/web-pixels-extension/src/types/WebPixelsManager.ts b/packages/web-pixels-extension/src/types/WebPixelsManager.ts new file mode 100644 index 000000000..d5c0ec636 --- /dev/null +++ b/packages/web-pixels-extension/src/types/WebPixelsManager.ts @@ -0,0 +1,62 @@ +import type { + PublisherCustomData, + PublisherData, + PublisherOptions, + SubscriberCallback, + SubscriberOptions, +} from './EventBus'; +import type {PixelEvents, CustomEvent, EventType} from './PixelEvents'; + +export type SchemaVersion = 'v1'; + +export type PixelEventName = keyof PixelEvents; + +type EventNameOfType = { + [K in PixelEventName]: PixelEvents[K] extends {type: T} ? K : never; +}[PixelEventName]; + +export type StandardEventName = EventNameOfType; +export type StandardEvent = PixelEvents[StandardEventName]; + +export type DomEventName = EventNameOfType; +export type DomEvent = PixelEvents[DomEventName]; + +export interface StandardEvents extends PixelEvents { + all_events: StandardEvent | CustomEvent | DomEvent; + all_standard_events: StandardEvent; + all_custom_events: CustomEvent; + all_dom_events: DomEvent; +} + +export type DomEvents = { + [key in DomEventName]: PixelEvents[key]; +}; + +export interface CustomEvents { + [key: string]: CustomEvent; +} + +export type Events = StandardEvents & CustomEvents; + +export interface WebPixelsManager { + publish( + name: K, + payload: PublisherData, + options?: PublisherOptions, + ): boolean; + publishCustomEvent( + name: string, + payload?: PublisherCustomData, + options?: PublisherOptions, + ): boolean; + publishDomEvent( + name: K, + payload: PublisherData, + options?: PublisherOptions, + ): boolean; + subscribe( + name: K, + callback: SubscriberCallback, + options?: SubscriberOptions, + ): () => boolean; +} diff --git a/packages/web-pixels-extension/src/types/index.ts b/packages/web-pixels-extension/src/types/index.ts index 692d6ea69..6bbceeb5a 100644 --- a/packages/web-pixels-extension/src/types/index.ts +++ b/packages/web-pixels-extension/src/types/index.ts @@ -7,6 +7,7 @@ export type { Browser, Context, Cart, + Shop, CartLine, Customer, DiscountApplication, @@ -38,7 +39,8 @@ export type { PublisherOptions, SubscriberCallback, SubscriberOptions, - KeyOfEvent, +} from './EventBus'; +export type { StandardEvents, CustomEvents, DomEvents, @@ -46,6 +48,6 @@ export type { PixelEventName, StandardEventName, Events, - EventBus, SchemaVersion, -} from './EventBus'; + WebPixelsManager, +} from './WebPixelsManager';