diff --git a/README.md b/README.md
index 139baba..d19ab8c 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@ SDK for building great Saleor Apps.
- [](https://www.npmjs.com/package/@saleor/app-sdk)
- [](https://www.npmjs.com/package/@saleor/app-sdk)
+[](https://www.npmjs.com/package/@saleor/app-sdk)
+[](https://www.npmjs.com/package/@saleor/app-sdk)
@@ -13,4 +13,4 @@ SDK for building great Saleor Apps.
```bash
npm i @saleor/app-sdk
-```
\ No newline at end of file
+```
diff --git a/src/const.ts b/src/const.ts
index a7f264b..36d4c92 100644
--- a/src/const.ts
+++ b/src/const.ts
@@ -1,2 +1,2 @@
export const SALEOR_DOMAIN_HEADER = "saleor-domain";
-export const SALEOR_EVENT_HEADER = "saleor-event";
\ No newline at end of file
+export const SALEOR_EVENT_HEADER = "saleor-event";
diff --git a/src/index.ts b/src/index.ts
index 9c93739..2708a4f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,43 +1,38 @@
-import path from "path";
import fg from "fast-glob";
-
import { print } from "graphql/language/printer.js";
+import path from "path";
-const capitalize = (value: string) =>
- value.charAt(0).toUpperCase() + value.slice(1);
+const capitalize = (value: string) => value.charAt(0).toUpperCase() + value.slice(1);
const dropFileExtension = (filename: string) => path.parse(filename).name;
-export const inferWebhooks = async (baseURL: string, webhooksPath: string, generatedGraphQL: any) => {
+export const inferWebhooks = async (
+ baseURL: string,
+ webhooksPath: string,
+ generatedGraphQL: any
+) => {
let entries;
+
if (process.env.NODE_ENV === "production") {
entries = await fg(["*.js"], { cwd: webhooksPath });
} else {
- entries = await fg(["*.ts"], { cwd: `pages/api/webhooks` });
+ entries = await fg(["*.ts"], { cwd: "pages/api/webhooks" });
}
return entries.map(dropFileExtension).map((name: string) => {
- const camelcaseName = name.split("-").map(capitalize).join("");
+ const camelCaseName = name.split("-").map(capitalize).join("");
- const eventName = name.toUpperCase().replace(new RegExp("-", "g"), "_");
+ const eventName = name.toUpperCase().replace(/-/g, "_");
let eventType: string;
- if (
- Object.values(generatedGraphQL.WebhookEventTypeAsyncEnum).includes(
- eventName
- )
- ) {
+ if (Object.values(generatedGraphQL.WebhookEventTypeAsyncEnum).includes(eventName)) {
eventType = "asyncEvents";
- } else if (
- Object.values(generatedGraphQL.WebhookEventTypeSyncEnum).includes(
- eventName
- )
- ) {
+ } else if (Object.values(generatedGraphQL.WebhookEventTypeSyncEnum).includes(eventName)) {
eventType = "syncEvents";
} else {
throw Error("Event type not found.");
}
- const statement = `${camelcaseName}SubscriptionDocument`;
+ const statement = `${camelCaseName}SubscriptionDocument`;
let query: string;
if (statement in generatedGraphQL) {
query = print((generatedGraphQL as any)[statement]);
diff --git a/tsconfig.json b/tsconfig.json
index 6319485..a337aa5 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -11,8 +11,10 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
- "target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
- "lib": ["ES2021"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
+ "target": "ES2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
+ "lib": [
+ "ES2021"
+ ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
@@ -25,7 +27,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
- "module": "commonjs", /* Specify what module code is generated. */
+ "module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
@@ -71,12 +73,12 @@
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
- "strict": true, /* Enable all strict type-checking options. */
+ "strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -98,6 +100,6 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}