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,239 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Array as Arr,
|
|
3
|
+
Console,
|
|
4
|
+
Context,
|
|
5
|
+
Effect,
|
|
6
|
+
Record as EffectRecord,
|
|
7
|
+
Formatter,
|
|
8
|
+
Match,
|
|
9
|
+
Option,
|
|
10
|
+
Schema,
|
|
11
|
+
} from "effect";
|
|
12
|
+
|
|
13
|
+
import { keyString, type ResourcePlan } from "./model.js";
|
|
14
|
+
import type {
|
|
15
|
+
ResourceApplyResult,
|
|
16
|
+
ResourceDestroyResult,
|
|
17
|
+
} from "./resourceStackLifecycle.js";
|
|
18
|
+
|
|
19
|
+
const ResourceOutputSummarySchema = Schema.Record(Schema.String, Schema.Json);
|
|
20
|
+
|
|
21
|
+
/** Formats resource outputs while keeping Stripe webhook state secret-free in CLI output. */
|
|
22
|
+
const renderResourceOutputSummary = (node: {
|
|
23
|
+
readonly outputs: unknown;
|
|
24
|
+
readonly schema: { readonly provider: string; readonly resource: string };
|
|
25
|
+
}) =>
|
|
26
|
+
Option.getOrElse(
|
|
27
|
+
Option.filter(
|
|
28
|
+
Option.map(
|
|
29
|
+
Schema.decodeUnknownOption(ResourceOutputSummarySchema)(node.outputs),
|
|
30
|
+
(outputs) =>
|
|
31
|
+
Arr.map(EffectRecord.toEntries(outputs), ([key, value]) =>
|
|
32
|
+
Match.value({
|
|
33
|
+
key,
|
|
34
|
+
provider: node.schema.provider,
|
|
35
|
+
resource: node.schema.resource,
|
|
36
|
+
}).pipe(
|
|
37
|
+
Match.when(
|
|
38
|
+
{
|
|
39
|
+
key: "WebhookSigningSecret",
|
|
40
|
+
provider: "stripe",
|
|
41
|
+
resource: "webhook-endpoint",
|
|
42
|
+
},
|
|
43
|
+
() => "WebhookSigningSecret=<redacted>",
|
|
44
|
+
),
|
|
45
|
+
Match.orElse(() => `${key}=${Formatter.format(value)}`),
|
|
46
|
+
),
|
|
47
|
+
).join(" "),
|
|
48
|
+
),
|
|
49
|
+
(summary) => summary.length > 0,
|
|
50
|
+
),
|
|
51
|
+
() => "",
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const resourceOutputLabel = (
|
|
55
|
+
resourcesByKey: ReadonlyMap<
|
|
56
|
+
string,
|
|
57
|
+
{
|
|
58
|
+
readonly outputs: unknown;
|
|
59
|
+
readonly schema: { readonly provider: string; readonly resource: string };
|
|
60
|
+
}
|
|
61
|
+
>,
|
|
62
|
+
key: string,
|
|
63
|
+
) =>
|
|
64
|
+
Option.getOrElse(
|
|
65
|
+
Option.map(
|
|
66
|
+
Option.fromUndefinedOr(resourcesByKey.get(key)),
|
|
67
|
+
renderResourceOutputSummary,
|
|
68
|
+
),
|
|
69
|
+
() => "",
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const renderApplyAction = (
|
|
73
|
+
action: ResourceApplyResult["plan"]["createOrUpdate"][number][number],
|
|
74
|
+
resourcesByKey: ReadonlyMap<
|
|
75
|
+
string,
|
|
76
|
+
{
|
|
77
|
+
readonly outputs: unknown;
|
|
78
|
+
readonly schema: { readonly provider: string; readonly resource: string };
|
|
79
|
+
}
|
|
80
|
+
>,
|
|
81
|
+
) => {
|
|
82
|
+
const label = resourceOutputLabel(resourcesByKey, keyString(action.node.key));
|
|
83
|
+
|
|
84
|
+
return Match.value(action).pipe(
|
|
85
|
+
Match.when(
|
|
86
|
+
{ _tag: "Create" },
|
|
87
|
+
({ node }) =>
|
|
88
|
+
`\u001b[32m[+] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId} created ${label}\u001b[0m`,
|
|
89
|
+
),
|
|
90
|
+
Match.when(
|
|
91
|
+
{ _tag: "Update" },
|
|
92
|
+
({ node }) =>
|
|
93
|
+
`\u001b[33m[~] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId} updated ${label}\u001b[0m`,
|
|
94
|
+
),
|
|
95
|
+
Match.orElse(
|
|
96
|
+
({ node }) =>
|
|
97
|
+
`\u001b[31m[-] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId}\u001b[0m`,
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const renderDestroyAction = (
|
|
103
|
+
action: ResourceDestroyResult["plan"]["destroy"][number][number],
|
|
104
|
+
resourcesByKey: ReadonlyMap<
|
|
105
|
+
string,
|
|
106
|
+
{
|
|
107
|
+
readonly outputs: unknown;
|
|
108
|
+
readonly schema: { readonly provider: string; readonly resource: string };
|
|
109
|
+
}
|
|
110
|
+
>,
|
|
111
|
+
) => {
|
|
112
|
+
const label = resourceOutputLabel(resourcesByKey, keyString(action.node.key));
|
|
113
|
+
|
|
114
|
+
return Match.value(action).pipe(
|
|
115
|
+
Match.when(
|
|
116
|
+
{ _tag: "Destroy" },
|
|
117
|
+
({ node }) =>
|
|
118
|
+
`\u001b[31m[-] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId} destroyed ${label}\u001b[0m`,
|
|
119
|
+
),
|
|
120
|
+
Match.orElse(
|
|
121
|
+
({ node }) =>
|
|
122
|
+
`\u001b[31m[-] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId}\u001b[0m`,
|
|
123
|
+
),
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resource applications use this service for operator output after the core
|
|
129
|
+
* planner and lifecycle return structured stack results. The service keeps
|
|
130
|
+
* display formatting in core so provider packages do not define app-facing
|
|
131
|
+
* workflow renderers.
|
|
132
|
+
*/
|
|
133
|
+
export class StackWorkflowRenderer extends Context.Service<StackWorkflowRenderer>()(
|
|
134
|
+
"nomoss/core/stackWorkflowRenderer",
|
|
135
|
+
{
|
|
136
|
+
make: Effect.succeed({
|
|
137
|
+
renderPlan: Effect.fn("StackWorkflowRenderer.renderPlan")(
|
|
138
|
+
function* (input: {
|
|
139
|
+
readonly stackName: string;
|
|
140
|
+
readonly plan: ResourcePlan;
|
|
141
|
+
}) {
|
|
142
|
+
const actions = Arr.appendAll(
|
|
143
|
+
Arr.flatten(input.plan.createOrUpdate),
|
|
144
|
+
Arr.appendAll(
|
|
145
|
+
Arr.flatten(input.plan.delete),
|
|
146
|
+
Arr.flatten(input.plan.destroy),
|
|
147
|
+
),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
yield* Console.log(`Stack "${input.stackName}"`);
|
|
151
|
+
yield* Console.log("Resources");
|
|
152
|
+
yield* Effect.forEach(
|
|
153
|
+
actions,
|
|
154
|
+
(action) =>
|
|
155
|
+
Console.log(
|
|
156
|
+
Match.value(action).pipe(
|
|
157
|
+
Match.tagsExhaustive({
|
|
158
|
+
Create: ({ node }) =>
|
|
159
|
+
`\u001b[32m[+] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId}\u001b[0m`,
|
|
160
|
+
Update: ({ node }) =>
|
|
161
|
+
`\u001b[33m[~] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId}\u001b[0m`,
|
|
162
|
+
Delete: ({ node }) =>
|
|
163
|
+
`\u001b[31m[-] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId}\u001b[0m`,
|
|
164
|
+
Destroy: ({ node }) =>
|
|
165
|
+
`\u001b[31m[-] ${node.schema.provider}:${node.schema.service}:${node.schema.resource} ${node.key.logicalId}\u001b[0m`,
|
|
166
|
+
}),
|
|
167
|
+
),
|
|
168
|
+
),
|
|
169
|
+
{
|
|
170
|
+
discard: true,
|
|
171
|
+
},
|
|
172
|
+
);
|
|
173
|
+
yield* Option.match(
|
|
174
|
+
Option.liftPredicate(actions, (value) => value.length === 0),
|
|
175
|
+
{
|
|
176
|
+
onNone: () => Effect.void,
|
|
177
|
+
onSome: () =>
|
|
178
|
+
Console.log(`no changes for stack ${input.stackName}`),
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
),
|
|
183
|
+
|
|
184
|
+
renderApplyResult: Effect.fn("StackWorkflowRenderer.renderApplyResult")(
|
|
185
|
+
function* (result: ResourceApplyResult) {
|
|
186
|
+
const resourcesByKey = new Map(
|
|
187
|
+
Arr.map(result.resources, (node) => [keyString(node.key), node]),
|
|
188
|
+
);
|
|
189
|
+
const actions = Arr.flatten(result.plan.createOrUpdate);
|
|
190
|
+
|
|
191
|
+
yield* Console.log(`Stack "${result.stackName}"`);
|
|
192
|
+
yield* Console.log("Resources");
|
|
193
|
+
yield* Effect.forEach(
|
|
194
|
+
actions,
|
|
195
|
+
(action) => Console.log(renderApplyAction(action, resourcesByKey)),
|
|
196
|
+
{
|
|
197
|
+
discard: true,
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
yield* Option.match(
|
|
201
|
+
Option.liftPredicate(actions, (value) => value.length === 0),
|
|
202
|
+
{
|
|
203
|
+
onNone: () => Effect.void,
|
|
204
|
+
onSome: () =>
|
|
205
|
+
Console.log(`no changes for stack ${result.stackName}`),
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
},
|
|
209
|
+
),
|
|
210
|
+
|
|
211
|
+
renderDestroyResult: Effect.fn(
|
|
212
|
+
"StackWorkflowRenderer.renderDestroyResult",
|
|
213
|
+
)(function* (result: ResourceDestroyResult) {
|
|
214
|
+
const resourcesByKey = new Map(
|
|
215
|
+
Arr.map(result.resources, (node) => [keyString(node.key), node]),
|
|
216
|
+
);
|
|
217
|
+
const actions = Arr.flatten(result.plan.destroy);
|
|
218
|
+
|
|
219
|
+
yield* Console.log(`Stack "${result.stackName}"`);
|
|
220
|
+
yield* Console.log("Resources");
|
|
221
|
+
yield* Effect.forEach(
|
|
222
|
+
actions,
|
|
223
|
+
(action) => Console.log(renderDestroyAction(action, resourcesByKey)),
|
|
224
|
+
{
|
|
225
|
+
discard: true,
|
|
226
|
+
},
|
|
227
|
+
);
|
|
228
|
+
yield* Option.match(
|
|
229
|
+
Option.liftPredicate(actions, (value) => value.length === 0),
|
|
230
|
+
{
|
|
231
|
+
onNone: () => Effect.void,
|
|
232
|
+
onSome: () =>
|
|
233
|
+
Console.log(`no changes for stack ${result.stackName}`),
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
}),
|
|
237
|
+
}),
|
|
238
|
+
},
|
|
239
|
+
) {}
|