@loopback/example-references-many 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +5 -0
- package/.eslintrc.js +8 -0
- package/.prettierignore +2 -0
- package/.prettierrc +7 -0
- package/.vscode/settings.json +20 -0
- package/.vscode/tasks.json +29 -0
- package/CHANGELOG.md +25 -0
- package/Dockerfile +28 -0
- package/LICENSE +25 -0
- package/README.md +49 -0
- package/data/db.json +18 -0
- package/dist/__tests__/acceptance/account.acceptance.d.ts +1 -0
- package/dist/__tests__/acceptance/account.acceptance.js +111 -0
- package/dist/__tests__/acceptance/account.acceptance.js.map +1 -0
- package/dist/__tests__/acceptance/customer.acceptance.d.ts +1 -0
- package/dist/__tests__/acceptance/customer.acceptance.js +163 -0
- package/dist/__tests__/acceptance/customer.acceptance.js.map +1 -0
- package/dist/__tests__/acceptance/home-page.acceptance.d.ts +1 -0
- package/dist/__tests__/acceptance/home-page.acceptance.js +31 -0
- package/dist/__tests__/acceptance/home-page.acceptance.js.map +1 -0
- package/dist/__tests__/acceptance/test-helper.d.ts +7 -0
- package/dist/__tests__/acceptance/test-helper.js +20 -0
- package/dist/__tests__/acceptance/test-helper.js.map +1 -0
- package/dist/__tests__/helpers.d.ts +26 -0
- package/dist/__tests__/helpers.js +101 -0
- package/dist/__tests__/helpers.js.map +1 -0
- package/dist/__tests__/integration/customer.repository.integration.d.ts +1 -0
- package/dist/__tests__/integration/customer.repository.integration.js +61 -0
- package/dist/__tests__/integration/customer.repository.integration.js.map +1 -0
- package/dist/__tests__/unit/controllers/account.controller.unit.d.ts +1 -0
- package/dist/__tests__/unit/controllers/account.controller.unit.js +106 -0
- package/dist/__tests__/unit/controllers/account.controller.unit.js.map +1 -0
- package/dist/__tests__/unit/controllers/customer.controller.unit.d.ts +1 -0
- package/dist/__tests__/unit/controllers/customer.controller.unit.js +108 -0
- package/dist/__tests__/unit/controllers/customer.controller.unit.js.map +1 -0
- package/dist/application.d.ts +272 -0
- package/dist/application.js +41 -0
- package/dist/application.js.map +1 -0
- package/dist/controllers/account.controller.d.ts +15 -0
- package/dist/controllers/account.controller.js +192 -0
- package/dist/controllers/account.controller.js.map +1 -0
- package/dist/controllers/customer.controller.d.ts +15 -0
- package/dist/controllers/customer.controller.js +192 -0
- package/dist/controllers/customer.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +2 -0
- package/dist/controllers/index.js +10 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/datasources/db.datasource.d.ts +12 -0
- package/dist/datasources/db.datasource.js +34 -0
- package/dist/datasources/db.datasource.js.map +1 -0
- package/dist/datasources/index.d.ts +1 -0
- package/dist/datasources/index.js +9 -0
- package/dist/datasources/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +1 -0
- package/dist/migrate.js +25 -0
- package/dist/migrate.js.map +1 -0
- package/dist/models/account.model.d.ts +9 -0
- package/dist/models/account.model.js +35 -0
- package/dist/models/account.model.js.map +1 -0
- package/dist/models/customer.model.d.ts +13 -0
- package/dist/models/customer.model.js +45 -0
- package/dist/models/customer.model.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +10 -0
- package/dist/models/index.js.map +1 -0
- package/dist/openapi-spec.d.ts +1 -0
- package/dist/openapi-spec.js +28 -0
- package/dist/openapi-spec.js.map +1 -0
- package/dist/repositories/account.repository.d.ts +6 -0
- package/dist/repositories/account.repository.js +23 -0
- package/dist/repositories/account.repository.js.map +1 -0
- package/dist/repositories/customer.repository.d.ts +11 -0
- package/dist/repositories/customer.repository.js +29 -0
- package/dist/repositories/customer.repository.js.map +1 -0
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.js +10 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/sequence.d.ts +3 -0
- package/dist/sequence.js +12 -0
- package/dist/sequence.js.map +1 -0
- package/package.json +78 -0
- package/public/index.html +72 -0
- package/src/__tests__/acceptance/account.acceptance.ts +139 -0
- package/src/__tests__/acceptance/customer.acceptance.ts +198 -0
- package/src/__tests__/acceptance/home-page.acceptance.ts +36 -0
- package/src/__tests__/acceptance/test-helper.ts +29 -0
- package/src/__tests__/helpers.ts +119 -0
- package/src/__tests__/integration/customer.repository.integration.ts +80 -0
- package/src/__tests__/unit/controllers/account.controller.unit.ts +127 -0
- package/src/__tests__/unit/controllers/customer.controller.unit.ts +136 -0
- package/src/application.ts +49 -0
- package/src/controllers/account.controller.ts +177 -0
- package/src/controllers/customer.controller.ts +177 -0
- package/src/controllers/index.ts +7 -0
- package/src/datasources/db.datasource.ts +34 -0
- package/src/datasources/index.ts +6 -0
- package/src/index.ts +42 -0
- package/src/migrate.ts +25 -0
- package/src/models/account.model.ts +31 -0
- package/src/models/customer.model.ts +40 -0
- package/src/models/index.ts +7 -0
- package/src/openapi-spec.ts +28 -0
- package/src/repositories/account.repository.ts +19 -0
- package/src/repositories/customer.repository.ts +42 -0
- package/src/repositories/index.ts +7 -0
- package/src/sequence.ts +8 -0
- package/tsconfig.json +39 -0
package/.dockerignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
|
+
// Node module: @loopback/example-references-many
|
|
3
|
+
// This file is licensed under the MIT License.
|
|
4
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
extends: ['@loopback/eslint-config'],
|
|
8
|
+
};
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.rulers": [80],
|
|
3
|
+
"editor.tabCompletion": "on",
|
|
4
|
+
"editor.tabSize": 2,
|
|
5
|
+
"editor.trimAutoWhitespace": true,
|
|
6
|
+
"editor.formatOnSave": true,
|
|
7
|
+
|
|
8
|
+
"files.exclude": {
|
|
9
|
+
"**/.DS_Store": true,
|
|
10
|
+
"**/.git": true,
|
|
11
|
+
"**/.hg": true,
|
|
12
|
+
"**/.svn": true,
|
|
13
|
+
"**/CVS": true,
|
|
14
|
+
"dist": true,
|
|
15
|
+
},
|
|
16
|
+
"files.insertFinalNewline": true,
|
|
17
|
+
"files.trimTrailingWhitespace": true,
|
|
18
|
+
|
|
19
|
+
"typescript.tsdk": "./node_modules/typescript/lib"
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
+
// for the documentation about the tasks.json format
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"tasks": [
|
|
6
|
+
{
|
|
7
|
+
"label": "Watch and Compile Project",
|
|
8
|
+
"type": "shell",
|
|
9
|
+
"command": "npm",
|
|
10
|
+
"args": ["--silent", "run", "build:watch"],
|
|
11
|
+
"group": {
|
|
12
|
+
"kind": "build",
|
|
13
|
+
"isDefault": true
|
|
14
|
+
},
|
|
15
|
+
"problemMatcher": "$tsc-watch"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"label": "Build, Test and Lint",
|
|
19
|
+
"type": "shell",
|
|
20
|
+
"command": "npm",
|
|
21
|
+
"args": ["--silent", "run", "test:dev"],
|
|
22
|
+
"group": {
|
|
23
|
+
"kind": "test",
|
|
24
|
+
"isDefault": true
|
|
25
|
+
},
|
|
26
|
+
"problemMatcher": ["$tsc", "$eslint-stylish", "$eslint-compact"]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [6.0.1](https://github.com/loopbackio/loopback-next/compare/@loopback/example-references-many@6.0.0...@loopback/example-references-many@6.0.1) (2022-06-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/example-references-many
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 6.0.0 (2022-05-05)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### ⚠ BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* remove node v12 support
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* add support for node v18 ([ccb4c61](https://github.com/loopbackio/loopback-next/commit/ccb4c61307d94ab7bb07a19c547dfc4fa7d388a8))
|
|
24
|
+
* remove node v12 support ([5f66e5b](https://github.com/loopbackio/loopback-next/commit/5f66e5bd288ba806b3aa6550fc29c5009de8b60d))
|
|
25
|
+
* **repository:** support `ReferencesMany` relation ([371a6dc](https://github.com/loopbackio/loopback-next/commit/371a6dcdf32d1a9a674f22528160b775f6639364))
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Check out https://hub.docker.com/_/node to select a new base image
|
|
2
|
+
FROM node:16-slim
|
|
3
|
+
|
|
4
|
+
# Set to a non-root built-in user `node`
|
|
5
|
+
USER node
|
|
6
|
+
|
|
7
|
+
# Create app directory (with user `node`)
|
|
8
|
+
RUN mkdir -p /home/node/app
|
|
9
|
+
|
|
10
|
+
WORKDIR /home/node/app
|
|
11
|
+
|
|
12
|
+
# Install app dependencies
|
|
13
|
+
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
|
14
|
+
# where available (npm@5+)
|
|
15
|
+
COPY --chown=node package*.json ./
|
|
16
|
+
|
|
17
|
+
RUN npm install
|
|
18
|
+
|
|
19
|
+
# Bundle app source code
|
|
20
|
+
COPY --chown=node . .
|
|
21
|
+
|
|
22
|
+
RUN npm run build
|
|
23
|
+
|
|
24
|
+
# Bind to all network interfaces so that it can be mapped to the host OS
|
|
25
|
+
ENV HOST=0.0.0.0 PORT=3000
|
|
26
|
+
|
|
27
|
+
EXPOSE ${PORT}
|
|
28
|
+
CMD [ "node", "." ]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) IBM Corp. and LoopBack contributors 2018,2019.
|
|
2
|
+
Node module: @loopback/example-references-many
|
|
3
|
+
This project is licensed under the MIT License, full text below.
|
|
4
|
+
|
|
5
|
+
--------
|
|
6
|
+
|
|
7
|
+
MIT license
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @loopback/example-references-many
|
|
2
|
+
|
|
3
|
+
## Try it out
|
|
4
|
+
|
|
5
|
+
1. Run the `lb4 example` command to select and clone the repository:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
lb4 example references-many
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2. Switch to the directory.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
cd loopback4-example-references-many
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. Finally, start the application!
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
$ npm start
|
|
21
|
+
|
|
22
|
+
Server is running at http://127.0.0.1:3000
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Feel free to look around in the application's code to get a feel for how it
|
|
26
|
+
works.
|
|
27
|
+
|
|
28
|
+
### Bugs/Feedback
|
|
29
|
+
|
|
30
|
+
Open an issue in [loopback-next](https://github.com/loopbackio/loopback-next)
|
|
31
|
+
and we'll take a look!
|
|
32
|
+
|
|
33
|
+
## Contributions
|
|
34
|
+
|
|
35
|
+
- [Guidelines](https://github.com/loopbackio/loopback-next/blob/master/docs/CONTRIBUTING.md)
|
|
36
|
+
- [Join the team](https://github.com/loopbackio/loopback-next/issues/110)
|
|
37
|
+
|
|
38
|
+
## Tests
|
|
39
|
+
|
|
40
|
+
Run `npm test` from the root folder.
|
|
41
|
+
|
|
42
|
+
## Contributors
|
|
43
|
+
|
|
44
|
+
See
|
|
45
|
+
[all contributors](https://github.com/loopbackio/loopback-next/graphs/contributors).
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
package/data/db.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ids": {
|
|
3
|
+
"Customer": 5,
|
|
4
|
+
"Account": 3
|
|
5
|
+
},
|
|
6
|
+
"models": {
|
|
7
|
+
"Customer": {
|
|
8
|
+
"1": "{\"firstName\":\"John\",\"lastName\":\"Doe\",\"accountIds\":[\"1\",\"2\"],\"id\":1}",
|
|
9
|
+
"2": "{\"firstName\":\"Tommy\",\"lastName\":\"Lee\",\"accountIds\":[\"1\"],\"id\":2}",
|
|
10
|
+
"3": "{\"firstName\":\"Julian\",\"lastName\":\"Lennon\",\"accountIds\":[],\"id\":3}",
|
|
11
|
+
"4": "{\"firstName\":\"Monica\",\"lastName\":\"Raymund\",\"accountIds\":[],\"id\":4}"
|
|
12
|
+
},
|
|
13
|
+
"Account": {
|
|
14
|
+
"1": "{\"balance\":0,\"id\":1}",
|
|
15
|
+
"2": "{\"balance\":20,\"id\":2}"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/example-references-many
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const repository_1 = require("@loopback/repository");
|
|
8
|
+
const testlab_1 = require("@loopback/testlab");
|
|
9
|
+
const helpers_1 = require("../helpers");
|
|
10
|
+
describe('ReferencesManyApplication', () => {
|
|
11
|
+
let app;
|
|
12
|
+
let client;
|
|
13
|
+
let accountRepo;
|
|
14
|
+
before(async () => {
|
|
15
|
+
app = await (0, helpers_1.givenRunningApplicationWithCustomConfiguration)();
|
|
16
|
+
});
|
|
17
|
+
after(() => app.stop());
|
|
18
|
+
before(async () => {
|
|
19
|
+
({ accountRepo } = await (0, helpers_1.givenAccountRepositories)(app));
|
|
20
|
+
});
|
|
21
|
+
before(() => {
|
|
22
|
+
client = (0, testlab_1.createRestAppClient)(app);
|
|
23
|
+
});
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
await accountRepo.deleteAll();
|
|
26
|
+
});
|
|
27
|
+
it('creates an account', async function () {
|
|
28
|
+
const account = (0, helpers_1.givenAccount)();
|
|
29
|
+
const response = await client.post('/accounts').send(account).expect(200);
|
|
30
|
+
(0, testlab_1.expect)(response.body).to.containDeep(account);
|
|
31
|
+
const result = await accountRepo.findById(response.body.id);
|
|
32
|
+
(0, testlab_1.expect)(result).to.containDeep(account);
|
|
33
|
+
});
|
|
34
|
+
it('gets a count of accounts', async function () {
|
|
35
|
+
await (0, helpers_1.givenAccountInstance)(accountRepo, { balance: 22 });
|
|
36
|
+
await (0, helpers_1.givenAccountInstance)(accountRepo, { balance: 33 });
|
|
37
|
+
await client.get('/accounts/count').expect(200, { count: 2 });
|
|
38
|
+
});
|
|
39
|
+
context('when dealing with a single persisted account', () => {
|
|
40
|
+
let persistedAccount;
|
|
41
|
+
beforeEach(async () => {
|
|
42
|
+
persistedAccount = await (0, helpers_1.givenAccountInstance)(accountRepo);
|
|
43
|
+
});
|
|
44
|
+
it('gets an account by ID', () => {
|
|
45
|
+
return client
|
|
46
|
+
.get(`/accounts/${persistedAccount.id}`)
|
|
47
|
+
.send()
|
|
48
|
+
.expect(200, (0, testlab_1.toJSON)(persistedAccount));
|
|
49
|
+
});
|
|
50
|
+
it('returns 404 when getting an account that does not exist', () => {
|
|
51
|
+
return client.get('/accounts/99999').expect(404);
|
|
52
|
+
});
|
|
53
|
+
it('replaces the account by ID', async () => {
|
|
54
|
+
const updatedAccount = (0, helpers_1.givenAccount)({
|
|
55
|
+
balance: 44,
|
|
56
|
+
});
|
|
57
|
+
await client
|
|
58
|
+
.put(`/accounts/${persistedAccount.id}`)
|
|
59
|
+
.send(updatedAccount)
|
|
60
|
+
.expect(204);
|
|
61
|
+
const result = await accountRepo.findById(persistedAccount.id);
|
|
62
|
+
(0, testlab_1.expect)(result).to.containEql(updatedAccount);
|
|
63
|
+
});
|
|
64
|
+
it('returns 404 when replacing an account that does not exist', () => {
|
|
65
|
+
return client.put('/accounts/99999').send((0, helpers_1.givenAccount)()).expect(404);
|
|
66
|
+
});
|
|
67
|
+
it('updates the account by ID ', async () => {
|
|
68
|
+
const updatedAccount = (0, helpers_1.givenAccount)({
|
|
69
|
+
balance: 55,
|
|
70
|
+
});
|
|
71
|
+
await client
|
|
72
|
+
.patch(`/accounts/${persistedAccount.id}`)
|
|
73
|
+
.send(updatedAccount)
|
|
74
|
+
.expect(204);
|
|
75
|
+
const result = await accountRepo.findById(persistedAccount.id);
|
|
76
|
+
(0, testlab_1.expect)(result).to.containEql(updatedAccount);
|
|
77
|
+
});
|
|
78
|
+
it('returns 404 when updating an account that does not exist', () => {
|
|
79
|
+
return client.patch('/account/99999').send((0, helpers_1.givenAccount)()).expect(404);
|
|
80
|
+
});
|
|
81
|
+
it('deletes the account', async () => {
|
|
82
|
+
await client.del(`/accounts/${persistedAccount.id}`).send().expect(204);
|
|
83
|
+
await (0, testlab_1.expect)(accountRepo.findById(persistedAccount.id)).to.be.rejectedWith(repository_1.EntityNotFoundError);
|
|
84
|
+
});
|
|
85
|
+
it('returns 404 when deleting an account that does not exist', async () => {
|
|
86
|
+
await client.del(`/accounts/99999`).expect(404);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
it('queries accounts with a filter', async () => {
|
|
90
|
+
await (0, helpers_1.givenAccountInstance)(accountRepo, { balance: 77 });
|
|
91
|
+
const emptyAccount = await (0, helpers_1.givenAccountInstance)(accountRepo, { balance: 0 });
|
|
92
|
+
await client
|
|
93
|
+
.get('/accounts')
|
|
94
|
+
.query({ filter: { where: { balance: 0 } } })
|
|
95
|
+
.expect(200, [(0, testlab_1.toJSON)(emptyAccount)]);
|
|
96
|
+
});
|
|
97
|
+
it('updates accounts using a filter', async () => {
|
|
98
|
+
await (0, helpers_1.givenAccountInstance)(accountRepo, {
|
|
99
|
+
balance: 1,
|
|
100
|
+
});
|
|
101
|
+
await (0, helpers_1.givenAccountInstance)(accountRepo, {
|
|
102
|
+
balance: 2,
|
|
103
|
+
});
|
|
104
|
+
await client
|
|
105
|
+
.patch('/accounts')
|
|
106
|
+
.query({ where: { balance: 2 } })
|
|
107
|
+
.send({ balance: 3 })
|
|
108
|
+
.expect(200, { count: 1 });
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=account.acceptance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.acceptance.js","sourceRoot":"","sources":["../../../src/__tests__/acceptance/account.acceptance.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,+CAA+C;AAC/C,gEAAgE;;AAEhE,qDAAyD;AACzD,+CAA8E;AAI9E,wCAKoB;AAEpB,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,GAA8B,CAAC;IACnC,IAAI,MAAc,CAAC;IACnB,IAAI,WAA8B,CAAC;IAEnC,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,GAAG,GAAG,MAAM,IAAA,wDAA8C,GAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,CAAC,EAAC,WAAW,EAAC,GAAG,MAAM,IAAA,kCAAwB,EAAC,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,EAAE;QACV,MAAM,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,WAAW,CAAC,SAAS,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE,KAAK;QAC5B,MAAM,OAAO,GAAG,IAAA,sBAAY,GAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1E,IAAA,gBAAM,EAAC,QAAQ,CAAC,IA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AoB,EAAC,WAAW,EAAE;YACtC,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QACH,MAAM,IAAA,8BAAoB,EAAC,WAAW,EAAE;YACtC,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QACH,MAAM,MAAM;aACT,KAAK,CAAC,WAAW,CAAC;aAClB,KAAK,CAAC,EAAC,KAAK,EAAE,EAAC,OAAO,EAAE,CAAC,EAAC,EAAC,CAAC;aAC5B,IAAI,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,CAAC;aAClB,MAAM,CAAC,GAAG,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/example-references-many
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const repository_1 = require("@loopback/repository");
|
|
8
|
+
const testlab_1 = require("@loopback/testlab");
|
|
9
|
+
const helpers_1 = require("../helpers");
|
|
10
|
+
describe('ReferencesManyApplication', () => {
|
|
11
|
+
let app;
|
|
12
|
+
let client;
|
|
13
|
+
let customerRepo;
|
|
14
|
+
let accountRepo;
|
|
15
|
+
before(async () => {
|
|
16
|
+
app = await (0, helpers_1.givenRunningApplicationWithCustomConfiguration)();
|
|
17
|
+
});
|
|
18
|
+
after(() => app.stop());
|
|
19
|
+
before(async () => {
|
|
20
|
+
({ customerRepo, accountRepo } = await (0, helpers_1.givenCustomerRepositories)(app));
|
|
21
|
+
});
|
|
22
|
+
before(() => {
|
|
23
|
+
client = (0, testlab_1.createRestAppClient)(app);
|
|
24
|
+
});
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
await customerRepo.deleteAll();
|
|
27
|
+
await accountRepo.deleteAll();
|
|
28
|
+
});
|
|
29
|
+
it('creates a customer', async function () {
|
|
30
|
+
const customer = (0, helpers_1.givenCustomer)();
|
|
31
|
+
const response = await client.post('/customers').send(customer).expect(200);
|
|
32
|
+
(0, testlab_1.expect)(response.body).to.containDeep(customer);
|
|
33
|
+
const result = await customerRepo.findById(response.body.id);
|
|
34
|
+
(0, testlab_1.expect)(result).to.containDeep(customer);
|
|
35
|
+
});
|
|
36
|
+
it('gets a count of customers', async function () {
|
|
37
|
+
await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
38
|
+
firstName: 'Andrew',
|
|
39
|
+
lastName: 'Jackson',
|
|
40
|
+
});
|
|
41
|
+
await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
42
|
+
firstName: 'James',
|
|
43
|
+
lastName: 'Gunn',
|
|
44
|
+
});
|
|
45
|
+
await client.get('/customers/count').expect(200, { count: 2 });
|
|
46
|
+
});
|
|
47
|
+
context('when dealing with a single persisted customer', () => {
|
|
48
|
+
let persistedCustomer;
|
|
49
|
+
beforeEach(async () => {
|
|
50
|
+
persistedCustomer = await (0, helpers_1.givenCustomerInstance)(customerRepo);
|
|
51
|
+
});
|
|
52
|
+
it('gets a customer by ID', () => {
|
|
53
|
+
return client
|
|
54
|
+
.get(`/customers/${persistedCustomer.id}`)
|
|
55
|
+
.send()
|
|
56
|
+
.expect(200, (0, testlab_1.toJSON)(persistedCustomer));
|
|
57
|
+
});
|
|
58
|
+
it('returns 404 when getting a customer that does not exist', () => {
|
|
59
|
+
return client.get('/customers/99999').expect(404);
|
|
60
|
+
});
|
|
61
|
+
it('replaces the customer by ID', async () => {
|
|
62
|
+
const updatedCustomer = (0, helpers_1.givenCustomer)({
|
|
63
|
+
firstName: 'Andrew',
|
|
64
|
+
lastName: 'Jackson',
|
|
65
|
+
});
|
|
66
|
+
await client
|
|
67
|
+
.put(`/customers/${persistedCustomer.id}`)
|
|
68
|
+
.send(updatedCustomer)
|
|
69
|
+
.expect(204);
|
|
70
|
+
const result = await customerRepo.findById(persistedCustomer.id);
|
|
71
|
+
(0, testlab_1.expect)(result).to.containEql(updatedCustomer);
|
|
72
|
+
});
|
|
73
|
+
it('returns 404 when replacing a customer that does not exist', () => {
|
|
74
|
+
return client.put('/customers/99999').send((0, helpers_1.givenCustomer)()).expect(404);
|
|
75
|
+
});
|
|
76
|
+
it('updates the customer by ID ', async () => {
|
|
77
|
+
const updatedCustomer = (0, helpers_1.givenCustomer)({
|
|
78
|
+
firstName: 'Tommy',
|
|
79
|
+
lastName: 'Jeans',
|
|
80
|
+
});
|
|
81
|
+
await client
|
|
82
|
+
.patch(`/customers/${persistedCustomer.id}`)
|
|
83
|
+
.send(updatedCustomer)
|
|
84
|
+
.expect(204);
|
|
85
|
+
const result = await customerRepo.findById(persistedCustomer.id);
|
|
86
|
+
(0, testlab_1.expect)(result).to.containEql(updatedCustomer);
|
|
87
|
+
});
|
|
88
|
+
it('returns 404 when updating a customer that does not exist', () => {
|
|
89
|
+
return client.patch('/customer/99999').send((0, helpers_1.givenCustomer)()).expect(404);
|
|
90
|
+
});
|
|
91
|
+
it('deletes the customer', async () => {
|
|
92
|
+
await client.del(`/customers/${persistedCustomer.id}`).send().expect(204);
|
|
93
|
+
await (0, testlab_1.expect)(customerRepo.findById(persistedCustomer.id)).to.be.rejectedWith(repository_1.EntityNotFoundError);
|
|
94
|
+
});
|
|
95
|
+
it('returns 404 when deleting a customer that does not exist', async () => {
|
|
96
|
+
await client.del(`/customers/99999`).expect(404);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
it('queries customers with a filter', async () => {
|
|
100
|
+
await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
101
|
+
firstName: 'Andrew',
|
|
102
|
+
lastName: 'Jackson',
|
|
103
|
+
});
|
|
104
|
+
const unnamedCustomer = await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
105
|
+
firstName: '',
|
|
106
|
+
lastName: '',
|
|
107
|
+
});
|
|
108
|
+
await client
|
|
109
|
+
.get('/customers')
|
|
110
|
+
.query({ filter: { where: { firstName: '' } } })
|
|
111
|
+
.expect(200, [(0, testlab_1.toJSON)(unnamedCustomer)]);
|
|
112
|
+
});
|
|
113
|
+
it('updates customers using a filter', async () => {
|
|
114
|
+
await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
115
|
+
firstName: 'Andrew',
|
|
116
|
+
lastName: 'Jackson',
|
|
117
|
+
});
|
|
118
|
+
await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
119
|
+
firstName: 'James',
|
|
120
|
+
lastName: 'Gunn',
|
|
121
|
+
});
|
|
122
|
+
await client
|
|
123
|
+
.patch('/customers')
|
|
124
|
+
.query({ where: { firstName: 'Andrew' } })
|
|
125
|
+
.send({ firstName: 'Tommy' })
|
|
126
|
+
.expect(200, { count: 1 });
|
|
127
|
+
});
|
|
128
|
+
it('includes Accounts in query result', async () => {
|
|
129
|
+
const firstAccount = await (0, helpers_1.givenAccountInstance)(accountRepo, { balance: 10 });
|
|
130
|
+
const secondAccount = await (0, helpers_1.givenAccountInstance)(accountRepo, {
|
|
131
|
+
balance: 20,
|
|
132
|
+
});
|
|
133
|
+
const customer = await (0, helpers_1.givenCustomerInstance)(customerRepo);
|
|
134
|
+
const customerWithAccounts = await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
135
|
+
accountIds: [firstAccount.id, secondAccount.id],
|
|
136
|
+
});
|
|
137
|
+
const filter = JSON.stringify({ include: ['accounts'] });
|
|
138
|
+
const response = await client.get('/customers').query({ filter: filter });
|
|
139
|
+
(0, testlab_1.expect)(response.body).to.have.length(2);
|
|
140
|
+
(0, testlab_1.expect)(response.body[0]).to.deepEqual({
|
|
141
|
+
...(0, testlab_1.toJSON)(customer),
|
|
142
|
+
accounts: [],
|
|
143
|
+
});
|
|
144
|
+
(0, testlab_1.expect)(response.body[1]).to.deepEqual({
|
|
145
|
+
...(0, testlab_1.toJSON)(customerWithAccounts),
|
|
146
|
+
accounts: [(0, testlab_1.toJSON)(firstAccount), (0, testlab_1.toJSON)(secondAccount)],
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
it('not includes a not existed Account in query result', async () => {
|
|
150
|
+
const notExistedId = 1;
|
|
151
|
+
const customer = await (0, helpers_1.givenCustomerInstance)(customerRepo, {
|
|
152
|
+
accountIds: [notExistedId],
|
|
153
|
+
});
|
|
154
|
+
const filter = JSON.stringify({ include: ['accounts'] });
|
|
155
|
+
const response = await client.get('/customers').query({ filter: filter });
|
|
156
|
+
(0, testlab_1.expect)(response.body).to.have.length(1);
|
|
157
|
+
(0, testlab_1.expect)(response.body[0]).to.deepEqual({
|
|
158
|
+
...(0, testlab_1.toJSON)(customer),
|
|
159
|
+
accounts: [],
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
//# sourceMappingURL=customer.acceptance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.acceptance.js","sourceRoot":"","sources":["../../../src/__tests__/acceptance/customer.acceptance.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,+CAA+C;AAC/C,gEAAgE;;AAEhE,qDAAyD;AACzD,+CAA8E;AAI9E,wCAMoB;AAEpB,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,GAA8B,CAAC;IACnC,IAAI,MAAc,CAAC;IACnB,IAAI,YAAgC,CAAC;IACrC,IAAI,WAA8B,CAAC;IAEnC,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,GAAG,GAAG,MAAM,IAAA,wDAA8C,GAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,CAAC,EAAC,YA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CAAC,EAAE,IAAA,gBAAM,EAAC,aAAa,CAAC,CAAC;SACxD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,YAAY,GAAG,CAAC,CAAC;QACvB,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAqB,EAAC,YAAY,EAAE;YACzD,UAAU,EAAE,CAAC,YAAY,CAAC;SAC3B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,CAAC,UAAU,CAAC,EAAC,CAAC,CAAC;QAEvD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;QAExE,IAAA,gBAAM,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACxC,IAAA,gBAAM,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC;YACpC,GAAG,IAAA,gBAAM,EAAC,QAAQ,CAAC;YACnB,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/example-references-many
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const test_helper_1 = require("./test-helper");
|
|
8
|
+
describe('HomePage', () => {
|
|
9
|
+
let app;
|
|
10
|
+
let client;
|
|
11
|
+
before('setupApplication', async () => {
|
|
12
|
+
({ app, client } = await (0, test_helper_1.setupApplication)());
|
|
13
|
+
});
|
|
14
|
+
after(async () => {
|
|
15
|
+
await app.stop();
|
|
16
|
+
});
|
|
17
|
+
it('exposes a default home page', async () => {
|
|
18
|
+
await client
|
|
19
|
+
.get('/')
|
|
20
|
+
.expect(200)
|
|
21
|
+
.expect('Content-Type', /text\/html/);
|
|
22
|
+
});
|
|
23
|
+
it('exposes self-hosted explorer', async () => {
|
|
24
|
+
await client
|
|
25
|
+
.get('/explorer/')
|
|
26
|
+
.expect(200)
|
|
27
|
+
.expect('Content-Type', /text\/html/)
|
|
28
|
+
.expect(/<title>LoopBack API Explorer/);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=home-page.acceptance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"home-page.acceptance.js","sourceRoot":"","sources":["../../../src/__tests__/acceptance/home-page.acceptance.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,+CAA+C;AAC/C,gEAAgE;;AAIhE,+CAA+C;AAE/C,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,GAA8B,CAAC;IACnC,IAAI,MAAc,CAAC;IAEnB,MAAM,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACpC,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,MAAM,IAAA,8BAAgB,GAAE,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,MAAM;aACT,GAAG,CAAC,GAAG,CAAC;aACR,MAAM,CAAC,GAAG,CAAC;aACX,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,MAAM;aACT,GAAG,CAAC,YAAY,CAAC;aACjB,MAAM,CAAC,GAAG,CAAC;aACX,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC;aACpC,MAAM,CAAC,8BAA8B,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/example-references-many
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.setupApplication = void 0;
|
|
8
|
+
const testlab_1 = require("@loopback/testlab");
|
|
9
|
+
const __1 = require("../..");
|
|
10
|
+
async function setupApplication() {
|
|
11
|
+
const app = new __1.ReferencesManyApplication({
|
|
12
|
+
rest: (0, testlab_1.givenHttpServerConfig)(),
|
|
13
|
+
});
|
|
14
|
+
await app.boot();
|
|
15
|
+
await app.start();
|
|
16
|
+
const client = (0, testlab_1.createRestAppClient)(app);
|
|
17
|
+
return { app, client };
|
|
18
|
+
}
|
|
19
|
+
exports.setupApplication = setupApplication;
|
|
20
|
+
//# sourceMappingURL=test-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helper.js","sourceRoot":"","sources":["../../../src/__tests__/acceptance/test-helper.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,+CAA+C;AAC/C,gEAAgE;;;AAEhE,+CAI2B;AAC3B,6BAAgD;AAEzC,KAAK,UAAU,gBAAgB;IACpC,MAAM,GAAG,GAAG,IAAI,6BAAyB,CAAC;QACxC,IAAI,EAAE,IAAA,+BAAqB,GAAE;KAC9B,CAAC,CAAC;IAEH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAElB,MAAM,MAAM,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;IAExC,OAAO,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC;AACvB,CAAC;AAXD,4CAWC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { juggler } from '@loopback/repository';
|
|
2
|
+
import { ReferencesManyApplication } from '../application';
|
|
3
|
+
import { Account, Customer } from '../models';
|
|
4
|
+
import { AccountRepository, CustomerRepository } from '../repositories';
|
|
5
|
+
/**
|
|
6
|
+
* Generate a complete Customer object for use with tests.
|
|
7
|
+
* @param customer - A partial (or complete) Customer object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function givenCustomer(customer?: Partial<Customer>): Customer;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a complete Account object for use with tests.
|
|
12
|
+
* @param account - A partial (or complete) Account object.
|
|
13
|
+
*/
|
|
14
|
+
export declare function givenAccount(account?: Partial<Account>): Account;
|
|
15
|
+
export declare function givenRunningApplicationWithCustomConfiguration(): Promise<ReferencesManyApplication>;
|
|
16
|
+
export declare function givenCustomerRepositories(app: ReferencesManyApplication): Promise<{
|
|
17
|
+
customerRepo: CustomerRepository;
|
|
18
|
+
accountRepo: AccountRepository;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function givenAccountRepositories(app: ReferencesManyApplication): Promise<{
|
|
21
|
+
accountRepo: AccountRepository;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function givenCustomerInstance(customerRepo: CustomerRepository, customer?: Partial<Customer>): Promise<Customer>;
|
|
24
|
+
export declare function givenAccountInstance(accountRepo: AccountRepository, account?: Partial<Account>): Promise<Account>;
|
|
25
|
+
export declare function givenEmptyDatabase(): Promise<void>;
|
|
26
|
+
export declare const testdb: juggler.DataSource;
|