@5minds/processcube_app_sdk 0.0.1-develop-c3e473-lk6h0fnw → 0.0.1-develop-40adb2-lkb16tf4
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/common/functions/hasClaim.d.ts +23 -0
- package/common/index.cjs +1 -1
- package/common/index.d.ts +22 -0
- package/common/index.mjs +1 -1
- package/package.json +3 -1
- package/server/index.cjs +1 -1
- package/server/index.d.ts +21 -0
- package/server/index.mjs +1 -1
- package/server/lib/UserTaskFunctions.d.ts +13 -2
- package/server/lib/getIdentity.d.ts +6 -0
- package/server/lib/index.d.ts +1 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Session, CallbacksOptions } from 'next-auth';
|
|
2
|
+
import type { JWT } from 'next-auth/jwt';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @returns {Boolean} A boolean whether the user has the claim or not
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasClaim(claim: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* This function passes the {@link Account}'s {@link Account.access_token} and {@link Account.id_token} to the generated {@link JWT}.
|
|
11
|
+
*
|
|
12
|
+
* @param args The arguments of {@link CallbacksOptions.jwt}.
|
|
13
|
+
* @returns A {@link JWT}
|
|
14
|
+
*/
|
|
15
|
+
export declare function authConfigJwtCallback(args: Parameters<CallbacksOptions['jwt']>[0]): Promise<JWT>;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* This function passes the {@link Account.access_token} Claims to the current {@link Session} user.
|
|
19
|
+
*
|
|
20
|
+
* @param args The arguments of {@link CallbacksOptions.session}.
|
|
21
|
+
* @returns A {@link JWT}
|
|
22
|
+
*/
|
|
23
|
+
export declare function authConfigSessionCallback(args: Parameters<CallbacksOptions['session']>[0]): Promise<Session>;
|
package/common/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var T=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var s in t)r(e,s,{get:t[s],enumerable:!0})},c=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of h(t))!S.call(e,n)&&n!==s&&r(e,n,{get:()=>t[n],enumerable:!(o=g(t,n))||o.enumerable});return e};var y=(e,t,s)=>(s=e!=null?T(C(e)):{},c(t||!e||!e.__esModule?r(s,"default",{value:e,enumerable:!0}):s,e)),x=e=>c(r({},"__esModule",{value:!0}),e);var v={};b(v,{RemoteUserTask:()=>j,authConfigJwtCallback:()=>f,authConfigSessionCallback:()=>k,hasClaim:()=>P});module.exports=x(v);var a=require("react/jsx-runtime");function j(e){return(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsx)("iframe",{width:"100%",height:"100%",src:e.url})})}var u=require("next-auth"),m=require("next-auth/react"),d=y(require("jwt-decode"),1);async function P(e){let t;return typeof window>"u"?t=(await(0,u.getServerSession)({callbacks:{jwt:f,session:k}}))?.user:t=(await(0,m.getSession)())?.user,!t||!t.claims?!1:t.claims[e]!=null}async function f(e){let{token:t,account:s}=e;return s&&(t.accessToken=s.access_token,t.idToken=s.id_token),t}async function k(e){let{session:t,token:s}=e,o=await l(s.accessToken),n=await l(s.idToken),p=Object.keys(n),i=Object.fromEntries(Object.entries(o).filter(([w,J])=>!p.includes(w)));return delete i.scope,delete i.jti,delete i.client_id,t.user.claims=i,t}async function l(e){return(0,d.default)(e)}0&&(module.exports={RemoteUserTask,authConfigJwtCallback,authConfigSessionCallback,hasClaim});
|
package/common/index.d.ts
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
1
|
export * from './components/RemoteUserTask';
|
|
2
|
+
export * from './functions/hasClaim';
|
|
3
|
+
import { DefaultSession } from 'next-auth';
|
|
4
|
+
declare module 'next-auth' {
|
|
5
|
+
/**
|
|
6
|
+
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
|
|
7
|
+
*/
|
|
8
|
+
interface Session {
|
|
9
|
+
user: {
|
|
10
|
+
/** The user's identity claims. */
|
|
11
|
+
claims?: Record<string, unknown>;
|
|
12
|
+
} & DefaultSession['user'];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
declare module 'next-auth/jwt' {
|
|
16
|
+
/** Returned by the `jwt` callback and `getToken`, when using JWT sessions */
|
|
17
|
+
interface JWT {
|
|
18
|
+
/** OpenID Access Token */
|
|
19
|
+
accessToken?: string;
|
|
20
|
+
/** OpenID ID Token */
|
|
21
|
+
idToken?: string;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/common/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";function w(t){return o("div",{style:{width:"100%",height:"100%"},children:o("iframe",{width:"100%",height:"100%",src:t.url})})}import{getServerSession as u}from"next-auth";import{getSession as m}from"next-auth/react";import d from"jwt-decode";async function j(t){let e;return typeof window>"u"?e=(await u({callbacks:{jwt:f,session:k}}))?.user:e=(await m())?.user,!e||!e.claims?!1:e.claims[t]!=null}async function f(t){let{token:e,account:s}=t;return s&&(e.accessToken=s.access_token,e.idToken=s.id_token),e}async function k(t){let{session:e,token:s}=t,r=await i(s.accessToken),a=await i(s.idToken),c=Object.keys(a),n=Object.fromEntries(Object.entries(r).filter(([l,p])=>!c.includes(l)));return delete n.scope,delete n.jti,delete n.client_id,e.user.claims=n,e}async function i(t){return d(t)}export{w as RemoteUserTask,f as authConfigJwtCallback,k as authConfigSessionCallback,j as hasClaim};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@5minds/processcube_app_sdk",
|
|
3
|
-
"version": "0.0.1-develop-
|
|
3
|
+
"version": "0.0.1-develop-40adb2-lkb16tf4",
|
|
4
4
|
"description": "The SDK for ProcessCube Apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "common/index.cjs",
|
|
@@ -73,11 +73,13 @@
|
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"next": ">=13.4",
|
|
76
|
+
"next-auth": "^4.22.1",
|
|
76
77
|
"react": ">=18.0.0"
|
|
77
78
|
},
|
|
78
79
|
"dependencies": {
|
|
79
80
|
"@5minds/processcube_engine_client": "^4.3.1",
|
|
80
81
|
"client-only": "^0.0.1",
|
|
82
|
+
"jwt-decode": "^3.1.2",
|
|
81
83
|
"only-server": "^0.0.1"
|
|
82
84
|
}
|
|
83
85
|
}
|
package/server/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var S=(e,s)=>{for(var n in s)d(e,n,{get:s[n],enumerable:!0})},h=(e,s,n,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of U(s))!F.call(e,o)&&o!==n&&d(e,o,{get:()=>s[o],enumerable:!(r=x(s,o))||r.enumerable});return e};var C=e=>h(d({},"__esModule",{value:!0}),e);var J={};S(J,{finishUserTask:()=>v,finishUserTaskAndGetNext:()=>E,getActiveProcessInstances:()=>W,getAssignedUserTasksByIdentity:()=>R,getIdentity:()=>_,getReservedUserTasksByIdentity:()=>B,getUserTasks:()=>M,getWaitingUserTaskByCorrelationId:()=>D,getWaitingUserTaskByFlowNodeInstanceId:()=>f,getWaitingUserTasks:()=>q,getWaitingUserTasksByFlowNodeId:()=>b,hardNavigate:()=>A,startProcess:()=>G,waitForUserTask:()=>P});module.exports=C(J);var oe=require("only-server");var a=require("@5minds/processcube_engine_client");var l=require("@5minds/processcube_engine_client"),t=new l.EngineClient(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function P(e={}){let{processInstanceId:s,flowNodeId:n}=e;return new Promise(async(r,o)=>{let w=await t.userTasks.onUserTaskWaiting(async i=>{let T=i.flowNodeInstanceId===void 0,k=s!==void 0&&i.processInstanceId!==s,g=n!==void 0&&i.flowNodeId!==n,N=s!==void 0&&n!==void 0&&i.processInstanceId!==s&&i.flowNodeId!==n;if(T||k||g||N)return;let u=await f(i.flowNodeInstanceId);return t.notification.removeSubscription(w),u===null?o(new Error(`UserTask with instance ID "${i.flowNodeInstanceId}" does not exist.`)):r(u)})})}async function E(e,s,n){await t.userTasks.finishUserTask(e,s);let r=await t.userTasks.query({flowNodeId:n,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.totalCount>0?r.userTasks[0]:null}async function M(...e){return t.userTasks.query(...e)}async function q(e){let s=await t.userTasks.query({state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return s.totalCount===0?null:s.userTasks}async function b(e,s){return t.userTasks.query({flowNodeId:e,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s)}async function f(e,s){let n=await t.userTasks.query({flowNodeInstanceId:e,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return n.userTasks.length?n.userTasks[0]:null}async function D(e){let s=await t.userTasks.query({correlationId:e,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended});return s.totalCount==0?null:s.userTasks[0]}async function B(e,s){let r=(await t.userTasks.query({state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(o=>o.actualOwnerId===e.userId);return r.length?r:null}async function R(e,s){let r=(await t.userTasks.query({state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(o=>o.assignedUserIds?.includes(e.userId));return r.length?r:null}var c=require("next/headers"),p=require("next-auth/jwt");async function _(){let e=await(0,p.getToken)({req:{cookies:(0,c.cookies)(),headers:(0,c.headers)()}});if(!e?.accessToken||!e?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:e?.accessToken,userId:e?.sub}}var I=require("@5minds/processcube_engine_client");async function W(){let e=await t.processInstances.query({state:I.DataModels.ProcessInstances.ProcessInstanceState.running});return e.totalCount===0?null:e.processInstances}var m=require("next/cache"),y=require("next/navigation");async function A(e,s){(0,m.revalidatePath)(e),(0,y.redirect)(e,s)}async function G(...e){return await t.processModels.startProcessInstance(...e)}async function v(...e){await t.userTasks.finishUserTask(...e)}0&&(module.exports={finishUserTask,finishUserTaskAndGetNext,getActiveProcessInstances,getAssignedUserTasksByIdentity,getIdentity,getReservedUserTasksByIdentity,getUserTasks,getWaitingUserTaskByCorrelationId,getWaitingUserTaskByFlowNodeInstanceId,getWaitingUserTasks,getWaitingUserTasksByFlowNodeId,hardNavigate,startProcess,waitForUserTask});
|
package/server/index.d.ts
CHANGED
|
@@ -8,3 +8,24 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
import { DefaultSession } from 'next-auth';
|
|
12
|
+
declare module 'next-auth' {
|
|
13
|
+
/**
|
|
14
|
+
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
|
|
15
|
+
*/
|
|
16
|
+
interface Session {
|
|
17
|
+
user: {
|
|
18
|
+
/** The user's identity claims. */
|
|
19
|
+
claims?: Record<string, unknown>;
|
|
20
|
+
} & DefaultSession['user'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
declare module 'next-auth/jwt' {
|
|
24
|
+
/** Returned by the `jwt` callback and `getToken`, when using JWT sessions */
|
|
25
|
+
interface JWT {
|
|
26
|
+
/** OpenID Access Token */
|
|
27
|
+
accessToken?: string;
|
|
28
|
+
/** OpenID ID Token */
|
|
29
|
+
idToken?: string;
|
|
30
|
+
}
|
|
31
|
+
}
|
package/server/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"only-server";import{DataModels as a}from"@5minds/processcube_engine_client";import{EngineClient as
|
|
1
|
+
import"only-server";import{DataModels as a}from"@5minds/processcube_engine_client";import{EngineClient as I}from"@5minds/processcube_engine_client";var t=new I(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function h(e={}){let{processInstanceId:s,flowNodeId:n}=e;return new Promise(async(r,i)=>{let d=await t.userTasks.onUserTaskWaiting(async o=>{let u=o.flowNodeInstanceId===void 0,l=s!==void 0&&o.processInstanceId!==s,f=n!==void 0&&o.flowNodeId!==n,p=s!==void 0&&n!==void 0&&o.processInstanceId!==s&&o.flowNodeId!==n;if(u||l||f||p)return;let c=await m(o.flowNodeInstanceId);return t.notification.removeSubscription(d),c===null?i(new Error(`UserTask with instance ID "${o.flowNodeInstanceId}" does not exist.`)):r(c)})})}async function C(e,s,n){await t.userTasks.finishUserTask(e,s);let r=await t.userTasks.query({flowNodeId:n,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.totalCount>0?r.userTasks[0]:null}async function P(...e){return t.userTasks.query(...e)}async function E(e){let s=await t.userTasks.query({state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return s.totalCount===0?null:s.userTasks}async function M(e,s){return t.userTasks.query({flowNodeId:e,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},s)}async function m(e,s){let n=await t.userTasks.query({flowNodeInstanceId:e,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return n.userTasks.length?n.userTasks[0]:null}async function q(e){let s=await t.userTasks.query({correlationId:e,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended});return s.totalCount==0?null:s.userTasks[0]}async function b(e,s){let r=(await t.userTasks.query({state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(i=>i.actualOwnerId===e.userId);return r.length?r:null}async function D(e,s){let r=(await t.userTasks.query({state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(i=>i.assignedUserIds?.includes(e.userId));return r.length?r:null}import{cookies as y,headers as w}from"next/headers";import{getToken as T}from"next-auth/jwt";async function W(){let e=await T({req:{cookies:y(),headers:w()}});if(!e?.accessToken||!e?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:e?.accessToken,userId:e?.sub}}import{DataModels as k}from"@5minds/processcube_engine_client";async function J(){let e=await t.processInstances.query({state:k.ProcessInstances.ProcessInstanceState.running});return e.totalCount===0?null:e.processInstances}import{revalidatePath as g}from"next/cache";import{redirect as N}from"next/navigation";async function Q(e,s){g(e),N(e,s)}async function Y(...e){return await t.processModels.startProcessInstance(...e)}async function Z(...e){await t.userTasks.finishUserTask(...e)}export{Z as finishUserTask,C as finishUserTaskAndGetNext,J as getActiveProcessInstances,D as getAssignedUserTasksByIdentity,W as getIdentity,b as getReservedUserTasksByIdentity,P as getUserTasks,q as getWaitingUserTaskByCorrelationId,m as getWaitingUserTaskByFlowNodeInstanceId,E as getWaitingUserTasks,M as getWaitingUserTasksByFlowNodeId,Q as hardNavigate,Y as startProcess,h as waitForUserTask};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { DataModels } from '@5minds/processcube_engine_client';
|
|
2
2
|
import { Client } from './internal/EngineClient';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Waits for a UserTask to be created and returns it.
|
|
5
|
+
*
|
|
6
|
+
* @param filterBy Additional filter options
|
|
7
|
+
* @param filterBy.processInstanceId The ID of the ProcessInstance the UserTask belongs to
|
|
8
|
+
* @param filterBy.flowNodeId The UserTask FlowNode ID (BPMN)
|
|
9
|
+
* @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance>} The created UserTask.
|
|
10
|
+
*/
|
|
11
|
+
export declare function waitForUserTask(filterBy?: {
|
|
12
|
+
processInstanceId?: string;
|
|
13
|
+
flowNodeId?: string;
|
|
14
|
+
}): Promise<DataModels.FlowNodeInstances.UserTaskInstance>;
|
|
4
15
|
export declare function finishUserTaskAndGetNext(flowNodeInstanceId: string, result: any, flowNodeId: string): Promise<DataModels.FlowNodeInstances.UserTaskInstance | null>;
|
|
5
16
|
export declare function getUserTasks(...args: Parameters<typeof Client.userTasks.query>): Promise<DataModels.FlowNodeInstances.UserTaskList>;
|
|
6
17
|
/**
|
|
@@ -8,7 +19,7 @@ export declare function getUserTasks(...args: Parameters<typeof Client.userTasks
|
|
|
8
19
|
* @param options Additional options for the query e.g. `identity` or `sortSettings`
|
|
9
20
|
* @returns DataModels.FlowNodeInstances.UserTaskList
|
|
10
21
|
*/
|
|
11
|
-
export declare function getWaitingUserTasks(options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.
|
|
22
|
+
export declare function getWaitingUserTasks(options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
|
|
12
23
|
/**
|
|
13
24
|
*
|
|
14
25
|
* @param flowNodeId The UserTasks ID (BPMN)
|
package/server/lib/index.d.ts
CHANGED