@next-core/easyops-runtime 0.6.44 → 0.6.46

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.
@@ -22,9 +22,7 @@ async function getArgsOfFlowApi(provider, originalArgs, method) {
22
22
  }
23
23
  const apiDefinition = await fetchFlowApiDefinition(provider);
24
24
  if (!apiDefinition) {
25
- throw new Error(`Flow API not found: "${provider}"`, {
26
- cause: "FLOW_API_NOT_FOUND"
27
- });
25
+ throw new FlowApiNotFoundError(`Flow API not found: "${provider}"`);
28
26
  }
29
27
  const apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);
30
28
  return getApiArgsFromApiProfile(apiProfile, originalArgs, method);
@@ -146,4 +144,17 @@ async function fetchFlowApiDefinitionFromRemote(namespace, name, version) {
146
144
  }
147
145
  } : null;
148
146
  }
147
+ class FlowApiNotFoundError extends Error {
148
+ constructor(message) {
149
+ // Pass remaining arguments (including vendor specific ones) to parent constructor
150
+ super(message);
151
+ this.name = "FlowApiNotFoundError";
152
+
153
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
154
+ // istanbul ignore else
155
+ if (Error.captureStackTrace) {
156
+ Error.captureStackTrace(this, FlowApiNotFoundError);
157
+ }
158
+ }
159
+ }
149
160
  //# sourceMappingURL=FlowApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlowApi.js","names":["_jsYaml","_interopRequireDefault","require","_apiGatewaySdk","_CollectContracts","remoteContractCache","Map","isFlowApiProvider","provider","includes","getArgsOfFlowApi","originalArgs","method","Error","apiDefinition","fetchFlowApiDefinition","cause","apiProfile","getApiProfileFromApiDefinition","getApiArgsFromApiProfile","uri","apiMethod","ext_fields","name","namespace","serviceName","responseWrapper","version","isFileType","request","isDownload","fileName","shift","url","args","getTransformedUriAndRestArgs","originalUri","prefix","restArgs","slice","transformedUri","replace","api","_contract$endpoint","_contract$response","contract","yaml","safeLoad","schema","JSON_SCHEMA","json","endpoint","response","wrapper","toLowerCase","type","namespaceName","nameWithVersion","split","getContract","namespaceId","promise","get","fetchFlowApiDefinitionFromRemote","set","_contractData$namespa","contractData","ContractApi_searchSingleContract","contractName"],"sources":["../../../src/flowApi/FlowApi.ts"],"sourcesContent":["import yaml from \"js-yaml\";\nimport { ContractApi_searchSingleContract } from \"@next-api-sdk/api-gateway-sdk\";\nimport { ContractRequest, ContractResponse, ExtField } from \"@next-core/types\";\nimport { getContract } from \"./CollectContracts.js\";\n\nconst remoteContractCache = new Map<\n string,\n Promise<CustomApiDefinition | null>\n>();\n\n// Legacy Custom API: `${namespace}@${name}`\n// Flow API: `${namespace}@${name}:${version}`\nexport function isFlowApiProvider(provider: string): boolean {\n return provider.includes(\"@\");\n}\n\nexport async function getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n): Promise<unknown[]> {\n if (!provider.includes(\":\")) {\n throw new Error(\n `You're using legacy Custom API \"${provider}\" which is dropped in v3, please use Flow API instead`\n );\n }\n\n const apiDefinition = await fetchFlowApiDefinition(provider);\n\n if (!apiDefinition) {\n throw new Error(`Flow API not found: \"${provider}\"`, {\n cause: \"FLOW_API_NOT_FOUND\",\n });\n }\n\n const apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);\n\n return getApiArgsFromApiProfile(apiProfile, originalArgs, method);\n}\n\nfunction getApiArgsFromApiProfile(\n {\n uri,\n method: apiMethod,\n ext_fields,\n name,\n namespace,\n serviceName,\n responseWrapper,\n version,\n isFileType,\n request,\n }: CustomApiProfile,\n originalArgs: unknown[],\n method?: string\n): unknown[] {\n const isDownload = isFileType && method === \"saveAs\";\n let fileName: string | undefined;\n if (isDownload) {\n fileName = originalArgs.shift() as string;\n }\n\n const { url, args } = getTransformedUriAndRestArgs(\n uri,\n originalArgs,\n name,\n namespace,\n serviceName,\n version\n );\n\n return [\n ...(isDownload ? [fileName] : []),\n {\n url,\n originalUri: uri,\n method: apiMethod,\n ext_fields,\n responseWrapper,\n request,\n isFileType,\n },\n ...args,\n ];\n}\n\nfunction getTransformedUriAndRestArgs(\n uri: string,\n originalArgs: unknown[],\n name: string,\n namespace: string,\n serviceName: string | undefined,\n version?: string\n): { url: string; args: unknown[] } {\n const prefix = version\n ? serviceName\n ? `api/gateway/${serviceName}`\n : `api/gateway/${namespace}.${name}@${version}`\n : `api/gateway/api_service.${namespace}.${name}`;\n const restArgs = originalArgs.slice();\n const transformedUri = uri.replace(\n /:([^/]+)/g,\n () => restArgs.shift() as string\n );\n return {\n url: prefix + transformedUri,\n args: restArgs,\n };\n}\n\nfunction getApiProfileFromApiDefinition(\n provider: string,\n api: CustomApiDefinition\n): CustomApiProfile {\n const contract: CustomApiDefinition[\"contract\"] =\n typeof api.contract === \"string\"\n ? (yaml.safeLoad(api.contract, {\n schema: yaml.JSON_SCHEMA,\n json: true,\n }) as CustomApiDefinition[\"contract\"])\n : api.contract;\n const { uri, method = \"GET\", ext_fields } = contract?.endpoint ?? {};\n const responseWrapper = contract?.response\n ? contract.response.wrapper !== false\n : false;\n if (!uri) {\n throw new Error(\n `Missing endpoint.uri in contract of provider \"${provider}\"`\n );\n }\n return {\n uri,\n method: method.toLowerCase() === \"list\" ? \"get\" : method,\n ext_fields,\n name: api.name,\n namespace: api.namespace,\n serviceName: api.serviceName,\n version: api.version,\n isFileType: contract?.response?.type === \"file\",\n responseWrapper,\n request: contract?.request,\n };\n}\n\nasync function fetchFlowApiDefinition(\n provider: string\n): Promise<CustomApiDefinition | null> {\n const [namespaceName, nameWithVersion] = provider.split(\"@\");\n const [name, version] = nameWithVersion.split(\":\");\n\n // Do not cache the result of `geContract`, which will lead to no contract\n // will be found when render twice immediately.\n const contract = getContract(`${namespaceName}.${name}`);\n if (contract) {\n return {\n name: contract.name,\n namespace: contract.namespaceId,\n serviceName: contract.serviceName,\n version: contract.version,\n contract: {\n endpoint: contract.endpoint,\n response: contract.response,\n request: contract.request,\n },\n };\n }\n let promise = remoteContractCache.get(provider);\n if (!promise) {\n promise = fetchFlowApiDefinitionFromRemote(namespaceName, name, version);\n remoteContractCache.set(provider, promise);\n }\n return promise;\n}\n\nasync function fetchFlowApiDefinitionFromRemote(\n namespace: string,\n name: string,\n version: string\n): Promise<CustomApiDefinition | null> {\n const { contractData } = await ContractApi_searchSingleContract({\n contractName: `${namespace}.${name}`,\n version,\n });\n\n // return undefined if don't found contract\n return contractData\n ? {\n name: contractData.name,\n namespace: contractData.namespace?.[0]?.name,\n serviceName: contractData.serviceName,\n version: contractData.version,\n contract: {\n endpoint: contractData.endpoint,\n response: contractData.response,\n request: contractData.request,\n },\n }\n : null;\n}\n\nexport interface CustomApiDefinition {\n name: string;\n namespace: string;\n version?: string;\n serviceName?: string;\n contract?: {\n endpoint: {\n ext_fields?: ExtField[];\n uri: string;\n method:\n | \"POST\"\n | \"post\"\n | \"PUT\"\n | \"put\"\n | \"GET\"\n | \"get\"\n | \"DELETE\"\n | \"delete\"\n | \"LIST\"\n | \"list\"\n | \"PATCH\"\n | \"patch\"\n | \"HEAD\"\n | \"head\";\n };\n request?: ContractRequest;\n response?: ContractResponse;\n };\n}\n\nexport interface CustomApiProfile {\n uri: string;\n method: string;\n name: string;\n namespace: string;\n serviceName?: string;\n responseWrapper: boolean;\n version?: string;\n isFileType?: boolean;\n ext_fields?: ExtField[];\n request?: ContractRequest;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,MAAMG,mBAAmB,GAAG,IAAIC,GAAG,CAGjC,CAAC;;AAEH;AACA;AACO,SAASC,iBAAiBA,CAACC,QAAgB,EAAW;EAC3D,OAAOA,QAAQ,CAACC,QAAQ,CAAC,GAAG,CAAC;AAC/B;AAEO,eAAeC,gBAAgBA,CACpCF,QAAgB,EAChBG,YAAuB,EACvBC,MAAe,EACK;EACpB,IAAI,CAACJ,QAAQ,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC3B,MAAM,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C,IAAI,CAACqD,OAAO,EAAE;IACZA,OAAO,GAAGE,gCAAgC,CAACP,aAAa,EAAEjC,IAAI,EAAEI,OAAO,CAAC;IACxEtB,mBAAmB,CAAC2D,GAAG,CAACxD,QAAQ,EAAEqD,OAAO,CAAC;EAC5C;EACA,OAAOA,OAAO;AAChB;AAEA,eAAeE,gCAAgCA,CAC7CvC,SAAiB,EACjBD,IAAY,EACZI,OAAe,EACsB;EAAA,IAAAsC,qBAAA;EACrC,MAAM;IAAEC;EAAa,CAAC,GAAG,MAAM,IAAAC,+CAAgC,EAAC;IAC9DC,YAAY,EAAG,GAAE5C,SAAU,IAAGD,IAAK,EAAC;IACpCI;EACF,CAAC,CAAC;;EAEF;EACA,OAAOuC,YAAY,GACf;IACE3C,IAAI,EAAE2C,YAAY,CAAC3C,IAAI;IACvBC,SAAS,GAAAyC,qBAAA,GAAEC,YAAY,CAAC1C,SAAS,cAAAyC,qBAAA,gBAAAA,qBAAA,GAAtBA,qBAAA,CAAyB,CAAC,CAAC,cAAAA,qBAAA,uBAA3BA,qBAAA,CAA6B1C,IAAI;IAC5CE,WAAW,EAAEyC,YAAY,CAACzC,WAAW;IACrCE,OAAO,EAAEuC,YAAY,CAACvC,OAAO;IAC7BkB,QAAQ,EAAE;MACRM,QAAQ,EAAEe,YAAY,CAACf,QAAQ;MAC/BC,QAAQ,EAAEc,YAAY,CAACd,QAAQ;MAC/BvB,OAAO,EAAEqC,YAAY,CAACrC;IACxB;EACF,CAAC,GACD,IAAI;AACV"}
1
+ {"version":3,"file":"FlowApi.js","names":["_jsYaml","_interopRequireDefault","require","_apiGatewaySdk","_CollectContracts","remoteContractCache","Map","isFlowApiProvider","provider","includes","getArgsOfFlowApi","originalArgs","method","Error","apiDefinition","fetchFlowApiDefinition","FlowApiNotFoundError","apiProfile","getApiProfileFromApiDefinition","getApiArgsFromApiProfile","uri","apiMethod","ext_fields","name","namespace","serviceName","responseWrapper","version","isFileType","request","isDownload","fileName","shift","url","args","getTransformedUriAndRestArgs","originalUri","prefix","restArgs","slice","transformedUri","replace","api","_contract$endpoint","_contract$response","contract","yaml","safeLoad","schema","JSON_SCHEMA","json","endpoint","response","wrapper","toLowerCase","type","namespaceName","nameWithVersion","split","getContract","namespaceId","promise","get","fetchFlowApiDefinitionFromRemote","set","_contractData$namespa","contractData","ContractApi_searchSingleContract","contractName","constructor","message","captureStackTrace"],"sources":["../../../src/flowApi/FlowApi.ts"],"sourcesContent":["import yaml from \"js-yaml\";\nimport { ContractApi_searchSingleContract } from \"@next-api-sdk/api-gateway-sdk\";\nimport { ContractRequest, ContractResponse, ExtField } from \"@next-core/types\";\nimport { getContract } from \"./CollectContracts.js\";\n\nconst remoteContractCache = new Map<\n string,\n Promise<CustomApiDefinition | null>\n>();\n\n// Legacy Custom API: `${namespace}@${name}`\n// Flow API: `${namespace}@${name}:${version}`\nexport function isFlowApiProvider(provider: string): boolean {\n return provider.includes(\"@\");\n}\n\nexport async function getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n): Promise<unknown[]> {\n if (!provider.includes(\":\")) {\n throw new Error(\n `You're using legacy Custom API \"${provider}\" which is dropped in v3, please use Flow API instead`\n );\n }\n\n const apiDefinition = await fetchFlowApiDefinition(provider);\n\n if (!apiDefinition) {\n throw new FlowApiNotFoundError(`Flow API not found: \"${provider}\"`);\n }\n\n const apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);\n\n return getApiArgsFromApiProfile(apiProfile, originalArgs, method);\n}\n\nfunction getApiArgsFromApiProfile(\n {\n uri,\n method: apiMethod,\n ext_fields,\n name,\n namespace,\n serviceName,\n responseWrapper,\n version,\n isFileType,\n request,\n }: CustomApiProfile,\n originalArgs: unknown[],\n method?: string\n): unknown[] {\n const isDownload = isFileType && method === \"saveAs\";\n let fileName: string | undefined;\n if (isDownload) {\n fileName = originalArgs.shift() as string;\n }\n\n const { url, args } = getTransformedUriAndRestArgs(\n uri,\n originalArgs,\n name,\n namespace,\n serviceName,\n version\n );\n\n return [\n ...(isDownload ? [fileName] : []),\n {\n url,\n originalUri: uri,\n method: apiMethod,\n ext_fields,\n responseWrapper,\n request,\n isFileType,\n },\n ...args,\n ];\n}\n\nfunction getTransformedUriAndRestArgs(\n uri: string,\n originalArgs: unknown[],\n name: string,\n namespace: string,\n serviceName: string | undefined,\n version?: string\n): { url: string; args: unknown[] } {\n const prefix = version\n ? serviceName\n ? `api/gateway/${serviceName}`\n : `api/gateway/${namespace}.${name}@${version}`\n : `api/gateway/api_service.${namespace}.${name}`;\n const restArgs = originalArgs.slice();\n const transformedUri = uri.replace(\n /:([^/]+)/g,\n () => restArgs.shift() as string\n );\n return {\n url: prefix + transformedUri,\n args: restArgs,\n };\n}\n\nfunction getApiProfileFromApiDefinition(\n provider: string,\n api: CustomApiDefinition\n): CustomApiProfile {\n const contract: CustomApiDefinition[\"contract\"] =\n typeof api.contract === \"string\"\n ? (yaml.safeLoad(api.contract, {\n schema: yaml.JSON_SCHEMA,\n json: true,\n }) as CustomApiDefinition[\"contract\"])\n : api.contract;\n const { uri, method = \"GET\", ext_fields } = contract?.endpoint ?? {};\n const responseWrapper = contract?.response\n ? contract.response.wrapper !== false\n : false;\n if (!uri) {\n throw new Error(\n `Missing endpoint.uri in contract of provider \"${provider}\"`\n );\n }\n return {\n uri,\n method: method.toLowerCase() === \"list\" ? \"get\" : method,\n ext_fields,\n name: api.name,\n namespace: api.namespace,\n serviceName: api.serviceName,\n version: api.version,\n isFileType: contract?.response?.type === \"file\",\n responseWrapper,\n request: contract?.request,\n };\n}\n\nasync function fetchFlowApiDefinition(\n provider: string\n): Promise<CustomApiDefinition | null> {\n const [namespaceName, nameWithVersion] = provider.split(\"@\");\n const [name, version] = nameWithVersion.split(\":\");\n\n // Do not cache the result of `geContract`, which will lead to no contract\n // will be found when render twice immediately.\n const contract = getContract(`${namespaceName}.${name}`);\n if (contract) {\n return {\n name: contract.name,\n namespace: contract.namespaceId,\n serviceName: contract.serviceName,\n version: contract.version,\n contract: {\n endpoint: contract.endpoint,\n response: contract.response,\n request: contract.request,\n },\n };\n }\n let promise = remoteContractCache.get(provider);\n if (!promise) {\n promise = fetchFlowApiDefinitionFromRemote(namespaceName, name, version);\n remoteContractCache.set(provider, promise);\n }\n return promise;\n}\n\nasync function fetchFlowApiDefinitionFromRemote(\n namespace: string,\n name: string,\n version: string\n): Promise<CustomApiDefinition | null> {\n const { contractData } = await ContractApi_searchSingleContract({\n contractName: `${namespace}.${name}`,\n version,\n });\n\n // return undefined if don't found contract\n return contractData\n ? {\n name: contractData.name,\n namespace: contractData.namespace?.[0]?.name,\n serviceName: contractData.serviceName,\n version: contractData.version,\n contract: {\n endpoint: contractData.endpoint,\n response: contractData.response,\n request: contractData.request,\n },\n }\n : null;\n}\n\nexport interface CustomApiDefinition {\n name: string;\n namespace: string;\n version?: string;\n serviceName?: string;\n contract?: {\n endpoint: {\n ext_fields?: ExtField[];\n uri: string;\n method:\n | \"POST\"\n | \"post\"\n | \"PUT\"\n | \"put\"\n | \"GET\"\n | \"get\"\n | \"DELETE\"\n | \"delete\"\n | \"LIST\"\n | \"list\"\n | \"PATCH\"\n | \"patch\"\n | \"HEAD\"\n | \"head\";\n };\n request?: ContractRequest;\n response?: ContractResponse;\n };\n}\n\nexport interface CustomApiProfile {\n uri: string;\n method: string;\n name: string;\n namespace: string;\n serviceName?: string;\n responseWrapper: boolean;\n version?: string;\n isFileType?: boolean;\n ext_fields?: ExtField[];\n request?: ContractRequest;\n}\n\nclass FlowApiNotFoundError extends Error {\n constructor(message: string) {\n // Pass remaining arguments (including vendor specific ones) to parent constructor\n super(message);\n\n this.name = \"FlowApiNotFoundError\";\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n // istanbul ignore else\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FlowApiNotFoundError);\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAA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;AACV;AA6CA,MAAMb,oBAAoB,SAASH,KAAK,CAAC;EACvCwD,WAAWA,CAACC,OAAe,EAAE;IAC3B;IACA,KAAK,CAACA,OAAO,CAAC;IAEd,IAAI,CAAC/C,IAAI,GAAG,sBAAsB;;IAElC;IACA;IACA,IAAIV,KAAK,CAAC0D,iBAAiB,EAAE;MAC3B1D,KAAK,CAAC0D,iBAAiB,CAAC,IAAI,EAAEvD,oBAAoB,CAAC;IACrD;EACF;AACF"}
@@ -19,9 +19,7 @@ function _getArgsOfFlowApi() {
19
19
  }
20
20
  var apiDefinition = yield fetchFlowApiDefinition(provider);
21
21
  if (!apiDefinition) {
22
- throw new Error("Flow API not found: \"".concat(provider, "\""), {
23
- cause: "FLOW_API_NOT_FOUND"
24
- });
22
+ throw new FlowApiNotFoundError("Flow API not found: \"".concat(provider, "\""));
25
23
  }
26
24
  var apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);
27
25
  return getApiArgsFromApiProfile(apiProfile, originalArgs, method);
@@ -158,4 +156,17 @@ function _fetchFlowApiDefinitionFromRemote() {
158
156
  });
159
157
  return _fetchFlowApiDefinitionFromRemote.apply(this, arguments);
160
158
  }
159
+ class FlowApiNotFoundError extends Error {
160
+ constructor(message) {
161
+ // Pass remaining arguments (including vendor specific ones) to parent constructor
162
+ super(message);
163
+ this.name = "FlowApiNotFoundError";
164
+
165
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
166
+ // istanbul ignore else
167
+ if (Error.captureStackTrace) {
168
+ Error.captureStackTrace(this, FlowApiNotFoundError);
169
+ }
170
+ }
171
+ }
161
172
  //# sourceMappingURL=FlowApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlowApi.js","names":["yaml","ContractApi_searchSingleContract","getContract","remoteContractCache","Map","isFlowApiProvider","provider","includes","getArgsOfFlowApi","_x","_x2","_x3","_getArgsOfFlowApi","apply","arguments","_asyncToGenerator","originalArgs","method","Error","concat","apiDefinition","fetchFlowApiDefinition","cause","apiProfile","getApiProfileFromApiDefinition","getApiArgsFromApiProfile","_ref","uri","apiMethod","ext_fields","name","namespace","serviceName","responseWrapper","version","isFileType","request","isDownload","fileName","shift","url","args","getTransformedUriAndRestArgs","originalUri","prefix","restArgs","slice","transformedUri","replace","api","_contract$endpoint","_contract$response","contract","safeLoad","schema","JSON_SCHEMA","json","endpoint","response","wrapper","toLowerCase","type","_x4","_fetchFlowApiDefinition","namespaceName","nameWithVersion","split","namespaceId","promise","get","fetchFlowApiDefinitionFromRemote","set","_x5","_x6","_x7","_fetchFlowApiDefinitionFromRemote","_contractData$namespa","contractData","contractName"],"sources":["../../../src/flowApi/FlowApi.ts"],"sourcesContent":["import yaml from \"js-yaml\";\nimport { ContractApi_searchSingleContract } from \"@next-api-sdk/api-gateway-sdk\";\nimport { ContractRequest, ContractResponse, ExtField } from \"@next-core/types\";\nimport { getContract } from \"./CollectContracts.js\";\n\nconst remoteContractCache = new Map<\n string,\n Promise<CustomApiDefinition | null>\n>();\n\n// Legacy Custom API: `${namespace}@${name}`\n// Flow API: `${namespace}@${name}:${version}`\nexport function isFlowApiProvider(provider: string): boolean {\n return provider.includes(\"@\");\n}\n\nexport async function getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n): Promise<unknown[]> {\n if (!provider.includes(\":\")) {\n throw new Error(\n `You're using legacy Custom API \"${provider}\" which is dropped in v3, please use Flow API instead`\n );\n }\n\n const apiDefinition = await fetchFlowApiDefinition(provider);\n\n if (!apiDefinition) {\n throw new Error(`Flow API not found: \"${provider}\"`, {\n cause: \"FLOW_API_NOT_FOUND\",\n });\n }\n\n const apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);\n\n return getApiArgsFromApiProfile(apiProfile, originalArgs, method);\n}\n\nfunction getApiArgsFromApiProfile(\n {\n uri,\n method: apiMethod,\n ext_fields,\n name,\n namespace,\n serviceName,\n responseWrapper,\n version,\n isFileType,\n request,\n }: CustomApiProfile,\n originalArgs: unknown[],\n method?: string\n): unknown[] {\n const isDownload = isFileType && method === \"saveAs\";\n let fileName: string | undefined;\n if (isDownload) {\n fileName = originalArgs.shift() as string;\n }\n\n const { url, args } = getTransformedUriAndRestArgs(\n uri,\n originalArgs,\n name,\n namespace,\n serviceName,\n version\n );\n\n return [\n ...(isDownload ? [fileName] : []),\n {\n url,\n originalUri: uri,\n method: apiMethod,\n ext_fields,\n responseWrapper,\n request,\n isFileType,\n },\n ...args,\n ];\n}\n\nfunction getTransformedUriAndRestArgs(\n uri: string,\n originalArgs: unknown[],\n name: string,\n namespace: string,\n serviceName: string | undefined,\n version?: string\n): { url: string; args: unknown[] } {\n const prefix = version\n ? serviceName\n ? `api/gateway/${serviceName}`\n : `api/gateway/${namespace}.${name}@${version}`\n : `api/gateway/api_service.${namespace}.${name}`;\n const restArgs = originalArgs.slice();\n const transformedUri = uri.replace(\n /:([^/]+)/g,\n () => restArgs.shift() as string\n );\n return {\n url: prefix + transformedUri,\n args: restArgs,\n };\n}\n\nfunction getApiProfileFromApiDefinition(\n provider: string,\n api: CustomApiDefinition\n): CustomApiProfile {\n const contract: CustomApiDefinition[\"contract\"] =\n typeof api.contract === \"string\"\n ? (yaml.safeLoad(api.contract, {\n schema: yaml.JSON_SCHEMA,\n json: true,\n }) as CustomApiDefinition[\"contract\"])\n : api.contract;\n const { uri, method = \"GET\", ext_fields } = contract?.endpoint ?? {};\n const responseWrapper = contract?.response\n ? contract.response.wrapper !== false\n : false;\n if (!uri) {\n throw new Error(\n `Missing endpoint.uri in contract of provider \"${provider}\"`\n );\n }\n return {\n uri,\n method: method.toLowerCase() === \"list\" ? \"get\" : method,\n ext_fields,\n name: api.name,\n namespace: api.namespace,\n serviceName: api.serviceName,\n version: api.version,\n isFileType: contract?.response?.type === \"file\",\n responseWrapper,\n request: contract?.request,\n };\n}\n\nasync function fetchFlowApiDefinition(\n provider: string\n): Promise<CustomApiDefinition | null> {\n const [namespaceName, nameWithVersion] = provider.split(\"@\");\n const [name, version] = nameWithVersion.split(\":\");\n\n // Do not cache the result of `geContract`, which will lead to no contract\n // will be found when render twice immediately.\n const contract = getContract(`${namespaceName}.${name}`);\n if (contract) {\n return {\n name: contract.name,\n namespace: contract.namespaceId,\n serviceName: contract.serviceName,\n version: contract.version,\n contract: {\n endpoint: contract.endpoint,\n response: contract.response,\n request: contract.request,\n },\n };\n }\n let promise = remoteContractCache.get(provider);\n if (!promise) {\n promise = fetchFlowApiDefinitionFromRemote(namespaceName, name, version);\n remoteContractCache.set(provider, promise);\n }\n return promise;\n}\n\nasync function fetchFlowApiDefinitionFromRemote(\n namespace: string,\n name: string,\n version: string\n): Promise<CustomApiDefinition | null> {\n const { contractData } = await ContractApi_searchSingleContract({\n contractName: `${namespace}.${name}`,\n version,\n });\n\n // return undefined if don't found contract\n return contractData\n ? {\n name: contractData.name,\n namespace: contractData.namespace?.[0]?.name,\n serviceName: contractData.serviceName,\n version: contractData.version,\n contract: {\n endpoint: contractData.endpoint,\n response: contractData.response,\n request: contractData.request,\n },\n }\n : null;\n}\n\nexport interface CustomApiDefinition {\n name: string;\n namespace: string;\n version?: string;\n serviceName?: string;\n contract?: {\n endpoint: {\n ext_fields?: ExtField[];\n uri: string;\n method:\n | \"POST\"\n | \"post\"\n | \"PUT\"\n | \"put\"\n | \"GET\"\n | \"get\"\n | \"DELETE\"\n | \"delete\"\n | \"LIST\"\n | \"list\"\n | \"PATCH\"\n | \"patch\"\n | \"HEAD\"\n | \"head\";\n };\n request?: ContractRequest;\n response?: ContractResponse;\n };\n}\n\nexport interface CustomApiProfile {\n uri: string;\n method: string;\n name: string;\n namespace: string;\n serviceName?: string;\n responseWrapper: boolean;\n version?: string;\n isFileType?: boolean;\n ext_fields?: ExtField[];\n request?: ContractRequest;\n}\n"],"mappings":";AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,SAASC,gCAAgC,QAAQ,+BAA+B;AAEhF,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,IAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAGjC,CAAC;;A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rC,IAAM;MAAEC;IAAa,CAAC,SAAS5E,gCAAgC,CAAC;MAC9D6E,YAAY,KAAA3D,MAAA,CAAKY,SAAS,OAAAZ,MAAA,CAAIW,IAAI,CAAE;MACpCI;IACF,CAAC,CAAC;;IAEF;IACA,OAAO2C,YAAY,GACf;MACE/C,IAAI,EAAE+C,YAAY,CAAC/C,IAAI;MACvBC,SAAS,GAAA6C,qBAAA,GAAEC,YAAY,CAAC9C,SAAS,cAAA6C,qBAAA,gBAAAA,qBAAA,GAAtBA,qBAAA,CAAyB,CAAC,CAAC,cAAAA,qBAAA,uBAA3BA,qBAAA,CAA6B9C,IAAI;MAC5CE,WAAW,EAAE6C,YAAY,CAAC7C,WAAW;MACrCE,OAAO,EAAE2C,YAAY,CAAC3C,OAAO;MAC7BkB,QAAQ,EAAE;QACRK,QAAQ,EAAEoB,YAAY,CAACpB,QAAQ;QAC/BC,QAAQ,EAAEmB,YAAY,CAACnB,QAAQ;QAC/BtB,OAAO,EAAEyC,YAAY,CAACzC;MACxB;IACF,CAAC,GACD,IAAI;EACV,CAAC;EAAA,OAAAuC,iCAAA,CAAA9D,KAAA,OAAAC,SAAA;AAAA"}
1
+ {"version":3,"file":"FlowApi.js","names":["yaml","ContractApi_searchSingleContract","getContract","remoteContractCache","Map","isFlowApiProvider","provider","includes","getArgsOfFlowApi","_x","_x2","_x3","_getArgsOfFlowApi","apply","arguments","_asyncToGenerator","originalArgs","method","Error","concat","apiDefinition","fetchFlowApiDefinition","FlowApiNotFoundError","apiProfile","getApiProfileFromApiDefinition","getApiArgsFromApiProfile","_ref","uri","apiMethod","ext_fields","name","namespace","serviceName","responseWrapper","version","isFileType","request","isDownload","fileName","shift","url","args","getTransformedUriAndRestArgs","originalUri","prefix","restArgs","slice","transformedUri","replace","api","_contract$endpoint","_contract$response","contract","safeLoad","schema","JSON_SCHEMA","json","endpoint","response","wrapper","toLowerCase","type","_x4","_fetchFlowApiDefinition","namespaceName","nameWithVersion","split","namespaceId","promise","get","fetchFlowApiDefinitionFromRemote","set","_x5","_x6","_x7","_fetchFlowApiDefinitionFromRemote","_contractData$namespa","contractData","contractName","constructor","message","captureStackTrace"],"sources":["../../../src/flowApi/FlowApi.ts"],"sourcesContent":["import yaml from \"js-yaml\";\nimport { ContractApi_searchSingleContract } from \"@next-api-sdk/api-gateway-sdk\";\nimport { ContractRequest, ContractResponse, ExtField } from \"@next-core/types\";\nimport { getContract } from \"./CollectContracts.js\";\n\nconst remoteContractCache = new Map<\n string,\n Promise<CustomApiDefinition | null>\n>();\n\n// Legacy Custom API: `${namespace}@${name}`\n// Flow API: `${namespace}@${name}:${version}`\nexport function isFlowApiProvider(provider: string): boolean {\n return provider.includes(\"@\");\n}\n\nexport async function getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n): Promise<unknown[]> {\n if (!provider.includes(\":\")) {\n throw new Error(\n `You're using legacy Custom API \"${provider}\" which is dropped in v3, please use Flow API instead`\n );\n }\n\n const apiDefinition = await fetchFlowApiDefinition(provider);\n\n if (!apiDefinition) {\n throw new FlowApiNotFoundError(`Flow API not found: \"${provider}\"`);\n }\n\n const apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);\n\n return getApiArgsFromApiProfile(apiProfile, originalArgs, method);\n}\n\nfunction getApiArgsFromApiProfile(\n {\n uri,\n method: apiMethod,\n ext_fields,\n name,\n namespace,\n serviceName,\n responseWrapper,\n version,\n isFileType,\n request,\n }: CustomApiProfile,\n originalArgs: unknown[],\n method?: string\n): unknown[] {\n const isDownload = isFileType && method === \"saveAs\";\n let fileName: string | undefined;\n if (isDownload) {\n fileName = originalArgs.shift() as string;\n }\n\n const { url, args } = getTransformedUriAndRestArgs(\n uri,\n originalArgs,\n name,\n namespace,\n serviceName,\n version\n );\n\n return [\n ...(isDownload ? [fileName] : []),\n {\n url,\n originalUri: uri,\n method: apiMethod,\n ext_fields,\n responseWrapper,\n request,\n isFileType,\n },\n ...args,\n ];\n}\n\nfunction getTransformedUriAndRestArgs(\n uri: string,\n originalArgs: unknown[],\n name: string,\n namespace: string,\n serviceName: string | undefined,\n version?: string\n): { url: string; args: unknown[] } {\n const prefix = version\n ? serviceName\n ? `api/gateway/${serviceName}`\n : `api/gateway/${namespace}.${name}@${version}`\n : `api/gateway/api_service.${namespace}.${name}`;\n const restArgs = originalArgs.slice();\n const transformedUri = uri.replace(\n /:([^/]+)/g,\n () => restArgs.shift() as string\n );\n return {\n url: prefix + transformedUri,\n args: restArgs,\n };\n}\n\nfunction getApiProfileFromApiDefinition(\n provider: string,\n api: CustomApiDefinition\n): CustomApiProfile {\n const contract: CustomApiDefinition[\"contract\"] =\n typeof api.contract === \"string\"\n ? (yaml.safeLoad(api.contract, {\n schema: yaml.JSON_SCHEMA,\n json: true,\n }) as CustomApiDefinition[\"contract\"])\n : api.contract;\n const { uri, method = \"GET\", ext_fields } = contract?.endpoint ?? {};\n const responseWrapper = contract?.response\n ? contract.response.wrapper !== false\n : false;\n if (!uri) {\n throw new Error(\n `Missing endpoint.uri in contract of provider \"${provider}\"`\n );\n }\n return {\n uri,\n method: method.toLowerCase() === \"list\" ? \"get\" : method,\n ext_fields,\n name: api.name,\n namespace: api.namespace,\n serviceName: api.serviceName,\n version: api.version,\n isFileType: contract?.response?.type === \"file\",\n responseWrapper,\n request: contract?.request,\n };\n}\n\nasync function fetchFlowApiDefinition(\n provider: string\n): Promise<CustomApiDefinition | null> {\n const [namespaceName, nameWithVersion] = provider.split(\"@\");\n const [name, version] = nameWithVersion.split(\":\");\n\n // Do not cache the result of `geContract`, which will lead to no contract\n // will be found when render twice immediately.\n const contract = getContract(`${namespaceName}.${name}`);\n if (contract) {\n return {\n name: contract.name,\n namespace: contract.namespaceId,\n serviceName: contract.serviceName,\n version: contract.version,\n contract: {\n endpoint: contract.endpoint,\n response: contract.response,\n request: contract.request,\n },\n };\n }\n let promise = remoteContractCache.get(provider);\n if (!promise) {\n promise = fetchFlowApiDefinitionFromRemote(namespaceName, name, version);\n remoteContractCache.set(provider, promise);\n }\n return promise;\n}\n\nasync function fetchFlowApiDefinitionFromRemote(\n namespace: string,\n name: string,\n version: string\n): Promise<CustomApiDefinition | null> {\n const { contractData } = await ContractApi_searchSingleContract({\n contractName: `${namespace}.${name}`,\n version,\n });\n\n // return undefined if don't found contract\n return contractData\n ? {\n name: contractData.name,\n namespace: contractData.namespace?.[0]?.name,\n serviceName: contractData.serviceName,\n version: contractData.version,\n contract: {\n endpoint: contractData.endpoint,\n response: contractData.response,\n request: contractData.request,\n },\n }\n : null;\n}\n\nexport interface CustomApiDefinition {\n name: string;\n namespace: string;\n version?: string;\n serviceName?: string;\n contract?: {\n endpoint: {\n ext_fields?: ExtField[];\n uri: string;\n method:\n | \"POST\"\n | \"post\"\n | \"PUT\"\n | \"put\"\n | \"GET\"\n | \"get\"\n | \"DELETE\"\n | \"delete\"\n | \"LIST\"\n | \"list\"\n | \"PATCH\"\n | \"patch\"\n | \"HEAD\"\n | \"head\";\n };\n request?: ContractRequest;\n response?: ContractResponse;\n };\n}\n\nexport interface CustomApiProfile {\n uri: string;\n method: string;\n name: string;\n namespace: string;\n serviceName?: string;\n responseWrapper: boolean;\n version?: string;\n isFileType?: boolean;\n ext_fields?: ExtField[];\n request?: ContractRequest;\n}\n\nclass FlowApiNotFoundError extends Error {\n constructor(message: string) {\n // Pass remaining arguments (including vendor specific ones) to parent constructor\n super(message);\n\n this.name = \"FlowApiNotFoundError\";\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n // istanbul ignore else\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FlowApiNotFoundError);\n }\n }\n}\n"],"mappings":";AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,SAASC,gCAAgC,QAAQ,+BAA+B;AAEhF,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,IAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAGjC,CAAC;;AAEH;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,QAAgB,EAAW;EAC3D,OAAOA,QAAQ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AAA,CAAIW,IAAI,CAAE;MACpCI;IACF,CAAC,CAAC;;IAEF;IACA,OAAO2C,YAAY,GACf;MACE/C,IAAI,EAAE+C,YAAY,CAAC/C,IAAI;MACvBC,SAAS,GAAA6C,qBAAA,GAAEC,YAAY,CAAC9C,SAAS,cAAA6C,qBAAA,gBAAAA,qBAAA,GAAtBA,qBAAA,CAAyB,CAAC,CAAC,cAAAA,qBAAA,uBAA3BA,qBAAA,CAA6B9C,IAAI;MAC5CE,WAAW,EAAE6C,YAAY,CAAC7C,WAAW;MACrCE,OAAO,EAAE2C,YAAY,CAAC3C,OAAO;MAC7BkB,QAAQ,EAAE;QACRK,QAAQ,EAAEoB,YAAY,CAACpB,QAAQ;QAC/BC,QAAQ,EAAEmB,YAAY,CAACnB,QAAQ;QAC/BtB,OAAO,EAAEyC,YAAY,CAACzC;MACxB;IACF,CAAC,GACD,IAAI;EACV,CAAC;EAAA,OAAAuC,iCAAA,CAAA9D,KAAA,OAAAC,SAAA;AAAA;AA6CD,MAAMQ,oBAAoB,SAASJ,KAAK,CAAC;EACvC6D,WAAWA,CAACC,OAAe,EAAE;IAC3B;IACA,KAAK,CAACA,OAAO,CAAC;IAEd,IAAI,CAAClD,IAAI,GAAG,sBAAsB;;IAElC;IACA;IACA,IAAIZ,KAAK,CAAC+D,iBAAiB,EAAE;MAC3B/D,KAAK,CAAC+D,iBAAiB,CAAC,IAAI,EAAE3D,oBAAoB,CAAC;IACrD;EACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/easyops-runtime",
3
- "version": "0.6.44",
3
+ "version": "0.6.46",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/easyops-runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "@next-core/cook": "^2.2.7",
48
48
  "@next-core/http": "^1.1.5",
49
49
  "@next-core/pipes": "^2.0.11",
50
- "@next-core/runtime": "^1.24.3",
50
+ "@next-core/runtime": "^1.24.5",
51
51
  "@next-core/types": "^1.7.1",
52
52
  "@next-core/utils": "^1.6.2",
53
53
  "js-yaml": "^3.14.1",
@@ -59,5 +59,5 @@
59
59
  "jest-websocket-mock": "^2.5.0",
60
60
  "whatwg-fetch": "^3.6.19"
61
61
  },
62
- "gitHead": "b251b1ab33315d47dec71ae257f40834af8bfa6c"
62
+ "gitHead": "97e23bfe9f2d53c33a6ef13e93d521335c9259f4"
63
63
  }