Skip to content

Commit edfe49b

Browse files
committedSep 13, 2023
fix: broken convertV1Config on Google Apps Script
1 parent ec8accb commit edfe49b

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed
 

‎src/lib/index.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { PartialDeep } from "type-fest"
32
import {
43
EnvContext,
54
ProcessingResult,
@@ -58,34 +57,32 @@ export {
5857
ThreadMatchConfig,
5958
V1Config,
6059
V1Rule,
61-
VariableEntry,
60+
VariableEntry
6261
}
6362

6463
/**
6564
* Run Gmail Processor with the given config
66-
* @param configJson - GmailProcessor configuration JSON - @see Config
65+
* @param config - GmailProcessor configuration JSON - @see Config
6766
* @param runMode - The processing mode - @see RunMode
6867
* @param ctx - The environment context to be used for processing - @see EnvContext
6968
* @returns Processing result - @see ProcessingResult
7069
*/
7170
export function run(
72-
configJson: PartialDeep<Config>,
71+
config: Config,
7372
runMode: string = RunMode.SAFE_MODE,
7473
ctx: EnvContext = EnvProvider.defaultContext(runMode as RunMode),
7574
): ProcessingResult {
76-
return GmailProcessor.runWithJson(configJson, ctx)
75+
return GmailProcessor.runWithJson(config, ctx)
7776
}
7877

7978
/**
8079
* Convert a GMail2GDrive v1.x config JSON into a Gmail Processor config
81-
* @param v1configJson - JSON of the v1 config
80+
* @param v1config - JSON of the v1 config - @see V1Config
8281
* @returns Converted JSON config - @see Config
8382
*/
84-
export function convertV1Config(
85-
v1configJson: PartialDeep<V1Config>,
86-
): PartialDeep<Config> {
83+
export function convertV1Config(v1config: V1Config): Config {
8784
return GmailProcessor.getEssentialConfig(
88-
V1ToV2Converter.v1ConfigToV2ConfigJson(v1configJson),
85+
V1ToV2Converter.v1ConfigToV2ConfigJson(v1config),
8986
)
9087
}
9188

@@ -101,3 +98,5 @@ export function convertV1Config(
10198
;(globalThis as any).ProcessingStage = ProcessingStage
10299
;(globalThis as any).RunMode = RunMode
103100
;(globalThis as any).V1Config = V1Config
101+
;(globalThis as any).convertV1Config = convertV1Config
102+
;(globalThis as any).run = run

‎src/test/mocks/ConfigMocks.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ export class ConfigMocks {
197197
]
198198
}
199199

200-
public static newDefaultConfigJson(): PartialDeep<Config> {
200+
public static newDefaultConfigJson(): Config {
201201
return {
202202
settings: this.newDefaultSettingsConfigJson(),
203203
threads: this.newComplexThreadConfigList(),
204204
global: this.newDefaultGlobalConfigJson(),
205205
}
206206
}
207207

208-
public static newDefaultV1ConfigJson(): PartialDeep<V1Config> {
208+
public static newDefaultV1ConfigJson(): V1Config {
209209
return {
210210
globalFilter: "has:attachment -in:trash -in:drafts -in:spam",
211211
processedLabel: "gmail2gdrive/client-test",
@@ -249,7 +249,7 @@ export class ConfigMocks {
249249
}
250250

251251
public static newDefaultConfig(
252-
configJson: PartialDeep<Config> = this.newDefaultConfigJson(),
252+
configJson: Config = this.newDefaultConfigJson(),
253253
): RequiredConfig {
254254
return newConfig(configJson)
255255
}

0 commit comments

Comments
 (0)
Please sign in to comment.