@kizenapps/engine 0.0.1-b1f3597

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.
Files changed (74) hide show
  1. package/LICENSE.md +674 -0
  2. package/README.md +160 -0
  3. package/dist/ThirdPartyScript-DdrF7zh7.d.ts +459 -0
  4. package/dist/automation-C8hsM_Rc.d.ts +36 -0
  5. package/dist/chunk-2MW4AGSN.js +2415 -0
  6. package/dist/chunk-2MW4AGSN.js.map +1 -0
  7. package/dist/chunk-3LDUYA57.js +61 -0
  8. package/dist/chunk-3LDUYA57.js.map +1 -0
  9. package/dist/chunk-5WRI5ZAA.js +29 -0
  10. package/dist/chunk-5WRI5ZAA.js.map +1 -0
  11. package/dist/chunk-727AYMPR.js +120 -0
  12. package/dist/chunk-727AYMPR.js.map +1 -0
  13. package/dist/chunk-GGGXYD3K.js +40 -0
  14. package/dist/chunk-GGGXYD3K.js.map +1 -0
  15. package/dist/chunk-LGJYUPYZ.js +3 -0
  16. package/dist/chunk-LGJYUPYZ.js.map +1 -0
  17. package/dist/chunk-NXLAROEM.js +730 -0
  18. package/dist/chunk-NXLAROEM.js.map +1 -0
  19. package/dist/chunk-P7GQBCEH.js +172 -0
  20. package/dist/chunk-P7GQBCEH.js.map +1 -0
  21. package/dist/chunk-UOTNQL56.js +46 -0
  22. package/dist/chunk-UOTNQL56.js.map +1 -0
  23. package/dist/chunk-VYBEGZLN.js +319 -0
  24. package/dist/chunk-VYBEGZLN.js.map +1 -0
  25. package/dist/chunk-XKKZPZMB.js +121 -0
  26. package/dist/chunk-XKKZPZMB.js.map +1 -0
  27. package/dist/communication.d.ts +13 -0
  28. package/dist/communication.js +6 -0
  29. package/dist/communication.js.map +1 -0
  30. package/dist/contexts/base.d.ts +99 -0
  31. package/dist/contexts/base.js +7 -0
  32. package/dist/contexts/base.js.map +1 -0
  33. package/dist/contexts/floatingFrame.d.ts +18 -0
  34. package/dist/contexts/floatingFrame.js +8 -0
  35. package/dist/contexts/floatingFrame.js.map +1 -0
  36. package/dist/contexts/recordDetail.d.ts +32 -0
  37. package/dist/contexts/recordDetail.js +8 -0
  38. package/dist/contexts/recordDetail.js.map +1 -0
  39. package/dist/floatingFrames-BzaoL7cq.d.ts +8 -0
  40. package/dist/generic-RiEgdDAq.d.ts +19 -0
  41. package/dist/index.d.ts +19 -0
  42. package/dist/index.js +6 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/merge-translations.js +28 -0
  45. package/dist/react.d.ts +367 -0
  46. package/dist/react.js +2732 -0
  47. package/dist/react.js.map +1 -0
  48. package/dist/routeScript-kttY2YZh.d.ts +303 -0
  49. package/dist/translation.json +8 -0
  50. package/dist/types.d.ts +90 -0
  51. package/dist/types.js +3 -0
  52. package/dist/types.js.map +1 -0
  53. package/dist/util.d.ts +40 -0
  54. package/dist/util.js +87 -0
  55. package/dist/util.js.map +1 -0
  56. package/dist/vite.d.ts +11 -0
  57. package/dist/vite.js +19 -0
  58. package/dist/vite.js.map +1 -0
  59. package/dist/workers/calendarSource.worker.d.ts +2 -0
  60. package/dist/workers/calendarSource.worker.js +62 -0
  61. package/dist/workers/calendarSource.worker.js.map +1 -0
  62. package/dist/workers/expression.worker.d.ts +2 -0
  63. package/dist/workers/expression.worker.js +35 -0
  64. package/dist/workers/expression.worker.js.map +1 -0
  65. package/dist/workers/floatingFrame.worker.d.ts +2 -0
  66. package/dist/workers/floatingFrame.worker.js +57 -0
  67. package/dist/workers/floatingFrame.worker.js.map +1 -0
  68. package/dist/workers/generic.worker.d.ts +2 -0
  69. package/dist/workers/generic.worker.js +57 -0
  70. package/dist/workers/generic.worker.js.map +1 -0
  71. package/dist/workers/recordDetail.worker.d.ts +2 -0
  72. package/dist/workers/recordDetail.worker.js +59 -0
  73. package/dist/workers/recordDetail.worker.js.map +1 -0
  74. package/package.json +93 -0
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ ## Kizen Plugin Engine
2
+
3
+ The core plugin engine for the Kizen developer platform for running plugin apps in web workers.
4
+
5
+ ### Installation
6
+
7
+ ```
8
+ yarn add @kizenapps/plugin-engine
9
+ ```
10
+
11
+ ### Usage
12
+
13
+ Your app needs to be wrapped in the `PluginEngineProvider`. This provider gives the internal components access to the worker runner, network requests, and other consumer-specific features, and adapts your application's common UI components like modals and toasts to a common API that plugins can use.
14
+
15
+ #### Context Provider
16
+
17
+ ```tsx
18
+ import { PluginEngineProvider } from '@kizenapps/plugin-engine/react';
19
+ import { useHistory } from 'react-router-dom';
20
+ import PluginContext from 'contexts/Plugins';
21
+
22
+ const AppProvider = ({ user, teamMember, business, clientObject }) => {
23
+ const history = useHistory();
24
+
25
+ const onNavigate = useCallback(
26
+ (path: string, args?: { replace?: boolean }) => {
27
+ if (args?.replace) {
28
+ history.replace(path);
29
+ } else {
30
+ history.push(path);
31
+ }
32
+ },
33
+ [history],
34
+ );
35
+
36
+ const [showToast, , clearToasts] = useToast();
37
+
38
+ const [integrationModalProps, , integrationModalTriggerProps] = useModal({});
39
+
40
+ const { onConfirm, show, onHide } = integrationModalProps;
41
+ const { show: showPrompt, showing } = integrationModalTriggerProps;
42
+
43
+ return (
44
+ <PluginEngineProvider
45
+ user={user}
46
+ teamMember={teamMember}
47
+ business={business}
48
+ clientObject={clientObject}
49
+ onNavigate={onNavigate}
50
+ monitoringExceptionHelper={onError}
51
+ showToast={showToast}
52
+ clearToasts={clearToasts}
53
+ modal={{
54
+ showing,
55
+ show,
56
+ onConfirm,
57
+ onHide,
58
+ showPrompt,
59
+ }}
60
+ performRequest={performKizenRequest}
61
+ appPath={import.meta.env.VITE_API_BASE_PATH}
62
+ bootstrapPlugins={pluginApps}
63
+ performFileUpload={FileService.upload}
64
+ getPendingCacheCount={getPendingCacheCount}
65
+ invalidateCache={invalidateCache}
66
+ >
67
+ {({
68
+ handleCreateRecordComplete,
69
+ handleCreateRelatedRecordComplete,
70
+ showCreateRecordModal,
71
+ showCreateRelatedRecordModal,
72
+ createRecordModalObjectId,
73
+ createRelatedRecordModalObjectId,
74
+ createRelatedRecordModalRelatedEntityId,
75
+ showLoadingIndicator,
76
+ hasFinishedBootstrapping,
77
+ derivedModalState,
78
+ showPluginModal,
79
+ pluginApiName,
80
+ ...rest
81
+ }) => {
82
+ return (
83
+ <PluginContext.Provider
84
+ value={{
85
+ isFetched: hasFetchedBootstrap,
86
+ isLoading,
87
+ pluginNames,
88
+ floatingFrames: isLoading ? [] : floatingFrames,
89
+ routablePages,
90
+ dataAdornments,
91
+ calendarSources,
92
+ refetch,
93
+ fullRefetch,
94
+ installedPluginAPINamesToIds,
95
+ plugins: data,
96
+ toolbarItems,
97
+ toolbarItemsByFullId,
98
+ routeScripts,
99
+ automationSteps: isLoading ? [] : automationSteps,
100
+ objectSettingsMenuItems,
101
+ userConfigsByApiName,
102
+ featureFlags,
103
+ refetchFeatureFlags,
104
+ featureFlagsLoading: !hasCalculatedFeatureFlags && !hasFinishedBootstrapping,
105
+ businessPluginAppsByApiName,
106
+ ...rest,
107
+ }}
108
+ >
109
+ {showLoadingIndicator ? <StyledLoader loading /> : null}
110
+ {children}
111
+ {showPluginModal ? (
112
+ <PluginModal modalState={derivedModalState} pluginApiName={pluginApiName} />
113
+ ) : null}
114
+ {showCreateRecordModal ? (
115
+ <Suspense fallback={null}>
116
+ <CreateRecordModal
117
+ objectId={createRecordModalObjectId}
118
+ onComplete={handleCreateRecordComplete}
119
+ />
120
+ </Suspense>
121
+ ) : null}
122
+ {showCreateRelatedRecordModal ? (
123
+ <Suspense fallback={null}>
124
+ <CreateRelatedRecordModal
125
+ objectId={createRelatedRecordModalObjectId}
126
+ relatedEntityId={createRelatedRecordModalRelatedEntityId}
127
+ onComplete={handleCreateRelatedRecordComplete}
128
+ />
129
+ </Suspense>
130
+ ) : null}
131
+ </PluginContext.Provider>
132
+ );
133
+ }}
134
+ </PluginEngineProvider>
135
+ );
136
+ };
137
+ ```
138
+
139
+ #### Running Scripts
140
+
141
+ ```tsx
142
+ import { useGenericPluginCustomScript } from '@kizenapps/plugin-engine/react';
143
+ import { useToast } from 'components/ToastProvider';
144
+
145
+ const ScriptButton = ({ pluginScript }: { pluginScript: string }) => {
146
+ const [showToast] = useToast();
147
+
148
+ const [executeInline, { pending: inlinePending }] = useGenericPluginCustomScript({
149
+ onError: (e) => {
150
+ showToast({
151
+ message: `Script could not be executed: ${e?.message}`,
152
+ variant: 'failure',
153
+ });
154
+ },
155
+ plugin: item,
156
+ });
157
+
158
+ return <button onClick={() => executeInline(pluginScript)} disabled={inlinePending} />;
159
+ };
160
+ ```
@@ -0,0 +1,459 @@
1
+ import { RefObject } from 'react';
2
+
3
+ interface PartialUser {
4
+ id: string;
5
+ crm_client_id: string;
6
+ }
7
+ interface PartialTeamMember {
8
+ id: string;
9
+ full_name: string;
10
+ first_name: string;
11
+ last_name: string;
12
+ email: string;
13
+ phone: string;
14
+ created: string;
15
+ }
16
+ type Profile = PartialTeamMember & PartialUser;
17
+ interface CurrentUser {
18
+ profile: Profile;
19
+ }
20
+ interface PartialBusiness {
21
+ id: string;
22
+ }
23
+ interface PartialRelatedObject {
24
+ field_id: string;
25
+ related_object: string;
26
+ }
27
+ interface PartialCustomObject {
28
+ object_type: 'pipeline' | 'standard';
29
+ fetch_url: string;
30
+ related_objects?: PartialRelatedObject[];
31
+ }
32
+ interface PartialEntity {
33
+ fields?: Record<string, {
34
+ id: string;
35
+ value: {
36
+ id?: string;
37
+ }[];
38
+ }>;
39
+ }
40
+ interface PartialClientObject {
41
+ id: string;
42
+ objectName: string;
43
+ }
44
+ interface SelectOption {
45
+ label: string;
46
+ value: string;
47
+ }
48
+ interface PartialLocation {
49
+ host: string;
50
+ hash: string;
51
+ href: string;
52
+ origin: string;
53
+ pathname: string;
54
+ search: string;
55
+ port: string;
56
+ protocol: string;
57
+ }
58
+ type ErrorHandler = (error: unknown) => void;
59
+ type ReleaseBlockingScriptHandler = (executionPlugin?: unknown) => void;
60
+ type JSONPrimitive = string | number | boolean | null;
61
+ type JSONValue = JSONPrimitive | JSONArray | JSONObject;
62
+ type JSONArray = JSONValue[];
63
+ interface JSONObject {
64
+ [key: string]: JSONValue | undefined;
65
+ }
66
+ type UnknownJSON = JSONObject;
67
+ interface AppPlugin {
68
+ business_config: unknown;
69
+ name: string;
70
+ employee_config: unknown;
71
+ }
72
+ type AppPlugins = Record<string, AppPlugin>;
73
+ type MaybeMessageError = {
74
+ message?: string;
75
+ } | undefined;
76
+ type EmployeeConfig<T = unknown> = Record<string, T>;
77
+
78
+ type PromiseResolve = (value: unknown) => void;
79
+ type PromiseReject = (reason?: unknown) => void;
80
+ interface PromiseState {
81
+ resolve: PromiseResolve;
82
+ reject: PromiseReject;
83
+ }
84
+ type PromiseMap = Map<string, PromiseState>;
85
+
86
+ declare class WorkerPromise {
87
+ private promises;
88
+ private isDebug;
89
+ constructor({ isDebug }: {
90
+ isDebug?: boolean;
91
+ });
92
+ private delete;
93
+ private get;
94
+ private set;
95
+ private id;
96
+ register(resolve: PromiseResolve, reject: PromiseReject): string;
97
+ resolve(id: string, data?: unknown): void;
98
+ reject(id: string, reason?: unknown): void;
99
+ }
100
+
101
+ interface ButtonConfig {
102
+ label: string;
103
+ variant?: 'text' | 'standard';
104
+ color?: string;
105
+ }
106
+ interface ModalDescription {
107
+ type: 'description';
108
+ content: string;
109
+ widthPercent: 50 | 100;
110
+ when?: string | undefined;
111
+ key: string;
112
+ }
113
+ interface ModalTextInput {
114
+ type: 'text';
115
+ label: string;
116
+ placeholder: string;
117
+ widthPercent: 50 | 100;
118
+ id: string;
119
+ defaultValue?: string;
120
+ when?: string | undefined;
121
+ key: string;
122
+ }
123
+ interface ModalSpacer {
124
+ type: 'spacer';
125
+ height: number;
126
+ widthPercent: 50 | 100;
127
+ when?: string | undefined;
128
+ key: string;
129
+ }
130
+ interface ModalDropdown {
131
+ type: 'dropdown';
132
+ label: string;
133
+ placeholder: string;
134
+ widthPercent: 50 | 100;
135
+ id: string;
136
+ multiselect?: boolean;
137
+ options: SelectOption[];
138
+ defaultValue?: string;
139
+ optionMapper?: UnknownFunction;
140
+ getFetchUrl?: UnknownFunction;
141
+ getHeaders?: UnknownFunction;
142
+ getBody?: UnknownFunction;
143
+ args?: UnknownJSON;
144
+ when?: string | undefined;
145
+ key: string;
146
+ }
147
+ interface ModalContainer {
148
+ type: 'container';
149
+ fields: ModalBlock[];
150
+ when?: string | undefined;
151
+ key: string;
152
+ }
153
+ type ModalBlock = ModalDescription | ModalTextInput | ModalSpacer | ModalDropdown | ModalContainer;
154
+ interface ModalConfig {
155
+ title?: string;
156
+ confirmButton?: ButtonConfig;
157
+ cancelButton?: ButtonConfig;
158
+ content?: ModalBlock[];
159
+ dynamic?: boolean;
160
+ pluginApiName?: string;
161
+ }
162
+ interface DynamicPromptConfig {
163
+ title?: string;
164
+ confirmButton?: ButtonConfig;
165
+ cancelButton?: ButtonConfig;
166
+ content?: ModalBlock[];
167
+ registerUtils?: Record<string, (...args: unknown[]) => unknown>;
168
+ }
169
+ type PromptState = Record<string, unknown>;
170
+ type DynamicPromptFn = (config: DynamicPromptConfig) => Promise<{
171
+ values: Record<string, ValueStore>;
172
+ }>;
173
+ type CurriedDynamicPromptFn = (instance: Instance, promises: WorkerPromise) => DynamicPromptFn;
174
+ type UnknownFunction = (...args: unknown[]) => unknown;
175
+ type SetupAssistantField = ModalBlock | AssistantField;
176
+ type MatchSetupAssistantField = AssistantField & {
177
+ match_hint?: string;
178
+ };
179
+ interface SetupAssistantConfig {
180
+ fields?: SetupAssistantField[] | undefined;
181
+ actions?: AssistantConfigAction[] | undefined;
182
+ services?: ConfigService[] | undefined;
183
+ }
184
+ interface AssistantConfigAction {
185
+ api_name: string;
186
+ name: string;
187
+ hint_object_name?: string;
188
+ }
189
+ interface AssistantField {
190
+ key: string;
191
+ type: 'custom_object' | 'description' | 'container' | 'field' | 'text' | 'number' | 'select' | 'boolean';
192
+ columns?: number;
193
+ fields?: AssistantField[];
194
+ content?: string;
195
+ label?: string;
196
+ object_id?: string;
197
+ default?: string;
198
+ options?: SelectOption[];
199
+ allow_multiple?: boolean;
200
+ placeholder?: string;
201
+ when?: string;
202
+ getFetchUrl?: string;
203
+ typeahead?: boolean;
204
+ optionMapper?: string;
205
+ fetchMethod?: 'GET' | 'POST';
206
+ getHeaders?: string;
207
+ getBody?: string;
208
+ getContextUrl?: string;
209
+ autoSelect?: boolean;
210
+ required?: boolean;
211
+ tooltip?: string;
212
+ dependencies?: string[];
213
+ validation_pattern?: string;
214
+ match_hint?: string;
215
+ }
216
+ type BooleanCleanValue = boolean;
217
+ interface BooleanValueStore {
218
+ value: boolean;
219
+ }
220
+ interface CustomObjectCleanValue {
221
+ objectId: string;
222
+ objectName: string;
223
+ }
224
+ interface CustomObjectValueStore {
225
+ value?: {
226
+ id: string;
227
+ objectName: string;
228
+ };
229
+ }
230
+ interface FieldCleanValueSingle {
231
+ fieldId: string;
232
+ fieldName: string;
233
+ objectId?: string;
234
+ objectName?: string;
235
+ }
236
+ type FieldCleanValue = FieldCleanValueSingle | FieldCleanValueSingle[];
237
+ interface FieldValueStore {
238
+ value: SelectOption | SelectOption[];
239
+ associatedObject?: {
240
+ id: string;
241
+ name: string;
242
+ };
243
+ }
244
+ type NumberCleanValue = number;
245
+ interface NumberValueStore {
246
+ value: number | string;
247
+ }
248
+ type SelectCleanValue = SelectOption | SelectOption[];
249
+ interface SelectValueStore {
250
+ value: SelectOption | SelectOption[];
251
+ }
252
+ type TextCleanValue = string;
253
+ interface TextValueStore {
254
+ value: string;
255
+ }
256
+ type ValueStore = BooleanValueStore | CustomObjectValueStore | FieldValueStore | NumberValueStore | SelectValueStore | TextValueStore;
257
+ type CleanValueStoreType = BooleanCleanValue | CustomObjectCleanValue | FieldCleanValue | NumberCleanValue | SelectCleanValue | TextCleanValue;
258
+ type CleanValueStore = Record<string, CleanValueStoreType>;
259
+ type OnShowModalFn = (config: ModalConfig, cb: () => void) => void;
260
+ type OnShowCreateRecordModalFn = (objectId: string, cb: (result: UnknownJSON) => void) => void;
261
+ type OnShowCreateRelatedRecordModalFn = (objectId: string, relatedEntityId: string, cb: (result: UnknownJSON) => void) => void;
262
+ type ModalQueue = {
263
+ config: ModalConfig;
264
+ cb: (...args: unknown[]) => void;
265
+ }[];
266
+ type CreateRecordModalQueue = {
267
+ objectId: string;
268
+ cb: (result: UnknownJSON) => void;
269
+ }[];
270
+ type CreateRelatedRecordModalQueue = {
271
+ objectId: string;
272
+ relatedEntityId: string;
273
+ cb: (result: UnknownJSON) => void;
274
+ }[];
275
+ type ModalCancelEventSource = 'button' | 'close';
276
+ interface ConfigService {
277
+ api_name: string;
278
+ prerequisite: boolean;
279
+ required: boolean;
280
+ }
281
+
282
+ type KizenRequestFnHandler<T = unknown> = (url: string, payload: unknown, options?: unknown) => Promise<T>;
283
+ type KizenRequestFn = <T>(method: string) => KizenRequestFnHandler<T>;
284
+ type CurriedKizenRequestFn = (instance: Instance, promises: WorkerPromise) => KizenRequestFn;
285
+ interface RequestOptions {
286
+ headers?: Record<string, string>;
287
+ returnErrors?: boolean;
288
+ credentials?: 'include';
289
+ }
290
+ type GetOptions = RequestOptions & {
291
+ ignoreCache?: boolean;
292
+ };
293
+ interface GetReturnValue {
294
+ data: UnknownJSON;
295
+ }
296
+ interface PostReturnValue {
297
+ data: UnknownJSON;
298
+ }
299
+ interface PatchReturnValue {
300
+ data: UnknownJSON;
301
+ }
302
+ interface PutReturnValue {
303
+ data: UnknownJSON;
304
+ }
305
+ interface DeleteReturnValue {
306
+ data: UnknownJSON;
307
+ }
308
+ type RequestWithErrorsResponse = [UnknownJSON | null, UnknownJSON | null];
309
+ type OnNetworkErrorFn = (error: unknown) => void;
310
+
311
+ declare const ACTIONS: {
312
+ QUERY_REQUEST: string;
313
+ UI_OUTPUT: string;
314
+ IFRAME_OUTPUT: string;
315
+ POSTFORMDATA_REQUEST: string;
316
+ SETSTATE: string;
317
+ DONE: string;
318
+ RUN: string;
319
+ OPEN_WINDOW: string;
320
+ COMMUNICATE: string;
321
+ HIDE: string;
322
+ SHOW: string;
323
+ EXPAND: string;
324
+ COLLAPSE: string;
325
+ HIDE_HEADER: string;
326
+ SHOW_HEADER: string;
327
+ OPEN_CREATE_RECORD_MODAL_REQUEST: string;
328
+ OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST: string;
329
+ SHOW_TOAST: string;
330
+ CLEAR_TOASTS: string;
331
+ REFRESH_TIMELINE: string;
332
+ REFRESH_ENTITY: string;
333
+ UPLOADFILE_REQUEST: string;
334
+ UPDATE_SESSION_DATA: string;
335
+ INSTALL_THIRD_PARTY_SCRIPT_REQUEST: string;
336
+ PROMPT_REQUEST: string;
337
+ DYNAMIC_PROMPT_REQUEST: string;
338
+ RELEASE_BLOCKING_SCRIPT: string;
339
+ AUTHORIZE: string;
340
+ COPY_TO_CLIPBOARD: string;
341
+ };
342
+ declare enum INDICATOR_TYPE {
343
+ NONE = "none",
344
+ BLOCK = "block",
345
+ BUTTON = "button",
346
+ SPINNER = "spinner"
347
+ }
348
+ declare const IFRAME_PREFIX = "kzn-integration-frame";
349
+
350
+ interface ErrorResponse {
351
+ status: number;
352
+ statusText: string;
353
+ body?: unknown;
354
+ }
355
+ interface DataCacheEntry<T> {
356
+ ts: number;
357
+ data: T;
358
+ }
359
+ type DataCache<T> = Map<string, DataCacheEntry<T>>;
360
+ interface BaseAPI {
361
+ get: KizenRequestFnHandler<GetReturnValue>;
362
+ post: KizenRequestFnHandler<PostReturnValue>;
363
+ put: KizenRequestFnHandler<PutReturnValue>;
364
+ delete: KizenRequestFnHandler<DeleteReturnValue>;
365
+ patch: KizenRequestFnHandler<PatchReturnValue>;
366
+ }
367
+ type PostFormDataPayload = Record<string, unknown>;
368
+ type PostFormDataFn = (url: string, data: PostFormDataPayload, createNewTab?: boolean) => Promise<unknown>;
369
+ type CurriedPostFormDataFn = (instance: Instance, promises: WorkerPromise) => PostFormDataFn;
370
+ interface StateChangePayload {
371
+ indicator?: INDICATOR_TYPE;
372
+ hidden?: boolean;
373
+ minimized?: boolean;
374
+ triggerHidden?: boolean;
375
+ hideHeader?: boolean;
376
+ createObjectRecordId?: string;
377
+ }
378
+ type Instance = Window & typeof globalThis;
379
+ interface UploadFileData {
380
+ file: string;
381
+ isPublic?: boolean;
382
+ fileName?: string;
383
+ }
384
+ type UploadFileFn = (data: UploadFileData) => Promise<unknown>;
385
+ type CurriedUploadFileFn = (instance: Instance, promises: WorkerPromise) => UploadFileFn;
386
+ type InternalSessionData = Record<string, unknown>;
387
+ type SetInternalSessionDataFn = (pluginId: string, state: InternalSessionData) => void;
388
+ type InstallThirdPartyScriptFn = (url: string, args: Record<string, unknown>) => Promise<{
389
+ url: string;
390
+ }>;
391
+ type CurriedInstallThirdPartyScriptFn = (instance: Instance, promises: WorkerPromise) => InstallThirdPartyScriptFn;
392
+ type PromptFn = (config: ModalConfig) => Promise<unknown>;
393
+ type CurriedPromptFn = (instance: Instance, promises: WorkerPromise) => PromptFn;
394
+ type RefreshEntityFn = (entityId: string) => Promise<unknown>;
395
+ type CurriedRefreshEntityFn = (instance: Instance, promises: WorkerPromise) => RefreshEntityFn;
396
+ type OpenCreateRecordFn = (objectId: string) => Promise<unknown>;
397
+ type CurriedOpenCreateRecordFn = (instance: Instance, promises: WorkerPromise) => OpenCreateRecordFn;
398
+ type OpenCreateRelatedRecordFn = (objectId: string, relatedEntityId: string) => Promise<unknown>;
399
+ type CurriedOpenCreateRelatedRecordFn = (instance: Instance, promises: WorkerPromise) => OpenCreateRelatedRecordFn;
400
+ interface WorkerContextArgs {
401
+ user: PartialUser;
402
+ teamMember: PartialTeamMember;
403
+ business: PartialBusiness;
404
+ clientObject?: PartialClientObject | undefined;
405
+ appPath: string;
406
+ onStateChange?: (options: StateChangePayload) => void;
407
+ scriptUIRef?: RefObject<HTMLDivElement | null>;
408
+ isDebug?: boolean;
409
+ scriptBody: string;
410
+ functionBody: string;
411
+ instance: Instance;
412
+ kizenRequest: KizenRequestFn;
413
+ postFormData: PostFormDataFn;
414
+ onError?: ErrorHandler;
415
+ onReleaseBlockingScript?: ReleaseBlockingScriptHandler;
416
+ args?: string;
417
+ uploadFile: UploadFileFn;
418
+ sessionData?: InternalSessionData;
419
+ pluginComponentId?: string;
420
+ installThirdPartyScript: InstallThirdPartyScriptFn;
421
+ prompt: PromptFn;
422
+ dynamicPrompt: DynamicPromptFn;
423
+ refreshEntity: RefreshEntityFn;
424
+ openCreateRecord: OpenCreateRecordFn;
425
+ openCreateRelatedRecord: OpenCreateRelatedRecordFn;
426
+ pluginApiName: string;
427
+ location: PartialLocation;
428
+ }
429
+ type KizenConfig = Record<string, unknown>;
430
+ interface KnownArgs {
431
+ __kizen_clean_config?: KizenConfig;
432
+ __kizen_user_config?: {
433
+ __kizen_clean_config?: KizenConfig;
434
+ };
435
+ pluginId?: string;
436
+ }
437
+ interface UserConfig {
438
+ config?: Record<string, UnknownJSON>;
439
+ }
440
+ type Args = KnownArgs & Record<string, unknown>;
441
+ interface ShowToastOptions {
442
+ variant?: 'alert' | 'failure' | 'success';
443
+ autohide?: boolean;
444
+ }
445
+
446
+ declare const ALLOWED_INTEGRATIONS: {
447
+ readonly FRESHWORKS: "freshworks";
448
+ readonly INTERCOM: "intercom";
449
+ };
450
+ declare class ThirdPartyScript {
451
+ private instance;
452
+ private scriptUrl;
453
+ private integration;
454
+ constructor(instance: Instance, scriptUrl: string);
455
+ get type(): (typeof ALLOWED_INTEGRATIONS)[keyof typeof ALLOWED_INTEGRATIONS];
456
+ call(...params: unknown[]): void;
457
+ }
458
+
459
+ export { type ErrorHandler as $, type Args as A, type BaseAPI as B, type CurrentUser as C, type DataCache as D, type CurriedInstallThirdPartyScriptFn as E, type CurriedKizenRequestFn as F, type GetOptions as G, type CurriedOpenCreateRecordFn as H, type Instance as I, type CurriedOpenCreateRelatedRecordFn as J, type CurriedPostFormDataFn as K, type CurriedPromptFn as L, type ModalConfig as M, type CurriedRefreshEntityFn as N, type CurriedUploadFileFn as O, type PartialEntity as P, type CustomObjectCleanValue as Q, type RequestWithErrorsResponse as R, type StateChangePayload as S, ThirdPartyScript as T, type UnknownJSON as U, type CustomObjectValueStore as V, type WorkerContextArgs as W, type DataCacheEntry as X, type DeleteReturnValue as Y, type DynamicPromptFn as Z, type EmployeeConfig as _, type PartialCustomObject as a, type ErrorResponse as a0, type FieldCleanValue as a1, type FieldValueStore as a2, type GetReturnValue as a3, type InstallThirdPartyScriptFn as a4, type JSONArray as a5, type JSONObject as a6, type JSONPrimitive as a7, type JSONValue as a8, type KizenConfig as a9, type PromptFn as aA, type PutReturnValue as aB, type RefreshEntityFn as aC, type ReleaseBlockingScriptHandler as aD, type SelectCleanValue as aE, type SelectValueStore as aF, type SetInternalSessionDataFn as aG, type SetupAssistantConfig as aH, type SetupAssistantField as aI, type TextValueStore as aJ, type UnknownFunction as aK, type UploadFileData as aL, type UploadFileFn as aM, type UserConfig as aN, type ValueStore as aO, ACTIONS as aP, ALLOWED_INTEGRATIONS as aQ, IFRAME_PREFIX as aR, INDICATOR_TYPE as aS, type KizenRequestFn as aa, type KizenRequestFnHandler as ab, type KnownArgs as ac, type MatchSetupAssistantField as ad, type MaybeMessageError as ae, type ModalBlock as af, type ModalCancelEventSource as ag, type ModalContainer as ah, type ModalQueue as ai, type NumberCleanValue as aj, type NumberValueStore as ak, type OnNetworkErrorFn as al, type OnShowCreateRecordModalFn as am, type OnShowCreateRelatedRecordModalFn as an, type OnShowModalFn as ao, type OpenCreateRecordFn as ap, type OpenCreateRelatedRecordFn as aq, type PartialRelatedObject as ar, type PatchReturnValue as as, type PostFormDataPayload as at, type PostReturnValue as au, type Profile as av, type PromiseMap as aw, type PromiseReject as ax, type PromiseResolve as ay, type PromiseState as az, type PartialUser as b, type PartialTeamMember as c, type PartialBusiness as d, type PartialClientObject as e, type PostFormDataFn as f, type PromptState as g, type InternalSessionData as h, type PartialLocation as i, type RequestOptions as j, type ShowToastOptions as k, type DynamicPromptConfig as l, type SelectOption as m, type AppPlugin as n, type AppPlugins as o, type AssistantConfigAction as p, type AssistantField as q, type BooleanCleanValue as r, type BooleanValueStore as s, type ButtonConfig as t, type CleanValueStore as u, type CleanValueStoreType as v, type ConfigService as w, type CreateRecordModalQueue as x, type CreateRelatedRecordModalQueue as y, type CurriedDynamicPromptFn as z };
@@ -0,0 +1,36 @@
1
+ import { a as CommonPluginDefinition } from './routeScript-kttY2YZh.js';
2
+
3
+ interface DataAdornmentConfig extends CommonPluginDefinition {
4
+ id?: string;
5
+ field_type: 'phonenumber' | 'date' | 'datetime';
6
+ script: string;
7
+ config: {
8
+ icon: string;
9
+ color: string;
10
+ tooltip: string;
11
+ customIcon?: string;
12
+ };
13
+ when?: string;
14
+ plugin_name?: string;
15
+ }
16
+
17
+ interface ToolbarItemConfig extends CommonPluginDefinition {
18
+ api_name: string;
19
+ color?: string;
20
+ icon?: string;
21
+ label: string;
22
+ script: string;
23
+ when?: string;
24
+ }
25
+
26
+ interface AutomationStepConfig<T = unknown> {
27
+ name: string;
28
+ overallDescription: string;
29
+ actions: Record<string, T>;
30
+ thumbnail?: string;
31
+ when?: string;
32
+ action_step_api_name?: string;
33
+ plugin_api_name?: string;
34
+ }
35
+
36
+ export type { AutomationStepConfig as A, DataAdornmentConfig as D, ToolbarItemConfig as T };