Coder Social home page Coder Social logo

jsii-struct-builder's People

Contributors

abdsahin avatar aminfazlmondo avatar blimmer avatar bradenm avatar gradybarrett avatar lexgpt avatar mrgrain avatar projen-builder[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jsii-struct-builder's Issues

Struct contains deprecated props

Should have a withoutDeprecated() helper to remove all deprecated.
Also might be worth adding a generic filter method that can be used for any kind of omits.

feat: support partial implementation

First of all, this is fantastic. ๐Ÿ‘ ๐Ÿš€

I started messing around with this when it was the first iteration (before the rename), and I could have sworn that the first cut supported implementing a jsii interface as a TS Partial - make every property optional. I can't seem to get that same behavior with this new version. Have I just officially lost it, or did that behavior get dropped in the transition?

Here's an example of what I'm doing right now:

new ProjenStruct(project, { name: "TokenAuthorizerProps" })
  .mixin(Struct.fromFqn("aws-cdk-lib.aws_apigateway.TokenAuthorizerProps"))
  .withoutDeprecated();

And I'd like that produced interface to have all mixed-in properties as optional.

Remove `default` from docstring when updating prop to be required

For example:

requiredNodejsProps.mixin(
  Struct.fromFqn("aws-cdk-lib.aws_lambda_nodejs.NodejsFunctionProps")
    .withoutDeprecated()
    .update("description", { optional: false })
);

Leaves the docstring in the produced code:

/**
 * A description of the function.
 * @default - No description.
 * @stability stable
 */
readonly description: string;

If optional: false, I think we could assume this (docs param):

requiredNodejsProps.mixin(
  Struct.fromFqn("aws-cdk-lib.aws_lambda_nodejs.NodejsFunctionProps")
    .withoutDeprecated()
    .update("description", { optional: false, docs: { default: undefined } })
);

Bug: annotations getting excluded

I upgrade the package to the newest version 0.4.11 and the generated structs have annotations missing from projen struct mixins.

Left is generated with the 0.4.11 version right is the 0.3.1 version
Screenshot 2023-07-12 at 13 41 05
Screenshot 2023-07-12 at 13 41 23

No changes made any changes to the underlying ProjenStruct

Docs: how to mixin from local file?

Hi, thanks so much for this library! Has really helped cdk-nextjs offer a flexible/customizable L3 construct to deploy Next.js on AWS.

Given the example from the docs:

new ProjenStruct(project, { name: 'MyProjectOptions' })
  .mixin(Struct.fromFqn('projen.typescript.TypeScriptProjectOptions'))
  .omit('sampleCode', 'projenrcTs', 'projenrcTsOptions');

How could I adjust this example to create a new interface from a local file like:

new ProjenStruct(project, { name: 'MyProjectOptions' })
  .mixin(Struct.fromLocal('./my/file/path/TypeScriptProjectOptions.ts'))
  .omit('sampleCode', 'projenrcTs', 'projenrcTsOptions');

Bug: mixin sets every property as experimental

Hello, First of love the library. Overriding projen properties is/was a pain point of ours. We set the new default properties by hand and even enforce some but having it reflected in the generated docs is hard. With this library it's easy thanks for that.

Using it however I think I found a bug as every property in the generated Struct has the @stability experimental doc annotation attached to it.

Using this code I'm trying to generate a new Struct extending from projen.typescript.TypeScriptProjectOptions.

export class NodeLibraryBlocProjenOptions extends ProjenStruct {
    constructor(project: typescript.TypeScriptProject, options?: ProjenStructOptions) {
        const defaultOptions: ProjenStructOptions = {
            name: 'NodeLibraryProjenOptions',
            filePath: './src/blocs/node-library/node-library.projen-options.ts',
        };
        super(project, { ...defaultOptions, ...options });
        this.mixin(Struct.fromFqn('projen.typescript.TypeScriptProjectOptions'));
    }
}

This generates this Struct and every property now has the @stability experimental tag.

/**
 * NodeLibraryProjenOptions
 */
export interface NodeLibraryProjenOptions {
    /**
     * TypeScript version to use.
     * NOTE: Typescript is not semantically versioned and should remain on the
     * same minor, so we recommend using a `~` dependency (e.g. `~1.2.3`).
     * @default "latest"
     * @stability experimental
     */
    readonly typescriptVersion?: string;
    /**
     * The name of the development tsconfig.json file.
     * @default "tsconfig.dev.json"
     * @stability experimental
     */
    readonly tsconfigDevFile?: string;
    /**
     * Custom tsconfig options for the development tsconfig.json file (used for testing).
     * @default - use the production tsconfig options
     * @stability experimental
     */
    readonly tsconfigDev?: javascript.TypescriptConfigOptions;
    /**
     * Custom TSConfig.
     * @default - default options
     * @stability experimental
     */
    readonly tsconfig?: javascript.TypescriptConfigOptions;

I can remove it for individual properties by manually setting the stability to undefined in an update function.

Cannot load structs from current module

Hi, thank you for your recommendation, to try your module.
After playing around I found out, that loading a struct from current module instead of external dependency is not working.
Now I open (as wished) an issue. Here is my error output just in case.

new ProjenStruct(gcixProject, { name: 'ArtifactsReportType', filePath: 'src/core/artifactsreport.ts' })
  .mixin(Struct.fromFqn('gcix.ArtifactsReport'));

The struct I want to load is in src/core/artifacts.ts, the .jsii is inside my root directory. I looked the Fqn up from inside the .jssi file. But all I get is:

Error: Cannot find module 'gcix/.jsii'
Require stack:
- $HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/private/assembly.js
- $HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/private/index.js
- $HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/builder/struct.js
- $HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/builder/index.js
- $HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/index.js
- $HOME_DIR/.projenrc.ts
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] ($HOME_DIR/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
    at Function.resolve (node:internal/modules/cjs/helpers:116:19)
    at assemblyPath ($HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/src/private/assembly.ts:15:31)
    at loadAssembly ($HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/src/private/assembly.ts:20:44)
    at loadInterface ($HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/src/private/assembly.ts:27:15)
    at findInterface ($HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/src/private/assembly.ts:46:16)
    at Function.fromFqn ($HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/src/builder/struct.ts:113:33)
    at Object.<anonymous> ($HOME_DIR/.projenrc.ts:49:118)
    at Module._compile (node:internal/modules/cjs/loader:1256:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '$HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/private/assembly.js',
    '$HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/private/index.js',
    '$HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/builder/struct.js',
    '$HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/builder/index.js',
    '$HOME_DIR/node_modules/@mrgrain/jsii-struct-builder/lib/index.js',
    '$HOME_DIR/.projenrc.ts'
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.