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.
Files changed (150) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +5 -15
  3. package/ROADMAP.md +2 -0
  4. package/docs/README.md +1 -1
  5. package/docs/application/aws-resource-coverage.md +26 -0
  6. package/docs/application/aws-resource-lifecycle-management.md +13 -23
  7. package/docs/application/cli-workflow.md +1 -1
  8. package/docs/application/engine-design.md +2 -2
  9. package/docs/application/generation-architecture.md +10 -45
  10. package/docs/application/resource-command-policy-stage.md +2 -2
  11. package/docs/application/resource-graph.md +1 -1
  12. package/docs/application/resource-lifecycle-tracker.md +1 -9
  13. package/docs/application/resource-mapping.md +4 -9
  14. package/docs/application/resource-operations.md +4 -2
  15. package/docs/application/tracing.md +2 -6
  16. package/docs/development/code-documentation.md +2 -0
  17. package/docs/development/effect-native-development.md +44 -0
  18. package/docs/development/linting.md +1 -1
  19. package/docs/development/review-code.md +22 -6
  20. package/docs/development/review-remediation-spec.md +28 -37
  21. package/docs/development/spec-writing.md +1 -1
  22. package/docs/development/testing.md +23 -9
  23. package/docs/operations/observability-sop.md +11 -17
  24. package/docs/operations/releasing.md +3 -1
  25. package/examples/README.md +3 -26
  26. package/examples/commands.ts +2 -36
  27. package/examples/queue/application.ts +8 -2
  28. package/examples/state-machine/application.ts +3 -1
  29. package/package.json +40 -46
  30. package/providers/aws/README.md +21 -0
  31. package/providers/aws/awsEnvironment.ts +114 -0
  32. package/providers/aws/generated/managementRegistry.ts +136 -0
  33. package/{src/providers/aws/resources/generated/native/apigatewayv2/api/index.ts → providers/aws/generated/resources/apigatewayv2/api.ts} +13 -50
  34. package/{src/providers/aws/resources/generated/native/apigatewayv2/integration/index.ts → providers/aws/generated/resources/apigatewayv2/integration.ts} +13 -37
  35. package/{src/providers/aws/resources/generated/native/apigatewayv2/route/index.ts → providers/aws/generated/resources/apigatewayv2/route.ts} +23 -40
  36. package/{src/providers/aws/resources/generated/native/apigatewayv2/stage/index.ts → providers/aws/generated/resources/apigatewayv2/stage.ts} +13 -38
  37. package/providers/aws/generated/resources/iam/accesskey.ts +184 -0
  38. package/{src/providers/aws/resources/generated/native/iam/group/index.ts → providers/aws/generated/resources/iam/group.ts} +13 -38
  39. package/{src/providers/aws/resources/generated/native/iam/grouppolicy/index.ts → providers/aws/generated/resources/iam/grouppolicy.ts} +29 -59
  40. package/{src/providers/aws/resources/generated/native/iam/instanceprofile/index.ts → providers/aws/generated/resources/iam/instanceprofile.ts} +13 -41
  41. package/{src/providers/aws/resources/generated/native/iam/managedpolicy/index.ts → providers/aws/generated/resources/iam/managedpolicy.ts} +13 -95
  42. package/providers/aws/generated/resources/iam/oidcprovider.ts +314 -0
  43. package/{src/providers/aws/resources/generated/native/iam/policy/index.ts → providers/aws/generated/resources/iam/policy.ts} +13 -28
  44. package/{src/providers/aws/resources/generated/native/iam/role/index.ts → providers/aws/generated/resources/iam/role.ts} +13 -47
  45. package/{src/providers/aws/resources/generated/native/iam/rolepolicy/index.ts → providers/aws/generated/resources/iam/rolepolicy.ts} +29 -59
  46. package/providers/aws/generated/resources/iam/samlprovider.ts +463 -0
  47. package/providers/aws/generated/resources/iam/servercertificate.ts +465 -0
  48. package/providers/aws/generated/resources/iam/servicelinkedrole.ts +187 -0
  49. package/{src/providers/aws/resources/generated/native/iam/user/index.ts → providers/aws/generated/resources/iam/user.ts} +13 -38
  50. package/{src/providers/aws/resources/generated/native/iam/userpolicy/index.ts → providers/aws/generated/resources/iam/userpolicy.ts} +29 -59
  51. package/{src/providers/aws/resources/generated/native/iam/usertogroupaddition/index.ts → providers/aws/generated/resources/iam/usertogroupaddition.ts} +13 -27
  52. package/providers/aws/generated/resources/iam/virtualmfadevice.ts +298 -0
  53. package/{src/providers/aws/resources/generated/native/kms/key/index.ts → providers/aws/generated/resources/kms/key.ts} +13 -41
  54. package/{src/providers/aws/resources/generated/native/lambda/function/index.ts → providers/aws/generated/resources/lambda/function.ts} +13 -63
  55. package/{src/providers/aws/resources/generated/native/lambda/permission/index.ts → providers/aws/generated/resources/lambda/permission.ts} +13 -55
  56. package/{src/providers/aws/resources/generated/native/s3/bucket/index.ts → providers/aws/generated/resources/s3/bucket.ts} +14 -104
  57. package/{src/providers/aws/resources/generated/native/sns/topic/index.ts → providers/aws/generated/resources/sns/topic.ts} +14 -29
  58. package/{src/providers/aws/resources/generated/native/sqs/queue/index.ts → providers/aws/generated/resources/sqs/queue.ts} +14 -38
  59. package/{src/providers/aws/resources/generated/native/stepfunctions/statemachine/index.ts → providers/aws/generated/resources/stepfunctions/statemachine.ts} +15 -58
  60. package/providers/aws/management/mappings/iam/group.ts +63 -0
  61. package/providers/aws/management/mappings/iam/iamIdentity.ts +41 -0
  62. package/providers/aws/management/mappings/iam/iamLifecycleSettings.ts +8 -0
  63. package/providers/aws/management/mappings/iam/inlinePolicies.ts +159 -0
  64. package/providers/aws/management/mappings/iam/instanceProfile.ts +77 -0
  65. package/providers/aws/management/mappings/iam/oidcProvider.ts +94 -0
  66. package/providers/aws/management/mappings/iam/role.ts +74 -0
  67. package/providers/aws/management/mappings/iam/samlProvider.ts +98 -0
  68. package/providers/aws/management/mappings/iam/serverCertificate.ts +72 -0
  69. package/providers/aws/management/mappings/iam/user.ts +61 -0
  70. package/providers/aws/management/mappings/iam/userToGroupAddition.ts +75 -0
  71. package/providers/aws/management/operations/iam/accessKey.ts +206 -0
  72. package/providers/aws/management/operations/iam/managedPolicy.ts +491 -0
  73. package/providers/aws/management/operations/iam/policy.ts +476 -0
  74. package/providers/aws/management/operations/iam/serviceLinkedRole.ts +172 -0
  75. package/providers/aws/management/operations/iam/virtualMfaDevice.ts +253 -0
  76. package/providers/aws/management/resourceAssociationConfiguration.ts +112 -0
  77. package/providers/aws/management/resourceAssociationRegistration.ts +349 -0
  78. package/providers/aws/management/resourceAssociations.ts +168 -0
  79. package/{src/providers → providers}/aws/management/resourceConfiguration.ts +24 -26
  80. package/providers/aws/management/resourceLifecycleRegistration.ts +540 -0
  81. package/providers/aws/management/resourceManagementModule.ts +31 -0
  82. package/providers/aws/management/resourceManagementRegistry.ts +62 -0
  83. package/providers/aws/management/resourceMapping.ts +84 -0
  84. package/providers/aws/management/resourceOperation.ts +134 -0
  85. package/providers/aws/management/resourceTagOperations.ts +108 -0
  86. package/providers/aws/management/resourceTiming.ts +4 -0
  87. package/providers/aws/runtime.ts +52 -0
  88. package/src/core/resource/resourceCommandPolicy.ts +20 -0
  89. package/src/core/resource/resourceLifecycle.ts +644 -0
  90. package/src/core/resource/resourceStabilization.ts +120 -0
  91. package/src/core/resource/resourceVersions.ts +102 -0
  92. package/src/core/stack/planner.ts +9 -0
  93. package/src/core/stack/resourceStackLifecycle.ts +36 -3
  94. package/src/core/state/resourceState.ts +6 -4
  95. package/src/core/state/stateStore.ts +57 -10
  96. package/src/providers/file/resourcePolicy.ts +13 -12
  97. package/src/providers/providerRuntimeLayer.ts +5 -2
  98. package/src/providers/resourceCommandPolicyLayer.ts +117 -37
  99. package/src/providers/stripe/management/resourcePolicy.ts +22 -11
  100. package/examples/http-echo/application.ts +0 -87
  101. package/src/providers/aws/client/awsClient.ts +0 -418
  102. package/src/providers/aws/client/awsClientConfig.ts +0 -133
  103. package/src/providers/aws/client/awsClientModel.ts +0 -119
  104. package/src/providers/aws/client/awsHttpOperation.ts +0 -153
  105. package/src/providers/aws/client/awsQueryOperation.ts +0 -149
  106. package/src/providers/aws/client/awsRequestSigner.ts +0 -115
  107. package/src/providers/aws/client/awsResponseDecoder.ts +0 -135
  108. package/src/providers/aws/client/awsRetryPolicy.ts +0 -62
  109. package/src/providers/aws/client/generated/apiGatewayV2.ts +0 -3025
  110. package/src/providers/aws/client/generated/cloudControl.ts +0 -5746
  111. package/src/providers/aws/client/generated/iam.ts +0 -10892
  112. package/src/providers/aws/client/generated/lambda.ts +0 -5403
  113. package/src/providers/aws/client/generated/sqs.ts +0 -3769
  114. package/src/providers/aws/client/generated/stepFunctions.ts +0 -1726
  115. package/src/providers/aws/client/openapi/cloudControl/CancelResourceRequest.json +0 -579
  116. package/src/providers/aws/client/openapi/cloudControl/CreateResource.json +0 -1019
  117. package/src/providers/aws/client/openapi/cloudControl/DeleteResource.json +0 -1018
  118. package/src/providers/aws/client/openapi/cloudControl/GetResource.json +0 -883
  119. package/src/providers/aws/client/openapi/cloudControl/GetResourceRequestStatus.json +0 -655
  120. package/src/providers/aws/client/openapi/cloudControl/ListResourceRequests.json +0 -566
  121. package/src/providers/aws/client/openapi/cloudControl/ListResources.json +0 -913
  122. package/src/providers/aws/client/openapi/cloudControl/UpdateResource.json +0 -1027
  123. package/src/providers/aws/cloudControl/client.ts +0 -69
  124. package/src/providers/aws/cloudControl/requestTracker.ts +0 -138
  125. package/src/providers/aws/cloudControl/resourceCommandPolicyLayer.ts +0 -63
  126. package/src/providers/aws/cloudControl/resourceLifecycle.ts +0 -479
  127. package/src/providers/aws/cloudControl/resources/generated/certificatemanager/certificate/index.ts +0 -179
  128. package/src/providers/aws/cloudControl/resources/generated/kms/key/index.ts +0 -362
  129. package/src/providers/aws/cloudControl/resources/generated/s3/bucket/index.ts +0 -2364
  130. package/src/providers/aws/cloudControl/resources/generated/sns/topic/index.ts +0 -326
  131. package/src/providers/aws/cloudControl/resources/generated/sqs/queue/index.ts +0 -307
  132. package/src/providers/aws/cloudControl/resources/generated/sqs/queueinlinepolicy/index.ts +0 -108
  133. package/src/providers/aws/cloudControl/runtime.ts +0 -127
  134. package/src/providers/aws/management/resourceMapping.ts +0 -343
  135. package/src/providers/aws/management/resourceOperation.ts +0 -57
  136. package/src/providers/aws/management/resourcePolicy.ts +0 -549
  137. package/src/providers/aws/management/resourceRegistration.ts +0 -294
  138. package/src/providers/aws/resources/apiGatewayV2/httpApi.ts +0 -327
  139. package/src/providers/aws/resources/generated/native/resourceCommands.ts +0 -152
  140. package/src/providers/aws/resources/iam/grant.ts +0 -150
  141. package/src/providers/aws/resources/iam/grantCommands.ts +0 -283
  142. package/src/providers/aws/resources/iam/policyDocument.ts +0 -30
  143. package/src/providers/aws/resources/iam/policyStatement.ts +0 -59
  144. package/src/providers/aws/resources/iam/role.ts +0 -426
  145. package/src/providers/aws/resources/iam/roleDeclaration.ts +0 -105
  146. package/src/providers/aws/resources/lambda/function.ts +0 -403
  147. package/src/providers/aws/resources/lambda/functionDeclaration.ts +0 -234
  148. package/src/providers/aws/resources/lambda/permission.ts +0 -363
  149. package/src/providers/aws/resources/stepFunctions/stateMachine.ts +0 -95
  150. 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
- * ProviderResourceCommandPolicy is the execution contract each registered
15
- * provider implements. Its service tag is derived from persisted resource
16
- * metadata so later commands can locate the same resource capability.
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
- interface ProviderResourceCommandPolicy {
19
- readonly execute: (
20
- command: ResourceCommand,
21
- ) => ReturnType<(typeof ResourceCommandPolicy)["Service"]["execute"]>;
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 resource schema.
26
- * Providers supply the implementation in the same runtime as command execution.
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
- * awsCloudControlCommandPolicyTag registers the common lifecycle used by
35
- * Cloud Control resources. Their saved metadata selects the resource type for
36
- * each invocation, so separate type registrations are unnecessary.
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 awsCloudControlCommandPolicyTag = Context.Service<
39
- ProviderResourceCommandPolicy,
40
- ProviderResourceCommandPolicy
41
- >("nomoss/providers/resourceCommandPolicyLayer/aws-cloud-control");
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 uses provider registrations
45
- * from the application's runtime. An absent registration produces a typed unsupported
46
- * command that retains the original request for diagnosis.
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 selects the provider registration identified by the command's
53
- * resource metadata. Resource context continues into provider spans and logs
54
- * so a read or mutation remains attributable to the same logical resource.
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
- const tag = Option.match(
80
- Option.fromUndefinedOr(node.schema.cloudControl),
81
- {
82
- onNone: () => providerCommandPolicyTag(node.schema),
83
- onSome: () => awsCloudControlCommandPolicyTag,
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(tag).pipe(
88
- Effect.flatMap(Effect.fromOption),
89
- Effect.mapError(
90
- () =>
91
- new ResourceCommandExecutionFailed({
92
- command,
93
- cause: new ResourceCommandUnsupported({ command }),
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 { providerCommandPolicyTag } from "../../resourceCommandPolicyLayer.js";
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 so execute can attach the
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.unwrap(
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 Layer.succeed(providerCommandPolicyTag(schema), {
486
- execute: (command) => policy.execute(definition, command),
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
- };