@minimaltech/ra-core-infra 0.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/LICENSE +26 -0
- package/README.md +119 -0
- package/dist/base/applications/base.application.d.ts +12 -0
- package/dist/base/applications/base.application.js +22 -0
- package/dist/base/applications/base.application.js.map +1 -0
- package/dist/base/applications/index.d.ts +1 -0
- package/dist/base/applications/index.js +2 -0
- package/dist/base/applications/index.js.map +1 -0
- package/dist/base/index.d.ts +3 -0
- package/dist/base/index.js +4 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/providers/base.provider.d.ts +10 -0
- package/dist/base/providers/base.provider.js +8 -0
- package/dist/base/providers/base.provider.js.map +1 -0
- package/dist/base/providers/count-rest-data.provider.d.ts +19 -0
- package/dist/base/providers/count-rest-data.provider.js +28 -0
- package/dist/base/providers/count-rest-data.provider.js.map +1 -0
- package/dist/base/providers/default-auth.provider.d.ts +17 -0
- package/dist/base/providers/default-auth.provider.js +116 -0
- package/dist/base/providers/default-auth.provider.js.map +1 -0
- package/dist/base/providers/default-i18n.provider.d.ts +8 -0
- package/dist/base/providers/default-i18n.provider.js +42 -0
- package/dist/base/providers/default-i18n.provider.js.map +1 -0
- package/dist/base/providers/default-rest-data.provider.d.ts +66 -0
- package/dist/base/providers/default-rest-data.provider.js +355 -0
- package/dist/base/providers/default-rest-data.provider.js.map +1 -0
- package/dist/base/providers/index.d.ts +5 -0
- package/dist/base/providers/index.js +6 -0
- package/dist/base/providers/index.js.map +1 -0
- package/dist/base/services/base-crud.service.d.ts +34 -0
- package/dist/base/services/base-crud.service.js +157 -0
- package/dist/base/services/base-crud.service.js.map +1 -0
- package/dist/base/services/base-network-request.service.d.ts +18 -0
- package/dist/base/services/base-network-request.service.js +43 -0
- package/dist/base/services/base-network-request.service.js.map +1 -0
- package/dist/base/services/default-auth.service.d.ts +22 -0
- package/dist/base/services/default-auth.service.js +38 -0
- package/dist/base/services/default-auth.service.js.map +1 -0
- package/dist/base/services/default-network-data.service.d.ts +173 -0
- package/dist/base/services/default-network-data.service.js +158 -0
- package/dist/base/services/default-network-data.service.js.map +1 -0
- package/dist/base/services/index.d.ts +4 -0
- package/dist/base/services/index.js +5 -0
- package/dist/base/services/index.js.map +1 -0
- package/dist/common/constants.d.ts +52 -0
- package/dist/common/constants.js +86 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +5 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/keys.d.ts +15 -0
- package/dist/common/keys.js +16 -0
- package/dist/common/keys.js.map +1 -0
- package/dist/common/locales/en.d.ts +2 -0
- package/dist/common/locales/en.js +207 -0
- package/dist/common/locales/en.js.map +1 -0
- package/dist/common/locales/index.d.ts +2 -0
- package/dist/common/locales/index.js +3 -0
- package/dist/common/locales/index.js.map +1 -0
- package/dist/common/locales/vi.d.ts +2 -0
- package/dist/common/locales/vi.js +206 -0
- package/dist/common/locales/vi.js.map +1 -0
- package/dist/common/types.d.ts +147 -0
- package/dist/common/types.js +2 -0
- package/dist/common/types.js.map +1 -0
- package/dist/helpers/di-container.helper.d.ts +8 -0
- package/dist/helpers/di-container.helper.js +20 -0
- package/dist/helpers/di-container.helper.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/logger.helper.d.ts +37 -0
- package/dist/helpers/logger.helper.js +65 -0
- package/dist/helpers/logger.helper.js.map +1 -0
- package/dist/helpers/network.helper.d.ts +25 -0
- package/dist/helpers/network.helper.js +56 -0
- package/dist/helpers/network.helper.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/components/CoreRaApplication.d.ts +3 -0
- package/dist/ui/components/CoreRaApplication.js +31 -0
- package/dist/ui/components/CoreRaApplication.js.map +1 -0
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.js +2 -0
- package/dist/ui/components/index.js.map +1 -0
- package/dist/ui/context.d.ts +8 -0
- package/dist/ui/context.js +7 -0
- package/dist/ui/context.js.map +1 -0
- package/dist/ui/hooks/index.d.ts +10 -0
- package/dist/ui/hooks/index.js +11 -0
- package/dist/ui/hooks/index.js.map +1 -0
- package/dist/ui/hooks/use-application-context.d.ts +2 -0
- package/dist/ui/hooks/use-application-context.js +22 -0
- package/dist/ui/hooks/use-application-context.js.map +1 -0
- package/dist/ui/hooks/use-autosave.d.ts +8 -0
- package/dist/ui/hooks/use-autosave.js +38 -0
- package/dist/ui/hooks/use-autosave.js.map +1 -0
- package/dist/ui/hooks/use-before-unload.d.ts +5 -0
- package/dist/ui/hooks/use-before-unload.js +22 -0
- package/dist/ui/hooks/use-before-unload.js.map +1 -0
- package/dist/ui/hooks/use-confirm.d.ts +10 -0
- package/dist/ui/hooks/use-confirm.js +29 -0
- package/dist/ui/hooks/use-confirm.js.map +1 -0
- package/dist/ui/hooks/use-copy-to-clipboard.d.ts +6 -0
- package/dist/ui/hooks/use-copy-to-clipboard.js +20 -0
- package/dist/ui/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/ui/hooks/use-debounce.d.ts +9 -0
- package/dist/ui/hooks/use-debounce.js +20 -0
- package/dist/ui/hooks/use-debounce.js.map +1 -0
- package/dist/ui/hooks/use-document-title.d.ts +5 -0
- package/dist/ui/hooks/use-document-title.js +11 -0
- package/dist/ui/hooks/use-document-title.js.map +1 -0
- package/dist/ui/hooks/use-injectable.d.ts +10 -0
- package/dist/ui/hooks/use-injectable.js +15 -0
- package/dist/ui/hooks/use-injectable.js.map +1 -0
- package/dist/ui/hooks/use-sizer.d.ts +6 -0
- package/dist/ui/hooks/use-sizer.js +33 -0
- package/dist/ui/hooks/use-sizer.js.map +1 -0
- package/dist/ui/hooks/use-window-dimensions.d.ts +4 -0
- package/dist/ui/hooks/use-window-dimensions.js +21 -0
- package/dist/ui/hooks/use-window-dimensions.js.map +1 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +5 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/types.d.ts +14 -0
- package/dist/ui/types.js +2 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/utilities/boolean.utility.d.ts +6 -0
- package/dist/utilities/boolean.utility.js +26 -0
- package/dist/utilities/boolean.utility.js.map +1 -0
- package/dist/utilities/error.utility.d.ts +18 -0
- package/dist/utilities/error.utility.js +35 -0
- package/dist/utilities/error.utility.js.map +1 -0
- package/dist/utilities/index.d.ts +4 -0
- package/dist/utilities/index.js +5 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/parse.utility.d.ts +14 -0
- package/dist/utilities/parse.utility.js +130 -0
- package/dist/utilities/parse.utility.js.map +1 -0
- package/dist/utilities/url.utility.d.ts +4 -0
- package/dist/utilities/url.utility.js +27 -0
- package/dist/utilities/url.utility.js.map +1 -0
- package/package.json +117 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) Minimal Technology Vietnam Ltd. 2023. All Rights Reserved.
|
|
2
|
+
This project is licensed under the MIT License, full text below.
|
|
3
|
+
|
|
4
|
+
-------- -------- -------- -------- -------- -------- -------- --------
|
|
5
|
+
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
-------- -------- -------- -------- -------- -------- -------- --------
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @minimaltech/ra-core-infra
|
|
2
|
+
|
|
3
|
+
Minimal Technology ReactJS Core Infrastructure - A React Admin Core framework built on LoopBack 4 for browser applications.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @minimaltech/ra-core-infra @loopback/context @loopback/filter
|
|
11
|
+
# or
|
|
12
|
+
yarn add @minimaltech/ra-core-infra @loopback/context @loopback/filter
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @minimaltech/ra-core-infra @loopback/context @loopback/filter
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Browser Setup (Required for Vite!)
|
|
18
|
+
|
|
19
|
+
Since this package uses LoopBack 4 (which requires Node.js APIs), you need to install and configure polyfills:
|
|
20
|
+
|
|
21
|
+
**1. Install the polyfill plugin:**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -D vite-plugin-node-polyfills
|
|
25
|
+
# or
|
|
26
|
+
yarn add -D vite-plugin-node-polyfills
|
|
27
|
+
# or
|
|
28
|
+
pnpm add -D vite-plugin-node-polyfills
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**2. Configure your `vite.config.ts`:**
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { defineConfig } from 'vite';
|
|
35
|
+
import react from '@vitejs/plugin-react';
|
|
36
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
plugins: [
|
|
40
|
+
react(),
|
|
41
|
+
nodePolyfills({
|
|
42
|
+
include: ['buffer', 'process'],
|
|
43
|
+
globals: {
|
|
44
|
+
Buffer: true,
|
|
45
|
+
global: true,
|
|
46
|
+
process: true,
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**That's it!** The plugin automatically handles all Node.js polyfills (Buffer, process, global).
|
|
54
|
+
|
|
55
|
+
**📖 [Complete Vite Setup Guide](./VITE_SETUP.md)** | [Browser Compatibility](https://github.com/phatnt199/aether/wiki/Browser-Compatibility-Setup)
|
|
56
|
+
|
|
57
|
+
## Customization
|
|
58
|
+
|
|
59
|
+
### Hooks
|
|
60
|
+
|
|
61
|
+
#### `useInjectable`
|
|
62
|
+
|
|
63
|
+
If you're using TypeScript, you'll need to specify your new keys, using [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation).
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
declare module '@minimaltech/ra-core-infra' {
|
|
67
|
+
interface IUseInjectableKeysOverrides {
|
|
68
|
+
['services.yourServices']: true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 📚 Documentation
|
|
74
|
+
|
|
75
|
+
- [Browser Compatibility Setup](https://github.com/phatnt199/aether/wiki/Browser-Compatibility-Setup) - **Read this first!**
|
|
76
|
+
- [Project WIKI](https://github.com/phatnt199/aether/wiki)
|
|
77
|
+
|
|
78
|
+
## ⚡ Features
|
|
79
|
+
|
|
80
|
+
- 🎯 React Admin Core integration
|
|
81
|
+
- 💉 Dependency Injection with LoopBack 4
|
|
82
|
+
- 🔍 Advanced data filtering
|
|
83
|
+
- 🌐 Browser-compatible (with polyfills)
|
|
84
|
+
- 📦 Tree-shakeable ES modules
|
|
85
|
+
- 🌍 i18n support
|
|
86
|
+
|
|
87
|
+
## 🛠️ Tech Stack
|
|
88
|
+
|
|
89
|
+
- React 18+
|
|
90
|
+
- React Admin Core 5+
|
|
91
|
+
- LoopBack 4 (Context & Filter)
|
|
92
|
+
- TypeScript
|
|
93
|
+
|
|
94
|
+
## 📦 What's Included
|
|
95
|
+
|
|
96
|
+
- **Base Applications**: Abstract application classes with DI
|
|
97
|
+
- **Providers**: Data providers, auth providers, i18n providers
|
|
98
|
+
<!-- - **UI Components**: Custom React Admin components -->
|
|
99
|
+
- **Services**: Network services, CRUD services
|
|
100
|
+
- **Utilities**: Helper functions and utilities
|
|
101
|
+
|
|
102
|
+
## 🤝 Contributing
|
|
103
|
+
|
|
104
|
+
Please read the [Project WIKI](https://github.com/phatnt199/aether/wiki) for contribution guidelines.
|
|
105
|
+
|
|
106
|
+
## 📄 License
|
|
107
|
+
|
|
108
|
+
MIT - See LICENSE file for details
|
|
109
|
+
|
|
110
|
+
## 🐛 Issues
|
|
111
|
+
|
|
112
|
+
Report issues at [GitHub Issues](https://github.com/phatnt199/aether/issues)
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
Please checkout these references for more guiding:
|
|
117
|
+
|
|
118
|
+
- [Browser Setup Guide](https://github.com/phatnt199/aether/wiki/Browser-Compatibility-Setup) ⭐ **Important!**
|
|
119
|
+
- [Project WIKI](https://github.com/phatnt199/aether/wiki)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BindingTag, Constructor, Context, DynamicValueProviderClass } from '@loopback/context';
|
|
2
|
+
import { ICoreRaApplication, ValueOrPromise } from '@/common';
|
|
3
|
+
export declare abstract class AbstractRaApplication extends Context implements ICoreRaApplication {
|
|
4
|
+
abstract bindContext(): ValueOrPromise<void>;
|
|
5
|
+
preConfigure(): ValueOrPromise<void>;
|
|
6
|
+
postConfigure(): ValueOrPromise<void>;
|
|
7
|
+
injectable<T>(scope: string, value: DynamicValueProviderClass<T> | Constructor<T>, tags?: BindingTag[]): void;
|
|
8
|
+
service<T>(value: DynamicValueProviderClass<T> | Constructor<T>): void;
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare abstract class BaseRaApplication extends AbstractRaApplication {
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context, } from '@loopback/context';
|
|
2
|
+
export class AbstractRaApplication extends Context {
|
|
3
|
+
preConfigure() {
|
|
4
|
+
this.bindContext();
|
|
5
|
+
}
|
|
6
|
+
postConfigure() { }
|
|
7
|
+
injectable(scope, value, tags) {
|
|
8
|
+
this.bind(`${scope}.${value.name}`)
|
|
9
|
+
.toInjectable(value)
|
|
10
|
+
.tag(...(tags ?? []), scope);
|
|
11
|
+
}
|
|
12
|
+
service(value) {
|
|
13
|
+
this.injectable('services', value);
|
|
14
|
+
}
|
|
15
|
+
async start() {
|
|
16
|
+
await this.preConfigure();
|
|
17
|
+
await this.postConfigure();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class BaseRaApplication extends AbstractRaApplication {
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=base.application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.application.js","sourceRoot":"","sources":["../../../src/base/applications/base.application.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,GAER,MAAM,mBAAmB,CAAC;AAK3B,MAAM,OAAgB,qBACpB,SAAQ,OAAO;IAQf,YAAY;QACV,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAGD,aAAa,KAA0B,CAAC;IAGxC,UAAU,CACR,KAAa,EACb,KAAoD,EACpD,IAAmB;QAEnB,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;aAChC,YAAY,CAAC,KAAK,CAAC;aACnB,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAQD,OAAO,CAAI,KAAoD;QAC7D,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAGD,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;CACF;AAGD,MAAM,OAAgB,iBAAkB,SAAQ,qBAAqB;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base.application';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/applications/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Provider } from '@loopback/context';
|
|
2
|
+
import { ValueOrPromise } from '@/common';
|
|
3
|
+
import { Logger } from '@/helpers';
|
|
4
|
+
export declare abstract class BaseProvider<T> implements Provider<T> {
|
|
5
|
+
protected logger: Logger;
|
|
6
|
+
constructor(opts: {
|
|
7
|
+
scope: string;
|
|
8
|
+
});
|
|
9
|
+
abstract value(): ValueOrPromise<T>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.provider.js","sourceRoot":"","sources":["../../../src/base/providers/base.provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,OAAgB,YAAY;IACtB,MAAM,CAAS;IAEzB,YAAY,IAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAClD,CAAC;CAGF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RaRecord } from 'react-admin';
|
|
2
|
+
import { AnyType, TRequestMethod, TRequestType } from '@/common';
|
|
3
|
+
import { DefaultRestDataProvider } from './default-rest-data.provider';
|
|
4
|
+
export declare class CountRestDataProvider<TResource extends string = string> extends DefaultRestDataProvider<TResource> {
|
|
5
|
+
getListHelper<RecordType extends RaRecord = AnyType>(opts: {
|
|
6
|
+
resource: TResource;
|
|
7
|
+
type: TRequestType;
|
|
8
|
+
queryKey: Record<string, AnyType>;
|
|
9
|
+
filter: Record<string, AnyType>;
|
|
10
|
+
requestProps: {
|
|
11
|
+
headers?: HeadersInit;
|
|
12
|
+
body?: AnyType;
|
|
13
|
+
method: TRequestMethod;
|
|
14
|
+
};
|
|
15
|
+
}): Promise<{
|
|
16
|
+
data: any;
|
|
17
|
+
total: any;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RequestTypes } from '@/common';
|
|
2
|
+
import { DefaultRestDataProvider } from './default-rest-data.provider';
|
|
3
|
+
export class CountRestDataProvider extends DefaultRestDataProvider {
|
|
4
|
+
getListHelper(opts) {
|
|
5
|
+
const { type, resource, queryKey, filter, requestProps } = opts;
|
|
6
|
+
const paths = [resource];
|
|
7
|
+
const response = this.networkService.doRequest({
|
|
8
|
+
type,
|
|
9
|
+
paths,
|
|
10
|
+
query: { ...queryKey, filter },
|
|
11
|
+
...requestProps,
|
|
12
|
+
});
|
|
13
|
+
const responseCount = this.networkService.doRequest({
|
|
14
|
+
type: RequestTypes.SEND,
|
|
15
|
+
paths: [resource, 'count'],
|
|
16
|
+
query: { ...queryKey, where: filter?.where },
|
|
17
|
+
...requestProps,
|
|
18
|
+
});
|
|
19
|
+
const responseAll = Promise.all([response, responseCount]).then((responses) => {
|
|
20
|
+
return {
|
|
21
|
+
data: responses?.[0]?.data,
|
|
22
|
+
total: responses?.[1]?.data?.count || 0,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
return responseAll;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=count-rest-data.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"count-rest-data.provider.js","sourceRoot":"","sources":["../../../src/base/providers/count-rest-data.provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,YAAY,EAAgC,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,MAAM,OAAO,qBAEX,SAAQ,uBAAkC;IAEjC,aAAa,CAAwC,IAM7D;QACC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAEhE,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEzB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAe;YAC3D,IAAI;YACJ,KAAK;YACL,KAAK,EAAE,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE;YAC9B,GAAG,YAAY;SAChB,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YAClD,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;YAC1B,KAAK,EAAE,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;YAC5C,GAAG,YAAY;SAChB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAC7D,CAAC,SAAoB,EAAE,EAAE;YACvB,OAAO;gBACL,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI;gBAC1B,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;aACxC,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DefaultAuthService } from '@/base/services';
|
|
2
|
+
import { AnyType, IAuthProvider, IAuthProviderOptions, IDataProvider, ValueOrPromise } from '@/common';
|
|
3
|
+
import { BaseProvider } from './base.provider';
|
|
4
|
+
export declare class DefaultAuthProvider<TResource extends string = string> extends BaseProvider<IAuthProvider> {
|
|
5
|
+
protected restDataProvider: IDataProvider<TResource>;
|
|
6
|
+
protected authProviderOptions: IAuthProviderOptions;
|
|
7
|
+
protected authService: DefaultAuthService;
|
|
8
|
+
constructor(restDataProvider: IDataProvider<TResource>, authProviderOptions: IAuthProviderOptions, authService: DefaultAuthService);
|
|
9
|
+
login(params: AnyType): Promise<unknown>;
|
|
10
|
+
logout(_params: AnyType): Promise<void>;
|
|
11
|
+
checkAuth(_params: AnyType): Promise<void>;
|
|
12
|
+
checkError(params: AnyType): Promise<void>;
|
|
13
|
+
getIdentity(_params: AnyType): Promise<any>;
|
|
14
|
+
getPermissions(_params: AnyType): Promise<void>;
|
|
15
|
+
getRoles(_params: AnyType): Promise<Set<string>>;
|
|
16
|
+
value(): ValueOrPromise<IAuthProvider>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var DefaultAuthProvider_1;
|
|
14
|
+
import { inject } from '@loopback/context';
|
|
15
|
+
import { DefaultAuthService } from '@/base/services';
|
|
16
|
+
import { CoreBindings, RequestMethods, } from '@/common';
|
|
17
|
+
import { BaseProvider } from './base.provider';
|
|
18
|
+
let DefaultAuthProvider = DefaultAuthProvider_1 = class DefaultAuthProvider extends BaseProvider {
|
|
19
|
+
restDataProvider;
|
|
20
|
+
authProviderOptions;
|
|
21
|
+
authService;
|
|
22
|
+
constructor(restDataProvider, authProviderOptions, authService) {
|
|
23
|
+
super({ scope: DefaultAuthProvider_1.name });
|
|
24
|
+
this.restDataProvider = restDataProvider;
|
|
25
|
+
this.authProviderOptions = authProviderOptions;
|
|
26
|
+
this.authService = authService;
|
|
27
|
+
}
|
|
28
|
+
login(params) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
this.restDataProvider
|
|
31
|
+
.send({
|
|
32
|
+
resource: (this.authProviderOptions.paths?.signIn ??
|
|
33
|
+
'/auth/login'),
|
|
34
|
+
params: { method: RequestMethods.POST, body: params },
|
|
35
|
+
})
|
|
36
|
+
.then(rs => {
|
|
37
|
+
const { userId, token } = rs.data;
|
|
38
|
+
this.authService.saveAuth({ token, userId, username: params.username });
|
|
39
|
+
resolve(rs);
|
|
40
|
+
})
|
|
41
|
+
.catch(error => {
|
|
42
|
+
console.log('[LOGIN]', error);
|
|
43
|
+
reject(error);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
logout(_params) {
|
|
48
|
+
return new Promise(resolve => {
|
|
49
|
+
this.authService.cleanUp();
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async checkAuth(_params) {
|
|
54
|
+
const token = this.authService.getAuth();
|
|
55
|
+
if (!token?.value) {
|
|
56
|
+
return Promise.reject({ redirectTo: 'login' });
|
|
57
|
+
}
|
|
58
|
+
if (!this.authProviderOptions.paths?.checkAuth) {
|
|
59
|
+
return Promise.resolve();
|
|
60
|
+
}
|
|
61
|
+
const rs = await this.restDataProvider.send({
|
|
62
|
+
resource: this.authProviderOptions.paths.checkAuth,
|
|
63
|
+
params: { method: RequestMethods.GET },
|
|
64
|
+
});
|
|
65
|
+
if (!rs?.data) {
|
|
66
|
+
return Promise.reject({ redirectTo: 'login' });
|
|
67
|
+
}
|
|
68
|
+
return await Promise.resolve();
|
|
69
|
+
}
|
|
70
|
+
checkError(params) {
|
|
71
|
+
const { status } = params;
|
|
72
|
+
if (status === 401) {
|
|
73
|
+
this.authService.cleanUp();
|
|
74
|
+
return Promise.reject({ redirectTo: 'login' });
|
|
75
|
+
}
|
|
76
|
+
if (status === 403) {
|
|
77
|
+
return Promise.reject({
|
|
78
|
+
redirectTo: `/unauthorized`,
|
|
79
|
+
logoutUser: false,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
}
|
|
84
|
+
getIdentity(_params) {
|
|
85
|
+
const user = this.authService.getUser();
|
|
86
|
+
if (!user?.userId) {
|
|
87
|
+
return Promise.reject({ message: '[getIdentity] No userId to get user identity!' });
|
|
88
|
+
}
|
|
89
|
+
return Promise.resolve(user);
|
|
90
|
+
}
|
|
91
|
+
getPermissions(_params) {
|
|
92
|
+
return Promise.resolve();
|
|
93
|
+
}
|
|
94
|
+
getRoles(_params) {
|
|
95
|
+
return Promise.resolve(this.authService.getRoles());
|
|
96
|
+
}
|
|
97
|
+
value() {
|
|
98
|
+
return {
|
|
99
|
+
login: (params) => this.login(params),
|
|
100
|
+
logout: (params) => this.logout(params),
|
|
101
|
+
checkError: (params) => this.checkError(params),
|
|
102
|
+
checkAuth: (params) => this.checkAuth(params),
|
|
103
|
+
getIdentity: (params) => this.getIdentity(params),
|
|
104
|
+
getPermissions: (params) => this.getPermissions(params),
|
|
105
|
+
getRoles: (params) => this.getRoles(params),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
DefaultAuthProvider = DefaultAuthProvider_1 = __decorate([
|
|
110
|
+
__param(0, inject(CoreBindings.DEFAULT_REST_DATA_PROVIDER)),
|
|
111
|
+
__param(1, inject(CoreBindings.AUTH_PROVIDER_OPTIONS)),
|
|
112
|
+
__param(2, inject(CoreBindings.DEFAULT_AUTH_SERVICE)),
|
|
113
|
+
__metadata("design:paramtypes", [Object, Object, DefaultAuthService])
|
|
114
|
+
], DefaultAuthProvider);
|
|
115
|
+
export { DefaultAuthProvider };
|
|
116
|
+
//# sourceMappingURL=default-auth.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-auth.provider.js","sourceRoot":"","sources":["../../../src/base/providers/default-auth.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAEL,YAAY,EAIZ,cAAc,GAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,IAAa,mBAAmB,2BAAhC,MAAa,mBAEX,SAAQ,YAA2B;IAGvB;IAEA;IAEA;IANZ,YAEY,gBAA0C,EA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AE/C,WAAA,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAA;IAE1C,WAAA,MAAM,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAA;qDACnB,kBAAkB;GAThC,mBAAmB,CAqI/B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { I18nProvider } from 'ra-core';
|
|
2
|
+
import { II18nProviderOptions, ValueOrPromise } from '@/common';
|
|
3
|
+
import { BaseProvider } from './base.provider';
|
|
4
|
+
export declare class DefaultI18nProvider extends BaseProvider<I18nProvider> {
|
|
5
|
+
protected i18nProviderOptions: II18nProviderOptions;
|
|
6
|
+
constructor(i18nProviderOptions: II18nProviderOptions);
|
|
7
|
+
value(): ValueOrPromise<I18nProvider>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var DefaultI18nProvider_1;
|
|
14
|
+
import { inject } from '@loopback/context';
|
|
15
|
+
import polyglotI18nProvider from 'ra-i18n-polyglot';
|
|
16
|
+
import { CoreBindings, englishMessages, } from '@/common';
|
|
17
|
+
import { BaseProvider } from './base.provider';
|
|
18
|
+
const [language] = (navigator?.language || 'en-US').split('-');
|
|
19
|
+
let DefaultI18nProvider = DefaultI18nProvider_1 = class DefaultI18nProvider extends BaseProvider {
|
|
20
|
+
i18nProviderOptions;
|
|
21
|
+
constructor(i18nProviderOptions) {
|
|
22
|
+
super({ scope: DefaultI18nProvider_1.name });
|
|
23
|
+
this.i18nProviderOptions = i18nProviderOptions;
|
|
24
|
+
}
|
|
25
|
+
value() {
|
|
26
|
+
const { i18nSources = { en: englishMessages }, listLanguages = [{ locale: 'en', name: 'English' }], } = this.i18nProviderOptions;
|
|
27
|
+
const listLocales = listLanguages.map(({ locale }) => locale);
|
|
28
|
+
const initialLocale = listLocales.includes(language) ? language : 'en';
|
|
29
|
+
return polyglotI18nProvider(locale => {
|
|
30
|
+
return i18nSources?.[locale] ?? englishMessages;
|
|
31
|
+
}, initialLocale, listLanguages, {
|
|
32
|
+
allowMissing: true,
|
|
33
|
+
onMissingKey: (key, _, __) => key,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
DefaultI18nProvider = DefaultI18nProvider_1 = __decorate([
|
|
38
|
+
__param(0, inject(CoreBindings.I18N_PROVIDER_OPTIONS)),
|
|
39
|
+
__metadata("design:paramtypes", [Object])
|
|
40
|
+
], DefaultI18nProvider);
|
|
41
|
+
export { DefaultI18nProvider };
|
|
42
|
+
//# sourceMappingURL=default-i18n.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-i18n.provider.js","sourceRoot":"","sources":["../../../src/base/providers/default-i18n.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACL,YAAY,EACZ,eAAe,GAGhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAA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DeleteManyResult, DeleteParams, DeleteResult, GetListParams, GetListResult, GetManyParams, GetManyReferenceParams, GetManyReferenceResult, GetManyResult, GetOneParams, GetOneResult, Identifier, QueryFunctionContext, RaRecord, UpdateManyParams, UpdateManyResult, UpdateParams, UpdateResult } from 'ra-core';
|
|
2
|
+
import { DefaultNetworkRequestService } from '@/base/services';
|
|
3
|
+
import { AnyType, ICustomParams, IDataProvider, IRestDataProviderOptions, ISendParams, ISendResponse, TRequestMethod, TRequestType, ValueOrPromise } from '@/common';
|
|
4
|
+
import { BaseProvider } from './base.provider';
|
|
5
|
+
export declare class DefaultRestDataProvider<TResource extends string = string> extends BaseProvider<IDataProvider<TResource>> {
|
|
6
|
+
protected restDataProviderOptions: IRestDataProviderOptions;
|
|
7
|
+
protected networkService: DefaultNetworkRequestService;
|
|
8
|
+
constructor(restDataProviderOptions: IRestDataProviderOptions);
|
|
9
|
+
getListHelper<RecordType extends RaRecord = AnyType>(opts: {
|
|
10
|
+
resource: TResource;
|
|
11
|
+
type: TRequestType;
|
|
12
|
+
queryKey: Record<string, AnyType>;
|
|
13
|
+
filter: Record<string, AnyType>;
|
|
14
|
+
requestProps: {
|
|
15
|
+
headers?: HeadersInit;
|
|
16
|
+
body?: AnyType;
|
|
17
|
+
method: TRequestMethod;
|
|
18
|
+
};
|
|
19
|
+
}): Promise<{
|
|
20
|
+
data: RecordType[];
|
|
21
|
+
total?: number;
|
|
22
|
+
}>;
|
|
23
|
+
getList<RecordType extends RaRecord = AnyType>(opts: {
|
|
24
|
+
resource: TResource;
|
|
25
|
+
params: GetListParams & QueryFunctionContext & ICustomParams;
|
|
26
|
+
}): Promise<GetListResult<RecordType>>;
|
|
27
|
+
getOne<RecordType extends RaRecord = AnyType>(opts: {
|
|
28
|
+
resource: TResource;
|
|
29
|
+
params: GetOneParams<RecordType> & QueryFunctionContext & ICustomParams;
|
|
30
|
+
}): Promise<GetOneResult<RecordType>>;
|
|
31
|
+
getMany<RecordType extends RaRecord = AnyType>(opts: {
|
|
32
|
+
resource: TResource;
|
|
33
|
+
params: GetManyParams<RecordType> & QueryFunctionContext & ICustomParams;
|
|
34
|
+
}): Promise<GetManyResult<RecordType>>;
|
|
35
|
+
getManyReference<RecordType extends RaRecord = AnyType>(opts: {
|
|
36
|
+
resource: TResource;
|
|
37
|
+
params: GetManyReferenceParams & QueryFunctionContext & ICustomParams;
|
|
38
|
+
}): Promise<GetManyReferenceResult<RecordType>>;
|
|
39
|
+
update<RecordType extends RaRecord = AnyType>(opts: {
|
|
40
|
+
resource: TResource;
|
|
41
|
+
params: UpdateParams;
|
|
42
|
+
}): Promise<UpdateResult<RecordType>>;
|
|
43
|
+
updateMany<RecordType extends RaRecord = AnyType>(opts: {
|
|
44
|
+
resource: TResource;
|
|
45
|
+
params: UpdateManyParams;
|
|
46
|
+
}): Promise<UpdateManyResult<RecordType>>;
|
|
47
|
+
create<RecordType extends Omit<RaRecord, 'id'> = AnyType, ResultRecordType extends RaRecord = RecordType & {
|
|
48
|
+
id: Identifier;
|
|
49
|
+
}>(opts: {
|
|
50
|
+
resource: TResource;
|
|
51
|
+
params: CreateParams;
|
|
52
|
+
}): Promise<CreateResult<ResultRecordType>>;
|
|
53
|
+
delete<RecordType extends RaRecord = AnyType>(opts: {
|
|
54
|
+
resource: TResource;
|
|
55
|
+
params: DeleteParams<RecordType>;
|
|
56
|
+
}): Promise<DeleteResult<RecordType>>;
|
|
57
|
+
deleteMany<RecordType extends RaRecord = AnyType>(opts: {
|
|
58
|
+
resource: TResource;
|
|
59
|
+
params: DeleteManyParams<RecordType>;
|
|
60
|
+
}): Promise<DeleteManyResult<RecordType>>;
|
|
61
|
+
send<ReturnType = AnyType>(opts: {
|
|
62
|
+
resource: TResource;
|
|
63
|
+
params: ISendParams;
|
|
64
|
+
}): Promise<ISendResponse<ReturnType>>;
|
|
65
|
+
value(): ValueOrPromise<IDataProvider<TResource>>;
|
|
66
|
+
}
|