@useparagon/core 1.0.9-canary.2 → 1.0.9-canary.3

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.
@@ -1,12 +1,13 @@
1
1
  import { ICreateTriggerContext, IPayloadValidationContext, ISetupTriggerResponseContext, ITeardownTriggerContext } from './customTrigger.context.interface';
2
- import { CustomTriggerSetupResponse, ICreateTriggerSetup, ICustomTriggerInit, ITeardownTriggerSetup, TriggerPayloadValidationOption, TriggerSubscription, WebhookTriggerLevel } from './customTrigger.interface';
3
- export declare abstract class ApiEndpointWebhookTrigger<TL extends WebhookTriggerLevel, InputResultMap extends Record<string, any> = Record<string, any>> implements ICustomTriggerInit<'PROGRAMMATIC', TL> {
2
+ import { CustomTriggerSetupResponse, ICreateTriggerSetup, ICustomTriggerInit, ITeardownTriggerSetup, TriggerPayloadValidationOption, TriggerSubscription, WebhookPayloadMapToUser, WebhookTriggerLevel } from './customTrigger.interface';
3
+ export declare abstract class ApiEndpointWebhookTrigger<TL extends WebhookTriggerLevel, IntegrationType extends 'custom' | 'default', InputResultMap extends Record<string, any> = Record<string, any>> implements ICustomTriggerInit<'PROGRAMMATIC', TL, IntegrationType, InputResultMap> {
4
4
  abstract triggerLevel: TL;
5
5
  readonly triggerSubscription: `${TriggerSubscription.PROGRAMMATIC}`;
6
6
  abstract id: string;
7
7
  abstract name: string;
8
8
  abstract description: string;
9
9
  abstract isConfigured: boolean;
10
+ abstract mapPayload: TL extends 'APP' ? WebhookPayloadMapToUser<IntegrationType> : undefined;
10
11
  abstract create(createContext: ICreateTriggerContext<InputResultMap>): ICreateTriggerSetup;
11
12
  abstract teardown(tearDownContext: ITeardownTriggerContext<InputResultMap>): ITeardownTriggerSetup;
12
13
  abstract setupResponse(setupContext: ISetupTriggerResponseContext<InputResultMap>): CustomTriggerSetupResponse | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"apiEndpointWebhook.trigger.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/apiEndpointWebhook.trigger.ts"],"names":[],"mappings":";;;AAgBA,MAAsB,yBAAyB;IAapC,mBAAmB,GAC1B,cAAc,CAAC;CAqDlB;AAnED,8DAmEC"}
1
+ {"version":3,"file":"apiEndpointWebhook.trigger.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/apiEndpointWebhook.trigger.ts"],"names":[],"mappings":";;;AAiBA,MAAsB,yBAAyB;IAepC,mBAAmB,GAC1B,cAAc,CAAC;CA6DlB;AA7ED,8DA6EC"}
@@ -1,10 +1,11 @@
1
1
  import { UserDefinedInput } from '../../inputs/input.interface';
2
2
  export declare class CustomTriggerContext<InputResultMap> {
3
3
  get webhookURL(): string;
4
- get setupResponse(): string;
4
+ get setupResponse(): Record<string, any>;
5
5
  get webhookRequest(): {
6
- body: object;
7
- headers: object;
6
+ body: Record<string, any>;
7
+ headers: Record<string, any>;
8
+ query: Record<string, any>;
8
9
  };
9
10
  get credential(): Record<string, any>;
10
11
  get profileData(): Record<string, any>;
@@ -13,4 +13,6 @@ export type ICreateTriggerContext<T extends Record<string, unknown>> = Pick<ICus
13
13
  export type ITeardownTriggerContext<T extends Record<string, unknown>> = Pick<ICustomTriggerContext<T>, 'setupResponse' | 'credential' | 'getEnvironmentSecret'>;
14
14
  export type ISetupTriggerResponseContext<T extends Record<string, unknown>> = Pick<ICustomTriggerContext<T>, 'getEnvironmentSecret'>;
15
15
  export type IPayloadValidationContext<T extends Record<string, unknown>> = Pick<ICustomTriggerContext<T>, 'getEnvironmentSecret' | 'persistData' | 'webhookRequest'>;
16
+ export type IProfileConfigContext = Pick<ICustomTriggerContext, 'profileData'>;
17
+ export type IProviderIdContext = Pick<ICustomTriggerContext, 'webhookRequest'>;
16
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"customTrigger.context.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/customTrigger.context.ts"],"names":[],"mappings":";;;AAAA,yEAA4E;AAC5E,iEAA0E;AAG1E,MAAa,oBAAoB;IAI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CAAC;IACJ,CAAC;CACF;AAjGD,oDAiGC"}
@@ -1,5 +1,5 @@
1
1
  import { FunctionStepLibraries } from '../../steps/library/function/libraries';
2
- import { ICreateTriggerContext, ISetupTriggerResponseContext, ITeardownTriggerContext } from './customTrigger.context.interface';
2
+ import { ICreateTriggerContext, IPayloadValidationContext, IProfileConfigContext, IProviderIdContext, ISetupTriggerResponseContext, ITeardownTriggerContext } from './customTrigger.context.interface';
3
3
  export declare enum TriggerSubscription {
4
4
  PROGRAMMATIC = "PROGRAMMATIC",
5
5
  MANUAL = "MANUAL"
@@ -46,33 +46,47 @@ export type CustomTriggerSetupResponse = {
46
46
  type: `${SetupResponseInitType.RESPOND_WITH_200}` | `${SetupResponseInitType.ECHO_REQUEST_BODY}`;
47
47
  } | {
48
48
  type: `${SetupResponseInitType.CUSTOM_CODE}`;
49
- code: (parameters: Record<string, string>, libraries: Pick<FunctionStepLibraries, 'crypto'>, request: {
49
+ code: (parameters: Record<string, any>, libraries: Pick<FunctionStepLibraries, 'crypto'>, request: {
50
50
  headers: Record<string, string>;
51
- body: object;
51
+ body: Record<string, any>;
52
+ query: Record<string, any>;
52
53
  }) => SetupResponse;
53
- parameters: Record<string, string>;
54
+ parameters: Record<string, any>;
54
55
  };
55
56
  export type TriggerPayloadValidationOption = {
56
57
  scheme: `${CustomTriggerPayloadValidationScheme.NONE}`;
57
58
  } | {
58
59
  scheme: `${CustomTriggerPayloadValidationScheme.CUSTOM}`;
59
- parameters: Record<string, string>;
60
- code: (parameters: Record<string, string>, libraries: Pick<FunctionStepLibraries, 'crypto'>) => boolean;
60
+ parameters: Record<string, any>;
61
+ code: (parameters: Record<string, any>, libraries: Pick<FunctionStepLibraries, 'crypto'>, request: {
62
+ headers: Record<string, string>;
63
+ body: Record<string, any>;
64
+ query: Record<string, any>;
65
+ }) => boolean;
61
66
  } | {
62
67
  scheme: `${CustomTriggerPayloadValidationScheme.SHA_1_BASE64_PAYLOAD_BODY}` | `${CustomTriggerPayloadValidationScheme.SHA_1_HEX_PAYLOAD_BODY}` | `${CustomTriggerPayloadValidationScheme.SHA_256_BASE64_PAYLOAD_BODY}` | `${CustomTriggerPayloadValidationScheme.SHA_256_HEX_PAYLOAD_BODY}`;
63
68
  webhookSecret: string;
64
69
  webhookSignatureHeader: string;
65
70
  };
71
+ export type WebhookPayloadMapToCustomIntegration = {
72
+ providerId: (context: IProviderIdContext) => string;
73
+ profileConfigKey: (context: IProfileConfigContext) => string;
74
+ };
75
+ export type WebhookPayloadMapToIntegration = {
76
+ providerId: (context: IProviderIdContext) => string;
77
+ };
78
+ export type WebhookPayloadMapToUser<T extends 'custom' | 'default'> = T extends 'custom' ? WebhookPayloadMapToCustomIntegration : WebhookPayloadMapToIntegration;
66
79
  export type ITeardownTriggerSetup = ICreateTriggerSetup;
67
- export type ICustomTriggerInit<TS extends `${TriggerSubscription}`, TL extends WebhookTriggerLevel, InputResultMap extends Record<string, any> = Record<string, any>> = {
80
+ export type ICustomTriggerInit<TS extends `${TriggerSubscription}`, TL extends WebhookTriggerLevel, IntegrationType extends 'custom' | 'default', InputResultMap extends Record<string, any> = Record<string, any>> = {
68
81
  id: string;
69
82
  name: string;
70
83
  description: string;
71
84
  triggerSubscription: TS;
72
85
  isConfigured: boolean;
73
86
  triggerLevel: TL;
74
- validatePayload: (validateWebhookContext: any) => TriggerPayloadValidationOption | undefined;
87
+ validatePayload: (validateWebhookContext: IPayloadValidationContext<InputResultMap>) => TriggerPayloadValidationOption | undefined;
75
88
  setupResponse: (setupContext: ISetupTriggerResponseContext<InputResultMap>) => CustomTriggerSetupResponse | undefined;
89
+ mapPayload: TL extends 'APP' ? WebhookPayloadMapToUser<IntegrationType> : undefined;
76
90
  } & (TS extends `${TriggerSubscription.PROGRAMMATIC}` ? {
77
91
  create: (createContext: ICreateTriggerContext<InputResultMap>) => ICreateTriggerSetup;
78
92
  teardown: (tearDownContext: ITeardownTriggerContext<InputResultMap>) => ITeardownTriggerSetup;
@@ -1 +1 @@
1
- {"version":3,"file":"customTrigger.interface.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/customTrigger.interface.ts"],"names":[],"mappings":";;;AAUA,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,wCAAiB,CAAA;AACnB,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B;AAUY,QAAA,qBAAqB,GAAG,+BAAwC,CAAC;AAE9E,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,4DAAuC,CAAA;IACvC,gDAA2B,CAAA;AAC7B,CAAC,EAJW,iBAAiB,iCAAjB,iBAAiB,QAI5B;AAKD,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,8DAAqC,CAAA;IACrC,gEAAuC,CAAA;IACvC,oDAA2B,CAAA;AAC7B,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAmDD,IAAY,oCAOX;AAPD,WAAY,oCAAoC;IAC9C,qDAAa,CAAA;IACb,yDAAiB,CAAA;IACjB,6FAAqD,CAAA;IACrD,mGAA2D,CAAA;IAC3D,yFAAiD,CAAA;IACjD,+FAAuD,CAAA;AACzD,CAAC,EAPW,oCAAoC,oDAApC,oCAAoC,QAO/C"}
1
+ {"version":3,"file":"customTrigger.interface.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/customTrigger.interface.ts"],"names":[],"mappings":";;;AAaA,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,wCAAiB,CAAA;AACnB,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B;AAUY,QAAA,qBAAqB,GAAG,+BAAwC,CAAC;AAE9E,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,4DAAuC,CAAA;IACvC,gDAA2B,CAAA;AAC7B,CAAC,EAJW,iBAAiB,iCAAjB,iBAAiB,QAI5B;AAKD,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,8DAAqC,CAAA;IACrC,gEAAuC,CAAA;IACvC,oDAA2B,CAAA;AAC7B,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAmDD,IAAY,oCAOX;AAPD,WAAY,oCAAoC;IAC9C,qDAAa,CAAA;IACb,yDAAiB,CAAA;IACjB,6FAAqD,CAAA;IACrD,mGAA2D,CAAA;IAC3D,yFAAiD,CAAA;IACjD,+FAAuD,CAAA;AACzD,CAAC,EAPW,oCAAoC,oDAApC,oCAAoC,QAO/C"}
@@ -12,6 +12,6 @@ export declare class CustomTriggerStep extends TriggerStep {
12
12
  private _parameters;
13
13
  parameters: ICustomTriggerStepParameters;
14
14
  type: StepType.ACTION_TRIGGER;
15
- constructor(CustomTriggerClass: Constructable<ICustomTriggerInit<`${TriggerSubscription}`, WebhookTriggerLevel>>);
15
+ constructor(CustomTriggerClass: Constructable<ICustomTriggerInit<`${TriggerSubscription}`, WebhookTriggerLevel, 'custom' | 'default'>>);
16
16
  serializeParameters(): ICustomTriggerStepParameters;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"customTrigger.step.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/customTrigger.step.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAEtD,wCAAyC;AACzC,uEAKmC;AAYnC,MAAa,iBAAkB,SAAQ,qBAAW;IAOxC,WAAW,CAGjB;IAKF,UAAU,CAA+B;IAQzC,IAAI,GAA4B,yBAAQ,CAAC,cAAc,CAAC;IAExD,YACE,kBAEC;QAED,KAAK,CAAC,EAAE,CAAC,CAAC;QACV,IAAI,CAAC,WAAW,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC/C,CAAC;IAKD,mBAAmB;QACjB,OAAO;YACL,GAAG,IAAI,CAAC,UAAU;YAClB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,eAAgB;YAC9C,MAAM,EAAE,+CAAqB;YAC7B,sBAAsB,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE;YAC3C,gBAAgB,EAAE,EAAE;SACrB,CAAC;IACJ,CAAC;CACF;AA/CD,8CA+CC"}
1
+ {"version":3,"file":"customTrigger.step.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/customTrigger.step.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAEtD,wCAAyC;AACzC,uEAKmC;AAYnC,MAAa,iBAAkB,SAAQ,qBAAW;IAOxC,WAAW,CAIjB;IAKF,UAAU,CAA+B;IAQzC,IAAI,GAA4B,yBAAQ,CAAC,cAAc,CAAC;IAExD,YACE,kBAMC;QAED,KAAK,CAAC,EAAE,CAAC,CAAC;QACV,IAAI,CAAC,WAAW,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC/C,CAAC;IAKD,mBAAmB;QACjB,OAAO;YACL,GAAG,IAAI,CAAC,UAAU;YAClB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,eAAgB;YAC9C,MAAM,EAAE,+CAAqB;YAC7B,sBAAsB,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE;YAC3C,gBAAgB,EAAE,EAAE;SACrB,CAAC;IACJ,CAAC;CACF;AApDD,8CAoDC"}
@@ -1,11 +1,13 @@
1
- import { CustomTriggerSetupResponse, ICustomTriggerInit, TriggerPayloadValidationOption, TriggerSubscription, WebhookTriggerLevel } from './customTrigger.interface';
2
- export declare abstract class ManualWebhookTrigger<TL extends WebhookTriggerLevel, InputResultMap extends Record<string, any> = Record<string, any>> implements ICustomTriggerInit<'MANUAL', TL, InputResultMap> {
1
+ import { IPayloadValidationContext, ISetupTriggerResponseContext } from './customTrigger.context.interface';
2
+ import { CustomTriggerSetupResponse, ICustomTriggerInit, TriggerPayloadValidationOption, TriggerSubscription, WebhookPayloadMapToUser, WebhookTriggerLevel } from './customTrigger.interface';
3
+ export declare abstract class ManualWebhookTrigger<TL extends WebhookTriggerLevel, IntegrationType extends 'custom' | 'default', InputResultMap extends Record<string, any> = Record<string, any>> implements ICustomTriggerInit<'MANUAL', TL, IntegrationType, InputResultMap> {
3
4
  abstract triggerLevel: TL;
4
5
  readonly triggerSubscription: `${TriggerSubscription.MANUAL}`;
5
6
  abstract id: string;
6
7
  abstract name: string;
7
8
  abstract description: string;
8
9
  abstract isConfigured: boolean;
9
- abstract setupResponse(setupContext: any): CustomTriggerSetupResponse | undefined;
10
- abstract validatePayload(validationContext: any): TriggerPayloadValidationOption | undefined;
10
+ abstract mapPayload: TL extends 'APP' ? WebhookPayloadMapToUser<IntegrationType> : undefined;
11
+ abstract setupResponse(setupContext: ISetupTriggerResponseContext<InputResultMap>): CustomTriggerSetupResponse | undefined;
12
+ abstract validatePayload(validationContext: IPayloadValidationContext<InputResultMap>): TriggerPayloadValidationOption | undefined;
11
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"manualWebhook.trigger.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/manualWebhook.trigger.ts"],"names":[],"mappings":";;;AAQA,MAAsB,oBAAoB;IAU/B,mBAAmB,GAAoC,QAAQ,CAAC;CAmC1E;AA7CD,oDA6CC"}
1
+ {"version":3,"file":"manualWebhook.trigger.js","sourceRoot":"","sources":["../../../src/triggers/customTrigger/manualWebhook.trigger.ts"],"names":[],"mappings":";;;AAaA,MAAsB,oBAAoB;IAW/B,mBAAmB,GAAoC,QAAQ,CAAC;CA2C1E;AAtDD,oDAsDC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useparagon/core",
3
- "version": "1.0.9-canary.2",
3
+ "version": "1.0.9-canary.3",
4
4
  "description": "Core libraries for paragraph",
5
5
  "repository": "https://github.com/useparagon/paragraph",
6
6
  "packageManager": "pnpm@8.10.5",