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
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Array as Arr,
|
|
3
|
-
Option,
|
|
4
|
-
Predicate,
|
|
5
|
-
Record,
|
|
6
|
-
Schema,
|
|
7
|
-
SchemaGetter,
|
|
8
|
-
String as Str,
|
|
9
|
-
Tuple,
|
|
10
|
-
} from "effect";
|
|
11
|
-
import { HttpApiEndpoint, HttpApiSchema } from "effect/http-api";
|
|
12
|
-
import { AwsJsonRpcPayload, type AwsOperation } from "./awsClientModel.js";
|
|
13
|
-
|
|
14
|
-
const HttpFields = Schema.Record(Schema.String, Schema.String);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The awsJsonRpcEmptyOutput schema factory accepts an empty reply or an empty
|
|
18
|
-
* JSON object for an operation with no output members. Both replies mean that
|
|
19
|
-
* the mutation succeeded, so callers receive void after response validation.
|
|
20
|
-
*
|
|
21
|
-
* @see ../../../../refs/smithy/docs/source-2.0/aws/protocols/aws-json.rst.template (Empty body serialization)
|
|
22
|
-
* @see ../../../../node_modules/effect/src/http-api/HttpApiSchema.ts (asText)
|
|
23
|
-
* @see ../../../../node_modules/effect/src/Schema.ts (fromJsonString and decodeTo)
|
|
24
|
-
*/
|
|
25
|
-
export const awsJsonRpcEmptyOutput = (contentType: string) =>
|
|
26
|
-
Schema.Union([
|
|
27
|
-
Schema.Literal(""),
|
|
28
|
-
Schema.fromJsonString(Schema.Struct({})),
|
|
29
|
-
]).pipe(
|
|
30
|
-
Schema.decodeTo(Schema.Void, {
|
|
31
|
-
decode: SchemaGetter.transform(() => undefined),
|
|
32
|
-
encode: SchemaGetter.transform(() => ""),
|
|
33
|
-
}),
|
|
34
|
-
HttpApiSchema.asText({ contentType }),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The optionalRestJsonMember codec treats a null structure member as absent
|
|
39
|
-
* when it reads an AWS reply. Optional members still encode through their
|
|
40
|
-
* original field schemas.
|
|
41
|
-
*
|
|
42
|
-
* @see ../../../../refs/smithy/smithy-aws-protocol-tests/model/restJson1/json-structs.smithy (RestJsonDoesntDeserializeNullStructureValues)
|
|
43
|
-
* @see ../../../../../command-options-fund/refs/effect/packages/effect/src/SchemaGetter.ts (transformOptional)
|
|
44
|
-
*/
|
|
45
|
-
export const optionalRestJsonMember = <Field extends Schema.Top>(
|
|
46
|
-
field: Field,
|
|
47
|
-
) =>
|
|
48
|
-
Schema.optionalKey(Schema.NullOr(field)).pipe(
|
|
49
|
-
Schema.decodeTo(Schema.optionalKey(Schema.toType(field)), {
|
|
50
|
-
decode: SchemaGetter.transformOptional((value) =>
|
|
51
|
-
Option.filter(value, Predicate.isNotNull),
|
|
52
|
-
),
|
|
53
|
-
encode: SchemaGetter.passthroughSupertype(),
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The awsHttpEndpoint function binds the Smithy path labels and success
|
|
59
|
-
* statuses to Effect's HTTP contract. HttpApiClient encodes parameters and
|
|
60
|
-
* decodes the response after AWS signing and transport.
|
|
61
|
-
*
|
|
62
|
-
* @see ../../../../../command-options-fund/refs/effect/packages/effect/src/http-api/HttpApiClient.ts (makeWith)
|
|
63
|
-
* @see ../../../../refs/smithy/docs/source-2.0/spec/http-bindings.rst (httpLabel)
|
|
64
|
-
*/
|
|
65
|
-
export const awsHttpEndpoint = <
|
|
66
|
-
Name extends string,
|
|
67
|
-
Success extends Schema.Top,
|
|
68
|
-
>(
|
|
69
|
-
name: Name,
|
|
70
|
-
operation: AwsOperation & { readonly output: Success },
|
|
71
|
-
) => {
|
|
72
|
-
const bindings = operation.rest?.bindings ?? {};
|
|
73
|
-
|
|
74
|
-
const labels = Record.filter(
|
|
75
|
-
bindings,
|
|
76
|
-
(binding) => binding.location === "LABEL",
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const fields = Record.fromEntries(
|
|
80
|
-
Arr.map(Record.values(labels), ({ name }) =>
|
|
81
|
-
Tuple.make(name, Schema.String),
|
|
82
|
-
),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const path = Str.replace(/\{([^}]+)\}/g, ":$1")(operation.path);
|
|
86
|
-
|
|
87
|
-
const success = Option.match(Option.fromUndefinedOr(operation.rest), {
|
|
88
|
-
onNone: () => operation.output,
|
|
89
|
-
onSome: ({ status }) =>
|
|
90
|
-
Arr.map(Arr.ensure(status), (code) =>
|
|
91
|
-
operation.output.pipe(HttpApiSchema.status(code)),
|
|
92
|
-
),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const payload = Option.getOrUndefined(
|
|
96
|
-
Option.liftPredicate(AwsJsonRpcPayload, () => operation.rest?.body ?? true),
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
return HttpApiEndpoint.make(operation.method)(
|
|
100
|
-
name,
|
|
101
|
-
`/${Str.slice(1)(path)}`,
|
|
102
|
-
{
|
|
103
|
-
params: fields,
|
|
104
|
-
headers: HttpFields,
|
|
105
|
-
query: HttpFields,
|
|
106
|
-
payload,
|
|
107
|
-
success,
|
|
108
|
-
},
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* The awsHttpRequest function places each encoded Smithy member in the
|
|
114
|
-
* location selected by its HTTP binding. The declaration schema has already
|
|
115
|
-
* checked the values. The remaining members form the JSON document.
|
|
116
|
-
*
|
|
117
|
-
* @see ../../../../refs/smithy/docs/source-2.0/spec/http-bindings.rst (HTTP message bindings)
|
|
118
|
-
*/
|
|
119
|
-
export const awsHttpRequest = (
|
|
120
|
-
operation: AwsOperation,
|
|
121
|
-
encoded: AwsJsonRpcPayload,
|
|
122
|
-
) => {
|
|
123
|
-
const bindings = operation.rest?.bindings ?? {};
|
|
124
|
-
|
|
125
|
-
const bound = Record.toEntries(
|
|
126
|
-
Record.filter(encoded, (_, name) => Record.has(bindings, name)),
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const fieldsFor = (location: "LABEL" | "HEADER" | "QUERY") => {
|
|
130
|
-
const selected = Arr.filter(
|
|
131
|
-
bound,
|
|
132
|
-
([field]) => bindings[field].location === location,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return Record.fromEntries(
|
|
136
|
-
Arr.map(selected, ([field, value]) =>
|
|
137
|
-
Tuple.make(bindings[field].name, String(value)),
|
|
138
|
-
),
|
|
139
|
-
);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const payload = Record.filter(
|
|
143
|
-
encoded,
|
|
144
|
-
(_, name) => !Record.has(bindings, name),
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
params: fieldsFor("LABEL"),
|
|
149
|
-
headers: fieldsFor("HEADER"),
|
|
150
|
-
query: fieldsFor("QUERY"),
|
|
151
|
-
payload,
|
|
152
|
-
};
|
|
153
|
-
};
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type QuerySerializerSettings,
|
|
3
|
-
QueryShapeSerializer,
|
|
4
|
-
type XmlSettings,
|
|
5
|
-
XmlShapeDeserializer,
|
|
6
|
-
} from "@aws-sdk/core/protocols";
|
|
7
|
-
import type { DocumentSchema, TimestampDateTimeSchema } from "@smithy/types";
|
|
8
|
-
import { Effect, Match, Option, Record, Schema, String as Str } from "effect";
|
|
9
|
-
import { HttpClientRequest, type HttpClientResponse } from "effect/http";
|
|
10
|
-
import {
|
|
11
|
-
type AwsJsonRpcPayload,
|
|
12
|
-
type AwsQueryOperation,
|
|
13
|
-
AwsRequestError,
|
|
14
|
-
type AwsServiceDefinition,
|
|
15
|
-
} from "./awsClientModel.js";
|
|
16
|
-
|
|
17
|
-
const settings = (
|
|
18
|
-
service: AwsServiceDefinition,
|
|
19
|
-
): QuerySerializerSettings & XmlSettings => ({
|
|
20
|
-
serviceNamespace: Str.split("#")(service.service)[0],
|
|
21
|
-
xmlNamespace: service.xmlNamespace ?? "",
|
|
22
|
-
httpBindings: false,
|
|
23
|
-
serializeEmptyLists: true,
|
|
24
|
-
timestampFormat: {
|
|
25
|
-
useTrait: true,
|
|
26
|
-
default: 5 satisfies TimestampDateTimeSchema,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The awsQueryRequest function supplies the action and API version required
|
|
32
|
-
* by AWS Query. The SDK serializer applies modeled names and list encoding
|
|
33
|
-
* before the shared AWS client signs the request body.
|
|
34
|
-
*
|
|
35
|
-
* @see ../../../../refs/smithy/docs/source-2.0/aws/protocols/aws-query-protocol.rst (Operation request serialization)
|
|
36
|
-
* @see ../../../../refs/aws-sdk-js-v3/packages-internal/core/src/submodules/protocols/query/QueryShapeSerializer.ts (write and flush)
|
|
37
|
-
*/
|
|
38
|
-
export const awsQueryRequest = Effect.fn("AwsQuery.request")(function* (
|
|
39
|
-
service: AwsServiceDefinition,
|
|
40
|
-
operation: AwsQueryOperation,
|
|
41
|
-
payload: AwsJsonRpcPayload,
|
|
42
|
-
) {
|
|
43
|
-
const members = yield* Effect.try({
|
|
44
|
-
try: () => {
|
|
45
|
-
const serializer = new QueryShapeSerializer(settings(service));
|
|
46
|
-
|
|
47
|
-
serializer.write(operation.query.input, payload);
|
|
48
|
-
|
|
49
|
-
return serializer.flush();
|
|
50
|
-
},
|
|
51
|
-
catch: () =>
|
|
52
|
-
new AwsRequestError({
|
|
53
|
-
message: `Could not serialize ${operation.name} as AWS Query`,
|
|
54
|
-
}),
|
|
55
|
-
}).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.String)));
|
|
56
|
-
|
|
57
|
-
const parameters = new URLSearchParams({
|
|
58
|
-
Action: operation.name,
|
|
59
|
-
Version: service.version,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const body = `${parameters}${members}`;
|
|
63
|
-
|
|
64
|
-
return HttpClientRequest.post(operation.path).pipe(
|
|
65
|
-
HttpClientRequest.bodyText(body, "application/x-www-form-urlencoded"),
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The awsQueryOutput function uses the generated Smithy result shape to read
|
|
71
|
-
* the operation's XML result. The JSON encoding preserves the date strings
|
|
72
|
-
* used by Nomoss's generated Effect schemas.
|
|
73
|
-
*
|
|
74
|
-
* @see ../../../../refs/aws-sdk-js-v3/packages-internal/core/src/submodules/protocols/query/AwsQueryProtocol.ts (deserializeResponse)
|
|
75
|
-
*/
|
|
76
|
-
export const awsQueryOutput = (
|
|
77
|
-
service: AwsServiceDefinition,
|
|
78
|
-
operation: AwsQueryOperation,
|
|
79
|
-
response: HttpClientResponse.HttpClientResponse,
|
|
80
|
-
) =>
|
|
81
|
-
Match.value(operation.query.output).pipe(
|
|
82
|
-
Match.when("unit", () => Effect.succeed(undefined)),
|
|
83
|
-
Match.orElse((shape) =>
|
|
84
|
-
response.text.pipe(
|
|
85
|
-
Effect.flatMap((xml) =>
|
|
86
|
-
Effect.try({
|
|
87
|
-
try: (): unknown =>
|
|
88
|
-
new XmlShapeDeserializer(settings(service)).read(
|
|
89
|
-
shape,
|
|
90
|
-
xml,
|
|
91
|
-
`${operation.name}Result`,
|
|
92
|
-
),
|
|
93
|
-
catch: () =>
|
|
94
|
-
new AwsRequestError({
|
|
95
|
-
message: `Could not decode the ${operation.name} AWS Query response`,
|
|
96
|
-
}),
|
|
97
|
-
}),
|
|
98
|
-
),
|
|
99
|
-
Effect.flatMap(
|
|
100
|
-
Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown)),
|
|
101
|
-
),
|
|
102
|
-
Effect.flatMap(
|
|
103
|
-
Schema.decodeEffect(Schema.fromJsonString(Schema.JsonObject)),
|
|
104
|
-
),
|
|
105
|
-
),
|
|
106
|
-
),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The awsQueryErrorBody function reads the error fields used by the common
|
|
111
|
-
* decoder. AWS Query returns the provider code and request ID as XML fields.
|
|
112
|
-
*
|
|
113
|
-
* @see ../../../../refs/smithy/docs/source-2.0/aws/protocols/aws-query-protocol.rst (Operation error serialization)
|
|
114
|
-
*/
|
|
115
|
-
export const awsQueryErrorBody = (
|
|
116
|
-
service: AwsServiceDefinition,
|
|
117
|
-
response: HttpClientResponse.HttpClientResponse,
|
|
118
|
-
) =>
|
|
119
|
-
response.text.pipe(
|
|
120
|
-
Effect.flatMap((xml) =>
|
|
121
|
-
Effect.try({
|
|
122
|
-
try: (): unknown =>
|
|
123
|
-
new XmlShapeDeserializer(settings(service)).read(
|
|
124
|
-
15 satisfies DocumentSchema,
|
|
125
|
-
xml,
|
|
126
|
-
),
|
|
127
|
-
catch: () =>
|
|
128
|
-
new AwsRequestError({
|
|
129
|
-
message: "Could not decode AWS Query error response",
|
|
130
|
-
}),
|
|
131
|
-
}),
|
|
132
|
-
),
|
|
133
|
-
Effect.flatMap(
|
|
134
|
-
Schema.decodeUnknownEffect(
|
|
135
|
-
Schema.Struct({
|
|
136
|
-
Error: Schema.JsonObject,
|
|
137
|
-
RequestId: Schema.optionalKey(Schema.String),
|
|
138
|
-
}),
|
|
139
|
-
),
|
|
140
|
-
),
|
|
141
|
-
Effect.map(({ Error: fields, RequestId }) =>
|
|
142
|
-
Option.fromUndefinedOr(RequestId).pipe(
|
|
143
|
-
Option.match({
|
|
144
|
-
onNone: () => fields,
|
|
145
|
-
onSome: (id) => Record.set(fields, "RequestId", id),
|
|
146
|
-
}),
|
|
147
|
-
),
|
|
148
|
-
),
|
|
149
|
-
);
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { Sha256 } from "@smithy/core/checksum";
|
|
2
|
-
import { SignatureV4 } from "@smithy/signature-v4";
|
|
3
|
-
import {
|
|
4
|
-
Array as Arr,
|
|
5
|
-
Context,
|
|
6
|
-
Data,
|
|
7
|
-
DateTime,
|
|
8
|
-
Effect,
|
|
9
|
-
Match,
|
|
10
|
-
Option,
|
|
11
|
-
Record,
|
|
12
|
-
Tuple,
|
|
13
|
-
} from "effect";
|
|
14
|
-
import { HttpClientRequest } from "effect/http";
|
|
15
|
-
import type { AwsCredentials } from "./awsClientConfig.js";
|
|
16
|
-
|
|
17
|
-
export interface AwsSigningContext {
|
|
18
|
-
readonly credentials: AwsCredentials;
|
|
19
|
-
readonly region: string;
|
|
20
|
-
readonly signingName: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class AwsRequestSigningError extends Data.TaggedError(
|
|
24
|
-
"AwsRequestSigningError",
|
|
25
|
-
)<{
|
|
26
|
-
readonly message: string;
|
|
27
|
-
}> {}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* AwsRequestSigner applies SigV4 to the serialized request that AwsClient will
|
|
31
|
-
* send. Its public API uses Nomoss credentials and signing context so AWS
|
|
32
|
-
* implementation types remain internal to signing.
|
|
33
|
-
*/
|
|
34
|
-
export class AwsRequestSigner extends Context.Service<AwsRequestSigner>()(
|
|
35
|
-
"nomoss/providers/aws/client/awsRequestSigner",
|
|
36
|
-
{
|
|
37
|
-
make: Effect.sync(() => {
|
|
38
|
-
/**
|
|
39
|
-
* The signRequest service method signs the final URL and headers with
|
|
40
|
-
* the prepared body or the empty payload. A retry can refresh its
|
|
41
|
-
* credentials and sign the same serialized request again.
|
|
42
|
-
*/
|
|
43
|
-
const signRequest = Effect.fn("AwsRequestSigner.signRequest")(function* (
|
|
44
|
-
request: HttpClientRequest.HttpClientRequest,
|
|
45
|
-
context: AwsSigningContext,
|
|
46
|
-
) {
|
|
47
|
-
const url = yield* HttpClientRequest.toUrl(request).pipe(
|
|
48
|
-
Effect.fromOption,
|
|
49
|
-
Effect.mapError(
|
|
50
|
-
() =>
|
|
51
|
-
new AwsRequestSigningError({
|
|
52
|
-
message: "Invalid AWS request URL",
|
|
53
|
-
}),
|
|
54
|
-
),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const body = yield* Match.value(request.body).pipe(
|
|
58
|
-
Match.tag("Empty", () => Effect.succeed(undefined)),
|
|
59
|
-
Match.tag("Uint8Array", (value) => Effect.succeed(value.body)),
|
|
60
|
-
Match.orElse(() =>
|
|
61
|
-
Effect.fail(
|
|
62
|
-
new AwsRequestSigningError({
|
|
63
|
-
message: "AWS request signing requires a serialized body",
|
|
64
|
-
}),
|
|
65
|
-
),
|
|
66
|
-
),
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const signingDate = DateTime.toDateUtc(yield* DateTime.now);
|
|
70
|
-
|
|
71
|
-
const signed = yield* Effect.tryPromise({
|
|
72
|
-
try: () =>
|
|
73
|
-
new SignatureV4({
|
|
74
|
-
credentials: context.credentials,
|
|
75
|
-
region: context.region,
|
|
76
|
-
service: context.signingName,
|
|
77
|
-
sha256: Sha256,
|
|
78
|
-
}).sign(
|
|
79
|
-
{
|
|
80
|
-
protocol: url.protocol,
|
|
81
|
-
hostname: url.hostname,
|
|
82
|
-
port: Option.getOrUndefined(
|
|
83
|
-
Option.liftPredicate(url.port, (port) => port !== "").pipe(
|
|
84
|
-
Option.map(Number),
|
|
85
|
-
),
|
|
86
|
-
),
|
|
87
|
-
method: request.method,
|
|
88
|
-
path: url.pathname,
|
|
89
|
-
query: Record.fromEntries(
|
|
90
|
-
Arr.map(
|
|
91
|
-
Arr.dedupe(Arr.fromIterable(url.searchParams.keys())),
|
|
92
|
-
(key) => Tuple.make(key, url.searchParams.getAll(key)),
|
|
93
|
-
),
|
|
94
|
-
),
|
|
95
|
-
headers: { ...request.headers, host: url.host },
|
|
96
|
-
body,
|
|
97
|
-
},
|
|
98
|
-
{ signingDate },
|
|
99
|
-
),
|
|
100
|
-
catch: () =>
|
|
101
|
-
new AwsRequestSigningError({
|
|
102
|
-
message: "AWS request signing failed",
|
|
103
|
-
}),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const signedRequest: HttpClientRequest.HttpClientRequest =
|
|
107
|
-
HttpClientRequest.setHeaders(request, signed.headers);
|
|
108
|
-
|
|
109
|
-
return signedRequest;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
return { signRequest };
|
|
113
|
-
}),
|
|
114
|
-
},
|
|
115
|
-
) {}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Array as Arr,
|
|
3
|
-
Context,
|
|
4
|
-
Effect,
|
|
5
|
-
Match,
|
|
6
|
-
Option,
|
|
7
|
-
Record,
|
|
8
|
-
Schema,
|
|
9
|
-
String as Str,
|
|
10
|
-
} from "effect";
|
|
11
|
-
import type { HttpClientResponse } from "effect/http";
|
|
12
|
-
import {
|
|
13
|
-
type AwsHttpOperation,
|
|
14
|
-
type AwsServiceDefinition,
|
|
15
|
-
AwsServiceError,
|
|
16
|
-
} from "./awsClientModel.js";
|
|
17
|
-
import { awsQueryErrorBody } from "./awsQueryOperation.js";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* AwsResponseDecoder converts unsuccessful AWS HTTP responses into provider
|
|
21
|
-
* failures used by retry handling and lifecycle diagnostics. Modeled error
|
|
22
|
-
* identity and details remain available to both consumers.
|
|
23
|
-
*/
|
|
24
|
-
export class AwsResponseDecoder extends Context.Service<AwsResponseDecoder>()(
|
|
25
|
-
"nomoss/providers/aws/client/awsResponseDecoder",
|
|
26
|
-
{
|
|
27
|
-
make: Effect.sync(() => {
|
|
28
|
-
/**
|
|
29
|
-
* The decodeError service method identifies a failure from the AWS
|
|
30
|
-
* error header or a code in the response body. If the code matches a
|
|
31
|
-
* generated error, the method validates the details before returning
|
|
32
|
-
* them for diagnostics and retry decisions.
|
|
33
|
-
*/
|
|
34
|
-
const decodeError = Effect.fn("AwsResponseDecoder.decodeError")(
|
|
35
|
-
function* (
|
|
36
|
-
service: AwsServiceDefinition,
|
|
37
|
-
operation: AwsHttpOperation,
|
|
38
|
-
response: HttpClientResponse.HttpClientResponse,
|
|
39
|
-
) {
|
|
40
|
-
const body: Readonly<Record<string, Schema.Json>> =
|
|
41
|
-
yield* Match.value(service.protocol).pipe(
|
|
42
|
-
Match.when("awsQuery", () =>
|
|
43
|
-
awsQueryErrorBody(service, response),
|
|
44
|
-
),
|
|
45
|
-
Match.orElse(() =>
|
|
46
|
-
response.json.pipe(
|
|
47
|
-
Effect.flatMap(Schema.decodeUnknownEffect(Schema.JsonObject)),
|
|
48
|
-
),
|
|
49
|
-
),
|
|
50
|
-
Effect.orElseSucceed(() => ({})),
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const code: string = Option.fromUndefinedOr(
|
|
54
|
-
response.headers["x-amzn-errortype"],
|
|
55
|
-
).pipe(
|
|
56
|
-
Option.orElse(() =>
|
|
57
|
-
Record.get(body, "__type").pipe(
|
|
58
|
-
Option.filter(Schema.is(Schema.String)),
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
Option.orElse(() =>
|
|
62
|
-
Record.get(body, "code").pipe(
|
|
63
|
-
Option.filter(Schema.is(Schema.String)),
|
|
64
|
-
),
|
|
65
|
-
),
|
|
66
|
-
Option.orElse(() =>
|
|
67
|
-
Record.get(body, "Code").pipe(
|
|
68
|
-
Option.filter(Schema.is(Schema.String)),
|
|
69
|
-
),
|
|
70
|
-
),
|
|
71
|
-
Option.map((name) => Str.split(name, "#")),
|
|
72
|
-
Option.flatMap(Arr.last),
|
|
73
|
-
Option.map((name) => Str.split(name, ":")[0]),
|
|
74
|
-
Option.match({
|
|
75
|
-
onNone: () => "UnknownError",
|
|
76
|
-
onSome: (code) => code,
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const modeled = Arr.findFirst(
|
|
81
|
-
operation.errors,
|
|
82
|
-
(error) => (error.code ?? error.name) === code,
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const details = yield* Option.match(modeled, {
|
|
86
|
-
onNone: () => Effect.succeed(body),
|
|
87
|
-
onSome: (error) => Schema.decodeUnknownEffect(error.schema)(body),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const message = Option.fromNullishOr(body.Message).pipe(
|
|
91
|
-
Option.orElse(() => Option.fromUndefinedOr(body.message)),
|
|
92
|
-
Option.filter(Schema.is(Schema.String)),
|
|
93
|
-
Option.match({
|
|
94
|
-
onSome: (message) => message,
|
|
95
|
-
onNone: () =>
|
|
96
|
-
`${operation.name} failed with HTTP ${response.status} (${code})`,
|
|
97
|
-
}),
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const failure: AwsServiceError = new AwsServiceError({
|
|
101
|
-
service: service.service,
|
|
102
|
-
operation: operation.name,
|
|
103
|
-
code,
|
|
104
|
-
statusCode: response.status,
|
|
105
|
-
requestId: Option.fromUndefinedOr(
|
|
106
|
-
response.headers["x-amzn-requestid"],
|
|
107
|
-
).pipe(
|
|
108
|
-
Option.orElse(() =>
|
|
109
|
-
Record.get(body, "RequestId").pipe(
|
|
110
|
-
Option.filter(Schema.is(Schema.String)),
|
|
111
|
-
),
|
|
112
|
-
),
|
|
113
|
-
Option.orElse(() =>
|
|
114
|
-
Option.fromUndefinedOr(response.headers["x-amz-request-id"]),
|
|
115
|
-
),
|
|
116
|
-
Option.getOrUndefined,
|
|
117
|
-
),
|
|
118
|
-
retryAfter: response.headers["retry-after"],
|
|
119
|
-
message,
|
|
120
|
-
retryable:
|
|
121
|
-
response.status === 408 ||
|
|
122
|
-
response.status === 429 ||
|
|
123
|
-
response.status >= 500 ||
|
|
124
|
-
Option.exists(modeled, (error) => error.retryable !== null),
|
|
125
|
-
details,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return failure;
|
|
129
|
-
},
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return { decodeError };
|
|
133
|
-
}),
|
|
134
|
-
},
|
|
135
|
-
) {}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Clock,
|
|
3
|
-
Context,
|
|
4
|
-
DateTime,
|
|
5
|
-
Effect,
|
|
6
|
-
Number as Num,
|
|
7
|
-
Option,
|
|
8
|
-
Random,
|
|
9
|
-
Schema,
|
|
10
|
-
} from "effect";
|
|
11
|
-
|
|
12
|
-
export interface AwsRetryContext {
|
|
13
|
-
readonly attempt: number;
|
|
14
|
-
readonly retryAfter: string | undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* AwsRetryPolicy calculates the delay before another attempt at a failed AWS
|
|
19
|
-
* request. Its backoff includes jitter and honors a valid Retry-After value.
|
|
20
|
-
* Attempt limits and interruption of the wait belong to AwsClient execution.
|
|
21
|
-
*/
|
|
22
|
-
export class AwsRetryPolicy extends Context.Service<AwsRetryPolicy>()(
|
|
23
|
-
"nomoss/providers/aws/client/awsRetryPolicy",
|
|
24
|
-
{
|
|
25
|
-
make: Effect.sync(() => {
|
|
26
|
-
/**
|
|
27
|
-
* retryDelay returns the delay for the next request attempt. A valid
|
|
28
|
-
* Retry-After value prevents an attempt earlier than AWS requested.
|
|
29
|
-
*/
|
|
30
|
-
const retryDelay = Effect.fn("AwsRetryPolicy.retryDelay")(function* (
|
|
31
|
-
context: AwsRetryContext,
|
|
32
|
-
) {
|
|
33
|
-
const now = yield* Clock.currentTimeMillis;
|
|
34
|
-
const jitter = yield* Random.next;
|
|
35
|
-
const backoff =
|
|
36
|
-
jitter * Num.min(20_000, 100 * 2 ** (context.attempt - 1));
|
|
37
|
-
|
|
38
|
-
const providerDelay = Option.fromUndefinedOr(context.retryAfter).pipe(
|
|
39
|
-
Option.flatMap((hint) =>
|
|
40
|
-
Option.match(
|
|
41
|
-
Schema.decodeUnknownOption(Schema.Finite)(Number(hint)),
|
|
42
|
-
{
|
|
43
|
-
onSome: (seconds) => Option.some(seconds * 1000),
|
|
44
|
-
onNone: () =>
|
|
45
|
-
DateTime.make(hint).pipe(
|
|
46
|
-
Option.map((date) => DateTime.toEpochMillis(date) - now),
|
|
47
|
-
),
|
|
48
|
-
},
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
Option.getOrElse(() => 0),
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const delay: number = Num.max(backoff, providerDelay);
|
|
55
|
-
|
|
56
|
-
return delay;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return { retryDelay };
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
) {}
|