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.
Files changed (150) hide show
  1. package/CHANGELOG.md +34 -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
@@ -0,0 +1,168 @@
1
+ import { AwsClient } from "@tradedal/aws-client-core";
2
+ import { AwsServiceError } from "@tradedal/aws-client-core/model";
3
+ import {
4
+ Array as Arr,
5
+ Context,
6
+ Data,
7
+ Effect,
8
+ HashSet,
9
+ Match,
10
+ Schema,
11
+ } from "effect";
12
+ import type {
13
+ AwsLifecycleSettings,
14
+ ResourceOperation,
15
+ } from "./resourceLifecycleRegistration.js";
16
+
17
+ /**
18
+ * The AssociationNames schema validates member names within one collection.
19
+ * Callers must pass names from that collection alone. A bare name carries
20
+ * no information about the type of member or the parent it belongs to.
21
+ */
22
+ export const AssociationNames = Schema.Array(Schema.String);
23
+
24
+ /**
25
+ * The associationChanges function identifies which links a stack may add or
26
+ * remove. A removal requires the name to appear in both the previous
27
+ * declaration and the provider's current list. For example, if a group
28
+ * contains Ana and Ben and the stack previously declared only Ana, an empty
29
+ * declaration removes Ana alone.
30
+ *
31
+ * @see ../../../refs/effect/packages/effect/src/HashSet.ts (difference and intersection)
32
+ */
33
+ export const associationChanges = (
34
+ observed: typeof AssociationNames.Type,
35
+ previous: typeof AssociationNames.Type,
36
+ desired: typeof AssociationNames.Type,
37
+ ) => {
38
+ const current = HashSet.fromIterable(observed);
39
+
40
+ const declared = HashSet.fromIterable(previous);
41
+
42
+ const requested = HashSet.fromIterable(desired);
43
+
44
+ const add = Arr.fromIterable(HashSet.difference(requested, current));
45
+
46
+ const remove = Arr.fromIterable(
47
+ HashSet.intersection(HashSet.difference(declared, requested), current),
48
+ );
49
+
50
+ return { add, remove };
51
+ };
52
+
53
+ /**
54
+ * The ResourceAssociationOperations definition specifies how a provider
55
+ * accepts changes to one collection. Use releaseSlotFirst for an instance
56
+ * profile: IAM allows one role, and the old role must leave before the
57
+ * request can add its replacement.
58
+ */
59
+ export interface ResourceAssociationOperations {
60
+ readonly add: ResourceOperation<unknown>;
61
+ readonly remove: ResourceOperation<unknown>;
62
+ readonly order?: "releaseSlotFirst";
63
+ }
64
+
65
+ class AssociationSlotOccupied extends Data.TaggedError(
66
+ "AssociationSlotOccupied",
67
+ )<{
68
+ readonly parent: string;
69
+ }> {
70
+ override get message() {
71
+ return `Resource "${this.parent}" has a member that this declaration cannot remove.`;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * The AwsResourceAssociationOperations service applies the same rules to
77
+ * a resource's member property and to a declaration that manages links on
78
+ * an independent parent. Both consumers confirm the requested links with
79
+ * a separate provider read.
80
+ */
81
+ export class AwsResourceAssociationOperations extends Context.Service<AwsResourceAssociationOperations>()(
82
+ "nomoss/providers/aws/management/resourceAssociations/AwsResourceAssociationOperations",
83
+ {
84
+ make: Effect.fn("AwsResourceAssociationOperations.make")(function* (
85
+ settings: Pick<AwsLifecycleSettings, "service" | "missingErrors">,
86
+ operations: ResourceAssociationOperations,
87
+ ) {
88
+ const client = yield* AwsClient;
89
+
90
+ const bind = client.bindOperation(settings.service);
91
+
92
+ const add = bind(operations.add);
93
+
94
+ const remove = bind(operations.remove);
95
+
96
+ const missing = AwsServiceError.hasCode(...settings.missingErrors);
97
+
98
+ /**
99
+ * The reconcile service method requires the full provider list and the
100
+ * previous and desired declarations for one parent. If the provider has
101
+ * a member outside the previous declaration and that member blocks a
102
+ * replacement, the method reports AssociationSlotOccupied before any write.
103
+ * Use the returned check on a fresh list to verify the new membership.
104
+ */
105
+ const reconcile = Effect.fn("AwsResourceAssociationOperations.reconcile")(
106
+ function* (
107
+ Parent: string,
108
+ observed: typeof AssociationNames.Type,
109
+ previous: typeof AssociationNames.Type,
110
+ desired: typeof AssociationNames.Type,
111
+ ) {
112
+ const changes = associationChanges(observed, previous, desired);
113
+
114
+ const releaseSlotFirst = operations.order === "releaseSlotFirst";
115
+
116
+ const occupiedByUndeclaredMember = Arr.some(
117
+ observed,
118
+ (name) => !Arr.contains(previous, name),
119
+ );
120
+
121
+ const blocked =
122
+ releaseSlotFirst &&
123
+ occupiedByUndeclaredMember &&
124
+ Arr.isReadonlyArrayNonEmpty(changes.add);
125
+
126
+ yield* new AssociationSlotOccupied({ parent: Parent }).pipe(
127
+ Effect.when(Effect.succeed(blocked)),
128
+ );
129
+
130
+ const order = Match.value(releaseSlotFirst).pipe(
131
+ Match.when(true, () => ["remove", "add"] as const),
132
+ Match.orElse(() => ["add", "remove"] as const),
133
+ );
134
+
135
+ yield* Effect.forEach(
136
+ order,
137
+ (action) =>
138
+ Effect.forEach(
139
+ changes[action],
140
+ (Member) =>
141
+ Match.value(action).pipe(
142
+ Match.when("add", () => add({ Parent, Member })),
143
+ Match.orElse(() =>
144
+ remove({ Parent, Member }).pipe(
145
+ Effect.catchIf(missing, () => Effect.void),
146
+ ),
147
+ ),
148
+ ),
149
+ { discard: true },
150
+ ),
151
+ { discard: true },
152
+ );
153
+
154
+ const accepts = (confirmed: typeof AssociationNames.Type): boolean =>
155
+ Arr.every(desired, (member) => Arr.contains(confirmed, member)) &&
156
+ Arr.every(
157
+ changes.remove,
158
+ (member) => !Arr.contains(confirmed, member),
159
+ );
160
+
161
+ return accepts;
162
+ },
163
+ );
164
+
165
+ return { reconcile };
166
+ }),
167
+ },
168
+ ) {}
@@ -1,17 +1,16 @@
1
- import { Schema } from "effect";
2
- import type { ResourceSchemaAnnotation } from "../../../core/resource/model.js";
3
1
  import type {
4
2
  AwsJsonRpcOperation,
5
3
  AwsJsonRpcPayload,
6
4
  AwsServiceDefinition,
7
- } from "../client/awsClientModel.js";
5
+ } from "@tradedal/aws-client-core/model";
6
+ import { Schema } from "effect";
7
+ import type { ResourceSchemaAnnotation } from "../../../src/core/resource/model.js";
8
8
 
9
9
  /**
10
- * The AwsAttributeResourceMapping schema validates imported resource metadata,
11
- * Registry definitions, and generated operation metadata before
12
- * publication. Explicit reset values describe how AWS clears a removed property.
13
- * A removal without that rule fails before mutation. Applications supply
14
- * resource properties through generated schemas.
10
+ * The AwsAttributeResourceMapping schema checks configuration for AWS APIs
11
+ * that accept named attributes. An attribute may declare a reset value so a
12
+ * command can distinguish a request to clear the attribute from a request
13
+ * that leaves it unchanged.
15
14
  */
16
15
  export const AwsAttributeResourceMapping = Schema.Struct({
17
16
  typeName: Schema.NonEmptyString,
@@ -53,10 +52,9 @@ export const AwsAttributeResourceMapping = Schema.Struct({
53
52
  });
54
53
 
55
54
  /**
56
- * The AwsResourceOperation interface retains the generated operation's codecs.
57
- * The shared policy supplies JSON objects, and the native input codec checks
58
- * the selected operation before the internal AWS client executes it. Unit
59
- * responses remain valid results for mutation calls.
55
+ * The AwsResourceOperation interface preserves the generated request codec
56
+ * when a definition selects an AWS operation. The client still checks the
57
+ * native request, and a mutation may return no value.
60
58
  */
61
59
  export interface AwsResourceOperation extends AwsJsonRpcOperation {
62
60
  readonly input: Schema.Codec<object, AwsJsonRpcPayload>;
@@ -64,16 +62,16 @@ export interface AwsResourceOperation extends AwsJsonRpcOperation {
64
62
  }
65
63
 
66
64
  /**
67
- * The AwsResourceAttributeValues type represents the string values exchanged by
68
- * attribute-map APIs. The generated attribute and tag codecs validate these
69
- * values before resource mapping or propagation checks use them.
65
+ * The AwsResourceAttributeValues type describes the string values that an
66
+ * attribute map sends to or receives from AWS. A property with a JSON value
67
+ * must use its encoded text in that map.
70
68
  */
71
69
  export type AwsResourceAttributeValues = Readonly<Record<string, string>>;
72
70
 
73
71
  /**
74
- * The AwsResourceProperties record gives lifecycle commands the validated
75
- * declaration together with its native attributes and managed tags. Commands
76
- * can validate a complete change before making its first AWS request.
72
+ * The AwsResourceProperties record distinguishes declared properties from
73
+ * the attributes and tags a provider call accepts. The same declaration can
74
+ * supply the resource's attribute request and a separate tag request.
77
75
  */
78
76
  export interface AwsResourceProperties {
79
77
  readonly properties: AwsJsonRpcPayload;
@@ -82,10 +80,10 @@ export interface AwsResourceProperties {
82
80
  }
83
81
 
84
82
  /**
85
- * The AwsResourceState record retains the provider values used to confirm a
86
- * mutation beside the reconstructed resource that core can save. Its complete
87
- * tag map lets propagation checks confirm removal of owned keys while preserving
88
- * tags outside the declaration.
83
+ * The AwsResourceState record preserves native attributes and the complete
84
+ * tag map beside the resource values the stack saves. A confirmation can
85
+ * use the tag map to check that a formerly declared key is absent even
86
+ * when other keys remain.
89
87
  */
90
88
  export interface AwsResourceState {
91
89
  readonly resource: AwsJsonRpcPayload;
@@ -94,10 +92,10 @@ export interface AwsResourceState {
94
92
  }
95
93
 
96
94
  /**
97
- * The AwsAttributeResourceConfiguration interface connects generated resource
98
- * validation to callable operation contracts. Attribute encodings and
99
- * create-only properties come from the selected Registry definition, so the
100
- * executor can translate values without a second resource schema.
95
+ * The AwsAttributeResourceConfiguration interface ties the selected AWS
96
+ * operations to the resource's generated schemas. The Registry definition
97
+ * specifies which properties require replacement and which values the
98
+ * attribute API expects as JSON text.
101
99
  */
102
100
  export interface AwsAttributeResourceConfiguration {
103
101
  readonly schema: ResourceSchemaAnnotation;