Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Integration with SesameHR #670

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
"leemons-plugin-package-manager-frontend-react": "1.0.0",
"leemons-plugin-scores": "1.0.31",
"leemons-plugin-scores-frontend-react": "1.0.0",
"leemons-plugin-sesamehr-private": "0.0.1",
"leemons-plugin-sesamehr-frontend-react-private": "1.0.0",
"leemons-plugin-sessions": "1.0.0",
"leemons-plugin-sessions-frontend-react": "1.0.0",
"leemons-plugin-scorm": "1.0.35",
Expand Down
3 changes: 3 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"@scorm/*": [
"./plugins/leemons-plugin-scorm/frontend/src/*"
],
"@sesamehr/*": [
"./private-plugins/leemons-plugin-sesamehr/frontend/src/*"
],
"@sessions/*": [
"./private-plugins/leemons-plugin-sessions/frontend/src/*"
],
Expand Down
10 changes: 6 additions & 4 deletions packages/leemons-mongodb-helpers/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { mongoDBPaginate, EMPTY_PAGINATED_RESULT } = require('./mongoDBPaginate');
const mongoDBPaginateAggregationPipeline = require('./mongoDBPaginateAggregationPipeline');
const { getKeyValueModel } = require('./key-value/getKeyValueModel');
const { deleteKey } = require('./key-value/deleteKey');
const { getKey } = require('./key-value/getKey');
const { getKeyValueModel } = require('./key-value/getKeyValueModel');
const { hasKey } = require('./key-value/hasKey');
const { setKey } = require('./key-value/setKey');
const { hasKeys } = require('./key-value/hasKeys');
const { setKey } = require('./key-value/setKey');
const { mongoDBPaginate, EMPTY_PAGINATED_RESULT } = require('./mongoDBPaginate');
const mongoDBPaginateAggregationPipeline = require('./mongoDBPaginateAggregationPipeline');

module.exports = {
mongoDBPaginate,
Expand All @@ -15,4 +16,5 @@ module.exports = {
hasKey,
setKey,
hasKeys,
deleteKey,
};
17 changes: 17 additions & 0 deletions packages/leemons-mongodb-helpers/src/key-value/deleteKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @typedef {import('mongoose').Model} Model
* @typedef {import('mongoose').DeleteResult} DeleteResult
*
* Deletes a key from the key-value store.
*
* @param {Model} model - The model to delete the key from.
* @param {string} key - The key to delete.
* @returns {Promise<DeleteResult>} A promise that resolves to the result of the delete operation.
*/
function deleteKey(model, key) {
return model.deleteOne({ key });
}

module.exports = {
deleteKey,
};
1 change: 1 addition & 0 deletions packages/leemons-mongodb-helpers/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type SetKeyQueryResult = {
export function getKey<T>(model: Model<T>, key: string): Promise<GetKeyQueryResult<T>>;
export function hasKey(model: Model<unknown>, key: string): Promise<boolean>;
export function setKey<T>(model: Model<T>, key: string, value?: T): Promise<SetKeyQueryResult>;
export function deleteKey<T>(model: Model<T>, key: string): Promise<DeleteResult>;

export type GetKeyValueModel = {
id: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/leemons-mongodb-helpers/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Model, PaginatedQueryResult } from '@leemons/mongodb';
import { FilterQuery, SortOrder } from 'mongoose';
import { FilterQuery, SortOrder, DeleteResult } from 'mongoose';

type Params<M extends Model<any> = Model<any>, R = object> = {
model: M;
Expand Down Expand Up @@ -44,6 +44,7 @@ export type SetKeyQueryResult = {
export function getKey<T>(model: Model<T>, key: string): Promise<GetKeyQueryResult<T>>;
export function hasKey(model: Model<unknown>, key: string): Promise<boolean>;
export function setKey<T>(model: Model<T>, key: string, value?: T): Promise<SetKeyQueryResult>;
export function deleteKey<T>(model: Model<T>, key: string): Promise<DeleteResult>;

export type GetKeyValueModel = {
id: string;
Expand Down
6 changes: 5 additions & 1 deletion packages/leemons-users/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ export interface User {
avatarAsset: AssetID;
locale: string;
gender: string;
bithdate: Date;
birthdate: Date;
center?: Center;
externalIdentities?: {
provider: string;
externalId: string;
}[];
}

export interface UserAgent {
Expand Down
16 changes: 16 additions & 0 deletions plugins/leemons-plugin-users/backend/models/users.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
const { mongoose, newModel } = require('@leemons/mongodb');

const externalIdentitySchema = new mongoose.Schema({
provider: {
type: String,
required: true,
},
externalId: {
type: String,
required: true,
},
});

const schema = new mongoose.Schema(
{
id: {
Expand Down Expand Up @@ -58,6 +69,11 @@ const schema = new mongoose.Schema(
type: String,
required: true,
},
externalIdentities: {
type: [externalIdentitySchema],
required: false,
default: [],
},
},
{
timestamps: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = {

if (
ctx.callerPlugin &&
[provider, 'bulk-data'].filter(Boolean).includes(ctx.callerPlugin)
[provider, 'bulk-data', 'sesamehr'].filter(Boolean).includes(ctx.callerPlugin)
) {
return listUsers({ ...ctx.params, ctx });
}
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.frontend.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
"@scorm/*": [
"./plugins/leemons-plugin-scorm/frontend/src/*"
],
"@sesamehr/*": [
"./private-plugins/leemons-plugin-sesamehr/frontend/src/*"
],
"@sessions/*": [
"./private-plugins/leemons-plugin-sessions/frontend/src/*"
],
Expand Down
Loading