@intentius/chant-lexicon-cedar 0.44.14 → 0.46.0

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 (49) hide show
  1. package/README.md +13 -4
  2. package/dist/avp/client.d.ts +18 -0
  3. package/dist/avp/client.d.ts.map +1 -1
  4. package/dist/codegen/docs.d.ts +5 -9
  5. package/dist/codegen/docs.d.ts.map +1 -1
  6. package/dist/codegen/generate.d.ts +35 -8
  7. package/dist/codegen/generate.d.ts.map +1 -1
  8. package/dist/commands.d.ts +14 -0
  9. package/dist/commands.d.ts.map +1 -0
  10. package/dist/config.d.ts +38 -2
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/index.d.ts +5 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/init-templates.d.ts +1 -1
  15. package/dist/integrity.json +4 -4
  16. package/dist/lint/post-synth/cede010.d.ts +5 -4
  17. package/dist/lint/post-synth/cede010.d.ts.map +1 -1
  18. package/dist/manifest.json +1 -1
  19. package/dist/plugin.d.ts.map +1 -1
  20. package/dist/rules/cede010.ts +5 -4
  21. package/dist/schema-artifact.d.ts +50 -0
  22. package/dist/schema-artifact.d.ts.map +1 -0
  23. package/dist/serializer.d.ts.map +1 -1
  24. package/dist/skills/chant-cedar-authoring.md +9 -3
  25. package/dist/spec/fetch.d.ts.map +1 -1
  26. package/package.json +2 -2
  27. package/src/avp/OWNERSHIP.md +4 -1
  28. package/src/avp/client.test.ts +35 -0
  29. package/src/avp/client.ts +29 -2
  30. package/src/codegen/docs.ts +5 -799
  31. package/src/codegen/generate-cli.ts +8 -6
  32. package/src/codegen/generate.ts +63 -14
  33. package/src/codegen/output-dir.test.ts +137 -0
  34. package/src/commands.test.ts +93 -0
  35. package/src/commands.ts +95 -0
  36. package/src/config.ts +50 -4
  37. package/src/index.ts +10 -2
  38. package/src/init-templates.test.ts +22 -4
  39. package/src/init-templates.ts +16 -16
  40. package/src/lint/post-synth/cede010.ts +5 -4
  41. package/src/plugin.ts +33 -8
  42. package/src/schema-artifact.test.ts +160 -0
  43. package/src/schema-artifact.ts +87 -0
  44. package/src/serializer.ts +17 -1
  45. package/src/skills/chant-cedar-authoring.md +9 -3
  46. package/src/spec/fetch.ts +23 -2
  47. package/dist/codegen/docs-dogwood.d.ts +0 -21
  48. package/dist/codegen/docs-dogwood.d.ts.map +0 -1
  49. package/src/codegen/docs-dogwood.ts +0 -1119
package/src/avp/client.ts CHANGED
@@ -45,6 +45,15 @@
45
45
  * signing against one would make every local lane need credentials to read
46
46
  * what it just deployed. `signEndpointOverride` opts back in for an
47
47
  * override that *is* real AWS — a VPC endpoint, a signing proxy.
48
+ *
49
+ * What counts as an override is {@link resolveEndpointOverride}: the
50
+ * `endpoint` option, else `AWS_ENDPOINT_URL_VERIFIEDPERMISSIONS`, else
51
+ * `AWS_ENDPOINT_URL` — the AWS SDK's own precedence, and the same rule the aws
52
+ * lexicon's `api/read-client.ts` applies to every transport it owns (#1694).
53
+ * It is restated here rather than imported for the reason above: cedar does
54
+ * not depend on the aws lexicon, and a lexicon build compiles against the
55
+ * published core, so a helper hoisted into core would reach neither lexicon
56
+ * until the next core release.
48
57
  */
49
58
 
50
59
  const DEFAULT_REGION = "us-east-1";
@@ -166,6 +175,24 @@ export function avpUrl(endpoint?: string, region = DEFAULT_REGION): string {
166
175
  return `${(endpoint ?? `https://${SERVICE}.${region}.amazonaws.com`).replace(/\/$/, "")}/`;
167
176
  }
168
177
 
178
+ /** The service-specific endpoint variable the AWS SDK reads for Verified Permissions. */
179
+ const SERVICE_ENDPOINT_ENV_VAR = "AWS_ENDPOINT_URL_VERIFIEDPERMISSIONS";
180
+
181
+ /**
182
+ * The one rule for what an endpoint override is (#1694): the `endpoint`
183
+ * option when given, else `AWS_ENDPOINT_URL_VERIFIEDPERMISSIONS`, else the
184
+ * ambient `AWS_ENDPOINT_URL`. The result is both the target and, through
185
+ * {@link requestHeaders}, the fact that decides whether the request is signed.
186
+ * Returns `undefined` for real AWS. Mirrors the aws lexicon's
187
+ * `resolveEndpointOverride` for this one service.
188
+ */
189
+ export function resolveEndpointOverride(
190
+ endpoint: string | undefined,
191
+ env: Record<string, string | undefined> = process.env,
192
+ ): string | undefined {
193
+ return endpoint || env[SERVICE_ENDPOINT_ENV_VAR] || env.AWS_ENDPOINT_URL || undefined;
194
+ }
195
+
169
196
  /**
170
197
  * Whether this process has anything to authenticate with.
171
198
  *
@@ -176,7 +203,7 @@ export function avpUrl(endpoint?: string, region = DEFAULT_REGION): string {
176
203
  */
177
204
  export function credentialsAvailable(env: Record<string, string | undefined> = process.env): boolean {
178
205
  return Boolean(
179
- env.AWS_ENDPOINT_URL ||
206
+ resolveEndpointOverride(undefined, env) ||
180
207
  env.AWS_ACCESS_KEY_ID ||
181
208
  env.AWS_PROFILE ||
182
209
  env.AWS_SESSION_TOKEN ||
@@ -256,7 +283,7 @@ export async function avpCall(
256
283
  ): Promise<Record<string, unknown>> {
257
284
  const env = options.env ?? process.env;
258
285
  const http = options.http ?? defaultHttp;
259
- const endpoint = options.endpoint ?? env.AWS_ENDPOINT_URL;
286
+ const endpoint = resolveEndpointOverride(options.endpoint, env);
260
287
  const url = avpUrl(endpoint, options.region);
261
288
  const payloadJson = JSON.stringify(payload);
262
289
  const res = await http(