@quoll/client-lib
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.7.0](https://github.com/mzogheib/quoll/compare/@quoll/client-lib@0.6.0...@quoll/client-lib@0.7.0) (2024-08-04) | ||
### Bug Fixes | ||
- revert subpath exports and tsconfig ([#233](https://github.com/mzogheib/quoll/issues/233)) ([3e23f39](https://github.com/mzogheib/quoll/commit/3e23f39055d7192e2b46e89b0f854d3b490bebd2)) | ||
### Features | ||
- add an authenticated `/user/me` endpoint to get a user ([#234](https://github.com/mzogheib/quoll/issues/234)) ([8237709](https://github.com/mzogheib/quoll/commit/8237709515dc77879f1664ee3979ee81bebe2612)) | ||
- **client-lib:** add a auth-user module ([2aa6a22](https://github.com/mzogheib/quoll/commit/2aa6a22fe99e1b112139f9b18879633f67ef09fb)) | ||
# [0.6.0](https://github.com/mzogheib/quoll/compare/@quoll/client-lib@0.5.2...@quoll/client-lib@0.6.0) (2024-07-28) | ||
@@ -8,0 +19,0 @@ |
@@ -7,5 +7,8 @@ "use strict"; | ||
const setDate = (newDate) => setProperty("date", newDate); | ||
return Object.assign(Object.assign({}, state), { setDate, | ||
reset }); | ||
return { | ||
...state, | ||
setDate, | ||
reset, | ||
}; | ||
}; | ||
exports.useDateModel = useDateModel; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,3 +9,6 @@ exports.useFeedsModel = void 0; | ||
const updateFeed = (0, react_1.useCallback)((feedName, newValue) => { | ||
const newFeed = Object.assign(Object.assign({}, feeds[feedName]), newValue); | ||
const newFeed = { | ||
...feeds[feedName], | ||
...newValue, | ||
}; | ||
setProperty(feedName, newFeed); | ||
@@ -25,6 +19,6 @@ }, [feeds, setProperty]); | ||
}, [updateFeed]); | ||
const connect = (0, react_1.useCallback)((name) => __awaiter(void 0, void 0, void 0, function* () { | ||
const connect = (0, react_1.useCallback)(async (name) => { | ||
try { | ||
updateFeed(name, { isAuthenticating: true }); | ||
const config = yield feedsService.connect(name); | ||
const config = await feedsService.connect(name); | ||
return config; | ||
@@ -38,7 +32,7 @@ } | ||
} | ||
}), [updateFeed]); | ||
const disconnect = (0, react_1.useCallback)((name) => __awaiter(void 0, void 0, void 0, function* () { | ||
}, [updateFeed]); | ||
const disconnect = (0, react_1.useCallback)(async (name) => { | ||
try { | ||
updateFeed(name, { isAuthenticating: true }); | ||
yield feedsService.deauthorize(name); | ||
await feedsService.deauthorize(name); | ||
updateFeed(name, { isConnected: false, isAuthenticating: false }); | ||
@@ -50,8 +44,8 @@ } | ||
} | ||
}), [updateFeed]); | ||
const authenticate = (0, react_1.useCallback)((name, code) => __awaiter(void 0, void 0, void 0, function* () { | ||
}, [updateFeed]); | ||
const authenticate = (0, react_1.useCallback)(async (name, code) => { | ||
updateFeed(name, { isAuthenticating: true }); | ||
yield feedsService.authenticate(name, { code }); | ||
await feedsService.authenticate(name, { code }); | ||
updateFeed(name, { isConnected: true, isAuthenticating: false }); | ||
}), [updateFeed]); | ||
}, [updateFeed]); | ||
return { | ||
@@ -58,0 +52,0 @@ feeds: Object.values(feeds), |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -16,28 +7,22 @@ exports.FeedsService = void 0; | ||
class FeedsService extends lib_1.AuthenticatedHttpService { | ||
connect(feed) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.request({ | ||
method: "GET", | ||
endpoint, | ||
params: { feed }, | ||
}); | ||
async connect(feed) { | ||
return this.request({ | ||
method: "GET", | ||
endpoint, | ||
params: { feed }, | ||
}); | ||
} | ||
authenticate(feed, payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.request({ | ||
method: "POST", | ||
endpoint, | ||
payload, | ||
params: { feed }, | ||
}); | ||
async authenticate(feed, payload) { | ||
return this.request({ | ||
method: "POST", | ||
endpoint, | ||
payload, | ||
params: { feed }, | ||
}); | ||
} | ||
deauthorize(feed) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.request({ | ||
method: "DELETE", | ||
endpoint, | ||
params: { feed }, | ||
}); | ||
async deauthorize(feed) { | ||
return this.request({ | ||
method: "DELETE", | ||
endpoint, | ||
params: { feed }, | ||
}); | ||
@@ -44,0 +29,0 @@ } |
@@ -5,1 +5,2 @@ export * from "./date"; | ||
export * from "./user"; | ||
export * from "./auth-user"; |
@@ -21,1 +21,2 @@ "use strict"; | ||
__exportStar(require("./user"), exports); | ||
__exportStar(require("./auth-user"), exports); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -15,6 +6,6 @@ exports.useTimelineModel = void 0; | ||
const { state, setProperty, reset } = useStore(); | ||
const fetchTimeline = (date) => __awaiter(void 0, void 0, void 0, function* () { | ||
const fetchTimeline = async (date) => { | ||
setProperty("isFetching", true); | ||
try { | ||
const newEntries = yield timelineService.get(date); | ||
const newEntries = await timelineService.get(date); | ||
setProperty("entries", newEntries); | ||
@@ -25,6 +16,9 @@ } | ||
} | ||
}); | ||
return Object.assign(Object.assign({}, state), { fetchTimeline, | ||
reset }); | ||
}; | ||
return { | ||
...state, | ||
fetchTimeline, | ||
reset, | ||
}; | ||
}; | ||
exports.useTimelineModel = useTimelineModel; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -46,13 +37,11 @@ exports.TimelineService = exports.getTimelineEntryImage = void 0; | ||
class TimelineService extends lib_1.AuthenticatedHttpService { | ||
get(date) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const _date = new Date(date); | ||
return this.request({ | ||
method: "GET", | ||
endpoint: "/timeline", | ||
params: { | ||
from: (0, lib_1.getStartOfDay)(_date).toISOString(), | ||
to: (0, lib_1.getEndOfDay)(_date).toISOString(), | ||
}, | ||
}); | ||
async get(date) { | ||
const _date = new Date(date); | ||
return this.request({ | ||
method: "GET", | ||
endpoint: "/timeline", | ||
params: { | ||
from: (0, lib_1.getStartOfDay)(_date).toISOString(), | ||
to: (0, lib_1.getEndOfDay)(_date).toISOString(), | ||
}, | ||
}); | ||
@@ -59,0 +48,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -16,5 +7,5 @@ exports.useUserModel = void 0; | ||
const { user, isAuthenticating } = state; | ||
const login = (userId) => __awaiter(void 0, void 0, void 0, function* () { | ||
const login = async (userId) => { | ||
setProperty("isAuthenticating", true); | ||
const user = yield service.login(userId); | ||
const user = await service.login(userId); | ||
storage.setProperty("id", userId); | ||
@@ -24,6 +15,6 @@ setProperty("user", user); | ||
return user; | ||
}); | ||
const signup = () => __awaiter(void 0, void 0, void 0, function* () { | ||
}; | ||
const signup = async () => { | ||
setProperty("isAuthenticating", true); | ||
const user = yield service.signup(); | ||
const user = await service.signup(); | ||
storage.setProperty("id", user._id); | ||
@@ -33,5 +24,5 @@ setProperty("user", user); | ||
return user; | ||
}); | ||
const getCurrentUserId = () => { var _a; return (_a = storage.getData()) === null || _a === void 0 ? void 0 : _a.id; }; | ||
const logout = () => __awaiter(void 0, void 0, void 0, function* () { | ||
}; | ||
const getCurrentUserId = () => storage.getData()?.id; | ||
const logout = async () => { | ||
setProperty("isAuthenticating", true); | ||
@@ -41,3 +32,3 @@ storage.clear(); | ||
setProperty("isAuthenticating", false); | ||
}); | ||
}; | ||
return { | ||
@@ -44,0 +35,0 @@ user, |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -15,17 +6,13 @@ exports.UserService = void 0; | ||
class UserService extends lib_1.HttpService { | ||
login(userId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.request({ | ||
method: "POST", | ||
endpoint: "/login", | ||
payload: { userId }, | ||
}); | ||
async login(userId) { | ||
return this.request({ | ||
method: "POST", | ||
endpoint: "/login", | ||
payload: { userId }, | ||
}); | ||
} | ||
signup() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.request({ | ||
method: "POST", | ||
endpoint: "/signup", | ||
}); | ||
async signup() { | ||
return await this.request({ | ||
method: "POST", | ||
endpoint: "/signup", | ||
}); | ||
@@ -32,0 +19,0 @@ } |
@@ -64,3 +64,6 @@ "use strict"; | ||
case makeActionType(name): | ||
return Object.assign(Object.assign({}, state), { [name]: value }); | ||
return { | ||
...state, | ||
[name]: value, | ||
}; | ||
default: | ||
@@ -67,0 +70,0 @@ return state; |
{ | ||
"name": "@quoll/client-lib", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Shared code for client side packages", | ||
@@ -19,3 +19,3 @@ "repository": "https://github.com/mzogheib/quoll", | ||
"dependencies": { | ||
"@quoll/lib": "^0.5.3", | ||
"@quoll/lib": "^0.5.4", | ||
"react-redux": "^7.2.1", | ||
@@ -25,3 +25,3 @@ "redux": "^4.0.5" | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.3", | ||
"@tsconfig/node18": "^18.2.4", | ||
"@types/react": "^18.2.45", | ||
@@ -34,3 +34,3 @@ "redux-devtools-extension": "^2.13.9", | ||
}, | ||
"gitHead": "b7c149c007b7f7ca53907b07d9054cb5fe17674d" | ||
"gitHead": "06628c005f6bd51200d3ea58801ac4af0c4be2b9" | ||
} |
@@ -5,1 +5,2 @@ export * from "./date"; | ||
export * from "./user"; | ||
export * from "./auth-user"; |
{ | ||
"extends": "@tsconfig/recommended/tsconfig.json", | ||
"extends": "@tsconfig/node18/tsconfig.json", | ||
"include": ["src"], | ||
@@ -4,0 +4,0 @@ "compilerOptions": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86952
71
1362
Updated@quoll/lib@^0.5.4