@shin1ohno/sage 0.7.8 → 0.8.4
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 +26 -8
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +30 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/validation.d.ts +130 -0
- package/dist/config/validation.d.ts.map +1 -0
- package/dist/config/validation.js +53 -0
- package/dist/config/validation.js.map +1 -0
- package/dist/index.js +677 -214
- package/dist/index.js.map +1 -1
- package/dist/integrations/calendar-service.d.ts +6 -3
- package/dist/integrations/calendar-service.d.ts.map +1 -1
- package/dist/integrations/calendar-service.js +26 -4
- package/dist/integrations/calendar-service.js.map +1 -1
- package/dist/integrations/calendar-source-manager.d.ts +302 -0
- package/dist/integrations/calendar-source-manager.d.ts.map +1 -0
- package/dist/integrations/calendar-source-manager.js +862 -0
- package/dist/integrations/calendar-source-manager.js.map +1 -0
- package/dist/integrations/google-calendar-service.d.ts +176 -0
- package/dist/integrations/google-calendar-service.d.ts.map +1 -0
- package/dist/integrations/google-calendar-service.js +745 -0
- package/dist/integrations/google-calendar-service.js.map +1 -0
- package/dist/oauth/google-oauth-handler.d.ts +149 -0
- package/dist/oauth/google-oauth-handler.d.ts.map +1 -0
- package/dist/oauth/google-oauth-handler.js +365 -0
- package/dist/oauth/google-oauth-handler.js.map +1 -0
- package/dist/types/config.d.ts +15 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +21 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/google-calendar-types.d.ts +139 -0
- package/dist/types/google-calendar-types.d.ts.map +1 -0
- package/dist/types/google-calendar-types.js +46 -0
- package/dist/types/google-calendar-types.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +22 -4
- package/dist/version.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -61,6 +61,17 @@ sage:
|
|
|
61
61
|
- Estimated: 90 minutes
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
### Google Calendar Integration
|
|
65
|
+
|
|
66
|
+
sage now supports multiple calendar sources:
|
|
67
|
+
|
|
68
|
+
- **macOS**: Use EventKit, Google Calendar, or both simultaneously
|
|
69
|
+
- **Linux/Windows**: Use Google Calendar as your primary calendar source
|
|
70
|
+
- **Automatic fallback**: If one source fails, sage automatically uses the other
|
|
71
|
+
- **Event deduplication**: Intelligent merging prevents duplicate events
|
|
72
|
+
|
|
73
|
+
**Setup**: See [Configuration Guide](docs/CONFIGURATION.md#google-calendar-integration) for Google OAuth setup instructions.
|
|
74
|
+
|
|
64
75
|
### Smart Reminder Routing
|
|
65
76
|
|
|
66
77
|
Tasks are automatically routed to the appropriate system:
|
|
@@ -75,11 +86,14 @@ Tasks are automatically routed to the appropriate system:
|
|
|
75
86
|
|
|
76
87
|
| クライアント | サーバー | Apple Reminders | Calendar | Notion |
|
|
77
88
|
|--------------|----------|----------------|----------|--------|
|
|
78
|
-
| Claude Desktop/Code | macOS (直接) | AppleScript |
|
|
79
|
-
| Claude
|
|
80
|
-
| Claude
|
|
89
|
+
| Claude Desktop/Code | macOS (直接) | AppleScript | EventKit + Google Calendar | MCP |
|
|
90
|
+
| Claude Desktop/Code | Linux/Windows (直接) | - | Google Calendar | MCP |
|
|
91
|
+
| Claude iOS/iPadOS | macOS (Remote MCP) | AppleScript | EventKit + Google Calendar | MCP |
|
|
92
|
+
| Claude iOS/iPadOS | Linux/Windows (Remote MCP) | - | Google Calendar | MCP |
|
|
93
|
+
| Claude Web | macOS (Remote MCP) | AppleScript | EventKit + Google Calendar | MCP |
|
|
94
|
+
| Claude Web | Linux/Windows (Remote MCP) | - | Google Calendar | MCP |
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
**Apple Reminders requires macOS** (AppleScript). **Calendar support** is available on all platforms via Google Calendar, with optional EventKit integration on macOS.
|
|
83
97
|
|
|
84
98
|
## Tools
|
|
85
99
|
|
|
@@ -105,11 +119,15 @@ Tasks are automatically routed to the appropriate system:
|
|
|
105
119
|
|
|
106
120
|
## Requirements
|
|
107
121
|
|
|
108
|
-
- **
|
|
109
|
-
-
|
|
110
|
-
|
|
122
|
+
- **Node.js >= 18.0.0**
|
|
123
|
+
- **Notion MCP server** (任意、Notion 統合用)
|
|
124
|
+
|
|
125
|
+
### Platform-Specific Requirements
|
|
126
|
+
|
|
127
|
+
- **macOS**: Full feature support (Apple Reminders, EventKit, Google Calendar)
|
|
128
|
+
- **Linux/Windows**: Calendar features via Google Calendar API (Apple Reminders not available)
|
|
111
129
|
|
|
112
|
-
**注意**:
|
|
130
|
+
**注意**: Apple Reminders 機能を使用する場合は macOS が必要です。Google Calendar のみを使用する場合は、Linux/Windows でも動作します。
|
|
113
131
|
|
|
114
132
|
## Development
|
|
115
133
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOpD,qBAAa,YAAY;IACvB;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,MAAM;IAI7B;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,MAAM;IAI9B;;OAEG;WACU,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IASvC;;;OAGG;WACU,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IA8CxC;;OAEG;WACU,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BpD;;OAEG;IACH,MAAM,CAAC,gBAAgB,IAAI,UAAU;IAUrC;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;CAO/E"}
|
package/dist/config/loader.js
CHANGED
|
@@ -6,6 +6,7 @@ import { readFile, writeFile, mkdir, access } from 'node:fs/promises';
|
|
|
6
6
|
import { homedir } from 'node:os';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { DEFAULT_CONFIG } from '../types/config.js';
|
|
9
|
+
import { validateCalendarSources } from './validation.js';
|
|
9
10
|
const SAGE_DIR = '.sage';
|
|
10
11
|
const CONFIG_FILE = 'config.json';
|
|
11
12
|
export class ConfigLoader {
|
|
@@ -46,6 +47,24 @@ export class ConfigLoader {
|
|
|
46
47
|
if (!parsed.version || !parsed.user) {
|
|
47
48
|
throw new Error('Invalid configuration file structure');
|
|
48
49
|
}
|
|
50
|
+
// Migrate config if calendar.sources is missing
|
|
51
|
+
let migrated = false;
|
|
52
|
+
if (!parsed.calendar.sources) {
|
|
53
|
+
// Deep copy to avoid reference sharing
|
|
54
|
+
parsed.calendar.sources = JSON.parse(JSON.stringify(DEFAULT_CONFIG.calendar.sources));
|
|
55
|
+
migrated = true;
|
|
56
|
+
}
|
|
57
|
+
// Validate calendar.sources if present
|
|
58
|
+
if (parsed.calendar.sources) {
|
|
59
|
+
const validation = validateCalendarSources(parsed.calendar.sources);
|
|
60
|
+
if (!validation.success) {
|
|
61
|
+
throw new Error(`Invalid calendar sources configuration: ${validation.error?.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Save migrated config
|
|
65
|
+
if (migrated) {
|
|
66
|
+
await this.save(parsed);
|
|
67
|
+
}
|
|
49
68
|
return parsed;
|
|
50
69
|
}
|
|
51
70
|
catch (error) {
|
|
@@ -61,6 +80,14 @@ export class ConfigLoader {
|
|
|
61
80
|
static async save(config) {
|
|
62
81
|
const configDir = this.getConfigDir();
|
|
63
82
|
const configPath = this.getConfigPath();
|
|
83
|
+
// Validate calendar.sources (required)
|
|
84
|
+
if (!config.calendar.sources) {
|
|
85
|
+
throw new Error('Missing required field: calendar.sources');
|
|
86
|
+
}
|
|
87
|
+
const validation = validateCalendarSources(config.calendar.sources);
|
|
88
|
+
if (!validation.success) {
|
|
89
|
+
throw new Error(`Invalid calendar sources configuration: ${validation.error?.message}`);
|
|
90
|
+
}
|
|
64
91
|
// Ensure the directory exists
|
|
65
92
|
await mkdir(configDir, { recursive: true });
|
|
66
93
|
// Update timestamp
|
|
@@ -75,8 +102,10 @@ export class ConfigLoader {
|
|
|
75
102
|
* Get the default configuration
|
|
76
103
|
*/
|
|
77
104
|
static getDefaultConfig() {
|
|
105
|
+
// Deep copy DEFAULT_CONFIG to avoid reference sharing
|
|
106
|
+
const config = JSON.parse(JSON.stringify(DEFAULT_CONFIG));
|
|
78
107
|
return {
|
|
79
|
-
...
|
|
108
|
+
...config,
|
|
80
109
|
createdAt: new Date().toISOString(),
|
|
81
110
|
lastUpdated: new Date().toISOString(),
|
|
82
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB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AU,GAAG,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,2CAA2C,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,CACvE,CAAC;QACJ,CAAC;QAED,8BAA8B;QAC9B,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5C,mBAAmB;QACnB,MAAM,aAAa,GAAe;YAChC,GAAG,MAAM;YACT,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;QAEF,wCAAwC;QACxC,MAAM,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB;QACrB,sDAAsD;QACtD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAe,CAAC;QACxE,OAAO;YACL,GAAG,MAAM;YACT,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAgB,EAAE,OAA4B;QAC/D,OAAO;YACL,GAAG,IAAI;YACP,GAAG,OAAO;YACV,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration validation schemas using Zod
|
|
3
|
+
* Provides runtime type validation for user configuration
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* EventKit source configuration schema
|
|
8
|
+
*/
|
|
9
|
+
export declare const EventKitSourceConfigSchema: z.ZodObject<{
|
|
10
|
+
enabled: z.ZodBoolean;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
}, {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Google Calendar source configuration schema
|
|
18
|
+
*/
|
|
19
|
+
export declare const GoogleCalendarSourceConfigSchema: z.ZodObject<{
|
|
20
|
+
enabled: z.ZodBoolean;
|
|
21
|
+
defaultCalendar: z.ZodDefault<z.ZodString>;
|
|
22
|
+
excludedCalendars: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
23
|
+
syncInterval: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
enableNotifications: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
defaultCalendar: string;
|
|
28
|
+
excludedCalendars: string[];
|
|
29
|
+
syncInterval: number;
|
|
30
|
+
enableNotifications: boolean;
|
|
31
|
+
}, {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
defaultCalendar?: string | undefined;
|
|
34
|
+
excludedCalendars?: string[] | undefined;
|
|
35
|
+
syncInterval?: number | undefined;
|
|
36
|
+
enableNotifications?: boolean | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Calendar sources configuration schema
|
|
40
|
+
* Validates that at least one calendar source is enabled
|
|
41
|
+
*/
|
|
42
|
+
export declare const CalendarSourcesSchema: z.ZodEffects<z.ZodObject<{
|
|
43
|
+
eventkit: z.ZodObject<{
|
|
44
|
+
enabled: z.ZodBoolean;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
}, {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
google: z.ZodObject<{
|
|
51
|
+
enabled: z.ZodBoolean;
|
|
52
|
+
defaultCalendar: z.ZodDefault<z.ZodString>;
|
|
53
|
+
excludedCalendars: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
54
|
+
syncInterval: z.ZodDefault<z.ZodNumber>;
|
|
55
|
+
enableNotifications: z.ZodDefault<z.ZodBoolean>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
defaultCalendar: string;
|
|
59
|
+
excludedCalendars: string[];
|
|
60
|
+
syncInterval: number;
|
|
61
|
+
enableNotifications: boolean;
|
|
62
|
+
}, {
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
defaultCalendar?: string | undefined;
|
|
65
|
+
excludedCalendars?: string[] | undefined;
|
|
66
|
+
syncInterval?: number | undefined;
|
|
67
|
+
enableNotifications?: boolean | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
eventkit: {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
};
|
|
73
|
+
google: {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
defaultCalendar: string;
|
|
76
|
+
excludedCalendars: string[];
|
|
77
|
+
syncInterval: number;
|
|
78
|
+
enableNotifications: boolean;
|
|
79
|
+
};
|
|
80
|
+
}, {
|
|
81
|
+
eventkit: {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
};
|
|
84
|
+
google: {
|
|
85
|
+
enabled: boolean;
|
|
86
|
+
defaultCalendar?: string | undefined;
|
|
87
|
+
excludedCalendars?: string[] | undefined;
|
|
88
|
+
syncInterval?: number | undefined;
|
|
89
|
+
enableNotifications?: boolean | undefined;
|
|
90
|
+
};
|
|
91
|
+
}>, {
|
|
92
|
+
eventkit: {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
};
|
|
95
|
+
google: {
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
defaultCalendar: string;
|
|
98
|
+
excludedCalendars: string[];
|
|
99
|
+
syncInterval: number;
|
|
100
|
+
enableNotifications: boolean;
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
eventkit: {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
};
|
|
106
|
+
google: {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
defaultCalendar?: string | undefined;
|
|
109
|
+
excludedCalendars?: string[] | undefined;
|
|
110
|
+
syncInterval?: number | undefined;
|
|
111
|
+
enableNotifications?: boolean | undefined;
|
|
112
|
+
};
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Validate calendar sources configuration
|
|
116
|
+
* @param sources - The calendar sources configuration to validate
|
|
117
|
+
* @returns Validation result with parsed data or error
|
|
118
|
+
*/
|
|
119
|
+
export declare function validateCalendarSources(sources: unknown): {
|
|
120
|
+
success: boolean;
|
|
121
|
+
data?: z.infer<typeof CalendarSourcesSchema>;
|
|
122
|
+
error?: z.ZodError;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Type exports for validated schemas
|
|
126
|
+
*/
|
|
127
|
+
export type ValidatedCalendarSources = z.infer<typeof CalendarSourcesSchema>;
|
|
128
|
+
export type ValidatedEventKitSourceConfig = z.infer<typeof EventKitSourceConfigSchema>;
|
|
129
|
+
export type ValidatedGoogleCalendarSourceConfig = z.infer<typeof GoogleCalendarSourceConfigSchema>;
|
|
130
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;EAErC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;EAM3C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW/B,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;CACpB,CAcA;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC7E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACvF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration validation schemas using Zod
|
|
3
|
+
* Provides runtime type validation for user configuration
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* EventKit source configuration schema
|
|
8
|
+
*/
|
|
9
|
+
export const EventKitSourceConfigSchema = z.object({
|
|
10
|
+
enabled: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Google Calendar source configuration schema
|
|
14
|
+
*/
|
|
15
|
+
export const GoogleCalendarSourceConfigSchema = z.object({
|
|
16
|
+
enabled: z.boolean(),
|
|
17
|
+
defaultCalendar: z.string().default('primary'),
|
|
18
|
+
excludedCalendars: z.array(z.string()).default([]),
|
|
19
|
+
syncInterval: z.number().min(60).max(3600).default(300),
|
|
20
|
+
enableNotifications: z.boolean().default(true),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Calendar sources configuration schema
|
|
24
|
+
* Validates that at least one calendar source is enabled
|
|
25
|
+
*/
|
|
26
|
+
export const CalendarSourcesSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
eventkit: EventKitSourceConfigSchema,
|
|
29
|
+
google: GoogleCalendarSourceConfigSchema,
|
|
30
|
+
})
|
|
31
|
+
.refine((data) => data.eventkit.enabled || data.google.enabled, {
|
|
32
|
+
message: 'At least one calendar source must be enabled',
|
|
33
|
+
path: ['sources'],
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Validate calendar sources configuration
|
|
37
|
+
* @param sources - The calendar sources configuration to validate
|
|
38
|
+
* @returns Validation result with parsed data or error
|
|
39
|
+
*/
|
|
40
|
+
export function validateCalendarSources(sources) {
|
|
41
|
+
const result = CalendarSourcesSchema.safeParse(sources);
|
|
42
|
+
if (result.success) {
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
data: result.data,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
error: result.error,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;IAC9C,iBAAiB,EAAE,CAAC,CAAC,KA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