@plitzi/sdk-interactions 0.30.19

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,77 @@
1
+ import { processTwig as e } from "@plitzi/sdk-shared/helpers/twigWrapper";
2
+ import { getPathsFromObeject as t } from "@plitzi/sdk-shared/helpers/utils";
3
+ //#region src/utility/twigTemplate.ts
4
+ var n = {
5
+ action: "twigTemplate",
6
+ title: "Twig Template",
7
+ type: "utility",
8
+ params: {
9
+ returnMode: {
10
+ label: "Mode",
11
+ canBind: !1,
12
+ type: "select",
13
+ defaultValue: "text",
14
+ options: [
15
+ {
16
+ label: "Text",
17
+ value: "text"
18
+ },
19
+ {
20
+ label: "Json Text",
21
+ value: "json"
22
+ },
23
+ {
24
+ label: "Json Object",
25
+ value: "jsonObject"
26
+ }
27
+ ]
28
+ },
29
+ template: {
30
+ label: "Template",
31
+ canBind: !1,
32
+ defaultValue: "",
33
+ type: (e) => {
34
+ let { returnMode: t } = e;
35
+ return t === "text" ? "codemirror-text" : "codemirror-json";
36
+ }
37
+ }
38
+ },
39
+ preview: (n) => {
40
+ let { template: r, returnMode: i } = n;
41
+ if (i === "jsonObject") try {
42
+ let i = JSON.parse(e(r, n));
43
+ if (i && typeof i == "object") return {
44
+ template: "",
45
+ content: t(i).reduce((e, t) => ({
46
+ ...e,
47
+ [t]: ""
48
+ }), {})
49
+ };
50
+ } catch {}
51
+ return {
52
+ template: "",
53
+ content: ""
54
+ };
55
+ },
56
+ callback: (t) => {
57
+ let { template: n, returnMode: r } = t, i = "";
58
+ try {
59
+ i = e(n, t);
60
+ } catch (e) {
61
+ console.error(e);
62
+ }
63
+ if (r === "jsonObject") try {
64
+ return { content: JSON.parse(i) };
65
+ } catch (e) {
66
+ console.error(e);
67
+ }
68
+ else if (r === "json") try {
69
+ return JSON.parse(i), { content: i };
70
+ } catch {
71
+ return { content: "" };
72
+ }
73
+ return { content: i };
74
+ }
75
+ };
76
+ //#endregion
77
+ export { n as default };
@@ -0,0 +1,9 @@
1
+ import { InteractionCallback } from '@plitzi/sdk-shared';
2
+ declare const delayTime: InteractionCallback<{
3
+ url: string;
4
+ method: string;
5
+ body: Record<string, string | Blob>;
6
+ authorizationToken: string;
7
+ credentials: RequestCredentials;
8
+ }>;
9
+ export default delayTime;
@@ -0,0 +1,117 @@
1
+ //#region src/utility/webHook.ts
2
+ var e = {
3
+ action: "webHook",
4
+ title: "Webhook",
5
+ type: "utility",
6
+ params: {
7
+ url: {
8
+ canBind: !0,
9
+ defaultValue: "",
10
+ type: "text",
11
+ label: "Url"
12
+ },
13
+ method: {
14
+ label: "Method",
15
+ type: "select",
16
+ defaultValue: "get",
17
+ options: [
18
+ {
19
+ label: "Get",
20
+ value: "get"
21
+ },
22
+ {
23
+ label: "Post",
24
+ value: "post"
25
+ },
26
+ {
27
+ label: "Put",
28
+ value: "put"
29
+ },
30
+ {
31
+ label: "Delete",
32
+ value: "delete"
33
+ },
34
+ {
35
+ label: "Patch",
36
+ value: "patch"
37
+ },
38
+ {
39
+ label: "Head",
40
+ value: "head"
41
+ }
42
+ ]
43
+ },
44
+ body: {
45
+ canBind: !0,
46
+ defaultValue: "",
47
+ type: "textarea",
48
+ label: "Body"
49
+ },
50
+ authorizationToken: {
51
+ canBind: !0,
52
+ defaultValue: "",
53
+ type: "text",
54
+ label: "Authorization Token"
55
+ },
56
+ credentials: {
57
+ canBind: !0,
58
+ defaultValue: "same-origin",
59
+ type: "select",
60
+ options: [
61
+ {
62
+ label: "Include",
63
+ value: "include"
64
+ },
65
+ {
66
+ label: "Omit",
67
+ value: "omit"
68
+ },
69
+ {
70
+ label: "Same Origin",
71
+ value: "same-origin"
72
+ }
73
+ ],
74
+ label: "Credentials"
75
+ }
76
+ },
77
+ preview: { response: {
78
+ status: "",
79
+ data: ""
80
+ } },
81
+ callback: async (e) => {
82
+ let { url: t, authorizationToken: n, body: r, credentials: i } = e, { method: a } = e, o = {};
83
+ try {
84
+ a = a.toUpperCase();
85
+ let e = {};
86
+ n && (e.Authorization = `Bearer ${n}`), Object.values(r).forEach((t) => {
87
+ if (t instanceof Blob && e["Content-Type"] !== "multipart/form-data") {
88
+ e["Content-Type"] = "multipart/form-data";
89
+ return;
90
+ }
91
+ });
92
+ let s = new FormData();
93
+ Object.entries(r).forEach(([e, t]) => {
94
+ s?.append(e, t);
95
+ });
96
+ let c = {
97
+ method: a,
98
+ headers: e,
99
+ credentials: i
100
+ };
101
+ (!a || a.toLowerCase() !== "get") && (c.body = s);
102
+ let l = await fetch(t, c), u = "";
103
+ try {
104
+ u = await l.json();
105
+ } catch {}
106
+ o = {
107
+ status: l.status,
108
+ data: u
109
+ };
110
+ } catch (e) {
111
+ console.error(e);
112
+ }
113
+ return { response: o };
114
+ }
115
+ };
116
+ //#endregion
117
+ export { e as default };
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@plitzi/sdk-interactions",
3
+ "version": "0.30.19",
4
+ "license": "AGPL-3.0",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs"
12
+ },
13
+ "./InteractionsContext": {
14
+ "types": "./dist/InteractionsContext.d.ts",
15
+ "import": "./dist/InteractionsContext.mjs"
16
+ },
17
+ "./InteractionsContextProvider": {
18
+ "types": "./dist/InteractionsContextProvider.d.ts",
19
+ "import": "./dist/InteractionsContextProvider.mjs"
20
+ },
21
+ "./InteractionsHelper": {
22
+ "types": "./dist/InteractionsHelper.d.ts",
23
+ "import": "./dist/InteractionsHelper.mjs"
24
+ },
25
+ "./InteractionsManager": {
26
+ "types": "./dist/InteractionsManager.d.ts",
27
+ "import": "./dist/InteractionsManager.mjs"
28
+ },
29
+ "./hooks/useInteractions": {
30
+ "types": "./dist/hooks/useInteractions.d.ts",
31
+ "import": "./dist/hooks/useInteractions.mjs"
32
+ },
33
+ "./index": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.mjs"
36
+ },
37
+ "./sources": {
38
+ "types": "./dist/sources/index.d.ts",
39
+ "import": "./dist/sources/index.mjs"
40
+ },
41
+ "./sources/AuthSource": {
42
+ "types": "./dist/sources/AuthSource/index.d.ts",
43
+ "import": "./dist/sources/AuthSource/index.mjs"
44
+ },
45
+ "./sources/AuthSource/AuthInteractions": {
46
+ "types": "./dist/sources/AuthSource/AuthInteractions.d.ts",
47
+ "import": "./dist/sources/AuthSource/AuthInteractions.mjs"
48
+ },
49
+ "./sources/AuthSource/index": {
50
+ "types": "./dist/sources/AuthSource/index.d.ts",
51
+ "import": "./dist/sources/AuthSource/index.mjs"
52
+ },
53
+ "./sources/index": {
54
+ "types": "./dist/sources/index.d.ts",
55
+ "import": "./dist/sources/index.mjs"
56
+ },
57
+ "./utility": {
58
+ "types": "./dist/utility/index.d.ts",
59
+ "import": "./dist/utility/index.mjs"
60
+ },
61
+ "./utility/delayTime": {
62
+ "types": "./dist/utility/delayTime.d.ts",
63
+ "import": "./dist/utility/delayTime.mjs"
64
+ },
65
+ "./utility/index": {
66
+ "types": "./dist/utility/index.d.ts",
67
+ "import": "./dist/utility/index.mjs"
68
+ },
69
+ "./utility/twigTemplate": {
70
+ "types": "./dist/utility/twigTemplate.d.ts",
71
+ "import": "./dist/utility/twigTemplate.mjs"
72
+ },
73
+ "./utility/webHook": {
74
+ "types": "./dist/utility/webHook.d.ts",
75
+ "import": "./dist/utility/webHook.mjs"
76
+ }
77
+ },
78
+ "scripts": {
79
+ "lint": "eslint ./src",
80
+ "typecheck": "tsc -p tsconfig.app.json --noEmit",
81
+ "build:dev": "vite build --mode development --minify false && node ../sdk-shared/scripts/generate-exports.mjs",
82
+ "build:dev-watch": "vite build --mode development --watch --minify false",
83
+ "build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
84
+ },
85
+ "type": "module",
86
+ "sideEffects": false,
87
+ "devDependencies": {
88
+ "eslint": "^9.39.4",
89
+ "typescript": "^6.0.3",
90
+ "vite": "^8.0.10"
91
+ },
92
+ "dependencies": {
93
+ "@plitzi/plitzi-ui": "^1.6.2",
94
+ "@plitzi/sdk-auth": "0.30.19",
95
+ "@plitzi/sdk-dev-tools": "0.30.19",
96
+ "@plitzi/sdk-event-bridge": "0.30.19",
97
+ "@plitzi/sdk-shared": "0.30.19"
98
+ }
99
+ }