nomoss 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +45 -0
- package/bin/nomoss +13 -0
- package/docs/code-documentation.md +36 -0
- package/docs/effect-native-development.md +55 -0
- package/docs/engine-design.md +93 -0
- package/docs/linting.md +88 -0
- package/docs/releasing.md +13 -0
- package/docs/resource-command-policy-stage.md +71 -0
- package/docs/resource-graph-mvp.md +31 -0
- package/docs/resource-graph-testing-approach.md +11 -0
- package/docs/resource-lifecycle-tracker.md +93 -0
- package/docs/testing.md +86 -0
- package/examples/upload-events/README.md +41 -0
- package/media/nomoss.gif +0 -0
- package/package.json +64 -0
- package/src/cli.ts +18 -0
- package/src/cliCommand.ts +186 -0
- package/src/cliRuntimeLayer.ts +49 -0
- package/src/core/index.ts +17 -0
- package/src/core/lifecycle.ts +127 -0
- package/src/core/model.ts +229 -0
- package/src/core/physicalNameStore.ts +226 -0
- package/src/core/planner.ts +645 -0
- package/src/core/resourceCommandPolicy.ts +79 -0
- package/src/core/resourceGraphBuilder.ts +167 -0
- package/src/core/resourceGraphStore.ts +288 -0
- package/src/core/resourceOutputResolver.ts +185 -0
- package/src/core/resourcePolicy.ts +77 -0
- package/src/core/resourceStackDefinition.ts +17 -0
- package/src/core/resourceStackLifecycle.ts +456 -0
- package/src/core/resourceStackOperations.ts +129 -0
- package/src/core/runtimeLayer.ts +73 -0
- package/src/core/stackWorkflowRenderer.ts +239 -0
- package/src/core/stateSecretService.ts +553 -0
- package/src/core/stateStore.ts +652 -0
- package/src/core/tracing.ts +26 -0
- package/src/index.ts +2 -0
- package/src/providers/aws/awsApply.ts +132 -0
- package/src/providers/aws/awsBucket.ts +329 -0
- package/src/providers/aws/awsBucketNotification.ts +351 -0
- package/src/providers/aws/awsBucketNotificationResourcePolicy.ts +251 -0
- package/src/providers/aws/awsBucketResourcePolicy.ts +198 -0
- package/src/providers/aws/awsProviderLayer.ts +274 -0
- package/src/providers/aws/awsQueue.ts +346 -0
- package/src/providers/aws/awsQueuePolicy.ts +419 -0
- package/src/providers/aws/awsQueuePolicyResourcePolicy.ts +215 -0
- package/src/providers/aws/awsQueueResourcePolicy.ts +270 -0
- package/src/providers/aws/awsReconciliation.ts +92 -0
- package/src/providers/aws/awsRefresh.ts +50 -0
- package/src/providers/aws/awsResourceLifecycle.ts +118 -0
- package/src/providers/aws/awsResourcePolicy.ts +83 -0
- package/src/providers/aws/awsResources.ts +274 -0
- package/src/providers/aws/awsRuntimeLayer.ts +21 -0
- package/src/providers/aws/awsSqsTransport.ts +33 -0
- package/src/providers/aws/awsStackLifecycle.ts +272 -0
- package/src/providers/aws/awsTagging.ts +186 -0
- package/src/providers/aws/constants.ts +3 -0
- package/src/providers/aws/index.ts +22 -0
- package/src/providers/aws/sampleStack.ts +65 -0
- package/src/providers/aws/stackWorkflow.ts +443 -0
- package/src/providers/index.ts +5 -0
- package/src/providers/provider.ts +5 -0
- package/src/providers/providerRuntimeLayer.ts +121 -0
- package/src/providers/resourceCommandPolicyLayer.ts +240 -0
- package/src/providers/stripe/index.ts +15 -0
- package/src/providers/stripe/stripeAccount.ts +139 -0
- package/src/providers/stripe/stripeBillingConfigurationExport.ts +180 -0
- package/src/providers/stripe/stripeBillingConfigurationExportResourcePolicy.ts +178 -0
- package/src/providers/stripe/stripeBillingPortalConfiguration.ts +153 -0
- package/src/providers/stripe/stripeBillingPortalConfigurationResourcePolicy.ts +177 -0
- package/src/providers/stripe/stripeCustomer.ts +148 -0
- package/src/providers/stripe/stripeCustomerResourcePolicy.ts +160 -0
- package/src/providers/stripe/stripePrice.ts +218 -0
- package/src/providers/stripe/stripePriceResourcePolicy.ts +151 -0
- package/src/providers/stripe/stripeProduct.ts +171 -0
- package/src/providers/stripe/stripeProductResourcePolicy.ts +161 -0
- package/src/providers/stripe/stripeResources.ts +454 -0
- package/src/providers/stripe/stripeRuntimeLayer.ts +131 -0
- package/src/providers/stripe/stripeWebhookEndpoint.ts +293 -0
- package/src/providers/stripe/stripeWebhookEndpointResourcePolicy.ts +198 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Array as Arr,
|
|
3
|
+
Context,
|
|
4
|
+
Data,
|
|
5
|
+
Effect,
|
|
6
|
+
Option,
|
|
7
|
+
Record as Rec,
|
|
8
|
+
Schema,
|
|
9
|
+
Stream,
|
|
10
|
+
} from "effect";
|
|
11
|
+
|
|
12
|
+
import { type ResourceNode, ResourceNodeSchema } from "./model.js";
|
|
13
|
+
import type { ResourceDependency } from "./resourceGraphStore.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stack lifecycle needs a typed failure when a planned resource depends on an
|
|
17
|
+
* upstream output that is absent from the applied stack state. The error carries
|
|
18
|
+
* the referenced logical id and property so failure recording can report the
|
|
19
|
+
* missing dependency without inventing a resource-specific placeholder value.
|
|
20
|
+
*/
|
|
21
|
+
export class ResourceOutputResolutionMissing extends Data.TaggedError(
|
|
22
|
+
"ResourceOutputResolutionMissing",
|
|
23
|
+
)<{
|
|
24
|
+
readonly property: string;
|
|
25
|
+
readonly sourceLogicalId: string;
|
|
26
|
+
}> {}
|
|
27
|
+
|
|
28
|
+
export class ResourceOutputPropertyPathInvalid extends Data.TaggedError(
|
|
29
|
+
"ResourceOutputPropertyPathInvalid",
|
|
30
|
+
)<{
|
|
31
|
+
readonly logicalId: string;
|
|
32
|
+
readonly property: string;
|
|
33
|
+
}> {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Stack lifecycle passes graph dependency edges here so create/update props can
|
|
37
|
+
* receive applied output values before `ResourceCommandPolicy` runs.
|
|
38
|
+
*/
|
|
39
|
+
export class ResourceOutputResolver extends Context.Service<ResourceOutputResolver>()(
|
|
40
|
+
"nomoss/core/resourceOutputResolver",
|
|
41
|
+
{
|
|
42
|
+
make: Effect.gen(function* () {
|
|
43
|
+
function replaceJsonProperty(
|
|
44
|
+
props: Schema.Json,
|
|
45
|
+
property: string,
|
|
46
|
+
value: Schema.Json,
|
|
47
|
+
): Option.Option<Schema.Json> {
|
|
48
|
+
const arrayIndex = (segment: string) =>
|
|
49
|
+
Option.map(
|
|
50
|
+
Option.fromNullishOr(segment.match(/^(?:0|[1-9]\d*)$/)),
|
|
51
|
+
() => Number.parseInt(segment, 10),
|
|
52
|
+
);
|
|
53
|
+
const replaceAtPath = (
|
|
54
|
+
current: Schema.Json,
|
|
55
|
+
remainingSegments: ReadonlyArray<string>,
|
|
56
|
+
): Option.Option<Schema.Json> =>
|
|
57
|
+
Option.match(Arr.head(remainingSegments), {
|
|
58
|
+
onNone: () => Option.some(value),
|
|
59
|
+
onSome: (segment) =>
|
|
60
|
+
Option.orElse(
|
|
61
|
+
Option.flatMap(
|
|
62
|
+
Schema.decodeUnknownOption(
|
|
63
|
+
Schema.Record(Schema.String, Schema.Json),
|
|
64
|
+
)(current),
|
|
65
|
+
(record) =>
|
|
66
|
+
Option.flatMap(
|
|
67
|
+
Option.fromUndefinedOr(record[segment]),
|
|
68
|
+
(child) =>
|
|
69
|
+
Option.map(
|
|
70
|
+
replaceAtPath(child, Arr.drop(remainingSegments, 1)),
|
|
71
|
+
(updatedChild) =>
|
|
72
|
+
Schema.Json.make(
|
|
73
|
+
Rec.set(record, segment, updatedChild),
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
() =>
|
|
79
|
+
Option.flatMap(
|
|
80
|
+
Schema.decodeUnknownOption(Schema.Array(Schema.Json))(
|
|
81
|
+
current,
|
|
82
|
+
),
|
|
83
|
+
(array) =>
|
|
84
|
+
Option.flatMap(arrayIndex(segment), (index) =>
|
|
85
|
+
Option.flatMap(Arr.get(array, index), (child) =>
|
|
86
|
+
Option.map(
|
|
87
|
+
replaceAtPath(
|
|
88
|
+
child,
|
|
89
|
+
Arr.drop(remainingSegments, 1),
|
|
90
|
+
),
|
|
91
|
+
(updatedChild) =>
|
|
92
|
+
Schema.Json.make(
|
|
93
|
+
Arr.appendAll(
|
|
94
|
+
Arr.append(
|
|
95
|
+
Arr.take(array, index),
|
|
96
|
+
updatedChild,
|
|
97
|
+
),
|
|
98
|
+
Arr.drop(array, index + 1),
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
),
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return replaceAtPath(props, property.split("."));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const resolveNodeProps = (
|
|
112
|
+
node: ResourceNode,
|
|
113
|
+
resources: ReadonlyArray<ResourceNode>,
|
|
114
|
+
dependencies: ReadonlyArray<ResourceDependency>,
|
|
115
|
+
) =>
|
|
116
|
+
Stream.runFoldEffect(
|
|
117
|
+
Stream.fromIterable(dependencies),
|
|
118
|
+
() => node.props,
|
|
119
|
+
(props, dependency) =>
|
|
120
|
+
Arr.findFirst(
|
|
121
|
+
resources,
|
|
122
|
+
(resource) =>
|
|
123
|
+
resource.key.logicalId === dependency.source.logicalId,
|
|
124
|
+
).pipe(
|
|
125
|
+
Effect.fromOption(
|
|
126
|
+
() =>
|
|
127
|
+
new ResourceOutputResolutionMissing({
|
|
128
|
+
property: dependency.edge.sourceProperty,
|
|
129
|
+
sourceLogicalId: dependency.source.logicalId,
|
|
130
|
+
}),
|
|
131
|
+
),
|
|
132
|
+
Effect.flatMap((resource) =>
|
|
133
|
+
Schema.decodeUnknownEffect(
|
|
134
|
+
Schema.Record(Schema.String, Schema.Json),
|
|
135
|
+
)(resource.outputs),
|
|
136
|
+
),
|
|
137
|
+
Effect.flatMap((outputs) =>
|
|
138
|
+
Effect.fromOption(
|
|
139
|
+
() =>
|
|
140
|
+
new ResourceOutputResolutionMissing({
|
|
141
|
+
property: dependency.edge.sourceProperty,
|
|
142
|
+
sourceLogicalId: dependency.source.logicalId,
|
|
143
|
+
}),
|
|
144
|
+
)(
|
|
145
|
+
Option.fromUndefinedOr(
|
|
146
|
+
outputs[dependency.edge.sourceProperty],
|
|
147
|
+
),
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
Effect.flatMap((value) =>
|
|
151
|
+
Effect.fromOption(
|
|
152
|
+
() =>
|
|
153
|
+
new ResourceOutputPropertyPathInvalid({
|
|
154
|
+
logicalId: node.key.logicalId,
|
|
155
|
+
property: dependency.edge.property,
|
|
156
|
+
}),
|
|
157
|
+
)(replaceJsonProperty(props, dependency.edge.property, value)),
|
|
158
|
+
),
|
|
159
|
+
),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
resolveNode: Effect.fn("ResourceOutputResolver.resolveNode")(function* (
|
|
164
|
+
node: ResourceNode,
|
|
165
|
+
resources: ReadonlyArray<ResourceNode>,
|
|
166
|
+
dependencies: ReadonlyArray<ResourceDependency>,
|
|
167
|
+
) {
|
|
168
|
+
const resolvedProps = yield* resolveNodeProps(
|
|
169
|
+
node,
|
|
170
|
+
resources,
|
|
171
|
+
dependencies,
|
|
172
|
+
);
|
|
173
|
+
const resolvedNode = yield* ResourceNodeSchema.makeEffect({
|
|
174
|
+
key: node.key,
|
|
175
|
+
schema: node.schema,
|
|
176
|
+
props: resolvedProps,
|
|
177
|
+
outputs: node.outputs,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return resolvedNode;
|
|
181
|
+
}),
|
|
182
|
+
};
|
|
183
|
+
}),
|
|
184
|
+
},
|
|
185
|
+
) {}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Context, Effect, Match, type Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
PlanDecision,
|
|
5
|
+
ResourceCommandResult,
|
|
6
|
+
ResourceObservation,
|
|
7
|
+
} from "./lifecycle.js";
|
|
8
|
+
import type { ResourceNode } from "./model.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resource policies share this protocol adapter so observed provider state,
|
|
12
|
+
* missing resources, unreadable resources, and default diff decisions use the
|
|
13
|
+
* same command-result contract.
|
|
14
|
+
*/
|
|
15
|
+
export class ResourcePolicy extends Context.Service<ResourcePolicy>()(
|
|
16
|
+
"nomoss/core/resourcePolicy",
|
|
17
|
+
{
|
|
18
|
+
make: Effect.succeed({
|
|
19
|
+
observed: (observation: ResourceObservation) =>
|
|
20
|
+
ResourceCommandResult.Observed({ observation }),
|
|
21
|
+
|
|
22
|
+
present: (node: ResourceNode, observedState: Schema.Json) =>
|
|
23
|
+
ResourceCommandResult.Observed({
|
|
24
|
+
observation: ResourceObservation.Present({
|
|
25
|
+
node,
|
|
26
|
+
observed: observedState,
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
missing: (node: ResourceNode) =>
|
|
31
|
+
ResourceCommandResult.Observed({
|
|
32
|
+
observation: ResourceObservation.Missing({ node }),
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
unreadable: (node: ResourceNode, reason: string) =>
|
|
36
|
+
ResourceCommandResult.Observed({
|
|
37
|
+
observation: ResourceObservation.Unreadable({ node, reason }),
|
|
38
|
+
}),
|
|
39
|
+
|
|
40
|
+
unreadableObservation: (node: ResourceNode, reason: string) =>
|
|
41
|
+
ResourceObservation.Unreadable({ node, reason }),
|
|
42
|
+
|
|
43
|
+
diffFromObservation: (
|
|
44
|
+
node: ResourceNode,
|
|
45
|
+
observation: ResourceObservation,
|
|
46
|
+
) =>
|
|
47
|
+
Match.value(observation).pipe(
|
|
48
|
+
Match.tagsExhaustive({
|
|
49
|
+
Present: () =>
|
|
50
|
+
Effect.succeed(
|
|
51
|
+
ResourceCommandResult.Decided({
|
|
52
|
+
decision: PlanDecision.NoOp({ node }),
|
|
53
|
+
}),
|
|
54
|
+
),
|
|
55
|
+
Missing: () =>
|
|
56
|
+
Effect.succeed(
|
|
57
|
+
ResourceCommandResult.Decided({
|
|
58
|
+
decision: PlanDecision.Create({ node }),
|
|
59
|
+
}),
|
|
60
|
+
),
|
|
61
|
+
Drifted: ({ reason }) =>
|
|
62
|
+
Effect.succeed(
|
|
63
|
+
ResourceCommandResult.Decided({
|
|
64
|
+
decision: PlanDecision.Repair({ node, reason }),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
Unreadable: ({ reason }) =>
|
|
68
|
+
Effect.succeed(
|
|
69
|
+
ResourceCommandResult.Decided({
|
|
70
|
+
decision: PlanDecision.Repair({ node, reason }),
|
|
71
|
+
}),
|
|
72
|
+
),
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
) {}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Applications provide this service to name the stack and register desired
|
|
5
|
+
* resources. Provider services are captured when the application layer builds
|
|
6
|
+
* the definition, so stack operations can run declaration, planning, apply,
|
|
7
|
+
* destroy, and rendering without consumer lifecycle wiring.
|
|
8
|
+
*/
|
|
9
|
+
export class ResourceStackDefinition extends Context.Service<ResourceStackDefinition>()(
|
|
10
|
+
"nomoss/core/resourceStackDefinition",
|
|
11
|
+
{
|
|
12
|
+
make: Effect.succeed({
|
|
13
|
+
stackName: "",
|
|
14
|
+
declare: Effect.fn("ResourceStackDefinition.declare")(function* () {}),
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
) {}
|