Skip to content

Commit 264d35d

Browse files
authored
Merge pull request #4 from RinseV/dev
2 parents 97d710a + 1eda04d commit 264d35d

32 files changed

+3317
-445
lines changed

.eslintrc

Lines changed: 0 additions & 13 deletions
This file was deleted.

.eslintrc.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
env: {
3+
es2021: true,
4+
node: true
5+
},
6+
extends: ['airbnb-typescript/base', 'prettier'],
7+
parser: '@typescript-eslint/parser',
8+
parserOptions: {
9+
ecmaVersion: 12,
10+
sourceType: 'module',
11+
project: './tsconfig.json'
12+
},
13+
plugins: ['@typescript-eslint', 'prettier'],
14+
rules: {
15+
indent: 'off',
16+
'@typescript-eslint/indent': ['error', 4],
17+
'@typescript-eslint/quotes': [0, 'double'],
18+
'max-len': ['error', { code: 160 }],
19+
20+
radix: 'off',
21+
'no-underscore-dangle': 'off',
22+
'no-restricted-syntax': 'warn',
23+
'import/prefer-default-export': 'off',
24+
'no-console': 'off',
25+
'class-methods-use-this': 'off',
26+
'max-classes-per-file': 'off',
27+
'no-restricted-syntax': 'off',
28+
'no-continue': 'off',
29+
quotes: 'off',
30+
'linebreak-style': 0,
31+
'no-plusplus': 'off',
32+
'prettier/prettier': 'error',
33+
34+
'import/named': 'off',
35+
'import/namespace': 'off',
36+
'import/default': 'off',
37+
'import/no-named-as-default-member': 'off'
38+
}
39+
};

.github/workflows/publish.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: '14.x'
15+
registry-url: 'https://registry.npmjs.org/'
16+
- name: Install dependencies and build
17+
run: yarn install && yarn build
18+
- name: Publish on NPM
19+
run: yarn publish --access public
20+
env:
21+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
22+

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: CI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Install dependencies
11+
run: yarn
12+
- name: Run tests
13+
run: yarn test

.npmignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ rollup.config.ts
1010
tsconfig.json
1111
.gitattributes
1212
yarn-error.log
13-
node_modules/
13+
node_modules/
14+
.nvmrc
15+
.gitattributes
16+
.env.example
17+
coverage
18+
test
19+
jest.config.ts
20+
.github
21+
*.tgz
22+
.eslintrc.js

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14.17.5

README.md

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,17 @@ then
2828
import { AH } from 'albert-heijn-wrapper';
2929
```
3030

31-
## Usage
31+
## Basic usage
3232
```javascript
3333
// Creates AH object, set verbose=true if you want to see all requests
3434
const ah = new AH(verbose);
3535
// Gets product as reponse from ID
3636
const product = await ah.product().getProductFromId(200486);
3737
```
38+
More information about the functions and parameters can be found on the [wiki](https://github.com/RinseV/jumbo-wrapper/wiki).
3839

39-
### Functions
40-
#### Products
41-
```javascript
42-
// Gets product from product ID
43-
AH.product().getProductFromId(productId);
44-
// Gets products that match the name with optional filter and sort options
45-
AH.product().getProductsFromName(productName, filter, sort);
46-
// Gets the first product that matches the name with optional filter and sort options
47-
AH.product().getFirstProductFromName(productName, filter, sort);
48-
```
49-
50-
#### Stores
51-
```javascript
52-
// Gets the closest stores from the given location (sorted by distance ascending)
53-
AH.store().getStoresFromLocation(latitude, longitude, maxResults);
54-
// Gets the closest store from given location
55-
AH.store().getClosestStoreFromLocation(latitude, longitude);
56-
```
57-
58-
#### Recipes
59-
```javascript
60-
// Gets recipe from recipe ID
61-
AH.recipe().getRecipeFromId(recipeId);
62-
// Gets the recipes that match the name with optional filter and sort options
63-
AH.recipe().getRecipeFromName(recipeName, filter, sort);
64-
// Gets the first recipe that matches the name with optional filter and sort options
65-
AH.recipe().getFirstRecipeFromName(recipeName, filter, sort);
66-
```
67-
68-
### Filtering and sorting
69-
#### Products
70-
It is possible to use certain product filters and sort options, these are provided via the ``ProductFilter`` and ``ProductSortOptions`` interface and enum respectively. The following sort options are available for products: relevant, price descending, price ascending. Products can also be filtered by brand (name), type (number), properties (described in ``ProductPropertyFilter``) and whether they are currently in the bonus or not.
71-
72-
#### Recipes
73-
It is possible to use certain recipe filters and sort options, these are provided via the RecipeFilter and RecipeSortOptions interface and enum respectively. The following sort options are available for products: newest, relevant, rating, preperation time. Recipes can also be filtered via enums, namely ``OftenUsedRecipeFilterOptions``, ``CourseRecipeFilterOptions``, ``DishTypeRecipeFilterOptions``, ``ContentRecipeFilterOptions``, ``WishesRecipeFilterOptions``, ``SpecialOccasionRecipeFilterOptions``, ``SeasonRecipeFilterOptions``, ``TechniqueRecipeFilterOptions`` and ``KitchenOriginRecipeFilterOptions``.
74-
75-
### Example usage
40+
## Example usage
41+
For all of these examples, please keep in mind that your function in which you request something should be `async` since the requests return a `Promise`.
7642
#### Products
7743
Let's say I want to find the names of the products called "Brood" but the products have to be gluten free, vegan and of the brand "AH Glutenvrij" and I want to sort on ascending price:
7844
```javascript
@@ -134,8 +100,5 @@ findNearestStore(50, 4);
134100
Wilhelminalaan 9, 4551EP
135101
```
136102

137-
### Advanced usage
138-
Every request can also be provided with additional headers and queries.
139-
140-
## Auth
103+
## Authentication
141104
Unfortunately, it is not possible to log in with your personal AH account, which means you won't be able to access your orders.

jest.config.ts

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
export default {
7+
// All imported modules in your tests should be mocked automatically
8+
// automock: false,
9+
10+
// Stop running tests after `n` failures
11+
// bail: 0,
12+
13+
// The directory where Jest should store its cached dependency information
14+
// cacheDirectory: "/tmp/jest_rs",
15+
16+
// Automatically clear mock calls, instances and results before every test
17+
clearMocks: true,
18+
19+
// Indicates whether the coverage information should be collected while executing the test
20+
collectCoverage: true,
21+
22+
// An array of glob patterns indicating a set of files for which coverage information should be collected
23+
// collectCoverageFrom: undefined,
24+
25+
// The directory where Jest should output its coverage files
26+
coverageDirectory: 'coverage',
27+
28+
// An array of regexp pattern strings used to skip coverage collection
29+
// coveragePathIgnorePatterns: [
30+
// "/node_modules/"
31+
// ],
32+
33+
// Indicates which provider should be used to instrument code for coverage
34+
coverageProvider: 'v8',
35+
36+
// A list of reporter names that Jest uses when writing coverage reports
37+
// coverageReporters: [
38+
// "json",
39+
// "text",
40+
// "lcov",
41+
// "clover"
42+
// ],
43+
44+
// An object that configures minimum threshold enforcement for coverage results
45+
// coverageThreshold: undefined,
46+
47+
// A path to a custom dependency extractor
48+
// dependencyExtractor: undefined,
49+
50+
// Make calling deprecated APIs throw helpful error messages
51+
// errorOnDeprecated: false,
52+
53+
// Force coverage collection from ignored files using an array of glob patterns
54+
// forceCoverageMatch: [],
55+
56+
// A path to a module which exports an async function that is triggered once before all test suites
57+
// globalSetup: undefined,
58+
59+
// A path to a module which exports an async function that is triggered once after all test suites
60+
// globalTeardown: undefined,
61+
62+
// A set of global variables that need to be available in all test environments
63+
// globals: {},
64+
65+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
66+
// maxWorkers: "50%",
67+
68+
// An array of directory names to be searched recursively up from the requiring module's location
69+
// moduleDirectories: [
70+
// "node_modules"
71+
// ],
72+
73+
// An array of file extensions your modules use
74+
// moduleFileExtensions: [
75+
// "js",
76+
// "jsx",
77+
// "ts",
78+
// "tsx",
79+
// "json",
80+
// "node"
81+
// ],
82+
83+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
84+
// moduleNameMapper: {},
85+
86+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
87+
// modulePathIgnorePatterns: [],
88+
89+
// Activates notifications for test results
90+
// notify: false,
91+
92+
// An enum that specifies notification mode. Requires { notify: true }
93+
// notifyMode: "failure-change",
94+
95+
// A preset that is used as a base for Jest's configuration
96+
preset: 'ts-jest',
97+
98+
// Run tests from one or more projects
99+
// projects: undefined,
100+
101+
// Use this configuration option to add custom reporters to Jest
102+
// reporters: undefined,
103+
104+
// Automatically reset mock state before every test
105+
// resetMocks: false,
106+
107+
// Reset the module registry before running each individual test
108+
// resetModules: false,
109+
110+
// A path to a custom resolver
111+
// resolver: undefined,
112+
113+
// Automatically restore mock state and implementation before every test
114+
// restoreMocks: false,
115+
116+
// The root directory that Jest should scan for tests and modules within
117+
// rootDir: undefined,
118+
119+
// A list of paths to directories that Jest should use to search for files in
120+
// roots: [
121+
// "<rootDir>"
122+
// ],
123+
124+
// Allows you to use a custom runner instead of Jest's default test runner
125+
// runner: "jest-runner",
126+
127+
// The paths to modules that run some code to configure or set up the testing environment before each test
128+
// setupFiles: [],
129+
130+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
131+
// setupFilesAfterEnv: [],
132+
133+
// The number of seconds after which a test is considered as slow and reported as such in the results.
134+
// slowTestThreshold: 5,
135+
136+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
137+
// snapshotSerializers: [],
138+
139+
// The test environment that will be used for testing
140+
testEnvironment: 'node'
141+
142+
// Options that will be passed to the testEnvironment
143+
// testEnvironmentOptions: {},
144+
145+
// Adds a location field to test results
146+
// testLocationInResults: false,
147+
148+
// The glob patterns Jest uses to detect test files
149+
// testMatch: [
150+
// "**/__tests__/**/*.[jt]s?(x)",
151+
// "**/?(*.)+(spec|test).[tj]s?(x)"
152+
// ],
153+
154+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
155+
// testPathIgnorePatterns: [
156+
// "/node_modules/"
157+
// ],
158+
159+
// The regexp pattern or array of patterns that Jest uses to detect test files
160+
// testRegex: [],
161+
162+
// This option allows the use of a custom results processor
163+
// testResultsProcessor: undefined,
164+
165+
// This option allows use of a custom test runner
166+
// testRunner: "jest-circus/runner",
167+
168+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
169+
// testURL: "http://localhost",
170+
171+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
172+
// timers: "real",
173+
174+
// A map from regular expressions to paths to transformers
175+
// transform: undefined,
176+
177+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
178+
// transformIgnorePatterns: [
179+
// "/node_modules/",
180+
// "\\.pnp\\.[^\\/]+$"
181+
// ],
182+
183+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
184+
// unmockedModulePathPatterns: undefined,
185+
186+
// Indicates whether each individual test should be reported during the run
187+
// verbose: undefined,
188+
189+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
190+
// watchPathIgnorePatterns: [],
191+
192+
// Whether to use watchman for file crawling
193+
// watchman: true,
194+
};

0 commit comments

Comments
 (0)