Skip to content

Commit

Permalink
chore: @functionless/aws, util, aws-util (#540)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: move fl-exp/interface to @functionless/aws
  • Loading branch information
sam committed Oct 6, 2022
1 parent 392128a commit d72d0a0
Show file tree
Hide file tree
Showing 62 changed files with 168 additions and 47 deletions.
3 changes: 2 additions & 1 deletion apps/fl-exp-simple/package.json
Expand Up @@ -14,12 +14,13 @@
"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/language-service": "^0.0.4",
"@functionless/register": "*",
"@types/jest": "^29.0.3",
"@types/node": "^18.7.18",
"@types/node": "^16",
"@types/uuid": "^8.3.4",
"aws-cdk-lib": "2.44.0",
"aws-cdk": "2.44.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/fl-exp-simple/src/api/_api.ts
@@ -1,3 +1,3 @@
import { RestApi } from "@functionless/fl-exp";
import { RestApi } from "@functionless/aws";

export default RestApi();
2 changes: 1 addition & 1 deletion apps/fl-exp-simple/src/api/todos/[todoId]/delete-todo.ts
@@ -1,4 +1,4 @@
import { Method, PathParam, LambdaFunction } from "@functionless/fl-exp";
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";
Expand Down
2 changes: 1 addition & 1 deletion apps/fl-exp-simple/src/api/todos/create-todo.ts
@@ -1,4 +1,4 @@
import { LambdaFunction, Method } from "@functionless/fl-exp";
import { LambdaFunction, Method } from "@functionless/aws";
import * as uuid from "uuid";
import MyDatabase from "../../table";

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

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/fl-exp";
import { Table } from "@functionless/aws";

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/fl-exp";
import { StepFunction } from "@functionless/aws";

import MyDatabase from "./table";

Expand Down
2 changes: 1 addition & 1 deletion apps/test-app/package.json
Expand Up @@ -16,7 +16,7 @@
"@graphql-codegen/cli": "^2.6.2",
"@graphql-codegen/typescript-resolvers": "^2.6.1",
"@graphql-codegen/typescript": "^2.4.8",
"@types/node": "^14",
"@types/node": "^16",
"aws-cdk-lib": "^2.44.0",
"aws-cdk": "^2.44.0",
"constructs": "10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@functionless/aws-constructs/package.json
Expand Up @@ -36,7 +36,7 @@
"@types/fs-extra": "^9.0.13",
"@types/jest": "^29.0.3",
"@types/minimatch": "^3.0.5",
"@types/node": "^14",
"@types/node": "^16",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "^5",
Expand Down
23 changes: 23 additions & 0 deletions packages/@functionless/aws-util/package.json
@@ -0,0 +1,23 @@
{
"name": "@functionless/aws-util",
"version": "0.0.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc -b",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"aws-sdk": "^2"
},
"devDependencies": {
"typescript": "^4.8.3",
"aws-sdk": "^2"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
}
}
1 change: 1 addition & 0 deletions packages/@functionless/aws-util/src/index.ts
@@ -0,0 +1 @@
export * from "./credentials";
11 changes: 11 additions & 0 deletions packages/@functionless/aws-util/tsconfig.json
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig-base",
"compilerOptions": {
"outDir": "lib",
"declaration": true,
"inlineSourceMap": true,
"rootDir": "src"
},
"include": ["src"],
"exclude": ["lib", "node_modules"]
}
26 changes: 26 additions & 0 deletions packages/@functionless/aws/package.json
@@ -0,0 +1,26 @@
{
"name": "@functionless/aws",
"version": "0.0.0",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"build": "tsc --build",
"typecheck": "tsc --noEmit",
"dev": "tsc --watch"
},
"dependencies": {
"typesafe-dynamodb": "^0.2.3",
"@functionless/aws-constructs": "*",
"@functionless/aws-util": "*",
"@functionless/util": "*"
},
"devDependencies": {
"typescript": "^4.8.3"
},
"publishConfig": {
"access": "public"
}
}
@@ -1,7 +1,7 @@
import STS from "aws-sdk/clients/sts";
import type { Credentials, CredentialsOptions } from "aws-sdk/lib/credentials";
import { getClientProps } from "../credentials";
import { memoize } from "../memoize";
import { getClientProps } from "@functionless/aws-util";
import { memoize } from "@functionless/util";

export function createClientFactory<
ClientClass extends new (props: {
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,6 @@
import type * as functionless from "@functionless/aws-constructs";
import { memoize } from "../memoize";
import Lambda from "aws-sdk/clients/lambda";
import { getEnvironmentVariableName } from "../util";
import { memoize, getEnvironmentVariableName } from "@functionless/util";

export type FunctionHandler<In = any, Out = any> = (input: In) => Promise<Out>;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
import StepFunctions from "aws-sdk/clients/stepfunctions";
import type * as functionless from "@functionless/aws-constructs";
import { getEnvironmentVariableName } from "../util";
import { getEnvironmentVariableName } from "@functionless/util";
import { createClientFactory } from "./client";

const stepFunctionClient = createClientFactory(StepFunctions);
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { AttributeType } from "./table/attribute-type";
import { TableAttributesApi, TableDocumentApi } from "./table/runtime";
import DynamoDB from "aws-sdk/clients/dynamodb";
import { DocumentClient } from "aws-sdk/clients/dynamodb";
import { getEnvironmentVariableName } from "../util";
import { getEnvironmentVariableName } from "@functionless/util";
import { createClientFactory } from "./client";

export const TableKind = "fl.Table";
Expand Down
16 changes: 16 additions & 0 deletions packages/@functionless/aws/tsconfig.json
@@ -0,0 +1,16 @@
{
"extends": "../../../tsconfig-base.json",
"compilerOptions": {
"outDir": "lib",
"declaration": true,
"inlineSourceMap": true,
"rootDir": "src"
},
"include": ["src"],
"exclude": ["lib", "test", "node_modules"],
"references": [
{ "path": "../aws-constructs" },
{ "path": "../aws-util" },
{ "path": "../util" }
]
}
10 changes: 7 additions & 3 deletions packages/@functionless/fl-exp/package.json
Expand Up @@ -12,6 +12,7 @@
],
"scripts": {
"build": "tsc --build",
"typecheck": "tsc --noEmit",
"deploy": "cdk deploy",
"synth": "cdk synth",
"test": "jest --passWithNoTests",
Expand All @@ -23,6 +24,9 @@
"@babel/plugin-transform-typescript": "^7.19.3",
"@functionless/ast-reflection": "^0.3.1",
"@functionless/aws-constructs": "^0.25.0",
"@functionless/aws": "*",
"@functionless/aws-util": "*",
"@functionless/util": "*",
"@types/aws-lambda": "^8.10.106",
"commander": "^9.4.0",
"dependency-tree": "^8.1.2",
Expand All @@ -31,16 +35,16 @@
"toposort": "^2.0.2"
},
"devDependencies": {
"@aws-cdk/aws-appsync-alpha": "2.44.0-alpha.0",
"@aws-sdk/client-dynamodb": "*",
"@aws-cdk/aws-appsync-alpha": "2.44.0-alpha.0",
"@functionless/language-service": "^0.0.4",
"@swc/jest": "^0.2.22",
"@types/express": "^4.17.14",
"@types/jest": "^29.0.3",
"@types/node": "^18.7.18",
"@types/node": "^16",
"@types/toposort": "^2.0.3",
"aws-cdk": "2.44.0",
"aws-cdk-lib": "2.44.0",
"aws-cdk": "2.44.0",
"aws-sdk": "^2",
"constructs": "10.0.0",
"esbuild": "0.15.9",
Expand Down
@@ -1,5 +1,5 @@
import { registerCommand } from "../../command-provider";
import { MethodKind } from "../../interface/method";
import { MethodKind } from "@functionless/aws";
import { invokeLambda } from "./lambda-function";
import { openConsole } from "./open-console";
import { invokeExpressStepFunction } from "./express-step-function";
Expand Down
@@ -1,8 +1,8 @@
import { StackResourceDetail } from "aws-sdk/clients/cloudformation";
import StepFunctions from "aws-sdk/clients/stepfunctions";
import { registerCommand } from "../../command-provider";
import { getClientProps } from "../../credentials";
import { ExpressStepFunctionKind } from "../../interface/express-step-function";
import { getClientProps } from "@functionless/aws-util";
import { ExpressStepFunctionKind } from "@functionless/aws";
import { openConsole } from "./open-console";

registerCommand({
Expand Down
@@ -1,10 +1,10 @@
import { registerCommand } from "../../command-provider";
import Lambda from "aws-sdk/clients/lambda";
import Logs from "aws-sdk/clients/cloudwatchlogs";
import { LambdaFunctionKind } from "../../interface/lambda-function";
import { LambdaFunctionKind } from "@functionless/aws";
import { promisify } from "util";
import { StackResourceDetail } from "aws-sdk/clients/cloudformation";
import { getClientProps } from "../../credentials";
import { getClientProps } from "@functionless/aws-util";
import { openConsole } from "./open-console";

export async function invokeLambda(
Expand Down
@@ -1,8 +1,8 @@
import { StackResourceDetail } from "aws-sdk/clients/cloudformation";
import StepFunctions from "aws-sdk/clients/stepfunctions";
import { registerCommand } from "../../command-provider";
import { getClientProps } from "../../credentials";
import { StepFunctionKind } from "../../interface/step-function";
import { getClientProps } from "@functionless/aws-util";
import { StepFunctionKind } from "@functionless/aws";
import { openConsole } from "./open-console";

registerCommand({
Expand Down
2 changes: 1 addition & 1 deletion packages/@functionless/fl-exp/src/index.ts
@@ -1 +1 @@
export * from "./interface";
export * from "./load-project";
2 changes: 1 addition & 1 deletion packages/@functionless/fl-exp/src/load-project.ts
@@ -1,6 +1,6 @@
import path from "path";
import fs from "fs/promises";
import { isResource } from "./interface";
import { isResource } from "@functionless/aws";
import { exists, ls } from "./util";
import { Folder, FolderProps } from "./tree/folder";
import { Project } from "./project";
Expand Down
6 changes: 3 additions & 3 deletions packages/@functionless/fl-exp/src/local-serve-project.ts
Expand Up @@ -9,7 +9,7 @@ import {
LambdaFunction,
Resource,
StepFunction,
} from "./interface";
} from "@functionless/aws";
import { Project } from "./project";
import type {
APIGatewayProxyEventQueryStringParameters,
Expand All @@ -25,8 +25,8 @@ import StepFunctions from "aws-sdk/clients/stepfunctions";
import STS from "aws-sdk/clients/sts";
import IAM from "aws-sdk/clients/iam";
import { isStepFunction } from "@functionless/aws-constructs";
import { getClientProps } from "./credentials";
import { getEnvironmentVariableName } from "./util";
import { getClientProps } from "@functionless/aws-util";
import { getEnvironmentVariableName } from "@functionless/util";
import { Tree } from "./tree/tree";
import { isFile } from "./tree/file";

Expand Down
2 changes: 1 addition & 1 deletion packages/@functionless/fl-exp/src/logical-id.ts
@@ -1,6 +1,6 @@
import CloudFormation from "aws-sdk/clients/cloudformation";
import crypto from "crypto";
import { getClientProps } from "./credentials";
import { getClientProps } from "@functionless/aws-util";

export async function resolveStackDetail(stackName: string, logicalId: string) {
const cfnClient = new CloudFormation(getClientProps());
Expand Down
2 changes: 1 addition & 1 deletion packages/@functionless/fl-exp/src/plugin.ts
Expand Up @@ -3,7 +3,7 @@ import * as babel from "@babel/core";
import fs from "fs/promises";
import path from "path";
import { Project } from "./project";
import { isResource } from "./interface";
import { isResource } from "@functionless/aws";

const babel_ts = require("@babel/plugin-transform-typescript");

Expand Down
2 changes: 1 addition & 1 deletion packages/@functionless/fl-exp/src/project.ts
@@ -1,4 +1,4 @@
import { Resource } from "./interface";
import { Resource } from "@functionless/aws";
import { isFile, File } from "./tree/file";
import { Folder } from "./tree/folder";
import { Tree } from "./tree/tree";
Expand Down
4 changes: 2 additions & 2 deletions packages/@functionless/fl-exp/src/synthesize.ts
Expand Up @@ -22,7 +22,7 @@ import {
LambdaFunction,
LambdaFunctionKind,
StepFunction,
} from "./interface";
} from "@functionless/aws";
import {
ASL,
FunctionlessNode,
Expand All @@ -35,7 +35,7 @@ import * as functionless from "@functionless/aws-constructs";
import { forEachChild } from "@functionless/aws-constructs/lib/visit";
import { logicalIdForPath } from "./logical-id";
import { bundleLambdaFunction, getBundleOutFolder } from "./bundle-lambda";
import { getEnvironmentVariableName } from "./util";
import { getEnvironmentVariableName } from "@functionless/util";
import { Tree } from "./tree/tree";
import { isFile, File } from "./tree/file";
import { isFolder } from "./tree/folder";
Expand Down
2 changes: 1 addition & 1 deletion packages/@functionless/fl-exp/src/tree/file.ts
@@ -1,5 +1,5 @@
import path from "path";
import { Resource } from "../interface";
import { Resource } from "@functionless/aws";
import { Project } from "../project";
import { Folder } from "./folder";

Expand Down
4 changes: 0 additions & 4 deletions packages/@functionless/fl-exp/src/util.ts
Expand Up @@ -14,7 +14,3 @@ export async function exists(file: string): Promise<boolean> {
export async function ls(dir: string): Promise<string[]> {
return (await fs.readdir(dir)).map((file) => path.resolve(dir, file));
}

export function getEnvironmentVariableName(resourceId: string): string {
return resourceId.replaceAll(/[^A-Za-z_0-9]/g, "_");
}
20 changes: 20 additions & 0 deletions packages/@functionless/util/package.json
@@ -0,0 +1,20 @@
{
"name": "@functionless/util",
"version": "0.0.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc -b",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/node": "^16",
"typescript": "^4.8.3"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/@functionless/util/src/environment-variable.ts
@@ -0,0 +1,3 @@
export function getEnvironmentVariableName(resourceId: string): string {
return resourceId.replaceAll(/[^A-Za-z_0-9]/g, "_");
}
2 changes: 2 additions & 0 deletions packages/@functionless/util/src/index.ts
@@ -0,0 +1,2 @@
export * from "./environment-variable";
export * from "./memoize";
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/@functionless/util/tsconfig.json
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig-base",
"compilerOptions": {
"outDir": "lib",
"declaration": true,
"inlineSourceMap": true,
"rootDir": "src"
},
"include": ["src"],
"exclude": ["lib", "node_modules"]
}

0 comments on commit d72d0a0

Please sign in to comment.