Skip to content

Commit 964e25c

Browse files
author
Kenneth
committed
feature/create-dun-js-package
1 parent 6de5c0e commit 964e25c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4800
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
lib
11+
node_modules
12+
# dist
13+
dist-ssr
14+
*.local
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?
26+
.env*

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 80,
6+
"tabWidth": 2
7+
}

README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
## Getting started
2+
3+
### Installation
4+
5+
Before you start, make sure you have a fresh version of [Node.js](https://nodejs.org/en/) installed. The current Long Term Support (LTS) release is an ideal starting point.
6+
7+
```bash
8+
# Run this command in your project root folder.
9+
# yarn
10+
yarn add dun-js
11+
12+
# npm
13+
npm install --save dun-js
14+
```
15+
16+
Then you can simply import or require the module.
17+
18+
```javascript
19+
// ES module
20+
import { AuthClient } from 'dun-js';
21+
const authClient = new AuthClient(/* configOptions */);
22+
```
23+
24+
```javascript
25+
// CommonJS
26+
var AuthClient = require('dun-js').AuthClient;
27+
var authClient = new AuthClient(/* configOptions */);
28+
```
29+
30+
## Usage guide
31+
32+
### Example Client
33+
34+
```javascript
35+
const config = {
36+
mode: 'development',
37+
brandUrl: 'jframework.io',
38+
};
39+
40+
const authClient = new AuthClient(config);
41+
```
42+
43+
### Usage with Typescript
44+
45+
Type definitions are provided implicitly through the `types` entry in `package.json`. Types can also be referenced explicitly by importing them.
46+
47+
```typescript
48+
import { AuthClient, DunConfig } from 'dun-js';
49+
50+
const config: DunConfig = {
51+
mode: 'development',
52+
brandUrl: 'jframework.io',
53+
};
54+
55+
const authClient: AuthClient = new AuthClient(config);
56+
```
57+
58+
### Using API
59+
60+
You can easily utilize the API by importing it and then invoking its methods.
61+
62+
Example:
63+
64+
```typescript
65+
import { ISignInPayload, signInAPI } from 'dun-js';
66+
67+
const payload: ISignInPayload = {
68+
username: formValues.username,
69+
password: formValues.password,
70+
};
71+
72+
const response = await signInAPI(payload);
73+
```
74+
75+
## Configuration reference
76+
77+
### Configuration options
78+
79+
These options can be included when instantiating DUN Auth JS (`new AuthClient(config)`).
80+
81+
#### `brandUrl`
82+
83+
> :warning: This option is required
84+
85+
The url for your DUN brand.
86+
87+
#### `mode`
88+
89+
The default environment for your application is set to 'production'. To switch to a development environment, set the environment to 'development'.
90+
91+
### Methods
92+
93+
#### `setAuthKey()`
94+
95+
Upon logging in, you will receive an `authKey` from the server. Use the following method to set the `authKey` in the request header.
96+
97+
Example:
98+
99+
```javascript
100+
authClient.setAuthKey(authKey);
101+
```
102+
103+
#### `setHeaders()`
104+
105+
If you want to set headers for all APIs, use this method.
106+
107+
Example:
108+
109+
```javascript
110+
const userHeaders = {
111+
UrlRequest: window.location.href,
112+
};
113+
114+
authClient.setHeaders(userHeaders);
115+
```
116+
117+
## API Reference
118+
119+
- [auth](https://developers.jframework.io/references/api-reference/authentication)
120+
- [signInUsingUsernameAPI](https://developers.jframework.io/references/api-reference/endpoints/users/authentication)
121+
- [signInUsingEmailAPI](https://developers.jframework.io/references/api-reference/endpoints/users/authentication-by-email)
122+
- [getGoogleLinkAPI](https://developers.jframework.io/guide/login-with-google#get-a-google-login-url-from-dun)
123+
- [brand](https://developers.jframework.io/references/api-reference/endpoints/brands)
124+
- [getListBrandEmailsAPI](https://developers.jframework.io/references/api-reference/endpoints/brands/get-emails)
125+
- [getBrandByUrlAPI](https://developers.jframework.io/references/api-reference/endpoints/brands/get-a-brand#api-v1-brands-by-url-brandurl)
126+
- [getListBrandLinksAPI](https://developers.jframework.io/references/api-reference/endpoints/brands/get-links)
127+
- [cdn](https://developers.jframework.io/references/api-reference/endpoints/cdn)
128+
- [cdnUploadFileAPI](https://developers.jframework.io/references/api-reference/endpoints/cdn)
129+
- currency
130+
- [getListCurrenciesAPI]
131+
- [getListExchangeRatesAPI]
132+
- [device](https://developers.jframework.io/references/api-reference/endpoints/devices)
133+
- [checkUserAccessAPI](https://developers.jframework.io/references/api-reference/endpoints/devices#api-v1-devices-user-access)
134+
- [integration](https://developers.jframework.io/references/api-reference/endpoints/app-integrations)
135+
- [getPushNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/app-integrations/push-notification#api-integrations-push-notification-1)
136+
- [invoice](https://developers.jframework.io/references/api-reference/endpoints/invoices)
137+
- [getListInvoicesAPI](https://developers.jframework.io/references/api-reference/endpoints/invoices/get-invoices)
138+
- [exportInvoiceAPI](https://developers.jframework.io/references/api-reference/endpoints/invoices/export-a-invoice)
139+
- [issue](https://developers.jframework.io/references/api-reference/endpoints/issues)
140+
- [createIssueAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/create-an-issue)
141+
- [getListIssuesAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/get-issues)
142+
- [deleteIssueAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/remove-an-issue)
143+
- [createIssueReactionAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/create-an-issue-reaction)
144+
- [deleteIssueReactionAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/remove-a-issue-reaction)
145+
- [getListIssuesByIdsAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/get-issues-by-list-id)
146+
- [getListIssueChildrenAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/get-children-issues)
147+
- [getListIssueCategoriesAPI](https://developers.jframework.io/references/api-reference/endpoints/issue-categories/get-issue-categories)
148+
- [language](https://developers.jframework.io/references/api-reference/endpoints/languages)
149+
- [getListLanguagesAPI](https://developers.jframework.io/references/api-reference/endpoints/languages)
150+
- [license](https://developers.jframework.io/references/api-reference/endpoints/licenses)
151+
- [checkValidLicenseAPI](https://developers.jframework.io/references/api-reference/endpoints/licenses/checks-a-license)
152+
- [applyLicenseAPI](https://developers.jframework.io/references/api-reference/endpoints/licenses/applies-a-license-to-the-logged-user)
153+
- [notification](https://developers.jframework.io/references/api-reference/endpoints/notifications)
154+
- [getNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/get-notifications-by-the-user-authorized)
155+
- [updateNotificationStatusAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/updates-status-of-the-notification)
156+
- [deleteNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/delete-a-notification)
157+
- [updateAllNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/updates-all-notification)
158+
- [organization](https://developers.jframework.io/references/api-reference/endpoints/organizations)
159+
- [getListOrganizationsAPI]
160+
- [getOrganizationDetailAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/get-an-organization)
161+
- [getListOrganizationsByViewerAPI]
162+
- [createOrganizationUserAPI]
163+
- [updateOrganizationUserAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/update-a-user-status-in-an-organization)
164+
- [deleteOrganizationUserAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/remove-a-user-in-an-organization)
165+
- [getListUsersOfOrganizationAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/list-users-of-an-organization)
166+
- [package](https://developers.jframework.io/references/api-reference/endpoints/packages)
167+
- [getListPackagesAPI](https://developers.jframework.io/references/api-reference/endpoints/packages)
168+
- payment-provider
169+
- [getListPaymentProvidersAPI]
170+
- [price](https://developers.jframework.io/references/api-reference/endpoints/prices)
171+
- [generateCheckoutLink](https://developers.jframework.io/references/api-reference/endpoints/prices#api-prices-id-direct-checkout-link)
172+
- [role](https://developers.jframework.io/references/api-reference/endpoints/roles)
173+
- [getListRolesAPI](https://developers.jframework.io/references/api-reference/endpoints/roles#api-roles)
174+
- [timezone](https://developers.jframework.io/references/api-reference/endpoints/time-zones)
175+
- [getListTimezonesAPI](https://developers.jframework.io/references/api-reference/endpoints/time-zones)
176+
- [user](https://developers.jframework.io/references/api-reference/endpoints/users)
177+
- [getUserInfoAPI](https://developers.jframework.io/references/api-reference/endpoints/users/gets-the-current-user-logged-in)
178+
- [getListUsersByIdsAPI]
179+
- [getUserInfoByIdAPI](https://developers.jframework.io/references/api-reference/endpoints/users/get-a-user)
180+
- [updateUserAPI](https://developers.jframework.io/references/api-reference/endpoints/users/update-a-user)
181+
- [signUpAPI](https://developers.jframework.io/references/api-reference/endpoints/users/register-a-new-user)
182+
- [forgotPasswordAPI](https://developers.jframework.io/references/api-reference/endpoints/users/forgot-password)
183+
- [resetPasswordAPI]
184+
- [changePasswordAPI](https://developers.jframework.io/references/api-reference/endpoints/users/change-password)
185+
- [getRefereesAPI](https://developers.jframework.io/references/api-reference/endpoints/users/gets-the-referees-of-a-user)
186+
- [checkCodeValidAPI]
187+
- [applyCodeAPI](https://developers.jframework.io/references/api-reference/endpoints/users/applies-the-referral-code-to-a-user)
188+
- [getListUserConfigurationsAPI]
189+
- [createUserConfigurationsAPI]
190+
- [updateUserConfigurationsAPI]
191+
- [wallet](https://developers.jframework.io/references/api-reference/endpoints/wallets)
192+
- [getWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/get-wallets)
193+
- [getWalletHistoriesAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/get-the-wallet-histories)
194+
- [createWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/create-a-wallet-default)
195+
- [exchangeWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/convert-wallet-money)
196+
- [addMoneyAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/add-money-to-a-wallet-with-checkout-link)
197+
- [closeWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/close-wallet)
198+
- [getListEarnEventsAPI]
199+
- [applyRedeemAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/apply-redeem)

dist/api/calendar.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { DateType, ICalendar, IdType, IGetListCalendarParams } from "@/models";
2+
export declare const getListCalendarAPI: (params?: IGetListCalendarParams) => Promise<ICalendar[]>;
3+
export declare const resetCalendarAPI: (deviceId: IdType) => Promise<boolean>;
4+
export declare const getLastSyncTimeCalendarAPI: (deviceId: IdType) => Promise<DateType | null>;

dist/api/call.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { DateType, ICall, IdType, IGetListCallParams } from "@/models";
2+
import { IListResponse } from "@/models/interfaces/common";
3+
export declare const getListCallAPI: (params?: IGetListCallParams) => Promise<IListResponse<ICall>>;
4+
export declare const resetCallAPI: (deviceId: IdType) => Promise<boolean>;
5+
export declare const deleteCallAPI: (id: IdType) => Promise<boolean>;
6+
export declare const getLastSyncTimeCallAPI: (deviceId: IdType) => Promise<DateType | null>;

dist/api/clipboard.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { DateType, IClipboard, IdType, IGetListClipboardParams } from "@/models";
2+
import { IListResponse } from "@/models/interfaces/common";
3+
export declare const getListClipboardAPI: (params?: IGetListClipboardParams) => Promise<IListResponse<IClipboard>>;
4+
export declare const resetClipboardAPI: (deviceId: IdType) => Promise<boolean>;
5+
export declare const deleteClipboardAPI: (id: IdType) => Promise<boolean>;
6+
export declare const getLastSyncTimeClipboardAPI: (deviceId: IdType) => Promise<DateType | null>;

dist/api/contact.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { DateType, IContact, IdType, IGetListContactParams } from "@/models";
2+
import { IListResponse } from "@/models/interfaces/common";
3+
export declare const getListContactAPI: (params?: IGetListContactParams) => Promise<IListResponse<IContact>>;
4+
export declare const resetContactAPI: (deviceId: IdType) => Promise<boolean>;
5+
export declare const deleteContactAPI: (id: IdType) => Promise<boolean>;
6+
export declare const getLastSyncTimeContactAPI: (deviceId: IdType) => Promise<DateType | null>;

dist/api/deviceDataSync.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { IDeviceDataSync, IGetOrCreateDeviceDataSync } from '@/models';
2+
export declare const getOrCreateDeviceDataSync: (params?: IGetOrCreateDeviceDataSync) => Promise<IDeviceDataSync>;
3+
export declare const createOrUpdateDeviceDataSync: (params?: IDeviceDataSync) => Promise<IDeviceDataSync>;

dist/api/deviceSettingSync.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ICreateOrUpdateDeviceSettingSync, IDeviceSettingSync, IGetOrCreateDeviceSettingSync } from "@/models";
2+
export declare const getDeviceSettingSync: (params?: IGetOrCreateDeviceSettingSync) => Promise<IDeviceSettingSync>;
3+
export declare const createOrUpdateDeviceSettingSync: (params?: ICreateOrUpdateDeviceSettingSync) => Promise<ICreateOrUpdateDeviceSettingSync>;

dist/api/devices.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { IAggregateDevice, IDeleteDeviceParams, IEditDeviceParams, IEditDevicePayload, IGetListAggregateDevicesParams } from "@/models";
2+
export declare const getAllAggregateDevicesAPI: (params: IGetListAggregateDevicesParams) => Promise<IAggregateDevice[]>;
3+
export declare const deleteDeviceAPI: (params: IDeleteDeviceParams) => Promise<import("axios").AxiosResponse<any, any>>;
4+
export declare const updateDeviceAPI: (params: IEditDeviceParams, payload: IEditDevicePayload) => Promise<any>;

0 commit comments

Comments
 (0)