New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mrgrain/jsii-struct-builder

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mrgrain/jsii-struct-builder - npm Package Compare versions

Comparing version 0.4.4 to 0.4.5

8

package.json

@@ -50,5 +50,5 @@ {

"prettier": "^2.8.8",
"projen": "^0.71.80",
"projen": "^0.71.118",
"standard-version": "^9",
"ts-jest": "^29.1.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",

@@ -61,3 +61,3 @@ "typescript": "^4.9.5"

"dependencies": {
"@jsii/spec": "^1.82.0",
"@jsii/spec": "^1.84.0",
"@ungap/structured-clone": "~1.0.0"

@@ -71,3 +71,3 @@ },

},
"version": "0.4.4",
"version": "0.4.5",
"jest": {

@@ -74,0 +74,0 @@ "testMatch": [

@@ -20,2 +20,7 @@ # jsii-struct-builder

Then add a `new ProjenStruct` in your `.projenrc.ts` file, passing a [TypeScript project](https://projen.io/typescript.html) as the first parameter.
See the sections below for more usage details.
If you're not using [`projen`](https://projen.io/), see [Use without `projen`](#use-without-projen).
### Create from an existing Struct

@@ -27,3 +32,3 @@

```ts
new ProjenStruct(project, { name: 'MyProjectOptions'})
new ProjenStruct(project, { name: 'MyProjectOptions' })
.mixin(Struct.fromFqn('projen.typescript.TypeScriptProjectOptions'))

@@ -40,3 +45,3 @@ .omit('sampleCode', 'projenrcTs', 'projenrcTsOptions');

```ts
new ProjenStruct(project, { name: 'MyProjectOptions'})
new ProjenStruct(project, { name: 'MyProjectOptions' })
.mixin(Struct.fromFqn('projen.typescript.TypeScriptProjectOptions'))

@@ -46,7 +51,7 @@ .add(

name: 'booleanSetting',
type: { primitive: jsii.PrimitiveType.Boolean }
type: { primitive: jsii.PrimitiveType.Boolean },
},
{
name: 'complexSetting',
type: { fqn: "my_project.SomeEnum" }
type: { fqn: 'my_project.SomeEnum' },
}

@@ -97,3 +102,3 @@ );

```ts
new ProjenStruct(project, { name: 'MyProjectOptions'})
new ProjenStruct(project, { name: 'MyProjectOptions' })
.mixin(Struct.fromFqn('projen.typescript.TypeScriptProjectOptions'))

@@ -112,2 +117,50 @@

### AWS CDK properties
A common use-case of this project is to expose arbitrary overrides in CDK constructs.
For example, you may want to provide common AWS Lambda configuration, but allow a consuming user to override any arbitrary property.
To accomplish this, first create the new struct in your `.projenrc.ts` file.
```ts
import { ProjenStruct, Struct } from '@mrgrain/jsii-struct-builder';
import { awscdk } from 'projen';
const project = new awscdk.AwsCdkConstructLibrary({
// your config - see https://projen.io/awscdk-construct.html
});
new ProjenStruct(project, { name: 'MyFunctionProps' })
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.FunctionProps'))
.withoutDeprecated()
.allOptional()
.omit('code'); // our construct always provides the code
```
Then use the new struct in your CDK construct.
```ts
// lib/MyFunction.ts
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
import { Construct } from 'constructs';
import { join } from 'path';
import { MyFunctionProps } from './MyFunctionProps';
export class MyFunction extends Construct {
constructor(scope: Construct, id: string, props: MyFunctionProps = {}) {
super(scope, id);
new Function(this, 'Function', {
// sensible defaults
runtime: Runtime.NODEJS_18_X,
handler: 'index.handler',
// user provided props
...props,
// always force `code` from our construct
code: Code.fromAsset(join(__dirname, 'lambda-handler')),
});
}
}
```
### Use without projen

@@ -119,8 +172,8 @@

```ts
const myProps = Struct.empty("@my-scope/my-pkg.MyFunctionProps")
.mixin(Struct.fromFqn("aws-cdk-lib.aws_lambda.FunctionProps"))
const myProps = Struct.empty('@my-scope/my-pkg.MyFunctionProps')
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.FunctionProps'))
.withoutDeprecated();
const renderer = new TypeScriptRenderer();
fs.writeFileSync("my-props.ts", renderer.renderStruct(myProps));
fs.writeFileSync('my-props.ts', renderer.renderStruct(myProps));
```

@@ -143,4 +196,4 @@

```ts
const foo = new ProjenStruct(project, { name: 'Foo'})
const bar = new ProjenStruct(project, { name: 'Bar'})
const foo = new ProjenStruct(project, { name: 'Foo' });
const bar = new ProjenStruct(project, { name: 'Bar' });

@@ -153,8 +206,8 @@ bar.mixin(foo);

```ts
const foo = new ProjenStruct(project, { name: 'Foo'})
const bar = new ProjenStruct(project, { name: 'Bar'})
const foo = new ProjenStruct(project, { name: 'Foo' });
const bar = new ProjenStruct(project, { name: 'Bar' });
foo.add({
name: 'barSettings',
type: bar
type: bar,
});

@@ -172,9 +225,8 @@ ```

importLocations: {
'my_project': '../enums'
}
})
.add({
my_project: '../enums',
},
}).add({
name: 'complexSetting',
type: { fqn: "my_project.SomeEnum" }
type: { fqn: 'my_project.SomeEnum' },
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc