@5minds/processcube_app_sdk 0.0.1-feature-3e01db-lk2db3bf → 0.0.1-feature-a3f7e6-lk2jhtt1

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.
@@ -0,0 +1,5 @@
1
+ import { Session, CallbacksOptions } from 'next-auth';
2
+ import type { JWT } from 'next-auth/jwt';
3
+ export declare function hasClaim(claim: string): Promise<boolean>;
4
+ export declare function authConfigJwtCallback(args: Parameters<CallbacksOptions['jwt']>[0]): Promise<JWT>;
5
+ export declare function authConfigSessionCallback(args: Parameters<CallbacksOptions['session']>[0]): Promise<Session>;
package/common/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(e,r)=>{for(var o in r)i(e,o,{get:r[o],enumerable:!0})},d=(e,r,o,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of p(r))!a.call(e,t)&&t!==o&&i(e,t,{get:()=>r[t],enumerable:!(m=h(r,t))||m.enumerable});return e};var R=e=>d(i({},"__esModule",{value:!0}),e);var k={};f(k,{RemoteUserTask:()=>g});module.exports=R(k);var s=require("react/jsx-runtime");function g(e){return(0,s.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,s.jsx)("iframe",{width:"100%",height:"100%",src:e.url})})}0&&(module.exports={RemoteUserTask});
1
+ "use strict";var T=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var S=(e,s)=>{for(var t in s)r(e,t,{get:s[t],enumerable:!0})},c=(e,s,t,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of h(s))!y.call(e,n)&&n!==t&&r(e,n,{get:()=>s[n],enumerable:!(o=g(s,n))||o.enumerable});return e};var x=(e,s,t)=>(t=e!=null?T(b(e)):{},c(s||!e||!e.__esModule?r(t,"default",{value:e,enumerable:!0}):t,e)),j=e=>c(r({},"__esModule",{value:!0}),e);var J={};S(J,{RemoteUserTask:()=>C,authConfigJwtCallback:()=>d,authConfigSessionCallback:()=>k,hasClaim:()=>P});module.exports=j(J);var a=require("react/jsx-runtime");function C(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"),f=x(require("jwt-decode"),1);async function P(e){let s;return typeof window>"u"?s=(await(0,u.getServerSession)({callbacks:{jwt:d,session:k}}))?.user:s=(await(0,m.getSession)())?.user,!s||!s.claims?!1:s.claims[e]!=null}async function d(e){let{token:s,account:t}=e;return t&&(s.accessToken=t.access_token,s.idToken=t.id_token),s}async function k(e){let{session:s,token:t}=e,o=await l(t.accessToken),n=await l(t.idToken),p=Object.keys(n),i=Object.fromEntries(Object.entries(o).filter(([w,O])=>!p.includes(w)));return delete i.scope,delete i.jti,delete i.client_id,s.user.claims=i,s}async function l(e){return(0,f.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 e}from"react/jsx-runtime";function t(r){return e("div",{style:{width:"100%",height:"100%"},children:e("iframe",{width:"100%",height:"100%",src:r.url})})}export{t as RemoteUserTask};
1
+ import{jsx as o}from"react/jsx-runtime";function w(s){return o("div",{style:{width:"100%",height:"100%"},children:o("iframe",{width:"100%",height:"100%",src:s.url})})}import{getServerSession as u}from"next-auth";import{getSession as m}from"next-auth/react";import f from"jwt-decode";async function j(s){let e;return typeof window>"u"?e=(await u({callbacks:{jwt:d,session:k}}))?.user:e=(await m())?.user,!e||!e.claims?!1:e.claims[s]!=null}async function d(s){let{token:e,account:t}=s;return t&&(e.accessToken=t.access_token,e.idToken=t.id_token),e}async function k(s){let{session:e,token:t}=s,r=await i(t.accessToken),a=await i(t.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(s){return f(s)}export{w as RemoteUserTask,d 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-feature-3e01db-lk2db3bf",
3
+ "version": "0.0.1-feature-a3f7e6-lk2jhtt1",
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 u=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var g=(e,s)=>{for(var t in s)u(e,t,{get:s[t],enumerable:!0})},m=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of T(s))!k.call(e,a)&&a!==t&&u(e,a,{get:()=>s[a],enumerable:!(r=I(s,a))||r.enumerable});return e};var w=e=>m(u({},"__esModule",{value:!0}),e);var R={};g(R,{finishTask:()=>q,finishUserTaskAndGetNext:()=>x,getAssignedUserTasksByIdentity:()=>F,getIdentity:()=>M,getUserTasks:()=>C,getWaitingUserTaskByFlowNodeInstanceId:()=>p,getWaitingUserTasks:()=>P,getWaitingUserTasksByFlowNodeId:()=>E,hardNavigate:()=>h,startProcess:()=>S,waitForUserTaskByProcessInstanceId:()=>U});module.exports=w(R);var H=require("only-server");var o=require("@5minds/processcube_engine_client");var l=require("@5minds/processcube_engine_client"),n=new l.EngineClient(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function N(e,s){let t=await n.userTasks.query({processInstanceId:e,flowNodeId:s});return t.totalCount==0?null:t.userTasks[0]}async function U(e,s){return new Promise(async(t,r)=>{let a=n.userTasks.onUserTaskWaiting(async i=>{if(i.processInstanceId===e&&i.flowNodeId===s&&i.flowNodeInstanceId!=null){let d=await p(i.flowNodeInstanceId);return d!=null?t(d):r(new Error(`UserTask with instance ID "${i.flowNodeInstanceId}" does not exist.`))}}),c=await N(e,s);c&&t(c),await a})}async function x(e,s,t){await n.userTasks.finishUserTask(e,s);let r=await n.userTasks.query({flowNodeId:t,state:o.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.totalCount>0?r.userTasks[0]:null}async function C(...e){return n.userTasks.query(...e)}async function P(e){return n.userTasks.query({state:o.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e)}async function E(e,s){return n.userTasks.query({flowNodeId:e,state:o.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s)}async function p(e,s){let t=await n.userTasks.query({flowNodeInstanceId:e,state:o.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return t.userTasks.length?t.userTasks[0]:null}async function F(e,s){let r=(await n.userTasks.query({state:o.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(a=>a.assignedUserIds?.includes(e.userId));return r.length?r:null}var f=require("next/cache"),y=require("next/navigation");async function h(e,s){(0,f.revalidatePath)(e),(0,y.redirect)(e,s)}async function S(...e){return await n.processModels.startProcessInstance(...e)}async function q(...e){await n.userTasks.finishUserTask(...e)}function M(){return n.userTasks.identity}0&&(module.exports={finishTask,finishUserTaskAndGetNext,getAssignedUserTasksByIdentity,getIdentity,getUserTasks,getWaitingUserTaskByFlowNodeInstanceId,getWaitingUserTasks,getWaitingUserTasksByFlowNodeId,hardNavigate,startProcess,waitForUserTaskByProcessInstanceId});
1
+ "use strict";var u=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var g=(e,s)=>{for(var t in s)u(e,t,{get:s[t],enumerable:!0})},N=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of I(s))!w.call(e,o)&&o!==t&&u(e,o,{get:()=>s[o],enumerable:!(n=k(s,o))||n.enumerable});return e};var x=e=>N(u({},"__esModule",{value:!0}),e);var M={};g(M,{finishUserTask:()=>D,finishUserTaskAndGetNext:()=>h,getIdentity:()=>F,getUserTasks:()=>P,getWaitingUserTaskByFlowNodeInstanceId:()=>f,getWaitingUserTasks:()=>E,getWaitingUserTasksByFlowNodeId:()=>S,hardNavigate:()=>q,startProcess:()=>R,waitForUserTaskByProcessInstanceId:()=>U});module.exports=x(M);var Q=require("only-server");var i=require("@5minds/processcube_engine_client");var p=require("@5minds/processcube_engine_client"),r=new p.EngineClient(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function C(e,s){let t=await r.userTasks.query({processInstanceId:e,flowNodeId:s});return t.totalCount==0?null:t.userTasks[0]}async function U(e,s){return new Promise(async(t,n)=>{let o=r.userTasks.onUserTaskWaiting(async a=>{if(a.processInstanceId===e&&a.flowNodeId===s&&a.flowNodeInstanceId!=null){let l=await f(a.flowNodeInstanceId);return l!=null?t(l):n(new Error(`UserTask with instance ID "${a.flowNodeInstanceId}" does not exist.`))}}),d=await C(e,s);d&&t(d),await o})}async function h(e,s,t){await r.userTasks.finishUserTask(e,s);let n=await r.userTasks.query({flowNodeId:t,state:i.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended});return n.totalCount>0?n.userTasks[0]:null}async function P(...e){return r.userTasks.query(...e)}async function E(e){return r.userTasks.query({state:i.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e)}async function S(e,s){return r.userTasks.query({flowNodeId:e,state:i.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s)}async function f(e,s){let t=await r.userTasks.query({flowNodeInstanceId:e,state:i.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return t.userTasks.length?t.userTasks[0]:null}var c=require("next/headers"),m=require("next-auth/jwt");async function F(){let e=await(0,m.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 y=require("next/cache"),T=require("next/navigation");async function q(e,s){(0,y.revalidatePath)(e),(0,T.redirect)(e,s)}async function R(...e){return await r.processModels.startProcessInstance(...e)}async function D(...e){await r.userTasks.finishUserTask(...e)}0&&(module.exports={finishUserTask,finishUserTaskAndGetNext,getIdentity,getUserTasks,getWaitingUserTaskByFlowNodeInstanceId,getWaitingUserTasks,getWaitingUserTasksByFlowNodeId,hardNavigate,startProcess,waitForUserTaskByProcessInstanceId});
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 o}from"@5minds/processcube_engine_client";import{EngineClient as d}from"@5minds/processcube_engine_client";var t=new d(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function l(e,s){let n=await t.userTasks.query({processInstanceId:e,flowNodeId:s});return n.totalCount==0?null:n.userTasks[0]}async function w(e,s){return new Promise(async(n,r)=>{let i=t.userTasks.onUserTaskWaiting(async a=>{if(a.processInstanceId===e&&a.flowNodeId===s&&a.flowNodeInstanceId!=null){let c=await p(a.flowNodeInstanceId);return c!=null?n(c):r(new Error(`UserTask with instance ID "${a.flowNodeInstanceId}" does not exist.`))}}),u=await l(e,s);u&&n(u),await i})}async function N(e,s,n){await t.userTasks.finishUserTask(e,s);let r=await t.userTasks.query({flowNodeId:n,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.totalCount>0?r.userTasks[0]:null}async function U(...e){return t.userTasks.query(...e)}async function x(e){return t.userTasks.query({state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},e)}async function C(e,s){return t.userTasks.query({flowNodeId:e,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},s)}async function p(e,s){let n=await t.userTasks.query({flowNodeInstanceId:e,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return n.userTasks.length?n.userTasks[0]:null}async function P(e,s){let r=(await t.userTasks.query({state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(i=>i.assignedUserIds?.includes(e.userId));return r.length?r:null}import{revalidatePath as f}from"next/cache";import{redirect as y}from"next/navigation";async function M(e,s){f(e),y(e,s)}async function D(...e){return await t.processModels.startProcessInstance(...e)}async function _(...e){await t.userTasks.finishUserTask(...e)}function b(){return t.userTasks.identity}export{_ as finishTask,N as finishUserTaskAndGetNext,P as getAssignedUserTasksByIdentity,b as getIdentity,U as getUserTasks,p as getWaitingUserTaskByFlowNodeInstanceId,x as getWaitingUserTasks,C as getWaitingUserTasksByFlowNodeId,M as hardNavigate,D as startProcess,w as waitForUserTaskByProcessInstanceId};
1
+ import"only-server";import{DataModels as a}from"@5minds/processcube_engine_client";import{EngineClient as d}from"@5minds/processcube_engine_client";var t=new d(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function l(e,s){let r=await t.userTasks.query({processInstanceId:e,flowNodeId:s});return r.totalCount==0?null:r.userTasks[0]}async function x(e,s){return new Promise(async(r,o)=>{let u=t.userTasks.onUserTaskWaiting(async n=>{if(n.processInstanceId===e&&n.flowNodeId===s&&n.flowNodeInstanceId!=null){let c=await p(n.flowNodeInstanceId);return c!=null?r(c):o(new Error(`UserTask with instance ID "${n.flowNodeInstanceId}" does not exist.`))}}),i=await l(e,s);i&&r(i),await u})}async function C(e,s,r){await t.userTasks.finishUserTask(e,s);let o=await t.userTasks.query({flowNodeId:r,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended});return o.totalCount>0?o.userTasks[0]:null}async function U(...e){return t.userTasks.query(...e)}async function h(e){return t.userTasks.query({state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},e)}async function P(e,s){return t.userTasks.query({flowNodeId:e,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},s)}async function p(e,s){let r=await t.userTasks.query({flowNodeInstanceId:e,state:a.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return r.userTasks.length?r.userTasks[0]:null}import{cookies as f,headers as m}from"next/headers";import{getToken as y}from"next-auth/jwt";async function q(){let e=await y({req:{cookies:f(),headers:m()}});if(!e?.accessToken||!e?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:e?.accessToken,userId:e?.sub}}import{revalidatePath as T}from"next/cache";import{redirect as k}from"next/navigation";async function _(e,s){T(e),k(e,s)}async function J(...e){return await t.processModels.startProcessInstance(...e)}async function L(...e){await t.userTasks.finishUserTask(...e)}export{L as finishUserTask,C as finishUserTaskAndGetNext,q as getIdentity,U as getUserTasks,p as getWaitingUserTaskByFlowNodeInstanceId,h as getWaitingUserTasks,P as getWaitingUserTasksByFlowNodeId,_ as hardNavigate,J as startProcess,x as waitForUserTaskByProcessInstanceId};
@@ -23,14 +23,3 @@ export declare function getWaitingUserTasksByFlowNodeId(flowNodeId: string | str
23
23
  * @returns DataModels.FlowNodeInstances.UserTaskInstance | null
24
24
  */
25
25
  export declare function getWaitingUserTaskByFlowNodeInstanceId(flowNodeInstanceId: string, options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.UserTaskInstance | null>;
26
- /**
27
- *
28
- * @param identity The identity of the user
29
- * @param options Additional options for the query e.g. `sortSettings`
30
- * @returns DataModels.FlowNodeInstances.UserTaskInstance[] | null
31
- */
32
- export declare function getAssignedUserTasksByIdentity(identity: DataModels.Iam.Identity, options?: {
33
- offset?: number;
34
- limit?: number;
35
- sortSettings?: DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings;
36
- }): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
@@ -0,0 +1,2 @@
1
+ import { DataModels } from '@5minds/processcube_engine_client';
2
+ export declare function getIdentity(): Promise<DataModels.Iam.Identity>;
@@ -1 +1,2 @@
1
1
  export * from './UserTaskFunctions';
2
+ export * from './getIdentity';
@@ -1,4 +1,3 @@
1
- import type { DataModels, EngineClient } from '@5minds/processcube_engine_client';
1
+ import type { EngineClient } from '@5minds/processcube_engine_client';
2
2
  export declare function startProcess(...args: Parameters<typeof EngineClient.prototype.processModels.startProcessInstance>): ReturnType<typeof EngineClient.prototype.processModels.startProcessInstance>;
3
- export declare function finishTask(...args: Parameters<typeof EngineClient.prototype.userTasks.finishUserTask>): ReturnType<typeof EngineClient.prototype.userTasks.finishUserTask>;
4
- export declare function getIdentity(): DataModels.Iam.Identity;
3
+ export declare function finishUserTask(...args: Parameters<typeof EngineClient.prototype.userTasks.finishUserTask>): ReturnType<typeof EngineClient.prototype.userTasks.finishUserTask>;