Parcourir la source

fix: Enable noImplicitAny on core and fix all tsc errors

Michael Bromley il y a 6 ans
Parent
commit
e24b33e677
50 fichiers modifiés avec 193 ajouts et 677 suppressions
  1. 1 0
      package.json
  2. 0 8
      packages/common/tsconfig.json
  3. 3 2
      packages/core/build/tsconfig.build.json
  4. 2 1
      packages/core/build/tsconfig.cli.json
  5. 2 8
      packages/core/e2e/administrator.e2e-spec.ts
  6. 9 13
      packages/core/e2e/collection.e2e-spec.ts
  7. 2 10
      packages/core/e2e/customer.e2e-spec.ts
  8. 1 1
      packages/core/e2e/product.e2e-spec.ts
  9. 1 1
      packages/core/e2e/promotion.e2e-spec.ts
  10. 2 7
      packages/core/e2e/role.e2e-spec.ts
  11. 3 6
      packages/core/e2e/shop-auth.e2e-spec.ts
  12. 3 10
      packages/core/e2e/shop-customer.e2e-spec.ts
  13. 9 21
      packages/core/e2e/shop-order.e2e-spec.ts
  14. 1 1
      packages/core/e2e/test-server.ts
  15. 0 10
      packages/core/e2e/utils/assert-throws-with-message.ts
  16. 9 0
      packages/core/e2e/utils/test-environment.ts
  17. 2 2
      packages/core/e2e/zone.e2e-spec.ts
  18. 1 1
      packages/core/mock-data/clear-all-tables.ts
  19. 2 2
      packages/core/mock-data/simple-graphql-client.ts
  20. 5 2
      packages/core/package.json
  21. 1 1
      packages/core/src/api/common/id-codec.spec.ts
  22. 6 6
      packages/core/src/api/common/id-codec.ts
  23. 2 2
      packages/core/src/api/config/generate-list-options.spec.ts
  24. 1 1
      packages/core/src/api/middleware/auth-guard.ts
  25. 1 1
      packages/core/src/common/calculated-decorator.ts
  26. 1 1
      packages/core/src/common/configurable-operation.ts
  27. 1 1
      packages/core/src/common/finite-state-machine.ts
  28. 7 7
      packages/core/src/config/merge-config.ts
  29. 2 2
      packages/core/src/data-import/import-cli.ts
  30. 1 1
      packages/core/src/data-import/providers/importer/importer.ts
  31. 2 2
      packages/core/src/data-import/providers/populator/populator.ts
  32. 1 1
      packages/core/src/entity/base/base.entity.ts
  33. 1 1
      packages/core/src/plugin/default-asset-server-plugin/default-asset-server-plugin.ts
  34. 1 1
      packages/core/src/plugin/default-search-plugin/search-index-item.entity.ts
  35. 3 3
      packages/core/src/plugin/default-search-plugin/search-strategy/search-strategy-utils.ts
  36. 1 1
      packages/core/src/service/helpers/list-query-builder/parse-sort-params.ts
  37. 2 1
      packages/core/src/service/helpers/order-state-machine/order-state-machine.ts
  38. 3 3
      packages/core/src/service/helpers/utils/patch-entity.ts
  39. 5 5
      packages/core/src/service/helpers/utils/translate-entity.ts
  40. 1 1
      packages/core/src/service/helpers/verification-token-generator/verification-token-generator.ts
  41. 2 2
      packages/core/src/service/services/auth.service.ts
  42. 2 2
      packages/core/src/service/services/collection.service.ts
  43. 0 9
      packages/core/tsconfig.json
  44. 18 0
      packages/core/typings.d.ts
  45. 47 506
      packages/core/yarn.lock
  46. 3 0
      packages/dev-server/README.md
  47. 1 1
      packages/dev-server/package.json
  48. 7 7
      packages/dev-server/populate-cli.ts
  49. 10 0
      packages/dev-server/tsconfig.json
  50. 2 2
      tsconfig.json

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
     "postcommit": "git update-index --again",
     "prepush": "yarn test:all && cd admin-ui && yarn build --prod",
     "dev-server": "ts-node packages/dev-server/index",
+    "dev-server:populate": "ts-node packages/dev-server/populate-cli",
     "test:all": "cd admin-ui && yarn test --watch=false --browsers=ChromeHeadlessCI --progress=false && cd ../server && yarn test && yarn test:e2e",
     "test:common": "jest --config packages/common/jest.config.js",
     "test:server": "jest --config packages/core/jest.config.js",

+ 0 - 8
packages/common/tsconfig.json

@@ -2,17 +2,9 @@
   "extends": "../../tsconfig.json",
   "compilerOptions": {
     "declaration": true,
-    "noImplicitAny": false,
     "removeComments": true,
     "noLib": false,
     "skipLibCheck": true,
-    "lib": ["es2017", "esnext.asynciterable"],
-    "allowSyntheticDefaultImports": true,
-    "emitDecoratorMetadata": true,
-    "experimentalDecorators": true,
-    "target": "es2017",
-    "strict": true,
-    "strictPropertyInitialization": false,
     "sourceMap": true,
     "newLine": "LF"
   }

+ 3 - 2
packages/core/build/tsconfig.build.json

@@ -2,9 +2,10 @@
   "extends": "../tsconfig.json",
   "compilerOptions": {
     "outDir": "../dist",
-    "rootDirs": ["../src", "../../../shared"]
+    "rootDirs": ["../src"]
   },
   "files": [
-    "../src/index.ts"
+    "../src/index.ts",
+    "../typings.d.ts"
   ]
 }

+ 2 - 1
packages/core/build/tsconfig.cli.json

@@ -5,6 +5,7 @@
     "declaration": false
   },
   "files": [
-    "../cli/vendure-cli.ts"
+    "../cli/vendure-cli.ts",
+    "../typings.d.ts"
   ]
 }

+ 2 - 8
packages/core/e2e/administrator.e2e-spec.ts

@@ -1,10 +1,4 @@
-import {
-    Administrator,
-    CreateAdministrator,
-    GetAdministrator,
-    GetAdministrators,
-    UpdateAdministrator,
-} from '@vendure/common/generated-types';
+import { Administrator, CreateAdministrator, GetAdministrator, GetAdministrators, UpdateAdministrator, } from '@vendure/common/generated-types';
 import path from 'path';
 
 import {
@@ -17,7 +11,7 @@ import {
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Administrator resolver', () => {
     const client = new TestAdminClient();

+ 9 - 13
packages/core/e2e/collection.e2e-spec.ts

@@ -26,17 +26,13 @@ import {
     UPDATE_COLLECTION,
 } from '../../../admin-ui/src/app/data/definitions/collection-definitions';
 import { FACET_VALUE_FRAGMENT } from '../../../admin-ui/src/app/data/definitions/facet-definitions';
-import {
-    GET_ASSET_LIST,
-    UPDATE_PRODUCT,
-    UPDATE_PRODUCT_VARIANTS,
-} from '../../../admin-ui/src/app/data/definitions/product-definitions';
+import { GET_ASSET_LIST, UPDATE_PRODUCT, UPDATE_PRODUCT_VARIANTS, } from '../../../admin-ui/src/app/data/definitions/product-definitions';
 import { facetValueCollectionFilter } from '../src/config/collection/default-collection-filters';
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Collection resolver', () => {
     const client = new TestAdminClient();
@@ -227,7 +223,7 @@ describe('Collection resolver', () => {
             expect(result.moveCollection.parent!.id).toBe(electronicsCollection.id);
 
             const positions = await getChildrenOf(electronicsCollection.id);
-            expect(positions.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
+            expect(positions.map((i: any) => i.id)).toEqual([pearCollection.id, computersCollection.id]);
         });
 
         it('re-evaluates Collection contents on move', async () => {
@@ -251,7 +247,7 @@ describe('Collection resolver', () => {
             });
 
             const afterResult = await getChildrenOf(electronicsCollection.id);
-            expect(afterResult.map(i => i.id)).toEqual([computersCollection.id, pearCollection.id]);
+            expect(afterResult.map((i: any) => i.id)).toEqual([computersCollection.id, pearCollection.id]);
         });
 
         it('corrects an out-of-bounds negative index value', async () => {
@@ -264,7 +260,7 @@ describe('Collection resolver', () => {
             });
 
             const afterResult = await getChildrenOf(electronicsCollection.id);
-            expect(afterResult.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
+            expect(afterResult.map((i: any) => i.id)).toEqual([pearCollection.id, computersCollection.id]);
         });
 
         it('corrects an out-of-bounds positive index value', async () => {
@@ -277,7 +273,7 @@ describe('Collection resolver', () => {
             });
 
             const afterResult = await getChildrenOf(electronicsCollection.id);
-            expect(afterResult.map(i => i.id)).toEqual([computersCollection.id, pearCollection.id]);
+            expect(afterResult.map((i: any) => i.id)).toEqual([computersCollection.id, pearCollection.id]);
         });
 
         it(
@@ -332,7 +328,7 @@ describe('Collection resolver', () => {
                 const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, {
                     id: electronicsCollection.id,
                 });
-                expect(result.collection.productVariants.items.map(i => i.name)).toEqual([
+                expect(result.collection.productVariants.items.map((i: any) => i.name)).toEqual([
                     'Laptop 13 inch 8GB',
                     'Laptop 15 inch 8GB',
                     'Laptop 13 inch 16GB',
@@ -361,7 +357,7 @@ describe('Collection resolver', () => {
                 const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, {
                     id: computersCollection.id,
                 });
-                expect(result.collection.productVariants.items.map(i => i.name)).toEqual([
+                expect(result.collection.productVariants.items.map((i: any) => i.name)).toEqual([
                     'Laptop 13 inch 8GB',
                     'Laptop 15 inch 8GB',
                     'Laptop 13 inch 16GB',
@@ -404,7 +400,7 @@ describe('Collection resolver', () => {
                         ],
                     } as CreateCollectionInput,
                 });
-                expect(result.createCollection.productVariants.items.map(i => i.name)).toEqual([
+                expect(result.createCollection.productVariants.items.map((i: any) => i.name)).toEqual([
                     'Instant Camera',
                 ]);
             });

+ 2 - 10
packages/core/e2e/customer.e2e-spec.ts

@@ -1,11 +1,4 @@
-import {
-    CreateCustomerAddress,
-    DeletionResult,
-    GetCustomer,
-    GetCustomerList,
-    UpdateCustomer,
-    UpdateCustomerAddress,
-} from '@vendure/common/generated-types';
+import { CreateCustomerAddress, DeletionResult, GetCustomer, GetCustomerList, UpdateCustomer, } from '@vendure/common/generated-types';
 import { omit } from '@vendure/common/omit';
 import gql from 'graphql-tag';
 import path from 'path';
@@ -15,13 +8,12 @@ import {
     GET_CUSTOMER,
     GET_CUSTOMER_LIST,
     UPDATE_CUSTOMER,
-    UPDATE_CUSTOMER_ADDRESS,
 } from '../../../admin-ui/src/app/data/definitions/customer-definitions';
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient, TestShopClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 // tslint:disable:no-non-null-assertion
 

+ 1 - 1
packages/core/e2e/product.e2e-spec.ts

@@ -32,7 +32,7 @@ import {
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 // tslint:disable:no-non-null-assertion
 

+ 1 - 1
packages/core/e2e/promotion.e2e-spec.ts

@@ -25,7 +25,7 @@ import { PromotionCondition } from '../src/config/promotion/promotion-condition'
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 // tslint:disable:no-non-null-assertion
 

+ 2 - 7
packages/core/e2e/role.e2e-spec.ts

@@ -3,17 +3,12 @@ import { omit } from '@vendure/common/omit';
 import { CUSTOMER_ROLE_CODE, SUPER_ADMIN_ROLE_CODE } from '@vendure/common/shared-constants';
 import path from 'path';
 
-import {
-    CREATE_ROLE,
-    GET_ROLE,
-    GET_ROLES,
-    UPDATE_ROLE,
-} from '../../../admin-ui/src/app/data/definitions/administrator-definitions';
+import { CREATE_ROLE, GET_ROLE, GET_ROLES, UPDATE_ROLE, } from '../../../admin-ui/src/app/data/definitions/administrator-definitions';
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Role resolver', () => {
     const client = new TestAdminClient();

+ 3 - 6
packages/core/e2e/shop-auth.e2e-spec.ts

@@ -5,10 +5,7 @@ import { DocumentNode } from 'graphql';
 import gql from 'graphql-tag';
 import path from 'path';
 
-import {
-    CREATE_ADMINISTRATOR,
-    CREATE_ROLE,
-} from '../../../admin-ui/src/app/data/definitions/administrator-definitions';
+import { CREATE_ADMINISTRATOR, CREATE_ROLE } from '../../../admin-ui/src/app/data/definitions/administrator-definitions';
 import { GET_CUSTOMER } from '../../../admin-ui/src/app/data/definitions/customer-definitions';
 import { NoopEmailGenerator } from '../src/config/email/noop-email-generator';
 import { defaultEmailTypes } from '../src/email/default-email-types';
@@ -16,7 +13,7 @@ import { defaultEmailTypes } from '../src/email/default-email-types';
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient, TestShopClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 let sendEmailFn: jest.Mock;
 const emailOptions = {
@@ -25,7 +22,7 @@ const emailOptions = {
     generator: new NoopEmailGenerator(),
     transport: {
         type: 'testing' as 'testing',
-        onSend: ctx => sendEmailFn(ctx),
+        onSend: (ctx: any) => sendEmailFn(ctx),
     },
 };
 

+ 3 - 10
packages/core/e2e/shop-customer.e2e-spec.ts

@@ -1,23 +1,16 @@
 /* tslint:disable:no-non-null-assertion */
-import {
-    CreateAddressInput,
-    UpdateAddressInput,
-    UpdateCustomerInput,
-} from '@vendure/common/generated-shop-types';
+import { CreateAddressInput, UpdateAddressInput, UpdateCustomerInput, } from '@vendure/common/generated-shop-types';
 import { AttemptLogin, GetCustomer } from '@vendure/common/generated-types';
 import gql from 'graphql-tag';
 import path from 'path';
 
 import { ATTEMPT_LOGIN } from '../../../admin-ui/src/app/data/definitions/auth-definitions';
-import {
-    CUSTOMER_FRAGMENT,
-    GET_CUSTOMER,
-} from '../../../admin-ui/src/app/data/definitions/customer-definitions';
+import { CUSTOMER_FRAGMENT, GET_CUSTOMER, } from '../../../admin-ui/src/app/data/definitions/customer-definitions';
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient, TestShopClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Shop customers', () => {
     const shopClient = new TestShopClient();

+ 9 - 21
packages/core/e2e/shop-order.e2e-spec.ts

@@ -1,28 +1,16 @@
 /* tslint:disable:no-non-null-assertion */
-import {
-    CreateAddressInput,
-    GetCountryList,
-    GetCustomer,
-    GetCustomerList,
-    UpdateCountry,
-} from '@vendure/common/generated-types';
+import { CreateAddressInput, GetCountryList, GetCustomer, GetCustomerList, UpdateCountry } from '@vendure/common/generated-types';
 import gql from 'graphql-tag';
 import path from 'path';
 
-import {
-    GET_CUSTOMER,
-    GET_CUSTOMER_LIST,
-} from '../../../admin-ui/src/app/data/definitions/customer-definitions';
-import {
-    GET_COUNTRY_LIST,
-    UPDATE_COUNTRY,
-} from '../../../admin-ui/src/app/data/definitions/settings-definitions';
+import { GET_CUSTOMER, GET_CUSTOMER_LIST } from '../../../admin-ui/src/app/data/definitions/customer-definitions';
+import { GET_COUNTRY_LIST, UPDATE_COUNTRY } from '../../../admin-ui/src/app/data/definitions/settings-definitions';
 import { PaymentMethodHandler } from '../src/config/payment-method/payment-method-handler';
 
 import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
 import { TestAdminClient, TestShopClient } from './test-client';
 import { TestServer } from './test-server';
-import { assertThrowsWithMessage } from './test-utils';
+import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Shop orders', () => {
     const adminClient = new TestAdminClient();
@@ -65,7 +53,7 @@ describe('Shop orders', () => {
 
         const result = await shopClient.query(GET_AVAILABLE_COUNTRIES);
         expect(result.availableCountries.length).toBe(countries.items.length - 1);
-        expect(result.availableCountries.find(c => c.id === AT.id)).toBeUndefined();
+        expect(result.availableCountries.find((c: GetCountryList.Items) => c.id === AT.id)).toBeUndefined();
     });
 
     describe('ordering as anonymous user', () => {
@@ -194,13 +182,13 @@ describe('Shop orders', () => {
                 quantity: 3,
             });
             expect(result1.addItemToOrder.lines.length).toBe(2);
-            expect(result1.addItemToOrder.lines.map(i => i.productVariant.id)).toEqual(['T_1', 'T_3']);
+            expect(result1.addItemToOrder.lines.map((i: any) => i.productVariant.id)).toEqual(['T_1', 'T_3']);
 
             const result2 = await shopClient.query(REMOVE_ITEM_FROM_ORDER, {
                 orderItemId: firstOrderItemId,
             });
             expect(result2.removeItemFromOrder.lines.length).toBe(1);
-            expect(result2.removeItemFromOrder.lines.map(i => i.productVariant.id)).toEqual(['T_3']);
+            expect(result2.removeItemFromOrder.lines.map((i: any) => i.productVariant.id)).toEqual(['T_3']);
         });
 
         it(
@@ -431,13 +419,13 @@ describe('Shop orders', () => {
                 quantity: 3,
             });
             expect(result1.addItemToOrder.lines.length).toBe(2);
-            expect(result1.addItemToOrder.lines.map(i => i.productVariant.id)).toEqual(['T_1', 'T_3']);
+            expect(result1.addItemToOrder.lines.map((i: any) => i.productVariant.id)).toEqual(['T_1', 'T_3']);
 
             const result2 = await shopClient.query(REMOVE_ITEM_FROM_ORDER, {
                 orderItemId: firstOrderItemId,
             });
             expect(result2.removeItemFromOrder.lines.length).toBe(1);
-            expect(result2.removeItemFromOrder.lines.map(i => i.productVariant.id)).toEqual(['T_3']);
+            expect(result2.removeItemFromOrder.lines.map((i: any) => i.productVariant.id)).toEqual(['T_3']);
         });
 
         it('nextOrderStates returns next valid states', async () => {

+ 1 - 1
packages/core/e2e/test-server.ts

@@ -12,7 +12,7 @@ import { Mutable } from '../src/common/types/common-types';
 import { VendureConfig } from '../src/config/vendure-config';
 
 import { testConfig } from './config/test-config';
-import { setTestEnvironment } from './test-utils';
+import { setTestEnvironment } from './utils/test-environment';
 
 // tslint:disable:no-console
 /**

+ 0 - 10
packages/core/e2e/test-utils.ts → packages/core/e2e/utils/assert-throws-with-message.ts

@@ -1,13 +1,3 @@
-export const E2E_TESTING_ENV_VARIABLE = 'isE2ETest';
-
-export function setTestEnvironment() {
-    process.env[E2E_TESTING_ENV_VARIABLE] = '1';
-}
-
-export function isTestEnvironment() {
-    return !!process.env[E2E_TESTING_ENV_VARIABLE];
-}
-
 /**
  * Helper method for creating tests which assert a given error message when the operation is attempted.
  */

+ 9 - 0
packages/core/e2e/utils/test-environment.ts

@@ -0,0 +1,9 @@
+export const E2E_TESTING_ENV_VARIABLE = 'isE2ETest';
+
+export function setTestEnvironment() {
+    process.env[E2E_TESTING_ENV_VARIABLE] = '1';
+}
+
+export function isTestEnvironment() {
+    return !!process.env[E2E_TESTING_ENV_VARIABLE];
+}

+ 2 - 2
packages/core/e2e/zone.e2e-spec.ts

@@ -125,7 +125,7 @@ describe('Facet resolver', () => {
             });
 
             const result2 = await client.query(GET_ZONE_LIST, {});
-            expect(result2.zones.find(c => c.id === pangaea.id)).toBeUndefined();
+            expect(result2.zones.find((c: any) => c.id === pangaea.id)).toBeUndefined();
         });
 
         it('does not delete Zone that is used in one or more TaxRates', async () => {
@@ -139,7 +139,7 @@ describe('Facet resolver', () => {
             });
 
             const result2 = await client.query(GET_ZONE_LIST, {});
-            expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
+            expect(result2.zones.find((c: any) => c.id === oceania.id)).not.toBeUndefined();
         });
     });
 });

+ 1 - 1
packages/core/mock-data/clear-all-tables.ts

@@ -1,6 +1,6 @@
 import { ConnectionOptions, createConnection } from 'typeorm';
 
-import { isTestEnvironment } from '../e2e/test-utils';
+import { isTestEnvironment } from '../e2e/utils/test-environment';
 
 // tslint:disable:no-console
 // tslint:disable:no-floating-promises

+ 2 - 2
packages/core/mock-data/simple-graphql-client.ts

@@ -126,7 +126,7 @@ export class SimpleGraphQLClient {
                 `${getConfig().channelTokenKey}: ${this.channelToken}`,
             ]);
             curl.perform();
-            curl.on('end', (statusCode, body) => {
+            curl.on('end', (statusCode: any, body: any) => {
                 curl.close();
                 const response = JSON.parse(body);
                 if (response.errors && response.errors.length) {
@@ -137,7 +137,7 @@ export class SimpleGraphQLClient {
                 resolve(response.data);
             });
 
-            curl.on('error', err => {
+            curl.on('error', (err: any) => {
                 curl.close();
                 console.log(err);
                 reject(err);

+ 5 - 2
packages/core/package.json

@@ -18,8 +18,6 @@
   "license": "MIT",
   "scripts": {
     "lint": "tslint --project tsconfig.json -c tslint.json",
-    "test:e2e": "jest --config ../../e2e/config/jest-e2e.json --runInBand",
-    "test:e2e:watch": "jest --config ../../e2e/config/jest-e2e.json --watch --runInBand",
     "generate-email-preview": "node -r ts-node/register src/email/preview/generate-email-preview.ts",
     "build": "rimraf dist && tsc -p ./build/tsconfig.build.json && tsc -p ./build/tsconfig.cli.json && gulp -f ./build/gulpfile.ts build",
     "publish:alpha": "yarn build && npm publish --access public --tag alpha"
@@ -80,14 +78,19 @@
     "@types/commander": "^2.12.2",
     "@types/cookie-session": "^2.0.36",
     "@types/csv-parse": "^1.1.11",
+    "@types/dateformat": "^3.0.0",
     "@types/express": "^4.0.39",
     "@types/faker": "^4.1.4",
     "@types/fs-extra": "^5.0.4",
+    "@types/graphql-iso-date": "^3.3.1",
+    "@types/graphql-type-json": "^0.1.3",
     "@types/gulp": "^4.0.5",
     "@types/handlebars": "^4.0.40",
     "@types/http-proxy-middleware": "^0.19.2",
     "@types/jest": "^23.3.12",
     "@types/mime-types": "^2.1.0",
+    "@types/mjml": "^4.0.2",
+    "@types/ms": "^0.7.30",
     "@types/nanoid": "^1.2.0",
     "@types/node": "^10.12.18",
     "@types/nodemailer": "^4.6.5",

+ 1 - 1
packages/core/src/api/common/id-codec.spec.ts

@@ -122,7 +122,7 @@ describe('IdCodecService', () => {
         });
 
         it('does not throw with an empty list', () => {
-            const input = [];
+            const input: any[] = [];
 
             const result = idCodec.encode(input);
             expect(() => idCodec.encode(input)).not.toThrow();

+ 6 - 6
packages/core/src/api/common/id-codec.ts

@@ -82,8 +82,8 @@ export class IdCodec {
         } else {
             target = this.transform(target, transformFn, transformKeys);
             for (const key of Object.keys(target)) {
-                if (this.isObject(target[key])) {
-                    target[key] = this.transformRecursive(target[key], transformFn, transformKeys);
+                if (this.isObject(target[key as keyof T])) {
+                    target[key as keyof T] = this.transformRecursive(target[key as keyof T], transformFn, transformKeys);
                 }
             }
         }
@@ -94,12 +94,12 @@ export class IdCodec {
         const clone = Object.assign({}, target);
         if (transformKeys) {
             for (const key of transformKeys) {
-                if (target[key]) {
-                    const val = target[key];
+                if (target[key as keyof T]) {
+                    const val = target[key as keyof T];
                     if (Array.isArray(val)) {
-                        clone[key] = val.map(v => transformFn(v));
+                        (clone as any)[key] = val.map(v => transformFn(v));
                     } else {
-                        clone[key] = transformFn(val);
+                        (clone as any)[key] = transformFn(val);
                     }
                 }
             }

+ 2 - 2
packages/core/src/api/config/generate-list-options.spec.ts

@@ -42,8 +42,8 @@ describe('generateListOptions()', () => {
     }
     `;
 
-    const removeLeadingWhitespace = s => {
-        const indent = s.match(/^\s+/m)[0].replace(/\n/, '');
+    const removeLeadingWhitespace = (s: string) => {
+        const indent = s.match(/^\s+/m)![0].replace(/\n/, '');
         return s.replace(new RegExp(`^${indent}`, 'gm'), '').trim();
     };
 

+ 1 - 1
packages/core/src/api/middleware/auth-guard.ts

@@ -38,7 +38,7 @@ export class AuthGuard implements CanActivate {
         const hasOwnerPermission = !!permissions && permissions.includes(Permission.Owner);
         const session = await this.getSession(req, res, hasOwnerPermission);
         const requestContext = await this.requestContextService.fromRequest(req, permissions, session);
-        req[REQUEST_CONTEXT_KEY] = requestContext;
+        (req as any)[REQUEST_CONTEXT_KEY] = requestContext;
 
         if (authDisabled || !permissions || isPublic) {
             return true;

+ 1 - 1
packages/core/src/common/calculated-decorator.ts

@@ -6,7 +6,7 @@ export const CALCULATED_PROPERTIES = '__calculatedProperties__';
  * to transfer the getter function from the prototype to the entity instance.
  */
 export function Calculated(): MethodDecorator {
-    return (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
+    return (target: object & { [key: string]: any }, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
         if (target[CALCULATED_PROPERTIES]) {
             if (!target[CALCULATED_PROPERTIES].includes(propertyKey)) {
                 target[CALCULATED_PROPERTIES].push(propertyKey);

+ 1 - 1
packages/core/src/common/configurable-operation.ts

@@ -55,7 +55,7 @@ export function configurableDefToOperation(def: ConfigurableOperationDef): Confi
  * { foo: 'bar' }
  **/
 export function argsArrayToHash<T>(args: ConfigArg[]): ConfigArgValues<T> {
-    const output: ConfigArgValues<T> = {} as any;
+    const output: ConfigArgValues<T> & { [key: string]: any } = {} as any;
     for (const arg of args) {
         if (arg.value != null) {
             output[arg.name] = coerceValueToType<T>(arg);

+ 1 - 1
packages/core/src/common/finite-state-machine.ts

@@ -57,7 +57,7 @@ export class FSM<T extends string, Data = any> {
      * Attempts to transition from the current state to the given state. If this transition is not allowed
      * per the config, then an error will be logged.
      */
-    transitionTo(state: T, data?: Data);
+    transitionTo(state: T, data?: Data): void;
     async transitionTo(state: T, data: Data) {
         if (this.canTransitionTo(state)) {
             // If the onTransitionStart callback is defined, invoke it. If it returns false,

+ 7 - 7
packages/core/src/config/merge-config.ts

@@ -26,17 +26,17 @@ export function mergeConfig<T extends VendureConfig>(target: T, source: DeepPart
 
     if (isObject(target) && isObject(source)) {
         for (const key in source) {
-            if (isObject(source[key])) {
-                if (!target[key]) {
-                    Object.assign(target, { [key]: {} });
+            if (isObject((source as any)[key])) {
+                if (!(target as any)[key]) {
+                    Object.assign((target as any), { [key]: {} });
                 }
-                if (!isClassInstance(source[key])) {
-                    mergeConfig(target[key], source[key]);
+                if (!isClassInstance((source as any)[key])) {
+                    mergeConfig((target as any)[key], (source as any)[key]);
                 } else {
-                    target[key] = source[key];
+                    (target as any)[key] = (source as any)[key];
                 }
             } else {
-                Object.assign(target, { [key]: source[key] });
+                Object.assign(target, { [key]: (source as any)[key] });
             }
         }
     }

+ 2 - 2
packages/core/src/data-import/import-cli.ts

@@ -1,6 +1,6 @@
 import path from 'path';
 
-import { devConfig } from '../../dev-config';
+import { devConfig } from '../../../dev-server/dev-config';
 import { SimpleGraphQLClient } from '../../mock-data/simple-graphql-client';
 import { bootstrap } from '../bootstrap';
 import { setConfig } from '../config/config-helpers';
@@ -27,7 +27,7 @@ if (require.main === module) {
 
 async function getClient() {
     const config: VendureConfig = {
-        ...devConfig,
+        ...devConfig as any,
         port: 3020,
         authOptions: {
             tokenMethod: 'bearer',

+ 1 - 1
packages/core/src/data-import/providers/importer/importer.ts

@@ -331,7 +331,7 @@ export class Importer {
         const regex = new RegExp(name, 'i');
         const found = taxCategories.find(tc => !!tc.name.match(regex));
         const match = found ? found : taxCategories[0];
-        this.taxCategoryService[name] = match.id;
+        this.taxCategoryMatches[name] = match.id as string;
         return match.id as string;
     }
 }

+ 2 - 2
packages/core/src/data-import/providers/populator/populator.ts

@@ -6,7 +6,7 @@ import { notNullOrUndefined } from '@vendure/common/shared-utils';
 import { RequestContext } from '../../../api/common/request-context';
 import { defaultShippingCalculator, defaultShippingEligibilityChecker } from '../../../config';
 import { facetValueCollectionFilter } from '../../../config/collection/default-collection-filters';
-import { Collection, TaxCategory } from '../../../entity';
+import { Collection, TaxCategory, Channel } from '../../../entity';
 import { Zone } from '../../../entity/zone/zone.entity';
 import { CollectionService, FacetValueService, ShippingMethodService } from '../../../service';
 import { ChannelService } from '../../../service/services/channel.service';
@@ -120,7 +120,7 @@ export class Populator {
         return { channel, ctx };
     }
 
-    private async setChannelDefaults(zoneMap, data: InitialData, channel) {
+    private async setChannelDefaults(zoneMap: ZoneMap, data: InitialData, channel: Channel) {
         const defaultZone = zoneMap.get(data.defaultZone);
         if (!defaultZone) {
             throw new Error(

+ 1 - 1
packages/core/src/entity/base/base.entity.ts

@@ -16,7 +16,7 @@ export abstract class VendureEntity {
     protected constructor(input?: DeepPartial<VendureEntity>) {
         if (input) {
             for (const [key, value] of Object.entries(input)) {
-                this[key] = value;
+                (this as any)[key] = value;
             }
         }
     }

+ 1 - 1
packages/core/src/plugin/default-asset-server-plugin/default-asset-server-plugin.ts

@@ -170,7 +170,7 @@ export class DefaultAssetServerPlugin implements VendurePlugin {
      * transformed image, save it to cache, and serve the result as a response.
      */
     private generateTransformedImage() {
-        return async (err, req: Request, res: Response, next: NextFunction) => {
+        return async (err: any, req: Request, res: Response, next: NextFunction) => {
             if (err && err.status === 404) {
                 if (req.query) {
                     let file: Buffer;

+ 1 - 1
packages/core/src/plugin/default-search-plugin/search-index-item.entity.ts

@@ -9,7 +9,7 @@ export class SearchIndexItem {
     constructor(input?: Partial<SearchIndexItem>) {
         if (input) {
             for (const [key, value] of Object.entries(input)) {
-                this[key] = value;
+                (this as any)[key] = value;
             }
         }
     }

+ 3 - 3
packages/core/src/plugin/default-search-plugin/search-strategy/search-strategy-utils.ts

@@ -25,9 +25,9 @@ export function mapToSearchResult(raw: any, currencyCode: CurrencyCode): SearchR
         productName: raw.si_productName,
         productVariantName: raw.si_productVariantName,
         description: raw.si_description,
-        facetIds: raw.si_facetIds.split(',').map(x => x.trim()),
-        facetValueIds: raw.si_facetValueIds.split(',').map(x => x.trim()),
-        collectionIds: raw.si_collectionIds.split(',').map(x => x.trim()),
+        facetIds: raw.si_facetIds.split(',').map((x: string) => x.trim()),
+        facetValueIds: raw.si_facetValueIds.split(',').map((x: string) => x.trim()),
+        collectionIds: raw.si_collectionIds.split(',').map((x: string) => x.trim()),
         productPreview: raw.si_productPreview,
         productVariantPreview: raw.si_productVariantPreview,
         score: raw.score || 0,

+ 1 - 1
packages/core/src/service/helpers/list-query-builder/parse-sort-params.ts

@@ -34,7 +34,7 @@ export function parseSortParams<T extends VendureEntity>(
         translationColumns = columns.concat(translationMetadata.columns.filter(c => !c.relationMetadata));
     }
 
-    const output = {};
+    const output: OrderByCondition = {};
     const alias = metadata.name.toLowerCase();
 
     for (const [key, order] of Object.entries(sortParams)) {

+ 2 - 1
packages/core/src/service/helpers/order-state-machine/order-state-machine.ts

@@ -110,7 +110,8 @@ export class OrderStateMachine {
             return defaultTranstions;
         }
         const merged = defaultTranstions;
-        for (const key of Object.keys(customTranstitions)) {
+        for (const k of Object.keys(customTranstitions)) {
+            const key = k as T;
             if (merged.hasOwnProperty(key)) {
                 merged[key].to = merged[key].to.concat(customTranstitions[key].to);
             } else {

+ 3 - 3
packages/core/src/service/helpers/utils/patch-entity.ts

@@ -8,11 +8,11 @@ export type InputPatch<T> = { [K in keyof T]?: T[K] | null };
  */
 export function patchEntity<T extends VendureEntity, I extends InputPatch<T>>(entity: T, input: I): T {
     for (const key of Object.keys(entity)) {
-        const value = input[key];
+        const value = input[key as keyof T];
         if (key === 'customFields') {
-            patchEntity(entity[key], value);
+            patchEntity((entity as any)[key], value as any);
         } else if (value != null && key !== 'id') {
-            entity[key] = value;
+            entity[key as keyof T] = value as any;
         }
     }
     return entity;

+ 5 - 5
packages/core/src/service/helpers/utils/translate-entity.ts

@@ -83,18 +83,18 @@ export function translateDeep<T extends Translatable>(
 
         if (Array.isArray(path) && path.length === 2) {
             const [path0, path1] = path as any;
-            const valueLevel0 = translatable[path0];
+            const valueLevel0 = (translatable as any)[path0];
 
             if (Array.isArray(valueLevel0)) {
                 valueLevel0.forEach((nested1, index) => {
-                    object = translatedEntity[path0][index];
+                    object = (translatedEntity as any)[path0][index];
                     property = path1;
                     object[property] = translateLeaf(object, property, languageCode);
                 });
                 property = '';
                 object = null;
             } else {
-                object = translatedEntity[path0];
+                object = (translatedEntity as any)[path0];
                 property = path1;
                 value = translateLeaf(object, property, languageCode);
             }
@@ -112,10 +112,10 @@ export function translateDeep<T extends Translatable>(
     return translatedEntity;
 }
 
-function translateLeaf(object: object | undefined, property: string, languageCode: LanguageCode): any {
+function translateLeaf(object: { [key: string]: any } | undefined, property: string, languageCode: LanguageCode): any {
     if (object && object[property]) {
         if (Array.isArray(object[property])) {
-            return object[property].map(nested2 => translateEntity(nested2, languageCode));
+            return object[property].map((nested2: any) => translateEntity(nested2, languageCode));
         } else if (object[property]) {
             return translateEntity(object[property], languageCode);
         }

+ 1 - 1
packages/core/src/service/helpers/verification-token-generator/verification-token-generator.ts

@@ -28,7 +28,7 @@ export class VerificationTokenGenerator {
      * as specified in the VendureConfig.
      */
     verifyVerificationToken(token: string): boolean {
-        const duration = ms(this.configService.authOptions.verificationTokenDuration);
+        const duration = ms(this.configService.authOptions.verificationTokenDuration as string);
         const [generatedOn] = token.split('_');
         const dateString = Buffer.from(generatedOn, 'base64').toString();
         const date = new Date(dateString);

+ 2 - 2
packages/core/src/service/services/auth.service.ts

@@ -21,7 +21,7 @@ import { OrderService } from './order.service';
  */
 @Injectable()
 export class AuthService {
-    private readonly sessionDurationInMs;
+    private readonly sessionDurationInMs: number;
 
     constructor(
         @InjectConnection() private connection: Connection,
@@ -29,7 +29,7 @@ export class AuthService {
         private configService: ConfigService,
         private orderService: OrderService,
     ) {
-        this.sessionDurationInMs = ms(this.configService.authOptions.sessionDuration);
+        this.sessionDurationInMs = ms(this.configService.authOptions.sessionDuration as string);
     }
 
     /**

+ 2 - 2
packages/core/src/service/services/collection.service.ts

@@ -158,7 +158,7 @@ export class CollectionService implements OnModuleInit {
      * Returns the descendants of a Collection as a flat array.
      */
     async getDescendants(ctx: RequestContext, rootId: ID): Promise<Array<Translated<Collection>>> {
-        const getChildren = async (id, _descendants: Collection[] = []) => {
+        const getChildren = async (id: ID, _descendants: Collection[] = []) => {
             const children = await this.connection
                 .getRepository(Collection)
                 .find({ where: { parent: { id } } });
@@ -183,7 +183,7 @@ export class CollectionService implements OnModuleInit {
         collectionId: ID,
         ctx?: RequestContext,
     ): Promise<Array<Translated<Collection> | Collection>> {
-        const getParent = async (id, _ancestors: Collection[] = []): Promise<Collection[]> => {
+        const getParent = async (id: ID, _ancestors: Collection[] = []): Promise<Collection[]> => {
             const parent = await this.connection
                 .getRepository(Collection)
                 .createQueryBuilder()

+ 0 - 9
packages/core/tsconfig.json

@@ -2,16 +2,7 @@
   "extends": "../../tsconfig.json",
   "compilerOptions": {
     "declaration": true,
-    "noImplicitAny": false,
     "removeComments": true,
-    "noLib": false,
-    "skipLibCheck": true,
-    "lib": ["es2017", "esnext.asynciterable"],
-    "allowSyntheticDefaultImports": true,
-    "emitDecoratorMetadata": true,
-    "experimentalDecorators": true,
-    "target": "es2017",
-    "strict": true,
     "strictPropertyInitialization": false,
     "sourceMap": true,
     "newLine": "LF"

+ 18 - 0
packages/core/typings.d.ts

@@ -0,0 +1,18 @@
+// This file is for any 3rd party JS libs which don't have a corresponding @types/ package.
+
+declare module 'node-libcurl' {
+    export const Curl: any;
+}
+
+declare module 'opn' {
+    declare const opn: (path: string) => Promise<any>;
+    export default opn;
+}
+
+declare module 'i18next-icu' {
+    // default
+}
+
+declare module 'i18next-node-fs-backend' {
+    // default
+}

Fichier diff supprimé car celui-ci est trop grand
+ 47 - 506
packages/core/yarn.lock


+ 3 - 0
packages/dev-server/README.md

@@ -0,0 +1,3 @@
+# Vendure Dev Server
+
+This package is not published to npm. It is used in development of the Vendure server and plugins.

+ 1 - 1
packages/dev-server/package.json

@@ -5,7 +5,7 @@
   "license": "MIT",
   "private": true,
   "scripts": {
-    "populate": "node -r ts-node/register mock-data/populate-cli.ts",
+    "populate": "node -r ts-node/register populate-cli.ts",
     "start:dev": "nodemon --config nodemon-debug.json"
   },
   "dependencies": {

+ 7 - 7
packages/core/mock-data/populate-cli.ts → packages/dev-server/populate-cli.ts

@@ -1,18 +1,18 @@
 import path from 'path';
 
-import { devConfig } from '../dev-config';
-import { bootstrap } from '../src';
-import { VendureConfig } from '../src/config/vendure-config';
+import { populate } from '../core/mock-data/populate';
+import { bootstrap, VendureConfig } from '../core/src';
 
-import { populate } from './populate';
+import { devConfig } from './dev-config';
 
 /**
  * A CLI script which populates the dev database with deterministic random data.
  */
 if (require.main === module) {
+    console.log('yolo');
     // Running from command line
     const populateConfig: VendureConfig = {
-        ...devConfig,
+        ...devConfig as any,
         authOptions: {
             tokenMethod: 'bearer',
         },
@@ -25,8 +25,8 @@ if (require.main === module) {
     populate(populateConfig, bootstrap, {
         logging: true,
         customerCount: 10,
-        productsCsvPath: path.join(__dirname, 'data-sources/products.csv'),
-        initialDataPath: path.join(__dirname, 'data-sources/initial-data'),
+        productsCsvPath: path.join(__dirname, '../core/mock-data/data-sources/products.csv'),
+        initialDataPath: path.join(__dirname, '../core/mock-data/data-sources/initial-data'),
     })
         .then(app => app.close())
         .then(

+ 10 - 0
packages/dev-server/tsconfig.json

@@ -0,0 +1,10 @@
+{
+  "extends": "../../tsconfig",
+  "compilerOptions": {
+    "module": "commonjs",
+    "sourceMap": true
+  },
+  "exclude": [
+    "node_modules"
+  ]
+}

+ 2 - 2
tsconfig.json

@@ -3,12 +3,12 @@
     "module": "commonjs",
     "noLib": false,
     "skipLibCheck": true,
-    "lib": ["es2017"],
+    "lib": ["es2017", "esnext.asynciterable"],
     "allowSyntheticDefaultImports": true,
     "esModuleInterop": true,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
-    "target": "es6",
+    "target": "es2017",
     "strict": true,
     "strictPropertyInitialization": false,
     "sourceMap": false

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff