Skip to content

Commit

Permalink
chore: refactor aws-constructs into individual packages (#552)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: @functionless/aws-constructs package has been refactored into many service-specific packages.
  • Loading branch information
sam committed Oct 14, 2022
1 parent b4013ad commit 01a2c9f
Show file tree
Hide file tree
Showing 448 changed files with 15,866 additions and 12,037 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -54,5 +54,6 @@ packages/*/lib
!/.github/workflows/close.yml
.turbo
lib
docs/
.npmrc
.turbo-cache
.turbo-cache
25 changes: 25 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,25 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/node_modules/.bin/jest",
"cwd": "${workspaceFolder}",
"runtimeArgs": ["--enable-source-maps"],
"args": [
"--runInBand",
"--watchAll=false",
"--testNamePattern",
"${jest.testNamePattern}",
"--runTestsByPath",
"${jest.testFile}",
"--coverage=false"
]
}
]
}
9 changes: 4 additions & 5 deletions apps/fl-exp-simple/package.json
Expand Up @@ -7,16 +7,14 @@
"build": "npm run synth",
"deploy": "cdk deploy",
"local": "fl local",
"synth": "cdk synth",
"synth": "cdk synth --quiet",
"test": "jest --passWithNoTests",
"validate": "functionless"
},
"devDependencies": {
"@aws-cdk/aws-appsync-alpha": "2.44.0-alpha.0",
"@functionless/ast-reflection": "^0.3.1",
"@functionless/aws": "*",
"@functionless/aws-constructs": "*",
"@functionless/fl-exp": "*",
"@functionless/cli": "*",
"@functionless/language-service": "^0.0.4",
"@functionless/register": "*",
"@types/jest": "^29.0.3",
Expand All @@ -27,8 +25,9 @@
"aws-sdk": "^2",
"constructs": "10.0.0",
"esbuild": "0.15.9",
"functionless": "*",
"jest": "^29.0.3",
"typesafe-dynamodb": "0.2.3",
"typesafe-dynamodb": "^0.2.3",
"typescript": "^4.8.3"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion apps/fl-exp-simple/src/api/_api.ts
@@ -1,3 +1,3 @@
import { RestApi } from "@functionless/aws";
import { RestApi } from "@functionless/aws-apigateway";

export default RestApi();
4 changes: 3 additions & 1 deletion apps/fl-exp-simple/src/api/todos/[todoId]/delete-todo.ts
@@ -1,8 +1,10 @@
import { Method, PathParam, LambdaFunction } from "@functionless/aws";
// BUG: Uncomment this and this line and `putEvents` call bellow
// to trigger the function serializer error.
// import Events from "../event-bus";

import { PathParam } from "@functionless/aws-apigateway";
import { LambdaFunction } from "@functionless/aws-lambda";
import { Method } from "@functionless/aws-apigateway";
import { MyDatabase } from "../../../table";

export default Method<{
Expand Down
3 changes: 2 additions & 1 deletion apps/fl-exp-simple/src/api/todos/create-todo.ts
@@ -1,4 +1,5 @@
import { LambdaFunction, Method } from "@functionless/aws";
import { LambdaFunction } from "@functionless/aws-lambda";
import { Method } from "@functionless/aws-apigateway";
import * as uuid from "uuid";
import MyDatabase from "../../table";

Expand Down
3 changes: 2 additions & 1 deletion apps/fl-exp-simple/src/api/todos/list-todos.ts
@@ -1,4 +1,5 @@
import { LambdaFunction, Method } from "@functionless/aws";
import { LambdaFunction } from "@functionless/aws-lambda";
import { Method } from "@functionless/aws-apigateway";

import { MyDatabase } from "../../table";

Expand Down
2 changes: 1 addition & 1 deletion apps/fl-exp-simple/src/table.ts
@@ -1,5 +1,5 @@
import type { AttributeType, BillingMode } from "aws-cdk-lib/aws-dynamodb";
import { Table } from "@functionless/aws";
import { Table } from "@functionless/aws-dynamodb";

interface TableItem<T extends string> {
pk: T;
Expand Down
2 changes: 1 addition & 1 deletion apps/fl-exp-simple/src/useless-machine.ts
@@ -1,4 +1,4 @@
import { StepFunction } from "@functionless/aws";
import { StepFunction } from "@functionless/aws-stepfunctions";

import MyDatabase from "./table";

Expand Down
13 changes: 12 additions & 1 deletion apps/fl-exp-simple/tsconfig.json
Expand Up @@ -7,5 +7,16 @@
"inlineSourceMap": true
},
"include": ["."],
"exclude": ["lib", "test", "node_modules"]
"exclude": ["lib", "test", "node_modules"],
"references": [
{
"path": "../../packages/@functionless/cli"
},
{
"path": "../../packages/@functionless/register"
},
{
"path": "../../packages/functionless"
}
]
}
6 changes: 3 additions & 3 deletions apps/test-app/package.json
Expand Up @@ -10,15 +10,15 @@
},
"dependencies": {
"@aws-cdk/aws-appsync-alpha": "2.44.0-alpha.0",
"@functionless/aws-constructs": "*",
"@functionless/language-service": "^0.0.4",
"@functionless/register": "*",
"@graphql-codegen/cli": "^2.6.2",
"@graphql-codegen/typescript-resolvers": "^2.6.1",
"@graphql-codegen/typescript": "^2.4.8",
"@types/node": "^16",
"aws-cdk-lib": "^2.44.0",
"aws-cdk": "^2.44.0",
"functionless": "^0.27.1",
"aws-cdk-lib": "2.44.0",
"aws-cdk": "2.44.0",
"constructs": "10.0.0",
"graphql": "^16.3.0",
"typesafe-dynamodb": "^0.2.3",
Expand Down
12 changes: 6 additions & 6 deletions apps/test-app/src/api-test.ts
Expand Up @@ -6,15 +6,15 @@ import {
Stack,
} from "aws-cdk-lib";
import type { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
import { Table } from "@functionless/aws-dynamodb-constructs";
import { Function } from "@functionless/aws-lambda-constructs";
import {
AwsMethod,
MockMethod,
ExpressStepFunction,
Function,
Table,
ApiGatewayInput,
AwsMethod,
LambdaMethod,
} from "@functionless/aws-constructs";
MockMethod,
} from "@functionless/aws-apigateway-constructs";
import { ExpressStepFunction } from "@functionless/aws-stepfunctions-constructs";

export const app = new App();

Expand Down
3 changes: 2 additions & 1 deletion apps/test-app/src/app.ts
@@ -1,7 +1,8 @@
import path from "path";
import * as appsync from "@aws-cdk/aws-appsync-alpha";
import { App, Stack } from "aws-cdk-lib";
import { EventBus, Event } from "@functionless/aws-constructs";
import { Event } from "@functionless/aws-events";
import { EventBus } from "@functionless/aws-events-constructs";
import { PeopleDatabase, Person } from "./people-db";
import { PeopleEvents } from "./people-events";

Expand Down
4 changes: 3 additions & 1 deletion apps/test-app/src/func-test.ts
@@ -1,5 +1,7 @@
import { App, Stack } from "aws-cdk-lib";
import { StepFunction, EventBus, Function } from "@functionless/aws-constructs";
import { EventBus } from "@functionless/aws-events-constructs";
import { Function } from "@functionless/aws-lambda-constructs";
import { StepFunction } from "@functionless/aws-stepfunctions-constructs";

export const app = new App();
export const stack = new Stack(app, "func-test");
Expand Down
22 changes: 12 additions & 10 deletions apps/test-app/src/message-board.ts
Expand Up @@ -8,20 +8,22 @@ import {
aws_events,
Duration,
} from "aws-cdk-lib";
import { Event } from "@functionless/aws-events";
import { EventBus } from "@functionless/aws-events-constructs";
import { Table } from "@functionless/aws-dynamodb-constructs";
import {
$AWS,
$SFN,
$util,
AppsyncContext,
AppsyncField,
AppsyncResolver,
Function,
StepFunction,
Table,
EventBus,
Event,
} from "@functionless/aws-appsync-constructs";
import { Function } from "@functionless/aws-lambda-constructs";
import {
$SFN,
ExpressStepFunction,
AppsyncField,
AppsyncContext,
} from "@functionless/aws-constructs";
StepFunction,
} from "@functionless/aws-stepfunctions-constructs";
import { $AWS } from "@functionless/aws-sdk";

export const app = new App();
export const stack = new Stack(app, "message-board");
Expand Down
14 changes: 6 additions & 8 deletions apps/test-app/src/order-processing-queue.ts
Expand Up @@ -5,14 +5,12 @@ import {
SecretValue,
Stack,
} from "aws-cdk-lib";
import {
Queue,
Function,
EventBus,
Event,
StepFunction,
JsonSecret,
} from "@functionless/aws-constructs";
import { Event } from "@functionless/aws-events";
import { EventBus } from "@functionless/aws-events-constructs";
import { Queue } from "@functionless/aws-sqs-constructs";
import { Function } from "@functionless/aws-lambda-constructs";
import { StepFunction } from "@functionless/aws-stepfunctions-constructs";
import { JsonSecret } from "@functionless/aws-secretsmanager-constructs";

const app = new App();
const stack = new Stack(app, "queue");
Expand Down
10 changes: 5 additions & 5 deletions apps/test-app/src/people-db.ts
Expand Up @@ -6,14 +6,14 @@ import {
RemovalPolicy,
} from "aws-cdk-lib";
import { Construct } from "constructs";
import { Table } from "@functionless/aws-dynamodb-constructs";
import {
Table,
Function,
$util,
AppsyncResolver,
AppsyncContext,
ExpressStepFunction,
} from "@functionless/aws-constructs";
AppsyncResolver,
} from "@functionless/aws-appsync-constructs";
import { Function } from "@functionless/aws-lambda-constructs";
import { ExpressStepFunction } from "@functionless/aws-stepfunctions-constructs";

import {
QueryResolvers,
Expand Down
38 changes: 17 additions & 21 deletions apps/test-app/src/people-events.ts
@@ -1,5 +1,7 @@
import { Construct } from "constructs";
import * as functionless from "@functionless/aws-constructs";
import { Event } from "@functionless/aws-events";
import { EventBus } from "@functionless/aws-events-constructs";
import { Function } from "@functionless/aws-lambda-constructs";

interface UserDetails {
id?: string;
Expand All @@ -9,7 +11,7 @@ interface UserDetails {
}

interface UserEvent
extends functionless.Event<
extends Event<
UserDetails,
// We can provide custom detail-types to match on
"Create" | "Update" | "Delete"
Expand All @@ -31,22 +33,23 @@ export class PeopleEvents extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);

const createOrUpdateFunction = new functionless.Function<
CreateOrUpdate,
void
>(this, "createOrUpdate", async (event) => {
console.log("event: ", event);
});
const createOrUpdateFunction = new Function<CreateOrUpdate, void>(
this,
"createOrUpdate",
async (event) => {
console.log("event: ", event);
}
);

const deleteFunction = new functionless.Function<Delete, void>(
const deleteFunction = new Function<Delete, void>(
this,
"delete",
async (event) => {
console.log("event: ", event);
}
);

const bus = new functionless.EventBus<UserEvent>(this, "myBus");
const bus = new EventBus<UserEvent>(this, "myBus");

// Create and update events are sent to a specific lambda function.
bus
Expand Down Expand Up @@ -79,10 +82,7 @@ export class PeopleEvents extends Construct {
)
.pipe(deleteFunction);

const catPeopleBus = new functionless.EventBus<UserEvent>(
this,
"catTeamBus"
);
const catPeopleBus = new EventBus<UserEvent>(this, "catTeamBus");

// New, young, cat loving users are forwarded to our sister team.
bus
Expand All @@ -101,13 +101,9 @@ export class PeopleEvents extends Construct {
catPeopleBus
.when(this, "catSinkRule", () => true)
.pipe(
new functionless.Function<UserEvent, void>(
this,
"cats",
async (event) => {
console.log("event: ", event);
}
)
new Function<UserEvent, void>(this, "cats", async (event) => {
console.log("event: ", event);
})
);
}
}
4 changes: 3 additions & 1 deletion apps/test-app/src/stream-processing.ts
@@ -1,5 +1,7 @@
import { App, aws_dynamodb, Stack } from "aws-cdk-lib";
import { Table, Queue, JsonSerializer } from "@functionless/aws-constructs";
import { Table } from "@functionless/aws-dynamodb-constructs";
import { Queue } from "@functionless/aws-sqs-constructs";
import { JsonSerializer } from "@functionless/serde";

const app = new App();
const stack = new Stack(app, "StreamProcessing");
Expand Down
14 changes: 6 additions & 8 deletions apps/test-app/src/text-processing-queue.ts
@@ -1,12 +1,10 @@
import { App, aws_logs, aws_stepfunctions, Stack } from "aws-cdk-lib";
import {
Queue,
Function,
EventBus,
Event,
StepFunction,
Serializer,
} from "@functionless/aws-constructs";
import { Event } from "@functionless/aws-events";
import { EventBus } from "@functionless/aws-events-constructs";
import { Queue } from "@functionless/aws-sqs-constructs";
import { Function } from "@functionless/aws-lambda-constructs";
import { StepFunction } from "@functionless/aws-stepfunctions-constructs";
import { Serializer } from "@functionless/serde";

const app = new App();
const stack = new Stack(app, "queue");
Expand Down
10 changes: 9 additions & 1 deletion apps/test-app/tsconfig.json
Expand Up @@ -10,5 +10,13 @@
]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules"],
"references": [
{
"path": "../../packages/@functionless/register"
},
{
"path": "../../packages/functionless"
}
]
}
1 change: 1 addition & 0 deletions apps/website/.gitignore
Expand Up @@ -19,5 +19,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

!/docs/
/docs/api
/docs/error-codes.md

0 comments on commit 01a2c9f

Please sign in to comment.