This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Shopify/webhook_export_refactorings
Separating webhook types into their own file
- Loading branch information
Showing
13 changed files
with
113 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {SessionStorage} from './auth/session'; | ||
|
||
export interface ContextParams { | ||
API_KEY: string; | ||
API_SECRET_KEY: string; | ||
SCOPES: string[]; | ||
HOST_NAME: string; | ||
API_VERSION: ApiVersion; | ||
IS_EMBEDDED_APP: boolean; | ||
SESSION_STORAGE?: SessionStorage; | ||
} | ||
|
||
export enum ApiVersion { | ||
April19 = '2019-04', | ||
July19 = '2019-07', | ||
October19 = '2019-10', | ||
January20 = '2020-01', | ||
April20 = '2020-04', | ||
July20 = '2020-07', | ||
October20 = '2020-10', | ||
Unstable = 'unstable', | ||
Unversioned = 'unversioned', | ||
} | ||
|
||
export enum ShopifyHeader { | ||
AccessToken = 'X-Shopify-Access-Token', | ||
Hmac = 'X-Shopify-Hmac-Sha256', | ||
Topic = 'X-Shopify-Topic', | ||
Domain = 'X-Shopify-Shop-Domain', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,4 @@ | ||
import {SessionStorage} from './auth/session'; | ||
|
||
export interface ContextParams { | ||
API_KEY: string; | ||
API_SECRET_KEY: string; | ||
SCOPES: string[]; | ||
HOST_NAME: string; | ||
API_VERSION: ApiVersion; | ||
IS_EMBEDDED_APP: boolean; | ||
SESSION_STORAGE?: SessionStorage; | ||
} | ||
|
||
export enum ApiVersion { | ||
April19 = '2019-04', | ||
July19 = '2019-07', | ||
October19 = '2019-10', | ||
January20 = '2020-01', | ||
April20 = '2020-04', | ||
July20 = '2020-07', | ||
October20 = '2020-10', | ||
Unstable = 'unstable', | ||
Unversioned = 'unversioned', | ||
} | ||
|
||
export enum ShopifyHeader { | ||
AccessToken = 'X-Shopify-Access-Token', | ||
Hmac = 'X-Shopify-Hmac-Sha256', | ||
Topic = 'X-Shopify-Topic', | ||
Domain = 'X-Shopify-Shop-Domain', | ||
} | ||
|
||
export * from './base_types'; | ||
export * from './auth/oauth/types'; | ||
export * from './clients/types'; | ||
export * from './webhooks/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {StatusCode} from '@shopify/network'; | ||
|
||
import {ApiVersion} from '../base_types'; | ||
|
||
export enum DeliveryMethod { | ||
Http = 'http', | ||
EventBridge = 'eventbridge', | ||
} | ||
|
||
type WebhookHandlerFunction = ( | ||
topic: string, | ||
shop_domain: string, | ||
body: Buffer | ||
) => void; | ||
|
||
export interface RegisterOptions { | ||
// See https://shopify.dev/docs/admin-api/graphql/reference/events/webhooksubscriptiontopic for available topics | ||
topic: string; | ||
path: string; | ||
shop: string; | ||
accessToken: string; | ||
apiVersion: ApiVersion; | ||
deliveryMethod?: DeliveryMethod; | ||
webhookHandler: WebhookHandlerFunction; | ||
} | ||
|
||
export interface RegisterReturn { | ||
success: boolean; | ||
result: unknown; | ||
} | ||
|
||
export interface WebhookRegistryEntry { | ||
path: string; | ||
topic: string; | ||
webhookHandler: WebhookHandlerFunction; | ||
} | ||
|
||
export interface ProcessOptions { | ||
headers: Record<string, string>; | ||
body: Buffer; | ||
} | ||
|
||
export interface ProcessReturn { | ||
statusCode: StatusCode; | ||
headers: Record<string, string>; | ||
} | ||
|
||
interface WebhookCheckResponseNode { | ||
node: { | ||
id: string; | ||
callbackUrl: string; | ||
}; | ||
} | ||
|
||
export interface WebhookCheckResponse { | ||
data: { | ||
webhookSubscriptions: { | ||
edges: WebhookCheckResponseNode[]; | ||
}; | ||
}; | ||
} |