yaschema-api-google-cloud-task-creator
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -22,2 +22,3 @@ "use strict"; | ||
const getGoogleCloudTasksClient_1 = require("../../internal-utils/getGoogleCloudTasksClient"); | ||
const getScheduleTimeMSec_1 = require("../../internal-utils/getScheduleTimeMSec"); | ||
const internalCreateGoogleCloudTask_1 = require("../../internal-utils/internalCreateGoogleCloudTask"); | ||
@@ -32,3 +33,3 @@ const CreateTaskRequirementsError_1 = require("../types/CreateTaskRequirementsError"); | ||
/** Uses `new CloudTasksClient().createTask` to access the specified API */ | ||
const createGoogleCloudTask = (api, req, { requestValidationMode = (0, validation_mode_1.getDefaultRequestValidationMode)(), creationOptions, limitMode = DEFAULT_TASK_LIMIT_MODE, limitMSec = DEFAULT_TASK_LIMIT_MSEC, limitType = DEFAULT_TASK_LIMIT_TYPE, limitNameExtension = '' } = {}) => __awaiter(void 0, void 0, void 0, function* () { | ||
const createGoogleCloudTask = (api_1, req_1, ...args_1) => __awaiter(void 0, [api_1, req_1, ...args_1], void 0, function* (api, req, { requestValidationMode = (0, validation_mode_1.getDefaultRequestValidationMode)(), creationOptions, limitMode = DEFAULT_TASK_LIMIT_MODE, limitMSec = DEFAULT_TASK_LIMIT_MSEC, limitType = DEFAULT_TASK_LIMIT_TYPE, limitNameExtension = '' } = {}) { | ||
if (api.method === 'LINK' || api.method === 'UNLINK') { | ||
@@ -42,3 +43,3 @@ throw new Error("LINK and UNLINK aren't supported by yaschema-api-google-cloud-task-creator"); | ||
}); | ||
const scheduleTimeMSec = getScheduleTimeMSec({ limitMode, limitMSec }); | ||
const scheduleTimeMSec = (0, getScheduleTimeMSec_1.getScheduleTimeMSec)({ limitMode, limitMSec }); | ||
const request = { | ||
@@ -50,4 +51,4 @@ parent: (0, getGoogleCloudTasksClient_1.getGoogleCloudTasksClient)().queuePath((0, google_cloud_project_1.getGoogleCloudProjectForRouteType)(api.routeType), (0, google_cloud_location_1.getGoogleCloudLocationForRouteType)(api.routeType), (0, google_cloud_task_queue_1.getGoogleCloudTaskQueueForRouteType)(api.routeType)), | ||
: null, | ||
scheduleTime: limitType !== 'none' && limitMSec > 0 && limitMode === 'trailing' | ||
? { seconds: scheduleTimeMSec / ONE_SEC_MSEC, nanos: (scheduleTimeMSec % ONE_SEC_MSEC) * ONE_MSEC_NSEC } | ||
scheduleTime: limitMSec > 0 && limitMode === 'trailing' | ||
? { seconds: Math.floor(scheduleTimeMSec / ONE_SEC_MSEC), nanos: (scheduleTimeMSec % ONE_SEC_MSEC) * ONE_MSEC_NSEC } | ||
: undefined, | ||
@@ -87,11 +88,3 @@ httpRequest: { | ||
// Helpers | ||
const getScheduleTimeMSec = ({ limitMode, limitMSec }) => { | ||
switch (limitMode) { | ||
case 'leading': | ||
return Math.floor(Date.now() / limitMSec) * limitMSec; | ||
case 'trailing': | ||
return Math.ceil(Date.now() / limitMSec) * limitMSec; | ||
} | ||
}; | ||
const normalizeTaskId = (name) => name.replace(/[^A-Za-z0-9_]+/g, '-'); | ||
//# sourceMappingURL=index.js.map |
@@ -33,15 +33,15 @@ "use strict"; | ||
* `FetchRequirementsError` */ | ||
const generateGoogleCloudCreateTaskRequirementsFromApiRequest = (api, req, { validationMode }) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
const generateGoogleCloudCreateTaskRequirementsFromApiRequest = (api_1, req_1, _a) => __awaiter(void 0, [api_1, req_1, _a], void 0, function* (api, req, { validationMode }) { | ||
var _b, _c, _d, _e, _f, _g, _h, _j; | ||
const [reqHeaders, reqParams, reqQuery, reqBody] = yield Promise.all([ | ||
((_a = api.schemas.request.headers) !== null && _a !== void 0 ? _a : anyReqHeadersSchema).serializeAsync(((_b = req.headers) !== null && _b !== void 0 ? _b : {}), { | ||
((_b = api.schemas.request.headers) !== null && _b !== void 0 ? _b : anyReqHeadersSchema).serializeAsync(((_c = req.headers) !== null && _c !== void 0 ? _c : {}), { | ||
validation: validationMode | ||
}), | ||
((_c = api.schemas.request.params) !== null && _c !== void 0 ? _c : anyReqParamsSchema).serializeAsync(((_d = req.params) !== null && _d !== void 0 ? _d : {}), { | ||
((_d = api.schemas.request.params) !== null && _d !== void 0 ? _d : anyReqParamsSchema).serializeAsync(((_e = req.params) !== null && _e !== void 0 ? _e : {}), { | ||
validation: validationMode | ||
}), | ||
((_e = api.schemas.request.query) !== null && _e !== void 0 ? _e : anyReqQuerySchema).serializeAsync(((_f = req.query) !== null && _f !== void 0 ? _f : {}), { | ||
((_f = api.schemas.request.query) !== null && _f !== void 0 ? _f : anyReqQuerySchema).serializeAsync(((_g = req.query) !== null && _g !== void 0 ? _g : {}), { | ||
validation: validationMode | ||
}), | ||
((_g = api.schemas.request.body) !== null && _g !== void 0 ? _g : anyReqBodySchema).serializeAsync(req.body, { validation: validationMode }) | ||
((_h = api.schemas.request.body) !== null && _h !== void 0 ? _h : anyReqBodySchema).serializeAsync(req.body, { validation: validationMode }) | ||
]); | ||
@@ -77,3 +77,3 @@ if (validationMode !== 'none') { | ||
catch (e) { | ||
throw new CreateTaskRequirementsError_1.CreateTaskRequirementsError((_h = lodash_1.default.get(e, 'message')) !== null && _h !== void 0 ? _h : ''); | ||
throw new CreateTaskRequirementsError_1.CreateTaskRequirementsError((_j = lodash_1.default.get(e, 'message')) !== null && _j !== void 0 ? _j : ''); | ||
} | ||
@@ -80,0 +80,0 @@ const url = (0, determine_api_url_using_pre_serialized_parts_1.determineApiUrlUsingPreSerializedParts)(api, { |
@@ -19,2 +19,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { getGoogleCloudTasksClient } from '../../internal-utils/getGoogleCloudTasksClient'; | ||
import { getScheduleTimeMSec } from '../../internal-utils/getScheduleTimeMSec'; | ||
import { internalCreateGoogleCloudTask } from '../../internal-utils/internalCreateGoogleCloudTask'; | ||
@@ -29,3 +30,3 @@ import { CreateTaskRequirementsError } from '../types/CreateTaskRequirementsError'; | ||
/** Uses `new CloudTasksClient().createTask` to access the specified API */ | ||
export const createGoogleCloudTask = (api, req, { requestValidationMode = getDefaultRequestValidationMode(), creationOptions, limitMode = DEFAULT_TASK_LIMIT_MODE, limitMSec = DEFAULT_TASK_LIMIT_MSEC, limitType = DEFAULT_TASK_LIMIT_TYPE, limitNameExtension = '' } = {}) => __awaiter(void 0, void 0, void 0, function* () { | ||
export const createGoogleCloudTask = (api_1, req_1, ...args_1) => __awaiter(void 0, [api_1, req_1, ...args_1], void 0, function* (api, req, { requestValidationMode = getDefaultRequestValidationMode(), creationOptions, limitMode = DEFAULT_TASK_LIMIT_MODE, limitMSec = DEFAULT_TASK_LIMIT_MSEC, limitType = DEFAULT_TASK_LIMIT_TYPE, limitNameExtension = '' } = {}) { | ||
if (api.method === 'LINK' || api.method === 'UNLINK') { | ||
@@ -46,4 +47,4 @@ throw new Error("LINK and UNLINK aren't supported by yaschema-api-google-cloud-task-creator"); | ||
: null, | ||
scheduleTime: limitType !== 'none' && limitMSec > 0 && limitMode === 'trailing' | ||
? { seconds: scheduleTimeMSec / ONE_SEC_MSEC, nanos: (scheduleTimeMSec % ONE_SEC_MSEC) * ONE_MSEC_NSEC } | ||
scheduleTime: limitMSec > 0 && limitMode === 'trailing' | ||
? { seconds: Math.floor(scheduleTimeMSec / ONE_SEC_MSEC), nanos: (scheduleTimeMSec % ONE_SEC_MSEC) * ONE_MSEC_NSEC } | ||
: undefined, | ||
@@ -82,11 +83,3 @@ httpRequest: { | ||
// Helpers | ||
const getScheduleTimeMSec = ({ limitMode, limitMSec }) => { | ||
switch (limitMode) { | ||
case 'leading': | ||
return Math.floor(Date.now() / limitMSec) * limitMSec; | ||
case 'trailing': | ||
return Math.ceil(Date.now() / limitMSec) * limitMSec; | ||
} | ||
}; | ||
const normalizeTaskId = (name) => name.replace(/[^A-Za-z0-9_]+/g, '-'); | ||
//# sourceMappingURL=index.js.map |
@@ -27,15 +27,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
* `FetchRequirementsError` */ | ||
export const generateGoogleCloudCreateTaskRequirementsFromApiRequest = (api, req, { validationMode }) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
export const generateGoogleCloudCreateTaskRequirementsFromApiRequest = (api_1, req_1, _a) => __awaiter(void 0, [api_1, req_1, _a], void 0, function* (api, req, { validationMode }) { | ||
var _b, _c, _d, _e, _f, _g, _h, _j; | ||
const [reqHeaders, reqParams, reqQuery, reqBody] = yield Promise.all([ | ||
((_a = api.schemas.request.headers) !== null && _a !== void 0 ? _a : anyReqHeadersSchema).serializeAsync(((_b = req.headers) !== null && _b !== void 0 ? _b : {}), { | ||
((_b = api.schemas.request.headers) !== null && _b !== void 0 ? _b : anyReqHeadersSchema).serializeAsync(((_c = req.headers) !== null && _c !== void 0 ? _c : {}), { | ||
validation: validationMode | ||
}), | ||
((_c = api.schemas.request.params) !== null && _c !== void 0 ? _c : anyReqParamsSchema).serializeAsync(((_d = req.params) !== null && _d !== void 0 ? _d : {}), { | ||
((_d = api.schemas.request.params) !== null && _d !== void 0 ? _d : anyReqParamsSchema).serializeAsync(((_e = req.params) !== null && _e !== void 0 ? _e : {}), { | ||
validation: validationMode | ||
}), | ||
((_e = api.schemas.request.query) !== null && _e !== void 0 ? _e : anyReqQuerySchema).serializeAsync(((_f = req.query) !== null && _f !== void 0 ? _f : {}), { | ||
((_f = api.schemas.request.query) !== null && _f !== void 0 ? _f : anyReqQuerySchema).serializeAsync(((_g = req.query) !== null && _g !== void 0 ? _g : {}), { | ||
validation: validationMode | ||
}), | ||
((_g = api.schemas.request.body) !== null && _g !== void 0 ? _g : anyReqBodySchema).serializeAsync(req.body, { validation: validationMode }) | ||
((_h = api.schemas.request.body) !== null && _h !== void 0 ? _h : anyReqBodySchema).serializeAsync(req.body, { validation: validationMode }) | ||
]); | ||
@@ -71,3 +71,3 @@ if (validationMode !== 'none') { | ||
catch (e) { | ||
throw new CreateTaskRequirementsError((_h = _.get(e, 'message')) !== null && _h !== void 0 ? _h : ''); | ||
throw new CreateTaskRequirementsError((_j = _.get(e, 'message')) !== null && _j !== void 0 ? _j : ''); | ||
} | ||
@@ -74,0 +74,0 @@ const url = determineApiUrlUsingPreSerializedParts(api, { |
{ | ||
"name": "yaschema-api-google-cloud-task-creator", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Google Cloud createTask support for yaschema-api", | ||
@@ -34,15 +34,15 @@ "keywords": [ | ||
"dependencies": { | ||
"@google-cloud/tasks": "5.0.0", | ||
"@google-cloud/tasks": "5.1.1", | ||
"lodash": "^4.17.21", | ||
"uuid": "9.0.1", | ||
"yaschema": "^3.3.0", | ||
"yaschema-api": "^3.4.2" | ||
"yaschema": "^3.4.0", | ||
"yaschema-api": "^3.4.4" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.11", | ||
"@types/lodash": "^4.14.202", | ||
"@types/jest": "^29.5.12", | ||
"@types/lodash": "^4.17.0", | ||
"@types/uuid": "9.0.8", | ||
"@typescript-eslint/eslint-plugin": "^6.18.1", | ||
"@typescript-eslint/parser": "^6.18.1", | ||
"eslint": "8.56.0", | ||
"@typescript-eslint/eslint-plugin": "^7.2.0", | ||
"@typescript-eslint/parser": "^7.2.0", | ||
"eslint": "8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
@@ -53,3 +53,3 @@ "eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"eslint-plugin-simple-import-sort": "^12.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
@@ -60,8 +60,8 @@ "google-gax": "4.3.1", | ||
"node-fetch": "^3.3.2", | ||
"prettier": "3.1.1", | ||
"prettier": "3.2.5", | ||
"trash-cli": "5.0.0", | ||
"ts-jest": "^29.1.1", | ||
"typedoc": "^0.25.7", | ||
"typescript": "5.3.3" | ||
"ts-jest": "^29.1.2", | ||
"typedoc": "^0.25.12", | ||
"typescript": "5.4.2" | ||
} | ||
} |
@@ -23,2 +23,3 @@ import type { CallOptions } from 'google-gax'; | ||
import { getGoogleCloudTasksClient } from '../../internal-utils/getGoogleCloudTasksClient'; | ||
import { getScheduleTimeMSec } from '../../internal-utils/getScheduleTimeMSec'; | ||
import { internalCreateGoogleCloudTask } from '../../internal-utils/internalCreateGoogleCloudTask'; | ||
@@ -111,4 +112,4 @@ import type { CreateTaskRequest } from '../../types/CreateTaskRequest'; | ||
scheduleTime: | ||
limitType !== 'none' && limitMSec > 0 && limitMode === 'trailing' | ||
? { seconds: scheduleTimeMSec / ONE_SEC_MSEC, nanos: (scheduleTimeMSec % ONE_SEC_MSEC) * ONE_MSEC_NSEC } | ||
limitMSec > 0 && limitMode === 'trailing' | ||
? { seconds: Math.floor(scheduleTimeMSec / ONE_SEC_MSEC), nanos: (scheduleTimeMSec % ONE_SEC_MSEC) * ONE_MSEC_NSEC } | ||
: undefined, | ||
@@ -151,11 +152,2 @@ httpRequest: { | ||
const getScheduleTimeMSec = ({ limitMode, limitMSec }: { limitMode: LimitMode; limitMSec: number }) => { | ||
switch (limitMode) { | ||
case 'leading': | ||
return Math.floor(Date.now() / limitMSec) * limitMSec; | ||
case 'trailing': | ||
return Math.ceil(Date.now() / limitMSec) * limitMSec; | ||
} | ||
}; | ||
const normalizeTaskId = (name: string) => name.replace(/[^A-Za-z0-9_]+/g, '-'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
171684
220
2046
+ Added@google-cloud/tasks@5.1.1(transitive)
- Removed@google-cloud/tasks@5.0.0(transitive)
Updated@google-cloud/tasks@5.1.1
Updatedyaschema@^3.4.0
Updatedyaschema-api@^3.4.4