├── .gitignore ├── .prettierrc ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── PluginContribution.md ├── README.en-US.md ├── README.md ├── README.zh-CN.md ├── docs ├── Configuration.md ├── PontxMocks.md ├── VSCodeExtensionGuide.md └── images │ └── pontx-ui.png ├── dpublish.json ├── examples ├── eggjs-ts-app │ ├── .eslintignore │ ├── .eslintrc │ ├── .gitignore │ ├── README.md │ ├── app │ │ ├── pontx │ │ │ ├── .gitignore │ │ │ └── sdk │ │ │ │ ├── api.d.ts │ │ │ │ ├── defs.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ └── petstore │ │ │ │ ├── api-lock.json │ │ │ │ ├── spec.d.ts │ │ │ │ └── type.d.ts │ │ ├── router.ts │ │ └── service │ │ │ └── Pet.ts │ ├── config │ │ ├── config.default.ts │ │ ├── config.local.ts │ │ ├── config.prod.ts │ │ ├── plugin.ts │ │ └── pontx-config.json │ ├── package.json │ └── tsconfig.json ├── node-app │ ├── config │ │ └── pontx-config.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── services │ │ │ ├── .gitignore │ │ │ └── sdk │ │ │ ├── README.md │ │ │ ├── api.d.ts │ │ │ ├── defaults.ts │ │ │ ├── defs.d.ts │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── index.ts │ │ │ ├── petstore │ │ │ ├── api-lock.json │ │ │ ├── index.ts │ │ │ ├── meta.js │ │ │ ├── meta.json │ │ │ ├── request.ts │ │ │ ├── spec.d.ts │ │ │ └── type.d.ts │ │ │ └── request.ts │ └── tsconfig.json ├── react-app-hooks │ ├── .eslintrc.cjs │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── pontx-config.json │ ├── index.html │ ├── package.json │ ├── public │ │ └── vite.svg │ ├── src │ │ ├── App.css │ │ ├── App.tsx │ │ ├── assets │ │ │ └── react.svg │ │ ├── index.css │ │ ├── main.tsx │ │ ├── services │ │ │ ├── .gitignore │ │ │ └── sdk │ │ │ │ ├── README.md │ │ │ │ ├── api.d.ts │ │ │ │ ├── defaults.ts │ │ │ │ ├── defs.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.js │ │ │ │ ├── index.ts │ │ │ │ ├── petstore │ │ │ │ ├── api-lock.json │ │ │ │ ├── index.ts │ │ │ │ ├── meta.js │ │ │ │ ├── meta.json │ │ │ │ ├── request.ts │ │ │ │ ├── spec.d.ts │ │ │ │ └── type.d.ts │ │ │ │ └── request.ts │ │ ├── types │ │ │ ├── global.d.ts │ │ │ └── imports.d.ts │ │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts ├── react-app-oas3 │ ├── .eslintrc.cjs │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── pontx-config.json │ ├── index.html │ ├── package.json │ ├── public │ │ └── vite.svg │ ├── src │ │ ├── App.css │ │ ├── App.tsx │ │ ├── assets │ │ │ └── react.svg │ │ ├── index.css │ │ ├── main.tsx │ │ ├── services │ │ │ ├── .gitignore │ │ │ └── sdk │ │ │ │ ├── README.md │ │ │ │ ├── api.d.ts │ │ │ │ ├── defaults.ts │ │ │ │ ├── defs.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.js │ │ │ │ ├── index.ts │ │ │ │ ├── petstore │ │ │ │ ├── api-lock.json │ │ │ │ ├── index.ts │ │ │ │ ├── meta.js │ │ │ │ ├── meta.json │ │ │ │ ├── request.ts │ │ │ │ ├── spec.d.ts │ │ │ │ └── type.d.ts │ │ │ │ └── request.ts │ │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts └── react-app │ ├── .eslintrc.cjs │ ├── .gitignore │ ├── README.md │ ├── config │ └── pontx-config.json │ ├── index.html │ ├── package.json │ ├── public │ └── vite.svg │ ├── src │ ├── App.css │ ├── App.tsx │ ├── assets │ │ └── react.svg │ ├── index.css │ ├── main.tsx │ ├── services │ │ ├── .gitignore │ │ └── sdk │ │ │ ├── README.md │ │ │ ├── api.d.ts │ │ │ ├── defaults.ts │ │ │ ├── defs.d.ts │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── index.ts │ │ │ ├── petstore │ │ │ ├── api-lock.json │ │ │ ├── index.ts │ │ │ ├── meta.js │ │ │ ├── meta.json │ │ │ ├── request.ts │ │ │ ├── spec.d.ts │ │ │ └── type.d.ts │ │ │ └── request.ts │ ├── types │ │ ├── global.d.ts │ │ └── imports.d.ts │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts ├── jest.config.js ├── lerna.json ├── package.json ├── packages ├── generate │ ├── asset_source_loader.d.ts │ ├── package.json │ ├── plugin.js │ ├── src │ │ ├── index.ts │ │ ├── language │ │ │ ├── JavaScript.ts │ │ │ ├── TypeScript.ts │ │ │ └── index.ts │ │ ├── plugin │ │ │ ├── getFilesBySpecs.ts │ │ │ ├── index.tsx │ │ │ ├── plugin.ts │ │ │ ├── snippetsProvider.ts │ │ │ └── template │ │ │ │ ├── apiDTs.ts │ │ │ │ ├── fetch.ts │ │ │ │ ├── metaJSON.ts │ │ │ │ ├── rootFiles.ts │ │ │ │ ├── specIndex.ts │ │ │ │ ├── specIndexDTsWithController.ts │ │ │ │ ├── specIndexDTsWithoutController.ts │ │ │ │ ├── specInterfaceDts.ts │ │ │ │ ├── specTs.ts │ │ │ │ ├── specsDts.ts │ │ │ │ └── utils.tsx │ │ └── utils.ts │ ├── tsconfig.json │ └── yarn.lock ├── jsonschema-form │ ├── .gitignore │ ├── README.md │ ├── index.html │ ├── package.json │ ├── src │ │ ├── App.css │ │ ├── App.tsx │ │ ├── favicon.svg │ │ ├── index.css │ │ ├── logo.svg │ │ ├── main.tsx │ │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts ├── oas-spec-ts │ ├── Contribution.md │ ├── README.md │ ├── package.json │ ├── scripts │ │ ├── generateCode.ts │ │ ├── parseDom.ts │ │ └── tsconfig.json │ ├── src │ │ ├── JsonSchema.ts │ │ ├── index.ts │ │ ├── oas2.0 │ │ │ ├── definition.json │ │ │ └── swagger2.0.ts │ │ └── oas3.0 │ │ │ ├── definition.json │ │ │ └── swagger3.0.ts │ └── tsconfig.json ├── pontx-cli │ ├── README.md │ ├── bin │ │ └── init.js │ ├── package.json │ ├── src │ │ ├── debugLog.ts │ │ └── index.ts │ └── tsconfig.json ├── pontx-manager │ ├── package.json │ ├── src │ │ ├── LocalDictManager.ts │ │ ├── config.ts │ │ ├── generateAICode.ts │ │ ├── index.ts │ │ ├── logger.ts │ │ ├── manager.ts │ │ ├── scan.ts │ │ ├── translator.ts │ │ └── utils.ts │ └── tsconfig.json ├── pontx-spec-diff │ ├── README.md │ ├── package.json │ ├── src │ │ ├── diff.ts │ │ ├── diffDoc.ts │ │ ├── index.ts │ │ └── pureDiff.ts │ ├── tsconfig.commonjs.json │ └── tsconfig.json ├── pontx-spec │ ├── README.md │ ├── apiSchema.json │ ├── configSchema.json │ ├── docs │ │ ├── .nojekyll │ │ ├── README.md │ │ ├── classes │ │ │ ├── DiffItem.md │ │ │ ├── Mod.md │ │ │ ├── Parameter.md │ │ │ ├── PontAPI.md │ │ │ ├── PontDirectory.md │ │ │ ├── PontJsonSchema.md │ │ │ ├── PontNamespace.md │ │ │ ├── PontSpec.md │ │ │ ├── PontSpecs.md │ │ │ ├── PontxDirectoryNode.md │ │ │ └── SpecDiffTree.md │ │ ├── enums │ │ │ └── PontxDirectoryNodeType.md │ │ └── modules.md │ ├── package.json │ ├── pontSchema.json │ ├── schemas │ │ ├── api-schema.json │ │ ├── draft-04.json │ │ ├── oas2.json │ │ ├── pontx-config-schema.json │ │ ├── pontx-schema.json │ │ └── struct-schema.json │ ├── src │ │ ├── dataType.ts │ │ ├── diff.ts │ │ ├── index.ts │ │ ├── jsonpointer.ts │ │ ├── parameter.ts │ │ ├── parse.ts │ │ ├── type.ts │ │ └── utils.ts │ ├── structSchema.json │ ├── tsconfig.json │ ├── tsconfig.lib.json │ └── yarn.lock ├── pontx-ui │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── postcss.config.js │ ├── src │ │ ├── App.tsx │ │ ├── common │ │ │ ├── HighlightWord │ │ │ │ └── HighlightWord.tsx │ │ │ └── LeftMenu │ │ │ │ ├── APIDirectory.component.tsx │ │ │ │ ├── APIDirectory.scss │ │ │ │ ├── APIDirectory.tsx │ │ │ │ ├── SubMenu.tsx │ │ │ │ ├── hooks.tsx │ │ │ │ └── type.ts │ │ ├── components │ │ │ ├── changes │ │ │ │ ├── APIDiff.tsx │ │ │ │ ├── DiffContent.less │ │ │ │ ├── DiffContent.tsx │ │ │ │ ├── DiffPage.tsx │ │ │ │ └── utils.tsx │ │ │ ├── components.less │ │ │ ├── components.scss │ │ │ ├── designer │ │ │ │ └── SchemaDesigner.tsx │ │ │ ├── docs │ │ │ │ ├── API.less │ │ │ │ ├── API.tsx │ │ │ │ ├── ApiParamsDoc.tsx │ │ │ │ ├── BaseClass.less │ │ │ │ ├── BaseClass.tsx │ │ │ │ └── utils.tsx │ │ │ ├── global.less │ │ │ ├── index.tsx │ │ │ ├── resources │ │ │ │ ├── api-outline.svg │ │ │ │ ├── api.svg │ │ │ │ ├── pontx.png │ │ │ │ ├── pontx.svg │ │ │ │ └── struct-outline.svg │ │ │ ├── style │ │ │ │ ├── font_1899989_82eb16avvpq.eot │ │ │ │ ├── font_1899989_lqawitevtzp.ttf │ │ │ │ ├── font_1899989_lqawitevtzp.woff │ │ │ │ ├── font_1899989_lqawitevtzp.woff2 │ │ │ │ └── themes.less │ │ │ └── utils │ │ │ │ ├── service.local.ts │ │ │ │ ├── service.ts │ │ │ │ └── utils.tsx │ │ ├── favicon.svg │ │ ├── index.ts │ │ ├── layout │ │ │ ├── Nav.less │ │ │ ├── Nav.tsx │ │ │ ├── Page.less │ │ │ ├── Page.tsx │ │ │ └── context.ts │ │ ├── logo.svg │ │ ├── main.tsx │ │ ├── pages │ │ │ ├── apiDoc │ │ │ │ ├── LeftMenu.less │ │ │ │ ├── LeftMenu.tsx │ │ │ │ └── index.tsx │ │ │ └── diffManager │ │ │ │ ├── DiffManager.less │ │ │ │ └── index.tsx │ │ ├── types.d.ts │ │ └── vite-env.d.ts │ ├── tailwind.config.js │ ├── tsconfig.build.json │ ├── tsconfig.commonjs.json │ ├── tsconfig.json │ ├── tsconfig.node.json │ ├── vite.config.ts │ ├── webpack.ui.css.js │ └── yarn.lock └── vscode-pontx │ ├── .vscode │ ├── lauch.json │ └── launch.json │ ├── .vscodeignore │ ├── LICENSE.txt │ ├── README.md │ ├── asset_source_loader.d.ts │ ├── media │ ├── config │ │ └── webpack.config.js │ ├── index.html │ ├── package.json │ ├── src │ │ ├── components │ │ │ └── App.tsx │ │ ├── favicon.svg │ │ ├── font_1899989_lqawitevtzp.ttf │ │ ├── icon.css │ │ ├── logo.svg │ │ ├── main.css │ │ ├── main.tsx │ │ ├── registerService.tsx │ │ ├── server.ts │ │ ├── utils │ │ │ └── utils.ts │ │ └── vite-env.d.ts │ ├── tsconfig.commonjs.json │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts │ ├── package.json │ ├── resource-control-api-protocol.json │ ├── resources │ ├── api-outline.svg │ ├── api.svg │ ├── pontx.png │ ├── pontx.svg │ └── struct-outline.svg │ ├── schemas │ ├── api-schema.json │ ├── draft-04.json │ ├── oas2.json │ ├── pontx-config-schema.json │ ├── pontx-schema.json │ └── struct-schema.json │ ├── src │ ├── Service.ts │ ├── UI.ts │ ├── changes │ │ ├── ChangexTreeItem.ts │ │ ├── TreeItem.ts │ │ ├── guide.md │ │ └── utils.ts │ ├── commands.ts │ ├── explorer.ts │ ├── extension.ts │ ├── utils.ts │ └── webview.ts │ ├── task.md │ ├── tsconfig.json │ └── yarn.lock ├── plugins ├── fetch │ └── pontx-meta-fetch-plugin │ │ ├── package.json │ │ ├── src │ │ ├── LocalDictManager.ts │ │ └── index.ts │ │ └── tsconfig.json ├── generate │ ├── core │ │ ├── asset_source_loader.d.ts │ │ ├── package.json │ │ ├── src │ │ │ ├── CodeGenerator.ts │ │ │ ├── FileGenerator.ts │ │ │ ├── Snippet.ts │ │ │ ├── index.ts │ │ │ └── utils.ts │ │ └── tsconfig.json │ ├── pontx-async-sdk-plugin │ │ ├── package.json │ │ ├── src │ │ │ └── index.tsx │ │ └── tsconfig.json │ ├── pontx-eggjs-sdk-plugin │ │ ├── package.json │ │ ├── src │ │ │ ├── index.tsx │ │ │ └── template │ │ │ │ ├── apiDTs.ts │ │ │ │ ├── rootFiles.ts │ │ │ │ ├── specIndexDTsWithController.ts │ │ │ │ ├── specIndexDTsWithoutController.ts │ │ │ │ ├── specInterfaceDts.ts │ │ │ │ ├── specsDts.ts │ │ │ │ └── utils.tsx │ │ └── tsconfig.json │ └── pontx-react-hooks-sdk-plugin │ │ ├── asset_source_loader.d.ts │ │ ├── package.json │ │ ├── src │ │ └── index.ts │ │ └── tsconfig.json ├── mocks │ └── pontx-mocks-plugin │ │ ├── package.json │ │ ├── src │ │ ├── index.ts │ │ └── utils.ts │ │ └── tsconfig.json ├── parser │ ├── pontx-oas2-parser-plugin │ │ ├── package.json │ │ ├── src │ │ │ ├── index.ts │ │ │ └── oas2 │ │ │ │ ├── compiler.ts │ │ │ │ ├── index.ts │ │ │ │ ├── parser.ts │ │ │ │ ├── schema.ts │ │ │ │ └── utils.ts │ │ ├── tsconfig.es6.json │ │ └── tsconfig.json │ └── pontx-oas3-parser-plugin │ │ ├── package.json │ │ ├── src │ │ ├── index.ts │ │ └── oas3 │ │ │ ├── compiler.ts │ │ │ ├── index.ts │ │ │ ├── parser.ts │ │ │ ├── schema.ts │ │ │ └── utils.ts │ │ ├── tsconfig.es6.json │ │ └── tsconfig.json └── report │ └── pontx-report-plugin │ ├── package.json │ ├── src │ └── index.ts │ └── tsconfig.json ├── progress.md ├── scripts ├── batch.js ├── buildNpm.js ├── changelog.js ├── checkComment.sh ├── clean-lock.js ├── configure-references.js ├── jest.js ├── patchNpm.js ├── release.js ├── releaseNpm.js ├── releasePlatform.js ├── releaseRestPkgs.js ├── releaseVscode.sh ├── syncRegistry.js ├── utils.js ├── verifyCommit.js └── verifySafeCode.js ├── sdk ├── pontx-eggjs-sdk │ ├── package.json │ ├── src │ │ ├── getMetaDataFromSpec.ts │ │ └── index.tsx │ └── tsconfig.json ├── pontx-hooks-sdk │ ├── package.json │ ├── src │ │ ├── index.tsx │ │ └── type.ts │ └── tsconfig.json └── pontx-sdk-core │ ├── package.json │ ├── src │ ├── auth.ts │ ├── helper.ts │ ├── index.tsx │ ├── providers │ │ ├── base.ts │ │ ├── fetch.ts │ │ ├── nodejs.ts │ │ └── react-hooks.ts │ ├── requester.ts │ ├── sdk.ts │ ├── sse │ │ ├── browser.ts │ │ ├── nodejs.ts │ │ └── type.ts │ ├── type.d.ts │ └── types.ts │ └── tsconfig.json ├── semix ├── semix-form │ ├── README.md │ ├── index.html │ ├── package.json │ ├── postcss.config.js │ ├── src │ │ ├── SemixForm.less │ │ ├── SemixForm.tsx │ │ ├── common │ │ │ ├── ErrorMessage.tsx │ │ │ ├── Field.less │ │ │ ├── Field.tsx │ │ │ ├── FormItem.tsx │ │ │ ├── Title.less │ │ │ ├── Title.tsx │ │ │ ├── Widget.tsx │ │ │ ├── index.less │ │ │ └── index.tsx │ │ ├── context.tsx │ │ ├── defaultWidgets.tsx │ │ ├── index.tsx │ │ ├── langs │ │ │ ├── en_US │ │ │ │ ├── amp_widgets.ts │ │ │ │ ├── apiDebugger.ts │ │ │ │ ├── api_change_detail.ts │ │ │ │ ├── api_change_group.ts │ │ │ │ ├── base.ts │ │ │ │ ├── cases.ts │ │ │ │ ├── extErrorMapping.ts │ │ │ │ ├── index.ts │ │ │ │ ├── jsonschema_form.ts │ │ │ │ ├── utils.ts │ │ │ │ └── workbench_widgets.ts │ │ │ └── zh_CN │ │ │ │ ├── amp_widgets.ts │ │ │ │ ├── apiDebugger.ts │ │ │ │ ├── api_change_detail.ts │ │ │ │ ├── api_change_group.ts │ │ │ │ ├── base.ts │ │ │ │ ├── cases.ts │ │ │ │ ├── extErrorMapping.ts │ │ │ │ ├── index.ts │ │ │ │ ├── jsonschema_form.ts │ │ │ │ ├── utils.ts │ │ │ │ └── workbench_widgets.ts │ │ ├── styles.less │ │ ├── type.tsx │ │ ├── utils.tsx │ │ ├── validate.ts │ │ └── widgets │ │ │ └── flowbite │ │ │ ├── Card.tsx │ │ │ ├── Object.tsx │ │ │ ├── Title.less │ │ │ ├── Title.tsx │ │ │ ├── checkbox.tsx │ │ │ ├── enum.less │ │ │ ├── enum.tsx │ │ │ ├── index.less │ │ │ ├── index.tsx │ │ │ ├── list.less │ │ │ ├── list.tsx │ │ │ ├── map.tsx │ │ │ ├── number.tsx │ │ │ ├── radio.less │ │ │ ├── radio.tsx │ │ │ ├── string.less │ │ │ ├── string.tsx │ │ │ ├── stringList.tsx │ │ │ └── swtich.tsx │ ├── tailwind.config.js │ ├── tsconfig.json │ ├── vite.config.ts │ └── webpack.css.js └── semix-rule-center │ ├── README.md │ ├── package.json │ ├── src │ ├── LintButton.tsx │ ├── LintSwitcher.tsx │ ├── SemixLintRow.tsx │ ├── SwitchButton.tsx │ ├── SwitchButtonGroup.tsx │ ├── index.less │ ├── index.tsx │ ├── types.ts │ ├── useRuleLintState.ts │ └── utils.tsx │ └── tsconfig.json ├── tests ├── configs │ └── multiple-origins-pontx-config.json └── origins │ ├── oas2.json │ └── oneapi.json ├── tsconfig.build.json ├── tsconfig.json └── yarn.lock /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "tabWidth": 2, 4 | "printWidth": 120, 5 | "singleQuote": false 6 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "emmet.triggerExpansionOnTab": true, 3 | "editor.formatOnSave": true, 4 | "[typescriptreact]": { 5 | "editor.defaultFormatter": "esbenp.prettier-vscode" 6 | }, 7 | "[json]": { 8 | "editor.defaultFormatter": "esbenp.prettier-vscode" 9 | }, 10 | "prettier.requireConfig": true, 11 | "[less]": { 12 | "editor.defaultFormatter": "esbenp.prettier-vscode" 13 | }, 14 | "[typescript]": { 15 | "editor.defaultFormatter": "esbenp.prettier-vscode" 16 | }, 17 | "[jsonc]": { 18 | "editor.defaultFormatter": "esbenp.prettier-vscode" 19 | }, 20 | "[javascript]": { 21 | "editor.defaultFormatter": "esbenp.prettier-vscode" 22 | }, 23 | "[css]": { 24 | "editor.defaultFormatter": "esbenp.prettier-vscode" 25 | }, 26 | "json.schemas": [ 27 | { 28 | "fileMatch": ["/*-pontx-config.json"], 29 | "url": "/packages/pontx-spec/configSchema.json" 30 | }, 31 | { 32 | "fileMatch": ["/*.rcapi.json"], 33 | "url": "/packages/vscode-pontx/resource-control-api-protocol.json" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "test", 9 | "path": "packages/pontx-spec-diff", 10 | "group": { 11 | "kind": "test", 12 | "isDefault": true 13 | }, 14 | "problemMatcher": [], 15 | "label": "test:pontx-spec-diff", 16 | "detail": "tsc -p tests/tsconfig.json" 17 | }, 18 | { 19 | "type": "npm", 20 | "script": "esbuild-watch", 21 | "path": "packages/vscode-pontx", 22 | "group": { 23 | "kind": "build", 24 | "isDefault": true 25 | }, 26 | "problemMatcher": [], 27 | "label": "vscode-pontx:esbuild-watch" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## 2023-06-06 4 | 1. FEAT: `pontx-config.json` new parameters `plugins.fetch.options.translate.cacheFilePath`,Caching translation results 5 | 6 | ## 2023-06-03 7 | 1. FIX: update baidu translate lib 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 pontjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/PontxMocks.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/docs/PontxMocks.md -------------------------------------------------------------------------------- /docs/VSCodeExtensionGuide.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/docs/VSCodeExtensionGuide.md -------------------------------------------------------------------------------- /docs/images/pontx-ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/docs/images/pontx-ui.png -------------------------------------------------------------------------------- /dpublish.json: -------------------------------------------------------------------------------- 1 | { 2 | "publishType": "npm", 3 | "usingYarn": true 4 | } 5 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/.eslintignore: -------------------------------------------------------------------------------- 1 | **/*.d.ts 2 | node_modules/ 3 | app/pontx/ 4 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "eslint-config-egg/typescript", 5 | "eslint-config-egg/lib/rules/enforce-node-prefix" 6 | ], 7 | "rules": { 8 | "array-bracket-spacing": 0, 9 | "@typescript-eslint/no-unused-vars": 0 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | npm-debug.log 3 | node_modules/ 4 | coverage/ 5 | .idea/ 6 | run/ 7 | logs/ 8 | .DS_Store 9 | .vscode 10 | *.swp 11 | *.lock 12 | *.js 13 | .eslintcache 14 | 15 | app/**/*.js 16 | test/**/*.js 17 | config/**/*.js 18 | app/**/*.map 19 | test/**/*.map 20 | config/**/*.map 21 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/README.md: -------------------------------------------------------------------------------- 1 | # tegg app 2 | 3 | [Hacker News](https://news.ycombinator.com/) showcase using [tegg](https://github.com/eggjs/tegg) 4 | 5 | ## QuickStart 6 | 7 | ### Development 8 | 9 | ```bash 10 | npm i 11 | npm run dev 12 | open http://localhost:7001/ 13 | ``` 14 | 15 | Don't tsc compile at development mode, if you had run `tsc` then you need to `npm run clean` before `npm run dev`. 16 | 17 | ### Deploy 18 | 19 | ```bash 20 | npm run tsc 21 | npm start 22 | ``` 23 | 24 | ### Npm Scripts 25 | 26 | - Use `npm run lint` to check code style 27 | - Use `npm test` to run unit test 28 | - se `npm run clean` to clean compiled js at development mode once 29 | 30 | ### Requirement 31 | 32 | - Node.js >= 16.x 33 | - Typescript >= 4.x 34 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/app/pontx/.gitignore: -------------------------------------------------------------------------------- 1 | .mocks 2 | .remote 3 | .local -------------------------------------------------------------------------------- /examples/eggjs-ts-app/app/pontx/sdk/api.d.ts: -------------------------------------------------------------------------------- 1 | export { API as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/app/pontx/sdk/defs.d.ts: -------------------------------------------------------------------------------- 1 | export { defs as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/app/pontx/sdk/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as API from "./api"; 2 | import * as defs from "./defs"; 3 | 4 | export { Services as PetstoreServices } from "./petstore/spec"; 5 | 6 | export { API, defs }; 7 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/app/router.ts: -------------------------------------------------------------------------------- 1 | import pontxSpec from './pontx/sdk/petstore/api-lock.json'; 2 | import { createPontxEggjsServer } from 'pontx-eggjs-sdk'; 3 | 4 | export const server = createPontxEggjsServer(pontxSpec as any, {}); 5 | 6 | import { Application } from 'egg'; 7 | 8 | export default (app: Application) => { 9 | const { router, controller } = app; 10 | 11 | // you can add middlewares to pontx auto controllers 12 | // const middlewares = [ app.middleware.authLogin(), app.middleware.permission(), app.middleware.handleResponse() ]; 13 | 14 | server.start(app, []); 15 | // router.get('/', controller.home.index); 16 | }; 17 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/config/config.default.ts: -------------------------------------------------------------------------------- 1 | import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; 2 | 3 | export default (appInfo: EggAppInfo) => { 4 | const config = {} as PowerPartial; 5 | 6 | // override config from framework / plugin 7 | // use for cookie sign key, should change to your own and keep security 8 | config.keys = appInfo.name + '_1710495924087_9957'; 9 | 10 | // add your egg config in here 11 | config.middleware = []; 12 | 13 | // add your special config in here 14 | const bizConfig = { 15 | sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, 16 | }; 17 | 18 | // the return config will combines to EggAppConfig 19 | return { 20 | ...config, 21 | ...bizConfig, 22 | }; 23 | }; 24 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/config/config.local.ts: -------------------------------------------------------------------------------- 1 | import { EggAppConfig, PowerPartial } from 'egg'; 2 | 3 | export default () => { 4 | const config: PowerPartial = {}; 5 | return config; 6 | }; 7 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/config/config.prod.ts: -------------------------------------------------------------------------------- 1 | import { EggAppConfig, PowerPartial } from 'egg'; 2 | 3 | export default () => { 4 | const config: PowerPartial = {}; 5 | return config; 6 | }; 7 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/config/plugin.ts: -------------------------------------------------------------------------------- 1 | import { EggPlugin } from 'egg'; 2 | 3 | const plugin: EggPlugin = { 4 | tegg: { 5 | enable: true, 6 | package: '@eggjs/tegg-plugin', 7 | }, 8 | teggConfig: { 9 | enable: true, 10 | package: '@eggjs/tegg-config', 11 | }, 12 | teggController: { 13 | enable: true, 14 | package: '@eggjs/tegg-controller-plugin', 15 | }, 16 | teggSchedule: { 17 | enable: true, 18 | package: '@eggjs/tegg-schedule-plugin', 19 | }, 20 | eventbusModule: { 21 | enable: true, 22 | package: '@eggjs/tegg-eventbus-plugin', 23 | }, 24 | aopModule: { 25 | enable: true, 26 | package: '@eggjs/tegg-aop-plugin', 27 | }, 28 | tracer: { 29 | enable: true, 30 | package: 'egg-tracer', 31 | }, 32 | }; 33 | 34 | export default plugin; 35 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/config/pontx-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "outDir": "../app/pontx", 3 | "plugins": { 4 | "generate": "../../../plugins/generate/pontx-eggjs-sdk-plugin" 5 | }, 6 | "origin": { 7 | "url": "https://petstore.swagger.io/v2/swagger.json", 8 | "name": "petstore" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/eggjs-ts-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eggjs/tsconfig", 3 | "compilerOptions": { 4 | "resolveJsonModule": true, 5 | "declaration": false, 6 | "strict": false, 7 | "noUnusedLocals": false, 8 | "noUnusedParameters": false, 9 | "paths": { 10 | "@/module/*": ["app/module/*"] 11 | }, 12 | "baseUrl": "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/node-app/config/pontx-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "outDir": "../src/services", 3 | "plugins": { 4 | "generate": { 5 | "options": { 6 | "sdkType": "nodejs" 7 | } 8 | } 9 | }, 10 | "origin": { 11 | "url": "https://petstore.swagger.io/v2/swagger.json", 12 | "name": "petstore" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/node-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-app", 3 | "private": true, 4 | "version": "0.0.0", 5 | "scripts": { 6 | "build": "tsc", 7 | "watch": "tsc -w", 8 | "do": "node ./lib/index.js", 9 | "sdk:test": "../../packages/pontx-cli/bin/init.js generate", 10 | "sdk": "pontx generate" 11 | }, 12 | "dependencies": { 13 | "node-fetch": "^2", 14 | "web-streams-nodejs": "^0.1.1", 15 | "pontx-sdk-core": "*" 16 | }, 17 | "devDependencies": { 18 | "@types/node-fetch": "*", 19 | "pontx-cli": "^0.4.4", 20 | "typescript": "^5.0.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/node-app/src/index.ts: -------------------------------------------------------------------------------- 1 | import fetch from "node-fetch"; 2 | import { APIs, setDefaults, setRootDefaults } from "./services/sdk"; 3 | 4 | setRootDefaults({ 5 | baseURL: "https://petstore.swagger.io/v2", 6 | }); 7 | 8 | // reqeust API by Node.js 9 | APIs.petstore.pet.findPetsByStatus 10 | .request({ 11 | status: ["available"], 12 | }) 13 | .then((pets) => { 14 | pets.map((pet) => { 15 | console.log(pet.name); 16 | }); 17 | }); 18 | APIs.petstore.pet.addPet 19 | .request({ 20 | name: "doggie", 21 | photoUrls: ["string"], 22 | tags: [ 23 | { 24 | id: 0, 25 | name: "string", 26 | }, 27 | ], 28 | status: "available", 29 | }) 30 | .then((pets) => {}); 31 | -------------------------------------------------------------------------------- /examples/node-app/src/services/.gitignore: -------------------------------------------------------------------------------- 1 | .mocks 2 | .remote 3 | .local -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/api.d.ts: -------------------------------------------------------------------------------- 1 | export { API as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/defaults.ts: -------------------------------------------------------------------------------- 1 | export const rootDefaults = {} as any; -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/defs.d.ts: -------------------------------------------------------------------------------- 1 | export { defs as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as API from "./api"; 2 | import * as defs from "./defs"; 3 | import type { PontxSDK } from "pontx-sdk-core"; 4 | 5 | export declare const pontxSDK: PontxSDK; 6 | 7 | import type { APIs as petstoreAPIs } from "./petstore/spec"; 8 | 9 | export declare const PetstoreAPIs: petstoreAPIs; 10 | 11 | export declare const APIs = { 12 | petstore: PetstoreAPIs, 13 | }; 14 | export { API, defs }; 15 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is the default generated SDK usage. 3 | * You can also implement and expose your custom pontx usage outside of pontx outDir. 4 | */ 5 | import { PontxSDK } from "pontx-sdk-core"; 6 | export const pontxSDK = new PontxSDK(); 7 | 8 | import petstoreMeta from "./petstore/meta.json"; 9 | export const PetstoreAPIs = pontxSDK.getClient(petstoreMeta); 10 | 11 | export const APIs = { 12 | petstore: PetstoreAPIs, 13 | }; 14 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/index.ts: -------------------------------------------------------------------------------- 1 | import type * as defs from "./defs"; 2 | import type * as API from "./api"; 3 | import { APIs as PetstoreAPIs } from "./petstore/"; 4 | import { rootDefaults } from "./defaults"; 5 | import { DefaultsType, RootDefaultsType, setSpecDefaults, SpecNames, DefaultsMapType } from "./request"; 6 | 7 | export const APIs = { 8 | petstore: PetstoreAPIs, 9 | } 10 | 11 | export const setRootDefaults = (defaults: RootDefaultsType) => { 12 | Object.keys(defaults).forEach((key) => { 13 | rootDefaults[key] = defaults[key]; 14 | }); 15 | }; 16 | 17 | export const setDefaultsAll = (defaults: RootDefaultsType) => { 18 | Object.keys(defaults).forEach((key) => { 19 | rootDefaults[key] = defaults[key]; 20 | }); 21 | 22 | Object.keys(APIs).forEach((specName: any) => { 23 | setSpecDefaults(specName); 24 | }); 25 | }; 26 | 27 | export const setDefaults = ( 28 | defaultsMap: DefaultsMapType 29 | ) => { 30 | Object.keys(APIs).forEach((specName: any) => { 31 | const defaults = defaultsMap?.[specName]; 32 | 33 | if (defaults && Object.keys(defaults)?.length > 0) { 34 | setSpecDefaults(specName, defaults); 35 | } 36 | }); 37 | }; 38 | 39 | export { defs, API, PetstoreAPIs }; 40 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/petstore/index.ts: -------------------------------------------------------------------------------- 1 | export * from './request'; 2 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/petstore/request.ts: -------------------------------------------------------------------------------- 1 | import { NodejsApiMethodsProvider } from "pontx-sdk-core/commonjs/providers/nodejs"; 2 | import { rootDefaults } from "../defaults"; 3 | import type { APIs as APIsType } from "./spec.d.ts"; 4 | import { createSDKClient, getSDKOptionsFormSpecJSON } from "pontx-sdk-core"; 5 | import specJSON from "./meta"; 6 | 7 | export const provider = new NodejsApiMethodsProvider(); 8 | 9 | export { NodejsApiMethodsProvider, specJSON }; 10 | 11 | export type DefaultsType = typeof provider.defaults & { pontxRequester?: typeof provider.pontxRequester }; 12 | 13 | export const setDefaults = (options = {} as DefaultsType) => { 14 | const finalOptions = { 15 | ...rootDefaults, 16 | ...options, 17 | }; 18 | const { pontxRequester, ...defaults } = finalOptions; 19 | 20 | provider.setDefaults(defaults); 21 | 22 | if (pontxRequester) { 23 | provider.pontxRequester = pontxRequester; 24 | } 25 | }; 26 | 27 | export const APIs = createSDKClient(specJSON as any, provider); 28 | 29 | export const createSDK = (options = {} as DefaultsType) => { 30 | const specOptions = getSDKOptionsFormSpecJSON(specJSON as any); 31 | const sdkProvider = new NodejsApiMethodsProvider({ ...specOptions, ...options}); 32 | return createSDKClient(specJSON as any, sdkProvider); 33 | } 34 | -------------------------------------------------------------------------------- /examples/node-app/src/services/sdk/request.ts: -------------------------------------------------------------------------------- 1 | import { setDefaults as setPetstoreDefaults, DefaultsType as PetstoreDefaultsType } from "./petstore/request"; 2 | 3 | export type SpecNames = 'petstore'; 4 | 5 | export type DefaultsMapType = { 6 | petstore: PetstoreDefaultsType; 7 | }; 8 | 9 | export type DefaultsType = DefaultsMapType[SpecName]; 10 | 11 | export type RootDefaultsType = PetstoreDefaultsType; 12 | 13 | export const setSpecDefaults = (specName: SpecName, defaults: DefaultsType = {} as any) => { 14 | switch (specName) { 15 | case "petstore": { 16 | setPetstoreDefaults(defaults as any); 17 | break; 18 | } 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /examples/node-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020"], 6 | "module": "Node16", 7 | "outDir": "lib", 8 | "allowJs": true, 9 | "skipLibCheck": true, 10 | /* Bundler mode */ 11 | "moduleResolution": "Node16", 12 | "resolveJsonModule": true, 13 | "strictFunctionTypes": false, 14 | "isolatedModules": true, 15 | "strictNullChecks": false, 16 | /* Linting */ 17 | "strict": false, 18 | "noUnusedLocals": false, 19 | "noUnusedParameters": false, 20 | "noFallthroughCasesInSwitch": false 21 | }, 22 | "include": ["src"] 23 | } 24 | -------------------------------------------------------------------------------- /examples/react-app-hooks/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"], 5 | ignorePatterns: ["dist", ".eslintrc.cjs"], 6 | parser: "@typescript-eslint/parser", 7 | plugins: ["react-refresh"], 8 | rules: { 9 | "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], 10 | "@typescript-eslint/no-explicit-any": "off", 11 | "no-extra-semi": "off", 12 | "@typescript-eslint/ban-types": "off", 13 | "@typescript-eslint/no-unused-vars": "off", 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /examples/react-app-hooks/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/react-app-hooks/README.md: -------------------------------------------------------------------------------- 1 | # React + TypeScript + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: 13 | 14 | - Configure the top-level `parserOptions` property like this: 15 | 16 | ```js 17 | parserOptions: { 18 | ecmaVersion: 'latest', 19 | sourceType: 'module', 20 | project: ['./tsconfig.json', './tsconfig.node.json'], 21 | tsconfigRootDir: __dirname, 22 | }, 23 | ``` 24 | 25 | - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` 26 | - Optionally add `plugin:@typescript-eslint/stylistic-type-checked` 27 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list 28 | -------------------------------------------------------------------------------- /examples/react-app-hooks/config/pontx-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "outDir": "../src/services", 3 | "plugins": { 4 | "generate": { 5 | "options": { 6 | "sdkType": "react-hooks" 7 | } 8 | } 9 | }, 10 | "origin": { 11 | "url": "https://petstore.swagger.io/v2/swagger.json", 12 | "name": "petstore" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/react-app-hooks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | Vite + React + TS 14 | 15 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/react-app-hooks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-app-hooks", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "sdk": "pontx generate", 10 | "sdk:test": "../../packages/pontx-cli/bin/init.js generate", 11 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 12 | "preview": "vite preview" 13 | }, 14 | "dependencies": { 15 | "swr": "^2.2.4", 16 | "react": "^18.2.0", 17 | "react-dom": "^18.2.0" 18 | }, 19 | "devDependencies": { 20 | "@types/react": "^18.2.15", 21 | "@types/react-dom": "^18.2.7", 22 | "@typescript-eslint/eslint-plugin": "^6.0.0", 23 | "@typescript-eslint/parser": "^6.0.0", 24 | "@vitejs/plugin-react": "^4.0.3", 25 | "eslint": "^8.45.0", 26 | "eslint-plugin-react-hooks": "^4.6.0", 27 | "eslint-plugin-react-refresh": "^0.4.3", 28 | "pontx-cli": "^0.4.4", 29 | "typescript": "^5.0.2", 30 | "vite": "^4.4.5" 31 | }, 32 | "repository": "git@github.com:pontjs/pontx.git" 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | } 6 | 7 | .pontx-async-sdk-sample .header { 8 | font-size: 16px; 9 | font-weight: bold; 10 | margin-bottom: 20px; 11 | } 12 | 13 | .pontx-hooks-sdk-sample select { 14 | height: 28px; 15 | line-height: 28px; 16 | width: 300px; 17 | margin-left: 8px; 18 | } 19 | 20 | .pontx-hooks-sdk-sample ul { 21 | border: 1px solid #ccc; 22 | padding: 10px 20px; 23 | border-radius: 2px; 24 | height: 50vh; 25 | overflow-y: auto; 26 | } 27 | 28 | .pontx-hooks-sdk-sample ul li .tag { 29 | margin-left: 20px; 30 | display: inline-block; 31 | background-color: #ccc; 32 | border-radius: 2px; 33 | padding: 0 10px; 34 | margin: 3px 0 3px 20px; 35 | } 36 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import App from "./App.tsx"; 4 | import "./index.css"; 5 | import { SWRConfig } from "swr"; 6 | import { PublicConfiguration } from "swr/_internal"; 7 | 8 | const swrGlobalConfig = { 9 | /** 错误重试,默认关闭 */ 10 | shouldRetryOnError: false, 11 | /** 获取焦点时,不重新请求 */ 12 | revalidateOnFocus: false, 13 | /** 接口缓存 1 分钟 */ 14 | dedupingInterval: 60 * 1000, 15 | } as Partial; 16 | 17 | ReactDOM.createRoot(document.getElementById("root")!).render( 18 | 19 | 20 | 21 | 22 | , 23 | ); 24 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/.gitignore: -------------------------------------------------------------------------------- 1 | .mocks 2 | .remote 3 | .local -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/api.d.ts: -------------------------------------------------------------------------------- 1 | export { API as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/defaults.ts: -------------------------------------------------------------------------------- 1 | export const rootDefaults = {} as any; -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/defs.d.ts: -------------------------------------------------------------------------------- 1 | export { defs as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as API from "./api"; 2 | import * as defs from "./defs"; 3 | 4 | import type { APIs as petstoreAPIs } from "./petstore/spec"; 5 | 6 | export declare const PetstoreAPIs: petstoreAPIs; 7 | 8 | export declare const APIs = { 9 | petstore: PetstoreAPIs, 10 | }; 11 | export { API, defs }; 12 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is the default generated SDK usage. 3 | * You can also implement and expose your custom pontx usage outside of pontx outDir. 4 | */ 5 | import { SdkMethodsFn, PontxSDK } from "pontx-hooks-sdk"; 6 | export const pontxSDK = new PontxSDK({ SdkMethodsFn }); 7 | 8 | import petstoreMeta from "./petstore/meta.json"; 9 | export const PetstoreAPIs = pontxSDK.getClient(petstoreMeta); 10 | 11 | export const APIs = { 12 | petstore: PetstoreAPIs, 13 | }; 14 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/index.ts: -------------------------------------------------------------------------------- 1 | import type * as defs from "./defs"; 2 | import type * as API from "./api"; 3 | import { APIs as PetstoreAPIs } from "./petstore/"; 4 | import { rootDefaults } from "./defaults"; 5 | import { DefaultsType, RootDefaultsType, setSpecDefaults, SpecNames, DefaultsMapType } from "./request"; 6 | 7 | export const APIs = { 8 | petstore: PetstoreAPIs, 9 | } 10 | 11 | export const setRootDefaults = (defaults: RootDefaultsType) => { 12 | Object.keys(defaults).forEach((key) => { 13 | rootDefaults[key] = defaults[key]; 14 | }); 15 | }; 16 | 17 | export const setDefaultsAll = (defaults: RootDefaultsType) => { 18 | Object.keys(defaults).forEach((key) => { 19 | rootDefaults[key] = defaults[key]; 20 | }); 21 | 22 | Object.keys(APIs).forEach((specName: any) => { 23 | setSpecDefaults(specName); 24 | }); 25 | }; 26 | 27 | export const setDefaults = ( 28 | defaultsMap: DefaultsMapType 29 | ) => { 30 | Object.keys(APIs).forEach((specName: any) => { 31 | const defaults = defaultsMap?.[specName]; 32 | 33 | if (defaults && Object.keys(defaults)?.length > 0) { 34 | setSpecDefaults(specName, defaults); 35 | } 36 | }); 37 | }; 38 | 39 | export { defs, API, PetstoreAPIs }; 40 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/petstore/index.ts: -------------------------------------------------------------------------------- 1 | export * from './request'; 2 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/petstore/request.ts: -------------------------------------------------------------------------------- 1 | import { ReactHooksApiMethodsProvider } from "pontx-sdk-core/lib/providers/react-hooks"; 2 | import { rootDefaults } from "../defaults"; 3 | import type { APIs as APIsType } from "./spec.d.ts"; 4 | import { createSDKClient, getSDKOptionsFormSpecJSON } from "pontx-sdk-core"; 5 | import specJSON from "./meta"; 6 | 7 | export const provider = new ReactHooksApiMethodsProvider(); 8 | 9 | export { ReactHooksApiMethodsProvider, specJSON }; 10 | 11 | export type DefaultsType = typeof provider.defaults & { pontxRequester?: typeof provider.pontxRequester }; 12 | 13 | export const setDefaults = (options = {} as DefaultsType) => { 14 | const finalOptions = { 15 | ...rootDefaults, 16 | ...options, 17 | }; 18 | const { pontxRequester, ...defaults } = finalOptions; 19 | 20 | provider.setDefaults(defaults); 21 | 22 | if (pontxRequester) { 23 | provider.pontxRequester = pontxRequester; 24 | } 25 | }; 26 | 27 | export const APIs = createSDKClient(specJSON as any, provider); 28 | 29 | export const createSDK = (options = {} as DefaultsType) => { 30 | const specOptions = getSDKOptionsFormSpecJSON(specJSON as any); 31 | const sdkProvider = new ReactHooksApiMethodsProvider({ ...specOptions, ...options}); 32 | return createSDKClient(specJSON as any, sdkProvider); 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/services/sdk/request.ts: -------------------------------------------------------------------------------- 1 | import { setDefaults as setPetstoreDefaults, DefaultsType as PetstoreDefaultsType } from "./petstore/request"; 2 | 3 | export type SpecNames = 'petstore'; 4 | 5 | export type DefaultsMapType = { 6 | petstore: PetstoreDefaultsType; 7 | }; 8 | 9 | export type DefaultsType = DefaultsMapType[SpecName]; 10 | 11 | export type RootDefaultsType = PetstoreDefaultsType; 12 | 13 | export const setSpecDefaults = (specName: SpecName, defaults: DefaultsType = {} as any) => { 14 | switch (specName) { 15 | case "petstore": { 16 | setPetstoreDefaults(defaults as any); 17 | break; 18 | } 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/types/global.d.ts: -------------------------------------------------------------------------------- 1 | import defs = PontxSDK.defs; 2 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/types/imports.d.ts: -------------------------------------------------------------------------------- 1 | import * as PontxSDK from "../services/sdk/api"; 2 | 3 | export import defs = PontxSDK.defs; 4 | 5 | export as namespace PontxSDK; 6 | -------------------------------------------------------------------------------- /examples/react-app-hooks/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/react-app-hooks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": false, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /examples/react-app-hooks/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /examples/react-app-hooks/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }); 8 | -------------------------------------------------------------------------------- /examples/react-app-oas3/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"], 5 | ignorePatterns: ["dist", ".eslintrc.cjs"], 6 | parser: "@typescript-eslint/parser", 7 | plugins: ["react-refresh"], 8 | rules: { 9 | "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], 10 | "@typescript-eslint/no-explicit-any": "off", 11 | "no-extra-semi": "off", 12 | "@typescript-eslint/ban-types": "off", 13 | "@typescript-eslint/no-unused-vars": "off", 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /examples/react-app-oas3/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/react-app-oas3/README.md: -------------------------------------------------------------------------------- 1 | # React + TypeScript + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: 13 | 14 | - Configure the top-level `parserOptions` property like this: 15 | 16 | ```js 17 | parserOptions: { 18 | ecmaVersion: 'latest', 19 | sourceType: 'module', 20 | project: ['./tsconfig.json', './tsconfig.node.json'], 21 | tsconfigRootDir: __dirname, 22 | }, 23 | ``` 24 | 25 | - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` 26 | - Optionally add `plugin:@typescript-eslint/stylistic-type-checked` 27 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list 28 | -------------------------------------------------------------------------------- /examples/react-app-oas3/config/pontx-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "outDir": "../src/services", 3 | "origin": { 4 | "url": "https://petstore3.swagger.io/api/v3/openapi.json", 5 | "name": "petstore" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/react-app-oas3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/react-app-oas3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-app-oas3", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "sdk:test": "../../packages/pontx-cli/bin/init.js generate", 10 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 11 | "preview": "vite preview" 12 | }, 13 | "dependencies": { 14 | "react": "^18.2.0", 15 | "pontx-sdk-core": "*", 16 | "react-dom": "^18.2.0" 17 | }, 18 | "devDependencies": { 19 | "@types/react": "^18.2.15", 20 | "@types/react-dom": "^18.2.7", 21 | "@typescript-eslint/eslint-plugin": "^6.0.0", 22 | "@typescript-eslint/parser": "^6.0.0", 23 | "@vitejs/plugin-react": "^4.0.3", 24 | "eslint": "^8.45.0", 25 | "eslint-plugin-react-hooks": "^4.6.0", 26 | "eslint-plugin-react-refresh": "^0.4.3", 27 | "pontx-cli": "^0.4.4", 28 | "typescript": "^5.0.2", 29 | "vite": "^4.4.5" 30 | }, 31 | "repository": "git@github.com:pontjs/pontx.git" 32 | } 33 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | } 6 | 7 | .pontx-async-sdk-sample .header { 8 | font-size: 16px; 9 | font-weight: bold; 10 | margin-bottom: 20px; 11 | } 12 | 13 | .pontx-async-sdk-sample select { 14 | height: 28px; 15 | line-height: 28px; 16 | width: 300px; 17 | margin-left: 8px; 18 | } 19 | 20 | .pontx-async-sdk-sample ul { 21 | border: 1px solid #ccc; 22 | padding: 10px 20px; 23 | border-radius: 2px; 24 | height: 50vh; 25 | overflow-y: auto; 26 | } 27 | 28 | .pontx-async-sdk-sample ul li .tag { 29 | margin-left: 20px; 30 | background-color: #ccc; 31 | border-radius: 2px; 32 | padding: 0 10px; 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App.tsx' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/.gitignore: -------------------------------------------------------------------------------- 1 | .mocks 2 | .remote 3 | .local -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/api.d.ts: -------------------------------------------------------------------------------- 1 | export { API as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/defaults.ts: -------------------------------------------------------------------------------- 1 | export const rootDefaults = {} as any; -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/defs.d.ts: -------------------------------------------------------------------------------- 1 | export { defs as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as API from "./api"; 2 | import * as defs from "./defs"; 3 | 4 | import type { APIs as petstoreAPIs } from "./petstore/spec"; 5 | 6 | export declare const PetstoreAPIs: petstoreAPIs; 7 | 8 | export declare const APIs = { 9 | petstore: PetstoreAPIs, 10 | }; 11 | export { API, defs }; 12 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is the default generated SDK usage. 3 | * You can also implement and expose your custom pontx usage outside of pontx outDir. 4 | */ 5 | import { PontxSDK } from "pontx-sdk-core"; 6 | export const pontxSDK = new PontxSDK(); 7 | 8 | import petstoreMeta from "./petstore/meta.json"; 9 | export const PetstoreAPIs = pontxSDK.getClient(petstoreMeta); 10 | 11 | export const APIs = { 12 | petstore: PetstoreAPIs, 13 | }; 14 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/index.ts: -------------------------------------------------------------------------------- 1 | import type * as defs from "./defs"; 2 | import type * as API from "./api"; 3 | import { APIs as PetstoreAPIs } from "./petstore/"; 4 | import { rootDefaults } from "./defaults"; 5 | import { DefaultsType, RootDefaultsType, setSpecDefaults, SpecNames, DefaultsMapType } from "./request"; 6 | 7 | export const APIs = { 8 | petstore: PetstoreAPIs, 9 | } 10 | 11 | export const setRootDefaults = (defaults: RootDefaultsType) => { 12 | Object.keys(defaults).forEach((key) => { 13 | rootDefaults[key] = defaults[key]; 14 | }); 15 | }; 16 | 17 | export const setDefaultsAll = (defaults: RootDefaultsType) => { 18 | Object.keys(defaults).forEach((key) => { 19 | rootDefaults[key] = defaults[key]; 20 | }); 21 | 22 | Object.keys(APIs).forEach((specName: any) => { 23 | setSpecDefaults(specName); 24 | }); 25 | }; 26 | 27 | export const setDefaults = ( 28 | defaultsMap: DefaultsMapType 29 | ) => { 30 | Object.keys(APIs).forEach((specName: any) => { 31 | const defaults = defaultsMap?.[specName]; 32 | 33 | if (defaults && Object.keys(defaults)?.length > 0) { 34 | setSpecDefaults(specName, defaults); 35 | } 36 | }); 37 | }; 38 | 39 | export { defs, API, PetstoreAPIs }; 40 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/petstore/index.ts: -------------------------------------------------------------------------------- 1 | export * from './request'; 2 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/petstore/request.ts: -------------------------------------------------------------------------------- 1 | import { HttpApiMethodsProvider } from "pontx-sdk-core"; 2 | import { rootDefaults } from "../defaults"; 3 | import type { APIs as APIsType } from "./spec.d.ts"; 4 | import { createSDKClient, getSDKOptionsFormSpecJSON } from "pontx-sdk-core"; 5 | import specJSON from "./meta"; 6 | 7 | export const provider = new HttpApiMethodsProvider(); 8 | 9 | export { HttpApiMethodsProvider, specJSON }; 10 | 11 | export type DefaultsType = typeof provider.defaults & { pontxRequester?: typeof provider.pontxRequester }; 12 | 13 | export const setDefaults = (options = {} as DefaultsType) => { 14 | const finalOptions = { 15 | ...rootDefaults, 16 | ...options, 17 | }; 18 | const { pontxRequester, ...defaults } = finalOptions; 19 | 20 | provider.setDefaults(defaults); 21 | 22 | if (pontxRequester) { 23 | provider.pontxRequester = pontxRequester; 24 | } 25 | }; 26 | 27 | export const APIs = createSDKClient(specJSON as any, provider); 28 | 29 | export const createSDK = (options = {} as DefaultsType) => { 30 | const specOptions = getSDKOptionsFormSpecJSON(specJSON as any); 31 | const sdkProvider = new HttpApiMethodsProvider({ ...specOptions, ...options}); 32 | return createSDKClient(specJSON as any, sdkProvider); 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/services/sdk/request.ts: -------------------------------------------------------------------------------- 1 | import { setDefaults as setPetstoreDefaults, DefaultsType as PetstoreDefaultsType } from "./petstore/request"; 2 | 3 | export type SpecNames = 'petstore'; 4 | 5 | export type DefaultsMapType = { 6 | petstore: PetstoreDefaultsType; 7 | }; 8 | 9 | export type DefaultsType = DefaultsMapType[SpecName]; 10 | 11 | export type RootDefaultsType = PetstoreDefaultsType; 12 | 13 | export const setSpecDefaults = (specName: SpecName, defaults: DefaultsType = {} as any) => { 14 | switch (specName) { 15 | case "petstore": { 16 | setPetstoreDefaults(defaults as any); 17 | break; 18 | } 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /examples/react-app-oas3/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/react-app-oas3/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": false, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /examples/react-app-oas3/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /examples/react-app-oas3/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /examples/react-app/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"], 5 | ignorePatterns: ["dist", ".eslintrc.cjs", "src/services"], 6 | parser: "@typescript-eslint/parser", 7 | plugins: ["react-refresh"], 8 | rules: { 9 | "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], 10 | "@typescript-eslint/no-explicit-any": "off", 11 | "no-extra-semi": "off", 12 | "@typescript-eslint/ban-types": "off", 13 | "@typescript-eslint/no-unused-vars": "off", 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /examples/react-app/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/react-app/README.md: -------------------------------------------------------------------------------- 1 | # React + TypeScript + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: 13 | 14 | - Configure the top-level `parserOptions` property like this: 15 | 16 | ```js 17 | parserOptions: { 18 | ecmaVersion: 'latest', 19 | sourceType: 'module', 20 | project: ['./tsconfig.json', './tsconfig.node.json'], 21 | tsconfigRootDir: __dirname, 22 | }, 23 | ``` 24 | 25 | - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` 26 | - Optionally add `plugin:@typescript-eslint/stylistic-type-checked` 27 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list 28 | -------------------------------------------------------------------------------- /examples/react-app/config/pontx-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "outDir": "../src/services", 3 | "plugins": {}, 4 | "origin": { 5 | "url": "https://petstore.swagger.io/v2/swagger.json", 6 | "name": "petstore" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/react-app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-app", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "sdk": "pontx generate", 10 | "sdk:test": "../../packages/pontx-cli/bin/init.js generate", 11 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 12 | "preview": "vite preview" 13 | }, 14 | "dependencies": { 15 | "react": "^18.2.0", 16 | "pontx-sdk-core": "*", 17 | "react-dom": "^18.2.0" 18 | }, 19 | "devDependencies": { 20 | "@types/react": "^18.2.15", 21 | "@types/react-dom": "^18.2.7", 22 | "@typescript-eslint/eslint-plugin": "^6.0.0", 23 | "@typescript-eslint/parser": "^6.0.0", 24 | "@vitejs/plugin-react": "^4.0.3", 25 | "eslint": "^8.45.0", 26 | "eslint-plugin-react-hooks": "^4.6.0", 27 | "eslint-plugin-react-refresh": "^0.4.3", 28 | "pontx-cli": "^0.4.4", 29 | "typescript": "^5.0.2", 30 | "vite": "^4.4.5" 31 | }, 32 | "repository": "git@github.com:pontjs/pontx.git" 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | } 6 | 7 | .pontx-async-sdk-sample .header { 8 | font-size: 16px; 9 | font-weight: bold; 10 | margin-bottom: 20px; 11 | } 12 | 13 | .pontx-async-sdk-sample select { 14 | height: 28px; 15 | line-height: 28px; 16 | width: 300px; 17 | margin-left: 8px; 18 | } 19 | 20 | .pontx-async-sdk-sample ul { 21 | border: 1px solid #ccc; 22 | padding: 10px 20px; 23 | border-radius: 2px; 24 | height: 50vh; 25 | overflow-y: auto; 26 | } 27 | 28 | .pontx-async-sdk-sample ul li .tag { 29 | margin-left: 20px; 30 | background-color: #ccc; 31 | border-radius: 2px; 32 | padding: 0 10px; 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App.tsx' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /examples/react-app/src/services/.gitignore: -------------------------------------------------------------------------------- 1 | .mocks 2 | .remote 3 | .local -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/api.d.ts: -------------------------------------------------------------------------------- 1 | export { API as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/defaults.ts: -------------------------------------------------------------------------------- 1 | export const rootDefaults = {} as any; -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/defs.d.ts: -------------------------------------------------------------------------------- 1 | export { defs as petstore } from './petstore/type'; 2 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as API from "./api"; 2 | import * as defs from "./defs"; 3 | 4 | import type { APIs as petstoreAPIs } from "./petstore/spec"; 5 | 6 | export declare const PetstoreAPIs: petstoreAPIs; 7 | 8 | export declare const APIs = { 9 | petstore: PetstoreAPIs, 10 | }; 11 | export { API, defs }; 12 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is the default generated SDK usage. 3 | * You can also implement and expose your custom pontx usage outside of pontx outDir. 4 | */ 5 | import { PontxSDK } from "pontx-sdk-core"; 6 | export const pontxSDK = new PontxSDK(); 7 | 8 | import petstoreMeta from "./petstore/meta.json"; 9 | export const PetstoreAPIs = pontxSDK.getClient(petstoreMeta); 10 | 11 | export const APIs = { 12 | petstore: PetstoreAPIs, 13 | }; 14 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/index.ts: -------------------------------------------------------------------------------- 1 | import type * as defs from "./defs"; 2 | import type * as API from "./api"; 3 | import { APIs as PetstoreAPIs } from "./petstore/"; 4 | import { rootDefaults } from "./defaults"; 5 | import { DefaultsType, RootDefaultsType, setSpecDefaults, SpecNames, DefaultsMapType } from "./request"; 6 | 7 | export const APIs = { 8 | petstore: PetstoreAPIs, 9 | } 10 | 11 | export const setRootDefaults = (defaults: RootDefaultsType) => { 12 | Object.keys(defaults).forEach((key) => { 13 | rootDefaults[key] = defaults[key]; 14 | }); 15 | }; 16 | 17 | export const setDefaultsAll = (defaults: RootDefaultsType) => { 18 | Object.keys(defaults).forEach((key) => { 19 | rootDefaults[key] = defaults[key]; 20 | }); 21 | 22 | Object.keys(APIs).forEach((specName: any) => { 23 | setSpecDefaults(specName); 24 | }); 25 | }; 26 | 27 | export const setDefaults = ( 28 | defaultsMap: DefaultsMapType 29 | ) => { 30 | Object.keys(APIs).forEach((specName: any) => { 31 | const defaults = defaultsMap?.[specName]; 32 | 33 | if (defaults && Object.keys(defaults)?.length > 0) { 34 | setSpecDefaults(specName, defaults); 35 | } 36 | }); 37 | }; 38 | 39 | export { defs, API, PetstoreAPIs }; 40 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/petstore/index.ts: -------------------------------------------------------------------------------- 1 | export * from './request'; 2 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/petstore/request.ts: -------------------------------------------------------------------------------- 1 | import { HttpApiMethodsProvider } from "pontx-sdk-core"; 2 | import { rootDefaults } from "../defaults"; 3 | import type { APIs as APIsType } from "./spec.d.ts"; 4 | import { createSDKClient, getSDKOptionsFormSpecJSON } from "pontx-sdk-core"; 5 | import specJSON from "./meta"; 6 | 7 | export const provider = new HttpApiMethodsProvider(); 8 | 9 | export { HttpApiMethodsProvider, specJSON }; 10 | 11 | export type DefaultsType = typeof provider.defaults & { pontxRequester?: typeof provider.pontxRequester }; 12 | 13 | export const setDefaults = (options = {} as DefaultsType) => { 14 | const finalOptions = { 15 | ...rootDefaults, 16 | ...options, 17 | }; 18 | const { pontxRequester, ...defaults } = finalOptions; 19 | 20 | provider.setDefaults(defaults); 21 | 22 | if (pontxRequester) { 23 | provider.pontxRequester = pontxRequester; 24 | } 25 | }; 26 | 27 | export const APIs = createSDKClient(specJSON as any, provider); 28 | 29 | export const createSDK = (options = {} as DefaultsType) => { 30 | const specOptions = getSDKOptionsFormSpecJSON(specJSON as any); 31 | const sdkProvider = new HttpApiMethodsProvider({ ...specOptions, ...options}); 32 | return createSDKClient(specJSON as any, sdkProvider); 33 | } 34 | -------------------------------------------------------------------------------- /examples/react-app/src/services/sdk/request.ts: -------------------------------------------------------------------------------- 1 | import { setDefaults as setPetstoreDefaults, DefaultsType as PetstoreDefaultsType } from "./petstore/request"; 2 | 3 | export type SpecNames = 'petstore'; 4 | 5 | export type DefaultsMapType = { 6 | petstore: PetstoreDefaultsType; 7 | }; 8 | 9 | export type DefaultsType = DefaultsMapType[SpecName]; 10 | 11 | export type RootDefaultsType = PetstoreDefaultsType; 12 | 13 | export const setSpecDefaults = (specName: SpecName, defaults: DefaultsType = {} as any) => { 14 | switch (specName) { 15 | case "petstore": { 16 | setPetstoreDefaults(defaults as any); 17 | break; 18 | } 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /examples/react-app/src/types/global.d.ts: -------------------------------------------------------------------------------- 1 | import defs = PontxSDK.defs; 2 | -------------------------------------------------------------------------------- /examples/react-app/src/types/imports.d.ts: -------------------------------------------------------------------------------- 1 | import * as PontxSDK from "../services/sdk/index"; 2 | 3 | export import defs = PontxSDK.defs; 4 | 5 | export as namespace PontxSDK; 6 | -------------------------------------------------------------------------------- /examples/react-app/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/react-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": false, 19 | "noUnusedLocals": false, 20 | "noUnusedParameters": false, 21 | "noFallthroughCasesInSwitch": false 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /examples/react-app/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /examples/react-app/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transform: { 3 | ".(ts|tsx)": "ts-jest", 4 | }, 5 | globals: {}, 6 | coverageDirectory: "coverage", 7 | coverageReporters: ["html", "lcov", "text"], 8 | collectCoverageFrom: ["packages/*/src/**/*.ts", "plugins/*/src/**/*.ts"], 9 | watchPathIgnorePatterns: ["/node_modules/"], 10 | testEnvironment: "node", 11 | moduleFileExtensions: ["ts", "tsx", "js", "json"], 12 | moduleNameMapper: {}, 13 | rootDir: __dirname, 14 | testMatch: ["/packages/**/tests/**/*spec.[jt]s?(x)", "/plugins/**/tests/**/*spec.[jt]s?(x)"], 15 | }; 16 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/**", "plugins/**", "sdk/**", "examples/**", "semix/**"], 3 | "version": "0.4.12", 4 | "useWorkspaces": true, 5 | "command": { 6 | "registry": "https://registry.npmmirror.com", 7 | "publish": { 8 | "ignoreChanges": ["package-lock.json", "*.md"], 9 | "message": "chore(release): publish %s" 10 | }, 11 | "bootstrap": { 12 | "npmClient": "yarn", 13 | "npmClientArgs": ["--registry https://registry.npmmirror.com"] 14 | } 15 | }, 16 | "publishConfig": { 17 | "directory": "lib" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/generate/asset_source_loader.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/generate/asset_source_loader.d.ts -------------------------------------------------------------------------------- /packages/generate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-generate", 3 | "version": "0.4.12", 4 | "description": "OpenAPI pont spec", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 11 | "build": "tsc --build" 12 | }, 13 | "dependencies": { 14 | "fs-extra": "*", 15 | "lodash": "*", 16 | "pontx-spec": "^0.4.12" 17 | }, 18 | "peerDependencies": { 19 | "pontx-manager": "*" 20 | }, 21 | "files": [ 22 | "package.json", 23 | "lib" 24 | ], 25 | "keywords": [], 26 | "author": "jasonHzq", 27 | "engines": { 28 | "typescript": ">=5.0.0" 29 | }, 30 | "license": "MIT", 31 | "devDependencies": { 32 | "@types/fs-extra": "*", 33 | "@types/lodash": "*" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/generate/plugin.js: -------------------------------------------------------------------------------- 1 | const { defaultPlugin } = require("./lib"); 2 | 3 | exports.default = defaultPlugin; 4 | -------------------------------------------------------------------------------- /packages/generate/src/index.ts: -------------------------------------------------------------------------------- 1 | import { createPontxGeneratePlugin, getFilesBySpecs, snippetsProvider } from "./plugin/index"; 2 | 3 | export * from "./plugin/index"; 4 | export * from "./utils"; 5 | export * from "./language/index"; 6 | 7 | export const defaultPlugin = createPontxGeneratePlugin({ 8 | snippetsProvider, 9 | getFilesBySpecs, 10 | getFilesBySginleSpec: async (spec, conf, options) => { 11 | const newSpec = { ...spec, name: "single" }; 12 | const files = await getFilesBySpecs( 13 | [ 14 | { 15 | spec: newSpec, 16 | conf: conf as any, 17 | name: "single", 18 | }, 19 | ], 20 | { ...options, multiple: false }, 21 | ); 22 | 23 | return files["single"] as any; 24 | }, 25 | }); 26 | -------------------------------------------------------------------------------- /packages/generate/src/language/index.ts: -------------------------------------------------------------------------------- 1 | import * as JavaScriptGenerator from "./JavaScript"; 2 | import * as TypeScriptGenerator from "./TypeScript"; 3 | 4 | export { JavaScriptGenerator, TypeScriptGenerator }; 5 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/index.tsx: -------------------------------------------------------------------------------- 1 | export * from "./plugin"; 2 | import { getFilesBySpecs } from "./getFilesBySpecs"; 3 | import { snippetsProvider } from "./snippetsProvider"; 4 | export * from "./template/rootFiles"; 5 | export * from "./template/metaJSON"; 6 | export * from "./template/specIndex"; 7 | export * from "./template/specTs"; 8 | export * from "./template/specIndexDTsWithController"; 9 | export * from "./template/specIndexDTsWithoutController"; 10 | 11 | export { getFilesBySpecs, snippetsProvider }; 12 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/snippetsProvider.ts: -------------------------------------------------------------------------------- 1 | import { SnippetsProvider } from "./plugin"; 2 | 3 | export const snippetsProvider: SnippetsProvider = (info) => { 4 | if (info.originName) { 5 | } 6 | const assignModule = info.controllerName ? `.${info.controllerName}` : ""; 7 | const snippets = [ 8 | { 9 | name: "request async", 10 | code: `try { 11 | const data = await API.${info.originName}${assignModule}.${info.api.name}.request({ }); 12 | } catch (e) { 13 | }`, 14 | }, 15 | ]; 16 | 17 | return snippets; 18 | }; 19 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/apiDTs.ts: -------------------------------------------------------------------------------- 1 | import * as PontSpec from "pontx-spec"; 2 | import * as _ from "lodash"; 3 | import { TypeScriptGenerator } from "../../language"; 4 | 5 | /** 生成单个接口的类型和 SDK 代码,可扩展其它方法 */ 6 | export const apiDTsCode = (api: PontSpec.PontAPI, controllerName: string, specName: string) => { 7 | const paramTypes = TypeScriptGenerator.generateParametersTsCode(api, specName, false); 8 | const bodyParam = api.parameters?.find((param) => param.in === "body"); 9 | let bodyParamType = "undefined"; 10 | if (bodyParam) { 11 | const bodyParamSchema = bodyParam?.schema; 12 | bodyParamType = TypeScriptGenerator.generateSchemaCode(bodyParamSchema, specName); 13 | } 14 | let method = api?.method; 15 | 16 | const code = [ 17 | `export ${paramTypes};`, 18 | method ? `export type method = '${method.toUpperCase()}';` : "", 19 | `export type bodyParams = ${bodyParamType};`, 20 | `export type APIResponse = ${TypeScriptGenerator.generateSchemaCode(api.responses["200"]?.schema)};`, 21 | ] 22 | .filter((id) => id) 23 | .join("\n"); 24 | 25 | return code; 26 | }; 27 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/fetch.ts: -------------------------------------------------------------------------------- 1 | const fetchtTs = `import { PontxAPISDK, PontxFetcher, defaultFetcherInstance } from "pontx-sdk-core"; 2 | 3 | export const defaults = { 4 | ...defaultFetcherInstance.config, 5 | }; 6 | 7 | const apiSDK = new PontxAPISDK(); 8 | 9 | apiSDK.getFetchConfig = () => { 10 | return { 11 | ...defaultFetcherInstance.config, 12 | ...defaults, 13 | }; 14 | }; 15 | 16 | export const useFetch = (fetcher: PontxFetcher) => { 17 | apiSDK.setFetchInstance(fetcher); 18 | }; 19 | 20 | export { apiSDK }; 21 | `; 22 | 23 | export const getFetchTs = () => { 24 | return fetchtTs; 25 | }; 26 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/specIndex.ts: -------------------------------------------------------------------------------- 1 | export const specIndexTs = () => { 2 | return `export * from './request'; 3 | `; 4 | }; 5 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/specIndexDTsWithoutController.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import * as PontSpec from "pontx-spec"; 3 | import { apiDTsCode } from "./apiDTs"; 4 | import { TypeScriptGenerator } from "../../language"; 5 | import { indentation } from "../../utils"; 6 | import { generateClassComment } from "../../language/TypeScript"; 7 | 8 | export const specIndexDTsWithoutController = (spec: PontSpec.PontSpec) => { 9 | return ` 10 | type ObjectMap = { 11 | [key in Key]: Value; 12 | }; 13 | 14 | export namespace defs { 15 | ${_.map(spec.definitions, (schema, name) => { 16 | const comment = generateClassComment(schema, name); 17 | return indentation(2)(comment + "export " + TypeScriptGenerator.generateBaseClassTsCode(schema, name, true)); 18 | }).join("\n\n")} 19 | } 20 | 21 | export namespace API { 22 | ${_.map(spec.apis, (api, name) => { 23 | const apiContentTsCode = indentation(2)(apiDTsCode(api, name, "")); 24 | const apiCommentCode = TypeScriptGenerator.apiComment(api); 25 | const apiNamespaceCode = indentation(2)(`${apiCommentCode}export namespace ${name} { 26 | ${apiContentTsCode} 27 | }`); 28 | return apiNamespaceCode; 29 | }).join("\n\n")} 30 | } 31 | `; 32 | }; 33 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/specInterfaceDts.ts: -------------------------------------------------------------------------------- 1 | import * as PontSpec from "pontx-spec"; 2 | import * as _ from "lodash"; 3 | import { TypeScriptGenerator } from "../../language"; 4 | import { indentation } from "../../utils"; 5 | 6 | export type request = (params: number, T) => Promise; 7 | 8 | export const apiInterface = (api: PontSpec.PontAPI, controllerName: string, specName: string) => { 9 | const prefix = controllerName ? `API.${controllerName}.${api.name}` : `API.${api.name}`; 10 | const Params = `${prefix}.Params`; 11 | const BodyParams = `${prefix}.bodyParams`; 12 | const Response = `${prefix}.APIResponse`; 13 | const Method = `${prefix}.method`; 14 | const apiCommentCode = TypeScriptGenerator.apiComment(api); 15 | 16 | return apiCommentCode + `${api.name}: RequestMethods<${Params}, ${BodyParams}, ${Response}, ${Method}>;`; 17 | }; 18 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/specsDts.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import * as PontSpec from "pontx-spec"; 3 | 4 | export const specsDts = (specs: PontSpec.PontSpec[]) => { 5 | const imports = specs.map((spec) => `import { ${spec.name} } from "./${spec.name}/type";`).join("\n"); 6 | 7 | return ""; 8 | }; 9 | -------------------------------------------------------------------------------- /packages/generate/src/plugin/template/utils.tsx: -------------------------------------------------------------------------------- 1 | export const getPrefix = (controllerName: string, specName: string) => { 2 | if (controllerName) { 3 | return `API.${controllerName}`; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/generate/src/utils.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs-extra"; 2 | 3 | export function clearPath(basePath: string) { 4 | const isExists = fs.existsSync(basePath); 5 | 6 | if (isExists) { 7 | return fs.removeSync(basePath); 8 | } 9 | } 10 | 11 | const makeArray = (cnt: number) => Array.from(new Array(cnt)); 12 | const indentationLine = (cnt: number) => (line: string) => 13 | line?.length 14 | ? makeArray(cnt) 15 | .map(() => " ") 16 | .join("") + line 17 | : ""; 18 | export const indentation = (cnt = 2) => { 19 | return (code: string) => { 20 | const lines = code?.split("\n") || ([] as string[]); 21 | return lines.map(indentationLine(cnt)).join("\n"); 22 | }; 23 | }; 24 | 25 | export const needQuotationMark = (name: string) => { 26 | return !name.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/); 27 | }; 28 | -------------------------------------------------------------------------------- /packages/generate/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "noImplicitAny": false, 6 | "target": "es6", 7 | "removeComments": true, 8 | "preserveConstEnums": true, 9 | "outDir": "lib", 10 | "noEmit": false, 11 | "moduleResolution": "node", 12 | "declaration": true, 13 | "baseUrl": ".", 14 | "paths": {}, 15 | "composite": true, 16 | "rootDir": "./src" 17 | }, 18 | "include": ["./src/**/*"], 19 | "exclude": ["node_modules"], 20 | "references": [ 21 | { 22 | "path": "../pontx-spec" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages/jsonschema-form/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/jsonschema-form/README.md: -------------------------------------------------------------------------------- 1 | # JSONSchema 通用渲染器(default render by xconsole) 2 | -------------------------------------------------------------------------------- /packages/jsonschema-form/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite App 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/jsonschema-form/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsonschema-form", 3 | "private": true, 4 | "version": "0.3.70", 5 | "scripts": { 6 | "dev": "vite", 7 | "build": "tsc && vite build", 8 | "preview": "vite preview" 9 | }, 10 | "dependencies": { 11 | "react": "^18.0.0", 12 | "react-dom": "^18.0.0" 13 | }, 14 | "devDependencies": { 15 | "@types/react": "^18.0.0", 16 | "@types/react-dom": "^18.0.0", 17 | "@vitejs/plugin-react": "^1.3.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/jsonschema-form/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | 40 | button { 41 | font-size: calc(10px + 2vmin); 42 | } 43 | -------------------------------------------------------------------------------- /packages/jsonschema-form/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | import logo from './logo.svg' 3 | import './App.css' 4 | 5 | function App() { 6 | const [count, setCount] = useState(0) 7 | 8 | return ( 9 |
10 |
11 | logo 12 |

Hello Vite + React!

13 |

14 | 17 |

18 |

19 | Edit App.tsx and save to test HMR updates. 20 |

21 |

22 | 28 | Learn React 29 | 30 | {' | '} 31 | 37 | Vite Docs 38 | 39 |

40 |
41 |
42 | ) 43 | } 44 | 45 | export default App 46 | -------------------------------------------------------------------------------- /packages/jsonschema-form/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /packages/jsonschema-form/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | 10 | ) 11 | -------------------------------------------------------------------------------- /packages/jsonschema-form/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/jsonschema-form/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": false, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "removeComments": true, 18 | "skipDefaultLibCheck": true, 19 | "composite": true, 20 | "outDir": "lib", 21 | "baseUrl": ".", 22 | "paths": {}, 23 | "rootDir": "./src", 24 | "jsx": "react-jsx" 25 | }, 26 | "include": ["src"], 27 | "references": [{ "path": "./tsconfig.node.json" }] 28 | } 29 | -------------------------------------------------------------------------------- /packages/jsonschema-form/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "esnext", 5 | "jsx": "react", 6 | "moduleResolution": "node" 7 | }, 8 | "include": ["src/vite.config.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/jsonschema-form/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()] 7 | }) 8 | -------------------------------------------------------------------------------- /packages/oas-spec-ts/Contribution.md: -------------------------------------------------------------------------------- 1 | # Contribution 2 | 3 | ## Steps 4 | 5 | * 1. Copy parseDom.js code to Chrome Console in OAS Page, eg: https://swagger.io/specification/v2/ 6 | 7 | * 2. Copy logging result in Chrome Console to definition.json. 8 | 9 | * 3. run `npm run generate`. 10 | -------------------------------------------------------------------------------- /packages/oas-spec-ts/README.md: -------------------------------------------------------------------------------- 1 | # oas-spec-ts 2 | -------------------------------------------------------------------------------- /packages/oas-spec-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oas-spec-ts", 3 | "version": "0.4.12", 4 | "description": "OpenAPI Spec OAS TS Typescript", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "release": "npm publish --registry https://registry.npmjs.org/", 10 | "dev": "tsc -p ./scripts/tsconfig.json -w", 11 | "generate": "node ./scripts/lib/generateCode.js ./src/oas2.0/definition.json ./src/oas2.0/swagger2.0.ts", 12 | "watch": "tsc --build --watch", 13 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 14 | "build": "npm run clean && tsc --build" 15 | }, 16 | "files": [ 17 | "lib", 18 | "package.json", 19 | "*.md" 20 | ], 21 | "keywords": [], 22 | "author": "jasonHzq", 23 | "license": "MIT" 24 | } 25 | -------------------------------------------------------------------------------- /packages/oas-spec-ts/scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "noImplicitAny": false, 5 | "declaration": true, 6 | "skipDefaultLibCheck": true, 7 | "skipLibCheck": true, 8 | "target": "es6", 9 | "removeComments": true, 10 | "preserveConstEnums": true, 11 | "sourceMap": true, 12 | "outDir": "lib", 13 | "moduleResolution": "node", 14 | "experimentalDecorators": true, 15 | "emitDecoratorMetadata": true, 16 | "baseUrl": ".", 17 | "allowSyntheticDefaultImports": true, 18 | "lib": ["dom", "es6", "es2017", "dom.iterable", "scripthost"] 19 | }, 20 | "include": ["../scripts/*"], 21 | "exclude": ["node_modules", "build"] 22 | } 23 | -------------------------------------------------------------------------------- /packages/oas-spec-ts/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as OAS2 from "./oas2.0/swagger2.0"; 2 | import * as OAS3 from "./oas3.0/swagger3.0"; 3 | 4 | export { 5 | JsonSchema, 6 | CoreSchemaMetaSchema, 7 | JsonSchemaArray, 8 | JsonSchemaMap, 9 | SimpleTypes, 10 | NonNegativeInteger, 11 | NonNegativeIntegerDefault0, 12 | StringArray, 13 | } from "./JsonSchema"; 14 | 15 | export { OAS2, OAS3 }; 16 | -------------------------------------------------------------------------------- /packages/oas-spec-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "composite": true, 5 | "module": "es6", 6 | "target": "es5", 7 | "moduleResolution": "node", 8 | "baseUrl": ".", 9 | "paths": {}, 10 | "rootDir": "./src", 11 | "outDir": "./lib" 12 | }, 13 | "include": ["src/**/*"], 14 | "exclude": ["node_modules", "lib"] 15 | } 16 | -------------------------------------------------------------------------------- /packages/pontx-cli/README.md: -------------------------------------------------------------------------------- 1 | # Pontx ClI 2 | 3 | ## Installation 4 | 5 | ``` 6 | npm i -g pontx-cli 7 | ``` 8 | 9 | ## Usage 10 | 11 | ### pontx ls 12 | 13 | 查看当前数据源 14 | 15 | ### pontx generate 16 | 17 | 生成 SDK 18 | 19 | ### pontx mocks 20 | 21 | 生成 mocks 22 | -------------------------------------------------------------------------------- /packages/pontx-cli/bin/init.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | require("../lib/index"); 6 | -------------------------------------------------------------------------------- /packages/pontx-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-cli", 3 | "version": "0.4.12", 4 | "description": "Pontx CLI", 5 | "bin": { 6 | "pontx": "bin/init.js" 7 | }, 8 | "main": "lib/index.js", 9 | "typings": "lib/index.d.ts", 10 | "scripts": { 11 | "watch": "tsc --build --watch", 12 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 13 | "build": "npm run clean && tsc --build" 14 | }, 15 | "peerDependencies": { 16 | "fs-extra": "^10.1.0", 17 | "lodash": "*" 18 | }, 19 | "dependencies": { 20 | "chalk": "^4.1.2", 21 | "commander": "^9.2.0", 22 | "pontx-manager": "^0.4.12", 23 | "pontx-meta-fetch-plugin": "^0.4.12", 24 | "pontx-oas2-parser-plugin": "^0.4.12", 25 | "pontx-oas3-parser-plugin": "^0.4.12", 26 | "signale": "1.4.0" 27 | }, 28 | "files": [ 29 | "bin", 30 | "lib", 31 | "package.json", 32 | "*.md" 33 | ], 34 | "keywords": [], 35 | "author": "jasonHzq", 36 | "license": "MIT", 37 | "devDependencies": { 38 | "@types/fs-extra": "*", 39 | "@types/lodash": "*" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/pontx-cli/src/debugLog.ts: -------------------------------------------------------------------------------- 1 | const chalk = require("chalk"); 2 | const { Signale } = require("signale"); 3 | 4 | const logger = new Signale(); 5 | logger.config({ 6 | displayTimestamp: true, 7 | }); 8 | 9 | export { logger }; 10 | 11 | export function cliLog(message: string, logType: string) { 12 | switch (logType) { 13 | case "info": { 14 | logger.info(message); 15 | break; 16 | } 17 | case "error": { 18 | logger.error(message); 19 | // process.exit(1); 20 | break; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/pontx-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "esModuleInterop": false, 11 | "baseUrl": ".", 12 | "paths": {}, 13 | "rootDir": "./src", 14 | "composite": true 15 | }, 16 | "include": ["./src/**/*"], 17 | "exclude": ["node_modules", "build"], 18 | "references": [ 19 | { 20 | "path": "../pontx-manager" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /packages/pontx-manager/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-manager", 3 | "version": "0.4.12", 4 | "description": "pont manager", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "watch": "tsc --build --watch", 9 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 10 | "build": "npm run clean && tsc --build" 11 | }, 12 | "dependencies": { 13 | "fast-json-stable-stringify": "^2.1.0", 14 | "fs-extra": "^10.1.0", 15 | "lodash": "*", 16 | "minipass-fetch": "^3.0.4", 17 | "node-fetch": "^2", 18 | "pontx-async-sdk-plugin": "^0.4.12", 19 | "pontx-generate-core": "^0.4.12", 20 | "pontx-meta-fetch-plugin": "^0.4.12", 21 | "pontx-mocks-plugin": "^0.4.12", 22 | "pontx-oas2-parser-plugin": "^0.4.12", 23 | "pontx-oas3-parser-plugin": "^0.4.12", 24 | "pontx-simple-react-hooks-sdk-plugin": "^0.3.112", 25 | "pontx-spec": "^0.4.12", 26 | "typescript": "^5" 27 | }, 28 | "files": [ 29 | "lib", 30 | "package.json", 31 | "*.md" 32 | ], 33 | "keywords": [], 34 | "author": "jasonHzq", 35 | "license": "MIT", 36 | "devDependencies": { 37 | "@types/fs-extra": "*", 38 | "@types/lodash": "*" 39 | }, 40 | "repository": "git@github.com:pontjs/pontx.git" 41 | } 42 | -------------------------------------------------------------------------------- /packages/pontx-manager/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as PontSpec from "pontx-spec"; 2 | export { 3 | InnerOriginConfig, 4 | PluginConfig, 5 | PontxFetchPlugin, 6 | PontxGeneratorPlugin, 7 | PontInnerManagerConfig, 8 | PontxConfigPlugin, 9 | PontxMocksPlugin, 10 | PontxParserPlugin, 11 | PontxTransformPlugin, 12 | Snippet, 13 | PontxPlugin, 14 | PontxPlugins, 15 | PontPublicManagerConfig, 16 | PontxReportPlugin, 17 | } from "./config"; 18 | export { PontManager, getSpecByName } from "./manager"; 19 | export * from "./logger"; 20 | export { requireTsFile, findRealPath, requireUncached, createTsProgram } from "./utils"; 21 | export { PontSpec }; 22 | export { lookForFiles } from "./scan"; 23 | -------------------------------------------------------------------------------- /packages/pontx-manager/src/logger.ts: -------------------------------------------------------------------------------- 1 | export class PontLoggerSpec { 2 | originName?: string; 3 | processType: "read" | "fetch" | "parser" | "diff" | "generate"; 4 | message: string; 5 | stack?: any; 6 | } 7 | 8 | const processTypeNameMap = { 9 | read: "本地文件读取", 10 | fetch: "远程数据获取", 11 | parser: "元数据解析", 12 | diff: "数据对比", 13 | generate: "代码生成", 14 | }; 15 | 16 | export class PontLogger { 17 | log(message: string, logType = "info" as "info" | "error", stack?: any) { 18 | console.log(message, stack); 19 | } 20 | 21 | info(message: string) { 22 | this.log(message, "info"); 23 | } 24 | 25 | error(errorSpec: PontLoggerSpec | string, stack?: any) { 26 | if (typeof errorSpec === "string") { 27 | this.log(errorSpec, "error", stack); 28 | } else if (errorSpec) { 29 | const originName = errorSpec.originName ? `[originName: ${errorSpec.originName}] ` : ""; 30 | const processType = errorSpec.processType ? `[${processTypeNameMap[errorSpec.processType]}]` : ""; 31 | 32 | this.log(`${originName}${processType}${errorSpec.message}`, "error", errorSpec.stack); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/pontx-manager/src/scan.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs-extra"; 2 | import * as path from "path"; 3 | 4 | export async function lookForFiles(dir: string, fileName: string): Promise { 5 | const files = await fs.readdir(dir); 6 | 7 | for (let file of files) { 8 | const currName = path.join(dir, file); 9 | 10 | const info = await fs.lstat(currName); 11 | if (info.isDirectory()) { 12 | if (file === ".git" || file === "node_modules") { 13 | continue; 14 | } 15 | 16 | const foundFile = await lookForFiles(currName, fileName); 17 | if (foundFile) { 18 | return foundFile; 19 | } 20 | } else if (info.isFile() && file === fileName) { 21 | return currName; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/pontx-manager/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "ES2015", 6 | "removeComments": true, 7 | "composite": true, 8 | "outDir": "lib", 9 | "moduleResolution": "Node", 10 | "baseUrl": ".", 11 | "paths": {}, 12 | "esModuleInterop": true, 13 | "rootDir": "./src" 14 | }, 15 | "include": ["./src/**/*"], 16 | "exclude": ["node_modules", "build"], 17 | "references": [{ "path": "../pontx-spec" }] 18 | } 19 | -------------------------------------------------------------------------------- /packages/pontx-spec-diff/README.md: -------------------------------------------------------------------------------- 1 | # pontx-spec-diff 2 | 3 | spec for [pont](https://github.com/pontjs/pontx) 4 | -------------------------------------------------------------------------------- /packages/pontx-spec-diff/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-spec-diff", 3 | "version": "0.4.12", 4 | "description": "pont spec", 5 | "module": "es6/index.js", 6 | "main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "watch": "tsc --build --watch", 10 | "clean": "rimraf lib", 11 | "build:extra": "tsc -p ./tsconfig.commonjs.json", 12 | "build:commonjs:watch": "npm run clean && tsc -p ./tsconfig.commonjs.json -w", 13 | "build": "tsc --build", 14 | "test": "tsc -p tests/tsconfig.json" 15 | }, 16 | "peerDependencies": { 17 | "lodash": "*" 18 | }, 19 | "dependencies": { 20 | "pontx-spec": "^0.4.12" 21 | }, 22 | "files": [ 23 | "lib/", 24 | "es6", 25 | "package.json", 26 | "*.md" 27 | ], 28 | "keywords": [], 29 | "author": "jasonHzq", 30 | "license": "MIT", 31 | "devDependencies": { 32 | "@types/lodash": "*", 33 | "lodash": "*" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/pontx-spec-diff/src/index.ts: -------------------------------------------------------------------------------- 1 | import { diffPontSpec, DiffResult, diffPontSpecs } from "./diff"; 2 | import { diffApi, diffBaseClass } from "./pureDiff"; 3 | import { BaseClazzDiffOp } from "./diffDoc"; 4 | 5 | export { diffPontSpec, DiffResult, diffPontSpecs, diffApi, diffBaseClass, BaseClazzDiffOp }; 6 | -------------------------------------------------------------------------------- /packages/pontx-spec-diff/tsconfig.commonjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "baseUrl": "./src", 11 | "paths": {}, 12 | "rootDir": "./src" 13 | }, 14 | "include": ["./src/**/*"], 15 | "exclude": ["node_modules", "es6", "tests", "lib"], 16 | "references": [] 17 | } 18 | -------------------------------------------------------------------------------- /packages/pontx-spec-diff/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ESNEXT", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "es6", 9 | "moduleResolution": "node", 10 | "noEmit": false, 11 | "baseUrl": "./src", 12 | "paths": {}, 13 | "rootDir": "./src", 14 | "composite": true 15 | }, 16 | "include": ["./src"], 17 | "exclude": ["node_modules", "build", "lib", "tests"], 18 | "references": [{ "path": "../pontx-spec" }] 19 | } 20 | -------------------------------------------------------------------------------- /packages/pontx-spec/README.md: -------------------------------------------------------------------------------- 1 | # pontx-spec 2 | 3 | spec for [pontx](https://github.com/pontjs/pontx) 4 | -------------------------------------------------------------------------------- /packages/pontx-spec/apiSchema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$ref": "pontSchema.json#/definitions/api" 4 | } 5 | -------------------------------------------------------------------------------- /packages/pontx-spec/docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /packages/pontx-spec/docs/README.md: -------------------------------------------------------------------------------- 1 | pontx-spec / [Exports](modules.md) 2 | 3 | # pontx-spec 4 | 5 | spec for [pontx](https://github.com/pontjs/pontx) 6 | -------------------------------------------------------------------------------- /packages/pontx-spec/docs/classes/Mod.md: -------------------------------------------------------------------------------- 1 | [pontx-spec](../README.md) / [Exports](../modules.md) / Mod 2 | 3 | # Class: Mod 4 | 5 | ## Table of contents 6 | 7 | ### Constructors 8 | 9 | - [constructor](Mod.md#constructor) 10 | 11 | ### Properties 12 | 13 | - [description](Mod.md#description) 14 | - [interfaces](Mod.md#interfaces) 15 | - [name](Mod.md#name) 16 | 17 | ## Constructors 18 | 19 | ### constructor 20 | 21 | • **new Mod**() 22 | 23 | ## Properties 24 | 25 | ### description 26 | 27 | • `Optional` **description**: `string` 28 | 29 | #### Defined in 30 | 31 | [pontx-spec/src/type.ts:230](https://github.com/pontjs/pontx/tree/main/packages/pontx-spec/src/type.ts#L230) 32 | 33 | ___ 34 | 35 | ### interfaces 36 | 37 | • **interfaces**: [`PontAPI`](PontAPI.md) & \{ `name`: `string` }[] = `[]` 38 | 39 | #### Defined in 40 | 41 | [pontx-spec/src/type.ts:229](https://github.com/pontjs/pontx/tree/main/packages/pontx-spec/src/type.ts#L229) 42 | 43 | ___ 44 | 45 | ### name 46 | 47 | • **name**: `string` \| `Symbol` 48 | 49 | #### Defined in 50 | 51 | [pontx-spec/src/type.ts:228](https://github.com/pontjs/pontx/tree/main/packages/pontx-spec/src/type.ts#L228) 52 | -------------------------------------------------------------------------------- /packages/pontx-spec/docs/classes/PontNamespace.md: -------------------------------------------------------------------------------- 1 | [pontx-spec](../README.md) / [Exports](../modules.md) / PontNamespace 2 | 3 | # Class: PontNamespace 4 | 5 | ## Table of contents 6 | 7 | ### Constructors 8 | 9 | - [constructor](PontNamespace.md#constructor) 10 | 11 | ### Properties 12 | 13 | - [title](PontNamespace.md#title) 14 | - [titleIntl](PontNamespace.md#titleintl) 15 | 16 | ## Constructors 17 | 18 | ### constructor 19 | 20 | • **new PontNamespace**() 21 | 22 | ## Properties 23 | 24 | ### title 25 | 26 | • **title**: `string` 27 | 28 | 标题 29 | 30 | #### Defined in 31 | 32 | [pontx-spec/src/type.ts:221](https://github.com/pontjs/pontx/tree/main/packages/pontx-spec/src/type.ts#L221) 33 | 34 | ___ 35 | 36 | ### titleIntl 37 | 38 | • `Optional` **titleIntl**: [`ObjectMap`](../modules.md#objectmap)\<`string`\> = `{}` 39 | 40 | #### Defined in 41 | 42 | [pontx-spec/src/type.ts:222](https://github.com/pontjs/pontx/tree/main/packages/pontx-spec/src/type.ts#L222) 43 | -------------------------------------------------------------------------------- /packages/pontx-spec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-spec", 3 | "version": "0.4.12", 4 | "description": "pont spec", 5 | "module": "es6/index.js", 6 | "main": "lib/index.js", 7 | "typings": "es6/index.d.ts", 8 | "scripts": { 9 | "watch": "tsc --build --watch", 10 | "tsc": "tsc -p ./tsconfig.json", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build:extra": "tsc -p ./tsconfig.lib.json", 13 | "build:commonjs:watch": "tsc -p ./tsconfig.lib.json -w", 14 | "build:doc": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts", 15 | "build": "npm run clean && tsc --build && tsc -m CommonJS --outDir lib" 16 | }, 17 | "peerDependencies": { 18 | "lodash": "*" 19 | }, 20 | "dependencies": { 21 | "oas-spec-ts": "^0.4.12" 22 | }, 23 | "files": [ 24 | "schemas", 25 | "lib/", 26 | "es6/", 27 | "*.json", 28 | "*.json", 29 | "docs", 30 | "package.json", 31 | "*.md" 32 | ], 33 | "keywords": [], 34 | "author": "jasonHzq", 35 | "license": "MIT", 36 | "devDependencies": { 37 | "@types/lodash": "*", 38 | "typedoc": "^0.24.0", 39 | "typedoc-plugin-markdown": "^3.13.3" 40 | }, 41 | "repository": "git@github.com:pontjs/pontx.git" 42 | } 43 | -------------------------------------------------------------------------------- /packages/pontx-spec/schemas/api-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$ref": "pont-schema.json#/definitions/api" 4 | } 5 | -------------------------------------------------------------------------------- /packages/pontx-spec/schemas/struct-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$ref": "pont-schema.json#/definitions/schema" 4 | } 5 | -------------------------------------------------------------------------------- /packages/pontx-spec/src/index.ts: -------------------------------------------------------------------------------- 1 | import { PontJsonSchema } from "./dataType"; 2 | import { Parameter } from "./parameter"; 3 | import { orderMap, ObjectMap, removeMapKeys } from "./utils"; 4 | import { PontJsonPointer } from "./jsonpointer"; 5 | 6 | export { PontJsonSchema, Parameter, ObjectMap, PontJsonPointer, removeMapKeys }; 7 | export { 8 | Mod, 9 | PontAPI, 10 | PontxDirectoryNode, 11 | PontSpec, 12 | PontSpecs, 13 | ResponseObject, 14 | WithoutModsName, 15 | PontxDirectoryNodeType, 16 | PontNamespace, 17 | } from "./type"; 18 | export { parsePontSpec2OAS2, parsePontSpec2OAS3 } from "./parse"; 19 | export * from "./diff"; 20 | -------------------------------------------------------------------------------- /packages/pontx-spec/src/parameter.ts: -------------------------------------------------------------------------------- 1 | import { PontJsonSchema } from "./dataType"; 2 | 3 | export class Parameter { 4 | schema: PontJsonSchema; 5 | name: string; 6 | in: "query" | "body" | "path" | "formData" | "header"; 7 | required: boolean; 8 | } 9 | -------------------------------------------------------------------------------- /packages/pontx-spec/structSchema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$ref": "pontSchema.json#/definitions/schema" 4 | } 5 | -------------------------------------------------------------------------------- /packages/pontx-spec/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "es6", 9 | "moduleResolution": "node", 10 | "declaration": true, 11 | "baseUrl": ".", 12 | "skipLibCheck": true, 13 | "skipDefaultLibCheck": true, 14 | "paths": {}, 15 | "rootDir": "./src", 16 | "composite": true 17 | }, 18 | "include": ["./src/**/*"], 19 | "exclude": ["node_modules", "build", "es6"], 20 | "references": [{ "path": "../oas-spec-ts" }] 21 | } 22 | -------------------------------------------------------------------------------- /packages/pontx-spec/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "skipLibCheck": true, 10 | "skipDefaultLibCheck": true, 11 | "moduleResolution": "node", 12 | "baseUrl": ".", 13 | "paths": {}, 14 | "rootDir": "./src" 15 | }, 16 | "include": ["./src/**/*"], 17 | "exclude": ["node_modules", "es6", "lib"] 18 | } 19 | -------------------------------------------------------------------------------- /packages/pontx-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | .mocks/ 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/pontx-ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Pont UI 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/pontx-ui/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/App.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author jasonHzq 3 | * @description 4 | */ 5 | import * as React from "react"; 6 | import { Nav } from "./layout/Nav"; 7 | import { LayoutContext, PageType } from "./layout/context"; 8 | import { Page } from "./layout/Page"; 9 | 10 | export class AppProps {} 11 | 12 | export const App: React.FC = (props) => { 13 | return ( 14 | 15 |
16 |
19 |
20 | ); 21 | }; 22 | 23 | App.defaultProps = new AppProps(); 24 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/common/LeftMenu/APIDirectory.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author 3 | * @description 4 | */ 5 | import { PontSpec } from "pontx-spec"; 6 | import * as React from "react"; 7 | import { useLeftMenuState } from "./hooks"; 8 | import { APIDirectoryComponent } from "./APIDirectory.component"; 9 | 10 | export class APIDirectoryProps { 11 | pontxSpec: PontSpec; 12 | onSelect?: (nodeName: string, nodeType: string) => void = () => {}; 13 | } 14 | 15 | export const APIDirectory: React.FC = (props) => { 16 | const { 17 | allDirs, 18 | startTransition, 19 | selectNode, 20 | dirs, 21 | search, 22 | setSearch, 23 | changeDirs, 24 | currentKey, 25 | debouncedSearch, 26 | setCurrentKey, 27 | } = useLeftMenuState(props.pontxSpec); 28 | 29 | return ( 30 | { 40 | selectNode(name, type); 41 | props.onSelect?.(name, type); 42 | }} 43 | startTransition={startTransition} 44 | /> 45 | ); 46 | }; 47 | 48 | APIDirectory.defaultProps = new APIDirectoryProps(); 49 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/changes/DiffContent.less: -------------------------------------------------------------------------------- 1 | @delete-color: #b01011; 2 | @create-color: #007100; 3 | 4 | .page-diff-content { 5 | .next-tabs-tabpane { 6 | padding: 20px; 7 | 8 | .diff-viewer { 9 | margin: 10px 0; 10 | display: block; 11 | border-radius: 3px; 12 | border-left: none; 13 | border: 1px solid #dedede; 14 | border-right: none; 15 | } 16 | } 17 | } 18 | 19 | .pontx-ui-page { 20 | .diff-page-header { 21 | margin-bottom: 12px; 22 | padding: 10px 20px; 23 | 24 | &.create { 25 | background-color: #eafded; 26 | border: 1px solid @create-color; 27 | } 28 | &.delete { 29 | background-color: #faeeef; 30 | border: 1px solid @delete-color; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/components.less: -------------------------------------------------------------------------------- 1 | @import url("./style/themes.less"); 2 | @import url("./changes/DiffContent.less"); 3 | @import url("./docs/API.less"); 4 | @import url("./docs/BaseClass.less"); 5 | @import url("//at.alicdn.com/t/a/font_4390490_0763b0fdyyuq.css"); 6 | 7 | table.semix-tree-table.semix-schema-table { 8 | border-collapse: collapse; 9 | } 10 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/components.scss: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @import "semix-schema-table/module/index.css"; 6 | @import "@vscode/codicons/dist/codicon.css"; 7 | @import "rc-input/assets/index.css"; 8 | @import "rc-tabs/assets/index.css"; 9 | @import "rc-menu/assets/index.css"; 10 | @import "../common/LeftMenu/APIDirectory.scss"; 11 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/designer/SchemaDesigner.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author 3 | * @description 4 | */ 5 | import * as React from "react"; 6 | 7 | export class TypeSelectorProps {} 8 | 9 | export const TypeSelector: React.FC = (props) => { 10 | const [selectedType, setSelectedType] = React.useState(""); 11 | const [selectedFormat, setSelectedFormat] = React.useState(""); 12 | 13 | return
; 14 | }; 15 | 16 | TypeSelector.defaultProps = new TypeSelectorProps(); 17 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/docs/BaseClass.less: -------------------------------------------------------------------------------- 1 | .pontx-ui-baseclass { 2 | .header { 3 | background-color: #d6e0e5; 4 | border-radius: 2px; 5 | padding: 8px 18px; 6 | line-height: 28px; 7 | margin-bottom: 20px; 8 | 9 | .title { 10 | color: black; 11 | font-weight: bold; 12 | } 13 | } 14 | .baseclass-page-content { 15 | padding: 12px 20px 12px; 16 | } 17 | } 18 | 19 | .pontx-ui-dropdown-baseclass { 20 | .next-overlay-inner { 21 | .pontx-ui-baseclass { 22 | min-width: 500px; 23 | background-color: white; 24 | border: 1px solid #89a6b5; 25 | padding: 0; 26 | } 27 | 28 | .header { 29 | border: 0; 30 | border-radius: 0; 31 | } 32 | .pontx-ui-schema-editor { 33 | border-radius: 0; 34 | } 35 | } 36 | .pontx-ui-baseclass { 37 | .header { 38 | margin-bottom: 0; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/docs/utils.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | export const getRefSchema = (schemas) => ($ref: string) => { 4 | const schemaName = $ref.split("/").pop(); 5 | const schema = schemas?.[schemaName]; 6 | if (schema) { 7 | return schema; 8 | } 9 | return null; 10 | }; 11 | 12 | export const renderExpandIcon = (node, onExpand) => { 13 | return ( 14 |
{ 23 | onExpand(node); 24 | }} 25 | > 26 | 27 |
28 | ); 29 | }; 30 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/index.tsx: -------------------------------------------------------------------------------- 1 | export * from "./changes/APIDiff"; 2 | export * from "./changes/DiffContent"; 3 | export * from "./changes/DiffPage"; 4 | export * from "./changes/utils"; 5 | export * from "./utils/service"; 6 | export * from "./docs/BaseClass"; 7 | export * from "./docs/API"; 8 | export { API as APIDocumment } from "./docs/API"; 9 | export { BaseClass as StructDocument } from "./docs/BaseClass"; 10 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/resources/pontx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/pontx-ui/src/components/resources/pontx.png -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/resources/pontx.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/style/font_1899989_82eb16avvpq.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/pontx-ui/src/components/style/font_1899989_82eb16avvpq.eot -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/style/font_1899989_lqawitevtzp.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/pontx-ui/src/components/style/font_1899989_lqawitevtzp.ttf -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/style/font_1899989_lqawitevtzp.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/pontx-ui/src/components/style/font_1899989_lqawitevtzp.woff -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/style/font_1899989_lqawitevtzp.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/pontx-ui/src/components/style/font_1899989_lqawitevtzp.woff2 -------------------------------------------------------------------------------- /packages/pontx-ui/src/components/style/themes.less: -------------------------------------------------------------------------------- 1 | @primary-color: #448ef7; 2 | @nav-height: 50px; 3 | @delete-color: #b01011; 4 | @update-color: #895503; 5 | @create-color: #007100; 6 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/index.ts: -------------------------------------------------------------------------------- 1 | import { PontUIService } from "./components/utils/service"; 2 | import { App } from "./App"; 3 | export { API as APIDocumment } from "./components/docs/API"; 4 | export { BaseClass as StructDocument } from "./components/docs/BaseClass"; 5 | export { DiffContent } from "./components/changes/DiffContent"; 6 | export { DiffPage } from "./components/changes/DiffPage"; 7 | export { LayoutContext } from "./layout/context"; 8 | export { PontUIService, App }; 9 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/layout/Page.less: -------------------------------------------------------------------------------- 1 | @import url(../components/style/themes.less); 2 | 3 | .pontx-directory { 4 | width: 400px; 5 | height: calc(100vh - 50px); 6 | } 7 | 8 | .pontx-ui { 9 | height: 100vh; 10 | 11 | .main-content { 12 | height: calc(100vh - @nav-height); 13 | display: flex; 14 | align-items: center; 15 | } 16 | 17 | .pontx-ui-page { 18 | flex-grow: 1; 19 | height: 100%; 20 | // padding: 20px; 21 | overflow-y: auto; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/layout/Page.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author 3 | * @description 4 | */ 5 | import * as React from "react"; 6 | import { ApiDoc } from "../pages/apiDoc"; 7 | import { DiffPage } from "../pages/diffManager"; 8 | import { LayoutContext, PageType } from "./context"; 9 | import "./Page.less"; 10 | 11 | export class PageProps {} 12 | 13 | export const Page: React.FC = (props) => { 14 | const { page } = LayoutContext.useContainer(); 15 | return ( 16 |
17 | {page === PageType.Diff ? : null} 18 | {page === PageType.Doc ? : null} 19 |
20 | ); 21 | }; 22 | 23 | Page.defaultProps = new PageProps(); 24 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/main.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as ReactDOM from "react-dom"; 3 | import "./components/components.less"; 4 | import "./components/components.scss"; 5 | import { App } from "./App"; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById("root"), 12 | ); 13 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/types.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@uiw/react-markdown-preview" { 2 | export default any; 3 | } 4 | -------------------------------------------------------------------------------- /packages/pontx-ui/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/pontx-ui/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./src/**/*.tsx"], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | }; 9 | -------------------------------------------------------------------------------- /packages/pontx-ui/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ES6", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "dist/es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "baseUrl": "./src", 12 | "paths": { 13 | "react": ["../node_modules/@types/react"] 14 | }, 15 | "rootDir": "./src" 16 | }, 17 | "include": ["./src/components/*"], 18 | "exclude": ["node_modules", "es6", "tests", "lib", "./src/service.local.ts"], 19 | "references": [] 20 | } 21 | -------------------------------------------------------------------------------- /packages/pontx-ui/tsconfig.commonjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "ES2015", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "dist/commonjs", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "baseUrl": "./src", 12 | "paths": { 13 | "react": ["../node_modules/@types/react"] 14 | }, 15 | "rootDir": "./src" 16 | }, 17 | "include": ["./src/components/*"], 18 | "exclude": ["node_modules", "es6", "tests", "lib", "./src/service.local.ts"], 19 | "references": [] 20 | } 21 | -------------------------------------------------------------------------------- /packages/pontx-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "target": "ES6", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strictPropertyInitialization": false, 11 | "strict": false, 12 | "noImplicitAny": false, 13 | "forceConsistentCasingInFileNames": true, 14 | "module": "ESNext", 15 | "skipDefaultLibCheck": true, 16 | "outDir": "lib", 17 | "declaration": true, 18 | "moduleResolution": "Node", 19 | "composite": true, 20 | "rootDir": "src", 21 | "resolveJsonModule": true, 22 | "isolatedModules": true, 23 | "paths": { 24 | "react": ["./node_modules/@types/react"] 25 | }, 26 | "jsx": "react" 27 | }, 28 | "include": ["src", "./src/**/*.json"], 29 | "exclude": ["node_modules"], 30 | "references": [ 31 | { "path": "./tsconfig.node.json" }, 32 | { 33 | "path": "../pontx-spec" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /packages/pontx-ui/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "esnext", 5 | "skipDefaultLibCheck": true, 6 | "skipLibCheck": true, 7 | "outDir": "out", 8 | "moduleResolution": "node" 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/vscode-pontx/.vscode/lauch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "configurations": [ 4 | { 5 | "name": "Extension", 6 | "type": "extensionHost", 7 | "request": "launch", 8 | "runtimeExecutable": "${execPath}", 9 | "args": ["--extensionDevelopmentPath=${workspaceRoot}"], 10 | "stopOnEntry": false, 11 | "sourceMaps": true, 12 | "outFiles": ["${workspaceRoot}/out/**/*.js"] 13 | }, 14 | { 15 | "name": "Extension Tests", 16 | "type": "extensionHost", 17 | "request": "launch", 18 | "runtimeExecutable": "${execPath}", 19 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test"], 20 | "stopOnEntry": false, 21 | "sourceMaps": true 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /packages/vscode-pontx/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "configurations": [ 4 | { 5 | "name": "Extension", 6 | "type": "extensionHost", 7 | "request": "launch", 8 | "runtimeExecutable": "${execPath}", 9 | "args": ["--extensionDevelopmentPath=${workspaceRoot}"], 10 | "stopOnEntry": false, 11 | "sourceMaps": true, 12 | "outFiles": ["${workspaceRoot}/out/**/*.js"] 13 | }, 14 | { 15 | "name": "Extension Tests", 16 | "type": "extensionHost", 17 | "request": "launch", 18 | "runtimeExecutable": "${execPath}", 19 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test"], 20 | "stopOnEntry": false, 21 | "sourceMaps": true 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /packages/vscode-pontx/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .vscode-test/ 3 | out/ 4 | src/ 5 | .gitignore 6 | media 7 | !media/dist 8 | node_modules 9 | !node_modules/@vscode/codicons/dist/ 10 | **/*.map 11 | tsconfig.json 12 | *.d.ts 13 | *.md 14 | !README.md 15 | stats.json 16 | yarn.lock 17 | -------------------------------------------------------------------------------- /packages/vscode-pontx/asset_source_loader.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/vscode-pontx/asset_source_loader.d.ts -------------------------------------------------------------------------------- /packages/vscode-pontx/media/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pont UI 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": "true", 3 | "name": "vscode-pontx-media", 4 | "module": "esnext", 5 | "main": "lib/server.js", 6 | "scripts": { 7 | "start": "vite --mode browser", 8 | "build:client": "NODE_ENV=production vite build", 9 | "build:server": "ncc build src/server.ts -o lib -m -e *.css", 10 | "build:server:dev": "ncc build src/server.ts -o lib -e *.css", 11 | "build": "npm run build:client && npm run build:server", 12 | "preview": "vite preview" 13 | }, 14 | "dependencies": { 15 | "pontx-ui": "^0.4.4" 16 | }, 17 | "version": "0.4.4" 18 | } 19 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/font_1899989_lqawitevtzp.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/vscode-pontx/media/src/font_1899989_lqawitevtzp.ttf -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/icon.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: NextIcon; 3 | src: url(./font_1899989_lqawitevtzp.ttf) format("truetype"); 4 | } 5 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/main.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | html body { 6 | padding: 0; 7 | border-left: 1px solid #d7d7d7; 8 | background-color: white; 9 | } 10 | .vscode-page { 11 | width: 100%; 12 | max-width: 100%; 13 | color: #333; 14 | } 15 | .pontx-page .next-icon { 16 | font-family: NextIcon !important; 17 | } 18 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/main.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as ReactDOM from "react-dom"; 3 | import "./registerService"; 4 | import "./main.css"; 5 | import "pontx-ui/dist/static/components.css"; 6 | import { App } from "./components/App"; 7 | 8 | ReactDOM.hydrate( 9 | // 10 | , 11 | document.getElementById("root")!, 12 | // , 13 | ); 14 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/registerService.tsx: -------------------------------------------------------------------------------- 1 | import { PontSpec } from "pontx-spec"; 2 | import { PontUIService } from "pontx-ui/dist/es6/components/utils/service"; 3 | import * as _ from "lodash"; 4 | import { getVSCode } from "./utils/utils"; 5 | 6 | if (import.meta.env.PROD) { 7 | const requestPostMessage = (message: { type: string; value?: any }): Promise => { 8 | const requestId = _.uniqueId(); 9 | getVSCode().postMessage({ ...message, requestId }); 10 | 11 | return new Promise((resove, reject) => { 12 | window.addEventListener("message", (event) => { 13 | const responseMessage = event.data; 14 | if (responseMessage?.type === message.type && responseMessage?.requestId === requestId) { 15 | return resove(responseMessage.data as T); 16 | } 17 | }); 18 | }); 19 | }; 20 | 21 | Object.keys(PontUIService).forEach((methodName) => { 22 | PontUIService[methodName] = (value, ...args) => { 23 | return requestPostMessage({ 24 | type: methodName, 25 | value, 26 | }); 27 | }; 28 | }); 29 | } 30 | // todo 31 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/server.ts: -------------------------------------------------------------------------------- 1 | import * as ReactDOMServer from "react-dom/server"; 2 | import * as React from "react"; 3 | import { App } from "./components/App"; 4 | 5 | export const createServerContent = (routerMeta) => { 6 | return ReactDOMServer.renderToString( 7 | React.createElement(App, { 8 | routerMeta, 9 | }), 10 | ); 11 | }; 12 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/utils/utils.ts: -------------------------------------------------------------------------------- 1 | import { PontUIService } from "pontx-ui/dist/es6/components/utils/service"; 2 | import * as React from "react"; 3 | import { useEffect } from "react"; 4 | import { PontSpec } from "pontx-spec"; 5 | import { WebviewApi } from "vscode-webview"; 6 | 7 | declare let acquireVsCodeApi: any; 8 | export const getVSCode = () => { 9 | if ((window as any).vscode) { 10 | return (window as any).vscode; 11 | } 12 | 13 | const vscode: WebviewApi = acquireVsCodeApi?.(); 14 | (window as any).vscode = vscode; 15 | 16 | return vscode; 17 | }; 18 | 19 | export function useCurrentSpec() { 20 | const [currentSpec, setCurrentSpec] = React.useState(undefined as PontSpec); 21 | 22 | useEffect(() => { 23 | PontUIService.requestPontSpecs().then((result) => { 24 | const currentSpec = 25 | result.localSpecs?.find((spec) => spec?.name === result?.currentOriginName) || result?.localSpecs?.[0]; 26 | setCurrentSpec(currentSpec); 27 | }); 28 | }, []); 29 | 30 | return { 31 | currentSpec, 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | interface ImportMetaEnv { 4 | readonly runtime: string; 5 | } 6 | 7 | interface ImportMeta { 8 | readonly env: ImportMetaEnv; 9 | } 10 | 11 | declare module "react/jsx-runtime" { 12 | export default any; 13 | } 14 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/tsconfig.commonjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "ES2015", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "jsx": "react", 11 | "skipDefaultLibCheck": true, 12 | "skipLibCheck": true, 13 | "baseUrl": "./src", 14 | "paths": {}, 15 | "rootDir": "./src" 16 | }, 17 | "include": ["./src/entry", "./src/utils", "./src/components", "src/server.ts"], 18 | "exclude": ["node_modules", "es6", "tests", "lib", "src/registerService.tsx"], 19 | "references": [] 20 | } 21 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "target": "ESNext", 5 | "useDefineForClassFields": true, 6 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 7 | "allowJs": false, 8 | "strict": false, 9 | "esModuleInterop": false, 10 | "declaration": false, 11 | "declarationMap": false, 12 | "outDir": "lib", 13 | "allowSyntheticDefaultImports": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "es2020", 16 | "moduleResolution": "Node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "jsx": "react", 20 | "rootDir": "./src" 21 | }, 22 | "include": ["./src/vite-env.d.ts", "src"] 23 | } 24 | // { "path": "../pontx-ui" } 25 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "esnext", 5 | "outDir": "out", 6 | "moduleResolution": "node" 7 | }, 8 | "include": ["vite.config.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/vscode-pontx/media/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | import * as path from "path"; 4 | 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [react()], 8 | root: "", 9 | resolve: { 10 | alias: { 11 | react: path.join(__dirname, "../../../node_modules/react"), 12 | "react-dom": path.join(__dirname, "../../../node_modules/react-dom"), 13 | }, 14 | }, 15 | build: { 16 | // minify: false, 17 | rollupOptions: { 18 | output: { 19 | entryFileNames: `assets/[name].js`, 20 | chunkFileNames: `assets/[name].js`, 21 | assetFileNames: `assets/[name].[ext]`, 22 | }, 23 | }, 24 | }, 25 | css: {}, 26 | }); 27 | -------------------------------------------------------------------------------- /packages/vscode-pontx/resources/pontx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/packages/vscode-pontx/resources/pontx.png -------------------------------------------------------------------------------- /packages/vscode-pontx/resources/pontx.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/vscode-pontx/schemas/api-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$ref": "pont-schema.json#/definitions/api" 4 | } 5 | -------------------------------------------------------------------------------- /packages/vscode-pontx/schemas/struct-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$ref": "pont-schema.json#/definitions/schema" 4 | } 5 | -------------------------------------------------------------------------------- /packages/vscode-pontx/src/changes/guide.md: -------------------------------------------------------------------------------- 1 | RemoteSpecs 2 | => Changes 3 | StagedSpecs 4 | => Staged Changes 5 | _ commit: updateRemoteSpecs = (RemoteSpecs, StagedSpec, Diffs) => NewRemoteSpecs 6 | _ unStage: updateStagedSpecs = (StagedSpec, LocalSpecs) 7 | LocalSpecs 8 | 9 | # 原始数据 10 | 11 | - LocalSpecs 12 | - RemoteSpecs 13 | 14 | # 衍生数据 15 | 16 | - Diff 算法 17 | - compare 18 | - Pure,判断指针相同。 19 | - 定制 Diff 级别。deepDiff(pre, next, stopRecurve: ) 20 | - 定制 Diff 组装 21 | 22 | # 渲染数据 23 | 24 | - List(明细) 25 | - Label 26 | - iconPath 27 | - command 28 | - resourceUri for Diff 类型 29 | - contextValue: item key for vscode 30 | - Tree(父子关系查询) 31 | 32 | ## 渲染方法 33 | 34 | - getChildren 35 | - fireEvent 36 | 37 | ## 事件 38 | 39 | - 变更明细 40 | - API 文档 41 | - 打开 42 | - Diff 管理 43 | -------------------------------------------------------------------------------- /packages/vscode-pontx/task.md: -------------------------------------------------------------------------------- 1 | ## bugfix 2 | 3 | - pontx @summary 和注释信息相同 4 | - 控制台 5 | - Diff 解决冲突 6 | - ext diff 时,无法 update diff。展示也有问题 7 | 8 | ## feature 9 | 10 | - pontx ai generate frontend code 11 | - pontx init 12 | - ui editor action as view meta/edit mocks/ 13 | - 离线状态 完成。 14 | - pont ui plugin 15 | - mocks 16 | - 定时更新 17 | - spec 进阶 18 | - test case 19 | - OneAPI parser plugin 20 | - more generators 21 | - usage report plugin 22 | - API 可编辑 23 | - json schema rule language server 24 | - pontx-service 冲突时,自动唤起 Diff 管理。 25 | - jsonschemastore 上传 26 | - diff too slow 27 | -------------------------------------------------------------------------------- /packages/vscode-pontx/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "outDir": "dist", 7 | "skipLibCheck": true, 8 | "skipDefaultLibCheck": true, 9 | "declarationMap": false, 10 | "declaration": false, 11 | "lib": ["es6", "es7"], 12 | "sourceMap": true, 13 | "rootDir": "./src" 14 | }, 15 | "exclude": ["node_modules", ".vscode-test", "out", "media", "dist"], 16 | "references": [ 17 | { 18 | "path": "../pontx-manager" 19 | }, 20 | { 21 | "path": "../pontx-spec-diff" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /plugins/fetch/pontx-meta-fetch-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-meta-fetch-plugin", 3 | "version": "0.4.12", 4 | "description": "OpenAPI pont spec", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 11 | "build": "npm run clean && tsc --build" 12 | }, 13 | "files": [ 14 | "package.json", 15 | "lib", 16 | "*.md" 17 | ], 18 | "dependencies": { 19 | "baidu-translate-service": "^1.0.0", 20 | "fs-extra": "*", 21 | "node-fetch": "^2.6.7", 22 | "translation.js": "^0.7.15" 23 | }, 24 | "peerDependencies": { 25 | "lodash": "*", 26 | "pontx-manager": "*" 27 | }, 28 | "keywords": [], 29 | "author": "jasonHzq", 30 | "license": "MIT", 31 | "devDependencies": { 32 | "@types/fs-extra": "*", 33 | "@types/lodash": "*" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /plugins/fetch/pontx-meta-fetch-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "rootDir": "./src", 11 | "composite": true, 12 | "baseUrl": ".", 13 | "paths": {} 14 | }, 15 | "include": ["./src/**/*"], 16 | "exclude": ["node_modules", "build"], 17 | "references": [ 18 | { 19 | "path": "../../../packages/pontx-manager" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /plugins/generate/core/asset_source_loader.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/plugins/generate/core/asset_source_loader.d.ts -------------------------------------------------------------------------------- /plugins/generate/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-generate-core", 3 | "version": "0.4.12", 4 | "description": "OpenAPI pont spec", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 11 | "build": "npm run clean && tsc --build" 12 | }, 13 | "dependencies": { 14 | "fs-extra": "*", 15 | "lodash": "*", 16 | "pontx-spec": "^0.4.12" 17 | }, 18 | "files": [ 19 | "package.json", 20 | "lib" 21 | ], 22 | "keywords": [], 23 | "author": "jasonHzq", 24 | "license": "MIT", 25 | "devDependencies": { 26 | "@types/fs-extra": "*", 27 | "@types/lodash": "*" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /plugins/generate/core/src/Snippet.ts: -------------------------------------------------------------------------------- 1 | export class Snippet { 2 | code = ""; 3 | name = ""; 4 | description? = ""; 5 | } 6 | -------------------------------------------------------------------------------- /plugins/generate/core/src/index.ts: -------------------------------------------------------------------------------- 1 | export { FileGenerator, FileStructure, NoModFileStructure } from "./FileGenerator"; 2 | export { CodeGenerator as CodeGenerator, indentation, needQuotationMark } from "./CodeGenerator"; 3 | export { Snippet } from "./Snippet"; 4 | -------------------------------------------------------------------------------- /plugins/generate/core/src/utils.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs-extra"; 2 | 3 | export function clearPath(basePath: string) { 4 | const isExists = fs.existsSync(basePath); 5 | 6 | if (isExists) { 7 | return fs.removeSync(basePath); 8 | } 9 | } 10 | export function getModName(mod) { 11 | if (typeof mod.name === "string") { 12 | return mod.name; 13 | } 14 | return "main"; 15 | } 16 | -------------------------------------------------------------------------------- /plugins/generate/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "noImplicitAny": false, 6 | "target": "es6", 7 | "removeComments": true, 8 | "preserveConstEnums": true, 9 | "outDir": "lib", 10 | "moduleResolution": "node", 11 | "baseUrl": ".", 12 | "paths": {}, 13 | "composite": true, 14 | "rootDir": "./src" 15 | }, 16 | "include": ["./src/**/*"], 17 | "exclude": ["node_modules", "build"], 18 | "references": [ 19 | { 20 | "path": "../../../packages/pontx-spec" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /plugins/generate/pontx-async-sdk-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-async-sdk-plugin", 3 | "version": "0.4.12", 4 | "description": "async await promise sdk oas2 oas3 swagger typescript ts pontx sdk plugin", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "builtin": "tsc -p ./tsconfig.builtin.json", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build": "npm run clean && tsc --build" 13 | }, 14 | "dependencies": { 15 | "pontx-generate": "^0.4.12", 16 | "pontx-spec": "^0.4.12" 17 | }, 18 | "peerDependencies": { 19 | "fs-extra": "^10.1.0", 20 | "pontx-manager": "*" 21 | }, 22 | "files": [ 23 | "package.json", 24 | "builtin", 25 | "builtinSrc", 26 | "lib" 27 | ], 28 | "keywords": [], 29 | "author": "jasonHzq", 30 | "license": "MIT", 31 | "devDependencies": { 32 | "@types/fs-extra": "^9.0.13", 33 | "@types/node": "*" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /plugins/generate/pontx-async-sdk-plugin/src/index.tsx: -------------------------------------------------------------------------------- 1 | import { getFilesBySpecs, snippetsProvider } from "pontx-generate"; 2 | import { createPontxGeneratePlugin, SnippetsProvider, PontxGeneratorPlugin } from "pontx-generate"; 3 | 4 | export const reactHooksGeneratePlugin: any = createPontxGeneratePlugin({ 5 | snippetsProvider, 6 | getFilesBySpecs, 7 | }); 8 | 9 | export default reactHooksGeneratePlugin; 10 | export { getFilesBySpecs, snippetsProvider }; 11 | -------------------------------------------------------------------------------- /plugins/generate/pontx-async-sdk-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "baseUrl": ".", 11 | "paths": {}, 12 | "rootDir": "./src", 13 | "composite": true 14 | }, 15 | "include": ["./src/**/*", "template"], 16 | "exclude": ["node_modules", "build", "tests"], 17 | "references": [ 18 | { 19 | "path": "../../../packages/generate/tsconfig.json" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /plugins/generate/pontx-eggjs-sdk-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-eggjs-sdk-plugin", 3 | "version": "0.4.12", 4 | "description": "egg.js typescript ts pontx sdk plugin", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "builtin": "tsc -p ./tsconfig.builtin.json", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build": "tsc --build" 13 | }, 14 | "dependencies": { 15 | "pontx-generate": "^0.4.12", 16 | "pontx-spec": "^0.4.12" 17 | }, 18 | "peerDependencies": { 19 | "fs-extra": "^10.1.0", 20 | "pontx-manager": "*" 21 | }, 22 | "files": [ 23 | "package.json", 24 | "builtin", 25 | "builtinSrc", 26 | "lib" 27 | ], 28 | "keywords": [], 29 | "author": "jasonHzq", 30 | "license": "MIT", 31 | "devDependencies": { 32 | "@types/fs-extra": "^9.0.13", 33 | "@types/node": "*" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /plugins/generate/pontx-eggjs-sdk-plugin/src/template/apiDTs.ts: -------------------------------------------------------------------------------- 1 | import * as PontSpec from "pontx-spec"; 2 | import * as _ from "lodash"; 3 | import { TypeScriptGenerator } from "pontx-generate"; 4 | 5 | /** 生成单个接口的类型和 SDK 代码,可扩展其它方法 */ 6 | export const apiDTsCode = (api: PontSpec.PontAPI, controllerName: string, specName: string) => { 7 | const paramTypes = TypeScriptGenerator.generateParametersTsCode(api, specName, false); 8 | const bodyParam = api.parameters?.find((param) => param.in === "body"); 9 | let bodyParamType = "undefined"; 10 | if (bodyParam) { 11 | const bodyParamSchema = bodyParam?.schema; 12 | bodyParamType = TypeScriptGenerator.generateSchemaCode(bodyParamSchema, specName); 13 | } 14 | let method = api?.method; 15 | 16 | const code = [ 17 | `export ${paramTypes};`, 18 | method ? `export type method = '${method.toUpperCase()}';` : "", 19 | `export type bodyParams = ${bodyParamType};`, 20 | `export type Request = {`, 21 | ` method?: '${method.toUpperCase()}';`, 22 | ` url?: string;`, 23 | bodyParamType === "undefined" ? "" : ` body: ${bodyParamType};`, 24 | ` params: Params;`, 25 | ` headers?: Headers;`, 26 | `}`, 27 | `export type APIResponse = ${TypeScriptGenerator.generateSchemaCode(api.responses["200"]?.schema)};`, 28 | ] 29 | .filter((id) => id) 30 | .join("\n"); 31 | 32 | return code; 33 | }; 34 | -------------------------------------------------------------------------------- /plugins/generate/pontx-eggjs-sdk-plugin/src/template/specIndexDTsWithoutController.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import * as PontSpec from "pontx-spec"; 3 | import { apiDTsCode } from "./apiDTs"; 4 | import { TypeScriptGenerator, indentation } from "pontx-generate"; 5 | import { generateClassComment } from "pontx-generate/lib/language/TypeScript"; 6 | 7 | export const specIndexDTsWithoutController = (spec: PontSpec.PontSpec) => { 8 | return ` 9 | type ObjectMap = { 10 | [key in Key]: Value; 11 | }; 12 | 13 | export namespace defs { 14 | ${_.map(spec.definitions, (schema, name) => { 15 | const comment = generateClassComment(schema, name); 16 | return indentation(2)(comment + "export " + TypeScriptGenerator.generateBaseClassTsCode(schema, name, true)); 17 | }).join("\n\n")} 18 | } 19 | 20 | export namespace API { 21 | ${_.map(spec.apis, (api, name) => { 22 | const apiContentTsCode = indentation(2)(apiDTsCode(api, name, "")); 23 | const apiCommentCode = TypeScriptGenerator.apiComment(api); 24 | const apiNamespaceCode = indentation(2)(`${apiCommentCode}export namespace ${name} { 25 | ${apiContentTsCode} 26 | };`); 27 | return apiNamespaceCode; 28 | }).join("\n\n")} 29 | } 30 | `; 31 | }; 32 | -------------------------------------------------------------------------------- /plugins/generate/pontx-eggjs-sdk-plugin/src/template/specsDts.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import * as PontSpec from "pontx-spec"; 3 | 4 | export const specsDts = (specs: PontSpec.PontSpec[]) => { 5 | const imports = specs.map((spec) => `import { ${spec.name} } from "./${spec.name}/type";`).join("\n"); 6 | 7 | return ""; 8 | }; 9 | -------------------------------------------------------------------------------- /plugins/generate/pontx-eggjs-sdk-plugin/src/template/utils.tsx: -------------------------------------------------------------------------------- 1 | export const getPrefix = (controllerName: string, specName: string) => { 2 | if (controllerName) { 3 | return `API.${controllerName}`; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /plugins/generate/pontx-eggjs-sdk-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "baseUrl": ".", 11 | "paths": {}, 12 | "rootDir": "./src", 13 | "composite": true 14 | }, 15 | "include": ["./src/**/*", "template"], 16 | "exclude": ["node_modules", "build", "tests"], 17 | "references": [ 18 | { 19 | "path": "../../../packages/generate/tsconfig.json" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /plugins/generate/pontx-react-hooks-sdk-plugin/asset_source_loader.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/plugins/generate/pontx-react-hooks-sdk-plugin/asset_source_loader.d.ts -------------------------------------------------------------------------------- /plugins/generate/pontx-react-hooks-sdk-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-react-hooks-sdk-plugin", 3 | "version": "0.3.88", 4 | "description": "OpenAPI pont spec", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "builtin": "tsc -p ./tsconfig.builtin.json", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build": "npm run clean && tsc --build" 13 | }, 14 | "dependencies": { 15 | "pontx-generate": "^0.3.88", 16 | "pontx-sdk-plugin-core": "^0.3.85", 17 | "pontx-spec": "^0.3.88" 18 | }, 19 | "peerDependencies": { 20 | "fs-extra": "^10.1.0", 21 | "pontx-manager": "*" 22 | }, 23 | "files": [ 24 | "package.json", 25 | "builtin", 26 | "builtinSrc", 27 | "lib" 28 | ], 29 | "keywords": [], 30 | "author": "jasonHzq", 31 | "license": "MIT", 32 | "devDependencies": { 33 | "@types/fs-extra": "^9.0.13", 34 | "@types/node": "*", 35 | "http-server": "*", 36 | "react": "^18.0.0", 37 | "swr": "^2.1.5" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /plugins/generate/pontx-react-hooks-sdk-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "baseUrl": ".", 11 | "paths": {}, 12 | "rootDir": "./src", 13 | "composite": true 14 | }, 15 | "include": ["./src/**/*", "template"], 16 | "exclude": ["node_modules", "build", "tests"], 17 | "references": [ 18 | { 19 | "path": "../../../packages/pontx-spec" 20 | }, 21 | { 22 | "path": "../../../packages/pontx-manager" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /plugins/mocks/pontx-mocks-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-mocks-plugin", 3 | "version": "0.4.12", 4 | "description": "OpenAPI pont spec", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 11 | "build": "npm run clean && tsc --build" 12 | }, 13 | "peerDependencies": { 14 | "lodash": "*", 15 | "pontx-manager": "*" 16 | }, 17 | "dependencies": { 18 | "json-schema-faker": "^0.5.3", 19 | "pontx-generate": "^0.4.12", 20 | "pontx-spec": "^0.4.12" 21 | }, 22 | "files": [ 23 | "package.json", 24 | "lib" 25 | ], 26 | "keywords": [], 27 | "author": "jasonHzq", 28 | "license": "MIT", 29 | "repository": "git@github.com:pontjs/pontx.git" 30 | } 31 | -------------------------------------------------------------------------------- /plugins/mocks/pontx-mocks-plugin/src/utils.ts: -------------------------------------------------------------------------------- 1 | export const mapPromiseValues = (promiseValues: { [x: string]: Promise }) => { 2 | return Promise.all(Object.values(promiseValues)).then((values) => { 3 | return Object.keys(promiseValues).reduce((result, key, index) => { 4 | result[key] = values[index]; 5 | return result; 6 | }, {} as { [x: string]: any }); 7 | }); 8 | }; 9 | -------------------------------------------------------------------------------- /plugins/mocks/pontx-mocks-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "noImplicitAny": false, 6 | "target": "es6", 7 | "removeComments": true, 8 | "preserveConstEnums": true, 9 | "outDir": "lib", 10 | "moduleResolution": "node", 11 | "baseUrl": ".", 12 | "paths": {}, 13 | "composite": true, 14 | "rootDir": "./src" 15 | }, 16 | "include": ["./src/**/*"], 17 | "exclude": ["node_modules", "build"], 18 | "references": [ 19 | { 20 | "path": "../../../packages/pontx-spec" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas2-parser-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-oas2-parser-plugin", 3 | "version": "0.4.12", 4 | "description": "OpenAPI Spec parse pont", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "release": "npm publish --registry //registry.npmjs.org", 10 | "watch": "tsc --build --watch", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build:extra": "tsc -p tsconfig.es6.json", 13 | "build": "npm run clean && tsc --build" 14 | }, 15 | "dependencies": { 16 | "oas-spec-ts": "^0.4.12", 17 | "pontx-oas3-parser-plugin": "^0.4.12", 18 | "pontx-spec": "^0.4.12" 19 | }, 20 | "peerDependencies": { 21 | "lodash": "*", 22 | "pontx-manager": "*" 23 | }, 24 | "files": [ 25 | "package.json", 26 | "module", 27 | "lib" 28 | ], 29 | "keywords": [], 30 | "author": "jasonHzq", 31 | "license": "MIT", 32 | "devDependencies": { 33 | "@types/lodash": "*" 34 | }, 35 | "repository": "git@github.com:pontjs/pontx.git" 36 | } 37 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas2-parser-plugin/src/index.ts: -------------------------------------------------------------------------------- 1 | import { PontOAS2ParserPlugin } from "./oas2/index"; 2 | export { parseOAS2 } from "./oas2/index"; 3 | 4 | export default PontOAS2ParserPlugin; 5 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas2-parser-plugin/tsconfig.es6.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ES6", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "useDefineForClassFields": true, 9 | "outDir": "module", 10 | "moduleResolution": "Node", 11 | "strictPropertyInitialization": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "baseUrl": ".", 14 | "paths": {}, 15 | "composite": true, 16 | "rootDir": "./src" 17 | }, 18 | "include": ["./src/**/*"], 19 | "exclude": ["node_modules", "build"], 20 | "references": [ 21 | { 22 | "path": "../../../packages/pontx-manager" 23 | }, 24 | { 25 | "path": "../../../packages/pontx-spec" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas2-parser-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "useDefineForClassFields": true, 9 | "outDir": "lib", 10 | "moduleResolution": "node", 11 | "strictPropertyInitialization": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "baseUrl": ".", 14 | "paths": {}, 15 | "composite": true, 16 | "rootDir": "./src" 17 | }, 18 | "include": ["./src/**/*"], 19 | "exclude": ["node_modules", "build"], 20 | "references": [ 21 | { 22 | "path": "../../../packages/pontx-manager" 23 | }, 24 | { 25 | "path": "../../../packages/pontx-spec" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas3-parser-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-oas3-parser-plugin", 3 | "version": "0.4.12", 4 | "description": "OpenAPI Spec parse pont", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "release": "npm publish", 11 | "build:extra": "tsc -p tsconfig.es6.json", 12 | "build:extra:watch": "tsc -p tsconfig.es6.json -w", 13 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 14 | "build": "npm run clean && tsc --build" 15 | }, 16 | "dependencies": { 17 | "oas-spec-ts": "^0.4.12", 18 | "pontx-spec": "^0.4.12" 19 | }, 20 | "peerDependencies": { 21 | "lodash": "*", 22 | "pontx-manager": "*" 23 | }, 24 | "files": [ 25 | "package.json", 26 | "lib" 27 | ], 28 | "keywords": [], 29 | "author": "jasonHzq", 30 | "license": "MIT", 31 | "devDependencies": { 32 | "@types/lodash": "*" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas3-parser-plugin/src/index.ts: -------------------------------------------------------------------------------- 1 | import { PontOAS3ParserPlugin } from "./oas3/index"; 2 | 3 | export default PontOAS3ParserPlugin; 4 | 5 | export { PontOAS3ParserPlugin }; 6 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas3-parser-plugin/src/oas3/index.ts: -------------------------------------------------------------------------------- 1 | import { parseOAS3 } from "./parser"; 2 | import { PontxParserPlugin } from "pontx-manager"; 3 | import { PontSpec } from "pontx-spec"; 4 | 5 | export class PontOAS3ParserPlugin extends PontxParserPlugin { 6 | apply(metaStr: string, specName: string, options?: any): Promise { 7 | try { 8 | let swaggerObj = null; 9 | 10 | try { 11 | swaggerObj = JSON.parse(metaStr); 12 | } catch (e) { 13 | this.logger.error("当前获取到的远程元数据不符合 JSON 格式,无法解析为 pont spec。元数据为:" + metaStr); 14 | return; 15 | } 16 | 17 | const origin = 18 | this.innerConfig?.origins?.find((origin) => origin?.name === specName) || this.innerConfig?.origins?.[0]; 19 | const originUrl = origin?.url; 20 | 21 | return Promise.resolve(parseOAS3(swaggerObj, specName, this.innerConfig.translator, originUrl)); 22 | } catch (e) { 23 | console.log(e.stack); 24 | this.logger.error(e.message); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas3-parser-plugin/tsconfig.es6.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ES6", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "useDefineForClassFields": true, 9 | "outDir": "module", 10 | "moduleResolution": "Node", 11 | "strictPropertyInitialization": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "baseUrl": ".", 14 | "paths": {}, 15 | "composite": true, 16 | "rootDir": "./src" 17 | }, 18 | "include": ["./src/**/*"], 19 | "exclude": ["node_modules", "build"], 20 | "references": [ 21 | { 22 | "path": "../../../packages/pontx-manager" 23 | }, 24 | { 25 | "path": "../../../packages/pontx-spec" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /plugins/parser/pontx-oas3-parser-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "useDefineForClassFields": true, 9 | "outDir": "lib", 10 | "moduleResolution": "node", 11 | "strictPropertyInitialization": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "baseUrl": ".", 14 | "paths": {}, 15 | "composite": true, 16 | "rootDir": "./src" 17 | }, 18 | "include": ["./src/**/*"], 19 | "exclude": ["node_modules", "build"], 20 | "references": [ 21 | { 22 | "path": "../../../packages/pontx-manager" 23 | }, 24 | { 25 | "path": "../../../packages/pontx-spec" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /plugins/report/pontx-report-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-report-plugin", 3 | "version": "0.3.70", 4 | "description": "OpenAPI pont spec", 5 | "private": true, 6 | "main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "pretest": "npm run build", 10 | "watch": "tsc -w", 11 | "build": "rimraf lib && tsc" 12 | }, 13 | "files": [ 14 | "package.json", 15 | "lib" 16 | ], 17 | "keywords": [], 18 | "devDependencies": { 19 | "@types/node": "*" 20 | }, 21 | "author": "jasonHzq", 22 | "license": "MIT" 23 | } 24 | -------------------------------------------------------------------------------- /plugins/report/pontx-report-plugin/src/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/plugins/report/pontx-report-plugin/src/index.ts -------------------------------------------------------------------------------- /plugins/report/pontx-report-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "noImplicitAny": false, 5 | "declaration": true, 6 | "skipDefaultLibCheck": true, 7 | "skipLibCheck": true, 8 | "target": "es6", 9 | "removeComments": true, 10 | "preserveConstEnums": true, 11 | "sourceMap": true, 12 | "outDir": "lib", 13 | "moduleResolution": "node", 14 | "experimentalDecorators": true, 15 | "emitDecoratorMetadata": true, 16 | "baseUrl": ".", 17 | "paths": { 18 | }, 19 | "allowSyntheticDefaultImports": true, 20 | "lib": ["dom", "es6", "es2017", "dom.iterable", "scripthost"] 21 | }, 22 | "include": ["./src/**/*"], 23 | "exclude": ["node_modules", "build"] 24 | } 25 | -------------------------------------------------------------------------------- /progress.md: -------------------------------------------------------------------------------- 1 | # progress 2 | ## todo 3 | ### 核心层 4 | 5 | * 测试用例 6 | * spec diff 7 | 8 | ### 插件 9 | 10 | * OAS2 parser 翻译 11 | * OAS3 parser 12 | * ng generate 13 | * responses filter transform 14 | * pont UI => pont platform => vscode pont 15 | * mocks, mocks in sdk 16 | * usage-report 17 | -------------------------------------------------------------------------------- /scripts/batch.js: -------------------------------------------------------------------------------- 1 | const child_process = require("child_process"); 2 | 3 | const cmd = process.argv[2]; 4 | 5 | console.log(`cmd found: ${cmd}`); 6 | 7 | const result = child_process.execSync("npm run pkg-ls", { 8 | // stdio: [0, 1, 2], 9 | }); 10 | 11 | if (result) { 12 | result 13 | .toString("utf-8") 14 | .split("\n") 15 | .forEach((line) => { 16 | if (line.startsWith(">")) { 17 | return; 18 | } 19 | if (line) { 20 | const pkgName = line.trim(); 21 | 22 | try { 23 | child_process.execSync(`${cmd} ${pkgName}`, { 24 | stdio: [0, 1, 2], 25 | }); 26 | } catch (e) {} 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /scripts/clean-lock.js: -------------------------------------------------------------------------------- 1 | const child_process = require("child_process"); 2 | const path = require("path"); 3 | 4 | try { 5 | child_process.execSync("rm package-lock.json", { 6 | cwd: path.join(__dirname + "../../"), 7 | stdio: [0, 1, 2], 8 | }); 9 | } catch (e) {} 10 | 11 | try { 12 | child_process.execSync("rm packages/**/package-lock.json", { 13 | cwd: path.join(__dirname + "../../"), 14 | stdio: [0, 1, 2], 15 | }); 16 | } catch (e) {} 17 | 18 | try { 19 | child_process.execSync("rm plugins/**/package-lock.json", { 20 | cwd: path.join(__dirname + "../../"), 21 | stdio: [0, 1, 2], 22 | }); 23 | } catch (e) {} 24 | 25 | try { 26 | child_process.execSync("rm plugins/**/*/package-lock.json", { 27 | cwd: path.join(__dirname + "../../"), 28 | stdio: [0, 1, 2], 29 | }); 30 | } catch (e) {} 31 | 32 | try { 33 | child_process.execSync("rm semix/**/package-lock.json", { 34 | cwd: path.join(__dirname + "../../"), 35 | stdio: [0, 1, 2], 36 | }); 37 | } catch (e) {} 38 | -------------------------------------------------------------------------------- /scripts/jest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is the entry for debug single test file in vscode 3 | * 4 | * Not using node_modules/.bin/jest due to cross platform issues, see 5 | * https://github.com/microsoft/vscode-recipes/issues/107 6 | */ 7 | require('jest').run(process.argv); 8 | -------------------------------------------------------------------------------- /scripts/patchNpm.js: -------------------------------------------------------------------------------- 1 | const { execSync, exec } = require("child_process"); 2 | const fs = require("fs-extra"); 3 | const path = require("path"); 4 | 5 | async function main() { 6 | const patchVersion = execSync(`lerna version patch --no-private --yes --message 'chore: publish'`, { 7 | encoding: "utf-8", 8 | }); 9 | fs.writeFileSync(path.join(__dirname, "dev", "patchVersion.txt"), patchVersion); 10 | console.log("packages version changes: \n" + patchVersion); 11 | } 12 | 13 | main(); 14 | -------------------------------------------------------------------------------- /scripts/releasePlatform.js: -------------------------------------------------------------------------------- 1 | const childProcess = require("child_process"); 2 | const path = require("path"); 3 | 4 | childProcess.execSync("npm run build", { 5 | cwd: path.join(__dirname, "../packages/pontx-platform"), 6 | stdio: [0, 1, 2], 7 | }); 8 | -------------------------------------------------------------------------------- /scripts/releaseVscode.sh: -------------------------------------------------------------------------------- 1 | cd packages/vscode-pontx 2 | echo 'deleting node_modules...' 3 | rm -rf node_modules 4 | cd ../ 5 | cp -r vscode-pontx vscode-pontx-cp 6 | cd vscode-pontx-cp 7 | echo 'installing node_modules...' 8 | npm cache clean --force 9 | npm i --registry https://registry.npmmirror.com 10 | echo 'release vscode' 11 | vsce package 12 | # cd .. 13 | # rm -rf vscode-pontx-cp 14 | # cd .. 15 | # npm run inst 16 | -------------------------------------------------------------------------------- /scripts/syncRegistry.js: -------------------------------------------------------------------------------- 1 | const child_process = require("child_process"); 2 | 3 | const packages = [ 4 | "jsonschema-form", 5 | "pontx-cli", 6 | "pontx-manager", 7 | "pontx-generate", 8 | "pontx-spec", 9 | "pontx-spec-diff", 10 | "pontx-ui", 11 | "oas-spec-ts", 12 | "pontx-meta-fetch-plugin", 13 | "pontx-generate-core", 14 | "pontx-mocks-plugin", 15 | "pontx-sdk-core", 16 | "pontx-sdk-plugin-core", 17 | "pontx-async-sdk-plugin", 18 | "pontx-oas2-parser-plugin", 19 | "pontx-oas3-parser-plugin", 20 | ]; 21 | 22 | const hostname = process.argv[2] || "https://npmmirror.com"; 23 | 24 | child_process.execSync(packages.map((name) => `open ${hostname}/sync/${name}`).join(" && ")); 25 | -------------------------------------------------------------------------------- /scripts/utils.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const chalk = require('chalk') 3 | 4 | const targets = (exports.targets = fs.readdirSync('packages').filter(f => { 5 | if (!fs.statSync(`packages/${f}`).isDirectory()) { 6 | return false 7 | } 8 | const pkg = require(`../packages/${f}/package.json`) 9 | if (pkg.private && !pkg.buildOptions) { 10 | return false 11 | } 12 | return true 13 | })) 14 | 15 | exports.fuzzyMatchTarget = (partialTargets, includeAllMatching) => { 16 | const matched = [] 17 | partialTargets.forEach(partialTarget => { 18 | for (const target of targets) { 19 | if (target.match(partialTarget)) { 20 | matched.push(target) 21 | if (!includeAllMatching) { 22 | break 23 | } 24 | } 25 | } 26 | }) 27 | if (matched.length) { 28 | return matched 29 | } else { 30 | console.log() 31 | console.error( 32 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( 33 | `Target ${chalk.underline(partialTargets)} not found!` 34 | )}` 35 | ) 36 | console.log() 37 | 38 | process.exit(1) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /scripts/verifyCommit.js: -------------------------------------------------------------------------------- 1 | // Invoked on the commit-msg git hook by yorkie. 2 | 3 | const chalk = require("chalk"); 4 | const msgPath = process.env.GIT_PARAMS; 5 | const msg = require("fs").readFileSync(msgPath, "utf-8").trim(); 6 | 7 | const commitRE = /^(revert: )?(feat|fix|docs|refactor|perf|test|workflow|build|ci|chore|wip|release)(\(.+\))?: .{1,50}/; 8 | 9 | if (!commitRE.test(msg)) { 10 | console.log(); 11 | console.error( 12 | ` ${chalk.bgRed.white(" ERROR ")} ${chalk.red(`commit 格式不合法 `)}\n\n` + 13 | ` ${chalk.bgBlue.white(` ${commitRE} `)}\n\n` + 14 | chalk.red(` Proper commit message format is required for automated changelog generation. Examples:\n\n`) + 15 | ` ${chalk.green(`feat(core): `)}\n` + 16 | ` ${chalk.green(`fix(plugin): handle some error when sometime (close #28)`)}\n\n` + 17 | chalk.red(` See .github/commit-convention.md for more details.\n`), 18 | ); 19 | process.exit(1); 20 | } 21 | -------------------------------------------------------------------------------- /scripts/verifySafeCode.js: -------------------------------------------------------------------------------- 1 | // Invoked on the commit-msg git hook by yorkie. 2 | 3 | const chalk = require("chalk"); 4 | const fs = require("fs-extra"); 5 | const path = require("path"); 6 | 7 | // 校验示例项目 8 | const examplePontConfig = require("../examples/react-app/config/pontx-config.json"); 9 | if (examplePontConfig.origin && examplePontConfig.origin.url !== "https://petstore.swagger.io/v2/swagger.json") { 10 | console.log(); 11 | console.error(` ${chalk.red(`[ERROR]: examples/react-app pont-config url 不合法`)}\n\n`); 12 | 13 | process.exit(1); 14 | } 15 | 16 | // 校验 pont-ui mocks 17 | const contextCode = fs.readFileSync(path.join(__dirname, "../packages/pontx-ui/src/layout/context.ts"), "utf-8"); 18 | const hasPontUIUseMocks = (contextCode || "").includes(`\nimport * as spec from "../mocks/spec.json";`); 19 | if (hasPontUIUseMocks) { 20 | console.log(); 21 | console.error(` ${chalk.red(`[ERROR]: packages/pont-ui/src/layout/context.ts 引用了 mocks 数据`)}\n\n`); 22 | 23 | process.exit(1); 24 | } 25 | -------------------------------------------------------------------------------- /sdk/pontx-eggjs-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-eggjs-sdk", 3 | "version": "0.4.12", 4 | "description": "async await promise sdk oas2 oas3 swagger typescript ts pontx sdk plugin", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "builtin": "tsc -p ./tsconfig.builtin.json", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build": "npm run clean && tsc --build" 13 | }, 14 | "peerDependencies": { 15 | "egg": "^3.17.5", 16 | "lodash": "*" 17 | }, 18 | "dependencies": { 19 | "pontx-spec": "^0.4.12" 20 | }, 21 | "devDependencies": { 22 | "@types/fs-extra": "^9.0.13", 23 | "@types/node": "*", 24 | "egg": "^3.17.5", 25 | "fs-extra": "^10.1.0", 26 | "http-server": "*", 27 | "pontx-generate": "^0.4.12", 28 | "pontx-generate-core": "^0.4.12", 29 | "pontx-manager": "^0.4.12", 30 | "react": "^18" 31 | }, 32 | "files": [ 33 | "package.json", 34 | "builtin", 35 | "builtinSrc", 36 | "lib" 37 | ], 38 | "keywords": [], 39 | "author": "jasonHzq", 40 | "license": "MIT" 41 | } 42 | -------------------------------------------------------------------------------- /sdk/pontx-eggjs-sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "ES2015", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "resolveJsonModule": true, 10 | "moduleResolution": "node", 11 | "baseUrl": "./src", 12 | "rootDir": "./src" 13 | }, 14 | "include": ["./src/*"], 15 | "exclude": ["node_modules", "es6", "tests", "lib"], 16 | "references": [] 17 | } 18 | -------------------------------------------------------------------------------- /sdk/pontx-hooks-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-hooks-sdk", 3 | "version": "0.3.88", 4 | "description": "async await promise sdk oas2 oas3 swagger typescript ts pontx sdk plugin", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "scripts": { 8 | "pretest": "npm run build", 9 | "watch": "tsc --build --watch", 10 | "builtin": "tsc -p ./tsconfig.builtin.json", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 12 | "build": "npm run clean && tsc --build" 13 | }, 14 | "peerDependencies": { 15 | "swr": "^2.2.4" 16 | }, 17 | "dependencies": { 18 | "pontx-sdk-core": "^0.3.88" 19 | }, 20 | "devDependencies": { 21 | "@types/fs-extra": "^9.0.13", 22 | "@types/node": "*", 23 | "fs-extra": "^10.1.0", 24 | "http-server": "*", 25 | "pontx-generate": "^0.3.88", 26 | "pontx-generate-core": "^0.3.88", 27 | "pontx-manager": "^0.3.88", 28 | "pontx-spec": "^0.3.88", 29 | "react": "^16.14.0", 30 | "swr": "^2.1.5" 31 | }, 32 | "files": [ 33 | "package.json", 34 | "builtin", 35 | "builtinSrc", 36 | "lib" 37 | ], 38 | "keywords": [], 39 | "author": "jasonHzq", 40 | "license": "MIT" 41 | } 42 | -------------------------------------------------------------------------------- /sdk/pontx-hooks-sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ES6", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "strictFunctionTypes": false, 9 | "strictNullChecks": false, 10 | "outDir": "lib", 11 | "moduleResolution": "node", 12 | "declaration": true, 13 | "baseUrl": ".", 14 | "paths": {}, 15 | "rootDir": "./src", 16 | "composite": true 17 | }, 18 | "include": ["./src/**/*", "template"], 19 | "exclude": ["node_modules", "build", "tests"], 20 | "references": [ 21 | { 22 | "path": "../pontx-sdk-core/tsconfig.json" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-sdk-core", 3 | "version": "0.4.12", 4 | "description": "async await promise sdk oas2 oas3 swagger typescript ts pontx sdk plugin", 5 | "module": "lib/index.js", 6 | "main": "commonjs/index.js", 7 | "typings": "commonjs/index.d.ts", 8 | "scripts": { 9 | "pretest": "npm run build", 10 | "watch": "tsc --build --watch", 11 | "build:module": "tsc", 12 | "build:extra:watch": "tsc --outDir commonjs --module commonjs -w", 13 | "build:extra": "tsc --outDir commonjs --module commonjs", 14 | "release": "npm publish --registry https://registry.npmjs.org/", 15 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 16 | "build": "npm run clean && tsc --build" 17 | }, 18 | "files": [ 19 | "commonjs", 20 | "package.json", 21 | "builtin", 22 | "builtinSrc", 23 | "lib" 24 | ], 25 | "keywords": [], 26 | "author": "jasonHzq", 27 | "license": "MIT", 28 | "devDependencies": { 29 | "@types/fs-extra": "^9.0.13", 30 | "@types/node": "*", 31 | "http-server": "*", 32 | "pontx-generate": "^0.4.12", 33 | "pontx-generate-core": "^0.4.12", 34 | "pontx-spec": "^0.4.12", 35 | "react": "^18", 36 | "swr": "^2.2.5", 37 | "web-streams-nodejs": "^0.1.1" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/src/index.tsx: -------------------------------------------------------------------------------- 1 | export * from "./helper"; 2 | export * from "./requester"; 3 | export * from "./providers/base"; 4 | export * from "./providers/fetch"; 5 | export * from "./sdk"; 6 | export * from "./types"; 7 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/src/providers/fetch.ts: -------------------------------------------------------------------------------- 1 | import { HttpRequestConfig, PontxBaseRequester, PontxHttpRequester, defaultPontxRequester } from "../requester"; 2 | import { ApiMethodsProvider, CommonApiMethodsProvider } from "./base"; 3 | import { handleSseResponse } from "../sse/browser"; 4 | 5 | export class HttpApiMethodsProvider extends CommonApiMethodsProvider { 6 | pontxRequester = defaultPontxRequester as PontxHttpRequester; 7 | 8 | constructor(config?: HttpRequestConfig) { 9 | super(config); 10 | 11 | this.defaults.handleResponse = handleSseResponse; 12 | 13 | if (config?.securitySchemes) { 14 | this.pontxRequester = new PontxHttpRequester({ 15 | securitySchemes: config.securitySchemes, 16 | baseURL: config.baseURL, 17 | headers: config.headers, 18 | }); 19 | if (config?.accessToken) { 20 | this.pontxRequester.accessToken = config.accessToken; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/src/sdk.ts: -------------------------------------------------------------------------------- 1 | import { ApiMethodsProvider } from "./providers/base"; 2 | import { mapValues } from "./helper"; 3 | import { SpecMeta } from "./types"; 4 | 5 | export function createSDKClient( 6 | meta: SpecMeta, 7 | provider: Provider, 8 | ): APIs { 9 | let client = {} as any; 10 | provider.specMeta = meta; 11 | 12 | if (meta.hasController) { 13 | client = mapValues(meta.apis, (controller) => { 14 | return mapValues(controller, (action) => { 15 | return provider.getSDKMethods(action, meta); 16 | }); 17 | }); 18 | } else { 19 | client = mapValues(meta.apis, (action) => { 20 | return provider.getSDKMethods(action, meta); 21 | }); 22 | } 23 | 24 | return client; 25 | } 26 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/src/sse/type.ts: -------------------------------------------------------------------------------- 1 | export type OctetStreamResponse = Response & { 2 | getReader: () => ReadableStreamDefaultReader; 3 | readContent: () => Promise<{ 4 | done: boolean; 5 | /** 本次读取的新增文本 */ 6 | value: string; 7 | /** 截止本次读取的总文本 */ 8 | responseValue: string; 9 | }>; 10 | readLines: () => Promise<{ done: boolean; lines: APIResponse[] }>; 11 | }; 12 | 13 | export type SseEvent = { 14 | id: any; 15 | data: Data; 16 | event: string; 17 | }; 18 | 19 | export type EventStreamResponse = Response & { 20 | getReader: () => ReadableStreamDefaultReader; 21 | read: () => Promise<{ 22 | done: boolean; 23 | events: SseEvent[]; 24 | /** @deprecated */ 25 | value?: SseEvent; 26 | }>; 27 | body: ReadableStream; 28 | }; 29 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/src/type.d.ts: -------------------------------------------------------------------------------- 1 | type OptionalBodyRequest = BodyParams extends null | undefined 2 | ? (params: Params, options?: RequestInit) => Promise 3 | : (params: Params, options?: { body: BodyParams } & Omit) => Promise; 4 | 5 | export type RequestMethods = { 6 | request: OptionalBodyRequest; 7 | }; 8 | -------------------------------------------------------------------------------- /sdk/pontx-sdk-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "compilerOptions": { 4 | "module": "ES6", 5 | "target": "es6", 6 | "removeComments": true, 7 | "preserveConstEnums": true, 8 | "outDir": "lib", 9 | "moduleResolution": "node", 10 | "baseUrl": ".", 11 | "paths": {}, 12 | "rootDir": "./src", 13 | "composite": true 14 | }, 15 | "include": ["./src/**/*", "template"], 16 | "exclude": ["node_modules", "build", "tests"], 17 | "references": [ 18 | { 19 | "path": "../../packages/pontx-spec" 20 | }, 21 | { 22 | "path": "../../packages/pontx-manager" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /semix/semix-form/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /semix/semix-form/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-semix-form", 3 | "version": "0.4.12", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "dev": "vite", 9 | "watch": "tsc -w", 10 | "build": "tsc && npm run build:css", 11 | "build:css": "webpack --config ./webpack.css.js", 12 | "release": "npm run build && npm publish --registry //registry.npmjs.org" 13 | }, 14 | "files": [ 15 | "dist" 16 | ], 17 | "devDependencies": { 18 | "@vitejs/plugin-react": "^4.0.0", 19 | "fix-esm-import-path": "^1.5.0", 20 | "intl-format": "^1.2.0", 21 | "lodash": "^4.17.21", 22 | "node-cpio": "*", 23 | "re-resizable": "^6.9.9", 24 | "semix-core": "^0.0.9", 25 | "semix-validate": "^0.1.10", 26 | "typescript": "^5.0.2", 27 | "vite": "^4.4.5" 28 | }, 29 | "peerDependencies": { 30 | "lodash": "^4.17.21", 31 | "semix-core": "^0.0.9" 32 | }, 33 | "dependencies": { 34 | "@heroicons/react": "*", 35 | "flowbite-react": "0.6.4", 36 | "pontx-spec": "^0.4.12", 37 | "semix-validate": "^0.1.10", 38 | "unstated-next": "^1.1.0", 39 | "use-deep-compare": "^1.1.0" 40 | }, 41 | "keywords": [ 42 | "jsonschema" 43 | ], 44 | "author": "jasonHzq", 45 | "license": "MIT" 46 | } 47 | -------------------------------------------------------------------------------- /semix/semix-form/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /semix/semix-form/src/SemixForm.less: -------------------------------------------------------------------------------- 1 | .semix-form { 2 | &.row .semix-form-field, 3 | .semix-form-field.row { 4 | display: flex; 5 | flex-flow: row nowrap; 6 | } 7 | 8 | .semix-form-field.vertical { 9 | display: flex; 10 | flex-flow: row wrap; 11 | flex-wrap: nowrap; 12 | flex-direction: column; 13 | } 14 | 15 | .semix-form-field.vertical > .semix-form-title { 16 | flex-basis: 0; 17 | min-width: 150px; 18 | width: 150px; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /semix/semix-form/src/common/ErrorMessage.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author 3 | * @description 4 | */ 5 | import * as React from "react"; 6 | import { ErrorField, FormStoreContext } from "../context"; 7 | import { ERROR_MESSAGE_COMPONENT_TYPE, SemixUISchema } from "../type"; 8 | 9 | export class ErrorMessageProps { 10 | schema: SemixUISchema; 11 | dataPath: string; 12 | errorFields: ErrorField[]; 13 | } 14 | 15 | export const ErrorMessage: React.FC = (props) => { 16 | const { widgets } = FormStoreContext.useContainer(); 17 | const WidgetComponent = widgets[ERROR_MESSAGE_COMPONENT_TYPE]; 18 | 19 | if (WidgetComponent) { 20 | return React.createElement(WidgetComponent, { 21 | errorFields: props.errorFields, 22 | }); 23 | } 24 | 25 | if (props.errorFields?.length) { 26 | return {props.errorFields[0]?.message}; 27 | } 28 | return null; 29 | }; 30 | 31 | ErrorMessage.defaultProps = new ErrorMessageProps(); 32 | -------------------------------------------------------------------------------- /semix/semix-form/src/common/Field.less: -------------------------------------------------------------------------------- 1 | .semix-form-field { 2 | // margin-bottom: 8px; 3 | 4 | .semix-form-error { 5 | color: red; 6 | } 7 | 8 | .semix-form-widget-wrapper { 9 | flex: 1 1; 10 | text-align: left; 11 | height: 100%; 12 | align-items: center; 13 | } 14 | } 15 | 16 | .semix-form-widget { 17 | height: 100%; 18 | } 19 | 20 | .semix-form-object, 21 | .semix-form-list { 22 | position: relative; 23 | 24 | .child-list { 25 | padding-left: 12px; 26 | } 27 | 28 | // &::before { 29 | // content: ""; 30 | // display: block; 31 | // width: 3px; 32 | // height: 100%; 33 | // background-color: #ddd; 34 | // position: absolute; 35 | // top: 0; 36 | // bottom: 0; 37 | // left: 0; 38 | // } 39 | } 40 | -------------------------------------------------------------------------------- /semix/semix-form/src/common/Title.less: -------------------------------------------------------------------------------- 1 | .semix-form-title { 2 | line-height: 30px; 3 | position: relative; 4 | 5 | .title { 6 | font-size: 12px; 7 | font-weight: bold; 8 | color: #333; 9 | // margin-bottom: 10px; 10 | 11 | &.required { 12 | &::before { 13 | content: "*"; 14 | color: red; 15 | } 16 | } 17 | } 18 | 19 | .desc { 20 | font-size: 12px; 21 | color: #666; 22 | margin-left: 8px; 23 | } 24 | 25 | .pull-right { 26 | float: right; 27 | 28 | .op { 29 | margin-right: 8px; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /semix/semix-form/src/common/index.less: -------------------------------------------------------------------------------- 1 | @import "./Field.less"; 2 | @import "./Title.less"; 3 | -------------------------------------------------------------------------------- /semix/semix-form/src/common/index.tsx: -------------------------------------------------------------------------------- 1 | export { ErrorMessage, ErrorMessageProps } from "./ErrorMessage"; 2 | -------------------------------------------------------------------------------- /semix/semix-form/src/defaultWidgets.tsx: -------------------------------------------------------------------------------- 1 | import { flowbiteWidgets } from "./widgets/flowbite"; 2 | 3 | export const defaultWidgets = flowbiteWidgets; 4 | -------------------------------------------------------------------------------- /semix/semix-form/src/index.tsx: -------------------------------------------------------------------------------- 1 | import { ErrorField, FormStoreContext, FormStoreIntialState } from "./context"; 2 | import type { FormInstance } from "./context"; 3 | import { SemixForm, SemixFormProps } from "./SemixForm"; 4 | export * from "./type"; 5 | import { 6 | calcUiSchema, 7 | getSchemaPathByDataPath, 8 | getSchemaBySchemaPath, 9 | getSchemaByRef, 10 | getFieldClassName, 11 | } from "./utils"; 12 | export * from "./common/index"; 13 | 14 | export { 15 | SemixForm, 16 | ErrorField, 17 | FormInstance, 18 | FormStoreContext, 19 | FormStoreIntialState, 20 | SemixFormProps, 21 | calcUiSchema, 22 | getFieldClassName, 23 | getSchemaByRef, 24 | getSchemaBySchemaPath, 25 | getSchemaPathByDataPath, 26 | }; 27 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/amp_widgets.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "enum": { 3 | "pleaseEnterWord": "Please enter a string" 4 | }, 5 | "stringList": { 6 | "pleaseEnterWord": "Please enter a string" 7 | }, 8 | "list": { 9 | "add": "add", 10 | "delete": "delete", 11 | "copy": "copy" 12 | }, 13 | "map": { 14 | "add": "add", 15 | "delete": "delete", 16 | "copy": "copy", 17 | "pleaseEnterWord": "Please enter a string" 18 | }, 19 | "number": { 20 | "pleaseEnterTheNumber": "Please enter the number", 21 | "pleaseEnter": "Please enter", 22 | "integerDigit": "Integer digit", 23 | "floatingPointNumber": "Floating-point number" 24 | }, 25 | "swtich": { 26 | "shutDown": "Shut down", 27 | "open": "open" 28 | }, 29 | "string": { 30 | "pleaseEnterWord": "Please enter a string" 31 | } 32 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/apiDebugger.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "index": { 3 | "empty": "empty", 4 | "submissionFailure": "Submission failure. ", 5 | "submittedSuccessfully": "Submitted successfully", 6 | "submit": "submit", 7 | "lookOnlyAtRequired": "Look only at required", 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/api_change_detail.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "index": { 3 | "change": "Change ", 4 | "deLabel": "OpenAPI removed the deprecated flag", 5 | "addedMark": "OpenAPI added the deprecated flag", 6 | "returnParameter": "The return parameter structure has changed", 7 | "parameterStructure": "Parameter schema: ", 8 | "changeDetails": "Change details", 9 | "parameterPosition": "Parameter location:", 10 | "parameterExample": "Example parameters:", 11 | "no": "true ", 12 | "is": "false ", 13 | "isItRequired": "Required: ", 14 | "parameters": "Parameter: ", 15 | "after": "After:", 16 | "before": "Before:", 17 | "errorCodeSending": "The error code has changed. Procedure", 18 | "deleteError": "Delete error code", 19 | "errorCode": "Error code ", 20 | "delete": "Delete ", 21 | "add": "Add " 22 | } 23 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/api_change_group.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "index": { 3 | "noChange": "There is no change record", 4 | "thereIsNo": "There is no", 5 | "interfaceDescription": "Interface description:", 6 | ",": ",", 7 | "change": "change", 8 | "goOffline": "Go offline", 9 | "add": "add", 10 | "viewChanges2": "View change set", 11 | "viewChanges": "View API change history", 12 | "operation": "operation", 13 | "changeContent": "Change content summary", 14 | "changeTime": "Change time", 15 | "name": "OpenAPI name", 16 | "delete": "delete", 17 | "returnParameter": "response parameters", 18 | "requestParameter": "Request parameter ", 19 | "errorCode": "Error code " 20 | } 21 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/base.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "Widget": { 3 | "unknownType": "Unknown type" 4 | }, 5 | "context": { 6 | "required": 'field required', 7 | } 8 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/cases.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "complex": { 3 | "descriptionInformation": "Description information", 4 | "useInterface": "When using PutObject interface, if a parameter prefixed with **x-oss-meta-*** is configured, the parameter is regarded as metadata." 5 | }, 6 | "simple": { 7 | "representativeCreation": "A resource property field that represents the time of creation", 8 | "creationTime": "Creation time", 9 | "representativeResource3": "A resource property field that represents the level 1 ID of the resource", 10 | "resourceLevel1": "Resource level ID", 11 | "representativeResource2": "A resource property field that represents the resource name", 12 | "resourceName": "Resource name", 13 | "representativeResource": "A resource property field that represents a resource group", 14 | "resourceGroup": "Resource group ID", 15 | "serveAsAGuarantee": "Used to ensure that the request is idempotent. This parameter value is generated by the client to ensure that it is unique across requests. The value contains only ASCII characters and a maximum of 64 characters" 16 | } 17 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/extErrorMapping.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "index": { 3 | "submit": "submit", 4 | "pleaseEnterTheVerdict": "Please enter the criteria", 5 | "actualReturn": "The actual http status code returned", 6 | "accordingToInterface": "According to the actual http status code returned by the interface, to determine whether the call is wrong. The gateway checks the http status code first. If the http status code is correct, the gateway checks whether the HTTP status code is incorrect.", 7 | "statusCodeJudgment": "http status code criteria", 8 | "pleaseEnterWord": "Please enter the response field path", 9 | "wrongOrNot": "Whether the condition is incorrectly judged", 10 | "errorMessage": "Name of the error message field", 11 | "errorCodeWord": "Error code field name", 12 | "thisConfigurationIsNot": "This configuration does not affect the results returned by the API runtime and is used only to extract the correct error information from the gateway log.", 13 | "bypassError": "Bypass error information mapping" 14 | } 15 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/index.ts: -------------------------------------------------------------------------------- 1 | import amp_widgets from "./amp_widgets"; 2 | import jsonschema_form from "./jsonschema_form"; 3 | import extErrorMapping from "./extErrorMapping"; 4 | import apiDebugger from "./apiDebugger"; 5 | import api_change_detail from "./api_change_detail"; 6 | import api_change_group from "./api_change_group"; 7 | import base from "./base"; 8 | import cases from "./cases"; 9 | import utils from "./utils"; 10 | import workbench_widgets from "./workbench_widgets"; 11 | 12 | export default { 13 | amp_widgets, 14 | jsonschema_form, 15 | api_change_detail, 16 | api_change_group, 17 | base, 18 | cases, 19 | utils, 20 | workbench_widgets, 21 | extErrorMapping, 22 | apiDebugger, 23 | }; 24 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/jsonschema_form.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | utils: { 3 | patternNotMatched: "The regular expression check fails: {val1}", 4 | notInEnums: "Not in enumeration value range", 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/utils.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "goOffline": "Go offline", 3 | "add": "add", 4 | "period": "。", 5 | "comma": ",", 6 | "colon": ":" 7 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/en_US/workbench_widgets.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "any": { 3 | "parameterValue": "The value of this parameter is any. During debugging, select the parameter type and enter the parameter value.", 4 | "parameterType": "Parameter type" 5 | }, 6 | "UploadFile": { 7 | "clickUpload": "Click upload", 8 | "reupload": "reupload", 9 | "notSupportedAtPresent": "Uploading files larger than 50M is currently not supported!" 10 | }, 11 | "simpleList": { 12 | "add": "add" 13 | }, 14 | "enum": { 15 | "pleaseEnterWord": "Please enter a string" 16 | }, 17 | "number": { 18 | "pleaseEnterTheNumber": "Please enter the number", 19 | "pleaseEnter": "Please enter", 20 | "integerDigit": "Integer digit", 21 | "floatingPointNumber": "Floating-point number" 22 | }, 23 | "string": { 24 | "pleaseEnterWord": "Please enter a string", 25 | "convertTo": "Converted to Input, line breaks are lost after conversion" 26 | }, 27 | "map": { 28 | "add": "add", 29 | "delete": "delete", 30 | "copy": "copy", 31 | "pleaseEnterWord": "Please enter a string" 32 | }, 33 | "stringList": { 34 | "pleaseEnterWord": "Please enter a string" 35 | }, 36 | "swtich": { 37 | "shutDown": "Shut down", 38 | "open": "open" 39 | } 40 | } -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/amp_widgets.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | enum: { 3 | pleaseEnterWord: '请输入字符串', 4 | }, 5 | stringList: { 6 | pleaseEnterWord: '请输入字符串', 7 | }, 8 | list: { 9 | add: '添加', 10 | delete: '删除', 11 | copy: '复制', 12 | }, 13 | map: { 14 | add: '添加', 15 | delete: '删除', 16 | copy: '复制', 17 | pleaseEnterWord: '请输入字符串', 18 | }, 19 | number: { 20 | pleaseEnterTheNumber: '请输入数字', 21 | pleaseEnter: '请输入', 22 | integerDigit: '整型数字', 23 | floatingPointNumber: '浮点数字', 24 | }, 25 | swtich: { 26 | shutDown: '关闭', 27 | open: '开启', 28 | }, 29 | string: { 30 | pleaseEnterWord: '请输入字符串', 31 | }, 32 | }; 33 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/apiDebugger.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | "index": { 3 | "empty": "清空", 4 | "submissionFailure": "提交失败。", 5 | "submittedSuccessfully": "提交成功", 6 | "submit": "提交", 7 | "lookOnlyAtRequired": "只看必填", 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/api_change_detail.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | index: { 3 | change: '变更', 4 | deLabel: 'OpenAPI 去除了 deprecated 标记', 5 | addedMark: 'OpenAPI 添加了 deprecated 标记', 6 | returnParameter: '返回参数结构发生变更', 7 | parameterStructure: '参数结构:', 8 | changeDetails: '变更详情', 9 | parameterPosition: '参数位置:', 10 | parameterExample: '参数示例:', 11 | no: '否', 12 | is: '是', 13 | isItRequired: '是否必填:', 14 | parameters: '参数:', 15 | after: '后:', 16 | before: '前:', 17 | errorCodeSending: '错误码发生变更', 18 | deleteError: '删除错误码', 19 | errorCode: '错误码', 20 | delete: '删除', 21 | add: '新增', 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/api_change_group.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | index: { 3 | noChange: '暂无变更记录', 4 | thereIsNo: '无', 5 | interfaceDescription: '接口描述:', 6 | ',': ',', 7 | change: '变更', 8 | goOffline: '下线', 9 | add: '新增', 10 | viewChanges2: '查看变更集', 11 | viewChanges: '查看API变更历史', 12 | operation: '操作', 13 | changeContent: '变更内容概要', 14 | changeTime: '变更时间', 15 | name: 'OpenAPI 名称', 16 | delete: '删除', 17 | returnParameter: '返回参数', 18 | requestParameter: '请求参数', 19 | errorCode: '错误码', 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/base.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | Widget: { 3 | unknownType: '未知类型', 4 | }, 5 | context: { 6 | required: '字段必填', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/cases.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | complex: { 3 | descriptionInformation: '描述信息', 4 | useInterface: 5 | '使用PutObject接口时,如果配置以**x-oss-meta-***为前缀的参数,则该参数视为元数据,', 6 | }, 7 | simple: { 8 | representativeCreation: '代表创建时间的资源属性字段', 9 | creationTime: '创建时间', 10 | representativeResource3: '代表资源一级ID的资源属性字段', 11 | resourceLevel1: '资源一级ID', 12 | representativeResource2: '代表资源名称的资源属性字段', 13 | resourceName: '资源名称', 14 | representativeResource: '代表资源组的资源属性字段', 15 | resourceGroup: '资源组ID', 16 | serveAsAGuarantee: 17 | '用于保证请求的幂等性。由客户端生成该参数值,要保证在不同请求间唯一。只支持 ASCII 字符,且不能超过 64 个字符', 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/extErrorMapping.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | index: { 3 | submit: '提交', 4 | pleaseEnterTheVerdict: '请输入判断条件', 5 | actualReturn: '实际返回的http状态码', 6 | accordingToInterface: 7 | '根据接口实际返回的 http 状态码,来进行本次调用是否错误的判断。网关优先对 http 状态码,如果http状态码返回正确,再通过“是否错误判断条件”进行判断。', 8 | statusCodeJudgment: 'http状态码判断条件', 9 | pleaseEnterWord: '请输入response字段路径', 10 | wrongOrNot: '是否错误判断条件', 11 | errorMessage: '错误信息字段名称', 12 | errorCodeWord: '错误码字段名称', 13 | thisConfigurationIsNot: 14 | '该配置不影响API运行时返回结果,仅用于在网关日志中提取正确的错误信息。', 15 | bypassError: '旁路错误信息映射', 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/index.ts: -------------------------------------------------------------------------------- 1 | import amp_widgets from "./amp_widgets"; 2 | import jsonschema_form from './jsonschema_form'; 3 | import extErrorMapping from "./extErrorMapping"; 4 | import apiDebugger from "./apiDebugger"; 5 | import api_change_detail from "./api_change_detail"; 6 | import api_change_group from "./api_change_group"; 7 | import base from "./base"; 8 | import cases from "./cases"; 9 | import utils from "./utils"; 10 | import workbench_widgets from "./workbench_widgets"; 11 | 12 | export default { 13 | amp_widgets, 14 | api_change_detail, 15 | api_change_group, 16 | base, 17 | cases, 18 | utils, 19 | workbench_widgets, 20 | extErrorMapping, 21 | apiDebugger, 22 | jsonschema_form, 23 | }; 24 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/jsonschema_form.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | utils: { 3 | patternNotMatched: "不符合正则表达式: {val1}", 4 | notInEnums: "取值范围只能是: {val1}", 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/utils.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | goOffline: "下线", 3 | add: "新增", 4 | period: "。", 5 | comma: ",", 6 | colon: ":", 7 | }; 8 | -------------------------------------------------------------------------------- /semix/semix-form/src/langs/zh_CN/workbench_widgets.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | any: { 3 | parameterValue: 4 | '该参数值为 any 类型,调试时请先选择参数类型,再输入参数值。', 5 | parameterType: '参数类型', 6 | }, 7 | UploadFile: { 8 | clickUpload: '点击上传', 9 | reupload: '重新上传', 10 | notSupportedAtPresent: '暂不支持上传超过50M的文件哦!', 11 | }, 12 | simpleList: { 13 | add: '添加', 14 | }, 15 | enum: { 16 | pleaseEnterWord: '请输入字符串', 17 | }, 18 | number: { 19 | pleaseEnterTheNumber: '请输入数字', 20 | pleaseEnter: '请输入', 21 | integerDigit: '整型数字', 22 | floatingPointNumber: '浮点数字', 23 | }, 24 | string: { 25 | pleaseEnterWord: '请输入字符串', 26 | convertTo: '转换为 Input,转换后将丢失换行符', 27 | }, 28 | map: { 29 | add: '添加', 30 | delete: '删除', 31 | copy: '复制', 32 | pleaseEnterWord: '请输入字符串', 33 | }, 34 | stringList: { 35 | pleaseEnterWord: '请输入字符串', 36 | }, 37 | swtich: { 38 | shutDown: '关闭', 39 | open: '开启', 40 | }, 41 | }; 42 | -------------------------------------------------------------------------------- /semix/semix-form/src/styles.less: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | @import "./SemixForm.less"; 5 | @import "./common/index.less"; 6 | @import "./widgets/flowbite/index.less"; 7 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/Card.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author 3 | * @description 4 | */ 5 | import * as React from "react"; 6 | 7 | export class SemixCardProps { 8 | children?: any; 9 | } 10 | 11 | export const SemixCard: React.FC = (props) => { 12 | return
{props.children}
; 13 | }; 14 | 15 | SemixCard.defaultProps = new SemixCardProps(); 16 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/Title.less: -------------------------------------------------------------------------------- 1 | .semix-form-title { 2 | line-height: 30px; 3 | position: relative; 4 | text-align: right; 5 | 6 | .title { 7 | &.required { 8 | &::before { 9 | display: inline-block; 10 | margin-right: 4px; 11 | color: #ff4d4f; 12 | font-size: 14px; 13 | line-height: 1; 14 | content: "*"; 15 | } 16 | } 17 | } 18 | 19 | .title { 20 | font-size: 12px; 21 | color: #1a1a1a; 22 | font-weight: normal; 23 | display: inline-flex; 24 | align-items: center; 25 | } 26 | 27 | .desc { 28 | font-size: 12px; 29 | color: #666; 30 | margin-left: 8px; 31 | } 32 | 33 | .pull-right { 34 | float: right; 35 | 36 | .op { 37 | margin-right: 8px; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/enum.less: -------------------------------------------------------------------------------- 1 | .semix-enum-item { 2 | position: relative; 3 | &:hover .input-emptystring-button { 4 | display: block; 5 | } 6 | .input-emptystring-button { 7 | position: absolute; 8 | bottom: 16px; 9 | left: 160px; 10 | left: 156px; 11 | z-index: 99; 12 | display: none; 13 | font-size: 12px; 14 | } 15 | .clear-emptystring-button { 16 | position: absolute; 17 | bottom: 16px; 18 | left: 160px; 19 | left: 156px; 20 | z-index: 99; 21 | display: block; 22 | font-size: 12px; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/index.less: -------------------------------------------------------------------------------- 1 | @import "./enum.less"; 2 | @import "./list.less"; 3 | @import "./string.less"; 4 | @import "./radio.less"; 5 | @import "./Title.less"; 6 | 7 | .semix-complex-type-item { 8 | .item-treenode-style { 9 | margin-left: -23px; 10 | } 11 | .array-delete-icon { 12 | margin: 0 5px; 13 | } 14 | .op { 15 | margin-right: 8px; 16 | } 17 | } 18 | 19 | .semix-form { 20 | .semix-form-field { 21 | display: flex; 22 | margin-bottom: 12px; 23 | text-align: right; 24 | } 25 | 26 | .semix-form-title { 27 | flex: 0 0 150px; 28 | margin-right: 10px; 29 | 30 | &::after { 31 | content: ":"; 32 | position: relative; 33 | top: -0.5px; 34 | margin: 0 8px 0 2px; 35 | } 36 | } 37 | .semix-form-widget { 38 | text-align: left; 39 | min-height: 30px; 40 | display: inline-flex; 41 | align-items: center; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @description 门户组件 3 | * 1、用于api-design-form 4 | * 2、用于api-debugger 5 | */ 6 | 7 | import { String } from "./string"; 8 | import { BooleanSwitch } from "./swtich"; 9 | import { NumberInput } from "./number"; 10 | import { SimpleList } from "./list"; 11 | import { EnumSelect } from "./enum"; 12 | import { SimpleMap } from "./map"; 13 | import { RenderObject } from "./Object"; 14 | import { RadioGroup } from "./radio"; 15 | import { CheckboxGroup } from "./checkbox"; 16 | import { Title } from "./Title"; 17 | import { StringList } from "./stringList"; 18 | 19 | export const flowbiteWidgets = { 20 | object: RenderObject, 21 | radio: RadioGroup, 22 | string: String, 23 | stringList: StringList, 24 | checkbox: CheckboxGroup, 25 | booleanSwitch: BooleanSwitch, 26 | number: NumberInput, 27 | integer: NumberInput, 28 | enum: EnumSelect, 29 | simpleMap: SimpleMap, 30 | list: SimpleList, 31 | title: Title, 32 | }; 33 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/list.less: -------------------------------------------------------------------------------- 1 | .semix-form-list { 2 | .list-item { 3 | position: relative; 4 | padding: 5px; 5 | .title-operator { 6 | position: absolute; 7 | top: 0; 8 | right: 0; 9 | z-index: 999; 10 | } 11 | 12 | .op { 13 | margin-right: 8px; 14 | text-decoration: none; 15 | } 16 | .key-item { 17 | background-color: aqua; 18 | .right-outlined { 19 | display: none !important; 20 | } 21 | } 22 | } 23 | // .list-item:hover { 24 | // background-color: #f7f7f7; 25 | // } 26 | } 27 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/radio.less: -------------------------------------------------------------------------------- 1 | .semix-form-widget.radio { 2 | .next-radio-wrapper { 3 | white-space: pre; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /semix/semix-form/src/widgets/flowbite/swtich.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { CommonWidgetProps } from "../../type"; 3 | import { ToggleSwitch } from "flowbite-react"; 4 | 5 | export class BooleanSwitchProps extends CommonWidgetProps {} 6 | 7 | export const BooleanSwitch: React.FC = (props) => { 8 | const { schema, ...rest } = props; 9 | 10 | let switchDefault = props?.schema?.default; 11 | 12 | if (typeof switchDefault === "string") { 13 | switchDefault = switchDefault === "true"; 14 | } 15 | 16 | return ( 17 |
18 | { 23 | props.onChange(value); 24 | }} 25 | /> 26 |
27 | ); 28 | }; 29 | 30 | BooleanSwitch.defaultProps = new BooleanSwitchProps(); 31 | -------------------------------------------------------------------------------- /semix/semix-form/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | 3 | export default { 4 | content: [ 5 | "src/*.tsx", 6 | "node_modules/flowbite-react/lib/esm/**/*.js", 7 | "../../node_modules/flowbite-react/lib/esm/**/*.js", 8 | ], 9 | theme: { 10 | extend: {}, 11 | }, 12 | plugins: [require("flowbite/plugin")], 13 | }; 14 | -------------------------------------------------------------------------------- /semix/semix-form/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.build.json", 3 | "include": ["./src/"], 4 | "compilerOptions": { 5 | "outDir": "./dist", 6 | "rootDir": "./src", 7 | "strict": false, 8 | "jsx": "react", 9 | "lib": ["ES2017", "ESNext", "DOM"], 10 | "moduleResolution": "node", 11 | "composite": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /semix/semix-form/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | optimizeDeps: { 8 | // exclude: ["load-script"], 9 | }, 10 | }); 11 | -------------------------------------------------------------------------------- /semix/semix-rule-center/README.md: -------------------------------------------------------------------------------- 1 | # `semix-rule-center` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | 9 | // TODO: DEMONSTRATE API 10 | ``` 11 | -------------------------------------------------------------------------------- /semix/semix-rule-center/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pontx-semix-rule-center", 3 | "version": "0.4.12", 4 | "homepage": "", 5 | "license": "MIT", 6 | "main": "./dist/index.js", 7 | "types": "./dist/index.d.ts", 8 | "files": [ 9 | "dist" 10 | ], 11 | "repository": { 12 | "type": "git" 13 | }, 14 | "scripts": { 15 | "dev": "vite", 16 | "start": "tsc -w", 17 | "clean:js": "rm src/*.js", 18 | "build": "tsc && npm run less", 19 | "less": "node-cpio --src src --dist dist -e less", 20 | "postpublish": "tnpm sync semix-rule-center" 21 | }, 22 | "dependencies": { 23 | "react-diff-viewer": "^3.1.1", 24 | "react-window": "^1.8.6", 25 | "semix-rule-lint": "*", 26 | "semix-validate": "*" 27 | }, 28 | "devDependencies": { 29 | "@types/classnames": "*", 30 | "@types/react": "*", 31 | "@types/react-dom": "*", 32 | "@types/react-window": "*", 33 | "copyfiles": "^2.4.1", 34 | "lodash": "*" 35 | }, 36 | "peerDependencies": { 37 | "classnames": "^2.3.1", 38 | "lodash": "*" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /semix/semix-rule-center/src/LintButton.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { SwitchButton } from "./SwitchButton"; 3 | 4 | export class LintButtonProps { 5 | checked? = false; 6 | onClick() {} 7 | errorCnt = 0; 8 | warningCnt = 0; 9 | warningIcon = null; 10 | errorIcon = null; 11 | } 12 | 13 | export const LintButton: React.FC = (props) => { 14 | const [checked, setChecked] = React.useState(props.checked); 15 | 16 | return ( 17 | { 20 | setChecked(!checked); 21 | props.onClick(); 22 | }} 23 | checked={checked} 24 | > 25 | {props.errorIcon} 26 | {props.errorCnt} 27 | {props.warningIcon} 28 | {props.warningCnt} 29 | 30 | ); 31 | }; 32 | 33 | LintButton.defaultProps = new LintButtonProps(); 34 | -------------------------------------------------------------------------------- /semix/semix-rule-center/src/SwitchButton.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author 3 | * @description 4 | */ 5 | 6 | import classNames from "classnames"; 7 | import * as React from "react"; 8 | 9 | export class SwitchButtonProps { 10 | checked = false; 11 | onClick() {} 12 | className?: string; 13 | children: any; 14 | disabled?: boolean; 15 | } 16 | 17 | export const SwitchButton: React.FC = (props) => { 18 | const { checked, onClick, className, ...rest } = props; 19 | const cx = classNames(className, "semix-switch-button", { 20 | active: props.checked, 21 | disabled: props.disabled, 22 | }); 23 | 24 | return ( 25 | 28 | ); 29 | }; 30 | 31 | SwitchButton.defaultProps = new SwitchButtonProps(); 32 | -------------------------------------------------------------------------------- /semix/semix-rule-center/src/types.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/semix/semix-rule-center/src/types.ts -------------------------------------------------------------------------------- /semix/semix-rule-center/src/utils.tsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pontjs/pontx/9c9496f7c0878dd3f5d39ace1446d4e6dc6d3fea/semix/semix-rule-center/src/utils.tsx -------------------------------------------------------------------------------- /semix/semix-rule-center/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // "extends": "../../../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "jsx": "react", 6 | "rootDir": "./src", 7 | "declaration": true, 8 | "declarationDir": "./dist", 9 | "lib": ["ES2017"], 10 | "skipDefaultLibCheck": true, 11 | "composite": true, 12 | "module": "ES2015", 13 | "allowSyntheticDefaultImports": true, 14 | "moduleResolution": "node", 15 | "skipLibCheck": true 16 | }, 17 | "include": ["./src"], 18 | "exclude": ["./node_modules/"] 19 | } 20 | -------------------------------------------------------------------------------- /tests/configs/multiple-origins-pontx-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "outDir": "../apis", 3 | "plugins": { 4 | "fetch": "../../plugins/fetch/pontx-meta-fetch-plugin", 5 | "parser": "../../plugins/parser/pontx-oas2-parser-plugin", 6 | "generate": "../../plugins/generate/pontx-react-hooks-generate-plugin" 7 | }, 8 | "origins": [ 9 | { 10 | "url": "http://127.0.0.1:9099/oas2.json", 11 | "name": "api1" 12 | }, 13 | { 14 | "url": "http://127.0.0.1:9099/oas2.json", 15 | "name": "api2" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./lib", 4 | "declaration": true, 5 | "declarationMap": true, 6 | "jsx": "react", 7 | "sourceMap": true, 8 | "strict": false, 9 | "module": "esnext", 10 | "noImplicitAny": false, 11 | "experimentalDecorators": true, 12 | "emitDecoratorMetadata": true, 13 | "removeComments": true, 14 | "strictNullChecks": false, 15 | "strictFunctionTypes": false, 16 | "strictPropertyInitialization": false, 17 | "strictBindCallApply": false, 18 | "preserveConstEnums": true, 19 | "allowSyntheticDefaultImports": true, 20 | "esModuleInterop": true, 21 | "skipLibCheck": true, 22 | "skipDefaultLibCheck": true, 23 | "lib": ["dom", "es6", "es2017", "dom.iterable", "scripthost"], 24 | "forceConsistentCasingInFileNames": true 25 | } 26 | } 27 | --------------------------------------------------------------------------------