@schnebel-crm/integration-sdk 0.1.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.
@@ -0,0 +1,12 @@
1
+ //#region src/config.d.ts
2
+ interface IntegrationProjectConfig {
3
+ /** Entry point for the integration (default: "./src/index.ts") */
4
+ entry?: string;
5
+ /** Output directory for the build (default: "./dist") */
6
+ outDir?: string;
7
+ /** GitHub repository URL (required for public App Store integrations) */
8
+ github?: string;
9
+ }
10
+ declare function defineConfig(config: IntegrationProjectConfig): IntegrationProjectConfig;
11
+ //#endregion
12
+ export { defineConfig as n, IntegrationProjectConfig as t };
@@ -0,0 +1,7 @@
1
+ //#region src/config.ts
2
+ function defineConfig(config) {
3
+ return config;
4
+ }
5
+
6
+ //#endregion
7
+ export { defineConfig as t };
@@ -0,0 +1,2 @@
1
+ import { n as defineConfig, t as IntegrationProjectConfig } from "./config-BB4KcLpw.mjs";
2
+ export { IntegrationProjectConfig, defineConfig };
@@ -0,0 +1,3 @@
1
+ import { t as defineConfig } from "./config-kHZazM_E.mjs";
2
+
3
+ export { defineConfig };
@@ -0,0 +1,93 @@
1
+ import { n as defineConfig, t as IntegrationProjectConfig } from "./config-BB4KcLpw.mjs";
2
+
3
+ //#region src/types.d.ts
4
+ declare const INTEGRATION_CATEGORIES: readonly ["email", "calendar", "communication", "analytics", "storage", "payment", "marketing", "automation", "other"];
5
+ type IntegrationCategory = (typeof INTEGRATION_CATEGORIES)[number];
6
+ declare const AUTH_TYPES: readonly ["none", "api_key", "oauth2", "basic", "custom"];
7
+ type AuthType = (typeof AUTH_TYPES)[number];
8
+ declare const CONFIG_FIELD_TYPES: readonly ["text", "number", "boolean", "select", "secret", "email", "url"];
9
+ type ConfigFieldType = (typeof CONFIG_FIELD_TYPES)[number];
10
+ type ConfigField = {
11
+ key: string;
12
+ label: string;
13
+ type: ConfigFieldType;
14
+ required: boolean;
15
+ description?: string;
16
+ placeholder?: string;
17
+ defaultValue?: string | number | boolean;
18
+ options?: Array<{
19
+ value: string;
20
+ label: string;
21
+ }>;
22
+ group?: string;
23
+ };
24
+ type CredentialField = {
25
+ key: string;
26
+ label: string;
27
+ type: "text" | "secret" | "oauth_token";
28
+ required: boolean;
29
+ description?: string;
30
+ placeholder?: string;
31
+ };
32
+ declare const CAPABILITIES: readonly ["send_email", "receive_email", "sync_contacts", "sync_calendar", "sync_tasks", "webhooks", "import_data", "export_data", "notifications", "file_storage", "analytics", "lead_tracking"];
33
+ type IntegrationCapability = (typeof CAPABILITIES)[number];
34
+ interface IntegrationDefinition<TConfig extends string = string, TCredential extends string = string> {
35
+ id: string;
36
+ name: string;
37
+ description: string;
38
+ icon: string;
39
+ category: IntegrationCategory;
40
+ authType: AuthType;
41
+ version: string;
42
+ capabilities: IntegrationCapability[];
43
+ configFields: (ConfigField & {
44
+ key: TConfig;
45
+ })[];
46
+ credentialFields: (CredentialField & {
47
+ key: TCredential;
48
+ })[];
49
+ webhookSupport: boolean;
50
+ multiInstance?: boolean;
51
+ documentationUrl?: string;
52
+ tags?: string[];
53
+ }
54
+ type InferConfigKeys<T extends IntegrationDefinition> = T["configFields"][number]["key"];
55
+ type InferCredentialKeys<T extends IntegrationDefinition> = T["credentialFields"][number]["key"];
56
+ interface IntegrationContext<TConfig extends Record<string, unknown> = Record<string, unknown>, TCredentials extends Record<string, unknown> = Record<string, unknown>> {
57
+ config: TConfig;
58
+ credentials: TCredentials;
59
+ organizationId: string;
60
+ installationId: string;
61
+ }
62
+ type ConnectionTestResult = {
63
+ success: true;
64
+ } | {
65
+ success: false;
66
+ error: string;
67
+ };
68
+ interface IntegrationAction<TInput = unknown, TOutput = unknown> {
69
+ id: string;
70
+ name: string;
71
+ description: string;
72
+ execute(ctx: IntegrationContext, input: TInput): Promise<TOutput>;
73
+ }
74
+ interface IntegrationHandler {
75
+ testConnection(ctx: IntegrationContext): Promise<ConnectionTestResult>;
76
+ onInstall?(ctx: IntegrationContext): Promise<void>;
77
+ onUninstall?(ctx: IntegrationContext): Promise<void>;
78
+ actions: IntegrationAction[];
79
+ }
80
+ //#endregion
81
+ //#region src/handler.d.ts
82
+ declare function defineHandler<TConfig extends Record<string, unknown>, TCredentials extends Record<string, unknown>>(handler: {
83
+ testConnection(ctx: IntegrationContext<TConfig, TCredentials>): Promise<ConnectionTestResult>;
84
+ onInstall?(ctx: IntegrationContext<TConfig, TCredentials>): Promise<void>;
85
+ onUninstall?(ctx: IntegrationContext<TConfig, TCredentials>): Promise<void>;
86
+ actions: IntegrationAction[];
87
+ }): IntegrationHandler;
88
+ declare function createAction<TInput = unknown, TOutput = unknown>(action: IntegrationAction<TInput, TOutput>): IntegrationAction;
89
+ //#endregion
90
+ //#region src/helpers.d.ts
91
+ declare function defineIntegration<TConfig extends string, TCredential extends string>(definition: IntegrationDefinition<TConfig, TCredential>): IntegrationDefinition<TConfig, TCredential>;
92
+ //#endregion
93
+ export { AUTH_TYPES, type AuthType, CAPABILITIES, CONFIG_FIELD_TYPES, type ConfigField, type ConfigFieldType, type ConnectionTestResult, type CredentialField, INTEGRATION_CATEGORIES, type InferConfigKeys, type InferCredentialKeys, type IntegrationAction, type IntegrationCapability, type IntegrationCategory, type IntegrationContext, type IntegrationDefinition, type IntegrationHandler, type IntegrationProjectConfig, createAction, defineConfig, defineHandler, defineIntegration };
package/dist/index.mjs ADDED
@@ -0,0 +1,62 @@
1
+ import { t as defineConfig } from "./config-kHZazM_E.mjs";
2
+
3
+ //#region src/types.ts
4
+ const INTEGRATION_CATEGORIES = [
5
+ "email",
6
+ "calendar",
7
+ "communication",
8
+ "analytics",
9
+ "storage",
10
+ "payment",
11
+ "marketing",
12
+ "automation",
13
+ "other"
14
+ ];
15
+ const AUTH_TYPES = [
16
+ "none",
17
+ "api_key",
18
+ "oauth2",
19
+ "basic",
20
+ "custom"
21
+ ];
22
+ const CONFIG_FIELD_TYPES = [
23
+ "text",
24
+ "number",
25
+ "boolean",
26
+ "select",
27
+ "secret",
28
+ "email",
29
+ "url"
30
+ ];
31
+ const CAPABILITIES = [
32
+ "send_email",
33
+ "receive_email",
34
+ "sync_contacts",
35
+ "sync_calendar",
36
+ "sync_tasks",
37
+ "webhooks",
38
+ "import_data",
39
+ "export_data",
40
+ "notifications",
41
+ "file_storage",
42
+ "analytics",
43
+ "lead_tracking"
44
+ ];
45
+
46
+ //#endregion
47
+ //#region src/handler.ts
48
+ function defineHandler(handler) {
49
+ return handler;
50
+ }
51
+ function createAction(action) {
52
+ return action;
53
+ }
54
+
55
+ //#endregion
56
+ //#region src/helpers.ts
57
+ function defineIntegration(definition) {
58
+ return Object.freeze(definition);
59
+ }
60
+
61
+ //#endregion
62
+ export { AUTH_TYPES, CAPABILITIES, CONFIG_FIELD_TYPES, INTEGRATION_CATEGORIES, createAction, defineConfig, defineHandler, defineIntegration };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@schnebel-crm/integration-sdk",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "SDK for building custom integrations for Schnebel CRM",
6
+ "main": "./dist/index.mjs",
7
+ "types": "./dist/index.d.mts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.mts",
11
+ "import": "./dist/index.mjs"
12
+ },
13
+ "./config": {
14
+ "types": "./dist/config.d.mts",
15
+ "import": "./dist/config.mjs"
16
+ }
17
+ },
18
+ "files": ["dist"],
19
+ "scripts": {
20
+ "build": "tsdown src/index.ts src/config.ts --format esm --dts --clean",
21
+ "check-types": "tsc --noEmit",
22
+ "prepublishOnly": "pnpm run build"
23
+ },
24
+ "keywords": ["schnebel", "crm", "integration", "sdk", "plugin"],
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/schnebel-it/schnebel-crm"
29
+ },
30
+ "devDependencies": {
31
+ "tsdown": "^0.16.5",
32
+ "typescript": "^5"
33
+ }
34
+ }