From fed8453f613685bd42698ae087c7c0b735c6d517 Mon Sep 17 00:00:00 2001 From: "Luiz H. R. Silva" Date: Tue, 4 Jun 2024 16:16:53 -0300 Subject: [PATCH] . --- dist-import/autenticacao.d.ts | 24 ------- dist-import/autenticacao.js | 23 +++++-- dist-import/index.d.ts | 2 - dist-import/tokenQuipo.d.ts | 34 --------- dist-require/autenticacao.js | 126 ++++++++++++++++++++++++++-------- dist-require/tokenQuipo.js | 2 +- package.json | 9 +-- src/autenticacao.ts | 2 +- tsconfig-back.json | 7 -- tsconfig-front.json | 7 -- tsconfig-import.json | 11 +++ tsconfig-require.json | 11 +++ tsconfig.json | 110 ++++------------------------- 13 files changed, 157 insertions(+), 211 deletions(-) delete mode 100644 dist-import/autenticacao.d.ts delete mode 100644 dist-import/index.d.ts delete mode 100644 dist-import/tokenQuipo.d.ts delete mode 100644 tsconfig-back.json delete mode 100644 tsconfig-front.json create mode 100644 tsconfig-import.json create mode 100644 tsconfig-require.json diff --git a/dist-import/autenticacao.d.ts b/dist-import/autenticacao.d.ts deleted file mode 100644 index cb35680..0000000 --- a/dist-import/autenticacao.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { type tipoResposta } from "~respostas"; -type tipoPostValidarTokem = { - token: string; -}; -type tipoPostCodigoContaSite = { - site: string; -}; -/** todas as rotas de comunicação com autenticador partem dessa variável */ -export declare const pAutenticacao: { - validarToken: ({ ambiente, post, buscar, }: { - ambiente: "desenvolvimento" | "producao"; - post: tipoPostValidarTokem; - /** função que conecta com a API */ - buscar: (url: string, post: tipoPostValidarTokem) => Promise>; - }) => Promise<"valido" | "erro">; - urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string; - codigoContaSite: ({ ambiente, post, buscar, }: { - ambiente: "desenvolvimento" | "producao"; - post: tipoPostCodigoContaSite; - /** função que conecta com a API */ - buscar: (url: string, post: tipoPostCodigoContaSite) => Promise>; - }) => Promise>; -}; -export {}; diff --git a/dist-import/autenticacao.js b/dist-import/autenticacao.js index 82360b5..2ea6d9d 100644 --- a/dist-import/autenticacao.js +++ b/dist-import/autenticacao.js @@ -1,30 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import { respostaComuns } from "~respostas"; const urlAutenticacao = (ambiente) => `${ambiente == "producao" ? "https://carro-de-boi.idz.one" : "http://localhost:5030"}/autenticacao`; /** faz a validação do token */ -const validarToken = async ({ ambiente, post, buscar, }) => { +const validarToken = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () { const url = `${urlAutenticacao(ambiente)}/autenticacao/api/validar_token`; try { - const resposta = await buscar(url, post) + const resposta = yield buscar(url, post) .then((resposta) => resposta.eCerto ? "valido" : "erro") - .catch((e) => "erro"); + .catch(() => "erro"); return resposta; } catch (e) { return "erro"; } -}; -const codigoContaSite = async ({ ambiente, post, buscar, }) => { +}); +const codigoContaSite = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () { const url = `${urlAutenticacao(ambiente)}/autenticacao/api/codigo_prefeitura_site`; try { - const resp = await buscar(url, post).catch((e) => respostaComuns.erro(`erro ao buscar código do site: ${e}`)); + const resp = yield buscar(url, post).catch((e) => respostaComuns.erro(`erro ao buscar código do site: ${e}`)); return resp; } catch (e) { return respostaComuns.erro(`erro ao buscar código do site: ${e}`); } -}; +}); /** todas as rotas de comunicação com autenticador partem dessa variável */ export const pAutenticacao = { validarToken, diff --git a/dist-import/index.d.ts b/dist-import/index.d.ts deleted file mode 100644 index 6475344..0000000 --- a/dist-import/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./tokenQuipo"; -export * from "./autenticacao"; diff --git a/dist-import/tokenQuipo.d.ts b/dist-import/tokenQuipo.d.ts deleted file mode 100644 index 2b7afd8..0000000 --- a/dist-import/tokenQuipo.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { z } from "zod"; -export declare const ztokenQuipo: z.ZodObject<{ - provedor: z.ZodString; - codigo_usuario: z.ZodString; - nome_usuario: z.ZodString; - codigo_conta: z.ZodString; - nome_conta: z.ZodString; - codigo_autenticacao: z.ZodString; - codigo_acesso_produto: z.ZodString; - tipo_de_acesso: z.ZodEnum<["publico", "governo", "sociedade"]>; - exp: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - provedor: string; - codigo_usuario: string; - nome_usuario: string; - codigo_conta: string; - nome_conta: string; - codigo_autenticacao: string; - codigo_acesso_produto: string; - tipo_de_acesso: "publico" | "governo" | "sociedade"; - exp?: number | undefined; -}, { - provedor: string; - codigo_usuario: string; - nome_usuario: string; - codigo_conta: string; - nome_conta: string; - codigo_autenticacao: string; - codigo_acesso_produto: string; - tipo_de_acesso: "publico" | "governo" | "sociedade"; - exp?: number | undefined; -}>; -export type tipos_de_acesso_quipo = z.infer["tipo_de_acesso"]; -export type tipoTokenQuipo = z.infer; diff --git a/dist-require/autenticacao.js b/dist-require/autenticacao.js index bb09cc3..828a33c 100644 --- a/dist-require/autenticacao.js +++ b/dist-require/autenticacao.js @@ -1,36 +1,104 @@ "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.pAutenticacao = void 0; -const _respostas_1 = require("~respostas"); -const urlAutenticacao = (ambiente) => `${ambiente == "producao" - ? "https://carro-de-boi.idz.one" - : "http://localhost:5030"}/autenticacao`; -/** faz a validação do token */ -const validarToken = async ({ ambiente, post, buscar, }) => { - const url = `${urlAutenticacao(ambiente)}/autenticacao/api/validar_token`; - try { - const resposta = await buscar(url, post) - .then((resposta) => resposta.eCerto ? "valido" : "erro") - .catch((e) => "erro"); - return resposta; - } - catch (e) { - return "erro"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -const codigoContaSite = async ({ ambiente, post, buscar, }) => { - const url = `${urlAutenticacao(ambiente)}/autenticacao/api/codigo_prefeitura_site`; - try { - const resp = await buscar(url, post).catch((e) => _respostas_1.respostaComuns.erro(`erro ao buscar código do site: ${e}`)); - return resp; - } - catch (e) { - return _respostas_1.respostaComuns.erro(`erro ao buscar código do site: ${e}`); - } +Object.defineProperty(exports, "__esModule", { value: true }); +exports.pAutenticacao = void 0; +var _respostas_1 = require("~respostas"); +var urlAutenticacao = function (ambiente) { + return "".concat(ambiente == "producao" + ? "https://carro-de-boi.idz.one" + : "http://localhost:5030", "/autenticacao"); +}; +/** faz a validação do token */ +var validarToken = function (_a) { + var ambiente = _a.ambiente, post = _a.post, buscar = _a.buscar; + return __awaiter(void 0, void 0, void 0, function () { + var url, resposta, e_1; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + url = "".concat(urlAutenticacao(ambiente), "/autenticacao/api/validar_token"); + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4 /*yield*/, buscar(url, post) + .then(function (resposta) { + return resposta.eCerto ? "valido" : "erro"; + }) + .catch(function () { return "erro"; })]; + case 2: + resposta = _b.sent(); + return [2 /*return*/, resposta]; + case 3: + e_1 = _b.sent(); + return [2 /*return*/, "erro"]; + case 4: return [2 /*return*/]; + } + }); + }); +}; +var codigoContaSite = function (_a) { + var ambiente = _a.ambiente, post = _a.post, buscar = _a.buscar; + return __awaiter(void 0, void 0, void 0, function () { + var url, resp, e_2; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + url = "".concat(urlAutenticacao(ambiente), "/autenticacao/api/codigo_prefeitura_site"); + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4 /*yield*/, buscar(url, post).catch(function (e) { + return _respostas_1.respostaComuns.erro("erro ao buscar c\u00F3digo do site: ".concat(e)); + })]; + case 2: + resp = _b.sent(); + return [2 /*return*/, resp]; + case 3: + e_2 = _b.sent(); + return [2 /*return*/, _respostas_1.respostaComuns.erro("erro ao buscar c\u00F3digo do site: ".concat(e_2))]; + case 4: return [2 /*return*/]; + } + }); + }); }; /** todas as rotas de comunicação com autenticador partem dessa variável */ exports.pAutenticacao = { - validarToken, - urlAutenticacao, - codigoContaSite, + validarToken: validarToken, + urlAutenticacao: urlAutenticacao, + codigoContaSite: codigoContaSite, }; diff --git a/dist-require/tokenQuipo.js b/dist-require/tokenQuipo.js index 966e99a..52da602 100644 --- a/dist-require/tokenQuipo.js +++ b/dist-require/tokenQuipo.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ztokenQuipo = void 0; -const zod_1 = require("zod"); +var zod_1 = require("zod"); exports.ztokenQuipo = zod_1.z.object({ provedor: zod_1.z.string(), codigo_usuario: zod_1.z.string(), diff --git a/package.json b/package.json index 1de1991..732ce99 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,18 @@ { "name": "~drives", - "version": "0.23.0", + "version": "0.28.0", "description": "", "main": "src/index.ts", "exports": { ".": { "import": "./dist-import/index.js", - "require": "./dist-require/index.js" + "require": "./dist-require/index.js", + "default": "./dist-require/index.js" } }, "scripts": { - "build-back": "rm -fr dist-require && tsc --project ./tsconfig-back.json", - "build-front": "rm -fr dist-import && tsc --project ./tsconfig-front.json", + "build-back": "rm -fr dist-require && tsc -p ./tsconfig-require.json", + "build-front": "rm -fr dist-import && tsc -p ./tsconfig-import.json", "build": "pnpm run biome && npm --no-git-tag-version version minor && pnpm run build-back && pnpm run build-front", "biome": "npx @biomejs/biome check --apply ./src", "nodev": "check-node-version --node '>= 20'" diff --git a/src/autenticacao.ts b/src/autenticacao.ts index d91b8af..4f78d05 100644 --- a/src/autenticacao.ts +++ b/src/autenticacao.ts @@ -30,7 +30,7 @@ const validarToken = async ({ .then((resposta) => resposta.eCerto ? ("valido" as const) : ("erro" as const), ) - .catch((e) => "erro" as const) + .catch(() => "erro" as const) return resposta } catch (e) { diff --git a/tsconfig-back.json b/tsconfig-back.json deleted file mode 100644 index c9cde5d..0000000 --- a/tsconfig-back.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig", - "compilerOptions": { - "outDir": "./dist-require", - "module": "commonjs" - } -} diff --git a/tsconfig-front.json b/tsconfig-front.json deleted file mode 100644 index ae18c06..0000000 --- a/tsconfig-front.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig", - "compilerOptions": { - "outDir": "./dist-import", - "module": "ES6" - } -} diff --git a/tsconfig-import.json b/tsconfig-import.json new file mode 100644 index 0000000..ef03fa1 --- /dev/null +++ b/tsconfig-import.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist-import", + "target": "ES2015", + "module": "ES2015", + "declaration": false, + "declarationMap": false, + "sourceMap": false + } +} diff --git a/tsconfig-require.json b/tsconfig-require.json new file mode 100644 index 0000000..68b68de --- /dev/null +++ b/tsconfig-require.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "target": "ES5", + "outDir": "./dist-require", + "declaration": true, + "declarationMap": false, + "sourceMap": false + }, +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index de02ecb..90a7a0d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,100 +1,20 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "ES2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - "lib": ["dom.iterable"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - "experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */, - "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */, - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - - /* Modules */ - "rootDir": "./src" /* Specify the root folder within your source files. */, - "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "resolveJsonModule": true, /* Enable importing .json files */ - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ - - /* Emit */ - "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - - /* Type Checking */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + "lib": ["es5", "es6", "es7", "esnext", "dom"], + "target": "es2018", + "removeComments": false, + "esModuleInterop": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "strict": true, + "skipLibCheck": true, + "strictPropertyInitialization": false, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "downlevelIteration": true, + "isolatedModules": true }, "include": ["src/**/*"] }