Skip to content

Commit

Permalink
Services and Syncs support (jitsucom#1021)
Browse files Browse the repository at this point in the history
* Added support for Service entity.
* Extract components from ConfigEditor. Now it is possible to build custom forms that looks like ConfigEditor
* WIP: oauth integratuion

Co-authored-by: Vladimir Klimontovich <[email protected]>
  • Loading branch information
absorbb and vklimontovich authored Jun 26, 2023
1 parent ad2233c commit e3f1c57
Show file tree
Hide file tree
Showing 47 changed files with 2,723 additions and 337 deletions.
24 changes: 18 additions & 6 deletions libs/jitsu-js/src/destination-plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@ export function satisfyDomainFilter(filter: string, subject: string | undefined)

export function applyFilters(event: AnalyticsClientEvent, creds: CommonDestinationCredentials): boolean {
const { hosts = "*", events = "*" } = creds;
const eventsArray = events.split("\n");
return (
!!hosts.split("\n").find(hostFilter => satisfyDomainFilter(hostFilter, event.context?.host)) &&
(!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.type)) ||
!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.event)))
);
try {
const eventsArray = Array.isArray(events) ? events : events.split("\n");
const hostsArray = Array.isArray(hosts) ? hosts : hosts.split("\n");
return (
!!hostsArray.find(hostFilter => satisfyDomainFilter(hostFilter, event.context?.host)) &&
(!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.type)) ||
!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.event)))
);
} catch (e) {
console.warn(
`Failed to apply filters: ${e.message}. Typeof events: ${typeof events}, typeof hosts: ${typeof hosts}. Values`,
events,
hosts
);
throw new Error(
`Failed to apply filters: ${e.message}. Typeof events: ${typeof events}, typeof hosts: ${typeof hosts}`
);
}
}

export const internalDestinationPlugins: Record<string, InternalPlugin<any>> = {
Expand Down
10 changes: 7 additions & 3 deletions libs/juava/src/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ const defaultSeed = "dea42a58-acf4-45af-85bb-e77e94bd5025";
const globalSeed: string[] = (process.env.GLOBAL_HASH_SECRET || defaultSeed).split(",").map(s => s.trim());

function hashInternal(secret: string, randomSeed: string, globalSeed: string) {
const hash = crypto.createHash("sha512");
hash.update(secret + randomSeed + globalSeed);
return `${randomSeed}.${hash.digest("hex")}`;
return `${randomSeed}.${hash("sha512", secret + randomSeed + globalSeed)}`;
}

export function hash(algorithm: string, value: string): string {
const hash = crypto.createHash(algorithm);
hash.update(value);
return hash.digest("hex");
}

export function hint(key: string) {
Expand Down
53 changes: 53 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions webapps/console/components/CodeEditor/SnippedEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Editor from "@monaco-editor/react";
import React from "react";
import { Radio } from "antd";
import { editor } from "monaco-editor";

/**
* See tagDestination comments, due to limitations of the react-jsonschema-form we can't use
Expand All @@ -19,6 +20,9 @@ export type SnippedEditorProps = {
languages?: SupportedLanguages[];
height?: number;
onChange: (value: SnippedEditorValue) => void;
options?: editor.IStandaloneEditorConstructionOptions;
//automatically fold code on provided level of indentation on editor mount
foldLevel?: number;
};

/**
Expand Down Expand Up @@ -75,6 +79,13 @@ export const SnippedEditor: React.FC<SnippedEditorProps> = props => {
}}
language={valueParsed.lang?.toLowerCase() || "html"}
height={props.height ? `${props.height}px` : "500px"}
onMount={
props.foldLevel
? editor => {
editor.getAction(`editor.foldLevel${props.foldLevel}`)?.run();
}
: undefined
}
className="rounded-lg"
options={{
renderLineHighlight: "none",
Expand All @@ -98,6 +109,7 @@ export const SnippedEditor: React.FC<SnippedEditorProps> = props => {
},
hideCursorInOverviewRuler: true,
overviewRulerLanes: 0,
...props.options,
}}
/>
</div>
Expand Down
Loading

0 comments on commit e3f1c57

Please sign in to comment.