@5minds/processcube_app_sdk 0.0.1-develop-e5b363-lki8hmms → 0.0.1-feature-b6bc60-ljphkna7

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/README.md CHANGED
@@ -1,83 +1,2 @@
1
1
  # ProcessCube.App.SDK
2
-
3
- Das SDK beinhaltet Komponenten und Funktionen für Frontend und Backend (Client/Server) zur einfachen und schnellen Entiwcklung einer ProcessCube App auf Basis von [Next.js](https://nextjs.org/).
4
-
5
- ## Installation zur Verwendung
6
-
7
- ### Vorraussetzungen
8
-
9
- - NodeJS `>= v16`
10
-
11
- ```shell
12
- npm i @5minds/processcube_app_sdk
13
- ```
14
-
15
- ## Benutzung
16
-
17
- Das NPM Paket hat *drei* Exports.
18
-
19
- ### Default/Common
20
-
21
- Hier werden Komponten und Funktionen exportiert, die im Client und Server genutzt werden können.
22
-
23
- Zum Beispiel die React Kompontene RemoteUserTask:
24
-
25
- ```javascript
26
- import { RemoteUserTask } from "@5minds/processcube_app_sdk";
27
- ```
28
-
29
- ### Server
30
-
31
- Hier steht alles ausschließlich für eine Serverseitige Umgebung zur Verfügung. Dazu zählen Funktionen die mit der Engine arbeiten, oder React Komponenten, die Serverseitig gerendert werden können.
32
-
33
- Beispiel:
34
-
35
- ```javascript
36
- import { startProcess } from "@5minds/processcube_app_sdk/server";
37
- ```
38
-
39
- Um die Engine URL anzupassen, die von den exportierten Funktionen genutzt wird, muss `PROCESSCUBE_ENGINE_URL` als Umgebungsvariable gesetzt werden. Andernfalls wird localhost mit dem Standardport der Engine genutzt `10560`.
40
-
41
- ### Client
42
-
43
- Es können nur Komponenten und Funktionen importiert werden, die im Browser funktionieren. Zum Beispiel React Komponenten, die einen Clientseitigen Router und dessen React Hooks nutzen oder Funktionen die auf `window` oder generell globale Browser APIs zugreifen möchten.
44
-
45
- ```javascript
46
- import { DynamicLink } from "@5minds/processcube_app_sdk/client";
47
- ```
48
-
49
- ## Wie kann ich das Projekt aufsetzen?
50
-
51
- ### Setup/Installation
52
-
53
- Das SDK wird über den Node Paketmanager `npm` gebaut.
54
-
55
- Für das Installieren und Bauen können folgende Befehle benutzt werden:
56
-
57
- ```shell
58
- npm ci
59
- npm run build
60
- ```
61
-
62
- Für ein Productionbuild:
63
-
64
- ```shell
65
- npm run build:prod
66
- ```
67
-
68
- Um mit dem Paket lokal zu arbeiten kann es mit npm in ein anderes Projekt verlinkt werden:
69
-
70
- ```shell
71
- npm link
72
- npm run watch
73
- ```
74
-
75
- Im Zielprojekt anschließend:
76
-
77
- ```shell
78
- npm link @5minds/processcube_app_sdk
79
- ```
80
-
81
- ## Wen kann ich auf das Projekt ansprechen?
82
-
83
- 1. [Alexander Kasten](mailto:alexander.kasten@5minds.de)
2
+ The SDK for ProcessCube Apps
@@ -0,0 +1,2 @@
1
+ export * from './DynamicLink';
2
+ export * from './RemoteUserTask';
package/client/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import 'client-only';
2
- export * from './components/DynamicLink';
1
+ export * from './components';
@@ -0,0 +1 @@
1
+ import{useRouter as n}from"next/navigation";import{jsx as p}from"react/jsx-runtime";function m({href:e,children:o}){let r=n();return p("a",{href:e,onClick:i=>{i.preventDefault(),r.replace(e),r.refresh()},children:o})}import{jsx as t}from"react/jsx-runtime";function c(e){return t("div",{style:{width:"100%",height:"100%"},children:t("iframe",{width:"100%",height:"100%",src:e.url})})}export{m as DynamicLink,c as RemoteUserTask};
package/package.json CHANGED
@@ -1,41 +1,40 @@
1
1
  {
2
2
  "name": "@5minds/processcube_app_sdk",
3
- "version": "0.0.1-develop-e5b363-lki8hmms",
3
+ "version": "0.0.1-feature-b6bc60-ljphkna7",
4
4
  "description": "The SDK for ProcessCube Apps",
5
5
  "type": "module",
6
- "main": "common/index.cjs",
7
- "module": "common/index.mjs",
8
- "browser": "client/index.mjs",
9
- "types": "common/index.d.ts",
6
+ "main": "server/index.js",
7
+ "module": "server/index.js",
8
+ "browser": "client/index.js",
9
+ "types": "server/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
- "types": "./common/index.d.ts",
13
- "require": "./common/index.cjs",
14
- "default": "./common/index.mjs"
12
+ "types": "./server/index.d.ts",
13
+ "default": "./server/index.js"
15
14
  },
16
15
  "./server": {
17
16
  "types": "./server/index.d.ts",
18
- "require": "./server/index.cjs",
19
- "default": "./server/index.mjs"
17
+ "default": "./server/index.js"
20
18
  },
21
19
  "./client": {
22
- "types": "./client/index.d.ts",
23
- "require": "./client/index.cjs",
24
- "default": "./client/index.mjs"
20
+ "types": {
21
+ "default": "./client/index.d.ts"
22
+ },
23
+ "default": "./client/index.js"
24
+ },
25
+ "./test": {
26
+ "import": "./client/index.js",
27
+ "require": "./client/index.js",
28
+ "default": "./client/index.js"
25
29
  }
26
30
  },
27
31
  "scripts": {
28
- "clean": "rm -rf server common client",
32
+ "clean": "rm -rf client server",
29
33
  "prepare": "npm run build:prod",
30
34
  "test": "echo \"Error: no test specified\" && exit 1",
31
- "build": "concurrently -n=build:esm,build:commonjs,build:types \"npm run build:esm\" \"npm run build:commonjs\" \"npm run build:types\"",
32
- "build:esm": "NODE_ENV=development esbuild src/**/*.ts --outdir=. --packages=external --bundle --format=esm --analyze=verbose --out-extension:.js=.mjs",
33
- "build:commonjs": "NODE_ENV=development esbuild src/**/*.ts --outdir=. --packages=external --bundle --platform=node --out-extension:.js=.cjs --analyze=verbose",
34
- "build:types": "tsc --emitDeclarationOnly && tsc -p tsconfig.common.json --emitDeclarationOnly && tsc -p tsconfig.client.json --emitDeclarationOnly",
35
- "build:prod": "npm run clean && concurrently -n=build:prod:esm,build:prod:commonjs,build:types \"npm run build:prod:esm\" \"npm run build:prod:commonjs\" \"npm run build:types\"",
36
- "build:prod:esm": "NODE_ENV=production esbuild src/**/*.ts --outdir=. --packages=external --bundle --format=esm --tree-shaking=true --splitting --minify --drop:console --out-extension:.js=.mjs",
37
- "build:prod:commonjs": "NODE_ENV=production esbuild src/**/*.ts --outdir=. --packages=external --bundle --platform=node --out-extension:.js=.cjs --tree-shaking=true --minify --drop:console",
38
- "watch": "NODE_ENV=development concurrently --kill-others -n=esbuild:esm,esbuild:comonjs,tsc:server,tsc:common,tsc:client \"esbuild src/**/*.ts --watch --outdir=. --format=esm --bundle --packages=external --out-extension:.js=.mjs\" \"esbuild src/**/*.ts --watch --outdir=. --platform=node --bundle --packages=external --out-extension:.js=.cjs\" \"tsc -p tsconfig.json --watch --preserveWatchOutput --emitDeclarationOnly\" \"tsc -p tsconfig.common.json --watch --preserveWatchOutput --emitDeclarationOnly\" \"tsc -p tsconfig.client.json --watch --preserveWatchOutput --emitDeclarationOnly\""
35
+ "build": "NODE_ENV=development esbuild src/server/index.ts src/client/index.ts --outdir=. --packages=external --bundle --format=esm --analyze=verbose && tsc --emitDeclarationOnly && tsc -p tsconfig.client.json --emitDeclarationOnly",
36
+ "build:prod": "npm run clean && NODE_ENV=production esbuild src/server/index.ts src/client/index.ts --outdir=. --packages=external --bundle --format=esm --tree-shaking=true --splitting --minify --drop:console && tsc --emitDeclarationOnly && tsc -p tsconfig.client.json --emitDeclarationOnly",
37
+ "watch": "NODE_ENV=development concurrently --kill-others -n=esbuild,tsc:server,tsc:client \"esbuild src/server/index.ts src/client/index.ts --watch --outdir=. --format=esm --bundle --packages=external\" \"tsc --watch --emitDeclarationOnly\" \"tsc -p tsconfig.client.json --watch --emitDeclarationOnly\""
39
38
  },
40
39
  "repository": {
41
40
  "type": "git",
@@ -43,8 +42,7 @@
43
42
  },
44
43
  "files": [
45
44
  "client",
46
- "server",
47
- "common"
45
+ "server"
48
46
  ],
49
47
  "keywords": [
50
48
  "SDK",
@@ -68,18 +66,15 @@
68
66
  "@types/react": "^18.2.13",
69
67
  "concurrently": "^8.2.0",
70
68
  "esbuild": "0.18.11",
69
+ "parcel": "^2.9.3",
71
70
  "prettier": "^2.8.8",
72
71
  "typescript": "^5.1.3"
73
72
  },
74
73
  "peerDependencies": {
75
74
  "next": ">=13.4",
76
- "next-auth": "^4.22.1",
77
75
  "react": ">=18.0.0"
78
76
  },
79
77
  "dependencies": {
80
- "@5minds/processcube_engine_client": "^4.3.1",
81
- "client-only": "^0.0.1",
82
- "jwt-decode": "^3.1.2",
83
- "only-server": "^0.0.1"
78
+ "@5minds/processcube_engine_client": "^4.3.1"
84
79
  }
85
80
  }
package/server/index.d.ts CHANGED
@@ -1,31 +1,8 @@
1
- import 'only-server';
1
+ declare const _default: {
2
+ config: ({ engineUrl }: {
3
+ engineUrl: string;
4
+ }) => void;
5
+ };
6
+ export default _default;
2
7
  export * from './lib';
3
8
  export * from './server-actions';
4
- declare global {
5
- namespace NodeJS {
6
- interface ProcessEnv {
7
- PROCESSCUBE_ENGINE_URL?: string;
8
- }
9
- }
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
- }
@@ -0,0 +1 @@
1
+ var f=process.env.PROCESSCUBE_ENGINE_URL||"http://localhost:10560";function o(){return f}function c(s){s=s}import{EngineClient as d,DataModels as p}from"@5minds/processcube_engine_client";var g=o(),n=new d(g);async function m(s){return(await n.userTasks.query({flowNodeInstanceId:s})).userTasks[0]}async function I(s,e){let t=await n.userTasks.query({processInstanceId:s,flowNodeId:e});return t.totalCount==0?null:t.userTasks[0]}async function E(s,e){return new Promise(async t=>{let r=n.userTasks.onUserTaskWaiting(async a=>{if(a.processInstanceId===s&&a.flowNodeId===e){let l=await m(a.flowNodeInstanceId);t(l)}}),i=await I(s,e);i&&t(i),await r})}async function P(s,e,t){await n.userTasks.finishUserTask(s,e);let r=await n.userTasks.query({flowNodeId:t,state:p.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.totalCount>0?r.userTasks[0]:null}import{revalidatePath as T}from"next/cache";import{redirect as k}from"next/navigation";async function R(s,e){T(s),k(s,e)}import{EngineClient as w}from"@5minds/processcube_engine_client";var y=o(),u=new w(y);async function _(s){return await u.processModels.startProcessInstance({processModelId:s})}async function v(s,e){await u.userTasks.finishUserTask(s,e)}var j={config:({engineUrl:s})=>{typeof s=="string"&&c(s)}};export{j as default,v as finishTask,P as finishUserTaskAndGetNext,R as hardNavigate,_ as startProcess,E as waitForUserTaskByProcessInstanceId};
@@ -1,64 +1,3 @@
1
1
  import { DataModels } from '@5minds/processcube_engine_client';
2
- import { Client } from './internal/EngineClient';
3
- /**
4
- * If there is no UserTask waiting, this function will wait for the next UserTask to be created.
5
- * If there is already a UserTask waiting, this function will return it.
6
- *
7
- * @param filterBy Additional filter options
8
- * @param filterBy.processInstanceId The ID of the ProcessInstance the UserTask belongs to
9
- * @param filterBy.flowNodeId The UserTask FlowNode ID (BPMN)
10
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance>} The created UserTask.
11
- */
12
- export declare function waitForUserTask(filterBy?: {
13
- processInstanceId?: string;
14
- flowNodeId?: string;
15
- }): Promise<DataModels.FlowNodeInstances.UserTaskInstance>;
2
+ export declare function waitForUserTaskByProcessInstanceId(processInstanceId: string, flowNodeId: string): Promise<DataModels.FlowNodeInstances.UserTaskInstance>;
16
3
  export declare function finishUserTaskAndGetNext(flowNodeInstanceId: string, result: any, flowNodeId: string): Promise<DataModels.FlowNodeInstances.UserTaskInstance | null>;
17
- export declare function getUserTasks(...args: Parameters<typeof Client.userTasks.query>): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
18
- /**
19
- *
20
- * @param options Additional options for the query e.g. {@link DataModels.Iam.Identity} or {@link DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings}
21
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>}
22
- */
23
- export declare function getWaitingUserTasks(options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
24
- /**
25
- *
26
- * @param flowNodeId The UserTasks ID (BPMN)
27
- * @param options Additional options for the query e.g. {@link DataModels.Iam.Identity} or {@link DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings}
28
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>}
29
- */
30
- export declare function getWaitingUserTasksByFlowNodeId(flowNodeId: string | string[], options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
31
- /**
32
- *
33
- * @param flowNodeInstanceId The UserTask Instance ID
34
- * @param options Additional options for the query e.g. {@link DataModels.Iam.Identity}
35
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance | null>}
36
- */
37
- export declare function getWaitingUserTaskByFlowNodeInstanceId(flowNodeInstanceId: string, options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.UserTaskInstance | null>;
38
- /**
39
- * @param correlationId The Correlation ID
40
- * @param options Additional options for the query e.g. {@link DataModels.Iam.Identity}
41
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>}
42
- */
43
- export declare function getWaitingUserTasksByCorrelationId(correlationId: string, options?: Parameters<typeof Client.userTasks.query>[1]): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
44
- /**
45
- * @param identity The identity of the user
46
- * @param options Additional options for the query e.g. {@link DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings}
47
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>}
48
- */
49
- export declare function getReservedUserTasksByIdentity(identity: DataModels.Iam.Identity, options?: {
50
- offset?: number;
51
- limit?: number;
52
- sortSettings?: DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings;
53
- }): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
54
- /**
55
- *
56
- * @param identity The identity of the user
57
- * @param options Additional options for the query e.g. {@link DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings}
58
- * @returns {Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>}
59
- */
60
- export declare function getAssignedUserTasksByIdentity(identity: DataModels.Iam.Identity, options?: {
61
- offset?: number;
62
- limit?: number;
63
- sortSettings?: DataModels.FlowNodeInstances.FlowNodeInstanceSortSettings;
64
- }): Promise<DataModels.FlowNodeInstances.UserTaskInstance[] | null>;
@@ -1,3 +1 @@
1
1
  export * from './UserTaskFunctions';
2
- export * from './getIdentity';
3
- export * from './ProcessInstanceFunctions';
@@ -0,0 +1,2 @@
1
+ export declare function getEngineUrl(): string;
2
+ export declare function setEngineUrl(engineUrl: string): void;
@@ -1,3 +1,3 @@
1
- import type { EngineClient } from '@5minds/processcube_engine_client';
2
- export declare function startProcess(...args: Parameters<typeof EngineClient.prototype.processModels.startProcessInstance>): ReturnType<typeof EngineClient.prototype.processModels.startProcessInstance>;
3
- export declare function finishUserTask(...args: Parameters<typeof EngineClient.prototype.userTasks.finishUserTask>): ReturnType<typeof EngineClient.prototype.userTasks.finishUserTask>;
1
+ import { DataModels } from '@5minds/processcube_engine_client';
2
+ export declare function startProcess(processModelId: string): Promise<DataModels.ProcessInstances.ProcessStartResponse>;
3
+ export declare function finishTask(flowNodeInstanceId: string, result: any): Promise<void>;
package/client/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";"use client";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var n in r)i(e,n,{get:r[n],enumerable:!0})},l=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of f(r))!m.call(e,o)&&o!==n&&i(e,o,{get:()=>r[o],enumerable:!(t=c(r,o))||t.enumerable});return e};var s=e=>l(i({},"__esModule",{value:!0}),e);var D={};u(D,{DynamicLink:()=>y});module.exports=s(D);var v=require("client-only");var p=require("next/navigation"),a=require("react/jsx-runtime");function y({href:e,children:r}){let n=(0,p.useRouter)();return(0,a.jsx)("a",{href:e,onClick:t=>{t.preventDefault(),n.replace(e),n.refresh()},children:r})}0&&(module.exports={DynamicLink});
package/client/index.mjs DELETED
@@ -1 +0,0 @@
1
- "use client";import"client-only";import{useRouter as t}from"next/navigation";import{jsx as i}from"react/jsx-runtime";function a({href:r,children:n}){let e=t();return i("a",{href:r,onClick:o=>{o.preventDefault(),e.replace(r),e.refresh()},children:n})}export{a as DynamicLink};
@@ -1,23 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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/server/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var S=(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 o of x(s))!P.call(e,o)&&o!==t&&u(e,o,{get:()=>s[o],enumerable:!(r=h(s,o))||r.enumerable});return e};var C=e=>M(u({},"__esModule",{value:!0}),e);var O={};S(O,{finishUserTask:()=>J,finishUserTaskAndGetNext:()=>E,getActiveProcessInstances:()=>A,getAssignedUserTasksByIdentity:()=>_,getIdentity:()=>W,getReservedUserTasksByIdentity:()=>R,getUserTasks:()=>p,getWaitingUserTaskByFlowNodeInstanceId:()=>m,getWaitingUserTasks:()=>q,getWaitingUserTasksByCorrelationId:()=>B,getWaitingUserTasksByFlowNodeId:()=>b,hardNavigate:()=>G,startProcess:()=>v,waitForUserTask:()=>D});module.exports=C(O);var ie=require("only-server");var a=require("@5minds/processcube_engine_client");var f=require("@5minds/processcube_engine_client"),n=new f.EngineClient(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function D(e={}){let{processInstanceId:s,flowNodeId:t}=e;return new Promise(async(r,o)=>{let d=await n.userTasks.onUserTaskWaiting(async i=>{let g=i.flowNodeInstanceId===void 0,N=s!==void 0&&i.processInstanceId!==s,F=t!==void 0&&i.flowNodeId!==t,U=s!==void 0&&t!==void 0&&i.processInstanceId!==s&&i.flowNodeId!==t;if(g||N||F||U)return;let I=await m(i.flowNodeInstanceId);return n.notification.removeSubscription(d),I===null?o(new Error(`UserTask with instance ID "${i.flowNodeInstanceId}" does not exist.`)):r(I)}),l=(await p({processInstanceId:s,flowNodeId:t,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended}))?.[0];l&&(n.notification.removeSubscription(d),r(l))})}async function E(e,s,t){await n.userTasks.finishUserTask(e,s);let r=await n.userTasks.query({flowNodeId:t,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.userTasks.length===0?null:r.userTasks[0]}async function p(...e){let s=await n.userTasks.query(...e);return s.userTasks.length===0?null:s.userTasks}async function q(e){let s=await n.userTasks.query({state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return s.userTasks.length===0?null:s.userTasks}async function b(e,s){let t=await n.userTasks.query({flowNodeId:e,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return t.userTasks.length===0?null:t.userTasks}async function m(e,s){let t=await n.userTasks.query({flowNodeInstanceId:e,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{...s,limit:1});return t.userTasks.length===0?null:t.userTasks[0]}async function B(e,s){let t=await n.userTasks.query({correlationId:e,state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return t.userTasks.length===0?null:t.userTasks}async function R(e,s){let r=(await n.userTasks.query({state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(o=>o.actualOwnerId===e.userId);return r.length===0?null:r}async function _(e,s){let r=(await n.userTasks.query({state:a.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(o=>o.assignedUserIds?.includes(e.userId));return r.length===0?null:r}var c=require("next/headers"),T=require("next-auth/jwt");async function W(){let e=await(0,T.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 k=require("@5minds/processcube_engine_client");async function A(e){let s=await n.processInstances.query({state:k.DataModels.ProcessInstances.ProcessInstanceState.running},e);return s.processInstances.length===0?null:s.processInstances}var w=require("next/cache"),y=require("next/navigation");async function G(e,s){(0,w.revalidatePath)(e),(0,y.redirect)(e,s)}async function v(...e){return await n.processModels.startProcessInstance(...e)}async function J(...e){await n.userTasks.finishUserTask(...e)}0&&(module.exports={finishUserTask,finishUserTaskAndGetNext,getActiveProcessInstances,getAssignedUserTasksByIdentity,getIdentity,getReservedUserTasksByIdentity,getUserTasks,getWaitingUserTaskByFlowNodeInstanceId,getWaitingUserTasks,getWaitingUserTasksByCorrelationId,getWaitingUserTasksByFlowNodeId,hardNavigate,startProcess,waitForUserTask});
package/server/index.mjs DELETED
@@ -1 +0,0 @@
1
- import"only-server";import{DataModels as o}from"@5minds/processcube_engine_client";import{EngineClient as m}from"@5minds/processcube_engine_client";var n=new m(process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560");async function C(e={}){let{processInstanceId:s,flowNodeId:t}=e;return new Promise(async(r,i)=>{let c=await n.userTasks.onUserTaskWaiting(async a=>{let l=a.flowNodeInstanceId===void 0,I=s!==void 0&&a.processInstanceId!==s,f=t!==void 0&&a.flowNodeId!==t,p=s!==void 0&&t!==void 0&&a.processInstanceId!==s&&a.flowNodeId!==t;if(l||I||f||p)return;let d=await k(a.flowNodeInstanceId);return n.notification.removeSubscription(c),d===null?i(new Error(`UserTask with instance ID "${a.flowNodeInstanceId}" does not exist.`)):r(d)}),u=(await T({processInstanceId:s,flowNodeId:t,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended}))?.[0];u&&(n.notification.removeSubscription(c),r(u))})}async function D(e,s,t){await n.userTasks.finishUserTask(e,s);let r=await n.userTasks.query({flowNodeId:t,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended});return r.userTasks.length===0?null:r.userTasks[0]}async function T(...e){let s=await n.userTasks.query(...e);return s.userTasks.length===0?null:s.userTasks}async function E(e){let s=await n.userTasks.query({state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return s.userTasks.length===0?null:s.userTasks}async function q(e,s){let t=await n.userTasks.query({flowNodeId:e,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return t.userTasks.length===0?null:t.userTasks}async function k(e,s){let t=await n.userTasks.query({flowNodeInstanceId:e,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},{...s,limit:1});return t.userTasks.length===0?null:t.userTasks[0]}async function b(e,s){let t=await n.userTasks.query({correlationId:e,state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return t.userTasks.length===0?null:t.userTasks}async function B(e,s){let r=(await n.userTasks.query({state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(i=>i.actualOwnerId===e.userId);return r.length===0?null:r}async function R(e,s){let r=(await n.userTasks.query({state:o.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:e,...s})).userTasks.filter(i=>i.assignedUserIds?.includes(e.userId));return r.length===0?null:r}import{cookies as w,headers as y}from"next/headers";import{getToken as g}from"next-auth/jwt";async function G(){let e=await g({req:{cookies:w(),headers:y()}});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 N}from"@5minds/processcube_engine_client";async function L(e){let s=await n.processInstances.query({state:N.ProcessInstances.ProcessInstanceState.running},e);return s.processInstances.length===0?null:s.processInstances}import{revalidatePath as F}from"next/cache";import{redirect as U}from"next/navigation";async function X(e,s){F(e),U(e,s)}async function ee(...e){return await n.processModels.startProcessInstance(...e)}async function se(...e){await n.userTasks.finishUserTask(...e)}export{se as finishUserTask,D as finishUserTaskAndGetNext,L as getActiveProcessInstances,R as getAssignedUserTasksByIdentity,G as getIdentity,B as getReservedUserTasksByIdentity,T as getUserTasks,k as getWaitingUserTaskByFlowNodeInstanceId,E as getWaitingUserTasks,b as getWaitingUserTasksByCorrelationId,q as getWaitingUserTasksByFlowNodeId,X as hardNavigate,ee as startProcess,C as waitForUserTask};
@@ -1,8 +0,0 @@
1
- import { DataModels } from '@5minds/processcube_engine_client';
2
- import { Client } from './internal/EngineClient';
3
- /**
4
- *
5
- * @param options The query options of {@link Client.processInstances.query}
6
- * @returns {DataModels.ProcessInstances.ProcessInstance[] | null}
7
- */
8
- export declare function getActiveProcessInstances(options?: Parameters<typeof Client.processInstances.query>[1]): Promise<DataModels.ProcessInstances.ProcessInstance[] | null>;
@@ -1,6 +0,0 @@
1
- import type { DataModels } from '@5minds/processcube_engine_client';
2
- /**
3
- *
4
- * @returns The users {@link DataModels.Iam.Identity} which can be used to access the 5Minds Engine.
5
- */
6
- export declare function getIdentity(): Promise<DataModels.Iam.Identity>;
@@ -1,2 +0,0 @@
1
- import { EngineClient } from '@5minds/processcube_engine_client';
2
- export declare const Client: EngineClient;