nomoss 0.0.3 → 0.0.4
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/CHANGELOG.md +27 -0
- package/README.md +5 -15
- package/ROADMAP.md +2 -0
- package/docs/README.md +1 -1
- package/docs/application/aws-resource-coverage.md +26 -0
- package/docs/application/aws-resource-lifecycle-management.md +13 -23
- package/docs/application/cli-workflow.md +1 -1
- package/docs/application/engine-design.md +2 -2
- package/docs/application/generation-architecture.md +10 -45
- package/docs/application/resource-command-policy-stage.md +2 -2
- package/docs/application/resource-graph.md +1 -1
- package/docs/application/resource-lifecycle-tracker.md +1 -9
- package/docs/application/resource-mapping.md +4 -9
- package/docs/application/resource-operations.md +4 -2
- package/docs/application/tracing.md +2 -6
- package/docs/development/code-documentation.md +2 -0
- package/docs/development/effect-native-development.md +44 -0
- package/docs/development/linting.md +1 -1
- package/docs/development/review-code.md +22 -6
- package/docs/development/review-remediation-spec.md +28 -37
- package/docs/development/spec-writing.md +1 -1
- package/docs/development/testing.md +23 -9
- package/docs/operations/observability-sop.md +11 -17
- package/docs/operations/releasing.md +3 -1
- package/examples/README.md +3 -26
- package/examples/commands.ts +2 -36
- package/examples/queue/application.ts +8 -2
- package/examples/state-machine/application.ts +3 -1
- package/package.json +40 -46
- package/providers/aws/README.md +21 -0
- package/providers/aws/awsEnvironment.ts +114 -0
- package/providers/aws/generated/managementRegistry.ts +136 -0
- package/{src/providers/aws/resources/generated/native/apigatewayv2/api/index.ts → providers/aws/generated/resources/apigatewayv2/api.ts} +13 -50
- package/{src/providers/aws/resources/generated/native/apigatewayv2/integration/index.ts → providers/aws/generated/resources/apigatewayv2/integration.ts} +13 -37
- package/{src/providers/aws/resources/generated/native/apigatewayv2/route/index.ts → providers/aws/generated/resources/apigatewayv2/route.ts} +23 -40
- package/{src/providers/aws/resources/generated/native/apigatewayv2/stage/index.ts → providers/aws/generated/resources/apigatewayv2/stage.ts} +13 -38
- package/providers/aws/generated/resources/iam/accesskey.ts +184 -0
- package/{src/providers/aws/resources/generated/native/iam/group/index.ts → providers/aws/generated/resources/iam/group.ts} +13 -38
- package/{src/providers/aws/resources/generated/native/iam/grouppolicy/index.ts → providers/aws/generated/resources/iam/grouppolicy.ts} +29 -59
- package/{src/providers/aws/resources/generated/native/iam/instanceprofile/index.ts → providers/aws/generated/resources/iam/instanceprofile.ts} +13 -41
- package/{src/providers/aws/resources/generated/native/iam/managedpolicy/index.ts → providers/aws/generated/resources/iam/managedpolicy.ts} +13 -95
- package/providers/aws/generated/resources/iam/oidcprovider.ts +314 -0
- package/{src/providers/aws/resources/generated/native/iam/policy/index.ts → providers/aws/generated/resources/iam/policy.ts} +13 -28
- package/{src/providers/aws/resources/generated/native/iam/role/index.ts → providers/aws/generated/resources/iam/role.ts} +13 -47
- package/{src/providers/aws/resources/generated/native/iam/rolepolicy/index.ts → providers/aws/generated/resources/iam/rolepolicy.ts} +29 -59
- package/providers/aws/generated/resources/iam/samlprovider.ts +463 -0
- package/providers/aws/generated/resources/iam/servercertificate.ts +465 -0
- package/providers/aws/generated/resources/iam/servicelinkedrole.ts +187 -0
- package/{src/providers/aws/resources/generated/native/iam/user/index.ts → providers/aws/generated/resources/iam/user.ts} +13 -38
- package/{src/providers/aws/resources/generated/native/iam/userpolicy/index.ts → providers/aws/generated/resources/iam/userpolicy.ts} +29 -59
- package/{src/providers/aws/resources/generated/native/iam/usertogroupaddition/index.ts → providers/aws/generated/resources/iam/usertogroupaddition.ts} +13 -27
- package/providers/aws/generated/resources/iam/virtualmfadevice.ts +298 -0
- package/{src/providers/aws/resources/generated/native/kms/key/index.ts → providers/aws/generated/resources/kms/key.ts} +13 -41
- package/{src/providers/aws/resources/generated/native/lambda/function/index.ts → providers/aws/generated/resources/lambda/function.ts} +13 -63
- package/{src/providers/aws/resources/generated/native/lambda/permission/index.ts → providers/aws/generated/resources/lambda/permission.ts} +13 -55
- package/{src/providers/aws/resources/generated/native/s3/bucket/index.ts → providers/aws/generated/resources/s3/bucket.ts} +14 -104
- package/{src/providers/aws/resources/generated/native/sns/topic/index.ts → providers/aws/generated/resources/sns/topic.ts} +14 -29
- package/{src/providers/aws/resources/generated/native/sqs/queue/index.ts → providers/aws/generated/resources/sqs/queue.ts} +14 -38
- package/{src/providers/aws/resources/generated/native/stepfunctions/statemachine/index.ts → providers/aws/generated/resources/stepfunctions/statemachine.ts} +15 -58
- package/providers/aws/management/mappings/iam/group.ts +63 -0
- package/providers/aws/management/mappings/iam/iamIdentity.ts +41 -0
- package/providers/aws/management/mappings/iam/iamLifecycleSettings.ts +8 -0
- package/providers/aws/management/mappings/iam/inlinePolicies.ts +159 -0
- package/providers/aws/management/mappings/iam/instanceProfile.ts +77 -0
- package/providers/aws/management/mappings/iam/oidcProvider.ts +94 -0
- package/providers/aws/management/mappings/iam/role.ts +74 -0
- package/providers/aws/management/mappings/iam/samlProvider.ts +98 -0
- package/providers/aws/management/mappings/iam/serverCertificate.ts +72 -0
- package/providers/aws/management/mappings/iam/user.ts +61 -0
- package/providers/aws/management/mappings/iam/userToGroupAddition.ts +75 -0
- package/providers/aws/management/operations/iam/accessKey.ts +206 -0
- package/providers/aws/management/operations/iam/managedPolicy.ts +491 -0
- package/providers/aws/management/operations/iam/policy.ts +476 -0
- package/providers/aws/management/operations/iam/serviceLinkedRole.ts +172 -0
- package/providers/aws/management/operations/iam/virtualMfaDevice.ts +253 -0
- package/providers/aws/management/resourceAssociationConfiguration.ts +112 -0
- package/providers/aws/management/resourceAssociationRegistration.ts +349 -0
- package/providers/aws/management/resourceAssociations.ts +168 -0
- package/{src/providers → providers}/aws/management/resourceConfiguration.ts +24 -26
- package/providers/aws/management/resourceLifecycleRegistration.ts +540 -0
- package/providers/aws/management/resourceManagementModule.ts +31 -0
- package/providers/aws/management/resourceManagementRegistry.ts +62 -0
- package/providers/aws/management/resourceMapping.ts +84 -0
- package/providers/aws/management/resourceOperation.ts +134 -0
- package/providers/aws/management/resourceTagOperations.ts +108 -0
- package/providers/aws/management/resourceTiming.ts +4 -0
- package/providers/aws/runtime.ts +52 -0
- package/src/core/resource/resourceCommandPolicy.ts +20 -0
- package/src/core/resource/resourceLifecycle.ts +644 -0
- package/src/core/resource/resourceStabilization.ts +120 -0
- package/src/core/resource/resourceVersions.ts +102 -0
- package/src/core/stack/planner.ts +9 -0
- package/src/core/stack/resourceStackLifecycle.ts +36 -3
- package/src/core/state/resourceState.ts +6 -4
- package/src/core/state/stateStore.ts +57 -10
- package/src/providers/file/resourcePolicy.ts +13 -12
- package/src/providers/providerRuntimeLayer.ts +5 -2
- package/src/providers/resourceCommandPolicyLayer.ts +117 -37
- package/src/providers/stripe/management/resourcePolicy.ts +22 -11
- package/examples/http-echo/application.ts +0 -87
- package/src/providers/aws/client/awsClient.ts +0 -418
- package/src/providers/aws/client/awsClientConfig.ts +0 -133
- package/src/providers/aws/client/awsClientModel.ts +0 -119
- package/src/providers/aws/client/awsHttpOperation.ts +0 -153
- package/src/providers/aws/client/awsQueryOperation.ts +0 -149
- package/src/providers/aws/client/awsRequestSigner.ts +0 -115
- package/src/providers/aws/client/awsResponseDecoder.ts +0 -135
- package/src/providers/aws/client/awsRetryPolicy.ts +0 -62
- package/src/providers/aws/client/generated/apiGatewayV2.ts +0 -3025
- package/src/providers/aws/client/generated/cloudControl.ts +0 -5746
- package/src/providers/aws/client/generated/iam.ts +0 -10892
- package/src/providers/aws/client/generated/lambda.ts +0 -5403
- package/src/providers/aws/client/generated/sqs.ts +0 -3769
- package/src/providers/aws/client/generated/stepFunctions.ts +0 -1726
- package/src/providers/aws/client/openapi/cloudControl/CancelResourceRequest.json +0 -579
- package/src/providers/aws/client/openapi/cloudControl/CreateResource.json +0 -1019
- package/src/providers/aws/client/openapi/cloudControl/DeleteResource.json +0 -1018
- package/src/providers/aws/client/openapi/cloudControl/GetResource.json +0 -883
- package/src/providers/aws/client/openapi/cloudControl/GetResourceRequestStatus.json +0 -655
- package/src/providers/aws/client/openapi/cloudControl/ListResourceRequests.json +0 -566
- package/src/providers/aws/client/openapi/cloudControl/ListResources.json +0 -913
- package/src/providers/aws/client/openapi/cloudControl/UpdateResource.json +0 -1027
- package/src/providers/aws/cloudControl/client.ts +0 -69
- package/src/providers/aws/cloudControl/requestTracker.ts +0 -138
- package/src/providers/aws/cloudControl/resourceCommandPolicyLayer.ts +0 -63
- package/src/providers/aws/cloudControl/resourceLifecycle.ts +0 -479
- package/src/providers/aws/cloudControl/resources/generated/certificatemanager/certificate/index.ts +0 -179
- package/src/providers/aws/cloudControl/resources/generated/kms/key/index.ts +0 -362
- package/src/providers/aws/cloudControl/resources/generated/s3/bucket/index.ts +0 -2364
- package/src/providers/aws/cloudControl/resources/generated/sns/topic/index.ts +0 -326
- package/src/providers/aws/cloudControl/resources/generated/sqs/queue/index.ts +0 -307
- package/src/providers/aws/cloudControl/resources/generated/sqs/queueinlinepolicy/index.ts +0 -108
- package/src/providers/aws/cloudControl/runtime.ts +0 -127
- package/src/providers/aws/management/resourceMapping.ts +0 -343
- package/src/providers/aws/management/resourceOperation.ts +0 -57
- package/src/providers/aws/management/resourcePolicy.ts +0 -549
- package/src/providers/aws/management/resourceRegistration.ts +0 -294
- package/src/providers/aws/resources/apiGatewayV2/httpApi.ts +0 -327
- package/src/providers/aws/resources/generated/native/resourceCommands.ts +0 -152
- package/src/providers/aws/resources/iam/grant.ts +0 -150
- package/src/providers/aws/resources/iam/grantCommands.ts +0 -283
- package/src/providers/aws/resources/iam/policyDocument.ts +0 -30
- package/src/providers/aws/resources/iam/policyStatement.ts +0 -59
- package/src/providers/aws/resources/iam/role.ts +0 -426
- package/src/providers/aws/resources/iam/roleDeclaration.ts +0 -105
- package/src/providers/aws/resources/lambda/function.ts +0 -403
- package/src/providers/aws/resources/lambda/functionDeclaration.ts +0 -234
- package/src/providers/aws/resources/lambda/permission.ts +0 -363
- package/src/providers/aws/resources/stepFunctions/stateMachine.ts +0 -95
- package/src/providers/aws/runtime.ts +0 -70
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Array as Arr,
|
|
3
|
-
type Duration,
|
|
4
|
-
Effect,
|
|
5
|
-
Layer,
|
|
6
|
-
Match,
|
|
7
|
-
Option,
|
|
8
|
-
Record,
|
|
9
|
-
Schedule,
|
|
10
|
-
Schema,
|
|
11
|
-
} from "effect";
|
|
12
|
-
import {
|
|
13
|
-
ResourceCommand,
|
|
14
|
-
ResourceCommandResult,
|
|
15
|
-
ResourceCommandUnsupported,
|
|
16
|
-
ResourceObservation,
|
|
17
|
-
} from "../../../core/resource/lifecycle.js";
|
|
18
|
-
import {
|
|
19
|
-
ResourceModel,
|
|
20
|
-
type ResourceNode,
|
|
21
|
-
type ResourceSchemaAnnotation,
|
|
22
|
-
resourceModelLayer,
|
|
23
|
-
} from "../../../core/resource/model.js";
|
|
24
|
-
import { ResourceCommandExecutionFailed } from "../../../core/resource/resourceCommandPolicy.js";
|
|
25
|
-
import { providerCommandPolicyTag } from "../../resourceCommandPolicyLayer.js";
|
|
26
|
-
import { AwsClient } from "../client/awsClient.js";
|
|
27
|
-
import type {
|
|
28
|
-
AwsJsonRpcPayload,
|
|
29
|
-
AwsOperation,
|
|
30
|
-
AwsServiceDefinition,
|
|
31
|
-
AwsServiceError,
|
|
32
|
-
} from "../client/awsClientModel.js";
|
|
33
|
-
|
|
34
|
-
type Operation<Output> = AwsOperation & {
|
|
35
|
-
readonly input: Schema.Codec<Schema.JsonObject, AwsJsonRpcPayload>;
|
|
36
|
-
readonly output: Schema.Codec<Output, unknown>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The awsResourceRegistration function supplies a lifecycle Layer for
|
|
41
|
-
* resources that use one AWS call per change. The read input schema selects
|
|
42
|
-
* the identity from the create request and response. This lets child
|
|
43
|
-
* resources retain parent identifiers that AWS omits from its reply.
|
|
44
|
-
*
|
|
45
|
-
* The Layer waits for reads to confirm a change. The optional readiness
|
|
46
|
-
* check lets a provider keep waiting after an object first appears. Core
|
|
47
|
-
* releases ownership when a post-delete read returns a configured
|
|
48
|
-
* missing-resource error. A provider can select rejected creates that may
|
|
49
|
-
* succeed after propagation. The retry window retains the last AWS error.
|
|
50
|
-
*
|
|
51
|
-
* @see ../../../../../command-options-fund/refs/effect/packages/effect/src/Schedule.ts (upTo)
|
|
52
|
-
*/
|
|
53
|
-
export const awsResourceRegistration = (
|
|
54
|
-
schema: ResourceSchemaAnnotation,
|
|
55
|
-
definition: {
|
|
56
|
-
readonly service: AwsServiceDefinition;
|
|
57
|
-
readonly create: Operation<Schema.JsonObject>;
|
|
58
|
-
readonly read: Operation<Schema.JsonObject>;
|
|
59
|
-
readonly update: Operation<unknown>;
|
|
60
|
-
readonly remove: Operation<unknown>;
|
|
61
|
-
readonly missingErrors: ReadonlyArray<string>;
|
|
62
|
-
readonly timeout: Duration.Input;
|
|
63
|
-
readonly ready?: (observation: Schema.JsonObject) => boolean;
|
|
64
|
-
readonly retryCreate?: (error: AwsServiceError) => boolean;
|
|
65
|
-
},
|
|
66
|
-
) =>
|
|
67
|
-
Layer.effect(
|
|
68
|
-
providerCommandPolicyTag(schema),
|
|
69
|
-
Effect.gen(function* () {
|
|
70
|
-
const model = yield* ResourceModel;
|
|
71
|
-
const client = yield* AwsClient;
|
|
72
|
-
|
|
73
|
-
const bindOperation = client.bindOperation(definition.service);
|
|
74
|
-
|
|
75
|
-
const bind = <Output>(operation: Operation<Output>) => {
|
|
76
|
-
const call = bindOperation(operation);
|
|
77
|
-
const input = Schema.decodeUnknownEffect(
|
|
78
|
-
Schema.toType(operation.input),
|
|
79
|
-
{
|
|
80
|
-
onExcessProperty: "error",
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
return (value: Schema.JsonObject) =>
|
|
85
|
-
input(value).pipe(Effect.flatMap(call));
|
|
86
|
-
};
|
|
87
|
-
const createResource = bind(definition.create);
|
|
88
|
-
const readResource = bind(definition.read);
|
|
89
|
-
const updateResource = bind(definition.update);
|
|
90
|
-
const removeResource = bind(definition.remove);
|
|
91
|
-
|
|
92
|
-
const readIdentity = Schema.decodeUnknownEffect(
|
|
93
|
-
Schema.toType(definition.read.input),
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const isMissing = (failure: { readonly _tag: string }) =>
|
|
97
|
-
failure._tag === "AwsServiceError" &&
|
|
98
|
-
"code" in failure &&
|
|
99
|
-
Arr.contains(definition.missingErrors, failure.code);
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The readProvider operation carries forward identity fields that the
|
|
103
|
-
* provider omits. Fields AWS does return take precedence so the caller
|
|
104
|
-
* can detect an identity mismatch.
|
|
105
|
-
*/
|
|
106
|
-
const readProvider = Effect.fn("AwsResource.readProvider")(function* (
|
|
107
|
-
node: ResourceNode,
|
|
108
|
-
) {
|
|
109
|
-
const identity = yield* readIdentity(node.outputs);
|
|
110
|
-
|
|
111
|
-
const observation: Option.Option<Schema.JsonObject> =
|
|
112
|
-
yield* readResource(identity).pipe(
|
|
113
|
-
Effect.map((fields) => Option.some({ ...identity, ...fields })),
|
|
114
|
-
Effect.catchIf(isMissing, () => Effect.succeedNone),
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
return observation;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const read = Effect.fn("AwsResource.read")(function* (
|
|
121
|
-
node: ResourceNode,
|
|
122
|
-
) {
|
|
123
|
-
const observation = yield* readProvider(node);
|
|
124
|
-
|
|
125
|
-
return yield* observation.pipe(
|
|
126
|
-
Option.map((observed) =>
|
|
127
|
-
model
|
|
128
|
-
.withObservedOutputs(node, observed)
|
|
129
|
-
.pipe(Effect.map((node) => ({ node, observed }))),
|
|
130
|
-
),
|
|
131
|
-
Effect.transposeOption,
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const waitFor = (
|
|
136
|
-
node: ResourceNode,
|
|
137
|
-
accepts: (state: Schema.JsonObject) => boolean,
|
|
138
|
-
) =>
|
|
139
|
-
read(node).pipe(
|
|
140
|
-
Effect.repeat({
|
|
141
|
-
while: (state) =>
|
|
142
|
-
!Option.exists(
|
|
143
|
-
state,
|
|
144
|
-
({ observed }) =>
|
|
145
|
-
(definition.ready?.(observed) ?? true) && accepts(observed),
|
|
146
|
-
),
|
|
147
|
-
schedule: Schedule.spaced("1 second"),
|
|
148
|
-
}),
|
|
149
|
-
Effect.timeout(definition.timeout),
|
|
150
|
-
Effect.flatMap(Effect.fromOption),
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
const create = Effect.fn("AwsResource.create")(function* (
|
|
154
|
-
node: ResourceNode,
|
|
155
|
-
) {
|
|
156
|
-
const properties = yield* model.decodeProps(node, Schema.JsonObject);
|
|
157
|
-
|
|
158
|
-
const request = createResource(properties);
|
|
159
|
-
|
|
160
|
-
const created = yield* Option.fromUndefinedOr(
|
|
161
|
-
definition.retryCreate,
|
|
162
|
-
).pipe(
|
|
163
|
-
Option.match({
|
|
164
|
-
onNone: () => request,
|
|
165
|
-
onSome: (retryCreate) =>
|
|
166
|
-
request.pipe(
|
|
167
|
-
Effect.retry({
|
|
168
|
-
while: (failure) =>
|
|
169
|
-
failure._tag === "AwsServiceError" && retryCreate(failure),
|
|
170
|
-
schedule: Schedule.spaced("1 second").pipe(
|
|
171
|
-
Schedule.upTo({ duration: definition.timeout }),
|
|
172
|
-
),
|
|
173
|
-
}),
|
|
174
|
-
),
|
|
175
|
-
}),
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
const identityFields = { ...properties, ...created };
|
|
179
|
-
|
|
180
|
-
const identity = yield* readIdentity(identityFields);
|
|
181
|
-
|
|
182
|
-
const identified = yield* model.withOutputs(node, identity);
|
|
183
|
-
|
|
184
|
-
const observed = yield* waitFor(identified, () => true);
|
|
185
|
-
|
|
186
|
-
return ResourceCommandResult.Created({ node: observed.node });
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const update = Effect.fn("AwsResource.update")(function* (
|
|
190
|
-
node: ResourceNode,
|
|
191
|
-
current: ResourceNode,
|
|
192
|
-
) {
|
|
193
|
-
const desired = yield* model.decodeProps(node, Schema.JsonObject);
|
|
194
|
-
const saved = yield* model.decodeProps(current, Schema.JsonObject);
|
|
195
|
-
const equivalent = Schema.toEquivalence(Schema.Json);
|
|
196
|
-
const sameProps = Record.isSubrecordBy(equivalent);
|
|
197
|
-
yield* Effect.fail(
|
|
198
|
-
new ResourceCommandUnsupported({
|
|
199
|
-
command: ResourceCommand.Apply({
|
|
200
|
-
decision: { _tag: "Update", node, current },
|
|
201
|
-
}),
|
|
202
|
-
}),
|
|
203
|
-
).pipe(
|
|
204
|
-
Effect.when(
|
|
205
|
-
Effect.succeed(
|
|
206
|
-
Record.keys(saved).some(
|
|
207
|
-
(property) => !Record.has(desired, property),
|
|
208
|
-
),
|
|
209
|
-
),
|
|
210
|
-
),
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
const changes = Record.filter(
|
|
214
|
-
desired,
|
|
215
|
-
(value, property) =>
|
|
216
|
-
!Record.has(saved, property) || !equivalent(value, saved[property]),
|
|
217
|
-
);
|
|
218
|
-
const identity = yield* Schema.decodeUnknownEffect(
|
|
219
|
-
Schema.toType(definition.read.input),
|
|
220
|
-
)(current.outputs);
|
|
221
|
-
|
|
222
|
-
yield* updateResource({ ...changes, ...identity });
|
|
223
|
-
const identified = yield* model.withOutputs(node, current.outputs);
|
|
224
|
-
const observed = yield* waitFor(identified, (state) =>
|
|
225
|
-
sameProps(changes, state),
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
return ResourceCommandResult.Updated({ node: observed.node });
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
const destroy = Effect.fn("AwsResource.destroy")(function* (
|
|
232
|
-
node: ResourceNode,
|
|
233
|
-
) {
|
|
234
|
-
const identity = yield* Schema.decodeUnknownEffect(
|
|
235
|
-
Schema.toType(definition.remove.input),
|
|
236
|
-
)(node.outputs);
|
|
237
|
-
yield* removeResource(identity).pipe(
|
|
238
|
-
Effect.asVoid,
|
|
239
|
-
Effect.catchIf(isMissing, () => Effect.void),
|
|
240
|
-
);
|
|
241
|
-
yield* readProvider(node).pipe(
|
|
242
|
-
Effect.repeat({
|
|
243
|
-
while: Option.isSome,
|
|
244
|
-
schedule: Schedule.spaced("1 second"),
|
|
245
|
-
}),
|
|
246
|
-
Effect.timeout(definition.timeout),
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
return ResourceCommandResult.Destroyed({ node });
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const execute = Effect.fn("AwsResource.execute")(
|
|
253
|
-
(command: ResourceCommand) =>
|
|
254
|
-
Match.value(command).pipe(
|
|
255
|
-
Match.tag("Read", ({ node }) =>
|
|
256
|
-
read(node).pipe(
|
|
257
|
-
Effect.map((result) => {
|
|
258
|
-
const observation = Option.match(result, {
|
|
259
|
-
onNone: () => ResourceObservation.Missing({ node }),
|
|
260
|
-
onSome: ResourceObservation.Present,
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
return ResourceCommandResult.Observed({ observation });
|
|
264
|
-
}),
|
|
265
|
-
),
|
|
266
|
-
),
|
|
267
|
-
Match.tag("Create", ({ node }) => create(node)),
|
|
268
|
-
Match.tag("Delete", "Destroy", ({ node }) => destroy(node)),
|
|
269
|
-
Match.tag("Apply", ({ decision }) =>
|
|
270
|
-
Match.value(decision).pipe(
|
|
271
|
-
Match.tag("Create", ({ node }) => create(node)),
|
|
272
|
-
Match.tag("Update", ({ node, current }) =>
|
|
273
|
-
update(node, current),
|
|
274
|
-
),
|
|
275
|
-
Match.tag("Delete", "Destroy", ({ node }) => destroy(node)),
|
|
276
|
-
Match.orElse(() =>
|
|
277
|
-
Effect.fail(new ResourceCommandUnsupported({ command })),
|
|
278
|
-
),
|
|
279
|
-
),
|
|
280
|
-
),
|
|
281
|
-
Match.orElse(() =>
|
|
282
|
-
Effect.fail(new ResourceCommandUnsupported({ command })),
|
|
283
|
-
),
|
|
284
|
-
),
|
|
285
|
-
(effect, command) =>
|
|
286
|
-
Effect.mapError(
|
|
287
|
-
effect,
|
|
288
|
-
(cause) => new ResourceCommandExecutionFailed({ command, cause }),
|
|
289
|
-
),
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
return { execute };
|
|
293
|
-
}),
|
|
294
|
-
).pipe(Layer.provide(resourceModelLayer));
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { Layer, Match, Schema, SchemaGetter, String as Str } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
AuthorizationType,
|
|
4
|
-
apiGatewayV2Service,
|
|
5
|
-
createApiOperation,
|
|
6
|
-
createIntegrationOperation,
|
|
7
|
-
createRouteOperation,
|
|
8
|
-
createStageOperation,
|
|
9
|
-
deleteApiOperation,
|
|
10
|
-
deleteIntegrationOperation,
|
|
11
|
-
deleteRouteOperation,
|
|
12
|
-
deleteStageOperation,
|
|
13
|
-
getApiOperation,
|
|
14
|
-
getIntegrationOperation,
|
|
15
|
-
getRouteOperation,
|
|
16
|
-
getStageOperation,
|
|
17
|
-
IntegrationType,
|
|
18
|
-
ProtocolType,
|
|
19
|
-
updateApiOperation,
|
|
20
|
-
updateIntegrationOperation,
|
|
21
|
-
updateRouteOperation,
|
|
22
|
-
updateStageOperation,
|
|
23
|
-
} from "../../client/generated/apiGatewayV2.js";
|
|
24
|
-
import {
|
|
25
|
-
resourceRequest,
|
|
26
|
-
resourceResponse,
|
|
27
|
-
} from "../../management/resourceOperation.js";
|
|
28
|
-
import { awsResourceRegistration } from "../../management/resourceRegistration.js";
|
|
29
|
-
import { AWSApiResourceSchema } from "../generated/native/apigatewayv2/api/index.js";
|
|
30
|
-
import { AWSIntegrationResourceSchema } from "../generated/native/apigatewayv2/integration/index.js";
|
|
31
|
-
import { AWSRouteResourceSchema } from "../generated/native/apigatewayv2/route/index.js";
|
|
32
|
-
import { AWSStageResourceSchema } from "../generated/native/apigatewayv2/stage/index.js";
|
|
33
|
-
|
|
34
|
-
const service = apiGatewayV2Service;
|
|
35
|
-
const missingErrors = ["NotFoundException"];
|
|
36
|
-
const timeout = "30 seconds";
|
|
37
|
-
|
|
38
|
-
const apiIdentity = Schema.Struct({ ApiId: Schema.String });
|
|
39
|
-
|
|
40
|
-
const createdApi = apiIdentity.pipe(Schema.encodeKeys({ ApiId: "apiId" }));
|
|
41
|
-
|
|
42
|
-
const apiSettings = {
|
|
43
|
-
Description: Schema.optionalKey(Schema.String),
|
|
44
|
-
Name: Schema.optionalKey(Schema.String),
|
|
45
|
-
DisableExecuteApiEndpoint: Schema.optionalKey(Schema.Boolean),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const apiKeys = {
|
|
49
|
-
ApiId: "apiId",
|
|
50
|
-
ApiEndpoint: "apiEndpoint",
|
|
51
|
-
Description: "description",
|
|
52
|
-
DisableExecuteApiEndpoint: "disableExecuteApiEndpoint",
|
|
53
|
-
Name: "name",
|
|
54
|
-
ProtocolType: "protocolType",
|
|
55
|
-
} as const;
|
|
56
|
-
|
|
57
|
-
const observedApi = Schema.Struct({
|
|
58
|
-
...apiSettings,
|
|
59
|
-
ApiEndpoint: Schema.String,
|
|
60
|
-
ApiId: Schema.String,
|
|
61
|
-
ProtocolType,
|
|
62
|
-
}).pipe(Schema.encodeKeys(apiKeys));
|
|
63
|
-
|
|
64
|
-
const createApiRequest = Schema.Struct({
|
|
65
|
-
...apiSettings,
|
|
66
|
-
Name: Schema.String,
|
|
67
|
-
ProtocolType,
|
|
68
|
-
}).pipe(Schema.encodeKeys(apiKeys));
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The updateApiRequest codec keeps ApiId in the request path. API Gateway
|
|
72
|
-
* returns apiId in the JSON body, so the response codec uses a different key.
|
|
73
|
-
*
|
|
74
|
-
* @see ../../../../../refs/aws-api-models/models/apigatewayv2/service/2018-11-29/apigatewayv2-2018-11-29.json (UpdateApiRequest)
|
|
75
|
-
*/
|
|
76
|
-
const updateApiRequest = Schema.Struct({
|
|
77
|
-
...apiIdentity.fields,
|
|
78
|
-
...apiSettings,
|
|
79
|
-
}).pipe(Schema.encodeKeys({ ...apiKeys, ApiId: "ApiId" }));
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The apiCommands Layer saves the API ID and URL returned by API Gateway.
|
|
83
|
-
* The ID identifies the API for later calls and lets child resources link to it.
|
|
84
|
-
*/
|
|
85
|
-
const apiCommands = awsResourceRegistration(AWSApiResourceSchema, {
|
|
86
|
-
service,
|
|
87
|
-
create: resourceResponse(
|
|
88
|
-
resourceRequest(createApiOperation, createApiRequest),
|
|
89
|
-
createdApi,
|
|
90
|
-
),
|
|
91
|
-
read: resourceResponse(
|
|
92
|
-
resourceRequest(getApiOperation, apiIdentity),
|
|
93
|
-
observedApi,
|
|
94
|
-
),
|
|
95
|
-
update: resourceRequest(updateApiOperation, updateApiRequest),
|
|
96
|
-
remove: resourceRequest(deleteApiOperation, apiIdentity),
|
|
97
|
-
missingErrors,
|
|
98
|
-
timeout,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const integrationIdentity = Schema.Struct({
|
|
102
|
-
...apiIdentity.fields,
|
|
103
|
-
IntegrationId: Schema.String,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const createdIntegration = Schema.Struct({ IntegrationId: Schema.String }).pipe(
|
|
107
|
-
Schema.encodeKeys({ IntegrationId: "integrationId" }),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const integrationSettings = {
|
|
111
|
-
Description: Schema.optionalKey(Schema.String),
|
|
112
|
-
IntegrationMethod: Schema.optionalKey(Schema.String),
|
|
113
|
-
IntegrationType: Schema.optionalKey(IntegrationType),
|
|
114
|
-
IntegrationUri: Schema.optionalKey(Schema.String),
|
|
115
|
-
PayloadFormatVersion: Schema.optionalKey(Schema.String),
|
|
116
|
-
TimeoutInMillis: Schema.optionalKey(Schema.Number),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const integrationKeys = {
|
|
120
|
-
Description: "description",
|
|
121
|
-
IntegrationMethod: "integrationMethod",
|
|
122
|
-
IntegrationType: "integrationType",
|
|
123
|
-
IntegrationUri: "integrationUri",
|
|
124
|
-
PayloadFormatVersion: "payloadFormatVersion",
|
|
125
|
-
TimeoutInMillis: "timeoutInMillis",
|
|
126
|
-
} as const;
|
|
127
|
-
|
|
128
|
-
const observedIntegration = Schema.Struct({
|
|
129
|
-
...integrationSettings,
|
|
130
|
-
IntegrationId: Schema.String,
|
|
131
|
-
}).pipe(
|
|
132
|
-
Schema.encodeKeys({ ...integrationKeys, IntegrationId: "integrationId" }),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
const createIntegrationRequest = Schema.Struct({
|
|
136
|
-
...apiIdentity.fields,
|
|
137
|
-
...integrationSettings,
|
|
138
|
-
IntegrationType,
|
|
139
|
-
}).pipe(Schema.encodeKeys(integrationKeys));
|
|
140
|
-
|
|
141
|
-
const updateIntegrationRequest = Schema.Struct({
|
|
142
|
-
...integrationIdentity.fields,
|
|
143
|
-
...integrationSettings,
|
|
144
|
-
}).pipe(Schema.encodeKeys(integrationKeys));
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* The integrationCommands Layer saves the integration ID with the parent API ID.
|
|
148
|
-
* API Gateway requires both values to read, update, or delete the integration.
|
|
149
|
-
*/
|
|
150
|
-
const integrationCommands = awsResourceRegistration(
|
|
151
|
-
AWSIntegrationResourceSchema,
|
|
152
|
-
{
|
|
153
|
-
service,
|
|
154
|
-
create: resourceResponse(
|
|
155
|
-
resourceRequest(createIntegrationOperation, createIntegrationRequest),
|
|
156
|
-
createdIntegration,
|
|
157
|
-
),
|
|
158
|
-
read: resourceResponse(
|
|
159
|
-
resourceRequest(getIntegrationOperation, integrationIdentity),
|
|
160
|
-
observedIntegration,
|
|
161
|
-
),
|
|
162
|
-
update: resourceRequest(
|
|
163
|
-
updateIntegrationOperation,
|
|
164
|
-
updateIntegrationRequest,
|
|
165
|
-
),
|
|
166
|
-
remove: resourceRequest(deleteIntegrationOperation, integrationIdentity),
|
|
167
|
-
missingErrors,
|
|
168
|
-
timeout,
|
|
169
|
-
},
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const routeIdentity = Schema.Struct({
|
|
173
|
-
...apiIdentity.fields,
|
|
174
|
-
RouteId: Schema.String,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const createdRoute = Schema.Struct({ RouteId: Schema.String }).pipe(
|
|
178
|
-
Schema.encodeKeys({ RouteId: "routeId" }),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* The integrationTarget codec translates the integration identifier used by
|
|
183
|
-
* the declared entity to the API Gateway route target. Plain provider targets
|
|
184
|
-
* that already contain the integration prefix retain their spelling.
|
|
185
|
-
*
|
|
186
|
-
* @see ../../../../../refs/aws-api-models/models/apigatewayv2/service/2018-11-29/apigatewayv2-2018-11-29.json (CreateRouteRequest.Target)
|
|
187
|
-
* @see ../../../../../../command-options-fund/refs/effect/packages/effect/src/Schema.ts (decodeTo)
|
|
188
|
-
*/
|
|
189
|
-
const integrationTarget = Schema.String.pipe(
|
|
190
|
-
Schema.decodeTo(Schema.String, {
|
|
191
|
-
decode: SchemaGetter.transform(Str.replace(/^integrations\//, "")),
|
|
192
|
-
encode: SchemaGetter.transform((value) =>
|
|
193
|
-
Match.value(Str.startsWith("integrations/")(value)).pipe(
|
|
194
|
-
Match.when(true, () => value),
|
|
195
|
-
Match.orElse(() => `integrations/${value}`),
|
|
196
|
-
),
|
|
197
|
-
),
|
|
198
|
-
}),
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
const routeSettings = {
|
|
202
|
-
AuthorizationType: Schema.optionalKey(AuthorizationType),
|
|
203
|
-
RouteKey: Schema.optionalKey(Schema.String),
|
|
204
|
-
Target: Schema.optionalKey(integrationTarget),
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const routeKeys = {
|
|
208
|
-
AuthorizationType: "authorizationType",
|
|
209
|
-
RouteKey: "routeKey",
|
|
210
|
-
Target: "target",
|
|
211
|
-
} as const;
|
|
212
|
-
|
|
213
|
-
const observedRoute = Schema.Struct({
|
|
214
|
-
...routeSettings,
|
|
215
|
-
RouteId: Schema.String,
|
|
216
|
-
}).pipe(Schema.encodeKeys({ ...routeKeys, RouteId: "routeId" }));
|
|
217
|
-
|
|
218
|
-
const createRouteRequest = Schema.Struct({
|
|
219
|
-
...apiIdentity.fields,
|
|
220
|
-
...routeSettings,
|
|
221
|
-
RouteKey: Schema.String,
|
|
222
|
-
}).pipe(Schema.encodeKeys(routeKeys));
|
|
223
|
-
|
|
224
|
-
const updateRouteRequest = Schema.Struct({
|
|
225
|
-
...routeIdentity.fields,
|
|
226
|
-
...routeSettings,
|
|
227
|
-
}).pipe(Schema.encodeKeys(routeKeys));
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* The routeCommands Layer manages routes within the API that owns them.
|
|
231
|
-
* A route created from an integration entity uses the resolved ID in its
|
|
232
|
-
* route target.
|
|
233
|
-
*/
|
|
234
|
-
const routeCommands = awsResourceRegistration(AWSRouteResourceSchema, {
|
|
235
|
-
service,
|
|
236
|
-
create: resourceResponse(
|
|
237
|
-
resourceRequest(createRouteOperation, createRouteRequest),
|
|
238
|
-
createdRoute,
|
|
239
|
-
),
|
|
240
|
-
read: resourceResponse(
|
|
241
|
-
resourceRequest(getRouteOperation, routeIdentity),
|
|
242
|
-
observedRoute,
|
|
243
|
-
),
|
|
244
|
-
// The UpdateRoute operation accepts the modeled HTTP 200 and the HTTP 201
|
|
245
|
-
// observed when renaming a route. Both replies use the generated response
|
|
246
|
-
// schema through awsHttpEndpoint's supported success statuses.
|
|
247
|
-
// See refs/aws-api-models/models/apigatewayv2/service/2018-11-29/apigatewayv2-2018-11-29.json,
|
|
248
|
-
// UpdateRoute, and src/providers/aws/client/awsHttpOperation.ts.
|
|
249
|
-
update: resourceRequest(
|
|
250
|
-
{
|
|
251
|
-
...updateRouteOperation,
|
|
252
|
-
rest: {
|
|
253
|
-
...updateRouteOperation.rest,
|
|
254
|
-
status: [updateRouteOperation.rest.status, 201].flat(),
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
updateRouteRequest,
|
|
258
|
-
),
|
|
259
|
-
remove: resourceRequest(deleteRouteOperation, routeIdentity),
|
|
260
|
-
missingErrors,
|
|
261
|
-
timeout,
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
const stageIdentity = Schema.Struct({
|
|
265
|
-
...apiIdentity.fields,
|
|
266
|
-
StageName: Schema.String,
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
const stageSettings = {
|
|
270
|
-
AutoDeploy: Schema.optionalKey(Schema.Boolean),
|
|
271
|
-
Description: Schema.optionalKey(Schema.String),
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
const stageKeys = {
|
|
275
|
-
AutoDeploy: "autoDeploy",
|
|
276
|
-
Description: "description",
|
|
277
|
-
} as const;
|
|
278
|
-
|
|
279
|
-
const observedStage = Schema.Struct({
|
|
280
|
-
...stageSettings,
|
|
281
|
-
StageName: Schema.String,
|
|
282
|
-
}).pipe(Schema.encodeKeys({ ...stageKeys, StageName: "stageName" }));
|
|
283
|
-
|
|
284
|
-
const createStageRequest = Schema.Struct({
|
|
285
|
-
...stageIdentity.fields,
|
|
286
|
-
...stageSettings,
|
|
287
|
-
}).pipe(Schema.encodeKeys({ ...stageKeys, StageName: "stageName" }));
|
|
288
|
-
|
|
289
|
-
const updateStageRequest = Schema.Struct({
|
|
290
|
-
...stageIdentity.fields,
|
|
291
|
-
...stageSettings,
|
|
292
|
-
}).pipe(Schema.encodeKeys(stageKeys));
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* The stageCommands Layer addresses a stage by its name and parent API ID.
|
|
296
|
-
* The stage name is supplied by the declaration when API Gateway creates it.
|
|
297
|
-
*/
|
|
298
|
-
const stageCommands = awsResourceRegistration(AWSStageResourceSchema, {
|
|
299
|
-
service,
|
|
300
|
-
create: resourceResponse(
|
|
301
|
-
resourceRequest(createStageOperation, createStageRequest),
|
|
302
|
-
observedStage,
|
|
303
|
-
),
|
|
304
|
-
read: resourceResponse(
|
|
305
|
-
resourceRequest(getStageOperation, stageIdentity),
|
|
306
|
-
observedStage,
|
|
307
|
-
),
|
|
308
|
-
update: resourceRequest(updateStageOperation, updateStageRequest),
|
|
309
|
-
remove: resourceRequest(deleteStageOperation, stageIdentity),
|
|
310
|
-
missingErrors,
|
|
311
|
-
timeout,
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* The httpApiCommands Layer gives the AWS runtime lifecycle registrations for
|
|
316
|
-
* HTTP APIs, integrations, routes, and stages. Each resource retains its own
|
|
317
|
-
* identity so the stack can update or remove it independently.
|
|
318
|
-
*
|
|
319
|
-
* @see ../../../../../refs/aws-api-models/models/apigatewayv2/service/2018-11-29/apigatewayv2-2018-11-29.json (API, integration, route, and stage operations)
|
|
320
|
-
* @see ../../../../../../command-options-fund/refs/effect/packages/effect/src/Layer.ts (mergeAll)
|
|
321
|
-
*/
|
|
322
|
-
export const httpApiCommands = Layer.mergeAll(
|
|
323
|
-
apiCommands,
|
|
324
|
-
integrationCommands,
|
|
325
|
-
routeCommands,
|
|
326
|
-
stageCommands,
|
|
327
|
-
);
|