Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@pentops/jsonapi-jdef-ts-generator
Advanced tools
Generate types from an api.json file served by your pentops j5 registry.
Generate types and API client functionality from a api.json
file served by your registry.
Install @pentops/jsonapi-jdef-ts-generator
as a dev dependency and @pentops/jsonapi-request
as a dependency (if you are going to use the generated API client).
Create a .jdef_config.js
file in your project root. This file should default export a configuration object:
const EXCLUDED_NAMESPACES = ['service', 'topic'];
export default {
typeOutput: {
fileName: 'index.ts',
directory: './packages/types/generated',
importPath: '@yourcompany/types',
},
clientOutput: {
fileName: 'index.ts',
directory: './packages/api-client/generated',
},
client: {
// Remove the excluded namespaces from the method name and camelCase the result
methodNameWriter: (method) =>
method.fullGrpcName
.split(/[./]/)
.filter((s) => s && !EXCLUDED_NAMESPACES.includes(s.toLowerCase()))
.map((s, i) => (i === 0 ? s : s[0].toUpperCase() + s.slice(1)))
.join(''),
},
types: {
enumType: 'enum',
// Remove the excluded namespaces from the interface/enum name and camelCase the result
nameWriter: (x) =>
x
.split('.')
.filter((s) => s && !EXCLUDED_NAMESPACES.includes(s.toLowerCase()))
.map((s) => s?.[0]?.toUpperCase() + s?.slice(1))
.join(''),
},
jsonSource: {
path: 'api.json',
},
};
You can specify the source of the api.json file using the jsonSource
property.
path
property should be the path to a local api.json
file.service
property should be set for a remote api.json
file. It should be an object with the following properties:
url
: The URL of the remote api.json
file.auth
: An optional object containing a token
if required.See the configuration definitions for more information.
Add a script to your package.json
to run the generator.
{
"scripts": {
"generate-types": "jdef-ts-generator"
}
}
You will need to have @pentops/jsonapi-request
installed as a dependency if you're going to use the generated API client.
FAQs
Generate types from an api.json file served by your pentops j5 registry.
We found that @pentops/jsonapi-jdef-ts-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.