@novu/framework 0.24.3-alpha.8 → 2.0.0-canary.0
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 +23 -34
- package/dist/express.d.ts +2 -1
- package/dist/express.js +17 -15
- package/dist/h3.d.ts +2 -1
- package/dist/h3.js +18 -15
- package/dist/{handler-mYQx1pDV.d.ts → handler-Mor_4K8F.d.ts} +290 -122
- package/dist/index.d.ts +248 -5
- package/dist/index.js +36 -19
- package/dist/next.d.ts +10 -3
- package/dist/next.js +17 -15
- package/dist/nuxt.d.ts +2 -1
- package/dist/nuxt.js +18 -15
- package/dist/remix.d.ts +2 -1
- package/dist/remix.js +16 -14
- package/dist/sveltekit.d.ts +2 -1
- package/dist/sveltekit.js +16 -14
- package/package.json +41 -5
|
@@ -1,34 +1,6 @@
|
|
|
1
1
|
import { JSONSchema, FromSchema as FromSchema$1 } from 'json-schema-to-ts';
|
|
2
2
|
import * as z from 'zod';
|
|
3
|
-
|
|
4
|
-
declare enum HttpHeaderKeysEnum {
|
|
5
|
-
SIGNATURE = "x-novu-signature",
|
|
6
|
-
ANONYMOUS = "x-novu-anonymous",
|
|
7
|
-
EXECUTION_DURATION = "x-novu-execution-duration",
|
|
8
|
-
SDK_VERSION = "x-novu-sdk",
|
|
9
|
-
FRAMEWORK = "x-novu-framework",
|
|
10
|
-
USER_AGENT = "user-agent",
|
|
11
|
-
CONTENT_TYPE = "content-type",
|
|
12
|
-
AUTHORIZATION = "authorization",
|
|
13
|
-
ACCESS_CONTROL_ALLOW_ORIGIN = "access-control-allow-origin",
|
|
14
|
-
ACCESS_CONTROL_ALLOW_METHODS = "access-control-allow-methods",
|
|
15
|
-
ACCESS_CONTROL_ALLOW_HEADERS = "access-control-allow-headers",
|
|
16
|
-
ACCESS_CONTROL_ALLOW_CREDENTIALS = "access-control-allow-credentials",
|
|
17
|
-
ACCESS_CONTROL_MAX_AGE = "access-control-max-age"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare enum ChannelStepEnum {
|
|
21
|
-
EMAIL = "email",
|
|
22
|
-
SMS = "sms",
|
|
23
|
-
PUSH = "push",
|
|
24
|
-
CHAT = "chat",
|
|
25
|
-
IN_APP = "in_app"
|
|
26
|
-
}
|
|
27
|
-
declare enum ActionStepEnum {
|
|
28
|
-
DIGEST = "digest",
|
|
29
|
-
DELAY = "delay",
|
|
30
|
-
CUSTOM = "custom"
|
|
31
|
-
}
|
|
3
|
+
import { TriggerEventStatusEnum, ITriggerPayload, TriggerRecipientSubscriber, ITenantDefine, TriggerRecipientsPayload } from '@novu/shared';
|
|
32
4
|
|
|
33
5
|
type CodeResult = {
|
|
34
6
|
code: string;
|
|
@@ -36,26 +8,42 @@ type CodeResult = {
|
|
|
36
8
|
|
|
37
9
|
type ClientOptions = {
|
|
38
10
|
/**
|
|
39
|
-
*
|
|
11
|
+
* @deprecated use `secretKey` instead
|
|
12
|
+
*/
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify your Novu secret key, to secure the Bridge Endpoint, and Novu API communication.
|
|
40
16
|
* Novu communicates securely with your endpoint using a signed HMAC header,
|
|
41
17
|
* ensuring that only trusted requests from Novu are actioned by your Bridge API.
|
|
42
|
-
* The
|
|
18
|
+
* The secret key is used to sign the HMAC header.
|
|
43
19
|
*/
|
|
44
|
-
|
|
20
|
+
secretKey?: string;
|
|
45
21
|
/**
|
|
46
22
|
* Explicitly use HMAC signature verification.
|
|
47
23
|
* Setting this to `false` will enable Novu to communicate with your Bridge API
|
|
48
24
|
* without requiring a valid HMAC signature.
|
|
49
25
|
* This is useful for local development and testing.
|
|
50
26
|
*
|
|
51
|
-
*
|
|
52
|
-
* to ensure that only trusted requests from Novu are actioned by your Bridge API.
|
|
27
|
+
* In production you must specify an `secretKey` and set this to `true`.
|
|
53
28
|
*
|
|
54
29
|
* Defaults to true.
|
|
55
30
|
*/
|
|
56
31
|
strictAuthentication?: boolean;
|
|
57
32
|
};
|
|
58
33
|
|
|
34
|
+
declare enum ChannelStepEnum {
|
|
35
|
+
EMAIL = "email",
|
|
36
|
+
SMS = "sms",
|
|
37
|
+
PUSH = "push",
|
|
38
|
+
CHAT = "chat",
|
|
39
|
+
IN_APP = "in_app"
|
|
40
|
+
}
|
|
41
|
+
declare enum ActionStepEnum {
|
|
42
|
+
DIGEST = "digest",
|
|
43
|
+
DELAY = "delay",
|
|
44
|
+
CUSTOM = "custom"
|
|
45
|
+
}
|
|
46
|
+
|
|
59
47
|
type Schema = JSONSchema | z.ZodSchema;
|
|
60
48
|
type JsonSchema = JSONSchema;
|
|
61
49
|
type FromSchema<T extends Schema> = T extends JSONSchema ? FromSchema$1<T> : T extends z.ZodSchema ? z.infer<T> : never;
|
|
@@ -2657,31 +2645,6 @@ declare const channelStepSchemas: {
|
|
|
2657
2645
|
};
|
|
2658
2646
|
};
|
|
2659
2647
|
|
|
2660
|
-
type Providers<T_StepType extends keyof typeof providerSchemas, T_Input, T_Output> = {
|
|
2661
|
-
[K in keyof (typeof providerSchemas)[T_StepType]]: (step: {
|
|
2662
|
-
/**
|
|
2663
|
-
* The inputs for the step.
|
|
2664
|
-
*/
|
|
2665
|
-
inputs: T_Input;
|
|
2666
|
-
/**
|
|
2667
|
-
* The outputs of the step.
|
|
2668
|
-
*/
|
|
2669
|
-
outputs: T_Output;
|
|
2670
|
-
}) => Promise<FromSchema<(typeof providerSchemas)[T_StepType][K]['output']>>;
|
|
2671
|
-
};
|
|
2672
|
-
|
|
2673
|
-
/**
|
|
2674
|
-
* A type that represents either `A` or `B`. Shared properties retain their
|
|
2675
|
-
* types and unique properties are marked as optional.
|
|
2676
|
-
*/
|
|
2677
|
-
type Either<A, B> = Partial<A> & Partial<B> & (A | B);
|
|
2678
|
-
/**
|
|
2679
|
-
* A type that represents a value that may be a promise or a regular value.
|
|
2680
|
-
*/
|
|
2681
|
-
type Awaitable<T> = T | Promise<T>;
|
|
2682
|
-
|
|
2683
|
-
type Skip<T> = (inputs: T) => Awaitable<boolean>;
|
|
2684
|
-
|
|
2685
2648
|
declare const actionStepSchemas: {
|
|
2686
2649
|
delay: {
|
|
2687
2650
|
output: {
|
|
@@ -2788,9 +2751,48 @@ declare const actionStepSchemas: {
|
|
|
2788
2751
|
};
|
|
2789
2752
|
};
|
|
2790
2753
|
|
|
2754
|
+
type Providers<T_StepType extends keyof typeof providerSchemas, T_Control, T_Output> = {
|
|
2755
|
+
[K in keyof (typeof providerSchemas)[T_StepType]]: (step: {
|
|
2756
|
+
/**
|
|
2757
|
+
* The controls for the step.
|
|
2758
|
+
*
|
|
2759
|
+
* @deprecated Use `controls` instead
|
|
2760
|
+
*/
|
|
2761
|
+
inputs: T_Control;
|
|
2762
|
+
/**
|
|
2763
|
+
* The controls for the step.
|
|
2764
|
+
*/
|
|
2765
|
+
controls: T_Control;
|
|
2766
|
+
/**
|
|
2767
|
+
* The outputs of the step.
|
|
2768
|
+
*/
|
|
2769
|
+
outputs: T_Output;
|
|
2770
|
+
}) => Promise<FromSchema<(typeof providerSchemas)[T_StepType][K]['output']>>;
|
|
2771
|
+
};
|
|
2772
|
+
|
|
2773
|
+
/**
|
|
2774
|
+
* A type that represents either `A` or `B`. Shared properties retain their
|
|
2775
|
+
* types and unique properties are marked as optional.
|
|
2776
|
+
*/
|
|
2777
|
+
type Either<A, B> = Partial<A> & Partial<B> & (A | B);
|
|
2778
|
+
/**
|
|
2779
|
+
* A type that represents a value that may be a promise or a regular value.
|
|
2780
|
+
*/
|
|
2781
|
+
type Awaitable<T> = T | Promise<T>;
|
|
2782
|
+
/**
|
|
2783
|
+
* A type that represents a type that is a prettified version of the original type.
|
|
2784
|
+
* The prettified type has any generics removed from intellisense and displays a flat object.
|
|
2785
|
+
*/
|
|
2786
|
+
type Prettify<T> = {
|
|
2787
|
+
[K in keyof T]: T[K];
|
|
2788
|
+
} & {};
|
|
2789
|
+
|
|
2790
|
+
type Skip<T> = (controls: T) => Awaitable<boolean>;
|
|
2791
|
+
|
|
2791
2792
|
type StepOptions = {
|
|
2792
2793
|
skip?: Skip<any>;
|
|
2793
2794
|
inputSchema?: Schema;
|
|
2795
|
+
controlSchema?: Schema;
|
|
2794
2796
|
providers?: Record<string, (payload: any) => Awaitable<any>>;
|
|
2795
2797
|
};
|
|
2796
2798
|
declare enum JobStatusEnum {
|
|
@@ -2821,30 +2823,58 @@ type StepContext = {
|
|
|
2821
2823
|
type StepOutput<T_Result> = Promise<T_Result & StepContext>;
|
|
2822
2824
|
type ActionStep<T_Outputs, T_Result> = <
|
|
2823
2825
|
/**
|
|
2824
|
-
* The schema for the
|
|
2826
|
+
* The schema for the controls of the step.
|
|
2825
2827
|
*/
|
|
2826
|
-
|
|
2828
|
+
T_ControlSchema extends Schema,
|
|
2827
2829
|
/**
|
|
2828
|
-
* The
|
|
2830
|
+
* The controls for the step.
|
|
2831
|
+
*/
|
|
2832
|
+
T_Controls = FromSchema<T_ControlSchema>>(
|
|
2833
|
+
/**
|
|
2834
|
+
* The name of the step. This is used to identify the step in the workflow.
|
|
2835
|
+
*/
|
|
2836
|
+
name: string,
|
|
2837
|
+
/**
|
|
2838
|
+
* The function to resolve the step notification content for the step.
|
|
2839
|
+
*
|
|
2840
|
+
* @param controls The controls for the step.
|
|
2841
|
+
*/
|
|
2842
|
+
resolve: (controls: T_Controls) => Awaitable<T_Outputs>,
|
|
2843
|
+
/**
|
|
2844
|
+
* The options for the step.
|
|
2829
2845
|
*/
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2846
|
+
options?: {
|
|
2847
|
+
/**
|
|
2848
|
+
* Skip the step. If the skip function returns true, the step will be skipped.
|
|
2849
|
+
*
|
|
2850
|
+
* @param controls The controls for the step.
|
|
2851
|
+
*/
|
|
2852
|
+
skip?: Skip<T_Controls>;
|
|
2853
|
+
/**
|
|
2854
|
+
* The schema for the controls of the step. Used to validate the user-provided controls from Novu Web.
|
|
2855
|
+
*
|
|
2856
|
+
* @deprecated Use `controlSchema` instead
|
|
2857
|
+
*/
|
|
2858
|
+
inputSchema?: T_ControlSchema;
|
|
2859
|
+
/**
|
|
2860
|
+
* The schema for the controls of the step. Used to validate the user-provided controls from Novu Web.
|
|
2861
|
+
*/
|
|
2862
|
+
controlSchema?: T_ControlSchema;
|
|
2833
2863
|
providers?: Record<string, (payload: unknown) => Awaitable<unknown>>;
|
|
2834
2864
|
}) => StepOutput<T_Result>;
|
|
2835
2865
|
type CustomStep = <
|
|
2836
2866
|
/**
|
|
2837
|
-
* The schema for the
|
|
2867
|
+
* The schema for the controls of the step.
|
|
2838
2868
|
*/
|
|
2839
|
-
|
|
2869
|
+
T_ControlSchema extends Schema,
|
|
2840
2870
|
/**
|
|
2841
2871
|
* The schema for the outputs of the step.
|
|
2842
2872
|
*/
|
|
2843
2873
|
T_OutputsSchema extends Schema,
|
|
2844
2874
|
/**
|
|
2845
|
-
* The
|
|
2875
|
+
* The controls for the step.
|
|
2846
2876
|
*/
|
|
2847
|
-
|
|
2877
|
+
T_Controls = FromSchema<T_ControlSchema>,
|
|
2848
2878
|
/**
|
|
2849
2879
|
* The result for the step.
|
|
2850
2880
|
*/
|
|
@@ -2856,9 +2886,9 @@ name: string,
|
|
|
2856
2886
|
/**
|
|
2857
2887
|
* The function to resolve the step notification content for the step.
|
|
2858
2888
|
*
|
|
2859
|
-
* @param
|
|
2889
|
+
* @param controls The controls for the step.
|
|
2860
2890
|
*/
|
|
2861
|
-
resolve: (
|
|
2891
|
+
resolve: (controls: T_Controls) => Awaitable<T_Outputs>,
|
|
2862
2892
|
/**
|
|
2863
2893
|
* The options for the step.
|
|
2864
2894
|
*/
|
|
@@ -2866,13 +2896,22 @@ options?: {
|
|
|
2866
2896
|
/**
|
|
2867
2897
|
* Skip the step. If the skip function returns true, the step will be skipped.
|
|
2868
2898
|
*
|
|
2869
|
-
* @param
|
|
2899
|
+
* @param controls The controls for the step.
|
|
2900
|
+
*/
|
|
2901
|
+
skip?: Skip<T_Controls>;
|
|
2902
|
+
/**
|
|
2903
|
+
* The schema for the controls of the step. Used to validate the user-provided controls from Novu Web.
|
|
2904
|
+
*
|
|
2905
|
+
* @deprecated Use `controlSchema` instead
|
|
2906
|
+
*/
|
|
2907
|
+
inputSchema?: T_ControlSchema;
|
|
2908
|
+
/**
|
|
2909
|
+
* The schema for the controls of the step. Used to validate the user-provided controls from Novu Web.
|
|
2870
2910
|
*/
|
|
2871
|
-
|
|
2911
|
+
controlSchema?: T_ControlSchema;
|
|
2872
2912
|
/**
|
|
2873
|
-
* The schema for the
|
|
2913
|
+
* The schema for the outputs of the step. Used to validate the output of the `resolve` function.
|
|
2874
2914
|
*/
|
|
2875
|
-
inputSchema?: T_InputSchema;
|
|
2876
2915
|
outputSchema?: T_OutputsSchema;
|
|
2877
2916
|
}) => Promise<T_Result & StepContext>;
|
|
2878
2917
|
type ChannelStep<
|
|
@@ -2889,13 +2928,13 @@ T_Outputs,
|
|
|
2889
2928
|
*/
|
|
2890
2929
|
T_Result> = <
|
|
2891
2930
|
/**
|
|
2892
|
-
* The schema for the
|
|
2931
|
+
* The schema for the controls of the step.
|
|
2893
2932
|
*/
|
|
2894
|
-
|
|
2933
|
+
T_ControlSchema extends Schema,
|
|
2895
2934
|
/**
|
|
2896
|
-
* The
|
|
2935
|
+
* The controls for the step.
|
|
2897
2936
|
*/
|
|
2898
|
-
|
|
2937
|
+
T_Controls = FromSchema<T_ControlSchema>>(
|
|
2899
2938
|
/**
|
|
2900
2939
|
* The name of the step. This is used to identify the step in the workflow.
|
|
2901
2940
|
*/
|
|
@@ -2903,9 +2942,9 @@ name: string,
|
|
|
2903
2942
|
/**
|
|
2904
2943
|
* The function to resolve the step notification content for the step.
|
|
2905
2944
|
*
|
|
2906
|
-
* @param
|
|
2945
|
+
* @param controls The controls for the step.
|
|
2907
2946
|
*/
|
|
2908
|
-
resolve: (
|
|
2947
|
+
resolve: (controls: T_Controls) => Awaitable<T_Outputs>,
|
|
2909
2948
|
/**
|
|
2910
2949
|
* The options for the step.
|
|
2911
2950
|
*/
|
|
@@ -2913,17 +2952,23 @@ options?: {
|
|
|
2913
2952
|
/**
|
|
2914
2953
|
* Skip the step. If the skip function returns true, the step will be skipped.
|
|
2915
2954
|
*
|
|
2916
|
-
* @param
|
|
2955
|
+
* @param controls The controls for the step.
|
|
2917
2956
|
*/
|
|
2918
|
-
skip?: Skip<
|
|
2957
|
+
skip?: Skip<T_Controls>;
|
|
2919
2958
|
/**
|
|
2920
|
-
* The schema for the
|
|
2959
|
+
* The schema for the controls of the step. Used to validate the user-provided controls from Novu Web.
|
|
2960
|
+
*
|
|
2961
|
+
* @deprecated Use `controlSchema` instead
|
|
2921
2962
|
*/
|
|
2922
|
-
inputSchema?:
|
|
2963
|
+
inputSchema?: T_ControlSchema;
|
|
2964
|
+
/**
|
|
2965
|
+
* The schema for the controls of the step. Used to validate the user-provided controls from Novu Web.
|
|
2966
|
+
*/
|
|
2967
|
+
controlSchema?: T_ControlSchema;
|
|
2923
2968
|
/**
|
|
2924
2969
|
* The providers for the step. Used to override the behaviour of the providers for the step.
|
|
2925
2970
|
*/
|
|
2926
|
-
providers?: Providers<T_StepType,
|
|
2971
|
+
providers?: Providers<T_StepType, T_Controls, T_Outputs>;
|
|
2927
2972
|
}) => Promise<T_Result & StepContext>;
|
|
2928
2973
|
type EmailOutput = FromSchema<(typeof channelStepSchemas)[ChannelStepEnum.EMAIL]['output']>;
|
|
2929
2974
|
type EmailResult = FromSchema<(typeof channelStepSchemas)[ChannelStepEnum.EMAIL]['result']>;
|
|
@@ -2964,14 +3009,18 @@ type Step = {
|
|
|
2964
3009
|
};
|
|
2965
3010
|
|
|
2966
3011
|
type Subscriber = {
|
|
3012
|
+
subscriberId?: string;
|
|
2967
3013
|
firstName?: string;
|
|
2968
3014
|
lastName?: string;
|
|
3015
|
+
email?: string;
|
|
3016
|
+
phone?: string;
|
|
3017
|
+
avatar?: string;
|
|
2969
3018
|
};
|
|
2970
3019
|
|
|
2971
3020
|
/**
|
|
2972
|
-
* The
|
|
3021
|
+
* The parameters for the workflow function.
|
|
2973
3022
|
*/
|
|
2974
|
-
type ExecuteInput<T_Payload,
|
|
3023
|
+
type ExecuteInput<T_Payload, T_Control> = {
|
|
2975
3024
|
/** Define a step in your workflow. */
|
|
2976
3025
|
step: Step;
|
|
2977
3026
|
/** The payload for the event, provided during trigger. */
|
|
@@ -2980,28 +3029,123 @@ type ExecuteInput<T_Payload, T_Input> = {
|
|
|
2980
3029
|
subscriber: Subscriber;
|
|
2981
3030
|
/** The environment the workflow is running in. */
|
|
2982
3031
|
environment: Record<string, unknown>;
|
|
2983
|
-
/**
|
|
2984
|
-
|
|
3032
|
+
/**
|
|
3033
|
+
* The controls for the event. Provided via the UI.
|
|
3034
|
+
*
|
|
3035
|
+
* @deprecated Use `controls` instead
|
|
3036
|
+
*/
|
|
3037
|
+
input: T_Control;
|
|
3038
|
+
/** The controls for the event. Provided via the UI. */
|
|
3039
|
+
controls: T_Control;
|
|
2985
3040
|
};
|
|
2986
3041
|
/**
|
|
2987
3042
|
* The function to execute the workflow.
|
|
2988
3043
|
*/
|
|
2989
|
-
type Execute<T_Payload,
|
|
3044
|
+
type Execute<T_Payload, T_Control> = (event: ExecuteInput<T_Payload, T_Control>) => Promise<void>;
|
|
2990
3045
|
/**
|
|
2991
3046
|
* The options for the workflow.
|
|
2992
3047
|
*/
|
|
2993
|
-
type WorkflowOptions<T_PayloadSchema,
|
|
3048
|
+
type WorkflowOptions<T_PayloadSchema, T_ControlSchema> = {
|
|
2994
3049
|
/** The schema for the payload. */
|
|
2995
3050
|
payloadSchema?: T_PayloadSchema;
|
|
2996
|
-
/**
|
|
2997
|
-
|
|
3051
|
+
/**
|
|
3052
|
+
* The schema for the controls.
|
|
3053
|
+
*
|
|
3054
|
+
* @deprecated Use `controlSchema` instead
|
|
3055
|
+
*/
|
|
3056
|
+
inputSchema?: T_ControlSchema;
|
|
3057
|
+
controlSchema?: T_ControlSchema;
|
|
3058
|
+
};
|
|
3059
|
+
|
|
3060
|
+
type EventPayload = ITriggerPayload & {};
|
|
3061
|
+
type Actor = TriggerRecipientSubscriber & {};
|
|
3062
|
+
type Tenant = ITenantDefine & Record<string, never>;
|
|
3063
|
+
type Recipients = TriggerRecipientsPayload & {};
|
|
3064
|
+
type EventTriggerResult = {
|
|
3065
|
+
/**
|
|
3066
|
+
* Cancel the workflow execution
|
|
3067
|
+
*/
|
|
3068
|
+
cancel: () => Promise<CancelEventTriggerResponse>;
|
|
3069
|
+
/**
|
|
3070
|
+
* Response data for the trigger
|
|
3071
|
+
*/
|
|
3072
|
+
data: EventTriggerResponse;
|
|
3073
|
+
};
|
|
3074
|
+
type EventTriggerParams<T_Payload = EventPayload> = {
|
|
3075
|
+
/**
|
|
3076
|
+
* Workflow id
|
|
3077
|
+
*/
|
|
3078
|
+
workflowId: string;
|
|
3079
|
+
/**
|
|
3080
|
+
* Recipients to trigger the workflow to
|
|
3081
|
+
*/
|
|
3082
|
+
to: Recipients;
|
|
3083
|
+
/**
|
|
3084
|
+
* Actor to trigger the workflow from
|
|
3085
|
+
*/
|
|
3086
|
+
actor?: Actor;
|
|
3087
|
+
/**
|
|
3088
|
+
* Bridge url to trigger the workflow to
|
|
3089
|
+
*/
|
|
3090
|
+
bridgeUrl?: string;
|
|
3091
|
+
/**
|
|
3092
|
+
* Payload to trigger the workflow with
|
|
3093
|
+
*/
|
|
3094
|
+
payload: T_Payload;
|
|
3095
|
+
/**
|
|
3096
|
+
* Tenant to trigger the workflow with
|
|
3097
|
+
*/
|
|
3098
|
+
tenant?: Tenant;
|
|
3099
|
+
/**
|
|
3100
|
+
* Transaction id for trigger
|
|
3101
|
+
*/
|
|
3102
|
+
transactionId?: string;
|
|
3103
|
+
/**
|
|
3104
|
+
* Overrides for trigger
|
|
3105
|
+
*/
|
|
3106
|
+
overrides?: Record<string, unknown>;
|
|
3107
|
+
/**
|
|
3108
|
+
* Controls for the step execution
|
|
3109
|
+
*/
|
|
3110
|
+
controls?: {
|
|
3111
|
+
steps: {
|
|
3112
|
+
[stepId: string]: Record<string, unknown>;
|
|
3113
|
+
};
|
|
3114
|
+
};
|
|
3115
|
+
};
|
|
3116
|
+
type EventTriggerResponse = {
|
|
3117
|
+
/**
|
|
3118
|
+
* If trigger was acknowledged or not
|
|
3119
|
+
*/
|
|
3120
|
+
acknowledged: boolean;
|
|
3121
|
+
/**
|
|
3122
|
+
* Status for trigger
|
|
3123
|
+
*/
|
|
3124
|
+
status: `${TriggerEventStatusEnum}`;
|
|
3125
|
+
/**
|
|
3126
|
+
* Any errors encountered during the trigger
|
|
3127
|
+
*/
|
|
3128
|
+
error?: string[];
|
|
3129
|
+
/**
|
|
3130
|
+
* Unique transaction identifier for the event
|
|
3131
|
+
*/
|
|
3132
|
+
transactionId?: string;
|
|
2998
3133
|
};
|
|
3134
|
+
/**
|
|
3135
|
+
* Flag indicating if the event was cancelled or not.
|
|
3136
|
+
* `false` indicates the event was not cancelled because the execution was completed.
|
|
3137
|
+
* `true` indicates the in-flight execution was cancelled.
|
|
3138
|
+
*/
|
|
3139
|
+
type CancelEventTriggerResponse = boolean;
|
|
2999
3140
|
|
|
3000
3141
|
type StepType = `${ChannelStepEnum | ActionStepEnum}`;
|
|
3001
3142
|
type DiscoverProviderOutput = {
|
|
3002
3143
|
type: string;
|
|
3003
3144
|
code: string;
|
|
3004
|
-
resolve: (
|
|
3145
|
+
resolve: ({ controls, outputs }: {
|
|
3146
|
+
controls: unknown;
|
|
3147
|
+
outputs: unknown;
|
|
3148
|
+
}) => Awaitable<unknown>;
|
|
3005
3149
|
outputs: {
|
|
3006
3150
|
schema: JsonSchema;
|
|
3007
3151
|
unknownSchema: Schema;
|
|
@@ -3014,6 +3158,10 @@ type DiscoverStepOutput = {
|
|
|
3014
3158
|
schema: JsonSchema;
|
|
3015
3159
|
unknownSchema: Schema;
|
|
3016
3160
|
};
|
|
3161
|
+
controls: {
|
|
3162
|
+
schema: JsonSchema;
|
|
3163
|
+
unknownSchema: Schema;
|
|
3164
|
+
};
|
|
3017
3165
|
outputs: {
|
|
3018
3166
|
schema: JsonSchema;
|
|
3019
3167
|
unknownSchema: Schema;
|
|
@@ -3023,7 +3171,7 @@ type DiscoverStepOutput = {
|
|
|
3023
3171
|
unknownSchema: Schema;
|
|
3024
3172
|
};
|
|
3025
3173
|
code: string;
|
|
3026
|
-
resolve: (
|
|
3174
|
+
resolve: (controls: any) => Awaitable<any>;
|
|
3027
3175
|
providers: Array<DiscoverProviderOutput>;
|
|
3028
3176
|
options: StepOptions;
|
|
3029
3177
|
};
|
|
@@ -3033,36 +3181,54 @@ type DiscoverWorkflowOutput = {
|
|
|
3033
3181
|
options: WorkflowOptions<unknown, unknown>;
|
|
3034
3182
|
code: string;
|
|
3035
3183
|
steps: Array<DiscoverStepOutput>;
|
|
3184
|
+
payload: {
|
|
3185
|
+
schema: JsonSchema;
|
|
3186
|
+
unknownSchema: Schema;
|
|
3187
|
+
};
|
|
3188
|
+
/** @deprecated */
|
|
3036
3189
|
data: {
|
|
3037
3190
|
schema: JsonSchema;
|
|
3038
3191
|
unknownSchema: Schema;
|
|
3039
3192
|
};
|
|
3193
|
+
/** @deprecated */
|
|
3040
3194
|
inputs: {
|
|
3041
3195
|
schema: JsonSchema;
|
|
3042
3196
|
unknownSchema: Schema;
|
|
3043
3197
|
};
|
|
3198
|
+
controls: {
|
|
3199
|
+
schema: JsonSchema;
|
|
3200
|
+
unknownSchema: Schema;
|
|
3201
|
+
};
|
|
3202
|
+
};
|
|
3203
|
+
type Workflow<T_Payload = any> = {
|
|
3204
|
+
trigger: (event: Prettify<Omit<EventTriggerParams<T_Payload>, 'workflowId' | 'bridgeUrl' | 'controls'>>) => Promise<EventTriggerResult>;
|
|
3205
|
+
definition: DiscoverWorkflowOutput;
|
|
3044
3206
|
};
|
|
3045
3207
|
type DiscoverOutput = {
|
|
3046
3208
|
workflows: Array<DiscoverWorkflowOutput>;
|
|
3047
3209
|
};
|
|
3048
3210
|
|
|
3049
|
-
|
|
3211
|
+
type Event = {
|
|
3212
|
+
/** @deprecated */
|
|
3050
3213
|
data: Record<string, unknown>;
|
|
3214
|
+
payload: Record<string, unknown>;
|
|
3051
3215
|
workflowId: string;
|
|
3052
3216
|
stepId: string;
|
|
3217
|
+
/** @deprecated */
|
|
3053
3218
|
inputs: Record<string, unknown>;
|
|
3054
|
-
|
|
3219
|
+
controls: Record<string, unknown>;
|
|
3220
|
+
state: State[];
|
|
3055
3221
|
action: 'execute' | 'preview';
|
|
3056
3222
|
subscriber: Subscriber;
|
|
3057
|
-
}
|
|
3058
|
-
|
|
3223
|
+
};
|
|
3224
|
+
type State = {
|
|
3059
3225
|
stepId: string;
|
|
3060
3226
|
outputs: any;
|
|
3061
3227
|
state: {
|
|
3062
3228
|
status: string;
|
|
3063
3229
|
error?: string;
|
|
3064
3230
|
};
|
|
3065
|
-
}
|
|
3231
|
+
};
|
|
3066
3232
|
type ExecuteOutputMetadata = {
|
|
3067
3233
|
status: string;
|
|
3068
3234
|
error: boolean;
|
|
@@ -3082,7 +3248,8 @@ type SupportedFrameworkName = 'next' | 'express' | 'nuxt' | 'h3' | 'sveltekit' |
|
|
|
3082
3248
|
|
|
3083
3249
|
type HealthCheck = {
|
|
3084
3250
|
status: 'ok' | 'error';
|
|
3085
|
-
|
|
3251
|
+
sdkVersion: string;
|
|
3252
|
+
frameworkVersion: string;
|
|
3086
3253
|
discovered: {
|
|
3087
3254
|
workflows: number;
|
|
3088
3255
|
steps: number;
|
|
@@ -3092,13 +3259,12 @@ type HealthCheck = {
|
|
|
3092
3259
|
declare class Client {
|
|
3093
3260
|
private discoveredWorkflows;
|
|
3094
3261
|
private templateEngine;
|
|
3095
|
-
|
|
3262
|
+
secretKey?: string;
|
|
3096
3263
|
version: string;
|
|
3097
3264
|
strictAuthentication: boolean;
|
|
3098
|
-
static NOVU_SIGNATURE_HEADER: HttpHeaderKeysEnum;
|
|
3099
3265
|
constructor(options?: ClientOptions);
|
|
3100
3266
|
private buildOptions;
|
|
3101
|
-
addWorkflows(workflows: Array<
|
|
3267
|
+
addWorkflows(workflows: Array<Workflow>): void;
|
|
3102
3268
|
healthCheck(): HealthCheck;
|
|
3103
3269
|
private getWorkflow;
|
|
3104
3270
|
private getStep;
|
|
@@ -3119,38 +3285,38 @@ declare class Client {
|
|
|
3119
3285
|
private throwInvalidEvent;
|
|
3120
3286
|
private executeStepFactory;
|
|
3121
3287
|
private shouldSkip;
|
|
3122
|
-
executeWorkflow(event:
|
|
3123
|
-
private
|
|
3288
|
+
executeWorkflow(event: Event): Promise<ExecuteOutput>;
|
|
3289
|
+
private createExecutionPayload;
|
|
3124
3290
|
private prettyPrintExecute;
|
|
3125
3291
|
private executeProviders;
|
|
3126
3292
|
private previewProvider;
|
|
3127
3293
|
private executeProvider;
|
|
3128
3294
|
private executeStep;
|
|
3129
|
-
private
|
|
3295
|
+
private compileControls;
|
|
3130
3296
|
/**
|
|
3131
|
-
* Create the
|
|
3297
|
+
* Create the controls for a step, taking both the event controls and the default controls into account
|
|
3132
3298
|
*
|
|
3133
|
-
* @param step The step to create the
|
|
3299
|
+
* @param step The step to create the controls for
|
|
3134
3300
|
* @param event The event that triggered the step
|
|
3135
|
-
* @returns The
|
|
3301
|
+
* @returns The controls for the step
|
|
3136
3302
|
*/
|
|
3137
|
-
private
|
|
3303
|
+
private createStepControls;
|
|
3138
3304
|
private previewStep;
|
|
3139
3305
|
private getStepCode;
|
|
3140
3306
|
private getWorkflowCode;
|
|
3141
3307
|
getCode(workflowId: string, stepId?: string): CodeResult;
|
|
3142
3308
|
}
|
|
3143
3309
|
|
|
3144
|
-
|
|
3310
|
+
type ServeHandlerOptions = {
|
|
3145
3311
|
client?: Client;
|
|
3146
|
-
workflows: Array<
|
|
3147
|
-
}
|
|
3148
|
-
|
|
3312
|
+
workflows: Array<Workflow>;
|
|
3313
|
+
};
|
|
3314
|
+
type INovuRequestHandlerOptions<Input extends any[] = any[], Output = any> = ServeHandlerOptions & {
|
|
3149
3315
|
frameworkName: string;
|
|
3150
3316
|
client?: Client;
|
|
3151
|
-
workflows: Array<
|
|
3317
|
+
workflows: Array<Workflow>;
|
|
3152
3318
|
handler: Handler<Input, Output>;
|
|
3153
|
-
}
|
|
3319
|
+
};
|
|
3154
3320
|
type Handler<Input extends any[] = any[], Output = any> = (...args: Input) => HandlerResponse<Output>;
|
|
3155
3321
|
type HandlerResponse<Output = any> = {
|
|
3156
3322
|
body: () => Awaitable<any>;
|
|
@@ -3160,16 +3326,17 @@ type HandlerResponse<Output = any> = {
|
|
|
3160
3326
|
url: () => Awaitable<URL>;
|
|
3161
3327
|
transformResponse: (res: IActionResponse<string>) => Output;
|
|
3162
3328
|
};
|
|
3163
|
-
|
|
3329
|
+
type IActionResponse<TBody extends string = string> = {
|
|
3164
3330
|
status: number;
|
|
3165
3331
|
headers: Record<string, string>;
|
|
3166
3332
|
body: TBody;
|
|
3167
|
-
}
|
|
3333
|
+
};
|
|
3168
3334
|
declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
3169
3335
|
readonly frameworkName: string;
|
|
3170
|
-
readonly handler: Handler
|
|
3336
|
+
readonly handler: Handler<Input, Output>;
|
|
3171
3337
|
readonly client: Client;
|
|
3172
3338
|
private readonly hmacEnabled;
|
|
3339
|
+
private readonly http;
|
|
3173
3340
|
constructor(options: INovuRequestHandlerOptions<Input, Output>);
|
|
3174
3341
|
createHandler(): (...args: Input) => Promise<Output>;
|
|
3175
3342
|
private getStaticHeaders;
|
|
@@ -3177,6 +3344,7 @@ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
|
3177
3344
|
private createError;
|
|
3178
3345
|
private handleAction;
|
|
3179
3346
|
private getPostActionMap;
|
|
3347
|
+
triggerAction(triggerEvent: EventTriggerParams): () => Promise<IActionResponse<string>>;
|
|
3180
3348
|
private getGetActionMap;
|
|
3181
3349
|
private handlePostAction;
|
|
3182
3350
|
private handleGetAction;
|
|
@@ -3186,4 +3354,4 @@ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
|
3186
3354
|
private hashHmac;
|
|
3187
3355
|
}
|
|
3188
3356
|
|
|
3189
|
-
export { type ActionStep as A, type
|
|
3357
|
+
export { type ExecuteInput as $, type ActionStep as A, type PushResult as B, Client as C, type DiscoverProviderOutput as D, type Execute as E, type FromSchema as F, type ChatOutput as G, type HealthCheck as H, type ChatResult as I, type JsonSchema as J, type InAppOutput as K, type InAppResult as L, type DelayOutput as M, NovuRequestHandler as N, type DelayResult as O, type PushOutput as P, type digestRegularOutput as Q, type digestTimedOutput as R, type Schema as S, type DigestOutput as T, type DigestResult as U, type Step as V, type WorkflowOptions as W, type Subscriber as X, type Either as Y, type Awaitable as Z, type Prettify as _, type Workflow as a, ChannelStepEnum as a0, ActionStepEnum as a1, type ServeHandlerOptions as b, type CodeResult as c, type ClientOptions as d, type StepType as e, type DiscoverStepOutput as f, type DiscoverWorkflowOutput as g, type DiscoverOutput as h, type EventTriggerResult as i, type EventTriggerParams as j, type EventTriggerResponse as k, type CancelEventTriggerResponse as l, type Event as m, type State as n, type ExecuteOutputMetadata as o, type ExecuteOutput as p, type SupportedFrameworkName as q, type Skip as r, type StepOptions as s, JobStatusEnum as t, type CustomStep as u, type ChannelStep as v, type EmailOutput as w, type EmailResult as x, type SmsOutput as y, type SmsResult as z };
|