Skip to content

Commit 1021a45

Browse files
feat: bring back admin-bro
1 parent 8ffe10e commit 1021a45

File tree

14 files changed

+233
-115
lines changed

14 files changed

+233
-115
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
This is an official [admin-bro](https://github.com/SoftwareBrothers/admin-bro) adapter which integrates [TypeORM](https://typeorm.io/) into admin-bro. (originally forked from [Arteha/admin-bro-typeorm](https://github.com/Arteha/admin-bro-typeorm))
44

5-
Installation: `npm install @admin-bro/typeorm`
5+
Installation: `yarn add @admin-bro/typeorm`
66

77
## Usage
88

99
The plugin can be registered using standard `AdminBro.registerAdapter` method.
1010

1111
```typescript
1212
import { Database, Resource } from "@admin-bro/typeorm";
13-
import AdminBro from '@admin-bro/core'
13+
import AdminBro from 'admin-bro'
1414

1515
AdminBro.registerAdapter({ Database, Resource });
1616

@@ -28,13 +28,13 @@ import {
2828
createConnection,
2929
ManyToOne,
3030
RelationId
31-
} from "typeorm";
32-
import * as express from "express";
33-
import { Database, Resource } from "@admin-bro/typeorm";
31+
} from 'typeorm';
32+
import * as express from 'express';
33+
import { Database, Resource } from '@admin-bro/typeorm';
3434
import { validate } from 'class-validator'
3535

36-
import AdminBro from "@admin-bro/core";
37-
import * as AdminBroExpress from "@admin-bro/express"
36+
import AdminBro from 'admin-bro';
37+
import * as AdminBroExpress from '@admin-bro/express'
3838

3939
Resource.validate = validate;
4040
AdminBro.registerAdapter({ Database, Resource });
@@ -75,7 +75,7 @@ export class Person extends BaseEntity
7575
const adminBro = new AdminBro({
7676
// databases: [connection],
7777
resources: [
78-
{ resource: Person, options: { parent: { name: "foobar" } } }
78+
{ resource: Person, options: { parent: { name: 'foobar' } } }
7979
],
8080
rootPath: '/admin',
8181
});

example-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"typescript": "3.9.7"
2121
},
2222
"dependencies": {
23-
"@admin-bro/core": "^3.0.0-beta.4",
23+
"admin-bro": "^3.0.0-beta.7",
2424
"@admin-bro/express": "^3.0.0-beta.1",
2525
"@admin-bro/typeorm": "^1.0.1",
2626
"express": "^4.17.1",

example-app/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'reflect-metadata'
22
import { createConnection } from 'typeorm'
33
import express from 'express'
4-
import AdminBro from '@admin-bro/core'
4+
import AdminBro from 'admin-bro'
55
import { buildRouter } from '@admin-bro/express'
66
import * as TypeormAdapter from '@admin-bro/typeorm'
77
import { User } from './entity/User'

example-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"sourceMap": true,
1919
"paths": {
2020
"react": ["node_modules/@types/react"],
21-
"@admin-bro/core": ["node_modules/@admin-bro/core"],
21+
"admin-bro": ["node_modules/admin-bro"],
2222
}
2323
},
2424
"include": [

example-app/yarn.lock

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,6 @@
22
# yarn lockfile v1
33

44

5-
"@admin-bro/core@^3.0.0-beta.4":
6-
version "3.0.0-beta.6"
7-
resolved "https://registry.yarnpkg.com/@admin-bro/core/-/core-3.0.0-beta.6.tgz#484482c3120a7072196ce874aa4d437bec092db8"
8-
integrity sha512-kpvG5QnTyT3UzRFGaSHKXFnMu44aASzCD3p4pD1YZnWV6blUhFcadbIN9Zb5iFRw75TIYGvhtDXaKv7iKTCHxA==
9-
dependencies:
10-
"@admin-bro/design-system" "^1.3.2"
11-
"@babel/core" "^7.10.2"
12-
"@babel/parser" "^7.10.2"
13-
"@babel/plugin-transform-runtime" "^7.10.1"
14-
"@babel/polyfill" "^7.10.1"
15-
"@babel/preset-env" "^7.10.2"
16-
"@babel/preset-react" "^7.10.1"
17-
"@babel/preset-typescript" "^7.10.1"
18-
"@babel/register" "^7.10.1"
19-
"@types/react" "^16.9.16"
20-
axios "^0.19.2"
21-
commander "^5.1.0"
22-
flat "^4.1.0"
23-
i18next "^19.1.0"
24-
lodash "^4.17.11"
25-
ora "^4.0.2"
26-
prop-types "^15.7.2"
27-
react ">= 16.13.1"
28-
react-dom ">= 16.13.1"
29-
react-i18next "^11.3.1"
30-
react-is "^16.13.1"
31-
react-redux "^7.2.0"
32-
react-router "^5.2.0"
33-
react-router-dom "^5.2.0"
34-
react-select "^2.4.2"
35-
redux "^4.0.5"
36-
rollup "^2.16.1"
37-
rollup-plugin-babel "^4.4.0"
38-
rollup-plugin-commonjs "^10.1.0"
39-
rollup-plugin-json "^4.0.0"
40-
rollup-plugin-node-resolve "^5.2.0"
41-
rollup-plugin-replace "^2.2.0"
42-
rollup-plugin-terser "^6.1.0"
43-
slash "^3.0.0"
44-
styled-components "^5.1.1"
45-
styled-system "^5.1.5"
46-
475
"@admin-bro/design-system@^1.3.2":
486
version "1.3.2"
497
resolved "https://registry.yarnpkg.com/@admin-bro/design-system/-/design-system-1.3.2.tgz#ec409d189b5112dd27f8ece974f2a7252c6db8c7"
@@ -1392,6 +1350,48 @@ accepts@~1.3.7:
13921350
mime-types "~2.1.24"
13931351
negotiator "0.6.2"
13941352

1353+
admin-bro@^3.0.0-beta.7:
1354+
version "3.0.0-beta.7"
1355+
resolved "https://registry.yarnpkg.com/admin-bro/-/admin-bro-3.0.0-beta.7.tgz#c257b70c48163f7f35ac580bf1ad39b5f26c1fc6"
1356+
integrity sha512-1F11kuWeVmB3nxhrPqZpt/SouCY8SqPy9dfgXApCjhM9gL1NfaaEXEq+QM48q69wvgcYvamRo3Dre9sIDLTJxQ==
1357+
dependencies:
1358+
"@admin-bro/design-system" "^1.3.2"
1359+
"@babel/core" "^7.10.2"
1360+
"@babel/parser" "^7.10.2"
1361+
"@babel/plugin-transform-runtime" "^7.10.1"
1362+
"@babel/polyfill" "^7.10.1"
1363+
"@babel/preset-env" "^7.10.2"
1364+
"@babel/preset-react" "^7.10.1"
1365+
"@babel/preset-typescript" "^7.10.1"
1366+
"@babel/register" "^7.10.1"
1367+
"@types/react" "^16.9.16"
1368+
axios "^0.19.2"
1369+
commander "^5.1.0"
1370+
flat "^4.1.0"
1371+
i18next "^19.1.0"
1372+
lodash "^4.17.11"
1373+
ora "^4.0.2"
1374+
prop-types "^15.7.2"
1375+
react ">= 16.13.1"
1376+
react-dom ">= 16.13.1"
1377+
react-i18next "^11.3.1"
1378+
react-is "^16.13.1"
1379+
react-redux "^7.2.0"
1380+
react-router "^5.2.0"
1381+
react-router-dom "^5.2.0"
1382+
react-select "^2.4.2"
1383+
redux "^4.0.5"
1384+
rollup "^2.16.1"
1385+
rollup-plugin-babel "^4.4.0"
1386+
rollup-plugin-commonjs "^10.1.0"
1387+
rollup-plugin-json "^4.0.0"
1388+
rollup-plugin-node-resolve "^5.2.0"
1389+
rollup-plugin-replace "^2.2.0"
1390+
rollup-plugin-terser "^6.1.0"
1391+
slash "^3.0.0"
1392+
styled-components "^5.1.1"
1393+
styled-system "^5.1.5"
1394+
13951395
ajv@^6.12.3:
13961396
version "6.12.3"
13971397
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
"author": "Artem Zabolotnyi <1arteha1@gmail.com>",
3434
"license": "MIT",
3535
"peerDependencies": {
36-
"@admin-bro/core": ">=3.0.0-beta.3",
36+
"admin-bro": ">=3.0.0-beta.7",
3737
"typeorm": ">=0.2.1"
3838
},
3939
"optionalDependencies": {},
4040
"devDependencies": {
4141
"@types/chai": "^4.2.4",
4242
"@types/mocha": "^5.2.7",
4343
"@types/node": "12.0.10",
44-
"@admin-bro/core": ">=3.0.0-beta.3",
44+
"admin-bro": ">=3.0.0-beta.3",
4545
"chai": "^4.2.0",
4646
"class-validator": "^0.11.0",
4747
"mocha": "^6.2.2",

spec/Resource.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'chai'
2-
import { BaseProperty, BaseRecord, ValidationError, Filter } from '@admin-bro/core'
2+
import { BaseProperty, BaseRecord, ValidationError, Filter } from 'admin-bro'
33
import { validate } from 'class-validator'
44

55
import { Car } from './entities/Car'

src/Database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Connection, BaseEntity } from 'typeorm'
22

3-
import { BaseDatabase } from '@admin-bro/core'
3+
import { BaseDatabase } from 'admin-bro'
44
import { Resource } from './Resource'
55

66
export class Database extends BaseDatabase {

src/Property.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata'
2-
import { BaseProperty, PropertyType } from '@admin-bro/core'
2+
import { BaseProperty, PropertyType } from 'admin-bro'
33
import { DATA_TYPES } from './utils/data-types'
44

55
export class Property extends BaseProperty {

src/Resource.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-param-reassign */
22
import { BaseEntity, In } from 'typeorm'
3-
import { BaseResource, ValidationError, Filter, BaseRecord } from '@admin-bro/core'
3+
import { BaseResource, ValidationError, Filter, BaseRecord } from 'admin-bro'
44

55
import { Property } from './Property'
66
import { convertFilter } from './utils/convertFilter'
@@ -157,13 +157,11 @@ export class Resource extends BaseResource {
157157
if (property && property.type() === 'mixed') { params[p] = JSON.parse(params[p]) }
158158
if (property && property.type() === 'number' && params[p] && params[p].toString().length) { params[p] = +params[p] }
159159
if (property && property.type() === 'reference' && params[p] && params[p].toString().length) {
160-
/**
161-
* references cannot be stored as an IDs in typeorm, so in order to mimic this) and
162-
* not fetching reference resource) change this:
163-
* { postId: "1" }
164-
* to that:
165-
* { post: { id: 1 } }
166-
*/
160+
// references cannot be stored as an IDs in typeorm, so in order to mimic this) and
161+
// not fetching reference resource) change this:
162+
// { postId: "1" }
163+
// to that:
164+
// { post: { id: 1 } }
167165
params[property.column.propertyName] = { id: +params[p] }
168166
}
169167
}

0 commit comments

Comments
 (0)