@galaxy-io/filament-ui 0.12.0 → 0.14.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/dist/api/queries/pipelines.d.ts +15 -0
- package/dist/api/queries/pipelines.js +8 -2
- package/dist/api/queries/runs.js +3 -0
- package/dist/api/queries/webhooks.d.ts +61 -0
- package/dist/api/queries/webhooks.js +41 -0
- package/dist/components/connections/ConnectorPreviewChip.js +4 -3
- package/dist/components/webhooks/WebhookDeliveryUrlCopyButton.d.ts +8 -0
- package/dist/components/webhooks/WebhookDeliveryUrlCopyButton.js +33 -0
- package/dist/components/webhooks/WebhookEndpointErrorLayout.d.ts +7 -0
- package/dist/components/webhooks/WebhookEndpointErrorLayout.js +26 -0
- package/dist/components/webhooks/WebhookEndpointStatusBeacon.d.ts +7 -0
- package/dist/components/webhooks/WebhookEndpointStatusBeacon.js +20 -0
- package/dist/components/webhooks/WebhookEndpointStatusCallout.d.ts +8 -0
- package/dist/components/webhooks/WebhookEndpointStatusCallout.js +11 -0
- package/dist/components/webhooks/constants.d.ts +10 -0
- package/dist/components/webhooks/constants.js +36 -0
- package/dist/components/webhooks/hooks/useWebhookEndpointSync.d.ts +8 -0
- package/dist/components/webhooks/hooks/useWebhookEndpointSync.js +112 -0
- package/dist/components/webhooks/types.d.ts +9 -0
- package/dist/components/webhooks/types.js +13 -0
- package/dist/components/webhooks/utils.d.ts +21 -0
- package/dist/components/webhooks/utils.js +47 -0
- package/dist/gen/ingestion/v1/connectors_pb.d.ts +6 -0
- package/dist/gen/ingestion/v1/connectors_pb.js +1 -1
- package/dist/gen/ingestion/v1/runs_pb.d.ts +2 -1
- package/dist/gen/ingestion/v1/service_pb.d.ts +19 -0
- package/dist/gen/ingestion/v1/service_pb.js +4 -2
- package/dist/gen/ingestion/v1/webhooks_pb.d.ts +177 -0
- package/dist/gen/ingestion/v1/webhooks_pb.js +23 -0
- package/dist/hooks/useConfirm.d.ts +1 -1
- package/dist/pages/connections/ConnectionsPage.js +0 -4
- package/dist/pages/connections/components/card/ConnectionCard.d.ts +0 -1
- package/dist/pages/connections/components/card/ConnectionCard.js +4 -9
- package/dist/pages/connections/components/create/configure/CreateConnectionConfigure.js +48 -11
- package/dist/pages/connections/components/drawer/ConnectionDrawer.js +6 -1
- package/dist/pages/connections/components/drawer/ConnectionDrawerSection.js +1 -1
- package/dist/pages/connections/components/drawer/ConnectionDrawerWebhook.d.ts +7 -0
- package/dist/pages/connections/components/drawer/ConnectionDrawerWebhook.js +105 -0
- package/dist/pages/connections/components/drawer/ConnectionDrawerWebhookSecrets.d.ts +7 -0
- package/dist/pages/connections/components/drawer/ConnectionDrawerWebhookSecrets.js +40 -0
- package/dist/pages/connections/components/drawer/ConnectionDrawerWebhookSigningKey.d.ts +9 -0
- package/dist/pages/connections/components/drawer/ConnectionDrawerWebhookSigningKey.js +120 -0
- package/dist/pages/connections/components/form/ConnectionFormSigningKeyModal.d.ts +9 -0
- package/dist/pages/connections/components/form/ConnectionFormSigningKeyModal.js +66 -0
- package/dist/pages/connections/components/form/ConnectionFormWrapper.d.ts +1 -0
- package/dist/pages/connections/components/form/ConnectionFormWrapper.js +2 -1
- package/dist/pages/connections/components/form/types.d.ts +5 -0
- package/dist/pages/connections/hooks/useConnectionWebhookKeyMint.d.ts +12 -0
- package/dist/pages/connections/hooks/useConnectionWebhookKeyMint.js +27 -0
- package/dist/pages/observability/ObservabilityPage.js +11 -15
- package/dist/pages/observability/components/band/ObservabilityBand.js +19 -15
- package/dist/pages/pipelines/canvas/hooks/usePipelineCanvasPanelResourceOptions.js +1 -1
- package/dist/pages/pipelines/canvas/panel/overview/PipelineCanvasPanelOverview.js +1 -1
- package/dist/pages/pipelines/canvas/panel/overview/node/PipelineCanvasPanelNodeDetail.js +1 -1
- package/dist/pages/pipelines/canvas/panel/overview/resource/PipelineCanvasPanelResourceDetail.js +11 -0
- package/dist/pages/pipelines/canvas/panel/overview/resource/PipelineCanvasPanelResourceEndpoint.js +1 -1
- package/dist/pages/pipelines/canvas/panel/overview/resource/PipelineCanvasPanelResourceSection.js +4 -1
- package/dist/pages/pipelines/canvas/routes/hooks/usePipelineCanvasRoutes.js +1 -1
- package/dist/pages/pipelines/components/create/components/CreatePipelineModalFooter.js +7 -1
- package/dist/pages/pipelines/components/create/hooks/useCreatePipelineResources.js +1 -1
- package/dist/pages/pipelines/components/create/steps/CreatePipelineModalResources.js +5 -2
- package/dist/pages/pipelines/components/create/steps/components/CreatePipelineModalResourcesTable.js +15 -2
- package/dist/pages/pipelines/components/create/steps/components/CreatePipelineModalResourcesUrlCell.d.ts +7 -0
- package/dist/pages/pipelines/components/create/steps/components/CreatePipelineModalResourcesUrlCell.js +27 -0
- package/dist/pages/pipelines/components/header/PipelinePageEditActions.js +10 -0
- package/dist/pages/pipelines/components/resource/PipelineResourceCreateForm.d.ts +1 -0
- package/dist/pages/pipelines/components/resource/PipelineResourceCreateForm.js +10 -3
- package/dist/pages/pipelines/components/run/PipelineRunModal.js +7 -4
- package/dist/pages/pipelines/components/run/PipelineRunModalResourcesPane.d.ts +1 -0
- package/dist/pages/pipelines/components/run/PipelineRunModalResourcesPane.js +5 -4
- package/dist/pages/pipelines/components/run/utils.d.ts +1 -0
- package/dist/pages/pipelines/components/run/utils.js +2 -1
- package/dist/pages/pipelines/settings/PipelineSettingsPageGeneral.js +1 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/errors.js +6 -1
- package/package.json +1 -1
|
@@ -34,6 +34,21 @@ export declare const useSuspenseListPipelinesInfiniteQuery: ({ input, }?: {
|
|
|
34
34
|
input?: InfiniteQueryInput<typeof IngestionService.method.listPipelines.input>;
|
|
35
35
|
}) => import('@tanstack/react-query').UseSuspenseInfiniteQueryResult<import('@tanstack/react-query').InfiniteData<ListPipelinesResponse, unknown>, import('@connectrpc/connect').ConnectError>;
|
|
36
36
|
export declare const createGetPipelineInput: (id: Pipeline["id"]) => GetPipelineRequest;
|
|
37
|
+
export declare const createGetPipelineQueryOptions: ({ input, transport, }: {
|
|
38
|
+
input: GetPipelineRequest;
|
|
39
|
+
transport: Transport;
|
|
40
|
+
}) => import('@connectrpc/connect-query').QueryOptions<Omit<import('@bufbuild/protobuf').DescMessage, "field" | "typeName"> & {
|
|
41
|
+
field: Record<"pipeline", import('@bufbuild/protobuf').DescField>;
|
|
42
|
+
typeName: "ingestion.v1.GetPipelineResponse";
|
|
43
|
+
} & {
|
|
44
|
+
readonly $codegenv2: {
|
|
45
|
+
a: GetPipelineResponse;
|
|
46
|
+
b: {
|
|
47
|
+
jsonType?: unknown;
|
|
48
|
+
validType?: unknown;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
} & import('@bufbuild/protobuf').DescMessage>;
|
|
37
52
|
export declare const createGetPipelineQueryKey: (input?: GetPipelineRequest, transport?: Transport) => ["connect-query", {
|
|
38
53
|
transport?: string;
|
|
39
54
|
serviceName: string;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { GetPipelineRequestSchema } from "../../gen/ingestion/v1/pipelines_pb.js";
|
|
2
2
|
import { IngestionService } from "../../gen/ingestion/v1/service_pb.js";
|
|
3
3
|
import { ACTIVE_RUNS_REFETCH_INTERVAL } from "./constants.js";
|
|
4
|
+
import { createGetWebhookEndpointQueryKey } from "./webhooks.js";
|
|
4
5
|
import { INITIAL_PAGE_PARAM, createListSearchInput, getNextPageParam, getScheduledRefetchInterval } from "../utils.js";
|
|
5
6
|
import { isRunActive } from "../../utils/runs.js";
|
|
6
7
|
import { createListRunsQueryKey } from "./runs.js";
|
|
7
8
|
import { create } from "@bufbuild/protobuf";
|
|
8
9
|
import { useQueryClient } from "@tanstack/react-query";
|
|
9
|
-
import { createConnectQueryKey, useMutation, useQuery, useSuspenseInfiniteQuery, useSuspenseQuery, useTransport } from "@connectrpc/connect-query";
|
|
10
|
+
import { createConnectQueryKey, createQueryOptions, useMutation, useQuery, useSuspenseInfiniteQuery, useSuspenseQuery, useTransport } from "@connectrpc/connect-query";
|
|
10
11
|
//#region src/api/queries/pipelines.ts
|
|
11
12
|
var getListPipelinesRefetchInterval = (pipelines) => {
|
|
12
13
|
if (!pipelines) return false;
|
|
@@ -57,6 +58,9 @@ var createGetPipelineInput = (id) => create(GetPipelineRequestSchema, {
|
|
|
57
58
|
includeVersions: true,
|
|
58
59
|
includeSchedule: true
|
|
59
60
|
});
|
|
61
|
+
var createGetPipelineQueryOptions = ({ input, transport }) => {
|
|
62
|
+
return createQueryOptions(IngestionService.method.getPipeline, input, { transport });
|
|
63
|
+
};
|
|
60
64
|
var createGetPipelineQueryKey = (input, transport) => {
|
|
61
65
|
return createConnectQueryKey({
|
|
62
66
|
schema: IngestionService.method.getPipeline,
|
|
@@ -90,6 +94,7 @@ var useUpdatePipelineMutation = (options = {}) => {
|
|
|
90
94
|
onSettled: (...args) => {
|
|
91
95
|
queryClient.invalidateQueries({ queryKey: createListPipelinesQueryKey(void 0, transport) });
|
|
92
96
|
queryClient.invalidateQueries({ queryKey: createGetPipelineQueryKey(void 0, transport) });
|
|
97
|
+
queryClient.invalidateQueries({ queryKey: createGetWebhookEndpointQueryKey(void 0, transport) });
|
|
93
98
|
return options.onSettled?.(...args);
|
|
94
99
|
}
|
|
95
100
|
});
|
|
@@ -103,9 +108,10 @@ var useDeletePipelineMutation = (options = {}) => {
|
|
|
103
108
|
queryClient.invalidateQueries({ queryKey: createListPipelinesQueryKey(void 0, transport) });
|
|
104
109
|
queryClient.invalidateQueries({ queryKey: createGetPipelineQueryKey(void 0, transport) });
|
|
105
110
|
queryClient.invalidateQueries({ queryKey: createListRunsQueryKey(void 0, transport) });
|
|
111
|
+
queryClient.invalidateQueries({ queryKey: createGetWebhookEndpointQueryKey(void 0, transport) });
|
|
106
112
|
return options.onSettled?.(...args);
|
|
107
113
|
}
|
|
108
114
|
});
|
|
109
115
|
};
|
|
110
116
|
//#endregion
|
|
111
|
-
export { createGetPipelineInput, createGetPipelineQueryKey, createListPipelinesInput, createListPipelinesQueryKey, useCreatePipelineMutation, useDeletePipelineMutation, useGetPipelineQuery, useListPipelinesQuery, useSuspenseGetPipelineQuery, useSuspenseListPipelinesInfiniteQuery, useSuspenseListPipelinesQuery, useUpdatePipelineMutation };
|
|
117
|
+
export { createGetPipelineInput, createGetPipelineQueryKey, createGetPipelineQueryOptions, createListPipelinesInput, createListPipelinesQueryKey, useCreatePipelineMutation, useDeletePipelineMutation, useGetPipelineQuery, useListPipelinesQuery, useSuspenseGetPipelineQuery, useSuspenseListPipelinesInfiniteQuery, useSuspenseListPipelinesQuery, useUpdatePipelineMutation };
|
package/dist/api/queries/runs.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ListRunsRequestSchema, RunStatus, TailRunRequestSchema } from "../../ge
|
|
|
2
2
|
import { ACTIVE_RUN_STATUSES } from "../../constants.js";
|
|
3
3
|
import { IngestionService } from "../../gen/ingestion/v1/service_pb.js";
|
|
4
4
|
import { ACTIVE_RUNS_REFETCH_INTERVAL, SCHEDULED_REFETCH_MAX_INTERVAL } from "./constants.js";
|
|
5
|
+
import { createGetWebhookEndpointQueryKey } from "./webhooks.js";
|
|
5
6
|
import { INITIAL_PAGE_PARAM, batchIterable, getNextPageParam, getScheduledRefetchInterval } from "../utils.js";
|
|
6
7
|
import { isRunActive } from "../../utils/runs.js";
|
|
7
8
|
import { createGetPipelineInput, createGetPipelineQueryKey, createListPipelinesQueryKey, useGetPipelineQuery } from "./pipelines.js";
|
|
@@ -165,6 +166,7 @@ var useRunPipelineMutation = (options = {}) => {
|
|
|
165
166
|
queryClient.invalidateQueries({ queryKey: createListRunsQueryKey(void 0, transport) });
|
|
166
167
|
queryClient.invalidateQueries({ queryKey: createListPipelinesQueryKey(void 0, transport) });
|
|
167
168
|
queryClient.invalidateQueries({ queryKey: createGetPipelineQueryKey(void 0, transport) });
|
|
169
|
+
queryClient.invalidateQueries({ queryKey: createGetWebhookEndpointQueryKey(void 0, transport) });
|
|
168
170
|
return options.onSettled?.(...args);
|
|
169
171
|
}
|
|
170
172
|
});
|
|
@@ -179,6 +181,7 @@ var useSignalRunMutation = (options = {}) => {
|
|
|
179
181
|
queryClient.invalidateQueries({ queryKey: createGetPipelineQueryKey(void 0, transport) });
|
|
180
182
|
queryClient.invalidateQueries({ queryKey: createListPipelinesQueryKey(void 0, transport) });
|
|
181
183
|
queryClient.invalidateQueries({ queryKey: createListRunsQueryKey(void 0, transport) });
|
|
184
|
+
queryClient.invalidateQueries({ queryKey: createGetWebhookEndpointQueryKey(void 0, transport) });
|
|
182
185
|
return options.onSettled?.(...args);
|
|
183
186
|
}
|
|
184
187
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Transport } from '@connectrpc/connect';
|
|
2
|
+
import { UseMutationOptions, UseQueryOptions } from '@connectrpc/connect-query';
|
|
3
|
+
import { Connection } from '../../gen/ingestion/v1/connections_pb';
|
|
4
|
+
import { IngestionService } from '../../gen/ingestion/v1/service_pb';
|
|
5
|
+
import { GetWebhookEndpointRequest, GetWebhookEndpointResponse, WebhookEndpointConfig } from '../../gen/ingestion/v1/webhooks_pb';
|
|
6
|
+
export declare const createGetWebhookEndpointInput: (sourceConnectionId: Connection["id"]) => GetWebhookEndpointRequest;
|
|
7
|
+
export declare const createGetWebhookEndpointQueryOptions: ({ input, transport, }: {
|
|
8
|
+
input: GetWebhookEndpointRequest;
|
|
9
|
+
transport: Transport;
|
|
10
|
+
}) => import('@connectrpc/connect-query').QueryOptions<Omit<import('@bufbuild/protobuf').DescMessage, "field" | "typeName"> & {
|
|
11
|
+
field: Record<"endpoint", import('@bufbuild/protobuf').DescField>;
|
|
12
|
+
typeName: "ingestion.v1.GetWebhookEndpointResponse";
|
|
13
|
+
} & {
|
|
14
|
+
readonly $codegenv2: {
|
|
15
|
+
a: GetWebhookEndpointResponse;
|
|
16
|
+
b: {
|
|
17
|
+
jsonType?: unknown;
|
|
18
|
+
validType?: unknown;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
} & import('@bufbuild/protobuf').DescMessage>;
|
|
22
|
+
export declare const createGetWebhookEndpointQueryKey: (input?: GetWebhookEndpointRequest, transport?: Transport) => ["connect-query", {
|
|
23
|
+
transport?: string;
|
|
24
|
+
serviceName: string;
|
|
25
|
+
methodName?: string;
|
|
26
|
+
input?: Record<string, unknown> | "skipped";
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
} & {
|
|
29
|
+
cardinality: "finite";
|
|
30
|
+
}] & {
|
|
31
|
+
[dataTagSymbol]: GetWebhookEndpointResponse;
|
|
32
|
+
[dataTagErrorSymbol]: import('@connectrpc/connect').ConnectError;
|
|
33
|
+
};
|
|
34
|
+
export declare const useGetWebhookEndpointQuery: ({ input, options, }: {
|
|
35
|
+
input: GetWebhookEndpointRequest;
|
|
36
|
+
options?: UseQueryOptions<typeof IngestionService.method.getWebhookEndpoint.output, GetWebhookEndpointResponse>;
|
|
37
|
+
}) => import('@tanstack/react-query').UseQueryResult<GetWebhookEndpointResponse, import('@connectrpc/connect').ConnectError>;
|
|
38
|
+
export declare const usePutWebhookEndpointMutation: (options?: UseMutationOptions<typeof IngestionService.method.putWebhookEndpoint.input, typeof IngestionService.method.putWebhookEndpoint.output>) => import('@tanstack/react-query').UseMutationResult<import('../../gen/ingestion/v1/webhooks_pb').PutWebhookEndpointResponse, import('@connectrpc/connect').ConnectError, import('../../gen/ingestion/v1/webhooks_pb').PutWebhookEndpointRequest | {
|
|
39
|
+
readonly $typeName?: undefined;
|
|
40
|
+
endpoint?: (WebhookEndpointConfig | {
|
|
41
|
+
readonly $typeName?: undefined;
|
|
42
|
+
sourceConnectionId?: string | undefined;
|
|
43
|
+
pipelineId?: string | undefined;
|
|
44
|
+
routeKey?: string | undefined;
|
|
45
|
+
resources?: string[] | undefined;
|
|
46
|
+
enabled?: boolean | undefined;
|
|
47
|
+
revision?: bigint | undefined;
|
|
48
|
+
successStatus?: number | undefined;
|
|
49
|
+
maxBodyBytes?: bigint | undefined;
|
|
50
|
+
hasSigningSecret?: boolean | undefined;
|
|
51
|
+
routeReady?: boolean | undefined;
|
|
52
|
+
verifier?: string | undefined;
|
|
53
|
+
previousKeyExpiresAt?: bigint | undefined;
|
|
54
|
+
accepting?: boolean | undefined;
|
|
55
|
+
deliveryUrl?: string | undefined;
|
|
56
|
+
}) | undefined;
|
|
57
|
+
expectedRevision?: bigint | undefined;
|
|
58
|
+
importedSecret?: string | undefined;
|
|
59
|
+
mintSecret?: boolean | undefined;
|
|
60
|
+
expectedPipelineVersionId?: string | undefined;
|
|
61
|
+
}, unknown>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GetWebhookEndpointRequestSchema } from "../../gen/ingestion/v1/webhooks_pb.js";
|
|
2
|
+
import { IngestionService } from "../../gen/ingestion/v1/service_pb.js";
|
|
3
|
+
import { createDiscoverResourcesQueryKey } from "./connectors.js";
|
|
4
|
+
import { ACTIVE_RUNS_REFETCH_INTERVAL } from "./constants.js";
|
|
5
|
+
import { create } from "@bufbuild/protobuf";
|
|
6
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
7
|
+
import { createConnectQueryKey, createQueryOptions, useMutation, useQuery, useTransport } from "@connectrpc/connect-query";
|
|
8
|
+
//#region src/api/queries/webhooks.ts
|
|
9
|
+
var getWebhookEndpointRefetchInterval = (endpoint) => endpoint?.enabled && endpoint.pipelineId && (endpoint.accepting || !endpoint.routeReady) ? ACTIVE_RUNS_REFETCH_INTERVAL : false;
|
|
10
|
+
var createGetWebhookEndpointInput = (sourceConnectionId) => create(GetWebhookEndpointRequestSchema, { sourceConnectionId });
|
|
11
|
+
var createGetWebhookEndpointQueryOptions = ({ input, transport }) => {
|
|
12
|
+
return createQueryOptions(IngestionService.method.getWebhookEndpoint, input, { transport });
|
|
13
|
+
};
|
|
14
|
+
var createGetWebhookEndpointQueryKey = (input, transport) => {
|
|
15
|
+
return createConnectQueryKey({
|
|
16
|
+
schema: IngestionService.method.getWebhookEndpoint,
|
|
17
|
+
input,
|
|
18
|
+
transport,
|
|
19
|
+
cardinality: "finite"
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var useGetWebhookEndpointQuery = ({ input, options = {} }) => {
|
|
23
|
+
return useQuery(IngestionService.method.getWebhookEndpoint, input, {
|
|
24
|
+
refetchInterval: (query) => getWebhookEndpointRefetchInterval(query.state.data?.endpoint),
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var usePutWebhookEndpointMutation = (options = {}) => {
|
|
29
|
+
const queryClient = useQueryClient();
|
|
30
|
+
const transport = useTransport();
|
|
31
|
+
return useMutation(IngestionService.method.putWebhookEndpoint, {
|
|
32
|
+
...options,
|
|
33
|
+
onSettled: (...args) => {
|
|
34
|
+
queryClient.invalidateQueries({ queryKey: createGetWebhookEndpointQueryKey(void 0, transport) });
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: createDiscoverResourcesQueryKey(void 0, transport) });
|
|
36
|
+
return options.onSettled?.(...args);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { createGetWebhookEndpointInput, createGetWebhookEndpointQueryKey, createGetWebhookEndpointQueryOptions, useGetWebhookEndpointQuery, usePutWebhookEndpointMutation };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { FlaskIcon } from "@phosphor-icons/react";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import Chip, { ChipSize
|
|
3
|
+
import Chip, { ChipSize } from "@galaxy-io/dls/chips/Chip";
|
|
3
4
|
//#region src/components/connections/ConnectorPreviewChip.tsx
|
|
4
5
|
var ConnectorPreviewChip = ({ isPreview }) => isPreview ? /* @__PURE__ */ jsx(Chip, {
|
|
5
|
-
|
|
6
|
+
icon: FlaskIcon,
|
|
7
|
+
ariaLabel: "This connector is in preview",
|
|
6
8
|
tooltip: "This connector is in preview",
|
|
7
|
-
variant: ChipVariant.TERTIARY,
|
|
8
9
|
size: ChipSize.SMALL
|
|
9
10
|
}) : null;
|
|
10
11
|
//#endregion
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Connection } from '../../gen/ingestion/v1/connections_pb';
|
|
3
|
+
interface WebhookDeliveryUrlCopyButtonProps {
|
|
4
|
+
sourceConnectionId: Connection["id"];
|
|
5
|
+
resource: string;
|
|
6
|
+
}
|
|
7
|
+
declare const WebhookDeliveryUrlCopyButton: FC<WebhookDeliveryUrlCopyButtonProps>;
|
|
8
|
+
export default WebhookDeliveryUrlCopyButton;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createWebhookDeliveryUrl } from "./utils.js";
|
|
2
|
+
import { createGetWebhookEndpointInput, useGetWebhookEndpointQuery } from "../../api/queries/webhooks.js";
|
|
3
|
+
import { ButtonSize, ButtonVariant } from "@galaxy-io/dls/buttons/Button";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import Text, { TextSize } from "@galaxy-io/dls/text/Text";
|
|
6
|
+
import { FontFamily } from "@galaxy-io/dls/theme/enums";
|
|
7
|
+
import CopyButton from "@galaxy-io/dls/buttons/CopyButton";
|
|
8
|
+
import Tooltip from "@galaxy-io/dls/tooltip/Tooltip";
|
|
9
|
+
//#region src/components/webhooks/WebhookDeliveryUrlCopyButton.tsx
|
|
10
|
+
var WebhookDeliveryUrlCopyButton = ({ sourceConnectionId, resource }) => {
|
|
11
|
+
const { data, isLoading } = useGetWebhookEndpointQuery({
|
|
12
|
+
input: createGetWebhookEndpointInput(sourceConnectionId),
|
|
13
|
+
options: { retry: false }
|
|
14
|
+
});
|
|
15
|
+
const deliveryUrl = createWebhookDeliveryUrl(resource, data?.endpoint?.deliveryUrl);
|
|
16
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
17
|
+
body: /* @__PURE__ */ jsx(Text, {
|
|
18
|
+
size: TextSize.BODY_SM,
|
|
19
|
+
family: FontFamily.MONO,
|
|
20
|
+
children: deliveryUrl ?? "Delivery URL unavailable. Configure WEBHOOK_PUBLIC_BASE_URL."
|
|
21
|
+
}),
|
|
22
|
+
children: /* @__PURE__ */ jsx(CopyButton, {
|
|
23
|
+
label: "Copy URL",
|
|
24
|
+
value: deliveryUrl ?? "",
|
|
25
|
+
ariaLabel: `Copy ${resource} delivery URL`,
|
|
26
|
+
variant: ButtonVariant.SECONDARY,
|
|
27
|
+
size: ButtonSize.SMALL,
|
|
28
|
+
isDisabled: isLoading || !deliveryUrl
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { WebhookDeliveryUrlCopyButton as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ConnectError } from '@connectrpc/connect';
|
|
3
|
+
interface WebhookEndpointErrorLayoutProps {
|
|
4
|
+
error: ConnectError | null;
|
|
5
|
+
}
|
|
6
|
+
declare const WebhookEndpointErrorLayout: FC<WebhookEndpointErrorLayoutProps>;
|
|
7
|
+
export default WebhookEndpointErrorLayout;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isUnimplementedError } from "../../utils/errors.js";
|
|
2
|
+
import ErrorLayout, { ErrorLayoutSize } from "@galaxy-io/dls/layout/ErrorLayout";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import Box from "@galaxy-io/dls/layout/Box";
|
|
5
|
+
//#region src/components/webhooks/WebhookEndpointErrorLayout.tsx
|
|
6
|
+
var WebhookEndpointErrorLayout = ({ error }) => {
|
|
7
|
+
if (isUnimplementedError(error)) return /* @__PURE__ */ jsx(Box, {
|
|
8
|
+
padding: 12,
|
|
9
|
+
children: /* @__PURE__ */ jsx(ErrorLayout, {
|
|
10
|
+
size: ErrorLayoutSize.SMALL,
|
|
11
|
+
header: "Webhooks unavailable",
|
|
12
|
+
description: "Webhook endpoints need PostgreSQL. This server does not support them."
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
16
|
+
padding: 12,
|
|
17
|
+
children: /* @__PURE__ */ jsx(ErrorLayout, {
|
|
18
|
+
size: ErrorLayoutSize.SMALL,
|
|
19
|
+
header: "Failed to load endpoint",
|
|
20
|
+
description: "The webhook endpoint for this source could not be loaded.",
|
|
21
|
+
detail: error?.message
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { WebhookEndpointErrorLayout as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { WebhookEndpointStatus } from './types';
|
|
3
|
+
interface WebhookEndpointStatusBeaconProps {
|
|
4
|
+
status: WebhookEndpointStatus;
|
|
5
|
+
}
|
|
6
|
+
declare const WebhookEndpointStatusBeacon: FC<WebhookEndpointStatusBeaconProps>;
|
|
7
|
+
export default WebhookEndpointStatusBeacon;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WebhookEndpointStatus } from "./types.js";
|
|
2
|
+
import { WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP, WEBHOOK_ENDPOINT_STATUS_TO_LABEL_MAP } from "./constants.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import Beacon, { BeaconVariant } from "@galaxy-io/dls/beacons/Beacon";
|
|
5
|
+
//#region src/components/webhooks/WebhookEndpointStatusBeacon.tsx
|
|
6
|
+
var WebhookEndpointStatusBeacon = ({ status }) => {
|
|
7
|
+
const hue = WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP[status];
|
|
8
|
+
const label = WEBHOOK_ENDPOINT_STATUS_TO_LABEL_MAP[status];
|
|
9
|
+
if (!hue) return /* @__PURE__ */ jsx(Beacon, {
|
|
10
|
+
variant: BeaconVariant.TERTIARY,
|
|
11
|
+
label
|
|
12
|
+
});
|
|
13
|
+
return /* @__PURE__ */ jsx(Beacon, {
|
|
14
|
+
color: hue,
|
|
15
|
+
label,
|
|
16
|
+
isPulse: status === WebhookEndpointStatus.LIVE
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { WebhookEndpointStatusBeacon as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { WebhookEndpointStatus } from './types';
|
|
3
|
+
interface WebhookEndpointStatusCalloutProps {
|
|
4
|
+
status: WebhookEndpointStatus;
|
|
5
|
+
actions?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const WebhookEndpointStatusCallout: FC<WebhookEndpointStatusCalloutProps>;
|
|
8
|
+
export default WebhookEndpointStatusCallout;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP, WEBHOOK_ENDPOINT_STATUS_TO_MESSAGE_MAP } from "./constants.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import Alert from "@galaxy-io/dls/feedback/Alert";
|
|
4
|
+
//#region src/components/webhooks/WebhookEndpointStatusCallout.tsx
|
|
5
|
+
var WebhookEndpointStatusCallout = ({ status, actions }) => /* @__PURE__ */ jsx(Alert, {
|
|
6
|
+
color: WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP[status],
|
|
7
|
+
header: WEBHOOK_ENDPOINT_STATUS_TO_MESSAGE_MAP[status],
|
|
8
|
+
actions
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { WebhookEndpointStatusCallout as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RoleColor } from '@galaxy-io/dls/theme/tokens/types';
|
|
2
|
+
import { WebhookEndpointStatus } from './types';
|
|
3
|
+
export declare const WEBHOOK_CONNECTOR_NAME = "webhook";
|
|
4
|
+
export declare const WEBHOOK_DOCS_PATH = "/pages/connectors/sources/webhook";
|
|
5
|
+
export declare const WEBHOOK_RESOURCE_PLACEHOLDER = "orders...";
|
|
6
|
+
export declare const WEBHOOK_RESOURCE_TOOLTIP = "Letters, digits, - and _. The name becomes the last part of the delivery URL.";
|
|
7
|
+
export declare const WEBHOOK_RESOURCE_NAME_PATTERN: RegExp;
|
|
8
|
+
export declare const WEBHOOK_ENDPOINT_STATUS_TO_LABEL_MAP: Record<WebhookEndpointStatus, string>;
|
|
9
|
+
export declare const WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP: Record<WebhookEndpointStatus, RoleColor | undefined>;
|
|
10
|
+
export declare const WEBHOOK_ENDPOINT_STATUS_TO_MESSAGE_MAP: Record<WebhookEndpointStatus, string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { WebhookEndpointStatus } from "./types.js";
|
|
2
|
+
//#region src/components/webhooks/constants.ts
|
|
3
|
+
var WEBHOOK_CONNECTOR_NAME = "webhook";
|
|
4
|
+
var WEBHOOK_DOCS_PATH = "/pages/connectors/sources/webhook";
|
|
5
|
+
var WEBHOOK_RESOURCE_PLACEHOLDER = "orders...";
|
|
6
|
+
var WEBHOOK_RESOURCE_TOOLTIP = "Letters, digits, - and _. The name becomes the last part of the delivery URL.";
|
|
7
|
+
var WEBHOOK_RESOURCE_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
8
|
+
var WEBHOOK_ENDPOINT_STATUS_TO_LABEL_MAP = {
|
|
9
|
+
[WebhookEndpointStatus.NO_KEY]: "No key",
|
|
10
|
+
[WebhookEndpointStatus.NO_PIPELINE]: "No pipeline",
|
|
11
|
+
[WebhookEndpointStatus.PIPELINE_DELETED]: "Pipeline deleted",
|
|
12
|
+
[WebhookEndpointStatus.OFF]: "Off",
|
|
13
|
+
[WebhookEndpointStatus.NOT_RUNNING]: "Not running",
|
|
14
|
+
[WebhookEndpointStatus.WAITING]: "Waiting",
|
|
15
|
+
[WebhookEndpointStatus.LIVE]: "Live"
|
|
16
|
+
};
|
|
17
|
+
var WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP = {
|
|
18
|
+
[WebhookEndpointStatus.NO_KEY]: void 0,
|
|
19
|
+
[WebhookEndpointStatus.NO_PIPELINE]: void 0,
|
|
20
|
+
[WebhookEndpointStatus.PIPELINE_DELETED]: "yellow",
|
|
21
|
+
[WebhookEndpointStatus.OFF]: void 0,
|
|
22
|
+
[WebhookEndpointStatus.NOT_RUNNING]: "yellow",
|
|
23
|
+
[WebhookEndpointStatus.WAITING]: "orange",
|
|
24
|
+
[WebhookEndpointStatus.LIVE]: "blue"
|
|
25
|
+
};
|
|
26
|
+
var WEBHOOK_ENDPOINT_STATUS_TO_MESSAGE_MAP = {
|
|
27
|
+
[WebhookEndpointStatus.NO_KEY]: "No signing key. Generate one under Secrets.",
|
|
28
|
+
[WebhookEndpointStatus.NO_PIPELINE]: "Create a pipeline from this source to receive payloads.",
|
|
29
|
+
[WebhookEndpointStatus.PIPELINE_DELETED]: "Pipeline deleted. Senders retry until a new one runs.",
|
|
30
|
+
[WebhookEndpointStatus.OFF]: "Add a resource to the pipeline to receive payloads.",
|
|
31
|
+
[WebhookEndpointStatus.NOT_RUNNING]: "Pipeline not running. Senders retry until it starts.",
|
|
32
|
+
[WebhookEndpointStatus.WAITING]: "Payloads wait until the pipeline reads every resource.",
|
|
33
|
+
[WebhookEndpointStatus.LIVE]: "These endpoints are live and can receive payloads."
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { WEBHOOK_CONNECTOR_NAME, WEBHOOK_DOCS_PATH, WEBHOOK_ENDPOINT_STATUS_TO_HUE_MAP, WEBHOOK_ENDPOINT_STATUS_TO_LABEL_MAP, WEBHOOK_ENDPOINT_STATUS_TO_MESSAGE_MAP, WEBHOOK_RESOURCE_NAME_PATTERN, WEBHOOK_RESOURCE_PLACEHOLDER, WEBHOOK_RESOURCE_TOOLTIP };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Connection } from '../../../gen/ingestion/v1/connections_pb';
|
|
2
|
+
import { Pipeline } from '../../../gen/ingestion/v1/pipelines_pb';
|
|
3
|
+
interface WebhookEndpointSyncInput {
|
|
4
|
+
sourceConnection: Connection | null | undefined;
|
|
5
|
+
pipelineId: Pipeline["id"];
|
|
6
|
+
}
|
|
7
|
+
export declare const useWebhookEndpointSync: () => (input: WebhookEndpointSyncInput) => Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createPutWebhookEndpointRequest, getWebhookRouteResources, getWebhookSourceRouteKeys, isSameWebhookResources, isWebhookConnector } from "../utils.js";
|
|
2
|
+
import { getErrorMessage, ignoreNotFoundError } from "../../../utils/errors.js";
|
|
3
|
+
import { createGetWebhookEndpointInput, createGetWebhookEndpointQueryOptions, usePutWebhookEndpointMutation } from "../../../api/queries/webhooks.js";
|
|
4
|
+
import { createGetPipelineInput, createGetPipelineQueryOptions } from "../../../api/queries/pipelines.js";
|
|
5
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { useTransport } from "@connectrpc/connect-query";
|
|
7
|
+
import { ToastVariant } from "@galaxy-io/dls/toast/Toast";
|
|
8
|
+
import { useToast } from "@galaxy-io/dls/toast/useToast";
|
|
9
|
+
//#region src/components/webhooks/hooks/useWebhookEndpointSync.ts
|
|
10
|
+
var pendingSyncs = /* @__PURE__ */ new Map();
|
|
11
|
+
var useWebhookEndpointSync = () => {
|
|
12
|
+
const { toast } = useToast();
|
|
13
|
+
const queryClient = useQueryClient();
|
|
14
|
+
const transport = useTransport();
|
|
15
|
+
const { mutateAsync: putEndpoint } = usePutWebhookEndpointMutation();
|
|
16
|
+
const sync = async ({ sourceConnection, pipelineId }) => {
|
|
17
|
+
if (!sourceConnection || !isWebhookConnector(sourceConnection.connector)) return;
|
|
18
|
+
const sourceConnectionId = sourceConnection.id;
|
|
19
|
+
try {
|
|
20
|
+
const pipeline = await queryClient.fetchQuery({
|
|
21
|
+
...createGetPipelineQueryOptions({
|
|
22
|
+
input: createGetPipelineInput(pipelineId),
|
|
23
|
+
transport
|
|
24
|
+
}),
|
|
25
|
+
staleTime: 0
|
|
26
|
+
}).then((response) => response.pipeline, ignoreNotFoundError);
|
|
27
|
+
if (pipeline?.deletedAt !== 0n) return;
|
|
28
|
+
const currentVersion = pipeline.currentVersion;
|
|
29
|
+
if (!currentVersion?.graph) return;
|
|
30
|
+
const graph = currentVersion.graph;
|
|
31
|
+
const expectedPipelineVersionId = currentVersion.id;
|
|
32
|
+
const routeKeys = getWebhookSourceRouteKeys(graph, sourceConnectionId);
|
|
33
|
+
const endpoint = await queryClient.fetchQuery({
|
|
34
|
+
...createGetWebhookEndpointQueryOptions({
|
|
35
|
+
input: createGetWebhookEndpointInput(sourceConnectionId),
|
|
36
|
+
transport
|
|
37
|
+
}),
|
|
38
|
+
staleTime: 0
|
|
39
|
+
}).then((response) => response.endpoint, ignoreNotFoundError);
|
|
40
|
+
const isBoundHere = endpoint?.pipelineId === pipelineId;
|
|
41
|
+
if (routeKeys.length === 0) {
|
|
42
|
+
if (endpoint && isBoundHere && (endpoint.enabled || endpoint.resources.length > 0)) await putEndpoint(createPutWebhookEndpointRequest({
|
|
43
|
+
sourceConnectionId,
|
|
44
|
+
endpoint,
|
|
45
|
+
patch: {
|
|
46
|
+
resources: [],
|
|
47
|
+
enabled: false
|
|
48
|
+
},
|
|
49
|
+
expectedPipelineVersionId
|
|
50
|
+
}));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!endpoint?.hasSigningSecret) {
|
|
54
|
+
toast({
|
|
55
|
+
variant: ToastVariant.WARNING,
|
|
56
|
+
header: "Webhook endpoint not set up",
|
|
57
|
+
description: "Generate a signing key under Secrets on the source."
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (endpoint.pipelineId && !isBoundHere) {
|
|
62
|
+
const boundPipeline = await queryClient.fetchQuery({
|
|
63
|
+
...createGetPipelineQueryOptions({
|
|
64
|
+
input: createGetPipelineInput(endpoint.pipelineId),
|
|
65
|
+
transport
|
|
66
|
+
}),
|
|
67
|
+
staleTime: 0
|
|
68
|
+
}).then((response) => response.pipeline, ignoreNotFoundError);
|
|
69
|
+
if (boundPipeline && boundPipeline.deletedAt === 0n) {
|
|
70
|
+
toast({
|
|
71
|
+
variant: ToastVariant.WARNING,
|
|
72
|
+
header: "Webhook endpoint unchanged",
|
|
73
|
+
description: `It stays bound to ${boundPipeline.name}.`
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const routeKey = isBoundHere && routeKeys.includes(endpoint.routeKey) ? endpoint.routeKey : routeKeys[0] ?? "";
|
|
79
|
+
const resources = getWebhookRouteResources(graph, routeKey);
|
|
80
|
+
if (isBoundHere && endpoint.routeKey === routeKey && endpoint.enabled && isSameWebhookResources(endpoint.resources, resources)) return;
|
|
81
|
+
await putEndpoint(createPutWebhookEndpointRequest({
|
|
82
|
+
sourceConnectionId,
|
|
83
|
+
endpoint,
|
|
84
|
+
patch: {
|
|
85
|
+
pipelineId,
|
|
86
|
+
routeKey,
|
|
87
|
+
resources,
|
|
88
|
+
enabled: true
|
|
89
|
+
},
|
|
90
|
+
expectedPipelineVersionId
|
|
91
|
+
}));
|
|
92
|
+
} catch (error) {
|
|
93
|
+
toast({
|
|
94
|
+
variant: ToastVariant.ERROR,
|
|
95
|
+
header: "Webhook endpoint not updated",
|
|
96
|
+
description: getErrorMessage(error, "Failed to update the webhook endpoint")
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return (input) => {
|
|
101
|
+
const sourceId = input.sourceConnection?.id;
|
|
102
|
+
if (!sourceId) return Promise.resolve();
|
|
103
|
+
const current = (pendingSyncs.get(sourceId) ?? Promise.resolve()).then(() => sync(input));
|
|
104
|
+
pendingSyncs.set(sourceId, current);
|
|
105
|
+
current.finally(() => {
|
|
106
|
+
if (pendingSyncs.get(sourceId) === current) pendingSyncs.delete(sourceId);
|
|
107
|
+
});
|
|
108
|
+
return current;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
//#endregion
|
|
112
|
+
export { useWebhookEndpointSync };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/components/webhooks/types.ts
|
|
2
|
+
var WebhookEndpointStatus = /* @__PURE__ */ function(WebhookEndpointStatus) {
|
|
3
|
+
WebhookEndpointStatus["NO_KEY"] = "NO_KEY";
|
|
4
|
+
WebhookEndpointStatus["NO_PIPELINE"] = "NO_PIPELINE";
|
|
5
|
+
WebhookEndpointStatus["PIPELINE_DELETED"] = "PIPELINE_DELETED";
|
|
6
|
+
WebhookEndpointStatus["OFF"] = "OFF";
|
|
7
|
+
WebhookEndpointStatus["NOT_RUNNING"] = "NOT_RUNNING";
|
|
8
|
+
WebhookEndpointStatus["WAITING"] = "WAITING";
|
|
9
|
+
WebhookEndpointStatus["LIVE"] = "LIVE";
|
|
10
|
+
return WebhookEndpointStatus;
|
|
11
|
+
}({});
|
|
12
|
+
//#endregion
|
|
13
|
+
export { WebhookEndpointStatus };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Connection } from '../../gen/ingestion/v1/connections_pb';
|
|
2
|
+
import { PipelineGraph } from '../../gen/ingestion/v1/pipelines_pb';
|
|
3
|
+
import { WebhookEndpointConfig } from '../../gen/ingestion/v1/webhooks_pb';
|
|
4
|
+
import { WebhookEndpointStatus } from './types';
|
|
5
|
+
export declare const isWebhookConnector: (connector: Connection["connector"] | undefined) => connector is "webhook";
|
|
6
|
+
export declare const getWebhookEndpointStatus: (endpoint: WebhookEndpointConfig | undefined, isPipelineDeleted: boolean) => WebhookEndpointStatus;
|
|
7
|
+
export declare const isWebhookPreviousKeyActive: (endpoint: WebhookEndpointConfig | undefined) => boolean;
|
|
8
|
+
export declare const createWebhookDeliveryBaseUrl: (deliveryUrl: WebhookEndpointConfig["deliveryUrl"] | undefined) => string | undefined;
|
|
9
|
+
export declare const createWebhookDeliveryUrl: (resource: string, deliveryUrl: WebhookEndpointConfig["deliveryUrl"] | undefined) => string | undefined;
|
|
10
|
+
export declare const createWebhookRouteKey: (sourceNodeId: string, sinkNodeId: string) => string;
|
|
11
|
+
export declare const getWebhookRouteResources: (graph: PipelineGraph | undefined, routeKey: WebhookEndpointConfig["routeKey"]) => string[];
|
|
12
|
+
export declare const getWebhookSourceRouteKeys: (graph: PipelineGraph | undefined, sourceConnectionId: Connection["id"]) => string[];
|
|
13
|
+
export declare const isSameWebhookResources: (left: string[], right: string[]) => boolean;
|
|
14
|
+
export declare const getWebhookResourceError: (resource: string) => "Use only letters, digits, - and _, up to 64 characters." | undefined;
|
|
15
|
+
export declare const createPutWebhookEndpointRequest: ({ sourceConnectionId, endpoint, patch, mintSecret, expectedPipelineVersionId, }: {
|
|
16
|
+
sourceConnectionId: Connection["id"];
|
|
17
|
+
endpoint: WebhookEndpointConfig | undefined;
|
|
18
|
+
patch?: Partial<Pick<WebhookEndpointConfig, "pipelineId" | "routeKey" | "resources" | "enabled">>;
|
|
19
|
+
mintSecret?: boolean;
|
|
20
|
+
expectedPipelineVersionId?: string;
|
|
21
|
+
}) => import('../../gen/ingestion/v1/webhooks_pb').PutWebhookEndpointRequest;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ConnectorKind } from "../../gen/ingestion/v1/common_pb.js";
|
|
2
|
+
import { PutWebhookEndpointRequestSchema, WebhookEndpointConfigSchema } from "../../gen/ingestion/v1/webhooks_pb.js";
|
|
3
|
+
import { WebhookEndpointStatus } from "./types.js";
|
|
4
|
+
import { WEBHOOK_CONNECTOR_NAME, WEBHOOK_RESOURCE_NAME_PATTERN } from "./constants.js";
|
|
5
|
+
import { create } from "@bufbuild/protobuf";
|
|
6
|
+
//#region src/components/webhooks/utils.ts
|
|
7
|
+
var isWebhookConnector = (connector) => connector === WEBHOOK_CONNECTOR_NAME;
|
|
8
|
+
var getWebhookEndpointStatus = (endpoint, isPipelineDeleted) => {
|
|
9
|
+
if (!endpoint?.hasSigningSecret) return WebhookEndpointStatus.NO_KEY;
|
|
10
|
+
if (!endpoint.pipelineId) return WebhookEndpointStatus.NO_PIPELINE;
|
|
11
|
+
if (isPipelineDeleted) return endpoint.enabled ? WebhookEndpointStatus.PIPELINE_DELETED : WebhookEndpointStatus.NO_PIPELINE;
|
|
12
|
+
if (!endpoint.enabled) return WebhookEndpointStatus.OFF;
|
|
13
|
+
if (!endpoint.accepting) return WebhookEndpointStatus.NOT_RUNNING;
|
|
14
|
+
if (!endpoint.routeReady) return WebhookEndpointStatus.WAITING;
|
|
15
|
+
return WebhookEndpointStatus.LIVE;
|
|
16
|
+
};
|
|
17
|
+
var isWebhookPreviousKeyActive = (endpoint) => !!endpoint && endpoint.previousKeyExpiresAt > BigInt(Date.now());
|
|
18
|
+
var createWebhookDeliveryBaseUrl = (deliveryUrl) => deliveryUrl || void 0;
|
|
19
|
+
var createWebhookDeliveryUrl = (resource, deliveryUrl) => {
|
|
20
|
+
const baseUrl = createWebhookDeliveryBaseUrl(deliveryUrl);
|
|
21
|
+
return baseUrl ? `${baseUrl}/${resource}` : void 0;
|
|
22
|
+
};
|
|
23
|
+
var createWebhookRouteKey = (sourceNodeId, sinkNodeId) => `route/${sourceNodeId}/${sinkNodeId}`;
|
|
24
|
+
var getWebhookRouteResources = (graph, routeKey) => [...new Set((graph?.edges ?? []).filter((edge) => edge.resource !== "" && createWebhookRouteKey(edge.fromNode, edge.toNode) === routeKey).map((edge) => edge.resource))].sort();
|
|
25
|
+
var getWebhookSourceRouteKeys = (graph, sourceConnectionId) => {
|
|
26
|
+
const sourceNodeIds = new Set((graph?.nodes ?? []).filter((node) => node.kind === ConnectorKind.SOURCE && node.connectionId === sourceConnectionId).map((node) => node.id));
|
|
27
|
+
return [...new Set((graph?.edges ?? []).filter((edge) => sourceNodeIds.has(edge.fromNode) && edge.resource !== "").map((edge) => createWebhookRouteKey(edge.fromNode, edge.toNode)))];
|
|
28
|
+
};
|
|
29
|
+
var isSameWebhookResources = (left, right) => [...left].sort().join("\n") === [...right].sort().join("\n");
|
|
30
|
+
var getWebhookResourceError = (resource) => WEBHOOK_RESOURCE_NAME_PATTERN.test(resource) ? void 0 : "Use only letters, digits, - and _, up to 64 characters.";
|
|
31
|
+
var createPutWebhookEndpointRequest = ({ sourceConnectionId, endpoint, patch = {}, mintSecret = false, expectedPipelineVersionId }) => create(PutWebhookEndpointRequestSchema, {
|
|
32
|
+
endpoint: create(WebhookEndpointConfigSchema, {
|
|
33
|
+
sourceConnectionId,
|
|
34
|
+
pipelineId: endpoint?.pipelineId ?? "",
|
|
35
|
+
routeKey: endpoint?.routeKey ?? "",
|
|
36
|
+
resources: endpoint?.resources ?? [],
|
|
37
|
+
enabled: endpoint?.enabled ?? false,
|
|
38
|
+
successStatus: endpoint?.successStatus ?? 0,
|
|
39
|
+
maxBodyBytes: endpoint?.maxBodyBytes ?? 0n,
|
|
40
|
+
...patch
|
|
41
|
+
}),
|
|
42
|
+
expectedRevision: endpoint?.revision ?? 0n,
|
|
43
|
+
mintSecret,
|
|
44
|
+
expectedPipelineVersionId
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createPutWebhookEndpointRequest, createWebhookDeliveryBaseUrl, createWebhookDeliveryUrl, createWebhookRouteKey, getWebhookEndpointStatus, getWebhookResourceError, getWebhookRouteResources, getWebhookSourceRouteKeys, isSameWebhookResources, isWebhookConnector, isWebhookPreviousKeyActive };
|
|
@@ -67,6 +67,12 @@ export type ConnectorSpec = Message<"ingestion.v1.ConnectorSpec"> & {
|
|
|
67
67
|
* @generated from field: bool is_preview = 14;
|
|
68
68
|
*/
|
|
69
69
|
isPreview: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Ingress verifier for sources that receive webhooks. Empty otherwise.
|
|
72
|
+
*
|
|
73
|
+
* @generated from field: string webhook_verifier = 15;
|
|
74
|
+
*/
|
|
75
|
+
webhookVerifier: string;
|
|
70
76
|
};
|
|
71
77
|
/**
|
|
72
78
|
* Describes the message ingestion.v1.ConnectorSpec.
|