diff --git a/README.md b/README.md index f5e9aea..8c07627 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ App({ | tag | | number | | Specify the tag from the interface url. By default, the first tag is read for the file name. | | filter | f | string[] | | Filter interfaces. Interfaces that meet the filter conditions will be generated. Example: `--filter "/pet*"`, generate an interface for `/pet`, and support multiple `--filter`. For more usage information, please refer to [micromatch](https://github.com/micromatch/micromatch) | | conjunction | c | string | By | The method's connector, the default value is `By`. | +| actionIndex | | number | -1 | The method name index, the default value is `-1`. | | version | v | boolean | | Output version information. | | help | h | boolean | | Output help information. | @@ -152,8 +153,8 @@ Create a `myPlugin.ts` file: ```ts // 引用模块 -// import { start } from 'https://deno.land/x/stc@2.6.1/mod.ts' -import { start } from 'jsr:@loongwoo/stc@^2.6.1' +// import { start } from 'https://deno.land/x/stc@2.7.0/mod.ts' +import { start } from 'jsr:@loongwoo/stc@^2.7.0' // Defining plugins const myPlugin: IPlugin = { diff --git a/deno.json b/deno.json index eb1f3a1..216545a 100644 --- a/deno.json +++ b/deno.json @@ -1,12 +1,12 @@ { "name": "@loongwoo/stc", - "version": "2.6.1", + "version": "2.7.0", "exports": "./mod.ts", "tasks": { "pack": "deno run -A src/pack.ts", "dev": "deno task pack && deno run -A --watch=src src/main.ts --url='https://petstore3.swagger.io/api/v3/openapi.json' --lang=ts", "serve": "deno run -A --watch=src src/service.ts", - "version": "echo '2.6.1' > release/version", + "version": "echo '2.7.0' > release/version", "build:npm": "deno run -A src/npm/build.ts", "build:mac": "deno compile -A --target x86_64-apple-darwin --output release/stc src/main.ts", "build:mac-m": "deno compile -A --target aarch64-apple-darwin --output release/stc-m src/main.ts", diff --git a/src/cli.ts b/src/cli.ts index b3594cf..b512b6f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -160,6 +160,7 @@ ${getT("$t(cli.option)")} -f, --filter ${getT("$t(cli.option_filter)")} --tag ${getT("$t(cli.option_tag)")} -c, --conjunction ${getT("$t(cli.option_conjunction)")} + --actionIndex ${getT("$t(cli.option_actionIndex)")} -v, --version ${getT("$t(cli.option_version)")} ${getT("$t(cli.example)")} @@ -184,6 +185,7 @@ export const main = async (): Promise => { "tag", "filter", "conjunction", + "actionIndex", ], alias: { h: "help", @@ -240,5 +242,6 @@ export const main = async (): Promise => { tag: args.tag, filter: args.filter, conjunction: args.conjunction, + actionIndex: args.actionIndex, }; }; diff --git a/src/core.ts b/src/core.ts index 99c7ff7..df00791 100644 --- a/src/core.ts +++ b/src/core.ts @@ -210,16 +210,21 @@ export const getDefinition = ( * 从 URL 获取方法名称 * @param url - 接口地址 * @param conjunction - 连接字符 + * @param index - 下标, 默认 -1 * @returns */ -const getMethodName = (url: string, conjunction: string) => { +const getMethodName = ( + url: string, + conjunction: string, + index: number = -1, +) => { const _url = url.split("/"); // 获取URL路径Query方法名称(取第一个Params) let _query = url.split("?")?.[1]?.split("&") .shift()?.replace(/[,=]/g, "_"); // 添加_分割标记 _query = _query ? `_${_query}` : ""; - let _name = _url.pop()?.split("?")[0] as string; + let _name = _url.slice(index).join("_")?.split("?")[0] as string; if (!_name) return _name; @@ -443,7 +448,7 @@ export const getApiPath = ( // 方法名 let name = currentMethod.operationId ?? - getMethodName(url, options!.conjunction!); + getMethodName(url, options!.conjunction!, options?.actionIndex); if (!name) { Logs.error(getT("$t(path.notName)", { url, method })); @@ -469,6 +474,18 @@ export const getApiPath = ( ); name = `${value.tag}@${name}`; + + if (pathMap.has(name)) { + Logs.error( + getT("$t(path.duplicate)", { + url, + method, + name: name.slice(name.indexOf("@") + 1), + }), + ); + + return; + } pathMap.set(name, value); }); }); diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index d4e37e4..475b32a 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -13,7 +13,8 @@ "parserTypeError": "The {{type}} type could not be resolved." }, "path": { - "notName": "The {{method}} of {{url}} cannot get the method name, so it is ignored." + "notName": "{{url}} {{method}} cannot get the method name, so it will be ignored.", + "duplicate": "{{url}} {{method}} has the same method name {{name}}, you can set the `--actionIndex` option." }, "app": { "apiJsonFileError": "API file parsing failed. Reason: {{error}}", @@ -39,7 +40,8 @@ "option_filter": "Filter interfaces, and the interfaces that meet the filter conditions will be generated.", "option_tag": "Specify tags from the interface url for filenames, the first one of tags is read by default.", "option_version": "View version information.", - "option_conjunction": "Conjunction of method name. [default: \"By\"]." + "option_conjunction": "Conjunction of method name. [default: \"By\"].", + "option_actionIndex": "Method name index. [default: -1]." }, "plugin": { "name": "Load plugin {{name}}", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index d61e386..906b956 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -13,7 +13,8 @@ "parserTypeError": "{{type}} 类型无法解析。" }, "path": { - "notName": "{{url}} 的 {{method}} 无法获取方法名称,故忽略。" + "notName": "{{url}} {{method}} 无法获取方法名称,故忽略。", + "duplicate": "{{url}} {{method}} 的 {{name}} 方法名重复,可设置 `--actionIndex` 选项。" }, "app": { "apiJsonFileError": "API 文件解析失败。原因:{{error}}", @@ -39,7 +40,8 @@ "option_filter": "过滤接口,符合过滤条件的接口会被生成。", "option_tag": "从接口 url 中指定标签,用于文件名,默认读取 tags 的第一个。", "option_version": "显示版本信息。", - "option_conjunction": "方法名的连接词。 [默认: \"By\"]。" + "option_conjunction": "方法名的连接词。 [默认: \"By\"]。", + "option_actionIndex": "方法名的索引。 [默认: -1]。" }, "plugin": { "name": "加载插件 {{name}}", diff --git a/src/npm/pkg.json b/src/npm/pkg.json index 0a43b7c..7eb686f 100644 --- a/src/npm/pkg.json +++ b/src/npm/pkg.json @@ -1,6 +1,6 @@ { "name": "@loongwoo/stc", - "version": "2.6.1", + "version": "2.7.0", "description": "A tool for converting OpenApi/Swagger/Apifox into code.", "type": "module", "module": "esm/mod.js", diff --git a/src/swagger.ts b/src/swagger.ts index d8c5c33..81a9acd 100644 --- a/src/swagger.ts +++ b/src/swagger.ts @@ -329,6 +329,10 @@ export interface ISwaggerOptions { * 方法名的连接词,默认值为 By */ readonly conjunction?: string; + /** + * 方法名的下标,默认值为 -1 + */ + readonly actionIndex?: number; } export interface IDefinitionNameMapping { diff --git a/test/action-index.json b/test/action-index.json new file mode 100644 index 0000000..113d3ab --- /dev/null +++ b/test/action-index.json @@ -0,0 +1,1609 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Api", + "version": "1.0" + }, + "paths": { + "/api/das/job/create": { + "post": { + "tags": [ + "Job" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobCreateRequestModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobCreateRequestModel" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/JobCreateRequestModel" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + } + } + } + } + } + }, + "/api/das/job/update": { + "post": { + "tags": [ + "Job" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobUpdateRequestModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobUpdateRequestModel" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/JobUpdateRequestModel" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + } + } + } + } + } + }, + "/api/das/job/enable": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + } + } + } + } + } + }, + "/api/das/job/disable": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + } + } + } + } + } + }, + "/api/das/job/detail": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobInfoModelResponse" + } + } + } + } + } + } + }, + "/api/das/job/query": { + "post": { + "tags": [ + "Job" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DASJobQuery" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/DASJobQuery" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/DASJobQuery" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/JobBaseInfoModelWithTriggerPagedResultResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobBaseInfoModelWithTriggerPagedResultResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobBaseInfoModelWithTriggerPagedResultResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/trigger/detail": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/JobTriggerInfoModelResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerInfoModelResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerInfoModelResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/trigger/update": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerRequestModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerRequestModel" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerRequestModel" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/JobTriggerInfoModelResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerInfoModelResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/JobTriggerInfoModelResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/trigger/disable": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/trigger/enable": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BooleanResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/tag/add": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/tag/remove": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + } + } + } + } + } + }, + "/api/das/job/{id}/tag/overwrite": { + "post": { + "tags": [ + "Job" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StringIListResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "BooleanResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "DASJobQuery": { + "type": "object", + "properties": { + "keyword": { + "type": "string", + "nullable": true + }, + "page": { + "type": "integer", + "format": "int32" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "status": { + "type": "integer", + "format": "int32" + }, + "tag": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "DASJobStatus": { + "enum": [ + 0, + 1 + ], + "type": "integer", + "format": "int32" + }, + "DASListener": { + "type": "object", + "properties": { + "listenerId": { + "type": "string", + "nullable": true + }, + "sources": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": {} + }, + "nullable": true + }, + "filter": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DASListenerTask" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "DASListenerResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/DASListener" + } + }, + "additionalProperties": false + }, + "DASListenerTask": { + "type": "object", + "properties": { + "taskId": { + "type": "integer", + "format": "int32" + }, + "paramMapping": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "DASTask": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "jobID": { + "type": "integer", + "format": "int32" + }, + "instanceID": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/DASTaskStatus" + }, + "context": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "updateTime": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false + }, + "DASTaskPagedResult": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "format": "int32" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DASTask" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "DASTaskPagedResultResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/DASTaskPagedResult" + } + }, + "additionalProperties": false + }, + "DASTaskQuery": { + "type": "object", + "properties": { + "keyword": { + "type": "string", + "nullable": true + }, + "page": { + "type": "integer", + "format": "int32" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "begin": { + "type": "string", + "format": "date-time" + }, + "end": { + "type": "string", + "format": "date-time" + }, + "jobId": { + "type": "integer", + "format": "int32" + }, + "status": { + "type": "integer", + "format": "int32", + "nullable": true + } + }, + "additionalProperties": false + }, + "DASTaskStatus": { + "enum": [ + 0, + 1, + 2, + 3 + ], + "type": "integer", + "format": "int32" + }, + "JobBaseInfoModelWithTrigger": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "triggerId": { + "type": "integer", + "format": "int32", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "description": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/DASJobStatus" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "createUserName": { + "type": "string", + "nullable": true + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "updateBy": { + "type": "integer", + "format": "int32" + }, + "updateUserName": { + "type": "string", + "nullable": true + }, + "updateTime": { + "type": "string", + "format": "date-time" + }, + "trigger": { + "$ref": "#/components/schemas/JobTriggerBasicInfoModel" + }, + "latestTask": { + "$ref": "#/components/schemas/DASTask" + }, + "latestFaildTask": { + "$ref": "#/components/schemas/DASTask" + } + }, + "additionalProperties": false + }, + "JobBaseInfoModelWithTriggerPagedResult": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "format": "int32" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JobBaseInfoModelWithTrigger" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "JobBaseInfoModelWithTriggerPagedResultResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/JobBaseInfoModelWithTriggerPagedResult" + } + }, + "additionalProperties": false + }, + "JobCreateRequestModel": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "maxLength": 50, + "minLength": 5, + "type": "string" + }, + "description": { + "maxLength": 200, + "type": "string", + "nullable": true + }, + "tags": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "parameter": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "flowLayout": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "flowData": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "JobInfoModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "triggerId": { + "type": "integer", + "format": "int32", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "description": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/DASJobStatus" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "createUserName": { + "type": "string", + "nullable": true + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "updateBy": { + "type": "integer", + "format": "int32" + }, + "updateUserName": { + "type": "string", + "nullable": true + }, + "updateTime": { + "type": "string", + "format": "date-time" + }, + "parameter": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "flowLayout": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "flowData": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "JobInfoModelResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/JobInfoModel" + } + }, + "additionalProperties": false + }, + "JobTriggerBasicInfoModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "triggerType": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/JobTriggerStatus" + } + }, + "additionalProperties": false + }, + "JobTriggerInfoModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "triggerType": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/JobTriggerStatus" + }, + "description": { + "type": "string", + "nullable": true + }, + "createUserName": { + "type": "string", + "nullable": true + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "updateBy": { + "type": "integer", + "format": "int32" + }, + "updateUserName": { + "type": "string", + "nullable": true + }, + "updateTime": { + "type": "string", + "format": "date-time" + }, + "configuration": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "JobTriggerInfoModelResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/JobTriggerInfoModel" + } + }, + "additionalProperties": false + }, + "JobTriggerRequestModel": { + "required": [ + "name", + "triggerType" + ], + "type": "object", + "properties": { + "triggerType": { + "maxLength": 50, + "minLength": 2, + "type": "string" + }, + "name": { + "maxLength": 50, + "minLength": 5, + "type": "string" + }, + "description": { + "maxLength": 200, + "type": "string", + "nullable": true + }, + "configuration": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "JobTriggerStatus": { + "enum": [ + 0, + 1 + ], + "type": "integer", + "format": "int32" + }, + "JobUpdateRequestModel": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "maxLength": 50, + "minLength": 5, + "type": "string" + }, + "description": { + "maxLength": 200, + "type": "string", + "nullable": true + }, + "tags": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "parameter": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "flowLayout": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "flowData": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "id": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "PagedQuery": { + "type": "object", + "properties": { + "keyword": { + "type": "string", + "nullable": true + }, + "page": { + "type": "integer", + "format": "int32" + }, + "size": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "StringIListResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "StringPagedResult": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "format": "int32" + }, + "data": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "StringPagedResultResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/StringPagedResult" + } + }, + "additionalProperties": false + }, + "TriggerQuery": { + "type": "object", + "properties": { + "keyword": { + "type": "string", + "nullable": true + }, + "page": { + "type": "integer", + "format": "int32" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "TriggerTemplateBaseInfoModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "triggerType": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "description": { + "type": "string", + "nullable": true + }, + "createUserName": { + "type": "string", + "nullable": true + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "updateBy": { + "type": "integer", + "format": "int32" + }, + "updateUserName": { + "type": "string", + "nullable": true + }, + "updateTime": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false + }, + "TriggerTemplateBaseInfoModelPagedResult": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "format": "int32" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TriggerTemplateBaseInfoModel" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "TriggerTemplateBaseInfoModelPagedResultResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/TriggerTemplateBaseInfoModelPagedResult" + } + }, + "additionalProperties": false + }, + "TriggerTemplateCreateRequestModel": { + "required": [ + "name", + "triggerType" + ], + "type": "object", + "properties": { + "triggerType": { + "maxLength": 50, + "minLength": 2, + "type": "string" + }, + "name": { + "maxLength": 50, + "minLength": 5, + "type": "string" + }, + "description": { + "maxLength": 200, + "type": "string", + "nullable": true + }, + "template": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "TriggerTemplateInfoModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "triggerType": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "description": { + "type": "string", + "nullable": true + }, + "createUserName": { + "type": "string", + "nullable": true + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "updateBy": { + "type": "integer", + "format": "int32" + }, + "updateUserName": { + "type": "string", + "nullable": true + }, + "updateTime": { + "type": "string", + "format": "date-time" + }, + "template": { + "type": "object", + "additionalProperties": {}, + "nullable": true + } + }, + "additionalProperties": false + }, + "TriggerTemplateInfoModelResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "code": { + "type": "string", + "nullable": true + }, + "message": { + "type": "string", + "nullable": true + }, + "result": { + "$ref": "#/components/schemas/TriggerTemplateInfoModel" + } + }, + "additionalProperties": false + }, + "TriggerTemplateUpdateRequestModel": { + "required": [ + "name", + "triggerType" + ], + "type": "object", + "properties": { + "triggerType": { + "maxLength": 50, + "minLength": 2, + "type": "string" + }, + "name": { + "maxLength": 50, + "minLength": 5, + "type": "string" + }, + "description": { + "maxLength": 200, + "type": "string", + "nullable": true + }, + "template": { + "type": "object", + "additionalProperties": {}, + "nullable": true + }, + "id": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + } + } + } +} diff --git a/test/cli.test.ts b/test/cli.test.ts index 4a3bccb..316bb84 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -61,3 +61,19 @@ Deno.test("conjunction", async () => { assertEquals(0, code); }); + +Deno.test("actionIndex", async () => { + const command = new Deno.Command("deno", { + args: [ + "run", + "-A", + "src/main.ts", + "--url=./test/action-index.json", + "--actionIndex=-2", + ], + }); + + const { code } = await command.output(); + + assertEquals(0, code); +});