Skip to content

Commit 2bf7290

Browse files
committed
fix: serialize classes properly and rename packages
1 parent f0f348a commit 2bf7290

36 files changed

+189
-91
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
# alchemy-effect
22

3-
WIP
3+
Alchemy Effect is an Infrastructure-as-Effects (iae) framework that unifies Business Logic and Infrastructure-as-Code into a single, unified model:
4+
1. *Resources* declared in your code
5+
2. *Business Logic* expressed as Effects accessing those resources
6+
3. *Bindings* attached to Functions, Workers, Hosts, etc. ensure least-privilege IAM policies
7+
8+
```ts
9+
// declare a FIFO SQS Queue with a String schema
10+
export class Messages extends SQS.Queue("Messages", {
11+
fifo: true,
12+
schema: S.String,
13+
}) {}
14+
15+
// declare a Lambda Function that sends a message to the Messages Queue
16+
export class Api extends Lambda.serve("Api", {
17+
fetch: Effect.fn(function* (event) {
18+
// Infer sqs::SendMessage IAM Policy
19+
yield* SQS.sendMessage(Messages, "Hello, world!");
20+
return {
21+
body: JSON.stringify(null),
22+
};
23+
}),
24+
}) ({
25+
main: import.meta.filename,
26+
// Type system guaranees least-privilege IAM policy
27+
bindings: $(SQS.SendMessage(Messages)),
28+
}) {}
29+
30+
// export the API's handler with runtime layers provided for bundling and running in AWS
31+
export default Api.handler.pipe(Effect.provide(SQS.clientFromEnv()), Lambda.toHandler);
32+
```
33+

alchemy-effect-aws/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@alchemy.run/effect-aws",
2+
"name": "@alchemy.run/aws",
33
"version": "0.0.0",
44
"license": "Apache-2.0",
55
"author": "Sam Goodwin <sam@alchemy.run>",
@@ -50,7 +50,7 @@
5050
}
5151
},
5252
"peerDependencies": {
53-
"@alchemy.run/effect": "workspace:*",
53+
"@alchemy.run/core": "workspace:*",
5454
"@effect/platform-node": "*",
5555
"@effect/platform": "*",
5656
"effect": "*"

alchemy-effect-aws/src/lambda/consume.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { From } from "@alchemy.run/effect";
2-
import { declare } from "@alchemy.run/effect";
1+
import type { From } from "@alchemy.run/core";
2+
import { declare } from "@alchemy.run/core";
33
import type {
44
Context as LambdaContext,
55
SQSBatchResponse,

alchemy-effect-aws/src/lambda/function.handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Capability } from "@alchemy.run/effect";
1+
import type { Capability } from "@alchemy.run/core";
22
import type { Context as LambdaContext } from "aws-lambda";
33
import * as Effect from "effect/Effect";
44

alchemy-effect-aws/src/lambda/function.invoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
type Capability,
77
declare,
88
toEnvKey,
9-
} from "@alchemy.run/effect";
9+
} from "@alchemy.run/core";
1010
import { FunctionClient } from "./function.client.ts";
1111
import { Function } from "./function.ts";
1212

alchemy-effect-aws/src/lambda/function.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FileSystem } from "@effect/platform";
55
import * as Effect from "effect/Effect";
66
import * as Schedule from "effect/Schedule";
77

8-
import { App, DotAlchemy } from "@alchemy.run/effect";
8+
import { App, DotAlchemy } from "@alchemy.run/core";
99

1010
import type {
1111
CreateFunctionUrlConfigRequest,

alchemy-effect-aws/src/lambda/function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Policy, Runtime, type Capability } from "@alchemy.run/effect";
1+
import { Policy, Runtime, type Capability } from "@alchemy.run/core";
22
import type * as IAM from "../iam.ts";
33

44
export type { Context } from "aws-lambda";

alchemy-effect-aws/src/sqs/queue.consume.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Binding, type Capability, type From } from "@alchemy.run/effect";
1+
import { Binding, type Capability, type From } from "@alchemy.run/core";
22
import type * as lambda from "aws-lambda";
33
import { Function } from "../lambda/index.ts";
44
import { Queue } from "./queue.ts";

alchemy-effect-aws/src/sqs/queue.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as Effect from "effect/Effect";
22
import * as Schedule from "effect/Schedule";
33

4-
import { App, type ProviderService } from "@alchemy.run/effect";
4+
import { App, type ProviderService } from "@alchemy.run/core";
55
import { AccountID } from "../account.ts";
66
import { Region } from "../region.ts";
77
import { QueueClient } from "./queue.client.ts";

alchemy-effect-aws/src/sqs/queue.send-message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
toEnvKey,
77
type Capability,
88
type To,
9-
} from "@alchemy.run/effect";
9+
} from "@alchemy.run/core";
1010
import { Function } from "../lambda/index.ts";
1111
import { QueueClient } from "./queue.client.ts";
1212
import { Queue } from "./queue.ts";

0 commit comments

Comments
 (0)