nomoss 0.0.3 → 0.0.5
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 +34 -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
|
@@ -7,23 +7,38 @@ import {
|
|
|
7
7
|
import type { ResourceSchemaAnnotation } from "../core/resource/model.js";
|
|
8
8
|
import {
|
|
9
9
|
ResourceCommandExecutionFailed,
|
|
10
|
+
type ResourceCommandFailure,
|
|
10
11
|
ResourceCommandPolicy,
|
|
11
12
|
} from "../core/resource/resourceCommandPolicy.js";
|
|
12
13
|
|
|
14
|
+
type ProviderResourceCommandPolicy = ResourceCommandPolicy["Service"];
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* The ResourceCommandPolicyResolver service can select a policy from saved
|
|
18
|
+
* metadata after a resource disappears from the declaration. It reports
|
|
19
|
+
* absence for unsupported types and reports initialization failures separately.
|
|
20
|
+
*
|
|
21
|
+
* @see ../../node_modules/effect/src/Context.ts (Service)
|
|
17
22
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
export class ResourceCommandPolicyResolver extends Context.Service<
|
|
24
|
+
ResourceCommandPolicyResolver,
|
|
25
|
+
{
|
|
26
|
+
readonly resolve: (
|
|
27
|
+
schema: ResourceSchemaAnnotation,
|
|
28
|
+
) => Effect.Effect<
|
|
29
|
+
Option.Option<ProviderResourceCommandPolicy>,
|
|
30
|
+
ResourceCommandFailure
|
|
31
|
+
>;
|
|
32
|
+
}
|
|
33
|
+
>()(
|
|
34
|
+
"nomoss/providers/resourceCommandPolicyLayer/ResourceCommandPolicyResolver",
|
|
35
|
+
) {}
|
|
23
36
|
|
|
24
37
|
/**
|
|
25
|
-
* providerCommandPolicyTag identifies the registration for a
|
|
26
|
-
* Providers supply
|
|
38
|
+
* The providerCommandPolicyTag function identifies the registration for a
|
|
39
|
+
* resource schema. Providers supply it in the runtime that issues commands.
|
|
40
|
+
*
|
|
41
|
+
* @see ../../node_modules/effect/src/Context.ts (Service)
|
|
27
42
|
*/
|
|
28
43
|
export const providerCommandPolicyTag = (schema: ResourceSchemaAnnotation) =>
|
|
29
44
|
Context.Service<ProviderResourceCommandPolicy, ProviderResourceCommandPolicy>(
|
|
@@ -31,27 +46,68 @@ export const providerCommandPolicyTag = (schema: ResourceSchemaAnnotation) =>
|
|
|
31
46
|
);
|
|
32
47
|
|
|
33
48
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
49
|
+
* The resourceCommandPolicy function keeps the provider's failure attached to
|
|
50
|
+
* its command. The stack can record the failed action while diagnostics still
|
|
51
|
+
* have the original cause.
|
|
52
|
+
*
|
|
53
|
+
* @see ../../node_modules/effect/src/Effect.ts (mapError)
|
|
54
|
+
*/
|
|
55
|
+
export const resourceCommandPolicy = <Failure extends ResourceCommandFailure>(
|
|
56
|
+
execute: (
|
|
57
|
+
command: ResourceCommand,
|
|
58
|
+
) => Effect.Effect<ResourceCommandResult, Failure>,
|
|
59
|
+
): ProviderResourceCommandPolicy => ({
|
|
60
|
+
execute: (command) =>
|
|
61
|
+
execute(command).pipe(
|
|
62
|
+
Effect.mapError(
|
|
63
|
+
(cause) => new ResourceCommandExecutionFailed({ command, cause }),
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The registerResourceCommands function lets a provider register one executor
|
|
70
|
+
* for several type identifiers. A caller can keep an old identifier as an
|
|
71
|
+
* alias when saved resources still use it.
|
|
72
|
+
*
|
|
73
|
+
* @see ../../node_modules/effect/src/Context.ts (make and add)
|
|
37
74
|
*/
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
75
|
+
export const registerResourceCommands = <
|
|
76
|
+
Failure extends ResourceCommandFailure,
|
|
77
|
+
>(
|
|
78
|
+
execute: (
|
|
79
|
+
command: ResourceCommand,
|
|
80
|
+
) => Effect.Effect<ResourceCommandResult, Failure>,
|
|
81
|
+
tag: Context.Key<
|
|
82
|
+
ProviderResourceCommandPolicy,
|
|
83
|
+
ProviderResourceCommandPolicy
|
|
84
|
+
>,
|
|
85
|
+
...aliases: ReadonlyArray<
|
|
86
|
+
Context.Key<ProviderResourceCommandPolicy, ProviderResourceCommandPolicy>
|
|
87
|
+
>
|
|
88
|
+
) => {
|
|
89
|
+
const policy = resourceCommandPolicy(execute);
|
|
90
|
+
|
|
91
|
+
return aliases.reduce(
|
|
92
|
+
(registrations, alias) => Context.add(registrations, alias, policy),
|
|
93
|
+
Context.make(tag, policy),
|
|
94
|
+
);
|
|
95
|
+
};
|
|
42
96
|
|
|
43
97
|
/**
|
|
44
|
-
* The providerResourceCommandPolicyLayerLive Layer
|
|
45
|
-
*
|
|
46
|
-
*
|
|
98
|
+
* The providerResourceCommandPolicyLayerLive Layer checks the application's
|
|
99
|
+
* registrations before asking a resolver to load a policy. If neither source
|
|
100
|
+
* has a policy for the saved type, dispatch returns an unsupported command.
|
|
101
|
+
*
|
|
102
|
+
* @see ../../node_modules/effect/src/Effect.ts (serviceOption)
|
|
47
103
|
*/
|
|
48
104
|
export const providerResourceCommandPolicyLayerLive = Layer.effect(
|
|
49
105
|
ResourceCommandPolicy,
|
|
50
106
|
Effect.sync(() => {
|
|
51
107
|
/**
|
|
52
|
-
* execute
|
|
53
|
-
*
|
|
54
|
-
*
|
|
108
|
+
* The execute service method accepts the schema on a saved node, including
|
|
109
|
+
* for deletion after the declaration has gone. Its failure retains the
|
|
110
|
+
* original command so diagnostics can identify the affected resource.
|
|
55
111
|
*/
|
|
56
112
|
const execute = Effect.fn("ProviderResourceCommandPolicy.execute")(
|
|
57
113
|
function* (command: ResourceCommand) {
|
|
@@ -76,22 +132,46 @@ export const providerResourceCommandPolicyLayerLive = Layer.effect(
|
|
|
76
132
|
|
|
77
133
|
yield* Effect.annotateCurrentSpan(resourceAttributes);
|
|
78
134
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
135
|
+
// A saved Cloud Control identity cannot address a native AWS resource.
|
|
136
|
+
yield* Effect.fail(
|
|
137
|
+
new ResourceCommandExecutionFailed({
|
|
138
|
+
command,
|
|
139
|
+
cause: new ResourceCommandUnsupported({ command }),
|
|
140
|
+
}),
|
|
141
|
+
).pipe(
|
|
142
|
+
Effect.when(Effect.succeed(node.schema.cloudControl !== undefined)),
|
|
85
143
|
);
|
|
86
144
|
|
|
87
|
-
const policy = yield* Effect.serviceOption(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
145
|
+
const policy = yield* Effect.serviceOption(
|
|
146
|
+
providerCommandPolicyTag(node.schema),
|
|
147
|
+
).pipe(
|
|
148
|
+
Effect.flatMap((registered) =>
|
|
149
|
+
Option.match(registered, {
|
|
150
|
+
onSome: Effect.succeedSome,
|
|
151
|
+
onNone: () =>
|
|
152
|
+
Effect.serviceOption(ResourceCommandPolicyResolver).pipe(
|
|
153
|
+
Effect.flatMap((resolver) =>
|
|
154
|
+
Option.match(resolver, {
|
|
155
|
+
onNone: () => Effect.succeedNone,
|
|
156
|
+
onSome: ({ resolve }) => resolve(node.schema),
|
|
157
|
+
}),
|
|
158
|
+
),
|
|
159
|
+
Effect.mapError(
|
|
160
|
+
(cause) =>
|
|
161
|
+
new ResourceCommandExecutionFailed({ command, cause }),
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
}),
|
|
165
|
+
),
|
|
166
|
+
Effect.flatMap((registered) =>
|
|
167
|
+
Effect.fromOption(
|
|
168
|
+
registered,
|
|
169
|
+
() =>
|
|
170
|
+
new ResourceCommandExecutionFailed({
|
|
171
|
+
command,
|
|
172
|
+
cause: new ResourceCommandUnsupported({ command }),
|
|
173
|
+
}),
|
|
174
|
+
),
|
|
95
175
|
),
|
|
96
176
|
);
|
|
97
177
|
|
|
@@ -24,12 +24,14 @@ import {
|
|
|
24
24
|
readResourceSchemaAnnotation,
|
|
25
25
|
resourceModelLayer,
|
|
26
26
|
} from "../../../core/resource/model.js";
|
|
27
|
-
import { ResourceCommandExecutionFailed } from "../../../core/resource/resourceCommandPolicy.js";
|
|
28
27
|
import {
|
|
29
28
|
ResourceRequest,
|
|
30
29
|
resourceRequestLayer,
|
|
31
30
|
} from "../../../core/resource/resourceRequest.js";
|
|
32
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
providerCommandPolicyTag,
|
|
33
|
+
registerResourceCommands,
|
|
34
|
+
} from "../../resourceCommandPolicyLayer.js";
|
|
33
35
|
import { StripeClient } from "../client/stripeClient.js";
|
|
34
36
|
import type { StripePayload } from "../client/stripeClientModel.js";
|
|
35
37
|
import type {
|
|
@@ -54,8 +56,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
54
56
|
/**
|
|
55
57
|
* The invoke service method validates resolved inputs against the selected
|
|
56
58
|
* generated request schema before provider I/O. Provider and validation
|
|
57
|
-
* failures propagate with their original types
|
|
58
|
-
* resource command through ResourceCommandExecutionFailed.
|
|
59
|
+
* failures propagate to the caller with their original types.
|
|
59
60
|
*/
|
|
60
61
|
const invoke = Effect.fn("StripeResourcePolicy.invoke")(function* <
|
|
61
62
|
State extends StripePayload,
|
|
@@ -113,6 +114,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
113
114
|
(schema) =>
|
|
114
115
|
Schema.decodeUnknownEffect(Schema.toType(schema))(state),
|
|
115
116
|
);
|
|
117
|
+
|
|
116
118
|
const values = yield* Effect.forEach(
|
|
117
119
|
Record.toEntries(definition.inputOutputs ?? {}),
|
|
118
120
|
([output, parameter]) =>
|
|
@@ -128,6 +130,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
128
130
|
),
|
|
129
131
|
),
|
|
130
132
|
);
|
|
133
|
+
|
|
131
134
|
const projected = definition.projectOutputs(state, previous);
|
|
132
135
|
const identity = Record.fromEntries(Arr.flatten(values));
|
|
133
136
|
const outputs: StripePayload = { ...projected, ...identity };
|
|
@@ -178,6 +181,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
178
181
|
state,
|
|
179
182
|
outputs,
|
|
180
183
|
);
|
|
184
|
+
|
|
181
185
|
const hydrated = yield* model.withObservedOutputs(
|
|
182
186
|
node,
|
|
183
187
|
projected,
|
|
@@ -230,7 +234,9 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
230
234
|
definition.request,
|
|
231
235
|
);
|
|
232
236
|
const input = yield* requests.prepare(properties, definition.request);
|
|
237
|
+
|
|
233
238
|
const created = yield* invoke(definition.operations.create, input);
|
|
239
|
+
|
|
234
240
|
const outputs = yield* projectOutputs(definition, node, created);
|
|
235
241
|
|
|
236
242
|
const applied = yield* model.withOutputs(node, outputs);
|
|
@@ -271,6 +277,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
271
277
|
);
|
|
272
278
|
|
|
273
279
|
const props = yield* model.decodeProps(node, definition.propsSchema);
|
|
280
|
+
|
|
274
281
|
const previous = yield* model.decodeOutputs(
|
|
275
282
|
current,
|
|
276
283
|
definition.outputsSchema,
|
|
@@ -281,6 +288,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
281
288
|
definition.request,
|
|
282
289
|
);
|
|
283
290
|
const input = Struct.assign(properties, definition.identify(previous));
|
|
291
|
+
|
|
284
292
|
const desiredProps = yield* requests.properties(
|
|
285
293
|
node.props,
|
|
286
294
|
definition.request,
|
|
@@ -289,6 +297,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
289
297
|
current.props,
|
|
290
298
|
definition.request,
|
|
291
299
|
);
|
|
300
|
+
|
|
292
301
|
const equivalent = Schema.toEquivalence(Schema.Json);
|
|
293
302
|
const changes = Record.filter(
|
|
294
303
|
desiredProps,
|
|
@@ -296,6 +305,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
296
305
|
!Record.has<string, Schema.Json>(currentProps, key) ||
|
|
297
306
|
!equivalent(value, currentProps[key]),
|
|
298
307
|
);
|
|
308
|
+
|
|
299
309
|
const validated = yield* Schema.decodeEffect(operation.input)(
|
|
300
310
|
input,
|
|
301
311
|
).pipe(
|
|
@@ -315,7 +325,9 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
315
325
|
);
|
|
316
326
|
|
|
317
327
|
const prepared = yield* requests.prepare(validated, definition.request);
|
|
328
|
+
|
|
318
329
|
const changed = yield* invoke(operation, prepared);
|
|
330
|
+
|
|
319
331
|
const outputs = yield* projectOutputs(
|
|
320
332
|
definition,
|
|
321
333
|
node,
|
|
@@ -356,6 +368,7 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
356
368
|
}),
|
|
357
369
|
),
|
|
358
370
|
);
|
|
371
|
+
|
|
359
372
|
const outputs = yield* model.decodeOutputs(
|
|
360
373
|
node,
|
|
361
374
|
definition.outputsSchema,
|
|
@@ -432,9 +445,6 @@ export class StripeResourcePolicy extends Context.Service<StripeResourcePolicy>(
|
|
|
432
445
|
Effect.fail(new ResourceCommandUnsupported({ command })),
|
|
433
446
|
),
|
|
434
447
|
Match.exhaustive,
|
|
435
|
-
Effect.mapError(
|
|
436
|
-
(cause) => new ResourceCommandExecutionFailed({ command, cause }),
|
|
437
|
-
),
|
|
438
448
|
);
|
|
439
449
|
|
|
440
450
|
return result;
|
|
@@ -477,13 +487,14 @@ export const stripeResourcePolicyRegistration = <
|
|
|
477
487
|
>(
|
|
478
488
|
definition: StripeResourceConfiguration<Props, Outputs, State>,
|
|
479
489
|
) =>
|
|
480
|
-
Layer.
|
|
490
|
+
Layer.effectContext(
|
|
481
491
|
Effect.gen(function* () {
|
|
482
492
|
const policy = yield* StripeResourcePolicy;
|
|
483
493
|
const schema = yield* policy.register(definition);
|
|
484
494
|
|
|
485
|
-
return
|
|
486
|
-
|
|
487
|
-
|
|
495
|
+
return registerResourceCommands(
|
|
496
|
+
(command) => policy.execute(definition, command),
|
|
497
|
+
providerCommandPolicyTag(schema),
|
|
498
|
+
);
|
|
488
499
|
}),
|
|
489
500
|
).pipe(Layer.provide(stripeResourcePolicyLayer));
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Effect, Layer } from "effect";
|
|
2
|
-
import { FetchHttpClient } from "effect/http";
|
|
3
|
-
import { Asset, localState } from "nomoss/core";
|
|
4
|
-
import { AwsProviderLive, awsClientConfigLayer } from "nomoss/providers/aws";
|
|
5
|
-
import { AWSApi } from "nomoss/providers/aws/apigatewayv2/api";
|
|
6
|
-
import { AWSIntegration } from "nomoss/providers/aws/apigatewayv2/integration";
|
|
7
|
-
import { AWSRoute } from "nomoss/providers/aws/apigatewayv2/route";
|
|
8
|
-
import { AWSStage } from "nomoss/providers/aws/apigatewayv2/stage";
|
|
9
|
-
import {
|
|
10
|
-
AWSFunction,
|
|
11
|
-
LambdaExecutionRole,
|
|
12
|
-
} from "nomoss/providers/aws/lambda/function";
|
|
13
|
-
|
|
14
|
-
const routes = [
|
|
15
|
-
{ name: "Health", route: "GET /health", handler: "index.health" },
|
|
16
|
-
{ name: "Echo", route: "POST /echo", handler: "index.echo" },
|
|
17
|
-
] as const;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The httpEchoStack definition links each route to a Lambda through its
|
|
21
|
-
* integration entity. Both functions use an IAM role declared by the stack.
|
|
22
|
-
* Nomoss builds the checked-in handler during planning. The stack exposes the
|
|
23
|
-
* API URL after apply saves it.
|
|
24
|
-
*
|
|
25
|
-
* @see ../../../command-options-fund/refs/effect/packages/effect/src/Layer.ts (provide)
|
|
26
|
-
*/
|
|
27
|
-
export const httpEchoStack = {
|
|
28
|
-
name: "http-echo",
|
|
29
|
-
providers: AwsProviderLive.pipe(
|
|
30
|
-
Layer.provide([awsClientConfigLayer, FetchHttpClient.layer]),
|
|
31
|
-
),
|
|
32
|
-
state: localState(),
|
|
33
|
-
resources: Effect.gen(function* () {
|
|
34
|
-
const code = Asset.fromBuild(new URL("./index.ts", import.meta.url), {
|
|
35
|
-
platform: "node",
|
|
36
|
-
target: "node24",
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const executionRole = yield* LambdaExecutionRole("ExecutionRole");
|
|
40
|
-
|
|
41
|
-
const api = yield* AWSApi({
|
|
42
|
-
logicalId: "Api",
|
|
43
|
-
props: { Name: "http-echo", ProtocolType: "HTTP" },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
yield* Effect.forEach(
|
|
47
|
-
routes,
|
|
48
|
-
Effect.fnUntraced(function* ({ name: logicalId, route, handler }) {
|
|
49
|
-
const lambda = yield* AWSFunction({
|
|
50
|
-
logicalId: `${logicalId}Function`,
|
|
51
|
-
executionRole,
|
|
52
|
-
props: {
|
|
53
|
-
Runtime: "nodejs24.x",
|
|
54
|
-
Handler: handler,
|
|
55
|
-
Code: code,
|
|
56
|
-
Timeout: 5,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const integration = yield* AWSIntegration({
|
|
61
|
-
logicalId: `${logicalId}Integration`,
|
|
62
|
-
props: {
|
|
63
|
-
ApiId: api,
|
|
64
|
-
IntegrationType: "AWS_PROXY",
|
|
65
|
-
IntegrationUri: lambda,
|
|
66
|
-
PayloadFormatVersion: "2.0",
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const httpRoute = yield* AWSRoute({
|
|
71
|
-
logicalId: `${logicalId}Route`,
|
|
72
|
-
props: { ApiId: api, RouteKey: route, Target: integration },
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
yield* lambda.grantInvoke(httpRoute);
|
|
76
|
-
}),
|
|
77
|
-
{ discard: true },
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
yield* AWSStage({
|
|
81
|
-
logicalId: "Stage",
|
|
82
|
-
props: { ApiId: api, StageName: "$default", AutoDeploy: true },
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return () => ({ url: api.ApiEndpoint });
|
|
86
|
-
}),
|
|
87
|
-
};
|