@e2y/odata-client
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -12,3 +12,6 @@ import { OHandler } from 'odata/dist/types/OHandler'; | ||
private static generateAuthorization; | ||
runCronjob(code: string): Promise<void>; | ||
runCronjob(code: string, timeoutParameters?: { | ||
timeout: number; | ||
interval: number; | ||
}): Promise<void>; | ||
private createOHandlerDefaultInstance; | ||
@@ -15,0 +18,0 @@ private cronjobHasFinishedSuccessfully; |
@@ -29,7 +29,8 @@ "use strict"; | ||
} | ||
async runCronjob(code) { | ||
async runCronjob(code, timeoutParameters) { | ||
this.validateCronjobPrePersistenceHookBeanIdIsDefined(); | ||
const { headers, ...rest } = this.handler.config, handler = odata_1.o(this.BASE_URL, { | ||
const { headers, ...rest } = this.handler.config; | ||
const handler = odata_1.o(this.BASE_URL, { | ||
...rest, | ||
headers: { ...headers, ...{ 'Pre-Persist-Hook': this.CRONJOB_PRE_PERSISTENCE_HOOK_BEAN_ID } } | ||
headers: { ...headers, 'Pre-Persist-Hook': this.CRONJOB_PRE_PERSISTENCE_HOOK_BEAN_ID } | ||
}), body = { | ||
@@ -40,7 +41,6 @@ code, | ||
await handler.post(this.CRONJOB_ENDPOINT, JSON.stringify(body)).query(); | ||
await this.cronjobHasFinishedSuccessfully(code); | ||
await this.cronjobHasFinishedSuccessfully(code, timeoutParameters); | ||
} | ||
createOHandlerDefaultInstance(baseURL, username, password, accessPassword) { | ||
const Authorization = ODataClient.generateAuthorization(username, password), Cookie = accessPassword ? ODataClient.encryptMD5(accessPassword) : undefined; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
return odata_1.o(baseURL, { | ||
@@ -56,8 +56,7 @@ agent: new https_1.Agent({ | ||
onError: (oHandler, response) => { | ||
// eslint-disable-next-line no-console | ||
console.log(response); | ||
console.error(response); | ||
} | ||
}); | ||
} | ||
async cronjobHasFinishedSuccessfully(code) { | ||
async cronjobHasFinishedSuccessfully(code, timeoutParameters = { interval: 2, timeout: 10 }) { | ||
await wait_for_expect_1.default(async () => { | ||
@@ -70,9 +69,9 @@ const { d: { results: [cronjob] } } = (await this.handler.get(this.CRONJOB_ENDPOINT).query({ | ||
expect_1.default(cronjob).toMatchObject({ result: { code: 'SUCCESS' }, status: { code: 'FINISHED' } }); | ||
}); | ||
}, timeoutParameters.timeout, timeoutParameters.interval); | ||
} | ||
validateCronjobPrePersistenceHookBeanIdIsDefined() { | ||
assert_1.default(this.CRONJOB_PRE_PERSISTENCE_HOOK_BEAN_ID, 'Ops! to run a cronjob through the odata client the "Pre-Persist-Hook-Bean-Id" needs to be defined.'); | ||
assert_1.default(this.CRONJOB_PRE_PERSISTENCE_HOOK_BEAN_ID, '❌ Oops! to run a cronjob through the odata client the "Pre-Persist-Hook-Bean-Id" needs to be defined.'); | ||
} | ||
} | ||
exports.ODataClient = ODataClient; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib2RhdGEtY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL29kYXRhLWNsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSxvREFBNEI7QUFDNUIsb0RBQTRCO0FBQzVCLGlDQUE4QjtBQUM5Qiw4Q0FBc0I7QUFDdEIsaUNBQTBCO0FBRTFCLHNFQUE0QztBQUs1QyxNQUFhLFdBQVc7SUFNdEIsWUFBb0IsRUFBRSxPQUFPLEVBQUUsY0FBYyxFQUFFLFFBQVEsRUFBRSxRQUFRLEVBQUUsT0FBTyxFQUFxQjtRQUM3RixJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQztRQUN4QixJQUFJLENBQUMsZ0JBQWdCLEdBQUcsT0FBTyxFQUFFLFFBQVEsSUFBSSwwQkFBMEIsQ0FBQztRQUN4RSxJQUFJLENBQUMsb0NBQW9DLEdBQUcsT0FBTyxFQUFFLHdCQUF3QixDQUFDO1FBQzlFLElBQUksQ0FBQyxPQU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QUF1RyxDQUN4RyxDQUFDO0lBQ0osQ0FBQztDQUNGO0FBNUZELGtDQTRGQyJ9 |
{ | ||
"name": "@e2y/odata-client", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "odata client", | ||
@@ -35,3 +35,3 @@ "author": "e2y", | ||
}, | ||
"gitHead": "ed39e445e8d14f0ece7d61bd0753f9948771d40a" | ||
"gitHead": "435a2aa00eb27a6cc6365a30c998f02084995232" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14262
158